@jsb188/app 1.1.1 → 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 -42
- 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/{utils → src/utils}/timeZone.ts +531 -852
- 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/journal.ts +0 -74
- package/constants/user.ts +0 -36
- package/constants/ws.ts +0 -47
- package/i18n/app.ts +0 -101
- package/i18n/auth.ts +0 -63
- package/i18n/billing.ts +0 -94
- package/i18n/datetime.ts +0 -21
- package/i18n/error.ts +0 -143
- package/i18n/form.ts +0 -74
- package/i18n/index.ts +0 -5
- package/i18n/user.ts +0 -101
- package/main.ts +0 -94
- package/platform.ts +0 -125
- package/types/ai.d.ts +0 -30
- package/types/app.d.ts +0 -48
- package/types/auth.d.ts +0 -63
- package/types/form.d.ts +0 -56
- package/types/journal.d.ts +0 -24
- package/types/organization.d.ts +0 -38
- package/types/user.d.ts +0 -52
- package/types.d.ts +0 -31
- package/utils/api.ts +0 -99
- package/utils/billing.ts +0 -134
- package/utils/datetime.ts +0 -542
- package/utils/emoji.ts +0 -151
- package/utils/journal.ts +0 -17
- package/utils/logic.ts +0 -118
- package/utils/number.ts +0 -139
- package/utils/object.ts +0 -425
- package/utils/string.ts +0 -323
- package/utils/url_client.ts +0 -138
- package/utils/user.ts +0 -273
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
|
-
}
|