@hazeljs/grpc 0.2.0-beta.34 → 0.2.0-beta.35

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.
@@ -0,0 +1,50 @@
1
+ import type { GrpcClientOptions } from './grpc.client.types';
2
+ type GrpcClientStub = Record<string, (req: unknown, cb: (err: Error | null, res: unknown) => void) => void>;
3
+ /**
4
+ * gRPC Client service - creates and caches gRPC client stubs for calling remote gRPC services
5
+ */
6
+ export declare class GrpcClientService {
7
+ private packageDefinition;
8
+ private protoDescriptor;
9
+ private options;
10
+ private stubCache;
11
+ /**
12
+ * Configure the client with proto path and options
13
+ */
14
+ configure(options: GrpcClientOptions): void;
15
+ /**
16
+ * Resolve URL from Discovery when configured
17
+ */
18
+ private resolveUrl;
19
+ /**
20
+ * Build filter for Discovery.
21
+ * Passes user filter; for protocol: 'grpc' use metadata: { protocol: 'grpc' }
22
+ * since ServiceFilter filters by metadata.
23
+ */
24
+ private buildDiscoveryFilter;
25
+ /**
26
+ * Get a gRPC client stub for the given service.
27
+ * When Discovery is configured and url is omitted, resolves URL from Discovery.
28
+ * Stubs are cached per (serviceName, url).
29
+ *
30
+ * @param serviceName - Service name as defined in proto (e.g. 'ProductService')
31
+ * @param url - Optional URL (e.g. 'localhost:50051'). Required if not using Discovery and no defaultUrl.
32
+ * @returns gRPC client stub with RPC methods
33
+ */
34
+ getClient(serviceName: string, url?: string): GrpcClientStub;
35
+ /**
36
+ * Get a gRPC client stub asynchronously.
37
+ * Use this when Discovery is configured, as URL resolution is async.
38
+ *
39
+ * @param serviceName - Service name as defined in proto (e.g. 'ProductService')
40
+ * @param url - Optional URL. When omitted and Discovery is configured, resolves from Discovery.
41
+ * @returns Promise resolving to gRPC client stub
42
+ */
43
+ getClientAsync(serviceName: string, url?: string): Promise<GrpcClientStub>;
44
+ /**
45
+ * Close all cached client channels (for graceful shutdown)
46
+ */
47
+ close(): void;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=grpc.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc.client.d.ts","sourceRoot":"","sources":["../src/grpc.client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AAE7B,KAAK,cAAc,GAAG,MAAM,CAC1B,MAAM,EACN,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CACtE,CAAC;AAEF;;GAEG;AACH,qBACa,iBAAiB;IAC5B,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,eAAe,CAAwC;IAC/D,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,SAAS,CAAkD;IAEnE;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAwB3C;;OAEG;YACW,UAAU;IA0BxB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,cAAc;IA2D5D;;;;;;;OAOG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAKhF;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd"}
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.GrpcClientService = void 0;
46
+ const core_1 = require("@hazeljs/core");
47
+ const grpc = __importStar(require("@grpc/grpc-js"));
48
+ const protoLoader = __importStar(require("@grpc/proto-loader"));
49
+ const core_2 = __importDefault(require("@hazeljs/core"));
50
+ /**
51
+ * gRPC Client service - creates and caches gRPC client stubs for calling remote gRPC services
52
+ */
53
+ let GrpcClientService = class GrpcClientService {
54
+ constructor() {
55
+ this.packageDefinition = null;
56
+ this.protoDescriptor = null;
57
+ this.options = null;
58
+ this.stubCache = new Map();
59
+ }
60
+ /**
61
+ * Configure the client with proto path and options
62
+ */
63
+ configure(options) {
64
+ this.options = options;
65
+ const protoPath = Array.isArray(options.protoPath) ? options.protoPath : [options.protoPath];
66
+ const loaderOptions = {
67
+ keepCase: true,
68
+ longs: String,
69
+ enums: String,
70
+ defaults: true,
71
+ oneofs: true,
72
+ ...(options.loader ?? {}),
73
+ };
74
+ this.packageDefinition = protoLoader.loadSync(protoPath, loaderOptions);
75
+ this.protoDescriptor = grpc.loadPackageDefinition(this.packageDefinition);
76
+ core_2.default.info('gRPC client configured', {
77
+ package: options.package,
78
+ defaultUrl: options.defaultUrl,
79
+ discovery: !!options.discovery,
80
+ });
81
+ }
82
+ /**
83
+ * Resolve URL from Discovery when configured
84
+ */
85
+ async resolveUrl(serviceName) {
86
+ const discovery = this.options?.discovery;
87
+ if (!discovery) {
88
+ const defaultUrl = this.options?.defaultUrl;
89
+ if (!defaultUrl) {
90
+ throw new Error('No URL provided and no defaultUrl configured. Pass url to getClient() or set defaultUrl in GrpcClientModule.forRoot().');
91
+ }
92
+ return defaultUrl;
93
+ }
94
+ const client = discovery.client;
95
+ const strategy = discovery.loadBalancingStrategy ?? 'round-robin';
96
+ const filter = this.buildDiscoveryFilter(discovery);
97
+ const instance = await client.getInstance(discovery.serviceName, strategy, filter);
98
+ if (!instance) {
99
+ throw new Error(`Discovery: no gRPC instance found for service "${discovery.serviceName}"`);
100
+ }
101
+ const url = `${instance.host}:${instance.port}`;
102
+ core_2.default.debug('Resolved gRPC URL from Discovery', { serviceName, url });
103
+ return url;
104
+ }
105
+ /**
106
+ * Build filter for Discovery.
107
+ * Passes user filter; for protocol: 'grpc' use metadata: { protocol: 'grpc' }
108
+ * since ServiceFilter filters by metadata.
109
+ */
110
+ buildDiscoveryFilter(discovery) {
111
+ return discovery.filter ?? {};
112
+ }
113
+ /**
114
+ * Get a gRPC client stub for the given service.
115
+ * When Discovery is configured and url is omitted, resolves URL from Discovery.
116
+ * Stubs are cached per (serviceName, url).
117
+ *
118
+ * @param serviceName - Service name as defined in proto (e.g. 'ProductService')
119
+ * @param url - Optional URL (e.g. 'localhost:50051'). Required if not using Discovery and no defaultUrl.
120
+ * @returns gRPC client stub with RPC methods
121
+ */
122
+ getClient(serviceName, url) {
123
+ if (!this.protoDescriptor || !this.options) {
124
+ throw new Error('GrpcClientService not configured. Use GrpcClientModule.forRoot() first.');
125
+ }
126
+ const pkg = this.options.package;
127
+ const pkgObj = this.protoDescriptor[pkg];
128
+ if (!pkgObj) {
129
+ throw new Error(`Package "${pkg}" not found in proto descriptor. Check your proto file and package name.`);
130
+ }
131
+ const ServiceConstructor = pkgObj[serviceName];
132
+ if (!ServiceConstructor) {
133
+ throw new Error(`Service "${serviceName}" not found in package "${pkg}". Check your proto file.`);
134
+ }
135
+ const resolveAndGetStub = (resolvedUrl) => {
136
+ let urlMap = this.stubCache.get(serviceName);
137
+ if (!urlMap) {
138
+ urlMap = new Map();
139
+ this.stubCache.set(serviceName, urlMap);
140
+ }
141
+ let stub = urlMap.get(resolvedUrl);
142
+ if (!stub) {
143
+ const credentials = this.options.credentials ?? grpc.credentials.createInsecure();
144
+ stub = new ServiceConstructor(resolvedUrl, credentials);
145
+ urlMap.set(resolvedUrl, stub);
146
+ core_2.default.debug('Created gRPC client stub', { serviceName, url: resolvedUrl });
147
+ }
148
+ return stub;
149
+ };
150
+ if (url) {
151
+ return resolveAndGetStub(url);
152
+ }
153
+ if (this.options.discovery) {
154
+ throw new Error('Discovery mode requires async getClientAsync(). Use getClientAsync(serviceName) when Discovery is configured.');
155
+ }
156
+ const defaultUrl = this.options.defaultUrl;
157
+ if (!defaultUrl) {
158
+ throw new Error('No URL provided. Pass url to getClient() or set defaultUrl in GrpcClientModule.forRoot().');
159
+ }
160
+ return resolveAndGetStub(defaultUrl);
161
+ }
162
+ /**
163
+ * Get a gRPC client stub asynchronously.
164
+ * Use this when Discovery is configured, as URL resolution is async.
165
+ *
166
+ * @param serviceName - Service name as defined in proto (e.g. 'ProductService')
167
+ * @param url - Optional URL. When omitted and Discovery is configured, resolves from Discovery.
168
+ * @returns Promise resolving to gRPC client stub
169
+ */
170
+ async getClientAsync(serviceName, url) {
171
+ const resolvedUrl = url ?? (await this.resolveUrl(serviceName));
172
+ return this.getClient(serviceName, resolvedUrl);
173
+ }
174
+ /**
175
+ * Close all cached client channels (for graceful shutdown)
176
+ */
177
+ close() {
178
+ this.stubCache.clear();
179
+ this.packageDefinition = null;
180
+ this.protoDescriptor = null;
181
+ this.options = null;
182
+ core_2.default.info('gRPC client closed');
183
+ }
184
+ };
185
+ exports.GrpcClientService = GrpcClientService;
186
+ exports.GrpcClientService = GrpcClientService = __decorate([
187
+ (0, core_1.Injectable)()
188
+ ], GrpcClientService);
@@ -0,0 +1,65 @@
1
+ import { GrpcClientService } from './grpc.client';
2
+ import type { GrpcClientModuleConfig } from './grpc.client.types';
3
+ /**
4
+ * gRPC Client module for HazelJS
5
+ * Provides gRPC client support for calling remote gRPC services
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Static URL
10
+ * @HazelModule({
11
+ * imports: [
12
+ * GrpcClientModule.forRoot({
13
+ * protoPath: join(__dirname, 'product.proto'),
14
+ * package: 'catalog',
15
+ * defaultUrl: 'localhost:50051',
16
+ * }),
17
+ * ],
18
+ * providers: [OrderService],
19
+ * })
20
+ * export class AppModule {}
21
+ *
22
+ * // With Discovery
23
+ * GrpcClientModule.forRoot({
24
+ * protoPath: join(__dirname, 'product.proto'),
25
+ * package: 'catalog',
26
+ * discovery: {
27
+ * client: discoveryClient,
28
+ * serviceName: 'product-service',
29
+ * loadBalancingStrategy: 'round-robin',
30
+ * filter: { metadata: { protocol: 'grpc' } },
31
+ * },
32
+ * });
33
+ * ```
34
+ */
35
+ export declare class GrpcClientModule {
36
+ /**
37
+ * Configure gRPC client module with options
38
+ */
39
+ static forRoot(options: GrpcClientModuleConfig): {
40
+ module: typeof GrpcClientModule;
41
+ providers: Array<{
42
+ provide: typeof GrpcClientService;
43
+ useFactory: () => GrpcClientService;
44
+ }>;
45
+ exports: Array<typeof GrpcClientService>;
46
+ global: boolean;
47
+ };
48
+ /**
49
+ * Configure gRPC client module asynchronously
50
+ */
51
+ static forRootAsync(options: {
52
+ useFactory: (...args: unknown[]) => Promise<GrpcClientModuleConfig> | GrpcClientModuleConfig;
53
+ inject?: unknown[];
54
+ }): {
55
+ module: typeof GrpcClientModule;
56
+ providers: Array<{
57
+ provide: string | typeof GrpcClientService;
58
+ useFactory: unknown;
59
+ inject?: unknown[];
60
+ }>;
61
+ exports: Array<typeof GrpcClientService>;
62
+ global: boolean;
63
+ };
64
+ }
65
+ //# sourceMappingURL=grpc.client.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc.client.module.d.ts","sourceRoot":"","sources":["../src/grpc.client.module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAIa,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG;QAC/C,MAAM,EAAE,OAAO,gBAAgB,CAAC;QAChC,SAAS,EAAE,KAAK,CAAC;YACf,OAAO,EAAE,OAAO,iBAAiB,CAAC;YAClC,UAAU,EAAE,MAAM,iBAAiB,CAAC;SACrC,CAAC,CAAC;QACH,OAAO,EAAE,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC;KACjB;IAsBD;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;QAC3B,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;QAC7F,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;KACpB,GAAG;QACF,MAAM,EAAE,OAAO,gBAAgB,CAAC;QAChC,SAAS,EAAE,KAAK,CAAC;YACf,OAAO,EAAE,MAAM,GAAG,OAAO,iBAAiB,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC;YACpB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;SACpB,CAAC,CAAC;QACH,OAAO,EAAE,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC;KACjB;CAuBF"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ var GrpcClientModule_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.GrpcClientModule = void 0;
14
+ const core_1 = require("@hazeljs/core");
15
+ const core_2 = __importDefault(require("@hazeljs/core"));
16
+ const grpc_client_1 = require("./grpc.client");
17
+ /**
18
+ * gRPC Client module for HazelJS
19
+ * Provides gRPC client support for calling remote gRPC services
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Static URL
24
+ * @HazelModule({
25
+ * imports: [
26
+ * GrpcClientModule.forRoot({
27
+ * protoPath: join(__dirname, 'product.proto'),
28
+ * package: 'catalog',
29
+ * defaultUrl: 'localhost:50051',
30
+ * }),
31
+ * ],
32
+ * providers: [OrderService],
33
+ * })
34
+ * export class AppModule {}
35
+ *
36
+ * // With Discovery
37
+ * GrpcClientModule.forRoot({
38
+ * protoPath: join(__dirname, 'product.proto'),
39
+ * package: 'catalog',
40
+ * discovery: {
41
+ * client: discoveryClient,
42
+ * serviceName: 'product-service',
43
+ * loadBalancingStrategy: 'round-robin',
44
+ * filter: { metadata: { protocol: 'grpc' } },
45
+ * },
46
+ * });
47
+ * ```
48
+ */
49
+ let GrpcClientModule = GrpcClientModule_1 = class GrpcClientModule {
50
+ /**
51
+ * Configure gRPC client module with options
52
+ */
53
+ static forRoot(options) {
54
+ const { isGlobal = true, ...clientOptions } = options;
55
+ core_2.default.info('Configuring gRPC client module...');
56
+ const grpcClientProvider = {
57
+ provide: grpc_client_1.GrpcClientService,
58
+ useFactory: () => {
59
+ const client = new grpc_client_1.GrpcClientService();
60
+ client.configure(clientOptions);
61
+ return client;
62
+ },
63
+ };
64
+ return {
65
+ module: GrpcClientModule_1,
66
+ providers: [grpcClientProvider],
67
+ exports: [grpc_client_1.GrpcClientService],
68
+ global: isGlobal,
69
+ };
70
+ }
71
+ /**
72
+ * Configure gRPC client module asynchronously
73
+ */
74
+ static forRootAsync(options) {
75
+ return {
76
+ module: GrpcClientModule_1,
77
+ providers: [
78
+ {
79
+ provide: 'GRPC_CLIENT_OPTIONS',
80
+ useFactory: options.useFactory,
81
+ inject: options.inject || [],
82
+ },
83
+ {
84
+ provide: grpc_client_1.GrpcClientService,
85
+ useFactory: (clientOptions) => {
86
+ const client = new grpc_client_1.GrpcClientService();
87
+ client.configure(clientOptions);
88
+ return client;
89
+ },
90
+ inject: ['GRPC_CLIENT_OPTIONS'],
91
+ },
92
+ ],
93
+ exports: [grpc_client_1.GrpcClientService],
94
+ global: true,
95
+ };
96
+ }
97
+ };
98
+ exports.GrpcClientModule = GrpcClientModule;
99
+ exports.GrpcClientModule = GrpcClientModule = GrpcClientModule_1 = __decorate([
100
+ (0, core_1.HazelModule)({
101
+ providers: [],
102
+ exports: [],
103
+ })
104
+ ], GrpcClientModule);
@@ -0,0 +1,66 @@
1
+ import type { ProtoLoaderOptions } from './grpc.types';
2
+ import type { ChannelCredentials } from '@grpc/grpc-js';
3
+ /**
4
+ * Service instance shape returned by Discovery (matches @hazeljs/discovery ServiceInstance)
5
+ */
6
+ export interface GrpcServiceInstanceLike {
7
+ host: string;
8
+ port: number;
9
+ protocol?: 'http' | 'https' | 'grpc';
10
+ }
11
+ /**
12
+ * Discovery client interface for optional Discovery integration.
13
+ * Matches @hazeljs/discovery DiscoveryClient API.
14
+ */
15
+ export interface GrpcDiscoveryClientLike {
16
+ getInstance(serviceName: string, strategy?: string, filter?: {
17
+ zone?: string;
18
+ tags?: string[];
19
+ metadata?: Record<string, unknown>;
20
+ status?: unknown;
21
+ }): Promise<GrpcServiceInstanceLike | null>;
22
+ }
23
+ /**
24
+ * Discovery configuration for GrpcClientService.
25
+ * Used when resolving gRPC service URLs via service discovery.
26
+ */
27
+ export interface GrpcClientDiscoveryConfig {
28
+ /** Discovery client instance (from @hazeljs/discovery) */
29
+ client: GrpcDiscoveryClientLike;
30
+ /** Service name to resolve (e.g. 'product-service') */
31
+ serviceName: string;
32
+ /** Load balancing strategy. @default 'round-robin' */
33
+ loadBalancingStrategy?: string;
34
+ /** Optional filter for service instances (e.g. filter by protocol: 'grpc') */
35
+ filter?: {
36
+ zone?: string;
37
+ tags?: string[];
38
+ metadata?: Record<string, unknown>;
39
+ status?: unknown;
40
+ };
41
+ }
42
+ /**
43
+ * gRPC client configuration options
44
+ */
45
+ export interface GrpcClientOptions {
46
+ /** Path to .proto file(s). Can be a single path or array of paths. */
47
+ protoPath: string | string[];
48
+ /** Package name as defined in the .proto file (e.g. 'hero', 'catalog') */
49
+ package: string;
50
+ /** Default URL for gRPC services when not using Discovery (e.g. 'localhost:50051') */
51
+ defaultUrl?: string;
52
+ /** Options passed to @grpc/proto-loader */
53
+ loader?: ProtoLoaderOptions;
54
+ /** Channel credentials (default: createInsecure) */
55
+ credentials?: ChannelCredentials;
56
+ /** Optional Discovery config for dynamic service resolution */
57
+ discovery?: GrpcClientDiscoveryConfig;
58
+ }
59
+ /**
60
+ * Extended options for GrpcClientModule.forRoot
61
+ */
62
+ export interface GrpcClientModuleConfig extends GrpcClientOptions {
63
+ /** Whether this is a global module. @default true */
64
+ isGlobal?: boolean;
65
+ }
66
+ //# sourceMappingURL=grpc.client.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc.client.types.d.ts","sourceRoot":"","sources":["../src/grpc.client.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,CACT,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,GACA,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,0DAA0D;IAC1D,MAAM,EAAE,uBAAuB,CAAC;IAChC,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,8EAA8E;IAC9E,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,oDAAoD;IACpD,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,yBAAyB,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * @hazeljs/grpc - gRPC module for HazelJS
3
3
  *
4
- * RPC server support with decorator-based handlers.
4
+ * RPC server and client support with decorator-based handlers.
5
5
  * Built on @grpc/grpc-js and @grpc/proto-loader.
6
6
  */
7
7
  export { GrpcModule } from './grpc.module';
8
8
  export { GrpcServer } from './grpc.server';
9
+ export { GrpcClientModule } from './grpc.client.module';
10
+ export { GrpcClientService } from './grpc.client';
9
11
  export { GrpcMethod, getGrpcMethodMetadata } from './decorators/grpc-method.decorator';
10
12
  export type { GrpcModuleOptions, GrpcModuleConfig, GrpcMethodMetadata, ProtoLoaderOptions, GrpcPackageDefinition, } from './grpc.types';
13
+ export type { GrpcClientOptions, GrpcClientModuleConfig, GrpcClientDiscoveryConfig, GrpcDiscoveryClientLike, GrpcServiceInstanceLike, } from './grpc.client.types';
11
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AACvF,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AACvF,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -2,15 +2,19 @@
2
2
  /**
3
3
  * @hazeljs/grpc - gRPC module for HazelJS
4
4
  *
5
- * RPC server support with decorator-based handlers.
5
+ * RPC server and client support with decorator-based handlers.
6
6
  * Built on @grpc/grpc-js and @grpc/proto-loader.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getGrpcMethodMetadata = exports.GrpcMethod = exports.GrpcServer = exports.GrpcModule = void 0;
9
+ exports.getGrpcMethodMetadata = exports.GrpcMethod = exports.GrpcClientService = exports.GrpcClientModule = exports.GrpcServer = exports.GrpcModule = void 0;
10
10
  var grpc_module_1 = require("./grpc.module");
11
11
  Object.defineProperty(exports, "GrpcModule", { enumerable: true, get: function () { return grpc_module_1.GrpcModule; } });
12
12
  var grpc_server_1 = require("./grpc.server");
13
13
  Object.defineProperty(exports, "GrpcServer", { enumerable: true, get: function () { return grpc_server_1.GrpcServer; } });
14
+ var grpc_client_module_1 = require("./grpc.client.module");
15
+ Object.defineProperty(exports, "GrpcClientModule", { enumerable: true, get: function () { return grpc_client_module_1.GrpcClientModule; } });
16
+ var grpc_client_1 = require("./grpc.client");
17
+ Object.defineProperty(exports, "GrpcClientService", { enumerable: true, get: function () { return grpc_client_1.GrpcClientService; } });
14
18
  var grpc_method_decorator_1 = require("./decorators/grpc-method.decorator");
15
19
  Object.defineProperty(exports, "GrpcMethod", { enumerable: true, get: function () { return grpc_method_decorator_1.GrpcMethod; } });
16
20
  Object.defineProperty(exports, "getGrpcMethodMetadata", { enumerable: true, get: function () { return grpc_method_decorator_1.getGrpcMethodMetadata; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/grpc",
3
- "version": "0.2.0-beta.34",
3
+ "version": "0.2.0-beta.35",
4
4
  "description": "gRPC module for HazelJS framework - RPC server and client support with decorators",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -52,5 +52,5 @@
52
52
  "url": "https://github.com/hazeljs/hazel-js/issues"
53
53
  },
54
54
  "homepage": "https://hazeljs.com",
55
- "gitHead": "56191ccdd4a307986c03b3c8bf9f9fc3d5e6548d"
55
+ "gitHead": "e8b3e24b025b079b0d7ec4046bd083c151676215"
56
56
  }