@tstdl/base 0.91.31 → 0.91.33
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
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,7 +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
|
-
export type SchemaPropertyDecoratorOptions =
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type SchemaPropertyDecoratorOptions = SchemaPropertyReflectionData;
|
|
7
|
+
export type SchemaPropertyDecoratorOptionsWithRequiredSchema = SetRequired<SchemaPropertyReflectionData, 'schema'>;
|
|
8
|
+
export type SchemaPropertyDecoratorOptionsWithoutSchema = TypedOmit<SchemaPropertyReflectionData, 'schema'>;
|
|
9
|
+
export declare function Property(schema: SchemaTestable, options?: SchemaPropertyDecoratorOptionsWithoutSchema): Decorator<'property' | 'accessor'>;
|
|
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/object.js
CHANGED
|
@@ -159,9 +159,12 @@ function getObjectSchemaPropertiesFromReflection(metadata, type) {
|
|
|
159
159
|
for (const [key, propertyMetadata] of metadata.properties) {
|
|
160
160
|
const reflectionData = propertyMetadata.data.tryGet('schema');
|
|
161
161
|
if (isUndefined(reflectionData?.schema) && (propertyMetadata.type == Object)) {
|
|
162
|
-
throw new Error(`Schema of property "${String(key)}" on type ${type.name} is inferred as Object. This is most likely unwanted and happens
|
|
162
|
+
throw new Error(`Schema of property "${String(key)}" on type ${type.name} is inferred as Object. This is most likely unwanted and happens if the property is defined as partial or the type is an union. Use an explicit @Property(Object) if this is wanted.`);
|
|
163
163
|
}
|
|
164
164
|
let propertySchema = reflectionData?.schema ?? propertyMetadata.type;
|
|
165
|
+
if (isUndefined(propertySchema)) {
|
|
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
|
+
}
|
|
165
168
|
if (reflectionData?.array == true) {
|
|
166
169
|
propertySchema = array(propertySchema);
|
|
167
170
|
}
|