@travetto/schema 7.0.0-rc.1 → 7.0.0-rc.2

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.
@@ -3,7 +3,7 @@ import { Any, Class, Primitive } from '@travetto/runtime';
3
3
  import { MethodValidatorFn, ValidatorFn } from '../validate/types.ts';
4
4
 
5
5
  type TemplateLiteralPart = string | NumberConstructor | StringConstructor | BooleanConstructor;
6
- export type TemplateLiteral = { op: 'and' | 'or', values: (TemplateLiteralPart | TemplateLiteral)[] };
6
+ export type TemplateLiteral = { operation: 'and' | 'or', values: (TemplateLiteralPart | TemplateLiteral)[] };
7
7
 
8
8
  export const CONSTRUCTOR_PROPERTY = 'CONSTRUCTOR';
9
9
 
@@ -83,7 +83,7 @@ export interface SchemaFieldMap {
83
83
  /**
84
84
  * List of all fields
85
85
  */
86
- [key: string | symbol]: SchemaFieldConfig;
86
+ [key: string]: SchemaFieldConfig;
87
87
  }
88
88
 
89
89
  /**
@@ -121,7 +121,7 @@ export interface SchemaClassConfig extends SchemaCoreConfig {
121
121
  /**
122
122
  * Method configs
123
123
  */
124
- methods: Record<string | symbol, SchemaMethodConfig>;
124
+ methods: Record<string, SchemaMethodConfig>;
125
125
  /**
126
126
  * Interfaces that the class implements
127
127
  */
@@ -209,7 +209,7 @@ export interface SchemaParameterConfig extends SchemaInputConfig {
209
209
  /**
210
210
  * Method the parameter belongs to
211
211
  */
212
- method: string | symbol;
212
+ method: string;
213
213
  /**
214
214
  * Source text for the parameter
215
215
  */
@@ -223,7 +223,7 @@ export interface SchemaFieldConfig extends SchemaInputConfig {
223
223
  /**
224
224
  * Field name
225
225
  */
226
- name: string | symbol;
226
+ name: string;
227
227
  /**
228
228
  * Is the field readonly, or write only?, defaults to no restrictions
229
229
  */
package/src/types.ts CHANGED
@@ -3,6 +3,6 @@ export class UnknownType { }
3
3
  /**
4
4
  * Geometric Point as [number,number] with validation and binding support
5
5
  *
6
- * @concrete ./internal/types.ts#PointImpl
6
+ * @concrete ./internal/types.ts#PointImplementation
7
7
  */
8
8
  export type Point = [number, number];
@@ -22,6 +22,6 @@ export class TypeMismatchError extends AppError {
22
22
  }
23
23
  }
24
24
 
25
- export function isValidationError(err: unknown): err is ValidationError {
26
- return !!err && err instanceof Error && 'path' in err;
25
+ export function isValidationError(error: unknown): error is ValidationError {
26
+ return !!error && error instanceof Error && 'path' in error;
27
27
  }
@@ -15,8 +15,8 @@ export const CommonRegExp = {
15
15
  export const CommonRegExpToName = new Map<RegExp, string>();
16
16
 
17
17
  // Rebind regexes
18
- for (const k of TypedObject.keys(CommonRegExp)) {
19
- const name = `[[:${k}:]]`;
20
- CommonRegExpToName.set(CommonRegExp[k], name);
21
- Messages.set(name, Messages.get(k)!);
18
+ for (const key of TypedObject.keys(CommonRegExp)) {
19
+ const name = `[[:${key}:]]`;
20
+ CommonRegExpToName.set(CommonRegExp[key], name);
21
+ Messages.set(name, Messages.get(key)!);
22
22
  }
@@ -11,19 +11,19 @@ import { SchemaRegistryIndex } from '../service/registry-index.ts';
11
11
  /**
12
12
  * Get the schema config for Class/Schema config, including support for polymorphism
13
13
  * @param base The starting type or config
14
- * @param o The value to use for the polymorphic check
14
+ * @param item The item to use for the polymorphic check
15
15
  */
16
- function resolveFieldMap<T>(base: Class<T>, o: T): SchemaFieldMap {
17
- const target = SchemaRegistryIndex.resolveInstanceType(base, o);
16
+ function resolveFieldMap<T>(base: Class<T>, item: T): SchemaFieldMap {
17
+ const target = SchemaRegistryIndex.resolveInstanceType(base, item);
18
18
  return SchemaRegistryIndex.get(target).getFields();
19
19
  }
20
20
 
21
- function isClassInstance<T>(o: unknown): o is ClassInstance<T> {
22
- return !DataUtil.isPlainObject(o) && o !== null && typeof o === 'object' && !!o.constructor;
21
+ function isClassInstance<T>(value: unknown): value is ClassInstance<T> {
22
+ return !DataUtil.isPlainObject(value) && value !== null && typeof value === 'object' && !!value.constructor;
23
23
  }
24
24
 
25
- function isRangeValue(o: unknown): o is number | string | Date {
26
- return typeof o === 'string' || typeof o === 'number' || o instanceof Date;
25
+ function isRangeValue(value: unknown): value is number | string | Date {
26
+ return typeof value === 'string' || typeof value === 'number' || value instanceof Date;
27
27
  }
28
28
 
29
29
  /**
@@ -35,15 +35,15 @@ export class SchemaValidator {
35
35
  /**
36
36
  * Validate the schema for a given object
37
37
  * @param fields The config to validate against
38
- * @param o The object to validate
38
+ * @param item The object to validate
39
39
  * @param relative The relative path as the validation recurses
40
40
  */
41
- static #validateFields<T>(fields: SchemaFieldMap, o: T, relative: string): ValidationError[] {
41
+ static #validateFields<T>(fields: SchemaFieldMap, item: T, relative: string): ValidationError[] {
42
42
  let errors: ValidationError[] = [];
43
43
 
44
44
  for (const [field, fieldConfig] of TypedObject.entries(fields)) {
45
45
  if (fieldConfig.access !== 'readonly') { // Do not validate readonly fields
46
- errors = errors.concat(this.#validateInputSchema(fieldConfig, o[castKey<T>(field)], relative));
46
+ errors = errors.concat(this.#validateInputSchema(fieldConfig, item[castKey<T>(field)], relative));
47
47
  }
48
48
  }
49
49
 
@@ -53,13 +53,13 @@ export class SchemaValidator {
53
53
  /**
54
54
  * Validate a single input config against a passed in value
55
55
  * @param input The input schema configuration
56
- * @param val The raw value, could be an array or not
56
+ * @param value The raw value, could be an array or not
57
57
  * @param relative The relative path of object traversal
58
58
  */
59
- static #validateInputSchema(input: SchemaInputConfig, val: unknown, relative: string = ''): ValidationError[] {
59
+ static #validateInputSchema(input: SchemaInputConfig, value: unknown, relative: string = ''): ValidationError[] {
60
60
  const key = 'name' in input ? input.name : ('index' in input ? input.index : 'unknown');
61
61
  const path = `${relative}${relative ? '.' : ''}${key}`;
62
- const hasValue = !(val === undefined || val === null || (typeof val === 'string' && val === '') || (Array.isArray(val) && val.length === 0));
62
+ const hasValue = !(value === undefined || value === null || (typeof value === 'string' && value === '') || (Array.isArray(value) && value.length === 0));
63
63
 
64
64
  if (!hasValue) {
65
65
  if (input.required?.active !== false) {
@@ -75,26 +75,26 @@ export class SchemaValidator {
75
75
  if (type === Object) {
76
76
  return [];
77
77
  } else if (array) {
78
- if (!Array.isArray(val)) {
79
- return this.#prepareErrors(path, [{ kind: 'type', type: Array, value: val }]);
78
+ if (!Array.isArray(value)) {
79
+ return this.#prepareErrors(path, [{ kind: 'type', type: Array, value }]);
80
80
  }
81
81
  let errors: ValidationError[] = [];
82
82
  if (complex) {
83
- for (let i = 0; i < val.length; i++) {
84
- const subErrors = this.#validateFields(resolveFieldMap(type, val[i]), val[i], `${path}[${i}]`);
83
+ for (let i = 0; i < value.length; i++) {
84
+ const subErrors = this.#validateFields(resolveFieldMap(type, value[i]), value[i], `${path}[${i}]`);
85
85
  errors = errors.concat(subErrors);
86
86
  }
87
87
  } else {
88
- for (let i = 0; i < val.length; i++) {
89
- const subErrors = this.#validateInput(input, val[i]);
88
+ for (let i = 0; i < value.length; i++) {
89
+ const subErrors = this.#validateInput(input, value[i]);
90
90
  errors.push(...this.#prepareErrors(`${path}[${i}]`, subErrors));
91
91
  }
92
92
  }
93
93
  return errors;
94
94
  } else if (complex) {
95
- return this.#validateFields(resolveFieldMap(type, val), val, path);
95
+ return this.#validateFields(resolveFieldMap(type, value), value, path);
96
96
  } else {
97
- const fieldErrors = this.#validateInput(input, val);
97
+ const fieldErrors = this.#validateInput(input, value);
98
98
  return this.#prepareErrors(path, fieldErrors);
99
99
  }
100
100
  }
@@ -106,13 +106,13 @@ export class SchemaValidator {
106
106
  * @param value The value to validate
107
107
  */
108
108
  static #validateRange(input: SchemaInputConfig, key: 'min' | 'max', value: string | number | Date): boolean {
109
- const f = input[key]!;
110
- const valueNum = (typeof value === 'string') ?
109
+ const config = input[key]!;
110
+ const parsed = (typeof value === 'string') ?
111
111
  (input.type === Date ? Date.parse(value) : parseInt(value, 10)) :
112
112
  (value instanceof Date ? value.getTime() : value);
113
113
 
114
- const boundary = (typeof f.n === 'number' ? f.n : f.n.getTime());
115
- return key === 'min' ? valueNum < boundary : valueNum > boundary;
114
+ const boundary = (typeof config.n === 'number' ? config.n : config.n.getTime());
115
+ return key === 'min' ? parsed < boundary : parsed > boundary;
116
116
  }
117
117
 
118
118
  /**
@@ -184,7 +184,7 @@ export class SchemaValidator {
184
184
  static #prepareErrors(path: string, results: ValidationResult[]): ValidationError[] {
185
185
  const out: ValidationError[] = [];
186
186
  for (const result of results) {
187
- const err: ValidationError = {
187
+ const error: ValidationError = {
188
188
  ...result,
189
189
  kind: result.kind,
190
190
  value: result.value,
@@ -194,20 +194,20 @@ export class SchemaValidator {
194
194
  type: (typeof result.type === 'function' ? result.type.name : result.type)
195
195
  };
196
196
 
197
- if (!err.re) {
198
- delete err.re;
197
+ if (!error.re) {
198
+ delete error.re;
199
199
  }
200
200
 
201
201
  const msg = result.message ?? (
202
- Messages.get(err.re ?? '') ??
203
- Messages.get(err.kind) ??
202
+ Messages.get(error.re ?? '') ??
203
+ Messages.get(error.kind) ??
204
204
  Messages.get('default')!
205
205
  );
206
206
 
207
- err.message = msg
208
- .replace(/\{([^}]+)\}/g, (_, k: (keyof ValidationError)) => `${err[k]}`);
207
+ error.message = msg
208
+ .replace(/\{([^}]+)\}/g, (_, key: (keyof ValidationError)) => `${error[key]}`);
209
209
 
210
- out.push(err);
210
+ out.push(error);
211
211
  }
212
212
  return out;
213
213
  }
@@ -215,7 +215,7 @@ export class SchemaValidator {
215
215
  /**
216
216
  * Validate the class level validations
217
217
  */
218
- static async #validateClassLevel<T>(cls: Class<T>, o: T, view?: string): Promise<ValidationError[]> {
218
+ static async #validateClassLevel<T>(cls: Class<T>, item: T, view?: string): Promise<ValidationError[]> {
219
219
  if (!SchemaRegistryIndex.has(cls)) {
220
220
  return [];
221
221
  }
@@ -226,19 +226,19 @@ export class SchemaValidator {
226
226
  // Handle class level validators
227
227
  for (const fn of classConfig.validators) {
228
228
  try {
229
- const res = await fn(o, view);
230
- if (res) {
231
- if (Array.isArray(res)) {
232
- errors.push(...res);
229
+ const error = await fn(item, view);
230
+ if (error) {
231
+ if (Array.isArray(error)) {
232
+ errors.push(...error);
233
233
  } else {
234
- errors.push(res);
234
+ errors.push(error);
235
235
  }
236
236
  }
237
- } catch (err: unknown) {
238
- if (isValidationError(err)) {
239
- errors.push(err);
237
+ } catch (error: unknown) {
238
+ if (isValidationError(error)) {
239
+ errors.push(error);
240
240
  } else {
241
- throw err;
241
+ throw error;
242
242
  }
243
243
  }
244
244
  }
@@ -248,60 +248,60 @@ export class SchemaValidator {
248
248
  /**
249
249
  * Validate an object against it's constructor's schema
250
250
  * @param cls The class to validate the objects against
251
- * @param o The object to validate
251
+ * @param item The object to validate
252
252
  * @param view The optional view to limit the scope to
253
253
  */
254
- static async validate<T>(cls: Class<T>, o: T, view?: string): Promise<T> {
255
- if (isClassInstance(o) && !(o instanceof cls || cls.Ⲑid === o.constructor.Ⲑid)) {
256
- throw new TypeMismatchError(cls.name, o.constructor.name);
254
+ static async validate<T>(cls: Class<T>, item: T, view?: string): Promise<T> {
255
+ if (isClassInstance(item) && !(item instanceof cls || cls.Ⲑid === item.constructor.Ⲑid)) {
256
+ throw new TypeMismatchError(cls.name, item.constructor.name);
257
257
  }
258
- cls = SchemaRegistryIndex.resolveInstanceType(cls, o);
258
+ cls = SchemaRegistryIndex.resolveInstanceType(cls, item);
259
259
 
260
260
  const fields = SchemaRegistryIndex.get(cls).getFields(view);
261
261
 
262
262
  // Validate using standard behaviors
263
263
  const errors = [
264
- ...this.#validateFields(fields, o, ''),
265
- ... await this.#validateClassLevel(cls, o, view)
264
+ ...this.#validateFields(fields, item, ''),
265
+ ... await this.#validateClassLevel(cls, item, view)
266
266
  ];
267
267
  if (errors.length) {
268
268
  throw new ValidationResultError(errors);
269
269
  }
270
270
 
271
- return o;
271
+ return item;
272
272
  }
273
273
 
274
274
  /**
275
275
  * Validate an entire array of values
276
276
  * @param cls The class to validate the objects against
277
- * @param obj The values to validate
277
+ * @param items The values to validate
278
278
  * @param view The view to limit by
279
279
  */
280
- static async validateAll<T>(cls: Class<T>, obj: T[], view?: string): Promise<T[]> {
281
- return await Promise.all<T>((obj ?? [])
282
- .map(o => this.validate(cls, o, view)));
280
+ static async validateAll<T>(cls: Class<T>, items: T[], view?: string): Promise<T[]> {
281
+ return await Promise.all<T>((items ?? [])
282
+ .map(item => this.validate(cls, item, view)));
283
283
  }
284
284
 
285
285
  /**
286
286
  * Validate partial, ignoring required fields as they are partial
287
287
  *
288
288
  * @param cls The class to validate against
289
- * @param o The value to validate
289
+ * @param item The value to validate
290
290
  * @param view The view to limit by
291
291
  */
292
- static async validatePartial<T>(cls: Class<T>, o: T, view?: string): Promise<T> {
292
+ static async validatePartial<T>(cls: Class<T>, item: T, view?: string): Promise<T> {
293
293
  try {
294
- await this.validate(cls, o, view);
295
- } catch (err) {
296
- if (err instanceof ValidationResultError) { // Don't check required fields
297
- const errs = err.details.errors.filter(x => x.kind !== 'required');
294
+ await this.validate(cls, item, view);
295
+ } catch (error) {
296
+ if (error instanceof ValidationResultError) { // Don't check required fields
297
+ const errs = error.details.errors.filter(validationError => validationError.kind !== 'required');
298
298
  if (errs.length) {
299
- err.details.errors = errs;
300
- throw err;
299
+ error.details.errors = errs;
300
+ throw error;
301
301
  }
302
302
  }
303
303
  }
304
- return o;
304
+ return item;
305
305
  }
306
306
 
307
307
  /**
@@ -311,7 +311,7 @@ export class SchemaValidator {
311
311
  * @param method The method being invoked
312
312
  * @param params The params to validate
313
313
  */
314
- static async validateMethod<T>(cls: Class<T>, method: string | symbol, params: unknown[], prefixes: (string | symbol | undefined)[] = []): Promise<void> {
314
+ static async validateMethod<T>(cls: Class<T>, method: string, params: unknown[], prefixes: (string | undefined)[] = []): Promise<void> {
315
315
  const errors: ValidationError[] = [];
316
316
  const config = SchemaRegistryIndex.get(cls).getMethod(method);
317
317
 
@@ -320,22 +320,22 @@ export class SchemaValidator {
320
320
  errors.push(...[
321
321
  ... this.#validateInputSchema(param, params[i]),
322
322
  ... await this.#validateClassLevel(param.type, params[i])
323
- ].map(x => {
323
+ ].map(error => {
324
324
  if (param.name && typeof param.name === 'string') {
325
- x.path = !prefixes[i] ?
326
- x.path.replace(`${param.name}.`, '') :
327
- x.path.replace(param.name, prefixes[i]!.toString());
325
+ error.path = !prefixes[i] ?
326
+ error.path.replace(`${param.name}.`, '') :
327
+ error.path.replace(param.name, prefixes[i]!);
328
328
  }
329
- return x;
329
+ return error;
330
330
  }));
331
331
  }
332
332
  for (const validator of config.validators) {
333
- const res = await validator(...params);
334
- if (res) {
335
- if (Array.isArray(res)) {
336
- errors.push(...res);
333
+ const error = await validator(...params);
334
+ if (error) {
335
+ if (Array.isArray(error)) {
336
+ errors.push(...error);
337
337
  } else {
338
- errors.push(res);
338
+ errors.push(error);
339
339
  }
340
340
  }
341
341
  }
@@ -22,7 +22,7 @@ export class SchemaTransformUtil {
22
22
  switch (type.key) {
23
23
  case 'pointer': return this.toConcreteType(state, type.target, node, root);
24
24
  case 'managed': return state.getOrImport(type);
25
- case 'tuple': return state.fromLiteral(type.subTypes.map(x => this.toConcreteType(state, x, node, root)!));
25
+ case 'tuple': return state.fromLiteral(type.subTypes.map(subType => this.toConcreteType(state, subType, node, root)!));
26
26
  case 'template': return state.createIdentifier(type.ctor.name);
27
27
  case 'literal': {
28
28
  if ((type.ctor === Array) && type.typeArguments?.length) {
@@ -60,7 +60,7 @@ class ${uniqueId} extends ${type.mappedClassName} {
60
60
  }
61
61
  case 'unknown': {
62
62
  const imp = state.importFile(this.TYPES_IMPORT);
63
- return state.createAccess(imp.ident, 'UnknownType');
63
+ return state.createAccess(imp.identifier, 'UnknownType');
64
64
  }
65
65
  case 'shape': {
66
66
  const uniqueId = state.generateUniqueIdentifier(node, type, 'Δ');
@@ -76,18 +76,18 @@ class ${uniqueId} extends ${type.mappedClassName} {
76
76
  ],
77
77
  id, [], [],
78
78
  Object.entries(type.fieldTypes)
79
- .map(([k, v]) =>
79
+ .map(([key, value]) =>
80
80
  this.computeInput(state, state.factory.createPropertyDeclaration(
81
- [], /\W/.test(k) ? state.factory.createComputedPropertyName(state.fromLiteral(k)) : k,
82
- v.undefinable || v.nullable ? state.factory.createToken(ts.SyntaxKind.QuestionToken) : undefined,
83
- v.key === 'unknown' ? state.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword) : undefined, undefined
84
- ), { type: v, root })
81
+ [], /\W/.test(key) ? state.factory.createComputedPropertyName(state.fromLiteral(key)) : key,
82
+ value.undefinable || value.nullable ? state.factory.createToken(ts.SyntaxKind.QuestionToken) : undefined,
83
+ value.key === 'unknown' ? state.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword) : undefined, undefined
84
+ ), { type: value, root })
85
85
  )
86
86
  );
87
87
  cls.getText = (): string => [
88
88
  `class ${uniqueId} {`,
89
89
  ...Object.entries(type.fieldTypes)
90
- .map(([k, v]) => ` ${k}${v.nullable ? '?' : ''}: ${v.name};`),
90
+ .map(([key, value]) => ` ${key}${value.nullable ? '?' : ''}: ${value.name};`),
91
91
  '}'
92
92
  ].join('\n');
93
93
  state.addStatements([cls], root || node);
@@ -135,12 +135,12 @@ class ${uniqueId} extends ${type.mappedClassName} {
135
135
  attrs.default = node.initializer;
136
136
  }
137
137
  } else {
138
- const acc = DeclarationUtil.getAccessorPair(node);
138
+ const pair = DeclarationUtil.getAccessorPair(node);
139
139
  attrs.accessor = true;
140
- if (!acc.setter) {
140
+ if (!pair.setter) {
141
141
  attrs.access = 'readonly';
142
142
  }
143
- if (!acc.getter) {
143
+ if (!pair.getter) {
144
144
  attrs.access = 'writeonly';
145
145
  } else if (!!typeExpr.undefinable) {
146
146
  attrs.required = { active: false };
@@ -160,8 +160,9 @@ class ${uniqueId} extends ${type.mappedClassName} {
160
160
  // We need to ensure we aren't being tripped up by the wrapper for arrays, sets, etc.
161
161
  // If we have a composition type
162
162
  if (primaryExpr.key === 'composition') {
163
- const values = primaryExpr.subTypes.map(x => x.key === 'literal' ? x.value : undefined)
164
- .filter(x => x !== undefined && x !== null);
163
+ const values = primaryExpr.subTypes
164
+ .map(subType => subType.key === 'literal' ? subType.value : undefined)
165
+ .filter(value => value !== undefined && value !== null);
165
166
 
166
167
  if (values.length === primaryExpr.subTypes.length) {
167
168
  attrs.enum = {
@@ -180,7 +181,9 @@ class ${uniqueId} extends ${type.mappedClassName} {
180
181
 
181
182
  if (ts.isParameter(node)) {
182
183
  const parentComments = DocUtil.describeDocs(node.parent);
183
- const paramComments: Partial<ParamDocumentation> = (parentComments.params ?? []).find(x => x.name === node.name.getText()) || {};
184
+ const paramComments: Partial<ParamDocumentation> = (parentComments.params ?? [])
185
+ .find(param => param.name === node.name.getText()) || {};
186
+
184
187
  if (paramComments.description) {
185
188
  attrs.description = paramComments.description;
186
189
  }
@@ -192,9 +195,9 @@ class ${uniqueId} extends ${type.mappedClassName} {
192
195
  }
193
196
 
194
197
  const tags = ts.getJSDocTags(node);
195
- const aliases = tags.filter(x => x.tagName.getText() === 'alias');
198
+ const aliases = tags.filter(tag => tag.tagName.getText() === 'alias');
196
199
  if (aliases.length) {
197
- attrs.aliases = aliases.map(x => x.comment).filter(x => !!x);
200
+ attrs.aliases = aliases.map(alias => alias.comment).filter(alias => !!alias);
198
201
  }
199
202
 
200
203
  const params: ts.Expression[] = [];
@@ -241,15 +244,15 @@ class ${uniqueId} extends ${type.mappedClassName} {
241
244
  ): T {
242
245
  const existingField = state.findDecorator('@travetto/schema', node, 'Field', this.FIELD_IMPORT);
243
246
  const existingInput = state.findDecorator('@travetto/schema', node, 'Input', this.INPUT_IMPORT);
244
- const decParams = this.computeInputDecoratorParams(state, node, config);
247
+ const params = this.computeInputDecoratorParams(state, node, config);
245
248
 
246
249
  let modifiers: ts.ModifierLike[];
247
250
  if (existingField) {
248
- const dec = state.createDecorator(this.FIELD_IMPORT, 'Field', ...decParams);
249
- modifiers = DecoratorUtil.spliceDecorators(node, existingField, [dec]);
251
+ const decorator = state.createDecorator(this.FIELD_IMPORT, 'Field', ...params);
252
+ modifiers = DecoratorUtil.spliceDecorators(node, existingField, [decorator]);
250
253
  } else {
251
- const dec = state.createDecorator(this.INPUT_IMPORT, 'Input', ...decParams);
252
- modifiers = DecoratorUtil.spliceDecorators(node, existingInput, [dec]);
254
+ const decorator = state.createDecorator(this.INPUT_IMPORT, 'Input', ...params);
255
+ modifiers = DecoratorUtil.spliceDecorators(node, existingInput, [decorator]);
253
256
  }
254
257
 
255
258
  let result: unknown;
@@ -324,8 +327,8 @@ class ${uniqueId} extends ${type.mappedClassName} {
324
327
  let cls;
325
328
  switch (type?.key) {
326
329
  case 'managed': {
327
- const [dec] = DeclarationUtil.getDeclarations(type.original!);
328
- cls = dec && ts.isClassDeclaration(dec) ? dec : undefined;
330
+ const [decorator] = DeclarationUtil.getDeclarations(type.original!);
331
+ cls = decorator && ts.isClassDeclaration(decorator) ? decorator : undefined;
329
332
  break;
330
333
  }
331
334
  case 'shape': cls = type.original; break;
@@ -59,8 +59,8 @@ export class SchemaTransformer {
59
59
  // Determine auto enrol methods
60
60
  for (const item of state.getDecoratorList(node)) {
61
61
  if (item.targets?.includes('@travetto/schema:Schema')) {
62
- for (const opt of item.options ?? []) {
63
- state[AutoEnrollMethods].add(opt);
62
+ for (const option of item.options ?? []) {
63
+ state[AutoEnrollMethods].add(option);
64
64
  }
65
65
  }
66
66
  }
@@ -76,7 +76,7 @@ export class SchemaTransformer {
76
76
  const comments = DocUtil.describeDocs(node);
77
77
 
78
78
  const existing = state.findDecorator(this, node, 'Schema', SchemaTransformUtil.SCHEMA_IMPORT);
79
- const cons = node.members.find(x => ts.isConstructorDeclaration(x));
79
+ const cons = node.members.find(member => ts.isConstructorDeclaration(member));
80
80
 
81
81
  const attrs: Record<string, string | boolean | ts.Expression | number | object | unknown[]> = {};
82
82
 
@@ -105,9 +105,9 @@ export class SchemaTransformer {
105
105
  if (cons) {
106
106
  attrs.methods = {
107
107
  [CONSTRUCTOR_PROPERTY]: {
108
- parameters: cons.parameters.map((p, i) => SchemaTransformUtil.computeInputDecoratorParams(state, p, { index: i })).map(x =>
109
- state.extendObjectLiteral({}, ...x)
110
- ),
108
+ parameters: cons.parameters
109
+ .map((parameter, i) => SchemaTransformUtil.computeInputDecoratorParams(state, parameter, { index: i }))
110
+ .map(expr => state.extendObjectLiteral({}, ...expr)),
111
111
  }
112
112
  };
113
113
  }
@@ -163,7 +163,7 @@ export class SchemaTransformer {
163
163
  node.name,
164
164
  node.questionToken,
165
165
  node.typeParameters,
166
- node.parameters.map((y, i) => SchemaTransformUtil.computeInput(state, y, { index: i })),
166
+ node.parameters.map((parameter, i) => SchemaTransformUtil.computeInput(state, parameter, { index: i })),
167
167
  node.type,
168
168
  node.body
169
169
  );