@ama-sdk/schematics 9.0.0-rc.9 → 9.0.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/README.md +16 -0
- package/package.json +7 -7
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.d.ts.map +1 -1
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.js +2 -1
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.js.map +1 -1
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts +10 -1
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts.map +1 -1
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.js +2 -1
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.js.map +1 -1
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen-tests.jar +0 -0
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen.jar +0 -0
- package/schematics/typescript/core/index.d.ts.map +1 -1
- package/schematics/typescript/core/index.js +2 -1
- package/schematics/typescript/core/index.js.map +1 -1
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator-tests.jar +0 -0
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator.jar +0 -0
- package/schematics/typescript/core/schema.d.ts +9 -0
- package/schematics/typescript/core/schema.d.ts.map +1 -1
- package/schematics/typescript/core/schema.json +5 -0
- package/schematics/typescript/shell/index.d.ts.map +1 -1
- package/schematics/typescript/shell/index.js +17 -14
- package/schematics/typescript/shell/index.js.map +1 -1
- package/schematics/typescript/shell/schema.json +1 -1
- package/schematics/typescript/shell/templates/base/.gitignore.template +2 -6
- package/schematics/typescript/shell/templates/base/.husky/commit-msg +1 -1
- package/schematics/typescript/shell/templates/base/.husky/pre-commit +1 -1
- package/schematics/typescript/shell/templates/base/.renovaterc.json +3 -3
- package/schematics/typescript/shell/templates/base/.vscode/settings.json +3 -1
- package/schematics/typescript/shell/templates/base/package.json.template +5 -6
- package/schematics/typescript/shell/templates/base/readme.md +88 -3
- package/schematics/typescript/shell/templates/base/src/api/fixtures.jest.ts +2 -0
- package/schematics/typescript/shell/templates/base/src/api/index.ts +1 -0
- package/schematics/typescript/shell/templates/base/src/models/base/enums.ts +2 -0
- package/schematics/typescript/shell/templates/base/src/models/base/index.ts +1 -0
- package/schematics/typescript/shell/templates/base/src/models/base/patterns.ts +2 -0
- package/schematics/typescript/shell/templates/base/src/spec/api-mock.ts +2 -0
- package/schematics/typescript/shell/templates/base/src/spec/operation-adapter.ts +0 -0
package/README.md
CHANGED
|
@@ -75,3 +75,19 @@ yarn schematics @ama-sdk/schematics:java-client-core --spec-path ./swagger-spec.
|
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
[Default swagger config](./schematics/java/client-core/swagger-codegen-java-client/config/swagger-codegen-config.json) will be used if `--swagger-config-path` is not provided.
|
|
78
|
+
|
|
79
|
+
### Debug the typescript generator
|
|
80
|
+
The OpenApi generator extracts an enhanced JSON data model from the specification YAML and uses this data model to feed the templates to generate the code.
|
|
81
|
+
If there is an issue with the files generated with the spec provided, the generator provides debugging features that log this data model.
|
|
82
|
+
|
|
83
|
+
You can use global property options to pass one or both of the following options:
|
|
84
|
+
* debugModel - logs the full JSON structure used to generate models
|
|
85
|
+
* debugOperations - logs the full JSON structure used to generate operations
|
|
86
|
+
|
|
87
|
+
Example:
|
|
88
|
+
```shell
|
|
89
|
+
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property debugModels,debugOperations
|
|
90
|
+
```
|
|
91
|
+
You can also use npx instead of yarn in the command.
|
|
92
|
+
|
|
93
|
+
You can correlate this data model with the [templates](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch) used by the generator.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/schematics",
|
|
3
|
-
"version": "9.0.0
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Swagger specification SDK Generator by schematics",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"nx": "nx",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@ama-sdk/core": "^9.0.0
|
|
44
|
+
"@ama-sdk/core": "^9.0.0",
|
|
45
45
|
"@angular-devkit/core": "~16.0.5",
|
|
46
46
|
"@angular-devkit/schematics": "~16.0.5",
|
|
47
47
|
"@angular-devkit/schematics-cli": "~16.0.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@angular-devkit/core": "~16.0.5",
|
|
54
54
|
"@angular-devkit/schematics": "~16.0.5",
|
|
55
|
-
"@o3r/dev-tools": "^9.0.0
|
|
55
|
+
"@o3r/dev-tools": "^9.0.0",
|
|
56
56
|
"js-yaml": "^4.1.0",
|
|
57
57
|
"minimatch": "^9.0.0",
|
|
58
58
|
"rxjs": "^7.8.1",
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"tslib": "^2.5.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@ama-sdk/core": "^9.0.0
|
|
64
|
+
"@ama-sdk/core": "^9.0.0",
|
|
65
65
|
"@angular-devkit/schematics-cli": "~16.0.5",
|
|
66
66
|
"@angular-eslint/eslint-plugin": "~16.0.3",
|
|
67
67
|
"@angular/cli": "~16.0.5",
|
|
68
68
|
"@nx/jest": "~16.5.0",
|
|
69
|
-
"@o3r/build-helpers": "^9.0.0
|
|
70
|
-
"@o3r/eslint-plugin": "^9.0.0
|
|
71
|
-
"@o3r/schematics": "^9.0.0
|
|
69
|
+
"@o3r/build-helpers": "^9.0.0",
|
|
70
|
+
"@o3r/eslint-plugin": "^9.0.0",
|
|
71
|
+
"@o3r/schematics": "^9.0.0",
|
|
72
72
|
"@openapitools/openapi-generator-cli": "~2.6.0",
|
|
73
73
|
"@schematics/angular": "~16.0.5",
|
|
74
74
|
"@types/jest": "~29.5.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-cli.generator.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAoC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAI5F;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IAEvE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,CAAC;IAClD,SAAS,KAAK,oBAAoB,IAAI,KAAK,GAAG,MAAM,CAEnD;IAED,kBAAkB;IAClB,SAAS,CAAC,QAAQ,CAAC,aAAa,6BAA6B;gBAEjD,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAA;KAAE;IAK9D;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAelC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"open-api-cli.generator.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAoC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAI5F;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IAEvE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,CAAC;IAClD,SAAS,KAAK,oBAAoB,IAAI,KAAK,GAAG,MAAM,CAEnD;IAED,kBAAkB;IAClB,SAAS,CAAC,QAAQ,CAAC,aAAa,6BAA6B;gBAEjD,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAA;KAAE;IAK9D;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAelC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAuBpB,kBAAkB;IAClB,SAAS,CAAC,iBAAiB,0BAA2C;IAEtE,kBAAkB;IAClB,SAAS,CAAC,uBAAuB,oBAAoB;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,yBAI5C,iBAAiB,wBAclD;CACH"}
|
|
@@ -73,7 +73,8 @@ class OpenApiCliGenerator extends code_generator_1.CodeGenerator {
|
|
|
73
73
|
'-g', generatorOptions.generatorName,
|
|
74
74
|
'-i', generatorOptions.specPath,
|
|
75
75
|
...generatorOptions.specConfigPath ? ['-c', generatorOptions.specConfigPath] : [],
|
|
76
|
-
'-o', generatorOptions.outputPath
|
|
76
|
+
'-o', generatorOptions.outputPath,
|
|
77
|
+
...generatorOptions.globalProperty ? ['--global-property', generatorOptions.globalProperty] : []
|
|
77
78
|
];
|
|
78
79
|
return new Promise((resolve, reject) => {
|
|
79
80
|
(0, node_child_process_1.spawn)(this.packageManagerRunner, args, spawnOptions)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-cli.generator.js","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts"],"names":[],"mappings":";;;AAAA,sDAAgD;AAChD,2DAAuD;AACvD,iEAA4F;AAC5F,kCAAkC;AAClC,6DAAmE;AAEnE;;GAEG;AACH,MAAa,mBAAoB,SAAQ,8BAAgC;IAGvE,IAAc,oBAAoB;QAChC,OAAO,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IACxD,CAAC;IAKD,YAAY,OAAkD;QAC5D,KAAK,EAAE,CAAC;QAJV,kBAAkB;QACC,kBAAa,GAAG,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"open-api-cli.generator.js","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts"],"names":[],"mappings":";;;AAAA,sDAAgD;AAChD,2DAAuD;AACvD,iEAA4F;AAC5F,kCAAkC;AAClC,6DAAmE;AAEnE;;GAEG;AACH,MAAa,mBAAoB,SAAQ,8BAAgC;IAGvE,IAAc,oBAAoB;QAChC,OAAO,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IACxD,CAAC;IAKD,YAAY,OAAkD;QAC5D,KAAK,EAAE,CAAC;QAJV,kBAAkB;QACC,kBAAa,GAAG,yBAAyB,CAAC;QAyD7D,kBAAkB;QACR,sBAAiB,GAAG,GAAG,EAAE,CAAC,wDAAiC,CAAC;QAEtE,kBAAkB;QACR,4BAAuB,GAAG,CAAC,iBAA6C,EAAE,EAAE,EAAE;YACtF,MAAM,aAAa,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;gBAClD,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;gBAC5I,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,OAAO,KAAK,EAAE,gBAAoC,EAAE,EAAE;gBACpD,IAAI,CAAC,gBAAgB,EAAE;oBACrB,OAAO,OAAO,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC;iBACpE;gBACD,MAAM,YAAY,GAAiB;oBACjC,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,IAAI;oBACX,GAAG,EAAE,aAAa;iBACnB,CAAC;gBACF,IAAI,gBAAg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C,CAAC,EAAE;YACjF,IAAI,EAAE,gBAAgB,CAAC,UAAU;YACjC,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE;SACjG,CAAC;QACF,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAA,0BAAK,EAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,EAAE,YAAY,CAAC;iBACjD,EAAE,CAAC,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC5B,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,OAAO,EAAE,CAAC;iBACX;qBAAM;oBACL,MAAM,CAAC,IAAI,KAAK,CAAC,oEAAoE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;iBAC1G;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CAyBF;AAxFD,kDAwFC"}
|
|
@@ -10,7 +10,7 @@ export type OpenApiCliOptions = CodegenTaskOptions & {
|
|
|
10
10
|
* - the one defined in your openapitools.json
|
|
11
11
|
* - the latest version if openapitools.json is missing
|
|
12
12
|
*
|
|
13
|
-
* @default
|
|
13
|
+
* @default ''
|
|
14
14
|
*/
|
|
15
15
|
generatorVersion: string;
|
|
16
16
|
/**
|
|
@@ -25,6 +25,15 @@ export type OpenApiCliOptions = CodegenTaskOptions & {
|
|
|
25
25
|
* @default path to our own custom typescript generator
|
|
26
26
|
*/
|
|
27
27
|
generatorCustomPath: string;
|
|
28
|
+
/**
|
|
29
|
+
* Comma separated string of options to give to the openapi-generator-cli
|
|
30
|
+
*
|
|
31
|
+
* @example debugModels to log the full json structure used to generate models
|
|
32
|
+
* @example debugOperations to log the full json structure used to generate operations
|
|
33
|
+
*
|
|
34
|
+
* @default ''
|
|
35
|
+
*/
|
|
36
|
+
globalProperty: string;
|
|
28
37
|
};
|
|
29
38
|
/**
|
|
30
39
|
* Default options to run our custom typescript generator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-cli.options.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACnD;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"open-api-cli.options.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACnD;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,iBAQ/C,CAAC"}
|
|
@@ -11,6 +11,7 @@ exports.defaultTypescriptGeneratorOptions = {
|
|
|
11
11
|
generatorCustomPath: path.join(__dirname, '..', '..', 'typescript', 'core', 'openapi-codegen-typescript', 'target', 'typescriptFetch-openapi-generator.jar'),
|
|
12
12
|
specPath: 'swagger-spec.yaml',
|
|
13
13
|
outputPath: '.',
|
|
14
|
-
specConfigPath: ''
|
|
14
|
+
specConfigPath: '',
|
|
15
|
+
globalProperty: ''
|
|
15
16
|
};
|
|
16
17
|
//# sourceMappingURL=open-api-cli.options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-cli.options.js","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts"],"names":[],"mappings":";;;AACA,kCAAkC;
|
|
1
|
+
{"version":3,"file":"open-api-cli.options.js","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts"],"names":[],"mappings":";;;AACA,kCAAkC;AAuClC;;GAEG;AACU,QAAA,iCAAiC,GAAsB;IAClE,gBAAgB,EAAE,EAAE;IACpB,aAAa,EAAE,iBAAiB;IAChC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,4BAA4B,EAAE,QAAQ,EAAE,uCAAuC,CAAC;IAC5J,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,EAAE;CACnB,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,UAAU,CAAC;AAgBvE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,2CAA2C,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,UAAU,CAAC;AAgBvE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,2CAA2C,GAAG,IAAI,CAgHlG"}
|
|
@@ -25,6 +25,7 @@ const getPathObjectTemplate = (pathObj) => {
|
|
|
25
25
|
function ngGenerateTypescriptSDK(options) {
|
|
26
26
|
const specPath = path.resolve(process.cwd(), options.specPath);
|
|
27
27
|
const targetPath = options.directory || '/';
|
|
28
|
+
const globalProperty = options.globalProperty;
|
|
28
29
|
const generateOperationFinder = async () => {
|
|
29
30
|
const swayOptions = {
|
|
30
31
|
definition: path.resolve(options.specPath)
|
|
@@ -100,7 +101,7 @@ function ngGenerateTypescriptSDK(options) {
|
|
|
100
101
|
return () => tree;
|
|
101
102
|
};
|
|
102
103
|
const runGeneratorRule = (tree, context) => {
|
|
103
|
-
const generatorOptions = { specPath };
|
|
104
|
+
const generatorOptions = { specPath, globalProperty };
|
|
104
105
|
const packageJsonFile = JSON.parse(((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', '..', 'package.json'))).toString());
|
|
105
106
|
const packageOpenApiSupportedVersion = packageJsonFile.openApiSupportedVersion?.replace(/\^|~/, '');
|
|
106
107
|
let openApiVersion = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":";;;AAAA,2DAYoC;AAEpC,qCAAiD;AACjD,kCAAkC;AAClC,iCAAiC;AACjC,6BAA6B;AAG7B,uDAAmD;AAEnD,+GAAyG;AAEzG,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,eAAe,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC;AAEnI,MAAM,qBAAqB,GAAG,CAAC,OAAmB,EAAE,EAAE;IACpD,OAAO;QAEN,MAAM,CAAC,IAAI,CAAC,OAAO,CAA0B,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC9D,MAAM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gB,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;SAC1D;QACD,OAAO,GAAG,EAAE,CAAC,CAAC,IAAI,4CAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,gBAAgB,EAAE,EAAC,aAAa,EAAE,OAAO,CAAC,SAAS,IAAI,SAAS,EAAC,CAAC,CAAC;IAC9I,CAAC,CAAC;IAEF,OAAO,IAAA,kBAAK,EAAC;QACX,kBAAkB;QAClB,cAAc;QACd,UAAU;QACV,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AAhHD,0DAgHC"}
|
|
Binary file
|
|
Binary file
|
|
@@ -8,5 +8,14 @@ export interface NgGenerateTypescriptSDKCoreSchematicsSchema extends JsonObject
|
|
|
8
8
|
packageManager: 'npm' | 'yarn' | '';
|
|
9
9
|
/** Path to the spec generation configuration */
|
|
10
10
|
specConfigPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* Comma separated string of options to give to the openapi-generator-cli
|
|
13
|
+
*
|
|
14
|
+
* @example debugModels to log the full json structure used to generate models
|
|
15
|
+
* @example debugOperations to log the full json structure used to generate operations
|
|
16
|
+
*
|
|
17
|
+
* @default ''
|
|
18
|
+
*/
|
|
19
|
+
globalProperty: string;
|
|
11
20
|
}
|
|
12
21
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,2CAA4C,SAAQ,UAAU;IAC7E,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,2CAA4C,SAAQ,UAAU;IAC7E,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
],
|
|
33
33
|
"description": "Package manager to be used in the generated SDK",
|
|
34
34
|
"default": ""
|
|
35
|
+
},
|
|
36
|
+
"globalProperty": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Comma separated string of options to give to the openapi-generator-cli",
|
|
39
|
+
"default": ""
|
|
35
40
|
}
|
|
36
41
|
},
|
|
37
42
|
"additionalProperties": true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/shell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAIL,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/shell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAIL,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAC,4CAA4C,EAAC,MAAM,UAAU,CAAC;AAE3E;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,4CAA4C,GAAG,IAAI,CAoFnG"}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ngGenerateTypescriptSDK = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const js_yaml_1 = require("js-yaml");
|
|
6
|
-
const read_package_1 = require("../../helpers/read-package");
|
|
7
6
|
const node_path_1 = require("node:path");
|
|
8
7
|
const node_install_1 = require("../../helpers/node-install");
|
|
8
|
+
const read_package_1 = require("../../helpers/read-package");
|
|
9
9
|
/**
|
|
10
10
|
* @param options
|
|
11
11
|
*/
|
|
@@ -47,6 +47,7 @@ function ngGenerateTypescriptSDK(options) {
|
|
|
47
47
|
projectName: options.name,
|
|
48
48
|
projectPackageName: options.package,
|
|
49
49
|
projectDescription: options.description,
|
|
50
|
+
packageManager: (0, node_install_1.getPackageManagerName)(options.packageManager),
|
|
50
51
|
projectHosting: options.hosting,
|
|
51
52
|
sdkCoreVersion: amaSdkSchematicsPackageJson.version,
|
|
52
53
|
angularVersion: amaSdkSchematicsPackageJson.dependencies['@angular-devkit/core'],
|
|
@@ -56,20 +57,22 @@ function ngGenerateTypescriptSDK(options) {
|
|
|
56
57
|
engineVersions,
|
|
57
58
|
empty: ''
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
if (properties.packageManager === 'yarn') {
|
|
61
|
+
const yarnrcPath = '.yarnrc.yml';
|
|
62
|
+
const yarnrc = ((0, js_yaml_1.load)(tree.exists(yarnrcPath) ? tree.readText(yarnrcPath) : '') || {});
|
|
63
|
+
yarnrc.nodeLinker ||= 'pnp';
|
|
64
|
+
yarnrc.packageExtensions ||= {};
|
|
65
|
+
yarnrc.packageExtensions['@ama-sdk/schematics@*'] = {
|
|
66
|
+
dependencies: {
|
|
67
|
+
'isomorphic-fetch': '~2.2.1'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (tree.exists(yarnrcPath)) {
|
|
71
|
+
tree.overwrite(yarnrcPath, (0, js_yaml_1.dump)(yarnrc, { indent: 2 }));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
tree.create(yarnrcPath, (0, js_yaml_1.dump)(yarnrc, { indent: 2 }));
|
|
66
75
|
}
|
|
67
|
-
};
|
|
68
|
-
if (tree.exists(yarnrcPath)) {
|
|
69
|
-
tree.overwrite(yarnrcPath, (0, js_yaml_1.dump)(yarnrc, { indent: 2 }));
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
tree.create(yarnrcPath, (0, js_yaml_1.dump)(yarnrc, { indent: 2 }));
|
|
73
76
|
}
|
|
74
77
|
const targetPath = options.directory || tree.root.path;
|
|
75
78
|
const baseRule = (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates/base'), [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/typescript/shell/index.ts"],"names":[],"mappings":";;;AAAA,2DAWoC;AACpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/typescript/shell/index.ts"],"names":[],"mappings":";;;AAAA,2DAWoC;AACpC,qCAAmC;AACnC,yCAA+C;AAC/C,6DAA6E;AAC7E,6DAA2D;AAG3D;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAAqD;IAE3F,MAAM,WAAW,GAAG,CAAC,KAAW,EAAE,OAAyB,EAAE,EAAE;QAC7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAU,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,oBAAQ,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACpJ,MAAM,WAAW,GAAG,IAAI,yBAAU,CAAC,EAAC,gBAAgB,EAAE,c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om.yo-rc.json
|
|
11
|
-
|
|
12
9
|
# Open API
|
|
13
10
|
.openapi-generator
|
|
14
11
|
|
|
@@ -38,6 +35,7 @@
|
|
|
38
35
|
.history
|
|
39
36
|
.ionide
|
|
40
37
|
|
|
38
|
+
<% if (packageManager === 'yarn') { %>
|
|
41
39
|
# Support for Project snippet scope
|
|
42
40
|
|
|
43
41
|
### yarn ###
|
|
@@ -56,10 +54,8 @@
|
|
|
56
54
|
|
|
57
55
|
# and uncomment the following lines
|
|
58
56
|
.pnp.*
|
|
59
|
-
|
|
60
|
-
### Yeoman ###
|
|
57
|
+
<% } %>
|
|
61
58
|
node_modules/
|
|
62
|
-
bower_components/
|
|
63
59
|
*.log
|
|
64
60
|
|
|
65
61
|
build/
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"updateInternalDeps": true,
|
|
28
28
|
"postUpdateOptions": [
|
|
29
|
-
"yarnDedupeHighest"
|
|
29
|
+
<% if (packageManager === 'yarn') { %>"yarnDedupeHighest",<% } %>
|
|
30
30
|
],
|
|
31
31
|
"rangeStrategy": "replace",
|
|
32
32
|
"automerge": true,
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
],
|
|
40
40
|
"postUpgradeTasks": {
|
|
41
41
|
"commands": [
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"<%=packageManager%> install",
|
|
43
|
+
"<%=packageManager%> run generate"
|
|
44
44
|
],
|
|
45
45
|
"executionMode": "branch"
|
|
46
46
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"typescript.preferences.importModuleSpecifier": "relative",
|
|
3
3
|
"typescript.preferences.quoteStyle": "single",
|
|
4
|
-
"jest.jestCommandLine": "
|
|
4
|
+
"jest.jestCommandLine": "<%=packageManager%> exec jest",
|
|
5
5
|
"jest.autoRun": {
|
|
6
6
|
"watch": false,
|
|
7
7
|
"onSave": "test-file"
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
"files.readonlyFromPermissions": true,
|
|
10
10
|
"files.readonlyInclude": {
|
|
11
11
|
"**/.cache/**": true,
|
|
12
|
+
<% if (packageManager === 'yarn') { %>
|
|
12
13
|
"**/.pnp.*": true,
|
|
13
14
|
"**/.yarn/**": true,
|
|
15
|
+
<% } %>
|
|
14
16
|
"**/node_modules/**": true,
|
|
15
17
|
"src/base/*/*.ts": true
|
|
16
18
|
},
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"clean": "rimraf test/ test-dev/ dist/ dist-dev/ dist-test/ build/",
|
|
33
33
|
"lint:ci": "eslint '**/*[jt]s' --quiet --format junit --output-file ./dist-lint/result.xml",
|
|
34
34
|
"lint": "eslint '**/*[jt]s' --cache",
|
|
35
|
-
"start": "tsc-watch -b tsconfigs/esm2020 --noClear --onFirstSuccess \"
|
|
36
|
-
"build": "
|
|
35
|
+
"start": "tsc-watch -b tsconfigs/esm2020 --noClear --onFirstSuccess \"<%=packageManager%> run files:pack --watch\"",
|
|
36
|
+
"build": "<%=packageManager%> run build:cjs && <%=packageManager%> run build:esm2015 && <%=packageManager%> run build:esm2020 && <%=packageManager%> run files:pack",
|
|
37
37
|
"build:cjs": "swc src -d dist/cjs -C module.type=commonjs -q",
|
|
38
38
|
"build:esm2015": "swc src -d dist/esm2015 -C module.type=es6 -q",
|
|
39
39
|
"build:esm2020": "tsc -b tsconfigs/esm2020",
|
|
40
40
|
"set:version": "set-version --placeholder 0.0.0",
|
|
41
41
|
"resolve": "node -e 'process.stdout.write(require.resolve(process.argv[1]));'",
|
|
42
42
|
"generate": "schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml",
|
|
43
|
-
"spec:regen": "
|
|
43
|
+
"spec:regen": "<%=packageManager%> run generate && <%=packageManager%> exec clear-index",
|
|
44
44
|
"clear-index": "node scripts/clear-index.js",
|
|
45
45
|
"files:pack": "node scripts/files-pack.js",
|
|
46
46
|
"test": "jest --passWithNoTests",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"lint-staged": {
|
|
54
54
|
"**/*.(js|ts)": [
|
|
55
|
-
"
|
|
55
|
+
"<%=packageManager%> exec eslint --quiet --fix --global fast"
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
@@ -115,6 +115,5 @@
|
|
|
115
115
|
"node": "<%= engineVersions['node'] %>",
|
|
116
116
|
"npm": "<%= engineVersions['npm'] %>",
|
|
117
117
|
"yarn": "<%= engineVersions['yarn'] %>"
|
|
118
|
-
}
|
|
119
|
-
"packageManager": "yarn@3.6.1"
|
|
118
|
+
}
|
|
120
119
|
}
|
|
@@ -22,6 +22,7 @@ The Code can be regenerated by running the following command:
|
|
|
22
22
|
```shell
|
|
23
23
|
yarn schematics @ama-sdk/sdk:typescript-core --spec-path [path to your swagger file]
|
|
24
24
|
```
|
|
25
|
+
Note that you can use ```npm exec``` instead of ```yarn``` for every command specified in this documentation.
|
|
25
26
|
|
|
26
27
|
***
|
|
27
28
|
|
|
@@ -109,11 +110,95 @@ You can build and run UT with:
|
|
|
109
110
|
yarn test
|
|
110
111
|
```
|
|
111
112
|
|
|
112
|
-
##
|
|
113
|
+
## Manage dates
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
### The timezone issue
|
|
116
|
+
Managing dates with timezones has always been a bit painful in front end applications.
|
|
117
|
+
Let's give a concrete example to understand the problem:
|
|
118
|
+
An API returns the date and hour of your flight in the timezone of the airport location. In our use case, let's say the departure airport is on GTM+7 : 2023-07-10T00:37:00.000+07:00.
|
|
119
|
+
The timezone sent is the one from the airport, here GMT+7. If you just use the Date(), the computer browser will convert this in its own timezone.
|
|
120
|
+
For example, if the user is in GMT+2 you will end up displaying the following: 2023-07-09T19:37:00.000+02:00.
|
|
121
|
+
This is not what you want. You want the exact date time of the flight at the airport timezone, not the one of your user's computer.
|
|
122
|
+
However, there might be cases where you might still need the timezone information.
|
|
123
|
+
For example, you want to be able to display that the flight is in X hours.
|
|
124
|
+
You will need to compute this information with the two timezones -- the airport's and the user's.
|
|
115
125
|
|
|
116
|
-
###
|
|
126
|
+
### Solution proposed to remove the timezone: utils.DateTime
|
|
127
|
+
We have introduced the utils.Date object to replace the Date implementation and ignore the timezone.
|
|
128
|
+
As we need to get rid of the timezones more often than not, this will be our default behavior.
|
|
129
|
+
By default, the Date models are replaced with utils.Date.
|
|
130
|
+
|
|
131
|
+
When we need to keep the timezone information, we create a new field directly in the SDK.
|
|
132
|
+
As this field does not exist in the specification, it will not be part of the base model but of the core model instead.
|
|
133
|
+
|
|
134
|
+
Simple example:
|
|
135
|
+
```yaml
|
|
136
|
+
Flight:
|
|
137
|
+
type: "object"
|
|
138
|
+
required:
|
|
139
|
+
- departureDateTime
|
|
140
|
+
properties:
|
|
141
|
+
departureDateTime:
|
|
142
|
+
type: string
|
|
143
|
+
format: date-time
|
|
144
|
+
```
|
|
145
|
+
Base model generated
|
|
146
|
+
```typescript
|
|
147
|
+
// flight.ts generated in base models
|
|
148
|
+
export interface Flight {
|
|
149
|
+
/** @see utils.DateTime */
|
|
150
|
+
departureDateTime: utils.DateTime;
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
You need to create a core model to store the timezone information (src/models/core/flight.ts):
|
|
154
|
+
```typescript
|
|
155
|
+
import type { IgnoreEnum } from '@ama-sdk/core';
|
|
156
|
+
import type { Flight } from '../../base/flight/flight';
|
|
157
|
+
export type FlightStopCoreIfy<T extends IgnoreEnum<Flight>> = T & {
|
|
158
|
+
/** Departure date time of the flight considering timezone */
|
|
159
|
+
departureDateTimeConsideringTimezone?: Date;
|
|
160
|
+
};
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
And an associated reviver (src/models/core/flight.reviver.ts):
|
|
164
|
+
```typescript
|
|
165
|
+
import type { Flight } from '../../base/flight/flight';
|
|
166
|
+
import type { reviveFlight } from '../../base/flight/flight.reviver';
|
|
167
|
+
import type { FlightCoreIfy } from './flight';
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param baseRevive
|
|
171
|
+
*/
|
|
172
|
+
export function reviveFlightFactory<R extends typeof reviveFlight>(baseRevive: R) {
|
|
173
|
+
const reviver = <T extends Flight = Flight>(data: any, dictionaries?: any) => {
|
|
174
|
+
const originalData: any = {...data};
|
|
175
|
+
const revivedData = baseRevive<FlightCoreIfy<T>>(data, dictionaries);
|
|
176
|
+
if (!revivedData) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
revivedData.departureDateTimeConsideringTimezone = originalData.departureDateTimeConsideringTimezone && new Date(originalData.departureDateTimeConsideringTimezone)
|
|
180
|
+
|| originalData.departureDateTime && new Date(originalData.departureDateTime);
|
|
181
|
+
return revivedData;
|
|
182
|
+
};
|
|
183
|
+
return reviver;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
And export it here (src/models/core/flight/index.ts):
|
|
188
|
+
```typescript
|
|
189
|
+
export * from './flight';
|
|
190
|
+
export * from './flight.reviver';
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
And here (src/models/core/index.ts):
|
|
194
|
+
```typescript
|
|
195
|
+
export * from './flight/index';
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
You can now use departureDateTimeConsideringTimezone to access the timezone information.
|
|
199
|
+
See [utils.Date](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-sdk/core/src/fwk/date.ts) for more information.
|
|
200
|
+
|
|
201
|
+
### How to keep the timezone (prevent Date replacement with utils.Date)
|
|
117
202
|
|
|
118
203
|
In order to add the timezone to your timestamp property you can add the x-date-timezone extension in your yaml, for example:
|
|
119
204
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { };
|
|
File without changes
|