@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.
Files changed (77) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +74 -74
  3. package/lib/FactoryFunctionModel.d.ts +13 -13
  4. package/lib/FactoryFunctionModel.js +2 -2
  5. package/lib/FactoryFunctionModel.js.map +1 -1
  6. package/lib/NamingModel.d.ts +182 -182
  7. package/lib/NamingModel.js +11 -11
  8. package/lib/NamingModel.js.map +1 -1
  9. package/lib/OptionModel.d.ts +228 -223
  10. package/lib/OptionModel.js +23 -23
  11. package/lib/OptionModel.js.map +1 -1
  12. package/lib/app.d.ts +8 -8
  13. package/lib/app.js +63 -63
  14. package/lib/app.js.map +1 -1
  15. package/lib/cli.d.ts +3 -3
  16. package/lib/cli.js +153 -153
  17. package/lib/data-model/DataModel.d.ts +85 -85
  18. package/lib/data-model/DataModel.js +134 -134
  19. package/lib/data-model/DataModelDigestion.d.ts +44 -44
  20. package/lib/data-model/DataModelDigestion.js +274 -274
  21. package/lib/data-model/DataModelDigestion.js.map +1 -1
  22. package/lib/data-model/DataModelDigestionV2.d.ts +10 -10
  23. package/lib/data-model/DataModelDigestionV2.js +200 -200
  24. package/lib/data-model/DataModelDigestionV4.d.ts +3 -3
  25. package/lib/data-model/DataModelDigestionV4.js +195 -195
  26. package/lib/data-model/DataTypeModel.d.ts +102 -102
  27. package/lib/data-model/DataTypeModel.js +8 -8
  28. package/lib/data-model/DataTypeModel.js.map +1 -1
  29. package/lib/data-model/NamingHelper.d.ts +55 -55
  30. package/lib/data-model/NamingHelper.js +214 -214
  31. package/lib/data-model/ServiceConfigHelper.d.ts +21 -21
  32. package/lib/data-model/ServiceConfigHelper.js +113 -113
  33. package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +80 -80
  34. package/lib/data-model/edmx/ODataEdmxModelBase.js +2 -2
  35. package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
  36. package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +63 -63
  37. package/lib/data-model/edmx/ODataEdmxModelV3.js +2 -2
  38. package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +67 -67
  39. package/lib/data-model/edmx/ODataEdmxModelV4.js +2 -2
  40. package/lib/defaultConfig.d.ts +9 -9
  41. package/lib/defaultConfig.js +165 -164
  42. package/lib/defaultConfig.js.map +1 -1
  43. package/lib/evaluateConfig.d.ts +25 -25
  44. package/lib/evaluateConfig.js +82 -82
  45. package/lib/generator/ImportContainer.d.ts +16 -16
  46. package/lib/generator/ImportContainer.js +91 -91
  47. package/lib/generator/ImportContainer.js.map +1 -1
  48. package/lib/generator/ModelGenerator.d.ts +2 -2
  49. package/lib/generator/ModelGenerator.js +211 -183
  50. package/lib/generator/ModelGenerator.js.map +1 -1
  51. package/lib/generator/QueryObjectGenerator.d.ts +2 -2
  52. package/lib/generator/QueryObjectGenerator.js +239 -239
  53. package/lib/generator/ServiceGenerator.d.ts +8 -8
  54. package/lib/generator/ServiceGenerator.js +422 -422
  55. package/lib/generator/ServiceGenerator.js.map +1 -1
  56. package/lib/generator/index.d.ts +3 -3
  57. package/lib/generator/index.js +9 -9
  58. package/lib/index.d.ts +3 -3
  59. package/lib/index.js +6 -6
  60. package/lib/project/ProjectManager.d.ts +30 -30
  61. package/lib/project/ProjectManager.js +177 -175
  62. package/lib/project/ProjectManager.js.map +1 -1
  63. package/lib/project/formatter/BaseFormatter.d.ts +49 -49
  64. package/lib/project/formatter/BaseFormatter.js +30 -30
  65. package/lib/project/formatter/FileFormatter.d.ts +16 -16
  66. package/lib/project/formatter/FileFormatter.js +2 -2
  67. package/lib/project/formatter/NoopFormatter.d.ts +29 -29
  68. package/lib/project/formatter/NoopFormatter.js +42 -42
  69. package/lib/project/formatter/PrettierFormatter.d.ts +46 -46
  70. package/lib/project/formatter/PrettierFormatter.js +92 -92
  71. package/lib/project/formatter/index.d.ts +2 -2
  72. package/lib/project/formatter/index.js +14 -14
  73. package/lib/project/logger/logFilePath.d.ts +1 -1
  74. package/lib/project/logger/logFilePath.js +12 -12
  75. package/lib/run-cli.d.ts +2 -2
  76. package/lib/run-cli.js +6 -6
  77. package/package.json +27 -28
@@ -1 +1 @@
1
- {"version":3,"file":"NamingModel.js","sourceRoot":"","sources":["../src/NamingModel.ts"],"names":[],"mappings":";;;AAKA,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,8CAA0B,CAAA;IAC1B,4CAAwB,CAAA;IACxB,kDAA8B,CAAA;IAC9B,4CAAwB,CAAA;AAC1B,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B","sourcesContent":["/**\r\n * The available naming strategies.\r\n */\r\nimport { PartialDeep } from \"type-fest\";\r\n\r\nexport enum NamingStrategies {\r\n NONE = \"\",\r\n PASCAL_CASE = \"pascalCase\",\r\n CAMEL_CASE = \"camelCase\",\r\n CONSTANT_CASE = \"constantCase\",\r\n SNAKE_CASE = \"snakeCase\",\r\n}\r\n\r\n/**\r\n * Based on an existing configuration (for example default settings) the user only specifies what needs\r\n * to be changed. Hence, all options are completely optional.\r\n */\r\nexport interface OverridableNamingOptions extends PartialDeep<NameSettings> {}\r\n\r\n/**\r\n * The required and optional name settings for the generator.\r\n */\r\nexport interface NameSettings {\r\n /**\r\n * Because multiple artefacts are generated out of the same entity, some name settings are required in order\r\n * to differentiate those artefacts. Out-of-the-box odata2ts provides you with sensible default settings,\r\n * so that you only need to override those settings you want to change.\r\n *\r\n * However, sometimes it makes more sense to start from scratch, so that the defaults don't interfere with\r\n * your own configuration. In this scenario this switch should be enabled to only have default values for\r\n * the required name settings.\r\n */\r\n minimalDefaults?: boolean;\r\n\r\n /**\r\n * Generation options for models, i.e. interfaces representing entity or complex types.\r\n */\r\n models: ModelNamingOptions;\r\n\r\n /**\r\n * Generation options for Query Objects.\r\n *\r\n * By default, prefix = \"Q\"\r\n */\r\n queryObjects: QueryObjectNamingOptions;\r\n\r\n services: ServiceNamingOptions;\r\n}\r\n\r\nexport interface ModelNamingOptions extends NamingStrategyOption, StandardNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of models: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can override the naming options here.\r\n * By default, prefix = \"Editable\"\r\n */\r\n editableModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Id\"\r\n */\r\n idModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * Operation parameter models are generated from function or action signatures.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Params\"\r\n */\r\n operationParamModels: EntityDerivedNamingOptions;\r\n}\r\n\r\nexport interface EntityDerivedNamingOptions extends RequiredNamingOptions {\r\n applyModelNaming?: boolean;\r\n}\r\n\r\nexport interface QueryObjectNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of query objects: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n idFunctions: RequiredNamingOptions;\r\n\r\n operations?: OperationNamingOptions;\r\n}\r\n\r\nexport interface OperationNamingOptions extends StandardNamingOptions {\r\n /**\r\n * Naming options for actions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n action?: StandardNamingOptions;\r\n /**\r\n * Naming options for functions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n function?: StandardNamingOptions;\r\n}\r\n\r\nexport interface NamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface FileNamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface StandardNamingOptions {\r\n /**\r\n * Prefix all names, e.g. \"I\" => \"ITest\"\r\n */\r\n prefix?: string;\r\n /**\r\n * Suffix all names, e.g. \"model\" => \"TestModel\"\r\n */\r\n suffix?: string;\r\n}\r\n\r\nexport interface RequiredNamingOptions extends Required<StandardNamingOptions> {}\r\n\r\n/**\r\n * Naming options for generated service classes.\r\n * These options affect the main service as well as all services generated for each entity, complex and collection type.\r\n *\r\n * There exists one specialty about services: The file names are not configurable.\r\n * File names are determined by the name of their corresponding classes, so that service file name\r\n * and service class name always correspond.\r\n *\r\n * By default, suffix = Service and namingStrategy = PascalCase\r\n */\r\nexport interface ServiceNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * Controls the naming options for the main odata service.\r\n * By default, the base service naming options are applied.\r\n * But since this is the main entry point for users, it can be configured individually here.\r\n *\r\n * By default, applyServiceNaming = true\r\n */\r\n main?: NamingStrategyOption & StandardNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Name of the service responsible for entity collections.\r\n *\r\n * By default, suffix = Collection and applyServiceNaming = true\r\n */\r\n collection: RequiredNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Naming for getter method of another service.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n relatedServiceGetter: NamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Operations are functions and actions of the OData service and are represented as methods\r\n * of the generated service class. This setting controls the naming of the corresponding\r\n * function.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n operations?: NamingStrategyOption & OperationNamingOptions;\r\n\r\n /**\r\n * Naming options for private properties of service classes.\r\n *\r\n * By default, prefix = _\r\n */\r\n privateProps: NamingStrategyOption & RequiredNamingOptions;\r\n}\r\n"]}
1
+ {"version":3,"file":"NamingModel.js","sourceRoot":"","sources":["../src/NamingModel.ts"],"names":[],"mappings":";;;AAKA,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,8CAA0B,CAAA;IAC1B,4CAAwB,CAAA;IACxB,kDAA8B,CAAA;IAC9B,4CAAwB,CAAA;AAC1B,CAAC,EANW,gBAAgB,gCAAhB,gBAAgB,QAM3B","sourcesContent":["/**\r\n * The available naming strategies.\r\n */\r\nimport { PartialDeep } from \"type-fest\";\r\n\r\nexport enum NamingStrategies {\r\n NONE = \"\",\r\n PASCAL_CASE = \"pascalCase\",\r\n CAMEL_CASE = \"camelCase\",\r\n CONSTANT_CASE = \"constantCase\",\r\n SNAKE_CASE = \"snakeCase\",\r\n}\r\n\r\n/**\r\n * Based on an existing configuration (for example default settings) the user only specifies what needs\r\n * to be changed. Hence, all options are completely optional.\r\n */\r\nexport interface OverridableNamingOptions extends PartialDeep<NameSettings> {}\r\n\r\n/**\r\n * The required and optional name settings for the generator.\r\n */\r\nexport interface NameSettings {\r\n /**\r\n * Because multiple artefacts are generated out of the same entity, some name settings are required in order\r\n * to differentiate those artefacts. Out-of-the-box odata2ts provides you with sensible default settings,\r\n * so that you only need to override those settings you want to change.\r\n *\r\n * However, sometimes it makes more sense to start from scratch, so that the defaults don't interfere with\r\n * your own configuration. In this scenario this switch should be enabled to only have default values for\r\n * the required name settings.\r\n */\r\n minimalDefaults?: boolean;\r\n\r\n /**\r\n * Generation options for models, i.e. interfaces representing entity or complex types.\r\n */\r\n models: ModelNamingOptions;\r\n\r\n /**\r\n * Generation options for Query Objects.\r\n *\r\n * By default, prefix = \"Q\"\r\n */\r\n queryObjects: QueryObjectNamingOptions;\r\n\r\n services: ServiceNamingOptions;\r\n}\r\n\r\nexport interface ModelNamingOptions extends NamingStrategyOption, StandardNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of models: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can override the naming options here.\r\n * By default, prefix = \"Editable\"\r\n */\r\n editableModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Id\"\r\n */\r\n idModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * Operation parameter models are generated from function or action signatures.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Params\"\r\n */\r\n operationParamModels: EntityDerivedNamingOptions;\r\n}\r\n\r\nexport interface EntityDerivedNamingOptions extends RequiredNamingOptions {\r\n applyModelNaming?: boolean;\r\n}\r\n\r\nexport interface QueryObjectNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of query objects: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n idFunctions: RequiredNamingOptions;\r\n\r\n operations?: OperationNamingOptions;\r\n}\r\n\r\nexport interface OperationNamingOptions extends StandardNamingOptions {\r\n /**\r\n * Naming options for actions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n action?: StandardNamingOptions;\r\n /**\r\n * Naming options for functions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n function?: StandardNamingOptions;\r\n}\r\n\r\nexport interface NamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface FileNamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface StandardNamingOptions {\r\n /**\r\n * Prefix all names, e.g. \"I\" => \"ITest\"\r\n */\r\n prefix?: string;\r\n /**\r\n * Suffix all names, e.g. \"model\" => \"TestModel\"\r\n */\r\n suffix?: string;\r\n}\r\n\r\nexport interface RequiredNamingOptions extends Required<StandardNamingOptions> {}\r\n\r\n/**\r\n * Naming options for generated service classes.\r\n * These options affect the main service as well as all services generated for each entity, complex and collection type.\r\n *\r\n * There exists one specialty about services: The file names are not configurable.\r\n * File names are determined by the name of their corresponding classes, so that service file name\r\n * and service class name always correspond.\r\n *\r\n * By default, suffix = Service and namingStrategy = PascalCase\r\n */\r\nexport interface ServiceNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * Controls the naming options for the main odata service.\r\n * By default, the base service naming options are applied.\r\n * But since this is the main entry point for users, it can be configured individually here.\r\n *\r\n * By default, applyServiceNaming = true\r\n */\r\n main?: NamingStrategyOption & StandardNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Name of the service responsible for entity collections.\r\n *\r\n * By default, suffix = Collection and applyServiceNaming = true\r\n */\r\n collection: RequiredNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Naming for getter method of another service.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n relatedServiceGetter: NamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Operations are functions and actions of the OData service and are represented as methods\r\n * of the generated service class. This setting controls the naming of the corresponding\r\n * function.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n operations?: NamingStrategyOption & OperationNamingOptions;\r\n\r\n /**\r\n * Naming options for private properties of service classes.\r\n *\r\n * By default, prefix = _\r\n */\r\n privateProps: NamingStrategyOption & RequiredNamingOptions;\r\n}\r\n"]}
@@ -1,223 +1,228 @@
1
- import { TypeConverterConfig } from "@odata2ts/converter-runtime";
2
- import { NameSettings, OverridableNamingOptions } from "./NamingModel";
3
- /**
4
- * Generation mode, by default "all".
5
- */
6
- export declare enum Modes {
7
- models = 0,
8
- qobjects = 1,
9
- service = 2,
10
- all = 3
11
- }
12
- /**
13
- * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.
14
- */
15
- export declare enum EmitModes {
16
- ts = "ts",
17
- js = "js",
18
- dts = "dts",
19
- js_dts = "js_dts"
20
- }
21
- /**
22
- * Config options for CLI.
23
- */
24
- export interface CliOptions {
25
- /**
26
- * The source file to use. Must be an EDMX compliant XML file.
27
- *
28
- * If not specified, at least one service must be configured in config file.
29
- */
30
- source?: string;
31
- /**
32
- * Specifies the output directory for the generated stuff.
33
- *
34
- * If not specified, at least one service must be configured in config file.
35
- */
36
- output?: string;
37
- /**
38
- * Only generates the specified services.
39
- * Relies on an existing config file where these service names are maintained.
40
- */
41
- services?: Array<string>;
42
- /**
43
- * Specifies what to generate:
44
- * - {@code Modes.models} will only generate TS interfaces
45
- * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions
46
- * - {@code Modes.service} will generate one main OData service client and one per each entity
47
- * - {@code Modes.all} the same as {@code Modes.service}
48
- *
49
- * QObjects will also generate models, and generating the service client will also generate models and QObjects.
50
- * Defaults to {@code Modes.all}
51
- */
52
- mode?: Modes;
53
- /**
54
- * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.
55
- * Defaults to {@code EmitModes.js_dts}
56
- */
57
- emitMode?: EmitModes;
58
- /**
59
- * Uses prettier with your local configuration to pretty print TypeScript files.
60
- * Only applies if mode is set to {@code EmitModes.ts}.
61
- */
62
- prettier?: boolean;
63
- /**
64
- * When compiling TypeScript to JS, "tsconfig.json" is used by default to add compilerOptions.
65
- * This option allows to specify an alternative file.
66
- *
67
- * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.
68
- */
69
- tsconfig?: string;
70
- /**
71
- * Verbose debugging information.
72
- */
73
- debug?: boolean;
74
- /**
75
- * Overrides the service name found in the source file.
76
- *
77
- * The service name is the basis for all file names and the name of the main OData client service
78
- * that serves as entry point for the user.
79
- */
80
- serviceName?: string;
81
- /**
82
- * odata2ts will automatically decide if a key prop is managed on the server side.
83
- * If managed, the property will not be editable (create, update, patch).
84
- * The following rule applies:
85
- * If a property is the only key prop of an entity, then the prop is deemed to be managed;
86
- * in ony other case the prop is unmanaged.
87
- */
88
- disableAutoManagedKey?: boolean;
89
- /**
90
- * By default, odata2ts doesn't change param, operation, property or model names.
91
- * The generated models and their properties are named exactly as advertised by the server.
92
- *
93
- * By allowing odata2ts to change these names, certain predefined formatting strategies are used:
94
- * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.
95
- *
96
- * The naming configuration allows to control this and other naming related settings.
97
- * Note: Even if renaming is disabled, model prefixing / suffing still applies.
98
- */
99
- allowRenaming?: boolean;
100
- }
101
- /**
102
- * Available options for the actual generation run.
103
- * Every property is required, except the overriding service name.
104
- */
105
- export interface RunOptions extends Required<Omit<ServiceGenerationOptions, "serviceName">> {
106
- serviceName?: string;
107
- naming: NameSettings;
108
- }
109
- /**
110
- * Available options for configuration files, i.e. odata2ts.config.ts.
111
- */
112
- export interface ConfigFileOptions extends Omit<CliOptions, "source" | "output" | "services"> {
113
- services?: {
114
- [serviceName: string]: ServiceGenerationOptions;
115
- };
116
- /**
117
- * Specify which converters to use by their package name, e.g. "@odata2ts/converter-v2-to-v4".
118
- * Each converter knows which data type to map.
119
- *
120
- * To only use specific converters, the object syntax must be used, where supported converters
121
- * must be listed by their ids.
122
- */
123
- converters?: Array<string | TypeConverterConfig>;
124
- /**
125
- * For each model an editable version is generated which represents the model definition for
126
- * create, update and patch actions.
127
- *
128
- * You can skip the generation altogether, not generating editable model variants,
129
- * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.
130
- */
131
- skipEditableModels?: boolean;
132
- /**
133
- * ID models are generated from entity id parameters.
134
- * The generation for one entity entails one model interface representing the id parameters and
135
- * one QId function which allows to format the parameters for URL usage and to parse parameters
136
- * from a URL string.
137
- *
138
- * You can skip the generation altogether, not generating models and QId objects, if the
139
- * generation mode is {@code Mode.model} or {@code Mode.qobject}.
140
- */
141
- skipIdModels?: boolean;
142
- /**
143
- * Operations are functions and actions of the OData service.
144
- * The generation for one operation entails one parameter model interface
145
- * and one QFunction / QAction class.
146
- *
147
- * You can skip the generation altogether, neither generating model nor query object,
148
- * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.
149
- */
150
- skipOperations?: boolean;
151
- /**
152
- * The naming options regarding the generated artefacts.
153
- */
154
- naming?: OverridableNamingOptions;
155
- /**
156
- * Some OData V2 services generate an extra wrapping for entity collection attributes:
157
- * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities
158
- * an object with the property "results" is wrapped around the entity collection.
159
- *
160
- * If you're using the odata client then there's a build-in workaround in place which transforms
161
- * the results to remove this extra mapping. However, if you're only interested in the types, then
162
- * the generated models will not match that extra wrapping.
163
- *
164
- * Setting this configuration option to <code>true</code> (default: false) will add this extra
165
- * wrapping to the generated models. But this option is only valid if the generation mode is set
166
- * to <code>models</code>; it is ignored otherwise.
167
- */
168
- v2ModelsWithExtraResultsWrapping?: boolean;
169
- }
170
- /**
171
- * Custom generation options which are dependent on a specific odata service.
172
- */
173
- export interface ServiceGenerationOptions extends Required<Pick<CliOptions, "source" | "output">>, Omit<ConfigFileOptions, "services"> {
174
- /**
175
- * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.
176
- */
177
- entitiesByName?: Array<EntityGenerationOptions>;
178
- /**
179
- * Configure generation process for individual properties based on their name.
180
- */
181
- propertiesByName?: Array<PropertyGenerationOptions>;
182
- }
183
- /**
184
- * Configuration options for EntityTypes and ComplexTypes.
185
- * This config applies if the name matches the name of an EntityType or ComplexType as it is specified
186
- * in the metadata (e.g. in EDMX <EntityType name="Test" ...)
187
- */
188
- export interface EntityGenerationOptions {
189
- /**
190
- * Name of the EntityType or ComplexType, e.g. "Person".
191
- * Must match exactly or can be a regular expression.
192
- */
193
- name: string | RegExp;
194
- /**
195
- * Use a different name.
196
- * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).
197
- */
198
- mappedName?: string;
199
- /**
200
- * Overwrite the key specification by naming the props by their EDMX name.
201
- */
202
- keys?: Array<string>;
203
- }
204
- /**
205
- * All configuration options for properties of models.
206
- */
207
- export interface PropertyGenerationOptions {
208
- /**
209
- * Name of the property to match.
210
- * Must match exactly or can be a regular expression.
211
- */
212
- name: string | RegExp;
213
- /**
214
- * Use a different name.
215
- * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).
216
- */
217
- mappedName?: string;
218
- /**
219
- * Managed attributes - i.e. managed by the server - cannot be created or updated.
220
- * Hence, they are left out of the editable model versions.
221
- */
222
- managed?: boolean;
223
- }
1
+ import { TypeConverterConfig } from "@odata2ts/converter-runtime";
2
+ import { NameSettings, OverridableNamingOptions } from "./NamingModel";
3
+ /**
4
+ * Generation mode, by default "all".
5
+ */
6
+ export declare enum Modes {
7
+ models = 0,
8
+ qobjects = 1,
9
+ service = 2,
10
+ all = 3
11
+ }
12
+ /**
13
+ * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.
14
+ */
15
+ export declare enum EmitModes {
16
+ ts = "ts",
17
+ js = "js",
18
+ dts = "dts",
19
+ js_dts = "js_dts"
20
+ }
21
+ /**
22
+ * Config options for CLI.
23
+ */
24
+ export interface CliOptions {
25
+ /**
26
+ * The source file to use. Must be an EDMX compliant XML file.
27
+ *
28
+ * If not specified, at least one service must be configured in config file.
29
+ */
30
+ source?: string;
31
+ /**
32
+ * Specifies the output directory for the generated stuff.
33
+ *
34
+ * If not specified, at least one service must be configured in config file.
35
+ */
36
+ output?: string;
37
+ /**
38
+ * Only generates the specified services.
39
+ * Relies on an existing config file where these service names are maintained.
40
+ */
41
+ services?: Array<string>;
42
+ /**
43
+ * Specifies what to generate:
44
+ * - {@code Modes.models} will only generate TS interfaces
45
+ * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions
46
+ * - {@code Modes.service} will generate one main OData service client and one per each entity
47
+ * - {@code Modes.all} the same as {@code Modes.service}
48
+ *
49
+ * QObjects will also generate models, and generating the service client will also generate models and QObjects.
50
+ * Defaults to {@code Modes.all}
51
+ */
52
+ mode?: Modes;
53
+ /**
54
+ * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.
55
+ * Defaults to {@code EmitModes.js_dts}
56
+ */
57
+ emitMode?: EmitModes;
58
+ /**
59
+ * Uses prettier with your local configuration to pretty print TypeScript files.
60
+ * Only applies if mode is set to {@code EmitModes.ts}.
61
+ */
62
+ prettier?: boolean;
63
+ /**
64
+ * When compiling TypeScript to JS, "tsconfig.json" is used by default to add compilerOptions.
65
+ * This option allows to specify an alternative file.
66
+ *
67
+ * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.
68
+ */
69
+ tsconfig?: string;
70
+ /**
71
+ * Verbose debugging information.
72
+ */
73
+ debug?: boolean;
74
+ /**
75
+ * Overrides the service name found in the source file.
76
+ *
77
+ * The service name is the basis for all file names and the name of the main OData client service
78
+ * that serves as entry point for the user.
79
+ */
80
+ serviceName?: string;
81
+ /**
82
+ * odata2ts will automatically decide if a key prop is managed on the server side.
83
+ * If managed, the property will not be editable (create, update, patch).
84
+ * The following rule applies:
85
+ * If a property is the only key prop of an entity, then the prop is deemed to be managed;
86
+ * in ony other case the prop is unmanaged.
87
+ */
88
+ disableAutoManagedKey?: boolean;
89
+ /**
90
+ * By default, odata2ts doesn't change param, operation, property or model names.
91
+ * The generated models and their properties are named exactly as advertised by the server.
92
+ *
93
+ * By allowing odata2ts to change these names, certain predefined formatting strategies are used:
94
+ * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.
95
+ *
96
+ * The naming configuration allows to control this and other naming related settings.
97
+ * Note: Even if renaming is disabled, model prefixing / suffing still applies.
98
+ */
99
+ allowRenaming?: boolean;
100
+ }
101
+ /**
102
+ * Available options for the actual generation run.
103
+ * Every property is required, except the overriding service name.
104
+ */
105
+ export interface RunOptions extends Required<Omit<ServiceGenerationOptions, "serviceName">> {
106
+ serviceName?: string;
107
+ naming: NameSettings;
108
+ }
109
+ /**
110
+ * Available options for configuration files, i.e. odata2ts.config.ts.
111
+ */
112
+ export interface ConfigFileOptions extends Omit<CliOptions, "source" | "output" | "services"> {
113
+ services?: {
114
+ [serviceName: string]: ServiceGenerationOptions;
115
+ };
116
+ /**
117
+ * Specify which converters to use by their package name, e.g. "@odata2ts/converter-v2-to-v4".
118
+ * Each converter knows which data type to map.
119
+ *
120
+ * To only use specific converters, the object syntax must be used, where supported converters
121
+ * must be listed by their ids.
122
+ */
123
+ converters?: Array<string | TypeConverterConfig>;
124
+ /**
125
+ * For each model an editable version is generated which represents the model definition for
126
+ * create, update and patch actions.
127
+ *
128
+ * You can skip the generation altogether, not generating editable model variants,
129
+ * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.
130
+ */
131
+ skipEditableModels?: boolean;
132
+ /**
133
+ * ID models are generated from entity id parameters.
134
+ * The generation for one entity entails one model interface representing the id parameters and
135
+ * one QId function which allows to format the parameters for URL usage and to parse parameters
136
+ * from a URL string.
137
+ *
138
+ * You can skip the generation altogether, not generating models and QId objects, if the
139
+ * generation mode is {@code Mode.model} or {@code Mode.qobject}.
140
+ */
141
+ skipIdModels?: boolean;
142
+ /**
143
+ * Operations are functions and actions of the OData service.
144
+ * The generation for one operation entails one parameter model interface
145
+ * and one QFunction / QAction class.
146
+ *
147
+ * You can skip the generation altogether, neither generating model nor query object,
148
+ * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.
149
+ */
150
+ skipOperations?: boolean;
151
+ /**
152
+ * Model properties have explaining comments by default.
153
+ * With this option you can turn that off.
154
+ */
155
+ skipComments?: boolean;
156
+ /**
157
+ * The naming options regarding the generated artefacts.
158
+ */
159
+ naming?: OverridableNamingOptions;
160
+ /**
161
+ * Some OData V2 services generate an extra wrapping for entity collection attributes:
162
+ * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities
163
+ * an object with the property "results" is wrapped around the entity collection.
164
+ *
165
+ * If you're using the odata client then there's a build-in workaround in place which transforms
166
+ * the results to remove this extra mapping. However, if you're only interested in the types, then
167
+ * the generated models will not match that extra wrapping.
168
+ *
169
+ * Setting this configuration option to <code>true</code> (default: false) will add this extra
170
+ * wrapping to the generated models. But this option is only valid if the generation mode is set
171
+ * to <code>models</code>; it is ignored otherwise.
172
+ */
173
+ v2ModelsWithExtraResultsWrapping?: boolean;
174
+ }
175
+ /**
176
+ * Custom generation options which are dependent on a specific odata service.
177
+ */
178
+ export interface ServiceGenerationOptions extends Required<Pick<CliOptions, "source" | "output">>, Omit<ConfigFileOptions, "services"> {
179
+ /**
180
+ * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.
181
+ */
182
+ entitiesByName?: Array<EntityGenerationOptions>;
183
+ /**
184
+ * Configure generation process for individual properties based on their name.
185
+ */
186
+ propertiesByName?: Array<PropertyGenerationOptions>;
187
+ }
188
+ /**
189
+ * Configuration options for EntityTypes and ComplexTypes.
190
+ * This config applies if the name matches the name of an EntityType or ComplexType as it is specified
191
+ * in the metadata (e.g. in EDMX <EntityType name="Test" ...)
192
+ */
193
+ export interface EntityGenerationOptions {
194
+ /**
195
+ * Name of the EntityType or ComplexType, e.g. "Person".
196
+ * Must match exactly or can be a regular expression.
197
+ */
198
+ name: string | RegExp;
199
+ /**
200
+ * Use a different name.
201
+ * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).
202
+ */
203
+ mappedName?: string;
204
+ /**
205
+ * Overwrite the key specification by naming the props by their EDMX name.
206
+ */
207
+ keys?: Array<string>;
208
+ }
209
+ /**
210
+ * All configuration options for properties of models.
211
+ */
212
+ export interface PropertyGenerationOptions {
213
+ /**
214
+ * Name of the property to match.
215
+ * Must match exactly or can be a regular expression.
216
+ */
217
+ name: string | RegExp;
218
+ /**
219
+ * Use a different name.
220
+ * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).
221
+ */
222
+ mappedName?: string;
223
+ /**
224
+ * Managed attributes - i.e. managed by the server - cannot be created or updated.
225
+ * Hence, they are left out of the editable model versions.
226
+ */
227
+ managed?: boolean;
228
+ }
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmitModes = exports.Modes = void 0;
4
- /**
5
- * Generation mode, by default "all".
6
- */
7
- var Modes;
8
- (function (Modes) {
9
- Modes[Modes["models"] = 0] = "models";
10
- Modes[Modes["qobjects"] = 1] = "qobjects";
11
- Modes[Modes["service"] = 2] = "service";
12
- Modes[Modes["all"] = 3] = "all";
13
- })(Modes = exports.Modes || (exports.Modes = {}));
14
- /**
15
- * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.
16
- */
17
- var EmitModes;
18
- (function (EmitModes) {
19
- EmitModes["ts"] = "ts";
20
- EmitModes["js"] = "js";
21
- EmitModes["dts"] = "dts";
22
- EmitModes["js_dts"] = "js_dts";
23
- })(EmitModes = exports.EmitModes || (exports.EmitModes = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmitModes = exports.Modes = void 0;
4
+ /**
5
+ * Generation mode, by default "all".
6
+ */
7
+ var Modes;
8
+ (function (Modes) {
9
+ Modes[Modes["models"] = 0] = "models";
10
+ Modes[Modes["qobjects"] = 1] = "qobjects";
11
+ Modes[Modes["service"] = 2] = "service";
12
+ Modes[Modes["all"] = 3] = "all";
13
+ })(Modes || (exports.Modes = Modes = {}));
14
+ /**
15
+ * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.
16
+ */
17
+ var EmitModes;
18
+ (function (EmitModes) {
19
+ EmitModes["ts"] = "ts";
20
+ EmitModes["js"] = "js";
21
+ EmitModes["dts"] = "dts";
22
+ EmitModes["js_dts"] = "js_dts";
23
+ })(EmitModes || (exports.EmitModes = EmitModes = {}));
24
24
  //# sourceMappingURL=OptionModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,GAAL,aAAK,KAAL,aAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The source file to use. Must be an EDMX compliant XML file.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions extends Required<Omit<ServiceGenerationOptions, \"serviceName\">> {\r\n serviceName?: string;\r\n naming: NameSettings;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"source\" | \"output\" | \"services\"> {\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n}\r\n\r\n/**\r\n * Custom generation options which are dependent on a specific odata service.\r\n */\r\nexport interface ServiceGenerationOptions\r\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\r\n Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.\r\n */\r\n entitiesByName?: Array<EntityGenerationOptions>;\r\n /**\r\n * Configure generation process for individual properties based on their name.\r\n */\r\n propertiesByName?: Array<PropertyGenerationOptions>;\r\n}\r\n\r\n/**\r\n * Configuration options for EntityTypes and ComplexTypes.\r\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\r\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\r\n */\r\nexport interface EntityGenerationOptions {\r\n /**\r\n * Name of the EntityType or ComplexType, e.g. \"Person\".\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Overwrite the key specification by naming the props by their EDMX name.\r\n */\r\n keys?: Array<string>;\r\n /**\r\n * Configuration of individual properties.\r\n */\r\n // properties?: Array<PropertyGenerationOptions>;\r\n\r\n // converter: string | Array<string>\r\n\r\n /**\r\n * Whether the generated service should allow for querying this model.\r\n * True by default.\r\n */\r\n // queryable?: boolean;\r\n /**\r\n * Whether the generated service should allow for creating new models (POST).\r\n * True by default.\r\n */\r\n // creatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for updates (PUT).\r\n * True by default.\r\n */\r\n // updatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for partial updates (PATCH).\r\n * True by default.\r\n */\r\n // patchable?: boolean;\r\n /**\r\n * Whether the generated service should allow for deletion.\r\n * True by default.\r\n */\r\n // deletable?: boolean;\r\n}\r\n\r\n/**\r\n * All configuration options for properties of models.\r\n */\r\nexport interface PropertyGenerationOptions {\r\n /**\r\n * Name of the property to match.\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\r\n * Hence, they are left out of the editable model versions.\r\n */\r\n managed?: boolean;\r\n\r\n /**\r\n * TODO\r\n *\r\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\r\n * as well it's i\r\n * and their ids, e.g. \"timeToDurationConverter\".\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n // converters?: Array<Required<TypeConverterConfig>>;\r\n}\r\n"]}
1
+ {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The source file to use. Must be an EDMX compliant XML file.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions extends Required<Omit<ServiceGenerationOptions, \"serviceName\">> {\r\n serviceName?: string;\r\n naming: NameSettings;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"source\" | \"output\" | \"services\"> {\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n /**\r\n * Model properties have explaining comments by default.\r\n * With this option you can turn that off.\r\n */\r\n skipComments?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n}\r\n\r\n/**\r\n * Custom generation options which are dependent on a specific odata service.\r\n */\r\nexport interface ServiceGenerationOptions\r\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\r\n Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.\r\n */\r\n entitiesByName?: Array<EntityGenerationOptions>;\r\n /**\r\n * Configure generation process for individual properties based on their name.\r\n */\r\n propertiesByName?: Array<PropertyGenerationOptions>;\r\n}\r\n\r\n/**\r\n * Configuration options for EntityTypes and ComplexTypes.\r\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\r\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\r\n */\r\nexport interface EntityGenerationOptions {\r\n /**\r\n * Name of the EntityType or ComplexType, e.g. \"Person\".\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Overwrite the key specification by naming the props by their EDMX name.\r\n */\r\n keys?: Array<string>;\r\n /**\r\n * Configuration of individual properties.\r\n */\r\n // properties?: Array<PropertyGenerationOptions>;\r\n\r\n // converter: string | Array<string>\r\n\r\n /**\r\n * Whether the generated service should allow for querying this model.\r\n * True by default.\r\n */\r\n // queryable?: boolean;\r\n /**\r\n * Whether the generated service should allow for creating new models (POST).\r\n * True by default.\r\n */\r\n // creatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for updates (PUT).\r\n * True by default.\r\n */\r\n // updatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for partial updates (PATCH).\r\n * True by default.\r\n */\r\n // patchable?: boolean;\r\n /**\r\n * Whether the generated service should allow for deletion.\r\n * True by default.\r\n */\r\n // deletable?: boolean;\r\n}\r\n\r\n/**\r\n * All configuration options for properties of models.\r\n */\r\nexport interface PropertyGenerationOptions {\r\n /**\r\n * Name of the property to match.\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\r\n * Hence, they are left out of the editable model versions.\r\n */\r\n managed?: boolean;\r\n\r\n /**\r\n * TODO\r\n *\r\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\r\n * as well it's i\r\n * and their ids, e.g. \"timeToDurationConverter\".\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n // converters?: Array<Required<TypeConverterConfig>>;\r\n}\r\n"]}
package/lib/app.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ODataEdmxModelBase } from "./data-model/edmx/ODataEdmxModelBase";
2
- import { RunOptions } from "./OptionModel";
3
- /**
4
- *
5
- * @param metadataJson metadata of a given OData service already parsed as JSON
6
- * @param options further options
7
- */
8
- export declare function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void>;
1
+ import { ODataEdmxModelBase } from "./data-model/edmx/ODataEdmxModelBase";
2
+ import { RunOptions } from "./OptionModel";
3
+ /**
4
+ *
5
+ * @param metadataJson metadata of a given OData service already parsed as JSON
6
+ * @param options further options
7
+ */
8
+ export declare function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void>;