@tstdl/base 0.78.0 → 0.78.2

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 (110) hide show
  1. package/api/server/gateway.js.map +1 -1
  2. package/api/types.d.ts +2 -2
  3. package/notification/api.d.ts +18 -0
  4. package/notification/api.js +35 -0
  5. package/notification/api.js.map +1 -0
  6. package/notification/model.d.ts +18 -0
  7. package/notification/model.js +36 -0
  8. package/notification/model.js.map +1 -0
  9. package/notification/module.d.ts +9 -0
  10. package/notification/module.js +15 -0
  11. package/notification/module.js.map +1 -0
  12. package/package.json +2 -2
  13. package/schema/coercers/index.d.ts +0 -1
  14. package/schema/coercers/index.js +0 -1
  15. package/schema/coercers/index.js.map +1 -1
  16. package/schema/constraints/maximum-length.js +1 -1
  17. package/schema/constraints/maximum-length.js.map +1 -1
  18. package/schema/constraints/minimum-length.js +1 -1
  19. package/schema/constraints/minimum-length.js.map +1 -1
  20. package/schema/schema.d.ts +10 -10
  21. package/schema/schema.js +16 -19
  22. package/schema/schema.js.map +1 -1
  23. package/schema/schemas/any.d.ts +4 -3
  24. package/schema/schemas/any.js +4 -4
  25. package/schema/schemas/any.js.map +1 -1
  26. package/schema/schemas/array.d.ts +5 -5
  27. package/schema/schemas/array.js +3 -2
  28. package/schema/schemas/array.js.map +1 -1
  29. package/schema/schemas/assign.d.ts +5 -5
  30. package/schema/schemas/boolean.d.ts +2 -2
  31. package/schema/schemas/boolean.js +1 -3
  32. package/schema/schemas/boolean.js.map +1 -1
  33. package/schema/schemas/constraint.d.ts +1 -1
  34. package/schema/schemas/constraint.js.map +1 -1
  35. package/schema/schemas/date.d.ts +2 -2
  36. package/schema/schemas/date.js +3 -2
  37. package/schema/schemas/date.js.map +1 -1
  38. package/schema/schemas/defaulted.d.ts +1 -1
  39. package/schema/schemas/defaulted.js +2 -4
  40. package/schema/schemas/defaulted.js.map +1 -1
  41. package/schema/schemas/enumeration.d.ts +2 -2
  42. package/schema/schemas/enumeration.js +7 -4
  43. package/schema/schemas/enumeration.js.map +1 -1
  44. package/schema/schemas/instance.d.ts +3 -2
  45. package/schema/schemas/instance.js +2 -2
  46. package/schema/schemas/instance.js.map +1 -1
  47. package/schema/schemas/literal.d.ts +3 -2
  48. package/schema/schemas/literal.js +7 -3
  49. package/schema/schemas/literal.js.map +1 -1
  50. package/schema/schemas/nullable.d.ts +3 -2
  51. package/schema/schemas/nullable.js +2 -2
  52. package/schema/schemas/nullable.js.map +1 -1
  53. package/schema/schemas/number.d.ts +2 -2
  54. package/schema/schemas/number.js +7 -6
  55. package/schema/schemas/number.js.map +1 -1
  56. package/schema/schemas/object.d.ts +1 -1
  57. package/schema/schemas/object.js.map +1 -1
  58. package/schema/schemas/one-or-many.d.ts +4 -8
  59. package/schema/schemas/one-or-many.js +5 -2
  60. package/schema/schemas/one-or-many.js.map +1 -1
  61. package/schema/schemas/optional.d.ts +3 -2
  62. package/schema/schemas/optional.js +2 -2
  63. package/schema/schemas/optional.js.map +1 -1
  64. package/schema/schemas/readable-stream.d.ts +4 -2
  65. package/schema/schemas/readable-stream.js +2 -2
  66. package/schema/schemas/readable-stream.js.map +1 -1
  67. package/schema/schemas/record.d.ts +1 -1
  68. package/schema/schemas/record.js.map +1 -1
  69. package/schema/schemas/regexp.d.ts +2 -2
  70. package/schema/schemas/regexp.js +2 -4
  71. package/schema/schemas/regexp.js.map +1 -1
  72. package/schema/schemas/string.d.ts +2 -2
  73. package/schema/schemas/string.js +8 -7
  74. package/schema/schemas/string.js.map +1 -1
  75. package/schema/schemas/transform.d.ts +3 -3
  76. package/schema/schemas/transform.js +2 -2
  77. package/schema/schemas/transform.js.map +1 -1
  78. package/schema/schemas/uint8-array.d.ts +4 -2
  79. package/schema/schemas/uint8-array.js +11 -5
  80. package/schema/schemas/uint8-array.js.map +1 -1
  81. package/schema/schemas/union.d.ts +4 -2
  82. package/schema/schemas/union.js +5 -3
  83. package/schema/schemas/union.js.map +1 -1
  84. package/schema/schemas/unknown.d.ts +4 -3
  85. package/schema/schemas/unknown.js +6 -6
  86. package/schema/schemas/unknown.js.map +1 -1
  87. package/schema/transformers/generic.d.ts +8 -9
  88. package/schema/transformers/generic.js +4 -10
  89. package/schema/transformers/generic.js.map +1 -1
  90. package/schema/transformers/lowercase.d.ts +1 -2
  91. package/schema/transformers/lowercase.js +1 -2
  92. package/schema/transformers/lowercase.js.map +1 -1
  93. package/schema/transformers/trim.d.ts +1 -2
  94. package/schema/transformers/trim.js +1 -2
  95. package/schema/transformers/trim.js.map +1 -1
  96. package/schema/transformers/uppercase.d.ts +1 -2
  97. package/schema/transformers/uppercase.js +1 -2
  98. package/schema/transformers/uppercase.js.map +1 -1
  99. package/schema/types.d.ts +41 -44
  100. package/schema/types.js +11 -2
  101. package/schema/types.js.map +1 -1
  102. package/schema/utils/schema.d.ts +5 -5
  103. package/schema/utils/schema.js +2 -2
  104. package/schema/utils/schema.js.map +1 -1
  105. package/schema/utils/value-type.d.ts +1 -0
  106. package/schema/utils/value-type.js +10 -1
  107. package/schema/utils/value-type.js.map +1 -1
  108. package/schema/coercers/default-value.coercer.d.ts +0 -9
  109. package/schema/coercers/default-value.coercer.js +0 -16
  110. package/schema/coercers/default-value.coercer.js.map +0 -1
@@ -2,12 +2,13 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Date = exports.date = void 0;
5
+ const array_1 = require("../../utils/array/array");
5
6
  const type_guards_1 = require("../../utils/type-guards");
6
7
  const constraints_1 = require("../constraints");
7
8
  const decorators_1 = require("../decorators");
8
9
  const types_1 = require("../types");
9
10
  function date(options = {}) {
10
- const constraints = [];
11
+ const constraints = (0, array_1.toArray)(options.valueConstraints ?? []);
11
12
  if ((0, type_guards_1.isDefined)(options.minimum)) {
12
13
  constraints.push(new constraints_1.MinimumDateConstraint(options.minimum));
13
14
  }
@@ -15,7 +16,7 @@ function date(options = {}) {
15
16
  constraints.push(new constraints_1.MaximumDateConstraint(options.maximum));
16
17
  }
17
18
  return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Date), {
18
- coerce: options.coerce,
19
+ ...options,
19
20
  valueConstraints: constraints
20
21
  });
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../source/schema/schemas/date.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,gDAA8E;AAC9E,8CAAwE;AAExE,oCAAmD;AAOnD,SAAgB,IAAI,CAAC,UAAuB,EAAE;IAC5C,MAAM,WAAW,GAA4B,EAAE,CAAC;IAEhD,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,mCAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9D;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,mCAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9D;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC9C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAfD,oBAeC;AAED,SAAgB,IAAI,CAAC,OAAqB;IACxC,OAAO,IAAA,oDAAuC,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC;AAFD,oBAEC"}
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../source/schema/schemas/date.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,mDAA8C;AAC9C,yDAAgD;AAChD,gDAA8E;AAC9E,8CAAwE;AAExE,oCAAmD;AAOnD,SAAgB,IAAI,CAAC,UAAuB,EAAE;IAC5C,MAAM,WAAW,GAA4B,IAAA,eAAO,EAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAErF,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,mCAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9D;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,mCAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9D;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC9C,GAAG,OAAO;QACV,gBAAgB,EAAE,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAfD,oBAeC;AAED,SAAgB,IAAI,CAAC,OAAqB;IACxC,OAAO,IAAA,oDAAuC,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC;AAFD,oBAEC"}
@@ -1,4 +1,4 @@
1
1
  import type { OneOrMany } from "../../types";
2
2
  import type { SchemaTestable } from '../schema';
3
3
  import type { ValueSchema } from '../types';
4
- export declare function defaulted<T, O, Default>(type: OneOrMany<SchemaTestable<T, O>>, defaultValue: Default): ValueSchema<T, O | Default>;
4
+ export declare function defaulted<T, Default>(type: OneOrMany<SchemaTestable<T>>, defaultValue: Default): ValueSchema<NonNullable<T> | Default>;
@@ -2,12 +2,10 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.defaulted = void 0;
5
- const coercers_1 = require("../coercers");
6
5
  const types_1 = require("../types");
6
+ const transform_1 = require("./transform");
7
7
  function defaulted(type, defaultValue) {
8
- return (0, types_1.valueSchema)(type, {
9
- coercers: new coercers_1.DefaultValueCoercer(defaultValue)
10
- });
8
+ return (0, transform_1.transform)((0, types_1.valueSchema)(type, { optional: true, nullable: true }), (value) => value ?? defaultValue); // eslint-disable-line @typescript-eslint/no-unnecessary-condition
11
9
  }
12
10
  exports.defaulted = defaulted;
13
11
  //# sourceMappingURL=defaulted.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaulted.js","sourceRoot":"","sources":["../../../source/schema/schemas/defaulted.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,0CAAkD;AAGlD,oCAAuC;AAEvC,SAAgB,SAAS,CAAgB,IAAqC,EAAE,YAAqB;IACnG,OAAO,IAAA,mBAAW,EAAC,IAAI,EAAE;QACvB,QAAQ,EAAE,IAAI,8BAAmB,CAAC,YAAY,CAAC;KAChD,CAAC,CAAC;AACL,CAAC;AAJD,8BAIC"}
1
+ {"version":3,"file":"defaulted.js","sourceRoot":"","sources":["../../../source/schema/schemas/defaulted.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAuC;AACvC,2CAAwC;AAExC,SAAgB,SAAS,CAAa,IAAkC,EAAE,YAAqB;IAC7F,OAAO,IAAA,qBAAS,EAAC,IAAA,mBAAW,EAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,KAAQ,EAAE,EAAE,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,CAAC,kEAAkE;AAClL,CAAC;AAFD,8BAEC"}
@@ -1,6 +1,6 @@
1
1
  import type { Decorator } from "../../reflection";
2
2
  import type { Enumeration as EnumerationType, EnumerationValue } from "../../types";
3
- import type { Coercible, ValueSchema } from '../types';
4
- export declare type EnumerationOptions = Coercible;
3
+ import type { ValueSchema, ValueSchemaOptions } from '../types';
4
+ export declare type EnumerationOptions = ValueSchemaOptions;
5
5
  export declare function enumeration<T extends EnumerationType>(enumerationValue: T, options?: EnumerationOptions): ValueSchema<EnumerationValue<T>>;
6
6
  export declare function Enumeration(enumerationValue: EnumerationType, options?: EnumerationOptions): Decorator<'property' | 'accessor'>;
@@ -2,18 +2,21 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Enumeration = exports.enumeration = void 0;
5
+ const array_1 = require("../../utils/array/array");
5
6
  const constraints_1 = require("../constraints");
6
7
  const decorators_1 = require("../decorators");
7
8
  const types_1 = require("../types");
8
- function enumeration(enumerationValue, options = {}) {
9
+ function enumeration(enumerationValue, options) {
10
+ const valueConstraints = (0, array_1.toArray)(options?.valueConstraints ?? []);
9
11
  const enumerationConstraint = new constraints_1.EnumerationConstraint(enumerationValue);
12
+ valueConstraints.push(enumerationConstraint);
10
13
  return (0, types_1.valueSchema)(enumerationConstraint.suitableTypes, {
11
- coerce: options.coerce,
12
- valueConstraints: enumerationConstraint
14
+ ...options,
15
+ valueConstraints
13
16
  });
14
17
  }
15
18
  exports.enumeration = enumeration;
16
- function Enumeration(enumerationValue, options = {}) {
19
+ function Enumeration(enumerationValue, options) {
17
20
  return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(enumeration(enumerationValue, options));
18
21
  }
19
22
  exports.Enumeration = Enumeration;
@@ -1 +1 @@
1
- {"version":3,"file":"enumeration.js","sourceRoot":"","sources":["../../../source/schema/schemas/enumeration.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,gDAAuD;AACvD,8CAAwE;AAExE,oCAAuC;AAIvC,SAAgB,WAAW,CAA4B,gBAAmB,EAAE,UAA8B,EAAE;IAC1G,MAAM,qBAAqB,GAAG,IAAI,mCAAqB,CAAC,gBAAgB,CAAC,CAAC;IAE1E,OAAO,IAAA,mBAAW,EAAC,qBAAqB,CAAC,aAAa,EAAE;QACtD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,qBAAqB;KACxC,CAAC,CAAC;AACL,CAAC;AAPD,kCAOC;AAED,SAAgB,WAAW,CAAC,gBAAiC,EAAE,UAA8B,EAAE;IAC7F,OAAO,IAAA,oDAAuC,EAAC,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC;AACzF,CAAC;AAFD,kCAEC"}
1
+ {"version":3,"file":"enumeration.js","sourceRoot":"","sources":["../../../source/schema/schemas/enumeration.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,mDAA8C;AAC9C,gDAAuD;AACvD,8CAAwE;AAExE,oCAAuC;AAIvC,SAAgB,WAAW,CAA4B,gBAAmB,EAAE,OAA4B;IACtG,MAAM,gBAAgB,GAA4B,IAAA,eAAO,EAAC,OAAO,EAAE,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAE3F,MAAM,qBAAqB,GAAG,IAAI,mCAAqB,CAAC,gBAAgB,CAAC,CAAC;IAC1E,gBAAgB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAE7C,OAAO,IAAA,mBAAW,EAAC,qBAAqB,CAAC,aAAa,EAAE;QACtD,GAAG,OAAO;QACV,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AAVD,kCAUC;AAED,SAAgB,WAAW,CAAC,gBAAiC,EAAE,OAA4B;IACzF,OAAO,IAAA,oDAAuC,EAAC,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC;AACzF,CAAC;AAFD,kCAEC"}
@@ -1,2 +1,3 @@
1
- import type { NormalizeValueType, TypeSchema, ValueType } from '../types';
2
- export declare function instance<T>(type: ValueType<T>): TypeSchema<NormalizeValueType<T>>;
1
+ import type { ValueSchema, ValueSchemaOptions, ValueType } from '../types';
2
+ export declare type InstanceOptions = ValueSchemaOptions;
3
+ export declare function instance<T>(type: ValueType<T>, options?: InstanceOptions): ValueSchema<T>;
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.instance = void 0;
5
5
  const types_1 = require("../types");
6
- function instance(type) {
7
- return (0, types_1.typeSchema)(type);
6
+ function instance(type, options) {
7
+ return (0, types_1.valueSchema)(type, options);
8
8
  }
9
9
  exports.instance = instance;
10
10
  //# sourceMappingURL=instance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../source/schema/schemas/instance.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;AAGjD,oCAAsC;AAEtC,SAAgB,QAAQ,CAAI,IAAkB;IAC5C,OAAO,IAAA,kBAAU,EAAI,IAAI,CAAC,CAAC;AAC7B,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../source/schema/schemas/instance.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;AAGjD,oCAAuC;AAIvC,SAAgB,QAAQ,CAAI,IAAkB,EAAE,OAAyB;IACvE,OAAO,IAAA,mBAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC;AAFD,4BAEC"}
@@ -1,4 +1,5 @@
1
1
  import type { Decorator } from "../../reflection";
2
- import type { ValueSchema } from '../types';
3
- export declare function literal<T>(value: T): ValueSchema<T>;
2
+ import type { ValueSchema, ValueSchemaOptions } from '../types';
3
+ export declare type LiteralOptions = ValueSchemaOptions;
4
+ export declare function literal<T>(value: T, options?: LiteralOptions): ValueSchema<T>;
4
5
  export declare function Literal(value: any): Decorator<'property' | 'accessor'>;
@@ -2,13 +2,17 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Literal = exports.literal = void 0;
5
+ const array_1 = require("../../utils/array/array");
5
6
  const constraints_1 = require("../constraints");
6
7
  const decorators_1 = require("../decorators");
7
8
  const types_1 = require("../types");
8
9
  const utils_1 = require("../utils");
9
- function literal(value) {
10
- return (0, types_1.valueSchema)((0, types_1.typeSchema)((0, utils_1.getValueType)(value)), {
11
- valueConstraints: new constraints_1.LiteralConstraint(value)
10
+ function literal(value, options) {
11
+ const valueConstraints = (0, array_1.toArray)(options?.valueConstraints ?? []);
12
+ valueConstraints.push(new constraints_1.LiteralConstraint(value));
13
+ return (0, types_1.valueSchema)((0, utils_1.getValueType)(value), {
14
+ ...options,
15
+ valueConstraints
12
16
  });
13
17
  }
14
18
  exports.literal = literal;
@@ -1 +1 @@
1
- {"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../source/schema/schemas/literal.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,gDAAmD;AACnD,8CAAwE;AAExE,oCAAmD;AACnD,oCAAwC;AAExC,SAAgB,OAAO,CAAI,KAAQ;IACjC,OAAO,IAAA,mBAAW,EAAM,IAAA,kBAAU,EAAC,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC,EAAE;QACvD,gBAAgB,EAAE,IAAI,+BAAiB,CAAC,KAAK,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC;AAJD,0BAIC;AAED,SAAgB,OAAO,CAAC,KAAU;IAChC,OAAO,IAAA,oDAAuC,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC;AAFD,0BAEC"}
1
+ {"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../source/schema/schemas/literal.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,mDAA8C;AAC9C,gDAAmD;AACnD,8CAAwE;AAExE,oCAAuC;AACvC,oCAAwC;AAIxC,SAAgB,OAAO,CAAI,KAAQ,EAAE,OAAwB;IAC3D,MAAM,gBAAgB,GAA4B,IAAA,eAAO,EAAC,OAAO,EAAE,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAC3F,gBAAgB,CAAC,IAAI,CAAC,IAAI,+BAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpD,OAAO,IAAA,mBAAW,EAAC,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE;QACtC,GAAG,OAAO;QACV,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AARD,0BAQC;AAED,SAAgB,OAAO,CAAC,KAAU;IAChC,OAAO,IAAA,oDAAuC,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC;AAFD,0BAEC"}
@@ -1,3 +1,4 @@
1
1
  import type { SchemaTestable } from '../schema';
2
- import type { ValueSchema } from '../types';
3
- export declare function nullable<T, O>(schema: SchemaTestable<T, O>): ValueSchema<T | null, O | null>;
2
+ import type { NormalizeValueType, ValueSchema, ValueSchemaOptions } from '../types';
3
+ export declare type NullableOptions = ValueSchemaOptions;
4
+ export declare function nullable<T>(schema: SchemaTestable<T>, options?: NullableOptions): ValueSchema<NormalizeValueType<T> | null>;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nullable = void 0;
4
4
  const types_1 = require("../types");
5
- function nullable(schema) {
6
- return (0, types_1.valueSchema)(schema, { nullable: true });
5
+ function nullable(schema, options) {
6
+ return (0, types_1.valueSchema)(schema, { ...options, nullable: true });
7
7
  }
8
8
  exports.nullable = nullable;
9
9
  //# sourceMappingURL=nullable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../../source/schema/schemas/nullable.ts"],"names":[],"mappings":";;;AAEA,oCAAuC;AAEvC,SAAgB,QAAQ,CAAO,MAA4B;IACzD,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAoC,CAAC;AACpF,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../../source/schema/schemas/nullable.ts"],"names":[],"mappings":";;;AAEA,oCAAuC;AAIvC,SAAgB,QAAQ,CAAI,MAAyB,EAAE,OAAyB;IAC9E,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAA8C,CAAC;AAC1G,CAAC;AAFD,4BAEC"}
@@ -1,6 +1,6 @@
1
1
  import type { Decorator } from "../../reflection";
2
- import type { Coercible, ValueSchema } from '../types';
3
- export declare type NumberOptions = Coercible & {
2
+ import type { ValueSchema, ValueSchemaOptions } from '../types';
3
+ export declare type NumberOptions = ValueSchemaOptions & {
4
4
  minimum?: number;
5
5
  maximum?: number;
6
6
  integer?: boolean;
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Number = exports.number = void 0;
5
+ const array_1 = require("../../utils/array/array");
5
6
  const type_guards_1 = require("../../utils/type-guards");
6
7
  const integer_1 = require("../constraints/integer");
7
8
  const maximum_1 = require("../constraints/maximum");
@@ -9,19 +10,19 @@ const minimum_1 = require("../constraints/minimum");
9
10
  const decorators_1 = require("../decorators");
10
11
  const types_1 = require("../types");
11
12
  function number(options = {}) {
12
- const constraints = [];
13
+ const valueConstraints = (0, array_1.toArray)(options.valueConstraints ?? []);
13
14
  if ((0, type_guards_1.isDefined)(options.minimum)) {
14
- constraints.push(new minimum_1.MinimumConstraint(options.minimum));
15
+ valueConstraints.push(new minimum_1.MinimumConstraint(options.minimum));
15
16
  }
16
17
  if ((0, type_guards_1.isDefined)(options.maximum)) {
17
- constraints.push(new maximum_1.MaximumConstraint(options.maximum));
18
+ valueConstraints.push(new maximum_1.MaximumConstraint(options.maximum));
18
19
  }
19
20
  if (options.integer == true) {
20
- constraints.push(integer_1.integerConstraint);
21
+ valueConstraints.push(integer_1.integerConstraint);
21
22
  }
22
23
  return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Number), {
23
- coerce: options.coerce,
24
- valueConstraints: constraints
24
+ ...options,
25
+ valueConstraints
25
26
  });
26
27
  }
27
28
  exports.number = number;
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,8CAAwE;AAExE,oCAAmD;AAQnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,WAA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C;KAC/D;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,gBAAgB,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IAED,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE;QAC3B,gBAAgB,CAAC,IAAI,CAAC,2BAAiB,CAAC,CAAC;KAC1C;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,GAAG,OAAO;QACV,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AAnBD,wBAmBC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
@@ -2,4 +2,4 @@ import type { Record, SimplifiedOptionalize, TypedOmit } from "../../types";
2
2
  import type { ObjectSchema, ObjectSchemaProperties } from '../types';
3
3
  export declare type ObjectOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties'>;
4
4
  export declare function explicitObject<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<T>;
5
- export declare function object<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<SimplifiedOptionalize<T>, SimplifiedOptionalize<T>>;
5
+ export declare function object<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<SimplifiedOptionalize<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/schema/schemas/object.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,cAAc,CAAmB,UAAqC,EAAE,OAA0B;IAChH,OAAO,MAAM,CAAC,UAAU,EAAE,OAAO,CAA2B,CAAC;AAC/D,CAAC;AAFD,wCAEC;AAED,SAAgB,MAAM,CAAmB,UAAqC,EAAE,OAA0B;IACxG,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU;QACV,GAAG,OAAO;KACX,CAAgF,CAAC;AACpF,CAAC;AALD,wBAKC"}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/schema/schemas/object.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,cAAc,CAAmB,UAAqC,EAAE,OAA0B;IAChH,OAAO,MAAM,CAAC,UAAU,EAAE,OAAO,CAA2B,CAAC;AAC/D,CAAC;AAFD,wCAEC;AAED,SAAgB,MAAM,CAAmB,UAAqC,EAAE,OAA0B;IACxG,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU;QACV,GAAG,OAAO;KACX,CAAsD,CAAC;AAC1D,CAAC;AALD,wBAKC"}
@@ -1,10 +1,6 @@
1
1
  import type { OneOrMany } from "../../types";
2
2
  import type { SchemaTestable } from '../schema';
3
- import type { ValueSchema } from '../types';
4
- export declare type OneOrManyOptions = {
5
- /** minimum array length */
6
- minimumLength?: number;
7
- /** maximum array length */
8
- maximumLength?: number;
9
- };
10
- export declare function oneOrMany<T, O = T>(innerValues: OneOrMany<SchemaTestable<T, O>>, options?: OneOrManyOptions): ValueSchema<T, O | O[]>;
3
+ import type { ValueSchema, ValueSchemaOptions } from '../types';
4
+ import { ArrayOptions } from './array';
5
+ export declare type OneOrManyOptions = ValueSchemaOptions & Pick<ArrayOptions, 'minimumLength' | 'maximumLength'>;
6
+ export declare function oneOrMany<T>(innerValues: OneOrMany<SchemaTestable<T>>, options?: OneOrManyOptions): ValueSchema<T | T[]>;
@@ -5,8 +5,11 @@ exports.oneOrMany = void 0;
5
5
  const array_1 = require("../../utils/array");
6
6
  const array_2 = require("./array");
7
7
  const union_1 = require("./union");
8
- function oneOrMany(innerValues, options = {}) {
9
- return (0, union_1.union)((0, array_2.array)(innerValues, options), ...(0, array_1.toArray)(innerValues));
8
+ function oneOrMany(innerValues, options) {
9
+ return (0, union_1.union)([
10
+ (0, array_2.array)(innerValues, { minimumLength: options?.minimumLength, maximumLength: options?.maximumLength }),
11
+ ...(0, array_1.toArray)(innerValues)
12
+ ], options);
10
13
  }
11
14
  exports.oneOrMany = oneOrMany;
12
15
  //# sourceMappingURL=one-or-many.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"one-or-many.js","sourceRoot":"","sources":["../../../source/schema/schemas/one-or-many.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,6CAAwC;AAGxC,mCAAgC;AAChC,mCAAgC;AAUhC,SAAgB,SAAS,CAAW,WAA4C,EAAE,UAA4B,EAAE;IAC9G,OAAO,IAAA,aAAK,EAAC,IAAA,aAAK,EAAC,WAAW,EAAE,OAAO,CAAC,EAAE,GAAG,IAAA,eAAO,EAAC,WAAW,CAAC,CAA4B,CAAC;AAChG,CAAC;AAFD,8BAEC"}
1
+ {"version":3,"file":"one-or-many.js","sourceRoot":"","sources":["../../../source/schema/schemas/one-or-many.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,6CAAwC;AAGxC,mCAA8C;AAC9C,mCAAgC;AAIhC,SAAgB,SAAS,CAAI,WAAyC,EAAE,OAA0B;IAChG,OAAO,IAAA,aAAK,EACV;QACE,IAAA,aAAK,EAAC,WAAW,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;QACpG,GAAG,IAAA,eAAO,EAAC,WAAW,CAAC;KACxB,EACD,OAAO,CACgB,CAAC;AAC5B,CAAC;AARD,8BAQC"}
@@ -1,4 +1,5 @@
1
1
  import type { OneOrMany } from "../../types";
2
2
  import type { SchemaTestable } from '../schema';
3
- import type { ValueSchema } from '../types';
4
- export declare function optional<T, O>(schema: OneOrMany<SchemaTestable<T, O>>): ValueSchema<T | undefined, O | undefined>;
3
+ import type { NormalizeValueType, ValueSchema, ValueSchemaOptions } from '../types';
4
+ export declare type OptionalOptions = ValueSchemaOptions;
5
+ export declare function optional<T>(schema: OneOrMany<SchemaTestable<T>>, options?: OptionalOptions): ValueSchema<NormalizeValueType<T> | undefined>;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.optional = void 0;
4
4
  const types_1 = require("../types");
5
- function optional(schema) {
6
- return (0, types_1.valueSchema)(schema, { optional: true });
5
+ function optional(schema, options) {
6
+ return (0, types_1.valueSchema)(schema, { ...options, optional: true });
7
7
  }
8
8
  exports.optional = optional;
9
9
  //# sourceMappingURL=optional.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../source/schema/schemas/optional.ts"],"names":[],"mappings":";;;AAGA,oCAAuC;AAEvC,SAAgB,QAAQ,CAAO,MAAuC;IACpE,OAAO,IAAA,mBAAW,EAAC,MAAsD,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACjG,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../source/schema/schemas/optional.ts"],"names":[],"mappings":";;;AAGA,oCAAuC;AAIvC,SAAgB,QAAQ,CAAI,MAAoC,EAAE,OAAyB;IACzF,OAAO,IAAA,mBAAW,EAAC,MAA2D,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAClH,CAAC;AAFD,4BAEC"}
@@ -1,4 +1,6 @@
1
1
  import type { Decorator } from "../../reflection";
2
- import type { TypeSchema } from '../types';
3
- export declare function readableStream(): TypeSchema<globalThis.ReadableStream>;
2
+ import type { Schema } from '../schema';
3
+ import type { ValueSchemaOptions } from '../types';
4
+ export declare type ReadableStreamOptions = ValueSchemaOptions;
5
+ export declare function readableStream(options?: ReadableStreamOptions): Schema<globalThis.ReadableStream>;
4
6
  export declare function ReadableStream(): Decorator<'property' | 'accessor'>;
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ReadableStream = exports.readableStream = void 0;
5
5
  const decorators_1 = require("../decorators");
6
6
  const types_1 = require("../types");
7
- function readableStream() {
8
- return (0, types_1.typeSchema)(globalThis.ReadableStream);
7
+ function readableStream(options) {
8
+ return (0, types_1.valueSchema)(globalThis.ReadableStream, options);
9
9
  }
10
10
  exports.readableStream = readableStream;
11
11
  function ReadableStream() {
@@ -1 +1 @@
1
- {"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAExE,oCAAsC;AAEtC,SAAgB,cAAc;IAC5B,OAAO,IAAA,kBAAU,EAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAC/C,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc;IAC5B,OAAO,IAAA,oDAAuC,EAAC,cAAc,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wCAEC"}
1
+ {"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,oCAAuC;AAIvC,SAAgB,cAAc,CAAC,OAA+B;IAC5D,OAAO,IAAA,mBAAW,EAAC,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc;IAC5B,OAAO,IAAA,oDAAuC,EAAC,cAAc,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wCAEC"}
@@ -2,4 +2,4 @@ import type { OneOrMany, Record, TypedOmit } from "../../types";
2
2
  import type { SchemaTestable } from '../schema';
3
3
  import type { ObjectSchema } from '../types';
4
4
  export declare type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'allowUnknownProperties' | 'mask'>;
5
- export declare function record<T, O>(valueType: OneOrMany<SchemaTestable<T, O>>, options?: RecordOptions): ObjectSchema<Record<any, O>>;
5
+ export declare function record<T>(valueType: OneOrMany<SchemaTestable<T>>, options?: RecordOptions): ObjectSchema<Record<any, T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAO,SAA0C,EAAE,OAAuB;IAC9F,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,SAAS;QACjC,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAI,SAAuC,EAAE,OAAuB;IACxF,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,SAAS;QACjC,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
@@ -1,6 +1,6 @@
1
1
  import type { Decorator } from "../../reflection";
2
2
  import type { Schema } from '../schema';
3
- import type { Coercible } from '../types';
4
- export declare type RegExpSchemaOptions = Coercible;
3
+ import type { ValueSchemaOptions } from '../types';
4
+ export declare type RegExpSchemaOptions = ValueSchemaOptions;
5
5
  export declare function regexp(options?: RegExpSchemaOptions): Schema<globalThis.RegExp>;
6
6
  export declare function RegExp(options?: RegExpSchemaOptions): Decorator<'property' | 'accessor'>;
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.RegExp = exports.regexp = void 0;
5
5
  const decorators_1 = require("../decorators");
6
6
  const types_1 = require("../types");
7
- function regexp(options = {}) {
8
- return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.RegExp), {
9
- coerce: options.coerce
10
- });
7
+ function regexp(options) {
8
+ return (0, types_1.valueSchema)(globalThis.RegExp, options);
11
9
  }
12
10
  exports.regexp = regexp;
13
11
  function RegExp(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,oCAAmD;AAInD,SAAgB,MAAM,CAAC,UAA+B,EAAE;IACtD,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
1
+ {"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,oCAAuC;AAIvC,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,mBAAW,EAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
@@ -1,6 +1,6 @@
1
1
  import type { Decorator } from "../../reflection";
2
- import type { Coercible, ValueSchema } from '../types';
3
- export declare type StringOptions = Coercible & {
2
+ import type { ValueSchema, ValueSchemaOptions } from '../types';
3
+ export declare type StringOptions = ValueSchemaOptions & {
4
4
  /** trim */
5
5
  trim?: boolean;
6
6
  /** lowercase */
@@ -2,23 +2,24 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.String = exports.string = void 0;
5
+ const array_1 = require("../../utils/array/array");
5
6
  const type_guards_1 = require("../../utils/type-guards");
6
7
  const constraints_1 = require("../constraints");
7
8
  const decorators_1 = require("../decorators");
8
9
  const transformers_1 = require("../transformers");
9
10
  const types_1 = require("../types");
10
11
  function string(options = {}) {
11
- const constraints = [];
12
- const transformers = [];
12
+ const valueConstraints = (0, array_1.toArray)(options.valueConstraints ?? []);
13
+ const transformers = (0, array_1.toArray)(options.transformers ?? []);
13
14
  if ((0, type_guards_1.isDefined)(options.minimumLength)) {
14
- constraints.push(new constraints_1.MinimumLengthConstraint(options.minimumLength));
15
+ valueConstraints.push(new constraints_1.MinimumLengthConstraint(options.minimumLength));
15
16
  }
16
17
  if ((0, type_guards_1.isDefined)(options.maximumLength)) {
17
- constraints.push(new constraints_1.MaximumLengthConstraint(options.maximumLength));
18
+ valueConstraints.push(new constraints_1.MaximumLengthConstraint(options.maximumLength));
18
19
  }
19
20
  if ((0, type_guards_1.isDefined)(options.pattern)) {
20
21
  const pattern = RegExp(options.pattern, options.patternFlags);
21
- constraints.push(new constraints_1.PatternConstraint(pattern, options.patternName));
22
+ valueConstraints.push(new constraints_1.PatternConstraint(pattern, options.patternName));
22
23
  }
23
24
  if ((0, type_guards_1.isDefined)(options.trim)) {
24
25
  transformers.push(new transformers_1.TrimTransformer());
@@ -30,8 +31,8 @@ function string(options = {}) {
30
31
  transformers.push(new transformers_1.UppercaseTransformer());
31
32
  }
32
33
  return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.String), {
33
- coerce: options.coerce,
34
- valueConstraints: constraints,
34
+ ...options,
35
+ valueConstraints,
35
36
  transformers
36
37
  });
37
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,gDAAqG;AACrG,8CAAwE;AACxE,kDAA8F;AAE9F,oCAAmD;AA4Bn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AAe,EAAE,CAAC,CAAC;KAC1C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,GAAG,OAAO;QACV,gBAAgB;QAChB,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAlCD,wBAkCC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
@@ -1,5 +1,5 @@
1
- import type { AbstractConstructor, OneOrMany } from "../../types";
2
- import type { Schema } from '../schema';
1
+ import type { OneOrMany } from "../../types";
2
+ import type { SchemaTestable } from '../schema';
3
3
  import type { GenericTransformFunction } from '../transformers/generic';
4
4
  import type { ValueSchema, ValueType } from '../types';
5
- export declare function transform<T, O, TransformOutput>(schema: OneOrMany<Schema<T, O>>, sourceType: OneOrMany<ValueType<T>>, targetType: AbstractConstructor<TransformOutput>, transformFunction: GenericTransformFunction<O, TransformOutput>): ValueSchema<TransformOutput>;
5
+ export declare function transform<T, O>(schema: OneOrMany<SchemaTestable<T>>, transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<ValueType<T>>): ValueSchema<O>;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transform = void 0;
4
4
  const generic_1 = require("../transformers/generic");
5
5
  const types_1 = require("../types");
6
- function transform(schema, sourceType, targetType, transformFunction) {
6
+ function transform(schema, transformFunction, sourceType) {
7
7
  return (0, types_1.valueSchema)(schema, {
8
- transformers: new generic_1.GenericTransformer(sourceType, targetType, transformFunction)
8
+ transformers: new generic_1.GenericTransformer(transformFunction, sourceType)
9
9
  });
10
10
  }
11
11
  exports.transform = transform;
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;AAGA,qDAA6D;AAE7D,oCAAuC;AAEvC,SAAgB,SAAS,CAAwB,MAA+B,EAAE,UAAmC,EAAE,UAAgD,EAAE,iBAA+D;IACtO,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE;QACzB,YAAY,EAAE,IAAI,4BAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAC;KAChF,CAAqB,CAAC;AACzB,CAAC;AAJD,8BAIC"}
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;AAGA,qDAA6D;AAE7D,oCAAuC;AAEvC,SAAgB,SAAS,CAAO,MAAoC,EAAE,iBAAiD,EAAE,UAAoC;IAC3J,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE;QACzB,YAAY,EAAE,IAAI,4BAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC;KACpE,CAAqB,CAAC;AACzB,CAAC;AAJD,8BAIC"}
@@ -1,7 +1,9 @@
1
1
  import type { Decorator } from "../../reflection";
2
- import type { Coercible, ValueSchema } from '../types';
3
- export declare type Uint8ArraySchemaOptions = Coercible & {
2
+ import type { ValueSchema, ValueSchemaOptions } from '../types';
3
+ export declare type Uint8ArraySchemaOptions = ValueSchemaOptions & {
4
+ /** Minimum byte length */
4
5
  minimumLength?: number;
6
+ /** Maximum byte length */
5
7
  maximumLength?: number;
6
8
  };
7
9
  export declare function uint8Array(options?: Uint8ArraySchemaOptions): ValueSchema<globalThis.Uint8Array>;
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Uint8Array = exports.uint8Array = void 0;
5
+ const array_1 = require("../../utils/array/array");
5
6
  const type_guards_1 = require("../../utils/type-guards");
6
7
  const uint8_array_coercer_1 = require("../coercers/uint8-array.coercer");
7
8
  const maximum_length_1 = require("../constraints/maximum-length");
@@ -9,16 +10,21 @@ const minimum_length_1 = require("../constraints/minimum-length");
9
10
  const utils_1 = require("../decorators/utils");
10
11
  const types_1 = require("../types");
11
12
  function uint8Array(options = {}) {
12
- const constraints = [];
13
+ const coercers = (0, array_1.toArray)(options.coercers ?? []);
14
+ const valueConstraints = (0, array_1.toArray)(options.valueConstraints ?? []);
15
+ if (options.coerce == true) {
16
+ coercers.push(uint8_array_coercer_1.uint8ArrayCoercer);
17
+ }
13
18
  if ((0, type_guards_1.isDefined)(options.minimumLength)) {
14
- constraints.push(new minimum_length_1.MinimumLengthConstraint(options.minimumLength));
19
+ valueConstraints.push(new minimum_length_1.MinimumLengthConstraint(options.minimumLength));
15
20
  }
16
21
  if ((0, type_guards_1.isDefined)(options.maximumLength)) {
17
- constraints.push(new maximum_length_1.MaximumLengthConstraint(options.maximumLength));
22
+ valueConstraints.push(new maximum_length_1.MaximumLengthConstraint(options.maximumLength));
18
23
  }
19
24
  return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Uint8Array), {
20
- coercers: (options.coerce == true) ? uint8_array_coercer_1.uint8ArrayCoercer : undefined,
21
- valueConstraints: constraints
25
+ ...options,
26
+ coercers,
27
+ valueConstraints
22
28
  });
23
29
  }
24
30
  exports.uint8Array = uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"uint8-array.js","sourceRoot":"","sources":["../../../source/schema/schemas/uint8-array.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,yEAAoE;AACpE,kEAAwE;AACxE,kEAAwE;AACxE,+CAA8E;AAE9E,oCAAmD;AAOnD,SAAgB,UAAU,CAAC,UAAmC,EAAE;IAC9D,MAAM,W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B,CAAC,CAAC;KAClC;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,wCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC3E;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,wCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC3E;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QACpD,GAAG,OAAO;QACV,QAAQ;QACR,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AArBD,gCAqBC;AAED,SAAgB,UAAU,CAAC,OAAiC;IAC1D,OAAO,IAAA,+CAAuC,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,gCAEC"}
@@ -1,5 +1,7 @@
1
1
  import type { Decorator } from "../../reflection";
2
2
  import type { SchemaTestable } from '../schema';
3
- import type { SchemaInput, SchemaOutput, ValueSchema } from '../types';
4
- export declare function union<T extends SchemaTestable[]>(...schemas: [...T]): ValueSchema<SchemaInput<T[number]>, SchemaOutput<T[number]>>;
3
+ import type { SchemaOutput, ValueSchema, ValueSchemaOptions } from '../types';
4
+ export declare type UnionOptions = ValueSchemaOptions;
5
+ export declare function union<T extends SchemaTestable[]>(...schemas: [...T]): ValueSchema<SchemaOutput<T[number]>>;
6
+ export declare function union<T extends SchemaTestable[]>(schemas: [...T], options?: UnionOptions): ValueSchema<SchemaOutput<T[number]>>;
5
7
  export declare function Union(...schemas: SchemaTestable[]): Decorator<'property' | 'accessor'>;
@@ -5,9 +5,11 @@ exports.Union = exports.union = void 0;
5
5
  const type_guards_1 = require("../../utils/type-guards");
6
6
  const decorators_1 = require("../decorators");
7
7
  const types_1 = require("../types");
8
- function union(...schemas) {
9
- (0, type_guards_1.assert)(schemas.length >= 2, 'Assign requires at least 2 schemas.');
10
- return (0, types_1.valueSchema)(schemas);
8
+ function union(...args) {
9
+ const schemas = (0, type_guards_1.isArray)(args[0]) ? args[0] : args;
10
+ const options = (0, type_guards_1.isArray)(args[0]) ? args[1] : undefined;
11
+ (0, type_guards_1.assert)(schemas.length >= 2, 'Union requires at least 2 schemas.');
12
+ return (0, types_1.valueSchema)(schemas, options);
11
13
  }
12
14
  exports.union = union;
13
15
  function Union(...schemas) {
@@ -1 +1 @@
1
- {"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAA6C;AAC7C,8CAAwE;AAGxE,oCAAuC;AAEvC,SAAgB,KAAK,CAA6B,GAAG,OAAe;IAClE,IAAA,oBAAM,EAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,qCAAqC,CAAC,CAAC;IACnE,OAAO,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAHD,sBAGC;AAED,SAAgB,KAAK,CAAC,GAAG,OAAyB;IAChD,OAAO,IAAA,oDAAuC,EAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,sBAEC"}
1
+ {"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAsD;AACtD,8CAAwE;AAGxE,oCAAuC;AAMvC,SAAgB,KAAK,CAA6B,GAAG,IAA8C;IACjG,MAAM,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAS,CAAC;IACvD,MAAM,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvE,IAAA,oBAAM,EAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,oCAAoC,CAAC,CAAC;IAClE,OAAO,IAAA,mBAAW,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAND,sBAMC;AAED,SAAgB,KAAK,CAAC,GAAG,OAAyB;IAChD,OAAO,IAAA,oDAAuC,EAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,sBAEC"}