@fachkraftfreund/n8n-nodes-supabase 1.2.18 → 1.2.20
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.
|
@@ -912,7 +912,8 @@ class Supabase {
|
|
|
912
912
|
}
|
|
913
913
|
try {
|
|
914
914
|
const results = await database_1.executeBulkDatabaseOperation.call(this, supabase, operation, items.length);
|
|
915
|
-
|
|
915
|
+
for (const r of results)
|
|
916
|
+
returnData.push(r);
|
|
916
917
|
}
|
|
917
918
|
catch (error) {
|
|
918
919
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
@@ -927,7 +928,8 @@ class Supabase {
|
|
|
927
928
|
else if (resource === 'database' && operation === 'read') {
|
|
928
929
|
try {
|
|
929
930
|
const operationResults = await database_1.executeDatabaseOperation.call(this, supabase, operation, 0, credentials.host);
|
|
930
|
-
|
|
931
|
+
for (const r of operationResults)
|
|
932
|
+
returnData.push(r);
|
|
931
933
|
}
|
|
932
934
|
catch (error) {
|
|
933
935
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
@@ -952,7 +954,8 @@ class Supabase {
|
|
|
952
954
|
else {
|
|
953
955
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`);
|
|
954
956
|
}
|
|
955
|
-
|
|
957
|
+
for (const r of operationResults)
|
|
958
|
+
returnData.push(r);
|
|
956
959
|
}
|
|
957
960
|
catch (error) {
|
|
958
961
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
@@ -6,9 +6,12 @@ async function executeDatabaseOperation(supabase, operation, itemIndex, hostUrl)
|
|
|
6
6
|
const returnData = [];
|
|
7
7
|
try {
|
|
8
8
|
switch (operation) {
|
|
9
|
-
case 'read':
|
|
10
|
-
|
|
9
|
+
case 'read': {
|
|
10
|
+
const rows = await handleRead.call(this, supabase, itemIndex, hostUrl);
|
|
11
|
+
for (const r of rows)
|
|
12
|
+
returnData.push(r);
|
|
11
13
|
break;
|
|
14
|
+
}
|
|
12
15
|
case 'delete':
|
|
13
16
|
returnData.push(...await handleDelete.call(this, supabase, itemIndex, hostUrl));
|
|
14
17
|
break;
|
|
@@ -206,44 +209,64 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
206
209
|
const filterChunks = (0, supabaseClient_1.expandChunkedFilters)(filters, maxInChars, maxItems);
|
|
207
210
|
console.log(`[Supabase READ] item=${itemIndex} table=${table} returnAll=${returnAll} chunks=${filterChunks.length} maxItems=${maxItems} maxInChars=${maxInChars}`);
|
|
208
211
|
const returnData = [];
|
|
209
|
-
|
|
210
|
-
const inFilter = chunkFilters.find(f => f.operator === 'in');
|
|
211
|
-
const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
|
|
212
|
-
console.log(`[Supabase READ] chunk ${chunkIndex + 1}/${totalChunks} (${chunkIds} IDs) - starting...`);
|
|
213
|
-
const chunkStart = Date.now();
|
|
214
|
-
const rows = [];
|
|
212
|
+
if (returnAll) {
|
|
215
213
|
const batchSize = 1000;
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
214
|
+
for (let ci = 0; ci < filterChunks.length; ci++) {
|
|
215
|
+
const chunkFilters = filterChunks[ci];
|
|
216
|
+
const inFilter = chunkFilters.find(f => f.operator === 'in');
|
|
217
|
+
const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
|
|
218
|
+
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) - starting...`);
|
|
219
|
+
const chunkStart = Date.now();
|
|
220
|
+
let lastId = null;
|
|
221
|
+
let hasMore = true;
|
|
222
|
+
let batchCount = 0;
|
|
223
|
+
while (hasMore) {
|
|
224
|
+
let query = buildReadQuery(supabase, table, returnFields, chunkFilters, []);
|
|
225
|
+
if (lastId !== null) {
|
|
226
|
+
query = query.gt('id', lastId);
|
|
227
|
+
}
|
|
228
|
+
query = query.order('id', { ascending: true }).limit(batchSize);
|
|
229
|
+
const { data, error } = await query;
|
|
230
|
+
if (error) {
|
|
231
|
+
console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
|
|
232
|
+
throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
|
|
233
|
+
}
|
|
234
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
235
|
+
for (const row of data) {
|
|
236
|
+
returnData.push({ json: row });
|
|
237
|
+
}
|
|
238
|
+
lastId = data[data.length - 1].id;
|
|
239
|
+
hasMore = data.length === batchSize;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
hasMore = false;
|
|
243
|
+
}
|
|
244
|
+
batchCount++;
|
|
245
|
+
if (batchCount % 50 === 0) {
|
|
246
|
+
console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
|
|
228
247
|
}
|
|
229
|
-
hasMore = batchData.length === batchSize;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
hasMore = false;
|
|
233
248
|
}
|
|
234
|
-
|
|
249
|
+
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} done in ${Date.now() - chunkStart}ms — ${batchCount} batches, ${returnData.length} total rows`);
|
|
235
250
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
251
|
+
if (sort.length > 0) {
|
|
252
|
+
returnData.sort((a, b) => {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
for (const s of sort) {
|
|
255
|
+
const aVal = (_a = a.json[s.column]) !== null && _a !== void 0 ? _a : null;
|
|
256
|
+
const bVal = (_b = b.json[s.column]) !== null && _b !== void 0 ? _b : null;
|
|
257
|
+
if (aVal === bVal)
|
|
258
|
+
continue;
|
|
259
|
+
if (aVal === null)
|
|
260
|
+
return 1;
|
|
261
|
+
if (bVal === null)
|
|
262
|
+
return -1;
|
|
263
|
+
if (aVal < bVal)
|
|
264
|
+
return s.ascending ? -1 : 1;
|
|
265
|
+
if (aVal > bVal)
|
|
266
|
+
return s.ascending ? 1 : -1;
|
|
267
|
+
}
|
|
268
|
+
return 0;
|
|
269
|
+
});
|
|
247
270
|
}
|
|
248
271
|
}
|
|
249
272
|
else {
|
|
@@ -276,7 +299,8 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
276
299
|
if (isMultiChunk && (userOffset > 0 || returnData.length > limit)) {
|
|
277
300
|
const sliced = returnData.slice(userOffset, userOffset + limit);
|
|
278
301
|
returnData.length = 0;
|
|
279
|
-
|
|
302
|
+
for (const r of sliced)
|
|
303
|
+
returnData.push(r);
|
|
280
304
|
}
|
|
281
305
|
}
|
|
282
306
|
if (returnData.length === 0) {
|
package/package.json
CHANGED