From dfddc7f2a0e9b6109ea267ace7412afb96e65fe6 Mon Sep 17 00:00:00 2001 From: Himanshu Sharma Date: Sun, 14 Apr 2024 22:39:35 +0530 Subject: [PATCH 1/4] DeployOptions and DeleteOptions added --- package-lock.json | 3 +-- src/protocol.ts | 65 +++++++++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6eeb3d1..1e6e2e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3870,8 +3870,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "ajv": { "version": "6.12.6", diff --git a/src/protocol.ts b/src/protocol.ts index 7f3fff6..5a874cd 100644 --- a/src/protocol.ts +++ b/src/protocol.ts @@ -50,6 +50,21 @@ export interface Branches { branches: [string]; } +export interface DeployOptions { + name: string; + env: { name: string; value: string }[]; + plan: Plans; + resourceType: ResourceType; + release?: string; + version?: string; +} + +export interface deleteOptions { + prefix: string; + suffix: string; + version: string; +} + export interface API { refresh(): Promise; validate(): Promise; @@ -68,19 +83,8 @@ export interface API { branch: string, jsons: MetaCallJSON[] ): Promise; - deploy( - name: string, - env: { name: string; value: string }[], - plan: Plans, - resourceType: ResourceType, - release?: string, - version?: string - ): Promise; - deployDelete( - prefix: string, - suffix: string, - version: string - ): Promise; + deploy(options: DeployOptions): Promise; + deployDelete(options: deleteOptions): Promise; logs( container: string, type: LogType, @@ -211,15 +215,16 @@ export default (token: string, baseURL: string): API => { ) .then((res: AxiosResponse) => res.data as Branches), - deploy: ( - name: string, - env: { name: string; value: string }[], - plan: Plans, - resourceType: ResourceType, - release: string = Date.now().toString(16), - version = 'v1' - ): Promise => - axios + deploy: (options: DeployOptions): Promise => { + const { + name, + env, + plan, + resourceType, + release = Date.now().toString(16), + version = 'v1' + } = options; + return axios .post( baseURL + '/api/deploy/create', { @@ -234,14 +239,12 @@ export default (token: string, baseURL: string): API => { headers: { Authorization: 'jwt ' + token } } ) - .then(res => res.data), + .then(res => res.data); + }, - deployDelete: ( - prefix: string, - suffix: string, - version = 'v1' - ): Promise => - axios + deployDelete: (options: deleteOptions): Promise => { + const { prefix, suffix, version = 'v1' } = options; + return axios .post( baseURL + '/api/deploy/delete', { @@ -253,8 +256,8 @@ export default (token: string, baseURL: string): API => { headers: { Authorization: 'jwt ' + token } } ) - .then(res => res.data), - + .then(res => res.data); + }, logs: ( container: string, type: LogType = LogType.Deploy, From 10d67f12476573f574235bbf0e6453cde150750d Mon Sep 17 00:00:00 2001 From: Himanshu Sharma Date: Sun, 14 Apr 2024 22:40:17 +0530 Subject: [PATCH 2/4] Updating version to v1 --- package-lock.json | 6 +++--- package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e6e2e7..6f4ac51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@metacall/protocol", - "version": "0.1.26", + "version": "1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@metacall/protocol", - "version": "0.1.26", + "version": "1", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -6010,4 +6010,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 21b1c50..c846106 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metacall/protocol", - "version": "0.1.26", + "version": "1", "description": "Tool for deploying into MetaCall FaaS platform.", "exports": { "./*": "./dist/*.js", @@ -111,4 +111,4 @@ "typescript": "4.3.2", "yamljs": "^0.3.0" } -} +} \ No newline at end of file From 9a5e8825b2ce8b94f921b4ff2406a49b4334eeb2 Mon Sep 17 00:00:00 2001 From: Himanshu Sharma Date: Thu, 18 Apr 2024 20:01:20 +0530 Subject: [PATCH 3/4] interface added --- src/deployment.ts | 24 ++++++++++++++++++++++++ src/protocol.ts | 47 +++++++++++++++++++++++++++++++---------------- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/deployment.ts b/src/deployment.ts index 47d3eec..58d0a88 100644 --- a/src/deployment.ts +++ b/src/deployment.ts @@ -104,6 +104,30 @@ export interface Deployment { packages: Record; ports: number[]; } +export class IDeployment implements Deployment { + public status: DeployStatus; + public prefix: string; + public suffix: string; + public version: string; + public packages: Record; + public ports: number[]; + + constructor( + status: DeployStatus, + prefix: string, + suffix: string, + version: string, + packages: Record, + ports: number[] + ) { + this.status = status; + this.prefix = prefix; + this.suffix = suffix; + this.version = version; + this.packages = packages; + this.ports = ports; + } +} export interface Create { suffix: string; diff --git a/src/protocol.ts b/src/protocol.ts index 5a874cd..493ae56 100644 --- a/src/protocol.ts +++ b/src/protocol.ts @@ -50,7 +50,7 @@ export interface Branches { branches: [string]; } -export interface DeployOptions { +export interface DeployBody { name: string; env: { name: string; value: string }[]; plan: Plans; @@ -59,12 +59,21 @@ export interface DeployOptions { version?: string; } -export interface deleteOptions { +export interface DeleteBody { prefix: string; suffix: string; version: string; } +export interface FetchFilesFromRepoBody { + branch: string; + url: string; +} + +export interface FetchBranchListBody { + url: string; +} + export interface API { refresh(): Promise; validate(): Promise; @@ -83,8 +92,8 @@ export interface API { branch: string, jsons: MetaCallJSON[] ): Promise; - deploy(options: DeployOptions): Promise; - deployDelete(options: deleteOptions): Promise; + deploy(options: DeployBody): Promise; + deployDelete(options: DeleteBody): Promise; logs( container: string, type: LogType, @@ -92,8 +101,8 @@ export interface API { prefix: string, version?: string ): Promise; - branchList(url: string): Promise; - fileList(url: string, branch: string): Promise; + branchList(options: FetchBranchListBody): Promise; + fileList(options: FetchFilesFromRepoBody): Promise; } export default (token: string, baseURL: string): API => { @@ -202,8 +211,9 @@ export default (token: string, baseURL: string): API => { } ) .then((res: AxiosResponse) => res.data as AddResponse), - branchList: (url: string): Promise => - axios + branchList: async (options: FetchBranchListBody): Promise => { + const { url } = options; + return await axios .post( baseURL + '/api/repository/branchlist', { @@ -213,9 +223,10 @@ export default (token: string, baseURL: string): API => { headers: { Authorization: 'jwt ' + token } } ) - .then((res: AxiosResponse) => res.data as Branches), + .then((res: AxiosResponse) => res.data as Branches); + }, - deploy: (options: DeployOptions): Promise => { + deploy: async (options: DeployBody): Promise => { const { name, env, @@ -224,7 +235,7 @@ export default (token: string, baseURL: string): API => { release = Date.now().toString(16), version = 'v1' } = options; - return axios + return await axios .post( baseURL + '/api/deploy/create', { @@ -242,9 +253,9 @@ export default (token: string, baseURL: string): API => { .then(res => res.data); }, - deployDelete: (options: deleteOptions): Promise => { + deployDelete: async (options: DeleteBody): Promise => { const { prefix, suffix, version = 'v1' } = options; - return axios + return await axios .post( baseURL + '/api/deploy/delete', { @@ -281,8 +292,11 @@ export default (token: string, baseURL: string): API => { ) .then(res => res.data), - fileList: (url: string, branch: string): Promise => - axios + fileList: async ( + options: FetchFilesFromRepoBody + ): Promise => { + const { url, branch } = options; + return await axios .post<{ [k: string]: string[] }>( baseURL + '/api/repository/filelist', { @@ -293,7 +307,8 @@ export default (token: string, baseURL: string): API => { headers: { Authorization: 'jwt ' + token } } ) - .then(res => res.data['files']) + .then(res => res.data['files']); + } }; return api; From d63948e34e2e2b8002f269d395f49b6a4d40d6a4 Mon Sep 17 00:00:00 2001 From: Himanshu Sharma Date: Thu, 18 Apr 2024 20:01:20 +0530 Subject: [PATCH 4/4] version restored --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c846106..21b1c50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metacall/protocol", - "version": "1", + "version": "0.1.26", "description": "Tool for deploying into MetaCall FaaS platform.", "exports": { "./*": "./dist/*.js", @@ -111,4 +111,4 @@ "typescript": "4.3.2", "yamljs": "^0.3.0" } -} \ No newline at end of file +}