@interop/was-client 0.9.2 → 0.11.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 +32 -4
- 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 +41 -12
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +87 -54
- 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 +48 -9
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +96 -37
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +245 -90
- 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 +71 -5
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +102 -7
- 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 +6 -6
package/dist/internal/content.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ValidationError } from '../errors.js';
|
|
1
|
+
import { ValidationError, WasServerError } from '../errors.js';
|
|
2
2
|
const OCTET_STREAM = 'application/octet-stream';
|
|
3
3
|
/**
|
|
4
4
|
* Whether a content-type denotes JSON -- `application/json` or any
|
|
5
5
|
* `application/<prefix>+json` structured-suffix variant (e.g.
|
|
6
|
-
* `application/ld+json`, `application/
|
|
6
|
+
* `application/ld+json`, `application/jose+json`), each optionally followed by
|
|
7
7
|
* parameters (`; charset=utf-8`). The `json` token is anchored to the end of the
|
|
8
8
|
* media type, so a non-JSON type that merely contains the substring `json` --
|
|
9
9
|
* `application/jsonl`, `application/json-seq`, `application/json5` -- is NOT
|
|
@@ -13,9 +13,28 @@ const OCTET_STREAM = 'application/octet-stream';
|
|
|
13
13
|
* @param contentType {string}
|
|
14
14
|
* @returns {boolean}
|
|
15
15
|
*/
|
|
16
|
-
function isJsonContentType(contentType) {
|
|
16
|
+
export function isJsonContentType(contentType) {
|
|
17
17
|
return /^application\/([^+\s;]+\+)?json\s*(;.*)?$/i.test(contentType);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether a content type denotes UTF-8-safe text that should be stored inline as
|
|
21
|
+
* a plain string (legible, no ~33% base64 inflation) rather than as opaque
|
|
22
|
+
* binary -- `text/*`, plus the XML/SVG family that is textual despite an
|
|
23
|
+
* `application/` or `image/` prefix (`application/xml`, any `+xml` structured
|
|
24
|
+
* suffix such as `image/svg+xml` / `application/atom+xml`). Kept deliberately
|
|
25
|
+
* narrow: an unlisted type is treated as binary (base64), which is always
|
|
26
|
+
* byte-safe, and the caller additionally gates on valid UTF-8 before choosing
|
|
27
|
+
* text. Any `; charset=…` parameter is ignored.
|
|
28
|
+
*
|
|
29
|
+
* @param contentType {string}
|
|
30
|
+
* @returns {boolean}
|
|
31
|
+
*/
|
|
32
|
+
export function isTextContentType(contentType) {
|
|
33
|
+
const type = (contentType.split(';')[0] ?? '').trim().toLowerCase();
|
|
34
|
+
return (type.startsWith('text/') ||
|
|
35
|
+
type === 'application/xml' ||
|
|
36
|
+
type.endsWith('+xml'));
|
|
37
|
+
}
|
|
19
38
|
/**
|
|
20
39
|
* Extension-to-content-type fallbacks for the common static-web file types --
|
|
21
40
|
* the only case where guessing a content-type from a resource id pays off
|
|
@@ -60,7 +79,14 @@ export function guessContentTypeFromId(id) {
|
|
|
60
79
|
const extension = id.slice(lastDot + 1).toLowerCase();
|
|
61
80
|
return WEB_CONTENT_TYPES[extension];
|
|
62
81
|
}
|
|
63
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Whether a value is a `Blob`, guarding for environments where `Blob` is
|
|
84
|
+
* undefined.
|
|
85
|
+
*
|
|
86
|
+
* @param value {unknown}
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
export function isBlob(value) {
|
|
64
90
|
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
65
91
|
}
|
|
66
92
|
/**
|
|
@@ -70,7 +96,7 @@ function isBlob(value) {
|
|
|
70
96
|
* @param bytes {Uint8Array}
|
|
71
97
|
* @returns {Uint8Array}
|
|
72
98
|
*/
|
|
73
|
-
function toPlainBytes(bytes) {
|
|
99
|
+
export function toPlainBytes(bytes) {
|
|
74
100
|
if (bytes.constructor === Uint8Array) {
|
|
75
101
|
return bytes;
|
|
76
102
|
}
|
|
@@ -85,7 +111,7 @@ function toPlainBytes(bytes) {
|
|
|
85
111
|
* with `||` rather than `??` so an empty-string `Blob.type` -- a typeless Blob
|
|
86
112
|
* -- falls through to the guess instead of becoming an empty content-type.)
|
|
87
113
|
*
|
|
88
|
-
* @param data {
|
|
114
|
+
* @param data {ResourceData} the resource content
|
|
89
115
|
* @param options {object}
|
|
90
116
|
* @param [options.contentType] {string} overrides the inferred content-type
|
|
91
117
|
* for binary data
|
|
@@ -116,15 +142,60 @@ export function prepareBody(data, options = {}) {
|
|
|
116
142
|
throw new ValidationError('Resource data must be a plain object/array (JSON) or a ' +
|
|
117
143
|
'Blob/Uint8Array (binary).');
|
|
118
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Extracts the id of a just-created resource from a create response. Prefers
|
|
147
|
+
* the response body's `id`; for a body-less 2xx falls back to the last path
|
|
148
|
+
* segment of the `Location` header (decoded, since the server emits a
|
|
149
|
+
* percent-encoded path). Throws a `WasServerError` when the response carries
|
|
150
|
+
* neither -- a malformed create response -- rather than letting an absent body
|
|
151
|
+
* surface as a raw `TypeError` on `data.id`.
|
|
152
|
+
*
|
|
153
|
+
* @param response {HttpResponse | null}
|
|
154
|
+
* @returns {string}
|
|
155
|
+
*/
|
|
156
|
+
export function createdId(response) {
|
|
157
|
+
const data = response?.data;
|
|
158
|
+
if (data !== null &&
|
|
159
|
+
typeof data === 'object' &&
|
|
160
|
+
typeof data.id === 'string') {
|
|
161
|
+
return data.id;
|
|
162
|
+
}
|
|
163
|
+
const location = response?.headers.get('location');
|
|
164
|
+
const segment = location
|
|
165
|
+
? location.split('/').filter(Boolean).pop()
|
|
166
|
+
: undefined;
|
|
167
|
+
if (segment) {
|
|
168
|
+
return decodeURIComponent(segment);
|
|
169
|
+
}
|
|
170
|
+
throw new WasServerError('Create response carried no resource id: the body has no `id` and there ' +
|
|
171
|
+
'is no `Location` header.');
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Unwraps a read response's pre-parsed JSON `data` as `T`, mapping a `null`
|
|
175
|
+
* response (a 404 that a `read` request resolved to `null`) to `null`. Captures
|
|
176
|
+
* the `response === null ? null : response.data as T` idiom shared across the
|
|
177
|
+
* handle read methods.
|
|
178
|
+
*
|
|
179
|
+
* @param response {HttpResponse | null}
|
|
180
|
+
* @returns {T | null}
|
|
181
|
+
*/
|
|
182
|
+
export function dataOrNull(response) {
|
|
183
|
+
return response === null ? null : response.data;
|
|
184
|
+
}
|
|
119
185
|
/**
|
|
120
186
|
* Reads a JSON response body, preferring the http-client's pre-parsed `data`
|
|
121
187
|
* and falling back to `response.json()` when it is absent.
|
|
122
188
|
*
|
|
189
|
+
* `@interop/http-client` pre-consumes the body into `.data` for JSON
|
|
190
|
+
* content-types, so a stored top-level `null` arrives as `.data === null`.
|
|
191
|
+
* Test for `undefined` rather than using `??`; otherwise the nullish fallback
|
|
192
|
+
* would re-invoke `.json()` on the already-consumed stream and throw.
|
|
193
|
+
*
|
|
123
194
|
* @param response {HttpResponse}
|
|
124
195
|
* @returns {Promise<unknown>}
|
|
125
196
|
*/
|
|
126
197
|
export async function readJsonData(response) {
|
|
127
|
-
return response.data
|
|
198
|
+
return response.data === undefined ? await response.json() : response.data;
|
|
128
199
|
}
|
|
129
200
|
/**
|
|
130
201
|
* Parses a resource GET response: returns the parsed object when the stored
|
|
@@ -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;IACnD,OAAO,4CAA4C,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;AACvE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,MAAM,IAAI,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACnE,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QACxB,IAAI,KAAK,iBAAiB;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACtB,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAA2B;IAChD,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,UAAU;IACf,EAAE,EAAE,iBAAiB;IACrB,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,cAAc;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C,IAAU,CAAA;AACxD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAsB;IACvD,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAA;AAC5E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAA6B;IAE7B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,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,EAAE,GAAG,IAAI,CAAA;IAC3C,MAAM,KAAK,CAAA;IACX,MAAM,IAAI,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;IACxC,IAAI,OAAO,GAAG,QAAQ,CAAA;IACtB,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACrB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;QACjD,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,MAAK;QACP,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACjB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACrC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,MAAK;QACP,CAAC;QACD,MAAM,IAAI,CAAA;QACV,OAAO,GAAG,OAAO,CAAA;QACjB,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAc;IAEd,IAAI,SAA8C,CAAA;IAClD,MAAM,KAAK,GAAqC,EAAE,CAAA;IAClD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,SAAS,KAAK,IAAI,CAAA;QAClB,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;IACD,iEAAiE;IACjE,MAAM,MAAM,GAA4B,EAAE,GAAG,SAAU,EAAE,KAAK,EAAE,CAAA;IAChE,OAAO,MAAM,CAAC,IAAI,CAAA;IAClB,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/internal/paths.d.ts
CHANGED
|
@@ -110,6 +110,10 @@ export declare function resourcePolicy(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,G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;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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AC,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,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I,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,UAAU,CAAA;IACxB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAYD;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,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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GAAG;YACvB,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,EAC1B,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,0EAA0E;IAC1E,IAAI,IAAa,CAAA;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,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"}
|