@agnocon/piece-buffer 0.0.5
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 +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/create-idea.d.ts +8 -0
- package/dist/lib/actions/create-idea.d.ts.map +1 -0
- package/dist/lib/actions/create-idea.js +102 -0
- package/dist/lib/actions/create-idea.js.map +1 -0
- package/dist/lib/actions/create-post.d.ts +12 -0
- package/dist/lib/actions/create-post.d.ts.map +1 -0
- package/dist/lib/actions/create-post.js +141 -0
- package/dist/lib/actions/create-post.js.map +1 -0
- package/dist/lib/common/auth.d.ts +2 -0
- package/dist/lib/common/auth.d.ts.map +1 -0
- package/dist/lib/common/auth.js +37 -0
- package/dist/lib/common/auth.js.map +1 -0
- package/dist/lib/common/client.d.ts +11 -0
- package/dist/lib/common/client.d.ts.map +1 -0
- package/dist/lib/common/client.js +34 -0
- package/dist/lib/common/client.js.map +1 -0
- package/dist/lib/common/props.d.ts +52 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +181 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/triggers/new-channel.d.ts +11 -0
- package/dist/lib/triggers/new-channel.d.ts.map +1 -0
- package/dist/lib/triggers/new-channel.js +73 -0
- package/dist/lib/triggers/new-channel.js.map +1 -0
- package/dist/lib/triggers/new-queue-item.d.ts +15 -0
- package/dist/lib/triggers/new-queue-item.d.ts.map +1 -0
- package/dist/lib/triggers/new-queue-item.js +118 -0
- package/dist/lib/triggers/new-queue-item.js.map +1 -0
- package/dist/lib/triggers/new-sent-item.d.ts +15 -0
- package/dist/lib/triggers/new-sent-item.d.ts.map +1 -0
- package/dist/lib/triggers/new-sent-item.js +117 -0
- package/dist/lib/triggers/new-sent-item.js.map +1 -0
- package/package.json +46 -0
- package/src/index.ts +33 -0
- package/src/lib/actions/create-idea.ts +123 -0
- package/src/lib/actions/create-post.ts +173 -0
- package/src/lib/common/auth.ts +31 -0
- package/src/lib/common/client.ts +44 -0
- package/src/lib/common/props.ts +224 -0
- package/src/lib/triggers/new-channel.ts +73 -0
- package/src/lib/triggers/new-queue-item.ts +122 -0
- package/src/lib/triggers/new-sent-item.ts +121 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bufferQueries = exports.bufferProps = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/buffer/src/lib/common/props.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 auth_1 = require("./auth");
|
|
9
|
+
const client_1 = require("./client");
|
|
10
|
+
function fetchOrganizations(accessToken) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const data = yield client_1.bufferClient.graphql({
|
|
14
|
+
accessToken,
|
|
15
|
+
query: `query { account { organizations { id name } } }`,
|
|
16
|
+
});
|
|
17
|
+
return (_b = (_a = data.account) === null || _a === void 0 ? void 0 : _a.organizations) !== null && _b !== void 0 ? _b : [];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function fetchChannels(accessToken, organizationId) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a;
|
|
23
|
+
const data = yield client_1.bufferClient.graphql({
|
|
24
|
+
accessToken,
|
|
25
|
+
query: `query Channels($organizationId: OrganizationId!) {
|
|
26
|
+
channels(input: { organizationId: $organizationId }) {
|
|
27
|
+
id
|
|
28
|
+
name
|
|
29
|
+
service
|
|
30
|
+
organizationId
|
|
31
|
+
createdAt
|
|
32
|
+
}
|
|
33
|
+
}`,
|
|
34
|
+
variables: { organizationId },
|
|
35
|
+
});
|
|
36
|
+
return (_a = data.channels) !== null && _a !== void 0 ? _a : [];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function fetchPosts(_a) {
|
|
40
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ accessToken, organizationId, channelIds, statusFilter, first = 50, }) {
|
|
41
|
+
var _b, _c;
|
|
42
|
+
const filter = {};
|
|
43
|
+
if (channelIds && channelIds.length > 0)
|
|
44
|
+
filter['channelIds'] = channelIds;
|
|
45
|
+
const data = yield client_1.bufferClient.graphql({
|
|
46
|
+
accessToken,
|
|
47
|
+
query: `query Posts($input: PostsInput!, $first: Int) {
|
|
48
|
+
posts(input: $input, first: $first) {
|
|
49
|
+
edges {
|
|
50
|
+
node {
|
|
51
|
+
id
|
|
52
|
+
text
|
|
53
|
+
status
|
|
54
|
+
createdAt
|
|
55
|
+
updatedAt
|
|
56
|
+
dueAt
|
|
57
|
+
sentAt
|
|
58
|
+
channelId
|
|
59
|
+
channelService
|
|
60
|
+
channel { id name service }
|
|
61
|
+
tags { id name }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}`,
|
|
66
|
+
variables: {
|
|
67
|
+
input: Object.assign({ organizationId }, (Object.keys(filter).length > 0 ? { filter } : {})),
|
|
68
|
+
first,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const posts = ((_c = (_b = data.posts) === null || _b === void 0 ? void 0 : _b.edges) !== null && _c !== void 0 ? _c : []).map((edge) => edge.node);
|
|
72
|
+
return statusFilter ? posts.filter((post) => statusFilter(post.status)) : posts;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.bufferProps = {
|
|
76
|
+
organizationId: () => pieces_framework_1.Property.Dropdown({
|
|
77
|
+
auth: auth_1.bufferAuth,
|
|
78
|
+
displayName: 'Organization',
|
|
79
|
+
description: 'The Buffer organization to use.',
|
|
80
|
+
required: true,
|
|
81
|
+
refreshers: [],
|
|
82
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
83
|
+
if (!auth) {
|
|
84
|
+
return {
|
|
85
|
+
disabled: true,
|
|
86
|
+
placeholder: 'Connect your Buffer account first.',
|
|
87
|
+
options: [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const organizations = yield fetchOrganizations(auth.secret_text);
|
|
92
|
+
return {
|
|
93
|
+
disabled: false,
|
|
94
|
+
options: organizations.map((org) => ({
|
|
95
|
+
label: org.name,
|
|
96
|
+
value: org.id,
|
|
97
|
+
})),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (_b) {
|
|
101
|
+
return {
|
|
102
|
+
disabled: true,
|
|
103
|
+
placeholder: 'Failed to load organizations.',
|
|
104
|
+
options: [],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
channelIds: (required = true) => pieces_framework_1.Property.MultiSelectDropdown({
|
|
110
|
+
auth: auth_1.bufferAuth,
|
|
111
|
+
displayName: 'Channels',
|
|
112
|
+
description: 'The Buffer channels to publish to.',
|
|
113
|
+
required,
|
|
114
|
+
refreshers: ['organizationId'],
|
|
115
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, organizationId }) {
|
|
116
|
+
if (!auth || !organizationId) {
|
|
117
|
+
return {
|
|
118
|
+
disabled: true,
|
|
119
|
+
placeholder: 'Select an organization first.',
|
|
120
|
+
options: [],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const channels = yield fetchChannels(auth.secret_text, organizationId);
|
|
125
|
+
return {
|
|
126
|
+
disabled: false,
|
|
127
|
+
options: channels.map((channel) => ({
|
|
128
|
+
label: `${channel.name} (${channel.service})`,
|
|
129
|
+
value: channel.id,
|
|
130
|
+
})),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (_b) {
|
|
134
|
+
return {
|
|
135
|
+
disabled: true,
|
|
136
|
+
placeholder: 'Failed to load channels.',
|
|
137
|
+
options: [],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
}),
|
|
142
|
+
channelId: () => pieces_framework_1.Property.Dropdown({
|
|
143
|
+
auth: auth_1.bufferAuth,
|
|
144
|
+
displayName: 'Channel',
|
|
145
|
+
description: 'The Buffer channel.',
|
|
146
|
+
required: true,
|
|
147
|
+
refreshers: ['organizationId'],
|
|
148
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, organizationId }) {
|
|
149
|
+
if (!auth || !organizationId) {
|
|
150
|
+
return {
|
|
151
|
+
disabled: true,
|
|
152
|
+
placeholder: 'Select an organization first.',
|
|
153
|
+
options: [],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const channels = yield fetchChannels(auth.secret_text, organizationId);
|
|
158
|
+
return {
|
|
159
|
+
disabled: false,
|
|
160
|
+
options: channels.map((channel) => ({
|
|
161
|
+
label: `${channel.name} (${channel.service})`,
|
|
162
|
+
value: channel.id,
|
|
163
|
+
})),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
catch (_b) {
|
|
167
|
+
return {
|
|
168
|
+
disabled: true,
|
|
169
|
+
placeholder: 'Failed to load channels.',
|
|
170
|
+
options: [],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
}),
|
|
175
|
+
};
|
|
176
|
+
exports.bufferQueries = {
|
|
177
|
+
fetchOrganizations,
|
|
178
|
+
fetchChannels,
|
|
179
|
+
fetchPosts,
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,6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AI,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBAC7B,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,+BAA+B;oBAC5C,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,aAAa,CAClC,IAAI,CAAC,WAAW,EAChB,cAAwB,CACzB,CAAC;gBACF,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;wBAClC,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,GAAG;wBAC7C,KAAK,EAAE,OAAO,CAAC,EAAE;qBAClB,CAAC,CAAC;iBACJ,CAAC;YACJ,CAAC;YAAC,WAAM,CAAC;gBACP,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,0BAA0B;oBACvC,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC,CAAA;KACF,CAAC;CACL,CAAC;AAEW,QAAA,aAAa,GAAG;IAC3B,kBAAkB;IAClB,aAAa;IACb,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newChannel: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
5
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
7
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-channel.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-channel.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AA4BnC,eAAO,MAAM,UAAU;;;;;;;;EAwCrB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newChannel = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/buffer/src/lib/triggers/new-channel.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 auth_1 = require("../common/auth");
|
|
10
|
+
const props_1 = require("../common/props");
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
+
items(_a) {
|
|
14
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
15
|
+
const channels = yield props_1.bufferQueries.fetchChannels(auth.secret_text, propsValue.organizationId);
|
|
16
|
+
return channels.map((channel) => ({
|
|
17
|
+
epochMilliSeconds: channel.createdAt
|
|
18
|
+
? new Date(channel.createdAt).getTime()
|
|
19
|
+
: 0,
|
|
20
|
+
data: channel,
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
exports.newChannel = (0, pieces_framework_1.createTrigger)({
|
|
26
|
+
auth: auth_1.bufferAuth,
|
|
27
|
+
name: 'new_channel',
|
|
28
|
+
displayName: 'New Channel',
|
|
29
|
+
description: 'Triggers when a new channel is connected to your Buffer organization.',
|
|
30
|
+
aiMetadata: {
|
|
31
|
+
description: 'Fires when a new social media channel (e.g. a Facebook page, Instagram or X account) is connected to the selected Buffer organization, representing the newly linked channel.',
|
|
32
|
+
},
|
|
33
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
34
|
+
props: {
|
|
35
|
+
organizationId: props_1.bufferProps.organizationId(),
|
|
36
|
+
},
|
|
37
|
+
sampleData: {
|
|
38
|
+
id: 'channel_id_example',
|
|
39
|
+
name: 'My Page',
|
|
40
|
+
service: 'facebook',
|
|
41
|
+
organizationId: 'org_id_example',
|
|
42
|
+
createdAt: '2026-05-25T10:00:00.000Z',
|
|
43
|
+
},
|
|
44
|
+
onEnable(context) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
47
|
+
auth: context.auth,
|
|
48
|
+
store: context.store,
|
|
49
|
+
propsValue: context.propsValue,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
onDisable(context) {
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
56
|
+
auth: context.auth,
|
|
57
|
+
store: context.store,
|
|
58
|
+
propsValue: context.propsValue,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
test(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
run(context) {
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=new-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-channel.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-channel.ts"],"names":[],"mappings":";;;;AAAA,qGAAqG;AACrG,qEAAqE;AACrE,gEAImC;AACnC,0DAIgC;AAChC,yCAA4C;AAC5C,2CAAsE;AAEtE,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAC5B,KAAK;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC9B,MAAM,QAAQ,GAAG,MAAM,qBAAa,CAAC,aAAa,CAChD,IAAI,CAAC,WAAW,EAChB,UAAU,CAAC,cAAc,CAC1B,CAAC;YACF,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAChC,iBAAiB,EAAE,OAAO,CAAC,SAAS;oBAClC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;oBACvC,CAAC,CAAC,CAAC;gBACL,IAAI,EAAE,OAAO;aACd,CAAC,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,UAAU,GAAG,IAAA,gCAAa,EAAC;IACtC,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,uEAAuE;IACpF,UAAU,EAAE;QACV,WAAW,EACT,+KAA+K;KAClL;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,KAAK,EAAE;QACL,cAAc,EAAE,mBAAW,CAAC,cAAc,EAAE;KAC7C;IACD,UAAU,EAAE;QACV,EAAE,EAAE,oBAAoB;QACxB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,UAAU;QACnB,cAAc,EAAE,gBAAgB;QAChC,SAAS,EAAE,0BAA0B;KACpB;IACb,QAAQ,CAAC,OAAO;;YACpB,MAAM,6BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE;gBACpC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACrB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE;gBACrC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;IACK,IAAI,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newQueueItem: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
5
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
6
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
7
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
10
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
11
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
12
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
13
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-queue-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-queue-item.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-queue-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AAqCnC,eAAO,MAAM,YAAY;;;;;;;;;;;;EA+EvB,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newQueueItem = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/buffer/src/lib/triggers/new-queue-item.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 auth_1 = require("../common/auth");
|
|
10
|
+
const props_1 = require("../common/props");
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
+
items(_a) {
|
|
14
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
15
|
+
const posts = yield props_1.bufferQueries.fetchPosts({
|
|
16
|
+
accessToken: auth.secret_text,
|
|
17
|
+
organizationId: propsValue.organizationId,
|
|
18
|
+
channelIds: propsValue.channelIds,
|
|
19
|
+
statusFilter: (status) => {
|
|
20
|
+
const normalized = status === null || status === void 0 ? void 0 : status.toLowerCase();
|
|
21
|
+
return normalized !== 'sent' && normalized !== 'error';
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return posts.map((post) => ({
|
|
25
|
+
epochMilliSeconds: post.createdAt
|
|
26
|
+
? new Date(post.createdAt).getTime()
|
|
27
|
+
: 0,
|
|
28
|
+
data: post,
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
exports.newQueueItem = (0, pieces_framework_1.createTrigger)({
|
|
34
|
+
auth: auth_1.bufferAuth,
|
|
35
|
+
name: 'new_queue_item',
|
|
36
|
+
displayName: 'New Queue Item',
|
|
37
|
+
description: 'Triggers when a new post is queued in Buffer.',
|
|
38
|
+
aiMetadata: {
|
|
39
|
+
description: 'Fires when a new not-yet-published post (any status except sent or error, e.g. pending, scheduled, or draft) appears in the selected Buffer organization, optionally limited to specific channels. Represents the queued post.',
|
|
40
|
+
},
|
|
41
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
42
|
+
props: {
|
|
43
|
+
organizationId: props_1.bufferProps.organizationId(),
|
|
44
|
+
channelIds: pieces_framework_1.Property.MultiSelectDropdown({
|
|
45
|
+
auth: auth_1.bufferAuth,
|
|
46
|
+
displayName: 'Channels',
|
|
47
|
+
description: 'Limit results to specific channels (optional).',
|
|
48
|
+
required: false,
|
|
49
|
+
refreshers: ['organizationId'],
|
|
50
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, organizationId }) {
|
|
51
|
+
if (!auth || !organizationId) {
|
|
52
|
+
return {
|
|
53
|
+
disabled: true,
|
|
54
|
+
placeholder: 'Select an organization first.',
|
|
55
|
+
options: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const channels = yield props_1.bufferQueries.fetchChannels(auth.secret_text, organizationId);
|
|
60
|
+
return {
|
|
61
|
+
disabled: false,
|
|
62
|
+
options: channels.map((channel) => ({
|
|
63
|
+
label: `${channel.name} (${channel.service})`,
|
|
64
|
+
value: channel.id,
|
|
65
|
+
})),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (_b) {
|
|
69
|
+
return {
|
|
70
|
+
disabled: true,
|
|
71
|
+
placeholder: 'Failed to load channels.',
|
|
72
|
+
options: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
sampleData: {
|
|
79
|
+
id: 'post_id_example',
|
|
80
|
+
text: 'Hello from Buffer!',
|
|
81
|
+
status: 'pending',
|
|
82
|
+
createdAt: '2026-05-25T10:00:00.000Z',
|
|
83
|
+
dueAt: '2026-05-25T18:00:00.000Z',
|
|
84
|
+
channelId: 'channel_id',
|
|
85
|
+
channelService: 'facebook',
|
|
86
|
+
channel: { id: 'channel_id', name: 'My Page', service: 'facebook' },
|
|
87
|
+
tags: [],
|
|
88
|
+
},
|
|
89
|
+
onEnable(context) {
|
|
90
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
92
|
+
auth: context.auth,
|
|
93
|
+
store: context.store,
|
|
94
|
+
propsValue: context.propsValue,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
onDisable(context) {
|
|
99
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
101
|
+
auth: context.auth,
|
|
102
|
+
store: context.store,
|
|
103
|
+
propsValue: context.propsValue,
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
test(context) {
|
|
108
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
run(context) {
|
|
113
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=new-queue-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-queue-item.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-queue-item.ts"],"names":[],"mappings":";;;;AAAA,wGAAwG;AACxG,qEAAqE;AACrE,gEAKmC;AACnC,0DAIgC;AAChC,yCAA4C;AAC5C,2CAIyB;AAEzB,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAC5B,KAAK;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,qBAAa,CAAC,UAAU,CAA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,SAAS,CAAC,OAAO;;YACrB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE;gBACrC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;IACK,IAAI,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newSentItem: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
5
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
6
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
7
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
10
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
11
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
12
|
+
organizationId: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
13
|
+
channelIds: import("@agnocon/pieces-framework").MultiSelectDropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-sent-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-sent-item.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-sent-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AAoCnC,eAAO,MAAM,WAAW;;;;;;;;;;;;EA+EtB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newSentItem = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/buffer/src/lib/triggers/new-sent-item.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 auth_1 = require("../common/auth");
|
|
10
|
+
const props_1 = require("../common/props");
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
+
items(_a) {
|
|
14
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
15
|
+
const posts = yield props_1.bufferQueries.fetchPosts({
|
|
16
|
+
accessToken: auth.secret_text,
|
|
17
|
+
organizationId: propsValue.organizationId,
|
|
18
|
+
channelIds: propsValue.channelIds,
|
|
19
|
+
statusFilter: (status) => (status === null || status === void 0 ? void 0 : status.toLowerCase()) === 'sent',
|
|
20
|
+
});
|
|
21
|
+
return posts.map((post) => ({
|
|
22
|
+
epochMilliSeconds: post.sentAt
|
|
23
|
+
? new Date(post.sentAt).getTime()
|
|
24
|
+
: post.createdAt
|
|
25
|
+
? new Date(post.createdAt).getTime()
|
|
26
|
+
: 0,
|
|
27
|
+
data: post,
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.newSentItem = (0, pieces_framework_1.createTrigger)({
|
|
33
|
+
auth: auth_1.bufferAuth,
|
|
34
|
+
name: 'new_sent_item',
|
|
35
|
+
displayName: 'New Sent Post',
|
|
36
|
+
description: 'Triggers when a Buffer post is successfully published.',
|
|
37
|
+
aiMetadata: {
|
|
38
|
+
description: 'Fires when a Buffer post is successfully published (status sent) to a connected channel in the selected organization, optionally limited to specific channels. Represents the sent post.',
|
|
39
|
+
},
|
|
40
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
41
|
+
props: {
|
|
42
|
+
organizationId: props_1.bufferProps.organizationId(),
|
|
43
|
+
channelIds: pieces_framework_1.Property.MultiSelectDropdown({
|
|
44
|
+
auth: auth_1.bufferAuth,
|
|
45
|
+
displayName: 'Channels',
|
|
46
|
+
description: 'Limit results to specific channels (optional).',
|
|
47
|
+
required: false,
|
|
48
|
+
refreshers: ['organizationId'],
|
|
49
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, organizationId }) {
|
|
50
|
+
if (!auth || !organizationId) {
|
|
51
|
+
return {
|
|
52
|
+
disabled: true,
|
|
53
|
+
placeholder: 'Select an organization first.',
|
|
54
|
+
options: [],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const channels = yield props_1.bufferQueries.fetchChannels(auth.secret_text, organizationId);
|
|
59
|
+
return {
|
|
60
|
+
disabled: false,
|
|
61
|
+
options: channels.map((channel) => ({
|
|
62
|
+
label: `${channel.name} (${channel.service})`,
|
|
63
|
+
value: channel.id,
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (_b) {
|
|
68
|
+
return {
|
|
69
|
+
disabled: true,
|
|
70
|
+
placeholder: 'Failed to load channels.',
|
|
71
|
+
options: [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
sampleData: {
|
|
78
|
+
id: 'post_id_example',
|
|
79
|
+
text: 'Hello from Buffer!',
|
|
80
|
+
status: 'sent',
|
|
81
|
+
createdAt: '2026-05-25T10:00:00.000Z',
|
|
82
|
+
sentAt: '2026-05-25T18:00:00.000Z',
|
|
83
|
+
channelId: 'channel_id',
|
|
84
|
+
channelService: 'facebook',
|
|
85
|
+
channel: { id: 'channel_id', name: 'My Page', service: 'facebook' },
|
|
86
|
+
tags: [],
|
|
87
|
+
},
|
|
88
|
+
onEnable(context) {
|
|
89
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
91
|
+
auth: context.auth,
|
|
92
|
+
store: context.store,
|
|
93
|
+
propsValue: context.propsValue,
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
onDisable(context) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
100
|
+
auth: context.auth,
|
|
101
|
+
store: context.store,
|
|
102
|
+
propsValue: context.propsValue,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
test(context) {
|
|
107
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
run(context) {
|
|
112
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=new-sent-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-sent-item.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-sent-item.ts"],"names":[],"mappings":";;;;AAAA,uGAAuG;AACvG,qEAAqE;AACrE,gEAKmC;AACnC,0DAIgC;AAChC,yCAA4C;AAC5C,2CAIyB;AAEzB,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAC5B,KAAK;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,qBAAa,CAAC,UAAU,CAAC;gBAC3C,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,cAAc,EAAE,UAAU,CAAC,cAAc;gBACzC,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,EAAE,MAAK,MAAM;aAC3D,CAAC,CAAC;YACH,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC1B,iBAAiB,EAAE,IAAI,CAAC,MAAM;oBAC5B,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;oBACjC,CAAC,CAAC,IAAI,CAAC,SAAS;wBACd,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,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|
|
1
|
+
{
|
|
2
|
+
"name": "@agnocon/piece-buffer",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "AgnoCon buffer 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-buffer"
|
|
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.0.5"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "restricted",
|
|
40
|
+
"tag": "latest"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"agnocon",
|
|
44
|
+
"connector"
|
|
45
|
+
]
|
|
46
|
+
}
|