wormajs 0.2.5 → 0.2.7

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.
Files changed (87) hide show
  1. package/README.md +2 -2
  2. package/dist/constant.js +20 -20
  3. package/dist/core/loader/astLoader/generates/tuple.js +1 -1
  4. package/dist/core/loader/astLoader/normalize/index.js +1 -1
  5. package/dist/core/loader/astLoader/normalize/normalizer.js +8 -8
  6. package/dist/core/loader/astLoader/normalize/rules/mergeAnyOf.js +9 -8
  7. package/dist/core/loader/astLoader/normalize/rules/normalizeCombiningKeywords.js +6 -6
  8. package/dist/core/loader/astLoader/normalize/rules/normalizeNullType.js +1 -1
  9. package/dist/core/loader/astLoader/parsers/const.js +4 -4
  10. package/dist/core/loader/astLoader/parsers/enum.js +3 -3
  11. package/dist/core/loader/astLoader/parsers/forward/array.js +3 -3
  12. package/dist/core/loader/astLoader/parsers/forward/const.js +3 -3
  13. package/dist/core/loader/astLoader/parsers/forward/enum.js +2 -2
  14. package/dist/core/loader/astLoader/parsers/forward/group.js +4 -4
  15. package/dist/core/loader/astLoader/parsers/forward/object.js +4 -4
  16. package/dist/core/loader/astLoader/parsers/forward/tuple.js +3 -3
  17. package/dist/core/loader/astLoader/parsers/group.js +1 -1
  18. package/dist/core/loader/astLoader/parsers/tuple.js +2 -2
  19. package/dist/core/loader/standardLoader/helper.js +1 -1
  20. package/dist/core/parser/templateParser/helper.js +5 -5
  21. package/dist/core/parser/templateParser/index.js +9 -7
  22. package/dist/functions/wormaJson.js +2 -2
  23. package/dist/helper/config/ConfigManager.js +10 -10
  24. package/dist/helper/config/zType.js +1 -1
  25. package/dist/helper/document/index.js +11 -11
  26. package/dist/helper/logger/index.js +1 -1
  27. package/dist/helper/template/index.js +9 -9
  28. package/dist/plugins/presets/aiDoc.js +1 -1
  29. package/dist/plugins/presets/apifox.js +2 -2
  30. package/dist/plugins/presets/payloadModifier/index.js +3 -0
  31. package/dist/plugins/presets/rename.js +5 -0
  32. package/dist/readConfig.js +9 -9
  33. package/dist/template/index.js +14 -14
  34. package/dist/template/presets/ai-doc/SKILL.md.handlebars +3 -3
  35. package/dist/template/presets/alova/common/helper.cjs.handlebars +18 -3
  36. package/dist/template/presets/alova/common/services/#index.cjs.handlebars +2 -2
  37. package/dist/template/presets/alova/common/services/{tag}.cjs.handlebars +7 -9
  38. package/dist/template/presets/alova/common/services/{tag}.d.cts.handlebars +5 -7
  39. package/dist/template/presets/alova/module/helper.js.handlebars +17 -2
  40. package/dist/template/presets/alova/module/services/#index.js.handlebars +1 -1
  41. package/dist/template/presets/alova/module/services/{tag}.d.ts.handlebars +5 -7
  42. package/dist/template/presets/alova/module/services/{tag}.js.handlebars +6 -6
  43. package/dist/template/presets/alova/partials/comment.handlebars +11 -2
  44. package/dist/template/presets/alova/partials/extract-responded.handlebars +3 -3
  45. package/dist/template/presets/alova/partials/typed-body.handlebars +3 -1
  46. package/dist/template/presets/alova/typescript/helper.ts.handlebars +11 -6
  47. package/dist/template/presets/alova/typescript/services/#index.ts.handlebars +1 -1
  48. package/dist/template/presets/alova/typescript/services/{tag}.ts.handlebars +6 -8
  49. package/dist/template/presets/alova-globals/partials/comment.handlebars +11 -2
  50. package/dist/template/presets/alova-globals/partials/globals-d-ts.handlebars +1 -1
  51. package/dist/template/presets/axios/common/helper.cjs.handlebars +18 -3
  52. package/dist/template/presets/axios/common/services/#index.cjs.handlebars +2 -2
  53. package/dist/template/presets/axios/common/services/{tag}.cjs.handlebars +25 -28
  54. package/dist/template/presets/axios/common/services/{tag}.d.cts.handlebars +1 -3
  55. package/dist/template/presets/axios/module/helper.js.handlebars +17 -2
  56. package/dist/template/presets/axios/module/services/#index.js.handlebars +2 -2
  57. package/dist/template/presets/axios/module/services/{tag}.d.ts.handlebars +1 -3
  58. package/dist/template/presets/axios/module/services/{tag}.js.handlebars +20 -20
  59. package/dist/template/presets/axios/partials/comment.handlebars +11 -2
  60. package/dist/template/presets/axios/typescript/helper.ts.handlebars +11 -6
  61. package/dist/template/presets/axios/typescript/services/#index.ts.handlebars +1 -1
  62. package/dist/template/presets/axios/typescript/services/{tag}.ts.handlebars +6 -8
  63. package/dist/template/presets/fetch/common/helper.cjs.handlebars +18 -3
  64. package/dist/template/presets/fetch/common/services/#index.cjs.handlebars +2 -2
  65. package/dist/template/presets/fetch/common/services/{tag}.cjs.handlebars +6 -9
  66. package/dist/template/presets/fetch/common/services/{tag}.d.cts.handlebars +1 -3
  67. package/dist/template/presets/fetch/module/helper.js.handlebars +17 -2
  68. package/dist/template/presets/fetch/module/services/#index.js.handlebars +2 -2
  69. package/dist/template/presets/fetch/module/services/{tag}.d.ts.handlebars +1 -3
  70. package/dist/template/presets/fetch/module/services/{tag}.js.handlebars +6 -6
  71. package/dist/template/presets/fetch/partials/comment.handlebars +11 -2
  72. package/dist/template/presets/fetch/typescript/helper.ts.handlebars +11 -6
  73. package/dist/template/presets/fetch/typescript/services/#index.ts.handlebars +1 -1
  74. package/dist/template/presets/fetch/typescript/services/{tag}.ts.handlebars +6 -8
  75. package/dist/template/presets/ky/module/helper.js.handlebars +17 -2
  76. package/dist/template/presets/ky/module/services/#index.js.handlebars +2 -2
  77. package/dist/template/presets/ky/module/services/{tag}.d.ts.handlebars +1 -3
  78. package/dist/template/presets/ky/module/services/{tag}.js.handlebars +6 -6
  79. package/dist/template/presets/ky/partials/comment.handlebars +11 -2
  80. package/dist/template/presets/ky/typescript/helper.ts.handlebars +11 -6
  81. package/dist/template/presets/ky/typescript/services/#index.ts.handlebars +1 -1
  82. package/dist/template/presets/ky/typescript/services/{tag}.ts.handlebars +6 -8
  83. package/dist/utils/base.js +9 -9
  84. package/dist/utils/openapi.js +9 -9
  85. package/package.json +1 -1
  86. package/typings/index.d.ts +1 -1
  87. package/typings/plugins.d.ts +30 -19
@@ -1,4 +1,5 @@
1
1
  {{> comment}}
2
+
2
3
  export function buildPayload(url: string, defaultConfig: Record<string, any>, apiName: string, config: any) {
3
4
  const mergedConfig: any = { ...defaultConfig[apiName], ...config };
4
5
  const pathParams = mergedConfig.pathParams;
@@ -24,15 +25,19 @@ export function buildPayload(url: string, defaultConfig: Record<string, any>, ap
24
25
 
25
26
  export type ServicesMap = {
26
27
  {{#each tagedApis}}
27
- {{{tagName}}}: typeof import('./services/{{{tagName}}}');
28
+ {{{tag}}}: typeof import('./services/{{{tag}}}');
28
29
  {{/each}}
29
30
  };
30
31
 
31
- export const setDefaultConfig = <
32
+ export function setDefaultConfig<
32
33
  T extends keyof ServicesMap,
33
34
  TagedMap extends Record<string, (config: any) => any> = ServicesMap[T],
34
35
  ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }
35
- >(
36
- _: T,
37
- configMap: ConfigMap
38
- ) => configMap;
36
+ >(_: T, configMap: ConfigMap): ConfigMap {
37
+ return configMap;
38
+ }
39
+
40
+ export function resolveTagDefaultConfig<C extends object, Key extends string>(defaultConfig: C, tagName: Key) {
41
+ const raw = (defaultConfig as any)[tagName];
42
+ return (raw || {}) as C extends { [K in Key]: infer V } ? V : {};
43
+ }
@@ -2,5 +2,5 @@
2
2
  import { setDefaultConfig } from '../helper';
3
3
 
4
4
  {{#each tagedApis}}
5
- export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
5
+ export const {{{tag}}}DefaultConfig = setDefaultConfig('{{{tag}}}', {});
6
6
  {{/each}}
@@ -1,13 +1,12 @@
1
1
  {{> comment}}
2
2
  import { fetchClient } from '../index';
3
- import { buildPayload } from '../helper';
3
+ import { buildPayload, resolveTagDefaultConfig } from '../helper';
4
+ import * as defaultConfig from './index';
4
5
  import type * as ComponentTypes from '../components';
5
- {{#each tagedApis}}
6
- import { {{{tagName}}}DefaultConfig } from '.';
7
- {{/each}}
8
6
 
9
- {{#each tagedApis}}
10
- {{#each apis}}
7
+ const {{{currentTag.tag}}}DefaultConfig = resolveTagDefaultConfig(defaultConfig, '{{{currentTag.tag}}}DefaultConfig');
8
+
9
+ {{#each currentTag.apis}}
11
10
  type {{{name}}}Response = {{addNamespace response @root.componentNames}};
12
11
  type {{{name}}}ExtraConfig = Omit<RequestInit, 'body'> & {
13
12
  {{#if pathParameters}}pathParams: {{addNamespace pathParameters @root.componentNames}};
@@ -17,9 +16,8 @@ type {{{name}}}ExtraConfig = Omit<RequestInit, 'body'> & {
17
16
  };
18
17
  {{> api-jsdoc}}
19
18
  export async function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
20
- const { url, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
19
+ const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
21
20
  return fetchClient.request(url, { method: '{{method}}', ...mergedConfig{{#if (eq response "Blob")}}, blob: true{{/if}} }) as Promise<{{{name}}}Response>;
22
21
  }
23
22
 
24
23
  {{/each}}
25
- {{/each}}
@@ -1,4 +1,5 @@
1
1
  {{> comment}}
2
+
2
3
  export function buildPayload(url, defaultConfig, apiName, config) {
3
4
  const mergedConfig = { ...defaultConfig[apiName], ...config };
4
5
  const pathParams = mergedConfig.pathParams;
@@ -27,7 +28,7 @@ export function buildPayload(url, defaultConfig, apiName, config) {
27
28
  /**
28
29
  * @typedef {{#raw "{{" }}{{/raw}}
29
30
  {{#each tagedApis}}
30
- * {{{tagName}}}: typeof import('./services/{{{tagName}}}')
31
+ * {{{tag}}}: typeof import('./services/{{{tag}}}')
31
32
  {{/each}}
32
33
  * {{#raw "}}" }}{{/raw}} ServicesMap
33
34
  */
@@ -40,4 +41,18 @@ export function buildPayload(url, defaultConfig, apiName, config) {
40
41
  * @param {ConfigMap} configMap
41
42
  * @returns {ConfigMap}
42
43
  */
43
- export const setDefaultConfig = (_, configMap) => configMap;
44
+ export function setDefaultConfig(_, configMap) {
45
+ return configMap;
46
+ }
47
+
48
+ /**
49
+ * @template {object} C
50
+ * @template {string} Key
51
+ * @param {C} defaultConfig
52
+ * @param {Key} tagName
53
+ * @returns {C extends { [K in Key]: infer V } ? V : {}}
54
+ */
55
+ export function resolveTagDefaultConfig(defaultConfig, tagName) {
56
+ const raw = defaultConfig[tagName];
57
+ return raw || {};
58
+ }
@@ -1,6 +1,6 @@
1
1
  {{> comment}}
2
- import { setDefaultConfig } from '../helper';
2
+ import { setDefaultConfig } from '../helper.js';
3
3
 
4
4
  {{#each tagedApis}}
5
- export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
5
+ export const {{{tag}}}DefaultConfig = setDefaultConfig('{{{tag}}}', {});
6
6
  {{/each}}
@@ -1,11 +1,9 @@
1
1
  import type { Options } from 'ky';
2
2
  import type * as ComponentTypes from '../components';
3
3
 
4
- {{#each tagedApis}}
5
- {{#each apis}}
4
+ {{#each currentTag.apis}}
6
5
  {{> dts-types}}
7
6
  {{> api-jsdoc}}
8
7
  {{> dts-fn-declare}}
9
8
 
10
9
  {{/each}}
11
- {{/each}}
@@ -1,13 +1,14 @@
1
1
  {{> comment}}
2
2
  import { kyInstance } from '../index.js';
3
- import { buildPayload } from '../helper.js';
4
- import { {{currentTag.tagName}}DefaultConfig } from './index.js';
3
+ import { buildPayload, resolveTagDefaultConfig } from '../helper.js';
4
+ import * as defaultConfig from './index.js';
5
5
 
6
- {{#each tagedApis}}
7
- {{#each apis}}
6
+ const {{currentTag.tag}}DefaultConfig = resolveTagDefaultConfig(defaultConfig, '{{currentTag.tag}}DefaultConfig');
7
+
8
+ {{#each currentTag.apis}}
8
9
  {{> api-jsdoc}}
9
10
  export function {{{name}}}(config = {}) {
10
- const { url, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
11
+ const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
11
12
  const resolvedPath = url.replace(/^\//, '');
12
13
  return kyInstance(resolvedPath, {
13
14
  method: '{{method}}',
@@ -16,4 +17,3 @@ export function {{{name}}}(config = {}) {
16
17
  }
17
18
 
18
19
  {{/each}}
19
- {{/each}}
@@ -1,5 +1,9 @@
1
- /* tslint:disable */
2
1
  /* eslint-disable */
2
+ /* biome-ignore-all */
3
+ /* stylelint-disable */
4
+ /* editorconfig-checker-disable-file */
5
+ /* oxlint-disable */
6
+ /* oxcformat-ignore */
3
7
  /**
4
8
  * {{title}} - version {{version}}
5
9
  *
@@ -13,7 +17,12 @@
13
17
  *
14
18
  * NOTE: This file is auto generated by the alova's vscode plugin.
15
19
  *
16
- * https://alova.js.org/devtools/vscode
20
+ * https://worma.js.org
17
21
  *
22
+ {{#if noOverwrite}}
23
+ * NOTE: This file is generated only once and will NOT be overwritten on regeneration.
24
+ * You can safely customize it to fit your needs.
25
+ {{else}}
18
26
  * **Do not edit the file manually.**
27
+ {{/if}}
19
28
  */
@@ -1,4 +1,5 @@
1
1
  {{> comment}}
2
+
2
3
  export function buildPayload(url: string, defaultConfig: Record<string, any>, apiName: string, config: any) {
3
4
  const mergedConfig: any = { ...defaultConfig[apiName], ...config };
4
5
  const pathParams = mergedConfig.pathParams;
@@ -26,15 +27,19 @@ export function buildPayload(url: string, defaultConfig: Record<string, any>, ap
26
27
 
27
28
  export type ServicesMap = {
28
29
  {{#each tagedApis}}
29
- {{{tagName}}}: typeof import('./services/{{{tagName}}}');
30
+ {{{tag}}}: typeof import('./services/{{{tag}}}');
30
31
  {{/each}}
31
32
  };
32
33
 
33
- export const setDefaultConfig = <
34
+ export function setDefaultConfig<
34
35
  T extends keyof ServicesMap,
35
36
  TagedMap extends Record<string, (config: any) => any> = ServicesMap[T],
36
37
  ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }
37
- >(
38
- _: T,
39
- configMap: ConfigMap
40
- ) => configMap;
38
+ >(_: T, configMap: ConfigMap): ConfigMap {
39
+ return configMap;
40
+ }
41
+
42
+ export function resolveTagDefaultConfig<C extends object, Key extends string>(defaultConfig: C, tagName: Key) {
43
+ const raw = (defaultConfig as any)[tagName];
44
+ return (raw || {}) as C extends { [K in Key]: infer V } ? V : {};
45
+ }
@@ -2,5 +2,5 @@
2
2
  import { setDefaultConfig } from '../helper';
3
3
 
4
4
  {{#each tagedApis}}
5
- export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
5
+ export const {{{tag}}}DefaultConfig = setDefaultConfig('{{{tag}}}', {});
6
6
  {{/each}}
@@ -1,14 +1,13 @@
1
1
  {{> comment}}
2
2
  import type { Options } from 'ky';
3
3
  import { kyInstance } from '../index';
4
- import { buildPayload } from '../helper';
4
+ import { buildPayload, resolveTagDefaultConfig } from '../helper';
5
+ import * as defaultConfig from './index';
5
6
  import type * as ComponentTypes from '../components';
6
- {{#each tagedApis}}
7
- import { {{{tagName}}}DefaultConfig } from '.';
8
- {{/each}}
9
7
 
10
- {{#each tagedApis}}
11
- {{#each apis}}
8
+ const {{{currentTag.tag}}}DefaultConfig = resolveTagDefaultConfig(defaultConfig, '{{{currentTag.tag}}}DefaultConfig');
9
+
10
+ {{#each currentTag.apis}}
12
11
  type {{{name}}}Response = {{addNamespace response @root.componentNames}};
13
12
  type {{{name}}}ExtraConfig = Options & {
14
13
  {{#if pathParameters}}pathParams: {{addNamespace pathParameters @root.componentNames}};
@@ -18,7 +17,7 @@ type {{{name}}}ExtraConfig = Options & {
18
17
  };
19
18
  {{> api-jsdoc}}
20
19
  export function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
21
- const { url, mergedConfig } = buildPayload('{{{path}}}', {{{tag}}}DefaultConfig, {{{name}}}.name, config);
20
+ const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
22
21
  const resolvedPath = url.replace(/^\//, '');
23
22
  return kyInstance(resolvedPath, {
24
23
  method: '{{method}}',
@@ -27,4 +26,3 @@ export function {{{name}}}(config{{#or pathParameters queryParameters requestBod
27
26
  }
28
27
 
29
28
  {{/each}}
30
- {{/each}}
@@ -143,12 +143,12 @@ function strHashCode(str) {
143
143
  return hash;
144
144
  }
145
145
  function getType(value) {
146
- // 处理 null undefined
146
+ // handle null and undefined
147
147
  if (value === null)
148
148
  return 'null';
149
149
  if (value === undefined)
150
150
  return 'undefined';
151
- // 基本类型
151
+ // primitive types
152
152
  const type = typeof value;
153
153
  if (type !== 'object' && type !== 'function') {
154
154
  if (type === 'number' && Number.isNaN(value))
@@ -161,7 +161,7 @@ function getType(value) {
161
161
  }
162
162
  return type;
163
163
  }
164
- // 特殊对象类型
164
+ // special object types
165
165
  if (Array.isArray(value))
166
166
  return 'Array';
167
167
  if (value instanceof Date)
@@ -176,7 +176,7 @@ function getType(value) {
176
176
  return 'Promise';
177
177
  if (value instanceof Error)
178
178
  return 'Error';
179
- // 函数类型
179
+ // function types
180
180
  if (typeof value === 'function') {
181
181
  if (value.constructor.name === 'AsyncFunction')
182
182
  return 'AsyncFunction';
@@ -184,19 +184,19 @@ function getType(value) {
184
184
  return 'GeneratorFunction';
185
185
  return 'Function';
186
186
  }
187
- // 其他对象类型
187
+ // other object types
188
188
  const tag = Object.prototype.toString.call(value).slice(8, -1);
189
189
  if (tag !== 'Object')
190
190
  return tag;
191
- // 自定义类实例
191
+ // custom class instances
192
192
  if (value.constructor && value.constructor !== Object) {
193
193
  return `Class (${value.constructor.name})`;
194
194
  }
195
- // 普通对象
195
+ // plain object
196
196
  return 'Object';
197
197
  }
198
198
  /**
199
- * 获取用户已安装的依赖列表
199
+ * Get the list of dependencies installed by the user
200
200
  */
201
201
  async function getUserInstalledDependencies(projectPath) {
202
202
  const { readPackageJson } = await Promise.resolve().then(() => __importStar(require('../utils/readPackageJson')));
@@ -207,6 +207,6 @@ async function getUserInstalledDependencies(projectPath) {
207
207
  const dependencies = Object.keys(packageJson.dependencies || {});
208
208
  const devDependencies = Object.keys(packageJson.devDependencies || {});
209
209
  const peerDependencies = Object.keys(packageJson.peerDependencies || {});
210
- // 合并所有依赖并去重
210
+ // merge all dependencies and deduplicate
211
211
  return [...new Set([...dependencies, ...devDependencies, ...peerDependencies])];
212
212
  }
@@ -127,11 +127,11 @@ function get$refName(path, toUpperCase = true) {
127
127
  * @returns Removed $ref object
128
128
  */
129
129
  /**
130
- * M2-B1: $ref 解引用缓存优化 —— 命中 searchMap 时跳过 cloneDeep
130
+ * M2-B1: $ref dereference cache optimization — skip cloneDeep when searchMap is hit
131
131
  */
132
132
  function removeAll$ref(schemaOrigin, openApi, optons) {
133
133
  const { searchMap = new Map(), refNameMap = new Map() } = optons ?? {};
134
- // 先检查缓存,命中则直接返回(避免 cloneDeep 开销)
134
+ // check the cache first; return directly on hit (avoid cloneDeep overhead)
135
135
  if (isReferenceObject(schemaOrigin)) {
136
136
  if (searchMap.has(schemaOrigin.$ref)) {
137
137
  return searchMap.get(schemaOrigin.$ref);
@@ -148,7 +148,7 @@ function removeAll$ref(schemaOrigin, openApi, optons) {
148
148
  }
149
149
  return schema;
150
150
  }
151
- // 非 $ref 节点:仍需 cloneDeep 防止污染原始文档,但子节点走 searchMap 去重
151
+ // non-$ref nodes: still cloneDeep to avoid mutating the original document, but children go through searchMap for deduplication
152
152
  const deepSchemaOrigin = (0, lodash_1.cloneDeep)(schemaOrigin);
153
153
  for (const key of Object.keys(deepSchemaOrigin)) {
154
154
  if (deepSchemaOrigin[key] && typeof deepSchemaOrigin[key] === 'object') {
@@ -234,10 +234,10 @@ function next$ref() {
234
234
  };
235
235
  }
236
236
  /**
237
- * 根据 usedRefs 优化 refsMap:
238
- * 1) 移除未使用的 key;
239
- * 2) 同组(相同 basePath+onlyName)内按版本升序将值左移,
240
- * 即剩余键依次接收原始值的前 N 个(N 为剩余键数量)。
237
+ * Optimize refsMap based on usedRefs:
238
+ * 1) remove unused keys;
239
+ * 2) within the same group (same basePath+onlyName), shift values left in ascending version order,
240
+ * i.e. remaining keys receive the first N original values (N = number of remaining keys).
241
241
  */
242
242
  function optimizeRefsMap(refsMap, usedRefs) {
243
243
  const helper = next$ref();
@@ -336,7 +336,7 @@ function removeBaseReference(obj, options) {
336
336
  function unCircular(obj, options) {
337
337
  const { openApi, map = [], objPath = '$', seen = new WeakMap(), refNameMap = new Map() } = options;
338
338
  if (typeof obj !== 'object' || obj === null) {
339
- return obj; // 原始值直接返回
339
+ return obj; // return the primitive value directly
340
340
  }
341
341
  if (seen.has(obj)) {
342
342
  return seen.get(obj);
@@ -402,7 +402,7 @@ function mergeObject(objValue, srcValue, options) {
402
402
  }
403
403
  return srcValue;
404
404
  }
405
- // M2-B1: mergeWith 自身不污染首参(返回新对象),去掉冗余 cloneDeep
405
+ // M2-B1: mergeWith does not mutate the first argument (returns a new object), removed redundant cloneDeep
406
406
  return (0, lodash_1.mergeWith)(objValue, srcValue, customizer);
407
407
  }
408
408
  function getResponseSuccessKey(responsesObject) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wormajs",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "A modern OpenAPI code generator - Generate type-safe API clients from OpenAPI specs",
5
5
  "author": "worma",
6
6
  "license": "MIT",
@@ -348,7 +348,7 @@ export interface Api {
348
348
  }
349
349
  export interface ApiDoc {
350
350
  apis: Api[];
351
- tagName: string;
351
+ tag: string;
352
352
  }
353
353
  export type ApiDescriptor = Omit<OperationObject, "requestBody" | "parameters" | "responses"> & {
354
354
  url: string;
@@ -368,7 +368,7 @@ export interface Api {
368
368
  }
369
369
  export interface ApiDoc {
370
370
  apis: Api[];
371
- tagName: string;
371
+ tag: string;
372
372
  }
373
373
  export type ApiDescriptor = Omit<OperationObject, "requestBody" | "parameters" | "responses"> & {
374
374
  url: string;
@@ -589,6 +589,11 @@ export interface ModifierConfig {
589
589
  * The scope the modifier applies to (which parameter location to process).
590
590
  */
591
591
  scope: ModifierScope;
592
+ /**
593
+ * API path filter: this config applies only when `apiDescriptor.url` matches;
594
+ * when omitted it applies to all APIs. Matching rules are the same as `match` (string substring / RegExp / function).
595
+ */
596
+ path?: string | RegExp | ((url: string) => boolean);
592
597
  /**
593
598
  * Match rule. Only matched fields are transformed; when omitted, all fields are transformed.
594
599
  * - string: the original field name contains this string
@@ -665,19 +670,19 @@ export declare const knife4j: (input: string | string[]) => ApiPlugin;
665
670
  */
666
671
  export declare const swagger: (input: string | string[]) => ApiPlugin;
667
672
  export interface YapiOptions {
668
- /** YApi 服务基础地址,例如 `https://yapi.xxx.com` */
673
+ /** YApi server base address, e.g. `https://yapi.xxx.com` */
669
674
  url: string;
670
- /** 项目 ID,必填,用于拼装导出地址 */
675
+ /** Project ID, required, used to build the export address */
671
676
  pid: string | number;
672
- /** OpenAPI 类型,默认 `OpenAPIV2` */
677
+ /** OpenAPI type, defaults to `OpenAPIV2` */
673
678
  type?: string;
674
- /** 接口状态,默认 `all` */
679
+ /** API status, defaults to `all` */
675
680
  status?: string;
676
- /** 是否包含 wiki,默认 `true` */
681
+ /** Whether to include wiki, defaults to `true` */
677
682
  isWiki?: boolean;
678
- /** 登录 cookie。也可通过 fetchOptions.headers.cookie 传入 */
683
+ /** Login cookie. Can also be passed via fetchOptions.headers.cookie */
679
684
  cookie?: string;
680
- /** 额外的 fetch 超时(毫秒) */
685
+ /** Extra fetch timeout in milliseconds */
681
686
  timeout?: number;
682
687
  }
683
688
  /**
@@ -726,6 +731,12 @@ export interface RenameConfig {
726
731
  * Target scope for renaming, defaults to 'url'
727
732
  */
728
733
  scope?: "url" | "params" | "pathParams" | "data" | "response" | "refName" | "name";
734
+ /**
735
+ * API path filter. When set, this config only takes effect on descriptors
736
+ * whose `url` matches the rule; otherwise the descriptor is returned unchanged.
737
+ * The rule can be a string (substring match), RegExp, or (url: string) => boolean.
738
+ */
739
+ path?: string | RegExp | ((url: string) => boolean);
729
740
  /**
730
741
  * Matching rule for selective renaming:
731
742
  * - string: target contains this string
@@ -789,32 +800,32 @@ export declare function processApiTags(apiDescriptor: ApiDescriptor, handler: Mo
789
800
  */
790
801
  export declare function tagModifier(handler: ModifierHandler): ApiPlugin;
791
802
  /**
792
- * worma.config 模板预设 - plugin mode
803
+ * worma.config template preset - plugin mode
793
804
  */
794
805
  export declare function config(): ApiPlugin;
795
806
  /**
796
- * globals 模板预设 - plugin mode
797
- * 全局模板,现有的全局模板,通过全局挂载的方式使用
807
+ * globals template preset - plugin mode
808
+ * Global template: an existing global template, used via global mounting
798
809
  */
799
810
  export declare function alovaGlobals(opts?: GlobalsTemplateOptions): ApiPlugin;
800
811
  /**
801
- * functional 模板预设 - plugin mode
802
- * 函数式模板,生成函数式API调用,支持tree-shaking,仅支持alova v3
812
+ * functional template preset - plugin mode
813
+ * Functional template that generates functional API calls, supports tree-shaking, only for alova v3
803
814
  */
804
815
  export declare function alova(opts?: FunctionalTemplateOptions): ApiPlugin;
805
816
  /**
806
- * axios 模板预设 - plugin mode
807
- * Axios相关模板
817
+ * axios template preset - plugin mode
818
+ * Axios-related template
808
819
  */
809
820
  export declare function axios(opts?: RequestLibTemplateOptions): ApiPlugin;
810
821
  /**
811
- * fetch 模板预设 - plugin mode
812
- * Fetch相关模板
822
+ * fetch template preset - plugin mode
823
+ * Fetch-related template
813
824
  */
814
825
  declare function fetch$1(opts?: RequestLibTemplateOptions): ApiPlugin;
815
826
  /**
816
- * ky 模板预设 - plugin mode
817
- * Ky相关模板
827
+ * ky template preset - plugin mode
828
+ * Ky-related template
818
829
  */
819
830
  export declare function ky(opts?: RequestLibTemplateOptions): ApiPlugin;
820
831