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

   # Which issue does this PR close?
   
   Part of #9322 (tracker: #9320).
   
   # Rationale for this change
   
   #9333 and #9348 generate the Node.js `ListOptions` and `StatOptions` from 
core. This PR generates the existing `DeleteOptions` the same way, so its napi 
object, JSDoc, and conversion to core come from the core `DeleteOptions`. 
`ReadOptions`, `ReaderOptions`, and `WriteOptions` stay hand-written for later 
PRs.
   
   # What changes are included in this PR?
   
   - `dev/src/generate/nodejs.rs` adds a `DeleteOptions` entry to the options 
table from #9348: module `delete`, exposing the core fields `version` 
(`Option<String>`), `recursive` (`bool`), and `if_match` (`Option<String>`). 
The generator code paths and `options_rs.j2` are unchanged.
   - `DeleteOptions` keeps its three members, with the same names, types, and 
order: `version?: string`, `recursive?: boolean`, and `ifMatch?: string`. 
`version` and `ifMatch` pass their strings through, and an omitted `recursive` 
is `false`. Core's `if_none_match`, `if_version_match`, `if_version_not_match`, 
and `if_not_changed` stay unexposed, and the conversion sets them to their 
defaults, as `..Default::default()` did before. No exposed field can fail to 
convert, so the conversion stays a `From`.
   - `bindings/nodejs/src/options.rs` replaces the hand-written `DeleteOptions` 
with the generated `src/options/delete.rs` and re-exports it, so `lib.rs` is 
unchanged. The napi struct now also derives `Debug`, which is Rust-only.
   - The `DeleteOptions` JSDoc now comes from the core doc comments in full, 
following the rules from #9333 and #9348. Rustdoc links become code spans, 
capability references use their JS names (`Capability.deleteWithVersion` and 
`Capability.deleteWithIfMatch`), and the spec link keeps only its text. 
`ErrorKind` references stay as written; #9334 tracks translating them.
   - One core `DeleteOptions` doc correction: the struct doc said "Once every 
condition holds, deleting a missing file remains a successful no-op." OpenDAL 
validates options and capabilities before it dispatches a delete. On `memory` 
and `fs`, `delete('missing', { version: 'v1' })` therefore fails with 
`Unsupported` naming `version`. On versioned Silo S3, the same call fails with 
`Unexpected` (HTTP 400), while a well-formed version id on a missing path 
succeeds. The sentence now reads: "With valid, supported options, deleting a 
missing file remains a successful no-op once every condition holds." It mirrors 
the `StatOptions` fix in #9348. Running every `ci_odev.yml` generator changes 
only the Node.js files; no other binding renders this sentence.
   - Tests:
     - `tests/delete-options-surface.test.mjs` freezes the three members and 
the `delete` and `deleteSync` signatures, using literals copied from 
`generated.d.ts` on `main`. The member set must match exactly. On `memory`, 
both methods must reject `version` and `ifMatch` with `Unsupported` naming the 
core option, for both an existing file and a missing path, and the file must 
stay. `recursive: true` must delete a file, and must succeed on a missing path. 
Without `recursive`, whether omitted, `{}`, or `false`, a directory's child 
must survive the delete; with `recursive: true`, it must not.
     - Generator tests now also cover `DeleteOptions`. A new core field leaves 
the napi struct unchanged and gets its default. Generation fails when 
`recursive` is missing or changes its core kind. The tests pin the three napi 
fields, the four unexposed defaults, the `From` conversion, and the JS 
capability names in the JSDoc. The `StatOptions` checks for fields and 
capability names now share a test with `DeleteOptions`.
   
   Verification:
   
   - Doc claims, on a build of this branch:
     - Without options or with `recursive: true`, deleting a missing path 
succeeds on `memory`, `fs`, and versioned Silo S3.
     - On Silo, `ifMatch` with a missing file or a wrong ETag fails with 
`ConditionNotMatch`, a wrong ETag keeps the file, and the right ETag deletes 
it. `version` deletes only that version: the current content stays, and stat of 
the deleted version returns `NotFound`.
     - On all three, `delete('a/', { recursive: true })` removes `a/x` and 
`a/sub/y` and keeps `ab/z`. Without the trailing slash, `ab/z` is also removed 
on `memory` and Silo, but not on `fs`, which matches "service-specific".
   - `generated.d.ts` differs from `main` only in the `DeleteOptions` JSDoc. 
With comments removed, it is byte-identical to `main`. `generated.js`, 
`index.*`, `lib.rs`, `src/options/list.rs`, and `src/options/stat.rs` are 
unchanged. TypeDoc renders the struct doc's three list items as a list.
   - Each new test fails under a mutation:
     - Surface test: dropping `ifMatch`, swapping `version` and `ifMatch`, 
dropping `recursive`, defaulting an omitted `recursive` to `true`, making 
`version` required, making `recursive` a string, exposing `ifNoneMatch`, or 
making the `delete` options parameter required.
     - Generator tests: skipping the kind check or tolerating a missing field 
for `DeleteOptions`, exposing `if_none_match` or dropping `if_match` from the 
table, converting unexposed string fields from JS, defaulting an omitted 
boolean to `true`, always emitting `TryFrom`, turning off the capability 
rewrite, or linking the wrong capability in the core `version` doc.
     - With core `recursive` changed to `usize`, or `if_match` removed, 
`generate -l nodejs` exits with an error. Adding a field to core 
`DeleteOptions` only adds `fake_option: Default::default()` to `delete.rs`.
   - Old-consumer probes:
     - A script of 1920 `delete` and `deleteSync` calls on `memory` and `fs` 
produces identical output, including the resulting files, against builds of 
`main` and this branch. It covers each member with 14 values (`undefined`, 
`null`, wrong types, and others), keys `main` never declared (`ifNoneMatch`, 
`ifVersionMatch`, `ifNotChanged`, snake_case names), and files, missing paths, 
directories, and prefixes. Dropping `ifMatch` from the conversion changes 80 
lines, and defaulting `recursive` to `true` changes 462.
     - A TypeScript file that implements and fully populates the `main` 
`DeleteOptions` compiles against both under `strict` and 
`exactOptionalPropertyTypes`. It fails when a member is removed or a required 
member is added.
   - The behavior suite passes on `memory`, `fs`, and versioned Silo S3 (with 
the CI fixture's capability overrides). On Silo, per-test outcomes match `main` 
(370 passed, 6 skipped).
   
   # Are there any user-facing changes?
   
   The `DeleteOptions` JSDoc text now follows core, and the core 
`DeleteOptions` rustdoc gets the correction above. Node.js members, types, 
optionality, the `delete` and `deleteSync` 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 entry, tests, and core 
doc correction. Ran the doc-claim checks on `memory`, `fs`, and Silo S3, plus 
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