@procedures/client 0.15.0 → 0.16.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/adapters/http/server/handler.d.ts.map +1 -1
  4. package/dist/adapters/http/server/handler.js +5 -3
  5. package/dist/adapters/http/server/handler.js.map +1 -1
  6. package/dist/browser.d.ts +3 -2
  7. package/dist/browser.d.ts.map +1 -1
  8. package/dist/browser.js +1 -1
  9. package/dist/browser.js.map +1 -1
  10. package/dist/client/errors/registry.d.ts.map +1 -1
  11. package/dist/client/errors/registry.js +12 -0
  12. package/dist/client/errors/registry.js.map +1 -1
  13. package/dist/client/middleware/rate-limit.d.ts +17 -0
  14. package/dist/client/middleware/rate-limit.d.ts.map +1 -1
  15. package/dist/client/middleware/rate-limit.js +94 -39
  16. package/dist/client/middleware/rate-limit.js.map +1 -1
  17. package/dist/events/index.d.ts +1 -0
  18. package/dist/events/index.d.ts.map +1 -1
  19. package/dist/events/index.js.map +1 -1
  20. package/dist/events/publisher.d.ts +50 -5
  21. package/dist/events/publisher.d.ts.map +1 -1
  22. package/dist/events/publisher.js +99 -10
  23. package/dist/events/publisher.js.map +1 -1
  24. package/dist/events/recheck.d.ts +84 -0
  25. package/dist/events/recheck.d.ts.map +1 -0
  26. package/dist/events/recheck.js +135 -0
  27. package/dist/events/recheck.js.map +1 -0
  28. package/dist/procedures/collection/changes.d.ts +9 -8
  29. package/dist/procedures/collection/changes.d.ts.map +1 -1
  30. package/dist/procedures/collection/changes.js +11 -11
  31. package/dist/procedures/collection/changes.js.map +1 -1
  32. package/dist/procedures/collection/index.d.ts +1 -0
  33. package/dist/procedures/collection/index.d.ts.map +1 -1
  34. package/dist/procedures/collection/index.js +2 -0
  35. package/dist/procedures/collection/index.js.map +1 -1
  36. package/dist/procedures/collection/partition.d.ts +4 -23
  37. package/dist/procedures/collection/partition.d.ts.map +1 -1
  38. package/dist/procedures/collection/partition.js +2 -28
  39. package/dist/procedures/collection/partition.js.map +1 -1
  40. package/dist/procedures/collection/topic.d.ts +86 -0
  41. package/dist/procedures/collection/topic.d.ts.map +1 -0
  42. package/dist/procedures/collection/topic.js +94 -0
  43. package/dist/procedures/collection/topic.js.map +1 -0
  44. package/dist/procedures/index.d.ts +1 -1
  45. package/dist/procedures/index.d.ts.map +1 -1
  46. package/dist/procedures/index.js +1 -1
  47. package/dist/procedures/index.js.map +1 -1
  48. package/dist/protocol.d.ts +1 -1
  49. package/dist/protocol.d.ts.map +1 -1
  50. package/dist/protocol.js +1 -0
  51. package/dist/protocol.js.map +1 -1
  52. package/dist/server/host-policy.d.ts +17 -0
  53. package/dist/server/host-policy.d.ts.map +1 -1
  54. package/dist/server/host-policy.js +7 -0
  55. package/dist/server/host-policy.js.map +1 -1
  56. package/dist/server/limits.d.ts +122 -0
  57. package/dist/server/limits.d.ts.map +1 -0
  58. package/dist/server/limits.js +153 -0
  59. package/dist/server/limits.js.map +1 -0
  60. package/dist/server/procedure-server.d.ts +35 -3
  61. package/dist/server/procedure-server.d.ts.map +1 -1
  62. package/dist/server/procedure-server.js +42 -8
  63. package/dist/server/procedure-server.js.map +1 -1
  64. package/dist/server/request-auth.d.ts +5 -1
  65. package/dist/server/request-auth.d.ts.map +1 -1
  66. package/dist/server/request-auth.js +19 -2
  67. package/dist/server/request-auth.js.map +1 -1
  68. package/package.json +3 -3
  69. package/src/adapters/http/server/handler.ts +5 -3
  70. package/src/browser.ts +5 -0
  71. package/src/client/errors/registry.ts +13 -0
  72. package/src/client/middleware/rate-limit.ts +116 -41
  73. package/src/events/index.ts +1 -0
  74. package/src/events/publisher.ts +121 -12
  75. package/src/events/recheck.ts +182 -0
  76. package/src/procedures/collection/changes.ts +12 -11
  77. package/src/procedures/collection/index.ts +2 -0
  78. package/src/procedures/collection/partition.ts +5 -27
  79. package/src/procedures/collection/topic.ts +115 -0
  80. package/src/procedures/index.ts +1 -0
  81. package/src/protocol.ts +3 -1
  82. package/src/server/host-policy.ts +22 -0
  83. package/src/server/limits.ts +254 -0
  84. package/src/server/procedure-server.ts +59 -9
  85. package/src/server/request-auth.ts +19 -2
@@ -0,0 +1,135 @@
1
+ /**
2
+ * The re-check of the admission of the open subscriptions (roadmap CLI-44).
3
+ *
4
+ * At the start of a subscription, a publisher examines the rights of the subscriber. It examines
5
+ * the topic rule, the reads of the capability, `allow` and the partition. A right can change
6
+ * later, for example when the app removes a user from a group. Thus the publisher examines each
7
+ * open subscription again:
8
+ *
9
+ * - At a change of the rights. The host uses `rightsChanged()` of the publisher, or the source of
10
+ * the option `recheck.rightsChanges` gives the change to its listener.
11
+ * - After the time `recheck.maxAge` on the clock of the publisher, from the last check.
12
+ *
13
+ * The check is the same function as at the start. While it operates, the events of the
14
+ * subscription wait. A refusal ends the subscription with its error, for example `FORBIDDEN`, and
15
+ * the events that wait go. Without a call of `rightsChanged()` and without the option, nothing
16
+ * changes.
17
+ */
18
+ import { toMs } from "../duration.js";
19
+ /** True when the change touches a subscription of the principal. A test that throws touches it. */
20
+ function touches(change, principal) {
21
+ if (change === undefined)
22
+ return true;
23
+ if (typeof change === "string")
24
+ return principal?.id === change;
25
+ try {
26
+ return change(principal);
27
+ }
28
+ catch {
29
+ return true;
30
+ }
31
+ }
32
+ /** The promise of a check. A check that throws at once gives a rejected promise. */
33
+ function started(check) {
34
+ return new Promise((resolve) => resolve(check()));
35
+ }
36
+ /**
37
+ * The re-checks of the open subscriptions of one publisher (roadmap CLI-44). The publisher gives
38
+ * each new subscription to `watch()`, with the check of its admission.
39
+ */
40
+ export class SubscriptionRechecks {
41
+ clock;
42
+ watches = new Set();
43
+ maxAgeMs;
44
+ source;
45
+ /** The function that removes the listener of the source, while a subscription is open */
46
+ stopListening;
47
+ constructor(options, clock) {
48
+ this.clock = clock;
49
+ const maxAgeMs = options.maxAge === undefined ? undefined : toMs(options.maxAge, "recheck.maxAge");
50
+ if (maxAgeMs !== undefined && !(maxAgeMs > 0)) {
51
+ throw new TypeError(`recheck.maxAge must be more than 0 ms, got ${maxAgeMs} ms`);
52
+ }
53
+ this.maxAgeMs = maxAgeMs;
54
+ this.source = options.rightsChanges;
55
+ }
56
+ /** The number of the subscriptions that the re-checks watch. */
57
+ get size() {
58
+ return this.watches.size;
59
+ }
60
+ /**
61
+ * This function watches a subscription until it ends. A change of the rights of its principal
62
+ * and its max age start the check. The check must throw the refusal.
63
+ */
64
+ watch(subscription, principal, check) {
65
+ const watch = {
66
+ principal,
67
+ timer: undefined,
68
+ recheck: () => {
69
+ this.stopTimer(watch);
70
+ return subscription.hold(started(check)).then(() => {
71
+ // A check that passes gives the admission a new age
72
+ if (this.watches.has(watch))
73
+ this.startTimer(watch);
74
+ });
75
+ },
76
+ };
77
+ this.watches.add(watch);
78
+ subscription.onEnd(() => this.unwatch(watch));
79
+ if (!this.watches.has(watch))
80
+ return;
81
+ this.startTimer(watch);
82
+ if (this.source && !this.stopListening) {
83
+ try {
84
+ this.stopListening = this.source((change) => void this.rightsChanged(change));
85
+ }
86
+ catch (error) {
87
+ // A source that cannot listen cannot tell a revocation: the subscription ends
88
+ void subscription.hold(Promise.reject(error));
89
+ }
90
+ }
91
+ }
92
+ /**
93
+ * This function starts a check of each watched subscription that the change touches. The
94
+ * promise ends when each check ends.
95
+ */
96
+ rightsChanged(change) {
97
+ const checks = [];
98
+ for (const watch of [...this.watches]) {
99
+ if (touches(change, watch.principal))
100
+ checks.push(watch.recheck());
101
+ }
102
+ return Promise.all(checks).then(() => undefined);
103
+ }
104
+ /** This function stops the watch of a subscription that ended. */
105
+ unwatch(watch) {
106
+ this.stopTimer(watch);
107
+ if (!this.watches.delete(watch) || this.watches.size > 0)
108
+ return;
109
+ // The last subscription ended: the publisher does not listen to the source
110
+ const stop = this.stopListening;
111
+ this.stopListening = undefined;
112
+ stop?.();
113
+ }
114
+ /** This function starts the timer of the max age of a subscription. */
115
+ startTimer(watch) {
116
+ if (this.maxAgeMs === undefined)
117
+ return;
118
+ this.stopTimer(watch);
119
+ const timer = this.clock.after(this.maxAgeMs, () => {
120
+ if (watch.timer === timer)
121
+ watch.timer = undefined;
122
+ void watch.recheck();
123
+ });
124
+ // A check does not keep a Node process alive
125
+ timer.unref?.();
126
+ watch.timer = timer;
127
+ }
128
+ /** This function stops the timer of the max age of a subscription. */
129
+ stopTimer(watch) {
130
+ const timer = watch.timer;
131
+ watch.timer = undefined;
132
+ timer?.();
133
+ }
134
+ }
135
+ //# sourceMappingURL=recheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recheck.js","sourceRoot":"","sources":["../../src/events/recheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,IAAI,EAAiB,MAAM,gBAAgB,CAAC;AA+CrD,mGAAmG;AACnG,SAAS,OAAO,CAAC,MAAgC,EAAE,SAAgC;IACjF,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACtC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,EAAE,EAAE,KAAK,MAAM,CAAC;IAChE,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,SAAS,OAAO,CAAC,KAA0B;IACzC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IASZ,KAAK;IARP,OAAO,GAAG,IAAI,GAAG,EAAS,CAAC;IAC3B,QAAQ,CAAqB;IAC7B,MAAM,CAAuC;IAC9D,yFAAyF;IACjF,aAAa,CAA2B;IAEhD,YACE,OAA4B,EACX,KAAY;qBAAZ,KAAK;QAEtB,MAAM,QAAQ,GAAG,OA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,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO;QACxC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;YACjD,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK;gBAAE,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;YACnD,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,6CAA6C;QAC7C,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAChB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,sEAAsE;IAC9D,SAAS,CAAC,KAAY;QAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;QACxB,KAAK,EAAE,EAAE,CAAC;IACZ,CAAC;CACF"}
@@ -26,6 +26,7 @@
26
26
  import type { EventBus } from "../../events/types.js";
27
27
  import type { AdmitItem } from "../invoke.js";
28
28
  import type { StorageChanges } from "./storage.js";
29
+ import type { RepositoryProvider } from "../types.js";
29
30
  /**
30
31
  * The change event of the writes of a collection, on the topic `collections.<name>` (roadmap
31
32
  * CLI-15). The data crosses the wire as JSON.
@@ -55,17 +56,18 @@ export interface CollectionChangeEvent {
55
56
  /** The origin of the writes, when one origin made all the changes of the event. */
56
57
  readonly origin?: string | undefined;
57
58
  }
58
- /**
59
- * This function gives the topic of the change events of a collection: `collections.<name>`, or
60
- * `collections.<name>.<partition>` for a partition (roadmap CLI-17).
61
- */
62
- export declare function collectionChangeTopic(collection: string, partition?: string): string;
59
+ export { collectionChangeTopic } from "./topic.js";
63
60
  /**
64
61
  * This function gives the resources that a subscriber of a topic reads: `collection:<name>` for
65
62
  * the topic `collections.<name>` and for a topic of a partition, `collections.<name>.<partition>`.
66
- * Another topic gives no resource. `EventPublisher` uses it as its default `reads`.
63
+ * Another topic gives no resource. `EventPublisher` uses it as its default `reads`, with the
64
+ * repository of the call.
65
+ *
66
+ * It reads the topic with `collectionTopicTarget()`, the parse of the listener of the publisher
67
+ * (roadmap CLI-42). With the repository, the plain topic of a dotted name, `collections.graph.nodes`,
68
+ * reads `collection:graph.nodes`. Without it, the first dot ends the name.
67
69
  */
68
- export declare function collectionTopicReads(topic: string): readonly string[];
70
+ export declare function collectionTopicReads(topic: string, repository?: RepositoryProvider): readonly string[];
69
71
  /** The part of a storage that the change events read. */
70
72
  interface ChangeLog {
71
73
  getChangesSince?(since?: string): Promise<StorageChanges<unknown>>;
@@ -92,5 +94,4 @@ export declare function writeWithChangeEvent<R>(bus: EventBus | undefined, stora
92
94
  * next event without a read.
93
95
  */
94
96
  export declare function startChangeChain(bus: EventBus | undefined, storage: object, topic: string | undefined, version: string): void;
95
- export {};
96
97
  //# sourceMappingURL=changes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,uFAAuF;IACvF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC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AE,CAGtG;AAED,yDAAyD;AACzD,UAAU,SAAS;IACjB,eAAe,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CACpE;AA4HD;;;;;;;;;;;;;;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"}
@@ -24,21 +24,21 @@
24
24
  * write resolves after its event is on the bus. A failed publish never fails the write.
25
25
  */
26
26
  import { withRows } from "../../events/rows.js";
27
- /**
28
- * This function gives the topic of the change events of a collection: `collections.<name>`, or
29
- * `collections.<name>.<partition>` for a partition (roadmap CLI-17).
30
- */
31
- export function collectionChangeTopic(collection, partition) {
32
- return partition === undefined ? `collections.${collection}` : `collections.${collection}.${partition}`;
33
- }
27
+ import { collectionTopicTarget } from "./topic.js";
28
+ export { collectionChangeTopic } from "./topic.js";
34
29
  /**
35
30
  * This function gives the resources that a subscriber of a topic reads: `collection:<name>` for
36
31
  * the topic `collections.<name>` and for a topic of a partition, `collections.<name>.<partition>`.
37
- * Another topic gives no resource. `EventPublisher` uses it as its default `reads`.
32
+ * Another topic gives no resource. `EventPublisher` uses it as its default `reads`, with the
33
+ * repository of the call.
34
+ *
35
+ * It reads the topic with `collectionTopicTarget()`, the parse of the listener of the publisher
36
+ * (roadmap CLI-42). With the repository, the plain topic of a dotted name, `collections.graph.nodes`,
37
+ * reads `collection:graph.nodes`. Without it, the first dot ends the name.
38
38
  */
39
- export function collectionTopicReads(topic) {
40
- const match = /^collections\.([^.]+)(?:\.|$)/.exec(topic);
41
- return match ? [`collection:${match[1]}`] : [];
39
+ export function collectionTopicReads(topic, repository) {
40
+ const target = collectionTopicTarget(topic, repository);
41
+ return target ? [`collection:${target.collection}`] : [];
42
42
  }
43
43
  /** The chains of each storage, by topic. A storage that goes away takes its chains with it. */
44
44
  const CHAINS = new WeakMap();
@@ -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;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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D,CAAC"}
@@ -10,6 +10,7 @@ export type { CollectionProceduresOptions, CollectionChangeEventsOptions } from
10
10
  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
+ export { collectionTopicRule } from "./topic.js";
13
14
  export type { CollectionPartitions, PartitionInput, PartitionResolver } from "./partition.js";
14
15
  export { admittedStorage, admitsRow } from "./admission.js";
15
16
  export type { CollectionAdmission, CollectionRow, CollectionWrite, CollectionWriteGuard } from "./admission.js";
@@ -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,EA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jB,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"}
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,OA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-11,6 +11,8 @@ 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 topic rule of a collection for EventPublisher (roadmap CLI-42)
15
+ export { collectionTopicRule } from "./topic.js";
14
16
  // The rules of the rows of a collection: a filter of the reads and a guard of the writes (roadmap CLI-41)
15
17
  export { admittedStorage, admitsRow } from "./admission.js";
16
18
  // The precondition of the writes: the expected version and VERSION_CONFLICT (roadmap CLI-16)
@@ -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;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"}
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;AACnJ,qEAAqE;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,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"}
@@ -11,10 +11,12 @@
11
11
  * - A subscriber names the partition that it asks for in the topic, as an input does:
12
12
  * `collections.<name>.<requested>`. The publisher resolves it in the same way and listens to the
13
13
  * topic of the resolved partition, so a subscriber cannot name the topic of another tenant.
14
+ * - In the topic of a partition, the name encodes `%` and `.` (`topic.ts`, roadmap CLI-42). Thus
15
+ * the name of a collection with partitions can have a dot.
14
16
  * - A collection without partitions refuses a call or a topic with a partition.
15
17
  */
16
18
  import type { ZodLike } from "../../client/validation/types.js";
17
- import type { ProcedureContext, RepositoryProvider } from "../types.js";
19
+ import type { ProcedureContext } from "../types.js";
18
20
  import type { CollectionStorage } from "./storage.js";
19
21
  /** The characters of a partition: letters, digits and `_ . : @ ~ + | / -`, 256 at most. */
20
22
  export declare const PARTITION_PATTERN: RegExp;
@@ -63,26 +65,5 @@ export declare function partitionOfCall(ctx: ProcedureContext, collection: strin
63
65
  * without `getPartitionStorage` refuses a partition.
64
66
  */
65
67
  export declare function storageOfCall<T>(ctx: ProcedureContext, collection: string, partition: string | undefined): CollectionStorage<T>;
66
- /**
67
- * This function gives the collection and the partition part of a topic of a call, with the
68
- * repository of the call: one rule for the read check and for the listener of the publisher.
69
- *
70
- * - A collection of the repository without partitions whose name is the whole rest of the topic
71
- * wins: its name can have a dot.
72
- * - Else the first part after `collections.` names the collection, and the rest is the partition
73
- * that the call asks for. A collection with partitions has no dot in its name.
74
- */
75
- export declare function collectionTopicTarget(topic: string, repository: RepositoryProvider | undefined): {
76
- collection: string;
77
- partition: string | undefined;
78
- } | undefined;
79
- /**
80
- * This function gives the collection and the partition part of a topic `collections.<name>` or
81
- * `collections.<name>.<partition>`, or undefined for another topic. It reads the topic alone:
82
- * `collectionTopicTarget` also knows the collections of a repository.
83
- */
84
- export declare function collectionTopicPartition(topic: string): {
85
- collection: string;
86
- partition: string | undefined;
87
- } | undefined;
68
+ export { collectionTopicPartition, collectionTopicTarget } from "./topic.js";
88
69
  //# sourceMappingURL=partition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"partition.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/partition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,2FAA2F;AAC3F,eAAO,MAAM,iBAAiB,EAAE,MAAwC,CAAC;AAEzE,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,M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AAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAQ/H;AAGD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
@@ -81,32 +81,6 @@ export function storageOfCall(ctx, collection, partition) {
81
81
  }
82
82
  return repository.getPartitionStorage(collection, partition);
83
83
  }
84
- /**
85
- * This function gives the collection and the partition part of a topic of a call, with the
86
- * repository of the call: one rule for the read check and for the listener of the publisher.
87
- *
88
- * - A collection of the repository without partitions whose name is the whole rest of the topic
89
- * wins: its name can have a dot.
90
- * - Else the first part after `collections.` names the collection, and the rest is the partition
91
- * that the call asks for. A collection with partitions has no dot in its name.
92
- */
93
- export function collectionTopicTarget(topic, repository) {
94
- if (!topic.startsWith("collections."))
95
- return undefined;
96
- const whole = topic.slice("collections.".length);
97
- if (whole !== "" && repository?.hasCollection(whole) && !repository.hasPartitions?.(whole))
98
- return { collection: whole, partition: undefined };
99
- return collectionTopicPartition(topic);
100
- }
101
- /**
102
- * This function gives the collection and the partition part of a topic `collections.<name>` or
103
- * `collections.<name>.<partition>`, or undefined for another topic. It reads the topic alone:
104
- * `collectionTopicTarget` also knows the collections of a repository.
105
- */
106
- export function collectionTopicPartition(topic) {
107
- const match = /^collections\.([^.]+)(?:\.(.+))?$/.exec(topic);
108
- if (!match)
109
- return undefined;
110
- return { collection: match[1], partition: match[2] };
111
- }
84
+ // The parse of a topic lives in topic.ts, with the encode (roadmap CLI-42)
85
+ export { collectionTopicPartition, collectionTopicTarget } from "./topic.js";
112
86
  //# sourceMappingURL=partition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"partition.js","sourceRoot":"","sources":["../../../src/procedures/collection/partition.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,iBAAiB,GAAW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AAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1H,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAI,GAAqB,EAAE,UAAkB,EAAE,SAA6B;IACvG,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAClC,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAClF,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,UAAU,CAAI,UAAU,CAAC,CAAC;IACzE,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,sEAAsE,SAAS,QAAQ,UAAU,EAAE,CAAC,CAAC;IACvH,CAAC;IACD,OAAO,UAAU,CAAC,mBAAmB,CAAI,UAAU,EAAE,SAAS,CAAC,CAAC;AAClE,CAAC;AAED,2EAA2E;AAC3E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * The topics of the change events of a collection (roadmap CLI-15, CLI-17 and CLI-42). This module
3
+ * has the one function that makes a topic, the functions that read it, and the topic rule of a
4
+ * collection. Each part of the client that makes or reads the topic of a collection or of a
5
+ * partition uses them.
6
+ *
7
+ * - `collections.<name>` is the topic of a collection. The name stays as it is, also with a dot.
8
+ * - `collections.<name>.<partition>` is the topic of a partition. In this form, the name encodes
9
+ * `%` as `%25` and `.` as `%2E`. Thus the first dot after `collections.` ends the name, and the
10
+ * partition after that dot can have each character, also `.`, `/` and `%`.
11
+ * - The partition stays as it is, and so does a name without `.` and `%`. Thus each topic of a
12
+ * partition of a name without `.` and `%` stays the same as before CLI-42.
13
+ * - Only the canonical form of a topic counts: a parse gives a collection and a partition only when
14
+ * `collectionChangeTopic(collection, partition)` gives the same topic. Thus `%2e` is no alias of
15
+ * `%2E`, and a rule or an `allow` function that compares the strings sees each topic one way.
16
+ * - The topic of a collection whose name has a dot, `collections.a.b`, has the same form as the
17
+ * topic of the partition `b` of the collection `a`. Only the repository knows the collection, so
18
+ * `collectionTopicTarget()` decides with it.
19
+ */
20
+ import type { RepositoryProvider } from "../types.js";
21
+ /**
22
+ * This function gives the topic of the change events of a collection: `collections.<name>`, or
23
+ * `collections.<name>.<partition>` for a partition (roadmap CLI-17). In the topic of a partition,
24
+ * the name encodes `%` and `.` (roadmap CLI-42), so `collectionTopicPartition()` gives back the
25
+ * same collection and the same partition.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * collectionChangeTopic("notes", "t1/board:b1"); // "collections.notes.t1/board:b1"
30
+ * collectionChangeTopic("graph.nodes", "acme/space"); // "collections.graph%2Enodes.acme/space"
31
+ * collectionChangeTopic("graph.nodes"); // "collections.graph.nodes"
32
+ * ```
33
+ */
34
+ export declare function collectionChangeTopic(collection: string, partition?: string): string;
35
+ /**
36
+ * This function gives the collection and the partition of a topic `collections.<name>` or
37
+ * `collections.<name>.<partition>`, or undefined for another topic. It reads the topic alone:
38
+ * `collectionTopicTarget()` also knows the collections of a repository.
39
+ *
40
+ * - The first dot after the name ends the name. In a topic with a partition, the name is decoded:
41
+ * `%2E` is a dot and `%25` is a `%` (roadmap CLI-42).
42
+ * - Each character after that dot is the partition. A partition has one character at least.
43
+ * - A topic that is not in the canonical form gives undefined: `collectionChangeTopic()` of the
44
+ * result always gives the topic again. Thus `collections.a%2eb.t1` names no collection.
45
+ * - For each name and each partition, `collectionTopicPartition(collectionChangeTopic(name,
46
+ * partition))` gives the same name and the same partition.
47
+ */
48
+ export declare function collectionTopicPartition(topic: string): {
49
+ collection: string;
50
+ partition: string | undefined;
51
+ } | undefined;
52
+ /**
53
+ * This function gives the collection and the partition part of a topic of a call, with the
54
+ * repository of the call: one rule for the read check and for the listener of the publisher.
55
+ *
56
+ * - A collection of the repository whose name is the whole rest of the topic wins, with or without
57
+ * partitions: its name can have a dot. The call then asks for no partition.
58
+ * - Else `collectionTopicPartition()` reads the topic: the first dot after the name ends the name,
59
+ * and the rest is the partition that the call asks for. In this form, the name encodes `%` and
60
+ * `.`, so the name of a collection with partitions can have a dot (roadmap CLI-42).
61
+ */
62
+ export declare function collectionTopicTarget(topic: string, repository: RepositoryProvider | undefined): {
63
+ collection: string;
64
+ partition: string | undefined;
65
+ } | undefined;
66
+ /**
67
+ * This function gives the topic rule of a collection for `EventPublisher` (the option `topics`):
68
+ * the topic of the collection, and the pattern of the topics of its partitions (roadmap CLI-42).
69
+ * Build the rule of a collection with it. Do not join the parts yourself: a dotted name needs its
70
+ * encoded form in the pattern.
71
+ *
72
+ * - The rule always has the two forms. For a collection with partitions, the plain topic asks for
73
+ * no partition, and the resolver of the partition decides.
74
+ * - For a collection without partitions, a topic of a partition passes the rule. The publisher then
75
+ * refuses it with `FORBIDDEN` (reason `partition-not-allowed`).
76
+ * - The pattern matches only the canonical form of a topic, so an alias of an escape gets
77
+ * `TOPIC_NOT_FOUND`.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * collectionTopicRule("graph.nodes"); // ["collections.graph.nodes", "collections.graph%2Enodes.*"]
82
+ * new EventPublisher({ bus, topics: ["orders.*", ...collectionTopicRule("graph.nodes")] });
83
+ * ```
84
+ */
85
+ export declare function collectionTopicRule(collection: string): string[];
86
+ //# sourceMappingURL=topic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topic.d.ts","sourceRoot":"","sources":["../../../src/procedures/collection/topic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAetD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAUzH;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,SAAS,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAKlK;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhE"}
@@ -0,0 +1,94 @@
1
+ /** The prefix of the topic of each collection. */
2
+ const PREFIX = "collections.";
3
+ /** This function encodes the name of a collection for a topic with a partition: `%` and `.` become `%25` and `%2E`. */
4
+ function encodeTopicName(name) {
5
+ return name.replace(/[%.]/g, (char) => (char === "%" ? "%25" : "%2E"));
6
+ }
7
+ /** This function decodes the name of a topic with a partition. The parse then checks the canonical form. */
8
+ function decodeTopicName(segment) {
9
+ return segment.replace(/%(25|2E)/g, (_sequence, code) => (code === "25" ? "%" : "."));
10
+ }
11
+ /**
12
+ * This function gives the topic of the change events of a collection: `collections.<name>`, or
13
+ * `collections.<name>.<partition>` for a partition (roadmap CLI-17). In the topic of a partition,
14
+ * the name encodes `%` and `.` (roadmap CLI-42), so `collectionTopicPartition()` gives back the
15
+ * same collection and the same partition.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * collectionChangeTopic("notes", "t1/board:b1"); // "collections.notes.t1/board:b1"
20
+ * collectionChangeTopic("graph.nodes", "acme/space"); // "collections.graph%2Enodes.acme/space"
21
+ * collectionChangeTopic("graph.nodes"); // "collections.graph.nodes"
22
+ * ```
23
+ */
24
+ export function collectionChangeTopic(collection, partition) {
25
+ return partition === undefined ? `${PREFIX}${collection}` : `${PREFIX}${encodeTopicName(collection)}.${partition}`;
26
+ }
27
+ /**
28
+ * This function gives the collection and the partition of a topic `collections.<name>` or
29
+ * `collections.<name>.<partition>`, or undefined for another topic. It reads the topic alone:
30
+ * `collectionTopicTarget()` also knows the collections of a repository.
31
+ *
32
+ * - The first dot after the name ends the name. In a topic with a partition, the name is decoded:
33
+ * `%2E` is a dot and `%25` is a `%` (roadmap CLI-42).
34
+ * - Each character after that dot is the partition. A partition has one character at least.
35
+ * - A topic that is not in the canonical form gives undefined: `collectionChangeTopic()` of the
36
+ * result always gives the topic again. Thus `collections.a%2eb.t1` names no collection.
37
+ * - For each name and each partition, `collectionTopicPartition(collectionChangeTopic(name,
38
+ * partition))` gives the same name and the same partition.
39
+ */
40
+ export function collectionTopicPartition(topic) {
41
+ if (!topic.startsWith(PREFIX))
42
+ return undefined;
43
+ const rest = topic.slice(PREFIX.length);
44
+ const dot = rest.indexOf(".");
45
+ if (dot === -1)
46
+ return rest === "" ? undefined : { collection: rest, partition: undefined };
47
+ if (dot === 0 || dot === rest.length - 1)
48
+ return undefined;
49
+ const collection = decodeTopicName(rest.slice(0, dot));
50
+ const partition = rest.slice(dot + 1);
51
+ // Only the canonical form counts: an alias of an escape names no collection
52
+ return collectionChangeTopic(collection, partition) === topic ? { collection, partition } : undefined;
53
+ }
54
+ /**
55
+ * This function gives the collection and the partition part of a topic of a call, with the
56
+ * repository of the call: one rule for the read check and for the listener of the publisher.
57
+ *
58
+ * - A collection of the repository whose name is the whole rest of the topic wins, with or without
59
+ * partitions: its name can have a dot. The call then asks for no partition.
60
+ * - Else `collectionTopicPartition()` reads the topic: the first dot after the name ends the name,
61
+ * and the rest is the partition that the call asks for. In this form, the name encodes `%` and
62
+ * `.`, so the name of a collection with partitions can have a dot (roadmap CLI-42).
63
+ */
64
+ export function collectionTopicTarget(topic, repository) {
65
+ if (!topic.startsWith(PREFIX))
66
+ return undefined;
67
+ const whole = topic.slice(PREFIX.length);
68
+ if (whole !== "" && repository?.hasCollection(whole))
69
+ return { collection: whole, partition: undefined };
70
+ return collectionTopicPartition(topic);
71
+ }
72
+ /**
73
+ * This function gives the topic rule of a collection for `EventPublisher` (the option `topics`):
74
+ * the topic of the collection, and the pattern of the topics of its partitions (roadmap CLI-42).
75
+ * Build the rule of a collection with it. Do not join the parts yourself: a dotted name needs its
76
+ * encoded form in the pattern.
77
+ *
78
+ * - The rule always has the two forms. For a collection with partitions, the plain topic asks for
79
+ * no partition, and the resolver of the partition decides.
80
+ * - For a collection without partitions, a topic of a partition passes the rule. The publisher then
81
+ * refuses it with `FORBIDDEN` (reason `partition-not-allowed`).
82
+ * - The pattern matches only the canonical form of a topic, so an alias of an escape gets
83
+ * `TOPIC_NOT_FOUND`.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * collectionTopicRule("graph.nodes"); // ["collections.graph.nodes", "collections.graph%2Enodes.*"]
88
+ * new EventPublisher({ bus, topics: ["orders.*", ...collectionTopicRule("graph.nodes")] });
89
+ * ```
90
+ */
91
+ export function collectionTopicRule(collection) {
92
+ return [collectionChangeTopic(collection), `${PREFIX}${encodeTopicName(collection)}.*`];
93
+ }
94
+ //# sourceMappingURL=topic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topic.js","sourceRoot":"","sources":["../../../src/procedures/collection/topic.ts"],"names":[],"mappings":"AAqBA,kDAAkD;AAClD,MAAM,MAAM,GAAG,cAAc,CAAC;AAE9B,uHAAuH;AACvH,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,4GAA4G;AAC5G,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,SAAS,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAA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G;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa,EAAE,UAA0C;IAC7F,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,EAAE,IAAI,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IACzG,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAkB;IACpD,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,GAAG,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1F,CAAC"}
@@ -25,7 +25,7 @@ export type { NarrowingNote, WireNarrowing, NarrowedCapability } from "./narrowi
25
25
  export { ProcedureRegistry, RegistryError, PROCEDURE_REGISTRY, assertValidPath } from "./registry.js";
26
26
  export { defineProcedure, defineStub, createProcedure, ProcedureBuilder, namespace, validateProcedure, } from "./define.js";
27
27
  export type { ProcedureDefinition, ProcedureStub } from "./define.js";
28
- export { createCollectionProcedures, collectionChangeTopic, collectionTopicReads, PARTITION_PATTERN, collectionTopicPartition, collectionTopicTarget, admittedStorage, admitsRow, DEFAULT_FIND_LIMIT, DEFAULT_QUERY_OPERATORS, DEFAULT_QUERY_POLICY, QUERY_OPERATORS, applyPatch, compareStorageValues, compileSelector, isPatchOperations, matchesSelector, mergePatch, patchProblems, queryEntries, queryOptionsProblems, selectorProblems, MAX_EXPECTED_VERSION_LENGTH, PRECONDITION_NOT_SUPPORTED, VERSION_CONFLICTS_METADATA_KEY, VersionConflictError, asVersionConflictError, isExpectedVersion, preconditionNotSupported, versionConflict, versionConflicts, versionConflictsOf, } from "./collection/index.js";
28
+ export { createCollectionProcedures, collectionChangeTopic, collectionTopicReads, PARTITION_PATTERN, collectionTopicPartition, collectionTopicTarget, collectionTopicRule, admittedStorage, admitsRow, DEFAULT_FIND_LIMIT, DEFAULT_QUERY_OPERATORS, DEFAULT_QUERY_POLICY, QUERY_OPERATORS, applyPatch, compareStorageValues, compileSelector, isPatchOperations, matchesSelector, mergePatch, patchProblems, queryEntries, queryOptionsProblems, selectorProblems, MAX_EXPECTED_VERSION_LENGTH, PRECONDITION_NOT_SUPPORTED, VERSION_CONFLICTS_METADATA_KEY, VersionConflictError, asVersionConflictError, isExpectedVersion, preconditionNotSupported, versionConflict, versionConflicts, versionConflictsOf, } from "./collection/index.js";
29
29
  export type { CurrentItem, VersionConflict, VersionOf, StorageItemWriteOptions, StorageBatchWriteOptions, CollectionProceduresOptions, CollectionChangeEventsOptions, CollectionChangeEvent, CollectionAdmission, CollectionRow, CollectionWrite, CollectionWriteGuard, CollectionPartitions, PartitionInput, PartitionResolver, StoragePatchOperations, StorageQueryOperator, StorageQueryPolicy, CollectionStorage, StorageChanges, StorageMetadata, StorageWriteOptions, StorageSetChange, StorageDeleteChange, StorageClearChange, StorageChangeEvent, StorageChangeBatch, StorageObserver, StorageFieldOperators, StoragePatch, StorageQueryOptions, StorageSelector, StorageSort, StorageSortDirection, } from "./collection/index.js";
30
30
  export { registerModule, registerProcedures, createAndRegister, } from "./discovery.js";
31
31
  export { clientModule, defineModule, moduleClosure, registerModules, createRegistry, registerClientProcedures, } from "./module.js";