@jsb188/app 1.0.3 → 1.1.1
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/constants/app.ts +2 -2
- package/constants/emoji.ts +16 -16
- package/constants/journal.ts +74 -0
- package/i18n/app.ts +2 -0
- package/i18n/auth.ts +12 -6
- package/i18n/datetime.ts +0 -1
- package/i18n/error.ts +11 -6
- package/i18n/form.ts +1 -0
- package/i18n/index.ts +0 -1
- package/i18n/user.ts +6 -3
- package/main.ts +36 -4
- package/package.json +10 -5
- package/platform.ts +125 -0
- package/types/ai.d.ts +30 -0
- package/types/app.d.ts +2 -0
- package/types/auth.d.ts +63 -0
- package/types/journal.d.ts +24 -0
- package/types/organization.d.ts +38 -0
- package/types.d.ts +8 -0
- package/utils/api.ts +77 -0
- package/utils/datetime.ts +473 -289
- package/utils/journal.ts +17 -0
- package/utils/logic.ts +81 -78
- package/utils/number.ts +92 -68
- package/utils/object.ts +277 -219
- package/utils/string.ts +219 -107
- package/utils/timeZone.ts +2369 -0
- package/types/datetime.d.ts +0 -10
package/constants/app.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//
|
|
2
|
+
// Big planet constants
|
|
3
3
|
|
|
4
4
|
export const NOTIF_EXPIRE_DAYS = 30;
|
|
5
5
|
|
|
@@ -16,7 +16,7 @@ export const STORAGE_KEYS = {
|
|
|
16
16
|
// Authentication
|
|
17
17
|
AUTH_TOKEN: 'AT', // There's no ":", so this is used as-is
|
|
18
18
|
LAST_VERSION: 'LV:', // ":" at end means it's a prefix
|
|
19
|
-
|
|
19
|
+
CURRENT_ACCOUNT_ID: 'CU:',
|
|
20
20
|
|
|
21
21
|
// Settings
|
|
22
22
|
LIGHT_MODE: 'LM:',
|
package/constants/emoji.ts
CHANGED
|
@@ -164,8 +164,8 @@ export const emojiToName = {
|
|
|
164
164
|
"👁️🗨️": "eye_in_speech_bubble",
|
|
165
165
|
"👁🗨️": "eye_in_speech_bubble",
|
|
166
166
|
"👁🗨": "eye_in_speech_bubble",
|
|
167
|
-
"🗨️": "
|
|
168
|
-
"🗨": "
|
|
167
|
+
"🗨️": "left_smpeech_bubble",
|
|
168
|
+
"🗨": "left_smpeech_bubble",
|
|
169
169
|
"🗯": "right_anger_bubble",
|
|
170
170
|
"💭": "thought_balloon",
|
|
171
171
|
"💤": "zzz",
|
|
@@ -250,11 +250,11 @@ export const emojiToName = {
|
|
|
250
250
|
"🤙🏾": "call_me_hand_medium_dark_skin_tone",
|
|
251
251
|
"🤙🏿": "call_me_hand_dark_skin_tone",
|
|
252
252
|
"👈": "point_left",
|
|
253
|
-
"👈🏻": "
|
|
254
|
-
"👈🏼": "
|
|
255
|
-
"👈🏽": "
|
|
256
|
-
"👈🏾": "
|
|
257
|
-
"👈🏿": "
|
|
253
|
+
"👈🏻": "backhand_index_pointing_left_lgight_skin_tone",
|
|
254
|
+
"👈🏼": "backhand_index_pointing_left_mdedium_light_skin_tone",
|
|
255
|
+
"👈🏽": "backhand_index_pointing_left_mdedium_skin_tone",
|
|
256
|
+
"👈🏾": "backhand_index_pointing_left_mdedium_dark_skin_tone",
|
|
257
|
+
"👈🏿": "backhand_index_pointing_left_dfark_skin_tone",
|
|
258
258
|
"👉": "point_right",
|
|
259
259
|
"👉🏻": "backhand_index_pointing_right_light_skin_tone",
|
|
260
260
|
"👉🏼": "backhand_index_pointing_right_medium_light_skin_tone",
|
|
@@ -4000,7 +4000,7 @@ export const emojiToName = {
|
|
|
4000
4000
|
"🛂": "passport_control",
|
|
4001
4001
|
"🛃": "customs",
|
|
4002
4002
|
"🛄": "baggage_claim",
|
|
4003
|
-
"🛅": "
|
|
4003
|
+
"🛅": "left_lguggage",
|
|
4004
4004
|
"⚠️": "warning",
|
|
4005
4005
|
"⚠": "warning",
|
|
4006
4006
|
"🚸": "children_crossing",
|
|
@@ -4750,7 +4750,7 @@ export const nameToEmoji = {
|
|
|
4750
4750
|
"bomb": "💣",
|
|
4751
4751
|
"speech_balloon": "💬",
|
|
4752
4752
|
"eye_in_speech_bubble": "👁🗨",
|
|
4753
|
-
"
|
|
4753
|
+
"left_smpeech_bubble": "🗨",
|
|
4754
4754
|
"right_anger_bubble": "🗯",
|
|
4755
4755
|
"thought_balloon": "💭",
|
|
4756
4756
|
"zzz": "💤",
|
|
@@ -4833,11 +4833,11 @@ export const nameToEmoji = {
|
|
|
4833
4833
|
"call_me_hand_medium_dark_skin_tone": "🤙🏾",
|
|
4834
4834
|
"call_me_hand_dark_skin_tone": "🤙🏿",
|
|
4835
4835
|
"backhand_index_pointing_left": "👈",
|
|
4836
|
-
"
|
|
4837
|
-
"
|
|
4838
|
-
"
|
|
4839
|
-
"
|
|
4840
|
-
"
|
|
4836
|
+
"backhand_index_pointing_left_lgight_skin_tone": "👈🏻",
|
|
4837
|
+
"backhand_index_pointing_left_mdedium_light_skin_tone": "👈🏼",
|
|
4838
|
+
"backhand_index_pointing_left_mdedium_skin_tone": "👈🏽",
|
|
4839
|
+
"backhand_index_pointing_left_mdedium_dark_skin_tone": "👈🏾",
|
|
4840
|
+
"backhand_index_pointing_left_dfark_skin_tone": "👈🏿",
|
|
4841
4841
|
"backhand_index_pointing_right": "👉",
|
|
4842
4842
|
"backhand_index_pointing_right_light_skin_tone": "👉🏻",
|
|
4843
4843
|
"backhand_index_pointing_right_medium_light_skin_tone": "👉🏼",
|
|
@@ -7630,7 +7630,7 @@ export const nameToEmoji = {
|
|
|
7630
7630
|
"passport_control": "🛂",
|
|
7631
7631
|
"customs": "🛃",
|
|
7632
7632
|
"baggage_claim": "🛄",
|
|
7633
|
-
"
|
|
7633
|
+
"left_lguggage": "🛅",
|
|
7634
7634
|
"warning": "⚠",
|
|
7635
7635
|
"children_crossing": "🚸",
|
|
7636
7636
|
"no_entry": "⛔",
|
|
@@ -7772,7 +7772,7 @@ export const nameToEmoji = {
|
|
|
7772
7772
|
"a_button_blood_type": "🅰️",
|
|
7773
7773
|
"ab_button_blood_type": "🆎",
|
|
7774
7774
|
"b_button_blood_type": "🅱️",
|
|
7775
|
-
"
|
|
7775
|
+
"cl_bdutton": "🆑",
|
|
7776
7776
|
"cool_button": "🆒",
|
|
7777
7777
|
"free_button": "🆓",
|
|
7778
7778
|
"information": "ℹ️",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Journal types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const JOURNAL_TYPE_ENUMS = [
|
|
7
|
+
'FIELD',
|
|
8
|
+
'HARVEST',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export const JOURNAL_TYPES_TO_TEXT = {
|
|
12
|
+
FIELD: 'field activities',
|
|
13
|
+
HARVEST: 'harvest activities',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const TEXT_TO_JOURNAL_TYPES = Object.fromEntries(
|
|
17
|
+
Object.entries(JOURNAL_TYPES_TO_TEXT).map(([key, value]) => [value, key]),
|
|
18
|
+
) as Record<string, string>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Activities for each journal types
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export const FIELD_LOG_ACTIVITY_ENUMS = [
|
|
25
|
+
'PREPARE_SOIL',
|
|
26
|
+
'PLANTING',
|
|
27
|
+
'IRRIGATION',
|
|
28
|
+
'FERTILIZATION_COMPOST',
|
|
29
|
+
'PROTECT_CROP',
|
|
30
|
+
'MONITOR_CROP',
|
|
31
|
+
'PRUNING',
|
|
32
|
+
'STRUCTURE_MAINTENANCE',
|
|
33
|
+
'PREPARE_HARVEST',
|
|
34
|
+
'OTHER_FIELD_ACTIVITY',
|
|
35
|
+
] as const;
|
|
36
|
+
|
|
37
|
+
export const HARVEST_LOG_ACTIVITY_ENUMS = [
|
|
38
|
+
'HARVEST_CROP',
|
|
39
|
+
'HARVEST_COUNT',
|
|
40
|
+
'SORT_GRADE',
|
|
41
|
+
'YIELD_LOSS_ESTIMATE',
|
|
42
|
+
'TRANSFER_TO_STORAGE',
|
|
43
|
+
'OTHER_HARVEST_ACTIVITY',
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Activity enums to text
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export const JOURNAL_ACTIVITIES_TO_TEXT = {
|
|
51
|
+
// # Field log activities
|
|
52
|
+
PREPARE_SOIL: 'soil, beds preparation',
|
|
53
|
+
PLANTING: 'seeding, transplanting',
|
|
54
|
+
IRRIGATION: 'irrigation management',
|
|
55
|
+
FERTILIZATION_COMPOST: 'fertilization, compost application',
|
|
56
|
+
PROTECT_CROP: 'weed, pest, disease management',
|
|
57
|
+
MONITOR_CROP: 'crop monitoring',
|
|
58
|
+
PRUNING: 'pruning',
|
|
59
|
+
STRUCTURE_MAINTENANCE: 'trellising, structure maintenance',
|
|
60
|
+
PREPARE_HARVEST: 'preparing crops for harvest',
|
|
61
|
+
OTHER_FIELD_ACTIVITY: 'other field activities',
|
|
62
|
+
|
|
63
|
+
// # Harvest log activities
|
|
64
|
+
HARVEST_CROP: 'harvesting crops',
|
|
65
|
+
HARVEST_COUNT: 'counting, weighing harvested crops',
|
|
66
|
+
SORT_GRADE: 'sorting, grading crops',
|
|
67
|
+
YIELD_LOSS_ESTIMATE: 'estimating yield or loss',
|
|
68
|
+
TRANSFER_TO_STORAGE: 'transferring crops to storage',
|
|
69
|
+
OTHER_HARVEST_ACTIVITY: 'other harvest activities',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const TEXT_TO_JOURNAL_ACTIVITIES = Object.fromEntries(
|
|
73
|
+
Object.entries(JOURNAL_ACTIVITIES_TO_TEXT).map(([key, value]) => [value, key]),
|
|
74
|
+
) as Record<string, string>;
|
package/i18n/app.ts
CHANGED
package/i18n/auth.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
en: {
|
|
3
3
|
// Login
|
|
4
|
-
log_in_sign_up: '
|
|
4
|
+
log_in_sign_up: 'Sign in / Sign up',
|
|
5
5
|
open_app: 'Open app',
|
|
6
6
|
continue_with_google: 'Continue with Google',
|
|
7
7
|
continue_with_discord: 'Continue with Discord',
|
|
8
8
|
continue_with_apple: 'Continue with Apple',
|
|
9
9
|
login_opts: 'Continue with e-mail, ID, or @username',
|
|
10
|
+
login_opts_phone_email: 'Continue with phone number or e-mail',
|
|
10
11
|
resend_verification_email: 'Send verification e-mail', // This is for title of <ModalHeader /> in <AuthSwitch />
|
|
11
12
|
reset_password: 'Reset password',
|
|
12
13
|
forgot_password_: 'Forgot password or username?',
|
|
@@ -15,19 +16,24 @@ export default {
|
|
|
15
16
|
change_password: 'Change password',
|
|
16
17
|
you_are_verified_: 'You are verified!',
|
|
17
18
|
account_is_verified: 'Thank you for verifying your account with e-mail address: %{emailAddress}',
|
|
18
|
-
continue_to_login: 'Continue to
|
|
19
|
+
continue_to_login: 'Continue to sign in',
|
|
19
20
|
|
|
20
21
|
// Auth
|
|
21
22
|
username_not_found: 'No one was found with that username.',
|
|
22
|
-
|
|
23
|
+
signed_in: 'Signed in',
|
|
23
24
|
hello_: 'Hello %{name}!',
|
|
24
|
-
you_are_logged_in: 'You are
|
|
25
|
+
you_are_logged_in: 'You are signed in.',
|
|
25
26
|
password_changed_msg: 'Your password has been changed.',
|
|
26
27
|
request_reset_password_instr: 'Enter your e-mail address and we will send you instructions to reset your password.',
|
|
27
28
|
resend_verification_instr: 'Enter your e-mail address for your account and we will send you a new verification e-mail.',
|
|
28
29
|
reset_password_instr: 'Choose a new password for your account with the e-mail address: %{emailAddress}',
|
|
29
30
|
_send_new_verification: 'to send a new verification e-mail.',
|
|
30
31
|
|
|
32
|
+
// Auth - check fails
|
|
33
|
+
no_account_with_phone: 'No account was found with that phone number.',
|
|
34
|
+
no_account_with_email: 'No account was found with that e-mail address.',
|
|
35
|
+
not_valid_email_or_phone: 'That is not a valid phone number or an e-mail address.',
|
|
36
|
+
|
|
31
37
|
// Reset password (requested)
|
|
32
38
|
reset_password_requested_1: 'Please check your e-mail at ',
|
|
33
39
|
reset_password_requested_2: ' for instructions to reset your password.',
|
|
@@ -38,11 +44,11 @@ export default {
|
|
|
38
44
|
agree_and_continue: 'Agree and continue',
|
|
39
45
|
sign_up_notice_1: 'By selecting "Agree and continue", I agree to the ',
|
|
40
46
|
sign_up_notice_2: ' and acknowledge the ',
|
|
41
|
-
|
|
47
|
+
user_created: 'Account created',
|
|
42
48
|
email_sent: 'E-mail sent',
|
|
43
49
|
check_email_1: 'Please check your e-mail at ',
|
|
44
50
|
check_email_2: ' to verify your account.',
|
|
45
|
-
check_email_3: 'Click "continue" to
|
|
51
|
+
check_email_3: 'Click "continue" to sign in as ',
|
|
46
52
|
check_email_4: ' or re-send another verification link to your e-mail.',
|
|
47
53
|
check_email: 'Check your e-mail',
|
|
48
54
|
not_verified_yet: 'Please verify your e-mail and try again.',
|
package/i18n/datetime.ts
CHANGED
package/i18n/error.ts
CHANGED
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
20012: 'Your token is invalid, please request a new link.',
|
|
50
50
|
20013: 'User already exists with that e-mail address. (%{value})',
|
|
51
51
|
20014: 'User already exists with that username. (%{value})',
|
|
52
|
-
20015: "
|
|
52
|
+
20015: "We couldn't find that user in our database.",
|
|
53
53
|
20016: 'You are being rate limited. Please try again in a moment.',
|
|
54
54
|
20017: 'Please check your-email before requesting another verification link or wait few more seconds.',
|
|
55
55
|
20018: "Your e-mail is already verified. There's no need to verify your e-mail again.",
|
|
@@ -73,7 +73,7 @@ export default {
|
|
|
73
73
|
20035: 'This action is only available to the owner.',
|
|
74
74
|
20036: 'This feature is only available for live chats.',
|
|
75
75
|
20037: 'This notification no longer exists.',
|
|
76
|
-
20038: '
|
|
76
|
+
20038: 'This chat has too many co-owners.',
|
|
77
77
|
20039: 'This chat was deleted or it does not exist.',
|
|
78
78
|
20040: 'This feature is only available to Perks, Plus, or Pro subscribers.',
|
|
79
79
|
20041: 'This live chat is offline.',
|
|
@@ -85,6 +85,9 @@ export default {
|
|
|
85
85
|
20047: 'You must enter a valid password.',
|
|
86
86
|
20048: 'This action is forbidden because you deleted your account.',
|
|
87
87
|
20049: 'You must activate your account before you can use the app.',
|
|
88
|
+
20050: 'That is an invalid ID.',
|
|
89
|
+
20051: 'Could not find user with that phone number. (%{value})',
|
|
90
|
+
20052: 'You do not have access to this organization\'s data.',
|
|
88
91
|
|
|
89
92
|
'29999_title': 'Not ready',
|
|
90
93
|
29999: 'AI chat is not ready right now.',
|
|
@@ -92,10 +95,11 @@ export default {
|
|
|
92
95
|
// 3x
|
|
93
96
|
|
|
94
97
|
30000: 'An unknown error occured.',
|
|
95
|
-
30003: "
|
|
96
|
-
|
|
98
|
+
30003: "We're having trouble accessing the server. Please try again in a moment.",
|
|
99
|
+
30004: 'We made a mistake in our code. We will fix this soon.',
|
|
100
|
+
30010: 'Google is not responding right now. Please try again in a momment.',
|
|
97
101
|
30011: 'Something went wrong with your Google authentication attempt. Please try again in a moment.',
|
|
98
|
-
30013: '
|
|
102
|
+
30013: 'Our database is in maintenance. Please try again in a moment.',
|
|
99
103
|
30014: 'Stripe CardElement is incorrect.',
|
|
100
104
|
30015: 'Invalid payment form values.',
|
|
101
105
|
30016: 'Stripe API request failed with an unknown reason. Please try again in a moment.',
|
|
@@ -107,7 +111,8 @@ export default {
|
|
|
107
111
|
30022: 'Your CVC number is incorrect.',
|
|
108
112
|
30023: 'Your card expiration date is incorrect.',
|
|
109
113
|
30024: 'Stripe customer and payment method was mismatched.',
|
|
110
|
-
30025: '
|
|
114
|
+
30025: 'E-mail server is experiencing an outage. Please try again in a moment.',
|
|
115
|
+
30028: 'You cannot send an empty message.',
|
|
111
116
|
|
|
112
117
|
// Form errors
|
|
113
118
|
|
package/i18n/form.ts
CHANGED
package/i18n/index.ts
CHANGED
package/i18n/user.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
en: {
|
|
3
3
|
displayName: 'Display name',
|
|
4
|
-
displayName_ph: 'e.g
|
|
4
|
+
displayName_ph: 'e.g. "Jane Doe"',
|
|
5
5
|
displayName_info: 'Display name is how others will see you.',
|
|
6
6
|
pronouns: 'Pronouns',
|
|
7
7
|
pronouns_ph: 'Enter your pronouns',
|
|
8
8
|
about: 'About me',
|
|
9
9
|
about_ph: 'This text will be displayed on your profile for others to see.',
|
|
10
10
|
username: 'Username',
|
|
11
|
-
username_ph: 'e.g
|
|
11
|
+
username_ph: 'e.g. "@jane_doe"',
|
|
12
12
|
username_info: 'Username, ID, and e-mail is used to log in to your account.',
|
|
13
13
|
email: 'E-mail',
|
|
14
|
-
email_ph: 'e.g
|
|
14
|
+
email_ph: 'e.g. jane_doe@email.com',
|
|
15
|
+
phone: 'e.g. jane_doe@email.com',
|
|
16
|
+
// phone_ph: 'e.g. 222-333-4444',
|
|
17
|
+
phone_ph: 'e.g. 123-444-5555',
|
|
15
18
|
password: 'Password',
|
|
16
19
|
password_ph: 'Enter your password',
|
|
17
20
|
passwordRepeat: 'Password (please repeat)',
|
package/main.ts
CHANGED
|
@@ -7,7 +7,8 @@ import error from './i18n/error';
|
|
|
7
7
|
import form from './i18n/form';
|
|
8
8
|
import user from './i18n/user';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// Get the correct type for ENV
|
|
11
|
+
let ENV: Map<string, string | boolean | number> = new Map();
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Extend i18n with app specific texts
|
|
@@ -50,13 +51,44 @@ export function configI18n(texts: Record<string, any>) {
|
|
|
50
51
|
|
|
51
52
|
export function registerENV(env: Record<string, string>) {
|
|
52
53
|
// Do not use process.env; because this package is used in client + server
|
|
53
|
-
|
|
54
|
+
|
|
55
|
+
for (const key in env) {
|
|
56
|
+
if (
|
|
57
|
+
typeof key !== 'undefined' &&
|
|
58
|
+
Object.prototype.hasOwnProperty.call(env, key)
|
|
59
|
+
) {
|
|
60
|
+
ENV.set(key, env[key]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Shim some development commands
|
|
65
|
+
console.dev = (
|
|
66
|
+
str: string,
|
|
67
|
+
...args: any[]
|
|
68
|
+
) => {
|
|
69
|
+
if (ENV.get('NODE_ENV') === 'development') {
|
|
70
|
+
const [preset, ...otherArgs] = args;
|
|
71
|
+
|
|
72
|
+
let style;
|
|
73
|
+
switch (preset) {
|
|
74
|
+
case 'em':
|
|
75
|
+
style = 'background: #FFF380;';
|
|
76
|
+
break;
|
|
77
|
+
case 'warning':
|
|
78
|
+
style = 'background: #E64545; color: #FFF;';
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log(`%c${str}`, `${style || 'background: #F2F0DA;'} padding: 3px 5px;`, ...(style ? otherArgs : args));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
54
86
|
}
|
|
55
87
|
|
|
56
88
|
/**
|
|
57
89
|
* Get environment variables
|
|
58
90
|
*/
|
|
59
91
|
|
|
60
|
-
export function getENVVariable(namespace: string): string | undefined {
|
|
61
|
-
return ENV
|
|
92
|
+
export function getENVVariable(namespace: string): string | boolean | number | undefined {
|
|
93
|
+
return ENV.get(namespace);
|
|
62
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Contains all the basic requirements for all @jsb188 apps.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"types": "types.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./main.ts",
|
|
12
|
+
"./platform": "./platform.ts",
|
|
12
13
|
"./i18n": "./i18n/index.ts",
|
|
13
14
|
"./constants/app": "./constants/app.ts",
|
|
14
15
|
"./constants/billing": "./constants/billing.ts",
|
|
@@ -19,16 +20,20 @@
|
|
|
19
20
|
"./utils/billing": "./utils/billing.ts",
|
|
20
21
|
"./utils/datetime": "./utils/datetime.ts",
|
|
21
22
|
"./utils/emoji": "./utils/emoji.ts",
|
|
23
|
+
"./utils/journal": "./utils/journal.ts",
|
|
22
24
|
"./utils/logic": "./utils/logic.ts",
|
|
23
25
|
"./utils/number": "./utils/number.ts",
|
|
24
26
|
"./utils/object": "./utils/object.ts",
|
|
25
27
|
"./utils/string": "./utils/string.ts",
|
|
26
28
|
"./utils/url_client": "./utils/url_client.ts",
|
|
27
29
|
"./utils/user": "./utils/user.ts",
|
|
28
|
-
"./types/
|
|
29
|
-
"./types/
|
|
30
|
-
"./types/
|
|
31
|
-
"./types/
|
|
30
|
+
"./types/ai.d": "./types/ai.d.ts",
|
|
31
|
+
"./types/app.d": "./types/app.d.ts",
|
|
32
|
+
"./types/auth.d": "./types/auth.d.ts",
|
|
33
|
+
"./types/form.d": "./types/form.d.ts",
|
|
34
|
+
"./types/journal.d": "./types/journal.d.ts",
|
|
35
|
+
"./types/organization.d": "./types/organization.d.ts",
|
|
36
|
+
"./types/user.d": "./types/user.d.ts"
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
39
|
"node-polyglot": "^2.6.0"
|
package/platform.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
|
|
2
|
+
const PLATFORM_HANDLERS: Record<string, any> = {};
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get current platform
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function getPlatform(): 'WEB' | 'MOBILE' | 'UNKNOWN' {
|
|
9
|
+
return PLATFORM_HANDLERS?.getPlatform?.() || 'UNKNOWN';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Fetch last used login token
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const fetchAuthToken = (cb: (token: string | null) => void): void => {
|
|
17
|
+
return PLATFORM_HANDLERS?.fetchAuthToken?.(cb) || cb(null);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Delete auth token
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export const deleteAuthToken = (): void => {
|
|
25
|
+
return PLATFORM_HANDLERS?.deleteAuthToken?.();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Save token after login
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export function saveAuthTokenToPlatform(token: string, cb: () => void) {
|
|
33
|
+
return PLATFORM_HANDLERS?.saveAuthTokenToPlatform?.(token, cb) || cb();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Clear platform and app specific (local API) cache
|
|
38
|
+
* Change this based on what the app uses
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
export function clearAppCache() {
|
|
42
|
+
return PLATFORM_HANDLERS?.clearAppCache?.();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Fetch last used light mode setting
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
export const fetchLightModeSetting = (
|
|
50
|
+
accountId: number | null,
|
|
51
|
+
cb: (lightMode: string) => void,
|
|
52
|
+
): void => {
|
|
53
|
+
return PLATFORM_HANDLERS?.fetchLightModeSetting?.(accountId, cb) || cb('SYSTEM');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get correct platform
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
export function getOS() {
|
|
61
|
+
return PLATFORM_HANDLERS?.getOS?.();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Update theme
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
export function updateAppTheme(lightMode: string, theme: string) {
|
|
69
|
+
return PLATFORM_HANDLERS?.updateAppTheme?.(lightMode, theme);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get the last version of app
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
export function getLocalLastVersion(accountId: string) {
|
|
77
|
+
return PLATFORM_HANDLERS?.getLocalLastVersion?.(accountId);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Save the last version of app
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
export function saveLocalLastVersion(accountId: string, version: string) {
|
|
85
|
+
return PLATFORM_HANDLERS?.saveLocalLastVersion?.(accountId, version);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get the necessary Object data for file input
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
export function getFileInputObject(fileInput: File) {
|
|
93
|
+
return PLATFORM_HANDLERS?.getFileInputObject?.(fileInput) || fileInput;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get buffer data from file
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
export function getBufferDataFromFile(file: any) {
|
|
101
|
+
return PLATFORM_HANDLERS?.getBufferDataFromFile?.(file) || file;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Check if system is dark mode
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
export function isSystemDarkMode() {
|
|
109
|
+
return PLATFORM_HANDLERS?.isSystemDarkMode?.();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Register platform specific handlers
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
export function registerPlatformHandlers(handlers: Record<string, any>) {
|
|
117
|
+
for (const key in handlers) {
|
|
118
|
+
if (
|
|
119
|
+
Object.prototype.hasOwnProperty.call(handlers, key) &&
|
|
120
|
+
typeof handlers[key] === 'function'
|
|
121
|
+
) {
|
|
122
|
+
PLATFORM_HANDLERS[key] = handlers[key];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
package/types/ai.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
// AI chat types
|
|
3
|
+
|
|
4
|
+
export type AIChatMessageType = 'MESSAGE' | 'SMS' | 'FUNCTION_CALL'| 'FUNCTION_CALL_OUTPUT';
|
|
5
|
+
|
|
6
|
+
// AI events
|
|
7
|
+
|
|
8
|
+
export type AIEventErrorName =
|
|
9
|
+
| 'AI_EVENT_UNKNOWN_ERR'
|
|
10
|
+
| 'AI_EVENT_DEVELOPER_ERR'
|
|
11
|
+
| 'AI_EVENT_NO_ACCESS'
|
|
12
|
+
| 'AI_COULD_NOT_RESOLVE'
|
|
13
|
+
| 'AI_CONTEXT_ERR'
|
|
14
|
+
| 'AI_ORG_ACL_FAILED'
|
|
15
|
+
| 'MISSING_API_KEY'
|
|
16
|
+
| 'LLM_PROVIDER_NOT_FOUND'
|
|
17
|
+
| 'MODERATION_MISSING'
|
|
18
|
+
| 'MODERATION_SERVICE_ERR'
|
|
19
|
+
| 'UNKNOWN_LLM_ERR'
|
|
20
|
+
| 'UNFINISHED_LOGIC';
|
|
21
|
+
|
|
22
|
+
// AI chat
|
|
23
|
+
|
|
24
|
+
export interface AIChatObj {
|
|
25
|
+
id: string;
|
|
26
|
+
calDate: string;
|
|
27
|
+
summary: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
}
|
package/types/app.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface EditUserPlusModalProps extends EditIfaceModalProps {
|
|
|
24
24
|
|
|
25
25
|
export type DarkOrLightEnum = 'light' | 'dark';
|
|
26
26
|
|
|
27
|
+
export type ColorEnum = 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'slate' | 'zinc' | 'stone';
|
|
28
|
+
|
|
27
29
|
// Stripe types
|
|
28
30
|
|
|
29
31
|
export type PlatformProductGroupEnum = 'PERKS' | 'PLUS' | 'PRO' | 'COINS';
|
package/types/auth.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { OrganizationShortData } from './organization.d';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Auth enums
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type AuthTypeEnum = 'ID' | 'USERNAME' | 'EMAIL' | 'PHONE';
|
|
8
|
+
export type LightModeEnum = 'LIGHT' | 'DARK' | 'SYSTEM';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Account
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface AccountData {
|
|
15
|
+
id: string;
|
|
16
|
+
deleted: boolean;
|
|
17
|
+
|
|
18
|
+
plus: any; // placeholder for later
|
|
19
|
+
|
|
20
|
+
profile: {
|
|
21
|
+
id: string;
|
|
22
|
+
firstName: string;
|
|
23
|
+
lastName: string;
|
|
24
|
+
photoId: string;
|
|
25
|
+
photoUri: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
email: {
|
|
29
|
+
id: string;
|
|
30
|
+
address: string;
|
|
31
|
+
verified: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
phone: {
|
|
35
|
+
id: string;
|
|
36
|
+
number: string;
|
|
37
|
+
verified: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AccountSettings {
|
|
42
|
+
theme: string | null;
|
|
43
|
+
lightMode: LightModeEnum;
|
|
44
|
+
timeZone: string | null;
|
|
45
|
+
showSelfAvatar: boolean;
|
|
46
|
+
isBubbleOther: boolean;
|
|
47
|
+
showOtherAvatar: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Auth context
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
export interface AuthenticationData {
|
|
55
|
+
token: string | null;
|
|
56
|
+
timeZone: string | null;
|
|
57
|
+
account: AccountData | null;
|
|
58
|
+
settings: AccountSettings | null;
|
|
59
|
+
primaryOrganizationId: string | null;
|
|
60
|
+
activated: boolean;
|
|
61
|
+
hasPassword: boolean;
|
|
62
|
+
version: string;
|
|
63
|
+
}
|