sim-sdk-web 1.0.2 → 1.0.4

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,133 @@
1
+ export declare enum MessageReceiveOptType {
2
+ Nomal = 0,
3
+ NotReceive = 1,
4
+ NotNotify = 2
5
+ }
6
+ export declare enum AllowType {
7
+ Allowed = 0,
8
+ NotAllowed = 1
9
+ }
10
+ export declare enum GroupType {
11
+ Group = 2,
12
+ WorkingGroup = 2
13
+ }
14
+ export declare enum GroupJoinSource {
15
+ Invitation = 2,
16
+ Search = 3,
17
+ QrCode = 4
18
+ }
19
+ export declare enum GroupMemberRole {
20
+ Nomal = 20,
21
+ Admin = 60,
22
+ Owner = 100
23
+ }
24
+ export declare enum GroupVerificationType {
25
+ ApplyNeedInviteNot = 0,
26
+ AllNeed = 1,
27
+ AllNot = 2
28
+ }
29
+ export declare enum MessageStatus {
30
+ Sending = 1,
31
+ Succeed = 2,
32
+ Failed = 3
33
+ }
34
+ export declare enum Platform {
35
+ iOS = 1,
36
+ Android = 2,
37
+ Windows = 3,
38
+ MacOSX = 4,
39
+ Web = 5,
40
+ Linux = 7,
41
+ AndroidPad = 8,
42
+ iPad = 9
43
+ }
44
+ export declare enum LogLevel {
45
+ Debug = 5,
46
+ Info = 4,
47
+ Warn = 3,
48
+ Error = 2,
49
+ Fatal = 1,
50
+ Panic = 0
51
+ }
52
+ export declare enum ApplicationHandleResult {
53
+ Unprocessed = 0,
54
+ Agree = 1,
55
+ Reject = -1
56
+ }
57
+ export declare enum MessageType {
58
+ MESSAGE_TYPE_TEXT = 0,
59
+ TextMessage = 101,
60
+ PictureMessage = 102,
61
+ VoiceMessage = 103,
62
+ VideoMessage = 104,
63
+ FileMessage = 105,
64
+ AtTextMessage = 106,
65
+ MergeMessage = 107,
66
+ CardMessage = 108,
67
+ LocationMessage = 109,
68
+ CustomMessage = 110,
69
+ TypingMessage = 113,
70
+ QuoteMessage = 114,
71
+ FaceMessage = 115,
72
+ FriendAdded = 1201,
73
+ OANotification = 1400,
74
+ GroupCreated = 1501,
75
+ MemberQuit = 1504,
76
+ GroupOwnerTransferred = 1507,
77
+ MemberKicked = 1508,
78
+ MemberInvited = 1509,
79
+ MemberEnter = 1510,
80
+ GroupDismissed = 1511,
81
+ GroupMemberMuted = 1512,
82
+ GroupMemberCancelMuted = 1513,
83
+ GroupMuted = 1514,
84
+ GroupCancelMuted = 1515,
85
+ GroupAnnouncementUpdated = 1519,
86
+ GroupNameUpdated = 1520,
87
+ BurnMessageChange = 1701,
88
+ RevokeMessage = 2101
89
+ }
90
+ export declare enum SessionType {
91
+ Single = 1,
92
+ Group = 3,
93
+ WorkingGroup = 3,
94
+ Notification = 4
95
+ }
96
+ export declare enum GroupStatus {
97
+ Nomal = 0,
98
+ Baned = 1,
99
+ Dismissed = 2,
100
+ Muted = 3
101
+ }
102
+ export declare enum GroupAtType {
103
+ AtNormal = 0,
104
+ AtMe = 1,
105
+ AtAll = 2,
106
+ AtAllAtMe = 3,
107
+ AtGroupNotice = 4
108
+ }
109
+ export declare enum GroupMemberFilter {
110
+ All = 0,
111
+ Owner = 1,
112
+ Admin = 2,
113
+ Nomal = 3,
114
+ AdminAndNomal = 4,
115
+ AdminAndOwner = 5
116
+ }
117
+ export declare enum Relationship {
118
+ isBlack = 0,
119
+ isFriend = 1
120
+ }
121
+ export declare enum LoginStatus {
122
+ Logout = 1,
123
+ Logging = 2,
124
+ Logged = 3
125
+ }
126
+ export declare enum OnlineState {
127
+ Online = 1,
128
+ Offline = 0
129
+ }
130
+ export declare enum GroupMessageReaderFilter {
131
+ Readed = 0,
132
+ UnRead = 1
133
+ }
@@ -0,0 +1,261 @@
1
+ import type { AtUsersInfoItem, GroupItem, MessageItem, OfflinePush, PicBaseInfo, SelfUserInfo } from './entity';
2
+ import type { GroupJoinSource, GroupMemberFilter, GroupMemberRole, MessageReceiveOptType, MessageType } from './enum';
3
+ export type LoginParams = {
4
+ appKey: string;
5
+ userId: string;
6
+ token: string;
7
+ platformID: number;
8
+ };
9
+ export type SetSelfInfoParams = Partial<SelfUserInfo>;
10
+ export type GetUserInfoWithCacheParams = {
11
+ userIDList: string[];
12
+ groupID?: string;
13
+ };
14
+ export type SplitConversationParams = {
15
+ offset: number;
16
+ count: number;
17
+ };
18
+ export type GetOneConversationParams = {
19
+ sourceID: string;
20
+ sessionType: number;
21
+ };
22
+ export type SetConversationDraftParams = {
23
+ conversationID: string;
24
+ draftText: string;
25
+ };
26
+ export type PinConversationParams = {
27
+ conversationID: string;
28
+ isPinned: boolean;
29
+ };
30
+ export type SetConversationRecvOptParams = {
31
+ conversationID: string;
32
+ opt: MessageReceiveOptType;
33
+ };
34
+ export type SetConversationPrivateParams = {
35
+ conversationID: string;
36
+ isPrivate: boolean;
37
+ };
38
+ export type SetBurnDurationParams = {
39
+ conversationID: string;
40
+ burnDuration: number;
41
+ };
42
+ export type AccessFriendParams = {
43
+ toUserID: string;
44
+ handleMsg: string;
45
+ };
46
+ export type AddBlackParams = {
47
+ toUserID: string;
48
+ ex?: string;
49
+ };
50
+ export type SearchFriendParams = {
51
+ keywordList: string[];
52
+ isSearchUserID: boolean;
53
+ isSearchNickname: boolean;
54
+ isSearchRemark: boolean;
55
+ };
56
+ export type RemarkFriendParams = {
57
+ toUserID: string;
58
+ remark: string;
59
+ };
60
+ export type CreateGroupParams = {
61
+ memberUserIDs: string[];
62
+ groupInfo: Partial<GroupItem>;
63
+ adminUserIDs?: string[];
64
+ ownerUserID?: string;
65
+ };
66
+ export type JoinGroupParams = {
67
+ groupID: string;
68
+ reqMsg: string;
69
+ joinSource: GroupJoinSource;
70
+ ex?: string;
71
+ };
72
+ export type OpreateGroupParams = {
73
+ groupID: string;
74
+ reason: string;
75
+ userIDList: string[];
76
+ };
77
+ export type SearchGroupParams = {
78
+ keywordList: string[];
79
+ isSearchGroupID: boolean;
80
+ isSearchGroupName: boolean;
81
+ };
82
+ export type SetGroupinfoParams = Partial<GroupItem> & {
83
+ groupID: string;
84
+ };
85
+ export type AccessGroupParams = {
86
+ groupID: string;
87
+ fromUserID: string;
88
+ handleMsg: string;
89
+ };
90
+ export declare type GetGroupMemberParams = {
91
+ groupID: string;
92
+ filter: GroupMemberFilter;
93
+ offset: number;
94
+ count: number;
95
+ };
96
+ export type getGroupMembersInfoParams = {
97
+ groupID: string;
98
+ userIDList: string[];
99
+ };
100
+ export type SearchGroupMemberParams = {
101
+ groupID: string;
102
+ keywordList: string[];
103
+ isSearchUserID: boolean;
104
+ isSearchMemberNickname: boolean;
105
+ offset: number;
106
+ count: number;
107
+ };
108
+ export type UpdateMemberInfoParams = {
109
+ groupID: string;
110
+ userId: string;
111
+ nickname?: string;
112
+ faceURL?: string;
113
+ roleLevel?: GroupMemberRole;
114
+ ex?: string;
115
+ };
116
+ export type GetGroupMemberByTimeParams = {
117
+ groupID: string;
118
+ filterUserIDList: string[];
119
+ offset: number;
120
+ count: number;
121
+ joinTimeBegin: number;
122
+ joinTimeEnd: number;
123
+ };
124
+ export type ChangeGroupMemberMuteParams = {
125
+ groupID: string;
126
+ userId: string;
127
+ mutedSeconds: number;
128
+ };
129
+ export type ChangeGroupMuteParams = {
130
+ groupID: string;
131
+ isMute: boolean;
132
+ };
133
+ export type TransferGroupParams = {
134
+ groupID: string;
135
+ newOwnerUserID: string;
136
+ };
137
+ export type AtMsgParams = {
138
+ text: string;
139
+ atUserIDList: string[];
140
+ atUsersInfo?: AtUsersInfoItem[];
141
+ message?: MessageItem;
142
+ };
143
+ export type ImageMsgParams = {
144
+ sourcePicture: PicBaseInfo;
145
+ bigPicture: PicBaseInfo;
146
+ snapshotPicture: PicBaseInfo;
147
+ sourcePath: string;
148
+ };
149
+ export type SoundMsgParams = {
150
+ uuid: string;
151
+ soundPath: string;
152
+ sourceUrl: string;
153
+ dataSize: number;
154
+ duration: number;
155
+ soundType?: string;
156
+ };
157
+ export type VideoMsgParams = {
158
+ videoPath: string;
159
+ duration: number;
160
+ videoType: string;
161
+ snapshotPath: string;
162
+ videoUUID: string;
163
+ videoUrl: string;
164
+ videoSize: number;
165
+ snapshotUUID: string;
166
+ snapshotSize: number;
167
+ snapshotUrl: string;
168
+ snapshotWidth: number;
169
+ snapshotHeight: number;
170
+ snapShotType?: string;
171
+ };
172
+ export type FileMsgParams = {
173
+ filePath: string;
174
+ fileName: string;
175
+ uuid: string;
176
+ sourceUrl: string;
177
+ fileSize: number;
178
+ fileType?: string;
179
+ };
180
+ export type MergerMsgParams = {
181
+ messageList: MessageItem[];
182
+ title: string;
183
+ summaryList: string[];
184
+ };
185
+ export type LocationMsgParams = {
186
+ description: string;
187
+ longitude: number;
188
+ latitude: number;
189
+ };
190
+ export type QuoteMsgParams = {
191
+ text: string;
192
+ message: string;
193
+ };
194
+ export type CustomMsgParams = {
195
+ data: string;
196
+ extension: string;
197
+ description: string;
198
+ };
199
+ export type FaceMessageParams = {
200
+ index: number;
201
+ data: string;
202
+ };
203
+ export type SendMsgParams = {
204
+ recvID: string;
205
+ groupID: string;
206
+ offlinePushInfo?: OfflinePush;
207
+ message: MessageItem;
208
+ isOnlineOnly?: boolean;
209
+ };
210
+ export type TypingUpdateParams = {
211
+ recvID: string;
212
+ msgTip: string;
213
+ };
214
+ export type OpreateMessageParams = {
215
+ conversationID: string;
216
+ clientMsgID: string;
217
+ };
218
+ export type SearchLocalParams = {
219
+ conversationID: string;
220
+ keywordList: string[];
221
+ keywordListMatchType?: number;
222
+ senderUserIDList?: string[];
223
+ messageTypeList?: MessageType[];
224
+ searchTimePosition?: number;
225
+ searchTimePeriod?: number;
226
+ pageIndex?: number;
227
+ count?: number;
228
+ };
229
+ export type GetAdvancedHistoryMsgParams = {
230
+ userId?: string;
231
+ groupID?: string;
232
+ lastMinSeq: number;
233
+ count: number;
234
+ startClientMsgID: string;
235
+ conversationID: string;
236
+ };
237
+ export type FindMessageParams = {
238
+ conversationID: string;
239
+ clientMsgIDList: string[];
240
+ };
241
+ export type InsertGroupMsgParams = {
242
+ message: MessageItem;
243
+ groupID: string;
244
+ sendID: string;
245
+ };
246
+ export type InsertSingleMsgParams = {
247
+ message: MessageItem;
248
+ recvID: string;
249
+ sendID: string;
250
+ };
251
+ export type SetMessageLocalExParams = {
252
+ conversationID: string;
253
+ clientMsgID: string;
254
+ localEx: string;
255
+ };
256
+ export declare type UploadFileParams = {
257
+ name?: string;
258
+ contentType?: string;
259
+ uuid?: string;
260
+ file: File;
261
+ };
@@ -0,0 +1,44 @@
1
+ export interface CommonOptions {
2
+ token: string;
3
+ }
4
+ export interface UploadParams {
5
+ hash: string;
6
+ size: number;
7
+ partSize: number;
8
+ maxParts: number;
9
+ cause: string;
10
+ name: string;
11
+ contentType: string;
12
+ }
13
+ export interface ConfirmData {
14
+ uploadID: string;
15
+ parts: string[];
16
+ cause: string;
17
+ name: string;
18
+ contentType: string;
19
+ }
20
+ export interface UploadData {
21
+ url: string;
22
+ upload: Upload;
23
+ }
24
+ export interface Upload {
25
+ uploadID: string;
26
+ partSize: number;
27
+ sign: Sign;
28
+ }
29
+ export interface Sign {
30
+ url: string;
31
+ query?: KeyForValueList[];
32
+ header?: KeyForValueList[];
33
+ parts: Part[];
34
+ }
35
+ export interface Part {
36
+ partNumber: number;
37
+ url: string;
38
+ query?: KeyForValueList[];
39
+ header?: KeyForValueList[];
40
+ }
41
+ export interface KeyForValueList {
42
+ key: string;
43
+ values: string[];
44
+ }
@@ -0,0 +1,25 @@
1
+ import type { SseResponse } from '../types/entity';
2
+ interface SseOptions {
3
+ url: string;
4
+ retryInterval?: number;
5
+ maxRetries?: number;
6
+ onMessage: (response: SseResponse) => void;
7
+ onReconnectSuccess: () => void;
8
+ }
9
+ declare class SseManager {
10
+ private url;
11
+ private retryInterval;
12
+ private maxRetries;
13
+ private reconnectAttempts;
14
+ private eventSource;
15
+ private connected;
16
+ private onMessage;
17
+ private onReconnectSuccess;
18
+ constructor(options: SseOptions);
19
+ connect: () => Promise<string>;
20
+ private handleMessage;
21
+ private reconnect;
22
+ close(): void;
23
+ isConnected(): boolean;
24
+ }
25
+ export default SseManager;
@@ -0,0 +1,11 @@
1
+ import { CbEvents } from '../constant/callback';
2
+ import type { SseResponse } from '../types/entity';
3
+ type Cbfn = (data: SseResponse) => void;
4
+ declare class Emitter {
5
+ private events;
6
+ constructor();
7
+ emit(event: CbEvents, data: SseResponse): this;
8
+ on(event: CbEvents, fn: Cbfn): this;
9
+ off(event: CbEvents, fn: Cbfn): this | undefined;
10
+ }
11
+ export default Emitter;
@@ -0,0 +1,17 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
3
+ interface RequestOptions extends AxiosRequestConfig {
4
+ url: string;
5
+ method?: HttpMethod;
6
+ headers?: Record<string, string>;
7
+ params?: Record<string, any>;
8
+ data?: Record<string, any>;
9
+ body?: any;
10
+ }
11
+ export declare const request: <T>(options: RequestOptions) => Promise<T>;
12
+ export declare const get: <T>(url: string, params?: Record<string, any>) => Promise<T>;
13
+ export declare const post: <T>(url: string, data?: Record<string, any>) => Promise<T>;
14
+ export declare const put: <T>(url: string, data?: Record<string, any>) => Promise<T>;
15
+ export declare const del: <T>(url: string, data?: Record<string, any>) => Promise<T>;
16
+ export declare const uploadFile: <T>(url: string, filePath: string | File, name: string, formData?: Record<string, any>) => Promise<T>;
17
+ export {};
@@ -0,0 +1,9 @@
1
+ import { CommonOptions, ConfirmData, UploadData, UploadParams } from '../types/upload';
2
+ export declare const getUploadPartsize: (baseUrl: string, size: number, commonOptions: CommonOptions) => Promise<{
3
+ size: number;
4
+ }>;
5
+ export declare const getUploadUrl: (baseUrl: string, params: UploadParams, commonOptions: CommonOptions) => Promise<UploadData>;
6
+ export declare const confirmUpload: (baseUrl: string, params: ConfirmData, commonOptions: CommonOptions) => Promise<{
7
+ url: string;
8
+ }>;
9
+ export declare const getMimeType: (fileName: string) => string;
@@ -0,0 +1 @@
1
+ export declare const uuid: () => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-sdk-web",
3
- "version": "v1.0.2",
3
+ "version": "v1.0.4",
4
4
  "description": "Sim SDK for Web",
5
5
  "source": "src/index.ts",
6
6
  "main": "lib/index.js",
@@ -18,16 +18,14 @@
18
18
  "scripts": {
19
19
  "build": "rimraf lib && microbundle --no-sourcemap && tsc-alias",
20
20
  "obfuscate": "javascript-obfuscator lib --output lib --config javascript-obfuscator-config.json",
21
- "build:rollup": "rimraf dist && rollup -c --bundleConfigAsCjs && rollup -c --bundleConfigAsCjs rollup.dts.config.js",
22
-
21
+ "build:rollup": "rimraf dist && rollup -c --bundleConfigAsCjs && rollup -c --bundleConfigAsCjs rollup.dts.config.js.cc",
23
22
  "test": "jest",
24
23
  "lint": "eslint . --ext .ts",
25
24
  "format": "prettier --write .",
26
25
  "release": "semantic-release"
27
26
  },
28
27
  "files": [
29
- "lib/**/*",
30
- "dist/**/*"
28
+ "lib/**/*"
31
29
  ],
32
30
  "keywords": [
33
31
  "Sim",
@@ -36,21 +34,10 @@
36
34
  ],
37
35
  "license": "Apache-2.0",
38
36
  "devDependencies": {
39
- "@babel/core": "^7.21.3",
40
- "@babel/plugin-transform-runtime": "^7.21.0",
41
- "@babel/preset-env": "^7.20.2",
42
- "@rollup/plugin-babel": "^6.0.3",
43
- "@rollup/plugin-commonjs": "^24.0.1",
44
- "@rollup/plugin-json": "^6.0.0",
45
- "@rollup/plugin-node-resolve": "^15.0.1",
46
- "@rollup/plugin-terser": "^0.4.0",
47
37
  "@types/spark-md5": "^3.0.3",
48
38
  "@typescript-eslint/parser": "^6.9.1",
49
- "javascript-obfuscator": "^4.1.1",
50
39
  "microbundle": "^0.15.1",
51
40
  "prettier": "^3.0.3",
52
- "rollup-plugin-dts": "^6.1.1",
53
- "rollup-plugin-typescript2": "^0.36.0",
54
41
  "semantic-release": "^22.0.6",
55
42
  "spark-md5": "^3.0.2",
56
43
  "tsc-alias": "^1.8.8",