@rudsys/n8n-nodes-sqlite3 0.1.5 → 0.1.6

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
  {
@@ -396,12 +461,25 @@ class SqliteSsh {
396
461
  // For rename: table param is OLD name, newTableName is NEW name
397
462
  // For drop: table param is table to drop
398
463
  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);
464
+ const columnsUi = this.getNodeParameter('columnsUi', i);
465
+ const columns = (columnsUi === null || columnsUi === void 0 ? void 0 : columnsUi.column) || [];
466
+ if (!columns.length) {
467
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one column is required to create a table', { itemIndex: i });
403
468
  }
404
- sql = `CREATE TABLE ${table} (${columnsDef});`;
469
+ const columnDefs = columns.map((col) => {
470
+ let def = `${escapeIdentifier(col.name)} ${col.type}`;
471
+ if (col.primaryKey) {
472
+ def += ' PRIMARY KEY';
473
+ if (col.autoIncrement && col.type === 'INTEGER')
474
+ def += ' AUTOINCREMENT';
475
+ }
476
+ if (col.notNull)
477
+ def += ' NOT NULL';
478
+ if (col.unique)
479
+ def += ' UNIQUE';
480
+ return def;
481
+ });
482
+ sql = `CREATE TABLE ${table} (${columnDefs.join(', ')});`;
405
483
  }
406
484
  else if (action === 'rename') {
407
485
  const newName = escapeIdentifier(this.getNodeParameter('newTableName', i));
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.6",
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",