gambling-bot-shared 0.1.54 → 1.0.1
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/README.MD +4 -0
- package/dist/{mongoose/atmRequest.schema.d.ts → atm/atmRequest.mongoose.d.ts} +18 -28
- package/dist/atm/index.d.ts +3 -0
- package/dist/{types → atm}/index.js +5 -10
- package/dist/atm/schemas/atm.forms.d.ts +5 -0
- package/dist/atm/schemas/atm.forms.js +11 -0
- package/dist/blackjack/index.d.ts +3 -0
- package/dist/blackjack/index.js +21 -0
- package/dist/bonus/index.d.ts +7 -0
- package/dist/bonus/index.js +23 -0
- package/dist/bonus/schemas/bonus.forms.d.ts +16 -0
- package/dist/bonus/schemas/bonus.forms.js +39 -0
- package/dist/{types → bonus/types}/bonus.d.ts +1 -1
- package/dist/{utils → bonus/utils}/calculateBonusReward.d.ts +1 -1
- package/dist/{utils → bonus/utils}/generateBonusPreview.d.ts +1 -1
- package/dist/{utils → bonus/utils}/normalizeBonusSettings.d.ts +1 -1
- package/dist/{mongoose/blackjackGame.schema.d.ts → casino/blackjackGame.mongoose.d.ts} +19 -29
- package/dist/{constants → casino/constants}/index.d.ts +4 -9
- package/dist/{constants → casino/constants}/index.js +4 -9
- package/dist/{constants → casino/constants}/plinkoConfig.js +1 -1
- package/dist/casino/index.d.ts +12 -0
- package/dist/casino/index.js +30 -0
- package/dist/{schemas/forms.d.ts → casino/schemas/casino.forms.d.ts} +0 -103
- package/dist/casino/schemas/casino.forms.js +80 -0
- package/dist/casino/services/casinoBet.service.d.ts +41 -0
- package/dist/casino/services/casinoBet.service.js +146 -0
- package/dist/casino/types/casinoSettings.d.ts +2 -0
- package/dist/{utils → casino/utils}/calculateRTP.d.ts +1 -1
- package/dist/{utils → casino/utils}/calculateRTP.js +0 -2
- package/dist/{utils → casino/utils}/normalizeCasinoSettings.d.ts +1 -1
- package/dist/{utils → common}/formatters.d.ts +1 -1
- package/dist/{utils → common}/formatters.js +2 -2
- package/dist/common/index.d.ts +4 -0
- package/dist/{server.js → common/index.js} +4 -1
- package/dist/common/zod.d.ts +2 -0
- package/dist/common/zod.js +16 -0
- package/dist/{mongoose/guildConfiguration.schema.d.ts → guild/guildConfiguration.mongoose.d.ts} +16 -26
- package/dist/{mongoose/guildConfiguration.schema.js → guild/guildConfiguration.mongoose.js} +6 -5
- package/dist/guild/index.d.ts +8 -0
- package/dist/guild/index.js +26 -0
- package/dist/guild/schemas/guild.forms.d.ts +68 -0
- package/dist/guild/schemas/guild.forms.js +43 -0
- package/dist/{types → guild/types}/guildConfiguration.d.ts +2 -2
- package/dist/{utils → guild/utils}/normalizeGlobalSettings.d.ts +1 -1
- package/dist/guild/utils/normalizeGlobalSettings.js +46 -0
- package/dist/mongoose/index.d.ts +8 -8
- package/dist/mongoose/index.js +17 -22
- package/dist/predictions/index.d.ts +11 -0
- package/dist/predictions/index.js +29 -0
- package/dist/{mongoose/prediction.schema.d.ts → predictions/prediction.mongoose.d.ts} +14 -24
- package/dist/predictions/schemas/prediction.forms.d.ts +20 -0
- package/dist/predictions/schemas/prediction.forms.js +24 -0
- package/dist/predictions/services/normalizePredictionInput.d.ts +6 -0
- package/dist/predictions/services/normalizePredictionInput.js +53 -0
- package/dist/predictions/services/parsePredictionAutolock.d.ts +9 -0
- package/dist/predictions/services/parsePredictionAutolock.js +20 -0
- package/dist/predictions/services/parsePredictionChoices.d.ts +11 -0
- package/dist/predictions/services/parsePredictionChoices.js +26 -0
- package/dist/predictions/services/prediction.db.d.ts +55 -0
- package/dist/predictions/services/prediction.db.js +72 -0
- package/dist/predictions/services/predictionLifecycle.service.d.ts +25 -0
- package/dist/predictions/services/predictionLifecycle.service.js +133 -0
- package/dist/predictions/services/predictionSummary.d.ts +30 -0
- package/dist/predictions/services/predictionSummary.js +58 -0
- package/dist/predictions/services/types.d.ts +27 -0
- package/dist/raffle/index.d.ts +6 -0
- package/dist/raffle/index.js +24 -0
- package/dist/{mongoose/raffle.schema.d.ts → raffle/raffle.mongoose.d.ts} +19 -32
- package/dist/raffle/schemas/raffle.forms.d.ts +11 -0
- package/dist/raffle/schemas/raffle.forms.js +17 -0
- package/dist/raffle/services/raffle.db.d.ts +51 -0
- package/dist/raffle/services/raffle.db.js +153 -0
- package/dist/raffle/services/raffleLifecycle.service.d.ts +15 -0
- package/dist/raffle/services/raffleLifecycle.service.js +34 -0
- package/dist/raffle/services/types.d.ts +27 -0
- package/dist/{types → raffle/types}/raffle.d.ts +7 -5
- package/dist/transactions/constants/index.d.ts +2 -0
- package/dist/{schemas → transactions/constants}/index.js +2 -1
- package/dist/transactions/index.d.ts +4 -0
- package/dist/{index.js → transactions/index.js} +3 -2
- package/dist/{mongoose/transaction.schema.d.ts → transactions/transaction.mongoose.d.ts} +13 -23
- package/dist/{types → transactions/types}/transaction.d.ts +1 -1
- package/dist/transactions/types/transaction.js +2 -0
- package/dist/user/index.d.ts +2 -0
- package/dist/user/index.js +20 -0
- package/dist/user/types/user.js +2 -0
- package/dist/{mongoose/user.schema.d.ts → user/user.mongoose.d.ts} +12 -22
- package/dist/vip/index.d.ts +3 -0
- package/dist/vip/index.js +21 -0
- package/dist/vip/schemas/vip.forms.d.ts +10 -0
- package/dist/vip/schemas/vip.forms.js +16 -0
- package/dist/vip/types/vipRoom.js +2 -0
- package/dist/{mongoose/vipRoom.schema.d.ts → vip/vipRoom.mongoose.d.ts} +10 -20
- package/package.json +66 -26
- package/dist/index.d.ts +0 -3
- package/dist/schemas/forms.js +0 -173
- package/dist/schemas/index.d.ts +0 -1
- package/dist/server.d.ts +0 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/utils/index.d.ts +0 -15
- package/dist/utils/index.js +0 -31
- package/dist/utils/normalizeGlobalSettings.js +0 -45
- /package/dist/{mongoose/atmRequest.schema.js → atm/atmRequest.mongoose.js} +0 -0
- /package/dist/{types → atm/types}/atmRequest.d.ts +0 -0
- /package/dist/{types → atm/types}/atmRequest.js +0 -0
- /package/dist/{constants → bonus/constants}/bonusLimits.d.ts +0 -0
- /package/dist/{constants → bonus/constants}/bonusLimits.js +0 -0
- /package/dist/{types → bonus/types}/bonus.js +0 -0
- /package/dist/{utils → bonus/utils}/bonusStreak.d.ts +0 -0
- /package/dist/{utils → bonus/utils}/bonusStreak.js +0 -0
- /package/dist/{utils → bonus/utils}/calculateBonusReward.js +0 -0
- /package/dist/{utils → bonus/utils}/generateBonusPreview.js +0 -0
- /package/dist/{utils → bonus/utils}/normalizeBonusSettings.js +0 -0
- /package/dist/{mongoose/blackjackGame.schema.js → casino/blackjackGame.mongoose.js} +0 -0
- /package/dist/{constants → casino/constants}/blackjack.d.ts +0 -0
- /package/dist/{constants → casino/constants}/blackjack.js +0 -0
- /package/dist/{constants → casino/constants}/casinoGames.d.ts +0 -0
- /package/dist/{constants → casino/constants}/casinoGames.js +0 -0
- /package/dist/{constants → casino/constants}/defaultConfig.d.ts +0 -0
- /package/dist/{constants → casino/constants}/defaultConfig.js +0 -0
- /package/dist/{constants → casino/constants}/lotteryConfig.d.ts +0 -0
- /package/dist/{constants → casino/constants}/lotteryConfig.js +0 -0
- /package/dist/{constants → casino/constants}/maxSimulations.d.ts +0 -0
- /package/dist/{constants → casino/constants}/maxSimulations.js +0 -0
- /package/dist/{constants → casino/constants}/plinkoConfig.d.ts +0 -0
- /package/dist/{constants → casino/constants}/rouletteConfig.d.ts +0 -0
- /package/dist/{constants → casino/constants}/rouletteConfig.js +0 -0
- /package/dist/{types → casino/types}/blackjackGame.d.ts +0 -0
- /package/dist/{types → casino/types}/blackjackGame.js +0 -0
- /package/dist/{types/guildConfiguration.js → casino/types/casinoSettings.js} +0 -0
- /package/dist/{utils → casino/utils}/normalizeCasinoSettings.js +0 -0
- /package/dist/{utils → casino/utils}/validateBetAmount.d.ts +0 -0
- /package/dist/{utils → casino/utils}/validateBetAmount.js +0 -0
- /package/dist/{utils → casino/utils}/winAnnouncements.d.ts +0 -0
- /package/dist/{utils → casino/utils}/winAnnouncements.js +0 -0
- /package/dist/{utils → common}/generateId.d.ts +0 -0
- /package/dist/{utils → common}/generateId.js +0 -0
- /package/dist/{utils → common}/parseTimeToSeconds.d.ts +0 -0
- /package/dist/{utils → common}/parseTimeToSeconds.js +0 -0
- /package/dist/{constants → guild/constants}/commonTimezones.d.ts +0 -0
- /package/dist/{constants → guild/constants}/commonTimezones.js +0 -0
- /package/dist/{constants → guild/constants}/defaultGlobalSettings.d.ts +0 -0
- /package/dist/{constants → guild/constants}/defaultGlobalSettings.js +0 -0
- /package/dist/{types/prediction.js → guild/types/guildConfiguration.js} +0 -0
- /package/dist/{utils → guild/utils}/globalSettings.d.ts +0 -0
- /package/dist/{utils → guild/utils}/globalSettings.js +0 -0
- /package/dist/{utils → guild/utils}/guildTimezone.d.ts +0 -0
- /package/dist/{utils → guild/utils}/guildTimezone.js +0 -0
- /package/dist/{mongoose/prediction.schema.js → predictions/prediction.mongoose.js} +0 -0
- /package/dist/{types/raffle.js → predictions/services/types.js} +0 -0
- /package/dist/{types → predictions/types}/prediction.d.ts +0 -0
- /package/dist/{types/transaction.js → predictions/types/prediction.js} +0 -0
- /package/dist/{utils → predictions/utils}/validatePredictionBet.d.ts +0 -0
- /package/dist/{utils → predictions/utils}/validatePredictionBet.js +0 -0
- /package/dist/{mongoose/raffle.schema.js → raffle/raffle.mongoose.js} +0 -0
- /package/dist/{types/user.js → raffle/services/types.js} +0 -0
- /package/dist/{types/vipRoom.js → raffle/types/raffle.js} +0 -0
- /package/dist/{constants → transactions/constants}/gameRecordFields.d.ts +0 -0
- /package/dist/{constants → transactions/constants}/gameRecordFields.js +0 -0
- /package/dist/{constants → transactions/constants}/transaction.d.ts +0 -0
- /package/dist/{constants → transactions/constants}/transaction.js +0 -0
- /package/dist/{mongoose/transaction.schema.js → transactions/transaction.mongoose.js} +0 -0
- /package/dist/{types → user/types}/user.d.ts +0 -0
- /package/dist/{mongoose/user.schema.js → user/user.mongoose.js} +0 -0
- /package/dist/{types → vip/types}/vipRoom.d.ts +0 -0
- /package/dist/{mongoose/vipRoom.schema.js → vip/vipRoom.mongoose.js} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.GuildConfigurationSchema = void 0;
|
|
18
|
+
__exportStar(require("./constants/defaultGlobalSettings"), exports);
|
|
19
|
+
__exportStar(require("./constants/commonTimezones"), exports);
|
|
20
|
+
__exportStar(require("./types/guildConfiguration"), exports);
|
|
21
|
+
__exportStar(require("./utils/globalSettings"), exports);
|
|
22
|
+
__exportStar(require("./utils/normalizeGlobalSettings"), exports);
|
|
23
|
+
__exportStar(require("./utils/guildTimezone"), exports);
|
|
24
|
+
__exportStar(require("./schemas/guild.forms"), exports);
|
|
25
|
+
var guildConfiguration_mongoose_1 = require("./guildConfiguration.mongoose");
|
|
26
|
+
Object.defineProperty(exports, "GuildConfigurationSchema", { enumerable: true, get: function () { return guildConfiguration_mongoose_1.GuildConfigurationSchema; } });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const channelsFormSchema: z.ZodObject<{
|
|
3
|
+
atm: z.ZodObject<{
|
|
4
|
+
actions: z.ZodString;
|
|
5
|
+
logs: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
casino: z.ZodObject<{
|
|
8
|
+
casinoChannelIds: z.ZodArray<z.ZodString>;
|
|
9
|
+
winAnnouncementsChannelId: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
prediction: z.ZodObject<{
|
|
12
|
+
actions: z.ZodString;
|
|
13
|
+
logs: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
raffle: z.ZodObject<{
|
|
16
|
+
actions: z.ZodString;
|
|
17
|
+
logs: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const managerRoleFormSchema: z.ZodObject<{
|
|
21
|
+
managerRoleId: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const globalSettingsFormSchema: z.ZodObject<{
|
|
24
|
+
disableRegistrations: z.ZodBoolean;
|
|
25
|
+
disableDeposits: z.ZodBoolean;
|
|
26
|
+
disableWithdrawals: z.ZodBoolean;
|
|
27
|
+
disableCasinoGames: z.ZodBoolean;
|
|
28
|
+
disableCasinoGamesForMods: z.ZodBoolean;
|
|
29
|
+
disablePredictions: z.ZodBoolean;
|
|
30
|
+
disablePredictionManagement: z.ZodBoolean;
|
|
31
|
+
disableRaffles: z.ZodBoolean;
|
|
32
|
+
disableRaffleManagement: z.ZodBoolean;
|
|
33
|
+
disableDailyBonus: z.ZodBoolean;
|
|
34
|
+
disableVip: z.ZodBoolean;
|
|
35
|
+
maintenanceMode: z.ZodBoolean;
|
|
36
|
+
timezone: z.ZodEnum<{
|
|
37
|
+
UTC: "UTC";
|
|
38
|
+
"Europe/London": "Europe/London";
|
|
39
|
+
"Europe/Paris": "Europe/Paris";
|
|
40
|
+
"Europe/Berlin": "Europe/Berlin";
|
|
41
|
+
"Europe/Prague": "Europe/Prague";
|
|
42
|
+
"Europe/Warsaw": "Europe/Warsaw";
|
|
43
|
+
"Europe/Athens": "Europe/Athens";
|
|
44
|
+
"Europe/Moscow": "Europe/Moscow";
|
|
45
|
+
"America/New_York": "America/New_York";
|
|
46
|
+
"America/Chicago": "America/Chicago";
|
|
47
|
+
"America/Denver": "America/Denver";
|
|
48
|
+
"America/Los_Angeles": "America/Los_Angeles";
|
|
49
|
+
"America/Toronto": "America/Toronto";
|
|
50
|
+
"America/Sao_Paulo": "America/Sao_Paulo";
|
|
51
|
+
"America/Mexico_City": "America/Mexico_City";
|
|
52
|
+
"Asia/Dubai": "Asia/Dubai";
|
|
53
|
+
"Asia/Kolkata": "Asia/Kolkata";
|
|
54
|
+
"Asia/Bangkok": "Asia/Bangkok";
|
|
55
|
+
"Asia/Singapore": "Asia/Singapore";
|
|
56
|
+
"Asia/Hong_Kong": "Asia/Hong_Kong";
|
|
57
|
+
"Asia/Tokyo": "Asia/Tokyo";
|
|
58
|
+
"Asia/Seoul": "Asia/Seoul";
|
|
59
|
+
"Australia/Sydney": "Australia/Sydney";
|
|
60
|
+
"Australia/Melbourne": "Australia/Melbourne";
|
|
61
|
+
"Pacific/Auckland": "Pacific/Auckland";
|
|
62
|
+
}>;
|
|
63
|
+
currencySymbol: z.ZodString;
|
|
64
|
+
currencyPlacement: z.ZodEnum<{
|
|
65
|
+
prefix: "prefix";
|
|
66
|
+
suffix: "suffix";
|
|
67
|
+
}>;
|
|
68
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.globalSettingsFormSchema = exports.managerRoleFormSchema = exports.channelsFormSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const atm_forms_1 = require("../../atm/schemas/atm.forms");
|
|
9
|
+
const casino_forms_1 = require("../../casino/schemas/casino.forms");
|
|
10
|
+
const prediction_forms_1 = require("../../predictions/schemas/prediction.forms");
|
|
11
|
+
const raffle_forms_1 = require("../../raffle/schemas/raffle.forms");
|
|
12
|
+
const commonTimezones_1 = require("../constants/commonTimezones");
|
|
13
|
+
exports.channelsFormSchema = zod_1.default.object({
|
|
14
|
+
atm: atm_forms_1.atmChannelsFormSchema,
|
|
15
|
+
casino: casino_forms_1.casinoChannelsFormSchema,
|
|
16
|
+
prediction: prediction_forms_1.predictionChannelsFormSchema,
|
|
17
|
+
raffle: raffle_forms_1.raffleChannelsFormSchema
|
|
18
|
+
});
|
|
19
|
+
exports.managerRoleFormSchema = zod_1.default.object({
|
|
20
|
+
managerRoleId: zod_1.default.string()
|
|
21
|
+
});
|
|
22
|
+
exports.globalSettingsFormSchema = zod_1.default.object({
|
|
23
|
+
disableRegistrations: zod_1.default.boolean(),
|
|
24
|
+
disableDeposits: zod_1.default.boolean(),
|
|
25
|
+
disableWithdrawals: zod_1.default.boolean(),
|
|
26
|
+
disableCasinoGames: zod_1.default.boolean(),
|
|
27
|
+
disableCasinoGamesForMods: zod_1.default.boolean(),
|
|
28
|
+
disablePredictions: zod_1.default.boolean(),
|
|
29
|
+
disablePredictionManagement: zod_1.default.boolean(),
|
|
30
|
+
disableRaffles: zod_1.default.boolean(),
|
|
31
|
+
disableRaffleManagement: zod_1.default.boolean(),
|
|
32
|
+
disableDailyBonus: zod_1.default.boolean(),
|
|
33
|
+
disableVip: zod_1.default.boolean(),
|
|
34
|
+
maintenanceMode: zod_1.default.boolean(),
|
|
35
|
+
timezone: zod_1.default.enum(commonTimezones_1.COMMON_TIMEZONES),
|
|
36
|
+
currencySymbol: zod_1.default
|
|
37
|
+
.string()
|
|
38
|
+
.max(8)
|
|
39
|
+
.refine((value) => value.trim().length > 0, {
|
|
40
|
+
message: 'Currency symbol is required'
|
|
41
|
+
}),
|
|
42
|
+
currencyPlacement: zod_1.default.enum(['prefix', 'suffix'])
|
|
43
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BonusSettings } from '../../bonus/types/bonus';
|
|
2
|
+
import { defaultCasinoSettings } from '../../casino/constants/defaultConfig';
|
|
2
3
|
import type { GlobalSettings } from '../constants/defaultGlobalSettings';
|
|
3
|
-
import { BonusSettings } from './bonus';
|
|
4
4
|
export type RewardMode = 'linear' | 'exponential';
|
|
5
5
|
export type TGuildConfiguration = {
|
|
6
6
|
guildId: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type GlobalSettings } from '../constants';
|
|
1
|
+
import { type GlobalSettings } from '../constants/defaultGlobalSettings';
|
|
2
2
|
export declare const normalizeGlobalSettings: (settings: Partial<GlobalSettings> | null | undefined) => GlobalSettings;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeGlobalSettings = void 0;
|
|
4
|
+
const commonTimezones_1 = require("../constants/commonTimezones");
|
|
5
|
+
const defaultGlobalSettings_1 = require("../constants/defaultGlobalSettings");
|
|
6
|
+
const coerceBool = (value, fallback) => {
|
|
7
|
+
if (typeof value === 'boolean')
|
|
8
|
+
return value;
|
|
9
|
+
if (value === 'true')
|
|
10
|
+
return true;
|
|
11
|
+
if (value === 'false')
|
|
12
|
+
return false;
|
|
13
|
+
return fallback;
|
|
14
|
+
};
|
|
15
|
+
const normalizeCurrencySymbol = (value) => {
|
|
16
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
17
|
+
return defaultGlobalSettings_1.defaultGlobalSettings.currencySymbol;
|
|
18
|
+
}
|
|
19
|
+
return value.slice(0, 8);
|
|
20
|
+
};
|
|
21
|
+
const normalizeCurrencyPlacement = (value) => value === 'suffix' ? 'suffix' : 'prefix';
|
|
22
|
+
const normalizeTimezone = (value) => {
|
|
23
|
+
const raw = typeof value === 'string' ? value.trim() : '';
|
|
24
|
+
if (raw.length > 0 && commonTimezones_1.COMMON_TIMEZONES.includes(raw)) {
|
|
25
|
+
return raw;
|
|
26
|
+
}
|
|
27
|
+
return defaultGlobalSettings_1.defaultGlobalSettings.timezone;
|
|
28
|
+
};
|
|
29
|
+
const normalizeGlobalSettings = (settings) => ({
|
|
30
|
+
disableRegistrations: coerceBool(settings?.disableRegistrations, defaultGlobalSettings_1.defaultGlobalSettings.disableRegistrations),
|
|
31
|
+
disableDeposits: coerceBool(settings?.disableDeposits, defaultGlobalSettings_1.defaultGlobalSettings.disableDeposits),
|
|
32
|
+
disableWithdrawals: coerceBool(settings?.disableWithdrawals, defaultGlobalSettings_1.defaultGlobalSettings.disableWithdrawals),
|
|
33
|
+
disableCasinoGames: coerceBool(settings?.disableCasinoGames, defaultGlobalSettings_1.defaultGlobalSettings.disableCasinoGames),
|
|
34
|
+
disableCasinoGamesForMods: coerceBool(settings?.disableCasinoGamesForMods, defaultGlobalSettings_1.defaultGlobalSettings.disableCasinoGamesForMods),
|
|
35
|
+
disablePredictions: coerceBool(settings?.disablePredictions, defaultGlobalSettings_1.defaultGlobalSettings.disablePredictions),
|
|
36
|
+
disablePredictionManagement: coerceBool(settings?.disablePredictionManagement, defaultGlobalSettings_1.defaultGlobalSettings.disablePredictionManagement),
|
|
37
|
+
disableRaffles: coerceBool(settings?.disableRaffles, defaultGlobalSettings_1.defaultGlobalSettings.disableRaffles),
|
|
38
|
+
disableRaffleManagement: coerceBool(settings?.disableRaffleManagement, defaultGlobalSettings_1.defaultGlobalSettings.disableRaffleManagement),
|
|
39
|
+
disableDailyBonus: coerceBool(settings?.disableDailyBonus, defaultGlobalSettings_1.defaultGlobalSettings.disableDailyBonus),
|
|
40
|
+
disableVip: coerceBool(settings?.disableVip, defaultGlobalSettings_1.defaultGlobalSettings.disableVip),
|
|
41
|
+
maintenanceMode: coerceBool(settings?.maintenanceMode, defaultGlobalSettings_1.defaultGlobalSettings.maintenanceMode),
|
|
42
|
+
timezone: normalizeTimezone(settings?.timezone),
|
|
43
|
+
currencySymbol: normalizeCurrencySymbol(settings?.currencySymbol),
|
|
44
|
+
currencyPlacement: normalizeCurrencyPlacement(settings?.currencyPlacement)
|
|
45
|
+
});
|
|
46
|
+
exports.normalizeGlobalSettings = normalizeGlobalSettings;
|
package/dist/mongoose/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
1
|
+
export { UserSchema } from '../user/user.mongoose';
|
|
2
|
+
export { VipRoomSchema } from '../vip/vipRoom.mongoose';
|
|
3
|
+
export { PredictionSchema } from '../predictions/prediction.mongoose';
|
|
4
|
+
export { TransactionSchema } from '../transactions/transaction.mongoose';
|
|
5
|
+
export { GuildConfigurationSchema } from '../guild/guildConfiguration.mongoose';
|
|
6
|
+
export { AtmRequestSchema } from '../atm/atmRequest.mongoose';
|
|
7
|
+
export { RaffleSchema } from '../raffle/raffle.mongoose';
|
|
8
|
+
export { BlackjackGameSchema } from '../casino/blackjackGame.mongoose';
|
package/dist/mongoose/index.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
exports.BlackjackGameSchema = exports.RaffleSchema = exports.AtmRequestSchema = exports.GuildConfigurationSchema = exports.TransactionSchema = exports.PredictionSchema = exports.VipRoomSchema = exports.UserSchema = void 0;
|
|
4
|
+
var user_mongoose_1 = require("../user/user.mongoose");
|
|
5
|
+
Object.defineProperty(exports, "UserSchema", { enumerable: true, get: function () { return user_mongoose_1.UserSchema; } });
|
|
6
|
+
var vipRoom_mongoose_1 = require("../vip/vipRoom.mongoose");
|
|
7
|
+
Object.defineProperty(exports, "VipRoomSchema", { enumerable: true, get: function () { return vipRoom_mongoose_1.VipRoomSchema; } });
|
|
8
|
+
var prediction_mongoose_1 = require("../predictions/prediction.mongoose");
|
|
9
|
+
Object.defineProperty(exports, "PredictionSchema", { enumerable: true, get: function () { return prediction_mongoose_1.PredictionSchema; } });
|
|
10
|
+
var transaction_mongoose_1 = require("../transactions/transaction.mongoose");
|
|
11
|
+
Object.defineProperty(exports, "TransactionSchema", { enumerable: true, get: function () { return transaction_mongoose_1.TransactionSchema; } });
|
|
12
|
+
var guildConfiguration_mongoose_1 = require("../guild/guildConfiguration.mongoose");
|
|
13
|
+
Object.defineProperty(exports, "GuildConfigurationSchema", { enumerable: true, get: function () { return guildConfiguration_mongoose_1.GuildConfigurationSchema; } });
|
|
14
|
+
var atmRequest_mongoose_1 = require("../atm/atmRequest.mongoose");
|
|
15
|
+
Object.defineProperty(exports, "AtmRequestSchema", { enumerable: true, get: function () { return atmRequest_mongoose_1.AtmRequestSchema; } });
|
|
16
|
+
var raffle_mongoose_1 = require("../raffle/raffle.mongoose");
|
|
17
|
+
Object.defineProperty(exports, "RaffleSchema", { enumerable: true, get: function () { return raffle_mongoose_1.RaffleSchema; } });
|
|
18
|
+
var blackjackGame_mongoose_1 = require("../casino/blackjackGame.mongoose");
|
|
19
|
+
Object.defineProperty(exports, "BlackjackGameSchema", { enumerable: true, get: function () { return blackjackGame_mongoose_1.BlackjackGameSchema; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './types/prediction';
|
|
2
|
+
export * from './utils/validatePredictionBet';
|
|
3
|
+
export * from './services/types';
|
|
4
|
+
export * from './services/parsePredictionChoices';
|
|
5
|
+
export * from './services/parsePredictionAutolock';
|
|
6
|
+
export * from './services/normalizePredictionInput';
|
|
7
|
+
export * from './services/predictionSummary';
|
|
8
|
+
export * from './services/prediction.db';
|
|
9
|
+
export * from './services/predictionLifecycle.service';
|
|
10
|
+
export * from './schemas/prediction.forms';
|
|
11
|
+
export { PredictionSchema } from './prediction.mongoose';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PredictionSchema = void 0;
|
|
18
|
+
__exportStar(require("./types/prediction"), exports);
|
|
19
|
+
__exportStar(require("./utils/validatePredictionBet"), exports);
|
|
20
|
+
__exportStar(require("./services/types"), exports);
|
|
21
|
+
__exportStar(require("./services/parsePredictionChoices"), exports);
|
|
22
|
+
__exportStar(require("./services/parsePredictionAutolock"), exports);
|
|
23
|
+
__exportStar(require("./services/normalizePredictionInput"), exports);
|
|
24
|
+
__exportStar(require("./services/predictionSummary"), exports);
|
|
25
|
+
__exportStar(require("./services/prediction.db"), exports);
|
|
26
|
+
__exportStar(require("./services/predictionLifecycle.service"), exports);
|
|
27
|
+
__exportStar(require("./schemas/prediction.forms"), exports);
|
|
28
|
+
var prediction_mongoose_1 = require("./prediction.mongoose");
|
|
29
|
+
Object.defineProperty(exports, "PredictionSchema", { enumerable: true, get: function () { return prediction_mongoose_1.PredictionSchema; } });
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { Schema } from 'mongoose';
|
|
2
|
-
import { TPrediction } from '
|
|
3
|
-
export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Model<TPrediction, any, any, any,
|
|
4
|
-
_id: import("mongoose").Types.ObjectId;
|
|
5
|
-
} & {
|
|
6
|
-
__v: number;
|
|
7
|
-
} & {
|
|
8
|
-
id: string;
|
|
9
|
-
}) | (import("mongoose").Document<unknown, any, TPrediction, any, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
10
|
-
_id: import("mongoose").Types.ObjectId;
|
|
11
|
-
} & {
|
|
12
|
-
__v: number;
|
|
13
|
-
}), any, TPrediction>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
2
|
+
import { TPrediction } from './types/prediction';
|
|
3
|
+
export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Model<TPrediction, any, any, any, any, any, TPrediction>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
14
4
|
id: string;
|
|
15
|
-
}, import("mongoose").
|
|
5
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
16
6
|
_id: import("mongoose").Types.ObjectId;
|
|
17
7
|
} & {
|
|
18
8
|
__v: number;
|
|
@@ -21,7 +11,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
21
11
|
}, {
|
|
22
12
|
predictionId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
23
13
|
id: string;
|
|
24
|
-
}, import("mongoose").
|
|
14
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
25
15
|
_id: import("mongoose").Types.ObjectId;
|
|
26
16
|
} & {
|
|
27
17
|
__v: number;
|
|
@@ -30,7 +20,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
30
20
|
}> | undefined;
|
|
31
21
|
guildId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
32
22
|
id: string;
|
|
33
|
-
}, import("mongoose").
|
|
23
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
34
24
|
_id: import("mongoose").Types.ObjectId;
|
|
35
25
|
} & {
|
|
36
26
|
__v: number;
|
|
@@ -39,7 +29,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
39
29
|
}> | undefined;
|
|
40
30
|
channelId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
41
31
|
id: string;
|
|
42
|
-
}, import("mongoose").
|
|
32
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
43
33
|
_id: import("mongoose").Types.ObjectId;
|
|
44
34
|
} & {
|
|
45
35
|
__v: number;
|
|
@@ -48,7 +38,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
48
38
|
}> | undefined;
|
|
49
39
|
creatorId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
50
40
|
id: string;
|
|
51
|
-
}, import("mongoose").
|
|
41
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
52
42
|
_id: import("mongoose").Types.ObjectId;
|
|
53
43
|
} & {
|
|
54
44
|
__v: number;
|
|
@@ -57,16 +47,16 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
57
47
|
}> | undefined;
|
|
58
48
|
title?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
59
49
|
id: string;
|
|
60
|
-
}, import("mongoose").
|
|
50
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
61
51
|
_id: import("mongoose").Types.ObjectId;
|
|
62
52
|
} & {
|
|
63
53
|
__v: number;
|
|
64
54
|
}, "id"> & {
|
|
65
55
|
id: string;
|
|
66
56
|
}> | undefined;
|
|
67
|
-
choices?: import("mongoose").SchemaDefinitionProperty<import("
|
|
57
|
+
choices?: import("mongoose").SchemaDefinitionProperty<import("./types/prediction").TPredictionOption[], TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
68
58
|
id: string;
|
|
69
|
-
}, import("mongoose").
|
|
59
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
70
60
|
_id: import("mongoose").Types.ObjectId;
|
|
71
61
|
} & {
|
|
72
62
|
__v: number;
|
|
@@ -75,7 +65,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
75
65
|
}> | undefined;
|
|
76
66
|
status?: import("mongoose").SchemaDefinitionProperty<"active" | "ended" | "paying" | "paid" | "canceled", TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
77
67
|
id: string;
|
|
78
|
-
}, import("mongoose").
|
|
68
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
79
69
|
_id: import("mongoose").Types.ObjectId;
|
|
80
70
|
} & {
|
|
81
71
|
__v: number;
|
|
@@ -84,7 +74,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
84
74
|
}> | undefined;
|
|
85
75
|
autolock?: import("mongoose").SchemaDefinitionProperty<Date | null | undefined, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
86
76
|
id: string;
|
|
87
|
-
}, import("mongoose").
|
|
77
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
88
78
|
_id: import("mongoose").Types.ObjectId;
|
|
89
79
|
} & {
|
|
90
80
|
__v: number;
|
|
@@ -93,7 +83,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
93
83
|
}> | undefined;
|
|
94
84
|
createdAt?: import("mongoose").SchemaDefinitionProperty<Date, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
95
85
|
id: string;
|
|
96
|
-
}, import("mongoose").
|
|
86
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
97
87
|
_id: import("mongoose").Types.ObjectId;
|
|
98
88
|
} & {
|
|
99
89
|
__v: number;
|
|
@@ -102,7 +92,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
|
|
|
102
92
|
}> | undefined;
|
|
103
93
|
updatedAt?: import("mongoose").SchemaDefinitionProperty<Date, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
104
94
|
id: string;
|
|
105
|
-
}, import("mongoose").
|
|
95
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
106
96
|
_id: import("mongoose").Types.ObjectId;
|
|
107
97
|
} & {
|
|
108
98
|
__v: number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const predictionChannelsFormSchema: z.ZodObject<{
|
|
3
|
+
actions: z.ZodString;
|
|
4
|
+
logs: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const predictionChoiceSchema: z.ZodObject<{
|
|
7
|
+
choiceName: z.ZodString;
|
|
8
|
+
odds: z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>, z.ZodNumber>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const createPredictionFormSchema: z.ZodObject<{
|
|
11
|
+
title: z.ZodString;
|
|
12
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
13
|
+
choiceName: z.ZodString;
|
|
14
|
+
odds: z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>, z.ZodNumber>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
autolock: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export declare const payoutPredictionFormSchema: z.ZodObject<{
|
|
19
|
+
winnerChoice: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.payoutPredictionFormSchema = exports.createPredictionFormSchema = exports.predictionChoiceSchema = exports.predictionChannelsFormSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const zod_2 = require("../../common/zod");
|
|
9
|
+
exports.predictionChannelsFormSchema = zod_1.default.object({
|
|
10
|
+
actions: zod_1.default.string(),
|
|
11
|
+
logs: zod_1.default.string()
|
|
12
|
+
});
|
|
13
|
+
exports.predictionChoiceSchema = zod_1.default.object({
|
|
14
|
+
choiceName: zod_1.default.string().min(1),
|
|
15
|
+
odds: zod_2.num.pipe(zod_1.default.number().positive())
|
|
16
|
+
});
|
|
17
|
+
exports.createPredictionFormSchema = zod_1.default.object({
|
|
18
|
+
title: zod_1.default.string().min(1).max(256),
|
|
19
|
+
choices: zod_1.default.array(exports.predictionChoiceSchema).min(2).max(3),
|
|
20
|
+
autolock: zod_1.default.string().optional()
|
|
21
|
+
});
|
|
22
|
+
exports.payoutPredictionFormSchema = zod_1.default.object({
|
|
23
|
+
winnerChoice: zod_1.default.string().min(1)
|
|
24
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TPredictionOption } from '../types/prediction';
|
|
2
|
+
import { parsePredictionAutolock } from './parsePredictionAutolock';
|
|
3
|
+
import { parsePredictionChoices } from './parsePredictionChoices';
|
|
4
|
+
export type PredictionChoiceInput = string | Pick<TPredictionOption, 'choiceName' | 'odds'>[];
|
|
5
|
+
export declare function normalizePredictionChoices(input: PredictionChoiceInput): ReturnType<typeof parsePredictionChoices>;
|
|
6
|
+
export declare function normalizePredictionAutolock(input: string, format: 'iso' | 'discord'): ReturnType<typeof parsePredictionAutolock>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePredictionChoices = normalizePredictionChoices;
|
|
4
|
+
exports.normalizePredictionAutolock = normalizePredictionAutolock;
|
|
5
|
+
const luxon_1 = require("luxon");
|
|
6
|
+
const parsePredictionAutolock_1 = require("./parsePredictionAutolock");
|
|
7
|
+
const parsePredictionChoices_1 = require("./parsePredictionChoices");
|
|
8
|
+
function normalizePredictionChoices(input) {
|
|
9
|
+
if (typeof input === 'string') {
|
|
10
|
+
return (0, parsePredictionChoices_1.parsePredictionChoices)(input);
|
|
11
|
+
}
|
|
12
|
+
if (input.length < 2 || input.length > 3) {
|
|
13
|
+
return { ok: false, error: 'INVALID_COUNT' };
|
|
14
|
+
}
|
|
15
|
+
for (const choice of input) {
|
|
16
|
+
if (!choice.choiceName?.trim() ||
|
|
17
|
+
typeof choice.odds !== 'number' ||
|
|
18
|
+
Number.isNaN(choice.odds) ||
|
|
19
|
+
choice.odds <= 0) {
|
|
20
|
+
return {
|
|
21
|
+
ok: false,
|
|
22
|
+
error: 'INVALID_FORMAT',
|
|
23
|
+
detail: choice.choiceName
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
ok: true,
|
|
29
|
+
choices: input.map((choice) => ({
|
|
30
|
+
choiceName: choice.choiceName.trim(),
|
|
31
|
+
odds: choice.odds,
|
|
32
|
+
bets: []
|
|
33
|
+
}))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function normalizePredictionAutolock(input, format) {
|
|
37
|
+
if (format === 'discord') {
|
|
38
|
+
return (0, parsePredictionAutolock_1.parsePredictionAutolock)(input);
|
|
39
|
+
}
|
|
40
|
+
const trimmed = input.trim();
|
|
41
|
+
if (!trimmed) {
|
|
42
|
+
return { ok: false, error: 'INVALID_FORMAT' };
|
|
43
|
+
}
|
|
44
|
+
const parsed = luxon_1.DateTime.fromISO(trimmed, { zone: 'utc' });
|
|
45
|
+
if (!parsed.isValid) {
|
|
46
|
+
return { ok: false, error: 'INVALID_DATE' };
|
|
47
|
+
}
|
|
48
|
+
const autolock = parsed.toJSDate();
|
|
49
|
+
if (autolock.getTime() <= Date.now()) {
|
|
50
|
+
return { ok: false, error: 'PAST_DATE' };
|
|
51
|
+
}
|
|
52
|
+
return { ok: true, autolock };
|
|
53
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ParsePredictionAutolockError = 'INVALID_FORMAT' | 'INVALID_DATE' | 'PAST_DATE';
|
|
2
|
+
export type ParsePredictionAutolockResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
autolock: Date;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
error: ParsePredictionAutolockError;
|
|
8
|
+
};
|
|
9
|
+
export declare function parsePredictionAutolock(input: string, timezone?: string): ParsePredictionAutolockResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePredictionAutolock = parsePredictionAutolock;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
5
|
+
const AUTOLOCK_REGEX = /^(\d{1,2})\.(\d{1,2})\.(\d{4}) (\d{2}):(\d{2})$/;
|
|
6
|
+
function parsePredictionAutolock(input, timezone = 'Europe/Prague') {
|
|
7
|
+
const match = input.match(AUTOLOCK_REGEX);
|
|
8
|
+
if (!match) {
|
|
9
|
+
return { ok: false, error: 'INVALID_FORMAT' };
|
|
10
|
+
}
|
|
11
|
+
const [, day, month, year, hour, minute] = match.map(Number);
|
|
12
|
+
const dt = luxon_1.DateTime.fromObject({ year, month, day, hour, minute }, { zone: timezone });
|
|
13
|
+
if (!dt.isValid) {
|
|
14
|
+
return { ok: false, error: 'INVALID_DATE' };
|
|
15
|
+
}
|
|
16
|
+
if (dt.toMillis() <= Date.now()) {
|
|
17
|
+
return { ok: false, error: 'PAST_DATE' };
|
|
18
|
+
}
|
|
19
|
+
return { ok: true, autolock: dt.toJSDate() };
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TPredictionOption } from '../types/prediction';
|
|
2
|
+
export type ParsePredictionChoicesError = 'INVALID_COUNT' | 'INVALID_FORMAT';
|
|
3
|
+
export type ParsePredictionChoicesResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
choices: TPredictionOption[];
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
error: ParsePredictionChoicesError;
|
|
9
|
+
detail?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function parsePredictionChoices(input: string): ParsePredictionChoicesResult;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePredictionChoices = parsePredictionChoices;
|
|
4
|
+
function parsePredictionChoices(input) {
|
|
5
|
+
const rawChoices = input.split(',').map((c) => c.trim());
|
|
6
|
+
if (rawChoices.length < 2 || rawChoices.length > 3) {
|
|
7
|
+
return { ok: false, error: 'INVALID_COUNT' };
|
|
8
|
+
}
|
|
9
|
+
const choicesArray = [];
|
|
10
|
+
for (const item of rawChoices) {
|
|
11
|
+
const [name, odds] = item.split(':').map((x) => x.trim());
|
|
12
|
+
if (!name || !odds || Number.isNaN(Number(odds))) {
|
|
13
|
+
return {
|
|
14
|
+
ok: false,
|
|
15
|
+
error: 'INVALID_FORMAT',
|
|
16
|
+
detail: item
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
choicesArray.push({
|
|
20
|
+
choiceName: name,
|
|
21
|
+
odds: Number(odds),
|
|
22
|
+
bets: []
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return { ok: true, choices: choicesArray };
|
|
26
|
+
}
|