Skip to content

Commit

Permalink
feat: add additional events
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpshr committed Dec 9, 2019
1 parent af536e1 commit d865070
Show file tree
Hide file tree
Showing 13 changed files with 874 additions and 23 deletions.
20 changes: 19 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
const { version: platformVersion } = require("zapier-platform-core");
const authentication = require("./lib/authentication");
const branchCreated = require("./lib/triggers/branchCreated");
const branchStatusUpdated = require("./lib/triggers/branchStatusUpdated");
const branchUpdated = require("./lib/triggers/branchUpdated");
const commentCreated = require("./lib/triggers/commentCreated");
const commentDeleted = require("./lib/triggers/commentDeleted");
const commentUpdated = require("./lib/triggers/commentUpdated");
const commitsCreated = require("./lib/triggers/commitsCreated");
const organizationsExist = require("./lib/triggers/organizationsExist");
const projectCreated = require("./lib/triggers/projectCreated");
const projectDeleted = require("./lib/triggers/projectDeleted");
const projectUpdated = require("./lib/triggers/projectUpdated");
const { version } = require("./package.json");

const AbstractZap = {
Expand All @@ -13,7 +22,16 @@ const AbstractZap = {

triggers: {
[branchCreated.key]: branchCreated,
[organizationsExist.key]: organizationsExist
[branchStatusUpdated.key]: branchStatusUpdated,
[branchUpdated.key]: branchUpdated,
[commentCreated.key]: commentCreated,
[commentDeleted.key]: commentDeleted,
[commentUpdated.key]: commentUpdated,
[commitsCreated.key]: commitsCreated,
[organizationsExist.key]: organizationsExist,
[projectCreated.key]: projectCreated,
[projectDeleted.key]: projectDeleted,
[projectUpdated.key]: projectUpdated
}
};

Expand Down
9 changes: 6 additions & 3 deletions lib/triggers/branchCreated.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const commonConfig = require("./commonConfig");
const { getConfig } = require("./common");

const outputFields = [
{ key: "createdAt" },
Expand Down Expand Up @@ -37,7 +37,7 @@ const sample = {
projectId: "003a1ae0-a4b3-11e9-807c-a35b74e69da5",
startedAtSha: "a23af8045784c10e9cf66602a5bcdb7605ca117b",
status: "active",
updatedAt: "2019-11-01T17:31:20.000Z",
updatedAt: "2019-10-29T17:59:30.000Z",
user: {
avatarUrl:
"https://avatars.goabstract.com/avatars/4010bed7-9ada-4eb4-9d9a-09c8b095d0a2",
Expand All @@ -50,11 +50,14 @@ const sample = {
}
};

const commonConfig = getConfig({
events: ["branch.created"]
});

module.exports = {
display: {
description: "Triggers when a new branch is created.",
hidden: false,
important: true,
label: "Branch created"
},
key: "branchCreated",
Expand Down
71 changes: 71 additions & 0 deletions lib/triggers/branchStatusUpdated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const { getConfig } = require("./common");

const outputFields = [
{ key: "createdAt" },
{ key: "description" },
{ key: "divergedFromBranchId" },
{ key: "head" },
{ key: "id" },
{ key: "mergeSha" },
{ key: "mergedIntoBranchId" },
{ key: "name" },
{ key: "parent" },
{ key: "projectId" },
{ key: "startedAtSha" },
{ key: "status" },
{ key: "updatedAt" },
{ key: "user__avatarUrl", label: "user.avatarUrl" },
{ key: "user__createdAt", label: "user.createdAt" },
{ key: "user__id", label: "user.id" },
{ key: "user__name", label: "user.name" },
{ key: "user__primaryEmailId", label: "user.primaryEmailId" },
{ key: "user__updatedAt", label: "user.updatedAt" },
{ key: "user__username", label: "user.username" }
];

const sample = {
createdAt: "2019-10-29T17:59:30.000Z",
description: "A test description",
divergedFromBranchId: "",
head: "201f5c4ceaf95a1589efa55e2b1a372a94d42aee",
id: "71547de2-6d7a-437e-89ae-7aec672c2c2b",
mergeSha: "",
mergedIntoBranchId: "",
name: "test-branch",
objectType: "branch",
parent: "master",
projectId: "003a1ae0-a4b3-11e9-807c-a35b74e69da5",
startedAtSha: "a23af8045784c10e9cf66602a5bcdb7605ca117b",
status: "active",
updatedAt: "2019-11-01T17:31:20.000Z",
user: {
avatarUrl:
"https://avatars.goabstract.com/avatars/4010bed7-9ada-4eb4-9d9a-09c8b095d0a2",
createdAt: "2018-11-04T18:28:19.027Z",
id: "e5954a04-26ea-4600-a41b-1f74350be974",
name: "Test User",
primaryEmailId: "f649461e-2f6c-4de1-8f72-55f81f068ee5",
updatedAt: "2019-06-17T16:12:47.915Z",
username: "test-user"
}
};

const commonConfig = getConfig({
events: ["branch.statusUpdated"]
});

module.exports = {
display: {
description: "Triggers when a branch status is updated.",
hidden: false,
label: "Branch status updated"
},
key: "branchStatusUpdated",
noun: "Branch status",
operation: {
...commonConfig.operation,
outputFields,
performList: () => [sample],
sample
}
};
71 changes: 71 additions & 0 deletions lib/triggers/branchUpdated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const { getConfig } = require("./common");

const outputFields = [
{ key: "createdAt" },
{ key: "description" },
{ key: "divergedFromBranchId" },
{ key: "head" },
{ key: "id" },
{ key: "mergeSha" },
{ key: "mergedIntoBranchId" },
{ key: "name" },
{ key: "parent" },
{ key: "projectId" },
{ key: "startedAtSha" },
{ key: "status" },
{ key: "updatedAt" },
{ key: "user__avatarUrl", label: "user.avatarUrl" },
{ key: "user__createdAt", label: "user.createdAt" },
{ key: "user__id", label: "user.id" },
{ key: "user__name", label: "user.name" },
{ key: "user__primaryEmailId", label: "user.primaryEmailId" },
{ key: "user__updatedAt", label: "user.updatedAt" },
{ key: "user__username", label: "user.username" }
];

const sample = {
createdAt: "2019-10-29T17:59:30.000Z",
description: "A test description",
divergedFromBranchId: "",
head: "201f5c4ceaf95a1589efa55e2b1a372a94d42aee",
id: "71547de2-6d7a-437e-89ae-7aec672c2c2b",
mergeSha: "",
mergedIntoBranchId: "",
name: "test-branch",
objectType: "branch",
parent: "master",
projectId: "003a1ae0-a4b3-11e9-807c-a35b74e69da5",
startedAtSha: "a23af8045784c10e9cf66602a5bcdb7605ca117b",
status: "active",
updatedAt: "2019-11-01T17:31:20.000Z",
user: {
avatarUrl:
"https://avatars.goabstract.com/avatars/4010bed7-9ada-4eb4-9d9a-09c8b095d0a2",
createdAt: "2018-11-04T18:28:19.027Z",
id: "e5954a04-26ea-4600-a41b-1f74350be974",
name: "Test User",
primaryEmailId: "f649461e-2f6c-4de1-8f72-55f81f068ee5",
updatedAt: "2019-06-17T16:12:47.915Z",
username: "test-user"
}
};

const commonConfig = getConfig({
events: ["branch.updated"]
});

module.exports = {
display: {
description: "Triggers when a branch is updated.",
hidden: false,
label: "Branch updated"
},
key: "branchUpdated",
noun: "Branch",
operation: {
...commonConfig.operation,
outputFields,
performList: () => [sample],
sample
}
};
103 changes: 103 additions & 0 deletions lib/triggers/commentCreated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const { getConfig } = require("./common");

const commitFields = [
{ key: "annotation" },
{ key: "body" },
{ key: "branchId" },
{ key: "branchName" },
{ key: "commenter__avatarUrl", label: "comment.qvatarUrl" },
{ key: "commenter__createdAt", label: "comment.createdAt" },
{ key: "commenter__id", label: "comment.id" },
{ key: "commenter__name", label: "comment.name" },
{ key: "commenter__objectType", label: "comment.objectType" },
{ key: "commenter__updatedAt", label: "comment.updatedAt" },
{ key: "commenter__username", label: "comment.username" },
{ key: "commitSha" },
{ key: "createdAt" },
{ key: "deletedAt" },
{ key: "editedAt" },
{ key: "fileId" },
{ key: "fileName" },
{ key: "file_type" },
{ key: "id" },
{ key: "layerId" },
{ key: "layerName" },
{ key: "objectType" },
{ key: "pageId" },
{ key: "page_name" },
{ key: "projectId" },
{ key: "publishedAt" },
{ key: "replyIds[]" },
{ key: "reviewId" },
{ key: "reviewStatus" },
{ key: "updatedAt" }
];

const outputFields = [
...commitFields,
...commitFields.map(field => ({
...field,
key: `parent__${field.key}`
}))
];

const commit = {
annotation: "",
body: "test comment",
branchId: "master",
branchName: "Master",
commenter: {
avatarUrl:
"https://avatars.goabstract.com/avatars/4010bed7-9ada-4eb4-9d9a-09c8b095d0a2.",
createdAt: "2018-11-04T18:28:19Z",
id: "e5954a04-26ea-4600-a41b-1f74350be974",
name: "Test User",
objectType: "user",
updatedAt: "2019-06-17T16:12:47Z",
username: "test-user"
},
commitSha: "",
createdAt: "2019-12-09T00:09:36Z",
deletedAt: "",
editedAt: "",
fileId: "",
fileName: "",
file_type: "",
id: "ab6341b0-8527-47d3-a0cc-5f526eb9c0bc",
layerId: "",
layerName: "",
objectType: "comment",
pageId: "",
page_name: "",
projectId: "003a1ae0-a4b3-11e9-807c-a35b74e69da5",
publishedAt: "2019-12-09T00:09:36Z",
replyIds: ["003a1ae0-a4b3-11e9-807c-a35b74e69da"],
reviewId: "",
reviewStatus: "",
updatedAt: "2019-12-09T00:09:36Z"
};

const sample = {
...commit,
parent: commit
};

const commonConfig = getConfig({
events: ["comment.created"]
});

module.exports = {
display: {
description: "Triggers when a new comment is created.",
hidden: false,
label: "Comment created"
},
key: "commentCreated",
noun: "Comment",
operation: {
...commonConfig.operation,
outputFields,
performList: () => [sample],
sample
}
};
Loading

0 comments on commit d865070

Please sign in to comment.