@rxap/open-api 12.1.1-next.1 → 12.2.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/package.json +8 -6
- package/src/schematics/open-api/coerce-open-api-project.d.ts +1 -1
- package/src/schematics/open-api/coerce-open-api-project.js +3 -2
- package/src/schematics/open-api/coerce-open-api-project.js.map +1 -1
- package/src/schematics/open-api/generate-openapi-provider.d.ts +2 -0
- package/src/schematics/open-api/generate-openapi-provider.js +37 -0
- package/src/schematics/open-api/generate-openapi-provider.js.map +1 -0
- package/src/schematics/open-api/index.js +26 -3
- package/src/schematics/open-api/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxap/open-api",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Merzough Münker",
|
|
6
6
|
"homepage": "https://gitlab.com/rxap/packages/libs/open-api",
|
|
@@ -19,21 +19,23 @@
|
|
|
19
19
|
},
|
|
20
20
|
"description": "Provides the functionality to create DataSource and RemoteMethod instances from an OpenAPI config.",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
+
"@angular-devkit/schematics": "^12.2.9",
|
|
22
23
|
"@angular/common": "^12.0.1",
|
|
23
24
|
"@angular/core": "^12.0.1",
|
|
24
25
|
"@angular/platform-browser": "^12.0.1",
|
|
25
|
-
"@rxap/data-source": "^12.1.3
|
|
26
|
+
"@rxap/data-source": "^12.1.3",
|
|
26
27
|
"@rxap/definition": "^12.0.8",
|
|
27
28
|
"@rxap/mixin": "^12.0.7",
|
|
28
29
|
"@rxap/remote-method": "^12.0.9",
|
|
29
|
-
"@rxap/utilities": "^12.2.
|
|
30
|
+
"@rxap/utilities": "^12.2.2",
|
|
31
|
+
"@schematics/angular": "^12.2.9",
|
|
30
32
|
"reflect-metadata": "^0.1.13",
|
|
31
33
|
"rxjs": "^6.5.5"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@rxap/schematics-open-api": "^12.0.
|
|
35
|
-
"@rxap/schematics-ts-morph": "^12.3.
|
|
36
|
-
"@rxap/schematics-utilities": "^12.
|
|
36
|
+
"@rxap/schematics-open-api": "^12.0.9",
|
|
37
|
+
"@rxap/schematics-ts-morph": "^12.3.2",
|
|
38
|
+
"@rxap/schematics-utilities": "^12.7.0",
|
|
37
39
|
"ajv-oai": "^1.2.1",
|
|
38
40
|
"openapi-types": "^9.0.0",
|
|
39
41
|
"ts-morph": "^10.1.0",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function CoerceOpenApiProject(project: string): Rule;
|
|
2
|
+
export declare function CoerceOpenApiProject(project: string, prefix: string): Rule;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CoerceOpenApiProject = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
6
|
-
function CoerceOpenApiProject(project) {
|
|
6
|
+
function CoerceOpenApiProject(project, prefix) {
|
|
7
7
|
return (host) => {
|
|
8
8
|
const angularJson = schematics_utilities_1.GetAngularJson(host);
|
|
9
9
|
if (!angularJson.projects.hasOwnProperty(project)) {
|
|
@@ -11,7 +11,8 @@ function CoerceOpenApiProject(project) {
|
|
|
11
11
|
return schematics_1.chain([
|
|
12
12
|
schematics_1.externalSchematic('@nrwl/angular', 'library', {
|
|
13
13
|
name: project,
|
|
14
|
-
importPath: `@${defaultProjectPrefix}/${project}
|
|
14
|
+
importPath: `@${defaultProjectPrefix}/${project}`,
|
|
15
|
+
prefix
|
|
15
16
|
}),
|
|
16
17
|
(tree) => {
|
|
17
18
|
var _a, _b, _c, _d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-open-api-project.js","sourceRoot":"","sources":["../../../../../../libs/open-api/src/schematics/open-api/coerce-open-api-project.ts"],"names":[],"mappings":";;;AAAA,2DAMoC;AACpC,qEAA4D;AAE5D,SAAgB,oBAAoB,CAAC,OAAe;
|
|
1
|
+
{"version":3,"file":"coerce-open-api-project.js","sourceRoot":"","sources":["../../../../../../libs/open-api/src/schematics/open-api/coerce-open-api-project.ts"],"names":[],"mappings":";;;AAAA,2DAMoC;AACpC,qEAA4D;AAE5D,SAAgB,oBAAoB,CAAC,OAAe,EAAE,MAAc;IAClE,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,WAAW,GAAG,qCAAc,CAAC,IAAI,CAAQ,CAAC;QAEhD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YACjD,MAAM,oBAAoB,GAClB,WAAW,CAAC,QAAQ,CAAE,WAAW,CAAC,cAAc,CAAE,CAAC,MAAM,CAAC;YAClE,OAAO,kBAAK,CAAC;gBACX,8BAAiB,CAAC,eAAe,EAAE,SAAS,EAAE;oBAC5C,IAAI,EAAQ,OAAO;oBACnB,UAAU,EAAE,IAAI,oBAAoB,IAAI,OAAO,EAAE;oBACjD,MAAM;iBACP,CAAC;gBACF,CAAC,IAAI,EAAE,EAAE;;oBACP,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAC7B,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,0CAAE,QAAQ,EAAE,mCAAI,IAAI,CACrD,CAAC;oBAEF,MAAM,KAAK,GAAG,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,eAAe,0CAAE,KAAK,mCAAI,EAAE,CAAC;oBAEzD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE;wBAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;4BACpC,IAAI,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;gCAC5B,OAAO,KAAK,CAAE,GAAG,CAAE,CAAC;gCACpB,KAAK,CAAE,GAAG,GAAG,IAAI,CAAE,GAAG,CAAE,yBAAyB,CAAE,CAAC;6BACrD;yBACF;wBAED,IAAI,CAAC,SAAS,CACZ,qBAAqB,EACrB,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAC3C,CAAC;qBACH;gBACH,CAAC;aACF,CAAC,CAAC;SACJ;QAED,OAAO,iBAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAvCD,oDAuCC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenerateOpenapiProvider = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
|
+
const const_1 = require("./const");
|
|
7
|
+
const { dasherize, classify } = core_1.strings;
|
|
8
|
+
function GenerateOpenapiProvider(project, operatorIdList) {
|
|
9
|
+
const sourceFile = project.createSourceFile('open-api-providers.ts');
|
|
10
|
+
const providerList = [];
|
|
11
|
+
sourceFile.addImportDeclaration({
|
|
12
|
+
moduleSpecifier: '@angular/core',
|
|
13
|
+
namedImports: ['Provider']
|
|
14
|
+
});
|
|
15
|
+
for (const operationId of operatorIdList) {
|
|
16
|
+
const name = [operationId, const_1.REMOTE_METHOD_FILE_SUFFIX].join('.');
|
|
17
|
+
const moduleSpecifier = './' + path_1.join(const_1.REMOTE_METHOD_BASE_PATH, dasherize(name));
|
|
18
|
+
const className = classify(name.replace(/\./g, '-'));
|
|
19
|
+
sourceFile.addImportDeclaration({
|
|
20
|
+
moduleSpecifier,
|
|
21
|
+
namedImports: [className]
|
|
22
|
+
});
|
|
23
|
+
providerList.push(className);
|
|
24
|
+
}
|
|
25
|
+
sourceFile.addVariableStatement({
|
|
26
|
+
isExported: true,
|
|
27
|
+
declarations: [
|
|
28
|
+
{
|
|
29
|
+
name: 'OPEN_API_PROVIDERS',
|
|
30
|
+
type: 'Provider[]',
|
|
31
|
+
initializer: `[${providerList.join(', ')}]`,
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.GenerateOpenapiProvider = GenerateOpenapiProvider;
|
|
37
|
+
//# sourceMappingURL=generate-openapi-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-openapi-provider.js","sourceRoot":"","sources":["../../../../../../libs/open-api/src/schematics/open-api/generate-openapi-provider.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAC5B,+CAA+C;AAC/C,mCAGiB;AAEjB,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,cAAO,CAAC;AAExC,SAAgB,uBAAuB,CACrC,OAAgB,EAChB,cAAwB;IAGxB,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAErE,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,UAAU,CAAC,oBAAoB,CAAC;QAC9B,eAAe,EAAE,eAAe;QAChC,YAAY,EAAE,CAAE,UAAU,CAAE;KAC7B,CAAC,CAAC;IAEH,KAAK,MAAM,WAAW,IAAI,cAAc,EAAE;QAExC,MAAM,IAAI,GAAO,CAAE,WAAW,EAAE,iCAAyB,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtE,MAAM,eAAe,GAAG,IAAI,GAAG,WAAI,CAAC,+BAAuB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9E,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QAErD,UAAU,CAAC,oBAAoB,CAAC;YAC9B,eAAe;YACf,YAAY,EAAE,CAAE,SAAS,CAAE;SAC5B,CAAC,CAAC;QAEH,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KAE9B;IAED,UAAU,CAAC,oBAAoB,CAAC;QAC9B,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE;YACZ;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;aAC5C;SACF;KACF,CAAC,CAAC;AAEL,CAAC;AAxCD,0DAwCC"}
|
|
@@ -11,9 +11,31 @@ const generate_remote_method_1 = require("./generate-remote-method");
|
|
|
11
11
|
const generate_data_source_1 = require("./generate-data-source");
|
|
12
12
|
const const_1 = require("./const");
|
|
13
13
|
const coerce_open_api_project_1 = require("./coerce-open-api-project");
|
|
14
|
+
const generate_openapi_provider_1 = require("./generate-openapi-provider");
|
|
15
|
+
function GetOperationIdList(openapi) {
|
|
16
|
+
const operationIdList = [];
|
|
17
|
+
for (const [path, methods] of Object.entries(openapi.paths)) {
|
|
18
|
+
if (methods) {
|
|
19
|
+
for (const method of Object.keys(methods).filter(schematics_open_api_1.IsHttpMethod)) {
|
|
20
|
+
const operation = methods[method];
|
|
21
|
+
if (schematics_open_api_1.IsOperationObject(operation)) {
|
|
22
|
+
if (schematics_open_api_1.IgnoreOperation(['hidden'])(operation)) {
|
|
23
|
+
console.log(`Ignore operation '${operation.operationId}'`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (schematics_open_api_1.HasOperationId(operation)) {
|
|
27
|
+
operationIdList.push(operation.operationId);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return operationIdList;
|
|
35
|
+
}
|
|
14
36
|
function default_1(options) {
|
|
15
37
|
return (host) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var _a;
|
|
38
|
+
var _a, _b;
|
|
17
39
|
const openapi = yield schematics_open_api_1.LoadOpenApiConfig(host, options);
|
|
18
40
|
const project = new ts_morph_1.Project({
|
|
19
41
|
manipulationSettings: {
|
|
@@ -28,7 +50,7 @@ function default_1(options) {
|
|
|
28
50
|
}
|
|
29
51
|
const projectBasePath = path_1.join('libs', options.project, 'src');
|
|
30
52
|
const basePath = path_1.join(projectBasePath, 'lib');
|
|
31
|
-
options.prefix = (_a = options.prefix) !== null && _a !== void 0 ? _a : schematics_utilities_1.GetProjectPrefix(host, options.project);
|
|
53
|
+
options.prefix = (_b = (_a = options.prefix) !== null && _a !== void 0 ? _a : (schematics_utilities_1.HasProject(host, options.project) ? schematics_utilities_1.GetProjectPrefix(host, options.project) : schematics_utilities_1.GetDefaultPrefix(host))) !== null && _b !== void 0 ? _b : 'rxap';
|
|
32
54
|
if (!options.debug) {
|
|
33
55
|
// TODO : reset the hack after the schematic execution is finished
|
|
34
56
|
console.debug = function () { };
|
|
@@ -42,11 +64,12 @@ function default_1(options) {
|
|
|
42
64
|
const_1.DATA_SOURCE_BASE_PATH,
|
|
43
65
|
const_1.REMOTE_METHOD_BASE_PATH
|
|
44
66
|
], basePath),
|
|
45
|
-
coerce_open_api_project_1.CoerceOpenApiProject(options.project),
|
|
67
|
+
coerce_open_api_project_1.CoerceOpenApiProject(options.project, options.prefix),
|
|
46
68
|
() => schematics_open_api_1.GenerateOperation(openapi, project, options, [
|
|
47
69
|
generate_data_source_1.GenerateDataSource,
|
|
48
70
|
generate_remote_method_1.GenerateRemoteMethod
|
|
49
71
|
]),
|
|
72
|
+
() => generate_openapi_provider_1.GenerateOpenapiProvider(project, GetOperationIdList(openapi)),
|
|
50
73
|
schematics_ts_morph_1.ApplyTsMorphProject(project, basePath),
|
|
51
74
|
schematics_ts_morph_1.FixMissingImports(),
|
|
52
75
|
(tree) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/open-api/src/schematics/open-api/index.ts"],"names":[],"mappings":";;;AA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