@travetto/schema 3.1.3 → 3.1.5
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/schema",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "Data type registry for runtime validation, reflection and binding.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"schema",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"directory": "module/schema"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/registry": "^3.1.
|
|
30
|
+
"@travetto/registry": "^3.1.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@travetto/transformer": "^3.1.
|
|
33
|
+
"@travetto/transformer": "^3.1.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@travetto/transformer": {
|
package/src/decorator/schema.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { ValidatorFn } from '../validate/types';
|
|
|
11
11
|
*
|
|
12
12
|
* @augments `@travetto/schema:Schema`
|
|
13
13
|
*/
|
|
14
|
-
export function Schema(cfg?: Partial<Pick<ClassConfig, 'subTypeField' | 'baseType'>>) { // Auto is used during compilation
|
|
14
|
+
export function Schema(cfg?: Partial<Pick<ClassConfig, 'subTypeName' | 'subTypeField' | 'baseType'>>) { // Auto is used during compilation
|
|
15
15
|
return <T, U extends Class<T>>(target: U): U => {
|
|
16
16
|
target.from ??= function <V>(this: Class<V>, data: DeepPartial<V>, view?: string): V {
|
|
17
17
|
return BindUtil.bindSchema(this, data, { view });
|
|
@@ -49,8 +49,8 @@ export function View<T>(name: string, fields: ViewFieldsConfig<Partial<T>>) {
|
|
|
49
49
|
* @param name
|
|
50
50
|
* @returns
|
|
51
51
|
*/
|
|
52
|
-
export function SubType<T>(name
|
|
52
|
+
export function SubType<T>(name: string) {
|
|
53
53
|
return (target: Class<Partial<T>>): void => {
|
|
54
|
-
SchemaRegistry.
|
|
54
|
+
SchemaRegistry.register(target, { subTypeName: name });
|
|
55
55
|
};
|
|
56
56
|
}
|
package/src/service/registry.ts
CHANGED
|
@@ -43,14 +43,6 @@ class $SchemaRegistry extends MetadataRegistry<ClassConfig, FieldConfig> {
|
|
|
43
43
|
return this.#baseSchema.get(cls)!;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* Get subtype name for a class
|
|
48
|
-
* @param cls Base class
|
|
49
|
-
*/
|
|
50
|
-
getSubTypeName(cls: Class): string | undefined {
|
|
51
|
-
return this.get(cls).subTypeName;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
46
|
/**
|
|
55
47
|
* Retrieve class level metadata
|
|
56
48
|
* @param cls
|