@travetto/schema 3.1.0-rc.2 → 3.1.0-rc.4

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.0-rc.2",
3
+ "version": "3.1.0-rc.4",
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.0-rc.0"
30
+ "@travetto/registry": "^3.1.0-rc.2"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/transformer": "^3.1.0-rc.1"
33
+ "@travetto/transformer": "^3.1.0-rc.2"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "@travetto/transformer": {
@@ -28,12 +28,12 @@ function prop<V>(obj: Partial<FieldConfig>): PropType<V> {
28
28
  * @param config The field configuration
29
29
  * @augments `@travetto/schema:Field`
30
30
  */
31
- export function Field(type: ClassList, config?: Partial<FieldConfig>) {
31
+ export function Field(type: ClassList, ...config: Partial<FieldConfig>[]) {
32
32
  return (f: ClassInstance, k: string, idx?: number): void => {
33
33
  if (idx !== undefined && typeof idx === 'number') {
34
- SchemaRegistry.registerPendingParamConfig(f.constructor, k, idx, type, config);
34
+ SchemaRegistry.registerPendingParamConfig(f.constructor, k, idx, type, Object.assign({}, ...config));
35
35
  } else {
36
- SchemaRegistry.registerPendingFieldConfig(f.constructor, k, type, config);
36
+ SchemaRegistry.registerPendingFieldConfig(f.constructor, k, type, Object.assign({}, ...config));
37
37
  }
38
38
  };
39
39
  }
@@ -44,6 +44,12 @@ export function Field(type: ClassList, config?: Partial<FieldConfig>) {
44
44
  * @augments `@travetto/schema:Field`
45
45
  */
46
46
  export function Alias(...aliases: string[]): PropType<unknown> { return prop({ aliases }); }
47
+ /**
48
+ * Specifier for the field
49
+ * @param specifier The specifier for a field
50
+ * @augments `@travetto/schema:Field`
51
+ */
52
+ export function Specifier(specifier: string): PropType<unknown> { return prop({ specifier }); }
47
53
  /**
48
54
  * Mark a field as writeonly
49
55
  * @param active This determines if this field is readonly or not.
@@ -140,12 +140,18 @@ export class SchemaTransformUtil {
140
140
  if (!existing) {
141
141
  const resolved = this.toConcreteType(state, typeExpr, node, config.root);
142
142
  params.push(resolved);
143
+ if (attrs.length) {
144
+ params.push(state.factory.createObjectLiteralExpression(attrs));
145
+ }
143
146
  } else {
144
- params.push(...DecoratorUtil.getArguments(existing) ?? []);
145
- }
146
-
147
- if (attrs.length) {
148
- params.push(state.factory.createObjectLiteralExpression(attrs));
147
+ const args = DecoratorUtil.getArguments(existing) ?? [];
148
+ if (args.length > 0) {
149
+ params.push(args[0]);
150
+ }
151
+ params.push(state.extendObjectLiteral(state.factory.createObjectLiteralExpression(attrs)));
152
+ if (args.length > 1) {
153
+ params.push(...args.slice(1));
154
+ }
149
155
  }
150
156
 
151
157
  const newModifiers = [