@spine-event-engine/storage-datastore 2.0.0-snapshot.2 → 2.0.0-snapshot.21

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 CHANGED
@@ -5,6 +5,9 @@ Datastore, including Firestore in Datastore mode. It implements the storage
5
5
  contract from `@spine-event-engine/storage`; it does not use Firestore Native
6
6
  APIs.
7
7
 
8
+ This is an experimental snapshot package. Use Node 24 or newer, generated
9
+ record schemas, and a configured Google Datastore client.
10
+
8
11
  For exact query limits, entity-storage behavior, and failure handling, see
9
12
  [REFERENCE documentation for agents](REFERENCE.md).
10
13
 
@@ -16,29 +19,57 @@ For exact query limits, entity-storage behavior, and failure handling, see
16
19
  - ✅ Rejects queries that exceed a finite reconciliation budget instead of
17
20
  returning incomplete results.
18
21
 
19
- ## 🚀 Build it in this workspace
22
+ ## 🚀 First snapshot success
20
23
 
21
24
  ```sh
22
- pnpm typecheck:build
25
+ mkdir spine-datastore-app && cd spine-datastore-app
26
+ pnpm init
27
+ pnpm add @spine-event-engine/storage-datastore@snapshot @spine-event-engine/storage@snapshot @bufbuild/protobuf @google-cloud/datastore
23
28
  ```
24
29
 
25
- Run this workspace-wide TypeScript build from the repository root. For an
26
- experimental npm consumer, install
27
- `@spine-event-engine/storage-datastore@2.0.0-snapshot.2` or the explicit
28
- `@spine-event-engine/storage-datastore@snapshot` tag.
30
+ Create a `storage.ts` file from the factory example below, replace `my-project`
31
+ with a Google Cloud project that you can access, and run it with Node 24 or
32
+ newer. A successful read of `task-42` proves the installed snapshot can create,
33
+ write, and read a Datastore record. The snapshot tag can change before a stable
34
+ release.
29
35
 
30
36
  ## 🔌 Create a factory
31
37
 
32
38
  Give the adapter an already configured Datastore client when the application
33
39
  controls Google authentication and client lifetime.
34
40
 
41
+ <!-- docs-snippet-path: packages/storage-datastore/src/index.ts -->
42
+
35
43
  ```ts
36
44
  import { Datastore } from "@google-cloud/datastore";
45
+ import { create, ScalarType } from "@bufbuild/protobuf";
46
+ import { StringValueSchema, type StringValue } from "@bufbuild/protobuf/wkt";
47
+ import { ColumnTypes, RecordColumn, RecordSpec } from "@spine-event-engine/storage";
37
48
  import { DatastoreStorageFactory } from "@spine-event-engine/storage-datastore";
38
49
 
39
50
  const factory = DatastoreStorageFactory.newBuilder()
40
51
  .setClient(new Datastore({ projectId: "my-project" }))
41
52
  .build();
53
+ const records = factory.createRecordStorage(
54
+ { name: "Tasks", multitenant: false },
55
+ new RecordSpec<string, StringValue>({
56
+ recordType: StringValueSchema,
57
+ idKind: "string",
58
+ extractId: (record) => record.value,
59
+ columns: [
60
+ new RecordColumn("value", ColumnTypes.scalar(ScalarType.STRING), (record) => record.value),
61
+ ],
62
+ }),
63
+ );
64
+
65
+ try {
66
+ await records.write(create(StringValueSchema, { value: "task-42" }));
67
+ const stored = await records.read("task-42");
68
+ if (stored?.value !== "task-42") throw new Error("The record was not stored.");
69
+ } finally {
70
+ await records.close();
71
+ factory.close();
72
+ }
42
73
  ```
43
74
 
44
75
  The builder always uses a client supplied by the caller. Its fixed finite reconciliation
@@ -47,6 +78,15 @@ through the normal storage API. When application values contain `Any`, configure
47
78
  a `StringifierRegistry` with that application's `TypeRegistry` before building;
48
79
  the layout section below explains why that mapping must remain reversible.
49
80
 
81
+ ## Build it in this workspace
82
+
83
+ Contributors changing this repository can run the workspace-wide build from its
84
+ root:
85
+
86
+ ```sh
87
+ pnpm typecheck:build
88
+ ```
89
+
50
90
  ## 🧭 Understand tenants and kinds
51
91
 
52
92
  Datastore uses its native namespace as the tenant boundary. By default, Spine
@@ -109,7 +149,7 @@ mapping is used for writes, key lookups, filters, ordering continuations, and
109
149
  reads. Primitive values use their native Datastore representation. There is no
110
150
  `_scope`, copied ID, storage revision, fingerprint, marker, or compatibility
111
151
  entity. The runnable configuration is in the
112
- [Message Board deployment](../../examples/message-board/app/src/deployment-config.ts).
152
+ [Message Board deployment](https://github.com/SpineEventEngine/spine-ts/blob/master/examples/message-board/app/src/deployment-config.ts).
113
153
 
114
154
  When a user queries `board == BoardId("board-7")`, Spine converts that generated
115
155
  `BoardId` with the same stringifier and sends a Datastore property filter for
@@ -217,6 +257,6 @@ kind, and key. The runtime never chooses a winner.
217
257
 
218
258
  ## 🔗 Learn more
219
259
 
220
- - [Storage API](../storage/README.md)
221
- - [Datastore guide](../../docs/USER_GUIDE.md#12-develop-with-google-cloud-datastore)
260
+ - [Storage API](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage/README.md)
261
+ - [Datastore guide](https://github.com/SpineEventEngine/spine-ts/blob/master/docs/USER_GUIDE.md#6-persist-application-data)
222
262
  - [Reference for coding agents](REFERENCE.md)
package/REFERENCE.md CHANGED
@@ -89,7 +89,7 @@ histories allocate no record handle or Datastore row.
89
89
 
90
90
  Queries run inside the selected native namespace. Normalized plans admit only
91
91
  IDs (up to Datastore's legal key filter bound), equality, one inequality column,
92
- flat conjunction, inequality-compatible ordering, limit, and mask. Nested or
92
+ flat conjunction, inequality-compatible ordering, and limit. Nested or
93
93
  disjunctive predicates, oversized key sets, and illegal inequality/order shapes
94
94
  reject before provider access; they never trigger an unfiltered reconciliation
95
95
  read.
@@ -109,12 +109,14 @@ This is deliberately the overlap, not MySQL parity: nested or disjunctive
109
109
  predicates and provider-illegal inequality/order shapes reject before provider
110
110
  access. Normalized plans have no offset; `RecordQuery.offset` is separate.
111
111
 
112
- The internal Entity commit reads current and immutable keys then applies current,
113
- enabled histories, and delivery events in one Datastore transaction. It rejects
114
- more than 25 entity groups, 500 mutations, or its conservative transaction-size
115
- limit before opening the transaction. Current mismatch returns `conflict`.
116
- An already-applied identical retry returns `committed`; divergent immutable
117
- content fails. Only ABORTED provider failures retry, for at most three attempts.
112
+ The provider Entity commit writes the supplied current record, enabled histories,
113
+ and delivery events in one Datastore transaction. It does not compare current
114
+ state with an expected previous record. The operation rejects more than 25
115
+ entity groups, 500 mutations, or its conservative transaction-size limit before
116
+ opening the transaction. Success resolves without a value. Identical immutable
117
+ retries remain accepted; divergent immutable content fails. Associated records
118
+ are still completed when the current record already matches the supplied value.
119
+ Only ABORTED provider failures retry, for at most three attempts.
118
120
 
119
121
  History reads use stable finite keyset pages. State history provides backward,
120
122
  state-at-time, trim, and truncate behavior; event history provides backward and
@@ -1,5 +1,5 @@
1
1
  import type { Message } from "@bufbuild/protobuf";
2
- import { type DeliveryCleanupInput, type DeliveryCleanupStorage } from "@spine-event-engine/storage/internal/delivery-cleanup";
2
+ import { type DeliveryCleanupInput, type DeliveryCleanupStorage } from "@spine-event-engine/storage/provider";
3
3
  import type { RecordSpec, StorageContext } from "@spine-event-engine/storage";
4
4
  import { DatastoreRecordStorage } from "./record-storage.js";
5
5
  /**
@@ -1 +1 @@
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,uDAAuD,CAAC;AAC/D,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
+ {"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"}
@@ -11,7 +11,7 @@
11
11
  * or implied. See the License for the specific language governing permissions and limitations under
12
12
  * the License.
13
13
  */
14
- import { cleanupOperationActive, } from "@spine-event-engine/storage/internal/delivery-cleanup";
14
+ import { cleanupOperationActive, } from "@spine-event-engine/storage/provider";
15
15
  import { DatastoreRecordStorage } from "./record-storage.js";
16
16
  /**
17
17
  * Coordinates one fenced delivered Inbox deletion in Datastore.
@@ -1 +1 @@
1
- {"version":3,"file":"delivery-cleanup.js","sourceRoot":"","sources":["../../src/datastore/delivery-cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EACL,sBAAsB,GAIvB,MAAM,uDAAuD,CAAC;AAG/D,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,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxE,IAAI,CAAC,+BAA+B,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC3C,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,GAAG,EAAE,CAAC;YACxB,MAAM,aAAa,GAAG,+BAA+B,CAAC,KAAK,CACzD,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAA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O,CAAC,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;gBAC9E,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC7B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,CAAC,+BAA+B,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnD,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC7B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACpD,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IACO,MAAM,CAAC,KAAK,CAAC,KAAc;QACjC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACzB,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ;YAC5B,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;YACjB,CAAC,CAAE,KAAK,CAAC,CAAC,CAAsC;YAChD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IACO,MAAM,CAAC,MAAM,CAAC,KAAgD;QACpE,OAAO,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC;CACF"}
@@ -1,9 +1,11 @@
1
1
  import { type Message } from "@bufbuild/protobuf";
2
- import { type EntityCommitInput, type EntityCommitResult, type EntityCommitStorage, type EntityEventHistoryPort, type EntityRecordStorage, type EntityStateHistoryPort, type EntityStorageInput } from "@spine-event-engine/storage/internal/entity-history";
2
+ import { type EntityCommitInput, type EntityCommitStorage, type EntityEventHistoryPort, type EntityRecordStorage, type EntityStateHistoryPort, type EntityStorageInput } from "@spine-event-engine/storage/provider";
3
3
  import { RecordSpec, type RecordStorage } from "@spine-event-engine/storage";
4
4
  /**
5
5
  * Opens one generated record family with its resolved Datastore layout.
6
6
  *
7
+ * @typeParam I Record identifier type.
8
+ * @typeParam R Stored Protobuf message type.
7
9
  * @param spec The generated record-family contract.
8
10
  * @param group The optional generated storage group.
9
11
  * @returns The opened record-storage handle.
@@ -11,6 +13,9 @@ import { RecordSpec, type RecordStorage } from "@spine-event-engine/storage";
11
13
  export type OpenEntityRecords = <I, R extends Message>(spec: RecordSpec<I, R>, group?: import("@spine-event-engine/storage").StorageGroup) => RecordStorage<I, R>;
12
14
  /**
13
15
  * Groups Entity current and optional history record families.
16
+ *
17
+ * @typeParam I Entity identifier type.
18
+ * @typeParam S Entity state message type.
14
19
  */
15
20
  export declare class DatastoreEntityStorage<I, S extends Message> {
16
21
  #private;
@@ -61,22 +66,89 @@ export declare class DatastoreEntityCommitStorage implements EntityCommitStorage
61
66
  /**
62
67
  * Commits one Entity state transition and its generated history records.
63
68
  *
69
+ * @typeParam I Entity identifier type.
70
+ * @typeParam S Entity state message type.
64
71
  * @param input The Entity mutation to commit.
65
- * @returns The committed or conflicting outcome.
72
+ * @returns Completion after Datastore commits the mutation.
73
+ */
74
+ commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<void>;
75
+ /**
76
+ * Retries the prepared Datastore transaction after bounded aborts.
77
+ *
78
+ * @typeParam I Entity identifier type.
79
+ * @typeParam S Entity state type.
80
+ * @param input Supplies current and immutable records.
81
+ * @param current Provides current Entity storage.
82
+ * @param states Provides state history when enabled.
83
+ * @param diagnostics Provides diagnostic history when enabled.
84
+ * @param events Provides delivery Event storage.
85
+ * @returns Completion after a successful transaction.
66
86
  */
67
- commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<EntityCommitResult>;
68
87
  private run;
88
+ /**
89
+ * Builds affected rows before opening a transaction.
90
+ *
91
+ * @typeParam I Entity identifier type.
92
+ * @param input Supplies records to materialize.
93
+ * @param current Provides current Entity storage.
94
+ * @param states Provides state history when enabled.
95
+ * @param diagnostics Provides diagnostic history when enabled.
96
+ * @param events Provides delivery Event storage.
97
+ * @returns Deduplicated rows for the transaction.
98
+ */
69
99
  private prepare;
100
+ /**
101
+ * Applies one prepared transaction attempt and rolls back on failure.
102
+ *
103
+ * @typeParam I Entity identifier type.
104
+ * @param current Opens a transaction for the Entity scope.
105
+ * @param prepared Supplies current and immutable rows.
106
+ * @returns Completion after the transaction commits.
107
+ */
70
108
  private tryCommit;
109
+ /**
110
+ * Loads affected keys in stable order within one transaction.
111
+ *
112
+ * @param transaction Supplies the active Datastore transaction.
113
+ * @param prepared Supplies affected rows.
114
+ * @returns Existing data indexed by key.
115
+ */
71
116
  private load;
72
- private conflict;
117
+ /**
118
+ * Rejects divergent data already stored under immutable keys.
119
+ *
120
+ * @param prepared Supplies proposed immutable rows.
121
+ * @param values Supplies existing data for affected keys.
122
+ */
73
123
  private validateImmutable;
124
+ /**
125
+ * Writes missing immutable rows and changed current state in the transaction.
126
+ *
127
+ * @param transaction Supplies the active Datastore transaction.
128
+ * @param prepared Supplies current and immutable rows.
129
+ * @param values Supplies existing data for affected keys.
130
+ */
74
131
  private apply;
132
+ /**
133
+ * Closes temporary record-family handles after the commit attempt.
134
+ *
135
+ * @param current Supplies current Entity storage.
136
+ * @param states Supplies state history when enabled.
137
+ * @param diagnostics Supplies diagnostic history when enabled.
138
+ * @param events Supplies delivery Event storage.
139
+ */
75
140
  private closeRecords;
76
141
  /**
77
142
  * Closes this commit storage to further commits.
78
143
  */
79
144
  close(): void;
145
+ /**
146
+ * Validates the Entity, tenant, history, and Event boundaries of a commit.
147
+ *
148
+ * @typeParam I Entity identifier type.
149
+ * @typeParam S Entity state type.
150
+ * @param input Supplies the proposed commit.
151
+ */
80
152
  private validate;
81
153
  }
82
154
  //# sourceMappingURL=entity-history.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity-history.d.ts","sourceRoot":"","sources":["../../src/datastore/entity-history.ts"],"names":[],"mappings":"AAcA,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAQ/E,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACxB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAkB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAc7F;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EACnD,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,KAAK,CAAC,EAAE,OAAO,6BAA6B,EAAE,YAAY,KACvD,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEzB;;GAEG;AACH,qBAAa,sBAAsB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO;;IAGtD;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9C;;;;;OAKG;gBACS,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB;IAsB3E;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;;;OAIG;IACH,MAAM,IA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