@odata2ts/odata2ts 0.23.1 → 0.25.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 +22 -0
- 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 +67 -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 +88 -85
- package/lib/data-model/DataModel.js +141 -134
- package/lib/data-model/DataModel.js.map +1 -1
- package/lib/data-model/DataModelDigestion.d.ts +48 -44
- package/lib/data-model/DataModelDigestion.js +299 -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 +210 -200
- package/lib/data-model/DataModelDigestionV2.js.map +1 -1
- package/lib/data-model/DataModelDigestionV4.d.ts +3 -3
- package/lib/data-model/DataModelDigestionV4.js +197 -195
- package/lib/data-model/DataModelDigestionV4.js.map +1 -1
- 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 +57 -55
- package/lib/data-model/NamingHelper.js +231 -214
- package/lib/data-model/NamingHelper.js.map +1 -1
- 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 +92 -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/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/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
|
@@ -1,85 +1,88 @@
|
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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 typeDefinitions;
|
|
17
|
+
private container;
|
|
18
|
+
constructor(version: ODataVersion, converters?: MappedConverterChains);
|
|
19
|
+
/**
|
|
20
|
+
* OData version: 2.0 or 4.0.
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
getODataVersion(): ODataVersion;
|
|
24
|
+
isV2(): boolean;
|
|
25
|
+
isV4(): boolean;
|
|
26
|
+
addTypeDefinition(name: string, type: string): void;
|
|
27
|
+
getPrimitiveType(name: string): string | undefined;
|
|
28
|
+
addModel(name: string, model: ModelType): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific model by its name.
|
|
31
|
+
*
|
|
32
|
+
* @param modelName the final model name that is generated
|
|
33
|
+
* @returns the model type
|
|
34
|
+
*/
|
|
35
|
+
getModel(modelName: string): ModelType;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve all known EntityType models from the EDMX model.
|
|
38
|
+
*
|
|
39
|
+
* @returns list of model types
|
|
40
|
+
*/
|
|
41
|
+
getModels(): ModelType[];
|
|
42
|
+
/**
|
|
43
|
+
* Set all model entity types
|
|
44
|
+
*
|
|
45
|
+
* @param models new model types
|
|
46
|
+
*/
|
|
47
|
+
setModels(models: {
|
|
48
|
+
[name: string]: ModelType;
|
|
49
|
+
}): void;
|
|
50
|
+
addComplexType(name: string, model: ComplexType): void;
|
|
51
|
+
/**
|
|
52
|
+
* Get a specific model by its name.
|
|
53
|
+
*
|
|
54
|
+
* @param name the final model name that is generated
|
|
55
|
+
* @returns the model type
|
|
56
|
+
*/
|
|
57
|
+
getComplexType(name: string): ComplexType;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve all known ComplexType models from the EDMX model.
|
|
60
|
+
*
|
|
61
|
+
* @returns list of model types
|
|
62
|
+
*/
|
|
63
|
+
getComplexTypes(): ComplexType[];
|
|
64
|
+
/**
|
|
65
|
+
* Set all complex types
|
|
66
|
+
*
|
|
67
|
+
* @param models new complex types
|
|
68
|
+
*/
|
|
69
|
+
setComplexTypes(complexTypes: {
|
|
70
|
+
[name: string]: ComplexType;
|
|
71
|
+
}): void;
|
|
72
|
+
addEnum(name: string, type: EnumType): void;
|
|
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(): EnumType[];
|
|
78
|
+
addOperationType(binding: string, operationType: OperationType): void;
|
|
79
|
+
getUnboundOperationTypes(): Array<OperationType>;
|
|
80
|
+
getOperationTypeByBinding(binding: string): Array<OperationType>;
|
|
81
|
+
getOperationTypeByEntityOrCollectionBinding(binding: string): Array<OperationType>;
|
|
82
|
+
addAction(name: string, action: ActionImportType): void;
|
|
83
|
+
addFunction(name: string, func: FunctionImportType): void;
|
|
84
|
+
addSingleton(name: string, singleton: SingletonType): void;
|
|
85
|
+
addEntitySet(name: string, entitySet: EntitySetType): void;
|
|
86
|
+
getEntityContainer(): EntityContainerModel;
|
|
87
|
+
getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string): import("@odata2ts/converter-runtime").ValueConverterChain | undefined;
|
|
88
|
+
}
|
|
@@ -1,135 +1,142 @@
|
|
|
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.
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
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.typeDefinitions = {};
|
|
15
|
+
this.container = { entitySets: {}, singletons: {}, functions: {}, actions: {} };
|
|
16
|
+
this.converters = converters;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* OData version: 2.0 or 4.0.
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
getODataVersion() {
|
|
23
|
+
return this.version;
|
|
24
|
+
}
|
|
25
|
+
isV2() {
|
|
26
|
+
return this.version === DataTypeModel_1.ODataVersion.V2;
|
|
27
|
+
}
|
|
28
|
+
isV4() {
|
|
29
|
+
return this.version === DataTypeModel_1.ODataVersion.V4;
|
|
30
|
+
}
|
|
31
|
+
addTypeDefinition(name, type) {
|
|
32
|
+
this.typeDefinitions[name] = type;
|
|
33
|
+
}
|
|
34
|
+
getPrimitiveType(name) {
|
|
35
|
+
return this.typeDefinitions[name];
|
|
36
|
+
}
|
|
37
|
+
addModel(name, model) {
|
|
38
|
+
this.modelTypes[name] = model;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get a specific model by its name.
|
|
42
|
+
*
|
|
43
|
+
* @param modelName the final model name that is generated
|
|
44
|
+
* @returns the model type
|
|
45
|
+
*/
|
|
46
|
+
getModel(modelName) {
|
|
47
|
+
return this.modelTypes[modelName];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Retrieve all known EntityType models from the EDMX model.
|
|
51
|
+
*
|
|
52
|
+
* @returns list of model types
|
|
53
|
+
*/
|
|
54
|
+
getModels() {
|
|
55
|
+
return Object.values(this.modelTypes);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set all model entity types
|
|
59
|
+
*
|
|
60
|
+
* @param models new model types
|
|
61
|
+
*/
|
|
62
|
+
setModels(models) {
|
|
63
|
+
this.modelTypes = models;
|
|
64
|
+
}
|
|
65
|
+
addComplexType(name, model) {
|
|
66
|
+
this.complexTypes[name] = model;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get a specific model by its name.
|
|
70
|
+
*
|
|
71
|
+
* @param name the final model name that is generated
|
|
72
|
+
* @returns the model type
|
|
73
|
+
*/
|
|
74
|
+
getComplexType(name) {
|
|
75
|
+
return this.complexTypes[name];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve all known ComplexType models from the EDMX model.
|
|
79
|
+
*
|
|
80
|
+
* @returns list of model types
|
|
81
|
+
*/
|
|
82
|
+
getComplexTypes() {
|
|
83
|
+
return Object.values(this.complexTypes);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set all complex types
|
|
87
|
+
*
|
|
88
|
+
* @param models new complex types
|
|
89
|
+
*/
|
|
90
|
+
setComplexTypes(complexTypes) {
|
|
91
|
+
this.complexTypes = complexTypes;
|
|
92
|
+
}
|
|
93
|
+
addEnum(name, type) {
|
|
94
|
+
this.enumTypes[name] = type;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get list of all known enums, i.e. EnumType nodes from the EDMX model.
|
|
98
|
+
* @returns list of enum types
|
|
99
|
+
*/
|
|
100
|
+
getEnums() {
|
|
101
|
+
return Object.values(this.enumTypes);
|
|
102
|
+
}
|
|
103
|
+
addOperationType(binding, operationType) {
|
|
104
|
+
if (!this.operationTypes[binding]) {
|
|
105
|
+
this.operationTypes[binding] = [];
|
|
106
|
+
}
|
|
107
|
+
this.operationTypes[binding].push(operationType);
|
|
108
|
+
}
|
|
109
|
+
getUnboundOperationTypes() {
|
|
110
|
+
const operations = this.operationTypes[ROOT_OPERATION_BINDING];
|
|
111
|
+
return !operations ? [] : [...operations];
|
|
112
|
+
}
|
|
113
|
+
getOperationTypeByBinding(binding) {
|
|
114
|
+
const operations = this.operationTypes[binding];
|
|
115
|
+
return !operations ? [] : [...operations];
|
|
116
|
+
}
|
|
117
|
+
getOperationTypeByEntityOrCollectionBinding(binding) {
|
|
118
|
+
const entityOps = this.operationTypes[binding] || [];
|
|
119
|
+
const collOps = this.operationTypes[`Collection(${binding})`] || [];
|
|
120
|
+
return [...collOps, ...entityOps];
|
|
121
|
+
}
|
|
122
|
+
addAction(name, action) {
|
|
123
|
+
this.container.actions[name] = action;
|
|
124
|
+
}
|
|
125
|
+
addFunction(name, func) {
|
|
126
|
+
this.container.functions[name] = func;
|
|
127
|
+
}
|
|
128
|
+
addSingleton(name, singleton) {
|
|
129
|
+
this.container.singletons[name] = singleton;
|
|
130
|
+
}
|
|
131
|
+
addEntitySet(name, entitySet) {
|
|
132
|
+
this.container.entitySets[name] = entitySet;
|
|
133
|
+
}
|
|
134
|
+
getEntityContainer() {
|
|
135
|
+
return this.container;
|
|
136
|
+
}
|
|
137
|
+
getConverter(dataType) {
|
|
138
|
+
return this.converters.get(dataType);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.DataModel = DataModel;
|
|
135
142
|
//# sourceMappingURL=DataModel.js.map
|
|
@@ -1 +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;
|
|
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;IAWpB,YAAoB,OAAqB,EAAE,aAAoC,IAAI,GAAG,EAAE;QAApE,YAAO,GAAP,OAAO,CAAc;QARjC,eAAU,GAAkC,EAAE,CAAC;QAC/C,iBAAY,GAAoC,EAAE,CAAC;QACnD,cAAS,GAAiC,EAAE,CAAC;QACrD,+BAA+B;QACvB,mBAAc,GAAgD,EAAE,CAAC;QACjE,oBAAe,GAA+B,EAAE,CAAC;QACjD,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,eAAe;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,IAAI;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AY,EAAE,IAAwB;QACvD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACxC,CAAC;IAEM,YAAY,CAAC,IAAY,EAAE,SAAwB;QACxD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAC9C,CAAC;IAEM,YAAY,CAAC,IAAY,EAAE,SAAwB;QACxD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAC9C,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,YAAY,CAAC,QAA8C;QAChE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF;AAlKD,8BAkKC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV2, ODataTypesV4 } from \"@odata2ts/odata-core\";\r\n\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n EntityContainerModel,\r\n EntitySetType,\r\n EnumType,\r\n FunctionImportType,\r\n ModelType,\r\n ODataVersion,\r\n OperationType,\r\n SingletonType,\r\n} from \"./DataTypeModel\";\r\n\r\nexport interface ProjectFiles {\r\n model: string;\r\n qObject: string;\r\n service: string;\r\n}\r\n\r\nconst ROOT_OPERATION_BINDING = \"/\";\r\n\r\nexport class DataModel {\r\n private readonly converters: MappedConverterChains;\r\n\r\n private modelTypes: { [name: string]: ModelType } = {};\r\n private complexTypes: { [name: string]: ComplexType } = {};\r\n private enumTypes: { [name: string]: EnumType } = {};\r\n // combines functions & actions\r\n private operationTypes: { [binding: string]: Array<OperationType> } = {};\r\n private typeDefinitions: { [name: string]: string } = {};\r\n private container: EntityContainerModel = { entitySets: {}, singletons: {}, functions: {}, actions: {} };\r\n\r\n constructor(private version: ODataVersion, converters: MappedConverterChains = new Map()) {\r\n this.converters = converters;\r\n }\r\n\r\n /**\r\n * OData version: 2.0 or 4.0.\r\n * @returns\r\n */\r\n public getODataVersion() {\r\n return this.version;\r\n }\r\n\r\n public isV2() {\r\n return this.version === ODataVersion.V2;\r\n }\r\n\r\n public isV4() {\r\n return this.version === ODataVersion.V4;\r\n }\r\n\r\n public addTypeDefinition(name: string, type: string) {\r\n this.typeDefinitions[name] = type;\r\n }\r\n\r\n public getPrimitiveType(name: string): string | undefined {\r\n return this.typeDefinitions[name];\r\n }\r\n\r\n public addModel(name: string, model: ModelType) {\r\n this.modelTypes[name] = model;\r\n }\r\n\r\n /**\r\n * Get a specific model by its name.\r\n *\r\n * @param modelName the final model name that is generated\r\n * @returns the model type\r\n */\r\n public getModel(modelName: string) {\r\n return this.modelTypes[modelName];\r\n }\r\n\r\n /**\r\n * Retrieve all known EntityType models from the EDMX model.\r\n *\r\n * @returns list of model types\r\n */\r\n public getModels() {\r\n return Object.values(this.modelTypes);\r\n }\r\n\r\n /**\r\n * Set all model entity types\r\n *\r\n * @param models new model types\r\n */\r\n public setModels(models: { [name: string]: ModelType }) {\r\n this.modelTypes = models;\r\n }\r\n\r\n public addComplexType(name: string, model: ComplexType) {\r\n this.complexTypes[name] = model;\r\n }\r\n\r\n /**\r\n * Get a specific model by its name.\r\n *\r\n * @param name the final model name that is generated\r\n * @returns the model type\r\n */\r\n public getComplexType(name: string) {\r\n return this.complexTypes[name];\r\n }\r\n\r\n /**\r\n * Retrieve all known ComplexType models from the EDMX model.\r\n *\r\n * @returns list of model types\r\n */\r\n public getComplexTypes() {\r\n return Object.values(this.complexTypes);\r\n }\r\n\r\n /**\r\n * Set all complex types\r\n *\r\n * @param models new complex types\r\n */\r\n public setComplexTypes(complexTypes: { [name: string]: ComplexType }) {\r\n this.complexTypes = complexTypes;\r\n }\r\n\r\n public addEnum(name: string, type: EnumType) {\r\n this.enumTypes[name] = type;\r\n }\r\n\r\n /**\r\n * Get list of all known enums, i.e. EnumType nodes from the EDMX model.\r\n * @returns list of enum types\r\n */\r\n public getEnums() {\r\n return Object.values(this.enumTypes);\r\n }\r\n\r\n public addOperationType(binding: string, operationType: OperationType) {\r\n if (!this.operationTypes[binding]) {\r\n this.operationTypes[binding] = [];\r\n }\r\n\r\n this.operationTypes[binding].push(operationType);\r\n }\r\n\r\n public getUnboundOperationTypes(): Array<OperationType> {\r\n const operations = this.operationTypes[ROOT_OPERATION_BINDING];\r\n return !operations ? [] : [...operations];\r\n }\r\n\r\n public getOperationTypeByBinding(binding: string): Array<OperationType> {\r\n const operations = this.operationTypes[binding];\r\n return !operations ? [] : [...operations];\r\n }\r\n\r\n public getOperationTypeByEntityOrCollectionBinding(binding: string): Array<OperationType> {\r\n const entityOps = this.operationTypes[binding] || [];\r\n const collOps = this.operationTypes[`Collection(${binding})`] || [];\r\n return [...collOps, ...entityOps];\r\n }\r\n\r\n public addAction(name: string, action: ActionImportType) {\r\n this.container.actions[name] = action;\r\n }\r\n\r\n public addFunction(name: string, func: FunctionImportType) {\r\n this.container.functions[name] = func;\r\n }\r\n\r\n public addSingleton(name: string, singleton: SingletonType) {\r\n this.container.singletons[name] = singleton;\r\n }\r\n\r\n public addEntitySet(name: string, entitySet: EntitySetType) {\r\n this.container.entitySets[name] = entitySet;\r\n }\r\n\r\n public getEntityContainer() {\r\n return this.container;\r\n }\r\n\r\n public getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string) {\r\n return this.converters.get(dataType);\r\n }\r\n}\r\n"]}
|
|
@@ -1,44 +1,48 @@
|
|
|
1
|
-
import { MappedConverterChains } from "@odata2ts/converter-runtime";
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
protected
|
|
18
|
-
protected
|
|
19
|
-
protected
|
|
20
|
-
protected
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
23
|
-
|
|
24
|
-
protected
|
|
25
|
-
|
|
26
|
-
protected
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import { MappedConverterChains } from "@odata2ts/converter-runtime";
|
|
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 { SchemaV3 } from "./edmx/ODataEdmxModelV3";
|
|
7
|
+
import { SchemaV4 } from "./edmx/ODataEdmxModelV4";
|
|
8
|
+
import { NamingHelper } from "./NamingHelper";
|
|
9
|
+
import { ServiceConfigHelper } from "./ServiceConfigHelper";
|
|
10
|
+
export interface TypeModel {
|
|
11
|
+
outputType: string;
|
|
12
|
+
qPath: string;
|
|
13
|
+
qCollection: string;
|
|
14
|
+
qParam: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {
|
|
17
|
+
protected version: ODataVersion;
|
|
18
|
+
protected schemas: Array<S>;
|
|
19
|
+
protected options: DigestionOptions;
|
|
20
|
+
protected namingHelper: NamingHelper;
|
|
21
|
+
protected static EDM_PREFIX: string;
|
|
22
|
+
protected static ROOT_OPERATION: string;
|
|
23
|
+
protected readonly dataModel: DataModel;
|
|
24
|
+
protected readonly serviceConfigHelper: ServiceConfigHelper;
|
|
25
|
+
private model2Type;
|
|
26
|
+
protected constructor(version: ODataVersion, schemas: Array<S>, options: DigestionOptions, namingHelper: NamingHelper, converters?: MappedConverterChains);
|
|
27
|
+
protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;
|
|
28
|
+
protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;
|
|
29
|
+
protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get essential infos about a given odata type from the version specific service variants.
|
|
32
|
+
*
|
|
33
|
+
* @param type
|
|
34
|
+
* @return tuple of return type, query object, query collection object
|
|
35
|
+
*/
|
|
36
|
+
protected abstract mapODataType(type: string): TypeModel;
|
|
37
|
+
digest(): Promise<DataModel>;
|
|
38
|
+
private collectModelTypes;
|
|
39
|
+
private digestEntityTypesAndOperations;
|
|
40
|
+
private getBaseModel;
|
|
41
|
+
private addTypeDefinition;
|
|
42
|
+
private addComplexType;
|
|
43
|
+
private addEntityType;
|
|
44
|
+
private postProcessModel;
|
|
45
|
+
private sortModelsByInheritance;
|
|
46
|
+
private collectBaseClassPropsAndKeys;
|
|
47
|
+
protected mapProp: (p: Property) => PropertyModel;
|
|
48
|
+
}
|