@agnocon/piece-box 0.1.7
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.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/common/index.d.ts +23 -0
- package/dist/lib/common/index.d.ts.map +1 -0
- package/dist/lib/common/index.js +44 -0
- package/dist/lib/common/index.js.map +1 -0
- package/dist/lib/triggers/new-comment.d.ts +15 -0
- package/dist/lib/triggers/new-comment.d.ts.map +1 -0
- package/dist/lib/triggers/new-comment.js +94 -0
- package/dist/lib/triggers/new-comment.js.map +1 -0
- package/dist/lib/triggers/new-file.d.ts +11 -0
- package/dist/lib/triggers/new-file.d.ts.map +1 -0
- package/dist/lib/triggers/new-file.js +117 -0
- package/dist/lib/triggers/new-file.js.map +1 -0
- package/dist/lib/triggers/new-folder.d.ts +11 -0
- package/dist/lib/triggers/new-folder.d.ts.map +1 -0
- package/dist/lib/triggers/new-folder.js +109 -0
- package/dist/lib/triggers/new-folder.js.map +1 -0
- package/package.json +46 -0
- package/src/index.ts +40 -0
- package/src/lib/common/index.ts +64 -0
- package/src/lib/triggers/new-comment.ts +96 -0
- package/src/lib/triggers/new-file.ts +120 -0
- package/src/lib/triggers/new-folder.ts +112 -0
package/LICENSE.MIT-AP
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Activepieces AB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Derived helpers in this folder are adapted from Activepieces (MIT) for use
|
|
24
|
+
inside CX without depending on @activepieces/* packages at runtime.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const boxAuth: import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>;
|
|
2
|
+
export declare const box: import("@agnocon/pieces-framework").Piece<import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,OAAO,qGAKlB,CAAC;AAEH,eAAO,MAAM,GAAG,gJAmBd,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.box = exports.boxAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/box/src/index.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const pieces_framework_2 = require("@agnocon/pieces-framework");
|
|
10
|
+
const common_1 = require("./lib/common");
|
|
11
|
+
const new_comment_1 = require("./lib/triggers/new-comment");
|
|
12
|
+
const new_file_1 = require("./lib/triggers/new-file");
|
|
13
|
+
const new_folder_1 = require("./lib/triggers/new-folder");
|
|
14
|
+
exports.boxAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
15
|
+
required: true,
|
|
16
|
+
authUrl: 'https://account.box.com/api/oauth2/authorize',
|
|
17
|
+
tokenUrl: 'https://api.box.com/oauth2/token',
|
|
18
|
+
scope: ['manage_webhook', 'root_readonly', 'root_readwrite'],
|
|
19
|
+
});
|
|
20
|
+
exports.box = (0, pieces_framework_1.createPiece)({
|
|
21
|
+
displayName: 'Box',
|
|
22
|
+
description: 'Secure content management and collaboration',
|
|
23
|
+
auth: exports.boxAuth,
|
|
24
|
+
minimumSupportedRelease: '0.30.0',
|
|
25
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/box.png',
|
|
26
|
+
categories: [pieces_framework_2.PieceCategory.CONTENT_AND_FILES],
|
|
27
|
+
authors: ["kishanprmr", "MoShizzle", "abuaboud"],
|
|
28
|
+
actions: [
|
|
29
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
30
|
+
baseUrl: () => common_1.common.baseUrl,
|
|
31
|
+
auth: exports.boxAuth,
|
|
32
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
return ({
|
|
34
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
triggers: [new_file_1.newFile, new_folder_1.newFolder, new_comment_1.newComment],
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,+EAA+E;AAC/E,qEAAqE;AACrE,gEAImC;AAEnC,0DAAmE;AACnE,gEAA0D;AAC1D,yCAAsC;AACtC,4DAAwD;AACxD,sDAAkD;AAClD,0DAAsD;AAEzC,QAAA,OAAO,GAAG,4BAAS,CAAC,MAAM,CAAC;IACtC,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,8CAA8C;IACvD,QAAQ,EAAE,kCAAkC;IAC5C,KAAK,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,CAAC;CAC7D,CAAC,CAAC;AAEU,QAAA,GAAG,GAAG,IAAA,8BAAW,EAAC;IAC7B,WAAW,EAAE,KAAK;IAClB,WAAW,EAAE,6CAA6C;IAE1D,IAAI,EAAE,eAAO;IACb,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,6CAA6C;IACtD,UAAU,EAAE,CAAC,gCAAa,CAAC,iBAAiB,CAAC;IAC7C,OAAO,EAAE,CAAC,YAAY,EAAC,WAAW,EAAC,UAAU,CAAC;IAC9C,OAAO,EAAE;QACP,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,eAAM,CAAC,OAAO;YAC7B,IAAI,EAAE,eAAO;YACb,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAU,IAAI,CAAC,YAAY,EAAE;iBAC7C,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,kBAAO,EAAE,sBAAS,EAAE,wBAAU,CAAC;CAC3C,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
export interface WebhookInformation {
|
|
3
|
+
id: string;
|
|
4
|
+
target: string;
|
|
5
|
+
type: string;
|
|
6
|
+
address: string;
|
|
7
|
+
created_at: string;
|
|
8
|
+
created_by: string;
|
|
9
|
+
triggers: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const common: {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
subscribeWebhook(auth: OAuth2PropertyValue, data: {
|
|
14
|
+
event: string;
|
|
15
|
+
target: {
|
|
16
|
+
id: number | string;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
webhookUrl: string;
|
|
20
|
+
}): Promise<WebhookInformation>;
|
|
21
|
+
unsubscribeWebhook(auth: OAuth2PropertyValue, webhookId: string): Promise<import("@agnocon/pieces-common").HttpResponse<any>>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/common/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,MAAM;;2BAIT,mBAAmB,QACnB;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE;YACN,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;YACpB,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,UAAU,EAAE,MAAM,CAAC;KACpB;6BAoB4B,mBAAmB,aAAa,MAAM;CAatE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.common = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/box/src/lib/common/index.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
exports.common = {
|
|
9
|
+
baseUrl: 'https://api.box.com/2.0',
|
|
10
|
+
subscribeWebhook(auth, data) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const request = {
|
|
13
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
14
|
+
url: `${exports.common.baseUrl}/webhooks`,
|
|
15
|
+
authentication: {
|
|
16
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
17
|
+
token: auth.access_token,
|
|
18
|
+
},
|
|
19
|
+
body: {
|
|
20
|
+
address: data.webhookUrl,
|
|
21
|
+
triggers: [data.event],
|
|
22
|
+
target: data.target,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
26
|
+
return response.body;
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
unsubscribeWebhook(auth, webhookId) {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const request = {
|
|
32
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
33
|
+
url: `${exports.common.baseUrl}/webhooks/${webhookId}`,
|
|
34
|
+
authentication: {
|
|
35
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
36
|
+
token: auth.access_token,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
40
|
+
return response;
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,0FAA0F;AAC1F,qEAAqE;AACrE,0DAKgC;AAanB,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,yBAAyB;IAE5B,gBAAgB,CACpB,IAAyB,EACzB,IAOC;;YAED,MAAM,OAAO,GAAgB;gBAC3B,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,cAAM,CAAC,OAAO,WAAW;gBACjC,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,YAAY;iBACzB;gBACD,IAAI,EAAE;oBACJ,OAAO,EAAE,IAAI,CAAC,UAAU;oBACxB,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;oBACtB,MAAM,EAAE,IAAI,CAAC,MAAM;iBACpB;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAqB,OAAO,CAAC,CAAC;YAC3E,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;IAEK,kBAAkB,CAAC,IAAyB,EAAE,SAAiB;;YACnE,MAAM,OAAO,GAAgB;gBAC3B,MAAM,EAAE,0BAAU,CAAC,MAAM;gBACzB,GAAG,EAAE,GAAG,cAAM,CAAC,OAAO,aAAa,SAAS,EAAE;gBAC9C,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,YAAY;iBACzB;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACvD,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newComment: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
id: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
type: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
6
|
+
id: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
type: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
id: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
type: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
11
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
12
|
+
id: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
13
|
+
type: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-comment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-comment.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-comment.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AAKnC,eAAO,MAAM,UAAU;;;;;;;;;;;;EAsFrB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newComment = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/box/src/lib/triggers/new-comment.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const __1 = require("../..");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
exports.newComment = (0, pieces_framework_1.createTrigger)({
|
|
11
|
+
auth: __1.boxAuth,
|
|
12
|
+
name: 'new_comment',
|
|
13
|
+
displayName: 'New Comment',
|
|
14
|
+
description: 'Triggers when a comment is created',
|
|
15
|
+
aiMetadata: {
|
|
16
|
+
description: 'Fires when a user posts a new comment on the specified Box file or folder. Each event represents a single created comment, including the comment text, the item it was added to, and the author.',
|
|
17
|
+
},
|
|
18
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
19
|
+
props: {
|
|
20
|
+
id: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'File/Folder ID',
|
|
22
|
+
description: 'The ID of the item to trigger a webhook',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
type: pieces_framework_1.Property.StaticDropdown({
|
|
26
|
+
displayName: 'Item Type',
|
|
27
|
+
description: 'The type of the item to trigger a webhook',
|
|
28
|
+
required: true,
|
|
29
|
+
options: {
|
|
30
|
+
options: [
|
|
31
|
+
{ label: 'File', value: 'file' },
|
|
32
|
+
{ label: 'Folder', value: 'folder' },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
onEnable(context) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const target = {
|
|
40
|
+
id: context.propsValue.id,
|
|
41
|
+
type: context.propsValue.type,
|
|
42
|
+
};
|
|
43
|
+
const webhook = yield common_1.common.subscribeWebhook(context.auth, {
|
|
44
|
+
event: 'COMMENT.CREATED',
|
|
45
|
+
target: target,
|
|
46
|
+
webhookUrl: context.webhookUrl,
|
|
47
|
+
});
|
|
48
|
+
yield context.store.put(`_new_comment_trigger`, webhook);
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
onDisable(context) {
|
|
52
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const webhook = yield context.store.get(`_new_comment_trigger`);
|
|
54
|
+
if (webhook) {
|
|
55
|
+
yield common_1.common.unsubscribeWebhook(context.auth, webhook.id);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
run(context) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return [context.payload.body];
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
sampleData: {
|
|
65
|
+
type: 'webhook_event',
|
|
66
|
+
id: '9a30442d-f681-4d25-8815-aa46f0515387',
|
|
67
|
+
created_at: '2023-04-19T13:25:07-07:00',
|
|
68
|
+
trigger: 'COMMENT.CREATED',
|
|
69
|
+
webhook: { id: '1396363668', type: 'webhook' },
|
|
70
|
+
created_by: {
|
|
71
|
+
type: 'user',
|
|
72
|
+
id: '24316851337',
|
|
73
|
+
name: 'Bonobo',
|
|
74
|
+
login: 'email@gmail.com',
|
|
75
|
+
},
|
|
76
|
+
source: {
|
|
77
|
+
id: '538146815',
|
|
78
|
+
type: 'comment',
|
|
79
|
+
is_reply_comment: false,
|
|
80
|
+
message: 'Simple times...',
|
|
81
|
+
created_by: {
|
|
82
|
+
type: 'user',
|
|
83
|
+
id: '24316851337',
|
|
84
|
+
name: 'Bonobo',
|
|
85
|
+
login: 'email@gmail.com',
|
|
86
|
+
},
|
|
87
|
+
created_at: '2023-04-19T13:25:07-07:00',
|
|
88
|
+
item: { id: '1194590019402', type: 'file' },
|
|
89
|
+
modified_at: '2023-04-19T13:25:07-07:00',
|
|
90
|
+
},
|
|
91
|
+
additional_info: [],
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=new-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-comment.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-comment.ts"],"names":[],"mappings":";;;;AAAA,kGAAkG;AAClG,qEAAqE;AACrE,gEAImC;AAEnC,6BAAgC;AAChC,sCAAuD;AAE1C,QAAA,UAAU,GAAG,IAAA,gCAAa,EAAC;IACtC,IAAI,EAAE,WAAO;IACb,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,oCAAoC;IACjD,UAAU,EAAE;QACV,WAAW,EACT,kMAAkM;KACrM;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,KAAK,EAAE;QACL,EAAE,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,2CAA2C;YACxD,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;iBACrC;aACF;SACF,CAAC;KACH;IAEK,QAAQ,CAAC,OAAO;;YACpB,MAAM,MAAM,GAAQ;gBAClB,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE;gBACzB,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI;aAC9B,CAAC;YAEF,MAAM,OAAO,GAAG,MAAM,eAAM,CAAC,gBAAgB,CAA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E,IAAI,EAAE,MAAM,EAAE;YAC3C,WAAW,EAAE,2BAA2B;SACzC;QACD,eAAe,EAAE,EAAE;KACpB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newFile: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
5
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-file.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AAKnC,eAAO,MAAM,OAAO;;;;;;;;EA8GlB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/box/src/lib/triggers/new-file.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const __1 = require("../..");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
exports.newFile = (0, pieces_framework_1.createTrigger)({
|
|
11
|
+
auth: __1.boxAuth,
|
|
12
|
+
name: 'new_file',
|
|
13
|
+
displayName: 'New File',
|
|
14
|
+
description: 'Triggers when a file is uploaded',
|
|
15
|
+
aiMetadata: {
|
|
16
|
+
description: 'Fires when a new file is uploaded into the specified Box folder. Each event represents one uploaded file, including its name, ID, size, version, and parent folder.',
|
|
17
|
+
},
|
|
18
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
19
|
+
props: {
|
|
20
|
+
folder: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Folder ID',
|
|
22
|
+
description: 'The ID of the folder in which file uploads will trigger this webhook',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
onEnable(context) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const target = {
|
|
29
|
+
id: context.propsValue.folder,
|
|
30
|
+
type: 'folder',
|
|
31
|
+
};
|
|
32
|
+
const webhook = yield common_1.common.subscribeWebhook(context.auth, {
|
|
33
|
+
event: 'FILE.UPLOADED',
|
|
34
|
+
target: target,
|
|
35
|
+
webhookUrl: context.webhookUrl,
|
|
36
|
+
});
|
|
37
|
+
yield context.store.put(`_new_file_trigger`, webhook);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
onDisable(context) {
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const webhook = yield context.store.get(`_new_file_trigger`);
|
|
43
|
+
if (webhook) {
|
|
44
|
+
yield common_1.common.unsubscribeWebhook(context.auth, webhook.id);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
run(context) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return [context.payload.body];
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
sampleData: {
|
|
54
|
+
type: 'webhook_event',
|
|
55
|
+
id: 'fb0bd323-33b9-4f71-9dbc-fbcc3fe109ad',
|
|
56
|
+
created_at: '2023-04-19T12:06:52-07:00',
|
|
57
|
+
trigger: 'FILE.UPLOADED',
|
|
58
|
+
webhook: { id: '1396340122', type: 'webhook' },
|
|
59
|
+
created_by: {
|
|
60
|
+
type: 'user',
|
|
61
|
+
id: '24316851337',
|
|
62
|
+
name: 'Bonobo',
|
|
63
|
+
login: 'email@gmail.com',
|
|
64
|
+
},
|
|
65
|
+
source: {
|
|
66
|
+
id: '1194585432265',
|
|
67
|
+
type: 'file',
|
|
68
|
+
file_version: {
|
|
69
|
+
type: 'file_version',
|
|
70
|
+
id: '1302595111465',
|
|
71
|
+
sha1: '63da452d845b91ccb638510d046b902e96275359',
|
|
72
|
+
},
|
|
73
|
+
sequence_id: '0',
|
|
74
|
+
etag: '0',
|
|
75
|
+
sha1: '63da452d845b91ccb638510d046b902e96275359',
|
|
76
|
+
name: 'ap-logo.svg',
|
|
77
|
+
description: '',
|
|
78
|
+
size: 877,
|
|
79
|
+
path_collection: { total_count: 2, entries: [Array] },
|
|
80
|
+
created_at: '2023-04-19T12:06:52-07:00',
|
|
81
|
+
modified_at: '2023-04-19T12:06:52-07:00',
|
|
82
|
+
trashed_at: null,
|
|
83
|
+
purged_at: null,
|
|
84
|
+
content_created_at: '2023-02-02T06:54:17-08:00',
|
|
85
|
+
content_modified_at: '2023-02-02T06:54:17-08:00',
|
|
86
|
+
created_by: {
|
|
87
|
+
type: 'user',
|
|
88
|
+
id: '24316851337',
|
|
89
|
+
name: 'Bonobo',
|
|
90
|
+
login: 'email@gmail.com',
|
|
91
|
+
},
|
|
92
|
+
modified_by: {
|
|
93
|
+
type: 'user',
|
|
94
|
+
id: '24316851332',
|
|
95
|
+
name: 'Bonobo',
|
|
96
|
+
login: 'email@gmail.com',
|
|
97
|
+
},
|
|
98
|
+
owned_by: {
|
|
99
|
+
type: 'user',
|
|
100
|
+
id: '24316851332',
|
|
101
|
+
name: 'Bonobo',
|
|
102
|
+
login: 'email@gmail.com',
|
|
103
|
+
},
|
|
104
|
+
shared_link: null,
|
|
105
|
+
parent: {
|
|
106
|
+
type: 'folder',
|
|
107
|
+
id: '198605434359',
|
|
108
|
+
sequence_id: '0',
|
|
109
|
+
etag: '0',
|
|
110
|
+
name: 'Kinembe',
|
|
111
|
+
},
|
|
112
|
+
item_status: 'active',
|
|
113
|
+
},
|
|
114
|
+
additional_info: [],
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=new-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-file.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-file.ts"],"names":[],"mappings":";;;;AAAA,+FAA+F;AAC/F,qEAAqE;AACrE,gEAImC;AAEnC,6BAAgC;AAChC,sCAAuD;AAE1C,QAAA,OAAO,GAAG,IAAA,gCAAa,EAAC;IACnC,IAAI,EAAE,WAAO;IACb,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,kCAAkC;IAC/C,UAAU,EAAE;QACV,WAAW,EACT,qKAAqK;KACxK;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EACT,sEAAsE;YACxE,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IAEK,QAAQ,CAAC,OAAO;;YACpB,MAAM,MAAM,GAAQ;gBAClB,EAA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YAChB,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,0CAA0C;YAChD,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,EAAE;YACf,IAAI,EAAE,GAAG;YACT,eAAe,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE;YACrD,UAAU,EAAE,2BAA2B;YACvC,WAAW,EAAE,2BAA2B;YACxC,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,IAAI;YACf,kBAAkB,EAAE,2BAA2B;YAC/C,mBAAmB,EAAE,2BAA2B;YAChD,UAAU,EAAE;gBACV,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,aAAa;gBACjB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,iBAAiB;aACzB;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,aAAa;gBACjB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,iBAAiB;aACzB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,aAAa;gBACjB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,iBAAiB;aACzB;YACD,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,EAAE,EAAE,cAAc;gBAClB,WAAW,EAAE,GAAG;gBAChB,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,SAAS;aAChB;YACD,WAAW,EAAE,QAAQ;SACtB;QACD,eAAe,EAAE,EAAE;KACpB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newFolder: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
5
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
folder: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-folder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-folder.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-folder.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AAKnC,eAAO,MAAM,SAAS;;;;;;;;EAsGpB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newFolder = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/box/src/lib/triggers/new-folder.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const __1 = require("../..");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
exports.newFolder = (0, pieces_framework_1.createTrigger)({
|
|
11
|
+
auth: __1.boxAuth,
|
|
12
|
+
name: 'new_folder',
|
|
13
|
+
displayName: 'New Folder',
|
|
14
|
+
description: 'Triggers when a folder is created',
|
|
15
|
+
aiMetadata: {
|
|
16
|
+
description: 'Fires when a new folder is created inside the specified Box parent folder. Each event represents one newly created folder, including its name, ID, parent folder, and creation timestamp.',
|
|
17
|
+
},
|
|
18
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
19
|
+
props: {
|
|
20
|
+
folder: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Folder ID',
|
|
22
|
+
description: 'The ID of the folder in which file uploads will trigger this webhook',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
onEnable(context) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const target = {
|
|
29
|
+
id: context.propsValue.folder,
|
|
30
|
+
type: 'folder',
|
|
31
|
+
};
|
|
32
|
+
const webhook = yield common_1.common.subscribeWebhook(context.auth, {
|
|
33
|
+
event: 'FOLDER.CREATED',
|
|
34
|
+
target: target,
|
|
35
|
+
webhookUrl: context.webhookUrl,
|
|
36
|
+
});
|
|
37
|
+
yield context.store.put(`_new_folder_trigger`, webhook);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
onDisable(context) {
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const webhook = yield context.store.get(`_new_folder_trigger`);
|
|
43
|
+
if (webhook) {
|
|
44
|
+
yield common_1.common.unsubscribeWebhook(context.auth, webhook.id);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
run(context) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return [context.payload.body];
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
sampleData: {
|
|
54
|
+
id: '3f08aca1-aa0b-49a5-8e5a-5d8980bfbdef',
|
|
55
|
+
type: 'webhook_event',
|
|
56
|
+
source: {
|
|
57
|
+
id: '218634717358',
|
|
58
|
+
etag: '0',
|
|
59
|
+
name: 'test folder',
|
|
60
|
+
size: 0,
|
|
61
|
+
type: 'folder',
|
|
62
|
+
parent: {
|
|
63
|
+
id: '218635125044',
|
|
64
|
+
etag: '0',
|
|
65
|
+
name: 'Desktop',
|
|
66
|
+
type: 'folder',
|
|
67
|
+
sequence_id: '0',
|
|
68
|
+
},
|
|
69
|
+
purged_at: null,
|
|
70
|
+
created_at: '2023-07-25T05:55:08-07:00',
|
|
71
|
+
trashed_at: null,
|
|
72
|
+
description: '',
|
|
73
|
+
item_status: 'active',
|
|
74
|
+
modified_at: '2023-07-25T05:55:08-07:00',
|
|
75
|
+
sequence_id: '0',
|
|
76
|
+
shared_link: null,
|
|
77
|
+
path_collection: {
|
|
78
|
+
entries: [
|
|
79
|
+
{
|
|
80
|
+
id: '0',
|
|
81
|
+
etag: null,
|
|
82
|
+
name: 'All Files',
|
|
83
|
+
type: 'folder',
|
|
84
|
+
sequence_id: null,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: '218635125044',
|
|
88
|
+
etag: '0',
|
|
89
|
+
name: 'Desktop',
|
|
90
|
+
type: 'folder',
|
|
91
|
+
sequence_id: '0',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
total_count: 2,
|
|
95
|
+
},
|
|
96
|
+
content_created_at: '2023-07-25T05:55:08-07:00',
|
|
97
|
+
content_modified_at: '2023-07-25T05:55:08-07:00',
|
|
98
|
+
folder_upload_email: null,
|
|
99
|
+
},
|
|
100
|
+
trigger: 'FOLDER.CREATED',
|
|
101
|
+
webhook: {
|
|
102
|
+
id: '1738566186',
|
|
103
|
+
type: 'webhook',
|
|
104
|
+
},
|
|
105
|
+
created_at: '2023-07-25T05:55:09-07:00',
|
|
106
|
+
additional_info: [],
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=new-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agnocon/piece-box",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "AgnoCon box connector",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src",
|
|
17
|
+
"LICENSE.MIT-AP"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"vendor": "node ../scripts/vendor-ap.mjs piece-box"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@agnocon/core-utils": "0.2.0",
|
|
25
|
+
"@agnocon/piece-types": "0.3.1",
|
|
26
|
+
"@agnocon/pieces-common": "0.12.8",
|
|
27
|
+
"@agnocon/pieces-framework": "0.36.0",
|
|
28
|
+
"tslib": "2.6.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "20.17.6",
|
|
32
|
+
"typescript": "5.5.4"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"agnocon": {
|
|
36
|
+
"originVersion": "0.1.7"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "restricted",
|
|
40
|
+
"tag": "latest"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"agnocon",
|
|
44
|
+
"connector"
|
|
45
|
+
]
|
|
46
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPiece,
|
|
3
|
+
OAuth2PropertyValue,
|
|
4
|
+
PieceAuth,
|
|
5
|
+
} from '@agnocon/pieces-framework';
|
|
6
|
+
|
|
7
|
+
import { createCustomApiCallAction } from '@agnocon/pieces-common';
|
|
8
|
+
import { PieceCategory } from '@agnocon/pieces-framework';
|
|
9
|
+
import { common } from './lib/common';
|
|
10
|
+
import { newComment } from './lib/triggers/new-comment';
|
|
11
|
+
import { newFile } from './lib/triggers/new-file';
|
|
12
|
+
import { newFolder } from './lib/triggers/new-folder';
|
|
13
|
+
|
|
14
|
+
export const boxAuth = PieceAuth.OAuth2({
|
|
15
|
+
required: true,
|
|
16
|
+
authUrl: 'https://account.box.com/api/oauth2/authorize',
|
|
17
|
+
tokenUrl: 'https://api.box.com/oauth2/token',
|
|
18
|
+
scope: ['manage_webhook', 'root_readonly', 'root_readwrite'],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const box = createPiece({
|
|
22
|
+
displayName: 'Box',
|
|
23
|
+
description: 'Secure content management and collaboration',
|
|
24
|
+
|
|
25
|
+
auth: boxAuth,
|
|
26
|
+
minimumSupportedRelease: '0.30.0',
|
|
27
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/box.png',
|
|
28
|
+
categories: [PieceCategory.CONTENT_AND_FILES],
|
|
29
|
+
authors: ["kishanprmr","MoShizzle","abuaboud"],
|
|
30
|
+
actions: [
|
|
31
|
+
createCustomApiCallAction({
|
|
32
|
+
baseUrl: () => common.baseUrl,
|
|
33
|
+
auth: boxAuth,
|
|
34
|
+
authMapping: async (auth) => ({
|
|
35
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
triggers: [newFile, newFolder, newComment],
|
|
40
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticationType,
|
|
3
|
+
HttpMethod,
|
|
4
|
+
HttpRequest,
|
|
5
|
+
httpClient,
|
|
6
|
+
} from '@agnocon/pieces-common';
|
|
7
|
+
import { OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
8
|
+
|
|
9
|
+
export interface WebhookInformation {
|
|
10
|
+
id: string;
|
|
11
|
+
target: string;
|
|
12
|
+
type: string;
|
|
13
|
+
address: string;
|
|
14
|
+
created_at: string;
|
|
15
|
+
created_by: string;
|
|
16
|
+
triggers: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const common = {
|
|
20
|
+
baseUrl: 'https://api.box.com/2.0',
|
|
21
|
+
|
|
22
|
+
async subscribeWebhook(
|
|
23
|
+
auth: OAuth2PropertyValue,
|
|
24
|
+
data: {
|
|
25
|
+
event: string;
|
|
26
|
+
target: {
|
|
27
|
+
id: number | string;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
webhookUrl: string;
|
|
31
|
+
}
|
|
32
|
+
) {
|
|
33
|
+
const request: HttpRequest = {
|
|
34
|
+
method: HttpMethod.POST,
|
|
35
|
+
url: `${common.baseUrl}/webhooks`,
|
|
36
|
+
authentication: {
|
|
37
|
+
type: AuthenticationType.BEARER_TOKEN,
|
|
38
|
+
token: auth.access_token,
|
|
39
|
+
},
|
|
40
|
+
body: {
|
|
41
|
+
address: data.webhookUrl,
|
|
42
|
+
triggers: [data.event],
|
|
43
|
+
target: data.target,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const response = await httpClient.sendRequest<WebhookInformation>(request);
|
|
48
|
+
return response.body;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
async unsubscribeWebhook(auth: OAuth2PropertyValue, webhookId: string) {
|
|
52
|
+
const request: HttpRequest = {
|
|
53
|
+
method: HttpMethod.DELETE,
|
|
54
|
+
url: `${common.baseUrl}/webhooks/${webhookId}`,
|
|
55
|
+
authentication: {
|
|
56
|
+
type: AuthenticationType.BEARER_TOKEN,
|
|
57
|
+
token: auth.access_token,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const response = await httpClient.sendRequest(request);
|
|
62
|
+
return response;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTrigger,
|
|
3
|
+
TriggerStrategy,
|
|
4
|
+
Property,
|
|
5
|
+
} from '@agnocon/pieces-framework';
|
|
6
|
+
|
|
7
|
+
import { boxAuth } from '../..';
|
|
8
|
+
import { WebhookInformation, common } from '../common';
|
|
9
|
+
|
|
10
|
+
export const newComment = createTrigger({
|
|
11
|
+
auth: boxAuth,
|
|
12
|
+
name: 'new_comment',
|
|
13
|
+
displayName: 'New Comment',
|
|
14
|
+
description: 'Triggers when a comment is created',
|
|
15
|
+
aiMetadata: {
|
|
16
|
+
description:
|
|
17
|
+
'Fires when a user posts a new comment on the specified Box file or folder. Each event represents a single created comment, including the comment text, the item it was added to, and the author.',
|
|
18
|
+
},
|
|
19
|
+
type: TriggerStrategy.WEBHOOK,
|
|
20
|
+
props: {
|
|
21
|
+
id: Property.ShortText({
|
|
22
|
+
displayName: 'File/Folder ID',
|
|
23
|
+
description: 'The ID of the item to trigger a webhook',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
type: Property.StaticDropdown({
|
|
27
|
+
displayName: 'Item Type',
|
|
28
|
+
description: 'The type of the item to trigger a webhook',
|
|
29
|
+
required: true,
|
|
30
|
+
options: {
|
|
31
|
+
options: [
|
|
32
|
+
{ label: 'File', value: 'file' },
|
|
33
|
+
{ label: 'Folder', value: 'folder' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async onEnable(context) {
|
|
40
|
+
const target: any = {
|
|
41
|
+
id: context.propsValue.id,
|
|
42
|
+
type: context.propsValue.type,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const webhook = await common.subscribeWebhook(context.auth, {
|
|
46
|
+
event: 'COMMENT.CREATED',
|
|
47
|
+
target: target,
|
|
48
|
+
webhookUrl: context.webhookUrl,
|
|
49
|
+
});
|
|
50
|
+
await context.store.put(`_new_comment_trigger`, webhook);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
async onDisable(context) {
|
|
54
|
+
const webhook = await context.store.get<WebhookInformation>(
|
|
55
|
+
`_new_comment_trigger`
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (webhook) {
|
|
59
|
+
await common.unsubscribeWebhook(context.auth, webhook.id);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
async run(context) {
|
|
64
|
+
return [context.payload.body];
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
sampleData: {
|
|
68
|
+
type: 'webhook_event',
|
|
69
|
+
id: '9a30442d-f681-4d25-8815-aa46f0515387',
|
|
70
|
+
created_at: '2023-04-19T13:25:07-07:00',
|
|
71
|
+
trigger: 'COMMENT.CREATED',
|
|
72
|
+
webhook: { id: '1396363668', type: 'webhook' },
|
|
73
|
+
created_by: {
|
|
74
|
+
type: 'user',
|
|
75
|
+
id: '24316851337',
|
|
76
|
+
name: 'Bonobo',
|
|
77
|
+
login: 'email@gmail.com',
|
|
78
|
+
},
|
|
79
|
+
source: {
|
|
80
|
+
id: '538146815',
|
|
81
|
+
type: 'comment',
|
|
82
|
+
is_reply_comment: false,
|
|
83
|
+
message: 'Simple times...',
|
|
84
|
+
created_by: {
|
|
85
|
+
type: 'user',
|
|
86
|
+
id: '24316851337',
|
|
87
|
+
name: 'Bonobo',
|
|
88
|
+
login: 'email@gmail.com',
|
|
89
|
+
},
|
|
90
|
+
created_at: '2023-04-19T13:25:07-07:00',
|
|
91
|
+
item: { id: '1194590019402', type: 'file' },
|
|
92
|
+
modified_at: '2023-04-19T13:25:07-07:00',
|
|
93
|
+
},
|
|
94
|
+
additional_info: [],
|
|
95
|
+
},
|
|
96
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTrigger,
|
|
3
|
+
TriggerStrategy,
|
|
4
|
+
Property,
|
|
5
|
+
} from '@agnocon/pieces-framework';
|
|
6
|
+
|
|
7
|
+
import { boxAuth } from '../..';
|
|
8
|
+
import { WebhookInformation, common } from '../common';
|
|
9
|
+
|
|
10
|
+
export const newFile = createTrigger({
|
|
11
|
+
auth: boxAuth,
|
|
12
|
+
name: 'new_file',
|
|
13
|
+
displayName: 'New File',
|
|
14
|
+
description: 'Triggers when a file is uploaded',
|
|
15
|
+
aiMetadata: {
|
|
16
|
+
description:
|
|
17
|
+
'Fires when a new file is uploaded into the specified Box folder. Each event represents one uploaded file, including its name, ID, size, version, and parent folder.',
|
|
18
|
+
},
|
|
19
|
+
type: TriggerStrategy.WEBHOOK,
|
|
20
|
+
props: {
|
|
21
|
+
folder: Property.ShortText({
|
|
22
|
+
displayName: 'Folder ID',
|
|
23
|
+
description:
|
|
24
|
+
'The ID of the folder in which file uploads will trigger this webhook',
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async onEnable(context) {
|
|
30
|
+
const target: any = {
|
|
31
|
+
id: context.propsValue.folder,
|
|
32
|
+
type: 'folder',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const webhook = await common.subscribeWebhook(context.auth, {
|
|
36
|
+
event: 'FILE.UPLOADED',
|
|
37
|
+
target: target,
|
|
38
|
+
webhookUrl: context.webhookUrl,
|
|
39
|
+
});
|
|
40
|
+
await context.store.put(`_new_file_trigger`, webhook);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
async onDisable(context) {
|
|
44
|
+
const webhook = await context.store.get<WebhookInformation>(
|
|
45
|
+
`_new_file_trigger`
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (webhook) {
|
|
49
|
+
await common.unsubscribeWebhook(context.auth, webhook.id);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
async run(context) {
|
|
54
|
+
return [context.payload.body];
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
sampleData: {
|
|
58
|
+
type: 'webhook_event',
|
|
59
|
+
id: 'fb0bd323-33b9-4f71-9dbc-fbcc3fe109ad',
|
|
60
|
+
created_at: '2023-04-19T12:06:52-07:00',
|
|
61
|
+
trigger: 'FILE.UPLOADED',
|
|
62
|
+
webhook: { id: '1396340122', type: 'webhook' },
|
|
63
|
+
created_by: {
|
|
64
|
+
type: 'user',
|
|
65
|
+
id: '24316851337',
|
|
66
|
+
name: 'Bonobo',
|
|
67
|
+
login: 'email@gmail.com',
|
|
68
|
+
},
|
|
69
|
+
source: {
|
|
70
|
+
id: '1194585432265',
|
|
71
|
+
type: 'file',
|
|
72
|
+
file_version: {
|
|
73
|
+
type: 'file_version',
|
|
74
|
+
id: '1302595111465',
|
|
75
|
+
sha1: '63da452d845b91ccb638510d046b902e96275359',
|
|
76
|
+
},
|
|
77
|
+
sequence_id: '0',
|
|
78
|
+
etag: '0',
|
|
79
|
+
sha1: '63da452d845b91ccb638510d046b902e96275359',
|
|
80
|
+
name: 'ap-logo.svg',
|
|
81
|
+
description: '',
|
|
82
|
+
size: 877,
|
|
83
|
+
path_collection: { total_count: 2, entries: [Array] },
|
|
84
|
+
created_at: '2023-04-19T12:06:52-07:00',
|
|
85
|
+
modified_at: '2023-04-19T12:06:52-07:00',
|
|
86
|
+
trashed_at: null,
|
|
87
|
+
purged_at: null,
|
|
88
|
+
content_created_at: '2023-02-02T06:54:17-08:00',
|
|
89
|
+
content_modified_at: '2023-02-02T06:54:17-08:00',
|
|
90
|
+
created_by: {
|
|
91
|
+
type: 'user',
|
|
92
|
+
id: '24316851337',
|
|
93
|
+
name: 'Bonobo',
|
|
94
|
+
login: 'email@gmail.com',
|
|
95
|
+
},
|
|
96
|
+
modified_by: {
|
|
97
|
+
type: 'user',
|
|
98
|
+
id: '24316851332',
|
|
99
|
+
name: 'Bonobo',
|
|
100
|
+
login: 'email@gmail.com',
|
|
101
|
+
},
|
|
102
|
+
owned_by: {
|
|
103
|
+
type: 'user',
|
|
104
|
+
id: '24316851332',
|
|
105
|
+
name: 'Bonobo',
|
|
106
|
+
login: 'email@gmail.com',
|
|
107
|
+
},
|
|
108
|
+
shared_link: null,
|
|
109
|
+
parent: {
|
|
110
|
+
type: 'folder',
|
|
111
|
+
id: '198605434359',
|
|
112
|
+
sequence_id: '0',
|
|
113
|
+
etag: '0',
|
|
114
|
+
name: 'Kinembe',
|
|
115
|
+
},
|
|
116
|
+
item_status: 'active',
|
|
117
|
+
},
|
|
118
|
+
additional_info: [],
|
|
119
|
+
},
|
|
120
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTrigger,
|
|
3
|
+
TriggerStrategy,
|
|
4
|
+
Property,
|
|
5
|
+
} from '@agnocon/pieces-framework';
|
|
6
|
+
|
|
7
|
+
import { boxAuth } from '../..';
|
|
8
|
+
import { WebhookInformation, common } from '../common';
|
|
9
|
+
|
|
10
|
+
export const newFolder = createTrigger({
|
|
11
|
+
auth: boxAuth,
|
|
12
|
+
name: 'new_folder',
|
|
13
|
+
displayName: 'New Folder',
|
|
14
|
+
description: 'Triggers when a folder is created',
|
|
15
|
+
aiMetadata: {
|
|
16
|
+
description:
|
|
17
|
+
'Fires when a new folder is created inside the specified Box parent folder. Each event represents one newly created folder, including its name, ID, parent folder, and creation timestamp.',
|
|
18
|
+
},
|
|
19
|
+
type: TriggerStrategy.WEBHOOK,
|
|
20
|
+
props: {
|
|
21
|
+
folder: Property.ShortText({
|
|
22
|
+
displayName: 'Folder ID',
|
|
23
|
+
description:
|
|
24
|
+
'The ID of the folder in which file uploads will trigger this webhook',
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async onEnable(context) {
|
|
30
|
+
const target: any = {
|
|
31
|
+
id: context.propsValue.folder,
|
|
32
|
+
type: 'folder',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const webhook = await common.subscribeWebhook(context.auth, {
|
|
36
|
+
event: 'FOLDER.CREATED',
|
|
37
|
+
target: target,
|
|
38
|
+
webhookUrl: context.webhookUrl,
|
|
39
|
+
});
|
|
40
|
+
await context.store.put(`_new_folder_trigger`, webhook);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
async onDisable(context) {
|
|
44
|
+
const webhook = await context.store.get<WebhookInformation>(
|
|
45
|
+
`_new_folder_trigger`
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (webhook) {
|
|
49
|
+
await common.unsubscribeWebhook(context.auth, webhook.id);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
async run(context) {
|
|
54
|
+
return [context.payload.body];
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
sampleData: {
|
|
58
|
+
id: '3f08aca1-aa0b-49a5-8e5a-5d8980bfbdef',
|
|
59
|
+
type: 'webhook_event',
|
|
60
|
+
source: {
|
|
61
|
+
id: '218634717358',
|
|
62
|
+
etag: '0',
|
|
63
|
+
name: 'test folder',
|
|
64
|
+
size: 0,
|
|
65
|
+
type: 'folder',
|
|
66
|
+
parent: {
|
|
67
|
+
id: '218635125044',
|
|
68
|
+
etag: '0',
|
|
69
|
+
name: 'Desktop',
|
|
70
|
+
type: 'folder',
|
|
71
|
+
sequence_id: '0',
|
|
72
|
+
},
|
|
73
|
+
purged_at: null,
|
|
74
|
+
created_at: '2023-07-25T05:55:08-07:00',
|
|
75
|
+
trashed_at: null,
|
|
76
|
+
description: '',
|
|
77
|
+
item_status: 'active',
|
|
78
|
+
modified_at: '2023-07-25T05:55:08-07:00',
|
|
79
|
+
sequence_id: '0',
|
|
80
|
+
shared_link: null,
|
|
81
|
+
path_collection: {
|
|
82
|
+
entries: [
|
|
83
|
+
{
|
|
84
|
+
id: '0',
|
|
85
|
+
etag: null,
|
|
86
|
+
name: 'All Files',
|
|
87
|
+
type: 'folder',
|
|
88
|
+
sequence_id: null,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: '218635125044',
|
|
92
|
+
etag: '0',
|
|
93
|
+
name: 'Desktop',
|
|
94
|
+
type: 'folder',
|
|
95
|
+
sequence_id: '0',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
total_count: 2,
|
|
99
|
+
},
|
|
100
|
+
content_created_at: '2023-07-25T05:55:08-07:00',
|
|
101
|
+
content_modified_at: '2023-07-25T05:55:08-07:00',
|
|
102
|
+
folder_upload_email: null,
|
|
103
|
+
},
|
|
104
|
+
trigger: 'FOLDER.CREATED',
|
|
105
|
+
webhook: {
|
|
106
|
+
id: '1738566186',
|
|
107
|
+
type: 'webhook',
|
|
108
|
+
},
|
|
109
|
+
created_at: '2023-07-25T05:55:09-07:00',
|
|
110
|
+
additional_info: [],
|
|
111
|
+
},
|
|
112
|
+
});
|