@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,9 +3,9 @@ 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.generateContextApi = void 0;
6
+ exports.generateContextApi = generateContextApi;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const common_1 = require("./common");
8
+ const common_js_1 = require("./common.js");
9
9
  function createContextApiForScope(api, requestContext) {
10
10
  return lodash_1.default.reduce(api, (acc, service, serviceName) => {
11
11
  acc[serviceName] = lodash_1.default.reduce(service, (accService, action, actionName) => {
@@ -26,12 +26,12 @@ function generateContextApi(baseApi, requestContext) {
26
26
  const api = contextApi;
27
27
  const rootScope = contextApi.root;
28
28
  if (rootScope) {
29
- for (const rootService of (0, common_1.getKeys)(rootScope)) {
29
+ for (const rootService of (0, common_js_1.getKeys)(rootScope)) {
30
30
  const curScope = (_a = api[rootService]) !== null && _a !== void 0 ? _a : {};
31
- for (const rootAction of (0, common_1.getKeys)(rootScope[rootService])) {
31
+ for (const rootAction of (0, common_js_1.getKeys)(rootScope[rootService])) {
32
32
  const rootServiceFunc = rootScope[rootService][rootAction];
33
33
  if (curScope[rootAction]) {
34
- for (const curScopeAction of (0, common_1.getKeys)(curScope[rootAction])) {
34
+ for (const curScopeAction of (0, common_js_1.getKeys)(curScope[rootAction])) {
35
35
  rootServiceFunc[curScopeAction] = curScope[rootAction][curScopeAction];
36
36
  }
37
37
  }
@@ -42,4 +42,3 @@ function generateContextApi(baseApi, requestContext) {
42
42
  }
43
43
  return api;
44
44
  }
45
- exports.generateContextApi = generateContextApi;
@@ -15,21 +15,32 @@ 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
- };
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
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getReflectionRoot = exports.getCachedReflectionRoot = void 0;
39
+ exports.getCachedReflectionRoot = getCachedReflectionRoot;
40
+ exports.getReflectionRoot = getReflectionRoot;
30
41
  const lodash_1 = __importDefault(require("lodash"));
31
42
  const protobufjs = __importStar(require("protobufjs"));
32
- const proto_path_resolver_1 = require("./proto-path-resolver");
43
+ const proto_path_resolver_js_1 = require("./proto-path-resolver.js");
33
44
  const reflectionClientsMap = {};
34
45
  function getCachedClient(actionEndpoint, credentials, grpcOptions, descriptorExtensionProto) {
35
46
  const cacheKey = [actionEndpoint, JSON.stringify([grpcOptions, descriptorExtensionProto])];
@@ -43,7 +54,7 @@ function getCachedClient(actionEndpoint, credentials, grpcOptions, descriptorExt
43
54
  descriptorRoot.loadSync(descriptorExtensionProto);
44
55
  }
45
56
  else {
46
- (0, proto_path_resolver_1.patchProtoPathResolver)(descriptorRoot, descriptorExtensionProto.includeProtoRoots);
57
+ (0, proto_path_resolver_js_1.patchProtoPathResolver)(descriptorRoot, descriptorExtensionProto.includeProtoRoots);
47
58
  descriptorRoot.loadSync(descriptorExtensionProto.filenames);
48
59
  }
49
60
  }
@@ -77,7 +88,6 @@ async function getCachedReflectionRoot(actionEndpoint, protoKey, credentials, gr
77
88
  const loadedRoot = await cachedRootPromise;
78
89
  return loadedRoot;
79
90
  }
80
- exports.getCachedReflectionRoot = getCachedReflectionRoot;
81
91
  /**
82
92
  * @param actionEndpoint
83
93
  * @param protoKey
@@ -96,4 +106,3 @@ async function getReflectionRoot(actionEndpoint, protoKey, credentials, grpcOpti
96
106
  }
97
107
  return loadedRoot;
98
108
  }
99
- exports.getReflectionRoot = getReflectionRoot;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* eslint-disable camelcase */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isRecreateServiceError = exports.isRetryableError = exports.decodeAnyMessageRecursively = void 0;
5
- const constants_1 = require("../constants");
4
+ exports.decodeAnyMessageRecursively = decodeAnyMessageRecursively;
5
+ exports.isRetryableError = isRetryableError;
6
+ exports.isRecreateServiceError = isRecreateServiceError;
7
+ const constants_js_1 = require("../constants.js");
6
8
  function isEncodedMessage(message) {
7
9
  return Boolean(message.type_url && message.value);
8
10
  }
@@ -25,21 +27,18 @@ function decodeAnyMessageRecursively(root, message, decodeAnyMessageProtoLoaderO
25
27
  }
26
28
  const typeName = message.type_url.substring(lastSlashIndex + 1);
27
29
  const type = root.lookupType(typeName);
28
- const decodedMessage = type.toObject(type.decode(message.value), Object.assign(Object.assign({}, constants_1.DEFAULT_PROTO_LOADER_OPTIONS), decodeAnyMessageProtoLoaderOptions));
30
+ const decodedMessage = type.toObject(type.decode(message.value), Object.assign(Object.assign({}, constants_js_1.DEFAULT_PROTO_LOADER_OPTIONS), decodeAnyMessageProtoLoaderOptions));
29
31
  return decodeAnyMessageRecursively(root, decodedMessage, decodeAnyMessageProtoLoaderOptions);
30
32
  }
31
- exports.decodeAnyMessageRecursively = decodeAnyMessageRecursively;
32
33
  function isRetryableError(error) {
33
34
  if (!error) {
34
35
  return false;
35
36
  }
36
- return constants_1.RETRYABLE_STATUS_CODES.includes(error.code);
37
+ return constants_js_1.RETRYABLE_STATUS_CODES.includes(error.code);
37
38
  }
38
- exports.isRetryableError = isRetryableError;
39
39
  function isRecreateServiceError(error) {
40
40
  if (!error) {
41
41
  return false;
42
42
  }
43
- return constants_1.RECREATE_SERVICE_CODES.includes(error.code);
43
+ return constants_js_1.RECREATE_SERVICE_CODES.includes(error.code);
44
44
  }
45
- exports.isRecreateServiceError = isRecreateServiceError;
@@ -0,0 +1,2 @@
1
+ import { overrideEndpoints } from './overrideEndpoints.js';
2
+ export default overrideEndpoints;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const overrideEndpoints_js_1 = require("./overrideEndpoints.js");
4
+ exports.default = overrideEndpoints_js_1.overrideEndpoints;
@@ -1,4 +1,4 @@
1
- import { ActionEndpoint, SchemasByScope } from '../..';
1
+ import { ActionEndpoint, SchemasByScope } from '../../index.js';
2
2
  export interface OverrideParams {
3
3
  [serviceKeyScope: string]: {
4
4
  [endpointName: string]: ActionEndpoint;
@@ -3,7 +3,7 @@ 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.overrideEndpoints = void 0;
6
+ exports.overrideEndpoints = overrideEndpoints;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  function parseOverrideEndpointsParams(params) {
9
9
  const parsedParams = [];
@@ -84,7 +84,6 @@ function overrideEndpoints(originalSchema, overrideParams, installation, env) {
84
84
  });
85
85
  return schema;
86
86
  }
87
- exports.overrideEndpoints = overrideEndpoints;
88
87
  function isExtendedEndpointConfig(config) {
89
88
  return typeof config === 'object';
90
89
  }
@@ -1,8 +1,8 @@
1
1
  import * as grpc from '@grpc/grpc-js';
2
2
  import * as protobufjs from 'protobufjs';
3
- import { Lang } from '../constants';
4
- import { GatewayError } from '../models/common';
5
- import { AppErrorConstructor } from '../models/error';
3
+ import { Lang } from '../constants.js';
4
+ import { GatewayError } from '../models/common.js';
5
+ import { AppErrorConstructor } from '../models/error.js';
6
6
  export declare function parseMixedError(e: Error & {
7
7
  code?: string;
8
8
  }): {
@@ -11,7 +11,7 @@ export declare function parseMixedError(e: Error & {
11
11
  code: string;
12
12
  debug: {
13
13
  originalError: Error & {
14
- code?: string | undefined;
14
+ code?: string;
15
15
  };
16
16
  stack: string | undefined;
17
17
  };
@@ -3,10 +3,15 @@ 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.grpcErrorFactory = exports.isGrpcError = exports.GrpcError = exports.parseGrpcError = exports.parseRestError = exports.parseMixedError = void 0;
6
+ exports.GrpcError = void 0;
7
+ exports.parseMixedError = parseMixedError;
8
+ exports.parseRestError = parseRestError;
9
+ exports.parseGrpcError = parseGrpcError;
10
+ exports.isGrpcError = isGrpcError;
11
+ exports.grpcErrorFactory = grpcErrorFactory;
7
12
  const lodash_1 = __importDefault(require("lodash"));
8
- const constants_1 = require("../constants");
9
- const grpc_1 = require("./grpc");
13
+ const constants_js_1 = require("../constants.js");
14
+ const grpc_js_1 = require("./grpc.js");
10
15
  const DEFAULT_GATEWAY_CODE = 'GATEWAY_REQUEST_ERROR';
11
16
  const DEFAULT_GATEWAY_MESSAGE = 'Gateway request error';
12
17
  function parseMixedError(e) {
@@ -20,7 +25,6 @@ function parseMixedError(e) {
20
25
  },
21
26
  };
22
27
  }
23
- exports.parseMixedError = parseMixedError;
24
28
  function getErrorTitle(error) {
25
29
  const prop = lodash_1.default.propertyOf(error);
26
30
  const details = prop('details[0]');
@@ -106,20 +110,20 @@ function parseRestError(error, lang) {
106
110
  title = errorTitle ? errorTitle : statusTitle;
107
111
  description = getErrorMessage(responseData);
108
112
  if (status === 403) {
109
- title = lang === constants_1.Lang.Ru ? 'Доступ запрещен' : 'Access denied';
113
+ title = lang === constants_js_1.Lang.Ru ? 'Доступ запрещен' : 'Access denied';
110
114
  }
111
115
  }
112
116
  else {
113
117
  code = prop('code');
114
- title = lang === constants_1.Lang.Ru ? 'Ошибка' : 'Error';
118
+ title = lang === constants_js_1.Lang.Ru ? 'Ошибка' : 'Error';
115
119
  if (code === 'ECONNABORTED' || code === 'ETIMEDOUT') {
116
120
  status = 504;
117
- description = lang === constants_1.Lang.Ru ? 'Превышено время ожидания ответа' : 'Timeout exceeded';
121
+ description = lang === constants_js_1.Lang.Ru ? 'Превышено время ожидания ответа' : 'Timeout exceeded';
118
122
  }
119
123
  else {
120
124
  status = 500;
121
125
  description =
122
- lang === constants_1.Lang.Ru
126
+ lang === constants_js_1.Lang.Ru
123
127
  ? 'Произошла непредвиденная ошибка. Попробуйте обновить страницу через некоторое время.'
124
128
  : 'An unexpected error has occurred. Try to refresh the page in a few moments.';
125
129
  }
@@ -134,22 +138,21 @@ function parseRestError(error, lang) {
134
138
  debug,
135
139
  };
136
140
  }
137
- exports.parseRestError = parseRestError;
138
141
  function decodeGrpcStatusMessage(metadata, packageRoot, decodeAnyMessageProtoLoaderOptions) {
139
142
  const statusMessageBin = metadata.get('grpc-status-details-bin')[0];
140
143
  if (!statusMessageBin) {
141
144
  return undefined;
142
145
  }
143
- return (0, grpc_1.decodeAnyMessageRecursively)(packageRoot, {
146
+ return (0, grpc_js_1.decodeAnyMessageRecursively)(packageRoot, {
144
147
  type_url: 'type.googleapis.com/google.rpc.Status',
145
148
  value: statusMessageBin,
146
149
  }, decodeAnyMessageProtoLoaderOptions);
147
150
  }
148
- function parseGrpcError(error, packageRoot, lang = constants_1.Lang.Ru, decodeAnyMessageProtoLoaderOptions) {
149
- let title = lang === constants_1.Lang.Ru ? 'Ошибка' : 'Error';
151
+ function parseGrpcError(error, packageRoot, lang = constants_js_1.Lang.Ru, decodeAnyMessageProtoLoaderOptions) {
152
+ let title = lang === constants_js_1.Lang.Ru ? 'Ошибка' : 'Error';
150
153
  if (error.code === 7) {
151
154
  // Always redefine title for Access denied errors
152
- title = lang === constants_1.Lang.Ru ? 'Доступ запрещен' : 'Access denied';
155
+ title = lang === constants_js_1.Lang.Ru ? 'Доступ запрещен' : 'Access denied';
153
156
  }
154
157
  let code = error.code;
155
158
  let description = error.details;
@@ -167,12 +170,12 @@ function parseGrpcError(error, packageRoot, lang = constants_1.Lang.Ru, decodeAn
167
170
  }
168
171
  // Always redefine description for Timeout exceeded errors
169
172
  if (error.code === 4) {
170
- description = lang === constants_1.Lang.Ru ? 'Превышено время ожидания ответа' : 'Timeout exceeded';
173
+ description = lang === constants_js_1.Lang.Ru ? 'Превышено время ожидания ответа' : 'Timeout exceeded';
171
174
  }
172
175
  // Use default description if description is undefined, but not for Access denied errors
173
176
  if (!description) {
174
177
  description =
175
- lang === constants_1.Lang.Ru
178
+ lang === constants_js_1.Lang.Ru
176
179
  ? 'Произошла непредвиденная ошибка. Попробуйте обновить страницу через некоторое время.'
177
180
  : 'An unexpected error has occurred. Try to refresh the page in a few moments.';
178
181
  }
@@ -185,7 +188,6 @@ function parseGrpcError(error, packageRoot, lang = constants_1.Lang.Ru, decodeAn
185
188
  description, grpcCode: code }, (typeof details === 'object' && !Array.isArray(details) ? details : { details })),
186
189
  };
187
190
  }
188
- exports.parseGrpcError = parseGrpcError;
189
191
  class GrpcError extends Error {
190
192
  constructor(message, parsedError, rawError) {
191
193
  super(message);
@@ -210,7 +212,6 @@ exports.GrpcError = GrpcError;
210
212
  function isGrpcError(error) {
211
213
  return error.getGatewayError !== undefined;
212
214
  }
213
- exports.isGrpcError = isGrpcError;
214
215
  function grpcErrorFactory(error) {
215
216
  return new GrpcError(error.message, {
216
217
  status: 500,
@@ -219,4 +220,3 @@ function grpcErrorFactory(error) {
219
220
  details: {},
220
221
  });
221
222
  }
222
- exports.grpcErrorFactory = grpcErrorFactory;
@@ -15,32 +15,39 @@ 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
- exports.patchProtoPathResolver = void 0;
30
- const fs_1 = __importDefault(require("fs"));
31
- const path_1 = __importDefault(require("path"));
36
+ exports.patchProtoPathResolver = patchProtoPathResolver;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
32
39
  const protobufjs = __importStar(require("protobufjs"));
33
40
  function patchProtoPathResolver(root, includeDirs) {
34
41
  const originalResolvePath = root.resolvePath;
35
42
  root.resolvePath = function (origin, target) {
36
- if (target in protobufjs.common || path_1.default.isAbsolute(target)) {
43
+ if (target in protobufjs.common || path.isAbsolute(target)) {
37
44
  return target;
38
45
  }
39
46
  for (let i = 0; i < includeDirs.length; i++) {
40
47
  const directory = includeDirs[i];
41
- const fullPath = path_1.default.join(directory, target);
48
+ const fullPath = path.join(directory, target);
42
49
  try {
43
- fs_1.default.accessSync(fullPath, fs_1.default.constants.R_OK);
50
+ fs.accessSync(fullPath, fs.constants.R_OK);
44
51
  return fullPath;
45
52
  }
46
53
  catch (err) {
@@ -50,4 +57,3 @@ function patchProtoPathResolver(root, includeDirs) {
50
57
  return originalResolvePath(origin, target);
51
58
  };
52
59
  }
53
- exports.patchProtoPathResolver = patchProtoPathResolver;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IncomingHttpHeaders } from 'http';
3
- import { GatewayContext } from '../models/context';
2
+ import { GatewayContext } from '../models/context.js';
4
3
  export declare function redactSensitiveHeaders(ctx: GatewayContext, headers: IncomingHttpHeaders): IncomingHttpHeaders;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.redactSensitiveHeaders = void 0;
3
+ exports.redactSensitiveHeaders = redactSensitiveHeaders;
4
4
  function redactSensitiveHeaders(ctx, headers) {
5
5
  var _a, _b;
6
6
  if ((_a = ctx.utils) === null || _a === void 0 ? void 0 : _a.redactSensitiveHeaders) {
@@ -13,4 +13,3 @@ function redactSensitiveHeaders(ctx, headers) {
13
13
  return headers;
14
14
  }
15
15
  }
16
- exports.redactSensitiveHeaders = redactSensitiveHeaders;
@@ -0,0 +1 @@
1
+ export declare const sourceDir: string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
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 () {
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.sourceDir = void 0;
37
+ // this one has a -cjs.cts suffix, so it will override the
38
+ // module at src/utils/source-dir.ts in the CommonJS build,
39
+ // and be excluded from the esm build.
40
+ const path = __importStar(require("path"));
41
+ exports.sourceDir = path.resolve(__dirname, '..');
@@ -1,2 +1,2 @@
1
- import { ContextApiWithRoot, SchemasByScope } from './../models/common';
1
+ import { ContextApiWithRoot, SchemasByScope } from '../models/common.js';
2
2
  export declare function getTypedApiFactory<TSchema extends SchemasByScope>(): (api: unknown) => ContextApiWithRoot<TSchema>;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTypedApiFactory = void 0;
3
+ exports.getTypedApiFactory = getTypedApiFactory;
4
4
  function getTypedApiFactory() {
5
5
  return (api) => api;
6
6
  }
7
- exports.getTypedApiFactory = getTypedApiFactory;
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPathArgsProxy = exports.getPathParam = exports.encodePathParams = exports.validateArgs = void 0;
7
- const ajv_1 = __importDefault(require("ajv"));
3
+ exports.validateArgs = validateArgs;
4
+ exports.encodePathParams = encodePathParams;
5
+ exports.getPathParam = getPathParam;
6
+ exports.getPathArgsProxy = getPathArgsProxy;
7
+ const ajv_1 = require("ajv");
8
8
  function validateArgs(args, schema) {
9
- const ajv = new ajv_1.default();
9
+ const ajv = new ajv_1.Ajv();
10
10
  const validate = ajv.compile(schema);
11
11
  return validate(args) ? false : ajv.errorsText(validate.errors);
12
12
  }
13
- exports.validateArgs = validateArgs;
14
13
  function encodePathParams(params) {
15
14
  const encodedParams = {};
16
15
  Object.keys(params).forEach((key) => {
@@ -27,11 +26,9 @@ function encodePathParams(params) {
27
26
  });
28
27
  return encodedParams;
29
28
  }
30
- exports.encodePathParams = encodePathParams;
31
29
  function getPathParam(value) {
32
30
  return /^((?!(\.\.|\?|#|\\|\/)).)*$/i.test(value) ? value : 'GATEWAY_INVALID_PARAM_VALUE';
33
31
  }
34
- exports.getPathParam = getPathParam;
35
32
  function getPathArgsProxy(args, encodePathArgs) {
36
33
  const encodePathArgsVal = encodePathArgs !== null && encodePathArgs !== void 0 ? encodePathArgs : true;
37
34
  if (!args) {
@@ -54,4 +51,3 @@ function getPathArgsProxy(args, encodePathArgs) {
54
51
  },
55
52
  });
56
53
  }
57
- exports.getPathArgsProxy = getPathArgsProxy;
@@ -0,0 +1,24 @@
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import * as protobufjs from 'protobufjs';
3
+ import type * as descriptor from 'protobufjs/ext/descriptor';
4
+ import { ApiActionConfig, ApiServiceGrpcActionConfig, EndpointsConfig, GatewayApiOptions } from '../models/common.js';
5
+ import { GatewayContext } from '../models/context.js';
6
+ import { AppErrorConstructor } from '../models/error.js';
7
+ declare module 'protobufjs' {
8
+ interface Root {
9
+ toDescriptor(protoVersion: string): protobufjs.Message<descriptor.IFileDescriptorSet> & descriptor.IFileDescriptorSet;
10
+ }
11
+ }
12
+ interface CredentialsMap {
13
+ insecure: grpc.ChannelCredentials;
14
+ secure: grpc.ChannelCredentials;
15
+ secureWithoutRootCert: grpc.ChannelCredentials;
16
+ }
17
+ export interface GrpcContext {
18
+ root: protobufjs.Root;
19
+ credentials: CredentialsMap;
20
+ }
21
+ export declare function createRoot(includeGrpcPaths?: string[]): protobufjs.Root;
22
+ export declare function getCredentialsMap(caCertificatePath?: string | null): CredentialsMap;
23
+ export declare function createGrpcAction<Context extends GatewayContext>({ root, credentials }: GrpcContext, endpoints: EndpointsConfig | undefined, config: ApiServiceGrpcActionConfig<Context, any, any>, serviceKey: string, actionName: string, options: GatewayApiOptions<Context>, ErrorConstructor: AppErrorConstructor): (actionConfig: ApiActionConfig<Context, any, any>) => Promise<import("../models/common.js").GatewayActionClientStreamResponse<any> | import("../models/common.js").GatewayActionServerStreamResponse<any> | import("../models/common.js").GatewayActionDuplexStreamResponse<any> | import("../models/common.js").GatewayActionUnaryResponse<any>>;
24
+ export {};