You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "kingsword09 (via GitHub)" <gi...@apache.org> on 2025/06/30 15:56:18 UTC
[PR] feat(bindings/nodejs): Add DeleteOptions support for new options API [opendal]
kingsword09 opened a new pull request, #6349:
URL: https://github.com/apache/opendal/pull/6349
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Related to https://github.com/apache/opendal/issues/6281.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
This PR adds support for opendal::options::DeleteOptions conversion in the nodejs bindings. This is part of the migration to the new options API outlined in RFC-6213 (https://github.com/apache/opendal/pull/6213).
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
- Added a complete mapping and conversion of opendal::options::DeleteOptions
- behavior tests mirroring Rust's async_delete.rs test suite
- Added the capabilities to support the options
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking-changes` label.
-->
Yes, users can now add options to their delete requests
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bindings/nodejs): Add DeleteOptions support for new options API [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #6349:
URL: https://github.com/apache/opendal/pull/6349#issuecomment-3061080385
Thank you @kingsword09 for working on this!
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bindings/nodejs): Add DeleteOptions support for new options API [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #6349:
URL: https://github.com/apache/opendal/pull/6349#discussion_r2184974533
##########
bindings/nodejs/tests/suites/syncDeleteOptions.suite.mjs:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { randomUUID } from 'node:crypto'
+import { test, describe, expect, assert } from 'vitest'
+
+import { generateBytes } from '../utils.mjs'
+
+/**
+ * @param {import("../../index").Operator} op
+ */
+export function run(op) {
+ const capability = op.capability()
+
+ describe.runIf(capability.write && capability.delete)('async delete options', () => {
+ test('test delete file', () => {
+ const filename = `random_file_${randomUUID()}`
+ const content = generateBytes()
+
+ op.writeSync(filename, content)
+ op.deleteSync(filename)
+
+ assert.isFalse(op.existsSync(filename))
+ })
+
+ test.runIf(capability.createDir)('test delete empty dir', () => {
+ const dirname = `random_dir_${randomUUID()}/`
+ op.createDirSync(dirname)
+ op.deleteSync(dirname)
+
+ assert.isFalse(op.existsSync(dirname))
+ })
+
+ test.runIf(capability.createDir)('test delete not existing', () => {
+ const filename = `random_file_${randomUUID()}`
+
+ op.deleteSync(filename)
+ assert.isFalse(op.existsSync(filename))
+ })
+
+ test.runIf(capability.deleteWithVersion)('test delete with version', () => {
+ const filename = `random_file_${randomUUID()}`
+ const content = generateBytes()
+
+ op.writeSync(filename, content)
+ const meta = op.statSync(filename)
+ const version = meta.version
+
+ op.deleteSync(filename)
+ assert.isFalse(op.existsSync(filename))
+
+ const metadata = op.statSync(filename, { version })
+ expect(metadata.version).toBe(version)
+
+ op.deleteSync(filename, { version })
+
+ expect(() => op.statSync(filename, { version })).toThrowError('NotFound')
+ })
+
+ test.runIf(capability.deleteWithVersion)('test delete with not existing version', () => {
+ const filename1 = `random_file_${randomUUID()}`
+ const content1 = generateBytes()
+
+ op.writeSync(filename1, content1)
+ const meta = op.statSync(filename)
Review Comment:
Oh, github copilet is correct.
<img width="920" alt="Image" src="https://github.com/user-attachments/assets/925f0b33-eeea-4f79-94fd-22bf82850b35" />
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bindings/nodejs): Add DeleteOptions support for new options API [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #6349:
URL: https://github.com/apache/opendal/pull/6349#issuecomment-3035392300
Hi, this PR LGTM to me. I will let Copilot in to see how it works.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bindings/nodejs): Add DeleteOptions support for new options API [opendal]
Posted by "kingsword09 (via GitHub)" <gi...@apache.org>.
kingsword09 commented on code in PR #6349:
URL: https://github.com/apache/opendal/pull/6349#discussion_r2185166386
##########
bindings/nodejs/tests/suites/syncDeleteOptions.suite.mjs:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { randomUUID } from 'node:crypto'
+import { test, describe, expect, assert } from 'vitest'
+
+import { generateBytes } from '../utils.mjs'
+
+/**
+ * @param {import("../../index").Operator} op
+ */
+export function run(op) {
+ const capability = op.capability()
+
+ describe.runIf(capability.write && capability.delete)('async delete options', () => {
+ test('test delete file', () => {
+ const filename = `random_file_${randomUUID()}`
+ const content = generateBytes()
+
+ op.writeSync(filename, content)
+ op.deleteSync(filename)
+
+ assert.isFalse(op.existsSync(filename))
+ })
+
+ test.runIf(capability.createDir)('test delete empty dir', () => {
+ const dirname = `random_dir_${randomUUID()}/`
+ op.createDirSync(dirname)
+ op.deleteSync(dirname)
+
+ assert.isFalse(op.existsSync(dirname))
+ })
+
+ test.runIf(capability.createDir)('test delete not existing', () => {
+ const filename = `random_file_${randomUUID()}`
+
+ op.deleteSync(filename)
+ assert.isFalse(op.existsSync(filename))
+ })
+
+ test.runIf(capability.deleteWithVersion)('test delete with version', () => {
+ const filename = `random_file_${randomUUID()}`
+ const content = generateBytes()
+
+ op.writeSync(filename, content)
+ const meta = op.statSync(filename)
+ const version = meta.version
+
+ op.deleteSync(filename)
+ assert.isFalse(op.existsSync(filename))
+
+ const metadata = op.statSync(filename, { version })
+ expect(metadata.version).toBe(version)
+
+ op.deleteSync(filename, { version })
+
+ expect(() => op.statSync(filename, { version })).toThrowError('NotFound')
+ })
+
+ test.runIf(capability.deleteWithVersion)('test delete with not existing version', () => {
+ const filename1 = `random_file_${randomUUID()}`
+ const content1 = generateBytes()
+
+ op.writeSync(filename1, content1)
+ const meta = op.statSync(filename)
Review Comment:
Fixed.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bindings/nodejs): Add DeleteOptions support for new options API [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #6349:
URL: https://github.com/apache/opendal/pull/6349
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org