@spine-event-engine/storage 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.
Files changed (53) hide show
  1. package/README.md +47 -14
  2. package/REFERENCE.md +26 -18
  3. package/dist/index.d.ts +2 -4
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +0 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/internal/entity-commit.d.ts +28 -23
  8. package/dist/internal/entity-commit.d.ts.map +1 -1
  9. package/dist/internal/entity-commit.js +10 -1
  10. package/dist/internal/entity-commit.js.map +1 -1
  11. package/dist/internal/entity-history.d.ts +1 -1
  12. package/dist/internal/entity-history.d.ts.map +1 -1
  13. package/dist/memory/canonical-utf8.d.ts.map +1 -1
  14. package/dist/memory/canonical-utf8.js +13 -6
  15. package/dist/memory/canonical-utf8.js.map +1 -1
  16. package/dist/memory/in-memory-entity-commit.d.ts +38 -6
  17. package/dist/memory/in-memory-entity-commit.d.ts.map +1 -1
  18. package/dist/memory/in-memory-entity-commit.js +281 -68
  19. package/dist/memory/in-memory-entity-commit.js.map +1 -1
  20. package/dist/memory/in-memory-entity-history.d.ts +115 -1
  21. package/dist/memory/in-memory-entity-history.d.ts.map +1 -1
  22. package/dist/memory/in-memory-entity-history.js +186 -41
  23. package/dist/memory/in-memory-entity-history.js.map +1 -1
  24. package/dist/memory/in-memory-record-storage.d.ts +19 -0
  25. package/dist/memory/in-memory-record-storage.d.ts.map +1 -1
  26. package/dist/memory/in-memory-record-storage.js +25 -4
  27. package/dist/memory/in-memory-record-storage.js.map +1 -1
  28. package/dist/memory/tenant-records.d.ts +33 -7
  29. package/dist/memory/tenant-records.d.ts.map +1 -1
  30. package/dist/memory/tenant-records.js +297 -77
  31. package/dist/memory/tenant-records.js.map +1 -1
  32. package/dist/provider.d.ts +18 -0
  33. package/dist/provider.d.ts.map +1 -0
  34. package/dist/provider.js +23 -0
  35. package/dist/provider.js.map +1 -0
  36. package/dist/query/query-policy.d.ts +18 -14
  37. package/dist/query/query-policy.d.ts.map +1 -1
  38. package/dist/query/query-policy.js +55 -28
  39. package/dist/query/query-policy.js.map +1 -1
  40. package/dist/record/record-query.d.ts +12 -11
  41. package/dist/record/record-query.d.ts.map +1 -1
  42. package/dist/record/record-query.js +4 -1
  43. package/dist/record/record-query.js.map +1 -1
  44. package/dist/record/record-storage.d.ts +12 -5
  45. package/dist/record/record-storage.d.ts.map +1 -1
  46. package/dist/record/record-storage.js +14 -12
  47. package/dist/record/record-storage.js.map +1 -1
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +6 -27
  50. package/dist/record/record-mask.d.ts +0 -11
  51. package/dist/record/record-mask.d.ts.map +0 -1
  52. package/dist/record/record-mask.js +0 -82
  53. package/dist/record/record-mask.js.map +0 -1
package/README.md CHANGED
@@ -5,6 +5,37 @@ includes an in-memory implementation for local development and tests. Use it
5
5
  when an application needs a small record store, or when an adapter needs to
6
6
  implement the same storage contract for a durable provider.
7
7
 
8
+ This is an experimental snapshot package. Use Node 24 or newer and generated
9
+ Protobuf record schemas before configuring storage.
10
+
11
+ ## Install and write one record
12
+
13
+ Install the storage contract and Protobuf-ES in the application or adapter that
14
+ owns persistence:
15
+
16
+ ```sh
17
+ pnpm add @spine-event-engine/storage@snapshot @bufbuild/protobuf
18
+ ```
19
+
20
+ The following in-memory record flow is suitable for a local test:
21
+
22
+ ```ts
23
+ import { create } from "@bufbuild/protobuf";
24
+ import { StringValueSchema } from "@bufbuild/protobuf/wkt";
25
+ import { InMemoryStorageFactory, RecordSpec } from "@spine-event-engine/storage";
26
+
27
+ const records = new InMemoryStorageFactory().createRecordStorage(
28
+ { name: "Users", multitenant: false },
29
+ new RecordSpec({
30
+ recordType: StringValueSchema,
31
+ idKind: "string",
32
+ extractId: (user) => user.value,
33
+ }),
34
+ );
35
+ await records.write(create(StringValueSchema, { value: "ava" }));
36
+ console.log((await records.read("ava"))?.value);
37
+ ```
38
+
8
39
  For detailed query, lifecycle, and adapter notes, see
9
40
  [REFERENCE documentation for agents](REFERENCE.md).
10
41
 
@@ -22,9 +53,8 @@ pnpm typecheck:build
22
53
  ```
23
54
 
24
55
  Run this workspace-wide TypeScript build from the repository root. For an
25
- experimental npm consumer, install
26
- `@spine-event-engine/storage@2.0.0-snapshot.2` or the explicit
27
- `@spine-event-engine/storage@snapshot` tag.
56
+ experimental npm consumer, install `@spine-event-engine/storage@snapshot`.
57
+ The snapshot tag can change before a stable release.
28
58
 
29
59
  ## 🧪 Start with the Proto fields people may query
30
60
 
@@ -95,8 +125,8 @@ The storage API clones data at its boundaries. For the base factory and the
95
125
  in-memory implementation, closing a factory prevents new record handles while
96
126
  existing handles remain usable. Closing a record handle invalidates that
97
127
  handle's later operations. Other adapters can close live handles; see their
98
- [Datastore reference](../storage-datastore/REFERENCE.md) and
99
- [MySQL reference](../storage-rdbms/REFERENCE.md) before choosing shutdown
128
+ [Datastore reference](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-datastore/REFERENCE.md) and
129
+ [MySQL reference](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-mysql/REFERENCE.md) before choosing shutdown
100
130
  behavior.
101
131
 
102
132
  ## 🧩 Keep compatible record families separate
@@ -135,15 +165,17 @@ ordinary Event Store is intentionally ungrouped.
135
165
  ## 🗄️ Choose a durable adapter
136
166
 
137
167
  `@spine-event-engine/storage-datastore` provides Google Cloud Datastore
138
- storage. `@spine-event-engine/storage-rdbms` provides MySQL storage. Configure
168
+ storage. `@spine-event-engine/storage-mysql` provides MySQL storage and
169
+ `@spine-event-engine/storage-postgres` provides PostgreSQL storage. Configure
139
170
  those packages in application code and pass the resulting factory to the Spine
140
171
  server; this package does not choose a database.
141
172
 
142
- | Need | Adapter |
143
- | --------------------------- | ------------------------------------------------------------------------- |
144
- | Local development and tests | `InMemoryStorageFactory` in this package |
145
- | Google Cloud Datastore | [`@spine-event-engine/storage-datastore`](../storage-datastore/README.md) |
146
- | MySQL | [`@spine-event-engine/storage-rdbms`](../storage-rdbms/README.md) |
173
+ | Need | Adapter |
174
+ | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
175
+ | Local development and tests | `InMemoryStorageFactory` in this package |
176
+ | Google Cloud Datastore | [`@spine-event-engine/storage-datastore`](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-datastore/README.md) |
177
+ | MySQL | [`@spine-event-engine/storage-mysql`](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-mysql/README.md) |
178
+ | PostgreSQL | [`@spine-event-engine/storage-postgres`](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-postgres/README.md) |
147
179
 
148
180
  ## ⚠️ Lifecycle differences
149
181
 
@@ -154,7 +186,8 @@ shutdown and queries.
154
186
 
155
187
  ## 🔗 Learn more
156
188
 
157
- - [Datastore adapter](../storage-datastore/README.md)
158
- - [MySQL adapter](../storage-rdbms/README.md)
159
- - [Server](../server/README.md)
189
+ - [Datastore adapter](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-datastore/README.md)
190
+ - [MySQL adapter](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-mysql/README.md)
191
+ - [PostgreSQL adapter](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-postgres/README.md)
192
+ - [Server](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/server/README.md)
160
193
  - [Reference for coding agents](REFERENCE.md)
package/REFERENCE.md CHANGED
@@ -6,16 +6,18 @@ This reference is for agents working with the Spine TS storage contract.
6
6
 
7
7
  Import public types from `@spine-event-engine/storage`. The entry point exports
8
8
  `StorageFactory`, `RecordStorage`, `RecordSpec`, `RecordSpecOptions`, `RecordColumn`, `RecordQuery`,
9
- `RecordMask`, `StorageGroup`, `ColumnTypes`, `ColumnMappings`, the exported
10
- column-mapping contracts, `TenantBoundary`, `TenantCatalog`,
11
- `TenantCatalogProvider`, `InMemoryStorageFactory`,
9
+ `StorageGroup`, `ColumnTypes`, `ColumnMappings`, the exported
10
+ column-mapping contracts, `InMemoryStorageFactory`,
12
11
  `InMemoryStorageBackend`, event-store types, normalized query policy/evaluator
13
12
  types, and entity history interfaces.
14
- The `./internal/entity-history` subpath supplies Entity records, source-type
15
- inputs, and current/state/event-history ports. The separate
16
- `./internal/entity-commit` subpath supplies atomic commit input/result types,
17
- `EntityCommitStorage`, and `EntityCommitStorageFactories`; both are
18
- framework/provider seams, not application-facing remote APIs.
13
+
14
+ ## Provider SPI
15
+
16
+ Storage-adapter implementers import the complete provider-only contract set from
17
+ `@spine-event-engine/storage/provider`: Event Store record access, Entity
18
+ history and Entity commit contracts, query values, tenant boundaries/catalogs,
19
+ and delivery-cleanup handles. The storage root intentionally does not export
20
+ these provider seams; application code uses its root storage contracts instead.
19
21
 
20
22
  ## Record storage
21
23
 
@@ -76,9 +78,9 @@ name validation from the common query shape.
76
78
 
77
79
  The normalized-plan matrix is intentionally provider-specific. MySQL admits
78
80
  IDs; equality and the five comparisons on mapped orderable columns; nested
79
- `all` and `either`; declared-column ordering; positive limits; and masks.
81
+ `all` and `either`; declared-column ordering; and positive limits.
80
82
  Datastore admits only IDs, equality, one provider-legal inequality column, flat
81
- `all`, compatible ordering, limits, and masks. Both reject unsupported shapes
83
+ `all`, compatible ordering, and limits. Both reject unsupported shapes
82
84
  before provider access. Normalized plans never include offset: the existing
83
85
  `RecordQuery.offset` path is separate. MySQL executes every admitted predicate,
84
86
  order, and finite bound in contained parameterized SQL; Datastore executes only
@@ -92,14 +94,14 @@ until each handle closes. `RecordStorage.close()` rejects that handle's later
92
94
  operations. Datastore follows the base factory behavior. Adapters can define a
93
95
  stronger shutdown lifecycle: the MySQL factory closes live handles while it
94
96
  drains its pool. Read the [Datastore reference](../storage-datastore/REFERENCE.md)
95
- and [MySQL reference](../storage-rdbms/REFERENCE.md) before relying on shutdown
97
+ and [MySQL reference](../storage-mysql/REFERENCE.md) or [PostgreSQL reference](../storage-postgres/REFERENCE.md) before relying on shutdown
96
98
  behavior. The in-memory backend is ephemeral and process-local. Passing one
97
99
  `InMemoryStorageBackend` to multiple in-memory factories deliberately shares
98
100
  its scoped rows.
99
101
 
100
102
  ## Entity storage
101
103
 
102
- The `./internal/entity-history` seam supplies the framework's Entity storage
104
+ The provider SPI supplies the framework's Entity storage
103
105
  ports. Current Entity state is a generated `spine.server.entity.EntityRecord`.
104
106
  Retained state history stores generated `EntityStateKey`/`EntityRecord` rows in
105
107
  a `StorageGroup` named after the Entity state type. Retained diagnostic event
@@ -112,9 +114,15 @@ not open or allocate its grouped records. Current Entity loading always uses
112
114
  the current record, never retained history. Event history is diagnostic data,
113
115
  not a source for rebuilding current state.
114
116
 
115
- The separate `./internal/entity-commit` port combines one current record with
116
- the nonempty enabled history families and delivery events. For the in-memory
117
- provider only, that operation stages and atomically publishes its touched
118
- families. Its outcomes are `"committed"` and `"conflict"`; it has no receipt or
119
- `"replayed"` outcome. Other providers define and document their atomicity
120
- guarantees.
117
+ The provider SPI's Entity commit accepts the next current record and associated
118
+ enabled history and delivery events, without an expected previous record.
119
+ `commit()` returns `Promise<void>`: success resolves without a value and storage
120
+ errors reject. There is no Entity conflict result. This changes the published
121
+ `storage/provider` types for custom adapters; application APIs and persisted
122
+ record layouts are unchanged.
123
+
124
+ The in-memory provider prepares only the affected records before applying them
125
+ together. Saving one Entity does not copy other Entities or whole history/Event
126
+ Store collections. Automatic Entity versions, immutable-record checks and
127
+ unrelated Inbox conditional updates remain. Other providers document their
128
+ transaction and partial-write guarantees separately.
package/dist/index.d.ts CHANGED
@@ -6,12 +6,11 @@ export { InMemoryStorageFactory } from "./memory/in-memory-storage-factory.js";
6
6
  export { StorageQueryPolicy } from "./query/query-policy.js";
7
7
  export { defaultQueryCandidateLimit, QueryCandidateLimitError, StorageQueryEvaluator, } from "./query/query-execution.js";
8
8
  export type { NormalizedQueryEntry } from "./query/query-execution.js";
9
- export type { NormalizedComparisonOperator, NormalizedQueryMask, NormalizedQueryOrder, NormalizedQueryPlan, NormalizedQueryPredicate, StorageQueryCapabilities, StorageQueryFeature, } from "./query/query-policy.js";
9
+ export type { NormalizedComparisonOperator, NormalizedQueryOrder, NormalizedQueryPlan, NormalizedQueryPredicate, StorageQueryCapabilities, StorageQueryFeature, } from "./query/query-policy.js";
10
10
  export { RecordColumn } from "./record/record-column.js";
11
11
  export { ColumnTypes, type RecordColumnType } from "./record/column-type.js";
12
12
  export { ColumnMappings, type ColumnMapping, type ColumnTypeMapping, } from "./record/column-mapping.js";
13
- export { RecordMask } from "./record/record-mask.js";
14
- export type { RecordContinuation, RecordContinuationValue, RecordFilter, RecordOrder, RecordReadOptions, } from "./record/record-query.js";
13
+ export type { RecordContinuation, RecordContinuationValue, RecordFilter, RecordOrder, } from "./record/record-query.js";
15
14
  export { RecordQuery } from "./record/record-query.js";
16
15
  export { RecordSpec, type RecordSpecOptions } from "./record/record-spec.js";
17
16
  export { RecordStorage } from "./record/record-storage.js";
@@ -19,5 +18,4 @@ export { StorageGroup } from "./record/storage-group.js";
19
18
  export type { RecordEntry } from "./record/record-storage.js";
20
19
  export type { Storage, StorageContext, StorageMode } from "./storage/storage.js";
21
20
  export { StorageFactory } from "./storage/storage-factory.js";
22
- export { TenantBoundary, type TenantCatalog, type TenantCatalogProvider, } from "./internal/tenancy.js";
23
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,UAAU,EACV,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC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AAM,4BAA4B,CAAC;AAC9D,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -20,11 +20,9 @@ export { defaultQueryCandidateLimit, QueryCandidateLimitError, StorageQueryEvalu
20
20
  export { RecordColumn } from "./record/record-column.js";
21
21
  export { ColumnTypes } from "./record/column-type.js";
22
22
  export { ColumnMappings, } from "./record/column-mapping.js";
23
- export { RecordMask } from "./record/record-mask.js";
24
23
  export { RecordQuery } from "./record/record-query.js";
25
24
  export { RecordSpec } from "./record/record-spec.js";
26
25
  export { RecordStorage } from "./record/record-storage.js";
27
26
  export { StorageGroup } from "./record/storage-group.js";
28
27
  export { StorageFactory } from "./storage/storage-factory.js";
29
- export { TenantBoundary, } from "./internal/tenancy.js";
30
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,UAAU,GAIX,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAyB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EACL,cAAc,GAGf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAQrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAA0B,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EACL,cAAc,GAGf,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,UAAU,GAIX,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAyB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EACL,cAAc,GAGf,MAAM,4BAA4B,CAAC;AAOpC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAA0B,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC"}
@@ -5,15 +5,19 @@ import type { StorageContext } from "../storage/storage.js";
5
5
  import type { EntityStorageInput } from "./entity-history.js";
6
6
  import type { StorageFactory } from "../storage/storage-factory.js";
7
7
  /**
8
- * Describes one provider-owned atomic mutation for an Entity commit.
8
+ * Describes one coordinated provider mutation for an Entity commit.
9
9
  *
10
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.
11
+ * framework delivery events. Memory and transactional database providers apply
12
+ * the changes atomically. MyISAM and Aria tables can retain partial writes.
13
+ * This contract is not an application-level transaction API.
14
+ *
15
+ * @typeParam I Entity identifier type.
16
+ * @typeParam S Entity state message type.
13
17
  */
14
18
  export interface EntityCommitInput<I, S extends Message> {
15
19
  /**
16
- * Identifies the storage scope that owns this commit.
20
+ * Identifies the storage scope for this commit.
17
21
  */
18
22
  readonly context: StorageContext;
19
23
  /**
@@ -24,10 +28,6 @@ export interface EntityCommitInput<I, S extends Message> {
24
28
  * Identifies the Entity record being changed.
25
29
  */
26
30
  readonly entityId: I;
27
- /**
28
- * Requires this current record before applying the next record.
29
- */
30
- readonly expected?: EntityRecord;
31
31
  /**
32
32
  * Stores the next current record.
33
33
  */
@@ -46,22 +46,23 @@ export interface EntityCommitInput<I, S extends Message> {
46
46
  readonly events?: readonly Event[];
47
47
  }
48
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.
49
+ * A provider handle for coordinated changes to one bounded Entity scope.
50
+ *
51
+ * Memory and transactional database providers apply each commit atomically.
52
+ * MyISAM and Aria tables can retain partial writes if a commit fails.
54
53
  */
55
54
  export interface EntityCommitStorage {
56
55
  /**
57
- * Applies one complete Entity mutation.
56
+ * Applies one Entity mutation across its current, history, and delivery records.
58
57
  *
58
+ * @typeParam I Entity identifier type.
59
+ * @typeParam S Entity state message type.
59
60
  * @param input Defines the unit of Entity, history, and delivery-event work.
60
- * @returns Resolves to the committed or conflict outcome.
61
+ * @returns Resolves when the Entity mutation completes.
61
62
  */
62
- commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<EntityCommitResult>;
63
+ commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<void>;
63
64
  /**
64
- * Closes this independently owned commit handle.
65
+ * Closes this independent commit handle.
65
66
  */
66
67
  close(): void;
67
68
  }
@@ -70,8 +71,10 @@ export interface EntityCommitStorage {
70
71
  */
71
72
  export interface EntityCommitStorageFactory {
72
73
  /**
73
- * Creates a handle that atomically mutates Entity persistence for one provider.
74
+ * Creates a handle that coordinates Entity persistence changes for one provider.
74
75
  *
76
+ * @typeParam I Entity identifier type.
77
+ * @typeParam S Entity state message type.
75
78
  * @param input Identifies the Entity storage layout the handle may commit.
76
79
  * @returns The independently closeable provider commit handle.
77
80
  */
@@ -82,23 +85,25 @@ export interface EntityCommitStorageFactory {
82
85
  */
83
86
  interface EntityCommitFactoryAccess {
84
87
  /**
85
- * Registers the atomic commit capability of one storage factory.
88
+ * Registers the Entity commit capability of one storage factory.
86
89
  *
87
90
  * @param factory Identifies the storage factory that provides the capability.
88
- * @param creator Creates atomic commit handles for that provider.
91
+ * @param creator Creates coordinated commit handles for that provider.
89
92
  */
90
93
  register(factory: StorageFactory, creator: EntityCommitStorageFactory): void;
91
94
  /**
92
- * Creates an atomic commit handle registered by a storage provider.
95
+ * Creates a commit handle registered by a storage provider.
93
96
  *
97
+ * @typeParam I Entity identifier type.
98
+ * @typeParam S Entity state message type.
94
99
  * @param factory Identifies the provider storage factory.
95
100
  * @param input Defines the Entity storage layout to commit.
96
- * @returns The provider-owned atomic commit handle.
101
+ * @returns The provider commit handle.
97
102
  */
98
103
  create<I, S extends Message>(factory: StorageFactory, input: EntityStorageInput<I, S>): EntityCommitStorage;
99
104
  }
100
105
  /**
101
- * Provides the typed internal lookup for provider-owned atomic commit handles.
106
+ * Provides the typed internal lookup for provider-managed atomic commit handles.
102
107
  *
103
108
  * Provider adapters register their creator while constructing their factory;
104
109
  * the end-user storage root deliberately exposes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ACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,EAAE,yBAuBzC,CAAC"}
@@ -12,7 +12,7 @@
12
12
  * the License.
13
13
  */
14
14
  /**
15
- * Provides the typed internal lookup for provider-owned atomic commit handles.
15
+ * Provides the typed internal lookup for provider-managed atomic commit handles.
16
16
  *
17
17
  * Provider adapters register their creator while constructing their factory;
18
18
  * the end-user storage root deliberately exposes no commit-construction method.
@@ -21,6 +21,15 @@ export const EntityCommitStorageFactories = Object.freeze({
21
21
  register(factory, creator) {
22
22
  creators.set(factory, creator);
23
23
  },
24
+ /**
25
+ * Creates the registered provider's Entity commit handle.
26
+ *
27
+ * @typeParam I Entity identifier type.
28
+ * @typeParam S Entity state message type.
29
+ * @param factory Identifies the registered provider.
30
+ * @param input Defines the Entity scope.
31
+ * @returns The provider commit handle.
32
+ */
24
33
  create(factory, input) {
25
34
  const creator = creators.get(factory);
26
35
  if (creator === undefined)
@@ -1 +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"}
1
+ {"version":3,"file":"entity-commit.js","sourceRoot":"","sources":["../../src/internal/entity-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqIH;;;;;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;;;;;;;;OAQG;IACH,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"}
@@ -8,5 +8,5 @@ export type { EntityRecord, EntityRecordStorage } from "../entity/entity-record.
8
8
  export { eventHistorySpec, stateHistorySpec } from "../entity/entity-history-record-spec.js";
9
9
  export { EntityHistoryConformance, type EntityHistoryConformanceAdapter, type EntityStorageConformance, } from "../entity/history-conformance.js";
10
10
  export type { EntityIdCodec, EntityStorageInput } from "../memory/in-memory-entity-history.js";
11
- export type { EntityCommitInput, EntityCommitResult, EntityCommitStorage, EntityCommitStorageFactory, } from "./entity-commit.js";
11
+ export type { EntityCommitInput, EntityCommitStorage, EntityCommitStorageFactory, } from "./entity-commit.js";
12
12
  //# sourceMappingURL=entity-history.d.ts.map
@@ -1 +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"}
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,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC"}
@@ -1 +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"}
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;IAgB5C;;;;;OAKG;iBACU,MAAM,GAAG,UAAU;CAyBjC,CAAC"}
@@ -24,15 +24,22 @@ export const CanonicalUtf8 = {
24
24
  * @returns A negative, zero, or positive comparison result.
25
25
  */
26
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);
27
+ if (left === right)
28
+ return 0;
29
+ let leftIndex = 0;
30
+ let rightIndex = 0;
31
+ while (leftIndex < left.length && rightIndex < right.length) {
32
+ const first = left.codePointAt(leftIndex);
33
+ const second = right.codePointAt(rightIndex);
34
+ if (first === undefined || second === undefined)
35
+ break;
36
+ const difference = first - second;
32
37
  if (difference !== 0)
33
38
  return difference;
39
+ leftIndex += first > 0xffff ? 2 : 1;
40
+ rightIndex += second > 0xffff ? 2 : 1;
34
41
  }
35
- return leftBytes.length - rightBytes.length;
42
+ return (leftIndex < left.length ? 1 : 0) - (rightIndex < right.length ? 1 : 0);
36
43
  },
37
44
  /**
38
45
  * Encodes a string as canonical UTF-8 bytes.
@@ -1 +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,GA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,EACxB,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAChC,IAAI,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"}
@@ -1,5 +1,5 @@
1
1
  import { type Message } from "@bufbuild/protobuf";
2
- import type { EntityCommitInput, EntityCommitResult, EntityCommitStorage } from "../internal/entity-commit.js";
2
+ import type { EntityCommitInput, EntityCommitStorage } from "../internal/entity-commit.js";
3
3
  import type { RecordSpec } from "../record/record-spec.js";
4
4
  import type { StorageGroup } from "../record/storage-group.js";
5
5
  import type { StorageContext } from "../storage/storage.js";
@@ -7,7 +7,17 @@ import type { StorageFactory } from "../storage/storage-factory.js";
7
7
  import { MemoryEntityStorageFactory, type EntityStorageInput } from "./in-memory-entity-history.js";
8
8
  import { TenantRecords } from "./tenant-records.js";
9
9
  /**
10
- * Implements provider-owned Entity commits for one shared in-memory backend.
10
+ * Opens the in-memory tenant slice for a generated record family.
11
+ * @typeParam I Record identifier type.
12
+ * @typeParam R Record message type.
13
+ * @param context Supplies the storage and tenant context.
14
+ * @param spec Supplies the materialized record layout.
15
+ * @param group Selects a grouped history family when present.
16
+ * @returns The tenant record slice.
17
+ */
18
+ type OpenRecords = <I, R extends Message>(context: StorageContext, spec: RecordSpec<I, R>, group?: StorageGroup) => TenantRecords<I, R>;
19
+ /**
20
+ * Implements provider Entity commits for one shared in-memory backend.
11
21
  */
12
22
  export declare class MemoryEntityCommitStorage implements EntityCommitStorage {
13
23
  #private;
@@ -15,21 +25,43 @@ export declare class MemoryEntityCommitStorage implements EntityCommitStorage {
15
25
  * Creates a commit handle bound to one Entity source type.
16
26
  *
17
27
  * @param entities Opens the matching current Entity storage.
18
- * @param factory Owns the Event Store coordination lock.
28
+ * @param factory Provides the Event Store coordination lock.
19
29
  * @param openRecords Opens exact generic-record backing slices.
20
30
  * @param input Defines the Entity storage source type.
21
31
  */
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>);
32
+ constructor(entities: MemoryEntityStorageFactory, factory: StorageFactory, openRecords: OpenRecords, input: EntityStorageInput<unknown, Message>);
23
33
  /**
24
34
  * Applies one fully preflighted in-memory Entity commit.
25
35
  *
36
+ * @typeParam I Entity identifier type.
37
+ * @typeParam S Entity state type.
26
38
  * @param input Defines the current record, retained histories, and delivery events.
27
- * @returns The durable in-memory commit outcome.
39
+ * @returns Completion after the in-memory commit.
28
40
  */
29
- commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<EntityCommitResult>;
41
+ commit<I, S extends Message>(input: EntityCommitInput<I, S>): Promise<void>;
30
42
  /**
31
43
  * Closes this commit handle without closing sibling handles.
32
44
  */
33
45
  close(): void;
46
+ /**
47
+ * Opens only record families used by one commit.
48
+ *
49
+ * @typeParam I Entity identifier type.
50
+ * @typeParam S Entity state type.
51
+ * @param input Supplies configured histories and delivery Events.
52
+ * @returns Live affected record families and their layouts.
53
+ */
54
+ private live;
55
+ /**
56
+ * Captures affected rows and creates isolated adapters for preparation.
57
+ *
58
+ * @typeParam I Entity identifier type.
59
+ * @typeParam S Entity state type.
60
+ * @param input Supplies the proposed record changes.
61
+ * @param backend Supplies the live current-record map.
62
+ * @returns The prepared affected-record workspace.
63
+ */
64
+ private stage;
34
65
  }
66
+ export {};
35
67
  //# sourceMappingURL=in-memory-entity-commit.d.ts.map
@@ -1 +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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