@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/string.ts
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
const NOT_ALLOWED_USERNAMES = [
|
|
2
|
-
'ai',
|
|
3
|
-
'kajiwoto',
|
|
4
|
-
];
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Combine list of class names
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export function cn(...classNames: (string | boolean | undefined | null)[]) {
|
|
11
|
-
return classNames.filter(Boolean).join(' ');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Shorten text to space with length limit
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export function shortenToSpace(
|
|
19
|
-
str: string,
|
|
20
|
-
len: number = 100,
|
|
21
|
-
ellipsis: string = '...',
|
|
22
|
-
): string {
|
|
23
|
-
if (!str || str.length < len) {
|
|
24
|
-
return str;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const trimmed = str.substring(0, len);
|
|
28
|
-
const spaceIndex = trimmed.lastIndexOf(' ');
|
|
29
|
-
|
|
30
|
-
if (spaceIndex < 0) {
|
|
31
|
-
return trimmed.substring(0, len) + ellipsis;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
trimmed.substring(0, Math.min(trimmed.length, spaceIndex)) +
|
|
36
|
-
ellipsis
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Shorten word to space, and remove article words
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
export function shortenName(str: string, len: number = 40): string {
|
|
45
|
-
const articleReplacedStart = str?.replace(/^(a|an|the|da|de|that|there|this|than|then)\b/i, '') || '';
|
|
46
|
-
if (articleReplacedStart.length < 5) {
|
|
47
|
-
return shortenToSpace(str, len, '');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const shortened = shortenToSpace(articleReplacedStart, len, '');
|
|
51
|
-
const articleReplacedEnd = shortened.replace(
|
|
52
|
-
/\b(a|an|the|da|de|that|there|this|than|then)$/i,
|
|
53
|
-
'',
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
if (articleReplacedEnd.length < 5) {
|
|
57
|
-
return shortened;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return articleReplacedEnd.trim();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Check if e-mail
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
export function isEmail(str: string) {
|
|
68
|
-
// return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(str);
|
|
69
|
-
const emailRegex =
|
|
70
|
-
/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
|
71
|
-
return emailRegex.test(str.trim());
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Convert various phone formats to international format
|
|
76
|
-
* @returns phone number in international format
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
export function convertToInternationalPhone(str: string) {
|
|
80
|
-
// Check if string has a character that isn't one of [(, ), +, -, " ", 0-9]
|
|
81
|
-
if (/[^0-9+\-\s().]/.test(str)) {
|
|
82
|
-
// Invalid
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const digits = str.replace(/[^0-9]/g, '');
|
|
87
|
-
if (digits.startsWith('0')) {
|
|
88
|
-
// Invalid
|
|
89
|
-
return null;
|
|
90
|
-
} else if (
|
|
91
|
-
!digits.startsWith('1') &&
|
|
92
|
-
digits.length === 10
|
|
93
|
-
) {
|
|
94
|
-
return '+1' + digits;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// If it doesn't start with a country code, assume it's already in international format
|
|
98
|
-
return '+' + digits;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Check if phone number
|
|
103
|
-
* @returns TRUE if starts with + and has 7-15 digits
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
export function isPhone(str: string, doNotConvertInternational: boolean = false) {
|
|
107
|
-
let phoneNumber: string | null = str.trim();
|
|
108
|
-
if (!doNotConvertInternational) {
|
|
109
|
-
phoneNumber = convertToInternationalPhone(phoneNumber);
|
|
110
|
-
if (!phoneNumber) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return /^\+[0-9]{7,15}$/.test(phoneNumber);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Check if valid username
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
export function isValidUsername(str: string) {
|
|
122
|
-
const username = str.replace(/^@/, '').toLowerCase();
|
|
123
|
-
return (
|
|
124
|
-
/^[a-z0-9_]+$/i.test(username) &&
|
|
125
|
-
!NOT_ALLOWED_USERNAMES.includes(username)
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Check if password is secure enough
|
|
131
|
-
* Rules:
|
|
132
|
-
* at least 8 characters long
|
|
133
|
-
* at least one lowercase letter
|
|
134
|
-
* at least one uppercase letter
|
|
135
|
-
* at least one special character
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
export function passwordStrength(str: string, minLength: number = 8) {
|
|
139
|
-
const isLongEnough = str.length >= minLength;
|
|
140
|
-
const hasLowercase = /[a-z]/.test(str);
|
|
141
|
-
const hasUppercase = /[A-Z]/.test(str);
|
|
142
|
-
const hasDigit = /\d/.test(str);
|
|
143
|
-
const hasSpecial = /\W/.test(str);
|
|
144
|
-
const valid = isLongEnough && hasLowercase && hasUppercase && hasDigit &&
|
|
145
|
-
hasSpecial;
|
|
146
|
-
// return /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*\W)[a-zA-Z\d\W]{8,}$/.test(str);
|
|
147
|
-
return {
|
|
148
|
-
valid,
|
|
149
|
-
isLongEnough,
|
|
150
|
-
hasLowercase,
|
|
151
|
-
hasUppercase,
|
|
152
|
-
hasDigit,
|
|
153
|
-
hasSpecial,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Get time base unique string
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
export function getTimeBasedUnique() {
|
|
162
|
-
return Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Convert string to alphanumeric (or space) only
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
export function getAlphanumeric(str: string, space: boolean = false) {
|
|
170
|
-
return str.replace(space ? /[^a-z0-9\s]/gi : /[^a-z0-9]/gi, '');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Get regex patterns from a text
|
|
175
|
-
*/
|
|
176
|
-
|
|
177
|
-
export function regexFromText(text: string) {
|
|
178
|
-
const words = getAlphanumeric(text, true).split(/\s+/).filter((s) => s.length >= 2);
|
|
179
|
-
if (!words.length) {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return new RegExp(
|
|
184
|
-
'\\b' + (words.length === 1 ? words[0] : '(?:' + words.join('|') + ')'),
|
|
185
|
-
'gi',
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Upper case first letter
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
export function ucFirst(str: string) {
|
|
194
|
-
if (!str) {
|
|
195
|
-
return '';
|
|
196
|
-
}
|
|
197
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Convert cameCalsed string to dash-separated
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
export function camelCaseToDash(str: string) {
|
|
205
|
-
if (/^[A-Z0-9]+$/.test(str)) {
|
|
206
|
-
return str.toLowerCase();
|
|
207
|
-
}
|
|
208
|
-
return str.replace(/[A-Z0-9]/g, (m, i) => {
|
|
209
|
-
return `${i ? '-' : ''}${m.toLowerCase()}`;
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Shorten text to a paragraph length
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
export function shortenToParagraph(str: string, len: number, replaceDoubleLineBreaks?: boolean) {
|
|
218
|
-
let trimedToParagraph = str || '';
|
|
219
|
-
if (replaceDoubleLineBreaks) {
|
|
220
|
-
trimedToParagraph = trimedToParagraph.replace(/\n\s*\n/g, '\n');
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
trimedToParagraph = trimedToParagraph.split('\n').reduce((acc, str) => {
|
|
224
|
-
if (acc.done) {
|
|
225
|
-
return acc;
|
|
226
|
-
}
|
|
227
|
-
acc.done = (acc.value.length + str.length) >= len;
|
|
228
|
-
acc.value = acc.done ? acc.value : acc.value + '\n' + str;
|
|
229
|
-
return acc;
|
|
230
|
-
}, {
|
|
231
|
-
done: false,
|
|
232
|
-
value: '',
|
|
233
|
-
}).value.trim();
|
|
234
|
-
|
|
235
|
-
if (!trimedToParagraph) {
|
|
236
|
-
return shortenToSpace(str || '', len);
|
|
237
|
-
} else if (trimedToParagraph.length <= len) {
|
|
238
|
-
return trimedToParagraph;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return shortenToSpace(trimedToParagraph, len);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Use this to validate if a string is empty or invisible
|
|
246
|
-
*/
|
|
247
|
-
|
|
248
|
-
export function isInvisibleString(str: string) {
|
|
249
|
-
if (!str?.trim()) {
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// eslint-disable-next-line no-misleading-character-class
|
|
254
|
-
const invisRegex = /[ㅤ ️⠀ْٔ]/g;
|
|
255
|
-
const checkStr = str.replace(invisRegex, ' '); // .replace(/[ㅤ ️⠀]/gi, ' ');
|
|
256
|
-
return !checkStr.trim();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Build a single text block with proper line breaks
|
|
261
|
-
* NOTE: Userful for building AI prompts
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
export function buildSingleText(lines: (string | undefined | false | null)[]) {
|
|
265
|
-
return lines
|
|
266
|
-
.reduce((acc, line_) => {
|
|
267
|
-
const line = line_ || '';
|
|
268
|
-
if (line || acc[acc.length - 1] !== '') {
|
|
269
|
-
acc.push(line);
|
|
270
|
-
}
|
|
271
|
-
return acc;
|
|
272
|
-
}, [] as string[])
|
|
273
|
-
.join('\n')
|
|
274
|
-
.trim();
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Join array of texts but last word has a special separator
|
|
279
|
-
*
|
|
280
|
-
* @param texts - Array of strings to join
|
|
281
|
-
* @param separator - Separator to use between texts
|
|
282
|
-
* @param lastSeparator - Separator to use before the last text
|
|
283
|
-
* @returns Joined string with special last separator
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
export function joinReadable(
|
|
287
|
-
texts: string[],
|
|
288
|
-
separator: string = ', ',
|
|
289
|
-
lastSeparator: string = ' and ',
|
|
290
|
-
) {
|
|
291
|
-
const lastIx = texts.length - 1;
|
|
292
|
-
return texts.reduce((acc, text, i) => {
|
|
293
|
-
return acc + (!acc ? '' : i === lastIx ? lastSeparator : separator) + text;
|
|
294
|
-
}, '');
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Helper for writing text with optional brackets
|
|
299
|
-
*
|
|
300
|
-
* @param text - Text to write
|
|
301
|
-
* @param bracketsText - Text that will be written in brackets
|
|
302
|
-
* @param brackets - Brackets to use, defaults to round brackets
|
|
303
|
-
* @returns Formatted text with optional brackets
|
|
304
|
-
*/
|
|
305
|
-
|
|
306
|
-
export function textWithBrackets(
|
|
307
|
-
text: string,
|
|
308
|
-
bracketsText?: string | string[],
|
|
309
|
-
brackets: [string, string] = ['(', ')']
|
|
310
|
-
) {
|
|
311
|
-
let bText;
|
|
312
|
-
if (Array.isArray(bracketsText)) {
|
|
313
|
-
bText = bracketsText.filter(Boolean).join(' ').trim();
|
|
314
|
-
} else {
|
|
315
|
-
bText = bracketsText?.trim();
|
|
316
|
-
}
|
|
317
|
-
if (!bText) {
|
|
318
|
-
return text;
|
|
319
|
-
} else if (!text) {
|
|
320
|
-
return bText;
|
|
321
|
-
}
|
|
322
|
-
return `${text} ${brackets[0].trimStart()}${bText}${brackets[1].trimEnd()}`;
|
|
323
|
-
}
|
package/utils/url_client.ts
DELETED
|
@@ -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
|
-
}
|