@tstdl/base 0.91.0 → 0.91.1

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 (154) hide show
  1. package/authentication/authentication.api.d.ts +1 -1
  2. package/enumerable/async-enumerable.d.ts +5 -1
  3. package/enumerable/async-enumerable.js +8 -8
  4. package/enumerable/enumerable.d.ts +5 -1
  5. package/enumerable/enumerable.js +8 -8
  6. package/package.json +1 -1
  7. package/schema-old/array-constraints/index.d.ts +0 -2
  8. package/schema-old/array-constraints/index.js +0 -2
  9. package/schema-old/array-constraints/maximum-length.d.ts +0 -11
  10. package/schema-old/array-constraints/maximum-length.js +0 -22
  11. package/schema-old/array-constraints/minimum-length.d.ts +0 -11
  12. package/schema-old/array-constraints/minimum-length.js +0 -22
  13. package/schema-old/coercers/boolean.coercer.d.ts +0 -9
  14. package/schema-old/coercers/boolean.coercer.js +0 -27
  15. package/schema-old/coercers/date.coercer.d.ts +0 -9
  16. package/schema-old/coercers/date.coercer.js +0 -16
  17. package/schema-old/coercers/index.d.ts +0 -6
  18. package/schema-old/coercers/index.js +0 -6
  19. package/schema-old/coercers/number.coercer.d.ts +0 -9
  20. package/schema-old/coercers/number.coercer.js +0 -14
  21. package/schema-old/coercers/regexp.coercer.d.ts +0 -11
  22. package/schema-old/coercers/regexp.coercer.js +0 -20
  23. package/schema-old/coercers/string.coercer.d.ts +0 -9
  24. package/schema-old/coercers/string.coercer.js +0 -14
  25. package/schema-old/coercers/uint8-array.coercer.d.ts +0 -11
  26. package/schema-old/coercers/uint8-array.coercer.js +0 -22
  27. package/schema-old/constraints/enumeration.d.ts +0 -13
  28. package/schema-old/constraints/enumeration.js +0 -29
  29. package/schema-old/constraints/generic.d.ts +0 -20
  30. package/schema-old/constraints/generic.js +0 -23
  31. package/schema-old/constraints/index.d.ts +0 -12
  32. package/schema-old/constraints/index.js +0 -12
  33. package/schema-old/constraints/integer.d.ts +0 -12
  34. package/schema-old/constraints/integer.js +0 -23
  35. package/schema-old/constraints/length.d.ts +0 -6
  36. package/schema-old/constraints/length.js +0 -15
  37. package/schema-old/constraints/literal.d.ts +0 -10
  38. package/schema-old/constraints/literal.js +0 -24
  39. package/schema-old/constraints/maximum-date.d.ts +0 -12
  40. package/schema-old/constraints/maximum-date.js +0 -26
  41. package/schema-old/constraints/maximum-length.d.ts +0 -12
  42. package/schema-old/constraints/maximum-length.js +0 -25
  43. package/schema-old/constraints/maximum.d.ts +0 -12
  44. package/schema-old/constraints/maximum.js +0 -24
  45. package/schema-old/constraints/minimum-date.d.ts +0 -12
  46. package/schema-old/constraints/minimum-date.js +0 -26
  47. package/schema-old/constraints/minimum-length.d.ts +0 -12
  48. package/schema-old/constraints/minimum-length.js +0 -25
  49. package/schema-old/constraints/minimum.d.ts +0 -12
  50. package/schema-old/constraints/minimum.js +0 -24
  51. package/schema-old/constraints/pattern.d.ts +0 -13
  52. package/schema-old/constraints/pattern.js +0 -26
  53. package/schema-old/decorators/class.d.ts +0 -3
  54. package/schema-old/decorators/class.js +0 -5
  55. package/schema-old/decorators/coerce.d.ts +0 -2
  56. package/schema-old/decorators/coerce.js +0 -5
  57. package/schema-old/decorators/constraint.d.ts +0 -4
  58. package/schema-old/decorators/constraint.js +0 -7
  59. package/schema-old/decorators/index.d.ts +0 -6
  60. package/schema-old/decorators/index.js +0 -6
  61. package/schema-old/decorators/property.d.ts +0 -6
  62. package/schema-old/decorators/property.js +0 -17
  63. package/schema-old/decorators/types.d.ts +0 -19
  64. package/schema-old/decorators/types.js +0 -1
  65. package/schema-old/decorators/utils.d.ts +0 -15
  66. package/schema-old/decorators/utils.js +0 -48
  67. package/schema-old/index.d.ts +0 -10
  68. package/schema-old/index.js +0 -10
  69. package/schema-old/schema.d.ts +0 -15
  70. package/schema-old/schema.error.d.ts +0 -26
  71. package/schema-old/schema.error.js +0 -64
  72. package/schema-old/schema.js +0 -283
  73. package/schema-old/schemas/any.d.ts +0 -5
  74. package/schema-old/schemas/any.js +0 -9
  75. package/schema-old/schemas/array.d.ts +0 -12
  76. package/schema-old/schemas/array.js +0 -23
  77. package/schema-old/schemas/assign.d.ts +0 -7
  78. package/schema-old/schemas/assign.js +0 -24
  79. package/schema-old/schemas/boolean.d.ts +0 -5
  80. package/schema-old/schemas/boolean.js +0 -9
  81. package/schema-old/schemas/constraint.d.ts +0 -5
  82. package/schema-old/schemas/constraint.js +0 -7
  83. package/schema-old/schemas/date.d.ts +0 -8
  84. package/schema-old/schemas/date.js +0 -22
  85. package/schema-old/schemas/defaulted.d.ts +0 -6
  86. package/schema-old/schemas/defaulted.js +0 -10
  87. package/schema-old/schemas/enumeration.d.ts +0 -6
  88. package/schema-old/schemas/enumeration.js +0 -17
  89. package/schema-old/schemas/index.d.ts +0 -26
  90. package/schema-old/schemas/index.js +0 -26
  91. package/schema-old/schemas/instance.d.ts +0 -3
  92. package/schema-old/schemas/instance.js +0 -5
  93. package/schema-old/schemas/literal.d.ts +0 -5
  94. package/schema-old/schemas/literal.js +0 -17
  95. package/schema-old/schemas/nullable.d.ts +0 -6
  96. package/schema-old/schemas/nullable.js +0 -9
  97. package/schema-old/schemas/number.d.ts +0 -9
  98. package/schema-old/schemas/number.js +0 -27
  99. package/schema-old/schemas/object.d.ts +0 -7
  100. package/schema-old/schemas/object.js +0 -12
  101. package/schema-old/schemas/omit.d.ts +0 -3
  102. package/schema-old/schemas/omit.js +0 -15
  103. package/schema-old/schemas/one-or-many.d.ts +0 -9
  104. package/schema-old/schemas/one-or-many.js +0 -15
  105. package/schema-old/schemas/optional.d.ts +0 -7
  106. package/schema-old/schemas/optional.js +0 -8
  107. package/schema-old/schemas/partial.d.ts +0 -4
  108. package/schema-old/schemas/partial.js +0 -17
  109. package/schema-old/schemas/pick.d.ts +0 -3
  110. package/schema-old/schemas/pick.js +0 -15
  111. package/schema-old/schemas/readable-stream.d.ts +0 -6
  112. package/schema-old/schemas/readable-stream.js +0 -9
  113. package/schema-old/schemas/record.d.ts +0 -5
  114. package/schema-old/schemas/record.js +0 -10
  115. package/schema-old/schemas/regexp.d.ts +0 -6
  116. package/schema-old/schemas/regexp.js +0 -9
  117. package/schema-old/schemas/string.d.ts +0 -22
  118. package/schema-old/schemas/string.js +0 -38
  119. package/schema-old/schemas/transform.d.ts +0 -5
  120. package/schema-old/schemas/transform.js +0 -7
  121. package/schema-old/schemas/uint8-array.d.ts +0 -10
  122. package/schema-old/schemas/uint8-array.js +0 -29
  123. package/schema-old/schemas/union.d.ts +0 -7
  124. package/schema-old/schemas/union.js +0 -13
  125. package/schema-old/schemas/unknown.d.ts +0 -5
  126. package/schema-old/schemas/unknown.js +0 -9
  127. package/schema-old/transformers/generic.d.ts +0 -12
  128. package/schema-old/transformers/generic.js +0 -18
  129. package/schema-old/transformers/index.d.ts +0 -4
  130. package/schema-old/transformers/index.js +0 -4
  131. package/schema-old/transformers/lowercase.d.ts +0 -8
  132. package/schema-old/transformers/lowercase.js +0 -12
  133. package/schema-old/transformers/trim.d.ts +0 -8
  134. package/schema-old/transformers/trim.js +0 -12
  135. package/schema-old/transformers/uppercase.d.ts +0 -8
  136. package/schema-old/transformers/uppercase.js +0 -12
  137. package/schema-old/types/index.d.ts +0 -5
  138. package/schema-old/types/index.js +0 -5
  139. package/schema-old/types/schema-array-constraint.d.ts +0 -5
  140. package/schema-old/types/schema-array-constraint.js +0 -2
  141. package/schema-old/types/schema-value-coercer.d.ts +0 -8
  142. package/schema-old/types/schema-value-coercer.js +0 -2
  143. package/schema-old/types/schema-value-constraint.d.ts +0 -8
  144. package/schema-old/types/schema-value-constraint.js +0 -2
  145. package/schema-old/types/schema-value-transformer.d.ts +0 -7
  146. package/schema-old/types/schema-value-transformer.js +0 -2
  147. package/schema-old/types/types.d.ts +0 -175
  148. package/schema-old/types/types.js +0 -172
  149. package/schema-old/utils/index.d.ts +0 -2
  150. package/schema-old/utils/index.js +0 -2
  151. package/schema-old/utils/schema.d.ts +0 -18
  152. package/schema-old/utils/schema.js +0 -139
  153. package/schema-old/utils/value-type.d.ts +0 -8
  154. package/schema-old/utils/value-type.js +0 -56
@@ -1,12 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { objectSchema } from '../types/index.js';
3
- export function explicitObject(properties, options) {
4
- return object(properties, options);
5
- }
6
- export function object(properties, options) {
7
- return objectSchema({
8
- properties,
9
- ...options
10
- });
11
- }
12
- export const emptyObjectSchema = explicitObject({});
@@ -1,3 +0,0 @@
1
- import type { ObjectLiteral, OneOrMany, SimplifyObject } from '../../types.js';
2
- import type { ObjectSchema, ObjectSchemaOrType } from '../types/index.js';
3
- export declare function omit<T extends ObjectLiteral, K extends keyof T>(schemaOrType: ObjectSchemaOrType<T>, keys: OneOrMany<K>): ObjectSchema<SimplifyObject<Omit<T, K>>>;
@@ -1,15 +0,0 @@
1
- import { toArray } from '../../utils/array/array.js';
2
- import { objectEntries } from '../../utils/object/object.js';
3
- import { objectSchema } from '../types/index.js';
4
- import { getObjectSchema } from '../utils/schema.js';
5
- export function omit(schemaOrType, keys) {
6
- const schema = getObjectSchema(schemaOrType);
7
- const keyArray = toArray(keys);
8
- const entries = objectEntries(schema.properties);
9
- const pickedEntries = entries.filter(([propertyKey]) => !keyArray.includes(propertyKey));
10
- const pickedSchema = objectSchema({
11
- ...schema,
12
- properties: Object.fromEntries(pickedEntries)
13
- });
14
- return pickedSchema;
15
- }
@@ -1,9 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { OneOrMany as OneOrManyType } from '../../types.js';
3
- import type { SchemaTestable } from '../schema.js';
4
- import type { ValueSchema, ValueSchemaOptions } from '../types/types.js';
5
- import type { ArrayOptions } from './array.js';
6
- export type OneOrMany<T> = OneOrManyType<T>;
7
- export type OneOrManyOptions = ValueSchemaOptions & Pick<ArrayOptions, 'minimumLength' | 'maximumLength'>;
8
- export declare function oneOrMany<T>(innerValues: OneOrMany<SchemaTestable<T>>, options?: OneOrManyOptions): ValueSchema<T | T[]>;
9
- export declare function OneOrMany(innerValues: OneOrMany<SchemaTestable>, options?: OneOrManyOptions): Decorator<'property' | 'accessor'>;
@@ -1,15 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { toArray } from '../../utils/array/array.js';
3
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/utils.js';
4
- import { array } from './array.js';
5
- import { union } from './union.js';
6
- export function oneOrMany(innerValues, options) {
7
- return union([
8
- array(innerValues, { minimumLength: options?.minimumLength, maximumLength: options?.maximumLength }),
9
- ...toArray(innerValues)
10
- ], options);
11
- }
12
- // eslint-disable-next-line @typescript-eslint/no-redeclare
13
- export function OneOrMany(innerValues, options) {
14
- return createSchemaPropertyDecoratorFromSchema(oneOrMany(innerValues, options));
15
- }
@@ -1,7 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { OneOrMany } from '../../types.js';
3
- import type { SchemaTestable } from '../schema.js';
4
- import type { ValueSchema, ValueSchemaOptions } from '../types/types.js';
5
- export type OptionalOptions = ValueSchemaOptions;
6
- export declare function optional<T>(schema: OneOrMany<SchemaTestable<T>>, options?: OptionalOptions): ValueSchema<T | undefined>;
7
- export declare function Optional(schema?: OneOrMany<SchemaTestable>): Decorator<'property' | 'accessor'>;
@@ -1,8 +0,0 @@
1
- import { createSchemaPropertyDecorator } from '../decorators/utils.js';
2
- import { valueSchema } from '../types/index.js';
3
- export function optional(schema, options) {
4
- return valueSchema(schema, { ...options, optional: true });
5
- }
6
- export function Optional(schema) {
7
- return createSchemaPropertyDecorator({ schema, optional: true });
8
- }
@@ -1,4 +0,0 @@
1
- import type { OneOrMany, PartialProperty, Record } from '../../types.js';
2
- import type { ObjectSchema, ObjectSchemaOrType } from '../types/types.js';
3
- export declare function partial<T extends Record>(schema: ObjectSchemaOrType<T>): ObjectSchema<Partial<T>>;
4
- export declare function partial<T extends Record, K extends keyof T>(schema: ObjectSchemaOrType<T>, keys: OneOrMany<K>): ObjectSchema<PartialProperty<T, K>>;
@@ -1,17 +0,0 @@
1
- import { toArray } from '../../utils/array/array.js';
2
- import { mapObjectValues } from '../../utils/object/object.js';
3
- import { isDefined, isUndefined } from '../../utils/type-guards.js';
4
- import { objectSchema } from '../types/index.js';
5
- import { getObjectSchema } from '../utils/schema.js';
6
- import { optional } from './optional.js';
7
- export function partial(schemaOrType, keys) {
8
- const schema = getObjectSchema(schemaOrType);
9
- const keyArray = isDefined(keys) ? toArray(keys) : undefined;
10
- const makeAllOptional = isUndefined(keyArray);
11
- const partialEntries = mapObjectValues(schema.properties, (propertySchema, key) => ((makeAllOptional || keyArray.includes(key)) ? optional(propertySchema) : propertySchema));
12
- const pickedSchema = objectSchema({
13
- ...schema,
14
- properties: partialEntries
15
- });
16
- return pickedSchema;
17
- }
@@ -1,3 +0,0 @@
1
- import type { OneOrMany, Record, SimplifyObject } from '../../types.js';
2
- import type { ObjectSchema, ObjectSchemaOrType } from '../types/index.js';
3
- export declare function pick<T extends Record, K extends keyof T>(schemaOrType: ObjectSchemaOrType<T>, key: OneOrMany<K>): ObjectSchema<SimplifyObject<Pick<T, K>>>;
@@ -1,15 +0,0 @@
1
- import { toArray } from '../../utils/array/array.js';
2
- import { objectEntries } from '../../utils/object/object.js';
3
- import { objectSchema } from '../types/index.js';
4
- import { getObjectSchema } from '../utils/schema.js';
5
- export function pick(schemaOrType, key) {
6
- const schema = getObjectSchema(schemaOrType);
7
- const keys = toArray(key);
8
- const entries = objectEntries(schema.properties);
9
- const pickedEntries = entries.filter(([propertyKey]) => keys.includes(propertyKey));
10
- const pickedSchema = objectSchema({
11
- ...schema,
12
- properties: Object.fromEntries(pickedEntries)
13
- });
14
- return pickedSchema;
15
- }
@@ -1,6 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { Schema } from '../schema.js';
3
- import type { ValueSchemaOptions } from '../types/types.js';
4
- export type ReadableStreamOptions = ValueSchemaOptions;
5
- export declare function readableStream(options?: ReadableStreamOptions): Schema<ReadableStream>;
6
- export declare function ReadableStreamProperty(options?: ReadableStreamOptions): Decorator<'property' | 'accessor'>;
@@ -1,9 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/index.js';
3
- import { valueSchema } from '../types/index.js';
4
- export function readableStream(options) {
5
- return valueSchema(ReadableStream, options);
6
- }
7
- export function ReadableStreamProperty(options) {
8
- return createSchemaPropertyDecoratorFromSchema(readableStream(options));
9
- }
@@ -1,5 +0,0 @@
1
- import type { OneOrMany, Record, TypedOmit } from '../../types.js';
2
- import type { SchemaTestable } from '../schema.js';
3
- import { type ObjectSchema } from '../types/index.js';
4
- export type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'unknownProperties' | 'unknownPropertiesKey' | 'mask'>;
5
- export declare function record<K extends PropertyKey, T>(keySchema: OneOrMany<SchemaTestable<K>>, valueSchema: OneOrMany<SchemaTestable<T>>, options?: RecordOptions): ObjectSchema<Record<K, T>>;
@@ -1,10 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { objectSchema } from '../types/index.js';
3
- export function record(keySchema, valueSchema, options) {
4
- return objectSchema({
5
- properties: {},
6
- unknownProperties: valueSchema,
7
- unknownPropertiesKey: keySchema,
8
- ...options
9
- });
10
- }
@@ -1,6 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { Schema } from '../schema.js';
3
- import type { ValueSchemaOptions } from '../types/types.js';
4
- export type RegExpSchemaOptions = ValueSchemaOptions;
5
- export declare function regexp(options?: RegExpSchemaOptions): Schema<RegExp>;
6
- export declare function RegExpProperty(options?: RegExpSchemaOptions): Decorator<'property' | 'accessor'>;
@@ -1,9 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/index.js';
3
- import { valueSchema } from '../types/index.js';
4
- export function regexp(options) {
5
- return valueSchema(RegExp, options);
6
- }
7
- export function RegExpProperty(options) {
8
- return createSchemaPropertyDecoratorFromSchema(regexp(options));
9
- }
@@ -1,22 +0,0 @@
1
- import type { Decorator } from '../../reflection/types.js';
2
- import type { ValueSchema, ValueSchemaOptions } from '../types/types.js';
3
- export type StringOptions = ValueSchemaOptions & {
4
- /** trim */
5
- trim?: boolean;
6
- /** lowercase */
7
- lowercase?: boolean;
8
- /** uppercase */
9
- uppercase?: boolean;
10
- /** minimum length */
11
- minimumLength?: number;
12
- /** maximum length */
13
- maximumLength?: number;
14
- /** regular expression */
15
- pattern?: string | RegExp;
16
- /** regular expression flags */
17
- patternFlags?: string;
18
- /** name for errors */
19
- patternName?: string;
20
- };
21
- export declare function string(options?: StringOptions): ValueSchema<string>;
22
- export declare function StringProperty(options?: StringOptions): Decorator<'property' | 'accessor'>;
@@ -1,38 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { toArrayCopy } from '../../utils/array/array.js';
3
- import { isDefined } from '../../utils/type-guards.js';
4
- import { MaximumLengthConstraint, MinimumLengthConstraint, PatternConstraint } from '../constraints/index.js';
5
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/utils.js';
6
- import { LowercaseTransformer, TrimTransformer, UppercaseTransformer } from '../transformers/index.js';
7
- import { valueSchema } from '../types/types.js';
8
- export function string(options = {}) {
9
- const valueConstraints = toArrayCopy(options.valueConstraints ?? []);
10
- const transformers = toArrayCopy(options.transformers ?? []);
11
- if (isDefined(options.minimumLength)) {
12
- valueConstraints.push(new MinimumLengthConstraint(options.minimumLength));
13
- }
14
- if (isDefined(options.maximumLength)) {
15
- valueConstraints.push(new MaximumLengthConstraint(options.maximumLength));
16
- }
17
- if (isDefined(options.pattern)) {
18
- const pattern = RegExp(options.pattern, options.patternFlags);
19
- valueConstraints.push(new PatternConstraint(pattern, options.patternName));
20
- }
21
- if (isDefined(options.trim)) {
22
- transformers.push(new TrimTransformer());
23
- }
24
- if (isDefined(options.lowercase)) {
25
- transformers.push(new LowercaseTransformer());
26
- }
27
- if (isDefined(options.uppercase)) {
28
- transformers.push(new UppercaseTransformer());
29
- }
30
- return valueSchema(String, {
31
- ...options,
32
- valueConstraints,
33
- transformers
34
- });
35
- }
36
- export function StringProperty(options) {
37
- return createSchemaPropertyDecoratorFromSchema(string(options));
38
- }
@@ -1,5 +0,0 @@
1
- import type { OneOrMany } from '../../types.js';
2
- import type { SchemaTestable } from '../schema.js';
3
- import type { GenericTransformFunction } from '../transformers/generic.js';
4
- import type { ValueSchema, ValueType } from '../types/index.js';
5
- export declare function transform<T, O>(schema: OneOrMany<SchemaTestable<T>>, transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<ValueType<T>>): ValueSchema<O>;
@@ -1,7 +0,0 @@
1
- import { GenericTransformer } from '../transformers/generic.js';
2
- import { valueSchema } from '../types/index.js';
3
- export function transform(schema, transformFunction, sourceType) {
4
- return valueSchema(schema, {
5
- transformers: new GenericTransformer(transformFunction, sourceType)
6
- });
7
- }
@@ -1,10 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { ValueSchema, ValueSchemaOptions } from '../types/types.js';
3
- export type Uint8ArraySchemaOptions = ValueSchemaOptions & {
4
- /** Minimum byte length */
5
- minimumLength?: number;
6
- /** Maximum byte length */
7
- maximumLength?: number;
8
- };
9
- export declare function uint8Array(options?: Uint8ArraySchemaOptions): ValueSchema<Uint8Array>;
10
- export declare function Uint8ArrayProperty(options?: Uint8ArraySchemaOptions): Decorator<'property' | 'accessor'>;
@@ -1,29 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { toArrayCopy } from '../../utils/array/array.js';
3
- import { isDefined } from '../../utils/type-guards.js';
4
- import { uint8ArrayCoercer } from '../coercers/uint8-array.coercer.js';
5
- import { MaximumLengthConstraint } from '../constraints/maximum-length.js';
6
- import { MinimumLengthConstraint } from '../constraints/minimum-length.js';
7
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/utils.js';
8
- import { valueSchema } from '../types/types.js';
9
- export function uint8Array(options = {}) {
10
- const coercers = toArrayCopy(options.coercers ?? []);
11
- const valueConstraints = toArrayCopy(options.valueConstraints ?? []);
12
- if (options.coerce == true) {
13
- coercers.push(uint8ArrayCoercer);
14
- }
15
- if (isDefined(options.minimumLength)) {
16
- valueConstraints.push(new MinimumLengthConstraint(options.minimumLength));
17
- }
18
- if (isDefined(options.maximumLength)) {
19
- valueConstraints.push(new MaximumLengthConstraint(options.maximumLength));
20
- }
21
- return valueSchema(Uint8Array, {
22
- ...options,
23
- coercers,
24
- valueConstraints
25
- });
26
- }
27
- export function Uint8ArrayProperty(options) {
28
- return createSchemaPropertyDecoratorFromSchema(uint8Array(options));
29
- }
@@ -1,7 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { SchemaTestable } from '../schema.js';
3
- import type { SchemaOutput, ValueSchema, ValueSchemaOptions } from '../types/index.js';
4
- export 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]>>;
7
- export declare function Union(...schemas: SchemaTestable[]): Decorator<'property' | 'accessor'>;
@@ -1,13 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { assert, isArray } from '../../utils/type-guards.js';
3
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/index.js';
4
- import { valueSchema } from '../types/index.js';
5
- export function union(...args) {
6
- const schemas = isArray(args[0]) ? args[0] : args;
7
- const options = isArray(args[0]) ? args[1] : undefined;
8
- assert(schemas.length >= 2, 'Union requires at least 2 schemas.');
9
- return valueSchema(schemas, options);
10
- }
11
- export function Union(...schemas) {
12
- return createSchemaPropertyDecoratorFromSchema(union(...schemas));
13
- }
@@ -1,5 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import { ValueSchema, ValueSchemaOptions } from '../types/index.js';
3
- export type UnknownOptions = ValueSchemaOptions;
4
- export declare function unknown(options?: UnknownOptions): ValueSchema<unknown>;
5
- export declare function UnknownProperty(options?: UnknownOptions): Decorator<'property' | 'accessor'>;
@@ -1,9 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaPropertyDecoratorFromSchema } from '../decorators/index.js';
3
- import { valueSchema } from '../types/index.js';
4
- export function unknown(options) {
5
- return valueSchema('any', options);
6
- }
7
- export function UnknownProperty(options) {
8
- return createSchemaPropertyDecoratorFromSchema(unknown(options));
9
- }
@@ -1,12 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { AbstractConstructor, OneOrMany } from '../../types.js';
3
- import type { TransformResult, ValueType } from '../types/index.js';
4
- import { SchemaValueTransformer } from '../types/index.js';
5
- export type GenericTransformFunction<T, O> = (value: T) => TransformResult<O>;
6
- export declare class GenericTransformer<T, O> extends SchemaValueTransformer<T, O> {
7
- readonly sourceType?: OneOrMany<ValueType<T>>;
8
- readonly transformFunction: GenericTransformFunction<T, O>;
9
- constructor(transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<ValueType<T>>);
10
- transform(value: T): TransformResult<O>;
11
- }
12
- export declare function Transform<T, O>(transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<AbstractConstructor<T>>): Decorator<'property' | 'accessor'>;
@@ -1,18 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaValueTransformerDecorator } from '../decorators/index.js';
3
- import { SchemaValueTransformer } from '../types/index.js';
4
- export class GenericTransformer extends SchemaValueTransformer {
5
- sourceType;
6
- transformFunction;
7
- constructor(transformFunction, sourceType) {
8
- super();
9
- this.sourceType = sourceType;
10
- this.transformFunction = transformFunction;
11
- }
12
- transform(value) {
13
- return this.transformFunction(value);
14
- }
15
- }
16
- export function Transform(transformFunction, sourceType) {
17
- return createSchemaValueTransformerDecorator(new GenericTransformer(transformFunction, sourceType));
18
- }
@@ -1,4 +0,0 @@
1
- export * from './generic.js';
2
- export * from './lowercase.js';
3
- export * from './trim.js';
4
- export * from './uppercase.js';
@@ -1,4 +0,0 @@
1
- export * from './generic.js';
2
- export * from './lowercase.js';
3
- export * from './trim.js';
4
- export * from './uppercase.js';
@@ -1,8 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { TransformResult } from '../types/index.js';
3
- import { SchemaValueTransformer } from '../types/index.js';
4
- export declare class LowercaseTransformer extends SchemaValueTransformer<string, string> {
5
- readonly sourceType: StringConstructor;
6
- transform(value: string): TransformResult<string>;
7
- }
8
- export declare function Lowercase(): Decorator<'property' | 'accessor'>;
@@ -1,12 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaValueTransformerDecorator } from '../decorators/index.js';
3
- import { SchemaValueTransformer, typeSchema } from '../types/index.js';
4
- export class LowercaseTransformer extends SchemaValueTransformer {
5
- sourceType = String;
6
- transform(value) {
7
- return value.toLowerCase();
8
- }
9
- }
10
- export function Lowercase() {
11
- return createSchemaValueTransformerDecorator(new LowercaseTransformer(), { schema: typeSchema(String) });
12
- }
@@ -1,8 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { TransformResult } from '../types/index.js';
3
- import { SchemaValueTransformer } from '../types/index.js';
4
- export declare class TrimTransformer extends SchemaValueTransformer<string, string> {
5
- readonly sourceType: StringConstructor;
6
- transform(value: string): TransformResult<string>;
7
- }
8
- export declare function Trim(): Decorator<'property' | 'accessor'>;
@@ -1,12 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaValueTransformerDecorator } from '../decorators/index.js';
3
- import { SchemaValueTransformer, typeSchema } from '../types/index.js';
4
- export class TrimTransformer extends SchemaValueTransformer {
5
- sourceType = String;
6
- transform(value) {
7
- return value.trim();
8
- }
9
- }
10
- export function Trim() {
11
- return createSchemaValueTransformerDecorator(new TrimTransformer(), { schema: typeSchema(String) });
12
- }
@@ -1,8 +0,0 @@
1
- import type { Decorator } from '../../reflection/index.js';
2
- import type { TransformResult } from '../types/index.js';
3
- import { SchemaValueTransformer } from '../types/index.js';
4
- export declare class UppercaseTransformer extends SchemaValueTransformer<string, string> {
5
- readonly sourceType: StringConstructor;
6
- transform(value: string): TransformResult<string>;
7
- }
8
- export declare function Uppercase(): Decorator<'property' | 'accessor'>;
@@ -1,12 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createSchemaValueTransformerDecorator } from '../decorators/index.js';
3
- import { SchemaValueTransformer, typeSchema } from '../types/index.js';
4
- export class UppercaseTransformer extends SchemaValueTransformer {
5
- sourceType = String;
6
- transform(value) {
7
- return value.toUpperCase();
8
- }
9
- }
10
- export function Uppercase() {
11
- return createSchemaValueTransformerDecorator(new UppercaseTransformer(), { schema: typeSchema(String) });
12
- }
@@ -1,5 +0,0 @@
1
- export * from './schema-array-constraint.js';
2
- export * from './schema-value-coercer.js';
3
- export * from './schema-value-constraint.js';
4
- export * from './schema-value-transformer.js';
5
- export * from './types.js';
@@ -1,5 +0,0 @@
1
- export * from './schema-array-constraint.js';
2
- export * from './schema-value-coercer.js';
3
- export * from './schema-value-constraint.js';
4
- export * from './schema-value-transformer.js';
5
- export * from './types.js';
@@ -1,5 +0,0 @@
1
- import type { JsonPath } from '../../json-path/json-path.js';
2
- import type { ConstraintContext, ConstraintResult } from './types.js';
3
- export declare abstract class SchemaArrayConstraint {
4
- abstract validate(value: readonly unknown[], path: JsonPath, context: ConstraintContext): ConstraintResult;
5
- }
@@ -1,2 +0,0 @@
1
- export class SchemaArrayConstraint {
2
- }
@@ -1,8 +0,0 @@
1
- import type { JsonPath } from '../../json-path/json-path.js';
2
- import type { OneOrMany } from '../../types.js';
3
- import type { CoercerContext, CoerceResult, ValueType } from './types.js';
4
- export declare abstract class SchemaValueCoercer {
5
- abstract readonly sourceType: OneOrMany<ValueType>;
6
- abstract readonly targetType: ValueType;
7
- abstract coerce(value: unknown, path: JsonPath, context: CoercerContext): CoerceResult;
8
- }
@@ -1,2 +0,0 @@
1
- export class SchemaValueCoercer {
2
- }
@@ -1,8 +0,0 @@
1
- import type { JsonPath } from '../../json-path/json-path.js';
2
- import type { OneOrMany } from '../../types.js';
3
- import type { ConstraintContext, ConstraintResult, ValueType } from './types.js';
4
- export declare abstract class SchemaValueConstraint {
5
- abstract readonly suitableTypes: OneOrMany<ValueType>;
6
- abstract readonly expects: OneOrMany<string>;
7
- abstract validate(value: unknown, path: JsonPath, context: ConstraintContext): ConstraintResult;
8
- }
@@ -1,2 +0,0 @@
1
- export class SchemaValueConstraint {
2
- }
@@ -1,7 +0,0 @@
1
- import type { JsonPath } from '../../json-path/json-path.js';
2
- import type { OneOrMany } from '../../types.js';
3
- import type { TransformerContext, TransformResult, ValueType } from './types.js';
4
- export declare abstract class SchemaValueTransformer<T = any, O = any> {
5
- abstract readonly sourceType?: OneOrMany<ValueType<T>>;
6
- abstract transform(value: T, path: JsonPath, context: TransformerContext): TransformResult<O>;
7
- }
@@ -1,2 +0,0 @@
1
- export class SchemaValueTransformer {
2
- }