@thisisagile/easy-mongo 9.5.9 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Utils.js CHANGED
@@ -2,14 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toMongoType = void 0;
4
4
  const easy_1 = require("@thisisagile/easy");
5
- const toMongoType = (input) => {
6
- return (0, easy_1.choose)(input)
7
- .case(v => (0, easy_1.isIsoDateString)(v), (v) => new easy_1.DateTime(v).toDate())
8
- .case(v => (0, easy_1.isArray)(v), (v) => v.map((i) => (0, exports.toMongoType)(i)))
9
- .case(v => (0, easy_1.isObject)(v) && !(0, easy_1.isDate)(v), (v) => Object.fromEntries((0, easy_1.meta)(v)
10
- .entries()
11
- .map(([k, i]) => [k, (0, exports.toMongoType)(i)])))
12
- .else(input);
13
- };
5
+ const toMongoType = (input) => (0, easy_1.choose)(input)
6
+ .type(easy_1.isIsoDateString, i => new easy_1.DateTime(i).toDate())
7
+ .type(easy_1.isArray, a => a.map((i) => (0, exports.toMongoType)(i)))
8
+ .type(easy_1.isDate, d => d)
9
+ .type(easy_1.isObject, o => Object.fromEntries((0, easy_1.meta)(o).entries().map(([k, i]) => [k, (0, exports.toMongoType)(i)])))
10
+ .else(input);
14
11
  exports.toMongoType = toMongoType;
15
12
  //# sourceMappingURL=Utils.js.map
package/dist/Utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;AAAA,4CAA6G;AAEtG,MAAM,WAAW,GAAG,CAAC,KAAc,EAAQ,EAAE;IAClD,OAAO,IAAA,aAAM,EAAW,KAAK,CAAC;SAC3B,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,IAAA,sBAAe,EAAC,CAAC,CAAC,EACvB,CAAC,CAAM,EAAE,EAAE,CAAC,IAAI,eAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,E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W,CAAC,IAAA,WAAI,EAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAA,mBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/F,IAAI,CAAC,KAAK,CAAC,CAAC;AANF,QAAA,WAAW,eAMT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-mongo",
3
- "version": "9.5.9",
3
+ "version": "10.2.0",
4
4
  "description": "Add support for MongoDB",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@thisisagile/easy-test": "9.5.9"
34
+ "@thisisagile/easy-test": "10.2.0"
35
35
  },
36
36
  "dependencies": {
37
- "@thisisagile/easy": "9.5.9",
37
+ "@thisisagile/easy": "10.2.0",
38
38
  "mongodb": "^4.5.0"
39
39
  }
40
40
  }
package/src/Utils.ts CHANGED
@@ -1,23 +1,9 @@
1
1
  import { choose, DateTime, isArray, isDate, isIsoDateString, isObject, Json, meta } from '@thisisagile/easy';
2
2
 
3
- export const toMongoType = (input: unknown): Json => {
4
- return choose<any, any>(input)
5
- .case(
6
- v => isIsoDateString(v),
7
- (v: any) => new DateTime(v).toDate()
8
- )
9
- .case(
10
- v => isArray(v),
11
- (v: any) => v.map((i: any) => toMongoType(i))
12
- )
13
- .case(
14
- v => isObject(v) && !isDate(v),
15
- (v: any) =>
16
- Object.fromEntries(
17
- meta(v)
18
- .entries()
19
- .map(([k, i]) => [k, toMongoType(i)])
20
- )
21
- )
22
- .else(input);
23
- };
3
+ export const toMongoType = (input: unknown): Json =>
4
+ choose(input)
5
+ .type(isIsoDateString, i => new DateTime(i).toDate() as any)
6
+ .type(isArray, a => a.map((i: any) => toMongoType(i)))
7
+ .type(isDate, d => d)
8
+ .type(isObject, o => Object.fromEntries(meta(o).entries().map(([k, i]) => [k, toMongoType(i)])))
9
+ .else(input);