@simplysm/service-common 13.0.28 → 13.0.30
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 +84 -65
- package/dist/define-event.d.ts.map +1 -1
- package/dist/define-event.js.map +1 -1
- package/dist/protocol/create-service-protocol.d.ts.map +1 -1
- package/dist/protocol/create-service-protocol.js +13 -2
- package/dist/protocol/create-service-protocol.js.map +1 -1
- package/dist/service-types/orm-service.types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/define-event.ts +3 -1
- package/src/protocol/create-service-protocol.ts +13 -2
- package/src/service-types/orm-service.types.ts +12 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @simplysm/service-common
|
|
2
2
|
|
|
3
|
-
A package that provides shared communication protocols, message types, and service interface definitions between the service client (`service-client`) and server (`service-server`). It includes binary protocol-based message encoding/decoding, automatic message chunking for large payloads, event system types, and service interfaces for ORM
|
|
3
|
+
A package that provides shared communication protocols, message types, and service interface definitions between the service client (`service-client`) and server (`service-server`). It includes binary protocol-based message encoding/decoding, automatic message chunking for large payloads, event system types, and service interfaces for ORM and auto-update.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -15,46 +15,48 @@ pnpm add @simplysm/service-common
|
|
|
15
15
|
### Module Structure
|
|
16
16
|
|
|
17
17
|
| Module Path | Description |
|
|
18
|
-
|
|
18
|
+
|-------------|-------------|
|
|
19
19
|
| `protocol/protocol.types` | Protocol constants, message type definitions |
|
|
20
|
-
| `protocol/service-protocol` |
|
|
21
|
-
| `service-types/orm-service.types` |
|
|
22
|
-
| `service-types/auto-update-service.types` |
|
|
23
|
-
| `types` | `ServiceUploadResult` |
|
|
24
|
-
| `define-event` | `defineEvent
|
|
20
|
+
| `protocol/service-protocol` | `ServiceProtocol` interface, `ServiceMessageDecodeResult` type, `createServiceProtocol()` factory |
|
|
21
|
+
| `service-types/orm-service.types` | `OrmService` interface and `DbConnOptions` type |
|
|
22
|
+
| `service-types/auto-update-service.types` | `AutoUpdateService` interface |
|
|
23
|
+
| `types` | `ServiceUploadResult` interface |
|
|
24
|
+
| `define-event` | `defineEvent()` function, `ServiceEventDef` interface |
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Protocol
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
### ServiceProtocol
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
The core interface for encoding and decoding messages in binary format. Created via the `createServiceProtocol()` factory function. Messages exceeding 3MB are automatically split into 300KB chunks, and the receiving side automatically assembles the chunks to restore the original message.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
#### Binary Header Structure
|
|
33
|
+
|
|
34
|
+
Each chunk consists of a 28-byte header followed by a JSON body (Big Endian).
|
|
33
35
|
|
|
34
36
|
| Offset | Size | Field | Description |
|
|
35
|
-
|
|
37
|
+
|--------|------|-------|-------------|
|
|
36
38
|
| 0 | 16 bytes | UUID | Message identifier (binary) |
|
|
37
39
|
| 16 | 8 bytes | TotalSize | Total message size (uint64) |
|
|
38
40
|
| 24 | 4 bytes | Index | Chunk index (uint32) |
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
#### API
|
|
41
43
|
|
|
42
44
|
| Method | Return Type | Description |
|
|
43
|
-
|
|
44
|
-
| `encode(uuid, message)` | `{ chunks: Bytes[]; totalSize: number }` | Encodes the message and automatically splits if
|
|
45
|
-
| `decode<
|
|
45
|
+
|--------|-------------|-------------|
|
|
46
|
+
| `encode(uuid, message)` | `{ chunks: Bytes[]; totalSize: number }` | Encodes the message and automatically splits into chunks if it exceeds `SPLIT_MESSAGE_SIZE` |
|
|
47
|
+
| `decode<TMessage extends ServiceMessage>(bytes)` | `ServiceMessageDecodeResult<TMessage>` | Decodes binary chunks and automatically assembles split messages |
|
|
46
48
|
| `dispose()` | `void` | Releases the GC timer of the internal chunk accumulator. Must be called when the instance is no longer used |
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
#### ServiceMessageDecodeResult
|
|
49
51
|
|
|
50
|
-
`ServiceMessageDecodeResult<
|
|
52
|
+
`ServiceMessageDecodeResult<TMessage extends ServiceMessage>` is a union type with two states.
|
|
51
53
|
|
|
52
54
|
| `type` | Fields | Description |
|
|
53
|
-
|
|
54
|
-
| `"complete"` | `uuid`, `message:
|
|
55
|
-
| `"progress"` | `uuid`, `totalSize`, `completedSize` | Split message in progress (only some chunks arrived) |
|
|
55
|
+
|--------|--------|-------------|
|
|
56
|
+
| `"complete"` | `uuid: string`, `message: TMessage` | All chunks received and message assembly complete |
|
|
57
|
+
| `"progress"` | `uuid: string`, `totalSize: number`, `completedSize: number` | Split message in progress (only some chunks have arrived) |
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
#### Usage Example
|
|
58
60
|
|
|
59
61
|
```typescript
|
|
60
62
|
import { createServiceProtocol } from "@simplysm/service-common";
|
|
@@ -86,7 +88,7 @@ for (const chunk of chunks) {
|
|
|
86
88
|
protocol.dispose();
|
|
87
89
|
```
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
### PROTOCOL_CONFIG
|
|
90
92
|
|
|
91
93
|
A constant object that controls protocol behavior.
|
|
92
94
|
|
|
@@ -95,80 +97,80 @@ import { PROTOCOL_CONFIG } from "@simplysm/service-common";
|
|
|
95
97
|
```
|
|
96
98
|
|
|
97
99
|
| Constant | Value | Description |
|
|
98
|
-
|
|
100
|
+
|----------|-------|-------------|
|
|
99
101
|
| `MAX_TOTAL_SIZE` | 100MB (104,857,600 bytes) | Maximum size for a single message. `ArgumentError` thrown if exceeded |
|
|
100
|
-
| `SPLIT_MESSAGE_SIZE` | 3MB (3,145,728 bytes) | Chunking threshold.
|
|
102
|
+
| `SPLIT_MESSAGE_SIZE` | 3MB (3,145,728 bytes) | Chunking threshold. Messages larger than this are automatically split |
|
|
101
103
|
| `CHUNK_SIZE` | 300KB (307,200 bytes) | Body size of each chunk when split |
|
|
102
104
|
| `GC_INTERVAL` | 10s (10,000ms) | Garbage collection cycle for incomplete messages |
|
|
103
105
|
| `EXPIRE_TIME` | 60s (60,000ms) | Expiration time for incomplete messages. Removed from memory if exceeded |
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
### Message Types
|
|
106
108
|
|
|
107
109
|
Type definitions for messages exchanged between client and server. `ServiceMessage` is a union of all message types.
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
#### Classification by Message Direction
|
|
110
112
|
|
|
111
113
|
| Union Type | Direction | Included Messages |
|
|
112
|
-
|
|
114
|
+
|------------|-----------|-------------------|
|
|
113
115
|
| `ServiceClientMessage` | Client -> Server | Request, Auth, event-related messages |
|
|
114
116
|
| `ServiceServerMessage` | Server -> Client | Reload, Response, Error, Event |
|
|
115
117
|
| `ServiceServerRawMessage` | Server -> Client (raw) | Progress + `ServiceServerMessage` |
|
|
116
118
|
| `ServiceMessage` | Bidirectional (all) | Union of all message types |
|
|
117
119
|
|
|
118
|
-
|
|
120
|
+
#### Individual Message Types
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
##### System Messages
|
|
121
123
|
|
|
122
124
|
| Type | `name` | Direction | `body` Type | Description |
|
|
123
|
-
|
|
125
|
+
|------|--------|-----------|-------------|-------------|
|
|
124
126
|
| `ServiceReloadMessage` | `"reload"` | Server -> Client | `{ clientName: string \| undefined; changedFileSet: Set<string> }` | Client reload command |
|
|
125
127
|
| `ServiceProgressMessage` | `"progress"` | Server -> Client | `{ totalSize: number; completedSize: number }` | Split message reception progress |
|
|
126
|
-
| `ServiceErrorMessage` | `"error"` | Server -> Client | `{ name
|
|
128
|
+
| `ServiceErrorMessage` | `"error"` | Server -> Client | `{ name: string; message: string; code: string; stack?: string; detail?: unknown; cause?: unknown }` | Error notification |
|
|
127
129
|
| `ServiceAuthMessage` | `"auth"` | Client -> Server | `string` (token) | Authentication token transmission |
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
##### Service Method Call Messages
|
|
130
132
|
|
|
131
133
|
| Type | `name` | Direction | `body` Type | Description |
|
|
132
|
-
|
|
133
|
-
| `ServiceRequestMessage` | `` `${
|
|
134
|
-
| `ServiceResponseMessage` | `"response"` | Server -> Client | `unknown` (return value) | Method call response |
|
|
134
|
+
|------|--------|-----------|-------------|-------------|
|
|
135
|
+
| `ServiceRequestMessage` | `` `${string}.${string}` `` | Client -> Server | `unknown[]` (parameter array) | RPC method call request |
|
|
136
|
+
| `ServiceResponseMessage` | `"response"` | Server -> Client | `unknown \| undefined` (optional return value) | Method call response |
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
##### Event Messages
|
|
137
139
|
|
|
138
140
|
| Type | `name` | Direction | `body` Type | Description |
|
|
139
|
-
|
|
140
|
-
| `ServiceAddEventListenerMessage` | `"evt:add"` | Client -> Server | `{ key
|
|
141
|
-
| `ServiceRemoveEventListenerMessage` | `"evt:remove"` | Client -> Server | `{ key }` | Event listener removal |
|
|
142
|
-
| `ServiceGetEventListenerInfosMessage` | `"evt:gets"` | Client -> Server | `{ name }` | Event listener info list query |
|
|
143
|
-
| `ServiceEmitEventMessage` | `"evt:emit"` | Client -> Server | `{ keys
|
|
144
|
-
| `ServiceEventMessage` | `"evt:on"` | Server -> Client | `{ keys
|
|
141
|
+
|------|--------|-----------|-------------|-------------|
|
|
142
|
+
| `ServiceAddEventListenerMessage` | `"evt:add"` | Client -> Server | `{ key: string; name: string; info: unknown }` | Event listener registration |
|
|
143
|
+
| `ServiceRemoveEventListenerMessage` | `"evt:remove"` | Client -> Server | `{ key: string }` | Event listener removal |
|
|
144
|
+
| `ServiceGetEventListenerInfosMessage` | `"evt:gets"` | Client -> Server | `{ name: string }` | Event listener info list query |
|
|
145
|
+
| `ServiceEmitEventMessage` | `"evt:emit"` | Client -> Server | `{ keys: string[]; data: unknown }` | Event emission |
|
|
146
|
+
| `ServiceEventMessage` | `"evt:on"` | Server -> Client | `{ keys: string[]; data: unknown }` | Event notification |
|
|
145
147
|
|
|
146
148
|
## defineEvent / ServiceEventDef
|
|
147
149
|
|
|
148
|
-
A function for defining
|
|
150
|
+
A function for defining type-safe service events. Events are used to publish real-time notifications from server to client.
|
|
149
151
|
|
|
150
152
|
### API
|
|
151
153
|
|
|
152
154
|
```typescript
|
|
153
155
|
function defineEvent<TInfo = unknown, TData = unknown>(
|
|
154
|
-
eventName: string
|
|
156
|
+
eventName: string,
|
|
155
157
|
): ServiceEventDef<TInfo, TData>
|
|
156
158
|
```
|
|
157
159
|
|
|
158
160
|
### Type Parameters
|
|
159
161
|
|
|
160
162
|
| Parameter | Description |
|
|
161
|
-
|
|
163
|
+
|-----------|-------------|
|
|
162
164
|
| `TInfo` | Additional information type for listener filtering |
|
|
163
165
|
| `TData` | Data type passed when the event is emitted |
|
|
164
166
|
|
|
165
167
|
### ServiceEventDef Properties
|
|
166
168
|
|
|
167
169
|
| Property | Type | Description |
|
|
168
|
-
|
|
170
|
+
|----------|------|-------------|
|
|
169
171
|
| `eventName` | `string` | Unique event identifier |
|
|
170
|
-
| `$info` | `TInfo` (declare) | For type extraction. Not used at runtime |
|
|
171
|
-
| `$data` | `TData` (declare) | For type extraction. Not used at runtime |
|
|
172
|
+
| `$info` | `TInfo` (declare) | For TypeScript type extraction only. Not used at runtime |
|
|
173
|
+
| `$data` | `TData` (declare) | For TypeScript type extraction only. Not used at runtime |
|
|
172
174
|
|
|
173
175
|
### Usage Example
|
|
174
176
|
|
|
@@ -195,9 +197,13 @@ await client.addEventListener(
|
|
|
195
197
|
|
|
196
198
|
An interface representing file upload results.
|
|
197
199
|
|
|
200
|
+
```typescript
|
|
201
|
+
import { ServiceUploadResult } from "@simplysm/service-common";
|
|
202
|
+
```
|
|
203
|
+
|
|
198
204
|
| Field | Type | Description |
|
|
199
|
-
|
|
200
|
-
| `path` | `string` | Storage path on server |
|
|
205
|
+
|-------|------|-------------|
|
|
206
|
+
| `path` | `string` | Storage path on the server |
|
|
201
207
|
| `filename` | `string` | Original filename |
|
|
202
208
|
| `size` | `number` | File size (bytes) |
|
|
203
209
|
|
|
@@ -207,24 +213,32 @@ Service interface definitions that are implemented on the server side and called
|
|
|
207
213
|
|
|
208
214
|
### OrmService
|
|
209
215
|
|
|
210
|
-
Defines database connection, transaction management, and query execution capabilities. Supports MySQL, MSSQL, PostgreSQL.
|
|
216
|
+
Defines database connection, transaction management, and query execution capabilities. Supports MySQL, MSSQL, and PostgreSQL.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import type { OrmService } from "@simplysm/service-common";
|
|
220
|
+
```
|
|
211
221
|
|
|
212
222
|
| Method | Parameters | Return Type | Description |
|
|
213
|
-
|
|
214
|
-
| `getInfo` | `opt: DbConnOptions & { configName: string }` | `Promise<{ dialect
|
|
223
|
+
|--------|------------|-------------|-------------|
|
|
224
|
+
| `getInfo` | `opt: DbConnOptions & { configName: string }` | `Promise<{ dialect: Dialect; database?: string; schema?: string }>` | Query DB connection info |
|
|
215
225
|
| `connect` | `opt: Record<string, unknown>` | `Promise<number>` | Create DB connection, return connection ID |
|
|
216
226
|
| `close` | `connId: number` | `Promise<void>` | Close DB connection |
|
|
217
|
-
| `beginTransaction` | `connId, isolationLevel
|
|
227
|
+
| `beginTransaction` | `connId: number, isolationLevel?: IsolationLevel` | `Promise<void>` | Begin transaction |
|
|
218
228
|
| `commitTransaction` | `connId: number` | `Promise<void>` | Commit transaction |
|
|
219
229
|
| `rollbackTransaction` | `connId: number` | `Promise<void>` | Rollback transaction |
|
|
220
|
-
| `executeParametrized` | `connId, query, params
|
|
221
|
-
| `executeDefs` | `connId, defs: QueryDef[], options?: (ResultMeta \| undefined)[]` | `Promise<unknown[][]>` | Execute queries
|
|
222
|
-
| `bulkInsert` | `connId, tableName, columnDefs: Record<string, ColumnMeta>, records` | `Promise<void>` | Bulk data insertion |
|
|
230
|
+
| `executeParametrized` | `connId: number, query: string, params?: unknown[]` | `Promise<unknown[][]>` | Execute a parameterized query |
|
|
231
|
+
| `executeDefs` | `connId: number, defs: QueryDef[], options?: (ResultMeta \| undefined)[]` | `Promise<unknown[][]>` | Execute queries defined as `QueryDef` array |
|
|
232
|
+
| `bulkInsert` | `connId: number, tableName: string, columnDefs: Record<string, ColumnMeta>, records: Record<string, unknown>[]` | `Promise<void>` | Bulk data insertion |
|
|
223
233
|
|
|
224
234
|
#### DbConnOptions
|
|
225
235
|
|
|
236
|
+
```typescript
|
|
237
|
+
import type { DbConnOptions } from "@simplysm/service-common";
|
|
238
|
+
```
|
|
239
|
+
|
|
226
240
|
| Field | Type | Description |
|
|
227
|
-
|
|
241
|
+
|-------|------|-------------|
|
|
228
242
|
| `configName?` | `string` | Config name to reference in server settings |
|
|
229
243
|
| `config?` | `Record<string, unknown>` | Directly passed connection config |
|
|
230
244
|
|
|
@@ -232,18 +246,23 @@ Defines database connection, transaction management, and query execution capabil
|
|
|
232
246
|
|
|
233
247
|
Defines a service for querying the latest version information of a client application.
|
|
234
248
|
|
|
249
|
+
```typescript
|
|
250
|
+
import type { AutoUpdateService } from "@simplysm/service-common";
|
|
251
|
+
```
|
|
252
|
+
|
|
235
253
|
| Method | Parameters | Return Type | Description |
|
|
236
|
-
|
|
237
|
-
| `getLastVersion` | `platform: string` | `Promise<{ version: string; downloadPath: string } \| undefined>` | Query latest version info for the specified platform. Returns `undefined` if none |
|
|
254
|
+
|--------|------------|-------------|-------------|
|
|
255
|
+
| `getLastVersion` | `platform: string` | `Promise<{ version: string; downloadPath: string } \| undefined>` | Query latest version info for the specified platform. Returns `undefined` if none exists |
|
|
238
256
|
|
|
239
|
-
Pass values like `"win32"`, `"darwin"`, `"linux"` to `platform`.
|
|
257
|
+
Pass values like `"win32"`, `"darwin"`, or `"linux"` to `platform`.
|
|
240
258
|
|
|
241
259
|
## Caveats
|
|
242
260
|
|
|
243
|
-
- `ServiceProtocol` instances are created via `createServiceProtocol()` factory function and internally use `LazyGcMap` to manage incomplete split messages. After use, you must call `dispose()` to release the GC timer.
|
|
261
|
+
- `ServiceProtocol` instances are created via the `createServiceProtocol()` factory function and internally use `LazyGcMap` to manage incomplete split messages. After use, you must call `dispose()` to release the GC timer.
|
|
244
262
|
- Encoding or decoding messages exceeding `PROTOCOL_CONFIG.MAX_TOTAL_SIZE` (100MB) will throw an `ArgumentError`.
|
|
245
|
-
- Passing binary data less than 28 bytes
|
|
246
|
-
-
|
|
263
|
+
- Passing binary data less than 28 bytes to `decode()` will throw an `ArgumentError`.
|
|
264
|
+
- `ServiceResponseMessage.body` is optional (`body?: unknown`) — the server may return `undefined` for void methods.
|
|
265
|
+
- Service interfaces (`OrmService`, `AutoUpdateService`) only provide type definitions. Actual implementations are handled by the `@simplysm/service-server` package.
|
|
247
266
|
- The `$info` and `$data` properties of `ServiceEventDef` are declared with `declare` and do not exist at runtime; they are only used for TypeScript type extraction.
|
|
248
267
|
|
|
249
268
|
## License
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-event.d.ts","sourceRoot":"","sources":["../src/define-event.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"define-event.d.ts","sourceRoot":"","sources":["../src/define-event.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAC1D,SAAS,EAAE,MAAM,GAChB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAM/B"}
|
package/dist/define-event.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/define-event.ts"],
|
|
4
|
-
"mappings": "AA0BO,SAAS,
|
|
4
|
+
"mappings": "AA0BO,SAAS,YACd,WAC+B;AAC/B,SAAO;AAAA,IACL;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-service-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/create-service-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-service-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/create-service-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,uBAAuB,CAAC;AAS/B,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG;QAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAEtF;;OAEG;IACH,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;OAKG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,CAAC,QAAQ,SAAS,cAAc,IAClE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CA6KvD"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import "@simplysm/core-common";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ArgumentError,
|
|
4
|
+
jsonStringify,
|
|
5
|
+
jsonParse,
|
|
6
|
+
LazyGcMap,
|
|
7
|
+
Uuid,
|
|
8
|
+
bytesConcat
|
|
9
|
+
} from "@simplysm/core-common";
|
|
3
10
|
import { PROTOCOL_CONFIG } from "./protocol.types.js";
|
|
4
11
|
function createServiceProtocol() {
|
|
5
12
|
const accumulator = new LazyGcMap({
|
|
@@ -10,7 +17,11 @@ function createServiceProtocol() {
|
|
|
10
17
|
const headerBytes = new Uint8Array(28);
|
|
11
18
|
const uuidBytes = new Uuid(header.uuid).toBytes();
|
|
12
19
|
headerBytes.set(uuidBytes, 0);
|
|
13
|
-
const headerView = new DataView(
|
|
20
|
+
const headerView = new DataView(
|
|
21
|
+
headerBytes.buffer,
|
|
22
|
+
headerBytes.byteOffset,
|
|
23
|
+
headerBytes.byteLength
|
|
24
|
+
);
|
|
14
25
|
headerView.setBigUint64(16, BigInt(header.totalSize), false);
|
|
15
26
|
headerView.setUint32(24, header.index, false);
|
|
16
27
|
return bytesConcat([headerBytes, ...bodyBytes ? [bodyBytes] : []]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["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M;AAAA,UACN;AAAA,UACA;AAAA,UACA,eAAe,QAAQ;AAAA,QACzB;AAAA,MACF,OAAO;AACL,oBAAY,OAAO,IAAI;AAEvB,cAAM,cAAc,YAAY,QAAQ,OAAO,aAAa,CAAC;AAC7D,YAAI;AACJ,YAAI;AACF,uBAAa,UAA6B,IAAI,YAAY,EAAE,OAAO,WAAW,CAAC;AAAA,QACjF,SAAS,KAAK;AACZ,gBAAM,IAAI,cAAc,qFAAoB,EAAE,MAAM,OAAO,IAAI,CAAC;AAAA,QAClE;AACA,eAAO;AAAA,UACL,MAAM;AAAA,UACN;AAAA,UACA,SAAS;AAAA,YACP,MAAM,WAAW,CAAC;AAAA,YAClB,MAAM,WAAW,CAAC;AAAA,UACpB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAgB;AACd,kBAAY,QAAQ;AAAA,IACtB;AAAA,EACF;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orm-service.types.d.ts","sourceRoot":"","sources":["../../src/service-types/orm-service.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"orm-service.types.d.ts","sourceRoot":"","sources":["../../src/service-types/orm-service.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,UAAU,EACV,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAC5D,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,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 서비스 모듈 (common)",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@simplysm/core-common": "13.0.
|
|
22
|
-
"@simplysm/orm-common": "13.0.
|
|
21
|
+
"@simplysm/core-common": "13.0.30",
|
|
22
|
+
"@simplysm/orm-common": "13.0.30"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/define-event.ts
CHANGED
|
@@ -24,7 +24,9 @@ export interface ServiceEventDef<TInfo = unknown, TData = unknown> {
|
|
|
24
24
|
* console.log(data.status); // typed
|
|
25
25
|
* });
|
|
26
26
|
*/
|
|
27
|
-
export function defineEvent<TInfo = unknown, TData = unknown>(
|
|
27
|
+
export function defineEvent<TInfo = unknown, TData = unknown>(
|
|
28
|
+
eventName: string,
|
|
29
|
+
): ServiceEventDef<TInfo, TData> {
|
|
28
30
|
return {
|
|
29
31
|
eventName,
|
|
30
32
|
$info: undefined as unknown as TInfo,
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Bytes } from "@simplysm/core-common";
|
|
2
2
|
import "@simplysm/core-common";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ArgumentError,
|
|
5
|
+
jsonStringify,
|
|
6
|
+
jsonParse,
|
|
7
|
+
LazyGcMap,
|
|
8
|
+
Uuid,
|
|
9
|
+
bytesConcat,
|
|
10
|
+
} from "@simplysm/core-common";
|
|
4
11
|
import { PROTOCOL_CONFIG, type ServiceMessage } from "./protocol.types";
|
|
5
12
|
|
|
6
13
|
/**
|
|
@@ -99,7 +106,11 @@ export function createServiceProtocol(): ServiceProtocol {
|
|
|
99
106
|
headerBytes.set(uuidBytes, 0);
|
|
100
107
|
|
|
101
108
|
// TotalSize (16-23), Index (24-27)
|
|
102
|
-
const headerView = new DataView(
|
|
109
|
+
const headerView = new DataView(
|
|
110
|
+
headerBytes.buffer,
|
|
111
|
+
headerBytes.byteOffset,
|
|
112
|
+
headerBytes.byteLength,
|
|
113
|
+
);
|
|
103
114
|
headerView.setBigUint64(16, BigInt(header.totalSize), false);
|
|
104
115
|
headerView.setUint32(24, header.index, false);
|
|
105
116
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Dialect,
|
|
3
|
+
IsolationLevel,
|
|
4
|
+
QueryDef,
|
|
5
|
+
ColumnMeta,
|
|
6
|
+
ResultMeta,
|
|
7
|
+
} from "@simplysm/orm-common";
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* ORM 서비스 인터페이스
|
|
@@ -25,7 +31,11 @@ export interface OrmService {
|
|
|
25
31
|
|
|
26
32
|
executeParametrized(connId: number, query: string, params?: unknown[]): Promise<unknown[][]>;
|
|
27
33
|
|
|
28
|
-
executeDefs(
|
|
34
|
+
executeDefs(
|
|
35
|
+
connId: number,
|
|
36
|
+
defs: QueryDef[],
|
|
37
|
+
options?: (ResultMeta | undefined)[],
|
|
38
|
+
): Promise<unknown[][]>;
|
|
29
39
|
|
|
30
40
|
bulkInsert(
|
|
31
41
|
connId: number,
|