@spine-event-engine/storage 2.0.0-snapshot.10
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/LICENSE +201 -0
- package/README.md +190 -0
- package/REFERENCE.md +122 -0
- package/dist/entity/entity-history-record-spec.d.ts +26 -0
- package/dist/entity/entity-history-record-spec.d.ts.map +1 -0
- package/dist/entity/entity-history-record-spec.js +77 -0
- package/dist/entity/entity-history-record-spec.js.map +1 -0
- package/dist/entity/entity-history-storage.d.ts +111 -0
- package/dist/entity/entity-history-storage.d.ts.map +1 -0
- package/dist/entity/entity-history-storage.js +40 -0
- package/dist/entity/entity-history-storage.js.map +1 -0
- package/dist/entity/entity-record.d.ts +31 -0
- package/dist/entity/entity-record.d.ts.map +1 -0
- package/dist/entity/entity-record.js +15 -0
- package/dist/entity/entity-record.js.map +1 -0
- package/dist/entity/history-conformance.d.ts +55 -0
- package/dist/entity/history-conformance.d.ts.map +1 -0
- package/dist/entity/history-conformance.js +165 -0
- package/dist/entity/history-conformance.js.map +1 -0
- package/dist/event/event-store.d.ts +141 -0
- package/dist/event/event-store.d.ts.map +1 -0
- package/dist/event/event-store.js +407 -0
- package/dist/event/event-store.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/delivery-cleanup.d.ts +99 -0
- package/dist/internal/delivery-cleanup.d.ts.map +1 -0
- package/dist/internal/delivery-cleanup.js +38 -0
- package/dist/internal/delivery-cleanup.js.map +1 -0
- package/dist/internal/entity-commit.d.ts +108 -0
- package/dist/internal/entity-commit.d.ts.map +1 -0
- package/dist/internal/entity-commit.js +32 -0
- package/dist/internal/entity-commit.js.map +1 -0
- package/dist/internal/entity-history.d.ts +12 -0
- package/dist/internal/entity-history.d.ts.map +1 -0
- package/dist/internal/entity-history.js +17 -0
- package/dist/internal/entity-history.js.map +1 -0
- package/dist/internal/event-store.d.ts +8 -0
- package/dist/internal/event-store.d.ts.map +1 -0
- package/dist/internal/event-store.js +21 -0
- package/dist/internal/event-store.js.map +1 -0
- package/dist/internal/query-values.d.ts +5 -0
- package/dist/internal/query-values.d.ts.map +1 -0
- package/dist/internal/query-values.js +18 -0
- package/dist/internal/query-values.js.map +1 -0
- package/dist/internal/tenancy.d.ts +89 -0
- package/dist/internal/tenancy.d.ts.map +1 -0
- package/dist/internal/tenancy.js +97 -0
- package/dist/internal/tenancy.js.map +1 -0
- package/dist/memory/canonical-utf8.d.ts +21 -0
- package/dist/memory/canonical-utf8.d.ts.map +1 -0
- package/dist/memory/canonical-utf8.js +65 -0
- package/dist/memory/canonical-utf8.js.map +1 -0
- package/dist/memory/in-memory-entity-commit.d.ts +35 -0
- package/dist/memory/in-memory-entity-commit.d.ts.map +1 -0
- package/dist/memory/in-memory-entity-commit.js +183 -0
- package/dist/memory/in-memory-entity-commit.js.map +1 -0
- package/dist/memory/in-memory-entity-history.d.ts +379 -0
- package/dist/memory/in-memory-entity-history.d.ts.map +1 -0
- package/dist/memory/in-memory-entity-history.js +756 -0
- package/dist/memory/in-memory-entity-history.js.map +1 -0
- package/dist/memory/in-memory-record-storage.d.ts +78 -0
- package/dist/memory/in-memory-record-storage.d.ts.map +1 -0
- package/dist/memory/in-memory-record-storage.js +127 -0
- package/dist/memory/in-memory-record-storage.js.map +1 -0
- package/dist/memory/in-memory-storage-backend.d.ts +38 -0
- package/dist/memory/in-memory-storage-backend.d.ts.map +1 -0
- package/dist/memory/in-memory-storage-backend.js +108 -0
- package/dist/memory/in-memory-storage-backend.js.map +1 -0
- package/dist/memory/in-memory-storage-factory.d.ts +58 -0
- package/dist/memory/in-memory-storage-factory.d.ts.map +1 -0
- package/dist/memory/in-memory-storage-factory.js +148 -0
- package/dist/memory/in-memory-storage-factory.js.map +1 -0
- package/dist/memory/memory-delivery-cleanup.d.ts +32 -0
- package/dist/memory/memory-delivery-cleanup.d.ts.map +1 -0
- package/dist/memory/memory-delivery-cleanup.js +61 -0
- package/dist/memory/memory-delivery-cleanup.js.map +1 -0
- package/dist/memory/tenant-records.d.ts +66 -0
- package/dist/memory/tenant-records.d.ts.map +1 -0
- package/dist/memory/tenant-records.js +573 -0
- package/dist/memory/tenant-records.js.map +1 -0
- package/dist/provider.d.ts +18 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +23 -0
- package/dist/provider.js.map +1 -0
- package/dist/query/query-execution.d.ts +50 -0
- package/dist/query/query-execution.d.ts.map +1 -0
- package/dist/query/query-execution.js +222 -0
- package/dist/query/query-execution.js.map +1 -0
- package/dist/query/query-policy.d.ts +115 -0
- package/dist/query/query-policy.d.ts.map +1 -0
- package/dist/query/query-policy.js +294 -0
- package/dist/query/query-policy.js.map +1 -0
- package/dist/record/column-mapping.d.ts +41 -0
- package/dist/record/column-mapping.d.ts.map +1 -0
- package/dist/record/column-mapping.js +36 -0
- package/dist/record/column-mapping.js.map +1 -0
- package/dist/record/column-type.d.ts +75 -0
- package/dist/record/column-type.d.ts.map +1 -0
- package/dist/record/column-type.js +69 -0
- package/dist/record/column-type.js.map +1 -0
- package/dist/record/record-column.d.ts +23 -0
- package/dist/record/record-column.d.ts.map +1 -0
- package/dist/record/record-column.js +41 -0
- package/dist/record/record-column.js.map +1 -0
- package/dist/record/record-mask.d.ts +11 -0
- package/dist/record/record-mask.d.ts.map +1 -0
- package/dist/record/record-mask.js +82 -0
- package/dist/record/record-mask.js.map +1 -0
- package/dist/record/record-query.d.ts +102 -0
- package/dist/record/record-query.d.ts.map +1 -0
- package/dist/record/record-query.js +44 -0
- package/dist/record/record-query.js.map +1 -0
- package/dist/record/record-spec.d.ts +101 -0
- package/dist/record/record-spec.d.ts.map +1 -0
- package/dist/record/record-spec.js +159 -0
- package/dist/record/record-spec.js.map +1 -0
- package/dist/record/record-storage.d.ts +202 -0
- package/dist/record/record-storage.d.ts.map +1 -0
- package/dist/record/record-storage.js +234 -0
- package/dist/record/record-storage.js.map +1 -0
- package/dist/record/storage-group.d.ts +17 -0
- package/dist/record/storage-group.d.ts.map +1 -0
- package/dist/record/storage-group.js +37 -0
- package/dist/record/storage-group.js.map +1 -0
- package/dist/storage/storage-factory.d.ts +44 -0
- package/dist/storage/storage-factory.d.ts.map +1 -0
- package/dist/storage/storage-factory.js +54 -0
- package/dist/storage/storage-factory.js.map +1 -0
- package/dist/storage/storage.d.ts +62 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +15 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
2
|
+
import type { Event } from "@spine-event-engine/proto";
|
|
3
|
+
import type { EntityRecord } from "../entity/entity-record.js";
|
|
4
|
+
import type { StorageContext } from "../storage/storage.js";
|
|
5
|
+
import type { EntityStorageInput } from "./entity-history.js";
|
|
6
|
+
import type { StorageFactory } from "../storage/storage-factory.js";
|
|
7
|
+
/**
|
|
8
|
+
* Describes one provider-owned atomic mutation for an Entity commit.
|
|
9
|
+
*
|
|
10
|
+
* This provider-only contract combines current state, retained histories, and
|
|
11
|
+
* framework delivery events. It is intentionally not an application-level
|
|
12
|
+
* transaction API.
|
|
13
|
+
*/
|
|
14
|
+
export interface EntityCommitInput<I, S extends Message> {
|
|
15
|
+
/**
|
|
16
|
+
* Identifies the storage scope that owns this commit.
|
|
17
|
+
*/
|
|
18
|
+
readonly context: StorageContext;
|
|
19
|
+
/**
|
|
20
|
+
* Defines the Entity storage layout mutated by this commit.
|
|
21
|
+
*/
|
|
22
|
+
readonly entity: EntityStorageInput<I, S>;
|
|
23
|
+
/**
|
|
24
|
+
* Identifies the Entity record being changed.
|
|
25
|
+
*/
|
|
26
|
+
readonly entityId: I;
|
|
27
|
+
/**
|
|
28
|
+
* Requires this current record before applying the next record.
|
|
29
|
+
*/
|
|
30
|
+
readonly expected?: EntityRecord;
|
|
31
|
+
/**
|
|
32
|
+
* Stores the next current record.
|
|
33
|
+
*/
|
|
34
|
+
readonly next: EntityRecord;
|
|
35
|
+
/**
|
|
36
|
+
* Appends retained Entity state-history rows.
|
|
37
|
+
*/
|
|
38
|
+
readonly states?: readonly EntityRecord[];
|
|
39
|
+
/**
|
|
40
|
+
* Appends retained diagnostic Entity-event rows.
|
|
41
|
+
*/
|
|
42
|
+
readonly diagnostics?: readonly Event[];
|
|
43
|
+
/**
|
|
44
|
+
* Appends canonical framework delivery events.
|
|
45
|
+
*/
|
|
46
|
+
readonly events?: readonly Event[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reports the durable outcome of one Entity commit attempt.
|
|
50
|
+
*/
|
|
51
|
+
export type EntityCommitResult = "committed" | "conflict";
|
|
52
|
+
/**
|
|
53
|
+
* A provider handle for atomic changes to one bounded Entity scope.
|
|
54
|
+
*/
|
|
55
|
+
export interface EntityCommitStorage {
|
|
56
|
+
/**
|
|
57
|
+
* Applies one complete Entity mutation.
|
|
58
|
+
*
|
|
59
|
+
* @param input Defines the unit of Entity, history, and delivery-event work.
|
|
60
|
+
* @returns Resolves to the committed or conflict outcome.
|
|
61
|
+
*/
|
|
62
|
+
commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<EntityCommitResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Closes this independently owned commit handle.
|
|
65
|
+
*/
|
|
66
|
+
close(): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Defines the provider-only storage-factory capability required by repositories.
|
|
70
|
+
*/
|
|
71
|
+
export interface EntityCommitStorageFactory {
|
|
72
|
+
/**
|
|
73
|
+
* Creates a handle that atomically mutates Entity persistence for one provider.
|
|
74
|
+
*
|
|
75
|
+
* @param input Identifies the Entity storage layout the handle may commit.
|
|
76
|
+
* @returns The independently closeable provider commit handle.
|
|
77
|
+
*/
|
|
78
|
+
createEntityCommitStorage<I, S extends Message>(input: EntityStorageInput<I, S>): EntityCommitStorage;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The framework-only access point for provider commit factories.
|
|
82
|
+
*/
|
|
83
|
+
interface EntityCommitFactoryAccess {
|
|
84
|
+
/**
|
|
85
|
+
* Registers the atomic commit capability of one storage factory.
|
|
86
|
+
*
|
|
87
|
+
* @param factory Identifies the storage factory that provides the capability.
|
|
88
|
+
* @param creator Creates atomic commit handles for that provider.
|
|
89
|
+
*/
|
|
90
|
+
register(factory: StorageFactory, creator: EntityCommitStorageFactory): void;
|
|
91
|
+
/**
|
|
92
|
+
* Creates an atomic commit handle registered by a storage provider.
|
|
93
|
+
*
|
|
94
|
+
* @param factory Identifies the provider storage factory.
|
|
95
|
+
* @param input Defines the Entity storage layout to commit.
|
|
96
|
+
* @returns The provider-owned atomic commit handle.
|
|
97
|
+
*/
|
|
98
|
+
create<I, S extends Message>(factory: StorageFactory, input: EntityStorageInput<I, S>): EntityCommitStorage;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Provides the typed internal lookup for provider-owned atomic commit handles.
|
|
102
|
+
*
|
|
103
|
+
* Provider adapters register their creator while constructing their factory;
|
|
104
|
+
* the end-user storage root deliberately exposes no commit-construction method.
|
|
105
|
+
*/
|
|
106
|
+
export declare const EntityCommitStorageFactories: EntityCommitFactoryAccess;
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=entity-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-commit.d.ts","sourceRoot":"","sources":["../../src/internal/entity-commit.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,k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;;GAEG;AACH,UAAU,yBAAyB;IAGjC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAE7E;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EACzB,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC9B,mBAAmB,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,EAAE,yBAczC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* Provides the typed internal lookup for provider-owned atomic commit handles.
|
|
16
|
+
*
|
|
17
|
+
* Provider adapters register their creator while constructing their factory;
|
|
18
|
+
* the end-user storage root deliberately exposes no commit-construction method.
|
|
19
|
+
*/
|
|
20
|
+
export const EntityCommitStorageFactories = Object.freeze({
|
|
21
|
+
register(factory, creator) {
|
|
22
|
+
creators.set(factory, creator);
|
|
23
|
+
},
|
|
24
|
+
create(factory, input) {
|
|
25
|
+
const creator = creators.get(factory);
|
|
26
|
+
if (creator === undefined)
|
|
27
|
+
throw new Error("StorageFactory does not provide the required atomic Entity commit storage.");
|
|
28
|
+
return creator.createEntityCommitStorage(input);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const creators = new WeakMap();
|
|
32
|
+
//# sourceMappingURL=entity-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-commit.js","sourceRoot":"","sources":["../../src/internal/entity-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA8B,MAAM,CAAC,MAAM,CAAC;IACnF,QAAQ,CAAC,OAAuB,EAAE,OAAmC;QACnE,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CACJ,OAAuB,EACvB,KAA+B;QAE/B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,OAAO,KAAK,SAAS;YACvB,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;QAChG,OAAO,OAAO,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAA8C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-only entity persistence SPI. This subpath is intentionally not part
|
|
3
|
+
* of the end-user storage root; storage adapters import it directly.
|
|
4
|
+
*/
|
|
5
|
+
export type { EntityEventHistoryPort, EntityStateHistoryPort, } from "../entity/entity-history-storage.js";
|
|
6
|
+
export { disabledEventHistoryPort, disabledStateHistoryPort, } from "../entity/entity-history-storage.js";
|
|
7
|
+
export type { EntityRecord, EntityRecordStorage } from "../entity/entity-record.js";
|
|
8
|
+
export { eventHistorySpec, stateHistorySpec } from "../entity/entity-history-record-spec.js";
|
|
9
|
+
export { EntityHistoryConformance, type EntityHistoryConformanceAdapter, type EntityStorageConformance, } from "../entity/history-conformance.js";
|
|
10
|
+
export type { EntityIdCodec, EntityStorageInput } from "../memory/in-memory-entity-history.js";
|
|
11
|
+
export type { EntityCommitInput, EntityCommitResult, EntityCommitStorage, EntityCommitStorageFactory, } from "./entity-commit.js";
|
|
12
|
+
//# sourceMappingURL=entity-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-history.d.ts","sourceRoot":"","sources":["../../src/internal/entity-history.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,YAAY,EACV,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EACL,wBAAwB,EACxB,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC/F,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export { disabledEventHistoryPort, disabledStateHistoryPort, } from "../entity/entity-history-storage.js";
|
|
15
|
+
export { eventHistorySpec, stateHistorySpec } from "../entity/entity-history-record-spec.js";
|
|
16
|
+
export { EntityHistoryConformance, } from "../entity/history-conformance.js";
|
|
17
|
+
//# sourceMappingURL=entity-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-history.js","sourceRoot":"","sources":["../../src/internal/entity-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EACL,wBAAwB,GAGzB,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-only Event Store record layout.
|
|
3
|
+
*
|
|
4
|
+
* Storage adapters use this subpath to address the same durable records as the
|
|
5
|
+
* framework Event Store without adding the layout to the end-user package root.
|
|
6
|
+
*/
|
|
7
|
+
export { eventStoreAccess, eventStoreRecordSpec } from "../event/event-store.js";
|
|
8
|
+
//# sourceMappingURL=event-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../../src/internal/event-store.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
* Provider-only Event Store record layout.
|
|
16
|
+
*
|
|
17
|
+
* Storage adapters use this subpath to address the same durable records as the
|
|
18
|
+
* framework Event Store without adding the layout to the end-user package root.
|
|
19
|
+
*/
|
|
20
|
+
export { eventStoreAccess, eventStoreRecordSpec } from "../event/event-store.js";
|
|
21
|
+
//# sourceMappingURL=event-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-store.js","sourceRoot":"","sources":["../../src/internal/event-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-values.d.ts","sourceRoot":"","sources":["../../src/internal/query-values.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
* Internal shared query-value semantics for storage adapters.
|
|
16
|
+
*/
|
|
17
|
+
export { StorageQueryValues } from "../query/query-execution.js";
|
|
18
|
+
//# sourceMappingURL=query-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-values.js","sourceRoot":"","sources":["../../src/internal/query-values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type TenantId } from "@spine-event-engine/proto";
|
|
2
|
+
import type { StorageContext } from "../storage/storage.js";
|
|
3
|
+
/**
|
|
4
|
+
* Provider-selection identity for one complete generated tenant value.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface TenantBoundary {
|
|
9
|
+
/**
|
|
10
|
+
* Stable in-process map key. Single tenancy uses one private symbol.
|
|
11
|
+
*/
|
|
12
|
+
readonly key: string | symbol;
|
|
13
|
+
/**
|
|
14
|
+
* Whether this is the one explicit single-tenant boundary.
|
|
15
|
+
*/
|
|
16
|
+
readonly single: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Complete cloned tenant ID, absent only for single tenancy.
|
|
19
|
+
*/
|
|
20
|
+
readonly tenantId: TenantId | undefined;
|
|
21
|
+
}
|
|
22
|
+
interface MultitenantTenantBoundary extends TenantBoundary {
|
|
23
|
+
readonly single: false;
|
|
24
|
+
readonly tenantId: TenantId;
|
|
25
|
+
}
|
|
26
|
+
interface TenantBoundaryFactory {
|
|
27
|
+
readonly single: TenantBoundary;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a boundary for the supplied tenant.
|
|
30
|
+
*
|
|
31
|
+
* @param tenantId The complete generated tenant identifier.
|
|
32
|
+
* @returns The immutable tenant boundary.
|
|
33
|
+
*/
|
|
34
|
+
from(tenantId: TenantId): MultitenantTenantBoundary;
|
|
35
|
+
/**
|
|
36
|
+
* Selects the boundary declared by a storage context.
|
|
37
|
+
*
|
|
38
|
+
* @param context The storage context.
|
|
39
|
+
* @returns The validated tenant boundary.
|
|
40
|
+
*/
|
|
41
|
+
of(context: StorageContext): TenantBoundary;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates immutable provider tenant boundaries.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare const TenantBoundary: TenantBoundaryFactory;
|
|
49
|
+
/**
|
|
50
|
+
* Provider-owned enumeration of storage tenant boundaries.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export interface TenantCatalog {
|
|
55
|
+
/**
|
|
56
|
+
* Lists the boundaries available for storage-backed startup work.
|
|
57
|
+
*
|
|
58
|
+
* @returns The available tenant boundaries.
|
|
59
|
+
*/
|
|
60
|
+
all(): Promise<readonly TenantBoundary[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Closes resources owned by this catalog.
|
|
63
|
+
*
|
|
64
|
+
* @returns Completion of resource release.
|
|
65
|
+
*/
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Records an admitted tenant when the provider requires an early cache.
|
|
69
|
+
*
|
|
70
|
+
* @param boundary The admitted boundary.
|
|
71
|
+
* @returns Completion of the catalog update.
|
|
72
|
+
*/
|
|
73
|
+
keep(boundary: TenantBoundary): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Storage-factory capability that owns one tenant catalog.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export interface TenantCatalogProvider {
|
|
81
|
+
/**
|
|
82
|
+
* Returns the catalog owned by this storage factory.
|
|
83
|
+
*
|
|
84
|
+
* @returns The provider-owned tenant catalog.
|
|
85
|
+
*/
|
|
86
|
+
tenantCatalog(): TenantCatalog;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=tenancy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenancy.d.ts","sourceRoot":"","sources":["../../src/internal/tenancy.ts"],"names":[],"mappings":"AAeA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAG7B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;CACzC;AAED,UAAU,yBAA0B,SAAQ,cAAc;IACxD,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,yBAAyB,CAAC;IAEpD;;;;;OAKG;IACH,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC;CAC7C;AAQD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,qBAuC5B,CAAC;AA0CF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAG5B;;;;OAIG;IACH,GAAG,IAAI,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAAC;IAE1C;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IAGpC;;;;OAIG;IACH,aAAa,IAAI,aAAa,CAAC;CAChC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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, toBinary } from "@bufbuild/protobuf";
|
|
15
|
+
import { TenantIdSchema } from "@spine-event-engine/proto";
|
|
16
|
+
const singleTenantKey = Symbol("single tenant");
|
|
17
|
+
const singleTenantBoundary = Object.freeze({
|
|
18
|
+
key: singleTenantKey,
|
|
19
|
+
single: true,
|
|
20
|
+
tenantId: undefined,
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Creates immutable provider tenant boundaries.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export const TenantBoundary = {
|
|
28
|
+
// prettier-ignore
|
|
29
|
+
/**
|
|
30
|
+
* The explicit singleton used by single-tenant providers.
|
|
31
|
+
*/
|
|
32
|
+
single: singleTenantBoundary,
|
|
33
|
+
/**
|
|
34
|
+
* Creates a boundary from a complete generated tenant ID.
|
|
35
|
+
*
|
|
36
|
+
* @param tenantId The generated tenant ID.
|
|
37
|
+
* @returns An immutable tenant boundary.
|
|
38
|
+
*/
|
|
39
|
+
from(tenantId) {
|
|
40
|
+
return new MultitenantBoundary(tenantId);
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Returns the boundary declared by a storage context.
|
|
44
|
+
*
|
|
45
|
+
* @param context The diagnostic context and tenant selection.
|
|
46
|
+
* @returns The validated provider tenant boundary.
|
|
47
|
+
*/
|
|
48
|
+
of(context) {
|
|
49
|
+
const tenantId = context.tenantId;
|
|
50
|
+
if (!context.multitenant) {
|
|
51
|
+
if (tenantId !== undefined) {
|
|
52
|
+
throw new Error(`Single-tenant storage "${context.name}" does not accept context.tenantId.`);
|
|
53
|
+
}
|
|
54
|
+
return singleTenantBoundary;
|
|
55
|
+
}
|
|
56
|
+
if (tenantId === undefined) {
|
|
57
|
+
throw new Error(`Multitenant storage "${context.name}" requires context.tenantId.`);
|
|
58
|
+
}
|
|
59
|
+
return new MultitenantBoundary(tenantId);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
Object.freeze(TenantBoundary);
|
|
63
|
+
class MultitenantBoundary {
|
|
64
|
+
#tenantId;
|
|
65
|
+
key;
|
|
66
|
+
single = false;
|
|
67
|
+
constructor(tenantId) {
|
|
68
|
+
TenantIds.require(tenantId);
|
|
69
|
+
this.#tenantId = clone(TenantIdSchema, tenantId);
|
|
70
|
+
this.key = TenantIds.key(this.#tenantId);
|
|
71
|
+
Object.freeze(this);
|
|
72
|
+
}
|
|
73
|
+
get tenantId() {
|
|
74
|
+
return clone(TenantIdSchema, this.#tenantId);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const TenantIds = Object.freeze({
|
|
78
|
+
require(tenantId) {
|
|
79
|
+
const kind = tenantId.kind;
|
|
80
|
+
const value = kind.case === "value"
|
|
81
|
+
? kind.value
|
|
82
|
+
: kind.case === "domain" || kind.case === "email"
|
|
83
|
+
? kind.value.value
|
|
84
|
+
: undefined;
|
|
85
|
+
if (value === undefined || value.trim().length === 0) {
|
|
86
|
+
throw new Error("Multitenant storage requires a non-empty TenantId.");
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
key(tenantId) {
|
|
90
|
+
const bytes = toBinary(TenantIdSchema, tenantId, { writeUnknownFields: false });
|
|
91
|
+
let encoded = "";
|
|
92
|
+
for (const byte of bytes)
|
|
93
|
+
encoded += byte.toString(16).padStart(2, "0");
|
|
94
|
+
return encoded;
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=tenancy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenancy.js","sourceRoot":"","sources":["../../src/internal/tenancy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAiB,MAAM,2BAA2B,CAAC;AAG1E,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAmDhD,MAAM,oBAAoB,GAAmB,MAAM,CAAC,MAAM,CAAC;IACzD,GAAG,EAAE,eAAe;IACpB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,SAAS;CACpB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAA0B;IACnD,kBAAkB;IAElB;;OAEG;IACH,MAAM,EAAE,oBAAoB;IAE5B;;;;;OAKG;IACH,IAAI,CAAC,QAAkB;QACrB,OAAO,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,EAAE,CAAC,OAAuB;QACxB,MAAM,QAAQ,GAAI,OAA4C,CAAC,QAAQ,CAAC;QACxE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACzB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,0BAA0B,OAAO,CAAC,IAAI,qCAAqC,CAC5E,CAAC;YACJ,CAAC;YACD,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E,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED,GAAG,CAAC,QAAkB;QACpB,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,EAAE,QAAQ,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC;QAChF,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACxE,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal canonical UTF-8 ordering shared by in-memory storage components.
|
|
3
|
+
*/
|
|
4
|
+
export declare const CanonicalUtf8: {
|
|
5
|
+
/**
|
|
6
|
+
* Compares strings by their canonical UTF-8 byte sequences.
|
|
7
|
+
*
|
|
8
|
+
* @param left The first string.
|
|
9
|
+
* @param right The second string.
|
|
10
|
+
* @returns A negative, zero, or positive comparison result.
|
|
11
|
+
*/
|
|
12
|
+
compare(left: string, right: string): number;
|
|
13
|
+
/**
|
|
14
|
+
* Encodes a string as canonical UTF-8 bytes.
|
|
15
|
+
*
|
|
16
|
+
* @param value The string to encode.
|
|
17
|
+
* @returns Its canonical UTF-8 byte sequence.
|
|
18
|
+
*/
|
|
19
|
+
bytes(value: string): Uint8Array;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=canonical-utf8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-utf8.d.ts","sourceRoot":"","sources":["../../src/memory/canonical-utf8.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,eAAO,MAAM,aAAa;IAGxB;;;;;;OAMG;kBACW,MAAM,SAAS,MAAM,GAAG,MAAM;IAW5C;;;;;OAKG;iBACU,MAAM,GAAG,UAAU;CAyBjC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
* Internal canonical UTF-8 ordering shared by in-memory storage components.
|
|
16
|
+
*/
|
|
17
|
+
export const CanonicalUtf8 = {
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
/**
|
|
20
|
+
* Compares strings by their canonical UTF-8 byte sequences.
|
|
21
|
+
*
|
|
22
|
+
* @param left The first string.
|
|
23
|
+
* @param right The second string.
|
|
24
|
+
* @returns A negative, zero, or positive comparison result.
|
|
25
|
+
*/
|
|
26
|
+
compare(left, right) {
|
|
27
|
+
const leftBytes = CanonicalUtf8.bytes(left);
|
|
28
|
+
const rightBytes = CanonicalUtf8.bytes(right);
|
|
29
|
+
const length = Math.min(leftBytes.length, rightBytes.length);
|
|
30
|
+
for (let index = 0; index < length; index += 1) {
|
|
31
|
+
const difference = (leftBytes[index] ?? 0) - (rightBytes[index] ?? 0);
|
|
32
|
+
if (difference !== 0)
|
|
33
|
+
return difference;
|
|
34
|
+
}
|
|
35
|
+
return leftBytes.length - rightBytes.length;
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Encodes a string as canonical UTF-8 bytes.
|
|
39
|
+
*
|
|
40
|
+
* @param value The string to encode.
|
|
41
|
+
* @returns Its canonical UTF-8 byte sequence.
|
|
42
|
+
*/
|
|
43
|
+
bytes(value) {
|
|
44
|
+
const bytes = [];
|
|
45
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
46
|
+
const codePoint = value.codePointAt(index);
|
|
47
|
+
if (codePoint === undefined)
|
|
48
|
+
continue;
|
|
49
|
+
if (codePoint > 0xffff)
|
|
50
|
+
index++;
|
|
51
|
+
if (codePoint <= 0x7f)
|
|
52
|
+
bytes.push(codePoint);
|
|
53
|
+
else if (codePoint <= 0x7ff)
|
|
54
|
+
bytes.push(0xc0 | (codePoint >> 6), 0x80 | (codePoint & 0x3f));
|
|
55
|
+
else if (codePoint <= 0xffff) {
|
|
56
|
+
bytes.push(0xe0 | (codePoint >> 12), 0x80 | ((codePoint >> 6) & 0x3f), 0x80 | (codePoint & 0x3f));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
bytes.push(0xf0 | (codePoint >> 18), 0x80 | ((codePoint >> 12) & 0x3f), 0x80 | ((codePoint >> 6) & 0x3f), 0x80 | (codePoint & 0x3f));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new Uint8Array(bytes);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=canonical-utf8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-utf8.js","sourceRoot":"","sources":["../../src/memory/canonical-utf8.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,kBAAkB;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,IAAY,EAAE,KAAa;QACjC,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,G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GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC1B,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CACR,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,EACxB,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EACjC,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAChC,IAAI,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC1B,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Message } from "@bufbuild/protobuf";
|
|
2
|
+
import type { EntityCommitInput, EntityCommitResult, EntityCommitStorage } from "../internal/entity-commit.js";
|
|
3
|
+
import type { RecordSpec } from "../record/record-spec.js";
|
|
4
|
+
import type { StorageGroup } from "../record/storage-group.js";
|
|
5
|
+
import type { StorageContext } from "../storage/storage.js";
|
|
6
|
+
import type { StorageFactory } from "../storage/storage-factory.js";
|
|
7
|
+
import { MemoryEntityStorageFactory, type EntityStorageInput } from "./in-memory-entity-history.js";
|
|
8
|
+
import { TenantRecords } from "./tenant-records.js";
|
|
9
|
+
/**
|
|
10
|
+
* Implements provider-owned Entity commits for one shared in-memory backend.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MemoryEntityCommitStorage implements EntityCommitStorage {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a commit handle bound to one Entity source type.
|
|
16
|
+
*
|
|
17
|
+
* @param entities Opens the matching current Entity storage.
|
|
18
|
+
* @param factory Owns the Event Store coordination lock.
|
|
19
|
+
* @param openRecords Opens exact generic-record backing slices.
|
|
20
|
+
* @param input Defines the Entity storage source type.
|
|
21
|
+
*/
|
|
22
|
+
constructor(entities: MemoryEntityStorageFactory, factory: StorageFactory, openRecords: <I, R extends Message>(context: StorageContext, spec: RecordSpec<I, R>, group?: StorageGroup) => TenantRecords<I, R>, input: EntityStorageInput<unknown, Message>);
|
|
23
|
+
/**
|
|
24
|
+
* Applies one fully preflighted in-memory Entity commit.
|
|
25
|
+
*
|
|
26
|
+
* @param input Defines the current record, retained histories, and delivery events.
|
|
27
|
+
* @returns The durable in-memory commit outcome.
|
|
28
|
+
*/
|
|
29
|
+
commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<EntityCommitResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Closes this commit handle without closing sibling handles.
|
|
32
|
+
*/
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=in-memory-entity-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-entity-commit.d.ts","sourceRoot":"","sources":["../../src/memory/in-memory-entity-commit.ts"],"names":[],"mappings":"AAcA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAOnE,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAGL,0BAA0B,EAG1B,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD;;GAEG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;;IAWnE;;;;;;;OAOG;gBAED,QAAQ,EAAE,0BAA0B,EACpC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAChC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,KAAK,CAAC,EAAE,YAAY,KACjB,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EACxB,KAAK,EAAE,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC;IAQ7C;;;;;OAKG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWzF;;OAEG;IACH,KAAK,IAAI,IAAI;CAoId"}
|