@fachkraftfreund/n8n-nodes-supabase 1.3.8 → 1.3.9

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.
@@ -62,7 +62,12 @@ function deduplicateByConflictKeys(rows, conflictColumns) {
62
62
  const seen = new Map();
63
63
  for (let i = 0; i < rows.length; i++) {
64
64
  const row = rows[i];
65
- const compositeKey = keys.map((k) => { var _a; return String((_a = row[k]) !== null && _a !== void 0 ? _a : ''); }).join('\0');
65
+ const compositeKey = keys.map((k) => {
66
+ const val = row[k];
67
+ if (val === null || val === undefined)
68
+ return '';
69
+ return String(val).trim().toLowerCase();
70
+ }).join('\0');
66
71
  seen.set(compositeKey, i);
67
72
  }
68
73
  return Array.from(seen.values()).sort((a, b) => a - b).map((i) => rows[i]);
@@ -206,7 +211,6 @@ async function handleBulkUpsert(supabase, itemCount) {
206
211
  const deduplicate = this.getNodeParameter('deduplicateByConflict', 0, false);
207
212
  (0, supabaseClient_1.validateTableName)(table);
208
213
  let rows = collectRowData(this, itemCount);
209
- console.log(`[Supabase UPSERT ${table}] rows=${rows.length}, onConflict="${onConflict}", deduplicate=${deduplicate}`);
210
214
  const options = {};
211
215
  if (onConflict)
212
216
  options.onConflict = onConflict;
@@ -216,28 +220,16 @@ async function handleBulkUpsert(supabase, itemCount) {
216
220
  console.log(`[Supabase UPSERT ${table}] dedup by "${onConflict}": ${before} → ${rows.length} rows`);
217
221
  }
218
222
  const returnData = [];
219
- const duplicateError = 'cannot affect row a second time';
220
223
  for (let offset = 0; offset < rows.length; offset += BULK_BATCH_SIZE) {
221
- let batch = rows.slice(offset, offset + BULK_BATCH_SIZE);
224
+ const batch = rows.slice(offset, offset + BULK_BATCH_SIZE);
222
225
  const batchLabel = `UPSERT ${table} batch ${Math.floor(offset / BULK_BATCH_SIZE) + 1}`;
223
226
  const data = await withRetry(async () => {
224
227
  const { data, error } = await supabase
225
228
  .from(table)
226
229
  .upsert(batch, options)
227
230
  .select();
228
- if (error) {
229
- const msg = (0, supabaseClient_1.formatSupabaseError)(error);
230
- if (msg.toLowerCase().includes(duplicateError) && onConflict) {
231
- const before = batch.length;
232
- batch = deduplicateByConflictKeys(batch, onConflict);
233
- console.log(`[Supabase ${batchLabel}] duplicate-row error caught, dedup fallback: ${before} → ${batch.length} rows`);
234
- const retry = await supabase.from(table).upsert(batch, options).select();
235
- if (retry.error)
236
- throw new Error((0, supabaseClient_1.formatSupabaseError)(retry.error));
237
- return retry.data;
238
- }
239
- throw new Error(msg);
240
- }
231
+ if (error)
232
+ throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
241
233
  return data;
242
234
  }, batchLabel);
243
235
  if (Array.isArray(data)) {
@@ -258,7 +250,6 @@ async function handleBulkUpdate(supabase, itemCount) {
258
250
  }
259
251
  const deduplicate = this.getNodeParameter('deduplicateByConflict', 0, false);
260
252
  let rows = collectRowData(this, itemCount);
261
- console.log(`[Supabase UPDATE ${table}] rows=${rows.length}, matchColumn="${matchColumn}", deduplicate=${deduplicate}`);
262
253
  for (let i = 0; i < rows.length; i++) {
263
254
  const row = rows[i];
264
255
  if (!row || row[matchColumn] === undefined) {
@@ -271,28 +262,16 @@ async function handleBulkUpdate(supabase, itemCount) {
271
262
  console.log(`[Supabase UPDATE ${table}] dedup by "${matchColumn}": ${before} → ${rows.length} rows`);
272
263
  }
273
264
  const returnData = [];
274
- const duplicateError = 'cannot affect row a second time';
275
265
  for (let offset = 0; offset < rows.length; offset += BULK_BATCH_SIZE) {
276
- let batch = rows.slice(offset, offset + BULK_BATCH_SIZE);
266
+ const batch = rows.slice(offset, offset + BULK_BATCH_SIZE);
277
267
  const batchLabel = `UPDATE ${table} batch ${Math.floor(offset / BULK_BATCH_SIZE) + 1}`;
278
268
  const data = await withRetry(async () => {
279
269
  const { data, error } = await supabase
280
270
  .from(table)
281
271
  .upsert(batch, { onConflict: matchColumn })
282
272
  .select();
283
- if (error) {
284
- const msg = (0, supabaseClient_1.formatSupabaseError)(error);
285
- if (msg.toLowerCase().includes(duplicateError)) {
286
- const before = batch.length;
287
- batch = deduplicateByConflictKeys(batch, matchColumn);
288
- console.log(`[Supabase ${batchLabel}] duplicate-row error caught, dedup fallback: ${before} → ${batch.length} rows`);
289
- const retry = await supabase.from(table).upsert(batch, { onConflict: matchColumn }).select();
290
- if (retry.error)
291
- throw new Error((0, supabaseClient_1.formatSupabaseError)(retry.error));
292
- return retry.data;
293
- }
294
- throw new Error(msg);
295
- }
273
+ if (error)
274
+ throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
296
275
  return data;
297
276
  }, batchLabel);
298
277
  if (Array.isArray(data)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fachkraftfreund/n8n-nodes-supabase",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "Comprehensive n8n community node for Supabase with database and storage operations",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",