@jayfong/x-server 1.27.0 → 1.27.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.27.3](https://github.com/jfWorks/x-server/compare/v1.27.2...v1.27.3) (2022-05-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * api gen ([5e0086f](https://github.com/jfWorks/x-server/commit/5e0086f166bf629f0a68ddea367816abf40197f0))
11
+
12
+ ### [1.27.2](https://github.com/jfWorks/x-server/compare/v1.27.1...v1.27.2) (2022-05-11)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * api gen GET ([601d94a](https://github.com/jfWorks/x-server/commit/601d94a9abd4a33a91f805dae74a0a471ba2cd59))
18
+
19
+ ### [1.27.1](https://github.com/jfWorks/x-server/compare/v1.27.0...v1.27.1) (2022-05-08)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * api ([d30109c](https://github.com/jfWorks/x-server/commit/d30109ce90db1f3f9c513b9867be6123bc6373e6))
25
+
5
26
  ## [1.27.0](https://github.com/jfWorks/x-server/compare/v1.26.9...v1.27.0) (2022-05-07)
6
27
 
7
28
 
@@ -186,7 +186,24 @@ class ApiGenerator {
186
186
 
187
187
  for (const handle of handles) {
188
188
  data[handle.category] = data[handle.category] || [];
189
- data[handle.category].push(handle.handlerMethod === 'FILE' ? {
189
+ data[handle.category].push(handle.handlerMethod === 'GET' ? {
190
+ method: handle.method.toUpperCase(),
191
+ title: handle.name,
192
+ path: handle.path,
193
+ res_body_type: 'json',
194
+ req_body_is_json_schema: false,
195
+ res_body_is_json_schema: true,
196
+ req_params: [],
197
+ req_query: handle.requestData.children.map(item => ({
198
+ required: item.required ? 1 : 0,
199
+ name: item.name,
200
+ desc: item.desc,
201
+ type: 'string'
202
+ })),
203
+ req_headers: [],
204
+ req_body_form: [],
205
+ res_body: JSON.stringify(handle.responseDataJsonSchema)
206
+ } : handle.handlerMethod === 'FILE' ? {
190
207
  method: handle.method.toUpperCase(),
191
208
  title: handle.name,
192
209
  path: handle.path,
@@ -200,6 +217,7 @@ class ApiGenerator {
200
217
  req_body_form: handle.requestData.children.map(item => ({
201
218
  required: item.required ? 1 : 0,
202
219
  name: item.name,
220
+ desc: item.desc,
203
221
  type: item.type === 'file' ? 'file' : 'text'
204
222
  })),
205
223
  res_body: JSON.stringify(handle.responseDataJsonSchema)
@@ -241,7 +259,7 @@ class ApiGenerator {
241
259
 
242
260
  for (const handlerList of handlerGroup) {
243
261
  const handlerListSourceFile = this.getTypeBySymbol(handlerList).getProperties()[0].getDeclarations()[0].getSourceFile();
244
- const basePath = `/${(0, _vtils.snakeCase)(handlerListSourceFile.getFilePath().replace('.ts', '').split('/src/handlers/')[1]).replace(/_/g, '/')}/`.replace(/\/{2,}/g, '/');
262
+ const basePath = `/${handlerListSourceFile.getFilePath().replace('.ts', '').split('/src/handlers/')[1].replace(/(^|\/)index$/, '/').split('/').map(v => (0, _vtils.snakeCase)(v)).join('/')}/`.replace(/\/{2,}/g, '/');
245
263
 
246
264
  for (const handler of handlerListSourceFile.getVariableStatements().filter(item => item.isExported())) {
247
265
  // 重要:这一步必须,先调一遍 getText 获取看到的对象,后续对于复杂定义才不会报错
@@ -259,7 +277,7 @@ class ApiGenerator {
259
277
  continue;
260
278
  }
261
279
 
262
- const handlerCategory = (0, _vtils.pascalCase)(basePath) || 'ROOT';
280
+ const handlerCategory = (0, _vtils.pascalCase)(basePath) || 'Index';
263
281
  const handlerName = handlerComment.description || handlerPath;
264
282
  const handlerMethod = methodType.getLiteralValueOrThrow();
265
283
  const serverMethod = _http_method.HandlerMethodToHttpMethod[handlerMethod];
@@ -170,7 +170,24 @@ export class ApiGenerator {
170
170
 
171
171
  for (const handle of handles) {
172
172
  data[handle.category] = data[handle.category] || [];
173
- data[handle.category].push(handle.handlerMethod === 'FILE' ? {
173
+ data[handle.category].push(handle.handlerMethod === 'GET' ? {
174
+ method: handle.method.toUpperCase(),
175
+ title: handle.name,
176
+ path: handle.path,
177
+ res_body_type: 'json',
178
+ req_body_is_json_schema: false,
179
+ res_body_is_json_schema: true,
180
+ req_params: [],
181
+ req_query: handle.requestData.children.map(item => ({
182
+ required: item.required ? 1 : 0,
183
+ name: item.name,
184
+ desc: item.desc,
185
+ type: 'string'
186
+ })),
187
+ req_headers: [],
188
+ req_body_form: [],
189
+ res_body: JSON.stringify(handle.responseDataJsonSchema)
190
+ } : handle.handlerMethod === 'FILE' ? {
174
191
  method: handle.method.toUpperCase(),
175
192
  title: handle.name,
176
193
  path: handle.path,
@@ -184,6 +201,7 @@ export class ApiGenerator {
184
201
  req_body_form: handle.requestData.children.map(item => ({
185
202
  required: item.required ? 1 : 0,
186
203
  name: item.name,
204
+ desc: item.desc,
187
205
  type: item.type === 'file' ? 'file' : 'text'
188
206
  })),
189
207
  res_body: JSON.stringify(handle.responseDataJsonSchema)
@@ -225,7 +243,7 @@ export class ApiGenerator {
225
243
 
226
244
  for (const handlerList of handlerGroup) {
227
245
  const handlerListSourceFile = this.getTypeBySymbol(handlerList).getProperties()[0].getDeclarations()[0].getSourceFile();
228
- const basePath = `/${snakeCase(handlerListSourceFile.getFilePath().replace('.ts', '').split('/src/handlers/')[1]).replace(/_/g, '/')}/`.replace(/\/{2,}/g, '/');
246
+ const basePath = `/${handlerListSourceFile.getFilePath().replace('.ts', '').split('/src/handlers/')[1].replace(/(^|\/)index$/, '/').split('/').map(v => snakeCase(v)).join('/')}/`.replace(/\/{2,}/g, '/');
229
247
 
230
248
  for (const handler of handlerListSourceFile.getVariableStatements().filter(item => item.isExported())) {
231
249
  // 重要:这一步必须,先调一遍 getText 获取看到的对象,后续对于复杂定义才不会报错
@@ -243,7 +261,7 @@ export class ApiGenerator {
243
261
  continue;
244
262
  }
245
263
 
246
- const handlerCategory = pascalCase(basePath) || 'ROOT';
264
+ const handlerCategory = pascalCase(basePath) || 'Index';
247
265
  const handlerName = handlerComment.description || handlerPath;
248
266
  const handlerMethod = methodType.getLiteralValueOrThrow();
249
267
  const serverMethod = HandlerMethodToHttpMethod[handlerMethod];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "1.27.0",
3
+ "version": "1.27.3",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",