From 2e2f61f7561ed7506c8ec3f9348c4c8562901c41 Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 15:58:54 +0530 Subject: [PATCH 01/16] added direct path load, pipeline & explicit resource management type changes --- types/oracledb/index.d.ts | 358 +++++++++++++++++++++++++++++++ types/oracledb/oracledb-tests.ts | 40 ++++ 2 files changed, 398 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index c2fa4cb95a70e9..46fd0a5d9b4f0a 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -1364,6 +1364,14 @@ declare namespace OracleDB { close(options: CloseConnectionOptions, callback: (error: DBError | null) => void): void; close(callback: (error: DBError | null) => void): void; + /** + * Implements Explicit Resource Management. Equivalent to calling + * connection.close(). + * + * @since 7.0 + */ + [Symbol.asyncDispose](): Promise; + /** * This call commits the current transaction in progress on the connection. */ @@ -1399,6 +1407,47 @@ declare namespace OracleDB { * @see https://node-oracledb.readthedocs.io/en/latest/user_guide/json_data_type.html#osontype */ decodeOSON(buf: Buffer): any; + + /** + * Performs a direct path load into the specified table. + * + * This method can only be used in node-oracledb Thin mode. + * + * @param schema The name of the database schema. + * @param table The name of the table into which data is to be loaded. + * @param columns The names of the columns to be populated. + * @param data The data to be loaded. + * + * @since 7.0 + */ + directPathLoad( + schema: string, + table: string, + columns: DirectPathLoadColumns, + data: DirectPathLoadData, + ): Promise; + /** + * Performs a direct path load into the specified table. + * + * This method can only be used in node-oracledb Thin mode. + * + * @param schema The name of the database schema. + * @param table The name of the table into which data is to be loaded. + * @param columns The names of the columns to be populated. + * @param data The data to be loaded. + * @param callback If directPathLoad() succeeds, error is NULL. + * If an error occurs, error contains the error message. + * + * @since 7.0 + */ + directPathLoad( + schema: string, + table: string, + columns: DirectPathLoadColumns, + data: DirectPathLoadData, + callback: (error: DBError | null) => void, + ): void; + /** * This synchronous method encodes a JavaScript value to OSON bytes and returns a Buffer. This method is useful for inserting OSON bytes directly into BLOB columns that have the check constraint IS JSON FORMAT OSON enabled. * @@ -1698,6 +1747,65 @@ declare namespace OracleDB { rollback(): Promise; rollback(callback: (error: DBError | null) => void): void; + /** + * Runs all of the operations in a pipeline and returns an array of + * results, each entry corresponding to an operation executed in the + * pipeline. + * + * @param pipeline The pipeline to be run. + * @param continueOnError Determines whether operations should continue + * to run after an error has occurred. + * If true, errors are stored as a corresponding pipeline operation result. + * If false, an error is raised as soon as it occurs and subsequent + * operations are terminated. + * Default is false. + * + * @since 7.0 + */ + runPipeline( + pipeline: Pipeline, + continueOnError?: boolean, + ): Promise; + /** + * Runs all of the operations in a pipeline and invokes the callback with + * the results. + * + * @param pipeline The pipeline to be run. + * @param continueOnError Determines whether operations should continue + * to run after an error has occurred. + * @param callback Callback where error is NULL on success, otherwise + * contains the error message; results is the array that contains the + * results of the executed pipeline operations. + * + * @since 7.0 + */ + runPipeline( + pipeline: Pipeline, + continueOnError: boolean, + callback: ( + error: DBError | null, + results: PipelineOperationResult[], + ) => void, + ): void; + /** + * Runs all of the operations in a pipeline and invokes the callback with + * the results. + * + * @param pipeline The pipeline to be run. + * @param callback Callback where error is NULL on success, otherwise + * contains the error message; results is the array that contains the + * results of the executed pipeline operations. + * + * @since 7.0 + */ + runPipeline( + pipeline: Pipeline, + callback: ( + error: DBError | null, + results: PipelineOperationResult[], + ) => void, + ): void; + /** * Used to shut down a database instance. This is the flexible version of oracledb.shutdown(), allowing more control over behavior. * @@ -2347,6 +2455,240 @@ declare namespace OracleDB { stack?: string; } + /** + * The names of table columns populated by directPathLoad(). + * Each entry corresponds to a target column in the destination table. + * + * @since 7.0 + */ + type DirectPathLoadColumns = Array; + + /** + * Data supplied to directPathLoad(). + * This is an array of rows, where each row is an array of column values. + * + * @since 7.0 + */ + type DirectPathLoadData = Array>; + + /** + * Bind values supplied to pipeline operations. + * This can be an object for bind-by-name or an array for bind-by-position. + * + * @since 7.0 + */ + type PipelineBindParameters = BindParameters; + /** + * Bind values supplied to pipeline addExecuteMany(). + * This should be an array of bind-by-name objects or bind-by-position + * arrays. + * + * @since 7.0 + */ + type PipelineExecuteManyBindParameters = BindParameters[]; + + /** + * Options supported in pipeline addExecute(), addFetchAll(), + * addFetchMany(), and addFetchOne(). + * + * @since 7.0 + */ + interface PipelineExecuteOptions { + /** + * Determines whether a commit occurs at the end of statement execution. + */ + autoCommit?: boolean | undefined; + /** + * The size of the internal buffer used for fetching query rows. + */ + fetchArraySize?: number | undefined; + /** + * The maximum number of rows that are fetched from a query. + */ + maxRows?: number | undefined; + /** + * The format of query rows, such as OUT_FORMAT_ARRAY or + * OUT_FORMAT_OBJECT. + */ + outFormat?: number | undefined; + /** + * The number of rows prefetched from Oracle Database. + */ + prefetchRows?: number | undefined; + } + + /** + * Options supported in pipeline addExecuteMany(). + * + * @since 7.0 + */ + interface PipelineExecuteManyOptions extends PipelineExecuteOptions { + /** + * Bind variable definitions for array DML operations. + */ + bindDefs?: Record | BindDefinition[] | undefined; + } + + /** + * Result object for each pipeline operation. + * + * @since 7.0 + */ + interface PipelineOperationResult { + /** + * Defined if the statement executed in the operation returned implicit + * results. + */ + implicitResults?: any[] | undefined; + /** + * Error encountered when running the operation. + * Only available if continueOnError is true. + */ + error?: DBError | undefined; + /** + * ROWID of a row affected by DML. + * If multiple rows were affected, this is the last ROWID. + */ + lastRowid?: string | undefined; + /** + * Array describing each column in a query executed by the operation. + */ + metaData?: Array> | undefined; + /** + * Array or object containing output values of OUT and IN OUT binds used + * in an operation. + */ + outBinds?: Record | any[] | undefined; + /** + * Array containing the rows fetched by the operation, if a query was + * executed. + */ + rows?: any[] | undefined; + /** + * Number of rows affected by the operation. + */ + rowsAffected?: number | undefined; + /** + * Warning encountered when running the operation. + */ + warning?: DBError | undefined; + } + + /** + * Pipeline objects represent a list of operations to be executed by + * connection.runPipeline(). + * + * @since 7.0 + */ + class Pipeline { + constructor(); + /** + * Adds a commit operation to the pipeline. + */ + addCommit(): void; + /** + * Adds an execute operation to the pipeline. + * + * @param statement The SQL statement to be executed. + * @param parameters The values or variables to be bound to the executed + * statement. + * @param options Optional parameter that may be used to control statement + * execution. + */ + addExecute( + statement: string, + parameters?: PipelineBindParameters, + options?: PipelineExecuteOptions, + ): void; + /** + * Adds an executeMany operation to the pipeline. + * + * @param statement The SQL or PL/SQL statement to be executed. + * @param parameters The values or variables to be bound to the executed + * statement. It must be an array of arrays (for bind by position) or an + * array of objects whose keys match the bind variable names in the SQL + * statement (for bind by name). + * @param options Optional parameter that may be used to control statement + * execution. + */ + addExecuteMany( + statement: string, + parameters: PipelineExecuteManyBindParameters, + options?: PipelineExecuteManyOptions, + ): void; + /** + * Adds an executeMany operation to the pipeline with a specified number + * of iterations when using previously-bound values. + * + * @param statement The SQL or PL/SQL statement to be executed. + * @param numIterations The number of iterations. + * @param options Optional parameter that may be used to control statement + * execution. + */ + addExecuteMany( + statement: string, + numIterations: number, + options?: PipelineExecuteManyOptions, + ): void; + /** + * Adds a fetch operation to the pipeline that returns all rows. + * + * @param statement The SQL or PL/SQL statement to be executed. + * @param parameters The values or variables to be bound to the executed + * statement. + * @param options Optional parameter that may be used to control statement + * execution. + * @param fetchArraySize The size of an internal buffer used for fetching + * query rows from Oracle Database. + * @param fetchLobs Determines whether to return LOB objects, or string or + * buffer values when fetching LOB columns. Default is true. + */ + addFetchAll( + statement: string, + parameters?: PipelineBindParameters, + options?: PipelineExecuteOptions, + fetchArraySize?: number, + fetchLobs?: boolean, + ): void; + /** + * Adds a fetch operation to the pipeline that returns up to numRows rows. + * + * @param statement The SQL or PL/SQL statement to be executed. + * @param parameters The values or variables to be bound to the executed + * statement. + * @param options Optional parameter that may be used to control statement + * execution. + * @param numRows The number of rows to be fetched. + * Default is the value of oracledb.fetchArraySize. + * @param fetchLobs Determines whether to return LOB objects, or string or + * buffer values when fetching LOB columns. Default is true. + */ + addFetchMany( + statement: string, + parameters?: PipelineBindParameters, + options?: PipelineExecuteOptions, + numRows?: number, + fetchLobs?: boolean, + ): void; + /** + * Adds a fetch operation to the pipeline that returns at most one row. + * + * @param statement The SQL or PL/SQL statement to be executed. + * @param parameters The values or variables to be bound to the executed + * statement. + * @param options Optional parameter that may be used to control statement + * execution. + * @param fetchLobs Determines whether to return LOB objects, or string or + * buffer values when fetching LOB columns. Default is true. + */ + addFetchOne( + statement: string, + parameters?: PipelineBindParameters, + options?: PipelineExecuteOptions, + fetchLobs?: boolean, + ): void; + } + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type type ResultCallback = (...args: [DBError] | [null, T]) => void; @@ -2888,6 +3230,14 @@ declare namespace OracleDB { close(drainTime: number, callback: (error: DBError | null) => void): void; close(callback: (error: DBError | null) => void): void; + /** + * Implements Explicit Resource Management. Equivalent to calling + * pool.close(). + * + * @since 7.0 + */ + [Symbol.asyncDispose](): Promise; + /** * This method obtains a connection from the connection pool. * @@ -3933,6 +4283,14 @@ declare namespace OracleDB { close(): Promise; close(callback: (error: DBError | null) => void): void; + /** + * Implements Explicit Resource Management. Equivalent to calling + * resultSet.close(). + * + * @since 7.0 + */ + [Symbol.asyncDispose](): Promise; + /** * This call fetches one row of the ResultSet as an object or an array of column values, * depending on the value of outFormat. diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index a84d75544dd064..c03c363eced877 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -911,3 +911,43 @@ export const version6_10Tests = async (): Promise => { const messages = await queue.deqMany(5); }; + +export const version7Tests = async (): Promise => { + const connection = await oracledb.getConnection({ + user: "test", + }); + + const columns: oracledb.DirectPathLoadColumns = ["ID", "NAME"]; + const data: oracledb.DirectPathLoadData = [ + [1, "first"], + [2, "second"], + ]; + await connection.directPathLoad("TEST_SCHEMA", "TEST_TABLE", columns, data); + connection.directPathLoad("TEST_SCHEMA", "TEST_TABLE", columns, data, error => { + expectType(error); + }); + + const pipeline = new oracledb.Pipeline(); + pipeline.addExecute("insert into test_table values (:1)", [1]); + pipeline.addExecuteMany("insert into test_table values (:1)", [[1], [2]]); + pipeline.addFetchAll("select * from test_table", [], { outFormat: oracledb.OUT_FORMAT_OBJECT }, 50, true); + pipeline.addFetchMany("select * from test_table", [], { outFormat: oracledb.OUT_FORMAT_OBJECT }, 10, false); + pipeline.addFetchOne( + "select * from test_table where id = :1", + [1], + { outFormat: oracledb.OUT_FORMAT_OBJECT }, + false, + ); + pipeline.addCommit(); + + const pipelineResults = await connection.runPipeline(pipeline, true); + expectType(pipelineResults); + connection.runPipeline(pipeline, (error, results) => { + expectType(error); + expectType(results); + }); + connection.runPipeline(pipeline, true, (error, results) => { + expectType(error); + expectType(results); + }); +}; From 05153753e41c8eff7ea2fd1ad3c1a041f0c3ef1c Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 16:37:56 +0530 Subject: [PATCH 02/16] added application context type changes --- types/oracledb/index.d.ts | 27 +++++++++++++++++++++++++++ types/oracledb/oracledb-tests.ts | 9 +++++++++ 2 files changed, 36 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 46fd0a5d9b4f0a..833bcf79bc3597 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -1296,6 +1296,19 @@ declare namespace OracleDB { * @since 6.3 */ readonly warning?: DBError | undefined; + /** + * This synchronous method sets application context key-value pairs for + * the given namespace. + * + * The namespace "CLIENTCONTEXT" is reserved for client + * session-based application contexts. + * + * @param namespaceName The application context namespace. + * @param keyValues The key-value entries to set. + * + * @since 7.0 + */ + appContext(namespaceName: string, keyValues: AppContextKeyValue[]): void; /** * Begins a new sessionless transaction using the specified transaction identifier. * This method returns the transaction identifier specified by the user or generated by node-oracledb as a Buffer value. @@ -1341,6 +1354,15 @@ declare namespace OracleDB { newPassword: string, callback: (error: DBError | null) => void, ): void; + /** + * This synchronous method clears all application context key-value + * pairs for the given namespace. + * + * @param namespaceName The application context namespace. + * + * @since 7.0 + */ + clearAppContext(namespaceName: string): void; /** * Releases a connection. @@ -2055,6 +2077,11 @@ declare namespace OracleDB { profile: string; configFileLocation: string; } + /** + * A key-value entry used by connection.appContext(). + * Each entry should represent one context attribute assignment. + */ + type AppContextKeyValue = Record; type AppContextOpts = [string, string, string]; /** * Provides connection credentials and connection-specific configuration properties. diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index c03c363eced877..1bf85c527957ca 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -917,6 +917,15 @@ export const version7Tests = async (): Promise => { user: "test", }); + const appCtx: oracledb.AppContextKeyValue[] = [ + { traceCtx: "12" }, + { version: "1" }, + ]; + connection.appContext("CLIENTCONTEXT", appCtx); + connection.clearAppContext("CLIENTCONTEXT"); + // @ts-expect-error + connection.appContext("CLIENTCONTEXT", [{ traceCtx: 12 }]); + const columns: oracledb.DirectPathLoadColumns = ["ID", "NAME"]; const data: oracledb.DirectPathLoadData = [ [1, "first"], From cfa77207f23abe0ab3c19b19f722e267bafb9008 Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 18:58:26 +0530 Subject: [PATCH 03/16] added thickModeDSNPassthrough boolean , pdbName & dbUniqueName strings & lob.trim() method to types --- types/oracledb/index.d.ts | 43 ++++++++++++++++++++++++++++++++ types/oracledb/oracledb-tests.ts | 12 +++++++++ 2 files changed, 55 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 833bcf79bc3597..513c580dfbbfdc 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -915,6 +915,18 @@ declare namespace OracleDB { * The value that is displayed for the connection.thin, pool.thin, and oracledb.thin attributes will be the same. */ let thin: boolean; + /** + * This property is a boolean that determines whether connect strings in + * node-oracledb Thick mode are passed unchanged to Oracle Client libraries + * or parsed by node-oracledb. + * + * This property must be set before creating the first standalone + * connection or pool. + * + * @default true + * @since 7.0 + */ + let thickModeDSNPassthrough: boolean; /** * This readonly property gives a numeric representation of the node-oracledb version. * For version x.y.z, this property gives the number: (10000 * x) + (100 * y) + z @@ -1150,6 +1162,16 @@ declare namespace OracleDB { * @since 4.1 */ dbOp?: string | undefined; + /** + * This read-only property is a string that identifies a globally + * unique name for the database. This property returns the same value + * as the SQL expression: + * SELECT UPPER(SYS_CONTEXT('USERENV', 'DB_UNIQUE_NAME')) FROM DUAL; + * Available only in node-oracledb Thin mode. + * + * @since 7.0 + */ + readonly dbUniqueName?: string | undefined; /** * This write-only property is a string that sets the execution context identifier. * The value is available in the ECID column of the V$SESSION view. It is also shown in audit logs. @@ -1217,6 +1239,15 @@ declare namespace OracleDB { * @since 2.2 */ readonly oracleServerVersionString: string; + /** + * This read-only property is a string that identifies the name of the + * pluggable database associated with the connection. This property + * returns the same value as the SQL expression: + * SELECT UPPER(SYS_CONTEXT('USERENV', 'CON_NAME')) FROM DUAL; + * + * @since 7.0 + */ + readonly pdbName?: string | undefined; /** * This read-only property identifies the port to which the client is connected. * Available only in node-oracledb Thin mode. @@ -3038,6 +3069,18 @@ declare namespace OracleDB { amount: number, callback: ResultCallback, ): void; + /** + * Trims the non-BFILE LOB to the specified size. + * + * If newSize is omitted, the LOB is trimmed to size 0. + * Values greater than or equal to 2^32 are not supported. + * + * @param newSize The size to which the LOB is to be trimmed. + * + * @since 7.0 + */ + trim(newSize?: number): Promise; + trim(callback: (error: DBError | null) => void): void; } /** diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index 1bf85c527957ca..e5f54faf3f67ad 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -913,9 +913,14 @@ export const version6_10Tests = async (): Promise => { }; export const version7Tests = async (): Promise => { + defaultOracledb.thickModeDSNPassthrough = false; + expectType(defaultOracledb.thickModeDSNPassthrough); + const connection = await oracledb.getConnection({ user: "test", }); + expectType(connection.pdbName); + expectType(connection.dbUniqueName); const appCtx: oracledb.AppContextKeyValue[] = [ { traceCtx: "12" }, @@ -936,6 +941,13 @@ export const version7Tests = async (): Promise => { expectType(error); }); + const lob = await connection.createLob(oracledb.CLOB); + await lob.trim(); + await lob.trim(10); + lob.trim(error => { + expectType(error); + }); + const pipeline = new oracledb.Pipeline(); pipeline.addExecute("insert into test_table values (:1)", [1]); pipeline.addExecuteMany("insert into test_table values (:1)", [[1], [2]]); From 14f0688990145634575871866f7d61a6203d2349 Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 19:18:54 +0530 Subject: [PATCH 04/16] enrich some comments --- types/oracledb/index.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 513c580dfbbfdc..879a6036b6016d 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -1465,6 +1465,7 @@ declare namespace OracleDB { * Performs a direct path load into the specified table. * * This method can only be used in node-oracledb Thin mode. + * It is not supported for BFILE data. * * @param schema The name of the database schema. * @param table The name of the table into which data is to be loaded. @@ -1483,6 +1484,7 @@ declare namespace OracleDB { * Performs a direct path load into the specified table. * * This method can only be used in node-oracledb Thin mode. + * It is not supported for BFILE data. * * @param schema The name of the database schema. * @param table The name of the table into which data is to be loaded. @@ -1805,6 +1807,10 @@ declare namespace OracleDB { * results, each entry corresponding to an operation executed in the * pipeline. * + * True pipelining requires Oracle AI Database 26ai (or later) in Thin + * mode. In Thick mode or older database versions, operations are + * executed sequentially. + * * @param pipeline The pipeline to be run. * @param continueOnError Determines whether operations should continue * to run after an error has occurred. @@ -1823,6 +1829,10 @@ declare namespace OracleDB { * Runs all of the operations in a pipeline and invokes the callback with * the results. * + * True pipelining requires Oracle AI Database 26ai (or later) in Thin + * mode. In Thick mode or older database versions, operations are + * executed sequentially. + * * @param pipeline The pipeline to be run. * @param continueOnError Determines whether operations should continue * to run after an error has occurred. @@ -1844,6 +1854,10 @@ declare namespace OracleDB { * Runs all of the operations in a pipeline and invokes the callback with * the results. * + * True pipelining requires Oracle AI Database 26ai (or later) in Thin + * mode. In Thick mode or older database versions, operations are + * executed sequentially. + * * @param pipeline The pipeline to be run. * @param callback Callback where error is NULL on success, otherwise * contains the error message; results is the array that contains the From 7e5f1595e8532c4e87e97d7a4751d29087b7df2a Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 19:36:34 +0530 Subject: [PATCH 05/16] added types for pool-event methods --- types/oracledb/index.d.ts | 54 ++++++++++++++++++++++++++++++++ types/oracledb/oracledb-tests.ts | 24 ++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 879a6036b6016d..beb79ec31d545c 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -5705,6 +5705,60 @@ declare namespace OracleDB { * @param traceContext input/output trace context object. */ onEndRoundTrip(traceContext: TraceContext): void; + + /** + * Called when the pool expands by creating new connections. + * @param pool the pool instance. + */ + onPoolExpand(pool: Pool): void; + + /** + * Called when the pool shrinks by removing connections. + * @param pool the pool instance. + */ + onPoolShrink(pool: Pool): void; + + /** + * Called when a connection is acquired from the pool. + * @param pool the pool instance. + */ + onPoolAcquire(pool: Pool): void; + + /** + * Called when a connection is released back to the pool. + * @param pool the pool instance. + */ + onPoolRelease(pool: Pool): void; + + /** + * Called when a connection request is queued. + * @param pool the pool instance. + */ + onPoolWait(pool: Pool): void; + + /** + * Called when a queued connection request times out. + * @param pool the pool instance. + */ + onPoolRequestTimeout(pool: Pool): void; + + /** + * Called when a pool free connection is reused. + * @param pool the pool instance. + */ + onPoolConnectionHit(pool: Pool): void; + + /** + * Called when a new request is created for a connection. + * @param pool the pool instance. + */ + onPoolConnectionMiss(pool: Pool): void; + + /** + * Called when the pool is closed. + * @param pool the pool instance. + */ + onPoolClose(pool: Pool): void; } /* diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index e5f54faf3f67ad..f4e70cc61064da 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -919,6 +919,30 @@ export const version7Tests = async (): Promise => { const connection = await oracledb.getConnection({ user: "test", }); + + class PoolTraceHandler extends oracledb.traceHandler.TraceHandlerBase { + // some representative methods for testing, + // others can be similarly tested. + override onPoolAcquire(pool: oracledb.Pool): void { + expectType(pool); + } + override onPoolWait(pool: oracledb.Pool): void { + expectType(pool); + } + override onPoolConnectionMiss(pool: oracledb.Pool): void { + expectType(pool); + } + } + + defaultOracledb.traceHandler.setTraceInstance(new PoolTraceHandler()); + expectType(defaultOracledb.traceHandler.getTraceInstance()); + + // negative test + class InvalidPoolTraceHandler extends oracledb.traceHandler.TraceHandlerBase { + // @ts-expect-error + override onPoolClose(pool: string): void {} + } + expectType(connection.pdbName); expectType(connection.dbUniqueName); From ca38f34b70f5d01196e7c1cd91987dbb05f3ae4a Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 20:20:40 +0530 Subject: [PATCH 06/16] added DBMS_ASSERT apis type changes --- types/oracledb/index.d.ts | 54 ++++++++++++++++++++++++++++++++ types/oracledb/oracledb-tests.ts | 13 ++++++++ 2 files changed, 67 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index beb79ec31d545c..1d53bdd4f37ce2 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -5436,6 +5436,60 @@ declare namespace OracleDB { readOnly?: boolean | undefined; } + /** + * This synchronous method returns the input value as a string that can safely + * be included in a SQL statement as a string literal. + * + * Embedded single quote characters are doubled. + * Non-string values fail standard parameter validation. + * + * @param value The value to be converted to a SQL string literal. + * @since 7.0 + */ + function enquoteLiteral(value: string): string; + + /** + * This synchronous method returns the input string enclosed in double quotes + * so it can be included in a SQL statement as an identifier. + * + * The default value of capitalize is `true`, so the input is converted to + * uppercase using locale-independent Unicode rules before quoting. + * Set capitalize to `false` to preserve case. + * Any input containing a double quote character is rejected. + * + * Uppercasing is done in the Node.js client and can differ from Oracle + * Database `DBMS_ASSERT.ENQUOTE_NAME()` behavior for some characters. + * + * @param name The string to be quoted for identifier use. + * @param capitalize Indicates whether the input string is converted to uppercase before quoting. The default is `true`. + * @since 7.0 + */ + function enquoteName(name: string, capitalize?: boolean): string; + + /** + * This synchronous method returns whether the input string is a qualified SQL name. + * + * Leading and trailing whitespace is ignored. Components may be separated + * by dots, and one optional trailing '@' database link name is allowed. + * The database link name can itself be dotted. + * Invalid SQL name strings return `false`. + * + * @param name The string to be validated. + * @since 7.0 + */ + function isQualifiedSqlName(name: string): boolean; + + /** + * This synchronous method returns whether the input string is a simple SQL name. + * + * Leading and trailing whitespace is ignored. + * Invalid SQL name strings return `false`. + * + * @param name The string to be validated. + * @since 7.0 + */ + function isSimpleSqlName(name: string): boolean; + /** * This method creates a pool of connections with the specified user name, password and connection string. * A pool is typically created once during application initialization. diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index f4e70cc61064da..c93295a1d52ff7 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -915,6 +915,19 @@ export const version6_10Tests = async (): Promise => { export const version7Tests = async (): Promise => { defaultOracledb.thickModeDSNPassthrough = false; expectType(defaultOracledb.thickModeDSNPassthrough); + expectType(defaultOracledb.enquoteLiteral("O'Reilly")); + expectType(defaultOracledb.enquoteName("Department_Name")); + expectType(defaultOracledb.enquoteName("Department_Name", false)); + expectType(defaultOracledb.isSimpleSqlName("employee_id")); + expectType(defaultOracledb.isQualifiedSqlName("HR.employees@db1")); + // @ts-expect-error + defaultOracledb.enquoteLiteral(123); + // @ts-expect-error + defaultOracledb.enquoteName("abc", "no"); + // @ts-expect-error + defaultOracledb.isSimpleSqlName(true); + // @ts-expect-error + defaultOracledb.isQualifiedSqlName(); const connection = await oracledb.getConnection({ user: "test", From 2f57b60853a473ea19a6177fa5fa3cbfcca8c5dc Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 21 Apr 2026 20:48:40 +0530 Subject: [PATCH 07/16] changed @types/oracledb version to 7.0.9999 --- types/oracledb/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/oracledb/package.json b/types/oracledb/package.json index 5c42224cb97780..6bc0eb208140a3 100644 --- a/types/oracledb/package.json +++ b/types/oracledb/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/oracledb", - "version": "6.10.9999", + "version": "7.0.9999", "projects": [ "https://github.com/oracle/node-oracledb" ], From a73e13839b56ef1befc237101a1700c40673233b Mon Sep 17 00:00:00 2001 From: prajalg Date: Wed, 22 Apr 2026 11:16:59 +0530 Subject: [PATCH 08/16] enriched comment for oracledb.isSimpleSqlName() --- types/oracledb/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 1d53bdd4f37ce2..61933e282949c3 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -5483,6 +5483,7 @@ declare namespace OracleDB { * This synchronous method returns whether the input string is a simple SQL name. * * Leading and trailing whitespace is ignored. + * Valid names are either unquoted identifiers that begin with a Unicode letter and then use Unicode letters, Unicode combining marks, Unicode digits, '_', '$', or '#', or quoted identifiers enclosed in double quotes with no embedded double quotes or the NUL character ('\u0000'). * Invalid SQL name strings return `false`. * * @param name The string to be validated. From d53eb927480a2dda16ffc118454579dff21189d9 Mon Sep 17 00:00:00 2001 From: prajalg Date: Mon, 11 May 2026 15:11:42 +0530 Subject: [PATCH 09/16] added type changes for end-user-security feature --- types/oracledb/index.d.ts | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 61933e282949c3..1f9bb3d556f551 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -1058,6 +1058,57 @@ declare namespace OracleDB { deferRoundTrip?: boolean; } + /** + * Configuration options used to create an EndUserSecurityContext object. + * + * Use either endUserToken, or the endUserName/key combination. + * + * @since 7.0 + */ + interface EndUserSecurityContextOptions { + /** + * A security token issued by an external Identity and Access Management (IAM) + * system that authorizes access to Oracle Database. + */ + databaseAccessToken: string; + /** + * The unique identification of an end user managed by an external IAM system. + * + * This attribute should not be set when `endUserName` is specified. + */ + endUserToken?: string | undefined; + /** + * The unique identification of an end user managed by Oracle Database. + * + * This attribute should not be set when `endUserToken` is specified. + */ + endUserName?: string | undefined; + /** + * The lookup identifier that the database maps to stored context attributes. + * This is required when `endUserName` is set. + */ + key?: string | undefined; + /** + * The names of data roles granted to the application or local database user. + */ + dataRoles?: string[] | undefined; + /** + * The attribute-value pairs provided by the application. + */ + attributes?: Record | undefined; + } + + /** + * Defines end user security context information for an end user. + * + * In this release, Deep Data Security is only supported in node-oracledb Thin mode. + * + * @since 7.0 + */ + class EndUserSecurityContext { + constructor(options: EndUserSecurityContextOptions); + } + interface Connection { /** * The action attribute for end-to-end application tracing. @@ -1395,6 +1446,19 @@ declare namespace OracleDB { */ clearAppContext(namespaceName: string): void; + /** + * This synchronous method clears the end user security context specified + * on a connection. + * + * This reverts the connection to its original state in which subsequent + * database operations are executed without any end user security context. + * + * Currently, this method is only relevant to node-oracledb Thin mode. + * + * @since 7.0 + */ + clearEndUserSecurityContext(): void; + /** * Releases a connection. * @@ -1873,6 +1937,19 @@ declare namespace OracleDB { ) => void, ): void; + /** + * This synchronous method sets the end user security context on a connection + * using the specified context. + * + * Once this method is called, the specified end user security context is + * applicable to all database operations performed in the connection. + * + * Currently, this method is only relevant to node-oracledb Thin mode. + * + * @since 7.0 + */ + setEndUserSecurityContext(context: EndUserSecurityContext): void; + /** * Used to shut down a database instance. This is the flexible version of oracledb.shutdown(), allowing more control over behavior. * From f74cba235698121eff019d24ba27a717493f207f Mon Sep 17 00:00:00 2001 From: prajalg Date: Mon, 11 May 2026 15:12:04 +0530 Subject: [PATCH 10/16] added type tests --- types/oracledb/oracledb-tests.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index c93295a1d52ff7..afd4aee95e7e4d 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -968,6 +968,29 @@ export const version7Tests = async (): Promise => { // @ts-expect-error connection.appContext("CLIENTCONTEXT", [{ traceCtx: 12 }]); + const endUserSecurityContext = new oracledb.EndUserSecurityContext({ + databaseAccessToken: "db-access-token", + endUserToken: "end-user-token", + dataRoles: ["ANALYST_ROLE"], + attributes: { + department: "sales", + }, + }); + connection.setEndUserSecurityContext(endUserSecurityContext); + connection.clearEndUserSecurityContext(); + + const endUserSecurityContextByName = new oracledb.EndUserSecurityContext({ + databaseAccessToken: "db-access-token", + endUserName: "APP_USER", + key: "ctx-key", + }); + connection.setEndUserSecurityContext(endUserSecurityContextByName); + + // @ts-expect-error databaseAccessToken is required + new oracledb.EndUserSecurityContext({ + endUserToken: "end-user-token", + }); + const columns: oracledb.DirectPathLoadColumns = ["ID", "NAME"]; const data: oracledb.DirectPathLoadData = [ [1, "first"], From 298f61cefc24501af09db2d1fc400220517a51fe Mon Sep 17 00:00:00 2001 From: prajalg Date: Fri, 29 May 2026 21:49:57 +0530 Subject: [PATCH 11/16] restructured endusersec type changes --- types/oracledb/index.d.ts | 56 ++++++++++++++++++++++---------- types/oracledb/oracledb-tests.ts | 26 +++++++++++++++ 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 1f9bb3d556f551..9f172c78d3fff2 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -1065,29 +1065,12 @@ declare namespace OracleDB { * * @since 7.0 */ - interface EndUserSecurityContextOptions { + interface BaseEndUserSecurityContextOptions { /** * A security token issued by an external Identity and Access Management (IAM) * system that authorizes access to Oracle Database. */ databaseAccessToken: string; - /** - * The unique identification of an end user managed by an external IAM system. - * - * This attribute should not be set when `endUserName` is specified. - */ - endUserToken?: string | undefined; - /** - * The unique identification of an end user managed by Oracle Database. - * - * This attribute should not be set when `endUserToken` is specified. - */ - endUserName?: string | undefined; - /** - * The lookup identifier that the database maps to stored context attributes. - * This is required when `endUserName` is set. - */ - key?: string | undefined; /** * The names of data roles granted to the application or local database user. */ @@ -1098,6 +1081,43 @@ declare namespace OracleDB { attributes?: Record | undefined; } + type EndUserSecurityContextOptions = + | (BaseEndUserSecurityContextOptions & { + /** + * The unique identification of an end user managed by an external IAM system. + */ + endUserToken: string; + /** + * The unique identification of an end user managed by Oracle Database. + * + * This attribute should not be set when `endUserToken` is specified. + */ + endUserName?: never; + /** + * The lookup identifier that the database maps to stored context attributes. + * + * This attribute should not be set when `endUserToken` is specified. + */ + key?: never; + }) + | (BaseEndUserSecurityContextOptions & { + /** + * The unique identification of an end user managed by an external IAM system. + * + * This attribute should not be set when `endUserName` is specified. + */ + endUserToken?: never; + /** + * The unique identification of an end user managed by Oracle Database. + */ + endUserName: string; + /** + * The lookup identifier that the database maps to stored context attributes. + * This is required when `endUserName` is set. + */ + key: string; + }); + /** * Defines end user security context information for an end user. * diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index afd4aee95e7e4d..46d9baeb66381d 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -968,6 +968,7 @@ export const version7Tests = async (): Promise => { // @ts-expect-error connection.appContext("CLIENTCONTEXT", [{ traceCtx: 12 }]); + // valid: IAM end-user token mode const endUserSecurityContext = new oracledb.EndUserSecurityContext({ databaseAccessToken: "db-access-token", endUserToken: "end-user-token", @@ -979,6 +980,7 @@ export const version7Tests = async (): Promise => { connection.setEndUserSecurityContext(endUserSecurityContext); connection.clearEndUserSecurityContext(); + // valid: database local user mode const endUserSecurityContextByName = new oracledb.EndUserSecurityContext({ databaseAccessToken: "db-access-token", endUserName: "APP_USER", @@ -990,6 +992,30 @@ export const version7Tests = async (): Promise => { new oracledb.EndUserSecurityContext({ endUserToken: "end-user-token", }); + // @ts-expect-error must specify either endUserToken or endUserName + key + new oracledb.EndUserSecurityContext({ + databaseAccessToken: "db-access-token", + }); + + // @ts-expect-error key is required when endUserName is set + new oracledb.EndUserSecurityContext({ + databaseAccessToken: "db-access-token", + endUserName: "APP_USER", + }); + + // @ts-expect-error endUserToken and endUserName are mutually exclusive + new oracledb.EndUserSecurityContext({ + databaseAccessToken: "db-access-token", + endUserToken: "end-user-token", + endUserName: "APP_USER", + key: "ctx-key", + }); + // @ts-expect-error key should not be set with endUserToken + new oracledb.EndUserSecurityContext({ + databaseAccessToken: "db-access-token", + endUserToken: "end-user-token", + key: "ctx-key", + }); const columns: oracledb.DirectPathLoadColumns = ["ID", "NAME"]; const data: oracledb.DirectPathLoadData = [ From 02b84351b7a7b1739c21a598e2c699e308e4c31d Mon Sep 17 00:00:00 2001 From: prajalg Date: Fri, 29 May 2026 21:51:14 +0530 Subject: [PATCH 12/16] added changes for asyncDispose feature --- types/oracledb/index.d.ts | 1 + types/oracledb/tsconfig.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 9f172c78d3fff2..1aafe9b78664c7 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -1,4 +1,5 @@ /// +/// import { Duplex, Readable } from "stream"; diff --git a/types/oracledb/tsconfig.json b/types/oracledb/tsconfig.json index 0d5374decf12b9..1bf90f427427da 100644 --- a/types/oracledb/tsconfig.json +++ b/types/oracledb/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "node16", "lib": [ - "es6" + "es6", + "esnext.disposable" ], "noImplicitAny": true, "noImplicitThis": true, From cc3e253956aab45fbc498a4a6c76632922894bcc Mon Sep 17 00:00:00 2001 From: prajalg Date: Fri, 29 May 2026 21:53:00 +0530 Subject: [PATCH 13/16] added tests for asyncDispose type changes --- types/oracledb/oracledb-tests.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index 46d9baeb66381d..1175c89d00858a 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -932,6 +932,13 @@ export const version7Tests = async (): Promise => { const connection = await oracledb.getConnection({ user: "test", }); + expectType<() => Promise>(connection[Symbol.asyncDispose]); + + const pool = await oracledb.createPool({}); + expectType<() => Promise>(pool[Symbol.asyncDispose]); + + const resultSetResult = await connection.execute("SELECT 1 FROM dual", [], { resultSet: true }); + expectType<() => Promise>(resultSetResult.resultSet![Symbol.asyncDispose]); class PoolTraceHandler extends oracledb.traceHandler.TraceHandlerBase { // some representative methods for testing, From 1efd87c58faeb5f3704b1897b8e3f58e10f18abe Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 2 Jun 2026 15:14:12 +0530 Subject: [PATCH 14/16] added missing callback style override for lob.trim(newSize) --- types/oracledb/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 2bde13d0712393..4c17cd9a6a025b 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -3193,6 +3193,7 @@ declare namespace OracleDB { */ trim(newSize?: number): Promise; trim(callback: (error: DBError | null) => void): void; + trim(newSize: number, callback: (error: DBError | null) => void): void; } /** From f38f9f4921359e5c54a3a68243bab43f623ca3e6 Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 2 Jun 2026 15:14:34 +0530 Subject: [PATCH 15/16] corresponding test additions --- types/oracledb/oracledb-tests.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index cb60de5638f5e4..20a083846cb6e6 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -940,6 +940,12 @@ export const version7Tests = async (): Promise => { const resultSetResult = await connection.execute("SELECT 1 FROM dual", [], { resultSet: true }); expectType<() => Promise>(resultSetResult.resultSet![Symbol.asyncDispose]); + await using disposablePool = await oracledb.createPool({}); + await using disposableConnection = await disposablePool.getConnection(); + + const disposableResult = await disposableConnection.execute("SELECT 1 FROM dual", [], { resultSet: true }); + await using disposableResultSet = disposableResult.resultSet!; + class PoolTraceHandler extends oracledb.traceHandler.TraceHandlerBase { // some representative methods for testing, // others can be similarly tested. @@ -1040,6 +1046,9 @@ export const version7Tests = async (): Promise => { lob.trim(error => { expectType(error); }); + lob.trim(10, error => { + expectType(error); + }); const pipeline = new oracledb.Pipeline(); pipeline.addExecute("insert into test_table values (:1)", [1]); From 390e7eaf930ee0bacc8b88e372b0c5ef7bacd38f Mon Sep 17 00:00:00 2001 From: prajalg Date: Tue, 2 Jun 2026 22:41:03 +0530 Subject: [PATCH 16/16] addressed review comments --- types/oracledb/index.d.ts | 25 ++++++++++++++----------- types/oracledb/oracledb-tests.ts | 10 ++++------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index 4c17cd9a6a025b..1eac06dbc24373 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -921,8 +921,7 @@ declare namespace OracleDB { * node-oracledb Thick mode are passed unchanged to Oracle Client libraries * or parsed by node-oracledb. * - * This property must be set before creating the first standalone - * connection or pool. + * If we are using this property, it must be be set before creating the first standalone connection or pool. * * @default true * @since 7.0 @@ -1474,7 +1473,7 @@ declare namespace OracleDB { * This reverts the connection to its original state in which subsequent * database operations are executed without any end user security context. * - * Currently, this method is only relevant to node-oracledb Thin mode. + * Currently, this method is only relevant in node-oracledb Thin mode. * * @since 7.0 */ @@ -1506,6 +1505,8 @@ declare namespace OracleDB { * Implements Explicit Resource Management. Equivalent to calling * connection.close(). * + * Requires Node.js 24. + * * @since 7.0 */ [Symbol.asyncDispose](): Promise; @@ -1930,10 +1931,7 @@ declare namespace OracleDB { runPipeline( pipeline: Pipeline, continueOnError: boolean, - callback: ( - error: DBError | null, - results: PipelineOperationResult[], - ) => void, + callback: ResultCallback, ): void; /** * Runs all of the operations in a pipeline and invokes the callback with @@ -1952,10 +1950,7 @@ declare namespace OracleDB { */ runPipeline( pipeline: Pipeline, - callback: ( - error: DBError | null, - results: PipelineOperationResult[], - ) => void, + callback: ResultCallback, ): void; /** @@ -2225,6 +2220,10 @@ declare namespace OracleDB { * Each entry should represent one context attribute assignment. */ type AppContextKeyValue = Record; + /** + * An application context entry used when creating a connection or pool. + * Each tuple contains the namespace, name, and value strings. + */ type AppContextOpts = [string, string, string]; /** * Provides connection credentials and connection-specific configuration properties. @@ -3417,6 +3416,8 @@ declare namespace OracleDB { * Implements Explicit Resource Management. Equivalent to calling * pool.close(). * + * Requires Node.js 24. + * * @since 7.0 */ [Symbol.asyncDispose](): Promise; @@ -4470,6 +4471,8 @@ declare namespace OracleDB { * Implements Explicit Resource Management. Equivalent to calling * resultSet.close(). * + * Requires Node.js 24. + * * @since 7.0 */ [Symbol.asyncDispose](): Promise; diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index 20a083846cb6e6..6d99745ea991b9 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -1065,12 +1065,10 @@ export const version7Tests = async (): Promise => { const pipelineResults = await connection.runPipeline(pipeline, true); expectType(pipelineResults); - connection.runPipeline(pipeline, (error, results) => { - expectType(error); - expectType(results); + connection.runPipeline(pipeline, (...args) => { + expectType<[oracledb.DBError] | [null, oracledb.PipelineOperationResult[]]>(args); }); - connection.runPipeline(pipeline, true, (error, results) => { - expectType(error); - expectType(results); + connection.runPipeline(pipeline, true, (...args) => { + expectType<[oracledb.DBError] | [null, oracledb.PipelineOperationResult[]]>(args); }); };