@jsb188/app 1.0.4 → 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.
Files changed (104) hide show
  1. package/package.json +57 -37
  2. package/src/constants/agent.ts +74 -0
  3. package/src/constants/app.ts +389 -0
  4. package/src/constants/emoji.ts +9153 -0
  5. package/src/constants/other.ts +13 -0
  6. package/src/constants/user.ts +27 -0
  7. package/src/constants/wsActions.ts +49 -0
  8. package/src/i18n/account.ts +139 -0
  9. package/src/i18n/agent.ts +397 -0
  10. package/src/i18n/agentToolBusiness.ts +196 -0
  11. package/src/i18n/agentToolGrid.ts +137 -0
  12. package/src/i18n/agentToolWorkflow.ts +101 -0
  13. package/src/i18n/agent_note.ts +109 -0
  14. package/src/i18n/app.ts +124 -0
  15. package/src/i18n/auth.ts +128 -0
  16. package/src/i18n/billing.ts +7 -0
  17. package/src/i18n/c.ts +907 -0
  18. package/src/i18n/campaign.ts +919 -0
  19. package/src/i18n/country.ts +249 -0
  20. package/src/i18n/datetime.ts +66 -0
  21. package/src/i18n/editor.ts +58 -0
  22. package/src/i18n/error.ts +579 -0
  23. package/src/i18n/field_doc_editor.ts +21 -0
  24. package/src/i18n/field_doc_programs.ts +52 -0
  25. package/src/i18n/field_docs.ts +190 -0
  26. package/src/i18n/index.ts +64 -0
  27. package/src/i18n/log.ts +566 -0
  28. package/src/i18n/memory.ts +59 -0
  29. package/src/i18n/message.ts +13 -0
  30. package/src/i18n/note.ts +19 -0
  31. package/src/i18n/org.ts +306 -0
  32. package/src/i18n/schedule.ts +209 -0
  33. package/src/i18n/sheet.ts +339 -0
  34. package/src/i18n/sheet_formula.ts +165 -0
  35. package/src/i18n/workflow.ts +111 -0
  36. package/src/main.ts +89 -0
  37. package/src/platform.ts +166 -0
  38. package/src/types/ai.d.ts +63 -0
  39. package/src/types/app.d.ts +127 -0
  40. package/src/types/auth.d.ts +94 -0
  41. package/src/types/console.d.ts +3 -0
  42. package/src/types/node-polyglot.d.ts +23 -0
  43. package/src/types/other.d.ts +66 -0
  44. package/src/types.d.ts +29 -0
  45. package/src/utils/account.ts +97 -0
  46. package/src/utils/api.ts +358 -0
  47. package/src/utils/authSession.ts +24 -0
  48. package/src/utils/clientIP.ts +213 -0
  49. package/src/utils/color.ts +279 -0
  50. package/src/utils/cron.ts +310 -0
  51. package/src/utils/csv.ts +19 -0
  52. package/src/utils/datetime.ts +1394 -0
  53. package/src/utils/deferredSave.ts +89 -0
  54. package/src/utils/email.ts +39 -0
  55. package/src/utils/emoji.ts +174 -0
  56. package/src/utils/expression.helpers.ts +470 -0
  57. package/src/utils/expression.test.ts +793 -0
  58. package/src/utils/expression.ts +2261 -0
  59. package/src/utils/interval.ts +80 -0
  60. package/src/utils/language.ts +9 -0
  61. package/src/utils/logic.ts +299 -0
  62. package/src/utils/managedSession.ts +34 -0
  63. package/src/utils/managedSessionBff.test.ts +60 -0
  64. package/src/utils/managedSessionBff.ts +117 -0
  65. package/src/utils/number.ts +338 -0
  66. package/src/utils/object.ts +916 -0
  67. package/src/utils/promise.ts +98 -0
  68. package/src/utils/queryReset.ts +266 -0
  69. package/src/utils/recurringTask.ts +60 -0
  70. package/src/utils/schema.ts +293 -0
  71. package/src/utils/string.test.ts +278 -0
  72. package/src/utils/string.ts +709 -0
  73. package/src/utils/timeZone.ts +2048 -0
  74. package/src/utils/url_client.ts +206 -0
  75. package/tsconfig.json +12 -0
  76. package/constants/app.ts +0 -47
  77. package/constants/billing.ts +0 -146
  78. package/constants/emoji.ts +0 -8945
  79. package/constants/user.ts +0 -36
  80. package/constants/ws.ts +0 -47
  81. package/i18n/app.ts +0 -99
  82. package/i18n/auth.ts +0 -57
  83. package/i18n/billing.ts +0 -94
  84. package/i18n/datetime.ts +0 -22
  85. package/i18n/error.ts +0 -138
  86. package/i18n/form.ts +0 -73
  87. package/i18n/index.ts +0 -6
  88. package/i18n/user.ts +0 -98
  89. package/main.ts +0 -62
  90. package/types/app.d.ts +0 -46
  91. package/types/datetime.d.ts +0 -10
  92. package/types/form.d.ts +0 -56
  93. package/types/user.d.ts +0 -52
  94. package/types.d.ts +0 -23
  95. package/utils/api.ts +0 -99
  96. package/utils/billing.ts +0 -134
  97. package/utils/datetime.ts +0 -358
  98. package/utils/emoji.ts +0 -151
  99. package/utils/logic.ts +0 -115
  100. package/utils/number.ts +0 -115
  101. package/utils/object.ts +0 -367
  102. package/utils/string.ts +0 -211
  103. package/utils/url_client.ts +0 -138
  104. package/utils/user.ts +0 -273
@@ -1,138 +0,0 @@
1
-
2
- type LinkType = 'USER' | 'KAJI' | 'DATASET' | 'VOICE' | 'FEED' | 'ROOM' | 'THREAD' | 'OTHER';
3
-
4
- // links to consider for User cards
5
- // instagram
6
- // tiktok
7
- // youtube
8
- // pinterest
9
- // twitch
10
- // linkedin
11
- // facebook
12
- // twiitter (x)
13
-
14
- /**
15
- * Uploaded assets
16
- */
17
-
18
- export function makeUploadsUrl(
19
- urlPath?: string | null,
20
- size?: string,
21
- animateGifs?: boolean,
22
- ): string {
23
- if (!urlPath) {
24
- return '';
25
- }
26
-
27
- let uriPrefix;
28
- if (
29
- urlPath.substring(urlPath.lastIndexOf('.')).toLowerCase() === '.gif' &&
30
- animateGifs
31
- ) {
32
- uriPrefix = 'original/';
33
- } else {
34
- switch (size) {
35
- case 'original':
36
- uriPrefix = 'original/';
37
- break;
38
- case 'large':
39
- case 'medium':
40
- uriPrefix = 'medium/';
41
- break;
42
- case 'small':
43
- case 'tiny':
44
- uriPrefix = 'small/';
45
- break;
46
- default:
47
- uriPrefix = 'small/';
48
- }
49
- }
50
- return 'https://static.chiefhappiness.co/' + uriPrefix + urlPath;
51
- }
52
-
53
- /**
54
- * Make chat URL
55
- */
56
-
57
- export function makeChatUrl(
58
- firstChatId?: string | null,
59
- secondChatId?: string | null,
60
- nextFirstChatId?: string | null,
61
- nextSecondChatId?: string | null,
62
- ) {
63
- const path = 'chat';
64
-
65
- if (
66
- nextFirstChatId &&
67
- nextFirstChatId === secondChatId
68
- ) {
69
- return `/${path}/${firstChatId}/${secondChatId}`;
70
- }
71
-
72
- const first = nextFirstChatId || firstChatId || 'none';
73
- const second = nextSecondChatId || secondChatId;
74
-
75
- if (first === second) {
76
- return `/${path}/${first}`;
77
- }
78
-
79
- return `/${path}/${first}${second ? `/${second}` : ''}`;
80
- }
81
-
82
- /**
83
- * Get default text for URL type
84
- */
85
-
86
- export function getUrlType(type: LinkType) {
87
- switch (type) {
88
- case 'USER':
89
- return 'User';
90
- case 'KAJI':
91
- return 'AI';
92
- case 'DATASET':
93
- return 'Dataset';
94
- case 'VOICE':
95
- return 'Voice';
96
- case 'FEED':
97
- return 'Feed post';
98
- case 'ROOM':
99
- return 'Room';
100
- case 'THREAD':
101
- return 'Forum thread';
102
- default:
103
- return 'Link';
104
- }
105
- }
106
-
107
- /**
108
- * Convert location search string to object
109
- */
110
-
111
- export function locationSearchToObject(searchParams?: string) {
112
- if (!searchParams) {
113
- return {};
114
- }
115
-
116
- const search = searchParams.substring(1);
117
- const searchParamsArray = search.split('&');
118
- const searchParamsObject: Record<string, string> = {};
119
-
120
- searchParamsArray.forEach((param) => {
121
- const [key, value] = param.split('=');
122
- searchParamsObject[key] = value;
123
- });
124
-
125
- return searchParamsObject;
126
- }
127
-
128
- /**
129
- * Check if current page is a chat page
130
- */
131
-
132
- export function isChatPage() {
133
- const pathname = globalThis?.location?.pathname?.toLowerCase();
134
- if (pathname) {
135
- return /^\/(?:chat|dm)\//i.test(pathname);
136
- }
137
- return false;
138
- }
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
- };