@fachkraftfreund/n8n-nodes-supabase 1.2.19 → 1.2.21
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;
|
|
@@ -208,44 +211,71 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
208
211
|
const returnData = [];
|
|
209
212
|
if (returnAll) {
|
|
210
213
|
const batchSize = 1000;
|
|
214
|
+
const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
|
|
215
|
+
const hasIdColumn = selectFields === '*' || selectFields.split(',').some(f => f.trim() === 'id');
|
|
211
216
|
for (let ci = 0; ci < filterChunks.length; ci++) {
|
|
212
217
|
const chunkFilters = filterChunks[ci];
|
|
213
218
|
const inFilter = chunkFilters.find(f => f.operator === 'in');
|
|
214
219
|
const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
|
|
215
|
-
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) - starting...`);
|
|
220
|
+
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) keyset=${hasIdColumn} - starting...`);
|
|
216
221
|
const chunkStart = Date.now();
|
|
217
|
-
let lastId = null;
|
|
218
|
-
let hasMore = true;
|
|
219
222
|
let batchCount = 0;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
223
|
+
let hasMore = true;
|
|
224
|
+
if (hasIdColumn) {
|
|
225
|
+
let lastId = null;
|
|
226
|
+
while (hasMore) {
|
|
227
|
+
let query = buildReadQuery(supabase, table, returnFields, chunkFilters, []);
|
|
228
|
+
if (lastId !== null) {
|
|
229
|
+
query = query.gt('id', lastId);
|
|
230
|
+
}
|
|
231
|
+
query = query.order('id', { ascending: true }).limit(batchSize);
|
|
232
|
+
const { data, error } = await query;
|
|
233
|
+
if (error) {
|
|
234
|
+
console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
|
|
235
|
+
throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
|
|
236
|
+
}
|
|
237
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
238
|
+
for (const row of data)
|
|
239
|
+
returnData.push({ json: row });
|
|
240
|
+
lastId = data[data.length - 1].id;
|
|
241
|
+
hasMore = data.length === batchSize;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
hasMore = false;
|
|
245
|
+
}
|
|
246
|
+
batchCount++;
|
|
247
|
+
if (batchCount % 50 === 0) {
|
|
248
|
+
console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
|
|
234
249
|
}
|
|
235
|
-
lastId = data[data.length - 1].id;
|
|
236
|
-
hasMore = data.length === batchSize;
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
hasMore = false;
|
|
240
250
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
let batchOffset = 0;
|
|
254
|
+
while (hasMore) {
|
|
255
|
+
const query = buildReadQuery(supabase, table, returnFields, chunkFilters, sort);
|
|
256
|
+
const { data, error } = await query.range(batchOffset, batchOffset + batchSize - 1);
|
|
257
|
+
if (error) {
|
|
258
|
+
console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
|
|
259
|
+
throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
|
|
260
|
+
}
|
|
261
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
262
|
+
for (const row of data)
|
|
263
|
+
returnData.push({ json: row });
|
|
264
|
+
hasMore = data.length === batchSize;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
hasMore = false;
|
|
268
|
+
}
|
|
269
|
+
batchOffset += batchSize;
|
|
270
|
+
batchCount++;
|
|
271
|
+
if (batchCount % 50 === 0) {
|
|
272
|
+
console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
|
|
273
|
+
}
|
|
244
274
|
}
|
|
245
275
|
}
|
|
246
276
|
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} done in ${Date.now() - chunkStart}ms — ${batchCount} batches, ${returnData.length} total rows`);
|
|
247
277
|
}
|
|
248
|
-
if (sort.length > 0) {
|
|
278
|
+
if (hasIdColumn && sort.length > 0) {
|
|
249
279
|
returnData.sort((a, b) => {
|
|
250
280
|
var _a, _b;
|
|
251
281
|
for (const s of sort) {
|
|
@@ -296,7 +326,8 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
296
326
|
if (isMultiChunk && (userOffset > 0 || returnData.length > limit)) {
|
|
297
327
|
const sliced = returnData.slice(userOffset, userOffset + limit);
|
|
298
328
|
returnData.length = 0;
|
|
299
|
-
|
|
329
|
+
for (const r of sliced)
|
|
330
|
+
returnData.push(r);
|
|
300
331
|
}
|
|
301
332
|
}
|
|
302
333
|
if (returnData.length === 0) {
|
package/package.json
CHANGED