@spine-event-engine/storage-datastore 2.0.0-snapshot.22 → 2.0.0-snapshot.24
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 +8 -2
- package/REFERENCE.md +55 -11
- package/dist/datastore/agent-execution.d.ts +337 -0
- package/dist/datastore/agent-execution.d.ts.map +1 -0
- package/dist/datastore/agent-execution.js +789 -0
- package/dist/datastore/agent-execution.js.map +1 -0
- package/dist/datastore/agent-history.d.ts +108 -0
- package/dist/datastore/agent-history.d.ts.map +1 -0
- package/dist/datastore/agent-history.js +219 -0
- package/dist/datastore/agent-history.js.map +1 -0
- package/dist/datastore/entity-history.d.ts +22 -65
- package/dist/datastore/entity-history.d.ts.map +1 -1
- package/dist/datastore/entity-history.js +83 -247
- package/dist/datastore/entity-history.js.map +1 -1
- package/dist/datastore/record-storage.d.ts +24 -0
- package/dist/datastore/record-storage.d.ts.map +1 -1
- package/dist/datastore/record-storage.js +46 -7
- package/dist/datastore/record-storage.js.map +1 -1
- package/dist/datastore/storage-factory.d.ts +110 -6
- package/dist/datastore/storage-factory.d.ts.map +1 -1
- package/dist/datastore/storage-factory.js +261 -8
- package/dist/datastore/storage-factory.js.map +1 -1
- package/dist/datastore/tenant-catalog.d.ts +9 -1
- package/dist/datastore/tenant-catalog.d.ts.map +1 -1
- package/dist/datastore/tenant-catalog.js +225 -1
- package/dist/datastore/tenant-catalog.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.yaml +24 -1
- package/package.json +5 -5
- package/dist/datastore/delivery-cleanup.d.ts +0 -31
- package/dist/datastore/delivery-cleanup.d.ts.map +0 -1
- package/dist/datastore/delivery-cleanup.js +0 -111
- package/dist/datastore/delivery-cleanup.js.map +0 -1
package/index.yaml
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
indexes:
|
|
1
|
+
indexes:
|
|
2
|
+
- kind: spine_agent_history
|
|
3
|
+
properties:
|
|
4
|
+
- name: scope_digest
|
|
5
|
+
- name: order_key
|
|
6
|
+
- kind: spine_agent_history
|
|
7
|
+
properties:
|
|
8
|
+
- name: scope_digest
|
|
9
|
+
- name: category
|
|
10
|
+
- name: order_key
|
|
11
|
+
- kind: spine_agent_history
|
|
12
|
+
properties:
|
|
13
|
+
- name: scope_digest
|
|
14
|
+
- name: conversation_digest
|
|
15
|
+
- name: order_key
|
|
16
|
+
- kind: spine_agent_execution_head
|
|
17
|
+
properties:
|
|
18
|
+
- name: state_digest
|
|
19
|
+
- name: pending_key
|
|
20
|
+
- kind: spine_agent_execution
|
|
21
|
+
properties:
|
|
22
|
+
- name: scope_digest
|
|
23
|
+
- name: status
|
|
24
|
+
- name: order_key
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spine-event-engine/storage-datastore",
|
|
3
|
-
"version": "2.0.0-snapshot.
|
|
3
|
+
"version": "2.0.0-snapshot.24",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@bufbuild/protobuf": "2.12.1",
|
|
30
30
|
"@google-cloud/datastore": "10.1.1",
|
|
31
|
-
"@spine-event-engine/core": "2.0.0-snapshot.
|
|
32
|
-
"@spine-event-engine/proto": "2.0.0-snapshot.
|
|
33
|
-
"@spine-event-engine/storage": "2.0.0-snapshot.
|
|
31
|
+
"@spine-event-engine/core": "2.0.0-snapshot.24",
|
|
32
|
+
"@spine-event-engine/proto": "2.0.0-snapshot.24",
|
|
33
|
+
"@spine-event-engine/storage": "2.0.0-snapshot.24"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"inventory:legacy": "node scripts/inventory-legacy-layout.mjs",
|
|
37
|
-
"test:emulator": "node scripts/verify-emulator-config.mjs && SPINE_TS_INBOX_PROVIDER=datastore pnpm --config.verify-deps-before-run=false exec vitest --root ../.. --config vitest.infrastructure.config.ts run packages/storage-datastore/test/datastore-emulator.test.ts packages/server/test/delivery/inbox-provider-cleanup.test.ts",
|
|
37
|
+
"test:emulator": "node scripts/verify-emulator-config.mjs && SPINE_TS_INBOX_PROVIDER=datastore pnpm --config.verify-deps-before-run=false exec vitest --root ../.. --config vitest.infrastructure.config.ts run packages/storage-datastore/test/datastore-emulator.test.ts packages/storage-datastore/test/datastore-agent-history.test.ts packages/storage-datastore/test/datastore-agent-execution.test.ts packages/server/test/delivery/inbox-provider-cleanup.test.ts",
|
|
38
38
|
"test:cloud": "node scripts/verify-cloud-config.mjs && pnpm --config.verify-deps-before-run=false exec vitest --root ../.. --config vitest.infrastructure.config.ts run packages/storage-datastore/test/datastore-cloud.test.ts"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Message } from "@bufbuild/protobuf";
|
|
2
|
-
import { type DeliveryCleanupInput, type DeliveryCleanupStorage } from "@spine-event-engine/storage/provider";
|
|
3
|
-
import type { RecordSpec, StorageContext } from "@spine-event-engine/storage";
|
|
4
|
-
import { DatastoreRecordStorage } from "./record-storage.js";
|
|
5
|
-
/**
|
|
6
|
-
* Coordinates one fenced delivered Inbox deletion in Datastore.
|
|
7
|
-
*/
|
|
8
|
-
export declare class DatastoreDeliveryCleanupStorage implements DeliveryCleanupStorage {
|
|
9
|
-
#private;
|
|
10
|
-
private readonly openStorage;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a Datastore cleanup coordinator.
|
|
13
|
-
*
|
|
14
|
-
* @param openStorage Opens a record-storage handle for one record family.
|
|
15
|
-
*/
|
|
16
|
-
constructor(openStorage: <I, R extends Message>(context: StorageContext, spec: RecordSpec<I, R>) => DatastoreRecordStorage<I, R>);
|
|
17
|
-
/**
|
|
18
|
-
* Removes an exact Inbox entity after validating its session entity in one transaction.
|
|
19
|
-
*
|
|
20
|
-
* @param input Describes the records and ownership predicate for deletion.
|
|
21
|
-
* @returns Whether the transaction deleted the exact Inbox entity.
|
|
22
|
-
*/
|
|
23
|
-
remove<InboxId, InboxRecord extends Message, SessionId, SessionRecord extends Message>(input: DeliveryCleanupInput<InboxId, InboxRecord, SessionId, SessionRecord>): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Closes this cleanup coordinator to further removal operations.
|
|
26
|
-
*/
|
|
27
|
-
close(): void;
|
|
28
|
-
private static first;
|
|
29
|
-
private static active;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=delivery-cleanup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-cleanup.d.ts","sourceRoot":"","sources":["../../src/datastore/delivery-cleanup.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,qBAAa,+BAAgC,YAAW,sBAAsB;;IAS1E,OAAO,CAAC,QAAQ,CAAC,WAAW;IAN9B;;;;OAIG;gBAEgB,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EACjD,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KACnB,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC;IAGnC;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,WAAW,SAAS,OAAO,EAAE,SAAS,EAAE,aAAa,SAAS,OAAO,EACzF,KAAK,EAAE,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,GAC1E,OAAO,CAAC,OAAO,CAAC;IA8DnB;;OAEG;IACH,KAAK,IAAI,IAAI;IAGb,OAAO,CAAC,MAAM,CAAC,KAAK;IAQpB,OAAO,CAAC,MAAM,CAAC,MAAM;CAGtB"}
|
|
@@ -1,111 +0,0 @@
|
|
|
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 { cleanupOperationActive, } from "@spine-event-engine/storage/provider";
|
|
15
|
-
import { DatastoreRecordStorage } from "./record-storage.js";
|
|
16
|
-
/**
|
|
17
|
-
* Coordinates one fenced delivered Inbox deletion in Datastore.
|
|
18
|
-
*/
|
|
19
|
-
export class DatastoreDeliveryCleanupStorage {
|
|
20
|
-
openStorage;
|
|
21
|
-
#open = true;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a Datastore cleanup coordinator.
|
|
24
|
-
*
|
|
25
|
-
* @param openStorage Opens a record-storage handle for one record family.
|
|
26
|
-
*/
|
|
27
|
-
constructor(openStorage) {
|
|
28
|
-
this.openStorage = openStorage;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Removes an exact Inbox entity after validating its session entity in one transaction.
|
|
32
|
-
*
|
|
33
|
-
* @param input Describes the records and ownership predicate for deletion.
|
|
34
|
-
* @returns Whether the transaction deleted the exact Inbox entity.
|
|
35
|
-
*/
|
|
36
|
-
async remove(input) {
|
|
37
|
-
if (!this.#open)
|
|
38
|
-
throw new Error("Delivery cleanup storage is closed.");
|
|
39
|
-
if (!DatastoreDeliveryCleanupStorage.active(input))
|
|
40
|
-
return false;
|
|
41
|
-
const inbox = this.openStorage(input.context, input.inbox.spec);
|
|
42
|
-
const sessions = this.openStorage(input.context, input.session.spec);
|
|
43
|
-
const transaction = sessions.transaction();
|
|
44
|
-
try {
|
|
45
|
-
await transaction.run();
|
|
46
|
-
const sessionEntity = DatastoreDeliveryCleanupStorage.first(await transaction.get(sessions.transactionEntity(input.session.expected).key));
|
|
47
|
-
if (!DatastoreDeliveryCleanupStorage.active(input)) {
|
|
48
|
-
await transaction.rollback();
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (sessionEntity === undefined ||
|
|
52
|
-
!sessions.matchesTransactionEntity(sessionEntity, input.session.expected) ||
|
|
53
|
-
!input.session.isCurrent(sessions.decodeTransactionEntity(sessionEntity))) {
|
|
54
|
-
await transaction.rollback();
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
const expectedInbox = inbox.transactionEntity(input.inbox.expected);
|
|
58
|
-
const inboxEntity = DatastoreDeliveryCleanupStorage.first(await transaction.get(expectedInbox.key));
|
|
59
|
-
if (inboxEntity === undefined ||
|
|
60
|
-
!inbox.matchesTransactionEntity(inboxEntity, input.inbox.expected)) {
|
|
61
|
-
await transaction.rollback();
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
if (!input.session.isCurrent(sessions.decodeTransactionEntity(sessionEntity))) {
|
|
65
|
-
await transaction.rollback();
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
if (!DatastoreDeliveryCleanupStorage.active(input)) {
|
|
69
|
-
await transaction.rollback();
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
transaction.delete(expectedInbox.key);
|
|
73
|
-
if (!input.session.isCurrent(sessions.decodeTransactionEntity(sessionEntity))) {
|
|
74
|
-
await transaction.rollback();
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (!DatastoreDeliveryCleanupStorage.active(input)) {
|
|
78
|
-
await transaction.rollback();
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
await transaction.commit();
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
await transaction.rollback().catch(() => undefined);
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
finally {
|
|
89
|
-
inbox.close();
|
|
90
|
-
sessions.close();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Closes this cleanup coordinator to further removal operations.
|
|
95
|
-
*/
|
|
96
|
-
close() {
|
|
97
|
-
this.#open = false;
|
|
98
|
-
}
|
|
99
|
-
static first(value) {
|
|
100
|
-
return Array.isArray(value) &&
|
|
101
|
-
value.length > 0 &&
|
|
102
|
-
typeof value[0] === "object" &&
|
|
103
|
-
value[0] !== null
|
|
104
|
-
? value[0]
|
|
105
|
-
: undefined;
|
|
106
|
-
}
|
|
107
|
-
static active(input) {
|
|
108
|
-
return cleanupOperationActive(input.operation);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=delivery-cleanup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-cleanup.js","sourceRoot":"","sources":["../../src/datastore/delivery-cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EACL,sBAAsB,GAIvB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,+BAA+B;IASvB;IARnB,KAAK,GAAG,IAAI,CAAC;IAEb;;;;OAIG;IACH,YACmB,WAGgB;QAHhB,gBAAW,GAAX,WAAW,CAGK;IAChC,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CACV,KAA2E;QAE3E,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,MAA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