n8n-nodes-script-runner 1.8.0 → 1.10.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.
@@ -13,13 +13,16 @@ async function fetchLinkedIn(accountId, url, totalLimit, apiKey, minDelaySec, ma
13
13
  const MAX_PAGES = 25;
14
14
  const MAX_CONSECUTIVE_EMPTY = 1;
15
15
  const PAGE_SIZE = 100;
16
+ // Store API metadata for return values
17
+ let apiEstimatedTotal = null;
18
+ let apiNextCursor = null;
16
19
  if (collected.length >= totalLimit || pageCount >= MAX_PAGES) {
17
20
  this.logger?.info?.(`Limit reached: ${collected.length} items | ${pageCount} pages`);
18
21
  return {
19
22
  items: collected,
20
- nextCursor: null,
23
+ nextCursor: apiNextCursor,
21
24
  lastFailedCursor: null,
22
- estimatedTotal: null,
25
+ estimatedTotal: apiEstimatedTotal,
23
26
  error: null,
24
27
  totalFetched: collected.length,
25
28
  };
@@ -44,18 +47,6 @@ async function fetchLinkedIn(accountId, url, totalLimit, apiKey, minDelaySec, ma
44
47
  `collected: ${collected.length}/${totalLimit}`);
45
48
  const response = await (0, axios_1.default)(config);
46
49
  const data = response.data;
47
- // Early return if page_count is zero
48
- if (data.paging?.page_count === 0) {
49
- this.logger.info(`page_count is 0, no results available`);
50
- return {
51
- items: collected,
52
- nextCursor: null,
53
- lastFailedCursor: null,
54
- estimatedTotal: 0,
55
- error: null,
56
- totalFetched: collected.length,
57
- };
58
- }
59
50
  const beforeLength = collected.length;
60
51
  // Deduplicate and collect
61
52
  if (Array.isArray(data.items)) {
@@ -68,16 +59,36 @@ async function fetchLinkedIn(accountId, url, totalLimit, apiKey, minDelaySec, ma
68
59
  }
69
60
  }
70
61
  }
62
+ // Early return if page_count is zero (no more pages available)
63
+ if (data.paging?.page_count === 0) {
64
+ const estimatedTotal = data.paging?.total_count ?? null;
65
+ if (estimatedTotal !== null)
66
+ apiEstimatedTotal = estimatedTotal;
67
+ this.logger.info(`page_count is 0, no more pages. Total collected: ${collected.length}`);
68
+ return {
69
+ items: collected,
70
+ nextCursor: null,
71
+ lastFailedCursor: null,
72
+ estimatedTotal: apiEstimatedTotal ?? estimatedTotal,
73
+ error: null,
74
+ totalFetched: collected.length,
75
+ };
76
+ }
71
77
  const addedThisPage = collected.length - beforeLength;
72
78
  const nextCursor = data.cursor ?? null;
73
79
  const estimatedTotal = data.paging?.total_count ?? null;
80
+ // Store for final return
81
+ if (estimatedTotal !== null)
82
+ apiEstimatedTotal = estimatedTotal;
83
+ if (nextCursor !== null)
84
+ apiNextCursor = nextCursor;
74
85
  if (!nextCursor) {
75
86
  this.logger.info(`No more cursor. Total collected: ${collected.length}`);
76
87
  return {
77
88
  items: collected,
78
- nextCursor: null,
89
+ nextCursor: apiNextCursor,
79
90
  lastFailedCursor: null,
80
- estimatedTotal,
91
+ estimatedTotal: apiEstimatedTotal ?? estimatedTotal,
81
92
  error: null,
82
93
  totalFetched: collected.length,
83
94
  };
@@ -129,9 +140,9 @@ async function fetchLinkedIn(accountId, url, totalLimit, apiKey, minDelaySec, ma
129
140
  // Fallback (should rarely reach here)
130
141
  return {
131
142
  items: collected,
132
- nextCursor: null,
133
- lastFailedCursor: startCursor,
134
- estimatedTotal: null,
143
+ nextCursor: apiNextCursor,
144
+ lastFailedCursor: null,
145
+ estimatedTotal: apiEstimatedTotal,
135
146
  error: null,
136
147
  totalFetched: collected.length,
137
148
  };
@@ -215,16 +226,17 @@ class LinkedInFetcher {
215
226
  for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
216
227
  try {
217
228
  const accountId = this.getNodeParameter('accountId', itemIndex);
218
- const url = this.getNodeParameter('url', itemIndex).trim();
229
+ const url = this.getNodeParameter('url', itemIndex)?.trim();
219
230
  const total = this.getNodeParameter('total', itemIndex);
220
231
  const apiKey = this.getNodeParameter('apiKey', itemIndex);
221
- let startCursor = this.getNodeParameter('startCursor', itemIndex, '').trim();
232
+ const startCursorRaw = this.getNodeParameter('startCursor', itemIndex, '');
233
+ let startCursor = startCursorRaw ? startCursorRaw.trim() : null;
222
234
  const minDelay = this.getNodeParameter('minDelay', itemIndex);
223
235
  const maxDelay = this.getNodeParameter('maxDelay', itemIndex);
224
236
  if (!url) {
225
237
  throw new Error('LinkedIn URL is required');
226
238
  }
227
- if (startCursor.trim() === '' || startCursor.trim() === 'null')
239
+ if (startCursor === '' || startCursor === 'null')
228
240
  startCursor = null;
229
241
  const result = await fetchLinkedIn.call(this, accountId, url, total, apiKey, minDelay, maxDelay, startCursor);
230
242
  returnData.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-script-runner",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "Custom n8n nodes for script execution (jsdom, cheerio) and HTTP requests (axios, fetch)",
5
5
  "main": "index.js",
6
6
  "scripts": {