@odata2ts/odata2ts 0.23.1 → 0.24.0

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +74 -74
  3. package/lib/FactoryFunctionModel.d.ts +13 -13
  4. package/lib/FactoryFunctionModel.js +2 -2
  5. package/lib/FactoryFunctionModel.js.map +1 -1
  6. package/lib/NamingModel.d.ts +182 -182
  7. package/lib/NamingModel.js +11 -11
  8. package/lib/NamingModel.js.map +1 -1
  9. package/lib/OptionModel.d.ts +228 -223
  10. package/lib/OptionModel.js +23 -23
  11. package/lib/OptionModel.js.map +1 -1
  12. package/lib/app.d.ts +8 -8
  13. package/lib/app.js +63 -63
  14. package/lib/app.js.map +1 -1
  15. package/lib/cli.d.ts +3 -3
  16. package/lib/cli.js +153 -153
  17. package/lib/data-model/DataModel.d.ts +85 -85
  18. package/lib/data-model/DataModel.js +134 -134
  19. package/lib/data-model/DataModelDigestion.d.ts +44 -44
  20. package/lib/data-model/DataModelDigestion.js +274 -274
  21. package/lib/data-model/DataModelDigestion.js.map +1 -1
  22. package/lib/data-model/DataModelDigestionV2.d.ts +10 -10
  23. package/lib/data-model/DataModelDigestionV2.js +200 -200
  24. package/lib/data-model/DataModelDigestionV4.d.ts +3 -3
  25. package/lib/data-model/DataModelDigestionV4.js +195 -195
  26. package/lib/data-model/DataTypeModel.d.ts +102 -102
  27. package/lib/data-model/DataTypeModel.js +8 -8
  28. package/lib/data-model/DataTypeModel.js.map +1 -1
  29. package/lib/data-model/NamingHelper.d.ts +55 -55
  30. package/lib/data-model/NamingHelper.js +214 -214
  31. package/lib/data-model/ServiceConfigHelper.d.ts +21 -21
  32. package/lib/data-model/ServiceConfigHelper.js +113 -113
  33. package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +80 -80
  34. package/lib/data-model/edmx/ODataEdmxModelBase.js +2 -2
  35. package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
  36. package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +63 -63
  37. package/lib/data-model/edmx/ODataEdmxModelV3.js +2 -2
  38. package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +67 -67
  39. package/lib/data-model/edmx/ODataEdmxModelV4.js +2 -2
  40. package/lib/defaultConfig.d.ts +9 -9
  41. package/lib/defaultConfig.js +165 -164
  42. package/lib/defaultConfig.js.map +1 -1
  43. package/lib/evaluateConfig.d.ts +25 -25
  44. package/lib/evaluateConfig.js +82 -82
  45. package/lib/generator/ImportContainer.d.ts +16 -16
  46. package/lib/generator/ImportContainer.js +91 -91
  47. package/lib/generator/ImportContainer.js.map +1 -1
  48. package/lib/generator/ModelGenerator.d.ts +2 -2
  49. package/lib/generator/ModelGenerator.js +211 -183
  50. package/lib/generator/ModelGenerator.js.map +1 -1
  51. package/lib/generator/QueryObjectGenerator.d.ts +2 -2
  52. package/lib/generator/QueryObjectGenerator.js +239 -239
  53. package/lib/generator/ServiceGenerator.d.ts +8 -8
  54. package/lib/generator/ServiceGenerator.js +422 -422
  55. package/lib/generator/ServiceGenerator.js.map +1 -1
  56. package/lib/generator/index.d.ts +3 -3
  57. package/lib/generator/index.js +9 -9
  58. package/lib/index.d.ts +3 -3
  59. package/lib/index.js +6 -6
  60. package/lib/project/ProjectManager.d.ts +30 -30
  61. package/lib/project/ProjectManager.js +177 -175
  62. package/lib/project/ProjectManager.js.map +1 -1
  63. package/lib/project/formatter/BaseFormatter.d.ts +49 -49
  64. package/lib/project/formatter/BaseFormatter.js +30 -30
  65. package/lib/project/formatter/FileFormatter.d.ts +16 -16
  66. package/lib/project/formatter/FileFormatter.js +2 -2
  67. package/lib/project/formatter/NoopFormatter.d.ts +29 -29
  68. package/lib/project/formatter/NoopFormatter.js +42 -42
  69. package/lib/project/formatter/PrettierFormatter.d.ts +46 -46
  70. package/lib/project/formatter/PrettierFormatter.js +92 -92
  71. package/lib/project/formatter/index.d.ts +2 -2
  72. package/lib/project/formatter/index.js +14 -14
  73. package/lib/project/logger/logFilePath.d.ts +1 -1
  74. package/lib/project/logger/logFilePath.js +12 -12
  75. package/lib/run-cli.d.ts +2 -2
  76. package/lib/run-cli.js +6 -6
  77. package/package.json +27 -28
@@ -1,55 +1,55 @@
1
- import { RunOptions } from "../OptionModel";
2
- export interface NamingHelperSettings extends Pick<RunOptions, "allowRenaming" | "naming"> {
3
- }
4
- export declare class NamingHelper {
5
- private readonly allowModelPropRenaming;
6
- private readonly serviceName;
7
- private readonly servicePrefix;
8
- private readonly options;
9
- constructor(options: NamingHelperSettings, serviceName: string, overridingServiceName?: string);
10
- /**
11
- * The prefix used to reference model or enum types in this schema.
12
- *
13
- * @returns service prefix
14
- */
15
- getServicePrefix(): string;
16
- /**
17
- * The OData service name as it was found and is used in metadata file.
18
- *
19
- * @returns
20
- */
21
- getODataServiceName(): string;
22
- getFileNames(): {
23
- model: string;
24
- qObject: string;
25
- service: string;
26
- };
27
- private getFileName;
28
- getFileNameService(name: string): string;
29
- stripServicePrefix(token: string): string;
30
- private namingFunction;
31
- private getName;
32
- private getModelNamingStrategy;
33
- private getModelPropNamingStrategy;
34
- private getQObjectNamingStrategy;
35
- private getQObjectPropNamingStrategy;
36
- private getOperationNamingStrategy;
37
- getModelName(name: string): string;
38
- getModelPropName(name: string): string;
39
- getEnumName(name: string): string;
40
- getEditableModelName(name: string): string;
41
- getIdModelName(name: string): string;
42
- getOperationParamsModelName(name: string): string;
43
- getQName(name: string): string;
44
- getQPropName(name: string): string;
45
- getQIdFunctionName(name: string): string;
46
- getQFunctionName(name: string): string;
47
- getQActionName(name: string): string;
48
- getMainServiceName(): string;
49
- getServiceName: (name: string) => string;
50
- getCollectionServiceName: (name: string) => string;
51
- getFunctionName(name: string): string;
52
- getActionName(name: string): string;
53
- getRelatedServiceGetter(name: string): string;
54
- getPrivatePropName: (name: string) => string;
55
- }
1
+ import { RunOptions } from "../OptionModel";
2
+ export interface NamingHelperSettings extends Pick<RunOptions, "allowRenaming" | "naming"> {
3
+ }
4
+ export declare class NamingHelper {
5
+ private readonly allowModelPropRenaming;
6
+ private readonly serviceName;
7
+ private readonly servicePrefix;
8
+ private readonly options;
9
+ constructor(options: NamingHelperSettings, serviceName: string, overridingServiceName?: string);
10
+ /**
11
+ * The prefix used to reference model or enum types in this schema.
12
+ *
13
+ * @returns service prefix
14
+ */
15
+ getServicePrefix(): string;
16
+ /**
17
+ * The OData service name as it was found and is used in metadata file.
18
+ *
19
+ * @returns
20
+ */
21
+ getODataServiceName(): string;
22
+ getFileNames(): {
23
+ model: string;
24
+ qObject: string;
25
+ service: string;
26
+ };
27
+ private getFileName;
28
+ getFileNameService(name: string): string;
29
+ stripServicePrefix(token: string): string;
30
+ private namingFunction;
31
+ private getName;
32
+ private getModelNamingStrategy;
33
+ private getModelPropNamingStrategy;
34
+ private getQObjectNamingStrategy;
35
+ private getQObjectPropNamingStrategy;
36
+ private getOperationNamingStrategy;
37
+ getModelName(name: string): string;
38
+ getModelPropName(name: string): string;
39
+ getEnumName(name: string): string;
40
+ getEditableModelName(name: string): string;
41
+ getIdModelName(name: string): string;
42
+ getOperationParamsModelName(name: string): string;
43
+ getQName(name: string): string;
44
+ getQPropName(name: string): string;
45
+ getQIdFunctionName(name: string): string;
46
+ getQFunctionName(name: string): string;
47
+ getQActionName(name: string): string;
48
+ getMainServiceName(): string;
49
+ getServiceName: (name: string) => string;
50
+ getCollectionServiceName: (name: string) => string;
51
+ getFunctionName(name: string): string;
52
+ getActionName(name: string): string;
53
+ getRelatedServiceGetter(name: string): string;
54
+ getPrivatePropName: (name: string) => string;
55
+ }
@@ -1,215 +1,215 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NamingHelper = void 0;
4
- const camel_case_1 = require("camel-case");
5
- const constant_case_1 = require("constant-case");
6
- const pascal_case_1 = require("pascal-case");
7
- const snake_case_1 = require("snake-case");
8
- const NamingModel_1 = require("../NamingModel");
9
- function getNamingStrategyImpl(strategy) {
10
- switch (strategy) {
11
- case NamingModel_1.NamingStrategies.CAMEL_CASE:
12
- return camel_case_1.camelCase;
13
- case NamingModel_1.NamingStrategies.PASCAL_CASE:
14
- return pascal_case_1.pascalCase;
15
- case NamingModel_1.NamingStrategies.CONSTANT_CASE:
16
- return constant_case_1.constantCase;
17
- case NamingModel_1.NamingStrategies.SNAKE_CASE:
18
- return snake_case_1.snakeCase;
19
- default:
20
- return undefined;
21
- }
22
- }
23
- const noopNamingFunction = (value, options) => {
24
- return ((options === null || options === void 0 ? void 0 : options.prefix) || "") + value + ((options === null || options === void 0 ? void 0 : options.suffix) || "");
25
- };
26
- class NamingHelper {
27
- constructor(options, serviceName, overridingServiceName) {
28
- var _a;
29
- this.getServiceName = (name) => {
30
- const opts = this.options.services;
31
- return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
32
- };
33
- this.getCollectionServiceName = (name) => {
34
- var _a;
35
- const opts = this.options.services;
36
- const strategy = this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy);
37
- const result = this.getName(name, strategy, opts === null || opts === void 0 ? void 0 : opts.collection);
38
- return ((_a = opts === null || opts === void 0 ? void 0 : opts.collection) === null || _a === void 0 ? void 0 : _a.applyServiceNaming) ? this.getName(result, strategy, opts) : result;
39
- };
40
- this.getPrivatePropName = (name) => {
41
- var _a;
42
- const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.privateProps;
43
- return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
44
- };
45
- if (!options) {
46
- throw new Error("NamingHelper: Options must be supplied!");
47
- }
48
- if (!(serviceName === null || serviceName === void 0 ? void 0 : serviceName.trim())) {
49
- throw new Error("NamingHelper: ServicePrefix must be supplied!");
50
- }
51
- this.allowModelPropRenaming = (_a = options.allowRenaming) !== null && _a !== void 0 ? _a : false;
52
- this.options = options.naming || {};
53
- this.servicePrefix = serviceName + ".";
54
- this.serviceName = overridingServiceName || serviceName;
55
- }
56
- /**
57
- * The prefix used to reference model or enum types in this schema.
58
- *
59
- * @returns service prefix
60
- */
61
- getServicePrefix() {
62
- return this.servicePrefix;
63
- }
64
- /**
65
- * The OData service name as it was found and is used in metadata file.
66
- *
67
- * @returns
68
- */
69
- getODataServiceName() {
70
- return this.serviceName;
71
- }
72
- getFileNames() {
73
- var _a, _b;
74
- return {
75
- model: this.getFileName((_a = this.options.models) === null || _a === void 0 ? void 0 : _a.fileName),
76
- qObject: this.getFileName((_b = this.options.queryObjects) === null || _b === void 0 ? void 0 : _b.fileName),
77
- service: this.getMainServiceName(),
78
- };
79
- }
80
- getFileName(opts) {
81
- return this.getName(this.serviceName, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
82
- }
83
- getFileNameService(name) {
84
- const opts = this.options.services;
85
- return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
86
- }
87
- stripServicePrefix(token) {
88
- return token.replace(this.servicePrefix, "");
89
- }
90
- namingFunction(strategy) {
91
- const strategyFn = getNamingStrategyImpl(strategy);
92
- if (!strategyFn || !this.allowModelPropRenaming) {
93
- return noopNamingFunction;
94
- }
95
- return (value, options) => {
96
- const prefix = options === null || options === void 0 ? void 0 : options.prefix;
97
- const suffix = options === null || options === void 0 ? void 0 : options.suffix;
98
- const isPrefixSpecialChar = prefix === null || prefix === void 0 ? void 0 : prefix.startsWith("_");
99
- const isSuffixSpecialChar = suffix === null || suffix === void 0 ? void 0 : suffix.endsWith("_");
100
- let result = strategyFn((prefix ? prefix + "_" : "") + value + (suffix ? "_" + suffix : ""));
101
- if (isPrefixSpecialChar) {
102
- result = "_" + result;
103
- }
104
- if (isSuffixSpecialChar) {
105
- result = result + "_";
106
- }
107
- return result;
108
- };
109
- }
110
- getName(name, strategy, options) {
111
- return strategy(this.stripServicePrefix(name), options);
112
- }
113
- getModelNamingStrategy() {
114
- var _a;
115
- return this.namingFunction((_a = this.options.models) === null || _a === void 0 ? void 0 : _a.namingStrategy);
116
- }
117
- getModelPropNamingStrategy() {
118
- var _a;
119
- return this.namingFunction((_a = this.options.models) === null || _a === void 0 ? void 0 : _a.propNamingStrategy);
120
- }
121
- getQObjectNamingStrategy() {
122
- var _a;
123
- return this.namingFunction((_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.namingStrategy);
124
- }
125
- getQObjectPropNamingStrategy() {
126
- var _a;
127
- return this.namingFunction((_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.propNamingStrategy);
128
- }
129
- getOperationNamingStrategy() {
130
- var _a, _b;
131
- return this.namingFunction((_b = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.namingStrategy);
132
- }
133
- getModelName(name) {
134
- return this.getName(name, this.getModelNamingStrategy(), this.options.models);
135
- }
136
- getModelPropName(name) {
137
- return this.getName(name, this.getModelPropNamingStrategy());
138
- }
139
- getEnumName(name) {
140
- return this.getName(name, this.getModelNamingStrategy(), this.options.models);
141
- }
142
- getEditableModelName(name) {
143
- var _a;
144
- let options = (_a = this.options.models) === null || _a === void 0 ? void 0 : _a.editableModels;
145
- const result = this.getName(name, this.getModelNamingStrategy(), options);
146
- return (options === null || options === void 0 ? void 0 : options.applyModelNaming)
147
- ? this.getName(result, this.getModelNamingStrategy(), this.options.models)
148
- : result;
149
- }
150
- getIdModelName(name) {
151
- var _a;
152
- let options = (_a = this.options.models) === null || _a === void 0 ? void 0 : _a.idModels;
153
- const result = this.getName(name, this.getModelNamingStrategy(), options);
154
- return (options === null || options === void 0 ? void 0 : options.applyModelNaming)
155
- ? this.getName(result, this.getModelNamingStrategy(), this.options.models)
156
- : result;
157
- }
158
- getOperationParamsModelName(name) {
159
- var _a;
160
- const settings = (_a = this.options.models) === null || _a === void 0 ? void 0 : _a.operationParamModels;
161
- const result = this.getName(name, this.getModelNamingStrategy(), settings);
162
- return (settings === null || settings === void 0 ? void 0 : settings.applyModelNaming)
163
- ? this.getName(result, this.getModelNamingStrategy(), this.options.models)
164
- : result;
165
- }
166
- getQName(name) {
167
- return this.getName(name, this.getQObjectNamingStrategy(), this.options.queryObjects);
168
- }
169
- getQPropName(name) {
170
- return this.getName(name, this.getQObjectPropNamingStrategy());
171
- }
172
- getQIdFunctionName(name) {
173
- var _a;
174
- const opts = (_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.idFunctions;
175
- const result = this.getName(name, this.getQObjectNamingStrategy(), opts);
176
- return this.getName(result, this.getQObjectNamingStrategy(), this.options.queryObjects);
177
- }
178
- getQFunctionName(name) {
179
- var _a;
180
- const opts = (_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.operations;
181
- const result = this.getName(name, this.getQObjectNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.function) || opts);
182
- return this.getName(result, this.getQObjectNamingStrategy(), this.options.queryObjects);
183
- }
184
- getQActionName(name) {
185
- var _a;
186
- const opts = (_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.operations;
187
- const result = this.getName(name, this.getQObjectNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.action) || opts);
188
- return this.getName(result, this.getQObjectNamingStrategy(), this.options.queryObjects);
189
- }
190
- getMainServiceName() {
191
- var _a, _b, _c, _d;
192
- const name = this.getODataServiceName();
193
- const opts = this.options.services;
194
- const strategy = this.namingFunction((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.main) === null || _a === void 0 ? void 0 : _a.namingStrategy) !== null && _b !== void 0 ? _b : (((_c = opts === null || opts === void 0 ? void 0 : opts.main) === null || _c === void 0 ? void 0 : _c.applyServiceNaming) ? opts.namingStrategy : undefined));
195
- const result = this.getName(name, strategy, opts === null || opts === void 0 ? void 0 : opts.main);
196
- return ((_d = opts === null || opts === void 0 ? void 0 : opts.main) === null || _d === void 0 ? void 0 : _d.applyServiceNaming) ? this.getName(result, strategy, opts) : result;
197
- }
198
- getFunctionName(name) {
199
- var _a;
200
- const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.operations;
201
- return this.getName(name, this.getOperationNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.function) || opts);
202
- }
203
- getActionName(name) {
204
- var _a;
205
- const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.operations;
206
- return this.getName(name, this.getOperationNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.action) || opts);
207
- }
208
- getRelatedServiceGetter(name) {
209
- var _a;
210
- const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.relatedServiceGetter;
211
- return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
212
- }
213
- }
214
- exports.NamingHelper = NamingHelper;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NamingHelper = void 0;
4
+ const camel_case_1 = require("camel-case");
5
+ const constant_case_1 = require("constant-case");
6
+ const pascal_case_1 = require("pascal-case");
7
+ const snake_case_1 = require("snake-case");
8
+ const NamingModel_1 = require("../NamingModel");
9
+ function getNamingStrategyImpl(strategy) {
10
+ switch (strategy) {
11
+ case NamingModel_1.NamingStrategies.CAMEL_CASE:
12
+ return camel_case_1.camelCase;
13
+ case NamingModel_1.NamingStrategies.PASCAL_CASE:
14
+ return pascal_case_1.pascalCase;
15
+ case NamingModel_1.NamingStrategies.CONSTANT_CASE:
16
+ return constant_case_1.constantCase;
17
+ case NamingModel_1.NamingStrategies.SNAKE_CASE:
18
+ return snake_case_1.snakeCase;
19
+ default:
20
+ return undefined;
21
+ }
22
+ }
23
+ const noopNamingFunction = (value, options) => {
24
+ return ((options === null || options === void 0 ? void 0 : options.prefix) || "") + value + ((options === null || options === void 0 ? void 0 : options.suffix) || "");
25
+ };
26
+ class NamingHelper {
27
+ constructor(options, serviceName, overridingServiceName) {
28
+ var _a;
29
+ this.getServiceName = (name) => {
30
+ const opts = this.options.services;
31
+ return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
32
+ };
33
+ this.getCollectionServiceName = (name) => {
34
+ var _a;
35
+ const opts = this.options.services;
36
+ const strategy = this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy);
37
+ const result = this.getName(name, strategy, opts === null || opts === void 0 ? void 0 : opts.collection);
38
+ return ((_a = opts === null || opts === void 0 ? void 0 : opts.collection) === null || _a === void 0 ? void 0 : _a.applyServiceNaming) ? this.getName(result, strategy, opts) : result;
39
+ };
40
+ this.getPrivatePropName = (name) => {
41
+ var _a;
42
+ const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.privateProps;
43
+ return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
44
+ };
45
+ if (!options) {
46
+ throw new Error("NamingHelper: Options must be supplied!");
47
+ }
48
+ if (!(serviceName === null || serviceName === void 0 ? void 0 : serviceName.trim())) {
49
+ throw new Error("NamingHelper: ServicePrefix must be supplied!");
50
+ }
51
+ this.allowModelPropRenaming = (_a = options.allowRenaming) !== null && _a !== void 0 ? _a : false;
52
+ this.options = options.naming || {};
53
+ this.servicePrefix = serviceName + ".";
54
+ this.serviceName = overridingServiceName || serviceName;
55
+ }
56
+ /**
57
+ * The prefix used to reference model or enum types in this schema.
58
+ *
59
+ * @returns service prefix
60
+ */
61
+ getServicePrefix() {
62
+ return this.servicePrefix;
63
+ }
64
+ /**
65
+ * The OData service name as it was found and is used in metadata file.
66
+ *
67
+ * @returns
68
+ */
69
+ getODataServiceName() {
70
+ return this.serviceName;
71
+ }
72
+ getFileNames() {
73
+ var _a, _b;
74
+ return {
75
+ model: this.getFileName((_a = this.options.models) === null || _a === void 0 ? void 0 : _a.fileName),
76
+ qObject: this.getFileName((_b = this.options.queryObjects) === null || _b === void 0 ? void 0 : _b.fileName),
77
+ service: this.getMainServiceName(),
78
+ };
79
+ }
80
+ getFileName(opts) {
81
+ return this.getName(this.serviceName, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
82
+ }
83
+ getFileNameService(name) {
84
+ const opts = this.options.services;
85
+ return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
86
+ }
87
+ stripServicePrefix(token) {
88
+ return token.replace(this.servicePrefix, "");
89
+ }
90
+ namingFunction(strategy) {
91
+ const strategyFn = getNamingStrategyImpl(strategy);
92
+ if (!strategyFn || !this.allowModelPropRenaming) {
93
+ return noopNamingFunction;
94
+ }
95
+ return (value, options) => {
96
+ const prefix = options === null || options === void 0 ? void 0 : options.prefix;
97
+ const suffix = options === null || options === void 0 ? void 0 : options.suffix;
98
+ const isPrefixSpecialChar = prefix === null || prefix === void 0 ? void 0 : prefix.startsWith("_");
99
+ const isSuffixSpecialChar = suffix === null || suffix === void 0 ? void 0 : suffix.endsWith("_");
100
+ let result = strategyFn((prefix ? prefix + "_" : "") + value + (suffix ? "_" + suffix : ""));
101
+ if (isPrefixSpecialChar) {
102
+ result = "_" + result;
103
+ }
104
+ if (isSuffixSpecialChar) {
105
+ result = result + "_";
106
+ }
107
+ return result;
108
+ };
109
+ }
110
+ getName(name, strategy, options) {
111
+ return strategy(this.stripServicePrefix(name), options);
112
+ }
113
+ getModelNamingStrategy() {
114
+ var _a;
115
+ return this.namingFunction((_a = this.options.models) === null || _a === void 0 ? void 0 : _a.namingStrategy);
116
+ }
117
+ getModelPropNamingStrategy() {
118
+ var _a;
119
+ return this.namingFunction((_a = this.options.models) === null || _a === void 0 ? void 0 : _a.propNamingStrategy);
120
+ }
121
+ getQObjectNamingStrategy() {
122
+ var _a;
123
+ return this.namingFunction((_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.namingStrategy);
124
+ }
125
+ getQObjectPropNamingStrategy() {
126
+ var _a;
127
+ return this.namingFunction((_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.propNamingStrategy);
128
+ }
129
+ getOperationNamingStrategy() {
130
+ var _a, _b;
131
+ return this.namingFunction((_b = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.namingStrategy);
132
+ }
133
+ getModelName(name) {
134
+ return this.getName(name, this.getModelNamingStrategy(), this.options.models);
135
+ }
136
+ getModelPropName(name) {
137
+ return this.getName(name, this.getModelPropNamingStrategy());
138
+ }
139
+ getEnumName(name) {
140
+ return this.getName(name, this.getModelNamingStrategy(), this.options.models);
141
+ }
142
+ getEditableModelName(name) {
143
+ var _a;
144
+ let options = (_a = this.options.models) === null || _a === void 0 ? void 0 : _a.editableModels;
145
+ const result = this.getName(name, this.getModelNamingStrategy(), options);
146
+ return (options === null || options === void 0 ? void 0 : options.applyModelNaming)
147
+ ? this.getName(result, this.getModelNamingStrategy(), this.options.models)
148
+ : result;
149
+ }
150
+ getIdModelName(name) {
151
+ var _a;
152
+ let options = (_a = this.options.models) === null || _a === void 0 ? void 0 : _a.idModels;
153
+ const result = this.getName(name, this.getModelNamingStrategy(), options);
154
+ return (options === null || options === void 0 ? void 0 : options.applyModelNaming)
155
+ ? this.getName(result, this.getModelNamingStrategy(), this.options.models)
156
+ : result;
157
+ }
158
+ getOperationParamsModelName(name) {
159
+ var _a;
160
+ const settings = (_a = this.options.models) === null || _a === void 0 ? void 0 : _a.operationParamModels;
161
+ const result = this.getName(name, this.getModelNamingStrategy(), settings);
162
+ return (settings === null || settings === void 0 ? void 0 : settings.applyModelNaming)
163
+ ? this.getName(result, this.getModelNamingStrategy(), this.options.models)
164
+ : result;
165
+ }
166
+ getQName(name) {
167
+ return this.getName(name, this.getQObjectNamingStrategy(), this.options.queryObjects);
168
+ }
169
+ getQPropName(name) {
170
+ return this.getName(name, this.getQObjectPropNamingStrategy());
171
+ }
172
+ getQIdFunctionName(name) {
173
+ var _a;
174
+ const opts = (_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.idFunctions;
175
+ const result = this.getName(name, this.getQObjectNamingStrategy(), opts);
176
+ return this.getName(result, this.getQObjectNamingStrategy(), this.options.queryObjects);
177
+ }
178
+ getQFunctionName(name) {
179
+ var _a;
180
+ const opts = (_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.operations;
181
+ const result = this.getName(name, this.getQObjectNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.function) || opts);
182
+ return this.getName(result, this.getQObjectNamingStrategy(), this.options.queryObjects);
183
+ }
184
+ getQActionName(name) {
185
+ var _a;
186
+ const opts = (_a = this.options.queryObjects) === null || _a === void 0 ? void 0 : _a.operations;
187
+ const result = this.getName(name, this.getQObjectNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.action) || opts);
188
+ return this.getName(result, this.getQObjectNamingStrategy(), this.options.queryObjects);
189
+ }
190
+ getMainServiceName() {
191
+ var _a, _b, _c, _d;
192
+ const name = this.getODataServiceName();
193
+ const opts = this.options.services;
194
+ const strategy = this.namingFunction((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.main) === null || _a === void 0 ? void 0 : _a.namingStrategy) !== null && _b !== void 0 ? _b : (((_c = opts === null || opts === void 0 ? void 0 : opts.main) === null || _c === void 0 ? void 0 : _c.applyServiceNaming) ? opts.namingStrategy : undefined));
195
+ const result = this.getName(name, strategy, opts === null || opts === void 0 ? void 0 : opts.main);
196
+ return ((_d = opts === null || opts === void 0 ? void 0 : opts.main) === null || _d === void 0 ? void 0 : _d.applyServiceNaming) ? this.getName(result, strategy, opts) : result;
197
+ }
198
+ getFunctionName(name) {
199
+ var _a;
200
+ const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.operations;
201
+ return this.getName(name, this.getOperationNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.function) || opts);
202
+ }
203
+ getActionName(name) {
204
+ var _a;
205
+ const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.operations;
206
+ return this.getName(name, this.getOperationNamingStrategy(), (opts === null || opts === void 0 ? void 0 : opts.action) || opts);
207
+ }
208
+ getRelatedServiceGetter(name) {
209
+ var _a;
210
+ const opts = (_a = this.options.services) === null || _a === void 0 ? void 0 : _a.relatedServiceGetter;
211
+ return this.getName(name, this.namingFunction(opts === null || opts === void 0 ? void 0 : opts.namingStrategy), opts);
212
+ }
213
+ }
214
+ exports.NamingHelper = NamingHelper;
215
215
  //# sourceMappingURL=NamingHelper.js.map
@@ -1,21 +1,21 @@
1
- import { DigestionOptions } from "../FactoryFunctionModel";
2
- import { EntityGenerationOptions, PropertyGenerationOptions } from "../OptionModel";
3
- export interface ConfiguredProp extends Omit<PropertyGenerationOptions, "name"> {
4
- }
5
- export interface ConfiguredEntity extends Omit<EntityGenerationOptions, "name"> {
6
- }
7
- export declare class ServiceConfigHelper {
8
- private propMapping;
9
- private entityMapping;
10
- private propRegExps;
11
- private entityRegExps;
12
- constructor(options: DigestionOptions);
13
- private evaluateProps;
14
- private getPropByName;
15
- private getPropByRegExp;
16
- findConfigPropByName: (name: string) => ConfiguredProp | undefined;
17
- private evaluateEntities;
18
- private getEntityByName;
19
- private getEntityByRegExp;
20
- findConfigEntityByName: (name: string) => ConfiguredEntity | undefined;
21
- }
1
+ import { DigestionOptions } from "../FactoryFunctionModel";
2
+ import { EntityGenerationOptions, PropertyGenerationOptions } from "../OptionModel";
3
+ export interface ConfiguredProp extends Omit<PropertyGenerationOptions, "name"> {
4
+ }
5
+ export interface ConfiguredEntity extends Omit<EntityGenerationOptions, "name"> {
6
+ }
7
+ export declare class ServiceConfigHelper {
8
+ private propMapping;
9
+ private entityMapping;
10
+ private propRegExps;
11
+ private entityRegExps;
12
+ constructor(options: DigestionOptions);
13
+ private evaluateProps;
14
+ private getPropByName;
15
+ private getPropByRegExp;
16
+ findConfigPropByName: (name: string) => ConfiguredProp | undefined;
17
+ private evaluateEntities;
18
+ private getEntityByName;
19
+ private getEntityByRegExp;
20
+ findConfigEntityByName: (name: string) => ConfiguredEntity | undefined;
21
+ }