@jsb188/app 1.1.5 → 1.1.7

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 (53) hide show
  1. package/package.json +31 -30
  2. package/src/constants/app.ts +367 -0
  3. package/src/constants/other.ts +17 -0
  4. package/src/constants/storage.ts +4 -0
  5. package/src/constants/wsActions.ts +21 -0
  6. package/{i18n → src/i18n}/account.ts +19 -6
  7. package/src/i18n/ai_agent.ts +88 -0
  8. package/{i18n → src/i18n}/app.ts +4 -18
  9. package/{i18n → src/i18n}/auth.ts +18 -8
  10. package/{i18n → src/i18n}/billing.ts +2 -2
  11. package/src/i18n/country.ts +249 -0
  12. package/src/i18n/datetime.ts +60 -0
  13. package/{i18n → src/i18n}/error.ts +18 -7
  14. package/src/i18n/form.ts +295 -0
  15. package/src/i18n/index.ts +35 -0
  16. package/src/i18n/log.ts +484 -0
  17. package/src/i18n/message.ts +11 -0
  18. package/src/i18n/org.ts +165 -0
  19. package/src/i18n/product.ts +75 -0
  20. package/{main.ts → src/main.ts} +20 -29
  21. package/{types → src/types}/account.d.ts +9 -8
  22. package/src/types/app.d.ts +74 -0
  23. package/{types → src/types}/auth.d.ts +1 -2
  24. package/{types → src/types}/form.d.ts +1 -1
  25. package/src/types/other.d.ts +44 -0
  26. package/src/types/storage.d.ts +70 -0
  27. package/{utils/user.ts → src/utils/account.ts} +7 -84
  28. package/{utils → src/utils}/api.ts +4 -4
  29. package/{utils → src/utils}/billing.ts +1 -1
  30. package/{utils → src/utils}/datetime.ts +295 -33
  31. package/{utils → src/utils}/logic.ts +42 -5
  32. package/{utils → src/utils}/number.ts +89 -16
  33. package/{utils → src/utils}/object.ts +164 -11
  34. package/{utils → src/utils}/string.ts +165 -34
  35. package/{utils → src/utils}/timeZone.ts +168 -13
  36. package/{utils → src/utils}/url_client.ts +1 -1
  37. package/tsconfig.json +13 -0
  38. package/constants/app.ts +0 -80
  39. package/constants/organization.ts +0 -12
  40. package/constants/ws.ts +0 -47
  41. package/i18n/datetime.ts +0 -21
  42. package/i18n/form.ts +0 -115
  43. package/i18n/index.ts +0 -5
  44. package/types/app.d.ts +0 -49
  45. package/types/organization.d.ts +0 -94
  46. package/utils/organization.ts +0 -102
  47. /package/{constants → src/constants}/billing.ts +0 -0
  48. /package/{constants → src/constants}/emoji.ts +0 -0
  49. /package/{constants → src/constants}/user.ts +0 -0
  50. /package/{platform.ts → src/platform.ts} +0 -0
  51. /package/{types → src/types}/ai.d.ts +0 -0
  52. /package/{types.d.ts → src/types.d.ts} +0 -0
  53. /package/{utils → src/utils}/emoji.ts +0 -0
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "noEmit": true,
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "esModuleInterop": true
11
+ },
12
+ "include": ["src/**/*"]
13
+ }
package/constants/app.ts DELETED
@@ -1,80 +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
- mainBodyScrollArea: 'main_scr',
12
- popOverScrollArea: 'pop_over_scr',
13
- };
14
-
15
- // Local storage
16
-
17
- export const STORAGE_KEYS = {
18
- // Authentication
19
- AUTH_TOKEN: 'AT', // There's no ":", so this is used as-is
20
- LAST_VERSION: 'LV:', // ":" at end means it's a prefix
21
- CURRENT_ACCOUNT_ID: 'CU:',
22
-
23
- // Settings
24
- LIGHT_MODE: 'LM:',
25
- } as Record<string, string>;
26
-
27
- // Support e-mails
28
-
29
- export const SUPPORT_EMAILS = {
30
- marketday: 'hello@marketday.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
- }>;
48
-
49
- // Languages
50
-
51
- export const SUPPORTED_LANGUAGES = [
52
- 'ENGLISH',
53
- 'SPANISH',
54
- ];
55
-
56
- // Colors
57
-
58
- export const COLORS = [
59
- 'red',
60
- 'orange',
61
- 'brown',
62
- 'amber',
63
- 'yellow',
64
- 'lime',
65
- 'green',
66
- 'emerald',
67
- 'teal',
68
- 'cyan',
69
- 'sky',
70
- 'blue',
71
- 'indigo',
72
- 'violet',
73
- 'purple',
74
- 'fuchsia',
75
- 'pink',
76
- 'rose',
77
- 'slate',
78
- 'zinc',
79
- 'stone'
80
- ];
@@ -1,12 +0,0 @@
1
- // Organization constants
2
- // IMPORTANT NOTE: Array order must *never* change, indexes are used to create PDF URLs
3
-
4
- export const OPERATION_ENUMS = ['ARABLE', 'LIVESTOCK'];
5
-
6
- // Employee ACL
7
-
8
- export const ROLE_ENUMS = ['MEMBER', 'MANAGER', 'ADMIN', 'OWNER']; // first is default value
9
-
10
- // Role categories (used for reminders)
11
-
12
- export const ROLE_CATEGORY_ENUMS = ['EMPLOYEES_ONLY', 'MANAGERS_ONLY'];
package/constants/ws.ts DELETED
@@ -1,47 +0,0 @@
1
- const WS_ACTIONS = {
2
- // Socket connection
3
- connect: 'connect',
4
- disconnect: 'disconnect',
5
- auth: 'auth',
6
-
7
- // App
8
- alert: 'alrt',
9
- data_update: 'du',
10
-
11
- // User
12
- me: 'me:',
13
- user_status: 'us:',
14
-
15
- // Chats list
16
- chats_list: 'cl:',
17
-
18
- // Chat
19
- chat_join: 'cj:',
20
- chat_leave_all: 'cla',
21
- chat_typing: 'ct',
22
- chat_message: 'cm',
23
- chat_read: 'cr',
24
- chat_moderate: 'cmd',
25
-
26
- // Live chats
27
- live_list: 'll:',
28
- live_list_stop: 'lls',
29
- live_start: 'lsr',
30
- live_stop: 'lsp',
31
- live_join: 'uslj',
32
- live_leave: 'usll',
33
- live_users_list: 'lul',
34
-
35
- // Peer
36
- peer_call: 'pc:',
37
- peer_accept: 'pa:',
38
- peer_decline: 'pd:',
39
- peer_leave: 'pl',
40
- peer_join: 'pj',
41
- peer_speaking: 'ps',
42
- peer_user_id: 'pui',
43
- peer_users_sync: 'pus',
44
- peer_users_list: 'pul',
45
- };
46
-
47
- export default WS_ACTIONS;
package/i18n/datetime.ts DELETED
@@ -1,21 +0,0 @@
1
- export default {
2
- en: {
3
- // Ago
4
- just_now: 'just now',
5
- in_minutes_ct: 'in %{smart_count} minute||||in %{smart_count} minutes',
6
- in_hours_ct: 'in %{smart_count} hour||||in %{smart_count} hours',
7
- minutes_ago_ct: '%{smart_count} minute ago||||%{smart_count} minutes ago',
8
- hours_ago_ct: '%{smart_count} hour ago||||%{smart_count} hours ago',
9
-
10
- // Time period
11
- period_TOMORROW: 'Tomorrow',
12
- period_TODAY: 'Today',
13
- period_YESTERDAY: 'Yesterday',
14
- period_THIS_WEEK: 'This week',
15
- period_THIS_MONTH: 'This month',
16
- period_LAST_WEEK: 'Last week',
17
- period_LAST_MONTH: 'Last month',
18
- period_OLDER: 'History',
19
- period_UPCOMING: 'Upcoming',
20
- }
21
- };
package/i18n/form.ts DELETED
@@ -1,115 +0,0 @@
1
- export default {
2
- en: {
3
- yes: 'Yes',
4
- no: 'No',
5
- no_nevermind: 'No, nevermind',
6
- ok: 'OK',
7
- or: 'or',
8
- warning: 'Warning',
9
- cancel: 'Cancel',
10
- continue: 'Continue',
11
- continue_editing: 'Continue editing',
12
- apply: 'Apply',
13
- apply_filters: 'Apply filters',
14
- hide: 'Hide',
15
- show: 'Show',
16
- deleted: 'Deleted',
17
- delete: 'Delete',
18
- try_again: 'Try again',
19
- refresh_page: 'Refresh page',
20
- search: 'Search',
21
- no_results: 'No results',
22
- change: 'Change',
23
- save: 'Save',
24
- saving_: 'Saving...',
25
- undo_changes: 'Undo changes',
26
- save_changes: 'Save changes',
27
- unsaved_changes_msg: 'You have unsaved changes.',
28
- ai: 'AI',
29
- you: 'You',
30
- copied_: 'Copied!',
31
- copied_text_: 'Copied "%{text}"',
32
- go_back: 'Go back',
33
- read_more: 'Read more',
34
- search_: 'Search: "%{query}"',
35
- close: 'Close',
36
- join: 'Join',
37
- change_img: 'Change image',
38
- upload_img: 'Upload image',
39
- keep_current_img: 'Keep current image',
40
- select_file: 'Select file',
41
- name: 'Name',
42
- pin_to_top: 'Pin to top',
43
- create_new: 'Create new',
44
- upload: 'Upload',
45
- create: 'Create',
46
- invite: 'Invite',
47
- invited: 'Invited',
48
- add: 'Add',
49
- remove: 'Remove',
50
- removed: 'Removed',
51
- history: 'History',
52
- edit: 'Edit',
53
- enter: 'Enter',
54
- accept: 'Accept',
55
- decline: 'Decline',
56
- dismiss: 'Dismiss',
57
- description: 'Description',
58
- no_desc: 'No description.',
59
- use_default: 'Use default',
60
- use_personal: 'Use personal',
61
- learn_more: 'Learn more',
62
- email: 'E-mail',
63
- thank_you: 'Thank you',
64
- click_here: 'Click here',
65
- success: 'Success',
66
- success_: 'Success!',
67
- help: 'Help',
68
- start: 'Start',
69
- end: 'End',
70
- time: 'Time',
71
- time_with_zone: 'Time (%{timeZone})',
72
- date: 'Date',
73
- start_date: 'Start date',
74
- end_date: 'End date',
75
- esc: 'ESC',
76
- settings: 'Settings',
77
- note: 'Note',
78
- details: 'Details',
79
- quantity: 'Quantity',
80
- quantity_ph: '7.5',
81
- unit: 'Unit',
82
- price: 'Price',
83
- cropId: 'Crop',
84
- logged_edited_at: 'Logged %{logDate}. Updated %{editDate}.',
85
- logged_at: 'Logged %{logDate}.',
86
- category: 'Category',
87
- activity: 'Activity',
88
- activity_ph: 'Type of activity',
89
- crop: 'Crop',
90
- crop_ph: 'Select crop',
91
- concentration: 'Concentration',
92
- concentration_ph: '0.5',
93
- concentration_unit: 'Concentration unit',
94
- concentration_unit_ph: 'mg/L',
95
- water_quantity: 'Quantity (water)',
96
- water_unit: 'Unit (water)',
97
- water_unit_ph: 'gallons, litres',
98
-
99
- // Day periods
100
- greet_MORNING: 'Good morning, %{name}.',
101
- greet_AFTERNOON: 'Good afternoon, %{name}.',
102
- greet_EVENING: 'Good evening, %{name}.',
103
- greet_NIGHT: 'Good evening, %{name}.',
104
-
105
- // Communication types
106
- comm_type_EMAIL: 'E-mail',
107
- comm_type_SMS: 'SMS',
108
-
109
- // Languages
110
- lang: {
111
- ENGLISH: 'English',
112
- SPANISH: 'Spanish',
113
- },
114
- },
115
- };
package/i18n/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import Polyglot from 'node-polyglot';
2
- import type NodePolyglot from '../types.d.ts'
3
-
4
- const i18n = new Polyglot();
5
- export default i18n as NodePolyglot;
package/types/app.d.ts DELETED
@@ -1,49 +0,0 @@
1
- import { COLORS } from '../constants/app';
2
-
3
- // Modal; App settings
4
-
5
- export interface EditIfaceModalProps {
6
- containerClassName: string;
7
- saveCounter: number;
8
- saving: boolean;
9
- hasChanges: boolean;
10
- openModalPopUp: (opts: any) => void;
11
- onChangeDiff: (diff: boolean) => void;
12
- }
13
-
14
- export interface EditUserModalProps extends EditIfaceModalProps {
15
- user: any;
16
- editUser: (obj: object) => void;
17
- }
18
-
19
- export interface EditUserPlusModalProps extends EditIfaceModalProps {
20
- user: any;
21
- editUserPlus: (obj: object) => void;
22
- }
23
-
24
- // App types
25
-
26
- export type DarkOrLightEnum = 'light' | 'dark';
27
-
28
- export type ColorEnum = typeof COLORS[number];
29
-
30
- // Stripe types
31
-
32
- export type PlatformProductGroupEnum = 'PERKS' | 'PLUS' | 'PRO' | 'COINS';
33
-
34
- // Server/API related types
35
-
36
- export interface ServerErrorObj {
37
- statusCode: number;
38
- errorCode: string;
39
- errorValue?: string;
40
- iconName?: string;
41
- title: string;
42
- message: string;
43
- }
44
-
45
- export interface SimpleErrorType {
46
- iconName?: string;
47
- title?: string;
48
- message: string;
49
- }
@@ -1,94 +0,0 @@
1
- import { OPERATION_ENUMS, ROLE_ENUMS, ROLE_CATEGORY_ENUMS } from '../constants/organization.ts';
2
-
3
- /*
4
- * ACL
5
- */
6
-
7
- export type OrganizationRoleEnum = typeof ROLE_ENUMS[number];
8
- export type OrganizationOperationEnum = typeof OPERATION_ENUMS[number];
9
- export type OrganizationRoleCategoryEnum = typeof ROLE_CATEGORY_ENUMS[number];
10
-
11
- type ACLPermission = 0 | 1 | 2 | 3; // 0: no access, 1: read-only, 2: allow-write, 3: allow-manage
12
- type ACLPermissionEnum = 'NONE' | 'READ' | 'WRITE' | 'MANAGE';
13
-
14
- export interface OrganizationACL {
15
- id: string;
16
- billing: ACLPermission;
17
- logs: ACLPermission;
18
- members: ACLPermission;
19
- finances: ACLPermission;
20
- settings: ACLPermission;
21
- integrations: ACLPermission;
22
- digests: ACLPermission;
23
- reminders: ACLPermission;
24
- }
25
-
26
- export interface OrganizationACLGQLData {
27
- id: string;
28
- billing: ACLPermissionEnum;
29
- logs: ACLPermissionEnum;
30
- members: ACLPermissionEnum;
31
- finances: ACLPermissionEnum;
32
- settings: ACLPermissionEnum;
33
- integrations: ACLPermissionEnum;
34
- digests: ACLPermissionEnum;
35
- reminders: ACLPermissionEnum;
36
- }
37
-
38
- /**
39
- * Organization object
40
- */
41
-
42
- export interface OrganizationShortData {
43
- id: string;
44
- name: string;
45
- primary: boolean;
46
- acl: OrganizationACL;
47
- }
48
-
49
- export interface OrganizationData {
50
- id: number;
51
- stripeCustomerId: string | null;
52
- name: string;
53
- operation: OrganizationOperationEnum;
54
- dailyDigestTime: string | null;
55
- reminders: string | null;
56
- domains: string[] | null;
57
- settings?: {
58
- emoji: string | null;
59
- timeZone: string | null;
60
- }
61
- }
62
-
63
- /**
64
- * Full organization object with relationship
65
- */
66
-
67
- export interface OrganizationRelData {
68
- id: string;
69
- primary: boolean;
70
- role: OrganizationRoleEnum;
71
- acl: OrganizationACL;
72
- organization: OrganizationData;
73
- }
74
-
75
- /**
76
- * GraphQL data for organization relationship
77
- */
78
-
79
- export interface OrganizationGQLData {
80
- id: string;
81
- name: string;
82
- stripeCustomerId: string | null;
83
- reminders: string | null;
84
- domains: string[] | null;
85
- membersCount: number;
86
- }
87
-
88
- export interface OrganizationRelGQLData {
89
- id: string;
90
- primary: boolean;
91
- role: OrganizationRoleEnum;
92
- acl: OrganizationACLGQLData;
93
- organization: OrganizationGQLData;
94
- }
@@ -1,102 +0,0 @@
1
- import { OrganizationRelData, OrganizationRelGQLData } from '../types/organization.d';
2
-
3
- // Placeholder to match Server import
4
- type ViewerOrganization = any;
5
-
6
- const PERMISSION_TO_INT = {
7
- NONE: 0,
8
- READ: 1,
9
- WRITE: 2,
10
- MANAGE: 3,
11
- };
12
-
13
- const INT_TO_PERMISSION = Object.keys(PERMISSION_TO_INT);
14
-
15
- /**
16
- * Get default permissions by role
17
- */
18
-
19
- export function getDefaultPermissionsByRole(orgRel: OrganizationRelGQLData | OrganizationRelData | ViewerOrganization) {
20
- const role = orgRel?.role || 'MEMBER';
21
- const acl: Record<string, any> = { ...orgRel?.acl };
22
-
23
- for (const key in acl) {
24
- if (typeof acl[key] === 'number') {
25
- acl[key] = INT_TO_PERMISSION[acl[key]] || 'NONE';
26
- }
27
- }
28
-
29
- // Also keep this synced with [resolvers/organizationTypeResolvers.ts]
30
-
31
- // 0 = "NONE"
32
- // 1 = "READ"
33
- // 2 = "WRITE"
34
- // 3 = "MANAGE"
35
-
36
- switch (role) {
37
- case 'ADMIN':
38
- case 'OWNER':
39
- return {
40
- billing: acl.billing || 'MANAGE',
41
- digests: acl.digests || 'MANAGE', // 2/3 = receive digests, 1 = only see from web app
42
- logs: acl.logs || 'MANAGE', // "READ" for logs does nothing
43
- viewData: acl.viewData || 'MANAGE', // This blocks access from users being able to read other people's logs
44
- members: acl.members || 'MANAGE',
45
- finances: acl.finances || 'MANAGE',
46
- settings: acl.settings || 'MANAGE',
47
- integrations: acl.integrations || 'MANAGE',
48
- reminders: acl.reminders || 'MANAGE',
49
- };
50
- case 'MANAGER':
51
- return {
52
- billing: acl.billing || 'READ',
53
- digests: acl.digests || 'WRITE', // 2/3 = receive digests, 1 = only see from web app
54
- logs: acl.logs || 'MANAGE', // "READ" for logs does nothing
55
- viewData: acl.viewData || 'MANAGE', // This blocks access from users being able to read other people's logs
56
- members: acl.members || 'WRITE',
57
- finances: acl.finances || 'READ',
58
- settings: acl.settings || 'READ',
59
- integrations: acl.integrations || 'NONE',
60
- reminders: acl.reminders || 'MANAGE',
61
- };
62
- case 'MEMBER':
63
- default:
64
- }
65
-
66
- return {
67
- billing: acl.billing || 'NONE',
68
- digests: acl.digests || 'NONE', // 2/3 = receive digests, 1 = only see from web app
69
- logs: acl.logs || 'WRITE', // "READ" for logs does nothing
70
- viewData: acl.viewData || 'NONE', // This blocks access from users being able to read other people's logs
71
- members: acl.members || 'READ',
72
- finances: acl.finances || 'NONE',
73
- settings: acl.settings || 'READ',
74
- integrations: acl.integrations || 'NONE',
75
- reminders: acl.reminders || 'WRITE',
76
- };
77
- }
78
-
79
- /**
80
- * Check if this account's ACL has required permissions for an action
81
- */
82
-
83
- export type ACLPermissionCheck = 'READ' | 'WRITE' | 'MANAGE';
84
- export type PermissionCheckFor = keyof ReturnType<typeof getDefaultPermissionsByRole>;
85
-
86
- export function checkACLPermission(
87
- orgRel: OrganizationRelGQLData | OrganizationRelData | ViewerOrganization,
88
- check: PermissionCheckFor,
89
- requiredPermission: ACLPermissionCheck,
90
- ): boolean | null {
91
- if (!orgRel) {
92
- return null;
93
- }
94
-
95
- const acl = getDefaultPermissionsByRole(orgRel);
96
-
97
- const requiredInt = PERMISSION_TO_INT[requiredPermission] || 4; // If invalid, it will always return false
98
- const permission = acl[check] as ACLPermissionCheck;
99
- const acccountPermissionInt = PERMISSION_TO_INT[permission] || 0; // If invalid, it will always return false
100
-
101
- return acccountPermissionInt >= requiredInt;
102
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes