@interop/was-client 0.9.2 → 0.10.0
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/README.md +27 -1
- package/dist/Collection.d.ts +49 -10
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +161 -61
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +13 -5
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +50 -38
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +1 -0
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +24 -27
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +43 -2
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +90 -14
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +11 -4
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +64 -33
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +194 -86
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +6 -12
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +6 -21
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/constants.d.ts +30 -0
- package/dist/edv/constants.d.ts.map +1 -0
- package/dist/edv/constants.js +30 -0
- package/dist/edv/constants.js.map +1 -0
- package/dist/edv/index.d.ts +1 -1
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +1 -1
- package/dist/edv/index.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -5
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/codec.d.ts +69 -4
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +93 -5
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/content.d.ts +74 -3
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +78 -7
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/describe.d.ts.map +1 -1
- package/dist/internal/describe.js +2 -1
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/pagination.d.ts +45 -0
- package/dist/internal/pagination.d.ts.map +1 -0
- package/dist/internal/pagination.js +53 -0
- package/dist/internal/pagination.js.map +1 -0
- package/dist/internal/paths.d.ts +4 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +10 -1
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/policy.d.ts +54 -0
- package/dist/internal/policy.d.ts.map +1 -0
- package/dist/internal/policy.js +58 -0
- package/dist/internal/policy.js.map +1 -0
- package/dist/internal/request.d.ts +4 -2
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +9 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/reserved.d.ts +3 -8
- package/dist/internal/reserved.d.ts.map +1 -1
- package/dist/internal/reserved.js +10 -20
- package/dist/internal/reserved.js.map +1 -1
- package/dist/internal/write.d.ts +37 -0
- package/dist/internal/write.d.ts.map +1 -0
- package/dist/internal/write.js +29 -0
- package/dist/internal/write.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG9D,MAAM,YAAY,GAAG,0BAA0B,CAAA;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB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I,EAAE,CAAA;IAC9D,IAAI,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAS,CAAA;IAC/C,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,EACtB,EACE,OAAO,EACP,YAAY,EACZ,UAAU,EACX,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GAC/D,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAQvC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { send } from './request.js';
|
|
2
|
+
import { dataOrNull } from './content.js';
|
|
2
3
|
import { collectionPath } from './paths.js';
|
|
3
4
|
/**
|
|
4
5
|
* Reads the Collection Description. Returns `null` if the collection is missing
|
|
@@ -18,6 +19,6 @@ export async function describeCollection(context, { spaceId, collectionId, capab
|
|
|
18
19
|
capability,
|
|
19
20
|
read: true
|
|
20
21
|
});
|
|
21
|
-
return response
|
|
22
|
+
return dataOrNull(response);
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=describe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAsB,EACtB,EACE,OAAO,EACP,YAAY,EACZ,UAAU,EACoD;IAEhE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC;QAC3C,MAAM,EAAE,KAAK;QACb,UAAU;QACV,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,OAAO,
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/internal/describe.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAsB,EACtB,EACE,OAAO,EACP,YAAY,EACZ,UAAU,EACoD;IAEhE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC;QAC3C,MAAM,EAAE,KAAK;QACb,UAAU;QACV,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,OAAO,UAAU,CAAwB,QAAQ,CAAC,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Pagination helpers for WAS list responses. A paginated listing carries a
|
|
6
|
+
* `next` continuation URL when more items may follow; its absence is the
|
|
7
|
+
* authoritative end-of-list signal (the spec forbids inferring page count from
|
|
8
|
+
* `totalItems`). `walkPages` is the single traversal core: it follows `next`
|
|
9
|
+
* from page to page, dereferencing each with the same authorization as the first
|
|
10
|
+
* request, and yields one page at a time (constant memory, early-exit-friendly).
|
|
11
|
+
* `collectPages` builds on it to eagerly aggregate every page into one envelope.
|
|
12
|
+
*/
|
|
13
|
+
import type { CollectionResourcesList } from '../types.js';
|
|
14
|
+
/**
|
|
15
|
+
* The first page (already read) plus the means to fetch each following page.
|
|
16
|
+
* The `fetchPage` callback fetches a single page by absolute URL, returning
|
|
17
|
+
* `null` if it is missing/unauthorized (which ends the traversal).
|
|
18
|
+
*/
|
|
19
|
+
export interface PageWalk {
|
|
20
|
+
first: CollectionResourcesList;
|
|
21
|
+
firstUrl: string;
|
|
22
|
+
fetchPage: (url: string) => Promise<CollectionResourcesList | null>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Lazily walks a list response page by page, yielding the first page and then
|
|
26
|
+
* each page reached by following `next`. Each `next` is resolved relative to the
|
|
27
|
+
* URL of the page that produced it, and a self-referential or already-seen
|
|
28
|
+
* `next` ends the traversal defensively rather than looping forever. Yields one
|
|
29
|
+
* page at a time, so a consumer can stop early without fetching the rest.
|
|
30
|
+
*
|
|
31
|
+
* @param walk {PageWalk}
|
|
32
|
+
* @returns {AsyncGenerator<CollectionResourcesList>}
|
|
33
|
+
*/
|
|
34
|
+
export declare function walkPages(walk: PageWalk): AsyncGenerator<CollectionResourcesList>;
|
|
35
|
+
/**
|
|
36
|
+
* Eagerly follows every `next` link, aggregating all pages' items into a single
|
|
37
|
+
* envelope shaped like the first page (with `next` dropped, since the whole list
|
|
38
|
+
* has been collected). Buffers the entire collection in memory; for a large
|
|
39
|
+
* collection prefer `walkPages` (one page at a time) or an item iterator.
|
|
40
|
+
*
|
|
41
|
+
* @param walk {PageWalk}
|
|
42
|
+
* @returns {Promise<CollectionResourcesList>}
|
|
43
|
+
*/
|
|
44
|
+
export declare function collectPages(walk: PageWalk): Promise<CollectionResourcesList>;
|
|
45
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/internal/pagination.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,uBAAuB,CAAA;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAA;CACpE;AAED;;;;;;;;;GASG;AACH,wBAAuB,SAAS,CAC9B,IAAI,EAAE,QAAQ,GACb,cAAc,CAAC,uBAAuB,CAAC,CAoBzC;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,uBAAuB,CAAC,CAWlC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazily walks a list response page by page, yielding the first page and then
|
|
3
|
+
* each page reached by following `next`. Each `next` is resolved relative to the
|
|
4
|
+
* URL of the page that produced it, and a self-referential or already-seen
|
|
5
|
+
* `next` ends the traversal defensively rather than looping forever. Yields one
|
|
6
|
+
* page at a time, so a consumer can stop early without fetching the rest.
|
|
7
|
+
*
|
|
8
|
+
* @param walk {PageWalk}
|
|
9
|
+
* @returns {AsyncGenerator<CollectionResourcesList>}
|
|
10
|
+
*/
|
|
11
|
+
export async function* walkPages(walk) {
|
|
12
|
+
const { first, firstUrl, fetchPage } = walk;
|
|
13
|
+
yield first;
|
|
14
|
+
const seen = new Set([firstUrl]);
|
|
15
|
+
let baseUrl = firstUrl;
|
|
16
|
+
let next = first.next;
|
|
17
|
+
while (next) {
|
|
18
|
+
const pageUrl = new URL(next, baseUrl).toString();
|
|
19
|
+
if (seen.has(pageUrl)) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
seen.add(pageUrl);
|
|
23
|
+
const page = await fetchPage(pageUrl);
|
|
24
|
+
if (page === null) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
yield page;
|
|
28
|
+
baseUrl = pageUrl;
|
|
29
|
+
next = page.next;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Eagerly follows every `next` link, aggregating all pages' items into a single
|
|
34
|
+
* envelope shaped like the first page (with `next` dropped, since the whole list
|
|
35
|
+
* has been collected). Buffers the entire collection in memory; for a large
|
|
36
|
+
* collection prefer `walkPages` (one page at a time) or an item iterator.
|
|
37
|
+
*
|
|
38
|
+
* @param walk {PageWalk}
|
|
39
|
+
* @returns {Promise<CollectionResourcesList>}
|
|
40
|
+
*/
|
|
41
|
+
export async function collectPages(walk) {
|
|
42
|
+
let aggregate;
|
|
43
|
+
const items = [];
|
|
44
|
+
for await (const page of walkPages(walk)) {
|
|
45
|
+
aggregate ??= page;
|
|
46
|
+
items.push(...page.items);
|
|
47
|
+
}
|
|
48
|
+
// `walkPages` always yields `first`, so `aggregate` is set here.
|
|
49
|
+
const result = { ...aggregate, items };
|
|
50
|
+
delete result.next;
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/internal/pagination.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,SAAS,CAC9B,IAAc;IAEd,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EA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(spaceId: string, collectionId: string, re
|
|
|
110
110
|
* Resolves a path against the server base URL, producing an absolute URL
|
|
111
111
|
* string suitable for zcap `invocationTarget`s.
|
|
112
112
|
*
|
|
113
|
+
* The path is joined onto `serverUrl`'s base path rather than its origin, so a
|
|
114
|
+
* WAS deployment mounted under a sub-path (e.g. `https://host/was/`) keeps that
|
|
115
|
+
* prefix. A bare-origin `serverUrl` behaves as before.
|
|
116
|
+
*
|
|
113
117
|
* @param options {object}
|
|
114
118
|
* @param options.serverUrl {string} the server base URL
|
|
115
119
|
* @param options.path {string} a leading-slash path (e.g. `/space/x`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;GASG;AAMH;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,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G;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,EACpB,SAAS,EACT,IAAI,EACL,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,MAAM,CAOT"}
|
package/dist/internal/paths.js
CHANGED
|
@@ -155,12 +155,21 @@ export function resourcePolicy(spaceId, collectionId, resourceId) {
|
|
|
155
155
|
* Resolves a path against the server base URL, producing an absolute URL
|
|
156
156
|
* string suitable for zcap `invocationTarget`s.
|
|
157
157
|
*
|
|
158
|
+
* The path is joined onto `serverUrl`'s base path rather than its origin, so a
|
|
159
|
+
* WAS deployment mounted under a sub-path (e.g. `https://host/was/`) keeps that
|
|
160
|
+
* prefix. A bare-origin `serverUrl` behaves as before.
|
|
161
|
+
*
|
|
158
162
|
* @param options {object}
|
|
159
163
|
* @param options.serverUrl {string} the server base URL
|
|
160
164
|
* @param options.path {string} a leading-slash path (e.g. `/space/x`)
|
|
161
165
|
* @returns {string}
|
|
162
166
|
*/
|
|
163
167
|
export function toUrl({ serverUrl, path }) {
|
|
164
|
-
|
|
168
|
+
// A leading-slash `path` is origin-absolute to `new URL`, which would drop
|
|
169
|
+
// any base-path prefix on `serverUrl`. Ensure the base ends in a slash and
|
|
170
|
+
// make the path relative so the prefix is preserved.
|
|
171
|
+
const base = serverUrl.endsWith('/') ? serverUrl : `${serverUrl}/`;
|
|
172
|
+
const relative = path.startsWith('/') ? path.slice(1) : path;
|
|
173
|
+
return new URL(relative, base).toString();
|
|
165
174
|
}
|
|
166
175
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;GASG;AAEH,SAAS,MAAM,CAAC,OAAe;IAC7B,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,WAAW,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,GAAG,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,eAAe,CAAA;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,UAAU,MAAM,CAAC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,YAAoB,EACpB,UAAkB;IAElB,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAA;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAe,EACf,YAAoB,EACpB,UAAkB;IAElB,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAA;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAe,EACf,YAAoB,EACpB,UAAkB;IAElB,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAA;AACzF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,EACpB,SAAS,EACT,IAAI,EAIL;IACC,2EAA2E;IAC3E,2EAA2E;IAC3E,qDAAqD;IACrD,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAA;IAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC5D,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Shared access-control policy I/O for the Space / Collection / Resource
|
|
6
|
+
* handles, which differ only in the policy sub-resource path. Each handle wraps
|
|
7
|
+
* these with its own JSDoc and the trivial `isPublic` / `setPublic` sugar.
|
|
8
|
+
*/
|
|
9
|
+
import type { ClientContext } from './request.js';
|
|
10
|
+
import type { IZcap, PolicyDocument } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Reads the access-control policy at `policyPath`. Returns `null` when no policy
|
|
13
|
+
* is set (or it is not visible to you).
|
|
14
|
+
*
|
|
15
|
+
* @param context {ClientContext}
|
|
16
|
+
* @param options {object}
|
|
17
|
+
* @param options.policyPath {string} the policy sub-resource path
|
|
18
|
+
* @param [options.capability] {IZcap}
|
|
19
|
+
* @returns {Promise<PolicyDocument | null>}
|
|
20
|
+
*/
|
|
21
|
+
export declare function readPolicy(context: ClientContext, { policyPath, capability }: {
|
|
22
|
+
policyPath: string;
|
|
23
|
+
capability?: IZcap;
|
|
24
|
+
}): Promise<PolicyDocument | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Sets (creates or replaces) the access-control policy at `policyPath`.
|
|
27
|
+
*
|
|
28
|
+
* @param context {ClientContext}
|
|
29
|
+
* @param options {object}
|
|
30
|
+
* @param options.policyPath {string} the policy sub-resource path
|
|
31
|
+
* @param options.policy {PolicyDocument}
|
|
32
|
+
* @param [options.capability] {IZcap}
|
|
33
|
+
* @returns {Promise<void>}
|
|
34
|
+
*/
|
|
35
|
+
export declare function writePolicy(context: ClientContext, { policyPath, policy, capability }: {
|
|
36
|
+
policyPath: string;
|
|
37
|
+
policy: PolicyDocument;
|
|
38
|
+
capability?: IZcap;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Removes the access-control policy at `policyPath`, reverting to
|
|
42
|
+
* capability-only access. Idempotent.
|
|
43
|
+
*
|
|
44
|
+
* @param context {ClientContext}
|
|
45
|
+
* @param options {object}
|
|
46
|
+
* @param options.policyPath {string} the policy sub-resource path
|
|
47
|
+
* @param [options.capability] {IZcap}
|
|
48
|
+
* @returns {Promise<void>}
|
|
49
|
+
*/
|
|
50
|
+
export declare function deletePolicy(context: ClientContext, { policyPath, capability }: {
|
|
51
|
+
policyPath: string;
|
|
52
|
+
capability?: IZcap;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/internal/policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAExD;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,aAAa,EACtB,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACrE,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQhC;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,aAAa,EACtB,EACE,UAAU,EACV,MAAM,EACN,UAAU,EACX,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACpE,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACrE,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { send } from './request.js';
|
|
2
|
+
import { dataOrNull } from './content.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the access-control policy at `policyPath`. Returns `null` when no policy
|
|
5
|
+
* is set (or it is not visible to you).
|
|
6
|
+
*
|
|
7
|
+
* @param context {ClientContext}
|
|
8
|
+
* @param options {object}
|
|
9
|
+
* @param options.policyPath {string} the policy sub-resource path
|
|
10
|
+
* @param [options.capability] {IZcap}
|
|
11
|
+
* @returns {Promise<PolicyDocument | null>}
|
|
12
|
+
*/
|
|
13
|
+
export async function readPolicy(context, { policyPath, capability }) {
|
|
14
|
+
const response = await send(context, {
|
|
15
|
+
path: policyPath,
|
|
16
|
+
method: 'GET',
|
|
17
|
+
capability,
|
|
18
|
+
read: true
|
|
19
|
+
});
|
|
20
|
+
return dataOrNull(response);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Sets (creates or replaces) the access-control policy at `policyPath`.
|
|
24
|
+
*
|
|
25
|
+
* @param context {ClientContext}
|
|
26
|
+
* @param options {object}
|
|
27
|
+
* @param options.policyPath {string} the policy sub-resource path
|
|
28
|
+
* @param options.policy {PolicyDocument}
|
|
29
|
+
* @param [options.capability] {IZcap}
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
export async function writePolicy(context, { policyPath, policy, capability }) {
|
|
33
|
+
await send(context, {
|
|
34
|
+
path: policyPath,
|
|
35
|
+
method: 'PUT',
|
|
36
|
+
capability,
|
|
37
|
+
json: policy
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Removes the access-control policy at `policyPath`, reverting to
|
|
42
|
+
* capability-only access. Idempotent.
|
|
43
|
+
*
|
|
44
|
+
* @param context {ClientContext}
|
|
45
|
+
* @param options {object}
|
|
46
|
+
* @param options.policyPath {string} the policy sub-resource path
|
|
47
|
+
* @param [options.capability] {IZcap}
|
|
48
|
+
* @returns {Promise<void>}
|
|
49
|
+
*/
|
|
50
|
+
export async function deletePolicy(context, { policyPath, capability }) {
|
|
51
|
+
await send(context, {
|
|
52
|
+
path: policyPath,
|
|
53
|
+
method: 'DELETE',
|
|
54
|
+
capability,
|
|
55
|
+
idempotent: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/internal/policy.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAsB,EACtB,EAAE,UAAU,EAAE,UAAU,EAA8C;IAEtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK;QACb,UAAU;QACV,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,OAAO,UAAU,CAAiB,QAAQ,CAAC,CAAA;AAC7C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAsB,EACtB,EACE,UAAU,EACV,MAAM,EACN,UAAU,EACyD;IAErE,MAAM,IAAI,CAAC,OAAO,EAAE;QAClB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK;QACb,UAAU;QACV,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAsB,EACtB,EAAE,UAAU,EAAE,UAAU,EAA8C;IAEtE,MAAM,IAAI,CAAC,OAAO,EAAE;QAClB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,QAAQ;QAChB,UAAU;QACV,UAAU,EAAE,IAAI;KACjB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -37,7 +37,9 @@ export interface SendInput {
|
|
|
37
37
|
json?: object;
|
|
38
38
|
body?: Blob | Uint8Array;
|
|
39
39
|
capability?: IZcap;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* When true, a 404 response resolves to `null` instead of throwing.
|
|
42
|
+
*/
|
|
41
43
|
read?: boolean;
|
|
42
44
|
/**
|
|
43
45
|
* When true, a 404 response resolves to `null` instead of throwing, so a
|
|
@@ -66,7 +68,7 @@ export declare function rawRequest(context: ClientContext, input: SendInput): Pr
|
|
|
66
68
|
* @param input.url {string} absolute URL to read
|
|
67
69
|
* @param [input.method] {string} HTTP method (defaults to `GET`)
|
|
68
70
|
* @param [input.headers] {Record<string,string>}
|
|
69
|
-
* @param [input.read] {boolean} when true, a 404 resolves to `null`
|
|
71
|
+
* @param [input.read] {boolean} when true, a 404/401/403 resolves to `null`
|
|
70
72
|
* @returns {Promise<HttpResponse | null>}
|
|
71
73
|
*/
|
|
72
74
|
export declare function unsignedRequest(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IAExB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,MAAM,CAA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,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,YAAY,CAAC,CAavB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAiC/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CACxB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAS9B"}
|
package/dist/internal/request.js
CHANGED
|
@@ -43,7 +43,7 @@ export async function rawRequest(context, input) {
|
|
|
43
43
|
* @param input.url {string} absolute URL to read
|
|
44
44
|
* @param [input.method] {string} HTTP method (defaults to `GET`)
|
|
45
45
|
* @param [input.headers] {Record<string,string>}
|
|
46
|
-
* @param [input.read] {boolean} when true, a 404 resolves to `null`
|
|
46
|
+
* @param [input.read] {boolean} when true, a 404/401/403 resolves to `null`
|
|
47
47
|
* @returns {Promise<HttpResponse | null>}
|
|
48
48
|
*/
|
|
49
49
|
export async function unsignedRequest(input) {
|
|
@@ -60,7 +60,14 @@ export async function unsignedRequest(input) {
|
|
|
60
60
|
if (response.ok) {
|
|
61
61
|
return response;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
// A public read resolves to `null` for any "not readable by you" status, not
|
|
64
|
+
// just 404: a conformant WAS masks unauthorized as 404, but a server that
|
|
65
|
+
// answers a missing capability with 401/403 should honor the same
|
|
66
|
+
// null-if-not-publicly-readable contract rather than throw.
|
|
67
|
+
if (input.read &&
|
|
68
|
+
(response.status === 404 ||
|
|
69
|
+
response.status === 401 ||
|
|
70
|
+
response.status === 403)) {
|
|
64
71
|
return null;
|
|
65
72
|
}
|
|
66
73
|
// Reconstruct a problem+json-shaped error so mapError can dispatch on it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AA6ClC,SAAS,iBAAiB,CAAC,OAAsB,EAAE,KAAgB;IACjE,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,GAAG,CAAA;IAClB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAsB,EACtB,KAAgB;IAEhB,MAAM,GAAG,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAA;IACpC,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;QAChC,GAAG;QACH,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM;QACN,2EAA2E;QAC3E,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI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IAAI,CACxB,OAAsB,EACtB,KAAgB;IAEhB,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;YAChE,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAA;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path segments reserved by the spec's Reserved Path Segment Registry. A
|
|
3
|
-
* collection or resource id that collides with one of these is rejected before
|
|
4
|
-
* the request is sent.
|
|
5
|
-
*/
|
|
6
|
-
export declare const RESERVED_SEGMENTS: readonly string[];
|
|
7
1
|
/**
|
|
8
2
|
* Throws a `ValidationError` if the given id collides with a reserved path
|
|
9
|
-
* segment.
|
|
3
|
+
* segment for its kind.
|
|
10
4
|
*
|
|
11
5
|
* @param id {string} the proposed collection or resource id
|
|
12
|
-
* @param kind {string} 'collection' or 'resource',
|
|
6
|
+
* @param kind {string} 'collection' or 'resource', selects the reserved set
|
|
7
|
+
* and is used in the message
|
|
13
8
|
* @returns {void}
|
|
14
9
|
*/
|
|
15
10
|
export declare function assertNotReserved(id: string, kind: 'collection' | 'resource'): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAmBA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,YAAY,GAAG,UAAU,GAC9B,IAAI,CAQN"}
|
|
@@ -5,35 +5,25 @@
|
|
|
5
5
|
* Reserved path-segment registry and the client-side id-collision guard.
|
|
6
6
|
* Rejecting reserved ids up front (with a clear `ValidationError`) is friendlier
|
|
7
7
|
* than letting the server answer `409 Conflict`.
|
|
8
|
+
*
|
|
9
|
+
* The reserved sets themselves are single-sourced from `@interop/storage-core`
|
|
10
|
+
* (the spec's Reserved Path Segment Registry) and re-exported here. This module
|
|
11
|
+
* only adds the client-side `ValidationError`-throwing guard.
|
|
8
12
|
*/
|
|
13
|
+
import { RESERVED_COLLECTION_IDS, RESERVED_RESOURCE_IDS } from '@interop/storage-core';
|
|
9
14
|
import { ValidationError } from '../errors.js';
|
|
10
|
-
/**
|
|
11
|
-
* Path segments reserved by the spec's Reserved Path Segment Registry. A
|
|
12
|
-
* collection or resource id that collides with one of these is rejected before
|
|
13
|
-
* the request is sent.
|
|
14
|
-
*/
|
|
15
|
-
export const RESERVED_SEGMENTS = [
|
|
16
|
-
'policy',
|
|
17
|
-
'backends',
|
|
18
|
-
'backend',
|
|
19
|
-
'collections',
|
|
20
|
-
'export',
|
|
21
|
-
'linkset',
|
|
22
|
-
'query',
|
|
23
|
-
'quota',
|
|
24
|
-
'quotas',
|
|
25
|
-
'meta'
|
|
26
|
-
];
|
|
27
15
|
/**
|
|
28
16
|
* Throws a `ValidationError` if the given id collides with a reserved path
|
|
29
|
-
* segment.
|
|
17
|
+
* segment for its kind.
|
|
30
18
|
*
|
|
31
19
|
* @param id {string} the proposed collection or resource id
|
|
32
|
-
* @param kind {string} 'collection' or 'resource',
|
|
20
|
+
* @param kind {string} 'collection' or 'resource', selects the reserved set
|
|
21
|
+
* and is used in the message
|
|
33
22
|
* @returns {void}
|
|
34
23
|
*/
|
|
35
24
|
export function assertNotReserved(id, kind) {
|
|
36
|
-
|
|
25
|
+
const reserved = kind === 'collection' ? RESERVED_COLLECTION_IDS : RESERVED_RESOURCE_IDS;
|
|
26
|
+
if (reserved.has(id)) {
|
|
37
27
|
throw new ValidationError(`Cannot use reserved path segment "${id}" as a ${kind} id.`);
|
|
38
28
|
}
|
|
39
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved.js","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"reserved.js","sourceRoot":"","sources":["../../src/internal/reserved.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAU,EACV,IAA+B;IAE/B,MAAM,QAAQ,GACZ,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,qBAAqB,CAAA;IACzE,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,eAAe,CACvB,qCAAqC,EAAE,UAAU,IAAI,MAAM,CAC5D,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The shared write orchestration: turn a codec's {@link EncodedWrite} plus a
|
|
6
|
+
* conditional-write precondition into request headers and send it. Captures the
|
|
7
|
+
* `writeHeaders(...) + send(...)` shape that `Collection.add` and `Resource.put`
|
|
8
|
+
* would otherwise each re-implement.
|
|
9
|
+
*/
|
|
10
|
+
import type { HttpResponse } from '@interop/http-client';
|
|
11
|
+
import type { EncodedWrite } from '../codec.js';
|
|
12
|
+
import type { IZcap } from '../types.js';
|
|
13
|
+
import type { ClientContext } from './request.js';
|
|
14
|
+
import type { WritePrecondition } from './conditional.js';
|
|
15
|
+
/**
|
|
16
|
+
* Sends an encoded write (`PUT`/`POST`) to a resource path, applying the
|
|
17
|
+
* encoded body (`json` or `body`), its content-type, and the conditional-write
|
|
18
|
+
* precondition. A write is never a `read`, so the response is always present
|
|
19
|
+
* (errors throw via `send`).
|
|
20
|
+
*
|
|
21
|
+
* @param context {ClientContext}
|
|
22
|
+
* @param options {object}
|
|
23
|
+
* @param options.path {string} the resource path to write
|
|
24
|
+
* @param options.method {string} `PUT` or `POST`
|
|
25
|
+
* @param options.encoded {EncodedWrite} the codec's encoded write
|
|
26
|
+
* @param [options.capability] {IZcap}
|
|
27
|
+
* @param [options.precondition] {WritePrecondition} conditional-write headers
|
|
28
|
+
* @returns {Promise<HttpResponse>}
|
|
29
|
+
*/
|
|
30
|
+
export declare function sendEncodedWrite(context: ClientContext, { path, method, encoded, capability, precondition }: {
|
|
31
|
+
path: string;
|
|
32
|
+
method: string;
|
|
33
|
+
encoded: EncodedWrite;
|
|
34
|
+
capability?: IZcap;
|
|
35
|
+
precondition?: WritePrecondition;
|
|
36
|
+
}): Promise<HttpResponse>;
|
|
37
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,aAAa,EACtB,EACE,IAAI,EACJ,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EACb,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,YAAY,CAAA;IACrB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC,GACA,OAAO,CAAC,YAAY,CAAC,CAUvB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { send } from './request.js';
|
|
2
|
+
import { writeHeaders } from './conditional.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sends an encoded write (`PUT`/`POST`) to a resource path, applying the
|
|
5
|
+
* encoded body (`json` or `body`), its content-type, and the conditional-write
|
|
6
|
+
* precondition. A write is never a `read`, so the response is always present
|
|
7
|
+
* (errors throw via `send`).
|
|
8
|
+
*
|
|
9
|
+
* @param context {ClientContext}
|
|
10
|
+
* @param options {object}
|
|
11
|
+
* @param options.path {string} the resource path to write
|
|
12
|
+
* @param options.method {string} `PUT` or `POST`
|
|
13
|
+
* @param options.encoded {EncodedWrite} the codec's encoded write
|
|
14
|
+
* @param [options.capability] {IZcap}
|
|
15
|
+
* @param [options.precondition] {WritePrecondition} conditional-write headers
|
|
16
|
+
* @returns {Promise<HttpResponse>}
|
|
17
|
+
*/
|
|
18
|
+
export async function sendEncodedWrite(context, { path, method, encoded, capability, precondition }) {
|
|
19
|
+
const response = await send(context, {
|
|
20
|
+
path,
|
|
21
|
+
method,
|
|
22
|
+
capability,
|
|
23
|
+
json: encoded.json,
|
|
24
|
+
body: encoded.body,
|
|
25
|
+
headers: writeHeaders(encoded.contentType, precondition)
|
|
26
|
+
});
|
|
27
|
+
return response;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAG/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAsB,EACtB,EACE,IAAI,EACJ,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EAOb;IAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI;QACJ,MAAM;QACN,UAAU;QACV,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC;KACzD,CAAC,CAAA;IACF,OAAO,QAAwB,CAAA;AACjC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ import type { IZcap, IDelegatedZcap } from '@interop/data-integrity-core/zcap';
|
|
|
16
16
|
import type { ISigner } from '@interop/data-integrity-core';
|
|
17
17
|
import type { ActionInput } from '@interop/storage-core';
|
|
18
18
|
export type { IZcap, IDelegatedZcap, ISigner };
|
|
19
|
+
/**
|
|
20
|
+
* Re-export the shared WAS wire model from `@interop/storage-core`. The
|
|
21
|
+
* resources-in-a-collection listing is `CollectionResourcesList` (formerly
|
|
22
|
+
* `ResourceListing`) and the collections-in-a-space listing is `CollectionsList`
|
|
23
|
+
* (formerly `CollectionListing`).
|
|
24
|
+
*/
|
|
19
25
|
export type { Action, ActionInput, SpaceDescription, CollectionDescription, CollectionEncryption, PolicyDocument, LinkSet, LinkSetEntry, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, ImportStats, BackendReference, BackendDescriptor, BackendRegistration, BackendConnectionInput, BackendConnectionPublic, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport } from '@interop/storage-core';
|
|
20
26
|
/**
|
|
21
27
|
* A JSON-serializable value, the shape stored for JSON resources and
|
|
@@ -27,6 +33,14 @@ export interface JsonObject {
|
|
|
27
33
|
}
|
|
28
34
|
export type JsonArray = Json[];
|
|
29
35
|
export type Json = JsonPrimitive | JsonObject | JsonArray;
|
|
36
|
+
/**
|
|
37
|
+
* The value accepted by a resource write (`put`/`add`): a JSON object or array,
|
|
38
|
+
* or binary as a `Blob`/`Uint8Array`. A top-level JSON primitive
|
|
39
|
+
* (`string`/`number`/`boolean`/`null`) is intentionally excluded -- the wire and
|
|
40
|
+
* EDV paths only carry container JSON, so wrap a bare primitive in an object or
|
|
41
|
+
* array before storing it.
|
|
42
|
+
*/
|
|
43
|
+
export type ResourceData = JsonObject | JsonArray | Blob | Uint8Array;
|
|
30
44
|
/**
|
|
31
45
|
* Return shape of `collection.add()` (server-generated resource id + location).
|
|
32
46
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,E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