Skip to content

feat(bindings/nodejs): add Operator.fromUri static factory#7471

Merged
TennyZhuang merged 1 commit intomainfrom
agent-nodejs-from-uri
May 2, 2026
Merged

feat(bindings/nodejs): add Operator.fromUri static factory#7471
TennyZhuang merged 1 commit intomainfrom
agent-nodejs-from-uri

Conversation

@TennyZhuang
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes none directly — surface parity with Rust Operator::from_uri and Python Operator.from_uri (filed in #6993).

Rationale

Add Operator.fromUri(uri, options?) static factory to the Node.js binding. Mirrors the Rust Operator::from_uri(impl IntoOperatorUri) API so Node consumers can spell their target as a single URI string instead of (scheme, options) pair, with optional extra options that override or supplement values encoded in the URI.

Examples:

const op = Operator.fromUri("memory://localhost/");
const op2 = Operator.fromUri("s3://my-bucket/", { region: "us-east-1" });

Implementation notes

  • Direct 1:1 mapping of Rust Operator::from_uri. When options is empty, the call passes the URI string alone (matching the IntoOperatorUri for String impl); otherwise it passes the (uri, options) pair (matching the IntoOperatorUri for (&str, O: IntoIterator<Item=(K,V)>) impl) so URI-encoded values and supplied options are merged by core, not by the binding.
  • Construction mirrors the existing Operator::new constructor (builds async_op then derives the matching blocking_op).
  • Generated generated.d.ts regenerated by pnpm build. The new static fromUri(...) line sits immediately before the existing capability() getter — no surrounding JSDoc was disturbed.

Intentional divergence from Rust

None.

Tests

Smoke build only on this PR (no public test for the static factory itself in this revision):

  • cd bindings/nodejs && pnpm build — succeeds; generated.d.ts regenerates with the new entry.
  • TypeScript surface check: Operator.fromUri("memory://localhost/") typechecks; passing options narrows to Record<string, string> correctly.

The Rust core path already has from_uri test coverage; this PR is a thin napi wrapper, so behavioral coverage at the binding layer is intentionally minimal.

CI reminder

CI status will be tracked via a scheduled reminder anchored to this PR (10-minute follow-up).

AI usage statement

This patch was produced with AI assistance under the OpenDAL binding regression coordination effort:

  • Drafted by @od-claude-lead-050121 (Claude) as Lane B worker.
  • Pre-reviewed by @od-kimi-scout-050121 (artifact author of the canonical v3 patch) and @od-codex-review-050121 (Codex; APPROVED v3 with verified SHA-256 0ba9ee30caa862840bae64e3a8b1d5a80b463f97a7209a6285dbeeae73e8e4be).
  • Pushed under shared TennyZhuang auth per the regression-effort hybrid publishing policy.

Add a static fromUri(uri, options?) factory method to the Node.js
Operator class, mirroring Rust Operator::from_uri and Python
Operator.from_uri (PR #6993).

The URI encodes scheme and configuration in a single string, e.g.
  memory://localhost/
  s3://bucket/path?region=us-east-1

Optional extra key-value options can be passed to override or
supplement values encoded in the URI.

Intentional divergence: none. Direct 1:1 mapping of Rust
Operator::from_uri((uri, options)) via IntoOperatorUri.

Scope: bindings/nodejs only (lib.rs + generated.d.ts).
AI-assisted: od-claude-lead-050121, reviewed by OpenDAL regression team.
@TennyZhuang TennyZhuang requested a review from suyanhanx as a code owner May 1, 2026 18:31
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels May 1, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 2, 2026
@TennyZhuang TennyZhuang merged commit 2a24aec into main May 2, 2026
65 of 74 checks passed
@TennyZhuang TennyZhuang deleted the agent-nodejs-from-uri branch May 2, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants