gambling-bot-shared 1.0.6 → 1.0.7

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,29 @@
1
+ export type GuildWipeEntity = 'all' | 'users' | 'transactions' | 'atm' | 'raffles' | 'predictions' | 'vip' | 'blackjack';
2
+ export type GuildDataWipeDeleteResult = {
3
+ deletedCount?: number;
4
+ };
5
+ export type GuildDataWipeModel = {
6
+ deleteMany: (filter: {
7
+ guildId: string;
8
+ }) => Promise<GuildDataWipeDeleteResult>;
9
+ };
10
+ export type GuildDataWipeModels = {
11
+ transactions: GuildDataWipeModel;
12
+ atmRequests: GuildDataWipeModel;
13
+ raffles: GuildDataWipeModel;
14
+ predictions: GuildDataWipeModel;
15
+ vipRooms: GuildDataWipeModel;
16
+ blackjackGames: GuildDataWipeModel;
17
+ users: GuildDataWipeModel;
18
+ };
19
+ export type GuildDataWipeSummary = {
20
+ entities: GuildWipeEntity[];
21
+ deleted: Record<string, number>;
22
+ };
23
+ export declare function normalizeGuildWipeEntities(entities: GuildWipeEntity[]): Exclude<GuildWipeEntity, 'all'>[];
24
+ export declare function runGuildDataWipe({ guildId, entities, models }: {
25
+ guildId: string;
26
+ entities: GuildWipeEntity[];
27
+ models: GuildDataWipeModels;
28
+ }): Promise<GuildDataWipeSummary>;
29
+ export declare function formatGuildDataWipeSummary(summary: GuildDataWipeSummary): string;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeGuildWipeEntities = normalizeGuildWipeEntities;
4
+ exports.runGuildDataWipe = runGuildDataWipe;
5
+ exports.formatGuildDataWipeSummary = formatGuildDataWipeSummary;
6
+ const formatters_1 = require("../common/formatters");
7
+ const WIPE_ENTITY_ORDER = [
8
+ 'transactions',
9
+ 'atm',
10
+ 'raffles',
11
+ 'predictions',
12
+ 'vip',
13
+ 'blackjack',
14
+ 'users'
15
+ ];
16
+ const ENTITY_TO_MODEL_KEY = {
17
+ transactions: 'transactions',
18
+ atm: 'atmRequests',
19
+ raffles: 'raffles',
20
+ predictions: 'predictions',
21
+ vip: 'vipRooms',
22
+ blackjack: 'blackjackGames',
23
+ users: 'users'
24
+ };
25
+ const WIPE_LABELS = {
26
+ transactions: 'Transactions',
27
+ atmRequests: 'ATM requests',
28
+ raffles: 'Raffles',
29
+ predictions: 'Predictions',
30
+ vipRooms: 'VIP rooms',
31
+ blackjackGames: 'Blackjack games',
32
+ users: 'Users'
33
+ };
34
+ async function countDeleted(result) {
35
+ return result.deletedCount ?? 0;
36
+ }
37
+ function normalizeGuildWipeEntities(entities) {
38
+ const withoutAll = entities.filter((entity) => entity !== 'all');
39
+ if (withoutAll.length !== entities.length) {
40
+ return [...WIPE_ENTITY_ORDER];
41
+ }
42
+ const selected = new Set(withoutAll);
43
+ return WIPE_ENTITY_ORDER.filter((entity) => selected.has(entity));
44
+ }
45
+ function buildWipeTargets(guildId, entities, models) {
46
+ const selected = new Set(entities);
47
+ return WIPE_ENTITY_ORDER.filter((entity) => selected.has(entity)).map((entity) => {
48
+ const key = ENTITY_TO_MODEL_KEY[entity];
49
+ return {
50
+ key,
51
+ label: WIPE_LABELS[key],
52
+ entity,
53
+ run: async () => countDeleted(await models[key].deleteMany({ guildId }))
54
+ };
55
+ });
56
+ }
57
+ async function runGuildDataWipe({ guildId, entities, models }) {
58
+ const normalizedEntities = normalizeGuildWipeEntities(entities);
59
+ const targets = buildWipeTargets(guildId, normalizedEntities, models);
60
+ const deleted = {};
61
+ for (const target of targets) {
62
+ deleted[target.key] = await target.run();
63
+ }
64
+ return {
65
+ entities: normalizedEntities,
66
+ deleted
67
+ };
68
+ }
69
+ function formatGuildDataWipeSummary(summary) {
70
+ const lines = Object.entries(summary.deleted)
71
+ .filter(([, count]) => count > 0)
72
+ .map(([key, count]) => `• **${WIPE_LABELS[key] ?? key}**: ${(0, formatters_1.formatNumberToReadableString)(count)} removed`);
73
+ if (lines.length === 0) {
74
+ return 'Nothing to remove — guild operational data was already empty.';
75
+ }
76
+ return lines.join('\n');
77
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './devAccess';
2
2
  export * from './bonusStressTest';
3
3
  export * from './casinoMonteCarlo';
4
+ export * from './guildDataWipe';
4
5
  export * from './yieldToEventLoop';
package/dist/dev/index.js CHANGED
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./devAccess"), exports);
18
18
  __exportStar(require("./bonusStressTest"), exports);
19
19
  __exportStar(require("./casinoMonteCarlo"), exports);
20
+ __exportStar(require("./guildDataWipe"), exports);
20
21
  __exportStar(require("./yieldToEventLoop"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gambling-bot-shared",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "license": "MIT",
5
5
  "type": "commonjs",
6
6
  "repository": {