@tstdl/base 0.91.32 → 0.91.34
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/package.json +1 -1
- package/password/password-check-result.model.js +2 -2
- package/schema/decorators/property.d.ts +3 -1
- package/schema/decorators/property.js +1 -1
- package/schema/schemas/array.js +2 -1
- package/schema/schemas/defaulted.js +2 -1
- package/schema/schemas/enumeration.js +2 -1
- package/schema/schemas/instance.js +2 -1
- package/schema/schemas/literal.js +2 -1
- package/schema/schemas/nullable.js +2 -1
- package/schema/schemas/object.js +1 -1
- package/schema/schemas/one-or-many.js +2 -1
- package/schema/schemas/optional.js +2 -1
- package/schema/schemas/transform.js +2 -1
- package/schema/schemas/union.js +2 -1
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { NumberProperty } from '../schema/index.js';
|
|
11
11
|
import { Array } from '../schema/schemas/array.js';
|
|
12
12
|
import { Enumeration } from '../schema/schemas/enumeration.js';
|
|
13
13
|
export var PasswordStrength;
|
|
@@ -33,7 +33,7 @@ __decorate([
|
|
|
33
33
|
__metadata("design:type", Number)
|
|
34
34
|
], PasswordCheckResult.prototype, "strength", void 0);
|
|
35
35
|
__decorate([
|
|
36
|
-
|
|
36
|
+
NumberProperty({ optional: true }),
|
|
37
37
|
__metadata("design:type", Number)
|
|
38
38
|
], PasswordCheckResult.prototype, "pwned", void 0);
|
|
39
39
|
__decorate([
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { SetRequired } from 'type-fest';
|
|
1
2
|
import type { Decorator } from '../../reflection/index.js';
|
|
2
3
|
import type { TypedOmit } from '../../types.js';
|
|
3
4
|
import type { SchemaTestable } from '../schema.js';
|
|
4
5
|
import type { SchemaPropertyReflectionData } from './types.js';
|
|
5
6
|
export type SchemaPropertyDecoratorOptions = SchemaPropertyReflectionData;
|
|
7
|
+
export type SchemaPropertyDecoratorOptionsWithRequiredSchema = SetRequired<SchemaPropertyReflectionData, 'schema'>;
|
|
6
8
|
export type SchemaPropertyDecoratorOptionsWithoutSchema = TypedOmit<SchemaPropertyReflectionData, 'schema'>;
|
|
7
9
|
export declare function Property(schema: SchemaTestable, options?: SchemaPropertyDecoratorOptionsWithoutSchema): Decorator<'property' | 'accessor'>;
|
|
8
|
-
export declare function Property(options:
|
|
10
|
+
export declare function Property(options: SchemaPropertyDecoratorOptionsWithRequiredSchema): Decorator<'property' | 'accessor'>;
|
|
@@ -4,7 +4,7 @@ import { isSchemaTestable } from '../testable.js';
|
|
|
4
4
|
import { createSchemaPropertyDecorator } from './utils.js';
|
|
5
5
|
export function Property(schemaOrOptions, optionsOrNothing) {
|
|
6
6
|
if (isDefined(optionsOrNothing)) {
|
|
7
|
-
return createSchemaPropertyDecorator({ schema: schemaOrOptions
|
|
7
|
+
return createSchemaPropertyDecorator({ ...optionsOrNothing, schema: schemaOrOptions });
|
|
8
8
|
}
|
|
9
9
|
if (isSchemaTestable(schemaOrOptions)) {
|
|
10
10
|
return createSchemaPropertyDecorator({ schema: schemaOrOptions });
|
package/schema/schemas/array.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SchemaError } from '../../schema/schema.error.js';
|
|
2
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
2
3
|
import { isArray } from '../../utils/type-guards.js';
|
|
3
4
|
import { typeOf } from '../../utils/type-of.js';
|
|
4
5
|
import { Property } from '../decorators/index.js';
|
|
@@ -12,7 +13,7 @@ export class ArraySchema extends Schema {
|
|
|
12
13
|
super();
|
|
13
14
|
this.#options = options;
|
|
14
15
|
this.itemSchema = schemaTestableToSchema(itemSchema);
|
|
15
|
-
this
|
|
16
|
+
lazyProperty(this, 'name', () => `Array[${this.itemSchema.name}]`);
|
|
16
17
|
}
|
|
17
18
|
_test(value, path, options) {
|
|
18
19
|
if (!isArray(value)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { isNullOrUndefined } from '../../utils/type-guards.js';
|
|
2
3
|
import { Property } from '../decorators/index.js';
|
|
3
4
|
import { Schema } from '../schema.js';
|
|
@@ -10,7 +11,7 @@ export class DefaultSchema extends Schema {
|
|
|
10
11
|
super();
|
|
11
12
|
this.schema = schemaTestableToSchema(schema);
|
|
12
13
|
this.defaultValue = defaultValue;
|
|
13
|
-
this
|
|
14
|
+
lazyProperty(this, 'name', () => `Defaulted[${this.schema.name}]`);
|
|
14
15
|
}
|
|
15
16
|
_test(value, path, options) {
|
|
16
17
|
if (isNullOrUndefined(value)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { enumValues } from '../../utils/enum.js';
|
|
2
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
2
3
|
import { isArray, isString } from '../../utils/type-guards.js';
|
|
3
4
|
import { Property } from '../decorators/index.js';
|
|
4
5
|
import { SimpleSchema } from './simple.js';
|
|
@@ -18,7 +19,7 @@ export class EnumerationSchema extends SimpleSchema {
|
|
|
18
19
|
});
|
|
19
20
|
this.enumeration = enumeration;
|
|
20
21
|
this.#allowedValuesSet = new Set(allowedValues);
|
|
21
|
-
this
|
|
22
|
+
lazyProperty(this, 'name', () => `Enumeration[${allowedValuesString}]`);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
export function enumeration(enumeration, options) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { typeOf } from '../../utils/type-of.js';
|
|
2
3
|
import { Property } from '../decorators/index.js';
|
|
3
4
|
import { SchemaError } from '../schema.error.js';
|
|
@@ -8,7 +9,7 @@ export class InstanceSchema extends Schema {
|
|
|
8
9
|
constructor(type) {
|
|
9
10
|
super();
|
|
10
11
|
this.type = type;
|
|
11
|
-
this
|
|
12
|
+
lazyProperty(this, 'name', () => `Instance[${type.name}]`);
|
|
12
13
|
}
|
|
13
14
|
_test(value, path, options) {
|
|
14
15
|
if (value instanceof this.type) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { isPrimitive } from '../../utils/type-guards.js';
|
|
2
3
|
import { typeOf } from '../../utils/type-of.js';
|
|
3
4
|
import { Property } from '../decorators/index.js';
|
|
@@ -9,7 +10,7 @@ export class LiteralSchema extends Schema {
|
|
|
9
10
|
constructor(value) {
|
|
10
11
|
super();
|
|
11
12
|
this.value = value;
|
|
12
|
-
this
|
|
13
|
+
lazyProperty(this, 'name', () => `Literal[${String(value)}]`);
|
|
13
14
|
}
|
|
14
15
|
_test(value, path, options) {
|
|
15
16
|
if (value === this.value) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { isNull } from '../../utils/type-guards.js';
|
|
2
3
|
import { createSchemaPropertyDecorator } from '../decorators/index.js';
|
|
3
4
|
import { Schema } from '../schema.js';
|
|
@@ -11,7 +12,7 @@ export class NullableSchema extends Schema {
|
|
|
11
12
|
}
|
|
12
13
|
super();
|
|
13
14
|
this.schema = schemaTestableToSchema(schema);
|
|
14
|
-
this
|
|
15
|
+
lazyProperty(this, 'name', () => `Nullable[${this.schema.name}]`);
|
|
15
16
|
}
|
|
16
17
|
_test(value, path, options) {
|
|
17
18
|
if (isNull(value)) {
|
package/schema/schemas/object.js
CHANGED
|
@@ -163,7 +163,7 @@ function getObjectSchemaPropertiesFromReflection(metadata, type) {
|
|
|
163
163
|
}
|
|
164
164
|
let propertySchema = reflectionData?.schema ?? propertyMetadata.type;
|
|
165
165
|
if (isUndefined(propertySchema)) {
|
|
166
|
-
throw new Error(`Could not infer schema for "${String(key)}" on type ${type.name}. This happens if neither explicit @Property(type) is used nor reflection metadata is available.`);
|
|
166
|
+
throw new Error(`Could not infer schema for property "${String(key)}" on type ${type.name}. This happens if neither explicit @Property(type) is used nor reflection metadata is available.`);
|
|
167
167
|
}
|
|
168
168
|
if (reflectionData?.array == true) {
|
|
169
169
|
propertySchema = array(propertySchema);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { Property } from '../decorators/index.js';
|
|
2
3
|
import { Schema } from '../schema.js';
|
|
3
4
|
import { schemaTestableToSchema } from '../testable.js';
|
|
@@ -10,7 +11,7 @@ export class OneOrManySchema extends Schema {
|
|
|
10
11
|
super();
|
|
11
12
|
const oneSchema = schemaTestableToSchema(schema);
|
|
12
13
|
this.schema = union(oneSchema, array(oneSchema));
|
|
13
|
-
this
|
|
14
|
+
lazyProperty(this, 'name', () => `OneOrMany[${oneSchema.name}]`);
|
|
14
15
|
}
|
|
15
16
|
_test(value, path, options) {
|
|
16
17
|
return this.schema._test(value, path, options);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { isUndefined } from '../../utils/type-guards.js';
|
|
2
3
|
import { createSchemaPropertyDecorator } from '../decorators/index.js';
|
|
3
4
|
import { Schema } from '../schema.js';
|
|
@@ -11,7 +12,7 @@ export class OptionalSchema extends Schema {
|
|
|
11
12
|
}
|
|
12
13
|
super();
|
|
13
14
|
this.schema = schemaTestableToSchema(schema);
|
|
14
|
-
this
|
|
15
|
+
lazyProperty(this, 'name', () => `Optional[${this.schema.name}]`);
|
|
15
16
|
}
|
|
16
17
|
_test(value, path, options) {
|
|
17
18
|
if (isUndefined(value)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { Schema } from '../schema.js';
|
|
2
3
|
import { schemaTestableToSchema } from '../testable.js';
|
|
3
4
|
export class TransformSchema extends Schema {
|
|
@@ -8,7 +9,7 @@ export class TransformSchema extends Schema {
|
|
|
8
9
|
super();
|
|
9
10
|
this.schema = schemaTestableToSchema(schema);
|
|
10
11
|
this.transformFn = transformFn;
|
|
11
|
-
this
|
|
12
|
+
lazyProperty(this, 'name', () => `Transform[${this.schema.name}]`);
|
|
12
13
|
}
|
|
13
14
|
_test(value, path, options) {
|
|
14
15
|
const result = this.schema._test(value, path, options);
|
package/schema/schemas/union.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lazyProperty } from '../../utils/object/lazy-property.js';
|
|
1
2
|
import { Property } from '../decorators/index.js';
|
|
2
3
|
import { SchemaError } from '../schema.error.js';
|
|
3
4
|
import { Schema } from '../schema.js';
|
|
@@ -14,7 +15,7 @@ export class UnionSchema extends Schema {
|
|
|
14
15
|
}
|
|
15
16
|
return schema;
|
|
16
17
|
});
|
|
17
|
-
this
|
|
18
|
+
lazyProperty(this, 'name', () => `Union[${this.schemas.map((schema) => schema.name).join(', ')}]`);
|
|
18
19
|
}
|
|
19
20
|
_test(value, path, options) {
|
|
20
21
|
const errors = [];
|