@odata2ts/odata2ts 0.18.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 (97) hide show
  1. package/CHANGELOG.md +601 -0
  2. package/LICENSE +21 -0
  3. package/README.md +129 -0
  4. package/lib/FactoryFunctionModel.d.ts +13 -0
  5. package/lib/FactoryFunctionModel.js +3 -0
  6. package/lib/FactoryFunctionModel.js.map +1 -0
  7. package/lib/NamingModel.d.ts +191 -0
  8. package/lib/NamingModel.js +12 -0
  9. package/lib/NamingModel.js.map +1 -0
  10. package/lib/OptionModel.d.ts +208 -0
  11. package/lib/OptionModel.js +24 -0
  12. package/lib/OptionModel.js.map +1 -0
  13. package/lib/app.d.ts +8 -0
  14. package/lib/app.js +61 -0
  15. package/lib/app.js.map +1 -0
  16. package/lib/cli.d.ts +3 -0
  17. package/lib/cli.js +154 -0
  18. package/lib/cli.js.map +1 -0
  19. package/lib/data-model/DataModel.d.ts +68 -0
  20. package/lib/data-model/DataModel.js +114 -0
  21. package/lib/data-model/DataModel.js.map +1 -0
  22. package/lib/data-model/DataModelDigestion.d.ts +43 -0
  23. package/lib/data-model/DataModelDigestion.js +224 -0
  24. package/lib/data-model/DataModelDigestion.js.map +1 -0
  25. package/lib/data-model/DataModelDigestionV2.d.ts +10 -0
  26. package/lib/data-model/DataModelDigestionV2.js +201 -0
  27. package/lib/data-model/DataModelDigestionV2.js.map +1 -0
  28. package/lib/data-model/DataModelDigestionV4.d.ts +3 -0
  29. package/lib/data-model/DataModelDigestionV4.js +196 -0
  30. package/lib/data-model/DataModelDigestionV4.js.map +1 -0
  31. package/lib/data-model/DataTypeModel.d.ts +102 -0
  32. package/lib/data-model/DataTypeModel.js +9 -0
  33. package/lib/data-model/DataTypeModel.js.map +1 -0
  34. package/lib/data-model/NamingHelper.d.ts +57 -0
  35. package/lib/data-model/NamingHelper.js +225 -0
  36. package/lib/data-model/NamingHelper.js.map +1 -0
  37. package/lib/data-model/ServiceConfigHelper.d.ts +13 -0
  38. package/lib/data-model/ServiceConfigHelper.js +63 -0
  39. package/lib/data-model/ServiceConfigHelper.js.map +1 -0
  40. package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +79 -0
  41. package/lib/data-model/edmx/ODataEdmxModelBase.js +3 -0
  42. package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -0
  43. package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +63 -0
  44. package/lib/data-model/edmx/ODataEdmxModelV3.js +3 -0
  45. package/lib/data-model/edmx/ODataEdmxModelV3.js.map +1 -0
  46. package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +67 -0
  47. package/lib/data-model/edmx/ODataEdmxModelV4.js +3 -0
  48. package/lib/data-model/edmx/ODataEdmxModelV4.js.map +1 -0
  49. package/lib/defaultConfig.d.ts +9 -0
  50. package/lib/defaultConfig.js +176 -0
  51. package/lib/defaultConfig.js.map +1 -0
  52. package/lib/evaluateConfig.d.ts +25 -0
  53. package/lib/evaluateConfig.js +78 -0
  54. package/lib/evaluateConfig.js.map +1 -0
  55. package/lib/generator/ImportContainer.d.ts +16 -0
  56. package/lib/generator/ImportContainer.js +92 -0
  57. package/lib/generator/ImportContainer.js.map +1 -0
  58. package/lib/generator/ModelGenerator.d.ts +2 -0
  59. package/lib/generator/ModelGenerator.js +178 -0
  60. package/lib/generator/ModelGenerator.js.map +1 -0
  61. package/lib/generator/QueryObjectGenerator.d.ts +2 -0
  62. package/lib/generator/QueryObjectGenerator.js +234 -0
  63. package/lib/generator/QueryObjectGenerator.js.map +1 -0
  64. package/lib/generator/ServiceGenerator.d.ts +5 -0
  65. package/lib/generator/ServiceGenerator.js +412 -0
  66. package/lib/generator/ServiceGenerator.js.map +1 -0
  67. package/lib/generator/index.d.ts +3 -0
  68. package/lib/generator/index.js +10 -0
  69. package/lib/generator/index.js.map +1 -0
  70. package/lib/index.d.ts +3 -0
  71. package/lib/index.js +7 -0
  72. package/lib/index.js.map +1 -0
  73. package/lib/project/ProjectManager.d.ts +30 -0
  74. package/lib/project/ProjectManager.js +177 -0
  75. package/lib/project/ProjectManager.js.map +1 -0
  76. package/lib/project/formatter/BaseFormatter.d.ts +49 -0
  77. package/lib/project/formatter/BaseFormatter.js +31 -0
  78. package/lib/project/formatter/BaseFormatter.js.map +1 -0
  79. package/lib/project/formatter/FileFormatter.d.ts +16 -0
  80. package/lib/project/formatter/FileFormatter.js +3 -0
  81. package/lib/project/formatter/FileFormatter.js.map +1 -0
  82. package/lib/project/formatter/NoopFormatter.d.ts +29 -0
  83. package/lib/project/formatter/NoopFormatter.js +43 -0
  84. package/lib/project/formatter/NoopFormatter.js.map +1 -0
  85. package/lib/project/formatter/PrettierFormatter.d.ts +46 -0
  86. package/lib/project/formatter/PrettierFormatter.js +93 -0
  87. package/lib/project/formatter/PrettierFormatter.js.map +1 -0
  88. package/lib/project/formatter/index.d.ts +2 -0
  89. package/lib/project/formatter/index.js +15 -0
  90. package/lib/project/formatter/index.js.map +1 -0
  91. package/lib/project/logger/logFilePath.d.ts +1 -0
  92. package/lib/project/logger/logFilePath.js +13 -0
  93. package/lib/project/logger/logFilePath.js.map +1 -0
  94. package/lib/run-cli.d.ts +2 -0
  95. package/lib/run-cli.js +7 -0
  96. package/lib/run-cli.js.map +1 -0
  97. package/package.json +91 -0
package/lib/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare class Cli {
2
+ run(): Promise<void>;
3
+ }
package/lib/cli.js ADDED
@@ -0,0 +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
+ }
154
+ //# sourceMappingURL=cli.js.map
package/lib/cli.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAAA,+DAA8C;AAC9C,6CAA0C;AAC1C,iFAAiE;AACjE,uCAA0D;AAC1D,mCAA4C;AAE5C,+BAA+B;AAE/B,qDAAyD;AACzD,+CAA4F;AAC5F,8DAA2D;AAE3D,SAAS,SAAS,CAAC,KAAa,EAAE,aAAgC;IAChE,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,mBAAK,CAAC,MAAM,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,mBAAK,CAAC,QAAQ,CAAC;QAC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,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,iBAAiB,MAAM,kBAAkB,CAAC,CAAC;YACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,yCAAyC;QACzC,MAAM,WAAW,GAAG,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,CAAC,MAAM,IAAA,2BAAkB,EAAC,WAAW,CAAC,CAA4B,CAAC;QACxF,sDAAsD;QACtD,iEAAiE;QACjE,iFAAiF;QAEjF,sCAAsC;QACtC,IAAI;YACF,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,gBAAgB,MAAM,wBAAwB,EAAE,KAAK,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,cAAc;QACd,IAAI;YACF,MAAM,IAAA,YAAM,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;SACrC;QAAC,OAAO,GAAQ,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClB;IACH,CAAC;CAAA"}
@@ -0,0 +1,68 @@
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 models, i.e. EntityType and ComplexType nodes from the EDMX model.
35
+ *
36
+ * @returns list of model types
37
+ */
38
+ getModels(): ModelType[];
39
+ addComplexType(name: string, model: ComplexType): void;
40
+ /**
41
+ * Get a specific model by its name.
42
+ *
43
+ * @param name the final model name that is generated
44
+ * @returns the model type
45
+ */
46
+ getComplexType(name: string): ComplexType;
47
+ /**
48
+ * Retrieve all known models, i.e. EntityType and ComplexType nodes from the EDMX model.
49
+ *
50
+ * @returns list of model types
51
+ */
52
+ getComplexTypes(): ComplexType[];
53
+ addEnum(name: string, type: EnumType): void;
54
+ /**
55
+ * Get list of all known enums, i.e. EnumType nodes from the EDMX model.
56
+ * @returns list of enum types
57
+ */
58
+ getEnums(): EnumType[];
59
+ addOperationType(binding: string, operationType: OperationType): void;
60
+ getUnboundOperationTypes(): Array<OperationType>;
61
+ getOperationTypeByBinding(binding: string): Array<OperationType>;
62
+ addAction(name: string, action: ActionImportType): void;
63
+ addFunction(name: string, func: FunctionImportType): void;
64
+ addSingleton(name: string, singleton: SingletonType): void;
65
+ addEntitySet(name: string, entitySet: EntitySetType): void;
66
+ getEntityContainer(): EntityContainerModel;
67
+ getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string): import("@odata2ts/converter-runtime").ValueConverterChain | undefined;
68
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataModel = void 0;
4
+ const DataTypeModel_1 = require("./DataTypeModel");
5
+ const ROOT_OPERATION_BINDING = "/";
6
+ class DataModel {
7
+ constructor(version, converters = new Map()) {
8
+ this.version = version;
9
+ this.modelTypes = {};
10
+ this.complexTypes = {};
11
+ this.enumTypes = {};
12
+ // combines functions & actions
13
+ this.operationTypes = {};
14
+ this.container = { entitySets: {}, singletons: {}, functions: {}, actions: {} };
15
+ this.converters = converters;
16
+ }
17
+ /**
18
+ * OData version: 2.0 or 4.0.
19
+ * @returns
20
+ */
21
+ getODataVersion() {
22
+ return this.version;
23
+ }
24
+ isV2() {
25
+ return this.version === DataTypeModel_1.ODataVersion.V2;
26
+ }
27
+ isV4() {
28
+ return this.version === DataTypeModel_1.ODataVersion.V4;
29
+ }
30
+ addModel(name, model) {
31
+ this.modelTypes[name] = model;
32
+ }
33
+ /**
34
+ * Get a specific model by its name.
35
+ *
36
+ * @param modelName the final model name that is generated
37
+ * @returns the model type
38
+ */
39
+ getModel(modelName) {
40
+ return this.modelTypes[modelName];
41
+ }
42
+ /**
43
+ * Retrieve all known models, i.e. EntityType and ComplexType nodes from the EDMX model.
44
+ *
45
+ * @returns list of model types
46
+ */
47
+ getModels() {
48
+ return Object.values(this.modelTypes);
49
+ }
50
+ addComplexType(name, model) {
51
+ this.complexTypes[name] = model;
52
+ }
53
+ /**
54
+ * Get a specific model by its name.
55
+ *
56
+ * @param name the final model name that is generated
57
+ * @returns the model type
58
+ */
59
+ getComplexType(name) {
60
+ return this.complexTypes[name];
61
+ }
62
+ /**
63
+ * Retrieve all known models, i.e. EntityType and ComplexType nodes from the EDMX model.
64
+ *
65
+ * @returns list of model types
66
+ */
67
+ getComplexTypes() {
68
+ return Object.values(this.complexTypes);
69
+ }
70
+ addEnum(name, type) {
71
+ this.enumTypes[name] = type;
72
+ }
73
+ /**
74
+ * Get list of all known enums, i.e. EnumType nodes from the EDMX model.
75
+ * @returns list of enum types
76
+ */
77
+ getEnums() {
78
+ return Object.values(this.enumTypes);
79
+ }
80
+ addOperationType(binding, operationType) {
81
+ if (!this.operationTypes[binding]) {
82
+ this.operationTypes[binding] = [];
83
+ }
84
+ this.operationTypes[binding].push(operationType);
85
+ }
86
+ getUnboundOperationTypes() {
87
+ const operations = this.operationTypes[ROOT_OPERATION_BINDING];
88
+ return !operations ? [] : [...operations];
89
+ }
90
+ getOperationTypeByBinding(binding) {
91
+ const operations = this.operationTypes[binding];
92
+ return !operations ? [] : [...operations];
93
+ }
94
+ addAction(name, action) {
95
+ this.container.actions[name] = action;
96
+ }
97
+ addFunction(name, func) {
98
+ this.container.functions[name] = func;
99
+ }
100
+ addSingleton(name, singleton) {
101
+ this.container.singletons[name] = singleton;
102
+ }
103
+ addEntitySet(name, entitySet) {
104
+ this.container.entitySets[name] = entitySet;
105
+ }
106
+ getEntityContainer() {
107
+ return this.container;
108
+ }
109
+ getConverter(dataType) {
110
+ return this.converters.get(dataType);
111
+ }
112
+ }
113
+ exports.DataModel = DataModel;
114
+ //# sourceMappingURL=DataModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../src/data-model/DataModel.ts"],"names":[],"mappings":";;;AAGA,mDAWyB;AAQzB,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,MAAa,SAAS;IAUpB,YAAoB,OAAqB,EAAE,aAAoC,IAAI,GAAG,EAAE;QAApE,YAAO,GAAP,OAAO,CAAc;QAPjC,eAAU,GAAkC,EAAE,CAAC;QAC/C,iBAAY,GAAoC,EAAE,CAAC;QACnD,cAAS,GAAiC,EAAE,CAAC;QACrD,+BAA+B;QACvB,mBAAc,GAAgD,EAAE,CAAC;QACjE,cAAS,GAAyB,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAGvG,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,e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
2
+ import { DigestionOptions } from "../FactoryFunctionModel";
3
+ import { DataModel } from "./DataModel";
4
+ import { ODataVersion, PropertyModel } from "./DataTypeModel";
5
+ import { ComplexType, EntityType, Property, Schema } from "./edmx/ODataEdmxModelBase";
6
+ import { NamingHelper } from "./NamingHelper";
7
+ import { ServiceConfigHelper } from "./ServiceConfigHelper";
8
+ export interface TypeModel {
9
+ outputType: string;
10
+ qPath: string;
11
+ qCollection: string;
12
+ qParam: string | undefined;
13
+ }
14
+ export declare abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {
15
+ protected version: ODataVersion;
16
+ protected schema: S;
17
+ protected options: DigestionOptions;
18
+ protected namingHelper: NamingHelper;
19
+ protected static EDM_PREFIX: string;
20
+ protected static ROOT_OPERATION: string;
21
+ protected readonly dataModel: DataModel;
22
+ protected readonly serviceConfigHelper: ServiceConfigHelper;
23
+ private model2Type;
24
+ protected constructor(version: ODataVersion, schema: S, options: DigestionOptions, namingHelper: NamingHelper, converters?: MappedConverterChains);
25
+ protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;
26
+ protected abstract digestEntityContainer(): void;
27
+ /**
28
+ * Get essential infos about a given odata type from the version specific service variants.
29
+ *
30
+ * @param type
31
+ * @return tuple of return type, query object, query collection object
32
+ */
33
+ protected abstract mapODataType(type: string): TypeModel;
34
+ digest(): Promise<DataModel>;
35
+ private collectModelTypes;
36
+ private digestSchema;
37
+ private getBaseModel;
38
+ private addComplexType;
39
+ private addEntityType;
40
+ private postProcessModel;
41
+ private collectBaseClassPropsAndKeys;
42
+ protected mapProp: (p: Property) => PropertyModel;
43
+ }
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Digester = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const DataModel_1 = require("./DataModel");
6
+ const ServiceConfigHelper_1 = require("./ServiceConfigHelper");
7
+ class Digester {
8
+ constructor(version, schema, options, namingHelper, converters) {
9
+ this.version = version;
10
+ this.schema = schema;
11
+ this.options = options;
12
+ this.namingHelper = namingHelper;
13
+ this.model2Type = new Map();
14
+ this.mapProp = (p) => {
15
+ if (!p.$.Type) {
16
+ throw new Error(`No type information given for property [${p.$.Name}]!`);
17
+ }
18
+ const isCollection = !!p.$.Type.match(/^Collection\(/);
19
+ const dataType = p.$.Type.replace(/^Collection\(([^\)]+)\)/, "$1");
20
+ const configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);
21
+ const name = this.namingHelper.getModelPropName((configProp === null || configProp === void 0 ? void 0 : configProp.mappedName) || p.$.Name);
22
+ let result;
23
+ // domain object known from service:
24
+ // EntityType, ComplexType or EnumType
25
+ if (dataType.startsWith(this.namingHelper.getServicePrefix())) {
26
+ const resultDt = this.model2Type.get(dataType);
27
+ if (!resultDt) {
28
+ throw new Error(`Couldn't determine model type for data type with name '${dataType}'`);
29
+ }
30
+ // special handling for enums
31
+ if (resultDt === "EnumType" /* EnumType */) {
32
+ result = {
33
+ dataType: resultDt,
34
+ type: this.namingHelper.getEnumName(dataType),
35
+ qPath: "QEnumPath",
36
+ qObject: isCollection ? "QEnumCollection" : undefined,
37
+ };
38
+ }
39
+ // handling of complex & entity types
40
+ else {
41
+ result = {
42
+ dataType: resultDt,
43
+ type: this.namingHelper.getModelName(dataType),
44
+ qPath: "QEntityPath",
45
+ qObject: this.namingHelper.getQName(dataType),
46
+ };
47
+ }
48
+ }
49
+ // OData built-in data types
50
+ else if (dataType.startsWith(Digester.EDM_PREFIX)) {
51
+ const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);
52
+ const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};
53
+ const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;
54
+ result = {
55
+ dataType: "PrimitiveType" /* PrimitiveType */,
56
+ type,
57
+ typeModule,
58
+ qPath,
59
+ qParam,
60
+ qObject: isCollection ? qCollection : undefined,
61
+ converters,
62
+ };
63
+ }
64
+ else {
65
+ throw new Error(`Unknown type [${dataType}]: Not 'Collection(...)', not '${this.namingHelper.getServicePrefix()}*', not OData type 'Edm.*'`);
66
+ }
67
+ return Object.assign({ odataName: p.$.Name, name, odataType: p.$.Type, required: p.$.Nullable === "false", isCollection: isCollection, managed: configProp === null || configProp === void 0 ? void 0 : configProp.managed }, result);
68
+ };
69
+ this.dataModel = new DataModel_1.DataModel(version, converters);
70
+ this.serviceConfigHelper = new ServiceConfigHelper_1.ServiceConfigHelper(options);
71
+ this.collectModelTypes(this.schema);
72
+ }
73
+ digest() {
74
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
75
+ this.digestSchema(this.schema);
76
+ return this.dataModel;
77
+ });
78
+ }
79
+ collectModelTypes(schema) {
80
+ var _a, _b, _c;
81
+ const servicePrefix = this.namingHelper.getServicePrefix();
82
+ (_a = schema.EnumType) === null || _a === void 0 ? void 0 : _a.forEach((et) => {
83
+ this.model2Type.set(servicePrefix + et.$.Name, "EnumType" /* EnumType */);
84
+ });
85
+ (_b = schema.ComplexType) === null || _b === void 0 ? void 0 : _b.forEach((ct) => {
86
+ this.model2Type.set(servicePrefix + ct.$.Name, "ComplexType" /* ComplexType */);
87
+ });
88
+ (_c = schema.EntityType) === null || _c === void 0 ? void 0 : _c.forEach((et) => {
89
+ this.model2Type.set(servicePrefix + et.$.Name, "ModelType" /* ModelType */);
90
+ });
91
+ }
92
+ digestSchema(schema) {
93
+ // enums
94
+ if (schema.EnumType) {
95
+ for (const et of schema.EnumType) {
96
+ const name = et.$.Name;
97
+ this.dataModel.addEnum(name, {
98
+ odataName: name,
99
+ name: this.namingHelper.getEnumName(name),
100
+ members: et.Member.map((m) => m.$.Name),
101
+ });
102
+ }
103
+ }
104
+ // entity types
105
+ this.addEntityType(schema.EntityType);
106
+ // complex types
107
+ this.addComplexType(schema.ComplexType);
108
+ this.postProcessModel();
109
+ // delegate to concrete entity container digestion
110
+ this.digestEntityContainer();
111
+ }
112
+ getBaseModel(model) {
113
+ var _a;
114
+ const name = this.namingHelper.getModelName(model.$.Name);
115
+ const qName = this.namingHelper.getQName(model.$.Name);
116
+ const editableName = this.namingHelper.getEditableModelName(model.$.Name);
117
+ const odataName = model.$.Name;
118
+ const bType = model.$.BaseType;
119
+ const props = [...((_a = model.Property) !== null && _a !== void 0 ? _a : []), ...this.getNavigationProps(model)];
120
+ // support for base types, i.e. extends clause of interfaces
121
+ const baseClasses = [];
122
+ if (bType) {
123
+ baseClasses.push(this.namingHelper.getModelName(bType));
124
+ }
125
+ return {
126
+ name,
127
+ qName,
128
+ odataName,
129
+ editableName,
130
+ baseClasses,
131
+ props: props.map(this.mapProp),
132
+ baseProps: [], // postprocess required
133
+ };
134
+ }
135
+ addComplexType(models) {
136
+ if (!models || !models.length) {
137
+ return;
138
+ }
139
+ for (const model of models) {
140
+ const baseModel = this.getBaseModel(model);
141
+ this.dataModel.addComplexType(baseModel.name, baseModel);
142
+ }
143
+ }
144
+ addEntityType(models) {
145
+ if (!models || !models.length) {
146
+ return;
147
+ }
148
+ for (const model of models) {
149
+ const baseModel = this.getBaseModel(model);
150
+ // key support: we add keys from this entity,
151
+ // but not keys stemming from base classes (postprocess required)
152
+ const keyNames = [];
153
+ const entity = model;
154
+ if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {
155
+ const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);
156
+ keyNames.push(...propNames);
157
+ }
158
+ this.dataModel.addModel(baseModel.name, Object.assign(Object.assign({}, baseModel), { idModelName: this.namingHelper.getIdModelName(model.$.Name), qIdFunctionName: this.namingHelper.getQIdFunctionName(model.$.Name), generateId: true, keyNames: keyNames, keys: [], getKeyUnion: () => keyNames.join(" | ") }));
159
+ }
160
+ }
161
+ postProcessModel() {
162
+ // complex types
163
+ this.dataModel.getComplexTypes().forEach((model) => {
164
+ const [baseProps] = this.collectBaseClassPropsAndKeys(model);
165
+ model.baseProps = baseProps;
166
+ });
167
+ // entity types
168
+ this.dataModel.getModels().forEach((model) => {
169
+ const [baseProps, baseKeys, idName, qIdName] = this.collectBaseClassPropsAndKeys(model);
170
+ model.baseProps = baseProps;
171
+ if (!model.keyNames.length && idName) {
172
+ model.idModelName = idName;
173
+ model.qIdFunctionName = qIdName;
174
+ model.generateId = false;
175
+ }
176
+ model.keyNames.unshift(...baseKeys);
177
+ // sanity check: entity types require key specification
178
+ if (!model.keyNames.length) {
179
+ throw new Error(`Key property is missing from Entity "${model.name}" (${model.odataName})!`);
180
+ }
181
+ const isSingleKey = model.keyNames.length === 1;
182
+ const props = [...model.baseProps, ...model.props];
183
+ model.keys = model.keyNames.map((keyName) => {
184
+ const prop = props.find((p) => p.odataName === keyName);
185
+ if (!prop) {
186
+ throw new Error(`Key with name [${keyName}] not found in props!`);
187
+ }
188
+ // automatically set key prop to managed, if this is the only key of the given entity
189
+ if (prop.managed === undefined) {
190
+ prop.managed = !this.options.disableAutoManagedKey && isSingleKey;
191
+ }
192
+ return prop;
193
+ });
194
+ });
195
+ }
196
+ collectBaseClassPropsAndKeys(model) {
197
+ return model.baseClasses.reduce(([props, keys, idName, qIdName], bc) => {
198
+ const baseModel = this.dataModel.getModel(bc) || this.dataModel.getComplexType(bc);
199
+ let idNameResult = idName;
200
+ let qIdNameResult = qIdName;
201
+ // recursive
202
+ if (baseModel.baseClasses.length) {
203
+ const [parentProps, parentKeys, parentIdName, parentQIdName] = this.collectBaseClassPropsAndKeys(baseModel);
204
+ props.unshift(...parentProps);
205
+ keys.unshift(...parentKeys);
206
+ if (parentIdName) {
207
+ idNameResult = parentIdName;
208
+ qIdNameResult = parentQIdName;
209
+ }
210
+ }
211
+ props.push(...baseModel.props);
212
+ if (baseModel.keyNames) {
213
+ keys.push(...baseModel.keyNames.filter((kn) => !keys.includes(kn)));
214
+ idNameResult = baseModel.idModelName;
215
+ qIdNameResult = baseModel.qIdFunctionName;
216
+ }
217
+ return [props, keys, idNameResult, qIdNameResult];
218
+ }, [[], [], "", ""]);
219
+ }
220
+ }
221
+ exports.Digester = Digester;
222
+ Digester.EDM_PREFIX = "Edm.";
223
+ Digester.ROOT_OPERATION = "/";
224
+ //# sourceMappingURL=DataModelDigestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAGA,2CAAwC;AAIxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,MAAS,EACT,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAG;QACT,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QA0MhE,YAAO,GAAG,CAAC,CAAW,EAAiB,EAAE;YACjD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;aAC1E;YAED,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACvD,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;YACnE,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,KAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAEpF,IAAI,MAA+G,CAAC;YAEpH,oCAAoC;YACpC,sCAAsC;Y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,CAAC;oBAC5B,aAAa,GAAG,aAAa,CAAC;iBAC/B;aACF;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,SAAS,CAAC,QAAQ,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpE,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;gBACrC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;aAC3C;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QACpD,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAA0D,CAC1E,CAAC;IACJ,CAAC;;AA/MH,4BAwRC;AAvRkB,mBAAU,GAAG,MAAM,CAAC;AACpB,uBAAc,GAAG,GAAG,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { DigesterFunction } from "../FactoryFunctionModel";
2
+ import { SchemaV3 } from "./edmx/ODataEdmxModelV3";
3
+ /**
4
+ * Digests an EDMX schema to produce a DataModel.
5
+ *
6
+ * @param schema
7
+ * @param options
8
+ * @param namingHelper
9
+ */
10
+ export declare const digest: DigesterFunction<SchemaV3>;