brackets-prisma-db 1.0.2 → 2.1.0
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 +52 -6
- package/dist/storage-handlers/delete-handlers/stage.js +38 -19
- package/dist/storage-handlers/insert-handlers/match-game.d.ts +3 -2
- package/dist/storage-handlers/insert-handlers/match-game.js +1 -0
- package/dist/storage-handlers/insert-handlers/match.d.ts +3 -2
- package/dist/storage-handlers/insert-handlers/match.js +1 -0
- package/dist/storage-handlers/insert-handlers/participant.js +6 -2
- package/dist/storage-handlers/select-handlers/group.js +1 -0
- package/dist/storage-handlers/select-handlers/match-game.d.ts +2 -2
- package/dist/storage-handlers/select-handlers/match-game.js +0 -2
- package/dist/storage-handlers/select-handlers/match.d.ts +2 -2
- package/dist/storage-handlers/select-handlers/match.js +0 -1
- package/dist/storage-handlers/update-handlers/match-game.d.ts +2 -2
- package/dist/storage-handlers/update-handlers/match-game.js +39 -23
- package/dist/storage-handlers/update-handlers/match.d.ts +2 -2
- package/dist/storage-handlers/update-handlers/match.js +40 -24
- package/dist/storage-handlers/update-handlers/participant.js +3 -0
- package/dist/transformers/enum/grand-final-type.d.ts +1 -1
- package/dist/transformers/enum/match-result.d.ts +1 -1
- package/dist/transformers/enum/match-status.d.ts +1 -1
- package/dist/transformers/enum/round-robin-mode.d.ts +1 -1
- package/dist/transformers/enum/seed-ordering.d.ts +1 -1
- package/dist/transformers/enum/stage-type.d.ts +1 -1
- package/dist/transformers/model/group.d.ts +3 -3
- package/dist/transformers/model/match-game.d.ts +18 -18
- package/dist/transformers/model/match-game.js +62 -1
- package/dist/transformers/model/match.d.ts +20 -22
- package/dist/transformers/model/match.js +64 -1
- package/dist/transformers/model/participant-result.d.ts +7 -7
- package/dist/transformers/model/participant.d.ts +7 -3
- package/dist/transformers/model/participant.js +21 -2
- package/dist/transformers/model/round.d.ts +3 -3
- package/dist/transformers/model/stage-settings.d.ts +7 -7
- package/dist/transformers/model/stage.d.ts +5 -5
- package/dist/types.d.ts +10 -0
- package/dist/types.js +2 -0
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -10,10 +10,10 @@ uses [prisma](https://www.prisma.io/) to store the data in an SQL Database.
|
|
|
10
10
|
|
|
11
11
|
Currently there are some features of the [manager](https://github.com/Drarig29/brackets-manager.js) that can't be used.
|
|
12
12
|
|
|
13
|
-
| **Feature** | **Status**
|
|
14
|
-
| ------------------- |
|
|
15
|
-
| Custom Participants | Implemented
|
|
16
|
-
| Custom Matches |
|
|
13
|
+
| **Feature** | **Status** |
|
|
14
|
+
| ------------------- | ----------- |
|
|
15
|
+
| Custom Participants | Implemented |
|
|
16
|
+
| Custom Matches | Implemented |
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
@@ -31,9 +31,55 @@ Lastly push the definition to your database using `npx prisma db push`.
|
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { SqlDatabase } from 'brackets-prisma-db';
|
|
34
|
-
import { prisma } from './client';
|
|
35
34
|
import { BracketsManager } from 'brackets-manager';
|
|
35
|
+
import { PrismaClient } from '@prisma/client'
|
|
36
|
+
|
|
37
|
+
// Your Prisma client
|
|
38
|
+
const prisma = new PrismaClient();
|
|
36
39
|
|
|
37
40
|
const storage = new SqlDatabase(prisma);
|
|
38
41
|
const manager = new BracketsManager(storage);
|
|
39
|
-
```
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Example with custom matches and participants:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { SqlDatabase } from 'brackets-prisma-db'
|
|
48
|
+
import { PrismaClient } from '@prisma/client'
|
|
49
|
+
import { BracketsManager } from 'brackets-manager'
|
|
50
|
+
import type { Match } from 'brackets-model'
|
|
51
|
+
|
|
52
|
+
type MatchWithWeather = Match & {
|
|
53
|
+
extra: {
|
|
54
|
+
weather: 'sunny' | 'rainy' | 'cloudy' | 'snowy'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const storage = new SqlDatabase(new PrismaClient())
|
|
59
|
+
const manager = new BracketsManager(storage)
|
|
60
|
+
|
|
61
|
+
const stage = await manager.create.stage({
|
|
62
|
+
tournamentId: 1,
|
|
63
|
+
name: 'Example',
|
|
64
|
+
type: 'single_elimination',
|
|
65
|
+
seeding: [
|
|
66
|
+
{ name: 'Team 1', color: 'red' },
|
|
67
|
+
{ name: 'Team 2', color: 'blue' },
|
|
68
|
+
{ name: 'Team 3', color: 'green' },
|
|
69
|
+
{ name: 'Team 4', color: 'yellow' },
|
|
70
|
+
],
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const currentMatches = await manager.get.currentMatches(stage.id)
|
|
74
|
+
|
|
75
|
+
await manager.update.match<MatchWithWeather>({
|
|
76
|
+
id: currentMatches[0].id,
|
|
77
|
+
opponent1: { result: 'win' },
|
|
78
|
+
extra: {
|
|
79
|
+
weather: 'sunny',
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const database = await manager.get.tournamentData(1)
|
|
84
|
+
console.log(database)
|
|
85
|
+
```
|
|
@@ -3,26 +3,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleStageDelete = void 0;
|
|
4
4
|
const transformers_1 = require("../../transformers");
|
|
5
5
|
async function handleStageDelete(prisma, filter) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
return prisma
|
|
7
|
+
.$transaction(async (tx) => {
|
|
8
|
+
// Build where clause if a filter is provided
|
|
9
|
+
const where = filter
|
|
10
|
+
? {
|
|
11
|
+
id: filter.id,
|
|
12
|
+
name: filter.name,
|
|
13
|
+
number: filter.number,
|
|
14
|
+
tournamentId: filter.tournament_id,
|
|
15
|
+
type: filter.type
|
|
16
|
+
? transformers_1.StageTypeTransformer.to(filter.type)
|
|
17
|
+
: undefined,
|
|
18
|
+
}
|
|
19
|
+
: undefined;
|
|
20
|
+
if (!where) {
|
|
21
|
+
// No filter: delete in the right order to satisfy FK constraints
|
|
22
|
+
await tx.stageSettings.deleteMany({});
|
|
23
|
+
await tx.stage.deleteMany({});
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
// Filtered delete: find matching stages
|
|
27
|
+
const stages = await tx.stage.findMany({
|
|
28
|
+
where,
|
|
29
|
+
select: { id: true },
|
|
30
|
+
});
|
|
31
|
+
if (stages.length === 0)
|
|
32
|
+
return true;
|
|
33
|
+
// Delete related StageSettings first to satisfy FK constraints
|
|
34
|
+
await tx.stageSettings.deleteMany({
|
|
35
|
+
where: { stageId: { in: stages.map((s) => s.id) } },
|
|
36
|
+
});
|
|
37
|
+
// Then delete the stages
|
|
38
|
+
await tx.stage.deleteMany({ where });
|
|
39
|
+
return true;
|
|
24
40
|
})
|
|
25
41
|
.then(() => true)
|
|
26
|
-
.catch(() =>
|
|
42
|
+
.catch((e) => {
|
|
43
|
+
console.error(new Error(`Error deleting stages with filter ${JSON.stringify(filter)}`, { cause: e }));
|
|
44
|
+
return false;
|
|
45
|
+
});
|
|
27
46
|
}
|
|
28
47
|
exports.handleStageDelete = handleStageDelete;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OmitId } from 'brackets-manager/dist/types';
|
|
2
2
|
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
3
|
+
import type { MatchGameWithExtra } from '../../types';
|
|
4
|
+
export declare function handleMatchGameInsert(prisma: PrismaClient, values: OmitId<MatchGameWithExtra> | OmitId<MatchGameWithExtra>[]): Promise<number> | Promise<boolean>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OmitId } from 'brackets-manager/dist/types';
|
|
2
2
|
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
3
|
+
import type { MatchWithExtra } from '../../types';
|
|
4
|
+
export declare function handleMatchInsert(prisma: PrismaClient, values: OmitId<MatchWithExtra> | OmitId<MatchWithExtra>[]): Promise<number> | Promise<boolean>;
|
|
@@ -6,14 +6,18 @@ function handleParticipantInsert(prisma, values) {
|
|
|
6
6
|
if (Array.isArray(values)) {
|
|
7
7
|
return prisma.participant
|
|
8
8
|
.createMany({
|
|
9
|
-
data: values.map(
|
|
9
|
+
data: values.map(p => {
|
|
10
|
+
const value = transformers_1.ParticipantTransformer.to(p);
|
|
11
|
+
return { ...value, extra: value.extra ?? undefined };
|
|
12
|
+
}),
|
|
10
13
|
})
|
|
11
14
|
.then(() => true)
|
|
12
15
|
.catch(() => false);
|
|
13
16
|
}
|
|
17
|
+
const value = transformers_1.ParticipantTransformer.to(values);
|
|
14
18
|
return prisma.participant
|
|
15
19
|
.create({
|
|
16
|
-
data:
|
|
20
|
+
data: { ...value, extra: value.extra ?? undefined },
|
|
17
21
|
})
|
|
18
22
|
.then((v) => v.id)
|
|
19
23
|
.catch(() => -1);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleGroupSelect = void 0;
|
|
4
|
+
// @ts-ignore
|
|
4
5
|
const transformers_1 = require("../../transformers");
|
|
5
6
|
async function handleGroupSelect(prisma, filter) {
|
|
6
7
|
if (filter === undefined) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from 'brackets-manager/dist/types';
|
|
2
1
|
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
2
|
+
import type { MatchGameWithExtra } from '../../types';
|
|
3
|
+
export declare function handleMatchGameSelect(prisma: PrismaClient, filter?: Partial<MatchGameWithExtra> | number): Promise<MatchGameWithExtra[] | MatchGameWithExtra | null>;
|
|
@@ -4,7 +4,6 @@ exports.handleMatchGameSelect = void 0;
|
|
|
4
4
|
const transformers_1 = require("../../transformers");
|
|
5
5
|
async function handleMatchGameSelect(prisma, filter) {
|
|
6
6
|
if (filter === undefined) {
|
|
7
|
-
// Query all entries of table
|
|
8
7
|
return prisma.matchGame
|
|
9
8
|
.findMany({
|
|
10
9
|
include: {
|
|
@@ -17,7 +16,6 @@ async function handleMatchGameSelect(prisma, filter) {
|
|
|
17
16
|
.catch(() => []);
|
|
18
17
|
}
|
|
19
18
|
if (typeof filter === 'number') {
|
|
20
|
-
// Find by Id
|
|
21
19
|
return prisma.matchGame
|
|
22
20
|
.findFirst({
|
|
23
21
|
where: { id: filter },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from 'brackets-manager/dist/types';
|
|
2
1
|
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
2
|
+
import type { MatchWithExtra } from '../../types';
|
|
3
|
+
export declare function handleMatchSelect(prisma: PrismaClient, filter?: Partial<MatchWithExtra> | number): Promise<MatchWithExtra[] | MatchWithExtra | null>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from 'brackets-manager/dist/types';
|
|
2
1
|
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
2
|
+
import type { MatchGameWithExtra } from '../../types';
|
|
3
|
+
export declare function handleMatchGameUpdate(prisma: PrismaClient, filter: Partial<MatchGameWithExtra> | number, value: Partial<MatchGameWithExtra> | MatchGameWithExtra): Promise<boolean>;
|
|
@@ -26,7 +26,9 @@ function getParticipantResultUpsertData(value) {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function getUpdateData(value) {
|
|
29
|
+
function getUpdateData(value, previousExtra) {
|
|
30
|
+
const extrasInput = value;
|
|
31
|
+
const extra = (0, transformers_1.matchGameExtraFromInput)(extrasInput, previousExtra);
|
|
30
32
|
return {
|
|
31
33
|
stageId: value.stage_id,
|
|
32
34
|
matchId: value.parent_id,
|
|
@@ -40,39 +42,53 @@ function getUpdateData(value) {
|
|
|
40
42
|
opponent2Result: value.opponent2
|
|
41
43
|
? getParticipantResultUpsertData(value.opponent2)
|
|
42
44
|
: undefined,
|
|
45
|
+
extra: extra ?? undefined
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
|
-
function updateById(prisma, id, value) {
|
|
48
|
+
async function updateById(prisma, id, value, previousExtra) {
|
|
49
|
+
let extraSource = previousExtra ?? null;
|
|
50
|
+
if (previousExtra === undefined) {
|
|
51
|
+
const existing = await prisma.matchGame.findUnique({
|
|
52
|
+
where: { id },
|
|
53
|
+
select: { extra: true },
|
|
54
|
+
});
|
|
55
|
+
extraSource = existing?.extra ?? null;
|
|
56
|
+
}
|
|
46
57
|
return prisma.matchGame.update({
|
|
47
58
|
where: {
|
|
48
59
|
id,
|
|
49
60
|
},
|
|
50
|
-
data: getUpdateData(value),
|
|
61
|
+
data: getUpdateData(value, extraSource),
|
|
51
62
|
});
|
|
52
63
|
}
|
|
53
64
|
async function handleMatchGameUpdate(prisma, filter, value) {
|
|
54
65
|
if (typeof filter === 'number') {
|
|
55
66
|
// Update by Id
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
try {
|
|
68
|
+
await updateById(prisma, filter, value);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const games = await prisma.matchGame.findMany({
|
|
77
|
+
where: {
|
|
78
|
+
id: filter.id,
|
|
79
|
+
number: filter.number,
|
|
80
|
+
stageId: filter.stage_id,
|
|
81
|
+
matchId: filter.parent_id,
|
|
82
|
+
status: filter.status
|
|
83
|
+
? transformers_1.MatchStatusTransformer.to(filter.status)
|
|
84
|
+
: undefined,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
await Promise.all(games.map((game) => updateById(prisma, game.id, value, game.extra ?? null)));
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return false;
|
|
59
92
|
}
|
|
60
|
-
return prisma.matchGame
|
|
61
|
-
.findMany({
|
|
62
|
-
where: {
|
|
63
|
-
id: filter.id,
|
|
64
|
-
number: filter.number,
|
|
65
|
-
stageId: filter.stage_id,
|
|
66
|
-
matchId: filter.parent_id,
|
|
67
|
-
status: filter.status
|
|
68
|
-
? transformers_1.MatchStatusTransformer.to(filter.status)
|
|
69
|
-
: undefined,
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
.then((games) => {
|
|
73
|
-
return Promise.all(games.map((game) => updateById(prisma, game.id, value)));
|
|
74
|
-
})
|
|
75
|
-
.then(() => true)
|
|
76
|
-
.catch(() => false);
|
|
77
93
|
}
|
|
78
94
|
exports.handleMatchGameUpdate = handleMatchGameUpdate;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from 'brackets-manager/dist/types';
|
|
2
1
|
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
|
|
2
|
+
import type { MatchWithExtra } from '../../types';
|
|
3
|
+
export declare function handleMatchUpdate(prisma: PrismaClient, filter: Partial<MatchWithExtra> | number, value: Partial<MatchWithExtra> | MatchWithExtra): Promise<boolean>;
|
|
@@ -26,7 +26,9 @@ function getParticipantResultUpsertData(value) {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function getUpdateData(value) {
|
|
29
|
+
function getUpdateData(value, previousExtra) {
|
|
30
|
+
const extrasInput = value;
|
|
31
|
+
const extra = (0, transformers_1.matchExtraFromInput)(extrasInput, previousExtra);
|
|
30
32
|
return {
|
|
31
33
|
stageId: value.stage_id,
|
|
32
34
|
groupId: value.group_id,
|
|
@@ -42,40 +44,54 @@ function getUpdateData(value) {
|
|
|
42
44
|
opponent2Result: value.opponent2
|
|
43
45
|
? getParticipantResultUpsertData(value.opponent2)
|
|
44
46
|
: undefined,
|
|
47
|
+
extra: extra ?? undefined,
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
|
-
function updateById(prisma, id, value) {
|
|
50
|
+
async function updateById(prisma, id, value, previousExtra) {
|
|
51
|
+
let extraSource = previousExtra ?? null;
|
|
52
|
+
if (previousExtra === undefined) {
|
|
53
|
+
const existing = await prisma.match.findUnique({
|
|
54
|
+
where: { id },
|
|
55
|
+
select: { extra: true },
|
|
56
|
+
});
|
|
57
|
+
extraSource = existing?.extra ?? null;
|
|
58
|
+
}
|
|
48
59
|
return prisma.match.update({
|
|
49
60
|
where: {
|
|
50
61
|
id,
|
|
51
62
|
},
|
|
52
|
-
data: getUpdateData(value),
|
|
63
|
+
data: getUpdateData(value, extraSource),
|
|
53
64
|
});
|
|
54
65
|
}
|
|
55
66
|
async function handleMatchUpdate(prisma, filter, value) {
|
|
56
67
|
if (typeof filter === 'number') {
|
|
57
68
|
// Update by Id
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
try {
|
|
70
|
+
await updateById(prisma, filter, value);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const matches = await prisma.match.findMany({
|
|
79
|
+
where: {
|
|
80
|
+
id: filter.id,
|
|
81
|
+
number: filter.number,
|
|
82
|
+
stageId: filter.stage_id,
|
|
83
|
+
groupId: filter.group_id,
|
|
84
|
+
roundId: filter.round_id,
|
|
85
|
+
status: filter.status
|
|
86
|
+
? transformers_1.MatchStatusTransformer.to(filter.status)
|
|
87
|
+
: undefined,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
await Promise.all(matches.map((match) => updateById(prisma, match.id, value, match.extra ?? null)));
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
61
95
|
}
|
|
62
|
-
return prisma.match
|
|
63
|
-
.findMany({
|
|
64
|
-
where: {
|
|
65
|
-
id: filter.id,
|
|
66
|
-
number: filter.number,
|
|
67
|
-
stageId: filter.stage_id,
|
|
68
|
-
groupId: filter.group_id,
|
|
69
|
-
roundId: filter.round_id,
|
|
70
|
-
status: filter.status
|
|
71
|
-
? transformers_1.MatchStatusTransformer.to(filter.status)
|
|
72
|
-
: undefined,
|
|
73
|
-
},
|
|
74
|
-
})
|
|
75
|
-
.then((matches) => {
|
|
76
|
-
return Promise.all(matches.map((match) => updateById(prisma, match.id, value)));
|
|
77
|
-
})
|
|
78
|
-
.then(() => true)
|
|
79
|
-
.catch(() => false);
|
|
80
96
|
}
|
|
81
97
|
exports.handleMatchUpdate = handleMatchUpdate;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleParticipantUpdate = void 0;
|
|
4
|
+
const transformers_1 = require("../../transformers");
|
|
4
5
|
async function handleParticipantUpdate(prisma, filter, value) {
|
|
5
6
|
if (typeof filter === 'number') {
|
|
6
7
|
// Update by Id
|
|
@@ -12,6 +13,7 @@ async function handleParticipantUpdate(prisma, filter, value) {
|
|
|
12
13
|
data: {
|
|
13
14
|
name: value.name,
|
|
14
15
|
tournamentId: value.tournament_id,
|
|
16
|
+
extra: (0, transformers_1.participantExtraFromInput)(value) ?? undefined,
|
|
15
17
|
},
|
|
16
18
|
})
|
|
17
19
|
.then(() => true)
|
|
@@ -28,6 +30,7 @@ async function handleParticipantUpdate(prisma, filter, value) {
|
|
|
28
30
|
data: {
|
|
29
31
|
name: value.name,
|
|
30
32
|
tournamentId: value.tournament_id,
|
|
33
|
+
extra: (0, transformers_1.participantExtraFromInput)(value) ?? undefined,
|
|
31
34
|
},
|
|
32
35
|
})
|
|
33
36
|
.then(() => true)
|
|
@@ -2,5 +2,5 @@ import * as Prisma from '@prisma/client';
|
|
|
2
2
|
import { GrandFinalType } from 'brackets-model';
|
|
3
3
|
export declare const GrandFinalTypeTransformer: {
|
|
4
4
|
to(type: GrandFinalType): "SIMPLE" | "DOUBLE" | "NONE";
|
|
5
|
-
from(type: Prisma.GrandFinalType): "none" | "simple" | "double";
|
|
5
|
+
from(type: Prisma.$Enums.GrandFinalType): "none" | "simple" | "double";
|
|
6
6
|
};
|
|
@@ -2,5 +2,5 @@ import * as Prisma from '@prisma/client';
|
|
|
2
2
|
import { Result } from 'brackets-model';
|
|
3
3
|
export declare const MatchResultTransformer: {
|
|
4
4
|
to(result: Result): "WIN" | "DRAW" | "LOSS";
|
|
5
|
-
from(result: Prisma.MatchResult): "win" | "draw" | "loss";
|
|
5
|
+
from(result: Prisma.$Enums.MatchResult): "win" | "draw" | "loss";
|
|
6
6
|
};
|
|
@@ -2,5 +2,5 @@ import * as Prisma from '@prisma/client';
|
|
|
2
2
|
import { Status } from 'brackets-model';
|
|
3
3
|
export declare const MatchStatusTransformer: {
|
|
4
4
|
to(status: Status): "LOCKED" | "WAITING" | "READY" | "RUNNING" | "COMPLETED" | "ARCHIVED";
|
|
5
|
-
from(status: Prisma.MatchStatus): Status;
|
|
5
|
+
from(status: Prisma.$Enums.MatchStatus): Status;
|
|
6
6
|
};
|
|
@@ -2,5 +2,5 @@ import * as Prisma from '@prisma/client';
|
|
|
2
2
|
import { RoundRobinMode } from 'brackets-model';
|
|
3
3
|
export declare const RoundRobinModeTransformer: {
|
|
4
4
|
to(mode: RoundRobinMode): "SIMPLE" | "DOUBLE";
|
|
5
|
-
from(mode: Prisma.RoundRobinMode): "simple" | "double";
|
|
5
|
+
from(mode: Prisma.$Enums.RoundRobinMode): "simple" | "double";
|
|
6
6
|
};
|
|
@@ -2,5 +2,5 @@ import * as Prisma from '@prisma/client';
|
|
|
2
2
|
import { SeedOrdering } from 'brackets-model';
|
|
3
3
|
export declare const SeedOrderingTransformer: {
|
|
4
4
|
to(ordering: SeedOrdering): "NATURAL" | "REVERSE" | "HALF_SHIFT" | "REVERSE_HALF_SHIFT" | "PAIR_FLIP" | "INNER_OUTER" | "GROUPS_EFFORT_BALANCED" | "GROUPS_SEED_OPTIMIZED" | "GROUPS_BRACKET_OPTIMIZED";
|
|
5
|
-
from(ordering: Prisma.SeedOrdering): "reverse" | "natural" | "half_shift" | "reverse_half_shift" | "pair_flip" | "inner_outer" | "groups.effort_balanced" | "groups.seed_optimized" | "groups.bracket_optimized";
|
|
5
|
+
from(ordering: Prisma.$Enums.SeedOrdering): "reverse" | "natural" | "half_shift" | "reverse_half_shift" | "pair_flip" | "inner_outer" | "groups.effort_balanced" | "groups.seed_optimized" | "groups.bracket_optimized";
|
|
6
6
|
};
|
|
@@ -2,5 +2,5 @@ import * as Prisma from '@prisma/client';
|
|
|
2
2
|
import { StageType } from 'brackets-model';
|
|
3
3
|
export declare const StageTypeTransformer: {
|
|
4
4
|
to(type: StageType): "ROUND_ROBIN" | "SINGLE_ELIMINATION" | "DOUBLE_ELIMINATION";
|
|
5
|
-
from(type: Prisma.StageType): "round_robin" | "single_elimination" | "double_elimination";
|
|
5
|
+
from(type: Prisma.$Enums.StageType): "round_robin" | "single_elimination" | "double_elimination";
|
|
6
6
|
};
|
|
@@ -5,11 +5,11 @@ export declare const GroupTransformer: {
|
|
|
5
5
|
stageId: number;
|
|
6
6
|
number: number;
|
|
7
7
|
};
|
|
8
|
-
from(output:
|
|
8
|
+
from(output: {
|
|
9
|
+
number: number;
|
|
9
10
|
id: number;
|
|
10
11
|
stageId: number;
|
|
11
|
-
|
|
12
|
-
}, unknown> & {}): {
|
|
12
|
+
}): {
|
|
13
13
|
id: number;
|
|
14
14
|
stage_id: number;
|
|
15
15
|
number: number;
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MatchGame } from 'brackets-model';
|
|
1
|
+
import { Prisma, MatchGame as PrismaMatchGame, ParticipantMatchGameResult as PrismaParticipantMatchGameResult } from '@prisma/client';
|
|
3
2
|
import { OmitId } from 'brackets-manager';
|
|
3
|
+
import type { MatchGameExtrasInput, MatchGameWithExtra } from '../../types';
|
|
4
|
+
type PrismaMatchGameWithRelations = PrismaMatchGame & {
|
|
5
|
+
opponent1Result: PrismaParticipantMatchGameResult | null;
|
|
6
|
+
opponent2Result: PrismaParticipantMatchGameResult | null;
|
|
7
|
+
extra: Prisma.JsonValue | null;
|
|
8
|
+
};
|
|
9
|
+
export declare function matchGameExtraFromInput(input: MatchGameExtrasInput, previousExtra?: Prisma.JsonValue | null): Prisma.JsonValue | null | undefined;
|
|
4
10
|
export declare const MatchGameTransformer: {
|
|
5
|
-
to(input: Omit<OmitId<
|
|
11
|
+
to(input: Omit<OmitId<MatchGameWithExtra>, 'opponent1' | 'opponent2'>): {
|
|
12
|
+
extra?: Prisma.JsonValue | undefined;
|
|
6
13
|
status: "LOCKED" | "WAITING" | "READY" | "RUNNING" | "COMPLETED" | "ARCHIVED";
|
|
7
14
|
stageId: number;
|
|
8
15
|
matchId: number;
|
|
9
16
|
number: number;
|
|
10
17
|
};
|
|
11
|
-
from(output:
|
|
12
|
-
|
|
13
|
-
status: Prisma.MatchStatus;
|
|
14
|
-
stageId: number;
|
|
15
|
-
matchId: number;
|
|
16
|
-
number: number;
|
|
17
|
-
}, unknown> & {} & {
|
|
18
|
-
opponent1Result: Prisma.ParticipantMatchGameResult | null;
|
|
19
|
-
opponent2Result: Prisma.ParticipantMatchGameResult | null;
|
|
20
|
-
}): {
|
|
21
|
-
id: number;
|
|
22
|
-
status: import("brackets-model").Status;
|
|
23
|
-
stage_id: number;
|
|
24
|
-
parent_id: number;
|
|
25
|
-
number: number;
|
|
18
|
+
from(output: PrismaMatchGameWithRelations): {
|
|
19
|
+
extra: string | number | boolean | Prisma.JsonObject | Prisma.JsonArray | undefined;
|
|
26
20
|
opponent1: {
|
|
27
21
|
id: number | null;
|
|
28
22
|
forfeit: boolean | undefined;
|
|
@@ -37,5 +31,11 @@ export declare const MatchGameTransformer: {
|
|
|
37
31
|
score: number | undefined;
|
|
38
32
|
result: "win" | "draw" | "loss" | undefined;
|
|
39
33
|
} | null;
|
|
34
|
+
id: number;
|
|
35
|
+
status: import("brackets-model").Status;
|
|
36
|
+
stage_id: number;
|
|
37
|
+
parent_id: number;
|
|
38
|
+
number: number;
|
|
40
39
|
};
|
|
41
40
|
};
|
|
41
|
+
export {};
|
|
@@ -1,23 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MatchGameTransformer = void 0;
|
|
3
|
+
exports.MatchGameTransformer = exports.matchGameExtraFromInput = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function getMatchGameExtras(input) {
|
|
9
|
+
const clone = { ...input };
|
|
10
|
+
delete clone.id;
|
|
11
|
+
delete clone.status;
|
|
12
|
+
delete clone.stage_id;
|
|
13
|
+
delete clone.parent_id;
|
|
14
|
+
delete clone.number;
|
|
15
|
+
delete clone.opponent1;
|
|
16
|
+
delete clone.opponent2;
|
|
17
|
+
delete clone.extra;
|
|
18
|
+
return Object.entries(clone).reduce((extras, [key, value]) => {
|
|
19
|
+
if (value !== undefined) {
|
|
20
|
+
extras[key] = value;
|
|
21
|
+
}
|
|
22
|
+
return extras;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
function normalizeMatchGameExtras(extra) {
|
|
26
|
+
if (!isRecord(extra)) {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
return extra;
|
|
30
|
+
}
|
|
31
|
+
function hasOwnExtraProperty(input) {
|
|
32
|
+
return Object.prototype.hasOwnProperty.call(input, 'extra');
|
|
33
|
+
}
|
|
34
|
+
function matchGameExtraFromInput(input, previousExtra) {
|
|
35
|
+
const customFields = getMatchGameExtras(input);
|
|
36
|
+
const hasCustomFields = Object.keys(customFields).length > 0;
|
|
37
|
+
if (hasOwnExtraProperty(input)) {
|
|
38
|
+
const providedExtra = input.extra;
|
|
39
|
+
if (providedExtra === undefined) {
|
|
40
|
+
return hasCustomFields ? customFields : undefined;
|
|
41
|
+
}
|
|
42
|
+
if (isRecord(providedExtra)) {
|
|
43
|
+
const normalized = providedExtra;
|
|
44
|
+
return hasCustomFields
|
|
45
|
+
? { ...normalized, ...customFields }
|
|
46
|
+
: normalized;
|
|
47
|
+
}
|
|
48
|
+
return providedExtra ?? null;
|
|
49
|
+
}
|
|
50
|
+
if (!hasCustomFields) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (isRecord(previousExtra)) {
|
|
54
|
+
const normalized = previousExtra;
|
|
55
|
+
return { ...normalized, ...customFields };
|
|
56
|
+
}
|
|
57
|
+
return customFields;
|
|
58
|
+
}
|
|
59
|
+
exports.matchGameExtraFromInput = matchGameExtraFromInput;
|
|
5
60
|
exports.MatchGameTransformer = {
|
|
6
61
|
to(input) {
|
|
62
|
+
const extrasInput = input;
|
|
63
|
+
const extra = matchGameExtraFromInput(extrasInput);
|
|
7
64
|
return {
|
|
8
65
|
status: __1.MatchStatusTransformer.to(input.status),
|
|
9
66
|
stageId: input.stage_id,
|
|
10
67
|
matchId: input.parent_id,
|
|
11
68
|
number: input.number,
|
|
69
|
+
...(extra !== undefined ? { extra } : {}),
|
|
12
70
|
};
|
|
13
71
|
},
|
|
14
72
|
from(output) {
|
|
73
|
+
const normalizedExtras = normalizeMatchGameExtras(output.extra);
|
|
15
74
|
return {
|
|
16
75
|
id: output.id,
|
|
17
76
|
status: __1.MatchStatusTransformer.from(output.status),
|
|
18
77
|
stage_id: output.stageId,
|
|
19
78
|
parent_id: output.matchId,
|
|
20
79
|
number: output.number,
|
|
80
|
+
...normalizedExtras,
|
|
81
|
+
extra: output.extra ?? undefined,
|
|
21
82
|
opponent1: output.opponent1Result
|
|
22
83
|
? __1.ParticipantMatchResultTransformer.from(output.opponent1Result)
|
|
23
84
|
: null,
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Match } from 'brackets-model';
|
|
1
|
+
import type { Match as PrismaMatch, ParticipantMatchResult as PrismaParticipantMatchResult, Prisma } from '@prisma/client';
|
|
3
2
|
import { OmitId } from 'brackets-manager';
|
|
3
|
+
import type { MatchExtrasInput, MatchWithExtra } from '../../types';
|
|
4
|
+
type PrismaMatchWithRelations = PrismaMatch & {
|
|
5
|
+
opponent1Result: PrismaParticipantMatchResult | null;
|
|
6
|
+
opponent2Result: PrismaParticipantMatchResult | null;
|
|
7
|
+
extra: Prisma.JsonValue | null;
|
|
8
|
+
};
|
|
9
|
+
export declare function matchExtraFromInput(input: MatchExtrasInput, previousExtra?: Prisma.JsonValue | null): Prisma.JsonValue | null | undefined;
|
|
4
10
|
export declare const MatchTransformer: {
|
|
5
|
-
to(input: Omit<OmitId<
|
|
11
|
+
to(input: Omit<OmitId<MatchWithExtra>, 'opponent1' | 'opponent2'>): {
|
|
6
12
|
status: "LOCKED" | "WAITING" | "READY" | "RUNNING" | "COMPLETED" | "ARCHIVED";
|
|
7
13
|
stageId: number;
|
|
8
14
|
groupId: number;
|
|
9
15
|
roundId: number;
|
|
10
16
|
number: number;
|
|
11
17
|
childCount: number;
|
|
18
|
+
extra: string | number | boolean | Prisma.JsonObject | Prisma.JsonArray | null;
|
|
12
19
|
};
|
|
13
|
-
from(output:
|
|
14
|
-
|
|
15
|
-
status: Prisma.MatchStatus;
|
|
16
|
-
stageId: number;
|
|
17
|
-
groupId: number;
|
|
18
|
-
roundId: number;
|
|
19
|
-
number: number;
|
|
20
|
-
childCount: number;
|
|
21
|
-
}, unknown> & {} & {
|
|
22
|
-
opponent1Result: Prisma.ParticipantMatchResult | null;
|
|
23
|
-
opponent2Result: Prisma.ParticipantMatchResult | null;
|
|
24
|
-
}): {
|
|
25
|
-
id: number;
|
|
26
|
-
status: import("brackets-model").Status;
|
|
27
|
-
stage_id: number;
|
|
28
|
-
group_id: number;
|
|
29
|
-
round_id: number;
|
|
30
|
-
number: number;
|
|
31
|
-
child_count: number;
|
|
20
|
+
from(output: PrismaMatchWithRelations): {
|
|
21
|
+
extra: string | number | boolean | Prisma.JsonObject | Prisma.JsonArray | undefined;
|
|
32
22
|
opponent1: {
|
|
33
23
|
id: number | null;
|
|
34
24
|
forfeit: boolean | undefined;
|
|
@@ -43,5 +33,13 @@ export declare const MatchTransformer: {
|
|
|
43
33
|
score: number | undefined;
|
|
44
34
|
result: "win" | "draw" | "loss" | undefined;
|
|
45
35
|
} | null;
|
|
36
|
+
id: number;
|
|
37
|
+
status: import("brackets-model").Status;
|
|
38
|
+
stage_id: number;
|
|
39
|
+
group_id: number;
|
|
40
|
+
round_id: number;
|
|
41
|
+
number: number;
|
|
42
|
+
child_count: number;
|
|
46
43
|
};
|
|
47
44
|
};
|
|
45
|
+
export {};
|
|
@@ -1,9 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MatchTransformer = void 0;
|
|
3
|
+
exports.MatchTransformer = exports.matchExtraFromInput = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function getMatchExtras(input) {
|
|
9
|
+
const clone = { ...input };
|
|
10
|
+
delete clone.id;
|
|
11
|
+
delete clone.status;
|
|
12
|
+
delete clone.stage_id;
|
|
13
|
+
delete clone.group_id;
|
|
14
|
+
delete clone.round_id;
|
|
15
|
+
delete clone.number;
|
|
16
|
+
delete clone.child_count;
|
|
17
|
+
delete clone.opponent1;
|
|
18
|
+
delete clone.opponent2;
|
|
19
|
+
delete clone.extra;
|
|
20
|
+
return Object.entries(clone).reduce((extras, [key, value]) => {
|
|
21
|
+
if (value !== undefined) {
|
|
22
|
+
extras[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return extras;
|
|
25
|
+
}, {});
|
|
26
|
+
}
|
|
27
|
+
function normalizeMatchExtras(extra) {
|
|
28
|
+
if (!isRecord(extra)) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
return extra;
|
|
32
|
+
}
|
|
33
|
+
function hasOwnExtraProperty(input) {
|
|
34
|
+
return Object.prototype.hasOwnProperty.call(input, 'extra');
|
|
35
|
+
}
|
|
36
|
+
function matchExtraFromInput(input, previousExtra) {
|
|
37
|
+
const customFields = getMatchExtras(input);
|
|
38
|
+
const hasCustomFields = Object.keys(customFields).length > 0;
|
|
39
|
+
if (hasOwnExtraProperty(input)) {
|
|
40
|
+
const providedExtra = input.extra;
|
|
41
|
+
if (providedExtra === undefined) {
|
|
42
|
+
return hasCustomFields ? customFields : undefined;
|
|
43
|
+
}
|
|
44
|
+
if (isRecord(providedExtra)) {
|
|
45
|
+
const normalized = providedExtra;
|
|
46
|
+
return hasCustomFields
|
|
47
|
+
? { ...normalized, ...customFields }
|
|
48
|
+
: normalized;
|
|
49
|
+
}
|
|
50
|
+
return providedExtra ?? null;
|
|
51
|
+
}
|
|
52
|
+
if (!hasCustomFields) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
if (isRecord(previousExtra)) {
|
|
56
|
+
const normalized = previousExtra;
|
|
57
|
+
return { ...normalized, ...customFields };
|
|
58
|
+
}
|
|
59
|
+
return customFields;
|
|
60
|
+
}
|
|
61
|
+
exports.matchExtraFromInput = matchExtraFromInput;
|
|
5
62
|
exports.MatchTransformer = {
|
|
6
63
|
to(input) {
|
|
64
|
+
const extrasInput = input;
|
|
65
|
+
const extra = matchExtraFromInput(extrasInput);
|
|
7
66
|
return {
|
|
8
67
|
status: __1.MatchStatusTransformer.to(input.status),
|
|
9
68
|
stageId: input.stage_id,
|
|
@@ -11,9 +70,11 @@ exports.MatchTransformer = {
|
|
|
11
70
|
roundId: input.round_id,
|
|
12
71
|
number: input.number,
|
|
13
72
|
childCount: input.child_count,
|
|
73
|
+
extra: extra ?? null,
|
|
14
74
|
};
|
|
15
75
|
},
|
|
16
76
|
from(output) {
|
|
77
|
+
const normalizedExtras = normalizeMatchExtras(output.extra);
|
|
17
78
|
return {
|
|
18
79
|
id: output.id,
|
|
19
80
|
status: __1.MatchStatusTransformer.from(output.status),
|
|
@@ -22,6 +83,8 @@ exports.MatchTransformer = {
|
|
|
22
83
|
round_id: output.roundId,
|
|
23
84
|
number: output.number,
|
|
24
85
|
child_count: output.childCount,
|
|
86
|
+
...normalizedExtras,
|
|
87
|
+
extra: output.extra ?? undefined,
|
|
25
88
|
opponent1: output.opponent1Result
|
|
26
89
|
? __1.ParticipantMatchResultTransformer.from(output.opponent1Result)
|
|
27
90
|
: null,
|
|
@@ -8,25 +8,25 @@ export declare const ParticipantMatchResultTransformer: {
|
|
|
8
8
|
score: number | null;
|
|
9
9
|
result: "WIN" | "DRAW" | "LOSS" | null;
|
|
10
10
|
};
|
|
11
|
-
from(output:
|
|
11
|
+
from(output: {
|
|
12
12
|
id: number;
|
|
13
|
-
participantId: number | null;
|
|
14
13
|
position: number | null;
|
|
14
|
+
result: Prisma.$Enums.MatchResult | null;
|
|
15
|
+
participantId: number | null;
|
|
15
16
|
forfeit: boolean | null;
|
|
16
17
|
score: number | null;
|
|
17
|
-
result: Prisma.MatchResult | null;
|
|
18
18
|
opponent1MatchId: number | null;
|
|
19
19
|
opponent2MatchId: number | null;
|
|
20
|
-
}
|
|
20
|
+
} | {
|
|
21
21
|
id: number;
|
|
22
|
-
participantId: number | null;
|
|
23
22
|
position: number | null;
|
|
23
|
+
result: Prisma.$Enums.MatchResult | null;
|
|
24
|
+
participantId: number | null;
|
|
24
25
|
forfeit: boolean | null;
|
|
25
26
|
score: number | null;
|
|
26
|
-
result: Prisma.MatchResult | null;
|
|
27
27
|
opponent1MatchGameId: number | null;
|
|
28
28
|
opponent2MatchGameId: number | null;
|
|
29
|
-
}
|
|
29
|
+
}): {
|
|
30
30
|
id: number | null;
|
|
31
31
|
forfeit: boolean | undefined;
|
|
32
32
|
position: number | undefined;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { Prisma } from '@prisma/client';
|
|
1
2
|
import { Participant } from 'brackets-model';
|
|
2
3
|
import { OmitId } from 'brackets-manager';
|
|
4
|
+
export declare function participantExtraFromInput(input: Partial<Participant> & Record<string, unknown>): Prisma.JsonValue | null;
|
|
3
5
|
export declare const ParticipantTransformer: {
|
|
4
6
|
to(input: OmitId<Participant>): {
|
|
5
7
|
name: string;
|
|
6
8
|
tournamentId: number;
|
|
9
|
+
extra: Prisma.JsonValue;
|
|
7
10
|
};
|
|
8
|
-
from(output:
|
|
11
|
+
from(output: {
|
|
9
12
|
id: number;
|
|
10
|
-
tournamentId: number;
|
|
11
13
|
name: string;
|
|
12
|
-
|
|
14
|
+
tournamentId: number;
|
|
15
|
+
extra: Prisma.JsonValue;
|
|
16
|
+
}): {
|
|
13
17
|
id: number;
|
|
14
18
|
name: string;
|
|
15
19
|
tournament_id: number;
|
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParticipantTransformer = void 0;
|
|
3
|
+
exports.ParticipantTransformer = exports.participantExtraFromInput = void 0;
|
|
4
4
|
function getParticipantExtras(input) {
|
|
5
5
|
const clone = { ...input };
|
|
6
6
|
// Delete Participant fields
|
|
7
7
|
delete clone.id;
|
|
8
8
|
delete clone.name;
|
|
9
9
|
delete clone.tournament_id;
|
|
10
|
+
delete clone.extra;
|
|
10
11
|
// Return Extras
|
|
11
12
|
return clone;
|
|
12
13
|
}
|
|
14
|
+
function getParticipantExtraValue(input) {
|
|
15
|
+
const extra = getParticipantExtras(input);
|
|
16
|
+
return Object.keys(extra).length > 0 ? extra : null;
|
|
17
|
+
}
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
function normalizeParticipantExtras(extra) {
|
|
22
|
+
if (!isRecord(extra)) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
return extra;
|
|
26
|
+
}
|
|
27
|
+
function participantExtraFromInput(input) {
|
|
28
|
+
return getParticipantExtraValue(input);
|
|
29
|
+
}
|
|
30
|
+
exports.participantExtraFromInput = participantExtraFromInput;
|
|
13
31
|
exports.ParticipantTransformer = {
|
|
14
32
|
to(input) {
|
|
15
33
|
return {
|
|
16
34
|
name: input.name,
|
|
17
35
|
tournamentId: input.tournament_id,
|
|
18
|
-
|
|
36
|
+
extra: getParticipantExtraValue(input),
|
|
19
37
|
};
|
|
20
38
|
},
|
|
21
39
|
from(output) {
|
|
@@ -23,6 +41,7 @@ exports.ParticipantTransformer = {
|
|
|
23
41
|
id: output.id,
|
|
24
42
|
name: output.name,
|
|
25
43
|
tournament_id: output.tournamentId,
|
|
44
|
+
...normalizeParticipantExtras(output.extra),
|
|
26
45
|
};
|
|
27
46
|
},
|
|
28
47
|
};
|
|
@@ -6,12 +6,12 @@ export declare const RoundTransformer: {
|
|
|
6
6
|
groupId: number;
|
|
7
7
|
number: number;
|
|
8
8
|
};
|
|
9
|
-
from(output:
|
|
9
|
+
from(output: {
|
|
10
|
+
number: number;
|
|
10
11
|
id: number;
|
|
11
12
|
stageId: number;
|
|
12
13
|
groupId: number;
|
|
13
|
-
|
|
14
|
-
}, unknown> & {}): {
|
|
14
|
+
}): {
|
|
15
15
|
id: number;
|
|
16
16
|
stage_id: number;
|
|
17
17
|
group_id: number;
|
|
@@ -14,20 +14,20 @@ export declare const StageSettingsTransformer: {
|
|
|
14
14
|
skipFirstRound: boolean | null;
|
|
15
15
|
grandFinal: "SIMPLE" | "DOUBLE" | "NONE" | null;
|
|
16
16
|
};
|
|
17
|
-
from(output: Omit<
|
|
17
|
+
from(output: Omit<{
|
|
18
18
|
id: string;
|
|
19
|
-
stageId: number;
|
|
20
19
|
size: number | null;
|
|
21
|
-
|
|
20
|
+
stageId: number;
|
|
21
|
+
seedOrdering: Prisma.$Enums.SeedOrdering[];
|
|
22
22
|
balanceByes: boolean | null;
|
|
23
23
|
matchesChildCount: number | null;
|
|
24
24
|
groupCount: number | null;
|
|
25
|
-
roundRobinMode: Prisma.RoundRobinMode | null;
|
|
26
|
-
manualOrdering:
|
|
25
|
+
roundRobinMode: Prisma.$Enums.RoundRobinMode | null;
|
|
26
|
+
manualOrdering: import("@prisma/client/runtime/library").JsonValue;
|
|
27
27
|
consolationFinal: boolean | null;
|
|
28
28
|
skipFirstRound: boolean | null;
|
|
29
|
-
grandFinal: Prisma.GrandFinalType | null;
|
|
30
|
-
},
|
|
29
|
+
grandFinal: Prisma.$Enums.GrandFinalType | null;
|
|
30
|
+
}, "stageId">): {
|
|
31
31
|
id: string;
|
|
32
32
|
size: number | undefined;
|
|
33
33
|
seedOrdering: ("reverse" | "natural" | "half_shift" | "reverse_half_shift" | "pair_flip" | "inner_outer" | "groups.effort_balanced" | "groups.seed_optimized" | "groups.bracket_optimized")[];
|
|
@@ -8,13 +8,13 @@ export declare const StageTransformer: {
|
|
|
8
8
|
number: number;
|
|
9
9
|
type: "ROUND_ROBIN" | "SINGLE_ELIMINATION" | "DOUBLE_ELIMINATION";
|
|
10
10
|
};
|
|
11
|
-
from(output:
|
|
11
|
+
from(output: {
|
|
12
|
+
number: number;
|
|
13
|
+
type: Prisma.$Enums.StageType;
|
|
12
14
|
id: number;
|
|
13
|
-
tournamentId: number;
|
|
14
15
|
name: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, unknown> & {} & {
|
|
16
|
+
tournamentId: number;
|
|
17
|
+
} & {
|
|
18
18
|
settings: Prisma.StageSettings;
|
|
19
19
|
}): {
|
|
20
20
|
id: number;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataTypes } from 'brackets-manager/dist/types';
|
|
2
|
+
import { Prisma } from '@prisma/client';
|
|
3
|
+
export type MatchWithExtra = DataTypes['match'] & {
|
|
4
|
+
extra?: Prisma.JsonValue | null;
|
|
5
|
+
};
|
|
6
|
+
export type MatchExtrasInput = Partial<MatchWithExtra> & Record<string, unknown>;
|
|
7
|
+
export type MatchGameWithExtra = DataTypes['match_game'] & {
|
|
8
|
+
extra?: Prisma.JsonValue | null;
|
|
9
|
+
};
|
|
10
|
+
export type MatchGameExtrasInput = Partial<MatchGameWithExtra> & Record<string, unknown>;
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brackets-prisma-db",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "A SQL database with Prisma for brackets-manager.js",
|
|
5
5
|
"author": "Tandashi",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"repository": {
|
|
@@ -33,16 +33,15 @@
|
|
|
33
33
|
"prepublishOnly": "npm run build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@prisma/client": "^
|
|
37
|
-
"brackets-
|
|
38
|
-
"brackets-model": "^1.4.0",
|
|
36
|
+
"@prisma/client": "^6.17.1",
|
|
37
|
+
"brackets-model": "1.4.0",
|
|
39
38
|
"typescript": "^5.1.3"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@types/node": "^20.3.0",
|
|
43
|
-
"prisma": "^
|
|
42
|
+
"prisma": "^6.17.1"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
|
-
"brackets-manager": "
|
|
45
|
+
"brackets-manager": "1.x"
|
|
47
46
|
}
|
|
48
|
-
}
|
|
47
|
+
}
|