@interop/was-client 0.11.0 → 0.13.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 +31 -5
- package/dist/Collection.d.ts +13 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +61 -52
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +39 -25
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +89 -74
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +43 -0
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +98 -56
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +33 -32
- package/dist/WasClient.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts +32 -7
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +83 -38
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +28 -10
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +66 -16
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/constants.d.ts +8 -0
- package/dist/edv/constants.d.ts.map +1 -1
- package/dist/edv/constants.js +10 -0
- package/dist/edv/constants.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -7
- package/dist/errors.js.map +1 -1
- package/dist/internal/codec.d.ts +6 -43
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +19 -40
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/conditional.d.ts +8 -3
- package/dist/internal/conditional.d.ts.map +1 -1
- package/dist/internal/conditional.js +5 -3
- package/dist/internal/conditional.js.map +1 -1
- package/dist/internal/content.d.ts +42 -8
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +70 -21
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/grant.d.ts +20 -2
- package/dist/internal/grant.d.ts.map +1 -1
- package/dist/internal/grant.js +22 -2
- package/dist/internal/grant.js.map +1 -1
- package/dist/internal/pagination.d.ts +16 -0
- package/dist/internal/pagination.d.ts.map +1 -1
- package/dist/internal/pagination.js +21 -1
- package/dist/internal/pagination.js.map +1 -1
- package/dist/internal/paths.d.ts +48 -17
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +85 -6
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +21 -12
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +22 -0
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/reserved.d.ts +8 -4
- package/dist/internal/reserved.d.ts.map +1 -1
- package/dist/internal/reserved.js +5 -4
- package/dist/internal/reserved.js.map +1 -1
- package/dist/internal/write.d.ts +47 -6
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +71 -1
- package/dist/internal/write.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -605,12 +605,17 @@ scope for now):
|
|
|
605
605
|
- **Ids.** `add()` mints an EDV id (a `z`-prefixed multibase value used verbatim
|
|
606
606
|
as the WAS resource id). `put(id, ...)` accepts only an EDV-format id; a
|
|
607
607
|
human-readable id is rejected (it would leak onto the URL) -- carry a
|
|
608
|
-
human-readable label inside the encrypted content instead.
|
|
608
|
+
human-readable label inside the encrypted content instead. By default the
|
|
609
|
+
minted id is random (the classic mutable-document model); pass
|
|
610
|
+
`createEdvEncryption({ idDerivation: 'content' })` to derive it from the
|
|
611
|
+
envelope's JWE ciphertext instead, making documents content-addressed -- the
|
|
612
|
+
id is then stable across replicas (no mapping table), at the cost of
|
|
613
|
+
immutability (an "update" is delete-old + add-new).
|
|
609
614
|
- **Metadata.** `resource.setName()` / `setTags()` / `setMeta()` work on an
|
|
610
|
-
encrypted collection: the user-writable `custom` (`name` / `tags`) is
|
|
611
|
-
into an envelope before it is sent, so the server never sees the
|
|
612
|
-
`meta()` decrypts it back for a keyed reader. The `/meta`
|
|
613
|
-
ETag (`metaVersion`), independent of the content ETag.
|
|
615
|
+
encrypted collection: the user-writable `custom` (`name` / `tags`) is
|
|
616
|
+
encrypted into an envelope before it is sent, so the server never sees the
|
|
617
|
+
plaintext, and `meta()` decrypts it back for a keyed reader. The `/meta`
|
|
618
|
+
endpoint has its own ETag (`metaVersion`), independent of the content ETag.
|
|
614
619
|
- **Binary.** A small `Blob`/`Uint8Array` is encrypted as a single document;
|
|
615
620
|
larger binaries are rejected until chunked encrypted blobs land.
|
|
616
621
|
- **Raw reads.** `get()` decrypts; the `getText()` / `getBytes()` escape hatches
|
|
@@ -625,6 +630,27 @@ const stats = await otherSpace.import(archive)
|
|
|
625
630
|
// policiesCreated, policiesSkipped }
|
|
626
631
|
```
|
|
627
632
|
|
|
633
|
+
`export()` buffers the whole tar archive into memory, which is the simplest
|
|
634
|
+
shape for small spaces. Two additive companions cover the large-space and
|
|
635
|
+
container cases:
|
|
636
|
+
|
|
637
|
+
```ts
|
|
638
|
+
// Constant memory: pipe the archive straight to a file / upload / compressor,
|
|
639
|
+
// without buffering the whole space into RAM. The stream must be consumed or
|
|
640
|
+
// cancelled (an abandoned stream holds the connection open).
|
|
641
|
+
const stream = await space.exportStream() // ReadableStream<Uint8Array>
|
|
642
|
+
|
|
643
|
+
// A Blob typed `application/x-tar`, the direct companion to import(). Copying a
|
|
644
|
+
// space is a one-liner:
|
|
645
|
+
const stats = await otherSpace.import(await space.exportBlob())
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
Pick by size: `exportStream()` for a large space, `exportBlob()` when you want
|
|
649
|
+
the `import()` companion or a browser download, and `export()` for a small space
|
|
650
|
+
or when you need the bytes anyway. (In Node a Blob is memory-backed, so
|
|
651
|
+
`exportBlob()` does not lower peak memory versus `export()`; browsers may spill
|
|
652
|
+
large Blobs to disk.)
|
|
653
|
+
|
|
628
654
|
### The manual-request escape hatch
|
|
629
655
|
|
|
630
656
|
`was.request(...)` mirrors ezcap's generic `request()` for hand-built calls. As
|
package/dist/Collection.d.ts
CHANGED
|
@@ -56,6 +56,16 @@ export declare class Collection {
|
|
|
56
56
|
* Creates or updates the collection by id (upsert). Merges the given fields
|
|
57
57
|
* over the current description.
|
|
58
58
|
*
|
|
59
|
+
* The merge needs a readable current description to be lost-update-safe, and
|
|
60
|
+
* `describe()` cannot distinguish "absent" from "unreadable" (WAS masks
|
|
61
|
+
* unauthorized reads as 404). When it returns `null` and neither `backend`
|
|
62
|
+
* nor `encryption` is supplied, this fails closed rather than sending a PUT
|
|
63
|
+
* body that would silently drop an existing collection's `backend` (a
|
|
64
|
+
* data-placement change) or trip `encryption-immutable` by clearing its
|
|
65
|
+
* marker on a replace-semantics server. Pass `force: true` to proceed anyway
|
|
66
|
+
* -- e.g. when creating a new collection through a handle (or use
|
|
67
|
+
* `space.createCollection()`, which does not merge).
|
|
68
|
+
*
|
|
59
69
|
* @param desc {object}
|
|
60
70
|
* @param [desc.name] {string}
|
|
61
71
|
* @param [desc.backend] {BackendReference}
|
|
@@ -63,12 +73,15 @@ export declare class Collection {
|
|
|
63
73
|
* encryption marker. Set-once on the server: it may be added to a Collection
|
|
64
74
|
* that lacks one, but changing/clearing an existing marker is rejected
|
|
65
75
|
* (`ConflictError`, `encryption-immutable`).
|
|
76
|
+
* @param [desc.force] {boolean} proceed even when the current description
|
|
77
|
+
* is unreadable and `backend`/`encryption` are omitted (see above)
|
|
66
78
|
* @returns {Promise<CollectionDescription>}
|
|
67
79
|
*/
|
|
68
80
|
configure(desc: {
|
|
69
81
|
name?: string;
|
|
70
82
|
backend?: BackendReference;
|
|
71
83
|
encryption?: CollectionEncryption;
|
|
84
|
+
force?: boolean;
|
|
72
85
|
}): Promise<CollectionDescription>;
|
|
73
86
|
/**
|
|
74
87
|
* Deletes the whole collection. Idempotent. To delete a single resource, use
|
package/dist/Collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAe1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,cAAc,EACd,uBAAuB,EACvB,eAAe,EAChB,MAAM,YAAY,CAAA;AAEnB,qBAAa,UAAU;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAO;IACpC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAoB;IACzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAE1C;;;;;;;;;;OAUG;gBACS,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,UAAU,EACX,EAAE;QACD,OAAO,EAAE,aAAa,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;QACpB,UAAU,CAAC,EAAE,KAAK,CAAA;QAClB,UAAU,CAAC,EAAE,kBAAkB,CAAA;KAChC;IA0BD,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,KAAK,WAAW,GAEtB;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM;IAId;;;;;;OAMG;IACG,QAAQ,IAAI,OAAO,CAAC,qBAAqB,GAAG,IAAI,C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AAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ3D;;;;;;;OAOG;IACG,SAAS,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAOjD;;;;;OAKG;IACG,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtD;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAKlC;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;OAKG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAOxC;;;;;;;;;;;;;;OAcG;IACG,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAOlD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAM5C"}
|
package/dist/Collection.js
CHANGED
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { collectionPath, collectionItems, collectionPolicy, collectionLinkset, collectionBackend, collectionQuota, resourcePath, toUrl } from './internal/paths.js';
|
|
10
10
|
import { assertNotReserved } from './internal/reserved.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { ValidationError } from './errors.js';
|
|
12
|
+
import { delegateGrantAt } from './internal/grant.js';
|
|
13
|
+
import { send, readData } from './internal/request.js';
|
|
14
|
+
import { CodecHolder, resolveCodec } from './internal/codec.js';
|
|
15
|
+
import { buildPageWalk, collectPages, walkPages } from './internal/pagination.js';
|
|
15
16
|
import { describeCollection } from './internal/describe.js';
|
|
16
17
|
import { readEtag } from './internal/conditional.js';
|
|
17
18
|
import { sendEncodedWrite } from './internal/write.js';
|
|
@@ -37,6 +38,16 @@ export class Collection {
|
|
|
37
38
|
* marker-discovery round-trip
|
|
38
39
|
*/
|
|
39
40
|
constructor({ context, spaceId, collectionId, capability, encryption }) {
|
|
41
|
+
// Guard the id against the Reserved Path Segment Registry up front
|
|
42
|
+
// (mirroring the `Resource` constructor), so a reserved id from caller
|
|
43
|
+
// input can never be mis-targeted at a space-level endpoint.
|
|
44
|
+
// `collectionPath(s, 'policy')` is byte-identical to the space policy path,
|
|
45
|
+
// so an unguarded `collection('policy').delete()` would silently wipe the
|
|
46
|
+
// space's access-control policy; the same collision exists for `backends` /
|
|
47
|
+
// `quotas` / `linkset` / `export` / `import` / `query`. Guarding in the
|
|
48
|
+
// constructor covers every operation (describe, delete, list, grant, ...),
|
|
49
|
+
// not just writes.
|
|
50
|
+
assertNotReserved({ id: collectionId, kind: 'collection' });
|
|
40
51
|
this._context = context;
|
|
41
52
|
this.spaceId = spaceId;
|
|
42
53
|
this.id = collectionId;
|
|
@@ -46,11 +57,7 @@ export class Collection {
|
|
|
46
57
|
spaceId: this.spaceId,
|
|
47
58
|
collectionId: this.id,
|
|
48
59
|
override: this._encryptionOverride,
|
|
49
|
-
|
|
50
|
-
spaceId: this.spaceId,
|
|
51
|
-
collectionId: this.id,
|
|
52
|
-
capability: this._capability
|
|
53
|
-
})
|
|
60
|
+
capability: this._capability
|
|
54
61
|
}));
|
|
55
62
|
}
|
|
56
63
|
get _path() {
|
|
@@ -97,6 +104,16 @@ export class Collection {
|
|
|
97
104
|
* Creates or updates the collection by id (upsert). Merges the given fields
|
|
98
105
|
* over the current description.
|
|
99
106
|
*
|
|
107
|
+
* The merge needs a readable current description to be lost-update-safe, and
|
|
108
|
+
* `describe()` cannot distinguish "absent" from "unreadable" (WAS masks
|
|
109
|
+
* unauthorized reads as 404). When it returns `null` and neither `backend`
|
|
110
|
+
* nor `encryption` is supplied, this fails closed rather than sending a PUT
|
|
111
|
+
* body that would silently drop an existing collection's `backend` (a
|
|
112
|
+
* data-placement change) or trip `encryption-immutable` by clearing its
|
|
113
|
+
* marker on a replace-semantics server. Pass `force: true` to proceed anyway
|
|
114
|
+
* -- e.g. when creating a new collection through a handle (or use
|
|
115
|
+
* `space.createCollection()`, which does not merge).
|
|
116
|
+
*
|
|
100
117
|
* @param desc {object}
|
|
101
118
|
* @param [desc.name] {string}
|
|
102
119
|
* @param [desc.backend] {BackendReference}
|
|
@@ -104,11 +121,24 @@ export class Collection {
|
|
|
104
121
|
* encryption marker. Set-once on the server: it may be added to a Collection
|
|
105
122
|
* that lacks one, but changing/clearing an existing marker is rejected
|
|
106
123
|
* (`ConflictError`, `encryption-immutable`).
|
|
124
|
+
* @param [desc.force] {boolean} proceed even when the current description
|
|
125
|
+
* is unreadable and `backend`/`encryption` are omitted (see above)
|
|
107
126
|
* @returns {Promise<CollectionDescription>}
|
|
108
127
|
*/
|
|
109
128
|
async configure(desc) {
|
|
110
|
-
assertNotReserved(this.id, 'collection');
|
|
111
129
|
const current = await this.describe();
|
|
130
|
+
if (current === null &&
|
|
131
|
+
desc.backend === undefined &&
|
|
132
|
+
desc.encryption === undefined &&
|
|
133
|
+
!desc.force) {
|
|
134
|
+
throw new ValidationError(`Cannot configure collection "${this.id}": its current description ` +
|
|
135
|
+
'is not readable with this capability (WAS returns 404 for both ' +
|
|
136
|
+
'not-found and unauthorized), so merging forward could silently ' +
|
|
137
|
+
"drop an existing collection's backend or encryption marker. " +
|
|
138
|
+
'Supply `backend`/`encryption` explicitly, use a read-capable ' +
|
|
139
|
+
'capability, or pass `force: true` if you are creating a new ' +
|
|
140
|
+
'collection.');
|
|
141
|
+
}
|
|
112
142
|
// Merge every current field forward (mirror `Space.configure`): a
|
|
113
143
|
// replace-semantics server drops anything omitted from the PUT body, so
|
|
114
144
|
// `configure({ name })` on an EDV collection would otherwise wipe its
|
|
@@ -247,8 +277,12 @@ export class Collection {
|
|
|
247
277
|
const location = response.headers.get('location') ?? undefined;
|
|
248
278
|
return {
|
|
249
279
|
id,
|
|
250
|
-
|
|
251
|
-
|
|
280
|
+
// RFC 9110 permits a relative `Location`; resolve it against the request
|
|
281
|
+
// URL so `AddResult.url` is always absolute (consumers like
|
|
282
|
+
// `was.publicRead({ resourceUrl })` require an absolute URL).
|
|
283
|
+
url: location
|
|
284
|
+
? new URL(location, toUrl({ serverUrl: this._context.serverUrl, path: this._itemsPath })).toString()
|
|
285
|
+
: toUrl({
|
|
252
286
|
serverUrl: this._context.serverUrl,
|
|
253
287
|
path: resourcePath(this.spaceId, this.id, id)
|
|
254
288
|
}),
|
|
@@ -265,14 +299,9 @@ export class Collection {
|
|
|
265
299
|
* @returns {Promise<Json | Blob | null>}
|
|
266
300
|
*/
|
|
267
301
|
async get(resourceId) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
method: 'GET',
|
|
272
|
-
capability: this._capability,
|
|
273
|
-
read: true
|
|
274
|
-
});
|
|
275
|
-
return response === null ? null : codec.decode(response);
|
|
302
|
+
// Delegate to the resource handle (the way `put()` does) so the reserved-id
|
|
303
|
+
// guard in the `Resource` constructor applies to reads and writes alike.
|
|
304
|
+
return this.resource(resourceId).get();
|
|
276
305
|
}
|
|
277
306
|
/**
|
|
278
307
|
* Creates or replaces a resource by id (upsert). Forwards the conditional-write
|
|
@@ -298,17 +327,7 @@ export class Collection {
|
|
|
298
327
|
* @returns {Promise<PageWalk | null>}
|
|
299
328
|
*/
|
|
300
329
|
async _listWalk() {
|
|
301
|
-
|
|
302
|
-
path: this._itemsPath,
|
|
303
|
-
method: 'GET',
|
|
304
|
-
capability: this._capability,
|
|
305
|
-
read: true
|
|
306
|
-
});
|
|
307
|
-
if (response === null) {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
return {
|
|
311
|
-
first: response.data,
|
|
330
|
+
return buildPageWalk({
|
|
312
331
|
firstUrl: toUrl({
|
|
313
332
|
serverUrl: this._context.serverUrl,
|
|
314
333
|
path: this._itemsPath
|
|
@@ -322,7 +341,7 @@ export class Collection {
|
|
|
322
341
|
});
|
|
323
342
|
return dataOrNull(pageResponse);
|
|
324
343
|
}
|
|
325
|
-
};
|
|
344
|
+
});
|
|
326
345
|
}
|
|
327
346
|
/**
|
|
328
347
|
* Lists the items in the collection. Transparently follows the server's `next`
|
|
@@ -376,11 +395,10 @@ export class Collection {
|
|
|
376
395
|
* @returns {Promise<IDelegatedZcap>}
|
|
377
396
|
*/
|
|
378
397
|
async grant(options) {
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
capability: options.capability ?? this._capability
|
|
398
|
+
return delegateGrantAt(this._context, {
|
|
399
|
+
path: this._path,
|
|
400
|
+
options,
|
|
401
|
+
capability: this._capability
|
|
384
402
|
});
|
|
385
403
|
}
|
|
386
404
|
/**
|
|
@@ -448,13 +466,10 @@ export class Collection {
|
|
|
448
466
|
* @returns {Promise<LinkSet | null>}
|
|
449
467
|
*/
|
|
450
468
|
async linkset() {
|
|
451
|
-
|
|
469
|
+
return readData(this._context, {
|
|
452
470
|
path: collectionLinkset(this.spaceId, this.id),
|
|
453
|
-
|
|
454
|
-
capability: this._capability,
|
|
455
|
-
read: true
|
|
471
|
+
capability: this._capability
|
|
456
472
|
});
|
|
457
|
-
return dataOrNull(response);
|
|
458
473
|
}
|
|
459
474
|
/**
|
|
460
475
|
* Reads the storage backend this collection is stored on ("Collection Backend
|
|
@@ -472,13 +487,10 @@ export class Collection {
|
|
|
472
487
|
* @returns {Promise<BackendDescriptor | null>}
|
|
473
488
|
*/
|
|
474
489
|
async backend() {
|
|
475
|
-
|
|
490
|
+
return readData(this._context, {
|
|
476
491
|
path: collectionBackend(this.spaceId, this.id),
|
|
477
|
-
|
|
478
|
-
capability: this._capability,
|
|
479
|
-
read: true
|
|
492
|
+
capability: this._capability
|
|
480
493
|
});
|
|
481
|
-
return dataOrNull(response);
|
|
482
494
|
}
|
|
483
495
|
/**
|
|
484
496
|
* Reads the collection's storage usage report, scoped to its backend (spec
|
|
@@ -489,13 +501,10 @@ export class Collection {
|
|
|
489
501
|
* @returns {Promise<BackendUsage | null>}
|
|
490
502
|
*/
|
|
491
503
|
async quota() {
|
|
492
|
-
|
|
504
|
+
return readData(this._context, {
|
|
493
505
|
path: collectionQuota(this.spaceId, this.id),
|
|
494
|
-
|
|
495
|
-
capability: this._capability,
|
|
496
|
-
read: true
|
|
506
|
+
capability: this._capability
|
|
497
507
|
});
|
|
498
|
-
return dataOrNull(response);
|
|
499
508
|
}
|
|
500
509
|
}
|
|
501
510
|
//# sourceMappingURL=Collection.js.map
|
package/dist/Collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,KAAK,EACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,KAAK,EACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EACL,aAAa,EACb,YAAY,E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,CAAC,WAAW;SAC7B,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK;QACT,OAAO,QAAQ,CAAe,IAAI,CAAC,QAAQ,EAAE;YAC3C,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAC5C,UAAU,EAAE,IAAI,CAAC,WAAW;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/Resource.d.ts
CHANGED
|
@@ -7,9 +7,24 @@ export declare class Resource {
|
|
|
7
7
|
readonly id: string;
|
|
8
8
|
private readonly _context;
|
|
9
9
|
private readonly _capability?;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the codec for this resource: the parent collection's shared codec
|
|
12
|
+
* when this handle came from `collection.resource(id)`, otherwise one
|
|
13
|
+
* resolved (and memoized per handle) for its own collection. A standalone
|
|
14
|
+
* resource discovers its collection's `encryption` marker (one GET on the
|
|
15
|
+
* collection, cached per handle) unless a per-handle override is set, and
|
|
16
|
+
* fails closed if it cannot key an encrypted collection. A fresh standalone
|
|
17
|
+
* handle re-reads the marker, so retain the handle to reuse it. A failed
|
|
18
|
+
* resolution (e.g. a transient 500/network error during marker discovery) is
|
|
19
|
+
* not memoized: the cache is cleared so the next call retries rather than
|
|
20
|
+
* re-throwing the stale error forever.
|
|
21
|
+
*
|
|
22
|
+
* A handle obtained via `collection.resource(id)` delegates to the parent's
|
|
23
|
+
* shared resolver on every call rather than memoizing locally: the parent
|
|
24
|
+
* already memoizes (so this adds no round-trip), and delegating lets a parent
|
|
25
|
+
* reset (e.g. after `configure()` adds the encryption marker) propagate here.
|
|
26
|
+
*/
|
|
27
|
+
private readonly _codec;
|
|
13
28
|
/**
|
|
14
29
|
* @param options {object}
|
|
15
30
|
* @param options.context {ClientContext}
|
|
@@ -35,26 +50,6 @@ export declare class Resource {
|
|
|
35
50
|
encryption?: EncryptionOverride;
|
|
36
51
|
});
|
|
37
52
|
private get _path();
|
|
38
|
-
/**
|
|
39
|
-
* Resolves (once, then caches) the codec for this resource: the parent
|
|
40
|
-
* collection's shared codec when this handle came from
|
|
41
|
-
* `collection.resource(id)`, otherwise one resolved for its own collection. A
|
|
42
|
-
* standalone resource discovers its collection's `encryption` marker (one GET
|
|
43
|
-
* on the collection, cached per handle) unless a per-handle override is set,
|
|
44
|
-
* and fails closed if it cannot key an encrypted collection. A fresh
|
|
45
|
-
* standalone handle re-reads the marker, so retain the handle to reuse it. A
|
|
46
|
-
* failed resolution (e.g. a transient 500/network error during marker
|
|
47
|
-
* discovery) is not memoized: the cache is cleared so the next call retries
|
|
48
|
-
* rather than re-throwing the stale error forever.
|
|
49
|
-
*
|
|
50
|
-
* A handle obtained via `collection.resource(id)` delegates to the parent's
|
|
51
|
-
* shared thunk on every call rather than memoizing locally: the parent already
|
|
52
|
-
* memoizes (so this adds no round-trip), and delegating lets a parent reset
|
|
53
|
-
* (e.g. after `configure()` adds the encryption marker) propagate here.
|
|
54
|
-
*
|
|
55
|
-
* @returns {Promise<ResourceCodec>}
|
|
56
|
-
*/
|
|
57
|
-
private _codec;
|
|
58
53
|
/**
|
|
59
54
|
* Reads the resource, auto-parsing JSON to an object and returning binary as
|
|
60
55
|
* a `Blob`. Returns `null` if the resource is missing or not visible to you
|
|
@@ -69,6 +64,12 @@ export declare class Resource {
|
|
|
69
64
|
* codec, so on an encrypted collection it never decrypts -- use `get()` to
|
|
70
65
|
* decrypt.
|
|
71
66
|
*
|
|
67
|
+
* For a JSON content-type the request layer has already consumed and parsed
|
|
68
|
+
* the body stream (`@interop/http-client` offers no opt-out through ezcap),
|
|
69
|
+
* so the text is re-serialized from the parsed value: semantically identical
|
|
70
|
+
* JSON, but not guaranteed byte-identical to what was uploaded (insignificant
|
|
71
|
+
* whitespace is not preserved).
|
|
72
|
+
*
|
|
72
73
|
* @returns {Promise<string | null>}
|
|
73
74
|
*/
|
|
74
75
|
getText(): Promise<string | null>;
|
|
@@ -78,6 +79,12 @@ export declare class Resource {
|
|
|
78
79
|
* it does NOT run the codec, so on an encrypted collection it never decrypts
|
|
79
80
|
* -- use `get()` to decrypt.
|
|
80
81
|
*
|
|
82
|
+
* For a JSON content-type the request layer has already consumed and parsed
|
|
83
|
+
* the body stream (`@interop/http-client` offers no opt-out through ezcap),
|
|
84
|
+
* so the bytes are re-serialized from the parsed value: semantically
|
|
85
|
+
* identical JSON, but not guaranteed byte-identical to what was uploaded
|
|
86
|
+
* (insignificant whitespace is not preserved).
|
|
87
|
+
*
|
|
81
88
|
* @returns {Promise<Uint8Array | null>}
|
|
82
89
|
*/
|
|
83
90
|
getBytes(): Promise<Uint8Array | null>;
|
|
@@ -97,7 +104,10 @@ export declare class Resource {
|
|
|
97
104
|
* `ifNoneMatch: true` for a create-if-absent. A failed precondition throws
|
|
98
105
|
* `PreconditionFailedError` (412). On an encrypted collection these are managed
|
|
99
106
|
* automatically by the codec (the EDV `sequence` becomes the enforced ETag), so
|
|
100
|
-
* the explicit options are for plaintext collections
|
|
107
|
+
* the explicit options are for plaintext collections -- and because the codec
|
|
108
|
+
* pre-reads the current document to compute them, updating an existing
|
|
109
|
+
* encrypted document needs read access (a PUT-only capability can only create;
|
|
110
|
+
* see `upsertResource`). Returns the new `etag`.
|
|
101
111
|
*
|
|
102
112
|
* @param data {ResourceData}
|
|
103
113
|
* @param options {object}
|
|
@@ -183,6 +193,10 @@ export declare class Resource {
|
|
|
183
193
|
/**
|
|
184
194
|
* Sets the resource's human-readable `name` (the value surfaced in collection
|
|
185
195
|
* listings), preserving any existing `tags`. Convenience over `setMeta()`.
|
|
196
|
+
* The write is pinned to the `etag` the `meta()` read returned (when the
|
|
197
|
+
* backend supports `conditional-writes`), so a concurrent metadata write
|
|
198
|
+
* surfaces as `PreconditionFailedError` instead of being silently erased by
|
|
199
|
+
* this full-replacement write.
|
|
186
200
|
*
|
|
187
201
|
* @param name {string}
|
|
188
202
|
* @returns {Promise<void>}
|
|
@@ -190,7 +204,7 @@ export declare class Resource {
|
|
|
190
204
|
setName(name: string): Promise<void>;
|
|
191
205
|
/**
|
|
192
206
|
* Sets the resource's `tags`, preserving any existing `name`. Convenience over
|
|
193
|
-
* `setMeta()`.
|
|
207
|
+
* `setMeta()`. Pinned to the `meta()` read's `etag` like {@link setName}.
|
|
194
208
|
*
|
|
195
209
|
* @param tags {Record<string, string>}
|
|
196
210
|
* @returns {Promise<void>}
|
package/dist/Resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAM1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EACV,kBAAkB,EAClB,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAQnB,qBAAa,QAAQ;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAO;IACpC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IAErD;;;;;;;;;;;;;;OAcG;gBACS,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,UAAU,EACV,KAAK,EACL,UAAU,EACX,EAAE;QACD,OAAO,EAAE,aAAa,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;Q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