@routier/core 0.2.0 → 0.2.1
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/dist/assertions/index.d.ts +30 -0
- package/dist/assertions/index.js +88 -4
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.js +25 -16
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/blocks.test.d.ts +1 -0
- package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/index.d.ts +1 -0
- package/dist/codegen/handlers/serialize/SerializeComputedHandler.d.ts +6 -0
- package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -0
- package/dist/codegen/index.js +1 -0
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/utils.test.d.ts +1 -0
- package/dist/collections/Changes.d.ts +2 -2
- package/dist/collections/IdSet.test.d.ts +1 -0
- package/dist/collections/TagCollection.contract.test.d.ts +1 -0
- package/dist/collections/TagCollection.d.ts +7 -7
- package/dist/collections/index.js +1 -1
- package/dist/collections/index.js.map +1 -1
- package/dist/expressions/constants.d.ts +2 -0
- package/dist/expressions/index.d.ts +2 -0
- package/dist/expressions/index.js +401 -34
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/sql.d.ts +28 -0
- package/dist/expressions/sql.test.d.ts +1 -0
- package/dist/expressions/utils.d.ts +1 -2
- package/dist/index.js +1669 -610
- package/dist/index.js.map +1 -1
- package/dist/performance/index.js +18 -7
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.js +18 -7
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +126 -694
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/Query.test.d.ts +1 -0
- package/dist/plugins/query/QueryOptionsCollection.d.ts +1 -0
- package/dist/plugins/translators/SqlTranslator.test.d.ts +1 -0
- package/dist/plugins/translators/TranslatedArrayValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedValues.test.d.ts +1 -0
- package/dist/plugins/translators/types.d.ts +8 -1
- package/dist/plugins/types.d.ts +6 -10
- package/dist/results/Result.d.ts +2 -2
- package/dist/results/Result.test.d.ts +1 -0
- package/dist/results/index.js.map +1 -1
- package/dist/results/utils.test.d.ts +1 -0
- package/dist/schema/PropertyInfo.d.ts +5 -1
- package/dist/schema/SchemaDefinition.d.ts +29 -1
- package/dist/schema/communication/broadcast.test.d.ts +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +1151 -132
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +3 -1
- package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
- package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
- package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +5 -1
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +3 -1
- package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
- package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
- package/dist/schema/property/modifiers/index.d.ts +2 -0
- package/dist/schema/property/types/SchemaArray.d.ts +2 -0
- package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
- package/dist/schema/property/types/SchemaDate.d.ts +2 -0
- package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
- package/dist/schema/property/types/SchemaObject.d.ts +2 -0
- package/dist/schema/property/types/SchemaString.d.ts +5 -1
- package/dist/schema/types.d.ts +37 -27
- package/dist/schema/utils/standardJsonSchema.d.ts +90 -0
- package/dist/schema/utils/standardJsonSchema.test.d.ts +1 -0
- package/dist/utilities/functions.d.ts +1 -1
- package/dist/utilities/index.js +153 -15
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/runtime.test.d.ts +1 -0
- package/dist/utilities/uuid.test.d.ts +1 -0
- package/package.json +2 -2
- package/readme.md +1 -1
- package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -23
- package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
- package/dist/plugins/replication/index.d.ts +0 -3
- package/dist/plugins/replication/types.d.ts +0 -5
- package/dist/schema/testSchemas.test.d.ts +0 -314
- /package/dist/{pipeline/WorkPipeline.test.d.ts → codegen/SlotPath.test.d.ts} +0 -0
package/dist/plugins/index.js
CHANGED
|
@@ -6,10 +6,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
6
6
|
assertInstanceOf: () => (assertInstanceOf),
|
|
7
7
|
assertIsArray: () => (assertIsArray),
|
|
8
8
|
assertIsNotNull: () => (assertIsNotNull),
|
|
9
|
-
|
|
9
|
+
assertIsNumber: () => (assertIsNumber),
|
|
10
|
+
assertString: () => (assertString),
|
|
11
|
+
isComparatorExpression: () => (isComparatorExpression),
|
|
12
|
+
isEmptyExpression: () => (isEmptyExpression),
|
|
13
|
+
isExpression: () => (isExpression),
|
|
14
|
+
isNotParsableExpression: () => (isNotParsableExpression),
|
|
15
|
+
isOperatorExpression: () => (isOperatorExpression),
|
|
16
|
+
isPropertyExpression: () => (isPropertyExpression),
|
|
17
|
+
isValueExpression: () => (isValueExpression)
|
|
10
18
|
});
|
|
19
|
+
/* import */ var _expressions_constants__rspack_import_1 = __webpack_require__("./src/expressions/constants.ts");
|
|
11
20
|
/* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/dates.ts");
|
|
12
21
|
|
|
22
|
+
|
|
13
23
|
function assertDate(data) {
|
|
14
24
|
if ((0,_utilities__rspack_import_0.isDate)(data) === false) {
|
|
15
25
|
throw new TypeError('Value is not a Date');
|
|
@@ -41,209 +51,76 @@ function assertInstanceOf(value, Instance) {
|
|
|
41
51
|
return;
|
|
42
52
|
}
|
|
43
53
|
if (value != null && typeof value === "object" && "constructor" in value) {
|
|
44
|
-
throw new TypeError(`
|
|
54
|
+
throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);
|
|
45
55
|
}
|
|
46
|
-
throw new TypeError(`
|
|
56
|
+
throw new TypeError(`value is not instance of type`);
|
|
47
57
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"./src/collections/Changes.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
52
|
-
__webpack_require__.r(__webpack_exports__);
|
|
53
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
54
|
-
BulkPersistChanges: () => (BulkPersistChanges),
|
|
55
|
-
BulkPersistResult: () => (BulkPersistResult),
|
|
56
|
-
SchemaPersistChanges: () => (SchemaPersistChanges),
|
|
57
|
-
SchemaPersistResult: () => (SchemaPersistResult)
|
|
58
|
-
});
|
|
59
|
-
/* import */ var _TagCollection__rspack_import_0 = __webpack_require__("./src/collections/TagCollection.ts");
|
|
60
|
-
|
|
61
|
-
class BulkPersistResult extends Map {
|
|
62
|
-
resolve(schemaId) {
|
|
63
|
-
if (this.has(schemaId)) {
|
|
64
|
-
return this.get(schemaId);
|
|
65
|
-
}
|
|
66
|
-
this.set(schemaId, new SchemaPersistResult());
|
|
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;
|
|
58
|
+
function assertIsNumber(value) {
|
|
59
|
+
if (typeof value !== "number") {
|
|
60
|
+
throw new TypeError("value is not of type `number`");
|
|
107
61
|
}
|
|
108
62
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (this.has(schemaId)) {
|
|
112
|
-
return this.get(schemaId);
|
|
113
|
-
}
|
|
114
|
-
this.set(schemaId, new SchemaPersistChanges());
|
|
115
|
-
return this.get(schemaId);
|
|
116
|
-
}
|
|
117
|
-
get(schemaId) {
|
|
118
|
-
return super.get(schemaId);
|
|
119
|
-
}
|
|
120
|
-
get aggregate() {
|
|
121
|
-
return {
|
|
122
|
-
size: this.aggregateSize,
|
|
123
|
-
adds: this.aggregateAddsSize,
|
|
124
|
-
updates: this.aggregateUpdatesSize,
|
|
125
|
-
removes: this.aggregateRemovesSize
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
get aggregateSize() {
|
|
129
|
-
let count = 0;
|
|
130
|
-
for (const [, result] of this) {
|
|
131
|
-
count += result.total;
|
|
132
|
-
}
|
|
133
|
-
return count;
|
|
134
|
-
}
|
|
135
|
-
get aggregateAddsSize() {
|
|
136
|
-
let count = 0;
|
|
137
|
-
for (const [, result] of this) {
|
|
138
|
-
count += result.adds.length;
|
|
139
|
-
}
|
|
140
|
-
return count;
|
|
141
|
-
}
|
|
142
|
-
get aggregateUpdatesSize() {
|
|
143
|
-
let count = 0;
|
|
144
|
-
for (const [, result] of this) {
|
|
145
|
-
count += result.updates.length;
|
|
146
|
-
}
|
|
147
|
-
return count;
|
|
148
|
-
}
|
|
149
|
-
get aggregateRemovesSize() {
|
|
150
|
-
let count = 0;
|
|
151
|
-
for (const [, result] of this) {
|
|
152
|
-
count += result.removes.length;
|
|
153
|
-
}
|
|
154
|
-
return count;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Ensures the result has the same result sets as the change sets
|
|
158
|
-
* @returns
|
|
159
|
-
*/
|
|
160
|
-
toResult() {
|
|
161
|
-
const result = new BulkPersistResult();
|
|
162
|
-
for (const [schemaId] of this) {
|
|
163
|
-
result.set(schemaId, new SchemaPersistResult());
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
63
|
+
function isObjectWithType(value) {
|
|
64
|
+
return typeof value === "object" && value !== null && "type" in value;
|
|
167
65
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
get hasItems() {
|
|
174
|
-
return this.total > 0;
|
|
175
|
-
}
|
|
176
|
-
get total() {
|
|
177
|
-
return this.adds.length + this.updates.length + this.removes.length;
|
|
178
|
-
}
|
|
66
|
+
/**
|
|
67
|
+
* Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.
|
|
68
|
+
*/
|
|
69
|
+
function isExpression(value) {
|
|
70
|
+
return isObjectWithType(value) && _expressions_constants__rspack_import_1.EXPRESSION_TYPES.includes(value.type);
|
|
179
71
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === "operator"`.
|
|
74
|
+
*/
|
|
75
|
+
function isOperatorExpression(value) {
|
|
76
|
+
return isObjectWithType(value) && value.type === "operator";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === "comparator"`.
|
|
80
|
+
*/
|
|
81
|
+
function isComparatorExpression(value) {
|
|
82
|
+
return isObjectWithType(value) && value.type === "comparator";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === "property"`.
|
|
86
|
+
*/
|
|
87
|
+
function isPropertyExpression(value) {
|
|
88
|
+
return isObjectWithType(value) && value.type === "property";
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Type guard: narrows `value` to `ValueExpression` when it is an object with `type === "value"`.
|
|
92
|
+
*/
|
|
93
|
+
function isValueExpression(value) {
|
|
94
|
+
return isObjectWithType(value) && value.type === "value";
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === "empty"`.
|
|
98
|
+
*/
|
|
99
|
+
function isEmptyExpression(value) {
|
|
100
|
+
return isObjectWithType(value) && value.type === "empty";
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === "not-parsable"`.
|
|
104
|
+
*/
|
|
105
|
+
function isNotParsableExpression(value) {
|
|
106
|
+
return isObjectWithType(value) && value.type === "not-parsable";
|
|
190
107
|
}
|
|
191
108
|
|
|
192
109
|
|
|
193
110
|
},
|
|
194
|
-
"./src/
|
|
111
|
+
"./src/expressions/constants.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
195
112
|
__webpack_require__.r(__webpack_exports__);
|
|
196
113
|
__webpack_require__.d(__webpack_exports__, {
|
|
197
|
-
|
|
114
|
+
EXPRESSION_TYPES: () => (EXPRESSION_TYPES)
|
|
198
115
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
has(key) {
|
|
209
|
-
return this.data.has(key);
|
|
210
|
-
}
|
|
211
|
-
set(key, tag) {
|
|
212
|
-
this._size++;
|
|
213
|
-
return this.data.set(key, tag);
|
|
214
|
-
}
|
|
215
|
-
delete(key) {
|
|
216
|
-
const result = this.data.delete(key);
|
|
217
|
-
if (result) {
|
|
218
|
-
this._size--;
|
|
219
|
-
}
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
setMany(keys, tag) {
|
|
223
|
-
this._size += keys.length;
|
|
224
|
-
for (let i = 0, length = keys.length; i < length; i++) {
|
|
225
|
-
const key = keys[i];
|
|
226
|
-
this.set(key, tag);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
combine(tags) {
|
|
230
|
-
for (const [key, value] of tags) {
|
|
231
|
-
this.data.set(key, value);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
values() {
|
|
235
|
-
return this.data.values();
|
|
236
|
-
}
|
|
237
|
-
keys() {
|
|
238
|
-
return this.data.keys();
|
|
239
|
-
}
|
|
240
|
-
[Symbol.dispose]() {
|
|
241
|
-
this.data.clear();
|
|
242
|
-
}
|
|
243
|
-
[Symbol.iterator]() {
|
|
244
|
-
return this.data[Symbol.iterator]();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
116
|
+
const EXPRESSION_TYPES = [
|
|
117
|
+
"operator",
|
|
118
|
+
"comparator",
|
|
119
|
+
"property",
|
|
120
|
+
"value",
|
|
121
|
+
"empty",
|
|
122
|
+
"not-parsable",
|
|
123
|
+
];
|
|
247
124
|
|
|
248
125
|
|
|
249
126
|
},
|
|
@@ -251,8 +128,7 @@ class TagCollection {
|
|
|
251
128
|
__webpack_require__.r(__webpack_exports__);
|
|
252
129
|
__webpack_require__.d(__webpack_exports__, {
|
|
253
130
|
forEach: () => (forEach),
|
|
254
|
-
getProperties: () => (getProperties)
|
|
255
|
-
isPropertyExpression: () => (isPropertyExpression)
|
|
131
|
+
getProperties: () => (getProperties)
|
|
256
132
|
});
|
|
257
133
|
/**
|
|
258
134
|
* Extracts all properties referenced in an expression
|
|
@@ -277,9 +153,6 @@ function getProperties(expression) {
|
|
|
277
153
|
traverse(expression);
|
|
278
154
|
return properties;
|
|
279
155
|
}
|
|
280
|
-
function isPropertyExpression(expression) {
|
|
281
|
-
return expression.type === "property";
|
|
282
|
-
}
|
|
283
156
|
function forEach(expression, callback) {
|
|
284
157
|
function traverse(expr) {
|
|
285
158
|
// Call the callback for this expression
|
|
@@ -304,37 +177,6 @@ function forEach(expression, callback) {
|
|
|
304
177
|
}
|
|
305
178
|
|
|
306
179
|
|
|
307
|
-
},
|
|
308
|
-
"./src/performance/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
309
|
-
__webpack_require__.r(__webpack_exports__);
|
|
310
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
311
|
-
measure: () => (measure),
|
|
312
|
-
now: () => (now)
|
|
313
|
-
});
|
|
314
|
-
/* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/logger.ts");
|
|
315
|
-
|
|
316
|
-
const measurements = {};
|
|
317
|
-
const now = () => {
|
|
318
|
-
if (typeof performance !== 'undefined' && performance.now) {
|
|
319
|
-
// Browser or modern Node.js
|
|
320
|
-
return performance.now();
|
|
321
|
-
}
|
|
322
|
-
// Fallback for older environments
|
|
323
|
-
return Date.now();
|
|
324
|
-
};
|
|
325
|
-
const measure = {
|
|
326
|
-
start: (name) => {
|
|
327
|
-
measurements[name] = now();
|
|
328
|
-
},
|
|
329
|
-
end: (name) => {
|
|
330
|
-
const start = measurements[name];
|
|
331
|
-
delete measurements[name];
|
|
332
|
-
const delta = now() - start;
|
|
333
|
-
_utilities__rspack_import_0.logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
|
|
338
180
|
},
|
|
339
181
|
"./src/pipeline/TrampolinePipeline.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
340
182
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -644,9 +486,9 @@ class EphemeralDataPlugin {
|
|
|
644
486
|
// For adds-only operations, we can skip load for better performance
|
|
645
487
|
const needsLoad = updatesLength > 0 || removesLength > 0;
|
|
646
488
|
const processChanges = () => {
|
|
647
|
-
result.adds =
|
|
648
|
-
result.updates =
|
|
649
|
-
result.removes =
|
|
489
|
+
result.adds = Array.from({ length: addsLength });
|
|
490
|
+
result.updates = Array.from({ length: updatesLength });
|
|
491
|
+
result.removes = Array.from({ length: removesLength });
|
|
650
492
|
for (let j = 0; j < addsLength; j++) {
|
|
651
493
|
const item = adds[j];
|
|
652
494
|
collection.add(item);
|
|
@@ -718,7 +560,7 @@ class EphemeralDataPlugin {
|
|
|
718
560
|
}
|
|
719
561
|
const records = collection.records;
|
|
720
562
|
const length = records.length;
|
|
721
|
-
const cloned =
|
|
563
|
+
const cloned = Array.from({ length });
|
|
722
564
|
for (let i = 0; i < length; i++) {
|
|
723
565
|
cloned[i] = schema.clone(records[i]);
|
|
724
566
|
}
|
|
@@ -795,8 +637,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
795
637
|
__webpack_require__.d(__webpack_exports__, {
|
|
796
638
|
QueryOptionsCollection: () => (QueryOptionsCollection)
|
|
797
639
|
});
|
|
640
|
+
/* import */ var _assertions__rspack_import_1 = __webpack_require__("./src/assertions/index.ts");
|
|
798
641
|
/* import */ var _expressions_utils__rspack_import_0 = __webpack_require__("./src/expressions/utils.ts");
|
|
799
642
|
|
|
643
|
+
|
|
800
644
|
class QueryOptionsCollection {
|
|
801
645
|
options = new Map();
|
|
802
646
|
nextExecutionTarget = "database";
|
|
@@ -833,7 +677,7 @@ class QueryOptionsCollection {
|
|
|
833
677
|
}
|
|
834
678
|
else {
|
|
835
679
|
(0,_expressions_utils__rspack_import_0.forEach)(filterValue.expression, (expression) => {
|
|
836
|
-
if ((0,
|
|
680
|
+
if ((0,_assertions__rspack_import_1.isPropertyExpression)(expression) && expression.property.isUnmapped) {
|
|
837
681
|
// Cut over to memory execution, unmapped properties are not in the database and
|
|
838
682
|
// cannot be queried
|
|
839
683
|
this.nextExecutionTarget = "memory";
|
|
@@ -873,6 +717,10 @@ class QueryOptionsCollection {
|
|
|
873
717
|
database: databaseQueryOptionsCollection
|
|
874
718
|
};
|
|
875
719
|
}
|
|
720
|
+
hasTransformations() {
|
|
721
|
+
const transformationOptions = ["map", "group", "min", "max", "count", "sum"];
|
|
722
|
+
return transformationOptions.some((name) => this.options.has(name));
|
|
723
|
+
}
|
|
876
724
|
has(name) {
|
|
877
725
|
return this.options.has(name);
|
|
878
726
|
}
|
|
@@ -942,358 +790,6 @@ var QueryOrdering;
|
|
|
942
790
|
})(QueryOrdering || (QueryOrdering = {}));
|
|
943
791
|
|
|
944
792
|
|
|
945
|
-
},
|
|
946
|
-
"./src/plugins/replication/OptimisticReplicationDbPlugin.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
947
|
-
__webpack_require__.r(__webpack_exports__);
|
|
948
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
949
|
-
OptimisticReplicationDbPlugin: () => (OptimisticReplicationDbPlugin)
|
|
950
|
-
});
|
|
951
|
-
/* import */ var _results__rspack_import_2 = __webpack_require__("./src/results/Result.ts");
|
|
952
|
-
/* import */ var _pipeline__rspack_import_5 = __webpack_require__("./src/pipeline/TrampolinePipeline.ts");
|
|
953
|
-
/* import */ var _query__rspack_import_1 = __webpack_require__("./src/plugins/query/Query.ts");
|
|
954
|
-
/* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/uuid.ts");
|
|
955
|
-
/* import */ var _utilities__rspack_import_6 = __webpack_require__("./src/utilities/replication.ts");
|
|
956
|
-
/* import */ var _collections__rspack_import_3 = __webpack_require__("./src/collections/Changes.ts");
|
|
957
|
-
/* import */ var _performance__rspack_import_4 = __webpack_require__("./src/performance/index.ts");
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
7;
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const getMemoryPluginCollectionSize = (plugin, schema) => {
|
|
966
|
-
if ("getCollectionSize" in plugin && typeof plugin.getCollectionSize === "function") {
|
|
967
|
-
return plugin.getCollectionSize(schema.collectionName);
|
|
968
|
-
}
|
|
969
|
-
throw new Error("Cannot get size of collection for MemoryPlugin, not an instance of MemoryPlugin");
|
|
970
|
-
};
|
|
971
|
-
const MAX_HYDRATION_WAIT_MS = 60_000; // 60 seconds max wait
|
|
972
|
-
const HYDRATION_POLL_INTERVAL_MS = 10; // Check ever 10 ms
|
|
973
|
-
class OptimisticReplicationDbPlugin {
|
|
974
|
-
plugins;
|
|
975
|
-
// Give more control over hydration, if the plugin is destroyed, so is the in memory data.
|
|
976
|
-
// It is up to the dev to control the lifecycle
|
|
977
|
-
collectionHydrationStatuses = new Map();
|
|
978
|
-
/**
|
|
979
|
-
* Creates a new OptimisticDbPluginReplicator that coordinates operations between a source database and its replicas.
|
|
980
|
-
*
|
|
981
|
-
* @param plugins Configuration object containing the source, read, and replica database plugins
|
|
982
|
-
* @param plugins.source The primary database plugin that will receive all operations first
|
|
983
|
-
* @param plugins.read The read-optimized plugin (typically a memory plugin) used for fast queries
|
|
984
|
-
* @param plugins.replicas Additional database plugins that will replicate operations from the source
|
|
985
|
-
*/
|
|
986
|
-
constructor(plugins) {
|
|
987
|
-
this.plugins = plugins;
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Will query the read plugin if there is one, otherwise the source plugin will be queried
|
|
991
|
-
*/
|
|
992
|
-
query(event, done) {
|
|
993
|
-
try {
|
|
994
|
-
const readPlugin = this.plugins.read;
|
|
995
|
-
const sourcePlugin = this.plugins.source;
|
|
996
|
-
const collectionSize = getMemoryPluginCollectionSize(this.plugins.read, event.operation.schema);
|
|
997
|
-
if (collectionSize === 0 && this.collectionHydrationStatuses.get(event.operation.schema.collectionName) == null) {
|
|
998
|
-
// Notify the cache that the db was hydrated right away
|
|
999
|
-
this.collectionHydrationStatuses.set(event.operation.schema.collectionName, "pending");
|
|
1000
|
-
// nothing is hydrated, let's try and hydrate before querying
|
|
1001
|
-
// Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
|
|
1002
|
-
// Other queries will do the same and hydrate if needed
|
|
1003
|
-
// We want to select all data here
|
|
1004
|
-
sourcePlugin.query({
|
|
1005
|
-
id: (0,_utilities__rspack_import_0.uuid)(8),
|
|
1006
|
-
schemas: event.schemas,
|
|
1007
|
-
source: "collection",
|
|
1008
|
-
// Select All Data
|
|
1009
|
-
operation: _query__rspack_import_1.Query.EMPTY(event.operation.schema)
|
|
1010
|
-
}, (sourceResult) => {
|
|
1011
|
-
if (sourceResult.ok === _results__rspack_import_2.Result.ERROR) {
|
|
1012
|
-
// Notify that hydration failed
|
|
1013
|
-
this.collectionHydrationStatuses.set(event.operation.schema.collectionName, "rejected");
|
|
1014
|
-
done(sourceResult);
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
// Source plugin can have no data, still should succeed
|
|
1018
|
-
if (Array.isArray(sourceResult.data.value) === false) {
|
|
1019
|
-
// Notify that hydration failed
|
|
1020
|
-
this.collectionHydrationStatuses.set(event.operation.schema.collectionName, "rejected");
|
|
1021
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, "Query result is not an array"));
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
const changesCollection = new _collections__rspack_import_3.BulkPersistChanges();
|
|
1025
|
-
const schemaChanges = changesCollection.resolve(event.operation.schema.id);
|
|
1026
|
-
// Add the existing items into the persist payload as adds
|
|
1027
|
-
schemaChanges.adds = sourceResult.data.value;
|
|
1028
|
-
readPlugin.bulkPersist({
|
|
1029
|
-
id: (0,_utilities__rspack_import_0.uuid)(8),
|
|
1030
|
-
schemas: event.schemas,
|
|
1031
|
-
operation: changesCollection,
|
|
1032
|
-
source: "collection",
|
|
1033
|
-
}, (readPersistResult) => {
|
|
1034
|
-
if (readPersistResult.ok === _results__rspack_import_2.Result.ERROR) {
|
|
1035
|
-
// Notify that hydration failed
|
|
1036
|
-
this.collectionHydrationStatuses.set(event.operation.schema.collectionName, "rejected");
|
|
1037
|
-
done(readPersistResult);
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
this.collectionHydrationStatuses.set(event.operation.schema.collectionName, "fulfilled");
|
|
1041
|
-
// requery the read plugin
|
|
1042
|
-
readPlugin.query(event, done);
|
|
1043
|
-
});
|
|
1044
|
-
});
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
if (this.collectionHydrationStatuses.get(event.operation.schema.collectionName) === "rejected") {
|
|
1048
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, "Hydration failed, unable to query read plugin"));
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
// If hydration is pending, do not query empty collection, wait for hydration
|
|
1052
|
-
if (this.collectionHydrationStatuses.get(event.operation.schema.collectionName) === "pending") {
|
|
1053
|
-
const start = (0,_performance__rspack_import_4.now)();
|
|
1054
|
-
const pollHydrationStatus = () => {
|
|
1055
|
-
const delta = (0,_performance__rspack_import_4.now)() - start;
|
|
1056
|
-
if (delta > MAX_HYDRATION_WAIT_MS) {
|
|
1057
|
-
this.collectionHydrationStatuses.set(event.operation.schema.collectionName, "rejected");
|
|
1058
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, `Hydration timeout: exceeded maximum wait time of ${MAX_HYDRATION_WAIT_MS}ms`));
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
if (this.collectionHydrationStatuses.get(event.operation.schema.collectionName) === "rejected") {
|
|
1062
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, "Hydration failed, unable to query read plugin"));
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
if (this.collectionHydrationStatuses.get(event.operation.schema.collectionName) === "fulfilled") {
|
|
1066
|
-
// Hydration completed successfully, proceed with query
|
|
1067
|
-
readPlugin.query(event, (readResult) => {
|
|
1068
|
-
if (readResult.ok === _results__rspack_import_2.Result.ERROR) {
|
|
1069
|
-
done(readResult);
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
done(readResult);
|
|
1073
|
-
});
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
// Still pending, check again after interval
|
|
1077
|
-
setTimeout(pollHydrationStatus, HYDRATION_POLL_INTERVAL_MS);
|
|
1078
|
-
};
|
|
1079
|
-
pollHydrationStatus();
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
// Collection is hydrated for the targeted collection and should be in sync
|
|
1083
|
-
readPlugin.query(event, (readResult) => {
|
|
1084
|
-
if (readResult.ok === _results__rspack_import_2.Result.ERROR) {
|
|
1085
|
-
done(readResult);
|
|
1086
|
-
return;
|
|
1087
|
-
}
|
|
1088
|
-
done(readResult);
|
|
1089
|
-
return;
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
catch (e) {
|
|
1093
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, e));
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
destroy(event, done) {
|
|
1097
|
-
try {
|
|
1098
|
-
const workPipeline = new _pipeline__rspack_import_5.WorkPipeline();
|
|
1099
|
-
const plugins = [this.plugins.source, ...this.plugins.replicas];
|
|
1100
|
-
for (let i = 0, length = plugins.length; i < length; i++) {
|
|
1101
|
-
workPipeline.pipe((done) => plugins[i].destroy(event, done));
|
|
1102
|
-
}
|
|
1103
|
-
workPipeline.filter((result) => {
|
|
1104
|
-
if (result.ok === _results__rspack_import_2.Result.ERROR) {
|
|
1105
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, result.error));
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
done(_results__rspack_import_2.PluginEventResult.success(event.id));
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
catch (e) {
|
|
1112
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, e));
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
bulkPersist(event, done) {
|
|
1116
|
-
try {
|
|
1117
|
-
const workPipeline = new _pipeline__rspack_import_5.WorkPipeline();
|
|
1118
|
-
const deferredPlugins = [this.plugins.source, ...this.plugins.replicas];
|
|
1119
|
-
// Since we are doing optimistic, we insert into the read plugin first and assume later plugins will succeed
|
|
1120
|
-
// This means the read plugin will generate ids for the source plugin
|
|
1121
|
-
this.plugins.read.bulkPersist({
|
|
1122
|
-
id: (0,_utilities__rspack_import_0.uuid)(8),
|
|
1123
|
-
operation: event.operation,
|
|
1124
|
-
schemas: event.schemas,
|
|
1125
|
-
source: "data-store",
|
|
1126
|
-
}, (r) => {
|
|
1127
|
-
if (r.ok !== _results__rspack_import_2.Result.SUCCESS) {
|
|
1128
|
-
done(r);
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
// optimistically call done and still continue saving the rest of the data. We read from the memory
|
|
1132
|
-
// db anyways
|
|
1133
|
-
done(r);
|
|
1134
|
-
const optimisticBulkPersistChanges = new _collections__rspack_import_3.BulkPersistChanges();
|
|
1135
|
-
// make sure we swap the adds here, that way we can make sure other persist events
|
|
1136
|
-
// don't take their additions and try to change subsequent calls
|
|
1137
|
-
(0,_utilities__rspack_import_6.resolveBulkPersistChanges)(event, r.data, optimisticBulkPersistChanges);
|
|
1138
|
-
for (let i = 0, length = deferredPlugins.length; i < length; i++) {
|
|
1139
|
-
workPipeline.pipe((d) => {
|
|
1140
|
-
const plugin = deferredPlugins[i];
|
|
1141
|
-
plugin.bulkPersist({
|
|
1142
|
-
id: (0,_utilities__rspack_import_0.uuid)(8),
|
|
1143
|
-
operation: optimisticBulkPersistChanges,
|
|
1144
|
-
schemas: event.schemas,
|
|
1145
|
-
source: "data-store",
|
|
1146
|
-
}, (r) => {
|
|
1147
|
-
if (r.ok === _results__rspack_import_2.Result.ERROR) {
|
|
1148
|
-
d(r);
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1151
|
-
d(_results__rspack_import_2.Result.success());
|
|
1152
|
-
});
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
setTimeout(() => {
|
|
1156
|
-
workPipeline.filter((_) => {
|
|
1157
|
-
// no-op for now, maybe implement retries?
|
|
1158
|
-
});
|
|
1159
|
-
}, 5);
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
catch (e) {
|
|
1163
|
-
done(_results__rspack_import_2.PluginEventResult.error(event.id, e));
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
},
|
|
1170
|
-
"./src/plugins/replication/ReplicationDbPlugin.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1171
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1172
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1173
|
-
ReplicationDbPlugin: () => (ReplicationDbPlugin)
|
|
1174
|
-
});
|
|
1175
|
-
/* import */ var _results__rspack_import_0 = __webpack_require__("./src/results/Result.ts");
|
|
1176
|
-
/* import */ var _pipeline__rspack_import_1 = __webpack_require__("./src/pipeline/TrampolinePipeline.ts");
|
|
1177
|
-
/* import */ var _collections__rspack_import_2 = __webpack_require__("./src/collections/Changes.ts");
|
|
1178
|
-
/* import */ var _utilities__rspack_import_3 = __webpack_require__("./src/utilities/replication.ts");
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
class ReplicationDbPlugin {
|
|
1184
|
-
plugins;
|
|
1185
|
-
/**
|
|
1186
|
-
* Creates a new DbPluginReplicator that coordinates operations between a source database and its replicas.
|
|
1187
|
-
*
|
|
1188
|
-
* @param plugins Configuration object containing the source, read (optional), and replica database plugins
|
|
1189
|
-
* @param plugins.source The primary database plugin that will receive all operations first
|
|
1190
|
-
* @param plugins.read Optional read-optimized plugin (typically a memory plugin) used for fast queries
|
|
1191
|
-
* @param plugins.replicas Additional database plugins that will replicate operations from the source
|
|
1192
|
-
*/
|
|
1193
|
-
constructor(plugins) {
|
|
1194
|
-
this.plugins = plugins;
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Will query the read plugin if there is one, otherwise the source plugin will be queried
|
|
1198
|
-
*/
|
|
1199
|
-
query(event, done) {
|
|
1200
|
-
try {
|
|
1201
|
-
const plugin = this.plugins.read != null ? this.plugins.read : this.plugins.source;
|
|
1202
|
-
plugin.query(event, done);
|
|
1203
|
-
}
|
|
1204
|
-
catch (e) {
|
|
1205
|
-
done(_results__rspack_import_0.PluginEventResult.error(event.id, e));
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
destroy(event, done) {
|
|
1209
|
-
try {
|
|
1210
|
-
const pipeline = new _pipeline__rspack_import_1.WorkPipeline();
|
|
1211
|
-
const plugins = [this.plugins.source, ...this.plugins.replicas];
|
|
1212
|
-
for (let i = 0, length = plugins.length; i < length; i++) {
|
|
1213
|
-
pipeline.pipe((done) => plugins[i].destroy(event, done));
|
|
1214
|
-
}
|
|
1215
|
-
pipeline.filter((result) => {
|
|
1216
|
-
if (result.ok === _results__rspack_import_0.Result.ERROR) {
|
|
1217
|
-
done(_results__rspack_import_0.PluginEventResult.error(event.id, result.error));
|
|
1218
|
-
return;
|
|
1219
|
-
}
|
|
1220
|
-
done(_results__rspack_import_0.PluginEventResult.success(event.id));
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
|
-
catch (e) {
|
|
1224
|
-
done(_results__rspack_import_0.PluginEventResult.error(event.id, e));
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
bulkPersist(event, done) {
|
|
1228
|
-
try {
|
|
1229
|
-
// insert into the source first to generate any ids, then take the result and persist that into the replicas
|
|
1230
|
-
const pipeline = new _pipeline__rspack_import_1.WorkPipeline();
|
|
1231
|
-
const plugins = [this.plugins.source, ...this.plugins.replicas];
|
|
1232
|
-
if (this.plugins.read != null) {
|
|
1233
|
-
plugins.push(this.plugins.read);
|
|
1234
|
-
}
|
|
1235
|
-
const result = new _collections__rspack_import_2.BulkPersistResult();
|
|
1236
|
-
for (let i = 0, length = plugins.length; i < length; i++) {
|
|
1237
|
-
pipeline.pipe((d) => {
|
|
1238
|
-
const plugin = plugins[i];
|
|
1239
|
-
// source is first
|
|
1240
|
-
if (i === 0) {
|
|
1241
|
-
plugin.bulkPersist(event, (r) => {
|
|
1242
|
-
if (r.ok === _results__rspack_import_0.Result.ERROR) {
|
|
1243
|
-
d(r);
|
|
1244
|
-
return;
|
|
1245
|
-
}
|
|
1246
|
-
// make sure we swap the adds here, that way we can make sure other persist events
|
|
1247
|
-
// don't take their additions and try to change subsequent calls
|
|
1248
|
-
(0,_utilities__rspack_import_3.resolveBulkPersistChanges)(event, r.data, event.operation);
|
|
1249
|
-
d(_results__rspack_import_0.Result.success());
|
|
1250
|
-
});
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
plugin.bulkPersist(event, (r) => {
|
|
1254
|
-
if (r.ok === _results__rspack_import_0.Result.ERROR) {
|
|
1255
|
-
d(r);
|
|
1256
|
-
return;
|
|
1257
|
-
}
|
|
1258
|
-
d(_results__rspack_import_0.Result.success());
|
|
1259
|
-
});
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
let successCount = 0;
|
|
1263
|
-
pipeline.filter((r) => {
|
|
1264
|
-
if (r.ok === _results__rspack_import_0.Result.ERROR) {
|
|
1265
|
-
if (successCount > 0) {
|
|
1266
|
-
done(_results__rspack_import_0.PluginEventResult.partial(event.id, result, r.error));
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
done(_results__rspack_import_0.PluginEventResult.error(event.id, r.error));
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
successCount++;
|
|
1273
|
-
done(_results__rspack_import_0.PluginEventResult.success(event.id, result));
|
|
1274
|
-
});
|
|
1275
|
-
}
|
|
1276
|
-
catch (e) {
|
|
1277
|
-
done(_results__rspack_import_0.PluginEventResult.error(event.id, e));
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
},
|
|
1284
|
-
"./src/plugins/replication/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1285
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1286
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1287
|
-
OptimisticReplicationDbPlugin: () => (/* reexport safe */ _OptimisticReplicationDbPlugin__rspack_import_1.OptimisticReplicationDbPlugin),
|
|
1288
|
-
ReplicationDbPlugin: () => (/* reexport safe */ _ReplicationDbPlugin__rspack_import_0.ReplicationDbPlugin)
|
|
1289
|
-
});
|
|
1290
|
-
/* import */ var _ReplicationDbPlugin__rspack_import_0 = __webpack_require__("./src/plugins/replication/ReplicationDbPlugin.ts");
|
|
1291
|
-
/* import */ var _OptimisticReplicationDbPlugin__rspack_import_1 = __webpack_require__("./src/plugins/replication/OptimisticReplicationDbPlugin.ts");
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
793
|
},
|
|
1298
794
|
"./src/plugins/translators/DataTranslator.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1299
795
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -1325,16 +821,17 @@ class DataTranslator {
|
|
|
1325
821
|
this.query = query;
|
|
1326
822
|
}
|
|
1327
823
|
translate(data) {
|
|
824
|
+
const isTransformed = this.query.options.hasTransformations();
|
|
1328
825
|
this.query.options.forEach(item => {
|
|
1329
826
|
data = this.functionMap[item.name](data, item);
|
|
1330
827
|
});
|
|
1331
828
|
if (Array.isArray(data)) {
|
|
1332
|
-
return new _TranslatedArrayValue__rspack_import_0.TranslatedArrayValue(data);
|
|
829
|
+
return new _TranslatedArrayValue__rspack_import_0.TranslatedArrayValue(data, isTransformed);
|
|
1333
830
|
}
|
|
1334
831
|
if (this.query.options.has("group")) {
|
|
1335
|
-
return new _TranslatedGroupValue__rspack_import_1.TranslatedGroupValue(data);
|
|
832
|
+
return new _TranslatedGroupValue__rspack_import_1.TranslatedGroupValue(data, isTransformed);
|
|
1336
833
|
}
|
|
1337
|
-
return new _TranslatedSingleValue__rspack_import_2.TranslatedSingleValue(data);
|
|
834
|
+
return new _TranslatedSingleValue__rspack_import_2.TranslatedSingleValue(data, isTransformed);
|
|
1338
835
|
}
|
|
1339
836
|
}
|
|
1340
837
|
|
|
@@ -1369,7 +866,7 @@ class JsonTranslator extends _DataTranslator__rspack_import_0.DataTranslator {
|
|
|
1369
866
|
if (Array.isArray(data) == false) {
|
|
1370
867
|
throw new Error("Can only map an array of data");
|
|
1371
868
|
}
|
|
1372
|
-
const response =
|
|
869
|
+
const response = Array.from({ length: data.length });
|
|
1373
870
|
for (let i = 0, length = data.length; i < length; i++) {
|
|
1374
871
|
for (let j = 0, l = option.value.fields.length; j < l; j++) {
|
|
1375
872
|
const field = option.value.fields[j];
|
|
@@ -1632,8 +1129,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
1632
1129
|
});
|
|
1633
1130
|
class TranslatedArrayValue {
|
|
1634
1131
|
value;
|
|
1635
|
-
|
|
1132
|
+
isTransformed;
|
|
1133
|
+
isEmpty;
|
|
1134
|
+
constructor(value, isTransformed) {
|
|
1636
1135
|
this.value = value;
|
|
1136
|
+
this.isEmpty = value == null || (Array.isArray(value) && value.length === 0);
|
|
1137
|
+
this.isTransformed = isTransformed;
|
|
1637
1138
|
}
|
|
1638
1139
|
forEach(callback) {
|
|
1639
1140
|
const data = this.value;
|
|
@@ -1656,8 +1157,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
1656
1157
|
});
|
|
1657
1158
|
class TranslatedGroupValue {
|
|
1658
1159
|
value;
|
|
1659
|
-
|
|
1160
|
+
isTransformed;
|
|
1161
|
+
isEmpty;
|
|
1162
|
+
constructor(value, isTransformed) {
|
|
1660
1163
|
this.value = value;
|
|
1164
|
+
this.isEmpty = value == null;
|
|
1165
|
+
this.isTransformed = isTransformed;
|
|
1661
1166
|
}
|
|
1662
1167
|
forEach(callback) {
|
|
1663
1168
|
const group = this.value;
|
|
@@ -1685,8 +1190,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
1685
1190
|
});
|
|
1686
1191
|
class TranslatedSingleValue {
|
|
1687
1192
|
value;
|
|
1688
|
-
|
|
1193
|
+
isTransformed;
|
|
1194
|
+
isEmpty;
|
|
1195
|
+
constructor(value, isTransformed) {
|
|
1689
1196
|
this.value = value;
|
|
1197
|
+
this.isEmpty = value == null;
|
|
1198
|
+
this.isTransformed = isTransformed;
|
|
1690
1199
|
}
|
|
1691
1200
|
forEach(callback) {
|
|
1692
1201
|
const result = callback(this.value);
|
|
@@ -1829,16 +1338,27 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1829
1338
|
__webpack_require__.d(__webpack_exports__, {
|
|
1830
1339
|
logger: () => (logger)
|
|
1831
1340
|
});
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Enable logging by setting `globalThis.__ROUTIER_DEBUG__ = true` before any routier code runs.
|
|
1343
|
+
*/
|
|
1344
|
+
const shouldLog = () => {
|
|
1345
|
+
if (typeof globalThis !== 'undefined') {
|
|
1346
|
+
const g = globalThis;
|
|
1347
|
+
if (g.__ROUTIER_DEBUG__ === true)
|
|
1348
|
+
return true;
|
|
1349
|
+
}
|
|
1350
|
+
if (typeof process !== 'undefined' && process.env != null) {
|
|
1351
|
+
const debug = process.env.DEBUG;
|
|
1352
|
+
if (debug === 'routier' || debug === '*')
|
|
1353
|
+
return true;
|
|
1354
|
+
const env = "development"?.toLowerCase();
|
|
1355
|
+
if (env === 'dev' || env === 'development' || env === 'test')
|
|
1356
|
+
return true;
|
|
1357
|
+
}
|
|
1358
|
+
return false;
|
|
1838
1359
|
};
|
|
1839
|
-
const shouldLog = isDevelopment();
|
|
1840
1360
|
const tryLog = (type, ...args) => {
|
|
1841
|
-
if (shouldLog) {
|
|
1361
|
+
if (shouldLog()) {
|
|
1842
1362
|
console[type](...args);
|
|
1843
1363
|
}
|
|
1844
1364
|
};
|
|
@@ -1864,88 +1384,6 @@ const logger = {
|
|
|
1864
1384
|
};
|
|
1865
1385
|
|
|
1866
1386
|
|
|
1867
|
-
},
|
|
1868
|
-
"./src/utilities/replication.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1869
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1870
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1871
|
-
resolveBulkPersistChanges: () => (resolveBulkPersistChanges)
|
|
1872
|
-
});
|
|
1873
|
-
const resolveBulkPersistChanges = (event, result, bulkPersistChanges) => {
|
|
1874
|
-
// make sure we swap the adds here, that way we can make sure other persist events
|
|
1875
|
-
// don't take their additions and try to change subsequent calls
|
|
1876
|
-
for (const [schemaId, changes] of event.operation) {
|
|
1877
|
-
const schemmaBulkPersistResult = result.get(schemaId);
|
|
1878
|
-
const schemaBulkPersistChanges = bulkPersistChanges.resolve(schemaId);
|
|
1879
|
-
// Set the original removes
|
|
1880
|
-
schemaBulkPersistChanges.removes = changes.removes;
|
|
1881
|
-
// Set the original updates
|
|
1882
|
-
schemaBulkPersistChanges.updates = changes.updates;
|
|
1883
|
-
// Take the adds from the result and set them to be persisted
|
|
1884
|
-
// in the replicated plugins because the id's are set in the
|
|
1885
|
-
// memory data store
|
|
1886
|
-
schemaBulkPersistChanges.adds = schemmaBulkPersistResult.adds;
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
},
|
|
1892
|
-
"./src/utilities/uuid.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1893
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1894
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1895
|
-
uuid: () => (uuid),
|
|
1896
|
-
uuidv4: () => (uuidv4)
|
|
1897
|
-
});
|
|
1898
|
-
const uuid = (length = 16) => {
|
|
1899
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
1900
|
-
const charLength = chars.length;
|
|
1901
|
-
let result = '';
|
|
1902
|
-
for (let i = 0; i < length; i++) {
|
|
1903
|
-
result += chars[Math.random() * charLength | 0];
|
|
1904
|
-
}
|
|
1905
|
-
return result;
|
|
1906
|
-
};
|
|
1907
|
-
const HEX_CHARS = '0123456789abcdef';
|
|
1908
|
-
const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
1909
|
-
const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
|
|
1910
|
-
const uuidv4 = () => {
|
|
1911
|
-
let randomBytes = null;
|
|
1912
|
-
if (hasCrypto) {
|
|
1913
|
-
randomBytes = crypto.getRandomValues(new Uint8Array(16));
|
|
1914
|
-
}
|
|
1915
|
-
let byteIndex = 0;
|
|
1916
|
-
let uuid = '';
|
|
1917
|
-
for (let i = 0; i < UUID_TEMPLATE.length; i++) {
|
|
1918
|
-
const c = UUID_TEMPLATE[i];
|
|
1919
|
-
if (c === '-') {
|
|
1920
|
-
uuid += '-';
|
|
1921
|
-
continue;
|
|
1922
|
-
}
|
|
1923
|
-
let r;
|
|
1924
|
-
if (hasCrypto && randomBytes) {
|
|
1925
|
-
// Each byte gives two hex digits (nibbles)
|
|
1926
|
-
r =
|
|
1927
|
-
(i % 2 === 0
|
|
1928
|
-
? randomBytes[byteIndex] >> 4
|
|
1929
|
-
: randomBytes[byteIndex++] & 0x0f);
|
|
1930
|
-
}
|
|
1931
|
-
else {
|
|
1932
|
-
r = Math.floor(Math.random() * 16);
|
|
1933
|
-
}
|
|
1934
|
-
if (c === 'x') {
|
|
1935
|
-
uuid += HEX_CHARS[r];
|
|
1936
|
-
}
|
|
1937
|
-
else if (c === 'y') {
|
|
1938
|
-
// Variant bits: 8, 9, A, or B
|
|
1939
|
-
uuid += HEX_CHARS[(r & 0x3) | 0x8];
|
|
1940
|
-
}
|
|
1941
|
-
else if (c === '4') {
|
|
1942
|
-
uuid += '4';
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
return uuid;
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
1387
|
},
|
|
1950
1388
|
|
|
1951
1389
|
});
|
|
@@ -2002,23 +1440,19 @@ var __webpack_exports__ = {};
|
|
|
2002
1440
|
__webpack_require__.r(__webpack_exports__);
|
|
2003
1441
|
__webpack_require__.d(__webpack_exports__, {
|
|
2004
1442
|
DataTranslator: () => (/* reexport safe */ _translators__rspack_import_0.DataTranslator),
|
|
2005
|
-
EphemeralDataPlugin: () => (/* reexport safe */
|
|
1443
|
+
EphemeralDataPlugin: () => (/* reexport safe */ _EphemeralDataPlugin__rspack_import_2.EphemeralDataPlugin),
|
|
2006
1444
|
JsonTranslator: () => (/* reexport safe */ _translators__rspack_import_0.JsonTranslator),
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
QueryOrdering: () => (/* reexport safe */ _query__rspack_import_2.QueryOrdering),
|
|
2011
|
-
ReplicationDbPlugin: () => (/* reexport safe */ _replication__rspack_import_1.ReplicationDbPlugin),
|
|
1445
|
+
Query: () => (/* reexport safe */ _query__rspack_import_1.Query),
|
|
1446
|
+
QueryOptionsCollection: () => (/* reexport safe */ _query__rspack_import_1.QueryOptionsCollection),
|
|
1447
|
+
QueryOrdering: () => (/* reexport safe */ _query__rspack_import_1.QueryOrdering),
|
|
2012
1448
|
SqlTranslator: () => (/* reexport safe */ _translators__rspack_import_0.SqlTranslator),
|
|
2013
1449
|
TranslatedArrayValue: () => (/* reexport safe */ _translators__rspack_import_0.TranslatedArrayValue),
|
|
2014
1450
|
TranslatedGroupValue: () => (/* reexport safe */ _translators__rspack_import_0.TranslatedGroupValue),
|
|
2015
1451
|
TranslatedSingleValue: () => (/* reexport safe */ _translators__rspack_import_0.TranslatedSingleValue)
|
|
2016
1452
|
});
|
|
2017
1453
|
/* import */ var _translators__rspack_import_0 = __webpack_require__("./src/plugins/translators/index.ts");
|
|
2018
|
-
/* import */ var
|
|
2019
|
-
/* import */ var
|
|
2020
|
-
/* import */ var _EphemeralDataPlugin__rspack_import_3 = __webpack_require__("./src/plugins/EphemeralDataPlugin.ts");
|
|
2021
|
-
|
|
1454
|
+
/* import */ var _query__rspack_import_1 = __webpack_require__("./src/plugins/query/index.ts");
|
|
1455
|
+
/* import */ var _EphemeralDataPlugin__rspack_import_2 = __webpack_require__("./src/plugins/EphemeralDataPlugin.ts");
|
|
2022
1456
|
|
|
2023
1457
|
|
|
2024
1458
|
|
|
@@ -2029,15 +1463,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
2029
1463
|
var __webpack_exports__DataTranslator = __webpack_exports__.DataTranslator;
|
|
2030
1464
|
var __webpack_exports__EphemeralDataPlugin = __webpack_exports__.EphemeralDataPlugin;
|
|
2031
1465
|
var __webpack_exports__JsonTranslator = __webpack_exports__.JsonTranslator;
|
|
2032
|
-
var __webpack_exports__OptimisticReplicationDbPlugin = __webpack_exports__.OptimisticReplicationDbPlugin;
|
|
2033
1466
|
var __webpack_exports__Query = __webpack_exports__.Query;
|
|
2034
1467
|
var __webpack_exports__QueryOptionsCollection = __webpack_exports__.QueryOptionsCollection;
|
|
2035
1468
|
var __webpack_exports__QueryOrdering = __webpack_exports__.QueryOrdering;
|
|
2036
|
-
var __webpack_exports__ReplicationDbPlugin = __webpack_exports__.ReplicationDbPlugin;
|
|
2037
1469
|
var __webpack_exports__SqlTranslator = __webpack_exports__.SqlTranslator;
|
|
2038
1470
|
var __webpack_exports__TranslatedArrayValue = __webpack_exports__.TranslatedArrayValue;
|
|
2039
1471
|
var __webpack_exports__TranslatedGroupValue = __webpack_exports__.TranslatedGroupValue;
|
|
2040
1472
|
var __webpack_exports__TranslatedSingleValue = __webpack_exports__.TranslatedSingleValue;
|
|
2041
|
-
export { __webpack_exports__DataTranslator as DataTranslator, __webpack_exports__EphemeralDataPlugin as EphemeralDataPlugin, __webpack_exports__JsonTranslator as JsonTranslator,
|
|
1473
|
+
export { __webpack_exports__DataTranslator as DataTranslator, __webpack_exports__EphemeralDataPlugin as EphemeralDataPlugin, __webpack_exports__JsonTranslator as JsonTranslator, __webpack_exports__Query as Query, __webpack_exports__QueryOptionsCollection as QueryOptionsCollection, __webpack_exports__QueryOrdering as QueryOrdering, __webpack_exports__SqlTranslator as SqlTranslator, __webpack_exports__TranslatedArrayValue as TranslatedArrayValue, __webpack_exports__TranslatedGroupValue as TranslatedGroupValue, __webpack_exports__TranslatedSingleValue as TranslatedSingleValue };
|
|
2042
1474
|
|
|
2043
1475
|
//# sourceMappingURL=index.js.map
|