@activepieces/piece-github 0.0.0-pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.githubNewRepoEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const common_1 = require("../common");
7
+ exports.githubNewRepoEvent = (0, framework_1.createTrigger)({
8
+ name: 'new_star',
9
+ displayName: 'New Star',
10
+ description: 'Triggers when there is a new star on the repository',
11
+ props: {
12
+ authentication: common_1.githubCommon.authentication,
13
+ repository: common_1.githubCommon.repositoryDropdown
14
+ },
15
+ sampleData: {
16
+ "action": "created",
17
+ "starred_at": "2023-01-23T13:23:24Z",
18
+ "repository": {
19
+ "id": 573661753,
20
+ "name": "activepieces",
21
+ "full_name": "activepieces/activepieces",
22
+ "owner": {
23
+ "login": "activepieces",
24
+ "id": 99494700,
25
+ },
26
+ "topics": [
27
+ "automation",
28
+ "low-code",
29
+ "no-code",
30
+ "workflows",
31
+ "zapier"
32
+ ],
33
+ "visibility": "public",
34
+ "forks": 10,
35
+ "open_issues": 49,
36
+ "watchers": 155,
37
+ "default_branch": "main"
38
+ },
39
+ "organization": {
40
+ "login": "activepieces",
41
+ "id": 99494700,
42
+ "description": "Automate your work, Open source alternative to Zapier, Tray.io, make"
43
+ },
44
+ "sender": {
45
+ "login": "abuaboud",
46
+ "id": 1812998,
47
+ "avatar_url": "https://avatars.githubusercontent.com/u/31868364?v=4",
48
+ }
49
+ },
50
+ type: framework_1.TriggerStrategy.WEBHOOK,
51
+ onEnable(context) {
52
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
+ const { repo, owner } = context.propsValue['repository'];
54
+ const request = {
55
+ method: framework_1.HttpMethod.POST,
56
+ url: `${common_1.githubCommon.baseUrl}/repos/${owner}/${repo}/hooks`,
57
+ body: {
58
+ owner: owner,
59
+ repo: repo,
60
+ active: true,
61
+ events: ['star'],
62
+ config: {
63
+ url: context.webhookUrl,
64
+ content_type: 'json',
65
+ insecure_ssl: '0',
66
+ },
67
+ },
68
+ authentication: {
69
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
70
+ token: context.propsValue['authentication']['access_token'],
71
+ },
72
+ queryParams: {},
73
+ };
74
+ const { body: webhook } = yield framework_1.httpClient.sendRequest(request);
75
+ yield context.store.put('_trigger', {
76
+ webhookId: webhook.id,
77
+ owner: owner,
78
+ repo: repo,
79
+ });
80
+ });
81
+ },
82
+ onDisable(context) {
83
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
84
+ const response = yield context.store.get('_trigger');
85
+ if (response !== null && response !== undefined) {
86
+ const request = {
87
+ method: framework_1.HttpMethod.DELETE,
88
+ url: `${common_1.githubCommon.baseUrl}/repos/${response.owner}/${response.repo}/hooks/${response.webhookId}`,
89
+ authentication: {
90
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
91
+ token: context.propsValue['authentication']['access_token'],
92
+ },
93
+ };
94
+ yield framework_1.httpClient.sendRequest(request);
95
+ }
96
+ });
97
+ },
98
+ run(context) {
99
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
100
+ if (isVerficationCall(context.payload.body)) {
101
+ return [];
102
+ }
103
+ return [context.payload.body];
104
+ });
105
+ },
106
+ });
107
+ function isVerficationCall(payload) {
108
+ return payload['zen'] !== undefined;
109
+ }
110
+ //# sourceMappingURL=new-star.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-star.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/github/src/lib/trigger/new-star.ts"],"names":[],"mappings":";;;;AAAA,uDAAkI;AAClI,sCAAyC;AAE5B,QAAA,kBAAkB,GAAG,IAAA,yBAAa,EAAC;IAC9C,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE;QACL,cAAc,EAAE,qBAAY,CAA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IAAI,CAAC,CAAC;QAChC,CAAC;KAAA;CACF,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,OAA4B;IACrD,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AACtC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const githubRegisterTrigger: ({ name, displayName, description, sampleData }: {
2
+ name: string;
3
+ displayName: string;
4
+ description: string;
5
+ sampleData: object;
6
+ }) => import("@activepieces/framework").Trigger;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.githubRegisterTrigger = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const common_1 = require("../common");
7
+ const githubRegisterTrigger = ({ name, displayName, description, sampleData }) => (0, framework_1.createTrigger)({
8
+ name: `trigger_${name}`,
9
+ displayName,
10
+ description,
11
+ props: {
12
+ authentication: common_1.githubCommon.authentication,
13
+ repository: common_1.githubCommon.repositoryDropdown
14
+ },
15
+ sampleData,
16
+ type: framework_1.TriggerStrategy.WEBHOOK,
17
+ onEnable(context) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ const { repo, owner } = context.propsValue['repository'];
20
+ const request = {
21
+ method: framework_1.HttpMethod.POST,
22
+ url: `${common_1.githubCommon.baseUrl}/repos/${owner}/${repo}/hooks`,
23
+ body: {
24
+ owner: owner,
25
+ repo: repo,
26
+ active: true,
27
+ events: [name],
28
+ config: {
29
+ url: context.webhookUrl,
30
+ content_type: 'json',
31
+ insecure_ssl: '0',
32
+ },
33
+ },
34
+ authentication: {
35
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
36
+ token: context.propsValue['authentication']['access_token'],
37
+ },
38
+ queryParams: {},
39
+ };
40
+ const { body: webhook } = yield framework_1.httpClient.sendRequest(request);
41
+ yield context.store.put(`github_${name}_trigger`, {
42
+ webhookId: webhook.id,
43
+ owner: owner,
44
+ repo: repo,
45
+ });
46
+ });
47
+ },
48
+ onDisable(context) {
49
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
50
+ const response = yield context.store.get(`github_${name}_trigger`);
51
+ if (response !== null && response !== undefined) {
52
+ const request = {
53
+ method: framework_1.HttpMethod.DELETE,
54
+ url: `${common_1.githubCommon.baseUrl}/repos/${response.owner}/${response.repo}/hooks/${response.webhookId}`,
55
+ authentication: {
56
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
57
+ token: context.propsValue['authentication']['access_token'],
58
+ },
59
+ };
60
+ yield framework_1.httpClient.sendRequest(request);
61
+ }
62
+ });
63
+ },
64
+ run(context) {
65
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
66
+ console.debug("payload received", context.payload.body);
67
+ if (isVerficationCall(context.payload.body)) {
68
+ return [];
69
+ }
70
+ return [context.payload.body];
71
+ });
72
+ },
73
+ });
74
+ exports.githubRegisterTrigger = githubRegisterTrigger;
75
+ function isVerficationCall(payload) {
76
+ return payload['zen'] !== undefined;
77
+ }
78
+ //# sourceMappingURL=register-trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-trigger.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/github/src/lib/trigger/register-trigger.ts"],"names":[],"mappings":";;;;AAAA,uDAOiC;AACjC,sCAAyC;AAElC,MAAM,qBAAqB,GAAG,CAAC,EACpC,IAAI,EACJ,WAAW,EACX,WAAW,EACX,UAAU,EAMX,EAAE,EAAE,CAAC,IAAA,yBAAa,EAAC;IAClB,IAAI,EAAE,WAAW,IAAI,EAAE;IACvB,WAAW;IACX,WAAW;IACX,KAAK,EAAE;QACL,cAAc,EAAE,qBAAY,CAAC,cAAc;QAC3C,UAAU,EAAE,qBAAY,CAAC,kBAAkB;KAC5C;IACD,UAAU;IACV,IAAI,EAAE,2BAAe,CAAC,OAAO;IACvB,QAAQ,CAAC,OAAO;;YACpB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,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