@gravity-ui/gateway 4.1.2-alpha.0 → 4.2.1

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