@spine-event-engine/storage-datastore 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 +262 -0
- package/REFERENCE.md +147 -0
- package/dist/datastore/column-mapping.d.ts +28 -0
- package/dist/datastore/column-mapping.d.ts.map +1 -0
- package/dist/datastore/column-mapping.js +141 -0
- package/dist/datastore/column-mapping.js.map +1 -0
- package/dist/datastore/delivery-cleanup.d.ts +31 -0
- package/dist/datastore/delivery-cleanup.d.ts.map +1 -0
- package/dist/datastore/delivery-cleanup.js +111 -0
- package/dist/datastore/delivery-cleanup.js.map +1 -0
- package/dist/datastore/entity-history.d.ts +82 -0
- package/dist/datastore/entity-history.d.ts.map +1 -0
- package/dist/datastore/entity-history.js +541 -0
- package/dist/datastore/entity-history.js.map +1 -0
- package/dist/datastore/id-column.d.ts +34 -0
- package/dist/datastore/id-column.d.ts.map +1 -0
- package/dist/datastore/id-column.js +103 -0
- package/dist/datastore/id-column.js.map +1 -0
- package/dist/datastore/namespace.d.ts +81 -0
- package/dist/datastore/namespace.d.ts.map +1 -0
- package/dist/datastore/namespace.js +123 -0
- package/dist/datastore/namespace.js.map +1 -0
- package/dist/datastore/record-storage.d.ts +223 -0
- package/dist/datastore/record-storage.d.ts.map +1 -0
- package/dist/datastore/record-storage.js +855 -0
- package/dist/datastore/record-storage.js.map +1 -0
- package/dist/datastore/storage-factory.d.ts +200 -0
- package/dist/datastore/storage-factory.d.ts.map +1 -0
- package/dist/datastore/storage-factory.js +224 -0
- package/dist/datastore/storage-factory.js.map +1 -0
- package/dist/datastore/tenant-catalog.d.ts +50 -0
- package/dist/datastore/tenant-catalog.d.ts.map +1 -0
- package/dist/datastore/tenant-catalog.js +154 -0
- package/dist/datastore/tenant-catalog.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.yaml +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,541 @@
|
|
|
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, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
15
|
+
import {} from "@bufbuild/protobuf/wkt";
|
|
16
|
+
import { EventSchema } from "@spine-event-engine/proto";
|
|
17
|
+
import { EntityRecordSchema, } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
|
|
18
|
+
import { eventStoreRecordSpec } from "@spine-event-engine/storage/provider";
|
|
19
|
+
import { disabledEventHistoryPort, disabledStateHistoryPort, eventHistorySpec, stateHistorySpec, } from "@spine-event-engine/storage/provider";
|
|
20
|
+
import { RecordSpec } from "@spine-event-engine/storage";
|
|
21
|
+
import { TenantBoundary } from "@spine-event-engine/storage/provider";
|
|
22
|
+
import { Datastore } from "@google-cloud/datastore";
|
|
23
|
+
import { DatastoreRecordStorage } from "./record-storage.js";
|
|
24
|
+
/**
|
|
25
|
+
* Groups Entity current and optional history record families.
|
|
26
|
+
*/
|
|
27
|
+
export class DatastoreEntityStorage {
|
|
28
|
+
// prettier-ignore
|
|
29
|
+
/**
|
|
30
|
+
* Provides access to current Entity records.
|
|
31
|
+
*/
|
|
32
|
+
current;
|
|
33
|
+
/**
|
|
34
|
+
* Provides access to retained Entity event history.
|
|
35
|
+
*/
|
|
36
|
+
events;
|
|
37
|
+
/**
|
|
38
|
+
* Provides access to retained Entity state history.
|
|
39
|
+
*/
|
|
40
|
+
states;
|
|
41
|
+
#records;
|
|
42
|
+
#open = true;
|
|
43
|
+
/**
|
|
44
|
+
* Creates storage handles for one Entity persistence contract.
|
|
45
|
+
*
|
|
46
|
+
* @param input The Entity persistence contract.
|
|
47
|
+
* @param openRecords The function that opens each generated record family.
|
|
48
|
+
*/
|
|
49
|
+
constructor(input, openRecords) {
|
|
50
|
+
const current = openRecords(input.recordSpec);
|
|
51
|
+
const states = input.stateHistory
|
|
52
|
+
? openRecords(stateHistorySpec(input.stateSchema).spec, stateHistorySpec(input.stateSchema).group)
|
|
53
|
+
: undefined;
|
|
54
|
+
const events = input.eventHistory
|
|
55
|
+
? openRecords(eventHistorySpec(input.stateSchema).spec, eventHistorySpec(input.stateSchema).group)
|
|
56
|
+
: undefined;
|
|
57
|
+
this.current = new CurrentStorage(input, current);
|
|
58
|
+
this.states =
|
|
59
|
+
states === undefined ? disabledStateHistoryPort() : new StateHistory(input, states);
|
|
60
|
+
this.events =
|
|
61
|
+
events === undefined ? disabledEventHistoryPort() : new EventHistory(input, events);
|
|
62
|
+
this.#records = [current, states, events].filter((value) => value !== undefined);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Closes all record-storage handles owned by this Entity storage.
|
|
66
|
+
*/
|
|
67
|
+
close() {
|
|
68
|
+
if (this.#open) {
|
|
69
|
+
this.#open = false;
|
|
70
|
+
for (const record of this.#records)
|
|
71
|
+
record.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns whether this Entity storage remains open.
|
|
76
|
+
*
|
|
77
|
+
* @returns `true` when this storage accepts operations.
|
|
78
|
+
*/
|
|
79
|
+
isOpen() {
|
|
80
|
+
return this.#open;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Coordinates an Entity mutation through one Datastore transaction.
|
|
85
|
+
*/
|
|
86
|
+
export class DatastoreEntityCommitStorage {
|
|
87
|
+
input;
|
|
88
|
+
openRecords;
|
|
89
|
+
#open = true;
|
|
90
|
+
/**
|
|
91
|
+
* Creates transactional commit storage for one Entity persistence contract.
|
|
92
|
+
*
|
|
93
|
+
* @param input The Entity persistence contract served by this instance.
|
|
94
|
+
* @param openRecords The function that opens generated record families.
|
|
95
|
+
*/
|
|
96
|
+
constructor(input, openRecords) {
|
|
97
|
+
this.input = input;
|
|
98
|
+
this.openRecords = openRecords;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Commits one Entity state transition and its generated history records.
|
|
102
|
+
*
|
|
103
|
+
* @param input The Entity mutation to commit.
|
|
104
|
+
* @returns The committed or conflicting outcome.
|
|
105
|
+
*/
|
|
106
|
+
async commit(input) {
|
|
107
|
+
this.validate(input);
|
|
108
|
+
const current = this.openRecords(input.entity.recordSpec);
|
|
109
|
+
const stateLayout = stateHistorySpec(input.entity.stateSchema);
|
|
110
|
+
const diagnosticLayout = eventHistorySpec(input.entity.stateSchema);
|
|
111
|
+
const states = input.entity.stateHistory
|
|
112
|
+
? this.openRecords(stateLayout.spec, stateLayout.group)
|
|
113
|
+
: undefined;
|
|
114
|
+
const diagnostics = input.entity.eventHistory
|
|
115
|
+
? this.openRecords(diagnosticLayout.spec, diagnosticLayout.group)
|
|
116
|
+
: undefined;
|
|
117
|
+
const events = this.openRecords(eventStoreRecordSpec);
|
|
118
|
+
try {
|
|
119
|
+
return await this.run(input, current, states, diagnostics, events);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
this.closeRecords(current, states, diagnostics, events);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async run(input, current, states, diagnostics, events) {
|
|
126
|
+
const prepared = this.prepare(input, current, states, diagnostics, events);
|
|
127
|
+
validateCommitSize(prepared.map((row) => row.entity));
|
|
128
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
129
|
+
try {
|
|
130
|
+
return await this.tryCommit(input, current, prepared);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (isAborted(error) && attempt < 2) {
|
|
134
|
+
await abortBackoff(attempt);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
throw entityTransactionError(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
throw new Error("Datastore transaction did not complete.");
|
|
141
|
+
}
|
|
142
|
+
prepare(input, current, states, diagnostics, events) {
|
|
143
|
+
return coalesceImmutableRows([
|
|
144
|
+
...preparedRows(current, [input.next], false),
|
|
145
|
+
...preparedRows(states, input.states ?? [], true),
|
|
146
|
+
...preparedRows(diagnostics, input.diagnostics ?? [], true),
|
|
147
|
+
...preparedRows(events, input.events ?? [], true),
|
|
148
|
+
]);
|
|
149
|
+
}
|
|
150
|
+
async tryCommit(input, current, prepared) {
|
|
151
|
+
const transaction = current.transaction();
|
|
152
|
+
try {
|
|
153
|
+
await transaction.run();
|
|
154
|
+
const values = await this.load(transaction, prepared);
|
|
155
|
+
if (await this.conflict(transaction, input, current, values))
|
|
156
|
+
return "conflict";
|
|
157
|
+
this.validateImmutable(prepared, values);
|
|
158
|
+
this.apply(transaction, prepared, values);
|
|
159
|
+
await transaction.commit();
|
|
160
|
+
return "committed";
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
await rollback(transaction);
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async load(transaction, prepared) {
|
|
168
|
+
const keys = [...uniqueKeys(prepared.map((row) => row.entity.key))].sort((left, right) => keyId(left).localeCompare(keyId(right)));
|
|
169
|
+
const values = [];
|
|
170
|
+
for (const key of keys)
|
|
171
|
+
values.push([
|
|
172
|
+
keyId(key),
|
|
173
|
+
first(await transaction.get(key)),
|
|
174
|
+
]);
|
|
175
|
+
return new Map(values);
|
|
176
|
+
}
|
|
177
|
+
async conflict(transaction, input, current, values) {
|
|
178
|
+
const live = values.get(keyId(current.transactionEntity(input.next).key));
|
|
179
|
+
const expected = input.expected === undefined ? undefined : current.transactionEntity(input.expected).data;
|
|
180
|
+
if (sameData(live, expected) || sameData(live, current.transactionEntity(input.next).data))
|
|
181
|
+
return false;
|
|
182
|
+
await transaction.rollback();
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
validateImmutable(prepared, values) {
|
|
186
|
+
for (const row of prepared.filter((item) => item.immutable)) {
|
|
187
|
+
const previous = values.get(keyId(row.entity.key));
|
|
188
|
+
if (previous !== undefined && !sameData(previous, row.entity.data))
|
|
189
|
+
throw new Error("Immutable history record has divergent content.");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
apply(transaction, prepared, values) {
|
|
193
|
+
for (const row of prepared) {
|
|
194
|
+
const previous = values.get(keyId(row.entity.key));
|
|
195
|
+
if (previous === undefined || (!row.immutable && !sameData(previous, row.entity.data)))
|
|
196
|
+
transaction.save(row.entity);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
closeRecords(current, states, diagnostics, events) {
|
|
200
|
+
current.close();
|
|
201
|
+
states?.close();
|
|
202
|
+
diagnostics?.close();
|
|
203
|
+
events.close();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Closes this commit storage to further commits.
|
|
207
|
+
*/
|
|
208
|
+
close() {
|
|
209
|
+
this.#open = false;
|
|
210
|
+
}
|
|
211
|
+
validate(input) {
|
|
212
|
+
if (!this.#open)
|
|
213
|
+
throw new Error("Entity commit storage is closed.");
|
|
214
|
+
if (input.entity.sourceType.typeName !== this.input.sourceType.typeName ||
|
|
215
|
+
TenantBoundary.of(input.context).key !== TenantBoundary.of(this.input.context).key)
|
|
216
|
+
throw new Error("Entity commit handle cannot commit another Entity source or tenant.");
|
|
217
|
+
validateCommitEntityId(input);
|
|
218
|
+
if ((input.states?.length ?? 0) > 0 && !input.entity.stateHistory)
|
|
219
|
+
throw new Error("Entity commit cannot append state history when it is disabled.");
|
|
220
|
+
if ((input.diagnostics?.length ?? 0) > 0 && !input.entity.eventHistory)
|
|
221
|
+
throw new Error("Entity commit cannot append event history when it is disabled.");
|
|
222
|
+
validateEvents(input.events ?? []);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
class CurrentStorage {
|
|
226
|
+
input;
|
|
227
|
+
records;
|
|
228
|
+
constructor(input, records) {
|
|
229
|
+
this.input = input;
|
|
230
|
+
this.records = records;
|
|
231
|
+
}
|
|
232
|
+
read(id) {
|
|
233
|
+
return this.records.read(id);
|
|
234
|
+
}
|
|
235
|
+
async write(record) {
|
|
236
|
+
const id = record.entityId === undefined ? undefined : this.input.id.unpack(record.entityId);
|
|
237
|
+
if (id === undefined)
|
|
238
|
+
throw new Error("Entity current record ID does not match its Entity ID schema.");
|
|
239
|
+
await this.records.write(record);
|
|
240
|
+
}
|
|
241
|
+
async query(plan) {
|
|
242
|
+
return (await this.records.queryPlanEntries(plan)).map((entry) => ({
|
|
243
|
+
...entry,
|
|
244
|
+
columns: new Map(this.input.columns.map((column) => [column.name, column.valueIn(entry.record)])),
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
class StateHistory {
|
|
249
|
+
input;
|
|
250
|
+
records;
|
|
251
|
+
constructor(input, records) {
|
|
252
|
+
this.input = input;
|
|
253
|
+
this.records = records;
|
|
254
|
+
}
|
|
255
|
+
append(record) {
|
|
256
|
+
this.requireOpen();
|
|
257
|
+
return immutable(this.records, record);
|
|
258
|
+
}
|
|
259
|
+
async backward(id, depth, from) {
|
|
260
|
+
this.requireOpen();
|
|
261
|
+
requireDepth(depth);
|
|
262
|
+
return this.pages([
|
|
263
|
+
entityFilter(this.input, id),
|
|
264
|
+
...(from === undefined ? [] : [numberFilter("version", "<=", from)]),
|
|
265
|
+
], [
|
|
266
|
+
{ property: "version", direction: "desc" },
|
|
267
|
+
{ property: "created", direction: "desc" },
|
|
268
|
+
], depth);
|
|
269
|
+
}
|
|
270
|
+
async stateAt(id, time) {
|
|
271
|
+
this.requireOpen();
|
|
272
|
+
const page = await this.provider().queryProviderPage({
|
|
273
|
+
filters: [entityFilter(this.input, id), timestampFilter("created", "<=", time)],
|
|
274
|
+
order: [
|
|
275
|
+
{ property: "created", direction: "desc" },
|
|
276
|
+
{ property: "version", direction: "desc" },
|
|
277
|
+
],
|
|
278
|
+
limit: 1,
|
|
279
|
+
});
|
|
280
|
+
const found = page.entries[0]?.record;
|
|
281
|
+
return found?.state === undefined
|
|
282
|
+
? undefined
|
|
283
|
+
: fromBinary(this.input.stateSchema, found.state.value);
|
|
284
|
+
}
|
|
285
|
+
async trim(id, keep) {
|
|
286
|
+
this.requireOpen();
|
|
287
|
+
requireKeep(keep);
|
|
288
|
+
for (;;) {
|
|
289
|
+
const page = await this.provider().queryProviderPage({
|
|
290
|
+
filters: [entityFilter(this.input, id)],
|
|
291
|
+
order: [
|
|
292
|
+
{ property: "version", direction: "desc" },
|
|
293
|
+
{ property: "created", direction: "desc" },
|
|
294
|
+
],
|
|
295
|
+
limit: 128,
|
|
296
|
+
});
|
|
297
|
+
const removable = page.entries.slice(keep);
|
|
298
|
+
await this.provider().deleteProviderEntries(removable);
|
|
299
|
+
if (!page.hasMore)
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async truncate(time) {
|
|
304
|
+
this.requireOpen();
|
|
305
|
+
for (;;) {
|
|
306
|
+
const page = await this.provider().queryProviderPage({
|
|
307
|
+
filters: [timestampFilter("created", "<", time)],
|
|
308
|
+
order: [
|
|
309
|
+
{ property: "created", direction: "asc" },
|
|
310
|
+
{ property: "version", direction: "asc" },
|
|
311
|
+
],
|
|
312
|
+
limit: 128,
|
|
313
|
+
});
|
|
314
|
+
await this.provider().deleteProviderEntries(page.entries);
|
|
315
|
+
if (!page.hasMore)
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
close() {
|
|
320
|
+
this.records.close();
|
|
321
|
+
}
|
|
322
|
+
provider() {
|
|
323
|
+
return this.records;
|
|
324
|
+
}
|
|
325
|
+
requireOpen() {
|
|
326
|
+
if (!this.records.isOpen())
|
|
327
|
+
throw new Error("Entity history storage is closed.");
|
|
328
|
+
}
|
|
329
|
+
async pages(filters, order, depth) {
|
|
330
|
+
const result = [];
|
|
331
|
+
let cursor;
|
|
332
|
+
for (;;) {
|
|
333
|
+
const page = await this.provider().queryProviderPage({
|
|
334
|
+
filters,
|
|
335
|
+
order,
|
|
336
|
+
...(cursor === undefined ? {} : { cursor }),
|
|
337
|
+
limit: Math.min(128, depth - result.length),
|
|
338
|
+
});
|
|
339
|
+
result.push(...page.entries.map((entry) => clone(EntityRecordSchema, entry.record)));
|
|
340
|
+
cursor = page.cursor;
|
|
341
|
+
if (!page.hasMore || result.length === depth)
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
class EventHistory {
|
|
348
|
+
input;
|
|
349
|
+
records;
|
|
350
|
+
constructor(input, records) {
|
|
351
|
+
this.input = input;
|
|
352
|
+
this.records = records;
|
|
353
|
+
}
|
|
354
|
+
append(event) {
|
|
355
|
+
this.requireOpen();
|
|
356
|
+
return immutable(this.records, event);
|
|
357
|
+
}
|
|
358
|
+
async backward(id, depth, from) {
|
|
359
|
+
this.requireOpen();
|
|
360
|
+
requireDepth(depth);
|
|
361
|
+
const result = [];
|
|
362
|
+
let cursor;
|
|
363
|
+
for (;;) {
|
|
364
|
+
const page = await this.provider().queryProviderPage({
|
|
365
|
+
filters: [
|
|
366
|
+
entityFilter(this.input, id),
|
|
367
|
+
...(from === undefined ? [] : [numberFilter("version", "<=", from)]),
|
|
368
|
+
],
|
|
369
|
+
order: [
|
|
370
|
+
{ property: "version", direction: "desc" },
|
|
371
|
+
{ property: "created", direction: "desc" },
|
|
372
|
+
],
|
|
373
|
+
...(cursor === undefined ? {} : { cursor }),
|
|
374
|
+
limit: Math.min(128, depth - result.length),
|
|
375
|
+
});
|
|
376
|
+
result.push(...page.entries.map((entry) => clone(EventSchema, entry.record)));
|
|
377
|
+
cursor = page.cursor;
|
|
378
|
+
if (!page.hasMore || result.length === depth)
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
async truncate(time) {
|
|
384
|
+
this.requireOpen();
|
|
385
|
+
for (;;) {
|
|
386
|
+
const page = await this.provider().queryProviderPage({
|
|
387
|
+
filters: [timestampFilter("created", "<", time)],
|
|
388
|
+
order: [
|
|
389
|
+
{ property: "created", direction: "asc" },
|
|
390
|
+
{ property: "version", direction: "asc" },
|
|
391
|
+
],
|
|
392
|
+
limit: 128,
|
|
393
|
+
});
|
|
394
|
+
await this.provider().deleteProviderEntries(page.entries);
|
|
395
|
+
if (!page.hasMore)
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
close() {
|
|
400
|
+
this.records.close();
|
|
401
|
+
}
|
|
402
|
+
provider() {
|
|
403
|
+
return this.records;
|
|
404
|
+
}
|
|
405
|
+
requireOpen() {
|
|
406
|
+
if (!this.records.isOpen())
|
|
407
|
+
throw new Error("Entity history storage is closed.");
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
async function immutable(records, record) {
|
|
411
|
+
const id = records.recordSpec.idValueIn(record);
|
|
412
|
+
if (await records.compareAndSet(id, undefined, record))
|
|
413
|
+
return;
|
|
414
|
+
const existing = await records.read(id);
|
|
415
|
+
if (existing === undefined)
|
|
416
|
+
throw new Error("Immutable history record was not retained.");
|
|
417
|
+
if (!same(toBinary(records.recordSpec.recordType, existing), toBinary(records.recordSpec.recordType, record)))
|
|
418
|
+
throw new Error("Immutable history record has divergent content.");
|
|
419
|
+
}
|
|
420
|
+
function preparedRows(storage, records, immutable) {
|
|
421
|
+
if (storage === undefined) {
|
|
422
|
+
if (records.length > 0)
|
|
423
|
+
throw new Error("Entity commit history is disabled.");
|
|
424
|
+
return [];
|
|
425
|
+
}
|
|
426
|
+
return records.map((record) => ({
|
|
427
|
+
storage,
|
|
428
|
+
record,
|
|
429
|
+
immutable,
|
|
430
|
+
entity: storage.transactionEntity(record),
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
function coalesceImmutableRows(rows) {
|
|
434
|
+
const seen = new Map();
|
|
435
|
+
return rows.filter((row) => {
|
|
436
|
+
if (!row.immutable)
|
|
437
|
+
return true;
|
|
438
|
+
const previous = seen.get(keyId(row.entity.key));
|
|
439
|
+
if (previous === undefined) {
|
|
440
|
+
seen.set(keyId(row.entity.key), row);
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
if (!sameData(previous.entity.data, row.entity.data))
|
|
444
|
+
throw new Error("Immutable history record has divergent content.");
|
|
445
|
+
return false;
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function same(left, right) {
|
|
449
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
450
|
+
}
|
|
451
|
+
function requireDepth(value) {
|
|
452
|
+
if (!Number.isSafeInteger(value) || value <= 0)
|
|
453
|
+
throw new Error("History depth must be a positive safe integer.");
|
|
454
|
+
}
|
|
455
|
+
function requireKeep(value) {
|
|
456
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
457
|
+
throw new Error("History retention must be a non-negative safe integer.");
|
|
458
|
+
}
|
|
459
|
+
function entityFilter(input, id) {
|
|
460
|
+
return { property: "entity_id", operator: "=", value: input.id.pack(id) };
|
|
461
|
+
}
|
|
462
|
+
function numberFilter(property, operator, value) {
|
|
463
|
+
return { property, operator, value };
|
|
464
|
+
}
|
|
465
|
+
function timestampFilter(property, operator, value) {
|
|
466
|
+
return { property, operator, value };
|
|
467
|
+
}
|
|
468
|
+
function first(value) {
|
|
469
|
+
return Array.isArray(value) ? value[0] : undefined;
|
|
470
|
+
}
|
|
471
|
+
function keyId(key) {
|
|
472
|
+
return JSON.stringify(key);
|
|
473
|
+
}
|
|
474
|
+
function uniqueKeys(keys) {
|
|
475
|
+
return [...new Map(keys.map((key) => [keyId(key), key])).values()];
|
|
476
|
+
}
|
|
477
|
+
function sameData(left, right) {
|
|
478
|
+
if (left === undefined || right === undefined)
|
|
479
|
+
return left === right;
|
|
480
|
+
const bytes = left.bytes;
|
|
481
|
+
return (bytes instanceof Uint8Array && right.bytes instanceof Uint8Array && same(bytes, right.bytes));
|
|
482
|
+
}
|
|
483
|
+
function isAborted(error) {
|
|
484
|
+
return typeof error === "object" && error !== null && Reflect.get(error, "code") === 10;
|
|
485
|
+
}
|
|
486
|
+
function entityTransactionError(error) {
|
|
487
|
+
if (error instanceof Error && error.message.startsWith("Immutable history record"))
|
|
488
|
+
return error;
|
|
489
|
+
return new Error("Datastore Entity transaction failed.");
|
|
490
|
+
}
|
|
491
|
+
function abortBackoff(attempt) {
|
|
492
|
+
const delayMs = 20 * (attempt + 1) + Math.floor(Math.random() * 40);
|
|
493
|
+
return new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
494
|
+
}
|
|
495
|
+
async function rollback(transaction) {
|
|
496
|
+
try {
|
|
497
|
+
await transaction.rollback();
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
/* original provider error remains authoritative */
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function validateCommitSize(rows) {
|
|
504
|
+
if (rows.length > 500)
|
|
505
|
+
throw new Error("Entity commit exceeds the 500-mutation limit.");
|
|
506
|
+
if (uniqueKeys(rows.map((row) => row.key)).length > 25)
|
|
507
|
+
throw new Error("Entity commit exceeds the 25 entity-group limit.");
|
|
508
|
+
const bytes = rows.reduce((total, row) => total +
|
|
509
|
+
Buffer.byteLength(JSON.stringify(row.data, (_key, value) => value instanceof Uint8Array
|
|
510
|
+
? Buffer.from(value).toString("base64")
|
|
511
|
+
: typeof value === "bigint"
|
|
512
|
+
? value.toString()
|
|
513
|
+
: value), "utf8"), 0);
|
|
514
|
+
if (bytes > 9 * 1024 * 1024)
|
|
515
|
+
throw new Error("Entity commit exceeds the transaction payload limit.");
|
|
516
|
+
}
|
|
517
|
+
function validateEvents(events) {
|
|
518
|
+
const ids = events.map((event) => event.id?.value);
|
|
519
|
+
if (ids.some((id) => id === undefined || id.trim().length === 0) ||
|
|
520
|
+
new Set(ids).size !== ids.length)
|
|
521
|
+
throw new Error("Entity commit requires non-blank unique delivery-event IDs.");
|
|
522
|
+
}
|
|
523
|
+
function validateCommitEntityId(input) {
|
|
524
|
+
const nextId = input.next.entityId === undefined ? undefined : input.entity.id.unpack(input.next.entityId);
|
|
525
|
+
if (nextId === undefined || input.entity.id.key(nextId) !== input.entity.id.key(input.entityId))
|
|
526
|
+
throw new Error("Entity commit current record ID does not match the committed Entity ID.");
|
|
527
|
+
for (const record of input.states ?? []) {
|
|
528
|
+
const stateId = record.entityId === undefined ? undefined : input.entity.id.unpack(record.entityId);
|
|
529
|
+
if (stateId === undefined ||
|
|
530
|
+
input.entity.id.key(stateId) !== input.entity.id.key(input.entityId))
|
|
531
|
+
throw new Error("Entity commit state-history record ID does not match the committed Entity ID.");
|
|
532
|
+
}
|
|
533
|
+
for (const event of input.diagnostics ?? []) {
|
|
534
|
+
const producer = event.context?.producerId;
|
|
535
|
+
const eventId = producer === undefined ? undefined : input.entity.id.unpack(producer);
|
|
536
|
+
if (eventId === undefined ||
|
|
537
|
+
input.entity.id.key(eventId) !== input.entity.id.key(input.entityId))
|
|
538
|
+
throw new Error("Entity commit diagnostic event ID does not match the committed Entity ID.");
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
//# sourceMappingURL=entity-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-history.js","sourceRoot":"","sources":["../../src/datastore/entity-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAkB,MAAM,wBAAwB,CAAC;AACx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"@spine-event-engine/core";
|
|
4
|
+
type DatastoreIdType<I> = I extends Message ? GenMessage<I> : string;
|
|
5
|
+
/**
|
|
6
|
+
* Converts a declared record ID to and from a Spine JVM Datastore key name.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DatastoreIdColumn<I> {
|
|
9
|
+
#private;
|
|
10
|
+
private readonly type;
|
|
11
|
+
/**
|
|
12
|
+
* Creates the ID conversion.
|
|
13
|
+
*
|
|
14
|
+
* @param type The generated message schema or supported primitive ID kind.
|
|
15
|
+
* @param stringifiers The schema-bound message stringifiers.
|
|
16
|
+
*/
|
|
17
|
+
constructor(type: DatastoreIdType<I>, stringifiers?: StringifierRegistry);
|
|
18
|
+
/**
|
|
19
|
+
* Converts a logical ID to a Datastore key name.
|
|
20
|
+
*
|
|
21
|
+
* @param id The logical record identifier.
|
|
22
|
+
* @returns The JVM-compatible key name.
|
|
23
|
+
*/
|
|
24
|
+
value(id: I): string;
|
|
25
|
+
/**
|
|
26
|
+
* Restores a logical ID from a Datastore key name.
|
|
27
|
+
*
|
|
28
|
+
* @param value The Datastore key name.
|
|
29
|
+
* @returns The restored record identifier.
|
|
30
|
+
*/
|
|
31
|
+
read(value: string): I;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=id-column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-column.d.ts","sourceRoot":"","sources":["../../src/datastore/id-column.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAErE;;GAEG;AACH,qBAAa,iBAAiB,CAAC,CAAC;;IAU5B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAPvB;;;;;OAKG;gBAEgB,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EACzC,YAAY,GAAE,mBAA+C;IAM/D;;;;;OAKG;IACH,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM;IAQpB;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC;CAqBvB"}
|