@travetto/schema
Advanced tools
Comparing version 3.1.0-rc.3 to 3.1.0-rc.4
{ | ||
"name": "@travetto/schema", | ||
"version": "3.1.0-rc.3", | ||
"version": "3.1.0-rc.4", | ||
"description": "Data type registry for runtime validation, reflection and binding.", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@travetto/registry": "^3.1.0-rc.1" | ||
"@travetto/registry": "^3.1.0-rc.2" | ||
}, | ||
@@ -33,0 +33,0 @@ "peerDependencies": { |
@@ -31,8 +31,8 @@ import { ClassInstance } from '@travetto/base'; | ||
*/ | ||
export function Field(type: ClassList, config?: Partial<FieldConfig>) { | ||
export function Field(type: ClassList, ...config: Partial<FieldConfig>[]) { | ||
return (f: ClassInstance, k: string, idx?: number): void => { | ||
if (idx !== undefined && typeof idx === 'number') { | ||
SchemaRegistry.registerPendingParamConfig(f.constructor, k, idx, type, config); | ||
SchemaRegistry.registerPendingParamConfig(f.constructor, k, idx, type, Object.assign({}, ...config)); | ||
} else { | ||
SchemaRegistry.registerPendingFieldConfig(f.constructor, k, type, config); | ||
SchemaRegistry.registerPendingFieldConfig(f.constructor, k, type, Object.assign({}, ...config)); | ||
} | ||
@@ -49,2 +49,8 @@ }; | ||
/** | ||
* Specifier for the field | ||
* @param specifier The specifier for a field | ||
* @augments `@travetto/schema:Field` | ||
*/ | ||
export function Specifier(specifier: string): PropType<unknown> { return prop({ specifier }); } | ||
/** | ||
* Mark a field as writeonly | ||
@@ -51,0 +57,0 @@ * @param active This determines if this field is readonly or not. |
@@ -143,10 +143,16 @@ import ts from 'typescript'; | ||
params.push(resolved); | ||
if (attrs.length) { | ||
params.push(state.factory.createObjectLiteralExpression(attrs)); | ||
} | ||
} else { | ||
params.push(...DecoratorUtil.getArguments(existing) ?? []); | ||
const args = DecoratorUtil.getArguments(existing) ?? []; | ||
if (args.length > 0) { | ||
params.push(args[0]); | ||
} | ||
params.push(state.extendObjectLiteral(state.factory.createObjectLiteralExpression(attrs))); | ||
if (args.length > 1) { | ||
params.push(...args.slice(1)); | ||
} | ||
} | ||
if (attrs.length) { | ||
params.push(state.factory.createObjectLiteralExpression(attrs)); | ||
} | ||
const newModifiers = [ | ||
@@ -153,0 +159,0 @@ ...(node.modifiers ?? []).filter(x => x !== existing), |
88112
1982