braid-text 0.2.76 ā 0.2.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +3 -1
- package/index.js +21 -1
- package/package.json +1 -1
- package/test/tests.js +33 -0
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
"Bash(node test/test.js:*)",
|
|
5
5
|
"Bash(node:*)",
|
|
6
6
|
"Bash(git add:*)",
|
|
7
|
-
"Bash(git commit -m \"$(cat <<''EOF''\n0.2.74 - updates url-file-db to 0.0.19\n\nš¤ Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")"
|
|
7
|
+
"Bash(git commit -m \"$(cat <<''EOF''\n0.2.74 - updates url-file-db to 0.0.19\n\nš¤ Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
|
8
|
+
"Bash(git push)",
|
|
9
|
+
"Bash(npm publish:*)"
|
|
8
10
|
],
|
|
9
11
|
"deny": [],
|
|
10
12
|
"ask": []
|
package/index.js
CHANGED
|
@@ -463,7 +463,27 @@ function create_braid_text() {
|
|
|
463
463
|
throw new Error("unknown")
|
|
464
464
|
}
|
|
465
465
|
|
|
466
|
-
braid_text.delete = async (key) => {
|
|
466
|
+
braid_text.delete = async (key, options) => {
|
|
467
|
+
if (!options) options = {}
|
|
468
|
+
|
|
469
|
+
// Handle URL - make a DELETE request
|
|
470
|
+
if (key instanceof URL) {
|
|
471
|
+
options.my_abort = new AbortController()
|
|
472
|
+
if (options.signal)
|
|
473
|
+
options.signal.addEventListener('abort', () =>
|
|
474
|
+
options.my_abort.abort())
|
|
475
|
+
|
|
476
|
+
var params = {
|
|
477
|
+
method: 'DELETE',
|
|
478
|
+
signal: options.my_abort.signal,
|
|
479
|
+
retry: () => true,
|
|
480
|
+
}
|
|
481
|
+
for (var x of ['headers', 'peer'])
|
|
482
|
+
if (options[x] != null) params[x] = options[x]
|
|
483
|
+
|
|
484
|
+
return await braid_fetch(key.href, params)
|
|
485
|
+
}
|
|
486
|
+
|
|
467
487
|
// Accept either a key string or a resource object
|
|
468
488
|
let resource = (typeof key == 'string') ? await get_resource(key) : key
|
|
469
489
|
await resource.delete()
|
package/package.json
CHANGED
package/test/tests.js
CHANGED
|
@@ -1896,6 +1896,39 @@ runTest(
|
|
|
1896
1896
|
'ok'
|
|
1897
1897
|
)
|
|
1898
1898
|
|
|
1899
|
+
runTest(
|
|
1900
|
+
"test braid_text.delete(url)",
|
|
1901
|
+
async () => {
|
|
1902
|
+
var key = 'test-' + Math.random().toString(36).slice(2)
|
|
1903
|
+
|
|
1904
|
+
// Create a resource first
|
|
1905
|
+
await braid_fetch(`/${key}`, {
|
|
1906
|
+
method: 'PUT',
|
|
1907
|
+
body: 'hello there'
|
|
1908
|
+
})
|
|
1909
|
+
|
|
1910
|
+
// Verify it exists
|
|
1911
|
+
let r1 = await braid_fetch(`/${key}`)
|
|
1912
|
+
if ((await r1.text()) !== 'hello there') return 'Resource not created properly'
|
|
1913
|
+
|
|
1914
|
+
// Delete using braid_text.delete(url)
|
|
1915
|
+
var r = await braid_fetch(`/eval`, {
|
|
1916
|
+
method: 'PUT',
|
|
1917
|
+
body: `void (async () => {
|
|
1918
|
+
await braid_text.delete(new URL('http://localhost:8889/${key}'))
|
|
1919
|
+
res.end('deleted')
|
|
1920
|
+
})()`
|
|
1921
|
+
})
|
|
1922
|
+
if (!r.ok) return 'delete failed: ' + r.status
|
|
1923
|
+
if ((await r.text()) !== 'deleted') return 'delete did not complete'
|
|
1924
|
+
|
|
1925
|
+
// Verify it's deleted (should be empty)
|
|
1926
|
+
let r2 = await braid_fetch(`/${key}`)
|
|
1927
|
+
return 'got: ' + (await r2.text())
|
|
1928
|
+
},
|
|
1929
|
+
'got: '
|
|
1930
|
+
)
|
|
1931
|
+
|
|
1899
1932
|
runTest(
|
|
1900
1933
|
"test getting a binary update from a subscription",
|
|
1901
1934
|
async () => {
|