@lemoncloud/chatic-sockets-lib 0.2.1 → 0.3.0
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/dist/client-socket-v2/gateways/channel-gateway.d.ts +1 -1
- package/dist/client-socket-v2/gateways/cloud-gateway.d.ts +7 -1
- package/dist/client-socket-v2/gateways/cloud-gateway.js +3 -0
- package/dist/client-socket-v2/gateways/place-gateway.d.ts +18 -0
- package/dist/client-socket-v2/gateways/place-gateway.js +14 -0
- package/dist/client-socket-v2/gateways/profile-gateway.d.ts +18 -0
- package/dist/client-socket-v2/gateways/profile-gateway.js +14 -0
- package/dist/client-socket-v2/gateways/user-gateway.d.ts +20 -8
- package/dist/client-socket-v2/gateways/user-gateway.js +1 -1
- package/dist/client-socket-v2/index.d.ts +5 -0
- package/dist/client-socket-v2/index.js +5 -0
- package/dist/client-socket-v2/plans/channel-sync-plan.d.ts +33 -0
- package/dist/client-socket-v2/plans/channel-sync-plan.js +66 -0
- package/dist/client-socket-v2/plans/device-sync-plan.d.ts +5 -1
- package/dist/client-socket-v2/plans/device-sync-plan.js +6 -3
- package/dist/client-socket-v2/plans/place-sync-plan.d.ts +33 -0
- package/dist/client-socket-v2/plans/place-sync-plan.js +67 -0
- package/dist/client-socket-v2/plans/profile-sync-plan.d.ts +33 -0
- package/dist/client-socket-v2/plans/profile-sync-plan.js +67 -0
- package/dist/client-socket-v2/socket-runtime.d.ts +5 -1
- package/dist/client-socket-v2/socket-runtime.js +5 -1
- package/dist/client-socket-v2/sync-scheduler.d.ts +15 -1
- package/dist/client-socket-v2/sync-scheduler.js +89 -12
- package/dist/client-socket-v2/types.d.ts +22 -0
- package/dist/lib/channel/types.d.ts +27 -11
- package/dist/lib/cloud/types.d.ts +38 -2
- package/dist/lib/device/contracts.d.ts +2 -0
- package/dist/lib/place/types.d.ts +53 -0
- package/dist/lib/place/types.js +2 -0
- package/dist/lib/profile/types.d.ts +55 -0
- package/dist/lib/profile/types.js +2 -0
- package/dist/lib/socket-actions.d.ts +55 -3
- package/dist/lib/socket-actions.js +44 -2
- package/dist/lib/socket-inputs.d.ts +3 -1
- package/dist/modules/chat/model.d.ts +107 -0
- package/dist/modules/chat/model.js +28 -0
- package/dist/modules/chat/views.d.ts +50 -0
- package/dist/modules/chat/views.js +23 -0
- package/dist/modules/sockets/model.d.ts +204 -0
- package/dist/modules/sockets/model.js +28 -0
- package/dist/modules/sockets/types.d.ts +88 -0
- package/dist/modules/sockets/types.js +78 -0
- package/dist/modules/sockets/views.d.ts +67 -0
- package/dist/modules/sockets/views.js +23 -0
- package/package.json +4 -2
|
@@ -33,6 +33,10 @@ exports.SocketActionTypeLUT = {
|
|
|
33
33
|
chat: 'chat',
|
|
34
34
|
/** user - user/site profile operations */
|
|
35
35
|
user: 'user',
|
|
36
|
+
/** place - place(site) CRUD operations */
|
|
37
|
+
place: 'place',
|
|
38
|
+
/** profile - site profile operations */
|
|
39
|
+
profile: 'profile',
|
|
36
40
|
/** cloud - cloud profile operations */
|
|
37
41
|
cloud: 'cloud',
|
|
38
42
|
},
|
|
@@ -112,9 +116,11 @@ exports.SocketActionTypeLUT = {
|
|
|
112
116
|
delete: 'delete',
|
|
113
117
|
/** sync - synchronize channel list/state */
|
|
114
118
|
sync: 'sync',
|
|
119
|
+
/** read - pull authoritative single-channel item */
|
|
120
|
+
read: 'read',
|
|
115
121
|
/** sync-users - synchronize channel users */
|
|
116
122
|
'sync-users': 'sync-users',
|
|
117
|
-
/** sync
|
|
123
|
+
/** @deprecated use `profile.sync`. synchronize related site profile (하위호환) */
|
|
118
124
|
'sync-site-profile': 'sync-site-profile',
|
|
119
125
|
/** unreads - get unread message summary */
|
|
120
126
|
unreads: 'unreads',
|
|
@@ -155,13 +161,49 @@ exports.SocketActionTypeLUT = {
|
|
|
155
161
|
/** set-site-profile - set site profile */
|
|
156
162
|
'set-site-profile': 'set-site-profile',
|
|
157
163
|
},
|
|
164
|
+
/**
|
|
165
|
+
* PlaceActionType
|
|
166
|
+
* - place(site) 도메인 액션
|
|
167
|
+
*/
|
|
168
|
+
PlaceActionType: {
|
|
169
|
+
'': '',
|
|
170
|
+
/** create - create a place(site) */
|
|
171
|
+
create: 'create',
|
|
172
|
+
/** get - get a place(site) */
|
|
173
|
+
get: 'get',
|
|
174
|
+
/** update - update a place(site) */
|
|
175
|
+
update: 'update',
|
|
176
|
+
/** delete - delete a place(site) */
|
|
177
|
+
delete: 'delete',
|
|
178
|
+
},
|
|
179
|
+
/**
|
|
180
|
+
* ProfileActionType
|
|
181
|
+
* - profile(site-profile) 도메인 액션
|
|
182
|
+
*/
|
|
183
|
+
ProfileActionType: {
|
|
184
|
+
'': '',
|
|
185
|
+
/** get - get site profile by id */
|
|
186
|
+
get: 'get',
|
|
187
|
+
/** get-mine - get current session's site profile */
|
|
188
|
+
'get-mine': 'get-mine',
|
|
189
|
+
/** set - set site profile */
|
|
190
|
+
set: 'set',
|
|
191
|
+
/** sync - synchronize site multi-profiles (delta since cursor) */
|
|
192
|
+
sync: 'sync',
|
|
193
|
+
},
|
|
158
194
|
/**
|
|
159
195
|
* CloudActionType
|
|
160
196
|
* - cloud 도메인 액션
|
|
161
197
|
*/
|
|
162
198
|
CloudActionType: {
|
|
163
199
|
'': '',
|
|
164
|
-
/**
|
|
200
|
+
/** create - create a cloud (미구현/500) */
|
|
201
|
+
create: 'create',
|
|
202
|
+
/** get - get a cloud */
|
|
203
|
+
get: 'get',
|
|
204
|
+
/** update - update a cloud */
|
|
165
205
|
update: 'update',
|
|
206
|
+
/** delete - delete a cloud */
|
|
207
|
+
delete: 'delete',
|
|
166
208
|
},
|
|
167
209
|
};
|
|
@@ -9,5 +9,7 @@ export type { DeviceGetInput, DeviceReadInput, DeviceSaveInput, DeviceSyncInput
|
|
|
9
9
|
export type { FindConnectionModelInput, SocketsFindConnectionInput } from './sockets/types';
|
|
10
10
|
export type { ChatFeedInput, ChatReadInput, ChatSendInput } from './chat/types';
|
|
11
11
|
export type { ChannelCreateInput, ChannelDeleteInput, ChannelGetSelfInput, ChannelInviteInput, ChannelJoinInput, ChannelLeaveInput, ChannelListMyInput, ChannelListUserInput, ChannelMineInput, ChannelSyncInput, ChannelSyncProfileInput, ChannelSyncSiteProfileInput, ChannelSyncUsersInput, ChannelUnreadsInput, ChannelUpdateInput, ChannelUpdateJoinInput, ChatDeleteChannelInput, ChatInviteInput, ChatLeaveInput, ChatMineInput, ChatStartInput, ChatUpdateChannelInput, ChatUpdateJoinInput, ChatUsersInput, JoinUpdateInput, } from './channel/types';
|
|
12
|
-
export type {
|
|
12
|
+
export type { PlaceCreateInput, PlaceDeleteInput, PlaceGetInput, PlaceUpdateInput } from './place/types';
|
|
13
|
+
export type { ProfileGetInput, ProfileGetMineInput, ProfileSetInput, ProfileSyncInput } from './profile/types';
|
|
14
|
+
export type { CloudCreateInput, CloudDeleteInput, CloudGetInput, CloudUpdateInput, UpdateCloudInput, } from './cloud/types';
|
|
13
15
|
export type { UserGetSiteProfileInput, UserInviteBatchInput, UserInviteInput, UserMakeSiteInput, UserMySiteInput, UserSetSiteProfileInput, UserUpdateProfileInput, UserUpdateSiteInput, } from './user/types';
|
|
@@ -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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$FIELD = exports.$HEAD = exports.filterFields = void 0;
|
|
4
|
+
const field_registry_1 = require("../../generated/field-registry");
|
|
5
|
+
/**
|
|
6
|
+
* extract field names from models
|
|
7
|
+
* - only fields start with lowercase, or all upper.
|
|
8
|
+
*/
|
|
9
|
+
const filterFields = (fields, base = []) => fields
|
|
10
|
+
.filter(field => field !== '_id' && /^[a-z_][a-zA-Z_]+/.test(field))
|
|
11
|
+
.reduce((L, k) => {
|
|
12
|
+
if (k && !L.includes(k))
|
|
13
|
+
L.push(k);
|
|
14
|
+
return L;
|
|
15
|
+
}, [...base]);
|
|
16
|
+
exports.filterFields = filterFields;
|
|
17
|
+
/** field names from head */
|
|
18
|
+
exports.$HEAD = {
|
|
19
|
+
channel: (0, exports.filterFields)(field_registry_1.fieldKeys.channelHead()),
|
|
20
|
+
};
|
|
21
|
+
// extract field names from models
|
|
22
|
+
exports.$FIELD = {
|
|
23
|
+
channel: (0, exports.filterFields)(field_registry_1.fieldKeys.channelModel(), ['meta']),
|
|
24
|
+
chat: (0, exports.filterFields)(field_registry_1.fieldKeys.chatModel(), ['meta']),
|
|
25
|
+
join: (0, exports.filterFields)(field_registry_1.fieldKeys.joinModel(), ['meta']),
|
|
26
|
+
};
|
|
27
|
+
/** must export default as below */
|
|
28
|
+
exports.default = { $HEAD: exports.$HEAD, $FIELD: exports.$FIELD };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `views.ts`
|
|
3
|
+
* - type of views used in chat module.
|
|
4
|
+
*/
|
|
5
|
+
import { View, Body } from 'lemon-model';
|
|
6
|
+
import { ChannelModel, ChatModel, JoinModel } from './model';
|
|
7
|
+
import $LUT from './types';
|
|
8
|
+
import type { DeviceView } from '../sockets/views';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export default $LUT;
|
|
11
|
+
/**
|
|
12
|
+
* type: `ChannelView`
|
|
13
|
+
*/
|
|
14
|
+
export interface ChannelView extends View, Partial<ChannelModel> {
|
|
15
|
+
/** (linked) owner info */
|
|
16
|
+
readonly owner$?: DeviceView;
|
|
17
|
+
/** (linked) last chat info */
|
|
18
|
+
readonly lastChat$?: ChatView;
|
|
19
|
+
/** (readonly) device's channel connection view */
|
|
20
|
+
readonly $join?: JoinView;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type `ChannelBody`
|
|
24
|
+
*/
|
|
25
|
+
export interface ChannelBody extends Body, Partial<ChannelView> {
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* type: `ChatView`
|
|
29
|
+
*/
|
|
30
|
+
export interface ChatView extends View, Partial<ChatModel> {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Type `ChatBody`
|
|
34
|
+
*/
|
|
35
|
+
export interface ChatBody extends Body, Partial<ChatView> {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* type: `JoinView`
|
|
39
|
+
*/
|
|
40
|
+
export interface JoinView extends Omit<View, 'joined'>, Omit<Partial<JoinModel>, 'joined'> {
|
|
41
|
+
/**
|
|
42
|
+
* current joined state for API/view consumers.
|
|
43
|
+
*/
|
|
44
|
+
readonly joined?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Type `JoinBody`
|
|
48
|
+
*/
|
|
49
|
+
export interface JoinBody extends Body, Partial<JoinView> {
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const types_1 = __importDefault(require("./types"));
|
|
21
|
+
//! export all internal types
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
exports.default = types_1.default;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `model.ts`
|
|
3
|
+
* - model definitions per account data
|
|
4
|
+
*
|
|
5
|
+
* @author Steve <steve@lemoncloud.io>
|
|
6
|
+
* @date 2022-08-29 initial version.
|
|
7
|
+
* @author Aiden <aiden@lemocloud.io>
|
|
8
|
+
* @date 2025-07-23 refactored for sockets service
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) 2022 LemonCloud Co Ltd. - All Rights Reserved.
|
|
11
|
+
*/
|
|
12
|
+
import { CoreModel } from 'lemon-model';
|
|
13
|
+
import $LUT, { DevicePlatform, DeviceStatus } from './types';
|
|
14
|
+
import type { ChannelHead } from '../chat/model';
|
|
15
|
+
/**
|
|
16
|
+
* type: `ModelType`
|
|
17
|
+
*/
|
|
18
|
+
export declare type ModelType = keyof typeof $LUT.ModelType;
|
|
19
|
+
/**
|
|
20
|
+
* type: `Model`: common model
|
|
21
|
+
*/
|
|
22
|
+
export declare type Model = CoreModel<ModelType>;
|
|
23
|
+
/**
|
|
24
|
+
* interface: `SocketModel`
|
|
25
|
+
*/
|
|
26
|
+
export interface SocketModel extends Model {
|
|
27
|
+
/** id of model */
|
|
28
|
+
id?: string;
|
|
29
|
+
/** name of model */
|
|
30
|
+
name?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* interface: `ConnectionModel`
|
|
34
|
+
* - a model for each connection to websocket.
|
|
35
|
+
* - 웹소켓 연결 정보를 저장하는 모델
|
|
36
|
+
*/
|
|
37
|
+
export interface ConnectionModel extends Model {
|
|
38
|
+
/**
|
|
39
|
+
* as `conn-id`
|
|
40
|
+
*/
|
|
41
|
+
id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* stereo type as initial `role`.
|
|
44
|
+
*/
|
|
45
|
+
stereo?: string;
|
|
46
|
+
/**
|
|
47
|
+
* (required) The deployment stage of the API (e.g., 'dev', 'prod').
|
|
48
|
+
*/
|
|
49
|
+
stage?: string;
|
|
50
|
+
/**
|
|
51
|
+
* (required) The domain name of the WebSocket API.
|
|
52
|
+
*/
|
|
53
|
+
domain?: string;
|
|
54
|
+
/**
|
|
55
|
+
* (required) The API Gateway ID for Management API endpoint.
|
|
56
|
+
*/
|
|
57
|
+
apiId?: string;
|
|
58
|
+
/**
|
|
59
|
+
* (required) The unique identifier for the WebSocket connection.
|
|
60
|
+
*/
|
|
61
|
+
connectionId?: string;
|
|
62
|
+
/** (optional) if it has valid session infor. */
|
|
63
|
+
hasSession?: number;
|
|
64
|
+
/** (internal) Timestamp when the connection was established. */
|
|
65
|
+
connectedAt?: number;
|
|
66
|
+
/** (internal) Timestamp when the connection was terminated. */
|
|
67
|
+
disConnectedAt?: number;
|
|
68
|
+
/** (internal) version no */
|
|
69
|
+
versionNo?: number;
|
|
70
|
+
/** (internal) tracking no */
|
|
71
|
+
no?: number;
|
|
72
|
+
/**
|
|
73
|
+
* (extended) The origin of the request.
|
|
74
|
+
*/
|
|
75
|
+
origin?: string;
|
|
76
|
+
/**
|
|
77
|
+
* (extended) The remote IP address of the client.
|
|
78
|
+
*/
|
|
79
|
+
remote?: string;
|
|
80
|
+
/**
|
|
81
|
+
* (extended) The User-Agent string of the client.
|
|
82
|
+
*/
|
|
83
|
+
agent?: string;
|
|
84
|
+
/**
|
|
85
|
+
* (extended) The reason for disconnection, if applicable.
|
|
86
|
+
*/
|
|
87
|
+
reason?: string;
|
|
88
|
+
/**
|
|
89
|
+
* (extended) The code of disconnection.
|
|
90
|
+
*/
|
|
91
|
+
disconnectCode?: number;
|
|
92
|
+
/**
|
|
93
|
+
* (extended) TTL for auto-deletion (ts)
|
|
94
|
+
*/
|
|
95
|
+
ttl?: number;
|
|
96
|
+
/**
|
|
97
|
+
* (internal) ping-pong count
|
|
98
|
+
*/
|
|
99
|
+
readonly count?: number;
|
|
100
|
+
/**
|
|
101
|
+
* (linked) 현재 연결이 구독 중인 채널(토픽) ID 목록
|
|
102
|
+
*
|
|
103
|
+
* @deprecated no more supported (see `chatic-socials-api`)
|
|
104
|
+
*/
|
|
105
|
+
channels?: string[];
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated no longer in use (Channel management has been delegated to chatic-socials-api)
|
|
108
|
+
*/
|
|
109
|
+
channel$$?: ChannelHead[];
|
|
110
|
+
/**
|
|
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`.
|
|
115
|
+
*/
|
|
116
|
+
deviceId?: string;
|
|
117
|
+
/** (internal) identity-id */
|
|
118
|
+
identityId?: string;
|
|
119
|
+
/** (internal) verified roles */
|
|
120
|
+
roles?: string[];
|
|
121
|
+
/** (internal) delegator-id — 소셜 로그인 시 게스트유저 uid */
|
|
122
|
+
did?: string;
|
|
123
|
+
/**
|
|
124
|
+
* (internal) connected device-info
|
|
125
|
+
*/
|
|
126
|
+
readonly $device?: DeviceModel;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* interface: `DeviceHead`
|
|
130
|
+
*/
|
|
131
|
+
export interface DeviceHead {
|
|
132
|
+
/** id of model */
|
|
133
|
+
id?: string;
|
|
134
|
+
/** name of model */
|
|
135
|
+
name?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* interface: `DeviceModel` (종단 기기)ㅊ
|
|
139
|
+
* - 디바이스 정보 관리 모델
|
|
140
|
+
* - 그럼, 여기에서는 ENDPOINT 간의 상태 동기화
|
|
141
|
+
*
|
|
142
|
+
* ex) 브라우저 창, 네이티브 앱, 노드기반 클라이언트.
|
|
143
|
+
*/
|
|
144
|
+
export interface DeviceModel extends Model, DeviceHead {
|
|
145
|
+
/** device-id (클라이언트에서 생성된 UUID) */
|
|
146
|
+
id?: string;
|
|
147
|
+
/** name of model */
|
|
148
|
+
name?: string;
|
|
149
|
+
/** device platform */
|
|
150
|
+
platform?: DevicePlatform;
|
|
151
|
+
/** status of device (for sync) */
|
|
152
|
+
status?: DeviceStatus;
|
|
153
|
+
/** tick count (for sync) */
|
|
154
|
+
tick?: number;
|
|
155
|
+
/** x position (for sync) */
|
|
156
|
+
posX?: number;
|
|
157
|
+
/** y position (for sync) */
|
|
158
|
+
posY?: number;
|
|
159
|
+
/** (후속 channel 선택용) 현재 보고 있는 채널 id */
|
|
160
|
+
currChannelId?: string;
|
|
161
|
+
/** (후속 channel 선택용) 현재 채널 진입 시각(ms) */
|
|
162
|
+
viewingSince?: number;
|
|
163
|
+
/** last activity timestamp */
|
|
164
|
+
lastActiveAt?: number;
|
|
165
|
+
/** connection start timestamp */
|
|
166
|
+
connectedAt?: number;
|
|
167
|
+
/** last disconnection timestamp */
|
|
168
|
+
disconnectedAt?: number;
|
|
169
|
+
/** (internal) connection-id */
|
|
170
|
+
connId?: string;
|
|
171
|
+
/** joined channel ids */
|
|
172
|
+
channelIds?: string[];
|
|
173
|
+
/**
|
|
174
|
+
* (internal) owner user-id
|
|
175
|
+
* - 푸시 전송 시, 타겟 유저 ID 매핑을 위해 이용됨.
|
|
176
|
+
* */
|
|
177
|
+
readonly userId?: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* extract field names from models
|
|
181
|
+
* - only fields start with lowercase, or all upper.
|
|
182
|
+
*/
|
|
183
|
+
export declare const filterFields: (fields: string[], base?: string[]) => string[];
|
|
184
|
+
/** field names from head */
|
|
185
|
+
export declare const $HEAD: {
|
|
186
|
+
device: string[];
|
|
187
|
+
};
|
|
188
|
+
export declare const $FIELD: {
|
|
189
|
+
socket: string[];
|
|
190
|
+
connection: string[];
|
|
191
|
+
device: string[];
|
|
192
|
+
};
|
|
193
|
+
/** must export default as below */
|
|
194
|
+
declare const _default: {
|
|
195
|
+
$HEAD: {
|
|
196
|
+
device: string[];
|
|
197
|
+
};
|
|
198
|
+
$FIELD: {
|
|
199
|
+
socket: string[];
|
|
200
|
+
connection: string[];
|
|
201
|
+
device: string[];
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$FIELD = exports.$HEAD = exports.filterFields = void 0;
|
|
4
|
+
const field_registry_1 = require("../../generated/field-registry");
|
|
5
|
+
/**
|
|
6
|
+
* extract field names from models
|
|
7
|
+
* - only fields start with lowercase, or all upper.
|
|
8
|
+
*/
|
|
9
|
+
const filterFields = (fields, base = []) => fields
|
|
10
|
+
.filter(field => field !== '_id' && /^[a-z_][a-zA-Z_]+/.test(field))
|
|
11
|
+
.reduce((L, k) => {
|
|
12
|
+
if (k && !L.includes(k))
|
|
13
|
+
L.push(k);
|
|
14
|
+
return L;
|
|
15
|
+
}, [...base]);
|
|
16
|
+
exports.filterFields = filterFields;
|
|
17
|
+
/** field names from head */
|
|
18
|
+
exports.$HEAD = {
|
|
19
|
+
device: (0, exports.filterFields)(field_registry_1.fieldKeys.deviceHead()),
|
|
20
|
+
};
|
|
21
|
+
// extract field names from models
|
|
22
|
+
exports.$FIELD = {
|
|
23
|
+
socket: (0, exports.filterFields)(field_registry_1.fieldKeys.socketModel(), ['meta']),
|
|
24
|
+
connection: (0, exports.filterFields)(field_registry_1.fieldKeys.connectionModel(), ['meta']),
|
|
25
|
+
device: (0, exports.filterFields)(field_registry_1.fieldKeys.deviceModel(), ['meta']),
|
|
26
|
+
};
|
|
27
|
+
/** must export default as below */
|
|
28
|
+
exports.default = { $HEAD: exports.$HEAD, $FIELD: exports.$FIELD };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `types.ts`
|
|
3
|
+
* - 기본 types used in `backend-proxy`
|
|
4
|
+
*
|
|
5
|
+
* **[중요! exports 순서]**
|
|
6
|
+
* 1. define data type in `types.ts` w/ internal types.
|
|
7
|
+
* 2. define Model in `model.ts`
|
|
8
|
+
* 3. define View/Body in `view.ts`, and external types.
|
|
9
|
+
*
|
|
10
|
+
* @author Steve <steve@lemoncloud.io>
|
|
11
|
+
* @date 2022-08-29 initial version.
|
|
12
|
+
* @author Aiden <aiden@lemocloud.io>
|
|
13
|
+
* @date 2025-07-23 refactored for sockets service
|
|
14
|
+
*
|
|
15
|
+
* Copyright (C) 2022 LemonCloud Co Ltd. - All Rights Reserved.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Lookup Table
|
|
19
|
+
*
|
|
20
|
+
* WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
|
|
21
|
+
*/
|
|
22
|
+
declare const $LUT: {
|
|
23
|
+
/**
|
|
24
|
+
* Possible type of model.
|
|
25
|
+
*/
|
|
26
|
+
ModelType: {
|
|
27
|
+
/** socket model */
|
|
28
|
+
socket: string;
|
|
29
|
+
/** connection model */
|
|
30
|
+
connection: string;
|
|
31
|
+
/** device model */
|
|
32
|
+
device: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* DeviceStatus
|
|
36
|
+
*/
|
|
37
|
+
DeviceStatus: {
|
|
38
|
+
'': string;
|
|
39
|
+
/** green - online */
|
|
40
|
+
green: string;
|
|
41
|
+
/** red - offline */
|
|
42
|
+
red: string;
|
|
43
|
+
/** yellow - away/idle */
|
|
44
|
+
yellow: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* DeviceEventType
|
|
48
|
+
*/
|
|
49
|
+
DeviceEventType: {
|
|
50
|
+
'': string;
|
|
51
|
+
/** ping - heartbeat */
|
|
52
|
+
ping: string;
|
|
53
|
+
/** status - status change */
|
|
54
|
+
status: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* DevicePlatform
|
|
58
|
+
*/
|
|
59
|
+
DevicePlatform: {
|
|
60
|
+
'': string;
|
|
61
|
+
/** iOS */
|
|
62
|
+
ios: string;
|
|
63
|
+
/** Android */
|
|
64
|
+
android: string;
|
|
65
|
+
/** Web browser */
|
|
66
|
+
web: string;
|
|
67
|
+
/** macOS */
|
|
68
|
+
macos: string;
|
|
69
|
+
/** Windows */
|
|
70
|
+
windows: string;
|
|
71
|
+
/** Linux */
|
|
72
|
+
linux: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* type: `DeviceStatus`
|
|
77
|
+
*/
|
|
78
|
+
export declare type DeviceStatus = keyof typeof $LUT.DeviceStatus;
|
|
79
|
+
/**
|
|
80
|
+
* type: `DeviceEventType`
|
|
81
|
+
*/
|
|
82
|
+
export declare type DeviceEventType = keyof typeof $LUT.DeviceEventType;
|
|
83
|
+
/**
|
|
84
|
+
* type: `DevicePlatform`
|
|
85
|
+
*/
|
|
86
|
+
export declare type DevicePlatform = keyof typeof $LUT.DevicePlatform;
|
|
87
|
+
/** must export $LUT as default */
|
|
88
|
+
export default $LUT;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `types.ts`
|
|
4
|
+
* - 기본 types used in `backend-proxy`
|
|
5
|
+
*
|
|
6
|
+
* **[중요! exports 순서]**
|
|
7
|
+
* 1. define data type in `types.ts` w/ internal types.
|
|
8
|
+
* 2. define Model in `model.ts`
|
|
9
|
+
* 3. define View/Body in `view.ts`, and external types.
|
|
10
|
+
*
|
|
11
|
+
* @author Steve <steve@lemoncloud.io>
|
|
12
|
+
* @date 2022-08-29 initial version.
|
|
13
|
+
* @author Aiden <aiden@lemocloud.io>
|
|
14
|
+
* @date 2025-07-23 refactored for sockets service
|
|
15
|
+
*
|
|
16
|
+
* Copyright (C) 2022 LemonCloud Co Ltd. - All Rights Reserved.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
/**
|
|
20
|
+
* Lookup Table
|
|
21
|
+
*
|
|
22
|
+
* WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
|
|
23
|
+
*/
|
|
24
|
+
const $LUT = {
|
|
25
|
+
/**
|
|
26
|
+
* Possible type of model.
|
|
27
|
+
*/
|
|
28
|
+
ModelType: {
|
|
29
|
+
/** socket model */
|
|
30
|
+
socket: 'socket',
|
|
31
|
+
/** connection model */
|
|
32
|
+
connection: 'connection',
|
|
33
|
+
/** device model */
|
|
34
|
+
device: 'device',
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* DeviceStatus
|
|
38
|
+
*/
|
|
39
|
+
DeviceStatus: {
|
|
40
|
+
'': '',
|
|
41
|
+
/** green - online */
|
|
42
|
+
green: 'green',
|
|
43
|
+
/** red - offline */
|
|
44
|
+
red: 'red',
|
|
45
|
+
/** yellow - away/idle */
|
|
46
|
+
yellow: 'yellow',
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* DeviceEventType
|
|
50
|
+
*/
|
|
51
|
+
DeviceEventType: {
|
|
52
|
+
'': '',
|
|
53
|
+
/** ping - heartbeat */
|
|
54
|
+
ping: 'ping',
|
|
55
|
+
/** status - status change */
|
|
56
|
+
status: 'status',
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* DevicePlatform
|
|
60
|
+
*/
|
|
61
|
+
DevicePlatform: {
|
|
62
|
+
'': '',
|
|
63
|
+
/** iOS */
|
|
64
|
+
ios: 'ios',
|
|
65
|
+
/** Android */
|
|
66
|
+
android: 'android',
|
|
67
|
+
/** Web browser */
|
|
68
|
+
web: 'web',
|
|
69
|
+
/** macOS */
|
|
70
|
+
macos: 'macos',
|
|
71
|
+
/** Windows */
|
|
72
|
+
windows: 'windows',
|
|
73
|
+
/** Linux */
|
|
74
|
+
linux: 'linux',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
/** must export $LUT as default */
|
|
78
|
+
exports.default = $LUT;
|