wormajs 0.2.1 → 0.2.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/dist/core/loader/astLoader/generates/tuple.js +8 -4
- package/dist/core/loader/astLoader/parsers/array.js +1 -1
- package/dist/core/loader/astLoader/parsers/forward/tuple.js +7 -2
- package/dist/core/loader/astLoader/parsers/simple.js +4 -0
- package/dist/core/loader/astLoader/parsers/tuple.js +14 -1
- package/dist/core/loader/astLoader/parsers/utils.js +7 -1
- package/dist/core/workerPool/worker.js +2 -1
- package/dist/template/presets/alova/common/helper.cjs.handlebars +13 -4
- package/dist/template/presets/alova/common/services/#index.cjs.handlebars +1 -4
- package/dist/template/presets/alova/module/helper.js.handlebars +13 -4
- package/dist/template/presets/alova/module/services/#index.js.handlebars +1 -4
- package/dist/template/presets/alova/typescript/helper.ts.handlebars +14 -3
- package/dist/template/presets/alova/typescript/services/#index.ts.handlebars +1 -4
- package/dist/template/presets/alova-globals/common/createApis.cjs.handlebars +1 -1
- package/dist/template/presets/alova-globals/partials/withConfigType-jsdoc.handlebars +1 -1
- package/dist/template/presets/axios/common/helper.cjs.handlebars +13 -4
- package/dist/template/presets/axios/common/services/#index.cjs.handlebars +1 -4
- package/dist/template/presets/axios/module/helper.js.handlebars +13 -4
- package/dist/template/presets/axios/module/services/#index.js.handlebars +2 -5
- package/dist/template/presets/axios/typescript/helper.ts.handlebars +13 -3
- package/dist/template/presets/axios/typescript/services/#index.ts.handlebars +1 -4
- package/dist/template/presets/fetch/common/helper.cjs.handlebars +13 -4
- package/dist/template/presets/fetch/common/services/#index.cjs.handlebars +1 -4
- package/dist/template/presets/fetch/module/helper.js.handlebars +13 -4
- package/dist/template/presets/fetch/module/services/#index.js.handlebars +2 -5
- package/dist/template/presets/fetch/typescript/helper.ts.handlebars +13 -3
- package/dist/template/presets/fetch/typescript/services/#index.ts.handlebars +1 -4
- package/dist/template/presets/ky/module/helper.js.handlebars +13 -4
- package/dist/template/presets/ky/module/services/#index.js.handlebars +2 -5
- package/dist/template/presets/ky/typescript/helper.ts.handlebars +13 -3
- package/dist/template/presets/ky/typescript/services/#index.ts.handlebars +1 -4
- package/package.json +1 -1
|
@@ -16,8 +16,12 @@ function tupleTypeGenerator(ast, ctx) {
|
|
|
16
16
|
const spreadParam = ast.spreadParam ?? {
|
|
17
17
|
type: type_1.ASTType.ANY,
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// 封闭元组(禁止额外项)时不展开剩余项
|
|
20
|
+
const isClosed = spreadParam.type === type_1.ASTType.NEVER;
|
|
21
|
+
if (!isClosed) {
|
|
22
|
+
while (params.length < minItems) {
|
|
23
|
+
params.push(spreadParam);
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
const lines = [`[`];
|
|
23
27
|
params.forEach((param, idx, arr) => {
|
|
@@ -26,12 +30,12 @@ function tupleTypeGenerator(ast, ctx) {
|
|
|
26
30
|
const endText = idx === arr.length - 1 ? '' : ',';
|
|
27
31
|
`${value}${endText}`.split('\n').forEach(line => lines.push(` ${line}`));
|
|
28
32
|
});
|
|
29
|
-
if (maxItems < minItems) {
|
|
33
|
+
if (maxItems < minItems && !isClosed) {
|
|
30
34
|
ctx.pathKey = spreadParam.keyName;
|
|
31
35
|
lines.push(`,\n...Array<${(0, utils_1.getValue)(ctx.next(spreadParam, ctx.options), ctx.options)}>`);
|
|
32
36
|
}
|
|
33
37
|
lines.push(`]`);
|
|
34
|
-
if (maxItems > minItems) {
|
|
38
|
+
if (maxItems > minItems && !isClosed) {
|
|
35
39
|
const nextParams = [...params];
|
|
36
40
|
for (let i = 0; i < maxItems - minItems; i += 1) {
|
|
37
41
|
nextParams.push(spreadParam);
|
|
@@ -6,7 +6,7 @@ const type_1 = require("../../../../type");
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
function arrayTypeParser(schema, ctx) {
|
|
8
8
|
ctx.pathKey = '[]';
|
|
9
|
-
const itemsAst = ctx.next(schema.items, ctx.options);
|
|
9
|
+
const itemsAst = ctx.next(schema.items || { type: 'any' }, ctx.options);
|
|
10
10
|
const result = {
|
|
11
11
|
...(0, utils_1.initAST)(schema, ctx),
|
|
12
12
|
type: type_1.ASTType.ARRAY,
|
|
@@ -4,8 +4,13 @@ exports.default = {
|
|
|
4
4
|
is(schema) {
|
|
5
5
|
// 判断是否为元组类型
|
|
6
6
|
// 1. type 为 'array'
|
|
7
|
-
// 2. 且 items
|
|
8
|
-
|
|
7
|
+
// 2. 且 items 是数组(老版 JSON Schema 元组语法)或存在 prefixItems(OpenAPI 3.1 / JSON Schema 2020-12 元组语法)
|
|
8
|
+
if (!schema)
|
|
9
|
+
return false;
|
|
10
|
+
const tuple = schema;
|
|
11
|
+
const isItemsArray = Array.isArray(tuple.items) && tuple.items.length > 0;
|
|
12
|
+
const isPrefixItems = Array.isArray(tuple.prefixItems) && tuple.prefixItems.length > 0;
|
|
13
|
+
return schema.type === 'array' && (isItemsArray || isPrefixItems);
|
|
9
14
|
},
|
|
10
15
|
to: 'tuple',
|
|
11
16
|
};
|
|
@@ -19,6 +19,10 @@ function stringTypeParser(schema, init) {
|
|
|
19
19
|
}
|
|
20
20
|
function simpleTypeParser(schema, ctx) {
|
|
21
21
|
const result = (0, utils_1.initAST)(schema, ctx);
|
|
22
|
+
if (!schema) {
|
|
23
|
+
result.type = type_1.ASTType.NULL;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
22
26
|
switch (schema.type) {
|
|
23
27
|
case 'boolean':
|
|
24
28
|
result.type = type_1.ASTType.BOOLEAN;
|
|
@@ -5,13 +5,26 @@ const helper_1 = require("../../../../helper");
|
|
|
5
5
|
const type_1 = require("../../../../type");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
function tupleTypeParser(schema, ctx) {
|
|
8
|
-
|
|
8
|
+
// OpenAPI 3.1 / JSON Schema 2020-12 用 prefixItems 表示固定位置元素,兼容老版 items 数组写法
|
|
9
|
+
const elementSchemas = (Array.isArray(schema.prefixItems)
|
|
10
|
+
? schema.prefixItems
|
|
11
|
+
: (Array.isArray(schema.items) ? schema.items : []));
|
|
12
|
+
const params = elementSchemas.map(item => ctx.next(item, ctx.options));
|
|
13
|
+
// 2020-12:单数 items 表示"剩余项"类型;items:false / additionalItems:false 表示禁止额外项
|
|
14
|
+
let spreadParam;
|
|
15
|
+
if (schema.items && !Array.isArray(schema.items)) {
|
|
16
|
+
spreadParam = ctx.next(schema.items, ctx.options);
|
|
17
|
+
}
|
|
18
|
+
else if (schema.additionalItems === false || schema.items === false) {
|
|
19
|
+
spreadParam = { type: type_1.ASTType.NEVER };
|
|
20
|
+
}
|
|
9
21
|
const result = {
|
|
10
22
|
...(0, utils_1.initAST)(schema, ctx),
|
|
11
23
|
type: type_1.ASTType.TUPLE,
|
|
12
24
|
minItems: schema.minItems,
|
|
13
25
|
maxItems: schema.maxItems,
|
|
14
26
|
params,
|
|
27
|
+
spreadParam,
|
|
15
28
|
};
|
|
16
29
|
const deepCommenter = helper_1.CommentHelper.load({
|
|
17
30
|
type: ctx.options.commentType,
|
|
@@ -12,6 +12,9 @@ const forward_1 = require("./forward");
|
|
|
12
12
|
exports.SchemaPrimitive = ['boolean', 'object', 'number', 'string', 'integer', 'array', 'null'];
|
|
13
13
|
function getCommentBySchema(schema, options) {
|
|
14
14
|
const commenter = helper_1.CommentHelper.load(options);
|
|
15
|
+
if (!schema) {
|
|
16
|
+
return commenter.end();
|
|
17
|
+
}
|
|
15
18
|
if (!(0, utils_1.isReferenceObject)(schema) && schema.title) {
|
|
16
19
|
commenter.add('[title]', schema.title);
|
|
17
20
|
}
|
|
@@ -30,7 +33,7 @@ function initAST(schema, ctx) {
|
|
|
30
33
|
type: ctx.options.commentType,
|
|
31
34
|
}),
|
|
32
35
|
keyName: ctx.keyName,
|
|
33
|
-
deprecated: (0, utils_1.isReferenceObject)(schema) ?
|
|
36
|
+
deprecated: schema && !(0, utils_1.isReferenceObject)(schema) ? schema.deprecated : false,
|
|
34
37
|
};
|
|
35
38
|
ctx.keyName = '';
|
|
36
39
|
return result;
|
|
@@ -44,6 +47,9 @@ function parse(schema, options) {
|
|
|
44
47
|
return null;
|
|
45
48
|
}
|
|
46
49
|
function getParserSchemaType(schema) {
|
|
50
|
+
if (!schema) {
|
|
51
|
+
return 'null';
|
|
52
|
+
}
|
|
47
53
|
if ((0, utils_1.isReferenceObject)(schema)) {
|
|
48
54
|
return 'reference';
|
|
49
55
|
}
|
|
@@ -55,6 +55,7 @@ node_worker_threads_1.parentPort?.on('message', async (batch) => {
|
|
|
55
55
|
node_worker_threads_1.parentPort?.postMessage({ type: 'result', data: allResults });
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
|
-
|
|
58
|
+
const error = err;
|
|
59
|
+
node_worker_threads_1.parentPort?.postMessage({ type: 'error', message: error.message });
|
|
59
60
|
}
|
|
60
61
|
});
|
|
@@ -4,10 +4,19 @@ function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
7
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
8
|
+
{{#each tagedApis}}
|
|
9
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}.cjs')
|
|
10
|
+
{{/each}}
|
|
11
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @template {keyof ServicesMap} T
|
|
16
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
17
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
18
|
+
* @param {T} _
|
|
19
|
+
* @param {ConfigMap} configMap
|
|
11
20
|
* @returns {ConfigMap}
|
|
12
21
|
*/
|
|
13
22
|
const setMethodDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
const { setMethodDefaultConfig } = require('../helper.cjs');
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
const {{{tagName}}} = require('./{{{tagName}}}.cjs');
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
const {{{tagName}}}DefaultConfig = setMethodDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
const {{{tagName}}}DefaultConfig = setMethodDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
10
7
|
|
|
11
8
|
{{#each tagedApis}}
|
|
@@ -4,10 +4,19 @@ export function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
7
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
8
|
+
{{#each tagedApis}}
|
|
9
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}')
|
|
10
|
+
{{/each}}
|
|
11
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @template {keyof ServicesMap} T
|
|
16
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
17
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
18
|
+
* @param {T} _
|
|
19
|
+
* @param {ConfigMap} configMap
|
|
11
20
|
* @returns {ConfigMap}
|
|
12
21
|
*/
|
|
13
22
|
export const setMethodDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { setMethodDefaultConfig } from '../helper.js';
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}.js';
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setMethodDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setMethodDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -3,7 +3,18 @@ export function buildPayload(url: string, defaultConfig: Record<string, any>, ap
|
|
|
3
3
|
{{> build-payload-body}}
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
export type ServicesMap = {
|
|
7
|
+
{{#each tagedApis}}
|
|
8
|
+
{{{tagName}}}: typeof import('./services/{{{tagName}}}');
|
|
9
|
+
{{/each}}
|
|
10
|
+
};
|
|
11
|
+
|
|
6
12
|
export const setMethodDefaultConfig = <
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
T extends keyof ServicesMap,
|
|
14
|
+
TagedMap extends Record<string, (config: any) => any> = ServicesMap[T],
|
|
15
|
+
ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }
|
|
16
|
+
>(
|
|
17
|
+
_: T,
|
|
18
|
+
configMap: ConfigMap
|
|
19
|
+
) => configMap;
|
|
20
|
+
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { setMethodDefaultConfig } from '../helper';
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}';
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setMethodDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setMethodDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -30,7 +30,7 @@ const mountApis = (Apis) => {
|
|
|
30
30
|
{{> withConfigType-jsdoc}}
|
|
31
31
|
/**
|
|
32
32
|
* @typedef {{#raw "{{ " }}{{/raw}}
|
|
33
|
-
* [P in keyof typeof import('./apiDefinitions')]?: MethodConfig<
|
|
33
|
+
* [P in keyof typeof import('./apiDefinitions.cjs')]?: MethodConfig<
|
|
34
34
|
* P extends `${infer Tag}.${infer Url}`
|
|
35
35
|
* ? Parameters<NonNullable<APISofParameters<Tag,Url>[0]>['transform']>[0]
|
|
36
36
|
* : any
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @template T
|
|
3
3
|
* @typedef {import('alova').AlovaMethodCreateConfig<
|
|
4
|
-
* typeof import('./index')['alovaInstance'] extends import('alova').Alova<infer AG>
|
|
4
|
+
* typeof import('./index{{#if (eq type "commonjs")}}.cjs{{/if}}')['alovaInstance'] extends import('alova').Alova<infer AG>
|
|
5
5
|
* ? AG
|
|
6
6
|
* : any,
|
|
7
7
|
* any,
|
|
@@ -23,10 +23,19 @@ function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
26
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
27
|
+
{{#each tagedApis}}
|
|
28
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}.cjs')
|
|
29
|
+
{{/each}}
|
|
30
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @template {keyof ServicesMap} T
|
|
35
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
36
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
37
|
+
* @param {T} _
|
|
38
|
+
* @param {ConfigMap} configMap
|
|
30
39
|
* @returns {ConfigMap}
|
|
31
40
|
*/
|
|
32
41
|
const setDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
const { setDefaultConfig } = require('../helper.cjs');
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
const {{{tagName}}} = require('./{{{tagName}}}.cjs');
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
10
7
|
|
|
11
8
|
{{#each tagedApis}}
|
|
@@ -23,10 +23,19 @@ export function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
26
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
27
|
+
{{#each tagedApis}}
|
|
28
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}')
|
|
29
|
+
{{/each}}
|
|
30
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @template {keyof ServicesMap} T
|
|
35
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
36
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
37
|
+
* @param {T} _
|
|
38
|
+
* @param {ConfigMap} configMap
|
|
30
39
|
* @returns {ConfigMap}
|
|
31
40
|
*/
|
|
32
41
|
export const setDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
|
-
import { setDefaultConfig } from '../helper
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}.js';
|
|
5
|
-
{{/each}}
|
|
2
|
+
import { setDefaultConfig } from '../helper';
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -22,7 +22,17 @@ export function buildPayload(url: string, defaultConfig: Record<string, any>, ap
|
|
|
22
22
|
return { url: resolvedUrl, mergedConfig };
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export type ServicesMap = {
|
|
26
|
+
{{#each tagedApis}}
|
|
27
|
+
{{{tagName}}}: typeof import('./services/{{{tagName}}}');
|
|
28
|
+
{{/each}}
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
export const setDefaultConfig = <
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
T extends keyof ServicesMap,
|
|
33
|
+
TagedMap extends Record<string, (config: any) => any> = ServicesMap[T],
|
|
34
|
+
ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }
|
|
35
|
+
>(
|
|
36
|
+
_: T,
|
|
37
|
+
configMap: ConfigMap
|
|
38
|
+
) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { setDefaultConfig } from '../helper';
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}';
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -23,10 +23,19 @@ function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
26
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
27
|
+
{{#each tagedApis}}
|
|
28
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}.cjs')
|
|
29
|
+
{{/each}}
|
|
30
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @template {keyof ServicesMap} T
|
|
35
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
36
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
37
|
+
* @param {T} _
|
|
38
|
+
* @param {ConfigMap} configMap
|
|
30
39
|
* @returns {ConfigMap}
|
|
31
40
|
*/
|
|
32
41
|
const setDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
const { setDefaultConfig } = require('../helper.cjs');
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
const {{{tagName}}} = require('./{{{tagName}}}.cjs');
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
10
7
|
|
|
11
8
|
{{#each tagedApis}}
|
|
@@ -23,10 +23,19 @@ export function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
26
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
27
|
+
{{#each tagedApis}}
|
|
28
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}')
|
|
29
|
+
{{/each}}
|
|
30
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @template {keyof ServicesMap} T
|
|
35
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
36
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
37
|
+
* @param {T} _
|
|
38
|
+
* @param {ConfigMap} configMap
|
|
30
39
|
* @returns {ConfigMap}
|
|
31
40
|
*/
|
|
32
41
|
export const setDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
|
-
import { setDefaultConfig } from '../helper
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}.js';
|
|
5
|
-
{{/each}}
|
|
2
|
+
import { setDefaultConfig } from '../helper';
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -22,7 +22,17 @@ export function buildPayload(url: string, defaultConfig: Record<string, any>, ap
|
|
|
22
22
|
return { url: resolvedUrl, mergedConfig };
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export type ServicesMap = {
|
|
26
|
+
{{#each tagedApis}}
|
|
27
|
+
{{{tagName}}}: typeof import('./services/{{{tagName}}}');
|
|
28
|
+
{{/each}}
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
export const setDefaultConfig = <
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
T extends keyof ServicesMap,
|
|
33
|
+
TagedMap extends Record<string, (config: any) => any> = ServicesMap[T],
|
|
34
|
+
ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }
|
|
35
|
+
>(
|
|
36
|
+
_: T,
|
|
37
|
+
configMap: ConfigMap
|
|
38
|
+
) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { setDefaultConfig } from '../helper';
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}';
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -25,10 +25,19 @@ export function buildPayload(url, defaultConfig, apiName, config) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
|
|
28
|
+
* @typedef {{#raw "{{" }}{{/raw}}
|
|
29
|
+
{{#each tagedApis}}
|
|
30
|
+
* {{{tagName}}}: typeof import('./services/{{{tagName}}}')
|
|
31
|
+
{{/each}}
|
|
32
|
+
* {{#raw "}}" }}{{/raw}} ServicesMap
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @template {keyof ServicesMap} T
|
|
37
|
+
* @template {Record<string, (config: any) => any>} [TagedMap = ServicesMap[T]]
|
|
38
|
+
* @template [ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }]
|
|
39
|
+
* @param {T} _
|
|
40
|
+
* @param {ConfigMap} configMap
|
|
32
41
|
* @returns {ConfigMap}
|
|
33
42
|
*/
|
|
34
43
|
export const setDefaultConfig = (_, configMap) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
|
-
import { setDefaultConfig } from '../helper
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}.js';
|
|
5
|
-
{{/each}}
|
|
2
|
+
import { setDefaultConfig } from '../helper';
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|
|
@@ -24,7 +24,17 @@ export function buildPayload(url: string, defaultConfig: Record<string, any>, ap
|
|
|
24
24
|
return { url: resolvedUrl, mergedConfig };
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export type ServicesMap = {
|
|
28
|
+
{{#each tagedApis}}
|
|
29
|
+
{{{tagName}}}: typeof import('./services/{{{tagName}}}');
|
|
30
|
+
{{/each}}
|
|
31
|
+
};
|
|
32
|
+
|
|
27
33
|
export const setDefaultConfig = <
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
T extends keyof ServicesMap,
|
|
35
|
+
TagedMap extends Record<string, (config: any) => any> = ServicesMap[T],
|
|
36
|
+
ConfigMap = { [K in keyof TagedMap]?: Partial<Parameters<TagedMap[K]>[0]> }
|
|
37
|
+
>(
|
|
38
|
+
_: T,
|
|
39
|
+
configMap: ConfigMap
|
|
40
|
+
) => configMap;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{{> comment}}
|
|
2
2
|
import { setDefaultConfig } from '../helper';
|
|
3
|
-
{{#each tagedApis}}
|
|
4
|
-
import * as {{{tagName}}} from './{{{tagName}}}';
|
|
5
|
-
{{/each}}
|
|
6
3
|
|
|
7
4
|
{{#each tagedApis}}
|
|
8
|
-
export const {{{tagName}}}DefaultConfig = setDefaultConfig({{{tagName}}}, {});
|
|
5
|
+
export const {{{tagName}}}DefaultConfig = setDefaultConfig('{{{tagName}}}', {});
|
|
9
6
|
{{/each}}
|