gambling-bot-shared 0.1.46 → 0.1.50
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/dist/constants/commonTimezones.d.ts +4 -0
- package/dist/constants/commonTimezones.js +33 -0
- package/dist/constants/defaultGlobalSettings.d.ts +20 -0
- package/dist/constants/defaultGlobalSettings.js +20 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/mongoose/guildConfiguration.schema.d.ts +9 -0
- package/dist/mongoose/guildConfiguration.schema.js +24 -0
- package/dist/schemas/forms.d.ts +46 -0
- package/dist/schemas/forms.js +24 -1
- package/dist/types/guildConfiguration.d.ts +3 -0
- package/dist/utils/formatters.d.ts +5 -0
- package/dist/utils/formatters.js +17 -1
- package/dist/utils/globalSettings.d.ts +6 -0
- package/dist/utils/globalSettings.js +50 -0
- package/dist/utils/guildTimezone.d.ts +6 -0
- package/dist/utils/guildTimezone.js +25 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/normalizeGlobalSettings.d.ts +2 -0
- package/dist/utils/normalizeGlobalSettings.js +46 -0
- package/package.json +3 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Curated IANA zones for admin selects (v1). */
|
|
2
|
+
export declare const COMMON_TIMEZONES: readonly ["UTC", "Europe/London", "Europe/Paris", "Europe/Berlin", "Europe/Prague", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", "America/Toronto", "America/Sao_Paulo", "America/Mexico_City", "Asia/Dubai", "Asia/Kolkata", "Asia/Bangkok", "Asia/Singapore", "Asia/Hong_Kong", "Asia/Tokyo", "Asia/Seoul", "Australia/Sydney", "Australia/Melbourne", "Pacific/Auckland"];
|
|
3
|
+
export type CommonTimezone = (typeof COMMON_TIMEZONES)[number];
|
|
4
|
+
export declare const isCommonTimezone: (value: string) => value is CommonTimezone;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCommonTimezone = exports.COMMON_TIMEZONES = void 0;
|
|
4
|
+
/** Curated IANA zones for admin selects (v1). */
|
|
5
|
+
exports.COMMON_TIMEZONES = [
|
|
6
|
+
'UTC',
|
|
7
|
+
'Europe/London',
|
|
8
|
+
'Europe/Paris',
|
|
9
|
+
'Europe/Berlin',
|
|
10
|
+
'Europe/Prague',
|
|
11
|
+
'Europe/Warsaw',
|
|
12
|
+
'Europe/Athens',
|
|
13
|
+
'Europe/Moscow',
|
|
14
|
+
'America/New_York',
|
|
15
|
+
'America/Chicago',
|
|
16
|
+
'America/Denver',
|
|
17
|
+
'America/Los_Angeles',
|
|
18
|
+
'America/Toronto',
|
|
19
|
+
'America/Sao_Paulo',
|
|
20
|
+
'America/Mexico_City',
|
|
21
|
+
'Asia/Dubai',
|
|
22
|
+
'Asia/Kolkata',
|
|
23
|
+
'Asia/Bangkok',
|
|
24
|
+
'Asia/Singapore',
|
|
25
|
+
'Asia/Hong_Kong',
|
|
26
|
+
'Asia/Tokyo',
|
|
27
|
+
'Asia/Seoul',
|
|
28
|
+
'Australia/Sydney',
|
|
29
|
+
'Australia/Melbourne',
|
|
30
|
+
'Pacific/Auckland'
|
|
31
|
+
];
|
|
32
|
+
const isCommonTimezone = (value) => exports.COMMON_TIMEZONES.includes(value);
|
|
33
|
+
exports.isCommonTimezone = isCommonTimezone;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type CurrencyPlacement = 'prefix' | 'suffix';
|
|
2
|
+
export type GlobalSettings = {
|
|
3
|
+
disableRegistrations: boolean;
|
|
4
|
+
disableDeposits: boolean;
|
|
5
|
+
disableWithdrawals: boolean;
|
|
6
|
+
disableCasinoGames: boolean;
|
|
7
|
+
disableCasinoGamesForMods: boolean;
|
|
8
|
+
disablePredictions: boolean;
|
|
9
|
+
disablePredictionManagement: boolean;
|
|
10
|
+
disableRaffles: boolean;
|
|
11
|
+
disableRaffleManagement: boolean;
|
|
12
|
+
disableDailyBonus: boolean;
|
|
13
|
+
disableVip: boolean;
|
|
14
|
+
maintenanceMode: boolean;
|
|
15
|
+
timezone: string;
|
|
16
|
+
currencySymbol: string;
|
|
17
|
+
/** prefix: symbol before amount ($1.5k). suffix: symbol after amount (1.5kCZK). Spacing is part of currencySymbol. */
|
|
18
|
+
currencyPlacement: CurrencyPlacement;
|
|
19
|
+
};
|
|
20
|
+
export declare const defaultGlobalSettings: GlobalSettings;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultGlobalSettings = void 0;
|
|
4
|
+
exports.defaultGlobalSettings = {
|
|
5
|
+
disableRegistrations: false,
|
|
6
|
+
disableDeposits: false,
|
|
7
|
+
disableWithdrawals: false,
|
|
8
|
+
disableCasinoGames: false,
|
|
9
|
+
disableCasinoGamesForMods: false,
|
|
10
|
+
disablePredictions: false,
|
|
11
|
+
disablePredictionManagement: false,
|
|
12
|
+
disableRaffles: false,
|
|
13
|
+
disableRaffleManagement: false,
|
|
14
|
+
disableDailyBonus: false,
|
|
15
|
+
disableVip: false,
|
|
16
|
+
maintenanceMode: false,
|
|
17
|
+
timezone: 'UTC',
|
|
18
|
+
currencySymbol: '$',
|
|
19
|
+
currencyPlacement: 'prefix'
|
|
20
|
+
};
|
package/dist/constants/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./bonusLimits"), exports);
|
|
18
|
+
__exportStar(require("./commonTimezones"), exports);
|
|
19
|
+
__exportStar(require("./defaultGlobalSettings"), exports);
|
|
18
20
|
__exportStar(require("./defaultConfig"), exports);
|
|
19
21
|
__exportStar(require("./maxSimulations"), exports);
|
|
20
22
|
__exportStar(require("./lotteryConfig"), exports);
|
|
@@ -206,4 +206,13 @@ export declare const GuildConfigurationSchema: Schema<TGuildConfiguration, impor
|
|
|
206
206
|
}, "id"> & {
|
|
207
207
|
id: string;
|
|
208
208
|
}> | undefined;
|
|
209
|
+
globalSettings?: import("mongoose").SchemaDefinitionProperty<import("../constants").GlobalSettings | undefined, TGuildConfiguration, import("mongoose").Document<unknown, {}, TGuildConfiguration, {
|
|
210
|
+
id: string;
|
|
211
|
+
}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TGuildConfiguration & {
|
|
212
|
+
_id: import("mongoose").Types.ObjectId;
|
|
213
|
+
} & {
|
|
214
|
+
__v: number;
|
|
215
|
+
}, "id"> & {
|
|
216
|
+
id: string;
|
|
217
|
+
}> | undefined;
|
|
209
218
|
}, TGuildConfiguration>;
|
|
@@ -97,5 +97,29 @@ exports.GuildConfigurationSchema = new mongoose_1.Schema({
|
|
|
97
97
|
weekly: { type: Number, default: 0 },
|
|
98
98
|
monthly: { type: Number, default: 0 }
|
|
99
99
|
}
|
|
100
|
+
},
|
|
101
|
+
globalSettings: {
|
|
102
|
+
disableRegistrations: { type: Boolean, default: false },
|
|
103
|
+
disableDeposits: { type: Boolean, default: false },
|
|
104
|
+
disableWithdrawals: { type: Boolean, default: false },
|
|
105
|
+
disableCasinoGames: { type: Boolean, default: false },
|
|
106
|
+
disableCasinoGamesForMods: { type: Boolean, default: false },
|
|
107
|
+
disablePredictions: { type: Boolean, default: false },
|
|
108
|
+
disablePredictionManagement: { type: Boolean, default: false },
|
|
109
|
+
disableRaffles: { type: Boolean, default: false },
|
|
110
|
+
disableRaffleManagement: { type: Boolean, default: false },
|
|
111
|
+
disableDailyBonus: { type: Boolean, default: false },
|
|
112
|
+
disableVip: { type: Boolean, default: false },
|
|
113
|
+
maintenanceMode: { type: Boolean, default: false },
|
|
114
|
+
timezone: { type: String, default: constants_1.defaultGlobalSettings.timezone },
|
|
115
|
+
currencySymbol: {
|
|
116
|
+
type: String,
|
|
117
|
+
default: constants_1.defaultGlobalSettings.currencySymbol
|
|
118
|
+
},
|
|
119
|
+
currencyPlacement: {
|
|
120
|
+
type: String,
|
|
121
|
+
enum: ['prefix', 'suffix'],
|
|
122
|
+
default: constants_1.defaultGlobalSettings.currencyPlacement
|
|
123
|
+
}
|
|
100
124
|
}
|
|
101
125
|
});
|
package/dist/schemas/forms.d.ts
CHANGED
|
@@ -108,6 +108,52 @@ export declare const vipSettingsFormSchema: z.ZodObject<{
|
|
|
108
108
|
export declare const managerRoleFormSchema: z.ZodObject<{
|
|
109
109
|
managerRoleId: z.ZodString;
|
|
110
110
|
}, z.core.$strip>;
|
|
111
|
+
export declare const globalSettingsFormSchema: z.ZodObject<{
|
|
112
|
+
disableRegistrations: z.ZodBoolean;
|
|
113
|
+
disableDeposits: z.ZodBoolean;
|
|
114
|
+
disableWithdrawals: z.ZodBoolean;
|
|
115
|
+
disableCasinoGames: z.ZodBoolean;
|
|
116
|
+
disableCasinoGamesForMods: z.ZodBoolean;
|
|
117
|
+
disablePredictions: z.ZodBoolean;
|
|
118
|
+
disablePredictionManagement: z.ZodBoolean;
|
|
119
|
+
disableRaffles: z.ZodBoolean;
|
|
120
|
+
disableRaffleManagement: z.ZodBoolean;
|
|
121
|
+
disableDailyBonus: z.ZodBoolean;
|
|
122
|
+
disableVip: z.ZodBoolean;
|
|
123
|
+
maintenanceMode: z.ZodBoolean;
|
|
124
|
+
timezone: z.ZodEnum<{
|
|
125
|
+
UTC: "UTC";
|
|
126
|
+
"Europe/London": "Europe/London";
|
|
127
|
+
"Europe/Paris": "Europe/Paris";
|
|
128
|
+
"Europe/Berlin": "Europe/Berlin";
|
|
129
|
+
"Europe/Prague": "Europe/Prague";
|
|
130
|
+
"Europe/Warsaw": "Europe/Warsaw";
|
|
131
|
+
"Europe/Athens": "Europe/Athens";
|
|
132
|
+
"Europe/Moscow": "Europe/Moscow";
|
|
133
|
+
"America/New_York": "America/New_York";
|
|
134
|
+
"America/Chicago": "America/Chicago";
|
|
135
|
+
"America/Denver": "America/Denver";
|
|
136
|
+
"America/Los_Angeles": "America/Los_Angeles";
|
|
137
|
+
"America/Toronto": "America/Toronto";
|
|
138
|
+
"America/Sao_Paulo": "America/Sao_Paulo";
|
|
139
|
+
"America/Mexico_City": "America/Mexico_City";
|
|
140
|
+
"Asia/Dubai": "Asia/Dubai";
|
|
141
|
+
"Asia/Kolkata": "Asia/Kolkata";
|
|
142
|
+
"Asia/Bangkok": "Asia/Bangkok";
|
|
143
|
+
"Asia/Singapore": "Asia/Singapore";
|
|
144
|
+
"Asia/Hong_Kong": "Asia/Hong_Kong";
|
|
145
|
+
"Asia/Tokyo": "Asia/Tokyo";
|
|
146
|
+
"Asia/Seoul": "Asia/Seoul";
|
|
147
|
+
"Australia/Sydney": "Australia/Sydney";
|
|
148
|
+
"Australia/Melbourne": "Australia/Melbourne";
|
|
149
|
+
"Pacific/Auckland": "Pacific/Auckland";
|
|
150
|
+
}>;
|
|
151
|
+
currencySymbol: z.ZodString;
|
|
152
|
+
currencyPlacement: z.ZodEnum<{
|
|
153
|
+
prefix: "prefix";
|
|
154
|
+
suffix: "suffix";
|
|
155
|
+
}>;
|
|
156
|
+
}, z.core.$strip>;
|
|
111
157
|
export declare const bonusFormSchema: z.ZodObject<{
|
|
112
158
|
rewardMode: z.ZodEnum<{
|
|
113
159
|
linear: "linear";
|
package/dist/schemas/forms.js
CHANGED
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.bonusFormSchema = exports.managerRoleFormSchema = exports.vipSettingsFormSchema = exports.casinoSettingsSchema = exports.channelsFormSchema = exports.raffleChannelsFormSchema = exports.predictionChannelsFormSchema = exports.casinoChannelsFormSchema = exports.atmChannelsFormSchema = void 0;
|
|
6
|
+
exports.bonusFormSchema = exports.globalSettingsFormSchema = exports.managerRoleFormSchema = exports.vipSettingsFormSchema = exports.casinoSettingsSchema = exports.channelsFormSchema = exports.raffleChannelsFormSchema = exports.predictionChannelsFormSchema = exports.casinoChannelsFormSchema = exports.atmChannelsFormSchema = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const commonTimezones_1 = require("../constants/commonTimezones");
|
|
8
9
|
const bonusLimits_1 = require("../constants/bonusLimits");
|
|
9
10
|
const plinkoConfig_1 = require("../constants/plinkoConfig");
|
|
10
11
|
const NO_CHANNEL = 'At least one channel must be selected.';
|
|
@@ -128,6 +129,28 @@ const bonusMultiplierInputSchema = zod_1.default
|
|
|
128
129
|
return Number.isNaN(num) ? undefined : num;
|
|
129
130
|
})
|
|
130
131
|
.pipe(bonusMultiplierSchema);
|
|
132
|
+
exports.globalSettingsFormSchema = zod_1.default.object({
|
|
133
|
+
disableRegistrations: zod_1.default.boolean(),
|
|
134
|
+
disableDeposits: zod_1.default.boolean(),
|
|
135
|
+
disableWithdrawals: zod_1.default.boolean(),
|
|
136
|
+
disableCasinoGames: zod_1.default.boolean(),
|
|
137
|
+
disableCasinoGamesForMods: zod_1.default.boolean(),
|
|
138
|
+
disablePredictions: zod_1.default.boolean(),
|
|
139
|
+
disablePredictionManagement: zod_1.default.boolean(),
|
|
140
|
+
disableRaffles: zod_1.default.boolean(),
|
|
141
|
+
disableRaffleManagement: zod_1.default.boolean(),
|
|
142
|
+
disableDailyBonus: zod_1.default.boolean(),
|
|
143
|
+
disableVip: zod_1.default.boolean(),
|
|
144
|
+
maintenanceMode: zod_1.default.boolean(),
|
|
145
|
+
timezone: zod_1.default.enum(commonTimezones_1.COMMON_TIMEZONES),
|
|
146
|
+
currencySymbol: zod_1.default
|
|
147
|
+
.string()
|
|
148
|
+
.max(8)
|
|
149
|
+
.refine((value) => value.trim().length > 0, {
|
|
150
|
+
message: 'Currency symbol is required'
|
|
151
|
+
}),
|
|
152
|
+
currencyPlacement: zod_1.default.enum(['prefix', 'suffix'])
|
|
153
|
+
});
|
|
131
154
|
exports.bonusFormSchema = zod_1.default.object({
|
|
132
155
|
rewardMode: zod_1.default.enum(['linear', 'exponential']),
|
|
133
156
|
baseReward: bonusAmountSchema,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defaultCasinoSettings } from '../constants';
|
|
2
|
+
import type { GlobalSettings } from '../constants/defaultGlobalSettings';
|
|
2
3
|
import { BonusSettings } from './bonus';
|
|
3
4
|
export type RewardMode = 'linear' | 'exponential';
|
|
4
5
|
export type TGuildConfiguration = {
|
|
@@ -28,4 +29,6 @@ export type TGuildConfiguration = {
|
|
|
28
29
|
maxMembers: number;
|
|
29
30
|
};
|
|
30
31
|
bonusSettings: BonusSettings;
|
|
32
|
+
globalSettings?: GlobalSettings;
|
|
31
33
|
};
|
|
34
|
+
export type { GlobalSettings } from '../constants/defaultGlobalSettings';
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import type { GlobalSettings } from '../constants/defaultGlobalSettings';
|
|
1
2
|
export declare const formatNumberToReadableString: (number: number) => string;
|
|
2
3
|
export declare const parseReadableStringToNumber: (readableString: string) => number;
|
|
3
4
|
export declare const formatNumberWithSpaces: (num: number) => string;
|
|
5
|
+
/** Compact amount with guild currency (prefix or suffix symbol). */
|
|
6
|
+
export declare const formatMoney: (amount: number, globalSettings?: Partial<GlobalSettings> | null) => string;
|
|
7
|
+
/** Full-precision amount with guild currency (prefix or suffix symbol). */
|
|
8
|
+
export declare const formatMoneyExact: (amount: number, globalSettings?: Partial<GlobalSettings> | null) => string;
|
|
4
9
|
export declare const formatNumberToPercentage: (num: number) => string;
|
|
5
10
|
export declare const getReadableName: (key: string, map: {
|
|
6
11
|
name: string;
|
package/dist/utils/formatters.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReadableName = exports.formatNumberToPercentage = exports.formatNumberWithSpaces = exports.parseReadableStringToNumber = exports.formatNumberToReadableString = void 0;
|
|
3
|
+
exports.getReadableName = exports.formatNumberToPercentage = exports.formatMoneyExact = exports.formatMoney = exports.formatNumberWithSpaces = exports.parseReadableStringToNumber = exports.formatNumberToReadableString = void 0;
|
|
4
|
+
const globalSettings_1 = require("./globalSettings");
|
|
5
|
+
const formatAmountWithCurrency = (amount, formattedAbsAmount, globalSettings) => {
|
|
6
|
+
const negative = amount < 0;
|
|
7
|
+
const sign = negative ? '-' : '';
|
|
8
|
+
const symbol = (0, globalSettings_1.getCurrencySymbol)(globalSettings);
|
|
9
|
+
if ((0, globalSettings_1.getCurrencyPlacement)(globalSettings) === 'suffix') {
|
|
10
|
+
return `${sign}${formattedAbsAmount}${symbol}`;
|
|
11
|
+
}
|
|
12
|
+
return `${sign}${symbol}${formattedAbsAmount}`;
|
|
13
|
+
};
|
|
4
14
|
const formatNumberToReadableString = (number) => {
|
|
5
15
|
const absNumber = Math.abs(number);
|
|
6
16
|
const roundTo = (num, digits = 2) => Math.round(num * 10 ** digits) / 10 ** digits;
|
|
@@ -43,6 +53,12 @@ const formatNumberWithSpaces = (num) => {
|
|
|
43
53
|
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
44
54
|
};
|
|
45
55
|
exports.formatNumberWithSpaces = formatNumberWithSpaces;
|
|
56
|
+
/** Compact amount with guild currency (prefix or suffix symbol). */
|
|
57
|
+
const formatMoney = (amount, globalSettings) => formatAmountWithCurrency(amount, (0, exports.formatNumberToReadableString)(Math.abs(amount)), globalSettings);
|
|
58
|
+
exports.formatMoney = formatMoney;
|
|
59
|
+
/** Full-precision amount with guild currency (prefix or suffix symbol). */
|
|
60
|
+
const formatMoneyExact = (amount, globalSettings) => formatAmountWithCurrency(amount, (0, exports.formatNumberWithSpaces)(Math.abs(amount)), globalSettings);
|
|
61
|
+
exports.formatMoneyExact = formatMoneyExact;
|
|
46
62
|
const formatNumberToPercentage = (num) => {
|
|
47
63
|
return (num * 100).toFixed(2) + '%';
|
|
48
64
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type CurrencyPlacement, type GlobalSettings } from '../constants/defaultGlobalSettings';
|
|
2
|
+
import type { TGuildConfiguration } from '../types/guildConfiguration';
|
|
3
|
+
export type GlobalFeature = 'registration' | 'deposit' | 'withdraw' | 'casinoGames' | 'casinoGamesForMods' | 'predictions' | 'predictionManagement' | 'raffles' | 'raffleManagement' | 'dailyBonus' | 'vip' | 'maintenance';
|
|
4
|
+
export declare function isGlobalFeatureDisabled(config: TGuildConfiguration | null | undefined, feature: GlobalFeature): boolean;
|
|
5
|
+
export declare const getCurrencyPlacement: (globalSettings?: Partial<GlobalSettings> | null) => CurrencyPlacement;
|
|
6
|
+
export declare const getCurrencySymbol: (globalSettings?: Partial<GlobalSettings> | null) => string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrencySymbol = exports.getCurrencyPlacement = void 0;
|
|
4
|
+
exports.isGlobalFeatureDisabled = isGlobalFeatureDisabled;
|
|
5
|
+
const defaultGlobalSettings_1 = require("../constants/defaultGlobalSettings");
|
|
6
|
+
function isGlobalFeatureDisabled(config, feature) {
|
|
7
|
+
const settings = config?.globalSettings;
|
|
8
|
+
if (!settings)
|
|
9
|
+
return false;
|
|
10
|
+
switch (feature) {
|
|
11
|
+
case 'registration':
|
|
12
|
+
return settings.disableRegistrations;
|
|
13
|
+
case 'deposit':
|
|
14
|
+
return settings.disableDeposits;
|
|
15
|
+
case 'withdraw':
|
|
16
|
+
return settings.disableWithdrawals;
|
|
17
|
+
case 'casinoGames':
|
|
18
|
+
return settings.disableCasinoGames;
|
|
19
|
+
case 'casinoGamesForMods':
|
|
20
|
+
return settings.disableCasinoGamesForMods;
|
|
21
|
+
case 'predictions':
|
|
22
|
+
return settings.disablePredictions;
|
|
23
|
+
case 'predictionManagement':
|
|
24
|
+
return settings.disablePredictionManagement;
|
|
25
|
+
case 'raffles':
|
|
26
|
+
return settings.disableRaffles;
|
|
27
|
+
case 'raffleManagement':
|
|
28
|
+
return settings.disableRaffleManagement;
|
|
29
|
+
case 'dailyBonus':
|
|
30
|
+
return settings.disableDailyBonus;
|
|
31
|
+
case 'vip':
|
|
32
|
+
return settings.disableVip;
|
|
33
|
+
case 'maintenance':
|
|
34
|
+
return settings.maintenanceMode;
|
|
35
|
+
default: {
|
|
36
|
+
const _exhaustive = feature;
|
|
37
|
+
return _exhaustive;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const getCurrencyPlacement = (globalSettings) => globalSettings?.currencyPlacement === 'suffix' ? 'suffix' : 'prefix';
|
|
42
|
+
exports.getCurrencyPlacement = getCurrencyPlacement;
|
|
43
|
+
const getCurrencySymbol = (globalSettings) => {
|
|
44
|
+
const symbol = globalSettings?.currencySymbol;
|
|
45
|
+
if (symbol == null || symbol.trim().length === 0) {
|
|
46
|
+
return defaultGlobalSettings_1.defaultGlobalSettings.currencySymbol;
|
|
47
|
+
}
|
|
48
|
+
return symbol;
|
|
49
|
+
};
|
|
50
|
+
exports.getCurrencySymbol = getCurrencySymbol;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const resolveGuildTimezone: (timezone?: string | null) => string;
|
|
2
|
+
/** Calendar dates (yyyy-MM-dd) interpreted in the guild timezone → UTC bounds for MongoDB. */
|
|
3
|
+
export declare const guildCalendarRangeToUtc: (dateFrom: string, dateTo: string, timezone?: string | null) => {
|
|
4
|
+
start: Date;
|
|
5
|
+
end: Date;
|
|
6
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guildCalendarRangeToUtc = exports.resolveGuildTimezone = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
5
|
+
const defaultGlobalSettings_1 = require("../constants/defaultGlobalSettings");
|
|
6
|
+
const resolveGuildTimezone = (timezone) => {
|
|
7
|
+
const raw = timezone?.trim();
|
|
8
|
+
return raw && raw.length > 0 ? raw : defaultGlobalSettings_1.defaultGlobalSettings.timezone;
|
|
9
|
+
};
|
|
10
|
+
exports.resolveGuildTimezone = resolveGuildTimezone;
|
|
11
|
+
/** Calendar dates (yyyy-MM-dd) interpreted in the guild timezone → UTC bounds for MongoDB. */
|
|
12
|
+
const guildCalendarRangeToUtc = (dateFrom, dateTo, timezone) => {
|
|
13
|
+
const zone = (0, exports.resolveGuildTimezone)(timezone);
|
|
14
|
+
const start = luxon_1.DateTime.fromISO(dateFrom, { zone }).startOf('day');
|
|
15
|
+
const end = luxon_1.DateTime.fromISO(dateTo, { zone }).endOf('day');
|
|
16
|
+
if (!start.isValid || !end.isValid) {
|
|
17
|
+
const fallbackStart = new Date(dateFrom);
|
|
18
|
+
fallbackStart.setHours(0, 0, 0, 0);
|
|
19
|
+
const fallbackEnd = new Date(dateTo);
|
|
20
|
+
fallbackEnd.setHours(23, 59, 59, 999);
|
|
21
|
+
return { start: fallbackStart, end: fallbackEnd };
|
|
22
|
+
}
|
|
23
|
+
return { start: start.toUTC().toJSDate(), end: end.toUTC().toJSDate() };
|
|
24
|
+
};
|
|
25
|
+
exports.guildCalendarRangeToUtc = guildCalendarRangeToUtc;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export * from './calculateBonusReward';
|
|
|
3
3
|
export * from './normalizeBonusSettings';
|
|
4
4
|
export * from './generateBonusPreview';
|
|
5
5
|
export * from './formatters';
|
|
6
|
+
export * from './globalSettings';
|
|
7
|
+
export * from './normalizeGlobalSettings';
|
|
8
|
+
export * from './guildTimezone';
|
|
6
9
|
export * from './generateId';
|
|
7
10
|
export * from './parseTimeToSeconds';
|
|
8
11
|
export * from './validateBetAmount';
|
package/dist/utils/index.js
CHANGED
|
@@ -19,6 +19,9 @@ __exportStar(require("./calculateBonusReward"), exports);
|
|
|
19
19
|
__exportStar(require("./normalizeBonusSettings"), exports);
|
|
20
20
|
__exportStar(require("./generateBonusPreview"), exports);
|
|
21
21
|
__exportStar(require("./formatters"), exports);
|
|
22
|
+
__exportStar(require("./globalSettings"), exports);
|
|
23
|
+
__exportStar(require("./normalizeGlobalSettings"), exports);
|
|
24
|
+
__exportStar(require("./guildTimezone"), exports);
|
|
22
25
|
__exportStar(require("./generateId"), exports);
|
|
23
26
|
__exportStar(require("./parseTimeToSeconds"), exports);
|
|
24
27
|
__exportStar(require("./validateBetAmount"), exports);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeGlobalSettings = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const coerceBool = (value, fallback) => {
|
|
6
|
+
if (typeof value === 'boolean')
|
|
7
|
+
return value;
|
|
8
|
+
if (value === 'true')
|
|
9
|
+
return true;
|
|
10
|
+
if (value === 'false')
|
|
11
|
+
return false;
|
|
12
|
+
return fallback;
|
|
13
|
+
};
|
|
14
|
+
const normalizeCurrencySymbol = (value) => {
|
|
15
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
16
|
+
return constants_1.defaultGlobalSettings.currencySymbol;
|
|
17
|
+
}
|
|
18
|
+
return value.slice(0, 8);
|
|
19
|
+
};
|
|
20
|
+
const normalizeCurrencyPlacement = (value) => value === 'suffix' ? 'suffix' : 'prefix';
|
|
21
|
+
const normalizeTimezone = (value) => {
|
|
22
|
+
const raw = typeof value === 'string' ? value.trim() : '';
|
|
23
|
+
if (raw.length > 0 &&
|
|
24
|
+
constants_1.COMMON_TIMEZONES.includes(raw)) {
|
|
25
|
+
return raw;
|
|
26
|
+
}
|
|
27
|
+
return constants_1.defaultGlobalSettings.timezone;
|
|
28
|
+
};
|
|
29
|
+
const normalizeGlobalSettings = (settings) => ({
|
|
30
|
+
disableRegistrations: coerceBool(settings?.disableRegistrations, constants_1.defaultGlobalSettings.disableRegistrations),
|
|
31
|
+
disableDeposits: coerceBool(settings?.disableDeposits, constants_1.defaultGlobalSettings.disableDeposits),
|
|
32
|
+
disableWithdrawals: coerceBool(settings?.disableWithdrawals, constants_1.defaultGlobalSettings.disableWithdrawals),
|
|
33
|
+
disableCasinoGames: coerceBool(settings?.disableCasinoGames, constants_1.defaultGlobalSettings.disableCasinoGames),
|
|
34
|
+
disableCasinoGamesForMods: coerceBool(settings?.disableCasinoGamesForMods, constants_1.defaultGlobalSettings.disableCasinoGamesForMods),
|
|
35
|
+
disablePredictions: coerceBool(settings?.disablePredictions, constants_1.defaultGlobalSettings.disablePredictions),
|
|
36
|
+
disablePredictionManagement: coerceBool(settings?.disablePredictionManagement, constants_1.defaultGlobalSettings.disablePredictionManagement),
|
|
37
|
+
disableRaffles: coerceBool(settings?.disableRaffles, constants_1.defaultGlobalSettings.disableRaffles),
|
|
38
|
+
disableRaffleManagement: coerceBool(settings?.disableRaffleManagement, constants_1.defaultGlobalSettings.disableRaffleManagement),
|
|
39
|
+
disableDailyBonus: coerceBool(settings?.disableDailyBonus, constants_1.defaultGlobalSettings.disableDailyBonus),
|
|
40
|
+
disableVip: coerceBool(settings?.disableVip, constants_1.defaultGlobalSettings.disableVip),
|
|
41
|
+
maintenanceMode: coerceBool(settings?.maintenanceMode, constants_1.defaultGlobalSettings.maintenanceMode),
|
|
42
|
+
timezone: normalizeTimezone(settings?.timezone),
|
|
43
|
+
currencySymbol: normalizeCurrencySymbol(settings?.currencySymbol),
|
|
44
|
+
currencyPlacement: normalizeCurrencyPlacement(settings?.currencyPlacement)
|
|
45
|
+
});
|
|
46
|
+
exports.normalizeGlobalSettings = normalizeGlobalSettings;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gambling-bot-shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
"mongoose": "^9.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@types/luxon": "^3.7.1",
|
|
35
36
|
"mongoose": "^9.1.4",
|
|
36
37
|
"typescript": "^5.9.3"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
40
|
+
"luxon": "^3.7.2",
|
|
39
41
|
"zod": "^4.3.6"
|
|
40
42
|
}
|
|
41
43
|
}
|