@spine-event-engine/server 2.0.0-snapshot.25 → 2.0.0-snapshot.26

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 (150) hide show
  1. package/README.md +49 -9
  2. package/REFERENCE.md +339 -22
  3. package/dist/agent/agent-history.d.ts +19 -3
  4. package/dist/agent/agent-history.d.ts.map +1 -1
  5. package/dist/agent/agent-history.js +41 -10
  6. package/dist/agent/agent-history.js.map +1 -1
  7. package/dist/agent/agent-live-read-runtime.d.ts +12 -1
  8. package/dist/agent/agent-live-read-runtime.d.ts.map +1 -1
  9. package/dist/agent/agent-live-read-runtime.js +5 -4
  10. package/dist/agent/agent-live-read-runtime.js.map +1 -1
  11. package/dist/browser/browser-server.d.ts +163 -0
  12. package/dist/browser/browser-server.d.ts.map +1 -1
  13. package/dist/browser/browser-server.js +579 -188
  14. package/dist/browser/browser-server.js.map +1 -1
  15. package/dist/browser/durable-subscription-bindings.d.ts +5 -0
  16. package/dist/browser/durable-subscription-bindings.d.ts.map +1 -1
  17. package/dist/browser/durable-subscription-bindings.js +226 -38
  18. package/dist/browser/durable-subscription-bindings.js.map +1 -1
  19. package/dist/browser/options.d.ts +5 -0
  20. package/dist/browser/options.d.ts.map +1 -1
  21. package/dist/bus/command-bus.d.ts +3 -0
  22. package/dist/bus/command-bus.d.ts.map +1 -1
  23. package/dist/bus/command-bus.js +69 -9
  24. package/dist/bus/command-bus.js.map +1 -1
  25. package/dist/bus/command-errors.d.ts +20 -4
  26. package/dist/bus/command-errors.d.ts.map +1 -1
  27. package/dist/bus/command-errors.js +47 -7
  28. package/dist/bus/command-errors.js.map +1 -1
  29. package/dist/bus/event-bus.d.ts +3 -0
  30. package/dist/bus/event-bus.d.ts.map +1 -1
  31. package/dist/bus/event-bus.js +130 -8
  32. package/dist/bus/event-bus.js.map +1 -1
  33. package/dist/context/bounded-context.d.ts +29 -11
  34. package/dist/context/bounded-context.d.ts.map +1 -1
  35. package/dist/context/bounded-context.js +147 -186
  36. package/dist/context/bounded-context.js.map +1 -1
  37. package/dist/entity/entity.d.ts +59 -0
  38. package/dist/entity/entity.d.ts.map +1 -1
  39. package/dist/entity/entity.js +60 -0
  40. package/dist/entity/entity.js.map +1 -1
  41. package/dist/handler/app-query-handler.d.ts +60 -0
  42. package/dist/handler/app-query-handler.d.ts.map +1 -0
  43. package/dist/handler/app-query-handler.js +23 -0
  44. package/dist/handler/app-query-handler.js.map +1 -0
  45. package/dist/handler/generated-registry-discovery.d.ts +6 -0
  46. package/dist/handler/generated-registry-discovery.d.ts.map +1 -1
  47. package/dist/handler/generated-registry-discovery.js +71 -2
  48. package/dist/handler/generated-registry-discovery.js.map +1 -1
  49. package/dist/handler/handler-decorators.d.ts +8 -29
  50. package/dist/handler/handler-decorators.d.ts.map +1 -1
  51. package/dist/handler/handler-decorators.js +33 -210
  52. package/dist/handler/handler-decorators.js.map +1 -1
  53. package/dist/handler/spine-metadata-inventory.d.ts +99 -0
  54. package/dist/handler/spine-metadata-inventory.d.ts.map +1 -0
  55. package/dist/handler/spine-metadata-inventory.js +162 -0
  56. package/dist/handler/spine-metadata-inventory.js.map +1 -0
  57. package/dist/index.d.ts +5 -3
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +4 -2
  60. package/dist/index.js.map +1 -1
  61. package/dist/repository/repository.d.ts +44 -1
  62. package/dist/repository/repository.d.ts.map +1 -1
  63. package/dist/repository/repository.js +368 -88
  64. package/dist/repository/repository.js.map +1 -1
  65. package/dist/server/managed-server-application.d.ts +12 -11
  66. package/dist/server/managed-server-application.d.ts.map +1 -1
  67. package/dist/server/managed-server-application.js +41 -25
  68. package/dist/server/managed-server-application.js.map +1 -1
  69. package/dist/server/node-coordinator.d.ts +18 -5
  70. package/dist/server/node-coordinator.d.ts.map +1 -1
  71. package/dist/server/node-coordinator.js +554 -84
  72. package/dist/server/node-coordinator.js.map +1 -1
  73. package/dist/server/reserved-spine-rpc-paths.json +1 -0
  74. package/dist/server/server-environment.d.ts +17 -0
  75. package/dist/server/server-environment.d.ts.map +1 -1
  76. package/dist/server/server-environment.js +77 -16
  77. package/dist/server/server-environment.js.map +1 -1
  78. package/dist/server/server.d.ts +45 -0
  79. package/dist/server/server.d.ts.map +1 -1
  80. package/dist/server/server.js +111 -3
  81. package/dist/server/server.js.map +1 -1
  82. package/dist/services/app-query-execution.d.ts +53 -0
  83. package/dist/services/app-query-execution.d.ts.map +1 -0
  84. package/dist/services/app-query-execution.js +408 -0
  85. package/dist/services/app-query-execution.js.map +1 -0
  86. package/dist/services/query-reader.d.ts +32 -7
  87. package/dist/services/query-reader.d.ts.map +1 -1
  88. package/dist/services/query-reader.js +22 -2
  89. package/dist/services/query-reader.js.map +1 -1
  90. package/dist/services/read-request-status.d.ts +65 -0
  91. package/dist/services/read-request-status.d.ts.map +1 -0
  92. package/dist/services/read-request-status.js +151 -0
  93. package/dist/services/read-request-status.js.map +1 -0
  94. package/dist/services/spine-services.d.ts +36 -7
  95. package/dist/services/spine-services.d.ts.map +1 -1
  96. package/dist/services/spine-services.js +900 -168
  97. package/dist/services/spine-services.js.map +1 -1
  98. package/dist/services/trusted-reader-ingress.d.ts +92 -0
  99. package/dist/services/trusted-reader-ingress.d.ts.map +1 -0
  100. package/dist/services/trusted-reader-ingress.js +89 -0
  101. package/dist/services/trusted-reader-ingress.js.map +1 -0
  102. package/dist/spi/handler-registry.d.ts +2 -0
  103. package/dist/spi/handler-registry.d.ts.map +1 -1
  104. package/dist/spi/handler-registry.js +1 -1
  105. package/dist/spi/handler-registry.js.map +1 -1
  106. package/dist/stand/read-side-filter-engine.d.ts +46 -0
  107. package/dist/stand/read-side-filter-engine.d.ts.map +1 -0
  108. package/dist/stand/read-side-filter-engine.js +356 -0
  109. package/dist/stand/read-side-filter-engine.js.map +1 -0
  110. package/dist/stand/read-side-filter.d.ts +247 -0
  111. package/dist/stand/read-side-filter.d.ts.map +1 -0
  112. package/dist/stand/read-side-filter.js +39 -0
  113. package/dist/stand/read-side-filter.js.map +1 -0
  114. package/dist/stand/read-side-message.d.ts +66 -0
  115. package/dist/stand/read-side-message.d.ts.map +1 -0
  116. package/dist/stand/read-side-message.js +167 -0
  117. package/dist/stand/read-side-message.js.map +1 -0
  118. package/dist/stand/stand-direct-delivery.d.ts +161 -0
  119. package/dist/stand/stand-direct-delivery.d.ts.map +1 -0
  120. package/dist/stand/stand-direct-delivery.js +210 -0
  121. package/dist/stand/stand-direct-delivery.js.map +1 -0
  122. package/dist/stand/stand.d.ts +80 -42
  123. package/dist/stand/stand.d.ts.map +1 -1
  124. package/dist/stand/stand.js +410 -54
  125. package/dist/stand/stand.js.map +1 -1
  126. package/dist/stand/subscription-observer.d.ts.map +1 -1
  127. package/dist/stand/subscription-observer.js +103 -0
  128. package/dist/stand/subscription-observer.js.map +1 -1
  129. package/dist/stand/subscription-read-filters.d.ts +40 -0
  130. package/dist/stand/subscription-read-filters.d.ts.map +1 -0
  131. package/dist/stand/subscription-read-filters.js +91 -0
  132. package/dist/stand/subscription-read-filters.js.map +1 -0
  133. package/dist/stand/subscription-reader-binding.d.ts +20 -0
  134. package/dist/stand/subscription-reader-binding.d.ts.map +1 -0
  135. package/dist/stand/subscription-reader-binding.js +56 -0
  136. package/dist/stand/subscription-reader-binding.js.map +1 -0
  137. package/dist/stand/subscription-records.d.ts +30 -3
  138. package/dist/stand/subscription-records.d.ts.map +1 -1
  139. package/dist/stand/subscription-records.js +61 -16
  140. package/dist/stand/subscription-records.js.map +1 -1
  141. package/dist/stand/subscription-registry.d.ts +49 -14
  142. package/dist/stand/subscription-registry.d.ts.map +1 -1
  143. package/dist/stand/subscription-registry.js +150 -31
  144. package/dist/stand/subscription-registry.js.map +1 -1
  145. package/dist/stand/subscription-runtime.d.ts +7 -2
  146. package/dist/stand/subscription-runtime.d.ts.map +1 -1
  147. package/dist/stand/subscription-runtime.js +131 -25
  148. package/dist/stand/subscription-runtime.js.map +1 -1
  149. package/dist/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +14 -14
@@ -0,0 +1,66 @@
1
+ import { type Message } from "@bufbuild/protobuf";
2
+ import type { GenMessage } from "@bufbuild/protobuf/codegenv2";
3
+ /**
4
+ * Cursor for copying one object without recursive calls.
5
+ */
6
+ interface CopyFrame {
7
+ readonly source: object;
8
+ readonly target: object;
9
+ readonly keys: readonly PropertyKey[];
10
+ next: number;
11
+ }
12
+ /**
13
+ * Detached Proto graph copies and shallow encodability checks.
14
+ */
15
+ export declare const ReadSideMessages: {
16
+ /**
17
+ * Copies a domain graph without recursion and rejects cyclic or executable values.
18
+ *
19
+ * @typeParam Value Input value type retained by the detached copy.
20
+ * @param value Source value to detach.
21
+ * @returns Mutable detached value.
22
+ */
23
+ copy<Value>(value: Value): Value;
24
+ /**
25
+ * Returns a frozen detached parent snapshot without recursively walking its graph.
26
+ *
27
+ * @typeParam Value Detached snapshot type.
28
+ * @param value Detached parent value.
29
+ * @returns The same read-only snapshot.
30
+ */
31
+ freeze<Value>(value: Value): Readonly<Value>;
32
+ /**
33
+ * Encodes one message's own scalar content without recursively encoding children.
34
+ *
35
+ * @param schema Schema of the current message.
36
+ * @param message Message whose scalar fields must be encodable.
37
+ */
38
+ checkShallow(schema: GenMessage<Message>, message: Message): void;
39
+ /**
40
+ * Creates a mutable shell for a Proto object, list, or binary field.
41
+ *
42
+ * @param source Value whose shape determines the shell.
43
+ * @returns Empty mutable copy target.
44
+ */
45
+ shell(source: object): object;
46
+ /**
47
+ * Creates an iterative copy cursor of a plain object or repeated field.
48
+ *
49
+ * @param source Value to inspect.
50
+ * @param target Detached target.
51
+ * @returns Mutable copy cursor.
52
+ */
53
+ frame(source: object, target: object): CopyFrame;
54
+ /**
55
+ * Copies one data property and schedules its nested object when necessary.
56
+ *
57
+ * @param frame Current object pair.
58
+ * @param key Source property key.
59
+ * @param seen Previously copied values.
60
+ * @param active Values on the current ancestry path.
61
+ * @param frames Pending copy cursors.
62
+ */
63
+ copyMember(frame: CopyFrame, key: PropertyKey, seen: WeakMap<object, object>, active: WeakSet<object>, frames: CopyFrame[]): void;
64
+ };
65
+ export {};
66
+ //# sourceMappingURL=read-side-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-side-message.d.ts","sourceRoot":"","sources":["../../src/stand/read-side-message.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;GAEG;AACH,UAAU,SAAS;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;;;;OAMG;SACE,KAAK,SAAS,KAAK,GAAG,KAAK;IAsBhC;;;;;;OAMG;WACI,KAAK,SAAS,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAc5C;;;;;OAKG;yBACkB,UAAU,CAAC,OAAO,CAAC,WAAW,OAAO,GAAG,IAAI;IAkBjE;;;;;OAKG;kBACW,MAAM,GAAG,MAAM;IAS7B;;;;;;OAMG;kBACW,MAAM,UAAU,MAAM,GAAG,SAAS;IAShD;;;;;;;;OAQG;sBAEM,SAAS,OACX,WAAW,QACV,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,UACrB,OAAO,CAAC,MAAM,CAAC,UACf,SAAS,EAAE,GAClB,IAAI;CA0BR,CAAC"}
@@ -0,0 +1,167 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ import { toBinary } from "@bufbuild/protobuf";
15
+ /**
16
+ * Detached Proto graph copies and shallow encodability checks.
17
+ */
18
+ export const ReadSideMessages = {
19
+ /**
20
+ * Copies a domain graph without recursion and rejects cyclic or executable values.
21
+ *
22
+ * @typeParam Value Input value type retained by the detached copy.
23
+ * @param value Source value to detach.
24
+ * @returns Mutable detached value.
25
+ */
26
+ copy(value) {
27
+ if (value === null || typeof value !== "object")
28
+ return value;
29
+ const root = ReadSideMessages.shell(value);
30
+ if (value instanceof Uint8Array)
31
+ return root;
32
+ const seen = new WeakMap([[value, root]]);
33
+ const active = new WeakSet([value]);
34
+ const frames = [ReadSideMessages.frame(value, root)];
35
+ while (frames.length > 0) {
36
+ const frame = frames.at(-1);
37
+ if (frame === undefined)
38
+ break;
39
+ if (frame.next === frame.keys.length) {
40
+ active.delete(frame.source);
41
+ frames.pop();
42
+ continue;
43
+ }
44
+ const key = frame.keys[frame.next++];
45
+ if (key === undefined)
46
+ throw new TypeError("Invalid read-side copy cursor.");
47
+ ReadSideMessages.copyMember(frame, key, seen, active, frames);
48
+ }
49
+ return root;
50
+ },
51
+ /**
52
+ * Returns a frozen detached parent snapshot without recursively walking its graph.
53
+ *
54
+ * @typeParam Value Detached snapshot type.
55
+ * @param value Detached parent value.
56
+ * @returns The same read-only snapshot.
57
+ */
58
+ freeze(value) {
59
+ const pending = [value];
60
+ const seen = new WeakSet();
61
+ while (pending.length > 0) {
62
+ const next = pending.pop();
63
+ if (next === null || typeof next !== "object" || seen.has(next))
64
+ continue;
65
+ seen.add(next);
66
+ if (next instanceof Uint8Array)
67
+ continue;
68
+ for (const key of Reflect.ownKeys(next))
69
+ pending.push(Reflect.get(next, key));
70
+ Object.freeze(next);
71
+ }
72
+ return value;
73
+ },
74
+ /**
75
+ * Encodes one message's own scalar content without recursively encoding children.
76
+ *
77
+ * @param schema Schema of the current message.
78
+ * @param message Message whose scalar fields must be encodable.
79
+ */
80
+ checkShallow(schema, message) {
81
+ if (message.$typeName !== schema.typeName)
82
+ throw new TypeError(`Read-side filter returned ${message.$typeName} for ${schema.typeName}.`);
83
+ const shallow = Object.assign(Object.create(null), message);
84
+ for (const field of schema.fields) {
85
+ if (field.fieldKind === "message" && field.oneof !== undefined) {
86
+ const selected = shallow[field.oneof.localName];
87
+ if (selected?.case === field.localName)
88
+ shallow[field.oneof.localName] = { case: undefined };
89
+ }
90
+ else if (field.fieldKind === "message")
91
+ shallow[field.localName] = undefined;
92
+ else if (field.fieldKind === "list" && field.listKind === "message")
93
+ shallow[field.localName] = [];
94
+ else if (field.fieldKind === "map" && field.mapKind === "message")
95
+ shallow[field.localName] = {};
96
+ }
97
+ toBinary(schema, shallow);
98
+ },
99
+ /**
100
+ * Creates a mutable shell for a Proto object, list, or binary field.
101
+ *
102
+ * @param source Value whose shape determines the shell.
103
+ * @returns Empty mutable copy target.
104
+ */
105
+ shell(source) {
106
+ if (source instanceof Uint8Array)
107
+ return new Uint8Array(source);
108
+ if (Array.isArray(source))
109
+ return new Array(source.length);
110
+ const prototype = Object.getPrototypeOf(source);
111
+ if (prototype !== Object.prototype && prototype !== null)
112
+ throw new TypeError("Read-side message contains an unsupported object value.");
113
+ return Object.create(prototype);
114
+ },
115
+ /**
116
+ * Creates an iterative copy cursor of a plain object or repeated field.
117
+ *
118
+ * @param source Value to inspect.
119
+ * @param target Detached target.
120
+ * @returns Mutable copy cursor.
121
+ */
122
+ frame(source, target) {
123
+ return {
124
+ source,
125
+ target,
126
+ keys: Reflect.ownKeys(source).filter((key) => key !== "length"),
127
+ next: 0,
128
+ };
129
+ },
130
+ /**
131
+ * Copies one data property and schedules its nested object when necessary.
132
+ *
133
+ * @param frame Current object pair.
134
+ * @param key Source property key.
135
+ * @param seen Previously copied values.
136
+ * @param active Values on the current ancestry path.
137
+ * @param frames Pending copy cursors.
138
+ */
139
+ copyMember(frame, key, seen, active, frames) {
140
+ const descriptor = Object.getOwnPropertyDescriptor(frame.source, key);
141
+ if (descriptor === undefined || !("value" in descriptor))
142
+ throw new TypeError("Read-side message contains an accessor property.");
143
+ const value = descriptor.value;
144
+ if (typeof value === "function" || typeof value === "symbol")
145
+ throw new TypeError("Read-side message contains an unserializable value.");
146
+ let copied = value;
147
+ if (value !== null && typeof value === "object") {
148
+ if (active.has(value))
149
+ throw new TypeError("Cyclic read-side message.");
150
+ copied = seen.get(value) ?? ReadSideMessages.shell(value);
151
+ if (!seen.has(value)) {
152
+ seen.set(value, copied);
153
+ if (!(value instanceof Uint8Array)) {
154
+ active.add(value);
155
+ frames.push(ReadSideMessages.frame(value, copied));
156
+ }
157
+ }
158
+ }
159
+ Object.defineProperty(frame.target, key, {
160
+ value: copied,
161
+ enumerable: descriptor.enumerable ?? false,
162
+ writable: true,
163
+ configurable: true,
164
+ });
165
+ },
166
+ };
167
+ //# sourceMappingURL=read-side-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-side-message.js","sourceRoot":"","sources":["../../src/stand/read-side-message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAa5D;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;;;;;;OAMG;IACH,IAAI,CAAQ,KAAY;QACtB,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC9D,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,KAAK,YAAY,UAAU;YAAE,OAAO,IAAa,CAAC;QACtD,MAAM,IAAI,GAAG,IAAI,OAAO,CAAiB,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,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event-engine/core";
3
+ import type { TenantId, Version } from "@spine-event-engine/proto";
4
+ import type { ReadSideContext } from "./read-side-filter.js";
5
+ import type { ReadSideFilterEngine } from "./read-side-filter-engine.js";
6
+ /**
7
+ * Preserves committed metadata and detached domain values before public filtering.
8
+ *
9
+ * @typeParam Schema The registered state schema.
10
+ */
11
+ export interface StandSourceUpdate<Schema extends MessageSchema = MessageSchema> {
12
+ /**
13
+ * Registered state type URL.
14
+ */
15
+ readonly typeUrl: string;
16
+ /**
17
+ * Typed Entity identifier from the committed update.
18
+ */
19
+ readonly id: unknown;
20
+ /**
21
+ * Committed current state before filtering.
22
+ */
23
+ readonly state: MessageShape<Schema>;
24
+ /**
25
+ * Committed prior state when the update replaced one.
26
+ */
27
+ readonly previousState?: MessageShape<Schema>;
28
+ /**
29
+ * Committed state version when supplied.
30
+ */
31
+ readonly version?: Version;
32
+ /**
33
+ * Tenant recorded with the committed state.
34
+ */
35
+ readonly tenantId?: TenantId;
36
+ }
37
+ /**
38
+ * Preserves original identity when a read policy removes the domain state.
39
+ */
40
+ export interface StandUpdateMetadata {
41
+ /**
42
+ * Registered state type URL.
43
+ */
44
+ readonly typeUrl: string;
45
+ /**
46
+ * Typed Entity identifier from the committed update.
47
+ */
48
+ readonly id: unknown;
49
+ /**
50
+ * Committed state version when supplied.
51
+ */
52
+ readonly version?: Version;
53
+ /**
54
+ * Tenant recorded with the committed state.
55
+ */
56
+ readonly tenantId?: TenantId;
57
+ }
58
+ /**
59
+ * Delivers a visible state or a removal after the producing Bounded Context's policies.
60
+ *
61
+ * @typeParam Schema The registered state schema.
62
+ */
63
+ export type StandUpdate<Schema extends MessageSchema = MessageSchema> = (StandUpdateMetadata & {
64
+ /**
65
+ * Indicates that the current state survived read policies.
66
+ */
67
+ readonly kind: "state";
68
+ /**
69
+ * Visible current state.
70
+ */
71
+ readonly state: MessageShape<Schema>;
72
+ /**
73
+ * Visible prior state when it survived independently.
74
+ */
75
+ readonly previousState?: MessageShape<Schema>;
76
+ }) | (StandUpdateMetadata & {
77
+ /**
78
+ * Indicates that read policies removed the current state.
79
+ */
80
+ readonly kind: "removal";
81
+ /**
82
+ * Marks a state no longer visible to this reader.
83
+ */
84
+ readonly noLongerMatching: true;
85
+ });
86
+ /**
87
+ * Receives serial filtered values and one terminal local delivery error.
88
+ *
89
+ * @typeParam Schema The registered state schema.
90
+ */
91
+ export interface StandObserver<Schema extends MessageSchema> {
92
+ /**
93
+ * Processes one visible state or removal before the next filter starts.
94
+ *
95
+ * @param update Visible state or removal with original committed metadata.
96
+ * @returns Completion of this delivery before the next update begins.
97
+ */
98
+ next(update: StandUpdate<Schema>): void | Promise<void>;
99
+ /**
100
+ * Notifies the observer of a terminal policy, callback, or waiting-capacity fault.
101
+ *
102
+ * @param error The local delivery fault that closed this observer.
103
+ * @returns Completion of local error notification, which cannot affect committed writes.
104
+ */
105
+ error(error: Error): void | Promise<void>;
106
+ }
107
+ /**
108
+ * Indicates that one direct subscriber exhausted its waiting-update capacity.
109
+ */
110
+ export declare class StandSubscriptionCapacityError extends Error {
111
+ /**
112
+ * Creates a local fault with the configured waiting capacity.
113
+ *
114
+ * @param limit Maximum number of waiting updates after the active update.
115
+ */
116
+ constructor(limit: number);
117
+ }
118
+ /**
119
+ * Serializes one direct observer independently of peer subscriptions.
120
+ *
121
+ * @typeParam Schema The registered state schema.
122
+ */
123
+ export declare class StandDirectDelivery<Schema extends MessageSchema> {
124
+ #private;
125
+ readonly schema: Schema;
126
+ readonly observer: StandObserver<Schema>;
127
+ readonly filters: ReadSideFilterEngine | undefined;
128
+ readonly facts: ReadSideContext;
129
+ readonly queueCapacity: number;
130
+ readonly onClose: () => void;
131
+ readonly externalSignal: AbortSignal | undefined;
132
+ /**
133
+ * Captures this subscription's policy and trusted invocation facts.
134
+ *
135
+ * @param schema Registered state schema.
136
+ * @param observer Local observer receiving visible values or one terminal fault.
137
+ * @param filters Producing Bounded Context read policies, if installed.
138
+ * @param facts Detached actor, tenant, and verified reader facts.
139
+ * @param queueCapacity Maximum waiting updates beyond the active update.
140
+ * @param onClose Removes this observer from its Stand registration.
141
+ * @param externalSignal Caller cancellation signal, if provided.
142
+ */
143
+ constructor(schema: Schema, observer: StandObserver<Schema>, filters: ReadSideFilterEngine | undefined, facts: ReadSideContext, queueCapacity: number, onClose: () => void, externalSignal: AbortSignal | undefined);
144
+ /**
145
+ * Returns whether this subscriber still accepts source updates.
146
+ *
147
+ * @returns True after cancellation, overflow, a policy fault, or close.
148
+ */
149
+ get closed(): boolean;
150
+ /**
151
+ * Admits one detached update without waiting for policy code.
152
+ *
153
+ * @param update Committed source update for this subscriber.
154
+ */
155
+ admit(update: StandSourceUpdate<Schema>): void;
156
+ /**
157
+ * Closes active work and clears queued snapshots without waiting on policy code.
158
+ */
159
+ readonly close: () => void;
160
+ }
161
+ //# sourceMappingURL=stand-direct-delivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stand-direct-delivery.d.ts","sourceRoot":"","sources":["../../src/stand/stand-direct-delivery.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa;IAC7E;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAErC;;OAEG;IACH,QAAQ,C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AC3C;AAED;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IACvD;;;;OAIG;gBACS,KAAK,EAAE,MAAM;CAI1B;AAED;;;;GAIG;AACH,qBAAa,mBAAmB,CAAC,MAAM,SAAS,aAAa;;IAqBzD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS;IAClD,QAAQ,CAAC,KAAK,EAAE,eAAe;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI;IAC5B,QAAQ,CAAC,cAAc,EAAE,WAAW,GAAG,SAAS;IAlBlD;;;;;;;;;;OAUG;gBAEQ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAC/B,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,KAAK,EAAE,eAAe,EACtB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,IAAI,EACnB,cAAc,EAAE,WAAW,GAAG,SAAS;IAMlD;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,IAAI;IAc9C;;OAEG;IACH,QAAQ,CAAC,KAAK,QAAO,IAAI,CAOvB;CA4GH"}
@@ -0,0 +1,210 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ /**
15
+ * Indicates that one direct subscriber exhausted its waiting-update capacity.
16
+ */
17
+ export class StandSubscriptionCapacityError extends Error {
18
+ /**
19
+ * Creates a local fault with the configured waiting capacity.
20
+ *
21
+ * @param limit Maximum number of waiting updates after the active update.
22
+ */
23
+ constructor(limit) {
24
+ super(`Stand subscription exceeded ${String(limit)} waiting updates.`);
25
+ this.name = "StandSubscriptionCapacityError";
26
+ }
27
+ }
28
+ /**
29
+ * Serializes one direct observer independently of peer subscriptions.
30
+ *
31
+ * @typeParam Schema The registered state schema.
32
+ */
33
+ export class StandDirectDelivery {
34
+ schema;
35
+ observer;
36
+ filters;
37
+ facts;
38
+ queueCapacity;
39
+ onClose;
40
+ externalSignal;
41
+ #pending = [];
42
+ #abort = new AbortController();
43
+ #active = false;
44
+ #closed = false;
45
+ /**
46
+ * Captures this subscription's policy and trusted invocation facts.
47
+ *
48
+ * @param schema Registered state schema.
49
+ * @param observer Local observer receiving visible values or one terminal fault.
50
+ * @param filters Producing Bounded Context read policies, if installed.
51
+ * @param facts Detached actor, tenant, and verified reader facts.
52
+ * @param queueCapacity Maximum waiting updates beyond the active update.
53
+ * @param onClose Removes this observer from its Stand registration.
54
+ * @param externalSignal Caller cancellation signal, if provided.
55
+ */
56
+ constructor(schema, observer, filters, facts, queueCapacity, onClose, externalSignal) {
57
+ this.schema = schema;
58
+ this.observer = observer;
59
+ this.filters = filters;
60
+ this.facts = facts;
61
+ this.queueCapacity = queueCapacity;
62
+ this.onClose = onClose;
63
+ this.externalSignal = externalSignal;
64
+ externalSignal?.addEventListener("abort", this.close, { once: true });
65
+ if (externalSignal?.aborted)
66
+ this.close();
67
+ }
68
+ /**
69
+ * Returns whether this subscriber still accepts source updates.
70
+ *
71
+ * @returns True after cancellation, overflow, a policy fault, or close.
72
+ */
73
+ get closed() {
74
+ return this.#closed;
75
+ }
76
+ /**
77
+ * Admits one detached update without waiting for policy code.
78
+ *
79
+ * @param update Committed source update for this subscriber.
80
+ */
81
+ admit(update) {
82
+ if (this.#closed)
83
+ return;
84
+ if (!this.#active) {
85
+ this.#active = true;
86
+ void this.#run(update);
87
+ return;
88
+ }
89
+ if (this.#pending.length >= this.queueCapacity) {
90
+ this.#fail(new StandSubscriptionCapacityError(this.queueCapacity));
91
+ return;
92
+ }
93
+ this.#pending.push(update);
94
+ }
95
+ /**
96
+ * Closes active work and clears queued snapshots without waiting on policy code.
97
+ */
98
+ close = () => {
99
+ if (this.#closed)
100
+ return;
101
+ this.#closed = true;
102
+ this.#pending.length = 0;
103
+ this.#abort.abort();
104
+ this.externalSignal?.removeEventListener("abort", this.close);
105
+ this.onClose();
106
+ };
107
+ /**
108
+ * Completes one filter and delivery before beginning the next.
109
+ *
110
+ * @param source Detached committed update selected for active processing.
111
+ */
112
+ async #run(source) {
113
+ try {
114
+ const update = this.filters === undefined
115
+ ? this.#visible(source)
116
+ : await this.#filtered(source, this.filters);
117
+ if (!this.#closed)
118
+ await this.observer.next(update);
119
+ }
120
+ catch (error) {
121
+ if (!this.#closed)
122
+ this.#fail(error instanceof Error ? error : new Error(String(error)));
123
+ }
124
+ finally {
125
+ this.#active = false;
126
+ const next = this.#pending.shift();
127
+ if (!this.#closed && next !== undefined) {
128
+ this.#active = true;
129
+ void this.#run(next);
130
+ }
131
+ }
132
+ }
133
+ /**
134
+ * Applies current and previous policies in source order, retaining original metadata.
135
+ *
136
+ * @param source Detached committed update.
137
+ * @param filters Installed read policy engine.
138
+ * @returns Visible state or removal with original metadata.
139
+ */
140
+ async #filtered(source, filters) {
141
+ const context = {
142
+ ...this.facts,
143
+ signal: this.#abort.signal,
144
+ };
145
+ const state = await filters.apply(this.schema, source.state, context);
146
+ if (this.#closed || state === null)
147
+ return this.#removal(source);
148
+ const previousState = source.previousState === undefined
149
+ ? undefined
150
+ : await filters.apply(this.schema, source.previousState, context);
151
+ return {
152
+ ...this.#metadata(source),
153
+ kind: "state",
154
+ state,
155
+ ...(previousState === undefined || previousState === null ? {} : { previousState }),
156
+ };
157
+ }
158
+ /**
159
+ * Passes a detached source value when the context installed no read policies.
160
+ *
161
+ * @param source Detached committed update.
162
+ * @returns State delivery without policy transformation.
163
+ */
164
+ #visible(source) {
165
+ return {
166
+ ...this.#metadata(source),
167
+ kind: "state",
168
+ state: source.state,
169
+ ...(source.previousState === undefined ? {} : { previousState: source.previousState }),
170
+ };
171
+ }
172
+ /**
173
+ * Keeps removal identity independent of edited domain values.
174
+ *
175
+ * @param source Detached committed update.
176
+ * @returns Removal with original identity and version.
177
+ */
178
+ #removal(source) {
179
+ return { ...this.#metadata(source), kind: "removal", noLongerMatching: true };
180
+ }
181
+ /**
182
+ * Selects original version and tenant fields from this committed notification.
183
+ *
184
+ * @param source Detached committed update.
185
+ * @returns Original metadata unaffected by policy mutations.
186
+ */
187
+ #metadata(source) {
188
+ return {
189
+ typeUrl: source.typeUrl,
190
+ id: source.id,
191
+ ...(source.version === undefined ? {} : { version: source.version }),
192
+ ...(source.tenantId === undefined ? {} : { tenantId: source.tenantId }),
193
+ };
194
+ }
195
+ /**
196
+ * Terminates only this subscriber and contains errors from the error observer.
197
+ *
198
+ * @param error Policy, callback, or waiting-capacity fault.
199
+ */
200
+ #fail(error) {
201
+ this.close();
202
+ try {
203
+ void Promise.resolve(this.observer.error(error)).catch(() => undefined);
204
+ }
205
+ catch {
206
+ /* A terminal observer cannot affect an already committed update. */
207
+ }
208
+ }
209
+ }
210
+ //# sourceMappingURL=stand-direct-delivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stand-direct-delivery.js","sourceRoot":"","sources":["../../src/stand/stand-direct-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA+HH;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD;;;;OAIG;IACH,YAAY,KAAa;QACvB,KAAK,CAAC,+BAA+B,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvE,IAAI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