Registry / networking / cloudvision-grpc-web

cloudvision-grpc-web

JSON →
library5.0.2jsnpmunverified

A gRPC-Web client library for Arista CloudVision that converts gRPC-Web calls into RXJS Observable streams. Version 5.0.2, release cadence is periodic with minor releases. Key differentiators: designed specifically for CloudVision frontend data access, wraps gRPC-Web with RXJS for reactive data handling, requires ts-proto for protobuf generation, and exposes utilities like fromResourceGrpcInvoke for streaming device inventory and other CloudVision resources.

npm install cloudvision-grpc-web
INSTALL
IMPORT
SIG · CLOUDVISION-GRPC-W
C
cloudvision-grpc-web
networkingjavascriptv5.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fromResourceGrpcInvoke
import { fromResourceGrpcInvoke } from 'cloudvision-grpc-web'
import fromResourceGrpcInvoke from 'cloudvision-grpc-web'
This is a named export, not default. Always use named import.
StreamControlMessage
import { StreamControlMessage } from 'cloudvision-grpc-web'
const StreamControlMessage = require('cloudvision-grpc-web').StreamControlMessage
Package is ESM-first; use import syntax. TypeScript types are included.
GrpcWebOptions
import type { GrpcWebOptions } from 'cloudvision-grpc-web'
Type import for TypeScript users. Only use for type annotations, not runtime.
default
import cloudvisionGrpcWeb from 'cloudvision-grpc-web'
There is no default export. Always use named imports.

Demonstrates using fromResourceGrpcInvoke to create an Observable stream for device data from CloudVision, with auth headers and error handling.

import { fromResourceGrpcInvoke } from 'cloudvision-grpc-web'; import { DeviceServiceGetAllDesc, DeviceStreamRequest } from './generated/arista/inventory.v1/services.gen'; const requestAllMessage = DeviceStreamRequest.fromPartial({}); const grpcRequest = fromResourceGrpcInvoke(DeviceServiceGetAllDesc, { host: process.env.CVP_HOST ?? 'http://localhost', headers: { Authorization: `Bearer ${process.env.CVP_TOKEN ?? ''}` }, request: { ...requestAllMessage, ...DeviceServiceGetAllDesc.requestType }, }); grpcRequest.data.subscribe({ next: (val) => console.log('Received data:', val), error: (err) => console.error('Stream error:', err), }); grpcRequest.messages.subscribe({ next: (msg) => console.log('Control message:', msg), });
Debug
Known issues
breakingIn v5.0.0, the package switched from pure gRPC-Web to ts-proto generated service descriptors. Existing code using raw google-protobuf/gRPC-Web types will not work.
fix
Migrate to ts-proto generated descriptors; update imports and use fromResourceGrpcInvoke with service descriptor objects.
affects: <5.0.0
gotchaThe request object must include both the message fields and the service descriptor's requestType property. Omitting requestType will cause the gRPC call to fail silently.
fix
Spread the request message and descriptor's requestType: request: { ...yourMessage, ...ServiceDesc.requestType }
affects: >=5.0.0
gotchaThe package uses RXJS Observables. Subscriptions must be managed manually or via async operators like firstValueFrom. Not subscribing to data or messages will cause unhandled errors.
fix
Always subscribe to both data and messages observables, or use operators like firstValueFrom to convert to promises.
affects: >=1.0.0
deprecatedThe older API fromResource (without GrpcInvoke) is deprecated and will be removed in v6.
fix
Use fromResourceGrpcInvoke instead.
affects: >=5.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'requestType')
Service descriptor is imported incorrectly or not generated with ts-proto.
fix
Ensure you have ts-proto installed and protobuf definitions generated: protoc --ts_proto_out=./gen --ts_proto_opt=outputServices=grpc-js ...
Error: No transport found for gRPC-Web
Missing gRPC-Web transport configuration; by default fromResourceGrpcInvoke uses HTTP/1.1 but not all servers support it.
fix
Pass a custom transport option: import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport' and provide it in options.
Observable created but never subscribed - possible memory leak
Created an Observable stream without subscribing. Async data is not processed.
fix
Always call .subscribe() on the returned observables, or use firstValueFrom() to get a promise.
Upgrade
Version history
5.0.2latest on npm
Audit
Dependencies
rxjsrequiredProvides Observable streams for reactive data handling
ts-protooptionalRequired for generating TypeScript protobuf definitions and gRPC service descriptors
Agent activity
29 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
cloudvision-grpc-web — npm install cloudvision-grpc-web · libregistry