@modern-js/bff-core 1.22.2-beta.0 → 1.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +26 -130
  2. package/dist/js/modern/api.js +34 -49
  3. package/dist/js/modern/client/generate-client.js +34 -52
  4. package/dist/js/modern/client/index.js +1 -1
  5. package/dist/js/modern/client/result.js +8 -10
  6. package/dist/js/modern/errors/http.js +14 -8
  7. package/dist/js/modern/index.js +3 -19
  8. package/dist/js/modern/operators/http.js +116 -139
  9. package/dist/js/modern/router/constants.js +13 -31
  10. package/dist/js/modern/router/index.js +131 -68
  11. package/dist/js/modern/router/types.js +1 -0
  12. package/dist/js/modern/router/utils.js +54 -36
  13. package/dist/js/modern/types.js +47 -45
  14. package/dist/js/modern/utils/alias.js +50 -35
  15. package/dist/js/modern/utils/debug.js +2 -5
  16. package/dist/js/modern/utils/index.js +2 -5
  17. package/dist/js/modern/utils/meta.js +4 -8
  18. package/dist/js/modern/utils/storage.js +14 -8
  19. package/dist/js/modern/utils/validate.js +29 -23
  20. package/dist/js/node/api.js +46 -78
  21. package/dist/js/node/client/generate-client.js +55 -85
  22. package/dist/js/node/client/index.js +18 -17
  23. package/dist/js/node/client/result.js +18 -32
  24. package/dist/js/node/errors/http.js +22 -28
  25. package/dist/js/node/index.js +122 -45
  26. package/dist/js/node/operators/http.js +169 -184
  27. package/dist/js/node/router/constants.js +28 -60
  28. package/dist/js/node/router/index.js +201 -112
  29. package/dist/js/node/router/types.js +5 -15
  30. package/dist/js/node/router/utils.js +78 -71
  31. package/dist/js/node/types.js +57 -71
  32. package/dist/js/node/utils/alias.js +73 -65
  33. package/dist/js/node/utils/debug.js +10 -27
  34. package/dist/js/node/utils/index.js +68 -28
  35. package/dist/js/node/utils/meta.js +12 -30
  36. package/dist/js/node/utils/storage.js +24 -36
  37. package/dist/js/node/utils/validate.js +44 -50
  38. package/package.json +40 -12
@@ -1,83 +1,104 @@
1
- import path from "path";
2
- import { fs, logger } from "@modern-js/utils";
3
- import "reflect-metadata";
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import path from 'path';
4
+ import { fs, logger } from '@modern-js/utils';
5
+ import 'reflect-metadata';
4
6
  import { HttpMethod, httpMethods, OperatorType, TriggerType } from "../types";
5
7
  import { debug } from "../utils";
6
- import {
7
- APIMode,
8
- FRAMEWORK_MODE_LAMBDA_DIR,
9
- API_FILE_RULES,
10
- FRAMEWORK_MODE_APP_DIR
11
- } from "./constants";
12
- import {
13
- getFiles,
14
- getPathFromFilename,
15
- requireHandlerModule,
16
- sortRoutes
17
- } from "./utils";
8
+ import { APIMode, FRAMEWORK_MODE_LAMBDA_DIR, API_FILE_RULES, FRAMEWORK_MODE_APP_DIR } from "./constants";
9
+ import { getFiles, getPathFromFilename, requireHandlerModule, sortRoutes } from "./utils";
18
10
  export * from "./types";
19
11
  export * from "./constants";
20
- class ApiRouter {
12
+ export class ApiRouter {
13
+ // lambdaDir is the dir which equal to the apiDir in function mode, and equal to the api/lambda dir in framework mode
21
14
  constructor({
22
- apiDir,
23
- lambdaDir,
15
+ apiDir: _apiDir,
16
+ lambdaDir: _lambdaDir,
24
17
  prefix
25
18
  }) {
26
- this.apiFiles = [];
27
- this.getExactApiMode = (apiDir) => {
19
+ _defineProperty(this, "apiMode", void 0);
20
+
21
+ _defineProperty(this, "apiDir", void 0);
22
+
23
+ _defineProperty(this, "existLambdaDir", void 0);
24
+
25
+ _defineProperty(this, "lambdaDir", void 0);
26
+
27
+ _defineProperty(this, "prefix", void 0);
28
+
29
+ _defineProperty(this, "apiFiles", []);
30
+
31
+ _defineProperty(this, "getExactApiMode", apiDir => {
28
32
  const exist = this.createExistChecker(apiDir);
29
33
  const existLambdaDir = exist(FRAMEWORK_MODE_LAMBDA_DIR);
30
34
  const existAppDir = exist(FRAMEWORK_MODE_APP_DIR);
31
- const existAppFile = exist("app.ts") || exist("app.js");
35
+ const existAppFile = exist('app.ts') || exist('app.js');
36
+
32
37
  if (existLambdaDir || existAppDir || existAppFile) {
33
38
  return APIMode.FARMEWORK;
34
39
  }
40
+
35
41
  return APIMode.FUNCTION;
36
- };
37
- this.createExistChecker = (base) => (target) => fs.pathExistsSync(path.resolve(base, target));
38
- this.getExactLambdaDir = (apiDir) => {
42
+ });
43
+
44
+ _defineProperty(this, "createExistChecker", base => target => fs.pathExistsSync(path.resolve(base, target)));
45
+
46
+ _defineProperty(this, "getExactLambdaDir", apiDir => {
39
47
  if (this.lambdaDir) {
40
48
  return this.lambdaDir;
41
49
  }
50
+
42
51
  const lambdaDir = this.apiMode === APIMode.FARMEWORK ? path.join(apiDir, FRAMEWORK_MODE_LAMBDA_DIR) : apiDir;
43
52
  return lambdaDir;
44
- };
45
- this.validateAbsolute(apiDir, "apiDir");
46
- this.validateAbsolute(lambdaDir, "lambdaDir");
53
+ });
54
+
55
+ this.validateAbsolute(_apiDir, 'apiDir');
56
+ this.validateAbsolute(_lambdaDir, 'lambdaDir');
47
57
  this.prefix = this.initPrefix(prefix);
48
- this.apiDir = apiDir;
49
- this.apiMode = this.getExactApiMode(apiDir);
50
- this.lambdaDir = lambdaDir || this.getExactLambdaDir(this.apiDir);
58
+ this.apiDir = _apiDir;
59
+ this.apiMode = this.getExactApiMode(_apiDir);
60
+ this.lambdaDir = _lambdaDir || this.getExactLambdaDir(this.apiDir);
51
61
  this.existLambdaDir = fs.existsSync(this.lambdaDir);
52
62
  }
63
+
53
64
  isExistLambda() {
54
65
  return this.existLambdaDir;
55
66
  }
67
+
56
68
  getApiMode() {
57
69
  return this.apiMode;
58
70
  }
71
+
59
72
  getLambdaDir() {
60
73
  return this.lambdaDir;
61
74
  }
75
+
62
76
  isApiFile(filename) {
63
77
  if (this.existLambdaDir) {
64
78
  return false;
65
79
  }
80
+
66
81
  if (!this.apiFiles.includes(filename)) {
67
82
  return false;
68
83
  }
84
+
69
85
  return true;
70
86
  }
87
+
71
88
  getSingleModuleHandlers(filename) {
72
89
  const moduleInfo = this.getModuleInfo(filename);
90
+
73
91
  if (moduleInfo) {
74
92
  return this.getModuleHandlerInfos(moduleInfo);
75
93
  }
94
+
76
95
  return null;
77
96
  }
97
+
78
98
  getHandlerInfo(filename, originFuncName, handler) {
79
99
  const httpMethod = this.getHttpMethod(originFuncName, handler);
80
100
  const routeName = this.getRouteName(filename, handler);
101
+
81
102
  if (httpMethod && routeName) {
82
103
  return {
83
104
  handler,
@@ -88,101 +109,135 @@ class ApiRouter {
88
109
  routePath: this.getRoutePath(this.prefix, routeName)
89
110
  };
90
111
  }
112
+
91
113
  return null;
92
- }
114
+ } // TODO: 性能提升,开发环境,判断下 lambda 目录修改时间
115
+
116
+
93
117
  getSafeRoutePath(filename, handler) {
94
118
  this.loadApiFiles();
95
119
  this.validateValidApifile(filename);
96
120
  return this.getRouteName(filename, handler);
97
121
  }
122
+
98
123
  getRouteName(filename, handler) {
99
124
  if (handler) {
100
125
  const trigger = Reflect.getMetadata(OperatorType.Trigger, handler);
126
+
101
127
  if (trigger && trigger.type === TriggerType.Http) {
102
128
  if (!trigger.path) {
103
- throw new Error(
104
- `The http trigger ${trigger.name} needs to specify a path`
105
- );
129
+ throw new Error(`The http trigger ${trigger.name} needs to specify a path`);
106
130
  }
131
+
107
132
  return trigger.path;
108
133
  }
109
134
  }
135
+
110
136
  const routePath = getPathFromFilename(this.lambdaDir, filename);
111
137
  return routePath;
112
138
  }
139
+
113
140
  getHttpMethod(originHandlerName, handler) {
114
141
  if (handler) {
115
142
  const trigger = Reflect.getMetadata(OperatorType.Trigger, handler);
143
+
116
144
  if (trigger && httpMethods.includes(trigger.method)) {
117
145
  return trigger.method;
118
146
  }
119
147
  }
148
+
120
149
  const upperName = originHandlerName.toUpperCase();
150
+
121
151
  switch (upperName) {
122
- case "GET":
152
+ case 'GET':
123
153
  return HttpMethod.Get;
124
- case "POST":
154
+
155
+ case 'POST':
125
156
  return HttpMethod.Post;
126
- case "PUT":
157
+
158
+ case 'PUT':
127
159
  return HttpMethod.Put;
128
- case "DELETE":
129
- case "DEL":
160
+
161
+ case 'DELETE':
162
+ case 'DEL':
130
163
  return HttpMethod.Delete;
131
- case "CONNECT":
164
+
165
+ case 'CONNECT':
132
166
  return HttpMethod.Connect;
133
- case "TRACE":
167
+
168
+ case 'TRACE':
134
169
  return HttpMethod.Trace;
135
- case "PATCH":
170
+
171
+ case 'PATCH':
136
172
  return HttpMethod.Patch;
137
- case "OPTION":
173
+
174
+ case 'OPTION':
138
175
  return HttpMethod.Option;
139
- case "DEFAULT": {
140
- return HttpMethod.Get;
141
- }
176
+
177
+ case 'DEFAULT':
178
+ {
179
+ return HttpMethod.Get;
180
+ }
181
+
142
182
  default:
143
- logger.warn(
144
- `Only api handlers are allowd to be exported, please remove the function ${originHandlerName} from exports`
145
- );
183
+ logger.warn(`Only api handlers are allowd to be exported, please remove the function ${originHandlerName} from exports`);
146
184
  return null;
147
185
  }
148
186
  }
187
+
149
188
  loadApiFiles() {
150
189
  if (!this.existLambdaDir) {
151
190
  return [];
152
- }
191
+ } // eslint-disable-next-line no-multi-assign
192
+
193
+
153
194
  const apiFiles = this.apiFiles = getFiles(this.lambdaDir, API_FILE_RULES);
154
195
  return apiFiles;
155
196
  }
197
+
156
198
  getApiFiles() {
157
199
  if (!this.existLambdaDir) {
158
200
  return [];
159
201
  }
202
+
160
203
  if (this.apiFiles.length > 0) {
161
204
  return this.apiFiles;
162
205
  }
206
+
163
207
  return this.loadApiFiles();
164
208
  }
209
+
165
210
  getApiHandlers() {
166
211
  const filenames = this.getApiFiles();
167
212
  const moduleInfos = this.getModuleInfos(filenames);
168
213
  const apiHandlers = this.getHandlerInfos(moduleInfos);
169
- debug("apiHandlers", apiHandlers.length, apiHandlers);
214
+ debug('apiHandlers', apiHandlers.length, apiHandlers);
170
215
  return apiHandlers;
171
216
  }
217
+ /**
218
+ * 如果用户未传入或传入空串,默认为 /api
219
+ * 如果传入 /,则 prefix 为 /
220
+ */
221
+
222
+
172
223
  initPrefix(prefix) {
173
- if (prefix === "/") {
174
- return "";
224
+ if (prefix === '/') {
225
+ return '';
175
226
  }
176
- return prefix || "/api";
227
+
228
+ return prefix || '/api';
177
229
  }
230
+
178
231
  validateAbsolute(filename, paramsName) {
179
- if (typeof filename === "string" && !path.isAbsolute(filename)) {
232
+ if (typeof filename === 'string' && !path.isAbsolute(filename)) {
180
233
  throw new Error(`The ${paramsName} ${filename} is not a abolute path`);
181
234
  }
182
235
  }
236
+
183
237
  getModuleInfos(filenames) {
184
- return filenames.map((filename) => this.getModuleInfo(filename)).filter((moduleInfo) => Boolean(moduleInfo));
238
+ return filenames.map(filename => this.getModuleInfo(filename)).filter(moduleInfo => Boolean(moduleInfo));
185
239
  }
240
+
186
241
  getModuleInfo(filename) {
187
242
  try {
188
243
  const module = requireHandlerModule(filename);
@@ -191,7 +246,7 @@ class ApiRouter {
191
246
  module
192
247
  };
193
248
  } catch (err) {
194
- if (process.env.NODE_ENV === "production") {
249
+ if (process.env.NODE_ENV === 'production') {
195
250
  throw err;
196
251
  } else {
197
252
  console.error(err);
@@ -199,10 +254,12 @@ class ApiRouter {
199
254
  }
200
255
  }
201
256
  }
257
+
202
258
  getHandlerInfos(moduleInfos) {
203
259
  let apiHandlers = [];
204
- moduleInfos.forEach((moduleInfo) => {
260
+ moduleInfos.forEach(moduleInfo => {
205
261
  const handlerInfos = this.getModuleHandlerInfos(moduleInfo);
262
+
206
263
  if (handlerInfos) {
207
264
  apiHandlers = apiHandlers.concat(handlerInfos);
208
265
  }
@@ -210,27 +267,33 @@ class ApiRouter {
210
267
  const sortedHandlers = sortRoutes(apiHandlers);
211
268
  return sortedHandlers;
212
269
  }
270
+
213
271
  getModuleHandlerInfos(moduleInfo) {
214
- const { module, filename } = moduleInfo;
215
- return Object.entries(module).filter(([, handler]) => typeof handler === "function").map(([key]) => {
272
+ const {
273
+ module,
274
+ filename
275
+ } = moduleInfo;
276
+ return Object.entries(module).filter(([, handler]) => typeof handler === 'function').map(([key]) => {
216
277
  const handler = module[key];
217
278
  const handlerInfo = this.getHandlerInfo(filename, key, handler);
218
279
  return handlerInfo;
219
- }).filter((handlerInfo) => Boolean(handlerInfo));
280
+ }).filter(handlerInfo => Boolean(handlerInfo));
220
281
  }
282
+
221
283
  validateValidApifile(filename) {
222
284
  if (!this.apiFiles.includes(filename)) {
223
285
  throw new Error(`The ${filename} is not a valid api file.`);
224
286
  }
225
287
  }
288
+
226
289
  getRoutePath(prefix, routeName) {
227
- const finalRouteName = routeName === "/" ? "" : routeName;
228
- if (prefix === "" && finalRouteName === "") {
229
- return "/";
290
+ const finalRouteName = routeName === '/' ? '' : routeName;
291
+
292
+ if (prefix === '' && finalRouteName === '') {
293
+ return '/';
230
294
  }
295
+
231
296
  return `${prefix}${finalRouteName}`;
232
297
  }
233
- }
234
- export {
235
- ApiRouter
236
- };
298
+
299
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,83 +1,101 @@
1
- import path from "path";
2
- import { globby } from "@modern-js/utils";
1
+ import path from 'path';
2
+ import { globby } from '@modern-js/utils';
3
3
  import { INDEX_SUFFIX } from "./constants";
4
- const getFiles = (lambdaDir, rules) => globby.sync(rules, {
4
+ export const getFiles = (lambdaDir, rules) => globby.sync(rules, {
5
5
  cwd: lambdaDir,
6
6
  gitignore: true
7
- }).map((file) => path.resolve(lambdaDir, file));
8
- const getPathFromFilename = (baseDir, filename) => {
7
+ }).map(file => path.resolve(lambdaDir, file));
8
+ export const getPathFromFilename = (baseDir, filename) => {
9
9
  const relativeName = filename.substring(baseDir.length);
10
- const relativePath = relativeName.split(".").slice(0, -1).join(".");
11
- const nameSplit = relativePath.split(path.sep).map((item) => {
10
+ const relativePath = relativeName.split('.').slice(0, -1).join('.');
11
+ const nameSplit = relativePath.split(path.sep).map(item => {
12
12
  if (item.length > 2) {
13
- if (item.startsWith("[") && item.endsWith("]")) {
13
+ if (item.startsWith('[') && item.endsWith(']')) {
14
14
  return `:${item.substring(1, item.length - 1)}`;
15
15
  }
16
16
  }
17
+
17
18
  return item;
18
19
  });
19
- const name = nameSplit.join("/");
20
+ const name = nameSplit.join('/');
20
21
  const finalName = name.endsWith(INDEX_SUFFIX) ? name.substring(0, name.length - INDEX_SUFFIX.length) : name;
21
22
  return clearRouteName(finalName);
22
23
  };
23
- const clearRouteName = (routeName) => {
24
+
25
+ const clearRouteName = routeName => {
24
26
  let finalRouteName = routeName.trim();
25
- if (!finalRouteName.startsWith("/")) {
27
+
28
+ if (!finalRouteName.startsWith('/')) {
26
29
  finalRouteName = `/${finalRouteName}`;
27
30
  }
28
- if (finalRouteName.length > 1 && finalRouteName.endsWith("/")) {
31
+
32
+ if (finalRouteName.length > 1 && finalRouteName.endsWith('/')) {
29
33
  finalRouteName = finalRouteName.substring(0, finalRouteName.length - 1);
30
34
  }
35
+
31
36
  return finalRouteName;
32
37
  };
33
- const isHandler = (input) => input && typeof input === "function";
34
- const enableRegister = (requireFn) => {
38
+
39
+ export const isHandler = input => input && typeof input === 'function';
40
+
41
+ const enableRegister = requireFn => {
42
+ // esbuild-register 做 unRegister 时,不会删除 register 添加的 require.extensions,导致第二次调用时 require.extensions['.ts'] 是 nodejs 默认 loader
43
+ // 所以这里根据第一次调用时,require.extensions 有没有,来判断是否需要使用 esbuild-register
35
44
  let existTsLoader = false;
36
45
  let firstCall = true;
37
- return (modulePath) => {
46
+ return modulePath => {
38
47
  if (firstCall) {
39
- existTsLoader = Boolean(require.extensions[".ts"]);
48
+ // eslint-disable-next-line node/no-deprecated-api
49
+ existTsLoader = Boolean(require.extensions['.ts']);
40
50
  firstCall = false;
41
51
  }
52
+
42
53
  if (!existTsLoader) {
43
54
  const {
44
55
  register
45
- } = require("esbuild-register/dist/node");
46
- const { unregister } = register({
47
- extensions: [".ts"]
56
+ } = require('esbuild-register/dist/node');
57
+
58
+ const {
59
+ unregister
60
+ } = register({
61
+ extensions: ['.ts']
48
62
  });
49
- const requiredModule2 = requireFn(modulePath);
63
+ const requiredModule = requireFn(modulePath);
50
64
  unregister();
51
- return requiredModule2;
65
+ return requiredModule;
52
66
  }
67
+
53
68
  const requiredModule = requireFn(modulePath);
54
69
  return requiredModule;
55
70
  };
56
71
  };
57
- const isFunction = (input) => input && {}.toString.call(input) === "[object Function]";
58
- const requireHandlerModule = enableRegister((modulePath) => {
59
- const originRequire = process.env.NODE_ENV === "test" ? jest.requireActual : require;
72
+
73
+ const isFunction = input => input && {}.toString.call(input) === '[object Function]';
74
+
75
+ export const requireHandlerModule = enableRegister(modulePath => {
76
+ // 测试环境不走缓存,因为缓存的 h andler 文件,会被 mockAPI 函数进行 mock,升级 jest28,setupFilesAfterEnv 能做异步操作的话,可解此问题
77
+ const originRequire = process.env.NODE_ENV === 'test' ? jest.requireActual : require;
60
78
  const module = originRequire(modulePath);
79
+
61
80
  if (isFunction(module)) {
62
- return { default: module };
81
+ return {
82
+ default: module
83
+ };
63
84
  }
85
+
64
86
  return module;
65
87
  });
66
- const routeValue = (routePath) => {
67
- if (routePath.includes(":")) {
88
+
89
+ const routeValue = routePath => {
90
+ if (routePath.includes(':')) {
68
91
  return 11;
69
92
  }
93
+
70
94
  return 1;
71
95
  };
72
- const sortRoutes = (apiHandlers) => {
96
+
97
+ export const sortRoutes = apiHandlers => {
73
98
  return apiHandlers.sort((handlerA, handlerB) => {
74
99
  return routeValue(handlerA.routeName) - routeValue(handlerB.routeName);
75
100
  });
76
- };
77
- export {
78
- getFiles,
79
- getPathFromFilename,
80
- isHandler,
81
- requireHandlerModule,
82
- sortRoutes
83
- };
101
+ };
@@ -1,45 +1,47 @@
1
- var OperatorType = /* @__PURE__ */ ((OperatorType2) => {
2
- OperatorType2[OperatorType2["Trigger"] = 0] = "Trigger";
3
- OperatorType2[OperatorType2["Middleware"] = 1] = "Middleware";
4
- return OperatorType2;
5
- })(OperatorType || {});
6
- var TriggerType = /* @__PURE__ */ ((TriggerType2) => {
7
- TriggerType2[TriggerType2["Http"] = 0] = "Http";
8
- return TriggerType2;
9
- })(TriggerType || {});
10
- var HttpMetadata = /* @__PURE__ */ ((HttpMetadata2) => {
11
- HttpMetadata2["Method"] = "METHOD";
12
- HttpMetadata2["Data"] = "DATA";
13
- HttpMetadata2["Query"] = "QUERY";
14
- HttpMetadata2["Params"] = "PARAMS";
15
- HttpMetadata2["Headers"] = "HEADERS";
16
- HttpMetadata2["Response"] = "RESPONSE";
17
- return HttpMetadata2;
18
- })(HttpMetadata || {});
19
- var ResponseMetaType = /* @__PURE__ */ ((ResponseMetaType2) => {
20
- ResponseMetaType2[ResponseMetaType2["StatusCode"] = 0] = "StatusCode";
21
- ResponseMetaType2[ResponseMetaType2["Redirect"] = 1] = "Redirect";
22
- ResponseMetaType2[ResponseMetaType2["Headers"] = 2] = "Headers";
23
- return ResponseMetaType2;
24
- })(ResponseMetaType || {});
25
- var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
26
- HttpMethod2["Get"] = "GET";
27
- HttpMethod2["Post"] = "POST";
28
- HttpMethod2["Put"] = "PUT";
29
- HttpMethod2["Delete"] = "DELETE";
30
- HttpMethod2["Connect"] = "CONNECT";
31
- HttpMethod2["Trace"] = "TRACE";
32
- HttpMethod2["Patch"] = "PATCH";
33
- HttpMethod2["Option"] = "OPTION";
34
- HttpMethod2["Head"] = "HEAD";
35
- return HttpMethod2;
36
- })(HttpMethod || {});
37
- const httpMethods = Object.values(HttpMethod);
38
- export {
39
- HttpMetadata,
40
- HttpMethod,
41
- OperatorType,
42
- ResponseMetaType,
43
- TriggerType,
44
- httpMethods
45
- };
1
+ export let OperatorType;
2
+
3
+ (function (OperatorType) {
4
+ OperatorType[OperatorType["Trigger"] = 0] = "Trigger";
5
+ OperatorType[OperatorType["Middleware"] = 1] = "Middleware";
6
+ })(OperatorType || (OperatorType = {}));
7
+
8
+ export let TriggerType;
9
+
10
+ (function (TriggerType) {
11
+ TriggerType[TriggerType["Http"] = 0] = "Http";
12
+ })(TriggerType || (TriggerType = {}));
13
+
14
+ export let HttpMetadata;
15
+
16
+ (function (HttpMetadata) {
17
+ HttpMetadata["Method"] = "METHOD";
18
+ HttpMetadata["Data"] = "DATA";
19
+ HttpMetadata["Query"] = "QUERY";
20
+ HttpMetadata["Params"] = "PARAMS";
21
+ HttpMetadata["Headers"] = "HEADERS";
22
+ HttpMetadata["Response"] = "RESPONSE";
23
+ })(HttpMetadata || (HttpMetadata = {}));
24
+
25
+ export let ResponseMetaType;
26
+
27
+ (function (ResponseMetaType) {
28
+ ResponseMetaType[ResponseMetaType["StatusCode"] = 0] = "StatusCode";
29
+ ResponseMetaType[ResponseMetaType["Redirect"] = 1] = "Redirect";
30
+ ResponseMetaType[ResponseMetaType["Headers"] = 2] = "Headers";
31
+ })(ResponseMetaType || (ResponseMetaType = {}));
32
+
33
+ export let HttpMethod;
34
+
35
+ (function (HttpMethod) {
36
+ HttpMethod["Get"] = "GET";
37
+ HttpMethod["Post"] = "POST";
38
+ HttpMethod["Put"] = "PUT";
39
+ HttpMethod["Delete"] = "DELETE";
40
+ HttpMethod["Connect"] = "CONNECT";
41
+ HttpMethod["Trace"] = "TRACE";
42
+ HttpMethod["Patch"] = "PATCH";
43
+ HttpMethod["Option"] = "OPTION";
44
+ HttpMethod["Head"] = "HEAD";
45
+ })(HttpMethod || (HttpMethod = {}));
46
+
47
+ export const httpMethods = Object.values(HttpMethod);