first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import type {
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
INodeCredentialTestResult,
|
||||
} from 'n8n-workflow';
|
||||
import type * as oracleDBTypes from 'oracledb';
|
||||
|
||||
import type { OracleDBNodeCredentials } from '../helpers/interfaces';
|
||||
import { configureOracleDB } from '../transport';
|
||||
|
||||
export async function oracleDBConnectionTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data as OracleDBNodeCredentials;
|
||||
|
||||
let pool: oracleDBTypes.Pool;
|
||||
|
||||
try {
|
||||
pool = await configureOracleDB.call(this, credentials, {});
|
||||
const conn = await pool.getConnection();
|
||||
await conn.close();
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
status: 'Error',
|
||||
message,
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Connection successful!',
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * as credentialTest from './credentialTest';
|
||||
export * as listSearch from './listSearch';
|
||||
export * as loadOptions from './loadOptions';
|
||||
export * as resourceMapping from './resourceMapping';
|
||||
@@ -0,0 +1,86 @@
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import type { ILoadOptionsFunctions, INodeListSearchResult } from 'n8n-workflow';
|
||||
import * as oracleDBTypes from 'oracledb';
|
||||
|
||||
import type { OracleDBNodeCredentials } from '../helpers/interfaces';
|
||||
import { configureOracleDB } from '../transport';
|
||||
|
||||
export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||
const credentials = await this.getCredentials<OracleDBNodeCredentials>('oracleDBApi');
|
||||
const options = { nodeVersion: this.getNode().typeVersion };
|
||||
|
||||
const pool: oracleDBTypes.Pool = await configureOracleDB.call(this, credentials, options);
|
||||
|
||||
let conn: oracleDBTypes.Connection | undefined;
|
||||
|
||||
try {
|
||||
conn = await pool.getConnection();
|
||||
|
||||
const response = await conn.execute<{ USERNAME: string }>(
|
||||
'SELECT username FROM all_users',
|
||||
[],
|
||||
{
|
||||
outFormat: oracleDBTypes.OUT_FORMAT_OBJECT,
|
||||
},
|
||||
);
|
||||
|
||||
const results =
|
||||
response.rows?.map((schema) => ({
|
||||
name: schema.USERNAME,
|
||||
value: schema.USERNAME,
|
||||
})) ?? [];
|
||||
|
||||
return { results };
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Failed to fetch schemas: ${error.message}`);
|
||||
} finally {
|
||||
if (conn) {
|
||||
await conn.close(); // Ensure connection is closed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||
const credentials = await this.getCredentials<OracleDBNodeCredentials>('oracleDBApi');
|
||||
const options = { nodeVersion: this.getNode().typeVersion };
|
||||
|
||||
const pool: oracleDBTypes.Pool = await configureOracleDB.call(this, credentials, options);
|
||||
|
||||
let conn: oracleDBTypes.Connection | undefined;
|
||||
|
||||
try {
|
||||
// Get the connection from the pool
|
||||
conn = await pool.getConnection();
|
||||
|
||||
// Retrieve the schema parameter
|
||||
const schema = this.getNodeParameter('schema', 0, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
// Execute the SQL query to fetch table names for the given schema
|
||||
const response = await conn.execute<{ TABLE_NAME: string }>(
|
||||
'SELECT table_name FROM all_tables WHERE owner = (:1)',
|
||||
[schema],
|
||||
{
|
||||
outFormat: oracleDBTypes.OUT_FORMAT_OBJECT, // Ensure that the response is in object format
|
||||
},
|
||||
);
|
||||
|
||||
// Map through the response.rows and format them
|
||||
const results =
|
||||
response.rows?.map((table) => ({
|
||||
name: table.TABLE_NAME,
|
||||
value: table.TABLE_NAME,
|
||||
})) ?? []; // Handle the case where rows might be undefined or empty
|
||||
|
||||
// Return the results in the required format
|
||||
return { results };
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Failed to fetch tables: ${error.message}`);
|
||||
} finally {
|
||||
// Ensure the connection is always closed
|
||||
if (conn) {
|
||||
await conn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
||||
import type * as oracleDBTypes from 'oracledb';
|
||||
|
||||
import type { OracleDBNodeCredentials } from '../helpers/interfaces';
|
||||
import { getColumnMetaData } from '../helpers/utils';
|
||||
import { configureOracleDB } from '../transport';
|
||||
|
||||
export async function getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const credentials = await this.getCredentials<OracleDBNodeCredentials>('oracleDBApi');
|
||||
const options = { nodeVersion: this.getNode().typeVersion };
|
||||
|
||||
const pool: oracleDBTypes.Pool = await configureOracleDB.call(this, credentials, options);
|
||||
|
||||
const schema = this.getNodeParameter('schema', 0, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const table = this.getNodeParameter('table', 0, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const columns = await getColumnMetaData(this.getNode(), pool, schema, table);
|
||||
|
||||
return columns.map((column) => ({
|
||||
name: column.columnName,
|
||||
value: column.columnName,
|
||||
description: `Type: ${column.dataType.toUpperCase()}, Nullable: ${column.isNullable}`,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function getColumnsMultiOptions(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData = await getColumns.call(this);
|
||||
const returnAll = { name: '*', value: '*', description: 'All columns' };
|
||||
return [returnAll, ...returnData];
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { ILoadOptionsFunctions, ResourceMapperFields, FieldType } from 'n8n-workflow';
|
||||
|
||||
import type { OracleDBNodeCredentials } from '../helpers/interfaces';
|
||||
import { getColumnMetaData, mapDbType } from '../helpers/utils';
|
||||
import { configureOracleDB } from '../transport';
|
||||
|
||||
export async function getMappingColumns(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<ResourceMapperFields> {
|
||||
const credentials = await this.getCredentials<OracleDBNodeCredentials>('oracleDBApi');
|
||||
|
||||
const pool = await configureOracleDB.call(this, credentials);
|
||||
|
||||
const schema = this.getNodeParameter('schema', 0, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const table = this.getNodeParameter('table', 0, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const columns = await getColumnMetaData(this.getNode(), pool, schema, table);
|
||||
const fields = columns.map((col) => {
|
||||
const type = mapDbType(col.dataType).n8nType as FieldType;
|
||||
const nullable = col.isNullable;
|
||||
const hasDefault = col.columnDefault === 'YES';
|
||||
const isGenerated = col.isGenerated === 'ALWAYS';
|
||||
|
||||
return {
|
||||
id: col.columnName,
|
||||
displayName: col.columnName,
|
||||
required: !nullable && !hasDefault && !isGenerated,
|
||||
display: true,
|
||||
type,
|
||||
defaultMatch: true,
|
||||
};
|
||||
});
|
||||
return { fields };
|
||||
}
|
||||
Reference in New Issue
Block a user