@spine-event-engine/storage 2.0.0-snapshot.2 → 2.0.0-snapshot.20
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 +47 -14
- package/REFERENCE.md +26 -18
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/entity-commit.d.ts +28 -23
- package/dist/internal/entity-commit.d.ts.map +1 -1
- package/dist/internal/entity-commit.js +10 -1
- package/dist/internal/entity-commit.js.map +1 -1
- package/dist/internal/entity-history.d.ts +1 -1
- package/dist/internal/entity-history.d.ts.map +1 -1
- package/dist/memory/canonical-utf8.d.ts.map +1 -1
- package/dist/memory/canonical-utf8.js +13 -6
- package/dist/memory/canonical-utf8.js.map +1 -1
- package/dist/memory/in-memory-entity-commit.d.ts +38 -6
- package/dist/memory/in-memory-entity-commit.d.ts.map +1 -1
- package/dist/memory/in-memory-entity-commit.js +281 -68
- package/dist/memory/in-memory-entity-commit.js.map +1 -1
- package/dist/memory/in-memory-entity-history.d.ts +115 -1
- package/dist/memory/in-memory-entity-history.d.ts.map +1 -1
- package/dist/memory/in-memory-entity-history.js +186 -41
- package/dist/memory/in-memory-entity-history.js.map +1 -1
- package/dist/memory/in-memory-record-storage.d.ts +19 -0
- package/dist/memory/in-memory-record-storage.d.ts.map +1 -1
- package/dist/memory/in-memory-record-storage.js +25 -4
- package/dist/memory/in-memory-record-storage.js.map +1 -1
- package/dist/memory/tenant-records.d.ts +33 -7
- package/dist/memory/tenant-records.d.ts.map +1 -1
- package/dist/memory/tenant-records.js +297 -77
- package/dist/memory/tenant-records.js.map +1 -1
- 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-policy.d.ts +18 -14
- package/dist/query/query-policy.d.ts.map +1 -1
- package/dist/query/query-policy.js +55 -28
- package/dist/query/query-policy.js.map +1 -1
- package/dist/record/record-query.d.ts +12 -11
- package/dist/record/record-query.d.ts.map +1 -1
- package/dist/record/record-query.js +4 -1
- package/dist/record/record-query.js.map +1 -1
- package/dist/record/record-storage.d.ts +12 -5
- package/dist/record/record-storage.d.ts.map +1 -1
- package/dist/record/record-storage.js +14 -12
- package/dist/record/record-storage.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -27
- package/dist/record/record-mask.d.ts +0 -11
- package/dist/record/record-mask.d.ts.map +0 -1
- package/dist/record/record-mask.js +0 -82
- package/dist/record/record-mask.js.map +0 -1
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
|
-
import { clone
|
|
14
|
+
import { clone } from "@bufbuild/protobuf";
|
|
15
|
+
import { EventSchema } from "@spine-event-engine/proto";
|
|
15
16
|
import { EntityRecordSchema } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
|
|
16
17
|
import { eventStoreAccess, eventStoreRecordSpec } from "../event/event-store.js";
|
|
17
18
|
import { eventHistorySpec, stateHistorySpec } from "../entity/entity-history-record-spec.js";
|
|
@@ -19,21 +20,22 @@ import { TenantBoundary } from "../internal/tenancy.js";
|
|
|
19
20
|
import { InMemoryEntityStorage, KeyedSerialQueue, MemoryEntityStorageFactory, ENTITY_SCOPE_MUTATION_KEY, } from "./in-memory-entity-history.js";
|
|
20
21
|
import { InMemoryRecordStorage } from "./in-memory-record-storage.js";
|
|
21
22
|
import { TenantRecords } from "./tenant-records.js";
|
|
22
|
-
const commitHost = globalThis;
|
|
23
23
|
/**
|
|
24
|
-
* Implements provider
|
|
24
|
+
* Implements provider Entity commits for one shared in-memory backend.
|
|
25
25
|
*/
|
|
26
26
|
export class MemoryEntityCommitStorage {
|
|
27
27
|
#entities;
|
|
28
28
|
#factory;
|
|
29
29
|
#openRecords;
|
|
30
30
|
#input;
|
|
31
|
+
#tenantKey;
|
|
32
|
+
#multitenant;
|
|
31
33
|
#open = true;
|
|
32
34
|
/**
|
|
33
35
|
* Creates a commit handle bound to one Entity source type.
|
|
34
36
|
*
|
|
35
37
|
* @param entities Opens the matching current Entity storage.
|
|
36
|
-
* @param factory
|
|
38
|
+
* @param factory Provides the Event Store coordination lock.
|
|
37
39
|
* @param openRecords Opens exact generic-record backing slices.
|
|
38
40
|
* @param input Defines the Entity storage source type.
|
|
39
41
|
*/
|
|
@@ -42,21 +44,45 @@ export class MemoryEntityCommitStorage {
|
|
|
42
44
|
this.#factory = factory;
|
|
43
45
|
this.#openRecords = openRecords;
|
|
44
46
|
this.#input = input;
|
|
47
|
+
this.#tenantKey = TenantBoundary.of(input.context).key;
|
|
48
|
+
this.#multitenant = input.context.multitenant;
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Applies one fully preflighted in-memory Entity commit.
|
|
48
52
|
*
|
|
53
|
+
* @typeParam I Entity identifier type.
|
|
54
|
+
* @typeParam S Entity state type.
|
|
49
55
|
* @param input Defines the current record, retained histories, and delivery events.
|
|
50
|
-
* @returns
|
|
56
|
+
* @returns Completion after the in-memory commit.
|
|
51
57
|
*/
|
|
52
58
|
commit(input) {
|
|
53
59
|
this.#requireOpen();
|
|
54
60
|
this.#requireCompatible(input);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
61
|
+
const tenant = TenantBoundary.of(input.context);
|
|
62
|
+
const context = tenant.tenantId === undefined
|
|
63
|
+
? { name: input.context.name, multitenant: false }
|
|
64
|
+
: { name: input.context.name, multitenant: true, tenantId: tenant.tenantId };
|
|
65
|
+
const snapshot = {
|
|
66
|
+
...input,
|
|
67
|
+
context,
|
|
68
|
+
entity: { ...input.entity, context },
|
|
69
|
+
entityId: input.entity.id.clone(input.entityId),
|
|
70
|
+
next: clone(EntityRecordSchema, input.next),
|
|
71
|
+
...(input.states === undefined
|
|
72
|
+
? {}
|
|
73
|
+
: { states: input.states.map((record) => clone(EntityRecordSchema, record)) }),
|
|
74
|
+
...(input.diagnostics === undefined
|
|
75
|
+
? {}
|
|
76
|
+
: { diagnostics: input.diagnostics.map((event) => clone(EventSchema, event)) }),
|
|
77
|
+
...(input.events === undefined
|
|
78
|
+
? {}
|
|
79
|
+
: { events: input.events.map((event) => clone(EventSchema, event)) }),
|
|
80
|
+
};
|
|
81
|
+
const backend = this.#entities.backend(snapshot.entity);
|
|
82
|
+
const work = () => backend.mutationQueue.run(ENTITY_SCOPE_MUTATION_KEY, () => this.#commit(snapshot, backend));
|
|
83
|
+
return snapshot.events === undefined || snapshot.events.length === 0
|
|
58
84
|
? work()
|
|
59
|
-
: eventStoreAccess.withLock(this.#factory,
|
|
85
|
+
: eventStoreAccess.withLock(this.#factory, snapshot.context, work);
|
|
60
86
|
}
|
|
61
87
|
/**
|
|
62
88
|
* Closes this commit handle without closing sibling handles.
|
|
@@ -64,58 +90,173 @@ export class MemoryEntityCommitStorage {
|
|
|
64
90
|
close() {
|
|
65
91
|
this.#open = false;
|
|
66
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Prepares and publishes one affected-record Entity commit under its existing queue.
|
|
95
|
+
*
|
|
96
|
+
* @typeParam I Entity identifier type.
|
|
97
|
+
* @typeParam S Entity state type.
|
|
98
|
+
* @param input Supplies current and immutable records.
|
|
99
|
+
* @param liveBackend Supplies the live current-record map and queue.
|
|
100
|
+
*/
|
|
67
101
|
async #commit(input, liveBackend) {
|
|
102
|
+
const stage = this.stage(input, liveBackend);
|
|
103
|
+
try {
|
|
104
|
+
await this.#writeStage(input, stage);
|
|
105
|
+
this.#publish(stage, liveBackend);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
stage.entity.close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Opens only record families used by one commit.
|
|
113
|
+
*
|
|
114
|
+
* @typeParam I Entity identifier type.
|
|
115
|
+
* @typeParam S Entity state type.
|
|
116
|
+
* @param input Supplies configured histories and delivery Events.
|
|
117
|
+
* @returns Live affected record families and their layouts.
|
|
118
|
+
*/
|
|
119
|
+
live(input) {
|
|
68
120
|
this.#requireEnabledHistories(input);
|
|
69
|
-
const stateLayout = input.states
|
|
70
|
-
?
|
|
71
|
-
:
|
|
72
|
-
const eventLayout = input.diagnostics
|
|
73
|
-
?
|
|
74
|
-
:
|
|
75
|
-
const
|
|
121
|
+
const stateLayout = input.states?.length
|
|
122
|
+
? stateHistorySpec(input.entity.stateSchema)
|
|
123
|
+
: undefined;
|
|
124
|
+
const eventLayout = input.diagnostics?.length
|
|
125
|
+
? eventHistorySpec(input.entity.stateSchema)
|
|
126
|
+
: undefined;
|
|
127
|
+
const states = stateLayout === undefined
|
|
76
128
|
? undefined
|
|
77
129
|
: this.#openRecords(input.context, stateLayout.spec, stateLayout.group);
|
|
78
|
-
const
|
|
130
|
+
const diagnostics = eventLayout === undefined
|
|
79
131
|
? undefined
|
|
80
132
|
: this.#openRecords(input.context, eventLayout.spec, eventLayout.group);
|
|
81
|
-
const
|
|
82
|
-
?
|
|
83
|
-
:
|
|
133
|
+
const events = input.events?.length
|
|
134
|
+
? this.#openRecords(input.context, eventStoreRecordSpec)
|
|
135
|
+
: undefined;
|
|
136
|
+
return { stateLayout, eventLayout, states, diagnostics, events };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Captures affected rows and creates isolated adapters for preparation.
|
|
140
|
+
*
|
|
141
|
+
* @typeParam I Entity identifier type.
|
|
142
|
+
* @typeParam S Entity state type.
|
|
143
|
+
* @param input Supplies the proposed record changes.
|
|
144
|
+
* @param backend Supplies the live current-record map.
|
|
145
|
+
* @returns The prepared affected-record workspace.
|
|
146
|
+
*/
|
|
147
|
+
stage(input, backend) {
|
|
148
|
+
const live = this.live(input);
|
|
149
|
+
const key = input.entity.id.key(input.entityId);
|
|
150
|
+
const previous = backend.current.get(key);
|
|
151
|
+
const ids = this.#ids(input, live);
|
|
84
152
|
const stagedBackend = {
|
|
85
|
-
current:
|
|
153
|
+
current: new Map(previous === undefined ? [] : [[key, previous]]),
|
|
86
154
|
mutationQueue: new KeyedSerialQueue(),
|
|
87
155
|
};
|
|
88
|
-
const stagedStates = InMemoryCommitValues.stage(
|
|
89
|
-
const stagedDiagnostics = InMemoryCommitValues.stage(
|
|
90
|
-
const stagedEvents = InMemoryCommitValues.stage(
|
|
91
|
-
const
|
|
156
|
+
const stagedStates = InMemoryCommitValues.stage(live.states, ids.stateIds);
|
|
157
|
+
const stagedDiagnostics = InMemoryCommitValues.stage(live.diagnostics, ids.diagnosticIds);
|
|
158
|
+
const stagedEvents = InMemoryCommitValues.stage(live.events, ids.deliveryIds);
|
|
159
|
+
const entity = new InMemoryEntityStorage(this.#stagedInput(input.entity, live.stateLayout, stagedStates, live.eventLayout, stagedDiagnostics), stagedBackend);
|
|
160
|
+
return {
|
|
161
|
+
live,
|
|
162
|
+
key,
|
|
163
|
+
previous,
|
|
164
|
+
...ids,
|
|
165
|
+
stagedBackend,
|
|
166
|
+
stagedStates,
|
|
167
|
+
stagedDiagnostics,
|
|
168
|
+
stagedEvents,
|
|
169
|
+
entity,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Materializes the storage identities and delivery rows before live application.
|
|
174
|
+
*
|
|
175
|
+
* @typeParam I Entity identifier type.
|
|
176
|
+
* @typeParam S Entity state type.
|
|
177
|
+
* @param input Supplies the changed records.
|
|
178
|
+
* @param live Supplies generated history layouts.
|
|
179
|
+
* @returns Affected keys and cloned delivery rows.
|
|
180
|
+
*/
|
|
181
|
+
#ids(input, live) {
|
|
182
|
+
const stateIds = (input.states ?? []).map((record) => {
|
|
183
|
+
const layout = live.stateLayout;
|
|
184
|
+
if (layout === undefined)
|
|
185
|
+
throw new TypeError("Cannot read properties of undefined (reading 'spec')");
|
|
186
|
+
return layout.spec.materialize(record).id;
|
|
187
|
+
});
|
|
188
|
+
const diagnosticIds = (input.diagnostics ?? []).map((event) => {
|
|
189
|
+
const layout = live.eventLayout;
|
|
190
|
+
if (layout === undefined)
|
|
191
|
+
throw new TypeError("Cannot read properties of undefined (reading 'spec')");
|
|
192
|
+
return layout.spec.materialize(event).id;
|
|
193
|
+
});
|
|
194
|
+
const materialized = (input.events ?? []).map((event) => eventStoreRecordSpec.materialize(clone(eventStoreRecordSpec.recordType, event)));
|
|
195
|
+
const deliveryIds = materialized.map((record) => record.id);
|
|
196
|
+
return { stateIds, diagnosticIds, materialized, deliveryIds };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Validates and writes only staged records before any live change.
|
|
200
|
+
*
|
|
201
|
+
* @typeParam I Entity identifier type.
|
|
202
|
+
* @typeParam S Entity state type.
|
|
203
|
+
* @param input Supplies the proposed record changes.
|
|
204
|
+
* @param stage Supplies affected-record adapters and materialized Events.
|
|
205
|
+
*/
|
|
206
|
+
async #writeStage(input, stage) {
|
|
207
|
+
const nextId = input.next.entityId === undefined ? undefined : input.entity.id.unpack(input.next.entityId);
|
|
208
|
+
if (nextId === undefined || input.entity.id.key(nextId) !== stage.key)
|
|
209
|
+
throw new Error("Entity commit current record identifies another Entity.");
|
|
210
|
+
if (new Set(stage.deliveryIds.map((id) => id.value)).size !== stage.deliveryIds.length ||
|
|
211
|
+
stage.deliveryIds.some((id) => stage.stagedEvents?.read(id) !== undefined))
|
|
212
|
+
throw new Error("Entity commit requires unique delivery-event IDs.");
|
|
213
|
+
await stage.entity.current.write(input.next);
|
|
214
|
+
for (const state of input.states ?? [])
|
|
215
|
+
await stage.entity.states.append(state);
|
|
216
|
+
for (const diagnostic of input.diagnostics ?? [])
|
|
217
|
+
await stage.entity.events.append(diagnostic);
|
|
218
|
+
stage.stagedEvents?.writeAll(stage.materialized);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Applies prepared rows synchronously and restores affected entries on failure.
|
|
222
|
+
*
|
|
223
|
+
* @param stage Supplies the complete affected-record preparation.
|
|
224
|
+
* @param backend Supplies the live current-record map.
|
|
225
|
+
*/
|
|
226
|
+
#publish(stage, backend) {
|
|
227
|
+
const changes = [
|
|
228
|
+
...InMemoryCommitValues.changes(stage.live.states, stage.stagedStates, stage.stateIds),
|
|
229
|
+
...InMemoryCommitValues.changes(stage.live.diagnostics, stage.stagedDiagnostics, stage.diagnosticIds),
|
|
230
|
+
...InMemoryCommitValues.changes(stage.live.events, stage.stagedEvents, stage.deliveryIds),
|
|
231
|
+
];
|
|
232
|
+
const next = stage.stagedBackend.current.get(stage.key);
|
|
92
233
|
try {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const delivery = [...(input.events ?? [])].map((event) => clone(eventStoreRecordSpec.recordType, event));
|
|
97
|
-
const materialized = delivery.map((event) => eventStoreRecordSpec.materialize(event));
|
|
98
|
-
const ids = materialized.map((record) => record.id);
|
|
99
|
-
if (new Set(ids.map((id) => id.value)).size !== ids.length ||
|
|
100
|
-
ids.some((id) => stagedEvents?.read(id) !== undefined)) {
|
|
101
|
-
throw new Error("Entity commit requires unique delivery-event IDs.");
|
|
102
|
-
}
|
|
103
|
-
await stagedEntity.current.write(input.next);
|
|
104
|
-
for (const state of input.states ?? [])
|
|
105
|
-
await stagedEntity.states.append(state);
|
|
106
|
-
for (const diagnostic of input.diagnostics ?? [])
|
|
107
|
-
await stagedEntity.events.append(diagnostic);
|
|
108
|
-
stagedEvents?.writeAll(materialized);
|
|
109
|
-
InMemoryCommitValues.replace(liveBackend.current, stagedBackend.current);
|
|
110
|
-
InMemoryCommitValues.publish(liveStates, stagedStates);
|
|
111
|
-
InMemoryCommitValues.publish(liveDiagnostics, stagedDiagnostics);
|
|
112
|
-
InMemoryCommitValues.publish(liveEvents, stagedEvents);
|
|
113
|
-
return "committed";
|
|
234
|
+
for (const change of changes)
|
|
235
|
+
change.apply();
|
|
236
|
+
backend.current.set(stage.key, next);
|
|
114
237
|
}
|
|
115
|
-
|
|
116
|
-
|
|
238
|
+
catch (error) {
|
|
239
|
+
if (stage.previous === undefined)
|
|
240
|
+
backend.current.delete(stage.key);
|
|
241
|
+
else
|
|
242
|
+
backend.current.set(stage.key, stage.previous);
|
|
243
|
+
for (const change of changes.reverse())
|
|
244
|
+
change.restore();
|
|
245
|
+
throw error;
|
|
117
246
|
}
|
|
118
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Connects affected staged history slices to the existing Entity adapters.
|
|
250
|
+
*
|
|
251
|
+
* @typeParam I Entity identifier type.
|
|
252
|
+
* @typeParam S Entity state type.
|
|
253
|
+
* @param entity Supplies the Entity storage layout.
|
|
254
|
+
* @param stateLayout Supplies the enabled state-history layout.
|
|
255
|
+
* @param states Supplies the affected staged state rows.
|
|
256
|
+
* @param eventLayout Supplies the enabled diagnostic-history layout.
|
|
257
|
+
* @param diagnostics Supplies the affected staged diagnostic rows.
|
|
258
|
+
* @returns The staged Entity storage layout.
|
|
259
|
+
*/
|
|
119
260
|
#stagedInput(entity, stateLayout, states, eventLayout, diagnostics) {
|
|
120
261
|
const base = { ...entity };
|
|
121
262
|
delete base.stateHistoryStorage;
|
|
@@ -134,6 +275,13 @@ export class MemoryEntityCommitStorage {
|
|
|
134
275
|
}),
|
|
135
276
|
};
|
|
136
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Rejects history rows when their corresponding history is disabled.
|
|
280
|
+
*
|
|
281
|
+
* @typeParam I Entity identifier type.
|
|
282
|
+
* @typeParam S Entity state type.
|
|
283
|
+
* @param input Supplies the requested histories.
|
|
284
|
+
*/
|
|
137
285
|
#requireEnabledHistories(input) {
|
|
138
286
|
if ((input.states?.length ?? 0) > 0 && !input.entity.stateHistory) {
|
|
139
287
|
throw new Error("Entity commit cannot append state history when it is disabled.");
|
|
@@ -142,42 +290,107 @@ export class MemoryEntityCommitStorage {
|
|
|
142
290
|
throw new Error("Entity commit cannot append event history when it is disabled.");
|
|
143
291
|
}
|
|
144
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Checks the tenant and Entity source type captured by this handle.
|
|
295
|
+
*
|
|
296
|
+
* @typeParam I Entity identifier type.
|
|
297
|
+
* @typeParam S Entity state type.
|
|
298
|
+
* @param input Supplies the requested scope.
|
|
299
|
+
*/
|
|
145
300
|
#requireCompatible(input) {
|
|
146
|
-
if (input.context.multitenant !== this.#
|
|
147
|
-
TenantBoundary.of(input.context).key !==
|
|
301
|
+
if (input.context.multitenant !== this.#multitenant ||
|
|
302
|
+
TenantBoundary.of(input.context).key !== this.#tenantKey ||
|
|
303
|
+
TenantBoundary.of(input.entity.context).key !== this.#tenantKey ||
|
|
148
304
|
input.entity.sourceType.typeName !== this.#input.sourceType.typeName) {
|
|
149
305
|
throw new Error("Entity commit handle cannot commit another Entity storage scope.");
|
|
150
306
|
}
|
|
151
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Rejects commits after this handle closes.
|
|
310
|
+
*/
|
|
152
311
|
#requireOpen() {
|
|
153
312
|
if (!this.#open)
|
|
154
313
|
throw new Error("Entity commit storage is closed.");
|
|
155
314
|
}
|
|
156
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Prepares only affected materialized rows for an in-memory commit.
|
|
318
|
+
*/
|
|
157
319
|
const InMemoryCommitValues = Object.freeze({
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Captures the affected live rows in an isolated tenant slice.
|
|
322
|
+
*
|
|
323
|
+
* @typeParam I Record identifier type.
|
|
324
|
+
* @typeParam R Record message type.
|
|
325
|
+
* @param live Supplies the live tenant slice when enabled.
|
|
326
|
+
* @param ids Identifies affected slots.
|
|
327
|
+
* @returns An isolated slice with only affected prior entries.
|
|
328
|
+
*/
|
|
329
|
+
stage(live, ids) {
|
|
164
330
|
if (live === undefined)
|
|
165
331
|
return undefined;
|
|
166
332
|
const staged = new TenantRecords();
|
|
167
|
-
|
|
333
|
+
for (const id of ids)
|
|
334
|
+
staged.apply(live.capture(id));
|
|
168
335
|
return staged;
|
|
169
336
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Builds synchronous apply and restore operations for affected slots.
|
|
339
|
+
*
|
|
340
|
+
* @typeParam I Record identifier type.
|
|
341
|
+
* @typeParam R Record message type.
|
|
342
|
+
* @param live Supplies the live tenant slice when enabled.
|
|
343
|
+
* @param staged Supplies fully prepared replacements.
|
|
344
|
+
* @param ids Identifies affected slots.
|
|
345
|
+
* @returns Operations that preserve complete prior entries and absence.
|
|
346
|
+
*/
|
|
347
|
+
changes(live, staged, ids) {
|
|
348
|
+
if (live === undefined || staged === undefined)
|
|
349
|
+
return [];
|
|
350
|
+
const seen = new Set();
|
|
351
|
+
return ids.flatMap((id) => {
|
|
352
|
+
const prior = live.capture(id);
|
|
353
|
+
if (seen.has(prior.key))
|
|
354
|
+
return [];
|
|
355
|
+
seen.add(prior.key);
|
|
356
|
+
const prepared = staged.capture(id);
|
|
357
|
+
return [new MemoryCommitChange(live, prepared, prior)];
|
|
358
|
+
});
|
|
181
359
|
},
|
|
182
360
|
});
|
|
361
|
+
/**
|
|
362
|
+
* Applies one affected materialized row and restores its complete prior slot.
|
|
363
|
+
*
|
|
364
|
+
* @typeParam I Record identifier type.
|
|
365
|
+
* @typeParam R Record message type.
|
|
366
|
+
*/
|
|
367
|
+
class MemoryCommitChange {
|
|
368
|
+
live;
|
|
369
|
+
prepared;
|
|
370
|
+
prior;
|
|
371
|
+
/**
|
|
372
|
+
* Captures the prepared and prior versions of one slot.
|
|
373
|
+
*
|
|
374
|
+
* @param live Supplies the affected tenant slice.
|
|
375
|
+
* @param prepared Supplies the replacement entry or absence.
|
|
376
|
+
* @param prior Supplies the complete prior entry or absence.
|
|
377
|
+
*/
|
|
378
|
+
constructor(live, prepared, prior) {
|
|
379
|
+
this.live = live;
|
|
380
|
+
this.prepared = prepared;
|
|
381
|
+
this.prior = prior;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Applies the fully prepared materialized row.
|
|
385
|
+
*/
|
|
386
|
+
apply() {
|
|
387
|
+
this.live.apply(this.prepared);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Restores the complete prior row or absence.
|
|
391
|
+
*/
|
|
392
|
+
restore() {
|
|
393
|
+
this.live.apply(this.prior);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
183
396
|
//# sourceMappingURL=in-memory-entity-commit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-entity-commit.js","sourceRoot":"","sources":["../../src/memory/in-memory-entity-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sEAAsE,CAAC;AAE1G,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAW7F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,0BAA0B,EAC1B,yBAAyB,GAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,GAAG,UAElB,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAC3B,SAAS,CAA6B;IACtC,QAAQ,CAAiB;IACzB,YAAY,CAII;IAChB,MAAM,CAAuC;IACtD,KAAK,GAAG,IAAI,CAAC;IAEb;;;;;;;OAOG;IACH,YACE,QA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