@celljs/grpc 0.0.0-stage → 4.3.0

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.
Files changed (186) hide show
  1. package/README.md +123 -2
  2. package/cell.yml +12 -0
  3. package/esm/node/call/async-queue.d.ts +31 -0
  4. package/esm/node/call/async-queue.js +80 -0
  5. package/esm/node/call/async-queue.js.map +1 -0
  6. package/esm/node/call/grpc-status.d.ts +33 -0
  7. package/esm/node/call/grpc-status.js +48 -0
  8. package/esm/node/call/grpc-status.js.map +1 -0
  9. package/esm/node/call/message-framer.d.ts +24 -0
  10. package/esm/node/call/message-framer.js +105 -0
  11. package/esm/node/call/message-framer.js.map +1 -0
  12. package/esm/node/call/metadata.d.ts +15 -0
  13. package/esm/node/call/metadata.js +81 -0
  14. package/esm/node/call/metadata.js.map +1 -0
  15. package/esm/node/client/grpc-channel.d.ts +64 -0
  16. package/esm/node/client/grpc-channel.js +285 -0
  17. package/esm/node/client/grpc-channel.js.map +1 -0
  18. package/esm/node/codec/proto-reader.d.ts +26 -0
  19. package/esm/node/codec/proto-reader.js +153 -0
  20. package/esm/node/codec/proto-reader.js.map +1 -0
  21. package/esm/node/codec/proto-writer.d.ts +29 -0
  22. package/esm/node/codec/proto-writer.js +150 -0
  23. package/esm/node/codec/proto-writer.js.map +1 -0
  24. package/esm/node/index.d.ts +15 -0
  25. package/esm/node/index.js +16 -0
  26. package/esm/node/index.js.map +1 -0
  27. package/esm/node/module.d.ts +3 -0
  28. package/esm/node/module.js +4 -0
  29. package/esm/node/module.js.map +1 -0
  30. package/esm/node/proto/proto-ast.d.ts +46 -0
  31. package/esm/node/proto/proto-ast.js +2 -0
  32. package/esm/node/proto/proto-ast.js.map +1 -0
  33. package/esm/node/proto/proto-parser.d.ts +45 -0
  34. package/esm/node/proto/proto-parser.js +451 -0
  35. package/esm/node/proto/proto-parser.js.map +1 -0
  36. package/esm/node/proto/proto-types.d.ts +76 -0
  37. package/esm/node/proto/proto-types.js +444 -0
  38. package/esm/node/proto/proto-types.js.map +1 -0
  39. package/esm/node/proto/proto.d.ts +57 -0
  40. package/esm/node/proto/proto.js +174 -0
  41. package/esm/node/proto/proto.js.map +1 -0
  42. package/esm/node/proto/well-known.d.ts +5 -0
  43. package/esm/node/proto/well-known.js +41 -0
  44. package/esm/node/proto/well-known.js.map +1 -0
  45. package/esm/node/server/grpc-server-lifecycle.d.ts +21 -0
  46. package/esm/node/server/grpc-server-lifecycle.js +65 -0
  47. package/esm/node/server/grpc-server-lifecycle.js.map +1 -0
  48. package/esm/node/server/grpc-server.d.ts +60 -0
  49. package/esm/node/server/grpc-server.js +312 -0
  50. package/esm/node/server/grpc-server.js.map +1 -0
  51. package/esm/node/server/grpc-service.d.ts +24 -0
  52. package/esm/node/server/grpc-service.js +38 -0
  53. package/esm/node/server/grpc-service.js.map +1 -0
  54. package/esm/node/test/proto-loader.d.ts +2 -0
  55. package/esm/node/test/proto-loader.js +13 -0
  56. package/esm/node/test/proto-loader.js.map +1 -0
  57. package/esm/node/test/test-protos.d.ts +28 -0
  58. package/esm/node/test/test-protos.js +145 -0
  59. package/esm/node/test/test-protos.js.map +1 -0
  60. package/esm/package.json +3 -0
  61. package/lib/node/call/async-queue.d.ts +32 -0
  62. package/lib/node/call/async-queue.d.ts.map +1 -0
  63. package/lib/node/call/async-queue.js +84 -0
  64. package/lib/node/call/async-queue.js.map +1 -0
  65. package/lib/node/call/grpc-status.d.ts +34 -0
  66. package/lib/node/call/grpc-status.d.ts.map +1 -0
  67. package/lib/node/call/grpc-status.js +52 -0
  68. package/lib/node/call/grpc-status.js.map +1 -0
  69. package/lib/node/call/message-framer.d.ts +25 -0
  70. package/lib/node/call/message-framer.d.ts.map +1 -0
  71. package/lib/node/call/message-framer.js +109 -0
  72. package/lib/node/call/message-framer.js.map +1 -0
  73. package/lib/node/call/metadata.d.ts +16 -0
  74. package/lib/node/call/metadata.d.ts.map +1 -0
  75. package/lib/node/call/metadata.js +84 -0
  76. package/lib/node/call/metadata.js.map +1 -0
  77. package/lib/node/client/grpc-channel.d.ts +65 -0
  78. package/lib/node/client/grpc-channel.d.ts.map +1 -0
  79. package/lib/node/client/grpc-channel.js +289 -0
  80. package/lib/node/client/grpc-channel.js.map +1 -0
  81. package/lib/node/codec/proto-reader.d.ts +27 -0
  82. package/lib/node/codec/proto-reader.d.ts.map +1 -0
  83. package/lib/node/codec/proto-reader.js +157 -0
  84. package/lib/node/codec/proto-reader.js.map +1 -0
  85. package/lib/node/codec/proto-writer.d.ts +30 -0
  86. package/lib/node/codec/proto-writer.d.ts.map +1 -0
  87. package/lib/node/codec/proto-writer.js +154 -0
  88. package/lib/node/codec/proto-writer.js.map +1 -0
  89. package/lib/node/grpc.spec.d.ts +2 -0
  90. package/lib/node/grpc.spec.d.ts.map +1 -0
  91. package/lib/node/grpc.spec.js +148 -0
  92. package/lib/node/grpc.spec.js.map +1 -0
  93. package/lib/node/index.d.ts +16 -0
  94. package/lib/node/index.d.ts.map +1 -0
  95. package/lib/node/index.js +32 -0
  96. package/lib/node/index.js.map +1 -0
  97. package/lib/node/interop.spec.d.ts +2 -0
  98. package/lib/node/interop.spec.d.ts.map +1 -0
  99. package/lib/node/interop.spec.js +194 -0
  100. package/lib/node/interop.spec.js.map +1 -0
  101. package/lib/node/module.d.ts +4 -0
  102. package/lib/node/module.d.ts.map +1 -0
  103. package/lib/node/module.js +6 -0
  104. package/lib/node/module.js.map +1 -0
  105. package/lib/node/proto/proto-ast.d.ts +47 -0
  106. package/lib/node/proto/proto-ast.d.ts.map +1 -0
  107. package/lib/node/proto/proto-ast.js +3 -0
  108. package/lib/node/proto/proto-ast.js.map +1 -0
  109. package/lib/node/proto/proto-parser.d.ts +46 -0
  110. package/lib/node/proto/proto-parser.d.ts.map +1 -0
  111. package/lib/node/proto/proto-parser.js +455 -0
  112. package/lib/node/proto/proto-parser.js.map +1 -0
  113. package/lib/node/proto/proto-parser.spec.d.ts +2 -0
  114. package/lib/node/proto/proto-parser.spec.d.ts.map +1 -0
  115. package/lib/node/proto/proto-parser.spec.js +95 -0
  116. package/lib/node/proto/proto-parser.spec.js.map +1 -0
  117. package/lib/node/proto/proto-types.d.ts +77 -0
  118. package/lib/node/proto/proto-types.d.ts.map +1 -0
  119. package/lib/node/proto/proto-types.js +449 -0
  120. package/lib/node/proto/proto-types.js.map +1 -0
  121. package/lib/node/proto/proto-types.spec.d.ts +2 -0
  122. package/lib/node/proto/proto-types.spec.d.ts.map +1 -0
  123. package/lib/node/proto/proto-types.spec.js +120 -0
  124. package/lib/node/proto/proto-types.spec.js.map +1 -0
  125. package/lib/node/proto/proto.d.ts +58 -0
  126. package/lib/node/proto/proto.d.ts.map +1 -0
  127. package/lib/node/proto/proto.js +178 -0
  128. package/lib/node/proto/proto.js.map +1 -0
  129. package/lib/node/proto/well-known.d.ts +6 -0
  130. package/lib/node/proto/well-known.d.ts.map +1 -0
  131. package/lib/node/proto/well-known.js +44 -0
  132. package/lib/node/proto/well-known.js.map +1 -0
  133. package/lib/node/server/grpc-server-lifecycle.d.ts +22 -0
  134. package/lib/node/server/grpc-server-lifecycle.d.ts.map +1 -0
  135. package/lib/node/server/grpc-server-lifecycle.js +68 -0
  136. package/lib/node/server/grpc-server-lifecycle.js.map +1 -0
  137. package/lib/node/server/grpc-server-lifecycle.spec.d.ts +2 -0
  138. package/lib/node/server/grpc-server-lifecycle.spec.d.ts.map +1 -0
  139. package/lib/node/server/grpc-server-lifecycle.spec.js +100 -0
  140. package/lib/node/server/grpc-server-lifecycle.spec.js.map +1 -0
  141. package/lib/node/server/grpc-server.d.ts +61 -0
  142. package/lib/node/server/grpc-server.d.ts.map +1 -0
  143. package/lib/node/server/grpc-server.js +316 -0
  144. package/lib/node/server/grpc-server.js.map +1 -0
  145. package/lib/node/server/grpc-service.d.ts +25 -0
  146. package/lib/node/server/grpc-service.d.ts.map +1 -0
  147. package/lib/node/server/grpc-service.js +42 -0
  148. package/lib/node/server/grpc-service.js.map +1 -0
  149. package/lib/node/test/proto-loader.d.ts +3 -0
  150. package/lib/node/test/proto-loader.d.ts.map +1 -0
  151. package/lib/node/test/proto-loader.js +16 -0
  152. package/lib/node/test/proto-loader.js.map +1 -0
  153. package/lib/node/test/test-protos.d.ts +29 -0
  154. package/lib/node/test/test-protos.d.ts.map +1 -0
  155. package/lib/node/test/test-protos.js +150 -0
  156. package/lib/node/test/test-protos.js.map +1 -0
  157. package/lib/package.spec.d.ts +2 -0
  158. package/lib/package.spec.d.ts.map +1 -0
  159. package/lib/package.spec.js +7 -0
  160. package/lib/package.spec.js.map +1 -0
  161. package/package.json +69 -4
  162. package/src/node/call/async-queue.ts +79 -0
  163. package/src/node/call/grpc-status.ts +49 -0
  164. package/src/node/call/message-framer.ts +109 -0
  165. package/src/node/call/metadata.ts +85 -0
  166. package/src/node/client/grpc-channel.ts +327 -0
  167. package/src/node/codec/proto-reader.ts +172 -0
  168. package/src/node/codec/proto-writer.ts +170 -0
  169. package/src/node/grpc.spec.ts +160 -0
  170. package/src/node/index.ts +15 -0
  171. package/src/node/interop.spec.ts +174 -0
  172. package/src/node/module.ts +4 -0
  173. package/src/node/proto/proto-ast.ts +48 -0
  174. package/src/node/proto/proto-parser.spec.ts +104 -0
  175. package/src/node/proto/proto-parser.ts +477 -0
  176. package/src/node/proto/proto-types.spec.ts +128 -0
  177. package/src/node/proto/proto-types.ts +497 -0
  178. package/src/node/proto/proto.ts +218 -0
  179. package/src/node/proto/well-known.ts +40 -0
  180. package/src/node/server/grpc-server-lifecycle.spec.ts +88 -0
  181. package/src/node/server/grpc-server-lifecycle.ts +56 -0
  182. package/src/node/server/grpc-server.ts +368 -0
  183. package/src/node/server/grpc-service.ts +40 -0
  184. package/src/node/test/proto-loader.ts +13 -0
  185. package/src/node/test/test-protos.ts +159 -0
  186. package/src/package.spec.ts +5 -0
@@ -0,0 +1,100 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const bun_test_1 = require("bun:test");
16
+ const core_1 = require("@celljs/core");
17
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
18
+ const auto_bind_1 = require("@celljs/core/lib/common/container/auto-bind");
19
+ const container_1 = require("@celljs/core/lib/common/container/container");
20
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
21
+ // Loaded in the order of the backend entry the CLI generates: core's static modules, then this package's module.
22
+ const static_module_1 = __importDefault(require("@celljs/core/lib/common/static-module"));
23
+ const utils_1 = require("@celljs/core/lib/common/utils");
24
+ const static_module_2 = __importDefault(require("@celljs/core/lib/node/static-module"));
25
+ const grpc_status_1 = require("../call/grpc-status");
26
+ const grpc_channel_1 = require("../client/grpc-channel");
27
+ const module_1 = __importDefault(require("../module"));
28
+ const proto_1 = require("../proto/proto");
29
+ const test_protos_1 = require("../test/test-protos");
30
+ const grpc_server_lifecycle_1 = require("./grpc-server-lifecycle");
31
+ const grpc_service_1 = require("./grpc-service");
32
+ const Greeter = proto_1.Proto.parse(test_protos_1.TEST_PROTO).service('Greeter');
33
+ let app;
34
+ /** The error a call fails with. (Not `expect(call).rejects`: under Bun 1.4 it breaks HTTP/2 streams of the same process.) */
35
+ async function failure(call) {
36
+ try {
37
+ await call;
38
+ }
39
+ catch (error) {
40
+ return error;
41
+ }
42
+ throw new Error('The call did not fail');
43
+ }
44
+ (0, bun_test_1.afterEach)(async () => {
45
+ await (app === null || app === void 0 ? void 0 : app.stop());
46
+ app = undefined;
47
+ });
48
+ async function start(server = {}) {
49
+ utils_1.currentThis.cellProps = { cell: { logger: { level: 'error' }, grpc: { server: { enabled: true, port: 0, host: '127.0.0.1', ...server } } } };
50
+ const container = new container_1.Container(static_module_1.default, static_module_2.default, module_1.default, (0, auto_bind_1.autoBind)());
51
+ container_provider_1.ContainerProvider.set(container);
52
+ app = container.get(application_protocol_1.Application);
53
+ await app.start();
54
+ return container.get(grpc_server_lifecycle_1.GrpcServerLifecycle);
55
+ }
56
+ (0, bun_test_1.describe)('GrpcService in an application', () => {
57
+ (0, bun_test_1.it)('serves the @GrpcService components on the configured port, with their dependencies injected', async () => {
58
+ let Names = class Names {
59
+ format(name) {
60
+ return name.toUpperCase();
61
+ }
62
+ };
63
+ Names = __decorate([
64
+ (0, core_1.Component)()
65
+ ], Names);
66
+ let GreeterService = class GreeterService {
67
+ sayHello({ name }) {
68
+ if (!name) {
69
+ throw new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.INVALID_ARGUMENT, 'name is required');
70
+ }
71
+ return { message: `Hello ${this.names.format(name)}` };
72
+ }
73
+ };
74
+ __decorate([
75
+ (0, core_1.Autowired)(Names),
76
+ __metadata("design:type", Names)
77
+ ], GreeterService.prototype, "names", void 0);
78
+ GreeterService = __decorate([
79
+ (0, grpc_service_1.GrpcService)(Greeter)
80
+ ], GreeterService);
81
+ const lifecycle = await start();
82
+ (0, bun_test_1.expect)(lifecycle.port).toBeGreaterThan(0);
83
+ const channel = new grpc_channel_1.GrpcChannel(`127.0.0.1:${lifecycle.port}`);
84
+ const greeter = channel.createClient(Greeter);
85
+ (0, bun_test_1.expect)(await greeter.sayHello({ name: 'cell' })).toMatchObject({ message: 'Hello CELL' });
86
+ (0, bun_test_1.expect)((await failure(greeter.sayHello({}))).message).toBe('INVALID_ARGUMENT: name is required');
87
+ (0, bun_test_1.expect)((await failure(greeter.chat([])[Symbol.asyncIterator]().next())).code).toBe(grpc_status_1.GrpcStatus.UNIMPLEMENTED);
88
+ // Stopping the application closes the server.
89
+ await (app === null || app === void 0 ? void 0 : app.stop());
90
+ app = undefined;
91
+ (0, bun_test_1.expect)((await failure(greeter.sayHello({ name: 'again' }))).code).toBe(grpc_status_1.GrpcStatus.UNAVAILABLE);
92
+ channel.close();
93
+ (0, bun_test_1.expect)([GreeterService, Names]).toHaveLength(2);
94
+ });
95
+ (0, bun_test_1.it)('starts no server when disabled', async () => {
96
+ const lifecycle = await start({ enabled: false });
97
+ (0, bun_test_1.expect)(lifecycle.server).toBeUndefined();
98
+ });
99
+ });
100
+ //# sourceMappingURL=grpc-server-lifecycle.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-server-lifecycle.spec.js","sourceRoot":"","sources":["../../../src/node/server/grpc-server-lifecycle.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAA2D;AAC3D,uCAAoD;AACpD,mGAAuF;AACvF,2EAAuE;AACvE,2EAAwE;AACxE,6FAAyF;AACzF,iHAAiH;AACjH,0FAAqE;AACrE,yDAA4D;AAC5D,wFAAiE;AACjE,qDAA4D;AAC5D,yDAAqD;AACrD,uDAAmC;AACnC,0CAAuC;AACvC,qDAAiD;AACjD,mEAA8D;AAC9D,iDAA6C;AAE7C,MAAM,OAAO,GAAG,aAAK,CAAC,KAAK,CAAC,wBAAU,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAE3D,IAAI,GAA4B,CAAC;AAEjC,6HAA6H;AAC7H,KAAK,UAAU,OAAO,CAAC,IAAsB;IACzC,IAAI,CAAC;QACD,MAAM,IAAI,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAkB,CAAC;IAC9B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAA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GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE,CAAA,CAAC;QAClB,GAAG,GAAG,SAAS,CAAC;QAChB,IAAA,iBAAM,EAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,wBAAU,CAAC,WAAW,CAAC,CAAC;QAC/F,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,IAAA,iBAAM,EAAC,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,IAAA,aAAE,EAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAClD,IAAA,iBAAM,EAAC,SAAS,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { type Http2Server, type IncomingHttpHeaders, type ServerHttp2Session, type ServerHttp2Stream } from 'node:http2';
2
+ import { type Metadata } from '../call/metadata';
3
+ import type { MethodDefinition, ServiceDefinition } from '../proto/proto';
4
+ /** What a service method gets besides the request: the call's metadata, cancellation and response metadata. */
5
+ export interface ServerCall {
6
+ readonly method: MethodDefinition;
7
+ /** The request metadata (headers), keys in lowercase. */
8
+ readonly metadata: Metadata;
9
+ /** Aborted when the client cancels, the deadline passes or the server closes. */
10
+ readonly signal: AbortSignal;
11
+ readonly deadline?: Date;
12
+ /** Adds response metadata; only before the first response message. */
13
+ setHeader(key: string, value: Metadata[string]): void;
14
+ /** Adds metadata to the trailers that end the call. */
15
+ setTrailer(key: string, value: Metadata[string]): void;
16
+ }
17
+ type Awaitable<T> = T | Promise<T>;
18
+ type Stream<T> = Iterable<T> | AsyncIterable<T>;
19
+ /** `rpc M (Req) returns (Res)` */
20
+ export type UnaryHandler<Req = any, Res = any> = (request: Req, call: ServerCall) => Awaitable<Res>;
21
+ /** `rpc M (stream Req) returns (Res)` */
22
+ export type ClientStreamHandler<Req = any, Res = any> = (requests: AsyncIterable<Req>, call: ServerCall) => Awaitable<Res>;
23
+ /** `rpc M (Req) returns (stream Res)`: return an async generator or any (async) iterable. */
24
+ export type ServerStreamHandler<Req = any, Res = any> = (request: Req, call: ServerCall) => Awaitable<Stream<Res>>;
25
+ /** `rpc M (stream Req) returns (stream Res)` */
26
+ export type BidiStreamHandler<Req = any, Res = any> = (requests: AsyncIterable<Req>, call: ServerCall) => Awaitable<Stream<Res>>;
27
+ export interface GrpcServerOptions {
28
+ /** Largest request message accepted, in bytes. Default 4 MiB. */
29
+ maxReceiveMessageSize?: number;
30
+ /** Reports errors of service methods that are not {@link GrpcError}s. Default `console.error`. */
31
+ onError?: (error: unknown, method: MethodDefinition) => void;
32
+ }
33
+ interface Handler {
34
+ method: MethodDefinition;
35
+ fn: (...args: any[]) => any;
36
+ }
37
+ /**
38
+ * A gRPC server on `node:http2` (cleartext HTTP/2). Each method of a service is the method of the
39
+ * implementation named after it in lowerCamelCase (`SayHello` → `sayHello`); see {@link UnaryHandler}
40
+ * and the other handler types for their signatures. Methods without an implementation answer
41
+ * `UNIMPLEMENTED`.
42
+ *
43
+ * In a Cell application, use {@link GrpcService} instead: the application starts the server.
44
+ */
45
+ export declare class GrpcServer {
46
+ protected readonly options: GrpcServerOptions;
47
+ protected readonly handlers: Map<string, Handler>;
48
+ protected readonly sessions: Set<ServerHttp2Session<typeof import("http").IncomingMessage, typeof import("http").ServerResponse, typeof import("http2").Http2ServerRequest, typeof import("http2").Http2ServerResponse>>;
49
+ protected server?: Http2Server;
50
+ constructor(options?: GrpcServerOptions);
51
+ addService(service: ServiceDefinition, implementation: object): this;
52
+ /** Starts listening; resolves to the port, which is a free one when `port` is 0. */
53
+ listen(port?: number, host?: string): Promise<number>;
54
+ get port(): number | undefined;
55
+ /** Stops accepting connections and closes the open ones; `force` also cancels the calls in progress. */
56
+ close(force?: boolean): Promise<void>;
57
+ /** Serves one HTTP/2 stream; for servers of your own (`server.on('stream', ...)`). */
58
+ handleStream(stream: ServerHttp2Stream, headers: IncomingHttpHeaders): void;
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=grpc-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-server.d.ts","sourceRoot":"","sources":["../../../src/node/server/grpc-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,WAAW,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKvI,OAAO,EAAE,KAAK,QAAQ,EAAgB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE1E,+GAA+G;AAC/G,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;IACzB,sEAAsE;IACtE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACtD,uDAAuD;IACvD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1D;AAED,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACnC,KAAK,MAAM,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC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,EAAE,iBAAiB;IAJzD,SAAS,CAAC,QAAQ,CAAC,QAAQ,uBAA8B;IACzD,SAAS,CAAC,QAAQ,CAAC,QAAQ,8LAAiC;IAC5D,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE/B,YAA+B,OAAO,GAAE,iBAAsB,EAAI;IAElE,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAYnE;IAED,oFAAoF;IACpF,MAAM,CAAC,IAAI,SAAQ,EAAE,IAAI,SAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBxD;IAED,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAG7B;IAED,wGAAwG;IACxG,KAAK,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAelC;IAED,sFAAsF;IACtF,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAwB1E;CACJ"}
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrpcServer = void 0;
4
+ const node_http2_1 = require("node:http2");
5
+ const async_queue_1 = require("../call/async-queue");
6
+ const grpc_status_1 = require("../call/grpc-status");
7
+ const message_framer_1 = require("../call/message-framer");
8
+ const metadata_1 = require("../call/metadata");
9
+ /**
10
+ * A gRPC server on `node:http2` (cleartext HTTP/2). Each method of a service is the method of the
11
+ * implementation named after it in lowerCamelCase (`SayHello` → `sayHello`); see {@link UnaryHandler}
12
+ * and the other handler types for their signatures. Methods without an implementation answer
13
+ * `UNIMPLEMENTED`.
14
+ *
15
+ * In a Cell application, use {@link GrpcService} instead: the application starts the server.
16
+ */
17
+ class GrpcServer {
18
+ constructor(options = {}) {
19
+ this.options = options;
20
+ this.handlers = new Map();
21
+ this.sessions = new Set();
22
+ }
23
+ addService(service, implementation) {
24
+ var _a;
25
+ for (const method of service.methods) {
26
+ const impl = implementation;
27
+ const fn = (_a = impl[method.jsName]) !== null && _a !== void 0 ? _a : impl[method.name];
28
+ if (this.handlers.has(method.path)) {
29
+ throw new Error(`${method.path} is served twice: add ${service.fullName} to the server once.`);
30
+ }
31
+ if (typeof fn === 'function') {
32
+ this.handlers.set(method.path, { method, fn: fn.bind(implementation) });
33
+ }
34
+ }
35
+ return this;
36
+ }
37
+ /** Starts listening; resolves to the port, which is a free one when `port` is 0. */
38
+ listen(port = 50051, host = '127.0.0.1') {
39
+ if (this.server) {
40
+ throw new Error('The gRPC server is already listening.');
41
+ }
42
+ const server = (0, node_http2_1.createServer)();
43
+ this.server = server;
44
+ server.on('session', session => {
45
+ this.sessions.add(session);
46
+ session.on('close', () => this.sessions.delete(session));
47
+ session.on('error', () => undefined);
48
+ });
49
+ server.on('stream', (stream, headers) => this.handleStream(stream, headers));
50
+ return new Promise((resolve, reject) => {
51
+ server.once('error', reject);
52
+ server.listen(port, host, () => {
53
+ server.off('error', reject);
54
+ resolve(server.address().port);
55
+ });
56
+ });
57
+ }
58
+ get port() {
59
+ var _a;
60
+ const address = (_a = this.server) === null || _a === void 0 ? void 0 : _a.address();
61
+ return address && typeof address === 'object' ? address.port : undefined;
62
+ }
63
+ /** Stops accepting connections and closes the open ones; `force` also cancels the calls in progress. */
64
+ close(force = false) {
65
+ const server = this.server;
66
+ this.server = undefined;
67
+ if (!server) {
68
+ return Promise.resolve();
69
+ }
70
+ const closed = new Promise(resolve => server.close(() => resolve()));
71
+ for (const session of this.sessions) {
72
+ if (force) {
73
+ session.destroy();
74
+ }
75
+ else {
76
+ session.close();
77
+ }
78
+ }
79
+ return closed;
80
+ }
81
+ /** Serves one HTTP/2 stream; for servers of your own (`server.on('stream', ...)`). */
82
+ handleStream(stream, headers) {
83
+ stream.on('error', () => undefined);
84
+ const contentType = headers['content-type'];
85
+ if (headers[':method'] !== 'POST' || typeof contentType !== 'string' || !contentType.startsWith('application/grpc')) {
86
+ stream.respond({ ':status': 415, 'grpc-status': String(grpc_status_1.GrpcStatus.UNKNOWN), 'grpc-message': 'Not a gRPC request' }, { endStream: true });
87
+ return;
88
+ }
89
+ const path = String(headers[':path']);
90
+ const handler = this.handlers.get(path);
91
+ if (!handler) {
92
+ stream.respond({
93
+ ':status': 200,
94
+ 'content-type': 'application/grpc+proto',
95
+ 'grpc-status': String(grpc_status_1.GrpcStatus.UNIMPLEMENTED),
96
+ 'grpc-message': metadata_1.MetadataUtil.encodeMessage(`The server does not implement ${path}`),
97
+ }, { endStream: true });
98
+ stream.resume();
99
+ return;
100
+ }
101
+ const call = new GrpcServerCall(stream, headers, handler.method, this.options);
102
+ call.run(handler.fn).catch(error => call.fail(error));
103
+ }
104
+ }
105
+ exports.GrpcServer = GrpcServer;
106
+ class GrpcServerCall {
107
+ constructor(stream, headers, method, options) {
108
+ this.stream = stream;
109
+ this.headers = headers;
110
+ this.method = method;
111
+ this.options = options;
112
+ this.controller = new AbortController();
113
+ this.responseHeaders = {};
114
+ this.trailers = {};
115
+ this.headersSent = false;
116
+ this.finished = false;
117
+ this.requestsRead = false;
118
+ this.metadata = metadata_1.MetadataUtil.fromHeaders(headers);
119
+ const timeout = metadata_1.MetadataUtil.parseTimeout(headers['grpc-timeout']);
120
+ if (timeout !== undefined) {
121
+ this.deadline = new Date(Date.now() + timeout);
122
+ this.timer = setTimeout(() => this.finish(new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.DEADLINE_EXCEEDED, 'Deadline exceeded')), timeout);
123
+ }
124
+ stream.once('close', () => {
125
+ clearTimeout(this.timer);
126
+ if (!this.finished) {
127
+ this.finished = true;
128
+ this.controller.abort(new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.CANCELLED, 'The call was cancelled'));
129
+ }
130
+ });
131
+ }
132
+ get signal() {
133
+ return this.controller.signal;
134
+ }
135
+ setHeader(key, value) {
136
+ if (this.headersSent) {
137
+ throw new Error('Response metadata is sent with the first response message; set it before.');
138
+ }
139
+ this.responseHeaders[key.toLowerCase()] = value;
140
+ }
141
+ setTrailer(key, value) {
142
+ this.trailers[key.toLowerCase()] = value;
143
+ }
144
+ async run(fn) {
145
+ var _a;
146
+ const { method } = this;
147
+ const input = method.requestStream ? this.requests() : await this.single();
148
+ const output = await fn(input, this);
149
+ if (method.responseStream) {
150
+ const iterator = toAsyncIterator(output, method);
151
+ try {
152
+ for (let r = await iterator.next(); !r.done; r = await iterator.next()) {
153
+ if (this.finished) {
154
+ break;
155
+ }
156
+ await this.write(r.value);
157
+ }
158
+ }
159
+ finally {
160
+ if (this.finished) {
161
+ await ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator));
162
+ }
163
+ }
164
+ }
165
+ else {
166
+ await this.write(output !== null && output !== void 0 ? output : {});
167
+ }
168
+ this.finish();
169
+ }
170
+ /** Ends the call with the status of `error`, reporting errors that are not gRPC statuses. */
171
+ fail(error) {
172
+ var _a;
173
+ const status = grpc_status_1.GrpcError.from(error);
174
+ if (status !== error && status.code === grpc_status_1.GrpcStatus.UNKNOWN && !this.finished) {
175
+ ((_a = this.options.onError) !== null && _a !== void 0 ? _a : console.error)(error, this.method);
176
+ }
177
+ this.finish(status);
178
+ }
179
+ /** Sends the status (OK when `error` is undefined) in the trailers and ends the call. */
180
+ finish(error) {
181
+ var _a;
182
+ if (this.finished) {
183
+ return;
184
+ }
185
+ this.finished = true;
186
+ clearTimeout(this.timer);
187
+ if (error) {
188
+ this.controller.abort(error);
189
+ }
190
+ if (this.stream.destroyed || this.stream.closed) {
191
+ return;
192
+ }
193
+ const trailers = metadata_1.MetadataUtil.toHeaders({ ...this.trailers, ...error === null || error === void 0 ? void 0 : error.metadata }, { 'grpc-status': String((_a = error === null || error === void 0 ? void 0 : error.code) !== null && _a !== void 0 ? _a : grpc_status_1.GrpcStatus.OK) });
194
+ if (error === null || error === void 0 ? void 0 : error.details) {
195
+ trailers['grpc-message'] = metadata_1.MetadataUtil.encodeMessage(error.details);
196
+ }
197
+ try {
198
+ if (this.headersSent) {
199
+ this.stream.once('wantTrailers', () => this.stream.sendTrailers(trailers));
200
+ this.stream.end();
201
+ }
202
+ else {
203
+ // Trailers-Only: the status in the only HEADERS frame.
204
+ this.stream.respond({ ...this.responseHeaderBlock(), ...trailers }, { endStream: true });
205
+ }
206
+ if (!this.stream.readableEnded) {
207
+ this.stream.resume();
208
+ }
209
+ }
210
+ catch (_b) {
211
+ // The client went away meanwhile.
212
+ this.stream.destroy();
213
+ }
214
+ }
215
+ responseHeaderBlock() {
216
+ return metadata_1.MetadataUtil.toHeaders(this.responseHeaders, {
217
+ ':status': 200,
218
+ 'content-type': 'application/grpc+proto',
219
+ 'grpc-accept-encoding': message_framer_1.ACCEPT_ENCODING,
220
+ });
221
+ }
222
+ async write(message) {
223
+ if (this.finished) {
224
+ return;
225
+ }
226
+ let framed;
227
+ try {
228
+ framed = message_framer_1.MessageFramer.frame(this.method.responseType.encode(message));
229
+ }
230
+ catch (error) {
231
+ throw new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.INTERNAL, `Could not encode the response of ${this.method.path}: ${error.message}`);
232
+ }
233
+ if (!this.headersSent) {
234
+ this.headersSent = true;
235
+ this.stream.respond(this.responseHeaderBlock(), { waitForTrailers: true });
236
+ }
237
+ if (!this.stream.write(framed)) {
238
+ await new Promise(resolve => {
239
+ const done = () => {
240
+ this.stream.off('drain', done);
241
+ this.stream.off('close', done);
242
+ resolve();
243
+ };
244
+ this.stream.on('drain', done);
245
+ this.stream.on('close', done);
246
+ });
247
+ }
248
+ }
249
+ async single() {
250
+ let request;
251
+ let count = 0;
252
+ for await (const message of this.requests()) {
253
+ request = message;
254
+ count++;
255
+ }
256
+ if (count !== 1) {
257
+ throw new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.INTERNAL, `${this.method.path} takes one request message, received ${count}`);
258
+ }
259
+ return request;
260
+ }
261
+ requests() {
262
+ var _a, _b;
263
+ if (this.requestsRead) {
264
+ throw new Error('The request stream can be read once.');
265
+ }
266
+ this.requestsRead = true;
267
+ const { stream } = this;
268
+ const type = this.method.requestType;
269
+ const queue = new async_queue_1.AsyncQueue({ pause: () => stream.pause(), resume: () => stream.resume() });
270
+ let deframer;
271
+ try {
272
+ deframer = new message_framer_1.MessageDeframer(String((_a = this.headers['grpc-encoding']) !== null && _a !== void 0 ? _a : 'identity'), (_b = this.options.maxReceiveMessageSize) !== null && _b !== void 0 ? _b : message_framer_1.DEFAULT_MAX_RECEIVE_MESSAGE_SIZE);
273
+ }
274
+ catch (error) {
275
+ queue.end(error);
276
+ return queue;
277
+ }
278
+ let failed = false;
279
+ stream.on('data', (chunk) => {
280
+ if (failed) {
281
+ return;
282
+ }
283
+ try {
284
+ for (const message of deframer.push(chunk)) {
285
+ queue.push(decode(type, message));
286
+ }
287
+ }
288
+ catch (error) {
289
+ failed = true;
290
+ queue.end(error);
291
+ }
292
+ });
293
+ stream.once('end', () => queue.end(deframer.pending ? new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.INTERNAL, 'The request stream ended in the middle of a message') : undefined));
294
+ this.signal.addEventListener('abort', () => queue.end(this.signal.reason), { once: true });
295
+ return queue;
296
+ }
297
+ }
298
+ function decode(type, message) {
299
+ try {
300
+ return type.decode(message);
301
+ }
302
+ catch (error) {
303
+ throw new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.INTERNAL, `Could not parse a ${type.fullName}: ${error.message}`);
304
+ }
305
+ }
306
+ function toAsyncIterator(output, method) {
307
+ if (output && typeof output[Symbol.asyncIterator] === 'function') {
308
+ return output[Symbol.asyncIterator]();
309
+ }
310
+ if (output && typeof output[Symbol.iterator] === 'function') {
311
+ const iterator = output[Symbol.iterator]();
312
+ return { next: async () => iterator.next(), return: async () => { var _a; var _b; return (_b = (_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator)) !== null && _b !== void 0 ? _b : { done: true, value: undefined }; } };
313
+ }
314
+ throw new grpc_status_1.GrpcError(grpc_status_1.GrpcStatus.INTERNAL, `${method.path} streams its responses: the method must return an (async) iterable, such as an async generator.`);
315
+ }
316
+ //# sourceMappingURL=grpc-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-server.js","sourceRoot":"","sources":["../../../src/node/server/grpc-server.ts"],"names":[],"mappings":";;;AAAA,2CAAuI;AAEvI,qDAAiD;AACjD,qDAA4D;AAC5D,2DAA2H;AAC3H,+CAA+D;AAyC/D;;;;;;;GAOG;AACH;IAKI,YAA+B,OAAO,GAAsB,EAAE;QAA/B,YAAO,GAAP,OAAO,CAAwB;QAJ3C,aAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QACtC,aAAQ,GAAG,IAAI,GAAG,EAAsB,CAAC;IAGK,CAAC;IAElE,UAAU,CAAC,OAA0B,EAAE,cAAsB;;QACzD,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,cAAyC,CAAC;YACvD,MAAM,EAAE,SAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mCAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,yBAAyB,OAAO,CAAC,QAAQ,sBAAsB,CAAC,CAAC;YACnG,CAAC;YACD,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC3B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,oFAAoF;IACpF,MAAM,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,WAAW;QACnC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,MAAM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AQ,CAAW,mCAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAA,EAAE,CAAC;IAC9H,CAAC;IACD,MAAM,IAAI,uBAAS,CAAC,wBAAU,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,IAAI,iGAAiG,CAAC,CAAC;AAC9J,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type ComponentOption } from '@celljs/core';
2
+ import type { ServiceDefinition } from '../proto/proto';
3
+ /** DI id of every {@link GrpcService} component. */
4
+ export declare const GRPC_SERVICE: unique symbol;
5
+ export declare const GRPC_SERVICE_TAG = "GrpcService";
6
+ /**
7
+ * Serves the class as the implementation of a gRPC service on the application's gRPC server
8
+ * (`cell.grpc.server`, port 50051 by default). Methods are named after the .proto methods in
9
+ * lowerCamelCase; the class is a component, so it can `@Autowired` others.
10
+ *
11
+ * ```ts
12
+ * @GrpcService(Greeter)
13
+ * export class GreeterService {
14
+ * sayHello({ name }: HelloRequest): HelloReply {
15
+ * return { message: `Hello ${name}` };
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ export declare function GrpcService(service: ServiceDefinition, option?: ComponentOption): ClassDecorator;
21
+ export declare namespace GrpcServiceUtil {
22
+ /** The service a {@link GrpcService} class implements. */
23
+ function getService(target: object): ServiceDefinition | undefined;
24
+ }
25
+ //# sourceMappingURL=grpc-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-service.d.ts","sourceRoot":"","sources":["../../../src/node/server/grpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,eAAe,EAAwB,MAAM,cAAc,CAAC;AACvG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,oDAAoD;AACpD,eAAO,MAAM,YAAY,eAAwB,CAAC;AAElD,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAI9C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,cAAc,CAQhG;AAED,yBAAiB,eAAe,CAAC;IAC7B,0DAA0D;IAC1D,SAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAExE;CACJ"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrpcServiceUtil = exports.GRPC_SERVICE_TAG = exports.GRPC_SERVICE = void 0;
4
+ exports.GrpcService = GrpcService;
5
+ const core_1 = require("@celljs/core");
6
+ /** DI id of every {@link GrpcService} component. */
7
+ exports.GRPC_SERVICE = Symbol('GrpcService');
8
+ exports.GRPC_SERVICE_TAG = 'GrpcService';
9
+ const SERVICE_KEY = 'cell:grpc-service';
10
+ /**
11
+ * Serves the class as the implementation of a gRPC service on the application's gRPC server
12
+ * (`cell.grpc.server`, port 50051 by default). Methods are named after the .proto methods in
13
+ * lowerCamelCase; the class is a component, so it can `@Autowired` others.
14
+ *
15
+ * ```ts
16
+ * @GrpcService(Greeter)
17
+ * export class GreeterService {
18
+ * sayHello({ name }: HelloRequest): HelloReply {
19
+ * return { message: `Hello ${name}` };
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ function GrpcService(service, option) {
25
+ return target => {
26
+ var _a;
27
+ const parsed = (0, core_1.parseComponentOption)(target, option !== null && option !== void 0 ? option : {});
28
+ parsed.id.push(exports.GRPC_SERVICE);
29
+ parsed.sysTags = [...((_a = parsed.sysTags) !== null && _a !== void 0 ? _a : []), exports.GRPC_SERVICE_TAG];
30
+ Reflect.defineMetadata(SERVICE_KEY, service, target);
31
+ (0, core_1.Component)(parsed)(target);
32
+ };
33
+ }
34
+ var GrpcServiceUtil;
35
+ (function (GrpcServiceUtil) {
36
+ /** The service a {@link GrpcService} class implements. */
37
+ function getService(target) {
38
+ return Reflect.getOwnMetadata(SERVICE_KEY, target);
39
+ }
40
+ GrpcServiceUtil.getService = getService;
41
+ })(GrpcServiceUtil || (exports.GrpcServiceUtil = GrpcServiceUtil = {}));
42
+ //# sourceMappingURL=grpc-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-service.js","sourceRoot":"","sources":["../../../src/node/server/grpc-service.ts"],"names":[],"mappings":";;;;AAAA,uCAAuG;AAGvG,oDAAoD;AACvC,QAAA,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAErC,QAAA,gBAAgB,GAAG,aAAa,CAAC;AAE9C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC;;;;;;;;;;;;;GAaG;AACH,qBAA4B,OAA0B,EAAE,MAAwB;IAC5E,OAAO,MAAM,CAAC,EAAE;;QACZ,MAAM,MAAM,GAAG,IAAA,2BAAoB,EAAC,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,EAAoB,CAAC,IAAI,CAAC,QAAA,YAAY,CAAC,CAAC;QAChD,MAAM,CAAC,OAAO,GAAG,CAAC,GAAG,OAAC,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC,EAAE,QAAA,gBAAgB,CAAC,CAAC;QAC/D,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACrD,IAAA,gBAAS,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;AACN,CAAC;AAED,IAAiB,eAAe,CAK/B;AALD,WAAiB,eAAe;IAC5B,0DAA0D;IAC1D,SAAgB,UAAU,CAAC,MAAc;QACrC,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAFe,gBAAA,UAAU,aAEzB,CAAA;AACL,CAAC,EALgB,eAAe,aAAf,eAAe,GAAf,eAAe,QAK/B"}
@@ -0,0 +1,3 @@
1
+ /** TEST_PROTO loaded by @grpc/proto-loader (protobuf.js), the reference implementation of the tests. */
2
+ export declare function loadTestProto(): import("@grpc/proto-loader").PackageDefinition;
3
+ //# sourceMappingURL=proto-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto-loader.d.ts","sourceRoot":"","sources":["../../../src/node/test/proto-loader.ts"],"names":[],"mappings":"AAMA,wGAAwG;AACxG,wBAAgB,aAAa,mDAK5B"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadTestProto = loadTestProto;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_os_1 = require("node:os");
6
+ const node_path_1 = require("node:path");
7
+ const proto_loader_1 = require("@grpc/proto-loader");
8
+ const test_protos_1 = require("./test-protos");
9
+ /** TEST_PROTO loaded by @grpc/proto-loader (protobuf.js), the reference implementation of the tests. */
10
+ function loadTestProto() {
11
+ const dir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cell-grpc-'));
12
+ const file = (0, node_path_1.join)(dir, 'test.proto');
13
+ (0, node_fs_1.writeFileSync)(file, test_protos_1.TEST_PROTO);
14
+ return (0, proto_loader_1.loadSync)(file, { keepCase: false, longs: String, enums: String, defaults: true, oneofs: true });
15
+ }
16
+ //# sourceMappingURL=proto-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto-loader.js","sourceRoot":"","sources":["../../../src/node/test/proto-loader.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,qCAAiC;AACjC,yCAAiC;AACjC,qDAA8C;AAC9C,+CAA2C;AAE3C,wGAAwG;AACxG;IACI,MAAM,GAAG,GAAG,IAAA,qBAAW,EAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,YAAY,CAAC,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACrC,IAAA,uBAAa,EAAC,IAAI,EAAE,wBAAU,CAAC,CAAC;IAChC,OAAO,IAAA,uBAAQ,EAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3G,CAAC"}