Merge pull request #1437 from rowyio/feat/buildship-authenticated-extension

ROWY-1542 Add buildship authenticated trigger
This commit is contained in:
Shams
2023-10-23 19:50:16 -07:00
committed by GitHub
2 changed files with 37 additions and 0 deletions

View File

@@ -128,4 +128,15 @@ type PushNotificationRequest = {
type PushNotificationBody = (
context: ExtensionContext
) => Message | Message[] | Promise<Message | Message[]>;
type TaskBody = (context: ExtensionContext) => Promise<any>;
type BuildshipAuthenticatedTriggerBody = (
context: ExtensionContext
) => Promise<{
buildshipConfig: {
projectId: string;
workflowId: string;
};
body: string;
}>;

View File

@@ -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<ExtensionType, string> = {
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")