@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.
Files changed (79) hide show
  1. package/package.json +57 -45
  2. package/src/constants/agent.ts +51 -41
  3. package/src/constants/app.ts +34 -13
  4. package/src/constants/emoji.ts +9144 -8936
  5. package/src/constants/other.ts +1 -5
  6. package/src/constants/user.ts +16 -25
  7. package/src/constants/wsActions.ts +27 -0
  8. package/src/i18n/account.ts +129 -107
  9. package/src/i18n/agent.ts +331 -73
  10. package/src/i18n/agentToolBusiness.ts +196 -0
  11. package/src/i18n/agentToolGrid.ts +137 -0
  12. package/src/i18n/agentToolWorkflow.ts +101 -0
  13. package/src/i18n/agent_note.ts +109 -0
  14. package/src/i18n/app.ts +107 -91
  15. package/src/i18n/auth.ts +117 -102
  16. package/src/i18n/billing.ts +5 -92
  17. package/src/i18n/c.ts +907 -0
  18. package/src/i18n/campaign.ts +919 -0
  19. package/src/i18n/country.ts +248 -248
  20. package/src/i18n/datetime.ts +32 -26
  21. package/src/i18n/editor.ts +58 -0
  22. package/src/i18n/error.ts +577 -192
  23. package/src/i18n/field_doc_editor.ts +21 -0
  24. package/src/i18n/field_doc_programs.ts +52 -0
  25. package/src/i18n/field_docs.ts +190 -0
  26. package/src/i18n/index.ts +42 -19
  27. package/src/i18n/log.ts +272 -238
  28. package/src/i18n/memory.ts +53 -0
  29. package/src/i18n/message.ts +3 -4
  30. package/src/i18n/note.ts +19 -0
  31. package/src/i18n/org.ts +164 -109
  32. package/src/i18n/schedule.ts +209 -0
  33. package/src/i18n/sheet.ts +333 -4
  34. package/src/i18n/sheet_formula.ts +165 -0
  35. package/src/i18n/workflow.ts +109 -23
  36. package/src/main.ts +68 -64
  37. package/src/platform.ts +90 -49
  38. package/src/types/ai.d.ts +52 -23
  39. package/src/types/app.d.ts +95 -44
  40. package/src/types/auth.d.ts +66 -40
  41. package/src/types/console.d.ts +3 -0
  42. package/src/types/other.d.ts +13 -6
  43. package/src/types.d.ts +12 -14
  44. package/src/utils/account.ts +64 -58
  45. package/src/utils/api.ts +326 -77
  46. package/src/utils/authSession.ts +24 -0
  47. package/src/utils/clientIP.ts +213 -0
  48. package/src/utils/color.ts +279 -0
  49. package/src/utils/cron.ts +49 -18
  50. package/src/utils/csv.ts +19 -0
  51. package/src/utils/datetime.ts +445 -117
  52. package/src/utils/deferredSave.ts +89 -0
  53. package/src/utils/email.ts +50 -0
  54. package/src/utils/emoji.ts +107 -84
  55. package/src/utils/expression.helpers.ts +470 -0
  56. package/src/utils/expression.test.ts +793 -0
  57. package/src/utils/expression.ts +2261 -0
  58. package/src/utils/interval.ts +80 -0
  59. package/src/utils/language.ts +9 -0
  60. package/src/utils/logic.ts +141 -121
  61. package/src/utils/managedSession.ts +34 -0
  62. package/src/utils/managedSessionBff.test.ts +60 -0
  63. package/src/utils/managedSessionBff.ts +117 -0
  64. package/src/utils/number.ts +85 -38
  65. package/src/utils/object.ts +227 -30
  66. package/src/utils/promise.ts +98 -0
  67. package/src/utils/queryReset.ts +266 -0
  68. package/src/utils/recurringTask.ts +60 -0
  69. package/src/utils/schema.ts +293 -0
  70. package/src/utils/string.test.ts +205 -208
  71. package/src/utils/string.ts +426 -463
  72. package/src/utils/timeZone.ts +309 -851
  73. package/src/utils/url_client.ts +145 -72
  74. package/tsconfig.json +10 -10
  75. package/src/constants/billing.ts +0 -146
  76. package/src/i18n/form.ts +0 -376
  77. package/src/i18n/product.ts +0 -76
  78. package/src/types/form.d.ts +0 -97
  79. 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 AIChatMessageType = 'MESSAGE' | 'SMS' | 'FUNCTION_CALL'| 'FUNCTION_CALL_OUTPUT';
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
- | 'AI_EVENT_UNKNOWN_ERR'
10
- | 'AI_EVENT_DEVELOPER_ERR'
11
- | 'AI_EVENT_NO_ACCESS'
12
- | 'AI_COULD_NOT_RESOLVE'
13
- | 'AI_CONTEXT_ERR'
14
- | 'AI_ORG_ACL_FAILED'
15
- | 'SETUP_INCOMPLETE_ORG'
16
- | 'MISSING_API_KEY'
17
- | 'LLM_PROVIDER_NOT_FOUND'
18
- | 'LLM_SERVICE_ERR'
19
- | 'MODERATION_MISSING'
20
- | 'MODERATION_SERVICE_ERR'
21
- | 'UNKNOWN_LLM_ERR'
22
- | 'TWILIO_API_ERR'
23
- | 'UNFINISHED_LOGIC';
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
- id: string;
29
- calDate: string;
30
- summary: string;
31
- archivedAt: string | null;
32
- createdAt: string;
33
- updatedAt: string;
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
  }
@@ -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
- containerClassName: string;
7
- saveCounter: number;
8
- saving: boolean;
9
- hasChanges: boolean;
10
- openModalPopUp: (opts: any) => void;
11
- onChangeDiff: (diff: boolean) => void;
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
- user: any;
16
- editUser: (obj: object) => void;
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
- statusCode: number;
38
- errorCode: string;
39
- errorValue?: string;
40
- iconName?: string;
41
- title: string;
42
- message: string;
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
- iconName?: string;
47
- title?: string;
48
- message: string;
38
+ iconName?: string;
39
+ title?: string;
40
+ message: string;
49
41
  }
50
42
 
51
43
  // Web Socket events
52
44
 
53
- export type ResetQueryRuleEnum = 'ALWAYS' | 'IF_FRAGMENT_NOT_FOUND' | 'IF_FRAGMENT_FOUND' | 'NEVER' | 'RESET_ONLY';
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
- id: string;
58
- route: string[]; // First items in the array have priority (Different org operations may not allow the actions handled by other org operations)
59
- message?: string | null; // If null, nothing will be visible to the client.
60
- messageType: 'NORMAL' | 'SUCCESS' | 'ERROR';
61
- resetQueryKeys?: string[]; // List of query keys including {variablesKey}
62
- resetQueryRule?: ResetQueryRuleEnum; // Defaults to "IF_FRAGMENT_FOUND"
63
- reactiveFragmentKeys?: string[]; // Fragment keys that are used to trigger reactivity
64
- fragments?: null | ({
65
- name: string;
66
- dataId: string;
67
- replaceId?: string; // Use this where client has a temporary ID that will be replaced by the server-side ID later
68
- appendRule?: AppendRuleEnum | null;
69
- data: any;
70
- } | null)[];
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
- accountId: string;
75
- updates: [any, any][];
125
+ accountId: string;
126
+ updates: [any, any][];
76
127
  }
@@ -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
- id: string;
16
- deleted: boolean;
13
+ id: string;
14
+ deleted: boolean;
17
15
 
18
- plus: any; // placeholder for later
16
+ plus: any; // placeholder for later
19
17
 
20
- settings: AccountSettings;
18
+ settings: AccountSettings;
21
19
 
22
- profile: {
23
- id: string;
24
- firstName: string;
25
- lastName: string;
26
- photoId: string;
27
- photoUri: string;
28
- };
20
+ profile: {
21
+ id: string;
22
+ firstName: string;
23
+ lastName: string;
24
+ photoId: string;
25
+ photoUri: string;
26
+ };
29
27
 
30
- email: {
31
- id: string;
32
- address: string;
33
- verified: boolean;
34
- };
28
+ email: {
29
+ id: string;
30
+ address: string;
31
+ verified: boolean;
32
+ };
35
33
 
36
- phone: {
37
- id: string;
38
- number: string;
39
- verified: boolean;
40
- };
34
+ phone: {
35
+ id: string;
36
+ number: string;
37
+ verified: boolean;
38
+ };
41
39
  }
42
40
 
43
41
  export interface AccountSettings {
44
- theme: string | null;
45
- language: string;
46
- lightMode: LightModeEnum;
47
- timeZone: string | null;
48
- showSelfAvatar: boolean;
49
- isBubbleOther: boolean;
50
- showOtherAvatar: boolean;
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
- token: string | null;
59
- timeZone: string | null;
60
- account: AccountData | null;
61
- settings: AccountSettings | null;
62
- primaryOrganizationId: string | null;
63
- activated: boolean;
64
- hasPassword: boolean;
65
- webVersion: string;
66
- mobileVersion: string;
67
- alertUpdatesOnMount: boolean;
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
  }
@@ -0,0 +1,3 @@
1
+ interface Console {
2
+ dev: (...args: any[]) => void;
3
+ }
@@ -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
- iconName?: String
49
+ iconName?: string;
43
50
  label: string;
44
51
  value: string;
45
52
  quantity?: number;
46
- unit?: string;
47
- tax?: number
48
- note?: string;
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
- interface Console {
4
- dev: (...args: any[]) => void;
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
- constructor(options?: any);
12
-
13
- clear(): void;
10
+ constructor(options?: any);
14
11
 
15
- extend(morePhrases: any, prefix?: any): void;
12
+ clear(): void;
16
13
 
17
- has(key: any): any;
14
+ extend(morePhrases: any, prefix?: any): void;
18
15
 
19
- locale(newLocale: any): any;
16
+ has(key: any): any;
20
17
 
21
- replace(newPhrases: any): void;
18
+ locale(newLocale: any): any;
22
19
 
23
- t(key: any, options?: any): any;
20
+ replace(newPhrases: any): void;
24
21
 
25
- unset(morePhrases: any, prefix: any): void;
22
+ t(key: any, options?: any): any;
26
23
 
27
- static transformPhrase(phrase: any, substitutions: any, locale: any): any;
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;
@@ -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
- if (!mode) {
14
- return 'LIGHT';
15
- }
13
+ if (!mode) {
14
+ return 'LIGHT';
15
+ }
16
16
 
17
- const index = mobileApp ? 1 : 0;
18
- const value = Number(mode.charAt(index));
17
+ const index = mobileApp ? 1 : 0;
18
+ const value = Number(mode.charAt(index));
19
19
 
20
- return (['LIGHT', 'SYSTEM', 'DARK'][value] || 'LIGHT') as LightModeValue;
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(mode_: string | undefined, newValue: LightModeValue, mobileApp: boolean): string {
28
- const mode = mode_ || '00';
29
- const index = mobileApp ? 1 : 0;
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
- let value = ['LIGHT', 'SYSTEM', 'DARK'].indexOf(newValue);
32
- if (value === -1) {
33
- value = 0;
34
- }
35
+ let value = ['LIGHT', 'SYSTEM', 'DARK'].indexOf(newValue);
36
+ if (value === -1) {
37
+ value = 0;
38
+ }
35
39
 
36
- return mode.substring(0, index) + value + mode.substring(index + 1);
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 = (plus: any): {
44
- name: string | null;
45
- group: PlusGroupEnum;
46
- cancelled: boolean;
47
- expired: boolean;
48
- expireAt: Date | null;
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
- if (!plus) {
51
- return {
52
- name: null,
53
- group: 'NORMAL',
54
- cancelled: false,
55
- expired: false,
56
- expireAt: null,
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
- const expired = (new Date(plus.expireAt)).getTime() < Date.now();
66
+ const expired = new Date(plus.expireAt).getTime() < Date.now();
61
67
 
62
- let group: PlusGroupEnum = 'NORMAL';
63
- if (!expired) {
64
- switch (plus.type) {
65
- case 'kajiwoto_plus':
66
- case 'kajiwoto_plus_yearly':
67
- case 'big_planet_plus':
68
- case 'big_planet_plus_yearly':
69
- group = 'PLUS';
70
- break;
71
- case 'kajiwoto_pro':
72
- case 'kajiwoto_pro_yearly':
73
- case 'big_planet_pro':
74
- case 'big_planet_pro_yearly':
75
- group = 'PRO';
76
- break;
77
- case 'perks':
78
- group = 'PERKS';
79
- break;
80
- default:
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
- return {
85
- name: plus.type,
86
- group,
87
- cancelled: !!plus.cancelled,
88
- expired,
89
- expireAt: plus.expireAt,
90
- };
90
+ return {
91
+ name: plus.type,
92
+ group,
93
+ cancelled: !!plus.cancelled,
94
+ expired,
95
+ expireAt: plus.expireAt,
96
+ };
91
97
  };