nice-grpc-web
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -23,7 +23,7 @@ "use strict"; | ||
? newMiddleware | ||
: nice_grpc_common_1.composeClientMiddleware(middleware, newMiddleware)); | ||
: (0, nice_grpc_common_1.composeClientMiddleware)(middleware, newMiddleware)); | ||
}, | ||
create(definition, channel, defaultCallOptions = {}) { | ||
const client = {}; | ||
const methodEntries = Object.entries(service_definitions_1.normalizeServiceDefinition(definition)); | ||
const methodEntries = Object.entries((0, service_definitions_1.normalizeServiceDefinition)(definition)); | ||
for (const [methodName, methodDefinition] of methodEntries) { | ||
@@ -36,6 +36,6 @@ const defaultOptions = { | ||
if (!methodDefinition.responseStream) { | ||
client[methodName] = createUnaryMethod_1.createUnaryMethod(methodDefinition, channel, middleware, defaultOptions); | ||
client[methodName] = (0, createUnaryMethod_1.createUnaryMethod)(methodDefinition, channel, middleware, defaultOptions); | ||
} | ||
else { | ||
client[methodName] = createServerStreamingMethod_1.createServerStreamingMethod(methodDefinition, channel, middleware, defaultOptions); | ||
client[methodName] = (0, createServerStreamingMethod_1.createServerStreamingMethod)(methodDefinition, channel, middleware, defaultOptions); | ||
} | ||
@@ -45,6 +45,6 @@ } | ||
if (!methodDefinition.responseStream) { | ||
client[methodName] = createClientStreamingMethod_1.createClientStreamingMethod(methodDefinition, channel, middleware, defaultOptions); | ||
client[methodName] = (0, createClientStreamingMethod_1.createClientStreamingMethod)(methodDefinition, channel, middleware, defaultOptions); | ||
} | ||
else { | ||
client[methodName] = createBidiStreamingMethod_1.createBidiStreamingMethod(methodDefinition, channel, middleware, defaultOptions); | ||
client[methodName] = (0, createBidiStreamingMethod_1.createBidiStreamingMethod)(methodDefinition, channel, middleware, defaultOptions); | ||
} | ||
@@ -51,0 +51,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
function createBidiStreamingMethod(definition, channel, middleware, defaultOptions) { | ||
const grpcMethodDefinition = service_definitions_1.toGrpcWebMethodDefinition(definition); | ||
const grpcMethodDefinition = (0, service_definitions_1.toGrpcWebMethodDefinition)(definition); | ||
const methodDescriptor = { | ||
@@ -26,6 +26,6 @@ path: definition.path, | ||
async function* bidiStreamingMethod(request, options) { | ||
if (!isAsyncIterable_1.isAsyncIterable(request)) { | ||
if (!(0, isAsyncIterable_1.isAsyncIterable)(request)) { | ||
throw new Error('A middleware passed invalid request to next(): expected a single message for bidirectional streaming method'); | ||
} | ||
const { metadata = nice_grpc_common_1.Metadata(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
const { metadata = (0, nice_grpc_common_1.Metadata)(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
const pipeAbortController = new node_abort_controller_1.default(); | ||
@@ -38,3 +38,3 @@ const sink = new AsyncSink_1.AsyncSink(); | ||
client.onHeaders(headers => { | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader(convertMetadata_1.convertMetadataFromGrpcWeb(headers)); | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader((0, convertMetadata_1.convertMetadataFromGrpcWeb)(headers)); | ||
}); | ||
@@ -45,3 +45,3 @@ client.onMessage(message => { | ||
client.onEnd((code, message, trailers) => { | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer(convertMetadata_1.convertMetadataFromGrpcWeb(trailers)); | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer((0, convertMetadata_1.convertMetadataFromGrpcWeb)(trailers)); | ||
if (code === grpc_web_1.grpc.Code.OK) { | ||
@@ -54,3 +54,3 @@ sink.end(); | ||
}); | ||
client.start(convertMetadata_1.convertMetadataToGrpcWeb(metadata)); | ||
client.start((0, convertMetadata_1.convertMetadataToGrpcWeb)(metadata)); | ||
let pipeError; | ||
@@ -60,3 +60,3 @@ pipeRequest(pipeAbortController.signal, request, client, definition).then(() => { | ||
}, err => { | ||
if (!abort_controller_x_1.isAbortError(err)) { | ||
if (!(0, abort_controller_x_1.isAbortError)(err)) { | ||
pipeError = err; | ||
@@ -79,3 +79,3 @@ client.close(); | ||
signal.removeEventListener('abort', abortListener); | ||
abort_controller_x_1.throwIfAborted(signal); | ||
(0, abort_controller_x_1.throwIfAborted)(signal); | ||
if (pipeError) { | ||
@@ -125,3 +125,3 @@ throw pipeError; | ||
for await (const item of request) { | ||
abort_controller_x_1.throwIfAborted(signal); | ||
(0, abort_controller_x_1.throwIfAborted)(signal); | ||
client.send({ | ||
@@ -128,0 +128,0 @@ serializeBinary: () => definition.requestSerialize(item), |
@@ -16,3 +16,3 @@ "use strict"; | ||
function createClientStreamingMethod(definition, channel, middleware, defaultOptions) { | ||
const grpcMethodDefinition = service_definitions_1.toGrpcWebMethodDefinition(definition); | ||
const grpcMethodDefinition = (0, service_definitions_1.toGrpcWebMethodDefinition)(definition); | ||
const methodDescriptor = { | ||
@@ -25,7 +25,7 @@ path: definition.path, | ||
async function* clientStreamingMethod(request, options) { | ||
if (!isAsyncIterable_1.isAsyncIterable(request)) { | ||
if (!(0, isAsyncIterable_1.isAsyncIterable)(request)) { | ||
throw new Error('A middleware passed invalid request to next(): expected a single message for client streaming method'); | ||
} | ||
const { metadata = nice_grpc_common_1.Metadata(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
return await abort_controller_x_1.execute(signal, (resolve, reject) => { | ||
const { metadata = (0, nice_grpc_common_1.Metadata)(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
return await (0, abort_controller_x_1.execute)(signal, (resolve, reject) => { | ||
const pipeAbortController = new node_abort_controller_1.default(); | ||
@@ -38,3 +38,3 @@ let response; | ||
client.onHeaders(headers => { | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader(convertMetadata_1.convertMetadataFromGrpcWeb(headers)); | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader((0, convertMetadata_1.convertMetadataFromGrpcWeb)(headers)); | ||
}); | ||
@@ -45,3 +45,3 @@ client.onMessage(message => { | ||
client.onEnd((code, message, trailers) => { | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer(convertMetadata_1.convertMetadataFromGrpcWeb(trailers)); | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer((0, convertMetadata_1.convertMetadataFromGrpcWeb)(trailers)); | ||
pipeAbortController.abort(); | ||
@@ -55,7 +55,7 @@ if (code === grpc_web_1.grpc.Code.OK) { | ||
}); | ||
client.start(convertMetadata_1.convertMetadataToGrpcWeb(metadata)); | ||
client.start((0, convertMetadata_1.convertMetadataToGrpcWeb)(metadata)); | ||
pipeRequest(pipeAbortController.signal, request, client, definition).then(() => { | ||
client.finishSend(); | ||
}, err => { | ||
if (!abort_controller_x_1.isAbortError(err)) { | ||
if (!(0, abort_controller_x_1.isAbortError)(err)) { | ||
reject(err); | ||
@@ -103,3 +103,3 @@ client.close(); | ||
for await (const item of request) { | ||
abort_controller_x_1.throwIfAborted(signal); | ||
(0, abort_controller_x_1.throwIfAborted)(signal); | ||
client.send({ | ||
@@ -106,0 +106,0 @@ serializeBinary: () => definition.requestSerialize(item), |
@@ -17,3 +17,3 @@ "use strict"; | ||
function createServerStreamingMethod(definition, channel, middleware, defaultOptions) { | ||
const grpcMethodDefinition = service_definitions_1.toGrpcWebMethodDefinition(definition); | ||
const grpcMethodDefinition = (0, service_definitions_1.toGrpcWebMethodDefinition)(definition); | ||
const methodDescriptor = { | ||
@@ -26,6 +26,6 @@ path: definition.path, | ||
async function* serverStreamingMethod(request, options) { | ||
if (isAsyncIterable_1.isAsyncIterable(request)) { | ||
if ((0, isAsyncIterable_1.isAsyncIterable)(request)) { | ||
throw new Error('A middleware passed invalid request to next(): expected a single message for server streaming method'); | ||
} | ||
const { metadata = nice_grpc_common_1.Metadata(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
const { metadata = (0, nice_grpc_common_1.Metadata)(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
const sink = new AsyncSink_1.AsyncSink(); | ||
@@ -37,3 +37,3 @@ const client = grpc_web_1.grpc.client(grpcMethodDefinition, { | ||
client.onHeaders(headers => { | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader(convertMetadata_1.convertMetadataFromGrpcWeb(headers)); | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader((0, convertMetadata_1.convertMetadataFromGrpcWeb)(headers)); | ||
}); | ||
@@ -44,3 +44,3 @@ client.onMessage(message => { | ||
client.onEnd((code, message, trailers) => { | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer(convertMetadata_1.convertMetadataFromGrpcWeb(trailers)); | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer((0, convertMetadata_1.convertMetadataFromGrpcWeb)(trailers)); | ||
if (code === grpc_web_1.grpc.Code.OK) { | ||
@@ -53,3 +53,3 @@ sink.end(); | ||
}); | ||
client.start(convertMetadata_1.convertMetadataToGrpcWeb(metadata)); | ||
client.start((0, convertMetadata_1.convertMetadataToGrpcWeb)(metadata)); | ||
client.send({ | ||
@@ -69,3 +69,3 @@ serializeBinary: () => definition.requestSerialize(request), | ||
signal.removeEventListener('abort', abortListener); | ||
abort_controller_x_1.throwIfAborted(signal); | ||
(0, abort_controller_x_1.throwIfAborted)(signal); | ||
} | ||
@@ -72,0 +72,0 @@ } |
@@ -16,3 +16,3 @@ "use strict"; | ||
function createUnaryMethod(definition, channel, middleware, defaultOptions) { | ||
const grpcMethodDefinition = service_definitions_1.toGrpcWebMethodDefinition(definition); | ||
const grpcMethodDefinition = (0, service_definitions_1.toGrpcWebMethodDefinition)(definition); | ||
const methodDescriptor = { | ||
@@ -25,7 +25,7 @@ path: definition.path, | ||
async function* unaryMethod(request, options) { | ||
if (isAsyncIterable_1.isAsyncIterable(request)) { | ||
if ((0, isAsyncIterable_1.isAsyncIterable)(request)) { | ||
throw new Error('A middleware passed invalid request to next(): expected a single message for unary method'); | ||
} | ||
const { metadata = nice_grpc_common_1.Metadata(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
return await abort_controller_x_1.execute(signal, (resolve, reject) => { | ||
const { metadata = (0, nice_grpc_common_1.Metadata)(), signal = new node_abort_controller_1.default().signal, onHeader, onTrailer, } = options; | ||
return await (0, abort_controller_x_1.execute)(signal, (resolve, reject) => { | ||
let response; | ||
@@ -37,3 +37,3 @@ const client = grpc_web_1.grpc.client(grpcMethodDefinition, { | ||
client.onHeaders(headers => { | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader(convertMetadata_1.convertMetadataFromGrpcWeb(headers)); | ||
onHeader === null || onHeader === void 0 ? void 0 : onHeader((0, convertMetadata_1.convertMetadataFromGrpcWeb)(headers)); | ||
}); | ||
@@ -44,3 +44,3 @@ client.onMessage(message => { | ||
client.onEnd((code, message, trailers) => { | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer(convertMetadata_1.convertMetadataFromGrpcWeb(trailers)); | ||
onTrailer === null || onTrailer === void 0 ? void 0 : onTrailer((0, convertMetadata_1.convertMetadataFromGrpcWeb)(trailers)); | ||
if (code === grpc_web_1.grpc.Code.OK) { | ||
@@ -53,3 +53,3 @@ resolve(response); | ||
}); | ||
client.start(convertMetadata_1.convertMetadataToGrpcWeb(metadata)); | ||
client.start((0, convertMetadata_1.convertMetadataToGrpcWeb)(metadata)); | ||
client.send({ | ||
@@ -56,0 +56,0 @@ serializeBinary: () => definition.requestSerialize(request), |
@@ -8,7 +8,7 @@ "use strict"; | ||
function normalizeServiceDefinition(definition) { | ||
if (grpc_web_1.isGrpcWebServiceDefinition(definition)) { | ||
return grpc_web_1.fromGrpcWebServiceDefinition(definition); | ||
if ((0, grpc_web_1.isGrpcWebServiceDefinition)(definition)) { | ||
return (0, grpc_web_1.fromGrpcWebServiceDefinition)(definition); | ||
} | ||
else if (ts_proto_1.isTsProtoServiceDefinition(definition)) { | ||
return ts_proto_1.fromTsProtoServiceDefinition(definition); | ||
else if ((0, ts_proto_1.isTsProtoServiceDefinition)(definition)) { | ||
return (0, ts_proto_1.fromTsProtoServiceDefinition)(definition); | ||
} | ||
@@ -15,0 +15,0 @@ else { |
@@ -18,3 +18,3 @@ "use strict"; | ||
function convertMetadataFromGrpcWeb(grpcMetadata) { | ||
const metadata = nice_grpc_common_1.Metadata(); | ||
const metadata = (0, nice_grpc_common_1.Metadata)(); | ||
for (const [key, values] of Object.entries(grpcMetadata.headersMap)) { | ||
@@ -21,0 +21,0 @@ metadata.set(key, key.endsWith('-bin') |
{ | ||
"name": "nice-grpc-web", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A Browser gRPC library that is nice to you", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
"@types/tcp-port-used": "^1.0.0", | ||
"@types/ws": "^7.4.4", | ||
"@types/ws": "^8.2.2", | ||
"google-protobuf": "^3.17.3", | ||
@@ -46,3 +46,3 @@ "grpc-tools": "^1.11.2", | ||
"mkdirp": "^1.0.4", | ||
"path-exists-cli": "^1.0.0", | ||
"path-exists-cli": "^2.0.0", | ||
"request": "^2.88.2", | ||
@@ -53,12 +53,12 @@ "tcp-port-used": "^1.0.2", | ||
"unzipper": "^0.10.11", | ||
"ws": "^7.5.0" | ||
"ws": "^8.4.2" | ||
}, | ||
"dependencies": { | ||
"@improbable-eng/grpc-web": "^0.14.0", | ||
"@improbable-eng/grpc-web": "^0.15.0", | ||
"abort-controller-x": "^0.2.6", | ||
"js-base64": "^3.6.1", | ||
"js-base64": "^3.7.2", | ||
"nice-grpc-common": "^1.0.4", | ||
"node-abort-controller": "^2.0.0" | ||
}, | ||
"gitHead": "5d08d062313f513648d2632af85d77607513637c" | ||
"gitHead": "c1a525d031cd5f2f4498b92c9756970eff760b16" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112898
+ Added@improbable-eng/grpc-web@0.15.0(transitive)
- Removed@improbable-eng/grpc-web@0.14.1(transitive)
Updatedjs-base64@^3.7.2