Skip to content

Commit

Permalink
chore: 🤖 copy fleek function assets
Browse files Browse the repository at this point in the history
  • Loading branch information
heldrida committed Oct 29, 2024
1 parent be190b2 commit 6d93d4e
Showing 1 changed file with 24 additions and 41 deletions.
65 changes: 24 additions & 41 deletions src/clients/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type DeployFleekFunctionArgs = {
cid: string;
sgx?: boolean;
blake3Hash?: string;
assetsCid?: string;
};
export type ListFleekFunctionArgs = {
functionId: string;
Expand All @@ -41,36 +42,33 @@ export type ListFleekFunctionArgs = {
export class FunctionsClient {
private graphqlClient: Client;

private static Deployment_MAPPED_PROPERTIES: FleekFunctionDeploymentGenqlSelection =
{
id: true,
fleekFunctionId: true,
private static Deployment_MAPPED_PROPERTIES: FleekFunctionDeploymentGenqlSelection = {
id: true,
fleekFunctionId: true,
cid: true,
updatedAt: true,
createdAt: true,
};

private static FleekFunction_MAPPED_PROPERTIES: FleekFunctionGenqlSelection = {
id: true,
name: true,
slug: true,
invokeUrl: true,
projectId: true,
currentDeploymentId: true,
currentDeployment: {
cid: true,
updatedAt: true,
createdAt: true,
};

private static FleekFunction_MAPPED_PROPERTIES: FleekFunctionGenqlSelection =
{
id: true,
name: true,
slug: true,
invokeUrl: true,
projectId: true,
currentDeploymentId: true,
currentDeployment: {
cid: true,
},
status: true,
};
},
status: true,
};

constructor(options: FunctionsClientOptions) {
this.graphqlClient = options.graphqlClient;
}

public get = async ({ name }: GetFleekFunctionArgs) => {
const response = await this.graphqlClient.query({
__name: 'GetFleekFunctionByName',
fleekFunctionByName: {
__args: {
where: {
Expand All @@ -86,7 +84,6 @@ export class FunctionsClient {

public list = async () => {
const response = await this.graphqlClient.query({
__name: 'GetFleekFunctions',
fleekFunctions: {
__args: {},
data: {
Expand All @@ -98,9 +95,7 @@ export class FunctionsClient {
return response.fleekFunctions.data;
};

public listDeployments = async ({
functionId,
}: ListFleekFunctionArgs): Promise<FleekFunctionDeployment[]> => {
public listDeployments = async ({ functionId }: ListFleekFunctionArgs): Promise<FleekFunctionDeployment[]> => {
const response = await this.graphqlClient.query({
fleekFunctionDeployments: {
__args: {
Expand All @@ -119,7 +114,6 @@ export class FunctionsClient {

public create = async ({ name }: CreateFleekFunctionArgs) => {
const response = await this.graphqlClient.mutation({
__name: 'CreateFleekFunction',
createFleekFunction: {
__args: {
data: {
Expand All @@ -133,20 +127,15 @@ export class FunctionsClient {
return response.createFleekFunction;
};

public deploy = async ({
functionId,
cid,
sgx,
blake3Hash,
}: DeployFleekFunctionArgs): Promise<FleekFunctionDeployment> => {
public deploy = async ({ functionId, cid, sgx, blake3Hash, assetsCid }: DeployFleekFunctionArgs): Promise<FleekFunctionDeployment> => {
const response = await this.graphqlClient.mutation({
triggerFleekFunctionDeployment: {
__args: {
where: {
functionId,
cid,
},
data: { sgx, blake3Hash },
data: { sgx, blake3Hash, assetsCid },
},
...FunctionsClient.Deployment_MAPPED_PROPERTIES,
},
Expand All @@ -157,7 +146,6 @@ export class FunctionsClient {

public delete = async ({ id }: DeleteFleekFunctionArgs) => {
const response = await this.graphqlClient.mutation({
__name: 'DeleteFleekFunction',
deleteFleekFunction: {
__args: {
where: {
Expand All @@ -171,12 +159,7 @@ export class FunctionsClient {
return response.deleteFleekFunction;
};

public update = async ({
id,
slug,
name,
status,
}: UpdateFleekFunctionArgs) => {
public update = async ({ id, slug, name, status }: UpdateFleekFunctionArgs) => {
const response = await this.graphqlClient.mutation({
updateFleekFunction: {
__args: {
Expand Down

0 comments on commit 6d93d4e

Please sign in to comment.