@nexusts/grpc 0.8.2 → 0.8.4

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.
package/dist/index.js.map CHANGED
@@ -2,11 +2,11 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/service.ts", "../src/decorators.ts", "../src/module.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * `GrpcService` — the main gRPC service.\n *\n * Owns the @grpc/grpc-js server, the loaded proto definition, and\n * the registered service implementations. The service is\n * registered in the DI container; the user calls `start()` to\n * bind the server to a port.\n *\n * const grpc = container.resolve(GrpcService);\n * await grpc.start();\n * // ...\n * await grpc.stop();\n *\n * The framework also exposes a `client<T>('ServiceName')` helper\n * for creating typed clients against the same (or a different)\n * server. Clients returned by this method are async — each method\n * returns a Promise (unary) or AsyncIterable (streaming).\n */\n\nimport { existsSync } from \"node:fs\";\nimport {\n\tloadPackageDefinition,\n\tServer as GrpcServer,\n\tServerCredentials,\n} from \"@grpc/grpc-js\";\nimport * as protoLoader from \"@grpc/proto-loader\";\nimport {\n\tgetGrpcMethodEntries,\n\tgetGrpcServiceName,\n} from \"./decorators.js\";\nimport type { GrpcConfig, GrpcStreamType } from \"./types.js\";\n\nexport const GRPC_SERVICE_TOKEN = Symbol.for(\"nexus:GrpcService\");\n\nexport class GrpcService {\n\treadonly name = \"grpc\";\n\t#config: Required<Omit<GrpcConfig, \"tls\" | \"onBound\">> &\n\t\tPick<GrpcConfig, \"tls\" | \"onBound\">;\n\t#server: GrpcServer | null = null;\n\t#bound = false;\n\t#proto: any = null;\n\t#instanceByService: Map<string, unknown> = new Map();\n\t#clientCtors: Map<string, new (url: string, creds: any) => any> = new Map();\n\t#resolve: (<T>(token: unknown) => T) | null = null;\n\t#host: string | null = null;\n\t#port: number | null = null;\n\n\tconstructor(config: GrpcConfig) {\n\t\tthis.#config = {\n\t\t\tprotoPath: config.protoPath,\n\t\t\tpackage: config.package ?? \"\",\n\t\t\tservices: config.services ?? [],\n\t\t\tport: config.port ?? 50051,\n\t\t\thost: config.host ?? \"0.0.0.0\",\n\t\t\ttls: config.tls,\n\t\t\tonBound: config.onBound,\n\t\t};\n\t}\n\n\t/** True if the server is currently bound to a port. */\n\tget isRunning(): boolean {\n\t\treturn this.#bound;\n\t}\n\n\t/** The actual host the server bound to. `null` until start(). */\n\tget host(): string | null {\n\t\treturn this.#host;\n\t}\n\n\t/** Inject a resolver function. Called by GrpcModule.forRoot(). */\n\tsetResolver(resolve: <T>(token: unknown) => T): void {\n\t\tthis.#resolve = resolve;\n\t}\n\n\t/** The actual port the server bound to. `null` until start(). */\n\tget port(): number | null {\n\t\treturn this.#port;\n\t}\n\n\t/**\n\t * Load the .proto file(s) and prepare the server.\n\t * Idempotent — call once at boot, before `start()`.\n\t */\n\tasync prepare(resolve: <T>(token: unknown) => T): Promise<void> {\n\t\t// Load proto(s)\n\t\tconst files = Array.isArray(this.#config.protoPath)\n\t\t\t? this.#config.protoPath\n\t\t\t: [this.#config.protoPath];\n\t\tfor (const f of files) {\n\t\t\tif (!existsSync(f)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[grpc] proto file not found: ${f}. ` +\n\t\t\t\t\t\t`Resolve the path relative to your project root.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst merged: Record<string, unknown> = {};\n\t\tfor (const f of files) {\n\t\t\tconst def = protoLoader.loadSync(f, {\n\t\t\t\tkeepCase: false,\n\t\t\t\tlongs: String,\n\t\t\t\tenums: String,\n\t\t\t\tdefaults: true,\n\t\t\t\toneofs: true,\n\t\t\t});\n\t\t\tconst loaded = loadPackageDefinition(def);\n\t\t\tObject.assign(merged, loaded);\n\t\t}\n\t\tthis.#proto = merged;\n\n\t\t// Build the server and register services\n\t\tthis.#server = new GrpcServer();\n\t\tfor (const ServiceImpl of this.#config.services) {\n\t\t\tconst svcName = getGrpcServiceName(ServiceImpl);\n\t\t\tif (!svcName) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[grpc] service ${ServiceImpl.name} is missing @GrpcService(name)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst methodEntries = getGrpcMethodEntries(ServiceImpl.prototype);\n\n\t\t\t// Walk the package path: proto.<package>.<serviceName>\n\t\t\tconst segments = this.#config.package\n\t\t\t\t? this.#config.package.split(\".\")\n\t\t\t\t: [];\n\t\t\tsegments.push(svcName);\n\t\t\tlet svcSpec:\n\t\t\t\t| { service: any; prototype?: unknown }\n\t\t\t\t| Record<string, unknown>\n\t\t\t\t| undefined = this.#proto as Record<string, unknown>;\n\t\t\tfor (const seg of segments) {\n\t\t\t\tif (svcSpec && typeof svcSpec === \"object\" && seg in svcSpec) {\n\t\t\t\t\tsvcSpec = (svcSpec as Record<string, unknown>)[seg] as typeof svcSpec;\n\t\t\t\t} else {\n\t\t\t\t\tsvcSpec = undefined;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!svcSpec) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[grpc] service \"${segments.join(\".\")}\" not found in proto definition. ` +\n\t\t\t\t\t\t`Check the .proto file and the @GrpcService name.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Resolve the implementation from the DI container\n\t\t\tconst instance = resolve(ServiceImpl);\n\t\t\tthis.#instanceByService.set(svcName, instance);\n\n\t\t\t// Build the handler map for every decorated method\n\t\t\tconst handlers: Record<string, any> = {};\n\t\t\tfor (const [methodKey, entry] of Object.entries(methodEntries)) {\n\t\t\t\tconst fn = (\n\t\t\t\t\tinstance as Record<string, (...args: unknown[]) => unknown>\n\t\t\t\t)[methodKey];\n\t\t\t\tif (typeof fn !== \"function\") continue;\n\n\t\t\t\thandlers[entry.protoName] = makeHandler(fn, instance, entry.streamType);\n\t\t\t}\n\n\t\t\tthis.#server!.addService((svcSpec as { service: any }).service, handlers);\n\t\t\tthis.#clientCtors.set(\n\t\t\t\tsvcName,\n\t\t\t\tsvcSpec as unknown as new (...a: any[]) => any,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Bind the server to the configured host/port.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.#resolve && !this.#server) {\n\t\t\tawait this.prepare(this.#resolve);\n\t\t}\n\t\tif (!this.#server) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[grpc] start() called before prepare(). Call prepare() first \" +\n\t\t\t\t\t\"(typically done automatically by the DI module).\",\n\t\t\t);\n\t\t}\n\t\tif (this.isRunning) return;\n\n\t\tconst creds = this.#config.tls\n\t\t\t? ServerCredentials.createSsl(\n\t\t\t\t\tthis.#config.tls.cert as Buffer,\n\t\t\t\t\tArray.isArray(this.#config.tls.key)\n\t\t\t\t\t\t? this.#config.tls.key[0]\n\t\t\t\t\t\t: (this.#config.tls.key as Buffer),\n\t\t\t\t)\n\t\t\t: ServerCredentials.createInsecure();\n\n\t\tconst port: number = await new Promise((resolveP, rejectP) => {\n\t\t\t(this.#server as GrpcServer).bindAsync(\n\t\t\t\t`${this.#config.host}:${this.#config.port}`,\n\t\t\t\tcreds,\n\t\t\t\t(err: Error | null, p: number) => {\n\t\t\t\t\treturn err ? rejectP(err) : resolveP(p);\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t\tthis.#host = this.#config.host;\n\t\tthis.#port = port;\n\t\tthis.#bound = true;\n\t\tconsole.log(\n\t\t\t`✓ gRPC server listening on ${this.#config.tls ? \"https\" : \"http\"}://${this.#host}:${this.#port}`,\n\t\t);\n\t\tthis.#config.onBound?.(this.#host, this.#port);\n\t}\n\n\t/** Stop the server and release the port. */\n\tasync stop(): Promise<void> {\n\t\tif (!this.#server) return;\n\t\tawait Promise.race([\n\t\t\tnew Promise<void>((resolveP, rejectP) => {\n\t\t\t\t(this.#server as GrpcServer).tryShutdown((err?: Error) =>\n\t\t\t\t\terr ? rejectP(err) : resolveP(),\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew Promise<void>((resolveP) => setTimeout(resolveP, 1000)),\n\t\t]).catch(() => {\n\t\t\t(this.#server as GrpcServer).forceShutdown();\n\t\t});\n\t\tthis.#server = null;\n\t\tthis.#host = null;\n\t\tthis.#port = null;\n\t\tthis.#bound = false;\n\t}\n\n\t/**\n\t * Build a typed client for a gRPC service.\n\t *\n\t * Method wrappers by call type:\n\t * - **Unary** — `(req: TReq) => Promise<TRes>`\n\t * - **Server stream** — `(req: TReq) => AsyncIterable<TRes>`\n\t * - **Client stream** — `(src: AsyncIterable<TReq>) => Promise<TRes>`\n\t * - **Bidi stream** — `(src: AsyncIterable<TReq>) => AsyncIterable<TRes>`\n\t */\n\tclient<T = Record<string, (...args: unknown[]) => unknown>>(\n\t\tserviceName: string,\n\t\toptions: { url: string; tls?: boolean } = {\n\t\t\turl: `127.0.0.1:${this.#port ?? 50051}`,\n\t\t},\n\t): T {\n\t\tif (!this.#proto) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[grpc] client() called before prepare(). \" +\n\t\t\t\t\t\"Did you forget to call grpc.start()?\",\n\t\t\t);\n\t\t}\n\t\tconst segments = this.#config.package\n\t\t\t? this.#config.package.split(\".\")\n\t\t\t: [];\n\t\tsegments.push(serviceName);\n\t\tlet svcSpec:\n\t\t\t| { service: any; prototype?: unknown }\n\t\t\t| Record<string, unknown>\n\t\t\t| undefined = this.#proto as Record<string, unknown>;\n\t\tfor (const seg of segments) {\n\t\t\tif (svcSpec && typeof svcSpec === \"object\" && seg in svcSpec) {\n\t\t\t\tsvcSpec = (svcSpec as Record<string, unknown>)[seg] as typeof svcSpec;\n\t\t\t} else {\n\t\t\t\tsvcSpec = undefined;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!svcSpec) {\n\t\t\tthrow new Error(\n\t\t\t\t`[grpc] service \"${segments.join(\".\")}\" not found in proto definition`,\n\t\t\t);\n\t\t}\n\n\t\tconst ClientCtor = svcSpec as unknown as {\n\t\t\tnew (url: string, creds: unknown): Record<\n\t\t\t\tstring,\n\t\t\t\t(...args: unknown[]) => unknown\n\t\t\t>;\n\t\t\tservice: Record<\n\t\t\t\tstring,\n\t\t\t\t{ requestStream: boolean; responseStream: boolean }\n\t\t\t>;\n\t\t};\n\n\t\tconst creds = options.tls\n\t\t\t? // @ts-ignore\n\t\t\t\trequire(\"@grpc/grpc-js\").credentials.createSsl()\n\t\t\t: // @ts-ignore\n\t\t\t\trequire(\"@grpc/grpc-js\").credentials.createInsecure();\n\n\t\tconst underlying = new ClientCtor(options.url, creds);\n\t\tconst wrapped: Record<string, (...args: unknown[]) => unknown> = {};\n\n\t\tfor (const [protoName, methodDef] of Object.entries(ClientCtor.service)) {\n\t\t\tconst { requestStream, responseStream } = methodDef;\n\t\t\t// gRPC proto names are PascalCase; JS clients expose camelCase\n\t\t\tconst methodName =\n\t\t\t\tprotoName.charAt(0).toLowerCase() + protoName.slice(1);\n\n\t\t\t// @ts-ignore — method exists on prototype at runtime\n\t\t\tconst fn = underlying[methodName];\n\t\t\tif (typeof fn !== \"function\") continue;\n\n\t\t\tconst streamType = classifyStreamType(requestStream, responseStream);\n\t\t\twrapped[methodName] = makeClientMethod(fn, underlying, streamType);\n\t\t}\n\n\t\treturn wrapped as unknown as T;\n\t}\n}\n\n// ── Server-side handler factories ─────────────────────────────────────────────\n\nfunction makeHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n\tstreamType: GrpcStreamType,\n): (...args: unknown[]) => void {\n\tswitch (streamType) {\n\t\tcase \"unary\":\n\t\t\treturn makeUnaryHandler(fn, instance);\n\t\tcase \"server\":\n\t\t\treturn makeServerStreamHandler(fn, instance);\n\t\tcase \"client\":\n\t\t\treturn makeClientStreamHandler(fn, instance);\n\t\tcase \"bidi\":\n\t\t\treturn makeBidiStreamHandler(fn, instance);\n\t}\n}\n\n/** Unary: (call, callback) => void */\nfunction makeUnaryHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: unknown, callback: (err: unknown, res?: unknown) => void) => {\n\t\tconst req = (call as { request: unknown }).request;\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = fn.call(instance, req);\n\t\t} catch (syncErr) {\n\t\t\tconst e = syncErr as Error & { code?: number };\n\t\t\tcallback({ code: e.code ?? 13, details: e.message });\n\t\t\treturn;\n\t\t}\n\t\tPromise.resolve(result).then(\n\t\t\t(value) => callback(null, value),\n\t\t\t(err: Error & { code?: number }) => {\n\t\t\t\tcallback({ code: err.code ?? 13, details: err.message });\n\t\t\t},\n\t\t);\n\t};\n}\n\n/** Server streaming: (call) => void — method returns AsyncIterable<TRes> */\nfunction makeServerStreamHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: any) => {\n\t\tconst req = call.request;\n\t\tlet iter: AsyncIterable<unknown>;\n\t\ttry {\n\t\t\titer = fn.call(instance, req) as AsyncIterable<unknown>;\n\t\t} catch (syncErr) {\n\t\t\tconst e = syncErr as Error & { code?: number };\n\t\t\tcall.emit(\"error\", { code: e.code ?? 13, details: e.message });\n\t\t\treturn;\n\t\t}\n\t\t(async () => {\n\t\t\tfor await (const item of iter) {\n\t\t\t\tcall.write(item);\n\t\t\t}\n\t\t\tcall.end();\n\t\t})().catch((err: Error & { code?: number }) => {\n\t\t\tcall.emit(\"error\", { code: err?.code ?? 13, details: err?.message ?? \"Internal error\" });\n\t\t});\n\t};\n}\n\n/** Client streaming: (call, callback) => void — method takes AsyncIterable<TReq> */\nfunction makeClientStreamHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: any, callback: (err: unknown, res?: unknown) => void) => {\n\t\tasync function* iterRequest() {\n\t\t\tfor await (const msg of call) {\n\t\t\t\tyield msg;\n\t\t\t}\n\t\t}\n\t\tPromise.resolve(fn.call(instance, iterRequest())).then(\n\t\t\t(result) => callback(null, result),\n\t\t\t(err: Error & { code?: number }) => {\n\t\t\t\tcallback({ code: err?.code ?? 13, details: err?.message ?? \"Internal error\" });\n\t\t\t},\n\t\t);\n\t};\n}\n\n/** Bidirectional streaming: (call) => void — method takes AsyncIterable<TReq>, returns AsyncIterable<TRes> */\nfunction makeBidiStreamHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: any) => {\n\t\t// Use event-based reading — Symbol.asyncIterator on ServerDuplexStream\n\t\t// conflicts with concurrent call.write() on the same object.\n\t\tconst queue: unknown[] = [];\n\t\tlet readEnded = false;\n\t\tlet readError: Error | null = null;\n\t\tlet readWakeup: (() => void) | null = null;\n\t\tconst notifyRead = () => { readWakeup?.(); readWakeup = null; };\n\n\t\tcall.on(\"data\", (msg: unknown) => { queue.push(msg); notifyRead(); });\n\t\tcall.on(\"end\", () => { readEnded = true; notifyRead(); });\n\t\tcall.on(\"error\", (err: Error) => { readError = err; notifyRead(); });\n\n\t\tasync function* iterRequest() {\n\t\t\twhile (true) {\n\t\t\t\twhile (queue.length > 0) yield queue.shift()!;\n\t\t\t\tif (readEnded) break;\n\t\t\t\tif (readError) throw readError;\n\t\t\t\tawait new Promise<void>((r) => { readWakeup = r; });\n\t\t\t}\n\t\t}\n\n\t\tlet iter: AsyncIterable<unknown>;\n\t\ttry {\n\t\t\titer = fn.call(instance, iterRequest()) as AsyncIterable<unknown>;\n\t\t} catch (syncErr) {\n\t\t\tconst e = syncErr as Error & { code?: number };\n\t\t\tcall.emit(\"error\", { code: e.code ?? 13, details: e.message });\n\t\t\treturn;\n\t\t}\n\t\t(async () => {\n\t\t\tfor await (const item of iter) {\n\t\t\t\tcall.write(item);\n\t\t\t}\n\t\t\tcall.end();\n\t\t})().catch((err: Error & { code?: number }) => {\n\t\t\tcall.emit(\"error\", { code: err?.code ?? 13, details: err?.message ?? \"Internal error\" });\n\t\t});\n\t};\n}\n\n// ── Client-side method wrappers ───────────────────────────────────────────────\n\nfunction classifyStreamType(\n\trequestStream: boolean,\n\tresponseStream: boolean,\n): GrpcStreamType {\n\tif (!requestStream && !responseStream) return \"unary\";\n\tif (!requestStream && responseStream) return \"server\";\n\tif (requestStream && !responseStream) return \"client\";\n\treturn \"bidi\";\n}\n\nfunction makeClientMethod(\n\tfn: (...args: unknown[]) => unknown,\n\tunderlying: Record<string, (...args: unknown[]) => unknown>,\n\tstreamType: GrpcStreamType,\n): (...args: unknown[]) => unknown {\n\tswitch (streamType) {\n\t\tcase \"unary\":\n\t\t\treturn (req: unknown) =>\n\t\t\t\tnew Promise((resolveP, rejectP) => {\n\t\t\t\t\t(fn as any).call(underlying, req, (err: Error | null, res: unknown) => {\n\t\t\t\t\t\tif (err) rejectP(err);\n\t\t\t\t\t\telse resolveP(res);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\tcase \"server\":\n\t\t\treturn (req: unknown): AsyncIterable<unknown> => {\n\t\t\t\tconst call = (fn as any).call(underlying, req);\n\t\t\t\treturn readableToAsyncIter(call);\n\t\t\t};\n\n\t\tcase \"client\":\n\t\t\treturn (source: unknown): Promise<unknown> =>\n\t\t\t\tnew Promise((resolveP, rejectP) => {\n\t\t\t\t\tconst call = (fn as any).call(\n\t\t\t\t\t\tunderlying,\n\t\t\t\t\t\t(err: Error | null, res: unknown) => {\n\t\t\t\t\t\t\tif (err) rejectP(err);\n\t\t\t\t\t\t\telse resolveP(res);\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\tfor await (const msg of source as AsyncIterable<unknown>) {\n\t\t\t\t\t\t\tcall.write(msg);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcall.end();\n\t\t\t\t\t})().catch(rejectP);\n\t\t\t\t});\n\n\t\tcase \"bidi\":\n\t\t\treturn (source: unknown): AsyncIterable<unknown> =>\n\t\t\t\tbidiClientImpl(fn as any, underlying, source as AsyncIterable<unknown>);\n\t}\n}\n\nasync function* bidiClientImpl(\n\tfn: (...args: any[]) => any,\n\tunderlying: Record<string, (...args: unknown[]) => unknown>,\n\tsource: AsyncIterable<unknown>,\n): AsyncIterable<unknown> {\n\tconst call = fn.call(underlying);\n\n\t// Collect responses via event listeners into a queue so that\n\t// the write-side can run concurrently without stream backpressure\n\t// issues that arise from using Symbol.asyncIterator on a Duplex.\n\tconst queue: unknown[] = [];\n\tlet ended = false;\n\tlet streamError: Error | null = null;\n\tlet wakeup: (() => void) | null = null;\n\n\tconst notify = () => { wakeup?.(); wakeup = null; };\n\tcall.on(\"data\", (msg: unknown) => { queue.push(msg); notify(); });\n\tcall.on(\"end\", () => { ended = true; notify(); });\n\tcall.on(\"error\", (err: Error) => { streamError = err; notify(); });\n\n\t// Write from source in background — runs concurrently with the read loop\n\tconst writeTask = (async () => {\n\t\ttry {\n\t\t\tfor await (const msg of source) {\n\t\t\t\tcall.write(msg);\n\t\t\t}\n\t\t} finally {\n\t\t\tcall.end();\n\t\t}\n\t})();\n\n\t// Yield messages as they arrive\n\twhile (true) {\n\t\twhile (queue.length > 0) yield queue.shift()!;\n\t\tif (ended) break;\n\t\tif (streamError) throw streamError;\n\t\tawait new Promise<void>((r) => { wakeup = r; });\n\t}\n\tawait writeTask;\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Convert a gRPC ClientReadableStream (or DuplexStream) to an AsyncIterable.\n * grpc-js streams extend Node.js Readable, which supports `for await...of`\n * via Symbol.asyncIterator.\n */\nasync function* readableToAsyncIter(stream: any): AsyncIterable<unknown> {\n\t// Use Symbol.asyncIterator if available (Node.js 10+ / Bun)\n\tif (typeof stream[Symbol.asyncIterator] === \"function\") {\n\t\tfor await (const msg of stream) {\n\t\t\tyield msg;\n\t\t}\n\t\treturn;\n\t}\n\t// Fallback: event-based conversion\n\tlet done = false;\n\tlet error: Error | null = null;\n\tconst buffer: unknown[] = [];\n\tlet resolve: (() => void) | null = null;\n\n\tstream.on(\"data\", (msg: unknown) => {\n\t\tbuffer.push(msg);\n\t\tresolve?.();\n\t\tresolve = null;\n\t});\n\tstream.on(\"end\", () => {\n\t\tdone = true;\n\t\tresolve?.();\n\t\tresolve = null;\n\t});\n\tstream.on(\"error\", (err: Error) => {\n\t\terror = err;\n\t\tresolve?.();\n\t\tresolve = null;\n\t});\n\n\twhile (true) {\n\t\twhile (buffer.length > 0) {\n\t\t\tyield buffer.shift()!;\n\t\t}\n\t\tif (done) break;\n\t\tif (error) throw error;\n\t\tawait new Promise<void>((r) => {\n\t\t\tresolve = r;\n\t\t});\n\t}\n}\n\nexport default GrpcService;\n",
5
+ "/**\n * `GrpcService` — the main gRPC service.\n *\n * Owns the @grpc/grpc-js server, the loaded proto definition, and\n * the registered service implementations. The service is\n * registered in the DI container; the user calls `start()` to\n * bind the server to a port.\n *\n * const grpc = container.resolve(GrpcService);\n * await grpc.start();\n * // ...\n * await grpc.stop();\n *\n * The framework also exposes a `client<T>('ServiceName')` helper\n * for creating typed clients against the same (or a different)\n * server. Clients returned by this method are async — each method\n * returns a Promise (unary) or AsyncIterable (streaming).\n */\n\nimport { existsSync } from \"node:fs\";\nimport {\n\tloadPackageDefinition,\n\tServer as GrpcServer,\n\tServerCredentials,\n} from \"@grpc/grpc-js\";\nimport * as protoLoader from \"@grpc/proto-loader\";\nimport {\n\tgetGrpcMethodEntries,\n\tgetGrpcServiceName,\n} from \"./decorators.js\";\nimport type { GrpcConfig, GrpcStreamType } from \"./types.js\";\n\nexport const GRPC_SERVICE_TOKEN = Symbol.for(\"nexus:GrpcService\");\n\nexport class GrpcService {\n\treadonly name = \"grpc\";\n\t#config: Required<Omit<GrpcConfig, \"tls\" | \"onBound\">> &\n\t\tPick<GrpcConfig, \"tls\" | \"onBound\">;\n\t#server: GrpcServer | null = null;\n\t#bound = false;\n\t#proto: any = null;\n\t#instanceByService: Map<string, unknown> = new Map();\n\t#clientCtors: Map<string, new (url: string, creds: any) => any> = new Map();\n\t#resolve: (<T>(token: unknown) => T) | null = null;\n\t#host: string | null = null;\n\t#port: number | null = null;\n\n\tconstructor(config: GrpcConfig) {\n\t\tthis.#config = {\n\t\t\tprotoPath: config.protoPath,\n\t\t\tpackage: config.package ?? \"\",\n\t\t\tservices: config.services ?? [],\n\t\t\tport: config.port ?? 50051,\n\t\t\thost: config.host ?? \"0.0.0.0\",\n\t\t\ttls: config.tls,\n\t\t\tonBound: config.onBound,\n\t\t};\n\t}\n\n\t/** True if the server is currently bound to a port. */\n\tget isRunning(): boolean {\n\t\treturn this.#bound;\n\t}\n\n\t/** The actual host the server bound to. `null` until start(). */\n\tget host(): string | null {\n\t\treturn this.#host;\n\t}\n\n\t/** Inject a resolver function. Called by GrpcModule.forRoot(). */\n\tsetResolver(resolve: <T>(token: unknown) => T): void {\n\t\tthis.#resolve = resolve;\n\t}\n\n\t/** The actual port the server bound to. `null` until start(). */\n\tget port(): number | null {\n\t\treturn this.#port;\n\t}\n\n\t/**\n\t * Load the .proto file(s) and prepare the server.\n\t * Idempotent — call once at boot, before `start()`.\n\t */\n\tasync prepare(resolve: <T>(token: unknown) => T): Promise<void> {\n\t\t// Load proto(s)\n\t\tconst files = Array.isArray(this.#config.protoPath)\n\t\t\t? this.#config.protoPath\n\t\t\t: [this.#config.protoPath];\n\t\tfor (const f of files) {\n\t\t\tif (!existsSync(f)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[grpc] proto file not found: ${f}. ` +\n\t\t\t\t\t\t`Resolve the path relative to your project root.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst merged: Record<string, unknown> = {};\n\t\tfor (const f of files) {\n\t\t\tconst def = protoLoader.loadSync(f, {\n\t\t\t\tkeepCase: false,\n\t\t\t\tlongs: String,\n\t\t\t\tenums: String,\n\t\t\t\tdefaults: true,\n\t\t\t\toneofs: true,\n\t\t\t});\n\t\t\tconst loaded = loadPackageDefinition(def);\n\t\t\tObject.assign(merged, loaded);\n\t\t}\n\t\tthis.#proto = merged;\n\n\t\t// Build the server and register services\n\t\tthis.#server = new GrpcServer();\n\t\tfor (const ServiceImpl of this.#config.services) {\n\t\t\tconst svcName = getGrpcServiceName(ServiceImpl);\n\t\t\tif (!svcName) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[grpc] service ${ServiceImpl.name} is missing @GrpcService(name)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst methodEntries = getGrpcMethodEntries(ServiceImpl.prototype);\n\n\t\t\t// Walk the package path: proto.<package>.<serviceName>\n\t\t\tconst segments = this.#config.package\n\t\t\t\t? this.#config.package.split(\".\")\n\t\t\t\t: [];\n\t\t\tsegments.push(svcName);\n\t\t\tlet svcSpec:\n\t\t\t\t| { service: any; prototype?: unknown }\n\t\t\t\t| Record<string, unknown>\n\t\t\t\t| undefined = this.#proto as Record<string, unknown>;\n\t\t\tfor (const seg of segments) {\n\t\t\t\tif (svcSpec && typeof svcSpec === \"object\" && seg in svcSpec) {\n\t\t\t\t\tsvcSpec = (svcSpec as Record<string, unknown>)[seg] as typeof svcSpec;\n\t\t\t\t} else {\n\t\t\t\t\tsvcSpec = undefined;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!svcSpec) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[grpc] service \"${segments.join(\".\")}\" not found in proto definition. ` +\n\t\t\t\t\t\t`Check the .proto file and the @GrpcService name.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Resolve the implementation from the DI container\n\t\t\tconst instance = resolve(ServiceImpl);\n\t\t\tthis.#instanceByService.set(svcName, instance);\n\n\t\t\t// Build the handler map for every decorated method\n\t\t\tconst handlers: Record<string, any> = {};\n\t\t\tfor (const [methodKey, entry] of Object.entries(methodEntries)) {\n\t\t\t\tconst fn = (\n\t\t\t\t\tinstance as Record<string, (...args: unknown[]) => unknown>\n\t\t\t\t)[methodKey];\n\t\t\t\tif (typeof fn !== \"function\") continue;\n\n\t\t\t\thandlers[entry.protoName] = makeHandler(fn, instance, entry.streamType);\n\t\t\t}\n\n\t\t\tthis.#server!.addService((svcSpec as { service: any }).service, handlers);\n\t\t\tthis.#clientCtors.set(\n\t\t\t\tsvcName,\n\t\t\t\tsvcSpec as unknown as new (...a: any[]) => any,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Bind the server to the configured host/port.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.#resolve && !this.#server) {\n\t\t\tawait this.prepare(this.#resolve);\n\t\t}\n\t\tif (!this.#server) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[grpc] start() called before prepare(). Call prepare() first \" +\n\t\t\t\t\t\"(typically done automatically by the DI module).\",\n\t\t\t);\n\t\t}\n\t\tif (this.isRunning) return;\n\n\t\tconst creds = this.#config.tls\n\t\t\t? ServerCredentials.createSsl(\n\t\t\t\t\tthis.#config.tls.cert as Buffer,\n\t\t\t\t\tArray.isArray(this.#config.tls.key)\n\t\t\t\t\t\t? this.#config.tls.key[0]\n\t\t\t\t\t\t: (this.#config.tls.key as Buffer),\n\t\t\t\t)\n\t\t\t: ServerCredentials.createInsecure();\n\n\t\tconst port: number = await new Promise((resolveP, rejectP) => {\n\t\t\t(this.#server as GrpcServer).bindAsync(\n\t\t\t\t`${this.#config.host}:${this.#config.port}`,\n\t\t\t\tcreds,\n\t\t\t\t(err: Error | null, p: number) => {\n\t\t\t\t\treturn err ? rejectP(err) : resolveP(p);\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t\tthis.#host = this.#config.host;\n\t\tthis.#port = port;\n\t\tthis.#bound = true;\n\t\tconsole.log(\n\t\t\t`✓ gRPC server listening on ${this.#config.tls ? \"https\" : \"http\"}://${this.#host}:${this.#port}`,\n\t\t);\n\t\tthis.#config.onBound?.(this.#host, this.#port);\n\t}\n\n\t/** Stop the server and release the port. */\n\tasync stop(): Promise<void> {\n\t\tif (!this.#server) return;\n\t\tawait Promise.race([\n\t\t\tnew Promise<void>((resolveP, rejectP) => {\n\t\t\t\t(this.#server as GrpcServer).tryShutdown((err?: Error) =>\n\t\t\t\t\terr ? rejectP(err) : resolveP(),\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew Promise<void>((resolveP) => setTimeout(resolveP, 1000)),\n\t\t]).catch(() => {\n\t\t\t(this.#server as GrpcServer).forceShutdown();\n\t\t});\n\t\tthis.#server = null;\n\t\tthis.#host = null;\n\t\tthis.#port = null;\n\t\tthis.#bound = false;\n\t}\n\n\t/**\n\t * Build a typed client for a gRPC service.\n\t *\n\t * Method wrappers by call type:\n\t * - **Unary** — `(req: TReq) => Promise<TRes>`\n\t * - **Server stream** — `(req: TReq) => AsyncIterable<TRes>`\n\t * - **Client stream** — `(src: AsyncIterable<TReq>) => Promise<TRes>`\n\t * - **Bidi stream** — `(src: AsyncIterable<TReq>) => AsyncIterable<TRes>`\n\t */\n\tclient<T = Record<string, (...args: unknown[]) => unknown>>(\n\t\tserviceName: string,\n\t\toptions: { url: string; tls?: boolean } = {\n\t\t\turl: `127.0.0.1:${this.#port ?? 50051}`,\n\t\t},\n\t): T {\n\t\tif (!this.#proto) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[grpc] client() called before prepare(). \" +\n\t\t\t\t\t\"Did you forget to call grpc.start()?\",\n\t\t\t);\n\t\t}\n\t\tconst segments = this.#config.package\n\t\t\t? this.#config.package.split(\".\")\n\t\t\t: [];\n\t\tsegments.push(serviceName);\n\t\tlet svcSpec:\n\t\t\t| { service: any; prototype?: unknown }\n\t\t\t| Record<string, unknown>\n\t\t\t| undefined = this.#proto as Record<string, unknown>;\n\t\tfor (const seg of segments) {\n\t\t\tif (svcSpec && typeof svcSpec === \"object\" && seg in svcSpec) {\n\t\t\t\tsvcSpec = (svcSpec as Record<string, unknown>)[seg] as typeof svcSpec;\n\t\t\t} else {\n\t\t\t\tsvcSpec = undefined;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!svcSpec) {\n\t\t\tthrow new Error(\n\t\t\t\t`[grpc] service \"${segments.join(\".\")}\" not found in proto definition`,\n\t\t\t);\n\t\t}\n\n\t\tconst ClientCtor = svcSpec as unknown as {\n\t\t\tnew (url: string, creds: unknown): Record<\n\t\t\t\tstring,\n\t\t\t\t(...args: unknown[]) => unknown\n\t\t\t>;\n\t\t\tservice: Record<\n\t\t\t\tstring,\n\t\t\t\t{ requestStream: boolean; responseStream: boolean }\n\t\t\t>;\n\t\t};\n\n\t\tconst creds = options.tls\n\t\t\t? // @ts-ignore\n\t\t\t\trequire(\"@grpc/grpc-js\").credentials.createSsl()\n\t\t\t: // @ts-ignore\n\t\t\t\trequire(\"@grpc/grpc-js\").credentials.createInsecure();\n\n\t\tconst underlying = new ClientCtor(options.url, creds);\n\t\tconst wrapped: Record<string, (...args: unknown[]) => unknown> = {};\n\n\t\tfor (const [protoName, methodDef] of Object.entries(ClientCtor.service)) {\n\t\t\tconst { requestStream, responseStream } = methodDef;\n\t\t\t// gRPC proto names are PascalCase; JS clients expose camelCase\n\t\t\tconst methodName =\n\t\t\t\tprotoName.charAt(0).toLowerCase() + protoName.slice(1);\n\n\t\t\t// @ts-ignore — method exists on prototype at runtime\n\t\t\tconst fn = underlying[methodName];\n\t\t\tif (typeof fn !== \"function\") continue;\n\n\t\t\tconst streamType = classifyStreamType(requestStream, responseStream);\n\t\t\twrapped[methodName] = makeClientMethod(fn, underlying, streamType);\n\t\t}\n\n\t\treturn wrapped as unknown as T;\n\t}\n}\n\n// ── Server-side handler factories ─────────────────────────────────────────────\n\nfunction makeHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n\tstreamType: GrpcStreamType,\n): Function {\n\tswitch (streamType) {\n\t\tcase \"unary\":\n\t\t\treturn makeUnaryHandler(fn, instance);\n\t\tcase \"server\":\n\t\t\treturn makeServerStreamHandler(fn, instance);\n\t\tcase \"client\":\n\t\t\treturn makeClientStreamHandler(fn, instance);\n\t\tcase \"bidi\":\n\t\t\treturn makeBidiStreamHandler(fn, instance);\n\t}\n}\n\n/** Unary: (call, callback) => void */\nfunction makeUnaryHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: unknown, callback: (err: unknown, res?: unknown) => void) => {\n\t\tconst req = (call as { request: unknown }).request;\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = fn.call(instance, req);\n\t\t} catch (syncErr) {\n\t\t\tconst e = syncErr as Error & { code?: number };\n\t\t\tcallback({ code: e.code ?? 13, details: e.message });\n\t\t\treturn;\n\t\t}\n\t\tPromise.resolve(result).then(\n\t\t\t(value) => callback(null, value),\n\t\t\t(err: Error & { code?: number }) => {\n\t\t\t\tcallback({ code: err.code ?? 13, details: err.message });\n\t\t\t},\n\t\t);\n\t};\n}\n\n/** Server streaming: (call) => void — method returns AsyncIterable<TRes> */\nfunction makeServerStreamHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: any) => {\n\t\tconst req = call.request;\n\t\tlet iter: AsyncIterable<unknown>;\n\t\ttry {\n\t\t\titer = fn.call(instance, req) as AsyncIterable<unknown>;\n\t\t} catch (syncErr) {\n\t\t\tconst e = syncErr as Error & { code?: number };\n\t\t\tcall.emit(\"error\", { code: e.code ?? 13, details: e.message });\n\t\t\treturn;\n\t\t}\n\t\t(async () => {\n\t\t\tfor await (const item of iter) {\n\t\t\t\tcall.write(item);\n\t\t\t}\n\t\t\tcall.end();\n\t\t})().catch((err: Error & { code?: number }) => {\n\t\t\tcall.emit(\"error\", { code: err?.code ?? 13, details: err?.message ?? \"Internal error\" });\n\t\t});\n\t};\n}\n\n/** Client streaming: (call, callback) => void — method takes AsyncIterable<TReq> */\nfunction makeClientStreamHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: any, callback: (err: unknown, res?: unknown) => void) => {\n\t\tasync function* iterRequest() {\n\t\t\tfor await (const msg of call) {\n\t\t\t\tyield msg;\n\t\t\t}\n\t\t}\n\t\tPromise.resolve(fn.call(instance, iterRequest())).then(\n\t\t\t(result) => callback(null, result),\n\t\t\t(err: Error & { code?: number }) => {\n\t\t\t\tcallback({ code: err?.code ?? 13, details: err?.message ?? \"Internal error\" });\n\t\t\t},\n\t\t);\n\t};\n}\n\n/** Bidirectional streaming: (call) => void — method takes AsyncIterable<TReq>, returns AsyncIterable<TRes> */\nfunction makeBidiStreamHandler(\n\tfn: (...args: unknown[]) => unknown,\n\tinstance: unknown,\n) {\n\treturn (call: any) => {\n\t\t// Use event-based reading — Symbol.asyncIterator on ServerDuplexStream\n\t\t// conflicts with concurrent call.write() on the same object.\n\t\tconst queue: unknown[] = [];\n\t\tlet readEnded = false;\n\t\tlet readError: Error | null = null;\n\t\tlet readWakeup: (() => void) | null = null;\n\t\tconst notifyRead = () => { readWakeup?.(); readWakeup = null; };\n\n\t\tcall.on(\"data\", (msg: unknown) => { queue.push(msg); notifyRead(); });\n\t\tcall.on(\"end\", () => { readEnded = true; notifyRead(); });\n\t\tcall.on(\"error\", (err: Error) => { readError = err; notifyRead(); });\n\n\t\tasync function* iterRequest() {\n\t\t\twhile (true) {\n\t\t\t\twhile (queue.length > 0) yield queue.shift()!;\n\t\t\t\tif (readEnded) break;\n\t\t\t\tif (readError) throw readError;\n\t\t\t\tawait new Promise<void>((r) => { readWakeup = r; });\n\t\t\t}\n\t\t}\n\n\t\tlet iter: AsyncIterable<unknown>;\n\t\ttry {\n\t\t\titer = fn.call(instance, iterRequest()) as AsyncIterable<unknown>;\n\t\t} catch (syncErr) {\n\t\t\tconst e = syncErr as Error & { code?: number };\n\t\t\tcall.emit(\"error\", { code: e.code ?? 13, details: e.message });\n\t\t\treturn;\n\t\t}\n\t\t(async () => {\n\t\t\tfor await (const item of iter) {\n\t\t\t\tcall.write(item);\n\t\t\t}\n\t\t\tcall.end();\n\t\t})().catch((err: Error & { code?: number }) => {\n\t\t\tcall.emit(\"error\", { code: err?.code ?? 13, details: err?.message ?? \"Internal error\" });\n\t\t});\n\t};\n}\n\n// ── Client-side method wrappers ───────────────────────────────────────────────\n\nfunction classifyStreamType(\n\trequestStream: boolean,\n\tresponseStream: boolean,\n): GrpcStreamType {\n\tif (!requestStream && !responseStream) return \"unary\";\n\tif (!requestStream && responseStream) return \"server\";\n\tif (requestStream && !responseStream) return \"client\";\n\treturn \"bidi\";\n}\n\nfunction makeClientMethod(\n\tfn: (...args: unknown[]) => unknown,\n\tunderlying: Record<string, (...args: unknown[]) => unknown>,\n\tstreamType: GrpcStreamType,\n): (...args: unknown[]) => unknown {\n\tswitch (streamType) {\n\t\tcase \"unary\":\n\t\t\treturn (req: unknown) =>\n\t\t\t\tnew Promise((resolveP, rejectP) => {\n\t\t\t\t\t(fn as any).call(underlying, req, (err: Error | null, res: unknown) => {\n\t\t\t\t\t\tif (err) rejectP(err);\n\t\t\t\t\t\telse resolveP(res);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\tcase \"server\":\n\t\t\treturn (req: unknown): AsyncIterable<unknown> => {\n\t\t\t\tconst call = (fn as any).call(underlying, req);\n\t\t\t\treturn readableToAsyncIter(call);\n\t\t\t};\n\n\t\tcase \"client\":\n\t\t\treturn (source: unknown): Promise<unknown> =>\n\t\t\t\tnew Promise((resolveP, rejectP) => {\n\t\t\t\t\tconst call = (fn as any).call(\n\t\t\t\t\t\tunderlying,\n\t\t\t\t\t\t(err: Error | null, res: unknown) => {\n\t\t\t\t\t\t\tif (err) rejectP(err);\n\t\t\t\t\t\t\telse resolveP(res);\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\tfor await (const msg of source as AsyncIterable<unknown>) {\n\t\t\t\t\t\t\tcall.write(msg);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcall.end();\n\t\t\t\t\t})().catch(rejectP);\n\t\t\t\t});\n\n\t\tcase \"bidi\":\n\t\t\treturn (source: unknown): AsyncIterable<unknown> =>\n\t\t\t\tbidiClientImpl(fn as any, underlying, source as AsyncIterable<unknown>);\n\t}\n}\n\nasync function* bidiClientImpl(\n\tfn: (...args: any[]) => any,\n\tunderlying: Record<string, (...args: unknown[]) => unknown>,\n\tsource: AsyncIterable<unknown>,\n): AsyncIterable<unknown> {\n\tconst call = fn.call(underlying);\n\n\t// Collect responses via event listeners into a queue so that\n\t// the write-side can run concurrently without stream backpressure\n\t// issues that arise from using Symbol.asyncIterator on a Duplex.\n\tconst queue: unknown[] = [];\n\tlet ended = false;\n\tlet streamError: Error | null = null;\n\tlet wakeup: (() => void) | null = null;\n\n\tconst notify = () => { wakeup?.(); wakeup = null; };\n\tcall.on(\"data\", (msg: unknown) => { queue.push(msg); notify(); });\n\tcall.on(\"end\", () => { ended = true; notify(); });\n\tcall.on(\"error\", (err: Error) => { streamError = err; notify(); });\n\n\t// Write from source in background — runs concurrently with the read loop\n\tconst writeTask = (async () => {\n\t\ttry {\n\t\t\tfor await (const msg of source) {\n\t\t\t\tcall.write(msg);\n\t\t\t}\n\t\t} finally {\n\t\t\tcall.end();\n\t\t}\n\t})();\n\n\t// Yield messages as they arrive\n\twhile (true) {\n\t\twhile (queue.length > 0) yield queue.shift()!;\n\t\tif (ended) break;\n\t\tif (streamError) throw streamError;\n\t\tawait new Promise<void>((r) => { wakeup = r; });\n\t}\n\tawait writeTask;\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Convert a gRPC ClientReadableStream (or DuplexStream) to an AsyncIterable.\n * grpc-js streams extend Node.js Readable, which supports `for await...of`\n * via Symbol.asyncIterator.\n */\nasync function* readableToAsyncIter(stream: any): AsyncIterable<unknown> {\n\t// Use Symbol.asyncIterator if available (Node.js 10+ / Bun)\n\tif (typeof stream[Symbol.asyncIterator] === \"function\") {\n\t\tfor await (const msg of stream) {\n\t\t\tyield msg;\n\t\t}\n\t\treturn;\n\t}\n\t// Fallback: event-based conversion\n\tlet done = false;\n\tlet error: Error | null = null;\n\tconst buffer: unknown[] = [];\n\tlet resolve: (() => void) | null = null;\n\n\tstream.on(\"data\", (msg: unknown) => {\n\t\tbuffer.push(msg);\n\t\tresolve?.();\n\t\tresolve = null;\n\t});\n\tstream.on(\"end\", () => {\n\t\tdone = true;\n\t\tresolve?.();\n\t\tresolve = null;\n\t});\n\tstream.on(\"error\", (err: Error) => {\n\t\terror = err;\n\t\tresolve?.();\n\t\tresolve = null;\n\t});\n\n\twhile (true) {\n\t\twhile (buffer.length > 0) {\n\t\t\tyield buffer.shift()!;\n\t\t}\n\t\tif (done) break;\n\t\tif (error) throw error;\n\t\tawait new Promise<void>((r) => {\n\t\t\tresolve = r;\n\t\t});\n\t}\n}\n\nexport default GrpcService;\n",
6
6
  "/**\n * gRPC decorators.\n *\n * Unary (request → response):\n * @GrpcMethod(\"FindById\")\n * async findById(req: { id: number }): Promise<TRes> { ... }\n *\n * Server streaming (request → stream<response>):\n * @GrpcServerStream(\"ListItems\")\n * async *listItems(req: { page: number }): AsyncIterable<TItem> { yield ...; }\n *\n * Client streaming (stream<request> → response):\n * @GrpcClientStream(\"UploadChunks\")\n * async uploadChunks(req: AsyncIterable<TChunk>): Promise<TResult> { ... }\n *\n * Bidirectional streaming (stream<request> → stream<response>):\n * @GrpcBidiStream(\"Chat\")\n * async *chat(req: AsyncIterable<TMsg>): AsyncIterable<TMsg> { yield ...; }\n */\n\nimport type { GrpcMethodEntry, GrpcStreamType } from \"./types.js\";\n\nconst GRPC_SERVICE_KEY = Symbol.for(\"nexus:grpc:service\");\nconst GRPC_METHOD_KEY = Symbol.for(\"nexus:grpc:method\");\n\n/**\n * Mark a class as a gRPC service implementation. The `name`\n * must match a `service` declaration in the .proto file.\n */\nexport function GrpcService(name: string): ClassDecorator {\n\treturn function (target: Function) {\n\t\tconst proto = (target as { prototype: object }).prototype ?? target;\n\t\t(proto as Record<symbol, unknown>)[GRPC_SERVICE_KEY] = { name };\n\t};\n}\n\n// ── Shared factory ──────────────────────────────────────────────────────────\n\nfunction makeMethodDecorator(\n\tprotoName: string,\n\tstreamType: GrpcStreamType,\n): MethodDecorator {\n\treturn function (\n\t\t_target: object,\n\t\tpropertyKey: string | symbol,\n\t\t_descriptor: PropertyDescriptor,\n\t) {\n\t\tconst proto = _target as Record<symbol, unknown>;\n\t\tproto[GRPC_METHOD_KEY] = proto[GRPC_METHOD_KEY] ?? {};\n\t\t(proto[GRPC_METHOD_KEY] as Record<string | symbol, GrpcMethodEntry>)[\n\t\t\tpropertyKey\n\t\t] = { protoName, streamType };\n\t\treturn _descriptor;\n\t};\n}\n\n// ── Public decorators ───────────────────────────────────────────────────────\n\n/**\n * Bind a method to a unary gRPC handler.\n * The method receives `(request: TReq)` and returns `Promise<TRes>`.\n */\nexport function GrpcMethod(name: string): MethodDecorator {\n\treturn makeMethodDecorator(name, \"unary\");\n}\n\n/**\n * Bind a method to a server-streaming gRPC handler.\n * The method receives `(request: TReq)` and returns `AsyncIterable<TRes>`.\n *\n * @example\n * @GrpcServerStream(\"ListNumbers\")\n * async *listNumbers(req: { count: number }): AsyncIterable<{ n: number }> {\n * for (let i = 0; i < req.count; i++) yield { n: i };\n * }\n */\nexport function GrpcServerStream(name: string): MethodDecorator {\n\treturn makeMethodDecorator(name, \"server\");\n}\n\n/**\n * Bind a method to a client-streaming gRPC handler.\n * The method receives `(requests: AsyncIterable<TReq>)` and returns `Promise<TRes>`.\n *\n * @example\n * @GrpcClientStream(\"Sum\")\n * async sum(reqs: AsyncIterable<{ n: number }>): Promise<{ total: number }> {\n * let total = 0;\n * for await (const { n } of reqs) total += n;\n * return { total };\n * }\n */\nexport function GrpcClientStream(name: string): MethodDecorator {\n\treturn makeMethodDecorator(name, \"client\");\n}\n\n/**\n * Bind a method to a bidirectional-streaming gRPC handler.\n * The method receives `(requests: AsyncIterable<TReq>)` and returns `AsyncIterable<TRes>`.\n *\n * @example\n * @GrpcBidiStream(\"Echo\")\n * async *echo(reqs: AsyncIterable<{ msg: string }>): AsyncIterable<{ msg: string }> {\n * for await (const { msg } of reqs) yield { msg: `echo: ${msg}` };\n * }\n */\nexport function GrpcBidiStream(name: string): MethodDecorator {\n\treturn makeMethodDecorator(name, \"bidi\");\n}\n\n// ── Metadata readers (internal) ─────────────────────────────────────────────\n\n/** Read the gRPC service name. Internal. */\nexport function getGrpcServiceName(target: object): string | undefined {\n\tconst t = (target as { prototype?: object }).prototype ?? target;\n\treturn (t as Record<symbol, { name?: string } | undefined>)[\n\t\tGRPC_SERVICE_KEY\n\t]?.name;\n}\n\n/**\n * Read all decorated method entries for a gRPC service.\n * Returns `{ [propertyKey]: GrpcMethodEntry }`.\n * Internal — used by `GrpcService.prepare()`.\n */\nexport function getGrpcMethodEntries(\n\ttarget: object,\n): Record<string, GrpcMethodEntry> {\n\tconst t = (target as { prototype?: object }).prototype ?? target;\n\treturn (\n\t\t((t as Record<symbol, unknown>)[GRPC_METHOD_KEY] as\n\t\t\t| Record<string, GrpcMethodEntry>\n\t\t\t| undefined) ?? {}\n\t);\n}\n\n/**\n * Read the bound method names for a gRPC service.\n * Returns `{ [propertyKey]: protoMethodName }`.\n * Kept for backwards compatibility.\n * @deprecated Use `getGrpcMethodEntries` for streaming type info.\n */\nexport function getGrpcMethodNames(target: object): Record<string, string> {\n\tconst entries = getGrpcMethodEntries(target);\n\tconst result: Record<string, string> = {};\n\tfor (const [key, entry] of Object.entries(entries)) {\n\t\tresult[key] = entry.protoName;\n\t}\n\treturn result;\n}\n",
7
7
  "/**\n * `GrpcModule` — wires `GrpcService` into the DI container.\n *\n * @Module({\n * imports: [\n * GrpcModule.forRoot({\n * protoPath: \"./proto/user.proto\",\n * services: [UserServiceImpl],\n * port: 50051,\n * }),\n * ],\n * })\n * class AppModule {}\n *\n * After boot, the user resolves `GrpcService` from the\n * container and calls `start()` / `stop()` to control the\n * gRPC server's lifecycle:\n *\n * const grpc = container.resolve(GrpcService);\n * await grpc.start();\n * // ...\n * await grpc.stop();\n *\n * The framework also auto-registers the service impl classes\n * as DI providers, so their `@Inject()`-decorated dependencies\n * are wired up automatically.\n */\n\nimport { Module } from \"@nexusts/core\";\nimport { GrpcService, GRPC_SERVICE_TOKEN } from \"./service.js\";\nimport type { GrpcConfig } from \"./types.js\";\n\n@Module({\n\tproviders: [GrpcService, { provide: GRPC_SERVICE_TOKEN, useExisting: GrpcService }],\n\texports: [GrpcService, GRPC_SERVICE_TOKEN],\n})\nexport class GrpcModule {\n\tstatic forRoot(config: GrpcConfig) {\n\t\t@Module({\n\t\t\tproviders: [\n\t\t\t\t{ provide: \"GRPC_CONFIG\", useValue: config },\n\t\t\t\t// Service impl classes must be registered as providers so\n\t\t\t\t// the DI container can instantiate them.\n\t\t\t\t...config.services,\n\t\t\t\t{\n\t\t\t\t\tprovide: GrpcService,\n\t\t\t\t\tuseFactory: (resolve: <T>(t: unknown) => T) => {\n\n\t\t\t\t\t\tconst svc = new GrpcService(config);\n\t\t\t\t\t\t// prepare() resolves the service impls from the\n\t\t\t\t\t\t// container and registers their handlers on the\n\t\t\t\t\t\t// gRPC server. The user calls start() later to\n\t\t\t\t\t\t// bind to a port.\n\t\t\t\t\t\tsvc.setResolver((t) => resolve(t));\n\t\t\t\t\t\treturn svc;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ provide: GRPC_SERVICE_TOKEN, useExisting: GrpcService },\n\t\t\t],\n\t\t\texports: [GrpcService, GRPC_SERVICE_TOKEN, \"GRPC_CONFIG\", ...config.services],\n\t\t})\n\t\tclass ConfiguredGrpcModule {}\n\t\tObject.defineProperty(ConfiguredGrpcModule, \"name\", {\n\t\t\tvalue: \"ConfiguredGrpcModule\",\n\t\t});\n\t\treturn ConfiguredGrpcModule as unknown as typeof GrpcModule;\n\t}\n}\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;AAmBA;AACA;AAAA;AAAA,YAEC;AAAA;AAAA;AAGD;;;ACHA,IAAM,mBAAmB,OAAO,IAAI,oBAAoB;AACxD,IAAM,kBAAkB,OAAO,IAAI,mBAAmB;AAM/C,SAAS,WAAW,CAAC,MAA8B;AAAA,EACzD,OAAO,QAAS,CAAC,QAAkB;AAAA,IAClC,MAAM,QAAS,OAAiC,aAAa;AAAA,IAC5D,MAAkC,oBAAoB,EAAE,KAAK;AAAA;AAAA;AAMhE,SAAS,mBAAmB,CAC3B,WACA,YACkB;AAAA,EAClB,OAAO,QAAS,CACf,SACA,aACA,aACC;AAAA,IACD,MA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e,sBAAsB,QAAQ;AAAA,MACnD,OAAO;AAAA,IACR,CAAC;AAAA,IACD,OAAO;AAAA;AAET;AA/Ba,aAAN;AAAA,EAJN,OAAO;AAAA,IACP,WAAW,CAAC,cAAa,EAAE,SAAS,oBAAoB,aAAa,aAAY,CAAC;AAAA,IAClF,SAAS,CAAC,cAAa,kBAAkB;AAAA,EAC1C,CAAC;AAAA,GACY;",
10
10
  "debugId": "DD2F9280C753352864756E2164756E21",
11
11
  "names": []
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexusts/grpc",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "gRPC server + typed client (reflection-based)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@nexusts/core": "^0.8.2"
29
+ "@nexusts/core": "^0.8.4"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",