@interop/was-client 0.4.0 → 0.6.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 +93 -6
- package/dist/Collection.d.ts +19 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +35 -1
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +6 -0
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +7 -1
- package/dist/Resource.js.map +1 -1
- package/dist/WasClient.d.ts +6 -3
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +8 -5
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +178 -0
- package/dist/edv/WasTransport.d.ts.map +1 -0
- package/dist/edv/WasTransport.js +284 -0
- package/dist/edv/WasTransport.js.map +1 -0
- package/dist/edv/index.d.ts +11 -0
- package/dist/edv/index.d.ts.map +1 -0
- package/dist/edv/index.js +11 -0
- package/dist/edv/index.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -1
- package/dist/errors.js.map +1 -1
- package/dist/internal/content.d.ts +30 -1
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +68 -3
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/paths.d.ts +10 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +14 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +2 -7
- package/dist/internal/request.js.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* An `@interop/edv-client` `Transport` that maps Encrypted Data Vault (EDV)
|
|
6
|
+
* document operations onto ordinary WAS Resource CRUD -- the "EDV-over-WAS"
|
|
7
|
+
* layout profile (Layer 1). It is paired with `EdvClientCore`, which does all
|
|
8
|
+
* encryption, decryption, and index blinding client-side; this transport only
|
|
9
|
+
* moves opaque JWE documents to and from a WAS server, reusing the client's
|
|
10
|
+
* zcap-signed request layer (`WasClient.request()`). Keys never reach the
|
|
11
|
+
* server.
|
|
12
|
+
*
|
|
13
|
+
* Profile decisions encoded here:
|
|
14
|
+
*
|
|
15
|
+
* - **Vault per Collection.** The WAS Collection is the EDV vault; each
|
|
16
|
+
* encrypted document is one WAS Resource.
|
|
17
|
+
* - **Restrict-mode ids.** The WAS resource id IS the EDV document id (the
|
|
18
|
+
* 128-bit multibase value `EdvClientCore.generateId()` produces), which is
|
|
19
|
+
* URL-safe and never a reserved segment.
|
|
20
|
+
* - **Encrypted content type.** Documents are stored as `application/json` by
|
|
21
|
+
* default, so the profile works against an unmodified WAS server. The
|
|
22
|
+
* preferred marker is `application/edv+json` (exported as `EDV_CONTENT_TYPE`),
|
|
23
|
+
* which distinguishes EDV envelopes from plaintext application JSON in
|
|
24
|
+
* listings and metadata -- but the server must register an `application/*+json`
|
|
25
|
+
* content-type parser to accept it (the reference was-teaching-server does; a
|
|
26
|
+
* server that does not will reject it with 415). Pass `contentType:
|
|
27
|
+
* EDV_CONTENT_TYPE` to opt into it where the server supports it.
|
|
28
|
+
*
|
|
29
|
+
* Scope: documents only (`insert` / `update` / `get`). Blinded `find` / `count`
|
|
30
|
+
* / `updateIndex` and chunked streams (`storeChunk` / `getChunk`) require
|
|
31
|
+
* server-side EDV affordances (blinded `/query`, the `/{id}/chunks/{n}`
|
|
32
|
+
* sub-segment, conditional writes) that a plaintext WAS server does not yet
|
|
33
|
+
* provide, so they throw here. Because there are no conditional writes, the EDV
|
|
34
|
+
* `sequence` is advisory (last-writer-wins on `update`).
|
|
35
|
+
*/
|
|
36
|
+
import { Transport } from '@interop/edv-client';
|
|
37
|
+
import { httpStatus } from '../errors.js';
|
|
38
|
+
import { readJsonData } from '../internal/content.js';
|
|
39
|
+
import { resourcePath } from '../internal/paths.js';
|
|
40
|
+
/**
|
|
41
|
+
* The preferred content type marking a stored EDV-encrypted document (a JSON
|
|
42
|
+
* envelope whose `jwe` property carries the ciphertext). Requires the server to
|
|
43
|
+
* register an `application/*+json` content-type parser; otherwise use the
|
|
44
|
+
* default `application/json` (see `WasTransport`'s `contentType` option).
|
|
45
|
+
*/
|
|
46
|
+
export const EDV_CONTENT_TYPE = 'application/edv+json';
|
|
47
|
+
/**
|
|
48
|
+
* The content type used by default: plain JSON, which an unmodified WAS server
|
|
49
|
+
* accepts. The stored envelope is still self-identifying by its `jwe` field.
|
|
50
|
+
*/
|
|
51
|
+
const DEFAULT_CONTENT_TYPE = 'application/json';
|
|
52
|
+
/**
|
|
53
|
+
* A shared `TextEncoder` for serializing envelope bytes (stateless, so one
|
|
54
|
+
* instance is reused across every `_put`).
|
|
55
|
+
*/
|
|
56
|
+
const ENCODER = new TextEncoder();
|
|
57
|
+
/**
|
|
58
|
+
* Builds an `Error` carrying the `name` that `EdvClientCore` (and the reference
|
|
59
|
+
* `HttpsTransport`) dispatch on -- `DuplicateError`, `InvalidStateError`,
|
|
60
|
+
* `NotFoundError`.
|
|
61
|
+
*
|
|
62
|
+
* @param options {object}
|
|
63
|
+
* @param options.name {string} the error name to set
|
|
64
|
+
* @param options.message {string} the human-readable message
|
|
65
|
+
* @param [options.cause] {unknown} the underlying error, if any
|
|
66
|
+
* @returns {Error}
|
|
67
|
+
*/
|
|
68
|
+
function namedError({ name, message, cause }) {
|
|
69
|
+
const err = new Error(message);
|
|
70
|
+
err.name = name;
|
|
71
|
+
if (cause !== undefined) {
|
|
72
|
+
err.cause = cause;
|
|
73
|
+
}
|
|
74
|
+
return err;
|
|
75
|
+
}
|
|
76
|
+
export class WasTransport extends Transport {
|
|
77
|
+
spaceId;
|
|
78
|
+
collectionId;
|
|
79
|
+
contentType;
|
|
80
|
+
_was;
|
|
81
|
+
/**
|
|
82
|
+
* @param options {object}
|
|
83
|
+
* @param options.was {WasClient} a WAS client holding the signer
|
|
84
|
+
* @param options.spaceId {string} the vault's Space id
|
|
85
|
+
* @param options.collectionId {string} the vault Collection id
|
|
86
|
+
* @param [options.contentType] {string} content type for stored envelopes;
|
|
87
|
+
* defaults to `application/json` (accepted by an unmodified server). Pass
|
|
88
|
+
* `EDV_CONTENT_TYPE` against a server that registers an `application/*+json`
|
|
89
|
+
* parser.
|
|
90
|
+
*/
|
|
91
|
+
constructor({ was, spaceId, collectionId, contentType = DEFAULT_CONTENT_TYPE }) {
|
|
92
|
+
super();
|
|
93
|
+
this._was = was;
|
|
94
|
+
this.spaceId = spaceId;
|
|
95
|
+
this.collectionId = collectionId;
|
|
96
|
+
this.contentType = contentType;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The WAS resource path for a document id, delegating to was-client's
|
|
100
|
+
* internal `resourcePath` builder so the percent-encoding and trailing-slash
|
|
101
|
+
* rules stay defined in one place (no trailing slash -- get/put/delete by
|
|
102
|
+
* id).
|
|
103
|
+
*
|
|
104
|
+
* @param id {string} the EDV document id (= WAS resource id)
|
|
105
|
+
* @returns {string}
|
|
106
|
+
*/
|
|
107
|
+
_resourcePath(id) {
|
|
108
|
+
return resourcePath(this.spaceId, this.collectionId, id);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Writes an encrypted document to its WAS resource path as
|
|
112
|
+
* `application/edv+json` (the envelope serialized to bytes so the stored
|
|
113
|
+
* content type is exact).
|
|
114
|
+
*
|
|
115
|
+
* @param id {string}
|
|
116
|
+
* @param encrypted {IEncryptedDocument}
|
|
117
|
+
* @returns {Promise<HttpResponse>}
|
|
118
|
+
*/
|
|
119
|
+
async _put(id, encrypted) {
|
|
120
|
+
const body = ENCODER.encode(JSON.stringify(encrypted));
|
|
121
|
+
return this._was.request({
|
|
122
|
+
path: this._resourcePath(id),
|
|
123
|
+
method: 'PUT',
|
|
124
|
+
body,
|
|
125
|
+
headers: { 'content-type': this.contentType }
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc
|
|
130
|
+
*
|
|
131
|
+
* Inserts a new encrypted document. WAS `PUT` is an upsert, so to preserve
|
|
132
|
+
* EDV insert semantics (`DuplicateError` if the id already exists) this first
|
|
133
|
+
* checks for an existing resource. The check + write is not atomic -- with no
|
|
134
|
+
* server-side conditional writes yet, this is an advisory, single-writer
|
|
135
|
+
* guard.
|
|
136
|
+
*
|
|
137
|
+
* @param options {object}
|
|
138
|
+
* @param options.encrypted {IEncryptedDocument} the document to insert
|
|
139
|
+
* @returns {Promise<void>}
|
|
140
|
+
*/
|
|
141
|
+
async insert({ encrypted } = {}) {
|
|
142
|
+
if (!encrypted) {
|
|
143
|
+
throw new TypeError('"encrypted" is required.');
|
|
144
|
+
}
|
|
145
|
+
if (await this._exists(encrypted.id)) {
|
|
146
|
+
throw namedError({
|
|
147
|
+
name: 'DuplicateError',
|
|
148
|
+
message: `A document with id "${encrypted.id}" already exists.`
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
await this._put(encrypted.id, encrypted);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* @inheritdoc
|
|
155
|
+
*
|
|
156
|
+
* Updates (upserts) an encrypted document. The EDV `sequence` is advisory
|
|
157
|
+
* here -- without server-side conditional writes, a stale write is not
|
|
158
|
+
* rejected (last-writer-wins).
|
|
159
|
+
*
|
|
160
|
+
* @param options {object}
|
|
161
|
+
* @param options.encrypted {IEncryptedDocument} the document to update
|
|
162
|
+
* @returns {Promise<void>}
|
|
163
|
+
*/
|
|
164
|
+
async update({ encrypted } = {}) {
|
|
165
|
+
if (!encrypted) {
|
|
166
|
+
throw new TypeError('"encrypted" is required.');
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
await this._put(encrypted.id, encrypted);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
// A server that DOES enforce conditional writes signals a stale update
|
|
173
|
+
// with 409; surface it the way `EdvClientCore` expects.
|
|
174
|
+
if (httpStatus(err) === 409) {
|
|
175
|
+
throw namedError({
|
|
176
|
+
name: 'InvalidStateError',
|
|
177
|
+
message: 'Conflict error.',
|
|
178
|
+
cause: err
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* @inheritdoc
|
|
186
|
+
*
|
|
187
|
+
* Reads an encrypted document by id. Throws a `NotFoundError` (the name
|
|
188
|
+
* `EdvClientCore` expects) when the resource is missing or not visible.
|
|
189
|
+
*
|
|
190
|
+
* @param options {object}
|
|
191
|
+
* @param options.id {string} the document id to read
|
|
192
|
+
* @returns {Promise<IEncryptedDocument>}
|
|
193
|
+
*/
|
|
194
|
+
async get({ id } = {}) {
|
|
195
|
+
if (!id) {
|
|
196
|
+
throw new TypeError('"id" is required.');
|
|
197
|
+
}
|
|
198
|
+
let response;
|
|
199
|
+
try {
|
|
200
|
+
response = await this._was.request({
|
|
201
|
+
path: this._resourcePath(id),
|
|
202
|
+
method: 'GET'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
if (httpStatus(err) === 404) {
|
|
207
|
+
throw namedError({
|
|
208
|
+
name: 'NotFoundError',
|
|
209
|
+
message: 'Document not found.',
|
|
210
|
+
cause: err
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
throw err;
|
|
214
|
+
}
|
|
215
|
+
return (await readJsonData(response));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Resolves to `true` if a resource exists at the document's path. A 404
|
|
219
|
+
* resolves to `false`; any other error propagates.
|
|
220
|
+
*
|
|
221
|
+
* @param id {string}
|
|
222
|
+
* @returns {Promise<boolean>}
|
|
223
|
+
*/
|
|
224
|
+
async _exists(id) {
|
|
225
|
+
try {
|
|
226
|
+
await this._was.request({ path: this._resourcePath(id), method: 'GET' });
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
if (httpStatus(err) === 404) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* @inheritdoc
|
|
238
|
+
*
|
|
239
|
+
* Blinded-index query is not part of the documents-only EDV-over-WAS profile;
|
|
240
|
+
* it needs the server's `/query` affordance.
|
|
241
|
+
*/
|
|
242
|
+
async find() {
|
|
243
|
+
return this._unsupported('find (blinded-index query)');
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @inheritdoc
|
|
247
|
+
*
|
|
248
|
+
* Index updates need the server's `/{id}/index` affordance.
|
|
249
|
+
*/
|
|
250
|
+
async updateIndex() {
|
|
251
|
+
return this._unsupported('updateIndex');
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @inheritdoc
|
|
255
|
+
*
|
|
256
|
+
* Chunked streams need the reserved `/{id}/chunks/{n}` sub-segment.
|
|
257
|
+
*/
|
|
258
|
+
async storeChunk() {
|
|
259
|
+
return this._unsupported('storeChunk (chunked streams)');
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* @inheritdoc
|
|
263
|
+
*
|
|
264
|
+
* Chunked streams need the reserved `/{id}/chunks/{n}` sub-segment.
|
|
265
|
+
*/
|
|
266
|
+
async getChunk() {
|
|
267
|
+
return this._unsupported('getChunk (chunked streams)');
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Throws a uniform "not supported in this profile" error for EDV operations
|
|
271
|
+
* that depend on server-side affordances absent from a plaintext WAS server.
|
|
272
|
+
*
|
|
273
|
+
* @param operation {string}
|
|
274
|
+
* @returns {never}
|
|
275
|
+
*/
|
|
276
|
+
_unsupported(operation) {
|
|
277
|
+
throw namedError({
|
|
278
|
+
name: 'NotSupportedError',
|
|
279
|
+
message: `"${operation}" is not supported by the documents-only ` +
|
|
280
|
+
'EDV-over-WAS profile (requires server-side EDV affordances).'
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=WasTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WasTransport.js","sourceRoot":"","sources":["../../src/edv/WasTransport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAI/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAA;AAEtD;;;GAGG;AACH,MAAM,oBAAoB,GAAG,kBAAkB,CAAA;AAQ/C;;;GAGG;AACH,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,SAAS,UAAU,CAAC,EAClB,IAAI,EACJ,OAAO,EACP,KAAK,EAKN;IACC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC9B,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;IACf,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;IACnB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,OAAO,YAAa,SAAQ,SAAS;IAChC,OAAO,CAAQ;IACf,YAAY,CAAQ;IACpB,WAAW,CAAQ;IAEX,IAAI,CAAc;IAEnC;;;;;;;;;OASG;IACH,YAAY,EACV,GAAG,EACH,OAAO,EACP,YAAY,EACZ,WAAW,GAAG,oBAAoB,EAMnC;QACC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,G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AAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,OAAO,CAAC,EAAU;QAC9B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;YACxE,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACM,KAAK,CAAC,IAAI;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAA;IACxD,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,WAAW;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;IACzC,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,UAAU;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,8BAA8B,CAAC,CAAA;IAC1D,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,QAAQ;QACrB,OAAO,IAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAA;IACxD,CAAC;IAED;;;;;;OAMG;IACK,YAAY,CAAC,SAAiB;QACpC,MAAM,UAAU,CAAC;YACf,IAAI,EAAE,mBAAmB;YACzB,OAAO,EACL,IAAI,SAAS,2CAA2C;gBACxD,8DAA8D;SACjE,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `@interop/was-client/edv` subpath entry: encrypted (EDV-over-WAS) storage
|
|
6
|
+
* support. Kept off the core `@interop/was-client` entry so plaintext consumers
|
|
7
|
+
* do not pull the `@interop/edv-client` / `@interop/minimal-cipher` crypto graph
|
|
8
|
+
* unless they opt in by importing this subpath.
|
|
9
|
+
*/
|
|
10
|
+
export { WasTransport, EDV_CONTENT_TYPE } from './WasTransport.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `@interop/was-client/edv` subpath entry: encrypted (EDV-over-WAS) storage
|
|
6
|
+
* support. Kept off the core `@interop/was-client` entry so plaintext consumers
|
|
7
|
+
* do not pull the `@interop/edv-client` / `@interop/minimal-cipher` crypto graph
|
|
8
|
+
* unless they opt in by importing this subpath.
|
|
9
|
+
*/
|
|
10
|
+
export { WasTransport, EDV_CONTENT_TYPE } from './WasTransport.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -83,6 +83,14 @@ export declare class QuotaExceededError extends WasError {
|
|
|
83
83
|
export declare class WasServerError extends WasError {
|
|
84
84
|
constructor(message: string, options?: WasErrorOptions);
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Reads the HTTP status from a raw ky/ezcap error, checking both the flat
|
|
88
|
+
* `status` and the nested `response.status` shapes.
|
|
89
|
+
*
|
|
90
|
+
* @param err {unknown} the caught error
|
|
91
|
+
* @returns {number | undefined}
|
|
92
|
+
*/
|
|
93
|
+
export declare function httpStatus(err: unknown): number | undefined;
|
|
86
94
|
/**
|
|
87
95
|
* Translates a thrown ky/ezcap error into the appropriate `WasError` subclass,
|
|
88
96
|
* carrying through the server's `problem+json` fields. Dispatches on the
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;gBAEP,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAU3D;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAA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;gBAEP,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAU3D;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AA6ED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CA6C/C"}
|
package/dist/errors.js
CHANGED
|
@@ -157,6 +157,17 @@ function errorForKind(kind, message, options) {
|
|
|
157
157
|
const ErrorClass = kind === undefined ? undefined : ERROR_CLASS_BY_KIND[kind];
|
|
158
158
|
return ErrorClass ? new ErrorClass(message, options) : null;
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Reads the HTTP status from a raw ky/ezcap error, checking both the flat
|
|
162
|
+
* `status` and the nested `response.status` shapes.
|
|
163
|
+
*
|
|
164
|
+
* @param err {unknown} the caught error
|
|
165
|
+
* @returns {number | undefined}
|
|
166
|
+
*/
|
|
167
|
+
export function httpStatus(err) {
|
|
168
|
+
const raw = err;
|
|
169
|
+
return raw?.status ?? raw?.response?.status;
|
|
170
|
+
}
|
|
160
171
|
/**
|
|
161
172
|
* Translates a thrown ky/ezcap error into the appropriate `WasError` subclass,
|
|
162
173
|
* carrying through the server's `problem+json` fields. Dispatches on the
|
|
@@ -171,7 +182,7 @@ export function mapError(err) {
|
|
|
171
182
|
return err;
|
|
172
183
|
}
|
|
173
184
|
const httpError = (err ?? {});
|
|
174
|
-
const status = httpError
|
|
185
|
+
const status = httpStatus(httpError);
|
|
175
186
|
const data = httpError.data;
|
|
176
187
|
const type = data?.type;
|
|
177
188
|
const title = data?.title;
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAmBpD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAS;IACf,IAAI,CAAS;IACb,KAAK,CAAS;IACd,OAAO,CAAW;IAClB,UAAU,CAAS;IAEnB,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QACnE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC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AC,CAAA;AACvC,CAAC"}
|
|
@@ -5,11 +5,23 @@
|
|
|
5
5
|
* JSON-vs-binary detection and body coercion for resource writes, plus
|
|
6
6
|
* content-type-aware parsing for resource reads. A plain object/array is sent
|
|
7
7
|
* as JSON; a `Blob`/`Uint8Array`/`Buffer` is sent as binary, with the
|
|
8
|
-
* content-type taken from `options.contentType`, the `Blob.type`,
|
|
8
|
+
* content-type taken from `options.contentType`, the `Blob.type`, a guess from
|
|
9
|
+
* the resource id's file extension (`options.filename`), or
|
|
9
10
|
* `application/octet-stream`.
|
|
10
11
|
*/
|
|
11
12
|
import type { HttpResponse } from '@interop/http-client';
|
|
12
13
|
import type { Json } from '../types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Guesses a content-type from a resource id's file extension, limited to the
|
|
16
|
+
* static-web types in `WEB_CONTENT_TYPES`. Returns `undefined` when the id has
|
|
17
|
+
* no extension, is a leading-dot dotfile (e.g. `.gitignore`), or carries an
|
|
18
|
+
* unrecognized extension -- never a generic fallback, so the caller stays in
|
|
19
|
+
* control of a miss.
|
|
20
|
+
*
|
|
21
|
+
* @param id {string} the resource id (often a filename like `index.html`)
|
|
22
|
+
* @returns {string | undefined}
|
|
23
|
+
*/
|
|
24
|
+
export declare function guessContentTypeFromId(id: string): string | undefined;
|
|
13
25
|
/**
|
|
14
26
|
* A write body resolved into either a JSON payload (passed to ezcap as `json`)
|
|
15
27
|
* or a binary payload with its content-type (passed as `body` + header).
|
|
@@ -22,15 +34,32 @@ export interface PreparedBody {
|
|
|
22
34
|
/**
|
|
23
35
|
* Inspects write data and resolves it to a JSON or binary payload.
|
|
24
36
|
*
|
|
37
|
+
* The binary content-type resolves in precedence order: an explicit
|
|
38
|
+
* `options.contentType`, then a non-empty `Blob.type`, then a guess from
|
|
39
|
+
* `options.filename`'s extension, then `application/octet-stream`. (Coalescing
|
|
40
|
+
* with `||` rather than `??` so an empty-string `Blob.type` -- a typeless Blob
|
|
41
|
+
* -- falls through to the guess instead of becoming an empty content-type.)
|
|
42
|
+
*
|
|
25
43
|
* @param data {Json | Blob | Uint8Array} the resource content
|
|
26
44
|
* @param options {object}
|
|
27
45
|
* @param [options.contentType] {string} overrides the inferred content-type
|
|
28
46
|
* for binary data
|
|
47
|
+
* @param [options.filename] {string} resource id used to guess a
|
|
48
|
+
* content-type by extension when none is given (binary data only)
|
|
29
49
|
* @returns {PreparedBody}
|
|
30
50
|
*/
|
|
31
51
|
export declare function prepareBody(data: Json | Blob | Uint8Array, options?: {
|
|
32
52
|
contentType?: string;
|
|
53
|
+
filename?: string;
|
|
33
54
|
}): PreparedBody;
|
|
55
|
+
/**
|
|
56
|
+
* Reads a JSON response body, preferring the http-client's pre-parsed `data`
|
|
57
|
+
* and falling back to `response.json()` when it is absent.
|
|
58
|
+
*
|
|
59
|
+
* @param response {HttpResponse}
|
|
60
|
+
* @returns {Promise<unknown>}
|
|
61
|
+
*/
|
|
62
|
+
export declare function readJsonData(response: HttpResponse): Promise<unknown>;
|
|
34
63
|
/**
|
|
35
64
|
* Parses a resource GET response: returns the parsed object when the stored
|
|
36
65
|
* content-type is JSON, otherwise a `Blob` whose `.type` carries the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AA+BvC;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOrE;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAoBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,EAC9B,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,YAAY,CA4Bd;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3E;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAC5B,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAS7B"}
|
package/dist/internal/content.js
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
import { ValidationError } from '../errors.js';
|
|
2
2
|
const OCTET_STREAM = 'application/octet-stream';
|
|
3
|
+
/**
|
|
4
|
+
* Extension-to-content-type fallbacks for the common static-web file types --
|
|
5
|
+
* the only case where guessing a content-type from a resource id pays off
|
|
6
|
+
* (e.g. serving an HTML site out of a public Collection). Deliberately tiny and
|
|
7
|
+
* inline: an explicit `contentType` (or a non-empty `Blob.type`) always wins,
|
|
8
|
+
* and an unknown extension yields no guess -- so this never needs the breadth
|
|
9
|
+
* (or the `mime-db`-sized weight) of a full media-type library. `.js`/`.mjs`
|
|
10
|
+
* are pinned to `text/javascript` (the WHATWG-preferred form).
|
|
11
|
+
*/
|
|
12
|
+
const WEB_CONTENT_TYPES = {
|
|
13
|
+
html: 'text/html',
|
|
14
|
+
css: 'text/css',
|
|
15
|
+
js: 'text/javascript',
|
|
16
|
+
mjs: 'text/javascript',
|
|
17
|
+
json: 'application/json',
|
|
18
|
+
svg: 'image/svg+xml',
|
|
19
|
+
png: 'image/png',
|
|
20
|
+
jpg: 'image/jpeg',
|
|
21
|
+
jpeg: 'image/jpeg',
|
|
22
|
+
gif: 'image/gif',
|
|
23
|
+
webp: 'image/webp',
|
|
24
|
+
ico: 'image/x-icon',
|
|
25
|
+
woff2: 'font/woff2',
|
|
26
|
+
txt: 'text/plain',
|
|
27
|
+
wasm: 'application/wasm'
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Guesses a content-type from a resource id's file extension, limited to the
|
|
31
|
+
* static-web types in `WEB_CONTENT_TYPES`. Returns `undefined` when the id has
|
|
32
|
+
* no extension, is a leading-dot dotfile (e.g. `.gitignore`), or carries an
|
|
33
|
+
* unrecognized extension -- never a generic fallback, so the caller stays in
|
|
34
|
+
* control of a miss.
|
|
35
|
+
*
|
|
36
|
+
* @param id {string} the resource id (often a filename like `index.html`)
|
|
37
|
+
* @returns {string | undefined}
|
|
38
|
+
*/
|
|
39
|
+
export function guessContentTypeFromId(id) {
|
|
40
|
+
const lastDot = id.lastIndexOf('.');
|
|
41
|
+
if (lastDot < 1) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const extension = id.slice(lastDot + 1).toLowerCase();
|
|
45
|
+
return WEB_CONTENT_TYPES[extension];
|
|
46
|
+
}
|
|
3
47
|
function isBlob(value) {
|
|
4
48
|
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
5
49
|
}
|
|
@@ -19,23 +63,34 @@ function toPlainBytes(bytes) {
|
|
|
19
63
|
/**
|
|
20
64
|
* Inspects write data and resolves it to a JSON or binary payload.
|
|
21
65
|
*
|
|
66
|
+
* The binary content-type resolves in precedence order: an explicit
|
|
67
|
+
* `options.contentType`, then a non-empty `Blob.type`, then a guess from
|
|
68
|
+
* `options.filename`'s extension, then `application/octet-stream`. (Coalescing
|
|
69
|
+
* with `||` rather than `??` so an empty-string `Blob.type` -- a typeless Blob
|
|
70
|
+
* -- falls through to the guess instead of becoming an empty content-type.)
|
|
71
|
+
*
|
|
22
72
|
* @param data {Json | Blob | Uint8Array} the resource content
|
|
23
73
|
* @param options {object}
|
|
24
74
|
* @param [options.contentType] {string} overrides the inferred content-type
|
|
25
75
|
* for binary data
|
|
76
|
+
* @param [options.filename] {string} resource id used to guess a
|
|
77
|
+
* content-type by extension when none is given (binary data only)
|
|
26
78
|
* @returns {PreparedBody}
|
|
27
79
|
*/
|
|
28
80
|
export function prepareBody(data, options = {}) {
|
|
81
|
+
const guessed = options.filename
|
|
82
|
+
? guessContentTypeFromId(options.filename)
|
|
83
|
+
: undefined;
|
|
29
84
|
if (isBlob(data)) {
|
|
30
85
|
return {
|
|
31
86
|
body: data,
|
|
32
|
-
contentType: options.contentType
|
|
87
|
+
contentType: options.contentType || data.type || guessed || OCTET_STREAM
|
|
33
88
|
};
|
|
34
89
|
}
|
|
35
90
|
if (data instanceof Uint8Array) {
|
|
36
91
|
return {
|
|
37
92
|
body: toPlainBytes(data),
|
|
38
|
-
contentType: options.contentType
|
|
93
|
+
contentType: options.contentType || guessed || OCTET_STREAM
|
|
39
94
|
};
|
|
40
95
|
}
|
|
41
96
|
if (data !== null && typeof data === 'object') {
|
|
@@ -45,6 +100,16 @@ export function prepareBody(data, options = {}) {
|
|
|
45
100
|
throw new ValidationError('Resource data must be a plain object/array (JSON) or a ' +
|
|
46
101
|
'Blob/Uint8Array (binary).');
|
|
47
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Reads a JSON response body, preferring the http-client's pre-parsed `data`
|
|
105
|
+
* and falling back to `response.json()` when it is absent.
|
|
106
|
+
*
|
|
107
|
+
* @param response {HttpResponse}
|
|
108
|
+
* @returns {Promise<unknown>}
|
|
109
|
+
*/
|
|
110
|
+
export async function readJsonData(response) {
|
|
111
|
+
return response.data ?? (await response.json());
|
|
112
|
+
}
|
|
48
113
|
/**
|
|
49
114
|
* Parses a resource GET response: returns the parsed object when the stored
|
|
50
115
|
* content-type is JSON, otherwise a `Blob` whose `.type` carries the
|
|
@@ -59,7 +124,7 @@ export async function parseResource(response) {
|
|
|
59
124
|
}
|
|
60
125
|
const contentType = response.headers.get('content-type') ?? '';
|
|
61
126
|
if (contentType.includes('json')) {
|
|
62
|
-
return (
|
|
127
|
+
return (await readJsonData(response));
|
|
63
128
|
}
|
|
64
129
|
return response.blob();
|
|
65
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,MAAM,YAAY,GAAG,0BAA0B,CAAA;AAE/C;;;;;;;;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;IACnB,KAAK,EAAE,YAAY;IACnB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,kBAAkB;CACzB,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAU;IAC/C,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACnC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IACrD,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAA;AACrC,CAAC;AAYD,SAAS,MAAM,CAAC,KAAc;IAC5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C,IAAI,IAAI,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;AACjD,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,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAS,CAAA;IAC/C,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC"}
|
package/dist/internal/paths.d.ts
CHANGED
|
@@ -75,6 +75,16 @@ export declare function collectionPolicy(spaceId: string, collectionId: string):
|
|
|
75
75
|
* (policy discovery).
|
|
76
76
|
*/
|
|
77
77
|
export declare function collectionLinkset(spaceId: string, collectionId: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* `/space/:spaceId/:collectionId/backend` -- the "Collection Backend Selected"
|
|
80
|
+
* descriptor (the backend this collection is stored on).
|
|
81
|
+
*/
|
|
82
|
+
export declare function collectionBackend(spaceId: string, collectionId: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* `/space/:spaceId/:collectionId/quota` -- the per-collection storage quota
|
|
85
|
+
* report (spec "Quotas").
|
|
86
|
+
*/
|
|
87
|
+
export declare function collectionQuota(spaceId: string, collectionId: string): string;
|
|
78
88
|
/**
|
|
79
89
|
* `/space/:spaceId/:collectionId/:resourceId` -- get / put / delete a resource
|
|
80
90
|
* (no trailing slash).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/internal/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;GASG;AAMH;;GA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AAE,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;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,EACpB,SAAS,EACT,IAAI,EACL,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,MAAM,CAET"}
|
|
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;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA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AAI,EAAE,MAAM,CAAA;CACb,GAAG,MAAM,CAET"}
|
package/dist/internal/paths.js
CHANGED
|
@@ -108,6 +108,20 @@ export function collectionPolicy(spaceId, collectionId) {
|
|
|
108
108
|
export function collectionLinkset(spaceId, collectionId) {
|
|
109
109
|
return `/space/${encode(spaceId)}/${encode(collectionId)}/linkset`;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* `/space/:spaceId/:collectionId/backend` -- the "Collection Backend Selected"
|
|
113
|
+
* descriptor (the backend this collection is stored on).
|
|
114
|
+
*/
|
|
115
|
+
export function collectionBackend(spaceId, collectionId) {
|
|
116
|
+
return `/space/${encode(spaceId)}/${encode(collectionId)}/backend`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* `/space/:spaceId/:collectionId/quota` -- the per-collection storage quota
|
|
120
|
+
* report (spec "Quotas").
|
|
121
|
+
*/
|
|
122
|
+
export function collectionQuota(spaceId, collectionId) {
|
|
123
|
+
return `/space/${encode(spaceId)}/${encode(collectionId)}/quota`;
|
|
124
|
+
}
|
|
111
125
|
/**
|
|
112
126
|
* `/space/:spaceId/:collectionId/:resourceId` -- get / put / delete a resource
|
|
113
127
|
* (no trailing slash).
|