@fachkraftfreund/n8n-nodes-supabase 1.2.0
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.
- package/LICENSE +21 -0
- package/README.md +428 -0
- package/dist/credentials/SupabaseExtendedApi.credentials.d.ts +9 -0
- package/dist/credentials/SupabaseExtendedApi.credentials.js +71 -0
- package/dist/nodes/Supabase/Supabase.node.d.ts +12 -0
- package/dist/nodes/Supabase/Supabase.node.js +750 -0
- package/dist/nodes/Supabase/icons/supabase.svg +15 -0
- package/dist/nodes/Supabase/operations/database/index.d.ts +4 -0
- package/dist/nodes/Supabase/operations/database/index.js +388 -0
- package/dist/nodes/Supabase/operations/storage/index.d.ts +4 -0
- package/dist/nodes/Supabase/operations/storage/index.js +474 -0
- package/dist/nodes/Supabase/types/index.d.ts +107 -0
- package/dist/nodes/Supabase/types/index.js +2 -0
- package/dist/nodes/Supabase/utils/supabaseClient.d.ts +13 -0
- package/dist/nodes/Supabase/utils/supabaseClient.js +138 -0
- package/package.json +92 -0
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Supabase = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const supabaseClient_1 = require("./utils/supabaseClient");
|
|
6
|
+
const database_1 = require("./operations/database");
|
|
7
|
+
const storage_1 = require("./operations/storage");
|
|
8
|
+
class Supabase {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.description = {
|
|
11
|
+
displayName: 'Supabase Extended',
|
|
12
|
+
name: 'supabaseExtended',
|
|
13
|
+
icon: 'file:icons/supabase.svg',
|
|
14
|
+
group: ['database'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
17
|
+
description: 'Interact with Supabase database and storage',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'Supabase Extended',
|
|
20
|
+
},
|
|
21
|
+
inputs: ['main'],
|
|
22
|
+
outputs: ['main'],
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'supabaseExtendedApi',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
properties: [
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Resource',
|
|
32
|
+
name: 'resource',
|
|
33
|
+
type: 'options',
|
|
34
|
+
noDataExpression: true,
|
|
35
|
+
options: [
|
|
36
|
+
{
|
|
37
|
+
name: 'Database',
|
|
38
|
+
value: 'database',
|
|
39
|
+
description: 'Perform database operations (CRUD, schema management)',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Storage',
|
|
43
|
+
value: 'storage',
|
|
44
|
+
description: 'Perform storage operations (files, buckets)',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
default: 'database',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Operation',
|
|
51
|
+
name: 'operation',
|
|
52
|
+
type: 'options',
|
|
53
|
+
noDataExpression: true,
|
|
54
|
+
displayOptions: {
|
|
55
|
+
show: {
|
|
56
|
+
resource: ['database'],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
options: [
|
|
60
|
+
{
|
|
61
|
+
name: 'Create',
|
|
62
|
+
value: 'create',
|
|
63
|
+
description: 'Create a new row',
|
|
64
|
+
action: 'Create a row',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Read',
|
|
68
|
+
value: 'read',
|
|
69
|
+
description: 'Read rows from table',
|
|
70
|
+
action: 'Read rows',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Update',
|
|
74
|
+
value: 'update',
|
|
75
|
+
description: 'Update existing rows',
|
|
76
|
+
action: 'Update rows',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'Delete',
|
|
80
|
+
value: 'delete',
|
|
81
|
+
description: 'Delete rows from table',
|
|
82
|
+
action: 'Delete rows',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Upsert',
|
|
86
|
+
value: 'upsert',
|
|
87
|
+
description: 'Insert or update rows',
|
|
88
|
+
action: 'Upsert rows',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'Create Table',
|
|
92
|
+
value: 'createTable',
|
|
93
|
+
description: 'Create a new table',
|
|
94
|
+
action: 'Create table',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Drop Table',
|
|
98
|
+
value: 'dropTable',
|
|
99
|
+
description: 'Drop an existing table',
|
|
100
|
+
action: 'Drop table',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'Add Column',
|
|
104
|
+
value: 'addColumn',
|
|
105
|
+
description: 'Add a column to existing table',
|
|
106
|
+
action: 'Add column',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'Drop Column',
|
|
110
|
+
value: 'dropColumn',
|
|
111
|
+
description: 'Drop a column from table',
|
|
112
|
+
action: 'Drop column',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'Create Index',
|
|
116
|
+
value: 'createIndex',
|
|
117
|
+
description: 'Create an index on table',
|
|
118
|
+
action: 'Create index',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'Drop Index',
|
|
122
|
+
value: 'dropIndex',
|
|
123
|
+
description: 'Drop an existing index',
|
|
124
|
+
action: 'Drop index',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'Custom Query',
|
|
128
|
+
value: 'customQuery',
|
|
129
|
+
description: 'Execute custom SQL query',
|
|
130
|
+
action: 'Execute custom query',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
default: 'read',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
displayName: 'Operation',
|
|
137
|
+
name: 'operation',
|
|
138
|
+
type: 'options',
|
|
139
|
+
noDataExpression: true,
|
|
140
|
+
displayOptions: {
|
|
141
|
+
show: {
|
|
142
|
+
resource: ['storage'],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
options: [
|
|
146
|
+
{
|
|
147
|
+
name: 'Upload File',
|
|
148
|
+
value: 'uploadFile',
|
|
149
|
+
description: 'Upload a file to storage',
|
|
150
|
+
action: 'Upload file',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'Download File',
|
|
154
|
+
value: 'downloadFile',
|
|
155
|
+
description: 'Download a file from storage',
|
|
156
|
+
action: 'Download file',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'List Files',
|
|
160
|
+
value: 'listFiles',
|
|
161
|
+
description: 'List files in a bucket/folder',
|
|
162
|
+
action: 'List files',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'Delete File',
|
|
166
|
+
value: 'deleteFile',
|
|
167
|
+
description: 'Delete file(s) from storage',
|
|
168
|
+
action: 'Delete file',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'Move File',
|
|
172
|
+
value: 'moveFile',
|
|
173
|
+
description: 'Move a file to different location',
|
|
174
|
+
action: 'Move file',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'Copy File',
|
|
178
|
+
value: 'copyFile',
|
|
179
|
+
description: 'Copy a file to different location',
|
|
180
|
+
action: 'Copy file',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'Create Bucket',
|
|
184
|
+
value: 'createBucket',
|
|
185
|
+
description: 'Create a new storage bucket',
|
|
186
|
+
action: 'Create bucket',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'Delete Bucket',
|
|
190
|
+
value: 'deleteBucket',
|
|
191
|
+
description: 'Delete a storage bucket',
|
|
192
|
+
action: 'Delete bucket',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'List Buckets',
|
|
196
|
+
value: 'listBuckets',
|
|
197
|
+
description: 'List all storage buckets',
|
|
198
|
+
action: 'List buckets',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'Get Bucket Details',
|
|
202
|
+
value: 'getBucketDetails',
|
|
203
|
+
description: 'Get details of a bucket',
|
|
204
|
+
action: 'Get bucket details',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'Get File Info',
|
|
208
|
+
value: 'getFileInfo',
|
|
209
|
+
description: 'Get information about a file',
|
|
210
|
+
action: 'Get file info',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'Generate Signed URL',
|
|
214
|
+
value: 'generateSignedUrl',
|
|
215
|
+
description: 'Generate signed URL for file access',
|
|
216
|
+
action: 'Generate signed URL',
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
default: 'uploadFile',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
displayName: 'UI Mode',
|
|
223
|
+
name: 'uiMode',
|
|
224
|
+
type: 'options',
|
|
225
|
+
options: [
|
|
226
|
+
{
|
|
227
|
+
name: 'Simple',
|
|
228
|
+
value: 'simple',
|
|
229
|
+
description: 'Use form fields and dropdowns',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'Advanced',
|
|
233
|
+
value: 'advanced',
|
|
234
|
+
description: 'Use JSON inputs for more flexibility',
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
default: 'simple',
|
|
238
|
+
displayOptions: {
|
|
239
|
+
show: {
|
|
240
|
+
resource: ['database'],
|
|
241
|
+
operation: ['create', 'read', 'update', 'delete', 'upsert'],
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
displayName: 'Table',
|
|
247
|
+
name: 'table',
|
|
248
|
+
type: 'string',
|
|
249
|
+
required: true,
|
|
250
|
+
default: '',
|
|
251
|
+
placeholder: 'users',
|
|
252
|
+
description: 'Name of the table to operate on',
|
|
253
|
+
displayOptions: {
|
|
254
|
+
show: {
|
|
255
|
+
resource: ['database'],
|
|
256
|
+
operation: ['create', 'read', 'update', 'delete', 'upsert'],
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
displayName: 'Columns',
|
|
262
|
+
name: 'columns',
|
|
263
|
+
type: 'fixedCollection',
|
|
264
|
+
typeOptions: {
|
|
265
|
+
multipleValues: true,
|
|
266
|
+
},
|
|
267
|
+
default: {},
|
|
268
|
+
placeholder: 'Add Column',
|
|
269
|
+
displayOptions: {
|
|
270
|
+
show: {
|
|
271
|
+
resource: ['database'],
|
|
272
|
+
operation: ['create', 'update', 'upsert'],
|
|
273
|
+
uiMode: ['simple'],
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
options: [
|
|
277
|
+
{
|
|
278
|
+
displayName: 'Column',
|
|
279
|
+
name: 'column',
|
|
280
|
+
values: [
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Name',
|
|
283
|
+
name: 'name',
|
|
284
|
+
type: 'string',
|
|
285
|
+
default: '',
|
|
286
|
+
placeholder: 'column_name',
|
|
287
|
+
description: 'Name of the column',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
displayName: 'Value',
|
|
291
|
+
name: 'value',
|
|
292
|
+
type: 'string',
|
|
293
|
+
default: '',
|
|
294
|
+
description: 'Value for the column',
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
displayName: 'JSON Data',
|
|
302
|
+
name: 'jsonData',
|
|
303
|
+
type: 'json',
|
|
304
|
+
default: '{}',
|
|
305
|
+
description: 'JSON object containing the data',
|
|
306
|
+
displayOptions: {
|
|
307
|
+
show: {
|
|
308
|
+
resource: ['database'],
|
|
309
|
+
operation: ['create', 'update', 'upsert'],
|
|
310
|
+
uiMode: ['advanced'],
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
displayName: 'Filters',
|
|
316
|
+
name: 'filters',
|
|
317
|
+
type: 'fixedCollection',
|
|
318
|
+
typeOptions: {
|
|
319
|
+
multipleValues: true,
|
|
320
|
+
},
|
|
321
|
+
default: {},
|
|
322
|
+
placeholder: 'Add Filter',
|
|
323
|
+
displayOptions: {
|
|
324
|
+
show: {
|
|
325
|
+
resource: ['database'],
|
|
326
|
+
operation: ['read', 'update', 'delete'],
|
|
327
|
+
uiMode: ['simple'],
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
options: [
|
|
331
|
+
{
|
|
332
|
+
displayName: 'Filter',
|
|
333
|
+
name: 'filter',
|
|
334
|
+
values: [
|
|
335
|
+
{
|
|
336
|
+
displayName: 'Column',
|
|
337
|
+
name: 'column',
|
|
338
|
+
type: 'string',
|
|
339
|
+
default: '',
|
|
340
|
+
placeholder: 'column_name',
|
|
341
|
+
description: 'Column to filter on',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
displayName: 'Operator',
|
|
345
|
+
name: 'operator',
|
|
346
|
+
type: 'options',
|
|
347
|
+
options: [
|
|
348
|
+
{ name: 'Equals', value: 'eq' },
|
|
349
|
+
{ name: 'Not Equals', value: 'neq' },
|
|
350
|
+
{ name: 'Greater Than', value: 'gt' },
|
|
351
|
+
{ name: 'Greater Than or Equal', value: 'gte' },
|
|
352
|
+
{ name: 'Less Than', value: 'lt' },
|
|
353
|
+
{ name: 'Less Than or Equal', value: 'lte' },
|
|
354
|
+
{ name: 'Like', value: 'like' },
|
|
355
|
+
{ name: 'Case Insensitive Like', value: 'ilike' },
|
|
356
|
+
{ name: 'Is', value: 'is' },
|
|
357
|
+
{ name: 'In', value: 'in' },
|
|
358
|
+
{ name: 'Contains', value: 'cs' },
|
|
359
|
+
{ name: 'Contained By', value: 'cd' },
|
|
360
|
+
],
|
|
361
|
+
default: 'eq',
|
|
362
|
+
description: 'Filter operator',
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
displayName: 'Value',
|
|
366
|
+
name: 'value',
|
|
367
|
+
type: 'string',
|
|
368
|
+
default: '',
|
|
369
|
+
description: 'Value to filter by',
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
displayName: 'Advanced Filters',
|
|
377
|
+
name: 'advancedFilters',
|
|
378
|
+
type: 'json',
|
|
379
|
+
default: '{}',
|
|
380
|
+
description: 'JSON object containing advanced filters',
|
|
381
|
+
displayOptions: {
|
|
382
|
+
show: {
|
|
383
|
+
resource: ['database'],
|
|
384
|
+
operation: ['read', 'update', 'delete'],
|
|
385
|
+
uiMode: ['advanced'],
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
displayName: 'Return Fields',
|
|
391
|
+
name: 'returnFields',
|
|
392
|
+
type: 'string',
|
|
393
|
+
default: '*',
|
|
394
|
+
placeholder: 'id,name,email',
|
|
395
|
+
description: 'Comma-separated list of fields to return (* for all)',
|
|
396
|
+
displayOptions: {
|
|
397
|
+
show: {
|
|
398
|
+
resource: ['database'],
|
|
399
|
+
operation: ['read'],
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
displayName: 'Sort',
|
|
405
|
+
name: 'sort',
|
|
406
|
+
type: 'fixedCollection',
|
|
407
|
+
typeOptions: {
|
|
408
|
+
multipleValues: true,
|
|
409
|
+
},
|
|
410
|
+
default: {},
|
|
411
|
+
placeholder: 'Add Sort Field',
|
|
412
|
+
displayOptions: {
|
|
413
|
+
show: {
|
|
414
|
+
resource: ['database'],
|
|
415
|
+
operation: ['read'],
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
options: [
|
|
419
|
+
{
|
|
420
|
+
displayName: 'Sort Field',
|
|
421
|
+
name: 'sortField',
|
|
422
|
+
values: [
|
|
423
|
+
{
|
|
424
|
+
displayName: 'Column',
|
|
425
|
+
name: 'column',
|
|
426
|
+
type: 'string',
|
|
427
|
+
default: '',
|
|
428
|
+
placeholder: 'column_name',
|
|
429
|
+
description: 'Column to sort by',
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
displayName: 'Ascending',
|
|
433
|
+
name: 'ascending',
|
|
434
|
+
type: 'boolean',
|
|
435
|
+
default: true,
|
|
436
|
+
description: 'Whether to sort in ascending order',
|
|
437
|
+
},
|
|
438
|
+
],
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
displayName: 'Limit',
|
|
444
|
+
name: 'limit',
|
|
445
|
+
type: 'number',
|
|
446
|
+
default: 100,
|
|
447
|
+
description: 'Maximum number of rows to return',
|
|
448
|
+
displayOptions: {
|
|
449
|
+
show: {
|
|
450
|
+
resource: ['database'],
|
|
451
|
+
operation: ['read'],
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
displayName: 'Offset',
|
|
457
|
+
name: 'offset',
|
|
458
|
+
type: 'number',
|
|
459
|
+
default: 0,
|
|
460
|
+
description: 'Number of rows to skip',
|
|
461
|
+
displayOptions: {
|
|
462
|
+
show: {
|
|
463
|
+
resource: ['database'],
|
|
464
|
+
operation: ['read'],
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
displayName: 'Bucket',
|
|
470
|
+
name: 'bucket',
|
|
471
|
+
type: 'options',
|
|
472
|
+
typeOptions: {
|
|
473
|
+
loadOptionsMethod: 'getBuckets',
|
|
474
|
+
},
|
|
475
|
+
required: true,
|
|
476
|
+
default: '',
|
|
477
|
+
placeholder: 'Select a bucket or enter manually',
|
|
478
|
+
description: 'Name of the storage bucket',
|
|
479
|
+
displayOptions: {
|
|
480
|
+
show: {
|
|
481
|
+
resource: ['storage'],
|
|
482
|
+
operation: ['uploadFile', 'downloadFile', 'listFiles', 'deleteFile', 'moveFile', 'copyFile', 'getFileInfo', 'generateSignedUrl'],
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
displayName: 'Input Type',
|
|
488
|
+
name: 'inputType',
|
|
489
|
+
type: 'options',
|
|
490
|
+
options: [
|
|
491
|
+
{
|
|
492
|
+
name: 'Binary Data',
|
|
493
|
+
value: 'binary',
|
|
494
|
+
description: 'File from previous node',
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
name: 'URL',
|
|
498
|
+
value: 'url',
|
|
499
|
+
description: 'Download from URL',
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
name: 'Text Content',
|
|
503
|
+
value: 'text',
|
|
504
|
+
description: 'Text content as file',
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
default: 'binary',
|
|
508
|
+
displayOptions: {
|
|
509
|
+
show: {
|
|
510
|
+
resource: ['storage'],
|
|
511
|
+
operation: ['uploadFile'],
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
displayName: 'File Name',
|
|
517
|
+
name: 'fileName',
|
|
518
|
+
type: 'string',
|
|
519
|
+
required: true,
|
|
520
|
+
default: '',
|
|
521
|
+
placeholder: 'document.pdf',
|
|
522
|
+
description: 'Name of the file to upload',
|
|
523
|
+
displayOptions: {
|
|
524
|
+
show: {
|
|
525
|
+
resource: ['storage'],
|
|
526
|
+
operation: ['uploadFile'],
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
displayName: 'Binary Property Name',
|
|
532
|
+
name: 'binaryPropertyName',
|
|
533
|
+
type: 'string',
|
|
534
|
+
default: 'data',
|
|
535
|
+
description: 'Name of the binary property containing the file data',
|
|
536
|
+
displayOptions: {
|
|
537
|
+
show: {
|
|
538
|
+
resource: ['storage'],
|
|
539
|
+
operation: ['uploadFile'],
|
|
540
|
+
inputType: ['binary'],
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
displayName: 'File URL',
|
|
546
|
+
name: 'fileUrl',
|
|
547
|
+
type: 'string',
|
|
548
|
+
default: '',
|
|
549
|
+
placeholder: 'https://example.com/file.pdf',
|
|
550
|
+
description: 'URL of the file to download and upload',
|
|
551
|
+
displayOptions: {
|
|
552
|
+
show: {
|
|
553
|
+
resource: ['storage'],
|
|
554
|
+
operation: ['uploadFile'],
|
|
555
|
+
inputType: ['url'],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
displayName: 'Text Content',
|
|
561
|
+
name: 'textContent',
|
|
562
|
+
type: 'string',
|
|
563
|
+
typeOptions: {
|
|
564
|
+
rows: 4,
|
|
565
|
+
},
|
|
566
|
+
default: '',
|
|
567
|
+
description: 'Text content to save as file',
|
|
568
|
+
displayOptions: {
|
|
569
|
+
show: {
|
|
570
|
+
resource: ['storage'],
|
|
571
|
+
operation: ['uploadFile'],
|
|
572
|
+
inputType: ['text'],
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
displayName: 'File Path',
|
|
578
|
+
name: 'filePath',
|
|
579
|
+
type: 'string',
|
|
580
|
+
required: true,
|
|
581
|
+
default: '',
|
|
582
|
+
placeholder: 'folder/document.pdf',
|
|
583
|
+
description: 'Path of the file in storage',
|
|
584
|
+
displayOptions: {
|
|
585
|
+
show: {
|
|
586
|
+
resource: ['storage'],
|
|
587
|
+
operation: ['downloadFile', 'getFileInfo', 'generateSignedUrl'],
|
|
588
|
+
},
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
displayName: 'Output Format',
|
|
593
|
+
name: 'outputFormat',
|
|
594
|
+
type: 'options',
|
|
595
|
+
options: [
|
|
596
|
+
{
|
|
597
|
+
name: 'Binary Data',
|
|
598
|
+
value: 'binary',
|
|
599
|
+
description: 'Return as binary data for further processing',
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
name: 'Text Content',
|
|
603
|
+
value: 'text',
|
|
604
|
+
description: 'Return as text content',
|
|
605
|
+
},
|
|
606
|
+
],
|
|
607
|
+
default: 'binary',
|
|
608
|
+
displayOptions: {
|
|
609
|
+
show: {
|
|
610
|
+
resource: ['storage'],
|
|
611
|
+
operation: ['downloadFile'],
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
displayName: 'Bucket Name',
|
|
617
|
+
name: 'bucketName',
|
|
618
|
+
type: 'string',
|
|
619
|
+
required: true,
|
|
620
|
+
default: '',
|
|
621
|
+
placeholder: 'my-new-bucket',
|
|
622
|
+
description: 'Name of the bucket',
|
|
623
|
+
displayOptions: {
|
|
624
|
+
show: {
|
|
625
|
+
resource: ['storage'],
|
|
626
|
+
operation: ['createBucket', 'deleteBucket', 'getBucketDetails'],
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
displayName: 'Public Bucket',
|
|
632
|
+
name: 'isPublic',
|
|
633
|
+
type: 'boolean',
|
|
634
|
+
default: false,
|
|
635
|
+
description: 'Whether the bucket should be publicly accessible',
|
|
636
|
+
displayOptions: {
|
|
637
|
+
show: {
|
|
638
|
+
resource: ['storage'],
|
|
639
|
+
operation: ['createBucket'],
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
],
|
|
644
|
+
};
|
|
645
|
+
this.methods = {
|
|
646
|
+
loadOptions: {
|
|
647
|
+
async getBuckets() {
|
|
648
|
+
const credentials = await this.getCredentials('supabaseExtendedApi');
|
|
649
|
+
try {
|
|
650
|
+
(0, supabaseClient_1.validateCredentials)(credentials);
|
|
651
|
+
const supabase = (0, supabaseClient_1.createSupabaseClient)(credentials);
|
|
652
|
+
const { data, error } = await supabase.storage.listBuckets();
|
|
653
|
+
if (error) {
|
|
654
|
+
throw new Error(`Failed to fetch buckets: ${error.message}`);
|
|
655
|
+
}
|
|
656
|
+
if (!Array.isArray(data)) {
|
|
657
|
+
return [
|
|
658
|
+
{
|
|
659
|
+
name: 'No buckets found',
|
|
660
|
+
value: '',
|
|
661
|
+
description: 'Create a bucket first or check your permissions',
|
|
662
|
+
},
|
|
663
|
+
];
|
|
664
|
+
}
|
|
665
|
+
const options = data.map((bucket) => ({
|
|
666
|
+
name: `${bucket.name}${bucket.public ? ' (Public)' : ' (Private)'}`,
|
|
667
|
+
value: bucket.name,
|
|
668
|
+
description: `Created: ${bucket.created_at ? new Date(bucket.created_at).toLocaleDateString() : 'Unknown'}`,
|
|
669
|
+
}));
|
|
670
|
+
options.sort((a, b) => a.name.localeCompare(b.name));
|
|
671
|
+
return options;
|
|
672
|
+
}
|
|
673
|
+
catch (error) {
|
|
674
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
675
|
+
return [
|
|
676
|
+
{
|
|
677
|
+
name: `Error: ${errorMessage}`,
|
|
678
|
+
value: '',
|
|
679
|
+
description: 'Failed to load buckets. Please check your credentials and try again.',
|
|
680
|
+
},
|
|
681
|
+
];
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
async getTables() {
|
|
685
|
+
return [
|
|
686
|
+
{
|
|
687
|
+
name: 'Enter table name manually',
|
|
688
|
+
value: '',
|
|
689
|
+
description: 'Please enter the table name manually in the field above',
|
|
690
|
+
},
|
|
691
|
+
];
|
|
692
|
+
},
|
|
693
|
+
async getColumns() {
|
|
694
|
+
return [
|
|
695
|
+
{
|
|
696
|
+
name: 'Enter column names manually',
|
|
697
|
+
value: '',
|
|
698
|
+
description: 'Please enter column names manually in the fields above',
|
|
699
|
+
},
|
|
700
|
+
];
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
async execute() {
|
|
706
|
+
const items = this.getInputData();
|
|
707
|
+
const returnData = [];
|
|
708
|
+
const credentials = await this.getCredentials('supabaseExtendedApi');
|
|
709
|
+
try {
|
|
710
|
+
(0, supabaseClient_1.validateCredentials)(credentials);
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
714
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid credentials: ${errorMessage}`);
|
|
715
|
+
}
|
|
716
|
+
const supabase = (0, supabaseClient_1.createSupabaseClient)(credentials);
|
|
717
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
718
|
+
try {
|
|
719
|
+
const resource = this.getNodeParameter('resource', itemIndex);
|
|
720
|
+
const operation = this.getNodeParameter('operation', itemIndex);
|
|
721
|
+
let operationResults = [];
|
|
722
|
+
if (resource === 'database') {
|
|
723
|
+
operationResults = await database_1.executeDatabaseOperation.call(this, supabase, operation, itemIndex);
|
|
724
|
+
}
|
|
725
|
+
else if (resource === 'storage') {
|
|
726
|
+
operationResults = await storage_1.executeStorageOperation.call(this, supabase, operation, itemIndex);
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`);
|
|
730
|
+
}
|
|
731
|
+
returnData.push(...operationResults);
|
|
732
|
+
}
|
|
733
|
+
catch (error) {
|
|
734
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
735
|
+
if (this.continueOnFail()) {
|
|
736
|
+
returnData.push({
|
|
737
|
+
json: {
|
|
738
|
+
error: errorMessage,
|
|
739
|
+
itemIndex,
|
|
740
|
+
},
|
|
741
|
+
});
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage, { itemIndex });
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return [returnData];
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
exports.Supabase = Supabase;
|