diff --git a/src/components/CodeEditor/extensions.d.ts b/src/components/CodeEditor/extensions.d.ts index 22af57566..d57c5e216 100644 --- a/src/components/CodeEditor/extensions.d.ts +++ b/src/components/CodeEditor/extensions.d.ts @@ -128,4 +128,15 @@ type PushNotificationRequest = { type PushNotificationBody = ( context: ExtensionContext ) => Message | Message[] | Promise; + type TaskBody = (context: ExtensionContext) => Promise; + +type BuildshipAuthenticatedTriggerBody = ( + context: ExtensionContext +) => Promise<{ + buildshipConfig: { + projectId: string; + workflowId: string; + }; + body: string; +}>; diff --git a/src/components/TableModals/ExtensionsModal/utils.ts b/src/components/TableModals/ExtensionsModal/utils.ts index 8254ff42b..fbeb71df6 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,30 @@ 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 ({ + buildshipConfig: { + projectId: "", + workflowId: "" + }, + 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 + }) + }) +}`, task: `const extensionBody: TaskBody = async({row, db, change, ref, logging}) => { logging.log("extensionBody started")