gambling-bot-shared 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atm/atmRequest.mongoose.d.ts +147 -0
- package/dist/atm/index.d.ts +2 -0
- package/dist/atm/index.js +0 -3
- package/dist/atm/schemas/atm.forms.d.ts +5 -0
- package/dist/atm/types/atmRequest.d.ts +17 -0
- package/dist/blackjack/index.d.ts +2 -0
- package/dist/blackjack/index.js +0 -3
- package/dist/bonus/constants/bonusLimits.d.ts +4 -0
- package/dist/bonus/index.d.ts +7 -0
- package/dist/bonus/schemas/bonus.forms.d.ts +16 -0
- package/dist/bonus/types/bonus.d.ts +13 -0
- package/dist/bonus/utils/bonusStreak.d.ts +7 -0
- package/dist/bonus/utils/calculateBonusReward.d.ts +14 -0
- package/dist/bonus/utils/generateBonusPreview.d.ts +11 -0
- package/dist/bonus/utils/normalizeBonusSettings.d.ts +6 -0
- package/dist/casino/blackjackGame.mongoose.d.ts +129 -0
- package/dist/casino/constants/blackjack.d.ts +41 -0
- package/dist/casino/constants/casinoGames.d.ts +3 -0
- package/dist/casino/constants/defaultConfig.d.ts +108 -0
- package/dist/casino/constants/index.d.ts +7 -0
- package/dist/casino/constants/lotteryConfig.d.ts +2 -0
- package/dist/casino/constants/maxSimulations.d.ts +5 -0
- package/dist/casino/constants/plinkoConfig.d.ts +15 -0
- package/dist/casino/constants/rouletteConfig.d.ts +1 -0
- package/dist/casino/index.d.ts +11 -0
- package/dist/casino/index.js +0 -3
- package/dist/casino/schemas/casino.forms.d.ts +80 -0
- package/dist/casino/services/casinoBet.service.d.ts +41 -0
- package/dist/casino/types/blackjackGame.d.ts +30 -0
- package/dist/casino/types/casinoSettings.d.ts +2 -0
- package/dist/casino/utils/calculateRTP.d.ts +2 -0
- package/dist/casino/utils/normalizeCasinoSettings.d.ts +2 -0
- package/dist/casino/utils/validateBetAmount.d.ts +8 -0
- package/dist/casino/utils/winAnnouncements.d.ts +4 -0
- package/dist/common/formatters.d.ts +16 -0
- package/dist/common/generateId.d.ts +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/parseTimeToSeconds.d.ts +1 -0
- package/dist/common/zod.d.ts +2 -0
- package/dist/guild/constants/commonTimezones.d.ts +4 -0
- package/dist/guild/constants/defaultGlobalSettings.d.ts +20 -0
- package/dist/guild/guildConfiguration.mongoose.d.ts +227 -0
- package/dist/guild/index.d.ts +7 -0
- package/dist/guild/index.js +0 -3
- package/dist/guild/schemas/guild.forms.d.ts +68 -0
- package/dist/guild/types/guildConfiguration.d.ts +35 -0
- package/dist/guild/utils/globalSettings.d.ts +6 -0
- package/dist/guild/utils/guildTimezone.d.ts +6 -0
- package/dist/guild/utils/normalizeGlobalSettings.d.ts +2 -0
- package/dist/mongoose/index.d.ts +8 -0
- package/dist/predictions/index.d.ts +10 -0
- package/dist/predictions/index.js +0 -3
- package/dist/predictions/prediction.mongoose.d.ts +102 -0
- package/dist/predictions/schemas/prediction.forms.d.ts +20 -0
- package/dist/predictions/services/normalizePredictionInput.d.ts +6 -0
- package/dist/predictions/services/parsePredictionAutolock.d.ts +9 -0
- package/dist/predictions/services/parsePredictionChoices.d.ts +11 -0
- package/dist/predictions/services/prediction.db.d.ts +55 -0
- package/dist/predictions/services/predictionLifecycle.service.d.ts +25 -0
- package/dist/predictions/services/predictionSummary.d.ts +30 -0
- package/dist/predictions/services/types.d.ts +27 -0
- package/dist/predictions/types/prediction.d.ts +21 -0
- package/dist/predictions/utils/validatePredictionBet.d.ts +13 -0
- package/dist/raffle/index.d.ts +5 -0
- package/dist/raffle/index.js +0 -3
- package/dist/raffle/raffle.mongoose.d.ts +138 -0
- package/dist/raffle/schemas/raffle.forms.d.ts +11 -0
- package/dist/raffle/services/raffle.db.d.ts +51 -0
- package/dist/raffle/services/raffleLifecycle.service.d.ts +15 -0
- package/dist/raffle/services/types.d.ts +27 -0
- package/dist/raffle/types/raffle.d.ts +21 -0
- package/dist/transactions/constants/gameRecordFields.d.ts +8 -0
- package/dist/transactions/constants/index.d.ts +2 -0
- package/dist/transactions/constants/transaction.d.ts +2 -0
- package/dist/transactions/index.d.ts +4 -0
- package/dist/transactions/transaction.mongoose.d.ts +93 -0
- package/dist/transactions/types/transaction.d.ts +15 -0
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +0 -3
- package/dist/user/types/user.d.ts +11 -0
- package/dist/user/user.mongoose.d.ts +93 -0
- package/dist/vip/index.d.ts +2 -0
- package/dist/vip/index.js +0 -3
- package/dist/vip/schemas/vip.forms.d.ts +10 -0
- package/dist/vip/types/vipRoom.d.ts +9 -0
- package/dist/vip/vipRoom.mongoose.d.ts +75 -0
- package/package.json +1 -1
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PredictionSchema = void 0;
|
|
18
17
|
__exportStar(require("./types/prediction"), exports);
|
|
19
18
|
__exportStar(require("./utils/validatePredictionBet"), exports);
|
|
20
19
|
__exportStar(require("./services/types"), exports);
|
|
@@ -25,5 +24,3 @@ __exportStar(require("./services/predictionSummary"), exports);
|
|
|
25
24
|
__exportStar(require("./services/prediction.db"), exports);
|
|
26
25
|
__exportStar(require("./services/predictionLifecycle.service"), exports);
|
|
27
26
|
__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; } });
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
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, {
|
|
4
|
+
id: string;
|
|
5
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
6
|
+
_id: import("mongoose").Types.ObjectId;
|
|
7
|
+
} & {
|
|
8
|
+
__v: number;
|
|
9
|
+
}, "id"> & {
|
|
10
|
+
id: string;
|
|
11
|
+
}, {
|
|
12
|
+
predictionId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
13
|
+
id: string;
|
|
14
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
15
|
+
_id: import("mongoose").Types.ObjectId;
|
|
16
|
+
} & {
|
|
17
|
+
__v: number;
|
|
18
|
+
}, "id"> & {
|
|
19
|
+
id: string;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
guildId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
22
|
+
id: string;
|
|
23
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
} & {
|
|
26
|
+
__v: number;
|
|
27
|
+
}, "id"> & {
|
|
28
|
+
id: string;
|
|
29
|
+
}> | undefined;
|
|
30
|
+
channelId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
31
|
+
id: string;
|
|
32
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
33
|
+
_id: import("mongoose").Types.ObjectId;
|
|
34
|
+
} & {
|
|
35
|
+
__v: number;
|
|
36
|
+
}, "id"> & {
|
|
37
|
+
id: string;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
creatorId?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
40
|
+
id: string;
|
|
41
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
42
|
+
_id: import("mongoose").Types.ObjectId;
|
|
43
|
+
} & {
|
|
44
|
+
__v: number;
|
|
45
|
+
}, "id"> & {
|
|
46
|
+
id: string;
|
|
47
|
+
}> | undefined;
|
|
48
|
+
title?: import("mongoose").SchemaDefinitionProperty<string, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
49
|
+
id: string;
|
|
50
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
51
|
+
_id: import("mongoose").Types.ObjectId;
|
|
52
|
+
} & {
|
|
53
|
+
__v: number;
|
|
54
|
+
}, "id"> & {
|
|
55
|
+
id: string;
|
|
56
|
+
}> | undefined;
|
|
57
|
+
choices?: import("mongoose").SchemaDefinitionProperty<import("./types/prediction").TPredictionOption[], TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
58
|
+
id: string;
|
|
59
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
60
|
+
_id: import("mongoose").Types.ObjectId;
|
|
61
|
+
} & {
|
|
62
|
+
__v: number;
|
|
63
|
+
}, "id"> & {
|
|
64
|
+
id: string;
|
|
65
|
+
}> | undefined;
|
|
66
|
+
status?: import("mongoose").SchemaDefinitionProperty<"active" | "ended" | "paying" | "paid" | "canceled", TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
67
|
+
id: string;
|
|
68
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
69
|
+
_id: import("mongoose").Types.ObjectId;
|
|
70
|
+
} & {
|
|
71
|
+
__v: number;
|
|
72
|
+
}, "id"> & {
|
|
73
|
+
id: string;
|
|
74
|
+
}> | undefined;
|
|
75
|
+
autolock?: import("mongoose").SchemaDefinitionProperty<Date | null | undefined, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
76
|
+
id: string;
|
|
77
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
78
|
+
_id: import("mongoose").Types.ObjectId;
|
|
79
|
+
} & {
|
|
80
|
+
__v: number;
|
|
81
|
+
}, "id"> & {
|
|
82
|
+
id: string;
|
|
83
|
+
}> | undefined;
|
|
84
|
+
createdAt?: import("mongoose").SchemaDefinitionProperty<Date, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
85
|
+
id: string;
|
|
86
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
87
|
+
_id: import("mongoose").Types.ObjectId;
|
|
88
|
+
} & {
|
|
89
|
+
__v: number;
|
|
90
|
+
}, "id"> & {
|
|
91
|
+
id: string;
|
|
92
|
+
}> | undefined;
|
|
93
|
+
updatedAt?: import("mongoose").SchemaDefinitionProperty<Date, TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
|
|
94
|
+
id: string;
|
|
95
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TPrediction & {
|
|
96
|
+
_id: import("mongoose").Types.ObjectId;
|
|
97
|
+
} & {
|
|
98
|
+
__v: number;
|
|
99
|
+
}, "id"> & {
|
|
100
|
+
id: string;
|
|
101
|
+
}> | undefined;
|
|
102
|
+
}, TPrediction>;
|
|
@@ -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,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,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,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,55 @@
|
|
|
1
|
+
import type { Model } from 'mongoose';
|
|
2
|
+
import type { TPrediction } from '../types/prediction';
|
|
3
|
+
import type { TAddPredictionBet, TCreatePrediction, TGetOldPredictions, TGetPrediction, TUpdatePredictionStatus } from './types';
|
|
4
|
+
export declare function createPredictionDb(predictionModel: Model<TPrediction>): {
|
|
5
|
+
getPredictionById: ({ predictionId, guildId }: TGetPrediction) => Promise<(import("mongoose").Document<unknown, {}, TPrediction, {}, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
6
|
+
_id: import("mongoose").Types.ObjectId;
|
|
7
|
+
} & {
|
|
8
|
+
__v: number;
|
|
9
|
+
} & {
|
|
10
|
+
id: string;
|
|
11
|
+
}) | null>;
|
|
12
|
+
getPredictionToLock: ({ status, useAutolock }: {
|
|
13
|
+
status?: TPrediction["status"];
|
|
14
|
+
useAutolock?: boolean;
|
|
15
|
+
}) => Promise<(import("mongoose").Document<unknown, {}, TPrediction, {}, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
16
|
+
_id: import("mongoose").Types.ObjectId;
|
|
17
|
+
} & {
|
|
18
|
+
__v: number;
|
|
19
|
+
} & {
|
|
20
|
+
id: string;
|
|
21
|
+
})[]>;
|
|
22
|
+
getOldPredictions: ({ statuses, olderThanDays }: TGetOldPredictions) => Promise<(import("mongoose").Document<unknown, {}, TPrediction, {}, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
23
|
+
_id: import("mongoose").Types.ObjectId;
|
|
24
|
+
} & {
|
|
25
|
+
__v: number;
|
|
26
|
+
} & {
|
|
27
|
+
id: string;
|
|
28
|
+
})[]>;
|
|
29
|
+
createPrediction: ({ predictionId, guildId, channelId, creatorId, title, choices, autolock, status }: TCreatePrediction) => Promise<void>;
|
|
30
|
+
updatePredictionStatus: ({ predictionId, guildId, fromStatus, toStatus }: TUpdatePredictionStatus) => Promise<(import("mongoose").Document<unknown, {}, TPrediction, {}, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
31
|
+
_id: import("mongoose").Types.ObjectId;
|
|
32
|
+
} & {
|
|
33
|
+
__v: number;
|
|
34
|
+
} & {
|
|
35
|
+
id: string;
|
|
36
|
+
}) | null>;
|
|
37
|
+
deletePrediction: ({ predictionId }: {
|
|
38
|
+
predictionId: string;
|
|
39
|
+
}) => Promise<void>;
|
|
40
|
+
findPredictions: (query: Record<string, unknown>) => Promise<(import("mongoose").Document<unknown, {}, TPrediction, {}, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
41
|
+
_id: import("mongoose").Types.ObjectId;
|
|
42
|
+
} & {
|
|
43
|
+
__v: number;
|
|
44
|
+
} & {
|
|
45
|
+
id: string;
|
|
46
|
+
})[]>;
|
|
47
|
+
addPredictionBet: ({ predictionId, guildId, choiceName, userId, amount, betId }: TAddPredictionBet) => Promise<(import("mongoose").Document<unknown, {}, TPrediction, {}, import("mongoose").DefaultSchemaOptions> & TPrediction & {
|
|
48
|
+
_id: import("mongoose").Types.ObjectId;
|
|
49
|
+
} & {
|
|
50
|
+
__v: number;
|
|
51
|
+
} & {
|
|
52
|
+
id: string;
|
|
53
|
+
}) | null>;
|
|
54
|
+
};
|
|
55
|
+
export type PredictionDb = ReturnType<typeof createPredictionDb>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CasinoBetService } from '../../casino/services/casinoBet.service';
|
|
2
|
+
import type { TPrediction } from '../types/prediction';
|
|
3
|
+
import type { PredictionDb } from './prediction.db';
|
|
4
|
+
import type { PayPredictionResult } from './types';
|
|
5
|
+
type PredictionLifecycleDeps = {
|
|
6
|
+
predictionDb: PredictionDb;
|
|
7
|
+
casinoBet: Pick<CasinoBetService, 'refundLockedBet' | 'settleCasinoWinnings'>;
|
|
8
|
+
};
|
|
9
|
+
export declare function createPredictionLifecycleService({ predictionDb, casinoBet }: PredictionLifecycleDeps): {
|
|
10
|
+
endPrediction: ({ predictionId, guildId }: {
|
|
11
|
+
predictionId: string;
|
|
12
|
+
guildId: string;
|
|
13
|
+
}) => Promise<TPrediction | null>;
|
|
14
|
+
cancelPrediction: ({ predictionId, guildId }: {
|
|
15
|
+
predictionId: string;
|
|
16
|
+
guildId: string;
|
|
17
|
+
}) => Promise<TPrediction | null>;
|
|
18
|
+
payoutPrediction: ({ predictionId, guildId, winnerChoice }: {
|
|
19
|
+
predictionId: string;
|
|
20
|
+
guildId: string;
|
|
21
|
+
winnerChoice: string;
|
|
22
|
+
}) => Promise<PayPredictionResult>;
|
|
23
|
+
};
|
|
24
|
+
export type PredictionLifecycleService = ReturnType<typeof createPredictionLifecycleService>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TPrediction } from '../types/prediction';
|
|
2
|
+
export declare function resolvePredictionBetId(bet: TPrediction['choices'][number]['bets'][number], predictionId: string): string;
|
|
3
|
+
export type PredictionChoiceSummary = {
|
|
4
|
+
choiceName: string;
|
|
5
|
+
odds: number;
|
|
6
|
+
betCount: number;
|
|
7
|
+
totalBetAmount: number;
|
|
8
|
+
payoutIfWins: number;
|
|
9
|
+
bets: TPrediction['choices'][number]['bets'];
|
|
10
|
+
};
|
|
11
|
+
export type PredictionCheckSummary = {
|
|
12
|
+
totalBetAmount: number;
|
|
13
|
+
bettorCount: number;
|
|
14
|
+
choices: PredictionChoiceSummary[];
|
|
15
|
+
};
|
|
16
|
+
export declare function getPredictionCheckSummary(prediction: TPrediction): PredictionCheckSummary;
|
|
17
|
+
export type PayoutBetSummary = {
|
|
18
|
+
userId: string;
|
|
19
|
+
betAmount: number;
|
|
20
|
+
winAmount: number;
|
|
21
|
+
};
|
|
22
|
+
export type PredictionPayoutSummary = {
|
|
23
|
+
participants: number;
|
|
24
|
+
winners: PayoutBetSummary[];
|
|
25
|
+
losers: PayoutBetSummary[];
|
|
26
|
+
totalWon: number;
|
|
27
|
+
totalLost: number;
|
|
28
|
+
casinoProfit: number;
|
|
29
|
+
};
|
|
30
|
+
export declare function calculatePredictionPayoutSummary(prediction: TPrediction, winnerChoice: string): PredictionPayoutSummary | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TPrediction, TPredictionOption } from '../types/prediction';
|
|
2
|
+
export type TCreatePrediction = Omit<TPrediction, 'createdAt' | 'updatedAt'>;
|
|
3
|
+
export type TGetPrediction = Pick<TPrediction, 'predictionId' | 'guildId'>;
|
|
4
|
+
export type TGetOldPredictions = {
|
|
5
|
+
statuses: TPrediction['status'][];
|
|
6
|
+
olderThanDays: number;
|
|
7
|
+
};
|
|
8
|
+
export type TUpdatePredictionStatus = Pick<TPrediction, 'predictionId' | 'guildId'> & {
|
|
9
|
+
fromStatus: TPrediction['status'] | TPrediction['status'][];
|
|
10
|
+
toStatus: TPrediction['status'];
|
|
11
|
+
};
|
|
12
|
+
export type TAddPredictionBet = Pick<TPrediction, 'predictionId' | 'guildId'> & {
|
|
13
|
+
choiceName: TPredictionOption['choiceName'];
|
|
14
|
+
userId: TPredictionOption['bets'][number]['userId'];
|
|
15
|
+
amount: TPredictionOption['bets'][number]['amount'];
|
|
16
|
+
betId: TPredictionOption['bets'][number]['betId'];
|
|
17
|
+
};
|
|
18
|
+
export type PayPredictionResult = {
|
|
19
|
+
ok: true;
|
|
20
|
+
outcome: 'paid' | 'refunded';
|
|
21
|
+
prediction: TPrediction;
|
|
22
|
+
winnerChoice?: string;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
code: 'NOT_FOUND' | 'INVALID_STATUS' | 'ALREADY_HANDLED' | 'INVALID_WINNER';
|
|
26
|
+
};
|
|
27
|
+
export type PredictionLifecycleErrorCode = 'NOT_FOUND' | 'INVALID_STATUS' | 'ALREADY_HANDLED';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TPredictionOption = {
|
|
2
|
+
choiceName: string;
|
|
3
|
+
odds: number;
|
|
4
|
+
bets: {
|
|
5
|
+
userId: string;
|
|
6
|
+
amount: number;
|
|
7
|
+
betId: string;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export type TPrediction = {
|
|
11
|
+
predictionId: string;
|
|
12
|
+
guildId: string;
|
|
13
|
+
channelId: string;
|
|
14
|
+
creatorId: string;
|
|
15
|
+
title: string;
|
|
16
|
+
choices: TPredictionOption[];
|
|
17
|
+
status: 'active' | 'ended' | 'paying' | 'paid' | 'canceled';
|
|
18
|
+
autolock?: Date | null;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PredictionBetValidationError = 'BELOW_MIN_BET' | 'ABOVE_MAX_PER_CHOICE';
|
|
2
|
+
export type PredictionBetValidationResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
} | {
|
|
5
|
+
ok: false;
|
|
6
|
+
error: PredictionBetValidationError;
|
|
7
|
+
};
|
|
8
|
+
export declare const validatePredictionChoiceBet: ({ userChoiceTotal, parsedBetAmount, maxBet, minBet }: {
|
|
9
|
+
userChoiceTotal: number;
|
|
10
|
+
parsedBetAmount: number;
|
|
11
|
+
maxBet: number;
|
|
12
|
+
minBet: number;
|
|
13
|
+
}) => PredictionBetValidationResult;
|
package/dist/raffle/index.js
CHANGED
|
@@ -14,11 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.RaffleSchema = void 0;
|
|
18
17
|
__exportStar(require("./types/raffle"), exports);
|
|
19
18
|
__exportStar(require("./services/types"), exports);
|
|
20
19
|
__exportStar(require("./services/raffle.db"), exports);
|
|
21
20
|
__exportStar(require("./services/raffleLifecycle.service"), exports);
|
|
22
21
|
__exportStar(require("./schemas/raffle.forms"), exports);
|
|
23
|
-
var raffle_mongoose_1 = require("./raffle.mongoose");
|
|
24
|
-
Object.defineProperty(exports, "RaffleSchema", { enumerable: true, get: function () { return raffle_mongoose_1.RaffleSchema; } });
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
import { TRaffle } from './types/raffle';
|
|
3
|
+
export declare const RaffleSchema: Schema<TRaffle, import("mongoose").Model<TRaffle, any, any, any, any, any, TRaffle>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
4
|
+
id: string;
|
|
5
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
6
|
+
_id: import("mongoose").Types.ObjectId;
|
|
7
|
+
} & {
|
|
8
|
+
__v: number;
|
|
9
|
+
}, "id"> & {
|
|
10
|
+
id: string;
|
|
11
|
+
}, {
|
|
12
|
+
drawId?: import("mongoose").SchemaDefinitionProperty<string, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
13
|
+
id: string;
|
|
14
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
15
|
+
_id: import("mongoose").Types.ObjectId;
|
|
16
|
+
} & {
|
|
17
|
+
__v: number;
|
|
18
|
+
}, "id"> & {
|
|
19
|
+
id: string;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
raffleId?: import("mongoose").SchemaDefinitionProperty<string, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
22
|
+
id: string;
|
|
23
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
} & {
|
|
26
|
+
__v: number;
|
|
27
|
+
}, "id"> & {
|
|
28
|
+
id: string;
|
|
29
|
+
}> | undefined;
|
|
30
|
+
guildId?: import("mongoose").SchemaDefinitionProperty<string, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
31
|
+
id: string;
|
|
32
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
33
|
+
_id: import("mongoose").Types.ObjectId;
|
|
34
|
+
} & {
|
|
35
|
+
__v: number;
|
|
36
|
+
}, "id"> & {
|
|
37
|
+
id: string;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
channelId?: import("mongoose").SchemaDefinitionProperty<string, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
40
|
+
id: string;
|
|
41
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
42
|
+
_id: import("mongoose").Types.ObjectId;
|
|
43
|
+
} & {
|
|
44
|
+
__v: number;
|
|
45
|
+
}, "id"> & {
|
|
46
|
+
id: string;
|
|
47
|
+
}> | undefined;
|
|
48
|
+
creatorId?: import("mongoose").SchemaDefinitionProperty<string, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
49
|
+
id: string;
|
|
50
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
51
|
+
_id: import("mongoose").Types.ObjectId;
|
|
52
|
+
} & {
|
|
53
|
+
__v: number;
|
|
54
|
+
}, "id"> & {
|
|
55
|
+
id: string;
|
|
56
|
+
}> | undefined;
|
|
57
|
+
ticketPrice?: import("mongoose").SchemaDefinitionProperty<number, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
58
|
+
id: string;
|
|
59
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
60
|
+
_id: import("mongoose").Types.ObjectId;
|
|
61
|
+
} & {
|
|
62
|
+
__v: number;
|
|
63
|
+
}, "id"> & {
|
|
64
|
+
id: string;
|
|
65
|
+
}> | undefined;
|
|
66
|
+
maxTicketsPerUser?: import("mongoose").SchemaDefinitionProperty<number, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
67
|
+
id: string;
|
|
68
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
69
|
+
_id: import("mongoose").Types.ObjectId;
|
|
70
|
+
} & {
|
|
71
|
+
__v: number;
|
|
72
|
+
}, "id"> & {
|
|
73
|
+
id: string;
|
|
74
|
+
}> | undefined;
|
|
75
|
+
nextDrawAt?: import("mongoose").SchemaDefinitionProperty<Date, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
76
|
+
id: string;
|
|
77
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
78
|
+
_id: import("mongoose").Types.ObjectId;
|
|
79
|
+
} & {
|
|
80
|
+
__v: number;
|
|
81
|
+
}, "id"> & {
|
|
82
|
+
id: string;
|
|
83
|
+
}> | undefined;
|
|
84
|
+
lastDrawAt?: import("mongoose").SchemaDefinitionProperty<Date | undefined, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
85
|
+
id: string;
|
|
86
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
87
|
+
_id: import("mongoose").Types.ObjectId;
|
|
88
|
+
} & {
|
|
89
|
+
__v: number;
|
|
90
|
+
}, "id"> & {
|
|
91
|
+
id: string;
|
|
92
|
+
}> | undefined;
|
|
93
|
+
drawIntervalMs?: import("mongoose").SchemaDefinitionProperty<number, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
94
|
+
id: string;
|
|
95
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
96
|
+
_id: import("mongoose").Types.ObjectId;
|
|
97
|
+
} & {
|
|
98
|
+
__v: number;
|
|
99
|
+
}, "id"> & {
|
|
100
|
+
id: string;
|
|
101
|
+
}> | undefined;
|
|
102
|
+
status?: import("mongoose").SchemaDefinitionProperty<import("./types/raffle").TRaffleStatus, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
103
|
+
id: string;
|
|
104
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
105
|
+
_id: import("mongoose").Types.ObjectId;
|
|
106
|
+
} & {
|
|
107
|
+
__v: number;
|
|
108
|
+
}, "id"> & {
|
|
109
|
+
id: string;
|
|
110
|
+
}> | undefined;
|
|
111
|
+
participants?: import("mongoose").SchemaDefinitionProperty<import("./types/raffle").TRaffleParticipant[], TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
112
|
+
id: string;
|
|
113
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
114
|
+
_id: import("mongoose").Types.ObjectId;
|
|
115
|
+
} & {
|
|
116
|
+
__v: number;
|
|
117
|
+
}, "id"> & {
|
|
118
|
+
id: string;
|
|
119
|
+
}> | undefined;
|
|
120
|
+
createdAt?: import("mongoose").SchemaDefinitionProperty<Date, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
121
|
+
id: string;
|
|
122
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
123
|
+
_id: import("mongoose").Types.ObjectId;
|
|
124
|
+
} & {
|
|
125
|
+
__v: number;
|
|
126
|
+
}, "id"> & {
|
|
127
|
+
id: string;
|
|
128
|
+
}> | undefined;
|
|
129
|
+
updatedAt?: import("mongoose").SchemaDefinitionProperty<Date, TRaffle, import("mongoose").Document<unknown, {}, TRaffle, {
|
|
130
|
+
id: string;
|
|
131
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TRaffle & {
|
|
132
|
+
_id: import("mongoose").Types.ObjectId;
|
|
133
|
+
} & {
|
|
134
|
+
__v: number;
|
|
135
|
+
}, "id"> & {
|
|
136
|
+
id: string;
|
|
137
|
+
}> | undefined;
|
|
138
|
+
}, TRaffle>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const raffleChannelsFormSchema: z.ZodObject<{
|
|
3
|
+
actions: z.ZodString;
|
|
4
|
+
logs: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const raffleCreateFormSchema: z.ZodObject<{
|
|
7
|
+
ticketPrice: z.ZodString;
|
|
8
|
+
maxTickets: z.ZodNumber;
|
|
9
|
+
drawTime: z.ZodString;
|
|
10
|
+
interval: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Model } from 'mongoose';
|
|
2
|
+
import type { TRaffle } from '../types/raffle';
|
|
3
|
+
import type { TAddRaffleTickets, TUpsertRaffle } from './types';
|
|
4
|
+
export declare function createRaffleDb(raffleModel: Model<TRaffle>): {
|
|
5
|
+
getRaffleById: ({ raffleId, guildId }: {
|
|
6
|
+
raffleId: string;
|
|
7
|
+
guildId: string;
|
|
8
|
+
}) => Promise<(import("mongoose").Document<unknown, {}, TRaffle, {}, import("mongoose").DefaultSchemaOptions> & TRaffle & {
|
|
9
|
+
_id: import("mongoose").Types.ObjectId;
|
|
10
|
+
} & {
|
|
11
|
+
__v: number;
|
|
12
|
+
} & {
|
|
13
|
+
id: string;
|
|
14
|
+
}) | null>;
|
|
15
|
+
upsertRaffle: ({ guildId, drawId, raffleId, creatorId, channelId, ticketPrice, maxTicketsPerUser, nextDrawAt, drawIntervalMs }: TUpsertRaffle) => Promise<import("mongoose").Document<unknown, {}, TRaffle, {}, import("mongoose").DefaultSchemaOptions> & TRaffle & {
|
|
16
|
+
_id: import("mongoose").Types.ObjectId;
|
|
17
|
+
} & {
|
|
18
|
+
__v: number;
|
|
19
|
+
} & {
|
|
20
|
+
id: string;
|
|
21
|
+
}>;
|
|
22
|
+
addRaffleTickets: ({ raffleId, guildId, userId, tickets, maxTicketsPerUser }: TAddRaffleTickets) => Promise<boolean>;
|
|
23
|
+
cancelRaffleAtomic: ({ raffleId, guildId }: {
|
|
24
|
+
raffleId: string;
|
|
25
|
+
guildId: string;
|
|
26
|
+
}) => Promise<(import("mongoose").Document<unknown, {}, TRaffle, {}, import("mongoose").DefaultSchemaOptions> & TRaffle & {
|
|
27
|
+
_id: import("mongoose").Types.ObjectId;
|
|
28
|
+
} & {
|
|
29
|
+
__v: number;
|
|
30
|
+
} & {
|
|
31
|
+
id: string;
|
|
32
|
+
}) | null>;
|
|
33
|
+
searchRafflesForAutocomplete: ({ guildId, query }: {
|
|
34
|
+
guildId: string;
|
|
35
|
+
query: string;
|
|
36
|
+
}) => Promise<any[]>;
|
|
37
|
+
getRafflesReadyToDraw: () => Promise<(import("mongoose").Document<unknown, {}, TRaffle, {}, import("mongoose").DefaultSchemaOptions> & TRaffle & {
|
|
38
|
+
_id: import("mongoose").Types.ObjectId;
|
|
39
|
+
} & {
|
|
40
|
+
__v: number;
|
|
41
|
+
} & {
|
|
42
|
+
id: string;
|
|
43
|
+
})[]>;
|
|
44
|
+
completeRaffleDraw: ({ raffleId, nextDrawAt, lastDrawAt, drawId }: {
|
|
45
|
+
raffleId: string;
|
|
46
|
+
nextDrawAt: Date;
|
|
47
|
+
lastDrawAt: Date;
|
|
48
|
+
drawId: string;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
export type RaffleDb = ReturnType<typeof createRaffleDb>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CasinoBetService } from '../../casino/services/casinoBet.service';
|
|
2
|
+
import type { RaffleDb } from './raffle.db';
|
|
3
|
+
import type { CancelRaffleResult } from './types';
|
|
4
|
+
type RaffleLifecycleDeps = {
|
|
5
|
+
raffleDb: RaffleDb;
|
|
6
|
+
casinoBet: Pick<CasinoBetService, 'refundRafflePurchase'>;
|
|
7
|
+
};
|
|
8
|
+
export declare function createRaffleLifecycleService({ raffleDb, casinoBet }: RaffleLifecycleDeps): {
|
|
9
|
+
cancelRaffle: ({ raffleId, guildId }: {
|
|
10
|
+
raffleId: string;
|
|
11
|
+
guildId: string;
|
|
12
|
+
}) => Promise<CancelRaffleResult>;
|
|
13
|
+
};
|
|
14
|
+
export type RaffleLifecycleService = ReturnType<typeof createRaffleLifecycleService>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TRaffle } from '../types/raffle';
|
|
2
|
+
export type TAddRaffleTickets = {
|
|
3
|
+
raffleId: string;
|
|
4
|
+
guildId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
tickets: number;
|
|
7
|
+
maxTicketsPerUser: number;
|
|
8
|
+
};
|
|
9
|
+
export type TUpsertRaffle = {
|
|
10
|
+
raffleId: string;
|
|
11
|
+
drawId: string;
|
|
12
|
+
guildId: string;
|
|
13
|
+
creatorId: string;
|
|
14
|
+
channelId: string;
|
|
15
|
+
ticketPrice: number;
|
|
16
|
+
maxTicketsPerUser: number;
|
|
17
|
+
nextDrawAt: Date;
|
|
18
|
+
drawIntervalMs: number;
|
|
19
|
+
};
|
|
20
|
+
export type CancelRaffleResult = {
|
|
21
|
+
ok: false;
|
|
22
|
+
code: 'NOT_FOUND';
|
|
23
|
+
} | {
|
|
24
|
+
ok: true;
|
|
25
|
+
raffle: TRaffle;
|
|
26
|
+
refundErrors: string[];
|
|
27
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TRaffleStatus = 'active' | 'canceled';
|
|
2
|
+
export type TRaffleParticipant = {
|
|
3
|
+
userId: string;
|
|
4
|
+
tickets: number;
|
|
5
|
+
};
|
|
6
|
+
export type TRaffle = {
|
|
7
|
+
drawId: string;
|
|
8
|
+
raffleId: string;
|
|
9
|
+
guildId: string;
|
|
10
|
+
channelId: string;
|
|
11
|
+
creatorId: string;
|
|
12
|
+
ticketPrice: number;
|
|
13
|
+
maxTicketsPerUser: number;
|
|
14
|
+
nextDrawAt: Date;
|
|
15
|
+
lastDrawAt?: Date;
|
|
16
|
+
drawIntervalMs: number;
|
|
17
|
+
status: TRaffleStatus;
|
|
18
|
+
participants: TRaffleParticipant[];
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const GAME_RECORD_FIELDS: {
|
|
2
|
+
readonly slots: readonly ["winMultipliers", "symbolWeights"];
|
|
3
|
+
readonly lottery: readonly ["winMultipliers"];
|
|
4
|
+
readonly roulette: readonly ["winMultipliers"];
|
|
5
|
+
readonly plinko: readonly ["binMultipliers"];
|
|
6
|
+
};
|
|
7
|
+
export type GameWithRecords = keyof typeof GAME_RECORD_FIELDS;
|
|
8
|
+
export type RecordKey = (typeof GAME_RECORD_FIELDS)[GameWithRecords][number];
|