@lemoncloud/chatic-sockets-api 0.26.402 → 0.26.404

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.
@@ -1,696 +0,0 @@
1
- /**
2
- * `wss-types.ts`
3
- * - WebSocket 통신을 위한 타입 정의
4
- *
5
- * @author Steve <steve@lemoncloud.io>
6
- * @date 2020-06-30 initial version
7
- * @author Aiden <aiden@lemoncloud.io>
8
- * @date 2025-07-31 refactored for WebSocket support
9
- * @date 2026-01-11 redesigned with envelope pattern
10
- *
11
- * @copyright (C) 2026 LemonCloud Co Ltd. - All Rights Reserved.
12
- */
13
- import type { AuthState } from '../../modules/auth/types';
14
- import type { UserHead } from '../../modules/auth/model';
15
- /**
16
- * interface: `ConnectionInfo`
17
- * - 연결 정보 공통 모델
18
- */
19
- export interface ConnectionInfo {
20
- /** stage of api-gateway */
21
- stage?: string;
22
- /** connected domain */
23
- domain?: string;
24
- /** api-gateway id */
25
- apiId?: string;
26
- /** connection-id */
27
- connectionId?: string;
28
- }
29
- /**
30
- * interface: `SocketEvent`
31
- * - Lambda에서 수신하는 WebSocket 이벤트
32
- */
33
- export interface SocketEvent extends ConnectionInfo {
34
- /** request-id */
35
- id: string;
36
- type: WSSEventType;
37
- route: WSSRouteKeyType;
38
- authorization?: string;
39
- stage: WSSStageType;
40
- direction: WSSDirectionType;
41
- disconnectCode?: WSSDisconnectStatusCode;
42
- reason: string;
43
- domain: string;
44
- origin: string;
45
- agent: string;
46
- connectionId: string;
47
- messageId: string;
48
- apiId: string;
49
- connectedAt: number;
50
- remote: string;
51
- body?: string;
52
- param: {
53
- [key: string]: string;
54
- };
55
- }
56
- /**
57
- * lookup table
58
- */
59
- declare const $LUT: {
60
- /**
61
- * EventType
62
- */
63
- EventType: {
64
- '': string;
65
- /** CONNECT */
66
- CONNECT: string;
67
- /** DISCONNECT */
68
- DISCONNECT: string;
69
- /** MESSAGE */
70
- MESSAGE: string;
71
- };
72
- /**
73
- * RouteKeyType
74
- */
75
- RouteKeyType: {
76
- /** $connect */
77
- $connect: string;
78
- /** $disconnect */
79
- $disconnect: string;
80
- /** $default */
81
- $default: string;
82
- /** echo */
83
- echo: string;
84
- };
85
- /**
86
- * StageType
87
- */
88
- StageType: {
89
- '': string;
90
- /** dev */
91
- dev: string;
92
- /** prod */
93
- prod: string;
94
- /** local */
95
- local: string;
96
- };
97
- /**
98
- * DirectionType
99
- */
100
- DirectionType: {
101
- '': string;
102
- /** IN */
103
- IN: string;
104
- /** OUT */
105
- OUT: string;
106
- };
107
- /**
108
- * DisconnectStatusCode
109
- */
110
- DisconnectStatusCode: {
111
- /** 1000 - Normal closure */
112
- 1000: string;
113
- /** 1001 - Server shutdown/page navigation */
114
- 1001: string;
115
- /** 1002 - Protocol error */
116
- 1002: string;
117
- /** 1003 - Unsupported data */
118
- 1003: string;
119
- /** 1005 - No status code received */
120
- 1005: string;
121
- /** 1006 - Abnormal closure */
122
- 1006: string;
123
- /** 1007 - Invalid frame payload */
124
- 1007: string;
125
- /** 1008 - Policy violation */
126
- 1008: string;
127
- /** 1009 - Message too big */
128
- 1009: string;
129
- /** 1011 - Internal server error */
130
- 1011: string;
131
- /** 1012 - Service restart */
132
- 1012: string;
133
- /** 1013 - Try again later */
134
- 1013: string;
135
- /** 1015 - TLS handshake failure */
136
- 1015: string;
137
- };
138
- /**
139
- * EventDomainType
140
- * - 이벤트 도메인
141
- */
142
- EventDomainType: {
143
- '': string;
144
- /** auth - authentication domain */
145
- auth: string;
146
- /** system */
147
- system: string;
148
- /** sync - client state synchronization */
149
- sync: string;
150
- /** model */
151
- model: string;
152
- /** channel - dynamic channel subscription */
153
- channel: string;
154
- /** chat - chat message domain (send/read via $protocol) */
155
- chat: string;
156
- /** user */
157
- user: string;
158
- /** @deprecated use 'sync' instead */
159
- presence: string;
160
- /** @deprecated use 'sync' instead */
161
- position: string;
162
- };
163
- /**
164
- * SystemActionType
165
- * - system 도메인 액션
166
- */
167
- SystemActionType: {
168
- '': string;
169
- /** ping */
170
- ping: string;
171
- /** pong */
172
- pong: string;
173
- /** info */
174
- info: string;
175
- /** message */
176
- message: string;
177
- /** error */
178
- error: string;
179
- };
180
- /**
181
- * ModelActionType
182
- * - data 도메인 액션
183
- */
184
- ModelActionType: {
185
- '': string;
186
- /** create */
187
- create: string;
188
- /** update */
189
- update: string;
190
- /** delete */
191
- delete: string;
192
- };
193
- /**
194
- * SyncActionType
195
- */
196
- SyncActionType: {
197
- '': string;
198
- /** update - client state update */
199
- update: string;
200
- /** info - get current state */
201
- info: string;
202
- /** @deprecated use 'update' instead */
203
- sync: string;
204
- };
205
- /**
206
- * AuthActionType
207
- * - auth domain actions
208
- */
209
- AuthActionType: {
210
- '': string;
211
- /** update - state synchronization */
212
- update: string;
213
- };
214
- /**
215
- * ChannelActionType
216
- * - channel domain actions
217
- */
218
- ChannelActionType: {
219
- '': string;
220
- /** subscribe - join channels */
221
- subscribe: string;
222
- /** unsubscribe - leave channels */
223
- unsubscribe: string;
224
- };
225
- /**
226
- * ChatActionType
227
- * - chat domain actions
228
- */
229
- ChatActionType: {
230
- '': string;
231
- /** send - send chat message */
232
- send: string;
233
- /** read - mark as read */
234
- read: string;
235
- /** start - start conversation */
236
- start: string;
237
- /** feed - get chat feed */
238
- feed: string;
239
- /** mine - get my channels */
240
- mine: string;
241
- /** users - get channel members */
242
- users: string;
243
- /** invite - invite users to channel */
244
- invite: string;
245
- /** leave - leave or kick from channel */
246
- leave: string;
247
- /** update-channel - update channel info */
248
- 'update-channel': string;
249
- /** update-join - update join (participation) settings */
250
- 'update-join': string;
251
- /** delete-channel - delete channel */
252
- 'delete-channel': string;
253
- /** error - error response */
254
- error: string;
255
- };
256
- /**
257
- * UserActionType
258
- * - user domain actions
259
- */
260
- UserActionType: {
261
- '': string;
262
- /** invite: 유저초대 */
263
- invite: string;
264
- /** my-site: 접근 가능 사이트 목록 조회 */
265
- 'my-site': string;
266
- /** make-site: 사이트 생성 */
267
- 'make-site': string;
268
- /** update-profile: 프로필 수정 */
269
- 'update-profile': string;
270
- /** update-site: 플레이스 수정 */
271
- 'update-site': string;
272
- /** error - error response */
273
- error: string;
274
- };
275
- /**
276
- * ClientStatusType
277
- */
278
- ClientStatusType: {
279
- '': string;
280
- /** green - online */
281
- green: string;
282
- /** red - offline */
283
- red: string;
284
- /** yellow - away/idle */
285
- yellow: string;
286
- };
287
- };
288
- /**
289
- * type: `WSSEventType
290
- */
291
- export declare type WSSEventType = keyof typeof $LUT.EventType;
292
- /**
293
- * type: `WSSRouteKeyType
294
- */
295
- export declare type WSSRouteKeyType = keyof typeof $LUT.RouteKeyType;
296
- /**
297
- * type: `WSSDirectionType
298
- */
299
- export declare type WSSDirectionType = keyof typeof $LUT.DirectionType;
300
- /**
301
- * type: `WSSDisconnectStatusCode
302
- */
303
- export declare type WSSDisconnectStatusCode = keyof typeof $LUT.DisconnectStatusCode;
304
- /**
305
- * type: `WSSStageType
306
- */
307
- export declare type WSSStageType = keyof typeof $LUT.StageType;
308
- /**
309
- * type: `WSSEventDomainType
310
- */
311
- export declare type WSSEventDomainType = keyof typeof $LUT.EventDomainType;
312
- /**
313
- * type: `WSSSystemActionType
314
- */
315
- export declare type WSSSystemActionType = keyof typeof $LUT.SystemActionType;
316
- /**
317
- * type: `WSSModelActionType
318
- */
319
- export declare type WSSModelActionType = keyof typeof $LUT.ModelActionType;
320
- /**
321
- * type: `WSSSyncActionType`
322
- */
323
- export declare type WSSSyncActionType = keyof typeof $LUT.SyncActionType;
324
- /**
325
- * type: `WSSAuthActionType`
326
- */
327
- export declare type WSSAuthActionType = keyof typeof $LUT.AuthActionType;
328
- /**
329
- * type: `WSSChannelActionType`
330
- */
331
- export declare type WSSChannelActionType = keyof typeof $LUT.ChannelActionType;
332
- /**
333
- * type: `WSSChatActionType`
334
- */
335
- export declare type WSSChatActionType = keyof typeof $LUT.ChatActionType;
336
- /**
337
- * type: `WSSUserActionType`
338
- */
339
- export declare type WSSUserActionType = keyof typeof $LUT.UserActionType;
340
- /**
341
- * type: `ClientStatusType`
342
- */
343
- export declare type ClientStatusType = keyof typeof $LUT.ClientStatusType;
344
- /**
345
- * type: `WSSActionType`
346
- */
347
- export declare type WSSActionType = WSSSystemActionType | WSSModelActionType | WSSSyncActionType | WSSAuthActionType | WSSChannelActionType | WSSChatActionType | WSSUserActionType;
348
- /**
349
- * interface: `WSSConnectParam`
350
- */
351
- export interface WSSConnectParam {
352
- /** get connection info after connect */
353
- info?: string | boolean;
354
- /** trigger auth event on connect (token if string) */
355
- auth?: string | boolean;
356
- /** join default channel */
357
- default?: string | boolean;
358
- /** use notify queue */
359
- notify?: string | boolean;
360
- /** (test) throw error */
361
- throws?: string;
362
- /** channel ids to subscribe */
363
- channels?: string[];
364
- /** device-id */
365
- deviceId?: string;
366
- /** device-name */
367
- deviceName?: string;
368
- }
369
- /**
370
- * interface: `WSSEnvelope`
371
- * - 양방향 WebSocket 통신 메시지 봉투
372
- */
373
- export interface WSSEnvelope<T = any> {
374
- /** event domain */
375
- type: WSSEventDomainType;
376
- /** action within domain */
377
- action: WSSActionType;
378
- /** (optional) payload data */
379
- payload?: T;
380
- /** (optional) message-id (for Server) */
381
- mid?: string;
382
- /** (optional) meta data (for Server) */
383
- meta?: WSSMeta;
384
- /** (internal) target user-ids for broadcast (only for server.) */
385
- userIds?: string[];
386
- }
387
- /**
388
- * interface: `WSSMeta`
389
- * - 메시지 메타데이터
390
- */
391
- export interface WSSMeta {
392
- /** timestamp (ms) */
393
- ts: number;
394
- /** sequence number */
395
- seq?: number;
396
- /** target channel */
397
- channel?: string;
398
- /** reference-id (for ack) */
399
- ref?: string;
400
- }
401
- /**
402
- * interface: `WSSPayload`
403
- * - base payload
404
- */
405
- export interface WSSPayload {
406
- /** payload-id */
407
- id?: string;
408
- /** reference id (for ack) */
409
- ref?: string;
410
- }
411
- /**
412
- * interface: `SystemPayload`
413
- * - system domain payload
414
- */
415
- export interface SystemPayload extends WSSPayload {
416
- /** content */
417
- content?: string;
418
- /** ping-pong count */
419
- count?: number;
420
- }
421
- /**
422
- * interface: `ClientSyncPayload`
423
- * - client sync domain payload
424
- */
425
- export interface ClientSyncPayload extends WSSPayload {
426
- /**
427
- * tick count (from Server)
428
- * 1. [Client] sends its current tick(Payload) to Server ONLY if tick is changed.
429
- * 2. [Server] compares Client.tick with its own tick:
430
- * - if equal, no action needed (Client is in sync)
431
- * - if different, Server responds with updated state and its current tick
432
- *
433
- * NOTE 주의! 무한 핑/퐁
434
- */
435
- tick: number;
436
- /** x position (for Client) */
437
- posX: number;
438
- /** y position (for Client) */
439
- posY: number;
440
- /** (optional) client timestamp (ms) */
441
- ts?: number;
442
- /**
443
- * ONLY for Client.
444
- * - status indicator
445
- */
446
- status: ClientStatusType;
447
- }
448
- /**
449
- * interface: `ModelSyncPayload`
450
- * - model sync domain payload
451
- * - only for Server
452
- */
453
- export interface ModelSyncPayload extends WSSPayload {
454
- /** id of model */
455
- sourceId?: string;
456
- /** type of model */
457
- sourceType?: string;
458
- /** service of source */
459
- service?: string;
460
- /** sid of model */
461
- sid?: string;
462
- /** uid of model */
463
- uid?: string;
464
- /** gid of model */
465
- gid?: string;
466
- /** oid of model (owner) */
467
- oid?: string;
468
- }
469
- /**
470
- * interface: `AuthPayload`
471
- * - auth domain payload for bidirectional communication
472
- */
473
- export interface AuthPayload extends WSSPayload {
474
- /** [Client] JWT token (issued by main backend) */
475
- token?: string;
476
- /** dry-run execution flag */
477
- dryRun?: boolean;
478
- /** [Server] current auth state */
479
- state?: AuthState;
480
- /** [Server] state transition timestamp */
481
- stateAt?: number;
482
- /** [Server] internal error */
483
- error?: string;
484
- /** (internal) authed conn-id */
485
- connId?: string;
486
- /** (internal) authed device-id */
487
- deviceId?: string;
488
- /** (internal) authed auth-id */
489
- authId?: string;
490
- /** (internal) authed member-id */
491
- memberId?: string;
492
- /** [Server] member info on success */
493
- readonly member$?: UserHead;
494
- }
495
- /**
496
- * interface: `ChannelPayload`
497
- * - channel domain payload for subscribe/unsubscribe
498
- */
499
- export interface ChannelPayload extends WSSPayload {
500
- /** [Client] channel ids to subscribe/unsubscribe */
501
- channels?: string[];
502
- /** [Server] channel ids successfully subscribed */
503
- subscribed?: string[];
504
- /** [Server] channel ids successfully unsubscribed */
505
- unsubscribed?: string[];
506
- }
507
- /**
508
- * interface: `ChatSendPayload`
509
- * - chat:send request payload
510
- */
511
- export interface ChatSendPayload extends WSSPayload {
512
- /** target channel id */
513
- channelId: string;
514
- /** message content */
515
- content: string;
516
- /** message type (default: "text") */
517
- contentType?: string;
518
- /** thread/reply parent id */
519
- parentId?: string;
520
- }
521
- /**
522
- * interface: `ChatReadPayload`
523
- * - chat:read request payload
524
- */
525
- export interface ChatReadPayload extends WSSPayload {
526
- /** target channel id */
527
- channelId: string;
528
- /** last read chat number (>= 1) */
529
- chatNo: number;
530
- }
531
- /**
532
- * interface: `ChatErrorPayload`
533
- * - chat:error response payload
534
- */
535
- export interface ChatErrorPayload extends WSSPayload {
536
- /** error message */
537
- error: string;
538
- }
539
- /**
540
- * interface: `ChatStartPayload`
541
- * - chat:start request payload
542
- */
543
- export interface ChatStartPayload extends WSSPayload {
544
- /** channel type: dm, self, public, private */
545
- stereo: 'dm' | 'self' | 'public' | 'private';
546
- /** channel name */
547
- name?: string;
548
- /** user ids to invite (excluding self) */
549
- userIds?: string[];
550
- /** first message content */
551
- content?: string;
552
- /** message type (default: "text") */
553
- contentType?: string;
554
- }
555
- /**
556
- * interface: `ChatFeedPayload`
557
- * - chat:feed request payload
558
- */
559
- export interface ChatFeedPayload extends WSSPayload {
560
- /** target channel id */
561
- channelId: string;
562
- /** cursor: fetch chatNo < cursorNo (exclusive upper bound) */
563
- cursorNo?: number;
564
- /** page size (default 20) */
565
- limit?: number;
566
- }
567
- /**
568
- * interface: `ChatMinePayload`
569
- * - chat:mine request payload
570
- */
571
- export interface ChatMinePayload extends WSSPayload {
572
- /** page size (default 5) */
573
- limit?: number;
574
- /** page number (default 0) */
575
- page?: number;
576
- /** include detail */
577
- detail?: boolean;
578
- }
579
- /**
580
- * interface: `ChatUsersPayload`
581
- * - chat:users request payload
582
- */
583
- export interface ChatUsersPayload extends WSSPayload {
584
- /** target channel id */
585
- channelId: string;
586
- /** page size (default 5) */
587
- limit?: number;
588
- /** page number (default 0) */
589
- page?: number;
590
- /** include detail */
591
- detail?: boolean;
592
- }
593
- /**
594
- * interface: `ChatInvitePayload`
595
- * - chat:invite request payload
596
- */
597
- export interface ChatInvitePayload extends WSSPayload {
598
- /** target channel id */
599
- channelId: string;
600
- /** user ids to invite */
601
- userIds: string[];
602
- }
603
- /**
604
- * interface: `ChatLeavePayload`
605
- * - chat:leave request payload
606
- */
607
- export interface ChatLeavePayload extends WSSPayload {
608
- /** target channel id */
609
- channelId: string;
610
- /** kick target user id (omit for self-leave) */
611
- userId?: string;
612
- /** kick reason */
613
- reason?: string;
614
- }
615
- /**
616
- * interface: `ChatUpdateChannelPayload`
617
- * - chat:update-channel request payload
618
- */
619
- export interface ChatUpdateChannelPayload extends WSSPayload {
620
- /** target channel id */
621
- channelId: string;
622
- /** channel name */
623
- name?: string;
624
- /** channel description */
625
- desc?: string;
626
- /** channel stereo */
627
- stereo?: '' | 'dm' | 'self' | 'public' | 'private';
628
- /** invite rule */
629
- inviteRule?: '' | 'owner' | 'all';
630
- }
631
- /**
632
- * interface: `ChatUpdateJoinPayload`
633
- * - chat:update-join request payload
634
- */
635
- export interface ChatUpdateJoinPayload extends WSSPayload {
636
- /** target channel id (joinId = channelId@userId, userId from conn.uid) */
637
- channelId: string;
638
- /** nick name in channel */
639
- nick?: string;
640
- /** notification setting */
641
- notify?: '' | 'all' | 'mention' | 'none';
642
- }
643
- /**
644
- * interface: `ChatDeleteChannelPayload`
645
- * - chat:delete-channel request payload
646
- */
647
- export interface ChatDeleteChannelPayload extends WSSPayload {
648
- /** target channel id */
649
- channelId: string;
650
- }
651
- /**
652
- * interface: `UserMakeSitePayload`
653
- * - user:make-site request payload
654
- */
655
- export interface UserMakeSitePayload extends WSSPayload {
656
- /** place name */
657
- name: string;
658
- }
659
- /**
660
- * interface: `UserInvitePayload`
661
- * - user:invite request payload
662
- */
663
- export interface UserInvitePayload extends WSSPayload {
664
- /** (optional) target channel id */
665
- channelId?: string;
666
- /** user name to invite */
667
- name: string;
668
- /** user phone to invite */
669
- phone: string;
670
- }
671
- /**
672
- * interface: `UserUpdateProfilePayload`
673
- * - user:update-profile request payload
674
- */
675
- export interface UserUpdateProfilePayload extends WSSPayload {
676
- /** name */
677
- name?: string;
678
- /** nick */
679
- nick?: string;
680
- /** thumbnail image (base64 encoded) */
681
- thumbnail?: string;
682
- }
683
- /**
684
- * interface: `UserUpdateSitePayload`
685
- * - user:update-site request payload
686
- * - 주의) sid 없으면 현재 세션의 sid로 요청됨!
687
- */
688
- export interface UserUpdateSitePayload extends WSSPayload {
689
- /** target site-id */
690
- sid?: string;
691
- /** name */
692
- name?: string;
693
- /** thumbnail image (base64 encoded) */
694
- thumbnail?: string;
695
- }
696
- export default $LUT;