@odata2ts/odata2ts 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +74 -74
- package/lib/FactoryFunctionModel.d.ts +13 -13
- package/lib/FactoryFunctionModel.js +2 -2
- package/lib/FactoryFunctionModel.js.map +1 -1
- package/lib/NamingModel.d.ts +182 -182
- package/lib/NamingModel.js +11 -11
- package/lib/NamingModel.js.map +1 -1
- package/lib/OptionModel.d.ts +228 -223
- package/lib/OptionModel.js +23 -23
- package/lib/OptionModel.js.map +1 -1
- package/lib/app.d.ts +8 -8
- package/lib/app.js +63 -63
- package/lib/app.js.map +1 -1
- package/lib/cli.d.ts +3 -3
- package/lib/cli.js +153 -153
- package/lib/data-model/DataModel.d.ts +85 -85
- package/lib/data-model/DataModel.js +134 -134
- package/lib/data-model/DataModelDigestion.d.ts +44 -44
- package/lib/data-model/DataModelDigestion.js +274 -274
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- package/lib/data-model/DataModelDigestionV2.d.ts +10 -10
- package/lib/data-model/DataModelDigestionV2.js +200 -200
- package/lib/data-model/DataModelDigestionV4.d.ts +3 -3
- package/lib/data-model/DataModelDigestionV4.js +195 -195
- package/lib/data-model/DataTypeModel.d.ts +102 -102
- package/lib/data-model/DataTypeModel.js +8 -8
- package/lib/data-model/DataTypeModel.js.map +1 -1
- package/lib/data-model/NamingHelper.d.ts +55 -55
- package/lib/data-model/NamingHelper.js +214 -214
- package/lib/data-model/ServiceConfigHelper.d.ts +21 -21
- package/lib/data-model/ServiceConfigHelper.js +113 -113
- package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +80 -80
- package/lib/data-model/edmx/ODataEdmxModelBase.js +2 -2
- package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
- package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +63 -63
- package/lib/data-model/edmx/ODataEdmxModelV3.js +2 -2
- package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +67 -67
- package/lib/data-model/edmx/ODataEdmxModelV4.js +2 -2
- package/lib/defaultConfig.d.ts +9 -9
- package/lib/defaultConfig.js +165 -164
- package/lib/defaultConfig.js.map +1 -1
- package/lib/evaluateConfig.d.ts +25 -25
- package/lib/evaluateConfig.js +82 -82
- package/lib/generator/ImportContainer.d.ts +16 -16
- package/lib/generator/ImportContainer.js +91 -91
- package/lib/generator/ImportContainer.js.map +1 -1
- package/lib/generator/ModelGenerator.d.ts +2 -2
- package/lib/generator/ModelGenerator.js +211 -183
- package/lib/generator/ModelGenerator.js.map +1 -1
- package/lib/generator/QueryObjectGenerator.d.ts +2 -2
- package/lib/generator/QueryObjectGenerator.js +239 -239
- package/lib/generator/ServiceGenerator.d.ts +8 -8
- package/lib/generator/ServiceGenerator.js +422 -422
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/lib/generator/index.d.ts +3 -3
- package/lib/generator/index.js +9 -9
- package/lib/index.d.ts +3 -3
- package/lib/index.js +6 -6
- package/lib/project/ProjectManager.d.ts +30 -30
- package/lib/project/ProjectManager.js +177 -175
- package/lib/project/ProjectManager.js.map +1 -1
- package/lib/project/formatter/BaseFormatter.d.ts +49 -49
- package/lib/project/formatter/BaseFormatter.js +30 -30
- package/lib/project/formatter/FileFormatter.d.ts +16 -16
- package/lib/project/formatter/FileFormatter.js +2 -2
- package/lib/project/formatter/NoopFormatter.d.ts +29 -29
- package/lib/project/formatter/NoopFormatter.js +42 -42
- package/lib/project/formatter/PrettierFormatter.d.ts +46 -46
- package/lib/project/formatter/PrettierFormatter.js +92 -92
- package/lib/project/formatter/index.d.ts +2 -2
- package/lib/project/formatter/index.js +14 -14
- package/lib/project/logger/logFilePath.d.ts +1 -1
- package/lib/project/logger/logFilePath.js +12 -12
- package/lib/run-cli.d.ts +2 -2
- package/lib/run-cli.js +6 -6
- package/package.json +27 -28
|
@@ -1,135 +1,135 @@
|
|
|
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 EntityType models from the EDMX model.
|
|
44
|
-
*
|
|
45
|
-
* @returns list of model types
|
|
46
|
-
*/
|
|
47
|
-
getModels() {
|
|
48
|
-
return Object.values(this.modelTypes);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Set all model entity types
|
|
52
|
-
*
|
|
53
|
-
* @param models new model types
|
|
54
|
-
*/
|
|
55
|
-
setModels(models) {
|
|
56
|
-
this.modelTypes = models;
|
|
57
|
-
}
|
|
58
|
-
addComplexType(name, model) {
|
|
59
|
-
this.complexTypes[name] = model;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get a specific model by its name.
|
|
63
|
-
*
|
|
64
|
-
* @param name the final model name that is generated
|
|
65
|
-
* @returns the model type
|
|
66
|
-
*/
|
|
67
|
-
getComplexType(name) {
|
|
68
|
-
return this.complexTypes[name];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Retrieve all known ComplexType models from the EDMX model.
|
|
72
|
-
*
|
|
73
|
-
* @returns list of model types
|
|
74
|
-
*/
|
|
75
|
-
getComplexTypes() {
|
|
76
|
-
return Object.values(this.complexTypes);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Set all complex types
|
|
80
|
-
*
|
|
81
|
-
* @param models new complex types
|
|
82
|
-
*/
|
|
83
|
-
setComplexTypes(complexTypes) {
|
|
84
|
-
this.complexTypes = complexTypes;
|
|
85
|
-
}
|
|
86
|
-
addEnum(name, type) {
|
|
87
|
-
this.enumTypes[name] = type;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get list of all known enums, i.e. EnumType nodes from the EDMX model.
|
|
91
|
-
* @returns list of enum types
|
|
92
|
-
*/
|
|
93
|
-
getEnums() {
|
|
94
|
-
return Object.values(this.enumTypes);
|
|
95
|
-
}
|
|
96
|
-
addOperationType(binding, operationType) {
|
|
97
|
-
if (!this.operationTypes[binding]) {
|
|
98
|
-
this.operationTypes[binding] = [];
|
|
99
|
-
}
|
|
100
|
-
this.operationTypes[binding].push(operationType);
|
|
101
|
-
}
|
|
102
|
-
getUnboundOperationTypes() {
|
|
103
|
-
const operations = this.operationTypes[ROOT_OPERATION_BINDING];
|
|
104
|
-
return !operations ? [] : [...operations];
|
|
105
|
-
}
|
|
106
|
-
getOperationTypeByBinding(binding) {
|
|
107
|
-
const operations = this.operationTypes[binding];
|
|
108
|
-
return !operations ? [] : [...operations];
|
|
109
|
-
}
|
|
110
|
-
getOperationTypeByEntityOrCollectionBinding(binding) {
|
|
111
|
-
const entityOps = this.operationTypes[binding] || [];
|
|
112
|
-
const collOps = this.operationTypes[`Collection(${binding})`] || [];
|
|
113
|
-
return [...collOps, ...entityOps];
|
|
114
|
-
}
|
|
115
|
-
addAction(name, action) {
|
|
116
|
-
this.container.actions[name] = action;
|
|
117
|
-
}
|
|
118
|
-
addFunction(name, func) {
|
|
119
|
-
this.container.functions[name] = func;
|
|
120
|
-
}
|
|
121
|
-
addSingleton(name, singleton) {
|
|
122
|
-
this.container.singletons[name] = singleton;
|
|
123
|
-
}
|
|
124
|
-
addEntitySet(name, entitySet) {
|
|
125
|
-
this.container.entitySets[name] = entitySet;
|
|
126
|
-
}
|
|
127
|
-
getEntityContainer() {
|
|
128
|
-
return this.container;
|
|
129
|
-
}
|
|
130
|
-
getConverter(dataType) {
|
|
131
|
-
return this.converters.get(dataType);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.DataModel = DataModel;
|
|
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 EntityType models from the EDMX model.
|
|
44
|
+
*
|
|
45
|
+
* @returns list of model types
|
|
46
|
+
*/
|
|
47
|
+
getModels() {
|
|
48
|
+
return Object.values(this.modelTypes);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Set all model entity types
|
|
52
|
+
*
|
|
53
|
+
* @param models new model types
|
|
54
|
+
*/
|
|
55
|
+
setModels(models) {
|
|
56
|
+
this.modelTypes = models;
|
|
57
|
+
}
|
|
58
|
+
addComplexType(name, model) {
|
|
59
|
+
this.complexTypes[name] = model;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get a specific model by its name.
|
|
63
|
+
*
|
|
64
|
+
* @param name the final model name that is generated
|
|
65
|
+
* @returns the model type
|
|
66
|
+
*/
|
|
67
|
+
getComplexType(name) {
|
|
68
|
+
return this.complexTypes[name];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieve all known ComplexType models from the EDMX model.
|
|
72
|
+
*
|
|
73
|
+
* @returns list of model types
|
|
74
|
+
*/
|
|
75
|
+
getComplexTypes() {
|
|
76
|
+
return Object.values(this.complexTypes);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Set all complex types
|
|
80
|
+
*
|
|
81
|
+
* @param models new complex types
|
|
82
|
+
*/
|
|
83
|
+
setComplexTypes(complexTypes) {
|
|
84
|
+
this.complexTypes = complexTypes;
|
|
85
|
+
}
|
|
86
|
+
addEnum(name, type) {
|
|
87
|
+
this.enumTypes[name] = type;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get list of all known enums, i.e. EnumType nodes from the EDMX model.
|
|
91
|
+
* @returns list of enum types
|
|
92
|
+
*/
|
|
93
|
+
getEnums() {
|
|
94
|
+
return Object.values(this.enumTypes);
|
|
95
|
+
}
|
|
96
|
+
addOperationType(binding, operationType) {
|
|
97
|
+
if (!this.operationTypes[binding]) {
|
|
98
|
+
this.operationTypes[binding] = [];
|
|
99
|
+
}
|
|
100
|
+
this.operationTypes[binding].push(operationType);
|
|
101
|
+
}
|
|
102
|
+
getUnboundOperationTypes() {
|
|
103
|
+
const operations = this.operationTypes[ROOT_OPERATION_BINDING];
|
|
104
|
+
return !operations ? [] : [...operations];
|
|
105
|
+
}
|
|
106
|
+
getOperationTypeByBinding(binding) {
|
|
107
|
+
const operations = this.operationTypes[binding];
|
|
108
|
+
return !operations ? [] : [...operations];
|
|
109
|
+
}
|
|
110
|
+
getOperationTypeByEntityOrCollectionBinding(binding) {
|
|
111
|
+
const entityOps = this.operationTypes[binding] || [];
|
|
112
|
+
const collOps = this.operationTypes[`Collection(${binding})`] || [];
|
|
113
|
+
return [...collOps, ...entityOps];
|
|
114
|
+
}
|
|
115
|
+
addAction(name, action) {
|
|
116
|
+
this.container.actions[name] = action;
|
|
117
|
+
}
|
|
118
|
+
addFunction(name, func) {
|
|
119
|
+
this.container.functions[name] = func;
|
|
120
|
+
}
|
|
121
|
+
addSingleton(name, singleton) {
|
|
122
|
+
this.container.singletons[name] = singleton;
|
|
123
|
+
}
|
|
124
|
+
addEntitySet(name, entitySet) {
|
|
125
|
+
this.container.entitySets[name] = entitySet;
|
|
126
|
+
}
|
|
127
|
+
getEntityContainer() {
|
|
128
|
+
return this.container;
|
|
129
|
+
}
|
|
130
|
+
getConverter(dataType) {
|
|
131
|
+
return this.converters.get(dataType);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.DataModel = DataModel;
|
|
135
135
|
//# sourceMappingURL=DataModel.js.map
|
|
@@ -1,44 +1,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 { 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 sortModelsByInheritance;
|
|
42
|
-
private collectBaseClassPropsAndKeys;
|
|
43
|
-
protected mapProp: (p: Property) => PropertyModel;
|
|
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 { 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 sortModelsByInheritance;
|
|
42
|
+
private collectBaseClassPropsAndKeys;
|
|
43
|
+
protected mapProp: (p: Property) => PropertyModel;
|
|
44
|
+
}
|