@jayfong/x-server 2.94.1 → 2.95.1

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.
@@ -129,9 +129,13 @@ class ApiGenerator {
129
129
  });
130
130
  const requestDataJsonSchema = this.apiDataToJsonSchema(requestData);
131
131
  const responseDataJsonSchema = this.apiDataToJsonSchema(responseData);
132
+ const handlerDescriptionDividerIndex = handlerDescription.indexOf('\n\n');
133
+ const apiName = handlerDescriptionDividerIndex === -1 ? handlerDescription : handlerDescription.substring(0, handlerDescriptionDividerIndex);
134
+ const apiDesc = handlerDescriptionDividerIndex === -1 ? '' : handlerDescription.substring(handlerDescriptionDividerIndex + 2);
132
135
  apiData.push({
133
136
  category: handlerCategory,
134
- name: handlerDescription,
137
+ name: apiName,
138
+ desc: apiDesc,
135
139
  path: handlerUrl,
136
140
  handlerMethod: handlerMethod,
137
141
  method: httpMethod,
@@ -311,6 +315,7 @@ class ApiGenerator {
311
315
  data[handle.category].push(handle.handlerMethod === 'GET' ? {
312
316
  method: handle.method.toUpperCase(),
313
317
  title: handle.name,
318
+ markdown: handle.desc,
314
319
  path: path,
315
320
  res_body_type: 'json',
316
321
  req_body_is_json_schema: false,
@@ -328,6 +333,7 @@ class ApiGenerator {
328
333
  } : handle.handlerMethod === 'FILE' ? {
329
334
  method: handle.method.toUpperCase(),
330
335
  title: handle.name,
336
+ markdown: handle.desc,
331
337
  path: path,
332
338
  req_body_type: 'form',
333
339
  res_body_type: 'json',
@@ -346,6 +352,7 @@ class ApiGenerator {
346
352
  } : {
347
353
  method: handle.method.toUpperCase(),
348
354
  title: handle.name,
355
+ markdown: handle.desc,
349
356
  path: path,
350
357
  req_body_type: 'json',
351
358
  res_body_type: 'json',
@@ -388,6 +395,7 @@ class ApiGenerator {
388
395
  [handle.method.toLowerCase()]: {
389
396
  tags: [handle.category],
390
397
  summary: handle.name,
398
+ description: handle.desc,
391
399
  requestBody: {
392
400
  content: {
393
401
  'application/json': {
@@ -213,10 +213,12 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
213
213
  noInstall: argv['local-install'] === false,
214
214
  channel: channel,
215
215
  excludeFiles: (argv.exclude ? (0, _vtils.castArray)(argv.exclude) : []).map(item => {
216
- return _vtils.StringTemplate.render(item, envMap, {
216
+ return _vtils.StringTemplate.render(item, {
217
+ ...envMap,
218
+ _: _vtils.escapeRegExp
219
+ }, {
217
220
  code: true,
218
- onlyCode: true,
219
- beforeReplace: v => (0, _vtils.escapeRegExp)(v)
221
+ onlyCode: true
220
222
  });
221
223
  }),
222
224
  prismaCliBinaryTargets: envMap.PRISMA_CLI_BINARY_TARGETS,
@@ -23,6 +23,7 @@ type ApiDto = {
23
23
  type ApiData = {
24
24
  category: string;
25
25
  name: string;
26
+ desc: string;
26
27
  path: string[];
27
28
  handlerMethod: XHandler.Method;
28
29
  method: string;
@@ -124,9 +124,13 @@ export class ApiGenerator {
124
124
  });
125
125
  const requestDataJsonSchema = this.apiDataToJsonSchema(requestData);
126
126
  const responseDataJsonSchema = this.apiDataToJsonSchema(responseData);
127
+ const handlerDescriptionDividerIndex = handlerDescription.indexOf('\n\n');
128
+ const apiName = handlerDescriptionDividerIndex === -1 ? handlerDescription : handlerDescription.substring(0, handlerDescriptionDividerIndex);
129
+ const apiDesc = handlerDescriptionDividerIndex === -1 ? '' : handlerDescription.substring(handlerDescriptionDividerIndex + 2);
127
130
  apiData.push({
128
131
  category: handlerCategory,
129
- name: handlerDescription,
132
+ name: apiName,
133
+ desc: apiDesc,
130
134
  path: handlerUrl,
131
135
  handlerMethod: handlerMethod,
132
136
  method: httpMethod,
@@ -306,6 +310,7 @@ export class ApiGenerator {
306
310
  data[handle.category].push(handle.handlerMethod === 'GET' ? {
307
311
  method: handle.method.toUpperCase(),
308
312
  title: handle.name,
313
+ markdown: handle.desc,
309
314
  path: path,
310
315
  res_body_type: 'json',
311
316
  req_body_is_json_schema: false,
@@ -323,6 +328,7 @@ export class ApiGenerator {
323
328
  } : handle.handlerMethod === 'FILE' ? {
324
329
  method: handle.method.toUpperCase(),
325
330
  title: handle.name,
331
+ markdown: handle.desc,
326
332
  path: path,
327
333
  req_body_type: 'form',
328
334
  res_body_type: 'json',
@@ -341,6 +347,7 @@ export class ApiGenerator {
341
347
  } : {
342
348
  method: handle.method.toUpperCase(),
343
349
  title: handle.name,
350
+ markdown: handle.desc,
344
351
  path: path,
345
352
  req_body_type: 'json',
346
353
  res_body_type: 'json',
@@ -383,6 +390,7 @@ export class ApiGenerator {
383
390
  [handle.method.toLowerCase()]: {
384
391
  tags: [handle.category],
385
392
  summary: handle.name,
393
+ description: handle.desc,
386
394
  requestBody: {
387
395
  content: {
388
396
  'application/json': {
package/lib/cli/cli.js CHANGED
@@ -211,10 +211,12 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
211
211
  noInstall: argv['local-install'] === false,
212
212
  channel: channel,
213
213
  excludeFiles: (argv.exclude ? castArray(argv.exclude) : []).map(item => {
214
- return StringTemplate.render(item, envMap, {
214
+ return StringTemplate.render(item, {
215
+ ...envMap,
216
+ _: escapeRegExp
217
+ }, {
215
218
  code: true,
216
- onlyCode: true,
217
- beforeReplace: v => escapeRegExp(v)
219
+ onlyCode: true
218
220
  });
219
221
  }),
220
222
  prismaCliBinaryTargets: envMap.PRISMA_CLI_BINARY_TARGETS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.94.1",
3
+ "version": "2.95.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",