chitralverma opened a new pull request, #9333:
URL: https://github.com/apache/opendal/pull/9333

   # Which issue does this PR close?
   
   Part of #9322 (tracker: #9320).
   
   # Rationale for this change
   
   Following Xuanwo's suggestion on #9320, this PR starts generating the 
Node.js operation options from core with the existing `ListOptions`. The shared 
core options parser (`dev/src/generate/core_options.rs`) drives the napi 
`ListOptions` object, its JSDoc, and its conversion to core. The other Node.js 
option structs stay hand-written for later PRs.
   
   # What changes are included in this PR?
   
   - `dev/src/generate/nodejs.rs` and 
`dev/src/generate/nodejs/list_options_rs.j2` render 
`bindings/nodejs/src/options/list.rs` from the core `ListOptions`. A table 
names the five core fields that JS exposes. The napi types stay as they were: 
`limit` is a `number` read as `u32`, `startAfter` a `string`, and `recursive`, 
`versions`, and `deleted` are `boolean`.
   - The JSDoc of `ListOptions` and its fields now comes from the core doc 
comments, so it reads the same as in the other bindings generated from core. 
Rustdoc links become plain code spans, because typedoc cannot resolve Rust 
paths.
   - The generated conversion names every core field instead of ending with 
`..Default::default()`. A new core field fails to compile in the binding until 
`generate -l nodejs` runs again, and the regenerated conversion sets it to its 
default, as it does for `glob` today.
   - `bindings/nodejs/src/options.rs` replaces the hand-written `ListOptions` 
with the generated module and re-exports it, so `lib.rs` is unchanged.
   - Tests:
     - `tests/list-options-surface.test.mjs` freezes the five `ListOptions` 
members and the `list`, `listSync`, `lister`, and `listerSync` signatures, 
using literals copied from `generated.d.ts` on `main`. It checks API only, not 
doc text: every member stays optional, and each list method accepts each 
member's declared type.
     - Rust unit tests in `options.rs` check that an explicit `limit: 0` 
reaches core as `Some(0)`, and that omitted `recursive`, `versions`, and 
`deleted` become `false` (an omitted `limit` stays `None`).
     - Generator tests check that the docs come from core, that a new core 
field leaves the napi struct unchanged and gets its default, and that a missing 
or retyped exposed field fails generation.
   
   Verification:
   
   - `generated.d.ts` differs from `main` only in the `ListOptions` JSDoc. With 
comments removed, it is byte-identical to `main`. `generated.js`, `lib.rs`, and 
`index.*` are unchanged.
   - Each new test fails under a mutation:
     - Surface test: making the generated booleans required, making the `list` 
options parameter required, or changing the native `limit` to `BigInt` while 
`generated.d.ts` stays stale.
     - Rust tests: mapping `limit: 0` to `None`, or defaulting omitted booleans 
to `true`.
     - Generator tests: dropping the core docs, or keeping rustdoc link targets.
     - Adding a field to core `ListOptions` only adds `fake_option: 
Default::default()` to the generated conversion and leaves `generated.d.ts` 
unchanged.
   - Old-consumer probes:
     - A script of 208 option calls, 32 of them across the four list methods, 
produces identical output against builds of `main` and this branch.
     - A TypeScript file that implements and fully populates the `main` option 
interfaces compiles against both under `strict` and 
`exactOptionalPropertyTypes`.
   - The existing sync and async list and lister suites pass on `fs`, `memory`, 
and Silo S3. On S3 the four `with limit` tests run, and per-test outcomes match 
`main`.
   - On Silo S3, `list(dir, { limit: 0 })` returns no entries while an omitted 
`limit` returns all three files, the same as on `main`, so the explicit `0` 
reaches the service.
   
   # Are there any user-facing changes?
   
   The `ListOptions` JSDoc text now follows core. Its members, types, 
optionality, the list method signatures, and the conversion to core are 
unchanged.
   
   # Breaking changes
   
   None
   
   # AI Usage Statement
   
   - **Harness:** Claude Code via T3 Code | **Model:** Claude Opus 5.5 | 
**Effort:** xhigh | **Role:** Implemented the generator, template, and tests; 
ran the surface diff, mutation checks, old-consumer probes, and the local and 
Linux CI steps; drafted this description. The author reviews every change and 
claim.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to