@simplysm/service-common 14.0.48 → 14.0.50
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 +32 -53
- package/docs/app-structure/app-structure-item.md +107 -0
- package/docs/app-structure/get-flat-permissions.md +57 -0
- package/docs/app-structure/is-usable-modules-chain.md +23 -0
- package/docs/app-structure/is-usable-modules.md +42 -0
- package/docs/{events.md → events/define-event.md} +30 -26
- package/docs/protocol/create-service-protocol.md +93 -0
- package/docs/protocol/protocol-config.md +21 -0
- package/docs/protocol/service-add-event-listener-message.md +23 -0
- package/docs/protocol/service-auth-message.md +17 -0
- package/docs/protocol/service-emit-event-message.md +21 -0
- package/docs/protocol/service-error-message.md +29 -0
- package/docs/protocol/service-event-message.md +21 -0
- package/docs/protocol/service-get-event-listener-infos-message.md +19 -0
- package/docs/protocol/service-message.md +52 -0
- package/docs/protocol/service-progress-message.md +21 -0
- package/docs/protocol/service-remove-event-listener-message.md +19 -0
- package/docs/protocol/service-request-message.md +17 -0
- package/docs/protocol/service-response-message.md +17 -0
- package/docs/service-types/app-structure-service.md +15 -0
- package/docs/service-types/auto-update-service.md +20 -0
- package/docs/{service-types.md → service-types/orm-service.md} +61 -90
- package/docs/{types.md → types/service-upload-result.md} +19 -19
- package/package.json +3 -3
- package/docs/app-structure.md +0 -175
- package/docs/protocol.md +0 -331
package/docs/protocol.md
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
# Protocol
|
|
2
|
-
|
|
3
|
-
## `PROTOCOL_CONFIG`
|
|
4
|
-
|
|
5
|
-
서비스 프로토콜 설정 상수.
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
export const PROTOCOL_CONFIG = {
|
|
9
|
-
MAX_TOTAL_SIZE: 100 * 1024 * 1024, // 최대 메시지 크기 (100MB)
|
|
10
|
-
SPLIT_MESSAGE_SIZE: 3 * 1024 * 1024, // 청킹 임계값 (3MB)
|
|
11
|
-
CHUNK_SIZE: 300 * 1024, // 청크 크기 (300KB)
|
|
12
|
-
GC_INTERVAL: 10 * 1000, // GC 주기 (10초)
|
|
13
|
-
EXPIRE_TIME: 60 * 1000, // 미완성 메시지 만료 시간 (60초)
|
|
14
|
-
} as const;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
| Field | Type | Description |
|
|
18
|
-
|-------|------|-------------|
|
|
19
|
-
| `MAX_TOTAL_SIZE` | `number` | 단일 메시지의 최대 허용 크기. 초과 시 `ArgumentError` 발생 |
|
|
20
|
-
| `SPLIT_MESSAGE_SIZE` | `number` | 이 크기를 초과하면 자동으로 청크 분할 |
|
|
21
|
-
| `CHUNK_SIZE` | `number` | 분할된 각 청크의 크기 |
|
|
22
|
-
| `GC_INTERVAL` | `number` | 내부 청크 누적기의 가비지 컬렉션 주기 (밀리초) |
|
|
23
|
-
| `EXPIRE_TIME` | `number` | 미완성 청크 메시지의 만료 시간. 이 시간 내에 모든 청크가 도착하지 않으면 제거 |
|
|
24
|
-
|
|
25
|
-
## `ServiceMessage`
|
|
26
|
-
|
|
27
|
-
모든 서비스 메시지의 유니언 타입. 클라이언트·서버 양방향 메시지를 모두 포함한다.
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
export type ServiceMessage =
|
|
31
|
-
| ServiceRequestMessage
|
|
32
|
-
| ServiceAuthMessage
|
|
33
|
-
| ServiceProgressMessage
|
|
34
|
-
| ServiceResponseMessage
|
|
35
|
-
| ServiceErrorMessage
|
|
36
|
-
| ServiceAddEventListenerMessage
|
|
37
|
-
| ServiceRemoveEventListenerMessage
|
|
38
|
-
| ServiceGetEventListenerInfosMessage
|
|
39
|
-
| ServiceEmitEventMessage
|
|
40
|
-
| ServiceEventMessage;
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## `ServiceServerMessage`
|
|
44
|
-
|
|
45
|
-
서버 → 클라이언트 메시지 유니언.
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
export type ServiceServerMessage =
|
|
49
|
-
| ServiceResponseMessage
|
|
50
|
-
| ServiceErrorMessage
|
|
51
|
-
| ServiceEventMessage;
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## `ServiceServerRawMessage`
|
|
55
|
-
|
|
56
|
-
서버가 보내는 모든 메시지 (진행 상태 포함).
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
export type ServiceServerRawMessage = ServiceProgressMessage | ServiceServerMessage;
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## `ServiceClientMessage`
|
|
63
|
-
|
|
64
|
-
클라이언트 → 서버 메시지 유니언.
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
export type ServiceClientMessage =
|
|
68
|
-
| ServiceRequestMessage
|
|
69
|
-
| ServiceAuthMessage
|
|
70
|
-
| ServiceAddEventListenerMessage
|
|
71
|
-
| ServiceRemoveEventListenerMessage
|
|
72
|
-
| ServiceGetEventListenerInfosMessage
|
|
73
|
-
| ServiceEmitEventMessage;
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## `ServiceProgressMessage`
|
|
77
|
-
|
|
78
|
-
서버가 보내는 청크 수신 진행 상태 알림 메시지.
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
export interface ServiceProgressMessage {
|
|
82
|
-
name: "progress";
|
|
83
|
-
body: {
|
|
84
|
-
totalSize: number;
|
|
85
|
-
completedSize: number;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
| Field | Type | Description |
|
|
91
|
-
|-------|------|-------------|
|
|
92
|
-
| `name` | `"progress"` | 고정 문자열 discriminant |
|
|
93
|
-
| `body.totalSize` | `number` | 전체 메시지 크기 (바이트) |
|
|
94
|
-
| `body.completedSize` | `number` | 현재까지 수신 완료된 크기 (바이트) |
|
|
95
|
-
|
|
96
|
-
## `ServiceErrorMessage`
|
|
97
|
-
|
|
98
|
-
서버가 보내는 에러 알림 메시지.
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
export interface ServiceErrorMessage {
|
|
102
|
-
name: "error";
|
|
103
|
-
body: {
|
|
104
|
-
name: string;
|
|
105
|
-
message: string;
|
|
106
|
-
code: string;
|
|
107
|
-
stack?: string;
|
|
108
|
-
detail?: unknown;
|
|
109
|
-
cause?: unknown;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
| Field | Type | Description |
|
|
115
|
-
|-------|------|-------------|
|
|
116
|
-
| `name` | `"error"` | 고정 문자열 discriminant |
|
|
117
|
-
| `body.name` | `string` | 에러 이름 (클래스명) |
|
|
118
|
-
| `body.message` | `string` | 에러 메시지 |
|
|
119
|
-
| `body.code` | `string` | 에러 코드 |
|
|
120
|
-
| `body.stack` | `string?` | 스택 트레이스 (선택) |
|
|
121
|
-
| `body.detail` | `unknown?` | 추가 상세 정보 (선택) |
|
|
122
|
-
| `body.cause` | `unknown?` | 원인 에러 (선택) |
|
|
123
|
-
|
|
124
|
-
## `ServiceAuthMessage`
|
|
125
|
-
|
|
126
|
-
클라이언트가 보내는 인증 메시지.
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
export interface ServiceAuthMessage {
|
|
130
|
-
name: "auth";
|
|
131
|
-
body: string;
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
| Field | Type | Description |
|
|
136
|
-
|-------|------|-------------|
|
|
137
|
-
| `name` | `"auth"` | 고정 문자열 discriminant |
|
|
138
|
-
| `body` | `string` | 인증 토큰 |
|
|
139
|
-
|
|
140
|
-
## `ServiceRequestMessage`
|
|
141
|
-
|
|
142
|
-
클라이언트가 보내는 서비스 메서드 요청 메시지.
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
export interface ServiceRequestMessage {
|
|
146
|
-
name: `${string}.${string}`;
|
|
147
|
-
body: unknown[];
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
| Field | Type | Description |
|
|
152
|
-
|-------|------|-------------|
|
|
153
|
-
| `name` | `` `${string}.${string}` `` | 서비스명.메서드명 형식 (예: `"OrmService.connect"`) |
|
|
154
|
-
| `body` | `unknown[]` | 메서드 매개변수 배열 |
|
|
155
|
-
|
|
156
|
-
## `ServiceResponseMessage`
|
|
157
|
-
|
|
158
|
-
서버가 보내는 서비스 메서드 응답 메시지.
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
export interface ServiceResponseMessage {
|
|
162
|
-
name: "response";
|
|
163
|
-
body?: unknown;
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
| Field | Type | Description |
|
|
168
|
-
|-------|------|-------------|
|
|
169
|
-
| `name` | `"response"` | 고정 문자열 discriminant |
|
|
170
|
-
| `body` | `unknown?` | 메서드 실행 결과 (없으면 void) |
|
|
171
|
-
|
|
172
|
-
## `ServiceAddEventListenerMessage`
|
|
173
|
-
|
|
174
|
-
클라이언트가 보내는 이벤트 리스너 추가 메시지.
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
export interface ServiceAddEventListenerMessage {
|
|
178
|
-
name: "evt:add";
|
|
179
|
-
body: {
|
|
180
|
-
key: string;
|
|
181
|
-
name: string;
|
|
182
|
-
info: unknown;
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
| Field | Type | Description |
|
|
188
|
-
|-------|------|-------------|
|
|
189
|
-
| `name` | `"evt:add"` | 고정 문자열 discriminant |
|
|
190
|
-
| `body.key` | `string` | 리스너 키 (UUID). removeEventListener에 사용 |
|
|
191
|
-
| `body.name` | `string` | 이벤트 이름 (`ServiceEventDef.eventName`) |
|
|
192
|
-
| `body.info` | `unknown` | 이벤트 발생 시 필터링을 위한 추가 리스너 정보 |
|
|
193
|
-
|
|
194
|
-
## `ServiceRemoveEventListenerMessage`
|
|
195
|
-
|
|
196
|
-
클라이언트가 보내는 이벤트 리스너 제거 메시지.
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
export interface ServiceRemoveEventListenerMessage {
|
|
200
|
-
name: "evt:remove";
|
|
201
|
-
body: {
|
|
202
|
-
key: string;
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
| Field | Type | Description |
|
|
208
|
-
|-------|------|-------------|
|
|
209
|
-
| `name` | `"evt:remove"` | 고정 문자열 discriminant |
|
|
210
|
-
| `body.key` | `string` | 제거할 리스너 키 (UUID) |
|
|
211
|
-
|
|
212
|
-
## `ServiceGetEventListenerInfosMessage`
|
|
213
|
-
|
|
214
|
-
클라이언트가 보내는 이벤트 리스너 정보 목록 요청 메시지.
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
export interface ServiceGetEventListenerInfosMessage {
|
|
218
|
-
name: "evt:gets";
|
|
219
|
-
body: {
|
|
220
|
-
name: string;
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
| Field | Type | Description |
|
|
226
|
-
|-------|------|-------------|
|
|
227
|
-
| `name` | `"evt:gets"` | 고정 문자열 discriminant |
|
|
228
|
-
| `body.name` | `string` | 조회할 이벤트 이름 |
|
|
229
|
-
|
|
230
|
-
## `ServiceEmitEventMessage`
|
|
231
|
-
|
|
232
|
-
클라이언트가 보내는 이벤트 발생 메시지.
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
export interface ServiceEmitEventMessage {
|
|
236
|
-
name: "evt:emit";
|
|
237
|
-
body: {
|
|
238
|
-
keys: string[];
|
|
239
|
-
data: unknown;
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
| Field | Type | Description |
|
|
245
|
-
|-------|------|-------------|
|
|
246
|
-
| `name` | `"evt:emit"` | 고정 문자열 discriminant |
|
|
247
|
-
| `body.keys` | `string[]` | 대상 리스너 키 목록 |
|
|
248
|
-
| `body.data` | `unknown` | 이벤트 데이터 |
|
|
249
|
-
|
|
250
|
-
## `ServiceEventMessage`
|
|
251
|
-
|
|
252
|
-
서버가 보내는 이벤트 알림 메시지.
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
export interface ServiceEventMessage {
|
|
256
|
-
name: "evt:on";
|
|
257
|
-
body: {
|
|
258
|
-
keys: string[];
|
|
259
|
-
data: unknown;
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
| Field | Type | Description |
|
|
265
|
-
|-------|------|-------------|
|
|
266
|
-
| `name` | `"evt:on"` | 고정 문자열 discriminant |
|
|
267
|
-
| `body.keys` | `string[]` | 대상 리스너 키 목록 |
|
|
268
|
-
| `body.data` | `unknown` | 이벤트 데이터 |
|
|
269
|
-
|
|
270
|
-
## `ServiceProtocol`
|
|
271
|
-
|
|
272
|
-
바이너리 프로토콜 V2 인코더/디코더 인터페이스. `createServiceProtocol()`로 생성한다.
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
export interface ServiceProtocol {
|
|
276
|
-
encode(uuid: string, message: ServiceMessage): { chunks: Bytes[]; totalSize: number };
|
|
277
|
-
decode<T extends ServiceMessage>(bytes: Bytes): ServiceMessageDecodeResult<T>;
|
|
278
|
-
dispose(): void;
|
|
279
|
-
}
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
| Method | Parameters | Return | Description |
|
|
283
|
-
|--------|-----------|--------|-------------|
|
|
284
|
-
| `encode` | `uuid: string, message: ServiceMessage` | `{ chunks: Bytes[]; totalSize: number }` | 메시지를 인코딩한다. 3MB 초과 시 300KB 청크로 자동 분할 |
|
|
285
|
-
| `decode` | `bytes: Bytes` | `ServiceMessageDecodeResult<T>` | 청크를 디코딩한다. 청크가 모두 도착하면 complete, 아니면 progress 반환 |
|
|
286
|
-
| `dispose` | 없음 | `void` | 내부 GC 타이머와 청크 누적기를 해제한다. 사용 후 반드시 호출 |
|
|
287
|
-
|
|
288
|
-
헤더 구조 (28바이트, Big Endian):
|
|
289
|
-
|
|
290
|
-
| Offset | Size | Field |
|
|
291
|
-
|--------|------|-------|
|
|
292
|
-
| 0 | 16 | UUID (바이너리) |
|
|
293
|
-
| 16 | 8 | TotalSize (uint64, 상위 4바이트 = 0) |
|
|
294
|
-
| 24 | 4 | Index (uint32) |
|
|
295
|
-
|
|
296
|
-
## `ServiceMessageDecodeResult`
|
|
297
|
-
|
|
298
|
-
메시지 디코딩 결과 유니언 타입. `type` 필드로 분기한다.
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
export type ServiceMessageDecodeResult<TMessage extends ServiceMessage> =
|
|
302
|
-
| { type: "complete"; uuid: string; message: TMessage }
|
|
303
|
-
| { type: "progress"; uuid: string; totalSize: number; completedSize: number };
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
**Variant: `complete`** — 모든 청크가 도착하여 메시지 재조립이 완료된 상태.
|
|
307
|
-
|
|
308
|
-
| Field | Type | Description |
|
|
309
|
-
|-------|------|-------------|
|
|
310
|
-
| `type` | `"complete"` | discriminant |
|
|
311
|
-
| `uuid` | `string` | 메시지 UUID |
|
|
312
|
-
| `message` | `TMessage` | 재조립된 메시지 |
|
|
313
|
-
|
|
314
|
-
**Variant: `progress`** — 청크 메시지 수신 진행 중.
|
|
315
|
-
|
|
316
|
-
| Field | Type | Description |
|
|
317
|
-
|-------|------|-------------|
|
|
318
|
-
| `type` | `"progress"` | discriminant |
|
|
319
|
-
| `uuid` | `string` | 메시지 UUID |
|
|
320
|
-
| `totalSize` | `number` | 전체 크기 (바이트) |
|
|
321
|
-
| `completedSize` | `number` | 수신 완료된 크기 (바이트) |
|
|
322
|
-
|
|
323
|
-
## `createServiceProtocol`
|
|
324
|
-
|
|
325
|
-
ServiceProtocol 인스턴스를 생성하는 팩토리 함수.
|
|
326
|
-
|
|
327
|
-
```typescript
|
|
328
|
-
export function createServiceProtocol(): ServiceProtocol;
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
내부에 `LazyGcMap` 기반 청크 누적기를 캡슐화한다. 미완성 메시지는 60초 후 GC로 자동 정리된다. 사용 후 반드시 `dispose()`를 호출하여 GC 타이머를 해제해야 한다.
|