wormajs 0.2.4 → 0.2.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/bin/renderer.js +8 -2
- package/dist/constant.js +20 -20
- package/dist/core/WorkerPool.js +5 -3
- package/dist/core/loader/astLoader/generates/tuple.js +1 -1
- package/dist/core/loader/astLoader/index.js +1 -3
- package/dist/core/loader/astLoader/normalize/index.js +1 -1
- package/dist/core/loader/astLoader/normalize/normalizer.js +9 -11
- package/dist/core/loader/astLoader/normalize/rules/mergeAnyOf.js +9 -8
- package/dist/core/loader/astLoader/normalize/rules/normalizeCombiningKeywords.js +6 -6
- package/dist/core/loader/astLoader/normalize/rules/normalizeNullType.js +1 -1
- package/dist/core/loader/astLoader/parsers/const.js +4 -4
- package/dist/core/loader/astLoader/parsers/enum.js +3 -3
- package/dist/core/loader/astLoader/parsers/forward/array.js +3 -3
- package/dist/core/loader/astLoader/parsers/forward/const.js +3 -3
- package/dist/core/loader/astLoader/parsers/forward/enum.js +2 -2
- package/dist/core/loader/astLoader/parsers/forward/group.js +4 -4
- package/dist/core/loader/astLoader/parsers/forward/object.js +4 -4
- package/dist/core/loader/astLoader/parsers/forward/tuple.js +3 -3
- package/dist/core/loader/astLoader/parsers/group.js +1 -1
- package/dist/core/loader/astLoader/parsers/tuple.js +2 -2
- package/dist/core/loader/callingCodeLoader/index.js +1 -3
- package/dist/core/loader/schemaLoader/index.js +1 -3
- package/dist/core/loader/standardLoader/helper.js +1 -1
- package/dist/core/loader/standardLoader/index.js +1 -3
- package/dist/core/parser/openApiParser/index.js +1 -3
- package/dist/core/parser/templateParser/helper.js +5 -5
- package/dist/core/parser/templateParser/index.js +14 -14
- package/dist/core/workerPool/poolManager.js +3 -3
- package/dist/functions/wormaJson.js +2 -2
- package/dist/helper/PluginDriver.js +2 -0
- package/dist/helper/comment.js +18 -20
- package/dist/helper/config/ConfigHelper.js +2 -3
- package/dist/helper/config/ConfigManager.js +16 -14
- package/dist/helper/config/GeneratorHelper.js +15 -13
- package/dist/helper/config/zType.js +1 -1
- package/dist/helper/document/index.js +13 -14
- package/dist/helper/logger/index.js +6 -8
- package/dist/helper/progress.js +5 -3
- package/dist/helper/template/index.js +13 -11
- package/dist/plugins/presets/aiDoc.js +1 -1
- package/dist/plugins/presets/apifox.js +2 -2
- package/dist/plugins/presets/payloadModifier/index.js +3 -0
- package/dist/plugins/presets/rename.js +5 -0
- package/dist/readConfig.js +9 -9
- package/dist/template/index.js +14 -14
- package/dist/template/presets/ai-doc/SKILL.md.handlebars +3 -3
- package/dist/template/presets/alova/common/helper.cjs.handlebars +18 -3
- package/dist/template/presets/alova/common/services/#index.cjs.handlebars +2 -2
- package/dist/template/presets/alova/common/services/{tag}.cjs.handlebars +7 -9
- package/dist/template/presets/alova/common/services/{tag}.d.cts.handlebars +5 -7
- package/dist/template/presets/alova/module/helper.js.handlebars +17 -2
- package/dist/template/presets/alova/module/services/#index.js.handlebars +1 -1
- package/dist/template/presets/alova/module/services/{tag}.d.ts.handlebars +5 -7
- package/dist/template/presets/alova/module/services/{tag}.js.handlebars +6 -6
- package/dist/template/presets/alova/partials/comment.handlebars +11 -2
- package/dist/template/presets/alova/partials/dts-fn-declare.handlebars +1 -1
- package/dist/template/presets/alova/partials/extract-responded.handlebars +3 -3
- package/dist/template/presets/alova/partials/typed-body.handlebars +3 -1
- package/dist/template/presets/alova/typescript/helper.ts.handlebars +11 -6
- package/dist/template/presets/alova/typescript/services/#index.ts.handlebars +1 -1
- package/dist/template/presets/alova/typescript/services/{tag}.ts.handlebars +7 -9
- package/dist/template/presets/alova-globals/partials/comment.handlebars +11 -2
- package/dist/template/presets/alova-globals/partials/globals-d-ts.handlebars +1 -1
- package/dist/template/presets/axios/common/helper.cjs.handlebars +18 -3
- package/dist/template/presets/axios/common/services/#index.cjs.handlebars +2 -2
- package/dist/template/presets/axios/common/services/{tag}.cjs.handlebars +25 -28
- package/dist/template/presets/axios/common/services/{tag}.d.cts.handlebars +1 -3
- package/dist/template/presets/axios/module/helper.js.handlebars +17 -2
- package/dist/template/presets/axios/module/services/#index.js.handlebars +2 -2
- package/dist/template/presets/axios/module/services/{tag}.d.ts.handlebars +1 -3
- package/dist/template/presets/axios/module/services/{tag}.js.handlebars +20 -20
- package/dist/template/presets/axios/partials/comment.handlebars +11 -2
- package/dist/template/presets/axios/partials/dts-fn-declare.handlebars +1 -1
- package/dist/template/presets/axios/typescript/helper.ts.handlebars +11 -6
- package/dist/template/presets/axios/typescript/services/#index.ts.handlebars +1 -1
- package/dist/template/presets/axios/typescript/services/{tag}.ts.handlebars +7 -9
- package/dist/template/presets/fetch/common/helper.cjs.handlebars +18 -3
- package/dist/template/presets/fetch/common/services/#index.cjs.handlebars +2 -2
- package/dist/template/presets/fetch/common/services/{tag}.cjs.handlebars +6 -9
- package/dist/template/presets/fetch/common/services/{tag}.d.cts.handlebars +1 -3
- package/dist/template/presets/fetch/module/helper.js.handlebars +17 -2
- package/dist/template/presets/fetch/module/services/#index.js.handlebars +2 -2
- package/dist/template/presets/fetch/module/services/{tag}.d.ts.handlebars +1 -3
- package/dist/template/presets/fetch/module/services/{tag}.js.handlebars +6 -6
- package/dist/template/presets/fetch/partials/comment.handlebars +11 -2
- package/dist/template/presets/fetch/partials/dts-fn-declare.handlebars +1 -1
- package/dist/template/presets/fetch/typescript/helper.ts.handlebars +11 -6
- package/dist/template/presets/fetch/typescript/services/#index.ts.handlebars +1 -1
- package/dist/template/presets/fetch/typescript/services/{tag}.ts.handlebars +7 -9
- package/dist/template/presets/ky/module/helper.js.handlebars +17 -2
- package/dist/template/presets/ky/module/services/#index.js.handlebars +2 -2
- package/dist/template/presets/ky/module/services/{tag}.d.ts.handlebars +1 -3
- package/dist/template/presets/ky/module/services/{tag}.js.handlebars +6 -6
- package/dist/template/presets/ky/partials/comment.handlebars +11 -2
- package/dist/template/presets/ky/partials/dts-fn-declare.handlebars +1 -1
- package/dist/template/presets/ky/typescript/helper.ts.handlebars +11 -6
- package/dist/template/presets/ky/typescript/services/#index.ts.handlebars +1 -1
- package/dist/template/presets/ky/typescript/services/{tag}.ts.handlebars +7 -9
- package/dist/utils/base.js +9 -9
- package/dist/utils/openapi.js +15 -15
- package/package.json +2 -2
- package/typings/index.d.ts +1 -1
- package/typings/plugins.d.ts +30 -19
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{{> comment}}
|
|
2
|
-
import { axiosInstance } from '../index.js';
|
|
3
|
-
import { buildPayload } from '../helper.js';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
{{
|
|
7
|
-
|
|
8
|
-
{{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{{/each}}
|
|
1
|
+
{{> comment}}
|
|
2
|
+
import { axiosInstance } from '../index.js';
|
|
3
|
+
import { buildPayload, resolveTagDefaultConfig } from '../helper.js';
|
|
4
|
+
import * as defaultConfig from './index.js';
|
|
5
|
+
|
|
6
|
+
const {{currentTag.tag}}DefaultConfig = resolveTagDefaultConfig(defaultConfig, '{{currentTag.tag}}DefaultConfig');
|
|
7
|
+
|
|
8
|
+
{{#each currentTag.apis}}
|
|
9
|
+
{{> api-jsdoc}}
|
|
10
|
+
export function {{{name}}}(config = {}) {
|
|
11
|
+
const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
|
|
12
|
+
return axiosInstance({
|
|
13
|
+
method: '{{method}}',
|
|
14
|
+
url,
|
|
15
|
+
...mergedConfig,{{#if (eq response "Blob")}}
|
|
16
|
+
responseType: 'blob',{{/if}}
|
|
17
|
+
}){{#if (eq response "Blob")}}.then(data => data instanceof Blob ? data : new Blob([data])){{/if}};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
{{/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://
|
|
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 +1 @@
|
|
|
1
|
-
export declare function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
|
|
1
|
+
export declare function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
|
|
@@ -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
|
-
{{{
|
|
28
|
+
{{{tag}}}: typeof import('./services/{{{tag}}}');
|
|
28
29
|
{{/each}}
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import type { AxiosRequestConfig } from 'axios';
|
|
3
3
|
import { axiosInstance } 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
|
-
{{
|
|
11
|
-
|
|
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 = Omit<AxiosRequestConfig, 'data' | 'params'> & {
|
|
14
13
|
{{#if pathParameters}}pathParams: {{addNamespace pathParameters @root.componentNames}};
|
|
@@ -17,8 +16,8 @@ type {{{name}}}ExtraConfig = Omit<AxiosRequestConfig, 'data' | 'params'> & {
|
|
|
17
16
|
{{/if}}
|
|
18
17
|
};
|
|
19
18
|
{{> api-jsdoc}}
|
|
20
|
-
export function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
|
|
21
|
-
const { url, mergedConfig } = buildPayload('{{{path}}}', {{
|
|
19
|
+
export function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
|
|
20
|
+
const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
|
|
22
21
|
return axiosInstance<unknown, {{{name}}}Response>({
|
|
23
22
|
method: '{{method}}',
|
|
24
23
|
url,
|
|
@@ -28,4 +27,3 @@ export function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Res
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
{{/each}}
|
|
31
|
-
{{/each}}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
|
+
|
|
2
3
|
function buildPayload(url, defaultConfig, apiName, config) {
|
|
3
4
|
const mergedConfig = { ...defaultConfig[apiName], ...config };
|
|
4
5
|
const pathParams = mergedConfig.pathParams;
|
|
@@ -25,7 +26,7 @@ function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
25
26
|
/**
|
|
26
27
|
* @typedef {{#raw "{{" }}{{/raw}}
|
|
27
28
|
{{#each tagedApis}}
|
|
28
|
-
* {{{
|
|
29
|
+
* {{{tag}}}: typeof import('./services/{{{tag}}}.cjs')
|
|
29
30
|
{{/each}}
|
|
30
31
|
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
31
32
|
*/
|
|
@@ -38,6 +39,20 @@ function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
38
39
|
* @param {ConfigMap} configMap
|
|
39
40
|
* @returns {ConfigMap}
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
function setDefaultConfig(_, configMap) {
|
|
43
|
+
return configMap;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @template {object} C
|
|
48
|
+
* @template {string} Key
|
|
49
|
+
* @param {C} defaultConfig
|
|
50
|
+
* @param {Key} tagName
|
|
51
|
+
* @returns {C extends { [K in Key]: infer V } ? V : {}}
|
|
52
|
+
*/
|
|
53
|
+
function resolveTagDefaultConfig(defaultConfig, tagName) {
|
|
54
|
+
const raw = defaultConfig[tagName];
|
|
55
|
+
return raw || {};
|
|
56
|
+
}
|
|
42
57
|
|
|
43
|
-
module.exports = { buildPayload, setDefaultConfig };
|
|
58
|
+
module.exports = { buildPayload, setDefaultConfig, resolveTagDefaultConfig };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
const { setDefaultConfig } = require('../helper.cjs');
|
|
3
3
|
|
|
4
4
|
{{#each tagedApis}}
|
|
5
|
-
const {{{
|
|
5
|
+
const {{{tag}}}DefaultConfig = setDefaultConfig('{{{tag}}}', {});
|
|
6
6
|
{{/each}}
|
|
7
7
|
|
|
8
8
|
{{#each tagedApis}}
|
|
9
|
-
module.exports.{{{
|
|
9
|
+
module.exports.{{{tag}}}DefaultConfig = {{{tag}}}DefaultConfig;
|
|
10
10
|
{{/each}}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
const { fetchClient } = require('../index.cjs');
|
|
3
|
-
const { buildPayload } = require('../helper.cjs');
|
|
4
|
-
const
|
|
3
|
+
const { buildPayload, resolveTagDefaultConfig } = require('../helper.cjs');
|
|
4
|
+
const defaultConfig = require('./index.cjs');
|
|
5
5
|
|
|
6
|
+
const {{{currentTag.tag}}}DefaultConfig = resolveTagDefaultConfig(defaultConfig, '{{{currentTag.tag}}}DefaultConfig');
|
|
6
7
|
|
|
7
|
-
{{#each
|
|
8
|
-
{{#each apis}}
|
|
8
|
+
{{#each currentTag.apis}}
|
|
9
9
|
{{> api-jsdoc}}
|
|
10
10
|
async function {{{name}}}(config = {}) {
|
|
11
|
-
const { url, mergedConfig } = buildPayload('{{{path}}}',
|
|
11
|
+
const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
|
|
12
12
|
return fetchClient.request(url, { method: '{{method}}', ...mergedConfig{{#if (eq response "Blob")}}, blob: true{{/if}} });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
{{/each}}
|
|
16
15
|
{{/each}}
|
|
17
16
|
module.exports = {
|
|
18
|
-
{{#each
|
|
19
|
-
{{#each apis}}
|
|
17
|
+
{{#each currentTag.apis}}
|
|
20
18
|
{{{name}}},
|
|
21
19
|
{{/each}}
|
|
22
|
-
{{/each}}
|
|
23
20
|
};
|
|
@@ -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;
|
|
@@ -25,7 +26,7 @@ export function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
25
26
|
/**
|
|
26
27
|
* @typedef {{#raw "{{" }}{{/raw}}
|
|
27
28
|
{{#each tagedApis}}
|
|
28
|
-
* {{{
|
|
29
|
+
* {{{tag}}}: typeof import('./services/{{{tag}}}')
|
|
29
30
|
{{/each}}
|
|
30
31
|
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
31
32
|
*/
|
|
@@ -38,4 +39,18 @@ export function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
38
39
|
* @param {ConfigMap} configMap
|
|
39
40
|
* @returns {ConfigMap}
|
|
40
41
|
*/
|
|
41
|
-
export
|
|
42
|
+
export function setDefaultConfig(_, configMap) {
|
|
43
|
+
return configMap;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @template {object} C
|
|
48
|
+
* @template {string} Key
|
|
49
|
+
* @param {C} defaultConfig
|
|
50
|
+
* @param {Key} tagName
|
|
51
|
+
* @returns {C extends { [K in Key]: infer V } ? V : {}}
|
|
52
|
+
*/
|
|
53
|
+
export function resolveTagDefaultConfig(defaultConfig, tagName) {
|
|
54
|
+
const raw = defaultConfig[tagName];
|
|
55
|
+
return raw || {};
|
|
56
|
+
}
|
|
@@ -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 {{{
|
|
5
|
+
export const {{{tag}}}DefaultConfig = setDefaultConfig('{{{tag}}}', {});
|
|
6
6
|
{{/each}}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { fetchClient } from '../index.js';
|
|
3
|
-
import { buildPayload } from '../helper.js';
|
|
4
|
-
import
|
|
3
|
+
import { buildPayload, resolveTagDefaultConfig } from '../helper.js';
|
|
4
|
+
import * as defaultConfig from './index.js';
|
|
5
5
|
|
|
6
|
-
{{
|
|
7
|
-
|
|
6
|
+
const {{currentTag.tag}}DefaultConfig = resolveTagDefaultConfig(defaultConfig, '{{currentTag.tag}}DefaultConfig');
|
|
7
|
+
|
|
8
|
+
{{#each currentTag.apis}}
|
|
8
9
|
{{> api-jsdoc}}
|
|
9
10
|
export async function {{{name}}}(config = {}) {
|
|
10
|
-
const { url, mergedConfig } = buildPayload('{{{path}}}', {{
|
|
11
|
+
const { url, mergedConfig } = buildPayload('{{{path}}}', {{../currentTag.tag}}DefaultConfig, {{{name}}}.name, config);
|
|
11
12
|
return fetchClient.request(url, { method: '{{method}}', ...mergedConfig{{#if (eq response "Blob")}}, blob: true{{/if}} });
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
{{/each}}
|
|
15
|
-
{{/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://
|
|
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 +1 @@
|
|
|
1
|
-
export declare function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
|
|
1
|
+
export declare function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
|
|
@@ -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
|
-
{{{
|
|
28
|
+
{{{tag}}}: typeof import('./services/{{{tag}}}');
|
|
28
29
|
{{/each}}
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|
|
@@ -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
|
-
{{
|
|
10
|
-
|
|
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}};
|
|
@@ -16,10 +15,9 @@ type {{{name}}}ExtraConfig = Omit<RequestInit, 'body'> & {
|
|
|
16
15
|
{{/if}}
|
|
17
16
|
};
|
|
18
17
|
{{> api-jsdoc}}
|
|
19
|
-
export async function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
|
|
20
|
-
const { url, mergedConfig } = buildPayload('{{{path}}}', {{
|
|
18
|
+
export async function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
|
|
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
|
-
* {{{
|
|
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
|
|
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 {{{
|
|
5
|
+
export const {{{tag}}}DefaultConfig = setDefaultConfig('{{{tag}}}', {});
|
|
6
6
|
{{/each}}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { kyInstance } from '../index.js';
|
|
3
|
-
import { buildPayload } from '../helper.js';
|
|
4
|
-
import
|
|
3
|
+
import { buildPayload, resolveTagDefaultConfig } from '../helper.js';
|
|
4
|
+
import * as defaultConfig from './index.js';
|
|
5
5
|
|
|
6
|
-
{{
|
|
7
|
-
|
|
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}}}', {{
|
|
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://
|
|
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 +1 @@
|
|
|
1
|
-
export declare function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
|
|
1
|
+
export declare function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response>;
|
|
@@ -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
|
-
{{{
|
|
30
|
+
{{{tag}}}: typeof import('./services/{{{tag}}}');
|
|
30
31
|
{{/each}}
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
export
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
}
|
|
@@ -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
|
-
{{
|
|
11
|
-
|
|
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}};
|
|
@@ -17,8 +16,8 @@ type {{{name}}}ExtraConfig = Options & {
|
|
|
17
16
|
{{/if}}
|
|
18
17
|
};
|
|
19
18
|
{{> api-jsdoc}}
|
|
20
|
-
export function {{{name}}}(config: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
|
|
21
|
-
const { url, mergedConfig } = buildPayload('{{{path}}}', {{
|
|
19
|
+
export function {{{name}}}(config{{#or pathParameters queryParameters requestBody }}{{else}}?{{/or}}: {{{name}}}ExtraConfig): Promise<{{{name}}}Response> {
|
|
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: {{{name}}}ExtraConfig): Promise<{{{name}}}Res
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
{{/each}}
|
|
30
|
-
{{/each}}
|