@lemoncloud/chatic-sockets-api 0.26.403 → 0.26.517

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,698 +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
- /** get-self - get or create personal channel */
254
- 'get-self': string;
255
- /** error - error response */
256
- error: string;
257
- };
258
- /**
259
- * UserActionType
260
- * - user domain actions
261
- */
262
- UserActionType: {
263
- '': string;
264
- /** invite: 유저초대 */
265
- invite: string;
266
- /** my-site: 접근 가능 사이트 목록 조회 */
267
- 'my-site': string;
268
- /** make-site: 사이트 생성 */
269
- 'make-site': string;
270
- /** update-profile: 프로필 수정 */
271
- 'update-profile': string;
272
- /** update-site: 플레이스 수정 */
273
- 'update-site': string;
274
- /** error - error response */
275
- error: string;
276
- };
277
- /**
278
- * ClientStatusType
279
- */
280
- ClientStatusType: {
281
- '': string;
282
- /** green - online */
283
- green: string;
284
- /** red - offline */
285
- red: string;
286
- /** yellow - away/idle */
287
- yellow: string;
288
- };
289
- };
290
- /**
291
- * type: `WSSEventType
292
- */
293
- export declare type WSSEventType = keyof typeof $LUT.EventType;
294
- /**
295
- * type: `WSSRouteKeyType
296
- */
297
- export declare type WSSRouteKeyType = keyof typeof $LUT.RouteKeyType;
298
- /**
299
- * type: `WSSDirectionType
300
- */
301
- export declare type WSSDirectionType = keyof typeof $LUT.DirectionType;
302
- /**
303
- * type: `WSSDisconnectStatusCode
304
- */
305
- export declare type WSSDisconnectStatusCode = keyof typeof $LUT.DisconnectStatusCode;
306
- /**
307
- * type: `WSSStageType
308
- */
309
- export declare type WSSStageType = keyof typeof $LUT.StageType;
310
- /**
311
- * type: `WSSEventDomainType
312
- */
313
- export declare type WSSEventDomainType = keyof typeof $LUT.EventDomainType;
314
- /**
315
- * type: `WSSSystemActionType
316
- */
317
- export declare type WSSSystemActionType = keyof typeof $LUT.SystemActionType;
318
- /**
319
- * type: `WSSModelActionType
320
- */
321
- export declare type WSSModelActionType = keyof typeof $LUT.ModelActionType;
322
- /**
323
- * type: `WSSSyncActionType`
324
- */
325
- export declare type WSSSyncActionType = keyof typeof $LUT.SyncActionType;
326
- /**
327
- * type: `WSSAuthActionType`
328
- */
329
- export declare type WSSAuthActionType = keyof typeof $LUT.AuthActionType;
330
- /**
331
- * type: `WSSChannelActionType`
332
- */
333
- export declare type WSSChannelActionType = keyof typeof $LUT.ChannelActionType;
334
- /**
335
- * type: `WSSChatActionType`
336
- */
337
- export declare type WSSChatActionType = keyof typeof $LUT.ChatActionType;
338
- /**
339
- * type: `WSSUserActionType`
340
- */
341
- export declare type WSSUserActionType = keyof typeof $LUT.UserActionType;
342
- /**
343
- * type: `ClientStatusType`
344
- */
345
- export declare type ClientStatusType = keyof typeof $LUT.ClientStatusType;
346
- /**
347
- * type: `WSSActionType`
348
- */
349
- export declare type WSSActionType = WSSSystemActionType | WSSModelActionType | WSSSyncActionType | WSSAuthActionType | WSSChannelActionType | WSSChatActionType | WSSUserActionType;
350
- /**
351
- * interface: `WSSConnectParam`
352
- */
353
- export interface WSSConnectParam {
354
- /** get connection info after connect */
355
- info?: string | boolean;
356
- /** trigger auth event on connect (token if string) */
357
- auth?: string | boolean;
358
- /** join default channel */
359
- default?: string | boolean;
360
- /** use notify queue */
361
- notify?: string | boolean;
362
- /** (test) throw error */
363
- throws?: string;
364
- /** channel ids to subscribe */
365
- channels?: string[];
366
- /** device-id */
367
- deviceId?: string;
368
- /** device-name */
369
- deviceName?: string;
370
- }
371
- /**
372
- * interface: `WSSEnvelope`
373
- * - 양방향 WebSocket 통신 메시지 봉투
374
- */
375
- export interface WSSEnvelope<T = any> {
376
- /** event domain */
377
- type: WSSEventDomainType;
378
- /** action within domain */
379
- action: WSSActionType;
380
- /** (optional) payload data */
381
- payload?: T;
382
- /** (optional) message-id (for Server) */
383
- mid?: string;
384
- /** (optional) meta data (for Server) */
385
- meta?: WSSMeta;
386
- /** (internal) target user-ids for broadcast (only for server.) */
387
- userIds?: string[];
388
- }
389
- /**
390
- * interface: `WSSMeta`
391
- * - 메시지 메타데이터
392
- */
393
- export interface WSSMeta {
394
- /** timestamp (ms) */
395
- ts: number;
396
- /** sequence number */
397
- seq?: number;
398
- /** target channel */
399
- channel?: string;
400
- /** reference-id (for ack) */
401
- ref?: string;
402
- }
403
- /**
404
- * interface: `WSSPayload`
405
- * - base payload
406
- */
407
- export interface WSSPayload {
408
- /** payload-id */
409
- id?: string;
410
- /** reference id (for ack) */
411
- ref?: string;
412
- }
413
- /**
414
- * interface: `SystemPayload`
415
- * - system domain payload
416
- */
417
- export interface SystemPayload extends WSSPayload {
418
- /** content */
419
- content?: string;
420
- /** ping-pong count */
421
- count?: number;
422
- }
423
- /**
424
- * interface: `ClientSyncPayload`
425
- * - client sync domain payload
426
- */
427
- export interface ClientSyncPayload extends WSSPayload {
428
- /**
429
- * tick count (from Server)
430
- * 1. [Client] sends its current tick(Payload) to Server ONLY if tick is changed.
431
- * 2. [Server] compares Client.tick with its own tick:
432
- * - if equal, no action needed (Client is in sync)
433
- * - if different, Server responds with updated state and its current tick
434
- *
435
- * NOTE 주의! 무한 핑/퐁
436
- */
437
- tick: number;
438
- /** x position (for Client) */
439
- posX: number;
440
- /** y position (for Client) */
441
- posY: number;
442
- /** (optional) client timestamp (ms) */
443
- ts?: number;
444
- /**
445
- * ONLY for Client.
446
- * - status indicator
447
- */
448
- status: ClientStatusType;
449
- }
450
- /**
451
- * interface: `ModelSyncPayload`
452
- * - model sync domain payload
453
- * - only for Server
454
- */
455
- export interface ModelSyncPayload extends WSSPayload {
456
- /** id of model */
457
- sourceId?: string;
458
- /** type of model */
459
- sourceType?: string;
460
- /** service of source */
461
- service?: string;
462
- /** sid of model */
463
- sid?: string;
464
- /** uid of model */
465
- uid?: string;
466
- /** gid of model */
467
- gid?: string;
468
- /** oid of model (owner) */
469
- oid?: string;
470
- }
471
- /**
472
- * interface: `AuthPayload`
473
- * - auth domain payload for bidirectional communication
474
- */
475
- export interface AuthPayload extends WSSPayload {
476
- /** [Client] JWT token (issued by main backend) */
477
- token?: string;
478
- /** dry-run execution flag */
479
- dryRun?: boolean;
480
- /** [Server] current auth state */
481
- state?: AuthState;
482
- /** [Server] state transition timestamp */
483
- stateAt?: number;
484
- /** [Server] internal error */
485
- error?: string;
486
- /** (internal) authed conn-id */
487
- connId?: string;
488
- /** (internal) authed device-id */
489
- deviceId?: string;
490
- /** (internal) authed auth-id */
491
- authId?: string;
492
- /** (internal) authed member-id */
493
- memberId?: string;
494
- /** [Server] member info on success */
495
- readonly member$?: UserHead;
496
- }
497
- /**
498
- * interface: `ChannelPayload`
499
- * - channel domain payload for subscribe/unsubscribe
500
- */
501
- export interface ChannelPayload extends WSSPayload {
502
- /** [Client] channel ids to subscribe/unsubscribe */
503
- channels?: string[];
504
- /** [Server] channel ids successfully subscribed */
505
- subscribed?: string[];
506
- /** [Server] channel ids successfully unsubscribed */
507
- unsubscribed?: string[];
508
- }
509
- /**
510
- * interface: `ChatSendPayload`
511
- * - chat:send request payload
512
- */
513
- export interface ChatSendPayload extends WSSPayload {
514
- /** target channel id */
515
- channelId: string;
516
- /** message content */
517
- content: string;
518
- /** message type (default: "text") */
519
- contentType?: string;
520
- /** thread/reply parent id */
521
- parentId?: string;
522
- }
523
- /**
524
- * interface: `ChatReadPayload`
525
- * - chat:read request payload
526
- */
527
- export interface ChatReadPayload extends WSSPayload {
528
- /** target channel id */
529
- channelId: string;
530
- /** last read chat number (>= 1) */
531
- chatNo: number;
532
- }
533
- /**
534
- * interface: `ChatErrorPayload`
535
- * - chat:error response payload
536
- */
537
- export interface ChatErrorPayload extends WSSPayload {
538
- /** error message */
539
- error: string;
540
- }
541
- /**
542
- * interface: `ChatStartPayload`
543
- * - chat:start request payload
544
- */
545
- export interface ChatStartPayload extends WSSPayload {
546
- /** channel type: dm, self, public, private */
547
- stereo: 'dm' | 'self' | 'public' | 'private';
548
- /** channel name */
549
- name?: string;
550
- /** user ids to invite (excluding self) */
551
- userIds?: string[];
552
- /** first message content */
553
- content?: string;
554
- /** message type (default: "text") */
555
- contentType?: string;
556
- }
557
- /**
558
- * interface: `ChatFeedPayload`
559
- * - chat:feed request payload
560
- */
561
- export interface ChatFeedPayload extends WSSPayload {
562
- /** target channel id */
563
- channelId: string;
564
- /** cursor: fetch chatNo < cursorNo (exclusive upper bound) */
565
- cursorNo?: number;
566
- /** page size (default 20) */
567
- limit?: number;
568
- }
569
- /**
570
- * interface: `ChatMinePayload`
571
- * - chat:mine request payload
572
- */
573
- export interface ChatMinePayload extends WSSPayload {
574
- /** page size (default 5) */
575
- limit?: number;
576
- /** page number (default 0) */
577
- page?: number;
578
- /** include detail */
579
- detail?: boolean;
580
- }
581
- /**
582
- * interface: `ChatUsersPayload`
583
- * - chat:users request payload
584
- */
585
- export interface ChatUsersPayload extends WSSPayload {
586
- /** target channel id */
587
- channelId: string;
588
- /** page size (default 5) */
589
- limit?: number;
590
- /** page number (default 0) */
591
- page?: number;
592
- /** include detail */
593
- detail?: boolean;
594
- }
595
- /**
596
- * interface: `ChatInvitePayload`
597
- * - chat:invite request payload
598
- */
599
- export interface ChatInvitePayload extends WSSPayload {
600
- /** target channel id */
601
- channelId: string;
602
- /** user ids to invite */
603
- userIds: string[];
604
- }
605
- /**
606
- * interface: `ChatLeavePayload`
607
- * - chat:leave request payload
608
- */
609
- export interface ChatLeavePayload extends WSSPayload {
610
- /** target channel id */
611
- channelId: string;
612
- /** kick target user id (omit for self-leave) */
613
- userId?: string;
614
- /** kick reason */
615
- reason?: string;
616
- }
617
- /**
618
- * interface: `ChatUpdateChannelPayload`
619
- * - chat:update-channel request payload
620
- */
621
- export interface ChatUpdateChannelPayload extends WSSPayload {
622
- /** target channel id */
623
- channelId: string;
624
- /** channel name */
625
- name?: string;
626
- /** channel description */
627
- desc?: string;
628
- /** channel stereo */
629
- stereo?: '' | 'dm' | 'self' | 'public' | 'private';
630
- /** invite rule */
631
- inviteRule?: '' | 'owner' | 'all';
632
- }
633
- /**
634
- * interface: `ChatUpdateJoinPayload`
635
- * - chat:update-join request payload
636
- */
637
- export interface ChatUpdateJoinPayload extends WSSPayload {
638
- /** target channel id (joinId = channelId@userId, userId from conn.uid) */
639
- channelId: string;
640
- /** nick name in channel */
641
- nick?: string;
642
- /** notification setting */
643
- notify?: '' | 'all' | 'mention' | 'none';
644
- }
645
- /**
646
- * interface: `ChatDeleteChannelPayload`
647
- * - chat:delete-channel request payload
648
- */
649
- export interface ChatDeleteChannelPayload extends WSSPayload {
650
- /** target channel id */
651
- channelId: string;
652
- }
653
- /**
654
- * interface: `UserMakeSitePayload`
655
- * - user:make-site request payload
656
- */
657
- export interface UserMakeSitePayload extends WSSPayload {
658
- /** place name */
659
- name: string;
660
- }
661
- /**
662
- * interface: `UserInvitePayload`
663
- * - user:invite request payload
664
- */
665
- export interface UserInvitePayload extends WSSPayload {
666
- /** (optional) target channel id */
667
- channelId?: string;
668
- /** user name to invite */
669
- name: string;
670
- /** user phone to invite */
671
- phone: string;
672
- }
673
- /**
674
- * interface: `UserUpdateProfilePayload`
675
- * - user:update-profile request payload
676
- */
677
- export interface UserUpdateProfilePayload extends WSSPayload {
678
- /** name */
679
- name?: string;
680
- /** nick */
681
- nick?: string;
682
- /** thumbnail image (base64 encoded) */
683
- thumbnail?: string;
684
- }
685
- /**
686
- * interface: `UserUpdateSitePayload`
687
- * - user:update-site request payload
688
- * - 주의) sid 없으면 현재 세션의 sid로 요청됨!
689
- */
690
- export interface UserUpdateSitePayload extends WSSPayload {
691
- /** target site-id */
692
- sid?: string;
693
- /** name */
694
- name?: string;
695
- /** thumbnail image (base64 encoded) */
696
- thumbnail?: string;
697
- }
698
- export default $LUT;