@activepieces/piece-hootsuite 0.0.1
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/package.json +16 -0
- package/src/index.d.ts +4 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +39 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-message.d.ts +7 -0
- package/src/lib/actions/create-message.d.ts.map +1 -0
- package/src/lib/actions/create-message.js +95 -0
- package/src/lib/actions/create-message.js.map +1 -0
- package/src/lib/actions/delete-message.d.ts +4 -0
- package/src/lib/actions/delete-message.d.ts.map +1 -0
- package/src/lib/actions/delete-message.js +35 -0
- package/src/lib/actions/delete-message.js.map +1 -0
- package/src/lib/actions/get-message.d.ts +4 -0
- package/src/lib/actions/get-message.d.ts.map +1 -0
- package/src/lib/actions/get-message.js +46 -0
- package/src/lib/actions/get-message.js.map +1 -0
- package/src/lib/auth.d.ts +2 -0
- package/src/lib/auth.d.ts.map +1 -0
- package/src/lib/auth.js +12 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/index.d.ts +10 -0
- package/src/lib/common/index.d.ts.map +1 -0
- package/src/lib/common/index.js +21 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/triggers/new-published-post.d.ts +3 -0
- package/src/lib/triggers/new-published-post.d.ts.map +1 -0
- package/src/lib/triggers/new-published-post.js +76 -0
- package/src/lib/triggers/new-published-post.js.map +1 -0
- package/src/lib/triggers/new-scheduled-post.d.ts +3 -0
- package/src/lib/triggers/new-scheduled-post.d.ts.map +1 -0
- package/src/lib/triggers/new-scheduled-post.js +77 -0
- package/src/lib/triggers/new-scheduled-post.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-hootsuite",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
8
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@activepieces/pieces-common": "0.12.3",
|
|
12
|
+
"@activepieces/pieces-framework": "0.28.1",
|
|
13
|
+
"@activepieces/shared": "0.76.7",
|
|
14
|
+
"tslib": "2.6.2"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { hootsuiteAuth } from './lib/auth';
|
|
2
|
+
export declare const hootsuite: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
+
export { hootsuiteAuth };
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,eAAO,MAAM,SAAS,+JAqBpB,CAAC;AAEH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hootsuiteAuth = exports.hootsuite = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const create_message_1 = require("./lib/actions/create-message");
|
|
9
|
+
const get_message_1 = require("./lib/actions/get-message");
|
|
10
|
+
const delete_message_1 = require("./lib/actions/delete-message");
|
|
11
|
+
const new_scheduled_post_1 = require("./lib/triggers/new-scheduled-post");
|
|
12
|
+
const new_published_post_1 = require("./lib/triggers/new-published-post");
|
|
13
|
+
const auth_1 = require("./lib/auth");
|
|
14
|
+
Object.defineProperty(exports, "hootsuiteAuth", { enumerable: true, get: function () { return auth_1.hootsuiteAuth; } });
|
|
15
|
+
exports.hootsuite = (0, pieces_framework_1.createPiece)({
|
|
16
|
+
displayName: 'Hootsuite',
|
|
17
|
+
description: 'Social media management — schedule posts and manage multiple networks from one dashboard.',
|
|
18
|
+
minimumSupportedRelease: '0.36.1',
|
|
19
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/hootsuite.png',
|
|
20
|
+
categories: [shared_1.PieceCategory.MARKETING],
|
|
21
|
+
auth: auth_1.hootsuiteAuth,
|
|
22
|
+
authors: ['onyedikachi-david'],
|
|
23
|
+
actions: [
|
|
24
|
+
create_message_1.createMessageAction,
|
|
25
|
+
get_message_1.getMessageAction,
|
|
26
|
+
delete_message_1.deleteMessageAction,
|
|
27
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
28
|
+
baseUrl: () => 'https://platform.hootsuite.com/v1',
|
|
29
|
+
auth: auth_1.hootsuiteAuth,
|
|
30
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
return ({
|
|
32
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
33
|
+
});
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
triggers: [new_scheduled_post_1.newScheduledPostTrigger, new_published_post_1.newPublishedPostTrigger],
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,+DAAwE;AAExE,iDAAqD;AACrD,iEAAmE;AACnE,2DAA6D;AAC7D,iEAAmE;AACnE,0EAA4E;AAC5E,0EAA4E;AAC5E,qCAA2C;AAyBlC,8FAzBA,oBAAa,OAyBA;AAvBT,QAAA,SAAS,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,2FAA2F;IACxG,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,mDAAmD;IAC5D,UAAU,EAAE,CAAC,sBAAa,CAAC,SAAS,CAAC;IACrC,IAAI,EAAE,oBAAa;IACnB,OAAO,EAAE,CAAC,mBAAmB,CAAC;IAC9B,OAAO,EAAE;QACP,oCAAmB;QACnB,8BAAgB;QAChB,oCAAmB;QACnB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,mCAAmC;YAClD,IAAI,EAAE,oBAAa;YACnB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACtE,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,4CAAuB,EAAE,4CAAuB,CAAC;CAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const createMessageAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
socialProfileIds: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
+
text: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
4
|
+
scheduledSendTime: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
5
|
+
emailNotification: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=create-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-message.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/create-message.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB;;;;;EAiF9B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMessageAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
exports.createMessageAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.hootsuiteAuth,
|
|
11
|
+
name: 'create_message',
|
|
12
|
+
displayName: 'Schedule Post',
|
|
13
|
+
description: 'Schedules or immediately publishes a post to one or more social media profiles.',
|
|
14
|
+
props: {
|
|
15
|
+
socialProfileIds: pieces_framework_1.Property.MultiSelectDropdown({
|
|
16
|
+
displayName: 'Social Profiles',
|
|
17
|
+
description: 'Select the social media profiles to post to.',
|
|
18
|
+
refreshers: [],
|
|
19
|
+
required: true,
|
|
20
|
+
auth: auth_1.hootsuiteAuth,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
if (!auth) {
|
|
23
|
+
return { disabled: true, options: [], placeholder: 'Please connect your Hootsuite account first' };
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const response = yield (0, common_1.hootsuiteApiCall)({
|
|
27
|
+
auth,
|
|
28
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
29
|
+
path: '/socialProfiles',
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
disabled: false,
|
|
33
|
+
options: response.body.data.map((p) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return ({
|
|
36
|
+
label: `${(_a = p.socialNetworkUsername) !== null && _a !== void 0 ? _a : p.id} (${p.type})`,
|
|
37
|
+
value: p.id,
|
|
38
|
+
});
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (_b) {
|
|
43
|
+
return { disabled: true, options: [], placeholder: 'Failed to load profiles. Check your connection.' };
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
text: pieces_framework_1.Property.LongText({
|
|
48
|
+
displayName: 'Post Text',
|
|
49
|
+
description: 'The text content of your post.',
|
|
50
|
+
required: true,
|
|
51
|
+
}),
|
|
52
|
+
scheduledSendTime: pieces_framework_1.Property.DateTime({
|
|
53
|
+
displayName: 'Scheduled Time',
|
|
54
|
+
description: 'When to publish the post (UTC, must be at least 5 minutes in the future). Leave empty to post immediately.',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
emailNotification: pieces_framework_1.Property.Checkbox({
|
|
58
|
+
displayName: 'Email Notification',
|
|
59
|
+
description: 'Send an email notification when the post is published.',
|
|
60
|
+
required: false,
|
|
61
|
+
defaultValue: false,
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
run(context) {
|
|
65
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
var _a, _b, _c, _d, _e;
|
|
67
|
+
const { socialProfileIds, text, scheduledSendTime, emailNotification } = context.propsValue;
|
|
68
|
+
const body = {
|
|
69
|
+
text,
|
|
70
|
+
socialProfileIds,
|
|
71
|
+
emailNotification,
|
|
72
|
+
};
|
|
73
|
+
if (scheduledSendTime) {
|
|
74
|
+
body['scheduledSendTime'] = new Date(scheduledSendTime).toISOString();
|
|
75
|
+
}
|
|
76
|
+
const response = yield (0, common_1.hootsuiteApiCall)({
|
|
77
|
+
auth: context.auth,
|
|
78
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
79
|
+
path: '/messages',
|
|
80
|
+
body,
|
|
81
|
+
});
|
|
82
|
+
const msg = response.body.data;
|
|
83
|
+
return {
|
|
84
|
+
id: msg.id,
|
|
85
|
+
state: msg.state,
|
|
86
|
+
scheduled_send_time: (_a = msg.scheduledSendTime) !== null && _a !== void 0 ? _a : null,
|
|
87
|
+
text: (_b = msg.text) !== null && _b !== void 0 ? _b : text,
|
|
88
|
+
social_profile_ids: ((_c = msg.socialProfileIds) !== null && _c !== void 0 ? _c : socialProfileIds).join(', '),
|
|
89
|
+
post_url: (_d = msg.postUrl) !== null && _d !== void 0 ? _d : null,
|
|
90
|
+
errors: (_e = msg.errors) !== null && _e !== void 0 ? _e : [],
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=create-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-message.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,kCAAwC;AACxC,sCAA6C;AAEhC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,iFAAiF;IAC9F,KAAK,EAAE;QACL,gBAAgB,EAAE,2BAAQ,CAAC,mBAAmB,CAAC;YAC7C,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,8CAA8C;YAC3D,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,oBAAa;YACnB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;gBACrG,CAAC;gBACD,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EAAyB;wBAC9D,IAAI;wBACJ,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AAC;YACF,IAAI,iBAAiB,EAAE,CAAC;gBACtB,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,WAAW,EAAE,CAAC;YACxE,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EAAkB;gBACvD,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,IAAI,EAAE,WAAW;gBACjB,IAAI;aACL,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,OAAO;gBACL,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,mBAAmB,EAAE,MAAA,GAAG,CAAC,iBAAiB,mCAAI,IAAI;gBAClD,IAAI,EAAE,MAAA,GAAG,CAAC,IAAI,mCAAI,IAAI;gBACtB,kBAAkB,EAAE,CAAC,MAAA,GAAG,CAAC,gBAAgB,mCAAI,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBACzE,QAAQ,EAAE,MAAA,GAAG,CAAC,OAAO,mCAAI,IAAI;gBAC7B,MAAM,EAAE,MAAA,GAAG,CAAC,MAAM,mCAAI,EAAE;aACzB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const deleteMessageAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
messageId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
4
|
+
//# sourceMappingURL=delete-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-message.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/delete-message.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB;;EAwB9B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteMessageAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
exports.deleteMessageAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.hootsuiteAuth,
|
|
11
|
+
name: 'delete_message',
|
|
12
|
+
displayName: 'Delete Post',
|
|
13
|
+
description: 'Permanently deletes a post. Only posts in a deletable state (e.g. SCHEDULED) can be removed.',
|
|
14
|
+
props: {
|
|
15
|
+
messageId: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Post ID',
|
|
17
|
+
description: 'The unique ID of the post to delete. You can get this from the "Schedule Post" or "Get Post Details" action.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
yield (0, common_1.hootsuiteApiCall)({
|
|
24
|
+
auth: context.auth,
|
|
25
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
26
|
+
path: `/messages/${context.propsValue.messageId}`,
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
success: true,
|
|
30
|
+
deleted_message_id: context.propsValue.messageId,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=delete-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-message.js","sourceRoot":"","sources":["../../../../src/lib/actions/delete-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,kCAAwC;AACxC,sCAA6C;AAEhC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,8FAA8F;IAC3G,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,8GAA8G;YAC3H,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,IAAA,yBAAgB,EAAC;gBACrB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,MAAM;gBACzB,IAAI,EAAE,aAAa,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE;aAClD,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,kBAAkB,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS;aACjD,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getMessageAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
messageId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
4
|
+
//# sourceMappingURL=get-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-message.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-message.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;;EAkC3B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMessageAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
exports.getMessageAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.hootsuiteAuth,
|
|
11
|
+
name: 'get_message',
|
|
12
|
+
displayName: 'Get Post Details',
|
|
13
|
+
description: 'Retrieves the details of a specific scheduled or published post by its ID.',
|
|
14
|
+
props: {
|
|
15
|
+
messageId: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Post ID',
|
|
17
|
+
description: 'The unique ID of the post. You can get this from a previous "Schedule Post" action output or from the Hootsuite dashboard URL.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
24
|
+
const response = yield (0, common_1.hootsuiteApiCall)({
|
|
25
|
+
auth: context.auth,
|
|
26
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
27
|
+
path: `/messages/${context.propsValue.messageId}`,
|
|
28
|
+
});
|
|
29
|
+
const msg = response.body.data;
|
|
30
|
+
return {
|
|
31
|
+
id: msg.id,
|
|
32
|
+
state: msg.state,
|
|
33
|
+
text: (_a = msg.text) !== null && _a !== void 0 ? _a : null,
|
|
34
|
+
scheduled_send_time: (_b = msg.scheduledSendTime) !== null && _b !== void 0 ? _b : null,
|
|
35
|
+
send_time: (_c = msg.sendTime) !== null && _c !== void 0 ? _c : null,
|
|
36
|
+
social_profile_ids: ((_d = msg.socialProfileIds) !== null && _d !== void 0 ? _d : []).join(', '),
|
|
37
|
+
post_url: (_e = msg.postUrl) !== null && _e !== void 0 ? _e : null,
|
|
38
|
+
tags: (_f = msg.tags) !== null && _f !== void 0 ? _f : [],
|
|
39
|
+
email_notification: (_g = msg.emailNotification) !== null && _g !== void 0 ? _g : null,
|
|
40
|
+
location: (_h = msg.location) !== null && _h !== void 0 ? _h : null,
|
|
41
|
+
errors: (_j = msg.errors) !== null && _j !== void 0 ? _j : [],
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=get-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-message.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,kCAAwC;AACxC,sCAA6C;AAEhC,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,4EAA4E;IACzF,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,gIAAgI;YAC7I,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EAAkB;gBACvD,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,aAAa,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE;aAClD,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,OAAO;gBACL,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,IAAI,EAAE,MAAA,GAAG,CAAC,IAAI,mCAAI,IAAI;gBACtB,mBAAmB,EAAE,MAAA,GAAG,CAAC,iBAAiB,mCAAI,IAAI;gBAClD,SAAS,EAAE,MAAA,GAAG,CAAC,QAAQ,mCAAI,IAAI;gBAC/B,kBAAkB,EAAE,CAAC,MAAA,GAAG,CAAC,gBAAgB,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC3D,QAAQ,EAAE,MAAA,GAAG,CAAC,OAAO,mCAAI,IAAI;gBAC7B,IAAI,EAAE,MAAA,GAAG,CAAC,IAAI,mCAAI,EAAE;gBACpB,kBAAkB,EAAE,MAAA,GAAG,CAAC,iBAAiB,mCAAI,IAAI;gBACjD,QAAQ,EAAE,MAAA,GAAG,CAAC,QAAQ,mCAAI,IAAI;gBAC9B,MAAM,EAAE,MAAA,GAAG,CAAC,MAAM,mCAAI,EAAE;aACzB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,+GAOxB,CAAC"}
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hootsuiteAuth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
exports.hootsuiteAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
6
|
+
description: 'Connect your Hootsuite account. Create an OAuth2 app and get your client credentials at https://developer.hootsuite.com.',
|
|
7
|
+
required: true,
|
|
8
|
+
authUrl: 'https://platform.hootsuite.com/oauth2/auth',
|
|
9
|
+
tokenUrl: 'https://platform.hootsuite.com/oauth2/token',
|
|
10
|
+
scope: ['offline', 'post'],
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,qEAA2D;AAE9C,QAAA,aAAa,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC5C,WAAW,EACT,0HAA0H;IAC5H,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,4CAA4C;IACrD,QAAQ,EAAE,6CAA6C;IACvD,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpMethod, HttpMessageBody, HttpResponse } from '@activepieces/pieces-common';
|
|
2
|
+
import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
|
|
3
|
+
export declare function hootsuiteApiCall<T extends HttpMessageBody>({ auth, method, path, body, queryParams, }: {
|
|
4
|
+
auth: OAuth2PropertyValue;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
path: string;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
queryParams?: Record<string, string>;
|
|
9
|
+
}): Promise<HttpResponse<T>>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,eAAe,EACf,YAAY,EAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,eAAe,EAAE,EAChE,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAW3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hootsuiteApiCall = hootsuiteApiCall;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const BASE_URL = 'https://platform.hootsuite.com/v1';
|
|
7
|
+
function hootsuiteApiCall(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, method, path, body, queryParams, }) {
|
|
9
|
+
return pieces_common_1.httpClient.sendRequest({
|
|
10
|
+
method,
|
|
11
|
+
url: `${BASE_URL}${path}`,
|
|
12
|
+
authentication: {
|
|
13
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
14
|
+
token: auth.access_token,
|
|
15
|
+
},
|
|
16
|
+
body,
|
|
17
|
+
queryParams,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":";;AAWA,4CAuBC;;AAlCD,+DAMqC;AAGrC,MAAM,QAAQ,GAAG,mCAAmC,CAAC;AAErD,SAAsB,gBAAgB;iEAA4B,EAChE,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,WAAW,GAOZ;QACC,OAAO,0BAAU,CAAC,WAAW,CAAI;YAC/B,MAAM;YACN,GAAG,EAAE,GAAG,QAAQ,GAAG,IAAI,EAAE;YACzB,cAAc,EAAE;gBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;gBACrC,KAAK,EAAE,IAAI,CAAC,YAAY;aACzB;YACD,IAAI;YACJ,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newPublishedPostTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}>;
|
|
3
|
+
//# sourceMappingURL=new-published-post.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-published-post.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-published-post.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AA0CxC,eAAO,MAAM,uBAAuB,kwBA2BlC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newPublishedPostTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
const polling = {
|
|
10
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
11
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
12
|
+
var _b;
|
|
13
|
+
const response = yield (0, common_1.hootsuiteApiCall)({
|
|
14
|
+
auth,
|
|
15
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
16
|
+
path: '/messages',
|
|
17
|
+
queryParams: {
|
|
18
|
+
state: 'SENT',
|
|
19
|
+
limit: '50',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return ((_b = response.body.data) !== null && _b !== void 0 ? _b : [])
|
|
23
|
+
.filter((msg) => !!msg.sendTime)
|
|
24
|
+
.map((msg) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
return ({
|
|
27
|
+
epochMilliSeconds: new Date(msg.sendTime).getTime(),
|
|
28
|
+
data: {
|
|
29
|
+
id: msg.id,
|
|
30
|
+
state: msg.state,
|
|
31
|
+
send_time: msg.sendTime,
|
|
32
|
+
text: (_a = msg.text) !== null && _a !== void 0 ? _a : null,
|
|
33
|
+
post_url: (_b = msg.postUrl) !== null && _b !== void 0 ? _b : null,
|
|
34
|
+
social_profile_ids: ((_c = msg.socialProfileIds) !== null && _c !== void 0 ? _c : []).join(', '),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
exports.newPublishedPostTrigger = (0, pieces_framework_1.createTrigger)({
|
|
41
|
+
auth: auth_1.hootsuiteAuth,
|
|
42
|
+
name: 'new_published_post',
|
|
43
|
+
displayName: 'New Published Post',
|
|
44
|
+
description: 'Triggers when a post is published (sent) in Hootsuite.',
|
|
45
|
+
props: {},
|
|
46
|
+
sampleData: {
|
|
47
|
+
id: 'msg_xyz456',
|
|
48
|
+
state: 'SENT',
|
|
49
|
+
send_time: '2024-06-01T10:00:00Z',
|
|
50
|
+
text: 'Check out our latest blog post!',
|
|
51
|
+
post_url: 'https://twitter.com/example/status/123456',
|
|
52
|
+
social_profile_ids: 'profile_1',
|
|
53
|
+
},
|
|
54
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
55
|
+
test(context) {
|
|
56
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return pieces_common_1.pollingHelper.test(polling, context);
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
onEnable(context) {
|
|
61
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, context);
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
onDisable(context) {
|
|
66
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, context);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
run(context) {
|
|
71
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return pieces_common_1.pollingHelper.poll(polling, context);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=new-published-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-published-post.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-published-post.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,+DAKqC;AACrC,kCAAwC;AACxC,sCAA6C;AAE7C,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;;QACpB,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EAAmB;YACxD,IAAI;YACJ,MAAM,EAAE,0BAAU,CAAC,GAAG;YACtB,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE;gBACX,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,IAAI;aACZ;SACF,CAAC,CAAC;QAEH,OAAO,CAAC,MAAA,QAAQ,CAAC,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;aAC9B,MAAM,CAAC,CAAC,GAAG,EAAkD,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,Q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CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newScheduledPostTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}>;
|
|
3
|
+
//# sourceMappingURL=new-scheduled-post.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-scheduled-post.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-scheduled-post.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AA4CxC,eAAO,MAAM,uBAAuB,kwBA0BlC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newScheduledPostTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
const polling = {
|
|
10
|
+
// LAST_ITEM is correct here: we want to fire when a post is newly created/scheduled,
|
|
11
|
+
// not when its scheduled time arrives. TIMEBASED with scheduledSendTime would fire
|
|
12
|
+
// based on due-time, causing posts scheduled for earlier dates to be missed.
|
|
13
|
+
strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
|
|
14
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
var _b;
|
|
16
|
+
const response = yield (0, common_1.hootsuiteApiCall)({
|
|
17
|
+
auth,
|
|
18
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
19
|
+
path: '/messages',
|
|
20
|
+
queryParams: {
|
|
21
|
+
state: 'SCHEDULED',
|
|
22
|
+
limit: '50',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return ((_b = response.body.data) !== null && _b !== void 0 ? _b : [])
|
|
26
|
+
.sort((a, b) => new Date(b.scheduledSendTime).getTime() - new Date(a.scheduledSendTime).getTime())
|
|
27
|
+
.map((msg) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
return ({
|
|
30
|
+
id: msg.id,
|
|
31
|
+
data: {
|
|
32
|
+
id: msg.id,
|
|
33
|
+
state: msg.state,
|
|
34
|
+
scheduled_send_time: msg.scheduledSendTime,
|
|
35
|
+
text: (_a = msg.text) !== null && _a !== void 0 ? _a : null,
|
|
36
|
+
social_profile_ids: ((_b = msg.socialProfileIds) !== null && _b !== void 0 ? _b : []).join(', '),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
exports.newScheduledPostTrigger = (0, pieces_framework_1.createTrigger)({
|
|
43
|
+
auth: auth_1.hootsuiteAuth,
|
|
44
|
+
name: 'new_scheduled_post',
|
|
45
|
+
displayName: 'New Scheduled Post',
|
|
46
|
+
description: 'Triggers when a new post is scheduled in Hootsuite.',
|
|
47
|
+
props: {},
|
|
48
|
+
sampleData: {
|
|
49
|
+
id: 'msg_abc123',
|
|
50
|
+
state: 'SCHEDULED',
|
|
51
|
+
scheduled_send_time: '2024-06-01T10:00:00Z',
|
|
52
|
+
text: 'Check out our latest blog post!',
|
|
53
|
+
social_profile_ids: 'profile_1, profile_2',
|
|
54
|
+
},
|
|
55
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
56
|
+
test(context) {
|
|
57
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return pieces_common_1.pollingHelper.test(polling, context);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
onEnable(context) {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, context);
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
onDisable(context) {
|
|
67
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, context);
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
run(context) {
|
|
72
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
return pieces_common_1.pollingHelper.poll(polling, context);
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=new-scheduled-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-scheduled-post.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-scheduled-post.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,+DAKqC;AACrC,kCAAwC;AACxC,sCAA6C;AAE7C,MAAM,OAAO,GAGT;IACF,qFAAqF;IACrF,mFAAmF;IACnF,6EAA6E;IAC7E,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAAiB,EAAE,oDAAZ,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