@camera.ui/rpc 1.0.1
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/README.md +3 -0
- package/dist/channel.d.ts +106 -0
- package/dist/channel.js +347 -0
- package/dist/channel.js.map +1 -0
- package/dist/chunking.d.ts +77 -0
- package/dist/chunking.js +151 -0
- package/dist/chunking.js.map +1 -0
- package/dist/client.d.ts +245 -0
- package/dist/client.js +1863 -0
- package/dist/client.js.map +1 -0
- package/dist/codec.d.ts +12 -0
- package/dist/codec.js +31 -0
- package/dist/codec.js.map +1 -0
- package/dist/decorators.d.ts +7 -0
- package/dist/decorators.js +192 -0
- package/dist/decorators.js.map +1 -0
- package/dist/errors.d.ts +30 -0
- package/dist/errors.js +54 -0
- package/dist/errors.js.map +1 -0
- package/dist/handler.d.ts +35 -0
- package/dist/handler.js +399 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/service.d.ts +60 -0
- package/dist/service.js +286 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +300 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +83 -0
- package/dist/utils.js +273 -0
- package/dist/utils.js.map +1 -0
- package/dist/wrapper.d.ts +1 -0
- package/dist/wrapper.js +2 -0
- package/dist/wrapper.js.map +1 -0
- package/package.json +49 -0
package/dist/handler.js
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { createError, RPCException } from './errors.js';
|
|
2
|
+
import { ERROR_CODES } from './types.js';
|
|
3
|
+
import { sleep } from './utils.js';
|
|
4
|
+
/**
|
|
5
|
+
* Handle streaming request - common logic for client and service
|
|
6
|
+
*/
|
|
7
|
+
export async function handleStreamRequest(handler, args, streamSubject, requestId, client) {
|
|
8
|
+
let generator;
|
|
9
|
+
// Check if handler is async or sync
|
|
10
|
+
const handlerResult = handler(...args);
|
|
11
|
+
// Check if the handler returned a Promise (async function)
|
|
12
|
+
if (handlerResult && typeof handlerResult.then === 'function') {
|
|
13
|
+
// Await the async result
|
|
14
|
+
const result = await handlerResult;
|
|
15
|
+
// Check if result is async generator
|
|
16
|
+
if (result && typeof result[Symbol.asyncIterator] === 'function') {
|
|
17
|
+
generator = result;
|
|
18
|
+
}
|
|
19
|
+
else if (result && typeof result[Symbol.iterator] === 'function') {
|
|
20
|
+
// Sync generator/iterator - convert to async
|
|
21
|
+
generator = (async function* () {
|
|
22
|
+
for (const value of result) {
|
|
23
|
+
yield value;
|
|
24
|
+
}
|
|
25
|
+
})();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw createError(ERROR_CODES.INTERNAL_ERROR, 'Handler must return a generator for stream');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (handlerResult && typeof handlerResult[Symbol.asyncIterator] === 'function') {
|
|
32
|
+
// Direct async generator
|
|
33
|
+
generator = handlerResult;
|
|
34
|
+
}
|
|
35
|
+
else if (handlerResult && typeof handlerResult[Symbol.iterator] === 'function') {
|
|
36
|
+
// Direct sync generator/iterator - convert to async
|
|
37
|
+
generator = (async function* () {
|
|
38
|
+
for (const value of handlerResult) {
|
|
39
|
+
yield value;
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw createError(ERROR_CODES.INTERNAL_ERROR, 'Handler must return a generator for stream');
|
|
45
|
+
}
|
|
46
|
+
// Listen for cancellation
|
|
47
|
+
let cancelled = false;
|
|
48
|
+
const cancelUnsub = await client.subscribe(`${streamSubject}.cancel`, () => {
|
|
49
|
+
cancelled = true;
|
|
50
|
+
});
|
|
51
|
+
// Give client time to set up subscription
|
|
52
|
+
await sleep(0);
|
|
53
|
+
// Stream values
|
|
54
|
+
try {
|
|
55
|
+
for await (const value of generator) {
|
|
56
|
+
if (cancelled || !client.isConnected)
|
|
57
|
+
break;
|
|
58
|
+
const streamMsg = {
|
|
59
|
+
id: requestId,
|
|
60
|
+
type: 'data',
|
|
61
|
+
data: value,
|
|
62
|
+
};
|
|
63
|
+
await client.publish(streamSubject, streamMsg);
|
|
64
|
+
}
|
|
65
|
+
if (!cancelled && client.isConnected) {
|
|
66
|
+
const endMsg = {
|
|
67
|
+
id: requestId,
|
|
68
|
+
type: 'end',
|
|
69
|
+
};
|
|
70
|
+
await client.publish(streamSubject, endMsg);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (!cancelled && client.isConnected) {
|
|
75
|
+
try {
|
|
76
|
+
const errorMsg = {
|
|
77
|
+
id: requestId,
|
|
78
|
+
type: 'error',
|
|
79
|
+
error: formatErrorObject(error),
|
|
80
|
+
};
|
|
81
|
+
await client.publish(streamSubject, errorMsg);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Ignore publish errors during disconnect
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
cancelUnsub();
|
|
90
|
+
// Ensure generator is closed
|
|
91
|
+
if (generator.return) {
|
|
92
|
+
try {
|
|
93
|
+
await generator.return();
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Ignore errors when closing generator
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Handle normal RPC call - common logic for client and service
|
|
103
|
+
*/
|
|
104
|
+
export async function handleNormalRPC(handler, params) {
|
|
105
|
+
// Ensure params is an array
|
|
106
|
+
const args = Array.isArray(params) ? params : params != null ? [params] : [];
|
|
107
|
+
// Call the handler
|
|
108
|
+
return handler(...args);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Format exception as error object
|
|
112
|
+
*/
|
|
113
|
+
export function formatErrorObject(error) {
|
|
114
|
+
if (error instanceof RPCException) {
|
|
115
|
+
return error.toJSON();
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return {
|
|
119
|
+
code: ERROR_CODES.INTERNAL_ERROR,
|
|
120
|
+
message: error instanceof Error ? error.message : 'Internal error',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Handle pull-based iterator request
|
|
126
|
+
*/
|
|
127
|
+
export async function handlePullIteratorRequest(handler, args, iteratorId, client) {
|
|
128
|
+
let generator;
|
|
129
|
+
// Check if handler is async or sync
|
|
130
|
+
const handlerResult = handler(...args);
|
|
131
|
+
// Check if the handler returned a Promise (async function)
|
|
132
|
+
if (handlerResult && typeof handlerResult.then === 'function') {
|
|
133
|
+
// Await the async result
|
|
134
|
+
const result = await handlerResult;
|
|
135
|
+
// Check if result is async generator
|
|
136
|
+
if (result && typeof result[Symbol.asyncIterator] === 'function') {
|
|
137
|
+
generator = result;
|
|
138
|
+
}
|
|
139
|
+
else if (result && typeof result[Symbol.iterator] === 'function') {
|
|
140
|
+
// Sync generator/iterator - convert to async
|
|
141
|
+
generator = (async function* () {
|
|
142
|
+
for (const value of result) {
|
|
143
|
+
yield value;
|
|
144
|
+
}
|
|
145
|
+
})();
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw createError(ERROR_CODES.INTERNAL_ERROR, 'Handler must return a generator for pull iterator');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (handlerResult && typeof handlerResult[Symbol.asyncIterator] === 'function') {
|
|
152
|
+
// Direct async generator
|
|
153
|
+
generator = handlerResult;
|
|
154
|
+
}
|
|
155
|
+
else if (handlerResult && typeof handlerResult[Symbol.iterator] === 'function') {
|
|
156
|
+
// Direct sync generator/iterator - convert to async
|
|
157
|
+
generator = (async function* () {
|
|
158
|
+
for (const value of handlerResult) {
|
|
159
|
+
yield value;
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
throw createError(ERROR_CODES.INTERNAL_ERROR, 'Handler must return a generator for pull iterator');
|
|
165
|
+
}
|
|
166
|
+
// Set up request/response subjects
|
|
167
|
+
const requestSubject = `_rpc.iterator.${iteratorId}.request`;
|
|
168
|
+
const responseSubject = `_rpc.iterator.${iteratorId}.response`;
|
|
169
|
+
// Track if iterator is active
|
|
170
|
+
let active = true;
|
|
171
|
+
// Subscribe to iterator requests
|
|
172
|
+
const unsub = await client.subscribe(requestSubject, async (msg) => {
|
|
173
|
+
if (!active)
|
|
174
|
+
return;
|
|
175
|
+
try {
|
|
176
|
+
if (msg.type === 'cancel') {
|
|
177
|
+
active = false;
|
|
178
|
+
// Close the generator explicitly
|
|
179
|
+
if (generator.return) {
|
|
180
|
+
await generator.return();
|
|
181
|
+
}
|
|
182
|
+
const response = {
|
|
183
|
+
id: iteratorId,
|
|
184
|
+
type: 'done',
|
|
185
|
+
};
|
|
186
|
+
await client.publish(responseSubject, response);
|
|
187
|
+
}
|
|
188
|
+
else if (msg.type === 'next') {
|
|
189
|
+
const { value, done } = await generator.next();
|
|
190
|
+
if (done) {
|
|
191
|
+
active = false;
|
|
192
|
+
const response = {
|
|
193
|
+
id: iteratorId,
|
|
194
|
+
type: 'done',
|
|
195
|
+
};
|
|
196
|
+
await client.publish(responseSubject, response);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
const response = {
|
|
200
|
+
id: iteratorId,
|
|
201
|
+
type: 'value',
|
|
202
|
+
value,
|
|
203
|
+
};
|
|
204
|
+
await client.publish(responseSubject, response);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
active = false;
|
|
210
|
+
const response = {
|
|
211
|
+
id: iteratorId,
|
|
212
|
+
type: 'error',
|
|
213
|
+
error: formatErrorObject(error),
|
|
214
|
+
};
|
|
215
|
+
await client.publish(responseSubject, response);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
// Return cleanup function
|
|
219
|
+
const cleanup = async () => {
|
|
220
|
+
active = false;
|
|
221
|
+
unsub();
|
|
222
|
+
// Ensure generator is closed
|
|
223
|
+
if (generator.return) {
|
|
224
|
+
try {
|
|
225
|
+
await generator.return();
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
// Ignore errors when closing generator
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
return cleanup;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Handle a pull-iterator-with-callbacks request.
|
|
236
|
+
*
|
|
237
|
+
* Builds a callback proxy whose methods publish oneway to `callbackSubject`,
|
|
238
|
+
* invokes the user handler with (...args, callbackProxy), then drives the
|
|
239
|
+
* returned async generator from iterator `next`/`cancel` requests.
|
|
240
|
+
*
|
|
241
|
+
* The iterator yields `undefined` — its sole purpose is client-driven flow
|
|
242
|
+
* control. Meaningful data travels over the callback channel.
|
|
243
|
+
*/
|
|
244
|
+
export async function handlePullCallbackRequest(handler, args, iteratorId, callbackSubject, callbackMethods, onewayMethods, client) {
|
|
245
|
+
// Build callback proxy. Each method publishes a CallbackInvocation oneway.
|
|
246
|
+
// Methods not in onewayMethods reject with NotImplemented (request-reply is v2).
|
|
247
|
+
const onewaySet = new Set(onewayMethods);
|
|
248
|
+
const callbackProxy = {};
|
|
249
|
+
let proxyActive = true;
|
|
250
|
+
for (const method of callbackMethods) {
|
|
251
|
+
const isOneway = onewaySet.has(method);
|
|
252
|
+
if (isOneway) {
|
|
253
|
+
callbackProxy[method] = (...a) => {
|
|
254
|
+
if (!proxyActive || !client.isConnected)
|
|
255
|
+
return;
|
|
256
|
+
const msg = { method, args: a };
|
|
257
|
+
client.publish(callbackSubject, msg).catch(() => {
|
|
258
|
+
// Swallow publish errors (disconnect mid-flight, client already gone).
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
callbackProxy[method] = () => {
|
|
264
|
+
throw createError(ERROR_CODES.INTERNAL_ERROR, `Request-reply callback '${method}' not supported in v1`);
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// Invoke the handler with callback proxy appended as last argument.
|
|
269
|
+
let generator;
|
|
270
|
+
const handlerResult = handler(...args, callbackProxy);
|
|
271
|
+
const coerceToAsyncGenerator = (r) => {
|
|
272
|
+
if (r && typeof r[Symbol.asyncIterator] === 'function')
|
|
273
|
+
return r;
|
|
274
|
+
if (r && typeof r[Symbol.iterator] === 'function') {
|
|
275
|
+
return (async function* () {
|
|
276
|
+
for (const value of r)
|
|
277
|
+
yield value;
|
|
278
|
+
})();
|
|
279
|
+
}
|
|
280
|
+
throw createError(ERROR_CODES.INTERNAL_ERROR, 'Handler must return a generator for pull-callback iterator');
|
|
281
|
+
};
|
|
282
|
+
if (handlerResult && typeof handlerResult.then === 'function') {
|
|
283
|
+
generator = coerceToAsyncGenerator(await handlerResult);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
generator = coerceToAsyncGenerator(handlerResult);
|
|
287
|
+
}
|
|
288
|
+
// Iterator request/response subjects (shared with plain pull iterator).
|
|
289
|
+
const requestSubject = `_rpc.iterator.${iteratorId}.request`;
|
|
290
|
+
const responseSubject = `_rpc.iterator.${iteratorId}.response`;
|
|
291
|
+
let active = true;
|
|
292
|
+
const unsub = await client.subscribe(requestSubject, async (msg) => {
|
|
293
|
+
if (!active)
|
|
294
|
+
return;
|
|
295
|
+
try {
|
|
296
|
+
if (msg.type === 'cancel') {
|
|
297
|
+
active = false;
|
|
298
|
+
proxyActive = false;
|
|
299
|
+
if (generator.return) {
|
|
300
|
+
await generator.return();
|
|
301
|
+
}
|
|
302
|
+
const response = { id: iteratorId, type: 'done' };
|
|
303
|
+
await client.publish(responseSubject, response);
|
|
304
|
+
}
|
|
305
|
+
else if (msg.type === 'next') {
|
|
306
|
+
const { done } = await generator.next();
|
|
307
|
+
if (done) {
|
|
308
|
+
active = false;
|
|
309
|
+
proxyActive = false;
|
|
310
|
+
const response = { id: iteratorId, type: 'done' };
|
|
311
|
+
await client.publish(responseSubject, response);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
// Batch boundary reached. Value is ignored by the protocol.
|
|
315
|
+
const response = { id: iteratorId, type: 'value' };
|
|
316
|
+
await client.publish(responseSubject, response);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
active = false;
|
|
322
|
+
proxyActive = false;
|
|
323
|
+
const response = {
|
|
324
|
+
id: iteratorId,
|
|
325
|
+
type: 'error',
|
|
326
|
+
error: formatErrorObject(error),
|
|
327
|
+
};
|
|
328
|
+
await client.publish(responseSubject, response);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const cleanup = async () => {
|
|
332
|
+
active = false;
|
|
333
|
+
proxyActive = false;
|
|
334
|
+
unsub();
|
|
335
|
+
if (generator.return) {
|
|
336
|
+
try {
|
|
337
|
+
await generator.return();
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
// Ignore errors when closing generator
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
return cleanup;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Handle callback subscription request.
|
|
348
|
+
* Creates a wrapper function, calls the handler with it,
|
|
349
|
+
* and manages the subscription lifecycle.
|
|
350
|
+
*/
|
|
351
|
+
export async function handleCallbackRequest(handler, args, callbackSubject, requestId, client) {
|
|
352
|
+
// Create wrapper callback that publishes to callbackSubject
|
|
353
|
+
const wrapperCallback = async (value) => {
|
|
354
|
+
if (!client.isConnected)
|
|
355
|
+
return;
|
|
356
|
+
const msg = {
|
|
357
|
+
id: requestId,
|
|
358
|
+
type: 'data',
|
|
359
|
+
data: value,
|
|
360
|
+
};
|
|
361
|
+
await client.publish(callbackSubject, msg);
|
|
362
|
+
};
|
|
363
|
+
// Call handler with args + wrapper callback
|
|
364
|
+
let handlerCleanup;
|
|
365
|
+
try {
|
|
366
|
+
const result = handler(...args, wrapperCallback);
|
|
367
|
+
// Handler may return cleanup sync or async
|
|
368
|
+
if (result && typeof result.then === 'function') {
|
|
369
|
+
handlerCleanup = await result;
|
|
370
|
+
}
|
|
371
|
+
else if (typeof result === 'function') {
|
|
372
|
+
handlerCleanup = result;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
// Send error to subscriber
|
|
377
|
+
const errorMsg = {
|
|
378
|
+
id: requestId,
|
|
379
|
+
type: 'error',
|
|
380
|
+
error: formatErrorObject(error),
|
|
381
|
+
};
|
|
382
|
+
await client.publish(callbackSubject, errorMsg);
|
|
383
|
+
throw error;
|
|
384
|
+
}
|
|
385
|
+
// Subscribe to cancel subject
|
|
386
|
+
const cancelUnsub = await client.subscribe(`${callbackSubject}.cancel`, async () => {
|
|
387
|
+
if (handlerCleanup) {
|
|
388
|
+
await handlerCleanup();
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
// Return combined cleanup
|
|
392
|
+
return async () => {
|
|
393
|
+
cancelUnsub();
|
|
394
|
+
if (handlerCleanup) {
|
|
395
|
+
await handlerCleanup();
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAKnC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAiB,EAAE,IAAW,EAAE,aAAqB,EAAE,SAAiB,EAAE,MAAiB;IACnI,IAAI,SAA6C,CAAC;IAElD,oCAAoC;IACpC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;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,CAAC;YAChD,cAAc,GAAG,MAAM,MAAM,CAAC;QAChC,CAAC;aAAM,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACxC,cAAc,GAAG,MAAM,CAAC;QAC1B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2BAA2B;QAC3B,MAAM,QAAQ,GAAoB;YAChC,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC;SAChC,CAAC;QACF,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,8BAA8B;IAC9B,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,eAAe,SAAS,EAAE,KAAK,IAAI,EAAE;QACjF,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,cAAc,EAAE,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,OAAO,KAAK,IAAI,EAAE;QAChB,WAAW,EAAE,CAAC;QACd,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,cAAc,EAAE,CAAC;QACzB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createRPCClient } from './client.js';
|
|
2
|
+
export { Channel, PrivateChannel } from './channel.js';
|
|
3
|
+
export { isNoRespondersError, isRPCError, RPCException } from './errors.js';
|
|
4
|
+
export { ERROR_CODES } from './types.js';
|
|
5
|
+
export { RPCService, Service } from './service.js';
|
|
6
|
+
export { RPCClass, RPCMethod, RPCNested, RPCProperty } from './decorators.js';
|
|
7
|
+
export { rpcCallbacks } from './utils.js';
|
|
8
|
+
export type { CallbackInvocation, CallbackMessage, CallbackParams, ErrorCode, PullCallbackParams, RPCAuthOptions, RPCClient, RPCClientOptions, RPCError, } from './types.js';
|
|
9
|
+
export type { Promisify } from './types.js';
|
|
10
|
+
export type { ServiceConfig, ServiceInfo, ServiceStats } from '@nats-io/services';
|
|
11
|
+
export type * from '@nats-io/nats-core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Main client
|
|
2
|
+
export { createRPCClient } from './client.js';
|
|
3
|
+
// Channel/PrivateChannel for bidirectional communication
|
|
4
|
+
export { Channel, PrivateChannel } from './channel.js';
|
|
5
|
+
// Error handling
|
|
6
|
+
export { isNoRespondersError, isRPCError, RPCException } from './errors.js';
|
|
7
|
+
export { ERROR_CODES } from './types.js';
|
|
8
|
+
// Service support
|
|
9
|
+
export { RPCService, Service } from './service.js';
|
|
10
|
+
// Decorators
|
|
11
|
+
export { RPCClass, RPCMethod, RPCNested, RPCProperty } from './decorators.js';
|
|
12
|
+
// Pull-iterator-with-callbacks helper
|
|
13
|
+
export { rpcCallbacks } from './utils.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvD,iBAAiB;AACjB,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEnD,aAAa;AACb,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9E,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Service as NATSService, ServiceClient, ServiceConfig, ServiceInfo, ServiceStats } from '@nats-io/services';
|
|
2
|
+
import type { NatsConnection } from '@nats-io/transport-node';
|
|
3
|
+
import type { RPCClient } from './client.js';
|
|
4
|
+
/**
|
|
5
|
+
* RPC Service wrapper with automatic encoding/decoding and streaming support
|
|
6
|
+
*/
|
|
7
|
+
export declare class RPCService {
|
|
8
|
+
private client;
|
|
9
|
+
private svc?;
|
|
10
|
+
private services;
|
|
11
|
+
private initialized;
|
|
12
|
+
constructor(client: RPCClient);
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the service manager
|
|
15
|
+
*/
|
|
16
|
+
init(nc: NatsConnection): void;
|
|
17
|
+
/**
|
|
18
|
+
* Add a service with automatic RPC endpoint wrapping
|
|
19
|
+
* Supports objects, classes, nested structures, streaming, and chunking
|
|
20
|
+
*/
|
|
21
|
+
registerHandler(config: ServiceConfig, handlers: object, options?: {
|
|
22
|
+
isolatedConnection?: boolean;
|
|
23
|
+
}): Promise<Service>;
|
|
24
|
+
/**
|
|
25
|
+
* Get service monitoring client
|
|
26
|
+
*/
|
|
27
|
+
monitor(): ServiceClient;
|
|
28
|
+
/**
|
|
29
|
+
* Stop all services and cleanup isolated connections
|
|
30
|
+
*/
|
|
31
|
+
stopAll(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Stop a specific service by name
|
|
34
|
+
*/
|
|
35
|
+
stop(serviceName: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Get all services info
|
|
38
|
+
*/
|
|
39
|
+
getAllInfo(): ServiceInfo[];
|
|
40
|
+
/**
|
|
41
|
+
* Get info for a specific service
|
|
42
|
+
*/
|
|
43
|
+
getInfo(serviceName: string): ServiceInfo | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get all services stats
|
|
46
|
+
*/
|
|
47
|
+
getAllStats(): Promise<ServiceStats[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Get stats for a specific service
|
|
50
|
+
*/
|
|
51
|
+
getStats(serviceName: string): Promise<ServiceStats | undefined>;
|
|
52
|
+
}
|
|
53
|
+
export declare class Service {
|
|
54
|
+
private natsService;
|
|
55
|
+
get isStopped(): boolean;
|
|
56
|
+
constructor(natsService: NATSService);
|
|
57
|
+
info(): ServiceInfo;
|
|
58
|
+
stats(): Promise<ServiceStats>;
|
|
59
|
+
stop(err?: Error): Promise<void>;
|
|
60
|
+
}
|