@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.
Files changed (110) hide show
  1. package/package.json +57 -42
  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/{utils → src/utils}/timeZone.ts +531 -852
  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/journal.ts +0 -74
  80. package/constants/user.ts +0 -36
  81. package/constants/ws.ts +0 -47
  82. package/i18n/app.ts +0 -101
  83. package/i18n/auth.ts +0 -63
  84. package/i18n/billing.ts +0 -94
  85. package/i18n/datetime.ts +0 -21
  86. package/i18n/error.ts +0 -143
  87. package/i18n/form.ts +0 -74
  88. package/i18n/index.ts +0 -5
  89. package/i18n/user.ts +0 -101
  90. package/main.ts +0 -94
  91. package/platform.ts +0 -125
  92. package/types/ai.d.ts +0 -30
  93. package/types/app.d.ts +0 -48
  94. package/types/auth.d.ts +0 -63
  95. package/types/form.d.ts +0 -56
  96. package/types/journal.d.ts +0 -24
  97. package/types/organization.d.ts +0 -38
  98. package/types/user.d.ts +0 -52
  99. package/types.d.ts +0 -31
  100. package/utils/api.ts +0 -99
  101. package/utils/billing.ts +0 -134
  102. package/utils/datetime.ts +0 -542
  103. package/utils/emoji.ts +0 -151
  104. package/utils/journal.ts +0 -17
  105. package/utils/logic.ts +0 -118
  106. package/utils/number.ts +0 -139
  107. package/utils/object.ts +0 -425
  108. package/utils/string.ts +0 -323
  109. package/utils/url_client.ts +0 -138
  110. package/utils/user.ts +0 -273
@@ -0,0 +1,206 @@
1
+ import { getENVVariable } from '../main.ts';
2
+
3
+ type LinkType = 'USER' | 'KAJI' | 'DATASET' | 'VOICE' | 'FEED' | 'ROOM' | 'THREAD' | 'OTHER';
4
+
5
+ /*
6
+ * Format a keyboard shortcut with the command modifier used by the current
7
+ * client platform.
8
+ */
9
+ export function getClientShortcutText(key: string, shiftKey: boolean = false): string {
10
+ const platform = globalThis.navigator?.platform || globalThis.navigator?.userAgent || '';
11
+ return [/Mac|iPhone|iPod|iPad/i.test(platform) ? 'cmd' : 'ctrl', shiftKey ? 'shift' : null, key.toLowerCase()]
12
+ .filter(Boolean)
13
+ .join('+');
14
+ }
15
+
16
+ // links to consider for User cards
17
+ // instagram
18
+ // tiktok
19
+ // youtube
20
+ // pinterest
21
+ // twitch
22
+ // linkedin
23
+ // facebook
24
+ // twiitter (x)
25
+
26
+ /**
27
+ * Uploaded assets
28
+ */
29
+
30
+ export function makeUploadsUrl(urlPath?: string | null, size?: 'small' | 'medium' | 'original', download?: boolean): string {
31
+ if (!urlPath) {
32
+ return '';
33
+ }
34
+
35
+ const searchParams: string[] = [];
36
+ if (size) {
37
+ searchParams.push(`size=${encodeURIComponent(size)}`);
38
+ }
39
+ if (download) {
40
+ searchParams.push('download=1');
41
+ }
42
+
43
+ const searchPath = searchParams.length ? `?${searchParams.join('&')}` : '';
44
+
45
+ return 'https://assets.chiefhappiness.co/marketday/' + urlPath + searchPath;
46
+ }
47
+
48
+ /**
49
+ * Local object URLs
50
+ */
51
+
52
+ // Hold counts and pending revocations of object URLs shared between components
53
+ const objectUrlHolds = new Map<string, number>();
54
+ const objectUrlRevokeTimers = new Map<string, ReturnType<typeof setTimeout>>();
55
+
56
+ /*
57
+ * Add one hold on a local object URL (e.g. an image preview from
58
+ * URL.createObjectURL()) and cancel a revocation scheduled by a holder that
59
+ * just released it.
60
+ */
61
+ export function retainObjectUrl(url: string) {
62
+ clearTimeout(objectUrlRevokeTimers.get(url));
63
+ objectUrlRevokeTimers.delete(url);
64
+ objectUrlHolds.set(url, (objectUrlHolds.get(url) || 0) + 1);
65
+ }
66
+
67
+ /*
68
+ * Release one hold on a local object URL and revoke it shortly after its last
69
+ * holder lets go, so a holder that unmounts in the same render as the one
70
+ * taking over (e.g. a page handing a preview to the next page) never breaks it.
71
+ */
72
+ export function releaseObjectUrl(url: string) {
73
+ const holds = (objectUrlHolds.get(url) || 0) - 1;
74
+ if (holds > 0) {
75
+ objectUrlHolds.set(url, holds);
76
+ return;
77
+ }
78
+
79
+ objectUrlHolds.delete(url);
80
+ clearTimeout(objectUrlRevokeTimers.get(url));
81
+ objectUrlRevokeTimers.set(
82
+ url,
83
+ setTimeout(() => {
84
+ objectUrlRevokeTimers.delete(url);
85
+ URL.revokeObjectURL(url);
86
+ }, 1000),
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Make a campaign-template preview asset URL, preserving older non-campaign paths.
92
+ */
93
+ export function makePreviewAssetUrl(uri?: string | null): string {
94
+ const assetsUrl = String(getENVVariable('ASSETS_URL') || 'https://assets.chiefhappiness.co').replace(/\/+$/, '');
95
+ const campaignPath = uri?.match(/^(\d+)\/previews\/(campaigns|campaign-instances)\/([^/]+)\.webp$/);
96
+ if (campaignPath) {
97
+ return `${assetsUrl}/previews/${campaignPath[2]}/${campaignPath[1]}/${campaignPath[3]}.webp`;
98
+ }
99
+ return uri ? `${assetsUrl}/preview/${uri}` : '';
100
+ }
101
+
102
+ /**
103
+ * Make url for static assets
104
+ */
105
+
106
+ export function makeStaticAssetUrl(urlPath?: string | null): string {
107
+ return 'https://assets.chiefhappiness.co/marketday/static/' + urlPath;
108
+ }
109
+
110
+ /**
111
+ * Make chat URL
112
+ */
113
+
114
+ export function makeChatUrl(
115
+ firstChatId?: string | null,
116
+ secondChatId?: string | null,
117
+ nextFirstChatId?: string | null,
118
+ nextSecondChatId?: string | null,
119
+ ) {
120
+ const path = 'chat';
121
+
122
+ if (nextFirstChatId && nextFirstChatId === secondChatId) {
123
+ return `/${path}/${firstChatId}/${secondChatId}`;
124
+ }
125
+
126
+ const first = nextFirstChatId || firstChatId || 'none';
127
+ const second = nextSecondChatId || secondChatId;
128
+
129
+ if (first === second) {
130
+ return `/${path}/${first}`;
131
+ }
132
+
133
+ return `/${path}/${first}${second ? `/${second}` : ''}`;
134
+ }
135
+
136
+ /**
137
+ * Get default text for URL type
138
+ */
139
+
140
+ export function getUrlType(type: LinkType) {
141
+ switch (type) {
142
+ case 'USER':
143
+ return 'User';
144
+ case 'KAJI':
145
+ return 'AI';
146
+ case 'DATASET':
147
+ return 'Dataset';
148
+ case 'VOICE':
149
+ return 'Voice';
150
+ case 'FEED':
151
+ return 'Feed post';
152
+ case 'ROOM':
153
+ return 'Room';
154
+ case 'THREAD':
155
+ return 'Forum thread';
156
+ default:
157
+ return 'Link';
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Convert location search string to object
163
+ */
164
+
165
+ export function locationSearchToObject(searchParams?: string) {
166
+ if (!searchParams) {
167
+ return {};
168
+ }
169
+
170
+ const search = searchParams.substring(1);
171
+ const searchParamsArray = search.split('&');
172
+ const searchParamsObject: Record<string, string> = {};
173
+
174
+ searchParamsArray.forEach((param) => {
175
+ const [key, value] = param.split('=');
176
+ searchParamsObject[key] = value;
177
+ });
178
+
179
+ return searchParamsObject;
180
+ }
181
+
182
+ /**
183
+ * Check if current page is a chat page
184
+ */
185
+
186
+ export function isChatPage() {
187
+ const pathname = globalThis?.location?.pathname?.toLowerCase();
188
+ if (pathname) {
189
+ return /^\/(?:chat|dm)\//i.test(pathname);
190
+ }
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * Check if a pathname falls under any of the given route prefixes.
196
+ * Matching is segment-aware: '/app/s' or '/app/s/' matches '/app/s' and '/app/s/12345', but not '/app/sheets'.
197
+ * Only the pathname is compared, so query strings and hashes never affect the result.
198
+ */
199
+
200
+ export function isPathnameUnderRoutes(pathname: string, routes: string[]) {
201
+ const [path] = pathname.split(/[?#]/);
202
+ return routes.some((route) => {
203
+ const prefix = route.replace(/\/+$/, '');
204
+ return prefix === '' || path === prefix || path.startsWith(prefix + '/');
205
+ });
206
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "noEmit": true,
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["src/**/*"]
12
+ }
package/constants/app.ts DELETED
@@ -1,47 +0,0 @@
1
-
2
- // Big planet constants
3
-
4
- export const NOTIF_EXPIRE_DAYS = 30;
5
-
6
- // DOM element names (ids)
7
-
8
- export const DOM_IDS = {
9
- sidebarInput: 'sidebar_input',
10
- mainFocusTextarea: 'main_tx_',
11
- };
12
-
13
- // Local storage
14
-
15
- export const STORAGE_KEYS = {
16
- // Authentication
17
- AUTH_TOKEN: 'AT', // There's no ":", so this is used as-is
18
- LAST_VERSION: 'LV:', // ":" at end means it's a prefix
19
- CURRENT_ACCOUNT_ID: 'CU:',
20
-
21
- // Settings
22
- LIGHT_MODE: 'LM:',
23
- } as Record<string, string>;
24
-
25
- // Support e-mails
26
-
27
- export const SUPPORT_EMAILS = {
28
- default: 'hi@kajiwoto.ai',
29
- big_planet: 'hi@kajiwoto.ai',
30
- cosmic: 'hi@kajiwoto.ai',
31
- } as Record<string, string>;
32
-
33
- // Social media
34
-
35
- export const SOCIAL_URLS = {
36
- big_planet: {
37
- x: 'https://x.com/bigplanetai',
38
- x_username: 'BigPlanetAI',
39
- },
40
- cosmic: {
41
- x: 'https://x.com/bigplanetai',
42
- x_username: 'BigPlanetAI',
43
- }
44
- } as Record<string, {
45
- x: string;
46
- x_username: string;
47
- }>;
@@ -1,146 +0,0 @@
1
- export const PLATFORM_PRODUCT_ENUMS = [
2
- // Subscriptions
3
- 'perks',
4
- 'kajiwoto_plus',
5
- 'kajiwoto_plus_yearly',
6
- 'kajiwoto_pro',
7
- 'kajiwoto_pro_yearly',
8
-
9
- // These are for future proofing; don't use these until they're in the database
10
- 'big_planet_plus',
11
- 'big_planet_plus_yearly',
12
- 'big_planet_pro',
13
- 'big_planet_pro_yearly',
14
-
15
- // Consumables
16
- 'coins_10',
17
- 'coins_20',
18
- 'coins_100',
19
-
20
- // Expired
21
- 'kajiwoto_creator',
22
- 'creator_dataset_sub',
23
- ];
24
-
25
- export const SUBSCRIPTION_CATALOG = [
26
- // [groupName, stripeProductId, stripePriceId]
27
- ['PLUS', 'prod_H0WgTKq5qiK51Q', 'plan_H0WhZdwYcq9Fn7'],
28
- ['PRO', 'prod_H0WgTKq5qiK51Q', 'price_1MkLqjJI6Kvu2OvUPzFwwncH'],
29
- ];
30
-
31
- export const SUBSCRIPTION_CATALOG_TEST = [
32
- // [groupName, stripeProductId, stripePriceId]
33
- ['PLUS', 'prod_O2uOYfarTaRqJX', 'price_1QBox9JI6Kvu2OvUoy9vBmKL'],
34
- ['PRO', 'prod_O2uOYfarTaRqJX', 'price_1QBox9JI6Kvu2OvUQ86KgX5C'],
35
- ];
36
-
37
- export const PRICE_ID_TO_PRODUCT = {
38
- plan_H0WhZdwYcq9Fn7: {
39
- name: 'kajiwoto_plus',
40
- group: 'PLUS',
41
- },
42
- price_1HmqX5JI6Kvu2OvUM1edHUMw: {
43
- name: 'kajiwoto_plus_yearly',
44
- group: 'PLUS',
45
- },
46
- price_1MkLqjJI6Kvu2OvUPzFwwncH: {
47
- name: 'kajiwoto_pro',
48
- group: 'PRO',
49
- },
50
- price_1MkLrzJI6Kvu2OvUMPyWvKdt: {
51
- name: 'kajiwoto_pro_yearly',
52
- group: 'PRO',
53
- },
54
- price_1IOudjJI6Kvu2OvU6znCc2oZ: {
55
- name: 'coins_10',
56
- group: 'COINS',
57
- },
58
- price_1IOudjJI6Kvu2OvUnRFoUQUm: {
59
- name: 'coins_20',
60
- group: 'COINS',
61
- },
62
- price_1K3y6EJI6Kvu2OvUYUDJgMy6: {
63
- name: 'coins_100',
64
- group: 'COINS',
65
- },
66
- // price_HNzF3cC8hMxs0Q: 'kajiwoto_creator',
67
- // plan_HIXtNYWIEx9eST: 'creator_dataset_sub',
68
- } as {
69
- [key: string]: {
70
- name: string;
71
- group: string;
72
- };
73
- };
74
-
75
- export const PRICE_ID_TO_PRODUCT_TEST = {
76
- price_1QBox9JI6Kvu2OvUoy9vBmKL: {
77
- name: 'kajiwoto_plus',
78
- group: 'PLUS',
79
- },
80
- price_1QBox9JI6Kvu2OvU7bKCLUYq: {
81
- name: 'kajiwoto_plus_yearly',
82
- group: 'PLUS',
83
- },
84
- price_1QBox9JI6Kvu2OvUQ86KgX5C: {
85
- name: 'kajiwoto_pro',
86
- group: 'PRO',
87
- },
88
- price_1QBox9JI6Kvu2OvU8Fn4ftXb: {
89
- name: 'kajiwoto_pro_yearly',
90
- group: 'PRO',
91
- },
92
- price_1NGnmKJI6Kvu2OvUx3bykj0F: {
93
- name: 'coins_10',
94
- group: 'COINS',
95
- },
96
- price_1NGoBHJI6Kvu2OvUONbOujKG: {
97
- name: 'coins_20',
98
- group: 'COINS',
99
- },
100
- price_1NGoAjJI6Kvu2OvUSRWartW3: {
101
- name: 'coins_100',
102
- group: 'COINS',
103
- },
104
- // price_HNzJjKRMAhEakr: 'kajiwoto_creator',
105
- // plan_HIYFVZvX8lLTol: 'creator_dataset_sub',
106
- } as {
107
- [key: string]: {
108
- name: string;
109
- group: string;
110
- };
111
- };
112
-
113
- // Products
114
- // export const PRICES = {
115
- // kajiwoto_plus: 7.99,
116
- // kajiwoto_plus_yearly: 87.89,
117
- // kajiwoto_pro: 29.99,
118
- // kajiwoto_pro_yearly: 299.99,
119
- // coins_10: 9.99,
120
- // coins_20: 19.98,
121
- // coins_100: 99.90,
122
-
123
- // // Skin Prices
124
- // SKIN_PRICE_1: 2.99,
125
- // SKIN_PRICE_2: 4.99,
126
- // SKIN_PRICE_3: 9.99,
127
- // SKIN_PRICE_4: 19.99
128
- // };
129
-
130
- // export const SUBSCRIPTION_PRODUCTS = [
131
- // 'kajiwoto_plus',
132
- // 'kajiwoto_plus_yearly',
133
- // 'kajiwoto_pro',
134
- // 'kajiwoto_pro_yearly',
135
- // 'kajiwoto_creator',
136
- // 'kplus_test'
137
- // ];
138
-
139
- // export const HAS_PLUS_SUB_TYPES = [
140
- // 'plus',
141
- // 'pro'
142
- // ];
143
-
144
- // export const HAS_PRO_SUB_TYPES = [
145
- // 'pro'
146
- // ];