@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
@@ -0,0 +1,75 @@
1
+ export default {
2
+ en: {
3
+ animal_id: 'Animal ID',
4
+ dam_id: 'Dam ID',
5
+ breed: 'Breed',
6
+
7
+ upcoming_markets: 'Upcoming markets',
8
+ markets_empty_msg: 'Talk to your AI to create farmers market events.',
9
+ event_not_scheduled_msg: 'This event is not scheduled for this date.',
10
+ attendance_list_empty_msg: 'Attendance list is empty for this date.',
11
+
12
+ // Report
13
+ collected_total_ct_evidences: 'Collected a total of %{smart_count} evidence.||||Collected a total of %{smart_count} evidences.',
14
+
15
+ // Content names
16
+ view_document: 'View document',
17
+ view_event: 'View event',
18
+ view_market: 'View market',
19
+
20
+ edit_document: 'Edit document',
21
+ edit_event: 'Edit event',
22
+ edit_market: 'Edit market',
23
+
24
+ delete_document: 'Delete document',
25
+ delete_event: 'Delete event',
26
+ delete_market: 'Delete market',
27
+
28
+ // Enums
29
+ status: {
30
+ ALIVE: 'Alive',
31
+ SICK: 'Sick',
32
+ SOLD: 'Sold',
33
+ DECEASED: 'Deceased',
34
+ },
35
+
36
+ event_frequency_msg: {
37
+ ONCE: 'This event does not repeat.',
38
+ WEEKLY: 'This event repeats weekly.',
39
+ },
40
+
41
+ contentName_plural: {
42
+ market: 'Markets',
43
+ },
44
+
45
+ feature_title: {
46
+ // This object is the "title" field of "actions" database document.
47
+ // It's used as visualization purposes only, in front-end UI.
48
+ CAL_EVENTS_ATTENDANCE: 'Attendance record',
49
+ CAL_EVENTS_LOAD_LIST: 'Load list',
50
+ },
51
+
52
+ feature_instructions: {
53
+ // This object is the "instruction" field of "actions" database document.
54
+ // It's used as visualization purposes only, in front-end UI.
55
+ CAL_EVENTS_ATTENDANCE: "Read the log and record the vendor's attendance.",
56
+ CAL_EVENTS_LOAD_LIST: "Save the vendor's load list for the market day.",
57
+ },
58
+
59
+ feature_notification: {
60
+ // This object is the "top right corner" toaster notification messages in the front-end UI.
61
+ CAL_EVENTS_ATTENDANCE_success: 'Vendor attendance has been recorded.',
62
+ CAL_EVENTS_ATTENDANCE_failed: 'Failed to record vendor attendance.',
63
+ CAL_EVENTS_LOAD_LIST_success: 'Load list has been saved.',
64
+ CAL_EVENTS_LOAD_LIST_failed: 'Failed to save load list.',
65
+ },
66
+
67
+ // Reports
68
+
69
+ report: {
70
+ GLOBAL_GAP: 'GLOBALG.A.P.',
71
+ ORGANIC_CERTIFICATION: 'USDA National Organic Program (NOP)',
72
+ CLEANING: 'Cleaning logs',
73
+ },
74
+ },
75
+ };
@@ -1,11 +1,4 @@
1
- import i18n from './i18n/';
2
- import app from './i18n/app';
3
- import auth from './i18n/auth';
4
- import billing from './i18n/billing';
5
- import datetime from './i18n/datetime';
6
- import error from './i18n/error';
7
- import form from './i18n/form';
8
- import account from './i18n/account';
1
+ import i18n, { i18nTranslations } from './i18n/index.ts';
9
2
 
10
3
  // Get the correct type for ENV
11
4
  let ENV: Map<string, string | boolean | number> = new Map();
@@ -14,31 +7,29 @@ let ENV: Map<string, string | boolean | number> = new Map();
14
7
  * Extend i18n with app specific texts
15
8
  */
16
9
 
17
- export function configI18n(texts: Record<string, any>) {
10
+ export function configI18n(texts?: Record<string, any>) {
18
11
 
19
12
  // Locale support for later
20
13
  const locale = 'en';
21
14
 
22
- const extendedObj = {
23
- app: app[locale],
24
- auth: auth[locale],
25
- billing: billing[locale],
26
- datetime: datetime[locale],
27
- error: error[locale],
28
- form: form[locale],
29
- account: account[locale],
30
- } as Record<string, any>;
31
-
32
- for (const key in texts) {
33
- const obj = texts[key][locale];
34
-
35
- if (extendedObj[key]) {
36
- extendedObj[key] = {
37
- ...extendedObj[key],
38
- ...obj
39
- };
40
- } else {
41
- extendedObj[key] = obj;
15
+ const extendedObj: Record<string, any> = {};
16
+
17
+ for (const key in i18nTranslations) {
18
+ extendedObj[key] = i18nTranslations[key][locale];
19
+ }
20
+
21
+ if (texts) {
22
+ for (const key in texts) {
23
+ const obj = texts[key][locale];
24
+
25
+ if (extendedObj[key]) {
26
+ extendedObj[key] = {
27
+ ...extendedObj[key],
28
+ ...obj
29
+ };
30
+ } else {
31
+ extendedObj[key] = obj;
32
+ }
42
33
  }
43
34
  }
44
35
 
@@ -7,8 +7,7 @@ import type { OrganizationACL, OrganizationRoleEnum } from './organization.d.ts'
7
7
  export interface AccountPhoneObj {
8
8
  id: number;
9
9
  number: string;
10
- primary: boolean;
11
- // verified: boolean; // Assume verified when data is fetched
10
+ verified: boolean;
12
11
  }
13
12
 
14
13
  /**
@@ -17,32 +16,33 @@ export interface AccountPhoneObj {
17
16
 
18
17
  export interface AccountObj {
19
18
  id: number;
20
- profile: {
21
- id: number;
19
+ settings: Record<string, any>;
20
+ profile: Partial<{
22
21
  firstName: string;
23
22
  lastName: string;
24
23
  storageId: number | null;
25
24
  // phone: AccountPhoneObj | null; // ?? This is a coding mistake, I think
26
- };
25
+ }>;
27
26
  }
28
27
 
29
28
  export interface AccountData extends AccountObj {
29
+ __table: 'accounts';
30
30
  phone: {
31
31
  id: number;
32
32
  number: string;
33
- primary: boolean;
34
33
  verified: boolean;
35
34
  banned: boolean;
36
35
  editAt: Date;
37
36
  };
38
37
  email: {
39
38
  id: number;
40
- email: string;
41
- primary: boolean;
39
+ address: string;
42
40
  verified: boolean;
43
41
  banned: boolean;
44
42
  editAt: Date;
45
43
  };
44
+ createdAt: Date;
45
+ updatedAt: Date;
46
46
  }
47
47
 
48
48
  /**
@@ -55,6 +55,7 @@ export interface AccountMembershipData {
55
55
  organizationId: number;
56
56
  role: OrganizationRoleEnum;
57
57
  acl: OrganizationACL;
58
+ notes?: string;
58
59
  primary: boolean;
59
60
  createdAt: Date;
60
61
  updatedAt: Date;
@@ -0,0 +1,74 @@
1
+ import { COLORS } from '../constants/app.ts';
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
+ }
50
+
51
+ // Web Socket events
52
+
53
+ type ResetQueryRuleEnum = 'ALWAYS' | 'IF_FRAGMENT_NOT_FOUND' | 'IF_FRAGMENT_FOUND' | 'NEVER';
54
+
55
+ export interface WSDataUpdateObj {
56
+ id: string;
57
+ route: string[]; // First items in the array have priority (Different org operations may not allow the actions handled by other org operations)
58
+ message?: string | null; // If null, nothing will be visible to the client.
59
+ messageType: 'NORMAL' | 'SUCCESS' | 'ERROR';
60
+ resetQueryKeys?: string[]; // List of query keys including {variablesKey}
61
+ resetQueryRule?: ResetQueryRuleEnum; // Defaults to "IF_FRAGMENT_FOUND"
62
+ reactiveFragmentKeys?: string[]; // Fragment keys that are used to trigger reactivity
63
+ fragments?: null | ({
64
+ name: string;
65
+ dataId: string;
66
+ replaceId?: string; // Use this where client has a temporary ID that will be replaced by the server-side ID later
67
+ data: any;
68
+ } | null)[];
69
+ }
70
+
71
+ export interface WSAppContextUpdateObj {
72
+ accountId: string;
73
+ updates: [any, any][];
74
+ }
@@ -1,4 +1,4 @@
1
- import type { OrganizationShortData } from './organization.d';
1
+ import type { OrganizationShortData } from './organization.d.ts';
2
2
 
3
3
  /**
4
4
  * Auth enums
@@ -14,7 +14,6 @@ export type LightModeEnum = 'LIGHT' | 'DARK' | 'SYSTEM';
14
14
  export interface AccountData {
15
15
  id: string;
16
16
  deleted: boolean;
17
- color: string;
18
17
 
19
18
  plus: any; // placeholder for later
20
19
 
@@ -10,7 +10,7 @@ interface SchemaItemAny {
10
10
  }
11
11
 
12
12
  export interface FormItemSchemaObj {
13
- __type: 'subtitle' | 'group' | 'input' | 'input_click' | 'input_w_button' | 'input_time_from_date' | 'password' | 'textarea' | 'none' | string;
13
+ __type: 'subtitle' | 'group' | 'input' | 'section_title' | 'input_click' | 'input_w_button' | 'input_time_from_date' | 'password' | 'textarea' | 'none' | string;
14
14
  autoFocus?: boolean;
15
15
  disabled?: boolean;
16
16
  hidden?: boolean | ((dataForSchema: any) => boolean);
@@ -0,0 +1,44 @@
1
+ import { DAY_OF_WEEK, SCHEDULE_FREQUENCY } from '../constants/other.ts';
2
+
3
+ /**
4
+ * Enums
5
+ */
6
+
7
+ export type DayOfWeekEnum = typeof DAY_OF_WEEK[number];
8
+ export type ScheduleFrequencyEnum = typeof SCHEDULE_FREQUENCY[number];
9
+
10
+ /**
11
+ * Address
12
+ */
13
+
14
+ export interface AddressObj {
15
+ line1: string;
16
+ line2?: string | null;
17
+ city: string;
18
+ state: string;
19
+ postalCode: string;
20
+ country: string;
21
+ }
22
+
23
+ /**
24
+ * Schedule
25
+ */
26
+
27
+ export interface ScheduleObj {
28
+ frequency: ScheduleFrequencyEnum;
29
+ weeksOfMonth?: number[];
30
+ daysOfWeek?: (0 | 1 | 2 | 3 | 4 | 5 | 6)[];
31
+ time?: [
32
+ string?, // Star time "hhmm" format
33
+ string?, // End time "hhmm" format (optional)
34
+ ];
35
+ }
36
+
37
+ /**
38
+ * File object
39
+ */
40
+
41
+ export interface FileObj {
42
+ buffer: Uint8Array;
43
+ contentType: string;
44
+ }
@@ -0,0 +1,70 @@
1
+ import { STORAGE_INTENT_ENUMS } from '../constants/storage.ts';
2
+
3
+ /**
4
+ * Enums
5
+ */
6
+
7
+ export type StorageIntentEnum = typeof STORAGE_INTENT_ENUMS[number];
8
+
9
+ /**
10
+ * Storage
11
+ */
12
+
13
+ export interface StorageData {
14
+ __table: 'storage';
15
+ id: number;
16
+ organizationId: number | null;
17
+ accountId: number | null;
18
+ uri: string;
19
+ size: number;
20
+ checked: boolean;
21
+ at: Date;
22
+ contentType: string;
23
+ values: Record<string, any> | null;
24
+ }
25
+
26
+ export interface StorageGQL {
27
+ __deleted?: boolean;
28
+
29
+ id: string;
30
+ organizationId: string | null;
31
+ accountId: string | null;
32
+ uri: string;
33
+ size: number;
34
+ checked: boolean;
35
+ at: Date;
36
+ contentType: string;
37
+
38
+ // client-side only
39
+ uploadStatus?: 'ERROR' | 'UPLOADING' | null;
40
+
41
+ // metadata
42
+ name: string | null;
43
+ description: string | null;
44
+ aiNote: string | null;
45
+ }
46
+
47
+ export type StorageUploadObj = Partial<{
48
+ uploaderAccountId: number;
49
+ values: Partial<{
50
+ name: string;
51
+ description: string;
52
+ aiNote: string;
53
+ }>;
54
+ uploadIntent: {
55
+ intent: StorageIntentEnum;
56
+ entries: [string, string][];
57
+ };
58
+ upsertQuery?: RelatedDocumentUpsertQuery;
59
+ realTimeUpdate?: string; // JSON.stringified object; "{{storageId}}" will be replaced with actual storage ID after upload
60
+ }>;
61
+
62
+ /**
63
+ * Post-upload related document query execution object
64
+ */
65
+
66
+ export interface RelatedDocumentUpsertQuery {
67
+ __table: string;
68
+ conflictKeys: string[];
69
+ data: Record<string, any>;
70
+ }
@@ -1,38 +1,10 @@
1
-
2
1
  /**
3
2
  * Types
4
3
  */
5
4
 
6
5
  type LightModeValue = 'LIGHT' | 'DARK' | 'SYSTEM';
7
- type FriendStatusEnum = 'BLOCKED' | 'DECLINED' | 'PENDING' | 'ACCEPTED';
8
-
9
- interface FriendFragment {
10
- myStatus: FriendStatusEnum;
11
- otherStatus: FriendStatusEnum;
12
- }
13
-
14
- interface FriendOptionsObj {
15
- friendButtonText: string;
16
- friendButtonIconName: string;
17
- friendStatusText: string;
18
- messageAllowed: boolean;
19
- options: {
20
- value: string;
21
- iconName: string;
22
- text: string;
23
- }[];
24
- }
25
-
26
6
  type PlusGroupEnum = 'NORMAL' | 'PERKS' | 'PLUS' | 'PRO';
27
7
 
28
- interface UserSubOutput {
29
- name: string | null;
30
- group: PlusGroupEnum;
31
- cancelled: boolean;
32
- expired: boolean;
33
- expireAt: Date | null;
34
- }
35
-
36
8
  /**
37
9
  * Get light mode value
38
10
  */
@@ -64,66 +36,17 @@ export function updateLightMode(mode_: string | undefined, newValue: LightModeVa
64
36
  return mode.substring(0, index) + value + mode.substring(index + 1);
65
37
  }
66
38
 
67
- /**
68
- * Resolve user's online status for chat
69
- */
70
-
71
- export function resolveOnlineStatus(user: object, viewerUserId: number) {
72
- // console.log('..... RESOLVE ONLINE STATUS .....', user.id, viewerUserId, user.onlineStatus);
73
- if (
74
- // This check won't be valid if user is switching logins;
75
- // So for those cases, use [user.self = true],
76
- // to validate that this is a self online status
77
- viewerUserId == user.id ||
78
- user.self
79
- ) {
80
- return user.onlineStatus;
81
- } else if (!user.lastLoginAt) {
82
- return 'APPEAR_OFFLINE';
83
- }
84
-
85
- const now = Date.now();
86
- const wasOnline = (now - user.lastLoginAt) < 420000; // 7 minutes
87
-
88
- if (wasOnline) {
89
- return user.onlineStatus;
90
- }
91
-
92
- return 'APPEAR_OFFLINE';
93
- }
94
-
95
- /**
96
- * Get user subscription type
97
- */
98
-
99
- export const getPlusStatus = (plus: any) => {
100
- if (!plus || plus.expireAt <= Date.now()) {
101
- return 'NORMAL';
102
- }
103
-
104
- switch (plus.type) {
105
- case 'kajiwoto_plus':
106
- case 'kajiwoto_plus_yearly':
107
- case 'big_planet_plus':
108
- case 'big_planet_plus_yearly':
109
- return 'PLUS';
110
- case 'kajiwoto_pro':
111
- case 'kajiwoto_pro_yearly':
112
- case 'big_planet_pro':
113
- case 'big_planet_pro_yearly':
114
- return 'PRO';
115
- case 'perks':
116
- return 'PERKS';
117
- default:
118
- return 'NORMAL';
119
- }
120
- };
121
-
122
39
  /**
123
40
  * Get user's subscription & status
124
41
  */
125
42
 
126
- export const getUserSubscription = (plus: any): UserSubOutput => {
43
+ export const getUserSubscription = (plus: any): {
44
+ name: string | null;
45
+ group: PlusGroupEnum;
46
+ cancelled: boolean;
47
+ expired: boolean;
48
+ expireAt: Date | null;
49
+ } => {
127
50
  if (!plus) {
128
51
  return {
129
52
  name: null,
@@ -1,6 +1,6 @@
1
- import i18n from '../i18n/';
2
- import { getENVVariable } from '../main';
3
- import type { ServerErrorObj } from '../types/app.d';
1
+ import i18n from '../i18n/index.ts';
2
+ import { getENVVariable } from '../main.ts';
3
+ import type { ServerErrorObj } from '../types/app.d.ts';
4
4
 
5
5
  let AUTH_TOKEN: string | null = null;
6
6
 
@@ -72,7 +72,7 @@ export function normalizeServerError(error?: any): ServerErrorObj {
72
72
 
73
73
  if (!message) {
74
74
  if (i18nErrCodeExists(errorCode)) {
75
- message = i18n.t(`error.${errorCode}`, { value: errorValue });
75
+ message = i18n.t(`error.${errorCode}`, { value: errorValue, smart_count: Number(errorValue) });
76
76
  } else {
77
77
  message = i18n.t('error.unknown_error');
78
78
  }
@@ -1,4 +1,4 @@
1
- import { SUBSCRIPTION_CATALOG, SUBSCRIPTION_CATALOG_TEST } from '../constants/billing';
1
+ import { SUBSCRIPTION_CATALOG, SUBSCRIPTION_CATALOG_TEST } from '../constants/billing.ts';
2
2
 
3
3
  /**
4
4
  * Types