@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.
@@ -0,0 +1,38 @@
1
+ export declare const fieldKeys: {
2
+ readonly authHead: <T extends object>() => Extract<keyof T, string>[];
3
+ readonly authModel: <T_1 extends object>() => Extract<keyof T_1, string>[];
4
+ readonly authTransformerModel: <T_2 extends object>() => Extract<keyof T_2, string>[];
5
+ readonly callbackHead: <T_3 extends object>() => Extract<keyof T_3, string>[];
6
+ readonly callbackModel: <T_4 extends object>() => Extract<keyof T_4, string>[];
7
+ readonly callbackServiceModel: <T_5 extends object>() => Extract<keyof T_5, string>[];
8
+ readonly callbackTransformerModel: <T_6 extends object>() => Extract<keyof T_6, string>[];
9
+ readonly channelHead: <T_7 extends object>() => Extract<keyof T_7, string>[];
10
+ readonly channelModel: <T_8 extends object>() => Extract<keyof T_8, string>[];
11
+ readonly chatModel: <T_9 extends object>() => Extract<keyof T_9, string>[];
12
+ readonly connectionModel: <T_10 extends object>() => Extract<keyof T_10, string>[];
13
+ readonly coreModel: <T_11 extends object>() => Extract<keyof T_11, string>[];
14
+ readonly deviceHead: <T_12 extends object>() => Extract<keyof T_12, string>[];
15
+ readonly deviceModel: <T_13 extends object>() => Extract<keyof T_13, string>[];
16
+ readonly joinModel: <T_14 extends object>() => Extract<keyof T_14, string>[];
17
+ readonly mockHead: <T_15 extends object>() => Extract<keyof T_15, string>[];
18
+ readonly mockModel: <T_16 extends object>() => Extract<keyof T_16, string>[];
19
+ readonly mockTestModel: <T_17 extends object>() => Extract<keyof T_17, string>[];
20
+ readonly mockTransformerModel: <T_18 extends object>() => Extract<keyof T_18, string>[];
21
+ readonly searchBatchModel: <T_19 extends object>() => Extract<keyof T_19, string>[];
22
+ readonly searchModel: <T_20 extends object>() => Extract<keyof T_20, string>[];
23
+ readonly searchQueryModel: <T_21 extends object>() => Extract<keyof T_21, string>[];
24
+ readonly socketModel: <T_22 extends object>() => Extract<keyof T_22, string>[];
25
+ readonly socketsTransformerModel: <T_23 extends object>() => Extract<keyof T_23, string>[];
26
+ readonly testHead: <T_24 extends object>() => Extract<keyof T_24, string>[];
27
+ readonly testModel: <T_25 extends object>() => Extract<keyof T_25, string>[];
28
+ readonly userHead: <T_26 extends object>() => Extract<keyof T_26, string>[];
29
+ readonly userModel: <T_27 extends object>() => Extract<keyof T_27, string>[];
30
+ readonly viewTransformerModel: <T_28 extends object>() => Extract<keyof T_28, string>[];
31
+ };
32
+ export declare const fieldRegistryMeta: {
33
+ readonly kind: "concrete";
34
+ readonly schemaVersion: 1;
35
+ readonly entryCount: 29;
36
+ readonly checksum: "cfe99591dae6d229";
37
+ readonly generatedBy: "lemon-fields";
38
+ };
@@ -0,0 +1,107 @@
1
+ /**
2
+ * `lib/broadcast/types.ts`
3
+ * - broadcast engine 공개 계약 — `DomainEvent` 와 내부 전달 타입.
4
+ */
5
+ import type { ConnectionModel, DeviceModel } from '../../modules/sockets/model';
6
+ /**
7
+ * interface: `DomainEvent`
8
+ * - CDC가 감지한 도메인 사실 1건 — 분류·렌더가 끝난 상태로 발행됨.
9
+ */
10
+ export interface DomainEvent<T = unknown> {
11
+ /** 멱등성 키 — Producer가 결정적으로 파생(재시도마다 동일). 생략 시 ingress가 생성 → 재시도 dedupe 불가 */
12
+ id?: string;
13
+ /** 계층형 시맨틱 타입 — 클라 핸들러 라우팅 키 (`chat.message.created` ...) */
14
+ type: string;
15
+ /** 발생 출처 서비스 */
16
+ source: string;
17
+ /** 이벤트 발생 시각 (epoch ms) — 메타데이터, 순서 보장 기준 아님 */
18
+ ts: number;
19
+ /** data 스키마 버전 */
20
+ version: number;
21
+ /** 행위자 */
22
+ actor?: string;
23
+ /** 관련 리소스 (`channel:C1`) */
24
+ subject: string;
25
+ /** ── the WHAT ── 일어난 일의 데이터, 클라에 그대로 전달됨 */
26
+ data: T;
27
+ /** ── the HOW ── 전달 지시 (producer가 덧붙인 라우팅 메타데이터, Engine 대상) */
28
+ broadcast: BroadcastDirective;
29
+ }
30
+ /** producer가 덧붙이는 전달 지시 */
31
+ export interface BroadcastDirective {
32
+ /** 수신 대상 — 도메인 식별자, 해석은 Engine */
33
+ audience: BroadcastAudience;
34
+ /** push 알림 — 있으면 push leg 실행. 엔진은 `data`를 해석하지 않고 push 서비스로 verbatim 전달 */
35
+ push?: PushPayload;
36
+ /** 제외 대상 */
37
+ exclude?: BroadcastExclude;
38
+ }
39
+ export declare type BroadcastAudience = {
40
+ type: 'channel';
41
+ channelId: string;
42
+ } | {
43
+ type: 'users';
44
+ userIds: string[];
45
+ }
46
+ /** 저수준 — deviceIds 직접 지정 (channel/users 해석 생략) */
47
+ | {
48
+ type: 'devices';
49
+ deviceIds: string[];
50
+ };
51
+ /**
52
+ * push 알림 payload.
53
+ * - localization 봉투(`*_loc_key`/`loc_args`/`link`/`type`/`silent`)는 APNs·FCM 표준 기반 **푸시 공용 인터페이스** — 엔진이 타입으로 안다.
54
+ * - `data`만 도메인별이라 `TData` 제네릭으로 열어 둔다 — 엔진은 `data`를 해석하지 않고 verbatim 전달.
55
+ * - 실제 발송 계약은 push 서비스(`chatic-pushes-api`)의 `ChaticPushPayload`. 의존성 결합을 피하려 엔진이 별도 선언한다.
56
+ */
57
+ export interface PushPayload<TData = any> {
58
+ /** notification title localization key */
59
+ title_loc_key?: string;
60
+ /** title localization arguments */
61
+ title_loc_args?: string[];
62
+ /** notification body localization key */
63
+ loc_key?: string;
64
+ /** body localization arguments */
65
+ loc_args?: string[];
66
+ /** app deep link (e.g. `channel?channelId=<channelId>`) */
67
+ link?: string;
68
+ /** domain event type — required */
69
+ type: string;
70
+ /** silent/background notification flag */
71
+ silent?: boolean;
72
+ /** custom app data — 도메인별, 엔진은 해석하지 않음 */
73
+ data: TData;
74
+ }
75
+ export interface BroadcastExclude {
76
+ userIds?: string[];
77
+ deviceIds?: string[];
78
+ connIds?: string[];
79
+ }
80
+ /** 클라이언트가 WS로 받는 공개 페이로드 — `broadcast` 메타데이터 제외 */
81
+ export declare type PublicEvent<T = unknown> = Omit<DomainEvent<T>, 'broadcast'>;
82
+ /** audience 해석 결과 1건 — device + (활성일 때만) connection */
83
+ export interface BroadcastRecipient {
84
+ device: DeviceModel;
85
+ /** 활성 커넥션 — 없으면 offline (WS 불가) */
86
+ connection?: ConnectionModel;
87
+ }
88
+ export interface BroadcastPushResult {
89
+ sent: number;
90
+ failed: number;
91
+ skipped: number;
92
+ }
93
+ /**
94
+ * interface: `BroadcastResult`
95
+ * - fan-out 결과 집계.
96
+ */
97
+ export interface BroadcastResult {
98
+ /** audience 해석된 대상 device 총수 */
99
+ total: number;
100
+ /** 등록 정보를 못 찾아 제외된 device 수 */
101
+ missing: number;
102
+ ws: {
103
+ sent: number;
104
+ failed: number;
105
+ };
106
+ push: BroadcastPushResult;
107
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * `lib/types.ts`
3
+ * - shared socket packet contracts for both server and client.
4
+ *
5
+ * RULES
6
+ * - every new socket packet type must be registered here first.
7
+ * - `SocketMessage<T>` payload usage must be derived from this file.
8
+ * - server/client code should treat this file as the source of truth for packet shapes.
9
+ */
10
+ /**
11
+ * common socket message metadata.
12
+ */
13
+ export interface SocketMessageMeta {
14
+ /** timestamp (ms) */
15
+ ts: number;
16
+ /** extensible metadata bag */
17
+ [key: string]: unknown;
18
+ }
19
+ /**
20
+ * base socket message envelope.
21
+ */
22
+ export interface SocketMessage<T = any, TType extends string = string> {
23
+ /** message type like `system.ping`, `system.ping:ok`, `system.ping:error` */
24
+ type: TType;
25
+ /** payload data */
26
+ data: T | null;
27
+ /** request-response correlation id */
28
+ mid?: string;
29
+ /** optional metadata */
30
+ meta?: SocketMessageMeta;
31
+ /** optional error message */
32
+ error?: string;
33
+ }
34
+ /**
35
+ * shared packet registry extension point.
36
+ *
37
+ * NOTE
38
+ * - keep only the base contract here.
39
+ * - each `src/lib/<domain>/types.ts` can extend this registry via module augmentation.
40
+ * - response types `:ok` / `:error` are derived from the merged registry.
41
+ */
42
+ export interface SocketPacketRegistry {
43
+ }
44
+ /**
45
+ * shorthand alias extension point.
46
+ * - domain folders can add aliases via module augmentation.
47
+ */
48
+ export interface SocketPacketAliasRegistry {
49
+ }
50
+ /**
51
+ * registered request packet type.
52
+ */
53
+ export declare type SocketPacketType = Extract<keyof SocketPacketRegistry, string>;
54
+ /**
55
+ * request input type before canonical normalization.
56
+ */
57
+ export declare type SocketPacketInputType = SocketPacketType | Extract<keyof SocketPacketAliasRegistry, string>;
58
+ /**
59
+ * resolve shorthand input into canonical packet type.
60
+ */
61
+ export declare type ResolveSocketPacketType<TType extends SocketPacketInputType> = TType extends keyof SocketPacketAliasRegistry ? SocketPacketAliasRegistry[TType] : TType;
62
+ /**
63
+ * packet status suffix.
64
+ */
65
+ export declare type SocketPacketStatus = 'request' | 'ok' | 'error';
66
+ /**
67
+ * derived success response type.
68
+ */
69
+ export declare type SocketPacketOkType<TType extends SocketPacketType = SocketPacketType> = `${TType}:ok`;
70
+ /**
71
+ * derived error response type.
72
+ */
73
+ export declare type SocketPacketErrorType<TType extends SocketPacketType = SocketPacketType> = `${TType}:error`;
74
+ /**
75
+ * union of all request/response packet type strings.
76
+ */
77
+ export declare type SocketMessageType<TType extends SocketPacketType = SocketPacketType> = TType | SocketPacketOkType<TType> | SocketPacketErrorType<TType>;
78
+ /**
79
+ * request payload of a registered packet.
80
+ */
81
+ export declare type SocketPacketRequestData<TType extends SocketPacketType> = SocketPacketRegistry[TType]['request'];
82
+ /**
83
+ * success payload of a registered packet.
84
+ */
85
+ export declare type SocketPacketResponseData<TType extends SocketPacketType> = SocketPacketRegistry[TType]['response'];
86
+ /**
87
+ * error payload of a registered packet.
88
+ */
89
+ export declare type SocketPacketErrorData<TType extends SocketPacketType> = SocketPacketRegistry[TType]['error'];
90
+ /**
91
+ * typed request message.
92
+ */
93
+ export declare type SocketRequestMessage<TType extends SocketPacketType = SocketPacketType> = SocketMessage<SocketPacketRequestData<TType>, TType>;
94
+ /**
95
+ * typed success message.
96
+ */
97
+ export declare type SocketResponseMessage<TType extends SocketPacketType = SocketPacketType> = SocketMessage<SocketPacketResponseData<TType>, SocketPacketOkType<TType>>;
98
+ /**
99
+ * typed error message.
100
+ */
101
+ export declare type SocketErrorMessage<TType extends SocketPacketType = SocketPacketType> = SocketMessage<SocketPacketErrorData<TType>, SocketPacketErrorType<TType>>;
102
+ /**
103
+ * helper to infer request payload from packet type.
104
+ */
105
+ export declare type InferSocketRequest<TType extends SocketPacketType> = SocketPacketRequestData<TType>;
106
+ /**
107
+ * helper to infer success payload from packet type.
108
+ */
109
+ export declare type InferSocketResponse<TType extends SocketPacketType> = SocketPacketResponseData<TType>;
110
+ /**
111
+ * helper to infer error payload from packet type.
112
+ */
113
+ export declare type InferSocketError<TType extends SocketPacketType> = SocketPacketErrorData<TType>;
114
+ /**
115
+ * optional normalized error shape for higher-level usage.
116
+ * - transport still uses `SocketMessage.error` as the primary field.
117
+ */
118
+ export interface SocketErrorShape {
119
+ message: string;
120
+ code?: string;
121
+ retryable?: boolean;
122
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * `sockets.ts`
3
+ * - basic definitions for supporting web-socket w/ AWS API Gateway + Lambda.
4
+ *
5
+ * @author Steve <steve@lemoncloud.io>
6
+ * @date 2026-05-06 refactoring for v2 support.
7
+ *
8
+ * @copyright (C) 2026 LemonCloud Co Ltd. - All Rights Reserved.
9
+ */
10
+ import { NextContext, NextIdentity } from 'lemon-model';
11
+ export type { NextContext };
12
+ export * from '../lib/types';
13
+ /**
14
+ * interface: `ConnectionInfo`
15
+ * - 연결 정보 공통 모델
16
+ */
17
+ export interface ConnectionInfo {
18
+ /** stage of api-gateway */
19
+ stage?: string;
20
+ /** connected domain */
21
+ domain?: string;
22
+ /** api-gateway id */
23
+ apiId?: string;
24
+ /** (optional) id as decoded from `connectionId` */
25
+ conId?: string;
26
+ /** (original) connection-id */
27
+ connectionId?: string;
28
+ /** (optional) user-agent */
29
+ userAgent?: string;
30
+ }
31
+ /**
32
+ * interface: `ConnectionIdentity`
33
+ * - common idenity with socket event.
34
+ */
35
+ export interface ConnectionIdentity extends NextIdentity, ConnectionInfo {
36
+ }
37
+ /**
38
+ * type: `WSSEventType
39
+ */
40
+ export declare type SocketEventType = '' | 'CONNECT' | 'DISCONNECT' | 'MESSAGE';
41
+ /**
42
+ * type: `SocketRouteKeyType`
43
+ * - must be matched with `sls/functions.socket.events.websocket.route`
44
+ */
45
+ export declare type SocketRouteKeyType = '$connect' | '$disconnect' | '$default' | 'echo';
46
+ /**
47
+ * type: `SocketStageType`
48
+ * - stage in API GW
49
+ */
50
+ export declare type SocketStageType = '' | 'dev' | 'prod' | 'local';
51
+ export declare type SocketDirectionType = '' | 'IN' | 'OUT';
52
+ /**
53
+ * interface: `SocketEvent`
54
+ * - Lambda에서 수신하는 WebSocket 이벤트 (Raw Level)
55
+ */
56
+ export interface SocketEvent<TBody = any> extends ConnectionInfo {
57
+ /** request-id */
58
+ id: string;
59
+ /** major type of event */
60
+ type: SocketEventType;
61
+ /** router-key from api-gateway */
62
+ route: SocketRouteKeyType;
63
+ /** known as Headr[Authorization] */
64
+ authorization?: string;
65
+ /** stage in api-gw */
66
+ stage: SocketStageType;
67
+ /** socket direction */
68
+ direction: SocketDirectionType;
69
+ /** code of disconnection */
70
+ disconnectCode?: number;
71
+ /** known as disconnectReason */
72
+ reason?: string;
73
+ /** known as Header[Origin] */
74
+ origin?: string;
75
+ /** known as Header[User-Agent] */
76
+ agent: string;
77
+ /** socket message-id */
78
+ messageId: string;
79
+ /**
80
+ * the original base64-encoded string (ex: c8OGXcpSIE0CJuQ=)
81
+ */
82
+ connectionId: string;
83
+ /** connectedAt (ts) */
84
+ connectedAt: number;
85
+ /** known as ClientIp */
86
+ remote: string;
87
+ /** query parameters */
88
+ param: {
89
+ [key: string]: string;
90
+ };
91
+ /** body payload in string */
92
+ body?: TBody;
93
+ }
94
+ /**
95
+ * type: `SocketEventAgent`
96
+ * - interface for handling WebSocket events.
97
+ */
98
+ export interface SocketEventAgent<T = ConnectionIdentity> {
99
+ /**
100
+ * Handle incoming WebSocket events.
101
+ *
102
+ * @param event SocketEvent - the socket event in lambda
103
+ * @param context NextContext - the current request's context.
104
+ * */
105
+ onSocketEvent(event: SocketEvent, context: NextContext<T>): Promise<any>;
106
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * `model.ts`
3
+ * - model definitions for chat module.
4
+ */
5
+ import { CoreModel } from 'lemon-model';
6
+ import $LUT, { ChannelStereo, ChatStereo, JoinStereo } from './types';
7
+ /**
8
+ * type: `ModelType`
9
+ */
10
+ export declare type ModelType = keyof typeof $LUT.ModelType;
11
+ /**
12
+ * type: `Model`: common model
13
+ */
14
+ export declare type Model = CoreModel<ModelType>;
15
+ /**
16
+ * interface: `ChannelHead`
17
+ */
18
+ export interface ChannelHead {
19
+ /** id of channel */
20
+ id?: string;
21
+ /** name of channel */
22
+ name?: string;
23
+ }
24
+ /**
25
+ * interface: `ChannelModel`
26
+ * - chat room state.
27
+ */
28
+ export interface ChannelModel extends Model, ChannelHead {
29
+ /** id of model */
30
+ id?: string;
31
+ /** name of channel */
32
+ name?: string;
33
+ /** channel stereo */
34
+ stereo?: ChannelStereo;
35
+ /** optional description */
36
+ desc?: string;
37
+ /** owner id (P1 uses deviceId) */
38
+ ownerId?: string;
39
+ /** last chat sequence in this channel */
40
+ chatNo?: number;
41
+ /** joined device ids */
42
+ memberIds?: string[];
43
+ }
44
+ /**
45
+ * interface: `ChatModel`
46
+ * - message or channel event.
47
+ */
48
+ export interface ChatModel extends Model {
49
+ /** id = `${channelId}:${chatNo}` */
50
+ id?: string;
51
+ /** chat event kind */
52
+ stereo?: ChatStereo;
53
+ /** channel-local sequence */
54
+ chatNo?: number;
55
+ /** message content */
56
+ content?: string;
57
+ /** message content type. v1 only uses text. */
58
+ contentType?: string;
59
+ /** parent channel id */
60
+ channelId?: string;
61
+ /** owner id. v1 uses deviceId. */
62
+ ownerId?: string;
63
+ }
64
+ /**
65
+ * interface: `JoinModel`
66
+ * - channel membership and read cursor.
67
+ */
68
+ export interface JoinModel extends Model {
69
+ /** id = `${channelId}:${ownerId}` */
70
+ id?: string;
71
+ /** join stereo. v1 only uses empty string. */
72
+ stereo?: JoinStereo;
73
+ /** joined channel id */
74
+ channelId?: string;
75
+ /** owner id. v1 uses deviceId. */
76
+ ownerId?: string;
77
+ /** last read chat sequence */
78
+ chatNo?: number;
79
+ /** current joined state. 1 = joined, 0 = left. */
80
+ joined?: number;
81
+ }
82
+ /**
83
+ * extract field names from models
84
+ * - only fields start with lowercase, or all upper.
85
+ */
86
+ export declare const filterFields: (fields: string[], base?: string[]) => string[];
87
+ /** field names from head */
88
+ export declare const $HEAD: {
89
+ channel: string[];
90
+ };
91
+ export declare const $FIELD: {
92
+ channel: string[];
93
+ chat: string[];
94
+ join: string[];
95
+ };
96
+ /** must export default as below */
97
+ declare const _default: {
98
+ $HEAD: {
99
+ channel: string[];
100
+ };
101
+ $FIELD: {
102
+ channel: string[];
103
+ chat: string[];
104
+ join: string[];
105
+ };
106
+ };
107
+ export default _default;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * `types.ts`
3
+ * - basic types for chat module.
4
+ */
5
+ /**
6
+ * Lookup Table
7
+ *
8
+ * WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
9
+ */
10
+ declare const $LUT: {
11
+ /**
12
+ * Possible type of model.
13
+ */
14
+ ModelType: {
15
+ /** channel model */
16
+ channel: string;
17
+ /** chat model */
18
+ chat: string;
19
+ /** join model */
20
+ join: string;
21
+ };
22
+ /**
23
+ * ChannelStereo
24
+ */
25
+ ChannelStereo: {
26
+ '': string;
27
+ /** direct message (1:1) */
28
+ dm: string;
29
+ /** self memo channel */
30
+ self: string;
31
+ /** open channel */
32
+ public: string;
33
+ /** invite-only channel */
34
+ private: string;
35
+ };
36
+ /**
37
+ * ChatStereo
38
+ */
39
+ ChatStereo: {
40
+ text: string;
41
+ join: string;
42
+ leave: string;
43
+ system: string;
44
+ };
45
+ /**
46
+ * JoinStereo
47
+ */
48
+ JoinStereo: {
49
+ '': string;
50
+ };
51
+ };
52
+ /**
53
+ * type: `ChannelStereo`
54
+ */
55
+ export declare type ChannelStereo = keyof typeof $LUT.ChannelStereo;
56
+ /**
57
+ * type: `ChatStereo`
58
+ */
59
+ export declare type ChatStereo = keyof typeof $LUT.ChatStereo;
60
+ /**
61
+ * type: `JoinStereo`
62
+ */
63
+ export declare type JoinStereo = keyof typeof $LUT.JoinStereo;
64
+ /** must export $LUT as default */
65
+ export default $LUT;
@@ -63,6 +63,11 @@ export interface TestModel extends Model, TestHead {
63
63
  count?: number;
64
64
  /** (optional) extra */
65
65
  extra?: SimpleSet;
66
+ /**
67
+ * string array for test of array set
68
+ * test for inc() method.
69
+ */
70
+ strings?: string[];
66
71
  /**
67
72
  * inner Object.
68
73
  */
@@ -10,7 +10,8 @@
10
10
  * Copyright (C) 2022 LemonCloud Co Ltd. - All Rights Reserved.
11
11
  */
12
12
  import { CoreModel } from 'lemon-model';
13
- import $LUT, { ChannelStereo, DevicePlatform, DeviceStatus } from './types';
13
+ import $LUT, { DevicePlatform, DeviceStatus } from './types';
14
+ import type { ChannelHead } from '../chat/model';
14
15
  /**
15
16
  * type: `ModelType`
16
17
  */
@@ -64,6 +65,10 @@ export interface ConnectionModel extends Model {
64
65
  connectedAt?: number;
65
66
  /** (internal) Timestamp when the connection was terminated. */
66
67
  disConnectedAt?: number;
68
+ /** (internal) version no */
69
+ versionNo?: number;
70
+ /** (internal) tracking no */
71
+ no?: number;
67
72
  /**
68
73
  * (extended) The origin of the request.
69
74
  */
@@ -94,6 +99,8 @@ export interface ConnectionModel extends Model {
94
99
  readonly count?: number;
95
100
  /**
96
101
  * (linked) 현재 연결이 구독 중인 채널(토픽) ID 목록
102
+ *
103
+ * @deprecated no more supported (see `chatic-socials-api`)
97
104
  */
98
105
  channels?: string[];
99
106
  /**
@@ -102,6 +109,9 @@ export interface ConnectionModel extends Model {
102
109
  channel$$?: ChannelHead[];
103
110
  /**
104
111
  * (linked) device id for state sync
112
+ * NOTE it must be 1:1 matching with device.
113
+ * - `Device` has the major one connection.
114
+ * - `Connection` is belong to single `Device`.
105
115
  */
106
116
  deviceId?: string;
107
117
  /** (internal) identity-id */
@@ -115,35 +125,6 @@ export interface ConnectionModel extends Model {
115
125
  */
116
126
  readonly $device?: DeviceModel;
117
127
  }
118
- /**
119
- * interface: `ChannelHead`
120
- * - common head of `ChannelModel`
121
- */
122
- export interface ChannelHead {
123
- /** id of channel */
124
- id?: string;
125
- /** name of channel */
126
- name?: string;
127
- }
128
- /**
129
- * interface: `ChannelModel`
130
- * - 웹소켓 접속 채널(room) 관리
131
- * @deprecated no longer in use (Channel management has been delegated to chatic-socials-api)
132
- */
133
- export interface ChannelModel extends Model, ChannelHead {
134
- /** stereo */
135
- stereo?: ChannelStereo;
136
- /** (internal) alised router-id if stereo=alias */
137
- aliasId?: string;
138
- /** (internal) the linked router */
139
- alias$?: ChannelHead;
140
- /** (optional) description of this channel */
141
- desc?: string;
142
- /** (internal) count of subscribers */
143
- subscribed?: number;
144
- /** (internal) the linked alias for detailed */
145
- readonly $alias?: ChannelModel;
146
- }
147
128
  /**
148
129
  * interface: `DeviceHead`
149
130
  */
@@ -154,8 +135,11 @@ export interface DeviceHead {
154
135
  name?: string;
155
136
  }
156
137
  /**
157
- * interface: `DeviceModel`
138
+ * interface: `DeviceModel` (종단 기기)ㅊ
158
139
  * - 디바이스 정보 관리 모델
140
+ * - 그럼, 여기에서는 ENDPOINT 간의 상태 동기화
141
+ *
142
+ * ex) 브라우저 창, 네이티브 앱, 노드기반 클라이언트.
159
143
  */
160
144
  export interface DeviceModel extends Model, DeviceHead {
161
145
  /** device-id (클라이언트에서 생성된 UUID) */
@@ -180,6 +164,13 @@ export interface DeviceModel extends Model, DeviceHead {
180
164
  disconnectedAt?: number;
181
165
  /** (internal) connection-id */
182
166
  connId?: string;
167
+ /** joined channel ids */
168
+ channelIds?: string[];
169
+ /**
170
+ * (internal) owner user-id
171
+ * - 푸시 전송 시, 타겟 유저 ID 매핑을 위해 이용됨.
172
+ * */
173
+ readonly userId?: string;
183
174
  }
184
175
  /**
185
176
  * extract field names from models
@@ -188,25 +179,21 @@ export interface DeviceModel extends Model, DeviceHead {
188
179
  export declare const filterFields: (fields: string[], base?: string[]) => string[];
189
180
  /** field names from head */
190
181
  export declare const $HEAD: {
191
- channel: string[];
192
182
  device: string[];
193
183
  };
194
184
  export declare const $FIELD: {
195
185
  socket: string[];
196
186
  connection: string[];
197
- channel: string[];
198
187
  device: string[];
199
188
  };
200
189
  /** must export default as below */
201
190
  declare const _default: {
202
191
  $HEAD: {
203
- channel: string[];
204
192
  device: string[];
205
193
  };
206
194
  $FIELD: {
207
195
  socket: string[];
208
196
  connection: string[];
209
- channel: string[];
210
197
  device: string[];
211
198
  };
212
199
  };