@jsb188/app 1.1.4 → 1.1.6
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 +340 -24
- package/constants/other.ts +17 -0
- package/constants/wsActions.ts +21 -0
- package/i18n/{user.ts → account.ts} +21 -38
- package/i18n/app.ts +4 -18
- package/i18n/auth.ts +33 -9
- package/i18n/billing.ts +1 -1
- package/i18n/datetime.ts +57 -18
- package/i18n/error.ts +32 -18
- package/i18n/form.ts +192 -3
- package/main.ts +2 -2
- package/package.json +6 -4
- package/types/account.d.ts +63 -0
- package/types/ai.d.ts +3 -0
- package/types/app.d.ts +26 -1
- package/types/auth.d.ts +6 -1
- package/types/form.d.ts +9 -3
- package/types/other.d.ts +61 -0
- package/utils/action.ts +28 -0
- package/utils/api.ts +1 -1
- package/utils/datetime.ts +417 -56
- package/utils/logic.ts +60 -9
- package/utils/number.ts +160 -8
- package/utils/object.ts +291 -71
- package/utils/string.ts +183 -21
- package/utils/timeZone.ts +612 -436
- package/utils/url_client.ts +17 -22
- package/utils/user.ts +1 -126
- package/constants/organization.ts +0 -8
- package/constants/ws.ts +0 -47
- package/types/organization.d.ts +0 -40
- package/types/user.d.ts +0 -52
package/utils/url_client.ts
CHANGED
|
@@ -24,30 +24,25 @@ export function makeUploadsUrl(
|
|
|
24
24
|
return '';
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const isGif = urlPath.substring(urlPath.lastIndexOf('.')).toLowerCase() === '.gif';
|
|
28
|
+
|
|
29
|
+
let prefix = '';
|
|
30
|
+
if (isGif && animateGifs) {
|
|
31
|
+
// Do gif path here
|
|
32
|
+
prefix = '';
|
|
33
33
|
} else {
|
|
34
|
-
|
|
35
|
-
case 'original':
|
|
36
|
-
uriPrefix = 'original/';
|
|
37
|
-
break;
|
|
38
|
-
case 'large':
|
|
39
|
-
case 'medium':
|
|
40
|
-
uriPrefix = 'medium/';
|
|
41
|
-
break;
|
|
42
|
-
case 'small':
|
|
43
|
-
case 'tiny':
|
|
44
|
-
uriPrefix = 'small/';
|
|
45
|
-
break;
|
|
46
|
-
default:
|
|
47
|
-
uriPrefix = 'small/';
|
|
48
|
-
}
|
|
34
|
+
// Do size paths here
|
|
49
35
|
}
|
|
50
|
-
|
|
36
|
+
|
|
37
|
+
return 'https://assets.chiefhappiness.co/marketday/' + prefix + urlPath;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Make url for static assets
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
export function makeStaticAssetUrl(urlPath?: string | null): string {
|
|
45
|
+
return 'https://assets.chiefhappiness.co/marketday/static/' + urlPath;
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
/**
|
package/utils/user.ts
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
import i18n from '../i18n/';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Types
|
|
5
3
|
*/
|
|
6
4
|
|
|
7
5
|
type LightModeValue = 'LIGHT' | 'DARK' | 'SYSTEM';
|
|
8
|
-
type FriendStatusEnum = 'BLOCKED' | 'DECLINED' | 'PENDING' | 'ACCEPTED';
|
|
9
|
-
|
|
10
|
-
interface FriendFragment {
|
|
11
|
-
myStatus: FriendStatusEnum;
|
|
12
|
-
otherStatus: FriendStatusEnum;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface FriendOptionsObj {
|
|
16
|
-
friendButtonText: string;
|
|
17
|
-
friendButtonIconName: string;
|
|
18
|
-
friendStatusText: string;
|
|
19
|
-
messageAllowed: boolean;
|
|
20
|
-
options: {
|
|
21
|
-
value: string;
|
|
22
|
-
iconName: string;
|
|
23
|
-
text: string;
|
|
24
|
-
}[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
6
|
type PlusGroupEnum = 'NORMAL' | 'PERKS' | 'PLUS' | 'PRO';
|
|
28
7
|
|
|
29
8
|
interface UserSubOutput {
|
|
@@ -69,7 +48,7 @@ export function updateLightMode(mode_: string | undefined, newValue: LightModeVa
|
|
|
69
48
|
* Resolve user's online status for chat
|
|
70
49
|
*/
|
|
71
50
|
|
|
72
|
-
export function resolveOnlineStatus(user:
|
|
51
|
+
export function resolveOnlineStatus(user: any, viewerUserId: number) {
|
|
73
52
|
// console.log('..... RESOLVE ONLINE STATUS .....', user.id, viewerUserId, user.onlineStatus);
|
|
74
53
|
if (
|
|
75
54
|
// This check won't be valid if user is switching logins;
|
|
@@ -93,110 +72,6 @@ export function resolveOnlineStatus(user: object, viewerUserId: number) {
|
|
|
93
72
|
return 'APPEAR_OFFLINE';
|
|
94
73
|
}
|
|
95
74
|
|
|
96
|
-
/**
|
|
97
|
-
* Get friend status between 2 users
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
export function getFriendOptions(friend?: FriendFragment | null): FriendOptionsObj {
|
|
101
|
-
const { myStatus, otherStatus } = friend || {};
|
|
102
|
-
if (myStatus === 'BLOCKED') {
|
|
103
|
-
// Blocked by user
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
friendButtonText: i18n.t('user.blocked'),
|
|
107
|
-
friendStatusText: i18n.t('user.blocked_by_me'),
|
|
108
|
-
friendButtonIconName: 'user-x',
|
|
109
|
-
messageAllowed: false,
|
|
110
|
-
options: [{
|
|
111
|
-
value: 'DECLINED',
|
|
112
|
-
iconName: 'user',
|
|
113
|
-
text: i18n.t('user.unblock'),
|
|
114
|
-
}],
|
|
115
|
-
};
|
|
116
|
-
} else if (otherStatus === 'BLOCKED') {
|
|
117
|
-
// Blocked by "other" user
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
friendButtonText: i18n.t('user.blocked'),
|
|
121
|
-
friendStatusText: i18n.t('user.blocked_by_other'),
|
|
122
|
-
friendButtonIconName: 'user-x',
|
|
123
|
-
messageAllowed: false,
|
|
124
|
-
options: [],
|
|
125
|
-
};
|
|
126
|
-
} else if (myStatus === 'ACCEPTED' && otherStatus === 'ACCEPTED') {
|
|
127
|
-
// Friends
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
friendButtonText: i18n.t('user.friends'),
|
|
131
|
-
friendStatusText: i18n.t('user.friends_msg'),
|
|
132
|
-
friendButtonIconName: 'user-check',
|
|
133
|
-
messageAllowed: true,
|
|
134
|
-
options: [{
|
|
135
|
-
value: 'DECLINED',
|
|
136
|
-
iconName: 'user-cancel',
|
|
137
|
-
text: i18n.t('user.remove_friend'),
|
|
138
|
-
}, {
|
|
139
|
-
value: 'BLOCKED',
|
|
140
|
-
iconName: 'user-x',
|
|
141
|
-
text: i18n.t('user.block'),
|
|
142
|
-
}],
|
|
143
|
-
};
|
|
144
|
-
} else if (myStatus === 'PENDING') {
|
|
145
|
-
// Pending request from other user
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
friendButtonText: i18n.t('user.friend_request'),
|
|
149
|
-
friendStatusText: i18n.t('user.add_friend_msg'),
|
|
150
|
-
friendButtonIconName: 'user-plus',
|
|
151
|
-
messageAllowed: false,
|
|
152
|
-
options: [{
|
|
153
|
-
value: 'ACCEPTED',
|
|
154
|
-
iconName: 'user-check',
|
|
155
|
-
text: i18n.t('user.accept_friend'),
|
|
156
|
-
}, {
|
|
157
|
-
value: 'DECLINED',
|
|
158
|
-
iconName: 'user-cancel',
|
|
159
|
-
text: i18n.t('user.ignore_friend'),
|
|
160
|
-
}, {
|
|
161
|
-
value: 'BLOCKED',
|
|
162
|
-
iconName: 'user-x',
|
|
163
|
-
text: i18n.t('user.block'),
|
|
164
|
-
}],
|
|
165
|
-
};
|
|
166
|
-
} else if (otherStatus === 'PENDING') {
|
|
167
|
-
// Sent a friend request; now waiting
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
friendButtonText: i18n.t('user.friend_requested'),
|
|
171
|
-
friendStatusText: i18n.t('user.sent_friend_msg'),
|
|
172
|
-
friendButtonIconName: 'mail',
|
|
173
|
-
messageAllowed: false,
|
|
174
|
-
options: [{
|
|
175
|
-
value: 'DECLINED',
|
|
176
|
-
iconName: 'user-cancel',
|
|
177
|
-
text: i18n.t('user.cancel_friend'),
|
|
178
|
-
}],
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// No actions taken, user can/should send request
|
|
183
|
-
return {
|
|
184
|
-
friendButtonText: i18n.t('user.add_friend'),
|
|
185
|
-
friendStatusText: i18n.t('user.add_friend_msg'),
|
|
186
|
-
friendButtonIconName: 'user-plus',
|
|
187
|
-
messageAllowed: false,
|
|
188
|
-
options: [{
|
|
189
|
-
value: 'PENDING',
|
|
190
|
-
iconName: 'mail',
|
|
191
|
-
text: i18n.t('user.send_friend'),
|
|
192
|
-
}, {
|
|
193
|
-
value: 'BLOCKED',
|
|
194
|
-
iconName: 'user-x',
|
|
195
|
-
text: i18n.t('user.block'),
|
|
196
|
-
}],
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
75
|
/**
|
|
201
76
|
* Get user subscription type
|
|
202
77
|
*/
|
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/types/organization.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { OPERATION_ENUMS, ROLE_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
|
-
|
|
10
|
-
export interface OrganizationACL {
|
|
11
|
-
id: string;
|
|
12
|
-
manageBilling: boolean | null;
|
|
13
|
-
manageIntegrations: boolean | null;
|
|
14
|
-
manageMembers: boolean | null;
|
|
15
|
-
manageProducts: boolean | null;
|
|
16
|
-
manageSettings: boolean | null;
|
|
17
|
-
viewMembers: boolean | null;
|
|
18
|
-
role: OrganizationRoleEnum | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Organization object
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
export interface OrganizationShortData {
|
|
26
|
-
id: string;
|
|
27
|
-
name: string;
|
|
28
|
-
primary: boolean;
|
|
29
|
-
acl: OrganizationACL;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface OrganizationData {
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
primary: boolean;
|
|
36
|
-
acl: OrganizationACL;
|
|
37
|
-
stripeCustomerId: string | null;
|
|
38
|
-
domains: string[] | null;
|
|
39
|
-
// members: OrganizationMemberData[] | null;
|
|
40
|
-
}
|
package/types/user.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { PersonaObj } from './chat';
|
|
2
|
-
|
|
3
|
-
type OnlineStatusEnum = null | 'AWAY' | 'BUSY' | 'APPEAR_OFFLINE';
|
|
4
|
-
type PlusStatusEnum = 'PRO' | 'PLUS' | 'PERKS' | 'NORMAL';
|
|
5
|
-
|
|
6
|
-
export interface AppUser {
|
|
7
|
-
id: string;
|
|
8
|
-
username: string;
|
|
9
|
-
displayName: string;
|
|
10
|
-
|
|
11
|
-
moderator: boolean;
|
|
12
|
-
activated: boolean;
|
|
13
|
-
|
|
14
|
-
plusStatus: PlusStatusEnum;
|
|
15
|
-
onlineStatus: OnlineStatusEnum;
|
|
16
|
-
|
|
17
|
-
plus: {
|
|
18
|
-
id: string;
|
|
19
|
-
expireAt: string;
|
|
20
|
-
cancelled: boolean;
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
theme: {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
backgroundPhotoUri: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
profile: {
|
|
31
|
-
id: string;
|
|
32
|
-
description: string;
|
|
33
|
-
pronouns: string;
|
|
34
|
-
photoUri: string;
|
|
35
|
-
backgroundPhotoUri: string;
|
|
36
|
-
adult: boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
email: {
|
|
40
|
-
id: string;
|
|
41
|
-
address: string;
|
|
42
|
-
verified: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
phone: {
|
|
46
|
-
id: string;
|
|
47
|
-
number: string;
|
|
48
|
-
verified: boolean;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
personas: PersonaObj[];
|
|
52
|
-
}
|