@xnkee/n8n-nodes-instagram 1.7.0 → 2.1.0
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.md → LICENSE} +21 -21
- package/README.md +132 -437
- package/dist/credentials/InstagramApi.credentials.d.ts +10 -0
- package/dist/credentials/InstagramApi.credentials.js +55 -0
- package/dist/credentials/InstagramApi.credentials.js.map +1 -0
- package/dist/credentials/InstagramOAuth2Api.credentials.d.ts +2 -2
- package/dist/credentials/InstagramOAuth2Api.credentials.js +33 -113
- package/dist/credentials/InstagramOAuth2Api.credentials.js.map +1 -1
- package/dist/credentials/InstagramUnifiedLoginOAuth2Api.credentials.d.ts +17 -0
- package/dist/credentials/InstagramUnifiedLoginOAuth2Api.credentials.js +116 -0
- package/dist/credentials/InstagramUnifiedLoginOAuth2Api.credentials.js.map +1 -0
- package/dist/credentials/instagram.svg +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/Instagram/GenericFunctions.d.ts +27 -23
- package/dist/nodes/Instagram/GenericFunctions.js +182 -223
- package/dist/nodes/Instagram/GenericFunctions.js.map +1 -1
- package/dist/nodes/Instagram/Instagram.node.d.ts +1 -1
- package/dist/nodes/Instagram/Instagram.node.js +109 -2353
- package/dist/nodes/Instagram/Instagram.node.js.map +1 -1
- package/dist/nodes/Instagram/Instagram.node.json +17 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.d.ts +17 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.js +415 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.js.map +1 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.json +16 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.fields.js +161 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.operations.js +62 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/comment/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/comment/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/comment/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.fields.js +65 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.operations.js +26 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/custom/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/custom/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/custom/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/index.d.ts +7 -0
- package/dist/nodes/Instagram/descriptions/index.js +24 -0
- package/dist/nodes/Instagram/descriptions/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/AccountInsight.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/insight/AccountInsight.fields.js +164 -0
- package/dist/nodes/Instagram/descriptions/insight/AccountInsight.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/Insight.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/insight/Insight.operations.js +32 -0
- package/dist/nodes/Instagram/descriptions/insight/Insight.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/MediaInsight.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/insight/MediaInsight.fields.js +87 -0
- package/dist/nodes/Instagram/descriptions/insight/MediaInsight.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/index.d.ts +4 -0
- package/dist/nodes/Instagram/descriptions/insight/index.js +12 -0
- package/dist/nodes/Instagram/descriptions/insight/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/Media.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/media/Media.operations.js +62 -0
- package/dist/nodes/Instagram/descriptions/media/Media.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/MediaGet.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/media/MediaGet.fields.js +163 -0
- package/dist/nodes/Instagram/descriptions/media/MediaGet.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/MediaPublish.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/media/MediaPublish.fields.js +285 -0
- package/dist/nodes/Instagram/descriptions/media/MediaPublish.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/index.d.ts +4 -0
- package/dist/nodes/Instagram/descriptions/media/index.js +12 -0
- package/dist/nodes/Instagram/descriptions/media/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.fields.js +122 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.operations.js +38 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/mention/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/mention/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/mention/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/message/Message.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/message/Message.fields.js +123 -0
- package/dist/nodes/Instagram/descriptions/message/Message.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/message/Message.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/message/Message.operations.js +44 -0
- package/dist/nodes/Instagram/descriptions/message/Message.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/message/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/message/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/message/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/User.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/user/User.operations.js +38 -0
- package/dist/nodes/Instagram/descriptions/user/User.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/UserInsights.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/user/UserInsights.fields.js +164 -0
- package/dist/nodes/Instagram/descriptions/user/UserInsights.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/UserProfile.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/user/UserProfile.fields.js +83 -0
- package/dist/nodes/Instagram/descriptions/user/UserProfile.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/index.d.ts +4 -0
- package/dist/nodes/Instagram/descriptions/user/index.js +12 -0
- package/dist/nodes/Instagram/descriptions/user/index.js.map +1 -0
- package/dist/nodes/Instagram/handlers/CommentHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/CommentHandler.js +63 -0
- package/dist/nodes/Instagram/handlers/CommentHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/CustomHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/CustomHandler.js +28 -0
- package/dist/nodes/Instagram/handlers/CustomHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/InsightHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/InsightHandler.js +42 -0
- package/dist/nodes/Instagram/handlers/InsightHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/MediaHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/MediaHandler.js +172 -0
- package/dist/nodes/Instagram/handlers/MediaHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/MentionHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/MentionHandler.js +48 -0
- package/dist/nodes/Instagram/handlers/MentionHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/MessageHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/MessageHandler.js +57 -0
- package/dist/nodes/Instagram/handlers/MessageHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/UserHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/UserHandler.js +48 -0
- package/dist/nodes/Instagram/handlers/UserHandler.js.map +1 -0
- package/dist/nodes/Instagram/instagram.svg +1 -0
- package/package.json +34 -46
- package/API_REFERENCE.md +0 -907
- package/AUTHENTICATION_GUIDE.md +0 -718
- package/CHANGELOG.md +0 -391
- package/dist/credentials/InstagramUnifiedLoginApi.credentials.d.ts +0 -9
- package/dist/credentials/InstagramUnifiedLoginApi.credentials.js +0 -481
- package/dist/credentials/InstagramUnifiedLoginApi.credentials.js.map +0 -1
- package/dist/nodes/Instagram/InstagramTrigger.node.d.ts +0 -17
- package/dist/nodes/Instagram/InstagramTrigger.node.js +0 -398
- package/dist/nodes/Instagram/InstagramTrigger.node.js.map +0 -1
- package/dist/nodes/Instagram/instagram-large.svg +0 -27
- package/dist/nodes/Instagram/instagram-small.svg +0 -14
- package/dist/nodes/Instagram/types.d.ts +0 -171
- package/dist/nodes/Instagram/types.js +0 -3
- package/dist/nodes/Instagram/types.js.map +0 -1
- package/dist/package.json +0 -76
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/index.js +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userProfileFields = void 0;
|
|
4
|
+
exports.userProfileFields = [
|
|
5
|
+
{
|
|
6
|
+
displayName: 'User ID',
|
|
7
|
+
name: 'userId',
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
default: '',
|
|
11
|
+
displayOptions: {
|
|
12
|
+
show: {
|
|
13
|
+
resource: ['user'],
|
|
14
|
+
operation: ['get'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
description: 'The Instagram User ID to retrieve profile details for',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Fields to Retrieve',
|
|
21
|
+
name: 'fieldsMode',
|
|
22
|
+
type: 'options',
|
|
23
|
+
options: [
|
|
24
|
+
{
|
|
25
|
+
name: 'All Fields (Recommended)',
|
|
26
|
+
value: 'all',
|
|
27
|
+
description: 'Retrieve all available profile fields',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Selected Fields',
|
|
31
|
+
value: 'selected',
|
|
32
|
+
description: 'Choose specific fields to retrieve',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
default: 'all',
|
|
36
|
+
displayOptions: {
|
|
37
|
+
show: {
|
|
38
|
+
resource: ['user'],
|
|
39
|
+
operation: ['get', 'getMe'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
description: 'Whether to retrieve all available fields or pick specific fields',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
displayName: 'Fields',
|
|
46
|
+
name: 'fields',
|
|
47
|
+
type: 'multiOptions',
|
|
48
|
+
options: [
|
|
49
|
+
{ name: 'Account Type', value: 'account_type' },
|
|
50
|
+
{ name: 'Biography', value: 'biography' },
|
|
51
|
+
{ name: 'Followers Count', value: 'followers_count' },
|
|
52
|
+
{ name: 'Follows Count', value: 'follows_count' },
|
|
53
|
+
{ name: 'ID', value: 'id' },
|
|
54
|
+
{ name: 'Media Count', value: 'media_count' },
|
|
55
|
+
{ name: 'Name', value: 'name' },
|
|
56
|
+
{ name: 'Profile Picture URL', value: 'profile_picture_url' },
|
|
57
|
+
{ name: 'User ID', value: 'user_id' },
|
|
58
|
+
{ name: 'Username', value: 'username' },
|
|
59
|
+
{ name: 'Website', value: 'website' },
|
|
60
|
+
],
|
|
61
|
+
default: [
|
|
62
|
+
'id',
|
|
63
|
+
'user_id',
|
|
64
|
+
'username',
|
|
65
|
+
'name',
|
|
66
|
+
'account_type',
|
|
67
|
+
'profile_picture_url',
|
|
68
|
+
'followers_count',
|
|
69
|
+
'media_count',
|
|
70
|
+
'biography',
|
|
71
|
+
'website',
|
|
72
|
+
],
|
|
73
|
+
displayOptions: {
|
|
74
|
+
show: {
|
|
75
|
+
resource: ['user'],
|
|
76
|
+
operation: ['get', 'getMe'],
|
|
77
|
+
fieldsMode: ['selected'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
description: 'Specific fields to return in the response',
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
//# sourceMappingURL=UserProfile.fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserProfile.fields.js","sourceRoot":"","sources":["../../../../../nodes/Instagram/descriptions/user/UserProfile.fields.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAAsB;IAClD;QACE,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,cAAc,EAAE;YACd,IAAI,EAAE;gBACJ,QAAQ,EAAE,CAAC,MAAM,CAAC;gBAClB,SAAS,EAAE,CAAC,KAAK,CAAC;aACnB;SACF;QACD,WAAW,EAAE,uDAAuD;KACrE;IACD;QACE,WAAW,EAAE,oBAAoB;QACjC,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,0BAA0B;gBAChC,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,uCAAuC;aACrD;YACD;gBACE,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,oCAAoC;aAClD;SACF;QACD,OAAO,EAAE,KAAK;QACd,cAAc,EAAE;YACd,IAAI,EAAE;gB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2CAA2C;KACzD;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userOperations = exports.userFields = void 0;
|
|
4
|
+
const User_operations_1 = require("./User.operations");
|
|
5
|
+
Object.defineProperty(exports, "userOperations", { enumerable: true, get: function () { return User_operations_1.userOperations; } });
|
|
6
|
+
const UserProfile_fields_1 = require("./UserProfile.fields");
|
|
7
|
+
const UserInsights_fields_1 = require("./UserInsights.fields");
|
|
8
|
+
exports.userFields = [
|
|
9
|
+
...UserProfile_fields_1.userProfileFields,
|
|
10
|
+
...UserInsights_fields_1.userInsightsFields,
|
|
11
|
+
];
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/Instagram/descriptions/user/index.ts"],"names":[],"mappings":";;;AACA,uDAAmD;AAS1C,+FATA,gCAAc,OASA;AARvB,6DAAyD;AACzD,+DAA2D;AAE9C,QAAA,UAAU,GAAsB;IAC3C,GAAG,sCAAiB;IACpB,GAAG,wCAAkB;CACtB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleComment = handleComment;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("../GenericFunctions");
|
|
6
|
+
const ALL_COMMENT_FIELDS = 'id,text,timestamp,like_count,hidden,replies_count,username,from{id,username}';
|
|
7
|
+
async function handleGetComment(i) {
|
|
8
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
9
|
+
const fields = GenericFunctions_1.resolveParameterList.call(this, i, ALL_COMMENT_FIELDS);
|
|
10
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'GET', `/${commentId}`, {}, { fields });
|
|
11
|
+
}
|
|
12
|
+
async function handleGetAllComments(i) {
|
|
13
|
+
const mediaId = this.getNodeParameter('mediaId', i);
|
|
14
|
+
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
15
|
+
const limit = returnAll ? undefined : this.getNodeParameter('limit', i, 50);
|
|
16
|
+
const fields = GenericFunctions_1.resolveParameterList.call(this, i, ALL_COMMENT_FIELDS);
|
|
17
|
+
return await GenericFunctions_1.instagramApiRequestAllItems.call(this, 'data', 'GET', `/${mediaId}/comments`, {}, { fields }, limit);
|
|
18
|
+
}
|
|
19
|
+
async function handleGetCommentReplies(i) {
|
|
20
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
21
|
+
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
22
|
+
const limit = returnAll ? undefined : this.getNodeParameter('limit', i, 50);
|
|
23
|
+
const fields = GenericFunctions_1.resolveParameterList.call(this, i, ALL_COMMENT_FIELDS);
|
|
24
|
+
return await GenericFunctions_1.instagramApiRequestAllItems.call(this, 'data', 'GET', `/${commentId}/replies`, {}, { fields }, limit);
|
|
25
|
+
}
|
|
26
|
+
async function handleCreateComment(i) {
|
|
27
|
+
const mediaId = this.getNodeParameter('mediaId', i);
|
|
28
|
+
const message = this.getNodeParameter('message', i);
|
|
29
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${mediaId}/comments`, { message });
|
|
30
|
+
}
|
|
31
|
+
async function handleReplyComment(i) {
|
|
32
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
33
|
+
const message = this.getNodeParameter('message', i);
|
|
34
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${commentId}/replies`, { message });
|
|
35
|
+
}
|
|
36
|
+
async function handleDeleteComment(i) {
|
|
37
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
38
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'DELETE', `/${commentId}`);
|
|
39
|
+
}
|
|
40
|
+
async function handleHideComment(i) {
|
|
41
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
42
|
+
const hide = this.getNodeParameter('hide', i, true);
|
|
43
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${commentId}`, { hide });
|
|
44
|
+
}
|
|
45
|
+
const commentOperationHandlers = {
|
|
46
|
+
get: handleGetComment,
|
|
47
|
+
getAll: handleGetAllComments,
|
|
48
|
+
getReplies: handleGetCommentReplies,
|
|
49
|
+
create: handleCreateComment,
|
|
50
|
+
reply: handleReplyComment,
|
|
51
|
+
delete: handleDeleteComment,
|
|
52
|
+
hide: handleHideComment,
|
|
53
|
+
};
|
|
54
|
+
async function handleComment(operation, i) {
|
|
55
|
+
const handler = commentOperationHandlers[operation];
|
|
56
|
+
if (!handler) {
|
|
57
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported Comment operation: ${operation}`, {
|
|
58
|
+
itemIndex: i,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return await handler.call(this, i);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=CommentHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentHandler.js","sourceRoot":"","sources":["../../../../nodes/Instagram/handlers/CommentHandler.ts"],"names":[],"mappings":";;AAsFA,sCAYC;AAlGD,+CAAqE;AACrE,0DAI6B;AAE7B,MAAM,kBAAkB,GACtB,8EAA8E,CAAC;AAEjF,KAAK,UAAU,gBAAgB,CAA0B,CAAS;IAChE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAW,CAAC;IAClE,MAAM,MAAM,GAAG,uCAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACtE,OAAO,MAAM,sCAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AACtF,CAAC;AAED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,CAAC;AACjF,CAAC;AAED,MAAM,wBAAwB,GAG1B;IACF,GAAG,EAAE,gBAAgB;IACrB,MAAM,EAAE,oBAAoB;IAC5B,UAAU,EAAE,uBAAuB;IACnC,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,mBAAmB;IAC3B,IAAI,EAAE,iBAAiB;CACxB,CAAC;AAEK,KAAK,UAAU,aAAa,CAEjC,SAAiB,EACjB,CAAS;IAET,MAAM,OAAO,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,kCAAkC,SAAS,EAAE,EAAE;YAC1F,SAAS,EAAE,CAAC;SACb,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleCustom = handleCustom;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("../GenericFunctions");
|
|
6
|
+
function parseJsonParameter(input, errorMessage, nodeContext, itemIndex) {
|
|
7
|
+
if (typeof input === 'object' && input !== null) {
|
|
8
|
+
return input;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(input || '{}');
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
throw new n8n_workflow_1.NodeOperationError(nodeContext, errorMessage, { itemIndex });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function handleCustom(_operation, i) {
|
|
18
|
+
const httpMethod = this.getNodeParameter('httpMethod', i);
|
|
19
|
+
const endpointPath = this.getNodeParameter('endpointPath', i);
|
|
20
|
+
const queryParamsJson = this.getNodeParameter('queryParamsJson', i, '{}');
|
|
21
|
+
const bodyParamsJson = this.getNodeParameter('bodyParamsJson', i, '{}');
|
|
22
|
+
const qs = parseJsonParameter(queryParamsJson, 'Query Parameters must be a valid JSON object', this.getNode(), i);
|
|
23
|
+
const body = parseJsonParameter(bodyParamsJson, 'Body Parameters must be a valid JSON object', this.getNode(), i);
|
|
24
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, httpMethod, endpointPath, body, qs,
|
|
25
|
+
// Send the path exactly as typed (e.g. /me/assigned_instagram_accounts with Unified Login)
|
|
26
|
+
{ rawEndpoint: true });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=CustomHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomHandler.js","sourceRoot":"","sources":["../../../../nodes/Instagram/handlers/CustomHandler.ts"],"names":[],"mappings":";;AAwBA,oCAgCC;AAxDD,+CAKsB;AACtB,0DAA0D;AAE1D,SAAS,kBAAkB,CACzB,KAA2B,EAC3B,YAAoB,EACpB,WAAgB,EAChB,SAAiB;IAEjB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,iCAAkB,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,YAAY,CAEhC,UAAkB,EAClB,CAAS;IAET,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,CAAwB,CAAC;IACjF,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAW,CAAC;IACxE,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,CAAC,EAAE,IAAI,CAAyB,CAAC;IAClG,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,CAAyB,CAAC;IAEhG,MAAM,EAAE,GAAG,kBAAkB,CAC3B,eAAe,EACf,8CAA8C,EAC9C,IAAI,CAAC,OAAO,EAAE,EACd,CAAC,CACF,CAAC;IACF,MAAM,IAAI,GAAG,kBAAkB,CAC7B,cAAc,EACd,6CAA6C,EAC7C,IAAI,CAAC,OAAO,EAAE,EACd,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,sCAAmB,CAAC,IAAI,CACnC,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,EAAE;IACF,2FAA2F;IAC3F,EAAE,WAAW,EAAE,IAAI,EAAE,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleInsight = handleInsight;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("../GenericFunctions");
|
|
6
|
+
const ALL_ACCOUNT_METRICS = 'reach,views,accounts_engaged,total_interactions,likes,comments,shares,saves,replies,profile_views,website_clicks,content_views';
|
|
7
|
+
const ALL_MEDIA_METRICS = 'reach,views,saved,shares,likes,comments,total_interactions,plays,profile_visits,profile_activity,follows';
|
|
8
|
+
async function handleGetAccountInsights(i) {
|
|
9
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
10
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
11
|
+
const metric = GenericFunctions_1.resolveParameterList.call(this, i, ALL_ACCOUNT_METRICS, 'metrics', 'metricsMode');
|
|
12
|
+
const period = this.getNodeParameter('period', i, 'day');
|
|
13
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
14
|
+
const qs = { metric, period };
|
|
15
|
+
if (additionalFields.since)
|
|
16
|
+
qs.since = additionalFields.since;
|
|
17
|
+
if (additionalFields.until)
|
|
18
|
+
qs.until = additionalFields.until;
|
|
19
|
+
if (additionalFields.metric_type && additionalFields.metric_type !== 'default') {
|
|
20
|
+
qs.metric_type = additionalFields.metric_type;
|
|
21
|
+
}
|
|
22
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'GET', `/${resolvedUserId}/insights`, {}, qs);
|
|
23
|
+
}
|
|
24
|
+
async function handleGetMediaInsights(i) {
|
|
25
|
+
const mediaId = this.getNodeParameter('mediaId', i);
|
|
26
|
+
const metric = GenericFunctions_1.resolveParameterList.call(this, i, ALL_MEDIA_METRICS, 'mediaMetrics', 'mediaMetricsMode');
|
|
27
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'GET', `/${mediaId}/insights`, {}, { metric });
|
|
28
|
+
}
|
|
29
|
+
const insightOperationHandlers = {
|
|
30
|
+
getAccountInsights: handleGetAccountInsights,
|
|
31
|
+
getMediaInsights: handleGetMediaInsights,
|
|
32
|
+
};
|
|
33
|
+
async function handleInsight(operation, i) {
|
|
34
|
+
const handler = insightOperationHandlers[operation];
|
|
35
|
+
if (!handler) {
|
|
36
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported Insight operation: ${operation}`, {
|
|
37
|
+
itemIndex: i,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return await handler.call(this, i);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=InsightHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InsightHandler.js","sourceRoot":"","sources":["../../../../nodes/Instagram/handlers/InsightHandler.ts"],"names":[],"mappings":";;AAyDA,sCAYC;AArED,+CAAkF;AAClF,0DAI6B;AAE7B,MAAM,mBAAmB,GACvB,gIAAgI,CAAC;AAEnI,MAAM,iB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uCAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAEzG,OAAO,MAAM,sCAAmB,CAAC,IAAI,CACnC,IAAI,EACJ,KAAK,EACL,IAAI,OAAO,WAAW,EACtB,EAAE,EACF,EAAE,MAAM,EAAE,CACX,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAG1B;IACF,kBAAkB,EAAE,wBAAwB;IAC5C,gBAAgB,EAAE,sBAAsB;CACzC,CAAC;AAEK,KAAK,UAAU,aAAa,CAEjC,SAAiB,EACjB,CAAS;IAET,MAAM,OAAO,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,kCAAkC,SAAS,EAAE,EAAE;YAC1F,SAAS,EAAE,CAAC;SACb,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleMedia = handleMedia;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("../GenericFunctions");
|
|
6
|
+
const ALL_SINGLE_MEDIA_FIELDS = 'id,caption,media_type,media_url,permalink,shortcode,thumbnail_url,timestamp,username,like_count,comments_count,is_comment_enabled,children{id,media_type,media_url,thumbnail_url},alt_text';
|
|
7
|
+
const ALL_GET_ALL_MEDIA_FIELDS = 'id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,like_count,comments_count,is_comment_enabled';
|
|
8
|
+
async function handleGetMedia(i) {
|
|
9
|
+
const mediaId = this.getNodeParameter('mediaId', i);
|
|
10
|
+
const fields = GenericFunctions_1.resolveParameterList.call(this, i, ALL_SINGLE_MEDIA_FIELDS);
|
|
11
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'GET', `/${mediaId}`, {}, { fields });
|
|
12
|
+
}
|
|
13
|
+
async function handleGetAllMedia(i) {
|
|
14
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
15
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
16
|
+
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
17
|
+
const limit = returnAll ? undefined : this.getNodeParameter('limit', i, 50);
|
|
18
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
19
|
+
const fields = GenericFunctions_1.resolveParameterList.call(this, i, ALL_GET_ALL_MEDIA_FIELDS);
|
|
20
|
+
const qs = { fields };
|
|
21
|
+
if (additionalFields.since)
|
|
22
|
+
qs.since = additionalFields.since;
|
|
23
|
+
if (additionalFields.until)
|
|
24
|
+
qs.until = additionalFields.until;
|
|
25
|
+
return await GenericFunctions_1.instagramApiRequestAllItems.call(this, 'data', 'GET', `/${resolvedUserId}/media`, {}, qs, limit);
|
|
26
|
+
}
|
|
27
|
+
function parseUserTags(rawTags, nodeContext) {
|
|
28
|
+
if (!rawTags)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (typeof rawTags === 'object')
|
|
31
|
+
return rawTags;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(rawTags);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new n8n_workflow_1.NodeOperationError(nodeContext, 'User Tags must be a valid JSON array string');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function handlePublishPhoto(i) {
|
|
40
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
41
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
42
|
+
const imageUrl = this.getNodeParameter('imageUrl', i);
|
|
43
|
+
const caption = this.getNodeParameter('caption', i, '');
|
|
44
|
+
const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
|
|
45
|
+
const containerBody = { image_url: imageUrl };
|
|
46
|
+
if (caption)
|
|
47
|
+
containerBody.caption = caption;
|
|
48
|
+
if (additionalOptions.alt_text_wrap)
|
|
49
|
+
containerBody.alt_text_wrap = additionalOptions.alt_text_wrap;
|
|
50
|
+
if (additionalOptions.location_id)
|
|
51
|
+
containerBody.location_id = additionalOptions.location_id;
|
|
52
|
+
const parsedTags = parseUserTags(additionalOptions.user_tags, this.getNode());
|
|
53
|
+
if (parsedTags)
|
|
54
|
+
containerBody.user_tags = parsedTags;
|
|
55
|
+
const container = await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media`, containerBody);
|
|
56
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media_publish`, {
|
|
57
|
+
creation_id: container.id,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async function handlePublishVideo(i) {
|
|
61
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
62
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
63
|
+
const videoUrl = this.getNodeParameter('videoUrl', i);
|
|
64
|
+
const mediaType = this.getNodeParameter('mediaType', i, 'REELS');
|
|
65
|
+
const caption = this.getNodeParameter('caption', i, '');
|
|
66
|
+
const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
|
|
67
|
+
const containerBody = {
|
|
68
|
+
media_type: mediaType,
|
|
69
|
+
video_url: videoUrl,
|
|
70
|
+
};
|
|
71
|
+
if (caption)
|
|
72
|
+
containerBody.caption = caption;
|
|
73
|
+
if (additionalOptions.cover_url)
|
|
74
|
+
containerBody.cover_url = additionalOptions.cover_url;
|
|
75
|
+
if (additionalOptions.thumb_offset)
|
|
76
|
+
containerBody.thumb_offset = additionalOptions.thumb_offset;
|
|
77
|
+
if (additionalOptions.location_id)
|
|
78
|
+
containerBody.location_id = additionalOptions.location_id;
|
|
79
|
+
if (additionalOptions.share_to_feed !== undefined) {
|
|
80
|
+
containerBody.share_to_feed = additionalOptions.share_to_feed;
|
|
81
|
+
}
|
|
82
|
+
if (additionalOptions.audio_name)
|
|
83
|
+
containerBody.audio_name = additionalOptions.audio_name;
|
|
84
|
+
const container = await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media`, containerBody);
|
|
85
|
+
await GenericFunctions_1.pollMediaContainerStatus.call(this, container.id);
|
|
86
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media_publish`, {
|
|
87
|
+
creation_id: container.id,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async function createSingleCarouselItem(resolvedUserId, item) {
|
|
91
|
+
const isImage = item.mediaType === 'IMAGE';
|
|
92
|
+
const itemBody = {
|
|
93
|
+
is_carousel_item: true,
|
|
94
|
+
...(isImage
|
|
95
|
+
? { image_url: item.url, ...(item.altText ? { alt_text_wrap: item.altText } : {}) }
|
|
96
|
+
: { media_type: 'VIDEO', video_url: item.url }),
|
|
97
|
+
};
|
|
98
|
+
const itemContainer = await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media`, itemBody);
|
|
99
|
+
if (!isImage) {
|
|
100
|
+
await GenericFunctions_1.pollMediaContainerStatus.call(this, itemContainer.id);
|
|
101
|
+
}
|
|
102
|
+
return itemContainer.id;
|
|
103
|
+
}
|
|
104
|
+
async function handlePublishCarousel(i) {
|
|
105
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
106
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
107
|
+
const caption = this.getNodeParameter('caption', i, '');
|
|
108
|
+
const carouselItems = this.getNodeParameter('carouselItems', i, {});
|
|
109
|
+
const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
|
|
110
|
+
const itemsList = carouselItems.item || [];
|
|
111
|
+
if (itemsList.length < 2 || itemsList.length > 10) {
|
|
112
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Instagram Carousel requires between 2 and 10 media items.', { itemIndex: i });
|
|
113
|
+
}
|
|
114
|
+
const childrenIds = [];
|
|
115
|
+
for (const item of itemsList) {
|
|
116
|
+
const containerId = await createSingleCarouselItem.call(this, resolvedUserId, item);
|
|
117
|
+
childrenIds.push(containerId);
|
|
118
|
+
}
|
|
119
|
+
const carouselBody = {
|
|
120
|
+
media_type: 'CAROUSEL',
|
|
121
|
+
children: childrenIds.join(','),
|
|
122
|
+
};
|
|
123
|
+
if (caption)
|
|
124
|
+
carouselBody.caption = caption;
|
|
125
|
+
if (additionalOptions.location_id)
|
|
126
|
+
carouselBody.location_id = additionalOptions.location_id;
|
|
127
|
+
const carouselContainer = await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media`, carouselBody);
|
|
128
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media_publish`, {
|
|
129
|
+
creation_id: carouselContainer.id,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async function handlePublishStory(i) {
|
|
133
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
134
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
135
|
+
const storyMediaType = this.getNodeParameter('storyMediaType', i, 'IMAGE');
|
|
136
|
+
const mediaUrl = this.getNodeParameter('mediaUrl', i);
|
|
137
|
+
const isImage = storyMediaType === 'IMAGE';
|
|
138
|
+
const storyBody = {
|
|
139
|
+
media_type: 'STORIES',
|
|
140
|
+
...(isImage ? { image_url: mediaUrl } : { video_url: mediaUrl }),
|
|
141
|
+
};
|
|
142
|
+
const container = await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media`, storyBody);
|
|
143
|
+
if (!isImage) {
|
|
144
|
+
await GenericFunctions_1.pollMediaContainerStatus.call(this, container.id);
|
|
145
|
+
}
|
|
146
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/media_publish`, {
|
|
147
|
+
creation_id: container.id,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async function handleDeleteMedia(i) {
|
|
151
|
+
const mediaId = this.getNodeParameter('mediaId', i);
|
|
152
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'DELETE', `/${mediaId}`);
|
|
153
|
+
}
|
|
154
|
+
const mediaOperationHandlers = {
|
|
155
|
+
get: handleGetMedia,
|
|
156
|
+
getAll: handleGetAllMedia,
|
|
157
|
+
publishPhoto: handlePublishPhoto,
|
|
158
|
+
publishVideo: handlePublishVideo,
|
|
159
|
+
publishCarousel: handlePublishCarousel,
|
|
160
|
+
publishStory: handlePublishStory,
|
|
161
|
+
delete: handleDeleteMedia,
|
|
162
|
+
};
|
|
163
|
+
async function handleMedia(operation, i) {
|
|
164
|
+
const handler = mediaOperationHandlers[operation];
|
|
165
|
+
if (!handler) {
|
|
166
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported Media operation: ${operation}`, {
|
|
167
|
+
itemIndex: i,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return await handler.call(this, i);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=MediaHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaHandler.js","sourceRoot":"","sources":["../../../../nodes/Instagram/handlers/MediaHandler.ts"],"names":[],"mappings":";;AAoPA,kCAYC;AAhQD,+CAIsB;AACtB,0DAM6B;AAE7B,MAAM,uBAAuB,GAC3B,4LAA4L,CAAC;AAE/L,MAAM,wBAAwB,GAC5B,gHAAgH,CAAC;AAQnH,KAAK,UAAU,cAAc,CAA0B,CAAS;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAW,CAAC;IAC9D,MAAM,MAAM,GAAG,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E,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleMention = handleMention;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("../GenericFunctions");
|
|
6
|
+
async function handleGetMentionedMedia(i) {
|
|
7
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
8
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
9
|
+
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
10
|
+
const limit = returnAll ? undefined : this.getNodeParameter('limit', i, 50);
|
|
11
|
+
return await GenericFunctions_1.instagramApiRequestAllItems.call(this, 'data', 'GET', `/${resolvedUserId}/tags`, {}, { fields: 'id,caption,media_type,media_url,permalink,timestamp,username' }, limit);
|
|
12
|
+
}
|
|
13
|
+
async function handleGetMentionedComment(i) {
|
|
14
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
15
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
16
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
17
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'GET', `/${resolvedUserId}/mentioned_comment`, {}, {
|
|
18
|
+
comment_id: commentId,
|
|
19
|
+
fields: 'id,text,timestamp,media{id,permalink}',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function handleReplyToMention(i) {
|
|
23
|
+
const rawUserId = this.getNodeParameter('userId', i, 'me');
|
|
24
|
+
const resolvedUserId = await GenericFunctions_1.getResolvedUserId.call(this, rawUserId);
|
|
25
|
+
const mentionTargetType = this.getNodeParameter('mentionTargetType', i);
|
|
26
|
+
const targetId = this.getNodeParameter('targetId', i);
|
|
27
|
+
const message = this.getNodeParameter('message', i);
|
|
28
|
+
const body = {
|
|
29
|
+
message,
|
|
30
|
+
...(mentionTargetType === 'media' ? { media_id: targetId } : { comment_id: targetId }),
|
|
31
|
+
};
|
|
32
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', `/${resolvedUserId}/mentions`, body);
|
|
33
|
+
}
|
|
34
|
+
const mentionOperationHandlers = {
|
|
35
|
+
getMentionedMedia: handleGetMentionedMedia,
|
|
36
|
+
getMentionedComment: handleGetMentionedComment,
|
|
37
|
+
replyToMention: handleReplyToMention,
|
|
38
|
+
};
|
|
39
|
+
async function handleMention(operation, i) {
|
|
40
|
+
const handler = mentionOperationHandlers[operation];
|
|
41
|
+
if (!handler) {
|
|
42
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported Mention operation: ${operation}`, {
|
|
43
|
+
itemIndex: i,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return await handler.call(this, i);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=MentionHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MentionHandler.js","sourceRoot":"","sources":["../../../../nodes/Instagram/handlers/MentionHandler.ts"],"names":[],"mappings":";;AAsEA,sCAYC;AAlFD,+CAAkF;AAClF,0DAI6B;AAE7B,KAAK,UAAU,uBAAuB,CAA0B,CAAS;IACvE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAW,CAAC;IACrE,MAAM,cAAc,GAAG,MAAM,oCAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACrE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,EAAE,KAAK,CAAY,CAAC;IAC1E,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAY,CAAC;IAExF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,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;KACvF,CAAC;IAEF,OAAO,MAAM,sCAAmB,CAAC,IAAI,CACnC,IAAI,EACJ,MAAM,EACN,IAAI,cAAc,WAAW,EAC7B,IAAI,CACL,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAG1B;IACF,iBAAiB,EAAE,uBAAuB;IAC1C,mBAAmB,EAAE,yBAAyB;IAC9C,cAAc,EAAE,oBAAoB;CACrC,CAAC;AAEK,KAAK,UAAU,aAAa,CAEjC,SAAiB,EACjB,CAAS;IAET,MAAM,OAAO,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,kCAAkC,SAAS,EAAE,EAAE;YAC1F,SAAS,EAAE,CAAC;SACb,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleMessage = handleMessage;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("../GenericFunctions");
|
|
6
|
+
async function handleSendTextMessage(i) {
|
|
7
|
+
const recipientId = this.getNodeParameter('recipientId', i);
|
|
8
|
+
const text = this.getNodeParameter('text', i);
|
|
9
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', '/me/messages', {
|
|
10
|
+
recipient: { id: recipientId },
|
|
11
|
+
message: { text },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function handleSendMediaMessage(i) {
|
|
15
|
+
const recipientId = this.getNodeParameter('recipientId', i);
|
|
16
|
+
const attachmentType = this.getNodeParameter('attachmentType', i);
|
|
17
|
+
const mediaUrl = this.getNodeParameter('mediaUrl', i);
|
|
18
|
+
return await GenericFunctions_1.instagramApiRequest.call(this, 'POST', '/me/messages', {
|
|
19
|
+
recipient: { id: recipientId },
|
|
20
|
+
message: {
|
|
21
|
+
attachment: {
|
|
22
|
+
type: attachmentType,
|
|
23
|
+
payload: {
|
|
24
|
+
url: mediaUrl,
|
|
25
|
+
is_reusable: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function handleGetConversations(i) {
|
|
32
|
+
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
33
|
+
const limit = returnAll ? undefined : this.getNodeParameter('limit', i, 50);
|
|
34
|
+
return await GenericFunctions_1.instagramApiRequestAllItems.call(this, 'data', 'GET', '/me/conversations', {}, { fields: 'id,updated_time,participants' }, limit);
|
|
35
|
+
}
|
|
36
|
+
async function handleGetMessages(i) {
|
|
37
|
+
const conversationId = this.getNodeParameter('conversationId', i);
|
|
38
|
+
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
39
|
+
const limit = returnAll ? undefined : this.getNodeParameter('limit', i, 50);
|
|
40
|
+
return await GenericFunctions_1.instagramApiRequestAllItems.call(this, 'data', 'GET', `/${conversationId}/messages`, {}, { fields: 'id,created_time,from,to,message,attachments' }, limit);
|
|
41
|
+
}
|
|
42
|
+
const messageOperationHandlers = {
|
|
43
|
+
sendText: handleSendTextMessage,
|
|
44
|
+
sendMedia: handleSendMediaMessage,
|
|
45
|
+
getConversations: handleGetConversations,
|
|
46
|
+
getMessages: handleGetMessages,
|
|
47
|
+
};
|
|
48
|
+
async function handleMessage(operation, i) {
|
|
49
|
+
const handler = messageOperationHandlers[operation];
|
|
50
|
+
if (!handler) {
|
|
51
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported Message operation: ${operation}`, {
|
|
52
|
+
itemIndex: i,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return await handler.call(this, i);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=MessageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageHandler.js","sourceRoot":"","sources":["../../../../nodes/Instagram/handlers/MessageHandler.ts"],"names":[],"mappings":";;AA4EA,sCAYC;AAxFD,+CAAqE;AACrE,0DAG6B;AAE7B,KAAK,UAAU,qBAAqB,CAA0B,CAAS;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAW,CAAC;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAW,CAAC;IAExD,OAAO,MAAM,sCAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE;QAClE,SAAS,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;QAC9B,OAAO,EAAE,EAAE,IAAI,EAAE;KAClB,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,sBAAsB,CAA0B,CAAS;IACtE,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAW,CAAC;IACtE,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,CAAW,CAAC;IAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;IAEhE,OAAO,MAAM,sCAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE;QAClE,SAAS,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;QAC9B,OAAO,EAAE;YACP,UAAU,EAAE;gBACV,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE;oBACP,GAAG,EAAE,QAAQ;oBACb,WAAW,EAAE,IAAI;iBAClB;aACF;SACF;KACF,CAA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