@jsb188/app 1.0.4 → 1.1.2
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 -37
- package/src/constants/agent.ts +74 -0
- package/src/constants/app.ts +389 -0
- package/src/constants/emoji.ts +9153 -0
- package/src/constants/other.ts +13 -0
- package/src/constants/user.ts +27 -0
- package/src/constants/wsActions.ts +49 -0
- package/src/i18n/account.ts +139 -0
- package/src/i18n/agent.ts +397 -0
- 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 +124 -0
- package/src/i18n/auth.ts +128 -0
- package/src/i18n/billing.ts +7 -0
- package/src/i18n/c.ts +907 -0
- package/src/i18n/campaign.ts +919 -0
- package/src/i18n/country.ts +249 -0
- package/src/i18n/datetime.ts +66 -0
- package/src/i18n/editor.ts +58 -0
- package/src/i18n/error.ts +579 -0
- 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 +64 -0
- package/src/i18n/log.ts +566 -0
- package/src/i18n/memory.ts +59 -0
- package/src/i18n/message.ts +13 -0
- package/src/i18n/note.ts +19 -0
- package/src/i18n/org.ts +306 -0
- package/src/i18n/schedule.ts +209 -0
- package/src/i18n/sheet.ts +339 -0
- package/src/i18n/sheet_formula.ts +165 -0
- package/src/i18n/workflow.ts +111 -0
- package/src/main.ts +89 -0
- package/src/platform.ts +166 -0
- package/src/types/ai.d.ts +63 -0
- package/src/types/app.d.ts +127 -0
- package/src/types/auth.d.ts +94 -0
- package/src/types/console.d.ts +3 -0
- package/src/types/node-polyglot.d.ts +23 -0
- package/src/types/other.d.ts +66 -0
- package/src/types.d.ts +29 -0
- package/src/utils/account.ts +97 -0
- package/src/utils/api.ts +358 -0
- 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 +310 -0
- package/src/utils/csv.ts +19 -0
- package/src/utils/datetime.ts +1394 -0
- package/src/utils/deferredSave.ts +89 -0
- package/src/utils/email.ts +39 -0
- package/src/utils/emoji.ts +174 -0
- 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 +299 -0
- 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 +338 -0
- package/src/utils/object.ts +916 -0
- 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 +278 -0
- package/src/utils/string.ts +709 -0
- package/src/utils/timeZone.ts +2048 -0
- package/src/utils/url_client.ts +206 -0
- package/tsconfig.json +12 -0
- package/constants/app.ts +0 -47
- package/constants/billing.ts +0 -146
- package/constants/emoji.ts +0 -8945
- package/constants/user.ts +0 -36
- package/constants/ws.ts +0 -47
- package/i18n/app.ts +0 -99
- package/i18n/auth.ts +0 -57
- package/i18n/billing.ts +0 -94
- package/i18n/datetime.ts +0 -22
- package/i18n/error.ts +0 -138
- package/i18n/form.ts +0 -73
- package/i18n/index.ts +0 -6
- package/i18n/user.ts +0 -98
- package/main.ts +0 -62
- package/types/app.d.ts +0 -46
- package/types/datetime.d.ts +0 -10
- package/types/form.d.ts +0 -56
- package/types/user.d.ts +0 -52
- package/types.d.ts +0 -23
- package/utils/api.ts +0 -99
- package/utils/billing.ts +0 -134
- package/utils/datetime.ts +0 -358
- package/utils/emoji.ts +0 -151
- package/utils/logic.ts +0 -115
- package/utils/number.ts +0 -115
- package/utils/object.ts +0 -367
- package/utils/string.ts +0 -211
- package/utils/url_client.ts +0 -138
- package/utils/user.ts +0 -273
package/main.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import i18n from './i18n/';
|
|
2
|
-
import app from './i18n/app';
|
|
3
|
-
import auth from './i18n/auth';
|
|
4
|
-
import billing from './i18n/billing';
|
|
5
|
-
import datetime from './i18n/datetime';
|
|
6
|
-
import error from './i18n/error';
|
|
7
|
-
import form from './i18n/form';
|
|
8
|
-
import user from './i18n/user';
|
|
9
|
-
|
|
10
|
-
let ENV: Record<string, string> = {};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Extend i18n with app specific texts
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
export function configI18n(texts: Record<string, any>) {
|
|
17
|
-
|
|
18
|
-
// Locale support for later
|
|
19
|
-
const locale = 'en';
|
|
20
|
-
|
|
21
|
-
const extendedObj = {
|
|
22
|
-
app: app[locale],
|
|
23
|
-
auth: auth[locale],
|
|
24
|
-
billing: billing[locale],
|
|
25
|
-
datetime: datetime[locale],
|
|
26
|
-
error: error[locale],
|
|
27
|
-
form: form[locale],
|
|
28
|
-
user: user[locale],
|
|
29
|
-
} as Record<string, any>;
|
|
30
|
-
|
|
31
|
-
for (const key in texts) {
|
|
32
|
-
const obj = texts[key][locale];
|
|
33
|
-
|
|
34
|
-
if (extendedObj[key]) {
|
|
35
|
-
extendedObj[key] = {
|
|
36
|
-
...extendedObj[key],
|
|
37
|
-
...obj
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
extendedObj[key] = obj;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
i18n.extend(extendedObj);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Register environment variables so the package may use it
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
export function registerENV(env: Record<string, string>) {
|
|
52
|
-
// Do not use process.env; because this package is used in client + server
|
|
53
|
-
ENV = { ...env };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get environment variables
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
export function getENVVariable(namespace: string): string | undefined {
|
|
61
|
-
return ENV[namespace];
|
|
62
|
-
}
|
package/types/app.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Modal; App settings
|
|
3
|
-
|
|
4
|
-
export interface EditIfaceModalProps {
|
|
5
|
-
containerClassName: string;
|
|
6
|
-
saveCounter: number;
|
|
7
|
-
saving: boolean;
|
|
8
|
-
hasChanges: boolean;
|
|
9
|
-
openModalPopUp: (opts: any) => void;
|
|
10
|
-
onChangeDiff: (diff: boolean) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface EditUserModalProps extends EditIfaceModalProps {
|
|
14
|
-
user: any;
|
|
15
|
-
editUser: (obj: object) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface EditUserPlusModalProps extends EditIfaceModalProps {
|
|
19
|
-
user: any;
|
|
20
|
-
editUserPlus: (obj: object) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// App types
|
|
24
|
-
|
|
25
|
-
export type DarkOrLightEnum = 'light' | 'dark';
|
|
26
|
-
|
|
27
|
-
// Stripe types
|
|
28
|
-
|
|
29
|
-
export type PlatformProductGroupEnum = 'PERKS' | 'PLUS' | 'PRO' | 'COINS';
|
|
30
|
-
|
|
31
|
-
// Server/API related types
|
|
32
|
-
|
|
33
|
-
export interface ServerErrorObj {
|
|
34
|
-
statusCode: number;
|
|
35
|
-
errorCode: string;
|
|
36
|
-
errorValue?: string;
|
|
37
|
-
iconName?: string;
|
|
38
|
-
title: string;
|
|
39
|
-
message: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface SimpleErrorType {
|
|
43
|
-
iconName?: string;
|
|
44
|
-
title?: string;
|
|
45
|
-
message: string;
|
|
46
|
-
}
|
package/types/datetime.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Date types
|
|
3
|
-
|
|
4
|
-
export type DatePeriodEnum = 'UPCOMING' | 'TOMORROW' | 'TODAY' | 'YESTERDAY' | 'THIS_WEEK' | 'THIS_MONTH' | 'LAST_WEEK' | 'LAST_MONTH' | 'OLDER';
|
|
5
|
-
|
|
6
|
-
export interface DatePeriodObj {
|
|
7
|
-
datePeriod: DatePeriodEnum;
|
|
8
|
-
date: Date;
|
|
9
|
-
item: any;
|
|
10
|
-
}
|
package/types/form.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Types; form schema
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
interface SchemaItemSetter {
|
|
7
|
-
setter?: (currentData?: any, dataForSchema?: any) => any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface FormItemSchemaObj {
|
|
11
|
-
__type: 'group' | 'input' | 'password' | 'textarea' | 'select' | string;
|
|
12
|
-
autoFocus?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
hidden?: boolean | ((dataForSchema: any) => boolean);
|
|
15
|
-
locked?: boolean | ((dataForSchema: any) => boolean);
|
|
16
|
-
labelClassName?: string;
|
|
17
|
-
listenToInput?: boolean;
|
|
18
|
-
value?: any;
|
|
19
|
-
item: Record<string, any> & SchemaItemSetter;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface SchemaRule {
|
|
23
|
-
for: string;
|
|
24
|
-
rule: (value: any, formValues: any) => boolean;
|
|
25
|
-
error: any;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export interface FormSchemaObj {
|
|
29
|
-
listData: FormItemSchemaObj[];
|
|
30
|
-
rules?: SchemaRule[];
|
|
31
|
-
isButtonDisabled?: (formValues: any) => boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Types; form items
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
interface FormGroupType {
|
|
39
|
-
id?: string;
|
|
40
|
-
name: string;
|
|
41
|
-
label?: string;
|
|
42
|
-
value: string | number | null;
|
|
43
|
-
items: Array<FormItemIfaceObj>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface FormItemIfaceObj extends FormItemSchemaObj {
|
|
47
|
-
name: string;
|
|
48
|
-
hidden?: boolean | ((dataForSchema: any) => boolean);
|
|
49
|
-
locked?: boolean | ((dataForSchema: any) => boolean);
|
|
50
|
-
formValues: any;
|
|
51
|
-
setFormValues: (values: any) => void;
|
|
52
|
-
onInput?: (e: React.FormEvent, name: string) => void;
|
|
53
|
-
onKeyDown?: (e: React.KeyboardEvent, name: string) => void;
|
|
54
|
-
onSubmit?: (e: React.MouseEvent, name: string) => void;
|
|
55
|
-
onChange?: (e: React.ChangeEvent, name: string) => void;
|
|
56
|
-
}
|
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
|
-
}
|
package/types.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** Declaration file generated by dts-gen */
|
|
2
|
-
|
|
3
|
-
declare class NodePolyglot {
|
|
4
|
-
constructor(options?: any);
|
|
5
|
-
|
|
6
|
-
clear(): void;
|
|
7
|
-
|
|
8
|
-
extend(morePhrases: any, prefix?: any): void;
|
|
9
|
-
|
|
10
|
-
has(key: any): any;
|
|
11
|
-
|
|
12
|
-
locale(newLocale: any): any;
|
|
13
|
-
|
|
14
|
-
replace(newPhrases: any): void;
|
|
15
|
-
|
|
16
|
-
t(key: any, options?: any): any;
|
|
17
|
-
|
|
18
|
-
unset(morePhrases: any, prefix: any): void;
|
|
19
|
-
|
|
20
|
-
static transformPhrase(phrase: any, substitutions: any, locale: any): any;
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
export = NodePolyglot;
|
package/utils/api.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import i18n from '../i18n/';
|
|
2
|
-
import { getENVVariable } from '../main';
|
|
3
|
-
import type { ServerErrorObj } from '../types/app.d';
|
|
4
|
-
|
|
5
|
-
let AUTH_TOKEN: string | null = null;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Global; save auth token to memory
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export function setAuthToken(token: string | null) {
|
|
12
|
-
if (getENVVariable('IS_BROWSER')) {
|
|
13
|
-
// Only set auth token if it's browser; we don't want to share it across users
|
|
14
|
-
AUTH_TOKEN = token || null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Global; get auth token for all API middleware use
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
export function getAuthToken(): string | null {
|
|
23
|
-
return getENVVariable('IS_BROWSER') ? AUTH_TOKEN : null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Helper; check if i18n exists for this error
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
function i18nErrCodeExists(errorCode: string): boolean {
|
|
31
|
-
return !!(i18n.has(`error.${errorCode}`) ||
|
|
32
|
-
i18n.has(`error.${errorCode}_other`));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Helper; normalize all errors from server
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
export function normalizeServerError(error?: any): ServerErrorObj {
|
|
40
|
-
let statusCode = 500;
|
|
41
|
-
let errorCode;
|
|
42
|
-
let errorValue;
|
|
43
|
-
let iconName;
|
|
44
|
-
let message;
|
|
45
|
-
|
|
46
|
-
if (!error || error instanceof Error) {
|
|
47
|
-
if (error?.message === 'Failed to fetch') {
|
|
48
|
-
errorCode = 'network_error';
|
|
49
|
-
iconName = 'wifi-off';
|
|
50
|
-
message = i18n.t('error.network_error');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!errorCode) {
|
|
55
|
-
if (error?.errors?.length) {
|
|
56
|
-
const loggedError = error.errors.find((gErr: ServerErrorObj) =>
|
|
57
|
-
gErr.errorCode &&
|
|
58
|
-
i18nErrCodeExists(gErr.errorCode)
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
if (loggedError) {
|
|
62
|
-
statusCode = loggedError.statusCode;
|
|
63
|
-
errorCode = loggedError.errorCode;
|
|
64
|
-
errorValue = loggedError.variableWord;
|
|
65
|
-
} else {
|
|
66
|
-
statusCode = error.errors[0].statusCode;
|
|
67
|
-
errorCode = error.errors[0].errorCode;
|
|
68
|
-
errorValue = error.errors[0].variableWord;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!message) {
|
|
74
|
-
if (i18nErrCodeExists(errorCode)) {
|
|
75
|
-
message = i18n.t(`error.${errorCode}`, { value: errorValue });
|
|
76
|
-
} else {
|
|
77
|
-
message = i18n.t('error.unknown_error');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
getENVVariable('NODE_ENV') === 'development' &&
|
|
83
|
-
message === i18n.t('error.unknown_error')
|
|
84
|
-
) {
|
|
85
|
-
// Log for development so I can see what went wrong
|
|
86
|
-
console.warn(error);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const title = i18n.has(`error.${errorCode}_title`) ? i18n.t(`error.${errorCode}_title`) : i18n.t('error.error');
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
statusCode,
|
|
93
|
-
errorCode,
|
|
94
|
-
errorValue,
|
|
95
|
-
iconName,
|
|
96
|
-
title,
|
|
97
|
-
message,
|
|
98
|
-
};
|
|
99
|
-
}
|
package/utils/billing.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { SUBSCRIPTION_CATALOG, SUBSCRIPTION_CATALOG_TEST } from '../constants/billing';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Types
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
type SubscriptionCatalogItem = {
|
|
8
|
-
group: string;
|
|
9
|
-
notReady: boolean;
|
|
10
|
-
priceLabel: string | null;
|
|
11
|
-
startingPrice: number;
|
|
12
|
-
currency: string;
|
|
13
|
-
recurringInterval: string;
|
|
14
|
-
recurringIntervalCount: number;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type SubscriptionPricingOption = {
|
|
18
|
-
id: string;
|
|
19
|
-
group: string;
|
|
20
|
-
notReady: boolean;
|
|
21
|
-
priceLabel: string;
|
|
22
|
-
price: number;
|
|
23
|
-
currency: string;
|
|
24
|
-
recurringInterval: string;
|
|
25
|
-
recurringIntervalCount: number;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get development or production catalog
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
function getSubscriptionCatalog(isDev = false) {
|
|
33
|
-
return isDev ? SUBSCRIPTION_CATALOG_TEST : SUBSCRIPTION_CATALOG;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get list of subscription catalogs
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
export function getPlatformSubscriptionCatalog(platformProducts?: any[], isDev?: boolean): SubscriptionCatalogItem[] {
|
|
41
|
-
|
|
42
|
-
return getSubscriptionCatalog(isDev).map((sub) => {
|
|
43
|
-
const [groupName, stripeProductId, stripePriceId] = sub;
|
|
44
|
-
const product = platformProducts?.find((pr: any) => pr.id === stripeProductId);
|
|
45
|
-
const startingPrice = product?.prices?.find((pc: any) => pc.id === stripePriceId);
|
|
46
|
-
|
|
47
|
-
if (!startingPrice) {
|
|
48
|
-
// Data is not ready; or the Stripe API Key used by the server is _not_ the live key
|
|
49
|
-
return {
|
|
50
|
-
group: groupName,
|
|
51
|
-
notReady: true,
|
|
52
|
-
priceLabel: null,
|
|
53
|
-
startingPrice: 0,
|
|
54
|
-
currency: 'USD',
|
|
55
|
-
recurringInterval: 'month',
|
|
56
|
-
recurringIntervalCount: 1
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Add locale here later
|
|
61
|
-
const locale = undefined;
|
|
62
|
-
|
|
63
|
-
const priceLabel = (
|
|
64
|
-
startingPrice.unitAmount / 100
|
|
65
|
-
).toLocaleString(locale, {
|
|
66
|
-
style: 'currency',
|
|
67
|
-
currency: startingPrice.currency,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
group: groupName,
|
|
72
|
-
notReady: false,
|
|
73
|
-
priceLabel,
|
|
74
|
-
startingPrice: startingPrice.unitAmount,
|
|
75
|
-
currency: startingPrice.currency,
|
|
76
|
-
recurringInterval: startingPrice.recurringInterval,
|
|
77
|
-
recurringIntervalCount: startingPrice.recurringIntervalCount,
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Get list of subscription options for each tier
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
export function getPlatformSubscriptionPricingOptions(
|
|
88
|
-
platformProducts?: any[],
|
|
89
|
-
subGroup?: 'PERKS' | 'PLUS' | 'PRO' | 'COINS',
|
|
90
|
-
isDev?: boolean
|
|
91
|
-
): SubscriptionPricingOption[] {
|
|
92
|
-
|
|
93
|
-
const catalogItem = getSubscriptionCatalog(isDev).find((item: any) => item[0] === subGroup);
|
|
94
|
-
if (!catalogItem) {
|
|
95
|
-
console.warn('Unknown subscription group: ' + subGroup);
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const [, stripeProductId] = catalogItem;
|
|
100
|
-
const product = platformProducts?.find((pr: any) => pr.id === stripeProductId);
|
|
101
|
-
if (!product) {
|
|
102
|
-
if (platformProducts) {
|
|
103
|
-
console.warn('Platform product not found for: ' + stripeProductId);
|
|
104
|
-
}
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const pricingList = product.prices
|
|
109
|
-
.filter((pc: any) => pc.productGroup === subGroup)
|
|
110
|
-
.sort((pc: any) => pc.recurringInterval === 'year' ? -1 : 1);
|
|
111
|
-
|
|
112
|
-
return pricingList.map((pc: any) => {
|
|
113
|
-
// Add locale here later
|
|
114
|
-
const locale = undefined;
|
|
115
|
-
|
|
116
|
-
const priceLabel = (
|
|
117
|
-
pc.unitAmount / 100
|
|
118
|
-
).toLocaleString(locale, {
|
|
119
|
-
style: 'currency',
|
|
120
|
-
currency: pc.currency,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
id: pc.id,
|
|
125
|
-
group: pc.productGroup,
|
|
126
|
-
notReady: false,
|
|
127
|
-
priceLabel,
|
|
128
|
-
price: pc.unitAmount,
|
|
129
|
-
currency: pc.currency,
|
|
130
|
-
recurringInterval: pc.recurringInterval,
|
|
131
|
-
recurringIntervalCount: pc.recurringIntervalCount,
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
}
|