@fachkraftfreund/n8n-nodes-supabase 1.3.12 → 1.3.14

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.
@@ -69,6 +69,12 @@ class Supabase {
69
69
  description: 'Read rows from table',
70
70
  action: 'Read rows',
71
71
  },
72
+ {
73
+ name: 'Count',
74
+ value: 'count',
75
+ description: 'Count rows matching conditions',
76
+ action: 'Count rows',
77
+ },
72
78
  {
73
79
  name: 'Update',
74
80
  value: 'update',
@@ -250,7 +256,7 @@ class Supabase {
250
256
  displayOptions: {
251
257
  show: {
252
258
  resource: ['database'],
253
- operation: ['create', 'read', 'update', 'delete', 'upsert', 'updateByQuery'],
259
+ operation: ['create', 'read', 'update', 'delete', 'upsert', 'updateByQuery', 'count'],
254
260
  },
255
261
  },
256
262
  },
@@ -267,7 +273,7 @@ class Supabase {
267
273
  displayOptions: {
268
274
  show: {
269
275
  resource: ['database'],
270
- operation: ['create', 'read', 'update', 'delete', 'upsert', 'findOrCreate', 'updateByQuery'],
276
+ operation: ['create', 'read', 'update', 'delete', 'upsert', 'findOrCreate', 'updateByQuery', 'count'],
271
277
  },
272
278
  },
273
279
  },
@@ -467,7 +473,7 @@ class Supabase {
467
473
  displayOptions: {
468
474
  show: {
469
475
  resource: ['database'],
470
- operation: ['read', 'delete', 'updateByQuery'],
476
+ operation: ['read', 'delete', 'updateByQuery', 'count'],
471
477
  uiMode: ['simple'],
472
478
  },
473
479
  },
@@ -527,7 +533,7 @@ class Supabase {
527
533
  displayOptions: {
528
534
  show: {
529
535
  resource: ['database'],
530
- operation: ['read', 'delete', 'updateByQuery'],
536
+ operation: ['read', 'delete', 'updateByQuery', 'count'],
531
537
  uiMode: ['advanced'],
532
538
  },
533
539
  },
@@ -542,7 +548,7 @@ class Supabase {
542
548
  displayOptions: {
543
549
  show: {
544
550
  resource: ['database'],
545
- operation: ['read'],
551
+ operation: ['read', 'update', 'updateByQuery'],
546
552
  },
547
553
  },
548
554
  },
@@ -1039,7 +1045,7 @@ class Supabase {
1039
1045
  }
1040
1046
  }
1041
1047
  }
1042
- else if (resource === 'database' && operation === 'read') {
1048
+ else if (resource === 'database' && (operation === 'read' || operation === 'count')) {
1043
1049
  try {
1044
1050
  const operationResults = await database_1.executeDatabaseOperation.call(this, supabase, operation, 0, credentials.host);
1045
1051
  for (const r of operationResults)
@@ -42,6 +42,9 @@ async function executeDatabaseOperation(supabase, operation, itemIndex, hostUrl)
42
42
  case 'updateByQuery':
43
43
  returnData.push(...await handleUpdateByQuery.call(this, supabase, itemIndex, hostUrl));
44
44
  break;
45
+ case 'count':
46
+ returnData.push(...await handleCount.call(this, supabase, itemIndex, hostUrl));
47
+ break;
45
48
  default:
46
49
  throw new Error(`Unknown database operation: ${operation}`);
47
50
  }
@@ -250,6 +253,8 @@ async function handleBulkUpsert(supabase, itemCount) {
250
253
  async function handleBulkUpdate(supabase, itemCount) {
251
254
  const table = this.getNodeParameter('table', 0);
252
255
  const matchColumn = this.getNodeParameter('matchColumn', 0);
256
+ const returnFields = this.getNodeParameter('returnFields', 0, '*');
257
+ const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
253
258
  (0, supabaseClient_1.validateTableName)(table);
254
259
  if (!matchColumn) {
255
260
  throw new Error('Match Column is required for update operations');
@@ -275,7 +280,7 @@ async function handleBulkUpdate(supabase, itemCount) {
275
280
  const { data, error } = await supabase
276
281
  .from(table)
277
282
  .upsert(batch, { onConflict: matchColumn })
278
- .select();
283
+ .select(selectFields);
279
284
  if (error)
280
285
  throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
281
286
  return data;
@@ -720,6 +725,8 @@ async function handleFindOrCreate(supabase, itemIndex) {
720
725
  }
721
726
  async function handleUpdateByQuery(supabase, itemIndex, hostUrl) {
722
727
  const table = this.getNodeParameter('table', itemIndex);
728
+ const returnFields = this.getNodeParameter('returnFields', itemIndex, '*');
729
+ const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
723
730
  (0, supabaseClient_1.validateTableName)(table);
724
731
  const uiMode = this.getNodeParameter('uiMode', itemIndex, 'simple');
725
732
  let updateData;
@@ -760,7 +767,7 @@ async function handleUpdateByQuery(supabase, itemIndex, hostUrl) {
760
767
  const operator = (0, supabaseClient_1.convertFilterOperator)(filter.operator);
761
768
  query = query.filter(filter.column, operator, (0, supabaseClient_1.normalizeFilterValue)(filter.operator, filter.value));
762
769
  }
763
- const { data, error } = await query.select();
770
+ const { data, error } = await query.select(selectFields);
764
771
  if (error)
765
772
  throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
766
773
  return data;
@@ -775,3 +782,24 @@ async function handleUpdateByQuery(supabase, itemIndex, hostUrl) {
775
782
  }
776
783
  return returnData;
777
784
  }
785
+ async function handleCount(supabase, itemIndex, hostUrl) {
786
+ const table = this.getNodeParameter('table', itemIndex);
787
+ (0, supabaseClient_1.validateTableName)(table);
788
+ const filters = getFilters(this, itemIndex);
789
+ const overhead = (0, supabaseClient_1.estimateUrlOverhead)(hostUrl, table, undefined, filters);
790
+ const maxInChars = Math.max(500, supabaseClient_1.MAX_SAFE_URL_LENGTH - overhead);
791
+ const filterChunks = (0, supabaseClient_1.expandChunkedFilters)(filters, maxInChars);
792
+ let totalCount = 0;
793
+ for (const chunkFilters of filterChunks) {
794
+ let query = supabase.from(table).select('*', { count: 'exact', head: true });
795
+ for (const filter of chunkFilters) {
796
+ const operator = (0, supabaseClient_1.convertFilterOperator)(filter.operator);
797
+ query = query.filter(filter.column, operator, (0, supabaseClient_1.normalizeFilterValue)(filter.operator, filter.value));
798
+ }
799
+ const { count, error } = await query;
800
+ if (error)
801
+ throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
802
+ totalCount += count !== null && count !== void 0 ? count : 0;
803
+ }
804
+ return [{ json: { count: totalCount, table } }];
805
+ }
@@ -75,7 +75,7 @@ export interface ISupabaseStorageResponse<T = any> {
75
75
  statusCode?: string;
76
76
  } | null;
77
77
  }
78
- export type DatabaseOperation = 'create' | 'read' | 'update' | 'delete' | 'upsert' | 'createTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'createIndex' | 'dropIndex' | 'customQuery' | 'findOrCreate' | 'updateByQuery';
78
+ export type DatabaseOperation = 'create' | 'read' | 'update' | 'delete' | 'upsert' | 'createTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'createIndex' | 'dropIndex' | 'customQuery' | 'findOrCreate' | 'updateByQuery' | 'count';
79
79
  export type StorageOperation = 'uploadFile' | 'downloadFile' | 'listFiles' | 'deleteFile' | 'moveFile' | 'copyFile' | 'createBucket' | 'deleteBucket' | 'listBuckets' | 'getBucketDetails' | 'getFileInfo' | 'generateSignedUrl';
80
80
  export type SupabaseResource = 'database' | 'storage';
81
81
  export interface ISupabaseNodeParameters {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fachkraftfreund/n8n-nodes-supabase",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "Comprehensive n8n community node for Supabase with database and storage operations",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",