@routier/core 0.0.1-alpha.2 → 0.0.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 +1 -1
- package/dist/assertions/index.js +7 -1
- package/dist/assertions/index.js.map +1 -1
- package/dist/codegen/handlers/SerializeHandlerBuilder.d.ts +2 -2
- package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/deserialize/DeserializeDeserializerHandler.d.ts +6 -0
- package/dist/codegen/handlers/serialize/SerializeSerializerHandler.d.ts +6 -0
- package/dist/collections/ReadonlySchemaCollection.d.ts +17 -0
- package/dist/collections/SchemaCollection.d.ts +5 -3
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.js +67 -9
- package/dist/collections/index.js.map +1 -1
- package/dist/expressions/index.js +67 -23
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/parser.d.ts +1 -1
- package/dist/index.js +598 -223
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.js +58 -9
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/translators/SqlTranslator.d.ts +2 -1
- package/dist/plugins/types.d.ts +2 -0
- package/dist/schema/communication/broadcast.d.ts +11 -0
- package/dist/schema/index.js +420 -182
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/modifiers/SchemaSerialize.d.ts +1 -1
- package/dist/schema/testSchemas.test.d.ts +269 -0
- package/dist/schema/types.d.ts +7 -4
- package/dist/utilities/dbPluginEventUtils.d.ts +1 -1
- package/dist/utilities/functions.d.ts +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +18 -1
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/types.d.ts +3 -0
- package/package.json +3 -4
- package/readme.md +0 -6
- /package/dist/{pipeline/TrampolinePipeline.test.d.ts → schema/schemaGeneration.test.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -21,7 +21,13 @@ function assertDate(data) {
|
|
|
21
21
|
}
|
|
22
22
|
function assertIsNotNull(data, message) {
|
|
23
23
|
if (data == null) {
|
|
24
|
-
|
|
24
|
+
if (message == null) {
|
|
25
|
+
throw new TypeError('Assertion failed, data is null');
|
|
26
|
+
}
|
|
27
|
+
if (typeof message === "string") {
|
|
28
|
+
throw new TypeError(message);
|
|
29
|
+
}
|
|
30
|
+
throw new TypeError(message());
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
function assertIsArray(data, message) {
|
|
@@ -541,15 +547,19 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
541
547
|
__webpack_require__.d(__webpack_exports__, {
|
|
542
548
|
CloneHandlerBuilder: () => (CloneHandlerBuilder)
|
|
543
549
|
});
|
|
550
|
+
/* ESM import */var _clone_CloneArrayHandler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clone/CloneArrayHandler */ "./src/codegen/handlers/clone/CloneArrayHandler.ts");
|
|
544
551
|
/* ESM import */var _clone_CloneObjectHandler__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./clone/CloneObjectHandler */ "./src/codegen/handlers/clone/CloneObjectHandler.ts");
|
|
545
552
|
/* ESM import */var _clone_CloneValueHandler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./clone/CloneValueHandler */ "./src/codegen/handlers/clone/CloneValueHandler.ts");
|
|
546
553
|
|
|
547
554
|
|
|
555
|
+
|
|
548
556
|
/// Purpose:
|
|
549
557
|
class CloneHandlerBuilder {
|
|
550
558
|
build() {
|
|
551
559
|
const handler = new _clone_CloneObjectHandler__WEBPACK_IMPORTED_MODULE_0__.CloneObjectHandler();
|
|
552
|
-
handler
|
|
560
|
+
handler
|
|
561
|
+
.setNext(new _clone_CloneValueHandler__WEBPACK_IMPORTED_MODULE_1__.CloneValueHandler())
|
|
562
|
+
.setNext(new _clone_CloneArrayHandler__WEBPACK_IMPORTED_MODULE_2__.CloneArrayHandler());
|
|
553
563
|
return handler;
|
|
554
564
|
}
|
|
555
565
|
}
|
|
@@ -590,10 +600,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
590
600
|
DeserializeHandlerBuilder: () => (DeserializeHandlerBuilder)
|
|
591
601
|
});
|
|
592
602
|
/* ESM import */var _deserialize_DeserializeObjectHandler__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deserialize/DeserializeObjectHandler */ "./src/codegen/handlers/deserialize/DeserializeObjectHandler.ts");
|
|
593
|
-
/* ESM import */var
|
|
594
|
-
/* ESM import */var
|
|
595
|
-
/* ESM import */var
|
|
596
|
-
/* ESM import */var
|
|
603
|
+
/* ESM import */var _deserialize_DeserializeValueHandler__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deserialize/DeserializeValueHandler */ "./src/codegen/handlers/deserialize/DeserializeValueHandler.ts");
|
|
604
|
+
/* ESM import */var _deserialize_DeserializeDateHandler__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./deserialize/DeserializeDateHandler */ "./src/codegen/handlers/deserialize/DeserializeDateHandler.ts");
|
|
605
|
+
/* ESM import */var _deserialize_DeserializeComputedValueHandler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./deserialize/DeserializeComputedValueHandler */ "./src/codegen/handlers/deserialize/DeserializeComputedValueHandler.ts");
|
|
606
|
+
/* ESM import */var _deserialize_DeserializeFunctionHandler__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./deserialize/DeserializeFunctionHandler */ "./src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts");
|
|
607
|
+
/* ESM import */var _deserialize_DeserializeDeserializerHandler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./deserialize/DeserializeDeserializerHandler */ "./src/codegen/handlers/deserialize/DeserializeDeserializerHandler.ts");
|
|
608
|
+
|
|
597
609
|
|
|
598
610
|
|
|
599
611
|
|
|
@@ -604,10 +616,11 @@ class DeserializeHandlerBuilder {
|
|
|
604
616
|
build() {
|
|
605
617
|
const handler = new _deserialize_DeserializeObjectHandler__WEBPACK_IMPORTED_MODULE_0__.DeserializeObjectHandler();
|
|
606
618
|
handler
|
|
607
|
-
.setNext(new
|
|
608
|
-
.setNext(new
|
|
609
|
-
.setNext(new
|
|
610
|
-
.setNext(new
|
|
619
|
+
.setNext(new _deserialize_DeserializeDeserializerHandler__WEBPACK_IMPORTED_MODULE_1__.DeserializeDeserializerHandler())
|
|
620
|
+
.setNext(new _deserialize_DeserializeComputedValueHandler__WEBPACK_IMPORTED_MODULE_2__.DeserializeComputedValueHandler())
|
|
621
|
+
.setNext(new _deserialize_DeserializeFunctionHandler__WEBPACK_IMPORTED_MODULE_3__.DeserializeFunctionHandler())
|
|
622
|
+
.setNext(new _deserialize_DeserializeValueHandler__WEBPACK_IMPORTED_MODULE_4__.DeserializeValueHandler())
|
|
623
|
+
.setNext(new _deserialize_DeserializeDateHandler__WEBPACK_IMPORTED_MODULE_5__.DeserializeDateHandler());
|
|
611
624
|
return handler;
|
|
612
625
|
}
|
|
613
626
|
}
|
|
@@ -868,18 +881,22 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
868
881
|
__webpack_require__.d(__webpack_exports__, {
|
|
869
882
|
SerializeHandlerBuilder: () => (SerializeHandlerBuilder)
|
|
870
883
|
});
|
|
871
|
-
/* ESM import */var
|
|
872
|
-
/* ESM import */var
|
|
873
|
-
/* ESM import */var
|
|
884
|
+
/* ESM import */var _serialize_SerializeDateHandler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./serialize/SerializeDateHandler */ "./src/codegen/handlers/serialize/SerializeDateHandler.ts");
|
|
885
|
+
/* ESM import */var _serialize_SerializeObjectHandler__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./serialize/SerializeObjectHandler */ "./src/codegen/handlers/serialize/SerializeObjectHandler.ts");
|
|
886
|
+
/* ESM import */var _serialize_SerializeValueHandler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serialize/SerializeValueHandler */ "./src/codegen/handlers/serialize/SerializeValueHandler.ts");
|
|
887
|
+
/* ESM import */var _serialize_SerializeSerializerHandler__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./serialize/SerializeSerializerHandler */ "./src/codegen/handlers/serialize/SerializeSerializerHandler.ts");
|
|
888
|
+
|
|
874
889
|
|
|
875
890
|
|
|
876
891
|
|
|
877
892
|
/// Purpose:
|
|
878
893
|
class SerializeHandlerBuilder {
|
|
879
894
|
build() {
|
|
880
|
-
const handler = new
|
|
881
|
-
handler
|
|
882
|
-
.setNext(new
|
|
895
|
+
const handler = new _serialize_SerializeSerializerHandler__WEBPACK_IMPORTED_MODULE_0__.SerializeSerializerHandler();
|
|
896
|
+
handler
|
|
897
|
+
.setNext(new _serialize_SerializeDateHandler__WEBPACK_IMPORTED_MODULE_1__.SerializeDateHandler())
|
|
898
|
+
.setNext(new _serialize_SerializeValueHandler__WEBPACK_IMPORTED_MODULE_2__.SerializeValueHandler())
|
|
899
|
+
.setNext(new _serialize_SerializeObjectHandler__WEBPACK_IMPORTED_MODULE_3__.SerializeObjectHandler());
|
|
883
900
|
return handler;
|
|
884
901
|
}
|
|
885
902
|
}
|
|
@@ -915,6 +932,43 @@ class StripHandlerBuilder {
|
|
|
915
932
|
}
|
|
916
933
|
|
|
917
934
|
|
|
935
|
+
}),
|
|
936
|
+
"./src/codegen/handlers/clone/CloneArrayHandler.ts":
|
|
937
|
+
/*!*********************************************************!*\
|
|
938
|
+
!*** ./src/codegen/handlers/clone/CloneArrayHandler.ts ***!
|
|
939
|
+
\*********************************************************/
|
|
940
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
941
|
+
__webpack_require__.r(__webpack_exports__);
|
|
942
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
943
|
+
CloneArrayHandler: () => (CloneArrayHandler)
|
|
944
|
+
});
|
|
945
|
+
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
946
|
+
/* ESM import */var _schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../schema */ "./src/schema/types.ts");
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
class CloneArrayHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
950
|
+
handle(property, builder) {
|
|
951
|
+
if (property.type === _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Array) {
|
|
952
|
+
if (property.isNullable || property.isOptional) {
|
|
953
|
+
// Child properties will take care of this
|
|
954
|
+
return builder;
|
|
955
|
+
}
|
|
956
|
+
const slot = builder.get("assignments");
|
|
957
|
+
const resultAssignmentPath = property.getAssignmentPath({ parent: "result" });
|
|
958
|
+
if (property.parent == null) {
|
|
959
|
+
slot.assign(`${resultAssignmentPath}`).value("{}");
|
|
960
|
+
return builder;
|
|
961
|
+
}
|
|
962
|
+
// slotPath.push(...property.getParentPathArray());
|
|
963
|
+
// const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());
|
|
964
|
+
// nestedObjectBuilder.nested(property.name, property.name)
|
|
965
|
+
return builder;
|
|
966
|
+
}
|
|
967
|
+
return super.handle(property, builder);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
|
|
918
972
|
}),
|
|
919
973
|
"./src/codegen/handlers/clone/CloneObjectHandler.ts":
|
|
920
974
|
/*!**********************************************************!*\
|
|
@@ -925,24 +979,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
925
979
|
__webpack_require__.d(__webpack_exports__, {
|
|
926
980
|
CloneObjectHandler: () => (CloneObjectHandler)
|
|
927
981
|
});
|
|
928
|
-
/* ESM import */var _SlotPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../SlotPath */ "./src/codegen/SlotPath.ts");
|
|
929
982
|
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
930
983
|
/* ESM import */var _schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../schema */ "./src/schema/types.ts");
|
|
931
984
|
|
|
932
985
|
|
|
933
|
-
|
|
934
986
|
class CloneObjectHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
935
987
|
handle(property, builder) {
|
|
936
988
|
if (property.type === _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object) {
|
|
937
|
-
|
|
938
|
-
let objectBuilder = builder.get(slotPath.get());
|
|
939
|
-
if (property.parent == null) {
|
|
940
|
-
objectBuilder.nested(property.name, property.name);
|
|
941
|
-
return builder;
|
|
942
|
-
}
|
|
943
|
-
slotPath.push(...property.getParentPathArray());
|
|
944
|
-
const nestedObjectBuilder = builder.get(slotPath.get());
|
|
945
|
-
nestedObjectBuilder.nested(property.name, property.name);
|
|
989
|
+
// Child properties will take care of this
|
|
946
990
|
return builder;
|
|
947
991
|
}
|
|
948
992
|
return super.handle(property, builder);
|
|
@@ -960,7 +1004,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
960
1004
|
__webpack_require__.d(__webpack_exports__, {
|
|
961
1005
|
CloneValueHandler: () => (CloneValueHandler)
|
|
962
1006
|
});
|
|
963
|
-
/* ESM import */var
|
|
1007
|
+
/* ESM import */var _blocks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../blocks */ "./src/codegen/blocks.ts");
|
|
964
1008
|
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
965
1009
|
/* ESM import */var _schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../schema */ "./src/schema/types.ts");
|
|
966
1010
|
|
|
@@ -968,21 +1012,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
968
1012
|
|
|
969
1013
|
class CloneValueHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
970
1014
|
handle(property, builder) {
|
|
971
|
-
if (property.type != _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object) {
|
|
972
|
-
|
|
973
|
-
const entitySelectorPath = property.
|
|
974
|
-
|
|
975
|
-
objectBuilder = builder.get("result")
|
|
976
|
-
.assign("const result", { name: "variable" })
|
|
977
|
-
.object({ name: "object" });
|
|
978
|
-
}
|
|
1015
|
+
if (property.type != _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object && property.type != _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Array) {
|
|
1016
|
+
const slot = builder.get("if");
|
|
1017
|
+
const entitySelectorPath = property.getSelectrorPath({ parent: "entity" });
|
|
1018
|
+
const resultAssignmentPath = property.getAssignmentPath({ parent: "result" });
|
|
979
1019
|
if (property.parent == null) {
|
|
980
|
-
|
|
1020
|
+
// we are a first level property
|
|
1021
|
+
slot.if(`${entitySelectorPath} != null`).appendBody(`${resultAssignmentPath} = ${entitySelectorPath}`);
|
|
981
1022
|
return builder;
|
|
982
1023
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1024
|
+
// Second level or more property
|
|
1025
|
+
// Need to ensure parent is assigned
|
|
1026
|
+
const propertyParentPath = ["result", ...property.getParentPathArray()];
|
|
1027
|
+
const ifBuilder = new _blocks__WEBPACK_IMPORTED_MODULE_2__.IfBuilder(`${propertyParentPath.join("?.")} == null`).appendBody(`${propertyParentPath.join(".")} = {};`);
|
|
1028
|
+
slot.if(`${entitySelectorPath} != null`).appendBody(ifBuilder.toString()).appendBody(`${resultAssignmentPath} = ${entitySelectorPath}`);
|
|
986
1029
|
return builder;
|
|
987
1030
|
}
|
|
988
1031
|
return super.handle(property, builder);
|
|
@@ -1123,6 +1166,47 @@ class DeserializeDateHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.Propert
|
|
|
1123
1166
|
}
|
|
1124
1167
|
|
|
1125
1168
|
|
|
1169
|
+
}),
|
|
1170
|
+
"./src/codegen/handlers/deserialize/DeserializeDeserializerHandler.ts":
|
|
1171
|
+
/*!****************************************************************************!*\
|
|
1172
|
+
!*** ./src/codegen/handlers/deserialize/DeserializeDeserializerHandler.ts ***!
|
|
1173
|
+
\****************************************************************************/
|
|
1174
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1175
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1176
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1177
|
+
DeserializeDeserializerHandler: () => (DeserializeDeserializerHandler)
|
|
1178
|
+
});
|
|
1179
|
+
/* ESM import */var _SlotPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../SlotPath */ "./src/codegen/SlotPath.ts");
|
|
1180
|
+
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
class DeserializeDeserializerHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
1184
|
+
handle(property, builder) {
|
|
1185
|
+
if (property.valueDeserializer != null) {
|
|
1186
|
+
let objectBuilder = builder.getOrDefault("result.variable.object");
|
|
1187
|
+
const assignmentBuilder = builder.getOrDefault("functions");
|
|
1188
|
+
const entitySelectorPath = property.getSelectrorPath({ parent: "entity" });
|
|
1189
|
+
if (objectBuilder == null) {
|
|
1190
|
+
objectBuilder = builder.get("result")
|
|
1191
|
+
.assign("const result", { name: "variable" })
|
|
1192
|
+
.object({ name: "object" });
|
|
1193
|
+
}
|
|
1194
|
+
const defaultFunctionWithParameters = this.toNamedFunction(property.valueDeserializer.toString(), assignmentBuilder);
|
|
1195
|
+
defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map((_, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: entitySelectorPath })));
|
|
1196
|
+
if (property.parent == null) {
|
|
1197
|
+
objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);
|
|
1198
|
+
return builder;
|
|
1199
|
+
}
|
|
1200
|
+
const slotPath = new _SlotPath__WEBPACK_IMPORTED_MODULE_1__.SlotPath(...property.getParentPathArray());
|
|
1201
|
+
objectBuilder = objectBuilder.get(slotPath.get());
|
|
1202
|
+
objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);
|
|
1203
|
+
return builder;
|
|
1204
|
+
}
|
|
1205
|
+
return super.handle(property, builder);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
|
|
1126
1210
|
}),
|
|
1127
1211
|
"./src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts":
|
|
1128
1212
|
/*!************************************************************************!*\
|
|
@@ -1452,7 +1536,7 @@ class EnrichmentNullableObjectHandler extends _types__WEBPACK_IMPORTED_MODULE_0_
|
|
|
1452
1536
|
if (enrichedSlot == null) {
|
|
1453
1537
|
throw new Error(`Error building enricher, could not find slot for ${slotPath.get()}`);
|
|
1454
1538
|
}
|
|
1455
|
-
enriched = enrichedSlot.nested(property.name,
|
|
1539
|
+
enriched = enrichedSlot.nested(property.name, `[${enrichedPath}]`);
|
|
1456
1540
|
}
|
|
1457
1541
|
return builder;
|
|
1458
1542
|
}
|
|
@@ -1471,22 +1555,29 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1471
1555
|
__webpack_require__.d(__webpack_exports__, {
|
|
1472
1556
|
EnrichmentObjectHandler: () => (EnrichmentObjectHandler)
|
|
1473
1557
|
});
|
|
1558
|
+
/* ESM import */var _SlotPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../SlotPath */ "./src/codegen/SlotPath.ts");
|
|
1474
1559
|
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
1475
1560
|
/* ESM import */var _schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../schema */ "./src/schema/types.ts");
|
|
1476
1561
|
|
|
1477
1562
|
|
|
1563
|
+
|
|
1478
1564
|
class EnrichmentObjectHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
1479
1565
|
handle(property, builder) {
|
|
1480
1566
|
if (property.type === _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object && (property.isNullable || property.isOptional) === false) {
|
|
1481
|
-
const
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1567
|
+
const slotPath = new _SlotPath__WEBPACK_IMPORTED_MODULE_2__.SlotPath("factory", "function", "enriched", "object", "enriched");
|
|
1568
|
+
const nestedSlotPath = this.buildSlotPath(property, slotPath);
|
|
1569
|
+
// Generate null check for current level using parent relationships
|
|
1570
|
+
const enrichedPath = property.getAssignmentPath({ parent: "enriched" });
|
|
1571
|
+
const slot = builder.get("factory.function.assignment");
|
|
1572
|
+
slot.assign(enrichedPath).value(`enableChangeTracking(${enrichedPath} || {}, "${property.name}")`);
|
|
1573
|
+
let enriched = builder.getOrDefault(nestedSlotPath.get());
|
|
1574
|
+
if (enriched == null) {
|
|
1575
|
+
const enrichedSlot = builder.get(slotPath.get());
|
|
1576
|
+
if (enrichedSlot == null) {
|
|
1577
|
+
throw new Error(`Error building enricher, could not find slot for ${slotPath.get()}`);
|
|
1578
|
+
}
|
|
1579
|
+
enriched = enrichedSlot.nested(property.name, `[${enrichedPath}]`);
|
|
1485
1580
|
}
|
|
1486
|
-
assignmentSlot.assign(childPath, { name: `[${childPath}]` }).call("enableChangeTracking", { name: "builder" });
|
|
1487
|
-
const changeTrackingSlot = builder.get("factory.function.tracking.freeze");
|
|
1488
|
-
const selectorPath = property.getSelectrorPath({ parent: "enriched" });
|
|
1489
|
-
changeTrackingSlot.if(`${selectorPath} != null`, { unshift: true }).unshiftBody(`${selectorPath} = Object.freeze(${selectorPath})`);
|
|
1490
1581
|
return builder;
|
|
1491
1582
|
}
|
|
1492
1583
|
return super.handle(property, builder);
|
|
@@ -2217,8 +2308,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
2217
2308
|
class SerializeDateHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
2218
2309
|
handle(property, builder) {
|
|
2219
2310
|
if (property.type === _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Date) {
|
|
2220
|
-
|
|
2221
|
-
let objectBuilder = builder.get(slotPath.get());
|
|
2311
|
+
let objectBuilder = builder.get("if");
|
|
2222
2312
|
const entitySelectorPath = property.getSelectrorPath({ parent: "entity" });
|
|
2223
2313
|
const entityAssignmentPath = property.getAssignmentPath({ parent: "result" });
|
|
2224
2314
|
const assignment = `${property.name}: ${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;
|
|
@@ -2232,12 +2322,14 @@ class SerializeDateHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyI
|
|
|
2232
2322
|
}
|
|
2233
2323
|
// A date cannot be a nested object, just do the assignment
|
|
2234
2324
|
if (property.parent == null) {
|
|
2235
|
-
objectBuilder.property(
|
|
2325
|
+
objectBuilder.if(`Object.hasOwn(entity, "${property.name}")`).appendBody(`${entityAssignmentPath} = ${entitySelectorPath}`);
|
|
2236
2326
|
return builder;
|
|
2237
2327
|
}
|
|
2238
|
-
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2328
|
+
// TODO: SOLVE THIS, IT IS CLOSE
|
|
2329
|
+
//const slotPath = new SlotPath(...property.getParentPathArray());
|
|
2330
|
+
// slotPath.push(...property.getParentPathArray());
|
|
2331
|
+
// const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());
|
|
2332
|
+
// nestedObjectBuilder.property(assignment)
|
|
2241
2333
|
return builder;
|
|
2242
2334
|
}
|
|
2243
2335
|
return super.handle(property, builder);
|
|
@@ -2264,15 +2356,52 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
2264
2356
|
class SerializeObjectHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
2265
2357
|
handle(property, builder) {
|
|
2266
2358
|
if (property.type === _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object) {
|
|
2267
|
-
const slotPath = new _SlotPath__WEBPACK_IMPORTED_MODULE_2__.SlotPath("
|
|
2268
|
-
|
|
2359
|
+
const slotPath = new _SlotPath__WEBPACK_IMPORTED_MODULE_2__.SlotPath("assignments");
|
|
2360
|
+
const childPath = property.getAssignmentPath({ parent: "result" });
|
|
2361
|
+
if (property.isNullable || property.isOptional) {
|
|
2362
|
+
// Do nothing if it's nullable or optional as property assignments will check
|
|
2363
|
+
// and create if it does not exist. This way we can handle null/optional
|
|
2364
|
+
return builder;
|
|
2365
|
+
}
|
|
2366
|
+
const slot = builder.get(slotPath.get());
|
|
2367
|
+
slot.assign(`${childPath}`, { name: `[${childPath}]` }).value("{}");
|
|
2368
|
+
return builder;
|
|
2369
|
+
}
|
|
2370
|
+
return super.handle(property, builder);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
}),
|
|
2376
|
+
"./src/codegen/handlers/serialize/SerializeSerializerHandler.ts":
|
|
2377
|
+
/*!**********************************************************************!*\
|
|
2378
|
+
!*** ./src/codegen/handlers/serialize/SerializeSerializerHandler.ts ***!
|
|
2379
|
+
\**********************************************************************/
|
|
2380
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2381
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2382
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2383
|
+
SerializeSerializerHandler: () => (SerializeSerializerHandler)
|
|
2384
|
+
});
|
|
2385
|
+
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
2386
|
+
|
|
2387
|
+
class SerializeSerializerHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
2388
|
+
handle(property, builder) {
|
|
2389
|
+
if (property.valueSerializer != null) {
|
|
2390
|
+
const objectBuilder = builder.getOrDefault("if");
|
|
2391
|
+
const assignmentBuilder = builder.getOrDefault("functions");
|
|
2392
|
+
const entitySelectorPath = property.getAssignmentPath({ parent: "entity" });
|
|
2393
|
+
const resultSelectorPath = property.getAssignmentPath({ parent: "result" });
|
|
2394
|
+
const defaultFunctionWithParameters = this.toNamedFunction(property.valueSerializer.toString(), assignmentBuilder);
|
|
2395
|
+
defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map((_, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: entitySelectorPath })));
|
|
2269
2396
|
if (property.parent == null) {
|
|
2270
|
-
objectBuilder.
|
|
2397
|
+
objectBuilder.if(`Object.hasOwn(entity, "${property.name}")`).appendBody(`${resultSelectorPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);
|
|
2271
2398
|
return builder;
|
|
2272
2399
|
}
|
|
2273
|
-
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2400
|
+
// TODO: SOLVE THIS
|
|
2401
|
+
//const slotPath = new SlotPath(...property.getParentPathArray());
|
|
2402
|
+
// const slotPath = new SlotPath(...property.getParentPathArray());
|
|
2403
|
+
// objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());
|
|
2404
|
+
// objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);
|
|
2276
2405
|
return builder;
|
|
2277
2406
|
}
|
|
2278
2407
|
return super.handle(property, builder);
|
|
@@ -2290,7 +2419,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2290
2419
|
__webpack_require__.d(__webpack_exports__, {
|
|
2291
2420
|
SerializeValueHandler: () => (SerializeValueHandler)
|
|
2292
2421
|
});
|
|
2293
|
-
/* ESM import */var
|
|
2422
|
+
/* ESM import */var _blocks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../blocks */ "./src/codegen/blocks.ts");
|
|
2294
2423
|
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./src/codegen/handlers/types.ts");
|
|
2295
2424
|
/* ESM import */var _schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../schema */ "./src/schema/types.ts");
|
|
2296
2425
|
|
|
@@ -2299,20 +2428,24 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
2299
2428
|
class SerializeValueHandler extends _types__WEBPACK_IMPORTED_MODULE_0__.PropertyInfoHandler {
|
|
2300
2429
|
handle(property, builder) {
|
|
2301
2430
|
if (property.type != _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object && property.type != _schema__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Date) {
|
|
2302
|
-
|
|
2431
|
+
const slot = builder.getOrDefault("if");
|
|
2303
2432
|
const entitySelectorPath = property.getAssignmentPath({ parent: "entity" });
|
|
2304
|
-
|
|
2305
|
-
objectBuilder = builder.get("result")
|
|
2306
|
-
.assign("const result", { name: "variable" })
|
|
2307
|
-
.object({ name: "object" });
|
|
2308
|
-
}
|
|
2433
|
+
const resultSelectorPath = property.getAssignmentPath({ parent: "result" });
|
|
2309
2434
|
if (property.parent == null) {
|
|
2310
|
-
|
|
2435
|
+
// Only assign if the incoming entity has the property, this allows partial serialization
|
|
2436
|
+
// Basically only serialize what is there
|
|
2437
|
+
slot.if(`Object.hasOwn(entity, "${property.name}")`).appendBody(`${resultSelectorPath} = ${entitySelectorPath}`);
|
|
2311
2438
|
return builder;
|
|
2312
2439
|
}
|
|
2313
|
-
const
|
|
2314
|
-
|
|
2315
|
-
|
|
2440
|
+
const parentSelectPath = ["entity", ...property.getParentPathArray()].join(".");
|
|
2441
|
+
const parentAssignPath = ["result", ...property.getParentPathArray()].join(".");
|
|
2442
|
+
const ifSlot = slot.if(`Object.hasOwn(${parentSelectPath}, "${property.name}")`);
|
|
2443
|
+
if (property.parent.isNullable || property.parent.isOptional) {
|
|
2444
|
+
// Do this for nullable/optional parents. Parent will be null if its nullable/optional
|
|
2445
|
+
const conditionallyCreateParent = new _blocks__WEBPACK_IMPORTED_MODULE_2__.IfBuilder(`${parentAssignPath} == null`).appendBody(`${parentAssignPath} = {}`);
|
|
2446
|
+
ifSlot.appendBody(conditionallyCreateParent.toString());
|
|
2447
|
+
}
|
|
2448
|
+
ifSlot.appendBody(`${resultSelectorPath} = ${entitySelectorPath}`);
|
|
2316
2449
|
return builder;
|
|
2317
2450
|
}
|
|
2318
2451
|
return super.handle(property, builder);
|
|
@@ -2498,11 +2631,10 @@ class PropertyInfoHandler {
|
|
|
2498
2631
|
const useFromPropertyName = property.from != null;
|
|
2499
2632
|
const entitySelectorPath = property.getAssignmentPath({ parent: "entity", useFromPropertyName });
|
|
2500
2633
|
if (property.parent != null) {
|
|
2501
|
-
const slotPath = new _SlotPath__WEBPACK_IMPORTED_MODULE_1__.SlotPath("factory", "function", "
|
|
2634
|
+
const slotPath = new _SlotPath__WEBPACK_IMPORTED_MODULE_1__.SlotPath("factory", "function", "enriched", "object", "enriched");
|
|
2502
2635
|
const path = property.parent.getAssignmentPath({ parent: "enriched" });
|
|
2503
2636
|
slotPath.push(`[${path}]`);
|
|
2504
|
-
const
|
|
2505
|
-
const objectBuilder = builder.getValue;
|
|
2637
|
+
const objectBuilder = root.get(slotPath.get());
|
|
2506
2638
|
const childEntityPathSelector = property.getSelectrorPath({ parent: "entity", useFromPropertyName });
|
|
2507
2639
|
objectBuilder.property(`${property.name}: ${childEntityPathSelector}`);
|
|
2508
2640
|
return;
|
|
@@ -2958,24 +3090,49 @@ class MemoryDataCollection {
|
|
|
2958
3090
|
|
|
2959
3091
|
|
|
2960
3092
|
}),
|
|
2961
|
-
"./src/collections/
|
|
2962
|
-
|
|
2963
|
-
!*** ./src/collections/
|
|
2964
|
-
|
|
3093
|
+
"./src/collections/ReadonlySchemaCollection.ts":
|
|
3094
|
+
/*!*****************************************************!*\
|
|
3095
|
+
!*** ./src/collections/ReadonlySchemaCollection.ts ***!
|
|
3096
|
+
\*****************************************************/
|
|
2965
3097
|
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2966
3098
|
__webpack_require__.r(__webpack_exports__);
|
|
2967
3099
|
__webpack_require__.d(__webpack_exports__, {
|
|
2968
|
-
|
|
3100
|
+
ReadonlySchemaCollection: () => (ReadonlySchemaCollection)
|
|
2969
3101
|
});
|
|
2970
3102
|
/**
|
|
2971
3103
|
* Collection of schemas with generic typing for type-safe schema retrieval
|
|
2972
3104
|
*/
|
|
2973
|
-
class
|
|
3105
|
+
class ReadonlySchemaCollection {
|
|
3106
|
+
data;
|
|
3107
|
+
constructor(data) {
|
|
3108
|
+
this.data = new Map(data);
|
|
3109
|
+
}
|
|
2974
3110
|
get(schemaId) {
|
|
2975
|
-
return
|
|
3111
|
+
return this.data.get(schemaId);
|
|
3112
|
+
}
|
|
3113
|
+
has(schemaId) {
|
|
3114
|
+
return this.data.has(schemaId);
|
|
3115
|
+
}
|
|
3116
|
+
get size() {
|
|
3117
|
+
return this.data.size;
|
|
3118
|
+
}
|
|
3119
|
+
keys() {
|
|
3120
|
+
return this.data.keys();
|
|
3121
|
+
}
|
|
3122
|
+
values() {
|
|
3123
|
+
return this.data.values();
|
|
3124
|
+
}
|
|
3125
|
+
entries() {
|
|
3126
|
+
return this.data.entries();
|
|
3127
|
+
}
|
|
3128
|
+
forEach(callbackfn, thisArg) {
|
|
3129
|
+
this.data.forEach(callbackfn, thisArg);
|
|
3130
|
+
}
|
|
3131
|
+
[Symbol.iterator]() {
|
|
3132
|
+
return this.data[Symbol.iterator]();
|
|
2976
3133
|
}
|
|
2977
3134
|
getByName(collectionName) {
|
|
2978
|
-
const found = [...this].find(x => x[1].collectionName === collectionName);
|
|
3135
|
+
const found = [...this.data].find(x => x[1].collectionName === collectionName);
|
|
2979
3136
|
if (found != null) {
|
|
2980
3137
|
return found[1];
|
|
2981
3138
|
}
|
|
@@ -2984,6 +3141,35 @@ class SchemaCollection extends Map {
|
|
|
2984
3141
|
}
|
|
2985
3142
|
|
|
2986
3143
|
|
|
3144
|
+
}),
|
|
3145
|
+
"./src/collections/SchemaCollection.ts":
|
|
3146
|
+
/*!*********************************************!*\
|
|
3147
|
+
!*** ./src/collections/SchemaCollection.ts ***!
|
|
3148
|
+
\*********************************************/
|
|
3149
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
3150
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3151
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
3152
|
+
SchemaCollection: () => (SchemaCollection)
|
|
3153
|
+
});
|
|
3154
|
+
/* ESM import */var _ReadonlySchemaCollection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ReadonlySchemaCollection */ "./src/collections/ReadonlySchemaCollection.ts");
|
|
3155
|
+
|
|
3156
|
+
/**
|
|
3157
|
+
* Collection of schemas with generic typing for type-safe schema retrieval
|
|
3158
|
+
*/
|
|
3159
|
+
class SchemaCollection extends _ReadonlySchemaCollection__WEBPACK_IMPORTED_MODULE_0__.ReadonlySchemaCollection {
|
|
3160
|
+
set(schemaId, schema) {
|
|
3161
|
+
this.data.set(schemaId, schema);
|
|
3162
|
+
return this;
|
|
3163
|
+
}
|
|
3164
|
+
delete(schemaId) {
|
|
3165
|
+
return this.data.delete(schemaId);
|
|
3166
|
+
}
|
|
3167
|
+
clear() {
|
|
3168
|
+
this.data.clear();
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
|
|
2987
3173
|
}),
|
|
2988
3174
|
"./src/collections/TagCollection.ts":
|
|
2989
3175
|
/*!******************************************!*\
|
|
@@ -3056,6 +3242,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
3056
3242
|
BulkPersistResult: () => (/* reexport safe */ _Changes__WEBPACK_IMPORTED_MODULE_0__.BulkPersistResult),
|
|
3057
3243
|
IdSet: () => (/* reexport safe */ _IdSet__WEBPACK_IMPORTED_MODULE_2__.IdSet),
|
|
3058
3244
|
MemoryDataCollection: () => (/* reexport safe */ _MemoryDataCollection__WEBPACK_IMPORTED_MODULE_3__.MemoryDataCollection),
|
|
3245
|
+
ReadonlySchemaCollection: () => (/* reexport safe */ _ReadonlySchemaCollection__WEBPACK_IMPORTED_MODULE_5__.ReadonlySchemaCollection),
|
|
3059
3246
|
SchemaCollection: () => (/* reexport safe */ _SchemaCollection__WEBPACK_IMPORTED_MODULE_4__.SchemaCollection),
|
|
3060
3247
|
SchemaPersistChanges: () => (/* reexport safe */ _Changes__WEBPACK_IMPORTED_MODULE_0__.SchemaPersistChanges),
|
|
3061
3248
|
SchemaPersistResult: () => (/* reexport safe */ _Changes__WEBPACK_IMPORTED_MODULE_0__.SchemaPersistResult),
|
|
@@ -3066,6 +3253,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
3066
3253
|
/* ESM import */var _IdSet__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./IdSet */ "./src/collections/IdSet.ts");
|
|
3067
3254
|
/* ESM import */var _MemoryDataCollection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./MemoryDataCollection */ "./src/collections/MemoryDataCollection.ts");
|
|
3068
3255
|
/* ESM import */var _SchemaCollection__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SchemaCollection */ "./src/collections/SchemaCollection.ts");
|
|
3256
|
+
/* ESM import */var _ReadonlySchemaCollection__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ReadonlySchemaCollection */ "./src/collections/ReadonlySchemaCollection.ts");
|
|
3257
|
+
|
|
3069
3258
|
|
|
3070
3259
|
|
|
3071
3260
|
|
|
@@ -3232,6 +3421,7 @@ const ERROR_MESSAGES = {
|
|
|
3232
3421
|
PROPERTY_NOT_FOUND: (path) => `Error parsing query, could not find PropertyInfo for path: ${path}`,
|
|
3233
3422
|
PARAM_PATH_NOT_FOUND: (value, params) => `Cannot find path in params for .where(). Make sure parameters are not used inline.\r\nPath: ${value}, Params: ${JSON.stringify(params)}`
|
|
3234
3423
|
};
|
|
3424
|
+
const STRINGIFIED_COMPARE_OPERATORS = ["true", "false"];
|
|
3235
3425
|
const combineExpressions = (...expressions) => {
|
|
3236
3426
|
if (expressions.length === 0) {
|
|
3237
3427
|
throw new Error("combineExpressions requires at least 1 expression");
|
|
@@ -3433,8 +3623,11 @@ const parseCondition = (schema, expression, params) => {
|
|
|
3433
3623
|
// This is a parameter path on the left side (e.g., params.distinctPlayers.includes(entity.playerId))
|
|
3434
3624
|
// For includes method, we need to swap left and right sides
|
|
3435
3625
|
if (methodMatch[2] === 'includes') {
|
|
3436
|
-
|
|
3437
|
-
|
|
3626
|
+
const property = getProperty(schema, rightSide);
|
|
3627
|
+
const value = getValue(leftSide, params); // retrieve the original value
|
|
3628
|
+
const serializer = property.property.valueSerializer;
|
|
3629
|
+
comparator.left = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3630
|
+
comparator.right = property;
|
|
3438
3631
|
}
|
|
3439
3632
|
else {
|
|
3440
3633
|
// For other methods, return NOT_PARSABLE for now
|
|
@@ -3443,8 +3636,11 @@ const parseCondition = (schema, expression, params) => {
|
|
|
3443
3636
|
}
|
|
3444
3637
|
else {
|
|
3445
3638
|
// Normal case: property on left, value on right
|
|
3446
|
-
|
|
3447
|
-
|
|
3639
|
+
const property = getProperty(schema, leftSide);
|
|
3640
|
+
const serializer = property.property.valueSerializer;
|
|
3641
|
+
const value = getValue(rightSide, params); // retrieve the original value
|
|
3642
|
+
comparator.left = property;
|
|
3643
|
+
comparator.right = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3448
3644
|
}
|
|
3449
3645
|
// If the comparison is explicitly to false, mark it as negated
|
|
3450
3646
|
if (methodMatch[6] === "false") {
|
|
@@ -3459,10 +3655,13 @@ const parseCondition = (schema, expression, params) => {
|
|
|
3459
3655
|
if (isNegation) {
|
|
3460
3656
|
comparator.negated = isNegation;
|
|
3461
3657
|
}
|
|
3658
|
+
const property = getProperty(schema, valueTransformMatch[1].trim());
|
|
3659
|
+
const serializer = property.property.valueSerializer;
|
|
3660
|
+
const value = getValue(valueTransformMatch[3], params); // retrieve the original value
|
|
3462
3661
|
// Create the property expression for the left side (no transformer)
|
|
3463
|
-
const propertyExpression =
|
|
3662
|
+
const propertyExpression = property;
|
|
3464
3663
|
// Create a ValueExpression for the right side with transformer
|
|
3465
|
-
const valueExpression = getValue(
|
|
3664
|
+
const valueExpression = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3466
3665
|
// Set transformer and locale based on the method
|
|
3467
3666
|
const method = valueTransformMatch[4];
|
|
3468
3667
|
if (method === 'toLowerCase' || method === 'toLocaleLowerCase') {
|
|
@@ -3488,47 +3687,48 @@ const parseCondition = (schema, expression, params) => {
|
|
|
3488
3687
|
comparator.negated = isNegation;
|
|
3489
3688
|
}
|
|
3490
3689
|
// Create the property expression for the left side with transformer
|
|
3491
|
-
const
|
|
3690
|
+
const property = getProperty(schema, transformMethodMatch[1]);
|
|
3492
3691
|
// Set transformer and locale based on the method
|
|
3493
3692
|
const method = transformMethodMatch[2];
|
|
3494
3693
|
if (method === 'toLowerCase' || method === 'toLocaleLowerCase') {
|
|
3495
|
-
|
|
3694
|
+
property.transformer = 'to-lower-case';
|
|
3496
3695
|
if (method === 'toLocaleLowerCase') {
|
|
3497
|
-
|
|
3696
|
+
property.locale = 'en-US'; // Default locale, could be extracted from method call
|
|
3498
3697
|
}
|
|
3499
3698
|
}
|
|
3500
3699
|
else {
|
|
3501
|
-
|
|
3700
|
+
property.transformer = 'to-upper-case';
|
|
3502
3701
|
if (method === 'toLocaleUpperCase') {
|
|
3503
|
-
|
|
3702
|
+
property.locale = 'en-US'; // Default locale, could be extracted from method call
|
|
3504
3703
|
}
|
|
3505
3704
|
}
|
|
3506
3705
|
// Create a ValueExpression for the right side
|
|
3507
|
-
let
|
|
3706
|
+
let value = getValue(transformMethodMatch[4], params);
|
|
3508
3707
|
// Check if the value also has a transformation (but only if it's not already handled by value-side check)
|
|
3509
3708
|
const valueTransformMatch = transformMethodMatch[4].match(/^([^)]+)\.(toLowerCase|toUpperCase|toLocaleLowerCase|toLocaleUpperCase)\(\)$/);
|
|
3510
3709
|
if (valueTransformMatch) {
|
|
3511
3710
|
// Create a new ValueExpression with the base value and transformer
|
|
3512
|
-
|
|
3711
|
+
value = new _types__WEBPACK_IMPORTED_MODULE_0__.ValueExpression({
|
|
3513
3712
|
value: valueTransformMatch[1].replace(/^["']|["']$/g, '') // Remove quotes
|
|
3514
3713
|
});
|
|
3515
3714
|
// Set transformer and locale based on the method
|
|
3516
3715
|
const valueMethod = valueTransformMatch[2];
|
|
3517
3716
|
if (valueMethod === 'toLowerCase' || valueMethod === 'toLocaleLowerCase') {
|
|
3518
|
-
|
|
3717
|
+
value.transformer = 'to-lower-case';
|
|
3519
3718
|
if (valueMethod === 'toLocaleLowerCase') {
|
|
3520
|
-
|
|
3719
|
+
value.locale = 'en-US'; // Default locale
|
|
3521
3720
|
}
|
|
3522
3721
|
}
|
|
3523
3722
|
else {
|
|
3524
|
-
|
|
3723
|
+
value.transformer = 'to-upper-case';
|
|
3525
3724
|
if (valueMethod === 'toLocaleUpperCase') {
|
|
3526
|
-
|
|
3725
|
+
value.locale = 'en-US'; // Default locale
|
|
3527
3726
|
}
|
|
3528
3727
|
}
|
|
3529
3728
|
}
|
|
3530
|
-
|
|
3531
|
-
comparator.
|
|
3729
|
+
const serializer = property.property.valueSerializer;
|
|
3730
|
+
comparator.left = property;
|
|
3731
|
+
comparator.right = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3532
3732
|
// If the comparison is explicitly to false, mark it as negated
|
|
3533
3733
|
if (transformMethodMatch[7] === "false") {
|
|
3534
3734
|
comparator.negated = true;
|
|
@@ -3565,8 +3765,11 @@ const parseCondition = (schema, expression, params) => {
|
|
|
3565
3765
|
if (isNegation) {
|
|
3566
3766
|
comparator.negated = isNegation;
|
|
3567
3767
|
}
|
|
3568
|
-
|
|
3569
|
-
|
|
3768
|
+
const property = getProperty(schema, propertySide);
|
|
3769
|
+
const value = getValue(valueSide, params);
|
|
3770
|
+
const serializer = property.property.valueSerializer;
|
|
3771
|
+
comparator.left = property;
|
|
3772
|
+
comparator.right = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3570
3773
|
convertAndAssignValue(comparator.right, comparator.left);
|
|
3571
3774
|
return comparator;
|
|
3572
3775
|
}
|
|
@@ -3600,11 +3803,30 @@ const parseCondition = (schema, expression, params) => {
|
|
|
3600
3803
|
if (isNegation) {
|
|
3601
3804
|
comparator.negated = isNegation;
|
|
3602
3805
|
}
|
|
3603
|
-
|
|
3604
|
-
|
|
3806
|
+
const property = getProperty(schema, propertySide);
|
|
3807
|
+
const value = getValue(valueSide, params);
|
|
3808
|
+
const serializer = property.property.valueSerializer;
|
|
3809
|
+
comparator.left = property;
|
|
3810
|
+
comparator.right = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3605
3811
|
convertAndAssignValue(comparator.right, comparator.left);
|
|
3606
3812
|
return comparator;
|
|
3607
3813
|
}
|
|
3814
|
+
// Check for standalone property reference (truthy comparison)
|
|
3815
|
+
// Pattern: property name only (e.g., "w.inStock" -> w.inStock === true)
|
|
3816
|
+
const standalonePropertyMatch = finalExpression.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$/);
|
|
3817
|
+
if (standalonePropertyMatch && isPropertyPath(finalExpression)) {
|
|
3818
|
+
const comparator = getComparator('===');
|
|
3819
|
+
if (isNegation) {
|
|
3820
|
+
comparator.negated = isNegation;
|
|
3821
|
+
}
|
|
3822
|
+
const property = getProperty(schema, finalExpression);
|
|
3823
|
+
const value = getValue('true', params);
|
|
3824
|
+
const serializer = property.property.valueSerializer;
|
|
3825
|
+
comparator.left = property;
|
|
3826
|
+
// need to parse the value so it matches what the serializer expects
|
|
3827
|
+
comparator.right = serializer ? getValue(String(property.property.valueSerializer(JSON.parse(value.value)))) : value;
|
|
3828
|
+
return comparator;
|
|
3829
|
+
}
|
|
3608
3830
|
// If we get here, the expression is too complex for the current parser
|
|
3609
3831
|
// This is expected for complex real-world expressions
|
|
3610
3832
|
throw new Error(`Unsupported expression format: ${finalExpression}`);
|
|
@@ -3664,6 +3886,17 @@ const getValue = (value, params) => {
|
|
|
3664
3886
|
}
|
|
3665
3887
|
}
|
|
3666
3888
|
}
|
|
3889
|
+
if (STRINGIFIED_COMPARE_OPERATORS.includes(value)) {
|
|
3890
|
+
return new _types__WEBPACK_IMPORTED_MODULE_0__.ValueExpression({ value });
|
|
3891
|
+
}
|
|
3892
|
+
if (isNaN(numValue)) {
|
|
3893
|
+
// value is a variable passed in by the dev, we cannot evaluate it's value
|
|
3894
|
+
// need to fallback to select all by throwing an error
|
|
3895
|
+
throw new Error(`Cannot derive value from variable, please pass parameters into the expression.
|
|
3896
|
+
|
|
3897
|
+
Example: .where(([x, params]) => x.id === params.id, { id: someVar.id })
|
|
3898
|
+
Issue At: ${value}`);
|
|
3899
|
+
}
|
|
3667
3900
|
// Default case: return as-is
|
|
3668
3901
|
return new _types__WEBPACK_IMPORTED_MODULE_0__.ValueExpression({ value });
|
|
3669
3902
|
};
|
|
@@ -4454,7 +4687,11 @@ class EphemeralDataPlugin {
|
|
|
4454
4687
|
done(_results__WEBPACK_IMPORTED_MODULE_1__.PluginEventResult.error(event.id, r.error));
|
|
4455
4688
|
return;
|
|
4456
4689
|
}
|
|
4457
|
-
const
|
|
4690
|
+
const cloned = [];
|
|
4691
|
+
for (let i = 0, length = collection.records.length; i < length; i++) {
|
|
4692
|
+
cloned.push(event.operation.schema.clone(collection.records[i]));
|
|
4693
|
+
}
|
|
4694
|
+
const translated = translator.translate(cloned);
|
|
4458
4695
|
done(_results__WEBPACK_IMPORTED_MODULE_1__.PluginEventResult.success(event.id, translated));
|
|
4459
4696
|
});
|
|
4460
4697
|
}
|
|
@@ -5158,6 +5395,7 @@ class OptimisticReplicationDbPlugin {
|
|
|
5158
5395
|
sourcePlugin.query({
|
|
5159
5396
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
5160
5397
|
schemas: event.schemas,
|
|
5398
|
+
source: "collection",
|
|
5161
5399
|
// Select All Data
|
|
5162
5400
|
operation: _query__WEBPACK_IMPORTED_MODULE_1__.Query.EMPTY(event.operation.schema)
|
|
5163
5401
|
}, (sourceResult) => {
|
|
@@ -5180,7 +5418,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
5180
5418
|
readPlugin.bulkPersist({
|
|
5181
5419
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
5182
5420
|
schemas: event.schemas,
|
|
5183
|
-
operation: changesCollection
|
|
5421
|
+
operation: changesCollection,
|
|
5422
|
+
source: "collection",
|
|
5184
5423
|
}, (readPersistResult) => {
|
|
5185
5424
|
if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
5186
5425
|
done(readPersistResult);
|
|
@@ -5234,7 +5473,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
5234
5473
|
this.plugins.read.bulkPersist({
|
|
5235
5474
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
5236
5475
|
operation: event.operation,
|
|
5237
|
-
schemas: event.schemas
|
|
5476
|
+
schemas: event.schemas,
|
|
5477
|
+
source: "data-store",
|
|
5238
5478
|
}, (r) => {
|
|
5239
5479
|
if (r.ok !== _results__WEBPACK_IMPORTED_MODULE_2__.Result.SUCCESS) {
|
|
5240
5480
|
done(r);
|
|
@@ -5253,7 +5493,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
5253
5493
|
plugin.bulkPersist({
|
|
5254
5494
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
5255
5495
|
operation: optimisticBulkPersistChanges,
|
|
5256
|
-
schemas: event.schemas
|
|
5496
|
+
schemas: event.schemas,
|
|
5497
|
+
source: "data-store",
|
|
5257
5498
|
}, (r) => {
|
|
5258
5499
|
if (r.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
5259
5500
|
d(r);
|
|
@@ -5528,6 +5769,9 @@ class JsonTranslator extends _DataTranslator__WEBPACK_IMPORTED_MODULE_0__.DataTr
|
|
|
5528
5769
|
}
|
|
5529
5770
|
sum(data, _) {
|
|
5530
5771
|
(0,_assertions__WEBPACK_IMPORTED_MODULE_1__.assertIsArray)(data, this._formatDataNotArrayError("sum"));
|
|
5772
|
+
if (data.length === 0) {
|
|
5773
|
+
throw new Error("Cannot perform operation on empty array, result query contains no data");
|
|
5774
|
+
}
|
|
5531
5775
|
const map = this.query.options.getLast("map");
|
|
5532
5776
|
let sum = 0;
|
|
5533
5777
|
const field = this._getSelectionField("sum", map);
|
|
@@ -5623,15 +5867,26 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
5623
5867
|
|
|
5624
5868
|
class SqlTranslator extends _DataTranslator__WEBPACK_IMPORTED_MODULE_0__.DataTranslator {
|
|
5625
5869
|
count(data, _) {
|
|
5870
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
5871
|
+
// Count should be returned as the property alias on the query
|
|
5872
|
+
return data[0].count;
|
|
5873
|
+
}
|
|
5626
5874
|
return data;
|
|
5627
5875
|
}
|
|
5628
5876
|
min(data, _) {
|
|
5629
|
-
return data;
|
|
5877
|
+
return this.shapeResult(data);
|
|
5630
5878
|
}
|
|
5631
5879
|
max(data, _) {
|
|
5632
|
-
return data;
|
|
5880
|
+
return this.shapeResult(data);
|
|
5633
5881
|
}
|
|
5634
5882
|
sum(data, _) {
|
|
5883
|
+
return this.shapeResult(data);
|
|
5884
|
+
}
|
|
5885
|
+
shapeResult(data) {
|
|
5886
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
5887
|
+
// Shape the result
|
|
5888
|
+
return data[0];
|
|
5889
|
+
}
|
|
5635
5890
|
return data;
|
|
5636
5891
|
}
|
|
5637
5892
|
distinct(data, _) {
|
|
@@ -5649,8 +5904,29 @@ class SqlTranslator extends _DataTranslator__WEBPACK_IMPORTED_MODULE_0__.DataTra
|
|
|
5649
5904
|
sort(data, _) {
|
|
5650
5905
|
return data;
|
|
5651
5906
|
}
|
|
5652
|
-
map(data,
|
|
5653
|
-
|
|
5907
|
+
map(data, option) {
|
|
5908
|
+
if (Array.isArray(data) == false) {
|
|
5909
|
+
throw new Error("Can only map an array of data");
|
|
5910
|
+
}
|
|
5911
|
+
if (this.query.options.has("count") && data.length === 1) {
|
|
5912
|
+
// data here is the shape of { count: number }[] and will map to nothing.
|
|
5913
|
+
// Return the original data and let count take care of this
|
|
5914
|
+
return data;
|
|
5915
|
+
}
|
|
5916
|
+
const response = [];
|
|
5917
|
+
for (let i = 0, length = data.length; i < length; i++) {
|
|
5918
|
+
for (let j = 0, l = option.value.fields.length; j < l; j++) {
|
|
5919
|
+
const field = option.value.fields[j];
|
|
5920
|
+
if (field.property != null) {
|
|
5921
|
+
const value = field.property.getValue(data[i]);
|
|
5922
|
+
if (value != null) {
|
|
5923
|
+
field.property.setValue(data[i], field.property.deserialize(value));
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
response.push(option.value.selector(data[i]));
|
|
5928
|
+
}
|
|
5929
|
+
return response;
|
|
5654
5930
|
}
|
|
5655
5931
|
}
|
|
5656
5932
|
|
|
@@ -6147,28 +6423,28 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6147
6423
|
__webpack_require__.d(__webpack_exports__, {
|
|
6148
6424
|
SchemaDefinition: () => (SchemaDefinition)
|
|
6149
6425
|
});
|
|
6150
|
-
/* ESM import */var
|
|
6151
|
-
/* ESM import */var
|
|
6152
|
-
/* ESM import */var
|
|
6153
|
-
/* ESM import */var
|
|
6154
|
-
/* ESM import */var
|
|
6155
|
-
/* ESM import */var
|
|
6156
|
-
/* ESM import */var
|
|
6157
|
-
/* ESM import */var
|
|
6158
|
-
/* ESM import */var
|
|
6159
|
-
/* ESM import */var
|
|
6160
|
-
/* ESM import */var
|
|
6161
|
-
/* ESM import */var
|
|
6162
|
-
/* ESM import */var
|
|
6163
|
-
/* ESM import */var
|
|
6164
|
-
/* ESM import */var
|
|
6165
|
-
/* ESM import */var
|
|
6166
|
-
/* ESM import */var
|
|
6426
|
+
/* ESM import */var _table_SchemaFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./table/SchemaFunction */ "./src/schema/table/SchemaFunction.ts");
|
|
6427
|
+
/* ESM import */var _table_SchemaComputed__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./table/SchemaComputed */ "./src/schema/table/SchemaComputed.ts");
|
|
6428
|
+
/* ESM import */var _property_base_SchemaBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./property/base/SchemaBase */ "./src/schema/property/base/SchemaBase.ts");
|
|
6429
|
+
/* ESM import */var _PropertyInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./PropertyInfo */ "./src/schema/PropertyInfo.ts");
|
|
6430
|
+
/* ESM import */var _codegen__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../codegen */ "./src/codegen/blocks.ts");
|
|
6431
|
+
/* ESM import */var _codegen_handlers_EnrichmentHandlerBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../codegen/handlers/EnrichmentHandlerBuilder */ "./src/codegen/handlers/EnrichmentHandlerBuilder.ts");
|
|
6432
|
+
/* ESM import */var _codegen_handlers_MergeHandlerBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../codegen/handlers/MergeHandlerBuilder */ "./src/codegen/handlers/MergeHandlerBuilder.ts");
|
|
6433
|
+
/* ESM import */var _codegen_handlers_PrepareHandlerBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../codegen/handlers/PrepareHandlerBuilder */ "./src/codegen/handlers/PrepareHandlerBuilder.ts");
|
|
6434
|
+
/* ESM import */var _codegen_handlers_StripHandlerBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../codegen/handlers/StripHandlerBuilder */ "./src/codegen/handlers/StripHandlerBuilder.ts");
|
|
6435
|
+
/* ESM import */var _codegen_handlers_CloneHandlerBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../codegen/handlers/CloneHandlerBuilder */ "./src/codegen/handlers/CloneHandlerBuilder.ts");
|
|
6436
|
+
/* ESM import */var _codegen_handlers_CompareHandlerBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../codegen/handlers/CompareHandlerBuilder */ "./src/codegen/handlers/CompareHandlerBuilder.ts");
|
|
6437
|
+
/* ESM import */var _codegen_handlers_DeserializeHandlerBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../codegen/handlers/DeserializeHandlerBuilder */ "./src/codegen/handlers/DeserializeHandlerBuilder.ts");
|
|
6438
|
+
/* ESM import */var _codegen_handlers_HashTypeHandlerBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../codegen/handlers/HashTypeHandlerBuilder */ "./src/codegen/handlers/HashTypeHandlerBuilder.ts");
|
|
6439
|
+
/* ESM import */var _codegen_handlers_IdSelectorHandlerBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../codegen/handlers/IdSelectorHandlerBuilder */ "./src/codegen/handlers/IdSelectorHandlerBuilder.ts");
|
|
6440
|
+
/* ESM import */var _codegen_handlers_HashHandlerBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../codegen/handlers/HashHandlerBuilder */ "./src/codegen/handlers/HashHandlerBuilder.ts");
|
|
6441
|
+
/* ESM import */var _codegen_handlers_EnableChangeTrackingHandlerBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../codegen/handlers/EnableChangeTrackingHandlerBuilder */ "./src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts");
|
|
6442
|
+
/* ESM import */var _codegen_handlers_FreezeHandlerBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../codegen/handlers/FreezeHandlerBuilder */ "./src/codegen/handlers/FreezeHandlerBuilder.ts");
|
|
6167
6443
|
/* ESM import */var _errors_SchemaError__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../errors/SchemaError */ "./src/errors/SchemaError.ts");
|
|
6168
|
-
/* ESM import */var
|
|
6169
|
-
/* ESM import */var
|
|
6170
|
-
/* ESM import */var
|
|
6171
|
-
/* ESM import */var
|
|
6444
|
+
/* ESM import */var _codegen_handlers_SerializeHandlerBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../codegen/handlers/SerializeHandlerBuilder */ "./src/codegen/handlers/SerializeHandlerBuilder.ts");
|
|
6445
|
+
/* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utilities */ "./src/utilities/strings.ts");
|
|
6446
|
+
/* ESM import */var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./src/schema/types.ts");
|
|
6447
|
+
/* ESM import */var _communication_broadcast__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./communication/broadcast */ "./src/schema/communication/broadcast.ts");
|
|
6172
6448
|
|
|
6173
6449
|
|
|
6174
6450
|
|
|
@@ -6190,54 +6466,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
6190
6466
|
|
|
6191
6467
|
|
|
6192
6468
|
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
// many db sets
|
|
6196
|
-
class CollectionSubscription {
|
|
6197
|
-
_channel;
|
|
6198
|
-
_id = (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)();
|
|
6199
|
-
_callback = null;
|
|
6200
|
-
constructor(id, signal) {
|
|
6201
|
-
// The id is the computed id from the collection. We need a static id so we can communicate across different
|
|
6202
|
-
// instances of a data store
|
|
6203
|
-
this._channel = new BroadcastChannel(`__routier-unidirectional-subscription-channel-${id}`);
|
|
6204
|
-
this._channel.onmessage = (event) => {
|
|
6205
|
-
const message = event.data;
|
|
6206
|
-
if (message.id === this._id) {
|
|
6207
|
-
return;
|
|
6208
|
-
}
|
|
6209
|
-
if (this._callback != null) {
|
|
6210
|
-
this._callback(message.changes);
|
|
6211
|
-
}
|
|
6212
|
-
};
|
|
6213
|
-
if (signal) {
|
|
6214
|
-
signal.addEventListener("abort", () => {
|
|
6215
|
-
this[Symbol.dispose]();
|
|
6216
|
-
}, { once: true });
|
|
6217
|
-
}
|
|
6218
|
-
}
|
|
6219
|
-
send(changes) {
|
|
6220
|
-
const message = {
|
|
6221
|
-
id: this._id,
|
|
6222
|
-
changes
|
|
6223
|
-
};
|
|
6224
|
-
this._channel.postMessage(message);
|
|
6225
|
-
}
|
|
6226
|
-
onMessage(callback) {
|
|
6227
|
-
this._callback = callback;
|
|
6228
|
-
}
|
|
6229
|
-
dispose() {
|
|
6230
|
-
this[Symbol.dispose]();
|
|
6231
|
-
}
|
|
6232
|
-
[Symbol.dispose]() {
|
|
6233
|
-
this._channel.onmessage = null;
|
|
6234
|
-
this._channel.close();
|
|
6235
|
-
this._channel = null;
|
|
6236
|
-
}
|
|
6237
|
-
}
|
|
6238
|
-
class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODULE_1__.SchemaBase {
|
|
6469
|
+
|
|
6470
|
+
class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODULE_0__.SchemaBase {
|
|
6239
6471
|
instance;
|
|
6240
|
-
type =
|
|
6472
|
+
type = _types__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Definition;
|
|
6241
6473
|
collectionName;
|
|
6242
6474
|
constructor(collectionName, schema) {
|
|
6243
6475
|
super();
|
|
@@ -6248,8 +6480,8 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6248
6480
|
}
|
|
6249
6481
|
modify(builder) {
|
|
6250
6482
|
const b = {
|
|
6251
|
-
function: (fn, injected) => new
|
|
6252
|
-
computed: (fn, injected) => new
|
|
6483
|
+
function: (fn, injected) => new _table_SchemaFunction__WEBPACK_IMPORTED_MODULE_2__.SchemaFunction(fn, injected),
|
|
6484
|
+
computed: (fn, injected) => new _table_SchemaComputed__WEBPACK_IMPORTED_MODULE_3__.SchemaComputed(fn, injected)
|
|
6253
6485
|
};
|
|
6254
6486
|
const r = builder(b);
|
|
6255
6487
|
return new SchemaDefinition(this.collectionName, { ...this.instance, ...r });
|
|
@@ -6261,7 +6493,7 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6261
6493
|
const properties = [];
|
|
6262
6494
|
for (let i = 0; i < explore.length; i++) {
|
|
6263
6495
|
const item = explore[i];
|
|
6264
|
-
if (item.instance.type ===
|
|
6496
|
+
if (item.instance.type === _types__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Definition) {
|
|
6265
6497
|
explore.push({
|
|
6266
6498
|
path: null,
|
|
6267
6499
|
instance: item.instance.instance,
|
|
@@ -6276,8 +6508,8 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6276
6508
|
const previousParent = item.parents.length === 0
|
|
6277
6509
|
? null
|
|
6278
6510
|
: item.parents[item.parents.length - 1].propertyInfo;
|
|
6279
|
-
if (propertyInstance.type ===
|
|
6280
|
-
const propertyInfo = new
|
|
6511
|
+
if (propertyInstance.type === _types__WEBPACK_IMPORTED_MODULE_1__.SchemaTypes.Object) {
|
|
6512
|
+
const propertyInfo = new _PropertyInfo__WEBPACK_IMPORTED_MODULE_4__.PropertyInfo(propertyInstance, key, previousParent);
|
|
6281
6513
|
explore.push({
|
|
6282
6514
|
path: [item.path, key].filter((w) => w != null).join("."),
|
|
6283
6515
|
instance: propertyInstance.instance,
|
|
@@ -6294,7 +6526,7 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6294
6526
|
previousParent.children.push(propertyInfo);
|
|
6295
6527
|
continue;
|
|
6296
6528
|
}
|
|
6297
|
-
const childPrimitivePropertyInfo = new
|
|
6529
|
+
const childPrimitivePropertyInfo = new _PropertyInfo__WEBPACK_IMPORTED_MODULE_4__.PropertyInfo(item.instance[key], key, previousParent);
|
|
6298
6530
|
if (previousParent === null) {
|
|
6299
6531
|
properties.push(childPrimitivePropertyInfo);
|
|
6300
6532
|
continue;
|
|
@@ -6384,19 +6616,19 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6384
6616
|
const schema = this;
|
|
6385
6617
|
const properties = [];
|
|
6386
6618
|
const propertyMap = new Map();
|
|
6387
|
-
const enrichmentHandlerBuilder = new
|
|
6388
|
-
const mergeHandlerFactory = new
|
|
6389
|
-
const prepareHandlerBuilder = new
|
|
6390
|
-
const stripHandlerBuilder = new
|
|
6391
|
-
const cloneHandlerBuilder = new
|
|
6392
|
-
const compareHandlerBuilder = new
|
|
6393
|
-
const deserializeHandlerBuilder = new
|
|
6394
|
-
const hashTypeHandlerBuilder = new
|
|
6395
|
-
const idSelectorHandlerBuilder = new
|
|
6396
|
-
const hashHandlerBuilder = new
|
|
6397
|
-
const enableChangeTrackingHandlerBuilder = new
|
|
6398
|
-
const freezeHandlerBuilder = new
|
|
6399
|
-
const serializeHandlerBuilder = new
|
|
6619
|
+
const enrichmentHandlerBuilder = new _codegen_handlers_EnrichmentHandlerBuilder__WEBPACK_IMPORTED_MODULE_5__.EnrichmentHandlerBuilder();
|
|
6620
|
+
const mergeHandlerFactory = new _codegen_handlers_MergeHandlerBuilder__WEBPACK_IMPORTED_MODULE_6__.MergeHandlerBuilder();
|
|
6621
|
+
const prepareHandlerBuilder = new _codegen_handlers_PrepareHandlerBuilder__WEBPACK_IMPORTED_MODULE_7__.PrepareHandlerBuilder();
|
|
6622
|
+
const stripHandlerBuilder = new _codegen_handlers_StripHandlerBuilder__WEBPACK_IMPORTED_MODULE_8__.StripHandlerBuilder();
|
|
6623
|
+
const cloneHandlerBuilder = new _codegen_handlers_CloneHandlerBuilder__WEBPACK_IMPORTED_MODULE_9__.CloneHandlerBuilder();
|
|
6624
|
+
const compareHandlerBuilder = new _codegen_handlers_CompareHandlerBuilder__WEBPACK_IMPORTED_MODULE_10__.CompareHandlerBuilder();
|
|
6625
|
+
const deserializeHandlerBuilder = new _codegen_handlers_DeserializeHandlerBuilder__WEBPACK_IMPORTED_MODULE_11__.DeserializeHandlerBuilder();
|
|
6626
|
+
const hashTypeHandlerBuilder = new _codegen_handlers_HashTypeHandlerBuilder__WEBPACK_IMPORTED_MODULE_12__.HashTypeHandlerBuilder();
|
|
6627
|
+
const idSelectorHandlerBuilder = new _codegen_handlers_IdSelectorHandlerBuilder__WEBPACK_IMPORTED_MODULE_13__.IdSelectorHandlerBuilder();
|
|
6628
|
+
const hashHandlerBuilder = new _codegen_handlers_HashHandlerBuilder__WEBPACK_IMPORTED_MODULE_14__.HashHandlerBuilder();
|
|
6629
|
+
const enableChangeTrackingHandlerBuilder = new _codegen_handlers_EnableChangeTrackingHandlerBuilder__WEBPACK_IMPORTED_MODULE_15__.EnableChangeTrackingHandlerBuilder();
|
|
6630
|
+
const freezeHandlerBuilder = new _codegen_handlers_FreezeHandlerBuilder__WEBPACK_IMPORTED_MODULE_16__.FreezeHandlerBuilder();
|
|
6631
|
+
const serializeHandlerBuilder = new _codegen_handlers_SerializeHandlerBuilder__WEBPACK_IMPORTED_MODULE_17__.SerializeHandlerBuilder();
|
|
6400
6632
|
const enricher = enrichmentHandlerBuilder.build();
|
|
6401
6633
|
const merge = mergeHandlerFactory.build();
|
|
6402
6634
|
const prepare = prepareHandlerBuilder.build();
|
|
@@ -6410,15 +6642,15 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6410
6642
|
const enableChangeTrackingHandler = enableChangeTrackingHandlerBuilder.build();
|
|
6411
6643
|
const freezeHandler = freezeHandlerBuilder.build();
|
|
6412
6644
|
const serializeHandler = serializeHandlerBuilder.build();
|
|
6413
|
-
const changeTrackingCodeBuilder = new
|
|
6645
|
+
const changeTrackingCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6414
6646
|
changeTrackingCodeBuilder.raw(`function ${this.createChangeTracker.toString()}`);
|
|
6415
6647
|
changeTrackingCodeBuilder.slot("declarations").variable("enableChangeTracking").value('createChangeTracker()');
|
|
6416
6648
|
changeTrackingCodeBuilder.slot("assignment");
|
|
6417
6649
|
changeTrackingCodeBuilder.slot("return").raw('\treturn enableChangeTracking(entity);');
|
|
6418
|
-
const freezeCodeBuilder = new
|
|
6650
|
+
const freezeCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6419
6651
|
freezeCodeBuilder.slot("assignment");
|
|
6420
6652
|
freezeCodeBuilder.slot("return").raw('\treturn Object.freeze(entity);');
|
|
6421
|
-
const enricherCodeBuilder = new
|
|
6653
|
+
const enricherCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6422
6654
|
const enricherFunctionRoot = enricherCodeBuilder.factory("factory", { name: "factory" }).parameters({ name: "collectionName", value: this.collectionName });
|
|
6423
6655
|
const enricherFunctionBody = enricherFunctionRoot.function(undefined, { name: "function" }).parameters("entity", "changeTrackingType").return();
|
|
6424
6656
|
enricherFunctionBody.raw(`function ${this.createChangeTracker.toString()}`);
|
|
@@ -6429,7 +6661,7 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6429
6661
|
enricherFunctionBody.slot("ifs");
|
|
6430
6662
|
enricherFunctionBody.slot("tracking").if('changeTrackingType === "immutable"', { name: "freeze" });
|
|
6431
6663
|
enricherFunctionBody.raw('\treturn enableChangeTracking(enriched);');
|
|
6432
|
-
const mergeCodeBuilder = new
|
|
6664
|
+
const mergeCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6433
6665
|
const mergeFunctionRoot = mergeCodeBuilder.factory("factory", { name: "factory" }).parameters({ name: "collectionName", value: this.collectionName });
|
|
6434
6666
|
const mergeFunctionBody = mergeFunctionRoot.function(undefined, { name: "function" }).parameters("destination", "source").return();
|
|
6435
6667
|
const pauseFunctionBody = mergeFunctionBody.function("pause")
|
|
@@ -6448,34 +6680,40 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6448
6680
|
unpause();
|
|
6449
6681
|
|
|
6450
6682
|
return destination;`);
|
|
6451
|
-
const prepareCodeBuilder = new
|
|
6683
|
+
const prepareCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6452
6684
|
prepareCodeBuilder.slot("result");
|
|
6453
6685
|
prepareCodeBuilder.slot("assignments");
|
|
6454
6686
|
prepareCodeBuilder.slot("return").raw(` return result;`);
|
|
6455
|
-
const stripCodeBuilder = new
|
|
6687
|
+
const stripCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6456
6688
|
stripCodeBuilder.slot("result");
|
|
6457
6689
|
stripCodeBuilder.slot("return").raw(` return result;`);
|
|
6458
|
-
const cloneCodeBuilder = new
|
|
6459
|
-
cloneCodeBuilder.slot("result");
|
|
6690
|
+
const cloneCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6691
|
+
cloneCodeBuilder.slot("result").raw("const result = {};");
|
|
6692
|
+
;
|
|
6693
|
+
cloneCodeBuilder.slot("assignments");
|
|
6694
|
+
cloneCodeBuilder.slot("if");
|
|
6460
6695
|
cloneCodeBuilder.slot("return").raw(` return result;`);
|
|
6461
|
-
const compareCodeBuilder = new
|
|
6696
|
+
const compareCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6462
6697
|
compareCodeBuilder.slot("result");
|
|
6463
6698
|
compareCodeBuilder.slot("return").raw(` return result;`);
|
|
6464
|
-
const deserializeCodeBuilder = new
|
|
6699
|
+
const deserializeCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6700
|
+
deserializeCodeBuilder.slot("functions");
|
|
6465
6701
|
deserializeCodeBuilder.slot("result");
|
|
6466
6702
|
deserializeCodeBuilder.slot("if");
|
|
6467
6703
|
deserializeCodeBuilder.slot("return").raw(` return result;`);
|
|
6468
|
-
const serializeCodeBuilder = new
|
|
6469
|
-
serializeCodeBuilder.slot("result");
|
|
6704
|
+
const serializeCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6705
|
+
serializeCodeBuilder.slot("result").raw("const result = {};");
|
|
6706
|
+
serializeCodeBuilder.slot("assignments");
|
|
6707
|
+
serializeCodeBuilder.slot("functions");
|
|
6470
6708
|
serializeCodeBuilder.slot("if");
|
|
6471
6709
|
serializeCodeBuilder.slot("return").raw(` return result;`);
|
|
6472
|
-
const idSelectorCodeBuilder = new
|
|
6710
|
+
const idSelectorCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6473
6711
|
idSelectorCodeBuilder.slot("result");
|
|
6474
6712
|
idSelectorCodeBuilder.slot("return").raw(` return result;`);
|
|
6475
|
-
const hashTypeCodeBuilder = new
|
|
6713
|
+
const hashTypeCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6476
6714
|
hashTypeCodeBuilder.slot("ifs");
|
|
6477
6715
|
hashTypeCodeBuilder.slot("return").raw(` return "Ids";`);
|
|
6478
|
-
const hashCodeBuilder = new
|
|
6716
|
+
const hashCodeBuilder = new _codegen__WEBPACK_IMPORTED_MODULE_18__.CodeBuilder();
|
|
6479
6717
|
hashCodeBuilder.slot("functions").raw(`
|
|
6480
6718
|
function stringifyDate(d) {
|
|
6481
6719
|
|
|
@@ -6501,7 +6739,7 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6501
6739
|
hashCodeBuilder.raw(` return result;`);
|
|
6502
6740
|
const idProperties = [];
|
|
6503
6741
|
const allPropertyNamesAndPaths = [];
|
|
6504
|
-
let hashType =
|
|
6742
|
+
let hashType = _types__WEBPACK_IMPORTED_MODULE_1__.HashType.Ids;
|
|
6505
6743
|
let hasIdentities = false;
|
|
6506
6744
|
let hasIdentityKeys = false;
|
|
6507
6745
|
this._iterate(schema, (property) => {
|
|
@@ -6557,13 +6795,12 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6557
6795
|
const idPropertyNames = idProperties.map(w => w.name);
|
|
6558
6796
|
const getId = (entity) => {
|
|
6559
6797
|
if (idPropertyNames.length > 1) {
|
|
6560
|
-
return hashFunction(entity,
|
|
6798
|
+
return hashFunction(entity, _types__WEBPACK_IMPORTED_MODULE_1__.HashType.Ids);
|
|
6561
6799
|
}
|
|
6562
6800
|
return getIdsFunction(entity)[0];
|
|
6563
6801
|
};
|
|
6564
6802
|
const getProperty = (id) => propertyMap.get(id);
|
|
6565
|
-
const id = (0,
|
|
6566
|
-
const paths = new Set(properties.map(x => x.getAssignmentPath()));
|
|
6803
|
+
const id = (0,_utilities__WEBPACK_IMPORTED_MODULE_19__.hash)([...allPropertyNamesAndPaths, this.collectionName].join(","));
|
|
6567
6804
|
// memoize this by the validProperties
|
|
6568
6805
|
// TODO: See if we can generate a function to do this and eliminate loops
|
|
6569
6806
|
const deserializePartial = (item, properties) => {
|
|
@@ -6579,7 +6816,7 @@ class SchemaDefinition extends _property_base_SchemaBase__WEBPACK_IMPORTED_MODUL
|
|
|
6579
6816
|
return item;
|
|
6580
6817
|
};
|
|
6581
6818
|
return {
|
|
6582
|
-
createSubscription: (signal) => new
|
|
6819
|
+
createSubscription: (signal) => new _communication_broadcast__WEBPACK_IMPORTED_MODULE_20__.SchemaSubscription(id, signal),
|
|
6583
6820
|
getId,
|
|
6584
6821
|
getProperty,
|
|
6585
6822
|
properties,
|
|
@@ -6698,6 +6935,124 @@ const s = {
|
|
|
6698
6935
|
};
|
|
6699
6936
|
|
|
6700
6937
|
|
|
6938
|
+
}),
|
|
6939
|
+
"./src/schema/communication/broadcast.ts":
|
|
6940
|
+
/*!***********************************************!*\
|
|
6941
|
+
!*** ./src/schema/communication/broadcast.ts ***!
|
|
6942
|
+
\***********************************************/
|
|
6943
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6944
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6945
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6946
|
+
SchemaSubscription: () => (SchemaSubscription)
|
|
6947
|
+
});
|
|
6948
|
+
/* ESM import */var _performance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../performance */ "./src/performance/index.ts");
|
|
6949
|
+
/* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/uuid.ts");
|
|
6950
|
+
|
|
6951
|
+
|
|
6952
|
+
const registry = {};
|
|
6953
|
+
const getChannelRegistry = (schemaId) => {
|
|
6954
|
+
if (registry[schemaId]) {
|
|
6955
|
+
return registry[schemaId];
|
|
6956
|
+
}
|
|
6957
|
+
const channel = new SchemaChannel(schemaId);
|
|
6958
|
+
registry[schemaId] = channel;
|
|
6959
|
+
return channel;
|
|
6960
|
+
};
|
|
6961
|
+
// Must have a sender and receiver. Sender cannot listen for it's own message
|
|
6962
|
+
class SchemaChannel {
|
|
6963
|
+
sender;
|
|
6964
|
+
receiver;
|
|
6965
|
+
constructor(schemaId) {
|
|
6966
|
+
this.sender = new SchemaChannelSender(schemaId);
|
|
6967
|
+
this.receiver = new SchemaChannelReceiver(schemaId);
|
|
6968
|
+
}
|
|
6969
|
+
}
|
|
6970
|
+
class SchemaChannelSender {
|
|
6971
|
+
broadcastChannel;
|
|
6972
|
+
constructor(schemaId) {
|
|
6973
|
+
this.broadcastChannel = new BroadcastChannel(`__routier-schema-subscription-channel:${schemaId}`);
|
|
6974
|
+
}
|
|
6975
|
+
send(changes) {
|
|
6976
|
+
this.broadcastChannel.postMessage(changes);
|
|
6977
|
+
}
|
|
6978
|
+
}
|
|
6979
|
+
class SchemaChannelReceiver {
|
|
6980
|
+
broadcastChannel;
|
|
6981
|
+
subscriptions = [];
|
|
6982
|
+
constructor(schemaId) {
|
|
6983
|
+
this.broadcastChannel = new BroadcastChannel(`__routier-schema-subscription-channel:${schemaId}`);
|
|
6984
|
+
this.broadcastChannel.onmessage = (e) => {
|
|
6985
|
+
// We can't send to the same instance it is not possbile
|
|
6986
|
+
const stampedChanges = e.data;
|
|
6987
|
+
for (let i = 0, length = this.subscriptions.length; i < length; i++) {
|
|
6988
|
+
const subscription = this.subscriptions[i];
|
|
6989
|
+
subscription.action(stampedChanges);
|
|
6990
|
+
}
|
|
6991
|
+
};
|
|
6992
|
+
}
|
|
6993
|
+
addListener(id, listener) {
|
|
6994
|
+
this.subscriptions.push(new SubscriptionListener(id, listener));
|
|
6995
|
+
}
|
|
6996
|
+
removeListeners(id) {
|
|
6997
|
+
this.subscriptions = this.subscriptions.filter(w => w.id !== id);
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
7000
|
+
class SubscriptionListener {
|
|
7001
|
+
id;
|
|
7002
|
+
listener;
|
|
7003
|
+
constructor(id, listener) {
|
|
7004
|
+
this.id = id;
|
|
7005
|
+
this.listener = listener;
|
|
7006
|
+
}
|
|
7007
|
+
action(changes) {
|
|
7008
|
+
this.listener(changes);
|
|
7009
|
+
}
|
|
7010
|
+
}
|
|
7011
|
+
class SchemaSubscription {
|
|
7012
|
+
id;
|
|
7013
|
+
schemaId;
|
|
7014
|
+
createdAt;
|
|
7015
|
+
constructor(schemaId, signal) {
|
|
7016
|
+
this.createdAt = (0,_performance__WEBPACK_IMPORTED_MODULE_0__.now)();
|
|
7017
|
+
this.id = (0,_utilities__WEBPACK_IMPORTED_MODULE_1__.uuid)(8);
|
|
7018
|
+
this.schemaId = schemaId;
|
|
7019
|
+
signal?.addEventListener("abort", () => {
|
|
7020
|
+
this.dispose();
|
|
7021
|
+
}, { once: true });
|
|
7022
|
+
}
|
|
7023
|
+
send(changes) {
|
|
7024
|
+
const regisry = getChannelRegistry(this.schemaId);
|
|
7025
|
+
// Send message to all listeners.
|
|
7026
|
+
// Since we create a new listener when we do onMessage,
|
|
7027
|
+
// we don't need to worry about sending to ourselves, it
|
|
7028
|
+
// can't happen
|
|
7029
|
+
regisry.sender.send({
|
|
7030
|
+
data: changes,
|
|
7031
|
+
timestamp: (0,_performance__WEBPACK_IMPORTED_MODULE_0__.now)()
|
|
7032
|
+
});
|
|
7033
|
+
}
|
|
7034
|
+
onMessage(callback) {
|
|
7035
|
+
const regisry = getChannelRegistry(this.schemaId);
|
|
7036
|
+
// Link the callback to an instance
|
|
7037
|
+
regisry.receiver.addListener(this.id, ({ data, timestamp }) => {
|
|
7038
|
+
if (timestamp < this.createdAt) {
|
|
7039
|
+
// Sent before the receiver was even created
|
|
7040
|
+
return;
|
|
7041
|
+
}
|
|
7042
|
+
callback(data);
|
|
7043
|
+
});
|
|
7044
|
+
}
|
|
7045
|
+
dispose() {
|
|
7046
|
+
this[Symbol.dispose]();
|
|
7047
|
+
}
|
|
7048
|
+
[Symbol.dispose]() {
|
|
7049
|
+
const regisry = getChannelRegistry(this.schemaId);
|
|
7050
|
+
// Remove listeners for this instance only
|
|
7051
|
+
regisry.receiver.removeListeners(this.id);
|
|
7052
|
+
}
|
|
7053
|
+
}
|
|
7054
|
+
|
|
7055
|
+
|
|
6701
7056
|
}),
|
|
6702
7057
|
"./src/schema/index.ts":
|
|
6703
7058
|
/*!*****************************!*\
|
|
@@ -7222,7 +7577,7 @@ class SchemaSerialize extends _base_SchemaBase__WEBPACK_IMPORTED_MODULE_0__.Sche
|
|
|
7222
7577
|
this.instance = current.instance;
|
|
7223
7578
|
this.valueSerializer = serializer;
|
|
7224
7579
|
}
|
|
7225
|
-
|
|
7580
|
+
deserialize(deserializer) {
|
|
7226
7581
|
return new _SchemaDeserialize__WEBPACK_IMPORTED_MODULE_1__.SchemaDeserialize(deserializer, this);
|
|
7227
7582
|
}
|
|
7228
7583
|
}
|
|
@@ -7931,6 +8286,19 @@ const toEventArray = (event) => {
|
|
|
7931
8286
|
};
|
|
7932
8287
|
|
|
7933
8288
|
|
|
8289
|
+
}),
|
|
8290
|
+
"./src/utilities/functions.ts":
|
|
8291
|
+
/*!************************************!*\
|
|
8292
|
+
!*** ./src/utilities/functions.ts ***!
|
|
8293
|
+
\************************************/
|
|
8294
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
8295
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8296
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8297
|
+
noop: () => (noop)
|
|
8298
|
+
});
|
|
8299
|
+
const noop = (...args) => { };
|
|
8300
|
+
|
|
8301
|
+
|
|
7934
8302
|
}),
|
|
7935
8303
|
"./src/utilities/index.ts":
|
|
7936
8304
|
/*!********************************!*\
|
|
@@ -7945,6 +8313,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
7945
8313
|
hash: () => (/* reexport safe */ _strings__WEBPACK_IMPORTED_MODULE_1__.hash),
|
|
7946
8314
|
isDate: () => (/* reexport safe */ _dates__WEBPACK_IMPORTED_MODULE_2__.isDate),
|
|
7947
8315
|
isNodeRuntime: () => (/* reexport safe */ _runtime__WEBPACK_IMPORTED_MODULE_4__.isNodeRuntime),
|
|
8316
|
+
noop: () => (/* reexport safe */ _functions__WEBPACK_IMPORTED_MODULE_9__.noop),
|
|
7948
8317
|
resolveBulkPersistChanges: () => (/* reexport safe */ _replication__WEBPACK_IMPORTED_MODULE_6__.resolveBulkPersistChanges),
|
|
7949
8318
|
toEventArray: () => (/* reexport safe */ _dbPluginEventUtils__WEBPACK_IMPORTED_MODULE_8__.toEventArray),
|
|
7950
8319
|
toMap: () => (/* reexport safe */ _arrays__WEBPACK_IMPORTED_MODULE_0__.toMap),
|
|
@@ -7960,6 +8329,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
7960
8329
|
/* ESM import */var _replication__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./replication */ "./src/utilities/replication.ts");
|
|
7961
8330
|
/* ESM import */var _queryOptionsCollection__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./queryOptionsCollection */ "./src/utilities/queryOptionsCollection.ts");
|
|
7962
8331
|
/* ESM import */var _dbPluginEventUtils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./dbPluginEventUtils */ "./src/utilities/dbPluginEventUtils.ts");
|
|
8332
|
+
/* ESM import */var _functions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./functions */ "./src/utilities/functions.ts");
|
|
8333
|
+
|
|
7963
8334
|
|
|
7964
8335
|
|
|
7965
8336
|
|
|
@@ -8244,6 +8615,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
8244
8615
|
QueryOptionsCollection: () => (/* reexport safe */ _plugins__WEBPACK_IMPORTED_MODULE_7__.QueryOptionsCollection),
|
|
8245
8616
|
QueryOrdering: () => (/* reexport safe */ _plugins__WEBPACK_IMPORTED_MODULE_7__.QueryOrdering),
|
|
8246
8617
|
RawBuilder: () => (/* reexport safe */ _codegen__WEBPACK_IMPORTED_MODULE_1__.RawBuilder),
|
|
8618
|
+
ReadonlySchemaCollection: () => (/* reexport safe */ _collections__WEBPACK_IMPORTED_MODULE_2__.ReadonlySchemaCollection),
|
|
8247
8619
|
ReplicationDbPlugin: () => (/* reexport safe */ _plugins__WEBPACK_IMPORTED_MODULE_7__.ReplicationDbPlugin),
|
|
8248
8620
|
Result: () => (/* reexport safe */ _results__WEBPACK_IMPORTED_MODULE_8__.Result),
|
|
8249
8621
|
SchemaArray: () => (/* reexport safe */ _schema__WEBPACK_IMPORTED_MODULE_9__.SchemaArray),
|
|
@@ -8297,6 +8669,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
8297
8669
|
isNodeRuntime: () => (/* reexport safe */ _utilities__WEBPACK_IMPORTED_MODULE_10__.isNodeRuntime),
|
|
8298
8670
|
isPropertyExpression: () => (/* reexport safe */ _expressions__WEBPACK_IMPORTED_MODULE_4__.isPropertyExpression),
|
|
8299
8671
|
measure: () => (/* reexport safe */ _performance__WEBPACK_IMPORTED_MODULE_5__.measure),
|
|
8672
|
+
noop: () => (/* reexport safe */ _utilities__WEBPACK_IMPORTED_MODULE_10__.noop),
|
|
8300
8673
|
now: () => (/* reexport safe */ _performance__WEBPACK_IMPORTED_MODULE_5__.now),
|
|
8301
8674
|
resolveBulkPersistChanges: () => (/* reexport safe */ _utilities__WEBPACK_IMPORTED_MODULE_10__.resolveBulkPersistChanges),
|
|
8302
8675
|
s: () => (/* reexport safe */ _schema__WEBPACK_IMPORTED_MODULE_9__.s),
|
|
@@ -8367,6 +8740,7 @@ var __webpack_exports__Query = __webpack_exports__.Query;
|
|
|
8367
8740
|
var __webpack_exports__QueryOptionsCollection = __webpack_exports__.QueryOptionsCollection;
|
|
8368
8741
|
var __webpack_exports__QueryOrdering = __webpack_exports__.QueryOrdering;
|
|
8369
8742
|
var __webpack_exports__RawBuilder = __webpack_exports__.RawBuilder;
|
|
8743
|
+
var __webpack_exports__ReadonlySchemaCollection = __webpack_exports__.ReadonlySchemaCollection;
|
|
8370
8744
|
var __webpack_exports__ReplicationDbPlugin = __webpack_exports__.ReplicationDbPlugin;
|
|
8371
8745
|
var __webpack_exports__Result = __webpack_exports__.Result;
|
|
8372
8746
|
var __webpack_exports__SchemaArray = __webpack_exports__.SchemaArray;
|
|
@@ -8420,6 +8794,7 @@ var __webpack_exports__isDate = __webpack_exports__.isDate;
|
|
|
8420
8794
|
var __webpack_exports__isNodeRuntime = __webpack_exports__.isNodeRuntime;
|
|
8421
8795
|
var __webpack_exports__isPropertyExpression = __webpack_exports__.isPropertyExpression;
|
|
8422
8796
|
var __webpack_exports__measure = __webpack_exports__.measure;
|
|
8797
|
+
var __webpack_exports__noop = __webpack_exports__.noop;
|
|
8423
8798
|
var __webpack_exports__now = __webpack_exports__.now;
|
|
8424
8799
|
var __webpack_exports__resolveBulkPersistChanges = __webpack_exports__.resolveBulkPersistChanges;
|
|
8425
8800
|
var __webpack_exports__s = __webpack_exports__.s;
|
|
@@ -8429,6 +8804,6 @@ var __webpack_exports__toMap = __webpack_exports__.toMap;
|
|
|
8429
8804
|
var __webpack_exports__toPromise = __webpack_exports__.toPromise;
|
|
8430
8805
|
var __webpack_exports__uuid = __webpack_exports__.uuid;
|
|
8431
8806
|
var __webpack_exports__uuidv4 = __webpack_exports__.uuidv4;
|
|
8432
|
-
export { __webpack_exports__AndBuilder as AndBuilder, __webpack_exports__ArrayBuilder as ArrayBuilder, __webpack_exports__AssignmentBuilder as AssignmentBuilder, __webpack_exports__AsyncPipeline as AsyncPipeline, __webpack_exports__Block as Block, __webpack_exports__BulkPersistChanges as BulkPersistChanges, __webpack_exports__BulkPersistResult as BulkPersistResult, __webpack_exports__CodeBuilder as CodeBuilder, __webpack_exports__ComparatorExpression as ComparatorExpression, __webpack_exports__ContainerBlock as ContainerBlock, __webpack_exports__DataTranslator as DataTranslator, __webpack_exports__DbPluginCapability as DbPluginCapability, __webpack_exports__DbPluginLoggingCapability as DbPluginLoggingCapability, __webpack_exports__EmptyExpression as EmptyExpression, __webpack_exports__EphemeralDataPlugin as EphemeralDataPlugin, __webpack_exports__Expression as Expression, __webpack_exports__FunctionBuilder as FunctionBuilder, __webpack_exports__FunctionFactoryBuilder as FunctionFactoryBuilder, __webpack_exports__HashType as HashType, __webpack_exports__IdSet as IdSet, __webpack_exports__IfBuilder as IfBuilder, __webpack_exports__JsonTranslator as JsonTranslator, __webpack_exports__MemoryDataCollection as MemoryDataCollection, __webpack_exports__NotParsableExpression as NotParsableExpression, __webpack_exports__ObjectBuilder as ObjectBuilder, __webpack_exports__OperatorExpression as OperatorExpression, __webpack_exports__OptimisticReplicationDbPlugin as OptimisticReplicationDbPlugin, __webpack_exports__PluginEventResult as PluginEventResult, __webpack_exports__PropertyExpression as PropertyExpression, __webpack_exports__PropertyInfo as PropertyInfo, __webpack_exports__Query as Query, __webpack_exports__QueryOptionsCollection as QueryOptionsCollection, __webpack_exports__QueryOrdering as QueryOrdering, __webpack_exports__RawBuilder as RawBuilder, __webpack_exports__ReplicationDbPlugin as ReplicationDbPlugin, __webpack_exports__Result as Result, __webpack_exports__SchemaArray as SchemaArray, __webpack_exports__SchemaBase as SchemaBase, __webpack_exports__SchemaBoolean as SchemaBoolean, __webpack_exports__SchemaCollection as SchemaCollection, __webpack_exports__SchemaComputed as SchemaComputed, __webpack_exports__SchemaDate as SchemaDate, __webpack_exports__SchemaDefault as SchemaDefault, __webpack_exports__SchemaDeserialize as SchemaDeserialize, __webpack_exports__SchemaDistinct as SchemaDistinct, __webpack_exports__SchemaError as SchemaError, __webpack_exports__SchemaFrom as SchemaFrom, __webpack_exports__SchemaFunction as SchemaFunction, __webpack_exports__SchemaIdentity as SchemaIdentity, __webpack_exports__SchemaIndex as SchemaIndex, __webpack_exports__SchemaKey as SchemaKey, __webpack_exports__SchemaNullable as SchemaNullable, __webpack_exports__SchemaNumber as SchemaNumber, __webpack_exports__SchemaObject as SchemaObject, __webpack_exports__SchemaOptional as SchemaOptional, __webpack_exports__SchemaPersistChanges as SchemaPersistChanges, __webpack_exports__SchemaPersistResult as SchemaPersistResult, __webpack_exports__SchemaReadonly as SchemaReadonly, __webpack_exports__SchemaSerialize as SchemaSerialize, __webpack_exports__SchemaString as SchemaString, __webpack_exports__SchemaTracked as SchemaTracked, __webpack_exports__SchemaTypes as SchemaTypes, __webpack_exports__SlotBlock as SlotBlock, __webpack_exports__SqlTranslator as SqlTranslator, __webpack_exports__StringBuilder as StringBuilder, __webpack_exports__SyncronousQueue as SyncronousQueue, __webpack_exports__TagCollection as TagCollection, __webpack_exports__TrampolinePipeline as TrampolinePipeline, __webpack_exports__ValueExpression as ValueExpression, __webpack_exports__VariableBuilder as VariableBuilder, __webpack_exports__WorkPipeline as WorkPipeline, __webpack_exports__assertDate as assertDate, __webpack_exports__assertInstanceOf as assertInstanceOf, __webpack_exports__assertIsArray as assertIsArray, __webpack_exports__assertIsNotNull as assertIsNotNull, __webpack_exports__assertString as assertString, __webpack_exports__cast as cast, __webpack_exports__clone as clone, __webpack_exports__combineExpressions as combineExpressions, __webpack_exports__combineQueryOptionsCollections as combineQueryOptionsCollections, __webpack_exports__forEach as forEach, __webpack_exports__getProperties as getProperties, __webpack_exports__hash as hash, __webpack_exports__isDate as isDate, __webpack_exports__isNodeRuntime as isNodeRuntime, __webpack_exports__isPropertyExpression as isPropertyExpression, __webpack_exports__measure as measure, __webpack_exports__now as now, __webpack_exports__resolveBulkPersistChanges as resolveBulkPersistChanges, __webpack_exports__s as s, __webpack_exports__toEventArray as toEventArray, __webpack_exports__toExpression as toExpression, __webpack_exports__toMap as toMap, __webpack_exports__toPromise as toPromise, __webpack_exports__uuid as uuid, __webpack_exports__uuidv4 as uuidv4 };
|
|
8807
|
+
export { __webpack_exports__AndBuilder as AndBuilder, __webpack_exports__ArrayBuilder as ArrayBuilder, __webpack_exports__AssignmentBuilder as AssignmentBuilder, __webpack_exports__AsyncPipeline as AsyncPipeline, __webpack_exports__Block as Block, __webpack_exports__BulkPersistChanges as BulkPersistChanges, __webpack_exports__BulkPersistResult as BulkPersistResult, __webpack_exports__CodeBuilder as CodeBuilder, __webpack_exports__ComparatorExpression as ComparatorExpression, __webpack_exports__ContainerBlock as ContainerBlock, __webpack_exports__DataTranslator as DataTranslator, __webpack_exports__DbPluginCapability as DbPluginCapability, __webpack_exports__DbPluginLoggingCapability as DbPluginLoggingCapability, __webpack_exports__EmptyExpression as EmptyExpression, __webpack_exports__EphemeralDataPlugin as EphemeralDataPlugin, __webpack_exports__Expression as Expression, __webpack_exports__FunctionBuilder as FunctionBuilder, __webpack_exports__FunctionFactoryBuilder as FunctionFactoryBuilder, __webpack_exports__HashType as HashType, __webpack_exports__IdSet as IdSet, __webpack_exports__IfBuilder as IfBuilder, __webpack_exports__JsonTranslator as JsonTranslator, __webpack_exports__MemoryDataCollection as MemoryDataCollection, __webpack_exports__NotParsableExpression as NotParsableExpression, __webpack_exports__ObjectBuilder as ObjectBuilder, __webpack_exports__OperatorExpression as OperatorExpression, __webpack_exports__OptimisticReplicationDbPlugin as OptimisticReplicationDbPlugin, __webpack_exports__PluginEventResult as PluginEventResult, __webpack_exports__PropertyExpression as PropertyExpression, __webpack_exports__PropertyInfo as PropertyInfo, __webpack_exports__Query as Query, __webpack_exports__QueryOptionsCollection as QueryOptionsCollection, __webpack_exports__QueryOrdering as QueryOrdering, __webpack_exports__RawBuilder as RawBuilder, __webpack_exports__ReadonlySchemaCollection as ReadonlySchemaCollection, __webpack_exports__ReplicationDbPlugin as ReplicationDbPlugin, __webpack_exports__Result as Result, __webpack_exports__SchemaArray as SchemaArray, __webpack_exports__SchemaBase as SchemaBase, __webpack_exports__SchemaBoolean as SchemaBoolean, __webpack_exports__SchemaCollection as SchemaCollection, __webpack_exports__SchemaComputed as SchemaComputed, __webpack_exports__SchemaDate as SchemaDate, __webpack_exports__SchemaDefault as SchemaDefault, __webpack_exports__SchemaDeserialize as SchemaDeserialize, __webpack_exports__SchemaDistinct as SchemaDistinct, __webpack_exports__SchemaError as SchemaError, __webpack_exports__SchemaFrom as SchemaFrom, __webpack_exports__SchemaFunction as SchemaFunction, __webpack_exports__SchemaIdentity as SchemaIdentity, __webpack_exports__SchemaIndex as SchemaIndex, __webpack_exports__SchemaKey as SchemaKey, __webpack_exports__SchemaNullable as SchemaNullable, __webpack_exports__SchemaNumber as SchemaNumber, __webpack_exports__SchemaObject as SchemaObject, __webpack_exports__SchemaOptional as SchemaOptional, __webpack_exports__SchemaPersistChanges as SchemaPersistChanges, __webpack_exports__SchemaPersistResult as SchemaPersistResult, __webpack_exports__SchemaReadonly as SchemaReadonly, __webpack_exports__SchemaSerialize as SchemaSerialize, __webpack_exports__SchemaString as SchemaString, __webpack_exports__SchemaTracked as SchemaTracked, __webpack_exports__SchemaTypes as SchemaTypes, __webpack_exports__SlotBlock as SlotBlock, __webpack_exports__SqlTranslator as SqlTranslator, __webpack_exports__StringBuilder as StringBuilder, __webpack_exports__SyncronousQueue as SyncronousQueue, __webpack_exports__TagCollection as TagCollection, __webpack_exports__TrampolinePipeline as TrampolinePipeline, __webpack_exports__ValueExpression as ValueExpression, __webpack_exports__VariableBuilder as VariableBuilder, __webpack_exports__WorkPipeline as WorkPipeline, __webpack_exports__assertDate as assertDate, __webpack_exports__assertInstanceOf as assertInstanceOf, __webpack_exports__assertIsArray as assertIsArray, __webpack_exports__assertIsNotNull as assertIsNotNull, __webpack_exports__assertString as assertString, __webpack_exports__cast as cast, __webpack_exports__clone as clone, __webpack_exports__combineExpressions as combineExpressions, __webpack_exports__combineQueryOptionsCollections as combineQueryOptionsCollections, __webpack_exports__forEach as forEach, __webpack_exports__getProperties as getProperties, __webpack_exports__hash as hash, __webpack_exports__isDate as isDate, __webpack_exports__isNodeRuntime as isNodeRuntime, __webpack_exports__isPropertyExpression as isPropertyExpression, __webpack_exports__measure as measure, __webpack_exports__noop as noop, __webpack_exports__now as now, __webpack_exports__resolveBulkPersistChanges as resolveBulkPersistChanges, __webpack_exports__s as s, __webpack_exports__toEventArray as toEventArray, __webpack_exports__toExpression as toExpression, __webpack_exports__toMap as toMap, __webpack_exports__toPromise as toPromise, __webpack_exports__uuid as uuid, __webpack_exports__uuidv4 as uuidv4 };
|
|
8433
8808
|
|
|
8434
8809
|
//# sourceMappingURL=index.js.map
|