ballrush-core 0.1.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 +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/mongo/index.d.ts +4 -0
- package/dist/mongo/index.js +20 -0
- package/dist/mongo/schemas/event-template.schema.d.ts +24 -0
- package/dist/mongo/schemas/event-template.schema.js +30 -0
- package/dist/mongo/schemas/event.schema.d.ts +37 -0
- package/dist/mongo/schemas/event.schema.js +56 -0
- package/dist/mongo/schemas/group.schema.d.ts +24 -0
- package/dist/mongo/schemas/group.schema.js +32 -0
- package/dist/mongo/schemas/user.schema.d.ts +13 -0
- package/dist/mongo/schemas/user.schema.js +13 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/shared.d.ts +147 -0
- package/dist/types/shared.js +49 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ballrush-core
|
|
2
|
+
|
|
3
|
+
Shared core library for **Ballrush** project.
|
|
4
|
+
Contains TypeScript types and Mongoose schema factories (without models).
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- 🗂 Shared **TypeScript types**
|
|
9
|
+
- 🏗 Mongoose **schema factories** (`createXSchema`) without `model()`
|
|
10
|
+
- 🎯 Designed for **DDD** (domain-driven design) architecture
|
|
11
|
+
- 🔌 Reusable in bot (`ballrush-bot`) and API (`ballrush-api`)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install ballrush-core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
License
|
|
20
|
+
|
|
21
|
+
MIT © 2025 Serhii Zghama
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./mongo"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
__exportStar(require("./schemas/user.schema"), exports);
|
|
18
|
+
__exportStar(require("./schemas/event-template.schema"), exports);
|
|
19
|
+
__exportStar(require("./schemas/event.schema"), exports);
|
|
20
|
+
__exportStar(require("./schemas/group.schema"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
import { ParticipantEvent } from "../../types";
|
|
3
|
+
export interface EventTemplateDoc {
|
|
4
|
+
templateId: number;
|
|
5
|
+
groupId: number;
|
|
6
|
+
adminId: number;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
preViewImg: string;
|
|
10
|
+
options: string[];
|
|
11
|
+
autoPost: boolean;
|
|
12
|
+
defaultTime: string;
|
|
13
|
+
defaultDayOfWeek: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
14
|
+
defaultLocation: string;
|
|
15
|
+
defaultDuration: string;
|
|
16
|
+
defaultParticipants: ParticipantEvent[];
|
|
17
|
+
maxPlayers: number;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
}
|
|
20
|
+
export declare function createEventTemplateSchema(): Schema<EventTemplateDoc, import("mongoose").Model<EventTemplateDoc, any, any, any, import("mongoose").Document<unknown, any, EventTemplateDoc> & EventTemplateDoc & {
|
|
21
|
+
_id: import("mongoose").Types.ObjectId;
|
|
22
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, EventTemplateDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<EventTemplateDoc>> & import("mongoose").FlatRecord<EventTemplateDoc> & {
|
|
23
|
+
_id: import("mongoose").Types.ObjectId;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEventTemplateSchema = createEventTemplateSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
function createEventTemplateSchema() {
|
|
6
|
+
const DefaultParticipantSchema = new mongoose_1.Schema({
|
|
7
|
+
userId: { type: Number, required: true },
|
|
8
|
+
voteOption: { type: Number, required: true },
|
|
9
|
+
username: { type: String, required: true },
|
|
10
|
+
votedAt: { type: Date, required: true },
|
|
11
|
+
});
|
|
12
|
+
const schema = new mongoose_1.Schema({
|
|
13
|
+
templateId: { type: Number, required: true, unique: true, index: true },
|
|
14
|
+
groupId: { type: Number, required: true, index: true },
|
|
15
|
+
adminId: { type: Number, required: true },
|
|
16
|
+
title: { type: String, required: true },
|
|
17
|
+
description: { type: String, required: true },
|
|
18
|
+
preViewImg: { type: String, required: true },
|
|
19
|
+
options: { type: [String], required: true },
|
|
20
|
+
autoPost: { type: Boolean, required: true },
|
|
21
|
+
defaultTime: { type: String, required: true },
|
|
22
|
+
defaultDayOfWeek: { type: Number, enum: [0, 1, 2, 3, 4, 5, 6], required: true },
|
|
23
|
+
defaultLocation: { type: String, required: true },
|
|
24
|
+
defaultDuration: { type: String, required: true },
|
|
25
|
+
defaultParticipants: { type: [DefaultParticipantSchema], default: [] },
|
|
26
|
+
maxPlayers: { type: Number, required: true, min: 1 },
|
|
27
|
+
createdAt: { type: Date, default: Date.now },
|
|
28
|
+
});
|
|
29
|
+
return schema;
|
|
30
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
import { EventStatus, Match, ParticipantEvent, Team } from "../../types";
|
|
3
|
+
export interface EventDoc {
|
|
4
|
+
eventId: number;
|
|
5
|
+
groupId: number;
|
|
6
|
+
messageId: number;
|
|
7
|
+
templateId: number;
|
|
8
|
+
date: Date;
|
|
9
|
+
createdBy: number;
|
|
10
|
+
participants: ParticipantEvent[];
|
|
11
|
+
teams: Team[];
|
|
12
|
+
matches: Match[];
|
|
13
|
+
seasonName: string;
|
|
14
|
+
status: EventStatus;
|
|
15
|
+
isRatingApplied?: boolean;
|
|
16
|
+
reportMessageId?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function createParticipantEventSchema(): Schema<ParticipantEvent, import("mongoose").Model<ParticipantEvent, any, any, any, import("mongoose").Document<unknown, any, ParticipantEvent> & ParticipantEvent & {
|
|
19
|
+
_id: import("mongoose").Types.ObjectId;
|
|
20
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ParticipantEvent, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ParticipantEvent>> & import("mongoose").FlatRecord<ParticipantEvent> & {
|
|
21
|
+
_id: import("mongoose").Types.ObjectId;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function createTeamSchema(): Schema<Team, import("mongoose").Model<Team, any, any, any, import("mongoose").Document<unknown, any, Team> & Team & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Team, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Team>> & import("mongoose").FlatRecord<Team> & {
|
|
26
|
+
_id: import("mongoose").Types.ObjectId;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function createMatchSchema(): Schema<Match, import("mongoose").Model<Match, any, any, any, import("mongoose").Document<unknown, any, Match> & Match & {
|
|
29
|
+
_id: import("mongoose").Types.ObjectId;
|
|
30
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Match, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Match>> & import("mongoose").FlatRecord<Match> & {
|
|
31
|
+
_id: import("mongoose").Types.ObjectId;
|
|
32
|
+
}>;
|
|
33
|
+
export declare function createEventSchema(): Schema<EventDoc, import("mongoose").Model<EventDoc, any, any, any, import("mongoose").Document<unknown, any, EventDoc> & EventDoc & {
|
|
34
|
+
_id: import("mongoose").Types.ObjectId;
|
|
35
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, EventDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<EventDoc>> & import("mongoose").FlatRecord<EventDoc> & {
|
|
36
|
+
_id: import("mongoose").Types.ObjectId;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createParticipantEventSchema = createParticipantEventSchema;
|
|
4
|
+
exports.createTeamSchema = createTeamSchema;
|
|
5
|
+
exports.createMatchSchema = createMatchSchema;
|
|
6
|
+
exports.createEventSchema = createEventSchema;
|
|
7
|
+
const mongoose_1 = require("mongoose");
|
|
8
|
+
function createParticipantEventSchema() {
|
|
9
|
+
return new mongoose_1.Schema({
|
|
10
|
+
userId: { type: Number, required: true },
|
|
11
|
+
voteOption: { type: Number, required: true },
|
|
12
|
+
votedAt: { type: Date, required: true },
|
|
13
|
+
username: { type: String, required: true },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function createTeamSchema() {
|
|
17
|
+
return new mongoose_1.Schema({
|
|
18
|
+
teamId: { type: Number, required: true },
|
|
19
|
+
teamName: { type: String, required: true },
|
|
20
|
+
players: { type: [Number], required: true },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function createMatchSchema() {
|
|
24
|
+
return new mongoose_1.Schema({
|
|
25
|
+
matchId: { type: Number, required: true },
|
|
26
|
+
team1Id: { type: Number, required: true },
|
|
27
|
+
team2Id: { type: Number, required: true },
|
|
28
|
+
score: { type: [Number], required: true },
|
|
29
|
+
matchDate: { type: Date, required: true },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function createEventSchema() {
|
|
33
|
+
const ParticipantSchema = createParticipantEventSchema();
|
|
34
|
+
const TeamSchema = createTeamSchema();
|
|
35
|
+
const MatchSchema = createMatchSchema();
|
|
36
|
+
const EventSchema = new mongoose_1.Schema({
|
|
37
|
+
eventId: { type: Number, required: true, unique: true, index: true },
|
|
38
|
+
groupId: { type: Number, required: true },
|
|
39
|
+
messageId: { type: Number, required: true },
|
|
40
|
+
templateId: { type: Number, required: true },
|
|
41
|
+
date: { type: Date, required: true },
|
|
42
|
+
seasonName: { type: String, required: true },
|
|
43
|
+
createdBy: { type: Number, required: true },
|
|
44
|
+
participants: { type: [ParticipantSchema], default: [] },
|
|
45
|
+
teams: { type: [TeamSchema], default: [] },
|
|
46
|
+
matches: { type: [MatchSchema], default: [] },
|
|
47
|
+
isRatingApplied: { type: Boolean },
|
|
48
|
+
reportMessageId: { type: Number },
|
|
49
|
+
status: {
|
|
50
|
+
type: String,
|
|
51
|
+
enum: ["active", "in_progress", "completed"],
|
|
52
|
+
default: "active",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
return EventSchema;
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
import { ParticipantGroup, RatingPoint } from "../../types";
|
|
3
|
+
export interface GroupDoc {
|
|
4
|
+
groupId: number;
|
|
5
|
+
groupName: string;
|
|
6
|
+
participants: ParticipantGroup[];
|
|
7
|
+
timezone: string;
|
|
8
|
+
isMessageLast: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function createRatingPointSchema(): Schema<RatingPoint, import("mongoose").Model<RatingPoint, any, any, any, import("mongoose").Document<unknown, any, RatingPoint> & RatingPoint & {
|
|
11
|
+
_id: import("mongoose").Types.ObjectId;
|
|
12
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, RatingPoint, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<RatingPoint>> & import("mongoose").FlatRecord<RatingPoint> & {
|
|
13
|
+
_id: import("mongoose").Types.ObjectId;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function createParticipantSchema(): Schema<ParticipantGroup, import("mongoose").Model<ParticipantGroup, any, any, any, import("mongoose").Document<unknown, any, ParticipantGroup> & ParticipantGroup & {
|
|
16
|
+
_id: import("mongoose").Types.ObjectId;
|
|
17
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ParticipantGroup, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ParticipantGroup>> & import("mongoose").FlatRecord<ParticipantGroup> & {
|
|
18
|
+
_id: import("mongoose").Types.ObjectId;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function createGroupSchema(): Schema<GroupDoc, import("mongoose").Model<GroupDoc, any, any, any, import("mongoose").Document<unknown, any, GroupDoc> & GroupDoc & {
|
|
21
|
+
_id: import("mongoose").Types.ObjectId;
|
|
22
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, GroupDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<GroupDoc>> & import("mongoose").FlatRecord<GroupDoc> & {
|
|
23
|
+
_id: import("mongoose").Types.ObjectId;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRatingPointSchema = createRatingPointSchema;
|
|
4
|
+
exports.createParticipantSchema = createParticipantSchema;
|
|
5
|
+
exports.createGroupSchema = createGroupSchema;
|
|
6
|
+
const mongoose_1 = require("mongoose");
|
|
7
|
+
function createRatingPointSchema() {
|
|
8
|
+
return new mongoose_1.Schema({
|
|
9
|
+
value: { type: Number, required: true },
|
|
10
|
+
changedAt: { type: Date, default: Date.now },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function createParticipantSchema() {
|
|
14
|
+
const RatingPointSchema = createRatingPointSchema();
|
|
15
|
+
return new mongoose_1.Schema({
|
|
16
|
+
userId: { type: Number, required: true },
|
|
17
|
+
position: { type: String, required: true },
|
|
18
|
+
ratingHistory: { type: [RatingPointSchema], default: [] },
|
|
19
|
+
isAdmin: { type: Boolean, required: true },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function createGroupSchema() {
|
|
23
|
+
const ParticipantSchema = createParticipantSchema();
|
|
24
|
+
const GroupSchema = new mongoose_1.Schema({
|
|
25
|
+
groupId: { type: Number, required: true, unique: true, index: true },
|
|
26
|
+
groupName: { type: String, required: true },
|
|
27
|
+
participants: { type: [ParticipantSchema], default: [] },
|
|
28
|
+
timezone: { type: String, default: "UTC+0" },
|
|
29
|
+
isMessageLast: { type: Boolean, default: false },
|
|
30
|
+
});
|
|
31
|
+
return GroupSchema;
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
import { LanguageType } from "../../types";
|
|
3
|
+
export interface UserDoc {
|
|
4
|
+
firstName: string;
|
|
5
|
+
language: LanguageType;
|
|
6
|
+
userId: number;
|
|
7
|
+
username?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createUserSchema(): Schema<UserDoc, import("mongoose").Model<UserDoc, any, any, any, import("mongoose").Document<unknown, any, UserDoc> & UserDoc & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, UserDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<UserDoc>> & import("mongoose").FlatRecord<UserDoc> & {
|
|
12
|
+
_id: import("mongoose").Types.ObjectId;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUserSchema = createUserSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
function createUserSchema() {
|
|
6
|
+
const UserSchema = new mongoose_1.Schema({
|
|
7
|
+
firstName: { type: String, required: true },
|
|
8
|
+
username: { type: String },
|
|
9
|
+
userId: { type: Number, required: true, unique: true, index: true },
|
|
10
|
+
language: { type: String, enum: ["ru", "en"], default: "ru" },
|
|
11
|
+
});
|
|
12
|
+
return UserSchema;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./shared";
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
__exportStar(require("./shared"), exports);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export type EventStatus = "active" | "in_progress" | "completed";
|
|
2
|
+
export type LanguageType = "en" | "ru";
|
|
3
|
+
export type DayOfWeek = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
|
|
4
|
+
export interface ParticipantBase {
|
|
5
|
+
userId: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ParticipantEvent extends ParticipantBase {
|
|
8
|
+
username: string;
|
|
9
|
+
voteOption: number;
|
|
10
|
+
votedAt: Date;
|
|
11
|
+
}
|
|
12
|
+
export interface ParticipantGroup extends ParticipantBase {
|
|
13
|
+
position: PlayerPosition;
|
|
14
|
+
ratingHistory: RatingPoint[];
|
|
15
|
+
isAdmin: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TeamParticipant extends ParticipantBase {
|
|
18
|
+
username: string;
|
|
19
|
+
rating: number;
|
|
20
|
+
position: PlayerPosition;
|
|
21
|
+
}
|
|
22
|
+
export interface TeamGeneration {
|
|
23
|
+
participants: TeamParticipant[];
|
|
24
|
+
totalRating: number;
|
|
25
|
+
}
|
|
26
|
+
export interface TeamVariations {
|
|
27
|
+
[adminId: number]: TeamGeneration[][];
|
|
28
|
+
}
|
|
29
|
+
export interface Team {
|
|
30
|
+
teamId: number;
|
|
31
|
+
teamName: string;
|
|
32
|
+
players: number[];
|
|
33
|
+
}
|
|
34
|
+
export interface Match {
|
|
35
|
+
matchId: number;
|
|
36
|
+
team1Id: number;
|
|
37
|
+
team2Id: number;
|
|
38
|
+
score: [number, number];
|
|
39
|
+
matchDate: Date;
|
|
40
|
+
}
|
|
41
|
+
export interface TeamStats {
|
|
42
|
+
teamId: number;
|
|
43
|
+
teamName: string;
|
|
44
|
+
emoji: string;
|
|
45
|
+
games: number;
|
|
46
|
+
wins: number;
|
|
47
|
+
losses: number;
|
|
48
|
+
draws: number;
|
|
49
|
+
points: number;
|
|
50
|
+
goalsFor: number;
|
|
51
|
+
goalsAgainst: number;
|
|
52
|
+
}
|
|
53
|
+
export interface Header {
|
|
54
|
+
title: string;
|
|
55
|
+
key: string;
|
|
56
|
+
maxWidth?: number;
|
|
57
|
+
}
|
|
58
|
+
export declare enum PlayerPosition {
|
|
59
|
+
FW = "FW",// Нападающий (Forward)
|
|
60
|
+
MF = "MF",// Полузащитник (Midfielder)
|
|
61
|
+
DF = "DF",// Защитник (Defender)
|
|
62
|
+
GK = "GK",// Вратарь (Goalkeeper)
|
|
63
|
+
UN = "UN"
|
|
64
|
+
}
|
|
65
|
+
export interface SelectedParticipants {
|
|
66
|
+
[adminId: string]: Set<number>;
|
|
67
|
+
}
|
|
68
|
+
export interface SelectedParticipantsDate {
|
|
69
|
+
[adminId: string]: Map<number, Date>;
|
|
70
|
+
}
|
|
71
|
+
export interface RatingPoint {
|
|
72
|
+
value: number;
|
|
73
|
+
changedAt: Date;
|
|
74
|
+
}
|
|
75
|
+
export declare const ACHIEVEMENTS: {
|
|
76
|
+
readonly WinStreak: {
|
|
77
|
+
readonly emoji: "🔥";
|
|
78
|
+
readonly title: "Win Streak";
|
|
79
|
+
readonly type: "team";
|
|
80
|
+
readonly description: "Команда выиграла 3 матча подряд.";
|
|
81
|
+
};
|
|
82
|
+
readonly HardToBeat: {
|
|
83
|
+
readonly emoji: "💪";
|
|
84
|
+
readonly title: "Hard to Beat";
|
|
85
|
+
readonly type: "team";
|
|
86
|
+
readonly description: "Команда не проиграла в 5 матчах подряд (включая ничьи).";
|
|
87
|
+
};
|
|
88
|
+
readonly IronDefense: {
|
|
89
|
+
readonly emoji: "🛡️";
|
|
90
|
+
readonly title: "Iron Defense";
|
|
91
|
+
readonly type: "team";
|
|
92
|
+
readonly description: "Команда не пропустила ни одного гола в 3 матчах подряд.";
|
|
93
|
+
};
|
|
94
|
+
readonly PerfectHarmony: {
|
|
95
|
+
readonly emoji: "🤝";
|
|
96
|
+
readonly title: "Perfect Harmony";
|
|
97
|
+
readonly type: "team";
|
|
98
|
+
readonly description: "Команда сыграла 3 матча подряд вничью.";
|
|
99
|
+
};
|
|
100
|
+
readonly ConsistentWinners: {
|
|
101
|
+
readonly emoji: "⚡";
|
|
102
|
+
readonly title: "Consistent Winners";
|
|
103
|
+
readonly type: "team";
|
|
104
|
+
readonly description: "Команда не проиграла ни одного матча за вечер.";
|
|
105
|
+
};
|
|
106
|
+
readonly MVPTeam: {
|
|
107
|
+
readonly emoji: "🏆";
|
|
108
|
+
readonly title: "MVP Team";
|
|
109
|
+
readonly type: "team";
|
|
110
|
+
readonly description: "Команда показала лучший результат во всех ключевых показателях — победах, забитых мячах, набранных очках и наименьшем количестве пропущенных мячей.";
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export type AchievementId = keyof typeof ACHIEVEMENTS;
|
|
114
|
+
export interface TeamAchievement {
|
|
115
|
+
teamId: number;
|
|
116
|
+
achievement: Achievement;
|
|
117
|
+
}
|
|
118
|
+
export type AchievementType = 'team' | 'personal';
|
|
119
|
+
export interface Achievement {
|
|
120
|
+
emoji: string;
|
|
121
|
+
title: string;
|
|
122
|
+
type: AchievementType;
|
|
123
|
+
description: string;
|
|
124
|
+
}
|
|
125
|
+
export type RenderMode = "view" | "edit";
|
|
126
|
+
export interface DisplayOptions {
|
|
127
|
+
parseMode?: "HTML" | "Markdown" | undefined;
|
|
128
|
+
isChangeColor?: boolean;
|
|
129
|
+
teamIndexToChange?: number;
|
|
130
|
+
mode?: RenderMode;
|
|
131
|
+
}
|
|
132
|
+
export interface VariationContext {
|
|
133
|
+
chatId: number;
|
|
134
|
+
groupId: number;
|
|
135
|
+
variationIndex: number;
|
|
136
|
+
messageId: number;
|
|
137
|
+
}
|
|
138
|
+
export interface CursorPos {
|
|
139
|
+
teamIdx: number;
|
|
140
|
+
index: number;
|
|
141
|
+
}
|
|
142
|
+
export interface EditSession {
|
|
143
|
+
baseVariationIndex: number;
|
|
144
|
+
workingTeams: TeamGeneration[];
|
|
145
|
+
cursor: CursorPos;
|
|
146
|
+
selectedPlayerId: number | null;
|
|
147
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ACHIEVEMENTS = exports.PlayerPosition = void 0;
|
|
4
|
+
var PlayerPosition;
|
|
5
|
+
(function (PlayerPosition) {
|
|
6
|
+
PlayerPosition["FW"] = "FW";
|
|
7
|
+
PlayerPosition["MF"] = "MF";
|
|
8
|
+
PlayerPosition["DF"] = "DF";
|
|
9
|
+
PlayerPosition["GK"] = "GK";
|
|
10
|
+
PlayerPosition["UN"] = "UN";
|
|
11
|
+
})(PlayerPosition || (exports.PlayerPosition = PlayerPosition = {}));
|
|
12
|
+
exports.ACHIEVEMENTS = {
|
|
13
|
+
WinStreak: {
|
|
14
|
+
emoji: '🔥',
|
|
15
|
+
title: 'Win Streak',
|
|
16
|
+
type: 'team',
|
|
17
|
+
description: 'Команда выиграла 3 матча подряд.',
|
|
18
|
+
},
|
|
19
|
+
HardToBeat: {
|
|
20
|
+
emoji: '💪',
|
|
21
|
+
title: 'Hard to Beat',
|
|
22
|
+
type: 'team',
|
|
23
|
+
description: 'Команда не проиграла в 5 матчах подряд (включая ничьи).',
|
|
24
|
+
},
|
|
25
|
+
IronDefense: {
|
|
26
|
+
emoji: '🛡️',
|
|
27
|
+
title: 'Iron Defense',
|
|
28
|
+
type: 'team',
|
|
29
|
+
description: 'Команда не пропустила ни одного гола в 3 матчах подряд.',
|
|
30
|
+
},
|
|
31
|
+
PerfectHarmony: {
|
|
32
|
+
emoji: '🤝',
|
|
33
|
+
title: 'Perfect Harmony',
|
|
34
|
+
type: 'team',
|
|
35
|
+
description: 'Команда сыграла 3 матча подряд вничью.',
|
|
36
|
+
},
|
|
37
|
+
ConsistentWinners: {
|
|
38
|
+
emoji: '⚡',
|
|
39
|
+
title: 'Consistent Winners',
|
|
40
|
+
type: 'team',
|
|
41
|
+
description: 'Команда не проиграла ни одного матча за вечер.',
|
|
42
|
+
},
|
|
43
|
+
MVPTeam: {
|
|
44
|
+
emoji: '🏆',
|
|
45
|
+
title: 'MVP Team',
|
|
46
|
+
type: 'team',
|
|
47
|
+
description: 'Команда показала лучший результат во всех ключевых показателях — победах, забитых мячах, набранных очках и наименьшем количестве пропущенных мячей.',
|
|
48
|
+
},
|
|
49
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ballrush-core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/**/*",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"clean": "rimraf dist",
|
|
16
|
+
"pack:check": "npm pack --dry-run",
|
|
17
|
+
"prepublishOnly": "npm run clean && npm run build && npm run pack:check"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"mongoose": "^7.0.0 || ^8.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.9.0",
|
|
24
|
+
"rimraf": "^5.0.0",
|
|
25
|
+
"mongoose": "^7.8.7"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": "./dist/index.js",
|
|
36
|
+
"./mongo": "./dist/mongo/index.js",
|
|
37
|
+
"./types": "./dist/types/index.js"
|
|
38
|
+
},
|
|
39
|
+
"typesVersions": {
|
|
40
|
+
"*": {
|
|
41
|
+
"mongo": [
|
|
42
|
+
"dist/mongo/index.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"types": [
|
|
45
|
+
"dist/types/index.d.ts"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"mongoose",
|
|
51
|
+
"schemas",
|
|
52
|
+
"typescript",
|
|
53
|
+
"ddd",
|
|
54
|
+
"telegram-bot",
|
|
55
|
+
"ballrush"
|
|
56
|
+
]
|
|
57
|
+
}
|