@tsed/json-mapper 7.0.0-alpha.2 → 7.0.0-beta.11

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.
Files changed (107) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/components/ArrayMapper.js +23 -0
  3. package/lib/cjs/components/ArrayMapper.js.map +1 -0
  4. package/lib/cjs/components/DateMapper.js +30 -0
  5. package/lib/cjs/components/DateMapper.js.map +1 -0
  6. package/lib/cjs/components/MapMapper.js +30 -0
  7. package/lib/cjs/components/MapMapper.js.map +1 -0
  8. package/lib/cjs/components/PrimitiveMapper.js +45 -0
  9. package/lib/cjs/components/PrimitiveMapper.js.map +1 -0
  10. package/lib/cjs/components/SetMapper.js +30 -0
  11. package/lib/cjs/components/SetMapper.js.map +1 -0
  12. package/lib/cjs/components/SymbolMapper.js +24 -0
  13. package/lib/cjs/components/SymbolMapper.js.map +1 -0
  14. package/lib/cjs/decorators/afterDeserialize.js +39 -0
  15. package/lib/cjs/decorators/afterDeserialize.js.map +1 -0
  16. package/lib/cjs/decorators/beforeDeserialize.js +39 -0
  17. package/lib/cjs/decorators/beforeDeserialize.js.map +1 -0
  18. package/lib/cjs/decorators/jsonMapper.js +18 -0
  19. package/lib/cjs/decorators/jsonMapper.js.map +1 -0
  20. package/lib/cjs/decorators/onDeserialize.js +29 -0
  21. package/lib/cjs/decorators/onDeserialize.js.map +1 -0
  22. package/lib/cjs/decorators/onSerialize.js +29 -0
  23. package/lib/cjs/decorators/onSerialize.js.map +1 -0
  24. package/lib/cjs/domain/JsonMapperContext.js +23 -0
  25. package/lib/cjs/domain/JsonMapperContext.js.map +1 -0
  26. package/lib/cjs/domain/JsonMapperTypesContainer.js +23 -0
  27. package/lib/cjs/domain/JsonMapperTypesContainer.js.map +1 -0
  28. package/lib/cjs/hooks/alterAfterDeserialize.js +9 -0
  29. package/lib/cjs/hooks/alterAfterDeserialize.js.map +1 -0
  30. package/lib/cjs/hooks/alterBeforeDeserialize.js +9 -0
  31. package/lib/cjs/hooks/alterBeforeDeserialize.js.map +1 -0
  32. package/lib/cjs/index.js +25 -0
  33. package/lib/cjs/index.js.map +1 -0
  34. package/lib/cjs/interfaces/JsonMapperMethods.js +3 -0
  35. package/lib/cjs/interfaces/JsonMapperMethods.js.map +1 -0
  36. package/lib/cjs/package.json +3 -0
  37. package/lib/cjs/utils/deserialize.js +154 -0
  38. package/lib/cjs/utils/deserialize.js.map +1 -0
  39. package/lib/cjs/utils/serialize.js +145 -0
  40. package/lib/cjs/utils/serialize.js.map +1 -0
  41. package/lib/esm/components/ArrayMapper.js +20 -0
  42. package/lib/esm/components/ArrayMapper.js.map +1 -0
  43. package/lib/esm/components/DateMapper.js +27 -0
  44. package/lib/esm/components/DateMapper.js.map +1 -0
  45. package/lib/esm/components/MapMapper.js +27 -0
  46. package/lib/esm/components/MapMapper.js.map +1 -0
  47. package/lib/esm/components/PrimitiveMapper.js +42 -0
  48. package/lib/esm/components/PrimitiveMapper.js.map +1 -0
  49. package/lib/esm/components/SetMapper.js +27 -0
  50. package/lib/esm/components/SetMapper.js.map +1 -0
  51. package/lib/esm/components/SymbolMapper.js +21 -0
  52. package/lib/esm/components/SymbolMapper.js.map +1 -0
  53. package/lib/esm/decorators/afterDeserialize.js +35 -0
  54. package/lib/esm/decorators/afterDeserialize.js.map +1 -0
  55. package/lib/esm/decorators/beforeDeserialize.js +35 -0
  56. package/lib/esm/decorators/beforeDeserialize.js.map +1 -0
  57. package/lib/esm/decorators/jsonMapper.js +14 -0
  58. package/lib/esm/decorators/jsonMapper.js.map +1 -0
  59. package/lib/esm/decorators/onDeserialize.js +25 -0
  60. package/lib/esm/decorators/onDeserialize.js.map +1 -0
  61. package/lib/esm/decorators/onSerialize.js +25 -0
  62. package/lib/esm/decorators/onSerialize.js.map +1 -0
  63. package/lib/esm/domain/JsonMapperContext.js +19 -0
  64. package/lib/esm/domain/JsonMapperContext.js.map +1 -0
  65. package/lib/esm/domain/JsonMapperTypesContainer.js +18 -0
  66. package/lib/esm/domain/JsonMapperTypesContainer.js.map +1 -0
  67. package/lib/esm/hooks/alterAfterDeserialize.js +5 -0
  68. package/lib/esm/hooks/alterAfterDeserialize.js.map +1 -0
  69. package/lib/esm/hooks/alterBeforeDeserialize.js +5 -0
  70. package/lib/esm/hooks/alterBeforeDeserialize.js.map +1 -0
  71. package/lib/esm/index.js +22 -0
  72. package/lib/esm/index.js.map +1 -0
  73. package/lib/esm/interfaces/JsonMapperMethods.js +2 -0
  74. package/lib/esm/interfaces/JsonMapperMethods.js.map +1 -0
  75. package/lib/esm/package.json +3 -0
  76. package/lib/esm/utils/deserialize.js +149 -0
  77. package/lib/esm/utils/deserialize.js.map +1 -0
  78. package/lib/esm/utils/serialize.js +140 -0
  79. package/lib/esm/utils/serialize.js.map +1 -0
  80. package/lib/{components → types/components}/ArrayMapper.d.ts +0 -0
  81. package/lib/{components → types/components}/DateMapper.d.ts +0 -0
  82. package/lib/{components → types/components}/MapMapper.d.ts +0 -0
  83. package/lib/{components → types/components}/PrimitiveMapper.d.ts +0 -0
  84. package/lib/{components → types/components}/SetMapper.d.ts +0 -0
  85. package/lib/{components → types/components}/SymbolMapper.d.ts +0 -0
  86. package/lib/{decorators → types/decorators}/afterDeserialize.d.ts +0 -0
  87. package/lib/{decorators → types/decorators}/beforeDeserialize.d.ts +0 -0
  88. package/lib/{decorators → types/decorators}/jsonMapper.d.ts +0 -0
  89. package/lib/{decorators → types/decorators}/onDeserialize.d.ts +0 -0
  90. package/lib/{decorators → types/decorators}/onSerialize.d.ts +0 -0
  91. package/lib/{domain → types/domain}/JsonMapperContext.d.ts +0 -0
  92. package/lib/types/domain/JsonMapperTypesContainer.d.ts +10 -0
  93. package/lib/{hooks → types/hooks}/alterAfterDeserialize.d.ts +0 -0
  94. package/lib/{hooks → types/hooks}/alterBeforeDeserialize.d.ts +0 -0
  95. package/lib/{index.d.ts → types/index.d.ts} +13 -3
  96. package/lib/{interfaces → types/interfaces}/JsonMapperMethods.d.ts +0 -0
  97. package/lib/{utils → types/utils}/deserialize.d.ts +6 -1
  98. package/lib/{utils → types/utils}/serialize.d.ts +7 -2
  99. package/package.json +34 -20
  100. package/readme.md +1 -0
  101. package/tsconfig.compile.esm.json +12 -0
  102. package/lib/components/index.d.ts +0 -6
  103. package/lib/domain/JsonMapperTypesContainer.d.ts +0 -10
  104. package/lib/index.js +0 -715
  105. package/lib/index.js.map +0 -1
  106. package/lib/index.modern.js +0 -704
  107. package/lib/index.modern.js.map +0 -1
package/jest.config.js ADDED
@@ -0,0 +1,14 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ ...require("@tsed/jest-config")(__dirname, "json-mapper"),
6
+ coverageThreshold: {
7
+ global: {
8
+ statements: 100,
9
+ branches: 88.16,
10
+ functions: 100,
11
+ lines: 100
12
+ }
13
+ }
14
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArrayMapper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsonMapper_1 = require("../decorators/jsonMapper");
6
+ /**
7
+ * Mapper for `Array` type.
8
+ * @jsonmapper
9
+ * @component
10
+ */
11
+ let ArrayMapper = class ArrayMapper {
12
+ deserialize(data, options) {
13
+ return [].concat(data).map((item) => options.next(item));
14
+ }
15
+ serialize(data, options) {
16
+ return [].concat(data).map((item) => options.next(item));
17
+ }
18
+ };
19
+ ArrayMapper = tslib_1.__decorate([
20
+ (0, jsonMapper_1.JsonMapper)(Array)
21
+ ], ArrayMapper);
22
+ exports.ArrayMapper = ArrayMapper;
23
+ //# sourceMappingURL=ArrayMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrayMapper.js","sourceRoot":"","sources":["../../../src/components/ArrayMapper.ts"],"names":[],"mappings":";;;;AAAA,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,WAAW,GAAxB,MAAa,WAAW;IACtB,WAAW,CAAU,IAAS,EAAE,OAAsB;QACpD,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,IAAW,EAAE,OAAsB;QAC3C,OAAO,EAAE,CAAC,MAAM,CAAC,IAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AARY,WAAW;IADvB,IAAA,uBAAU,EAAC,KAAK,CAAC;GACL,WAAW,CAQvB;AARY,kCAAW","sourcesContent":["import {JsonMapper} from \"../decorators/jsonMapper\";\nimport {JsonMapperCtx, JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n\n/**\n * Mapper for `Array` type.\n * @jsonmapper\n * @component\n */\n@JsonMapper(Array)\nexport class ArrayMapper implements JsonMapperMethods {\n deserialize<T = any>(data: any, options: JsonMapperCtx): T[] {\n return [].concat(data).map((item) => options.next(item));\n }\n\n serialize(data: any[], options: JsonMapperCtx): any {\n return [].concat(data as any).map((item) => options.next(item));\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateMapper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@tsed/core");
6
+ const jsonMapper_1 = require("../decorators/jsonMapper");
7
+ /**
8
+ * Mapper for `Date` type.
9
+ * @jsonmapper
10
+ * @component
11
+ */
12
+ let DateMapper = class DateMapper {
13
+ deserialize(data) {
14
+ // don't convert unexpected data. In normal case, Ajv reject unexpected data.
15
+ // But by default, we have to skip data deserialization and let user to apply
16
+ // the right mapping
17
+ if ((0, core_1.isBoolean)(data) || data === null || data === undefined) {
18
+ return data;
19
+ }
20
+ return new Date(data);
21
+ }
22
+ serialize(object) {
23
+ return new Date(object).toISOString();
24
+ }
25
+ };
26
+ DateMapper = tslib_1.__decorate([
27
+ (0, jsonMapper_1.JsonMapper)(Date)
28
+ ], DateMapper);
29
+ exports.DateMapper = DateMapper;
30
+ //# sourceMappingURL=DateMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateMapper.js","sourceRoot":"","sources":["../../../src/components/DateMapper.ts"],"names":[],"mappings":";;;;AAAA,qCAAqC;AACrC,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,UAAU,GAAvB,MAAa,UAAU;IAGrB,WAAW,CAAC,IAAS;QACnB,6EAA6E;QAC7E,6EAA6E;QAC7E,oBAAoB;QACpB,IAAI,IAAA,gBAAS,EAAC,IAAI,CAAC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YAC1D,OAAO,IAAI,CAAC;SACb;QAED,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,SAAS,CAAC,MAAY;QACpB,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;CACF,CAAA;AAjBY,UAAU;IADtB,IAAA,uBAAU,EAAC,IAAI,CAAC;GACJ,UAAU,CAiBtB;AAjBY,gCAAU","sourcesContent":["import {isBoolean} from \"@tsed/core\";\nimport {JsonMapper} from \"../decorators/jsonMapper\";\nimport {JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n\n/**\n * Mapper for `Date` type.\n * @jsonmapper\n * @component\n */\n@JsonMapper(Date)\nexport class DateMapper implements JsonMapperMethods {\n deserialize(data: string | number): Date;\n deserialize(data: boolean | null | undefined): boolean | null | undefined;\n deserialize(data: any): any {\n // don't convert unexpected data. In normal case, Ajv reject unexpected data.\n // But by default, we have to skip data deserialization and let user to apply\n // the right mapping\n if (isBoolean(data) || data === null || data === undefined) {\n return data;\n }\n\n return new Date(data);\n }\n\n serialize(object: Date): any {\n return new Date(object).toISOString();\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapMapper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@tsed/core");
6
+ const jsonMapper_1 = require("../decorators/jsonMapper");
7
+ /**
8
+ * Mapper for `Map` type.
9
+ * @jsonmapper
10
+ * @component
11
+ */
12
+ let MapMapper = class MapMapper {
13
+ deserialize(data, ctx) {
14
+ const obj = new Map();
15
+ (0, core_1.objectKeys)(data).forEach((key) => {
16
+ obj.set(key, ctx.next(data[key]));
17
+ });
18
+ return obj;
19
+ }
20
+ serialize(data, ctx) {
21
+ const obj = {};
22
+ data.forEach((value, key) => (obj[key] = ctx.next(value)));
23
+ return obj;
24
+ }
25
+ };
26
+ MapMapper = tslib_1.__decorate([
27
+ (0, jsonMapper_1.JsonMapper)(Map)
28
+ ], MapMapper);
29
+ exports.MapMapper = MapMapper;
30
+ //# sourceMappingURL=MapMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapMapper.js","sourceRoot":"","sources":["../../../src/components/MapMapper.ts"],"names":[],"mappings":";;;;AAAA,qCAAsC;AACtC,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAA8B,IAA0B,EAAE,GAAwB;QAC3F,MAAM,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;QAEjC,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAM,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,CAAI,IAAoB,EAAE,GAAkB;QACnD,MAAM,GAAG,GAAQ,EAAE,CAAC;QAEpB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAQ,EAAE,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtE,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAA;AAlBY,SAAS;IADrB,IAAA,uBAAU,EAAC,GAAG,CAAC;GACH,SAAS,CAkBrB;AAlBY,8BAAS","sourcesContent":["import {objectKeys} from \"@tsed/core\";\nimport {JsonMapper} from \"../decorators/jsonMapper\";\nimport {JsonMapperCtx, JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n\n/**\n * Mapper for `Map` type.\n * @jsonmapper\n * @component\n */\n@JsonMapper(Map)\nexport class MapMapper implements JsonMapperMethods {\n deserialize<T = any, C = Map<string, T>>(data: {[key: string]: any}, ctx: JsonMapperCtx<T, C>): Map<string, T> {\n const obj = new Map<string, T>();\n\n objectKeys(data).forEach((key) => {\n obj.set(key, ctx.next(data[key]) as T);\n });\n\n return obj;\n }\n\n serialize<T>(data: Map<string, T>, ctx: JsonMapperCtx): any {\n const obj: any = {};\n\n data.forEach((value: T, key: string) => (obj[key] = ctx.next(value)));\n\n return obj;\n }\n}\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrimitiveMapper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const exceptions_1 = require("@tsed/exceptions");
6
+ const jsonMapper_1 = require("../decorators/jsonMapper");
7
+ /**
8
+ * Mapper for the `String`, `Number` and `Boolean` types.
9
+ * @jsonmapper
10
+ * @component
11
+ */
12
+ let PrimitiveMapper = class PrimitiveMapper {
13
+ deserialize(data, ctx) {
14
+ switch (ctx.type) {
15
+ case String:
16
+ return data === null ? null : "" + data;
17
+ case Number:
18
+ if ([null, "null"].includes(data))
19
+ return null;
20
+ const n = +data;
21
+ if (isNaN(n)) {
22
+ throw new exceptions_1.BadRequest("Cast error. Expression value is not a number.");
23
+ }
24
+ return n;
25
+ case Boolean:
26
+ if (["true", "1", true].includes(data))
27
+ return true;
28
+ if (["false", "0", false].includes(data))
29
+ return false;
30
+ if ([null, "null"].includes(data))
31
+ return null;
32
+ if (data === undefined)
33
+ return undefined;
34
+ return !!data;
35
+ }
36
+ }
37
+ serialize(object) {
38
+ return object;
39
+ }
40
+ };
41
+ PrimitiveMapper = tslib_1.__decorate([
42
+ (0, jsonMapper_1.JsonMapper)(String, Number, Boolean)
43
+ ], PrimitiveMapper);
44
+ exports.PrimitiveMapper = PrimitiveMapper;
45
+ //# sourceMappingURL=PrimitiveMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveMapper.js","sourceRoot":"","sources":["../../../src/components/PrimitiveMapper.ts"],"names":[],"mappings":";;;;AAAA,iDAA4C;AAC5C,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAe;IAC1B,WAAW,CAAI,IAAS,EAAE,GAAkB;QAC1C,QAAQ,GAAG,CAAC,IAAI,EAAE;YAChB,KAAK,MAAM;gBACT,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;YAE1C,KAAK,MAAM;gBACT,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAE/C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;gBAEhB,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;oBACZ,MAAM,IAAI,uBAAU,CAAC,+CAA+C,CAAC,CAAC;iBACvE;gBAED,OAAO,CAAC,CAAC;YAEX,KAAK,OAAO;gBACV,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,OAAO,IAAI,CAAC;gBACpD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,OAAO,KAAK,CAAC;gBACvD,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAC/C,IAAI,IAAI,KAAK,SAAS;oBAAE,OAAO,SAAS,CAAC;gBAEzC,OAAO,CAAC,CAAC,IAAI,CAAC;SACjB;IACH,CAAC;IAED,SAAS,CAAC,MAAiC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA9BY,eAAe;IAD3B,IAAA,uBAAU,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;GACvB,eAAe,CA8B3B;AA9BY,0CAAe","sourcesContent":["import {BadRequest} from \"@tsed/exceptions\";\nimport {JsonMapper} from \"../decorators/jsonMapper\";\nimport {JsonMapperCtx, JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n\n/**\n * Mapper for the `String`, `Number` and `Boolean` types.\n * @jsonmapper\n * @component\n */\n@JsonMapper(String, Number, Boolean)\nexport class PrimitiveMapper implements JsonMapperMethods {\n deserialize<T>(data: any, ctx: JsonMapperCtx): string | number | boolean | void | null {\n switch (ctx.type) {\n case String:\n return data === null ? null : \"\" + data;\n\n case Number:\n if ([null, \"null\"].includes(data)) return null;\n\n const n = +data;\n\n if (isNaN(n)) {\n throw new BadRequest(\"Cast error. Expression value is not a number.\");\n }\n\n return n;\n\n case Boolean:\n if ([\"true\", \"1\", true].includes(data)) return true;\n if ([\"false\", \"0\", false].includes(data)) return false;\n if ([null, \"null\"].includes(data)) return null;\n if (data === undefined) return undefined;\n\n return !!data;\n }\n }\n\n serialize(object: string | number | boolean): string | number | boolean {\n return object;\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetMapper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@tsed/core");
6
+ const jsonMapper_1 = require("../decorators/jsonMapper");
7
+ /**
8
+ * Mapper for the `Set` Type.
9
+ * @jsonmapper
10
+ * @component
11
+ */
12
+ let SetMapper = class SetMapper {
13
+ deserialize(data, ctx) {
14
+ const obj = new Set();
15
+ (0, core_1.objectKeys)(data).forEach((key) => {
16
+ obj.add(ctx.next(data[key]));
17
+ });
18
+ return obj;
19
+ }
20
+ serialize(data, ctx) {
21
+ const array = [];
22
+ data.forEach((value) => array.push(ctx.next(value)));
23
+ return array;
24
+ }
25
+ };
26
+ SetMapper = tslib_1.__decorate([
27
+ (0, jsonMapper_1.JsonMapper)(Set)
28
+ ], SetMapper);
29
+ exports.SetMapper = SetMapper;
30
+ //# sourceMappingURL=SetMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SetMapper.js","sourceRoot":"","sources":["../../../src/components/SetMapper.ts"],"names":[],"mappings":";;;;AAAA,qCAAsC;AACtC,yDAAoD;AAGpD;;;;GAIG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAAI,IAAS,EAAE,GAAkB;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAK,CAAC;QAEzB,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,CAAI,IAAY,EAAE,GAAkB;QAC3C,MAAM,KAAK,GAAU,EAAE,CAAC;QAExB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAlBY,SAAS;IADrB,IAAA,uBAAU,EAAC,GAAG,CAAC;GACH,SAAS,CAkBrB;AAlBY,8BAAS","sourcesContent":["import {objectKeys} from \"@tsed/core\";\nimport {JsonMapper} from \"../decorators/jsonMapper\";\nimport {JsonMapperCtx, JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n\n/**\n * Mapper for the `Set` Type.\n * @jsonmapper\n * @component\n */\n@JsonMapper(Set)\nexport class SetMapper implements JsonMapperMethods {\n deserialize<T>(data: any, ctx: JsonMapperCtx): Set<T> {\n const obj = new Set<T>();\n\n objectKeys(data).forEach((key) => {\n obj.add(ctx.next(data[key]));\n });\n\n return obj;\n }\n\n serialize<T>(data: Set<T>, ctx: JsonMapperCtx): any[] {\n const array: any[] = [];\n\n data.forEach((value) => array.push(ctx.next(value)));\n\n return array;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SymbolMapper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsonMapper_1 = require("../decorators/jsonMapper");
6
+ /**
7
+ * Mapper for the `Symbol` type.
8
+ *
9
+ * @jsonmapper
10
+ * @component
11
+ */
12
+ let SymbolMapper = class SymbolMapper {
13
+ deserialize(data) {
14
+ return Symbol.for(data);
15
+ }
16
+ serialize(object) {
17
+ return object.toString().replace("Symbol(", "").replace(")", "");
18
+ }
19
+ };
20
+ SymbolMapper = tslib_1.__decorate([
21
+ (0, jsonMapper_1.JsonMapper)(Symbol)
22
+ ], SymbolMapper);
23
+ exports.SymbolMapper = SymbolMapper;
24
+ //# sourceMappingURL=SymbolMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SymbolMapper.js","sourceRoot":"","sources":["../../../src/components/SymbolMapper.ts"],"names":[],"mappings":";;;;AAAA,yDAAoD;AAGpD;;;;;GAKG;AAEH,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,WAAW,CAAC,IAAY;QACtB,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AARY,YAAY;IADxB,IAAA,uBAAU,EAAC,MAAM,CAAC;GACN,YAAY,CAQxB;AARY,oCAAY","sourcesContent":["import {JsonMapper} from \"../decorators/jsonMapper\";\nimport {JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n\n/**\n * Mapper for the `Symbol` type.\n *\n * @jsonmapper\n * @component\n */\n@JsonMapper(Symbol)\nexport class SymbolMapper implements JsonMapperMethods {\n deserialize(data: string): symbol {\n return Symbol.for(data);\n }\n\n serialize(object: Symbol): any {\n return object.toString().replace(\"Symbol(\", \"\").replace(\")\", \"\");\n }\n}\n"]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AfterDeserialize = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ /**
6
+ * Call the function after JsonMapper.
7
+ *
8
+ * ## Example
9
+ *
10
+ * ```typescript
11
+ * @AfterDeserialize((data: Model) => { // After deserialize get the instance class
12
+ * if (data.prop1 === 'VALUE' && data.prop2 !== 'VALUE2') {
13
+ * throw BadRequest('MyMessage'); // or throw a ValidationError
14
+ * } else {
15
+ * data.prop2 = 'VALUE2';
16
+ * return data;
17
+ * }
18
+ * })
19
+ * class Model {
20
+ * @Property()
21
+ * prop1: string;
22
+ * @Property()
23
+ * prop2: string;
24
+ * }
25
+ * ```
26
+ *
27
+ * @returns {Function}
28
+ * @decorator
29
+ * @schema
30
+ * @property
31
+ * @param cb
32
+ */
33
+ function AfterDeserialize(cb) {
34
+ return (0, schema_1.JsonEntityFn)((storedJson) => {
35
+ storedJson.schema.$hooks.on("afterDeserialize", cb);
36
+ });
37
+ }
38
+ exports.AfterDeserialize = AfterDeserialize;
39
+ //# sourceMappingURL=afterDeserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afterDeserialize.js","sourceRoot":"","sources":["../../../src/decorators/afterDeserialize.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,gBAAgB,CAAC,EAA4B;IAC3D,OAAO,IAAA,qBAAY,EAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,4CAIC","sourcesContent":["import {JsonEntityFn, JsonHookContext} from \"@tsed/schema\";\n\nexport interface AfterDeserializeCallback {\n (value: any, ctx: JsonHookContext): any;\n}\n\n/**\n * Call the function after JsonMapper.\n *\n * ## Example\n *\n * ```typescript\n * @AfterDeserialize((data: Model) => { // After deserialize get the instance class\n * if (data.prop1 === 'VALUE' && data.prop2 !== 'VALUE2') {\n * throw BadRequest('MyMessage'); // or throw a ValidationError\n * } else {\n * data.prop2 = 'VALUE2';\n * return data;\n * }\n * })\n * class Model {\n * @Property()\n * prop1: string;\n * @Property()\n * prop2: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @schema\n * @property\n * @param cb\n */\nexport function AfterDeserialize(cb: AfterDeserializeCallback): ClassDecorator {\n return JsonEntityFn((storedJson) => {\n storedJson.schema.$hooks.on(\"afterDeserialize\", cb);\n });\n}\n"]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeforeDeserialize = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ /**
6
+ * Call the function before JsonMapper.
7
+ *
8
+ * ## Example
9
+ *
10
+ * ```typescript
11
+ * @BeforeDeserialize((data: Record<string, unknown>) => { // Before deserialize get the data
12
+ * if (data.prop1 === 'VALUE' && data.prop2 !== 'VALUE2') {
13
+ * throw BadRequest('MyMessage'); // or throw a ValidationError
14
+ * } else {
15
+ * data.prop2 = 'VALUE2';
16
+ * return data;
17
+ * }
18
+ * })
19
+ * class Model {
20
+ * @Property()
21
+ * prop1: string;
22
+ * @Property()
23
+ * prop2: string;
24
+ * }
25
+ * ```
26
+ *
27
+ * @returns {Function}
28
+ * @decorator
29
+ * @schema
30
+ * @property
31
+ * @param cb
32
+ */
33
+ function BeforeDeserialize(cb) {
34
+ return (0, schema_1.JsonEntityFn)((storedJson) => {
35
+ storedJson.schema.$hooks.on("beforeDeserialize", cb);
36
+ });
37
+ }
38
+ exports.BeforeDeserialize = BeforeDeserialize;
39
+ //# sourceMappingURL=beforeDeserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beforeDeserialize.js","sourceRoot":"","sources":["../../../src/decorators/beforeDeserialize.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,iBAAiB,CAAC,EAA6B;IAC7D,OAAO,IAAA,qBAAY,EAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,8CAIC","sourcesContent":["import {JsonEntityFn, JsonHookContext} from \"@tsed/schema\";\n\nexport interface BeforeDeserializeCallback {\n (value: any, ctx: JsonHookContext): any;\n}\n\n/**\n * Call the function before JsonMapper.\n *\n * ## Example\n *\n * ```typescript\n * @BeforeDeserialize((data: Record<string, unknown>) => { // Before deserialize get the data\n * if (data.prop1 === 'VALUE' && data.prop2 !== 'VALUE2') {\n * throw BadRequest('MyMessage'); // or throw a ValidationError\n * } else {\n * data.prop2 = 'VALUE2';\n * return data;\n * }\n * })\n * class Model {\n * @Property()\n * prop1: string;\n * @Property()\n * prop2: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @schema\n * @property\n * @param cb\n */\nexport function BeforeDeserialize(cb: BeforeDeserializeCallback): ClassDecorator {\n return JsonEntityFn((storedJson) => {\n storedJson.schema.$hooks.on(\"beforeDeserialize\", cb);\n });\n}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonMapper = void 0;
4
+ const JsonMapperTypesContainer_1 = require("../domain/JsonMapperTypesContainer");
5
+ /**
6
+ * Register a new JsonMapper Type
7
+ * @param types
8
+ * @constructor
9
+ */
10
+ function JsonMapper(...types) {
11
+ return (target) => {
12
+ types.forEach((type) => {
13
+ (0, JsonMapperTypesContainer_1.registerJsonTypeMapper)(type, target);
14
+ });
15
+ };
16
+ }
17
+ exports.JsonMapper = JsonMapper;
18
+ //# sourceMappingURL=jsonMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonMapper.js","sourceRoot":"","sources":["../../../src/decorators/jsonMapper.ts"],"names":[],"mappings":";;;AACA,iFAA0E;AAE1E;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAG,KAAqB;IACjD,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAA,iDAAsB,EAAC,IAAI,EAAE,MAAa,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,gCAMC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {registerJsonTypeMapper} from \"../domain/JsonMapperTypesContainer\";\n\n/**\n * Register a new JsonMapper Type\n * @param types\n * @constructor\n */\nexport function JsonMapper(...types: (any | Type)[]): ClassDecorator {\n return (target) => {\n types.forEach((type) => {\n registerJsonTypeMapper(type, target as any);\n });\n };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnDeserialize = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ /**
6
+ * Call the function before property deserialization.
7
+ *
8
+ * ## Example
9
+ *
10
+ * ```typescript
11
+ * class Model {
12
+ * @OnDeserialize(v => v + 1)
13
+ * property: string;
14
+ * }
15
+ * ```
16
+ *
17
+ * @returns {Function}
18
+ * @decorator
19
+ * @schema
20
+ * @property
21
+ * @param cb
22
+ */
23
+ function OnDeserialize(cb) {
24
+ return (0, schema_1.JsonEntityFn)((storedJson) => {
25
+ storedJson.schema.$hooks.on("onDeserialize", cb);
26
+ });
27
+ }
28
+ exports.OnDeserialize = OnDeserialize;
29
+ //# sourceMappingURL=onDeserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onDeserialize.js","sourceRoot":"","sources":["../../../src/decorators/onDeserialize.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAM3D;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,aAAa,CAAC,EAAyB;IACrD,OAAO,IAAA,qBAAY,EAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,sCAIC","sourcesContent":["import {JsonHookContext, JsonEntityFn} from \"@tsed/schema\";\n\nexport interface OnDeserializeCallback {\n (value: any, ctx: JsonHookContext): any;\n}\n\n/**\n * Call the function before property deserialization.\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @OnDeserialize(v => v + 1)\n * property: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @schema\n * @property\n * @param cb\n */\nexport function OnDeserialize(cb: OnDeserializeCallback): PropertyDecorator {\n return JsonEntityFn((storedJson) => {\n storedJson.schema.$hooks.on(\"onDeserialize\", cb);\n });\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnSerialize = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ /**
6
+ * Call the function before property serialization.
7
+ *
8
+ * ## Example
9
+ *
10
+ * ```typescript
11
+ * class Model {
12
+ * @OnSerialize(v => v + 1)
13
+ * property: string;
14
+ * }
15
+ * ```
16
+ *
17
+ * @returns {Function}
18
+ * @decorator
19
+ * @schema
20
+ * @property
21
+ * @param cb
22
+ */
23
+ function OnSerialize(cb) {
24
+ return (0, schema_1.JsonEntityFn)((storedJson) => {
25
+ storedJson.schema.$hooks.on("onSerialize", cb);
26
+ });
27
+ }
28
+ exports.OnSerialize = OnSerialize;
29
+ //# sourceMappingURL=onSerialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onSerialize.js","sourceRoot":"","sources":["../../../src/decorators/onSerialize.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAM3D;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,WAAW,CAAC,EAAuB;IACjD,OAAO,IAAA,qBAAY,EAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,kCAIC","sourcesContent":["import {JsonEntityFn, JsonHookContext} from \"@tsed/schema\";\n\nexport interface OnSerializeCallback {\n (value: any, ctx: JsonHookContext): any;\n}\n\n/**\n * Call the function before property serialization.\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @OnSerialize(v => v + 1)\n * property: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @schema\n * @property\n * @param cb\n */\nexport function OnSerialize(cb: OnSerializeCallback): PropertyDecorator {\n return JsonEntityFn((storedJson) => {\n storedJson.schema.$hooks.on(\"onSerialize\", cb);\n });\n}\n"]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonMapperContext = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ /**
6
+ * @ignore
7
+ */
8
+ class JsonMapperContext {
9
+ constructor({ type, collectionType, next, options }) {
10
+ this.type = type;
11
+ this.collectionType = (0, core_1.isCollection)(collectionType) ? collectionType : undefined;
12
+ this._next = next;
13
+ this.options = options;
14
+ }
15
+ next(data) {
16
+ return this._next(data, {
17
+ ...this.options,
18
+ type: this.type
19
+ });
20
+ }
21
+ }
22
+ exports.JsonMapperContext = JsonMapperContext;
23
+ //# sourceMappingURL=JsonMapperContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonMapperContext.js","sourceRoot":"","sources":["../../../src/domain/JsonMapperContext.ts"],"names":[],"mappings":";;;AAAA,qCAA8C;AAS9C;;GAEG;AACH,MAAa,iBAAiB;IAM5B,YAAY,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAyB;QACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAA,mBAAY,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QAChF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,IAAS;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACtB,GAAG,IAAI,CAAC,OAAO;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,8CAmBC","sourcesContent":["import {isCollection, Type} from \"@tsed/core\";\nimport {JsonMapperCtx} from \"../interfaces/JsonMapperMethods\";\n/**\n * @ignore\n */\nexport interface JsonMapperContextProps extends Partial<Omit<JsonMapperCtx, \"next\">> {\n next: (data: any, options: any) => void;\n options: any;\n}\n/**\n * @ignore\n */\nexport class JsonMapperContext implements JsonMapperCtx {\n readonly collectionType: Type<any> | undefined;\n readonly type: Type<any> | any;\n readonly options: any;\n private _next: (data: any, options: any) => void;\n\n constructor({type, collectionType, next, options}: JsonMapperContextProps) {\n this.type = type;\n this.collectionType = isCollection(collectionType) ? collectionType : undefined;\n this._next = next;\n this.options = options;\n }\n\n next(data: any) {\n return this._next(data, {\n ...this.options,\n type: this.type\n });\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getJsonMapperTypes = exports.registerJsonTypeMapper = void 0;
4
+ /**
5
+ * @ignore
6
+ */
7
+ // tslint:disable-next-line:variable-name
8
+ const JsonMapperTypesContainer = new Map();
9
+ /**
10
+ * @ignore
11
+ */
12
+ function registerJsonTypeMapper(type, token) {
13
+ JsonMapperTypesContainer.set(type, new token());
14
+ }
15
+ exports.registerJsonTypeMapper = registerJsonTypeMapper;
16
+ /**
17
+ * @ignore
18
+ */
19
+ function getJsonMapperTypes() {
20
+ return JsonMapperTypesContainer;
21
+ }
22
+ exports.getJsonMapperTypes = getJsonMapperTypes;
23
+ //# sourceMappingURL=JsonMapperTypesContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonMapperTypesContainer.js","sourceRoot":"","sources":["../../../src/domain/JsonMapperTypesContainer.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,yCAAyC;AACzC,MAAM,wBAAwB,GAAwD,IAAI,GAAG,EAAE,CAAC;AAChG;;GAEG;AACH,SAAgB,sBAAsB,CAAC,IAAiC,EAAE,KAA8B;IACtG,wBAAwB,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;AAClD,CAAC;AAFD,wDAEC;AACD;;GAEG;AACH,SAAgB,kBAAkB;IAChC,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAFD,gDAEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonMapperMethods} from \"../interfaces/JsonMapperMethods\";\n/**\n * @ignore\n */\n// tslint:disable-next-line:variable-name\nconst JsonMapperTypesContainer: Map<Type<any> | Symbol | string, JsonMapperMethods> = new Map();\n/**\n * @ignore\n */\nexport function registerJsonTypeMapper(type: Type<any> | Symbol | string, token: Type<JsonMapperMethods>) {\n JsonMapperTypesContainer.set(type, new token());\n}\n/**\n * @ignore\n */\nexport function getJsonMapperTypes(): Map<Type<any> | Symbol | string, JsonMapperMethods> {\n return JsonMapperTypesContainer;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alterAfterDeserialize = void 0;
4
+ function alterAfterDeserialize(data, schema, options) {
5
+ var _a;
6
+ return (_a = schema === null || schema === void 0 ? void 0 : schema.$hooks) === null || _a === void 0 ? void 0 : _a.alter("afterDeserialize", data, [options]);
7
+ }
8
+ exports.alterAfterDeserialize = alterAfterDeserialize;
9
+ //# sourceMappingURL=alterAfterDeserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alterAfterDeserialize.js","sourceRoot":"","sources":["../../../src/hooks/alterAfterDeserialize.ts"],"names":[],"mappings":";;;AAEA,SAAgB,qBAAqB,CAAC,IAAS,EAAE,MAAuB,EAAE,OAAY;;IACpF,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,KAAK,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,sDAEC","sourcesContent":["import {Hooks} from \"@tsed/core\";\n\nexport function alterAfterDeserialize(data: any, schema: {$hooks: Hooks}, options: any) {\n return schema?.$hooks?.alter(\"afterDeserialize\", data, [options]);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alterBeforeDeserialize = void 0;
4
+ function alterBeforeDeserialize(data, schema, options) {
5
+ var _a;
6
+ return (_a = schema === null || schema === void 0 ? void 0 : schema.$hooks) === null || _a === void 0 ? void 0 : _a.alter("beforeDeserialize", data, [options]);
7
+ }
8
+ exports.alterBeforeDeserialize = alterBeforeDeserialize;
9
+ //# sourceMappingURL=alterBeforeDeserialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alterBeforeDeserialize.js","sourceRoot":"","sources":["../../../src/hooks/alterBeforeDeserialize.ts"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CAAC,IAAS,EAAE,MAAuB,EAAE,OAAY;;IACrF,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,KAAK,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wDAEC","sourcesContent":["import {Hooks} from \"@tsed/core\";\n\nexport function alterBeforeDeserialize(data: any, schema: {$hooks: Hooks}, options: any) {\n return schema?.$hooks?.alter(\"beforeDeserialize\", data, [options]);\n}\n"]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * @file Automatically generated by barrelsby.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tslib_1 = require("tslib");
7
+ tslib_1.__exportStar(require("./components/ArrayMapper"), exports);
8
+ tslib_1.__exportStar(require("./components/DateMapper"), exports);
9
+ tslib_1.__exportStar(require("./components/MapMapper"), exports);
10
+ tslib_1.__exportStar(require("./components/PrimitiveMapper"), exports);
11
+ tslib_1.__exportStar(require("./components/SetMapper"), exports);
12
+ tslib_1.__exportStar(require("./components/SymbolMapper"), exports);
13
+ tslib_1.__exportStar(require("./decorators/afterDeserialize"), exports);
14
+ tslib_1.__exportStar(require("./decorators/beforeDeserialize"), exports);
15
+ tslib_1.__exportStar(require("./decorators/jsonMapper"), exports);
16
+ tslib_1.__exportStar(require("./decorators/onDeserialize"), exports);
17
+ tslib_1.__exportStar(require("./decorators/onSerialize"), exports);
18
+ tslib_1.__exportStar(require("./domain/JsonMapperContext"), exports);
19
+ tslib_1.__exportStar(require("./domain/JsonMapperTypesContainer"), exports);
20
+ tslib_1.__exportStar(require("./hooks/alterAfterDeserialize"), exports);
21
+ tslib_1.__exportStar(require("./hooks/alterBeforeDeserialize"), exports);
22
+ tslib_1.__exportStar(require("./interfaces/JsonMapperMethods"), exports);
23
+ tslib_1.__exportStar(require("./utils/deserialize"), exports);
24
+ tslib_1.__exportStar(require("./utils/serialize"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mEAAyC;AACzC,kEAAwC;AACxC,iEAAuC;AACvC,uEAA6C;AAC7C,iEAAuC;AACvC,oEAA0C;AAC1C,wEAA8C;AAC9C,yEAA+C;AAC/C,kEAAwC;AACxC,qEAA2C;AAC3C,mEAAyC;AACzC,qEAA2C;AAC3C,4EAAkD;AAClD,wEAA8C;AAC9C,yEAA+C;AAC/C,yEAA+C;AAC/C,8DAAoC;AACpC,4DAAkC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/ArrayMapper\";\nexport * from \"./components/DateMapper\";\nexport * from \"./components/MapMapper\";\nexport * from \"./components/PrimitiveMapper\";\nexport * from \"./components/SetMapper\";\nexport * from \"./components/SymbolMapper\";\nexport * from \"./decorators/afterDeserialize\";\nexport * from \"./decorators/beforeDeserialize\";\nexport * from \"./decorators/jsonMapper\";\nexport * from \"./decorators/onDeserialize\";\nexport * from \"./decorators/onSerialize\";\nexport * from \"./domain/JsonMapperContext\";\nexport * from \"./domain/JsonMapperTypesContainer\";\nexport * from \"./hooks/alterAfterDeserialize\";\nexport * from \"./hooks/alterBeforeDeserialize\";\nexport * from \"./interfaces/JsonMapperMethods\";\nexport * from \"./utils/deserialize\";\nexport * from \"./utils/serialize\";\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=JsonMapperMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonMapperMethods.js","sourceRoot":"","sources":["../../../src/interfaces/JsonMapperMethods.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\n\nexport interface JsonMapperCtx<T = any, C = any> {\n collectionType: Type<C> | undefined;\n type: Type<T> | T;\n next: JsonMapperNext;\n}\n\nexport interface JsonMapperNext {\n (obj: any): any;\n}\n\nexport interface JsonMapperMethods {\n /**\n *\n * @param obj\n * @param {JsonMapperNext} ctx\n * @returns {any}\n */\n deserialize<T = any, C = any>(obj: any, ctx: JsonMapperCtx<T, C>): any;\n\n /**\n *\n * @param obj\n * @param ctx\n * @returns {any}\n */\n serialize(obj: any, ctx: JsonMapperCtx<any>): any;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }