@fachkraftfreund/n8n-nodes-supabase 1.3.13 → 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
|
},
|
|
@@ -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
|
}
|
|
@@ -779,3 +782,24 @@ async function handleUpdateByQuery(supabase, itemIndex, hostUrl) {
|
|
|
779
782
|
}
|
|
780
783
|
return returnData;
|
|
781
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