@jsb188/app 1.0.4 → 1.1.3

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 CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- // App constants
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
- CURRENT_USER_ID: 'CU:',
19
+ CURRENT_ACCOUNT_ID: 'CU:',
20
20
 
21
21
  // Settings
22
22
  LIGHT_MODE: 'LM:',
@@ -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
- "đŸ—¨ī¸": "left_speech_bubble",
168
- "🗨": "left_speech_bubble",
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
- "👈đŸģ": "backhand_index_pointing_left_light_skin_tone",
254
- "👈đŸŧ": "backhand_index_pointing_left_medium_light_skin_tone",
255
- "👈đŸŊ": "backhand_index_pointing_left_medium_skin_tone",
256
- "👈🏾": "backhand_index_pointing_left_medium_dark_skin_tone",
257
- "👈đŸŋ": "backhand_index_pointing_left_dark_skin_tone",
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
- "🛅": "left_luggage",
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
- "left_speech_bubble": "🗨",
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
- "backhand_index_pointing_left_light_skin_tone": "👈đŸģ",
4837
- "backhand_index_pointing_left_medium_light_skin_tone": "👈đŸŧ",
4838
- "backhand_index_pointing_left_medium_skin_tone": "👈đŸŊ",
4839
- "backhand_index_pointing_left_medium_dark_skin_tone": "👈🏾",
4840
- "backhand_index_pointing_left_dark_skin_tone": "👈đŸŋ",
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
- "left_luggage": "🛅",
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
- "cl_button": "🆑",
7775
+ "cl_bdutton": "🆑",
7776
7776
  "cool_button": "🆒",
7777
7777
  "free_button": "🆓",
7778
7778
  "information": "â„šī¸",
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Journal types
3
+ */
4
+
5
+ export const JOURNAL_TYPE_ENUMS = [
6
+ 'SEED',
7
+ 'FIELD',
8
+ 'HARVEST',
9
+ 'POST_HARVEST',
10
+ 'SALES',
11
+ ];
12
+
13
+ export const JOURNAL_TYPES_TO_TEXT = {
14
+ SEED: 'seed purchases',
15
+ FIELD: 'field activities',
16
+ HARVEST: 'harvest activities',
17
+ POST_HARVEST: 'handling, washing, sorting, grading, packaging after harvest',
18
+ SALES: 'sales',
19
+ };
20
+
21
+ export const TEXT_TO_JOURNAL_TYPES = Object.fromEntries(
22
+ Object.entries(JOURNAL_TYPES_TO_TEXT).map(([key, value]) => [value, key]),
23
+ ) as Record<string, string>;
24
+
25
+ /**
26
+ * Activities for each journal types
27
+ */
28
+
29
+ export const SEED_LOG_ACTIVITY_ENUMS = [
30
+ 'SEED_PURCHASE_INFO',
31
+ 'SEED_COMPLIANCE_NOTE',
32
+ 'OTHER_SEED_ACTIVITY',
33
+ ] as const;
34
+
35
+ export const FIELD_LOG_ACTIVITY_ENUMS = [
36
+ 'PREPARE_SOIL',
37
+ 'PLANTING',
38
+ 'IRRIGATION',
39
+ 'FERTILIZATION_COMPOST',
40
+ 'PROTECT_CROP',
41
+ 'MONITOR_CROP',
42
+ 'PRUNING',
43
+ 'STRUCTURE_MAINTENANCE',
44
+ 'PREPARE_HARVEST',
45
+ 'OTHER_FIELD_ACTIVITY',
46
+ ] as const;
47
+
48
+ export const HARVEST_LOG_ACTIVITY_ENUMS = [
49
+ 'HARVEST_CROP',
50
+ 'HARVEST_COUNT',
51
+ 'SORT_GRADE',
52
+ 'YIELD_LOSS_ESTIMATE',
53
+ 'OTHER_HARVEST_ACTIVITY',
54
+ ] as const;
55
+
56
+ export const POST_HARVEST_LOG_ACTIVITY_ENUMS = [
57
+ 'POST_HARVEST_HANDLING',
58
+ 'POST_HARVEST_PACKAGING',
59
+ 'OTHER_POST_HARVEST_ACTIVITY',
60
+ ] as const;
61
+
62
+ export const SALES_LOG_ACTIVITY_ENUMS = [
63
+ 'SALE_TRANSACTION',
64
+ 'SALE_DETAILS',
65
+ 'SALE_FEEDBACK',
66
+ 'OTHER_SALES_ACTIVITY',
67
+ ] as const;
68
+
69
+ /**
70
+ * Activity enums to text
71
+ */
72
+
73
+ export const JOURNAL_ACTIVITIES_TO_TEXT = {
74
+ // # Seed log activities
75
+ SEED_PURCHASE_INFO: 'seed purchase information',
76
+ SEED_COMPLIANCE_NOTE: 'seed compliance notes',
77
+ OTHER_SEED_ACTIVITY: 'other seed purchase related notes',
78
+
79
+ // # Field log activities
80
+ PREPARE_SOIL: 'soil, beds preparation',
81
+ PLANTING: 'seeding, transplanting',
82
+ IRRIGATION: 'irrigation management',
83
+ FERTILIZATION_COMPOST: 'fertilization, compost application',
84
+ PROTECT_CROP: 'weed, pest, disease management',
85
+ MONITOR_CROP: 'crop monitoring',
86
+ PRUNING: 'pruning',
87
+ STRUCTURE_MAINTENANCE: 'trellising, structure maintenance',
88
+ PREPARE_HARVEST: 'preparing crops for harvest',
89
+ OTHER_FIELD_ACTIVITY: 'other field activities',
90
+
91
+ // # Harvest log activities
92
+ HARVEST_CROP: 'harvesting crops',
93
+ HARVEST_COUNT: 'counting, weighing harvested crops',
94
+ SORT_GRADE: 'sorting, grading crops',
95
+ YIELD_LOSS_ESTIMATE: 'estimating yield or loss',
96
+ OTHER_HARVEST_ACTIVITY: 'other harvest activities',
97
+
98
+ // # Post-harvest log activities
99
+ POST_HARVEST_HANDLING: 'washing, drying, trimming, sorting, or grading produce',
100
+ POST_HARVEST_PACKAGING: 'packaging, cooling, or moving produce to storage',
101
+ OTHER_POST_HARVEST_ACTIVITY: 'other post-harvest activities',
102
+
103
+ // # Sales log activities
104
+ SALE_TRANSACTION: 'sale transactions',
105
+ SALE_DETAILS: 'sale details',
106
+ SALE_FEEDBACK: 'sale feedback or issues',
107
+ OTHER_SALES_ACTIVITY: 'other sales related notes',
108
+ };
109
+
110
+ export const TEXT_TO_JOURNAL_ACTIVITIES = Object.fromEntries(
111
+ Object.entries(JOURNAL_ACTIVITIES_TO_TEXT).map(([key, value]) => [value, key]),
112
+ ) as Record<string, string>;
113
+
114
+ // Moved to walk-in
115
+ // Hydrocooled immediately after harvest
116
+ // Bagged and labeled greens
117
+ // Packed in clamshells
118
+ // Stickered with farm logo
package/i18n/app.ts CHANGED
@@ -9,6 +9,8 @@ export default {
9
9
  // All apps
10
10
  route_: 'App | %{text}',
11
11
  route_auth: 'Log in or sign up',
12
+ route_not_found: 'Page Not Found',
13
+ route_not_found_desc: 'The page you are looking for does not exist.',
12
14
 
13
15
  // @home screen
14
16
  hey_: 'Hey, ',
package/i18n/auth.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  export default {
2
2
  en: {
3
3
  // Login
4
- log_in_sign_up: 'Log in / Sign up',
4
+ welcome_back: 'Welcome back',
5
+ log_in_sign_up: 'Sign in / Sign up',
5
6
  open_app: 'Open app',
6
7
  continue_with_google: 'Continue with Google',
7
8
  continue_with_discord: 'Continue with Discord',
8
9
  continue_with_apple: 'Continue with Apple',
9
10
  login_opts: 'Continue with e-mail, ID, or @username',
11
+ login_opts_phone_email: 'Continue with phone number or e-mail',
12
+ verify_your_acc: 'Verify your account',
10
13
  resend_verification_email: 'Send verification e-mail', // This is for title of <ModalHeader /> in <AuthSwitch />
11
14
  reset_password: 'Reset password',
12
15
  forgot_password_: 'Forgot password or username?',
@@ -15,19 +18,24 @@ export default {
15
18
  change_password: 'Change password',
16
19
  you_are_verified_: 'You are verified!',
17
20
  account_is_verified: 'Thank you for verifying your account with e-mail address: %{emailAddress}',
18
- continue_to_login: 'Continue to log in',
21
+ continue_to_login: 'Continue to sign in',
19
22
 
20
23
  // Auth
21
24
  username_not_found: 'No one was found with that username.',
22
- login_success: 'Logged In',
25
+ signed_in: 'Signed in',
23
26
  hello_: 'Hello %{name}!',
24
- you_are_logged_in: 'You are logged in.',
27
+ you_are_logged_in: 'You are signed in.',
25
28
  password_changed_msg: 'Your password has been changed.',
26
29
  request_reset_password_instr: 'Enter your e-mail address and we will send you instructions to reset your password.',
27
30
  resend_verification_instr: 'Enter your e-mail address for your account and we will send you a new verification e-mail.',
28
31
  reset_password_instr: 'Choose a new password for your account with the e-mail address: %{emailAddress}',
29
32
  _send_new_verification: 'to send a new verification e-mail.',
30
33
 
34
+ // Auth - check fails
35
+ no_account_with_phone: 'No account was found with that phone number.',
36
+ no_account_with_email: 'No account was found with that e-mail address.',
37
+ not_valid_email_or_phone: 'That is not a valid phone number or an e-mail address.',
38
+
31
39
  // Reset password (requested)
32
40
  reset_password_requested_1: 'Please check your e-mail at ',
33
41
  reset_password_requested_2: ' for instructions to reset your password.',
@@ -35,14 +43,15 @@ export default {
35
43
 
36
44
  // Sign up
37
45
  sign_up: 'Sign up',
46
+ create_account: 'Create an account',
38
47
  agree_and_continue: 'Agree and continue',
39
48
  sign_up_notice_1: 'By selecting "Agree and continue", I agree to the ',
40
49
  sign_up_notice_2: ' and acknowledge the ',
41
- account_created: 'Account created',
50
+ user_created: 'Account created',
42
51
  email_sent: 'E-mail sent',
43
52
  check_email_1: 'Please check your e-mail at ',
44
53
  check_email_2: ' to verify your account.',
45
- check_email_3: 'Click "continue" to log in as ',
54
+ check_email_3: 'Click "continue" to sign in as ',
46
55
  check_email_4: ' or re-send another verification link to your e-mail.',
47
56
  check_email: 'Check your e-mail',
48
57
  not_verified_yet: 'Please verify your e-mail and try again.',
@@ -52,6 +61,7 @@ export default {
52
61
  resend_verification: 'Send verification e-mail',
53
62
 
54
63
  // Sign out
55
- signing_out_: 'Logging you out...'
64
+ sign_out: 'Sign out',
65
+ signing_out_: 'Signing you out...'
56
66
  },
57
67
  };
package/i18n/datetime.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export default {
2
2
  en: {
3
-
4
3
  // Ago
5
4
  just_now: 'just now',
6
5
  in_minutes_ct: 'in %{smart_count} minute||||in %{smart_count} minutes',
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: "Sorry, we couldn't find that user in our database.",
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: 'Sorry! This chat has too many co-owners.',
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: 'This page does not exist.',
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: "Sorry, we're having trouble accessing the server. Please try again in a moment.",
96
- 30010: 'Sorry, Google is not responding right now. Please try again in a momment.',
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: 'Sorry, our database is in maintenance. Please try again in a moment.',
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: 'Sorry, e-mail server is experiencing an outage. Please try again in a moment.',
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
@@ -7,6 +7,8 @@ export default {
7
7
  or: 'or',
8
8
  cancel: 'Cancel',
9
9
  continue: 'Continue',
10
+ apply: 'Apply',
11
+ apply_filters: 'Apply filters',
10
12
  hide: 'Hide',
11
13
  show: 'Show',
12
14
  try_again: 'Try again',
@@ -41,6 +43,7 @@ export default {
41
43
  add: 'Add',
42
44
  remove: 'Remove',
43
45
  removed: 'Removed',
46
+ history: 'History',
44
47
  edit: 'Edit',
45
48
  enter: 'Enter',
46
49
  accept: 'Accept',
@@ -56,6 +59,7 @@ export default {
56
59
  click_here: 'Click here',
57
60
  success: 'Success',
58
61
  success_: 'Success!',
62
+ help: 'Help',
59
63
 
60
64
  // Day periods
61
65
  greet_MORNING: 'Good morning, %{name}.',
package/i18n/index.ts CHANGED
@@ -2,5 +2,4 @@ import Polyglot from 'node-polyglot';
2
2
  import type NodePolyglot from '../types.d.ts'
3
3
 
4
4
  const i18n = new Polyglot();
5
-
6
5
  export default i18n as NodePolyglot;
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., "Jane Doe"',
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., "@jane_doe"',
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., jane_doe@email.com',
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)',
@@ -61,10 +64,12 @@ export default {
61
64
  copy_id: 'Copy ID',
62
65
 
63
66
  // Profile
67
+ your_profile: 'Your profile',
64
68
  open_profile: 'Open profile',
65
69
  cards_ct: '%{smart_count} Card||||%{smart_count} Cards',
66
70
  report_user: 'Report user',
67
71
  profile_deactivated_desc: 'This account has been deactivated.',
72
+ phone_numbers: 'Phone numbers',
68
73
 
69
74
  // Friend status
70
75
  blocked: 'Blocked',
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
- let ENV: Record<string, string> = {};
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
- ENV = { ...env };
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[namespace];
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.0.4",
3
+ "version": "1.1.3",
4
4
  "description": "Contains all the basic requirements for all @jsb188 apps.",
5
5
  "license": "ISC",
6
6
  "author": "jsb188",
@@ -9,29 +9,36 @@
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",
15
16
  "./constants/emoji": "./constants/emoji.ts",
17
+ "./constants/journal": "./constants/journal.ts",
16
18
  "./constants/user": "./constants/user.ts",
17
19
  "./constants/ws": "./constants/ws.ts",
18
20
  "./utils/api": "./utils/api.ts",
19
21
  "./utils/billing": "./utils/billing.ts",
20
22
  "./utils/datetime": "./utils/datetime.ts",
21
23
  "./utils/emoji": "./utils/emoji.ts",
24
+ "./utils/journal": "./utils/journal.ts",
22
25
  "./utils/logic": "./utils/logic.ts",
23
26
  "./utils/number": "./utils/number.ts",
24
27
  "./utils/object": "./utils/object.ts",
25
28
  "./utils/string": "./utils/string.ts",
26
29
  "./utils/url_client": "./utils/url_client.ts",
27
30
  "./utils/user": "./utils/user.ts",
28
- "./types/app": "./types/app.d.ts",
29
- "./types/datetime": "./types/datetime.d.ts",
30
- "./types/form": "./types/form.d.ts",
31
- "./types/user": "./types/user.d.ts"
31
+ "./types/ai.d": "./types/ai.d.ts",
32
+ "./types/app.d": "./types/app.d.ts",
33
+ "./types/auth.d": "./types/auth.d.ts",
34
+ "./types/form.d": "./types/form.d.ts",
35
+ "./types/journal.d": "./types/journal.d.ts",
36
+ "./types/organization.d": "./types/organization.d.ts",
37
+ "./types/user.d": "./types/user.d.ts"
32
38
  },
33
39
  "dependencies": {
34
- "node-polyglot": "^2.6.0"
40
+ "node-polyglot": "^2.6.0",
41
+ "luxon": "^3.6.1"
35
42
  },
36
43
  "scripts": {
37
44
  "test": "echo \"Error: no test specified\" && exit 1"
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
+ }