gambling-bot-shared 0.1.46 → 0.1.48

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.
@@ -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,21 @@
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
+ currencyCode: string;
17
+ currencySymbol: string;
18
+ /** prefix: symbol before amount ($ 1.5k). suffix: ISO code after amount (1.5k CZK). */
19
+ currencyPlacement: CurrencyPlacement;
20
+ };
21
+ export declare const defaultGlobalSettings: GlobalSettings;
@@ -0,0 +1,21 @@
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
+ currencyCode: 'USD',
19
+ currencySymbol: '$',
20
+ currencyPlacement: 'prefix'
21
+ };
@@ -1,4 +1,6 @@
1
1
  export * from './bonusLimits';
2
+ export * from './commonTimezones';
3
+ export * from './defaultGlobalSettings';
2
4
  export * from './defaultConfig';
3
5
  export * from './maxSimulations';
4
6
  export * from './lotteryConfig';
@@ -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,30 @@ 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
+ currencyCode: { type: String, default: constants_1.defaultGlobalSettings.currencyCode },
116
+ currencySymbol: {
117
+ type: String,
118
+ default: constants_1.defaultGlobalSettings.currencySymbol
119
+ },
120
+ currencyPlacement: {
121
+ type: String,
122
+ enum: ['prefix', 'suffix'],
123
+ default: constants_1.defaultGlobalSettings.currencyPlacement
124
+ }
100
125
  }
101
126
  });
@@ -108,6 +108,53 @@ 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
+ currencyCode: z.ZodString;
152
+ currencySymbol: z.ZodString;
153
+ currencyPlacement: z.ZodEnum<{
154
+ prefix: "prefix";
155
+ suffix: "suffix";
156
+ }>;
157
+ }, z.core.$strip>;
111
158
  export declare const bonusFormSchema: z.ZodObject<{
112
159
  rewardMode: z.ZodEnum<{
113
160
  linear: "linear";
@@ -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
+ currencyCode: zod_1.default
147
+ .string()
148
+ .trim()
149
+ .toUpperCase()
150
+ .regex(/^[A-Z]{3}$/, 'Use a 3-letter ISO 4217 code (e.g. USD, CZK).'),
151
+ currencySymbol: zod_1.default.string().trim().min(1).max(8),
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: symbol, suffix: ISO code). */
6
+ export declare const formatMoney: (amount: number, globalSettings?: Partial<GlobalSettings> | null) => string;
7
+ /** Full-precision amount with guild currency (prefix: symbol, suffix: ISO code). */
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;
@@ -1,6 +1,15 @@
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
+ if ((0, globalSettings_1.getCurrencyPlacement)(globalSettings) === 'suffix') {
9
+ return `${sign}${formattedAbsAmount} ${(0, globalSettings_1.getCurrencyCode)(globalSettings)}`;
10
+ }
11
+ return `${sign}${(0, globalSettings_1.getCurrencySymbol)(globalSettings)} ${formattedAbsAmount}`;
12
+ };
4
13
  const formatNumberToReadableString = (number) => {
5
14
  const absNumber = Math.abs(number);
6
15
  const roundTo = (num, digits = 2) => Math.round(num * 10 ** digits) / 10 ** digits;
@@ -43,6 +52,12 @@ const formatNumberWithSpaces = (num) => {
43
52
  return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
44
53
  };
45
54
  exports.formatNumberWithSpaces = formatNumberWithSpaces;
55
+ /** Compact amount with guild currency (prefix: symbol, suffix: ISO code). */
56
+ const formatMoney = (amount, globalSettings) => formatAmountWithCurrency(amount, (0, exports.formatNumberToReadableString)(Math.abs(amount)), globalSettings);
57
+ exports.formatMoney = formatMoney;
58
+ /** Full-precision amount with guild currency (prefix: symbol, suffix: ISO code). */
59
+ const formatMoneyExact = (amount, globalSettings) => formatAmountWithCurrency(amount, (0, exports.formatNumberWithSpaces)(Math.abs(amount)), globalSettings);
60
+ exports.formatMoneyExact = formatMoneyExact;
46
61
  const formatNumberToPercentage = (num) => {
47
62
  return (num * 100).toFixed(2) + '%';
48
63
  };
@@ -0,0 +1,7 @@
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;
7
+ export declare const getCurrencyCode: (globalSettings?: Partial<GlobalSettings> | null) => string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrencyCode = 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) => globalSettings?.currencySymbol?.trim() || '$';
44
+ exports.getCurrencySymbol = getCurrencySymbol;
45
+ const getCurrencyCode = (globalSettings) => {
46
+ const raw = typeof globalSettings?.currencyCode === 'string'
47
+ ? globalSettings.currencyCode.trim().toUpperCase()
48
+ : '';
49
+ return /^[A-Z]{3}$/.test(raw) ? raw : defaultGlobalSettings_1.defaultGlobalSettings.currencyCode;
50
+ };
51
+ exports.getCurrencyCode = getCurrencyCode;
@@ -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;
@@ -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';
@@ -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,2 @@
1
+ import { type GlobalSettings } from '../constants';
2
+ export declare const normalizeGlobalSettings: (settings: Partial<GlobalSettings> | null | undefined) => GlobalSettings;
@@ -0,0 +1,50 @@
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 trimCurrencyCode = (value) => {
15
+ const raw = typeof value === 'string' ? value.trim().toUpperCase() : '';
16
+ const code = raw.slice(0, 3);
17
+ return /^[A-Z]{3}$/.test(code) ? code : constants_1.defaultGlobalSettings.currencyCode;
18
+ };
19
+ const trimCurrencySymbol = (value) => {
20
+ const raw = typeof value === 'string' ? value.trim() : '';
21
+ return raw.length > 0 ? raw.slice(0, 8) : constants_1.defaultGlobalSettings.currencySymbol;
22
+ };
23
+ const normalizeCurrencyPlacement = (value) => value === 'suffix' ? 'suffix' : 'prefix';
24
+ const normalizeTimezone = (value) => {
25
+ const raw = typeof value === 'string' ? value.trim() : '';
26
+ if (raw.length > 0 &&
27
+ constants_1.COMMON_TIMEZONES.includes(raw)) {
28
+ return raw;
29
+ }
30
+ return constants_1.defaultGlobalSettings.timezone;
31
+ };
32
+ const normalizeGlobalSettings = (settings) => ({
33
+ disableRegistrations: coerceBool(settings?.disableRegistrations, constants_1.defaultGlobalSettings.disableRegistrations),
34
+ disableDeposits: coerceBool(settings?.disableDeposits, constants_1.defaultGlobalSettings.disableDeposits),
35
+ disableWithdrawals: coerceBool(settings?.disableWithdrawals, constants_1.defaultGlobalSettings.disableWithdrawals),
36
+ disableCasinoGames: coerceBool(settings?.disableCasinoGames, constants_1.defaultGlobalSettings.disableCasinoGames),
37
+ disableCasinoGamesForMods: coerceBool(settings?.disableCasinoGamesForMods, constants_1.defaultGlobalSettings.disableCasinoGamesForMods),
38
+ disablePredictions: coerceBool(settings?.disablePredictions, constants_1.defaultGlobalSettings.disablePredictions),
39
+ disablePredictionManagement: coerceBool(settings?.disablePredictionManagement, constants_1.defaultGlobalSettings.disablePredictionManagement),
40
+ disableRaffles: coerceBool(settings?.disableRaffles, constants_1.defaultGlobalSettings.disableRaffles),
41
+ disableRaffleManagement: coerceBool(settings?.disableRaffleManagement, constants_1.defaultGlobalSettings.disableRaffleManagement),
42
+ disableDailyBonus: coerceBool(settings?.disableDailyBonus, constants_1.defaultGlobalSettings.disableDailyBonus),
43
+ disableVip: coerceBool(settings?.disableVip, constants_1.defaultGlobalSettings.disableVip),
44
+ maintenanceMode: coerceBool(settings?.maintenanceMode, constants_1.defaultGlobalSettings.maintenanceMode),
45
+ timezone: normalizeTimezone(settings?.timezone),
46
+ currencyCode: trimCurrencyCode(settings?.currencyCode),
47
+ currencySymbol: trimCurrencySymbol(settings?.currencySymbol),
48
+ currencyPlacement: normalizeCurrencyPlacement(settings?.currencyPlacement)
49
+ });
50
+ exports.normalizeGlobalSettings = normalizeGlobalSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gambling-bot-shared",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
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
  }