@fachkraftfreund/n8n-nodes-supabase 1.3.11 → 1.3.13

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.
@@ -542,7 +542,7 @@ class Supabase {
542
542
  displayOptions: {
543
543
  show: {
544
544
  resource: ['database'],
545
- operation: ['read'],
545
+ operation: ['read', 'update', 'updateByQuery'],
546
546
  },
547
547
  },
548
548
  },
@@ -107,17 +107,18 @@ function parseFilters(context, itemIndex) {
107
107
  throw new Error('Invalid advanced filters JSON');
108
108
  }
109
109
  }
110
- const BATCH_SIZE = 1000;
110
+ const DEFAULT_BATCH_SIZE = 1000;
111
111
  async function* fetchBatches(supabase, table, selectFields, filters, sort, hostUrl, returnAll, limit, joins) {
112
112
  const overhead = (0, supabaseClient_2.estimateUrlOverhead)(hostUrl, table, selectFields, filters, sort);
113
113
  const maxInChars = Math.max(500, supabaseClient_2.MAX_SAFE_URL_LENGTH - overhead);
114
114
  const maxItems = (0, supabaseClient_2.computeMaxIdsPerChunk)(selectFields);
115
115
  const filterChunks = (0, supabaseClient_2.expandChunkedFilters)(filters, maxInChars, maxItems);
116
+ const BATCH_SIZE = (0, supabaseClient_2.computeBatchSize)(selectFields);
116
117
  const hasIdColumn = selectFields === '*' || selectFields.split(',').some((f) => f.trim() === 'id');
117
118
  let totalYielded = 0;
118
119
  const maxRows = returnAll ? Infinity : limit;
119
120
  const startTime = Date.now();
120
- console.log(`[Supabase CSV] starting export table=${table} returnAll=${returnAll} chunks=${filterChunks.length} keyset=${hasIdColumn}`);
121
+ console.log(`[Supabase CSV] starting export table=${table} returnAll=${returnAll} chunks=${filterChunks.length} keyset=${hasIdColumn} batchSize=${BATCH_SIZE}`);
121
122
  for (let ci = 0; ci < filterChunks.length; ci++) {
122
123
  const chunkFilters = filterChunks[ci];
123
124
  if (totalYielded >= maxRows)
@@ -250,6 +250,8 @@ async function handleBulkUpsert(supabase, itemCount) {
250
250
  async function handleBulkUpdate(supabase, itemCount) {
251
251
  const table = this.getNodeParameter('table', 0);
252
252
  const matchColumn = this.getNodeParameter('matchColumn', 0);
253
+ const returnFields = this.getNodeParameter('returnFields', 0, '*');
254
+ const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
253
255
  (0, supabaseClient_1.validateTableName)(table);
254
256
  if (!matchColumn) {
255
257
  throw new Error('Match Column is required for update operations');
@@ -275,7 +277,7 @@ async function handleBulkUpdate(supabase, itemCount) {
275
277
  const { data, error } = await supabase
276
278
  .from(table)
277
279
  .upsert(batch, { onConflict: matchColumn })
278
- .select();
280
+ .select(selectFields);
279
281
  if (error)
280
282
  throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
281
283
  return data;
@@ -369,10 +371,10 @@ async function handleRead(supabase, itemIndex, hostUrl) {
369
371
  const maxInChars = Math.max(500, supabaseClient_1.MAX_SAFE_URL_LENGTH - overhead);
370
372
  const maxItems = (0, supabaseClient_1.computeMaxIdsPerChunk)(selectWithJoins);
371
373
  const filterChunks = (0, supabaseClient_1.expandChunkedFilters)(filters, maxInChars, maxItems);
372
- console.log(`[Supabase READ] item=${itemIndex} table=${table} returnAll=${returnAll} chunks=${filterChunks.length} maxItems=${maxItems} maxInChars=${maxInChars}`);
374
+ const batchSize = (0, supabaseClient_1.computeBatchSize)(selectWithJoins);
375
+ console.log(`[Supabase READ] item=${itemIndex} table=${table} returnAll=${returnAll} chunks=${filterChunks.length} maxItems=${maxItems} maxInChars=${maxInChars} batchSize=${batchSize}`);
373
376
  const returnData = [];
374
377
  if (returnAll) {
375
- const batchSize = 1000;
376
378
  const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
377
379
  const hasIdColumn = selectFields === '*' || selectFields.split(',').some(f => f.trim() === 'id');
378
380
  for (let ci = 0; ci < filterChunks.length; ci++) {
@@ -720,6 +722,8 @@ async function handleFindOrCreate(supabase, itemIndex) {
720
722
  }
721
723
  async function handleUpdateByQuery(supabase, itemIndex, hostUrl) {
722
724
  const table = this.getNodeParameter('table', itemIndex);
725
+ const returnFields = this.getNodeParameter('returnFields', itemIndex, '*');
726
+ const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
723
727
  (0, supabaseClient_1.validateTableName)(table);
724
728
  const uiMode = this.getNodeParameter('uiMode', itemIndex, 'simple');
725
729
  let updateData;
@@ -760,7 +764,7 @@ async function handleUpdateByQuery(supabase, itemIndex, hostUrl) {
760
764
  const operator = (0, supabaseClient_1.convertFilterOperator)(filter.operator);
761
765
  query = query.filter(filter.column, operator, (0, supabaseClient_1.normalizeFilterValue)(filter.operator, filter.value));
762
766
  }
763
- const { data, error } = await query.select();
767
+ const { data, error } = await query.select(selectFields);
764
768
  if (error)
765
769
  throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
766
770
  return data;
@@ -14,6 +14,7 @@ export declare function convertFilterOperator(operator: string): string;
14
14
  export declare function normalizeFilterValue(operator: string, value: string | number | boolean | null | unknown[]): string | number | boolean | null;
15
15
  export declare const MAX_SAFE_URL_LENGTH = 7500;
16
16
  export declare function computeMaxIdsPerChunk(selectFields?: string): number;
17
+ export declare function computeBatchSize(selectFields?: string): number;
17
18
  export declare function estimateUrlOverhead(hostUrl: string, table: string, selectFields?: string, filters?: IRowFilter[], sort?: IRowSort[]): number;
18
19
  export declare function chunkInFilterValues(values: unknown[], maxChars: number, maxItems?: number): unknown[][];
19
20
  export declare function expandChunkedFilters(filters: IRowFilter[], maxInChars?: number, maxItems?: number): IRowFilter[][];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expandChunkedFilters = exports.chunkInFilterValues = exports.estimateUrlOverhead = exports.computeMaxIdsPerChunk = exports.MAX_SAFE_URL_LENGTH = exports.normalizeFilterValue = exports.convertFilterOperator = exports.validateColumnName = exports.validateTableName = exports.sanitizeColumnName = exports.isNetworkError = exports.isAuthError = exports.formatSupabaseError = exports.getDatabaseUrl = exports.getStorageUrl = exports.validateCredentials = exports.createSupabaseClient = void 0;
3
+ exports.expandChunkedFilters = exports.chunkInFilterValues = exports.estimateUrlOverhead = exports.computeBatchSize = exports.computeMaxIdsPerChunk = exports.MAX_SAFE_URL_LENGTH = exports.normalizeFilterValue = exports.convertFilterOperator = exports.validateColumnName = exports.validateTableName = exports.sanitizeColumnName = exports.isNetworkError = exports.isAuthError = exports.formatSupabaseError = exports.getDatabaseUrl = exports.getStorageUrl = exports.validateCredentials = exports.createSupabaseClient = void 0;
4
4
  const supabase_js_1 = require("@supabase/supabase-js");
5
5
  function createSupabaseClient(credentials) {
6
6
  const client = (0, supabase_js_1.createClient)(credentials.host, credentials.serviceKey, {
@@ -171,6 +171,16 @@ function computeMaxIdsPerChunk(selectFields) {
171
171
  return Math.max(100, Math.floor(BASE_LIMIT / (1 + joinCount * 1.5)));
172
172
  }
173
173
  exports.computeMaxIdsPerChunk = computeMaxIdsPerChunk;
174
+ function computeBatchSize(selectFields) {
175
+ const BASE = 2000;
176
+ if (!selectFields || selectFields === '*')
177
+ return BASE;
178
+ const joinCount = (selectFields.match(/\(/g) || []).length;
179
+ if (joinCount === 0)
180
+ return BASE;
181
+ return Math.max(50, Math.floor(BASE / (1 + joinCount * 0.5)));
182
+ }
183
+ exports.computeBatchSize = computeBatchSize;
174
184
  function estimateUrlOverhead(hostUrl, table, selectFields, filters, sort) {
175
185
  let overhead = hostUrl.length + '/rest/v1/'.length + table.length + 1;
176
186
  if (selectFields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fachkraftfreund/n8n-nodes-supabase",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "Comprehensive n8n community node for Supabase with database and storage operations",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",