@lemoncloud/chatic-sockets-lib 0.2.0 → 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/create-client-socket-v2.js +5 -0
- package/dist/client-socket-v2/gateways/auth-gateway.d.ts +6 -0
- package/dist/client-socket-v2/gateways/auth-gateway.js +11 -0
- package/dist/client-socket-v2/gateways/channel-gateway.d.ts +38 -0
- package/dist/client-socket-v2/gateways/channel-gateway.js +24 -0
- package/dist/client-socket-v2/gateways/chat-gateway.d.ts +22 -0
- package/dist/client-socket-v2/gateways/chat-gateway.js +16 -0
- package/dist/client-socket-v2/gateways/cloud-gateway.d.ts +18 -0
- package/dist/client-socket-v2/gateways/cloud-gateway.js +14 -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 +38 -0
- package/dist/client-socket-v2/gateways/user-gateway.js +18 -0
- package/dist/client-socket-v2/index.d.ts +13 -0
- package/dist/client-socket-v2/index.js +12 -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/socket-transport.d.ts +14 -4
- package/dist/client-socket-v2/socket-transport.js +58 -60
- 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 +38 -7
- package/dist/lib/channel/types.d.ts +191 -0
- package/dist/lib/channel/types.js +2 -0
- package/dist/lib/chat/types.d.ts +79 -0
- package/dist/lib/chat/types.js +2 -0
- package/dist/lib/cloud/types.d.ts +54 -0
- package/dist/lib/cloud/types.js +2 -0
- package/dist/lib/device/contracts.d.ts +2 -0
- package/dist/lib/device/types.d.ts +1 -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 +291 -0
- package/dist/lib/socket-actions.js +209 -0
- package/dist/lib/socket-inputs.d.ts +15 -0
- package/dist/lib/socket-inputs.js +8 -0
- package/dist/lib/sockets/types.d.ts +27 -0
- package/dist/lib/sockets/types.js +17 -0
- package/dist/lib/types.d.ts +2 -0
- package/dist/lib/user/types.d.ts +102 -0
- package/dist/lib/user/types.js +2 -0
- package/dist/modules/chat/model.d.ts +107 -0
- package/dist/modules/chat/model.js +28 -0
- package/dist/modules/chat/types.d.ts +65 -0
- package/dist/modules/chat/types.js +55 -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
|
@@ -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,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;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `types.ts`
|
|
4
|
+
* - basic types for chat module.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
/**
|
|
8
|
+
* Lookup Table
|
|
9
|
+
*
|
|
10
|
+
* WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
|
|
11
|
+
*/
|
|
12
|
+
const $LUT = {
|
|
13
|
+
/**
|
|
14
|
+
* Possible type of model.
|
|
15
|
+
*/
|
|
16
|
+
ModelType: {
|
|
17
|
+
/** channel model */
|
|
18
|
+
channel: 'channel',
|
|
19
|
+
/** chat model */
|
|
20
|
+
chat: 'chat',
|
|
21
|
+
/** join model */
|
|
22
|
+
join: 'join',
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* ChannelStereo
|
|
26
|
+
*/
|
|
27
|
+
ChannelStereo: {
|
|
28
|
+
'': '',
|
|
29
|
+
/** direct message (1:1) */
|
|
30
|
+
dm: 'dm',
|
|
31
|
+
/** self memo channel */
|
|
32
|
+
self: 'self',
|
|
33
|
+
/** open channel */
|
|
34
|
+
public: 'public',
|
|
35
|
+
/** invite-only channel */
|
|
36
|
+
private: 'private',
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* ChatStereo
|
|
40
|
+
*/
|
|
41
|
+
ChatStereo: {
|
|
42
|
+
text: 'text',
|
|
43
|
+
join: 'join',
|
|
44
|
+
leave: 'leave',
|
|
45
|
+
system: 'system',
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* JoinStereo
|
|
49
|
+
*/
|
|
50
|
+
JoinStereo: {
|
|
51
|
+
'': '',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
/** must export $LUT as default */
|
|
55
|
+
exports.default = $LUT;
|
|
@@ -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;
|