@gct-paas/cli 0.1.5-dev.3 → 0.1.5-dev.6
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 +3 -10
- package/dist/actions/gen-api/model-manage.d.ts +6 -0
- package/es/actions/gen-api/model-manage.d.ts +6 -0
- package/es/actions/gen-api/model-manage.mjs +5 -10
- package/hbs-temp/api-config.ts.hbs +3 -2
- package/hbs-temp/apis/{{api}}.service.d.ts.hbs +8 -1
- package/package.json +2 -2
|
@@ -72,22 +72,15 @@ class ModelManage {
|
|
|
72
72
|
return param2;
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
|
|
76
|
-
queries.push({
|
|
77
|
-
name: "id",
|
|
78
|
-
in: "query",
|
|
79
|
-
description: "\u6570\u636E\u4E3B\u952E",
|
|
80
|
-
required: true,
|
|
81
|
-
type: "string"
|
|
82
|
-
});
|
|
83
|
-
}
|
|
75
|
+
const matches = [...config.requestPath.matchAll(/\{([^}]*)\}/g)].map(m => m[1]);
|
|
84
76
|
methods.push({
|
|
85
77
|
name: methodName !== "undefined" ? methodName : "",
|
|
86
78
|
mode,
|
|
87
79
|
model: config,
|
|
88
80
|
requestEntity,
|
|
89
81
|
responseEntity,
|
|
90
|
-
queries
|
|
82
|
+
queries,
|
|
83
|
+
pathParams: matches
|
|
91
84
|
});
|
|
92
85
|
}
|
|
93
86
|
this.entities.set(entityName, {
|
|
@@ -42,6 +42,12 @@ export interface IMethodModel {
|
|
|
42
42
|
* @type {IObject[]}
|
|
43
43
|
*/
|
|
44
44
|
queries: IObject[];
|
|
45
|
+
/**
|
|
46
|
+
* 路径参数, 路径示例:/gct-apaas/api/model-comprehensive/model/{key}/{mode}/{modelCategory}
|
|
47
|
+
*
|
|
48
|
+
* @type {string[]}
|
|
49
|
+
*/
|
|
50
|
+
pathParams?: string[];
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* 实体模型
|
|
@@ -42,6 +42,12 @@ export interface IMethodModel {
|
|
|
42
42
|
* @type {IObject[]}
|
|
43
43
|
*/
|
|
44
44
|
queries: IObject[];
|
|
45
|
+
/**
|
|
46
|
+
* 路径参数, 路径示例:/gct-apaas/api/model-comprehensive/model/{key}/{mode}/{modelCategory}
|
|
47
|
+
*
|
|
48
|
+
* @type {string[]}
|
|
49
|
+
*/
|
|
50
|
+
pathParams?: string[];
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* 实体模型
|
|
@@ -76,22 +76,17 @@ export class ModelManage {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
in: "query",
|
|
83
|
-
description: "\u6570\u636E\u4E3B\u952E",
|
|
84
|
-
required: true,
|
|
85
|
-
type: "string"
|
|
86
|
-
});
|
|
87
|
-
}
|
|
79
|
+
const matches = [...config.requestPath.matchAll(/\{([^}]*)\}/g)].map(
|
|
80
|
+
(m) => m[1]
|
|
81
|
+
);
|
|
88
82
|
methods.push({
|
|
89
83
|
name: methodName !== "undefined" ? methodName : "",
|
|
90
84
|
mode,
|
|
91
85
|
model: config,
|
|
92
86
|
requestEntity,
|
|
93
87
|
responseEntity,
|
|
94
|
-
queries
|
|
88
|
+
queries,
|
|
89
|
+
pathParams: matches
|
|
95
90
|
});
|
|
96
91
|
}
|
|
97
92
|
this.entities.set(entityName, {
|
|
@@ -10,8 +10,9 @@ export const apiConfig: any[] = [
|
|
|
10
10
|
mode: '{{ method.mode }}',
|
|
11
11
|
method: '{{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}',
|
|
12
12
|
path: '{{#eq method.name '{id}'}}{{else}}{{method.model.requestPath}}{{/eq}}',
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
{{#gt method.pathParams.length 0}}hasPathParams: true,{{/gt}}
|
|
14
|
+
{{#gt method.queries.length 0}}hasQuery: true,{{/gt}}
|
|
15
|
+
{{#if method.requestEntity}}hasData: true{{/if}}
|
|
15
16
|
},
|
|
16
17
|
{{/each}}
|
|
17
18
|
]
|
|
@@ -11,10 +11,17 @@ export interface {{ method.mode }}{{#if method.name}}{{pascalCase (camelCase met
|
|
|
11
11
|
{{/each}}
|
|
12
12
|
}
|
|
13
13
|
{{/gt}}
|
|
14
|
+
{{#gt method.pathParams.length 0}}
|
|
15
|
+
export interface {{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}PathParams {
|
|
16
|
+
{{#each method.pathParams as |param|}}
|
|
17
|
+
{{camelCase param}}: string;
|
|
18
|
+
{{/each}}
|
|
19
|
+
}
|
|
20
|
+
{{/gt}}
|
|
14
21
|
{{/each}}
|
|
15
22
|
export interface {{pascalCase (camelCase entityName) }}Service {
|
|
16
23
|
{{#each methods as |method|}}
|
|
17
24
|
// {{ method.model.summary }}
|
|
18
|
-
{{ method.mode }}{{#if method.name}}{{pascalCase (camelCase method.name) }}{{/if}}({{#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<
|
|
25
|
+
{{ 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}}unknown{{/if}}>;
|
|
19
26
|
{{/each}}
|
|
20
27
|
}
|
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.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"bin": {
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"unbuild": "^3.6.1"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "2f73ef719a7c5e53eb9c9ebc1f5f46148fda4831"
|
|
70
70
|
}
|