@lemoncloud/chatic-sockets-lib 0.1.0 → 0.2.1

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.
Files changed (46) hide show
  1. package/dist/client-socket-v2/connection-rotation-controller.d.ts +4 -0
  2. package/dist/client-socket-v2/connection-rotation-controller.js +9 -3
  3. package/dist/client-socket-v2/create-client-socket-v2.js +155 -27
  4. package/dist/client-socket-v2/gateways/auth-gateway.d.ts +6 -0
  5. package/dist/client-socket-v2/gateways/auth-gateway.js +11 -0
  6. package/dist/client-socket-v2/gateways/channel-gateway.d.ts +38 -0
  7. package/dist/client-socket-v2/gateways/channel-gateway.js +24 -0
  8. package/dist/client-socket-v2/gateways/chat-gateway.d.ts +22 -0
  9. package/dist/client-socket-v2/gateways/chat-gateway.js +16 -0
  10. package/dist/client-socket-v2/gateways/cloud-gateway.d.ts +12 -0
  11. package/dist/client-socket-v2/gateways/cloud-gateway.js +11 -0
  12. package/dist/client-socket-v2/gateways/user-gateway.d.ts +26 -0
  13. package/dist/client-socket-v2/gateways/user-gateway.js +18 -0
  14. package/dist/client-socket-v2/index.d.ts +10 -0
  15. package/dist/client-socket-v2/index.js +9 -0
  16. package/dist/client-socket-v2/keep-alive-loop.d.ts +5 -7
  17. package/dist/client-socket-v2/keep-alive-loop.js +32 -9
  18. package/dist/client-socket-v2/message-router.d.ts +1 -0
  19. package/dist/client-socket-v2/message-router.js +4 -0
  20. package/dist/client-socket-v2/reconnect-controller.d.ts +23 -7
  21. package/dist/client-socket-v2/reconnect-controller.js +72 -9
  22. package/dist/client-socket-v2/socket-runtime.js +14 -4
  23. package/dist/client-socket-v2/socket-transport.d.ts +22 -5
  24. package/dist/client-socket-v2/socket-transport.js +79 -55
  25. package/dist/client-socket-v2/types.d.ts +45 -8
  26. package/dist/lib/auth/types.d.ts +36 -0
  27. package/dist/lib/auth/types.js +2 -0
  28. package/dist/lib/channel/types.d.ts +175 -0
  29. package/dist/lib/channel/types.js +2 -0
  30. package/dist/lib/chat/types.d.ts +79 -0
  31. package/dist/lib/chat/types.js +2 -0
  32. package/dist/lib/cloud/types.d.ts +18 -0
  33. package/dist/lib/cloud/types.js +2 -0
  34. package/dist/lib/device/types.d.ts +1 -0
  35. package/dist/lib/socket-actions.d.ts +239 -0
  36. package/dist/lib/socket-actions.js +167 -0
  37. package/dist/lib/socket-inputs.d.ts +13 -0
  38. package/dist/lib/socket-inputs.js +8 -0
  39. package/dist/lib/sockets/types.d.ts +27 -0
  40. package/dist/lib/sockets/types.js +17 -0
  41. package/dist/lib/types.d.ts +2 -0
  42. package/dist/lib/user/types.d.ts +102 -0
  43. package/dist/lib/user/types.js +2 -0
  44. package/dist/modules/chat/types.d.ts +65 -0
  45. package/dist/modules/chat/types.js +55 -0
  46. package/package.json +1 -1
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ /**
3
+ * `socket-actions.ts`
4
+ * - supported wsv2 socket domain/action lookup table.
5
+ *
6
+ * Keep this file client-safe. It is used as a public type contract and must not
7
+ * import server-side modules.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SocketActionTypeLUT = void 0;
11
+ /**
12
+ * lookup table
13
+ * - wsv2에서 공개/지원하는 socket action 목록
14
+ */
15
+ exports.SocketActionTypeLUT = {
16
+ /**
17
+ * DomainType
18
+ * - message domain
19
+ */
20
+ DomainType: {
21
+ '': '',
22
+ /** system - builtin/system messages */
23
+ system: 'system',
24
+ /** sockets - socket connection helpers */
25
+ sockets: 'sockets',
26
+ /** device - client device state */
27
+ device: 'device',
28
+ /** auth - connection authentication */
29
+ auth: 'auth',
30
+ /** channel - chat channel operations */
31
+ channel: 'channel',
32
+ /** chat - chat message operations */
33
+ chat: 'chat',
34
+ /** user - user/site profile operations */
35
+ user: 'user',
36
+ /** cloud - cloud profile operations */
37
+ cloud: 'cloud',
38
+ },
39
+ /**
40
+ * SystemActionType
41
+ * - system 도메인 액션
42
+ */
43
+ SystemActionType: {
44
+ '': '',
45
+ /** ping - keep-alive request */
46
+ ping: 'ping',
47
+ /** pong - keep-alive response/event */
48
+ pong: 'pong',
49
+ /** info - connection/server information */
50
+ info: 'info',
51
+ /** message - generic system message */
52
+ message: 'message',
53
+ /** error - generic system error */
54
+ error: 'error',
55
+ },
56
+ /**
57
+ * SocketsActionType
58
+ * - sockets 도메인 액션
59
+ */
60
+ SocketsActionType: {
61
+ '': '',
62
+ /** find-connection - find or create current connection model */
63
+ 'find-connection': 'find-connection',
64
+ },
65
+ /**
66
+ * DeviceActionType
67
+ * - device 도메인 액션
68
+ */
69
+ DeviceActionType: {
70
+ '': '',
71
+ /** save - create or update linked device */
72
+ save: 'save',
73
+ /** read - read linked or requested device */
74
+ read: 'read',
75
+ /** sync - client device state sync hint */
76
+ sync: 'sync',
77
+ },
78
+ /**
79
+ * AuthActionType
80
+ * - auth 도메인 액션
81
+ */
82
+ AuthActionType: {
83
+ '': '',
84
+ /** update - update authentication state for current connection */
85
+ update: 'update',
86
+ },
87
+ /**
88
+ * ChannelActionType
89
+ * - channel 도메인 액션
90
+ */
91
+ ChannelActionType: {
92
+ '': '',
93
+ /** create - create a channel */
94
+ create: 'create',
95
+ /** join - join a channel */
96
+ join: 'join',
97
+ /** leave - leave or kick from a channel */
98
+ leave: 'leave',
99
+ /** get-self - get or create personal channel */
100
+ 'get-self': 'get-self',
101
+ /** mine - list my channels */
102
+ mine: 'mine',
103
+ /** list-user - list channel members */
104
+ 'list-user': 'list-user',
105
+ /** invite - invite users to a channel */
106
+ invite: 'invite',
107
+ /** update - update channel information */
108
+ update: 'update',
109
+ /** update-join - update channel participation settings */
110
+ 'update-join': 'update-join',
111
+ /** delete - delete a channel */
112
+ delete: 'delete',
113
+ /** sync - synchronize channel list/state */
114
+ sync: 'sync',
115
+ /** sync-users - synchronize channel users */
116
+ 'sync-users': 'sync-users',
117
+ /** sync-site-profile - synchronize related site profile */
118
+ 'sync-site-profile': 'sync-site-profile',
119
+ /** unreads - get unread message summary */
120
+ unreads: 'unreads',
121
+ },
122
+ /**
123
+ * ChatActionType
124
+ * - chat 도메인 액션
125
+ */
126
+ ChatActionType: {
127
+ '': '',
128
+ /** send - send chat message */
129
+ send: 'send',
130
+ /** read - mark chat message/channel as read */
131
+ read: 'read',
132
+ /** feed - get chat feed */
133
+ feed: 'feed',
134
+ },
135
+ /**
136
+ * UserActionType
137
+ * - user 도메인 액션
138
+ */
139
+ UserActionType: {
140
+ '': '',
141
+ /** invite - invite a user */
142
+ invite: 'invite',
143
+ /** invite-batch - invite multiple users */
144
+ 'invite-batch': 'invite-batch',
145
+ /** my-site - list accessible sites */
146
+ 'my-site': 'my-site',
147
+ /** make-site - create a site */
148
+ 'make-site': 'make-site',
149
+ /** update-profile - update user profile */
150
+ 'update-profile': 'update-profile',
151
+ /** update-site - update site profile */
152
+ 'update-site': 'update-site',
153
+ /** get-site-profile - get site profile */
154
+ 'get-site-profile': 'get-site-profile',
155
+ /** set-site-profile - set site profile */
156
+ 'set-site-profile': 'set-site-profile',
157
+ },
158
+ /**
159
+ * CloudActionType
160
+ * - cloud 도메인 액션
161
+ */
162
+ CloudActionType: {
163
+ '': '',
164
+ /** update - update cloud profile */
165
+ update: 'update',
166
+ },
167
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `socket-inputs.ts`
3
+ * - public socket message.data input type barrel.
4
+ *
5
+ * Keep this file type-only and client-safe.
6
+ */
7
+ export type { AuthUpdateInput } from './auth/types';
8
+ export type { DeviceGetInput, DeviceReadInput, DeviceSaveInput, DeviceSyncInput } from './device/types';
9
+ export type { FindConnectionModelInput, SocketsFindConnectionInput } from './sockets/types';
10
+ export type { ChatFeedInput, ChatReadInput, ChatSendInput } from './chat/types';
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 { CloudUpdateInput, UpdateCloudInput } from './cloud/types';
13
+ export type { UserGetSiteProfileInput, UserInviteBatchInput, UserInviteInput, UserMakeSiteInput, UserMySiteInput, UserSetSiteProfileInput, UserUpdateProfileInput, UserUpdateSiteInput, } from './user/types';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * `socket-inputs.ts`
4
+ * - public socket message.data input type barrel.
5
+ *
6
+ * Keep this file type-only and client-safe.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ export * from './packets';
2
+ export interface FindConnectionModelEvent {
3
+ id?: string;
4
+ stage?: string;
5
+ domain?: string;
6
+ apiId?: string;
7
+ connectionId?: string;
8
+ connectedAt?: number;
9
+ origin?: string;
10
+ remote?: string;
11
+ reason?: string;
12
+ agent?: string;
13
+ route?: string;
14
+ param?: {
15
+ [key: string]: string;
16
+ };
17
+ }
18
+ export interface FindConnectionModelInput {
19
+ event: FindConnectionModelEvent;
20
+ }
21
+ export declare type SocketsFindConnectionInput = FindConnectionModelInput;
22
+ export interface FindConnectionModelOptions {
23
+ useSession?: boolean;
24
+ errScope?: string;
25
+ validate?: boolean;
26
+ current?: number;
27
+ }
@@ -0,0 +1,17 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./packets"), exports);
@@ -30,6 +30,8 @@ export interface SocketMessage<T = any, TType extends string = string> {
30
30
  meta?: SocketMessageMeta;
31
31
  /** optional error message */
32
32
  error?: string;
33
+ /** optional error code (HTTP status base); omitted when unclassified */
34
+ errorCode?: number;
33
35
  }
34
36
  /**
35
37
  * shared packet registry extension point.
@@ -0,0 +1,102 @@
1
+ import type { InferSocketRequest, SocketRequestMessage } from '../types';
2
+ export interface UserMakeSiteRequestData {
3
+ name: string;
4
+ }
5
+ export interface UserInviteRequestData {
6
+ channelId?: string;
7
+ name: string;
8
+ phone: string;
9
+ }
10
+ export interface UserInviteBatchRequestData {
11
+ to: string[];
12
+ channelId?: string;
13
+ cloudId?: string;
14
+ cloudName?: string;
15
+ }
16
+ export interface UserUpdateProfileRequestData {
17
+ name?: string;
18
+ nick?: string;
19
+ thumbnail?: string;
20
+ }
21
+ export interface UserUpdateSiteRequestData {
22
+ sid?: string;
23
+ name?: string;
24
+ thumbnail?: string;
25
+ }
26
+ export interface UserSetSiteProfileRequestData {
27
+ id?: string;
28
+ userId?: string;
29
+ siteId?: string;
30
+ nick?: string;
31
+ thumbnail?: string;
32
+ active?: boolean;
33
+ [key: string]: unknown;
34
+ }
35
+ declare module '../types' {
36
+ interface SocketPacketRegistry {
37
+ 'user.get-site-profile': {
38
+ request: Record<string, never>;
39
+ response: unknown;
40
+ error: null;
41
+ };
42
+ 'user.my-site': {
43
+ request: Record<string, never>;
44
+ response: unknown;
45
+ error: null;
46
+ };
47
+ 'user.make-site': {
48
+ request: UserMakeSiteRequestData;
49
+ response: unknown;
50
+ error: null;
51
+ };
52
+ 'user.invite': {
53
+ request: UserInviteRequestData;
54
+ response: unknown;
55
+ error: null;
56
+ };
57
+ 'user.invite-batch': {
58
+ request: UserInviteBatchRequestData;
59
+ response: unknown;
60
+ error: null;
61
+ };
62
+ 'user.update-profile': {
63
+ request: UserUpdateProfileRequestData;
64
+ response: unknown;
65
+ error: null;
66
+ };
67
+ 'user.update-site': {
68
+ request: UserUpdateSiteRequestData;
69
+ response: unknown;
70
+ error: null;
71
+ };
72
+ 'user.set-site-profile': {
73
+ request: UserSetSiteProfileRequestData;
74
+ response: unknown;
75
+ error: null;
76
+ };
77
+ }
78
+ }
79
+ export declare type UserGetSiteProfileType = 'user.get-site-profile';
80
+ export declare type UserGetSiteProfileInput = InferSocketRequest<UserGetSiteProfileType>;
81
+ export declare type UserGetSiteProfileRequestMessage = SocketRequestMessage<UserGetSiteProfileType>;
82
+ export declare type UserMySiteType = 'user.my-site';
83
+ export declare type UserMySiteInput = InferSocketRequest<UserMySiteType>;
84
+ export declare type UserMySiteRequestMessage = SocketRequestMessage<UserMySiteType>;
85
+ export declare type UserMakeSiteType = 'user.make-site';
86
+ export declare type UserMakeSiteInput = InferSocketRequest<UserMakeSiteType>;
87
+ export declare type UserMakeSiteRequestMessage = SocketRequestMessage<UserMakeSiteType>;
88
+ export declare type UserInviteType = 'user.invite';
89
+ export declare type UserInviteInput = InferSocketRequest<UserInviteType>;
90
+ export declare type UserInviteRequestMessage = SocketRequestMessage<UserInviteType>;
91
+ export declare type UserInviteBatchType = 'user.invite-batch';
92
+ export declare type UserInviteBatchInput = InferSocketRequest<UserInviteBatchType>;
93
+ export declare type UserInviteBatchRequestMessage = SocketRequestMessage<UserInviteBatchType>;
94
+ export declare type UserUpdateProfileType = 'user.update-profile';
95
+ export declare type UserUpdateProfileInput = InferSocketRequest<UserUpdateProfileType>;
96
+ export declare type UserUpdateProfileRequestMessage = SocketRequestMessage<UserUpdateProfileType>;
97
+ export declare type UserUpdateSiteType = 'user.update-site';
98
+ export declare type UserUpdateSiteInput = InferSocketRequest<UserUpdateSiteType>;
99
+ export declare type UserUpdateSiteRequestMessage = SocketRequestMessage<UserUpdateSiteType>;
100
+ export declare type UserSetSiteProfileType = 'user.set-site-profile';
101
+ export declare type UserSetSiteProfileInput = InferSocketRequest<UserSetSiteProfileType>;
102
+ export declare type UserSetSiteProfileRequestMessage = SocketRequestMessage<UserSetSiteProfileType>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemoncloud/chatic-sockets-lib",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Client websocket transport and sync runtime for chatic sockets v2",
5
5
  "main": "dist/client-socket-v2/index.js",
6
6
  "types": "dist/client-socket-v2/index.d.ts",