@mookielianhd/n8n-nodes-instagram 3.2.1 → 3.4.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.
@@ -8,6 +8,30 @@ class InstagramApi {
8
8
  this.icon = 'file:instagram.svg';
9
9
  this.documentationUrl = 'https://github.com/MookieLian/n8n-nodes-instagram#credentials';
10
10
  this.properties = [
11
+ {
12
+ displayName: 'Auth Mode',
13
+ name: 'authMode',
14
+ type: 'options',
15
+ default: 'auto',
16
+ description: 'How to use the access token for authentication and which host to use for the connection test. Use Auto unless you know you need a specific API surface.',
17
+ options: [
18
+ {
19
+ name: 'Auto (Detect by Token Prefix)',
20
+ value: 'auto',
21
+ description: 'If the token starts with "IG", use graph.instagram.com (Bearer auth). Otherwise, use graph.facebook.com (access_token query).',
22
+ },
23
+ {
24
+ name: 'Graph API (graph.facebook.com)',
25
+ value: 'graph',
26
+ description: 'Use Facebook Graph API style (graph.facebook.com) with access_token query parameter. Common for Instagram Graph API publishing flows.',
27
+ },
28
+ {
29
+ name: 'Instagram API (graph.instagram.com)',
30
+ value: 'instagram',
31
+ description: 'Use Instagram API style (graph.instagram.com) with Authorization: Bearer <token>. Common for IG-prefixed tokens.',
32
+ },
33
+ ],
34
+ },
11
35
  {
12
36
  displayName: 'Access Token',
13
37
  name: 'accessToken',
@@ -21,6 +45,9 @@ class InstagramApi {
21
45
  this.authenticate = {
22
46
  type: 'generic',
23
47
  properties: {
48
+ headers: {
49
+ Authorization: '={{"Bearer " + $credentials.accessToken}}',
50
+ },
24
51
  qs: {
25
52
  access_token: '={{$credentials.accessToken}}',
26
53
  },
@@ -29,7 +56,15 @@ class InstagramApi {
29
56
  this.test = {
30
57
  request: {
31
58
  method: 'GET',
32
- url: 'https://graph.facebook.com/v22.0/me',
59
+ url: '={{(() => {\n' +
60
+ ' const token = String($credentials.accessToken || "");\n' +
61
+ ' const authMode = String($credentials.authMode || "auto");\n' +
62
+ ' const isIgPrefixed = token.startsWith("IG");\n' +
63
+ ' const mode = authMode === "auto" ? (isIgPrefixed ? "instagram" : "graph") : authMode;\n' +
64
+ ' return mode === "instagram"\n' +
65
+ ' ? "https://graph.instagram.com/v21.0/me"\n' +
66
+ ' : "https://graph.facebook.com/v22.0/me";\n' +
67
+ '})()}}',
33
68
  qs: {
34
69
  fields: 'id',
35
70
  },
@@ -1 +1 @@
1
- {"version":3,"file":"InstagramApi.credentials.js","sourceRoot":"","sources":["../../credentials/InstagramApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAAG,eAAe,CAAC;QAC9B,SAAI,GAAS,oBAAoB,CAAC;QAClC,qBAAgB,GAAG,+DAA+D,CAAC;QACnF,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,gEAAgE;aAC7E;SACD,CAAC;QACF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,EAAE,EAAE;oBACH,YAAY,EAAE,+BAA+B;iBAC7C;aACD;SACD,CAAC;QACF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,qCAAqC;gBAC1C,EAAE,EAAE;oBACH,MAAM,EAAE,IAAI;iBACZ;aACD;SACD,CAAC;IACH,CAAC;CAAA;AAjCD,oCAiCC"}
1
+ {"version":3,"file":"InstagramApi.credentials.js","sourceRoot":"","sources":["../../credentials/InstagramApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAAG,eAAe,CAAC;QAC9B,SAAI,GAAS,oBAAoB,CAAC;QAClC,qBAAgB,GAAG,+DAA+D,CAAC;QACnF,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,MAAM;gBACf,WAAW,EACV,yJAAyJ;gBAC1J,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,+BAA+B;wBACrC,KAAK,EAAE,MAAM;wBACb,WAAW,EACV,+HAA+H;qBAChI;oBACD;wBACC,IAAI,EAAE,gCAAgC;wBACtC,KAAK,EAAE,OAAO;wBACd,WAAW,EACV,uIAAuI;qBACxI;oBACD;wBACC,IAAI,EAAE,qCAAqC;wBAC3C,KAAK,EAAE,WAAW;wBAClB,WAAW,EACV,kHAAkH;qBACnH;iBACD;aACD;YACD;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,gEAAgE;aAC7E;SACD,CAAC;QACF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,2CAA2C;iBAC1D;gBACD,EAAE,EAAE;oBACH,YAAY,EAAE,+BAA+B;iBAC7C;aACD;SACD,CAAC;QACF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,MAAM,EAAE,KAAK;gBACb,GAAG,EACF,eAAe;oBACf,2DAA2D;oBAC3D,+DAA+D;oBAC/D,kDAAkD;oBAClD,2FAA2F;oBAC3F,iCAAiC;oBACjC,gDAAgD;oBAChD,gDAAgD;oBAChD,QAAQ;gBACT,EAAE,EAAE;oBACH,MAAM,EAAE,IAAI;iBACZ;aACD;SACD,CAAC;IACH,CAAC;CAAA;AAzED,oCAyEC"}
@@ -736,6 +736,27 @@ class Instagram {
736
736
  default: '',
737
737
  description: 'Alternative text for image posts (for accessibility). Image only; not supported for Reels or Stories.',
738
738
  },
739
+ {
740
+ displayName: 'Audio Name',
741
+ name: 'audioName',
742
+ type: 'string',
743
+ default: '',
744
+ description: 'Custom name for the original audio associated with this reel. Applies only to Reels.',
745
+ },
746
+ {
747
+ displayName: 'Collaborators',
748
+ name: 'collaborators',
749
+ type: 'string',
750
+ default: '',
751
+ description: 'Comma-separated Instagram usernames to invite as collaborators on this reel (without @). Applies only to Reels.',
752
+ },
753
+ {
754
+ displayName: 'Cover URL',
755
+ name: 'coverUrl',
756
+ type: 'string',
757
+ default: '',
758
+ description: 'URL of an image to use as the custom cover for the reel. Applies only to Reels.',
759
+ },
739
760
  {
740
761
  displayName: 'Location ID',
741
762
  name: 'locationId',
@@ -794,6 +815,23 @@ class Instagram {
794
815
  },
795
816
  ],
796
817
  },
818
+ {
819
+ displayName: 'Share to Feed',
820
+ name: 'shareToFeed',
821
+ type: 'boolean',
822
+ default: true,
823
+ description: 'Whether to share the reel to the Instagram feed as well as the Reels tab. Applies only to Reels.',
824
+ },
825
+ {
826
+ displayName: 'Thumbnail Offset (Seconds)',
827
+ name: 'thumbOffset',
828
+ type: 'number',
829
+ typeOptions: {
830
+ minValue: 0,
831
+ },
832
+ default: 0,
833
+ description: 'Time in seconds from the start of the video to use for the reel thumbnail. Applies only to Reels.',
834
+ },
797
835
  {
798
836
  displayName: 'Trial Reel - Graduation Strategy',
799
837
  name: 'trialReelGraduationStrategy',
@@ -870,7 +908,7 @@ class Instagram {
870
908
  };
871
909
  }
872
910
  async execute() {
873
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
911
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
874
912
  const items = this.getInputData();
875
913
  const returnItems = [];
876
914
  const hostUrl = 'graph.facebook.com';
@@ -1068,7 +1106,14 @@ class Instagram {
1068
1106
  }
1069
1107
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to get message text parameter at item index ${itemIndex}: ${error instanceof Error ? error.message : String(error)}`, { itemIndex });
1070
1108
  }
1071
- const url = `https://${hostUrl}/${graphApiVersion}/${accountId}/messages`;
1109
+ const credentials = (await this.getCredentials('instagramApi'));
1110
+ const accessToken = (_a = credentials === null || credentials === void 0 ? void 0 : credentials.accessToken) !== null && _a !== void 0 ? _a : '';
1111
+ const authMode = (_b = credentials === null || credentials === void 0 ? void 0 : credentials.authMode) !== null && _b !== void 0 ? _b : 'auto';
1112
+ const isIgPrefixed = accessToken.startsWith('IG');
1113
+ const mode = authMode === 'auto' ? (isIgPrefixed ? 'instagram' : 'graph') : authMode;
1114
+ const url = mode === 'instagram'
1115
+ ? `https://graph.instagram.com/${graphApiVersion}/me/messages`
1116
+ : `https://${hostUrl}/${graphApiVersion}/${accountId}/messages`;
1072
1117
  const requestOptions = {
1073
1118
  headers: {
1074
1119
  accept: 'application/json,text/*;q=0.99',
@@ -1111,7 +1156,7 @@ class Instagram {
1111
1156
  let errorItem;
1112
1157
  const errorWithGraph = error;
1113
1158
  if (errorWithGraph.response !== undefined) {
1114
- const graphApiErrors = (_b = (_a = errorWithGraph.response.body) === null || _a === void 0 ? void 0 : _a.error) !== null && _b !== void 0 ? _b : {};
1159
+ const graphApiErrors = (_d = (_c = errorWithGraph.response.body) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : {};
1115
1160
  errorItem = {
1116
1161
  statusCode: errorWithGraph.statusCode,
1117
1162
  ...graphApiErrors,
@@ -1128,7 +1173,7 @@ class Instagram {
1128
1173
  if (resource === 'auth') {
1129
1174
  try {
1130
1175
  if (operation === 'refreshAccessToken') {
1131
- let token = (_c = this.getNodeParameter('accessToken', itemIndex, '')) !== null && _c !== void 0 ? _c : '';
1176
+ let token = (_e = this.getNodeParameter('accessToken', itemIndex, '')) !== null && _e !== void 0 ? _e : '';
1132
1177
  if (!token) {
1133
1178
  let credentials;
1134
1179
  try {
@@ -1140,7 +1185,7 @@ class Instagram {
1140
1185
  if (!credentials) {
1141
1186
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Instagram API credentials not found. Please configure the Instagram API credential.', { itemIndex });
1142
1187
  }
1143
- token = (_d = credentials === null || credentials === void 0 ? void 0 : credentials.accessToken) !== null && _d !== void 0 ? _d : '';
1188
+ token = (_f = credentials === null || credentials === void 0 ? void 0 : credentials.accessToken) !== null && _f !== void 0 ? _f : '';
1144
1189
  }
1145
1190
  if (!token || typeof token !== 'string') {
1146
1191
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No access token provided and no access token found in the Instagram API credential. Please provide an access token or configure it in the credential.', { itemIndex });
@@ -1266,7 +1311,7 @@ class Instagram {
1266
1311
  let errorItem;
1267
1312
  const errorWithGraph = error;
1268
1313
  if (errorWithGraph.response !== undefined) {
1269
- const graphApiErrors = (_f = (_e = errorWithGraph.response.body) === null || _e === void 0 ? void 0 : _e.error) !== null && _f !== void 0 ? _f : {};
1314
+ const graphApiErrors = (_h = (_g = errorWithGraph.response.body) === null || _g === void 0 ? void 0 : _g.error) !== null && _h !== void 0 ? _h : {};
1270
1315
  errorItem = {
1271
1316
  statusCode: errorWithGraph.statusCode,
1272
1317
  ...graphApiErrors,
@@ -1348,7 +1393,7 @@ class Instagram {
1348
1393
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid carousel media array field name at item index ${itemIndex}. Field name must be a non-empty string.`, { itemIndex });
1349
1394
  }
1350
1395
  const mediaTypeMode = this.getNodeParameter('carouselMediaArrayType', itemIndex, 'auto');
1351
- const itemJson = (_g = items[itemIndex]) === null || _g === void 0 ? void 0 : _g.json;
1396
+ const itemJson = (_j = items[itemIndex]) === null || _j === void 0 ? void 0 : _j.json;
1352
1397
  const rawArray = resolveFieldPath(itemJson, fieldName);
1353
1398
  if (!Array.isArray(rawArray)) {
1354
1399
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid carousel media array at item index ${itemIndex}. The field "${fieldName}" must contain an array.`, { itemIndex });
@@ -1430,7 +1475,7 @@ class Instagram {
1430
1475
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to get carousel media parameter at item index ${itemIndex}: ${error instanceof Error ? error.message : String(error)}`, { itemIndex });
1431
1476
  }
1432
1477
  }
1433
- const mediaItems = (_h = carouselMedia === null || carouselMedia === void 0 ? void 0 : carouselMedia.mediaItem) !== null && _h !== void 0 ? _h : [];
1478
+ const mediaItems = (_k = carouselMedia === null || carouselMedia === void 0 ? void 0 : carouselMedia.mediaItem) !== null && _k !== void 0 ? _k : [];
1434
1479
  if (!Array.isArray(mediaItems)) {
1435
1480
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid carousel media items format at item index ${itemIndex}. Media items must be an array.`, { itemIndex });
1436
1481
  }
@@ -1454,7 +1499,7 @@ class Instagram {
1454
1499
  if (item.mediaType !== 'image' && item.mediaType !== 'video') {
1455
1500
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${mediaLabel}: Invalid media type '${item.mediaType}'. Media type must be either 'image' or 'video'.`, { itemIndex });
1456
1501
  }
1457
- const url = isVideo ? ((_j = item.videoUrl) !== null && _j !== void 0 ? _j : '').trim() : ((_k = item.imageUrl) !== null && _k !== void 0 ? _k : '').trim();
1502
+ const url = isVideo ? ((_l = item.videoUrl) !== null && _l !== void 0 ? _l : '').trim() : ((_m = item.imageUrl) !== null && _m !== void 0 ? _m : '').trim();
1458
1503
  if (!url || typeof url !== 'string') {
1459
1504
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${mediaLabel}: ${isVideo ? 'Video URL' : 'Image URL'} is required and must be a non-empty string.`, { itemIndex });
1460
1505
  }
@@ -1556,11 +1601,11 @@ class Instagram {
1556
1601
  const errorItem = errorWithGraph.response !== undefined
1557
1602
  ? {
1558
1603
  statusCode: errorWithGraph.statusCode,
1559
- ...((_m = (_l = errorWithGraph.response.body) === null || _l === void 0 ? void 0 : _l.error) !== null && _m !== void 0 ? _m : {}),
1604
+ ...((_p = (_o = errorWithGraph.response.body) === null || _o === void 0 ? void 0 : _o.error) !== null && _p !== void 0 ? _p : {}),
1560
1605
  headers: errorWithGraph.response.headers,
1561
1606
  }
1562
1607
  : error;
1563
- const contextMessage = error instanceof Error ? error.message : String((_o = error.message) !== null && _o !== void 0 ? _o : error);
1608
+ const contextMessage = error instanceof Error ? error.message : String((_q = error.message) !== null && _q !== void 0 ? _q : error);
1564
1609
  returnItems.push({
1565
1610
  json: { ...errorItem, carouselErrorContext: contextMessage },
1566
1611
  pairedItem: { item: itemIndex },
@@ -1730,13 +1775,13 @@ class Instagram {
1730
1775
  }
1731
1776
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to fetch ${edge} for hashtag ${hashtagId} at page ${pageNumber}: ${error instanceof Error ? error.message : String(error)}`, { itemIndex });
1732
1777
  }
1733
- const pageData = (_p = response.data) !== null && _p !== void 0 ? _p : [];
1778
+ const pageData = (_r = response.data) !== null && _r !== void 0 ? _r : [];
1734
1779
  if (!Array.isArray(pageData)) {
1735
1780
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid data format in response from ${edge} API at page ${pageNumber}. Expected array, got: ${typeof pageData}. Response: ${JSON.stringify(response)}`, { itemIndex });
1736
1781
  }
1737
1782
  accumulated.push(...pageData);
1738
1783
  const paging = response.paging;
1739
- after = (_q = paging === null || paging === void 0 ? void 0 : paging.cursors) === null || _q === void 0 ? void 0 : _q.after;
1784
+ after = (_s = paging === null || paging === void 0 ? void 0 : paging.cursors) === null || _s === void 0 ? void 0 : _s.after;
1740
1785
  if ((!returnAll && accumulated.length >= hardCap) || !after) {
1741
1786
  hasMore = false;
1742
1787
  }
@@ -1754,7 +1799,7 @@ class Instagram {
1754
1799
  let errorItem;
1755
1800
  const errorWithGraph = error;
1756
1801
  if (errorWithGraph.response !== undefined) {
1757
- const graphApiErrors = (_s = (_r = errorWithGraph.response.body) === null || _r === void 0 ? void 0 : _r.error) !== null && _s !== void 0 ? _s : {};
1802
+ const graphApiErrors = (_u = (_t = errorWithGraph.response.body) === null || _t === void 0 ? void 0 : _t.error) !== null && _u !== void 0 ? _u : {};
1758
1803
  errorItem = {
1759
1804
  statusCode: errorWithGraph.statusCode,
1760
1805
  ...graphApiErrors,
@@ -1834,7 +1879,7 @@ class Instagram {
1834
1879
  let errorItem;
1835
1880
  const errorWithGraph = error;
1836
1881
  if (errorWithGraph.response !== undefined) {
1837
- const graphApiErrors = (_u = (_t = errorWithGraph.response.body) === null || _t === void 0 ? void 0 : _t.error) !== null && _u !== void 0 ? _u : {};
1882
+ const graphApiErrors = (_w = (_v = errorWithGraph.response.body) === null || _v === void 0 ? void 0 : _v.error) !== null && _w !== void 0 ? _w : {};
1838
1883
  errorItem = {
1839
1884
  statusCode: errorWithGraph.statusCode,
1840
1885
  ...graphApiErrors,
@@ -1991,13 +2036,13 @@ class Instagram {
1991
2036
  }
1992
2037
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to fetch media for account ${accountId} at page ${pageNumber}: ${error instanceof Error ? error.message : String(error)}`, { itemIndex });
1993
2038
  }
1994
- const pageData = (_v = response.data) !== null && _v !== void 0 ? _v : [];
2039
+ const pageData = (_x = response.data) !== null && _x !== void 0 ? _x : [];
1995
2040
  if (!Array.isArray(pageData)) {
1996
2041
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid data format in response from IG User media API at page ${pageNumber}. Expected array, got: ${typeof pageData}. Response: ${JSON.stringify(response)}`, { itemIndex });
1997
2042
  }
1998
2043
  accumulated.push(...pageData);
1999
2044
  const paging = response.paging;
2000
- after = (_w = paging === null || paging === void 0 ? void 0 : paging.cursors) === null || _w === void 0 ? void 0 : _w.after;
2045
+ after = (_y = paging === null || paging === void 0 ? void 0 : paging.cursors) === null || _y === void 0 ? void 0 : _y.after;
2001
2046
  if ((!returnAll && accumulated.length >= hardCap) || !after) {
2002
2047
  hasMore = false;
2003
2048
  }
@@ -2015,7 +2060,7 @@ class Instagram {
2015
2060
  let errorItem;
2016
2061
  const errorWithGraph = error;
2017
2062
  if (errorWithGraph.response !== undefined) {
2018
- const graphApiErrors = (_y = (_x = errorWithGraph.response.body) === null || _x === void 0 ? void 0 : _x.error) !== null && _y !== void 0 ? _y : {};
2063
+ const graphApiErrors = (_0 = (_z = errorWithGraph.response.body) === null || _z === void 0 ? void 0 : _z.error) !== null && _0 !== void 0 ? _0 : {};
2019
2064
  errorItem = {
2020
2065
  statusCode: errorWithGraph.statusCode,
2021
2066
  ...graphApiErrors,
@@ -2248,7 +2293,14 @@ class Instagram {
2248
2293
  }
2249
2294
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to get private reply text parameter at item index ${itemIndex}: ${error instanceof Error ? error.message : String(error)}`, { itemIndex });
2250
2295
  }
2251
- const url = `https://${hostUrl}/${graphApiVersion}/${accountId}/messages`;
2296
+ const credentials = (await this.getCredentials('instagramApi'));
2297
+ const accessToken = (_1 = credentials === null || credentials === void 0 ? void 0 : credentials.accessToken) !== null && _1 !== void 0 ? _1 : '';
2298
+ const authMode = (_2 = credentials === null || credentials === void 0 ? void 0 : credentials.authMode) !== null && _2 !== void 0 ? _2 : 'auto';
2299
+ const isIgPrefixed = accessToken.startsWith('IG');
2300
+ const mode = authMode === 'auto' ? (isIgPrefixed ? 'instagram' : 'graph') : authMode;
2301
+ const url = mode === 'instagram'
2302
+ ? `https://graph.instagram.com/${graphApiVersion}/me/messages`
2303
+ : `https://${hostUrl}/${graphApiVersion}/${accountId}/messages`;
2252
2304
  const requestOptions = {
2253
2305
  headers: {
2254
2306
  accept: 'application/json,text/*;q=0.99',
@@ -2291,7 +2343,7 @@ class Instagram {
2291
2343
  let errorItem;
2292
2344
  const errorWithGraph = error;
2293
2345
  if (errorWithGraph.response !== undefined) {
2294
- const graphApiErrors = (_0 = (_z = errorWithGraph.response.body) === null || _z === void 0 ? void 0 : _z.error) !== null && _0 !== void 0 ? _0 : {};
2346
+ const graphApiErrors = (_4 = (_3 = errorWithGraph.response.body) === null || _3 === void 0 ? void 0 : _3.error) !== null && _4 !== void 0 ? _4 : {};
2295
2347
  errorItem = {
2296
2348
  statusCode: errorWithGraph.statusCode,
2297
2349
  ...graphApiErrors,
@@ -2366,7 +2418,7 @@ class Instagram {
2366
2418
  }
2367
2419
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to get additional fields parameter at item index ${itemIndex}: ${error instanceof Error ? error.message : String(error)}`, { itemIndex });
2368
2420
  }
2369
- const altText = (_1 = additionalFields.altText) !== null && _1 !== void 0 ? _1 : '';
2421
+ const altText = (_5 = additionalFields.altText) !== null && _5 !== void 0 ? _5 : '';
2370
2422
  const rawLocationId = additionalFields.locationId;
2371
2423
  const userTagsCollection = additionalFields.userTags;
2372
2424
  const productTagsCollection = additionalFields.productTags;
@@ -2458,6 +2510,31 @@ class Instagram {
2458
2510
  mediaQs.product_tags = JSON.stringify(productTags);
2459
2511
  }
2460
2512
  }
2513
+ if (resource === 'reels') {
2514
+ const shareToFeed = additionalFields.shareToFeed;
2515
+ if (shareToFeed !== undefined) {
2516
+ mediaQs.share_to_feed = shareToFeed;
2517
+ }
2518
+ const collaboratorsRaw = additionalFields.collaborators;
2519
+ const collaborators = collaboratorsRaw === null || collaboratorsRaw === void 0 ? void 0 : collaboratorsRaw.trim();
2520
+ if (collaborators) {
2521
+ mediaQs.collaborators = collaborators;
2522
+ }
2523
+ const coverUrlRaw = additionalFields.coverUrl;
2524
+ const coverUrl = coverUrlRaw === null || coverUrlRaw === void 0 ? void 0 : coverUrlRaw.trim();
2525
+ if (coverUrl) {
2526
+ mediaQs.cover_url = coverUrl;
2527
+ }
2528
+ const audioNameRaw = additionalFields.audioName;
2529
+ const audioName = audioNameRaw === null || audioNameRaw === void 0 ? void 0 : audioNameRaw.trim();
2530
+ if (audioName) {
2531
+ mediaQs.audio_name = audioName;
2532
+ }
2533
+ const thumbOffset = additionalFields.thumbOffset;
2534
+ if (thumbOffset !== undefined) {
2535
+ mediaQs.thumb_offset = thumbOffset;
2536
+ }
2537
+ }
2461
2538
  const graduationStrategy = additionalFields.trialReelGraduationStrategy;
2462
2539
  if (graduationStrategy) {
2463
2540
  if (resource !== 'reels') {
@@ -2485,7 +2562,7 @@ class Instagram {
2485
2562
  let errorCode;
2486
2563
  let errorType;
2487
2564
  const err = error;
2488
- if ((_3 = (_2 = err.response) === null || _2 === void 0 ? void 0 : _2.body) === null || _3 === void 0 ? void 0 : _3.error) {
2565
+ if ((_7 = (_6 = err.response) === null || _6 === void 0 ? void 0 : _6.body) === null || _7 === void 0 ? void 0 : _7.error) {
2489
2566
  const graphError = err.response.body.error;
2490
2567
  errorMessage = graphError.message || errorMessage;
2491
2568
  errorCode = graphError.code;
@@ -2511,7 +2588,7 @@ class Instagram {
2511
2588
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to create media container: The ${videoUrl ? 'video' : 'image'} URL appears to be invalid or unreachable. Error: ${errorMessage}${errorCode ? ` (Code: ${errorCode})` : ''}. Please verify that the URL is accessible and points to a valid ${videoUrl ? 'video' : 'image'} file. URL: ${urlToCheck.substring(0, 100)}${urlToCheck.length > 100 ? '...' : ''}`, { itemIndex });
2512
2589
  }
2513
2590
  if (!this.continueOnFail()) {
2514
- const errorObj = (_5 = (_4 = err.response) === null || _4 === void 0 ? void 0 : _4.body) === null || _5 === void 0 ? void 0 : _5.error;
2591
+ const errorObj = (_9 = (_8 = err.response) === null || _8 === void 0 ? void 0 : _8.body) === null || _9 === void 0 ? void 0 : _9.error;
2515
2592
  const detailedError = {
2516
2593
  message: errorMessage,
2517
2594
  ...(errorCode && { code: errorCode }),
@@ -2534,7 +2611,7 @@ class Instagram {
2534
2611
  }
2535
2612
  let errorItem;
2536
2613
  if (err.response !== undefined) {
2537
- const graphApiErrors = (_7 = (_6 = err.response.body) === null || _6 === void 0 ? void 0 : _6.error) !== null && _7 !== void 0 ? _7 : {};
2614
+ const graphApiErrors = (_11 = (_10 = err.response.body) === null || _10 === void 0 ? void 0 : _10.error) !== null && _11 !== void 0 ? _11 : {};
2538
2615
  errorItem = {
2539
2616
  statusCode: err.statusCode,
2540
2617
  ...graphApiErrors,
@@ -2645,7 +2722,7 @@ class Instagram {
2645
2722
  let errorItem;
2646
2723
  const err = error;
2647
2724
  if (err.response !== undefined) {
2648
- const graphApiErrors = (_9 = (_8 = err.response.body) === null || _8 === void 0 ? void 0 : _8.error) !== null && _9 !== void 0 ? _9 : {};
2725
+ const graphApiErrors = (_13 = (_12 = err.response.body) === null || _12 === void 0 ? void 0 : _12.error) !== null && _13 !== void 0 ? _13 : {};
2649
2726
  errorItem = {
2650
2727
  statusCode: err.statusCode,
2651
2728
  ...graphApiErrors,
@@ -2691,7 +2768,7 @@ class Instagram {
2691
2768
  let errorItem;
2692
2769
  const errorWithGraph = error;
2693
2770
  if (errorWithGraph.response !== undefined) {
2694
- const graphApiErrors = (_11 = (_10 = errorWithGraph.response.body) === null || _10 === void 0 ? void 0 : _10.error) !== null && _11 !== void 0 ? _11 : {};
2771
+ const graphApiErrors = (_15 = (_14 = errorWithGraph.response.body) === null || _14 === void 0 ? void 0 : _14.error) !== null && _15 !== void 0 ? _15 : {};
2695
2772
  errorItem = {
2696
2773
  statusCode: errorWithGraph.statusCode,
2697
2774
  ...graphApiErrors,