@spine-event-engine/server 2.0.0-snapshot.25 → 2.0.0-snapshot.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -16
- package/REFERENCE.md +486 -57
- package/dist/agent/agent-history.d.ts +19 -3
- package/dist/agent/agent-history.d.ts.map +1 -1
- package/dist/agent/agent-history.js +41 -10
- package/dist/agent/agent-history.js.map +1 -1
- package/dist/agent/agent-live-ai-runtime.d.ts +1 -1
- package/dist/agent/agent-live-ai-runtime.js +1 -1
- package/dist/agent/agent-live-budget.d.ts +1 -1
- package/dist/agent/agent-live-budget.js +1 -1
- package/dist/agent/agent-live-read-runtime.d.ts +13 -2
- package/dist/agent/agent-live-read-runtime.d.ts.map +1 -1
- package/dist/agent/agent-live-read-runtime.js +6 -5
- package/dist/agent/agent-live-read-runtime.js.map +1 -1
- package/dist/browser/browser-admission.d.ts +47 -0
- package/dist/browser/browser-admission.d.ts.map +1 -0
- package/dist/browser/browser-admission.js +200 -0
- package/dist/browser/browser-admission.js.map +1 -0
- package/dist/browser/browser-server.d.ts +171 -1
- package/dist/browser/browser-server.d.ts.map +1 -1
- package/dist/browser/browser-server.js +1027 -303
- package/dist/browser/browser-server.js.map +1 -1
- package/dist/browser/durable-subscription-bindings.d.ts +5 -0
- package/dist/browser/durable-subscription-bindings.d.ts.map +1 -1
- package/dist/browser/durable-subscription-bindings.js +226 -38
- package/dist/browser/durable-subscription-bindings.js.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/options.d.ts +53 -2
- package/dist/browser/options.d.ts.map +1 -1
- package/dist/bus/command-bus.d.ts +9 -1
- package/dist/bus/command-bus.d.ts.map +1 -1
- package/dist/bus/command-bus.js +75 -10
- package/dist/bus/command-bus.js.map +1 -1
- package/dist/bus/command-errors.d.ts +20 -4
- package/dist/bus/command-errors.d.ts.map +1 -1
- package/dist/bus/command-errors.js +47 -7
- package/dist/bus/command-errors.js.map +1 -1
- package/dist/bus/event-bus.d.ts +9 -1
- package/dist/bus/event-bus.d.ts.map +1 -1
- package/dist/bus/event-bus.js +136 -9
- package/dist/bus/event-bus.js.map +1 -1
- package/dist/context/bounded-context.d.ts +59 -39
- package/dist/context/bounded-context.d.ts.map +1 -1
- package/dist/context/bounded-context.js +277 -262
- package/dist/context/bounded-context.js.map +1 -1
- package/dist/context/entity-inbox.d.ts +12 -17
- package/dist/context/entity-inbox.d.ts.map +1 -1
- package/dist/context/entity-inbox.js +106 -119
- package/dist/context/entity-inbox.js.map +1 -1
- package/dist/context/local-inbox-handoff.d.ts +13 -13
- package/dist/context/local-inbox-handoff.d.ts.map +1 -1
- package/dist/context/local-inbox-handoff.js +60 -32
- package/dist/context/local-inbox-handoff.js.map +1 -1
- package/dist/context/persistent-tenant-index.d.ts +81 -0
- package/dist/context/persistent-tenant-index.d.ts.map +1 -0
- package/dist/context/persistent-tenant-index.js +270 -0
- package/dist/context/persistent-tenant-index.js.map +1 -0
- package/dist/context/projection-handoff.d.ts +9 -9
- package/dist/context/projection-handoff.d.ts.map +1 -1
- package/dist/context/projection-handoff.js +31 -23
- package/dist/context/projection-handoff.js.map +1 -1
- package/dist/context/tenant-index.d.ts +7 -6
- package/dist/context/tenant-index.d.ts.map +1 -1
- package/dist/context/tenant-index.js +2 -188
- package/dist/context/tenant-index.js.map +1 -1
- package/dist/context/tenant-unknown-error.d.ts +2 -2
- package/dist/context/tenant-unknown-error.d.ts.map +1 -1
- package/dist/context/tenant-unknown-error.js +4 -1
- package/dist/context/tenant-unknown-error.js.map +1 -1
- package/dist/delivery/delivery-supervisor.d.ts.map +1 -1
- package/dist/delivery/delivery-supervisor.js +12 -3
- package/dist/delivery/delivery-supervisor.js.map +1 -1
- package/dist/delivery/delivery.d.ts +4 -3
- package/dist/delivery/delivery.d.ts.map +1 -1
- package/dist/delivery/delivery.js +82 -34
- package/dist/delivery/delivery.js.map +1 -1
- package/dist/delivery/reception-observation.d.ts +3 -3
- package/dist/delivery/reception-observation.js +2 -2
- package/dist/entity/entity.d.ts +59 -0
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +60 -0
- package/dist/entity/entity.js.map +1 -1
- package/dist/handler/app-query-handler.d.ts +60 -0
- package/dist/handler/app-query-handler.d.ts.map +1 -0
- package/dist/handler/app-query-handler.js +23 -0
- package/dist/handler/app-query-handler.js.map +1 -0
- package/dist/handler/generated-registry-discovery.d.ts +6 -0
- package/dist/handler/generated-registry-discovery.d.ts.map +1 -1
- package/dist/handler/generated-registry-discovery.js +71 -2
- package/dist/handler/generated-registry-discovery.js.map +1 -1
- package/dist/handler/handler-decorators.d.ts +8 -29
- package/dist/handler/handler-decorators.d.ts.map +1 -1
- package/dist/handler/handler-decorators.js +33 -210
- package/dist/handler/handler-decorators.js.map +1 -1
- package/dist/handler/spine-metadata-inventory.d.ts +99 -0
- package/dist/handler/spine-metadata-inventory.d.ts.map +1 -0
- package/dist/handler/spine-metadata-inventory.js +162 -0
- package/dist/handler/spine-metadata-inventory.js.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/repository/command-routing.d.ts +1 -1
- package/dist/repository/command-routing.js +1 -1
- package/dist/repository/event-routing.d.ts +1 -1
- package/dist/repository/event-routing.js +1 -1
- package/dist/repository/repository.d.ts +61 -26
- package/dist/repository/repository.d.ts.map +1 -1
- package/dist/repository/repository.js +612 -306
- package/dist/repository/repository.js.map +1 -1
- package/dist/repository/state-update-routing.d.ts +1 -1
- package/dist/repository/state-update-routing.js +1 -1
- package/dist/runtime/signal-publisher.d.ts +23 -8
- package/dist/runtime/signal-publisher.d.ts.map +1 -1
- package/dist/runtime/signal-publisher.js +11 -8
- package/dist/runtime/signal-publisher.js.map +1 -1
- package/dist/server/managed-server-application.d.ts +12 -11
- package/dist/server/managed-server-application.d.ts.map +1 -1
- package/dist/server/managed-server-application.js +41 -25
- package/dist/server/managed-server-application.js.map +1 -1
- package/dist/server/node-coordinator.d.ts +18 -5
- package/dist/server/node-coordinator.d.ts.map +1 -1
- package/dist/server/node-coordinator.js +744 -108
- package/dist/server/node-coordinator.js.map +1 -1
- package/dist/server/reserved-spine-rpc-paths.json +1 -0
- package/dist/server/server-environment.d.ts +23 -5
- package/dist/server/server-environment.d.ts.map +1 -1
- package/dist/server/server-environment.js +89 -24
- package/dist/server/server-environment.js.map +1 -1
- package/dist/server/server.d.ts +45 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +112 -3
- package/dist/server/server.js.map +1 -1
- package/dist/services/app-query-execution.d.ts +53 -0
- package/dist/services/app-query-execution.d.ts.map +1 -0
- package/dist/services/app-query-execution.js +408 -0
- package/dist/services/app-query-execution.js.map +1 -0
- package/dist/services/native-operation.d.ts +34 -0
- package/dist/services/native-operation.d.ts.map +1 -0
- package/dist/services/native-operation.js +77 -0
- package/dist/services/native-operation.js.map +1 -0
- package/dist/services/query-reader.d.ts +32 -7
- package/dist/services/query-reader.d.ts.map +1 -1
- package/dist/services/query-reader.js +22 -2
- package/dist/services/query-reader.js.map +1 -1
- package/dist/services/read-request-status.d.ts +65 -0
- package/dist/services/read-request-status.d.ts.map +1 -0
- package/dist/services/read-request-status.js +151 -0
- package/dist/services/read-request-status.js.map +1 -0
- package/dist/services/spine-services.d.ts +42 -7
- package/dist/services/spine-services.d.ts.map +1 -1
- package/dist/services/spine-services.js +1005 -175
- package/dist/services/spine-services.js.map +1 -1
- package/dist/services/trusted-reader-ingress.d.ts +110 -0
- package/dist/services/trusted-reader-ingress.d.ts.map +1 -0
- package/dist/services/trusted-reader-ingress.js +102 -0
- package/dist/services/trusted-reader-ingress.js.map +1 -0
- package/dist/spi/handler-registry.d.ts +2 -0
- package/dist/spi/handler-registry.d.ts.map +1 -1
- package/dist/spi/handler-registry.js +1 -1
- package/dist/spi/handler-registry.js.map +1 -1
- package/dist/stand/read-side-filter-engine.d.ts +46 -0
- package/dist/stand/read-side-filter-engine.d.ts.map +1 -0
- package/dist/stand/read-side-filter-engine.js +356 -0
- package/dist/stand/read-side-filter-engine.js.map +1 -0
- package/dist/stand/read-side-filter.d.ts +247 -0
- package/dist/stand/read-side-filter.d.ts.map +1 -0
- package/dist/stand/read-side-filter.js +39 -0
- package/dist/stand/read-side-filter.js.map +1 -0
- package/dist/stand/read-side-message.d.ts +66 -0
- package/dist/stand/read-side-message.d.ts.map +1 -0
- package/dist/stand/read-side-message.js +167 -0
- package/dist/stand/read-side-message.js.map +1 -0
- package/dist/stand/stand-direct-delivery.d.ts +161 -0
- package/dist/stand/stand-direct-delivery.d.ts.map +1 -0
- package/dist/stand/stand-direct-delivery.js +210 -0
- package/dist/stand/stand-direct-delivery.js.map +1 -0
- package/dist/stand/stand.d.ts +81 -43
- package/dist/stand/stand.d.ts.map +1 -1
- package/dist/stand/stand.js +411 -55
- package/dist/stand/stand.js.map +1 -1
- package/dist/stand/subscription-observer.d.ts.map +1 -1
- package/dist/stand/subscription-observer.js +103 -0
- package/dist/stand/subscription-observer.js.map +1 -1
- package/dist/stand/subscription-read-filters.d.ts +40 -0
- package/dist/stand/subscription-read-filters.d.ts.map +1 -0
- package/dist/stand/subscription-read-filters.js +91 -0
- package/dist/stand/subscription-read-filters.js.map +1 -0
- package/dist/stand/subscription-reader-binding.d.ts +20 -0
- package/dist/stand/subscription-reader-binding.d.ts.map +1 -0
- package/dist/stand/subscription-reader-binding.js +56 -0
- package/dist/stand/subscription-reader-binding.js.map +1 -0
- package/dist/stand/subscription-records.d.ts +30 -3
- package/dist/stand/subscription-records.d.ts.map +1 -1
- package/dist/stand/subscription-records.js +61 -16
- package/dist/stand/subscription-records.js.map +1 -1
- package/dist/stand/subscription-registry.d.ts +49 -14
- package/dist/stand/subscription-registry.d.ts.map +1 -1
- package/dist/stand/subscription-registry.js +150 -31
- package/dist/stand/subscription-registry.js.map +1 -1
- package/dist/stand/subscription-runtime.d.ts +7 -2
- package/dist/stand/subscription-runtime.d.ts.map +1 -1
- package/dist/stand/subscription-runtime.js +131 -25
- package/dist/stand/subscription-runtime.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -14
|
@@ -0,0 +1,91 @@
|
|
|
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 { clone } from "@bufbuild/protobuf";
|
|
15
|
+
import { SubscriptionUpdateSchema, } from "@spine-event-engine/proto/client";
|
|
16
|
+
/**
|
|
17
|
+
* Applies one read-policy scope to data in an already matched subscription update.
|
|
18
|
+
*/
|
|
19
|
+
class SubscriptionReadFilterScope {
|
|
20
|
+
/**
|
|
21
|
+
* Processes only domain data, retaining acknowledgements and existing removals.
|
|
22
|
+
*
|
|
23
|
+
* @param update Matched source update with original identity and envelope fields.
|
|
24
|
+
* @param filters Installed BC or Server read-policy scope.
|
|
25
|
+
* @param facts Actual subscription operation and trusted activation facts.
|
|
26
|
+
* @returns Detached surviving data or control, or null for an empty data batch.
|
|
27
|
+
*/
|
|
28
|
+
async apply(update, filters, facts) {
|
|
29
|
+
const visible = clone(SubscriptionUpdateSchema, update);
|
|
30
|
+
if (filters === undefined)
|
|
31
|
+
return visible;
|
|
32
|
+
if (visible.update.case === "entityUpdates")
|
|
33
|
+
return this.#states(visible, filters, facts);
|
|
34
|
+
if (visible.update.case === "eventUpdates")
|
|
35
|
+
return this.#events(visible, filters, facts);
|
|
36
|
+
return visible;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Replaces Entity states or emits removal using their original packed IDs.
|
|
40
|
+
*
|
|
41
|
+
* @param update Detached Entity data batch.
|
|
42
|
+
* @param filters Scope selected for this delivery boundary.
|
|
43
|
+
* @param facts Current reader and Topic facts.
|
|
44
|
+
* @returns Entity update with filtered states or removal controls.
|
|
45
|
+
*/
|
|
46
|
+
async #states(update, filters, facts) {
|
|
47
|
+
if (update.update.case !== "entityUpdates")
|
|
48
|
+
return update;
|
|
49
|
+
for (const item of update.update.value.update) {
|
|
50
|
+
if (item.kind.case !== "state")
|
|
51
|
+
continue;
|
|
52
|
+
const state = await filters.applyPacked(item.kind.value, facts);
|
|
53
|
+
item.kind =
|
|
54
|
+
state === null
|
|
55
|
+
? { case: "noLongerMatching", value: true }
|
|
56
|
+
: { case: "state", value: state };
|
|
57
|
+
}
|
|
58
|
+
return update;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Replaces visible domain payloads inside their original Event envelopes.
|
|
62
|
+
*
|
|
63
|
+
* @param update Detached Event data batch.
|
|
64
|
+
* @param filters Scope selected for this delivery boundary.
|
|
65
|
+
* @param facts Current reader and Topic facts.
|
|
66
|
+
* @returns Event update or null when every Event was removed.
|
|
67
|
+
*/
|
|
68
|
+
async #events(update, filters, facts) {
|
|
69
|
+
if (update.update.case !== "eventUpdates")
|
|
70
|
+
return update;
|
|
71
|
+
const surviving = [];
|
|
72
|
+
for (const event of update.update.value.event) {
|
|
73
|
+
if (event.message === undefined)
|
|
74
|
+
throw new TypeError("Subscription Event payload is missing.");
|
|
75
|
+
const payload = await filters.applyPacked(event.message, facts);
|
|
76
|
+
if (payload !== null) {
|
|
77
|
+
event.message = payload;
|
|
78
|
+
surviving.push(event);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (surviving.length === 0)
|
|
82
|
+
return null;
|
|
83
|
+
update.update.value.event = surviving;
|
|
84
|
+
return update;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Reuses one policy traversal without exposing an additional constructor.
|
|
89
|
+
*/
|
|
90
|
+
export const SubscriptionReadFilters = new SubscriptionReadFilterScope();
|
|
91
|
+
//# sourceMappingURL=subscription-read-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-read-filters.js","sourceRoot":"","sources":["../../src/stand/subscription-read-filters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,wBAAwB,GAEzB,MAAM,kCAAkC,CAAC;AAsB1C;;GAEG;AACH,MAAM,2BAA2B;IAC/B;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,CACT,MAA0B,EAC1B,OAAyC,EACzC,KAAsB;QAEtB,MAAM,OAAO,GAAG,KAAK,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC;QAC1C,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,eAAe;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1F,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACzF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CACX,MAA0B,EAC1B,OAA6B,EAC7B,KAAsB;QAEtB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,eAAe;YAAE,OAAO,MAAM,CAAC;QAC1D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,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;IAChB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,IAAI,2BAA2B,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReaderIdentity } from "@spine-event-engine/core/spi/trusted-reader";
|
|
2
|
+
import { type SubscriptionReaderBinding } from "@spine-event-engine/proto/client";
|
|
3
|
+
/**
|
|
4
|
+
* Converts stable verified reader IDs to the maintained subscription record field.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SubscriptionReaderBindings: Readonly<{
|
|
7
|
+
/**
|
|
8
|
+
* Decodes a persisted binding without treating an absent legacy field as anonymous.
|
|
9
|
+
*
|
|
10
|
+
* @param binding Stored reader field, or undefined for a legacy record.
|
|
11
|
+
* @returns Stable reader identity, or undefined when no binding was stored.
|
|
12
|
+
*/ read(binding: SubscriptionReaderBinding | undefined): ReaderIdentity | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Encodes the stable reader identity in the maintained record field.
|
|
15
|
+
*
|
|
16
|
+
* @param reader Verified reader identity, or undefined for a legacy record.
|
|
17
|
+
* @returns Binding field when a stable identity is present.
|
|
18
|
+
*/ write(reader: ReaderIdentity | undefined): SubscriptionReaderBinding | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=subscription-reader-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-reader-binding.d.ts","sourceRoot":"","sources":["../../src/stand/subscription-reader-binding.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC;IAChD;;;;;OAKG,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAyB,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC;IAErF;;;;;OAKG,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,yBAAyB,GAAG,SAAS,CAAC;CACtF,CAgCC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { create } from "@bufbuild/protobuf";
|
|
15
|
+
import { EmptySchema } from "@bufbuild/protobuf/wkt";
|
|
16
|
+
import { SubscriptionReaderBindingSchema, } from "@spine-event-engine/proto/client";
|
|
17
|
+
/**
|
|
18
|
+
* Converts stable verified reader IDs to the maintained subscription record field.
|
|
19
|
+
*/
|
|
20
|
+
export const SubscriptionReaderBindings = Object.freeze({
|
|
21
|
+
/**
|
|
22
|
+
* Reads one bound identity while leaving older records explicitly unbound.
|
|
23
|
+
*
|
|
24
|
+
* @param binding Stored reader field, possibly absent on a legacy record.
|
|
25
|
+
* @returns Stable identity or undefined only when the field is absent.
|
|
26
|
+
*/
|
|
27
|
+
read(binding) {
|
|
28
|
+
if (binding === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (binding.identity.case === "principalId" && binding.identity.value.trim())
|
|
31
|
+
return Object.freeze({ kind: "principal", id: binding.identity.value });
|
|
32
|
+
if (binding.identity.case === "anonymous")
|
|
33
|
+
return Object.freeze({ kind: "anonymous" });
|
|
34
|
+
throw new Error("Subscription reader binding is invalid.");
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Writes one stable identity without storing authority facts or credentials.
|
|
38
|
+
*
|
|
39
|
+
* @param reader Verified reader identity, or undefined for an old unbound record.
|
|
40
|
+
* @returns Maintained Proto binding field when present.
|
|
41
|
+
*/
|
|
42
|
+
write(reader) {
|
|
43
|
+
if (reader === undefined)
|
|
44
|
+
return undefined;
|
|
45
|
+
if (reader.kind === "anonymous")
|
|
46
|
+
return create(SubscriptionReaderBindingSchema, {
|
|
47
|
+
identity: { case: "anonymous", value: create(EmptySchema) },
|
|
48
|
+
});
|
|
49
|
+
if (!reader.id.trim())
|
|
50
|
+
throw new Error("Subscription reader principal ID is invalid.");
|
|
51
|
+
return create(SubscriptionReaderBindingSchema, {
|
|
52
|
+
identity: { case: "principalId", value: reader.id },
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=subscription-reader-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-reader-binding.js","sourceRoot":"","sources":["../../src/stand/subscription-reader-binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EACL,+BAA+B,GAEhC,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAclC,MAAM,CAAC,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,OAA8C;QACjD,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC5C,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,aAAa,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE;YAC1E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1E,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACvF,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAkC;QACtC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW;YAC7B,OAAO,MAAM,CAAC,+BAA+B,EAAE;gBAC7C,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE;aAC5D,CAAC,CAAC;QACL,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACvF,OAAO,MAAM,CAAC,+BAA+B,EAAE;YAC7C,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE;SACpD,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import { SubscriptionRecordSchema, type SubscriptionRecord } from "@spine-event-engine/proto/client";
|
|
2
2
|
import type { StandSubscriptionEntry } from "./subscription-registry.js";
|
|
3
|
+
import type { ReaderIdentity } from "@spine-event-engine/core/spi/trusted-reader";
|
|
3
4
|
/**
|
|
4
5
|
* Encodes and validates the approved durable subscription record.
|
|
5
6
|
*/
|
|
6
7
|
export declare const StandSubscriptionRecords: {
|
|
7
8
|
readonly schema: typeof SubscriptionRecordSchema;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Validates and decodes a retained Stand subscription record.
|
|
11
|
+
*
|
|
12
|
+
* @param record The durable subscription record.
|
|
13
|
+
* @param expectedId Expected canonical subscription ID.
|
|
14
|
+
* @returns The detached subscription entry with its stable reader binding.
|
|
15
|
+
*/ read(record: SubscriptionRecord, expectedId?: string): StandSubscriptionEntry;
|
|
16
|
+
/**
|
|
17
|
+
* Encodes a validated reader-bound entry as the maintained Proto record.
|
|
18
|
+
*
|
|
19
|
+
* @param entry Retained subscription entry.
|
|
20
|
+
* @returns The serialized record ready for storage.
|
|
21
|
+
*/ write(entry: StandSubscriptionEntry): SubscriptionRecord;
|
|
22
|
+
/**
|
|
23
|
+
* Decodes a bounded wire record and validates its stored subscription fields.
|
|
24
|
+
*
|
|
25
|
+
* @param bytes The serialized message bytes.
|
|
26
|
+
* @param expectedId Expected canonical subscription ID.
|
|
27
|
+
* @returns The validated detached subscription entry.
|
|
28
|
+
*/ decode(bytes: Uint8Array, expectedId?: string): StandSubscriptionEntry;
|
|
29
|
+
/**
|
|
30
|
+
* Validates the pending phase and its activation expiry.
|
|
31
|
+
*
|
|
32
|
+
* @param record The durable subscription record.
|
|
33
|
+
* @param subscription The subscription definition being processed.
|
|
34
|
+
* @param createdAt The record creation time in milliseconds.
|
|
35
|
+
* @param reader The verified reader facts for this operation.
|
|
36
|
+
* @returns The pending subscription entry.
|
|
37
|
+
*/ pending(record: SubscriptionRecord, subscription: SubscriptionRecord["subscription"], createdAt: number, reader: ReaderIdentity | undefined): StandSubscriptionEntry;
|
|
11
38
|
};
|
|
12
39
|
//# sourceMappingURL=subscription-records.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-records.d.ts","sourceRoot":"","sources":["../../src/stand/subscription-records.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,wBAAwB,EAIxB,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription-records.d.ts","sourceRoot":"","sources":["../../src/stand/subscription-records.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,wBAAwB,EAIxB,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAIlF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,wBAAwB,CAAC;IAEjD;;;;;;OAMG,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;IAElF;;;;;OAKG,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAsB,GAAG,kBAAkB,CAAC;IAE7D;;;;;;OAMG,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;IAE3E;;;;;;;;OAQG,CAAC,OAAO,CACT,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,kBAAkB,CAAC,cAAc,CAAC,EAChD,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,sBAAsB,CAAC;CAyG1B,CAAC"}
|
|
@@ -13,13 +13,20 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { clone, create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
15
15
|
import { SubscriptionRecordSchema, SubscriptionIdSchema, SubscriptionSchema, SubscriptionStatus, } from "@spine-event-engine/proto/client";
|
|
16
|
+
import { SubscriptionReaderBindings } from "./subscription-reader-binding.js";
|
|
16
17
|
const maximumBytes = 1_048_576;
|
|
17
18
|
/**
|
|
18
19
|
* Encodes and validates the approved durable subscription record.
|
|
19
20
|
*/
|
|
20
21
|
export const StandSubscriptionRecords = Object.freeze({
|
|
21
22
|
schema: SubscriptionRecordSchema,
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Validates and decodes a retained Stand subscription record.
|
|
25
|
+
*
|
|
26
|
+
* @param record The durable subscription record.
|
|
27
|
+
* @param expectedId Expected canonical subscription ID.
|
|
28
|
+
* @returns The detached subscription entry with its stable reader binding.
|
|
29
|
+
*/ read(record, expectedId) {
|
|
23
30
|
try {
|
|
24
31
|
const id = record.id?.value;
|
|
25
32
|
const subscription = record.subscription;
|
|
@@ -31,30 +38,49 @@ export const StandSubscriptionRecords = Object.freeze({
|
|
|
31
38
|
subscription.topic.id.value.trim() === "")
|
|
32
39
|
throw Error();
|
|
33
40
|
const createdAt = milliseconds(record.whenCreated);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw Error();
|
|
38
|
-
return Object.freeze({
|
|
39
|
-
subscription: clone(SubscriptionSchema, subscription),
|
|
40
|
-
phase: "pending",
|
|
41
|
-
createdAt,
|
|
42
|
-
pendingUntil,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
41
|
+
const reader = SubscriptionReaderBindings.read(record.reader);
|
|
42
|
+
if (record.status === SubscriptionStatus.PENDING)
|
|
43
|
+
return this.pending(record, subscription, createdAt, reader);
|
|
45
44
|
if (record.status !== SubscriptionStatus.ACTIVE || record.whenActivationExpires !== undefined)
|
|
46
45
|
throw Error();
|
|
47
46
|
return Object.freeze({
|
|
48
47
|
subscription: clone(SubscriptionSchema, subscription),
|
|
49
48
|
phase: "active",
|
|
50
49
|
createdAt,
|
|
50
|
+
...(reader === undefined ? {} : { reader }),
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
catch {
|
|
54
54
|
throw new Error("Stand subscription record is invalid.");
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Reads a pending row only when its activation deadline follows creation.
|
|
59
|
+
*
|
|
60
|
+
* @param record The durable subscription record.
|
|
61
|
+
* @param subscription The subscription definition being processed.
|
|
62
|
+
* @param createdAt The record creation time in milliseconds.
|
|
63
|
+
* @param reader The verified reader facts for this operation.
|
|
64
|
+
* @returns The pending subscription entry.
|
|
65
|
+
*/
|
|
66
|
+
pending(record, subscription, createdAt, reader) {
|
|
67
|
+
const pendingUntil = milliseconds(record.whenActivationExpires);
|
|
68
|
+
if (pendingUntil < createdAt || subscription === undefined)
|
|
69
|
+
throw Error();
|
|
70
|
+
return Object.freeze({
|
|
71
|
+
subscription: clone(SubscriptionSchema, subscription),
|
|
72
|
+
phase: "pending",
|
|
73
|
+
createdAt,
|
|
74
|
+
pendingUntil,
|
|
75
|
+
...(reader === undefined ? {} : { reader }),
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* Encodes a validated reader-bound entry as the maintained Proto record.
|
|
80
|
+
*
|
|
81
|
+
* @param entry Retained subscription entry.
|
|
82
|
+
* @returns The serialized record ready for storage.
|
|
83
|
+
*/ write(entry) {
|
|
58
84
|
const id = entry.subscription.id;
|
|
59
85
|
if (id === undefined)
|
|
60
86
|
throw new TypeError("Stand subscription ID must be non-blank.");
|
|
@@ -63,6 +89,9 @@ export const StandSubscriptionRecords = Object.freeze({
|
|
|
63
89
|
subscription: clone(SubscriptionSchema, entry.subscription),
|
|
64
90
|
status: entry.phase === "pending" ? SubscriptionStatus.PENDING : SubscriptionStatus.ACTIVE,
|
|
65
91
|
whenCreated: timestamp(entry.createdAt),
|
|
92
|
+
...(entry.reader === undefined
|
|
93
|
+
? {}
|
|
94
|
+
: { reader: SubscriptionReaderBindings.write(entry.reader) }),
|
|
66
95
|
...(entry.phase === "pending"
|
|
67
96
|
? { whenActivationExpires: timestamp(entry.pendingUntil) }
|
|
68
97
|
: {}),
|
|
@@ -72,7 +101,13 @@ export const StandSubscriptionRecords = Object.freeze({
|
|
|
72
101
|
throw new RangeError("Stand subscription record exceeds 1048576 bytes.");
|
|
73
102
|
return record;
|
|
74
103
|
},
|
|
75
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Decodes a bounded wire record and validates its stored subscription fields.
|
|
106
|
+
*
|
|
107
|
+
* @param bytes The serialized message bytes.
|
|
108
|
+
* @param expectedId Expected canonical subscription ID.
|
|
109
|
+
* @returns The validated detached subscription entry.
|
|
110
|
+
*/ decode(bytes, expectedId) {
|
|
76
111
|
if (bytes.byteLength > maximumBytes)
|
|
77
112
|
throw new Error("Malformed Stand subscription record.");
|
|
78
113
|
try {
|
|
@@ -83,7 +118,12 @@ export const StandSubscriptionRecords = Object.freeze({
|
|
|
83
118
|
}
|
|
84
119
|
},
|
|
85
120
|
});
|
|
86
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Converts a Proto timestamp to epoch milliseconds.
|
|
123
|
+
*
|
|
124
|
+
* @param value Stored Proto timestamp, if present.
|
|
125
|
+
* @returns The timestamp in milliseconds.
|
|
126
|
+
*/ function milliseconds(value) {
|
|
87
127
|
if (value === undefined || value.seconds < 0n || value.nanos < 0 || value.nanos >= 1_000_000_000)
|
|
88
128
|
throw Error();
|
|
89
129
|
const result = Number(value.seconds) * 1000 + Math.floor(value.nanos / 1_000_000);
|
|
@@ -91,7 +131,12 @@ function milliseconds(value) {
|
|
|
91
131
|
throw Error();
|
|
92
132
|
return result;
|
|
93
133
|
}
|
|
94
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Creates a Proto timestamp from epoch milliseconds.
|
|
136
|
+
*
|
|
137
|
+
* @param value Validated epoch milliseconds.
|
|
138
|
+
* @returns The Proto timestamp.
|
|
139
|
+
*/ function timestamp(value) {
|
|
95
140
|
if (!Number.isSafeInteger(value) || value < 0)
|
|
96
141
|
throw new RangeError("Stand subscription time is invalid.");
|
|
97
142
|
return { seconds: BigInt(Math.floor(value / 1000)), nanos: (value % 1000) * 1_000_000 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-records.js","sourceRoot":"","sources":["../../src/stand/subscription-records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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AAE,CAAC;AAC1F,CAAC"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { type ReaderIdentity } from "@spine-event-engine/core/spi/trusted-reader";
|
|
1
2
|
import { type Subscription, type SubscriptionId, type SubscriptionRecord } from "@spine-event-engine/proto/client";
|
|
2
|
-
import { RecordSpec, type StorageContext, type StorageFactory } from "@spine-event-engine/storage";
|
|
3
|
+
import { RecordSpec, StorageGroup, type StorageContext, type StorageFactory } from "@spine-event-engine/storage";
|
|
4
|
+
import { type StoragePreparationMode } from "@spine-event-engine/storage/provider";
|
|
5
|
+
/**
|
|
6
|
+
* Maps a logical Bounded Context name to one provider-safe durable record family.
|
|
7
|
+
*
|
|
8
|
+
* @param contextName Logical Bounded Context name.
|
|
9
|
+
* @returns A stable physical StorageGroup.
|
|
10
|
+
*/
|
|
11
|
+
export declare const subscriptionRecordGroup: (contextName: string) => StorageGroup;
|
|
3
12
|
/**
|
|
4
13
|
* Exact durable subscription layout shared by the registry and preparation.
|
|
5
14
|
*/
|
|
@@ -12,6 +21,10 @@ interface StandSubscriptionEntryBase {
|
|
|
12
21
|
* Provides the subscription definition.
|
|
13
22
|
*/
|
|
14
23
|
readonly subscription: Subscription;
|
|
24
|
+
/**
|
|
25
|
+
* Stable verified reader binding, absent only in legacy records.
|
|
26
|
+
*/
|
|
27
|
+
readonly reader?: ReaderIdentity;
|
|
15
28
|
/**
|
|
16
29
|
* Records when the definition was created, in milliseconds since Unix epoch.
|
|
17
30
|
*/
|
|
@@ -77,11 +90,16 @@ export type StandActivateResult = Readonly<{
|
|
|
77
90
|
* Identifies an absent or expired definition.
|
|
78
91
|
*/
|
|
79
92
|
kind: "missing" | "expired";
|
|
93
|
+
}> | Readonly<{
|
|
94
|
+
/**
|
|
95
|
+
* The current record is bound to a different or unverifiable reader.
|
|
96
|
+
*/
|
|
97
|
+
kind: "denied";
|
|
80
98
|
}>;
|
|
81
99
|
/**
|
|
82
100
|
* Identifies the outcome of deleting a durable subscription definition.
|
|
83
101
|
*/
|
|
84
|
-
export type StandDeleteResult = "deleted" | "missing";
|
|
102
|
+
export type StandDeleteResult = "deleted" | "missing" | "denied";
|
|
85
103
|
/**
|
|
86
104
|
* Describes one finite cleanup pass.
|
|
87
105
|
*/
|
|
@@ -124,22 +142,25 @@ export interface StandSubscriptionRegistry {
|
|
|
124
142
|
*
|
|
125
143
|
* @param subscription Provides the definition to create.
|
|
126
144
|
* @returns Resolves to the creation outcome.
|
|
145
|
+
* @param reader The verified reader facts for this operation.
|
|
127
146
|
*/
|
|
128
|
-
create(subscription: Subscription): Promise<StandCreateResult>;
|
|
147
|
+
create(subscription: Subscription, reader?: ReaderIdentity): Promise<StandCreateResult>;
|
|
129
148
|
/**
|
|
130
149
|
* Activates the definition identified by an explicit subscription ID.
|
|
131
150
|
*
|
|
132
151
|
* @param id Identifies the definition to activate.
|
|
133
152
|
* @returns Resolves to the activation outcome.
|
|
153
|
+
* @param reader The verified reader facts for this operation.
|
|
134
154
|
*/
|
|
135
|
-
activate(id: SubscriptionId): Promise<StandActivateResult>;
|
|
155
|
+
activate(id: SubscriptionId, reader?: ReaderIdentity): Promise<StandActivateResult>;
|
|
136
156
|
/**
|
|
137
157
|
* Deletes the definition identified by an explicit subscription ID.
|
|
138
158
|
*
|
|
139
159
|
* @param id Identifies the definition to delete.
|
|
140
160
|
* @returns Resolves to the deletion outcome.
|
|
161
|
+
* @param reader The verified reader facts for this operation.
|
|
141
162
|
*/
|
|
142
|
-
delete(id: SubscriptionId): Promise<StandDeleteResult>;
|
|
163
|
+
delete(id: SubscriptionId, reader?: ReaderIdentity): Promise<StandDeleteResult>;
|
|
143
164
|
/**
|
|
144
165
|
* Gets an isolated current definition, when it exists.
|
|
145
166
|
*
|
|
@@ -180,22 +201,25 @@ export declare class InMemorySubscriptionRegistry implements StandSubscriptionRe
|
|
|
180
201
|
*
|
|
181
202
|
* @param subscription Provides the definition to create.
|
|
182
203
|
* @returns Resolves to the creation outcome.
|
|
204
|
+
* @param reader The verified reader facts for this operation.
|
|
183
205
|
*/
|
|
184
|
-
create(subscription: Subscription): Promise<StandCreateResult>;
|
|
206
|
+
create(subscription: Subscription, reader?: ReaderIdentity): Promise<StandCreateResult>;
|
|
185
207
|
/**
|
|
186
208
|
* Activates an unexpired in-memory pending definition.
|
|
187
209
|
*
|
|
188
210
|
* @param value Identifies the definition to activate.
|
|
189
211
|
* @returns Resolves to the activation outcome.
|
|
212
|
+
* @param reader The verified reader facts for this operation.
|
|
190
213
|
*/
|
|
191
|
-
activate(value: SubscriptionId): Promise<StandActivateResult>;
|
|
214
|
+
activate(value: SubscriptionId, reader?: ReaderIdentity): Promise<StandActivateResult>;
|
|
192
215
|
/**
|
|
193
216
|
* Deletes an in-memory definition, when present.
|
|
194
217
|
*
|
|
195
218
|
* @param value Identifies the definition to delete.
|
|
196
219
|
* @returns Resolves to the deletion outcome.
|
|
220
|
+
* @param reader The verified reader facts for this operation.
|
|
197
221
|
*/
|
|
198
|
-
delete(value: SubscriptionId): Promise<StandDeleteResult>;
|
|
222
|
+
delete(value: SubscriptionId, reader?: ReaderIdentity): Promise<StandDeleteResult>;
|
|
199
223
|
/**
|
|
200
224
|
* Gets an isolated in-memory definition, when present.
|
|
201
225
|
*
|
|
@@ -228,37 +252,48 @@ export declare class InMemorySubscriptionRegistry implements StandSubscriptionRe
|
|
|
228
252
|
export declare class StorageSubscriptionRegistry implements StandSubscriptionRegistry {
|
|
229
253
|
#private;
|
|
230
254
|
/**
|
|
231
|
-
* Indicates that the backing storage
|
|
255
|
+
* Indicates that the backing storage retains durable definitions.
|
|
232
256
|
*/
|
|
233
257
|
readonly persistent = true;
|
|
234
258
|
/**
|
|
235
259
|
* Creates a registry backed by one compare-and-set-capable record handle.
|
|
236
260
|
*
|
|
237
|
-
* @param context Identifies the storage
|
|
261
|
+
* @param context Identifies the storage context.
|
|
238
262
|
* @param storageFactory Creates the registry record handle.
|
|
263
|
+
* @param storageGroup Selects the physical subscription record family.
|
|
264
|
+
*/
|
|
265
|
+
constructor(context: StorageContext, storageFactory: StorageFactory, storageGroup: StorageGroup);
|
|
266
|
+
/**
|
|
267
|
+
* Prepares this registry's captured factory, context, and physical group.
|
|
268
|
+
*
|
|
269
|
+
* @param mode Required preparation mode.
|
|
270
|
+
* @returns Completion of storage preparation.
|
|
239
271
|
*/
|
|
240
|
-
|
|
272
|
+
prepare(mode: StoragePreparationMode): Promise<void>;
|
|
241
273
|
/**
|
|
242
274
|
* Creates a pending durable definition or finds its identical predecessor.
|
|
243
275
|
*
|
|
244
276
|
* @param subscription Provides the definition to create.
|
|
245
277
|
* @returns Resolves to the creation outcome.
|
|
278
|
+
* @param reader The verified reader facts for this operation.
|
|
246
279
|
*/
|
|
247
|
-
create(subscription: Subscription): Promise<StandCreateResult>;
|
|
280
|
+
create(subscription: Subscription, reader?: ReaderIdentity): Promise<StandCreateResult>;
|
|
248
281
|
/**
|
|
249
282
|
* Activates an unexpired durable pending definition.
|
|
250
283
|
*
|
|
251
284
|
* @param value Identifies the definition to activate.
|
|
252
285
|
* @returns Resolves to the activation outcome.
|
|
286
|
+
* @param reader The verified reader facts for this operation.
|
|
253
287
|
*/
|
|
254
|
-
activate(value: SubscriptionId): Promise<StandActivateResult>;
|
|
288
|
+
activate(value: SubscriptionId, reader?: ReaderIdentity): Promise<StandActivateResult>;
|
|
255
289
|
/**
|
|
256
290
|
* Deletes a durable definition after observing its current record.
|
|
257
291
|
*
|
|
258
292
|
* @param value Identifies the definition to delete.
|
|
259
293
|
* @returns Resolves to the deletion outcome.
|
|
294
|
+
* @param reader The verified reader facts for this operation.
|
|
260
295
|
*/
|
|
261
|
-
delete(value: SubscriptionId): Promise<StandDeleteResult>;
|
|
296
|
+
delete(value: SubscriptionId, reader?: ReaderIdentity): Promise<StandDeleteResult>;
|
|
262
297
|
/**
|
|
263
298
|
* Gets an isolated durable definition, when present.
|
|
264
299
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-registry.d.ts","sourceRoot":"","sources":["../../src/stand/subscription-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription-registry.d.ts","sourceRoot":"","sources":["../../src/stand/subscription-registry.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAIpG,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAGL,UAAU,EACV,YAAY,EAEZ,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,sCAAsC,CAAC;AAM9C;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,aAAa,MAAM,KAAG,YAG7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,UAAU,CAAC,cAAc,EAAE,kBAAkB,CAiB9E,CAAC;AAEL;;GAEG;AACH,UAAU,0BAA0B;IAGlC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAClD,0BAA0B,GAAG;IAG3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CACjD,0BAA0B,GAAG;IAG3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC;CAC/B,C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