n8n-nodes-nextcloud-ext 1.0.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 +357 -0
- package/dist/credentials/NextCloudApi.credentials.d.ts +9 -0
- package/dist/credentials/NextCloudApi.credentials.js +57 -0
- package/dist/credentials/NextCloudApi.credentials.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/NextCloud/NextCloud.node.d.ts +10 -0
- package/dist/nodes/NextCloud/NextCloud.node.js +601 -0
- package/dist/nodes/NextCloud/NextCloud.node.js.map +1 -0
- package/dist/nodes/NextCloud/nextcloud.svg +13 -0
- package/dist/nodes/NextCloudSpreadsheet/NextCloudSpreadsheet.node.d.ts +12 -0
- package/dist/nodes/NextCloudSpreadsheet/NextCloudSpreadsheet.node.js +820 -0
- package/dist/nodes/NextCloudSpreadsheet/NextCloudSpreadsheet.node.js.map +1 -0
- package/dist/nodes/NextCloudSpreadsheet/nextcloud.svg +13 -0
- package/dist/nodes/shared/GenericFunctions.d.ts +55 -0
- package/dist/nodes/shared/GenericFunctions.js +523 -0
- package/dist/nodes/shared/GenericFunctions.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,820 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NextCloudSpreadsheet = void 0;
|
|
37
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
38
|
+
const GenericFunctions_1 = require("../shared/GenericFunctions");
|
|
39
|
+
const xlsx = __importStar(require("xlsx"));
|
|
40
|
+
class NextCloudSpreadsheet {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.description = {
|
|
43
|
+
displayName: 'Nextcloud Spreadsheet',
|
|
44
|
+
name: 'nextCloudSpreadsheet',
|
|
45
|
+
icon: 'file:nextcloud.svg',
|
|
46
|
+
group: ['transform'],
|
|
47
|
+
version: 1,
|
|
48
|
+
subtitle: '={{$parameter["operation"] + " · " + $parameter["resource"]}}',
|
|
49
|
+
description: 'Read and write spreadsheet files (.xlsx, .ods, .csv) stored on Nextcloud — includes named Excel table support',
|
|
50
|
+
defaults: {
|
|
51
|
+
name: 'Nextcloud Spreadsheet',
|
|
52
|
+
},
|
|
53
|
+
inputs: ['main'],
|
|
54
|
+
outputs: ['main'],
|
|
55
|
+
credentials: [
|
|
56
|
+
{
|
|
57
|
+
name: 'nextCloudApi',
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
properties: [
|
|
62
|
+
// ==================================================================
|
|
63
|
+
// Resource
|
|
64
|
+
// ==================================================================
|
|
65
|
+
{
|
|
66
|
+
displayName: 'Resource',
|
|
67
|
+
name: 'resource',
|
|
68
|
+
type: 'options',
|
|
69
|
+
noDataExpression: true,
|
|
70
|
+
options: [
|
|
71
|
+
{
|
|
72
|
+
name: 'Sheet',
|
|
73
|
+
value: 'sheet',
|
|
74
|
+
description: 'Work with worksheet data — first row is treated as column headers',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Table',
|
|
78
|
+
value: 'table',
|
|
79
|
+
description: 'Work with a named Excel table (Insert → Table in Excel)',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Workbook',
|
|
83
|
+
value: 'workbook',
|
|
84
|
+
description: 'Inspect the workbook structure (sheets, tables)',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
default: 'sheet',
|
|
88
|
+
},
|
|
89
|
+
// ==================================================================
|
|
90
|
+
// SHEET operations
|
|
91
|
+
// ==================================================================
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Operation',
|
|
94
|
+
name: 'operation',
|
|
95
|
+
type: 'options',
|
|
96
|
+
noDataExpression: true,
|
|
97
|
+
displayOptions: { show: { resource: ['sheet'] } },
|
|
98
|
+
options: [
|
|
99
|
+
{
|
|
100
|
+
name: 'Append Row',
|
|
101
|
+
value: 'appendRow',
|
|
102
|
+
description: 'Add a new row at the end of the sheet',
|
|
103
|
+
action: 'Append a row to a sheet',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'Clear',
|
|
107
|
+
value: 'clear',
|
|
108
|
+
description: 'Delete all data rows (the header row is kept)',
|
|
109
|
+
action: 'Clear all data rows from a sheet',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Delete Row',
|
|
113
|
+
value: 'deleteRow',
|
|
114
|
+
description: 'Delete a specific data row by number',
|
|
115
|
+
action: 'Delete a row from a sheet',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'Get Columns',
|
|
119
|
+
value: 'getColumns',
|
|
120
|
+
description: 'Return the list of column headers (first row)',
|
|
121
|
+
action: 'Get column headers from a sheet',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'Get Rows',
|
|
125
|
+
value: 'getRows',
|
|
126
|
+
description: 'Return all rows as n8n items',
|
|
127
|
+
action: 'Get all rows from a sheet',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'Update Row',
|
|
131
|
+
value: 'updateRow',
|
|
132
|
+
description: 'Update an existing row by its row number',
|
|
133
|
+
action: 'Update a row in a sheet',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
default: 'getRows',
|
|
137
|
+
},
|
|
138
|
+
// ==================================================================
|
|
139
|
+
// TABLE operations
|
|
140
|
+
// ==================================================================
|
|
141
|
+
{
|
|
142
|
+
displayName: 'Operation',
|
|
143
|
+
name: 'operation',
|
|
144
|
+
type: 'options',
|
|
145
|
+
noDataExpression: true,
|
|
146
|
+
displayOptions: { show: { resource: ['table'] } },
|
|
147
|
+
options: [
|
|
148
|
+
{
|
|
149
|
+
name: 'Append Row',
|
|
150
|
+
value: 'appendRow',
|
|
151
|
+
description: 'Add a row at the end of the table and extend the table range',
|
|
152
|
+
action: 'Append a row to a table',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'Delete Row',
|
|
156
|
+
value: 'deleteRow',
|
|
157
|
+
description: 'Remove a data row and shrink the table range',
|
|
158
|
+
action: 'Delete a row from a table',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'Get Columns',
|
|
162
|
+
value: 'getColumns',
|
|
163
|
+
description: 'Return the column headers of the table',
|
|
164
|
+
action: 'Get column headers of a table',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'Get Rows',
|
|
168
|
+
value: 'getRows',
|
|
169
|
+
description: 'Return all data rows of the table as n8n items',
|
|
170
|
+
action: 'Get all rows from a table',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'List',
|
|
174
|
+
value: 'list',
|
|
175
|
+
description: 'List all named tables in the workbook',
|
|
176
|
+
action: 'List named tables in workbook',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'Update Row',
|
|
180
|
+
value: 'updateRow',
|
|
181
|
+
description: 'Update an existing row by its row number within the table',
|
|
182
|
+
action: 'Update a row in a table',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
default: 'getRows',
|
|
186
|
+
},
|
|
187
|
+
// ==================================================================
|
|
188
|
+
// WORKBOOK operations
|
|
189
|
+
// ==================================================================
|
|
190
|
+
{
|
|
191
|
+
displayName: 'Operation',
|
|
192
|
+
name: 'operation',
|
|
193
|
+
type: 'options',
|
|
194
|
+
noDataExpression: true,
|
|
195
|
+
displayOptions: { show: { resource: ['workbook'] } },
|
|
196
|
+
options: [
|
|
197
|
+
{
|
|
198
|
+
name: 'Get Sheets',
|
|
199
|
+
value: 'getSheets',
|
|
200
|
+
description: 'Return all worksheet names',
|
|
201
|
+
action: 'Get all sheet names',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'Get Tables',
|
|
205
|
+
value: 'getTables',
|
|
206
|
+
description: 'Return all named tables across all sheets',
|
|
207
|
+
action: 'Get all named tables',
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
default: 'getSheets',
|
|
211
|
+
},
|
|
212
|
+
// ==================================================================
|
|
213
|
+
// File selector (shared by all resources)
|
|
214
|
+
// ==================================================================
|
|
215
|
+
{
|
|
216
|
+
displayName: 'File',
|
|
217
|
+
name: 'filePathMode',
|
|
218
|
+
type: 'options',
|
|
219
|
+
options: [
|
|
220
|
+
{ name: 'From List', value: 'list' },
|
|
221
|
+
{ name: 'By Path (Expression)', value: 'path' },
|
|
222
|
+
],
|
|
223
|
+
default: 'list',
|
|
224
|
+
description: 'How to specify the spreadsheet file',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
displayName: 'File',
|
|
228
|
+
name: 'filePathFromList',
|
|
229
|
+
type: 'options',
|
|
230
|
+
typeOptions: { loadOptionsMethod: 'getSpreadsheetFiles' },
|
|
231
|
+
displayOptions: { show: { filePathMode: ['list'] } },
|
|
232
|
+
default: '',
|
|
233
|
+
description: 'Select a spreadsheet file from your Nextcloud root folder',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
displayName: 'File Path',
|
|
237
|
+
name: 'filePath',
|
|
238
|
+
type: 'string',
|
|
239
|
+
default: '',
|
|
240
|
+
placeholder: '/Documents/data.xlsx',
|
|
241
|
+
description: 'Path of the spreadsheet file on Nextcloud',
|
|
242
|
+
displayOptions: { show: { filePathMode: ['path'] } },
|
|
243
|
+
},
|
|
244
|
+
// ==================================================================
|
|
245
|
+
// Sheet selector (Sheet resource only)
|
|
246
|
+
// ==================================================================
|
|
247
|
+
{
|
|
248
|
+
displayName: 'Sheet',
|
|
249
|
+
name: 'sheetMode',
|
|
250
|
+
type: 'options',
|
|
251
|
+
options: [
|
|
252
|
+
{ name: 'From List', value: 'list' },
|
|
253
|
+
{ name: 'By Name (Expression)', value: 'name' },
|
|
254
|
+
{ name: 'First Sheet', value: 'first' },
|
|
255
|
+
],
|
|
256
|
+
default: 'list',
|
|
257
|
+
description: 'Which worksheet to use',
|
|
258
|
+
displayOptions: { show: { resource: ['sheet'] } },
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
displayName: 'Sheet',
|
|
262
|
+
name: 'sheetFromList',
|
|
263
|
+
type: 'options',
|
|
264
|
+
typeOptions: { loadOptionsMethod: 'getSheetsForFile' },
|
|
265
|
+
displayOptions: {
|
|
266
|
+
show: {
|
|
267
|
+
resource: ['sheet'],
|
|
268
|
+
sheetMode: ['list'],
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
default: '',
|
|
272
|
+
description: 'Select the worksheet',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
displayName: 'Sheet Name',
|
|
276
|
+
name: 'sheetName',
|
|
277
|
+
type: 'string',
|
|
278
|
+
default: '',
|
|
279
|
+
placeholder: 'Sheet1',
|
|
280
|
+
description: 'Exact name of the worksheet',
|
|
281
|
+
displayOptions: {
|
|
282
|
+
show: {
|
|
283
|
+
resource: ['sheet'],
|
|
284
|
+
sheetMode: ['name'],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
// ==================================================================
|
|
289
|
+
// Table selector (Table resource only — not for List operation)
|
|
290
|
+
// ==================================================================
|
|
291
|
+
{
|
|
292
|
+
displayName: 'Table',
|
|
293
|
+
name: 'tableMode',
|
|
294
|
+
type: 'options',
|
|
295
|
+
options: [
|
|
296
|
+
{ name: 'From List', value: 'list' },
|
|
297
|
+
{ name: 'By Name (Expression)', value: 'name' },
|
|
298
|
+
],
|
|
299
|
+
default: 'list',
|
|
300
|
+
description: 'Which named table to use',
|
|
301
|
+
displayOptions: {
|
|
302
|
+
show: {
|
|
303
|
+
resource: ['table'],
|
|
304
|
+
operation: ['getRows', 'appendRow', 'updateRow', 'deleteRow', 'getColumns'],
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
displayName: 'Table',
|
|
310
|
+
name: 'tableFromList',
|
|
311
|
+
type: 'options',
|
|
312
|
+
typeOptions: { loadOptionsMethod: 'getTablesForFile' },
|
|
313
|
+
displayOptions: {
|
|
314
|
+
show: {
|
|
315
|
+
resource: ['table'],
|
|
316
|
+
tableMode: ['list'],
|
|
317
|
+
operation: ['getRows', 'appendRow', 'updateRow', 'deleteRow', 'getColumns'],
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
default: '',
|
|
321
|
+
description: 'Select a named table from the workbook',
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
displayName: 'Table Name',
|
|
325
|
+
name: 'tableName',
|
|
326
|
+
type: 'string',
|
|
327
|
+
default: '',
|
|
328
|
+
placeholder: 'Tableau1',
|
|
329
|
+
description: 'Exact name of the Excel table (case-sensitive)',
|
|
330
|
+
displayOptions: {
|
|
331
|
+
show: {
|
|
332
|
+
resource: ['table'],
|
|
333
|
+
tableMode: ['name'],
|
|
334
|
+
operation: ['getRows', 'appendRow', 'updateRow', 'deleteRow', 'getColumns'],
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
// ==================================================================
|
|
339
|
+
// GET ROWS (sheet) — options
|
|
340
|
+
// ==================================================================
|
|
341
|
+
{
|
|
342
|
+
displayName: 'Return RAW Data',
|
|
343
|
+
name: 'rawData',
|
|
344
|
+
type: 'boolean',
|
|
345
|
+
default: false,
|
|
346
|
+
description: 'Whether to return raw rows (arrays) instead of objects keyed by column header',
|
|
347
|
+
displayOptions: {
|
|
348
|
+
show: {
|
|
349
|
+
resource: ['sheet'],
|
|
350
|
+
operation: ['getRows'],
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
displayName: 'Filters',
|
|
356
|
+
name: 'filters',
|
|
357
|
+
type: 'fixedCollection',
|
|
358
|
+
placeholder: 'Add Filter',
|
|
359
|
+
default: {},
|
|
360
|
+
typeOptions: { multipleValues: true },
|
|
361
|
+
displayOptions: {
|
|
362
|
+
show: {
|
|
363
|
+
resource: ['sheet'],
|
|
364
|
+
operation: ['getRows'],
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
options: [
|
|
368
|
+
{
|
|
369
|
+
displayName: 'Filter',
|
|
370
|
+
name: 'filter',
|
|
371
|
+
values: [
|
|
372
|
+
{
|
|
373
|
+
displayName: 'Column',
|
|
374
|
+
name: 'column',
|
|
375
|
+
type: 'string',
|
|
376
|
+
default: '',
|
|
377
|
+
description: 'Column header to filter on',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
displayName: 'Value',
|
|
381
|
+
name: 'value',
|
|
382
|
+
type: 'string',
|
|
383
|
+
default: '',
|
|
384
|
+
description: 'Value that must match (exact, case-insensitive)',
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
},
|
|
390
|
+
// ==================================================================
|
|
391
|
+
// GET ROWS (table) — filters
|
|
392
|
+
// ==================================================================
|
|
393
|
+
{
|
|
394
|
+
displayName: 'Filters',
|
|
395
|
+
name: 'tableFilters',
|
|
396
|
+
type: 'fixedCollection',
|
|
397
|
+
placeholder: 'Add Filter',
|
|
398
|
+
default: {},
|
|
399
|
+
typeOptions: { multipleValues: true },
|
|
400
|
+
displayOptions: {
|
|
401
|
+
show: {
|
|
402
|
+
resource: ['table'],
|
|
403
|
+
operation: ['getRows'],
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
options: [
|
|
407
|
+
{
|
|
408
|
+
displayName: 'Filter',
|
|
409
|
+
name: 'filter',
|
|
410
|
+
values: [
|
|
411
|
+
{
|
|
412
|
+
displayName: 'Column Name or ID',
|
|
413
|
+
name: 'column',
|
|
414
|
+
type: 'string',
|
|
415
|
+
default: '',
|
|
416
|
+
description: 'Column header to filter on — must match the table column name exactly',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
displayName: 'Value',
|
|
420
|
+
name: 'value',
|
|
421
|
+
type: 'string',
|
|
422
|
+
default: '',
|
|
423
|
+
description: 'Value that must match (exact, case-insensitive)',
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
],
|
|
428
|
+
},
|
|
429
|
+
// ==================================================================
|
|
430
|
+
// APPEND / UPDATE ROW — column values (sheet)
|
|
431
|
+
// ==================================================================
|
|
432
|
+
{
|
|
433
|
+
displayName: 'Column Values',
|
|
434
|
+
name: 'columnValues',
|
|
435
|
+
type: 'fixedCollection',
|
|
436
|
+
placeholder: 'Add Column',
|
|
437
|
+
default: {},
|
|
438
|
+
typeOptions: { multipleValues: true },
|
|
439
|
+
displayOptions: {
|
|
440
|
+
show: {
|
|
441
|
+
resource: ['sheet'],
|
|
442
|
+
operation: ['appendRow', 'updateRow'],
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
options: [
|
|
446
|
+
{
|
|
447
|
+
displayName: 'Column',
|
|
448
|
+
name: 'column',
|
|
449
|
+
values: [
|
|
450
|
+
{
|
|
451
|
+
displayName: 'Column Name',
|
|
452
|
+
name: 'name',
|
|
453
|
+
type: 'string',
|
|
454
|
+
default: '',
|
|
455
|
+
description: 'Must match the header in the first row exactly',
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
displayName: 'Value',
|
|
459
|
+
name: 'value',
|
|
460
|
+
type: 'string',
|
|
461
|
+
default: '',
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
},
|
|
467
|
+
// ==================================================================
|
|
468
|
+
// APPEND / UPDATE ROW — column values (table)
|
|
469
|
+
// ==================================================================
|
|
470
|
+
{
|
|
471
|
+
displayName: 'Column Values',
|
|
472
|
+
name: 'tableColumnValues',
|
|
473
|
+
type: 'fixedCollection',
|
|
474
|
+
placeholder: 'Add Column',
|
|
475
|
+
default: {},
|
|
476
|
+
typeOptions: { multipleValues: true },
|
|
477
|
+
displayOptions: {
|
|
478
|
+
show: {
|
|
479
|
+
resource: ['table'],
|
|
480
|
+
operation: ['appendRow', 'updateRow'],
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
options: [
|
|
484
|
+
{
|
|
485
|
+
displayName: 'Column',
|
|
486
|
+
name: 'column',
|
|
487
|
+
values: [
|
|
488
|
+
{
|
|
489
|
+
displayName: 'Column Name',
|
|
490
|
+
name: 'name',
|
|
491
|
+
type: 'string',
|
|
492
|
+
default: '',
|
|
493
|
+
description: 'Must match the table column header exactly',
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
displayName: 'Value',
|
|
497
|
+
name: 'value',
|
|
498
|
+
type: 'string',
|
|
499
|
+
default: '',
|
|
500
|
+
},
|
|
501
|
+
],
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
},
|
|
505
|
+
// ==================================================================
|
|
506
|
+
// Row number (sheet)
|
|
507
|
+
// ==================================================================
|
|
508
|
+
{
|
|
509
|
+
displayName: 'Row Number',
|
|
510
|
+
name: 'rowNumber',
|
|
511
|
+
type: 'number',
|
|
512
|
+
default: 1,
|
|
513
|
+
typeOptions: { minValue: 1 },
|
|
514
|
+
description: 'Row number to act on — 1 = first data row (the row immediately below the header)',
|
|
515
|
+
displayOptions: {
|
|
516
|
+
show: {
|
|
517
|
+
resource: ['sheet'],
|
|
518
|
+
operation: ['updateRow', 'deleteRow'],
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
// ==================================================================
|
|
523
|
+
// Row number (table)
|
|
524
|
+
// ==================================================================
|
|
525
|
+
{
|
|
526
|
+
displayName: 'Row Number',
|
|
527
|
+
name: 'tableRowNumber',
|
|
528
|
+
type: 'number',
|
|
529
|
+
default: 1,
|
|
530
|
+
typeOptions: { minValue: 1 },
|
|
531
|
+
description: 'Row number inside the table — 1 = first data row (does not count the header)',
|
|
532
|
+
displayOptions: {
|
|
533
|
+
show: {
|
|
534
|
+
resource: ['table'],
|
|
535
|
+
operation: ['updateRow', 'deleteRow'],
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
};
|
|
541
|
+
// ============================================================
|
|
542
|
+
// Load-options methods (dynamic dropdowns)
|
|
543
|
+
// ============================================================
|
|
544
|
+
this.methods = {
|
|
545
|
+
loadOptions: {
|
|
546
|
+
async getSpreadsheetFiles() {
|
|
547
|
+
return (0, GenericFunctions_1.getSpreadsheetFiles)(this);
|
|
548
|
+
},
|
|
549
|
+
async getSheetsForFile() {
|
|
550
|
+
const filePath = resolveFilePath(this);
|
|
551
|
+
if (!filePath)
|
|
552
|
+
return [];
|
|
553
|
+
return (0, GenericFunctions_1.getSheetsForFile)(this, filePath);
|
|
554
|
+
},
|
|
555
|
+
async getTablesForFile() {
|
|
556
|
+
const filePath = resolveFilePath(this);
|
|
557
|
+
if (!filePath)
|
|
558
|
+
return [];
|
|
559
|
+
return (0, GenericFunctions_1.getTablesForFile)(this, filePath);
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
// ============================================================
|
|
565
|
+
// Execute
|
|
566
|
+
// ============================================================
|
|
567
|
+
async execute() {
|
|
568
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
569
|
+
const items = this.getInputData();
|
|
570
|
+
const returnData = [];
|
|
571
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
572
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
573
|
+
const creds = await (0, GenericFunctions_1.getCredentials)(this);
|
|
574
|
+
for (let i = 0; i < items.length; i++) {
|
|
575
|
+
try {
|
|
576
|
+
// ----------------------------------------------------------
|
|
577
|
+
// Resolve file path
|
|
578
|
+
// ----------------------------------------------------------
|
|
579
|
+
const filePathMode = this.getNodeParameter('filePathMode', i, 'list');
|
|
580
|
+
const filePath = filePathMode === 'list'
|
|
581
|
+
? this.getNodeParameter('filePathFromList', i, '')
|
|
582
|
+
: this.getNodeParameter('filePath', i, '');
|
|
583
|
+
if (!filePath) {
|
|
584
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No file path specified', { itemIndex: i });
|
|
585
|
+
}
|
|
586
|
+
const fileExt = (_a = filePath.split('.').pop()) !== null && _a !== void 0 ? _a : 'xlsx';
|
|
587
|
+
// ----------------------------------------------------------
|
|
588
|
+
// WORKBOOK resource
|
|
589
|
+
// ----------------------------------------------------------
|
|
590
|
+
if (resource === 'workbook') {
|
|
591
|
+
const buffer = await (0, GenericFunctions_1.downloadFile)(this, creds, filePath);
|
|
592
|
+
const wb = (0, GenericFunctions_1.parseWorkbook)(buffer);
|
|
593
|
+
if (operation === 'getSheets') {
|
|
594
|
+
for (const name of (0, GenericFunctions_1.getSheetNames)(wb)) {
|
|
595
|
+
returnData.push({ json: { sheetName: name } });
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
else if (operation === 'getTables') {
|
|
599
|
+
const tables = (0, GenericFunctions_1.getWorkbookTables)(wb);
|
|
600
|
+
if (tables.length === 0) {
|
|
601
|
+
returnData.push({ json: { message: 'No named tables found in this workbook' } });
|
|
602
|
+
}
|
|
603
|
+
for (const t of tables) {
|
|
604
|
+
returnData.push({
|
|
605
|
+
json: {
|
|
606
|
+
name: t.name,
|
|
607
|
+
displayName: t.displayName,
|
|
608
|
+
sheetName: t.sheetName,
|
|
609
|
+
ref: t.ref,
|
|
610
|
+
columns: t.columns,
|
|
611
|
+
dataRowCount: t.dataRowCount,
|
|
612
|
+
},
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
// ----------------------------------------------------------
|
|
619
|
+
// TABLE resource
|
|
620
|
+
// ----------------------------------------------------------
|
|
621
|
+
if (resource === 'table') {
|
|
622
|
+
const buffer = await (0, GenericFunctions_1.downloadFile)(this, creds, filePath);
|
|
623
|
+
const workbook = (0, GenericFunctions_1.parseWorkbook)(buffer);
|
|
624
|
+
// List all tables — no table name needed
|
|
625
|
+
if (operation === 'list') {
|
|
626
|
+
const tables = (0, GenericFunctions_1.getWorkbookTables)(workbook);
|
|
627
|
+
if (tables.length === 0) {
|
|
628
|
+
returnData.push({ json: { message: 'No named tables found in this workbook' } });
|
|
629
|
+
}
|
|
630
|
+
for (const t of tables) {
|
|
631
|
+
returnData.push({
|
|
632
|
+
json: {
|
|
633
|
+
name: t.name,
|
|
634
|
+
displayName: t.displayName,
|
|
635
|
+
sheetName: t.sheetName,
|
|
636
|
+
ref: t.ref,
|
|
637
|
+
columns: t.columns,
|
|
638
|
+
dataRowCount: t.dataRowCount,
|
|
639
|
+
},
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
// Resolve table name
|
|
645
|
+
const tableMode = this.getNodeParameter('tableMode', i, 'list');
|
|
646
|
+
const tableName = tableMode === 'list'
|
|
647
|
+
? this.getNodeParameter('tableFromList', i, '')
|
|
648
|
+
: this.getNodeParameter('tableName', i, '');
|
|
649
|
+
if (!tableName) {
|
|
650
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No table name specified', {
|
|
651
|
+
itemIndex: i,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
if (operation === 'getColumns') {
|
|
655
|
+
const columns = (0, GenericFunctions_1.getTableColumns)(workbook, tableName);
|
|
656
|
+
returnData.push({
|
|
657
|
+
json: { tableName, columns, count: columns.length, filePath },
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
else if (operation === 'getRows') {
|
|
661
|
+
const filtersCollection = this.getNodeParameter('tableFilters', i, {});
|
|
662
|
+
const filterList = ((_b = filtersCollection.filter) !== null && _b !== void 0 ? _b : []);
|
|
663
|
+
const rows = (0, GenericFunctions_1.getTableRows)(workbook, tableName, filterList);
|
|
664
|
+
for (const row of rows) {
|
|
665
|
+
returnData.push({ json: row });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
else if (operation === 'appendRow') {
|
|
669
|
+
const colValues = this.getNodeParameter('tableColumnValues', i, {});
|
|
670
|
+
const columns = (_c = colValues.column) !== null && _c !== void 0 ? _c : [];
|
|
671
|
+
const rowData = {};
|
|
672
|
+
for (const col of columns)
|
|
673
|
+
rowData[col.name] = col.value;
|
|
674
|
+
(0, GenericFunctions_1.appendRowToTable)(workbook, tableName, rowData);
|
|
675
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
676
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
677
|
+
returnData.push({
|
|
678
|
+
json: { success: true, operation: 'appendRow', tableName, rowData },
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
else if (operation === 'updateRow') {
|
|
682
|
+
const rowNumber = this.getNodeParameter('tableRowNumber', i, 1);
|
|
683
|
+
const colValues = this.getNodeParameter('tableColumnValues', i, {});
|
|
684
|
+
const columns = (_d = colValues.column) !== null && _d !== void 0 ? _d : [];
|
|
685
|
+
const rowData = {};
|
|
686
|
+
for (const col of columns)
|
|
687
|
+
rowData[col.name] = col.value;
|
|
688
|
+
(0, GenericFunctions_1.updateRowInTable)(workbook, tableName, rowNumber, rowData);
|
|
689
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
690
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
691
|
+
returnData.push({
|
|
692
|
+
json: { success: true, operation: 'updateRow', tableName, rowNumber, rowData },
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
else if (operation === 'deleteRow') {
|
|
696
|
+
const rowNumber = this.getNodeParameter('tableRowNumber', i, 1);
|
|
697
|
+
(0, GenericFunctions_1.deleteRowFromTable)(workbook, tableName, rowNumber);
|
|
698
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
699
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
700
|
+
returnData.push({
|
|
701
|
+
json: {
|
|
702
|
+
success: true,
|
|
703
|
+
operation: 'deleteRow',
|
|
704
|
+
tableName,
|
|
705
|
+
deletedRow: rowNumber,
|
|
706
|
+
},
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
// ----------------------------------------------------------
|
|
712
|
+
// SHEET resource
|
|
713
|
+
// ----------------------------------------------------------
|
|
714
|
+
if (resource === 'sheet') {
|
|
715
|
+
// Resolve sheet name
|
|
716
|
+
const sheetMode = this.getNodeParameter('sheetMode', i, 'list');
|
|
717
|
+
let sheetName = sheetMode === 'list'
|
|
718
|
+
? this.getNodeParameter('sheetFromList', i, '')
|
|
719
|
+
: sheetMode === 'name'
|
|
720
|
+
? this.getNodeParameter('sheetName', i, '')
|
|
721
|
+
: '';
|
|
722
|
+
const buffer = await (0, GenericFunctions_1.downloadFile)(this, creds, filePath);
|
|
723
|
+
const workbook = (0, GenericFunctions_1.parseWorkbook)(buffer);
|
|
724
|
+
if (!sheetName)
|
|
725
|
+
sheetName = workbook.SheetNames[0];
|
|
726
|
+
if (!workbook.SheetNames.includes(sheetName)) {
|
|
727
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sheet "${sheetName}" not found. Available: ${workbook.SheetNames.join(', ')}`, { itemIndex: i });
|
|
728
|
+
}
|
|
729
|
+
const sheet = workbook.Sheets[sheetName];
|
|
730
|
+
if (operation === 'getRows') {
|
|
731
|
+
const rawData = this.getNodeParameter('rawData', i, false);
|
|
732
|
+
const filtersCollection = this.getNodeParameter('filters', i, {});
|
|
733
|
+
const filterList = ((_e = filtersCollection.filter) !== null && _e !== void 0 ? _e : []);
|
|
734
|
+
let rows = (0, GenericFunctions_1.sheetToRows)(sheet, rawData);
|
|
735
|
+
if (!rawData && filterList.length > 0) {
|
|
736
|
+
rows = rows.filter((row) => filterList.every((f) => { var _a; return String((_a = row[f.column]) !== null && _a !== void 0 ? _a : '').toLowerCase() === f.value.toLowerCase(); }));
|
|
737
|
+
}
|
|
738
|
+
for (const row of rows)
|
|
739
|
+
returnData.push({ json: row });
|
|
740
|
+
}
|
|
741
|
+
else if (operation === 'getColumns') {
|
|
742
|
+
const headers = (0, GenericFunctions_1.getHeaders)(sheet);
|
|
743
|
+
returnData.push({
|
|
744
|
+
json: { columns: headers, count: headers.length, sheetName, filePath },
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
else if (operation === 'appendRow') {
|
|
748
|
+
const colValues = this.getNodeParameter('columnValues', i, {});
|
|
749
|
+
const columns = (_f = colValues.column) !== null && _f !== void 0 ? _f : [];
|
|
750
|
+
const rowData = {};
|
|
751
|
+
for (const col of columns)
|
|
752
|
+
rowData[col.name] = col.value;
|
|
753
|
+
(0, GenericFunctions_1.appendRowToSheet)(sheet, rowData);
|
|
754
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
755
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
756
|
+
returnData.push({
|
|
757
|
+
json: {
|
|
758
|
+
success: true,
|
|
759
|
+
operation: 'appendRow',
|
|
760
|
+
sheetName,
|
|
761
|
+
rowData,
|
|
762
|
+
totalRows: (0, GenericFunctions_1.getDataRowCount)(sheet),
|
|
763
|
+
},
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
else if (operation === 'updateRow') {
|
|
767
|
+
const rowNumber = this.getNodeParameter('rowNumber', i, 1);
|
|
768
|
+
const colValues = this.getNodeParameter('columnValues', i, {});
|
|
769
|
+
const columns = (_g = colValues.column) !== null && _g !== void 0 ? _g : [];
|
|
770
|
+
const rowData = {};
|
|
771
|
+
for (const col of columns)
|
|
772
|
+
rowData[col.name] = col.value;
|
|
773
|
+
(0, GenericFunctions_1.updateRowInSheet)(sheet, rowNumber, rowData);
|
|
774
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
775
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
776
|
+
returnData.push({
|
|
777
|
+
json: { success: true, operation: 'updateRow', sheetName, rowNumber, rowData },
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
else if (operation === 'deleteRow') {
|
|
781
|
+
const rowNumber = this.getNodeParameter('rowNumber', i, 1);
|
|
782
|
+
(0, GenericFunctions_1.deleteRowFromSheet)(workbook, sheetName, rowNumber);
|
|
783
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
784
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
785
|
+
returnData.push({
|
|
786
|
+
json: { success: true, operation: 'deleteRow', sheetName, deletedRow: rowNumber },
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
else if (operation === 'clear') {
|
|
790
|
+
const headers = (0, GenericFunctions_1.getHeaders)(sheet);
|
|
791
|
+
workbook.Sheets[sheetName] = xlsx.utils.aoa_to_sheet([headers]);
|
|
792
|
+
const outBuffer = (0, GenericFunctions_1.serializeWorkbook)(workbook, fileExt);
|
|
793
|
+
await (0, GenericFunctions_1.uploadFile)(this, creds, filePath, outBuffer);
|
|
794
|
+
returnData.push({
|
|
795
|
+
json: { success: true, operation: 'clear', sheetName, columnsPreserved: headers },
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
catch (error) {
|
|
801
|
+
if (this.continueOnFail()) {
|
|
802
|
+
returnData.push({ json: { error: error.message }, pairedItem: i });
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
throw error;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return [returnData];
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
exports.NextCloudSpreadsheet = NextCloudSpreadsheet;
|
|
812
|
+
// Helper used by loadOptions methods (no item index context available there)
|
|
813
|
+
function resolveFilePath(context) {
|
|
814
|
+
const mode = context.getNodeParameter('filePathMode', 'list');
|
|
815
|
+
if (mode === 'list') {
|
|
816
|
+
return context.getNodeParameter('filePathFromList', '');
|
|
817
|
+
}
|
|
818
|
+
return context.getNodeParameter('filePath', '');
|
|
819
|
+
}
|
|
820
|
+
//# sourceMappingURL=NextCloudSpreadsheet.node.js.map
|