Skip to content

[oracledb] Update types for node-oracledb 7.0 features#1

Open
prajalg wants to merge 21 commits into
masterfrom
oracledb-type-changes
Open

[oracledb] Update types for node-oracledb 7.0 features#1
prajalg wants to merge 21 commits into
masterfrom
oracledb-type-changes

Conversation

@prajalg

@prajalg prajalg commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

This PR updates @types/oracledb with node-oracledb 7.0-aligned type changes:

  • Added pipeline typings:
    • oracledb.Pipeline
    • pipeline.addCommit()
    • pipeline.addExecute()
    • pipeline.addExecuteMany()
    • pipeline.addFetchAll()
    • pipeline.addFetchMany()
    • pipeline.addFetchOne()
    • connection.runPipeline()
    • related pipeline option/result types
  • Added direct path load typings:
    • connection.directPathLoad()
    • DirectPathLoadColumns
    • DirectPathLoadData
  • Added application context typings:
    • connection.appContext()
    • connection.clearAppContext()
    • AppContextKeyValue
  • Added explicit resource management typings:
    • [Symbol.asyncDispose]() for Connection, Pool, and ResultSet
    • Added disposable lib support for explicit resource management:
  • Added connection properties:
    • connection.pdbName
    • connection.dbUniqueName
  • Added lob.trim() typings (Promise + callback overloads)
  • Added oracledb.thickModeDSNPassthrough
  • Added trace pool event hook methods to TraceHandlerBase
  • Added DBMS_ASSERT-related APIs:
    • oracledb.isSimpleSqlName()
    • oracledb.isQualifiedSqlName()
    • oracledb.enquoteLiteral()
    • oracledb.enquoteName()
  • Added End User Security Context typings:
    • oracledb.EndUserSecurityContext constructor typing
    • EndUserSecurityContextOptions
    • connection.setEndUserSecurityContext()
    • connection.clearEndUserSecurityContext()
  • Added version7Tests coverage in types/oracledb/oracledb-tests.ts
  • Updated package version:
    • types/oracledb/package.json: 6.10.9999 -> 7.0.9999

Checklist

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change.
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run pnpm test oracledb.

Summary by CodeRabbit

  • New Features
    • Adds end-user security context & thick-mode passthrough, app-context management, direct-path load and pipeline execution, SQL name/literal helpers, LOB trim, connection identity properties, async resource disposal, and expanded pool tracing hooks.
  • Tests
    • Adds compile-time/type-check tests validating the new typings and APIs.
  • Chores
    • Bumps package to 7.0 and updates TypeScript config for disposable support.

@prajalg prajalg changed the title Oracledb type changes [oracledb] Update types for node-oracledb 7.0 features Apr 21, 2026
@prajalg prajalg force-pushed the oracledb-type-changes branch from 0118338 to 2f57b60 Compare April 22, 2026 03:23
Repository owner deleted a comment from coderabbitai Bot May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a981b34-a364-425c-ba70-ed42e3743a83

📥 Commits

Reviewing files that changed from the base of the PR and between f38f9f4 and 390e7ea.

📒 Files selected for processing (2)
  • types/oracledb/index.d.ts
  • types/oracledb/oracledb-tests.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • types/oracledb/oracledb-tests.ts
  • types/oracledb/index.d.ts

📝 Walkthrough

Walkthrough

Updates OracleDB TypeScript types to v7.0: adds thick-mode DSN passthrough, Deep Data Security types and APIs, synchronous appContext, direct-path load and Pipeline APIs, LOB trimming, async-dispose signatures, SQL helper functions, extended TraceHandlerBase hooks, tests, and package/tsconfig updates.

Changes

OracleDB 7.0 Type Definitions

Layer / File(s) Summary
Package version & build config
types/oracledb/package.json, types/oracledb/tsconfig.json, types/oracledb/index.d.ts
Bumps package to 7.0.9999 and adds esnext.disposable lib reference for async-dispose typings.
Connection Configuration & Metadata
types/oracledb/index.d.ts
Adds thickModeDSNPassthrough global, dbUniqueName and pdbName Connection properties, and disposable typings for Connection/Pool/ResultSet.
Security & Application Context
types/oracledb/index.d.ts
Introduces BaseEndUserSecurityContextOptions, EndUserSecurityContextOptions, EndUserSecurityContext class, setEndUserSecurityContext()/clearEndUserSecurityContext() (declared alongside pipeline overloads), appContext()/clearAppContext() and AppContextKeyValue.
Data Loading & Pipelining
types/oracledb/index.d.ts
Adds Thin-mode directPathLoad() overloads, DirectPathLoadColumns/DirectPathLoadData types, Pipeline class and builder methods, pipeline bind/option/result types, and Connection.runPipeline() overloads returning PipelineOperationResult[].
LOB & SQL Utilities
types/oracledb/index.d.ts
Adds Lob.trim(newSize?) Promise and callback overloads and exported helpers enquoteLiteral(), enquoteName(), isQualifiedSqlName(), isSimpleSqlName().
Tracing Extensions & Type Tests
types/oracledb/index.d.ts, types/oracledb/oracledb-tests.ts
Extends TraceHandlerBase with pool lifecycle and connection event hooks; adds version7Tests() covering new typings (DSN passthrough, asyncDispose, trace hooks, connection identity, appContext, EndUserSecurityContext, directPathLoad, Lob.trim, Pipeline/runPipeline).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through types with nimble paws,

Added contexts, pipelines, and tiny laws.
LOBs trimmed tidy, disposals in line,
Oracle7 sings — the typings align! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title '[oracledb] Update types for node-oracledb 7.0 features' directly and clearly summarizes the main change—adding TypeScript type definitions for node-oracledb version 7.0 features across multiple APIs (Pipeline, Direct Path Load, Application Context, resource management, etc.). The title is concise, specific, and accurately reflects the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oracledb-type-changes

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@types/oracledb/index.d.ts`:
- Around line 1068-1099: EndUserSecurityContextOptions currently allows invalid
combinations; replace the single interface with a discriminated union of two
shapes: one for token-based context (with required databaseAccessToken and
required endUserToken, and explicitly no endUserName/key) and one for name-based
context (with required databaseAccessToken, required endUserName and required
key, and explicitly no endUserToken); preserve optional dataRoles and attributes
on both variants and ensure the union prevents both or neither being set. Use
the existing type name EndUserSecurityContextOptions and the property names
endUserToken, endUserName, and key as the discriminators so callers and tooling
pick the correct shape.
- Around line 1484-1490: The declaration of [Symbol.asyncDispose]():
Promise<void> in types/oracledb/index.d.ts (also present around the other
occurrences) requires the ESNext disposable lib / TS 5.2+ baseline; update the
package typings to declare that requirement by adding either a "Minimum
TypeScript Version: 5.2" header to the type package or inserting a triple-slash
reference directive /// <reference lib="esnext.disposable" /> at the top of
types/oracledb/index.d.ts (and ensure types/oracledb/tsconfig.json includes
"lib": ["es6","esnext.disposable"] or equivalent) so Symbol.asyncDispose is
recognized by consumers.

In `@types/oracledb/oracledb-tests.ts`:
- Around line 915-1034: Add type-checks for the new async disposal signatures by
asserting that Connection, Pool, and ResultSet implement Symbol.asyncDispose:
after obtaining `connection` in `version7Tests`, add expectType checks that
`connection[Symbol.asyncDispose]` exists and is a function, likewise for
`oracledb.Pool.prototype[Symbol.asyncDispose]` and
`oracledb.ResultSet.prototype[Symbol.asyncDispose]` (or instances obtained from
`connection.getPool()` / `connection.execute()`), ensuring the tests reference
Symbol.asyncDispose and the Connection/Pool/ResultSet types to validate the new
signatures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d3d08835-2d2b-4d01-8db9-44b6015f4d2d

📥 Commits

Reviewing files that changed from the base of the PR and between bbf749b and 305cb20.

📒 Files selected for processing (3)
  • types/oracledb/index.d.ts
  • types/oracledb/oracledb-tests.ts
  • types/oracledb/package.json

Comment thread types/oracledb/index.d.ts Outdated
Comment thread types/oracledb/index.d.ts
Comment thread types/oracledb/oracledb-tests.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
types/oracledb/oracledb-tests.ts (1)

1037-1042: ⚡ Quick win

Add test coverage for trim callback variant with length parameter.

The promise-based tests cover both trim() and trim(10), but the callback-based test only covers trim(callback). Consider adding test coverage for trim(length, callback) to ensure all overload combinations are validated.

✅ Suggested test addition
 lob.trim(error => {
     expectType<oracledb.DBError | null>(error);
 });
+lob.trim(10, error => {
+    expectType<oracledb.DBError | null>(error);
+});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@types/oracledb/oracledb-tests.ts` around lines 1037 - 1042, Add a
callback-based test for the lob.trim overload that accepts a length parameter:
locate the LOB created via connection.createLob(oracledb.CLOB) and add a call to
lob.trim(10, callback) similar to the existing lob.trim(callback) case; in the
callback assert the error type with expectType<oracledb.DBError | null>(error)
(and optionally validate behavior if needed) so both promise and callback
overloads (trim() / trim(length) and trim(callback) / trim(length, callback))
are covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@types/oracledb/oracledb-tests.ts`:
- Around line 1037-1042: Add a callback-based test for the lob.trim overload
that accepts a length parameter: locate the LOB created via
connection.createLob(oracledb.CLOB) and add a call to lob.trim(10, callback)
similar to the existing lob.trim(callback) case; in the callback assert the
error type with expectType<oracledb.DBError | null>(error) (and optionally
validate behavior if needed) so both promise and callback overloads (trim() /
trim(length) and trim(callback) / trim(length, callback)) are covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 71f82cd5-adaf-459e-8575-a0b3f76901c0

📥 Commits

Reviewing files that changed from the base of the PR and between 305cb20 and fa2c2b8.

📒 Files selected for processing (3)
  • types/oracledb/index.d.ts
  • types/oracledb/oracledb-tests.ts
  • types/oracledb/tsconfig.json
✅ Files skipped from review due to trivial changes (1)
  • types/oracledb/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • types/oracledb/index.d.ts

@sudarshan12s sudarshan12s left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except minor comments

Comment thread types/oracledb/index.d.ts Outdated
Comment thread types/oracledb/index.d.ts Outdated
Comment thread types/oracledb/index.d.ts Outdated
Comment thread types/oracledb/index.d.ts
* 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is also only available in Thin mode, right?

@prajalg prajalg Jun 2, 2026

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actually, its not stated explicitly in documentation but I tested, conn.pdbName returns pdbName in thick mode too without NJS-089, unlike dbUniqueName

Comment thread types/oracledb/index.d.ts Outdated
Comment thread types/oracledb/index.d.ts
Comment thread types/oracledb/index.d.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants