UNPKG

7.17 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright 2019 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.experimental = exports.StatusBuilder = exports.getClientChannel = exports.ServerCredentials = exports.Server = exports.setLogVerbosity = exports.setLogger = exports.load = exports.loadObject = exports.CallCredentials = exports.ChannelCredentials = exports.waitForClientReady = exports.closeClient = exports.Channel = exports.makeGenericClientConstructor = exports.makeClientConstructor = exports.loadPackageDefinition = exports.Client = exports.propagate = exports.connectivityState = exports.status = exports.logVerbosity = exports.Metadata = exports.credentials = void 0;
20const call_credentials_1 = require("./call-credentials");
21Object.defineProperty(exports, "CallCredentials", { enumerable: true, get: function () { return call_credentials_1.CallCredentials; } });
22const channel_1 = require("./channel");
23Object.defineProperty(exports, "connectivityState", { enumerable: true, get: function () { return channel_1.ConnectivityState; } });
24Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return channel_1.ChannelImplementation; } });
25const channel_credentials_1 = require("./channel-credentials");
26Object.defineProperty(exports, "ChannelCredentials", { enumerable: true, get: function () { return channel_credentials_1.ChannelCredentials; } });
27const client_1 = require("./client");
28Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
29const constants_1 = require("./constants");
30Object.defineProperty(exports, "logVerbosity", { enumerable: true, get: function () { return constants_1.LogVerbosity; } });
31Object.defineProperty(exports, "status", { enumerable: true, get: function () { return constants_1.Status; } });
32Object.defineProperty(exports, "propagate", { enumerable: true, get: function () { return constants_1.Propagate; } });
33const logging = require("./logging");
34const make_client_1 = require("./make-client");
35Object.defineProperty(exports, "loadPackageDefinition", { enumerable: true, get: function () { return make_client_1.loadPackageDefinition; } });
36Object.defineProperty(exports, "makeClientConstructor", { enumerable: true, get: function () { return make_client_1.makeClientConstructor; } });
37Object.defineProperty(exports, "makeGenericClientConstructor", { enumerable: true, get: function () { return make_client_1.makeClientConstructor; } });
38const metadata_1 = require("./metadata");
39Object.defineProperty(exports, "Metadata", { enumerable: true, get: function () { return metadata_1.Metadata; } });
40const server_1 = require("./server");
41Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
42const server_credentials_1 = require("./server-credentials");
43Object.defineProperty(exports, "ServerCredentials", { enumerable: true, get: function () { return server_credentials_1.ServerCredentials; } });
44const status_builder_1 = require("./status-builder");
45Object.defineProperty(exports, "StatusBuilder", { enumerable: true, get: function () { return status_builder_1.StatusBuilder; } });
46/**** Client Credentials ****/
47// Using assign only copies enumerable properties, which is what we want
48exports.credentials = {
49 /**
50 * Combine a ChannelCredentials with any number of CallCredentials into a
51 * single ChannelCredentials object.
52 * @param channelCredentials The ChannelCredentials object.
53 * @param callCredentials Any number of CallCredentials objects.
54 * @return The resulting ChannelCredentials object.
55 */
56 combineChannelCredentials: (channelCredentials, ...callCredentials) => {
57 return callCredentials.reduce((acc, other) => acc.compose(other), channelCredentials);
58 },
59 /**
60 * Combine any number of CallCredentials into a single CallCredentials
61 * object.
62 * @param first The first CallCredentials object.
63 * @param additional Any number of additional CallCredentials objects.
64 * @return The resulting CallCredentials object.
65 */
66 combineCallCredentials: (first, ...additional) => {
67 return additional.reduce((acc, other) => acc.compose(other), first);
68 },
69 // from channel-credentials.ts
70 createInsecure: channel_credentials_1.ChannelCredentials.createInsecure,
71 createSsl: channel_credentials_1.ChannelCredentials.createSsl,
72 // from call-credentials.ts
73 createFromMetadataGenerator: call_credentials_1.CallCredentials.createFromMetadataGenerator,
74 createFromGoogleCredential: call_credentials_1.CallCredentials.createFromGoogleCredential,
75 createEmpty: call_credentials_1.CallCredentials.createEmpty,
76};
77/**
78 * Close a Client object.
79 * @param client The client to close.
80 */
81exports.closeClient = (client) => client.close();
82exports.waitForClientReady = (client, deadline, callback) => client.waitForReady(deadline, callback);
83/* eslint-enable @typescript-eslint/no-explicit-any */
84/**** Unimplemented function stubs ****/
85/* eslint-disable @typescript-eslint/no-explicit-any */
86exports.loadObject = (value, options) => {
87 throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
88};
89exports.load = (filename, format, options) => {
90 throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
91};
92exports.setLogger = (logger) => {
93 logging.setLogger(logger);
94};
95exports.setLogVerbosity = (verbosity) => {
96 logging.setLoggerVerbosity(verbosity);
97};
98exports.getClientChannel = (client) => {
99 return client_1.Client.prototype.getChannel.call(client);
100};
101var client_interceptors_1 = require("./client-interceptors");
102Object.defineProperty(exports, "ListenerBuilder", { enumerable: true, get: function () { return client_interceptors_1.ListenerBuilder; } });
103Object.defineProperty(exports, "RequesterBuilder", { enumerable: true, get: function () { return client_interceptors_1.RequesterBuilder; } });
104Object.defineProperty(exports, "InterceptingCall", { enumerable: true, get: function () { return client_interceptors_1.InterceptingCall; } });
105Object.defineProperty(exports, "InterceptorConfigurationError", { enumerable: true, get: function () { return client_interceptors_1.InterceptorConfigurationError; } });
106const experimental = require("./experimental");
107exports.experimental = experimental;
108const resolver = require("./resolver");
109const load_balancer = require("./load-balancer");
110(() => {
111 resolver.registerAll();
112 load_balancer.registerAll();
113})();
114//# sourceMappingURL=index.js.map
\No newline at end of file