@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/plugins/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) {
|
|
@@ -838,7 +844,11 @@ class EphemeralDataPlugin {
|
|
|
838
844
|
done(_results__WEBPACK_IMPORTED_MODULE_1__.PluginEventResult.error(event.id, r.error));
|
|
839
845
|
return;
|
|
840
846
|
}
|
|
841
|
-
const
|
|
847
|
+
const cloned = [];
|
|
848
|
+
for (let i = 0, length = collection.records.length; i < length; i++) {
|
|
849
|
+
cloned.push(event.operation.schema.clone(collection.records[i]));
|
|
850
|
+
}
|
|
851
|
+
const translated = translator.translate(cloned);
|
|
842
852
|
done(_results__WEBPACK_IMPORTED_MODULE_1__.PluginEventResult.success(event.id, translated));
|
|
843
853
|
});
|
|
844
854
|
}
|
|
@@ -1509,6 +1519,7 @@ class OptimisticReplicationDbPlugin {
|
|
|
1509
1519
|
sourcePlugin.query({
|
|
1510
1520
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
1511
1521
|
schemas: event.schemas,
|
|
1522
|
+
source: "collection",
|
|
1512
1523
|
// Select All Data
|
|
1513
1524
|
operation: _query__WEBPACK_IMPORTED_MODULE_1__.Query.EMPTY(event.operation.schema)
|
|
1514
1525
|
}, (sourceResult) => {
|
|
@@ -1531,7 +1542,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
1531
1542
|
readPlugin.bulkPersist({
|
|
1532
1543
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
1533
1544
|
schemas: event.schemas,
|
|
1534
|
-
operation: changesCollection
|
|
1545
|
+
operation: changesCollection,
|
|
1546
|
+
source: "collection",
|
|
1535
1547
|
}, (readPersistResult) => {
|
|
1536
1548
|
if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
1537
1549
|
done(readPersistResult);
|
|
@@ -1585,7 +1597,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
1585
1597
|
this.plugins.read.bulkPersist({
|
|
1586
1598
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
1587
1599
|
operation: event.operation,
|
|
1588
|
-
schemas: event.schemas
|
|
1600
|
+
schemas: event.schemas,
|
|
1601
|
+
source: "data-store",
|
|
1589
1602
|
}, (r) => {
|
|
1590
1603
|
if (r.ok !== _results__WEBPACK_IMPORTED_MODULE_2__.Result.SUCCESS) {
|
|
1591
1604
|
done(r);
|
|
@@ -1604,7 +1617,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
1604
1617
|
plugin.bulkPersist({
|
|
1605
1618
|
id: (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)(8),
|
|
1606
1619
|
operation: optimisticBulkPersistChanges,
|
|
1607
|
-
schemas: event.schemas
|
|
1620
|
+
schemas: event.schemas,
|
|
1621
|
+
source: "data-store",
|
|
1608
1622
|
}, (r) => {
|
|
1609
1623
|
if (r.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
1610
1624
|
d(r);
|
|
@@ -1879,6 +1893,9 @@ class JsonTranslator extends _DataTranslator__WEBPACK_IMPORTED_MODULE_0__.DataTr
|
|
|
1879
1893
|
}
|
|
1880
1894
|
sum(data, _) {
|
|
1881
1895
|
(0,_assertions__WEBPACK_IMPORTED_MODULE_1__.assertIsArray)(data, this._formatDataNotArrayError("sum"));
|
|
1896
|
+
if (data.length === 0) {
|
|
1897
|
+
throw new Error("Cannot perform operation on empty array, result query contains no data");
|
|
1898
|
+
}
|
|
1882
1899
|
const map = this.query.options.getLast("map");
|
|
1883
1900
|
let sum = 0;
|
|
1884
1901
|
const field = this._getSelectionField("sum", map);
|
|
@@ -1974,15 +1991,26 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
1974
1991
|
|
|
1975
1992
|
class SqlTranslator extends _DataTranslator__WEBPACK_IMPORTED_MODULE_0__.DataTranslator {
|
|
1976
1993
|
count(data, _) {
|
|
1994
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
1995
|
+
// Count should be returned as the property alias on the query
|
|
1996
|
+
return data[0].count;
|
|
1997
|
+
}
|
|
1977
1998
|
return data;
|
|
1978
1999
|
}
|
|
1979
2000
|
min(data, _) {
|
|
1980
|
-
return data;
|
|
2001
|
+
return this.shapeResult(data);
|
|
1981
2002
|
}
|
|
1982
2003
|
max(data, _) {
|
|
1983
|
-
return data;
|
|
2004
|
+
return this.shapeResult(data);
|
|
1984
2005
|
}
|
|
1985
2006
|
sum(data, _) {
|
|
2007
|
+
return this.shapeResult(data);
|
|
2008
|
+
}
|
|
2009
|
+
shapeResult(data) {
|
|
2010
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
2011
|
+
// Shape the result
|
|
2012
|
+
return data[0];
|
|
2013
|
+
}
|
|
1986
2014
|
return data;
|
|
1987
2015
|
}
|
|
1988
2016
|
distinct(data, _) {
|
|
@@ -2000,8 +2028,29 @@ class SqlTranslator extends _DataTranslator__WEBPACK_IMPORTED_MODULE_0__.DataTra
|
|
|
2000
2028
|
sort(data, _) {
|
|
2001
2029
|
return data;
|
|
2002
2030
|
}
|
|
2003
|
-
map(data,
|
|
2004
|
-
|
|
2031
|
+
map(data, option) {
|
|
2032
|
+
if (Array.isArray(data) == false) {
|
|
2033
|
+
throw new Error("Can only map an array of data");
|
|
2034
|
+
}
|
|
2035
|
+
if (this.query.options.has("count") && data.length === 1) {
|
|
2036
|
+
// data here is the shape of { count: number }[] and will map to nothing.
|
|
2037
|
+
// Return the original data and let count take care of this
|
|
2038
|
+
return data;
|
|
2039
|
+
}
|
|
2040
|
+
const response = [];
|
|
2041
|
+
for (let i = 0, length = data.length; i < length; i++) {
|
|
2042
|
+
for (let j = 0, l = option.value.fields.length; j < l; j++) {
|
|
2043
|
+
const field = option.value.fields[j];
|
|
2044
|
+
if (field.property != null) {
|
|
2045
|
+
const value = field.property.getValue(data[i]);
|
|
2046
|
+
if (value != null) {
|
|
2047
|
+
field.property.setValue(data[i], field.property.deserialize(value));
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
response.push(option.value.selector(data[i]));
|
|
2052
|
+
}
|
|
2053
|
+
return response;
|
|
2005
2054
|
}
|
|
2006
2055
|
}
|
|
2007
2056
|
|