Skip to content

feat(bindings/nodejs): generate Metadata from core - #9133

Draft
chitralverma wants to merge 1 commit into
apache:mainfrom
chitralverma:feat/generate-nodejs-metadata
Draft

chitralverma wants to merge 1 commit into
apache:mainfrom
chitralverma:feat/generate-nodejs-metadata

Conversation

@chitralverma

@chitralverma chitralverma commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #9129.

Rationale for this change

The Node.js Metadata was hand-copied from core. It lacked content_language and is_current, and its docs were reworded. This PR generates it from the accessors of core/core/src/types/metadata.rs with the shared dev/src/generate/metadata.rs parser, as .NET (#8287) already does.

What changes are included in this PR?

  • dev/src/generate/nodejs.rs + dev/src/generate/nodejs/metadata_rs.j2: new generate -l nodejs target that renders bindings/nodejs/src/metadata.rs, one #[napi] accessor per core accessor in core order, with docs from core. metadata_field is the only place that maps a core return shape to its JS type, and it keeps the types the binding already exposed:
    • is_* predicates stay methods (isDeleted(), now also isCurrent()), everything else stays a getter.
    • mode and contentLength stay nullable (EntryMode | null, bigint | null).
    • lastModified stays an RFC 3339 string, userMetadata stays Record<string, string> | null.
    • isFile() and isDirectory() are kept and rendered right after mode, since the parser skips the derived is_file/is_dir. Their docs now come from core too.
  • bindings/nodejs/src/metadata.rs: generated. Metadata moves out of lib.rs.
  • bindings/nodejs/generated.d.ts: regenerated by napi build. Only the Metadata class changed.
  • Tests: unit tests in dev/src/generate/nodejs.rs pin the JS shapes above and render the real core file. tests/suites/async.suite.mjs adds a behavior test that stats a written file and reads the accessors, including the new ones.
  • CI: ci_odev.yml check_generated runs generate -l nodejs and cargo fmt for Node.js. ci_bindings_nodejs.yml also regenerates before pnpm build (its existing git diff --exit-code then covers generated.d.ts), and now triggers on dev/src/generate/**.

This overlaps with #9125 (Capability) in dev/src/generate/nodejs.rs, dev/src/generate/mod.rs, and the two workflows. Whichever lands second needs a small rebase so that generate() calls both generate_capability and generate_metadata.

Are there any user-facing changes?

Yes, additions only. Metadata gains contentLanguage (getter, string | null) and isCurrent() (method, boolean | null, null when the service does not report it). Existing members and their types are unchanged. Doc comments now come from core, and members follow core order in generated.d.ts.

Breaking changes

None.

AI Usage Statement

  • Harness: Jcode | Model: Claude Opus 5.5 | Effort: medium | Role: Implemented the generator and template, ran the Node.js behavior tests (memory and fs services), and drafted this description. I reviewed the changes.
  • Harness: Claude Code via T3 Code | Model: Claude Opus 5.5 | Effort: medium | Role: Rebased onto current main, regenerated bindings/nodejs/src/metadata.rs against the current core Metadata (no drift; checksum is skipped by the shared parser), and kept this description in sync.

@chitralverma
chitralverma marked this pull request as ready for review November 26, 2026 05:53
@chitralverma
chitralverma marked this pull request as draft November 26, 2026 06:11
@github-actions github-actions Bot added bindings/nodejs releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files. labels Nov 26, 2026
@chitralverma
chitralverma force-pushed the feat/generate-nodejs-metadata branch from d86f97d to 06e0786 Compare November 27, 2026 08:34
Part of apache#9129.

Signed-off-by: Chitral Verma <chitralverma@gmail.com>
@chitralverma
chitralverma force-pushed the feat/generate-nodejs-metadata branch from 06e0786 to db161f3 Compare November 27, 2026 09:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bindings/nodejs releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant