@procedures/client 0.14.0 → 0.15.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 +69 -0
- package/README.md +12 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/http/client/transport.d.ts.map +1 -1
- package/dist/adapters/http/client/transport.js +4 -0
- package/dist/adapters/http/client/transport.js.map +1 -1
- package/dist/adapters/http/server/body.d.ts +17 -0
- package/dist/adapters/http/server/body.d.ts.map +1 -0
- package/dist/adapters/http/server/body.js +44 -0
- package/dist/adapters/http/server/body.js.map +1 -0
- package/dist/adapters/http/server/cors.d.ts +24 -1
- package/dist/adapters/http/server/cors.d.ts.map +1 -1
- package/dist/adapters/http/server/cors.js +33 -1
- package/dist/adapters/http/server/cors.js.map +1 -1
- package/dist/adapters/http/server/handler.d.ts +3 -1
- package/dist/adapters/http/server/handler.d.ts.map +1 -1
- package/dist/adapters/http/server/handler.js +7 -34
- package/dist/adapters/http/server/handler.js.map +1 -1
- package/dist/adapters/local/client/transport.d.ts.map +1 -1
- package/dist/adapters/local/client/transport.js +5 -0
- package/dist/adapters/local/client/transport.js.map +1 -1
- package/dist/browser.d.ts +4 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +6 -1
- package/dist/browser.js.map +1 -1
- package/dist/client/client.js +1 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/errors/registry.d.ts.map +1 -1
- package/dist/client/errors/registry.js +1 -0
- package/dist/client/errors/registry.js.map +1 -1
- package/dist/client/types.d.ts +6 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js +7 -1
- package/dist/client/types.js.map +1 -1
- package/dist/events/publisher.d.ts.map +1 -1
- package/dist/events/publisher.js +10 -5
- package/dist/events/publisher.js.map +1 -1
- package/dist/events/rows.d.ts +12 -4
- package/dist/events/rows.d.ts.map +1 -1
- package/dist/events/rows.js +13 -16
- package/dist/events/rows.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +10 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +11 -0
- package/dist/node.js.map +1 -1
- package/dist/procedures/collection/admission.d.ts +77 -0
- package/dist/procedures/collection/admission.d.ts.map +1 -0
- package/dist/procedures/collection/admission.js +204 -0
- package/dist/procedures/collection/admission.js.map +1 -0
- package/dist/procedures/collection/changes.d.ts +3 -1
- package/dist/procedures/collection/changes.d.ts.map +1 -1
- package/dist/procedures/collection/changes.js +10 -6
- package/dist/procedures/collection/changes.js.map +1 -1
- package/dist/procedures/collection/index.d.ts +5 -1
- package/dist/procedures/collection/index.d.ts.map +1 -1
- package/dist/procedures/collection/index.js +4 -0
- package/dist/procedures/collection/index.js.map +1 -1
- package/dist/procedures/collection/patch-in-parts.d.ts +15 -0
- package/dist/procedures/collection/patch-in-parts.d.ts.map +1 -0
- package/dist/procedures/collection/patch-in-parts.js +47 -0
- package/dist/procedures/collection/patch-in-parts.js.map +1 -0
- package/dist/procedures/collection/precondition.d.ts +111 -0
- package/dist/procedures/collection/precondition.d.ts.map +1 -0
- package/dist/procedures/collection/precondition.js +153 -0
- package/dist/procedures/collection/precondition.js.map +1 -0
- package/dist/procedures/collection/procedures.d.ts +8 -0
- package/dist/procedures/collection/procedures.d.ts.map +1 -1
- package/dist/procedures/collection/procedures.js +66 -76
- package/dist/procedures/collection/procedures.js.map +1 -1
- package/dist/procedures/collection/query.d.ts +2 -0
- package/dist/procedures/collection/query.d.ts.map +1 -1
- package/dist/procedures/collection/query.js +3 -0
- package/dist/procedures/collection/query.js.map +1 -1
- package/dist/procedures/collection/schemas.d.ts +16 -0
- package/dist/procedures/collection/schemas.d.ts.map +1 -1
- package/dist/procedures/collection/schemas.js +26 -5
- package/dist/procedures/collection/schemas.js.map +1 -1
- package/dist/procedures/collection/storage.d.ts +34 -6
- package/dist/procedures/collection/storage.d.ts.map +1 -1
- package/dist/procedures/collection/storage.js +3 -0
- package/dist/procedures/collection/storage.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/procedures/invoke.d.ts +5 -2
- package/dist/procedures/invoke.d.ts.map +1 -1
- package/dist/procedures/invoke.js +5 -1
- package/dist/procedures/invoke.js.map +1 -1
- package/dist/procedures/types.d.ts +7 -0
- package/dist/procedures/types.d.ts.map +1 -1
- package/dist/procedures/types.js.map +1 -1
- package/dist/protocol.d.ts +1 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -0
- package/dist/protocol.js.map +1 -1
- package/dist/server/index.d.ts +70 -5
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +26 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +5 -0
- package/dist/server/procedure-server.js.map +1 -1
- package/package.json +12 -1
- package/src/adapters/http/client/transport.ts +3 -0
- package/src/adapters/http/server/body.ts +43 -0
- package/src/adapters/http/server/cors.ts +42 -1
- package/src/adapters/http/server/handler.ts +10 -32
- package/src/adapters/local/client/transport.ts +4 -0
- package/src/browser.ts +25 -1
- package/src/client/client.ts +1 -1
- package/src/client/errors/registry.ts +1 -0
- package/src/client/types.ts +8 -0
- package/src/events/publisher.ts +8 -5
- package/src/events/rows.ts +19 -6
- package/src/index.ts +9 -6
- package/src/node.ts +13 -1
- package/src/procedures/collection/admission.ts +243 -0
- package/src/procedures/collection/changes.ts +11 -5
- package/src/procedures/collection/index.ts +21 -0
- package/src/procedures/collection/patch-in-parts.ts +56 -0
- package/src/procedures/collection/precondition.ts +180 -0
- package/src/procedures/collection/procedures.ts +69 -78
- package/src/procedures/collection/query.ts +16 -0
- package/src/procedures/collection/schemas.ts +43 -6
- package/src/procedures/collection/storage.ts +36 -6
- package/src/procedures/index.ts +22 -0
- package/src/procedures/invoke.ts +7 -2
- package/src/procedures/types.ts +8 -0
- package/src/protocol.ts +3 -1
- package/src/server/index.ts +94 -17
- package/src/server/procedure-server.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* and transport adapters.
|
|
6
6
|
*
|
|
7
7
|
* This entry point is for Node. It exports the browser-safe entry point
|
|
8
|
-
* ("@procedures/client/browser")
|
|
8
|
+
* ("@procedures/client/browser"). It also exports the server transports, which use `http` and
|
|
9
|
+
* `ws`, but these exports are deprecated (CLI-6 step 1). Their entry is "@procedures/client/node".
|
|
10
|
+
* The next MINOR removes them from this entry, so the root imports no `http` and no `ws`.
|
|
9
11
|
*
|
|
10
12
|
* The `WebSocketTransport` of this entry uses the global `WebSocket`, because some applications
|
|
11
13
|
* bundle this entry for a browser. The Node entry "@procedures/client/node" has a
|
|
@@ -15,7 +17,11 @@ export * from "./browser.js";
|
|
|
15
17
|
// ============================================================================
|
|
16
18
|
// Server Transports (Node only)
|
|
17
19
|
// ============================================================================
|
|
18
|
-
export {
|
|
20
|
+
export { defaultServerUrlStrategy, rpcServerUrlStrategy } from "./adapters/http/server/strategies.js";
|
|
21
|
+
// Deprecated (CLI-6 step 1): import these from "@procedures/client/node". The next MINOR removes
|
|
22
|
+
// them from the root. ./server/index.ts holds the deprecated aliases, so an editor marks each old
|
|
23
|
+
// import, and each alias is the same class or type as the export of ./node.
|
|
24
|
+
export { HttpServerTransport } from "./server/index.js";
|
|
19
25
|
export { WebSocketServerTransport } from "./server/index.js";
|
|
20
26
|
export { checkBrowserRequest, hasAmbientCredentials, isLoopbackHost, isLoopbackAddress, hostNameOf } from "./server/browser-guard.js";
|
|
21
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAE7B,+EAA+E;AAC/E,gCAAgC;AAChC,+EAA+E;AAC/E,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACtG,iGAAiG;AACjG,kGAAkG;AAClG,4EAA4E;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/node.d.ts
CHANGED
|
@@ -18,18 +18,27 @@
|
|
|
18
18
|
* The option `addressing` of `procedureHandler` gives the method and the payload of a request
|
|
19
19
|
* (CLI-31). `urlAddressing()` is the default, and `bodyPathAddressing()` reads the path from the
|
|
20
20
|
* body of a single endpoint.
|
|
21
|
+
*
|
|
22
|
+
* The server transports are in this entry too (CLI-6): `HttpServerTransport`, the Express shim
|
|
23
|
+
* over `procedureHandler`, and `WebSocketServerTransport`. The root and `./server` also export
|
|
24
|
+
* them, but these exports are deprecated. The next MINOR removes them, so the root imports no
|
|
25
|
+
* `http` and no `ws`.
|
|
21
26
|
*/
|
|
22
27
|
export { WebSocketTransport } from "./adapters/websocket/client/node.js";
|
|
23
28
|
export type { WebSocketTransportOptions, WebSocketClass } from "./adapters/websocket/client/types.js";
|
|
24
29
|
export { writeNdjsonStream } from "./adapters/http/server/ndjson.js";
|
|
25
30
|
export type { WriteNdjsonStreamOptions, NdjsonError } from "./adapters/http/server/ndjson.js";
|
|
26
31
|
export { procedureHandler } from "./adapters/http/server/handler.js";
|
|
32
|
+
export { readJsonBody, BodyError } from "./adapters/http/server/body.js";
|
|
27
33
|
export type { ProcedureHandlerOptions, NodeProcedureHandler, NodeUrlStrategy, UrlRequest } from "./adapters/http/server/handler.js";
|
|
28
|
-
export type { CorsOptions } from "./adapters/http/server/cors.js";
|
|
34
|
+
export type { CorsOptions, CredentialedCorsOptions } from "./adapters/http/server/cors.js";
|
|
35
|
+
export { credentialedCors } from "./adapters/http/server/cors.js";
|
|
29
36
|
export type { RoutedRequest } from "./adapters/http/server/strategies.js";
|
|
30
37
|
export { defaultServerUrlStrategy, rpcServerUrlStrategy } from "./adapters/http/server/strategies.js";
|
|
31
38
|
export { urlAddressing, bodyPathAddressing } from "./adapters/http/server/addressing.js";
|
|
32
39
|
export type { Addressing, CallAddress, UrlAddressingOptions, BodyPathAddressingOptions } from "./adapters/http/server/addressing.js";
|
|
40
|
+
export { HttpServerTransport } from "./adapters/http/server/transport.js";
|
|
41
|
+
export type { HttpServerTransportOptions, HttpUrlStrategy } from "./adapters/http/server/types.js";
|
|
33
42
|
export { upgradeHandler } from "./adapters/websocket/server/upgrade.js";
|
|
34
43
|
export type { UpgradeHandlerOptions, NodeUpgradeHandler } from "./adapters/websocket/server/upgrade.js";
|
|
35
44
|
export { WebSocketServerTransport } from "./adapters/websocket/server/transport.js";
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,YAAY,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,YAAY,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpI,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAEtG,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AACzF,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAErI,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,YAAY,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,YAAY,EACV,+BAA+B,EAC/B,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sCAAsC,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -18,13 +18,24 @@
|
|
|
18
18
|
* The option `addressing` of `procedureHandler` gives the method and the payload of a request
|
|
19
19
|
* (CLI-31). `urlAddressing()` is the default, and `bodyPathAddressing()` reads the path from the
|
|
20
20
|
* body of a single endpoint.
|
|
21
|
+
*
|
|
22
|
+
* The server transports are in this entry too (CLI-6): `HttpServerTransport`, the Express shim
|
|
23
|
+
* over `procedureHandler`, and `WebSocketServerTransport`. The root and `./server` also export
|
|
24
|
+
* them, but these exports are deprecated. The next MINOR removes them, so the root imports no
|
|
25
|
+
* `http` and no `ws`.
|
|
21
26
|
*/
|
|
22
27
|
export { WebSocketTransport } from "./adapters/websocket/client/node.js";
|
|
23
28
|
export { writeNdjsonStream } from "./adapters/http/server/ndjson.js";
|
|
24
29
|
export { procedureHandler } from "./adapters/http/server/handler.js";
|
|
30
|
+
// The JSON body of a request, read to a limit: the procedure handler and the MCP face read it so (CLI-35)
|
|
31
|
+
export { readJsonBody, BodyError } from "./adapters/http/server/body.js";
|
|
32
|
+
// The credentialed CORS of the trusted origins of a host, for a route of the app (CLI-49)
|
|
33
|
+
export { credentialedCors } from "./adapters/http/server/cors.js";
|
|
25
34
|
export { defaultServerUrlStrategy, rpcServerUrlStrategy } from "./adapters/http/server/strategies.js";
|
|
26
35
|
// The addressing of a request: the URL (the default), or the path in the body of a single endpoint (CLI-31)
|
|
27
36
|
export { urlAddressing, bodyPathAddressing } from "./adapters/http/server/addressing.js";
|
|
37
|
+
// The server transports (CLI-6): the root and ./server export them only until the next MINOR
|
|
38
|
+
export { HttpServerTransport } from "./adapters/http/server/transport.js";
|
|
28
39
|
export { upgradeHandler } from "./adapters/websocket/server/upgrade.js";
|
|
29
40
|
export { WebSocketServerTransport } from "./adapters/websocket/server/transport.js";
|
|
30
41
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,0GAA0G;AAC1G,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAGzE,0FAA0F;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACtG,4GAA4G;AAC5G,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAEzF,6FAA6F;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of the rows of a served collection (roadmap CLI-41). A right can depend on the
|
|
3
|
+
* document: a `when` condition of Graph, or `accessAdmitItem()` of `@procedures/access`. The option
|
|
4
|
+
* `admission` of `createCollectionProcedures()` gives the rules as data:
|
|
5
|
+
*
|
|
6
|
+
* - `admit` examines each row `{ id, value }` that a read gives. It has the shape of `AdmitItem`,
|
|
7
|
+
* the output filter of a host. The change events with values give it the same rows for each
|
|
8
|
+
* subscriber, so the reads and the events obey one rule.
|
|
9
|
+
* - `guard` examines each write `{ op, id, doc, prev }` before the storage changes. A refused write
|
|
10
|
+
* gets `FORBIDDEN` with the reason `write-not-allowed`.
|
|
11
|
+
*
|
|
12
|
+
* The procedures apply the rules in one place: the view of the storage of a call
|
|
13
|
+
* (`admittedStorage()`). Each read and each write of each procedure goes through this view.
|
|
14
|
+
*
|
|
15
|
+
* - A refused row is absent: `get` gives undefined, `has` gives false, and the lists, `size`,
|
|
16
|
+
* `find` and `changes` do not have it. A delta of `changes` puts the id of a refused row in
|
|
17
|
+
* `deleted`, so a copy of the caller drops it.
|
|
18
|
+
* - An error of `admit` fails the read. It does not hide the rows, so a sync does not delete them.
|
|
19
|
+
* - The guard reads the stored item before the write. CLI-16 (`expectedVersion`) closes the gap of
|
|
20
|
+
* a write of another writer between that read and the write.
|
|
21
|
+
* - The rules get the invocation of the call (`ctx.invocation`). A call without an invocation gets
|
|
22
|
+
* no row and makes no write.
|
|
23
|
+
*/
|
|
24
|
+
import { type AdmitItem, type Invocation } from "../invoke.js";
|
|
25
|
+
import type { ProcedureContext } from "../types.js";
|
|
26
|
+
import type { CollectionStorage } from "./storage.js";
|
|
27
|
+
/** A row of a collection: the id and the stored item. The rule `admit` examines one row at a time. */
|
|
28
|
+
export interface CollectionRow {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly value: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** A write of a collection, as the guard examines it. */
|
|
33
|
+
export interface CollectionWrite {
|
|
34
|
+
/**
|
|
35
|
+
* The operation. `setBatch` gives one `set` for each item. `deleteBatch` and `clear` give one
|
|
36
|
+
* `delete` for each id.
|
|
37
|
+
*/
|
|
38
|
+
readonly op: "set" | "patch" | "delete";
|
|
39
|
+
/** The id of the item. */
|
|
40
|
+
readonly id: string;
|
|
41
|
+
/** The item after the write: the value of a `set`, or the merged item of a `patch`. Undefined for a `delete`. */
|
|
42
|
+
readonly doc: unknown;
|
|
43
|
+
/** The stored item before the write. Undefined when the id has no item. */
|
|
44
|
+
readonly prev: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The guard of the writes of a collection. It gets each write and the invocation of the call. It
|
|
48
|
+
* gives true to permit the write. An error that it throws passes through, and the storage does
|
|
49
|
+
* not change.
|
|
50
|
+
*/
|
|
51
|
+
export type CollectionWriteGuard = (write: CollectionWrite, invocation: Invocation) => boolean | Promise<boolean>;
|
|
52
|
+
/** The rules of the rows of a served collection (roadmap CLI-41). Each rule is optional. */
|
|
53
|
+
export interface CollectionAdmission {
|
|
54
|
+
/**
|
|
55
|
+
* The rule of the rows. It gets each row `{ id, value }` of a read and the invocation of the
|
|
56
|
+
* call, and it gives true to admit the row. The change events with values apply it for each
|
|
57
|
+
* subscriber, with the invocation of the subscription.
|
|
58
|
+
*/
|
|
59
|
+
admit?: AdmitItem | undefined;
|
|
60
|
+
/** The guard of each `set`, `patch` and `delete`, also of the batches and of `clear`. */
|
|
61
|
+
guard?: CollectionWriteGuard | undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* This function tells if the rule of the rows admits a row for a call. Without a rule, it gives
|
|
65
|
+
* true. A call without an invocation gets no row.
|
|
66
|
+
*/
|
|
67
|
+
export declare function admitsRow(admission: CollectionAdmission | undefined, ctx: ProcedureContext, id: string, value: unknown): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* This function gives the view of the storage of a call: the storage, with the rules of the
|
|
70
|
+
* collection for each read and each write. Without rules, it gives the storage itself.
|
|
71
|
+
*
|
|
72
|
+
* @param storage - The storage of the call: of the collection, or of its partition
|
|
73
|
+
* @param admission - The rules of the collection
|
|
74
|
+
* @param ctx - The context of the call. The rules get its invocation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function admittedStorage<T>(storage: CollectionStorage<T>, admission: CollectionAdmission | undefined, ctx: ProcedureContext): CollectionStorage<T>;
|
|
77
|
+
//# sourceMappingURL=admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAmB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAuC,MAAM,cAAc,CAAC;AAG3F,sGAAsG;AACtG,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACxC,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iHAAiH;IACjH,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAElH,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,yFAAyF;IACzF,KAAK,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC1C;AAUD;;;GAGG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,mBAAmB,GAAG,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/I;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,mBAAmB,GAAG,SAAS,EAAE,GAAG,EAAE,gBAAgB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAmHzJ"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of the rows of a served collection (roadmap CLI-41). A right can depend on the
|
|
3
|
+
* document: a `when` condition of Graph, or `accessAdmitItem()` of `@procedures/access`. The option
|
|
4
|
+
* `admission` of `createCollectionProcedures()` gives the rules as data:
|
|
5
|
+
*
|
|
6
|
+
* - `admit` examines each row `{ id, value }` that a read gives. It has the shape of `AdmitItem`,
|
|
7
|
+
* the output filter of a host. The change events with values give it the same rows for each
|
|
8
|
+
* subscriber, so the reads and the events obey one rule.
|
|
9
|
+
* - `guard` examines each write `{ op, id, doc, prev }` before the storage changes. A refused write
|
|
10
|
+
* gets `FORBIDDEN` with the reason `write-not-allowed`.
|
|
11
|
+
*
|
|
12
|
+
* The procedures apply the rules in one place: the view of the storage of a call
|
|
13
|
+
* (`admittedStorage()`). Each read and each write of each procedure goes through this view.
|
|
14
|
+
*
|
|
15
|
+
* - A refused row is absent: `get` gives undefined, `has` gives false, and the lists, `size`,
|
|
16
|
+
* `find` and `changes` do not have it. A delta of `changes` puts the id of a refused row in
|
|
17
|
+
* `deleted`, so a copy of the caller drops it.
|
|
18
|
+
* - An error of `admit` fails the read. It does not hide the rows, so a sync does not delete them.
|
|
19
|
+
* - The guard reads the stored item before the write. CLI-16 (`expectedVersion`) closes the gap of
|
|
20
|
+
* a write of another writer between that read and the write.
|
|
21
|
+
* - The rules get the invocation of the call (`ctx.invocation`). A call without an invocation gets
|
|
22
|
+
* no row and makes no write.
|
|
23
|
+
*/
|
|
24
|
+
import { InvocationError } from "../invoke.js";
|
|
25
|
+
import { applyPatch } from "./query.js";
|
|
26
|
+
import { patchInParts } from "./patch-in-parts.js";
|
|
27
|
+
/** The size of a page of a query of the storage, when the policy gives no `maxLimit`. */
|
|
28
|
+
const QUERY_PAGE = 1000;
|
|
29
|
+
/** The refusal of a write. */
|
|
30
|
+
function writeRefused(ctx, write) {
|
|
31
|
+
return new InvocationError("FORBIDDEN", `The rule of the collection does not permit the ${write.op} of "${write.id}"`, ctx.path, "write-not-allowed");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This function tells if the rule of the rows admits a row for a call. Without a rule, it gives
|
|
35
|
+
* true. A call without an invocation gets no row.
|
|
36
|
+
*/
|
|
37
|
+
export async function admitsRow(admission, ctx, id, value) {
|
|
38
|
+
const admit = admission?.admit;
|
|
39
|
+
if (!admit)
|
|
40
|
+
return true;
|
|
41
|
+
const invocation = ctx.invocation;
|
|
42
|
+
return invocation !== undefined && (await admit({ id, value }, invocation)) === true;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* This function gives the view of the storage of a call: the storage, with the rules of the
|
|
46
|
+
* collection for each read and each write. Without rules, it gives the storage itself.
|
|
47
|
+
*
|
|
48
|
+
* @param storage - The storage of the call: of the collection, or of its partition
|
|
49
|
+
* @param admission - The rules of the collection
|
|
50
|
+
* @param ctx - The context of the call. The rules get its invocation.
|
|
51
|
+
*/
|
|
52
|
+
export function admittedStorage(storage, admission, ctx) {
|
|
53
|
+
const admit = admission?.admit;
|
|
54
|
+
const guard = admission?.guard;
|
|
55
|
+
if (!admit && !guard)
|
|
56
|
+
return storage;
|
|
57
|
+
const invocation = ctx.invocation;
|
|
58
|
+
const admits = (id, value) => admitsRow(admission, ctx, id, value);
|
|
59
|
+
/** The entries that the rule admits, in their order. */
|
|
60
|
+
const admitted = async (entries) => {
|
|
61
|
+
if (!admit)
|
|
62
|
+
return entries;
|
|
63
|
+
const keep = await Promise.all(entries.map(([id, value]) => admits(id, value)));
|
|
64
|
+
return entries.filter((_, index) => keep[index]);
|
|
65
|
+
};
|
|
66
|
+
/** The entries of the storage that the rule admits. The rule needs the ids, so the storage must give them. */
|
|
67
|
+
const entries = async () => {
|
|
68
|
+
if (!storage.getEntries)
|
|
69
|
+
throw new Error("The storage cannot give the ids of its items, so the rule of the rows cannot examine them");
|
|
70
|
+
return admitted(await storage.getEntries());
|
|
71
|
+
};
|
|
72
|
+
/** This function throws `FORBIDDEN` unless the guard permits each write. */
|
|
73
|
+
const permit = async (writes) => {
|
|
74
|
+
if (!guard)
|
|
75
|
+
return;
|
|
76
|
+
for (const write of writes) {
|
|
77
|
+
if (invocation === undefined || (await guard(write, invocation)) !== true)
|
|
78
|
+
throw writeRefused(ctx, write);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const view = {
|
|
82
|
+
async get(id) {
|
|
83
|
+
const value = await storage.get(id);
|
|
84
|
+
return value === undefined || (await admits(id, value)) ? value : undefined;
|
|
85
|
+
},
|
|
86
|
+
async getAll() {
|
|
87
|
+
return admit ? (await entries()).map(([, value]) => value) : storage.getAll();
|
|
88
|
+
},
|
|
89
|
+
async find(predicate) {
|
|
90
|
+
return admit ? (await entries()).map(([, value]) => value).filter(predicate) : storage.find(predicate);
|
|
91
|
+
},
|
|
92
|
+
async has(id) {
|
|
93
|
+
return admit ? (await view.get(id)) !== undefined : storage.has(id);
|
|
94
|
+
},
|
|
95
|
+
async size() {
|
|
96
|
+
return admit ? (await entries()).length : storage.size();
|
|
97
|
+
},
|
|
98
|
+
async getBatch(ids) {
|
|
99
|
+
const found = await storage.getBatch(ids);
|
|
100
|
+
if (!admit)
|
|
101
|
+
return found;
|
|
102
|
+
const kept = await admitted([...found.entries()]);
|
|
103
|
+
return new Map(kept);
|
|
104
|
+
},
|
|
105
|
+
async set(id, value, options) {
|
|
106
|
+
if (guard)
|
|
107
|
+
await permit([{ op: "set", id, doc: value, prev: await storage.get(id) }]);
|
|
108
|
+
return storage.set(id, value, options);
|
|
109
|
+
},
|
|
110
|
+
async delete(id, options) {
|
|
111
|
+
if (guard)
|
|
112
|
+
await permit([{ op: "delete", id, doc: undefined, prev: await storage.get(id) }]);
|
|
113
|
+
return storage.delete(id, options);
|
|
114
|
+
},
|
|
115
|
+
async clear(options) {
|
|
116
|
+
if (!guard)
|
|
117
|
+
return storage.clear(options);
|
|
118
|
+
// Each item is a delete that the guard examines. The storage deletes only the items that it examined.
|
|
119
|
+
if (!storage.getEntries)
|
|
120
|
+
throw new Error("The storage cannot give the ids of its items, so the guard cannot examine a clear");
|
|
121
|
+
const all = await storage.getEntries();
|
|
122
|
+
await permit(all.map(([id, prev]) => ({ op: "delete", id, doc: undefined, prev })));
|
|
123
|
+
if (all.length > 0)
|
|
124
|
+
await storage.deleteBatch(all.map(([id]) => id), options);
|
|
125
|
+
},
|
|
126
|
+
async setBatch(items, options) {
|
|
127
|
+
if (guard) {
|
|
128
|
+
const before = await storage.getBatch(items.map(([id]) => id));
|
|
129
|
+
await permit(items.map(([id, value]) => ({ op: "set", id, doc: value, prev: before.get(id) })));
|
|
130
|
+
}
|
|
131
|
+
return storage.setBatch(items, options);
|
|
132
|
+
},
|
|
133
|
+
async deleteBatch(ids, options) {
|
|
134
|
+
if (guard) {
|
|
135
|
+
const before = await storage.getBatch(ids);
|
|
136
|
+
await permit(ids.map((id) => ({ op: "delete", id, doc: undefined, prev: before.get(id) })));
|
|
137
|
+
}
|
|
138
|
+
return storage.deleteBatch(ids, options);
|
|
139
|
+
},
|
|
140
|
+
async patch(id, fields, options) {
|
|
141
|
+
const check = async (prev, doc) => permit([{ op: "patch", id, doc, prev }]);
|
|
142
|
+
if (!storage.patch)
|
|
143
|
+
return patchInParts(storage, id, fields, options, guard ? check : undefined);
|
|
144
|
+
if (guard) {
|
|
145
|
+
const prev = await storage.get(id);
|
|
146
|
+
// A patch of a missing id changes nothing
|
|
147
|
+
if (prev === undefined)
|
|
148
|
+
return undefined;
|
|
149
|
+
await check(prev, applyPatch(prev, fields));
|
|
150
|
+
}
|
|
151
|
+
return storage.patch(id, fields, options);
|
|
152
|
+
},
|
|
153
|
+
close: () => storage.close(),
|
|
154
|
+
};
|
|
155
|
+
if (storage.getEntries)
|
|
156
|
+
view.getEntries = async () => (admit ? entries() : storage.getEntries());
|
|
157
|
+
if (admit ? storage.getEntries : storage.getIds) {
|
|
158
|
+
view.getIds = async () => (admit ? (await entries()).map(([id]) => id) : storage.getIds());
|
|
159
|
+
}
|
|
160
|
+
if (storage.getChangesSince) {
|
|
161
|
+
view.getChangesSince = async (since) => {
|
|
162
|
+
const changes = await storage.getChangesSince(since);
|
|
163
|
+
if (!admit)
|
|
164
|
+
return changes;
|
|
165
|
+
const changed = await admitted(changes.changed);
|
|
166
|
+
if (changes.full)
|
|
167
|
+
return { ...changes, changed };
|
|
168
|
+
// A delta: the copy of the caller drops each refused row
|
|
169
|
+
const kept = new Set(changed.map(([id]) => id));
|
|
170
|
+
const refused = changes.changed.filter(([id]) => !kept.has(id)).map(([id]) => id);
|
|
171
|
+
return { ...changes, changed, deleted: [...changes.deleted, ...refused] };
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (storage.query) {
|
|
175
|
+
view.query = async (selector, options, policy) => admit ? admittedQuery(storage, admitted, selector, options ?? {}, policy) : storage.query(selector, options, policy);
|
|
176
|
+
}
|
|
177
|
+
return view;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The query of a storage with the rule of the rows. The storage runs the selector and the order,
|
|
181
|
+
* page by page. The skip and the limit count the admitted rows only, so a page of the caller is full.
|
|
182
|
+
*/
|
|
183
|
+
async function admittedQuery(storage, admitted, selector, options, policy) {
|
|
184
|
+
const page = policy?.maxLimit !== undefined && Number.isFinite(policy.maxLimit) ? policy.maxLimit : QUERY_PAGE;
|
|
185
|
+
const skip = options.skip ?? 0;
|
|
186
|
+
const limit = options.limit;
|
|
187
|
+
const out = [];
|
|
188
|
+
let skipped = 0;
|
|
189
|
+
for (let offset = 0;; offset += page) {
|
|
190
|
+
const rows = await storage.query(selector, { ...(options.sort !== undefined && { sort: options.sort }), skip: offset, limit: page }, policy);
|
|
191
|
+
for (const entry of await admitted(rows)) {
|
|
192
|
+
if (skipped < skip) {
|
|
193
|
+
skipped++;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
out.push(entry);
|
|
197
|
+
if (limit !== undefined && out.length >= limit)
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
if (rows.length < page)
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission.js","sourceRoot":"","sources":["../../../src/procedures/collection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AAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChB,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,IAAI,KAAK;gBAAE,OAAO,GAAG,CAAC;QAC7D,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI;YAAE,OAAO,GAAG,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* write resolves after its event is on the bus. A failed publish never fails the write.
|
|
25
25
|
*/
|
|
26
26
|
import type { EventBus } from "../../events/types.js";
|
|
27
|
+
import type { AdmitItem } from "../invoke.js";
|
|
27
28
|
import type { StorageChanges } from "./storage.js";
|
|
28
29
|
/**
|
|
29
30
|
* The change event of the writes of a collection, on the topic `collections.<name>` (roadmap
|
|
@@ -82,8 +83,9 @@ interface ChangeLog {
|
|
|
82
83
|
* @param origin - The origin of the write
|
|
83
84
|
* @param write - The write
|
|
84
85
|
* @param values - True: the events carry the values, for the output filter of each subscriber
|
|
86
|
+
* @param admit - The rule of the rows of the collection: each subscriber applies it to the values (roadmap CLI-41)
|
|
85
87
|
*/
|
|
86
|
-
export declare function writeWithChangeEvent<R>(bus: EventBus | undefined, storage: object & ChangeLog, topic: string | undefined, ids: readonly string[] | "*", origin: string | undefined, write: () => Promise<R>, values?: boolean): Promise<R>;
|
|
88
|
+
export declare function writeWithChangeEvent<R>(bus: EventBus | undefined, storage: object & ChangeLog, topic: string | undefined, ids: readonly string[] | "*", origin: string | undefined, write: () => Promise<R>, values?: boolean, admit?: AdmitItem): Promise<R>;
|
|
87
89
|
/**
|
|
88
90
|
* This function starts the chain of the events of a storage at the version of a call of
|
|
89
91
|
* `changes`, when the chain has no version. The subscriber that made the call then applies the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,O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;;;;;GAcG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,GAAG,EAAE,QAAQ,GAAG,SAAS,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACvB,MAAM,UAAQ,EACd,KAAK,CAAC,EAAE,SAAS,GAChB,OAAO,CAAC,CAAC,CAAC,CAYZ;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI7H"}
|
|
@@ -80,11 +80,14 @@ function hint(version, origin) {
|
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* The event of a delta with the values of the changed items. Each row `{ id, value }` passes the
|
|
83
|
-
* output filter of each subscriber
|
|
83
|
+
* output filter of each subscriber and the rule of the rows of the collection, and a refused row
|
|
84
|
+
* goes from `values` to `withheld`.
|
|
84
85
|
*/
|
|
85
|
-
function withValues(event, entries) {
|
|
86
|
+
function withValues(event, entries, admit) {
|
|
86
87
|
return withRows({ ...event, values: entries }, {
|
|
87
88
|
rows: entries,
|
|
89
|
+
// The rule of the rows of the collection (roadmap CLI-41): each subscriber applies it too
|
|
90
|
+
...(admit && { admit }),
|
|
88
91
|
keep: (admitted) => {
|
|
89
92
|
const withheld = entries.filter((_, index) => !admitted[index]).map(({ id }) => id);
|
|
90
93
|
return {
|
|
@@ -96,7 +99,7 @@ function withValues(event, entries) {
|
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
101
|
/** One publish: the event of the writes that ended since the last publish. */
|
|
99
|
-
async function publish(chain, storage, bus, topic, values) {
|
|
102
|
+
async function publish(chain, storage, bus, topic, values, admit) {
|
|
100
103
|
const writes = chain.ended.splice(0);
|
|
101
104
|
// An earlier publish told these writes
|
|
102
105
|
if (writes.length === 0)
|
|
@@ -136,7 +139,7 @@ async function publish(chain, storage, bus, topic, values) {
|
|
|
136
139
|
deleted: changes.deleted,
|
|
137
140
|
...(origin !== undefined && { origin }),
|
|
138
141
|
};
|
|
139
|
-
bus.emit(topic, values ? withValues(event, changes.changed.map(([id, value]) => ({ id, value }))) : event);
|
|
142
|
+
bus.emit(topic, values ? withValues(event, changes.changed.map(([id, value]) => ({ id, value })), admit) : event);
|
|
140
143
|
}
|
|
141
144
|
/**
|
|
142
145
|
* This function runs a write of a collection procedure, and then publishes the change event of
|
|
@@ -151,8 +154,9 @@ async function publish(chain, storage, bus, topic, values) {
|
|
|
151
154
|
* @param origin - The origin of the write
|
|
152
155
|
* @param write - The write
|
|
153
156
|
* @param values - True: the events carry the values, for the output filter of each subscriber
|
|
157
|
+
* @param admit - The rule of the rows of the collection: each subscriber applies it to the values (roadmap CLI-41)
|
|
154
158
|
*/
|
|
155
|
-
export async function writeWithChangeEvent(bus, storage, topic, ids, origin, write, values = false) {
|
|
159
|
+
export async function writeWithChangeEvent(bus, storage, topic, ids, origin, write, values = false, admit) {
|
|
156
160
|
if (bus === undefined || topic === undefined)
|
|
157
161
|
return write();
|
|
158
162
|
const chain = chainOf(storage, topic);
|
|
@@ -162,7 +166,7 @@ export async function writeWithChangeEvent(bus, storage, topic, ids, origin, wri
|
|
|
162
166
|
}
|
|
163
167
|
finally {
|
|
164
168
|
chain.ended.push(started);
|
|
165
|
-
const run = chain.tail.then(() => publish(chain, storage, bus, topic, values));
|
|
169
|
+
const run = chain.tail.then(() => publish(chain, storage, bus, topic, values, admit));
|
|
166
170
|
chain.tail = run.catch(() => undefined);
|
|
167
171
|
await chain.tail;
|
|
168
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../../../src/procedures/collection/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../../../src/procedures/collection/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA+BhD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,SAAkB;IAC1E,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,UAAU,EAAE,CAAC,CAAC,CAAC,eAAe,UAAU,IAAI,SAAS,EAAE,CAAC;AAC1G,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,KAAK,GAAG,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC;AA0BD,+FAA+F;AAC/F,MAAM,MAAM,GAAG,IAAI,OAAO,EAAoC,CAAC;AAE/D,SAAS,OAAO,CAAC,OAAe,EAAE,KAAa;IAC7C,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IA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E,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QACtF,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,KAAK,CAAC,IAAI,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAyB,EAAE,OAAe,EAAE,KAAyB,EAAE,OAAe;IACrH,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACtC,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC;AACzD,CAAC"}
|
|
@@ -11,7 +11,11 @@ export { collectionChangeTopic, collectionTopicReads } from "./changes.js";
|
|
|
11
11
|
export type { CollectionChangeEvent } from "./changes.js";
|
|
12
12
|
export { PARTITION_PATTERN, collectionTopicPartition, collectionTopicTarget, partitionOfCall, storageOfCall, withPartition } from "./partition.js";
|
|
13
13
|
export type { CollectionPartitions, PartitionInput, PartitionResolver } from "./partition.js";
|
|
14
|
-
export
|
|
14
|
+
export { admittedStorage, admitsRow } from "./admission.js";
|
|
15
|
+
export type { CollectionAdmission, CollectionRow, CollectionWrite, CollectionWriteGuard } from "./admission.js";
|
|
16
|
+
export type { CollectionStorage, StorageChanges, StorageMetadata, StorageWriteOptions, StorageItemWriteOptions, StorageBatchWriteOptions, StorageSetChange, StorageDeleteChange, StorageClearChange, StorageChangeEvent, StorageChangeBatch, StorageObserver, } from "./storage.js";
|
|
17
|
+
export { MAX_EXPECTED_VERSION_LENGTH, PRECONDITION_NOT_SUPPORTED, VERSION_CONFLICTS_METADATA_KEY, VersionConflictError, asVersionConflictError, isExpectedVersion, preconditionNotSupported, versionConflict, versionConflicts, versionConflictsOf, } from "./precondition.js";
|
|
18
|
+
export type { CurrentItem, VersionConflict, VersionOf } from "./precondition.js";
|
|
15
19
|
export { DEFAULT_FIND_LIMIT, DEFAULT_QUERY_OPERATORS, DEFAULT_QUERY_POLICY, QUERY_OPERATORS, applyPatch, compareStorageValues, compileSelector, isPatchOperations, matchesSelector, mergePatch, patchProblems, queryEntries, queryOptionsProblems, selectorProblems, } from "./query.js";
|
|
16
20
|
export type { StorageFieldOperators, StoragePatch, StoragePatchOperations, StorageQueryOperator, StorageQueryOptions, StorageQueryPolicy, StorageSelector, StorageSort, StorageSortDirection, } from "./query.js";
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,eAAe,EACf,SAAS,EACT,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,YAAY,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAGlG,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnJ,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG9F,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,GAChB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB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E,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAIjF,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
|
@@ -11,6 +11,10 @@ export { createCollectionProcedures } from "./procedures.js";
|
|
|
11
11
|
export { collectionChangeTopic, collectionTopicReads } from "./changes.js";
|
|
12
12
|
// The partitions of a collection (roadmap CLI-17)
|
|
13
13
|
export { PARTITION_PATTERN, collectionTopicPartition, collectionTopicTarget, partitionOfCall, storageOfCall, withPartition } from "./partition.js";
|
|
14
|
+
// The rules of the rows of a collection: a filter of the reads and a guard of the writes (roadmap CLI-41)
|
|
15
|
+
export { admittedStorage, admitsRow } from "./admission.js";
|
|
16
|
+
// The precondition of the writes: the expected version and VERSION_CONFLICT (roadmap CLI-16)
|
|
17
|
+
export { MAX_EXPECTED_VERSION_LENGTH, PRECONDITION_NOT_SUPPORTED, VERSION_CONFLICTS_METADATA_KEY, VersionConflictError, asVersionConflictError, isExpectedVersion, preconditionNotSupported, versionConflict, versionConflicts, versionConflictsOf, } from "./precondition.js";
|
|
14
18
|
// The query language of the storages: the same JSON on the wire and in query() (roadmap CLI-34:
|
|
15
19
|
// the one copy of the language)
|
|
16
20
|
export { DEFAULT_FIND_LIMIT, DEFAULT_QUERY_OPERATORS, DEFAULT_QUERY_POLICY, QUERY_OPERATORS, applyPatch, compareStorageValues, compileSelector, isPatchOperations, matchesSelector, mergePatch, patchProblems, queryEntries, queryOptionsProblems, selectorProblems, } from "./query.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/collection/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU;AACV,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAuBtB,aAAa;AACb,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAG7D,mDAAmD;AACnD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG3E,kDAAkD;AAClD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/collection/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU;AACV,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAuBtB,aAAa;AACb,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAG7D,mDAAmD;AACnD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG3E,kDAAkD;AAClD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGnJ,0GAA0G;AAC1G,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAmB5D,6FAA6F;AAC7F,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,gGAAgG;AAChG,gCAAgC;AAChC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The patch of an item of a storage (roadmap CLI-14): `patch()` of the storage, or a read, a merge
|
|
3
|
+
* and a write for a storage without it.
|
|
4
|
+
*/
|
|
5
|
+
import { type StoragePatch } from "./query.js";
|
|
6
|
+
import type { CollectionStorage, StorageWriteOptions } from "./storage.js";
|
|
7
|
+
/**
|
|
8
|
+
* This function patches an item of a storage without `patch()`: a read, a merge and a write. The
|
|
9
|
+
* check gets the stored item and the merged item before the write. An error of the check stops
|
|
10
|
+
* the patch, and the storage does not change.
|
|
11
|
+
*/
|
|
12
|
+
export declare function patchInParts(storage: CollectionStorage<unknown>, id: string, fields: StoragePatch, options?: StorageWriteOptions, check?: (prev: unknown, next: unknown) => Promise<void>): Promise<unknown>;
|
|
13
|
+
/** This function patches an item: with `patch()` of the storage, or in parts. It gives the new item, or undefined for a missing id. */
|
|
14
|
+
export declare function patchItem(storage: CollectionStorage<unknown>, id: string, fields: StoragePatch, options?: StorageWriteOptions): Promise<unknown>;
|
|
15
|
+
//# sourceMappingURL=patch-in-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-in-parts.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/patch-in-parts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAS3E;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EACnC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,mBAAmB,EAC7B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GACtD,OAAO,CAAC,OAAO,CAAC,CAyBlB;AAED,uIAAuI;AACvI,wBAAgB,SAAS,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhJ"}
|