@jsb188/app 1.1.10 → 1.1.12
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/package.json +57 -45
- package/src/constants/agent.ts +51 -41
- package/src/constants/app.ts +34 -13
- package/src/constants/emoji.ts +9144 -8936
- package/src/constants/other.ts +1 -5
- package/src/constants/user.ts +16 -25
- package/src/constants/wsActions.ts +27 -0
- package/src/i18n/account.ts +129 -107
- package/src/i18n/agent.ts +331 -73
- package/src/i18n/agentToolBusiness.ts +196 -0
- package/src/i18n/agentToolGrid.ts +137 -0
- package/src/i18n/agentToolWorkflow.ts +101 -0
- package/src/i18n/agent_note.ts +109 -0
- package/src/i18n/app.ts +107 -91
- package/src/i18n/auth.ts +117 -102
- package/src/i18n/billing.ts +5 -92
- package/src/i18n/c.ts +907 -0
- package/src/i18n/campaign.ts +919 -0
- package/src/i18n/country.ts +248 -248
- package/src/i18n/datetime.ts +32 -26
- package/src/i18n/editor.ts +58 -0
- package/src/i18n/error.ts +577 -192
- package/src/i18n/field_doc_editor.ts +21 -0
- package/src/i18n/field_doc_programs.ts +52 -0
- package/src/i18n/field_docs.ts +190 -0
- package/src/i18n/index.ts +42 -19
- package/src/i18n/log.ts +272 -238
- package/src/i18n/memory.ts +53 -0
- package/src/i18n/message.ts +3 -4
- package/src/i18n/note.ts +19 -0
- package/src/i18n/org.ts +164 -109
- package/src/i18n/schedule.ts +209 -0
- package/src/i18n/sheet.ts +333 -4
- package/src/i18n/sheet_formula.ts +165 -0
- package/src/i18n/workflow.ts +109 -23
- package/src/main.ts +68 -64
- package/src/platform.ts +90 -49
- package/src/types/ai.d.ts +52 -23
- package/src/types/app.d.ts +95 -44
- package/src/types/auth.d.ts +66 -40
- package/src/types/console.d.ts +3 -0
- package/src/types/other.d.ts +13 -6
- package/src/types.d.ts +12 -14
- package/src/utils/account.ts +64 -58
- package/src/utils/api.ts +326 -77
- package/src/utils/authSession.ts +24 -0
- package/src/utils/clientIP.ts +213 -0
- package/src/utils/color.ts +279 -0
- package/src/utils/cron.ts +49 -18
- package/src/utils/csv.ts +19 -0
- package/src/utils/datetime.ts +445 -117
- package/src/utils/deferredSave.ts +89 -0
- package/src/utils/email.ts +50 -0
- package/src/utils/emoji.ts +107 -84
- package/src/utils/expression.helpers.ts +470 -0
- package/src/utils/expression.test.ts +793 -0
- package/src/utils/expression.ts +2261 -0
- package/src/utils/interval.ts +80 -0
- package/src/utils/language.ts +9 -0
- package/src/utils/logic.ts +141 -121
- package/src/utils/managedSession.ts +34 -0
- package/src/utils/managedSessionBff.test.ts +60 -0
- package/src/utils/managedSessionBff.ts +117 -0
- package/src/utils/number.ts +85 -38
- package/src/utils/object.ts +227 -30
- package/src/utils/promise.ts +98 -0
- package/src/utils/queryReset.ts +266 -0
- package/src/utils/recurringTask.ts +60 -0
- package/src/utils/schema.ts +293 -0
- package/src/utils/string.test.ts +205 -208
- package/src/utils/string.ts +426 -463
- package/src/utils/timeZone.ts +309 -851
- package/src/utils/url_client.ts +145 -72
- package/tsconfig.json +10 -10
- package/src/constants/billing.ts +0 -146
- package/src/i18n/form.ts +0 -376
- package/src/i18n/product.ts +0 -76
- package/src/types/form.d.ts +0 -97
- package/src/utils/billing.ts +0 -134
package/src/types/ai.d.ts
CHANGED
|
@@ -1,34 +1,63 @@
|
|
|
1
|
-
|
|
2
1
|
// AI chat types
|
|
3
2
|
|
|
4
|
-
export type
|
|
3
|
+
export type AIChatType = 'ORCHESTRATOR';
|
|
4
|
+
|
|
5
|
+
export type AIChatMessageType =
|
|
6
|
+
| 'MESSAGE'
|
|
7
|
+
| 'SMS'
|
|
8
|
+
| 'IMAGE'
|
|
9
|
+
| 'FILE'
|
|
10
|
+
| 'SMS_IMAGE'
|
|
11
|
+
| 'SMS_FILE'
|
|
12
|
+
| 'TRANSCRIBED_MESSAGE'
|
|
13
|
+
| 'FUNCTION_CALL'
|
|
14
|
+
| 'FUNCTION_CALL_OUTPUT';
|
|
5
15
|
|
|
6
16
|
// AI events
|
|
7
17
|
|
|
8
18
|
export type AIEventErrorName =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
| 'AI_EVENT_UNKNOWN_ERR'
|
|
20
|
+
| 'AI_EVENT_DEVELOPER_ERR'
|
|
21
|
+
| 'AI_EVENT_NO_ACCESS'
|
|
22
|
+
| 'AI_COULD_NOT_RESOLVE'
|
|
23
|
+
| 'AI_CONTEXT_ERR'
|
|
24
|
+
| 'AI_CONTEXT_MANAGEMENT_ERR'
|
|
25
|
+
| 'AI_TOOL_EXECUTION_ERR'
|
|
26
|
+
| 'AI_ORG_ACL_FAILED'
|
|
27
|
+
| 'SETUP_INCOMPLETE_ORG'
|
|
28
|
+
| 'MISSING_API_KEY'
|
|
29
|
+
| 'LLM_PROVIDER_NOT_FOUND'
|
|
30
|
+
| 'LLM_SERVICE_ERR'
|
|
31
|
+
| 'MODERATION_MISSING'
|
|
32
|
+
| 'MODERATION_SERVICE_ERR'
|
|
33
|
+
| 'UNKNOWN_LLM_ERR'
|
|
34
|
+
| 'TWILIO_API_ERR'
|
|
35
|
+
| 'UNFINISHED_LOGIC';
|
|
24
36
|
|
|
25
37
|
// AI chat
|
|
26
38
|
|
|
27
39
|
export interface AIChatData {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
activityOrder?: string;
|
|
41
|
+
id: string;
|
|
42
|
+
type: AIChatType | null;
|
|
43
|
+
organizationId: string | null;
|
|
44
|
+
agentNoteId?: string | null;
|
|
45
|
+
calDate: string | null;
|
|
46
|
+
summary: string;
|
|
47
|
+
userManagedSummary: boolean;
|
|
48
|
+
archivedAt: string | null;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Public execution metadata shared by GraphQL responses and CHAT_RUN_UPDATE SSE events.
|
|
54
|
+
export interface AIChatRunData {
|
|
55
|
+
id: string;
|
|
56
|
+
sourceMessageIds: string[];
|
|
57
|
+
status: 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'DELIVERY_UNKNOWN';
|
|
58
|
+
inProgress: boolean;
|
|
59
|
+
createdAt: string | null;
|
|
60
|
+
claimedAt: string | null;
|
|
61
|
+
finishedAt: string | null;
|
|
62
|
+
updatedAt: string | null;
|
|
34
63
|
}
|
package/src/types/app.d.ts
CHANGED
|
@@ -1,76 +1,127 @@
|
|
|
1
1
|
import { COLORS } from '../constants/app.ts';
|
|
2
|
+
import type { QueryResetTarget } from '../utils/queryReset.ts';
|
|
2
3
|
|
|
3
4
|
// Modal; App settings
|
|
4
5
|
|
|
5
6
|
export interface EditIfaceModalProps {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
containerClassName: string;
|
|
8
|
+
saveCounter: number;
|
|
9
|
+
saving: boolean;
|
|
10
|
+
hasChanges: boolean;
|
|
11
|
+
openModalPopUp: (opts: any) => void;
|
|
12
|
+
onChangeDiff: (diff: boolean) => void;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export interface EditUserModalProps extends EditIfaceModalProps {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface EditUserPlusModalProps extends EditIfaceModalProps {
|
|
20
|
-
user: any;
|
|
21
|
-
editUserPlus: (obj: object) => void;
|
|
16
|
+
user: any;
|
|
17
|
+
editUser: (obj: object) => void;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
// App types
|
|
25
21
|
|
|
26
22
|
export type DarkOrLightEnum = 'light' | 'dark';
|
|
27
23
|
|
|
28
|
-
export type ColorEnum = typeof COLORS[number];
|
|
29
|
-
|
|
30
|
-
// Stripe types
|
|
31
|
-
|
|
32
|
-
export type PlatformProductGroupEnum = 'PERKS' | 'PLUS' | 'PRO' | 'COINS';
|
|
24
|
+
export type ColorEnum = (typeof COLORS)[number];
|
|
33
25
|
|
|
34
26
|
// Server/API related types
|
|
35
27
|
|
|
36
28
|
export interface ServerErrorObj {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
statusCode: number;
|
|
30
|
+
errorCode: string;
|
|
31
|
+
errorValue?: string;
|
|
32
|
+
iconName?: string;
|
|
33
|
+
title: string;
|
|
34
|
+
message: string;
|
|
43
35
|
}
|
|
44
36
|
|
|
45
37
|
export interface SimpleErrorType {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
iconName?: string;
|
|
39
|
+
title?: string;
|
|
40
|
+
message: string;
|
|
49
41
|
}
|
|
50
42
|
|
|
51
43
|
// Web Socket events
|
|
52
44
|
|
|
53
|
-
export type ResetQueryRuleEnum =
|
|
45
|
+
export type ResetQueryRuleEnum =
|
|
46
|
+
| 'ALWAYS'
|
|
47
|
+
| 'IF_FRAGMENT_NOT_FOUND'
|
|
48
|
+
| 'IF_FRAGMENT_NOT_IN_QUERY'
|
|
49
|
+
| 'IF_FRAGMENT_FOUND'
|
|
50
|
+
| 'NEVER'
|
|
51
|
+
| 'RESET_ONLY';
|
|
54
52
|
export type AppendRuleEnum = 'APPEND_NEW' | 'APPEND_AT_END' | 'APPEND_AT_FRONT';
|
|
55
53
|
|
|
54
|
+
export type ReactiveMessageKindEnum = 'DATA_TABLE' | 'FIELD_DOC' | 'LOG' | 'ORGANIZATION' | 'SHEET';
|
|
55
|
+
|
|
56
|
+
export interface ReactiveMessageObj {
|
|
57
|
+
kind: ReactiveMessageKindEnum;
|
|
58
|
+
identifier?: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
text: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Explicit single-record reads supported by oversized fragment recovery. */
|
|
64
|
+
export interface WSFragmentRecoveryTarget {
|
|
65
|
+
kind: 'AGENT_NOTE' | 'LOG_ENTRY';
|
|
66
|
+
organizationId: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
export interface WSDataUpdateObj {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
id: string;
|
|
71
|
+
aiChatSubmission?: AIChatSubmissionWSObj;
|
|
72
|
+
orchestratorArtifact?: OrchestratorArtifactWSObj; // Sheet, tab, table, form or workflow the orchestrator just changed
|
|
73
|
+
messages?: ReactiveMessageObj[];
|
|
74
|
+
resetQueries?: QueryResetTarget[]; // Structured query reset targets
|
|
75
|
+
resetQueryRule?: ResetQueryRuleEnum; // Defaults to "IF_FRAGMENT_FOUND"
|
|
76
|
+
reactiveFragmentKeys?: string[]; // Fragment keys that are used to trigger reactivity
|
|
77
|
+
authorizationContextChanged?: boolean; // Private memory/disk cache must be discarded and auth reloaded
|
|
78
|
+
fragments?:
|
|
79
|
+
| null
|
|
80
|
+
| ({
|
|
81
|
+
name: string;
|
|
82
|
+
dataId: string;
|
|
83
|
+
sequence?: string;
|
|
84
|
+
sequenceKey?: string;
|
|
85
|
+
recovery?: WSFragmentRecoveryTarget; // Fetch this record before applying; data is only an identity placeholder.
|
|
86
|
+
replaceId?: string; // Use this where client has a temporary ID that will be replaced by the server-side ID later
|
|
87
|
+
appendRule?: AppendRuleEnum | null;
|
|
88
|
+
data: any;
|
|
89
|
+
} | null)[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface AIChatSubmissionWSObj {
|
|
93
|
+
aiChatId: string;
|
|
94
|
+
clientRequestId: string;
|
|
95
|
+
phase: 'RECEIVED';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type OrchestratorArtifactKind = 'SHEET' | 'SHEET_TAB' | 'DATA_TABLE' | 'FIELD_DOC' | 'WORKFLOW';
|
|
99
|
+
export type OrchestratorArtifactAction = 'CREATED' | 'UPDATED' | 'DELETED';
|
|
100
|
+
|
|
101
|
+
/* One sheet, tab, table, form or workflow a Orchestrator tool call committed, sent to the account's watching tabs */
|
|
102
|
+
export interface OrchestratorArtifactWSObj {
|
|
103
|
+
aiChatId: string; // Serialized generic id
|
|
104
|
+
runId: string; // Durable ai_chat_runs id
|
|
105
|
+
callId: string; // Tool call id; the client's idempotency key
|
|
106
|
+
organizationId: string | null; // Serialized controller organization at tool time
|
|
107
|
+
toolName: string;
|
|
108
|
+
kind: OrchestratorArtifactKind;
|
|
109
|
+
action: OrchestratorArtifactAction;
|
|
110
|
+
sheetId?: string | null; // Serialized; SHEET and SHEET_TAB
|
|
111
|
+
sheetTabId?: string | null; // Serialized; SHEET_TAB, and SHEET when one tab is known (e.g. the first tab on create)
|
|
112
|
+
dataTableId?: string | null; // Serialized; DATA_TABLE
|
|
113
|
+
fieldDocId?: string | null; // Serialized; FIELD_DOC
|
|
114
|
+
fieldDocProgramId?: string | null; // Serialized; FIELD_DOC, the program whose page lists the form's documents
|
|
115
|
+
hasDraft?: boolean | null; // FIELD_DOC: whether the form currently has unpublished changes
|
|
116
|
+
draftStateAt?: string | null; // FIELD_DOC: when the server observed hasDraft, independent of the historical tool call time
|
|
117
|
+
workflowId?: string | null; // Serialized; WORKFLOW
|
|
118
|
+
active?: boolean | null; // WORKFLOW: whether new matching logs run it, when known
|
|
119
|
+
title?: string | null; // Sheet title, tab name, table, form or workflow title as stored when the event was built, else the call's
|
|
120
|
+
replayed?: boolean; // The tool result came from a durable receipt replay
|
|
121
|
+
at: string; // ISO timestamp of emission
|
|
71
122
|
}
|
|
72
123
|
|
|
73
124
|
export interface WSAppContextUpdateObj {
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
accountId: string;
|
|
126
|
+
updates: [any, any][];
|
|
76
127
|
}
|
package/src/types/auth.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { OrganizationShortData } from './organization.d.ts';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Auth enums
|
|
5
3
|
*/
|
|
@@ -12,42 +10,68 @@ export type LightModeEnum = 'LIGHT' | 'DARK' | 'SYSTEM';
|
|
|
12
10
|
*/
|
|
13
11
|
|
|
14
12
|
export interface AccountData {
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
id: string;
|
|
14
|
+
deleted: boolean;
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
plus: any; // placeholder for later
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
settings: AccountSettings;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
profile: {
|
|
21
|
+
id: string;
|
|
22
|
+
firstName: string;
|
|
23
|
+
lastName: string;
|
|
24
|
+
photoId: string;
|
|
25
|
+
photoUri: string;
|
|
26
|
+
};
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
email: {
|
|
29
|
+
id: string;
|
|
30
|
+
address: string;
|
|
31
|
+
verified: boolean;
|
|
32
|
+
};
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
phone: {
|
|
35
|
+
id: string;
|
|
36
|
+
number: string;
|
|
37
|
+
verified: boolean;
|
|
38
|
+
};
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
export interface AccountSettings {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
theme: string | null;
|
|
43
|
+
language: string;
|
|
44
|
+
lightMode: LightModeEnum;
|
|
45
|
+
timeZone: string | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface AccountSessionOrganizationAuthorizationData {
|
|
49
|
+
id: string;
|
|
50
|
+
organizationId: string;
|
|
51
|
+
ssoConnectionId?: string | null;
|
|
52
|
+
authorizationMethod: string;
|
|
53
|
+
authorizedAt: string;
|
|
54
|
+
lastActivityAt?: string | null;
|
|
55
|
+
revokedAt?: string | null;
|
|
56
|
+
revokeReason?: string | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface AccountSessionData {
|
|
60
|
+
id: string;
|
|
61
|
+
accountId: string;
|
|
62
|
+
authMethod: string;
|
|
63
|
+
deviceName?: string | null;
|
|
64
|
+
userAgent?: string | null;
|
|
65
|
+
createdIpAddress?: string | null;
|
|
66
|
+
lastIpAddress?: string | null;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
lastActivityAt: string;
|
|
69
|
+
idleExpiresAt: string;
|
|
70
|
+
absoluteExpiresAt: string;
|
|
71
|
+
revokedAt?: string | null;
|
|
72
|
+
revokeReason?: string | null;
|
|
73
|
+
current: boolean;
|
|
74
|
+
organizationAuthorizations: AccountSessionOrganizationAuthorizationData[];
|
|
51
75
|
}
|
|
52
76
|
|
|
53
77
|
/**
|
|
@@ -55,14 +79,16 @@ export interface AccountSettings {
|
|
|
55
79
|
*/
|
|
56
80
|
|
|
57
81
|
export interface AuthenticationData {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
token: string | null;
|
|
83
|
+
sessionBootstrapToken?: string | null;
|
|
84
|
+
cacheAuthorizationEpoch?: string | null;
|
|
85
|
+
timeZone: string | null;
|
|
86
|
+
account: AccountData | null;
|
|
87
|
+
settings: AccountSettings | null;
|
|
88
|
+
primaryOrganizationId: string | null;
|
|
89
|
+
activated: boolean;
|
|
90
|
+
hasPassword: boolean;
|
|
91
|
+
webVersion: string;
|
|
92
|
+
mobileVersion: string;
|
|
93
|
+
alertUpdatesOnMount: boolean;
|
|
68
94
|
}
|
package/src/types/other.d.ts
CHANGED
|
@@ -4,8 +4,15 @@ import { DAY_OF_WEEK, SCHEDULE_FREQUENCY } from '../constants/other.ts';
|
|
|
4
4
|
* Enums
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export type DayOfWeekEnum = typeof DAY_OF_WEEK[number];
|
|
8
|
-
export type ScheduleFrequencyEnum = typeof SCHEDULE_FREQUENCY[number];
|
|
7
|
+
export type DayOfWeekEnum = (typeof DAY_OF_WEEK)[number];
|
|
8
|
+
export type ScheduleFrequencyEnum = (typeof SCHEDULE_FREQUENCY)[number];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Shared acknowledgment returned by optimistic editor mutations.
|
|
12
|
+
*/
|
|
13
|
+
export interface EditVersionPayloadGQL {
|
|
14
|
+
editVersion: number;
|
|
15
|
+
}
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* Address
|
|
@@ -39,13 +46,13 @@ export interface ScheduleObj {
|
|
|
39
46
|
*/
|
|
40
47
|
|
|
41
48
|
export interface LabelAndValue {
|
|
42
|
-
|
|
49
|
+
iconName?: string;
|
|
43
50
|
label: string;
|
|
44
51
|
value: string;
|
|
45
52
|
quantity?: number;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
unit?: string;
|
|
54
|
+
tax?: number;
|
|
55
|
+
note?: string;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
/**
|
package/src/types.d.ts
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
|
|
2
1
|
declare global {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
interface Console {
|
|
3
|
+
dev: (...args: any[]) => void;
|
|
4
|
+
}
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
/** Declaration file generated by dts-gen */
|
|
9
8
|
|
|
10
9
|
declare class NodePolyglot {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
clear(): void;
|
|
10
|
+
constructor(options?: any);
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
clear(): void;
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
extend(morePhrases: any, prefix?: any): void;
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
has(key: any): any;
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
locale(newLocale: any): any;
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
replace(newPhrases: any): void;
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
t(key: any, options?: any): any;
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
unset(morePhrases: any, prefix: any): void;
|
|
28
25
|
|
|
26
|
+
static transformPhrase(phrase: any, substitutions: any, locale: any): any;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
export = NodePolyglot;
|
package/src/utils/account.ts
CHANGED
|
@@ -10,82 +10,88 @@ type PlusGroupEnum = 'NORMAL' | 'PERKS' | 'PLUS' | 'PRO';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export function getLightMode(mode: string, mobileApp: boolean): LightModeValue {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (!mode) {
|
|
14
|
+
return 'LIGHT';
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const index = mobileApp ? 1 : 0;
|
|
18
|
+
const value = Number(mode.charAt(index));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
return (['LIGHT', 'SYSTEM', 'DARK'][value] || 'LIGHT') as LightModeValue;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Update light mode value
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
export function updateLightMode(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
export function updateLightMode(
|
|
28
|
+
mode_: string | undefined,
|
|
29
|
+
newValue: LightModeValue,
|
|
30
|
+
mobileApp: boolean,
|
|
31
|
+
): string {
|
|
32
|
+
const mode = mode_ || '00';
|
|
33
|
+
const index = mobileApp ? 1 : 0;
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
let value = ['LIGHT', 'SYSTEM', 'DARK'].indexOf(newValue);
|
|
36
|
+
if (value === -1) {
|
|
37
|
+
value = 0;
|
|
38
|
+
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
return mode.substring(0, index) + value + mode.substring(index + 1);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
44
|
* Get user's subscription & status
|
|
41
45
|
*/
|
|
42
46
|
|
|
43
|
-
export const getUserSubscription = (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
export const getUserSubscription = (
|
|
48
|
+
plus: any,
|
|
49
|
+
): {
|
|
50
|
+
name: string | null;
|
|
51
|
+
group: PlusGroupEnum;
|
|
52
|
+
cancelled: boolean;
|
|
53
|
+
expired: boolean;
|
|
54
|
+
expireAt: Date | null;
|
|
49
55
|
} => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if (!plus) {
|
|
57
|
+
return {
|
|
58
|
+
name: null,
|
|
59
|
+
group: 'NORMAL',
|
|
60
|
+
cancelled: false,
|
|
61
|
+
expired: false,
|
|
62
|
+
expireAt: null,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
const expired = new Date(plus.expireAt).getTime() < Date.now();
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
let group: PlusGroupEnum = 'NORMAL';
|
|
69
|
+
if (!expired) {
|
|
70
|
+
switch (plus.type) {
|
|
71
|
+
case 'kajiwoto_plus':
|
|
72
|
+
case 'kajiwoto_plus_yearly':
|
|
73
|
+
case 'big_planet_plus':
|
|
74
|
+
case 'big_planet_plus_yearly':
|
|
75
|
+
group = 'PLUS';
|
|
76
|
+
break;
|
|
77
|
+
case 'kajiwoto_pro':
|
|
78
|
+
case 'kajiwoto_pro_yearly':
|
|
79
|
+
case 'big_planet_pro':
|
|
80
|
+
case 'big_planet_pro_yearly':
|
|
81
|
+
group = 'PRO';
|
|
82
|
+
break;
|
|
83
|
+
case 'perks':
|
|
84
|
+
group = 'PERKS';
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
}
|
|
88
|
+
}
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
return {
|
|
91
|
+
name: plus.type,
|
|
92
|
+
group,
|
|
93
|
+
cancelled: !!plus.cancelled,
|
|
94
|
+
expired,
|
|
95
|
+
expireAt: plus.expireAt,
|
|
96
|
+
};
|
|
91
97
|
};
|