@rudsys/n8n-nodes-sqlite3 0.1.2 → 0.1.5

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.
@@ -10,7 +10,7 @@ class SqliteSsh {
10
10
  name: 'sqliteSsh',
11
11
  icon: 'fa:database',
12
12
  group: ['transform'],
13
- version: 1,
13
+ version: 2,
14
14
  description: 'Execute SQLite operations on a remote server via SSH',
15
15
  defaults: {
16
16
  name: 'SQLite SSH',
@@ -52,10 +52,113 @@ class SqliteSsh {
52
52
  { name: 'Select', value: 'select', description: 'Select data from a table' },
53
53
  { name: 'Update', value: 'update', description: 'Update data in a table' },
54
54
  { name: 'Delete', value: 'delete', description: 'Delete data from a table' },
55
+ { name: 'Table Operations', value: 'manageTables', description: 'Create, rename, drop, or list tables' },
56
+ { name: 'Column Operations', value: 'manageColumns', description: 'Add, rename, drop, or list columns' },
55
57
  { name: 'Vacuum', value: 'vacuum', description: 'Rebuild the database file' },
56
58
  ],
57
59
  default: 'executeQuery',
58
60
  },
61
+ // ------------------ Table Operations ------------------
62
+ {
63
+ displayName: 'Action',
64
+ name: 'tableAction',
65
+ type: 'options',
66
+ displayOptions: { show: { operation: ['manageTables'] } },
67
+ options: [
68
+ { name: 'List Tables', value: 'list' },
69
+ { name: 'Create Table', value: 'create' },
70
+ { name: 'Rename Table', value: 'rename' },
71
+ { name: 'Drop Table', value: 'drop' },
72
+ ],
73
+ default: 'list',
74
+ description: 'Action to perform on tables',
75
+ },
76
+ {
77
+ displayName: 'New Table Name',
78
+ name: 'newTableName',
79
+ type: 'string',
80
+ displayOptions: {
81
+ show: {
82
+ operation: ['manageTables'],
83
+ tableAction: ['rename'],
84
+ },
85
+ },
86
+ default: '',
87
+ placeholder: 'my_renamed_table',
88
+ required: true,
89
+ },
90
+ {
91
+ displayName: 'Columns Definition',
92
+ name: 'tableColumnsDefinition',
93
+ type: 'string',
94
+ displayOptions: {
95
+ show: {
96
+ operation: ['manageTables'],
97
+ tableAction: ['create'],
98
+ },
99
+ },
100
+ default: 'id INTEGER PRIMARY KEY, name TEXT NOT NULL',
101
+ placeholder: 'id INTEGER PRIMARY KEY, name TEXT',
102
+ description: 'Comma-separated column definitions',
103
+ typeOptions: { rows: 4 },
104
+ },
105
+ // ------------------ Column Operations ------------------
106
+ {
107
+ displayName: 'Action',
108
+ name: 'columnAction',
109
+ type: 'options',
110
+ displayOptions: { show: { operation: ['manageColumns'] } },
111
+ options: [
112
+ { name: 'List Columns', value: 'list' },
113
+ { name: 'Add Column', value: 'add' },
114
+ { name: 'Rename Column', value: 'rename' },
115
+ { name: 'Drop Column', value: 'drop' },
116
+ ],
117
+ default: 'list',
118
+ description: 'Action to perform on the table columns',
119
+ },
120
+ {
121
+ displayName: 'Column Name',
122
+ name: 'columnName',
123
+ type: 'string',
124
+ displayOptions: {
125
+ show: {
126
+ operation: ['manageColumns'],
127
+ columnAction: ['add', 'rename', 'drop'],
128
+ },
129
+ },
130
+ default: '',
131
+ placeholder: 'my_new_column',
132
+ required: true,
133
+ },
134
+ {
135
+ displayName: 'New Column Name',
136
+ name: 'newColumnName',
137
+ type: 'string',
138
+ displayOptions: {
139
+ show: {
140
+ operation: ['manageColumns'],
141
+ columnAction: ['rename'],
142
+ },
143
+ },
144
+ default: '',
145
+ placeholder: 'my_renamed_column',
146
+ required: true,
147
+ },
148
+ {
149
+ displayName: 'Column Definition',
150
+ name: 'columnDefinition',
151
+ type: 'string',
152
+ displayOptions: {
153
+ show: {
154
+ operation: ['manageColumns'],
155
+ columnAction: ['add'],
156
+ },
157
+ },
158
+ default: 'TEXT',
159
+ placeholder: 'TEXT NOT NULL DEFAULT ""',
160
+ description: 'Type and constraints (e.g., INTEGER PRIMARY KEY, TEXT DEFAULT "active")',
161
+ },
59
162
  // ------------------ Execute Query ------------------
60
163
  {
61
164
  displayName: 'Query',
@@ -160,7 +263,7 @@ class SqliteSsh {
160
263
  name: 'value',
161
264
  type: 'string',
162
265
  default: '',
163
- // displayOptions removed to prevent dependency loop inside fixedCollection
266
+ displayOptions: { hide: { operator: ['isNull', 'isNotNull'] } },
164
267
  },
165
268
  ],
166
269
  },
@@ -282,6 +385,58 @@ class SqliteSsh {
282
385
  else if (operation === 'executeQuery') {
283
386
  sql = this.getNodeParameter('query', i);
284
387
  }
388
+ else if (operation === 'manageTables') {
389
+ const action = this.getNodeParameter('tableAction', i);
390
+ if (action === 'list') {
391
+ sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';";
392
+ }
393
+ else {
394
+ // For create, rename, drop - table param is used
395
+ // For create: table param is the NEW table name
396
+ // For rename: table param is OLD name, newTableName is NEW name
397
+ // For drop: table param is table to drop
398
+ if (action === 'create') {
399
+ let columnsDef = this.getNodeParameter('tableColumnsDefinition', i);
400
+ columnsDef = columnsDef.trim();
401
+ if (columnsDef.startsWith('(') && columnsDef.endsWith(')')) {
402
+ columnsDef = columnsDef.slice(1, -1);
403
+ }
404
+ sql = `CREATE TABLE ${table} (${columnsDef});`;
405
+ }
406
+ else if (action === 'rename') {
407
+ const newName = escapeIdentifier(this.getNodeParameter('newTableName', i));
408
+ sql = `ALTER TABLE ${table} RENAME TO ${newName};`;
409
+ }
410
+ else if (action === 'drop') {
411
+ sql = `DROP TABLE ${table};`;
412
+ }
413
+ }
414
+ }
415
+ else if (operation === 'manageColumns') {
416
+ const action = this.getNodeParameter('columnAction', i);
417
+ if (action === 'list') {
418
+ // PRAGMA table_info returns list of columns
419
+ sql = `PRAGMA table_info(${table});`;
420
+ }
421
+ else {
422
+ const colName = escapeIdentifier(this.getNodeParameter('columnName', i));
423
+ if (action === 'add') {
424
+ let colDef = this.getNodeParameter('columnDefinition', i);
425
+ colDef = colDef.trim();
426
+ if (colDef.startsWith('(') && colDef.endsWith(')')) {
427
+ colDef = colDef.slice(1, -1);
428
+ }
429
+ sql = `ALTER TABLE ${table} ADD COLUMN ${colName} ${colDef};`;
430
+ }
431
+ else if (action === 'rename') {
432
+ const newColName = escapeIdentifier(this.getNodeParameter('newColumnName', i));
433
+ sql = `ALTER TABLE ${table} RENAME COLUMN ${colName} TO ${newColName};`;
434
+ }
435
+ else if (action === 'drop') {
436
+ sql = `ALTER TABLE ${table} DROP COLUMN ${colName};`;
437
+ }
438
+ }
439
+ }
285
440
  else if (operation === 'vacuum') {
286
441
  sql = 'VACUUM;';
287
442
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rudsys/n8n-nodes-sqlite3",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "n8n node for Remote SQLite operations via SSH",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/rudsys/n8n-nodes-sqlite3",