@interop/was-client 0.98.0 → 0.99.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 +59 -41
- package/dist/Collection.d.ts +43 -15
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +127 -54
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +26 -11
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +26 -11
- package/dist/Resource.js.map +1 -1
- package/dist/WasClient.d.ts +20 -4
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +27 -6
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +6 -14
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts +2 -1
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +312 -80
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +76 -12
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +76 -11
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +11 -9
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/index.d.ts +1 -0
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/transportFactory.d.ts.map +1 -1
- package/dist/edv/transportFactory.js +3 -2
- package/dist/edv/transportFactory.js.map +1 -1
- package/dist/errors.d.ts +13 -6
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +16 -7
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codec.d.ts +51 -2
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +53 -21
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/indexSchema.d.ts +30 -0
- package/dist/internal/indexSchema.d.ts.map +1 -1
- package/dist/internal/indexSchema.js +40 -0
- package/dist/internal/indexSchema.js.map +1 -1
- package/dist/internal/meta.d.ts +9 -3
- package/dist/internal/meta.d.ts.map +1 -1
- package/dist/internal/meta.js +13 -7
- package/dist/internal/meta.js.map +1 -1
- package/dist/internal/paths.d.ts +11 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +13 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/request.d.ts +9 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +31 -3
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/write.d.ts +10 -10
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +23 -30
- package/dist/internal/write.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/interop-alliance/was-client/actions?query=workflow%3A%22CI%22)
|
|
4
4
|
[](https://npm.im/@interop/was-client)
|
|
5
5
|
|
|
6
|
-
> A developer-friendly client for Wallet Attached Storage (
|
|
6
|
+
> A developer-friendly client for Wallet Attached Storage (PWS) servers, with a
|
|
7
7
|
> database-driver-inspired navigational API over zcap-authorized HTTP.
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
- [Storage introspection: backends and quotas](#storage-introspection-backends-and-quotas)
|
|
28
28
|
- [Registering a Bring-Your-Own-Storage backend](#registering-a-bring-your-own-storage-backend)
|
|
29
29
|
- [Replica registration](#replica-registration)
|
|
30
|
-
- [Encrypted collections (EDV-over-
|
|
30
|
+
- [Encrypted collections (EDV-over-PWS): pass-through encryption via the PWS client (recommended)](#encrypted-collections-edv-over-pws-pass-through-encryption-via-the-pws-client-recommended)
|
|
31
31
|
- [Cross-replica sync](#cross-replica-sync)
|
|
32
32
|
- [Resource logs (co-managed key resources)](#resource-logs-co-managed-key-resources)
|
|
33
33
|
- [Export and import](#export-and-import)
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
|
|
39
39
|
## Background
|
|
40
40
|
|
|
41
|
-
The
|
|
41
|
+
The PWS protocol exposes a general purpose database-like container model --
|
|
42
42
|
`SpacesRepository > Space > Collection > Resource` -- over HTTP, authorized with
|
|
43
43
|
[Authorization Capabilities (zcaps)](https://w3c-ccg.github.io/zcap-spec/).
|
|
44
44
|
|
|
45
45
|
`@interop/was-client` wraps that `ZcapClient` and exposes the containment model
|
|
46
46
|
through cheap, lazy navigational handles modeled on a document store's DX
|
|
47
|
-
(`client > db > collection`), using
|
|
48
|
-
(`add`/`get`/`put`/`list`/`delete`) rather than `insertOne`/`findOne` (
|
|
47
|
+
(`client > db > collection`), using PWS-specific verbs
|
|
48
|
+
(`add`/`get`/`put`/`list`/`delete`) rather than `insertOne`/`findOne` (PWS has
|
|
49
49
|
no query-by-filter yet).
|
|
50
50
|
|
|
51
|
-
| Document db driver |
|
|
51
|
+
| Document db driver | PWS client |
|
|
52
52
|
| ----------------------------------- | ------------------------------------------ |
|
|
53
53
|
| `new Client(url)` | `new WasClient({ serverUrl, zcapClient })` |
|
|
54
54
|
| `client.db('app')` | `was.space(spaceId)` |
|
|
@@ -205,7 +205,7 @@ own pace produces.
|
|
|
205
205
|
Before its first signed request, the client reads the server's service
|
|
206
206
|
description. It sends an unsigned `HEAD` to `serverUrl`, the Spaces Repository
|
|
207
207
|
URL, and follows the `Link: <...>; rel="service"` header on the response,
|
|
208
|
-
whatever its status. The
|
|
208
|
+
whatever its status. The PWS server itself answers that URL. The server root is
|
|
209
209
|
often a landing page served by something else, with no `service` link. Then it
|
|
210
210
|
reads the linked document with an unsigned `GET`. The spec fixes no path for the
|
|
211
211
|
document, so the client assumes none. A server that advertises its Spaces
|
|
@@ -213,7 +213,7 @@ Repository at a URL other than `serverUrl` is refused with
|
|
|
213
213
|
`IncompatibleServerError`, since every Space path would otherwise be addressed
|
|
214
214
|
at the wrong mount.
|
|
215
215
|
|
|
216
|
-
From the document the client selects the
|
|
216
|
+
From the document the client selects the PWS specification version it speaks.
|
|
217
217
|
This client speaks only v0.5. It ignores `specs` keys other than
|
|
218
218
|
`https://w3id.org/pws` and entries without a `version`. If no entry names v0.5,
|
|
219
219
|
or the document is malformed, every signed request rejects with
|
|
@@ -251,7 +251,7 @@ that copy without fetching, and `service({ refresh: true })` discovers afresh.
|
|
|
251
251
|
|
|
252
252
|
### The handle model
|
|
253
253
|
|
|
254
|
-
The client exposes the
|
|
254
|
+
The client exposes the PWS containment model
|
|
255
255
|
(`SpacesRepository > Space > Collection > Resource`) as navigational handles.
|
|
256
256
|
Handles are lazy and synchronous to obtain -- only the verb methods hit the
|
|
257
257
|
network. Lazy chains never throw: `was.space(x).collection(y)` does no I/O and
|
|
@@ -350,7 +350,7 @@ const userSpaces = items.filter(item => !item.type.includes('AuxiliarySpace'))
|
|
|
350
350
|
|
|
351
351
|
### Collections
|
|
352
352
|
|
|
353
|
-
A Collection lives inside a Space and holds resources.
|
|
353
|
+
A Collection lives inside a Space and holds resources. PWS does not auto-create
|
|
354
354
|
parents, so `createCollection` throws `NotFoundError` if the space does not
|
|
355
355
|
exist. The server generates the id unless you pass one (a handful of reserved
|
|
356
356
|
ids are rejected).
|
|
@@ -451,7 +451,7 @@ Writes detect the payload: a plain object/array is sent as JSON; a
|
|
|
451
451
|
`Blob`/`Uint8Array`/`Buffer` is sent as binary, with the content-type taken from
|
|
452
452
|
`options.contentType`, the `Blob.type`, or `application/octet-stream`. A
|
|
453
453
|
`ReadableStream<Uint8Array>` is accepted only by an encrypted collection (see
|
|
454
|
-
[Encrypted collections](#encrypted-collections-edv-over-
|
|
454
|
+
[Encrypted collections](#encrypted-collections-edv-over-pws-pass-through-encryption-via-the-pws-client-recommended)).
|
|
455
455
|
A plaintext collection refuses it with `ValidationError`. A plaintext resource
|
|
456
456
|
has no chunked representation, and a signed request carries a `Digest` of its
|
|
457
457
|
whole body. Buffer the stream into a `Blob` there.
|
|
@@ -502,7 +502,7 @@ handle's URL. The recipient rebuilds access from the received zcap with
|
|
|
502
502
|
const added = await collection.add({ secret: 'value' })
|
|
503
503
|
const zcap = await was.grant({
|
|
504
504
|
to: bobDid,
|
|
505
|
-
actions: ['GET'], // HTTP verbs: 'GET' | 'PUT' | 'POST' | 'DELETE'
|
|
505
|
+
actions: ['GET'], // HTTP verbs: 'GET' | 'HEAD' | 'PUT' | 'POST' | 'DELETE'
|
|
506
506
|
target: added.url
|
|
507
507
|
})
|
|
508
508
|
|
|
@@ -511,7 +511,18 @@ const handle = bobWas.fromCapability(zcap) // a Resource here
|
|
|
511
511
|
await handle.get() // succeeds; a write would be denied by the GET-only grant
|
|
512
512
|
```
|
|
513
513
|
|
|
514
|
-
|
|
514
|
+
A resource-scoped grant does not cover the Collection Metadata object, so a
|
|
515
|
+
client constructed with an `encryption` provider cannot discover whether the
|
|
516
|
+
collection is encrypted and fails closed with `EncryptionError`. Pass the handle
|
|
517
|
+
an explicit override, as you would to `collection.resource(id, options)`:
|
|
518
|
+
`'plaintext'` for a plaintext collection, or the collection's `encryption`
|
|
519
|
+
descriptor (shared out of band with the grant) for an encrypted one.
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
const handle = bobWas.fromCapability(zcap, { encryption: 'plaintext' })
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
Actions are HTTP verbs (`GET` / `PUT` / `POST` / `DELETE`). The PWS server
|
|
515
526
|
authorizes on these case-sensitively (uppercase), but `grant()` also accepts the
|
|
516
527
|
lowercase forms and normalizes them to uppercase in the signed zcap -- so
|
|
517
528
|
`actions: ['get']` still validates server-side.
|
|
@@ -531,7 +542,7 @@ await space.revoke(zcap) // from now on the capability is rejected
|
|
|
531
542
|
Two parties may revoke: the Space's controller, and any controller in the
|
|
532
543
|
capability's own delegation chain -- so an application can revoke the capability
|
|
533
544
|
it holds, without being granted anything extra. Anyone else gets a
|
|
534
|
-
`NotFoundError`,
|
|
545
|
+
`NotFoundError`, PWS's mask for "not visible to you".
|
|
535
546
|
|
|
536
547
|
Three properties are easy to get wrong:
|
|
537
548
|
|
|
@@ -757,7 +768,7 @@ const { descriptor } = await store.read() // verified head state, `history` kept
|
|
|
757
768
|
### Conditional writes (optimistic concurrency)
|
|
758
769
|
|
|
759
770
|
Every Resource carries a strong **`ETag`** validator that changes on every write
|
|
760
|
-
(conditional writes are a baseline
|
|
771
|
+
(conditional writes are a baseline PWS server requirement). Use it to prevent
|
|
761
772
|
the lost-update problem -- two clients that both read version _N_ and each write
|
|
762
773
|
_N+1_, the second silently clobbering the first.
|
|
763
774
|
|
|
@@ -996,7 +1007,7 @@ surfaces the Space's registrations as the read-only `replicas` member, one
|
|
|
996
1007
|
`{ fromSpace, toSpace, role }` summary per peer, with no registration id and no
|
|
997
1008
|
capability. The server ignores `replicas` in a write body.
|
|
998
1009
|
|
|
999
|
-
### Encrypted collections (EDV-over-
|
|
1010
|
+
### Encrypted collections (EDV-over-PWS): pass-through encryption via the PWS client (recommended)
|
|
1000
1011
|
|
|
1001
1012
|
This is the recommended way to use encrypted collections. For the low-level
|
|
1002
1013
|
alternative -- driving an `EdvClientCore` directly via `WasTransport`, which is
|
|
@@ -1082,7 +1093,7 @@ Encrypted collections are a **stricter contract**, not a drop-in (documents-only
|
|
|
1082
1093
|
scope for now):
|
|
1083
1094
|
|
|
1084
1095
|
- **Ids.** `add()` mints an EDV id (a `z`-prefixed multibase value used verbatim
|
|
1085
|
-
as the
|
|
1096
|
+
as the PWS resource id). `put(id, ...)` accepts only an EDV-format id; a
|
|
1086
1097
|
human-readable id is rejected (it would leak onto the URL) -- carry a
|
|
1087
1098
|
human-readable label inside the encrypted content instead. By default the
|
|
1088
1099
|
minted id is random (the classic mutable-document model); pass
|
|
@@ -1106,23 +1117,23 @@ scope for now):
|
|
|
1106
1117
|
read back transparently by `get()`. Serving the chunk endpoints is a
|
|
1107
1118
|
conformance requirement of a server that offers encrypted collections, so
|
|
1108
1119
|
there is no client-side gate -- one that does not answers `501`.
|
|
1109
|
-
`put(id, bigBlob)` takes the same route
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
ciphertext derives its id. A chunked
|
|
1116
|
-
wrote, and a `507` surfaces as
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
the
|
|
1120
|
-
`
|
|
1120
|
+
`put(id, bigBlob)` takes the same route, creating the resource where none is
|
|
1121
|
+
stored at `id` (pass `ifNoneMatch: true` to get a `412` when the id is taken)
|
|
1122
|
+
and replacing the document otherwise. Replacing a chunked document, with a
|
|
1123
|
+
blob of any size or a JSON value, reaps the chunks the new document does not
|
|
1124
|
+
cover once it is stored. One limit applies: a content-addressed collection
|
|
1125
|
+
(`idDerivation: 'content'`) refuses a chunked write, since it stores the
|
|
1126
|
+
document twice and no single ciphertext derives its id. A chunked create that
|
|
1127
|
+
fails partway deletes what it wrote, and a `507` surfaces as
|
|
1128
|
+
`QuotaExceededError`. One that could not clean up, and a replace that fails
|
|
1129
|
+
partway, leave a pending stub, which every read refuses; the EDV doc cipher's
|
|
1130
|
+
`isPendingStub` recognizes it, the next `put()` at the id replaces it, and
|
|
1131
|
+
`delete()` removes it with its chunks. Tune the threshold and the chunk size
|
|
1132
|
+
with `createEdvEncryption({ maxBlobBytes, chunkSize })`.
|
|
1121
1133
|
- **Streams.** A `ReadableStream<Uint8Array>` has no known size, so `add()`
|
|
1122
1134
|
always routes it to the chunked-stream path, however short it is. It is
|
|
1123
1135
|
encrypted and written as it is read, without buffering. `put(id, stream)`
|
|
1124
|
-
takes the same route
|
|
1125
|
-
document it is refused with `ValidationError` before the stream is read. A
|
|
1136
|
+
takes the same route, creating or replacing the document at `id`. A
|
|
1126
1137
|
content-addressed collection refuses a stream for the reason it refuses a
|
|
1127
1138
|
large blob. A write that fails midway cancels the stream, so the source behind
|
|
1128
1139
|
it is released. The content type is `options.contentType`, then a guess from
|
|
@@ -1214,7 +1225,7 @@ const { count } = await vault.find({
|
|
|
1214
1225
|
```
|
|
1215
1226
|
|
|
1216
1227
|
Attribute names are dotted paths rooted at `content` or `meta` (the document's
|
|
1217
|
-
own `meta`, which carries the content type and encoding -- not the
|
|
1228
|
+
own `meta`, which carries the content type and encoding -- not the PWS `/meta`
|
|
1218
1229
|
name/tags, which live in a separate envelope and are deliberately not indexed).
|
|
1219
1230
|
Pass an array of names for a compound index, searchable by a leading prefix of
|
|
1220
1231
|
its attributes; `unique: true` makes the server answer a colliding write with
|
|
@@ -1241,14 +1252,16 @@ that offers encrypted collections; one that does not answers `501`
|
|
|
1241
1252
|
(`NotImplementedError`). `find()` / `declareIndex()` on a plaintext collection
|
|
1242
1253
|
throw -- there is no client-side index there.
|
|
1243
1254
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
it
|
|
1255
|
+
`collection.setMeta({ custom })` replaces the whole `custom` object, with one
|
|
1256
|
+
exception: a `custom` that does not name `indexSchema` keeps the stored schema.
|
|
1257
|
+
A `custom` that does name it is sent as given, so `indexSchema: undefined` drops
|
|
1258
|
+
the stored schema. The `setName()` / `setTags()` sugar merges and leaves it
|
|
1259
|
+
intact either way.
|
|
1247
1260
|
|
|
1248
1261
|
### Cross-replica sync
|
|
1249
1262
|
|
|
1250
1263
|
The opt-in `@interop/was-client/sync` subpath supplies everything a wallet needs
|
|
1251
|
-
to replicate one Space + Collection across devices, with
|
|
1264
|
+
to replicate one Space + Collection across devices, with PWS as the primary
|
|
1252
1265
|
copy. It is not a sync engine itself -- it provides the seams a change engine
|
|
1253
1266
|
plugs into:
|
|
1254
1267
|
|
|
@@ -1404,7 +1417,7 @@ const page = await collection.changes({ method: 'GET', checkpoint, limit: 100 })
|
|
|
1404
1417
|
|
|
1405
1418
|
### Resource logs (co-managed key resources)
|
|
1406
1419
|
|
|
1407
|
-
The opt-in `@interop/was-client/log` subpath is the
|
|
1420
|
+
The opt-in `@interop/was-client/log` subpath is the PWS binding of
|
|
1408
1421
|
`@interop/vh-resource-log`'s store port. Resource logs -- the hash-linked, JSON
|
|
1409
1422
|
Lines log format (the encrypted-collections spec's Resource Log Profile)
|
|
1410
1423
|
governing key resources co-managed between a wallet's clients and the storage
|
|
@@ -1415,8 +1428,8 @@ library: the JSON Lines codec, the `ResourceLogStore` port, the read-back
|
|
|
1415
1428
|
re-exports none of them.
|
|
1416
1429
|
|
|
1417
1430
|
- **`resourceLogStore({ resource })`** / **`resourceLogStore({ collection })`**
|
|
1418
|
-
-- the port over one of the two places a
|
|
1419
|
-
`text/jsonl` either way: a
|
|
1431
|
+
-- the port over one of the two places a PWS server keeps a log, stored as
|
|
1432
|
+
`text/jsonl` either way: a PWS Resource whose whole body is the log (a key
|
|
1420
1433
|
roster), or a Collection's governing history log at its `/meta/log`
|
|
1421
1434
|
sub-resource (the descriptor the server derives `encryption` from; see "The
|
|
1422
1435
|
governing history log" above). The store does read-with-etag of the full log,
|
|
@@ -1471,7 +1484,7 @@ const response = await was.request({ path: `/space/${spaceId}`, method: 'GET' })
|
|
|
1471
1484
|
## Errors and the 404/null caveat
|
|
1472
1485
|
|
|
1473
1486
|
Read methods (`describe`/`get`/`list`) return `null` on a 404, following
|
|
1474
|
-
MongoDB's `findOne` semantics. **
|
|
1487
|
+
MongoDB's `findOne` semantics. **PWS returns 404 for both not-found and
|
|
1475
1488
|
unauthorized**, so `null` means "not visible to you" rather than strictly "does
|
|
1476
1489
|
not exist". Write/delete methods throw a typed error instead.
|
|
1477
1490
|
|
|
@@ -1500,9 +1513,14 @@ instead, as `{ outcome: 'not-found' }`, rather than swallowing it.
|
|
|
1500
1513
|
Spec endpoints a given server has not yet implemented surface as
|
|
1501
1514
|
`NotImplementedError` (the server's 501).
|
|
1502
1515
|
|
|
1516
|
+
The client-side errors (`EncryptionError` and its subtypes, `NotSupportedError`,
|
|
1517
|
+
`UnknownEpochError`) are `WasError`s too; they carry no `status`. An
|
|
1518
|
+
`UnknownEpochError` carries the `collectionId` whose descriptor to re-read and
|
|
1519
|
+
the envelope's unroutable `kids`.
|
|
1520
|
+
|
|
1503
1521
|
`IncompatibleServerError` comes from service discovery, not from a response
|
|
1504
1522
|
status. Any signed method, read methods included, throws it when the server
|
|
1505
|
-
speaks no
|
|
1523
|
+
speaks no PWS version this client understands (see
|
|
1506
1524
|
[Service discovery](#service-discovery)). It carries no `status`, so a read
|
|
1507
1525
|
method does not mistake it for a 404.
|
|
1508
1526
|
|
package/dist/Collection.d.ts
CHANGED
|
@@ -77,7 +77,12 @@ export declare class Collection {
|
|
|
77
77
|
*
|
|
78
78
|
* The merge runs against the same read the write is pinned to, and rebases
|
|
79
79
|
* with it: a rival configuration change landing in between is re-read and
|
|
80
|
-
* merged over rather than re-applied stale.
|
|
80
|
+
* merged over rather than re-applied stale. That covers the `encryption`
|
|
81
|
+
* descriptor too, which the merge carries forward whole: a reader escrowed
|
|
82
|
+
* into the current epoch by a concurrent `addRecipient` is re-read on the
|
|
83
|
+
* rebase, so this write never sends the roster without that reader's
|
|
84
|
+
* wrapped key. Pass `ifMatch` to pin the write to a validator of your own
|
|
85
|
+
* instead, and see a lost race as `PreconditionFailedError`.
|
|
81
86
|
*
|
|
82
87
|
* The merge needs a readable current object to be lost-update-safe, and the
|
|
83
88
|
* read cannot distinguish "absent" from "unreadable" (WAS masks unauthorized
|
|
@@ -108,18 +113,24 @@ export declare class Collection {
|
|
|
108
113
|
* rather than merged forward. `null` means the caller read it and found
|
|
109
114
|
* the collection absent or unreadable; omitting the member entirely is
|
|
110
115
|
* what asks for the read
|
|
116
|
+
* @param [desc.ifMatch] {string} the caller's own validator (the `etag`
|
|
117
|
+
* from {@link describeWithEtag}): the merge then runs once against the
|
|
118
|
+
* version it names and a lost race surfaces as `PreconditionFailedError`
|
|
119
|
+
* instead of being rebased, for a caller whose decision to write depends
|
|
120
|
+
* on what it read. A pinned write is to an object the caller has read, so
|
|
121
|
+
* an unreadable one is `NotFoundError`, not a create
|
|
111
122
|
* @returns {Promise<{ description: CollectionMetadata; etag?: string }>}
|
|
112
123
|
* the `description` as merged and written by the last attempt, together
|
|
113
|
-
* with that write's `etag` -- the validator to pass to
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* the client
|
|
124
|
+
* with that write's `etag` -- the validator to pass to a follow-on
|
|
125
|
+
* `ifMatch` for a compare-and-swap. `etag` is absent only where the header
|
|
126
|
+
* did not reach the client
|
|
117
127
|
*/
|
|
118
128
|
configure(desc: CollectionWritableFields & {
|
|
119
129
|
force?: boolean;
|
|
120
130
|
current?: (CollectionMetadata & {
|
|
121
131
|
etag?: string;
|
|
122
132
|
}) | null;
|
|
133
|
+
ifMatch?: string;
|
|
123
134
|
}): Promise<{
|
|
124
135
|
description: CollectionMetadata;
|
|
125
136
|
etag?: string;
|
|
@@ -200,11 +211,26 @@ export declare class Collection {
|
|
|
200
211
|
}) | null>;
|
|
201
212
|
/**
|
|
202
213
|
* Replaces the Collection's user-writable annotations (`custom`). This is a
|
|
203
|
-
* full replacement of `custom`: any
|
|
204
|
-
* an omitted `custom` clears
|
|
205
|
-
* members are carried forward -- the same `PUT` replaces the
|
|
206
|
-
* Collection Metadata object, so they are read and re-sent rather
|
|
207
|
-
* dropped.
|
|
214
|
+
* full replacement of `custom`: any annotation omitted from it is cleared,
|
|
215
|
+
* and an omitted `custom` clears every annotation. The Collection's
|
|
216
|
+
* configuration members are carried forward -- the same `PUT` replaces the
|
|
217
|
+
* whole Collection Metadata object, so they are read and re-sent rather
|
|
218
|
+
* than dropped.
|
|
219
|
+
*
|
|
220
|
+
* One member of `custom` is carried forward the same way, and is the one
|
|
221
|
+
* exception to the full replacement: the persisted `indexSchema` that
|
|
222
|
+
* {@link declareIndex} stores there. It is collection state this library
|
|
223
|
+
* owns, not an annotation the caller is replacing, so a `custom` with no
|
|
224
|
+
* `indexSchema` member of its own (and an omitted `custom`) keeps the stored
|
|
225
|
+
* one. A `custom` that names `indexSchema` is sent as given, and installs
|
|
226
|
+
* what it names on this handle's codec, as {@link declareIndex} does. That
|
|
227
|
+
* is also how the stored schema is dropped: a `custom` carrying
|
|
228
|
+
* `indexSchema: undefined` names the member, so nothing is carried forward,
|
|
229
|
+
* and the undefined member is omitted from the serialized write. Carrying
|
|
230
|
+
* the schema forward opens the stored `custom` through the codec (reusing
|
|
231
|
+
* the open a preceding {@link meta} read performed). A stored `custom` this
|
|
232
|
+
* client cannot open carries nothing, so the write still replaces it as
|
|
233
|
+
* given.
|
|
208
234
|
*
|
|
209
235
|
* On an encrypted collection `custom` is encrypted into an opaque envelope by
|
|
210
236
|
* the codec before it is sent, so `name` / `tags` are never stored as
|
|
@@ -230,7 +256,8 @@ export declare class Collection {
|
|
|
230
256
|
* @param meta {object}
|
|
231
257
|
* @param [meta.custom] {ResourceMetadataCustomInput} the user-writable
|
|
232
258
|
* properties; extra members beyond `name` / `tags` are admitted (this
|
|
233
|
-
* Collection-level `custom` also carries the persisted `indexSchema
|
|
259
|
+
* Collection-level `custom` also carries the persisted `indexSchema`,
|
|
260
|
+
* which is carried forward from the stored object when omitted here)
|
|
234
261
|
* while `name` / `tags` themselves stay checked at their stored types
|
|
235
262
|
* @param options {object}
|
|
236
263
|
* @param [options.ifMatch] {string} update only if the `ETag` matches
|
|
@@ -605,10 +632,11 @@ export declare class Collection {
|
|
|
605
632
|
* The query is sent as a `POST` whose body carries the parameters, or in
|
|
606
633
|
* the read-only `GET` form with the parameters in the query string, which
|
|
607
634
|
* the server verifies under the `GET` action and answers with the same page.
|
|
608
|
-
* A capability whose `allowedAction` excludes `POST` (a GET
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
* overrides the
|
|
635
|
+
* A capability whose `allowedAction` excludes `POST` (a GET and HEAD grant
|
|
636
|
+
* on the collection, say, which is what a subscription agent holds) reads
|
|
637
|
+
* the feed with `GET`, since the `POST` form refuses it with
|
|
638
|
+
* `NotFoundError`; every other handle sends `POST`. `method` overrides the
|
|
639
|
+
* derived form.
|
|
612
640
|
*
|
|
613
641
|
* @param [options] {object}
|
|
614
642
|
* @param [options.checkpoint] {ChangesCheckpoint} opaque checkpoint from a prior page; resume strictly after it
|
package/dist/Collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAgC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AA+BlE,OAAO,KAAK,EAEV,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,WAAW,EAEZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,YAAY,EAEZ,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,cAAc,EACd,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,cAAc,EACd,uBAAuB,EAEvB,2BAA2B,EAC3B,eAAe,EAChB,MAAM,YAAY,CAAA;AA8FnB,qBAAa,UAAU;;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAYnB;;;;;;;;;;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,EAA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