@gravity-ui/gateway 4.7.0 → 4.7.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.
- package/README.md +128 -3
- package/{build → dist/commonjs}/components/grpc.d.ts +5 -5
- package/{build → dist/commonjs}/components/grpc.js +94 -84
- package/{build → dist/commonjs}/components/mixed.d.ts +4 -4
- package/{build → dist/commonjs}/components/mixed.js +11 -12
- package/{build → dist/commonjs}/components/rest.d.ts +5 -5
- package/{build → dist/commonjs}/components/rest.js +33 -33
- package/{build → dist/commonjs}/constants.d.ts +2 -2
- package/{build → dist/commonjs}/constants.js +29 -19
- package/{build → dist/commonjs}/index.d.ts +9 -8
- package/{build → dist/commonjs}/index.js +35 -46
- package/{build → dist/commonjs}/models/common.d.ts +12 -7
- package/{build → dist/commonjs}/models/context.d.ts +0 -1
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/utils/axios.d.ts +4 -0
- package/{build → dist/commonjs}/utils/axios.js +3 -4
- package/{build → dist/commonjs}/utils/common.d.ts +4 -4
- package/{build → dist/commonjs}/utils/common.js +8 -8
- package/{build → dist/commonjs}/utils/create-context-api.d.ts +2 -2
- package/{build → dist/commonjs}/utils/create-context-api.js +5 -6
- package/{build → dist/commonjs}/utils/grpc-reflection.js +15 -35
- package/{build → dist/commonjs}/utils/grpc.d.ts +1 -1
- package/{build → dist/commonjs}/utils/grpc.js +10 -11
- package/dist/commonjs/utils/overrideEndpoints/index.d.ts +2 -0
- package/dist/commonjs/utils/overrideEndpoints/index.js +4 -0
- package/{build → dist/commonjs}/utils/overrideEndpoints/overrideEndpoints.d.ts +1 -1
- package/{build → dist/commonjs}/utils/overrideEndpoints/overrideEndpoints.js +1 -2
- package/dist/commonjs/utils/package-root.d.ts +1 -0
- package/dist/commonjs/utils/package-root.js +44 -0
- package/{build → dist/commonjs}/utils/parse-error.d.ts +5 -5
- package/{build → dist/commonjs}/utils/parse-error.js +19 -19
- package/{build → dist/commonjs}/utils/proto-path-resolver.d.ts +1 -1
- package/{build → dist/commonjs}/utils/proto-path-resolver.js +24 -15
- package/{build → dist/commonjs}/utils/redact-sensitive-headers.d.ts +1 -2
- package/{build → dist/commonjs}/utils/redact-sensitive-headers.js +1 -2
- package/dist/commonjs/utils/source-dir.d.ts +1 -0
- package/dist/commonjs/utils/source-dir.js +41 -0
- package/{build → dist/commonjs}/utils/typed-api.d.ts +1 -1
- package/{build → dist/commonjs}/utils/typed-api.js +1 -2
- package/{build → dist/commonjs}/utils/validate.js +6 -10
- package/dist/esm/components/grpc.d.ts +24 -0
- package/dist/esm/components/grpc.js +691 -0
- package/dist/esm/components/mixed.d.ts +11 -0
- package/dist/esm/components/mixed.js +62 -0
- package/dist/esm/components/rest.d.ts +8 -0
- package/dist/esm/components/rest.js +357 -0
- package/dist/esm/constants.d.ts +53 -0
- package/dist/esm/constants.js +82 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +274 -0
- package/dist/esm/models/common.d.ts +289 -0
- package/dist/esm/models/common.js +5 -0
- package/dist/esm/models/context.d.ts +22 -0
- package/dist/esm/models/context.js +1 -0
- package/dist/esm/models/error.d.ts +12 -0
- package/dist/esm/models/error.js +1 -0
- package/dist/esm/package.json +3 -0
- package/{build → dist/esm}/utils/axios.d.ts +1 -1
- package/dist/esm/utils/axios.js +24 -0
- package/dist/esm/utils/common.d.ts +16 -0
- package/dist/esm/utils/common.js +48 -0
- package/dist/esm/utils/create-context-api.d.ts +4 -0
- package/dist/esm/utils/create-context-api.js +38 -0
- package/dist/esm/utils/grpc-reflection.d.ts +28 -0
- package/dist/esm/utils/grpc-reflection.js +72 -0
- package/dist/esm/utils/grpc.d.ts +15 -0
- package/dist/esm/utils/grpc.js +72 -0
- package/dist/esm/utils/overrideEndpoints/index.d.ts +2 -0
- package/dist/esm/utils/overrideEndpoints/index.js +2 -0
- package/dist/esm/utils/overrideEndpoints/overrideEndpoints.d.ts +17 -0
- package/dist/esm/utils/overrideEndpoints/overrideEndpoints.js +96 -0
- package/dist/esm/utils/package-root.d.ts +1 -0
- package/dist/esm/utils/package-root.js +8 -0
- package/dist/esm/utils/parse-error.d.ts +30 -0
- package/dist/esm/utils/parse-error.js +214 -0
- package/dist/esm/utils/proto-path-resolver.d.ts +2 -0
- package/dist/esm/utils/proto-path-resolver.js +23 -0
- package/dist/esm/utils/redact-sensitive-headers.d.ts +3 -0
- package/dist/esm/utils/redact-sensitive-headers.js +12 -0
- package/dist/esm/utils/source-dir.d.ts +1 -0
- package/dist/esm/utils/source-dir.js +4 -0
- package/dist/esm/utils/typed-api.d.ts +2 -0
- package/dist/esm/utils/typed-api.js +3 -0
- package/dist/esm/utils/validate.d.ts +4 -0
- package/dist/esm/utils/validate.js +47 -0
- package/package.json +41 -16
- package/build/utils/overrideEndpoints/index.d.ts +0 -2
- package/build/utils/overrideEndpoints/index.js +0 -4
- /package/bin/{patch.js → patch.cjs} +0 -0
- /package/{build → dist/commonjs}/models/common.js +0 -0
- /package/{build → dist/commonjs}/models/context.js +0 -0
- /package/{build → dist/commonjs}/models/error.d.ts +0 -0
- /package/{build → dist/commonjs}/models/error.js +0 -0
- /package/{build → dist/commonjs}/utils/grpc-reflection.d.ts +0 -0
- /package/{build → dist/commonjs}/utils/validate.d.ts +0 -0
|
@@ -16,49 +16,61 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
38
|
};
|
|
29
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.
|
|
40
|
+
exports.createRoot = createRoot;
|
|
41
|
+
exports.getCredentialsMap = getCredentialsMap;
|
|
42
|
+
exports.createGrpcAction = createGrpcAction;
|
|
31
43
|
const fs_1 = __importDefault(require("fs"));
|
|
32
44
|
const path_1 = __importDefault(require("path"));
|
|
33
45
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
34
46
|
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
35
47
|
const lodash_1 = __importDefault(require("lodash"));
|
|
36
48
|
const object_sizeof_1 = __importDefault(require("object-sizeof"));
|
|
37
|
-
const
|
|
49
|
+
const protobufjs_1 = __importDefault(require("protobufjs"));
|
|
38
50
|
const uuid_1 = require("uuid");
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
51
|
+
const constants_js_1 = require("../constants.js");
|
|
52
|
+
const common_js_1 = require("../models/common.js");
|
|
53
|
+
const common_js_2 = require("../utils/common.js");
|
|
54
|
+
const grpc_reflection_js_1 = require("../utils/grpc-reflection.js");
|
|
55
|
+
const grpc_js_1 = require("../utils/grpc.js");
|
|
56
|
+
const package_root_js_1 = require("../utils/package-root.js");
|
|
57
|
+
const parse_error_js_1 = require("../utils/parse-error.js");
|
|
58
|
+
const proto_path_resolver_js_1 = require("../utils/proto-path-resolver.js");
|
|
59
|
+
const redact_sensitive_headers_js_1 = require("../utils/redact-sensitive-headers.js");
|
|
60
|
+
const validate_js_1 = require("../utils/validate.js");
|
|
61
|
+
const grpcLoaderOptions = Object.assign(Object.assign({}, constants_js_1.DEFAULT_PROTO_LOADER_OPTIONS), { includeDirs: [path_1.default.join(package_root_js_1.packageRoot, 'proto')] });
|
|
49
62
|
function createRoot(includeGrpcPaths) {
|
|
50
|
-
const root = new
|
|
51
|
-
root.loadSync(path_1.default.resolve(
|
|
52
|
-
root.loadSync(path_1.default.resolve(
|
|
53
|
-
root.loadSync(path_1.default.resolve(
|
|
63
|
+
const root = new protobufjs_1.default.Root();
|
|
64
|
+
root.loadSync(path_1.default.resolve(package_root_js_1.packageRoot, 'proto/google/rpc/code.proto'));
|
|
65
|
+
root.loadSync(path_1.default.resolve(package_root_js_1.packageRoot, 'proto/google/rpc/error_details.proto'));
|
|
66
|
+
root.loadSync(path_1.default.resolve(package_root_js_1.packageRoot, 'proto/google/rpc/status.proto'));
|
|
54
67
|
// Load well-known internal protobufjs types
|
|
55
68
|
root.loadSync('google/protobuf/struct.proto');
|
|
56
69
|
root.loadSync('google/protobuf/wrappers.proto');
|
|
57
70
|
grpcLoaderOptions.includeDirs = [...grpcLoaderOptions.includeDirs, ...(includeGrpcPaths !== null && includeGrpcPaths !== void 0 ? includeGrpcPaths : [])];
|
|
58
|
-
(0,
|
|
71
|
+
(0, proto_path_resolver_js_1.patchProtoPathResolver)(root, grpcLoaderOptions.includeDirs);
|
|
59
72
|
return root;
|
|
60
73
|
}
|
|
61
|
-
exports.createRoot = createRoot;
|
|
62
74
|
function getCredentialsMap(caCertificatePath) {
|
|
63
75
|
let certificate;
|
|
64
76
|
if (caCertificatePath && fs_1.default.existsSync(caCertificatePath)) {
|
|
@@ -70,7 +82,6 @@ function getCredentialsMap(caCertificatePath) {
|
|
|
70
82
|
insecure: grpc.ChannelCredentials.createInsecure(),
|
|
71
83
|
};
|
|
72
84
|
}
|
|
73
|
-
exports.getCredentialsMap = getCredentialsMap;
|
|
74
85
|
function decodeResponse(response, packageRoot, ctx, encodedFields = [], ErrorConstructor, decodeAnyMessageProtoLoaderOptions) {
|
|
75
86
|
const systemFields = ['metadata', 'response', 'error.details'];
|
|
76
87
|
[...systemFields, ...encodedFields].forEach((fieldName) => {
|
|
@@ -78,21 +89,21 @@ function decodeResponse(response, packageRoot, ctx, encodedFields = [], ErrorCon
|
|
|
78
89
|
const parsedFieldName = fieldName.replace(/\.\*$/, '');
|
|
79
90
|
const fieldValue = lodash_1.default.get(response, parsedFieldName);
|
|
80
91
|
if (fieldValue) {
|
|
81
|
-
lodash_1.default.set(response, parsedFieldName, (0,
|
|
92
|
+
lodash_1.default.set(response, parsedFieldName, (0, grpc_js_1.decodeAnyMessageRecursively)(packageRoot, fieldValue, decodeAnyMessageProtoLoaderOptions));
|
|
82
93
|
}
|
|
83
94
|
}
|
|
84
95
|
catch (error) {
|
|
85
|
-
(0,
|
|
96
|
+
(0, common_js_2.handleError)(ErrorConstructor, error, ctx, 'Message decoding failed', { fieldName });
|
|
86
97
|
}
|
|
87
98
|
});
|
|
88
99
|
}
|
|
89
100
|
function createMetadata({ options, actionConfig, config, params, serviceName, proxyHeadersCaller, ctx, }) {
|
|
90
101
|
var _a;
|
|
91
102
|
const { headers, requestId, authArgs } = actionConfig;
|
|
92
|
-
const proxyHeaders = [...
|
|
103
|
+
const proxyHeaders = [...constants_js_1.DEFAULT_PROXY_HEADERS];
|
|
93
104
|
let metadata = {
|
|
94
105
|
'x-request-id': requestId,
|
|
95
|
-
'accept-language': headers[
|
|
106
|
+
'accept-language': headers[constants_js_1.DEFAULT_LANG_HEADER] || constants_js_1.Lang.Ru,
|
|
96
107
|
};
|
|
97
108
|
if (typeof options.proxyHeaders === 'function') {
|
|
98
109
|
Object.assign(metadata, proxyHeadersCaller(options.proxyHeaders));
|
|
@@ -138,7 +149,7 @@ function createMetadata({ options, actionConfig, config, params, serviceName, pr
|
|
|
138
149
|
return serviceMetadata;
|
|
139
150
|
}
|
|
140
151
|
function createActionEndpoint(endpointData) {
|
|
141
|
-
return (0,
|
|
152
|
+
return (0, common_js_2.isExtendedActionEndpoint)(endpointData) ? endpointData.path : endpointData;
|
|
142
153
|
}
|
|
143
154
|
const packageObjectsMap = new Map();
|
|
144
155
|
const serviceInstancesMap = {};
|
|
@@ -170,7 +181,7 @@ function clearInstancesCache(service, instancesMap, cachePath, closeTimeout, ctx
|
|
|
170
181
|
function getChannelCredential(config, endpointData, credentials) {
|
|
171
182
|
let endpointInsecure;
|
|
172
183
|
let endpointSecureWithoutRootCert;
|
|
173
|
-
if ((0,
|
|
184
|
+
if ((0, common_js_2.isExtendedGrpcActionEndpoint)(endpointData)) {
|
|
174
185
|
endpointInsecure = endpointData === null || endpointData === void 0 ? void 0 : endpointData.insecure;
|
|
175
186
|
endpointSecureWithoutRootCert = endpointData === null || endpointData === void 0 ? void 0 : endpointData.secureWithoutRootCert;
|
|
176
187
|
}
|
|
@@ -219,7 +230,7 @@ async function refreshCache(actionEndpoint, config, endpointData, grpcOptions, c
|
|
|
219
230
|
}
|
|
220
231
|
}
|
|
221
232
|
function getServiceInstanceReflectCached(config, endpointData, grpcOptions, credentials) {
|
|
222
|
-
if (config.reflection ===
|
|
233
|
+
if (config.reflection === common_js_1.GrpcReflection.OnEveryRequest) {
|
|
223
234
|
return getServiceInstanceReflect(config, endpointData, grpcOptions, credentials);
|
|
224
235
|
}
|
|
225
236
|
const actionEndpoint = createActionEndpoint(endpointData);
|
|
@@ -241,24 +252,24 @@ function getServiceInstanceReflectCached(config, endpointData, grpcOptions, cred
|
|
|
241
252
|
}
|
|
242
253
|
async function getServiceInstanceReflect(config, endpointData, grpcOptions, credentials, isRefreshCache) {
|
|
243
254
|
const actionEndpoint = createActionEndpoint(endpointData);
|
|
244
|
-
const endpointInsecure = (0,
|
|
255
|
+
const endpointInsecure = (0, common_js_2.isExtendedGrpcActionEndpoint)(endpointData)
|
|
245
256
|
? endpointData === null || endpointData === void 0 ? void 0 : endpointData.insecure
|
|
246
257
|
: undefined;
|
|
247
258
|
const isInsecure = config.insecure || endpointInsecure;
|
|
248
259
|
const creds = isInsecure ? credentials.insecure : credentials.secure;
|
|
249
|
-
const endpointGrpcOptions = (0,
|
|
260
|
+
const endpointGrpcOptions = (0, common_js_2.isExtendedGrpcActionEndpoint)(endpointData)
|
|
250
261
|
? endpointData.grpcOptions || {}
|
|
251
262
|
: {};
|
|
252
|
-
const combinedGrpcOptions = Object.assign(Object.assign(Object.assign({},
|
|
263
|
+
const combinedGrpcOptions = Object.assign(Object.assign(Object.assign({}, constants_js_1.DEFAULT_GRPC_OPTIONS), grpcOptions), endpointGrpcOptions);
|
|
253
264
|
let loadedRoot;
|
|
254
|
-
if (config.reflection ===
|
|
255
|
-
loadedRoot = await (0,
|
|
265
|
+
if (config.reflection === common_js_1.GrpcReflection.OnEveryRequest || isRefreshCache) {
|
|
266
|
+
loadedRoot = await (0, grpc_reflection_js_1.getReflectionRoot)(actionEndpoint, config.protoKey, creds, combinedGrpcOptions, isRefreshCache);
|
|
256
267
|
}
|
|
257
268
|
else {
|
|
258
|
-
loadedRoot = await (0,
|
|
269
|
+
loadedRoot = await (0, grpc_reflection_js_1.getCachedReflectionRoot)(actionEndpoint, config.protoKey, creds, combinedGrpcOptions);
|
|
259
270
|
}
|
|
260
271
|
const descriptor = loadedRoot.toDescriptor('proto3');
|
|
261
|
-
const definition = protoLoader.loadFileDescriptorSetFromObject(descriptor,
|
|
272
|
+
const definition = protoLoader.loadFileDescriptorSetFromObject(descriptor, constants_js_1.DEFAULT_PROTO_LOADER_OPTIONS);
|
|
262
273
|
const packageObject = grpc.loadPackageDefinition(definition);
|
|
263
274
|
const Service = lodash_1.default.get(packageObject, config.protoKey);
|
|
264
275
|
const serviceInstance = new Service(actionEndpoint, creds, combinedGrpcOptions);
|
|
@@ -292,10 +303,10 @@ async function getServiceInstance(root, config, endpointData, grpcOptions, crede
|
|
|
292
303
|
const packageObject = loadAndCachePackageObject(root, config.protoPath);
|
|
293
304
|
const Service = lodash_1.default.get(packageObject, config.protoKey);
|
|
294
305
|
const creds = getChannelCredential(config, endpointData, credentials);
|
|
295
|
-
const endpointGrpcOptions = (0,
|
|
306
|
+
const endpointGrpcOptions = (0, common_js_2.isExtendedGrpcActionEndpoint)(endpointData)
|
|
296
307
|
? endpointData.grpcOptions || {}
|
|
297
308
|
: {};
|
|
298
|
-
serviceInstance = new Service(actionEndpoint, creds, Object.assign(Object.assign(Object.assign({},
|
|
309
|
+
serviceInstance = new Service(actionEndpoint, creds, Object.assign(Object.assign(Object.assign({}, constants_js_1.DEFAULT_GRPC_OPTIONS), grpcOptions), endpointGrpcOptions));
|
|
299
310
|
// Save pointer to service in cache
|
|
300
311
|
lodash_1.default.set(serviceInstancesMap, cacheKey, serviceInstance);
|
|
301
312
|
}
|
|
@@ -322,7 +333,7 @@ async function getResponseData({ config, response, ctx, packageRoot, args, Error
|
|
|
322
333
|
ctx.log('Transformed response data');
|
|
323
334
|
}
|
|
324
335
|
catch (error) {
|
|
325
|
-
(0,
|
|
336
|
+
(0, common_js_2.handleError)(ErrorConstructor, error, ctx, 'Transform response data failed');
|
|
326
337
|
}
|
|
327
338
|
}
|
|
328
339
|
return responseData;
|
|
@@ -362,8 +373,8 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
362
373
|
if (endpointData) {
|
|
363
374
|
const actionEndpoint = createActionEndpoint(endpointData);
|
|
364
375
|
if ('reflection' in config &&
|
|
365
|
-
(config.reflection ===
|
|
366
|
-
config.reflection ===
|
|
376
|
+
(config.reflection === common_js_1.GrpcReflection.OnEveryRequest ||
|
|
377
|
+
config.reflection === common_js_1.GrpcReflection.OnFirstRequest)) {
|
|
367
378
|
getService = () => getServiceInstanceReflectCached(config, endpointData, grpcOptions, credentials);
|
|
368
379
|
recreateService = (service, closeTimeout, ctx) => {
|
|
369
380
|
const cachePath = [config.protoKey, actionEndpoint];
|
|
@@ -387,7 +398,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
387
398
|
var _a;
|
|
388
399
|
const { args, requestId, headers, ctx: parentCtx, userId, abortSignal } = actionConfig;
|
|
389
400
|
const { action } = config;
|
|
390
|
-
const lang = headers[
|
|
401
|
+
const lang = headers[constants_js_1.DEFAULT_LANG_HEADER] || constants_js_1.Lang.Ru; // header might be empty string
|
|
391
402
|
const ctx = parentCtx.create(`Gateway ${serviceName} ${actionName} [grpc]`, {
|
|
392
403
|
tags: {
|
|
393
404
|
action: actionName,
|
|
@@ -412,7 +423,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
412
423
|
'x-api-request-protokey': config.protoKey,
|
|
413
424
|
'x-api-request-lang': lang,
|
|
414
425
|
'x-request-id': requestId,
|
|
415
|
-
'x-gateway-version':
|
|
426
|
+
'x-gateway-version': constants_js_1.VERSION,
|
|
416
427
|
};
|
|
417
428
|
const protopath = 'protoPath' in config ? config.protoPath : undefined;
|
|
418
429
|
if (protopath) {
|
|
@@ -421,7 +432,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
421
432
|
let proxyHeadersExtra;
|
|
422
433
|
const proxyHeadersCaller = (proxyHeadersFunc) => {
|
|
423
434
|
if (proxyHeadersExtra === undefined) {
|
|
424
|
-
proxyHeadersExtra = (0,
|
|
435
|
+
proxyHeadersExtra = (0, common_js_2.getProxyHeadersArgs)(serviceName, actionName, config);
|
|
425
436
|
}
|
|
426
437
|
return proxyHeadersFunc(Object.assign({}, headers), 'rest', proxyHeadersExtra);
|
|
427
438
|
};
|
|
@@ -435,10 +446,10 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
435
446
|
}
|
|
436
447
|
}
|
|
437
448
|
}
|
|
438
|
-
ctx.log('Initiating request', { debugHeaders: (0,
|
|
449
|
+
ctx.log('Initiating request', { debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders) });
|
|
439
450
|
const sendStats = (status, data) => {
|
|
440
451
|
if (options === null || options === void 0 ? void 0 : options.sendStats) {
|
|
441
|
-
options.sendStats(Object.assign(Object.assign({}, data), { restStatus: status }), (0,
|
|
452
|
+
options.sendStats(Object.assign(Object.assign({}, data), { restStatus: status }), (0, redact_sensitive_headers_js_1.redactSensitiveHeaders)(parentCtx, headers), parentCtx, { debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders) });
|
|
442
453
|
}
|
|
443
454
|
else {
|
|
444
455
|
ctx.stats(Object.assign(Object.assign({}, requestData), { responseStatus: status }));
|
|
@@ -449,7 +460,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
449
460
|
const restStatus = lodash_1.default.get(grpcError.getGatewayError(), 'status', 500);
|
|
450
461
|
sendStats(restStatus, Object.assign(Object.assign({}, requestData), { responseSize: (_a = grpcError.getRawError()) === null || _a === void 0 ? void 0 : _a.metadata, grpcStatus: grpcError.getGatewayError().code }));
|
|
451
462
|
ctx.logError('Request failed', ErrorConstructor.wrap(grpcError.getAppError(ErrorConstructor)), Object.assign({ serviceName,
|
|
452
|
-
actionName, debugHeaders: (0,
|
|
463
|
+
actionName, debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders) }, grpcError.getGatewayError()));
|
|
453
464
|
ctx.end();
|
|
454
465
|
}
|
|
455
466
|
let params;
|
|
@@ -458,7 +469,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
458
469
|
params = await config.params(args, headers, { ctx });
|
|
459
470
|
}
|
|
460
471
|
catch (error) {
|
|
461
|
-
(0,
|
|
472
|
+
(0, common_js_2.handleError)(ErrorConstructor, error, ctx, 'Getting config params failed');
|
|
462
473
|
}
|
|
463
474
|
}
|
|
464
475
|
let service;
|
|
@@ -466,7 +477,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
466
477
|
service = await getService(args);
|
|
467
478
|
}
|
|
468
479
|
catch (error) {
|
|
469
|
-
(0,
|
|
480
|
+
(0, common_js_2.handleError)(ErrorConstructor, error, ctx, 'getService failed');
|
|
470
481
|
throw error;
|
|
471
482
|
}
|
|
472
483
|
let stopListeningForAbort = null;
|
|
@@ -482,7 +493,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
482
493
|
}
|
|
483
494
|
if (!endpointData) {
|
|
484
495
|
const errorText = `Gateway config error. Endpoint has been not found in service "${serviceKey}"`;
|
|
485
|
-
throw new
|
|
496
|
+
throw new parse_error_js_1.GrpcError(errorText, {
|
|
486
497
|
status: 400,
|
|
487
498
|
code: 'ENDPOINT_NOT_FOUND',
|
|
488
499
|
message: errorText,
|
|
@@ -491,9 +502,9 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
491
502
|
const actionEndpoint = getActionEndpoint(args);
|
|
492
503
|
debugHeaders['x-api-request-endpoint'] = actionEndpoint;
|
|
493
504
|
const validationSchema = config.validationSchema || options.validationSchema;
|
|
494
|
-
const invalidParams = validationSchema ? (0,
|
|
505
|
+
const invalidParams = validationSchema ? (0, validate_js_1.validateArgs)(args, validationSchema) : false;
|
|
495
506
|
if (invalidParams) {
|
|
496
|
-
throw new
|
|
507
|
+
throw new parse_error_js_1.GrpcError('Invalid params', {
|
|
497
508
|
status: 400,
|
|
498
509
|
code: 'INVALID_PARAMS',
|
|
499
510
|
message: 'Validation failed',
|
|
@@ -503,7 +514,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
503
514
|
},
|
|
504
515
|
});
|
|
505
516
|
}
|
|
506
|
-
const timeout = (_c = (_b = (_a = actionConfig === null || actionConfig === void 0 ? void 0 : actionConfig.timeout) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config.timeout) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.timeout) !== null && _c !== void 0 ? _c :
|
|
517
|
+
const timeout = (_c = (_b = (_a = actionConfig === null || actionConfig === void 0 ? void 0 : actionConfig.timeout) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config.timeout) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.timeout) !== null && _c !== void 0 ? _c : constants_js_1.DEFAULT_TIMEOUT;
|
|
507
518
|
const serviceOptions = {
|
|
508
519
|
deadline: Date.now() + timeout,
|
|
509
520
|
};
|
|
@@ -518,7 +529,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
518
529
|
ctx,
|
|
519
530
|
});
|
|
520
531
|
if (!service[action]) {
|
|
521
|
-
reject(new
|
|
532
|
+
reject(new parse_error_js_1.GrpcError('Not found action', {
|
|
522
533
|
status: 400,
|
|
523
534
|
code: 'GRPC_ACTION_NOT_FOUND',
|
|
524
535
|
message: `Not found action ${action} in ${serviceKey}`,
|
|
@@ -528,11 +539,11 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
528
539
|
switch (config.type) {
|
|
529
540
|
case 'serverStream': {
|
|
530
541
|
ctx.log('Creating serverStream request', {
|
|
531
|
-
debugHeaders: (0,
|
|
542
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
532
543
|
});
|
|
533
544
|
const actionCall = service[action].bind(service);
|
|
534
545
|
const stream = actionCall(body, serviceMetadata, serviceOptions);
|
|
535
|
-
stopListeningForAbort = (0,
|
|
546
|
+
stopListeningForAbort = (0, grpc_js_1.listenForAbort)({
|
|
536
547
|
signal: abortSignal,
|
|
537
548
|
config,
|
|
538
549
|
call: stream,
|
|
@@ -540,9 +551,9 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
540
551
|
});
|
|
541
552
|
stream.on('error', (error) => {
|
|
542
553
|
ctx.log('ServerStream error', {
|
|
543
|
-
debugHeaders: (0,
|
|
554
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
544
555
|
});
|
|
545
|
-
processError(new
|
|
556
|
+
processError(new parse_error_js_1.GrpcError('ClientReadableStream error', (0, parse_error_js_1.parseGrpcError)(error, root, lang, config.decodeAnyMessageProtoLoaderOptions), error));
|
|
546
557
|
});
|
|
547
558
|
stream.on('status', (status) => {
|
|
548
559
|
ctx.log('ServerStream status changed', status);
|
|
@@ -550,7 +561,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
550
561
|
stream.on('end', () => {
|
|
551
562
|
stopListeningForAbort === null || stopListeningForAbort === void 0 ? void 0 : stopListeningForAbort();
|
|
552
563
|
ctx.log('ServerStream request completed', {
|
|
553
|
-
debugHeaders: (0,
|
|
564
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
554
565
|
});
|
|
555
566
|
ctx.end();
|
|
556
567
|
});
|
|
@@ -559,10 +570,10 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
559
570
|
}
|
|
560
571
|
case 'clientStream': {
|
|
561
572
|
ctx.log('Creating clientStream request', {
|
|
562
|
-
debugHeaders: (0,
|
|
573
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
563
574
|
});
|
|
564
575
|
if (!actionConfig.callback) {
|
|
565
|
-
throw new
|
|
576
|
+
throw new parse_error_js_1.GrpcError('Invalid action type', {
|
|
566
577
|
status: 400,
|
|
567
578
|
code: 'ACTION_CALLBACK_REQUIRED',
|
|
568
579
|
message: `Client stream actions require callback function`,
|
|
@@ -570,7 +581,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
570
581
|
}
|
|
571
582
|
const actionCall = service[action].bind(service);
|
|
572
583
|
const stream = actionCall(serviceMetadata, serviceOptions, actionConfig.callback);
|
|
573
|
-
stopListeningForAbort = (0,
|
|
584
|
+
stopListeningForAbort = (0, grpc_js_1.listenForAbort)({
|
|
574
585
|
signal: abortSignal,
|
|
575
586
|
config,
|
|
576
587
|
call: stream,
|
|
@@ -584,11 +595,11 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
584
595
|
}
|
|
585
596
|
case 'bidi': {
|
|
586
597
|
ctx.log('Creating serverStream request', {
|
|
587
|
-
debugHeaders: (0,
|
|
598
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
588
599
|
});
|
|
589
600
|
const actionCall = service[action].bind(service);
|
|
590
601
|
const stream = actionCall(serviceMetadata, serviceOptions);
|
|
591
|
-
stopListeningForAbort = (0,
|
|
602
|
+
stopListeningForAbort = (0, grpc_js_1.listenForAbort)({
|
|
592
603
|
signal: abortSignal,
|
|
593
604
|
config,
|
|
594
605
|
call: stream,
|
|
@@ -596,9 +607,9 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
596
607
|
});
|
|
597
608
|
stream.on('error', (error) => {
|
|
598
609
|
ctx.log('BidiStream error', {
|
|
599
|
-
debugHeaders: (0,
|
|
610
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
600
611
|
});
|
|
601
|
-
processError(new
|
|
612
|
+
processError(new parse_error_js_1.GrpcError('BidiStream error', (0, parse_error_js_1.parseGrpcError)(error, root, lang, config.decodeAnyMessageProtoLoaderOptions), error));
|
|
602
613
|
});
|
|
603
614
|
stream.on('status', (status) => {
|
|
604
615
|
ctx.log('BidiStream status changed', status);
|
|
@@ -606,7 +617,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
606
617
|
stream.on('end', () => {
|
|
607
618
|
stopListeningForAbort === null || stopListeningForAbort === void 0 ? void 0 : stopListeningForAbort();
|
|
608
619
|
ctx.log('BidiStream request completed', {
|
|
609
|
-
debugHeaders: (0,
|
|
620
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
610
621
|
});
|
|
611
622
|
ctx.end();
|
|
612
623
|
});
|
|
@@ -618,7 +629,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
618
629
|
}
|
|
619
630
|
default: {
|
|
620
631
|
ctx.log('Starting unary request', {
|
|
621
|
-
debugHeaders: (0,
|
|
632
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
622
633
|
});
|
|
623
634
|
let retries = (_d = config.retries) !== null && _d !== void 0 ? _d : 0;
|
|
624
635
|
let actionCall = service[action].bind(service);
|
|
@@ -630,26 +641,26 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
630
641
|
requestData.requestTime = endRequestTime - startRequestTime;
|
|
631
642
|
const shouldRecreateService = error &&
|
|
632
643
|
options.grpcRecreateService &&
|
|
633
|
-
(0,
|
|
644
|
+
(0, grpc_js_1.isRecreateServiceError)(error);
|
|
634
645
|
const shouldRetry = error &&
|
|
635
646
|
retries &&
|
|
636
|
-
((_b = (_a = options.grpcRetryCondition) === null || _a === void 0 ? void 0 : _a.call(options, error)) !== null && _b !== void 0 ? _b : (0,
|
|
647
|
+
((_b = (_a = options.grpcRetryCondition) === null || _a === void 0 ? void 0 : _a.call(options, error)) !== null && _b !== void 0 ? _b : (0, grpc_js_1.isRetryableGrpcError)(error));
|
|
637
648
|
if (shouldRecreateService) {
|
|
638
649
|
ctx.log(`Service client for ${config.protoKey} is going to be re-created`);
|
|
639
650
|
recreateService(service, timeout * 1.5, ctx, args);
|
|
640
651
|
}
|
|
641
652
|
if (shouldRetry) {
|
|
642
|
-
(0,
|
|
653
|
+
(0, common_js_2.handleError)(ErrorConstructor, error, ctx, `Request failed, retrying ${retries--} more times`, {
|
|
643
654
|
serviceName,
|
|
644
655
|
actionName,
|
|
645
|
-
debugHeaders: (0,
|
|
656
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
646
657
|
});
|
|
647
658
|
// Update pointer to re-created client in local service variable
|
|
648
659
|
try {
|
|
649
660
|
service = await getService(args);
|
|
650
661
|
}
|
|
651
662
|
catch (error) {
|
|
652
|
-
(0,
|
|
663
|
+
(0, common_js_2.handleError)(ErrorConstructor, error, ctx, 'getService failed');
|
|
653
664
|
throw error;
|
|
654
665
|
}
|
|
655
666
|
stopListeningForAbort === null || stopListeningForAbort === void 0 ? void 0 : stopListeningForAbort();
|
|
@@ -660,7 +671,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
660
671
|
}
|
|
661
672
|
if (error) {
|
|
662
673
|
stopListeningForAbort === null || stopListeningForAbort === void 0 ? void 0 : stopListeningForAbort();
|
|
663
|
-
reject(new
|
|
674
|
+
reject(new parse_error_js_1.GrpcError('gRPC request error', (0, parse_error_js_1.parseGrpcError)(error, root, lang, config.decodeAnyMessageProtoLoaderOptions), error));
|
|
664
675
|
return;
|
|
665
676
|
}
|
|
666
677
|
const responseData = await getResponseData({
|
|
@@ -675,7 +686,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
675
686
|
const responseHeaders = {};
|
|
676
687
|
if (config.proxyResponseHeaders) {
|
|
677
688
|
const proxyResponseHeaders = [];
|
|
678
|
-
const headersFromMetadata = (0,
|
|
689
|
+
const headersFromMetadata = (0, common_js_2.getHeadersFromMetadata)(trailingMetadata);
|
|
679
690
|
if (typeof config.proxyResponseHeaders === 'function') {
|
|
680
691
|
Object.assign(responseHeaders, config.proxyResponseHeaders(headersFromMetadata, 'grpc'));
|
|
681
692
|
}
|
|
@@ -689,10 +700,10 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
689
700
|
}
|
|
690
701
|
}
|
|
691
702
|
}
|
|
692
|
-
Object.assign(debugHeaders, (0,
|
|
703
|
+
Object.assign(debugHeaders, (0, common_js_2.getHeadersFromMetadata)(trailingMetadata, 'x-metadata-'));
|
|
693
704
|
sendStats(200, Object.assign(Object.assign({}, requestData), { responseSize: (0, object_sizeof_1.default)(response), grpcStatus: 0 }));
|
|
694
705
|
ctx.log('Request completed', {
|
|
695
|
-
debugHeaders: (0,
|
|
706
|
+
debugHeaders: (0, common_js_2.sanitizeDebugHeaders)(debugHeaders),
|
|
696
707
|
});
|
|
697
708
|
ctx.end();
|
|
698
709
|
stopListeningForAbort === null || stopListeningForAbort === void 0 ? void 0 : stopListeningForAbort();
|
|
@@ -701,7 +712,7 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
701
712
|
call.on('status', (status) => {
|
|
702
713
|
trailingMetadata = status.metadata.toJSON();
|
|
703
714
|
});
|
|
704
|
-
stopListeningForAbort = (0,
|
|
715
|
+
stopListeningForAbort = (0, grpc_js_1.listenForAbort)({
|
|
705
716
|
signal: abortSignal,
|
|
706
717
|
config,
|
|
707
718
|
call,
|
|
@@ -712,11 +723,10 @@ function createGrpcAction({ root, credentials }, endpoints, config, serviceKey,
|
|
|
712
723
|
}
|
|
713
724
|
}
|
|
714
725
|
}).catch((error) => {
|
|
715
|
-
const grpcError = (0,
|
|
726
|
+
const grpcError = (0, parse_error_js_1.isGrpcError)(error) ? error : (0, parse_error_js_1.grpcErrorFactory)(error);
|
|
716
727
|
processError(grpcError);
|
|
717
728
|
stopListeningForAbort === null || stopListeningForAbort === void 0 ? void 0 : stopListeningForAbort();
|
|
718
729
|
return Promise.reject({ error: grpcError.getGatewayError(), debugHeaders });
|
|
719
730
|
});
|
|
720
731
|
};
|
|
721
732
|
}
|
|
722
|
-
exports.default = createGrpcAction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ApiActionConfig, ApiByScope, ApiServiceMixedActionConfig, GatewayConfig, GatewayRequest, GatewayResponse, SchemasByScope } from '../models/common';
|
|
2
|
-
import { GatewayContext } from '../models/context';
|
|
3
|
-
import { AppErrorConstructor } from '../models/error';
|
|
4
|
-
import type { GrpcContext } from './grpc';
|
|
1
|
+
import { ApiActionConfig, ApiByScope, ApiServiceMixedActionConfig, GatewayConfig, GatewayRequest, GatewayResponse, SchemasByScope } from '../models/common.js';
|
|
2
|
+
import { GatewayContext } from '../models/context.js';
|
|
3
|
+
import { AppErrorConstructor } from '../models/error.js';
|
|
4
|
+
import type { GrpcContext } from './grpc.js';
|
|
5
5
|
export declare function createMixedAction<TSchema extends SchemasByScope, Context extends GatewayContext, Req extends GatewayRequest<Context>, Res extends GatewayResponse>(config: ApiServiceMixedActionConfig<Context, Req, Res, any, any, any>, api: ApiByScope<TSchema, Context, Req, Res>, serviceName: string, actionName: string, extra: {
|
|
6
6
|
config: GatewayConfig<Context, Req, Res>;
|
|
7
7
|
grpcContext: GrpcContext;
|
|
@@ -11,11 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.createMixedAction =
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
14
|
+
exports.createMixedAction = createMixedAction;
|
|
15
|
+
const constants_js_1 = require("../constants.js");
|
|
16
|
+
const common_js_1 = require("../utils/common.js");
|
|
17
|
+
const create_context_api_js_1 = require("../utils/create-context-api.js");
|
|
18
|
+
const parse_error_js_1 = require("../utils/parse-error.js");
|
|
19
19
|
function createMixedAction(config, api, serviceName, actionName, extra, ErrorConstructor) {
|
|
20
20
|
return async (actionConfig) => {
|
|
21
21
|
const { args } = actionConfig, context = __rest(actionConfig, ["args"]);
|
|
@@ -26,9 +26,9 @@ function createMixedAction(config, api, serviceName, actionName, extra, ErrorCon
|
|
|
26
26
|
type: 'mixed',
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
|
-
const contextApi = (0,
|
|
29
|
+
const contextApi = (0, create_context_api_js_1.generateContextApi)(api, Object.assign(Object.assign({}, context), { ctx }));
|
|
30
30
|
try {
|
|
31
|
-
const responseData = await config(contextApi, args, Object.assign(Object.assign({ headers: actionConfig.headers, lang: actionConfig.headers[
|
|
31
|
+
const responseData = await config(contextApi, args, Object.assign(Object.assign({ headers: actionConfig.headers, lang: actionConfig.headers[constants_js_1.DEFAULT_LANG_HEADER] || constants_js_1.Lang.Ru, ctx }, extra), { abortSignal: actionConfig.abortSignal }));
|
|
32
32
|
ctx.log('Request completed');
|
|
33
33
|
return {
|
|
34
34
|
responseData,
|
|
@@ -37,15 +37,15 @@ function createMixedAction(config, api, serviceName, actionName, extra, ErrorCon
|
|
|
37
37
|
}
|
|
38
38
|
catch (e) {
|
|
39
39
|
if (e instanceof Object && 'error' in e) {
|
|
40
|
-
(0,
|
|
40
|
+
(0, common_js_1.handleError)(ErrorConstructor, e, ctx, 'Request failed', {
|
|
41
41
|
actionName,
|
|
42
42
|
serviceName,
|
|
43
43
|
});
|
|
44
44
|
throw e;
|
|
45
45
|
}
|
|
46
46
|
if (e instanceof Error) {
|
|
47
|
-
const parsedError = (0,
|
|
48
|
-
(0,
|
|
47
|
+
const parsedError = (0, parse_error_js_1.parseMixedError)(e);
|
|
48
|
+
(0, common_js_1.handleError)(ErrorConstructor, e, ctx, 'Request failed', {
|
|
49
49
|
actionName,
|
|
50
50
|
serviceName,
|
|
51
51
|
});
|
|
@@ -53,7 +53,7 @@ function createMixedAction(config, api, serviceName, actionName, extra, ErrorCon
|
|
|
53
53
|
error: parsedError,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
(0,
|
|
56
|
+
(0, common_js_1.handleError)(ErrorConstructor, e, ctx, 'Request failed');
|
|
57
57
|
throw {
|
|
58
58
|
error: e,
|
|
59
59
|
};
|
|
@@ -63,4 +63,3 @@ function createMixedAction(config, api, serviceName, actionName, extra, ErrorCon
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
exports.createMixedAction = createMixedAction;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ApiActionConfig, ApiServiceRestActionConfig, EndpointsConfig, GatewayApiOptions, Headers } from '../models/common';
|
|
2
|
-
import { GatewayContext } from '../models/context';
|
|
3
|
-
import { AppErrorConstructor } from '../models/error';
|
|
4
|
-
export
|
|
1
|
+
import { ApiActionConfig, ApiServiceRestActionConfig, EndpointsConfig, GatewayApiOptions, Headers } from '../models/common.js';
|
|
2
|
+
import { GatewayContext } from '../models/context.js';
|
|
3
|
+
import { AppErrorConstructor } from '../models/error.js';
|
|
4
|
+
export declare function createRestAction<Context extends GatewayContext>(endpoints: EndpointsConfig | undefined, config: ApiServiceRestActionConfig<Context, any, any>, serviceKey: string, actionName: string, options: GatewayApiOptions<Context>, ErrorConstructor: AppErrorConstructor): (actionConfig: ApiActionConfig<Context, any>) => Promise<{
|
|
5
5
|
responseData: unknown;
|
|
6
|
-
responseHeaders?: Headers
|
|
6
|
+
responseHeaders?: Headers;
|
|
7
7
|
debugHeaders: Headers;
|
|
8
8
|
}>;
|