chitralverma opened a new pull request, #9420:
URL: https://github.com/apache/opendal/pull/9420
# Which issue does this PR close?
Part of #9322 (tracker: #9320).
# Rationale for this change
Node.js lacks the remaining core option fields, and `copy`, `rename`, and
`remove` take no options. No Node.js caller is known. This gives parity with
Java (#9234; #8393 needs a stat that fails when a GCS generation changed) and
.NET (#8440). Typical uses:
- Optimistic concurrency: `op.write(path, data, { ifNotChanged: await
op.stat(path) })` fails with `ConditionNotMatch` if another writer replaced the
file.
- Re-stat a cached GCS object only while its generation is unchanged:
`op.stat(path, { ifVersionMatch: cached.version })`.
- Publish without overwriting: `op.copy('staging/a.csv', 'live/a.csv', {
ifNotExists: true })`.
- Undo an overwrite on a versioned bucket: `op.restore(path, { version })`.
# What changes are included in this PR?
- `StatOptions`: `ifVersionMatch`, `ifVersionNotMatch`.
- `ReadOptions`: `limit`, `ifVersionMatch`, `ifVersionNotMatch`,
`contentLengthHint`. `limit` and the hint are checked `bigint`s, like `offset`
and `size`.
- `ReaderOptions`: `ifVersionMatch`, `ifVersionNotMatch`,
`contentLengthHint`.
- `WriteOptions`: `ifVersionMatch`, `ifVersionNotMatch`, `ifNotChanged`.
- `DeleteOptions`: `ifNoneMatch`, `ifVersionMatch`, `ifVersionNotMatch`,
`ifNotChanged`.
- `CopyOptions`, new on `copy` and `copySync`: all 13 core fields. `chunk`
and `sourceContentLengthHint` are checked `bigint`s.
- `RenameOptions`, new on `rename` and `renameSync`: `ifNotExists`.
- `RestoreOptions`, new on the new `restore` and `restoreSync`: `version`,
`ifNotExists`.
- `DeleterOptions`, new on `remove` and `removeSync`: `concurrent`. `remove`
already deletes through a core deleter.
- `ifNotChanged` takes a `Metadata` that this binding returned.
- The JSDoc comes from core in Node.js names, without Rust-only text such as
`Writer::copy_from_options` and copy result metadata.
# Are there any user-facing changes?
- Every new member is optional. Type check only: mapped types such as
`Required<ReadOptions>` gain members, and a value with a new member name but
another type no longer matches.
- Behavior: `copy`, `copySync`, `rename`, and `renameSync` now convert a
third argument, and `remove` and `removeSync` a second. napi ignored it before.
A member with a wrong type now throws, for example `{ chunk: 5 }`, and a known
member takes effect.
- `ifNotChanged` with a value that is not a binding `Metadata` throws before
the call.
Verified: `generated.d.ts` vs `main` changes JSDoc and adds members and four
interfaces; the six changed methods only gain a trailing `options?`. Each field
works through the async and sync methods: conditions on Azurite and Silo, `fs`
rename on Linux, GCS version conditions and the hints as request traces. An
audit of the request builders of each service that advertises a newly exposed
condition found none that drops it on its own. Each new surface and generator
test fails under a mutation. All `ci_odev` generators, fmt and `git diff
--exit-code`; dev and Node.js tests and clippy, also on Linux.
Not verified: live GCS (the nightly `gcs` job runs the new suites); copy
conditions and restore `ifNotExists` on AWS S3, because Silo ignores them.
# Breaking changes
None
# AI Usage Statement
- **Harness:** Claude Code via T3 Code | **Model:** Claude Opus 5.5 |
**Effort:** xhigh
- **Role:** Implemented the changes and tests, audited the service request
builders, verified each field on real builds, drafted this text. 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]