@odata2ts/odata2ts 0.23.0 → 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.
- package/CHANGELOG.md +14 -0
- package/README.md +74 -74
- package/lib/FactoryFunctionModel.d.ts +13 -13
- package/lib/FactoryFunctionModel.js +2 -2
- package/lib/FactoryFunctionModel.js.map +1 -1
- package/lib/NamingModel.d.ts +182 -182
- package/lib/NamingModel.js +11 -11
- package/lib/NamingModel.js.map +1 -1
- package/lib/OptionModel.d.ts +228 -223
- package/lib/OptionModel.js +23 -23
- package/lib/OptionModel.js.map +1 -1
- package/lib/app.d.ts +8 -8
- package/lib/app.js +63 -63
- package/lib/app.js.map +1 -1
- package/lib/cli.d.ts +3 -3
- package/lib/cli.js +153 -153
- package/lib/data-model/DataModel.d.ts +85 -85
- package/lib/data-model/DataModel.js +134 -134
- package/lib/data-model/DataModelDigestion.d.ts +44 -44
- package/lib/data-model/DataModelDigestion.js +274 -274
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- package/lib/data-model/DataModelDigestionV2.d.ts +10 -10
- package/lib/data-model/DataModelDigestionV2.js +200 -200
- package/lib/data-model/DataModelDigestionV4.d.ts +3 -3
- package/lib/data-model/DataModelDigestionV4.js +195 -195
- package/lib/data-model/DataTypeModel.d.ts +102 -102
- package/lib/data-model/DataTypeModel.js +8 -8
- package/lib/data-model/DataTypeModel.js.map +1 -1
- package/lib/data-model/NamingHelper.d.ts +55 -55
- package/lib/data-model/NamingHelper.js +214 -214
- package/lib/data-model/ServiceConfigHelper.d.ts +21 -21
- package/lib/data-model/ServiceConfigHelper.js +113 -113
- package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +80 -80
- package/lib/data-model/edmx/ODataEdmxModelBase.js +2 -2
- package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
- package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +63 -63
- package/lib/data-model/edmx/ODataEdmxModelV3.js +2 -2
- package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +67 -67
- package/lib/data-model/edmx/ODataEdmxModelV4.js +2 -2
- package/lib/defaultConfig.d.ts +9 -9
- package/lib/defaultConfig.js +165 -164
- package/lib/defaultConfig.js.map +1 -1
- package/lib/evaluateConfig.d.ts +25 -25
- package/lib/evaluateConfig.js +82 -82
- package/lib/generator/ImportContainer.d.ts +16 -16
- package/lib/generator/ImportContainer.js +91 -91
- package/lib/generator/ImportContainer.js.map +1 -1
- package/lib/generator/ModelGenerator.d.ts +2 -2
- package/lib/generator/ModelGenerator.js +211 -183
- package/lib/generator/ModelGenerator.js.map +1 -1
- package/lib/generator/QueryObjectGenerator.d.ts +2 -2
- package/lib/generator/QueryObjectGenerator.js +239 -239
- package/lib/generator/ServiceGenerator.d.ts +8 -8
- package/lib/generator/ServiceGenerator.js +422 -422
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/lib/generator/index.d.ts +3 -3
- package/lib/generator/index.js +9 -9
- package/lib/index.d.ts +3 -3
- package/lib/index.js +6 -6
- package/lib/project/ProjectManager.d.ts +30 -30
- package/lib/project/ProjectManager.js +177 -175
- package/lib/project/ProjectManager.js.map +1 -1
- package/lib/project/formatter/BaseFormatter.d.ts +49 -49
- package/lib/project/formatter/BaseFormatter.js +30 -30
- package/lib/project/formatter/FileFormatter.d.ts +16 -16
- package/lib/project/formatter/FileFormatter.js +2 -2
- package/lib/project/formatter/NoopFormatter.d.ts +29 -29
- package/lib/project/formatter/NoopFormatter.js +42 -42
- package/lib/project/formatter/PrettierFormatter.d.ts +46 -46
- package/lib/project/formatter/PrettierFormatter.js +92 -92
- package/lib/project/formatter/index.d.ts +2 -2
- package/lib/project/formatter/index.js +14 -14
- package/lib/project/logger/logFilePath.d.ts +1 -1
- package/lib/project/logger/logFilePath.js +12 -12
- package/lib/run-cli.d.ts +2 -2
- package/lib/run-cli.js +6 -6
- package/package.json +27 -28
package/lib/evaluateConfig.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.evaluateConfigOptions = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
|
|
6
|
-
const defaultConfig_1 = require("./defaultConfig");
|
|
7
|
-
const OptionModel_1 = require("./OptionModel");
|
|
8
|
-
/**
|
|
9
|
-
* Provides default values and evaluates the various config file and CLI options.
|
|
10
|
-
* This function always returns a list of RunOptions,
|
|
11
|
-
* whereby each item represents one generation run / one service.
|
|
12
|
-
*
|
|
13
|
-
* Configurations are merged in the following order (last one wins):
|
|
14
|
-
* - default values
|
|
15
|
-
* - config file: base settings
|
|
16
|
-
* - config file: service specific settings
|
|
17
|
-
* - CLI options
|
|
18
|
-
*
|
|
19
|
-
* If the CLI options specify source and output, then the service config is completely ignored and only the
|
|
20
|
-
* base settings are applied from the config file.
|
|
21
|
-
*
|
|
22
|
-
* If the CLI options do not specify source and output, but do specify services, then these services must
|
|
23
|
-
* exist in the config file and each service must supply values for source and output as a minimum.
|
|
24
|
-
*
|
|
25
|
-
* If the CLI options neither entail source nor services, then at least one service must be configured in the
|
|
26
|
-
* config file. All configured services are returned.
|
|
27
|
-
*
|
|
28
|
-
* @param cliOpts CLI passed options
|
|
29
|
-
* @param configOpts config file options
|
|
30
|
-
*/
|
|
31
|
-
function evaluateConfigOptions(cliOpts, configOpts) {
|
|
32
|
-
var _a;
|
|
33
|
-
const defaultConfig = ((_a = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : (0, defaultConfig_1.getDefaultConfig)();
|
|
34
|
-
// No config file
|
|
35
|
-
if (!configOpts) {
|
|
36
|
-
if (!cliOpts.source || !cliOpts.output) {
|
|
37
|
-
throw new Error("Without any configuration file options --source and --output must be specified!");
|
|
38
|
-
}
|
|
39
|
-
return [(0, deepmerge_1.default)(defaultConfig, cliOpts)];
|
|
40
|
-
}
|
|
41
|
-
const { services: cliServices, source, output } = cliOpts, cliBaseOpts = tslib_1.__rest(cliOpts, ["services", "source", "output"]);
|
|
42
|
-
const { services: confServices } = configOpts, confBaseOpts = tslib_1.__rest(configOpts, ["services"]);
|
|
43
|
-
// No configurations of services in config file
|
|
44
|
-
// or CLI opts specify source and output => ignore service config
|
|
45
|
-
if ((source && output) || !confServices) {
|
|
46
|
-
if (!source || !output) {
|
|
47
|
-
throw new Error("No services were configured in config file, so options --source and --output must be specified!");
|
|
48
|
-
}
|
|
49
|
-
const merged = deepmerge_1.default.all([defaultConfig, confBaseOpts, cliOpts]);
|
|
50
|
-
return [safeGuardOptions(merged)];
|
|
51
|
-
}
|
|
52
|
-
// Either services are specified or we use all configured services
|
|
53
|
-
const servicesToUse = (cliServices === null || cliServices === void 0 ? void 0 : cliServices.length) ? cliServices : Object.keys(confServices);
|
|
54
|
-
return servicesToUse.map((s) => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
const service = confServices[s];
|
|
57
|
-
if (!service) {
|
|
58
|
-
throw new Error(`Specified service "${s}" doesn't exist in configuration!`);
|
|
59
|
-
}
|
|
60
|
-
const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : defaultConfig;
|
|
61
|
-
const merged = deepmerge_1.default.all([serviceDefault, confBaseOpts, service, cliBaseOpts]);
|
|
62
|
-
return safeGuardOptions(merged);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
exports.evaluateConfigOptions = evaluateConfigOptions;
|
|
66
|
-
/**
|
|
67
|
-
* Make sure that some options are only active if in correct mode.
|
|
68
|
-
* @param options
|
|
69
|
-
*/
|
|
70
|
-
function safeGuardOptions(options) {
|
|
71
|
-
// skip options are not valid for service generation
|
|
72
|
-
if (options.mode === OptionModel_1.Modes.service || options.mode === OptionModel_1.Modes.all) {
|
|
73
|
-
options.skipEditableModels = false;
|
|
74
|
-
options.skipIdModels = false;
|
|
75
|
-
options.skipOperations = false;
|
|
76
|
-
}
|
|
77
|
-
// special option which is only valid for model generation
|
|
78
|
-
if (options.mode !== OptionModel_1.Modes.models) {
|
|
79
|
-
options.v2ModelsWithExtraResultsWrapping = false;
|
|
80
|
-
}
|
|
81
|
-
return options;
|
|
82
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateConfigOptions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
|
|
6
|
+
const defaultConfig_1 = require("./defaultConfig");
|
|
7
|
+
const OptionModel_1 = require("./OptionModel");
|
|
8
|
+
/**
|
|
9
|
+
* Provides default values and evaluates the various config file and CLI options.
|
|
10
|
+
* This function always returns a list of RunOptions,
|
|
11
|
+
* whereby each item represents one generation run / one service.
|
|
12
|
+
*
|
|
13
|
+
* Configurations are merged in the following order (last one wins):
|
|
14
|
+
* - default values
|
|
15
|
+
* - config file: base settings
|
|
16
|
+
* - config file: service specific settings
|
|
17
|
+
* - CLI options
|
|
18
|
+
*
|
|
19
|
+
* If the CLI options specify source and output, then the service config is completely ignored and only the
|
|
20
|
+
* base settings are applied from the config file.
|
|
21
|
+
*
|
|
22
|
+
* If the CLI options do not specify source and output, but do specify services, then these services must
|
|
23
|
+
* exist in the config file and each service must supply values for source and output as a minimum.
|
|
24
|
+
*
|
|
25
|
+
* If the CLI options neither entail source nor services, then at least one service must be configured in the
|
|
26
|
+
* config file. All configured services are returned.
|
|
27
|
+
*
|
|
28
|
+
* @param cliOpts CLI passed options
|
|
29
|
+
* @param configOpts config file options
|
|
30
|
+
*/
|
|
31
|
+
function evaluateConfigOptions(cliOpts, configOpts) {
|
|
32
|
+
var _a;
|
|
33
|
+
const defaultConfig = ((_a = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : (0, defaultConfig_1.getDefaultConfig)();
|
|
34
|
+
// No config file
|
|
35
|
+
if (!configOpts) {
|
|
36
|
+
if (!cliOpts.source || !cliOpts.output) {
|
|
37
|
+
throw new Error("Without any configuration file options --source and --output must be specified!");
|
|
38
|
+
}
|
|
39
|
+
return [(0, deepmerge_1.default)(defaultConfig, cliOpts)];
|
|
40
|
+
}
|
|
41
|
+
const { services: cliServices, source, output } = cliOpts, cliBaseOpts = tslib_1.__rest(cliOpts, ["services", "source", "output"]);
|
|
42
|
+
const { services: confServices } = configOpts, confBaseOpts = tslib_1.__rest(configOpts, ["services"]);
|
|
43
|
+
// No configurations of services in config file
|
|
44
|
+
// or CLI opts specify source and output => ignore service config
|
|
45
|
+
if ((source && output) || !confServices) {
|
|
46
|
+
if (!source || !output) {
|
|
47
|
+
throw new Error("No services were configured in config file, so options --source and --output must be specified!");
|
|
48
|
+
}
|
|
49
|
+
const merged = deepmerge_1.default.all([defaultConfig, confBaseOpts, cliOpts]);
|
|
50
|
+
return [safeGuardOptions(merged)];
|
|
51
|
+
}
|
|
52
|
+
// Either services are specified or we use all configured services
|
|
53
|
+
const servicesToUse = (cliServices === null || cliServices === void 0 ? void 0 : cliServices.length) ? cliServices : Object.keys(confServices);
|
|
54
|
+
return servicesToUse.map((s) => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const service = confServices[s];
|
|
57
|
+
if (!service) {
|
|
58
|
+
throw new Error(`Specified service "${s}" doesn't exist in configuration!`);
|
|
59
|
+
}
|
|
60
|
+
const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : defaultConfig;
|
|
61
|
+
const merged = deepmerge_1.default.all([serviceDefault, confBaseOpts, service, cliBaseOpts]);
|
|
62
|
+
return safeGuardOptions(merged);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.evaluateConfigOptions = evaluateConfigOptions;
|
|
66
|
+
/**
|
|
67
|
+
* Make sure that some options are only active if in correct mode.
|
|
68
|
+
* @param options
|
|
69
|
+
*/
|
|
70
|
+
function safeGuardOptions(options) {
|
|
71
|
+
// skip options are not valid for service generation
|
|
72
|
+
if (options.mode === OptionModel_1.Modes.service || options.mode === OptionModel_1.Modes.all) {
|
|
73
|
+
options.skipEditableModels = false;
|
|
74
|
+
options.skipIdModels = false;
|
|
75
|
+
options.skipOperations = false;
|
|
76
|
+
}
|
|
77
|
+
// special option which is only valid for model generation
|
|
78
|
+
if (options.mode !== OptionModel_1.Modes.models) {
|
|
79
|
+
options.v2ModelsWithExtraResultsWrapping = false;
|
|
80
|
+
}
|
|
81
|
+
return options;
|
|
82
|
+
}
|
|
83
83
|
//# sourceMappingURL=evaluateConfig.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ImportDeclarationStructure } from "ts-morph";
|
|
2
|
-
import { ProjectFiles } from "../data-model/DataModel";
|
|
3
|
-
export declare class ImportContainer {
|
|
4
|
-
private mapping;
|
|
5
|
-
private container;
|
|
6
|
-
constructor(fileNames: ProjectFiles);
|
|
7
|
-
addFromCore(...names: Array<string>): void;
|
|
8
|
-
addFromQObject(...names: Array<string>): void;
|
|
9
|
-
addFromClientApi(...names: Array<string>): void;
|
|
10
|
-
addFromService(...names: Array<string>): void;
|
|
11
|
-
addGeneratedModel(...names: Array<string>): void;
|
|
12
|
-
addGeneratedQObject(...names: Array<string>): void;
|
|
13
|
-
addCustomType(moduleName: string, typeName: string): void;
|
|
14
|
-
addGeneratedService(key: string, ...names: Array<string>): void;
|
|
15
|
-
getImportDeclarations(fromSubPath?: boolean): Array<ImportDeclarationStructure>;
|
|
16
|
-
}
|
|
1
|
+
import { ImportDeclarationStructure } from "ts-morph";
|
|
2
|
+
import { ProjectFiles } from "../data-model/DataModel";
|
|
3
|
+
export declare class ImportContainer {
|
|
4
|
+
private mapping;
|
|
5
|
+
private container;
|
|
6
|
+
constructor(fileNames: ProjectFiles);
|
|
7
|
+
addFromCore(...names: Array<string>): void;
|
|
8
|
+
addFromQObject(...names: Array<string>): void;
|
|
9
|
+
addFromClientApi(...names: Array<string>): void;
|
|
10
|
+
addFromService(...names: Array<string>): void;
|
|
11
|
+
addGeneratedModel(...names: Array<string>): void;
|
|
12
|
+
addGeneratedQObject(...names: Array<string>): void;
|
|
13
|
+
addCustomType(moduleName: string, typeName: string): void;
|
|
14
|
+
addGeneratedService(key: string, ...names: Array<string>): void;
|
|
15
|
+
getImportDeclarations(fromSubPath?: boolean): Array<ImportDeclarationStructure>;
|
|
16
|
+
}
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImportContainer = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
class ImportContainer {
|
|
6
|
-
constructor(fileNames) {
|
|
7
|
-
this.mapping = {
|
|
8
|
-
core: { moduleName: "@odata2ts/odata-core", isRelative: false },
|
|
9
|
-
qobjects: { moduleName: "@odata2ts/odata-query-objects", isRelative: false },
|
|
10
|
-
clientApi: { moduleName: "@odata2ts/http-client-api", isRelative: false },
|
|
11
|
-
service: { moduleName: "@odata2ts/odata-service", isRelative: false },
|
|
12
|
-
genModel: { moduleName: "", isRelative: true },
|
|
13
|
-
genQObjects: { moduleName: "", isRelative: true },
|
|
14
|
-
};
|
|
15
|
-
this.container = {
|
|
16
|
-
core: new Set(),
|
|
17
|
-
qobjects: new Set(),
|
|
18
|
-
clientApi: new Set(),
|
|
19
|
-
service: new Set(),
|
|
20
|
-
genModel: new Set(),
|
|
21
|
-
genQObjects: new Set(),
|
|
22
|
-
genServices: {},
|
|
23
|
-
customTypes: new Map(),
|
|
24
|
-
};
|
|
25
|
-
this.mapping.genModel.moduleName = fileNames.model;
|
|
26
|
-
this.mapping.genQObjects.moduleName = fileNames.qObject;
|
|
27
|
-
}
|
|
28
|
-
addFromCore(...names) {
|
|
29
|
-
names.forEach((n) => this.container.core.add(n));
|
|
30
|
-
}
|
|
31
|
-
addFromQObject(...names) {
|
|
32
|
-
names.forEach((n) => this.container.qobjects.add(n));
|
|
33
|
-
}
|
|
34
|
-
addFromClientApi(...names) {
|
|
35
|
-
names.forEach((n) => this.container.clientApi.add(n));
|
|
36
|
-
}
|
|
37
|
-
addFromService(...names) {
|
|
38
|
-
names.forEach((n) => this.container.service.add(n));
|
|
39
|
-
}
|
|
40
|
-
addGeneratedModel(...names) {
|
|
41
|
-
names.forEach((n) => this.container.genModel.add(n));
|
|
42
|
-
}
|
|
43
|
-
addGeneratedQObject(...names) {
|
|
44
|
-
names.forEach((n) => this.container.genQObjects.add(n));
|
|
45
|
-
}
|
|
46
|
-
addCustomType(moduleName, typeName) {
|
|
47
|
-
let importList = this.container.customTypes.get(moduleName);
|
|
48
|
-
if (!importList) {
|
|
49
|
-
importList = new Set();
|
|
50
|
-
this.container.customTypes.set(moduleName, importList);
|
|
51
|
-
}
|
|
52
|
-
importList.add(typeName);
|
|
53
|
-
}
|
|
54
|
-
addGeneratedService(key, ...names) {
|
|
55
|
-
let serv = this.container.genServices[key];
|
|
56
|
-
if (!serv) {
|
|
57
|
-
serv = new Set();
|
|
58
|
-
this.container.genServices[key] = serv;
|
|
59
|
-
}
|
|
60
|
-
names.forEach((n) => serv.add(n));
|
|
61
|
-
}
|
|
62
|
-
getImportDeclarations(fromSubPath = false) {
|
|
63
|
-
const _a = this.container, { genServices, customTypes } = _a, standardImports = tslib_1.__rest(_a, ["genServices", "customTypes"]);
|
|
64
|
-
return [
|
|
65
|
-
...[...customTypes.keys()]
|
|
66
|
-
.filter((key) => { var _a; return !!((_a = customTypes.get(key)) === null || _a === void 0 ? void 0 : _a.size); })
|
|
67
|
-
.map((key) => {
|
|
68
|
-
return {
|
|
69
|
-
namedImports: [...customTypes.get(key)],
|
|
70
|
-
moduleSpecifier: key,
|
|
71
|
-
};
|
|
72
|
-
}),
|
|
73
|
-
...Object.entries(standardImports)
|
|
74
|
-
.filter(([key, values]) => !!values.size)
|
|
75
|
-
.map(([key, values]) => {
|
|
76
|
-
const mapping = this.mapping[key];
|
|
77
|
-
return {
|
|
78
|
-
namedImports: [...values],
|
|
79
|
-
moduleSpecifier: `${mapping.isRelative ? `${fromSubPath ? ".." : "."}/` : ""}${mapping.moduleName}`,
|
|
80
|
-
};
|
|
81
|
-
}),
|
|
82
|
-
...Object.entries(genServices).map(([key, values]) => {
|
|
83
|
-
return {
|
|
84
|
-
namedImports: [...values],
|
|
85
|
-
moduleSpecifier: (fromSubPath ? "./" : "./service/") + key,
|
|
86
|
-
};
|
|
87
|
-
}),
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.ImportContainer = ImportContainer;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportContainer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
class ImportContainer {
|
|
6
|
+
constructor(fileNames) {
|
|
7
|
+
this.mapping = {
|
|
8
|
+
core: { moduleName: "@odata2ts/odata-core", isRelative: false },
|
|
9
|
+
qobjects: { moduleName: "@odata2ts/odata-query-objects", isRelative: false },
|
|
10
|
+
clientApi: { moduleName: "@odata2ts/http-client-api", isRelative: false },
|
|
11
|
+
service: { moduleName: "@odata2ts/odata-service", isRelative: false },
|
|
12
|
+
genModel: { moduleName: "", isRelative: true },
|
|
13
|
+
genQObjects: { moduleName: "", isRelative: true },
|
|
14
|
+
};
|
|
15
|
+
this.container = {
|
|
16
|
+
core: new Set(),
|
|
17
|
+
qobjects: new Set(),
|
|
18
|
+
clientApi: new Set(),
|
|
19
|
+
service: new Set(),
|
|
20
|
+
genModel: new Set(),
|
|
21
|
+
genQObjects: new Set(),
|
|
22
|
+
genServices: {},
|
|
23
|
+
customTypes: new Map(),
|
|
24
|
+
};
|
|
25
|
+
this.mapping.genModel.moduleName = fileNames.model;
|
|
26
|
+
this.mapping.genQObjects.moduleName = fileNames.qObject;
|
|
27
|
+
}
|
|
28
|
+
addFromCore(...names) {
|
|
29
|
+
names.forEach((n) => this.container.core.add(n));
|
|
30
|
+
}
|
|
31
|
+
addFromQObject(...names) {
|
|
32
|
+
names.forEach((n) => this.container.qobjects.add(n));
|
|
33
|
+
}
|
|
34
|
+
addFromClientApi(...names) {
|
|
35
|
+
names.forEach((n) => this.container.clientApi.add(n));
|
|
36
|
+
}
|
|
37
|
+
addFromService(...names) {
|
|
38
|
+
names.forEach((n) => this.container.service.add(n));
|
|
39
|
+
}
|
|
40
|
+
addGeneratedModel(...names) {
|
|
41
|
+
names.forEach((n) => this.container.genModel.add(n));
|
|
42
|
+
}
|
|
43
|
+
addGeneratedQObject(...names) {
|
|
44
|
+
names.forEach((n) => this.container.genQObjects.add(n));
|
|
45
|
+
}
|
|
46
|
+
addCustomType(moduleName, typeName) {
|
|
47
|
+
let importList = this.container.customTypes.get(moduleName);
|
|
48
|
+
if (!importList) {
|
|
49
|
+
importList = new Set();
|
|
50
|
+
this.container.customTypes.set(moduleName, importList);
|
|
51
|
+
}
|
|
52
|
+
importList.add(typeName);
|
|
53
|
+
}
|
|
54
|
+
addGeneratedService(key, ...names) {
|
|
55
|
+
let serv = this.container.genServices[key];
|
|
56
|
+
if (!serv) {
|
|
57
|
+
serv = new Set();
|
|
58
|
+
this.container.genServices[key] = serv;
|
|
59
|
+
}
|
|
60
|
+
names.forEach((n) => serv.add(n));
|
|
61
|
+
}
|
|
62
|
+
getImportDeclarations(fromSubPath = false) {
|
|
63
|
+
const _a = this.container, { genServices, customTypes } = _a, standardImports = tslib_1.__rest(_a, ["genServices", "customTypes"]);
|
|
64
|
+
return [
|
|
65
|
+
...[...customTypes.keys()]
|
|
66
|
+
.filter((key) => { var _a; return !!((_a = customTypes.get(key)) === null || _a === void 0 ? void 0 : _a.size); })
|
|
67
|
+
.map((key) => {
|
|
68
|
+
return {
|
|
69
|
+
namedImports: [...customTypes.get(key)],
|
|
70
|
+
moduleSpecifier: key,
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
...Object.entries(standardImports)
|
|
74
|
+
.filter(([key, values]) => !!values.size)
|
|
75
|
+
.map(([key, values]) => {
|
|
76
|
+
const mapping = this.mapping[key];
|
|
77
|
+
return {
|
|
78
|
+
namedImports: [...values],
|
|
79
|
+
moduleSpecifier: `${mapping.isRelative ? `${fromSubPath ? ".." : "."}/` : ""}${mapping.moduleName}`,
|
|
80
|
+
};
|
|
81
|
+
}),
|
|
82
|
+
...Object.entries(genServices).map(([key, values]) => {
|
|
83
|
+
return {
|
|
84
|
+
namedImports: [...values],
|
|
85
|
+
moduleSpecifier: (fromSubPath ? "./" : "./service/") + key,
|
|
86
|
+
};
|
|
87
|
+
}),
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ImportContainer = ImportContainer;
|
|
92
92
|
//# sourceMappingURL=ImportContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportContainer.js","sourceRoot":"","sources":["../../src/generator/ImportContainer.ts"],"names":[],"mappings":";;;;AAeA,MAAa,eAAe;IAuB1B,YAAY,SAAuB;QAtB3B,YAAO,GAEX;YACF,IAAI,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,KAAK,EAAE;YAC/D,QAAQ,EAAE,EAAE,UAAU,EAAE,+BAA+B,EAAE,UAAU,EAAE,KAAK,EAAE;YAC5E,SAAS,EAAE,EAAE,UAAU,EAAE,2BAA2B,EAAE,UAAU,EAAE,KAAK,EAAE;YACzE,OAAO,EAAE,EAAE,UAAU,EAAE,yBAAyB,EAAE,UAAU,E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EAAE;gBACnD,OAAO;oBACL,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC;oBACzB,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,GAAG;iBAC7B,CAAC;YAClC,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAnGD,0CAmGC","sourcesContent":["import { ImportDeclarationStructure } from \"ts-morph\";\n\nimport { ProjectFiles } from \"../data-model/DataModel\";\n\ntype ImportContainerType = {\n core: Set<string>;\n qobjects: Set<string>;\n clientApi: Set<string>;\n service: Set<string>;\n genModel: Set<string>;\n genQObjects: Set<string>;\n genServices: { [key: string]: Set<string> };\n customTypes: Map<string, Set<string>>;\n};\n\nexport class ImportContainer {\n private mapping: {\n [K in keyof ImportContainerType as string]: { moduleName: string; isRelative: boolean; addName?: boolean };\n } = {\n core: { moduleName: \"@odata2ts/odata-core\", isRelative: false },\n qobjects: { moduleName: \"@odata2ts/odata-query-objects\", isRelative: false },\n clientApi: { moduleName: \"@odata2ts/http-client-api\", isRelative: false },\n service: { moduleName: \"@odata2ts/odata-service\", isRelative: false },\n genModel: { moduleName: \"\", isRelative: true },\n genQObjects: { moduleName: \"\", isRelative: true },\n };\n\n private container: ImportContainerType = {\n core: new Set(),\n qobjects: new Set(),\n clientApi: new Set(),\n service: new Set(),\n genModel: new Set(),\n genQObjects: new Set(),\n genServices: {},\n customTypes: new Map(),\n };\n\n constructor(fileNames: ProjectFiles) {\n this.mapping.genModel.moduleName = fileNames.model;\n this.mapping.genQObjects.moduleName = fileNames.qObject;\n }\n\n public addFromCore(...names: Array<string>) {\n names.forEach((n) => this.container.core.add(n));\n }\n\n public addFromQObject(...names: Array<string>) {\n names.forEach((n) => this.container.qobjects.add(n));\n }\n\n public addFromClientApi(...names: Array<string>) {\n names.forEach((n) => this.container.clientApi.add(n));\n }\n\n public addFromService(...names: Array<string>) {\n names.forEach((n) => this.container.service.add(n));\n }\n\n public addGeneratedModel(...names: Array<string>) {\n names.forEach((n) => this.container.genModel.add(n));\n }\n\n public addGeneratedQObject(...names: Array<string>) {\n names.forEach((n) => this.container.genQObjects.add(n));\n }\n\n public addCustomType(moduleName: string, typeName: string) {\n let importList = this.container.customTypes.get(moduleName);\n if (!importList) {\n importList = new Set();\n this.container.customTypes.set(moduleName, importList);\n }\n importList.add(typeName);\n }\n\n public addGeneratedService(key: string, ...names: Array<string>) {\n let serv = this.container.genServices[key];\n if (!serv) {\n serv = new Set();\n this.container.genServices[key] = serv;\n }\n names.forEach((n) => serv.add(n));\n }\n\n public getImportDeclarations(fromSubPath: boolean = false): Array<ImportDeclarationStructure> {\n const { genServices, customTypes, ...standardImports } = this.container;\n\n return [\n ...[...customTypes.keys()]\n .filter((key) => !!customTypes.get(key)?.size)\n .map((key) => {\n return {\n namedImports: [...customTypes.get(key)!],\n moduleSpecifier: key,\n } as ImportDeclarationStructure;\n }),\n ...Object.entries(standardImports)\n .filter(([key, values]) => !!values.size)\n .map(([key, values]) => {\n const mapping = this.mapping[key];\n return {\n namedImports: [...values],\n moduleSpecifier: `${mapping.isRelative ? `${fromSubPath ? \"..\" : \".\"}/` : \"\"}${mapping.moduleName}`,\n } as ImportDeclarationStructure;\n }),\n ...Object.entries(genServices).map(([key, values]) => {\n return {\n namedImports: [...values],\n moduleSpecifier: (fromSubPath ? \"./\" : \"./service/\") + key,\n } as ImportDeclarationStructure;\n }),\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ImportContainer.js","sourceRoot":"","sources":["../../src/generator/ImportContainer.ts"],"names":[],"mappings":";;;;AAeA,MAAa,eAAe;IAuB1B,YAAY,SAAuB;QAtB3B,YAAO,GAEX;YACF,IAAI,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,KAAK,EAAE;YAC/D,QAAQ,EAAE,EAAE,UAAU,EAAE,+BAA+B,EAAE,UAAU,EAAE,KAAK,EAAE;YAC5E,SAAS,EAAE,EAAE,UAAU,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GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;gBACnD,OAAO;oBACL,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC;oBACzB,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,GAAG;iBAC7B,CAAC;YAClC,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAnGD,0CAmGC","sourcesContent":["import { ImportDeclarationStructure } from \"ts-morph\";\r\n\r\nimport { ProjectFiles } from \"../data-model/DataModel\";\r\n\r\ntype ImportContainerType = {\r\n core: Set<string>;\r\n qobjects: Set<string>;\r\n clientApi: Set<string>;\r\n service: Set<string>;\r\n genModel: Set<string>;\r\n genQObjects: Set<string>;\r\n genServices: { [key: string]: Set<string> };\r\n customTypes: Map<string, Set<string>>;\r\n};\r\n\r\nexport class ImportContainer {\r\n private mapping: {\r\n [K in keyof ImportContainerType as string]: { moduleName: string; isRelative: boolean; addName?: boolean };\r\n } = {\r\n core: { moduleName: \"@odata2ts/odata-core\", isRelative: false },\r\n qobjects: { moduleName: \"@odata2ts/odata-query-objects\", isRelative: false },\r\n clientApi: { moduleName: \"@odata2ts/http-client-api\", isRelative: false },\r\n service: { moduleName: \"@odata2ts/odata-service\", isRelative: false },\r\n genModel: { moduleName: \"\", isRelative: true },\r\n genQObjects: { moduleName: \"\", isRelative: true },\r\n };\r\n\r\n private container: ImportContainerType = {\r\n core: new Set(),\r\n qobjects: new Set(),\r\n clientApi: new Set(),\r\n service: new Set(),\r\n genModel: new Set(),\r\n genQObjects: new Set(),\r\n genServices: {},\r\n customTypes: new Map(),\r\n };\r\n\r\n constructor(fileNames: ProjectFiles) {\r\n this.mapping.genModel.moduleName = fileNames.model;\r\n this.mapping.genQObjects.moduleName = fileNames.qObject;\r\n }\r\n\r\n public addFromCore(...names: Array<string>) {\r\n names.forEach((n) => this.container.core.add(n));\r\n }\r\n\r\n public addFromQObject(...names: Array<string>) {\r\n names.forEach((n) => this.container.qobjects.add(n));\r\n }\r\n\r\n public addFromClientApi(...names: Array<string>) {\r\n names.forEach((n) => this.container.clientApi.add(n));\r\n }\r\n\r\n public addFromService(...names: Array<string>) {\r\n names.forEach((n) => this.container.service.add(n));\r\n }\r\n\r\n public addGeneratedModel(...names: Array<string>) {\r\n names.forEach((n) => this.container.genModel.add(n));\r\n }\r\n\r\n public addGeneratedQObject(...names: Array<string>) {\r\n names.forEach((n) => this.container.genQObjects.add(n));\r\n }\r\n\r\n public addCustomType(moduleName: string, typeName: string) {\r\n let importList = this.container.customTypes.get(moduleName);\r\n if (!importList) {\r\n importList = new Set();\r\n this.container.customTypes.set(moduleName, importList);\r\n }\r\n importList.add(typeName);\r\n }\r\n\r\n public addGeneratedService(key: string, ...names: Array<string>) {\r\n let serv = this.container.genServices[key];\r\n if (!serv) {\r\n serv = new Set();\r\n this.container.genServices[key] = serv;\r\n }\r\n names.forEach((n) => serv.add(n));\r\n }\r\n\r\n public getImportDeclarations(fromSubPath: boolean = false): Array<ImportDeclarationStructure> {\r\n const { genServices, customTypes, ...standardImports } = this.container;\r\n\r\n return [\r\n ...[...customTypes.keys()]\r\n .filter((key) => !!customTypes.get(key)?.size)\r\n .map((key) => {\r\n return {\r\n namedImports: [...customTypes.get(key)!],\r\n moduleSpecifier: key,\r\n } as ImportDeclarationStructure;\r\n }),\r\n ...Object.entries(standardImports)\r\n .filter(([key, values]) => !!values.size)\r\n .map(([key, values]) => {\r\n const mapping = this.mapping[key];\r\n return {\r\n namedImports: [...values],\r\n moduleSpecifier: `${mapping.isRelative ? `${fromSubPath ? \"..\" : \".\"}/` : \"\"}${mapping.moduleName}`,\r\n } as ImportDeclarationStructure;\r\n }),\r\n ...Object.entries(genServices).map(([key, values]) => {\r\n return {\r\n namedImports: [...values],\r\n moduleSpecifier: (fromSubPath ? \"./\" : \"./service/\") + key,\r\n } as ImportDeclarationStructure;\r\n }),\r\n ];\r\n }\r\n}\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EntityBasedGeneratorFunction } from "../FactoryFunctionModel";
|
|
2
|
-
export declare const generateModels: EntityBasedGeneratorFunction;
|
|
1
|
+
import { EntityBasedGeneratorFunction } from "../FactoryFunctionModel";
|
|
2
|
+
export declare const generateModels: EntityBasedGeneratorFunction;
|