@activepieces/piece-mastodon 0.3.0 → 0.4.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
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-mastodon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@sinclair/typebox": "
|
|
6
|
-
"axios": "1.
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
5
|
+
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"axios": "^1.6.3",
|
|
7
|
+
"dayjs": "1.11.9",
|
|
8
|
+
"form-data": "4.0.0",
|
|
9
|
+
"is-base64": "1.1.0",
|
|
10
|
+
"lodash": "4.17.21",
|
|
11
|
+
"nanoid": "3.3.6",
|
|
12
|
+
"semver": "7.5.4",
|
|
13
|
+
"@activepieces/pieces-common": "0.2.8",
|
|
14
|
+
"@activepieces/pieces-framework": "0.7.14",
|
|
15
|
+
"@activepieces/shared": "0.10.66",
|
|
16
|
+
"tslib": "2.6.2"
|
|
12
17
|
},
|
|
13
18
|
"main": "./src/index.js",
|
|
14
|
-
"
|
|
19
|
+
"type": "commonjs"
|
|
15
20
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const mastodonAuth: import("@activepieces/pieces-framework").CustomAuthProperty<
|
|
1
|
+
export declare const mastodonAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
2
|
base_url: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
access_token: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
4
|
}>;
|
|
5
|
-
export declare const mastodon: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<
|
|
5
|
+
export declare const mastodon: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
6
|
base_url: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
7
|
access_token: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
8
|
}>>;
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mastodon = exports.mastodonAuth = void 0;
|
|
4
4
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
5
|
const post_status_1 = require("./lib/actions/post-status");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
7
|
const markdownDescription = `
|
|
7
8
|
**Base Url**: The base url of your Mastodon instance (e.g \`https://mastodon.social\`)
|
|
8
9
|
|
|
@@ -14,33 +15,37 @@ const markdownDescription = `
|
|
|
14
15
|
4. Copy access token from **Your access token**
|
|
15
16
|
`;
|
|
16
17
|
exports.mastodonAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
17
|
-
displayName: "Authentication",
|
|
18
18
|
description: markdownDescription,
|
|
19
19
|
props: {
|
|
20
20
|
base_url: pieces_framework_1.Property.ShortText({
|
|
21
21
|
displayName: 'Base URL',
|
|
22
22
|
description: 'The base URL of your Mastodon instance',
|
|
23
|
-
defaultValue:
|
|
23
|
+
defaultValue: 'https://mastodon.social/',
|
|
24
24
|
required: true,
|
|
25
25
|
}),
|
|
26
26
|
access_token: pieces_framework_1.Property.ShortText({
|
|
27
27
|
displayName: 'Access Token',
|
|
28
28
|
description: 'The access token for your Mastodon account, check the documentation for how to get this',
|
|
29
|
-
required: true
|
|
30
|
-
})
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
31
|
},
|
|
32
|
-
required: true
|
|
32
|
+
required: true,
|
|
33
33
|
});
|
|
34
34
|
exports.mastodon = (0, pieces_framework_1.createPiece)({
|
|
35
35
|
displayName: 'Mastodon',
|
|
36
36
|
logoUrl: 'https://cdn.activepieces.com/pieces/mastodon.png',
|
|
37
37
|
minimumSupportedRelease: '0.5.0',
|
|
38
|
-
authors: [
|
|
39
|
-
"abuaboud"
|
|
40
|
-
],
|
|
38
|
+
authors: ['abuaboud'],
|
|
41
39
|
auth: exports.mastodonAuth,
|
|
42
40
|
actions: [
|
|
43
|
-
post_status_1.postStatus
|
|
41
|
+
post_status_1.postStatus,
|
|
42
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
43
|
+
baseUrl: (auth) => auth.base_url.replace(/\/$/, '') + '/api/v1',
|
|
44
|
+
auth: exports.mastodonAuth,
|
|
45
|
+
authMapping: (auth) => ({
|
|
46
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
44
49
|
],
|
|
45
50
|
triggers: [],
|
|
46
51
|
});
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/mastodon/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAIwC;AACxC,2DAAuD;AACvD,+DAAwE;AAExE,MAAM,mBAAmB,GAAG;;;;;;;;;CAS3B,CAAC;AAEW,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,mBAAmB;IAChC,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,wCAAwC;YACrD,YAAY,EAAE,0BAA0B;YACxC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,yFAAyF;YAC3F,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEU,QAAA,QAAQ,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,UAAU;IAEvB,OAAO,EAAE,kDAAkD;IAC3D,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,IAAI,EAAE,oBAAY;IAClB,OAAO,EAAE;QACP,wBAAU;QACV,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,IAA6B,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS;YACxE,IAAI,EAAE,oBAAY;YAClB,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtB,aAAa,EAAE,UACZ,IAAiC,CAAC,YACrC,EAAE;aACH,CAAC;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare const postStatus: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<
|
|
1
|
+
export declare const postStatus: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
2
|
base_url: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
access_token: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
4
|
}>, {
|
|
5
5
|
status: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
6
|
+
media: import("@activepieces/pieces-framework").FileProperty<false>;
|
|
6
7
|
}>;
|
|
@@ -2,28 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.postStatus = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
5
6
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
7
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
8
|
const __1 = require("../..");
|
|
9
|
+
const uploadMedia = (media, baseUrl, token) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
const formData = new form_data_1.default();
|
|
11
|
+
formData.append('file', Buffer.from(media.base64, 'base64'), media.filename);
|
|
12
|
+
const postMediaResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
13
|
+
url: `${baseUrl}/api/v2/media`,
|
|
14
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
15
|
+
authentication: {
|
|
16
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
17
|
+
token,
|
|
18
|
+
},
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-type': 'multipart/form-data',
|
|
21
|
+
},
|
|
22
|
+
body: formData,
|
|
23
|
+
});
|
|
24
|
+
return postMediaResponse.body.id;
|
|
25
|
+
});
|
|
8
26
|
exports.postStatus = (0, pieces_framework_1.createAction)({
|
|
9
27
|
auth: __1.mastodonAuth,
|
|
10
28
|
name: 'post_status',
|
|
11
29
|
displayName: 'Post Status',
|
|
12
30
|
description: 'Post a status to Mastodon',
|
|
13
|
-
sampleData: {},
|
|
14
31
|
props: {
|
|
15
32
|
status: pieces_framework_1.Property.LongText({
|
|
16
33
|
displayName: 'Status',
|
|
17
34
|
description: 'The text of your status',
|
|
18
35
|
required: true,
|
|
19
|
-
})
|
|
36
|
+
}),
|
|
37
|
+
media: pieces_framework_1.Property.File({
|
|
38
|
+
displayName: 'Media URL or File',
|
|
39
|
+
description: 'The media attachement for your status',
|
|
40
|
+
required: false,
|
|
41
|
+
}),
|
|
20
42
|
},
|
|
21
43
|
run(context) {
|
|
22
44
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
45
|
const token = context.auth.access_token;
|
|
24
46
|
const status = context.propsValue.status;
|
|
47
|
+
const media = context.propsValue.media;
|
|
25
48
|
// Remove trailing slash from base_url
|
|
26
|
-
const baseUrl = context.auth.base_url.replace(/\/$/,
|
|
49
|
+
const baseUrl = context.auth.base_url.replace(/\/$/, '');
|
|
50
|
+
let mediaId = undefined;
|
|
51
|
+
if (media) {
|
|
52
|
+
mediaId = yield uploadMedia(media, baseUrl, token);
|
|
53
|
+
}
|
|
27
54
|
return yield pieces_common_1.httpClient.sendRequest({
|
|
28
55
|
url: `${baseUrl}/api/v1/statuses`,
|
|
29
56
|
method: pieces_common_1.HttpMethod.POST,
|
|
@@ -31,9 +58,7 @@ exports.postStatus = (0, pieces_framework_1.createAction)({
|
|
|
31
58
|
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
32
59
|
token,
|
|
33
60
|
},
|
|
34
|
-
body: {
|
|
35
|
-
status,
|
|
36
|
-
}
|
|
61
|
+
body: Object.assign({ status }, (mediaId ? { media_ids: [mediaId] } : {})),
|
|
37
62
|
});
|
|
38
63
|
});
|
|
39
64
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-status.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"post-status.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/mastodon/src/lib/actions/post-status.ts"],"names":[],"mappings":";;;;AAAA,kEAAiC;AACjC,qEAAgF;AAChF,+DAIqC;AACrC,6BAAqC;AAErC,MAAM,WAAW,GAAG,CAAO,KAAa,EAAE,OAAe,EAAE,KAAa,EAAE,EAAE;IAC1E,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE7E,MAAM,iBAAiB,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;QACrD,GAAG,EAAE,GAAG,OAAO,eAAe;QAC9B,MAAM,EAAE,0BAAU,CAAC,IAAI;QACvB,cAAc,EAAE;YACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;YACrC,KAA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