@rudsys/n8n-nodes-sqlite3 0.1.5 → 0.1.7

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.
@@ -88,19 +88,84 @@ class SqliteSsh {
88
88
  required: true,
89
89
  },
90
90
  {
91
- displayName: 'Columns Definition',
92
- name: 'tableColumnsDefinition',
93
- type: 'string',
91
+ displayName: 'Columns',
92
+ name: 'columnsUi',
93
+ type: 'fixedCollection',
94
+ typeOptions: {
95
+ multipleValues: true,
96
+ },
94
97
  displayOptions: {
95
98
  show: {
96
99
  operation: ['manageTables'],
97
100
  tableAction: ['create'],
98
101
  },
99
102
  },
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 },
103
+ default: {},
104
+ placeholder: 'Add Column',
105
+ options: [
106
+ {
107
+ name: 'column',
108
+ displayName: 'Column',
109
+ values: [
110
+ {
111
+ displayName: 'Name',
112
+ name: 'name',
113
+ type: 'string',
114
+ default: '',
115
+ required: true,
116
+ description: 'Name of the column',
117
+ },
118
+ {
119
+ displayName: 'Type',
120
+ name: 'type',
121
+ type: 'options',
122
+ options: [
123
+ { name: 'INTEGER', value: 'INTEGER' },
124
+ { name: 'TEXT', value: 'TEXT' },
125
+ { name: 'REAL', value: 'REAL' },
126
+ { name: 'BLOB', value: 'BLOB' },
127
+ { name: 'NUMERIC', value: 'NUMERIC' },
128
+ ],
129
+ default: 'TEXT',
130
+ description: 'Data type of the column',
131
+ },
132
+ {
133
+ displayName: 'Primary Key',
134
+ name: 'primaryKey',
135
+ type: 'boolean',
136
+ default: false,
137
+ description: 'Whether this column is a primary key',
138
+ },
139
+ {
140
+ displayName: 'Auto Increment',
141
+ name: 'autoIncrement',
142
+ type: 'boolean',
143
+ default: false,
144
+ displayOptions: {
145
+ show: {
146
+ primaryKey: [true],
147
+ type: ['INTEGER'],
148
+ },
149
+ },
150
+ description: 'Whether this column should auto increment (only for INTEGER PRIMARY KEY)',
151
+ },
152
+ {
153
+ displayName: 'Not Null',
154
+ name: 'notNull',
155
+ type: 'boolean',
156
+ default: false,
157
+ description: 'Whether this column cannot be null',
158
+ },
159
+ {
160
+ displayName: 'Unique',
161
+ name: 'unique',
162
+ type: 'boolean',
163
+ default: false,
164
+ description: 'Whether values in this column must be unique',
165
+ },
166
+ ],
167
+ },
168
+ ],
104
169
  },
105
170
  // ------------------ Column Operations ------------------
106
171
  {
@@ -175,9 +240,25 @@ class SqliteSsh {
175
240
  displayName: 'Table',
176
241
  name: 'table',
177
242
  type: 'string',
178
- displayOptions: { show: { operation: ['insert', 'select', 'update', 'delete'] } },
243
+ displayOptions: {
244
+ show: {
245
+ operation: [
246
+ 'insert',
247
+ 'select',
248
+ 'update',
249
+ 'delete',
250
+ 'manageTables',
251
+ 'manageColumns',
252
+ ],
253
+ },
254
+ hide: {
255
+ operation: ['manageTables'],
256
+ tableAction: ['list'],
257
+ },
258
+ },
179
259
  default: '',
180
260
  required: true,
261
+ description: 'Name of the table',
181
262
  },
182
263
  // ------------------ Insert Options ------------------
183
264
  {
@@ -396,12 +477,25 @@ class SqliteSsh {
396
477
  // For rename: table param is OLD name, newTableName is NEW name
397
478
  // For drop: table param is table to drop
398
479
  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);
480
+ const columnsUi = this.getNodeParameter('columnsUi', i);
481
+ const columns = (columnsUi === null || columnsUi === void 0 ? void 0 : columnsUi.column) || [];
482
+ if (!columns.length) {
483
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one column is required to create a table', { itemIndex: i });
403
484
  }
404
- sql = `CREATE TABLE ${table} (${columnsDef});`;
485
+ const columnDefs = columns.map((col) => {
486
+ let def = `${escapeIdentifier(col.name)} ${col.type}`;
487
+ if (col.primaryKey) {
488
+ def += ' PRIMARY KEY';
489
+ if (col.autoIncrement && col.type === 'INTEGER')
490
+ def += ' AUTOINCREMENT';
491
+ }
492
+ if (col.notNull)
493
+ def += ' NOT NULL';
494
+ if (col.unique)
495
+ def += ' UNIQUE';
496
+ return def;
497
+ });
498
+ sql = `CREATE TABLE ${table} (${columnDefs.join(', ')});`;
405
499
  }
406
500
  else if (action === 'rename') {
407
501
  const newName = escapeIdentifier(this.getNodeParameter('newTableName', i));
@@ -441,8 +535,12 @@ class SqliteSsh {
441
535
  sql = 'VACUUM;';
442
536
  }
443
537
  const result = await ssh.execCommand(`${binaryPath} -json "${databasePath}" '${sql.replace(/'/g, "'\\''")}'`);
444
- if (result.code !== 0)
445
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), result.stderr || 'SQLite Error', { itemIndex: i });
538
+ if (result.code !== 0) {
539
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), result.stderr || 'SQLite Error', {
540
+ itemIndex: i,
541
+ description: `Query: ${sql}`,
542
+ });
543
+ }
446
544
  if (result.stdout) {
447
545
  try {
448
546
  const parsed = JSON.parse(result.stdout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rudsys/n8n-nodes-sqlite3",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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",