@procedures/client 0.35.0 → 0.36.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/CHANGELOG.md +67 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/http/server/handler.d.ts.map +1 -1
- package/dist/adapters/http/server/handler.js +17 -3
- package/dist/adapters/http/server/handler.js.map +1 -1
- package/dist/adapters/port/transport.d.ts.map +1 -1
- package/dist/adapters/port/transport.js +2 -0
- package/dist/adapters/port/transport.js.map +1 -1
- package/dist/adapters/websocket/server/transport.d.ts.map +1 -1
- package/dist/adapters/websocket/server/transport.js +2 -0
- package/dist/adapters/websocket/server/transport.js.map +1 -1
- package/dist/adapters/websocket/shared/rpc.d.ts.map +1 -1
- package/dist/adapters/websocket/shared/rpc.js +14 -5
- package/dist/adapters/websocket/shared/rpc.js.map +1 -1
- package/dist/browser.d.ts +6 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +4 -1
- package/dist/browser.js.map +1 -1
- package/dist/client/errors/index.d.ts +1 -1
- package/dist/client/errors/index.d.ts.map +1 -1
- package/dist/client/errors/index.js +1 -1
- package/dist/client/errors/index.js.map +1 -1
- package/dist/client/errors/registry.d.ts +10 -0
- package/dist/client/errors/registry.d.ts.map +1 -1
- package/dist/client/errors/registry.js +12 -0
- package/dist/client/errors/registry.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +5 -1
- package/dist/events/bus.js.map +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/publisher.d.ts +18 -2
- package/dist/events/publisher.d.ts.map +1 -1
- package/dist/events/publisher.js +142 -25
- package/dist/events/publisher.js.map +1 -1
- package/dist/events/recheck.d.ts +27 -5
- package/dist/events/recheck.d.ts.map +1 -1
- package/dist/events/recheck.js +11 -10
- package/dist/events/recheck.js.map +1 -1
- package/dist/procedures/collection/admission.d.ts +26 -7
- package/dist/procedures/collection/admission.d.ts.map +1 -1
- package/dist/procedures/collection/admission.js +39 -7
- package/dist/procedures/collection/admission.js.map +1 -1
- package/dist/procedures/collection/changes.d.ts +28 -4
- package/dist/procedures/collection/changes.d.ts.map +1 -1
- package/dist/procedures/collection/changes.js +50 -6
- package/dist/procedures/collection/changes.js.map +1 -1
- package/dist/procedures/collection/hint-filter.d.ts +143 -0
- package/dist/procedures/collection/hint-filter.d.ts.map +1 -0
- package/dist/procedures/collection/hint-filter.js +311 -0
- package/dist/procedures/collection/hint-filter.js.map +1 -0
- package/dist/procedures/collection/index.d.ts +2 -0
- package/dist/procedures/collection/index.d.ts.map +1 -1
- package/dist/procedures/collection/index.js +2 -0
- package/dist/procedures/collection/index.js.map +1 -1
- package/dist/procedures/collection/procedures.d.ts +2 -2
- package/dist/procedures/collection/procedures.d.ts.map +1 -1
- package/dist/procedures/collection/procedures.js +6 -4
- package/dist/procedures/collection/procedures.js.map +1 -1
- package/dist/procedures/index.d.ts +2 -2
- package/dist/procedures/index.d.ts.map +1 -1
- package/dist/procedures/index.js +3 -1
- package/dist/procedures/index.js.map +1 -1
- package/dist/server/error-policy.d.ts +96 -0
- package/dist/server/error-policy.d.ts.map +1 -0
- package/dist/server/error-policy.js +196 -0
- package/dist/server/error-policy.js.map +1 -0
- package/dist/server/error-response.d.ts +30 -0
- package/dist/server/error-response.d.ts.map +1 -0
- package/dist/server/error-response.js +90 -0
- package/dist/server/error-response.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/last-resort.d.ts +17 -0
- package/dist/server/last-resort.d.ts.map +1 -0
- package/dist/server/last-resort.js +19 -0
- package/dist/server/last-resort.js.map +1 -0
- package/dist/server/procedure-server.d.ts +3 -11
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +7 -42
- package/dist/server/procedure-server.js.map +1 -1
- package/dist/server/server.d.ts +43 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +39 -2
- package/dist/server/server.js.map +1 -1
- package/dist/server/types.d.ts +12 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/http/server/handler.ts +18 -3
- package/src/adapters/port/transport.ts +2 -0
- package/src/adapters/websocket/server/transport.ts +2 -0
- package/src/adapters/websocket/shared/rpc.ts +14 -5
- package/src/browser.ts +11 -0
- package/src/client/errors/index.ts +1 -0
- package/src/client/errors/registry.ts +13 -0
- package/src/client/index.ts +1 -0
- package/src/events/bus.ts +6 -1
- package/src/events/index.ts +1 -1
- package/src/events/publisher.ts +150 -26
- package/src/events/recheck.ts +38 -13
- package/src/procedures/collection/admission.ts +50 -9
- package/src/procedures/collection/changes.ts +68 -7
- package/src/procedures/collection/hint-filter.ts +376 -0
- package/src/procedures/collection/index.ts +3 -0
- package/src/procedures/collection/procedures.ts +8 -6
- package/src/procedures/index.ts +5 -0
- package/src/server/error-policy.ts +263 -0
- package/src/server/error-response.ts +91 -0
- package/src/server/index.ts +2 -0
- package/src/server/last-resort.ts +23 -0
- package/src/server/procedure-server.ts +8 -41
- package/src/server/server.ts +73 -3
- package/src/server/types.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# @procedures/client
|
|
2
2
|
|
|
3
|
+
## 0.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f1fae86: The publisher of the remote events filters the change events of a collection row by row, with the rule of its rows (roadmap CLI-78). Thus a principal with a rule of the rows can subscribe to a topic of a collection. It gets only the ids of the rows that it can read.
|
|
8
|
+
|
|
9
|
+
MINOR (breaking, pre-1.0): this change has a new default. Before, each subscriber got each id of an event, and `withheld` named the rows that the rule refused. With this change, a row that the rule refuses is not in the event of that subscriber. Before 1.0.0, a changed default raises the MINOR.
|
|
10
|
+
|
|
11
|
+
- The rule is `admission.admit` of `createCollectionProcedures()`. The reads apply the same rule. The publisher finds it in the registry of the call, so it also filters the events of other publishers on the topic.
|
|
12
|
+
- A changed row that the rule admits stays in `changed`. A changed row that the rule refuses, and a deleted row, go to `deleted` only when the rule admitted the row before the change. The subscriber does not get the id of a row that it could not read.
|
|
13
|
+
- The rule examines the rows of the event: the row after the change, from the change log, and the row before the change. While a subscriber has a filter, each write of the procedures reads the rows before it with one `getBatch()`. The publisher does not read a storage.
|
|
14
|
+
- When the event has no image of a row, or the rule fails, the subscriber gets a hint without ids and without `since`. It then reads the changes through the rule of the reads.
|
|
15
|
+
- An event with `reset: true` and an event without ids pass, without ids.
|
|
16
|
+
- When the subscriber can read no row of an event, it gets no event. Its next event gets the `since` of the last event that it got, so it applies the next delta without a read. The `seq` of the events counts only the events that the subscriber gets, so the subscriber sees no gap.
|
|
17
|
+
- With values, an event has only the values of the rows that the rule admits. `withheld` names only the rows that the output filter of the host (`admitItem`) refused.
|
|
18
|
+
- The new optional `admission.admitsAll(invocation, partition)` tells that a subscriber reads each row of its partition. The events of that subscriber then pass as before, with no filter and no read before a write.
|
|
19
|
+
- At a re-check after a change of the rights (`rightsChanged()`, roadmap CLI-44), each subscriber with a filter gets a `reset` hint, so it reads its rows again. A subscriber whose `admitsAll` changes at a re-check also gets a `reset` hint.
|
|
20
|
+
- A delta of `changes` gives only ids that the caller can read. Before, it put the id of each refused row in `deleted`. A delta with a refused row or a deleted row becomes a full answer (`full: true`) of the admitted rows. The copy of the caller then drops each other row. When `admitsAll` admits the caller, the delta stays as before.
|
|
21
|
+
- `admittedStorage()` has a new optional parameter `partition`. `admitsAll` gets it.
|
|
22
|
+
- The rules get an invocation of the collection, not the call of `events.subscribe`. It has the principal, the capability, the metadata and the signal of the subscription. Its path is the path of `changes`, and its input has the partition of the topic. Thus a rule that reads `invocation.input.partition` works for the events too.
|
|
23
|
+
- `rightsChanged(change, scope)` of `EventPublisher` has a new optional parameter `scope`: `{ collection?, partition? }` or a list of them. Each field is a name or a test of the name, for example a test of each partition of a tenant. A test that throws matches.
|
|
24
|
+
- With a scope, only the topics of the scope with a filter get a `reset` hint and a new `admitsAll`. Without it, the change touches each topic, as before. The source `recheck.rightsChanges` can give a scope to its listener too. The new types are `RightsScope` and `RightsScopes`.
|
|
25
|
+
- New exports: `withHintImages(event, images)`, `hintImagesOf(event)` and the types `HintImages` and `HintRowState`. A publisher of change events, for example a watcher of a change stream, gives the rows before and after the change. Without them, a subscriber with a filter gets a hint without ids.
|
|
26
|
+
|
|
27
|
+
Migration:
|
|
28
|
+
|
|
29
|
+
- A subscriber that read `withheld` to find the rows that the rule refused: these rows are not in the event. A row that the subscriber read before the change and that the rule refuses after it comes as a delete.
|
|
30
|
+
- A reader of `changes` with a rule of the rows: apply a full answer as a replacement of the copy. The sync of `@procedures/client-store` does this. A full answer comes after each delete, so give `admitsAll` to the principals with full rights.
|
|
31
|
+
- A host whose `allow` of `events.subscribe` refused a principal with a rule of the rows can admit it.
|
|
32
|
+
- A host with full rights for some principals: give `admission.admitsAll`. Without it, the publisher examines each row of each event for each subscriber. Also, each write reads its rows before the change while such a subscriber is open.
|
|
33
|
+
- Graph: give `admitsAll` for the principals that read a whole partition. Then admit the principals with a `when` condition in `allow`.
|
|
34
|
+
- The site, MiniMongo and jarvis: no change, if their collections have no `admission.admit`. Then their events do not change.
|
|
35
|
+
|
|
36
|
+
## 0.35.1
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 9f0405d: `watchStorageChanges()` publishes the change stream of a `MongoDocumentStorage` collection as collection hints, and `versionOfStored()` gives the version of a raw stored document (roadmap CLI-77).
|
|
41
|
+
|
|
42
|
+
PATCH: the change only adds exports and new optional options, and keeps each behavior of 0.35.0 (the watcher is not released yet). Before 1.0.0, a new feature raises the PATCH. The fixed group shares one version, so this rides the next release (0.35.0 when it is not out yet).
|
|
43
|
+
|
|
44
|
+
- `versionOfStored(doc, form?, partition?)` gives the version that `storage.versionOf(id)` gives for a stored document: `_seq` as text, `0` for a document without `_seq`, and `undefined` for a tombstone or a document without an id. It gives the value that `versionOf()` reads.
|
|
45
|
+
- `watchStorageChanges(storage, publish, options?)` watches the change stream of the collection. It publishes each change on the topic of the collection procedures, `collectionChangeTopic(name, partition)`, with the partition from `storage.form.partitionOf()`. The event is a `CollectionChangeEvent` without `since` (a hint), with the id in `changed` or `deleted` and the version of the item in `versions`. A tombstone and a delete are deletes. It returns `{ ready, stop() }`.
|
|
46
|
+
- With `ownWrites: "skip"` (the default), the watcher skips the events of the writes of this process through the storage, because the collection procedures publish them already. Each write of the storage notes its sequence numbers while a watcher is open. `ownWrites: "publish"` publishes each change.
|
|
47
|
+
- With `rawWrites: "adopt"` (the default), the watcher gives a raw write a new `_seq` through the write path of the storage, so `changes(since)` has it. It reads from the event alone whether a write is raw. It gives back the storage fields and the partition fields that a raw replace took, and never changes a field of the item. The write matches only the state that the event saw, so one of two racing watchers wins and the other does nothing. The event of that write publishes the hint with the new version; a raw write does not carry its old version. The adoptions of a watcher wait in one bounded queue, one at a time, in batches that take one block of numbers. The watcher keeps the ids of the raw writes that do not fit in a full queue or whose last try failed (up to 10,000), and adopts them again when the queue is empty, with the documents then. A failure that can go away tries again after the backoff. A failed last try, a second failure, or an id over that limit gives the partition a reset hint. The adoption is exact only with `changeStreamPreAndPostImages`. With the images before the change (`changeStreamPreAndPostImages`), a raw delete becomes a tombstone; without them, it is a hint without a version. A prune of tombstones publishes nothing. `rawWrites: "ignore"` writes nothing and publishes a hint without a version. A read-only user gets the same hint, with one log.
|
|
48
|
+
- With `sweep` (on by default with `rawWrites: "adopt"`), the watcher adopts each document without `_seq` after each gap, in pages of the index of `_id`. `sweepAtOpen: true` (off by default) also sweeps when the stream opens: the first watcher on a legacy collection adopts every legacy document, and the next delta of every subscriber is the whole collection. A document that the sweep cannot place goes to the log once, and the next sweeps leave it.
|
|
49
|
+
- `ready` rejects when the first open fails with an error that does not go away (a single server, a refused access, a wrong option). The watcher asks the server with `hello` first, so on a single server `ready` rejects at once. The watcher tries again after other errors.
|
|
50
|
+
- After an error of the stream, the watcher opens it again after a backoff (`backoff`, on the injected `clock`), from the resume token of the last event. When the server does not know the token any more, or the collection was dropped or renamed, it publishes a reset hint (no ids, `reset: true`) on the plain topic, on each partition of the counters, on each partition that it saw, and on each channel of the bus of the collection. The option `gapPartitions` adds more.
|
|
51
|
+
- `@procedures/client`: `CollectionChangeEvent` has the new optional field `versions`, `[{ id, version }]`: the version of each changed item, as `versionOf(id)` of the storage gives it. A publisher that knows the versions sets it. The new optional field `reset`: `true` tells the subscriber to read the collection in full, with `changes` and no `since`. PATCH: new optional fields of an output type, and before 1.0.0 a new feature raises the PATCH.
|
|
52
|
+
- `@procedures/store`: `EventsChangeFeed` reads `versions` and `reset` of an event, and `HybridStorage` does a full pull for a hint with `reset: true`. PATCH: a fix, so that a store does not miss the changes of a reset.
|
|
53
|
+
- `storageChangeOf(change, form?)` reads the change of an item from a change event, for an app that watches the collection itself.
|
|
54
|
+
- Fix: `ViewMaterializer` leaves `_seq` and `_tomb` of a source out of the content of a row, before the hash. A row is no write of a storage, so the watcher of the target does not read it as a raw write. The other fields of the source stay in the row.
|
|
55
|
+
- f5c2407: PATCH: a new optional option whose default keeps the old behavior. The error policy of a server (roadmap CLI-80).
|
|
56
|
+
|
|
57
|
+
- The new option `errors` of `Server` and `ProcedureServer` tells what an error tells the caller. A host gives it with `serverOptions`. `Server.handle()` applies it, so each face sends the same error: HTTP, WebSocket, MCP and a message port.
|
|
58
|
+
- `expose: "all"` is the default. Each error goes to the caller as before.
|
|
59
|
+
- `expose: "coded"` sends an error with a known code as it is. Each other error goes to the caller as `INTERNAL_ERROR` with the message `internal error` and its real retryable flag. It keeps only the metadata keys of the new option `keepMetadata`: by default the trace keys `traceparent` and `tracestate`. The server gives the real error to `onError`, or to `console.error` without `onError`.
|
|
60
|
+
- A known code is a code of `ERROR_CODES` or of `ERROR_REGISTRY`, for example `NOT_FOUND` or `CONFLICT`. The new function `isKnownErrorCode(code)` does this check. `ECONNREFUSED` and a numeric code of MongoDB are not known codes.
|
|
61
|
+
- The option `codes` adds the codes of the application that go out as they are, for example `QUOTA_EXCEEDED`.
|
|
62
|
+
- The codes `OUTPUT_VALIDATION_ERROR` and `NO_OUTPUT` tell of a failure of the server, so `"coded"` hides them, with `INTERNAL_ERROR`, `HANDLER_ERROR` and `UNKNOWN`.
|
|
63
|
+
- The server applies `map(error, { path, transport })` first, with the real error of its own class. Its result goes to the caller as it is, with its `retryAfterMs` and its conflicts. `undefined` gives the error to `expose`.
|
|
64
|
+
- The policy applies to an error before a stream and to the error that ends a stream. A nested call of `ctx.client` keeps the real error.
|
|
65
|
+
- The new optional field `transport` of `ServerRequest` names the face of a request. The HTTP, WebSocket, message port and MCP faces set it.
|
|
66
|
+
- The last-resort catch of each face applies the same policy when `handle()` throws. This is true for the HTTP, WebSocket, message port and MCP faces, and for the tracked call of a host (`@procedures/peer`). The new function `lastResortError(handler, error, request)` and the new optional method `RequestHandler.exposeError()` do this. The logger gets each hidden error one time.
|
|
67
|
+
- The new types are `ServerErrorPolicy`, `ExposedError` and `ErrorCall`. The new exports are `exposeError`, `lastResortError`, `HIDDEN_ERROR_MESSAGE` and `DEFAULT_KEPT_METADATA`.
|
|
68
|
+
- An MCP result for an unknown tool has `_meta` with the code `NOT_FOUND`.
|
|
69
|
+
|
|
3
70
|
## 0.35.0
|
|
4
71
|
|
|
5
72
|
No changes in this release.
|