openapi-ts-generator 9.24.2 → 9.31.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.
@@ -6,7 +6,7 @@ import { IEnumValue } from './enum-value';
6
6
  * @param lookupValue - The value to look up in the enum, which can be a number or a string.
7
7
  * @returns The key of the enum value if found, otherwise `undefined`.
8
8
  */
9
- export declare function getEnumKey(data: IEnumValue[], lookupValue: number | string): number | undefined;
9
+ export declare function getEnumKey(data: IEnumValue[], lookupValue: number | string): number | string | undefined;
10
10
  /**
11
11
  * Retrieves the display text for a given enum value.
12
12
  *
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEnum = exports.getEnumDisplayText = exports.getEnumKey = void 0;
3
+ exports.getEnumKey = getEnumKey;
4
+ exports.getEnumDisplayText = getEnumDisplayText;
5
+ exports.getEnum = getEnum;
4
6
  /**
5
7
  * Retrieves the key of an enum value from a list of enum values.
6
8
  *
@@ -9,10 +11,8 @@ exports.getEnum = exports.getEnumDisplayText = exports.getEnumKey = void 0;
9
11
  * @returns The key of the enum value if found, otherwise `undefined`.
10
12
  */
11
13
  function getEnumKey(data, lookupValue) {
12
- var _a;
13
- return (_a = getEnum(data, lookupValue)) === null || _a === void 0 ? void 0 : _a.key;
14
+ return getEnum(data, lookupValue)?.key;
14
15
  }
15
- exports.getEnumKey = getEnumKey;
16
16
  /**
17
17
  * Retrieves the display text for a given enum value.
18
18
  *
@@ -21,10 +21,8 @@ exports.getEnumKey = getEnumKey;
21
21
  * @returns The display text associated with the given enum value, or `undefined` if not found.
22
22
  */
23
23
  function getEnumDisplayText(data, lookupValue) {
24
- var _a;
25
- return (_a = getEnum(data, lookupValue)) === null || _a === void 0 ? void 0 : _a.displayText;
24
+ return getEnum(data, lookupValue)?.displayText;
26
25
  }
27
- exports.getEnumDisplayText = getEnumDisplayText;
28
26
  /**
29
27
  * Retrieves an enum value from a list of enum values based on a lookup value.
30
28
  *
@@ -33,6 +31,5 @@ exports.getEnumDisplayText = getEnumDisplayText;
33
31
  * @returns The matching enum value, or `undefined` if no match is found.
34
32
  */
35
33
  function getEnum(data, lookupValue) {
36
- return data.find(function (f) { return f.name === lookupValue || f.key === lookupValue; });
34
+ return data.find((f) => f.name === lookupValue || f.key === lookupValue);
37
35
  }
38
- exports.getEnum = getEnum;
@@ -6,4 +6,4 @@ var EnumProperties;
6
6
  EnumProperties["KEY"] = "key";
7
7
  EnumProperties["NAME"] = "name";
8
8
  EnumProperties["DISPLAY_TEXT"] = "displayText";
9
- })(EnumProperties = exports.EnumProperties || (exports.EnumProperties = {}));
9
+ })(EnumProperties || (exports.EnumProperties = EnumProperties = {}));
@@ -1,5 +1,5 @@
1
1
  export interface IEnumValue {
2
- key: number;
3
- name: string;
4
- displayText: string;
2
+ key?: number | string;
3
+ name?: string;
4
+ displayText?: string;
5
5
  }
@@ -1,39 +1,18 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.BarrelGenerator = void 0;
19
- var fs_1 = require("fs");
20
- var base_generator_1 = require("./base.generator");
21
- var BarrelGenerator = /** @class */ (function (_super) {
22
- __extends(BarrelGenerator, _super);
23
- function BarrelGenerator(options) {
24
- var _this = this;
25
- var _a;
26
- _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.barrel) || this;
27
- _this.GeneratorName = 'BarrelGenerator';
28
- _this.tsRegex = /.ts$/;
29
- return _this;
4
+ const fs_1 = require("fs");
5
+ const base_generator_1 = require("./base.generator");
6
+ class BarrelGenerator extends base_generator_1.BaseGenerator {
7
+ constructor(options) {
8
+ super(options, options.templates?.barrel);
9
+ this.GeneratorName = 'BarrelGenerator';
10
+ this.tsRegex = /.ts$/;
30
11
  }
31
- BarrelGenerator.prototype.generate = function () {
32
- var _this = this;
33
- var fileNames = (0, fs_1.readdirSync)(this.generatorOptions.outputPath).map(function (value) { return value.replace(_this.tsRegex, ''); });
34
- fileNames = fileNames.filter(function (x) { return x !== 'endpoints'; });
35
- return _super.prototype.generateFile.call(this, "".concat(this.generatorOptions.outputPath, "/index.ts"), fileNames.length ? { fileNames: fileNames } : null);
36
- };
37
- return BarrelGenerator;
38
- }(base_generator_1.BaseGenerator));
12
+ generate() {
13
+ let fileNames = (0, fs_1.readdirSync)(this.generatorOptions.outputPath).map((value) => value.replace(this.tsRegex, ''));
14
+ fileNames = fileNames.filter((x) => x !== 'endpoints');
15
+ return super.generateFile(`${this.generatorOptions.outputPath}/index.ts`, fileNames.length ? { fileNames } : null);
16
+ }
17
+ }
39
18
  exports.BarrelGenerator = BarrelGenerator;
@@ -1,43 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseGenerator = void 0;
4
- var fs_1 = require("fs");
5
- var handlebars_1 = require("handlebars");
6
- var BaseGenerator = /** @class */ (function () {
7
- function BaseGenerator(generatorOptions, templateFilePath) {
4
+ const fs_1 = require("fs");
5
+ const handlebars_1 = require("handlebars");
6
+ class BaseGenerator {
7
+ constructor(generatorOptions, templateFilePath) {
8
8
  this.generatorOptions = generatorOptions;
9
9
  this.templateFilePath = templateFilePath;
10
10
  this.emptyArrayRegex = /, ]/g;
11
11
  if (templateFilePath) {
12
- var templateSource = (0, fs_1.readFileSync)(templateFilePath, { encoding: 'utf8' });
12
+ const templateSource = (0, fs_1.readFileSync)(templateFilePath, { encoding: 'utf8' });
13
13
  this.template = (0, handlebars_1.compile)(templateSource);
14
14
  }
15
15
  }
16
- BaseGenerator.prototype.generateFile = function (outputFilePath, context) {
17
- var _a, _b, _c, _d, _e, _f, _g, _h;
16
+ generateFile(outputFilePath, context) {
18
17
  if (!this.template) {
19
- (_a = this.generatorOptions.logger) === null || _a === void 0 ? void 0 : _a.warn("Template for ".concat(this.GeneratorName, " has not been specified."));
18
+ this.generatorOptions.logger?.warn(`Template for ${this.GeneratorName} has not been specified.`);
20
19
  }
21
20
  else if (!context) {
22
- (_b = this.generatorOptions.logger) === null || _b === void 0 ? void 0 : _b.warn("Context for ".concat(this.GeneratorName, " has not been provided."));
21
+ this.generatorOptions.logger?.warn(`Context for ${this.GeneratorName} has not been provided.`);
23
22
  }
24
23
  else {
25
24
  try {
26
- var content = this.template(context).replace(this.emptyArrayRegex, ']');
25
+ const content = this.template(context).replace(this.emptyArrayRegex, ']');
27
26
  (0, fs_1.writeFileSync)(outputFilePath, content, { encoding: 'utf8' });
28
27
  return content;
29
28
  }
30
29
  catch (err) {
31
- (_c = this.generatorOptions.logger) === null || _c === void 0 ? void 0 : _c.error("Error executing template: ".concat((_d = this.templateFilePath) !== null && _d !== void 0 ? _d : 'undefined', "."));
32
- (_e = this.generatorOptions.logger) === null || _e === void 0 ? void 0 : _e.error("This is likely an issue with the template.");
33
- (_f = this.generatorOptions.logger) === null || _f === void 0 ? void 0 : _f.error("Data: ".concat(JSON.stringify(context)));
34
- (_g = this.generatorOptions.logger) === null || _g === void 0 ? void 0 : _g.error("Goto: https://github.com/ikemtz/openapi-ts-generator to report an issue if necessary.");
35
- (_h = this.generatorOptions.logger) === null || _h === void 0 ? void 0 : _h.error(JSON.stringify(err));
30
+ this.generatorOptions.logger?.error(`Error executing template: ${this.templateFilePath ?? 'undefined'}.`);
31
+ this.generatorOptions.logger?.error(`This is likely an issue with the template.`);
32
+ this.generatorOptions.logger?.error(`Data: ${JSON.stringify(context)}`);
33
+ this.generatorOptions.logger?.error(`Goto: https://github.com/ikemtz/openapi-ts-generator to report an issue if necessary.`);
34
+ this.generatorOptions.logger?.error(JSON.stringify(err));
36
35
  throw err;
37
36
  }
38
37
  }
39
38
  return null;
40
- };
41
- return BaseGenerator;
42
- }());
39
+ }
40
+ }
43
41
  exports.BaseGenerator = BaseGenerator;
@@ -1,75 +1,35 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
- if (ar || !(i in from)) {
31
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
- ar[i] = from[i];
33
- }
34
- }
35
- return to.concat(ar || Array.prototype.slice.call(from));
36
- };
37
2
  Object.defineProperty(exports, "__esModule", { value: true });
38
3
  exports.EndPointsGenerator = void 0;
39
- var base_generator_1 = require("./base.generator");
40
- var _ = require("lodash");
41
- var EndPointsGenerator = /** @class */ (function (_super) {
42
- __extends(EndPointsGenerator, _super);
43
- function EndPointsGenerator(options) {
44
- var _this = this;
45
- var _a;
46
- _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.endpoints) || this;
47
- _this.GeneratorName = 'EndPointsGenerator';
48
- _this.endpointIdentifierRegex = /[A-z0-9_-]*$/;
49
- return _this;
4
+ const base_generator_1 = require("./base.generator");
5
+ const lodash_1 = require("lodash");
6
+ class EndPointsGenerator extends base_generator_1.BaseGenerator {
7
+ constructor(options) {
8
+ super(options, options.templates?.endpoints);
9
+ this.GeneratorName = 'EndPointsGenerator';
10
+ this.endpointIdentifierRegex = /[A-z0-9_-]*$/;
11
+ }
12
+ generate(templateData) {
13
+ const paths = this.eliminateDupes(templateData);
14
+ return super.generateFile(`${this.generatorOptions.outputPath}/endpoints.ts`, { paths });
50
15
  }
51
- EndPointsGenerator.prototype.generate = function (templateData) {
52
- var paths = this.eliminateDupes(templateData);
53
- return _super.prototype.generateFile.call(this, "".concat(this.generatorOptions.outputPath, "/endpoints.ts"), { paths: paths });
54
- };
55
- EndPointsGenerator.prototype.eliminateDupes = function (templateData) {
56
- var _this = this;
57
- var sortedTemplateData = __spreadArray([], templateData.paths, true).sort(function (x, y) { return (x.endpoint.toUpperCase() < y.endpoint.toUpperCase() ? -1 : 1); });
58
- var result = [];
59
- sortedTemplateData.forEach(function (val) {
60
- val = __assign(__assign({}, val), { tag: _.camelCase(val.tag) });
61
- var dupeIndex = result.findIndex(function (f) { return f.tag === val.tag; });
16
+ eliminateDupes(templateData) {
17
+ const sortedTemplateData = [...templateData.paths].sort((x, y) => (x.endpoint.toUpperCase() < y.endpoint.toUpperCase() ? -1 : 1));
18
+ const result = [];
19
+ sortedTemplateData.forEach((val) => {
20
+ val = { ...val, tag: (0, lodash_1.camelCase)(val.tag) };
21
+ const dupeIndex = result.findIndex((f) => f.tag === val.tag);
62
22
  if (dupeIndex > -1) {
63
- var dupeCount = result.filter(function (f) { return f.tag === val.tag; }).length + 1;
64
- var endpointIdentifier = (_this.endpointIdentifierRegex.exec(val.endpoint) || [])[0];
65
- result.push(__assign(__assign({}, val), { tag: _.camelCase("".concat(val.tag, "_").concat(endpointIdentifier || dupeCount)) }));
23
+ const dupeCount = result.filter((f) => f.tag === val.tag).length + 1;
24
+ const endpointIdentifier = (this.endpointIdentifierRegex.exec(val.endpoint) || [])[0];
25
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
26
+ result.push({ ...val, tag: (0, lodash_1.camelCase)(`${val.tag}_${endpointIdentifier || dupeCount}`) });
66
27
  }
67
28
  else {
68
29
  result.push(val);
69
30
  }
70
31
  });
71
32
  return result;
72
- };
73
- return EndPointsGenerator;
74
- }(base_generator_1.BaseGenerator));
33
+ }
34
+ }
75
35
  exports.EndPointsGenerator = EndPointsGenerator;
@@ -1,39 +1,19 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.EnumGenerator = void 0;
19
- var _ = require("lodash");
20
- var base_generator_1 = require("./base.generator");
21
- var EnumGenerator = /** @class */ (function (_super) {
22
- __extends(EnumGenerator, _super);
23
- function EnumGenerator(options) {
24
- var _this = this;
25
- var _a;
26
- _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.enum) || this;
27
- _this.GeneratorName = 'EnumGenerator';
28
- return _this;
4
+ const lodash_1 = require("lodash");
5
+ const base_generator_1 = require("./base.generator");
6
+ class EnumGenerator extends base_generator_1.BaseGenerator {
7
+ constructor(options) {
8
+ super(options, options.templates?.enum);
9
+ this.GeneratorName = 'EnumGenerator';
29
10
  }
30
- EnumGenerator.prototype.generate = function (templateData) {
31
- var _this = this;
32
- var _a;
33
- (_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (entity) { return entity.isEnum; }).forEach(function (entity) {
34
- _super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name), ".enum.ts"), entity);
11
+ generate(templateData) {
12
+ templateData.entities
13
+ ?.filter((entity) => entity.isEnum)
14
+ .forEach((entity) => {
15
+ super.generateFile(`${this.generatorOptions.outputPath}/${(0, lodash_1.kebabCase)(entity.name)}.enum.ts`, entity);
35
16
  });
36
- };
37
- return EnumGenerator;
38
- }(base_generator_1.BaseGenerator));
17
+ }
18
+ }
39
19
  exports.EnumGenerator = EnumGenerator;
@@ -1,42 +1,57 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
8
26
  };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
15
33
  };
16
34
  })();
17
35
  Object.defineProperty(exports, "__esModule", { value: true });
18
36
  exports.FormGroupFactoryGenerator = void 0;
19
- var _ = require("lodash");
20
- var base_generator_1 = require("./base.generator");
21
- var HandleBars = require("handlebars");
22
- var FormGroupFactoryGenerator = /** @class */ (function (_super) {
23
- __extends(FormGroupFactoryGenerator, _super);
24
- function FormGroupFactoryGenerator(options) {
25
- var _this = this;
26
- var _a;
27
- _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.formGroupFactory) || this;
28
- _this.GeneratorName = 'FormGroupFactoryGenerator';
29
- return _this;
37
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
38
+ const lodash_1 = require("lodash");
39
+ const base_generator_1 = require("./base.generator");
40
+ const HandleBars = __importStar(require("handlebars"));
41
+ class FormGroupFactoryGenerator extends base_generator_1.BaseGenerator {
42
+ constructor(options) {
43
+ super(options, options.templates?.formGroupFactory);
44
+ this.GeneratorName = 'FormGroupFactoryGenerator';
30
45
  }
31
- FormGroupFactoryGenerator.prototype.generate = function (templateData) {
32
- var _this = this;
33
- var _a;
46
+ generate(templateData) {
34
47
  this.registerHelpers();
35
- (_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (val) { var _a, _b; return ((_a = val.valueProperties) === null || _a === void 0 ? void 0 : _a.length) + ((_b = val.referenceProperties) === null || _b === void 0 ? void 0 : _b.length) > 0; }).forEach(function (entity) {
36
- _super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name), ".form-group-fac.ts"), entity);
48
+ templateData.entities
49
+ ?.filter((val) => val.valueProperties?.length + val.referenceProperties?.length > 0)
50
+ .forEach((entity) => {
51
+ super.generateFile(`${this.generatorOptions.outputPath}/${(0, lodash_1.kebabCase)(entity.name)}.form-group-fac.ts`, entity);
37
52
  });
38
- };
39
- FormGroupFactoryGenerator.prototype.registerHelpers = function () {
53
+ }
54
+ registerHelpers() {
40
55
  this.registerValidatorHelper('minimum', 'min');
41
56
  this.registerValidatorHelper('maximum', 'max');
42
57
  this.registerValidatorHelper('minLength');
@@ -44,25 +59,21 @@ var FormGroupFactoryGenerator = /** @class */ (function (_super) {
44
59
  this.registerValidatorHelper('maxItems', 'maxLength');
45
60
  this.registerValidatorHelper('minItems', 'minLength');
46
61
  this.registerValidatorHelper('pattern');
47
- };
48
- FormGroupFactoryGenerator.prototype.registerValidatorHelper = function (validatorName, angularValidatorName) {
49
- var _this = this;
50
- if (angularValidatorName === void 0) { angularValidatorName = validatorName; }
51
- HandleBars.registerHelper("".concat(validatorName, "Validator"), function (x, y) {
52
- return _this.validatorFactory(x, y, validatorName, angularValidatorName);
53
- });
54
- };
55
- FormGroupFactoryGenerator.prototype.validatorFactory = function (propertyCollection, propertyContext, validationName, angularValidatorFunctionName) {
56
- var props = propertyContext.data.root[propertyCollection];
57
- var prop = props[propertyContext.data.index];
58
- var value = prop[validationName];
62
+ }
63
+ registerValidatorHelper(validatorName, angularValidatorName = validatorName) {
64
+ HandleBars.registerHelper(`${validatorName}Validator`, (x, y) => this.validatorFactory(x, y, validatorName, angularValidatorName));
65
+ }
66
+ validatorFactory(propertyCollection, propertyContext, validationName, angularValidatorFunctionName) {
67
+ const props = propertyContext.data.root[propertyCollection];
68
+ const prop = props[propertyContext.data.index];
69
+ let value = prop[validationName];
59
70
  if (value !== undefined && value !== null) {
60
- var hasMultipleValidators = prop.hasMultipleValidators;
61
- value = typeof value === 'string' ? "'".concat(value, "'") : value;
62
- return "Validators.".concat(angularValidatorFunctionName, "(").concat(value, ")").concat(hasMultipleValidators ? ', ' : '');
71
+ const hasMultipleValidators = prop.hasMultipleValidators;
72
+ value = typeof value === 'string' ? `'${value}'` : value;
73
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
74
+ return `Validators.${angularValidatorFunctionName}(${value})${hasMultipleValidators ? ', ' : ''}`;
63
75
  }
64
76
  return '';
65
- };
66
- return FormGroupFactoryGenerator;
67
- }(base_generator_1.BaseGenerator));
77
+ }
78
+ }
68
79
  exports.FormGroupFactoryGenerator = FormGroupFactoryGenerator;
@@ -1,39 +1,20 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.FormGenerator = void 0;
19
- var _ = require("lodash");
20
- var base_generator_1 = require("./base.generator");
21
- var FormGenerator = /** @class */ (function (_super) {
22
- __extends(FormGenerator, _super);
23
- function FormGenerator(options) {
24
- var _this = this;
25
- var _a;
26
- _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.form) || this;
27
- _this.GeneratorName = 'FormGenerator';
28
- return _this;
4
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
5
+ const lodash_1 = require("lodash");
6
+ const base_generator_1 = require("./base.generator");
7
+ class FormGenerator extends base_generator_1.BaseGenerator {
8
+ constructor(options) {
9
+ super(options, options.templates?.form);
10
+ this.GeneratorName = 'FormGenerator';
29
11
  }
30
- FormGenerator.prototype.generate = function (templateData) {
31
- var _this = this;
32
- var _a;
33
- (_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (val) { var _a, _b; return ((_a = val.valueProperties) === null || _a === void 0 ? void 0 : _a.length) + ((_b = val.referenceProperties) === null || _b === void 0 ? void 0 : _b.length) > 0; }).forEach(function (entity) {
34
- _super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name), ".form.ts"), entity);
12
+ generate(templateData) {
13
+ templateData.entities
14
+ ?.filter((val) => val.valueProperties?.length + val.referenceProperties?.length > 0)
15
+ .forEach((entity) => {
16
+ super.generateFile(`${this.generatorOptions.outputPath}/${(0, lodash_1.kebabCase)(entity.name)}.form.ts`, entity);
35
17
  });
36
- };
37
- return FormGenerator;
38
- }(base_generator_1.BaseGenerator));
18
+ }
19
+ }
39
20
  exports.FormGenerator = FormGenerator;
@@ -1,39 +1,21 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ModelPropertiesGenerator = void 0;
19
- var _ = require("lodash");
20
- var base_generator_1 = require("./base.generator");
21
- var ModelPropertiesGenerator = /** @class */ (function (_super) {
22
- __extends(ModelPropertiesGenerator, _super);
23
- function ModelPropertiesGenerator(options) {
24
- var _this = this;
25
- var _a;
26
- _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.modelProperties) || this;
27
- _this.GeneratorName = 'ModelPropertiesGenerator';
28
- return _this;
4
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
5
+ const lodash_1 = require("lodash");
6
+ const base_generator_1 = require("./base.generator");
7
+ class ModelPropertiesGenerator extends base_generator_1.BaseGenerator {
8
+ constructor(options) {
9
+ super(options, options.templates?.modelProperties);
10
+ this.GeneratorName = 'ModelPropertiesGenerator';
29
11
  }
30
- ModelPropertiesGenerator.prototype.generate = function (templateData) {
31
- var _this = this;
32
- var _a;
33
- (_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (entity) { return !entity.isEnum; }).filter(function (val) { var _a, _b; return ((_a = val.valueProperties) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = val.referenceProperties) === null || _b === void 0 ? void 0 : _b.length) > 0; }).forEach(function (entity) {
34
- _super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name), ".properties.ts"), entity);
12
+ generate(templateData) {
13
+ templateData.entities
14
+ ?.filter((entity) => !entity.isEnum)
15
+ .filter((val) => val.valueProperties?.length > 0 || val.referenceProperties?.length > 0)
16
+ .forEach((entity) => {
17
+ super.generateFile(`${this.generatorOptions.outputPath}/${(0, lodash_1.kebabCase)(entity.name)}.properties.ts`, entity);
35
18
  });
36
- };
37
- return ModelPropertiesGenerator;
38
- }(base_generator_1.BaseGenerator));
19
+ }
20
+ }
39
21
  exports.ModelPropertiesGenerator = ModelPropertiesGenerator;