@fachkraftfreund/n8n-nodes-supabase 1.2.17 → 1.2.19
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.
|
@@ -207,34 +207,63 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
207
207
|
console.log(`[Supabase READ] item=${itemIndex} table=${table} returnAll=${returnAll} chunks=${filterChunks.length} maxItems=${maxItems} maxInChars=${maxInChars}`);
|
|
208
208
|
const returnData = [];
|
|
209
209
|
if (returnAll) {
|
|
210
|
+
const batchSize = 1000;
|
|
210
211
|
for (let ci = 0; ci < filterChunks.length; ci++) {
|
|
211
212
|
const chunkFilters = filterChunks[ci];
|
|
212
213
|
const inFilter = chunkFilters.find(f => f.operator === 'in');
|
|
213
214
|
const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
|
|
214
215
|
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) - starting...`);
|
|
215
216
|
const chunkStart = Date.now();
|
|
216
|
-
|
|
217
|
-
let batchOffset = 0;
|
|
217
|
+
let lastId = null;
|
|
218
218
|
let hasMore = true;
|
|
219
|
+
let batchCount = 0;
|
|
219
220
|
while (hasMore) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
console.log(`[Supabase READ] chunk ${ci + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(batchError)}`);
|
|
224
|
-
throw new Error((0, supabaseClient_1.formatSupabaseError)(batchError));
|
|
221
|
+
let query = buildReadQuery(supabase, table, returnFields, chunkFilters, []);
|
|
222
|
+
if (lastId !== null) {
|
|
223
|
+
query = query.gt('id', lastId);
|
|
225
224
|
}
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
query = query.order('id', { ascending: true }).limit(batchSize);
|
|
226
|
+
const { data, error } = await query;
|
|
227
|
+
if (error) {
|
|
228
|
+
console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
|
|
229
|
+
throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
|
|
230
|
+
}
|
|
231
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
232
|
+
for (const row of data) {
|
|
228
233
|
returnData.push({ json: row });
|
|
229
234
|
}
|
|
230
|
-
|
|
235
|
+
lastId = data[data.length - 1].id;
|
|
236
|
+
hasMore = data.length === batchSize;
|
|
231
237
|
}
|
|
232
238
|
else {
|
|
233
239
|
hasMore = false;
|
|
234
240
|
}
|
|
235
|
-
|
|
241
|
+
batchCount++;
|
|
242
|
+
if (batchCount % 50 === 0) {
|
|
243
|
+
console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
|
|
244
|
+
}
|
|
236
245
|
}
|
|
237
|
-
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} done in ${Date.now() - chunkStart}ms
|
|
246
|
+
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} done in ${Date.now() - chunkStart}ms — ${batchCount} batches, ${returnData.length} total rows`);
|
|
247
|
+
}
|
|
248
|
+
if (sort.length > 0) {
|
|
249
|
+
returnData.sort((a, b) => {
|
|
250
|
+
var _a, _b;
|
|
251
|
+
for (const s of sort) {
|
|
252
|
+
const aVal = (_a = a.json[s.column]) !== null && _a !== void 0 ? _a : null;
|
|
253
|
+
const bVal = (_b = b.json[s.column]) !== null && _b !== void 0 ? _b : null;
|
|
254
|
+
if (aVal === bVal)
|
|
255
|
+
continue;
|
|
256
|
+
if (aVal === null)
|
|
257
|
+
return 1;
|
|
258
|
+
if (bVal === null)
|
|
259
|
+
return -1;
|
|
260
|
+
if (aVal < bVal)
|
|
261
|
+
return s.ascending ? -1 : 1;
|
|
262
|
+
if (aVal > bVal)
|
|
263
|
+
return s.ascending ? 1 : -1;
|
|
264
|
+
}
|
|
265
|
+
return 0;
|
|
266
|
+
});
|
|
238
267
|
}
|
|
239
268
|
}
|
|
240
269
|
else {
|
|
@@ -9,6 +9,13 @@ function createSupabaseClient(credentials) {
|
|
|
9
9
|
persistSession: false,
|
|
10
10
|
detectSessionInUrl: false,
|
|
11
11
|
},
|
|
12
|
+
global: {
|
|
13
|
+
fetch: (url, init) => {
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timeout = setTimeout(() => controller.abort(), 60000);
|
|
16
|
+
return fetch(url, { ...init, signal: controller.signal }).finally(() => clearTimeout(timeout));
|
|
17
|
+
},
|
|
18
|
+
},
|
|
12
19
|
});
|
|
13
20
|
return client;
|
|
14
21
|
}
|
package/package.json
CHANGED