import * as grpc from '@grpc/grpc-js' ; import * as loader from '@grpc/proto-loader' ; import { ProtoGrpcType as AuthProtoType } from '../proto/auth' ; import { AuthServiceClient } from '../proto/build/stack/auth/v1beta1/AuthService' ; import { LicensesClient } from '../proto/build/stack/license/v1beta1/Licenses' ; import { PlansClient } from '../proto/build/stack/nucleate/v1beta/Plans' ; import { SubscriptionsClient } from '../proto/build/stack/nucleate/v1beta/Subscriptions' ; import { ProtoGrpcType as BzlProtoType } from '../proto/bzl' ; import { ProtoGrpcType as CodesearchProtoType } from '../proto/codesearch' ; import { ProtoGrpcType as LicenseProtoType } from '../proto/license' ; import { ProtoGrpcType as NucleateProtoType } from '../proto/nucleate' ; export function loadAuthProtos ( protofile ) { const protoPackage = loader . loadSync ( protofile , { keepCase : false , defaults : false , oneofs : true , } ) ; return grpc . loadPackageDefinition ( protoPackage ) as unknown as AuthProtoType ; } export function loadNucleateProtos ( protofile ) { const protoPackage = loader . loadSync ( protofile , { keepCase : false , defaults : false , oneofs : true , } ) ; return grpc . loadPackageDefinition ( protoPackage ) as unknown as NucleateProtoType ; } export function loadBzlProtos ( protofile ) { const protoPackage = loader . loadSync ( protofile , { keepCase : false , defaults : false , oneofs : true , } ) ; return grpc . loadPackageDefinition ( protoPackage ) as unknown as BzlProtoType ; } export function loadCodesearchProtos ( protofile ) { const protoPackage = loader . loadSync ( protofile , { keepCase : false , defaults : false , oneofs : true , } ) ; return grpc . loadPackageDefinition ( protoPackage ) as unknown as CodesearchProtoType ; } export function getGRPCCredentials ( address ) { if ( address . endsWith ( ':443' ) ) { return grpc . credentials . createSsl ( ) ; } return grpc . credentials . createInsecure ( ) ; } param address export function createAuthServiceClient ( proto , address , creds = getGRPCCredentials ( address ) ) { return new proto . build . stack . auth . v1beta1 . AuthService ( address , creds ) ; } param address export function createSubscriptionsClient ( proto , address ) { return new proto . build . stack . nucleate . v1beta . Subscriptions ( address , getGRPCCredentials ( address ) ) ; } param address export function createPlansClient ( proto , address , creds = getGRPCCredentials ( address ) ) { return new proto . build . stack . nucleate . v1beta . Plans ( address , creds ) ; } param address export function createLicensesClient ( proto , address , creds = getGRPCCredentials ( address ) ) { return new proto . build . stack . license . v1beta1 . Licenses ( address , creds ) ; }