From 57dc302c3a7675c1511acf3d38e434474915aae2 Mon Sep 17 00:00:00 2001 From: Gabriel Pinto Date: Sat, 2 Nov 2024 03:46:19 +0000 Subject: [PATCH 1/4] fix: FleekFunction type inference --- src/clients/functions.ts | 67 ++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/src/clients/functions.ts b/src/clients/functions.ts index 6f1fdfa..8213534 100644 --- a/src/clients/functions.ts +++ b/src/clients/functions.ts @@ -6,12 +6,11 @@ import { FleekFunctionGenqlSelection, FleekFunctionStatus, } from '@fleek-platform/utils-genql-client'; - type FunctionsClientOptions = { graphqlClient: Client; }; -export type FleekFunction = Omit; +export type FleekFunction = Omit; export type GetFleekFunctionArgs = { name: string; @@ -43,34 +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, - }; + }, + siteId: true, + status: true, + }; constructor(options: FunctionsClientOptions) { this.graphqlClient = options.graphqlClient; } - public get = async ({ name }: GetFleekFunctionArgs) => { + public get = async ({ name }: GetFleekFunctionArgs): Promise => { const response = await this.graphqlClient.query({ __name: 'GetFleekFunctionByName', fleekFunctionByName: { @@ -86,7 +84,7 @@ export class FunctionsClient { return response.fleekFunctionByName; }; - public list = async () => { + public list = async (): Promise => { const response = await this.graphqlClient.query({ __name: 'GetFleekFunctions', fleekFunctions: { @@ -100,9 +98,7 @@ export class FunctionsClient { return response.fleekFunctions.data; }; - public listDeployments = async ({ - functionId, - }: ListFleekFunctionArgs): Promise => { + public listDeployments = async ({ functionId }: ListFleekFunctionArgs): Promise => { const response = await this.graphqlClient.query({ fleekFunctionDeployments: { __args: { @@ -136,13 +132,7 @@ export class FunctionsClient { return response.createFleekFunction; }; - public deploy = async ({ - functionId, - cid, - sgx, - blake3Hash, - assetsCid, - }: DeployFleekFunctionArgs): Promise => { + public deploy = async ({ functionId, cid, sgx, blake3Hash, assetsCid }: DeployFleekFunctionArgs): Promise => { const response = await this.graphqlClient.mutation({ triggerFleekFunctionDeployment: { __args: { @@ -175,12 +165,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: { From fdabba1ada1158a1b84505d17e828a5e16235235 Mon Sep 17 00:00:00 2001 From: Gabriel Pinto Date: Sat, 2 Nov 2024 03:49:09 +0000 Subject: [PATCH 2/4] fix: tests --- src/clients/functions.test.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/clients/functions.test.ts b/src/clients/functions.test.ts index 79329b6..f3b7cd6 100644 --- a/src/clients/functions.test.ts +++ b/src/clients/functions.test.ts @@ -1,20 +1,12 @@ -import { - describe, - expect, - it, - vi, - afterAll, - afterEach, - beforeAll, -} from 'vitest'; -import { server } from '../mocks/graphql/node'; -import { mockGraphqlServiceApiUrl as graphqlServiceApiUrl } from '../mocks/graphql/handlers'; +import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'; + import { FleekSdk } from '../FleekSdk'; +import { mockGraphqlServiceApiUrl as graphqlServiceApiUrl } from '../mocks/graphql/handlers'; +import { server } from '../mocks/graphql/node'; import state from '../mocks/state'; vi.mock('@fleek-platform/utils-token', async (importOriginal) => { - const original = - await importOriginal(); + const original = await importOriginal(); return { ...original, @@ -51,6 +43,7 @@ describe('FleekSDK', () => { "invokeUrl": "blue-green-yellow.functions.on-fleek.app", "name": "electronic-co-shop", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "blue-green-yellow", "status": "ACTIVE", } @@ -71,6 +64,7 @@ describe('FleekSDK', () => { "invokeUrl": "red-green-blue.functions.on-fleek.app", "name": "electronicCoLanding", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "red-green-blue", "status": "ACTIVE", }, @@ -81,6 +75,7 @@ describe('FleekSDK', () => { "invokeUrl": "white-black-silver.functions.on-fleek.app", "name": "electronic-co-blog", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "white-black-silver", "status": "ACTIVE", }, @@ -91,6 +86,7 @@ describe('FleekSDK', () => { "invokeUrl": "green-gold-silver.functions.on-fleek.app", "name": "electronic-co-videos", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "green-gold-silver", "status": "ACTIVE", }, @@ -103,6 +99,7 @@ describe('FleekSDK', () => { "invokeUrl": "blue-green-yellow.functions.on-fleek.app", "name": "electronic-co-shop", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "blue-green-yellow", "status": "ACTIVE", }, @@ -113,6 +110,7 @@ describe('FleekSDK', () => { "invokeUrl": "blue-gold-yellow.functions.on-fleek.app", "name": "electronic-co-deprecated", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "blue-gold-yellow", "status": "ACTIVE", }, @@ -135,10 +133,11 @@ describe('FleekSDK', () => { "invokeUrl": "https://crooked-bland-jackal.dev.on-fleek-functions.app", "name": "new-function", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "crooked-bland-jackal", "status": "ACTIVE", } - `, + ` ); }); @@ -155,6 +154,7 @@ describe('FleekSDK', () => { "invokeUrl": "green-gold-silver.functions.on-fleek.app", "name": "electronic-co-videos", "projectId": "clgkiwjd8000c08mefyco2eoo", + "siteId": null, "slug": "green-gold-silver", "status": "ACTIVE", } From ef66882dba86b617b07a86ab5765831f0f922706 Mon Sep 17 00:00:00 2001 From: Gabriel Pinto Date: Sat, 2 Nov 2024 03:57:16 +0000 Subject: [PATCH 3/4] chore: use workspace dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0133f86..b91608b 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@biomejs/biome": "^1.8.3", "@changesets/cli": "^2.27.9", "@fleek-platform/errors": "^2.7.0", - "@fleek-platform/utils-genql-client": "^0.2.1", + "@fleek-platform/utils-genql-client": "workspace:*", "@fleek-platform/utils-token": "^0.2.2", "@jspm/core": "^2.0.1", "@tsconfig/node16": "^16.1.3", From 63414d774fe8bc1ddcf5e243817da2e6ca2bc9dd Mon Sep 17 00:00:00 2001 From: Gabriel Pinto Date: Sat, 2 Nov 2024 05:31:31 +0000 Subject: [PATCH 4/4] chore: bump utils-genql-client --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b91608b..4678d4c 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@biomejs/biome": "^1.8.3", "@changesets/cli": "^2.27.9", "@fleek-platform/errors": "^2.7.0", - "@fleek-platform/utils-genql-client": "workspace:*", + "@fleek-platform/utils-genql-client": "^0.2.2", "@fleek-platform/utils-token": "^0.2.2", "@jspm/core": "^2.0.1", "@tsconfig/node16": "^16.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b511b56..8062e3e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,7 @@ importers: '@biomejs/biome': ^1.8.3 '@changesets/cli': ^2.27.9 '@fleek-platform/errors': ^2.7.0 - '@fleek-platform/utils-genql-client': ^0.2.1 + '@fleek-platform/utils-genql-client': ^0.2.2 '@fleek-platform/utils-token': ^0.2.2 '@jspm/core': ^2.0.1 '@noble/hashes': ^1.4.0 @@ -57,7 +57,7 @@ importers: '@biomejs/biome': 1.9.4 '@changesets/cli': 2.27.9 '@fleek-platform/errors': 2.7.0 - '@fleek-platform/utils-genql-client': 0.2.1 + '@fleek-platform/utils-genql-client': 0.2.2 '@fleek-platform/utils-token': 0.2.2 '@jspm/core': 2.1.0 '@tsconfig/node16': 16.1.3 @@ -637,8 +637,8 @@ packages: nanoid: 3.3.7 dev: true - /@fleek-platform/utils-genql-client/0.2.1: - resolution: {integrity: sha512-q2MtlgH4QkMnHh+1OBuBi0klZIn5UpBnM9VNO3n25EAh/91ppWxdjCV3kNALi/hNV2B+lOeoQDjeiE922lMiBA==} + /@fleek-platform/utils-genql-client/0.2.2: + resolution: {integrity: sha512-Pvfhp85I/cJy6rFd0qGWNwFWqcj+pB7DhFAkLwOJhuBjMpqTetOixqQNVfsOKh9Ho33eLphTEdFFGXoQlVVDUg==} dev: true /@fleek-platform/utils-token/0.2.2: