@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.
- package/CHANGELOG.md +10 -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/app.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runApp = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const odata_core_1 = require("@odata2ts/odata-core");
|
|
6
|
-
const DataModelDigestionV2_1 = require("./data-model/DataModelDigestionV2");
|
|
7
|
-
const DataModelDigestionV4_1 = require("./data-model/DataModelDigestionV4");
|
|
8
|
-
const NamingHelper_1 = require("./data-model/NamingHelper");
|
|
9
|
-
const generator_1 = require("./generator");
|
|
10
|
-
const OptionModel_1 = require("./OptionModel");
|
|
11
|
-
const ProjectManager_1 = require("./project/ProjectManager");
|
|
12
|
-
function isQObjectGen(mode) {
|
|
13
|
-
return [OptionModel_1.Modes.qobjects, OptionModel_1.Modes.service, OptionModel_1.Modes.all].includes(mode);
|
|
14
|
-
}
|
|
15
|
-
function isServiceGen(mode) {
|
|
16
|
-
return [OptionModel_1.Modes.service, OptionModel_1.Modes.all].includes(mode);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param metadataJson metadata of a given OData service already parsed as JSON
|
|
21
|
-
* @param options further options
|
|
22
|
-
*/
|
|
23
|
-
function runApp(metadataJson, options) {
|
|
24
|
-
var _a;
|
|
25
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
// determine edmx edmxVersion attribute
|
|
27
|
-
const edmxVersion = metadataJson["edmx:Edmx"].$.Version;
|
|
28
|
-
const version = edmxVersion === "1.0" ? odata_core_1.ODataVersions.V2 : odata_core_1.ODataVersions.V4;
|
|
29
|
-
const dataService = metadataJson["edmx:Edmx"]["edmx:DataServices"][0];
|
|
30
|
-
// handling multiple schemas => merge them
|
|
31
|
-
const schemaRaw = dataService.Schema.reduce((collector, schema) => (Object.assign(Object.assign({}, schema), collector)), {});
|
|
32
|
-
const detectedServiceName = dataService.Schema.length === 1
|
|
33
|
-
? dataService.Schema[0].$.Namespace
|
|
34
|
-
: (_a = dataService.Schema.find((schema) => !schema.EntityContainer)) === null || _a === void 0 ? void 0 : _a.$.Namespace;
|
|
35
|
-
// encapsulate the whole naming logic
|
|
36
|
-
const namingHelper = new NamingHelper_1.NamingHelper(options, detectedServiceName, options.serviceName);
|
|
37
|
-
// parse model information from edmx into something we can really work with
|
|
38
|
-
// => that stuff is called dataModel!
|
|
39
|
-
const dataModel = version === odata_core_1.ODataVersions.V2
|
|
40
|
-
? yield (0, DataModelDigestionV2_1.digest)(schemaRaw, options, namingHelper)
|
|
41
|
-
: yield (0, DataModelDigestionV4_1.digest)(schemaRaw, options, namingHelper);
|
|
42
|
-
// handling the overall generation project
|
|
43
|
-
const project = yield (0, ProjectManager_1.createProjectManager)(namingHelper.getFileNames(), options.output, options.emitMode, options.prettier, options.tsconfig);
|
|
44
|
-
// Generate Model Interfaces
|
|
45
|
-
// supported edmx types: EntityType, ComplexType, EnumType
|
|
46
|
-
const modelsFile = yield project.createModelFile();
|
|
47
|
-
(0, generator_1.generateModels)(dataModel, modelsFile, version, options, namingHelper);
|
|
48
|
-
// Generate Query Objects
|
|
49
|
-
// supported edmx types: EntityType, ComplexType
|
|
50
|
-
// supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object
|
|
51
|
-
if (isQObjectGen(options.mode)) {
|
|
52
|
-
const qFile = yield project.createQObjectFile();
|
|
53
|
-
(0, generator_1.generateQueryObjects)(dataModel, qFile, version, options, namingHelper);
|
|
54
|
-
}
|
|
55
|
-
// Generate Individual OData-Service
|
|
56
|
-
if (isServiceGen(options.mode)) {
|
|
57
|
-
yield project.cleanServiceDir();
|
|
58
|
-
yield (0, generator_1.generateServices)(dataModel, project, version, namingHelper);
|
|
59
|
-
}
|
|
60
|
-
yield project.writeFiles();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
exports.runApp = runApp;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const odata_core_1 = require("@odata2ts/odata-core");
|
|
6
|
+
const DataModelDigestionV2_1 = require("./data-model/DataModelDigestionV2");
|
|
7
|
+
const DataModelDigestionV4_1 = require("./data-model/DataModelDigestionV4");
|
|
8
|
+
const NamingHelper_1 = require("./data-model/NamingHelper");
|
|
9
|
+
const generator_1 = require("./generator");
|
|
10
|
+
const OptionModel_1 = require("./OptionModel");
|
|
11
|
+
const ProjectManager_1 = require("./project/ProjectManager");
|
|
12
|
+
function isQObjectGen(mode) {
|
|
13
|
+
return [OptionModel_1.Modes.qobjects, OptionModel_1.Modes.service, OptionModel_1.Modes.all].includes(mode);
|
|
14
|
+
}
|
|
15
|
+
function isServiceGen(mode) {
|
|
16
|
+
return [OptionModel_1.Modes.service, OptionModel_1.Modes.all].includes(mode);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param metadataJson metadata of a given OData service already parsed as JSON
|
|
21
|
+
* @param options further options
|
|
22
|
+
*/
|
|
23
|
+
function runApp(metadataJson, options) {
|
|
24
|
+
var _a;
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
// determine edmx edmxVersion attribute
|
|
27
|
+
const edmxVersion = metadataJson["edmx:Edmx"].$.Version;
|
|
28
|
+
const version = edmxVersion === "1.0" ? odata_core_1.ODataVersions.V2 : odata_core_1.ODataVersions.V4;
|
|
29
|
+
const dataService = metadataJson["edmx:Edmx"]["edmx:DataServices"][0];
|
|
30
|
+
// handling multiple schemas => merge them
|
|
31
|
+
const schemaRaw = dataService.Schema.reduce((collector, schema) => (Object.assign(Object.assign({}, schema), collector)), {});
|
|
32
|
+
const detectedServiceName = dataService.Schema.length === 1
|
|
33
|
+
? dataService.Schema[0].$.Namespace
|
|
34
|
+
: (_a = dataService.Schema.find((schema) => !schema.EntityContainer)) === null || _a === void 0 ? void 0 : _a.$.Namespace;
|
|
35
|
+
// encapsulate the whole naming logic
|
|
36
|
+
const namingHelper = new NamingHelper_1.NamingHelper(options, detectedServiceName, options.serviceName);
|
|
37
|
+
// parse model information from edmx into something we can really work with
|
|
38
|
+
// => that stuff is called dataModel!
|
|
39
|
+
const dataModel = version === odata_core_1.ODataVersions.V2
|
|
40
|
+
? yield (0, DataModelDigestionV2_1.digest)(schemaRaw, options, namingHelper)
|
|
41
|
+
: yield (0, DataModelDigestionV4_1.digest)(schemaRaw, options, namingHelper);
|
|
42
|
+
// handling the overall generation project
|
|
43
|
+
const project = yield (0, ProjectManager_1.createProjectManager)(namingHelper.getFileNames(), options.output, options.emitMode, options.prettier, options.tsconfig);
|
|
44
|
+
// Generate Model Interfaces
|
|
45
|
+
// supported edmx types: EntityType, ComplexType, EnumType
|
|
46
|
+
const modelsFile = yield project.createModelFile();
|
|
47
|
+
(0, generator_1.generateModels)(dataModel, modelsFile, version, options, namingHelper);
|
|
48
|
+
// Generate Query Objects
|
|
49
|
+
// supported edmx types: EntityType, ComplexType
|
|
50
|
+
// supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object
|
|
51
|
+
if (isQObjectGen(options.mode)) {
|
|
52
|
+
const qFile = yield project.createQObjectFile();
|
|
53
|
+
(0, generator_1.generateQueryObjects)(dataModel, qFile, version, options, namingHelper);
|
|
54
|
+
}
|
|
55
|
+
// Generate Individual OData-Service
|
|
56
|
+
if (isServiceGen(options.mode)) {
|
|
57
|
+
yield project.cleanServiceDir();
|
|
58
|
+
yield (0, generator_1.generateServices)(dataModel, project, version, namingHelper);
|
|
59
|
+
}
|
|
60
|
+
yield project.writeFiles();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.runApp = runApp;
|
|
64
64
|
//# sourceMappingURL=app.js.map
|
package/lib/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,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C;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\n\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\nimport { Modes, RunOptions } from \"./OptionModel\";\nimport { createProjectManager } from \"./project/ProjectManager\";\n\nfunction isQObjectGen(mode: Modes) {\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\n}\n\nfunction isServiceGen(mode: Modes) {\n return [Modes.service, Modes.all].includes(mode);\n}\n\n/**\n *\n * @param metadataJson metadata of a given OData service already parsed as JSON\n * @param options further options\n */\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\n // determine edmx edmxVersion attribute\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\n\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\n\n // handling multiple schemas => merge them\n const schemaRaw = dataService.Schema.reduce(\n (collector, schema) => ({\n ...schema,\n ...collector,\n }),\n {} as Schema<any, any>\n );\n const detectedServiceName =\n dataService.Schema.length === 1\n ? dataService.Schema[0].$.Namespace\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\n\n // encapsulate the whole naming logic\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\n // parse model information from edmx into something we can really work with\n // => that stuff is called dataModel!\n const dataModel =\n version === ODataVersions.V2\n ? await digestV2(schemaRaw as SchemaV3, options, namingHelper)\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\n // handling the overall generation project\n const project = await createProjectManager(\n namingHelper.getFileNames(),\n options.output,\n options.emitMode,\n options.prettier,\n options.tsconfig\n );\n\n // Generate Model Interfaces\n // supported edmx types: EntityType, ComplexType, EnumType\n const modelsFile = await project.createModelFile();\n generateModels(dataModel, modelsFile, version, options, namingHelper);\n\n // Generate Query Objects\n // supported edmx types: EntityType, ComplexType\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\n if (isQObjectGen(options.mode)) {\n const qFile = await project.createQObjectFile();\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\n }\n\n // Generate Individual OData-Service\n if (isServiceGen(options.mode)) {\n await project.cleanServiceDir();\n await generateServices(dataModel, project, version, namingHelper);\n }\n\n await project.writeFiles();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAsB,MAAM,CAAC,YAAqC,EAAE,OAAmB;;;QACrF,uCAAuC;QACvC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACxD,MAAM,OAAO,GAAG,WAAW,KAAK,KAAK,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B;QAC5B,0DAA0D;QAC1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QACnD,IAAA,0BAAc,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAEtE,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\r\nimport { Modes, RunOptions } from \"./OptionModel\";\r\nimport { createProjectManager } from \"./project/ProjectManager\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n\r\n // handling multiple schemas => merge them\r\n const schemaRaw = dataService.Schema.reduce(\r\n (collector, schema) => ({\r\n ...schema,\r\n ...collector,\r\n }),\r\n {} as Schema<any, any>\r\n );\r\n const detectedServiceName =\r\n dataService.Schema.length === 1\r\n ? dataService.Schema[0].$.Namespace\r\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\r\n\r\n // encapsulate the whole naming logic\r\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\r\n // parse model information from edmx into something we can really work with\r\n // => that stuff is called dataModel!\r\n const dataModel =\r\n version === ODataVersions.V2\r\n ? await digestV2(schemaRaw as SchemaV3, options, namingHelper)\r\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\r\n // handling the overall generation project\r\n const project = await createProjectManager(\r\n namingHelper.getFileNames(),\r\n options.output,\r\n options.emitMode,\r\n options.prettier,\r\n options.tsconfig\r\n );\r\n\r\n // Generate Model Interfaces\r\n // supported edmx types: EntityType, ComplexType, EnumType\r\n const modelsFile = await project.createModelFile();\r\n generateModels(dataModel, modelsFile, version, options, namingHelper);\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n const qFile = await project.createQObjectFile();\r\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n await project.cleanServiceDir();\r\n await generateServices(dataModel, project, version, namingHelper);\r\n }\r\n\r\n await project.writeFiles();\r\n}\r\n"]}
|
package/lib/cli.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare class Cli {
|
|
2
|
-
run(): Promise<void>;
|
|
3
|
-
}
|
|
1
|
+
export declare class Cli {
|
|
2
|
+
run(): Promise<void>;
|
|
3
|
+
}
|
package/lib/cli.js
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Cli = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const commander_1 = tslib_1.__importStar(require("commander"));
|
|
6
|
-
const cosmiconfig_1 = require("cosmiconfig");
|
|
7
|
-
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
8
|
-
const fs_extra_1 = require("fs-extra");
|
|
9
|
-
const xml2js_1 = require("xml2js");
|
|
10
|
-
const app_1 = require("./app");
|
|
11
|
-
const evaluateConfig_1 = require("./evaluateConfig");
|
|
12
|
-
const OptionModel_1 = require("./OptionModel");
|
|
13
|
-
const logFilePath_1 = require("./project/logger/logFilePath");
|
|
14
|
-
function parseMode(value, dummyPrevious) {
|
|
15
|
-
switch (value) {
|
|
16
|
-
case "models":
|
|
17
|
-
return OptionModel_1.Modes.models;
|
|
18
|
-
case "qobjects":
|
|
19
|
-
return OptionModel_1.Modes.qobjects;
|
|
20
|
-
case "service":
|
|
21
|
-
return OptionModel_1.Modes.service;
|
|
22
|
-
case "all":
|
|
23
|
-
return OptionModel_1.Modes.all;
|
|
24
|
-
default:
|
|
25
|
-
throw new Error(`Not a valid Mode: ${value}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function parseEmitMode(value, dummyPrevious) {
|
|
29
|
-
switch (value) {
|
|
30
|
-
case "dts":
|
|
31
|
-
return OptionModel_1.EmitModes.dts;
|
|
32
|
-
case "js":
|
|
33
|
-
return OptionModel_1.EmitModes.js;
|
|
34
|
-
case "ts":
|
|
35
|
-
return OptionModel_1.EmitModes.ts;
|
|
36
|
-
case "js_dts":
|
|
37
|
-
return OptionModel_1.EmitModes.js_dts;
|
|
38
|
-
default:
|
|
39
|
-
throw new Error(`Not a valid EmitMode: ${value}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function processCliArgs() {
|
|
43
|
-
var _a;
|
|
44
|
-
const cli = new commander_1.default.Command()
|
|
45
|
-
.version("0.3.0")
|
|
46
|
-
.description("CLI to generate Typescript Interfaces for models of a given OData service.")
|
|
47
|
-
.argument("[services...]", "Run the generation process only for certain services specified in config file", [])
|
|
48
|
-
.option("-s, --source <metadata.xml>", "Metadata file describing the OData service")
|
|
49
|
-
.option("-o, --output <path>", "Output location for generated files")
|
|
50
|
-
.addOption(new commander_1.Option("-m, --mode <mode>", "What kind of stuff gets generated")
|
|
51
|
-
.choices(Object.values(OptionModel_1.Modes).filter((t) => isNaN(Number(t))))
|
|
52
|
-
.argParser(parseMode))
|
|
53
|
-
.addOption(new commander_1.Option("-e, --emit-mode <mode>", "Output TS source files, compiled JS files with/wihthout generated d.ts files")
|
|
54
|
-
.choices(Object.values(OptionModel_1.EmitModes))
|
|
55
|
-
.argParser(parseEmitMode))
|
|
56
|
-
.option("-p, --prettier", "Format result with prettier (only applies if emitMode=ts)")
|
|
57
|
-
.option("-t, --tsconfig <path>", "Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)")
|
|
58
|
-
.option("-d, --debug", "Verbose debug infos")
|
|
59
|
-
.option("-name, --service-name <serviceName>", "Give the service your own name")
|
|
60
|
-
.option("-n, --disable-auto-managed-key", "Give the service your own name")
|
|
61
|
-
.option("-r, --allow-renaming ", "Give the service your own name")
|
|
62
|
-
.parse(process.argv);
|
|
63
|
-
const args = ((_a = cli.args) === null || _a === void 0 ? void 0 : _a.length) ? { services: cli.args } : {};
|
|
64
|
-
return Object.assign(Object.assign({}, cli.opts()), args);
|
|
65
|
-
}
|
|
66
|
-
function processConfigFile() {
|
|
67
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const moduleName = "odata2ts";
|
|
69
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
70
|
-
searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],
|
|
71
|
-
loaders: {
|
|
72
|
-
".ts": (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)(),
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
const discoveredConfig = yield explorer.search();
|
|
76
|
-
if (discoveredConfig === null || discoveredConfig === void 0 ? void 0 : discoveredConfig.config) {
|
|
77
|
-
console.log("Loaded config file: ", (0, logFilePath_1.logFilePath)(discoveredConfig.filepath));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
console.log("No config file found.");
|
|
81
|
-
}
|
|
82
|
-
return discoveredConfig === null || discoveredConfig === void 0 ? void 0 : discoveredConfig.config;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
class Cli {
|
|
86
|
-
run() {
|
|
87
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
let runs;
|
|
89
|
-
try {
|
|
90
|
-
const cliOpts = processCliArgs();
|
|
91
|
-
if (cliOpts.debug) {
|
|
92
|
-
console.log("CLI opts:", cliOpts);
|
|
93
|
-
}
|
|
94
|
-
const fileOpts = yield processConfigFile();
|
|
95
|
-
runs = (0, evaluateConfig_1.evaluateConfigOptions)(cliOpts, fileOpts);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
console.error("Bad arguments!", error === null || error === void 0 ? void 0 : error.message);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
for (let run of runs) {
|
|
102
|
-
yield startServiceGenerationRun(run);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.Cli = Cli;
|
|
108
|
-
function startServiceGenerationRun(options) {
|
|
109
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
const { source, output, debug, mode, emitMode, prettier, serviceName } = options;
|
|
111
|
-
console.log("---------------------------");
|
|
112
|
-
console.log("Starting generation process");
|
|
113
|
-
if (debug) {
|
|
114
|
-
console.log("Resolved config:", {
|
|
115
|
-
source,
|
|
116
|
-
output,
|
|
117
|
-
debug,
|
|
118
|
-
mode: OptionModel_1.Modes[mode],
|
|
119
|
-
emitMode,
|
|
120
|
-
prettier,
|
|
121
|
-
serviceName,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
console.log("Reading file:", source);
|
|
125
|
-
const exists = yield (0, fs_extra_1.pathExists)(source);
|
|
126
|
-
if (!exists) {
|
|
127
|
-
console.error(`Input source [${source}] doesn't exist!`);
|
|
128
|
-
process.exit(2);
|
|
129
|
-
}
|
|
130
|
-
// read metadata file and convert to JSON
|
|
131
|
-
const metadataXml = yield (0, fs_extra_1.readFile)(source);
|
|
132
|
-
const metadataJson = (yield (0, xml2js_1.parseStringPromise)(metadataXml));
|
|
133
|
-
// TODO find out if "1.0" and "4.0" are really correct
|
|
134
|
-
// TODO exit here if no version not suitable version was detected
|
|
135
|
-
// console.log(`OData version detected: ${metadataJson["edmx:Edmx"].$.Version}`);
|
|
136
|
-
// ensure that output directory exists
|
|
137
|
-
try {
|
|
138
|
-
yield (0, fs_extra_1.emptyDir)(output);
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
console.error(`Output path [${output}] couldn't be created!`, error);
|
|
142
|
-
process.exit(3);
|
|
143
|
-
}
|
|
144
|
-
// run the app
|
|
145
|
-
try {
|
|
146
|
-
yield (0, app_1.runApp)(metadataJson, options);
|
|
147
|
-
}
|
|
148
|
-
catch (err) {
|
|
149
|
-
console.error("Error while running the program", err);
|
|
150
|
-
process.exit(99);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cli = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const commander_1 = tslib_1.__importStar(require("commander"));
|
|
6
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
7
|
+
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const xml2js_1 = require("xml2js");
|
|
10
|
+
const app_1 = require("./app");
|
|
11
|
+
const evaluateConfig_1 = require("./evaluateConfig");
|
|
12
|
+
const OptionModel_1 = require("./OptionModel");
|
|
13
|
+
const logFilePath_1 = require("./project/logger/logFilePath");
|
|
14
|
+
function parseMode(value, dummyPrevious) {
|
|
15
|
+
switch (value) {
|
|
16
|
+
case "models":
|
|
17
|
+
return OptionModel_1.Modes.models;
|
|
18
|
+
case "qobjects":
|
|
19
|
+
return OptionModel_1.Modes.qobjects;
|
|
20
|
+
case "service":
|
|
21
|
+
return OptionModel_1.Modes.service;
|
|
22
|
+
case "all":
|
|
23
|
+
return OptionModel_1.Modes.all;
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Not a valid Mode: ${value}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function parseEmitMode(value, dummyPrevious) {
|
|
29
|
+
switch (value) {
|
|
30
|
+
case "dts":
|
|
31
|
+
return OptionModel_1.EmitModes.dts;
|
|
32
|
+
case "js":
|
|
33
|
+
return OptionModel_1.EmitModes.js;
|
|
34
|
+
case "ts":
|
|
35
|
+
return OptionModel_1.EmitModes.ts;
|
|
36
|
+
case "js_dts":
|
|
37
|
+
return OptionModel_1.EmitModes.js_dts;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`Not a valid EmitMode: ${value}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function processCliArgs() {
|
|
43
|
+
var _a;
|
|
44
|
+
const cli = new commander_1.default.Command()
|
|
45
|
+
.version("0.3.0")
|
|
46
|
+
.description("CLI to generate Typescript Interfaces for models of a given OData service.")
|
|
47
|
+
.argument("[services...]", "Run the generation process only for certain services specified in config file", [])
|
|
48
|
+
.option("-s, --source <metadata.xml>", "Metadata file describing the OData service")
|
|
49
|
+
.option("-o, --output <path>", "Output location for generated files")
|
|
50
|
+
.addOption(new commander_1.Option("-m, --mode <mode>", "What kind of stuff gets generated")
|
|
51
|
+
.choices(Object.values(OptionModel_1.Modes).filter((t) => isNaN(Number(t))))
|
|
52
|
+
.argParser(parseMode))
|
|
53
|
+
.addOption(new commander_1.Option("-e, --emit-mode <mode>", "Output TS source files, compiled JS files with/wihthout generated d.ts files")
|
|
54
|
+
.choices(Object.values(OptionModel_1.EmitModes))
|
|
55
|
+
.argParser(parseEmitMode))
|
|
56
|
+
.option("-p, --prettier", "Format result with prettier (only applies if emitMode=ts)")
|
|
57
|
+
.option("-t, --tsconfig <path>", "Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)")
|
|
58
|
+
.option("-d, --debug", "Verbose debug infos")
|
|
59
|
+
.option("-name, --service-name <serviceName>", "Give the service your own name")
|
|
60
|
+
.option("-n, --disable-auto-managed-key", "Give the service your own name")
|
|
61
|
+
.option("-r, --allow-renaming ", "Give the service your own name")
|
|
62
|
+
.parse(process.argv);
|
|
63
|
+
const args = ((_a = cli.args) === null || _a === void 0 ? void 0 : _a.length) ? { services: cli.args } : {};
|
|
64
|
+
return Object.assign(Object.assign({}, cli.opts()), args);
|
|
65
|
+
}
|
|
66
|
+
function processConfigFile() {
|
|
67
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const moduleName = "odata2ts";
|
|
69
|
+
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
70
|
+
searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],
|
|
71
|
+
loaders: {
|
|
72
|
+
".ts": (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)(),
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const discoveredConfig = yield explorer.search();
|
|
76
|
+
if (discoveredConfig === null || discoveredConfig === void 0 ? void 0 : discoveredConfig.config) {
|
|
77
|
+
console.log("Loaded config file: ", (0, logFilePath_1.logFilePath)(discoveredConfig.filepath));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.log("No config file found.");
|
|
81
|
+
}
|
|
82
|
+
return discoveredConfig === null || discoveredConfig === void 0 ? void 0 : discoveredConfig.config;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
class Cli {
|
|
86
|
+
run() {
|
|
87
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
let runs;
|
|
89
|
+
try {
|
|
90
|
+
const cliOpts = processCliArgs();
|
|
91
|
+
if (cliOpts.debug) {
|
|
92
|
+
console.log("CLI opts:", cliOpts);
|
|
93
|
+
}
|
|
94
|
+
const fileOpts = yield processConfigFile();
|
|
95
|
+
runs = (0, evaluateConfig_1.evaluateConfigOptions)(cliOpts, fileOpts);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error("Bad arguments!", error === null || error === void 0 ? void 0 : error.message);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
for (let run of runs) {
|
|
102
|
+
yield startServiceGenerationRun(run);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.Cli = Cli;
|
|
108
|
+
function startServiceGenerationRun(options) {
|
|
109
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const { source, output, debug, mode, emitMode, prettier, serviceName } = options;
|
|
111
|
+
console.log("---------------------------");
|
|
112
|
+
console.log("Starting generation process");
|
|
113
|
+
if (debug) {
|
|
114
|
+
console.log("Resolved config:", {
|
|
115
|
+
source,
|
|
116
|
+
output,
|
|
117
|
+
debug,
|
|
118
|
+
mode: OptionModel_1.Modes[mode],
|
|
119
|
+
emitMode,
|
|
120
|
+
prettier,
|
|
121
|
+
serviceName,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
console.log("Reading file:", source);
|
|
125
|
+
const exists = yield (0, fs_extra_1.pathExists)(source);
|
|
126
|
+
if (!exists) {
|
|
127
|
+
console.error(`Input source [${source}] doesn't exist!`);
|
|
128
|
+
process.exit(2);
|
|
129
|
+
}
|
|
130
|
+
// read metadata file and convert to JSON
|
|
131
|
+
const metadataXml = yield (0, fs_extra_1.readFile)(source);
|
|
132
|
+
const metadataJson = (yield (0, xml2js_1.parseStringPromise)(metadataXml));
|
|
133
|
+
// TODO find out if "1.0" and "4.0" are really correct
|
|
134
|
+
// TODO exit here if no version not suitable version was detected
|
|
135
|
+
// console.log(`OData version detected: ${metadataJson["edmx:Edmx"].$.Version}`);
|
|
136
|
+
// ensure that output directory exists
|
|
137
|
+
try {
|
|
138
|
+
yield (0, fs_extra_1.emptyDir)(output);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error(`Output path [${output}] couldn't be created!`, error);
|
|
142
|
+
process.exit(3);
|
|
143
|
+
}
|
|
144
|
+
// run the app
|
|
145
|
+
try {
|
|
146
|
+
yield (0, app_1.runApp)(metadataJson, options);
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.error("Error while running the program", err);
|
|
150
|
+
process.exit(99);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
154
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { MappedConverterChains } from "@odata2ts/converter-runtime";
|
|
2
|
-
import { ODataTypesV2, ODataTypesV4 } from "@odata2ts/odata-core";
|
|
3
|
-
import { ActionImportType, ComplexType, EntityContainerModel, EntitySetType, EnumType, FunctionImportType, ModelType, ODataVersion, OperationType, SingletonType } from "./DataTypeModel";
|
|
4
|
-
export interface ProjectFiles {
|
|
5
|
-
model: string;
|
|
6
|
-
qObject: string;
|
|
7
|
-
service: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class DataModel {
|
|
10
|
-
private version;
|
|
11
|
-
private readonly converters;
|
|
12
|
-
private modelTypes;
|
|
13
|
-
private complexTypes;
|
|
14
|
-
private enumTypes;
|
|
15
|
-
private operationTypes;
|
|
16
|
-
private container;
|
|
17
|
-
constructor(version: ODataVersion, converters?: MappedConverterChains);
|
|
18
|
-
/**
|
|
19
|
-
* OData version: 2.0 or 4.0.
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
getODataVersion(): ODataVersion;
|
|
23
|
-
isV2(): boolean;
|
|
24
|
-
isV4(): boolean;
|
|
25
|
-
addModel(name: string, model: ModelType): void;
|
|
26
|
-
/**
|
|
27
|
-
* Get a specific model by its name.
|
|
28
|
-
*
|
|
29
|
-
* @param modelName the final model name that is generated
|
|
30
|
-
* @returns the model type
|
|
31
|
-
*/
|
|
32
|
-
getModel(modelName: string): ModelType;
|
|
33
|
-
/**
|
|
34
|
-
* Retrieve all known EntityType models from the EDMX model.
|
|
35
|
-
*
|
|
36
|
-
* @returns list of model types
|
|
37
|
-
*/
|
|
38
|
-
getModels(): ModelType[];
|
|
39
|
-
/**
|
|
40
|
-
* Set all model entity types
|
|
41
|
-
*
|
|
42
|
-
* @param models new model types
|
|
43
|
-
*/
|
|
44
|
-
setModels(models: {
|
|
45
|
-
[name: string]: ModelType;
|
|
46
|
-
}): void;
|
|
47
|
-
addComplexType(name: string, model: ComplexType): void;
|
|
48
|
-
/**
|
|
49
|
-
* Get a specific model by its name.
|
|
50
|
-
*
|
|
51
|
-
* @param name the final model name that is generated
|
|
52
|
-
* @returns the model type
|
|
53
|
-
*/
|
|
54
|
-
getComplexType(name: string): ComplexType;
|
|
55
|
-
/**
|
|
56
|
-
* Retrieve all known ComplexType models from the EDMX model.
|
|
57
|
-
*
|
|
58
|
-
* @returns list of model types
|
|
59
|
-
*/
|
|
60
|
-
getComplexTypes(): ComplexType[];
|
|
61
|
-
/**
|
|
62
|
-
* Set all complex types
|
|
63
|
-
*
|
|
64
|
-
* @param models new complex types
|
|
65
|
-
*/
|
|
66
|
-
setComplexTypes(complexTypes: {
|
|
67
|
-
[name: string]: ComplexType;
|
|
68
|
-
}): void;
|
|
69
|
-
addEnum(name: string, type: EnumType): void;
|
|
70
|
-
/**
|
|
71
|
-
* Get list of all known enums, i.e. EnumType nodes from the EDMX model.
|
|
72
|
-
* @returns list of enum types
|
|
73
|
-
*/
|
|
74
|
-
getEnums(): EnumType[];
|
|
75
|
-
addOperationType(binding: string, operationType: OperationType): void;
|
|
76
|
-
getUnboundOperationTypes(): Array<OperationType>;
|
|
77
|
-
getOperationTypeByBinding(binding: string): Array<OperationType>;
|
|
78
|
-
getOperationTypeByEntityOrCollectionBinding(binding: string): Array<OperationType>;
|
|
79
|
-
addAction(name: string, action: ActionImportType): void;
|
|
80
|
-
addFunction(name: string, func: FunctionImportType): void;
|
|
81
|
-
addSingleton(name: string, singleton: SingletonType): void;
|
|
82
|
-
addEntitySet(name: string, entitySet: EntitySetType): void;
|
|
83
|
-
getEntityContainer(): EntityContainerModel;
|
|
84
|
-
getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string): import("@odata2ts/converter-runtime").ValueConverterChain | undefined;
|
|
85
|
-
}
|
|
1
|
+
import { MappedConverterChains } from "@odata2ts/converter-runtime";
|
|
2
|
+
import { ODataTypesV2, ODataTypesV4 } from "@odata2ts/odata-core";
|
|
3
|
+
import { ActionImportType, ComplexType, EntityContainerModel, EntitySetType, EnumType, FunctionImportType, ModelType, ODataVersion, OperationType, SingletonType } from "./DataTypeModel";
|
|
4
|
+
export interface ProjectFiles {
|
|
5
|
+
model: string;
|
|
6
|
+
qObject: string;
|
|
7
|
+
service: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class DataModel {
|
|
10
|
+
private version;
|
|
11
|
+
private readonly converters;
|
|
12
|
+
private modelTypes;
|
|
13
|
+
private complexTypes;
|
|
14
|
+
private enumTypes;
|
|
15
|
+
private operationTypes;
|
|
16
|
+
private container;
|
|
17
|
+
constructor(version: ODataVersion, converters?: MappedConverterChains);
|
|
18
|
+
/**
|
|
19
|
+
* OData version: 2.0 or 4.0.
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
getODataVersion(): ODataVersion;
|
|
23
|
+
isV2(): boolean;
|
|
24
|
+
isV4(): boolean;
|
|
25
|
+
addModel(name: string, model: ModelType): void;
|
|
26
|
+
/**
|
|
27
|
+
* Get a specific model by its name.
|
|
28
|
+
*
|
|
29
|
+
* @param modelName the final model name that is generated
|
|
30
|
+
* @returns the model type
|
|
31
|
+
*/
|
|
32
|
+
getModel(modelName: string): ModelType;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve all known EntityType models from the EDMX model.
|
|
35
|
+
*
|
|
36
|
+
* @returns list of model types
|
|
37
|
+
*/
|
|
38
|
+
getModels(): ModelType[];
|
|
39
|
+
/**
|
|
40
|
+
* Set all model entity types
|
|
41
|
+
*
|
|
42
|
+
* @param models new model types
|
|
43
|
+
*/
|
|
44
|
+
setModels(models: {
|
|
45
|
+
[name: string]: ModelType;
|
|
46
|
+
}): void;
|
|
47
|
+
addComplexType(name: string, model: ComplexType): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get a specific model by its name.
|
|
50
|
+
*
|
|
51
|
+
* @param name the final model name that is generated
|
|
52
|
+
* @returns the model type
|
|
53
|
+
*/
|
|
54
|
+
getComplexType(name: string): ComplexType;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieve all known ComplexType models from the EDMX model.
|
|
57
|
+
*
|
|
58
|
+
* @returns list of model types
|
|
59
|
+
*/
|
|
60
|
+
getComplexTypes(): ComplexType[];
|
|
61
|
+
/**
|
|
62
|
+
* Set all complex types
|
|
63
|
+
*
|
|
64
|
+
* @param models new complex types
|
|
65
|
+
*/
|
|
66
|
+
setComplexTypes(complexTypes: {
|
|
67
|
+
[name: string]: ComplexType;
|
|
68
|
+
}): void;
|
|
69
|
+
addEnum(name: string, type: EnumType): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get list of all known enums, i.e. EnumType nodes from the EDMX model.
|
|
72
|
+
* @returns list of enum types
|
|
73
|
+
*/
|
|
74
|
+
getEnums(): EnumType[];
|
|
75
|
+
addOperationType(binding: string, operationType: OperationType): void;
|
|
76
|
+
getUnboundOperationTypes(): Array<OperationType>;
|
|
77
|
+
getOperationTypeByBinding(binding: string): Array<OperationType>;
|
|
78
|
+
getOperationTypeByEntityOrCollectionBinding(binding: string): Array<OperationType>;
|
|
79
|
+
addAction(name: string, action: ActionImportType): void;
|
|
80
|
+
addFunction(name: string, func: FunctionImportType): void;
|
|
81
|
+
addSingleton(name: string, singleton: SingletonType): void;
|
|
82
|
+
addEntitySet(name: string, entitySet: EntitySetType): void;
|
|
83
|
+
getEntityContainer(): EntityContainerModel;
|
|
84
|
+
getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string): import("@odata2ts/converter-runtime").ValueConverterChain | undefined;
|
|
85
|
+
}
|