diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts
index 7c31d1acc55ffa..1eac06dbc24373 100644
--- a/types/oracledb/index.d.ts
+++ b/types/oracledb/index.d.ts
@@ -1,4 +1,5 @@
///
+///
import { Duplex, Readable } from "stream";
@@ -915,6 +916,17 @@ 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.
+ *
+ * If we are using this property, it must be 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
@@ -1046,6 +1058,77 @@ 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 BaseEndUserSecurityContextOptions {
+ /**
+ * A security token issued by an external Identity and Access Management (IAM)
+ * system that authorizes access to Oracle Database.
+ */
+ databaseAccessToken: string;
+ /**
+ * 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;
+ }
+
+ 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.
+ *
+ * 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.
@@ -1150,6 +1233,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 +1310,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.
@@ -1296,6 +1398,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 +1456,28 @@ 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;
+
+ /**
+ * 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 in node-oracledb Thin mode.
+ *
+ * @since 7.0
+ */
+ clearEndUserSecurityContext(): void;
/**
* Releases a connection.
@@ -1364,6 +1501,16 @@ 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().
+ *
+ * Requires Node.js 24.
+ *
+ * @since 7.0
+ */
+ [Symbol.asyncDispose](): Promise;
+
/**
* This call commits the current transaction in progress on the connection.
*/
@@ -1399,6 +1546,49 @@ 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.
+ * 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.
+ * @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.
+ * 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.
+ * @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 +1888,84 @@ 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.
+ *
+ * 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.
+ * 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.
+ *
+ * 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.
+ * @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: ResultCallback,
+ ): void;
+ /**
+ * 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
+ * results of the executed pipeline operations.
+ *
+ * @since 7.0
+ */
+ runPipeline(
+ pipeline: Pipeline,
+ callback: ResultCallback,
+ ): 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.
*
@@ -1947,6 +2215,15 @@ 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;
+ /**
+ * 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.
@@ -2347,6 +2624,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;
@@ -2669,6 +3180,19 @@ 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;
+ trim(newSize: number, callback: (error: DBError | null) => void): void;
}
/**
@@ -2888,6 +3412,16 @@ 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().
+ *
+ * Requires Node.js 24.
+ *
+ * @since 7.0
+ */
+ [Symbol.asyncDispose](): Promise;
+
/**
* This method obtains a connection from the connection pool.
*
@@ -3933,6 +4467,16 @@ declare namespace OracleDB {
close(): Promise;
close(callback: (error: DBError | null) => void): void;
+ /**
+ * Implements Explicit Resource Management. Equivalent to calling
+ * resultSet.close().
+ *
+ * Requires Node.js 24.
+ *
+ * @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.
@@ -4994,6 +5538,61 @@ 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.
+ * 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.
+ * @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.
@@ -5263,6 +5862,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 60dc9f3622c464..6d99745ea991b9 100644
--- a/types/oracledb/oracledb-tests.ts
+++ b/types/oracledb/oracledb-tests.ts
@@ -911,3 +911,164 @@ export const version6_10Tests = async (): Promise => {
const messages = await queue.deqMany(5);
};
+
+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",
+ });
+ 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]);
+
+ 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.
+ 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);
+
+ const appCtx: oracledb.AppContextKeyValue[] = [
+ { traceCtx: "12" },
+ { version: "1" },
+ ];
+ connection.appContext("CLIENTCONTEXT", appCtx);
+ connection.clearAppContext("CLIENTCONTEXT");
+ // @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",
+ dataRoles: ["ANALYST_ROLE"],
+ attributes: {
+ department: "sales",
+ },
+ });
+ connection.setEndUserSecurityContext(endUserSecurityContext);
+ connection.clearEndUserSecurityContext();
+
+ // valid: database local user mode
+ 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",
+ });
+ // @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 = [
+ [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 lob = await connection.createLob(oracledb.CLOB);
+ await lob.trim();
+ await lob.trim(10);
+ 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]);
+ 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, (...args) => {
+ expectType<[oracledb.DBError] | [null, oracledb.PipelineOperationResult[]]>(args);
+ });
+ connection.runPipeline(pipeline, true, (...args) => {
+ expectType<[oracledb.DBError] | [null, oracledb.PipelineOperationResult[]]>(args);
+ });
+};
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"
],
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,