@simplysm/service-client 13.0.100 → 14.0.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.
Files changed (67) hide show
  1. package/README.md +403 -89
  2. package/dist/features/event-client.d.ts.map +1 -1
  3. package/dist/features/event-client.js +75 -67
  4. package/dist/features/event-client.js.map +1 -6
  5. package/dist/features/file-client.d.ts +3 -2
  6. package/dist/features/file-client.d.ts.map +1 -1
  7. package/dist/features/file-client.js +41 -39
  8. package/dist/features/file-client.js.map +1 -6
  9. package/dist/features/orm/orm-client-connector.js +37 -38
  10. package/dist/features/orm/orm-client-connector.js.map +1 -6
  11. package/dist/features/orm/orm-client-db-context-executor.d.ts.map +1 -1
  12. package/dist/features/orm/orm-client-db-context-executor.js +60 -60
  13. package/dist/features/orm/orm-client-db-context-executor.js.map +1 -6
  14. package/dist/features/orm/orm-connect-options.js +2 -1
  15. package/dist/features/orm/orm-connect-options.js.map +1 -6
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +7 -1
  19. package/dist/index.js.map +1 -6
  20. package/dist/protocol/client-protocol-wrapper.d.ts +1 -0
  21. package/dist/protocol/client-protocol-wrapper.d.ts.map +1 -1
  22. package/dist/protocol/client-protocol-wrapper.js +93 -70
  23. package/dist/protocol/client-protocol-wrapper.js.map +1 -6
  24. package/dist/service-client.d.ts +5 -3
  25. package/dist/service-client.d.ts.map +1 -1
  26. package/dist/service-client.js +110 -111
  27. package/dist/service-client.js.map +1 -6
  28. package/dist/transport/service-transport.d.ts +0 -1
  29. package/dist/transport/service-transport.d.ts.map +1 -1
  30. package/dist/transport/service-transport.js +115 -104
  31. package/dist/transport/service-transport.js.map +1 -6
  32. package/dist/transport/socket-provider.d.ts.map +1 -1
  33. package/dist/transport/socket-provider.js +185 -155
  34. package/dist/transport/socket-provider.js.map +1 -6
  35. package/dist/types/browser-compat.d.ts +33 -0
  36. package/dist/types/browser-compat.d.ts.map +1 -0
  37. package/dist/types/browser-compat.js +17 -0
  38. package/dist/types/browser-compat.js.map +1 -0
  39. package/dist/types/connection-options.d.ts +1 -1
  40. package/dist/types/connection-options.d.ts.map +1 -1
  41. package/dist/types/connection-options.js +2 -1
  42. package/dist/types/connection-options.js.map +1 -6
  43. package/dist/types/progress.types.d.ts +1 -0
  44. package/dist/types/progress.types.d.ts.map +1 -1
  45. package/dist/types/progress.types.js +2 -1
  46. package/dist/types/progress.types.js.map +1 -6
  47. package/dist/workers/client-protocol.worker.js +38 -24
  48. package/dist/workers/client-protocol.worker.js.map +1 -6
  49. package/package.json +16 -9
  50. package/src/features/event-client.ts +19 -17
  51. package/src/features/file-client.ts +11 -10
  52. package/src/features/orm/orm-client-connector.ts +2 -2
  53. package/src/features/orm/orm-client-db-context-executor.ts +8 -7
  54. package/src/index.ts +6 -5
  55. package/src/protocol/client-protocol-wrapper.ts +37 -28
  56. package/src/service-client.ts +24 -20
  57. package/src/transport/service-transport.ts +19 -25
  58. package/src/transport/socket-provider.ts +44 -38
  59. package/src/types/browser-compat.ts +47 -0
  60. package/src/types/connection-options.ts +1 -1
  61. package/src/types/progress.types.ts +1 -0
  62. package/src/workers/client-protocol.worker.ts +10 -10
  63. package/docs/features.md +0 -143
  64. package/docs/protocol.md +0 -29
  65. package/docs/service-client.md +0 -93
  66. package/docs/transport.md +0 -96
  67. package/docs/types.md +0 -55
package/README.md CHANGED
@@ -1,126 +1,440 @@
1
1
  # @simplysm/service-client
2
2
 
3
- Simplysm package - Service module (client)
3
+ Service client SDK -- WebSocket-based RPC client with type-safe service proxy, event subscription, file upload/download, and ORM connector.
4
4
 
5
- WebSocket-based service client for communicating with `@simplysm/service-server`. Provides type-safe service method calls, event pub/sub, file upload/download, and client-side ORM connectivity.
5
+ Depends on `@simplysm/service-common` for protocol and shared types.
6
6
 
7
- ## Installation
7
+ ## API
8
8
 
9
- ```bash
10
- npm install @simplysm/service-client
9
+ | Export | Kind | Category | Description |
10
+ |--------|------|----------|-------------|
11
+ | `ServiceConnectionOptions` | interface | Types | Connection options (host, port, SSL, reconnect) |
12
+ | `ServiceProgress` | interface | Types | Progress callback hooks for request/response/server |
13
+ | `ServiceProgressState` | interface | Types | Progress state (uuid, totalSize, completedSize) |
14
+ | `SocketProviderEvents` | interface | Transport | Socket provider event map |
15
+ | `SocketProvider` | interface | Transport | Low-level WebSocket abstraction |
16
+ | `createSocketProvider` | function | Transport | Create a socket provider instance |
17
+ | `ServiceTransportEvents` | interface | Transport | Transport event map |
18
+ | `ServiceTransport` | interface | Transport | Service-level message transport |
19
+ | `createServiceTransport` | function | Transport | Create a service transport instance |
20
+ | `ClientProtocolWrapper` | interface | Protocol | Client-side protocol encoder/decoder wrapper |
21
+ | `createClientProtocolWrapper` | function | Protocol | Create a client protocol wrapper |
22
+ | `EventClient` | interface | Features | Event subscription client |
23
+ | `createEventClient` | function | Features | Create an event client |
24
+ | `FileClient` | interface | Features | File upload/download client |
25
+ | `createFileClient` | function | Features | Create a file client |
26
+ | `OrmConnectOptions` | interface | Features | ORM connection options |
27
+ | `OrmClientConnector` | interface | Features | ORM client connector (with/without transaction) |
28
+ | `createOrmClientConnector` | function | Features | Create an ORM client connector |
29
+ | `OrmClientDbContextExecutor` | class | Features | ORM DbContext executor for client-side use |
30
+ | `ServiceClient` | class | Main | Main service client class |
31
+ | `ServiceProxy` | type | Main | Type-safe service proxy mapping |
32
+ | `createServiceClient` | function | Main | Create a ServiceClient instance |
33
+
34
+ ## Usage
35
+
36
+ ```ts
37
+ import { createServiceClient } from "@simplysm/service-client";
38
+
39
+ // Create and connect
40
+ const client = createServiceClient("my-app", {
41
+ host: "localhost",
42
+ port: 3000,
43
+ ssl: false,
44
+ });
45
+ await client.connect();
46
+
47
+ // Type-safe RPC calls via proxy
48
+ interface MyService {
49
+ greet(name: string): Promise<string>;
50
+ }
51
+ const myService = client.getService<MyService>("MyService");
52
+ const result = await myService.greet("world");
53
+
54
+ // Authenticate
55
+ await client.auth(token);
56
+
57
+ // File upload
58
+ const uploadResults = await client.uploadFile(fileList);
59
+
60
+ // File download
61
+ const bytes = await client.downloadFileBuffer("uploads/file.txt");
62
+
63
+ // Event subscription
64
+ import { defineEvent } from "@simplysm/service-common";
65
+ const ChatEvent = defineEvent<{ roomId: number }, { text: string }>("ChatEvent");
66
+
67
+ const listenerKey = await client.addListener(ChatEvent, { roomId: 1 }, async (data) => {
68
+ // handle event
69
+ });
70
+ await client.removeListener(listenerKey);
71
+
72
+ // Clean up
73
+ await client.close();
11
74
  ```
12
75
 
13
- ## API Overview
76
+ ## Types
14
77
 
15
- ### Types
16
- | API | Type | Description |
17
- |-----|------|-------------|
18
- | `ServiceConnectionOptions` | interface | Connection options (host, port, ssl, reconnect) |
19
- | `ServiceProgress` | interface | Progress callback config for requests |
20
- | `ServiceProgressState` | interface | Progress state (uuid, totalSize, completedSize) |
78
+ ### ServiceConnectionOptions
21
79
 
22
- -> See [docs/types.md](./docs/types.md) for details.
80
+ ```ts
81
+ interface ServiceConnectionOptions {
82
+ port: number;
83
+ host: string;
84
+ ssl?: boolean;
85
+ maxReconnectCount?: number;
86
+ }
87
+ ```
23
88
 
24
- ### Transport
25
- | API | Type | Description |
26
- |-----|------|-------------|
27
- | `SocketProvider` | interface | WebSocket connection provider |
28
- | `SocketProviderEvents` | interface | Socket events (message, state) |
29
- | `createSocketProvider` | function | Create socket with heartbeat and auto-reconnect |
30
- | `ServiceTransport` | interface | Message routing and request/response correlation |
31
- | `ServiceTransportEvents` | interface | Transport events (reload, event) |
32
- | `createServiceTransport` | function | Create transport instance |
89
+ | Field | Type | Description |
90
+ |-------|------|-------------|
91
+ | `port` | `number` | Server port |
92
+ | `host` | `string` | Server hostname |
93
+ | `ssl` | `boolean?` | Enable SSL/TLS |
94
+ | `maxReconnectCount` | `number?` | Max reconnection attempts. Set to `0` to disable reconnection and disconnect immediately. |
33
95
 
34
- -> See [docs/transport.md](./docs/transport.md) for details.
96
+ ### ServiceProgress
35
97
 
36
- ### Protocol
37
- | API | Type | Description |
38
- |-----|------|-------------|
39
- | `ClientProtocolWrapper` | interface | Protocol wrapper with Web Worker offloading |
40
- | `createClientProtocolWrapper` | function | Create protocol wrapper |
98
+ Callback hooks for monitoring message progress.
41
99
 
42
- -> See [docs/protocol.md](./docs/protocol.md) for details.
100
+ ```ts
101
+ interface ServiceProgress {
102
+ request?: (s: ServiceProgressState) => void;
103
+ response?: (s: ServiceProgressState) => void;
104
+ server?: (s: ServiceProgressState) => void;
105
+ }
106
+ ```
43
107
 
44
- ### Features (Event, File, ORM)
45
- | API | Type | Description |
46
- |-----|------|-------------|
47
- | `EventClient` | interface | Event listener management |
48
- | `createEventClient` | function | Create event client |
49
- | `FileClient` | interface | File upload/download |
50
- | `createFileClient` | function | Create file client |
51
- | `OrmConnectOptions` | interface | ORM connection options |
52
- | `OrmClientConnector` | interface | Client-side ORM connector |
53
- | `createOrmClientConnector` | function | Create ORM connector |
54
- | `OrmClientDbContextExecutor` | class | DbContext executor via service protocol |
108
+ | Field | Type | Description |
109
+ |-------|------|-------------|
110
+ | `request` | `(s: ServiceProgressState) => void` | Called during request encoding/sending progress |
111
+ | `response` | `(s: ServiceProgressState) => void` | Called during response decoding progress |
112
+ | `server` | `(s: ServiceProgressState) => void` | Called when server reports chunk receive progress |
55
113
 
56
- -> See [docs/features.md](./docs/features.md) for details.
114
+ ### ServiceProgressState
57
115
 
58
- ### Main
59
- | API | Type | Description |
60
- |-----|------|-------------|
61
- | `ServiceClient` | class | Main client (connect, auth, service calls, events, files) |
62
- | `ServiceClientEvents` | interface | Client events (progress, state, reload) |
63
- | `ServiceProxy` | type | Type wrapper for remote service methods |
64
- | `createServiceClient` | function | Factory to create ServiceClient |
116
+ ```ts
117
+ interface ServiceProgressState {
118
+ uuid: string;
119
+ totalSize: number;
120
+ completedSize: number;
121
+ }
122
+ ```
65
123
 
66
- -> See [docs/service-client.md](./docs/service-client.md) for details.
124
+ | Field | Type | Description |
125
+ |-------|------|-------------|
126
+ | `uuid` | `string` | Message UUID |
127
+ | `totalSize` | `number` | Total message size in bytes |
128
+ | `completedSize` | `number` | Bytes transferred so far |
67
129
 
68
- ## Usage Examples
130
+ ## Transport
69
131
 
70
- ### Connect and Call Service Methods
132
+ ### SocketProviderEvents
71
133
 
72
- ```typescript
73
- import { createServiceClient } from "@simplysm/service-client";
134
+ ```ts
135
+ interface SocketProviderEvents {
136
+ message: Bytes;
137
+ state: "connected" | "closed" | "reconnecting";
138
+ }
139
+ ```
74
140
 
75
- const client = createServiceClient("my-app", {
76
- host: "localhost",
77
- port: 3000,
78
- });
141
+ | Event | Data Type | Description |
142
+ |-------|-----------|-------------|
143
+ | `message` | `Bytes` | Raw binary message received |
144
+ | `state` | `"connected" \| "closed" \| "reconnecting"` | Connection state change |
79
145
 
80
- await client.connect();
81
- await client.auth(jwtToken);
146
+ ### SocketProvider
82
147
 
83
- // Type-safe service proxy
84
- interface UserService {
85
- getProfile(): Promise<{ name: string; email: string }>;
86
- updateName(name: string): Promise<void>;
148
+ Low-level WebSocket abstraction with auto-reconnect.
149
+
150
+ ```ts
151
+ interface SocketProvider {
152
+ readonly clientName: string;
153
+ readonly connected: boolean;
154
+ on<K extends keyof SocketProviderEvents & string>(type: K, listener: (data: SocketProviderEvents[K]) => void): void;
155
+ off<K extends keyof SocketProviderEvents & string>(type: K, listener: (data: SocketProviderEvents[K]) => void): void;
156
+ connect(): Promise<void>;
157
+ close(): Promise<void>;
158
+ send(data: Bytes): Promise<void>;
87
159
  }
160
+ ```
161
+
162
+ | Member | Kind | Description |
163
+ |--------|------|-------------|
164
+ | `clientName` | property | Client identifier name |
165
+ | `connected` | property | Whether currently connected |
166
+ | `on` | method | Subscribe to an event |
167
+ | `off` | method | Unsubscribe from an event |
168
+ | `connect` | method | Open the WebSocket connection |
169
+ | `close` | method | Close the connection |
170
+ | `send` | method | Send binary data |
88
171
 
89
- const userService = client.getService<UserService>("User");
90
- const profile = await userService.getProfile();
91
- await userService.updateName("New Name");
172
+ ### createSocketProvider
173
+
174
+ ```ts
175
+ function createSocketProvider(url: string, clientName: string, maxReconnectCount: number): SocketProvider;
92
176
  ```
93
177
 
94
- ### Client-Side ORM
178
+ | Parameter | Type | Description |
179
+ |-----------|------|-------------|
180
+ | `url` | `string` | WebSocket URL |
181
+ | `clientName` | `string` | Client identifier |
182
+ | `maxReconnectCount` | `number` | Maximum reconnection attempts |
183
+
184
+ ### ServiceTransportEvents
185
+
186
+ ```ts
187
+ interface ServiceTransportEvents {
188
+ event: { keys: string[]; data: unknown };
189
+ }
190
+ ```
191
+
192
+ | Event | Data Type | Description |
193
+ |-------|-----------|-------------|
194
+ | `event` | `{ keys: string[]; data: unknown }` | Server-side event broadcast received |
195
+
196
+ ### ServiceTransport
95
197
 
96
- ```typescript
97
- import { createOrmClientConnector } from "@simplysm/service-client";
198
+ Service-level message transport built on top of `SocketProvider`.
98
199
 
99
- const orm = createOrmClientConnector(client);
200
+ ```ts
201
+ interface ServiceTransport {
202
+ on<K extends keyof ServiceTransportEvents & string>(type: K, listener: (data: ServiceTransportEvents[K]) => void): void;
203
+ off<K extends keyof ServiceTransportEvents & string>(type: K, listener: (data: ServiceTransportEvents[K]) => void): void;
204
+ send(message: ServiceClientMessage, progress?: ServiceProgress): Promise<unknown>;
205
+ }
206
+ ```
207
+
208
+ | Method | Parameters | Return | Description |
209
+ |--------|-----------|--------|-------------|
210
+ | `on` | `type`, `listener` | `void` | Subscribe to transport events |
211
+ | `off` | `type`, `listener` | `void` | Unsubscribe from transport events |
212
+ | `send` | `message: ServiceClientMessage`, `progress?: ServiceProgress` | `Promise<unknown>` | Send a service message and await the response |
213
+
214
+ ### createServiceTransport
100
215
 
101
- const users = await orm.connect(
102
- { dbContextDef: MyDb, connOpt: { configName: "main" } },
103
- async (db) => {
104
- return db.user().where((u) => [expr.eq(u.status, "active")]).execute();
105
- },
106
- );
216
+ ```ts
217
+ function createServiceTransport(socket: SocketProvider, protocol: ClientProtocolWrapper): ServiceTransport;
107
218
  ```
108
219
 
109
- ### Event Subscription
220
+ ## Protocol
110
221
 
111
- ```typescript
112
- import { defineEvent } from "@simplysm/service-common";
222
+ ### ClientProtocolWrapper
223
+
224
+ Client-side protocol encoder/decoder wrapper.
225
+
226
+ ```ts
227
+ interface ClientProtocolWrapper {
228
+ encode(uuid: string, message: ServiceMessage): Promise<{ chunks: Bytes[]; totalSize: number }>;
229
+ decode(bytes: Bytes): Promise<ServiceMessageDecodeResult<ServiceMessage>>;
230
+ dispose(): void;
231
+ }
232
+ ```
113
233
 
114
- const OrderUpdated = defineEvent<{ orderId: number }, { status: string }>("OrderUpdated");
234
+ | Method | Parameters | Return | Description |
235
+ |--------|-----------|--------|-------------|
236
+ | `encode` | `uuid: string`, `message: ServiceMessage` | `Promise<{ chunks: Bytes[]; totalSize: number }>` | Encode a message into binary chunks |
237
+ | `decode` | `bytes: Bytes` | `Promise<ServiceMessageDecodeResult<ServiceMessage>>` | Decode received binary data |
238
+ | `dispose` | -- | `void` | Clean up resources |
115
239
 
116
- const key = await client.addListener(
117
- OrderUpdated,
118
- { orderId: 123 },
119
- async (data) => {
120
- console.log("Order status:", data.status);
121
- },
122
- );
240
+ ### createClientProtocolWrapper
123
241
 
124
- // Later: unsubscribe
125
- await client.removeListener(key);
242
+ ```ts
243
+ function createClientProtocolWrapper(protocol: ServiceProtocol): ClientProtocolWrapper;
126
244
  ```
245
+
246
+ Creates a `ClientProtocolWrapper` from a `ServiceProtocol` instance.
247
+
248
+ ## Features
249
+
250
+ ### EventClient
251
+
252
+ Event subscription client for the service event system.
253
+
254
+ ```ts
255
+ interface EventClient {
256
+ addListener<TInfo, TData>(eventDef: ServiceEventDef<TInfo, TData>, info: TInfo, cb: (data: TData) => PromiseLike<void>): Promise<string>;
257
+ removeListener(key: string): Promise<void>;
258
+ emit<TInfo, TData>(eventDef: ServiceEventDef<TInfo, TData>, infoSelector: (item: TInfo) => boolean, data: TData): Promise<void>;
259
+ resubscribeAll(): Promise<void>;
260
+ }
261
+ ```
262
+
263
+ | Method | Parameters | Return | Description |
264
+ |--------|-----------|--------|-------------|
265
+ | `addListener` | `eventDef`, `info: TInfo`, `cb` | `Promise<string>` | Subscribe to an event; returns listener key |
266
+ | `removeListener` | `key: string` | `Promise<void>` | Unsubscribe by listener key |
267
+ | `emit` | `eventDef`, `infoSelector`, `data: TData` | `Promise<void>` | Emit an event to matching listeners |
268
+ | `resubscribeAll` | -- | `Promise<void>` | Resubscribe all listeners (e.g., after reconnect) |
269
+
270
+ ### createEventClient
271
+
272
+ ```ts
273
+ function createEventClient(transport: ServiceTransport): EventClient;
274
+ ```
275
+
276
+ ### FileClient
277
+
278
+ File upload and download client.
279
+
280
+ ```ts
281
+ interface FileClient {
282
+ download(relPath: string): Promise<Bytes>;
283
+ upload(files: File[] | FileList | { name: string; data: BlobPart }[], authToken: string): Promise<ServiceUploadResult[]>;
284
+ }
285
+ ```
286
+
287
+ | Method | Parameters | Return | Description |
288
+ |--------|-----------|--------|-------------|
289
+ | `download` | `relPath: string` | `Promise<Bytes>` | Download a file by relative path |
290
+ | `upload` | `files`, `authToken: string` | `Promise<ServiceUploadResult[]>` | Upload files with authentication |
291
+
292
+ ### createFileClient
293
+
294
+ ```ts
295
+ function createFileClient(hostUrl: string, clientName: string): FileClient;
296
+ ```
297
+
298
+ ### OrmConnectOptions\<TDef\>
299
+
300
+ ```ts
301
+ interface OrmConnectOptions<TDef extends DbContextDef<any, any, any>> {
302
+ dbContextDef: TDef;
303
+ connOpt: DbConnOptions & { configName: string };
304
+ dbContextOpt?: {
305
+ database: string;
306
+ schema: string;
307
+ };
308
+ }
309
+ ```
310
+
311
+ | Field | Type | Description |
312
+ |-------|------|-------------|
313
+ | `dbContextDef` | `TDef` | Database context definition |
314
+ | `connOpt` | `DbConnOptions & { configName: string }` | Connection options with required config name |
315
+ | `dbContextOpt` | `{ database: string; schema: string }?` | Optional database/schema override |
316
+
317
+ ### OrmClientConnector
318
+
319
+ ORM client connector that opens a database context over the service RPC layer.
320
+
321
+ ```ts
322
+ interface OrmClientConnector {
323
+ connect<TDef extends DbContextDef<any, any, any>, R>(
324
+ config: OrmConnectOptions<TDef>,
325
+ callback: (db: DbContextInstance<TDef>) => Promise<R> | R,
326
+ ): Promise<R>;
327
+ connectWithoutTransaction<TDef extends DbContextDef<any, any, any>, R>(
328
+ config: OrmConnectOptions<TDef>,
329
+ callback: (db: DbContextInstance<TDef>) => Promise<R> | R,
330
+ ): Promise<R>;
331
+ }
332
+ ```
333
+
334
+ | Method | Parameters | Return | Description |
335
+ |--------|-----------|--------|-------------|
336
+ | `connect` | `config`, `callback` | `Promise<R>` | Open a DB context with automatic transaction (begin/commit/rollback) |
337
+ | `connectWithoutTransaction` | `config`, `callback` | `Promise<R>` | Open a DB context without automatic transaction management |
338
+
339
+ ### createOrmClientConnector
340
+
341
+ ```ts
342
+ function createOrmClientConnector(serviceClient: ServiceClient): OrmClientConnector;
343
+ ```
344
+
345
+ ### OrmClientDbContextExecutor
346
+
347
+ Implements `DbContextExecutor` for client-side ORM usage over the service RPC layer.
348
+
349
+ ```ts
350
+ class OrmClientDbContextExecutor implements DbContextExecutor {
351
+ constructor(client: ServiceClient, opt: DbConnOptions & { configName: string });
352
+ }
353
+ ```
354
+
355
+ | Method | Parameters | Return | Description |
356
+ |--------|-----------|--------|-------------|
357
+ | `getInfo` | -- | `Promise<{ dialect; database?; schema? }>` | Get database info |
358
+ | `connect` | -- | `Promise<void>` | Open the connection |
359
+ | `beginTransaction` | `isolationLevel?: IsolationLevel` | `Promise<void>` | Begin a transaction |
360
+ | `commitTransaction` | -- | `Promise<void>` | Commit the transaction |
361
+ | `rollbackTransaction` | -- | `Promise<void>` | Rollback the transaction |
362
+ | `close` | -- | `Promise<void>` | Close the connection |
363
+ | `executeDefs` | `defs: QueryDef[]`, `options?: (ResultMeta \| undefined)[]` | `Promise<T[][]>` | Execute query definitions |
364
+ | `executeParametrized` | `query: string`, `params?: unknown[]` | `Promise<unknown[][]>` | Execute a parameterized query |
365
+ | `bulkInsert` | `tableName: string`, `columnDefs: Record<string, ColumnMeta>`, `records: Record<string, unknown>[]` | `Promise<void>` | Bulk insert records |
366
+
367
+ ## Main
368
+
369
+ ### ServiceClient
370
+
371
+ Main service client class. Extends `EventEmitter` with progress and state events.
372
+
373
+ ```ts
374
+ class ServiceClient extends EventEmitter<{
375
+ "request-progress": ServiceProgressState;
376
+ "response-progress": ServiceProgressState;
377
+ "server-progress": ServiceProgressState;
378
+ "state": "connected" | "closed" | "reconnecting";
379
+ }> {
380
+ constructor(name: string, options: ServiceConnectionOptions);
381
+ }
382
+ ```
383
+
384
+ #### Events
385
+
386
+ | Event | Data Type | Description |
387
+ |-------|-----------|-------------|
388
+ | `request-progress` | `ServiceProgressState` | Request sending progress |
389
+ | `response-progress` | `ServiceProgressState` | Response receiving progress |
390
+ | `server-progress` | `ServiceProgressState` | Server-side chunk progress |
391
+ | `state` | `"connected" \| "closed" \| "reconnecting"` | Connection state change |
392
+
393
+ #### Properties
394
+
395
+ | Property | Type | Description |
396
+ |----------|------|-------------|
397
+ | `name` | `string` | Client name |
398
+ | `options` | `ServiceConnectionOptions` | Connection options |
399
+ | `connected` | `boolean` | Whether the client is connected |
400
+ | `hostUrl` | `string` | Full host URL (computed from options) |
401
+
402
+ #### Methods
403
+
404
+ | Method | Parameters | Return | Description |
405
+ |--------|-----------|--------|-------------|
406
+ | `getService<TService>` | `serviceName: string` | `ServiceProxy<TService>` | Get a type-safe service proxy |
407
+ | `connect` | -- | `Promise<void>` | Open the WebSocket connection |
408
+ | `close` | -- | `Promise<void>` | Close the connection |
409
+ | `send` | `serviceName`, `methodName`, `params`, `progress?` | `Promise<unknown>` | Send an RPC call |
410
+ | `auth` | `token: string` | `Promise<void>` | Authenticate with a JWT token |
411
+ | `addListener` | `eventDef`, `info`, `cb` | `Promise<string>` | Subscribe to an event |
412
+ | `removeListener` | `key: string` | `Promise<void>` | Unsubscribe from an event |
413
+ | `emitEvent` | `eventDef`, `infoSelector`, `data` | `Promise<void>` | Emit an event |
414
+ | `uploadFile` | `files` | `Promise<ServiceUploadResult[]>` | Upload files |
415
+ | `downloadFileBuffer` | `relPath: string` | `Promise<Bytes>` | Download a file |
416
+
417
+ ### ServiceProxy\<TService\>
418
+
419
+ Maps service method signatures to async versions. Every method returns `Promise<Awaited<R>>`.
420
+
421
+ ```ts
422
+ type ServiceProxy<TService> = {
423
+ [K in keyof TService]: TService[K] extends (...args: infer P) => infer R
424
+ ? (...args: P) => Promise<Awaited<R>>
425
+ : never;
426
+ };
427
+ ```
428
+
429
+ ### createServiceClient
430
+
431
+ ```ts
432
+ function createServiceClient(name: string, options: ServiceConnectionOptions): ServiceClient;
433
+ ```
434
+
435
+ Factory function to create a `ServiceClient` instance.
436
+
437
+ | Parameter | Type | Description |
438
+ |-----------|------|-------------|
439
+ | `name` | `string` | Client identifier name |
440
+ | `options` | `ServiceConnectionOptions` | Connection options |
@@ -1 +1 @@
1
- {"version":3,"file":"event-client.d.ts","sourceRoot":"","sources":["..\\..\\src\\features\\event-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKvE,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,KAAK,EAAE,KAAK,EACtB,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,WAAW,CAAC,IAAI,CAAC,GACrC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE,KAAK,EACf,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvC,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EACtC,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,GAAG,WAAW,CAsG1E"}
1
+ {"version":3,"file":"event-client.d.ts","sourceRoot":"","sources":["..\\..\\src\\features\\event-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKvE,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,KAAK,EAAE,KAAK,EACtB,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,WAAW,CAAC,IAAI,CAAC,GACrC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE,KAAK,EACf,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvC,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EACtC,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,GAAG,WAAW,CAwG1E"}