@spine-event-engine/storage 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 +190 -0
- package/REFERENCE.md +122 -0
- package/dist/entity/entity-history-record-spec.d.ts +26 -0
- package/dist/entity/entity-history-record-spec.d.ts.map +1 -0
- package/dist/entity/entity-history-record-spec.js +77 -0
- package/dist/entity/entity-history-record-spec.js.map +1 -0
- package/dist/entity/entity-history-storage.d.ts +111 -0
- package/dist/entity/entity-history-storage.d.ts.map +1 -0
- package/dist/entity/entity-history-storage.js +40 -0
- package/dist/entity/entity-history-storage.js.map +1 -0
- package/dist/entity/entity-record.d.ts +31 -0
- package/dist/entity/entity-record.d.ts.map +1 -0
- package/dist/entity/entity-record.js +15 -0
- package/dist/entity/entity-record.js.map +1 -0
- package/dist/entity/history-conformance.d.ts +55 -0
- package/dist/entity/history-conformance.d.ts.map +1 -0
- package/dist/entity/history-conformance.js +165 -0
- package/dist/entity/history-conformance.js.map +1 -0
- package/dist/event/event-store.d.ts +141 -0
- package/dist/event/event-store.d.ts.map +1 -0
- package/dist/event/event-store.js +407 -0
- package/dist/event/event-store.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/delivery-cleanup.d.ts +99 -0
- package/dist/internal/delivery-cleanup.d.ts.map +1 -0
- package/dist/internal/delivery-cleanup.js +38 -0
- package/dist/internal/delivery-cleanup.js.map +1 -0
- package/dist/internal/entity-commit.d.ts +108 -0
- package/dist/internal/entity-commit.d.ts.map +1 -0
- package/dist/internal/entity-commit.js +32 -0
- package/dist/internal/entity-commit.js.map +1 -0
- package/dist/internal/entity-history.d.ts +12 -0
- package/dist/internal/entity-history.d.ts.map +1 -0
- package/dist/internal/entity-history.js +17 -0
- package/dist/internal/entity-history.js.map +1 -0
- package/dist/internal/event-store.d.ts +8 -0
- package/dist/internal/event-store.d.ts.map +1 -0
- package/dist/internal/event-store.js +21 -0
- package/dist/internal/event-store.js.map +1 -0
- package/dist/internal/query-values.d.ts +5 -0
- package/dist/internal/query-values.d.ts.map +1 -0
- package/dist/internal/query-values.js +18 -0
- package/dist/internal/query-values.js.map +1 -0
- package/dist/internal/tenancy.d.ts +89 -0
- package/dist/internal/tenancy.d.ts.map +1 -0
- package/dist/internal/tenancy.js +97 -0
- package/dist/internal/tenancy.js.map +1 -0
- package/dist/memory/canonical-utf8.d.ts +21 -0
- package/dist/memory/canonical-utf8.d.ts.map +1 -0
- package/dist/memory/canonical-utf8.js +65 -0
- package/dist/memory/canonical-utf8.js.map +1 -0
- package/dist/memory/in-memory-entity-commit.d.ts +35 -0
- package/dist/memory/in-memory-entity-commit.d.ts.map +1 -0
- package/dist/memory/in-memory-entity-commit.js +183 -0
- package/dist/memory/in-memory-entity-commit.js.map +1 -0
- package/dist/memory/in-memory-entity-history.d.ts +379 -0
- package/dist/memory/in-memory-entity-history.d.ts.map +1 -0
- package/dist/memory/in-memory-entity-history.js +756 -0
- package/dist/memory/in-memory-entity-history.js.map +1 -0
- package/dist/memory/in-memory-record-storage.d.ts +78 -0
- package/dist/memory/in-memory-record-storage.d.ts.map +1 -0
- package/dist/memory/in-memory-record-storage.js +127 -0
- package/dist/memory/in-memory-record-storage.js.map +1 -0
- package/dist/memory/in-memory-storage-backend.d.ts +38 -0
- package/dist/memory/in-memory-storage-backend.d.ts.map +1 -0
- package/dist/memory/in-memory-storage-backend.js +108 -0
- package/dist/memory/in-memory-storage-backend.js.map +1 -0
- package/dist/memory/in-memory-storage-factory.d.ts +58 -0
- package/dist/memory/in-memory-storage-factory.d.ts.map +1 -0
- package/dist/memory/in-memory-storage-factory.js +148 -0
- package/dist/memory/in-memory-storage-factory.js.map +1 -0
- package/dist/memory/memory-delivery-cleanup.d.ts +32 -0
- package/dist/memory/memory-delivery-cleanup.d.ts.map +1 -0
- package/dist/memory/memory-delivery-cleanup.js +61 -0
- package/dist/memory/memory-delivery-cleanup.js.map +1 -0
- package/dist/memory/tenant-records.d.ts +66 -0
- package/dist/memory/tenant-records.d.ts.map +1 -0
- package/dist/memory/tenant-records.js +573 -0
- package/dist/memory/tenant-records.js.map +1 -0
- package/dist/provider.d.ts +18 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +23 -0
- package/dist/provider.js.map +1 -0
- package/dist/query/query-execution.d.ts +50 -0
- package/dist/query/query-execution.d.ts.map +1 -0
- package/dist/query/query-execution.js +222 -0
- package/dist/query/query-execution.js.map +1 -0
- package/dist/query/query-policy.d.ts +115 -0
- package/dist/query/query-policy.d.ts.map +1 -0
- package/dist/query/query-policy.js +294 -0
- package/dist/query/query-policy.js.map +1 -0
- package/dist/record/column-mapping.d.ts +41 -0
- package/dist/record/column-mapping.d.ts.map +1 -0
- package/dist/record/column-mapping.js +36 -0
- package/dist/record/column-mapping.js.map +1 -0
- package/dist/record/column-type.d.ts +75 -0
- package/dist/record/column-type.d.ts.map +1 -0
- package/dist/record/column-type.js +69 -0
- package/dist/record/column-type.js.map +1 -0
- package/dist/record/record-column.d.ts +23 -0
- package/dist/record/record-column.d.ts.map +1 -0
- package/dist/record/record-column.js +41 -0
- package/dist/record/record-column.js.map +1 -0
- package/dist/record/record-mask.d.ts +11 -0
- package/dist/record/record-mask.d.ts.map +1 -0
- package/dist/record/record-mask.js +82 -0
- package/dist/record/record-mask.js.map +1 -0
- package/dist/record/record-query.d.ts +102 -0
- package/dist/record/record-query.d.ts.map +1 -0
- package/dist/record/record-query.js +44 -0
- package/dist/record/record-query.js.map +1 -0
- package/dist/record/record-spec.d.ts +101 -0
- package/dist/record/record-spec.d.ts.map +1 -0
- package/dist/record/record-spec.js +159 -0
- package/dist/record/record-spec.js.map +1 -0
- package/dist/record/record-storage.d.ts +202 -0
- package/dist/record/record-storage.d.ts.map +1 -0
- package/dist/record/record-storage.js +234 -0
- package/dist/record/record-storage.js.map +1 -0
- package/dist/record/storage-group.d.ts +17 -0
- package/dist/record/storage-group.d.ts.map +1 -0
- package/dist/record/storage-group.js +37 -0
- package/dist/record/storage-group.js.map +1 -0
- package/dist/storage/storage-factory.d.ts +44 -0
- package/dist/storage/storage-factory.d.ts.map +1 -0
- package/dist/storage/storage-factory.js +54 -0
- package/dist/storage/storage-factory.js.map +1 -0
- package/dist/storage/storage.d.ts +62 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +15 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Storage API and in-memory storage for Spine TS
|
|
2
|
+
|
|
3
|
+
`@spine-event-engine/storage` defines the storage API used by Spine TS and
|
|
4
|
+
includes an in-memory implementation for local development and tests. Use it
|
|
5
|
+
when an application needs a small record store, or when an adapter needs to
|
|
6
|
+
implement the same storage contract for a durable provider.
|
|
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
|
+
|
|
39
|
+
For detailed query, lifecycle, and adapter notes, see
|
|
40
|
+
[REFERENCE documentation for agents](REFERENCE.md).
|
|
41
|
+
|
|
42
|
+
## 💡 Why use it?
|
|
43
|
+
|
|
44
|
+
- ✅ Gives every Spine repository one storage contract.
|
|
45
|
+
- ✅ Includes a fast in-memory implementation for development and tests.
|
|
46
|
+
- ✅ Supports typed IDs, declared columns, filtering, sorting, and limits.
|
|
47
|
+
- ✅ Lets applications select persistence without changing domain handlers.
|
|
48
|
+
|
|
49
|
+
## 🚀 Build it in this workspace
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pnpm typecheck:build
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run this workspace-wide TypeScript build from the repository root. For an
|
|
56
|
+
experimental npm consumer, install `@spine-event-engine/storage@snapshot`.
|
|
57
|
+
The snapshot tag can change before a stable release.
|
|
58
|
+
|
|
59
|
+
## 🧪 Start with the Proto fields people may query
|
|
60
|
+
|
|
61
|
+
Persistence begins in the Proto model. Mark only the fields that need to be
|
|
62
|
+
filtered or sorted with `(column)`. The complete message is always kept as
|
|
63
|
+
authoritative bytes; an unmarked field is not silently promoted to a provider
|
|
64
|
+
property.
|
|
65
|
+
|
|
66
|
+
```proto
|
|
67
|
+
message TaskView {
|
|
68
|
+
TaskId id = 1;
|
|
69
|
+
UserId assignee = 2 [(column) = true];
|
|
70
|
+
string title = 3;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Here `assignee` is a query column. `title` stays in the serialized record. The
|
|
75
|
+
generated record specification carries that declaration into the selected
|
|
76
|
+
storage adapter.
|
|
77
|
+
|
|
78
|
+
## 🧪 Store a Protobuf record in memory
|
|
79
|
+
|
|
80
|
+
Create a `RecordSpec` to describe the record type, identity, and searchable
|
|
81
|
+
columns. Its source type defaults to the record type. Pass it to an
|
|
82
|
+
`InMemoryStorageFactory` with the storage context.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { create, ScalarType } from "@bufbuild/protobuf";
|
|
86
|
+
import { StringValueSchema, type StringValue } from "@bufbuild/protobuf/wkt";
|
|
87
|
+
import {
|
|
88
|
+
ColumnTypes,
|
|
89
|
+
InMemoryStorageFactory,
|
|
90
|
+
RecordColumn,
|
|
91
|
+
RecordSpec,
|
|
92
|
+
} from "@spine-event-engine/storage";
|
|
93
|
+
|
|
94
|
+
const records = new InMemoryStorageFactory().createRecordStorage(
|
|
95
|
+
{ name: "Users", multitenant: false },
|
|
96
|
+
new RecordSpec<string, StringValue>({
|
|
97
|
+
recordType: StringValueSchema,
|
|
98
|
+
idKind: "string",
|
|
99
|
+
extractId: (user) => user.value,
|
|
100
|
+
columns: [
|
|
101
|
+
new RecordColumn("value", ColumnTypes.scalar(ScalarType.STRING), (user) => user.value),
|
|
102
|
+
],
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
await records.write(create(StringValueSchema, { value: "ava" }));
|
|
107
|
+
const user = await records.read("ava");
|
|
108
|
+
const users = await records.query({
|
|
109
|
+
filters: [{ column: "value", value: "ava" }],
|
|
110
|
+
sort: [{ field: "value", direction: "asc" }],
|
|
111
|
+
limit: 20,
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`InMemoryStorageFactory` creates a fresh backend by default. Pass the same
|
|
116
|
+
`InMemoryStorageBackend` to separate factories only when they intentionally
|
|
117
|
+
need to share rows. Query named columns, sort them, and limit the result; the
|
|
118
|
+
column names come from the declared `RecordSpec`/Proto mapping. `RecordQuery<I>`
|
|
119
|
+
types its IDs. Providers apply their documented runtime mapping and validation
|
|
120
|
+
to filter names and values: MySQL checks declared columns, while other adapters
|
|
121
|
+
can support different query shapes. A provider can push down supported ID and
|
|
122
|
+
declared-column query parts while preserving the common result semantics.
|
|
123
|
+
|
|
124
|
+
The storage API clones data at its boundaries. For the base factory and the
|
|
125
|
+
in-memory implementation, closing a factory prevents new record handles while
|
|
126
|
+
existing handles remain usable. Closing a record handle invalidates that
|
|
127
|
+
handle's later operations. Other adapters can close live handles; see their
|
|
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-rdbms/REFERENCE.md) before choosing shutdown
|
|
130
|
+
behavior.
|
|
131
|
+
|
|
132
|
+
## 🧩 Keep compatible record families separate
|
|
133
|
+
|
|
134
|
+
Most applications only need a `RecordSpec`. Sometimes two record families use
|
|
135
|
+
the same source type and record type but must remain separate: for example,
|
|
136
|
+
two independently retained views of the same Task state records.
|
|
137
|
+
Pass a `StorageGroup` as the optional third argument to give that family its
|
|
138
|
+
separate physical storage group. The group is deliberately separate from the
|
|
139
|
+
`RecordSpec`, because the record layout has not changed.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { create } from "@bufbuild/protobuf";
|
|
143
|
+
import { StringValueSchema, type StringValue } from "@bufbuild/protobuf/wkt";
|
|
144
|
+
import { InMemoryStorageFactory, RecordSpec, StorageGroup } from "@spine-event-engine/storage";
|
|
145
|
+
|
|
146
|
+
const factory = new InMemoryStorageFactory();
|
|
147
|
+
const stateHistorySpec = new RecordSpec<string, StringValue>({
|
|
148
|
+
recordType: StringValueSchema,
|
|
149
|
+
idKind: "string",
|
|
150
|
+
extractId: (state) => state.value,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const auditStates = factory.createRecordStorage(
|
|
154
|
+
{ name: "Tasks", multitenant: false },
|
|
155
|
+
stateHistorySpec,
|
|
156
|
+
new StorageGroup("example.tasks.TaskState.audit"),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
await auditStates.write(create(StringValueSchema, { value: "first" }));
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Use a group only when otherwise compatible records must not share rows. The
|
|
163
|
+
ordinary Event Store is intentionally ungrouped.
|
|
164
|
+
|
|
165
|
+
## 🗄️ Choose a durable adapter
|
|
166
|
+
|
|
167
|
+
`@spine-event-engine/storage-datastore` provides Google Cloud Datastore
|
|
168
|
+
storage. `@spine-event-engine/storage-rdbms` provides MySQL storage. Configure
|
|
169
|
+
those packages in application code and pass the resulting factory to the Spine
|
|
170
|
+
server; this package does not choose a database.
|
|
171
|
+
|
|
172
|
+
| Need | Adapter |
|
|
173
|
+
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
174
|
+
| Local development and tests | `InMemoryStorageFactory` in this package |
|
|
175
|
+
| Google Cloud Datastore | [`@spine-event-engine/storage-datastore`](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-datastore/README.md) |
|
|
176
|
+
| MySQL | [`@spine-event-engine/storage-rdbms`](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-rdbms/README.md) |
|
|
177
|
+
|
|
178
|
+
## ⚠️ Lifecycle differences
|
|
179
|
+
|
|
180
|
+
The common API defines record behavior, not deployment policy. Provider
|
|
181
|
+
adapters may close live handles, impose query budgets, or require indexes and
|
|
182
|
+
credentials. Read the selected adapter guide before configuring production
|
|
183
|
+
shutdown and queries.
|
|
184
|
+
|
|
185
|
+
## 🔗 Learn more
|
|
186
|
+
|
|
187
|
+
- [Datastore adapter](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-datastore/README.md)
|
|
188
|
+
- [MySQL adapter](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/storage-rdbms/README.md)
|
|
189
|
+
- [Server](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/server/README.md)
|
|
190
|
+
- [Reference for coding agents](REFERENCE.md)
|
package/REFERENCE.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @spine-event-engine/storage reference
|
|
2
|
+
|
|
3
|
+
This reference is for agents working with the Spine TS storage contract.
|
|
4
|
+
|
|
5
|
+
## Public entry point
|
|
6
|
+
|
|
7
|
+
Import public types from `@spine-event-engine/storage`. The entry point exports
|
|
8
|
+
`StorageFactory`, `RecordStorage`, `RecordSpec`, `RecordSpecOptions`, `RecordColumn`, `RecordQuery`,
|
|
9
|
+
`RecordMask`, `StorageGroup`, `ColumnTypes`, `ColumnMappings`, the exported
|
|
10
|
+
column-mapping contracts, `InMemoryStorageFactory`,
|
|
11
|
+
`InMemoryStorageBackend`, event-store types, normalized query policy/evaluator
|
|
12
|
+
types, and entity history interfaces.
|
|
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 atomic 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.
|
|
21
|
+
|
|
22
|
+
## Record storage
|
|
23
|
+
|
|
24
|
+
`StorageFactory.createRecordStorage(context, spec, group?)` returns an
|
|
25
|
+
independently closeable `RecordStorage`. A single-tenant context forbids a
|
|
26
|
+
tenant ID. A multitenant context requires a complete generated `TenantId`.
|
|
27
|
+
The Bounded Context name is diagnostic only. A `RecordSpec` fixes the
|
|
28
|
+
source type, stored record type, identity extractor, ID schema or primitive ID
|
|
29
|
+
kind, and materialized columns. `sourceType` defaults to `recordType`; Entity
|
|
30
|
+
record specifications use the entity state type as their source type.
|
|
31
|
+
`RecordSpecOptions` is the public constructor-input contract for those fields.
|
|
32
|
+
For generated application records, Proto `(column)` declarations determine the
|
|
33
|
+
materialized fields. A field without that declaration remains only in the
|
|
34
|
+
authoritative serialized record; providers do not infer columns from every
|
|
35
|
+
field in the message.
|
|
36
|
+
|
|
37
|
+
`StorageGroup` is an optional external physical-family identity. It is not part
|
|
38
|
+
of `RecordSpec`: use it only when records with an otherwise compatible layout
|
|
39
|
+
must remain distinct. The in-memory provider keys physical identity by backend,
|
|
40
|
+
tenant boundary, source type, and either the named group or the explicit
|
|
41
|
+
ungrouped value. It keeps different source types and
|
|
42
|
+
different groups separate even when they use the same stored record type.
|
|
43
|
+
`idType`, `recordType`, `sourceType`, and `columns` are read-only accessors.
|
|
44
|
+
|
|
45
|
+
`RecordStorage` supports `write`, `writeAll`, `read`, `delete`, `compareAndSet`,
|
|
46
|
+
`index`, `query`, `queryEntries`, `queryPlan`, and `queryPlanEntries`. It clones
|
|
47
|
+
IDs and messages at its public boundary. `RecordQuery.ids` filters actual
|
|
48
|
+
storage slots, while `index()` returns logical IDs extracted from record bodies.
|
|
49
|
+
Its `atomicCompareAndSet` capability defaults to `false`. A provider sets it to
|
|
50
|
+
`true` only when `compareAndSet()` is atomic across compatible handles; code
|
|
51
|
+
that needs that guarantee must reject a handle that does not declare it.
|
|
52
|
+
|
|
53
|
+
## Query behavior
|
|
54
|
+
|
|
55
|
+
Record queries validate positive limits, non-negative offsets, and
|
|
56
|
+
continuations that match the requested sort fields. Query plans are normalized
|
|
57
|
+
and checked against adapter capabilities. If a provider returns more candidates
|
|
58
|
+
than a plan's explicit query budget, or the exported
|
|
59
|
+
`defaultQueryCandidateLimit` of 10,000 when it is omitted,
|
|
60
|
+
`QueryCandidateLimitError` is thrown before
|
|
61
|
+
local materialization can return a partial semantic result.
|
|
62
|
+
An explicit query budget must be a positive safe integer no greater
|
|
63
|
+
than 10,000.
|
|
64
|
+
|
|
65
|
+
An accepted query budget is distinct from the one-row raw-provider
|
|
66
|
+
overflow lookahead used to detect excess: the shared default accepts 10,000
|
|
67
|
+
records and can fetch 10,001 raw rows; a provider may declare a lower accepted
|
|
68
|
+
ceiling, such as Datastore's 1,000 accepted / 1,001 raw rows.
|
|
69
|
+
|
|
70
|
+
`StorageQueryPolicy` validates normalized plans and
|
|
71
|
+
`StorageQueryEvaluator` applies the portable query semantics. Provider packages
|
|
72
|
+
can push down supported ID, declared-column, and sort parts of a plan, but must
|
|
73
|
+
preserve these semantics and enforce their documented bounds. `RecordQuery<I>`
|
|
74
|
+
statically types IDs only; filter and sort names are strings and filter values
|
|
75
|
+
are `unknown`. Each provider documents the runtime mapping and validation it
|
|
76
|
+
applies before using those inputs; callers cannot infer shared filter or sort
|
|
77
|
+
name validation from the common query shape.
|
|
78
|
+
|
|
79
|
+
The normalized-plan matrix is intentionally provider-specific. MySQL admits
|
|
80
|
+
IDs; equality and the five comparisons on mapped orderable columns; nested
|
|
81
|
+
`all` and `either`; declared-column ordering; positive limits; and masks.
|
|
82
|
+
Datastore admits only IDs, equality, one provider-legal inequality column, flat
|
|
83
|
+
`all`, compatible ordering, limits, and masks. Both reject unsupported shapes
|
|
84
|
+
before provider access. Normalized plans never include offset: the existing
|
|
85
|
+
`RecordQuery.offset` path is separate. MySQL executes every admitted predicate,
|
|
86
|
+
order, and finite bound in contained parameterized SQL; Datastore executes only
|
|
87
|
+
that stated overlap. See each provider reference for mappings and index needs.
|
|
88
|
+
|
|
89
|
+
## Lifecycle
|
|
90
|
+
|
|
91
|
+
The base `StorageFactory.close()` prevents later record-storage creation. The
|
|
92
|
+
in-memory factory follows that behavior and leaves existing record handles open
|
|
93
|
+
until each handle closes. `RecordStorage.close()` rejects that handle's later
|
|
94
|
+
operations. Datastore follows the base factory behavior. Adapters can define a
|
|
95
|
+
stronger shutdown lifecycle: the MySQL factory closes live handles while it
|
|
96
|
+
drains its pool. Read the [Datastore reference](../storage-datastore/REFERENCE.md)
|
|
97
|
+
and [MySQL reference](../storage-rdbms/REFERENCE.md) before relying on shutdown
|
|
98
|
+
behavior. The in-memory backend is ephemeral and process-local. Passing one
|
|
99
|
+
`InMemoryStorageBackend` to multiple in-memory factories deliberately shares
|
|
100
|
+
its scoped rows.
|
|
101
|
+
|
|
102
|
+
## Entity storage
|
|
103
|
+
|
|
104
|
+
The provider SPI supplies the framework's Entity storage
|
|
105
|
+
ports. Current Entity state is a generated `spine.server.entity.EntityRecord`.
|
|
106
|
+
Retained state history stores generated `EntityStateKey`/`EntityRecord` rows in
|
|
107
|
+
a `StorageGroup` named after the Entity state type. Retained diagnostic event
|
|
108
|
+
history stores generated `EventId`/`Event` rows in that same state-type-named
|
|
109
|
+
group. The framework Event Store is a separate, ungrouped `EventId`/`Event`
|
|
110
|
+
record family.
|
|
111
|
+
|
|
112
|
+
History ports are lazy. When a history is disabled, the in-memory provider does
|
|
113
|
+
not open or allocate its grouped records. Current Entity loading always uses
|
|
114
|
+
the current record, never retained history. Event history is diagnostic data,
|
|
115
|
+
not a source for rebuilding current state.
|
|
116
|
+
|
|
117
|
+
The provider SPI's Entity commit contract combines one current record with
|
|
118
|
+
the nonempty enabled history families and delivery events. For the in-memory
|
|
119
|
+
provider only, that operation stages and atomically publishes its touched
|
|
120
|
+
families. Its outcomes are `"committed"` and `"conflict"`; it has no receipt or
|
|
121
|
+
`"replayed"` outcome. Other providers define and document their atomicity
|
|
122
|
+
guarantees.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Message } from "@bufbuild/protobuf";
|
|
2
|
+
import type { GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
3
|
+
import { type Event, type EventId } from "@spine-event-engine/proto";
|
|
4
|
+
import { type EntityRecord } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
|
|
5
|
+
import { type EntityStateKey } from "@spine-event-engine/proto/generated/spine/server/entity/state_key_pb.js";
|
|
6
|
+
import { RecordSpec } from "../record/record-spec.js";
|
|
7
|
+
import { StorageGroup } from "../record/storage-group.js";
|
|
8
|
+
/**
|
|
9
|
+
* Creates the generated state-history layout for one Entity state type.
|
|
10
|
+
* @param stateType The served Entity state message type.
|
|
11
|
+
* @returns The separate group and record specification for retained states.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stateHistorySpec(stateType: GenMessage<Message>): {
|
|
14
|
+
readonly group: StorageGroup;
|
|
15
|
+
readonly spec: RecordSpec<EntityStateKey, EntityRecord>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Creates the generated diagnostic event-history layout for one Entity state type.
|
|
19
|
+
* @param stateType The served Entity state message type.
|
|
20
|
+
* @returns The separate group and record specification for retained events.
|
|
21
|
+
*/
|
|
22
|
+
export declare function eventHistorySpec(stateType: GenMessage<Message>): {
|
|
23
|
+
readonly group: StorageGroup;
|
|
24
|
+
readonly spec: RecordSpec<EventId, Event>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=entity-history-record-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-history-record-spec.d.ts","sourceRoot":"","sources":["../../src/entity/entity-history-record-spec.ts"],"names":[],"mappings":"AAcA,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAA8B,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,yEAAyE,CAAC;AAIjF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAChE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;CACzD,CA+BA;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAChE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CAC3C,CA8BA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { create, ScalarType } from "@bufbuild/protobuf";
|
|
15
|
+
import { AnySchema, TimestampSchema } from "@bufbuild/protobuf/wkt";
|
|
16
|
+
import { EventIdSchema, EventSchema } from "@spine-event-engine/proto";
|
|
17
|
+
import { EntityRecordSchema, } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
|
|
18
|
+
import { EntityStateKeySchema, } from "@spine-event-engine/proto/generated/spine/server/entity/state_key_pb.js";
|
|
19
|
+
import { RecordColumn } from "../record/record-column.js";
|
|
20
|
+
import { ColumnTypes } from "../record/column-type.js";
|
|
21
|
+
import { RecordSpec } from "../record/record-spec.js";
|
|
22
|
+
import { StorageGroup } from "../record/storage-group.js";
|
|
23
|
+
/**
|
|
24
|
+
* Creates the generated state-history layout for one Entity state type.
|
|
25
|
+
* @param stateType The served Entity state message type.
|
|
26
|
+
* @returns The separate group and record specification for retained states.
|
|
27
|
+
*/
|
|
28
|
+
export function stateHistorySpec(stateType) {
|
|
29
|
+
return {
|
|
30
|
+
group: new StorageGroup(stateType.typeName),
|
|
31
|
+
spec: new RecordSpec({
|
|
32
|
+
sourceType: stateType,
|
|
33
|
+
recordType: EntityRecordSchema,
|
|
34
|
+
idSchema: EntityStateKeySchema,
|
|
35
|
+
extractId: (record) => {
|
|
36
|
+
if (record.entityId === undefined) {
|
|
37
|
+
throw new Error("State history requires EntityRecord.entityId.");
|
|
38
|
+
}
|
|
39
|
+
return create(EntityStateKeySchema, {
|
|
40
|
+
entityId: record.entityId,
|
|
41
|
+
version: record.version?.number ?? 0,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
columns: [
|
|
45
|
+
new RecordColumn("entity_id", ColumnTypes.message(AnySchema), (record) => record.entityId),
|
|
46
|
+
new RecordColumn("created", ColumnTypes.message(TimestampSchema), (record) => record.version?.timestamp ?? create(TimestampSchema)),
|
|
47
|
+
new RecordColumn("version", ColumnTypes.scalar(ScalarType.INT32), (record) => record.version?.number ?? 0),
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates the generated diagnostic event-history layout for one Entity state type.
|
|
54
|
+
* @param stateType The served Entity state message type.
|
|
55
|
+
* @returns The separate group and record specification for retained events.
|
|
56
|
+
*/
|
|
57
|
+
export function eventHistorySpec(stateType) {
|
|
58
|
+
return {
|
|
59
|
+
group: new StorageGroup(stateType.typeName),
|
|
60
|
+
spec: new RecordSpec({
|
|
61
|
+
sourceType: EventSchema,
|
|
62
|
+
recordType: EventSchema,
|
|
63
|
+
idSchema: EventIdSchema,
|
|
64
|
+
extractId: (event) => {
|
|
65
|
+
if (event.id === undefined)
|
|
66
|
+
throw new Error("Event history requires Event.id.");
|
|
67
|
+
return event.id;
|
|
68
|
+
},
|
|
69
|
+
columns: [
|
|
70
|
+
new RecordColumn("entity_id", ColumnTypes.message(AnySchema), (event) => event.context?.producerId),
|
|
71
|
+
new RecordColumn("created", ColumnTypes.message(TimestampSchema), (event) => event.context?.timestamp ?? create(TimestampSchema)),
|
|
72
|
+
new RecordColumn("version", ColumnTypes.scalar(ScalarType.INT32), (event) => event.context?.version?.number ?? 0),
|
|
73
|
+
],
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=entity-history-record-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-history-record-spec.js","sourceRoot":"","sources":["../../src/entity/entity-history-record-spec.ts"],"names":[],"mappings":"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"}
|