xpt-shared-types 1.8.0 → 1.9.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.
@@ -3,3 +3,4 @@
3
3
  */
4
4
  export * from './country';
5
5
  export * from './lobby';
6
+ export * from './tournamentEntry';
@@ -19,3 +19,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  */
20
20
  __exportStar(require("./country"), exports);
21
21
  __exportStar(require("./lobby"), exports);
22
+ __exportStar(require("./tournamentEntry"), exports);
@@ -0,0 +1,36 @@
1
+ /**
2
+ * A tournament entry after registration — withdrawing it and changing its
3
+ * roster.
4
+ *
5
+ * Neither is a Strapi content type. An entry is a `tournament-participant`
6
+ * row; these name the window in which its registrant may still act on it and
7
+ * the bodies of the endpoints that do so, so the backend guards and the
8
+ * client's buttons agree on both.
9
+ */
10
+ /**
11
+ * Statuses in which an entry can still be withdrawn or have its roster
12
+ * changed. Everything before is unpublished; everything after has a bracket
13
+ * that reads the entry, so the entry is frozen.
14
+ */
15
+ export declare const ENTRY_EDITABLE_STATUSES: readonly ["open", "checkIn"];
16
+ export type EntryEditableStatus = (typeof ENTRY_EDITABLE_STATUSES)[number];
17
+ /** True when `status` still lets an entry be withdrawn or re-rostered. */
18
+ export declare function isEntryEditable(status: string | null | undefined): status is EntryEditableStatus;
19
+ /**
20
+ * Body of `PUT /tournaments/:id/entry/roster`. Flat, like `/join`, not inside
21
+ * `data`. The full new roster, not a diff — the server works out who was
22
+ * added and who was removed.
23
+ */
24
+ export interface TournamentRosterUpdateInput {
25
+ selectedMemberIds: number[];
26
+ }
27
+ /** Body of `POST /tournaments/:id/join` for a team entry. Flat, like above. */
28
+ export interface TournamentTeamJoinInput {
29
+ teamId: string;
30
+ selectedMemberIds: number[];
31
+ }
32
+ /**
33
+ * `error.details.name` values the entry endpoints raise that a client is
34
+ * expected to branch on. Anything else is a plain message.
35
+ */
36
+ export type TournamentEntryErrorName = 'NotEntryLeader' | 'MembersMissingGameAccount' | 'InsufficientCoins' | 'GameAccountRequired' | 'TeamEntryRequired';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * A tournament entry after registration — withdrawing it and changing its
4
+ * roster.
5
+ *
6
+ * Neither is a Strapi content type. An entry is a `tournament-participant`
7
+ * row; these name the window in which its registrant may still act on it and
8
+ * the bodies of the endpoints that do so, so the backend guards and the
9
+ * client's buttons agree on both.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ENTRY_EDITABLE_STATUSES = void 0;
13
+ exports.isEntryEditable = isEntryEditable;
14
+ /**
15
+ * Statuses in which an entry can still be withdrawn or have its roster
16
+ * changed. Everything before is unpublished; everything after has a bracket
17
+ * that reads the entry, so the entry is frozen.
18
+ */
19
+ exports.ENTRY_EDITABLE_STATUSES = ['open', 'checkIn'];
20
+ /** True when `status` still lets an entry be withdrawn or re-rostered. */
21
+ function isEntryEditable(status) {
22
+ return exports.ENTRY_EDITABLE_STATUSES.includes(status !== null && status !== void 0 ? status : '');
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xpt-shared-types",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Shared types and data for XPT projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,3 +3,4 @@
3
3
  */
4
4
  export * from './country';
5
5
  export * from './lobby';
6
+ export * from './tournamentEntry';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * A tournament entry after registration — withdrawing it and changing its
3
+ * roster.
4
+ *
5
+ * Neither is a Strapi content type. An entry is a `tournament-participant`
6
+ * row; these name the window in which its registrant may still act on it and
7
+ * the bodies of the endpoints that do so, so the backend guards and the
8
+ * client's buttons agree on both.
9
+ */
10
+
11
+ import type { TournamentCurrentStatus } from '../generated/enums';
12
+
13
+ /**
14
+ * Statuses in which an entry can still be withdrawn or have its roster
15
+ * changed. Everything before is unpublished; everything after has a bracket
16
+ * that reads the entry, so the entry is frozen.
17
+ */
18
+ export const ENTRY_EDITABLE_STATUSES = ['open', 'checkIn'] as const satisfies
19
+ readonly TournamentCurrentStatus[];
20
+
21
+ export type EntryEditableStatus = (typeof ENTRY_EDITABLE_STATUSES)[number];
22
+
23
+ /** True when `status` still lets an entry be withdrawn or re-rostered. */
24
+ export function isEntryEditable(
25
+ status: string | null | undefined
26
+ ): status is EntryEditableStatus {
27
+ return (ENTRY_EDITABLE_STATUSES as readonly string[]).includes(status ?? '');
28
+ }
29
+
30
+ /**
31
+ * Body of `PUT /tournaments/:id/entry/roster`. Flat, like `/join`, not inside
32
+ * `data`. The full new roster, not a diff — the server works out who was
33
+ * added and who was removed.
34
+ */
35
+ export interface TournamentRosterUpdateInput {
36
+ selectedMemberIds: number[];
37
+ }
38
+
39
+ /** Body of `POST /tournaments/:id/join` for a team entry. Flat, like above. */
40
+ export interface TournamentTeamJoinInput {
41
+ teamId: string;
42
+ selectedMemberIds: number[];
43
+ }
44
+
45
+ /**
46
+ * `error.details.name` values the entry endpoints raise that a client is
47
+ * expected to branch on. Anything else is a plain message.
48
+ */
49
+ export type TournamentEntryErrorName =
50
+ | 'NotEntryLeader'
51
+ | 'MembersMissingGameAccount'
52
+ | 'InsufficientCoins'
53
+ | 'GameAccountRequired'
54
+ | 'TeamEntryRequired';