brackets-drizzle-db 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/LICENSE +674 -0
- package/README.md +136 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.js +48 -0
- package/dist/db/schema/enums.d.ts +12 -0
- package/dist/db/schema/enums.js +41 -0
- package/dist/db/schema/group.d.ts +65 -0
- package/dist/db/schema/group.js +26 -0
- package/dist/db/schema/index.d.ts +8 -0
- package/dist/db/schema/index.js +26 -0
- package/dist/db/schema/match-game.d.ts +267 -0
- package/dist/db/schema/match-game.js +81 -0
- package/dist/db/schema/match.d.ts +303 -0
- package/dist/db/schema/match.js +94 -0
- package/dist/db/schema/participant.d.ts +82 -0
- package/dist/db/schema/participant.js +27 -0
- package/dist/db/schema/round.d.ts +82 -0
- package/dist/db/schema/round.js +33 -0
- package/dist/db/schema/stage.d.ts +344 -0
- package/dist/db/schema/stage.js +72 -0
- package/dist/db/schema/tournament.d.ts +115 -0
- package/dist/db/schema/tournament.js +25 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/storage-handlers/delete-handlers/group.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/group.js +27 -0
- package/dist/storage-handlers/delete-handlers/index.d.ts +7 -0
- package/dist/storage-handlers/delete-handlers/index.js +23 -0
- package/dist/storage-handlers/delete-handlers/match-game.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/match-game.js +43 -0
- package/dist/storage-handlers/delete-handlers/match.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/match.js +45 -0
- package/dist/storage-handlers/delete-handlers/participant.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/participant.js +27 -0
- package/dist/storage-handlers/delete-handlers/round.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/round.js +29 -0
- package/dist/storage-handlers/delete-handlers/stage.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/stage.js +48 -0
- package/dist/storage-handlers/delete-handlers/tournament.d.ts +3 -0
- package/dist/storage-handlers/delete-handlers/tournament.js +25 -0
- package/dist/storage-handlers/delete.d.ts +3 -0
- package/dist/storage-handlers/delete.js +24 -0
- package/dist/storage-handlers/index.d.ts +4 -0
- package/dist/storage-handlers/index.js +20 -0
- package/dist/storage-handlers/insert-handlers/group.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/group.js +21 -0
- package/dist/storage-handlers/insert-handlers/index.d.ts +7 -0
- package/dist/storage-handlers/insert-handlers/index.js +23 -0
- package/dist/storage-handlers/insert-handlers/match-game.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/match-game.js +66 -0
- package/dist/storage-handlers/insert-handlers/match.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/match.js +66 -0
- package/dist/storage-handlers/insert-handlers/participant.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/participant.js +25 -0
- package/dist/storage-handlers/insert-handlers/round.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/round.js +21 -0
- package/dist/storage-handlers/insert-handlers/stage.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/stage.js +44 -0
- package/dist/storage-handlers/insert-handlers/tournament.d.ts +5 -0
- package/dist/storage-handlers/insert-handlers/tournament.js +25 -0
- package/dist/storage-handlers/insert.d.ts +3 -0
- package/dist/storage-handlers/insert.js +25 -0
- package/dist/storage-handlers/select-handlers/group.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/group.js +44 -0
- package/dist/storage-handlers/select-handlers/index.d.ts +7 -0
- package/dist/storage-handlers/select-handlers/index.js +23 -0
- package/dist/storage-handlers/select-handlers/match-game.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/match-game.js +80 -0
- package/dist/storage-handlers/select-handlers/match.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/match.js +86 -0
- package/dist/storage-handlers/select-handlers/participant.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/participant.js +40 -0
- package/dist/storage-handlers/select-handlers/round.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/round.js +46 -0
- package/dist/storage-handlers/select-handlers/stage.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/stage.js +60 -0
- package/dist/storage-handlers/select-handlers/tournament.d.ts +3 -0
- package/dist/storage-handlers/select-handlers/tournament.js +38 -0
- package/dist/storage-handlers/select.d.ts +3 -0
- package/dist/storage-handlers/select.js +24 -0
- package/dist/storage-handlers/update-handlers/group.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/group.js +33 -0
- package/dist/storage-handlers/update-handlers/index.d.ts +7 -0
- package/dist/storage-handlers/update-handlers/index.js +23 -0
- package/dist/storage-handlers/update-handlers/match-game.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/match-game.js +99 -0
- package/dist/storage-handlers/update-handlers/match.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/match.js +105 -0
- package/dist/storage-handlers/update-handlers/participant.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/participant.js +40 -0
- package/dist/storage-handlers/update-handlers/round.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/round.js +37 -0
- package/dist/storage-handlers/update-handlers/stage.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/stage.js +61 -0
- package/dist/storage-handlers/update-handlers/tournament.d.ts +3 -0
- package/dist/storage-handlers/update-handlers/tournament.js +40 -0
- package/dist/storage-handlers/update.d.ts +3 -0
- package/dist/storage-handlers/update.js +24 -0
- package/dist/storage.d.ts +18 -0
- package/dist/storage.js +25 -0
- package/dist/transformers/enum/grand-final-type.d.ts +6 -0
- package/dist/transformers/enum/grand-final-type.js +25 -0
- package/dist/transformers/enum/index.d.ts +6 -0
- package/dist/transformers/enum/index.js +22 -0
- package/dist/transformers/enum/match-result.d.ts +6 -0
- package/dist/transformers/enum/match-result.js +25 -0
- package/dist/transformers/enum/match-status.d.ts +6 -0
- package/dist/transformers/enum/match-status.js +38 -0
- package/dist/transformers/enum/round-robin-mode.d.ts +6 -0
- package/dist/transformers/enum/round-robin-mode.js +21 -0
- package/dist/transformers/enum/seed-ordering.d.ts +6 -0
- package/dist/transformers/enum/seed-ordering.js +49 -0
- package/dist/transformers/enum/stage-type.d.ts +6 -0
- package/dist/transformers/enum/stage-type.js +25 -0
- package/dist/transformers/index.d.ts +2 -0
- package/dist/transformers/index.js +18 -0
- package/dist/transformers/model/group.d.ts +15 -0
- package/dist/transformers/model/group.js +18 -0
- package/dist/transformers/model/index.d.ts +9 -0
- package/dist/transformers/model/index.js +25 -0
- package/dist/transformers/model/match-game.d.ts +21 -0
- package/dist/transformers/model/match-game.js +90 -0
- package/dist/transformers/model/match.d.ts +23 -0
- package/dist/transformers/model/match.js +96 -0
- package/dist/transformers/model/participant-result.d.ts +21 -0
- package/dist/transformers/model/participant-result.js +26 -0
- package/dist/transformers/model/participant.d.ts +19 -0
- package/dist/transformers/model/participant.js +47 -0
- package/dist/transformers/model/round.d.ts +17 -0
- package/dist/transformers/model/round.js +20 -0
- package/dist/transformers/model/stage-settings.d.ts +18 -0
- package/dist/transformers/model/stage-settings.js +46 -0
- package/dist/transformers/model/stage.d.ts +22 -0
- package/dist/transformers/model/stage.js +26 -0
- package/dist/transformers/model/tournament.d.ts +30 -0
- package/dist/transformers/model/tournament.js +39 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +2 -0
- package/package.json +45 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoundRobinModeTransformer = void 0;
|
|
4
|
+
exports.RoundRobinModeTransformer = {
|
|
5
|
+
to(mode) {
|
|
6
|
+
switch (mode) {
|
|
7
|
+
case 'simple':
|
|
8
|
+
return 'SIMPLE';
|
|
9
|
+
case 'double':
|
|
10
|
+
return 'DOUBLE';
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
from(mode) {
|
|
14
|
+
switch (mode) {
|
|
15
|
+
case 'SIMPLE':
|
|
16
|
+
return 'simple';
|
|
17
|
+
case 'DOUBLE':
|
|
18
|
+
return 'double';
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SeedOrdering } from 'brackets-model';
|
|
2
|
+
import type { SeedOrdering as DrizzleSeedOrdering } from '../../db/schema/enums';
|
|
3
|
+
export declare const SeedOrderingTransformer: {
|
|
4
|
+
to(ordering: SeedOrdering): DrizzleSeedOrdering;
|
|
5
|
+
from(ordering: DrizzleSeedOrdering): SeedOrdering;
|
|
6
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeedOrderingTransformer = void 0;
|
|
4
|
+
exports.SeedOrderingTransformer = {
|
|
5
|
+
to(ordering) {
|
|
6
|
+
switch (ordering) {
|
|
7
|
+
case 'natural':
|
|
8
|
+
return 'NATURAL';
|
|
9
|
+
case 'reverse':
|
|
10
|
+
return 'REVERSE';
|
|
11
|
+
case 'half_shift':
|
|
12
|
+
return 'HALF_SHIFT';
|
|
13
|
+
case 'reverse_half_shift':
|
|
14
|
+
return 'REVERSE_HALF_SHIFT';
|
|
15
|
+
case 'pair_flip':
|
|
16
|
+
return 'PAIR_FLIP';
|
|
17
|
+
case 'inner_outer':
|
|
18
|
+
return 'INNER_OUTER';
|
|
19
|
+
case 'groups.effort_balanced':
|
|
20
|
+
return 'GROUPS_EFFORT_BALANCED';
|
|
21
|
+
case 'groups.seed_optimized':
|
|
22
|
+
return 'GROUPS_SEED_OPTIMIZED';
|
|
23
|
+
case 'groups.bracket_optimized':
|
|
24
|
+
return 'GROUPS_BRACKET_OPTIMIZED';
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
from(ordering) {
|
|
28
|
+
switch (ordering) {
|
|
29
|
+
case 'NATURAL':
|
|
30
|
+
return 'natural';
|
|
31
|
+
case 'REVERSE':
|
|
32
|
+
return 'reverse';
|
|
33
|
+
case 'HALF_SHIFT':
|
|
34
|
+
return 'half_shift';
|
|
35
|
+
case 'REVERSE_HALF_SHIFT':
|
|
36
|
+
return 'reverse_half_shift';
|
|
37
|
+
case 'PAIR_FLIP':
|
|
38
|
+
return 'pair_flip';
|
|
39
|
+
case 'INNER_OUTER':
|
|
40
|
+
return 'inner_outer';
|
|
41
|
+
case 'GROUPS_EFFORT_BALANCED':
|
|
42
|
+
return 'groups.effort_balanced';
|
|
43
|
+
case 'GROUPS_SEED_OPTIMIZED':
|
|
44
|
+
return 'groups.seed_optimized';
|
|
45
|
+
case 'GROUPS_BRACKET_OPTIMIZED':
|
|
46
|
+
return 'groups.bracket_optimized';
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StageTypeTransformer = void 0;
|
|
4
|
+
exports.StageTypeTransformer = {
|
|
5
|
+
to(type) {
|
|
6
|
+
switch (type) {
|
|
7
|
+
case 'round_robin':
|
|
8
|
+
return 'ROUND_ROBIN';
|
|
9
|
+
case 'single_elimination':
|
|
10
|
+
return 'SINGLE_ELIMINATION';
|
|
11
|
+
case 'double_elimination':
|
|
12
|
+
return 'DOUBLE_ELIMINATION';
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
from(type) {
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'ROUND_ROBIN':
|
|
18
|
+
return 'round_robin';
|
|
19
|
+
case 'SINGLE_ELIMINATION':
|
|
20
|
+
return 'single_elimination';
|
|
21
|
+
case 'DOUBLE_ELIMINATION':
|
|
22
|
+
return 'double_elimination';
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -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("./enum"), exports);
|
|
18
|
+
__exportStar(require("./model"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Group } from 'brackets-model';
|
|
2
|
+
import { OmitId } from 'brackets-manager';
|
|
3
|
+
import type { Group as DrizzleGroup } from '../../db/schema';
|
|
4
|
+
type GroupInput = {
|
|
5
|
+
stage_id: number | string;
|
|
6
|
+
number: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const GroupTransformer: {
|
|
9
|
+
to(input: OmitId<Group> | GroupInput): {
|
|
10
|
+
stageId: string;
|
|
11
|
+
number: number;
|
|
12
|
+
};
|
|
13
|
+
from(output: DrizzleGroup): Group;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupTransformer = void 0;
|
|
4
|
+
exports.GroupTransformer = {
|
|
5
|
+
to(input) {
|
|
6
|
+
return {
|
|
7
|
+
stageId: String(input.stage_id),
|
|
8
|
+
number: input.number,
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
from(output) {
|
|
12
|
+
return {
|
|
13
|
+
id: output.id,
|
|
14
|
+
stage_id: output.stageId,
|
|
15
|
+
number: output.number,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './group';
|
|
2
|
+
export * from './match';
|
|
3
|
+
export * from './match-game';
|
|
4
|
+
export * from './participant';
|
|
5
|
+
export * from './participant-result';
|
|
6
|
+
export * from './round';
|
|
7
|
+
export * from './stage';
|
|
8
|
+
export * from './stage-settings';
|
|
9
|
+
export * from './tournament';
|
|
@@ -0,0 +1,25 @@
|
|
|
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("./group"), exports);
|
|
18
|
+
__exportStar(require("./match"), exports);
|
|
19
|
+
__exportStar(require("./match-game"), exports);
|
|
20
|
+
__exportStar(require("./participant"), exports);
|
|
21
|
+
__exportStar(require("./participant-result"), exports);
|
|
22
|
+
__exportStar(require("./round"), exports);
|
|
23
|
+
__exportStar(require("./stage"), exports);
|
|
24
|
+
__exportStar(require("./stage-settings"), exports);
|
|
25
|
+
__exportStar(require("./tournament"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OmitId } from 'brackets-manager';
|
|
2
|
+
import type { MatchGameWithExtra, MatchGameExtrasInput, JsonValue } from '../../types';
|
|
3
|
+
import type { MatchGame as DrizzleMatchGame, ParticipantMatchGameResult } from '../../db/schema';
|
|
4
|
+
type DrizzleMatchGameWithRelations = DrizzleMatchGame & {
|
|
5
|
+
opponent1Result: ParticipantMatchGameResult | null;
|
|
6
|
+
opponent2Result: ParticipantMatchGameResult | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function matchGameExtraFromInput(input: MatchGameExtrasInput, previousExtra?: JsonValue | null): JsonValue | null | undefined;
|
|
9
|
+
export declare const MatchGameTransformer: {
|
|
10
|
+
to(input: Omit<OmitId<MatchGameWithExtra>, "opponent1" | "opponent2">): {
|
|
11
|
+
status: "LOCKED" | "WAITING" | "READY" | "RUNNING" | "COMPLETED" | "ARCHIVED";
|
|
12
|
+
stageId: string;
|
|
13
|
+
matchId: string;
|
|
14
|
+
number: number;
|
|
15
|
+
extra: string | number | boolean | JsonValue[] | {
|
|
16
|
+
[key: string]: JsonValue;
|
|
17
|
+
} | null;
|
|
18
|
+
};
|
|
19
|
+
from(output: DrizzleMatchGameWithRelations): MatchGameWithExtra;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MatchGameTransformer = void 0;
|
|
4
|
+
exports.matchGameExtraFromInput = matchGameExtraFromInput;
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function getMatchGameExtras(input) {
|
|
10
|
+
const clone = { ...input };
|
|
11
|
+
delete clone.id;
|
|
12
|
+
delete clone.status;
|
|
13
|
+
delete clone.stage_id;
|
|
14
|
+
delete clone.parent_id;
|
|
15
|
+
delete clone.number;
|
|
16
|
+
delete clone.opponent1;
|
|
17
|
+
delete clone.opponent2;
|
|
18
|
+
delete clone.extra;
|
|
19
|
+
return Object.entries(clone).reduce((extras, [key, value]) => {
|
|
20
|
+
if (value !== undefined) {
|
|
21
|
+
extras[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return extras;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
function normalizeMatchGameExtras(extra) {
|
|
27
|
+
if (!isRecord(extra)) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
return extra;
|
|
31
|
+
}
|
|
32
|
+
function hasOwnExtraProperty(input) {
|
|
33
|
+
return Object.prototype.hasOwnProperty.call(input, 'extra');
|
|
34
|
+
}
|
|
35
|
+
function matchGameExtraFromInput(input, previousExtra) {
|
|
36
|
+
const customFields = getMatchGameExtras(input);
|
|
37
|
+
const hasCustomFields = Object.keys(customFields).length > 0;
|
|
38
|
+
if (hasOwnExtraProperty(input)) {
|
|
39
|
+
const providedExtra = input.extra;
|
|
40
|
+
if (providedExtra === undefined) {
|
|
41
|
+
return hasCustomFields ? customFields : undefined;
|
|
42
|
+
}
|
|
43
|
+
if (isRecord(providedExtra)) {
|
|
44
|
+
const normalized = providedExtra;
|
|
45
|
+
return hasCustomFields
|
|
46
|
+
? { ...normalized, ...customFields }
|
|
47
|
+
: normalized;
|
|
48
|
+
}
|
|
49
|
+
return providedExtra ?? null;
|
|
50
|
+
}
|
|
51
|
+
if (!hasCustomFields) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (isRecord(previousExtra)) {
|
|
55
|
+
const normalized = previousExtra;
|
|
56
|
+
return { ...normalized, ...customFields };
|
|
57
|
+
}
|
|
58
|
+
return customFields;
|
|
59
|
+
}
|
|
60
|
+
exports.MatchGameTransformer = {
|
|
61
|
+
to(input) {
|
|
62
|
+
const extrasInput = input;
|
|
63
|
+
const extra = matchGameExtraFromInput(extrasInput);
|
|
64
|
+
return {
|
|
65
|
+
status: __1.MatchStatusTransformer.to(input.status),
|
|
66
|
+
stageId: String(input.stage_id),
|
|
67
|
+
matchId: String(input.parent_id),
|
|
68
|
+
number: input.number,
|
|
69
|
+
extra: extra ?? null,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
from(output) {
|
|
73
|
+
const normalizedExtras = normalizeMatchGameExtras(output.extra);
|
|
74
|
+
return {
|
|
75
|
+
id: output.id,
|
|
76
|
+
status: __1.MatchStatusTransformer.from(output.status),
|
|
77
|
+
stage_id: output.stageId,
|
|
78
|
+
parent_id: output.matchId,
|
|
79
|
+
number: output.number,
|
|
80
|
+
...normalizedExtras,
|
|
81
|
+
extra: output.extra ?? undefined,
|
|
82
|
+
opponent1: output.opponent1Result
|
|
83
|
+
? __1.ParticipantMatchResultTransformer.from(output.opponent1Result)
|
|
84
|
+
: null,
|
|
85
|
+
opponent2: output.opponent2Result
|
|
86
|
+
? __1.ParticipantMatchResultTransformer.from(output.opponent2Result)
|
|
87
|
+
: null,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OmitId } from 'brackets-manager';
|
|
2
|
+
import type { MatchWithExtra, MatchExtrasInput, JsonValue } from '../../types';
|
|
3
|
+
import type { Match as DrizzleMatch, ParticipantMatchResult } from '../../db/schema';
|
|
4
|
+
type DrizzleMatchWithRelations = DrizzleMatch & {
|
|
5
|
+
opponent1Result: ParticipantMatchResult | null;
|
|
6
|
+
opponent2Result: ParticipantMatchResult | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function matchExtraFromInput(input: MatchExtrasInput, previousExtra?: JsonValue | null): JsonValue | null | undefined;
|
|
9
|
+
export declare const MatchTransformer: {
|
|
10
|
+
to(input: Omit<OmitId<MatchWithExtra>, "opponent1" | "opponent2">): {
|
|
11
|
+
status: "LOCKED" | "WAITING" | "READY" | "RUNNING" | "COMPLETED" | "ARCHIVED";
|
|
12
|
+
stageId: string;
|
|
13
|
+
groupId: string;
|
|
14
|
+
roundId: string;
|
|
15
|
+
number: number;
|
|
16
|
+
childCount: number;
|
|
17
|
+
extra: string | number | boolean | JsonValue[] | {
|
|
18
|
+
[key: string]: JsonValue;
|
|
19
|
+
} | null;
|
|
20
|
+
};
|
|
21
|
+
from(output: DrizzleMatchWithRelations): MatchWithExtra;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MatchTransformer = void 0;
|
|
4
|
+
exports.matchExtraFromInput = matchExtraFromInput;
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function getMatchExtras(input) {
|
|
10
|
+
const clone = { ...input };
|
|
11
|
+
delete clone.id;
|
|
12
|
+
delete clone.status;
|
|
13
|
+
delete clone.stage_id;
|
|
14
|
+
delete clone.group_id;
|
|
15
|
+
delete clone.round_id;
|
|
16
|
+
delete clone.number;
|
|
17
|
+
delete clone.child_count;
|
|
18
|
+
delete clone.opponent1;
|
|
19
|
+
delete clone.opponent2;
|
|
20
|
+
delete clone.extra;
|
|
21
|
+
return Object.entries(clone).reduce((extras, [key, value]) => {
|
|
22
|
+
if (value !== undefined) {
|
|
23
|
+
extras[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return extras;
|
|
26
|
+
}, {});
|
|
27
|
+
}
|
|
28
|
+
function normalizeMatchExtras(extra) {
|
|
29
|
+
if (!isRecord(extra)) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
return extra;
|
|
33
|
+
}
|
|
34
|
+
function hasOwnExtraProperty(input) {
|
|
35
|
+
return Object.prototype.hasOwnProperty.call(input, 'extra');
|
|
36
|
+
}
|
|
37
|
+
function matchExtraFromInput(input, previousExtra) {
|
|
38
|
+
const customFields = getMatchExtras(input);
|
|
39
|
+
const hasCustomFields = Object.keys(customFields).length > 0;
|
|
40
|
+
if (hasOwnExtraProperty(input)) {
|
|
41
|
+
const providedExtra = input.extra;
|
|
42
|
+
if (providedExtra === undefined) {
|
|
43
|
+
return hasCustomFields ? customFields : undefined;
|
|
44
|
+
}
|
|
45
|
+
if (isRecord(providedExtra)) {
|
|
46
|
+
const normalized = providedExtra;
|
|
47
|
+
return hasCustomFields
|
|
48
|
+
? { ...normalized, ...customFields }
|
|
49
|
+
: normalized;
|
|
50
|
+
}
|
|
51
|
+
return providedExtra ?? null;
|
|
52
|
+
}
|
|
53
|
+
if (!hasCustomFields) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (isRecord(previousExtra)) {
|
|
57
|
+
const normalized = previousExtra;
|
|
58
|
+
return { ...normalized, ...customFields };
|
|
59
|
+
}
|
|
60
|
+
return customFields;
|
|
61
|
+
}
|
|
62
|
+
exports.MatchTransformer = {
|
|
63
|
+
to(input) {
|
|
64
|
+
const extrasInput = input;
|
|
65
|
+
const extra = matchExtraFromInput(extrasInput);
|
|
66
|
+
return {
|
|
67
|
+
status: __1.MatchStatusTransformer.to(input.status),
|
|
68
|
+
stageId: String(input.stage_id),
|
|
69
|
+
groupId: String(input.group_id),
|
|
70
|
+
roundId: String(input.round_id),
|
|
71
|
+
number: input.number,
|
|
72
|
+
childCount: input.child_count,
|
|
73
|
+
extra: extra ?? null,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
from(output) {
|
|
77
|
+
const normalizedExtras = normalizeMatchExtras(output.extra);
|
|
78
|
+
return {
|
|
79
|
+
id: output.id,
|
|
80
|
+
status: __1.MatchStatusTransformer.from(output.status),
|
|
81
|
+
stage_id: output.stageId,
|
|
82
|
+
group_id: output.groupId,
|
|
83
|
+
round_id: output.roundId,
|
|
84
|
+
number: output.number,
|
|
85
|
+
child_count: output.childCount,
|
|
86
|
+
...normalizedExtras,
|
|
87
|
+
extra: output.extra ?? undefined,
|
|
88
|
+
opponent1: output.opponent1Result
|
|
89
|
+
? __1.ParticipantMatchResultTransformer.from(output.opponent1Result)
|
|
90
|
+
: null,
|
|
91
|
+
opponent2: output.opponent2Result
|
|
92
|
+
? __1.ParticipantMatchResultTransformer.from(output.opponent2Result)
|
|
93
|
+
: null,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ParticipantResult } from 'brackets-model';
|
|
2
|
+
import type { ParticipantMatchResult, ParticipantMatchGameResult } from '../../db/schema';
|
|
3
|
+
type DrizzleParticipantResult = ParticipantMatchResult | ParticipantMatchGameResult;
|
|
4
|
+
type ParticipantResultInput = {
|
|
5
|
+
id?: number | string | null;
|
|
6
|
+
forfeit?: boolean;
|
|
7
|
+
position?: number;
|
|
8
|
+
score?: number;
|
|
9
|
+
result?: 'win' | 'draw' | 'loss';
|
|
10
|
+
};
|
|
11
|
+
export declare const ParticipantMatchResultTransformer: {
|
|
12
|
+
to(input: ParticipantResultInput): {
|
|
13
|
+
participantId: string | null;
|
|
14
|
+
forfeit: boolean | null;
|
|
15
|
+
position: number | null;
|
|
16
|
+
score: number | null;
|
|
17
|
+
result: "WIN" | "DRAW" | "LOSS" | null;
|
|
18
|
+
};
|
|
19
|
+
from(output: DrizzleParticipantResult): ParticipantResult;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParticipantMatchResultTransformer = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
exports.ParticipantMatchResultTransformer = {
|
|
6
|
+
to(input) {
|
|
7
|
+
return {
|
|
8
|
+
participantId: input.id != null ? String(input.id) : null,
|
|
9
|
+
forfeit: input.forfeit ?? null,
|
|
10
|
+
position: input.position ?? null,
|
|
11
|
+
score: input.score ?? null,
|
|
12
|
+
result: input.result ? __1.MatchResultTransformer.to(input.result) : null,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
from(output) {
|
|
16
|
+
return {
|
|
17
|
+
id: output.participantId ?? null,
|
|
18
|
+
forfeit: output.forfeit ?? undefined,
|
|
19
|
+
position: output.position ?? undefined,
|
|
20
|
+
score: output.score ?? undefined,
|
|
21
|
+
result: output.result
|
|
22
|
+
? __1.MatchResultTransformer.from(output.result)
|
|
23
|
+
: undefined,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Participant } from 'brackets-model';
|
|
2
|
+
import { OmitId } from 'brackets-manager';
|
|
3
|
+
import type { Participant as DrizzleParticipant } from '../../db/schema';
|
|
4
|
+
import type { JsonValue } from '../../types';
|
|
5
|
+
export declare function participantExtraFromInput(input: Record<string, unknown>): JsonValue | null;
|
|
6
|
+
type ParticipantInput = {
|
|
7
|
+
name: string;
|
|
8
|
+
tournament_id: number | string;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export declare const ParticipantTransformer: {
|
|
12
|
+
to(input: OmitId<Participant> | ParticipantInput): {
|
|
13
|
+
name: string;
|
|
14
|
+
tournamentId: string;
|
|
15
|
+
extra: JsonValue;
|
|
16
|
+
};
|
|
17
|
+
from(output: DrizzleParticipant): Participant;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParticipantTransformer = void 0;
|
|
4
|
+
exports.participantExtraFromInput = participantExtraFromInput;
|
|
5
|
+
function getParticipantExtras(input) {
|
|
6
|
+
const clone = { ...input };
|
|
7
|
+
// Delete Participant fields
|
|
8
|
+
delete clone.id;
|
|
9
|
+
delete clone.name;
|
|
10
|
+
delete clone.tournament_id;
|
|
11
|
+
delete clone.extra;
|
|
12
|
+
// Return Extras
|
|
13
|
+
return clone;
|
|
14
|
+
}
|
|
15
|
+
function getParticipantExtraValue(input) {
|
|
16
|
+
const extra = getParticipantExtras(input);
|
|
17
|
+
return Object.keys(extra).length > 0 ? extra : null;
|
|
18
|
+
}
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
function normalizeParticipantExtras(extra) {
|
|
23
|
+
if (!isRecord(extra)) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
return extra;
|
|
27
|
+
}
|
|
28
|
+
function participantExtraFromInput(input) {
|
|
29
|
+
return getParticipantExtraValue(input);
|
|
30
|
+
}
|
|
31
|
+
exports.ParticipantTransformer = {
|
|
32
|
+
to(input) {
|
|
33
|
+
return {
|
|
34
|
+
name: input.name,
|
|
35
|
+
tournamentId: String(input.tournament_id),
|
|
36
|
+
extra: getParticipantExtraValue(input),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
from(output) {
|
|
40
|
+
return {
|
|
41
|
+
id: output.id,
|
|
42
|
+
name: output.name,
|
|
43
|
+
tournament_id: output.tournamentId,
|
|
44
|
+
...normalizeParticipantExtras(output.extra),
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Round } from 'brackets-model';
|
|
2
|
+
import { OmitId } from 'brackets-manager';
|
|
3
|
+
import type { Round as DrizzleRound } from '../../db/schema';
|
|
4
|
+
type RoundInput = {
|
|
5
|
+
stage_id: number | string;
|
|
6
|
+
group_id: number | string;
|
|
7
|
+
number: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const RoundTransformer: {
|
|
10
|
+
to(input: OmitId<Round> | RoundInput): {
|
|
11
|
+
stageId: string;
|
|
12
|
+
groupId: string;
|
|
13
|
+
number: number;
|
|
14
|
+
};
|
|
15
|
+
from(output: DrizzleRound): Round;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoundTransformer = void 0;
|
|
4
|
+
exports.RoundTransformer = {
|
|
5
|
+
to(input) {
|
|
6
|
+
return {
|
|
7
|
+
stageId: String(input.stage_id),
|
|
8
|
+
groupId: String(input.group_id),
|
|
9
|
+
number: input.number,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
from(output) {
|
|
13
|
+
return {
|
|
14
|
+
id: output.id,
|
|
15
|
+
stage_id: output.stageId,
|
|
16
|
+
group_id: output.groupId,
|
|
17
|
+
number: output.number,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StageSettings } from 'brackets-model';
|
|
2
|
+
import { OmitId } from 'brackets-manager';
|
|
3
|
+
import type { StageSettings as DrizzleStageSettings } from '../../db/schema';
|
|
4
|
+
export declare const StageSettingsTransformer: {
|
|
5
|
+
to(input: OmitId<StageSettings>): {
|
|
6
|
+
size: number | null;
|
|
7
|
+
seedOrdering: ("NATURAL" | "REVERSE" | "HALF_SHIFT" | "REVERSE_HALF_SHIFT" | "PAIR_FLIP" | "INNER_OUTER" | "GROUPS_EFFORT_BALANCED" | "GROUPS_SEED_OPTIMIZED" | "GROUPS_BRACKET_OPTIMIZED")[];
|
|
8
|
+
balanceByes: boolean | null;
|
|
9
|
+
matchesChildCount: number | null;
|
|
10
|
+
groupCount: number | null;
|
|
11
|
+
roundRobinMode: "SIMPLE" | "DOUBLE" | null;
|
|
12
|
+
manualOrdering: number[][] | null;
|
|
13
|
+
consolationFinal: boolean | null;
|
|
14
|
+
skipFirstRound: boolean | null;
|
|
15
|
+
grandFinal: "NONE" | "SIMPLE" | "DOUBLE" | null;
|
|
16
|
+
};
|
|
17
|
+
from(output: Omit<DrizzleStageSettings, "stageId">): StageSettings;
|
|
18
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StageSettingsTransformer = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
exports.StageSettingsTransformer = {
|
|
6
|
+
to(input) {
|
|
7
|
+
return {
|
|
8
|
+
size: input.size ?? null,
|
|
9
|
+
seedOrdering: input.seedOrdering
|
|
10
|
+
? input.seedOrdering.map(__1.SeedOrderingTransformer.to)
|
|
11
|
+
: [],
|
|
12
|
+
balanceByes: input.balanceByes ?? null,
|
|
13
|
+
matchesChildCount: input.matchesChildCount ?? null,
|
|
14
|
+
groupCount: input.groupCount ?? null,
|
|
15
|
+
roundRobinMode: input.roundRobinMode
|
|
16
|
+
? __1.RoundRobinModeTransformer.to(input.roundRobinMode)
|
|
17
|
+
: null,
|
|
18
|
+
manualOrdering: input.manualOrdering ?? null,
|
|
19
|
+
consolationFinal: input.consolationFinal ?? null,
|
|
20
|
+
skipFirstRound: input.skipFirstRound ?? null,
|
|
21
|
+
grandFinal: input.grandFinal
|
|
22
|
+
? __1.GrandFinalTypeTransformer.to(input.grandFinal)
|
|
23
|
+
: null,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
from(output) {
|
|
27
|
+
return {
|
|
28
|
+
size: output.size ?? undefined,
|
|
29
|
+
seedOrdering: output.seedOrdering
|
|
30
|
+
? output.seedOrdering.map(__1.SeedOrderingTransformer.from)
|
|
31
|
+
: [],
|
|
32
|
+
balanceByes: output.balanceByes ?? undefined,
|
|
33
|
+
matchesChildCount: output.matchesChildCount ?? undefined,
|
|
34
|
+
groupCount: output.groupCount ?? undefined,
|
|
35
|
+
roundRobinMode: output.roundRobinMode
|
|
36
|
+
? __1.RoundRobinModeTransformer.from(output.roundRobinMode)
|
|
37
|
+
: undefined,
|
|
38
|
+
manualOrdering: output.manualOrdering,
|
|
39
|
+
consolationFinal: output.consolationFinal ?? undefined,
|
|
40
|
+
skipFirstRound: output.skipFirstRound ?? undefined,
|
|
41
|
+
grandFinal: output.grandFinal
|
|
42
|
+
? __1.GrandFinalTypeTransformer.from(output.grandFinal)
|
|
43
|
+
: undefined,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
};
|