@tstdl/base 0.90.92 → 0.91.0-beta1
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.
- package/api/types.d.ts +1 -1
- package/authentication/authentication.api.d.ts +21 -22
- package/authentication/authentication.api.js +1 -6
- package/authentication/client/api.client.d.ts +4 -5
- package/authentication/client/api.client.js +1 -2
- package/authentication/client/http-client.middleware.d.ts +1 -1
- package/browser/pdf-options.js +8 -9
- package/errors/custom.error.d.ts +5 -5
- package/examples/api/basic-overview.js +4 -4
- package/http/client/http-client-request.d.ts +1 -2
- package/http/client/module.d.ts +1 -1
- package/image-service/image-service.js +4 -7
- package/mail/mail.client.d.ts +2 -2
- package/mail/mail.client.js +3 -5
- package/orm/decorators.d.ts +1 -0
- package/orm/decorators.js +4 -0
- package/orm/entity.js +3 -3
- package/orm/index.d.ts +4 -0
- package/orm/index.js +4 -0
- package/orm/repository.d.ts +6 -8
- package/orm/repository.js +7 -0
- package/orm/schema-converter.d.ts +83 -0
- package/orm/schema-converter.js +74 -0
- package/orm/schema.d.ts +3 -0
- package/orm/schema.js +1 -0
- package/orm/types.d.ts +8 -0
- package/orm/types.js +6 -0
- package/package.json +6 -4
- package/reflection/registry.d.ts +1 -1
- package/reflection/utils.d.ts +2 -2
- package/schema/decorators/class.d.ts +1 -1
- package/schema/decorators/index.d.ts +0 -2
- package/schema/decorators/index.js +0 -2
- package/schema/decorators/property.d.ts +6 -5
- package/schema/decorators/property.js +10 -14
- package/schema/decorators/types.d.ts +7 -12
- package/schema/decorators/utils.d.ts +2 -15
- package/schema/decorators/utils.js +3 -43
- package/schema/index.d.ts +1 -6
- package/schema/index.js +15 -6
- package/schema/schema.d.ts +89 -14
- package/schema/schema.error.d.ts +4 -6
- package/schema/schema.error.js +6 -10
- package/schema/schema.js +74 -276
- package/schema/schemas/any.d.ts +7 -5
- package/schema/schemas/any.js +10 -6
- package/schema/schemas/array.d.ts +10 -12
- package/schema/schemas/array.js +27 -19
- package/schema/schemas/bigint.d.ts +8 -0
- package/schema/schemas/bigint.js +19 -0
- package/schema/schemas/boolean.d.ts +15 -5
- package/schema/schemas/boolean.js +47 -6
- package/schema/schemas/date.d.ts +9 -7
- package/schema/schemas/date.js +25 -19
- package/schema/schemas/defaulted.d.ts +11 -6
- package/schema/schemas/defaulted.js +23 -8
- package/schema/schemas/enumeration.d.ts +10 -5
- package/schema/schemas/enumeration.js +25 -15
- package/schema/schemas/index.d.ts +4 -6
- package/schema/schemas/index.js +4 -6
- package/schema/schemas/instance.d.ts +11 -3
- package/schema/schemas/instance.js +25 -4
- package/schema/schemas/literal.d.ts +10 -5
- package/schema/schemas/literal.js +25 -15
- package/schema/schemas/never.d.ts +6 -0
- package/schema/schemas/never.js +11 -0
- package/schema/schemas/nullable.d.ts +10 -6
- package/schema/schemas/nullable.js +24 -7
- package/schema/schemas/number.d.ts +13 -7
- package/schema/schemas/number.js +34 -23
- package/schema/schemas/object.d.ts +75 -7
- package/schema/schemas/object.js +171 -6
- package/schema/schemas/one-or-many.d.ts +10 -7
- package/schema/schemas/one-or-many.js +18 -11
- package/schema/schemas/optional.d.ts +10 -7
- package/schema/schemas/optional.js +21 -3
- package/schema/schemas/readable-stream.d.ts +8 -6
- package/schema/schemas/readable-stream.js +11 -6
- package/schema/schemas/regexp.d.ts +8 -6
- package/schema/schemas/regexp.js +25 -7
- package/schema/schemas/simple.d.ts +27 -0
- package/schema/schemas/simple.js +57 -0
- package/schema/schemas/string.d.ts +13 -21
- package/schema/schemas/string.js +26 -34
- package/schema/schemas/symbol.d.ts +12 -0
- package/schema/schemas/symbol.js +25 -0
- package/schema/schemas/transform.d.ts +9 -5
- package/schema/schemas/transform.js +19 -6
- package/schema/schemas/uint8-array.d.ts +9 -5
- package/schema/schemas/uint8-array.js +17 -26
- package/schema/schemas/union.d.ts +14 -7
- package/schema/schemas/union.js +30 -11
- package/schema/schemas/unknown.d.ts +7 -5
- package/schema/schemas/unknown.js +11 -7
- package/schema/testable.d.ts +3 -0
- package/schema/testable.js +30 -0
- package/schema/types.d.ts +31 -0
- package/schema/types.js +1 -0
- package/schema-old/decorators/class.d.ts +3 -0
- package/schema-old/decorators/class.js +5 -0
- package/schema-old/decorators/index.d.ts +6 -0
- package/schema-old/decorators/index.js +6 -0
- package/schema-old/decorators/property.d.ts +6 -0
- package/schema-old/decorators/property.js +17 -0
- package/schema-old/decorators/types.d.ts +19 -0
- package/schema-old/decorators/types.js +1 -0
- package/schema-old/decorators/utils.d.ts +15 -0
- package/schema-old/decorators/utils.js +48 -0
- package/schema-old/index.d.ts +10 -0
- package/schema-old/index.js +10 -0
- package/schema-old/schema.d.ts +15 -0
- package/schema-old/schema.error.d.ts +26 -0
- package/schema-old/schema.error.js +64 -0
- package/schema-old/schema.js +283 -0
- package/schema-old/schemas/any.d.ts +5 -0
- package/schema-old/schemas/any.js +9 -0
- package/schema-old/schemas/array.d.ts +12 -0
- package/schema-old/schemas/array.js +23 -0
- package/schema-old/schemas/boolean.d.ts +5 -0
- package/schema-old/schemas/boolean.js +9 -0
- package/schema-old/schemas/date.d.ts +8 -0
- package/schema-old/schemas/date.js +22 -0
- package/schema-old/schemas/defaulted.d.ts +6 -0
- package/schema-old/schemas/defaulted.js +10 -0
- package/schema-old/schemas/enumeration.d.ts +6 -0
- package/schema-old/schemas/enumeration.js +17 -0
- package/schema-old/schemas/index.d.ts +26 -0
- package/schema-old/schemas/index.js +26 -0
- package/schema-old/schemas/instance.d.ts +3 -0
- package/schema-old/schemas/instance.js +5 -0
- package/schema-old/schemas/literal.d.ts +5 -0
- package/schema-old/schemas/literal.js +17 -0
- package/schema-old/schemas/nullable.d.ts +6 -0
- package/schema-old/schemas/nullable.js +9 -0
- package/schema-old/schemas/number.d.ts +9 -0
- package/schema-old/schemas/number.js +27 -0
- package/schema-old/schemas/object.d.ts +7 -0
- package/schema-old/schemas/object.js +12 -0
- package/schema-old/schemas/one-or-many.d.ts +9 -0
- package/schema-old/schemas/one-or-many.js +15 -0
- package/schema-old/schemas/optional.d.ts +7 -0
- package/schema-old/schemas/optional.js +8 -0
- package/schema-old/schemas/readable-stream.d.ts +6 -0
- package/schema-old/schemas/readable-stream.js +9 -0
- package/schema-old/schemas/regexp.d.ts +6 -0
- package/schema-old/schemas/regexp.js +9 -0
- package/schema-old/schemas/string.d.ts +22 -0
- package/schema-old/schemas/string.js +38 -0
- package/schema-old/schemas/transform.d.ts +5 -0
- package/schema-old/schemas/transform.js +7 -0
- package/schema-old/schemas/uint8-array.d.ts +10 -0
- package/schema-old/schemas/uint8-array.js +29 -0
- package/schema-old/schemas/union.d.ts +7 -0
- package/schema-old/schemas/union.js +13 -0
- package/schema-old/schemas/unknown.d.ts +5 -0
- package/schema-old/schemas/unknown.js +9 -0
- package/templates/resolvers/string.template-resolver.d.ts +0 -1
- package/templates/resolvers/string.template-resolver.js +1 -5
- package/templates/template.model.js +1 -1
- package/types.d.ts +2 -0
- package/utils/type-guards.js +1 -1
- /package/{schema → schema-old}/array-constraints/index.d.ts +0 -0
- /package/{schema → schema-old}/array-constraints/index.js +0 -0
- /package/{schema → schema-old}/array-constraints/maximum-length.d.ts +0 -0
- /package/{schema → schema-old}/array-constraints/maximum-length.js +0 -0
- /package/{schema → schema-old}/array-constraints/minimum-length.d.ts +0 -0
- /package/{schema → schema-old}/array-constraints/minimum-length.js +0 -0
- /package/{schema → schema-old}/coercers/boolean.coercer.d.ts +0 -0
- /package/{schema → schema-old}/coercers/boolean.coercer.js +0 -0
- /package/{schema → schema-old}/coercers/date.coercer.d.ts +0 -0
- /package/{schema → schema-old}/coercers/date.coercer.js +0 -0
- /package/{schema → schema-old}/coercers/index.d.ts +0 -0
- /package/{schema → schema-old}/coercers/index.js +0 -0
- /package/{schema → schema-old}/coercers/number.coercer.d.ts +0 -0
- /package/{schema → schema-old}/coercers/number.coercer.js +0 -0
- /package/{schema → schema-old}/coercers/regexp.coercer.d.ts +0 -0
- /package/{schema → schema-old}/coercers/regexp.coercer.js +0 -0
- /package/{schema → schema-old}/coercers/string.coercer.d.ts +0 -0
- /package/{schema → schema-old}/coercers/string.coercer.js +0 -0
- /package/{schema → schema-old}/coercers/uint8-array.coercer.d.ts +0 -0
- /package/{schema → schema-old}/coercers/uint8-array.coercer.js +0 -0
- /package/{schema → schema-old}/constraints/enumeration.d.ts +0 -0
- /package/{schema → schema-old}/constraints/enumeration.js +0 -0
- /package/{schema → schema-old}/constraints/generic.d.ts +0 -0
- /package/{schema → schema-old}/constraints/generic.js +0 -0
- /package/{schema → schema-old}/constraints/index.d.ts +0 -0
- /package/{schema → schema-old}/constraints/index.js +0 -0
- /package/{schema → schema-old}/constraints/integer.d.ts +0 -0
- /package/{schema → schema-old}/constraints/integer.js +0 -0
- /package/{schema → schema-old}/constraints/length.d.ts +0 -0
- /package/{schema → schema-old}/constraints/length.js +0 -0
- /package/{schema → schema-old}/constraints/literal.d.ts +0 -0
- /package/{schema → schema-old}/constraints/literal.js +0 -0
- /package/{schema → schema-old}/constraints/maximum-date.d.ts +0 -0
- /package/{schema → schema-old}/constraints/maximum-date.js +0 -0
- /package/{schema → schema-old}/constraints/maximum-length.d.ts +0 -0
- /package/{schema → schema-old}/constraints/maximum-length.js +0 -0
- /package/{schema → schema-old}/constraints/maximum.d.ts +0 -0
- /package/{schema → schema-old}/constraints/maximum.js +0 -0
- /package/{schema → schema-old}/constraints/minimum-date.d.ts +0 -0
- /package/{schema → schema-old}/constraints/minimum-date.js +0 -0
- /package/{schema → schema-old}/constraints/minimum-length.d.ts +0 -0
- /package/{schema → schema-old}/constraints/minimum-length.js +0 -0
- /package/{schema → schema-old}/constraints/minimum.d.ts +0 -0
- /package/{schema → schema-old}/constraints/minimum.js +0 -0
- /package/{schema → schema-old}/constraints/pattern.d.ts +0 -0
- /package/{schema → schema-old}/constraints/pattern.js +0 -0
- /package/{schema → schema-old}/decorators/coerce.d.ts +0 -0
- /package/{schema → schema-old}/decorators/coerce.js +0 -0
- /package/{schema → schema-old}/decorators/constraint.d.ts +0 -0
- /package/{schema → schema-old}/decorators/constraint.js +0 -0
- /package/{schema → schema-old}/schemas/assign.d.ts +0 -0
- /package/{schema → schema-old}/schemas/assign.js +0 -0
- /package/{schema → schema-old}/schemas/constraint.d.ts +0 -0
- /package/{schema → schema-old}/schemas/constraint.js +0 -0
- /package/{schema → schema-old}/schemas/omit.d.ts +0 -0
- /package/{schema → schema-old}/schemas/omit.js +0 -0
- /package/{schema → schema-old}/schemas/partial.d.ts +0 -0
- /package/{schema → schema-old}/schemas/partial.js +0 -0
- /package/{schema → schema-old}/schemas/pick.d.ts +0 -0
- /package/{schema → schema-old}/schemas/pick.js +0 -0
- /package/{schema → schema-old}/schemas/record.d.ts +0 -0
- /package/{schema → schema-old}/schemas/record.js +0 -0
- /package/{schema → schema-old}/transformers/generic.d.ts +0 -0
- /package/{schema → schema-old}/transformers/generic.js +0 -0
- /package/{schema → schema-old}/transformers/index.d.ts +0 -0
- /package/{schema → schema-old}/transformers/index.js +0 -0
- /package/{schema → schema-old}/transformers/lowercase.d.ts +0 -0
- /package/{schema → schema-old}/transformers/lowercase.js +0 -0
- /package/{schema → schema-old}/transformers/trim.d.ts +0 -0
- /package/{schema → schema-old}/transformers/trim.js +0 -0
- /package/{schema → schema-old}/transformers/uppercase.d.ts +0 -0
- /package/{schema → schema-old}/transformers/uppercase.js +0 -0
- /package/{schema → schema-old}/types/index.d.ts +0 -0
- /package/{schema → schema-old}/types/index.js +0 -0
- /package/{schema → schema-old}/types/schema-array-constraint.d.ts +0 -0
- /package/{schema → schema-old}/types/schema-array-constraint.js +0 -0
- /package/{schema → schema-old}/types/schema-value-coercer.d.ts +0 -0
- /package/{schema → schema-old}/types/schema-value-coercer.js +0 -0
- /package/{schema → schema-old}/types/schema-value-constraint.d.ts +0 -0
- /package/{schema → schema-old}/types/schema-value-constraint.js +0 -0
- /package/{schema → schema-old}/types/schema-value-transformer.d.ts +0 -0
- /package/{schema → schema-old}/types/schema-value-transformer.js +0 -0
- /package/{schema → schema-old}/types/types.d.ts +0 -0
- /package/{schema → schema-old}/types/types.js +0 -0
- /package/{schema → schema-old}/utils/index.d.ts +0 -0
- /package/{schema → schema-old}/utils/index.js +0 -0
- /package/{schema → schema-old}/utils/schema.d.ts +0 -0
- /package/{schema → schema-old}/utils/schema.js +0 -0
- /package/{schema → schema-old}/utils/value-type.d.ts +0 -0
- /package/{schema → schema-old}/utils/value-type.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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'>;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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'>;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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'>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|
|
@@ -7,7 +7,6 @@ export declare class StringTemplateField<Renderer extends string = string, Optio
|
|
|
7
7
|
template: StringTemplate<Context>;
|
|
8
8
|
}
|
|
9
9
|
export declare class StringTemplateResolver extends TemplateResolver<StringTemplateField> {
|
|
10
|
-
constructor();
|
|
11
10
|
canHandle(resolver: string): boolean;
|
|
12
11
|
resolve(field: StringTemplateField): StringTemplate<Record>;
|
|
13
12
|
}
|
|
@@ -19,9 +19,6 @@ __decorate([
|
|
|
19
19
|
__metadata("design:type", Object)
|
|
20
20
|
], StringTemplateField.prototype, "template", void 0);
|
|
21
21
|
let StringTemplateResolver = class StringTemplateResolver extends TemplateResolver {
|
|
22
|
-
constructor() {
|
|
23
|
-
super();
|
|
24
|
-
}
|
|
25
22
|
canHandle(resolver) {
|
|
26
23
|
return (resolver == 'string');
|
|
27
24
|
}
|
|
@@ -30,8 +27,7 @@ let StringTemplateResolver = class StringTemplateResolver extends TemplateResolv
|
|
|
30
27
|
}
|
|
31
28
|
};
|
|
32
29
|
StringTemplateResolver = __decorate([
|
|
33
|
-
Singleton()
|
|
34
|
-
__metadata("design:paramtypes", [])
|
|
30
|
+
Singleton()
|
|
35
31
|
], StringTemplateResolver);
|
|
36
32
|
export { StringTemplateResolver };
|
|
37
33
|
export function stringTemplateField(field) {
|
|
@@ -41,7 +41,7 @@ __decorate([
|
|
|
41
41
|
__metadata("design:type", String)
|
|
42
42
|
], Template.prototype, "name", void 0);
|
|
43
43
|
__decorate([
|
|
44
|
-
Property(
|
|
44
|
+
Property(object({}, { unknownProperties: TemplateField })),
|
|
45
45
|
__metadata("design:type", Object)
|
|
46
46
|
], Template.prototype, "fields", void 0);
|
|
47
47
|
__decorate([
|
package/types.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export type PrimitiveObject = {
|
|
|
28
28
|
};
|
|
29
29
|
export type PrimitiveArray = PrimitiveValue[];
|
|
30
30
|
export type BuiltIn = Primitive | RegExp | Date | Function;
|
|
31
|
+
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
31
32
|
export type Json = JsonPrimitive | JsonObject | JsonArray;
|
|
32
33
|
export type JsonPrimitive = string | number | boolean | null;
|
|
33
34
|
export type JsonObject = {
|
|
@@ -156,6 +157,7 @@ export type IfUnknown<T, Then, Else = never> = unknown extends T ? Then : Else;
|
|
|
156
157
|
export type IsAny<T> = IfAny<T, true, false>;
|
|
157
158
|
export type IsUnknown<T> = IfUnknown<T, true, false>;
|
|
158
159
|
export type If<B extends Boolean, Then, Else> = B extends true ? Then : Else;
|
|
160
|
+
export type Not<T extends boolean> = T extends true ? false : true;
|
|
159
161
|
export type Fallback<T, F> = [T] extends [never] ? F : T;
|
|
160
162
|
export type PartialProperty<T, P extends keyof T> = Omit<T, P> & Partial<Pick<T, P>>;
|
|
161
163
|
export type TypeOf<T extends object, P extends keyof T> = T[P];
|
package/utils/type-guards.js
CHANGED
|
@@ -62,7 +62,7 @@ export const assertNullOrUndefined = nullOrUndefinedGuards.assertNullOrUndefined
|
|
|
62
62
|
export const assertNotNullOrUndefined = nullOrUndefinedGuards.assertNotNullOrUndefined;
|
|
63
63
|
export const assertNullOrUndefinedPass = nullOrUndefinedGuards.assertNullOrUndefinedPass;
|
|
64
64
|
export const assertNotNullOrUndefinedPass = nullOrUndefinedGuards.assertNotNullOrUndefinedPass;
|
|
65
|
-
const numberGuards = createGuards('number', (value) => (typeof value == 'number'));
|
|
65
|
+
const numberGuards = createGuards('number', (value) => (typeof value == 'number') && !Number.isNaN(value));
|
|
66
66
|
export const isNumber = numberGuards.isNumber;
|
|
67
67
|
export const isNotNumber = numberGuards.isNotNumber;
|
|
68
68
|
export const assertNumber = numberGuards.assertNumber;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|