n8n-nodes-oracle11g 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.
@@ -0,0 +1,65 @@
1
+ class Oracle11gApi {
2
+ constructor() {
3
+ this.name = 'oracle11gApi';
4
+ this.displayName = 'Oracle 11g API';
5
+ this.properties = [
6
+ {
7
+ displayName: 'Host',
8
+ name: 'host',
9
+ type: 'string',
10
+ default: '',
11
+ required: true,
12
+ },
13
+ {
14
+ displayName: 'Port',
15
+ name: 'port',
16
+ type: 'number',
17
+ default: 1521,
18
+ required: true,
19
+ },
20
+ {
21
+ displayName: 'Database',
22
+ name: 'database',
23
+ type: 'string',
24
+ default: '',
25
+ required: true,
26
+ },
27
+ {
28
+ displayName: 'Username',
29
+ name: 'username',
30
+ type: 'string',
31
+ default: '',
32
+ required: true,
33
+ },
34
+ {
35
+ displayName: 'Password',
36
+ name: 'password',
37
+ type: 'string',
38
+ typeOptions: {
39
+ password: true,
40
+ },
41
+ default: '',
42
+ required: true,
43
+ },
44
+ {
45
+ displayName: 'Connection Type',
46
+ name: 'connectionType',
47
+ type: 'options',
48
+ options: [
49
+ {
50
+ name: 'Service Name',
51
+ value: 'service',
52
+ },
53
+ {
54
+ name: 'SID',
55
+ value: 'sid',
56
+ },
57
+ ],
58
+ default: 'service',
59
+ required: true,
60
+ },
61
+ ];
62
+ }
63
+ }
64
+
65
+ module.exports = { Oracle11gApi };
@@ -0,0 +1,67 @@
1
+ import {
2
+ ICredentialType,
3
+ INodeProperties,
4
+ } from 'n8n-workflow';
5
+
6
+ export class Oracle11gApi implements ICredentialType {
7
+ name = 'oracle11gApi';
8
+ displayName = 'Oracle 11g Database';
9
+ documentationUrl = 'https://docs.oracle.com/cd/B28359_01/server.111/b28318/toc.htm';
10
+ properties: INodeProperties[] = [
11
+ {
12
+ displayName: 'Host',
13
+ name: 'host',
14
+ type: 'string',
15
+ default: 'localhost',
16
+ required: true,
17
+ },
18
+ {
19
+ displayName: 'Port',
20
+ name: 'port',
21
+ type: 'number',
22
+ default: 1521,
23
+ required: true,
24
+ },
25
+ {
26
+ displayName: 'Service Name / SID',
27
+ name: 'database',
28
+ type: 'string',
29
+ default: '',
30
+ placeholder: 'ORCL or XE',
31
+ required: true,
32
+ },
33
+ {
34
+ displayName: 'Username',
35
+ name: 'username',
36
+ type: 'string',
37
+ default: '',
38
+ required: true,
39
+ },
40
+ {
41
+ displayName: 'Password',
42
+ name: 'password',
43
+ type: 'string',
44
+ typeOptions: {
45
+ password: true,
46
+ },
47
+ default: '',
48
+ required: true,
49
+ },
50
+ {
51
+ displayName: 'Connection Type',
52
+ name: 'connectionType',
53
+ type: 'options',
54
+ options: [
55
+ {
56
+ name: 'Service Name',
57
+ value: 'serviceName',
58
+ },
59
+ {
60
+ name: 'SID',
61
+ value: 'sid',
62
+ },
63
+ ],
64
+ default: 'serviceName',
65
+ },
66
+ ];
67
+ }
@@ -0,0 +1,7 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class Oracle11gApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Oracle11gApi = void 0;
4
+
5
+ class Oracle11gApi {
6
+ constructor() {
7
+ this.name = 'oracle11gApi';
8
+ this.displayName = 'Oracle 11g Database';
9
+ this.documentationUrl = 'https://docs.oracle.com/cd/B28359_01/server.111/b28318/toc.htm';
10
+ this.properties = [
11
+ {
12
+ displayName: 'Host',
13
+ name: 'host',
14
+ type: 'string',
15
+ default: 'localhost',
16
+ required: true,
17
+ },
18
+ {
19
+ displayName: 'Port',
20
+ name: 'port',
21
+ type: 'number',
22
+ default: 1521,
23
+ required: true,
24
+ },
25
+ {
26
+ displayName: 'Service Name / SID',
27
+ name: 'database',
28
+ type: 'string',
29
+ default: '',
30
+ placeholder: 'ORCL or XE',
31
+ required: true,
32
+ },
33
+ {
34
+ displayName: 'Username',
35
+ name: 'username',
36
+ type: 'string',
37
+ default: '',
38
+ required: true,
39
+ },
40
+ {
41
+ displayName: 'Password',
42
+ name: 'password',
43
+ type: 'string',
44
+ typeOptions: {
45
+ password: true,
46
+ },
47
+ default: '',
48
+ required: true,
49
+ },
50
+ {
51
+ displayName: 'Connection Type',
52
+ name: 'connectionType',
53
+ type: 'options',
54
+ options: [
55
+ {
56
+ name: 'Service Name',
57
+ value: 'serviceName',
58
+ },
59
+ {
60
+ name: 'SID',
61
+ value: 'sid',
62
+ },
63
+ ],
64
+ default: 'serviceName',
65
+ },
66
+ ];
67
+ }
68
+ }
69
+ exports.Oracle11gApi = Oracle11gApi;
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Oracle11g implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,100 @@
1
+ const { NodeOperationError } = require('n8n-workflow');
2
+ const oracledb = require('oracledb');
3
+
4
+ class Oracle11g {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: 'Oracle 11g Database',
8
+ name: 'oracle11g',
9
+ icon: 'fa:database',
10
+ group: ['input'],
11
+ version: 1,
12
+ description: 'Execute SQL queries on Oracle 11g database',
13
+ defaults: {
14
+ name: 'Oracle 11g Database',
15
+ },
16
+ inputs: ['main'],
17
+ outputs: ['main'],
18
+ credentials: [
19
+ {
20
+ name: 'oracle11gApi',
21
+ required: true,
22
+ },
23
+ ],
24
+ properties: [
25
+ {
26
+ displayName: 'Query',
27
+ name: 'query',
28
+ type: 'string',
29
+ typeOptions: {
30
+ rows: 5,
31
+ },
32
+ default: 'SELECT SYSDATE FROM DUAL',
33
+ placeholder: 'SELECT * FROM your_table',
34
+ description: 'SQL query to execute',
35
+ },
36
+ ],
37
+ };
38
+ }
39
+
40
+ async execute(executeFunctions) {
41
+ const items = executeFunctions.getInputData();
42
+ const returnData = [];
43
+
44
+ // Initialize Oracle client
45
+ try {
46
+ oracledb.initOracleClient({ libDir: '/oracle/instantclient_21_9' });
47
+ } catch (err) {
48
+ // Already initialized
49
+ }
50
+
51
+ for (let i = 0; i < items.length; i++) {
52
+ try {
53
+ const credentials = await executeFunctions.getCredentials('oracle11gApi');
54
+ const query = executeFunctions.getNodeParameter('query', i);
55
+
56
+ const connectString = `${credentials.host}:${credentials.port}/${credentials.database}`;
57
+
58
+ const connection = await oracledb.getConnection({
59
+ user: credentials.username,
60
+ password: credentials.password,
61
+ connectString,
62
+ });
63
+
64
+ const result = await connection.execute(query, [], {
65
+ outFormat: oracledb.OUT_FORMAT_OBJECT,
66
+ });
67
+
68
+ if (result.rows && Array.isArray(result.rows)) {
69
+ for (const row of result.rows) {
70
+ returnData.push({
71
+ json: row,
72
+ pairedItem: { item: i },
73
+ });
74
+ }
75
+ } else {
76
+ returnData.push({
77
+ json: { success: true, rowsAffected: result.rowsAffected || 0 },
78
+ pairedItem: { item: i },
79
+ });
80
+ }
81
+
82
+ await connection.close();
83
+
84
+ } catch (error) {
85
+ if (executeFunctions.continueOnFail()) {
86
+ returnData.push({
87
+ json: { error: error.message },
88
+ pairedItem: { item: i },
89
+ });
90
+ continue;
91
+ }
92
+ throw new NodeOperationError(executeFunctions.getNode(), error, { itemIndex: i });
93
+ }
94
+ }
95
+
96
+ return [returnData];
97
+ }
98
+ }
99
+
100
+ module.exports = { Oracle11g };
Binary file
@@ -0,0 +1,78 @@
1
+ const { NodeOperationError } = require('n8n-workflow');
2
+
3
+ class Oracle11g {
4
+ constructor() {
5
+ this.description = {
6
+ displayName: 'Oracle 11g',
7
+ name: 'oracle11g',
8
+ icon: 'fa:database',
9
+ group: ['input'],
10
+ version: 1,
11
+ description: 'Execute SQL queries on Oracle 11g database',
12
+ defaults: {
13
+ name: 'Oracle 11g',
14
+ },
15
+ inputs: ['main'],
16
+ outputs: ['main'],
17
+ credentials: [
18
+ {
19
+ name: 'oracle11gApi',
20
+ required: true,
21
+ },
22
+ ],
23
+ properties: [
24
+ {
25
+ displayName: 'SQL Query',
26
+ name: 'query',
27
+ type: 'string',
28
+ typeOptions: {
29
+ rows: 5,
30
+ },
31
+ default: 'SELECT SYSDATE FROM dual',
32
+ required: true,
33
+ description: 'SQL query to execute',
34
+ },
35
+ ],
36
+ };
37
+ }
38
+
39
+ async execute(executeFunctions) {
40
+ const items = executeFunctions.getInputData();
41
+ const returnData = [];
42
+ const oracledb = require('oracledb');
43
+
44
+ for (let i = 0; i < items.length; i++) {
45
+ try {
46
+ const credentials = await executeFunctions.getCredentials('oracle11gApi');
47
+ const query = executeFunctions.getNodeParameter('query', i);
48
+
49
+ const connectionString = credentials.connectionType === 'service'
50
+ ? credentials.host + ':' + credentials.port + '/' + credentials.database
51
+ : credentials.host + ':' + credentials.port + ':' + credentials.database;
52
+
53
+ const connection = await oracledb.getConnection({
54
+ user: credentials.username,
55
+ password: credentials.password,
56
+ connectString: connectionString,
57
+ });
58
+
59
+ const result = await connection.execute(query);
60
+ await connection.close();
61
+
62
+ returnData.push({
63
+ json: {
64
+ query,
65
+ result: result.rows,
66
+ columns: result.metaData ? result.metaData.map(col => col.name) : [],
67
+ },
68
+ });
69
+ } catch (error) {
70
+ throw new NodeOperationError(executeFunctions.getNode(), error, { itemIndex: i });
71
+ }
72
+ }
73
+
74
+ return [returnData];
75
+ }
76
+ }
77
+
78
+ module.exports = { Oracle11g };
@@ -0,0 +1,295 @@
1
+ import {
2
+ IExecuteFunctions,
3
+ INodeExecutionData,
4
+ INodeType,
5
+ INodeTypeDescription,
6
+ NodeOperationError,
7
+ } from 'n8n-workflow';
8
+
9
+ import * as oracledb from 'oracledb';
10
+
11
+ export class Oracle11g implements INodeType {
12
+ description: INodeTypeDescription = {
13
+ displayName: 'Oracle 11g Database',
14
+ name: 'oracle11g',
15
+ icon: 'file:oracle.svg',
16
+ group: ['input', 'output'],
17
+ version: 1,
18
+ description: 'Execute SQL queries on Oracle 11g database',
19
+ defaults: {
20
+ name: 'Oracle 11g',
21
+ },
22
+ inputs: ['main'],
23
+ outputs: ['main'],
24
+ credentials: [
25
+ {
26
+ name: 'oracle11gApi',
27
+ required: true,
28
+ },
29
+ ],
30
+ properties: [
31
+ {
32
+ displayName: 'Operation',
33
+ name: 'operation',
34
+ type: 'options',
35
+ noDataExpression: true,
36
+ options: [
37
+ {
38
+ name: 'Execute Query',
39
+ value: 'executeQuery',
40
+ description: 'Execute a SQL query and return results',
41
+ action: 'Execute a SQL query',
42
+ },
43
+ {
44
+ name: 'Insert',
45
+ value: 'insert',
46
+ description: 'Insert data into table',
47
+ action: 'Insert data into table',
48
+ },
49
+ {
50
+ name: 'Update',
51
+ value: 'update',
52
+ description: 'Update data in table',
53
+ action: 'Update data in table',
54
+ },
55
+ ],
56
+ default: 'executeQuery',
57
+ },
58
+ {
59
+ displayName: 'Query',
60
+ name: 'query',
61
+ type: 'string',
62
+ displayOptions: {
63
+ show: {
64
+ operation: ['executeQuery'],
65
+ },
66
+ },
67
+ typeOptions: {
68
+ editor: 'sqlEditor',
69
+ rows: 5,
70
+ },
71
+ default: 'SELECT SYSDATE FROM DUAL',
72
+ placeholder: 'SELECT * FROM your_table WHERE condition = :value',
73
+ description: 'SQL query to execute. Use :paramName for parameters.',
74
+ },
75
+ {
76
+ displayName: 'Table',
77
+ name: 'table',
78
+ type: 'string',
79
+ displayOptions: {
80
+ show: {
81
+ operation: ['insert', 'update'],
82
+ },
83
+ },
84
+ default: '',
85
+ placeholder: 'TABLE_NAME',
86
+ description: 'Name of the table',
87
+ },
88
+ {
89
+ displayName: 'Columns',
90
+ name: 'columns',
91
+ type: 'string',
92
+ displayOptions: {
93
+ show: {
94
+ operation: ['insert'],
95
+ },
96
+ },
97
+ default: '',
98
+ placeholder: 'column1, column2, column3',
99
+ description: 'Comma-separated list of column names',
100
+ },
101
+ {
102
+ displayName: 'Values',
103
+ name: 'values',
104
+ type: 'string',
105
+ displayOptions: {
106
+ show: {
107
+ operation: ['insert'],
108
+ },
109
+ },
110
+ default: '',
111
+ placeholder: ':value1, :value2, :value3',
112
+ description: 'Comma-separated list of values (use :paramName for parameters)',
113
+ },
114
+ {
115
+ displayName: 'Set Clause',
116
+ name: 'setClause',
117
+ type: 'string',
118
+ displayOptions: {
119
+ show: {
120
+ operation: ['update'],
121
+ },
122
+ },
123
+ default: '',
124
+ placeholder: 'column1 = :value1, column2 = :value2',
125
+ description: 'SET clause for UPDATE (use :paramName for parameters)',
126
+ },
127
+ {
128
+ displayName: 'Where Clause',
129
+ name: 'whereClause',
130
+ type: 'string',
131
+ displayOptions: {
132
+ show: {
133
+ operation: ['update'],
134
+ },
135
+ },
136
+ default: '',
137
+ placeholder: 'id = :id',
138
+ description: 'WHERE clause for UPDATE (use :paramName for parameters)',
139
+ },
140
+ {
141
+ displayName: 'Parameters',
142
+ name: 'parameters',
143
+ type: 'fixedCollection',
144
+ typeOptions: {
145
+ multipleValues: true,
146
+ },
147
+ default: {},
148
+ placeholder: 'Add Parameter',
149
+ description: 'Parameters for the SQL query',
150
+ options: [
151
+ {
152
+ name: 'parameter',
153
+ displayName: 'Parameter',
154
+ values: [
155
+ {
156
+ displayName: 'Name',
157
+ name: 'name',
158
+ type: 'string',
159
+ default: '',
160
+ placeholder: 'paramName',
161
+ description: 'Parameter name (without :)',
162
+ },
163
+ {
164
+ displayName: 'Value',
165
+ name: 'value',
166
+ type: 'string',
167
+ default: '',
168
+ description: 'Parameter value',
169
+ },
170
+ ],
171
+ },
172
+ ],
173
+ },
174
+ ],
175
+ };
176
+
177
+ async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
178
+ const items = this.getInputData();
179
+ const returnData: INodeExecutionData[] = [];
180
+
181
+ // Initialize Oracle client in thick mode
182
+ try {
183
+ oracledb.initOracleClient({ libDir: '/oracle/instantclient_21_9' });
184
+ } catch (err) {
185
+ // Already initialized
186
+ }
187
+
188
+ for (let i = 0; i < items.length; i++) {
189
+ try {
190
+ const credentials = await this.getCredentials('oracle11gApi');
191
+ const operation = this.getNodeParameter('operation', i) as string;
192
+
193
+ // Build connection string
194
+ const connectionType = credentials.connectionType as string;
195
+ let connectString: string;
196
+
197
+ if (connectionType === 'sid') {
198
+ connectString = `${credentials.host}:${credentials.port}:${credentials.database}`;
199
+ } else {
200
+ connectString = `${credentials.host}:${credentials.port}/${credentials.database}`;
201
+ }
202
+
203
+ const connectionConfig: oracledb.ConnectionAttributes = {
204
+ user: credentials.username as string,
205
+ password: credentials.password as string,
206
+ connectString,
207
+ };
208
+
209
+ let connection: oracledb.Connection;
210
+
211
+ try {
212
+ connection = await oracledb.getConnection(connectionConfig);
213
+
214
+ let query = '';
215
+ let bindParams: any = {};
216
+
217
+ // Build parameters
218
+ const parameters = this.getNodeParameter('parameters', i) as any;
219
+ if (parameters.parameter) {
220
+ for (const param of parameters.parameter) {
221
+ bindParams[param.name] = param.value;
222
+ }
223
+ }
224
+
225
+ // Build query based on operation
226
+ if (operation === 'executeQuery') {
227
+ query = this.getNodeParameter('query', i) as string;
228
+ } else if (operation === 'insert') {
229
+ const table = this.getNodeParameter('table', i) as string;
230
+ const columns = this.getNodeParameter('columns', i) as string;
231
+ const values = this.getNodeParameter('values', i) as string;
232
+ query = `INSERT INTO ${table} (${columns}) VALUES (${values})`;
233
+ } else if (operation === 'update') {
234
+ const table = this.getNodeParameter('table', i) as string;
235
+ const setClause = this.getNodeParameter('setClause', i) as string;
236
+ const whereClause = this.getNodeParameter('whereClause', i) as string;
237
+ query = `UPDATE ${table} SET ${setClause}`;
238
+ if (whereClause) {
239
+ query += ` WHERE ${whereClause}`;
240
+ }
241
+ }
242
+
243
+ const result = await connection.execute(query, bindParams, {
244
+ outFormat: oracledb.OUT_FORMAT_OBJECT,
245
+ fetchArraySize: 100,
246
+ });
247
+
248
+ if (operation === 'executeQuery' && result.rows && Array.isArray(result.rows)) {
249
+ for (const row of result.rows) {
250
+ returnData.push({
251
+ json: row as any,
252
+ pairedItem: { item: i },
253
+ });
254
+ }
255
+ } else {
256
+ // For INSERT/UPDATE operations
257
+ returnData.push({
258
+ json: {
259
+ operation,
260
+ rowsAffected: result.rowsAffected || 0,
261
+ success: true,
262
+ },
263
+ pairedItem: { item: i },
264
+ });
265
+ }
266
+
267
+ await connection.close();
268
+ } catch (error) {
269
+ if (connection!) {
270
+ await connection.close();
271
+ }
272
+ throw error;
273
+ }
274
+
275
+ } catch (error) {
276
+ if (this.continueOnFail()) {
277
+ returnData.push({
278
+ json: {
279
+ error: error.message,
280
+ },
281
+ pairedItem: {
282
+ item: i,
283
+ },
284
+ });
285
+ continue;
286
+ }
287
+ throw new NodeOperationError(this.getNode(), error as Error, {
288
+ itemIndex: i,
289
+ });
290
+ }
291
+ }
292
+
293
+ return [returnData];
294
+ }
295
+ }
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "n8n-nodes-oracle11g",
3
+ "version": "1.0.0",
4
+ "description": "Oracle 11g node for n8n",
5
+ "main": "index.js",
6
+ "n8n": {
7
+ "nodes": ["nodes/Oracle11g/Oracle11g.node.js"],
8
+ "credentials": ["credentials/Oracle11gApi.credentials.js"]
9
+ },
10
+ "dependencies": {
11
+ "oracledb": "^6.0.0"
12
+ }
13
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2019",
4
+ "module": "commonjs",
5
+ "lib": ["es2019"],
6
+ "declaration": true,
7
+ "outDir": "./dist",
8
+ "rootDir": "./",
9
+ "strict": true,
10
+ "noUnusedLocals": true,
11
+ "noUnusedParameters": true,
12
+ "noImplicitReturns": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "moduleResolution": "node",
15
+ "allowSyntheticDefaultImports": true,
16
+ "esModuleInterop": true,
17
+ "experimentalDecorators": true,
18
+ "emitDecoratorMetadata": true,
19
+ "skipLibCheck": true,
20
+ "forceConsistentCasingInFileNames": true,
21
+ "resolveJsonModule": true
22
+ },
23
+ "include": [
24
+ "credentials/**/*",
25
+ "nodes/**/*"
26
+ ],
27
+ "exclude": [
28
+ "dist",
29
+ "node_modules",
30
+ "**/*.test.ts"
31
+ ]
32
+ }