yapi-to-typescript2 1.0.0
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/LICENSE +21 -0
- package/README.md +22 -0
- package/lib/cjs/Generator.js +1135 -0
- package/lib/cjs/SwaggerToYApiServer.js +336 -0
- package/lib/cjs/cli.js +285 -0
- package/lib/cjs/helpers.js +230 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/swaggerJsonToYApiData.js +496 -0
- package/lib/cjs/types.js +100 -0
- package/lib/cjs/utils.js +766 -0
- package/lib/esm/Generator.js +1111 -0
- package/lib/esm/SwaggerToYApiServer.js +317 -0
- package/lib/esm/cli.js +257 -0
- package/lib/esm/helpers.js +216 -0
- package/lib/esm/index.d.ts +845 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/swaggerJsonToYApiData.js +483 -0
- package/lib/esm/types.js +79 -0
- package/lib/esm/utils.js +707 -0
- package/package.json +114 -0
|
@@ -0,0 +1,1111 @@
|
|
|
1
|
+
import _createForOfIteratorHelperLoose from "@babel/runtime/helpers/esm/createForOfIteratorHelperLoose";
|
|
2
|
+
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
|
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13;
|
|
7
|
+
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
import * as changeCase from 'change-case';
|
|
10
|
+
import dayjs from 'dayjs';
|
|
11
|
+
import fs from 'fs-extra';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import { castArray, cloneDeepFast, dedent, groupBy, isEmpty, isFunction, last, memoize, noop, omit, uniq, values } from 'vtils';
|
|
14
|
+
import { Method, QueryStringArrayFormat, RequestBodyType } from './types';
|
|
15
|
+
import { exec } from 'child_process';
|
|
16
|
+
import { getCachedPrettierOptions, getNormalizedRelativePath, getPrettier, getRequestDataJsonSchema, getResponseDataJsonSchema, httpGet, jsonSchemaToType, sortByWeights, throwError } from './utils';
|
|
17
|
+
import { SwaggerToYApiServer } from './SwaggerToYApiServer';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @see https://webpack.js.org/guides/tree-shaking/#mark-a-function-call-as-side-effect-free
|
|
21
|
+
* @see https://terser.org/docs/api-reference.html#annotations
|
|
22
|
+
*/
|
|
23
|
+
var COMPRESSOR_TREE_SHAKING_ANNOTATION = '/*#__PURE__*/';
|
|
24
|
+
export var Generator = /*#__PURE__*/function () {
|
|
25
|
+
/** 配置 */
|
|
26
|
+
function Generator(config, options) {
|
|
27
|
+
var _this = this;
|
|
28
|
+
|
|
29
|
+
if (options === void 0) {
|
|
30
|
+
options = {
|
|
31
|
+
cwd: process.cwd()
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.options = options;
|
|
36
|
+
this.config = [];
|
|
37
|
+
this.disposes = [];
|
|
38
|
+
this.fetchProject = memoize( /*#__PURE__*/function () {
|
|
39
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
40
|
+
var serverUrl, token, projectInfo, basePath;
|
|
41
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
|
+
while (1) {
|
|
43
|
+
switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
serverUrl = _ref.serverUrl, token = _ref.token;
|
|
46
|
+
_context.next = 3;
|
|
47
|
+
return _this.fetchApi(serverUrl + "/api/project/get", {
|
|
48
|
+
token: token
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
case 3:
|
|
52
|
+
projectInfo = _context.sent;
|
|
53
|
+
basePath = ("/" + (projectInfo.basepath || '/')).replace(/\/+$/, '').replace(/^\/+/, '/');
|
|
54
|
+
projectInfo.basepath = basePath; // 实现项目在 YApi 上的地址
|
|
55
|
+
|
|
56
|
+
projectInfo._url = serverUrl + "/project/" + projectInfo._id + "/interface/api";
|
|
57
|
+
return _context.abrupt("return", projectInfo);
|
|
58
|
+
|
|
59
|
+
case 8:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
return function (_x) {
|
|
68
|
+
return _ref2.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}(), function (_ref3) {
|
|
71
|
+
var serverUrl = _ref3.serverUrl,
|
|
72
|
+
token = _ref3.token;
|
|
73
|
+
return serverUrl + "|" + token;
|
|
74
|
+
});
|
|
75
|
+
this.fetchExport = memoize( /*#__PURE__*/function () {
|
|
76
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4) {
|
|
77
|
+
var serverUrl, token, projectInfo, categoryList;
|
|
78
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context2.prev = _context2.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
serverUrl = _ref4.serverUrl, token = _ref4.token;
|
|
83
|
+
_context2.next = 3;
|
|
84
|
+
return _this.fetchProject({
|
|
85
|
+
serverUrl: serverUrl,
|
|
86
|
+
token: token
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
case 3:
|
|
90
|
+
projectInfo = _context2.sent;
|
|
91
|
+
_context2.next = 6;
|
|
92
|
+
return _this.fetchApi(serverUrl + "/api/plugin/export", {
|
|
93
|
+
type: 'json',
|
|
94
|
+
status: 'all',
|
|
95
|
+
isWiki: 'false',
|
|
96
|
+
token: token
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
case 6:
|
|
100
|
+
categoryList = _context2.sent;
|
|
101
|
+
return _context2.abrupt("return", categoryList.map(function (cat) {
|
|
102
|
+
var _cat$list, _cat$list$, _cat$list2, _cat$list2$;
|
|
103
|
+
|
|
104
|
+
var projectId = ((_cat$list = cat.list) == null ? void 0 : (_cat$list$ = _cat$list[0]) == null ? void 0 : _cat$list$.project_id) || 0;
|
|
105
|
+
var catId = ((_cat$list2 = cat.list) == null ? void 0 : (_cat$list2$ = _cat$list2[0]) == null ? void 0 : _cat$list2$.catid) || 0; // 实现分类在 YApi 上的地址
|
|
106
|
+
|
|
107
|
+
// 实现分类在 YApi 上的地址
|
|
108
|
+
cat._url = serverUrl + "/project/" + projectId + "/interface/api/cat_" + catId;
|
|
109
|
+
cat.list = (cat.list || []).map(function (item) {
|
|
110
|
+
var interfaceId = item._id; // 实现接口在 YApi 上的地址
|
|
111
|
+
|
|
112
|
+
// 实现接口在 YApi 上的地址
|
|
113
|
+
item._url = serverUrl + "/project/" + projectId + "/interface/api/" + interfaceId;
|
|
114
|
+
item.path = "" + projectInfo.basepath + item.path;
|
|
115
|
+
return item;
|
|
116
|
+
});
|
|
117
|
+
return cat;
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
case 8:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context2.stop();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, _callee2);
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
return function (_x2) {
|
|
129
|
+
return _ref5.apply(this, arguments);
|
|
130
|
+
};
|
|
131
|
+
}(), function (_ref6) {
|
|
132
|
+
var serverUrl = _ref6.serverUrl,
|
|
133
|
+
token = _ref6.token;
|
|
134
|
+
return serverUrl + "|" + token;
|
|
135
|
+
});
|
|
136
|
+
// config 可能是对象或数组,统一为数组
|
|
137
|
+
this.config = castArray(config);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var _proto = Generator.prototype;
|
|
141
|
+
|
|
142
|
+
_proto.prepare = /*#__PURE__*/function () {
|
|
143
|
+
var _prepare = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
144
|
+
var _this2 = this;
|
|
145
|
+
|
|
146
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
147
|
+
while (1) {
|
|
148
|
+
switch (_context4.prev = _context4.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
_context4.next = 2;
|
|
151
|
+
return Promise.all( // config 可能是对象或数组,统一为数组
|
|
152
|
+
this.config.map( /*#__PURE__*/function () {
|
|
153
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(item) {
|
|
154
|
+
var swaggerToYApiServer;
|
|
155
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
156
|
+
while (1) {
|
|
157
|
+
switch (_context3.prev = _context3.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
if (!(item.serverType === 'swagger')) {
|
|
160
|
+
_context3.next = 6;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
swaggerToYApiServer = new SwaggerToYApiServer({
|
|
165
|
+
swaggerJsonUrl: item.serverUrl
|
|
166
|
+
});
|
|
167
|
+
_context3.next = 4;
|
|
168
|
+
return swaggerToYApiServer.start();
|
|
169
|
+
|
|
170
|
+
case 4:
|
|
171
|
+
item.serverUrl = _context3.sent;
|
|
172
|
+
|
|
173
|
+
_this2.disposes.push(function () {
|
|
174
|
+
return swaggerToYApiServer.stop();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
case 6:
|
|
178
|
+
if (item.serverUrl) {
|
|
179
|
+
// 去除地址后面的 /
|
|
180
|
+
// fix: https://github.com/fjc0k/yapi-to-typescript/issues/22
|
|
181
|
+
item.serverUrl = item.serverUrl.replace(/\/+$/, '');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return _context3.abrupt("return", item);
|
|
185
|
+
|
|
186
|
+
case 8:
|
|
187
|
+
case "end":
|
|
188
|
+
return _context3.stop();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, _callee3);
|
|
192
|
+
}));
|
|
193
|
+
|
|
194
|
+
return function (_x3) {
|
|
195
|
+
return _ref7.apply(this, arguments);
|
|
196
|
+
};
|
|
197
|
+
}()));
|
|
198
|
+
|
|
199
|
+
case 2:
|
|
200
|
+
this.config = _context4.sent;
|
|
201
|
+
|
|
202
|
+
case 3:
|
|
203
|
+
case "end":
|
|
204
|
+
return _context4.stop();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}, _callee4, this);
|
|
208
|
+
}));
|
|
209
|
+
|
|
210
|
+
function prepare() {
|
|
211
|
+
return _prepare.apply(this, arguments);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return prepare;
|
|
215
|
+
}();
|
|
216
|
+
|
|
217
|
+
_proto.generate = /*#__PURE__*/function () {
|
|
218
|
+
var _generate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
219
|
+
var _this3 = this;
|
|
220
|
+
|
|
221
|
+
var outputFileList;
|
|
222
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
223
|
+
while (1) {
|
|
224
|
+
switch (_context10.prev = _context10.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
outputFileList = Object.create(null);
|
|
227
|
+
_context10.next = 3;
|
|
228
|
+
return Promise.all(this.config.map( /*#__PURE__*/function () {
|
|
229
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(serverConfig, serverIndex) {
|
|
230
|
+
var projects;
|
|
231
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
232
|
+
while (1) {
|
|
233
|
+
switch (_context9.prev = _context9.next) {
|
|
234
|
+
case 0:
|
|
235
|
+
projects = serverConfig.projects.reduce(function (projects, project) {
|
|
236
|
+
projects.push.apply(projects, castArray(project.token).map(function (token) {
|
|
237
|
+
return _extends({}, project, {
|
|
238
|
+
token: token
|
|
239
|
+
});
|
|
240
|
+
}));
|
|
241
|
+
return projects;
|
|
242
|
+
}, []);
|
|
243
|
+
return _context9.abrupt("return", Promise.all(projects.map( /*#__PURE__*/function () {
|
|
244
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(projectConfig, projectIndex) {
|
|
245
|
+
var projectInfo;
|
|
246
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
247
|
+
while (1) {
|
|
248
|
+
switch (_context8.prev = _context8.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
_context8.next = 2;
|
|
251
|
+
return _this3.fetchProjectInfo(_extends({}, serverConfig, projectConfig));
|
|
252
|
+
|
|
253
|
+
case 2:
|
|
254
|
+
projectInfo = _context8.sent;
|
|
255
|
+
_context8.next = 5;
|
|
256
|
+
return Promise.all(projectConfig.categories.map( /*#__PURE__*/function () {
|
|
257
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(categoryConfig, categoryIndex) {
|
|
258
|
+
var categoryIds, _categoryIds, excludedCategoryIds, codes, _iterator, _step, _outputFileList$group, groupedCodes;
|
|
259
|
+
|
|
260
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
261
|
+
while (1) {
|
|
262
|
+
switch (_context7.prev = _context7.next) {
|
|
263
|
+
case 0:
|
|
264
|
+
// 分类处理
|
|
265
|
+
// 数组化
|
|
266
|
+
categoryIds = castArray(categoryConfig.id); // 全部分类
|
|
267
|
+
|
|
268
|
+
// 全部分类
|
|
269
|
+
if (categoryIds.includes(0)) {
|
|
270
|
+
(_categoryIds = categoryIds).push.apply(_categoryIds, projectInfo.cats.map(function (cat) {
|
|
271
|
+
return cat._id;
|
|
272
|
+
}));
|
|
273
|
+
} // 唯一化
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
// 唯一化
|
|
277
|
+
categoryIds = uniq(categoryIds); // 去掉被排除的分类
|
|
278
|
+
|
|
279
|
+
// 去掉被排除的分类
|
|
280
|
+
excludedCategoryIds = categoryIds.filter(function (id) {
|
|
281
|
+
return id < 0;
|
|
282
|
+
}).map(Math.abs);
|
|
283
|
+
categoryIds = categoryIds.filter(function (id) {
|
|
284
|
+
return !excludedCategoryIds.includes(Math.abs(id));
|
|
285
|
+
}); // 删除不存在的分类
|
|
286
|
+
|
|
287
|
+
// 删除不存在的分类
|
|
288
|
+
categoryIds = categoryIds.filter(function (id) {
|
|
289
|
+
return !!projectInfo.cats.find(function (cat) {
|
|
290
|
+
return cat._id === id;
|
|
291
|
+
});
|
|
292
|
+
}); // 顺序化
|
|
293
|
+
|
|
294
|
+
// 顺序化
|
|
295
|
+
categoryIds = categoryIds.sort();
|
|
296
|
+
_context7.next = 9;
|
|
297
|
+
return Promise.all(categoryIds.map( /*#__PURE__*/function () {
|
|
298
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id, categoryIndex2) {
|
|
299
|
+
var syntheticalConfig, interfaceList, interfaceCodes, groupedInterfaceCodes;
|
|
300
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
301
|
+
while (1) {
|
|
302
|
+
switch (_context6.prev = _context6.next) {
|
|
303
|
+
case 0:
|
|
304
|
+
categoryConfig = _extends({}, categoryConfig, {
|
|
305
|
+
id: id
|
|
306
|
+
});
|
|
307
|
+
syntheticalConfig = _extends({}, serverConfig, projectConfig, categoryConfig, {
|
|
308
|
+
mockUrl: projectInfo.getMockUrl()
|
|
309
|
+
});
|
|
310
|
+
syntheticalConfig.target = syntheticalConfig.target || 'typescript';
|
|
311
|
+
syntheticalConfig.devUrl = projectInfo.getDevUrl(syntheticalConfig.devEnvName);
|
|
312
|
+
syntheticalConfig.prodUrl = projectInfo.getProdUrl(syntheticalConfig.prodEnvName); // 接口列表
|
|
313
|
+
|
|
314
|
+
_context6.next = 7;
|
|
315
|
+
return _this3.fetchInterfaceList(syntheticalConfig);
|
|
316
|
+
|
|
317
|
+
case 7:
|
|
318
|
+
interfaceList = _context6.sent;
|
|
319
|
+
interfaceList = interfaceList.map(function (interfaceInfo) {
|
|
320
|
+
// 实现 _project 字段
|
|
321
|
+
interfaceInfo._project = omit(projectInfo, ['cats', 'getMockUrl', 'getDevUrl', 'getProdUrl']); // 预处理
|
|
322
|
+
|
|
323
|
+
// 预处理
|
|
324
|
+
var _interfaceInfo = isFunction(syntheticalConfig.preproccessInterface) ? syntheticalConfig.preproccessInterface(cloneDeepFast(interfaceInfo), changeCase, syntheticalConfig) : interfaceInfo;
|
|
325
|
+
|
|
326
|
+
return _interfaceInfo;
|
|
327
|
+
}).filter(Boolean);
|
|
328
|
+
interfaceList.sort(function (a, b) {
|
|
329
|
+
return a._id - b._id;
|
|
330
|
+
});
|
|
331
|
+
_context6.next = 12;
|
|
332
|
+
return Promise.all(interfaceList.map( /*#__PURE__*/function () {
|
|
333
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(interfaceInfo) {
|
|
334
|
+
var outputFilePath, categoryUID, code, weights;
|
|
335
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
336
|
+
while (1) {
|
|
337
|
+
switch (_context5.prev = _context5.next) {
|
|
338
|
+
case 0:
|
|
339
|
+
outputFilePath = path.resolve(_this3.options.cwd, typeof syntheticalConfig.outputFilePath === 'function' ? syntheticalConfig.outputFilePath(interfaceInfo, changeCase) : syntheticalConfig.outputFilePath);
|
|
340
|
+
categoryUID = "_" + serverIndex + "_" + projectIndex + "_" + categoryIndex + "_" + categoryIndex2;
|
|
341
|
+
_context5.next = 4;
|
|
342
|
+
return _this3.generateInterfaceCode(syntheticalConfig, interfaceInfo, categoryUID);
|
|
343
|
+
|
|
344
|
+
case 4:
|
|
345
|
+
code = _context5.sent;
|
|
346
|
+
weights = [serverIndex, projectIndex, categoryIndex, categoryIndex2];
|
|
347
|
+
return _context5.abrupt("return", {
|
|
348
|
+
categoryUID: categoryUID,
|
|
349
|
+
outputFilePath: outputFilePath,
|
|
350
|
+
weights: weights,
|
|
351
|
+
code: code
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
case 7:
|
|
355
|
+
case "end":
|
|
356
|
+
return _context5.stop();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}, _callee5);
|
|
360
|
+
}));
|
|
361
|
+
|
|
362
|
+
return function (_x12) {
|
|
363
|
+
return _ref12.apply(this, arguments);
|
|
364
|
+
};
|
|
365
|
+
}()));
|
|
366
|
+
|
|
367
|
+
case 12:
|
|
368
|
+
interfaceCodes = _context6.sent;
|
|
369
|
+
groupedInterfaceCodes = groupBy(interfaceCodes, function (item) {
|
|
370
|
+
return item.outputFilePath;
|
|
371
|
+
});
|
|
372
|
+
return _context6.abrupt("return", Object.keys(groupedInterfaceCodes).map(function (outputFilePath) {
|
|
373
|
+
var categoryCode = [].concat(uniq(sortByWeights(groupedInterfaceCodes[outputFilePath]).map(function (item) {
|
|
374
|
+
return item.categoryUID;
|
|
375
|
+
})).map(function (categoryUID) {
|
|
376
|
+
return syntheticalConfig.typesOnly ? '' : dedent(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n const mockUrl", " = ", " as any\n const devUrl", " = ", " as any\n const prodUrl", " = ", " as any\n const dataKey", " = ", " as any\n "])), categoryUID, JSON.stringify(syntheticalConfig.mockUrl), categoryUID, JSON.stringify(syntheticalConfig.devUrl), categoryUID, JSON.stringify(syntheticalConfig.prodUrl), categoryUID, JSON.stringify(syntheticalConfig.dataKey));
|
|
377
|
+
}), sortByWeights(groupedInterfaceCodes[outputFilePath]).map(function (item) {
|
|
378
|
+
return item.code;
|
|
379
|
+
})).filter(Boolean).join('\n\n');
|
|
380
|
+
|
|
381
|
+
if (!outputFileList[outputFilePath]) {
|
|
382
|
+
outputFileList[outputFilePath] = {
|
|
383
|
+
syntheticalConfig: syntheticalConfig,
|
|
384
|
+
content: [],
|
|
385
|
+
requestFunctionFilePath: syntheticalConfig.requestFunctionFilePath ? path.resolve(_this3.options.cwd, syntheticalConfig.requestFunctionFilePath) : path.join(path.dirname(outputFilePath), 'request.ts'),
|
|
386
|
+
requestHookMakerFilePath: syntheticalConfig.reactHooks && syntheticalConfig.reactHooks.enabled ? syntheticalConfig.reactHooks.requestHookMakerFilePath ? path.resolve(_this3.options.cwd, syntheticalConfig.reactHooks.requestHookMakerFilePath) : path.join(path.dirname(outputFilePath), 'makeRequestHook.ts') : ''
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
outputFilePath: outputFilePath,
|
|
392
|
+
code: categoryCode,
|
|
393
|
+
weights: last(sortByWeights(groupedInterfaceCodes[outputFilePath])).weights
|
|
394
|
+
};
|
|
395
|
+
}));
|
|
396
|
+
|
|
397
|
+
case 15:
|
|
398
|
+
case "end":
|
|
399
|
+
return _context6.stop();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}, _callee6);
|
|
403
|
+
}));
|
|
404
|
+
|
|
405
|
+
return function (_x10, _x11) {
|
|
406
|
+
return _ref11.apply(this, arguments);
|
|
407
|
+
};
|
|
408
|
+
}()));
|
|
409
|
+
|
|
410
|
+
case 9:
|
|
411
|
+
codes = _context7.sent.flat();
|
|
412
|
+
|
|
413
|
+
for (_iterator = _createForOfIteratorHelperLoose(values(groupBy(codes, function (item) {
|
|
414
|
+
return item.outputFilePath;
|
|
415
|
+
}))); !(_step = _iterator()).done;) {
|
|
416
|
+
groupedCodes = _step.value;
|
|
417
|
+
sortByWeights(groupedCodes);
|
|
418
|
+
|
|
419
|
+
(_outputFileList$group = outputFileList[groupedCodes[0].outputFilePath].content).push.apply(_outputFileList$group, groupedCodes.map(function (item) {
|
|
420
|
+
return item.code;
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
case 11:
|
|
425
|
+
case "end":
|
|
426
|
+
return _context7.stop();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}, _callee7);
|
|
430
|
+
}));
|
|
431
|
+
|
|
432
|
+
return function (_x8, _x9) {
|
|
433
|
+
return _ref10.apply(this, arguments);
|
|
434
|
+
};
|
|
435
|
+
}()));
|
|
436
|
+
|
|
437
|
+
case 5:
|
|
438
|
+
case "end":
|
|
439
|
+
return _context8.stop();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}, _callee8);
|
|
443
|
+
}));
|
|
444
|
+
|
|
445
|
+
return function (_x6, _x7) {
|
|
446
|
+
return _ref9.apply(this, arguments);
|
|
447
|
+
};
|
|
448
|
+
}())));
|
|
449
|
+
|
|
450
|
+
case 2:
|
|
451
|
+
case "end":
|
|
452
|
+
return _context9.stop();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}, _callee9);
|
|
456
|
+
}));
|
|
457
|
+
|
|
458
|
+
return function (_x4, _x5) {
|
|
459
|
+
return _ref8.apply(this, arguments);
|
|
460
|
+
};
|
|
461
|
+
}()));
|
|
462
|
+
|
|
463
|
+
case 3:
|
|
464
|
+
return _context10.abrupt("return", outputFileList);
|
|
465
|
+
|
|
466
|
+
case 4:
|
|
467
|
+
case "end":
|
|
468
|
+
return _context10.stop();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}, _callee10, this);
|
|
472
|
+
}));
|
|
473
|
+
|
|
474
|
+
function generate() {
|
|
475
|
+
return _generate.apply(this, arguments);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return generate;
|
|
479
|
+
}();
|
|
480
|
+
|
|
481
|
+
_proto.write = /*#__PURE__*/function () {
|
|
482
|
+
var _write = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(outputFileList) {
|
|
483
|
+
var _this4 = this;
|
|
484
|
+
|
|
485
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
486
|
+
while (1) {
|
|
487
|
+
switch (_context12.prev = _context12.next) {
|
|
488
|
+
case 0:
|
|
489
|
+
return _context12.abrupt("return", Promise.all(Object.keys(outputFileList).map( /*#__PURE__*/function () {
|
|
490
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(outputFilePath) {
|
|
491
|
+
var _outputFileList$outpu, content, requestFunctionFilePath, requestHookMakerFilePath, syntheticalConfig, rawRequestFunctionFilePath, rawRequestHookMakerFilePath, rawOutputContent, prettier, prettyOutputContent, outputContent;
|
|
492
|
+
|
|
493
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
494
|
+
while (1) {
|
|
495
|
+
switch (_context11.prev = _context11.next) {
|
|
496
|
+
case 0:
|
|
497
|
+
_outputFileList$outpu = outputFileList[outputFilePath], content = _outputFileList$outpu.content, requestFunctionFilePath = _outputFileList$outpu.requestFunctionFilePath, requestHookMakerFilePath = _outputFileList$outpu.requestHookMakerFilePath, syntheticalConfig = _outputFileList$outpu.syntheticalConfig;
|
|
498
|
+
rawRequestFunctionFilePath = requestFunctionFilePath;
|
|
499
|
+
rawRequestHookMakerFilePath = requestHookMakerFilePath; // 支持 .jsx? 后缀
|
|
500
|
+
|
|
501
|
+
// 支持 .jsx? 后缀
|
|
502
|
+
outputFilePath = outputFilePath.replace(/\.js(x)?$/, '.ts$1');
|
|
503
|
+
requestFunctionFilePath = requestFunctionFilePath.replace(/\.js(x)?$/, '.ts$1');
|
|
504
|
+
requestHookMakerFilePath = requestHookMakerFilePath.replace(/\.js(x)?$/, '.ts$1');
|
|
505
|
+
|
|
506
|
+
if (syntheticalConfig.typesOnly) {
|
|
507
|
+
_context11.next = 20;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
_context11.next = 9;
|
|
512
|
+
return fs.pathExists(rawRequestFunctionFilePath);
|
|
513
|
+
|
|
514
|
+
case 9:
|
|
515
|
+
if (_context11.sent) {
|
|
516
|
+
_context11.next = 12;
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
_context11.next = 12;
|
|
521
|
+
return fs.outputFile(requestFunctionFilePath, dedent(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n import type { RequestFunctionParams } from 'yapi-to-typescript'\n\n export interface RequestOptions {\n /**\n * \u4F7F\u7528\u7684\u670D\u52A1\u5668\u3002\n *\n * - `prod`: \u751F\u4EA7\u670D\u52A1\u5668\n * - `dev`: \u6D4B\u8BD5\u670D\u52A1\u5668\n * - `mock`: \u6A21\u62DF\u670D\u52A1\u5668\n *\n * @default prod\n */\n server?: 'prod' | 'dev' | 'mock',\n }\n\n export default function request<TResponseData>(\n payload: RequestFunctionParams,\n options: RequestOptions = {\n server: 'prod',\n },\n ): Promise<TResponseData> {\n return new Promise<TResponseData>((resolve, reject) => {\n // \u57FA\u672C\u5730\u5740\n const baseUrl = options.server === 'mock'\n ? payload.mockUrl\n : options.server === 'dev'\n ? payload.devUrl\n : payload.prodUrl\n\n // \u8BF7\u6C42\u5730\u5740\n const url = `${baseUrl}${payload.path}`\n\n // \u5177\u4F53\u8BF7\u6C42\u903B\u8F91\n })\n }\n "], ["\n import type { RequestFunctionParams } from 'yapi-to-typescript'\n\n export interface RequestOptions {\n /**\n * \u4F7F\u7528\u7684\u670D\u52A1\u5668\u3002\n *\n * - \\`prod\\`: \u751F\u4EA7\u670D\u52A1\u5668\n * - \\`dev\\`: \u6D4B\u8BD5\u670D\u52A1\u5668\n * - \\`mock\\`: \u6A21\u62DF\u670D\u52A1\u5668\n *\n * @default prod\n */\n server?: 'prod' | 'dev' | 'mock',\n }\n\n export default function request<TResponseData>(\n payload: RequestFunctionParams,\n options: RequestOptions = {\n server: 'prod',\n },\n ): Promise<TResponseData> {\n return new Promise<TResponseData>((resolve, reject) => {\n // \u57FA\u672C\u5730\u5740\n const baseUrl = options.server === 'mock'\n ? payload.mockUrl\n : options.server === 'dev'\n ? payload.devUrl\n : payload.prodUrl\n\n // \u8BF7\u6C42\u5730\u5740\n const url = \\`\\${baseUrl}\\${payload.path}\\`\n\n // \u5177\u4F53\u8BF7\u6C42\u903B\u8F91\n })\n }\n "]))));
|
|
522
|
+
|
|
523
|
+
case 12:
|
|
524
|
+
_context11.t0 = syntheticalConfig.reactHooks && syntheticalConfig.reactHooks.enabled;
|
|
525
|
+
|
|
526
|
+
if (!_context11.t0) {
|
|
527
|
+
_context11.next = 17;
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
_context11.next = 16;
|
|
532
|
+
return fs.pathExists(rawRequestHookMakerFilePath);
|
|
533
|
+
|
|
534
|
+
case 16:
|
|
535
|
+
_context11.t0 = !_context11.sent;
|
|
536
|
+
|
|
537
|
+
case 17:
|
|
538
|
+
if (!_context11.t0) {
|
|
539
|
+
_context11.next = 20;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
_context11.next = 20;
|
|
544
|
+
return fs.outputFile(requestHookMakerFilePath, dedent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n import { useState, useEffect } from 'react'\n import type { RequestConfig } from 'yapi-to-typescript'\n import type { Request } from ", "\n import baseRequest from ", "\n\n export default function makeRequestHook<TRequestData, TRequestConfig extends RequestConfig, TRequestResult extends ReturnType<typeof baseRequest>>(request: Request<TRequestData, TRequestConfig, TRequestResult>) {\n type Data = TRequestResult extends Promise<infer R> ? R : TRequestResult\n return function useRequest(requestData: TRequestData) {\n // \u4E00\u4E2A\u7B80\u5355\u7684 Hook \u5B9E\u73B0\uFF0C\u5B9E\u9645\u9879\u76EE\u53EF\u7ED3\u5408\u5176\u4ED6\u5E93\u4F7F\u7528\uFF0C\u6BD4\u5982\uFF1A\n // @umijs/hooks \u7684 useRequest (https://github.com/umijs/hooks)\n // swr (https://github.com/zeit/swr)\n\n const [loading, setLoading] = useState(true)\n const [data, setData] = useState<Data>()\n\n useEffect(() => {\n request(requestData).then(data => {\n setLoading(false)\n setData(data as any)\n })\n }, [JSON.stringify(requestData)])\n\n return {\n loading,\n data,\n }\n }\n }\n "])), JSON.stringify(getNormalizedRelativePath(requestHookMakerFilePath, outputFilePath)), JSON.stringify(getNormalizedRelativePath(requestHookMakerFilePath, requestFunctionFilePath))));
|
|
545
|
+
|
|
546
|
+
case 20:
|
|
547
|
+
// 始终写入主文件
|
|
548
|
+
rawOutputContent = dedent(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n /* tslint:disable */\n /* eslint-disable */\n\n /* \u8BE5\u6587\u4EF6\u7531 yapi-to-typescript \u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u76F4\u63A5\u4FEE\u6539\uFF01\uFF01\uFF01 */\n\n ", "\n "])), syntheticalConfig.typesOnly ? dedent(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n type FileData = File\n\n ", "\n "])), content.join('\n\n').trim()) : dedent(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n // @ts-ignore\n // prettier-ignore\n import { QueryStringArrayFormat, Method, RequestBodyType, ResponseBodyType, FileData, prepare } from 'yapi-to-typescript'\n // @ts-ignore\n // prettier-ignore\n import type { RequestConfig, RequestFunctionRestArgs } from 'yapi-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 "])), JSON.stringify(getNormalizedRelativePath(outputFilePath, requestFunctionFilePath)), !syntheticalConfig.reactHooks || !syntheticalConfig.reactHooks.enabled ? '' : dedent(_templateObject7 || (_templateObject7 = _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
|
|
549
|
+
|
|
550
|
+
_context11.next = 23;
|
|
551
|
+
return getPrettier(_this4.options.cwd);
|
|
552
|
+
|
|
553
|
+
case 23:
|
|
554
|
+
prettier = _context11.sent;
|
|
555
|
+
_context11.t1 = prettier;
|
|
556
|
+
_context11.t2 = rawOutputContent;
|
|
557
|
+
_context11.t3 = _extends;
|
|
558
|
+
_context11.t4 = {};
|
|
559
|
+
_context11.next = 30;
|
|
560
|
+
return getCachedPrettierOptions();
|
|
561
|
+
|
|
562
|
+
case 30:
|
|
563
|
+
_context11.t5 = _context11.sent;
|
|
564
|
+
_context11.t6 = {
|
|
565
|
+
filepath: outputFilePath
|
|
566
|
+
};
|
|
567
|
+
_context11.t7 = (0, _context11.t3)(_context11.t4, _context11.t5, _context11.t6);
|
|
568
|
+
_context11.next = 35;
|
|
569
|
+
return _context11.t1.format.call(_context11.t1, _context11.t2, _context11.t7);
|
|
570
|
+
|
|
571
|
+
case 35:
|
|
572
|
+
prettyOutputContent = _context11.sent;
|
|
573
|
+
outputContent = dedent(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n /* prettier-ignore-start */\n ", "\n /* prettier-ignore-end */\n "])), prettyOutputContent) + "\n";
|
|
574
|
+
_context11.next = 39;
|
|
575
|
+
return fs.outputFile(outputFilePath, outputContent);
|
|
576
|
+
|
|
577
|
+
case 39:
|
|
578
|
+
if (!(syntheticalConfig.target === 'javascript')) {
|
|
579
|
+
_context11.next = 44;
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
_context11.next = 42;
|
|
584
|
+
return _this4.tsc(outputFilePath);
|
|
585
|
+
|
|
586
|
+
case 42:
|
|
587
|
+
_context11.next = 44;
|
|
588
|
+
return Promise.all([fs.remove(requestFunctionFilePath).catch(noop), fs.remove(requestHookMakerFilePath).catch(noop), fs.remove(outputFilePath).catch(noop)]);
|
|
589
|
+
|
|
590
|
+
case 44:
|
|
591
|
+
case "end":
|
|
592
|
+
return _context11.stop();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}, _callee11);
|
|
596
|
+
}));
|
|
597
|
+
|
|
598
|
+
return function (_x14) {
|
|
599
|
+
return _ref13.apply(this, arguments);
|
|
600
|
+
};
|
|
601
|
+
}())));
|
|
602
|
+
|
|
603
|
+
case 1:
|
|
604
|
+
case "end":
|
|
605
|
+
return _context12.stop();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}, _callee12);
|
|
609
|
+
}));
|
|
610
|
+
|
|
611
|
+
function write(_x13) {
|
|
612
|
+
return _write.apply(this, arguments);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return write;
|
|
616
|
+
}();
|
|
617
|
+
|
|
618
|
+
_proto.tsc = /*#__PURE__*/function () {
|
|
619
|
+
var _tsc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(file) {
|
|
620
|
+
var _this5 = this;
|
|
621
|
+
|
|
622
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
623
|
+
while (1) {
|
|
624
|
+
switch (_context13.prev = _context13.next) {
|
|
625
|
+
case 0:
|
|
626
|
+
return _context13.abrupt("return", new Promise(function (resolve) {
|
|
627
|
+
// add this to fix bug that not-generator-file-on-window
|
|
628
|
+
var command = "" + (require('os').platform() === 'win32' ? 'node ' : '') + JSON.stringify(require.resolve("typescript/bin/tsc"));
|
|
629
|
+
exec(command + " --target ES2019 --module ESNext --jsx preserve --declaration --esModuleInterop " + JSON.stringify(file), {
|
|
630
|
+
cwd: _this5.options.cwd,
|
|
631
|
+
env: process.env
|
|
632
|
+
}, function () {
|
|
633
|
+
return resolve();
|
|
634
|
+
});
|
|
635
|
+
}));
|
|
636
|
+
|
|
637
|
+
case 1:
|
|
638
|
+
case "end":
|
|
639
|
+
return _context13.stop();
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}, _callee13);
|
|
643
|
+
}));
|
|
644
|
+
|
|
645
|
+
function tsc(_x15) {
|
|
646
|
+
return _tsc.apply(this, arguments);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return tsc;
|
|
650
|
+
}();
|
|
651
|
+
|
|
652
|
+
_proto.fetchApi = /*#__PURE__*/function () {
|
|
653
|
+
var _fetchApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(url, query) {
|
|
654
|
+
var res;
|
|
655
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
656
|
+
while (1) {
|
|
657
|
+
switch (_context14.prev = _context14.next) {
|
|
658
|
+
case 0:
|
|
659
|
+
_context14.next = 2;
|
|
660
|
+
return httpGet(url, query);
|
|
661
|
+
|
|
662
|
+
case 2:
|
|
663
|
+
res = _context14.sent;
|
|
664
|
+
|
|
665
|
+
/* istanbul ignore next */
|
|
666
|
+
if (res && res.errcode) {
|
|
667
|
+
throwError(res.errmsg + " [\u8BF7\u6C42\u5730\u5740: " + url + "] [\u8BF7\u6C42\u53C2\u6570: " + new URLSearchParams(query).toString() + "]");
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
return _context14.abrupt("return", res.data || res);
|
|
671
|
+
|
|
672
|
+
case 5:
|
|
673
|
+
case "end":
|
|
674
|
+
return _context14.stop();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}, _callee14);
|
|
678
|
+
}));
|
|
679
|
+
|
|
680
|
+
function fetchApi(_x16, _x17) {
|
|
681
|
+
return _fetchApi.apply(this, arguments);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return fetchApi;
|
|
685
|
+
}();
|
|
686
|
+
|
|
687
|
+
/** 获取分类的接口列表 */
|
|
688
|
+
_proto.fetchInterfaceList =
|
|
689
|
+
/*#__PURE__*/
|
|
690
|
+
function () {
|
|
691
|
+
var _fetchInterfaceList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref14) {
|
|
692
|
+
var serverUrl, token, id, category;
|
|
693
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
694
|
+
while (1) {
|
|
695
|
+
switch (_context15.prev = _context15.next) {
|
|
696
|
+
case 0:
|
|
697
|
+
serverUrl = _ref14.serverUrl, token = _ref14.token, id = _ref14.id;
|
|
698
|
+
_context15.next = 3;
|
|
699
|
+
return this.fetchExport({
|
|
700
|
+
serverUrl: serverUrl,
|
|
701
|
+
token: token
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
case 3:
|
|
705
|
+
_context15.t0 = _context15.sent;
|
|
706
|
+
|
|
707
|
+
if (_context15.t0) {
|
|
708
|
+
_context15.next = 6;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
_context15.t0 = [];
|
|
713
|
+
|
|
714
|
+
case 6:
|
|
715
|
+
category = _context15.t0.find(function (cat) {
|
|
716
|
+
return !isEmpty(cat) && !isEmpty(cat.list) && cat.list[0].catid === id;
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
if (category) {
|
|
720
|
+
category.list.forEach(function (interfaceInfo) {
|
|
721
|
+
// 实现 _category 字段
|
|
722
|
+
interfaceInfo._category = omit(category, ['list']);
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return _context15.abrupt("return", category ? category.list : []);
|
|
727
|
+
|
|
728
|
+
case 9:
|
|
729
|
+
case "end":
|
|
730
|
+
return _context15.stop();
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}, _callee15, this);
|
|
734
|
+
}));
|
|
735
|
+
|
|
736
|
+
function fetchInterfaceList(_x18) {
|
|
737
|
+
return _fetchInterfaceList.apply(this, arguments);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
return fetchInterfaceList;
|
|
741
|
+
}()
|
|
742
|
+
/** 获取项目信息 */
|
|
743
|
+
;
|
|
744
|
+
|
|
745
|
+
_proto.fetchProjectInfo =
|
|
746
|
+
/*#__PURE__*/
|
|
747
|
+
function () {
|
|
748
|
+
var _fetchProjectInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(syntheticalConfig) {
|
|
749
|
+
var projectInfo, projectCats;
|
|
750
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
751
|
+
while (1) {
|
|
752
|
+
switch (_context16.prev = _context16.next) {
|
|
753
|
+
case 0:
|
|
754
|
+
_context16.next = 2;
|
|
755
|
+
return this.fetchProject(syntheticalConfig);
|
|
756
|
+
|
|
757
|
+
case 2:
|
|
758
|
+
projectInfo = _context16.sent;
|
|
759
|
+
_context16.next = 5;
|
|
760
|
+
return this.fetchApi(syntheticalConfig.serverUrl + "/api/interface/getCatMenu", {
|
|
761
|
+
token: syntheticalConfig.token,
|
|
762
|
+
project_id: projectInfo._id
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
case 5:
|
|
766
|
+
projectCats = _context16.sent;
|
|
767
|
+
return _context16.abrupt("return", _extends({}, projectInfo, {
|
|
768
|
+
cats: projectCats,
|
|
769
|
+
getMockUrl: function getMockUrl() {
|
|
770
|
+
return syntheticalConfig.serverUrl + "/mock/" + projectInfo._id;
|
|
771
|
+
},
|
|
772
|
+
getDevUrl: function getDevUrl(devEnvName) {
|
|
773
|
+
var env = projectInfo.env.find(function (e) {
|
|
774
|
+
return e.name === devEnvName;
|
|
775
|
+
});
|
|
776
|
+
return env && env.domain
|
|
777
|
+
/* istanbul ignore next */
|
|
778
|
+
|| '';
|
|
779
|
+
},
|
|
780
|
+
getProdUrl: function getProdUrl(prodEnvName) {
|
|
781
|
+
var env = projectInfo.env.find(function (e) {
|
|
782
|
+
return e.name === prodEnvName;
|
|
783
|
+
});
|
|
784
|
+
return env && env.domain
|
|
785
|
+
/* istanbul ignore next */
|
|
786
|
+
|| '';
|
|
787
|
+
}
|
|
788
|
+
}));
|
|
789
|
+
|
|
790
|
+
case 7:
|
|
791
|
+
case "end":
|
|
792
|
+
return _context16.stop();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}, _callee16, this);
|
|
796
|
+
}));
|
|
797
|
+
|
|
798
|
+
function fetchProjectInfo(_x19) {
|
|
799
|
+
return _fetchProjectInfo.apply(this, arguments);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return fetchProjectInfo;
|
|
803
|
+
}()
|
|
804
|
+
/** 生成接口代码 */
|
|
805
|
+
;
|
|
806
|
+
|
|
807
|
+
_proto.generateInterfaceCode =
|
|
808
|
+
/*#__PURE__*/
|
|
809
|
+
function () {
|
|
810
|
+
var _generateInterfaceCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(syntheticalConfig, interfaceInfo, categoryUID) {
|
|
811
|
+
var _syntheticalConfig$js, _syntheticalConfig$js2, _syntheticalConfig$js3, _syntheticalConfig$js4;
|
|
812
|
+
|
|
813
|
+
var extendedInterfaceInfo, requestFunctionName, requestConfigName, requestConfigTypeName, requestDataTypeName, responseDataTypeName, requestDataJsonSchema, requestDataType, responseDataJsonSchema, responseDataType, isRequestDataOptional, requestHookName, paramNames, paramNamesLiteral, paramNameType, queryNames, queryNamesLiteral, queryNameType, genComment, requestFunctionExtraInfo;
|
|
814
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
815
|
+
while (1) {
|
|
816
|
+
switch (_context17.prev = _context17.next) {
|
|
817
|
+
case 0:
|
|
818
|
+
extendedInterfaceInfo = _extends({}, interfaceInfo, {
|
|
819
|
+
parsedPath: path.parse(interfaceInfo.path)
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
if (!isFunction(syntheticalConfig.getRequestFunctionName)) {
|
|
823
|
+
_context17.next = 7;
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
_context17.next = 4;
|
|
828
|
+
return syntheticalConfig.getRequestFunctionName(extendedInterfaceInfo, changeCase);
|
|
829
|
+
|
|
830
|
+
case 4:
|
|
831
|
+
_context17.t0 = _context17.sent;
|
|
832
|
+
_context17.next = 8;
|
|
833
|
+
break;
|
|
834
|
+
|
|
835
|
+
case 7:
|
|
836
|
+
_context17.t0 = changeCase.camelCase(extendedInterfaceInfo.parsedPath.name);
|
|
837
|
+
|
|
838
|
+
case 8:
|
|
839
|
+
requestFunctionName = _context17.t0;
|
|
840
|
+
requestConfigName = changeCase.camelCase(requestFunctionName + "RequestConfig");
|
|
841
|
+
requestConfigTypeName = changeCase.pascalCase(requestConfigName);
|
|
842
|
+
|
|
843
|
+
if (!isFunction(syntheticalConfig.getRequestDataTypeName)) {
|
|
844
|
+
_context17.next = 17;
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
_context17.next = 14;
|
|
849
|
+
return syntheticalConfig.getRequestDataTypeName(extendedInterfaceInfo, changeCase);
|
|
850
|
+
|
|
851
|
+
case 14:
|
|
852
|
+
_context17.t1 = _context17.sent;
|
|
853
|
+
_context17.next = 18;
|
|
854
|
+
break;
|
|
855
|
+
|
|
856
|
+
case 17:
|
|
857
|
+
_context17.t1 = changeCase.pascalCase(requestFunctionName + "Request");
|
|
858
|
+
|
|
859
|
+
case 18:
|
|
860
|
+
requestDataTypeName = _context17.t1;
|
|
861
|
+
|
|
862
|
+
if (!isFunction(syntheticalConfig.getResponseDataTypeName)) {
|
|
863
|
+
_context17.next = 25;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
_context17.next = 22;
|
|
868
|
+
return syntheticalConfig.getResponseDataTypeName(extendedInterfaceInfo, changeCase);
|
|
869
|
+
|
|
870
|
+
case 22:
|
|
871
|
+
_context17.t2 = _context17.sent;
|
|
872
|
+
_context17.next = 26;
|
|
873
|
+
break;
|
|
874
|
+
|
|
875
|
+
case 25:
|
|
876
|
+
_context17.t2 = changeCase.pascalCase(requestFunctionName + "Response");
|
|
877
|
+
|
|
878
|
+
case 26:
|
|
879
|
+
responseDataTypeName = _context17.t2;
|
|
880
|
+
requestDataJsonSchema = getRequestDataJsonSchema(extendedInterfaceInfo, syntheticalConfig.customTypeMapping || {});
|
|
881
|
+
_context17.next = 30;
|
|
882
|
+
return jsonSchemaToType(requestDataJsonSchema, requestDataTypeName);
|
|
883
|
+
|
|
884
|
+
case 30:
|
|
885
|
+
requestDataType = _context17.sent;
|
|
886
|
+
responseDataJsonSchema = getResponseDataJsonSchema(extendedInterfaceInfo, syntheticalConfig.customTypeMapping || {}, syntheticalConfig.dataKey);
|
|
887
|
+
_context17.next = 34;
|
|
888
|
+
return jsonSchemaToType(responseDataJsonSchema, responseDataTypeName);
|
|
889
|
+
|
|
890
|
+
case 34:
|
|
891
|
+
responseDataType = _context17.sent;
|
|
892
|
+
isRequestDataOptional = /(\{\}|any)$/.test(requestDataType);
|
|
893
|
+
|
|
894
|
+
if (!(syntheticalConfig.reactHooks && syntheticalConfig.reactHooks.enabled)) {
|
|
895
|
+
_context17.next = 47;
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
if (!isFunction(syntheticalConfig.reactHooks.getRequestHookName)) {
|
|
900
|
+
_context17.next = 43;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
_context17.next = 40;
|
|
905
|
+
return syntheticalConfig.reactHooks.getRequestHookName(extendedInterfaceInfo, changeCase);
|
|
906
|
+
|
|
907
|
+
case 40:
|
|
908
|
+
_context17.t4 = _context17.sent;
|
|
909
|
+
_context17.next = 44;
|
|
910
|
+
break;
|
|
911
|
+
|
|
912
|
+
case 43:
|
|
913
|
+
_context17.t4 = "use" + changeCase.pascalCase(requestFunctionName);
|
|
914
|
+
|
|
915
|
+
case 44:
|
|
916
|
+
_context17.t3 = _context17.t4;
|
|
917
|
+
_context17.next = 48;
|
|
918
|
+
break;
|
|
919
|
+
|
|
920
|
+
case 47:
|
|
921
|
+
_context17.t3 = '';
|
|
922
|
+
|
|
923
|
+
case 48:
|
|
924
|
+
requestHookName = _context17.t3;
|
|
925
|
+
// 支持路径参数
|
|
926
|
+
paramNames = (extendedInterfaceInfo.req_params
|
|
927
|
+
/* istanbul ignore next */
|
|
928
|
+
|| []).map(function (item) {
|
|
929
|
+
return item.name;
|
|
930
|
+
});
|
|
931
|
+
paramNamesLiteral = JSON.stringify(paramNames);
|
|
932
|
+
paramNameType = paramNames.length === 0 ? 'string' : "'" + paramNames.join("' | '") + "'"; // 支持查询参数
|
|
933
|
+
|
|
934
|
+
queryNames = (extendedInterfaceInfo.req_query
|
|
935
|
+
/* istanbul ignore next */
|
|
936
|
+
|| []).map(function (item) {
|
|
937
|
+
return item.name;
|
|
938
|
+
});
|
|
939
|
+
queryNamesLiteral = JSON.stringify(queryNames);
|
|
940
|
+
queryNameType = queryNames.length === 0 ? 'string' : "'" + queryNames.join("' | '") + "'"; // 接口注释
|
|
941
|
+
|
|
942
|
+
genComment = function genComment(genTitle) {
|
|
943
|
+
var _ref15 = _extends({}, syntheticalConfig.comment, syntheticalConfig.serverType === 'swagger' ? {
|
|
944
|
+
tag: false,
|
|
945
|
+
updateTime: false,
|
|
946
|
+
link: false
|
|
947
|
+
} : {}),
|
|
948
|
+
_ref15$enabled = _ref15.enabled,
|
|
949
|
+
isEnabled = _ref15$enabled === void 0 ? true : _ref15$enabled,
|
|
950
|
+
_ref15$title = _ref15.title,
|
|
951
|
+
hasTitle = _ref15$title === void 0 ? true : _ref15$title,
|
|
952
|
+
_ref15$category = _ref15.category,
|
|
953
|
+
hasCategory = _ref15$category === void 0 ? true : _ref15$category,
|
|
954
|
+
_ref15$tag = _ref15.tag,
|
|
955
|
+
hasTag = _ref15$tag === void 0 ? true : _ref15$tag,
|
|
956
|
+
_ref15$requestHeader = _ref15.requestHeader,
|
|
957
|
+
hasRequestHeader = _ref15$requestHeader === void 0 ? true : _ref15$requestHeader,
|
|
958
|
+
_ref15$updateTime = _ref15.updateTime,
|
|
959
|
+
hasUpdateTime = _ref15$updateTime === void 0 ? true : _ref15$updateTime,
|
|
960
|
+
_ref15$link = _ref15.link,
|
|
961
|
+
hasLink = _ref15$link === void 0 ? true : _ref15$link,
|
|
962
|
+
extraTags = _ref15.extraTags;
|
|
963
|
+
|
|
964
|
+
if (!isEnabled) {
|
|
965
|
+
return '';
|
|
966
|
+
} // 转义标题中的 /
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
var escapedTitle = String(extendedInterfaceInfo.title).replace(/\//g, '\\/');
|
|
970
|
+
var description = hasLink ? "[" + escapedTitle + "\u2197](" + extendedInterfaceInfo._url + ")" : escapedTitle;
|
|
971
|
+
var summary = [hasCategory && {
|
|
972
|
+
label: '分类',
|
|
973
|
+
value: hasLink ? "[" + extendedInterfaceInfo._category.name + "\u2197](" + extendedInterfaceInfo._category._url + ")" : extendedInterfaceInfo._category.name
|
|
974
|
+
}, hasTag && {
|
|
975
|
+
label: '标签',
|
|
976
|
+
value: extendedInterfaceInfo.tag.map(function (tag) {
|
|
977
|
+
return "`" + tag + "`";
|
|
978
|
+
})
|
|
979
|
+
}, hasRequestHeader && {
|
|
980
|
+
label: '请求头',
|
|
981
|
+
value: "`" + extendedInterfaceInfo.method.toUpperCase() + " " + extendedInterfaceInfo.path + "`"
|
|
982
|
+
}, hasUpdateTime && {
|
|
983
|
+
label: '更新时间',
|
|
984
|
+
value: process.env.JEST_WORKER_ID // 测试时使用 unix 时间戳
|
|
985
|
+
? String(extendedInterfaceInfo.up_time) :
|
|
986
|
+
/* istanbul ignore next */
|
|
987
|
+
"`" + dayjs(extendedInterfaceInfo.up_time * 1000).format('YYYY-MM-DD HH:mm:ss') + "`"
|
|
988
|
+
}];
|
|
989
|
+
|
|
990
|
+
if (typeof extraTags === 'function') {
|
|
991
|
+
var tags = extraTags(extendedInterfaceInfo);
|
|
992
|
+
|
|
993
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(tags), _step2; !(_step2 = _iterator2()).done;) {
|
|
994
|
+
var tag = _step2.value;
|
|
995
|
+
;
|
|
996
|
+
(tag.position === 'start' ? summary.unshift : summary.push).call(summary, {
|
|
997
|
+
label: tag.name,
|
|
998
|
+
value: tag.value
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
var titleComment = hasTitle ? dedent(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n * ", "\n *\n "])), genTitle(description)) : '';
|
|
1004
|
+
var extraComment = summary.filter(function (item) {
|
|
1005
|
+
return typeof item !== 'boolean' && !isEmpty(item.value);
|
|
1006
|
+
}).map(function (item) {
|
|
1007
|
+
var _item = item;
|
|
1008
|
+
return "* @" + _item.label + " " + castArray(_item.value).join(', ');
|
|
1009
|
+
}).join('\n');
|
|
1010
|
+
return dedent(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n /**\n ", "\n */\n "])), [titleComment, extraComment].filter(Boolean).join('\n'));
|
|
1011
|
+
}; // 请求参数额外信息
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
if (!(typeof syntheticalConfig.setRequestFunctionExtraInfo === 'function')) {
|
|
1015
|
+
_context17.next = 62;
|
|
1016
|
+
break;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
_context17.next = 59;
|
|
1020
|
+
return syntheticalConfig.setRequestFunctionExtraInfo(extendedInterfaceInfo, changeCase);
|
|
1021
|
+
|
|
1022
|
+
case 59:
|
|
1023
|
+
_context17.t5 = _context17.sent;
|
|
1024
|
+
_context17.next = 63;
|
|
1025
|
+
break;
|
|
1026
|
+
|
|
1027
|
+
case 62:
|
|
1028
|
+
_context17.t5 = {};
|
|
1029
|
+
|
|
1030
|
+
case 63:
|
|
1031
|
+
requestFunctionExtraInfo = _context17.t5;
|
|
1032
|
+
return _context17.abrupt("return", dedent(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n "])), genComment(function (title) {
|
|
1033
|
+
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u7C7B\u578B**";
|
|
1034
|
+
}), requestDataType.trim(), genComment(function (title) {
|
|
1035
|
+
return "\u63A5\u53E3 " + title + " \u7684 **\u8FD4\u56DE\u7C7B\u578B**";
|
|
1036
|
+
}), responseDataType.trim(), syntheticalConfig.typesOnly ? '' : dedent(_templateObject12 || (_templateObject12 = _taggedTemplateLiteralLoose(["\n ", "\n type ", " = Readonly<RequestConfig<\n ", ",\n ", ",\n ", ",\n ", ",\n ", ",\n ", ",\n ", ",\n ", "\n >>\n\n ", "\n const ", ": ", " = ", " {\n mockUrl: mockUrl", ",\n devUrl: devUrl", ",\n prodUrl: prodUrl", ",\n path: ", ",\n method: Method.", ",\n requestHeaders: ", ",\n requestBodyType: RequestBodyType.", ",\n responseBodyType: ResponseBodyType.", ",\n dataKey: dataKey", ",\n paramNames: ", ",\n queryNames: ", ",\n requestDataOptional: ", ",\n requestDataJsonSchema: ", ",\n responseDataJsonSchema: ", ",\n requestFunctionName: ", ",\n queryStringArrayFormat: QueryStringArrayFormat.", ",\n extraInfo: ", ",\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) {
|
|
1037
|
+
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u914D\u7F6E\u7684\u7C7B\u578B**";
|
|
1038
|
+
}), requestConfigTypeName, JSON.stringify(syntheticalConfig.mockUrl), JSON.stringify(syntheticalConfig.devUrl), JSON.stringify(syntheticalConfig.prodUrl), JSON.stringify(extendedInterfaceInfo.path), JSON.stringify(syntheticalConfig.dataKey) || 'undefined', paramNameType, queryNameType, JSON.stringify(isRequestDataOptional), genComment(function (title) {
|
|
1039
|
+
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u914D\u7F6E**";
|
|
1040
|
+
}), requestConfigName, requestConfigTypeName, COMPRESSOR_TREE_SHAKING_ANNOTATION, categoryUID, categoryUID, categoryUID, JSON.stringify(extendedInterfaceInfo.path), extendedInterfaceInfo.method, JSON.stringify((extendedInterfaceInfo.req_headers || []).filter(function (item) {
|
|
1041
|
+
return item.name.toLowerCase() !== 'content-type';
|
|
1042
|
+
}).reduce(function (res, item) {
|
|
1043
|
+
res[item.name] = item.value;
|
|
1044
|
+
return res;
|
|
1045
|
+
}, {})), extendedInterfaceInfo.method === Method.GET ? RequestBodyType.query : extendedInterfaceInfo.req_body_type
|
|
1046
|
+
/* istanbul ignore next */
|
|
1047
|
+
|| RequestBodyType.none, extendedInterfaceInfo.res_body_type, categoryUID, paramNamesLiteral, queryNamesLiteral, JSON.stringify(isRequestDataOptional), JSON.stringify((_syntheticalConfig$js = syntheticalConfig.jsonSchema) != null && _syntheticalConfig$js.enabled && ((_syntheticalConfig$js2 = syntheticalConfig.jsonSchema) == null ? void 0 : _syntheticalConfig$js2.requestData) !== false ? requestDataJsonSchema : {}), JSON.stringify((_syntheticalConfig$js3 = syntheticalConfig.jsonSchema) != null && _syntheticalConfig$js3.enabled && ((_syntheticalConfig$js4 = syntheticalConfig.jsonSchema) == null ? void 0 : _syntheticalConfig$js4.responseData) !== false ? responseDataJsonSchema : {}), JSON.stringify(requestFunctionName), syntheticalConfig.queryStringArrayFormat || QueryStringArrayFormat.brackets, JSON.stringify(requestFunctionExtraInfo), genComment(function (title) {
|
|
1048
|
+
return "\u63A5\u53E3 " + title + " \u7684 **\u8BF7\u6C42\u51FD\u6570**";
|
|
1049
|
+
}), requestFunctionName, COMPRESSOR_TREE_SHAKING_ANNOTATION, isRequestDataOptional ? '?' : '', requestDataTypeName, responseDataTypeName, requestConfigName, requestFunctionName, requestConfigName, !syntheticalConfig.reactHooks || !syntheticalConfig.reactHooks.enabled ? '' : dedent(_templateObject13 || (_templateObject13 = _taggedTemplateLiteralLoose(["\n ", "\n export const ", " = ", " makeRequestHook<", ", ", ", ReturnType<typeof ", ">>(", ")\n "])), genComment(function (title) {
|
|
1050
|
+
return "\u63A5\u53E3 " + title + " \u7684 **React Hook**";
|
|
1051
|
+
}), requestHookName, COMPRESSOR_TREE_SHAKING_ANNOTATION, requestDataTypeName, requestConfigTypeName, requestFunctionName, requestFunctionName))));
|
|
1052
|
+
|
|
1053
|
+
case 65:
|
|
1054
|
+
case "end":
|
|
1055
|
+
return _context17.stop();
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}, _callee17);
|
|
1059
|
+
}));
|
|
1060
|
+
|
|
1061
|
+
function generateInterfaceCode(_x20, _x21, _x22) {
|
|
1062
|
+
return _generateInterfaceCode.apply(this, arguments);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
return generateInterfaceCode;
|
|
1066
|
+
}();
|
|
1067
|
+
|
|
1068
|
+
_proto.destroy = /*#__PURE__*/function () {
|
|
1069
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
1070
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1071
|
+
while (1) {
|
|
1072
|
+
switch (_context19.prev = _context19.next) {
|
|
1073
|
+
case 0:
|
|
1074
|
+
return _context19.abrupt("return", Promise.all(this.disposes.map( /*#__PURE__*/function () {
|
|
1075
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(dispose) {
|
|
1076
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1077
|
+
while (1) {
|
|
1078
|
+
switch (_context18.prev = _context18.next) {
|
|
1079
|
+
case 0:
|
|
1080
|
+
return _context18.abrupt("return", dispose());
|
|
1081
|
+
|
|
1082
|
+
case 1:
|
|
1083
|
+
case "end":
|
|
1084
|
+
return _context18.stop();
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}, _callee18);
|
|
1088
|
+
}));
|
|
1089
|
+
|
|
1090
|
+
return function (_x23) {
|
|
1091
|
+
return _ref16.apply(this, arguments);
|
|
1092
|
+
};
|
|
1093
|
+
}())));
|
|
1094
|
+
|
|
1095
|
+
case 1:
|
|
1096
|
+
case "end":
|
|
1097
|
+
return _context19.stop();
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}, _callee19, this);
|
|
1101
|
+
}));
|
|
1102
|
+
|
|
1103
|
+
function destroy() {
|
|
1104
|
+
return _destroy.apply(this, arguments);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
return destroy;
|
|
1108
|
+
}();
|
|
1109
|
+
|
|
1110
|
+
return Generator;
|
|
1111
|
+
}();
|