@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.
@@ -0,0 +1,83 @@
1
+ import type { ServiceInfo } from '@nats-io/services';
2
+ import type { RPCClient } from './client.js';
3
+ import type { Promisify } from './types.js';
4
+ /**
5
+ * Mark a plain object of functions as a callback bundle that can be passed
6
+ * as an argument to pull-callback RPC methods. The proxy detects the marker
7
+ * and routes the call through callPullIteratorWithCallback().
8
+ *
9
+ * @example
10
+ * const cbs = rpcCallbacks({
11
+ * onItem: (data) => queue.push(data),
12
+ * onEndOfBatch: () => batchEnd.resolve(),
13
+ * }, { oneway: ['onItem', 'onEndOfBatch'] });
14
+ *
15
+ * for await (const _ of service.pullBatches(count, cbs)) {
16
+ * // batch boundary — apply backpressure here
17
+ * }
18
+ */
19
+ export declare function rpcCallbacks<T extends Record<string, (...a: any[]) => any>>(obj: T, options?: {
20
+ oneway?: (keyof T)[];
21
+ }): T;
22
+ /** Test whether a value was produced by rpcCallbacks(). */
23
+ export declare function isRpcCallbacks(v: any): v is Record<string, (...a: any[]) => any>;
24
+ /** Read the oneway-method list from a callback bundle. */
25
+ export declare function getCallbacksOneway(v: any): string[];
26
+ /**
27
+ * Promise check. Used internally to detect async handlers
28
+ * that need to be awaited so dispatch stays ordered.
29
+ */
30
+ export declare function isPromise(value: unknown): value is Promise<unknown>;
31
+ /**
32
+ * Create a proxy for RPC calls with support for nested objects
33
+ * Works for both flat and deep object structures
34
+ *
35
+ * @param client - RPC client with call and callStream methods
36
+ * @param namespace - RPC namespace
37
+ * @param path - Current path in proxy hierarchy (internal use)
38
+ * @param methodCache - Shared method cache for method discovery
39
+ * @returns Proxy that intercepts property access and method calls
40
+ *
41
+ * @example
42
+ * // Flat usage
43
+ * const service = client.createProxy<MyService>('myservice');
44
+ * await service.someMethod();
45
+ *
46
+ * // Nested usage
47
+ * const app = client.createProxy<AppService>('app');
48
+ * await app.db.find('key');
49
+ *
50
+ * // Streaming
51
+ * for await (const item of service.dataStream()) {
52
+ * console.log(item);
53
+ * }
54
+ *
55
+ * // Optional chaining for unknown methods
56
+ * const result = await service.maybeMethod?.(); // undefined if method doesn't exist
57
+ */
58
+ export declare function createProxy<T extends object>(client: RPCClient, namespace: string, path?: string[], methodCache?: Set<string> | null): Promisify<T>;
59
+ /**
60
+ * Create a service proxy with proper streaming support
61
+ * Handles NATS service endpoints with automatic discovery
62
+ *
63
+ * @param client - RPC client instance
64
+ * @param selected - Selected service info from discovery
65
+ * @param timeout - Optional timeout for requests
66
+ * @param path - Current path in proxy hierarchy (internal use)
67
+ * @returns Proxy that intercepts property access and method calls
68
+ *
69
+ * @example
70
+ * const service = await client.createServiceProxy<MyService>('myservice');
71
+ * await service.someMethod();
72
+ *
73
+ * // Nested endpoints
74
+ * await service.config.get();
75
+ *
76
+ * // Streaming
77
+ * for await (const item of service.generateData()) {
78
+ * console.log(item);
79
+ * }
80
+ */
81
+ export declare function createServiceProxy<T extends object>(client: RPCClient, selected: ServiceInfo, timeout?: number, path?: string[]): Promisify<T>;
82
+ export declare function generateId(): string;
83
+ export declare function sleep(ms: number): Promise<void>;
package/dist/utils.js ADDED
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Symbol keys used to mark objects as rpc callback bundles.
3
+ * Hidden from Object.keys() / JSON serialization.
4
+ */
5
+ const RPC_CALLBACKS_MARKER = Symbol.for('rpc.callbacks');
6
+ const RPC_CALLBACKS_ONEWAY = Symbol.for('rpc.callbacks.oneway');
7
+ /**
8
+ * Mark a plain object of functions as a callback bundle that can be passed
9
+ * as an argument to pull-callback RPC methods. The proxy detects the marker
10
+ * and routes the call through callPullIteratorWithCallback().
11
+ *
12
+ * @example
13
+ * const cbs = rpcCallbacks({
14
+ * onItem: (data) => queue.push(data),
15
+ * onEndOfBatch: () => batchEnd.resolve(),
16
+ * }, { oneway: ['onItem', 'onEndOfBatch'] });
17
+ *
18
+ * for await (const _ of service.pullBatches(count, cbs)) {
19
+ * // batch boundary — apply backpressure here
20
+ * }
21
+ */
22
+ // eslint-disable-next-line space-before-function-paren
23
+ export function rpcCallbacks(obj, options) {
24
+ Object.defineProperty(obj, RPC_CALLBACKS_MARKER, { value: true, enumerable: false });
25
+ Object.defineProperty(obj, RPC_CALLBACKS_ONEWAY, {
26
+ value: options?.oneway ?? Object.keys(obj),
27
+ enumerable: false,
28
+ });
29
+ return obj;
30
+ }
31
+ /** Test whether a value was produced by rpcCallbacks(). */
32
+ export function isRpcCallbacks(v) {
33
+ return !!v && typeof v === 'object' && v[RPC_CALLBACKS_MARKER] === true;
34
+ }
35
+ /** Read the oneway-method list from a callback bundle. */
36
+ export function getCallbacksOneway(v) {
37
+ return v?.[RPC_CALLBACKS_ONEWAY] ?? [];
38
+ }
39
+ /**
40
+ * Promise check. Used internally to detect async handlers
41
+ * that need to be awaited so dispatch stays ordered.
42
+ */
43
+ export function isPromise(value) {
44
+ if (value instanceof Promise)
45
+ return true;
46
+ if (value === null || typeof value !== 'object')
47
+ return false;
48
+ const v = value;
49
+ return typeof v.then === 'function' && typeof v.catch === 'function';
50
+ }
51
+ /**
52
+ * Create a proxy for RPC calls with support for nested objects
53
+ * Works for both flat and deep object structures
54
+ *
55
+ * @param client - RPC client with call and callStream methods
56
+ * @param namespace - RPC namespace
57
+ * @param path - Current path in proxy hierarchy (internal use)
58
+ * @param methodCache - Shared method cache for method discovery
59
+ * @returns Proxy that intercepts property access and method calls
60
+ *
61
+ * @example
62
+ * // Flat usage
63
+ * const service = client.createProxy<MyService>('myservice');
64
+ * await service.someMethod();
65
+ *
66
+ * // Nested usage
67
+ * const app = client.createProxy<AppService>('app');
68
+ * await app.db.find('key');
69
+ *
70
+ * // Streaming
71
+ * for await (const item of service.dataStream()) {
72
+ * console.log(item);
73
+ * }
74
+ *
75
+ * // Optional chaining for unknown methods
76
+ * const result = await service.maybeMethod?.(); // undefined if method doesn't exist
77
+ */
78
+ export function createProxy(client, namespace, path = [], methodCache = null) {
79
+ // Shared cache reference that can be updated
80
+ let cache = methodCache;
81
+ const updateCache = (methods) => {
82
+ cache ??= new Set(methods);
83
+ };
84
+ const stripMethods = (result) => {
85
+ // Skip binary data types - spread operator would convert them to plain objects
86
+ if (result instanceof Uint8Array || result instanceof ArrayBuffer) {
87
+ return result;
88
+ }
89
+ if (result && typeof result === 'object' && '__methods' in result) {
90
+ updateCache(result.__methods);
91
+ const { __methods, ...rest } = result;
92
+ return Array.isArray(result) ? Object.assign([...result], rest) : rest;
93
+ }
94
+ return result;
95
+ };
96
+ return new Proxy({}, {
97
+ get(_target, prop) {
98
+ // Handle promise-like detection (for async/await)
99
+ if (prop === 'then' || prop === 'catch' || prop === 'finally') {
100
+ return undefined;
101
+ }
102
+ // Handle inspection and debugging
103
+ if (typeof prop === 'symbol' || prop === 'toString') {
104
+ return () => `[RPCProxy ${namespace}${path.length ? '.' + path.join('.') : ''}]`;
105
+ }
106
+ // If we have cached methods and this method doesn't exist, return undefined
107
+ // This enables: proxy.nonExistent?.() → undefined
108
+ if (cache && path.length === 0 && !cache.has(prop)) {
109
+ return undefined;
110
+ }
111
+ // Build the full path
112
+ const fullPath = [...path, prop];
113
+ // Return a callable proxy that can also act as a thenable
114
+ return new Proxy(function () { }, {
115
+ // Handle method calls
116
+ apply(_target, _thisArg, args) {
117
+ const method = fullPath.join('.');
118
+ const subject = `rpc.${namespace}.${method}`;
119
+ const isPullIterator = prop.toLowerCase().includes('pull');
120
+ // rpcCallbacks() bundle in args → pull-callback mode.
121
+ // The bundle itself is the unambiguous marker — a name heuristic
122
+ // would only add a false negative for methods whose name doesn't
123
+ // happen to contain "pull".
124
+ const callbacksIdx = args.findIndex((a) => isRpcCallbacks(a));
125
+ if (callbacksIdx !== -1) {
126
+ const cbs = args[callbacksIdx];
127
+ const oneway = getCallbacksOneway(cbs);
128
+ const otherArgs = args.filter((_, i) => i !== callbacksIdx);
129
+ return client.callPullIteratorWithCallback(subject, cbs, oneway, ...otherArgs);
130
+ }
131
+ // Detect plain function argument → classic callback subscription
132
+ const callbackIdx = args.findIndex((a) => typeof a === 'function');
133
+ if (callbackIdx !== -1) {
134
+ const callback = args[callbackIdx];
135
+ const otherArgs = args.filter((_, i) => i !== callbackIdx);
136
+ return client.callWithCallback(subject, otherArgs, callback);
137
+ }
138
+ const isGenerator = prop.toLowerCase().includes('generate');
139
+ if (isGenerator) {
140
+ return client.callStream(subject, ...args);
141
+ }
142
+ else if (isPullIterator) {
143
+ return client.callPullIterator(subject, ...args);
144
+ }
145
+ else {
146
+ // Wrap call to strip __methods from result
147
+ return (async () => {
148
+ const result = await client.call(subject, ...args);
149
+ return stripMethods(result);
150
+ })();
151
+ }
152
+ },
153
+ // Handle nested property access and promise resolution
154
+ get(_target, nestedProp) {
155
+ // Check if this is a promise method (then, catch, finally)
156
+ if (nestedProp === 'then' || nestedProp === 'catch' || nestedProp === 'finally') {
157
+ // This property is being awaited - make the RPC call
158
+ const method = fullPath.join('.');
159
+ const promise = (async () => {
160
+ if (!client.isConnected && !client.isClosed) {
161
+ await client.connect();
162
+ }
163
+ const result = await client.call(`rpc.${namespace}.${method}`);
164
+ return stripMethods(result);
165
+ })();
166
+ // @ts-ignore
167
+ return promise[nestedProp].bind(promise);
168
+ }
169
+ // Otherwise, return another proxy for nested access (share cache)
170
+ return createProxy(client, namespace, fullPath, cache)[nestedProp];
171
+ },
172
+ });
173
+ },
174
+ });
175
+ }
176
+ /**
177
+ * Create a service proxy with proper streaming support
178
+ * Handles NATS service endpoints with automatic discovery
179
+ *
180
+ * @param client - RPC client instance
181
+ * @param selected - Selected service info from discovery
182
+ * @param timeout - Optional timeout for requests
183
+ * @param path - Current path in proxy hierarchy (internal use)
184
+ * @returns Proxy that intercepts property access and method calls
185
+ *
186
+ * @example
187
+ * const service = await client.createServiceProxy<MyService>('myservice');
188
+ * await service.someMethod();
189
+ *
190
+ * // Nested endpoints
191
+ * await service.config.get();
192
+ *
193
+ * // Streaming
194
+ * for await (const item of service.generateData()) {
195
+ * console.log(item);
196
+ * }
197
+ */
198
+ export function createServiceProxy(client, selected, timeout, path = []) {
199
+ const target = {};
200
+ return new Proxy(target, {
201
+ get(target, prop) {
202
+ // Handle special properties
203
+ if (prop === 'then' || prop === 'catch' || prop === 'finally') {
204
+ return undefined;
205
+ }
206
+ if (typeof prop === 'symbol' || prop === 'toString') {
207
+ return () => `[ServiceProxy ${selected.name}${path.length ? '.' + path.join('.') : ''}]`;
208
+ }
209
+ // Check if property exists on target (for added methods like disconnect)
210
+ if (prop in target) {
211
+ return target[prop];
212
+ }
213
+ const fullPath = [...path, prop];
214
+ const fullPathStr = fullPath.join('.');
215
+ // Check if this is an endpoint
216
+ const endpoint = selected.endpoints.find((e) => {
217
+ // Match exact path or last segment
218
+ if (e.subject === fullPathStr)
219
+ return true;
220
+ const parts = e.subject.split('.');
221
+ return parts[parts.length - 1] === prop && parts.slice(0, -1).join('.') === path.join('.');
222
+ });
223
+ if (endpoint) {
224
+ // Return a callable proxy similar to createProxy
225
+ return new Proxy(function () { }, {
226
+ apply(_target, _thisArg, args) {
227
+ const isPullIterator = prop.toLowerCase().includes('pull');
228
+ // rpcCallbacks() bundle in args → pull-callback mode
229
+ // (bundle marker is unambiguous, no name heuristic needed).
230
+ const callbacksIdx = args.findIndex((a) => isRpcCallbacks(a));
231
+ if (callbacksIdx !== -1) {
232
+ const cbs = args[callbacksIdx];
233
+ const oneway = getCallbacksOneway(cbs);
234
+ const otherArgs = args.filter((_, i) => i !== callbacksIdx);
235
+ return client.callPullIteratorWithCallback(endpoint.subject, cbs, oneway, ...otherArgs);
236
+ }
237
+ // Detect plain function argument → callback mode
238
+ const callbackIdx = args.findIndex((a) => typeof a === 'function');
239
+ if (callbackIdx !== -1) {
240
+ const callback = args[callbackIdx];
241
+ const otherArgs = args.filter((_, i) => i !== callbackIdx);
242
+ return client.callWithCallback(endpoint.subject, otherArgs, callback);
243
+ }
244
+ const isGenerator = prop.toLowerCase().includes('generate');
245
+ if (isGenerator) {
246
+ return client.callStream(endpoint.subject, ...args);
247
+ }
248
+ else if (isPullIterator) {
249
+ return client.callPullIterator(endpoint.subject, ...args);
250
+ }
251
+ else {
252
+ return client.call(endpoint.subject, ...args);
253
+ }
254
+ },
255
+ });
256
+ }
257
+ // Check if this is a nested namespace
258
+ const prefix = fullPathStr + '.';
259
+ const hasNested = selected.endpoints.some((e) => e.subject.startsWith(prefix));
260
+ if (hasNested) {
261
+ return createServiceProxy(client, selected, timeout, fullPath);
262
+ }
263
+ return undefined;
264
+ },
265
+ });
266
+ }
267
+ export function generateId() {
268
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
269
+ }
270
+ export function sleep(ms) {
271
+ return new Promise((resolve) => setTimeout(resolve, ms));
272
+ }
273
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACzD,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAiD,GAAM,EAAE,OAAkC;IACrH,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACrF,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,oBAAoB,EAAE;QAC/C,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1C,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,cAAc,CAAC,CAAM;IACnC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,K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ED,MAAM,UAAU,UAAU;IACxB,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1 @@
1
+ export { wsconnect as connect, createInbox, errors, headers } from '@nats-io/nats-core';
@@ -0,0 +1,2 @@
1
+ export { wsconnect as connect, createInbox, errors, headers } from '@nats-io/nats-core';
2
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../src/wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@camera.ui/rpc",
3
+ "version": "1.0.1",
4
+ "description": "camera.ui rpc package",
5
+ "author": "seydx (https://github.com/cameraui/rpc)",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "rimraf dist && tsc -p tsconfig.build.json",
16
+ "format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
17
+ "lint": "eslint .",
18
+ "lint:fix": "eslint --fix .",
19
+ "test": "vitest run",
20
+ "prepublishOnly": "npm i --package-lock-only && npm run lint:fix && npm run format && npm run build"
21
+ },
22
+ "devDependencies": {
23
+ "vitest": "^4.1.9"
24
+ },
25
+ "dependencies": {
26
+ "@nats-io/nats-core": "^3.4.0",
27
+ "@nats-io/services": "^3.4.0",
28
+ "@nats-io/transport-node": "^3.4.0",
29
+ "msgpackr": "^2.0.4",
30
+ "reflect-metadata": "^0.2.2"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/cameraui/rpc/issues"
34
+ },
35
+ "engines": {
36
+ "node": ">=22.0.0"
37
+ },
38
+ "homepage": "https://github.com/cameraui/rpc#readme",
39
+ "keywords": [
40
+ "camera.ui",
41
+ "nats",
42
+ "rpc"
43
+ ],
44
+ "license": "MIT",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/cameraui/rpc.git"
48
+ }
49
+ }