@jsb188/app 1.1.1 → 1.1.2
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/package.json +57 -42
- package/src/constants/agent.ts +74 -0
- package/src/constants/app.ts +389 -0
- package/src/constants/emoji.ts +9153 -0
- package/src/constants/other.ts +13 -0
- package/src/constants/user.ts +27 -0
- package/src/constants/wsActions.ts +49 -0
- package/src/i18n/account.ts +139 -0
- package/src/i18n/agent.ts +397 -0
- package/src/i18n/agentToolBusiness.ts +196 -0
- package/src/i18n/agentToolGrid.ts +137 -0
- package/src/i18n/agentToolWorkflow.ts +101 -0
- package/src/i18n/agent_note.ts +109 -0
- package/src/i18n/app.ts +124 -0
- package/src/i18n/auth.ts +128 -0
- package/src/i18n/billing.ts +7 -0
- package/src/i18n/c.ts +907 -0
- package/src/i18n/campaign.ts +919 -0
- package/src/i18n/country.ts +249 -0
- package/src/i18n/datetime.ts +66 -0
- package/src/i18n/editor.ts +58 -0
- package/src/i18n/error.ts +579 -0
- package/src/i18n/field_doc_editor.ts +21 -0
- package/src/i18n/field_doc_programs.ts +52 -0
- package/src/i18n/field_docs.ts +190 -0
- package/src/i18n/index.ts +64 -0
- package/src/i18n/log.ts +566 -0
- package/src/i18n/memory.ts +59 -0
- package/src/i18n/message.ts +13 -0
- package/src/i18n/note.ts +19 -0
- package/src/i18n/org.ts +306 -0
- package/src/i18n/schedule.ts +209 -0
- package/src/i18n/sheet.ts +339 -0
- package/src/i18n/sheet_formula.ts +165 -0
- package/src/i18n/workflow.ts +111 -0
- package/src/main.ts +89 -0
- package/src/platform.ts +166 -0
- package/src/types/ai.d.ts +63 -0
- package/src/types/app.d.ts +127 -0
- package/src/types/auth.d.ts +94 -0
- package/src/types/console.d.ts +3 -0
- package/src/types/node-polyglot.d.ts +23 -0
- package/src/types/other.d.ts +66 -0
- package/src/types.d.ts +29 -0
- package/src/utils/account.ts +97 -0
- package/src/utils/api.ts +358 -0
- package/src/utils/authSession.ts +24 -0
- package/src/utils/clientIP.ts +213 -0
- package/src/utils/color.ts +279 -0
- package/src/utils/cron.ts +310 -0
- package/src/utils/csv.ts +19 -0
- package/src/utils/datetime.ts +1394 -0
- package/src/utils/deferredSave.ts +89 -0
- package/src/utils/email.ts +39 -0
- package/src/utils/emoji.ts +174 -0
- package/src/utils/expression.helpers.ts +470 -0
- package/src/utils/expression.test.ts +793 -0
- package/src/utils/expression.ts +2261 -0
- package/src/utils/interval.ts +80 -0
- package/src/utils/language.ts +9 -0
- package/src/utils/logic.ts +299 -0
- package/src/utils/managedSession.ts +34 -0
- package/src/utils/managedSessionBff.test.ts +60 -0
- package/src/utils/managedSessionBff.ts +117 -0
- package/src/utils/number.ts +338 -0
- package/src/utils/object.ts +916 -0
- package/src/utils/promise.ts +98 -0
- package/src/utils/queryReset.ts +266 -0
- package/src/utils/recurringTask.ts +60 -0
- package/src/utils/schema.ts +293 -0
- package/src/utils/string.test.ts +278 -0
- package/src/utils/string.ts +709 -0
- package/{utils → src/utils}/timeZone.ts +531 -852
- package/src/utils/url_client.ts +206 -0
- package/tsconfig.json +12 -0
- package/constants/app.ts +0 -47
- package/constants/billing.ts +0 -146
- package/constants/emoji.ts +0 -8945
- package/constants/journal.ts +0 -74
- package/constants/user.ts +0 -36
- package/constants/ws.ts +0 -47
- package/i18n/app.ts +0 -101
- package/i18n/auth.ts +0 -63
- package/i18n/billing.ts +0 -94
- package/i18n/datetime.ts +0 -21
- package/i18n/error.ts +0 -143
- package/i18n/form.ts +0 -74
- package/i18n/index.ts +0 -5
- package/i18n/user.ts +0 -101
- package/main.ts +0 -94
- package/platform.ts +0 -125
- package/types/ai.d.ts +0 -30
- package/types/app.d.ts +0 -48
- package/types/auth.d.ts +0 -63
- package/types/form.d.ts +0 -56
- package/types/journal.d.ts +0 -24
- package/types/organization.d.ts +0 -38
- package/types/user.d.ts +0 -52
- package/types.d.ts +0 -31
- package/utils/api.ts +0 -99
- package/utils/billing.ts +0 -134
- package/utils/datetime.ts +0 -542
- package/utils/emoji.ts +0 -151
- package/utils/journal.ts +0 -17
- package/utils/logic.ts +0 -118
- package/utils/number.ts +0 -139
- package/utils/object.ts +0 -425
- package/utils/string.ts +0 -323
- package/utils/url_client.ts +0 -138
- package/utils/user.ts +0 -273
package/utils/user.ts
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import i18n from '../i18n/';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Types
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
type LightModeValue = 'LIGHT' | 'DARK' | 'SYSTEM';
|
|
8
|
-
type FriendStatusEnum = 'BLOCKED' | 'DECLINED' | 'PENDING' | 'ACCEPTED';
|
|
9
|
-
|
|
10
|
-
interface FriendFragment {
|
|
11
|
-
myStatus: FriendStatusEnum;
|
|
12
|
-
otherStatus: FriendStatusEnum;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface FriendOptionsObj {
|
|
16
|
-
friendButtonText: string;
|
|
17
|
-
friendButtonIconName: string;
|
|
18
|
-
friendStatusText: string;
|
|
19
|
-
messageAllowed: boolean;
|
|
20
|
-
options: {
|
|
21
|
-
value: string;
|
|
22
|
-
iconName: string;
|
|
23
|
-
text: string;
|
|
24
|
-
}[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type PlusGroupEnum = 'NORMAL' | 'PERKS' | 'PLUS' | 'PRO';
|
|
28
|
-
|
|
29
|
-
interface UserSubOutput {
|
|
30
|
-
name: string | null;
|
|
31
|
-
group: PlusGroupEnum;
|
|
32
|
-
cancelled: boolean;
|
|
33
|
-
expired: boolean;
|
|
34
|
-
expireAt: Date | null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Get light mode value
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
export function getLightMode(mode: string, mobileApp: boolean): LightModeValue {
|
|
42
|
-
if (!mode) {
|
|
43
|
-
return 'LIGHT';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const index = mobileApp ? 1 : 0;
|
|
47
|
-
const value = Number(mode.charAt(index));
|
|
48
|
-
|
|
49
|
-
return (['LIGHT', 'SYSTEM', 'DARK'][value] || 'LIGHT') as LightModeValue;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Update light mode value
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
export function updateLightMode(mode_: string | undefined, newValue: LightModeValue, mobileApp: boolean): string {
|
|
57
|
-
const mode = mode_ || '00';
|
|
58
|
-
const index = mobileApp ? 1 : 0;
|
|
59
|
-
|
|
60
|
-
let value = ['LIGHT', 'SYSTEM', 'DARK'].indexOf(newValue);
|
|
61
|
-
if (value === -1) {
|
|
62
|
-
value = 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return mode.substring(0, index) + value + mode.substring(index + 1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Resolve user's online status for chat
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
export function resolveOnlineStatus(user: object, viewerUserId: number) {
|
|
73
|
-
// console.log('..... RESOLVE ONLINE STATUS .....', user.id, viewerUserId, user.onlineStatus);
|
|
74
|
-
if (
|
|
75
|
-
// This check won't be valid if user is switching logins;
|
|
76
|
-
// So for those cases, use [user.self = true],
|
|
77
|
-
// to validate that this is a self online status
|
|
78
|
-
viewerUserId == user.id ||
|
|
79
|
-
user.self
|
|
80
|
-
) {
|
|
81
|
-
return user.onlineStatus;
|
|
82
|
-
} else if (!user.lastLoginAt) {
|
|
83
|
-
return 'APPEAR_OFFLINE';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const now = Date.now();
|
|
87
|
-
const wasOnline = (now - user.lastLoginAt) < 420000; // 7 minutes
|
|
88
|
-
|
|
89
|
-
if (wasOnline) {
|
|
90
|
-
return user.onlineStatus;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return 'APPEAR_OFFLINE';
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Get friend status between 2 users
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
export function getFriendOptions(friend?: FriendFragment | null): FriendOptionsObj {
|
|
101
|
-
const { myStatus, otherStatus } = friend || {};
|
|
102
|
-
if (myStatus === 'BLOCKED') {
|
|
103
|
-
// Blocked by user
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
friendButtonText: i18n.t('user.blocked'),
|
|
107
|
-
friendStatusText: i18n.t('user.blocked_by_me'),
|
|
108
|
-
friendButtonIconName: 'user-x',
|
|
109
|
-
messageAllowed: false,
|
|
110
|
-
options: [{
|
|
111
|
-
value: 'DECLINED',
|
|
112
|
-
iconName: 'user',
|
|
113
|
-
text: i18n.t('user.unblock'),
|
|
114
|
-
}],
|
|
115
|
-
};
|
|
116
|
-
} else if (otherStatus === 'BLOCKED') {
|
|
117
|
-
// Blocked by "other" user
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
friendButtonText: i18n.t('user.blocked'),
|
|
121
|
-
friendStatusText: i18n.t('user.blocked_by_other'),
|
|
122
|
-
friendButtonIconName: 'user-x',
|
|
123
|
-
messageAllowed: false,
|
|
124
|
-
options: [],
|
|
125
|
-
};
|
|
126
|
-
} else if (myStatus === 'ACCEPTED' && otherStatus === 'ACCEPTED') {
|
|
127
|
-
// Friends
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
friendButtonText: i18n.t('user.friends'),
|
|
131
|
-
friendStatusText: i18n.t('user.friends_msg'),
|
|
132
|
-
friendButtonIconName: 'user-check',
|
|
133
|
-
messageAllowed: true,
|
|
134
|
-
options: [{
|
|
135
|
-
value: 'DECLINED',
|
|
136
|
-
iconName: 'user-cancel',
|
|
137
|
-
text: i18n.t('user.remove_friend'),
|
|
138
|
-
}, {
|
|
139
|
-
value: 'BLOCKED',
|
|
140
|
-
iconName: 'user-x',
|
|
141
|
-
text: i18n.t('user.block'),
|
|
142
|
-
}],
|
|
143
|
-
};
|
|
144
|
-
} else if (myStatus === 'PENDING') {
|
|
145
|
-
// Pending request from other user
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
friendButtonText: i18n.t('user.friend_request'),
|
|
149
|
-
friendStatusText: i18n.t('user.add_friend_msg'),
|
|
150
|
-
friendButtonIconName: 'user-plus',
|
|
151
|
-
messageAllowed: false,
|
|
152
|
-
options: [{
|
|
153
|
-
value: 'ACCEPTED',
|
|
154
|
-
iconName: 'user-check',
|
|
155
|
-
text: i18n.t('user.accept_friend'),
|
|
156
|
-
}, {
|
|
157
|
-
value: 'DECLINED',
|
|
158
|
-
iconName: 'user-cancel',
|
|
159
|
-
text: i18n.t('user.ignore_friend'),
|
|
160
|
-
}, {
|
|
161
|
-
value: 'BLOCKED',
|
|
162
|
-
iconName: 'user-x',
|
|
163
|
-
text: i18n.t('user.block'),
|
|
164
|
-
}],
|
|
165
|
-
};
|
|
166
|
-
} else if (otherStatus === 'PENDING') {
|
|
167
|
-
// Sent a friend request; now waiting
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
friendButtonText: i18n.t('user.friend_requested'),
|
|
171
|
-
friendStatusText: i18n.t('user.sent_friend_msg'),
|
|
172
|
-
friendButtonIconName: 'mail',
|
|
173
|
-
messageAllowed: false,
|
|
174
|
-
options: [{
|
|
175
|
-
value: 'DECLINED',
|
|
176
|
-
iconName: 'user-cancel',
|
|
177
|
-
text: i18n.t('user.cancel_friend'),
|
|
178
|
-
}],
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// No actions taken, user can/should send request
|
|
183
|
-
return {
|
|
184
|
-
friendButtonText: i18n.t('user.add_friend'),
|
|
185
|
-
friendStatusText: i18n.t('user.add_friend_msg'),
|
|
186
|
-
friendButtonIconName: 'user-plus',
|
|
187
|
-
messageAllowed: false,
|
|
188
|
-
options: [{
|
|
189
|
-
value: 'PENDING',
|
|
190
|
-
iconName: 'mail',
|
|
191
|
-
text: i18n.t('user.send_friend'),
|
|
192
|
-
}, {
|
|
193
|
-
value: 'BLOCKED',
|
|
194
|
-
iconName: 'user-x',
|
|
195
|
-
text: i18n.t('user.block'),
|
|
196
|
-
}],
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Get user subscription type
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
export const getPlusStatus = (plus: any) => {
|
|
205
|
-
if (!plus || plus.expireAt <= Date.now()) {
|
|
206
|
-
return 'NORMAL';
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
switch (plus.type) {
|
|
210
|
-
case 'kajiwoto_plus':
|
|
211
|
-
case 'kajiwoto_plus_yearly':
|
|
212
|
-
case 'big_planet_plus':
|
|
213
|
-
case 'big_planet_plus_yearly':
|
|
214
|
-
return 'PLUS';
|
|
215
|
-
case 'kajiwoto_pro':
|
|
216
|
-
case 'kajiwoto_pro_yearly':
|
|
217
|
-
case 'big_planet_pro':
|
|
218
|
-
case 'big_planet_pro_yearly':
|
|
219
|
-
return 'PRO';
|
|
220
|
-
case 'perks':
|
|
221
|
-
return 'PERKS';
|
|
222
|
-
default:
|
|
223
|
-
return 'NORMAL';
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Get user's subscription & status
|
|
229
|
-
*/
|
|
230
|
-
|
|
231
|
-
export const getUserSubscription = (plus: any): UserSubOutput => {
|
|
232
|
-
if (!plus) {
|
|
233
|
-
return {
|
|
234
|
-
name: null,
|
|
235
|
-
group: 'NORMAL',
|
|
236
|
-
cancelled: false,
|
|
237
|
-
expired: false,
|
|
238
|
-
expireAt: null,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const expired = (new Date(plus.expireAt)).getTime() < Date.now();
|
|
243
|
-
|
|
244
|
-
let group: PlusGroupEnum = 'NORMAL';
|
|
245
|
-
if (!expired) {
|
|
246
|
-
switch (plus.type) {
|
|
247
|
-
case 'kajiwoto_plus':
|
|
248
|
-
case 'kajiwoto_plus_yearly':
|
|
249
|
-
case 'big_planet_plus':
|
|
250
|
-
case 'big_planet_plus_yearly':
|
|
251
|
-
group = 'PLUS';
|
|
252
|
-
break;
|
|
253
|
-
case 'kajiwoto_pro':
|
|
254
|
-
case 'kajiwoto_pro_yearly':
|
|
255
|
-
case 'big_planet_pro':
|
|
256
|
-
case 'big_planet_pro_yearly':
|
|
257
|
-
group = 'PRO';
|
|
258
|
-
break;
|
|
259
|
-
case 'perks':
|
|
260
|
-
group = 'PERKS';
|
|
261
|
-
break;
|
|
262
|
-
default:
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return {
|
|
267
|
-
name: plus.type,
|
|
268
|
-
group,
|
|
269
|
-
cancelled: !!plus.cancelled,
|
|
270
|
-
expired,
|
|
271
|
-
expireAt: plus.expireAt,
|
|
272
|
-
};
|
|
273
|
-
};
|