@jsb188/app 1.1.10 → 1.1.11

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 (63) hide show
  1. package/package.json +54 -45
  2. package/src/constants/agent.ts +58 -25
  3. package/src/constants/app.ts +18 -14
  4. package/src/constants/billing.ts +92 -92
  5. package/src/constants/emoji.ts +9144 -8936
  6. package/src/constants/other.ts +1 -5
  7. package/src/constants/user.ts +16 -25
  8. package/src/constants/wsActions.ts +35 -0
  9. package/src/i18n/account.ts +129 -107
  10. package/src/i18n/agent.ts +63 -43
  11. package/src/i18n/agentDoc.ts +110 -0
  12. package/src/i18n/app.ts +101 -91
  13. package/src/i18n/auth.ts +119 -102
  14. package/src/i18n/billing.ts +73 -78
  15. package/src/i18n/campaign.ts +217 -0
  16. package/src/i18n/country.ts +248 -248
  17. package/src/i18n/datetime.ts +26 -26
  18. package/src/i18n/error.ts +428 -182
  19. package/src/i18n/field_docs.ts +28 -0
  20. package/src/i18n/form.ts +464 -344
  21. package/src/i18n/index.ts +25 -18
  22. package/src/i18n/log.ts +53 -213
  23. package/src/i18n/memory.ts +39 -0
  24. package/src/i18n/message.ts +3 -4
  25. package/src/i18n/note.ts +17 -0
  26. package/src/i18n/org.ts +115 -109
  27. package/src/i18n/sheet.ts +376 -4
  28. package/src/i18n/workflow.ts +70 -23
  29. package/src/main.ts +66 -62
  30. package/src/platform.ts +25 -24
  31. package/src/types/ai.d.ts +33 -23
  32. package/src/types/app.d.ts +95 -37
  33. package/src/types/auth.d.ts +66 -40
  34. package/src/types/console.d.ts +3 -0
  35. package/src/types/form.d.ts +65 -61
  36. package/src/types/other.d.ts +6 -6
  37. package/src/types.d.ts +12 -14
  38. package/src/utils/account.ts +64 -58
  39. package/src/utils/api.ts +280 -77
  40. package/src/utils/authSession.ts +24 -0
  41. package/src/utils/billing.ts +110 -103
  42. package/src/utils/color.ts +202 -0
  43. package/src/utils/cron.ts +49 -18
  44. package/src/utils/datetime.ts +255 -103
  45. package/src/utils/emoji.ts +107 -84
  46. package/src/utils/expression.ts +867 -0
  47. package/src/utils/interval.ts +80 -0
  48. package/src/utils/logic.ts +209 -36
  49. package/src/utils/managedSession.ts +34 -0
  50. package/src/utils/managedSessionBff.test.ts +60 -0
  51. package/src/utils/managedSessionBff.ts +117 -0
  52. package/src/utils/number.ts +60 -32
  53. package/src/utils/object.ts +198 -30
  54. package/src/utils/promise.ts +27 -0
  55. package/src/utils/queryReset.ts +179 -0
  56. package/src/utils/recurringTask.ts +60 -0
  57. package/src/utils/schema.ts +293 -0
  58. package/src/utils/string.test.ts +220 -208
  59. package/src/utils/string.ts +471 -438
  60. package/src/utils/timeZone.ts +309 -851
  61. package/src/utils/url_client.ts +73 -69
  62. package/tsconfig.json +10 -10
  63. package/src/i18n/product.ts +0 -76
@@ -2,280 +2,292 @@ import { beforeAll, describe, expect, it } from 'vitest';
2
2
 
3
3
  import { configI18n } from '../main.ts';
4
4
  import {
5
- addIndefiniteArticle,
6
- buildSingleText,
7
- camelCaseToDash,
8
- cn,
9
- convertToInternationalPhone,
10
- escapeCSVValue,
11
- formatPhoneNumber,
12
- formatReferenceNumber,
13
- getAlphanumeric,
14
- getDisplayName,
15
- getNthString,
16
- getSearchNames,
17
- guessFirstName,
18
- isEmail,
19
- isInvisibleString,
20
- isPhone,
21
- joinReadable,
22
- makeAddressText,
23
- passwordStrength,
24
- regexFromText,
25
- removeGeneratedTextGarbage,
26
- shortenToParagraph,
27
- shortenToSpace,
28
- splitTextIntoChunks,
29
- textWithBrackets,
30
- truncateFileName,
31
- ucFirst,
5
+ addIndefiniteArticle,
6
+ buildSingleText,
7
+ camelCaseToDash,
8
+ cn,
9
+ convertToInternationalPhone,
10
+ escapeCSVValue,
11
+ formatPhoneNumber,
12
+ formatReferenceNumber,
13
+ getAlphanumeric,
14
+ getDisplayName,
15
+ getNthString,
16
+ getSearchNames,
17
+ guessFirstName,
18
+ isEmail,
19
+ isInvisibleString,
20
+ isPhone,
21
+ joinReadable,
22
+ makeAddressText,
23
+ passwordStrength,
24
+ regexFromText,
25
+ removeGeneratedTextGarbage,
26
+ shortenToParagraph,
27
+ shortenToSpace,
28
+ splitTextIntoChunks,
29
+ textWithBrackets,
30
+ truncateFileName,
31
+ ucFirst,
32
32
  } from './string.ts';
33
33
 
34
34
  beforeAll(() => {
35
- configI18n();
35
+ configI18n();
36
36
  });
37
37
 
38
38
  describe('cn', () => {
39
- it('joins truthy class names with spaces', () => {
40
- expect(cn('card', false, 'selected', undefined, null, '')).toBe('card selected');
41
- });
39
+ it('joins truthy class names with spaces', () => {
40
+ expect(cn('card', false, 'selected', undefined, null, '')).toBe(
41
+ 'card selected',
42
+ );
43
+ });
42
44
  });
43
45
 
44
46
  describe('shortenToSpace', () => {
45
- it('shortens at the last available space before the limit', () => {
46
- expect(shortenToSpace('alpha beta gamma', 12)).toBe('alpha beta...');
47
- });
47
+ it('shortens at the last available space before the limit', () => {
48
+ expect(shortenToSpace('alpha beta gamma', 12)).toBe('alpha beta...');
49
+ });
48
50
 
49
- it('falls back to a hard cut when no spaces exist', () => {
50
- expect(shortenToSpace('alphabetagamma', 5)).toBe('alpha...');
51
- });
51
+ it('falls back to a hard cut when no spaces exist', () => {
52
+ expect(shortenToSpace('alphabetagamma', 5)).toBe('alpha...');
53
+ });
52
54
  });
53
55
 
54
56
  describe('guessFirstName', () => {
55
- it('drops leading articles and returns the first meaningful word', () => {
56
- expect(guessFirstName('the quick brown fox')).toBe('quick');
57
- });
57
+ it('drops leading articles and returns the first meaningful word', () => {
58
+ expect(guessFirstName('the quick brown fox')).toBe('quick');
59
+ });
58
60
 
59
- it('keeps short names instead of stripping the full word as an article suffix', () => {
60
- expect(guessFirstName('An Lee')).toBe('Lee');
61
- });
61
+ it('keeps short names instead of stripping the full word as an article suffix', () => {
62
+ expect(guessFirstName('An Lee')).toBe('Lee');
63
+ });
62
64
  });
63
65
 
64
66
  describe('addIndefiniteArticle', () => {
65
- it('handles silent-h and consonant-sounding vowel exceptions', () => {
66
- expect(addIndefiniteArticle('honest answer')).toBe('an honest answer');
67
- expect(addIndefiniteArticle('user')).toBe('a user');
68
- });
67
+ it('handles silent-h and consonant-sounding vowel exceptions', () => {
68
+ expect(addIndefiniteArticle('honest answer')).toBe('an honest answer');
69
+ expect(addIndefiniteArticle('user')).toBe('a user');
70
+ });
69
71
  });
70
72
 
71
73
  describe('isEmail', () => {
72
- it('accepts trimmed valid emails and rejects malformed values', () => {
73
- expect(isEmail(' hello@example.com ')).toBe(true);
74
- expect(isEmail('hello@example')).toBe(false);
75
- });
74
+ it('accepts trimmed valid emails and rejects malformed values', () => {
75
+ expect(isEmail(' hello@example.com ')).toBe(true);
76
+ expect(isEmail('hello@example')).toBe(false);
77
+ });
76
78
  });
77
79
 
78
80
  describe('convertToInternationalPhone and isPhone', () => {
79
- it('normalizes North American and existing international numbers', () => {
80
- expect(convertToInternationalPhone('(555) 123-4567')).toBe('+15551234567');
81
- expect(convertToInternationalPhone('+44 20 1234 5678')).toBe('+442012345678');
82
- });
83
-
84
- it('rejects invalid phone-like input', () => {
85
- expect(convertToInternationalPhone('05551234567')).toBeNull();
86
- expect(convertToInternationalPhone('555-abc-1234')).toBeNull();
87
- });
88
-
89
- it('supports optional conversion when validating phone numbers', () => {
90
- expect(isPhone('5551234567')).toBe(true);
91
- expect(isPhone('5551234567', true)).toBe(false);
92
- expect(isPhone('+442012345678', true)).toBe(true);
93
- });
81
+ it('normalizes North American and existing international numbers', () => {
82
+ expect(convertToInternationalPhone('(555) 123-4567')).toBe('+15551234567');
83
+ expect(convertToInternationalPhone('+44 20 1234 5678')).toBe(
84
+ '+442012345678',
85
+ );
86
+ });
87
+
88
+ it('rejects invalid phone-like input', () => {
89
+ expect(convertToInternationalPhone('05551234567')).toBeNull();
90
+ expect(convertToInternationalPhone('555-abc-1234')).toBeNull();
91
+ });
92
+
93
+ it('supports optional conversion when validating phone numbers', () => {
94
+ expect(isPhone('5551234567')).toBe(true);
95
+ expect(isPhone('5551234567', true)).toBe(false);
96
+ expect(isPhone('+442012345678', true)).toBe(true);
97
+ });
94
98
  });
95
99
 
96
100
  describe('passwordStrength', () => {
97
- it('reports rule-by-rule password strength details', () => {
98
- expect(passwordStrength('Abcdef1!')).toEqual({
99
- valid: true,
100
- isLongEnough: true,
101
- hasLowercase: true,
102
- hasUppercase: true,
103
- hasDigit: true,
104
- hasSpecial: true,
105
- });
106
-
107
- expect(passwordStrength('abcdefg')).toMatchObject({
108
- valid: false,
109
- isLongEnough: false,
110
- hasLowercase: true,
111
- hasUppercase: false,
112
- hasDigit: false,
113
- hasSpecial: false,
114
- });
115
- });
101
+ it('reports rule-by-rule password strength details', () => {
102
+ expect(passwordStrength('Abcdef1!')).toEqual({
103
+ valid: true,
104
+ isLongEnough: true,
105
+ hasLowercase: true,
106
+ hasUppercase: true,
107
+ hasDigit: true,
108
+ hasSpecial: true,
109
+ });
110
+
111
+ expect(passwordStrength('abcdefg')).toMatchObject({
112
+ valid: false,
113
+ isLongEnough: false,
114
+ hasLowercase: true,
115
+ hasUppercase: false,
116
+ hasDigit: false,
117
+ hasSpecial: false,
118
+ });
119
+ });
116
120
  });
117
121
 
118
122
  describe('getAlphanumeric and getSearchNames', () => {
119
- it('removes punctuation while optionally preserving spaces', () => {
120
- expect(getAlphanumeric('A-B_C!', false)).toBe('ABC');
121
- expect(getAlphanumeric('A-B_C!', true)).toBe('ABC');
122
- });
123
-
124
- it('splits mixed delimiters and keeps case-insensitive unique names', () => {
125
- expect(getSearchNames(['Alice, Bob and alice', 'Carol;\nBob', null])).toEqual([
126
- 'Alice',
127
- 'Bob',
128
- 'Carol',
129
- ]);
130
- });
123
+ it('removes punctuation while optionally preserving spaces', () => {
124
+ expect(getAlphanumeric('A-B_C!', false)).toBe('ABC');
125
+ expect(getAlphanumeric('A-B_C!', true)).toBe('ABC');
126
+ });
127
+
128
+ it('splits mixed delimiters and keeps case-insensitive unique names', () => {
129
+ expect(
130
+ getSearchNames(['Alice, Bob and alice', 'Carol;\nBob', null]),
131
+ ).toEqual(['Alice', 'Bob', 'Carol']);
132
+ });
131
133
  });
132
134
 
133
135
  describe('regexFromText', () => {
134
- it('builds a case-insensitive regex from cleaned words', () => {
135
- const regex = regexFromText('Hello, world!');
136
+ it('builds a case-insensitive regex from cleaned words', () => {
137
+ const regex = regexFromText('Hello, world!');
136
138
 
137
- expect(regex).not.toBeNull();
138
- expect('say hello there'.match(regex!)).toEqual(['hello']);
139
- expect('WORLD tour'.match(regex!)).toEqual(['WORLD']);
140
- });
139
+ expect(regex).not.toBeNull();
140
+ expect('say hello there'.match(regex!)).toEqual(['hello']);
141
+ expect('WORLD tour'.match(regex!)).toEqual(['WORLD']);
142
+ });
141
143
 
142
- it('returns null when no searchable words remain', () => {
143
- expect(regexFromText('a !')).toBeNull();
144
- });
144
+ it('returns null when no searchable words remain', () => {
145
+ expect(regexFromText('a !')).toBeNull();
146
+ });
145
147
  });
146
148
 
147
149
  describe('ucFirst and camelCaseToDash', () => {
148
- it('formats capitalization and dash-separated names', () => {
149
- expect(ucFirst('marketday')).toBe('Marketday');
150
- expect(camelCaseToDash('camelCase2Value')).toBe('camel-case-2-value');
151
- expect(camelCaseToDash('API')).toBe('api');
152
- });
150
+ it('formats capitalization and dash-separated names', () => {
151
+ expect(ucFirst('marketday')).toBe('Marketday');
152
+ expect(camelCaseToDash('camelCase2Value')).toBe('camel-case-2-value');
153
+ expect(camelCaseToDash('API')).toBe('api');
154
+ });
153
155
  });
154
156
 
155
157
  describe('shortenToParagraph', () => {
156
- it('uses paragraph boundaries before falling back to word trimming', () => {
157
- const text = 'First line\nSecond line\nThird line';
158
+ it('uses paragraph boundaries before falling back to word trimming', () => {
159
+ const text = 'First line\nSecond line\nThird line';
158
160
 
159
- expect(shortenToParagraph(text, 18)).toBe('First line');
160
- expect(shortenToParagraph('Alpha beta gamma', 10)).toBe('Alpha...');
161
- });
161
+ expect(shortenToParagraph(text, 18)).toBe('First line');
162
+ expect(shortenToParagraph('Alpha beta gamma', 10)).toBe('Alpha...');
163
+ });
162
164
  });
163
165
 
164
166
  describe('isInvisibleString', () => {
165
- it('detects strings made only from whitespace-like invisible characters', () => {
166
- expect(isInvisibleString('ㅤ️⠀')).toBe(true);
167
- expect(isInvisibleString(' visible ')).toBe(false);
168
- });
167
+ it('detects strings made only from whitespace-like invisible characters', () => {
168
+ expect(isInvisibleString('ㅤ️⠀')).toBe(true);
169
+ expect(isInvisibleString(' visible ')).toBe(false);
170
+ });
169
171
  });
170
172
 
171
173
  describe('buildSingleText', () => {
172
- it('supports feature maps, conditional lines, first-match groups, and blank line collapsing', () => {
173
- expect(
174
- buildSingleText(
175
- [
176
- 'Header',
177
- '',
178
- '',
179
- { advanced: ['Advanced section'] },
180
- [['beta', '!legacy'], ['Beta only']],
181
- [
182
- [['admin'], ['Admin choice']],
183
- [['member'], [' Member choice']],
184
- [['!member'], ['Fallback choice']],
185
- ],
186
- 'Footer',
187
- ],
188
- '\n',
189
- ['advanced', 'beta', 'member'],
190
- ),
191
- ).toBe('Header\n\nAdvanced section\nBeta only\nMember choice\nFooter');
192
- });
174
+ it('supports feature maps, conditional lines, first-match groups, and blank line collapsing', () => {
175
+ expect(
176
+ buildSingleText(
177
+ [
178
+ 'Header',
179
+ '',
180
+ '',
181
+ { advanced: ['Advanced section'] },
182
+ [['beta', '!legacy'], ['Beta only']],
183
+ [
184
+ [['admin'], ['Admin choice']],
185
+ [['member'], [' Member choice']],
186
+ [['!member'], ['Fallback choice']],
187
+ ],
188
+ 'Footer',
189
+ ],
190
+ '\n',
191
+ ['advanced', 'beta', 'member'],
192
+ ),
193
+ ).toBe('Header\n\nAdvanced section\nBeta only\nMember choice\nFooter');
194
+ });
193
195
  });
194
196
 
195
197
  describe('joinReadable and textWithBrackets', () => {
196
- it('joins human-readable lists and appends bracket text when present', () => {
197
- expect(joinReadable(['Alpha', 'Beta', 'Gamma'])).toBe('Alpha, Beta and Gamma');
198
- expect(textWithBrackets('Status', ['draft', 'internal'], ['[', ']'])).toBe('Status [draft internal]');
199
- expect(textWithBrackets('', ['draft', 'internal'], ['[', ']'])).toBe('draft internal');
200
- });
198
+ it('joins human-readable lists and appends bracket text when present', () => {
199
+ expect(joinReadable(['Alpha', 'Beta', 'Gamma'])).toBe(
200
+ 'Alpha, Beta and Gamma',
201
+ );
202
+ expect(textWithBrackets('Status', ['draft', 'internal'], ['[', ']'])).toBe(
203
+ 'Status [draft internal]',
204
+ );
205
+ expect(textWithBrackets('', ['draft', 'internal'], ['[', ']'])).toBe(
206
+ 'draft internal',
207
+ );
208
+ });
201
209
  });
202
210
 
203
211
  describe('removeGeneratedTextGarbage and escapeCSVValue', () => {
204
- it('normalizes generated whitespace and escapes CSV-sensitive values', () => {
205
- expect(removeGeneratedTextGarbage('Hello\n\n world\tfrom\r\nAI')).toBe('Hello world from AI');
206
- expect(escapeCSVValue('plain')).toBe('plain');
207
- expect(escapeCSVValue('a,"b"\nc')).toBe('"a,""b""\nc"');
208
- });
212
+ it('normalizes generated whitespace and escapes CSV-sensitive values', () => {
213
+ expect(removeGeneratedTextGarbage('Hello\n\n world\tfrom\r\nAI')).toBe(
214
+ 'Hello world from AI',
215
+ );
216
+ expect(escapeCSVValue('plain')).toBe('plain');
217
+ expect(escapeCSVValue('a,"b"\nc')).toBe('"a,""b""\nc"');
218
+ });
209
219
  });
210
220
 
211
221
  describe('truncateFileName', () => {
212
- it('preserves extensions while truncating long file names', () => {
213
- expect(truncateFileName('very-long-document-name.pdf', 12)).toBe('very-....pdf');
214
- expect(truncateFileName('short.txt', 20)).toBe('short.txt');
215
- });
222
+ it('preserves extensions while truncating long file names', () => {
223
+ expect(truncateFileName('very-long-document-name.pdf', 12)).toBe(
224
+ 'very-....pdf',
225
+ );
226
+ expect(truncateFileName('short.txt', 20)).toBe('short.txt');
227
+ });
216
228
  });
217
229
 
218
230
  describe('formatPhoneNumber', () => {
219
- it('formats trailing 10 digits into a readable North American phone number', () => {
220
- expect(formatPhoneNumber('+15551234567')).toBe('+1 (555) 123-4567');
221
- expect(formatPhoneNumber('5551234567')).toBe('(555) 123-4567');
222
- expect(formatPhoneNumber('not-a-phone')).toBe('not-a-phone');
223
- });
231
+ it('formats trailing 10 digits into a readable North American phone number', () => {
232
+ expect(formatPhoneNumber('+15551234567')).toBe('+1 (555) 123-4567');
233
+ expect(formatPhoneNumber('5551234567')).toBe('(555) 123-4567');
234
+ expect(formatPhoneNumber('not-a-phone')).toBe('not-a-phone');
235
+ });
224
236
  });
225
237
 
226
238
  describe('splitTextIntoChunks', () => {
227
- it('prefers nearby line breaks when splitting long text', () => {
228
- expect(splitTextIntoChunks('12345\n67890\nabcde', 10, 5)).toEqual([
229
- '12345',
230
- '67890',
231
- 'abcde',
232
- ]);
233
- });
234
-
235
- it('falls back to whitespace boundaries when no line break is nearby', () => {
236
- expect(splitTextIntoChunks('alpha beta gamma delta', 12, 2)).toEqual([
237
- 'alpha beta',
238
- 'gamma delta',
239
- ]);
240
- });
239
+ it('prefers nearby line breaks when splitting long text', () => {
240
+ expect(splitTextIntoChunks('12345\n67890\nabcde', 10, 5)).toEqual([
241
+ '12345',
242
+ '67890',
243
+ 'abcde',
244
+ ]);
245
+ });
246
+
247
+ it('falls back to whitespace boundaries when no line break is nearby', () => {
248
+ expect(splitTextIntoChunks('alpha beta gamma delta', 12, 2)).toEqual([
249
+ 'alpha beta',
250
+ 'gamma delta',
251
+ ]);
252
+ });
241
253
  });
242
254
 
243
255
  describe('formatReferenceNumber and getNthString', () => {
244
- it('formats numeric references and ordinal suffixes', () => {
245
- expect(formatReferenceNumber('42')).toBe('#42');
246
- expect(formatReferenceNumber('abc')).toBe('abc');
247
- expect(getNthString(1)).toBe('1st');
248
- expect(getNthString(2)).toBe('2nd');
249
- expect(getNthString(3)).toBe('3rd');
250
- expect(getNthString(11)).toBe('11th');
251
- expect(getNthString(23)).toBe('23rd');
252
- });
256
+ it('formats numeric references and ordinal suffixes', () => {
257
+ expect(formatReferenceNumber('42')).toBe('#42');
258
+ expect(formatReferenceNumber('abc')).toBe('abc');
259
+ expect(getNthString(1)).toBe('1st');
260
+ expect(getNthString(2)).toBe('2nd');
261
+ expect(getNthString(3)).toBe('3rd');
262
+ expect(getNthString(11)).toBe('11th');
263
+ expect(getNthString(23)).toBe('23rd');
264
+ });
253
265
  });
254
266
 
255
267
  describe('makeAddressText and getDisplayName', () => {
256
- it('formats addresses in each supported display mode', () => {
257
- const address = {
258
- line1: '1 Main St',
259
- line2: 'Suite 2',
260
- city: 'Toronto',
261
- state: 'ON',
262
- postalCode: 'A1A 1A1',
263
- country: 'CA',
264
- };
265
-
266
- expect(makeAddressText(address, 'REGION_ONLY')).toBe('Toronto, ON, CA');
267
- expect(makeAddressText(address, 'SINGLE_LINE', true)).toBe(
268
- '1 Main St, Suite 2, Toronto, ON, A1A 1A1, Canada',
269
- );
270
- expect(makeAddressText(address)).toBe(
271
- '1 Main St\nSuite 2\nToronto, ON A1A 1A1\nCA',
272
- );
273
- });
274
-
275
- it('builds a full name and short display name together', () => {
276
- expect(getDisplayName('John', 'Smith')).toEqual({
277
- fullName: 'John Smith',
278
- displayName: 'John',
279
- });
280
- });
268
+ it('formats addresses in each supported display mode', () => {
269
+ const address = {
270
+ line1: '1 Main St',
271
+ line2: 'Suite 2',
272
+ city: 'Toronto',
273
+ state: 'ON',
274
+ postalCode: 'A1A 1A1',
275
+ country: 'CA',
276
+ };
277
+
278
+ expect(makeAddressText(address, 'REGION_ONLY')).toBe('Toronto, ON, CA');
279
+ expect(makeAddressText(address, 'SINGLE_LINE', true)).toBe(
280
+ '1 Main St, Suite 2, Toronto, ON, A1A 1A1, Canada',
281
+ );
282
+ expect(makeAddressText(address)).toBe(
283
+ '1 Main St\nSuite 2\nToronto, ON A1A 1A1\nCA',
284
+ );
285
+ });
286
+
287
+ it('builds a full name and short display name together', () => {
288
+ expect(getDisplayName('John', 'Smith')).toEqual({
289
+ fullName: 'John Smith',
290
+ displayName: 'John',
291
+ });
292
+ });
281
293
  });