yapi-to-typescript2 1.0.0 → 1.0.2

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/esm/utils.js CHANGED
@@ -1,7 +1,59 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _createForOfIteratorHelperLoose from "@babel/runtime/helpers/esm/createForOfIteratorHelperLoose";
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
5
57
  import fs from 'fs-extra';
6
58
  import JSON5 from 'json5';
7
59
  import nodeFetch from 'node-fetch';
@@ -9,24 +61,23 @@ import path from 'path';
9
61
  import prettier from 'prettier';
10
62
  import ProxyAgent from 'proxy-agent';
11
63
  import toJsonSchema from 'to-json-schema';
12
- import { castArray, cloneDeepFast, forOwn, isArray, isEmpty, isObject, mapKeys, memoize, run, traverse } from 'vtils';
64
+ import { castArray, cloneDeepFast, forOwn, isArray, isEmpty, isObject, mapKeys, memoize, run, traverse, } from 'vtils';
13
65
  import { compile } from 'json-schema-to-typescript';
14
66
  import { FileData } from './helpers';
15
- import { Method, RequestBodyType, RequestFormItemType, Required, ResponseBodyType } from './types';
67
+ import { Method, RequestBodyType, RequestFormItemType, Required, ResponseBodyType, } from './types';
16
68
  import { URL } from 'url';
17
69
  /**
18
70
  * 抛出错误。
19
71
  *
20
72
  * @param msg 错误信息
21
73
  */
22
-
23
74
  export function throwError() {
24
- for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
25
- msg[_key] = arguments[_key];
26
- }
27
-
28
- /* istanbul ignore next */
29
- throw new Error(msg.join(''));
75
+ var msg = [];
76
+ for (var _i = 0; _i < arguments.length; _i++) {
77
+ msg[_i] = arguments[_i];
78
+ }
79
+ /* istanbul ignore next */
80
+ throw new Error(msg.join(''));
30
81
  }
31
82
  /**
32
83
  * 将路径统一为 unix 风格的路径。
@@ -34,9 +85,8 @@ export function throwError() {
34
85
  * @param path 路径
35
86
  * @returns unix 风格的路径
36
87
  */
37
-
38
88
  export function toUnixPath(path) {
39
- return path.replace(/[/\\]+/g, '/');
89
+ return path.replace(/[/\\]+/g, '/');
40
90
  }
41
91
  /**
42
92
  * 获得规范化的相对路径。
@@ -45,67 +95,53 @@ export function toUnixPath(path) {
45
95
  * @param to 去向路径
46
96
  * @returns 相对路径
47
97
  */
48
-
49
98
  export function getNormalizedRelativePath(from, to) {
50
- return toUnixPath(path.relative(path.dirname(from), to)).replace(/^(?=[^.])/, './').replace(/\.(ts|js)x?$/i, '');
99
+ return toUnixPath(path.relative(path.dirname(from), to))
100
+ .replace(/^(?=[^.])/, './')
101
+ .replace(/\.(ts|js)x?$/i, '');
51
102
  }
52
103
  /**
53
104
  * 原地遍历 JSONSchema。
54
105
  */
55
-
56
106
  export function traverseJsonSchema(jsonSchema, cb, currentPath) {
57
- if (currentPath === void 0) {
58
- currentPath = [];
59
- }
60
-
61
- /* istanbul ignore if */
62
- if (!isObject(jsonSchema)) return jsonSchema; // Mock.toJSONSchema 产生的 properties 为数组,然而 JSONSchema4 的 properties 为对象
63
-
64
- if (isArray(jsonSchema.properties)) {
65
- jsonSchema.properties = jsonSchema.properties.reduce(function (props, js) {
66
- props[js.name] = js;
67
- return props;
68
- }, {});
69
- } // 处理传入的 JSONSchema
70
-
71
-
72
- cb(jsonSchema, currentPath); // 继续处理对象的子元素
73
-
74
- if (jsonSchema.properties) {
75
- forOwn(jsonSchema.properties, function (item, key) {
76
- return traverseJsonSchema(item, cb, [].concat(currentPath, [key]));
77
- });
78
- } // 继续处理数组的子元素
79
-
80
-
81
- if (jsonSchema.items) {
82
- castArray(jsonSchema.items).forEach(function (item, index) {
83
- return traverseJsonSchema(item, cb, [].concat(currentPath, [index]));
84
- });
85
- } // 处理 oneOf
86
-
87
-
88
- if (jsonSchema.oneOf) {
89
- jsonSchema.oneOf.forEach(function (item) {
90
- return traverseJsonSchema(item, cb, currentPath);
91
- });
92
- } // 处理 anyOf
93
-
94
-
95
- if (jsonSchema.anyOf) {
96
- jsonSchema.anyOf.forEach(function (item) {
97
- return traverseJsonSchema(item, cb, currentPath);
98
- });
99
- } // 处理 allOf
100
-
101
-
102
- if (jsonSchema.allOf) {
103
- jsonSchema.allOf.forEach(function (item) {
104
- return traverseJsonSchema(item, cb, currentPath);
105
- });
106
- }
107
-
108
- return jsonSchema;
107
+ if (currentPath === void 0) { currentPath = []; }
108
+ /* istanbul ignore if */
109
+ if (!isObject(jsonSchema))
110
+ return jsonSchema;
111
+ // Mock.toJSONSchema 产生的 properties 为数组,然而 JSONSchema4 的 properties 为对象
112
+ if (isArray(jsonSchema.properties)) {
113
+ jsonSchema.properties = jsonSchema.properties.reduce(function (props, js) {
114
+ props[js.name] = js;
115
+ return props;
116
+ }, {});
117
+ }
118
+ // 处理传入的 JSONSchema
119
+ cb(jsonSchema, currentPath);
120
+ // 继续处理对象的子元素
121
+ if (jsonSchema.properties) {
122
+ forOwn(jsonSchema.properties, function (item, key) {
123
+ return traverseJsonSchema(item, cb, __spreadArray(__spreadArray([], currentPath, true), [key], false));
124
+ });
125
+ }
126
+ // 继续处理数组的子元素
127
+ if (jsonSchema.items) {
128
+ castArray(jsonSchema.items).forEach(function (item, index) {
129
+ return traverseJsonSchema(item, cb, __spreadArray(__spreadArray([], currentPath, true), [index], false));
130
+ });
131
+ }
132
+ // 处理 oneOf
133
+ if (jsonSchema.oneOf) {
134
+ jsonSchema.oneOf.forEach(function (item) { return traverseJsonSchema(item, cb, currentPath); });
135
+ }
136
+ // 处理 anyOf
137
+ if (jsonSchema.anyOf) {
138
+ jsonSchema.anyOf.forEach(function (item) { return traverseJsonSchema(item, cb, currentPath); });
139
+ }
140
+ // 处理 allOf
141
+ if (jsonSchema.allOf) {
142
+ jsonSchema.allOf.forEach(function (item) { return traverseJsonSchema(item, cb, currentPath); });
143
+ }
144
+ return jsonSchema;
109
145
  }
110
146
  /**
111
147
  * 原地处理 JSONSchema。
@@ -113,62 +149,44 @@ export function traverseJsonSchema(jsonSchema, cb, currentPath) {
113
149
  * @param jsonSchema 待处理的 JSONSchema
114
150
  * @returns 处理后的 JSONSchema
115
151
  */
116
-
117
152
  export function processJsonSchema(jsonSchema, customTypeMapping) {
118
- return traverseJsonSchema(jsonSchema, function (jsonSchema) {
119
- // 删除通过 swagger 导入时未剔除的 ref
120
- delete jsonSchema.$ref;
121
- delete jsonSchema.$$ref; // 数组只取第一个判断类型
122
-
123
- if (jsonSchema.type === 'array' && Array.isArray(jsonSchema.items) && jsonSchema.items.length) {
124
- jsonSchema.items = jsonSchema.items[0];
125
- } // 处理类型名称为标准的 JSONSchema 类型名称
126
-
127
-
128
- if (jsonSchema.type) {
129
- // 类型映射表,键都为小写
130
- var typeMapping = _extends({
131
- byte: 'integer',
132
- short: 'integer',
133
- int: 'integer',
134
- long: 'integer',
135
- float: 'number',
136
- double: 'number',
137
- bigdecimal: 'number',
138
- char: 'string',
139
- void: 'null'
140
- }, mapKeys(customTypeMapping, function (_, key) {
141
- return key.toLowerCase();
142
- }));
143
-
144
- var isMultiple = Array.isArray(jsonSchema.type);
145
- var types = castArray(jsonSchema.type).map(function (type) {
146
- // 所有类型转成小写,如:String -> string
147
- type = type.toLowerCase(); // 映射为标准的 JSONSchema 类型
148
-
149
- type = typeMapping[type] || type;
150
- return type;
151
- });
152
- jsonSchema.type = isMultiple ? types : types[0];
153
- } // 移除字段名称首尾空格
154
-
155
-
156
- if (jsonSchema.properties) {
157
- forOwn(jsonSchema.properties, function (_, prop) {
158
- var propDef = jsonSchema.properties[prop];
159
- delete jsonSchema.properties[prop];
160
- jsonSchema.properties[prop.trim()] = propDef;
161
- });
162
-
163
- if (Array.isArray(jsonSchema.required)) {
164
- jsonSchema.required = jsonSchema.required.map(function (prop) {
165
- return prop.trim();
166
- });
167
- }
168
- }
169
-
170
- return jsonSchema;
171
- });
153
+ return traverseJsonSchema(jsonSchema, function (jsonSchema) {
154
+ // 删除通过 swagger 导入时未剔除的 ref
155
+ delete jsonSchema.$ref;
156
+ delete jsonSchema.$$ref;
157
+ // 数组只取第一个判断类型
158
+ if (jsonSchema.type === 'array' &&
159
+ Array.isArray(jsonSchema.items) &&
160
+ jsonSchema.items.length) {
161
+ jsonSchema.items = jsonSchema.items[0];
162
+ }
163
+ // 处理类型名称为标准的 JSONSchema 类型名称
164
+ if (jsonSchema.type) {
165
+ // 类型映射表,键都为小写
166
+ var typeMapping_1 = __assign({ byte: 'integer', short: 'integer', int: 'integer', long: 'integer', float: 'number', double: 'number', bigdecimal: 'number', char: 'string', void: 'null' }, mapKeys(customTypeMapping, function (_, key) { return key.toLowerCase(); }));
167
+ var isMultiple = Array.isArray(jsonSchema.type);
168
+ var types = castArray(jsonSchema.type).map(function (type) {
169
+ // 所有类型转成小写,如:String -> string
170
+ type = type.toLowerCase();
171
+ // 映射为标准的 JSONSchema 类型
172
+ type = typeMapping_1[type] || type;
173
+ return type;
174
+ });
175
+ jsonSchema.type = isMultiple ? types : types[0];
176
+ }
177
+ // 移除字段名称首尾空格
178
+ if (jsonSchema.properties) {
179
+ forOwn(jsonSchema.properties, function (_, prop) {
180
+ var propDef = jsonSchema.properties[prop];
181
+ delete jsonSchema.properties[prop];
182
+ jsonSchema.properties[prop.trim()] = propDef;
183
+ });
184
+ if (Array.isArray(jsonSchema.required)) {
185
+ jsonSchema.required = jsonSchema.required.map(function (prop) { return prop.trim(); });
186
+ }
187
+ }
188
+ return jsonSchema;
189
+ });
172
190
  }
173
191
  /**
174
192
  * 获取适用于 JSTT 的 JSONSchema。
@@ -176,51 +194,46 @@ export function processJsonSchema(jsonSchema, customTypeMapping) {
176
194
  * @param jsonSchema 待处理的 JSONSchema
177
195
  * @returns 适用于 JSTT 的 JSONSchema
178
196
  */
179
-
180
197
  export function jsonSchemaToJSTTJsonSchema(jsonSchema, typeName) {
181
- if (jsonSchema) {
182
- // 去除最外层的 description 以防止 JSTT 提取它作为类型的注释
183
- delete jsonSchema.description;
184
- }
185
-
186
- return traverseJsonSchema(jsonSchema, function (jsonSchema, currentPath) {
187
- // 支持类型引用
188
- var refValue = // YApi 低版本不支持配置 title,可以在 description 里配置
189
- jsonSchema.title == null ? jsonSchema.description : jsonSchema.title;
190
-
191
- if (refValue != null && refValue.startsWith('&')) {
192
- var typeRelativePath = refValue.substring(1);
193
- var typeAbsolutePath = toUnixPath(path.resolve(path.dirname(("/" + currentPath.join('/')).replace(/\/{2,}/g, '/')), typeRelativePath).replace(/^[a-z]+:/i, ''));
194
- var typeAbsolutePathArr = typeAbsolutePath.split('/').filter(Boolean);
195
- var tsTypeLeft = '';
196
- var tsTypeRight = typeName;
197
-
198
- for (var _iterator = _createForOfIteratorHelperLoose(typeAbsolutePathArr), _step; !(_step = _iterator()).done;) {
199
- var key = _step.value;
200
- tsTypeLeft += 'NonNullable<';
201
- tsTypeRight += "[" + JSON.stringify(key) + "]>";
202
- }
203
-
204
- var tsType = "" + tsTypeLeft + tsTypeRight;
205
- jsonSchema.tsType = tsType;
206
- } // 去除 title 和 id,防止 json-schema-to-typescript 提取它们作为接口名
207
-
208
-
209
- delete jsonSchema.title;
210
- delete jsonSchema.id; // 忽略数组长度限制
211
-
212
- delete jsonSchema.minItems;
213
- delete jsonSchema.maxItems;
214
-
215
- if (jsonSchema.type === 'object') {
216
- // additionalProperties 设为 false
217
- jsonSchema.additionalProperties = false;
218
- } // 删除 default,防止 json-schema-to-typescript 根据它推测类型
219
-
220
-
221
- delete jsonSchema.default;
222
- return jsonSchema;
223
- });
198
+ if (jsonSchema) {
199
+ // 去除最外层的 description 以防止 JSTT 提取它作为类型的注释
200
+ delete jsonSchema.description;
201
+ }
202
+ return traverseJsonSchema(jsonSchema, function (jsonSchema, currentPath) {
203
+ // 支持类型引用
204
+ var refValue =
205
+ // YApi 低版本不支持配置 title,可以在 description 里配置
206
+ jsonSchema.title == null ? jsonSchema.description : jsonSchema.title;
207
+ if (refValue === null || refValue === void 0 ? void 0 : refValue.startsWith('&')) {
208
+ var typeRelativePath = refValue.substring(1);
209
+ var typeAbsolutePath = toUnixPath(path
210
+ .resolve(path.dirname("/".concat(currentPath.join('/')).replace(/\/{2,}/g, '/')), typeRelativePath)
211
+ .replace(/^[a-z]+:/i, ''));
212
+ var typeAbsolutePathArr = typeAbsolutePath.split('/').filter(Boolean);
213
+ var tsTypeLeft = '';
214
+ var tsTypeRight = typeName;
215
+ for (var _i = 0, typeAbsolutePathArr_1 = typeAbsolutePathArr; _i < typeAbsolutePathArr_1.length; _i++) {
216
+ var key = typeAbsolutePathArr_1[_i];
217
+ tsTypeLeft += 'NonNullable<';
218
+ tsTypeRight += "[".concat(JSON.stringify(key), "]>");
219
+ }
220
+ var tsType = "".concat(tsTypeLeft).concat(tsTypeRight);
221
+ jsonSchema.tsType = tsType;
222
+ }
223
+ // 去除 title 和 id,防止 json-schema-to-typescript 提取它们作为接口名
224
+ delete jsonSchema.title;
225
+ delete jsonSchema.id;
226
+ // 忽略数组长度限制
227
+ delete jsonSchema.minItems;
228
+ delete jsonSchema.maxItems;
229
+ if (jsonSchema.type === 'object') {
230
+ // 将 additionalProperties 设为 false
231
+ jsonSchema.additionalProperties = false;
232
+ }
233
+ // 删除 default,防止 json-schema-to-typescript 根据它推测类型
234
+ delete jsonSchema.default;
235
+ return jsonSchema;
236
+ });
224
237
  }
225
238
  /**
226
239
  * 将 JSONSchema 字符串转为 JSONSchema 对象。
@@ -228,9 +241,8 @@ export function jsonSchemaToJSTTJsonSchema(jsonSchema, typeName) {
228
241
  * @param str 要转换的 JSONSchema 字符串
229
242
  * @returns 转换后的 JSONSchema 对象
230
243
  */
231
-
232
244
  export function jsonSchemaStringToJsonSchema(str, customTypeMapping) {
233
- return processJsonSchema(JSON.parse(str), customTypeMapping);
245
+ return processJsonSchema(JSON.parse(str), customTypeMapping);
234
246
  }
235
247
  /**
236
248
  * 获得 JSON 数据的 JSONSchema 对象。
@@ -238,29 +250,27 @@ export function jsonSchemaStringToJsonSchema(str, customTypeMapping) {
238
250
  * @param json JSON 数据
239
251
  * @returns JSONSchema 对象
240
252
  */
241
-
242
253
  export function jsonToJsonSchema(json, customTypeMapping) {
243
- var schema = toJsonSchema(json, {
244
- required: false,
245
- arrays: {
246
- mode: 'first'
247
- },
248
- objects: {
249
- additionalProperties: false
250
- },
251
- strings: {
252
- detectFormat: false
253
- },
254
- postProcessFnc: function postProcessFnc(type, schema, value) {
255
- if (!schema.description && !!value && type !== 'object') {
256
- schema.description = JSON.stringify(value);
257
- }
258
-
259
- return schema;
260
- }
261
- });
262
- delete schema.description;
263
- return processJsonSchema(schema, customTypeMapping);
254
+ var schema = toJsonSchema(json, {
255
+ required: false,
256
+ arrays: {
257
+ mode: 'first',
258
+ },
259
+ objects: {
260
+ additionalProperties: false,
261
+ },
262
+ strings: {
263
+ detectFormat: false,
264
+ },
265
+ postProcessFnc: function (type, schema, value) {
266
+ if (!schema.description && !!value && type !== 'object') {
267
+ schema.description = JSON.stringify(value);
268
+ }
269
+ return schema;
270
+ },
271
+ });
272
+ delete schema.description;
273
+ return processJsonSchema(schema, customTypeMapping);
264
274
  }
265
275
  /**
266
276
  * 获得 mockjs 模板的 JSONSchema 对象。
@@ -268,48 +278,43 @@ export function jsonToJsonSchema(json, customTypeMapping) {
268
278
  * @param template mockjs 模板
269
279
  * @returns JSONSchema 对象
270
280
  */
271
-
272
281
  export function mockjsTemplateToJsonSchema(template, customTypeMapping) {
273
- var actions = []; // https://github.com/nuysoft/Mock/blob/refactoring/src/mock/constant.js#L27
274
-
275
- var keyRe = /(.+)\|(?:\+(\d+)|([+-]?\d+-?[+-]?\d*)?(?:\.(\d+-?\d*))?)/; // https://github.com/nuysoft/Mock/wiki/Mock.Random
276
-
277
- var numberPatterns = ['natural', 'integer', 'float', 'range', 'increment'];
278
- var boolPatterns = ['boolean', 'bool'];
279
-
280
- var normalizeValue = function normalizeValue(value) {
281
- if (typeof value === 'string' && value.startsWith('@')) {
282
- var pattern = value.slice(1);
283
-
284
- if (numberPatterns.some(function (p) {
285
- return pattern.startsWith(p);
286
- })) {
287
- return 1;
288
- }
289
-
290
- if (boolPatterns.some(function (p) {
291
- return pattern.startsWith(p);
292
- })) {
293
- return true;
294
- }
295
- }
296
-
297
- return value;
298
- };
299
-
300
- traverse(template, function (value, key, parent) {
301
- if (typeof key === 'string') {
302
- actions.push(function () {
303
- delete parent[key];
304
- parent[// https://github.com/nuysoft/Mock/blob/refactoring/src/mock/schema/schema.js#L16
305
- key.replace(keyRe, '$1')] = normalizeValue(value);
306
- });
307
- }
308
- });
309
- actions.forEach(function (action) {
310
- return action();
311
- });
312
- return jsonToJsonSchema(template, customTypeMapping);
282
+ var actions = [];
283
+ // https://github.com/nuysoft/Mock/blob/refactoring/src/mock/constant.js#L27
284
+ var keyRe = /(.+)\|(?:\+(\d+)|([+-]?\d+-?[+-]?\d*)?(?:\.(\d+-?\d*))?)/;
285
+ // https://github.com/nuysoft/Mock/wiki/Mock.Random
286
+ var numberPatterns = [
287
+ 'natural',
288
+ 'integer',
289
+ 'float',
290
+ 'range',
291
+ 'increment',
292
+ ];
293
+ var boolPatterns = ['boolean', 'bool'];
294
+ var normalizeValue = function (value) {
295
+ if (typeof value === 'string' && value.startsWith('@')) {
296
+ var pattern_1 = value.slice(1);
297
+ if (numberPatterns.some(function (p) { return pattern_1.startsWith(p); })) {
298
+ return 1;
299
+ }
300
+ if (boolPatterns.some(function (p) { return pattern_1.startsWith(p); })) {
301
+ return true;
302
+ }
303
+ }
304
+ return value;
305
+ };
306
+ traverse(template, function (value, key, parent) {
307
+ if (typeof key === 'string') {
308
+ actions.push(function () {
309
+ delete parent[key];
310
+ parent[
311
+ // https://github.com/nuysoft/Mock/blob/refactoring/src/mock/schema/schema.js#L16
312
+ key.replace(keyRe, '$1')] = normalizeValue(value);
313
+ });
314
+ }
315
+ });
316
+ actions.forEach(function (action) { return action(); });
317
+ return jsonToJsonSchema(template, customTypeMapping);
313
318
  }
314
319
  /**
315
320
  * 获得属性定义列表的 JSONSchema 对象。
@@ -317,39 +322,32 @@ export function mockjsTemplateToJsonSchema(template, customTypeMapping) {
317
322
  * @param propDefinitions 属性定义列表
318
323
  * @returns JSONSchema 对象
319
324
  */
320
-
321
325
  export function propDefinitionsToJsonSchema(propDefinitions, customTypeMapping) {
322
- return processJsonSchema({
323
- type: 'object',
324
- required: propDefinitions.reduce(function (res, prop) {
325
- if (prop.required) {
326
- res.push(prop.name);
327
- }
328
-
329
- return res;
330
- }, []),
331
- properties: propDefinitions.reduce(function (res, prop) {
332
- res[prop.name] = _extends({
333
- type: prop.type,
334
- description: prop.comment
335
- }, prop.type === 'file' ? {
336
- tsType: FileData.name
337
- } : {});
338
- return res;
339
- }, {})
340
- }, customTypeMapping);
326
+ return processJsonSchema({
327
+ type: 'object',
328
+ required: propDefinitions.reduce(function (res, prop) {
329
+ if (prop.required) {
330
+ res.push(prop.name);
331
+ }
332
+ return res;
333
+ }, []),
334
+ properties: propDefinitions.reduce(function (res, prop) {
335
+ res[prop.name] = __assign({ type: prop.type, description: prop.comment }, (prop.type === 'file' ? { tsType: FileData.name } : {}));
336
+ return res;
337
+ }, {}),
338
+ }, customTypeMapping);
341
339
  }
342
340
  var JSTTOptions = {
343
- bannerComment: '',
344
- style: {
345
- bracketSpacing: false,
346
- printWidth: 120,
347
- semi: true,
348
- singleQuote: true,
349
- tabWidth: 2,
350
- trailingComma: 'none',
351
- useTabs: false
352
- }
341
+ bannerComment: '',
342
+ style: {
343
+ bracketSpacing: false,
344
+ printWidth: 120,
345
+ semi: true,
346
+ singleQuote: true,
347
+ tabWidth: 2,
348
+ trailingComma: 'none',
349
+ useTabs: false,
350
+ },
353
351
  };
354
352
  /**
355
353
  * 根据 JSONSchema 对象生产 TypeScript 类型定义。
@@ -358,350 +356,230 @@ var JSTTOptions = {
358
356
  * @param typeName 类型名称
359
357
  * @returns TypeScript 类型定义
360
358
  */
361
-
362
- export function jsonSchemaToType(_x, _x2) {
363
- return _jsonSchemaToType.apply(this, arguments);
364
- }
365
-
366
- function _jsonSchemaToType() {
367
- _jsonSchemaToType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(jsonSchema, typeName) {
368
- var fakeTypeName, code;
369
- return _regeneratorRuntime.wrap(function _callee$(_context) {
370
- while (1) {
371
- switch (_context.prev = _context.next) {
372
- case 0:
373
- if (!isEmpty(jsonSchema)) {
374
- _context.next = 2;
375
- break;
376
- }
377
-
378
- return _context.abrupt("return", "export interface " + typeName + " {}");
379
-
380
- case 2:
381
- if (!jsonSchema.__is_any__) {
382
- _context.next = 5;
383
- break;
359
+ export function jsonSchemaToType(jsonSchema, typeName) {
360
+ return __awaiter(this, void 0, void 0, function () {
361
+ var fakeTypeName, code;
362
+ return __generator(this, function (_a) {
363
+ switch (_a.label) {
364
+ case 0:
365
+ if (isEmpty(jsonSchema)) {
366
+ return [2 /*return*/, "export interface ".concat(typeName, " {}")];
367
+ }
368
+ if (jsonSchema.__is_any__) {
369
+ delete jsonSchema.__is_any__;
370
+ return [2 /*return*/, "export type ".concat(typeName, " = any")];
371
+ }
372
+ fakeTypeName = 'THISISAFAKETYPENAME';
373
+ return [4 /*yield*/, compile(jsonSchemaToJSTTJsonSchema(cloneDeepFast(jsonSchema), typeName), fakeTypeName, JSTTOptions)];
374
+ case 1:
375
+ code = _a.sent();
376
+ return [2 /*return*/, code.replace(fakeTypeName, typeName).trim()];
384
377
  }
385
-
386
- delete jsonSchema.__is_any__;
387
- return _context.abrupt("return", "export type " + typeName + " = any");
388
-
389
- case 5:
390
- // JSTT 会转换 typeName,因此传入一个全大写的假 typeName,生成代码后再替换回真正的 typeName
391
- fakeTypeName = 'THISISAFAKETYPENAME';
392
- _context.next = 8;
393
- return compile(jsonSchemaToJSTTJsonSchema(cloneDeepFast(jsonSchema), typeName), fakeTypeName, JSTTOptions);
394
-
395
- case 8:
396
- code = _context.sent;
397
- return _context.abrupt("return", code.replace(fakeTypeName, typeName).trim());
398
-
399
- case 10:
400
- case "end":
401
- return _context.stop();
402
- }
403
- }
404
- }, _callee);
405
- }));
406
- return _jsonSchemaToType.apply(this, arguments);
378
+ });
379
+ });
407
380
  }
408
-
409
381
  export function getRequestDataJsonSchema(interfaceInfo, customTypeMapping) {
410
- var jsonSchema; // 处理表单数据(仅 POST 类接口)
411
-
412
- if (isPostLikeMethod(interfaceInfo.method)) {
413
- switch (interfaceInfo.req_body_type) {
414
- case RequestBodyType.form:
415
- jsonSchema = propDefinitionsToJsonSchema(interfaceInfo.req_body_form.map(function (item) {
416
- return {
382
+ var jsonSchema;
383
+ // 处理表单数据(仅 POST 类接口)
384
+ if (isPostLikeMethod(interfaceInfo.method)) {
385
+ switch (interfaceInfo.req_body_type) {
386
+ case RequestBodyType.form:
387
+ jsonSchema = propDefinitionsToJsonSchema(interfaceInfo.req_body_form.map(function (item) { return ({
388
+ name: item.name,
389
+ required: item.required === Required.true,
390
+ type: (item.type === RequestFormItemType.file
391
+ ? 'file'
392
+ : 'string'),
393
+ comment: item.desc,
394
+ }); }), customTypeMapping);
395
+ break;
396
+ case RequestBodyType.json:
397
+ if (interfaceInfo.req_body_other) {
398
+ jsonSchema = interfaceInfo.req_body_is_json_schema
399
+ ? jsonSchemaStringToJsonSchema(interfaceInfo.req_body_other, customTypeMapping)
400
+ : jsonToJsonSchema(JSON5.parse(interfaceInfo.req_body_other), customTypeMapping);
401
+ }
402
+ break;
403
+ default:
404
+ /* istanbul ignore next */
405
+ break;
406
+ }
407
+ }
408
+ // 处理查询数据
409
+ if (isArray(interfaceInfo.req_query) && interfaceInfo.req_query.length) {
410
+ var queryJsonSchema = propDefinitionsToJsonSchema(interfaceInfo.req_query.map(function (item) { return ({
417
411
  name: item.name,
418
412
  required: item.required === Required.true,
419
- type: item.type === RequestFormItemType.file ? 'file' : 'string',
420
- comment: item.desc
421
- };
422
- }), customTypeMapping);
423
- break;
424
-
425
- case RequestBodyType.json:
426
- if (interfaceInfo.req_body_other) {
427
- jsonSchema = interfaceInfo.req_body_is_json_schema ? jsonSchemaStringToJsonSchema(interfaceInfo.req_body_other, customTypeMapping) : jsonToJsonSchema(JSON5.parse(interfaceInfo.req_body_other), customTypeMapping);
413
+ type: item.type || 'string',
414
+ comment: item.desc,
415
+ }); }), customTypeMapping);
416
+ /* istanbul ignore else */
417
+ if (jsonSchema) {
418
+ jsonSchema.properties = __assign(__assign({}, jsonSchema.properties), queryJsonSchema.properties);
419
+ jsonSchema.required = __spreadArray(__spreadArray([], (Array.isArray(jsonSchema.required) ? jsonSchema.required : []), true), (Array.isArray(queryJsonSchema.required)
420
+ ? queryJsonSchema.required
421
+ : []), true);
422
+ }
423
+ else {
424
+ jsonSchema = queryJsonSchema;
428
425
  }
429
-
430
- break;
431
-
432
- default:
433
- /* istanbul ignore next */
434
- break;
435
- }
436
- } // 处理查询数据
437
-
438
-
439
- if (isArray(interfaceInfo.req_query) && interfaceInfo.req_query.length) {
440
- var queryJsonSchema = propDefinitionsToJsonSchema(interfaceInfo.req_query.map(function (item) {
441
- return {
442
- name: item.name,
443
- required: item.required === Required.true,
444
- type: item.type || 'string',
445
- comment: item.desc
446
- };
447
- }), customTypeMapping);
448
- /* istanbul ignore else */
449
-
450
- if (jsonSchema) {
451
- jsonSchema.properties = _extends({}, jsonSchema.properties, queryJsonSchema.properties);
452
- jsonSchema.required = [].concat(Array.isArray(jsonSchema.required) ? jsonSchema.required : [], Array.isArray(queryJsonSchema.required) ? queryJsonSchema.required : []);
453
- } else {
454
- jsonSchema = queryJsonSchema;
455
426
  }
456
- } // 处理路径参数
457
-
458
-
459
- if (isArray(interfaceInfo.req_params) && interfaceInfo.req_params.length) {
460
- var paramsJsonSchema = propDefinitionsToJsonSchema(interfaceInfo.req_params.map(function (item) {
461
- return {
462
- name: item.name,
463
- required: true,
464
- type: item.type || 'string',
465
- comment: item.desc
466
- };
467
- }), customTypeMapping);
468
- /* istanbul ignore else */
469
-
470
- if (jsonSchema) {
471
- jsonSchema.properties = _extends({}, jsonSchema.properties, paramsJsonSchema.properties);
472
- jsonSchema.required = [].concat(Array.isArray(jsonSchema.required) ? jsonSchema.required : [], Array.isArray(paramsJsonSchema.required) ? paramsJsonSchema.required : []);
473
- } else {
474
- jsonSchema = paramsJsonSchema;
427
+ // 处理路径参数
428
+ if (isArray(interfaceInfo.req_params) && interfaceInfo.req_params.length) {
429
+ var paramsJsonSchema = propDefinitionsToJsonSchema(interfaceInfo.req_params.map(function (item) { return ({
430
+ name: item.name,
431
+ required: true,
432
+ type: item.type || 'string',
433
+ comment: item.desc,
434
+ }); }), customTypeMapping);
435
+ /* istanbul ignore else */
436
+ if (jsonSchema) {
437
+ jsonSchema.properties = __assign(__assign({}, jsonSchema.properties), paramsJsonSchema.properties);
438
+ jsonSchema.required = __spreadArray(__spreadArray([], (Array.isArray(jsonSchema.required) ? jsonSchema.required : []), true), (Array.isArray(paramsJsonSchema.required)
439
+ ? paramsJsonSchema.required
440
+ : []), true);
441
+ }
442
+ else {
443
+ jsonSchema = paramsJsonSchema;
444
+ }
475
445
  }
476
- }
477
-
478
- return jsonSchema || {};
446
+ return jsonSchema || {};
479
447
  }
480
448
  export function getResponseDataJsonSchema(interfaceInfo, customTypeMapping, dataKey) {
481
- var jsonSchema = {};
482
-
483
- switch (interfaceInfo.res_body_type) {
484
- case ResponseBodyType.json:
485
- if (interfaceInfo.res_body) {
486
- jsonSchema = interfaceInfo.res_body_is_json_schema ? jsonSchemaStringToJsonSchema(interfaceInfo.res_body, customTypeMapping) : mockjsTemplateToJsonSchema(JSON5.parse(interfaceInfo.res_body), customTypeMapping);
487
- }
488
-
489
- break;
490
-
491
- default:
492
- jsonSchema = {
493
- __is_any__: true
494
- };
495
- break;
496
- }
497
-
498
- if (dataKey && jsonSchema) {
499
- jsonSchema = reachJsonSchema(jsonSchema, dataKey);
500
- }
501
-
502
- return jsonSchema;
449
+ var jsonSchema = {};
450
+ switch (interfaceInfo.res_body_type) {
451
+ case ResponseBodyType.json:
452
+ if (interfaceInfo.res_body) {
453
+ jsonSchema = interfaceInfo.res_body_is_json_schema
454
+ ? jsonSchemaStringToJsonSchema(interfaceInfo.res_body, customTypeMapping)
455
+ : mockjsTemplateToJsonSchema(JSON5.parse(interfaceInfo.res_body), customTypeMapping);
456
+ }
457
+ break;
458
+ default:
459
+ jsonSchema = { __is_any__: true };
460
+ break;
461
+ }
462
+ if (dataKey && jsonSchema) {
463
+ jsonSchema = reachJsonSchema(jsonSchema, dataKey);
464
+ }
465
+ return jsonSchema;
503
466
  }
504
467
  export function reachJsonSchema(jsonSchema, path) {
505
- var last = jsonSchema;
506
-
507
- for (var _iterator2 = _createForOfIteratorHelperLoose(castArray(path)), _step2; !(_step2 = _iterator2()).done;) {
508
- var _last$properties;
509
-
510
- var segment = _step2.value;
511
-
512
- var _last = (_last$properties = last.properties) == null ? void 0 : _last$properties[segment];
513
-
514
- if (!_last) {
515
- return jsonSchema;
468
+ var _a;
469
+ var last = jsonSchema;
470
+ for (var _i = 0, _b = castArray(path); _i < _b.length; _i++) {
471
+ var segment = _b[_i];
472
+ var _last = (_a = last.properties) === null || _a === void 0 ? void 0 : _a[segment];
473
+ if (!_last) {
474
+ return jsonSchema;
475
+ }
476
+ last = _last;
516
477
  }
517
-
518
- last = _last;
519
- }
520
-
521
- return last;
478
+ return last;
522
479
  }
523
480
  export function sortByWeights(list) {
524
- list.sort(function (a, b) {
525
- var _x$weights;
526
-
527
- var x = a.weights.length > b.weights.length ? b : a;
528
- var minLen = Math.min(a.weights.length, b.weights.length);
529
- var maxLen = Math.max(a.weights.length, b.weights.length);
530
-
531
- (_x$weights = x.weights).push.apply(_x$weights, new Array(maxLen - minLen).fill(0));
532
-
533
- var w = a.weights.reduce(function (w, _, i) {
534
- if (w === 0) {
535
- w = a.weights[i] - b.weights[i];
536
- }
537
-
538
- return w;
539
- }, 0);
540
- return w;
541
- });
542
- return list;
481
+ list.sort(function (a, b) {
482
+ var _a;
483
+ var x = a.weights.length > b.weights.length ? b : a;
484
+ var minLen = Math.min(a.weights.length, b.weights.length);
485
+ var maxLen = Math.max(a.weights.length, b.weights.length);
486
+ (_a = x.weights).push.apply(_a, new Array(maxLen - minLen).fill(0));
487
+ var w = a.weights.reduce(function (w, _, i) {
488
+ if (w === 0) {
489
+ w = a.weights[i] - b.weights[i];
490
+ }
491
+ return w;
492
+ }, 0);
493
+ return w;
494
+ });
495
+ return list;
543
496
  }
544
497
  export function isGetLikeMethod(method) {
545
- return method === Method.GET || method === Method.OPTIONS || method === Method.HEAD;
498
+ return (method === Method.GET || method === Method.OPTIONS || method === Method.HEAD);
546
499
  }
547
500
  export function isPostLikeMethod(method) {
548
- return !isGetLikeMethod(method);
501
+ return !isGetLikeMethod(method);
549
502
  }
550
- export function getPrettier(_x3) {
551
- return _getPrettier.apply(this, arguments);
552
- }
553
-
554
- function _getPrettier() {
555
- _getPrettier = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(cwd) {
556
- var projectPrettierPath;
557
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
558
- while (1) {
559
- switch (_context2.prev = _context2.next) {
560
- case 0:
561
- projectPrettierPath = path.join(cwd, 'node_modules/prettier');
562
- _context2.next = 3;
563
- return fs.pathExists(projectPrettierPath);
564
-
565
- case 3:
566
- if (!_context2.sent) {
567
- _context2.next = 5;
568
- break;
503
+ export function getPrettier(cwd) {
504
+ return __awaiter(this, void 0, void 0, function () {
505
+ var projectPrettierPath;
506
+ return __generator(this, function (_a) {
507
+ switch (_a.label) {
508
+ case 0:
509
+ projectPrettierPath = path.join(cwd, 'node_modules/prettier');
510
+ return [4 /*yield*/, fs.pathExists(projectPrettierPath)];
511
+ case 1:
512
+ if (_a.sent()) {
513
+ return [2 /*return*/, require(projectPrettierPath)];
514
+ }
515
+ return [2 /*return*/, require('prettier')];
569
516
  }
570
-
571
- return _context2.abrupt("return", require(projectPrettierPath));
572
-
573
- case 5:
574
- return _context2.abrupt("return", require('prettier'));
575
-
576
- case 6:
577
- case "end":
578
- return _context2.stop();
579
- }
580
- }
581
- }, _callee2);
582
- }));
583
- return _getPrettier.apply(this, arguments);
517
+ });
518
+ });
584
519
  }
585
-
586
520
  export function getPrettierOptions() {
587
- return _getPrettierOptions.apply(this, arguments);
588
- }
589
-
590
- function _getPrettierOptions() {
591
- _getPrettierOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
592
- var prettierOptions, _yield$run, prettierConfigPathErr, prettierConfigPath, _yield$run2, prettierConfigErr, prettierConfig;
593
-
594
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
595
- while (1) {
596
- switch (_context3.prev = _context3.next) {
597
- case 0:
598
- prettierOptions = {
599
- parser: 'typescript',
600
- printWidth: 120,
601
- tabWidth: 2,
602
- singleQuote: true,
603
- semi: false,
604
- trailingComma: 'all',
605
- bracketSpacing: false,
606
- endOfLine: 'lf'
607
- }; // 测试时跳过本地配置的解析
608
-
609
- if (!process.env.JEST_WORKER_ID) {
610
- _context3.next = 3;
611
- break;
612
- }
613
-
614
- return _context3.abrupt("return", prettierOptions);
615
-
616
- case 3:
617
- _context3.next = 5;
618
- return run(function () {
619
- return prettier.resolveConfigFile();
620
- });
621
-
622
- case 5:
623
- _yield$run = _context3.sent;
624
- prettierConfigPathErr = _yield$run[0];
625
- prettierConfigPath = _yield$run[1];
626
-
627
- if (!(prettierConfigPathErr || !prettierConfigPath)) {
628
- _context3.next = 10;
629
- break;
630
- }
631
-
632
- return _context3.abrupt("return", prettierOptions);
633
-
634
- case 10:
635
- _context3.next = 12;
636
- return run(function () {
637
- return prettier.resolveConfig(prettierConfigPath);
638
- });
639
-
640
- case 12:
641
- _yield$run2 = _context3.sent;
642
- prettierConfigErr = _yield$run2[0];
643
- prettierConfig = _yield$run2[1];
644
-
645
- if (!(prettierConfigErr || !prettierConfig)) {
646
- _context3.next = 17;
647
- break;
521
+ return __awaiter(this, void 0, void 0, function () {
522
+ var prettierOptions, _a, prettierConfigPathErr, prettierConfigPath, _b, prettierConfigErr, prettierConfig;
523
+ return __generator(this, function (_c) {
524
+ switch (_c.label) {
525
+ case 0:
526
+ prettierOptions = {
527
+ parser: 'typescript',
528
+ printWidth: 120,
529
+ tabWidth: 2,
530
+ singleQuote: true,
531
+ semi: false,
532
+ trailingComma: 'all',
533
+ bracketSpacing: false,
534
+ endOfLine: 'lf',
535
+ };
536
+ // 测试时跳过本地配置的解析
537
+ if (process.env.JEST_WORKER_ID) {
538
+ return [2 /*return*/, prettierOptions];
539
+ }
540
+ return [4 /*yield*/, run(function () {
541
+ return prettier.resolveConfigFile();
542
+ })];
543
+ case 1:
544
+ _a = _c.sent(), prettierConfigPathErr = _a[0], prettierConfigPath = _a[1];
545
+ if (prettierConfigPathErr || !prettierConfigPath) {
546
+ return [2 /*return*/, prettierOptions];
547
+ }
548
+ return [4 /*yield*/, run(function () {
549
+ return prettier.resolveConfig(prettierConfigPath);
550
+ })];
551
+ case 2:
552
+ _b = _c.sent(), prettierConfigErr = _b[0], prettierConfig = _b[1];
553
+ if (prettierConfigErr || !prettierConfig) {
554
+ return [2 /*return*/, prettierOptions];
555
+ }
556
+ return [2 /*return*/, __assign(__assign(__assign({}, prettierOptions), prettierConfig), { parser: 'typescript' })];
648
557
  }
649
-
650
- return _context3.abrupt("return", prettierOptions);
651
-
652
- case 17:
653
- return _context3.abrupt("return", _extends({}, prettierOptions, prettierConfig, {
654
- parser: 'typescript'
655
- }));
656
-
657
- case 18:
658
- case "end":
659
- return _context3.stop();
660
- }
661
- }
662
- }, _callee3);
663
- }));
664
- return _getPrettierOptions.apply(this, arguments);
558
+ });
559
+ });
665
560
  }
666
-
667
561
  export var getCachedPrettierOptions = memoize(getPrettierOptions);
668
- export function httpGet(_x4, _x5) {
669
- return _httpGet.apply(this, arguments);
670
- }
671
-
672
- function _httpGet() {
673
- _httpGet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url, query) {
674
- var _url, res;
675
-
676
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
677
- while (1) {
678
- switch (_context4.prev = _context4.next) {
679
- case 0:
680
- _url = new URL(url);
681
-
682
- if (query) {
683
- Object.keys(query).forEach(function (key) {
684
- _url.searchParams.set(key, query[key]);
685
- });
562
+ export function httpGet(url, query) {
563
+ return __awaiter(this, void 0, void 0, function () {
564
+ var _url, res;
565
+ return __generator(this, function (_a) {
566
+ switch (_a.label) {
567
+ case 0:
568
+ _url = new URL(url);
569
+ if (query) {
570
+ Object.keys(query).forEach(function (key) {
571
+ _url.searchParams.set(key, query[key]);
572
+ });
573
+ }
574
+ url = _url.toString();
575
+ return [4 /*yield*/, nodeFetch(url, {
576
+ method: 'GET',
577
+ agent: new ProxyAgent(),
578
+ })];
579
+ case 1:
580
+ res = _a.sent();
581
+ return [2 /*return*/, res.json()];
686
582
  }
687
-
688
- url = _url.toString();
689
- _context4.next = 5;
690
- return nodeFetch(url, {
691
- method: 'GET',
692
- agent: new ProxyAgent()
693
- });
694
-
695
- case 5:
696
- res = _context4.sent;
697
- return _context4.abrupt("return", res.json());
698
-
699
- case 7:
700
- case "end":
701
- return _context4.stop();
702
- }
703
- }
704
- }, _callee4);
705
- }));
706
- return _httpGet.apply(this, arguments);
707
- }
583
+ });
584
+ });
585
+ }