@routier/core 0.2.1 → 0.4.0
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 +21 -0
- package/{readme.md → README.md} +3 -3
- package/dist/assertions/index.cjs +191 -0
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.js +43 -63
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.cjs +820 -0
- package/dist/capabilities/index.cjs.map +1 -0
- package/dist/capabilities/index.js +584 -558
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
- package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
- package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
- package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
- package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
- package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
- package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
- package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
- package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
- package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
- package/dist/codegen/handlers/types.d.ts +55 -1
- package/dist/codegen/index.cjs +618 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.js +99 -127
- package/dist/codegen/index.js.map +1 -1
- package/dist/collections/MemoryDataCollection.d.ts +15 -1
- package/dist/collections/TagCollection.d.ts +0 -1
- package/dist/collections/index.cjs +702 -0
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.js +282 -276
- package/dist/collections/index.js.map +1 -1
- package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
- package/dist/errors/PluginDestroyedError.d.ts +10 -0
- package/dist/errors/index.cjs +132 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +61 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/expressions/evaluate.d.ts +53 -0
- package/dist/expressions/index.cjs +2087 -0
- package/dist/expressions/index.cjs.map +1 -0
- package/dist/expressions/index.d.ts +1 -1
- package/dist/expressions/index.js +1727 -1082
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/parser.d.ts +19 -0
- package/dist/expressions/types.d.ts +87 -2
- package/dist/index.cjs +14377 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +12374 -7931
- package/dist/index.js.map +1 -1
- package/dist/performance/index.cjs +217 -0
- package/dist/performance/index.cjs.map +1 -0
- package/dist/performance/index.js +120 -55
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.cjs +576 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.js +223 -161
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
- package/dist/plugins/CacheDbPlugin.d.ts +70 -0
- package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
- package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
- package/dist/plugins/RetryDbPlugin.d.ts +77 -0
- package/dist/plugins/index.cjs +6551 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +6271 -1170
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +34 -0
- package/dist/plugins/query/explain.d.ts +82 -0
- package/dist/plugins/query/formatExplanation.d.ts +9 -0
- package/dist/plugins/query/index.d.ts +4 -0
- package/dist/plugins/query/join.d.ts +210 -0
- package/dist/plugins/query/similarity.d.ts +38 -0
- package/dist/plugins/query/types.d.ts +75 -1
- package/dist/plugins/translators/DataTranslator.d.ts +28 -0
- package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
- package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
- package/dist/plugins/translators/index.d.ts +1 -0
- package/dist/plugins/types.d.ts +125 -3
- package/dist/plugins/wire/handler.d.ts +122 -0
- package/dist/plugins/wire/index.d.ts +4 -0
- package/dist/plugins/wire/persist.d.ts +43 -0
- package/dist/plugins/wire/query.d.ts +49 -0
- package/dist/plugins/wire/types.d.ts +139 -0
- package/dist/results/index.cjs +174 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.js +29 -44
- package/dist/results/index.js.map +1 -1
- package/dist/schema/PropertyInfo.d.ts +31 -2
- package/dist/schema/SchemaDefinition.d.ts +23 -1
- package/dist/schema/builder.d.ts +35 -1
- package/dist/schema/communication/broadcast.d.ts +17 -1
- package/dist/schema/index.cjs +6911 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +5330 -4541
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +48 -2
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
- package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
- package/dist/schema/property/modifiers/index.d.ts +1 -0
- package/dist/schema/property/types/SchemaFile.d.ts +60 -0
- package/dist/schema/property/types/SchemaString.d.ts +21 -1
- package/dist/schema/property/types/SchemaVector.d.ts +61 -0
- package/dist/schema/property/types/index.d.ts +2 -0
- package/dist/schema/table/SchemaTransform.d.ts +40 -0
- package/dist/schema/table/index.d.ts +1 -0
- package/dist/schema/types.d.ts +166 -8
- package/dist/schema/utils/propertyKind.d.ts +4 -0
- package/dist/types/index.cjs +23 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.js +0 -14
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.cjs +1013 -0
- package/dist/utilities/index.cjs.map +1 -0
- package/dist/utilities/index.js +541 -379
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +48 -0
- package/package.json +156 -98
- package/dist/codegen/SlotPath.test.d.ts +0 -1
- package/dist/codegen/blocks.test.d.ts +0 -1
- package/dist/codegen/utils.test.d.ts +0 -1
- package/dist/collections/Changes.test.d.ts +0 -1
- package/dist/collections/IdSet.test.d.ts +0 -1
- package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
- package/dist/collections/TagCollection.contract.test.d.ts +0 -1
- package/dist/collections/TagCollection.test.d.ts +0 -1
- package/dist/expressions/parser.test.d.ts +0 -1
- package/dist/expressions/sql.d.ts +0 -28
- package/dist/expressions/sql.test.d.ts +0 -1
- package/dist/expressions/utils.test.d.ts +0 -1
- package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
- package/dist/plugins/query/Query.test.d.ts +0 -1
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
- package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
- package/dist/results/Result.test.d.ts +0 -1
- package/dist/results/utils.test.d.ts +0 -1
- package/dist/schema/PropertyInfo.test.d.ts +0 -1
- package/dist/schema/communication/broadcast.test.d.ts +0 -1
- package/dist/schema/schemaGeneration.test.d.ts +0 -1
- package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
- package/dist/utilities/arrays.test.d.ts +0 -1
- package/dist/utilities/dates.test.d.ts +0 -1
- package/dist/utilities/runtime.test.d.ts +0 -1
- package/dist/utilities/strings.test.d.ts +0 -1
- package/dist/utilities/uuid.test.d.ts +0 -1
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_modules__ = ({
|
|
4
|
+
533(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
$E: () => (SchemaPersistChanges),
|
|
7
|
+
R7: () => (SchemaPersistResult),
|
|
8
|
+
om: () => (BulkPersistResult),
|
|
9
|
+
qk: () => (BulkPersistChanges)
|
|
10
|
+
});
|
|
11
|
+
/* import */ var _TagCollection__rspack_import_0 = __webpack_require__(356);
|
|
12
|
+
|
|
13
|
+
class BulkPersistResult extends Map {
|
|
14
|
+
resolve(schemaId) {
|
|
15
|
+
if (this.has(schemaId)) {
|
|
16
|
+
return this.get(schemaId);
|
|
17
|
+
}
|
|
18
|
+
this.set(schemaId, new SchemaPersistResult());
|
|
19
|
+
return this.get(schemaId);
|
|
20
|
+
}
|
|
21
|
+
get(schemaId) {
|
|
22
|
+
return super.get(schemaId);
|
|
23
|
+
}
|
|
24
|
+
get aggregate() {
|
|
25
|
+
return {
|
|
26
|
+
size: this.aggregateSize,
|
|
27
|
+
adds: this.aggregateAddsSize,
|
|
28
|
+
updates: this.aggregateUpdatesSize,
|
|
29
|
+
removes: this.aggregateRemovesSize
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
get aggregateSize() {
|
|
33
|
+
let count = 0;
|
|
34
|
+
for (const [, result] of this){
|
|
35
|
+
count += result.total;
|
|
36
|
+
}
|
|
37
|
+
return count;
|
|
38
|
+
}
|
|
39
|
+
get aggregateAddsSize() {
|
|
40
|
+
let count = 0;
|
|
41
|
+
for (const [, result] of this){
|
|
42
|
+
count += result.adds.length;
|
|
43
|
+
}
|
|
44
|
+
return count;
|
|
45
|
+
}
|
|
46
|
+
get aggregateUpdatesSize() {
|
|
47
|
+
let count = 0;
|
|
48
|
+
for (const [, result] of this){
|
|
49
|
+
count += result.updates.length;
|
|
50
|
+
}
|
|
51
|
+
return count;
|
|
52
|
+
}
|
|
53
|
+
get aggregateRemovesSize() {
|
|
54
|
+
let count = 0;
|
|
55
|
+
for (const [, result] of this){
|
|
56
|
+
count += result.removes.length;
|
|
57
|
+
}
|
|
58
|
+
return count;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class BulkPersistChanges extends Map {
|
|
62
|
+
resolve(schemaId) {
|
|
63
|
+
if (this.has(schemaId)) {
|
|
64
|
+
return this.get(schemaId);
|
|
65
|
+
}
|
|
66
|
+
this.set(schemaId, new SchemaPersistChanges());
|
|
67
|
+
return this.get(schemaId);
|
|
68
|
+
}
|
|
69
|
+
get(schemaId) {
|
|
70
|
+
return super.get(schemaId);
|
|
71
|
+
}
|
|
72
|
+
get aggregate() {
|
|
73
|
+
return {
|
|
74
|
+
size: this.aggregateSize,
|
|
75
|
+
adds: this.aggregateAddsSize,
|
|
76
|
+
updates: this.aggregateUpdatesSize,
|
|
77
|
+
removes: this.aggregateRemovesSize
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
get aggregateSize() {
|
|
81
|
+
let count = 0;
|
|
82
|
+
for (const [, result] of this){
|
|
83
|
+
count += result.total;
|
|
84
|
+
}
|
|
85
|
+
return count;
|
|
86
|
+
}
|
|
87
|
+
get aggregateAddsSize() {
|
|
88
|
+
let count = 0;
|
|
89
|
+
for (const [, result] of this){
|
|
90
|
+
count += result.adds.length;
|
|
91
|
+
}
|
|
92
|
+
return count;
|
|
93
|
+
}
|
|
94
|
+
get aggregateUpdatesSize() {
|
|
95
|
+
let count = 0;
|
|
96
|
+
for (const [, result] of this){
|
|
97
|
+
count += result.updates.length;
|
|
98
|
+
}
|
|
99
|
+
return count;
|
|
100
|
+
}
|
|
101
|
+
get aggregateRemovesSize() {
|
|
102
|
+
let count = 0;
|
|
103
|
+
for (const [, result] of this){
|
|
104
|
+
count += result.removes.length;
|
|
105
|
+
}
|
|
106
|
+
return count;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Ensures the result has the same result sets as the change sets
|
|
110
|
+
* @returns
|
|
111
|
+
*/ toResult() {
|
|
112
|
+
const result = new BulkPersistResult();
|
|
113
|
+
for (const [schemaId] of this){
|
|
114
|
+
result.set(schemaId, new SchemaPersistResult());
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
class SchemaPersistChanges {
|
|
120
|
+
adds = [];
|
|
121
|
+
updates = [];
|
|
122
|
+
removes = [];
|
|
123
|
+
tags = new _TagCollection__rspack_import_0/* .TagCollection */.r();
|
|
124
|
+
get hasItems() {
|
|
125
|
+
return this.total > 0;
|
|
126
|
+
}
|
|
127
|
+
get total() {
|
|
128
|
+
return this.adds.length + this.updates.length + this.removes.length;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
class SchemaPersistResult {
|
|
132
|
+
adds = [];
|
|
133
|
+
updates = [];
|
|
134
|
+
removes = [];
|
|
135
|
+
get hasItems() {
|
|
136
|
+
return this.total > 0;
|
|
137
|
+
}
|
|
138
|
+
get total() {
|
|
139
|
+
return this.adds.length + this.updates.length + this.removes.length;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
},
|
|
145
|
+
995(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
146
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
147
|
+
g: () => (ReadonlySchemaCollection)
|
|
148
|
+
});
|
|
149
|
+
/**
|
|
150
|
+
* Collection of schemas with generic typing for type-safe schema retrieval
|
|
151
|
+
*/ class ReadonlySchemaCollection {
|
|
152
|
+
data;
|
|
153
|
+
constructor(data){
|
|
154
|
+
this.data = new Map(data);
|
|
155
|
+
}
|
|
156
|
+
get(schemaId) {
|
|
157
|
+
return this.data.get(schemaId);
|
|
158
|
+
}
|
|
159
|
+
has(schemaId) {
|
|
160
|
+
return this.data.has(schemaId);
|
|
161
|
+
}
|
|
162
|
+
get size() {
|
|
163
|
+
return this.data.size;
|
|
164
|
+
}
|
|
165
|
+
keys() {
|
|
166
|
+
return this.data.keys();
|
|
167
|
+
}
|
|
168
|
+
values() {
|
|
169
|
+
return this.data.values();
|
|
170
|
+
}
|
|
171
|
+
entries() {
|
|
172
|
+
return this.data.entries();
|
|
173
|
+
}
|
|
174
|
+
forEach(callbackfn, thisArg) {
|
|
175
|
+
this.data.forEach(callbackfn, thisArg);
|
|
176
|
+
}
|
|
177
|
+
[Symbol.iterator]() {
|
|
178
|
+
return this.data[Symbol.iterator]();
|
|
179
|
+
}
|
|
180
|
+
getByName(collectionName) {
|
|
181
|
+
const found = [
|
|
182
|
+
...this.data
|
|
183
|
+
].find((x)=>x[1].collectionName === collectionName);
|
|
184
|
+
if (found != null) {
|
|
185
|
+
return found[1];
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
},
|
|
193
|
+
393(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
194
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
195
|
+
w: () => (SchemaCollection)
|
|
196
|
+
});
|
|
197
|
+
/* import */ var _ReadonlySchemaCollection__rspack_import_0 = __webpack_require__(995);
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Collection of schemas with generic typing for type-safe schema retrieval
|
|
201
|
+
*/ class SchemaCollection extends _ReadonlySchemaCollection__rspack_import_0/* .ReadonlySchemaCollection */.g {
|
|
202
|
+
set(schemaId, schema) {
|
|
203
|
+
this.data.set(schemaId, schema);
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
delete(schemaId) {
|
|
207
|
+
return this.data.delete(schemaId);
|
|
208
|
+
}
|
|
209
|
+
clear() {
|
|
210
|
+
this.data.clear();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
},
|
|
216
|
+
356(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
217
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
218
|
+
r: () => (TagCollection)
|
|
219
|
+
});
|
|
220
|
+
class TagCollection {
|
|
221
|
+
data = new Map();
|
|
222
|
+
// Delegated to the map rather than tracked in a counter field: every mutation path
|
|
223
|
+
// (set, setMany, combine, delete, dispose) would otherwise have to maintain it, and
|
|
224
|
+
// a missed path silently reports a size that disagrees with the contents.
|
|
225
|
+
get size() {
|
|
226
|
+
return this.data.size;
|
|
227
|
+
}
|
|
228
|
+
get(key) {
|
|
229
|
+
return this.data.get(key);
|
|
230
|
+
}
|
|
231
|
+
has(key) {
|
|
232
|
+
return this.data.has(key);
|
|
233
|
+
}
|
|
234
|
+
set(key, tag) {
|
|
235
|
+
return this.data.set(key, tag);
|
|
236
|
+
}
|
|
237
|
+
delete(key) {
|
|
238
|
+
return this.data.delete(key);
|
|
239
|
+
}
|
|
240
|
+
setMany(keys, tag) {
|
|
241
|
+
for(let i = 0, length = keys.length; i < length; i++){
|
|
242
|
+
const key = keys[i];
|
|
243
|
+
this.set(key, tag);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
combine(tags) {
|
|
247
|
+
for (const [key, value] of tags){
|
|
248
|
+
this.set(key, value);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
values() {
|
|
252
|
+
return this.data.values();
|
|
253
|
+
}
|
|
254
|
+
keys() {
|
|
255
|
+
return this.data.keys();
|
|
256
|
+
}
|
|
257
|
+
[Symbol.dispose]() {
|
|
258
|
+
this.data.clear();
|
|
259
|
+
}
|
|
260
|
+
[Symbol.iterator]() {
|
|
261
|
+
return this.data[Symbol.iterator]();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
},
|
|
267
|
+
718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
268
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
269
|
+
Q: () => (Result)
|
|
270
|
+
});
|
|
271
|
+
class BaseResult {
|
|
272
|
+
static ERROR = "error";
|
|
273
|
+
static SUCCESS = "success";
|
|
274
|
+
static PARTIAL = "partial";
|
|
275
|
+
static resolve(result, resolve, reject) {
|
|
276
|
+
if (result.ok === BaseResult.SUCCESS) {
|
|
277
|
+
resolve(result.data);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (result.ok === BaseResult.PARTIAL) {
|
|
281
|
+
reject({
|
|
282
|
+
partial: result.data,
|
|
283
|
+
error: result.error
|
|
284
|
+
});
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
reject(result.error);
|
|
288
|
+
}
|
|
289
|
+
static assertSuccess(result) {
|
|
290
|
+
if (result.ok !== BaseResult.SUCCESS) {
|
|
291
|
+
throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
class Result extends BaseResult {
|
|
296
|
+
static success(data) {
|
|
297
|
+
return {
|
|
298
|
+
ok: Result.SUCCESS,
|
|
299
|
+
data
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
static error(error) {
|
|
303
|
+
return {
|
|
304
|
+
ok: Result.ERROR,
|
|
305
|
+
error
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
static partial(data, error) {
|
|
309
|
+
return {
|
|
310
|
+
ok: Result.PARTIAL,
|
|
311
|
+
data,
|
|
312
|
+
error
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
class PluginEventResult extends (/* unused pure expression or super */ null && (BaseResult)) {
|
|
317
|
+
static success(id, data) {
|
|
318
|
+
return {
|
|
319
|
+
id,
|
|
320
|
+
ok: Result.SUCCESS,
|
|
321
|
+
data
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
static error(id, error) {
|
|
325
|
+
return {
|
|
326
|
+
id,
|
|
327
|
+
ok: Result.ERROR,
|
|
328
|
+
error
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
static partial(id, data, error) {
|
|
332
|
+
return {
|
|
333
|
+
id,
|
|
334
|
+
ok: Result.PARTIAL,
|
|
335
|
+
data,
|
|
336
|
+
error
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
static assertSuccess(result) {
|
|
340
|
+
if (result.ok !== Result.SUCCESS) {
|
|
341
|
+
throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
},
|
|
348
|
+
537(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
349
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
350
|
+
L: () => (SchemaTypes)
|
|
351
|
+
});
|
|
352
|
+
var SchemaTypes = /*#__PURE__*/ function(SchemaTypes) {
|
|
353
|
+
SchemaTypes["Array"] = "Array";
|
|
354
|
+
SchemaTypes["Boolean"] = "Boolean";
|
|
355
|
+
SchemaTypes["Date"] = "Date";
|
|
356
|
+
SchemaTypes["Number"] = "Number";
|
|
357
|
+
SchemaTypes["Object"] = "Object";
|
|
358
|
+
SchemaTypes["String"] = "String";
|
|
359
|
+
SchemaTypes["Definition"] = "Definition";
|
|
360
|
+
SchemaTypes["Function"] = "Function";
|
|
361
|
+
SchemaTypes["Computed"] = "Computed";
|
|
362
|
+
/**
|
|
363
|
+
* Content in, reference out. The only type whose write shape differs from its stored
|
|
364
|
+
* shape, and a leaf on purpose — see `SchemaFile`.
|
|
365
|
+
*/ SchemaTypes["File"] = "File";
|
|
366
|
+
/**
|
|
367
|
+
* A fixed-length list of numbers, carrying its dimension count — see `SchemaVector`.
|
|
368
|
+
*
|
|
369
|
+
* Value-shaped exactly like `s.array(s.number())`, which is why every array codegen
|
|
370
|
+
* handler accepts it. It is a distinct type only so a backend can recognise it and store
|
|
371
|
+
* it natively; nothing else needs to tell the two apart.
|
|
372
|
+
*/ SchemaTypes["Vector"] = "Vector";
|
|
373
|
+
return SchemaTypes;
|
|
374
|
+
}({});
|
|
375
|
+
var HashType = /*#__PURE__*/ (/* unused pure expression or super */ null && (function(HashType) {
|
|
376
|
+
HashType["Ids"] = "Ids";
|
|
377
|
+
HashType["Object"] = "Object";
|
|
378
|
+
return HashType;
|
|
379
|
+
}({})));
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
},
|
|
383
|
+
618(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
384
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
385
|
+
g: () => (uuidv4)
|
|
386
|
+
});
|
|
387
|
+
const uuid = (length = 16)=>{
|
|
388
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
389
|
+
const charLength = chars.length;
|
|
390
|
+
let result = '';
|
|
391
|
+
for(let i = 0; i < length; i++){
|
|
392
|
+
result += chars[Math.random() * charLength | 0];
|
|
393
|
+
}
|
|
394
|
+
return result;
|
|
395
|
+
};
|
|
396
|
+
const HEX_CHARS = '0123456789abcdef';
|
|
397
|
+
const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
398
|
+
const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
|
|
399
|
+
const hasRandomUUID = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
|
|
400
|
+
const uuidv4 = ()=>{
|
|
401
|
+
if (hasRandomUUID) {
|
|
402
|
+
return crypto.randomUUID();
|
|
403
|
+
}
|
|
404
|
+
return uuidv4Fallback();
|
|
405
|
+
};
|
|
406
|
+
const uuidv4Fallback = ()=>{
|
|
407
|
+
let randomBytes = null;
|
|
408
|
+
if (hasCrypto) {
|
|
409
|
+
randomBytes = crypto.getRandomValues(new Uint8Array(16));
|
|
410
|
+
}
|
|
411
|
+
let byteIndex = 0;
|
|
412
|
+
let uuid = '';
|
|
413
|
+
for(let i = 0; i < UUID_TEMPLATE.length; i++){
|
|
414
|
+
const c = UUID_TEMPLATE[i];
|
|
415
|
+
if (c === '-') {
|
|
416
|
+
uuid += '-';
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
let r;
|
|
420
|
+
if (hasCrypto && randomBytes) {
|
|
421
|
+
// Each byte gives two hex digits (nibbles)
|
|
422
|
+
r = i % 2 === 0 ? randomBytes[byteIndex] >> 4 : randomBytes[byteIndex++] & 0x0f;
|
|
423
|
+
} else {
|
|
424
|
+
r = Math.floor(Math.random() * 16);
|
|
425
|
+
}
|
|
426
|
+
if (c === 'x') {
|
|
427
|
+
uuid += HEX_CHARS[r];
|
|
428
|
+
} else if (c === 'y') {
|
|
429
|
+
// Variant bits: 8, 9, A, or B
|
|
430
|
+
uuid += HEX_CHARS[r & 0x3 | 0x8];
|
|
431
|
+
} else if (c === '4') {
|
|
432
|
+
uuid += '4';
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return uuid;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
});
|
|
442
|
+
// The module cache
|
|
443
|
+
var __webpack_module_cache__ = {};
|
|
444
|
+
|
|
445
|
+
// The require function
|
|
446
|
+
function __webpack_require__(moduleId) {
|
|
447
|
+
|
|
448
|
+
// Check if module is in cache
|
|
449
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
450
|
+
if (cachedModule !== undefined) {
|
|
451
|
+
return cachedModule.exports;
|
|
452
|
+
}
|
|
453
|
+
// Create a new module (and put it into the cache)
|
|
454
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
455
|
+
exports: {}
|
|
456
|
+
});
|
|
457
|
+
// Execute the module function
|
|
458
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
459
|
+
|
|
460
|
+
// Return the exports of the module
|
|
461
|
+
return module.exports;
|
|
462
|
+
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// webpack/runtime/define_property_getters
|
|
466
|
+
(() => {
|
|
467
|
+
__webpack_require__.d = (exports, definition) => {
|
|
468
|
+
for(var key in definition) {
|
|
469
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
470
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
})();
|
|
475
|
+
// webpack/runtime/has_own_property
|
|
476
|
+
(() => {
|
|
477
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
478
|
+
})();
|
|
479
|
+
// webpack/runtime/make_namespace_object
|
|
480
|
+
(() => {
|
|
481
|
+
// define __esModule on exports
|
|
482
|
+
__webpack_require__.r = (exports) => {
|
|
483
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
484
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
485
|
+
}
|
|
486
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
487
|
+
};
|
|
488
|
+
})();
|
|
489
|
+
var __webpack_exports__ = {};
|
|
490
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
491
|
+
(() => {
|
|
492
|
+
// ESM COMPAT FLAG
|
|
493
|
+
__webpack_require__.r(__webpack_exports__);
|
|
494
|
+
|
|
495
|
+
// EXPORTS
|
|
496
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
497
|
+
SchemaCollection: () => (/* reexport */ SchemaCollection/* .SchemaCollection */.w),
|
|
498
|
+
IdSet: () => (/* reexport */ IdSet),
|
|
499
|
+
TagCollection: () => (/* reexport */ TagCollection/* .TagCollection */.r),
|
|
500
|
+
BulkPersistChanges: () => (/* reexport */ Changes/* .BulkPersistChanges */.qk),
|
|
501
|
+
BulkPersistResult: () => (/* reexport */ Changes/* .BulkPersistResult */.om),
|
|
502
|
+
SchemaPersistChanges: () => (/* reexport */ Changes/* .SchemaPersistChanges */.$E),
|
|
503
|
+
SchemaPersistResult: () => (/* reexport */ Changes/* .SchemaPersistResult */.R7),
|
|
504
|
+
ReadonlySchemaCollection: () => (/* reexport */ ReadonlySchemaCollection/* .ReadonlySchemaCollection */.g),
|
|
505
|
+
MemoryDataCollection: () => (/* reexport */ MemoryDataCollection)
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// EXTERNAL MODULE: ./src/collections/Changes.ts
|
|
509
|
+
var Changes = __webpack_require__(533);
|
|
510
|
+
// EXTERNAL MODULE: ./src/collections/TagCollection.ts
|
|
511
|
+
var TagCollection = __webpack_require__(356);
|
|
512
|
+
;// CONCATENATED MODULE: ./src/collections/IdSet.ts
|
|
513
|
+
class IdSet {
|
|
514
|
+
ids;
|
|
515
|
+
constructor(...ids){
|
|
516
|
+
this.ids = Object.freeze(ids);
|
|
517
|
+
}
|
|
518
|
+
equals(other) {
|
|
519
|
+
if (this.ids.length === 1) {
|
|
520
|
+
return this.ids[0] === other.ids[0];
|
|
521
|
+
}
|
|
522
|
+
return this.toString() === other.toString();
|
|
523
|
+
}
|
|
524
|
+
toString() {
|
|
525
|
+
if (this.ids.length === 1) {
|
|
526
|
+
return String(this.ids[0]);
|
|
527
|
+
}
|
|
528
|
+
return this.ids.toString();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// EXTERNAL MODULE: ./src/schema/types.ts
|
|
533
|
+
var types = __webpack_require__(537);
|
|
534
|
+
// EXTERNAL MODULE: ./src/results/Result.ts
|
|
535
|
+
var Result = __webpack_require__(718);
|
|
536
|
+
// EXTERNAL MODULE: ./src/utilities/uuid.ts
|
|
537
|
+
var utilities_uuid = __webpack_require__(618);
|
|
538
|
+
;// CONCATENATED MODULE: ./src/collections/MemoryDataCollection.ts
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
class MemoryDataCollection {
|
|
544
|
+
nextNumericalIds;
|
|
545
|
+
data;
|
|
546
|
+
schema;
|
|
547
|
+
idProperties;
|
|
548
|
+
get size() {
|
|
549
|
+
return this.data.size;
|
|
550
|
+
}
|
|
551
|
+
get records() {
|
|
552
|
+
return [
|
|
553
|
+
...this.data.values()
|
|
554
|
+
];
|
|
555
|
+
}
|
|
556
|
+
/** Iterates stored records without materializing them into an array. */ values() {
|
|
557
|
+
return this.data.values();
|
|
558
|
+
}
|
|
559
|
+
constructor(schema){
|
|
560
|
+
this.data = new Map();
|
|
561
|
+
this.nextNumericalIds = new Map();
|
|
562
|
+
this.schema = schema;
|
|
563
|
+
this.idProperties = schema.idProperties;
|
|
564
|
+
}
|
|
565
|
+
_getNextId(property) {
|
|
566
|
+
let nextId = 1;
|
|
567
|
+
if (this.nextNumericalIds.has(property.id) === true) {
|
|
568
|
+
nextId = this.nextNumericalIds.get(property.id) + 1;
|
|
569
|
+
}
|
|
570
|
+
this.nextNumericalIds.set(property.id, nextId);
|
|
571
|
+
return nextId;
|
|
572
|
+
}
|
|
573
|
+
resolveId(property, value) {
|
|
574
|
+
if (typeof value !== "number") {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const currentIdForProperty = this.nextNumericalIds.get(property.id);
|
|
578
|
+
if (value <= currentIdForProperty) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
this.nextNumericalIds.set(property.id, value);
|
|
582
|
+
}
|
|
583
|
+
getAndSetId(item, property) {
|
|
584
|
+
if (item[property.name] != null) {
|
|
585
|
+
return item[property.name];
|
|
586
|
+
}
|
|
587
|
+
if (property.type === types/* .SchemaTypes.String */.L.String) {
|
|
588
|
+
const uuid = (0,utilities_uuid/* .uuidv4 */.g)();
|
|
589
|
+
item[property.name] = uuid;
|
|
590
|
+
return uuid;
|
|
591
|
+
}
|
|
592
|
+
if (property.type === types/* .SchemaTypes.Number */.L.Number) {
|
|
593
|
+
const id = this._getNextId(property);
|
|
594
|
+
item[property.name] = id;
|
|
595
|
+
return id;
|
|
596
|
+
}
|
|
597
|
+
throw new Error(`Id Property '${property.name}' must be string or number, found '${property.type}'`);
|
|
598
|
+
}
|
|
599
|
+
seed(items) {
|
|
600
|
+
for(let i = 0, length = items.length; i < length; i++){
|
|
601
|
+
const id = this.resolveIdSet(items[i]);
|
|
602
|
+
this.data.set(id.toString(), items[i]);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
resolveCurrentIdSet(item) {
|
|
606
|
+
const idProperties = this.schema.idProperties;
|
|
607
|
+
const ids = [];
|
|
608
|
+
// ensure keys
|
|
609
|
+
for(let j = 0, l = idProperties.length; j < l; j++){
|
|
610
|
+
const property = idProperties[j];
|
|
611
|
+
const value = property.getValue(item);
|
|
612
|
+
if (value == null) {
|
|
613
|
+
throw new Error(`Key cannot be null. Key: ${property.name}`);
|
|
614
|
+
}
|
|
615
|
+
ids.push(value);
|
|
616
|
+
}
|
|
617
|
+
return new IdSet(...ids);
|
|
618
|
+
}
|
|
619
|
+
resolveIdSet(item) {
|
|
620
|
+
if (this.schema.hasIdentityKeys) {
|
|
621
|
+
const idProperties = this.schema.idProperties;
|
|
622
|
+
const ids = Array.from({
|
|
623
|
+
length: idProperties.length
|
|
624
|
+
});
|
|
625
|
+
// Need to make sure we allow for seeding the collection when we call add vs seed
|
|
626
|
+
// There will be an existing id, but the id type could still be identity
|
|
627
|
+
if (idProperties.length === 1) {
|
|
628
|
+
const value = this.getAndSetId(item, idProperties[0]);
|
|
629
|
+
this.resolveId(idProperties[0], value);
|
|
630
|
+
ids[0] = value;
|
|
631
|
+
} else {
|
|
632
|
+
for(let j = 0, l = idProperties.length; j < l; j++){
|
|
633
|
+
const value = this.getAndSetId(item, idProperties[j]);
|
|
634
|
+
this.resolveId(idProperties[j], value);
|
|
635
|
+
ids[j] = value;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return new IdSet(...ids);
|
|
639
|
+
}
|
|
640
|
+
return this.resolveCurrentIdSet(item);
|
|
641
|
+
}
|
|
642
|
+
add(item) {
|
|
643
|
+
const id = this.resolveIdSet(item);
|
|
644
|
+
this.data.set(id.toString(), item);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Adds a record only when no record with the same key is present. Durable
|
|
648
|
+
* collections use this to hydrate stored records around in-memory mutations
|
|
649
|
+
* without clobbering them.
|
|
650
|
+
*/ addIfAbsent(item) {
|
|
651
|
+
const id = this.resolveIdSet(item);
|
|
652
|
+
const key = id.toString();
|
|
653
|
+
if (this.data.has(key) === false) {
|
|
654
|
+
this.data.set(key, item);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Looks up a single record by its key values without scanning the collection.
|
|
659
|
+
* @param ids Key values in schema id property order
|
|
660
|
+
* @returns The matching record or undefined when no record has the given key
|
|
661
|
+
*/ getByIds(ids) {
|
|
662
|
+
return this.data.get(new IdSet(...ids).toString());
|
|
663
|
+
}
|
|
664
|
+
remove(item) {
|
|
665
|
+
const id = this.resolveCurrentIdSet(item);
|
|
666
|
+
this.data.delete(id.toString());
|
|
667
|
+
}
|
|
668
|
+
update(item) {
|
|
669
|
+
const id = this.resolveCurrentIdSet(item);
|
|
670
|
+
this.data.set(id.toString(), item);
|
|
671
|
+
}
|
|
672
|
+
destroy(done) {
|
|
673
|
+
this.nextNumericalIds.clear();
|
|
674
|
+
this.data.clear();
|
|
675
|
+
done(Result/* .Result.success */.Q.success());
|
|
676
|
+
}
|
|
677
|
+
load(done) {
|
|
678
|
+
done(Result/* .Result.success */.Q.success());
|
|
679
|
+
}
|
|
680
|
+
save(done) {
|
|
681
|
+
done(Result/* .Result.success */.Q.success());
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// EXTERNAL MODULE: ./src/collections/SchemaCollection.ts
|
|
686
|
+
var SchemaCollection = __webpack_require__(393);
|
|
687
|
+
// EXTERNAL MODULE: ./src/collections/ReadonlySchemaCollection.ts
|
|
688
|
+
var ReadonlySchemaCollection = __webpack_require__(995);
|
|
689
|
+
;// CONCATENATED MODULE: ./src/collections/index.ts
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
})();
|
|
698
|
+
|
|
699
|
+
module.exports = __webpack_exports__;
|
|
700
|
+
})()
|
|
701
|
+
;
|
|
702
|
+
//# sourceMappingURL=index.cjs.map
|