@jsb188/app 1.1.3 → 1.1.4
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 -4
- package/constants/organization.ts +8 -0
- package/i18n/app.ts +11 -20
- package/i18n/auth.ts +39 -17
- package/i18n/error.ts +4 -1
- package/i18n/user.ts +1 -1
- package/package.json +1 -4
- package/types/organization.d.ts +3 -1
- package/utils/api.ts +0 -1
- package/utils/object.ts +41 -41
- package/utils/string.ts +24 -9
- package/utils/timeZone.ts +473 -1
- package/constants/journal.ts +0 -118
- package/types/journal.d.ts +0 -35
- package/utils/journal.ts +0 -20
package/constants/app.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const NOTIF_EXPIRE_DAYS = 30;
|
|
|
7
7
|
|
|
8
8
|
export const DOM_IDS = {
|
|
9
9
|
sidebarInput: 'sidebar_input',
|
|
10
|
-
mainFocusTextarea: '
|
|
10
|
+
mainFocusTextarea: 'main_tx',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// Local storage
|
|
@@ -25,9 +25,7 @@ export const STORAGE_KEYS = {
|
|
|
25
25
|
// Support e-mails
|
|
26
26
|
|
|
27
27
|
export const SUPPORT_EMAILS = {
|
|
28
|
-
|
|
29
|
-
big_planet: 'hi@kajiwoto.ai',
|
|
30
|
-
cosmic: 'hi@kajiwoto.ai',
|
|
28
|
+
marketday: 'hello@marketday.ai'
|
|
31
29
|
} as Record<string, string>;
|
|
32
30
|
|
|
33
31
|
// Social media
|
package/i18n/app.ts
CHANGED
|
@@ -6,12 +6,22 @@ export default {
|
|
|
6
6
|
privacy: 'Privacy Policy',
|
|
7
7
|
tos: 'Terms of Service',
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// Routes
|
|
10
10
|
route_: 'App | %{text}',
|
|
11
11
|
route_auth: 'Log in or sign up',
|
|
12
|
+
route_auth_signup: 'Create an account',
|
|
12
13
|
route_not_found: 'Page Not Found',
|
|
13
14
|
route_not_found_desc: 'The page you are looking for does not exist.',
|
|
14
15
|
|
|
16
|
+
// Toolbar titles
|
|
17
|
+
// NOTE: If i18n.has(routeName) -> /app/ routes will show the title in the toolbar
|
|
18
|
+
toolbar_title_logs: 'Logs',
|
|
19
|
+
toolbar_title_ai_chat: 'AI',
|
|
20
|
+
|
|
21
|
+
// General
|
|
22
|
+
open_app: 'Open app',
|
|
23
|
+
home: 'Home',
|
|
24
|
+
|
|
15
25
|
// @home screen
|
|
16
26
|
hey_: 'Hey, ',
|
|
17
27
|
how_to_use_app: 'How to use this app',
|
|
@@ -40,20 +50,6 @@ export default {
|
|
|
40
50
|
message_you_3: 'Your messages are colorful.',
|
|
41
51
|
message_you_4: 'Because you are special!',
|
|
42
52
|
|
|
43
|
-
// Theme names
|
|
44
|
-
theme_terracotta: 'Terracotta',
|
|
45
|
-
theme_envy_green: 'Envy green',
|
|
46
|
-
theme_vaporwave: 'Vaporwave',
|
|
47
|
-
theme_facetious: 'Facetious',
|
|
48
|
-
theme_sebastian_garden: 'Sebastian\'s garden',
|
|
49
|
-
theme_bob_deep_sea: 'Bob\'s deep sea',
|
|
50
|
-
theme_saif_flowers: 'Saif\'s flowers',
|
|
51
|
-
theme_bona_mocha: 'Bona\'s mocha',
|
|
52
|
-
theme_naffe_heart: 'Naffe\'s heart',
|
|
53
|
-
theme_dominic_aquarium: 'Dominic\'s aquarium',
|
|
54
|
-
theme_xavii_toothpaste: 'Xavii\'s toothpaste',
|
|
55
|
-
theme_miyu_sugar_sherbet: 'Miyu\'s sugar sherbet',
|
|
56
|
-
|
|
57
53
|
// Settings
|
|
58
54
|
settings: 'Settings',
|
|
59
55
|
appearance: 'Appearance',
|
|
@@ -87,11 +83,6 @@ export default {
|
|
|
87
83
|
notif_message_CO_OWNER_ADDED: 'You became a co-owner. You have live and moderation permissions.',
|
|
88
84
|
notif_message_CO_OWNER_INVITE: 'You received an invitation to become a co-owner for this chat.',
|
|
89
85
|
|
|
90
|
-
// Homepage; Top banner
|
|
91
|
-
hp_desc_1: 'is a ',
|
|
92
|
-
hp_desc_2: 'community owned',
|
|
93
|
-
hp_desc_3: 'messaging app.',
|
|
94
|
-
|
|
95
86
|
// Homepage; Roadmap
|
|
96
87
|
roadmap: 'Roadmap',
|
|
97
88
|
|
package/i18n/auth.ts
CHANGED
|
@@ -2,7 +2,8 @@ export default {
|
|
|
2
2
|
en: {
|
|
3
3
|
// Login
|
|
4
4
|
welcome_back: 'Welcome back',
|
|
5
|
-
|
|
5
|
+
log_in: 'Log in',
|
|
6
|
+
log_in_sign_up: 'Log in / Sign up',
|
|
6
7
|
open_app: 'Open app',
|
|
7
8
|
continue_with_google: 'Continue with Google',
|
|
8
9
|
continue_with_discord: 'Continue with Discord',
|
|
@@ -10,15 +11,14 @@ export default {
|
|
|
10
11
|
login_opts: 'Continue with e-mail, ID, or @username',
|
|
11
12
|
login_opts_phone_email: 'Continue with phone number or e-mail',
|
|
12
13
|
verify_your_acc: 'Verify your account',
|
|
13
|
-
resend_verification_email: 'Send verification e-mail', // This is for title of <ModalHeader /> in <AuthSwitch />
|
|
14
14
|
reset_password: 'Reset password',
|
|
15
15
|
forgot_password_: 'Forgot password or username?',
|
|
16
16
|
signup_email: 'Sign up using e-mail',
|
|
17
|
-
signup_using_other: '
|
|
17
|
+
signup_using_other: 'Log in with an existing account',
|
|
18
18
|
change_password: 'Change password',
|
|
19
19
|
you_are_verified_: 'You are verified!',
|
|
20
20
|
account_is_verified: 'Thank you for verifying your account with e-mail address: %{emailAddress}',
|
|
21
|
-
continue_to_login: 'Continue to
|
|
21
|
+
continue_to_login: 'Continue to log in',
|
|
22
22
|
|
|
23
23
|
// Auth
|
|
24
24
|
username_not_found: 'No one was found with that username.',
|
|
@@ -27,32 +27,47 @@ export default {
|
|
|
27
27
|
you_are_logged_in: 'You are signed in.',
|
|
28
28
|
password_changed_msg: 'Your password has been changed.',
|
|
29
29
|
request_reset_password_instr: 'Enter your e-mail address and we will send you instructions to reset your password.',
|
|
30
|
-
resend_verification_instr: 'Enter your e-mail address
|
|
30
|
+
resend_verification_instr: 'Enter your e-mail address and we will send you an e-mail to verify your account.',
|
|
31
31
|
reset_password_instr: 'Choose a new password for your account with the e-mail address: %{emailAddress}',
|
|
32
|
-
|
|
32
|
+
_verify_your_email: ' to verify your e-mail.',
|
|
33
|
+
_verify_your_phone: ' to verify your phone number.',
|
|
33
34
|
|
|
34
35
|
// Auth - check fails
|
|
35
36
|
no_account_with_phone: 'No account was found with that phone number.',
|
|
36
37
|
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
|
|
38
|
+
not_valid_email_or_phone: 'That is not a valid phone number or e-mail address.',
|
|
38
39
|
|
|
39
40
|
// Reset password (requested)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
reset_password_requested_msg: (
|
|
42
|
+
'Check your e-mail, <strong>%{emailAddress}</strong> ' +
|
|
43
|
+
'for instructions to reset your password.'
|
|
44
|
+
),
|
|
45
|
+
if_need_more_help_email: (
|
|
46
|
+
'If you need assistance, please contact us at ' +
|
|
47
|
+
'[%{emailAddress}](mailto:%{emailAddress}).'
|
|
48
|
+
),
|
|
49
|
+
|
|
50
|
+
// Invite required
|
|
51
|
+
invite_required: 'Invite required',
|
|
52
|
+
invite_required_msg: (
|
|
53
|
+
'Account creation is currently not opened to the public. ' +
|
|
54
|
+
'Ask your team for an invite or contact us at ' +
|
|
55
|
+
'[%{emailAddress}](mailto:%{emailAddress}) to create an account.'
|
|
56
|
+
),
|
|
43
57
|
|
|
44
58
|
// Sign up
|
|
45
59
|
sign_up: 'Sign up',
|
|
46
60
|
create_account: 'Create an account',
|
|
47
61
|
agree_and_continue: 'Agree and continue',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
sign_up_notice_msg: (
|
|
63
|
+
'By selecting "Agree and continue", I agree to the ' +
|
|
64
|
+
'[Terms of Service](/tos) and acknowledge the ' +
|
|
65
|
+
'[Privacy Policy](/privacy).'
|
|
66
|
+
),
|
|
51
67
|
email_sent: 'E-mail sent',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
check_email_4: ' or re-send another verification link to your e-mail.',
|
|
68
|
+
check_email_msg: 'Please check your e-mail for instructions to verify your account.',
|
|
69
|
+
// check_email_3: 'Click "continue" to log in as ',
|
|
70
|
+
// check_email_4: ' or re-send another verification link to your e-mail.',
|
|
56
71
|
check_email: 'Check your e-mail',
|
|
57
72
|
not_verified_yet: 'Please verify your e-mail and try again.',
|
|
58
73
|
resend_change_verification: 'Re-send verification link or change e-mail',
|
|
@@ -60,6 +75,13 @@ export default {
|
|
|
60
75
|
verify_email_msg: 'Send a new verification link to your e-mail.',
|
|
61
76
|
resend_verification: 'Send verification e-mail',
|
|
62
77
|
|
|
78
|
+
// Sign up success
|
|
79
|
+
account_created: 'Account created',
|
|
80
|
+
account_created_msg: (
|
|
81
|
+
'Your account has been created successfully. Please follow the instructions ' +
|
|
82
|
+
'in the e-mail we sent you to verify your account.'
|
|
83
|
+
),
|
|
84
|
+
|
|
63
85
|
// Sign out
|
|
64
86
|
sign_out: 'Sign out',
|
|
65
87
|
signing_out_: 'Signing you out...'
|
package/i18n/error.ts
CHANGED
|
@@ -5,6 +5,7 @@ export default {
|
|
|
5
5
|
network_error_title: 'Network error',
|
|
6
6
|
unknown_error: 'An unknown error occured.',
|
|
7
7
|
network_error: 'Failed to connect to server. Please try again in a moment.',
|
|
8
|
+
network_or_outage_error: 'Failed to connect to server. If your internect connection is stable, our servers may be experiencing an outage.',
|
|
8
9
|
app_error_title: 'App crashed',
|
|
9
10
|
app_error: 'Uh-oh, please refresh the page and tell someone.',
|
|
10
11
|
not_allowed: 'Not allowed',
|
|
@@ -84,10 +85,12 @@ export default {
|
|
|
84
85
|
20046: 'Your new password must be different from your current password.',
|
|
85
86
|
20047: 'You must enter a valid password.',
|
|
86
87
|
20048: 'This action is forbidden because you deleted your account.',
|
|
87
|
-
20049: 'You
|
|
88
|
+
20049: 'You haven\'t verified your account yet.',
|
|
88
89
|
20050: 'This page does not exist.',
|
|
89
90
|
20051: 'Could not find user with that phone number. (%{value})',
|
|
90
91
|
20052: 'You do not have access to this organization\'s data.',
|
|
92
|
+
20053: 'You haven\'t verified your account yet.',
|
|
93
|
+
20054: 'You need an invitation to create an account.',
|
|
91
94
|
|
|
92
95
|
'29999_title': 'Not ready',
|
|
93
96
|
29999: 'AI chat is not ready right now.',
|
package/i18n/user.ts
CHANGED
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
phone_ph: 'e.g. 123-444-5555',
|
|
18
18
|
password: 'Password',
|
|
19
19
|
password_ph: 'Enter your password',
|
|
20
|
-
passwordRepeat: 'Password (
|
|
20
|
+
passwordRepeat: 'Password (repeat)',
|
|
21
21
|
search_ph: 'Search @ or ID',
|
|
22
22
|
no_one_found_: 'No one found: "%{query}"',
|
|
23
23
|
from_friends_list: 'From your friends list',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Contains all the basic requirements for all @jsb188 apps.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -14,14 +14,12 @@
|
|
|
14
14
|
"./constants/app": "./constants/app.ts",
|
|
15
15
|
"./constants/billing": "./constants/billing.ts",
|
|
16
16
|
"./constants/emoji": "./constants/emoji.ts",
|
|
17
|
-
"./constants/journal": "./constants/journal.ts",
|
|
18
17
|
"./constants/user": "./constants/user.ts",
|
|
19
18
|
"./constants/ws": "./constants/ws.ts",
|
|
20
19
|
"./utils/api": "./utils/api.ts",
|
|
21
20
|
"./utils/billing": "./utils/billing.ts",
|
|
22
21
|
"./utils/datetime": "./utils/datetime.ts",
|
|
23
22
|
"./utils/emoji": "./utils/emoji.ts",
|
|
24
|
-
"./utils/journal": "./utils/journal.ts",
|
|
25
23
|
"./utils/logic": "./utils/logic.ts",
|
|
26
24
|
"./utils/number": "./utils/number.ts",
|
|
27
25
|
"./utils/object": "./utils/object.ts",
|
|
@@ -32,7 +30,6 @@
|
|
|
32
30
|
"./types/app.d": "./types/app.d.ts",
|
|
33
31
|
"./types/auth.d": "./types/auth.d.ts",
|
|
34
32
|
"./types/form.d": "./types/form.d.ts",
|
|
35
|
-
"./types/journal.d": "./types/journal.d.ts",
|
|
36
33
|
"./types/organization.d": "./types/organization.d.ts",
|
|
37
34
|
"./types/user.d": "./types/user.d.ts"
|
|
38
35
|
},
|
package/types/organization.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { OPERATION_ENUMS, ROLE_ENUMS } from '../constants/organization.ts';
|
|
1
2
|
|
|
2
3
|
/*
|
|
3
4
|
* ACL
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
export type OrganizationRoleEnum =
|
|
7
|
+
export type OrganizationRoleEnum = typeof ROLE_ENUMS[number];
|
|
8
|
+
export type OrganizationOperationEnum = typeof OPERATION_ENUMS[number];
|
|
7
9
|
|
|
8
10
|
export interface OrganizationACL {
|
|
9
11
|
id: string;
|
package/utils/api.ts
CHANGED
package/utils/object.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function uniq(arr: Array<any>, fn?: (value: any, index: number, self: Arr
|
|
|
29
29
|
* Remove undefined (and/or null) values from an object
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
export function removeUndefined(obj:
|
|
32
|
+
export function removeUndefined<T>(obj: T, removeNull?: boolean) {
|
|
33
33
|
for (const key in obj) {
|
|
34
34
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
35
35
|
if (
|
|
@@ -276,15 +276,15 @@ export function intersection(arr1: Array<any>, arr2: Array<any>) {
|
|
|
276
276
|
*/
|
|
277
277
|
|
|
278
278
|
export function getNestedValue(obj: any, path: string): any {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
if (!obj || !path) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
return path.split('.').reduce((o, key) => {
|
|
283
|
+
if (o && typeof o === 'object' && key in o) {
|
|
284
|
+
return o[key];
|
|
285
|
+
}
|
|
286
|
+
return undefined;
|
|
287
|
+
}, obj);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
/**
|
|
@@ -296,27 +296,27 @@ export function getNestedValue(obj: any, path: string): any {
|
|
|
296
296
|
*/
|
|
297
297
|
|
|
298
298
|
export function assignToNestedObject(obj: any, path: string, value: any) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
299
|
+
if (!obj || !path) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const keys = path.split('.');
|
|
303
|
+
const lastKey = keys.pop();
|
|
304
|
+
const nestedObj = keys.reduce((o, key) => {
|
|
305
|
+
if (!o[key]) {
|
|
306
|
+
o[key] = {};
|
|
307
|
+
}
|
|
308
|
+
return o[key];
|
|
309
|
+
}, obj);
|
|
310
|
+
|
|
311
|
+
if (lastKey) {
|
|
312
|
+
if (typeof nestedObj === 'object' && nestedObj !== null) {
|
|
313
|
+
nestedObj[lastKey] = value;
|
|
314
|
+
} else {
|
|
315
|
+
console.warn(`(!1) Cannot assign value to ${lastKey} because its reference is not an object.`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return obj;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
/**
|
|
@@ -336,15 +336,15 @@ export function groupCollections(collections: Array<any>, innerCollectionNames:
|
|
|
336
336
|
|
|
337
337
|
if (i === -1) {
|
|
338
338
|
innerCollectionNames.forEach((name: string) => {
|
|
339
|
-
|
|
339
|
+
const ref = getNestedValue(obj, name);
|
|
340
340
|
if (!ref) {
|
|
341
|
-
|
|
341
|
+
assignToNestedObject(obj, name, []);
|
|
342
342
|
} else {
|
|
343
|
-
|
|
343
|
+
assignToNestedObject(obj, name, [ref]);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
// Old version, but this doesn't support merged array collections
|
|
347
|
+
// if (!obj[name]) {
|
|
348
348
|
// obj[name] = [];
|
|
349
349
|
// } else {
|
|
350
350
|
// obj[name] = [obj[name]];
|
|
@@ -354,16 +354,16 @@ export function groupCollections(collections: Array<any>, innerCollectionNames:
|
|
|
354
354
|
acc.push(obj);
|
|
355
355
|
} else {
|
|
356
356
|
innerCollectionNames.forEach((name: string) => {
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
const innerObj = getNestedValue(obj, name);
|
|
358
|
+
const ref = getNestedValue(acc[i], name);
|
|
359
359
|
|
|
360
360
|
if (!ref) {
|
|
361
|
-
|
|
361
|
+
assignToNestedObject(acc[i], name, innerObj ? [innerObj] : []);
|
|
362
362
|
} else if (innerObj && !ref.find((o: any) => o.id === innerObj.id)) {
|
|
363
|
-
|
|
363
|
+
assignToNestedObject(acc[i], name, ref.concat(innerObj));
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
// Old version, but this doesn't support merged array collections
|
|
367
367
|
// const innerObj = obj[name];
|
|
368
368
|
// if (!acc[i][name]) {
|
|
369
369
|
// acc[i][name] = innerObj ? [innerObj] : [];
|
package/utils/string.ts
CHANGED
|
@@ -42,17 +42,16 @@ export function shortenToSpace(
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
export function guessFirstName(str: string, len: number = 40): string {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const spaceIx = shortened.indexOf(' ');
|
|
45
|
+
let shortened = str?.replace(/^(a|an|the|da|de|that|there|this|than|then)\b/i, '')?.trim() || '';
|
|
46
|
+
const spaceIx = shortened.indexOf(' ');
|
|
48
47
|
|
|
49
48
|
if (spaceIx >= 0) {
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
shortened = shortened.substring(0, spaceIx + 1);
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (len < shortened.length) {
|
|
53
|
+
shortened = shortened.substring(0, len);
|
|
54
|
+
}
|
|
56
55
|
|
|
57
56
|
const articleReplacedEnd = shortened.replace(
|
|
58
57
|
/\b(a|an|the|da|de|that|there|this|than|then)$/i,
|
|
@@ -60,7 +59,7 @@ export function guessFirstName(str: string, len: number = 40): string {
|
|
|
60
59
|
);
|
|
61
60
|
|
|
62
61
|
if (articleReplacedEnd.length < 5) {
|
|
63
|
-
return shortened;
|
|
62
|
+
return shortened.trim();
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
return articleReplacedEnd.trim();
|
|
@@ -327,3 +326,19 @@ export function textWithBrackets(
|
|
|
327
326
|
}
|
|
328
327
|
return `${text} ${brackets[0].trimStart()}${bText}${brackets[1].trimEnd()}`;
|
|
329
328
|
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Remove all line breaks and spaces from String
|
|
332
|
+
* NOTE: This is designed to remove garbage string from OpenAI text generation
|
|
333
|
+
*
|
|
334
|
+
* @param str - String to clean
|
|
335
|
+
* @returns Cleaned string without line breaks and spaces
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
export function removeGeneratedTextGarbage(str: string) {
|
|
339
|
+
if (!str || typeof str !== 'string') {
|
|
340
|
+
return '';
|
|
341
|
+
}
|
|
342
|
+
// Remove all line breaks and spaces
|
|
343
|
+
return str.replace(/[\n\r\s]+/g, ' ').trim();
|
|
344
|
+
}
|
package/utils/timeZone.ts
CHANGED
|
@@ -1842,6 +1842,427 @@ const TIMEZONE_DATA = {
|
|
|
1842
1842
|
list: string[];
|
|
1843
1843
|
}>;
|
|
1844
1844
|
|
|
1845
|
+
const TIMEZONES_LIST = [
|
|
1846
|
+
'Africa/Abidjan',
|
|
1847
|
+
'Africa/Accra',
|
|
1848
|
+
'Africa/Addis_Ababa',
|
|
1849
|
+
'Africa/Algiers',
|
|
1850
|
+
'Africa/Asmara',
|
|
1851
|
+
'Africa/Bamako',
|
|
1852
|
+
'Africa/Bangui',
|
|
1853
|
+
'Africa/Banjul',
|
|
1854
|
+
'Africa/Bissau',
|
|
1855
|
+
'Africa/Blantyre',
|
|
1856
|
+
'Africa/Brazzaville',
|
|
1857
|
+
'Africa/Bujumbura',
|
|
1858
|
+
'Africa/Cairo',
|
|
1859
|
+
'Africa/Casablanca',
|
|
1860
|
+
'Africa/Ceuta',
|
|
1861
|
+
'Africa/Conakry',
|
|
1862
|
+
'Africa/Dakar',
|
|
1863
|
+
'Africa/Dar_es_Salaam',
|
|
1864
|
+
'Africa/Djibouti',
|
|
1865
|
+
'Africa/Douala',
|
|
1866
|
+
'Africa/El_Aaiun',
|
|
1867
|
+
'Africa/Freetown',
|
|
1868
|
+
'Africa/Gaborone',
|
|
1869
|
+
'Africa/Harare',
|
|
1870
|
+
'Africa/Johannesburg',
|
|
1871
|
+
'Africa/Juba',
|
|
1872
|
+
'Africa/Kampala',
|
|
1873
|
+
'Africa/Khartoum',
|
|
1874
|
+
'Africa/Kigali',
|
|
1875
|
+
'Africa/Kinshasa',
|
|
1876
|
+
'Africa/Lagos',
|
|
1877
|
+
'Africa/Libreville',
|
|
1878
|
+
'Africa/Lome',
|
|
1879
|
+
'Africa/Luanda',
|
|
1880
|
+
'Africa/Lubumbashi',
|
|
1881
|
+
'Africa/Lusaka',
|
|
1882
|
+
'Africa/Malabo',
|
|
1883
|
+
'Africa/Maputo',
|
|
1884
|
+
'Africa/Maseru',
|
|
1885
|
+
'Africa/Mbabane',
|
|
1886
|
+
'Africa/Mogadishu',
|
|
1887
|
+
'Africa/Monrovia',
|
|
1888
|
+
'Africa/Nairobi',
|
|
1889
|
+
'Africa/Ndjamena',
|
|
1890
|
+
'Africa/Niamey',
|
|
1891
|
+
'Africa/Nouakchott',
|
|
1892
|
+
'Africa/Ouagadougou',
|
|
1893
|
+
'Africa/Porto-Novo',
|
|
1894
|
+
'Africa/Sao_Tome',
|
|
1895
|
+
'Africa/Tripoli',
|
|
1896
|
+
'Africa/Tunis',
|
|
1897
|
+
'Africa/Windhoek',
|
|
1898
|
+
'America/Adak',
|
|
1899
|
+
'America/Anchorage',
|
|
1900
|
+
'America/Anguilla',
|
|
1901
|
+
'America/Antigua',
|
|
1902
|
+
'America/Araguaina',
|
|
1903
|
+
'America/Argentina/Buenos_Aires',
|
|
1904
|
+
'America/Argentina/Catamarca',
|
|
1905
|
+
'America/Argentina/Cordoba',
|
|
1906
|
+
'America/Argentina/Jujuy',
|
|
1907
|
+
'America/Argentina/La_Rioja',
|
|
1908
|
+
'America/Argentina/Mendoza',
|
|
1909
|
+
'America/Argentina/Rio_Gallegos',
|
|
1910
|
+
'America/Argentina/Salta',
|
|
1911
|
+
'America/Argentina/San_Juan',
|
|
1912
|
+
'America/Argentina/San_Luis',
|
|
1913
|
+
'America/Argentina/Tucuman',
|
|
1914
|
+
'America/Argentina/Ushuaia',
|
|
1915
|
+
'America/Aruba',
|
|
1916
|
+
'America/Asuncion',
|
|
1917
|
+
'America/Atikokan',
|
|
1918
|
+
'America/Bahia',
|
|
1919
|
+
'America/Bahia_Banderas',
|
|
1920
|
+
'America/Barbados',
|
|
1921
|
+
'America/Belem',
|
|
1922
|
+
'America/Belize',
|
|
1923
|
+
'America/Blanc-Sablon',
|
|
1924
|
+
'America/Boa_Vista',
|
|
1925
|
+
'America/Bogota',
|
|
1926
|
+
'America/Boise',
|
|
1927
|
+
'America/Cambridge_Bay',
|
|
1928
|
+
'America/Campo_Grande',
|
|
1929
|
+
'America/Cancun',
|
|
1930
|
+
'America/Caracas',
|
|
1931
|
+
'America/Cayenne',
|
|
1932
|
+
'America/Cayman',
|
|
1933
|
+
'America/Chicago',
|
|
1934
|
+
'America/Chihuahua',
|
|
1935
|
+
'America/Ciudad_Juarez',
|
|
1936
|
+
'America/Costa_Rica',
|
|
1937
|
+
'America/Coyhaique',
|
|
1938
|
+
'America/Creston',
|
|
1939
|
+
'America/Cuiaba',
|
|
1940
|
+
'America/Curacao',
|
|
1941
|
+
'America/Danmarkshavn',
|
|
1942
|
+
'America/Dawson',
|
|
1943
|
+
'America/Dawson_Creek',
|
|
1944
|
+
'America/Denver',
|
|
1945
|
+
'America/Detroit',
|
|
1946
|
+
'America/Dominica',
|
|
1947
|
+
'America/Edmonton',
|
|
1948
|
+
'America/Eirunepe',
|
|
1949
|
+
'America/El_Salvador',
|
|
1950
|
+
'America/Fort_Nelson',
|
|
1951
|
+
'America/Fortaleza',
|
|
1952
|
+
'America/Glace_Bay',
|
|
1953
|
+
'America/Goose_Bay',
|
|
1954
|
+
'America/Grand_Turk',
|
|
1955
|
+
'America/Grenada',
|
|
1956
|
+
'America/Guadeloupe',
|
|
1957
|
+
'America/Guatemala',
|
|
1958
|
+
'America/Guayaquil',
|
|
1959
|
+
'America/Guyana',
|
|
1960
|
+
'America/Halifax',
|
|
1961
|
+
'America/Havana',
|
|
1962
|
+
'America/Hermosillo',
|
|
1963
|
+
'America/Indiana/Indianapolis',
|
|
1964
|
+
'America/Indiana/Knox',
|
|
1965
|
+
'America/Indiana/Marengo',
|
|
1966
|
+
'America/Indiana/Petersburg',
|
|
1967
|
+
'America/Indiana/Tell_City',
|
|
1968
|
+
'America/Indiana/Vevay',
|
|
1969
|
+
'America/Indiana/Vincennes',
|
|
1970
|
+
'America/Indiana/Winamac',
|
|
1971
|
+
'America/Inuvik',
|
|
1972
|
+
'America/Iqaluit',
|
|
1973
|
+
'America/Jamaica',
|
|
1974
|
+
'America/Juneau',
|
|
1975
|
+
'America/Kentucky/Louisville',
|
|
1976
|
+
'America/Kentucky/Monticello',
|
|
1977
|
+
'America/Kralendijk',
|
|
1978
|
+
'America/La_Paz',
|
|
1979
|
+
'America/Lima',
|
|
1980
|
+
'America/Los_Angeles',
|
|
1981
|
+
'America/Lower_Princes',
|
|
1982
|
+
'America/Maceio',
|
|
1983
|
+
'America/Managua',
|
|
1984
|
+
'America/Manaus',
|
|
1985
|
+
'America/Marigot',
|
|
1986
|
+
'America/Martinique',
|
|
1987
|
+
'America/Matamoros',
|
|
1988
|
+
'America/Mazatlan',
|
|
1989
|
+
'America/Menominee',
|
|
1990
|
+
'America/Merida',
|
|
1991
|
+
'America/Metlakatla',
|
|
1992
|
+
'America/Mexico_City',
|
|
1993
|
+
'America/Miquelon',
|
|
1994
|
+
'America/Moncton',
|
|
1995
|
+
'America/Monterrey',
|
|
1996
|
+
'America/Montevideo',
|
|
1997
|
+
'America/Montserrat',
|
|
1998
|
+
'America/Nassau',
|
|
1999
|
+
'America/New_York',
|
|
2000
|
+
'America/Nome',
|
|
2001
|
+
'America/Noronha',
|
|
2002
|
+
'America/North_Dakota/Beulah',
|
|
2003
|
+
'America/North_Dakota/Center',
|
|
2004
|
+
'America/North_Dakota/New_Salem',
|
|
2005
|
+
'America/Nuuk',
|
|
2006
|
+
'America/Ojinaga',
|
|
2007
|
+
'America/Panama',
|
|
2008
|
+
'America/Paramaribo',
|
|
2009
|
+
'America/Phoenix',
|
|
2010
|
+
'America/Port-au-Prince',
|
|
2011
|
+
'America/Port_of_Spain',
|
|
2012
|
+
'America/Porto_Velho',
|
|
2013
|
+
'America/Puerto_Rico',
|
|
2014
|
+
'America/Punta_Arenas',
|
|
2015
|
+
'America/Rankin_Inlet',
|
|
2016
|
+
'America/Recife',
|
|
2017
|
+
'America/Regina',
|
|
2018
|
+
'America/Resolute',
|
|
2019
|
+
'America/Rio_Branco',
|
|
2020
|
+
'America/Santarem',
|
|
2021
|
+
'America/Santiago',
|
|
2022
|
+
'America/Santo_Domingo',
|
|
2023
|
+
'America/Sao_Paulo',
|
|
2024
|
+
'America/Scoresbysund',
|
|
2025
|
+
'America/Sitka',
|
|
2026
|
+
'America/St_Barthelemy',
|
|
2027
|
+
'America/St_Johns',
|
|
2028
|
+
'America/St_Kitts',
|
|
2029
|
+
'America/St_Lucia',
|
|
2030
|
+
'America/St_Thomas',
|
|
2031
|
+
'America/St_Vincent',
|
|
2032
|
+
'America/Swift_Current',
|
|
2033
|
+
'America/Tegucigalpa',
|
|
2034
|
+
'America/Thule',
|
|
2035
|
+
'America/Tijuana',
|
|
2036
|
+
'America/Toronto',
|
|
2037
|
+
'America/Tortola',
|
|
2038
|
+
'America/Vancouver',
|
|
2039
|
+
'America/Whitehorse',
|
|
2040
|
+
'America/Winnipeg',
|
|
2041
|
+
'America/Yakutat',
|
|
2042
|
+
'Antarctica/Casey',
|
|
2043
|
+
'Antarctica/Davis',
|
|
2044
|
+
'Antarctica/DumontDUrville',
|
|
2045
|
+
'Antarctica/Macquarie',
|
|
2046
|
+
'Antarctica/Mawson',
|
|
2047
|
+
'Antarctica/McMurdo',
|
|
2048
|
+
'Antarctica/Palmer',
|
|
2049
|
+
'Antarctica/Rothera',
|
|
2050
|
+
'Antarctica/Syowa',
|
|
2051
|
+
'Antarctica/Troll',
|
|
2052
|
+
'Antarctica/Vostok',
|
|
2053
|
+
'Arctic/Longyearbyen',
|
|
2054
|
+
'Asia/Aden',
|
|
2055
|
+
'Asia/Almaty',
|
|
2056
|
+
'Asia/Amman',
|
|
2057
|
+
'Asia/Anadyr',
|
|
2058
|
+
'Asia/Aqtau',
|
|
2059
|
+
'Asia/Aqtobe',
|
|
2060
|
+
'Asia/Ashgabat',
|
|
2061
|
+
'Asia/Atyrau',
|
|
2062
|
+
'Asia/Baghdad',
|
|
2063
|
+
'Asia/Bahrain',
|
|
2064
|
+
'Asia/Baku',
|
|
2065
|
+
'Asia/Bangkok',
|
|
2066
|
+
'Asia/Barnaul',
|
|
2067
|
+
'Asia/Beirut',
|
|
2068
|
+
'Asia/Bishkek',
|
|
2069
|
+
'Asia/Brunei',
|
|
2070
|
+
'Asia/Chita',
|
|
2071
|
+
'Asia/Colombo',
|
|
2072
|
+
'Asia/Damascus',
|
|
2073
|
+
'Asia/Dhaka',
|
|
2074
|
+
'Asia/Dili',
|
|
2075
|
+
'Asia/Dubai',
|
|
2076
|
+
'Asia/Dushanbe',
|
|
2077
|
+
'Asia/Famagusta',
|
|
2078
|
+
'Asia/Gaza',
|
|
2079
|
+
'Asia/Hebron',
|
|
2080
|
+
'Asia/Ho_Chi_Minh',
|
|
2081
|
+
'Asia/Hong_Kong',
|
|
2082
|
+
'Asia/Hovd',
|
|
2083
|
+
'Asia/Irkutsk',
|
|
2084
|
+
'Asia/Jakarta',
|
|
2085
|
+
'Asia/Jayapura',
|
|
2086
|
+
'Asia/Jerusalem',
|
|
2087
|
+
'Asia/Kabul',
|
|
2088
|
+
'Asia/Kamchatka',
|
|
2089
|
+
'Asia/Karachi',
|
|
2090
|
+
'Asia/Kathmandu',
|
|
2091
|
+
'Asia/Khandyga',
|
|
2092
|
+
'Asia/Kolkata',
|
|
2093
|
+
'Asia/Krasnoyarsk',
|
|
2094
|
+
'Asia/Kuala_Lumpur',
|
|
2095
|
+
'Asia/Kuching',
|
|
2096
|
+
'Asia/Kuwait',
|
|
2097
|
+
'Asia/Macau',
|
|
2098
|
+
'Asia/Magadan',
|
|
2099
|
+
'Asia/Makassar',
|
|
2100
|
+
'Asia/Manila',
|
|
2101
|
+
'Asia/Muscat',
|
|
2102
|
+
'Asia/Nicosia',
|
|
2103
|
+
'Asia/Novokuznetsk',
|
|
2104
|
+
'Asia/Novosibirsk',
|
|
2105
|
+
'Asia/Omsk',
|
|
2106
|
+
'Asia/Oral',
|
|
2107
|
+
'Asia/Phnom_Penh',
|
|
2108
|
+
'Asia/Pontianak',
|
|
2109
|
+
'Asia/Pyongyang',
|
|
2110
|
+
'Asia/Qatar',
|
|
2111
|
+
'Asia/Qostanay',
|
|
2112
|
+
'Asia/Qyzylorda',
|
|
2113
|
+
'Asia/Riyadh',
|
|
2114
|
+
'Asia/Sakhalin',
|
|
2115
|
+
'Asia/Samarkand',
|
|
2116
|
+
'Asia/Seoul',
|
|
2117
|
+
'Asia/Shanghai',
|
|
2118
|
+
'Asia/Singapore',
|
|
2119
|
+
'Asia/Srednekolymsk',
|
|
2120
|
+
'Asia/Taipei',
|
|
2121
|
+
'Asia/Tashkent',
|
|
2122
|
+
'Asia/Tbilisi',
|
|
2123
|
+
'Asia/Tehran',
|
|
2124
|
+
'Asia/Thimphu',
|
|
2125
|
+
'Asia/Tokyo',
|
|
2126
|
+
'Asia/Tomsk',
|
|
2127
|
+
'Asia/Ulaanbaatar',
|
|
2128
|
+
'Asia/Urumqi',
|
|
2129
|
+
'Asia/Ust-Nera',
|
|
2130
|
+
'Asia/Vientiane',
|
|
2131
|
+
'Asia/Vladivostok',
|
|
2132
|
+
'Asia/Yakutsk',
|
|
2133
|
+
'Asia/Yangon',
|
|
2134
|
+
'Asia/Yekaterinburg',
|
|
2135
|
+
'Asia/Yerevan',
|
|
2136
|
+
'Atlantic/Azores',
|
|
2137
|
+
'Atlantic/Bermuda',
|
|
2138
|
+
'Atlantic/Canary',
|
|
2139
|
+
'Atlantic/Cape_Verde',
|
|
2140
|
+
'Atlantic/Faroe',
|
|
2141
|
+
'Atlantic/Madeira',
|
|
2142
|
+
'Atlantic/Reykjavik',
|
|
2143
|
+
'Atlantic/South_Georgia',
|
|
2144
|
+
'Atlantic/St_Helena',
|
|
2145
|
+
'Atlantic/Stanley',
|
|
2146
|
+
'Australia/Adelaide',
|
|
2147
|
+
'Australia/Brisbane',
|
|
2148
|
+
'Australia/Broken_Hill',
|
|
2149
|
+
'Australia/Darwin',
|
|
2150
|
+
'Australia/Eucla',
|
|
2151
|
+
'Australia/Hobart',
|
|
2152
|
+
'Australia/Lindeman',
|
|
2153
|
+
'Australia/Lord_Howe',
|
|
2154
|
+
'Australia/Melbourne',
|
|
2155
|
+
'Australia/Perth',
|
|
2156
|
+
'Australia/Sydney',
|
|
2157
|
+
'Europe/Amsterdam',
|
|
2158
|
+
'Europe/Andorra',
|
|
2159
|
+
'Europe/Astrakhan',
|
|
2160
|
+
'Europe/Athens',
|
|
2161
|
+
'Europe/Belgrade',
|
|
2162
|
+
'Europe/Berlin',
|
|
2163
|
+
'Europe/Bratislava',
|
|
2164
|
+
'Europe/Brussels',
|
|
2165
|
+
'Europe/Bucharest',
|
|
2166
|
+
'Europe/Budapest',
|
|
2167
|
+
'Europe/Busingen',
|
|
2168
|
+
'Europe/Chisinau',
|
|
2169
|
+
'Europe/Copenhagen',
|
|
2170
|
+
'Europe/Dublin',
|
|
2171
|
+
'Europe/Gibraltar',
|
|
2172
|
+
'Europe/Guernsey',
|
|
2173
|
+
'Europe/Helsinki',
|
|
2174
|
+
'Europe/Isle_of_Man',
|
|
2175
|
+
'Europe/Istanbul',
|
|
2176
|
+
'Europe/Jersey',
|
|
2177
|
+
'Europe/Kaliningrad',
|
|
2178
|
+
'Europe/Kirov',
|
|
2179
|
+
'Europe/Kyiv',
|
|
2180
|
+
'Europe/Lisbon',
|
|
2181
|
+
'Europe/Ljubljana',
|
|
2182
|
+
'Europe/London',
|
|
2183
|
+
'Europe/Luxembourg',
|
|
2184
|
+
'Europe/Madrid',
|
|
2185
|
+
'Europe/Malta',
|
|
2186
|
+
'Europe/Mariehamn',
|
|
2187
|
+
'Europe/Minsk',
|
|
2188
|
+
'Europe/Monaco',
|
|
2189
|
+
'Europe/Moscow',
|
|
2190
|
+
'Europe/Oslo',
|
|
2191
|
+
'Europe/Paris',
|
|
2192
|
+
'Europe/Podgorica',
|
|
2193
|
+
'Europe/Prague',
|
|
2194
|
+
'Europe/Riga',
|
|
2195
|
+
'Europe/Rome',
|
|
2196
|
+
'Europe/Samara',
|
|
2197
|
+
'Europe/San_Marino',
|
|
2198
|
+
'Europe/Sarajevo',
|
|
2199
|
+
'Europe/Saratov',
|
|
2200
|
+
'Europe/Simferopol',
|
|
2201
|
+
'Europe/Skopje',
|
|
2202
|
+
'Europe/Sofia',
|
|
2203
|
+
'Europe/Stockholm',
|
|
2204
|
+
'Europe/Tallinn',
|
|
2205
|
+
'Europe/Tirane',
|
|
2206
|
+
'Europe/Ulyanovsk',
|
|
2207
|
+
'Europe/Vaduz',
|
|
2208
|
+
'Europe/Vatican',
|
|
2209
|
+
'Europe/Vienna',
|
|
2210
|
+
'Europe/Vilnius',
|
|
2211
|
+
'Europe/Volgograd',
|
|
2212
|
+
'Europe/Warsaw',
|
|
2213
|
+
'Europe/Zagreb',
|
|
2214
|
+
'Europe/Zurich',
|
|
2215
|
+
'Indian/Antananarivo',
|
|
2216
|
+
'Indian/Chagos',
|
|
2217
|
+
'Indian/Christmas',
|
|
2218
|
+
'Indian/Cocos',
|
|
2219
|
+
'Indian/Comoro',
|
|
2220
|
+
'Indian/Kerguelen',
|
|
2221
|
+
'Indian/Mahe',
|
|
2222
|
+
'Indian/Maldives',
|
|
2223
|
+
'Indian/Mauritius',
|
|
2224
|
+
'Indian/Mayotte',
|
|
2225
|
+
'Indian/Reunion',
|
|
2226
|
+
'Pacific/Apia',
|
|
2227
|
+
'Pacific/Auckland',
|
|
2228
|
+
'Pacific/Bougainville',
|
|
2229
|
+
'Pacific/Chatham',
|
|
2230
|
+
'Pacific/Chuuk',
|
|
2231
|
+
'Pacific/Easter',
|
|
2232
|
+
'Pacific/Efate',
|
|
2233
|
+
'Pacific/Fakaofo',
|
|
2234
|
+
'Pacific/Fiji',
|
|
2235
|
+
'Pacific/Funafuti',
|
|
2236
|
+
'Pacific/Galapagos',
|
|
2237
|
+
'Pacific/Gambier',
|
|
2238
|
+
'Pacific/Guadalcanal',
|
|
2239
|
+
'Pacific/Guam',
|
|
2240
|
+
'Pacific/Honolulu',
|
|
2241
|
+
'Pacific/Kanton',
|
|
2242
|
+
'Pacific/Kiritimati',
|
|
2243
|
+
'Pacific/Kosrae',
|
|
2244
|
+
'Pacific/Kwajalein',
|
|
2245
|
+
'Pacific/Majuro',
|
|
2246
|
+
'Pacific/Marquesas',
|
|
2247
|
+
'Pacific/Midway',
|
|
2248
|
+
'Pacific/Nauru',
|
|
2249
|
+
'Pacific/Niue',
|
|
2250
|
+
'Pacific/Norfolk',
|
|
2251
|
+
'Pacific/Noumea',
|
|
2252
|
+
'Pacific/Pago_Pago',
|
|
2253
|
+
'Pacific/Palau',
|
|
2254
|
+
'Pacific/Pitcairn',
|
|
2255
|
+
'Pacific/Pohnpei',
|
|
2256
|
+
'Pacific/Port_Moresby',
|
|
2257
|
+
'Pacific/Rarotonga',
|
|
2258
|
+
'Pacific/Saipan',
|
|
2259
|
+
'Pacific/Tahiti',
|
|
2260
|
+
'Pacific/Tarawa',
|
|
2261
|
+
'Pacific/Tongatapu',
|
|
2262
|
+
'Pacific/Wake',
|
|
2263
|
+
'Pacific/Wallis'
|
|
2264
|
+
];
|
|
2265
|
+
|
|
1845
2266
|
// Object.values(TIMEZONE_DATA).forEach((item) => {
|
|
1846
2267
|
// console.log(
|
|
1847
2268
|
// item.abbr + ': {\n' +
|
|
@@ -1877,18 +2298,25 @@ const TIMEZONE_DATA = {
|
|
|
1877
2298
|
|
|
1878
2299
|
/**
|
|
1879
2300
|
* Check if timezone is valid
|
|
2301
|
+
* @param tz - Timezone string
|
|
2302
|
+
* @returns {boolean} - True if valid, false otherwise
|
|
1880
2303
|
*/
|
|
1881
2304
|
|
|
1882
2305
|
export function isValidTimeZone(tz: string) {
|
|
1883
2306
|
if (tz && tz.length > 0) {
|
|
1884
2307
|
// return TIMEZONES_LIST.includes(tz);
|
|
1885
|
-
|
|
2308
|
+
return DateTime.now().setZone(tz).isValid;
|
|
1886
2309
|
}
|
|
1887
2310
|
return false;
|
|
1888
2311
|
}
|
|
1889
2312
|
|
|
1890
2313
|
/**
|
|
1891
2314
|
* Get (approximate) time zone from major address components
|
|
2315
|
+
* @param country - Country code (ISO 3166-1 alpha-2)
|
|
2316
|
+
* @param state - State or province code (ISO 3166-2)
|
|
2317
|
+
* @param _city - City name (optional, not used in current implementation)
|
|
2318
|
+
* @returns {string} - Time zone identifier (IANA format)
|
|
2319
|
+
* If no specific time zone is found, returns a default time zone.
|
|
1892
2320
|
*/
|
|
1893
2321
|
|
|
1894
2322
|
export function getTimeZone(country: string, state: string, _city?: string) {
|
|
@@ -1910,6 +2338,15 @@ export function getTimeZone(country: string, state: string, _city?: string) {
|
|
|
1910
2338
|
|
|
1911
2339
|
/**
|
|
1912
2340
|
* Parse date in timezone
|
|
2341
|
+
* @param input - Date object or string in "YYYY-MM-DD" format
|
|
2342
|
+
* @param tz - Timezone string (IANA format), defaults to DEFAULT_TIMEZONE
|
|
2343
|
+
* @param addDay - Number of days to add (can be negative), defaults to 0
|
|
2344
|
+
* @returns {Date} - Date object adjusted to the specified timezone
|
|
2345
|
+
* If input is a string in "YYYY-MM-DD" format, it will be parsed as the start of that day in the specified timezone.
|
|
2346
|
+
* If input is a Date object, it will be converted to the specified timezone.
|
|
2347
|
+
* If addDay is provided, it will adjust the date by the specified number of days.
|
|
2348
|
+
* If tz is not provided, it defaults to DEFAULT_TIMEZONE.
|
|
2349
|
+
* If input is invalid, it will return an invalid Date object.
|
|
1913
2350
|
*/
|
|
1914
2351
|
|
|
1915
2352
|
export function parseDateInTimezone(
|
|
@@ -1937,3 +2374,38 @@ export function parseDateInTimezone(
|
|
|
1937
2374
|
|
|
1938
2375
|
return dt.toJSDate();
|
|
1939
2376
|
}
|
|
2377
|
+
|
|
2378
|
+
/**
|
|
2379
|
+
* Get the index of timzeone from TIMEZONES_LIST
|
|
2380
|
+
* @param tz - Timezone string (IANA format)
|
|
2381
|
+
* @returns {number | string} - Index of the timezone in TIMEZONES_LIST, or the original timezone string if not found
|
|
2382
|
+
*/
|
|
2383
|
+
|
|
2384
|
+
export function timeZoneToIndex(tz: string): number | string {
|
|
2385
|
+
const index = TIMEZONES_LIST.indexOf(tz);
|
|
2386
|
+
if (index === -1) {
|
|
2387
|
+
return tz;
|
|
2388
|
+
}
|
|
2389
|
+
return index;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* Get time zone from index
|
|
2394
|
+
* @param index - Index of the timezone in TIMEZONES_LIST
|
|
2395
|
+
* @returns {string} - Timezone string (IANA format) if index is valid, otherwise return the index itself
|
|
2396
|
+
*/
|
|
2397
|
+
|
|
2398
|
+
export function indexToTimeZone(index?: number | string | null): string | null {
|
|
2399
|
+
if (index === null || index === undefined) {
|
|
2400
|
+
return null;
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
const value = Number(index);
|
|
2404
|
+
if (!isNaN(value) && value < TIMEZONES_LIST.length) {
|
|
2405
|
+
return TIMEZONES_LIST[value];
|
|
2406
|
+
} else if (isValidTimeZone(String(index))) {
|
|
2407
|
+
return String(index);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
return null;
|
|
2411
|
+
}
|
package/constants/journal.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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/types/journal.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { FIELD_LOG_ACTIVITY_ENUMS, HARVEST_LOG_ACTIVITY_ENUMS, JOURNAL_TYPE_ENUMS } from '../constants/journal.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Journal entry object
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface JournalEntryObj {
|
|
8
|
-
id: string
|
|
9
|
-
accountId: string
|
|
10
|
-
type: JournalTypeEnum
|
|
11
|
-
notes: string
|
|
12
|
-
date: string // ISO date string
|
|
13
|
-
editAt: string // ISO date string
|
|
14
|
-
|
|
15
|
-
activity: JournalEntryActivityEnum
|
|
16
|
-
item: string
|
|
17
|
-
quantity: number
|
|
18
|
-
unit: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type JournalTypeEnum = typeof JOURNAL_TYPE_ENUMS[number];
|
|
22
|
-
export type FieldLogActivityEnum = typeof FIELD_LOG_ACTIVITY_ENUMS[number];
|
|
23
|
-
export type HarvestLogActivityEnum = typeof HARVEST_LOG_ACTIVITY_ENUMS[number];
|
|
24
|
-
export type JournalEntryActivityEnum = FieldLogActivityEnum | HarvestLogActivityEnum;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Filters for search
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
export interface FilterJournalEntriesArgs {
|
|
31
|
-
type?: JournalTypeEnum | null;
|
|
32
|
-
startDate?: string | null;
|
|
33
|
-
endDate?: string | null;
|
|
34
|
-
query?: string;
|
|
35
|
-
}
|
package/utils/journal.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ColorEnum } from '../types/app.d';
|
|
2
|
-
import type { JournalTypeEnum } from '../types/journal.d';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Map journal type to a color
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export function getJournalTypeColor(type: JournalTypeEnum): ColorEnum {
|
|
9
|
-
const journalTypeToColor = {
|
|
10
|
-
SEED: 'brown',
|
|
11
|
-
FIELD: 'yellow',
|
|
12
|
-
HARVEST: 'green',
|
|
13
|
-
POST_HARVEST: 'cyan',
|
|
14
|
-
SALES: 'blue',
|
|
15
|
-
} as Record<JournalTypeEnum, ColorEnum>;
|
|
16
|
-
|
|
17
|
-
// Default to zinc if type is not found
|
|
18
|
-
const color = journalTypeToColor[type] || 'zinc';
|
|
19
|
-
return color;
|
|
20
|
-
}
|