gingersnap 0.26.6 → 0.26.7
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/data/model/model.cjs +9 -9
- package/data/model/model.mjs +9 -9
- package/package.json +1 -1
package/data/model/model.cjs
CHANGED
|
@@ -464,7 +464,7 @@ class Model {
|
|
|
464
464
|
const model = new this();
|
|
465
465
|
const props = this.buildPropTree(Object.getPrototypeOf(model));
|
|
466
466
|
R__namespace.forEach(([key, fieldProps]) => {
|
|
467
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
467
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
468
468
|
let value = data[key];
|
|
469
469
|
if (value === undefined || value === null) {
|
|
470
470
|
for (const alias of (_a = fieldProps.aliases) !== null && _a !== void 0 ? _a : []) {
|
|
@@ -487,7 +487,7 @@ class Model {
|
|
|
487
487
|
}
|
|
488
488
|
const checkOtherTypes = (value, Type, fallback) => {
|
|
489
489
|
var _a, _b;
|
|
490
|
-
if (
|
|
490
|
+
if (Type && Type === Time.Instant) {
|
|
491
491
|
switch (typeof value) {
|
|
492
492
|
case "number":
|
|
493
493
|
return new Time.Instant(value);
|
|
@@ -501,7 +501,7 @@ class Model {
|
|
|
501
501
|
throw new ParsingError.ParsingError([], `value for ${key} is not a valid type to convert to Instant`);
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
else if (
|
|
504
|
+
else if (Type && Type === Time.Duration) {
|
|
505
505
|
switch (typeof value) {
|
|
506
506
|
case "number":
|
|
507
507
|
return Time.milliseconds(value);
|
|
@@ -657,7 +657,7 @@ class Model {
|
|
|
657
657
|
throw new ParsingError.ParsingError([], (_g = e === null || e === void 0 ? void 0 : e.message) !== null && _g !== void 0 ? _g : String(e));
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
-
else if (
|
|
660
|
+
else if (fieldProps.Type && fieldProps.Type === Time.Instant) {
|
|
661
661
|
switch (typeof value) {
|
|
662
662
|
case "number":
|
|
663
663
|
model[key] = new Time.Instant(value);
|
|
@@ -673,7 +673,7 @@ class Model {
|
|
|
673
673
|
throw new ParsingError.ParsingError([], `value for ${key} is not a valid type to convert to Instant`);
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
|
-
else if (
|
|
676
|
+
else if (fieldProps.Type && fieldProps.Type === Time.Duration) {
|
|
677
677
|
switch (typeof value) {
|
|
678
678
|
case "number":
|
|
679
679
|
model[key] = Time.milliseconds(value);
|
|
@@ -695,7 +695,7 @@ class Model {
|
|
|
695
695
|
catch (e) {
|
|
696
696
|
if (e instanceof ParsingError.ParsingError)
|
|
697
697
|
throw e;
|
|
698
|
-
throw new ParsingError.ParsingError([], (
|
|
698
|
+
throw new ParsingError.ParsingError([], (_h = e === null || e === void 0 ? void 0 : e.message) !== null && _h !== void 0 ? _h : String(e));
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
else if (fieldProps.isArray) {
|
|
@@ -704,7 +704,7 @@ class Model {
|
|
|
704
704
|
value = JSON.parse(value);
|
|
705
705
|
}
|
|
706
706
|
catch (e) {
|
|
707
|
-
throw new ParsingError.ParsingError([], (
|
|
707
|
+
throw new ParsingError.ParsingError([], (_j = e === null || e === void 0 ? void 0 : e.message) !== null && _j !== void 0 ? _j : String(e));
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
if (!(value instanceof Array || Array.isArray(value))) {
|
|
@@ -738,7 +738,7 @@ class Model {
|
|
|
738
738
|
}
|
|
739
739
|
}));
|
|
740
740
|
}
|
|
741
|
-
else if (((
|
|
741
|
+
else if (((_k = fieldProps.Type) === null || _k === void 0 ? void 0 : _k.name) === "Date") {
|
|
742
742
|
const newDate = new Date(value);
|
|
743
743
|
if (isNaN(newDate.getTime()))
|
|
744
744
|
throw new ParsingError.ParsingError([], `value for key ${key} is an invalid date`);
|
|
@@ -757,7 +757,7 @@ class Model {
|
|
|
757
757
|
R__namespace.forEach(([k, v]) => {
|
|
758
758
|
if (v.__callback__)
|
|
759
759
|
v.__callback__(k, v.properties, model, key);
|
|
760
|
-
}, R__namespace.toPairs((
|
|
760
|
+
}, R__namespace.toPairs((_l = fieldProps.customTags) !== null && _l !== void 0 ? _l : {}));
|
|
761
761
|
}, Array.from(props.fields.entries()));
|
|
762
762
|
return Object.seal(model);
|
|
763
763
|
}
|
package/data/model/model.mjs
CHANGED
|
@@ -443,7 +443,7 @@ class Model {
|
|
|
443
443
|
const model = new this();
|
|
444
444
|
const props = this.buildPropTree(Object.getPrototypeOf(model));
|
|
445
445
|
R.forEach(([key, fieldProps]) => {
|
|
446
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
446
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
447
447
|
let value = data[key];
|
|
448
448
|
if (value === undefined || value === null) {
|
|
449
449
|
for (const alias of (_a = fieldProps.aliases) !== null && _a !== void 0 ? _a : []) {
|
|
@@ -466,7 +466,7 @@ class Model {
|
|
|
466
466
|
}
|
|
467
467
|
const checkOtherTypes = (value, Type, fallback) => {
|
|
468
468
|
var _a, _b;
|
|
469
|
-
if (
|
|
469
|
+
if (Type && Type === Instant) {
|
|
470
470
|
switch (typeof value) {
|
|
471
471
|
case "number":
|
|
472
472
|
return new Instant(value);
|
|
@@ -480,7 +480,7 @@ class Model {
|
|
|
480
480
|
throw new ParsingError([], `value for ${key} is not a valid type to convert to Instant`);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
else if (
|
|
483
|
+
else if (Type && Type === Duration) {
|
|
484
484
|
switch (typeof value) {
|
|
485
485
|
case "number":
|
|
486
486
|
return milliseconds(value);
|
|
@@ -636,7 +636,7 @@ class Model {
|
|
|
636
636
|
throw new ParsingError([], (_g = e === null || e === void 0 ? void 0 : e.message) !== null && _g !== void 0 ? _g : String(e));
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
|
-
else if (
|
|
639
|
+
else if (fieldProps.Type && fieldProps.Type === Instant) {
|
|
640
640
|
switch (typeof value) {
|
|
641
641
|
case "number":
|
|
642
642
|
model[key] = new Instant(value);
|
|
@@ -652,7 +652,7 @@ class Model {
|
|
|
652
652
|
throw new ParsingError([], `value for ${key} is not a valid type to convert to Instant`);
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
-
else if (
|
|
655
|
+
else if (fieldProps.Type && fieldProps.Type === Duration) {
|
|
656
656
|
switch (typeof value) {
|
|
657
657
|
case "number":
|
|
658
658
|
model[key] = milliseconds(value);
|
|
@@ -674,7 +674,7 @@ class Model {
|
|
|
674
674
|
catch (e) {
|
|
675
675
|
if (e instanceof ParsingError)
|
|
676
676
|
throw e;
|
|
677
|
-
throw new ParsingError([], (
|
|
677
|
+
throw new ParsingError([], (_h = e === null || e === void 0 ? void 0 : e.message) !== null && _h !== void 0 ? _h : String(e));
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
else if (fieldProps.isArray) {
|
|
@@ -683,7 +683,7 @@ class Model {
|
|
|
683
683
|
value = JSON.parse(value);
|
|
684
684
|
}
|
|
685
685
|
catch (e) {
|
|
686
|
-
throw new ParsingError([], (
|
|
686
|
+
throw new ParsingError([], (_j = e === null || e === void 0 ? void 0 : e.message) !== null && _j !== void 0 ? _j : String(e));
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
689
|
if (!(value instanceof Array || Array.isArray(value))) {
|
|
@@ -717,7 +717,7 @@ class Model {
|
|
|
717
717
|
}
|
|
718
718
|
}));
|
|
719
719
|
}
|
|
720
|
-
else if (((
|
|
720
|
+
else if (((_k = fieldProps.Type) === null || _k === void 0 ? void 0 : _k.name) === "Date") {
|
|
721
721
|
const newDate = new Date(value);
|
|
722
722
|
if (isNaN(newDate.getTime()))
|
|
723
723
|
throw new ParsingError([], `value for key ${key} is an invalid date`);
|
|
@@ -736,7 +736,7 @@ class Model {
|
|
|
736
736
|
R.forEach(([k, v]) => {
|
|
737
737
|
if (v.__callback__)
|
|
738
738
|
v.__callback__(k, v.properties, model, key);
|
|
739
|
-
}, R.toPairs((
|
|
739
|
+
}, R.toPairs((_l = fieldProps.customTags) !== null && _l !== void 0 ? _l : {}));
|
|
740
740
|
}, Array.from(props.fields.entries()));
|
|
741
741
|
return Object.seal(model);
|
|
742
742
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"gingersnap","version":"0.26.
|
|
1
|
+
{"name":"gingersnap","version":"0.26.7","description":"A general purpose library built with the aim of filling the gaps of javascript shortcomings","dependencies":{"@msgpack/msgpack":"^3.0.0-beta2","browser-or-node":"^3.0.0-pre.0","modern-isomorphic-ws":"^1.0.5","object-hash":"^3.0.0","papaparse":"^5.4.1","protobufjs":"^7.2.6","ramda":"^0.30.1","reflect-metadata":"^0.2.2","tslib":"^2.6.3","uuid":"^9.0.1","ws":"^8.16.0","x2js":"^3.4.4"},"author":"CookieNerds LLC","exports":{"./synchronize":{"import":{"types":"./synchronize.d.ts","default":"./synchronize.mjs"},"require":{"types":"./synchronize.d.ts","default":"./synchronize.cjs"}},"./mocks":{"import":{"types":"./mocks.d.ts","default":"./mocks.mjs"},"require":{"types":"./mocks.d.ts","default":"./mocks.cjs"}},"./socket":{"import":{"types":"./socket.d.ts","default":"./socket.mjs"},"require":{"types":"./socket.d.ts","default":"./socket.cjs"}},"./typing/types":{"import":{"types":"./typing/types.d.ts","default":"./typing/types.mjs"},"require":{"types":"./typing/types.d.ts","default":"./typing/types.cjs"}},"./stream":{"import":{"types":"./stream/index.d.ts","default":"./stream.mjs"},"require":{"types":"./stream/index.d.ts","default":"./stream.cjs"}},"./reflection/injector":{"import":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.mjs"},"require":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.cjs"}},"./stream/call":{"import":{"types":"./stream/call.d.ts","default":"./stream/call.mjs"},"require":{"types":"./stream/call.d.ts","default":"./stream/call.cjs"}},"./stream/state":{"import":{"types":"./stream/state.d.ts","default":"./stream/state.mjs"},"require":{"types":"./stream/state.d.ts","default":"./stream/state.cjs"}},"./stream/collector":{"import":{"types":"./stream/collector.d.ts","default":"./stream/collector.mjs"},"require":{"types":"./stream/collector.d.ts","default":"./stream/collector.cjs"}},"./stream/observable":{"import":{"types":"./stream/observable.d.ts","default":"./stream/observable.mjs"},"require":{"types":"./stream/observable.d.ts","default":"./stream/observable.cjs"}},"./networking":{"import":{"types":"./networking/index.d.ts","default":"./networking.mjs"},"require":{"types":"./networking/index.d.ts","default":"./networking.cjs"}},"./managers":{"import":{"types":"./managers/index.d.ts","default":"./managers.mjs"},"require":{"types":"./managers/index.d.ts","default":"./managers.cjs"}},"./future":{"import":{"types":"./future/index.d.ts","default":"./future.mjs"},"require":{"types":"./future/index.d.ts","default":"./future.cjs"}},"./errors":{"import":{"types":"./errors/index.d.ts","default":"./errors.mjs"},"require":{"types":"./errors/index.d.ts","default":"./errors.cjs"}},"./data-structures/array":{"import":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.mjs"},"require":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.cjs"}},"./data-structures/object":{"import":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.mjs"},"require":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.cjs"}},"./data/decoders":{"import":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.mjs"},"require":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.cjs"}},"./data/model":{"import":{"types":"./data/model/index.d.ts","default":"./data/model.mjs"},"require":{"types":"./data/model/index.d.ts","default":"./data/model.cjs"}},"./data/bus":{"import":{"types":"./data/bus.d.ts","default":"./data/bus.mjs"},"require":{"types":"./data/bus.d.ts","default":"./data/bus.cjs"}},"./data/AtomicValue":{"import":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.mjs"},"require":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.cjs"}},"./data/store":{"import":{"types":"./data/store/index.d.ts","default":"./data/store.mjs"},"require":{"types":"./data/store/index.d.ts","default":"./data/store.cjs"}},"./functools":{"import":{"types":"./functools/index.d.ts","default":"./functools.mjs"},"require":{"types":"./functools/index.d.ts","default":"./functools.cjs"}},"./files":{"import":{"types":"./files.d.ts","default":"./files.mjs"},"require":{"types":"./files.d.ts","default":"./files.cjs"}}}}
|