From 4ed7a89a31d198aad6b01bac8dc3b82c9c3aa627 Mon Sep 17 00:00:00 2001 From: Bobby Wang Date: Fri, 13 Oct 2023 18:50:46 +0800 Subject: [PATCH 1/5] add buildship authenticated trigger --- src/components/CodeEditor/extensions.d.ts | 8 ++++++++ .../TableModals/ExtensionsModal/utils.ts | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/components/CodeEditor/extensions.d.ts b/src/components/CodeEditor/extensions.d.ts index 22af5756..a61232b7 100644 --- a/src/components/CodeEditor/extensions.d.ts +++ b/src/components/CodeEditor/extensions.d.ts @@ -128,4 +128,12 @@ type PushNotificationRequest = { type PushNotificationBody = ( context: ExtensionContext ) => Message | Message[] | Promise; + type TaskBody = (context: ExtensionContext) => Promise; + +type BuildshipAuthenticatedTriggerBody = ( + context: ExtensionContext +) => Promise<{ + url: string; + body: string; +}>; diff --git a/src/components/TableModals/ExtensionsModal/utils.ts b/src/components/TableModals/ExtensionsModal/utils.ts index 8254ff42..59587a5f 100644 --- a/src/components/TableModals/ExtensionsModal/utils.ts +++ b/src/components/TableModals/ExtensionsModal/utils.ts @@ -1,4 +1,5 @@ export const extensionTypes = [ + "buildshipAuthenticatedTrigger", "task", "docSync", "historySnapshot", @@ -15,6 +16,7 @@ export const extensionTypes = [ export type ExtensionType = typeof extensionTypes[number]; export const extensionNames: Record = { + buildshipAuthenticatedTrigger: "Buildship Authenticated Trigger", task: "Task", docSync: "Doc Sync", historySnapshot: "History Snapshot", @@ -61,6 +63,18 @@ export interface IRuntimeOptions { export const triggerTypes: ExtensionTrigger[] = ["create", "update", "delete"]; const extensionBodyTemplate = { + buildshipAuthenticatedTrigger: `const extensionBody: BuildshipAuthenticatedTriggerBody = async({row, db, change, ref, logging}) => { + logging.log("extensionBody started") + + // Put your endpoint URL and request body below. + // It will trigger your endpoint with the request body. + return ({ + url: "", + body: JSON.stringify({ + + }) + }) +}`, task: `const extensionBody: TaskBody = async({row, db, change, ref, logging}) => { logging.log("extensionBody started") From fe16570a941bb6631288a34af6384ee5265aff3d Mon Sep 17 00:00:00 2001 From: Bobby Wang Date: Wed, 18 Oct 2023 05:54:11 +0800 Subject: [PATCH 2/5] fix buildship typo --- src/components/TableModals/ExtensionsModal/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TableModals/ExtensionsModal/utils.ts b/src/components/TableModals/ExtensionsModal/utils.ts index 59587a5f..05c5cb6b 100644 --- a/src/components/TableModals/ExtensionsModal/utils.ts +++ b/src/components/TableModals/ExtensionsModal/utils.ts @@ -16,7 +16,7 @@ export const extensionTypes = [ export type ExtensionType = typeof extensionTypes[number]; export const extensionNames: Record = { - buildshipAuthenticatedTrigger: "Buildship Authenticated Trigger", + buildshipAuthenticatedTrigger: "BuildShip Authenticated Trigger", task: "Task", docSync: "Doc Sync", historySnapshot: "History Snapshot", From 1646e99e499c6548001d768f956961da6ead5957 Mon Sep 17 00:00:00 2001 From: Bobby Wang Date: Thu, 19 Oct 2023 06:24:46 +0800 Subject: [PATCH 3/5] add prefilled values for buildship extension --- src/components/TableModals/ExtensionsModal/utils.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/TableModals/ExtensionsModal/utils.ts b/src/components/TableModals/ExtensionsModal/utils.ts index 05c5cb6b..02a95ffc 100644 --- a/src/components/TableModals/ExtensionsModal/utils.ts +++ b/src/components/TableModals/ExtensionsModal/utils.ts @@ -71,7 +71,16 @@ const extensionBodyTemplate = { return ({ url: "", body: JSON.stringify({ - + row, + ref: { + id: ref.id, + path: ref.path + }, + change: { + before: change.before.get(), + after: change.after.get(), + }, + // Add your own payload here }) }) }`, From b30395f28ca9ceaaa9ac491699eff1570f3324f6 Mon Sep 17 00:00:00 2001 From: Bobby Wang Date: Mon, 23 Oct 2023 06:49:53 +0800 Subject: [PATCH 4/5] update buildship trigger body config --- src/components/TableModals/ExtensionsModal/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/TableModals/ExtensionsModal/utils.ts b/src/components/TableModals/ExtensionsModal/utils.ts index 02a95ffc..fbeb71df 100644 --- a/src/components/TableModals/ExtensionsModal/utils.ts +++ b/src/components/TableModals/ExtensionsModal/utils.ts @@ -69,7 +69,10 @@ const extensionBodyTemplate = { // Put your endpoint URL and request body below. // It will trigger your endpoint with the request body. return ({ - url: "", + buildshipConfig: { + projectId: "", + workflowId: "" + }, body: JSON.stringify({ row, ref: { From a249b3d20a83a05e3f1e4daecbe05e693601d0e6 Mon Sep 17 00:00:00 2001 From: Bobby Wang Date: Mon, 23 Oct 2023 06:54:43 +0800 Subject: [PATCH 5/5] update buildship trigger context type --- src/components/CodeEditor/extensions.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/CodeEditor/extensions.d.ts b/src/components/CodeEditor/extensions.d.ts index a61232b7..d57c5e21 100644 --- a/src/components/CodeEditor/extensions.d.ts +++ b/src/components/CodeEditor/extensions.d.ts @@ -134,6 +134,9 @@ type TaskBody = (context: ExtensionContext) => Promise; type BuildshipAuthenticatedTriggerBody = ( context: ExtensionContext ) => Promise<{ - url: string; + buildshipConfig: { + projectId: string; + workflowId: string; + }; body: string; }>;