@aom-js/schemer 0.0.1 → 0.0.3

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 (106) hide show
  1. package/dist/cjs/defines/decorators.d.ts +2 -4
  2. package/dist/cjs/defines/decorators.d.ts.map +1 -1
  3. package/dist/cjs/defines/decorators.js +43 -13
  4. package/dist/cjs/defines/decorators.js.map +1 -1
  5. package/dist/cjs/defines/helpers/index.d.ts +2 -0
  6. package/dist/cjs/defines/helpers/index.d.ts.map +1 -0
  7. package/dist/cjs/defines/helpers/index.js +18 -0
  8. package/dist/cjs/defines/helpers/index.js.map +1 -0
  9. package/dist/cjs/defines/helpers/is-nullable.d.ts +3 -0
  10. package/dist/cjs/defines/helpers/is-nullable.d.ts.map +1 -0
  11. package/dist/cjs/defines/helpers/is-nullable.js +10 -0
  12. package/dist/cjs/defines/helpers/is-nullable.js.map +1 -0
  13. package/dist/cjs/defines/mapped-types/index.d.ts +6 -0
  14. package/dist/cjs/defines/mapped-types/index.d.ts.map +1 -0
  15. package/dist/cjs/defines/mapped-types/index.js +22 -0
  16. package/dist/cjs/defines/mapped-types/index.js.map +1 -0
  17. package/dist/cjs/defines/mapped-types/intersection-type.helper.d.ts +11 -0
  18. package/dist/cjs/defines/mapped-types/intersection-type.helper.d.ts.map +1 -0
  19. package/dist/cjs/defines/mapped-types/intersection-type.helper.js +40 -0
  20. package/dist/cjs/defines/mapped-types/intersection-type.helper.js.map +1 -0
  21. package/dist/cjs/defines/mapped-types/mapped-type.interface.d.ts +5 -0
  22. package/dist/cjs/defines/mapped-types/mapped-type.interface.d.ts.map +1 -0
  23. package/dist/cjs/defines/mapped-types/mapped-type.interface.js +3 -0
  24. package/dist/cjs/defines/mapped-types/mapped-type.interface.js.map +1 -0
  25. package/dist/cjs/defines/mapped-types/omit-type.helper.d.ts +5 -0
  26. package/dist/cjs/defines/mapped-types/omit-type.helper.d.ts.map +1 -0
  27. package/dist/cjs/defines/mapped-types/omit-type.helper.js +29 -0
  28. package/dist/cjs/defines/mapped-types/omit-type.helper.js.map +1 -0
  29. package/dist/cjs/defines/mapped-types/partial-type.helper.d.ts +5 -0
  30. package/dist/cjs/defines/mapped-types/partial-type.helper.d.ts.map +1 -0
  31. package/dist/cjs/defines/mapped-types/partial-type.helper.js +26 -0
  32. package/dist/cjs/defines/mapped-types/partial-type.helper.js.map +1 -0
  33. package/dist/cjs/defines/mapped-types/pick-type.helper.d.ts +5 -0
  34. package/dist/cjs/defines/mapped-types/pick-type.helper.d.ts.map +1 -0
  35. package/dist/cjs/defines/mapped-types/pick-type.helper.js +29 -0
  36. package/dist/cjs/defines/mapped-types/pick-type.helper.js.map +1 -0
  37. package/dist/cjs/defines/mapped-types/type.interface.d.ts +2 -0
  38. package/dist/cjs/defines/mapped-types/type.interface.d.ts.map +1 -0
  39. package/dist/cjs/defines/mapped-types/type.interface.js +3 -0
  40. package/dist/cjs/defines/mapped-types/type.interface.js.map +1 -0
  41. package/dist/cjs/defines/mapped-types/types/remove-fields-with-type.type.d.ts +6 -0
  42. package/dist/cjs/defines/mapped-types/types/remove-fields-with-type.type.d.ts.map +1 -0
  43. package/dist/cjs/defines/mapped-types/types/remove-fields-with-type.type.js +3 -0
  44. package/dist/cjs/defines/mapped-types/types/remove-fields-with-type.type.js.map +1 -0
  45. package/dist/cjs/defines/module.d.ts +10 -7
  46. package/dist/cjs/defines/module.d.ts.map +1 -1
  47. package/dist/cjs/defines/module.js +9 -4
  48. package/dist/cjs/defines/module.js.map +1 -1
  49. package/dist/cjs/defines/properties.d.ts +42 -0
  50. package/dist/cjs/defines/properties.d.ts.map +1 -0
  51. package/dist/cjs/defines/properties.js +238 -0
  52. package/dist/cjs/defines/properties.js.map +1 -0
  53. package/dist/cjs/defines/types.d.ts +24 -4
  54. package/dist/cjs/defines/types.d.ts.map +1 -1
  55. package/dist/cjs/defines/types.js +11 -0
  56. package/dist/cjs/defines/types.js.map +1 -1
  57. package/dist/cjs/index.d.ts +3 -0
  58. package/dist/cjs/index.d.ts.map +1 -1
  59. package/dist/cjs/index.js +5 -0
  60. package/dist/cjs/index.js.map +1 -1
  61. package/dist/mjs/defines/decorators.js +44 -13
  62. package/dist/mjs/defines/decorators.js.map +1 -1
  63. package/dist/mjs/defines/helpers/index.js +2 -0
  64. package/dist/mjs/defines/helpers/index.js.map +1 -0
  65. package/dist/mjs/defines/helpers/is-nullable.js +7 -0
  66. package/dist/mjs/defines/helpers/is-nullable.js.map +1 -0
  67. package/dist/mjs/defines/mapped-types/index.js +6 -0
  68. package/dist/mjs/defines/mapped-types/index.js.map +1 -0
  69. package/dist/mjs/defines/mapped-types/intersection-type.helper.js +37 -0
  70. package/dist/mjs/defines/mapped-types/intersection-type.helper.js.map +1 -0
  71. package/dist/mjs/defines/mapped-types/mapped-type.interface.js +2 -0
  72. package/dist/mjs/defines/mapped-types/mapped-type.interface.js.map +1 -0
  73. package/dist/mjs/defines/mapped-types/omit-type.helper.js +26 -0
  74. package/dist/mjs/defines/mapped-types/omit-type.helper.js.map +1 -0
  75. package/dist/mjs/defines/mapped-types/partial-type.helper.js +23 -0
  76. package/dist/mjs/defines/mapped-types/partial-type.helper.js.map +1 -0
  77. package/dist/mjs/defines/mapped-types/pick-type.helper.js +26 -0
  78. package/dist/mjs/defines/mapped-types/pick-type.helper.js.map +1 -0
  79. package/dist/mjs/defines/mapped-types/type.interface.js +2 -0
  80. package/dist/mjs/defines/mapped-types/type.interface.js.map +1 -0
  81. package/dist/mjs/defines/mapped-types/types/remove-fields-with-type.type.js +2 -0
  82. package/dist/mjs/defines/mapped-types/types/remove-fields-with-type.type.js.map +1 -0
  83. package/dist/mjs/defines/module.js +9 -4
  84. package/dist/mjs/defines/module.js.map +1 -1
  85. package/dist/mjs/defines/properties.js +235 -0
  86. package/dist/mjs/defines/properties.js.map +1 -0
  87. package/dist/mjs/defines/types.js +10 -1
  88. package/dist/mjs/defines/types.js.map +1 -1
  89. package/dist/mjs/index.js +3 -0
  90. package/dist/mjs/index.js.map +1 -1
  91. package/dist/types/defines/decorators.d.ts +2 -4
  92. package/dist/types/defines/helpers/index.d.ts +1 -0
  93. package/dist/types/defines/helpers/is-nullable.d.ts +2 -0
  94. package/dist/types/defines/mapped-types/index.d.ts +5 -0
  95. package/dist/types/defines/mapped-types/intersection-type.helper.d.ts +10 -0
  96. package/dist/types/defines/mapped-types/mapped-type.interface.d.ts +4 -0
  97. package/dist/types/defines/mapped-types/omit-type.helper.d.ts +4 -0
  98. package/dist/types/defines/mapped-types/partial-type.helper.d.ts +4 -0
  99. package/dist/types/defines/mapped-types/pick-type.helper.d.ts +4 -0
  100. package/dist/types/defines/mapped-types/type.interface.d.ts +1 -0
  101. package/dist/types/defines/mapped-types/types/remove-fields-with-type.type.d.ts +5 -0
  102. package/dist/types/defines/module.d.ts +10 -7
  103. package/dist/types/defines/properties.d.ts +41 -0
  104. package/dist/types/defines/types.d.ts +24 -4
  105. package/dist/types/index.d.ts +3 -0
  106. package/package.json +6 -2
@@ -1,4 +1,6 @@
1
1
  import { AomCore } from "@aom-js/core";
2
+ import { defaultMetadataStorage } from "class-transformer/cjs/storage";
3
+ import { targetConstructorToSchema } from "class-validator-jsonschema";
2
4
  export class AomSchemas extends AomCore {
3
5
  constructor() {
4
6
  super(...arguments);
@@ -6,11 +8,14 @@ export class AomSchemas extends AomCore {
6
8
  }
7
9
  }
8
10
  export class Schemer {
9
- constructor(config) {
10
- this.render = config.render;
11
+ constructor(refPointerPrefix) {
12
+ this.refPointerPrefix = refPointerPrefix;
11
13
  }
12
- static config(config) {
13
- this.default = new this(config);
14
+ render(target) {
15
+ return targetConstructorToSchema(target, {
16
+ classTransformerMetadataStorage: defaultMetadataStorage,
17
+ refPointerPrefix: this.refPointerPrefix,
18
+ });
14
19
  }
15
20
  }
16
21
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/defines/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAIjD,MAAM,OAAO,UAAW,SAAQ,OAAO;IAAvC;;QAGE,gBAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IAC3D,CAAC;CAAA;AAED,MAAM,OAAO,OAAO;IAQlB,YAAY,MAAqB;QAE/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IASD,MAAM,CAAC,MAAM,CAAC,MAAqB;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF"}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/defines/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAUvE,MAAM,OAAO,UAAW,SAAQ,OAAO;IAAvC;;QAIE,gBAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IAI3D,CAAC;CAAA;AAED,MAAM,OAAO,OAAO;IAOlB,YAAY,gBAAwB;QAClC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAG3C,CAAC;IAGD,MAAM,CAAC,MAAmB;QACxB,OAAO,yBAAyB,CAAC,MAAM,EAAE;YACvC,+BAA+B,EAAE,sBAAsB;YACvD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC,CAAC;IACL,CAAC;CAYF"}
@@ -0,0 +1,235 @@
1
+ import { Allow, IsBoolean, IsDate, IsEnum, IsNumber, IsOptional, IsString, Max, MaxDate, MaxLength, Min, MinDate, MinLength, ValidateNested, } from "class-validator";
2
+ import { SchemaTypes } from "./types";
3
+ import { AomSchemas } from "./module";
4
+ import { DecoratorsQueueStore } from "@aom-js/core";
5
+ import { Transform, Type } from "class-transformer";
6
+ import { JSONSchema } from "class-validator-jsonschema";
7
+ import { IsNullable } from "./helpers";
8
+ function checkExistsSchemaParams($) {
9
+ if ($.schemaParams) {
10
+ throw new Error(`${$._.target.name}.${String($._.property)} already has defined schema params`);
11
+ }
12
+ }
13
+ const _String = (params) => {
14
+ return AomSchemas.propertyDecorator(($) => {
15
+ checkExistsSchemaParams($);
16
+ $.schemaName = SchemaTypes.STRING;
17
+ $.schemaParams = params;
18
+ const { originInstance, property } = $._;
19
+ const decorators = [
20
+ IsString({
21
+ each: params.isArray,
22
+ message: params.message,
23
+ groups: params.groups,
24
+ always: params.always,
25
+ }),
26
+ params.isOptional ? IsOptional() : undefined,
27
+ params.maxLength ? MaxLength(params.maxLength) : undefined,
28
+ params.minLength ? MinLength(params.minLength) : undefined,
29
+ params.nullable ? IsNullable() : undefined,
30
+ JSONSchema({
31
+ description: params.description,
32
+ deprecated: params.deprecated,
33
+ nullable: params.nullable,
34
+ default: params.default,
35
+ examples: params.examples,
36
+ }),
37
+ ...(params.decorators || []),
38
+ ].filter(Boolean);
39
+ Reflect.decorate(decorators, originInstance, property);
40
+ }, DecoratorsQueueStore.LAST);
41
+ };
42
+ const _Number = (params) => {
43
+ return AomSchemas.propertyDecorator(($) => {
44
+ checkExistsSchemaParams($);
45
+ $.schemaName = SchemaTypes.NUMBER;
46
+ $.schemaParams = params;
47
+ const { originInstance, property } = $._;
48
+ const decorators = [
49
+ IsNumber({}, {
50
+ each: params.isArray,
51
+ message: params.message,
52
+ groups: params.groups,
53
+ always: params.always,
54
+ }),
55
+ params.isOptional ? IsOptional() : undefined,
56
+ params.maxValue ? Max(params.maxValue) : undefined,
57
+ params.minValue ? Min(params.minValue) : undefined,
58
+ JSONSchema({
59
+ description: params.description,
60
+ deprecated: params.deprecated,
61
+ nullable: params.nullable,
62
+ default: params.default,
63
+ examples: params.examples,
64
+ }),
65
+ Transform(({ value }) => {
66
+ if (params.nullable && value === null)
67
+ return null;
68
+ return Number(value);
69
+ }),
70
+ ...(params.decorators || []),
71
+ ].filter(Boolean);
72
+ Reflect.decorate(decorators, originInstance, property);
73
+ }, DecoratorsQueueStore.LAST);
74
+ };
75
+ const _Boolean = (params) => {
76
+ return AomSchemas.propertyDecorator(($) => {
77
+ checkExistsSchemaParams($);
78
+ $.schemaName = SchemaTypes.BOOLEAN;
79
+ $.schemaParams = params;
80
+ const { originInstance, property } = $._;
81
+ const decorators = [
82
+ IsBoolean({
83
+ each: params.isArray,
84
+ message: params.message,
85
+ groups: params.groups,
86
+ always: params.always,
87
+ }),
88
+ params.isOptional ? IsOptional() : undefined,
89
+ params.nullable ? IsNullable() : undefined,
90
+ JSONSchema({
91
+ description: params.description,
92
+ deprecated: params.deprecated,
93
+ nullable: params.nullable,
94
+ default: params.default,
95
+ examples: params.examples,
96
+ }),
97
+ Transform(({ value }) => {
98
+ if (params.nullable && value === null)
99
+ return null;
100
+ const isTrue = value === "true";
101
+ const isFalse = value === "false";
102
+ if (isTrue)
103
+ return true;
104
+ if (isFalse)
105
+ return false;
106
+ return typeof value === "boolean" ? value : Boolean(+value);
107
+ }),
108
+ ...(params.decorators || []),
109
+ ].filter(Boolean);
110
+ Reflect.decorate(decorators, originInstance, property);
111
+ }, DecoratorsQueueStore.LAST);
112
+ };
113
+ const _Any = (params) => {
114
+ return AomSchemas.propertyDecorator(($) => {
115
+ checkExistsSchemaParams($);
116
+ $.schemaName = SchemaTypes.ANY;
117
+ $.schemaParams = params;
118
+ const { originInstance, property } = $._;
119
+ const decorators = [
120
+ Allow({
121
+ each: params.isArray,
122
+ message: params.message,
123
+ groups: params.groups,
124
+ always: params.always,
125
+ }),
126
+ params.isOptional ? IsOptional() : undefined,
127
+ params.nullable ? IsNullable() : undefined,
128
+ JSONSchema({
129
+ description: params.description,
130
+ deprecated: params.deprecated,
131
+ nullable: params.nullable,
132
+ default: params.default,
133
+ examples: params.examples,
134
+ }),
135
+ ...(params.decorators || []),
136
+ ].filter(Boolean);
137
+ Reflect.decorate(decorators, originInstance, property);
138
+ }, DecoratorsQueueStore.LAST);
139
+ };
140
+ const _Enum = (params) => {
141
+ return AomSchemas.propertyDecorator(($) => {
142
+ checkExistsSchemaParams($);
143
+ $.schemaName = SchemaTypes.ENUM;
144
+ $.schemaParams = params;
145
+ const { originInstance, property } = $._;
146
+ const decorators = [
147
+ IsEnum(params.value, {
148
+ each: params.isArray,
149
+ message: params.message,
150
+ groups: params.groups,
151
+ always: params.always,
152
+ }),
153
+ params.isOptional ? IsOptional() : undefined,
154
+ params.nullable ? IsNullable() : undefined,
155
+ JSONSchema({
156
+ description: params.description,
157
+ deprecated: params.deprecated,
158
+ nullable: params.nullable,
159
+ default: params.default,
160
+ examples: params.examples,
161
+ }),
162
+ ...(params.decorators || []),
163
+ ].filter(Boolean);
164
+ Reflect.decorate(decorators, originInstance, property);
165
+ }, DecoratorsQueueStore.LAST);
166
+ };
167
+ const _Date = (params) => {
168
+ return AomSchemas.propertyDecorator(($) => {
169
+ checkExistsSchemaParams($);
170
+ $.schemaName = SchemaTypes.DATE;
171
+ $.schemaParams = params;
172
+ const { target, property } = $._;
173
+ const decorators = [
174
+ IsDate({
175
+ each: params.isArray,
176
+ message: params.message,
177
+ groups: params.groups,
178
+ always: params.always,
179
+ }),
180
+ params.maxDate ? MaxDate(params.maxDate) : undefined,
181
+ params.minDate ? MinDate(params.minDate) : undefined,
182
+ params.isOptional ? IsOptional() : undefined,
183
+ params.nullable ? IsNullable() : undefined,
184
+ JSONSchema({
185
+ description: params.description,
186
+ deprecated: params.deprecated,
187
+ nullable: params.nullable,
188
+ default: params.default,
189
+ examples: params.examples,
190
+ }),
191
+ Transform(({ value }) => {
192
+ if (params.nullable && value === null)
193
+ return null;
194
+ return new Date(value);
195
+ }),
196
+ ].filter(Boolean);
197
+ Reflect.decorate(decorators, Object.getPrototypeOf(target), property);
198
+ }, DecoratorsQueueStore.LAST);
199
+ };
200
+ const _Type = (params) => {
201
+ return AomSchemas.propertyDecorator(($) => {
202
+ checkExistsSchemaParams($);
203
+ $.schemaParams = params;
204
+ $.schemaName = SchemaTypes.TYPE;
205
+ const { originInstance, property } = $._;
206
+ $._.root.connections.set(property, params.value);
207
+ const decorators = [
208
+ Type(params.value),
209
+ ValidateNested({
210
+ each: params.isArray,
211
+ message: params.message,
212
+ groups: params.groups,
213
+ always: params.always,
214
+ }),
215
+ params.isOptional ? IsOptional() : undefined,
216
+ params.nullable ? IsNullable() : undefined,
217
+ JSONSchema({
218
+ description: params.description,
219
+ deprecated: params.deprecated,
220
+ nullable: params.nullable,
221
+ }),
222
+ ].filter(Boolean);
223
+ Reflect.decorate(decorators, originInstance, property);
224
+ }, DecoratorsQueueStore.LAST);
225
+ };
226
+ export const PropertySchema = {
227
+ [SchemaTypes.STRING]: _String,
228
+ [SchemaTypes.NUMBER]: _Number,
229
+ [SchemaTypes.DATE]: _Date,
230
+ [SchemaTypes.BOOLEAN]: _Boolean,
231
+ [SchemaTypes.ENUM]: _Enum,
232
+ [SchemaTypes.ANY]: _Any,
233
+ [SchemaTypes.TYPE]: _Type,
234
+ };
235
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/defines/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,GAAG,EACH,OAAO,EACP,SAAS,EACT,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAkD,WAAW,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,W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AM,CAAC,EAAE,OAAO;IAC7B,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK;IACzB,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,QAAQ;IAC/B,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK;IACzB,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI;IACvB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK;CAC1B,CAAC"}
@@ -1,2 +1,11 @@
1
- export {};
1
+ export var SchemaTypes;
2
+ (function (SchemaTypes) {
3
+ SchemaTypes["STRING"] = "String";
4
+ SchemaTypes["DATE"] = "Date";
5
+ SchemaTypes["NUMBER"] = "Number";
6
+ SchemaTypes["BOOLEAN"] = "Boolean";
7
+ SchemaTypes["ENUM"] = "Enum";
8
+ SchemaTypes["ANY"] = "Any";
9
+ SchemaTypes["TYPE"] = "Type";
10
+ })(SchemaTypes || (SchemaTypes = {}));
2
11
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/defines/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/defines/types.ts"],"names":[],"mappings":"AAoCA,MAAM,CAAN,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,4BAAa,CAAA;IACb,0BAAW,CAAA;IACX,4BAAa,CAAA;AACf,CAAC,EARW,WAAW,KAAX,WAAW,QAQtB"}
package/dist/mjs/index.js CHANGED
@@ -1,4 +1,7 @@
1
+ import "reflect-metadata";
1
2
  export * from "./defines/decorators";
2
3
  export * from "./defines/types";
3
4
  export * from "./defines/module";
5
+ export { PropertySchema } from "./defines/properties";
6
+ export * from "./defines/mapped-types";
4
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,cAAc,wBAAwB,CAAC"}
@@ -1,4 +1,2 @@
1
- import { Schemer } from "./module";
2
- import { ConnectionSchema } from "./types";
3
- export declare function ComponentSchema(schemer?: Schemer): ClassDecorator;
4
- export declare function ComponentConnect(schema: ConnectionSchema): PropertyDecorator;
1
+ import { BaseDescriptionsProperties } from "./types";
2
+ export declare function ComponentSchema(params?: BaseDescriptionsProperties): ClassDecorator;
@@ -0,0 +1 @@
1
+ export * from "./is-nullable";
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from "class-validator";
2
+ export declare function IsNullable(validationOptions?: ValidationOptions): PropertyDecorator;
@@ -0,0 +1,5 @@
1
+ export * from "./mapped-type.interface";
2
+ export * from "./partial-type.helper";
3
+ export * from "./pick-type.helper";
4
+ export * from "./omit-type.helper";
5
+ export * from './intersection-type.helper';
@@ -0,0 +1,10 @@
1
+ import { Type } from "./type.interface";
2
+ import { MappedType } from "./mapped-type.interface";
3
+ import { RemoveFieldsWithType } from "./types/remove-fields-with-type.type";
4
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
5
+ type ClassRefsToConstructors<T extends Type[]> = {
6
+ [U in keyof T]: T[U] extends Type<infer V> ? V : never;
7
+ };
8
+ type Intersection<T extends Type[]> = MappedType<RemoveFieldsWithType<UnionToIntersection<ClassRefsToConstructors<T>[number]>, Function>>;
9
+ export declare function IntersectionType<T extends Type[]>(...classRefs: T): Intersection<T>;
10
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Type } from "./type.interface";
2
+ export interface MappedType<T> extends Type<T> {
3
+ new (): T;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Type } from "./type.interface";
2
+ import { MappedType } from "./mapped-type.interface";
3
+ import { RemoveFieldsWithType } from "./types/remove-fields-with-type.type";
4
+ export declare function OmitType<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): MappedType<RemoveFieldsWithType<Omit<T, (typeof keys)[number]>, Function>>;
@@ -0,0 +1,4 @@
1
+ import { Type } from "./type.interface";
2
+ import { MappedType } from "./mapped-type.interface";
3
+ import { RemoveFieldsWithType } from "./types/remove-fields-with-type.type";
4
+ export declare function PartialType<T>(classRef: Type<T>): MappedType<RemoveFieldsWithType<Partial<T>, Function>>;
@@ -0,0 +1,4 @@
1
+ import { Type } from "./type.interface";
2
+ import { MappedType } from "./mapped-type.interface";
3
+ import { RemoveFieldsWithType } from "./types/remove-fields-with-type.type";
4
+ export declare function PickType<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): MappedType<RemoveFieldsWithType<Pick<T, (typeof keys)[number]>, Function>>;
@@ -0,0 +1 @@
1
+ export type Type<T = any> = new (...args: any[]) => T;
@@ -0,0 +1,5 @@
1
+ type KeysWithType<T, Type> = {
2
+ [K in keyof T]: T[K] extends Type ? K : never;
3
+ }[keyof T];
4
+ export type RemoveFieldsWithType<T, Type> = Exclude<T, KeysWithType<T, Type>>;
5
+ export {};
@@ -1,12 +1,15 @@
1
- import { AomCore, Property } from "@aom-js/core";
2
- import { ConnectionSchema, SchemerConfig, RenderHandler } from "./types";
1
+ import { AomCore, Constructor, Property } from "@aom-js/core";
2
+ import { targetConstructorToSchema } from "class-validator-jsonschema";
3
+ import { ConnectionSchema, CommonDescriptionsProperties, SchemaTypes } from "./types";
3
4
  export declare class AomSchemas extends AomCore {
4
5
  schemer: Schemer;
6
+ isComponentSchema: boolean;
5
7
  connections: Map<Property, ConnectionSchema>;
8
+ schemaName?: SchemaTypes;
9
+ schemaParams?: CommonDescriptionsProperties;
6
10
  }
7
- export declare class Schemer implements SchemerConfig {
8
- render: RenderHandler;
9
- constructor(config: SchemerConfig);
10
- static default: Schemer;
11
- static config(config: SchemerConfig): void;
11
+ export declare class Schemer {
12
+ private refPointerPrefix;
13
+ constructor(refPointerPrefix: string);
14
+ render(target: Constructor): ReturnType<typeof targetConstructorToSchema>;
12
15
  }
@@ -0,0 +1,41 @@
1
+ import { CommonDescriptionsProperties, ConnectionSchema } from "./types";
2
+ declare interface StringDescriptionsProperties extends CommonDescriptionsProperties {
3
+ minLength?: number;
4
+ maxLength?: number;
5
+ pattern?: string;
6
+ default?: string;
7
+ }
8
+ declare interface NumberDescriptionsProperties extends CommonDescriptionsProperties {
9
+ minValue?: number;
10
+ maxValue?: number;
11
+ default?: number;
12
+ }
13
+ declare interface BooleanDescriptionsProperties extends CommonDescriptionsProperties {
14
+ default?: boolean;
15
+ }
16
+ declare interface AnyDescriptionsProperties extends CommonDescriptionsProperties {
17
+ default?: any;
18
+ }
19
+ type EnumLike = Record<string, string | number>;
20
+ declare interface EnumDescriptionsProperties<T extends EnumLike> extends CommonDescriptionsProperties {
21
+ value: T;
22
+ default?: T[keyof T];
23
+ }
24
+ declare interface DateDescriptionsProperties extends CommonDescriptionsProperties {
25
+ minDate?: Date;
26
+ maxDate?: Date;
27
+ default?: Date;
28
+ }
29
+ declare interface TypeDescriptionsProperties extends CommonDescriptionsProperties {
30
+ value: ConnectionSchema;
31
+ }
32
+ export declare const PropertySchema: {
33
+ String: (params: StringDescriptionsProperties) => PropertyDecorator;
34
+ Number: (params: NumberDescriptionsProperties) => PropertyDecorator;
35
+ Date: (params: DateDescriptionsProperties) => PropertyDecorator;
36
+ Boolean: (params: BooleanDescriptionsProperties) => PropertyDecorator;
37
+ Enum: <T extends EnumLike>(params: EnumDescriptionsProperties<T>) => PropertyDecorator;
38
+ Any: (params: AnyDescriptionsProperties) => PropertyDecorator;
39
+ Type: (params: TypeDescriptionsProperties) => PropertyDecorator;
40
+ };
41
+ export {};
@@ -1,6 +1,26 @@
1
1
  import { ClassConstructor } from "@aom-js/core";
2
- export declare type ConnectionSchema = (() => ClassConstructor) | ClassConstructor;
3
- export declare type RenderHandler = (target: ClassConstructor) => any;
4
- export declare interface SchemerConfig {
5
- render: RenderHandler;
2
+ import { ValidationArguments } from "class-validator";
3
+ export declare type ConnectionSchema = () => ClassConstructor;
4
+ export declare interface BaseDescriptionsProperties {
5
+ description?: string;
6
+ deprecated?: boolean;
7
+ }
8
+ export declare interface CommonDescriptionsProperties extends BaseDescriptionsProperties {
9
+ nullable?: boolean;
10
+ examples?: any[];
11
+ isOptional?: boolean;
12
+ isArray?: boolean;
13
+ message?: string | ((validationArguments: ValidationArguments) => string);
14
+ groups?: string[];
15
+ always?: boolean;
16
+ decorators?: PropertyDecorator[];
17
+ }
18
+ export declare enum SchemaTypes {
19
+ STRING = "String",
20
+ DATE = "Date",
21
+ NUMBER = "Number",
22
+ BOOLEAN = "Boolean",
23
+ ENUM = "Enum",
24
+ ANY = "Any",
25
+ TYPE = "Type"
6
26
  }
@@ -1,3 +1,6 @@
1
+ import "reflect-metadata";
1
2
  export * from "./defines/decorators";
2
3
  export * from "./defines/types";
3
4
  export * from "./defines/module";
5
+ export { PropertySchema } from "./defines/properties";
6
+ export * from "./defines/mapped-types";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.1",
2
+ "version": "0.0.3",
3
3
  "name": "@aom-js/schemer",
4
4
  "description": "`@aom` meta-framework schemer code",
5
5
  "homepage": "https://github.com/aom-js/main#readme",
@@ -14,7 +14,11 @@
14
14
  "license": "ISC",
15
15
  "author": "Grigory B. Kholstinnikov (scarych)",
16
16
  "dependencies": {
17
- "@aom-js/core": "*"
17
+ "@aom-js/core": "^0.0.2",
18
+ "class-transformer": "^0.5.1",
19
+ "class-validator": "^0.14.2",
20
+ "class-validator-jsonschema": "^5.1.0",
21
+ "reflect-metadata": "^0.2.2"
18
22
  },
19
23
  "devDependencies": {
20
24
  "@types/node": "^22.14.0",