@tsed/json-mapper 7.35.0-rc.1 → 7.35.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.
Files changed (97) hide show
  1. package/jest.config.js +3 -3
  2. package/lib/browser/json-mapper.umd.min.js +1 -1
  3. package/lib/browser/json-mapper.umd.min.js.map +1 -1
  4. package/lib/cjs/components/ArrayMapper.js +23 -0
  5. package/lib/cjs/components/ArrayMapper.js.map +1 -0
  6. package/lib/cjs/components/DateMapper.js +1 -1
  7. package/lib/cjs/components/DateMapper.js.map +1 -1
  8. package/lib/cjs/components/MapMapper.js +30 -0
  9. package/lib/cjs/components/MapMapper.js.map +1 -0
  10. package/lib/cjs/components/PrimitiveMapper.js +26 -30
  11. package/lib/cjs/components/PrimitiveMapper.js.map +1 -1
  12. package/lib/cjs/components/SetMapper.js +30 -0
  13. package/lib/cjs/components/SetMapper.js.map +1 -0
  14. package/lib/cjs/components/SymbolMapper.js.map +1 -1
  15. package/lib/cjs/domain/JsonMapperContext.js +27 -0
  16. package/lib/cjs/domain/JsonMapperContext.js.map +1 -0
  17. package/lib/cjs/index.js +4 -9
  18. package/lib/cjs/index.js.map +1 -1
  19. package/lib/cjs/utils/deserialize.js +202 -5
  20. package/lib/cjs/utils/deserialize.js.map +1 -1
  21. package/lib/cjs/utils/serialize.js +143 -5
  22. package/lib/cjs/utils/serialize.js.map +1 -1
  23. package/lib/esm/components/ArrayMapper.js +20 -0
  24. package/lib/esm/components/ArrayMapper.js.map +1 -0
  25. package/lib/esm/components/DateMapper.js +1 -1
  26. package/lib/esm/components/DateMapper.js.map +1 -1
  27. package/lib/esm/components/MapMapper.js +27 -0
  28. package/lib/esm/components/MapMapper.js.map +1 -0
  29. package/lib/esm/components/PrimitiveMapper.js +26 -30
  30. package/lib/esm/components/PrimitiveMapper.js.map +1 -1
  31. package/lib/esm/components/SetMapper.js +27 -0
  32. package/lib/esm/components/SetMapper.js.map +1 -0
  33. package/lib/esm/components/SymbolMapper.js.map +1 -1
  34. package/lib/esm/domain/JsonMapperContext.js +23 -0
  35. package/lib/esm/domain/JsonMapperContext.js.map +1 -0
  36. package/lib/esm/index.js +4 -9
  37. package/lib/esm/index.js.map +1 -1
  38. package/lib/esm/utils/deserialize.js +200 -4
  39. package/lib/esm/utils/deserialize.js.map +1 -1
  40. package/lib/esm/utils/serialize.js +141 -4
  41. package/lib/esm/utils/serialize.js.map +1 -1
  42. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  43. package/lib/tsconfig.tsbuildinfo +1 -1
  44. package/lib/types/components/ArrayMapper.d.ts +10 -0
  45. package/lib/types/components/MapMapper.d.ts +12 -0
  46. package/lib/types/components/PrimitiveMapper.d.ts +0 -4
  47. package/lib/types/components/SetMapper.d.ts +10 -0
  48. package/lib/types/domain/JsonMapperContext.d.ts +20 -0
  49. package/lib/types/index.d.ts +4 -9
  50. package/lib/types/utils/deserialize.d.ts +47 -2
  51. package/lib/types/utils/serialize.d.ts +18 -2
  52. package/package.json +8 -11
  53. package/lib/cjs/domain/JsonDeserializer.js +0 -275
  54. package/lib/cjs/domain/JsonDeserializer.js.map +0 -1
  55. package/lib/cjs/domain/JsonDeserializerOptions.js +0 -3
  56. package/lib/cjs/domain/JsonDeserializerOptions.js.map +0 -1
  57. package/lib/cjs/domain/JsonMapperCompiler.js +0 -167
  58. package/lib/cjs/domain/JsonMapperCompiler.js.map +0 -1
  59. package/lib/cjs/domain/JsonSerializer.js +0 -219
  60. package/lib/cjs/domain/JsonSerializer.js.map +0 -1
  61. package/lib/cjs/domain/JsonSerializerOptions.js +0 -3
  62. package/lib/cjs/domain/JsonSerializerOptions.js.map +0 -1
  63. package/lib/cjs/domain/Writer.js +0 -141
  64. package/lib/cjs/domain/Writer.js.map +0 -1
  65. package/lib/cjs/hooks/alterOnDeserialize.js +0 -8
  66. package/lib/cjs/hooks/alterOnDeserialize.js.map +0 -1
  67. package/lib/cjs/hooks/alterOnSerialize.js +0 -8
  68. package/lib/cjs/hooks/alterOnSerialize.js.map +0 -1
  69. package/lib/cjs/utils/getObjectProperties.js +0 -9
  70. package/lib/cjs/utils/getObjectProperties.js.map +0 -1
  71. package/lib/esm/domain/JsonDeserializer.js +0 -271
  72. package/lib/esm/domain/JsonDeserializer.js.map +0 -1
  73. package/lib/esm/domain/JsonDeserializerOptions.js +0 -2
  74. package/lib/esm/domain/JsonDeserializerOptions.js.map +0 -1
  75. package/lib/esm/domain/JsonMapperCompiler.js +0 -163
  76. package/lib/esm/domain/JsonMapperCompiler.js.map +0 -1
  77. package/lib/esm/domain/JsonSerializer.js +0 -215
  78. package/lib/esm/domain/JsonSerializer.js.map +0 -1
  79. package/lib/esm/domain/JsonSerializerOptions.js +0 -2
  80. package/lib/esm/domain/JsonSerializerOptions.js.map +0 -1
  81. package/lib/esm/domain/Writer.js +0 -137
  82. package/lib/esm/domain/Writer.js.map +0 -1
  83. package/lib/esm/hooks/alterOnDeserialize.js +0 -4
  84. package/lib/esm/hooks/alterOnDeserialize.js.map +0 -1
  85. package/lib/esm/hooks/alterOnSerialize.js +0 -4
  86. package/lib/esm/hooks/alterOnSerialize.js.map +0 -1
  87. package/lib/esm/utils/getObjectProperties.js +0 -5
  88. package/lib/esm/utils/getObjectProperties.js.map +0 -1
  89. package/lib/types/domain/JsonDeserializer.d.ts +0 -33
  90. package/lib/types/domain/JsonDeserializerOptions.d.ts +0 -31
  91. package/lib/types/domain/JsonMapperCompiler.d.ts +0 -58
  92. package/lib/types/domain/JsonSerializer.d.ts +0 -21
  93. package/lib/types/domain/JsonSerializerOptions.d.ts +0 -13
  94. package/lib/types/domain/Writer.d.ts +0 -43
  95. package/lib/types/hooks/alterOnDeserialize.d.ts +0 -2
  96. package/lib/types/hooks/alterOnSerialize.d.ts +0 -2
  97. package/lib/types/utils/getObjectProperties.d.ts +0 -1
@@ -1,215 +0,0 @@
1
- import { classOf, hasJsonMethod, isClassObject, isCollection, isDate, isMomentObject, isMongooseObject, isNil, isObject, isPrimitive, nameOf } from "@tsed/core";
2
- import { getPropertiesStores, JsonEntityStore } from "@tsed/schema";
3
- import { alterOnSerialize } from "../hooks/alterOnSerialize.js";
4
- import { getObjectProperties } from "../utils/getObjectProperties.js";
5
- import { JsonMapperCompiler } from "./JsonMapperCompiler.js";
6
- import { getJsonMapperTypes } from "./JsonMapperTypesContainer.js";
7
- import { Writer } from "./Writer.js";
8
- function getBestType(type, obj) {
9
- const dataType = classOf(obj);
10
- if (dataType && !isClassObject(dataType)) {
11
- return dataType;
12
- }
13
- return type || Object;
14
- }
15
- export class JsonSerializer extends JsonMapperCompiler {
16
- constructor() {
17
- super();
18
- this.addTypeMapper(Object, this.mapObject.bind(this));
19
- this.addTypeMapper(Array, this.mapArray.bind(this));
20
- this.addTypeMapper(Map, this.mapMap.bind(this));
21
- this.addTypeMapper(Set, this.mapSet.bind(this));
22
- this.addGlobal("mapJSON", this.mapJSON.bind(this));
23
- this.addTypeMapper("ObjectId", (value) => String(value));
24
- }
25
- map(input, options = {}) {
26
- if (isNil(input)) {
27
- return input;
28
- }
29
- options = this.mapOptions(options);
30
- const model = getBestType(options.type, input);
31
- const mapper = this.compile(model, options.groups);
32
- return mapper.fn(input, this.createContext(options));
33
- }
34
- alterValue(schemaId, value, options) {
35
- return alterOnSerialize(this.schemes[schemaId], value, options);
36
- }
37
- createMapper(model, id, groups) {
38
- const entity = JsonEntityStore.from(model);
39
- const properties = new Set();
40
- const schemaProperties = [...getPropertiesStores(entity).values()];
41
- const writer = new Writer().arrow("input", "options");
42
- writer.if("isNil(input)").return("input");
43
- // prepare options
44
- writer.const("obj", "{}");
45
- writer.set("options", "{...options, self: input}");
46
- // detect some special case
47
- writer.add(this.mapPrecondition(id));
48
- if (!schemaProperties.length) {
49
- return writer.return("input").root().toString();
50
- }
51
- // properties
52
- writer.add(...schemaProperties.flatMap((propertyStore) => {
53
- properties.add(propertyStore.propertyKey);
54
- if (propertyStore.schema?.$hooks?.has("groups") && this.alterGroups(propertyStore.schema, groups)) {
55
- return;
56
- }
57
- return this.mapProperty(propertyStore, id, groups);
58
- }));
59
- // discriminator
60
- writer.add(this.mapDiscriminator(entity));
61
- // additional properties
62
- writer.add(this.mapAdditionalProperties(entity, properties));
63
- return writer.return("obj").root().toString();
64
- }
65
- mapOptions({ groups = false, useAlias = true, types, ...options }) {
66
- const customMappers = {};
67
- types = types || getJsonMapperTypes();
68
- types.forEach((mapper, model) => {
69
- if (![Array, Set, Map].includes(model)) {
70
- this.addTypeMapper(model, mapper.serialize.bind(mapper));
71
- }
72
- });
73
- return {
74
- ...options,
75
- groups,
76
- useAlias,
77
- customMappers
78
- };
79
- }
80
- mapProperty(propertyStore, id, groups) {
81
- const key = String(propertyStore.propertyKey);
82
- const aliasKey = String(propertyStore.parent.schema.getAliasOf(key) || key);
83
- const schemaId = this.getSchemaId(id, key);
84
- let writer = new Writer().add(`// Map ${key} ${id} ${groups || ""}`);
85
- // ignore hook (deprecated)
86
- if (propertyStore.schema?.$hooks?.has("ignore")) {
87
- this.schemes[schemaId] = propertyStore.schema;
88
- writer = writer.if(`!alterIgnore('${schemaId}', {...options, self: input})`);
89
- }
90
- writer = writer.add(`let ${key} = input.${key};`).if(`${key} !== undefined`);
91
- const format = propertyStore.itemSchema.get("format");
92
- const formatOpts = format && `options: {format: '${format}'}`;
93
- // pre hook
94
- const hasSerializer = propertyStore.schema?.$hooks?.has("onSerialize");
95
- if (hasSerializer) {
96
- this.schemes[schemaId] = propertyStore.schema;
97
- const opts = Writer.options(formatOpts);
98
- writer.set(key, `alterValue('${schemaId}', ${key}, ${opts})`);
99
- }
100
- const fill = this.getPropertyFiller(propertyStore, key, groups, formatOpts);
101
- if (hasSerializer) {
102
- fill(writer.if(`${key} === input.${key}`));
103
- }
104
- else {
105
- fill(writer);
106
- }
107
- if (aliasKey !== key) {
108
- writer.set(`obj[options.useAlias ? '${aliasKey}' : '${key}']`, key);
109
- }
110
- else {
111
- writer.set(`obj.${key}`, key);
112
- }
113
- return writer.root();
114
- }
115
- getPropertyFiller(propertyStore, key, groups, formatOpts) {
116
- if (propertyStore.isCollection) {
117
- const type = propertyStore.getBestType();
118
- const nestedMapper = this.compile(type, groups);
119
- return (writer) => writer.callMapper(nameOf(propertyStore.collectionType), key, `id: '${nestedMapper.id}'`, formatOpts);
120
- }
121
- const type = propertyStore.getBestType();
122
- const nestedMapper = this.compile(type, groups);
123
- return (writer) => writer.callMapper(nestedMapper.id, key, formatOpts);
124
- }
125
- mapPrecondition(id) {
126
- const writer = new Writer();
127
- writer.if("input && isCollection(input)").return(Writer.mapperFrom("input", `{...options, id: '${id}'}`));
128
- writer.if("hasJsonMethod(input)").return(`mapJSON(input, {...options, id: '${id}'})`);
129
- return writer;
130
- }
131
- mapDiscriminator(entity) {
132
- if (entity.discriminatorAncestor) {
133
- const discriminator = entity.discriminatorAncestor.schema.discriminator();
134
- const type = discriminator.getDefaultValue(entity.target);
135
- if (type) {
136
- const writer = new Writer();
137
- writer.if(`!obj.${discriminator.propertyName}`).set(`obj.${discriminator.propertyName}`, `'${type}'`);
138
- return writer;
139
- }
140
- }
141
- }
142
- mapAdditionalProperties(entity, properties) {
143
- const additionalProperties = !!entity.schema.get("additionalProperties");
144
- if (additionalProperties) {
145
- const exclude = [...properties.values()].map((key) => `'${key}'`).join(", ");
146
- const writer = new Writer();
147
- writer.add("// add additional properties");
148
- writer.each("objectKeys(input)", ["key"]).if(`![${exclude}].includes(key)`).set("obj[key]", "input[key]");
149
- return writer;
150
- }
151
- }
152
- mapObject(input, { type, ...options }) {
153
- if ((input && isPrimitive(input)) || !input) {
154
- // prevent mongoose mapping error
155
- return input;
156
- }
157
- if (input && isCollection(input)) {
158
- return this.execMapper(nameOf(classOf(input)), input, options);
159
- }
160
- if (hasJsonMethod(input)) {
161
- return this.mapJSON(input, options);
162
- }
163
- return getObjectProperties(input)
164
- .filter(([, value]) => value !== undefined)
165
- .reduce((obj, [key, value]) => {
166
- if (isNil(value)) {
167
- return {
168
- ...obj,
169
- [key]: value
170
- };
171
- }
172
- const mapper = this.compile(classOf(value), options.groups);
173
- return {
174
- ...obj,
175
- [key]: mapper.fn(value, options)
176
- };
177
- }, {});
178
- }
179
- mapSet(input, options) {
180
- return [...input.values()].map((item) => {
181
- return this.mapItem(item, options);
182
- });
183
- }
184
- mapArray(input, options) {
185
- return [].concat(input).map((item) => {
186
- return this.mapItem(item, options);
187
- });
188
- }
189
- mapMap(input, options) {
190
- return [...input.entries()].reduce((obj, [key, item]) => {
191
- return {
192
- ...obj,
193
- [key]: this.mapItem(item, options)
194
- };
195
- }, {});
196
- }
197
- mapItem(input, { id, ...options }) {
198
- if (!id && input) {
199
- return this.compile(classOf(input), options.groups).fn(input, options);
200
- }
201
- return id ? this.execMapper(id, input, options) : input;
202
- }
203
- mapJSON(input, { id, ...options }) {
204
- if (isMongooseObject(input)) {
205
- return input.toJSON({ ...options, id });
206
- }
207
- id = id || nameOf(classOf(input));
208
- if (this.mappers[id] && (isDate(input) || isMomentObject(input))) {
209
- return this.execMapper(id, input, options);
210
- }
211
- input = input.toJSON();
212
- return isObject(input) ? this.execMapper(id, input, options) : input;
213
- }
214
- }
215
- //# sourceMappingURL=JsonSerializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JsonSerializer.js","sourceRoot":"","sources":["../../../src/domain/JsonSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,aAAa,EACb,aAAa,EACb,YAAY,EACZ,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,EAEP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,mBAAmB,EAAkB,eAAe,EAAoB,MAAM,cAAc,CAAC;AACrG,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAC,M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,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SACxE;QAED,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,CAAC;IAEO,OAAO,CAAC,KAAU,EAAE,EAAC,EAAE,EAAE,GAAG,OAAO,EAAwB;QACjE,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC;SACvC;QAED,EAAE,GAAG,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAElC,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;YAChE,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;SAC5C;QAED,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAEvB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACvE,CAAC;CACF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=JsonSerializerOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JsonSerializerOptions.js","sourceRoot":"","sources":["../../../src/domain/JsonSerializerOptions.ts"],"names":[],"mappings":""}
@@ -1,137 +0,0 @@
1
- export class Writer {
2
- static object = {
3
- assign(...args) {
4
- return `{ ${args.filter(Boolean).join(", ")} }`;
5
- }
6
- };
7
- _root;
8
- body = [];
9
- _indent;
10
- constructor(root) {
11
- this._root = root;
12
- }
13
- static indent(lines) {
14
- return lines.map((p) => `\t${p}`);
15
- }
16
- static mapper(mapperId, key, options) {
17
- return `execMapper('${mapperId}', ${key}, ${options})`;
18
- }
19
- static mapperFrom(key, options) {
20
- return `execMapper(nameOf(classOf(${key})), ${key}, ${options})`;
21
- }
22
- static options(...args) {
23
- args = args.filter(Boolean);
24
- return !args.length ? "options" : Writer.object.assign("...options", ...args);
25
- }
26
- add(...lines) {
27
- lines = lines.filter((line) => line !== undefined);
28
- lines.length && this.body.push(...lines);
29
- return this;
30
- }
31
- arrow(...args) {
32
- this.add(`(${args}) => {`);
33
- const writer = this.new();
34
- this.add("}");
35
- return writer;
36
- }
37
- build() {
38
- const result = this.body.flatMap((line) => {
39
- return line instanceof Writer ? line.build() : line;
40
- });
41
- return this._indent ? result.map((item) => "\t" + item) : result;
42
- }
43
- callMapper(id, key, ...options) {
44
- return this.set(key, Writer.mapper(id, key, Writer.options(...options)));
45
- }
46
- returnCallMapper(id, key, ...options) {
47
- return this.return(Writer.mapper(id, key, Writer.options(...options)));
48
- }
49
- const(name, line) {
50
- this.add(`const ${name} = ${line};`);
51
- return this;
52
- }
53
- each(iterable, args = []) {
54
- const writer = this.add(iterable + ".forEach((" + args.join(", ") + ") => {").new();
55
- this.add("});");
56
- return writer;
57
- }
58
- if(condition) {
59
- const writer = new IfWriter(condition, this);
60
- this.add(writer);
61
- return writer;
62
- }
63
- switch(input) {
64
- const sw = new SwitchWriter(input);
65
- this.add(sw);
66
- return sw;
67
- }
68
- indent(indent) {
69
- this._indent = indent;
70
- return this;
71
- }
72
- new(indent = true) {
73
- const writer = new Writer(this.root());
74
- writer.indent(indent);
75
- this.add(writer);
76
- return writer;
77
- }
78
- return(line) {
79
- this.add(`return ${line};`);
80
- return this.root();
81
- }
82
- root() {
83
- return this._root || this;
84
- }
85
- set(left, right) {
86
- this.add(`${left} = ${right};`);
87
- return this;
88
- }
89
- toString() {
90
- return this.build().join("\n");
91
- }
92
- }
93
- class IfWriter extends Writer {
94
- condition;
95
- elseWriter;
96
- constructor(condition, root) {
97
- super();
98
- this.condition = condition;
99
- this._root = root;
100
- }
101
- else() {
102
- const writer = new Writer(this._root);
103
- this.elseWriter = writer;
104
- return writer;
105
- }
106
- build() {
107
- return [
108
- `if (${this.condition}) {`,
109
- ...Writer.indent(super.build()),
110
- "}",
111
- this.elseWriter ? [`else {`, ...Writer.indent(this.elseWriter.build()), "}"] : []
112
- ].flat();
113
- }
114
- }
115
- class SwitchWriter extends Writer {
116
- input;
117
- #map = new Map();
118
- constructor(input) {
119
- super();
120
- this.input = input;
121
- }
122
- case(condition) {
123
- const writer = new Writer();
124
- this.#map.set(condition, writer);
125
- return writer;
126
- }
127
- build() {
128
- return [
129
- `switch (${this.input}) {`,
130
- ...Writer.indent(Array.from(this.#map.entries()).flatMap(([condition, writer]) => {
131
- return [condition === "default" ? `${condition}:` : `case ${condition}:`, ...Writer.indent(writer.build())];
132
- })),
133
- "}"
134
- ].flat();
135
- }
136
- }
137
- //# sourceMappingURL=Writer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Writer.js","sourceRoot":"","sources":["../../../src/domain/Writer.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,MAAM;IACjB,MAAM,CAAC,MAAM,GAAG;QACd,MAAM,CAAC,GAAG,IAAc;YACtB,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAClD,CAAC;KACF,CAAC;IAEQ,KAAK,CAAU;IACf,IAAI,GAAwB,EAAE,CAAC;IACjC,OAAO,CAAU;IAEzB,YAAY,IAAa;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAe;QAC3B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAA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CAAC,CAAC,CACH;YACD,GAAG;SACJ,CAAC,IAAI,EAAE,CAAC;IACX,CAAC;CACF"}
@@ -1,4 +0,0 @@
1
- export function alterOnDeserialize(schema, value, options) {
2
- return schema.$hooks.alter("onDeserialize", value, [options]);
3
- }
4
- //# sourceMappingURL=alterOnDeserialize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alterOnDeserialize.js","sourceRoot":"","sources":["../../../src/hooks/alterOnDeserialize.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,MAAkB,EAAE,KAAU,EAAE,OAAwB;IACzF,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC"}
@@ -1,4 +0,0 @@
1
- export function alterOnSerialize(schema, value, options) {
2
- return schema.$hooks.alter("onSerialize", value, [options]);
3
- }
4
- //# sourceMappingURL=alterOnSerialize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alterOnSerialize.js","sourceRoot":"","sources":["../../../src/hooks/alterOnSerialize.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,MAAkB,EAAE,KAAU,EAAE,OAAwB;IACvF,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9D,CAAC"}
@@ -1,5 +0,0 @@
1
- import { isFunction } from "@tsed/core";
2
- export function getObjectProperties(obj) {
3
- return Object.entries(obj).filter(([, value]) => !isFunction(value));
4
- }
5
- //# sourceMappingURL=getObjectProperties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getObjectProperties.js","sourceRoot":"","sources":["../../../src/utils/getObjectProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC"}
@@ -1,33 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { JsonDeserializerOptions } from "./JsonDeserializerOptions";
3
- import { CachedJsonMapper, JsonMapperCompiler } from "./JsonMapperCompiler";
4
- export declare class JsonDeserializer extends JsonMapperCompiler<JsonDeserializerOptions> {
5
- /**
6
- * Cached classes by his id
7
- * @protected
8
- */
9
- protected constructors: Record<string, Type<any>>;
10
- constructor();
11
- map<Model = any>(input: any, options?: JsonDeserializerOptions): Model;
12
- compile(model: Type<any>, groups: false | string[]): CachedJsonMapper<JsonDeserializerOptions>;
13
- eval(mapper: string, { id, groupsId, model }: {
14
- id: string;
15
- model: Type<any>;
16
- groupsId: string;
17
- }): CachedJsonMapper<JsonDeserializerOptions>;
18
- protected newInstanceOf(id: string, obj: any, options: any): any;
19
- protected createMapper(model: Type<any>, id: string, groups: false | string[]): string;
20
- protected alterValue(schemaId: string, value: any, options: JsonDeserializerOptions): any;
21
- private mapDiscriminator;
22
- private mapProperty;
23
- private getPropertyFiller;
24
- private mapOptions;
25
- private mapAdditionalProperties;
26
- private mapObject;
27
- private mapSet;
28
- private mapArray;
29
- private mapMap;
30
- private mapItem;
31
- private alterBeforeDeserialize;
32
- private alterAfterDeserialize;
33
- }
@@ -1,31 +0,0 @@
1
- import { MetadataTypes, Type } from "@tsed/core";
2
- import { JsonEntityStore } from "@tsed/schema";
3
- import { JsonMapperMethods } from "../interfaces/JsonMapperMethods";
4
- export interface JsonDeserializerOptions<T = any, C = any> extends MetadataTypes<T, C> {
5
- /**
6
- * Types used to map complex types (Symbol, Array, Set, Map)
7
- */
8
- types?: Map<Type<any> | Symbol | string, JsonMapperMethods>;
9
- /**
10
- * useAlias mapping
11
- */
12
- useAlias?: boolean;
13
- /**
14
- * Accept additionalProperties or ignore it
15
- */
16
- additionalProperties?: boolean;
17
- /**
18
- *
19
- */
20
- disableUnsecureConstructor?: boolean;
21
- /**
22
- * Use the store which have all metadata to deserialize correctly the model. This
23
- * property is useful when you deal with metadata parameters.
24
- */
25
- store?: JsonEntityStore;
26
- /**
27
- *
28
- */
29
- groups?: string[] | false;
30
- [key: string]: any;
31
- }
@@ -1,58 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { JsonSchema } from "@tsed/schema";
3
- export type JsonMapperCallback<Options> = (input: any, options?: Options) => any;
4
- export type CachedJsonMapper<Options> = {
5
- id: string;
6
- fn: JsonMapperCallback<Options>;
7
- };
8
- export type CachedGroupsJsonMapper<Options> = Map<string, CachedJsonMapper<Options>>;
9
- export declare abstract class JsonMapperCompiler<Options extends Record<string, any> = any> {
10
- /**
11
- * Cached mappers metadata
12
- * @protected
13
- */
14
- protected cache: Map<string | Type<any>, CachedGroupsJsonMapper<Options>>;
15
- /**
16
- * Cached executable mappers by his id
17
- * @protected
18
- */
19
- protected mappers: Record<string, JsonMapperCallback<Options>>;
20
- /**
21
- * Cached schemas
22
- * @protected
23
- */
24
- protected schemes: Record<string, any>;
25
- /**
26
- * Cached classes by his id
27
- * @protected
28
- */
29
- protected constructors: Record<string, Type<any>>;
30
- /**
31
- * Global variables available in the mapper
32
- * @protected
33
- */
34
- protected globals: Record<string, any>;
35
- constructor();
36
- addTypeMapper(model: Type<any> | string, fn: any): this;
37
- removeTypeMapper(model: Type<any> | string): void;
38
- addGlobal(key: string, value: any): this;
39
- eval(mapper: string, { id, groupsId, model }: {
40
- id: string;
41
- model: Type<any>;
42
- groupsId: string;
43
- }): CachedJsonMapper<Options>;
44
- createContext(options: Options): Options & {
45
- cache: Map<string | Type<any>, CachedGroupsJsonMapper<Options>>;
46
- };
47
- compile(model: Type<any>, groups: false | string[]): CachedJsonMapper<Options>;
48
- protected execMapper(id: string, value: any, options: Options): any;
49
- protected abstract map(input: any, options: Options): any;
50
- protected abstract alterValue(schemaId: string, value: any, options: Options): any;
51
- protected abstract createMapper(model: Type<any>, id: string, groups: false | string[]): string;
52
- protected getType(model: Type<any>): Type<any> | MapConstructor | ObjectConstructor | ArrayConstructor | SetConstructor;
53
- protected alterIgnore(id: string, options: Options): any;
54
- protected alterGroups(schema: JsonSchema, groups: false | string[]): any;
55
- protected getGroupsId(groups: false | string[]): string;
56
- protected getId(model: Type<any>, groupsId: string): string;
57
- protected getSchemaId(id: string, propertyKey: string): string;
58
- }
@@ -1,21 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { JsonMapperCompiler } from "./JsonMapperCompiler";
3
- import { JsonSerializerOptions } from "./JsonSerializerOptions";
4
- export declare class JsonSerializer extends JsonMapperCompiler<JsonSerializerOptions> {
5
- constructor();
6
- map(input: any, options?: JsonSerializerOptions): any;
7
- protected alterValue(schemaId: string, value: any, options: JsonSerializerOptions): any;
8
- protected createMapper(model: Type<any>, id: string, groups: false | string[]): string;
9
- private mapOptions;
10
- private mapProperty;
11
- private getPropertyFiller;
12
- private mapPrecondition;
13
- private mapDiscriminator;
14
- private mapAdditionalProperties;
15
- private mapObject;
16
- private mapSet;
17
- private mapArray;
18
- private mapMap;
19
- private mapItem;
20
- private mapJSON;
21
- }
@@ -1,13 +0,0 @@
1
- import { MetadataTypes, Type } from "@tsed/core";
2
- import { JsonMapperMethods } from "../interfaces/JsonMapperMethods";
3
- export interface JsonSerializerOptions<T = any, C = any> extends MetadataTypes<T, C> {
4
- /**
5
- * Types used to map complex types (Symbol, Number, String, etc...)
6
- */
7
- types?: Map<Type<any> | Symbol | string, JsonMapperMethods>;
8
- /**
9
- * useAlias mapping
10
- */
11
- useAlias?: boolean;
12
- [key: string]: any;
13
- }
@@ -1,43 +0,0 @@
1
- export declare class Writer {
2
- static object: {
3
- assign(...args: string[]): string;
4
- };
5
- protected _root?: Writer;
6
- protected body: (string | Writer)[];
7
- private _indent;
8
- constructor(root?: Writer);
9
- static indent(lines: string[]): string[];
10
- static mapper(mapperId: string, key: string, options: string): string;
11
- static mapperFrom(key: string, options: string): string;
12
- static options(...args: string[]): string;
13
- add(...lines: (undefined | string | Writer)[]): this;
14
- arrow(...args: string[]): Writer;
15
- build(): string[];
16
- callMapper(id: string, key: string, ...options: string[]): this;
17
- returnCallMapper(id: string, key: string, ...options: string[]): Writer;
18
- const(name: string, line: string): this;
19
- each(iterable: string, args?: string[]): Writer;
20
- if(condition: string): IfWriter;
21
- switch(input: string): SwitchWriter;
22
- indent(indent: boolean): this;
23
- new(indent?: boolean): Writer;
24
- return(line: string): Writer;
25
- root(): Writer;
26
- set(left: string, right: string): this;
27
- toString(): string;
28
- }
29
- declare class IfWriter extends Writer {
30
- protected condition: string;
31
- protected elseWriter?: Writer;
32
- constructor(condition: string, root: Writer);
33
- else(): Writer;
34
- build(): string[];
35
- }
36
- declare class SwitchWriter extends Writer {
37
- #private;
38
- private input;
39
- constructor(input: string);
40
- case(condition: string): Writer;
41
- build(): string[];
42
- }
43
- export {};
@@ -1,2 +0,0 @@
1
- import { JsonHookContext, JsonSchema } from "@tsed/schema";
2
- export declare function alterOnDeserialize(schema: JsonSchema, value: any, options: JsonHookContext): any;
@@ -1,2 +0,0 @@
1
- import { JsonHookContext, JsonSchema } from "@tsed/schema";
2
- export declare function alterOnSerialize(schema: JsonSchema, value: any, options: JsonHookContext): any;
@@ -1 +0,0 @@
1
- export declare function getObjectProperties(obj: any): [string, any][];