@travetto/schema 3.1.4 → 3.1.6
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 +3 -3
- package/src/bind-util.ts +4 -5
- package/src/service/registry.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/schema",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
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.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@travetto/transformer": "^3.1.
|
|
33
|
+
"@travetto/transformer": "^3.1.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@travetto/transformer": {
|
package/src/bind-util.ts
CHANGED
|
@@ -67,9 +67,7 @@ export class BindUtil {
|
|
|
67
67
|
sub = sub[name] as Record<string, unknown>;
|
|
68
68
|
|
|
69
69
|
if (idx && key !== undefined) {
|
|
70
|
-
|
|
71
|
-
sub[key] = {};
|
|
72
|
-
}
|
|
70
|
+
sub[key] ??= {};
|
|
73
71
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
74
72
|
sub = sub[key] as Record<string, unknown>;
|
|
75
73
|
}
|
|
@@ -85,6 +83,7 @@ export class BindUtil {
|
|
|
85
83
|
const arr = last.indexOf('[') > 0;
|
|
86
84
|
const name = last.split(/[^A-Za-z_0-9]/)[0];
|
|
87
85
|
const idx = arr ? last.split(/[\[\]]/)[1] : '';
|
|
86
|
+
|
|
88
87
|
let key = arr ? (/^\d+$/.test(idx) ? parseInt(idx, 10) : (idx.trim() || undefined)) : undefined;
|
|
89
88
|
if (sub[name] === undefined) {
|
|
90
89
|
sub[name] = (typeof key === 'string') ? {} : [];
|
|
@@ -123,11 +122,11 @@ export class BindUtil {
|
|
|
123
122
|
if (ObjectUtil.isPlainObject(v)) {
|
|
124
123
|
Object.assign(out, this.flattenPaths(v, `${pre}[${i}].`));
|
|
125
124
|
} else {
|
|
126
|
-
out[`${pre}[${i}]`] = v;
|
|
125
|
+
out[`${pre}[${i}]`] = v ?? '';
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
} else {
|
|
130
|
-
out[pre] = value;
|
|
129
|
+
out[pre] = value ?? '';
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
return out;
|
package/src/service/registry.ts
CHANGED
|
@@ -251,6 +251,9 @@ class $SchemaRegistry extends MetadataRegistry<ClassConfig, FieldConfig> {
|
|
|
251
251
|
registerPendingParamFacet(target: Class, method: string, idx: number, config: Partial<FieldConfig>): Class {
|
|
252
252
|
const methods = this.getOrCreatePending(target)!.methods!;
|
|
253
253
|
const params = (methods[method] ??= []);
|
|
254
|
+
if (config.name === '') {
|
|
255
|
+
delete config.name;
|
|
256
|
+
}
|
|
254
257
|
|
|
255
258
|
if (config.aliases) {
|
|
256
259
|
config.aliases = [...params[idx]?.aliases ?? [], ...config.aliases];
|