@gravity-ui/gateway 4.1.0 → 4.1.1-alpha.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.
Files changed (90) hide show
  1. package/{build → dist/commonjs}/components/grpc.d.ts +4 -4
  2. package/{build → dist/commonjs}/components/grpc.js +85 -75
  3. package/{build → dist/commonjs}/components/mixed.d.ts +4 -4
  4. package/{build → dist/commonjs}/components/mixed.js +11 -12
  5. package/{build → dist/commonjs}/components/rest.d.ts +5 -5
  6. package/{build → dist/commonjs}/components/rest.js +32 -32
  7. package/{build → dist/commonjs}/constants.d.ts +2 -2
  8. package/{build → dist/commonjs}/constants.js +25 -18
  9. package/{build → dist/commonjs}/index.d.ts +8 -7
  10. package/{build → dist/commonjs}/index.js +32 -44
  11. package/{build → dist/commonjs}/models/common.d.ts +11 -6
  12. package/{build → dist/commonjs}/models/context.d.ts +0 -1
  13. package/dist/commonjs/package.json +3 -0
  14. package/dist/commonjs/utils/axios.d.ts +3 -0
  15. package/{build → dist/commonjs}/utils/axios.js +3 -4
  16. package/{build → dist/commonjs}/utils/common.d.ts +3 -3
  17. package/{build → dist/commonjs}/utils/common.js +7 -8
  18. package/{build → dist/commonjs}/utils/create-context-api.d.ts +2 -2
  19. package/{build → dist/commonjs}/utils/create-context-api.js +5 -6
  20. package/{build → dist/commonjs}/utils/grpc-reflection.js +21 -12
  21. package/{build → dist/commonjs}/utils/grpc.js +7 -8
  22. package/dist/commonjs/utils/overrideEndpoints/index.d.ts +2 -0
  23. package/dist/commonjs/utils/overrideEndpoints/index.js +4 -0
  24. package/{build → dist/commonjs}/utils/overrideEndpoints/overrideEndpoints.d.ts +1 -1
  25. package/{build → dist/commonjs}/utils/overrideEndpoints/overrideEndpoints.js +1 -2
  26. package/{build → dist/commonjs}/utils/parse-error.d.ts +4 -4
  27. package/{build → dist/commonjs}/utils/parse-error.js +18 -18
  28. package/{build → dist/commonjs}/utils/proto-path-resolver.js +23 -17
  29. package/{build → dist/commonjs}/utils/redact-sensitive-headers.d.ts +1 -2
  30. package/{build → dist/commonjs}/utils/redact-sensitive-headers.js +1 -2
  31. package/dist/commonjs/utils/source-dir.d.ts +1 -0
  32. package/dist/commonjs/utils/source-dir.js +41 -0
  33. package/{build → dist/commonjs}/utils/typed-api.d.ts +1 -1
  34. package/{build → dist/commonjs}/utils/typed-api.js +1 -2
  35. package/{build → dist/commonjs}/utils/validate.js +6 -10
  36. package/dist/esm/components/grpc.d.ts +24 -0
  37. package/dist/esm/components/grpc.js +641 -0
  38. package/dist/esm/components/mixed.d.ts +11 -0
  39. package/dist/esm/components/mixed.js +62 -0
  40. package/dist/esm/components/rest.d.ts +8 -0
  41. package/dist/esm/components/rest.js +349 -0
  42. package/dist/esm/constants.d.ts +53 -0
  43. package/dist/esm/constants.js +79 -0
  44. package/dist/esm/index.d.ts +12 -0
  45. package/dist/esm/index.js +264 -0
  46. package/dist/esm/models/common.d.ts +272 -0
  47. package/dist/esm/models/common.js +5 -0
  48. package/dist/esm/models/context.d.ts +22 -0
  49. package/dist/esm/models/context.js +1 -0
  50. package/dist/esm/models/error.d.ts +12 -0
  51. package/dist/esm/models/error.js +1 -0
  52. package/dist/esm/package.json +3 -0
  53. package/{build → dist/esm}/utils/axios.d.ts +1 -1
  54. package/dist/esm/utils/axios.js +23 -0
  55. package/dist/esm/utils/common.d.ts +15 -0
  56. package/dist/esm/utils/common.js +38 -0
  57. package/dist/esm/utils/create-context-api.d.ts +4 -0
  58. package/dist/esm/utils/create-context-api.js +38 -0
  59. package/dist/esm/utils/grpc-reflection.d.ts +28 -0
  60. package/dist/esm/utils/grpc-reflection.js +68 -0
  61. package/dist/esm/utils/grpc.d.ts +5 -0
  62. package/dist/esm/utils/grpc.js +39 -0
  63. package/dist/esm/utils/overrideEndpoints/index.d.ts +2 -0
  64. package/dist/esm/utils/overrideEndpoints/index.js +2 -0
  65. package/dist/esm/utils/overrideEndpoints/overrideEndpoints.d.ts +17 -0
  66. package/dist/esm/utils/overrideEndpoints/overrideEndpoints.js +96 -0
  67. package/dist/esm/utils/parse-error.d.ts +30 -0
  68. package/dist/esm/utils/parse-error.js +210 -0
  69. package/dist/esm/utils/proto-path-resolver.d.ts +2 -0
  70. package/dist/esm/utils/proto-path-resolver.js +23 -0
  71. package/dist/esm/utils/redact-sensitive-headers.d.ts +3 -0
  72. package/dist/esm/utils/redact-sensitive-headers.js +12 -0
  73. package/dist/esm/utils/source-dir.d.ts +1 -0
  74. package/dist/esm/utils/source-dir.js +4 -0
  75. package/dist/esm/utils/typed-api.d.ts +2 -0
  76. package/dist/esm/utils/typed-api.js +3 -0
  77. package/dist/esm/utils/validate.d.ts +4 -0
  78. package/dist/esm/utils/validate.js +47 -0
  79. package/package.json +41 -16
  80. package/build/utils/overrideEndpoints/index.d.ts +0 -2
  81. package/build/utils/overrideEndpoints/index.js +0 -4
  82. /package/bin/{patch.js → patch.cjs} +0 -0
  83. /package/{build → dist/commonjs}/models/common.js +0 -0
  84. /package/{build → dist/commonjs}/models/context.js +0 -0
  85. /package/{build → dist/commonjs}/models/error.d.ts +0 -0
  86. /package/{build → dist/commonjs}/models/error.js +0 -0
  87. /package/{build → dist/commonjs}/utils/grpc-reflection.d.ts +0 -0
  88. /package/{build → dist/commonjs}/utils/grpc.d.ts +0 -0
  89. /package/{build → dist/commonjs}/utils/proto-path-resolver.d.ts +0 -0
  90. /package/{build → dist/commonjs}/utils/validate.d.ts +0 -0
@@ -3,24 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createRestAction = createRestAction;
6
7
  const querystring_1 = __importDefault(require("querystring"));
7
8
  const url_1 = __importDefault(require("url"));
8
9
  const lodash_1 = __importDefault(require("lodash"));
9
10
  const uuid_1 = require("uuid");
10
- const constants_1 = require("../constants");
11
- const axios_1 = require("../utils/axios");
12
- const common_1 = require("../utils/common");
13
- const parse_error_1 = require("../utils/parse-error");
14
- const redact_sensitive_headers_1 = require("../utils/redact-sensitive-headers");
15
- const validate_1 = require("../utils/validate");
11
+ const constants_js_1 = require("../constants.js");
12
+ const axios_js_1 = require("../utils/axios.js");
13
+ const common_js_1 = require("../utils/common.js");
14
+ const parse_error_js_1 = require("../utils/parse-error.js");
15
+ const redact_sensitive_headers_js_1 = require("../utils/redact-sensitive-headers.js");
16
+ const validate_js_1 = require("../utils/validate.js");
16
17
  function getRestResponseSize(data, ctx, ErrorConstructor) {
17
18
  var _a;
18
19
  let responseSize = 0;
19
20
  try {
20
- responseSize = constants_1.ECMA_STRING_SIZE * ((_a = JSON.stringify(data)) === null || _a === void 0 ? void 0 : _a.length);
21
+ responseSize = constants_js_1.ECMA_STRING_SIZE * ((_a = JSON.stringify(data)) === null || _a === void 0 ? void 0 : _a.length);
21
22
  }
22
23
  catch (error) {
23
- (0, common_1.handleError)(ErrorConstructor, error, ctx, 'Calculate response size failed');
24
+ (0, common_js_1.handleError)(ErrorConstructor, error, ctx, 'Calculate response size failed');
24
25
  }
25
26
  return responseSize;
26
27
  }
@@ -36,13 +37,13 @@ function getConfigSerializerFunction(config) {
36
37
  function createRestAction(endpoints, config, serviceKey, actionName, options, ErrorConstructor) {
37
38
  var _a, _b, _c;
38
39
  const timeout = (_c = (_a = config === null || config === void 0 ? void 0 : config.timeout) !== null && _a !== void 0 ? _a : (_b = options === null || options === void 0 ? void 0 : options.axiosConfig) === null || _b === void 0 ? void 0 : _b.timeout) !== null && _c !== void 0 ? _c : options === null || options === void 0 ? void 0 : options.timeout;
39
- const defaultAxiosClient = (0, axios_1.getAxiosClient)(timeout, config === null || config === void 0 ? void 0 : config.retries, options === null || options === void 0 ? void 0 : options.axiosConfig, options === null || options === void 0 ? void 0 : options.axiosInterceptors);
40
+ const defaultAxiosClient = (0, axios_js_1.getAxiosClient)(timeout, config === null || config === void 0 ? void 0 : config.retries, options === null || options === void 0 ? void 0 : options.axiosConfig, options === null || options === void 0 ? void 0 : options.axiosInterceptors);
40
41
  /* eslint-disable complexity */
41
42
  return async function action(actionConfig) {
42
43
  var _a, _b, _c, _d, _e, _f, _g, _h;
43
44
  const { args, requestId, headers: requestHeaders, ctx: parentCtx, authArgs, userId, } = actionConfig;
44
45
  const debugHeaders = {};
45
- const lang = requestHeaders[constants_1.DEFAULT_LANG_HEADER] || constants_1.Lang.Ru; // header might be empty string
46
+ const lang = requestHeaders[constants_js_1.DEFAULT_LANG_HEADER] || constants_js_1.Lang.Ru; // header might be empty string
46
47
  const serviceName = (options === null || options === void 0 ? void 0 : options.serviceName) || serviceKey;
47
48
  const idempotency = config.idempotency;
48
49
  const ctx = parentCtx.create(`Gateway ${serviceName} ${actionName} [rest]`, {
@@ -55,7 +56,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
55
56
  ctx.log('Initiating request');
56
57
  const validationSchema = config.validationSchema || options.validationSchema;
57
58
  if (validationSchema) {
58
- const invalidParams = (0, validate_1.validateArgs)(args, validationSchema);
59
+ const invalidParams = (0, validate_js_1.validateArgs)(args, validationSchema);
59
60
  if (invalidParams) {
60
61
  ctx.log('Invalid params', { invalidParams });
61
62
  ctx.end();
@@ -92,26 +93,26 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
92
93
  },
93
94
  });
94
95
  }
95
- const actionEndpoint = (0, common_1.isExtendedActionEndpoint)(endpointData)
96
+ const actionEndpoint = (0, common_js_1.isExtendedActionEndpoint)(endpointData)
96
97
  ? endpointData.path
97
98
  : endpointData;
98
- const endpointAxiosConfig = (0, common_1.isExtendedRestActionEndpoint)(endpointData)
99
+ const endpointAxiosConfig = (0, common_js_1.isExtendedRestActionEndpoint)(endpointData)
99
100
  ? endpointData.axiosConfig
100
101
  : undefined;
101
102
  const pathArgs = config.validationSchema
102
- ? (0, validate_1.encodePathParams)(args)
103
- : (0, validate_1.getPathArgsProxy)(args, options.encodePathArgs);
103
+ ? (0, validate_js_1.encodePathParams)(args)
104
+ : (0, validate_js_1.getPathArgsProxy)(args, options.encodePathArgs);
104
105
  const actionPath = typeof config.path === 'function' ? config.path(pathArgs) : config.path;
105
106
  const actionURL = actionEndpoint + actionPath;
106
107
  const parsedActionURL = url_1.default.parse(actionURL);
107
- const proxyHeaders = [...constants_1.DEFAULT_PROXY_HEADERS];
108
+ const proxyHeaders = [...constants_js_1.DEFAULT_PROXY_HEADERS];
108
109
  let actionHeaders = {
109
110
  // It's important not to lose the port in HOST header
110
111
  host: (_a = parsedActionURL.host) !== null && _a !== void 0 ? _a : undefined,
111
112
  accept: 'application/json, */*',
112
113
  'accept-encoding': 'gzip, deflate',
113
114
  'accept-language': lang,
114
- 'x-gateway-version': constants_1.VERSION,
115
+ 'x-gateway-version': constants_js_1.VERSION,
115
116
  };
116
117
  if (typeof options.proxyHeaders === 'function') {
117
118
  Object.assign(actionHeaders, options.proxyHeaders(Object.assign({}, requestHeaders), 'rest'));
@@ -150,7 +151,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
150
151
  params = await config.params(args, actionHeaders, { ctx });
151
152
  }
152
153
  catch (error) {
153
- (0, common_1.handleError)(ErrorConstructor, error, ctx, 'Getting config params failed');
154
+ (0, common_js_1.handleError)(ErrorConstructor, error, ctx, 'Getting config params failed');
154
155
  }
155
156
  }
156
157
  const { body = undefined, query = undefined, headers = actionHeaders } = params !== null && params !== void 0 ? params : {};
@@ -171,7 +172,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
171
172
  }
172
173
  }
173
174
  catch (error) {
174
- (0, common_1.handleError)(ErrorConstructor, error, ctx, 'Stringify request body failed');
175
+ (0, common_js_1.handleError)(ErrorConstructor, error, ctx, 'Stringify request body failed');
175
176
  }
176
177
  Object.assign(debugHeaders, {
177
178
  'x-api-request-method': config.method,
@@ -179,7 +180,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
179
180
  'x-api-request-body': requestBody ? requestBody : null,
180
181
  'x-api-request-lang': lang,
181
182
  'x-request-id': requestId,
182
- 'x-gateway-version': constants_1.VERSION,
183
+ 'x-gateway-version': constants_js_1.VERSION,
183
184
  });
184
185
  if (headers['content-type']) {
185
186
  debugHeaders['x-api-content-type'] = headers['content-type'];
@@ -199,10 +200,10 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
199
200
  const customActionTimeout = (_e = (_d = (_c = actionConfig.timeout) !== null && _c !== void 0 ? _c : config.timeout) !== null && _d !== void 0 ? _d : endpointAxiosConfig === null || endpointAxiosConfig === void 0 ? void 0 : endpointAxiosConfig.timeout) !== null && _e !== void 0 ? _e : timeout;
200
201
  if (actionConfig.timeout || endpointAxiosConfig) {
201
202
  const customActionAxiosConfig = Object.assign(Object.assign({}, ((options === null || options === void 0 ? void 0 : options.axiosConfig) || {})), (endpointAxiosConfig || {}));
202
- axiosClient = (0, axios_1.getAxiosClient)(customActionTimeout, config === null || config === void 0 ? void 0 : config.retries, customActionAxiosConfig, options === null || options === void 0 ? void 0 : options.axiosInterceptors);
203
+ axiosClient = (0, axios_js_1.getAxiosClient)(customActionTimeout, config === null || config === void 0 ? void 0 : config.retries, customActionAxiosConfig, options === null || options === void 0 ? void 0 : options.axiosInterceptors);
203
204
  }
204
- headers['x-request-timeout'] = customActionTimeout !== null && customActionTimeout !== void 0 ? customActionTimeout : constants_1.DEFAULT_TIMEOUT;
205
- ctx.log('Starting request', { debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders) });
205
+ headers['x-request-timeout'] = customActionTimeout !== null && customActionTimeout !== void 0 ? customActionTimeout : constants_js_1.DEFAULT_TIMEOUT;
206
+ ctx.log('Starting request', { debugHeaders: (0, common_js_1.sanitizeDebugHeaders)(debugHeaders) });
206
207
  const requestData = {
207
208
  timestamp: startRequestTime,
208
209
  service: serviceName,
@@ -277,7 +278,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
277
278
  ctx.log('Transformed response data');
278
279
  }
279
280
  catch (error) {
280
- (0, common_1.handleError)(ErrorConstructor, error, ctx, 'Transform response data failed');
281
+ (0, common_js_1.handleError)(ErrorConstructor, error, ctx, 'Transform response data failed');
281
282
  }
282
283
  }
283
284
  if (config.proxyResponseHeaders) {
@@ -295,12 +296,12 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
295
296
  }
296
297
  }
297
298
  if (options === null || options === void 0 ? void 0 : options.sendStats) {
298
- options.sendStats(Object.assign(Object.assign({}, requestData), { responseSize: getRestResponseSize(response === null || response === void 0 ? void 0 : response.data, ctx, ErrorConstructor), restStatus: 200 }), (0, redact_sensitive_headers_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders) });
299
+ options.sendStats(Object.assign(Object.assign({}, requestData), { responseSize: getRestResponseSize(response === null || response === void 0 ? void 0 : response.data, ctx, ErrorConstructor), restStatus: 200 }), (0, redact_sensitive_headers_js_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_js_1.sanitizeDebugHeaders)(debugHeaders) });
299
300
  }
300
301
  else {
301
302
  ctx.stats(Object.assign(Object.assign({}, requestData), { responseStatus: 200 }));
302
303
  }
303
- ctx.log('Request completed', { debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders) });
304
+ ctx.log('Request completed', { debugHeaders: (0, common_js_1.sanitizeDebugHeaders)(debugHeaders) });
304
305
  ctx.end();
305
306
  return { responseData: response.data, responseHeaders, debugHeaders };
306
307
  }
@@ -320,20 +321,20 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
320
321
  ctx.log('Transformed response error');
321
322
  }
322
323
  catch (error) {
323
- (0, common_1.handleError)(ErrorConstructor, error, ctx, 'Transform response error failed');
324
+ (0, common_js_1.handleError)(ErrorConstructor, error, ctx, 'Transform response error failed');
324
325
  }
325
326
  }
326
327
  if (!parsedError) {
327
328
  try {
328
- parsedError = (0, parse_error_1.parseRestError)(error, lang);
329
+ parsedError = (0, parse_error_js_1.parseRestError)(error, lang);
329
330
  }
330
331
  catch (error) {
331
- (0, common_1.handleError)(ErrorConstructor, error, ctx, 'Error parse rest error');
332
+ (0, common_js_1.handleError)(ErrorConstructor, error, ctx, 'Error parse rest error');
332
333
  }
333
334
  }
334
335
  const responseStatus = lodash_1.default.get(parsedError, 'status') || lodash_1.default.get(error, 'status', 500);
335
336
  if (options === null || options === void 0 ? void 0 : options.sendStats) {
336
- options.sendStats(Object.assign(Object.assign({}, requestData), { responseSize: getRestResponseSize((_h = error === null || error === void 0 ? void 0 : error.response) === null || _h === void 0 ? void 0 : _h.data, ctx, ErrorConstructor), restStatus: responseStatus, userId }), (0, redact_sensitive_headers_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders) });
337
+ options.sendStats(Object.assign(Object.assign({}, requestData), { responseSize: getRestResponseSize((_h = error === null || error === void 0 ? void 0 : error.response) === null || _h === void 0 ? void 0 : _h.data, ctx, ErrorConstructor), restStatus: responseStatus, userId }), (0, redact_sensitive_headers_js_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_js_1.sanitizeDebugHeaders)(debugHeaders) });
337
338
  }
338
339
  else {
339
340
  ctx.stats(Object.assign(Object.assign({}, requestData), { responseStatus }));
@@ -342,7 +343,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
342
343
  actionURL,
343
344
  parsedError,
344
345
  serviceName,
345
- debugHeaders: (0, common_1.sanitizeDebugHeaders)(debugHeaders),
346
+ debugHeaders: (0, common_js_1.sanitizeDebugHeaders)(debugHeaders),
346
347
  });
347
348
  ctx.end();
348
349
  return Promise.reject({
@@ -352,4 +353,3 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
352
353
  }
353
354
  };
354
355
  }
355
- exports.default = createRestAction;
@@ -1,5 +1,5 @@
1
- import http from 'http';
2
- import https from 'https';
1
+ import * as http from 'http';
2
+ import * as https from 'https';
3
3
  import * as grpc from '@grpc/grpc-js';
4
4
  export declare const VERSION: any;
5
5
  export declare enum Lang {
@@ -15,20 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
28
35
  Object.defineProperty(exports, "__esModule", { value: true });
29
36
  exports.AXIOS_RETRY_NAMESPACE = exports.DEFAULT_VALIDATION_SCHEMA = exports.RECREATE_SERVICE_CODES = exports.RETRYABLE_STATUS_CODES = exports.ANY_ACTION_SYMBOL = exports.ECMA_STRING_SIZE = exports.DEFAULT_PROTO_LOADER_OPTIONS = exports.DEFAULT_GRPC_OPTIONS = exports.DEFAULT_AXIOS_OPTIONS = exports.DEFAULT_PROXY_HEADERS = exports.DEFAULT_LANG_HEADER = exports.DEFAULT_TIMEOUT = exports.Lang = exports.VERSION = void 0;
30
- const http_1 = __importDefault(require("http"));
31
- const https_1 = __importDefault(require("https"));
37
+ const http = __importStar(require("http"));
38
+ const https = __importStar(require("https"));
32
39
  const grpc = __importStar(require("@grpc/grpc-js"));
33
40
  const packageJson = require('../package.json');
34
41
  exports.VERSION = packageJson.version;
@@ -47,18 +54,18 @@ exports.DEFAULT_PROXY_HEADERS = [
47
54
  'x-forwarded-for',
48
55
  ];
49
56
  exports.DEFAULT_AXIOS_OPTIONS = {
50
- maxContentLength: 1024 * 1024 * 100,
51
- httpAgent: new http_1.default.Agent({
52
- //@ts-ignore https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L233
57
+ maxContentLength: 1024 * 1024 * 100, // 100 Mb
58
+ httpAgent: new http.Agent({
59
+ // https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L233
53
60
  family: 6,
54
61
  }),
55
- httpsAgent: new https_1.default.Agent({
56
- //@ts-ignore https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L233
62
+ httpsAgent: new https.Agent({
63
+ // https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L233
57
64
  family: 6,
58
65
  }),
59
66
  };
60
67
  exports.DEFAULT_GRPC_OPTIONS = {
61
- 'grpc.max_receive_message_length': 1024 * 1024 * 100,
68
+ 'grpc.max_receive_message_length': 1024 * 1024 * 100, // 100 Mb
62
69
  'grpc.keepalive_time_ms': 10000,
63
70
  'grpc.keepalive_timeout_ms': 1000,
64
71
  'grpc.keepalive_permit_without_calls': 1,
@@ -1,11 +1,12 @@
1
- import { ApiWithRoot, GatewayConfig, GatewayRequest, GatewayResponse, SchemasByScope } from './models/common';
2
- import { GatewayContext } from './models/context';
3
- export * from './utils/typed-api';
4
- export * from './utils/grpc-reflection';
5
- export * from './models/common';
6
- export * from './models/context';
7
- export * from './models/error';
1
+ import { ApiWithRoot, GatewayConfig, GatewayRequest, GatewayResponse, SchemasByScope } from './models/common.js';
2
+ import { GatewayContext } from './models/context.js';
3
+ export * from './utils/typed-api.js';
4
+ export * from './utils/grpc-reflection.js';
5
+ export * from './models/common.js';
6
+ export * from './models/context.js';
7
+ export * from './models/error.js';
8
8
  export declare function getGatewayControllers<TSchema extends SchemasByScope, Context extends GatewayContext, Req extends GatewayRequest<Context>, Res extends GatewayResponse>(schemasByScope: TSchema, config: GatewayConfig<Context, Req, Res>): {
9
9
  controller: (req: Req, res: Res) => Promise<any>;
10
10
  api: ApiWithRoot<TSchema, Context, Req, Res>;
11
11
  };
12
+ export default getGatewayControllers;
@@ -10,18 +10,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
@@ -29,19 +17,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
18
  };
31
19
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.getGatewayControllers = void 0;
20
+ exports.getGatewayControllers = getGatewayControllers;
33
21
  const lodash_1 = __importDefault(require("lodash"));
34
- const grpc_1 = __importStar(require("./components/grpc"));
35
- const mixed_1 = require("./components/mixed");
36
- const rest_1 = __importDefault(require("./components/rest"));
37
- const constants_1 = require("./constants");
38
- const common_1 = require("./utils/common");
39
- const overrideEndpoints_1 = __importDefault(require("./utils/overrideEndpoints"));
40
- __exportStar(require("./utils/typed-api"), exports);
41
- __exportStar(require("./utils/grpc-reflection"), exports);
42
- __exportStar(require("./models/common"), exports);
43
- __exportStar(require("./models/context"), exports);
44
- __exportStar(require("./models/error"), exports);
22
+ const grpc_js_1 = require("./components/grpc.js");
23
+ const mixed_js_1 = require("./components/mixed.js");
24
+ const rest_js_1 = require("./components/rest.js");
25
+ const constants_js_1 = require("./constants.js");
26
+ const common_js_1 = require("./utils/common.js");
27
+ const overrideEndpoints_js_1 = require("./utils/overrideEndpoints/overrideEndpoints.js");
28
+ __exportStar(require("./utils/typed-api.js"), exports);
29
+ __exportStar(require("./utils/grpc-reflection.js"), exports);
30
+ __exportStar(require("./models/common.js"), exports);
31
+ __exportStar(require("./models/context.js"), exports);
32
+ __exportStar(require("./models/error.js"), exports);
45
33
  function isMixedActionConfig(actionConfig) {
46
34
  return typeof actionConfig === 'function';
47
35
  }
@@ -67,11 +55,11 @@ function createApiAction(schema, config, serviceKey, actionName, api, grpcContex
67
55
  const env = config.env || '';
68
56
  if (isMixedActionConfig(action)) {
69
57
  const resultServiceName = serviceName || serviceKey;
70
- return (0, mixed_1.createMixedAction)(action, api, resultServiceName, actionName, { config, grpcContext }, config.ErrorConstructor);
58
+ return (0, mixed_js_1.createMixedAction)(action, api, resultServiceName, actionName, { config, grpcContext }, config.ErrorConstructor);
71
59
  }
72
60
  const endpointsConfig = lodash_1.default.get(serviceSchema.endpoints, [installation, env]);
73
61
  if (isRestActionConfig(action)) {
74
- return (0, rest_1.default)(endpointsConfig, action, serviceKey, actionName, {
62
+ return (0, rest_js_1.createRestAction)(endpointsConfig, action, serviceKey, actionName, {
75
63
  serviceName,
76
64
  timeout: config.timeout,
77
65
  sendStats: config.sendStats,
@@ -85,7 +73,7 @@ function createApiAction(schema, config, serviceKey, actionName, api, grpcContex
85
73
  }, config.ErrorConstructor);
86
74
  }
87
75
  const grpcRecreateService = (_a = config.grpcRecreateService) !== null && _a !== void 0 ? _a : true;
88
- return (0, grpc_1.default)(grpcContext, endpointsConfig, action, serviceKey, actionName, {
76
+ return (0, grpc_js_1.createGrpcAction)(grpcContext, endpointsConfig, action, serviceKey, actionName, {
89
77
  serviceName,
90
78
  timeout: config.timeout,
91
79
  sendStats: config.sendStats,
@@ -161,8 +149,8 @@ function generateGatewayApiController(schemasByScope, Api, config, controllerAct
161
149
  });
162
150
  }
163
151
  if (controllerActions &&
164
- lodash_1.default.get(controllerActions, [scope]) !== constants_1.ANY_ACTION_SYMBOL &&
165
- lodash_1.default.get(controllerActions, [scope, service]) !== constants_1.ANY_ACTION_SYMBOL &&
152
+ lodash_1.default.get(controllerActions, [scope]) !== constants_js_1.ANY_ACTION_SYMBOL &&
153
+ lodash_1.default.get(controllerActions, [scope, service]) !== constants_js_1.ANY_ACTION_SYMBOL &&
166
154
  !lodash_1.default.get(controllerActions, [scope, service, action])) {
167
155
  return res.status(404).send({
168
156
  status: 404,
@@ -179,7 +167,7 @@ function generateGatewayApiController(schemasByScope, Api, config, controllerAct
179
167
  await onBeforeAction(req, res, scope, service, action, actionConfig);
180
168
  }
181
169
  catch (error) {
182
- (0, common_1.handleError)(config.ErrorConstructor, error, req.ctx, 'Before action handler error');
170
+ (0, common_js_1.handleError)(config.ErrorConstructor, error, req.ctx, 'Before action handler error');
183
171
  throw { error, debugHeaders: {} };
184
172
  }
185
173
  }
@@ -239,25 +227,25 @@ function getGatewayControllers(schemasByScope, config) {
239
227
  if (process.env.GATEWAY_ENDPOINTS_OVERRIDES) {
240
228
  try {
241
229
  // eslint-disable-next-line no-param-reassign
242
- schemasByScope = (0, overrideEndpoints_1.default)(schemasByScope, JSON.parse(process.env.GATEWAY_ENDPOINTS_OVERRIDES), config.installation, config.env);
230
+ schemasByScope = (0, overrideEndpoints_js_1.overrideEndpoints)(schemasByScope, JSON.parse(process.env.GATEWAY_ENDPOINTS_OVERRIDES), config.installation, config.env);
243
231
  }
244
232
  catch (err) {
245
233
  console.warn('Error when parse GATEWAY_ENDPOINTS_OVERRIDES', err);
246
234
  }
247
235
  }
248
- const credentials = (0, grpc_1.getCredentialsMap)(config.caCertificatePath);
249
- for (const scope of (0, common_1.getKeys)(schemasByScope)) {
250
- apiByScope[scope] = generateGatewayApi(schemasByScope[scope], config, { root: (0, grpc_1.createRoot)(config.includeProtoRoots), credentials }, apiByScope);
236
+ const credentials = (0, grpc_js_1.getCredentialsMap)(config.caCertificatePath);
237
+ for (const scope of (0, common_js_1.getKeys)(schemasByScope)) {
238
+ apiByScope[scope] = generateGatewayApi(schemasByScope[scope], config, { root: (0, grpc_js_1.createRoot)(config.includeProtoRoots), credentials }, apiByScope);
251
239
  }
252
240
  const api = Object.assign({}, apiByScope);
253
241
  const rootScope = apiByScope.root;
254
242
  if (rootScope) {
255
- for (const rootService of (0, common_1.getKeys)(rootScope)) {
243
+ for (const rootService of (0, common_js_1.getKeys)(rootScope)) {
256
244
  const curScope = (_a = api[rootService]) !== null && _a !== void 0 ? _a : {};
257
- for (const rootAction of (0, common_1.getKeys)(rootScope[rootService])) {
245
+ for (const rootAction of (0, common_js_1.getKeys)(rootScope[rootService])) {
258
246
  const rootServiceFunc = rootScope[rootService][rootAction];
259
247
  if (curScope[rootAction]) {
260
- for (const curScopeAction of (0, common_1.getKeys)(curScope[rootAction])) {
248
+ for (const curScopeAction of (0, common_js_1.getKeys)(curScope[rootAction])) {
261
249
  rootServiceFunc[curScopeAction] = curScope[rootAction][curScopeAction];
262
250
  }
263
251
  }
@@ -270,15 +258,15 @@ function getGatewayControllers(schemasByScope, config) {
270
258
  ? config.actions.reduce((acc, item) => {
271
259
  const [scope, service, action] = item.split('.');
272
260
  // Ignore option '*' for scopes
273
- if (scope === constants_1.ANY_ACTION_SYMBOL) {
261
+ if (scope === constants_js_1.ANY_ACTION_SYMBOL) {
274
262
  return acc;
275
263
  }
276
- if (service === constants_1.ANY_ACTION_SYMBOL) {
277
- lodash_1.default.set(acc, [scope], constants_1.ANY_ACTION_SYMBOL);
264
+ if (service === constants_js_1.ANY_ACTION_SYMBOL) {
265
+ lodash_1.default.set(acc, [scope], constants_js_1.ANY_ACTION_SYMBOL);
278
266
  }
279
- else if (action === constants_1.ANY_ACTION_SYMBOL) {
280
- if (acc[scope] !== constants_1.ANY_ACTION_SYMBOL) {
281
- lodash_1.default.set(acc, [scope, service], constants_1.ANY_ACTION_SYMBOL);
267
+ else if (action === constants_js_1.ANY_ACTION_SYMBOL) {
268
+ if (acc[scope] !== constants_js_1.ANY_ACTION_SYMBOL) {
269
+ lodash_1.default.set(acc, [scope, service], constants_js_1.ANY_ACTION_SYMBOL);
282
270
  }
283
271
  }
284
272
  else {
@@ -293,4 +281,4 @@ function getGatewayControllers(schemasByScope, config) {
293
281
  api,
294
282
  };
295
283
  }
296
- exports.getGatewayControllers = getGatewayControllers;
284
+ exports.default = getGatewayControllers;
@@ -1,14 +1,13 @@
1
- /// <reference types="node" />
2
1
  import { IncomingHttpHeaders } from 'http';
3
2
  import { ClientDuplexStream, ClientReadableStream, ClientWritableStream } from '@grpc/grpc-js';
4
- import { HandlerType } from '@grpc/grpc-js/build/src/server-call';
3
+ import type { HandlerType } from '@grpc/grpc-js/build/src/server-call.js';
5
4
  import { AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
6
5
  import type { Request, Response } from 'express';
7
6
  import * as protobufjs from 'protobufjs';
8
- import type { GrpcContext } from '../components/grpc';
9
- import { Lang } from '../constants';
10
- import { GatewayContext } from './context';
11
- import { AppErrorConstructor } from './error';
7
+ import type { GrpcContext } from '../components/grpc.js';
8
+ import { Lang } from '../constants.js';
9
+ import { GatewayContext } from './context.js';
10
+ import { AppErrorConstructor } from './error.js';
12
11
  export interface GatewayRequest<Context extends GatewayContext> extends Request {
13
12
  id: string;
14
13
  ctx: Context;
@@ -202,12 +201,18 @@ export interface GatewayActionUnaryResponse<TAction> extends GatewayActionHeader
202
201
  }
203
202
  export interface GatewayActionClientStreamResponse<TAction> extends GatewayActionHeaders {
204
203
  stream: ClientWritableStream<ApiActionResponseType<TAction>>;
204
+ responseData?: never;
205
+ responseHeaders?: never;
205
206
  }
206
207
  export interface GatewayActionServerStreamResponse<TAction> extends GatewayActionHeaders {
207
208
  stream: ClientReadableStream<ApiActionResponseType<TAction>>;
209
+ responseData?: never;
210
+ responseHeaders?: never;
208
211
  }
209
212
  export interface GatewayActionDuplexStreamResponse<TAction> extends GatewayActionHeaders {
210
213
  stream: ClientDuplexStream<ApiActionParams<TAction>, ApiActionResponseType<TAction>>;
214
+ responseData?: never;
215
+ responseHeaders?: never;
211
216
  }
212
217
  export type GatewayActionResponseData<Context extends GatewayContext, Req extends GatewayRequest<Context>, Res extends GatewayResponse, TAction extends ApiServiceActionConfig<Context, Req, Res, unknown, unknown, unknown>> = TAction extends ApiServiceGrpcActionConfig<Context, unknown, unknown, unknown> ? TAction['type'] extends 'clientStream' ? GatewayActionClientStreamResponse<TAction> : TAction['type'] extends 'serverStream' ? GatewayActionServerStreamResponse<TAction> : TAction['type'] extends 'bidi' ? GatewayActionDuplexStreamResponse<TAction> : GatewayActionUnaryResponse<TAction> : GatewayActionUnaryResponse<TAction>;
213
218
  type GatewayAction<Context extends GatewayContext, Req extends GatewayRequest<Context>, Res extends GatewayResponse, TAction extends ApiServiceActionConfig<Context, Req, Res, unknown, unknown, unknown>> = undefined extends ApiActionParams<TAction> ? (params?: ApiActionConfig<Context, ApiActionParams<TAction>, ApiActionResponseType<TAction>>) => Promise<GatewayActionResponseData<Context, Req, Res, TAction>> : (params: ApiActionConfig<Context, ApiActionParams<TAction>, ApiActionResponseType<TAction>>) => Promise<GatewayActionResponseData<Context, Req, Res, TAction>>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IncomingHttpHeaders } from 'http';
3
2
  export interface GatewayContextParams {
4
3
  tags?: Record<string, string | number | boolean | undefined>;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,3 @@
1
+ import axios, { AxiosRequestConfig } from 'axios';
2
+ import { AxiosInterceptorsConfig } from '../models/common.js';
3
+ export declare function getAxiosClient(timeout?: number, retries?: number, axiosConfig?: AxiosRequestConfig, { request: reqInterceptors, response: resInterceptors }?: AxiosInterceptorsConfig): axios.AxiosInstance;
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAxiosClient = void 0;
6
+ exports.getAxiosClient = getAxiosClient;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const axios_retry_1 = __importDefault(require("axios-retry"));
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
- const constants_1 = require("../constants");
11
- function getAxiosClient(timeout = constants_1.DEFAULT_TIMEOUT, retries = 0, axiosConfig = constants_1.DEFAULT_AXIOS_OPTIONS, { request: reqInterceptors, response: resInterceptors } = {}) {
10
+ const constants_js_1 = require("../constants.js");
11
+ function getAxiosClient(timeout = constants_js_1.DEFAULT_TIMEOUT, retries = 0, axiosConfig = constants_js_1.DEFAULT_AXIOS_OPTIONS, { request: reqInterceptors, response: resInterceptors } = {}) {
12
12
  const client = axios_1.default.create(Object.assign(Object.assign({}, axiosConfig), { timeout }));
13
13
  reqInterceptors === null || reqInterceptors === void 0 ? void 0 : reqInterceptors.forEach(({ callback, errorCallback }) => client.interceptors.request.use(callback, errorCallback));
14
14
  resInterceptors === null || resInterceptors === void 0 ? void 0 : resInterceptors.forEach(({ callback, errorCallback }) => client.interceptors.response.use(callback, errorCallback));
@@ -27,4 +27,3 @@ function getAxiosClient(timeout = constants_1.DEFAULT_TIMEOUT, retries = 0, axio
27
27
  });
28
28
  return client;
29
29
  }
30
- exports.getAxiosClient = getAxiosClient;
@@ -1,8 +1,8 @@
1
1
  import * as grpc from '@grpc/grpc-js';
2
2
  import _ from 'lodash';
3
- import { ActionEndpoint, ExtendedActionEndpoint, ExtendedGrpcActionEndpoint, ExtendedRestActionEndpoint, Headers } from '../models/common';
4
- import { Dict, GatewayContext } from '../models/context';
5
- import { AppErrorConstructor } from '../models/error';
3
+ import { ActionEndpoint, ExtendedActionEndpoint, ExtendedGrpcActionEndpoint, ExtendedRestActionEndpoint, Headers } from '../models/common.js';
4
+ import { Dict, GatewayContext } from '../models/context.js';
5
+ import { AppErrorConstructor } from '../models/error.js';
6
6
  export declare function isExtendedActionEndpoint(endpoint: ActionEndpoint): endpoint is ExtendedActionEndpoint;
7
7
  export declare function isExtendedGrpcActionEndpoint(endpoint: ActionEndpoint): endpoint is ExtendedGrpcActionEndpoint;
8
8
  export declare function isExtendedRestActionEndpoint(endpoint: ActionEndpoint): endpoint is ExtendedRestActionEndpoint;
@@ -3,40 +3,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.handleError = exports.getHeadersFromMetadata = exports.sanitizeDebugHeaders = exports.getKeys = exports.isExtendedRestActionEndpoint = exports.isExtendedGrpcActionEndpoint = exports.isExtendedActionEndpoint = void 0;
6
+ exports.isExtendedActionEndpoint = isExtendedActionEndpoint;
7
+ exports.isExtendedGrpcActionEndpoint = isExtendedGrpcActionEndpoint;
8
+ exports.isExtendedRestActionEndpoint = isExtendedRestActionEndpoint;
9
+ exports.getKeys = getKeys;
10
+ exports.sanitizeDebugHeaders = sanitizeDebugHeaders;
11
+ exports.getHeadersFromMetadata = getHeadersFromMetadata;
12
+ exports.handleError = handleError;
7
13
  const lodash_1 = __importDefault(require("lodash"));
8
14
  function isExtendedActionEndpoint(endpoint) {
9
15
  return (endpoint === null || endpoint === void 0 ? void 0 : endpoint.path) !== undefined;
10
16
  }
11
- exports.isExtendedActionEndpoint = isExtendedActionEndpoint;
12
17
  function isExtendedGrpcActionEndpoint(endpoint) {
13
18
  return ((endpoint === null || endpoint === void 0 ? void 0 : endpoint.grpcOptions) !== undefined ||
14
19
  (endpoint === null || endpoint === void 0 ? void 0 : endpoint.insecure) !== undefined ||
15
20
  (endpoint === null || endpoint === void 0 ? void 0 : endpoint.secureWithoutRootCert) !== undefined);
16
21
  }
17
- exports.isExtendedGrpcActionEndpoint = isExtendedGrpcActionEndpoint;
18
22
  function isExtendedRestActionEndpoint(endpoint) {
19
23
  return (endpoint === null || endpoint === void 0 ? void 0 : endpoint.axiosConfig) !== undefined;
20
24
  }
21
- exports.isExtendedRestActionEndpoint = isExtendedRestActionEndpoint;
22
25
  function getKeys(obj) {
23
26
  return Object.keys(obj);
24
27
  }
25
- exports.getKeys = getKeys;
26
28
  /**
27
29
  * This function should only use to sanitize debugHeaders that are creating in our code
28
30
  */
29
31
  function sanitizeDebugHeaders(debugHeaders) {
30
32
  return lodash_1.default.omit(debugHeaders, ['x-api-request-body']);
31
33
  }
32
- exports.sanitizeDebugHeaders = sanitizeDebugHeaders;
33
34
  function getHeadersFromMetadata(metadata, prefix = '') {
34
35
  return Object.entries(metadata).reduce((headers, [key, values]) => {
35
36
  headers[`${prefix}${key}`] = values.filter((value) => typeof value === 'string').join(' ');
36
37
  return headers;
37
38
  }, {});
38
39
  }
39
- exports.getHeadersFromMetadata = getHeadersFromMetadata;
40
40
  function handleError(ErrorConstructor, error, ctx, message, extra) {
41
41
  if (error instanceof Error) {
42
42
  ctx.logError(message, ErrorConstructor.wrap(error), extra);
@@ -48,4 +48,3 @@ function handleError(ErrorConstructor, error, ctx, message, extra) {
48
48
  ctx.logError(message, error, extra);
49
49
  }
50
50
  }
51
- exports.handleError = handleError;
@@ -1,4 +1,4 @@
1
- import { GatewayContext } from '../models/context';
2
- import { ApiActionConfig, ApiByScope, ContextApiWithRoot, GatewayRequest, GatewayResponse, SchemasByScope } from './../models/common';
1
+ import { ApiActionConfig, ApiByScope, ContextApiWithRoot, GatewayRequest, GatewayResponse, SchemasByScope } from '../models/common.js';
2
+ import { GatewayContext } from '../models/context.js';
3
3
  export type RequestContext<Context extends GatewayContext> = Omit<ApiActionConfig<Context, never>, 'args'>;
4
4
  export declare function generateContextApi<TFullSchema extends SchemasByScope, Context extends GatewayContext, Req extends GatewayRequest<Context>, Res extends GatewayResponse>(baseApi: ApiByScope<TFullSchema, Context, Req, Res>, requestContext: RequestContext<Context>): ContextApiWithRoot<TFullSchema>;