@ama-sdk/schematics 12.1.0-prerelease.11 → 12.1.0-prerelease.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-sdk/schematics",
3
- "version": "12.1.0-prerelease.11",
3
+ "version": "12.1.0-prerelease.12",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -61,11 +61,11 @@
61
61
  }
62
62
  },
63
63
  "peerDependencies": {
64
- "@ama-sdk/core": "^12.1.0-prerelease.11",
64
+ "@ama-sdk/core": "^12.1.0-prerelease.12",
65
65
  "@angular-devkit/core": "^19.0.0",
66
66
  "@angular-devkit/schematics-cli": "^19.0.0",
67
67
  "@angular/cli": "^19.0.0",
68
- "@o3r/schematics": "^12.1.0-prerelease.11",
68
+ "@o3r/schematics": "^12.1.0-prerelease.12",
69
69
  "@openapitools/openapi-generator-cli": "^2.15.0",
70
70
  "openapi-types": "^12.0.0",
71
71
  "ts-node": "~10.9.2",
@@ -84,17 +84,17 @@
84
84
  "tslib": "^2.6.2"
85
85
  },
86
86
  "devDependencies": {
87
- "@ama-sdk/core": "^12.1.0-prerelease.11",
87
+ "@ama-sdk/core": "^12.1.0-prerelease.12",
88
88
  "@angular-devkit/schematics-cli": "~19.0.0",
89
89
  "@angular/cli": "~19.0.0",
90
90
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
91
91
  "@nx/eslint-plugin": "~20.2.0",
92
92
  "@nx/jest": "~20.2.0",
93
- "@o3r/build-helpers": "^12.1.0-prerelease.11",
94
- "@o3r/eslint-plugin": "^12.1.0-prerelease.11",
95
- "@o3r/schematics": "^12.1.0-prerelease.11",
96
- "@o3r/telemetry": "^12.1.0-prerelease.11",
97
- "@o3r/test-helpers": "^12.1.0-prerelease.11",
93
+ "@o3r/build-helpers": "^12.1.0-prerelease.12",
94
+ "@o3r/eslint-plugin": "^12.1.0-prerelease.12",
95
+ "@o3r/schematics": "^12.1.0-prerelease.12",
96
+ "@o3r/telemetry": "^12.1.0-prerelease.12",
97
+ "@o3r/test-helpers": "^12.1.0-prerelease.12",
98
98
  "@openapitools/openapi-generator-cli": "~2.16.0",
99
99
  "@schematics/angular": "~19.0.0",
100
100
  "@stylistic/eslint-plugin": "~3.0.0",
@@ -0,0 +1,18 @@
1
+ import { CodeGenerator } from '../code-generator';
2
+ import { JavaGeneratorTaskOptions } from './swagger-java.options';
3
+ /**
4
+ * Manage the schematic to generate a sdk using the Swagger 2 Generator
5
+ * Note: a working java setup compatible with Swagger 2 Generator is required to use this class
6
+ * @deprecated to be removed in v12
7
+ */
8
+ export declare class SwaggerJavaGenerator extends CodeGenerator<JavaGeneratorTaskOptions> {
9
+ /** @inheritDoc */
10
+ protected generatorName: string;
11
+ /** @inheritDoc */
12
+ protected getDefaultOptions: () => Readonly<JavaGeneratorTaskOptions>;
13
+ /** @inheritDoc */
14
+ protected runCodeGeneratorFactory(factoryOptions?: {
15
+ rootDirectory?: string;
16
+ }): (generatorOptions?: JavaGeneratorTaskOptions) => Promise<void>;
17
+ }
18
+ //# sourceMappingURL=swagger-java.generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger-java.generator.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/swagger-java-generator/swagger-java.generator.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,wBAAwB,CAAC;IAC/E,kBAAkB;IAClB,SAAS,CAAC,aAAa,SAAoB;IAE3C,kBAAkB;IAClB,SAAS,CAAC,iBAAiB,2CAAwB;IACnD,kBAAkB;IAClB,SAAS,CAAC,uBAAuB,CAAC,cAAc,GAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAO,uBAE9C,wBAAwB;CA6C5D"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwaggerJavaGenerator = void 0;
4
+ const node_child_process_1 = require("node:child_process");
5
+ const path = require("node:path");
6
+ const code_generator_1 = require("../code-generator");
7
+ const swagger_java_options_1 = require("./swagger-java.options");
8
+ /**
9
+ * Manage the schematic to generate a sdk using the Swagger 2 Generator
10
+ * Note: a working java setup compatible with Swagger 2 Generator is required to use this class
11
+ * @deprecated to be removed in v12
12
+ */
13
+ class SwaggerJavaGenerator extends code_generator_1.CodeGenerator {
14
+ constructor() {
15
+ super(...arguments);
16
+ /** @inheritDoc */
17
+ this.generatorName = 'java-generator';
18
+ /** @inheritDoc */
19
+ this.getDefaultOptions = () => swagger_java_options_1.defaultOptions;
20
+ }
21
+ /** @inheritDoc */
22
+ runCodeGeneratorFactory(factoryOptions = {}) {
23
+ const rootDirectory = factoryOptions.rootDirectory || process.cwd();
24
+ return async (generatorOptions) => {
25
+ if (!generatorOptions) {
26
+ return Promise.reject(new Error('Missing options'));
27
+ }
28
+ const spawnOptions = {
29
+ stdio: 'inherit',
30
+ shell: true,
31
+ cwd: rootDirectory
32
+ };
33
+ const codegenPath = path.join(generatorOptions.targetFolder, `${generatorOptions.codegenLanguage}-${generatorOptions.codegenFileName}`);
34
+ const cliPath = path.resolve(__dirname, '..', '..', 'resources', generatorOptions.cliFilename);
35
+ const args = [
36
+ '-cp',
37
+ codegenPath + path.delimiter + cliPath,
38
+ 'io.swagger.codegen.SwaggerCodegen',
39
+ 'generate',
40
+ '-l',
41
+ generatorOptions.codegenLanguage,
42
+ '-i',
43
+ generatorOptions.specPath,
44
+ '-o',
45
+ generatorOptions.outputPath
46
+ ];
47
+ if (!generatorOptions.apiTests) {
48
+ args.push('-DapiTests=false');
49
+ }
50
+ if (generatorOptions.specConfigPath) {
51
+ args.push(`-c=${generatorOptions.specConfigPath}`);
52
+ }
53
+ return new Promise((resolve, reject) => {
54
+ (0, node_child_process_1.spawn)('java', args, spawnOptions)
55
+ .on('close', (code) => {
56
+ if (code === 0) {
57
+ resolve();
58
+ }
59
+ else {
60
+ reject(new Error(`Java generator failed with status ${code}`));
61
+ }
62
+ });
63
+ });
64
+ };
65
+ }
66
+ }
67
+ exports.SwaggerJavaGenerator = SwaggerJavaGenerator;
68
+ //# sourceMappingURL=swagger-java.generator.js.map
@@ -0,0 +1,32 @@
1
+ import { CodegenTaskOptions } from '../code-generator';
2
+ /**
3
+ * Options for the generator-java task.
4
+ */
5
+ export type JavaGeneratorTaskOptions = CodegenTaskOptions & {
6
+ targetFolder: string;
7
+ /**
8
+ * Enable API testing in Swagger Codegen
9
+ * @default true
10
+ */
11
+ apiTests: boolean;
12
+ /**
13
+ * Path to the Swagger CLI
14
+ * @default 'swagger-codegen-cli.jar'
15
+ */
16
+ cliFilename: string;
17
+ /**
18
+ * Path to the Swagger Codegen
19
+ * @default 'swagger-codegen.jar'
20
+ */
21
+ codegenFileName: string;
22
+ /**
23
+ * Template language use for the codegen
24
+ * @default 'default'
25
+ */
26
+ codegenLanguage: string;
27
+ };
28
+ /**
29
+ * Default options to generate a JAVA sdk using the Swagger 2 Generator
30
+ */
31
+ export declare const defaultOptions: Readonly<JavaGeneratorTaskOptions>;
32
+ //# sourceMappingURL=swagger-java.options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger-java.options.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/swagger-java-generator/swagger-java.options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,wBAAwB,CASpD,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultOptions = void 0;
4
+ /**
5
+ * Default options to generate a JAVA sdk using the Swagger 2 Generator
6
+ */
7
+ exports.defaultOptions = {
8
+ apiTests: true,
9
+ targetFolder: './',
10
+ cliFilename: 'swagger-codegen-cli.jar',
11
+ codegenFileName: 'swagger-codegen.jar',
12
+ codegenLanguage: 'default',
13
+ specPath: 'swagger-spec.yaml',
14
+ outputPath: '.',
15
+ specConfigPath: ''
16
+ };
17
+ //# sourceMappingURL=swagger-java.options.js.map
@@ -0,0 +1,9 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { NgGenerateJavaClientCoreSchematicsSchema } from './schema';
3
+ /**
4
+ * Generate a Java client SDK source code base on swagger specification
5
+ * @deprecated Remove in otter v12
6
+ * @param options
7
+ */
8
+ export declare const ngGenerateJavaClientCore: (options: NgGenerateJavaClientCoreSchematicsSchema) => () => Promise<Rule>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/java/client-core/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAOpC,OAAO,EACL,wCAAwC,EACzC,MAAM,UAAU,CAAC;AA2ElB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAAa,wCAAwC,wBAGzF,CAAC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngGenerateJavaClientCore = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const path = require("node:path");
6
+ const schematics_1 = require("@angular-devkit/schematics");
7
+ const swagger_java_generator_1 = require("../../code-generator/swagger-java-generator/swagger-java.generator");
8
+ const tree_glob_1 = require("../../helpers/tree-glob");
9
+ /** Base path where to find codegen jars */
10
+ const jarBasePath = path.resolve(__dirname, 'swagger-codegen-java-client', 'target');
11
+ /**
12
+ * Generate a Java client SDK source code base on swagger specification
13
+ * @param options
14
+ */
15
+ function ngGenerateJavaClientCoreFn(options) {
16
+ const specPath = path.resolve(process.cwd(), options.specPath);
17
+ /**
18
+ * rule to clear previous SDK generation
19
+ * @param tree
20
+ * @param context
21
+ */
22
+ const clearGeneratedCode = async (tree, context) => {
23
+ const swaggerConfig = options.specConfigPath ? JSON.parse(await node_fs_1.promises.readFile(options.specConfigPath, { encoding: 'utf8' })) : undefined;
24
+ if (swaggerConfig?.additionalProperties) {
25
+ const modelPackage = swaggerConfig.additionalProperties?.basePackage;
26
+ if (modelPackage) {
27
+ context.logger.info('Remove previously generated base models');
28
+ (0, tree_glob_1.treeGlob)(tree, path.join('src', 'main', 'java', ...modelPackage.split('.'), '**', '*.java')).forEach((file) => tree.delete(file));
29
+ }
30
+ const apiInterfacesPackage = swaggerConfig.additionalProperties.endpointsPackage;
31
+ if (apiInterfacesPackage) {
32
+ context.logger.info('Remove previously generated API interfaces');
33
+ (0, tree_glob_1.treeGlob)(tree, path.join('src', 'main', 'java', ...apiInterfacesPackage.split('.'), '**', '*.java')).forEach((file) => tree.delete(file));
34
+ }
35
+ const apiImplPackage = swaggerConfig.additionalProperties.endpointsImplPackage;
36
+ if (apiImplPackage) {
37
+ context.logger.info('Remove previously generated API implementations');
38
+ (0, tree_glob_1.treeGlob)(tree, path.join('src', 'main', 'java', ...apiImplPackage.split('.'), '**', '*.java')).forEach((file) => tree.delete(file));
39
+ }
40
+ }
41
+ context.logger.info('Remove previously generated doc');
42
+ (0, tree_glob_1.treeGlob)(tree, path.join('docs', '**')).forEach((file) => tree.delete(file));
43
+ if (tree.exists('/README.md')) {
44
+ context.logger.info('Remove previously generated readme');
45
+ tree.delete('/README.md');
46
+ }
47
+ return () => tree;
48
+ };
49
+ /**
50
+ * rule to update readme and generate mandatory code source
51
+ * @param tree
52
+ */
53
+ const generateSource = async (tree) => {
54
+ const specContent = await node_fs_1.promises.readFile(path.resolve(process.cwd(), options.specPath), { encoding: 'utf8' });
55
+ if (tree.exists('/swagger-spec.yaml')) {
56
+ tree.overwrite('/swagger-spec.yaml', specContent);
57
+ }
58
+ else {
59
+ tree.create('/swagger-spec.yaml', specContent);
60
+ }
61
+ return () => tree;
62
+ };
63
+ return (0, schematics_1.chain)([
64
+ clearGeneratedCode,
65
+ generateSource,
66
+ (new swagger_java_generator_1.SwaggerJavaGenerator()).getGeneratorRunSchematic({
67
+ targetFolder: jarBasePath,
68
+ specPath,
69
+ codegenLanguage: 'javaClient',
70
+ apiTests: false,
71
+ specConfigPath: options.specConfigPath || undefined
72
+ })
73
+ ]);
74
+ }
75
+ /**
76
+ * Generate a Java client SDK source code base on swagger specification
77
+ * @deprecated Remove in otter v12
78
+ * @param options
79
+ */
80
+ const ngGenerateJavaClientCore = (options) => async () => {
81
+ const { createSchematicWithMetricsIfInstalled } = await Promise.resolve().then(() => require('@o3r/schematics'));
82
+ return createSchematicWithMetricsIfInstalled(ngGenerateJavaClientCoreFn)(options);
83
+ };
84
+ exports.ngGenerateJavaClientCore = ngGenerateJavaClientCore;
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgGenerateJavaClientCoreSchematicsSchema extends SchematicOptionObject {
3
+ /** Path to the swagger specification used to generate the SDK */
4
+ specPath: string;
5
+ /** Swagger config file */
6
+ specConfigPath?: string | undefined;
7
+ }
8
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/java/client-core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,wCAAyC,SAAQ,qBAAqB;IACrF,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map