@gct-paas/cli 0.1.5-dev.6 → 0.1.5-dev.8
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/dist/actions/gen-api/model-manage.cjs +11 -5
- package/dist/core/handlebars/helpers/format-js-type/format-js-type.cjs +24 -15
- package/dist/core/handlebars/helpers/format-js-type/format-js-type.d.ts +1 -1
- package/es/actions/gen-api/model-manage.mjs +9 -5
- package/es/core/handlebars/helpers/format-js-type/format-js-type.d.ts +1 -1
- package/es/core/handlebars/helpers/format-js-type/format-js-type.mjs +20 -15
- package/hbs-temp/apis/{{api}}.service.d.ts.hbs +15 -3
- package/hbs-temp/entities.d.ts.hbs +2 -2
- package/package.json +2 -3
|
@@ -51,11 +51,17 @@ class ModelManage {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
if (param && param.schema) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
if (param.name === "requestBody") {
|
|
55
|
+
requestEntity = {
|
|
56
|
+
title: "IObject"
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
const refKey = this.getOriginRef(param.schema);
|
|
60
|
+
requestEntity = cfg.definitions[refKey];
|
|
61
|
+
if (requestEntity && Object.keys(requestEntity).length > 0) {
|
|
62
|
+
this.definitions.set(refKey, requestEntity);
|
|
63
|
+
entitySet.add(refKey);
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
let responseEntity = void 0;
|
|
@@ -9,33 +9,42 @@ class HelperFormatJsType extends _helperBase.HelperBase {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super("formatJsType");
|
|
11
11
|
}
|
|
12
|
-
onExecute(
|
|
13
|
-
if (!
|
|
12
|
+
onExecute(config) {
|
|
13
|
+
if (!config) {
|
|
14
14
|
return "unknown";
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
const {
|
|
17
|
+
type,
|
|
18
|
+
items: cfg,
|
|
19
|
+
originalRef
|
|
20
|
+
} = config;
|
|
21
|
+
const fieldType = type || originalRef;
|
|
22
|
+
if (!fieldType) {
|
|
23
|
+
return "unknown";
|
|
24
|
+
}
|
|
25
|
+
if (fieldType === "array") {
|
|
17
26
|
if (cfg) {
|
|
18
|
-
let
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
} else if (
|
|
23
|
-
|
|
27
|
+
let type2 = cfg.type || cfg.originalRef;
|
|
28
|
+
if (type2) {
|
|
29
|
+
if (type2 === "integer") {
|
|
30
|
+
type2 = "number";
|
|
31
|
+
} else if (type2.startsWith("Triple\xAB")) {
|
|
32
|
+
type2 = type2.replace("Triple\xAB", "ITripleObject<").replace("\xBB", ">");
|
|
24
33
|
}
|
|
25
34
|
} else {
|
|
26
|
-
|
|
35
|
+
type2 = "unknown";
|
|
27
36
|
}
|
|
28
|
-
return
|
|
37
|
+
return type2 + "[]";
|
|
29
38
|
}
|
|
30
39
|
return "unknown[]";
|
|
31
40
|
}
|
|
32
|
-
if (
|
|
41
|
+
if (fieldType === "integer") {
|
|
33
42
|
return "number";
|
|
34
43
|
}
|
|
35
|
-
if (
|
|
36
|
-
return "
|
|
44
|
+
if (fieldType === "object") {
|
|
45
|
+
return "IObject";
|
|
37
46
|
}
|
|
38
|
-
return
|
|
47
|
+
return fieldType;
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
50
|
exports.HelperFormatJsType = HelperFormatJsType;
|
|
@@ -53,11 +53,15 @@ export class ModelManage {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
if (param && param.schema) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
|
|
56
|
+
if (param.name === "requestBody") {
|
|
57
|
+
requestEntity = { title: "IObject" };
|
|
58
|
+
} else {
|
|
59
|
+
const refKey = this.getOriginRef(param.schema);
|
|
60
|
+
requestEntity = cfg.definitions[refKey];
|
|
61
|
+
if (requestEntity && Object.keys(requestEntity).length > 0) {
|
|
62
|
+
this.definitions.set(refKey, requestEntity);
|
|
63
|
+
entitySet.add(refKey);
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
let responseEntity = void 0;
|
|
@@ -3,32 +3,37 @@ export class HelperFormatJsType extends HelperBase {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
super("formatJsType");
|
|
5
5
|
}
|
|
6
|
-
onExecute(
|
|
7
|
-
if (!
|
|
6
|
+
onExecute(config) {
|
|
7
|
+
if (!config) {
|
|
8
8
|
return "unknown";
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const { type, items: cfg, originalRef } = config;
|
|
11
|
+
const fieldType = type || originalRef;
|
|
12
|
+
if (!fieldType) {
|
|
13
|
+
return "unknown";
|
|
14
|
+
}
|
|
15
|
+
if (fieldType === "array") {
|
|
11
16
|
if (cfg) {
|
|
12
|
-
let
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
} else if (
|
|
17
|
-
|
|
17
|
+
let type2 = cfg.type || cfg.originalRef;
|
|
18
|
+
if (type2) {
|
|
19
|
+
if (type2 === "integer") {
|
|
20
|
+
type2 = "number";
|
|
21
|
+
} else if (type2.startsWith("Triple\xAB")) {
|
|
22
|
+
type2 = type2.replace("Triple\xAB", "ITripleObject<").replace("\xBB", ">");
|
|
18
23
|
}
|
|
19
24
|
} else {
|
|
20
|
-
|
|
25
|
+
type2 = "unknown";
|
|
21
26
|
}
|
|
22
|
-
return
|
|
27
|
+
return type2 + "[]";
|
|
23
28
|
}
|
|
24
29
|
return "unknown[]";
|
|
25
30
|
}
|
|
26
|
-
if (
|
|
31
|
+
if (fieldType === "integer") {
|
|
27
32
|
return "number";
|
|
28
33
|
}
|
|
29
|
-
if (
|
|
30
|
-
return "
|
|
34
|
+
if (fieldType === "object") {
|
|
35
|
+
return "IObject";
|
|
31
36
|
}
|
|
32
|
-
return
|
|
37
|
+
return fieldType;
|
|
33
38
|
}
|
|
34
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import type { AxiosRequestConfig } from 'axios';
|
|
2
3
|
{{#gt entityRefs.length 0}}
|
|
3
4
|
import type { {{formatImport entityRefs}} } from '../entities';
|
|
@@ -7,7 +8,16 @@ import type { {{formatImport entityRefs}} } from '../entities';
|
|
|
7
8
|
{{#gt method.queries.length 0}}
|
|
8
9
|
export interface {{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}Query {
|
|
9
10
|
{{#each method.queries as |query|}}
|
|
10
|
-
|
|
11
|
+
{{#neq query.description ""}}
|
|
12
|
+
/**
|
|
13
|
+
* {{query.description}}
|
|
14
|
+
*/
|
|
15
|
+
{{/neq}}
|
|
16
|
+
{{#eq query.name "requestParam"}}
|
|
17
|
+
[key: any]: any;
|
|
18
|
+
{{else}}
|
|
19
|
+
{{camelCase query.name}}{{#if query.required}}{{else}}?{{/if}}: {{#if query.items}}{{formatJsType query}}{{else}}{{formatJsType query}}{{/if}};
|
|
20
|
+
{{/eq}}
|
|
11
21
|
{{/each}}
|
|
12
22
|
}
|
|
13
23
|
{{/gt}}
|
|
@@ -21,7 +31,9 @@ export interface {{ method.mode }}{{#if method.name}}{{pascalCase (camelCase met
|
|
|
21
31
|
{{/each}}
|
|
22
32
|
export interface {{pascalCase (camelCase entityName) }}Service {
|
|
23
33
|
{{#each methods as |method|}}
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
/**
|
|
35
|
+
* {{ method.model.summary }}
|
|
36
|
+
*/
|
|
37
|
+
{{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}({{#gt method.pathParams.length 0}}path: {{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}PathParams, {{/gt}}{{#gt method.queries.length 0}}query: {{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}Query, {{/gt}}{{#if method.requestEntity}}data: {{method.requestEntity.title}}, {{/if}}config?: Partial<AxiosRequestConfig>): Promise<{{#if method.responseEntity}}{{formatImportItem method.responseEntity.title}}{{else}}any{{/if}}>;
|
|
26
38
|
{{/each}}
|
|
27
39
|
}
|
|
@@ -7,9 +7,9 @@ export interface {{ entity.title }} {
|
|
|
7
7
|
/**
|
|
8
8
|
* {{ property.description }}
|
|
9
9
|
*
|
|
10
|
-
* @type {{{formatJsType property
|
|
10
|
+
* @type {{{formatJsType property }}}
|
|
11
11
|
*/
|
|
12
|
-
{{ key }}{{#if property.required}}{{else}}?{{/if}}: {{formatJsType property
|
|
12
|
+
{{ key }}{{#if property.required}}{{else}}?{{/if}}: {{formatJsType property }};
|
|
13
13
|
{{/each}}
|
|
14
14
|
{{else}}
|
|
15
15
|
// 暂无属性
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gct-paas/cli",
|
|
3
|
-
"version": "0.1.5-dev.
|
|
3
|
+
"version": "0.1.5-dev.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"bin": {
|
|
@@ -65,6 +65,5 @@
|
|
|
65
65
|
"tsx": "^4.21.0",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"unbuild": "^3.6.1"
|
|
68
|
-
}
|
|
69
|
-
"gitHead": "2f73ef719a7c5e53eb9c9ebc1f5f46148fda4831"
|
|
68
|
+
}
|
|
70
69
|
}
|