yapi-apifox-to-typescript 4.1.1 → 4.1.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/lib/cjs/ApifoxToYApiData.js +1 -1
- package/lib/cjs/Generator.js +7 -6
- package/lib/cjs/utils.js +16 -5
- package/lib/esm/ApifoxToYApiData.js +1 -1
- package/lib/esm/Generator.js +7 -6
- package/lib/esm/utils.js +16 -5
- package/package.json +1 -1
|
@@ -142,7 +142,7 @@ var ApifoxToYApiData = /*#__PURE__*/function () {
|
|
|
142
142
|
;
|
|
143
143
|
|
|
144
144
|
_proto.getCats = function getCats(cats) {
|
|
145
|
-
var categoryIds = (0, _utils.getFilteredCat)(cats, []); // 对cat进行有效性过滤
|
|
145
|
+
var categoryIds = (0, _utils.getFilteredCat)(cats, [], true); // 对cat进行有效性过滤
|
|
146
146
|
|
|
147
147
|
return this.getValidCat(categoryIds);
|
|
148
148
|
}
|
package/lib/cjs/Generator.js
CHANGED
|
@@ -597,7 +597,7 @@ var Generator = /*#__PURE__*/function () {
|
|
|
597
597
|
|
|
598
598
|
case 20:
|
|
599
599
|
// 始终写入主文件
|
|
600
|
-
rawOutputContent = (0, _vtils.dedent)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2.default)(["\n /* tslint:disable */\n /* eslint-disable */\n\n /* \u8BE5\u6587\u4EF6\u7531 yapi-apifox-to-typescript \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u76F4\u63A5\u4FEE\u6539\uFF01\uFF01\uFF01 */\n\n ", "\n "])), syntheticalConfig.typesOnly ? (0, _vtils.dedent)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteralLoose2.default)(["\n // @ts-ignore\n type FileData = File\n\n ", "\n "])), content.join('\n\n').trim()) : (0, _vtils.dedent)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteralLoose2.default)(["\n // @ts-ignore\n // prettier-ignore\n import { QueryStringArrayFormat, Method, ", "FileData, prepare } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n // prettier-ignore\n import type { RequestConfig, RequestFunctionRestArgs } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n import request from ", "\n ", "\n\n type UserRequestRestArgs = RequestFunctionRestArgs<typeof request>\n\n // Request: \u76EE\u524D React Hooks \u529F\u80FD\u6709\u7528\u5230\n export type Request<TRequestData, TRequestConfig extends RequestConfig, TRequestResult> = (\n TRequestConfig['requestDataOptional'] extends true\n ? (requestData?: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n : (requestData: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n ) & {\n requestConfig: TRequestConfig\n }\n\n ", "\n "])), syntheticalConfig.ignoreUselessConfigVar ? "" : "
|
|
600
|
+
rawOutputContent = (0, _vtils.dedent)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2.default)(["\n /* tslint:disable */\n /* eslint-disable */\n\n /* \u8BE5\u6587\u4EF6\u7531 yapi-apifox-to-typescript \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u76F4\u63A5\u4FEE\u6539\uFF01\uFF01\uFF01 */\n\n ", "\n "])), syntheticalConfig.typesOnly ? (0, _vtils.dedent)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteralLoose2.default)(["\n // @ts-ignore\n type FileData = File\n\n ", "\n "])), content.join('\n\n').trim()) : (0, _vtils.dedent)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteralLoose2.default)(["\n // @ts-ignore\n // prettier-ignore\n import { QueryStringArrayFormat, Method, RequestBodyType, ", "FileData, prepare } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n // prettier-ignore\n import type { RequestConfig, RequestFunctionRestArgs } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n import request from ", "\n ", "\n\n type UserRequestRestArgs = RequestFunctionRestArgs<typeof request>\n\n // Request: \u76EE\u524D React Hooks \u529F\u80FD\u6709\u7528\u5230\n export type Request<TRequestData, TRequestConfig extends RequestConfig, TRequestResult> = (\n TRequestConfig['requestDataOptional'] extends true\n ? (requestData?: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n : (requestData: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n ) & {\n requestConfig: TRequestConfig\n }\n\n ", "\n "])), syntheticalConfig.ignoreUselessConfigVar ? "" : "ResponseBodyType, ", JSON.stringify((0, _utils.getNormalizedRelativePath)(outputFilePath, requestFunctionFilePath)), !syntheticalConfig.reactHooks || !syntheticalConfig.reactHooks.enabled ? '' : (0, _vtils.dedent)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteralLoose2.default)(["\n // @ts-ignore\n import makeRequestHook from ", "\n "])), JSON.stringify((0, _utils.getNormalizedRelativePath)(outputFilePath, requestHookMakerFilePath))), content.join('\n\n').trim())); // ref: https://prettier.io/docs/en/options.html
|
|
601
601
|
|
|
602
602
|
_context11.next = 23;
|
|
603
603
|
return (0, _utils.getPrettier)(_this4.options.cwd);
|
|
@@ -1084,8 +1084,9 @@ var Generator = /*#__PURE__*/function () {
|
|
|
1084
1084
|
|
|
1085
1085
|
case 61:
|
|
1086
1086
|
requestFunctionExtraInfo = _context17.t5;
|
|
1087
|
-
requestHeaders = JSON.stringify((extendedInterfaceInfo.req_headers || []
|
|
1088
|
-
|
|
1087
|
+
requestHeaders = JSON.stringify((extendedInterfaceInfo.req_headers || []).filter(function (item) {
|
|
1088
|
+
return item.name.toLowerCase() !== 'content-type';
|
|
1089
|
+
}).reduce(function (res, item) {
|
|
1089
1090
|
res[item.name] = item.value;
|
|
1090
1091
|
return res;
|
|
1091
1092
|
}, {}));
|
|
@@ -1093,11 +1094,11 @@ var Generator = /*#__PURE__*/function () {
|
|
|
1093
1094
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u7C7B\u578B**";
|
|
1094
1095
|
}), requestDataType.trim(), genComment(function (title) {
|
|
1095
1096
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8FD4\u56DE\u7C7B\u578B**";
|
|
1096
|
-
}), responseDataType.trim(), syntheticalConfig.typesOnly ? '' : (0, _vtils.dedent)(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteralLoose2.default)(["\n ", "\n ", "\n path: ", ",\n method: Method.", ",\n ", "", "", "", "", "\n }\n\n ", "\n export const ", " = ", " (\n requestData", ": ", ",\n ...args: UserRequestRestArgs\n ) => {\n return request<", ">(\n prepare(", ", requestData),\n ...args,\n )\n }\n\n ", ".requestConfig = ", "\n\n ", "\n "])), genComment(function (title) {
|
|
1097
|
+
}), responseDataType.trim(), syntheticalConfig.typesOnly ? '' : (0, _vtils.dedent)(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteralLoose2.default)(["\n ", "\n ", "\n path: ", ",\n method: Method.", ",\n ", "", "", "", "requestBodyType: RequestBodyType.", ",\n ", "\n }\n\n ", "\n export const ", " = ", " (\n requestData", ": ", ",\n ...args: UserRequestRestArgs\n ) => {\n return request<", ">(\n prepare(", ", requestData),\n ...args,\n )\n }\n\n ", ".requestConfig = ", "\n\n ", "\n "])), genComment(function (title) {
|
|
1097
1098
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u914D\u7F6E**";
|
|
1098
|
-
}), syntheticalConfig.withoutUrl !== true ? "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {\n mockUrl: mockUrl" + categoryUID + ",\n devUrl: devUrl" + categoryUID + ",\n prodUrl: prodUrl" + categoryUID + "," : "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {", JSON.stringify(extendedInterfaceInfo.path), extendedInterfaceInfo.method, paramNames.length === 0 ? '' : "paramNames: " + paramNamesLiteral + ",", queryNames.length === 0 ? '' : "queryNames: " + queryNamesLiteral + ",", syntheticalConfig.queryStringArrayFormat ? "queryStringArrayFormat: QueryStringArrayFormat." + syntheticalConfig.queryStringArrayFormat + "," : '', requestHeaders === '{}' ? '' : "requestHeaders: " + requestHeaders + ",",
|
|
1099
|
+
}), syntheticalConfig.withoutUrl !== true ? "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {\n mockUrl: mockUrl" + categoryUID + ",\n devUrl: devUrl" + categoryUID + ",\n prodUrl: prodUrl" + categoryUID + "," : "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {", JSON.stringify(extendedInterfaceInfo.path), extendedInterfaceInfo.method, paramNames.length === 0 ? '' : "paramNames: " + paramNamesLiteral + ",", queryNames.length === 0 ? '' : "queryNames: " + queryNamesLiteral + ",", syntheticalConfig.queryStringArrayFormat ? "queryStringArrayFormat: QueryStringArrayFormat." + syntheticalConfig.queryStringArrayFormat + "," : '', requestHeaders === '{}' ? '' : "requestHeaders: " + requestHeaders + ",", extendedInterfaceInfo.method === _types.Method.GET ? _types.RequestBodyType.query : extendedInterfaceInfo.req_body_type
|
|
1099
1100
|
/* istanbul ignore next */
|
|
1100
|
-
|| _types.RequestBodyType.none
|
|
1101
|
+
|| _types.RequestBodyType.none, syntheticalConfig.ignoreUselessConfigVar ? "" : "responseBodyType: ResponseBodyType." + extendedInterfaceInfo.res_body_type + ",\n dataKey: dataKey" + categoryUID + ",\n requestDataOptional: " + JSON.stringify(isRequestDataOptional) + ",\n requestDataJsonSchema: " + JSON.stringify((_syntheticalConfig$js = syntheticalConfig.jsonSchema) != null && _syntheticalConfig$js.enabled && ((_syntheticalConfig$js2 = syntheticalConfig.jsonSchema) == null ? void 0 : _syntheticalConfig$js2.requestData) !== false ? requestDataJsonSchema : {}) + ",\n responseDataJsonSchema: " + JSON.stringify((_syntheticalConfig$js3 = syntheticalConfig.jsonSchema) != null && _syntheticalConfig$js3.enabled && ((_syntheticalConfig$js4 = syntheticalConfig.jsonSchema) == null ? void 0 : _syntheticalConfig$js4.responseData) !== false ? responseDataJsonSchema : {}) + ",\n requestFunctionName: " + JSON.stringify(requestFunctionName) + ",\n extraInfo: " + JSON.stringify(requestFunctionExtraInfo), genComment(function (title) {
|
|
1101
1102
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u51FD\u6570**";
|
|
1102
1103
|
}), requestFunctionName, COMPRESSOR_TREE_SHAKING_ANNOTATION, isRequestDataOptional ? '?' : '', requestDataTypeName, responseDataTypeName, requestConfigName, requestFunctionName, requestConfigName, !syntheticalConfig.reactHooks || !syntheticalConfig.reactHooks.enabled ? '' : (0, _vtils.dedent)(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteralLoose2.default)(["\n ", "\n export const ", " = ", " makeRequestHook<", ", ", ", ReturnType<typeof ", ">>(", ")\n "])), genComment(function (title) {
|
|
1103
1104
|
return "\u63A5\u53E3 " + title + " \u7684 **React Hook**";
|
package/lib/cjs/utils.js
CHANGED
|
@@ -769,7 +769,11 @@ function _httpGet() {
|
|
|
769
769
|
return _httpGet.apply(this, arguments);
|
|
770
770
|
}
|
|
771
771
|
|
|
772
|
-
var getFilteredCat = function getFilteredCat(cat, cats) {
|
|
772
|
+
var getFilteredCat = function getFilteredCat(cat, cats, isApifox) {
|
|
773
|
+
if (isApifox === void 0) {
|
|
774
|
+
isApifox = false;
|
|
775
|
+
}
|
|
776
|
+
|
|
773
777
|
// 分类处理
|
|
774
778
|
// 数组化
|
|
775
779
|
var categoryIds = (0, _vtils.castArray)(cat.id); // 全部分类
|
|
@@ -792,11 +796,18 @@ var getFilteredCat = function getFilteredCat(cat, cats) {
|
|
|
792
796
|
return !excludedCategoryIds.includes(Math.abs(id));
|
|
793
797
|
}); // 删除不存在的分类
|
|
794
798
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return
|
|
799
|
+
if (!isApifox) {
|
|
800
|
+
categoryIds = categoryIds.filter(function (id) {
|
|
801
|
+
return !!cats.find(function (c) {
|
|
802
|
+
return c._id === id;
|
|
803
|
+
});
|
|
804
|
+
});
|
|
805
|
+
} else {
|
|
806
|
+
categoryIds = categoryIds.filter(function (id) {
|
|
807
|
+
return id !== 0;
|
|
798
808
|
});
|
|
799
|
-
}
|
|
809
|
+
} // 顺序化
|
|
810
|
+
|
|
800
811
|
|
|
801
812
|
categoryIds = categoryIds.sort();
|
|
802
813
|
return categoryIds;
|
|
@@ -129,7 +129,7 @@ export var ApifoxToYApiData = /*#__PURE__*/function () {
|
|
|
129
129
|
;
|
|
130
130
|
|
|
131
131
|
_proto.getCats = function getCats(cats) {
|
|
132
|
-
var categoryIds = getFilteredCat(cats, []); // 对cat进行有效性过滤
|
|
132
|
+
var categoryIds = getFilteredCat(cats, [], true); // 对cat进行有效性过滤
|
|
133
133
|
|
|
134
134
|
return this.getValidCat(categoryIds);
|
|
135
135
|
}
|
package/lib/esm/Generator.js
CHANGED
|
@@ -574,7 +574,7 @@ export var Generator = /*#__PURE__*/function () {
|
|
|
574
574
|
|
|
575
575
|
case 20:
|
|
576
576
|
// 始终写入主文件
|
|
577
|
-
rawOutputContent = dedent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n /* tslint:disable */\n /* eslint-disable */\n\n /* \u8BE5\u6587\u4EF6\u7531 yapi-apifox-to-typescript \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u76F4\u63A5\u4FEE\u6539\uFF01\uFF01\uFF01 */\n\n ", "\n "])), syntheticalConfig.typesOnly ? dedent(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n type FileData = File\n\n ", "\n "])), content.join('\n\n').trim()) : dedent(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n // prettier-ignore\n import { QueryStringArrayFormat, Method, ", "FileData, prepare } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n // prettier-ignore\n import type { RequestConfig, RequestFunctionRestArgs } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n import request from ", "\n ", "\n\n type UserRequestRestArgs = RequestFunctionRestArgs<typeof request>\n\n // Request: \u76EE\u524D React Hooks \u529F\u80FD\u6709\u7528\u5230\n export type Request<TRequestData, TRequestConfig extends RequestConfig, TRequestResult> = (\n TRequestConfig['requestDataOptional'] extends true\n ? (requestData?: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n : (requestData: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n ) & {\n requestConfig: TRequestConfig\n }\n\n ", "\n "])), syntheticalConfig.ignoreUselessConfigVar ? "" : "
|
|
577
|
+
rawOutputContent = dedent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n /* tslint:disable */\n /* eslint-disable */\n\n /* \u8BE5\u6587\u4EF6\u7531 yapi-apifox-to-typescript \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u76F4\u63A5\u4FEE\u6539\uFF01\uFF01\uFF01 */\n\n ", "\n "])), syntheticalConfig.typesOnly ? dedent(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n type FileData = File\n\n ", "\n "])), content.join('\n\n').trim()) : dedent(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n // prettier-ignore\n import { QueryStringArrayFormat, Method, RequestBodyType, ", "FileData, prepare } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n // prettier-ignore\n import type { RequestConfig, RequestFunctionRestArgs } from 'yapi-apifox-to-typescript'\n // @ts-ignore\n import request from ", "\n ", "\n\n type UserRequestRestArgs = RequestFunctionRestArgs<typeof request>\n\n // Request: \u76EE\u524D React Hooks \u529F\u80FD\u6709\u7528\u5230\n export type Request<TRequestData, TRequestConfig extends RequestConfig, TRequestResult> = (\n TRequestConfig['requestDataOptional'] extends true\n ? (requestData?: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n : (requestData: TRequestData, ...args: RequestFunctionRestArgs<typeof request>) => TRequestResult\n ) & {\n requestConfig: TRequestConfig\n }\n\n ", "\n "])), syntheticalConfig.ignoreUselessConfigVar ? "" : "ResponseBodyType, ", JSON.stringify(getNormalizedRelativePath(outputFilePath, requestFunctionFilePath)), !syntheticalConfig.reactHooks || !syntheticalConfig.reactHooks.enabled ? '' : dedent(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n import makeRequestHook from ", "\n "])), JSON.stringify(getNormalizedRelativePath(outputFilePath, requestHookMakerFilePath))), content.join('\n\n').trim())); // ref: https://prettier.io/docs/en/options.html
|
|
578
578
|
|
|
579
579
|
_context11.next = 23;
|
|
580
580
|
return getPrettier(_this4.options.cwd);
|
|
@@ -1061,8 +1061,9 @@ export var Generator = /*#__PURE__*/function () {
|
|
|
1061
1061
|
|
|
1062
1062
|
case 61:
|
|
1063
1063
|
requestFunctionExtraInfo = _context17.t5;
|
|
1064
|
-
requestHeaders = JSON.stringify((extendedInterfaceInfo.req_headers || []
|
|
1065
|
-
|
|
1064
|
+
requestHeaders = JSON.stringify((extendedInterfaceInfo.req_headers || []).filter(function (item) {
|
|
1065
|
+
return item.name.toLowerCase() !== 'content-type';
|
|
1066
|
+
}).reduce(function (res, item) {
|
|
1066
1067
|
res[item.name] = item.value;
|
|
1067
1068
|
return res;
|
|
1068
1069
|
}, {}));
|
|
@@ -1070,11 +1071,11 @@ export var Generator = /*#__PURE__*/function () {
|
|
|
1070
1071
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u7C7B\u578B**";
|
|
1071
1072
|
}), requestDataType.trim(), genComment(function (title) {
|
|
1072
1073
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8FD4\u56DE\u7C7B\u578B**";
|
|
1073
|
-
}), responseDataType.trim(), syntheticalConfig.typesOnly ? '' : dedent(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n path: ", ",\n method: Method.", ",\n ", "", "", "", "", "\n }\n\n ", "\n export const ", " = ", " (\n requestData", ": ", ",\n ...args: UserRequestRestArgs\n ) => {\n return request<", ">(\n prepare(", ", requestData),\n ...args,\n )\n }\n\n ", ".requestConfig = ", "\n\n ", "\n "])), genComment(function (title) {
|
|
1074
|
+
}), responseDataType.trim(), syntheticalConfig.typesOnly ? '' : dedent(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n path: ", ",\n method: Method.", ",\n ", "", "", "", "requestBodyType: RequestBodyType.", ",\n ", "\n }\n\n ", "\n export const ", " = ", " (\n requestData", ": ", ",\n ...args: UserRequestRestArgs\n ) => {\n return request<", ">(\n prepare(", ", requestData),\n ...args,\n )\n }\n\n ", ".requestConfig = ", "\n\n ", "\n "])), genComment(function (title) {
|
|
1074
1075
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u914D\u7F6E**";
|
|
1075
|
-
}), syntheticalConfig.withoutUrl !== true ? "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {\n mockUrl: mockUrl" + categoryUID + ",\n devUrl: devUrl" + categoryUID + ",\n prodUrl: prodUrl" + categoryUID + "," : "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {", JSON.stringify(extendedInterfaceInfo.path), extendedInterfaceInfo.method, paramNames.length === 0 ? '' : "paramNames: " + paramNamesLiteral + ",", queryNames.length === 0 ? '' : "queryNames: " + queryNamesLiteral + ",", syntheticalConfig.queryStringArrayFormat ? "queryStringArrayFormat: QueryStringArrayFormat." + syntheticalConfig.queryStringArrayFormat + "," : '', requestHeaders === '{}' ? '' : "requestHeaders: " + requestHeaders + ",",
|
|
1076
|
+
}), syntheticalConfig.withoutUrl !== true ? "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {\n mockUrl: mockUrl" + categoryUID + ",\n devUrl: devUrl" + categoryUID + ",\n prodUrl: prodUrl" + categoryUID + "," : "const " + requestConfigName + ": " + requestConfigTypeName + " = " + COMPRESSOR_TREE_SHAKING_ANNOTATION + " {", JSON.stringify(extendedInterfaceInfo.path), extendedInterfaceInfo.method, paramNames.length === 0 ? '' : "paramNames: " + paramNamesLiteral + ",", queryNames.length === 0 ? '' : "queryNames: " + queryNamesLiteral + ",", syntheticalConfig.queryStringArrayFormat ? "queryStringArrayFormat: QueryStringArrayFormat." + syntheticalConfig.queryStringArrayFormat + "," : '', requestHeaders === '{}' ? '' : "requestHeaders: " + requestHeaders + ",", extendedInterfaceInfo.method === Method.GET ? RequestBodyType.query : extendedInterfaceInfo.req_body_type
|
|
1076
1077
|
/* istanbul ignore next */
|
|
1077
|
-
|| RequestBodyType.none
|
|
1078
|
+
|| RequestBodyType.none, syntheticalConfig.ignoreUselessConfigVar ? "" : "responseBodyType: ResponseBodyType." + extendedInterfaceInfo.res_body_type + ",\n dataKey: dataKey" + categoryUID + ",\n requestDataOptional: " + JSON.stringify(isRequestDataOptional) + ",\n requestDataJsonSchema: " + JSON.stringify((_syntheticalConfig$js = syntheticalConfig.jsonSchema) != null && _syntheticalConfig$js.enabled && ((_syntheticalConfig$js2 = syntheticalConfig.jsonSchema) == null ? void 0 : _syntheticalConfig$js2.requestData) !== false ? requestDataJsonSchema : {}) + ",\n responseDataJsonSchema: " + JSON.stringify((_syntheticalConfig$js3 = syntheticalConfig.jsonSchema) != null && _syntheticalConfig$js3.enabled && ((_syntheticalConfig$js4 = syntheticalConfig.jsonSchema) == null ? void 0 : _syntheticalConfig$js4.responseData) !== false ? responseDataJsonSchema : {}) + ",\n requestFunctionName: " + JSON.stringify(requestFunctionName) + ",\n extraInfo: " + JSON.stringify(requestFunctionExtraInfo), genComment(function (title) {
|
|
1078
1079
|
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u51FD\u6570**";
|
|
1079
1080
|
}), requestFunctionName, COMPRESSOR_TREE_SHAKING_ANNOTATION, isRequestDataOptional ? '?' : '', requestDataTypeName, responseDataTypeName, requestConfigName, requestFunctionName, requestConfigName, !syntheticalConfig.reactHooks || !syntheticalConfig.reactHooks.enabled ? '' : dedent(_templateObject12 || (_templateObject12 = _taggedTemplateLiteralLoose(["\n ", "\n export const ", " = ", " makeRequestHook<", ", ", ", ReturnType<typeof ", ">>(", ")\n "])), genComment(function (title) {
|
|
1080
1081
|
return "\u63A5\u53E3 " + title + " \u7684 **React Hook**";
|
package/lib/esm/utils.js
CHANGED
|
@@ -709,7 +709,11 @@ function _httpGet() {
|
|
|
709
709
|
return _httpGet.apply(this, arguments);
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
export var getFilteredCat = function getFilteredCat(cat, cats) {
|
|
712
|
+
export var getFilteredCat = function getFilteredCat(cat, cats, isApifox) {
|
|
713
|
+
if (isApifox === void 0) {
|
|
714
|
+
isApifox = false;
|
|
715
|
+
}
|
|
716
|
+
|
|
713
717
|
// 分类处理
|
|
714
718
|
// 数组化
|
|
715
719
|
var categoryIds = castArray(cat.id); // 全部分类
|
|
@@ -732,11 +736,18 @@ export var getFilteredCat = function getFilteredCat(cat, cats) {
|
|
|
732
736
|
return !excludedCategoryIds.includes(Math.abs(id));
|
|
733
737
|
}); // 删除不存在的分类
|
|
734
738
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
return
|
|
739
|
+
if (!isApifox) {
|
|
740
|
+
categoryIds = categoryIds.filter(function (id) {
|
|
741
|
+
return !!cats.find(function (c) {
|
|
742
|
+
return c._id === id;
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
} else {
|
|
746
|
+
categoryIds = categoryIds.filter(function (id) {
|
|
747
|
+
return id !== 0;
|
|
738
748
|
});
|
|
739
|
-
}
|
|
749
|
+
} // 顺序化
|
|
750
|
+
|
|
740
751
|
|
|
741
752
|
categoryIds = categoryIds.sort();
|
|
742
753
|
return categoryIds;
|