@ttt-productions/q-core 0.1.13 → 0.1.15

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.
@@ -47,6 +47,7 @@ export declare const STATS_MIGRATION_OPERATION_ID = "migration";
47
47
  export declare const STATS_MIGRATION_CORRECTION_REASON = "The recorded result differs from what its recorded plays add up to; this correction keeps the recorded result.";
48
48
  export declare const GAME_REPAIR_REFUSAL_COPY: {
49
49
  readonly eventUnreadable: "One of this game's recorded stats can no longer be read. Fix the event in the console, then repair the game.";
50
+ readonly eventSequenceGap: "This game's recorded stats are numbered with a gap or a repeat. Fix the event documents in the console, then restore the game.";
50
51
  readonly sourcesDisagree: "This game's record, its stored numbers, and its recorded stats all disagree, so nothing says what was applied. Fix the game in the console first.";
51
52
  readonly scoreAmbiguous: "The team's score was edited in two places to different values. Enter the score you want as a correction instead.";
52
53
  readonly fieldNotCorrectable: "That number cannot be corrected for this sport. Restore the game from its recorded stats, or reopen it and score it again.";
@@ -1 +1 @@
1
- {"version":3,"file":"sports.d.ts","sourceRoot":"","sources":["../../src/constants/sports.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,+BAA+B;;;;;;;;CAQgB,CAAC;AAI7D,eAAO,MAAM,gCAAgC;;;;CAIe,CAAC;AAG7D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAGtC,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAI1C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAG7C,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAGrD,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAGnD,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAGtD,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAG3C,eAAO,MAAM,6BAA6B;;;;;CAKgB,CAAC;AAI3D,eAAO,MAAM,wBAAwB,2CAA2C,CAAC;AAIjF,eAAO,MAAM,0BAA0B,8CAA8C,CAAC;AAGtF,eAAO,MAAM,uBA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eAAO,MAAM,kCAAkC,wBAAyB,CAAC;AACzE,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,kCAAkC,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -71,6 +71,7 @@ export const STATS_MIGRATION_CORRECTION_REASON = 'The recorded result differs fr
71
71
  // What an admin reads when Fix stats refuses a game repair.
72
72
  export const GAME_REPAIR_REFUSAL_COPY = {
73
73
  eventUnreadable: "One of this game's recorded stats can no longer be read. Fix the event in the console, then repair the game.",
74
+ eventSequenceGap: "This game's recorded stats are numbered with a gap or a repeat. Fix the event documents in the console, then restore the game.",
74
75
  sourcesDisagree: "This game's record, its stored numbers, and its recorded stats all disagree, so nothing says what was applied. Fix the game in the console first.",
75
76
  scoreAmbiguous: "The team's score was edited in two places to different values. Enter the score you want as a correction instead.",
76
77
  fieldNotCorrectable: "That number cannot be corrected for this sport. Restore the game from its recorded stats, or reopen it and score it again.",
@@ -1 +1 @@
1
- {"version":3,"file":"sports.js","sourceRoot":"","sources":["../../src/constants/sports.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,gGAAgG;AAEhG,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,6BAA6B,EAC7B,iCAAiC,EACjC,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAS5B,8FAA8F;AAC9F,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,CAAC,+BAA+B,CAAC,EAAE,CAAC;IACpC,CAAC,+BAA+B,CAAC,EAAE,CAAC;IACpC,CAAC,iCAAiC,CAAC,EAAE,CAAC;IACtC,CAAC,6BAA6B,CAAC,EAAE,CAAC;IAClC,CAAC,4BAA4B,CAAC,EAAE,CAAC;IACjC,CAAC,6BAA6B,CAAC,EAAE,CAAC;IAClC,CAAC,+BAA+B,CAAC,EAAE,CAAC;CACsB,CAAC;AA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AE,mDAAmD;IACrE,YAAY,EAAE,2CAA2C;IACzD,cAAc,EAAE,kCAAkC;IAClD,gBAAgB,EAAE,mFAAmF;IACrG,SAAS,EAAE,sFAAsF;IACjG,eAAe,EAAE,mFAAmF;IACpG,uBAAuB,EAAE,0CAA0C;IACnE,qBAAqB,EAAE,mEAAmE;IAC1F,aAAa,EAAE,4FAA4F;CACpD,CAAC;AAE1D,qGAAqG;AACrG,oGAAoG;AACpG,+FAA+F;AAC/F,MAAM,CAAC,MAAM,4BAA4B,GAAG,WAAW,CAAC;AACxD,MAAM,CAAC,MAAM,iCAAiC,GAC5C,gHAAgH,CAAC;AAEnH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,eAAe,EAAE,8GAA8G;IAC/H,eAAe,EACb,mJAAmJ;IACrJ,cAAc,EACZ,kHAAkH;IACpH,mBAAmB,EACjB,4HAA4H;IAC9H,eAAe,EAAE,2CAA2C;IAC5D,aAAa,EAAE,wCAAwC;IACvD,YAAY,EAAE,2CAA2C;CACL,CAAC;AAEvD,gGAAgG;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,cAAc,EACZ,4HAA4H;IAC9H,kBAAkB,EAChB,yGAAyG;IAC3G,kBAAkB,EAChB,qIAAqI;CAC/E,CAAC;AAE3D,mGAAmG;AACnG,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,gBAAgB,EAAE,gEAAgE;CACrB,CAAC;AAEhE,iGAAiG;AACjG,kGAAkG;AAClG,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAU,CAAC","sourcesContent":["// Sport rule values that are persisted or validated on both sides of the boundary. What a sport\n// DOES with them — applying an event, recomputing a score — belongs to its adapter (SPORT-003).\n\nimport {\n BASKETBALL_ASSIST_EVENT_TYPE,\n BASKETBALL_BULK_EDIT_EVENT_TYPE,\n BASKETBALL_ONE_POINT_EVENT_TYPE,\n BASKETBALL_REBOUND_EVENT_TYPE,\n BASKETBALL_THREE_POINT_EVENT_TYPE,\n BASKETBALL_TIMEOUT_EVENT_TYPE,\n BASKETBALL_TWO_POINT_EVENT_TYPE,\n FOOTBALL_BULK_EDIT_EVENT_TYPE,\n FOOTBALL_ONE_POINT_EVENT_TYPE,\n FOOTBALL_SIX_POINT_EVENT_TYPE,\n FOOTBALL_TWO_POINT_EVENT_TYPE,\n} from '../types/sports.js';\nimport type { BasketballPlayerStatKey, BasketballStatEventType, FootballStatEventType } from '../types/sports.js';\nimport type {\n FinalizationNotReadyReason,\n GameRepairRefusal,\n StatEventRefusalCode,\n StatsIntegrityRefusal,\n} from '../types/stats.js';\n\n// Points a basketball stat event adds to its team's score. BULK_EDIT carries its own `value`.\nexport const BASKETBALL_POINTS_BY_EVENT_TYPE = {\n [BASKETBALL_ONE_POINT_EVENT_TYPE]: 1,\n [BASKETBALL_TWO_POINT_EVENT_TYPE]: 2,\n [BASKETBALL_THREE_POINT_EVENT_TYPE]: 3,\n [BASKETBALL_REBOUND_EVENT_TYPE]: 0,\n [BASKETBALL_ASSIST_EVENT_TYPE]: 0,\n [BASKETBALL_TIMEOUT_EVENT_TYPE]: 0,\n [BASKETBALL_BULK_EDIT_EVENT_TYPE]: 0,\n} as const satisfies Record<BasketballStatEventType, number>;\n\n// Basketball fantasy points (FP): each player counter times its weight. Every weight is a multiple\n// of one half, so FP summed across games equals FP of the summed counters exactly.\nexport const BASKETBALL_FANTASY_POINT_WEIGHTS = {\n points: 1,\n rebounds: 1.5,\n assists: 2,\n} as const satisfies Record<BasketballPlayerStatKey, number>;\n\n// A curling game is this many rounds; `roundScores` has exactly this many slots.\nexport const CURLING_ROUND_COUNT = 14;\n\n// A scored curling round is worth 1..MAX; a blank end is 0.\nexport const MAX_CURLING_ROUND_POINTS = 4;\n\n// The most events one scoring write may carry: each event is a document created in the write's one\n// transaction, and a Firestore transaction commits at most 500 writes.\nexport const MAX_STAT_EVENTS_PER_WRITE = 200;\n\n// The most lines and fields one Correct a game call may set; a game holds far fewer.\nexport const MAX_GAME_STATS_CORRECTION_TARGETS = 200;\n\n// The most destination changes one rebuild call lists in its answer; the audit events record all.\nexport const MAX_STATS_REPAIR_LISTED_CHANGES = 500;\n\n// The most findings one stats check keeps on its report; every finding is still counted by kind.\nexport const MAX_STATS_VALIDATION_DISCREPANCIES = 500;\n\n// The most events one page of a completed game's finalized record holds.\nexport const STAT_HISTORY_PAGE_SIZE = 1000;\n\n// Points a football stat event adds to its team's score. FOOTBALL_BULK_EDIT carries its own `value`.\nexport const FOOTBALL_POINTS_BY_EVENT_TYPE = {\n [FOOTBALL_SIX_POINT_EVENT_TYPE]: 6,\n [FOOTBALL_TWO_POINT_EVENT_TYPE]: 2,\n [FOOTBALL_ONE_POINT_EVENT_TYPE]: 1,\n [FOOTBALL_BULK_EDIT_EVENT_TYPE]: 0,\n} as const satisfies Record<FootballStatEventType, number>;\n\n// A game write's answer — a scoring event, a bulk-entry form, absence, the possession arrow, a ghost\n// added from the game — when the request names a team the game does not hold.\nexport const TEAM_NOT_IN_GAME_MESSAGE = 'That team is not playing in this game.';\n\n// A game write's answer — a bulk-entry row, absence, a memo — when the request names a person the\n// game's roster does not hold.\nexport const NOT_ON_GAME_ROSTER_MESSAGE = \"That player is not on this game's roster.\";\n\n// What the scorekeeper reads beside an event a scoring write refused.\nexport const STAT_EVENT_REFUSAL_COPY = {\n eventTypeNotInSport: \"That stat does not belong to this game's sport.\",\n teamNotInGame: TEAM_NOT_IN_GAME_MESSAGE,\n playerNotRostered: \"That player is not on this game's roster for that team.\",\n assisterNotRostered: \"The assisting player is not on this game's roster for that team.\",\n assistNotAllowed: 'Only a 2- or 3-point basket can be assisted, and never by the player who scored it.',\n playerNotAllowed: \"That stat is the team's; it cannot name a player.\",\n roundNotNext: 'That round is not the next one to record.',\n roundsComplete: 'Every round is already recorded.',\n bulkValueInvalid: 'That entry is not a real result: stats are whole numbers and never go below zero.',\n bulkStale: 'The numbers changed while you were editing. Check the flagged values and save again.',\n eventIdConflict: 'A different stat was already saved under this one. Discard it and enter it again.',\n voidTargetNotSportEvent: 'There is no recorded stat there to undo.',\n correctionNotAccepted: 'Corrections are made from Fix stats, not from the scoring screen.',\n undoBelowZero: 'Undoing that play would leave a stat below zero, because a later entry already lowered it.',\n} as const satisfies Record<StatEventRefusalCode, string>;\n\n// The operation every correction the game copy appends is recorded under, and the reason it carries.\n// The copy carries each recorded result exactly: where a game's recorded lines differ from what its\n// recorded plays replay to, one correction per field closes the difference, and these name it.\nexport const STATS_MIGRATION_OPERATION_ID = 'migration';\nexport const STATS_MIGRATION_CORRECTION_REASON =\n 'The recorded result differs from what its recorded plays add up to; this correction keeps the recorded result.';\n\n// What an admin reads when Fix stats refuses a game repair.\nexport const GAME_REPAIR_REFUSAL_COPY = {\n eventUnreadable: \"One of this game's recorded stats can no longer be read. Fix the event in the console, then repair the game.\",\n sourcesDisagree:\n \"This game's record, its stored numbers, and its recorded stats all disagree, so nothing says what was applied. Fix the game in the console first.\",\n scoreAmbiguous:\n \"The team's score was edited in two places to different values. Enter the score you want as a correction instead.\",\n fieldNotCorrectable:\n \"That number cannot be corrected for this sport. Restore the game from its recorded stats, or reopen it and score it again.\",\n lineNotRostered: \"That player is not on this game's roster.\",\n teamNotInGame: \"That team is not playing in this game.\",\n gameTooLarge: 'This repair is too large to save at once.',\n} as const satisfies Record<GameRepairRefusal, string>;\n\n// What the caller reads when a stats path refuses a game whose numbers changed outside the app.\nexport const STATS_INTEGRITY_REFUSAL_COPY = {\n statsOutOfBand:\n \"This game's stored numbers no longer match the stats recorded for it. An admin must reconcile the game in Fix stats first.\",\n finalRecordMissing:\n \"This finalized game's record of its stats is missing. An admin must repair the game in Fix stats first.\",\n aggregateBelowZero:\n 'A league, career, or hall-of-fame total holds less than this game added to it. An admin must rebuild the totals in Fix stats first.',\n} as const satisfies Record<StatsIntegrityRefusal, string>;\n\n// What the finish control shows while a game may not be finalized, and what finalize refuses with.\nexport const FINALIZATION_NOT_READY_COPY = {\n roundsIncomplete: 'Every round must be recorded before the game can be finalized.',\n} as const satisfies Record<FinalizationNotReadyReason, string>;\n\n// The hall of fame's minimum-games filter: each choice keeps the careers with at least that many\n// games played. None is chosen until the viewer picks one, so the hall of fame opens on everyone.\nexport const HALL_OF_FAME_MINIMUM_GAMES_CHOICES = [25, 50, 100] as const;\nexport type HallOfFameMinimumGames = (typeof HALL_OF_FAME_MINIMUM_GAMES_CHOICES)[number];\n"]}
1
+ {"version":3,"file":"sports.js","sourceRoot":"","sources":["../../src/constants/sports.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,gGAAgG;AAEhG,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,6BAA6B,EAC7B,iCAAiC,EACjC,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAS5B,8FAA8F;AAC9F,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,CAAC,+BAA+B,CAAC,EAAE,CAAC;IACpC,CAAC,+BAA+B,CAAC,EAAE,CAAC;IACpC,CAAC,iCAAiC,CAAC,EAAE,CAAC;IACtC,CAAC,6BAA6B,CAAC,EAAE,CAAC;IAClC,CAAC,4BAA4B,CAAC,EAAE,CAAC;IACjC,CAAC,6BAA6B,CAAC,EAAE,CAAC;IAClC,CAAC,+BAA+B,CAAC,EAAE,CAAC;CACsB,CAAC;AAE7D,mGAAmG;AACnG,mFAAmF;AACnF,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,GAAG;IACb,OAAO,EAAE,CAAC;CACgD,CAAC;AAE7D,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,mGAAmG;AAC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CAAC,MAAM,4BAA4B,GAAG,WAAW,CAAC;AACxD,MAAM,CAAC,MAAM,iCAAiC,GAC5C,gHAAgH,CAAC;AAEnH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,eAAe,EAAE,8GAA8G;IAC/H,gBAAgB,EACd,gIAAgI;IAClI,eAAe,EACb,mJAAmJ;IACrJ,cAAc,EACZ,kHAAkH;IACpH,mBAAmB,EACjB,4HAA4H;IAC9H,eAAe,EAAE,2CAA2C;IAC5D,aAAa,EAAE,wCAAwC;IACvD,YAAY,EAAE,2CAA2C;CACL,CAAC;AAEvD,gGAAgG;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,cAAc,EACZ,4HAA4H;IAC9H,kBAAkB,EAChB,yGAAyG;IAC3G,kBAAkB,EAChB,qIAAqI;CAC/E,CAAC;AAE3D,mGAAmG;AACnG,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,gBAAgB,EAAE,gEAAgE;CACrB,CAAC;AAEhE,iGAAiG;AACjG,kGAAkG;AAClG,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAU,CAAC","sourcesContent":["// Sport rule values that are persisted or validated on both sides of the boundary. What a sport\n// DOES with them — applying an event, recomputing a score — belongs to its adapter (SPORT-003).\n\nimport {\n BASKETBALL_ASSIST_EVENT_TYPE,\n BASKETBALL_BULK_EDIT_EVENT_TYPE,\n BASKETBALL_ONE_POINT_EVENT_TYPE,\n BASKETBALL_REBOUND_EVENT_TYPE,\n BASKETBALL_THREE_POINT_EVENT_TYPE,\n BASKETBALL_TIMEOUT_EVENT_TYPE,\n BASKETBALL_TWO_POINT_EVENT_TYPE,\n FOOTBALL_BULK_EDIT_EVENT_TYPE,\n FOOTBALL_ONE_POINT_EVENT_TYPE,\n FOOTBALL_SIX_POINT_EVENT_TYPE,\n FOOTBALL_TWO_POINT_EVENT_TYPE,\n} from '../types/sports.js';\nimport type { BasketballPlayerStatKey, BasketballStatEventType, FootballStatEventType } from '../types/sports.js';\nimport type {\n FinalizationNotReadyReason,\n GameRepairRefusal,\n StatEventRefusalCode,\n StatsIntegrityRefusal,\n} from '../types/stats.js';\n\n// Points a basketball stat event adds to its team's score. BULK_EDIT carries its own `value`.\nexport const BASKETBALL_POINTS_BY_EVENT_TYPE = {\n [BASKETBALL_ONE_POINT_EVENT_TYPE]: 1,\n [BASKETBALL_TWO_POINT_EVENT_TYPE]: 2,\n [BASKETBALL_THREE_POINT_EVENT_TYPE]: 3,\n [BASKETBALL_REBOUND_EVENT_TYPE]: 0,\n [BASKETBALL_ASSIST_EVENT_TYPE]: 0,\n [BASKETBALL_TIMEOUT_EVENT_TYPE]: 0,\n [BASKETBALL_BULK_EDIT_EVENT_TYPE]: 0,\n} as const satisfies Record<BasketballStatEventType, number>;\n\n// Basketball fantasy points (FP): each player counter times its weight. Every weight is a multiple\n// of one half, so FP summed across games equals FP of the summed counters exactly.\nexport const BASKETBALL_FANTASY_POINT_WEIGHTS = {\n points: 1,\n rebounds: 1.5,\n assists: 2,\n} as const satisfies Record<BasketballPlayerStatKey, number>;\n\n// A curling game is this many rounds; `roundScores` has exactly this many slots.\nexport const CURLING_ROUND_COUNT = 14;\n\n// A scored curling round is worth 1..MAX; a blank end is 0.\nexport const MAX_CURLING_ROUND_POINTS = 4;\n\n// The most events one scoring write may carry: each event is a document created in the write's one\n// transaction, and a Firestore transaction commits at most 500 writes.\nexport const MAX_STAT_EVENTS_PER_WRITE = 200;\n\n// The most lines and fields one Correct a game call may set; a game holds far fewer.\nexport const MAX_GAME_STATS_CORRECTION_TARGETS = 200;\n\n// The most destination changes one rebuild call lists in its answer; the audit events record all.\nexport const MAX_STATS_REPAIR_LISTED_CHANGES = 500;\n\n// The most findings one stats check keeps on its report; every finding is still counted by kind.\nexport const MAX_STATS_VALIDATION_DISCREPANCIES = 500;\n\n// The most events one page of a completed game's finalized record holds.\nexport const STAT_HISTORY_PAGE_SIZE = 1000;\n\n// Points a football stat event adds to its team's score. FOOTBALL_BULK_EDIT carries its own `value`.\nexport const FOOTBALL_POINTS_BY_EVENT_TYPE = {\n [FOOTBALL_SIX_POINT_EVENT_TYPE]: 6,\n [FOOTBALL_TWO_POINT_EVENT_TYPE]: 2,\n [FOOTBALL_ONE_POINT_EVENT_TYPE]: 1,\n [FOOTBALL_BULK_EDIT_EVENT_TYPE]: 0,\n} as const satisfies Record<FootballStatEventType, number>;\n\n// A game write's answer — a scoring event, a bulk-entry form, absence, the possession arrow, a ghost\n// added from the game — when the request names a team the game does not hold.\nexport const TEAM_NOT_IN_GAME_MESSAGE = 'That team is not playing in this game.';\n\n// A game write's answer — a bulk-entry row, absence, a memo — when the request names a person the\n// game's roster does not hold.\nexport const NOT_ON_GAME_ROSTER_MESSAGE = \"That player is not on this game's roster.\";\n\n// What the scorekeeper reads beside an event a scoring write refused.\nexport const STAT_EVENT_REFUSAL_COPY = {\n eventTypeNotInSport: \"That stat does not belong to this game's sport.\",\n teamNotInGame: TEAM_NOT_IN_GAME_MESSAGE,\n playerNotRostered: \"That player is not on this game's roster for that team.\",\n assisterNotRostered: \"The assisting player is not on this game's roster for that team.\",\n assistNotAllowed: 'Only a 2- or 3-point basket can be assisted, and never by the player who scored it.',\n playerNotAllowed: \"That stat is the team's; it cannot name a player.\",\n roundNotNext: 'That round is not the next one to record.',\n roundsComplete: 'Every round is already recorded.',\n bulkValueInvalid: 'That entry is not a real result: stats are whole numbers and never go below zero.',\n bulkStale: 'The numbers changed while you were editing. Check the flagged values and save again.',\n eventIdConflict: 'A different stat was already saved under this one. Discard it and enter it again.',\n voidTargetNotSportEvent: 'There is no recorded stat there to undo.',\n correctionNotAccepted: 'Corrections are made from Fix stats, not from the scoring screen.',\n undoBelowZero: 'Undoing that play would leave a stat below zero, because a later entry already lowered it.',\n} as const satisfies Record<StatEventRefusalCode, string>;\n\n// The operation every correction the game copy appends is recorded under, and the reason it carries.\n// The copy carries each recorded result exactly: where a game's recorded lines differ from what its\n// recorded plays replay to, one correction per field closes the difference, and these name it.\nexport const STATS_MIGRATION_OPERATION_ID = 'migration';\nexport const STATS_MIGRATION_CORRECTION_REASON =\n 'The recorded result differs from what its recorded plays add up to; this correction keeps the recorded result.';\n\n// What an admin reads when Fix stats refuses a game repair.\nexport const GAME_REPAIR_REFUSAL_COPY = {\n eventUnreadable: \"One of this game's recorded stats can no longer be read. Fix the event in the console, then repair the game.\",\n eventSequenceGap:\n \"This game's recorded stats are numbered with a gap or a repeat. Fix the event documents in the console, then restore the game.\",\n sourcesDisagree:\n \"This game's record, its stored numbers, and its recorded stats all disagree, so nothing says what was applied. Fix the game in the console first.\",\n scoreAmbiguous:\n \"The team's score was edited in two places to different values. Enter the score you want as a correction instead.\",\n fieldNotCorrectable:\n \"That number cannot be corrected for this sport. Restore the game from its recorded stats, or reopen it and score it again.\",\n lineNotRostered: \"That player is not on this game's roster.\",\n teamNotInGame: \"That team is not playing in this game.\",\n gameTooLarge: 'This repair is too large to save at once.',\n} as const satisfies Record<GameRepairRefusal, string>;\n\n// What the caller reads when a stats path refuses a game whose numbers changed outside the app.\nexport const STATS_INTEGRITY_REFUSAL_COPY = {\n statsOutOfBand:\n \"This game's stored numbers no longer match the stats recorded for it. An admin must reconcile the game in Fix stats first.\",\n finalRecordMissing:\n \"This finalized game's record of its stats is missing. An admin must repair the game in Fix stats first.\",\n aggregateBelowZero:\n 'A league, career, or hall-of-fame total holds less than this game added to it. An admin must rebuild the totals in Fix stats first.',\n} as const satisfies Record<StatsIntegrityRefusal, string>;\n\n// What the finish control shows while a game may not be finalized, and what finalize refuses with.\nexport const FINALIZATION_NOT_READY_COPY = {\n roundsIncomplete: 'Every round must be recorded before the game can be finalized.',\n} as const satisfies Record<FinalizationNotReadyReason, string>;\n\n// The hall of fame's minimum-games filter: each choice keeps the careers with at least that many\n// games played. None is chosen until the viewer picks one, so the hall of fame opens on everyone.\nexport const HALL_OF_FAME_MINIMUM_GAMES_CHOICES = [25, 50, 100] as const;\nexport type HallOfFameMinimumGames = (typeof HALL_OF_FAME_MINIMUM_GAMES_CHOICES)[number];\n"]}
@@ -162,6 +162,36 @@ export declare const GameStatsCorrectionSchema: z.ZodObject<{
162
162
  value: z.ZodNumber;
163
163
  }, z.core.$strict>;
164
164
  export type GameStatsCorrection = z.infer<typeof GameStatsCorrectionSchema>;
165
+ export declare const GameRepairChangesSchema: z.ZodObject<{
166
+ lines: z.ZodArray<z.ZodObject<{
167
+ lineKey: z.ZodString;
168
+ field: z.ZodString;
169
+ stored: z.ZodNumber;
170
+ rebuilt: z.ZodNumber;
171
+ }, z.core.$strict>>;
172
+ scores: z.ZodArray<z.ZodObject<{
173
+ teamId: z.ZodString;
174
+ stored: z.ZodNumber;
175
+ rebuilt: z.ZodNumber;
176
+ }, z.core.$strict>>;
177
+ absentRosterPlayerIds: z.ZodOptional<z.ZodObject<{
178
+ stored: z.ZodArray<z.ZodString>;
179
+ rebuilt: z.ZodArray<z.ZodString>;
180
+ }, z.core.$strict>>;
181
+ nonScoringRosterPlayerIds: z.ZodOptional<z.ZodObject<{
182
+ stored: z.ZodArray<z.ZodString>;
183
+ rebuilt: z.ZodArray<z.ZodString>;
184
+ }, z.core.$strict>>;
185
+ statEventSequence: z.ZodOptional<z.ZodObject<{
186
+ stored: z.ZodNumber;
187
+ rebuilt: z.ZodNumber;
188
+ }, z.core.$strict>>;
189
+ recordRewritten: z.ZodOptional<z.ZodObject<{
190
+ pagesBefore: z.ZodNumber;
191
+ pagesAfter: z.ZodNumber;
192
+ }, z.core.$strict>>;
193
+ }, z.core.$strict>;
194
+ export type GameRepairChanges = z.infer<typeof GameRepairChangesSchema>;
165
195
  export declare const GameStatsRepairResultSchema: z.ZodObject<{
166
196
  gameId: z.ZodString;
167
197
  leagueId: z.ZodString;
@@ -184,6 +214,35 @@ export declare const GameStatsRepairResultSchema: z.ZodObject<{
184
214
  value: z.ZodNumber;
185
215
  }, z.core.$strict>>;
186
216
  gameChanged: z.ZodBoolean;
217
+ gameChanges: z.ZodObject<{
218
+ lines: z.ZodArray<z.ZodObject<{
219
+ lineKey: z.ZodString;
220
+ field: z.ZodString;
221
+ stored: z.ZodNumber;
222
+ rebuilt: z.ZodNumber;
223
+ }, z.core.$strict>>;
224
+ scores: z.ZodArray<z.ZodObject<{
225
+ teamId: z.ZodString;
226
+ stored: z.ZodNumber;
227
+ rebuilt: z.ZodNumber;
228
+ }, z.core.$strict>>;
229
+ absentRosterPlayerIds: z.ZodOptional<z.ZodObject<{
230
+ stored: z.ZodArray<z.ZodString>;
231
+ rebuilt: z.ZodArray<z.ZodString>;
232
+ }, z.core.$strict>>;
233
+ nonScoringRosterPlayerIds: z.ZodOptional<z.ZodObject<{
234
+ stored: z.ZodArray<z.ZodString>;
235
+ rebuilt: z.ZodArray<z.ZodString>;
236
+ }, z.core.$strict>>;
237
+ statEventSequence: z.ZodOptional<z.ZodObject<{
238
+ stored: z.ZodNumber;
239
+ rebuilt: z.ZodNumber;
240
+ }, z.core.$strict>>;
241
+ recordRewritten: z.ZodOptional<z.ZodObject<{
242
+ pagesBefore: z.ZodNumber;
243
+ pagesAfter: z.ZodNumber;
244
+ }, z.core.$strict>>;
245
+ }, z.core.$strict>;
187
246
  destinationChanges: z.ZodArray<z.ZodObject<{
188
247
  ref: z.ZodString;
189
248
  field: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/schemas/stats.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8BxB,eAAO,MAAM,uBAAuB;;kBAA8C,CAAC;AACnF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAGxE,eAAO,MAAM,wBAAwB;;;;;;;;kBAO1B,CAAC;AACZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAI1E,eAAO,MAA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2C,CAAC,CAAC;AAEhH,eAAO,MAAM,4CAA4C;;kBAE9C,CAAC;AACZ,MAAM,MAAM,sCAAsC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4CAA4C,CAAC,CAAC"}
@@ -156,8 +156,30 @@ export const RecalculateGameStatsInputSchema = z
156
156
  export const GameStatsCorrectionSchema = z
157
157
  .object({ lineKey: z.string().min(1), field: statCounterKeySchema, value: z.number().int() })
158
158
  .strict();
159
+ // A list of roster entries a repair replaced, as the game stored it and as the repair rebuilds it.
160
+ const replacedEntryListSchema = z
161
+ .object({ stored: z.array(gameRosterPlayerIdSchema), rebuilt: z.array(gameRosterPlayerIdSchema) })
162
+ .strict();
163
+ // Every value of the game document a repair changed, each with the value the game stored and the
164
+ // value the repair writes — never the whole document (BACKEND-212). `lines` holds each changed field
165
+ // of a team or player line (`lineKey` the team id or the roster entry id), `scores` each team whose
166
+ // score mirror changed, and the lists, the event counter and `recordRewritten` appear only when the
167
+ // repair changes them; `recordRewritten` names the finalized record's page counts before and after,
168
+ // without copying the record.
169
+ export const GameRepairChangesSchema = z
170
+ .object({
171
+ lines: z.array(z.object({ lineKey: z.string().min(1), field: z.string().min(1), stored: z.number(), rebuilt: z.number() }).strict()),
172
+ scores: z.array(z.object({ teamId: teamIdSchema, stored: z.number(), rebuilt: z.number() }).strict()),
173
+ absentRosterPlayerIds: replacedEntryListSchema.optional(),
174
+ nonScoringRosterPlayerIds: replacedEntryListSchema.optional(),
175
+ statEventSequence: z.object({ stored: countSchema, rebuilt: countSchema }).strict().optional(),
176
+ recordRewritten: z.object({ pagesBefore: countSchema, pagesAfter: countSchema }).strict().optional(),
177
+ })
178
+ .strict();
159
179
  // What a game repair did: `reconciled` it changed the game; `unchanged` there was nothing to change;
160
180
  // `alreadyApplied` the operation had already committed and this call is its acknowledged retry.
181
+ // `gameChanges` is what it changed on the game document, or on a dry run would change; empty lists
182
+ // for any other outcome.
161
183
  export const GameStatsRepairResultSchema = z
162
184
  .object({
163
185
  gameId: gameIdSchema,
@@ -167,6 +189,7 @@ export const GameStatsRepairResultSchema = z
167
189
  outcome: z.enum(GAME_STATS_REPAIR_OUTCOME_KEYS),
168
190
  corrections: z.array(GameStatsCorrectionSchema),
169
191
  gameChanged: z.boolean(),
192
+ gameChanges: GameRepairChangesSchema,
170
193
  destinationChanges: z.array(StatsDestinationChangeSchema),
171
194
  })
172
195
  .strict();
@@ -1 +1 @@
1
- {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/schemas/stats.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,sGAAsG;AACtG,2BAA2B;AAC3B,4BAA4B;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,8BAA8B,EAC9B,4CAA4C,GAC7C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,+FAA+F;AAC/F,kGAAkG;AAClG,+DAA+D;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAGnF,mGAAmG;AACnG,MAAM,CAAC,MAAM,wBAAwB,GAA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6B,GAAG,CAAC;KAC3C,MAAM,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC;KAClF,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC;KAC5C,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,OAAO,EAAE,4BAA4B;IACrC,iBAAiB,EAAE,2BAA2B,CAAC,KAAK,CAAC,iBAAiB;CACvE,CAAC;KACD,MAAM,EAAE,CAAC;AAGZ,sGAAsG;AACtG,iEAAiE;AACjE,MAAM,CAAC,MAAM,2CAA2C,GAAG,CAAC;KACzD,MAAM,CAAC,EAAE,QAAQ,EAAE,6BAA6B,EAAE,CAAC;KACnD,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,4CAA4C,GAAG,CAAC;KAC1D,MAAM,CAAC,EAAE,QAAQ,EAAE,6BAA6B,EAAE,CAAC;KACnD,MAAM,EAAE,CAAC","sourcesContent":["// Callable contracts for the stats pipeline: finalize, reopen, the Fix stats actions — the rebuilds,\n// the game repairs, the historical baseline, the stats check, and deleting a check's report — and the\n// migration's placement of\n// an unplaceable stat line.\n\nimport { z } from 'zod';\nimport { MAX_GAME_STATS_CORRECTION_TARGETS } from '../constants/sports.js';\nimport { statCounterKeySchema, statsOperationIdSchema, statsValidationReportIdSchema } from '../doc-schemas/atoms.js';\nimport { StatsDestinationChangeSchema, StatsOperationCountsSchema } from '../doc-schemas/stats-operation.js';\nimport {\n StatsValidationReportSchema,\n StatsValidationScopeSchema,\n StatsValidationSummarySchema,\n} from '../doc-schemas/system.js';\nimport { HistoricalStatsSchema } from '../doc-schemas/user-profile.js';\nimport {\n GAME_FINALIZE_OUTCOME_KEYS,\n GAME_REOPEN_OUTCOME_KEYS,\n GAME_STATS_REPAIR_OUTCOME_KEYS,\n UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS,\n} from '../types/stats.js';\nimport {\n countSchema,\n gameIdSchema,\n gameRosterPlayerIdSchema,\n leagueIdSchema,\n repairReasonSchema,\n sportKeySchema,\n teamIdSchema,\n userIdSchema,\n} from './atoms.js';\n\n// `finalizeGame` (a captain or co-captain of either team) / `adminFinalizeGame` (an admin or a\n// referee): make a game's numbers permanent. Everything it writes is derived server-side from the\n// game's events; nothing in the input is a number (SPORT-202).\nexport const FinalizeGameInputSchema = z.object({ gameId: gameIdSchema }).strict();\nexport type FinalizeGameInput = z.infer<typeof FinalizeGameInputSchema>;\n\n// `alreadyFinalized` when the game was completed before the call: nothing was written (SPORT-203).\nexport const FinalizeGameResultSchema = z\n .object({\n gameId: gameIdSchema,\n leagueId: leagueIdSchema,\n outcome: z.enum(GAME_FINALIZE_OUTCOME_KEYS),\n nonScoringRosterPlayerIds: z.array(gameRosterPlayerIdSchema),\n })\n .strict();\nexport type FinalizeGameResult = z.infer<typeof FinalizeGameResultSchema>;\n\n// `reopenGame` (an admin): take a finalized game's numbers back out so it can be scored again. It\n// changes a completed record, so the admin says why (SPORT-206, BACKEND-212).\nexport const ReopenGameInputSchema = z.object({ gameId: gameIdSchema, reason: repairReasonSchema }).strict();\nexport type ReopenGameInput = z.infer<typeof ReopenGameInputSchema>;\n\n// `alreadyOpen` when the game was not completed: nothing was written.\nexport const ReopenGameResultSchema = z\n .object({ gameId: gameIdSchema, leagueId: leagueIdSchema, outcome: z.enum(GAME_REOPEN_OUTCOME_KEYS) })\n .strict();\nexport type ReopenGameResult = z.infer<typeof ReopenGameResultSchema>;\n\n// `resolve.unrosteredStatLine` (an admin, at the cutover console, before the cutover): a recorded V1\n// stat line that no roster entry and no play of the game can place is placed on the team the admin\n// names, as the game's missing roster entry; the game's copy is then run again. The admin says why.\n// `dryRun` previews the placement — whether the game would then convert — and writes nothing.\nexport const AdminResolveUnrosteredStatLineInputSchema = z\n .object({\n gameId: gameIdSchema,\n userId: userIdSchema,\n teamId: teamIdSchema,\n reason: repairReasonSchema,\n dryRun: z.boolean().optional(),\n })\n .strict();\nexport type AdminResolveUnrosteredStatLineInput = z.infer<typeof AdminResolveUnrosteredStatLineInputSchema>;\n\n// `gameConverts` says whether the game's stats now convert, so the operator knows the copy can run.\nexport const AdminResolveUnrosteredStatLineResultSchema = z\n .object({\n gameId: gameIdSchema,\n userId: userIdSchema,\n teamId: teamIdSchema,\n outcome: z.enum(UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS),\n gameConverts: z.boolean(),\n })\n .strict();\nexport type AdminResolveUnrosteredStatLineResult = z.infer<typeof AdminResolveUnrosteredStatLineResultSchema>;\n\n// Every rebuild and every game repair is a repair of a completed record: it takes a reason, runs\n// under an operation id the admin's browser mints when the admin starts it, and offers a dry run that\n// lists each document it would change, with before and after, and writes nothing (BACKEND-212,\n// SPORT-206). A real run resumes from its operation document, so a cursor is taken from the client\n// only to page a dry run, which keeps no operation.\nconst statsRepairFields = {\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n resumeAfter: z.string().min(1).optional(),\n};\n\nconst cursorOnlyOnDryRun = (input: { dryRun: boolean; resumeAfter?: string }): boolean =>\n input.dryRun || input.resumeAfter === undefined;\nconst CURSOR_ONLY_ON_DRY_RUN = {\n message: 'A real run resumes from its operation; only a dry run takes a cursor.',\n path: ['resumeAfter'],\n};\n\n// `recalculateLeagueStats`: every team of one league — its standings line and its per-membership rows.\nexport const RecalculateLeagueStatsInputSchema = z\n .object({ leagueId: leagueIdSchema, ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateLeagueStatsInput = z.infer<typeof RecalculateLeagueStatsInputSchema>;\n\n// `recalculateAllLeagueStats`: every league, closed ones included, a page of leagues per call.\nexport const RecalculateAllLeagueStatsInputSchema = z\n .object({ ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateAllLeagueStatsInput = z.infer<typeof RecalculateAllLeagueStatsInputSchema>;\n\n// `recalculateUserStats`: one person's career line in every sport.\nexport const RecalculateUserStatsInputSchema = z\n .object({ userId: userIdSchema, ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateUserStatsInput = z.infer<typeof RecalculateUserStatsInputSchema>;\n\n// `recalculateAllUserStats`: every profile's career lines, a page of profiles per call.\nexport const RecalculateAllUserStatsInputSchema = z\n .object({ ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateAllUserStatsInput = z.infer<typeof RecalculateAllUserStatsInputSchema>;\n\n// `recalculateHallOfFame`: one sport's hall of fame — one person's entry, or the whole sport a page\n// of profiles per call. Refused for a sport that keeps none.\nexport const RecalculateHallOfFameInputSchema = z\n .object({ sportKey: sportKeySchema, userId: userIdSchema.optional(), ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateHallOfFameInput = z.infer<typeof RecalculateHallOfFameInputSchema>;\n\n// What one call of a rebuild did. `complete` is false while a paged rebuild has pages left: the\n// admin calls again with the same operation id — or, for a dry run, with `resumeAfter` set to\n// `nextResumeAfter`. `changes` is every document this call changed or, on a dry run, would change,\n// up to MAX_STATS_REPAIR_LISTED_CHANGES (`changesTruncated` says more were left out). A game whose\n// stored numbers disagree with its record is named in `stoppedOnGameIds`, and what it feeds is left\n// untouched. `scopeChanged` says a game was finalized or reopened in the scope while it ran, so the\n// admin runs it again.\nexport const StatsRebuildResultSchema = z\n .object({\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n complete: z.boolean(),\n nextResumeAfter: z.string().min(1).nullable(),\n counts: StatsOperationCountsSchema,\n stoppedOnGameIds: z.array(gameIdSchema),\n changes: z.array(StatsDestinationChangeSchema),\n changesTruncated: z.boolean(),\n scopeChanged: z.boolean(),\n })\n .strict();\nexport type StatsRebuildResult = z.infer<typeof StatsRebuildResultSchema>;\n\n// A line a correction sets, by its absolute value: the team line of `teamId`, or the player line\n// `{teamId}_{playerUserId}` when a player is named. Only a field the sport's adapter lists in\n// `correctableFields` may be set.\nexport const GameStatsCorrectionTargetSchema = z\n .object({\n teamId: teamIdSchema,\n playerUserId: userIdSchema.optional(),\n stat: statCounterKeySchema,\n value: countSchema,\n })\n .strict();\nexport type GameStatsCorrectionTarget = z.infer<typeof GameStatsCorrectionTargetSchema>;\n\n// `adminCorrectGameStats`: set named fields of a game's lines to the values given, or keep the\n// numbers the game stores now — a hand edit made outside the app — as corrections. Exactly one of the\n// two.\nexport const AdminCorrectGameStatsInputSchema = z\n .object({\n gameId: gameIdSchema,\n targets: z.array(GameStatsCorrectionTargetSchema).min(1).max(MAX_GAME_STATS_CORRECTION_TARGETS).optional(),\n keepStored: z.literal(true).optional(),\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n })\n .strict()\n .refine((input) => (input.targets === undefined) !== (input.keepStored === undefined), {\n message: 'Give the values to set, or keep the stored numbers — one of the two.',\n path: ['targets'],\n });\nexport type AdminCorrectGameStatsInput = z.infer<typeof AdminCorrectGameStatsInputSchema>;\n\n// `recalculateGameStats`: restore a game's numbers from its events, discarding a hand edit.\nexport const RecalculateGameStatsInputSchema = z\n .object({\n gameId: gameIdSchema,\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n })\n .strict();\nexport type RecalculateGameStatsInput = z.infer<typeof RecalculateGameStatsInputSchema>;\n\n// One correction a repair appended, or on a dry run would append.\nexport const GameStatsCorrectionSchema = z\n .object({ lineKey: z.string().min(1), field: statCounterKeySchema, value: z.number().int() })\n .strict();\nexport type GameStatsCorrection = z.infer<typeof GameStatsCorrectionSchema>;\n\n// What a game repair did: `reconciled` it changed the game; `unchanged` there was nothing to change;\n// `alreadyApplied` the operation had already committed and this call is its acknowledged retry.\nexport const GameStatsRepairResultSchema = z\n .object({\n gameId: gameIdSchema,\n leagueId: leagueIdSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n outcome: z.enum(GAME_STATS_REPAIR_OUTCOME_KEYS),\n corrections: z.array(GameStatsCorrectionSchema),\n gameChanged: z.boolean(),\n destinationChanges: z.array(StatsDestinationChangeSchema),\n })\n .strict();\nexport type GameStatsRepairResult = z.infer<typeof GameStatsRepairResultSchema>;\n\n// `adminUpdateHistoricalStats`: a person's pre-Q-Sports career totals for a sport that takes them,\n// written whole, and their career line and hall-of-fame entry rebuilt with them.\nexport const AdminUpdateHistoricalStatsInputSchema = z\n .object({\n userId: userIdSchema,\n sportKey: sportKeySchema,\n stats: HistoricalStatsSchema,\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n })\n .strict();\nexport type AdminUpdateHistoricalStatsInput = z.infer<typeof AdminUpdateHistoricalStatsInputSchema>;\n\nexport const AdminUpdateHistoricalStatsResultSchema = z\n .object({\n userId: userIdSchema,\n sportKey: sportKeySchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n outcome: z.enum(GAME_STATS_REPAIR_OUTCOME_KEYS),\n baselineBefore: HistoricalStatsSchema.nullable(),\n stoppedOnGameIds: z.array(gameIdSchema),\n changes: z.array(StatsDestinationChangeSchema),\n })\n .strict();\nexport type AdminUpdateHistoricalStatsResult = z.infer<typeof AdminUpdateHistoricalStatsResultSchema>;\n\n// `runStatsValidation`: check one game, one league, or — with neither — everything. A check that\n// reaches its time budget saves its place on its operation and answers `complete: false`; calling\n// again with the same operation id resumes it. It writes no stat, so it takes no reason.\nexport const RunStatsValidationInputSchema = z\n .object({ operationId: statsOperationIdSchema, scope: StatsValidationScopeSchema })\n .strict();\nexport type RunStatsValidationInput = z.infer<typeof RunStatsValidationInputSchema>;\n\nexport const RunStatsValidationResultSchema = z\n .object({\n reportId: z.string().min(1),\n complete: z.boolean(),\n summary: StatsValidationSummarySchema,\n discrepancyCounts: StatsValidationReportSchema.shape.discrepancyCounts,\n })\n .strict();\nexport type RunStatsValidationResult = z.infer<typeof RunStatsValidationResultSchema>;\n\n// `adminDeleteStatsValidationReport`: delete one stats check's report. It writes no stat, so it takes\n// no reason; a report that is not there is refused as not found.\nexport const AdminDeleteStatsValidationReportInputSchema = z\n .object({ reportId: statsValidationReportIdSchema })\n .strict();\nexport type AdminDeleteStatsValidationReportInput = z.infer<typeof AdminDeleteStatsValidationReportInputSchema>;\n\nexport const AdminDeleteStatsValidationReportResultSchema = z\n .object({ reportId: statsValidationReportIdSchema })\n .strict();\nexport type AdminDeleteStatsValidationReportResult = z.infer<typeof AdminDeleteStatsValidationReportResultSchema>;\n"]}
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/schemas/stats.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,sGAAsG;AACtG,2BAA2B;AAC3B,4BAA4B;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,8BAA8B,EAC9B,4CAA4C,GAC7C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,YAAY,GACb,M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,EAAE,sBAAsB;IACnC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC;IAC/C,cAAc,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IAChD,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,4BAA4B,CAAC;CAC/C,CAAC;KACD,MAAM,EAAE,CAAC;AAGZ,iGAAiG;AACjG,kGAAkG;AAClG,yFAAyF;AACzF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC;KAC3C,MAAM,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC;KAClF,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC;KAC5C,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,OAAO,EAAE,4BAA4B;IACrC,iBAAiB,EAAE,2BAA2B,CAAC,KAAK,CAAC,iBAAiB;CACvE,CAAC;KACD,MAAM,EAAE,CAAC;AAGZ,sGAAsG;AACtG,iEAAiE;AACjE,MAAM,CAAC,MAAM,2CAA2C,GAAG,CAAC;KACzD,MAAM,CAAC,EAAE,QAAQ,EAAE,6BAA6B,EAAE,CAAC;KACnD,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,4CAA4C,GAAG,CAAC;KAC1D,MAAM,CAAC,EAAE,QAAQ,EAAE,6BAA6B,EAAE,CAAC;KACnD,MAAM,EAAE,CAAC","sourcesContent":["// Callable contracts for the stats pipeline: finalize, reopen, the Fix stats actions — the rebuilds,\n// the game repairs, the historical baseline, the stats check, and deleting a check's report — and the\n// migration's placement of\n// an unplaceable stat line.\n\nimport { z } from 'zod';\nimport { MAX_GAME_STATS_CORRECTION_TARGETS } from '../constants/sports.js';\nimport { statCounterKeySchema, statsOperationIdSchema, statsValidationReportIdSchema } from '../doc-schemas/atoms.js';\nimport { StatsDestinationChangeSchema, StatsOperationCountsSchema } from '../doc-schemas/stats-operation.js';\nimport {\n StatsValidationReportSchema,\n StatsValidationScopeSchema,\n StatsValidationSummarySchema,\n} from '../doc-schemas/system.js';\nimport { HistoricalStatsSchema } from '../doc-schemas/user-profile.js';\nimport {\n GAME_FINALIZE_OUTCOME_KEYS,\n GAME_REOPEN_OUTCOME_KEYS,\n GAME_STATS_REPAIR_OUTCOME_KEYS,\n UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS,\n} from '../types/stats.js';\nimport {\n countSchema,\n gameIdSchema,\n gameRosterPlayerIdSchema,\n leagueIdSchema,\n repairReasonSchema,\n sportKeySchema,\n teamIdSchema,\n userIdSchema,\n} from './atoms.js';\n\n// `finalizeGame` (a captain or co-captain of either team) / `adminFinalizeGame` (an admin or a\n// referee): make a game's numbers permanent. Everything it writes is derived server-side from the\n// game's events; nothing in the input is a number (SPORT-202).\nexport const FinalizeGameInputSchema = z.object({ gameId: gameIdSchema }).strict();\nexport type FinalizeGameInput = z.infer<typeof FinalizeGameInputSchema>;\n\n// `alreadyFinalized` when the game was completed before the call: nothing was written (SPORT-203).\nexport const FinalizeGameResultSchema = z\n .object({\n gameId: gameIdSchema,\n leagueId: leagueIdSchema,\n outcome: z.enum(GAME_FINALIZE_OUTCOME_KEYS),\n nonScoringRosterPlayerIds: z.array(gameRosterPlayerIdSchema),\n })\n .strict();\nexport type FinalizeGameResult = z.infer<typeof FinalizeGameResultSchema>;\n\n// `reopenGame` (an admin): take a finalized game's numbers back out so it can be scored again. It\n// changes a completed record, so the admin says why (SPORT-206, BACKEND-212).\nexport const ReopenGameInputSchema = z.object({ gameId: gameIdSchema, reason: repairReasonSchema }).strict();\nexport type ReopenGameInput = z.infer<typeof ReopenGameInputSchema>;\n\n// `alreadyOpen` when the game was not completed: nothing was written.\nexport const ReopenGameResultSchema = z\n .object({ gameId: gameIdSchema, leagueId: leagueIdSchema, outcome: z.enum(GAME_REOPEN_OUTCOME_KEYS) })\n .strict();\nexport type ReopenGameResult = z.infer<typeof ReopenGameResultSchema>;\n\n// `resolve.unrosteredStatLine` (an admin, at the cutover console, before the cutover): a recorded V1\n// stat line that no roster entry and no play of the game can place is placed on the team the admin\n// names, as the game's missing roster entry; the game's copy is then run again. The admin says why.\n// `dryRun` previews the placement — whether the game would then convert — and writes nothing.\nexport const AdminResolveUnrosteredStatLineInputSchema = z\n .object({\n gameId: gameIdSchema,\n userId: userIdSchema,\n teamId: teamIdSchema,\n reason: repairReasonSchema,\n dryRun: z.boolean().optional(),\n })\n .strict();\nexport type AdminResolveUnrosteredStatLineInput = z.infer<typeof AdminResolveUnrosteredStatLineInputSchema>;\n\n// `gameConverts` says whether the game's stats now convert, so the operator knows the copy can run.\nexport const AdminResolveUnrosteredStatLineResultSchema = z\n .object({\n gameId: gameIdSchema,\n userId: userIdSchema,\n teamId: teamIdSchema,\n outcome: z.enum(UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS),\n gameConverts: z.boolean(),\n })\n .strict();\nexport type AdminResolveUnrosteredStatLineResult = z.infer<typeof AdminResolveUnrosteredStatLineResultSchema>;\n\n// Every rebuild and every game repair is a repair of a completed record: it takes a reason, runs\n// under an operation id the admin's browser mints when the admin starts it, and offers a dry run that\n// lists each document it would change, with before and after, and writes nothing (BACKEND-212,\n// SPORT-206). A real run resumes from its operation document, so a cursor is taken from the client\n// only to page a dry run, which keeps no operation.\nconst statsRepairFields = {\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n resumeAfter: z.string().min(1).optional(),\n};\n\nconst cursorOnlyOnDryRun = (input: { dryRun: boolean; resumeAfter?: string }): boolean =>\n input.dryRun || input.resumeAfter === undefined;\nconst CURSOR_ONLY_ON_DRY_RUN = {\n message: 'A real run resumes from its operation; only a dry run takes a cursor.',\n path: ['resumeAfter'],\n};\n\n// `recalculateLeagueStats`: every team of one league — its standings line and its per-membership rows.\nexport const RecalculateLeagueStatsInputSchema = z\n .object({ leagueId: leagueIdSchema, ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateLeagueStatsInput = z.infer<typeof RecalculateLeagueStatsInputSchema>;\n\n// `recalculateAllLeagueStats`: every league, closed ones included, a page of leagues per call.\nexport const RecalculateAllLeagueStatsInputSchema = z\n .object({ ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateAllLeagueStatsInput = z.infer<typeof RecalculateAllLeagueStatsInputSchema>;\n\n// `recalculateUserStats`: one person's career line in every sport.\nexport const RecalculateUserStatsInputSchema = z\n .object({ userId: userIdSchema, ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateUserStatsInput = z.infer<typeof RecalculateUserStatsInputSchema>;\n\n// `recalculateAllUserStats`: every profile's career lines, a page of profiles per call.\nexport const RecalculateAllUserStatsInputSchema = z\n .object({ ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateAllUserStatsInput = z.infer<typeof RecalculateAllUserStatsInputSchema>;\n\n// `recalculateHallOfFame`: one sport's hall of fame — one person's entry, or the whole sport a page\n// of profiles per call. Refused for a sport that keeps none.\nexport const RecalculateHallOfFameInputSchema = z\n .object({ sportKey: sportKeySchema, userId: userIdSchema.optional(), ...statsRepairFields })\n .strict()\n .refine(cursorOnlyOnDryRun, CURSOR_ONLY_ON_DRY_RUN);\nexport type RecalculateHallOfFameInput = z.infer<typeof RecalculateHallOfFameInputSchema>;\n\n// What one call of a rebuild did. `complete` is false while a paged rebuild has pages left: the\n// admin calls again with the same operation id — or, for a dry run, with `resumeAfter` set to\n// `nextResumeAfter`. `changes` is every document this call changed or, on a dry run, would change,\n// up to MAX_STATS_REPAIR_LISTED_CHANGES (`changesTruncated` says more were left out). A game whose\n// stored numbers disagree with its record is named in `stoppedOnGameIds`, and what it feeds is left\n// untouched. `scopeChanged` says a game was finalized or reopened in the scope while it ran, so the\n// admin runs it again.\nexport const StatsRebuildResultSchema = z\n .object({\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n complete: z.boolean(),\n nextResumeAfter: z.string().min(1).nullable(),\n counts: StatsOperationCountsSchema,\n stoppedOnGameIds: z.array(gameIdSchema),\n changes: z.array(StatsDestinationChangeSchema),\n changesTruncated: z.boolean(),\n scopeChanged: z.boolean(),\n })\n .strict();\nexport type StatsRebuildResult = z.infer<typeof StatsRebuildResultSchema>;\n\n// A line a correction sets, by its absolute value: the team line of `teamId`, or the player line\n// `{teamId}_{playerUserId}` when a player is named. Only a field the sport's adapter lists in\n// `correctableFields` may be set.\nexport const GameStatsCorrectionTargetSchema = z\n .object({\n teamId: teamIdSchema,\n playerUserId: userIdSchema.optional(),\n stat: statCounterKeySchema,\n value: countSchema,\n })\n .strict();\nexport type GameStatsCorrectionTarget = z.infer<typeof GameStatsCorrectionTargetSchema>;\n\n// `adminCorrectGameStats`: set named fields of a game's lines to the values given, or keep the\n// numbers the game stores now — a hand edit made outside the app — as corrections. Exactly one of the\n// two.\nexport const AdminCorrectGameStatsInputSchema = z\n .object({\n gameId: gameIdSchema,\n targets: z.array(GameStatsCorrectionTargetSchema).min(1).max(MAX_GAME_STATS_CORRECTION_TARGETS).optional(),\n keepStored: z.literal(true).optional(),\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n })\n .strict()\n .refine((input) => (input.targets === undefined) !== (input.keepStored === undefined), {\n message: 'Give the values to set, or keep the stored numbers — one of the two.',\n path: ['targets'],\n });\nexport type AdminCorrectGameStatsInput = z.infer<typeof AdminCorrectGameStatsInputSchema>;\n\n// `recalculateGameStats`: restore a game's numbers from its events, discarding a hand edit.\nexport const RecalculateGameStatsInputSchema = z\n .object({\n gameId: gameIdSchema,\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n })\n .strict();\nexport type RecalculateGameStatsInput = z.infer<typeof RecalculateGameStatsInputSchema>;\n\n// One correction a repair appended, or on a dry run would append.\nexport const GameStatsCorrectionSchema = z\n .object({ lineKey: z.string().min(1), field: statCounterKeySchema, value: z.number().int() })\n .strict();\nexport type GameStatsCorrection = z.infer<typeof GameStatsCorrectionSchema>;\n\n// A list of roster entries a repair replaced, as the game stored it and as the repair rebuilds it.\nconst replacedEntryListSchema = z\n .object({ stored: z.array(gameRosterPlayerIdSchema), rebuilt: z.array(gameRosterPlayerIdSchema) })\n .strict();\n\n// Every value of the game document a repair changed, each with the value the game stored and the\n// value the repair writes — never the whole document (BACKEND-212). `lines` holds each changed field\n// of a team or player line (`lineKey` the team id or the roster entry id), `scores` each team whose\n// score mirror changed, and the lists, the event counter and `recordRewritten` appear only when the\n// repair changes them; `recordRewritten` names the finalized record's page counts before and after,\n// without copying the record.\nexport const GameRepairChangesSchema = z\n .object({\n lines: z.array(\n z.object({ lineKey: z.string().min(1), field: z.string().min(1), stored: z.number(), rebuilt: z.number() }).strict(),\n ),\n scores: z.array(z.object({ teamId: teamIdSchema, stored: z.number(), rebuilt: z.number() }).strict()),\n absentRosterPlayerIds: replacedEntryListSchema.optional(),\n nonScoringRosterPlayerIds: replacedEntryListSchema.optional(),\n statEventSequence: z.object({ stored: countSchema, rebuilt: countSchema }).strict().optional(),\n recordRewritten: z.object({ pagesBefore: countSchema, pagesAfter: countSchema }).strict().optional(),\n })\n .strict();\nexport type GameRepairChanges = z.infer<typeof GameRepairChangesSchema>;\n\n// What a game repair did: `reconciled` it changed the game; `unchanged` there was nothing to change;\n// `alreadyApplied` the operation had already committed and this call is its acknowledged retry.\n// `gameChanges` is what it changed on the game document, or on a dry run would change; empty lists\n// for any other outcome.\nexport const GameStatsRepairResultSchema = z\n .object({\n gameId: gameIdSchema,\n leagueId: leagueIdSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n outcome: z.enum(GAME_STATS_REPAIR_OUTCOME_KEYS),\n corrections: z.array(GameStatsCorrectionSchema),\n gameChanged: z.boolean(),\n gameChanges: GameRepairChangesSchema,\n destinationChanges: z.array(StatsDestinationChangeSchema),\n })\n .strict();\nexport type GameStatsRepairResult = z.infer<typeof GameStatsRepairResultSchema>;\n\n// `adminUpdateHistoricalStats`: a person's pre-Q-Sports career totals for a sport that takes them,\n// written whole, and their career line and hall-of-fame entry rebuilt with them.\nexport const AdminUpdateHistoricalStatsInputSchema = z\n .object({\n userId: userIdSchema,\n sportKey: sportKeySchema,\n stats: HistoricalStatsSchema,\n reason: repairReasonSchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n })\n .strict();\nexport type AdminUpdateHistoricalStatsInput = z.infer<typeof AdminUpdateHistoricalStatsInputSchema>;\n\nexport const AdminUpdateHistoricalStatsResultSchema = z\n .object({\n userId: userIdSchema,\n sportKey: sportKeySchema,\n operationId: statsOperationIdSchema,\n dryRun: z.boolean(),\n outcome: z.enum(GAME_STATS_REPAIR_OUTCOME_KEYS),\n baselineBefore: HistoricalStatsSchema.nullable(),\n stoppedOnGameIds: z.array(gameIdSchema),\n changes: z.array(StatsDestinationChangeSchema),\n })\n .strict();\nexport type AdminUpdateHistoricalStatsResult = z.infer<typeof AdminUpdateHistoricalStatsResultSchema>;\n\n// `runStatsValidation`: check one game, one league, or — with neither — everything. A check that\n// reaches its time budget saves its place on its operation and answers `complete: false`; calling\n// again with the same operation id resumes it. It writes no stat, so it takes no reason.\nexport const RunStatsValidationInputSchema = z\n .object({ operationId: statsOperationIdSchema, scope: StatsValidationScopeSchema })\n .strict();\nexport type RunStatsValidationInput = z.infer<typeof RunStatsValidationInputSchema>;\n\nexport const RunStatsValidationResultSchema = z\n .object({\n reportId: z.string().min(1),\n complete: z.boolean(),\n summary: StatsValidationSummarySchema,\n discrepancyCounts: StatsValidationReportSchema.shape.discrepancyCounts,\n })\n .strict();\nexport type RunStatsValidationResult = z.infer<typeof RunStatsValidationResultSchema>;\n\n// `adminDeleteStatsValidationReport`: delete one stats check's report. It writes no stat, so it takes\n// no reason; a report that is not there is refused as not found.\nexport const AdminDeleteStatsValidationReportInputSchema = z\n .object({ reportId: statsValidationReportIdSchema })\n .strict();\nexport type AdminDeleteStatsValidationReportInput = z.infer<typeof AdminDeleteStatsValidationReportInputSchema>;\n\nexport const AdminDeleteStatsValidationReportResultSchema = z\n .object({ reportId: statsValidationReportIdSchema })\n .strict();\nexport type AdminDeleteStatsValidationReportResult = z.infer<typeof AdminDeleteStatsValidationReportResultSchema>;\n"]}
@@ -419,6 +419,17 @@ export declare const DeleteTeamGhostPlayerResultSchema: z.ZodObject<{
419
419
  publicUserDeleted: z.ZodBoolean;
420
420
  }, z.core.$strict>;
421
421
  export type DeleteTeamGhostPlayerResult = z.infer<typeof DeleteTeamGhostPlayerResultSchema>;
422
+ export declare const GhostRemovalRefusalDetailsSchema: z.ZodObject<{
423
+ reason: z.ZodEnum<{
424
+ gameHeld: "gameHeld";
425
+ ghostHasPlayed: "ghostHasPlayed";
426
+ removalStopped: "removalStopped";
427
+ ghostBeingLinked: "ghostBeingLinked";
428
+ captainNotRemovable: "captainNotRemovable";
429
+ }>;
430
+ finishedGameEntriesRemoved: z.ZodOptional<z.ZodNumber>;
431
+ }, z.core.$strict>;
432
+ export type GhostRemovalRefusalDetails = z.infer<typeof GhostRemovalRefusalDetailsSchema>;
422
433
  export declare const AdminUpdateLeagueTeamCaptainInputSchema: z.ZodObject<{
423
434
  teamId: z.ZodString;
424
435
  captainUserId: z.ZodString;
@@ -472,4 +483,13 @@ export declare const AdminDeleteLeagueTeamResultSchema: z.ZodObject<{
472
483
  remainingGameCount: z.ZodNumber;
473
484
  }, z.core.$strict>;
474
485
  export type AdminDeleteLeagueTeamResult = z.infer<typeof AdminDeleteLeagueTeamResultSchema>;
486
+ export declare const LEAGUE_TEAM_DELETE_REFUSAL_KEYS: readonly ["teamHasPlayed"];
487
+ export type LeagueTeamDeleteRefusal = (typeof LEAGUE_TEAM_DELETE_REFUSAL_KEYS)[number];
488
+ export declare const LeagueTeamDeleteRefusalDetailsSchema: z.ZodObject<{
489
+ reason: z.ZodEnum<{
490
+ teamHasPlayed: "teamHasPlayed";
491
+ }>;
492
+ deletedGameCount: z.ZodNumber;
493
+ }, z.core.$strict>;
494
+ export type LeagueTeamDeleteRefusalDetails = z.infer<typeof LeagueTeamDeleteRefusalDetailsSchema>;
475
495
  //# sourceMappingURL=teams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../../src/schemas/teams.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsCxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAwC,CAAC;AACjF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAElC,CAAC;AACZ,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,eAAO,MAAM,4BAA4B;;;;kBAE9B,CAAC;AACZ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAYlF,eAAO,MAAM,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C,CAAC;AAC1F,MAAM,MAAM,kCAAkC,GAAG,2BAA2B,CAAC;AAK7E,eAAO,MAAM,gCAAgC;;kBAA8C,CAAC;AAC5F,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAK1F,eAAO,MAAM,iCAAiC;;;;kBAMnC,CAAC;AACZ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAM5F,eAAO,MAAM,+BAA+B,4BAA6B,CAAC;AAC1E,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AACvF,eAAO,MAAM,oCAAoC;;;;;kBAEtC,CAAC;AACZ,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC"}
@@ -6,7 +6,7 @@ import { leagueJoinWarningActedOnSchema, leagueJoinWarningFindingSchema, } from
6
6
  import { documentIdSegmentSchema, membershipRosterSyncStatusSchema } from '../doc-schemas/atoms.js';
7
7
  import { buildGhostUserIdForRequest, isGhostUserId } from '../ids/minted-ids.js';
8
8
  import { isDocumentIdSegment } from '../paths/utils.js';
9
- import { GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS } from '../types/stats.js';
9
+ import { GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS, GHOST_REMOVAL_REFUSAL_KEYS } from '../types/stats.js';
10
10
  import { MEMBER_ASSIGNABLE_TEAM_ROLES } from '../types/unions.js';
11
11
  import { contactPhoneSchema, countSchema, displayNameSchema, gameIdSchema, leagueIdSchema, teamIconSchema, teamIdSchema, teamNameSchema, teamRoleSchema, teamTypeSchema, userIdSchema, } from './atoms.js';
12
12
  // ---------------------------------------------------------------------------------------------
@@ -191,6 +191,12 @@ export const DeleteTeamGhostPlayerResultSchema = z
191
191
  publicUserDeleted: z.boolean(),
192
192
  })
193
193
  .strict();
194
+ // The details of a ghost removal's designed refusal: its reason, and — for a refusal that stops a
195
+ // removal already under way — `finishedGameEntriesRemoved`, the removal's count so far, as the result
196
+ // counts it. Those entries stay removed.
197
+ export const GhostRemovalRefusalDetailsSchema = z
198
+ .object({ reason: z.enum(GHOST_REMOVAL_REFUSAL_KEYS), finishedGameEntriesRemoved: countSchema.optional() })
199
+ .strict();
194
200
  // `adminUpdateLeagueTeamCaptain`: make a member of the team its captain. Every other captain the team
195
201
  // holds becomes a player.
196
202
  export const AdminUpdateLeagueTeamCaptainInputSchema = z
@@ -236,4 +242,12 @@ export const AdminDeleteLeagueTeamResultSchema = z
236
242
  remainingGameCount: countSchema,
237
243
  })
238
244
  .strict();
245
+ // Why a team's deletion was refused, in the refusal's details: the team has played — a completed
246
+ // game, or a stat in one of its games — whether that is found before anything is deleted or only as a
247
+ // later game is reached. `deletedGameCount` is the unplayed games this request had already deleted
248
+ // when it found the play, 0 when it found it first; those games stay deleted.
249
+ export const LEAGUE_TEAM_DELETE_REFUSAL_KEYS = ['teamHasPlayed'];
250
+ export const LeagueTeamDeleteRefusalDetailsSchema = z
251
+ .object({ reason: z.enum(LEAGUE_TEAM_DELETE_REFUSAL_KEYS), deletedGameCount: countSchema })
252
+ .strict();
239
253
  //# sourceMappingURL=teams.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/schemas/teams.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,kGAAkG;AAClG,6EAA6E;AAE7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;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AM,CAAC,MAAM,oCAAoC,GAAG,CAAC;KAClD,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;KAC1D,MAAM,EAAE,CAAC;AAGZ,sFAAsF;AACtF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC;KAC/C,MAAM,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;KAChF,MAAM,EAAE,CAAC;AAGZ,mGAAmG;AACnG,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC;KACrD,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;KAClE,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,wCAAwC,GAAG,iCAAiC,CAAC;AAG1F,kGAAkG;AAClG,oGAAoG;AACpG,sDAAsD;AACtD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAG5F,iGAAiG;AACjG,qGAAqG;AACrG,0BAA0B;AAC1B,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC;KAC/C,MAAM,CAAC;IACN,MAAM,EAAE,YAAY;IACpB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,kBAAkB,EAAE,WAAW;CAChC,CAAC;KACD,MAAM,EAAE,CAAC","sourcesContent":["// Callable contracts for teams and team membership. The acting user is always `request.auth.uid` —\n// never an input field (ARCH-106). The entry, never a field of the payload, decides the authority\n// (BACKEND-004); an admin entry's schema adds only what its authority needs.\n\nimport { z } from 'zod';\nimport {\n leagueJoinWarningActedOnSchema,\n leagueJoinWarningFindingSchema,\n} from '../utils/league-join-warning.js';\nimport { documentIdSegmentSchema, membershipRosterSyncStatusSchema } from '../doc-schemas/atoms.js';\nimport { buildGhostUserIdForRequest, isGhostUserId } from '../ids/minted-ids.js';\nimport { isDocumentIdSegment } from '../paths/utils.js';\nimport { GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS } from '../types/stats.js';\nimport { MEMBER_ASSIGNABLE_TEAM_ROLES } from '../types/unions.js';\nimport {\n contactPhoneSchema,\n countSchema,\n displayNameSchema,\n gameIdSchema,\n leagueIdSchema,\n teamIconSchema,\n teamIdSchema,\n teamNameSchema,\n teamRoleSchema,\n teamTypeSchema,\n userIdSchema,\n} from './atoms.js';\n\n// ---------------------------------------------------------------------------------------------\n// Team creation — `createLeagueTeam` (the creator becomes captain) and `adminCreateLeagueTeam`\n// (an admin creates the team with a newly minted ghost captain). Both write the team's contact\n// phone; `teamType` is read only in a Competitive/Recreational league, which requires it.\n// ---------------------------------------------------------------------------------------------\n\nconst teamCreationFields = {\n leagueId: leagueIdSchema,\n name: teamNameSchema,\n icon: teamIconSchema,\n teamType: teamTypeSchema.optional(),\n contactPhone: contactPhoneSchema,\n};\n\nexport const CreateLeagueTeamInputSchema = z.object(teamCreationFields).strict();\nexport type CreateLeagueTeamInput = z.infer<typeof CreateLeagueTeamInputSchema>;\n\nexport const AdminCreateLeagueTeamInputSchema = z\n .object({ ...teamCreationFields, captainDisplayName: displayNameSchema })\n .strict();\nexport type AdminCreateLeagueTeamInput = z.infer<typeof AdminCreateLeagueTeamInputSchema>;\n\nexport const CreateLeagueTeamResultSchema = z\n .object({ leagueId: leagueIdSchema, teamId: teamIdSchema, captainUserId: userIdSchema })\n .strict();\nexport type CreateLeagueTeamResult = z.infer<typeof CreateLeagueTeamResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// Ghost add — one core behind two doors. The team page door (`createTeamGhostPlayer` /\n// `adminCreateTeamGhostPlayer`) needs authority over the team; the game page door\n// (`createGameGhostPlayer` / `adminCreateGameGhostPlayer`) needs scoring authority over the game\n// and adds to one of its two teams. The ghost id is derived by the server from the add's\n// `requestId`, which the client mints once when the add starts and re-sends on every retry, so a\n// retry after an unknown outcome is recognised as the same add (`buildGhostUserIdForRequest`).\n// ---------------------------------------------------------------------------------------------\n\n// One document-id segment (ARCH-106), short enough that the ghost id derived from it is one too.\nexport const ghostCreateRequestIdSchema = documentIdSegmentSchema.refine(\n (requestId) => isDocumentIdSegment(buildGhostUserIdForRequest(requestId)),\n 'Not a ghost add request id.',\n);\n\nexport const CreateTeamGhostPlayerInputSchema = z\n .object({ teamId: teamIdSchema, displayName: displayNameSchema, requestId: ghostCreateRequestIdSchema })\n .strict();\nexport type CreateTeamGhostPlayerInput = z.infer<typeof CreateTeamGhostPlayerInputSchema>;\n\nexport const CreateGameGhostPlayerInputSchema = z\n .object({\n gameId: gameIdSchema,\n teamId: teamIdSchema,\n displayName: displayNameSchema,\n requestId: ghostCreateRequestIdSchema,\n })\n .strict();\nexport type CreateGameGhostPlayerInput = z.infer<typeof CreateGameGhostPlayerInputSchema>;\n\n// `rosterSyncStatus` is where the new membership's roster work stood when the call returned: the\n// membership is committed either way, and `pending` finishes in the background.\nexport const CreateGhostPlayerResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n rosterSyncStatus: membershipRosterSyncStatusSchema,\n })\n .strict();\nexport type CreateGhostPlayerResult = z.infer<typeof CreateGhostPlayerResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// The join warning — `getLeagueJoinWarning` (the person, or a captain or co-captain of the target\n// team) and `adminGetLeagueJoinWarning` (an admin, about anyone).\n// ---------------------------------------------------------------------------------------------\n\n// `targetTeamId` is the team the door acts for; a free-agent signup and a team being created have\n// none. `actedOn` is the item the door answers, which the warning leaves out.\nexport const GetLeagueJoinWarningInputSchema = z\n .object({\n leagueId: leagueIdSchema,\n userId: userIdSchema,\n targetTeamId: teamIdSchema.optional(),\n actedOn: leagueJoinWarningActedOnSchema.optional(),\n })\n .strict();\nexport type GetLeagueJoinWarningInput = z.infer<typeof GetLeagueJoinWarningInputSchema>;\n\nexport const GetLeagueJoinWarningResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n userId: userIdSchema,\n findings: z.array(leagueJoinWarningFindingSchema),\n })\n .strict();\nexport type GetLeagueJoinWarningResult = z.infer<typeof GetLeagueJoinWarningResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// Roster reconciliation recovery — an admin puts a team's failed roster obligations back to work.\n// ---------------------------------------------------------------------------------------------\n\nexport const AdminRetryLeagueTeamRosterSyncInputSchema = z.object({ teamId: teamIdSchema }).strict();\nexport type AdminRetryLeagueTeamRosterSyncInput = z.infer<typeof AdminRetryLeagueTeamRosterSyncInputSchema>;\n\nexport const AdminRetryLeagueTeamRosterSyncResultSchema = z\n .object({\n teamId: teamIdSchema,\n // Failed obligations put back to pending.\n retried: countSchema,\n // Of those and any already pending, how many the call itself finished.\n reconciled: countSchema,\n // Failed obligations left as they are because they fail their schema, by document id; a\n // damaged document's id is reported as stored, so it is not held to the membership id format.\n damagedTeamMembershipIds: z.array(z.string().min(1)),\n })\n .strict();\nexport type AdminRetryLeagueTeamRosterSyncResult = z.infer<typeof AdminRetryLeagueTeamRosterSyncResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// Linking a ghost to a real account — `linkGhostPlayerToUser` in a league that is not closed, and\n// `adminLinkClosedLeagueGhostPlayer` in a closed one. Both are admin-only and act on one team. A link\n// takes no reason: the admin chooses the account and confirms, and the link's audit event records\n// who linked which ghost to whom and what moved (BACKEND-212). The ghost and the account are\n// ids the core checks itself, so a ghost id named as the account, or a real id named as the ghost,\n// is refused with a failure record rather than at the parse. Every name the link records is read\n// server-side, never sent.\n// ---------------------------------------------------------------------------------------------\n\nexport const LinkGhostPlayerInputSchema = z\n .object({\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n userId: userIdSchema,\n })\n .strict();\nexport type LinkGhostPlayerInput = z.infer<typeof LinkGhostPlayerInputSchema>;\n\n// `complete` is false when the call ran out of time part-way: the link stays under way, and the same\n// call by the same account continues it. `membershipOutcome` is present once it is complete.\n// `publicUserDeleted` is false when something else still names the ghost.\nexport const LinkGhostPlayerResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n userId: userIdSchema,\n complete: z.boolean(),\n gamesMoved: countSchema,\n membershipOutcome: z.enum(GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS).optional(),\n publicUserDeleted: z.boolean(),\n })\n .strict();\nexport type LinkGhostPlayerResult = z.infer<typeof LinkGhostPlayerResultSchema>;\n\nexport const AdminLinkClosedLeagueGhostPlayerInputSchema = LinkGhostPlayerInputSchema;\nexport type AdminLinkClosedLeagueGhostPlayerInput = LinkGhostPlayerInput;\nexport const AdminLinkClosedLeagueGhostPlayerResultSchema = LinkGhostPlayerResultSchema;\nexport type AdminLinkClosedLeagueGhostPlayerResult = LinkGhostPlayerResult;\n\n// ---------------------------------------------------------------------------------------------\n// Managing a team's members. A role change and a removal each have a member entry — the team's\n// captain or a co-captain, read from their membership — and an admin entry; changing the captain,\n// renaming the team, changing its type, setting its contact phone, and deleting it are admin-only.\n// Every target is named by id and read server-side; nothing here names who is acting (ARCH-106).\n// ---------------------------------------------------------------------------------------------\n\n/** A ghost id, refused for any other id, so a removal input cannot name a real account. */\nexport const ghostUserIdSchema = userIdSchema.refine(isGhostUserId, 'Not a ghost player.');\n\n// `updateTeamMembershipRole` (the captain) / `adminUpdateTeamMembershipRole`: promote a player to\n// co-captain, or demote a co-captain to player.\nexport const UpdateTeamMembershipRoleInputSchema = z\n .object({ teamId: teamIdSchema, userId: userIdSchema, role: z.enum(MEMBER_ASSIGNABLE_TEAM_ROLES) })\n .strict();\nexport type UpdateTeamMembershipRoleInput = z.infer<typeof UpdateTeamMembershipRoleInputSchema>;\n\n// `changed` is false when the member already held the role: nothing was written or recorded.\nexport const UpdateTeamMembershipRoleResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n userId: userIdSchema,\n role: teamRoleSchema,\n changed: z.boolean(),\n })\n .strict();\nexport type UpdateTeamMembershipRoleResult = z.infer<typeof UpdateTeamMembershipRoleResultSchema>;\n\n// `deleteTeamMembership` (the captain or a co-captain) / `adminDeleteTeamMembership`: remove a real\n// player from the team. A ghost is removed through its own action, below.\nexport const DeleteTeamMembershipInputSchema = z\n .object({\n teamId: teamIdSchema,\n userId: userIdSchema.refine((userId) => !isGhostUserId(userId), 'A ghost player is removed as a ghost player.'),\n })\n .strict();\nexport type DeleteTeamMembershipInput = z.infer<typeof DeleteTeamMembershipInputSchema>;\n\n// `deleted` is false when the person held no membership on the team: nothing was written. The\n// membership is gone either way; `rosterSyncStatus` is where its roster work stood on return.\nexport const DeleteTeamMembershipResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n userId: userIdSchema,\n deleted: z.boolean(),\n rosterSyncStatus: membershipRosterSyncStatusSchema,\n })\n .strict();\nexport type DeleteTeamMembershipResult = z.infer<typeof DeleteTeamMembershipResultSchema>;\n\n// `deleteTeamGhostPlayer` (the captain or a co-captain) / `adminDeleteTeamGhostPlayer`: remove a ghost\n// that has never played, completely. A never-played ghost holds no stat, so its removal is not a\n// repair and takes no reason; its audit event still records who removed what (BACKEND-212).\nexport const DeleteTeamGhostPlayerInputSchema = z\n .object({ teamId: teamIdSchema, ghostUserId: ghostUserIdSchema })\n .strict();\nexport type DeleteTeamGhostPlayerInput = z.infer<typeof DeleteTeamGhostPlayerInputSchema>;\n\n// `complete` is false when the call ran out of time part-way: the ghost's games stay held and the\n// same call finishes the removal. `finishedGameEntriesRemoved` is the whole removal's count so far,\n// never one call's share, so a later response replaces an earlier one. `publicUserDeleted` is false\n// when something else still names the ghost, so its name stays until that reference goes.\nexport const DeleteTeamGhostPlayerResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n complete: z.boolean(),\n finishedGameEntriesRemoved: countSchema,\n publicUserDeleted: z.boolean(),\n })\n .strict();\nexport type DeleteTeamGhostPlayerResult = z.infer<typeof DeleteTeamGhostPlayerResultSchema>;\n\n// `adminUpdateLeagueTeamCaptain`: make a member of the team its captain. Every other captain the team\n// holds becomes a player.\nexport const AdminUpdateLeagueTeamCaptainInputSchema = z\n .object({ teamId: teamIdSchema, captainUserId: userIdSchema })\n .strict();\nexport type AdminUpdateLeagueTeamCaptainInput = z.infer<typeof AdminUpdateLeagueTeamCaptainInputSchema>;\n\nexport const AdminUpdateLeagueTeamCaptainResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n captainUserId: userIdSchema,\n demotedUserIds: z.array(userIdSchema),\n changed: z.boolean(),\n })\n .strict();\nexport type AdminUpdateLeagueTeamCaptainResult = z.infer<typeof AdminUpdateLeagueTeamCaptainResultSchema>;\n\n// `adminUpdateLeagueTeamName`: rename a team. The name lives on the team alone; nothing copies it.\nexport const AdminUpdateLeagueTeamNameInputSchema = z\n .object({ teamId: teamIdSchema, name: teamNameSchema })\n .strict();\nexport type AdminUpdateLeagueTeamNameInput = z.infer<typeof AdminUpdateLeagueTeamNameInputSchema>;\n\n// `adminUpdateLeagueTeamType`: change a team's type in a league that sorts its teams by type.\nexport const AdminUpdateLeagueTeamTypeInputSchema = z\n .object({ teamId: teamIdSchema, teamType: teamTypeSchema })\n .strict();\nexport type AdminUpdateLeagueTeamTypeInput = z.infer<typeof AdminUpdateLeagueTeamTypeInputSchema>;\n\n// The answer to either edit: `changed` is false when the team already held the value.\nexport const AdminUpdateLeagueTeamResultSchema = z\n .object({ leagueId: leagueIdSchema, teamId: teamIdSchema, changed: z.boolean() })\n .strict();\nexport type AdminUpdateLeagueTeamResult = z.infer<typeof AdminUpdateLeagueTeamResultSchema>;\n\n// `adminUpdateLeagueTeamContact`: set the team's contact phone on its admin-only contact document.\nexport const AdminUpdateLeagueTeamContactInputSchema = z\n .object({ teamId: teamIdSchema, contactPhone: contactPhoneSchema })\n .strict();\nexport type AdminUpdateLeagueTeamContactInput = z.infer<typeof AdminUpdateLeagueTeamContactInputSchema>;\n\nexport const AdminUpdateLeagueTeamContactResultSchema = AdminUpdateLeagueTeamResultSchema;\nexport type AdminUpdateLeagueTeamContactResult = AdminUpdateLeagueTeamResult;\n\n// `adminDeleteLeagueTeam`: delete a team that has never played, with everything that is only its.\n// A never-played team holds no stat, so its deletion is not a repair and takes no reason; its audit\n// event still records who deleted what (BACKEND-212).\nexport const AdminDeleteLeagueTeamInputSchema = z.object({ teamId: teamIdSchema }).strict();\nexport type AdminDeleteLeagueTeamInput = z.infer<typeof AdminDeleteLeagueTeamInputSchema>;\n\n// `complete` is false when the call ran out of time part-way: what is left stays, the team still\n// stands, and the same call finishes the deletion. `remainingGameCount` is the team's games still to\n// delete when it stopped.\nexport const AdminDeleteLeagueTeamResultSchema = z\n .object({\n teamId: teamIdSchema,\n complete: z.boolean(),\n remainingGameCount: countSchema,\n })\n .strict();\nexport type AdminDeleteLeagueTeamResult = z.infer<typeof AdminDeleteLeagueTeamResultSchema>;\n"]}
1
+ {"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/schemas/teams.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,kGAAkG;AAClG,6EAA6E;AAE7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kCAAkC,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,YAAY,EAC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C,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;KAC1F,MAAM,EAAE,CAAC","sourcesContent":["// Callable contracts for teams and team membership. The acting user is always `request.auth.uid` —\n// never an input field (ARCH-106). The entry, never a field of the payload, decides the authority\n// (BACKEND-004); an admin entry's schema adds only what its authority needs.\n\nimport { z } from 'zod';\nimport {\n leagueJoinWarningActedOnSchema,\n leagueJoinWarningFindingSchema,\n} from '../utils/league-join-warning.js';\nimport { documentIdSegmentSchema, membershipRosterSyncStatusSchema } from '../doc-schemas/atoms.js';\nimport { buildGhostUserIdForRequest, isGhostUserId } from '../ids/minted-ids.js';\nimport { isDocumentIdSegment } from '../paths/utils.js';\nimport { GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS, GHOST_REMOVAL_REFUSAL_KEYS } from '../types/stats.js';\nimport { MEMBER_ASSIGNABLE_TEAM_ROLES } from '../types/unions.js';\nimport {\n contactPhoneSchema,\n countSchema,\n displayNameSchema,\n gameIdSchema,\n leagueIdSchema,\n teamIconSchema,\n teamIdSchema,\n teamNameSchema,\n teamRoleSchema,\n teamTypeSchema,\n userIdSchema,\n} from './atoms.js';\n\n// ---------------------------------------------------------------------------------------------\n// Team creation — `createLeagueTeam` (the creator becomes captain) and `adminCreateLeagueTeam`\n// (an admin creates the team with a newly minted ghost captain). Both write the team's contact\n// phone; `teamType` is read only in a Competitive/Recreational league, which requires it.\n// ---------------------------------------------------------------------------------------------\n\nconst teamCreationFields = {\n leagueId: leagueIdSchema,\n name: teamNameSchema,\n icon: teamIconSchema,\n teamType: teamTypeSchema.optional(),\n contactPhone: contactPhoneSchema,\n};\n\nexport const CreateLeagueTeamInputSchema = z.object(teamCreationFields).strict();\nexport type CreateLeagueTeamInput = z.infer<typeof CreateLeagueTeamInputSchema>;\n\nexport const AdminCreateLeagueTeamInputSchema = z\n .object({ ...teamCreationFields, captainDisplayName: displayNameSchema })\n .strict();\nexport type AdminCreateLeagueTeamInput = z.infer<typeof AdminCreateLeagueTeamInputSchema>;\n\nexport const CreateLeagueTeamResultSchema = z\n .object({ leagueId: leagueIdSchema, teamId: teamIdSchema, captainUserId: userIdSchema })\n .strict();\nexport type CreateLeagueTeamResult = z.infer<typeof CreateLeagueTeamResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// Ghost add — one core behind two doors. The team page door (`createTeamGhostPlayer` /\n// `adminCreateTeamGhostPlayer`) needs authority over the team; the game page door\n// (`createGameGhostPlayer` / `adminCreateGameGhostPlayer`) needs scoring authority over the game\n// and adds to one of its two teams. The ghost id is derived by the server from the add's\n// `requestId`, which the client mints once when the add starts and re-sends on every retry, so a\n// retry after an unknown outcome is recognised as the same add (`buildGhostUserIdForRequest`).\n// ---------------------------------------------------------------------------------------------\n\n// One document-id segment (ARCH-106), short enough that the ghost id derived from it is one too.\nexport const ghostCreateRequestIdSchema = documentIdSegmentSchema.refine(\n (requestId) => isDocumentIdSegment(buildGhostUserIdForRequest(requestId)),\n 'Not a ghost add request id.',\n);\n\nexport const CreateTeamGhostPlayerInputSchema = z\n .object({ teamId: teamIdSchema, displayName: displayNameSchema, requestId: ghostCreateRequestIdSchema })\n .strict();\nexport type CreateTeamGhostPlayerInput = z.infer<typeof CreateTeamGhostPlayerInputSchema>;\n\nexport const CreateGameGhostPlayerInputSchema = z\n .object({\n gameId: gameIdSchema,\n teamId: teamIdSchema,\n displayName: displayNameSchema,\n requestId: ghostCreateRequestIdSchema,\n })\n .strict();\nexport type CreateGameGhostPlayerInput = z.infer<typeof CreateGameGhostPlayerInputSchema>;\n\n// `rosterSyncStatus` is where the new membership's roster work stood when the call returned: the\n// membership is committed either way, and `pending` finishes in the background.\nexport const CreateGhostPlayerResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n rosterSyncStatus: membershipRosterSyncStatusSchema,\n })\n .strict();\nexport type CreateGhostPlayerResult = z.infer<typeof CreateGhostPlayerResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// The join warning — `getLeagueJoinWarning` (the person, or a captain or co-captain of the target\n// team) and `adminGetLeagueJoinWarning` (an admin, about anyone).\n// ---------------------------------------------------------------------------------------------\n\n// `targetTeamId` is the team the door acts for; a free-agent signup and a team being created have\n// none. `actedOn` is the item the door answers, which the warning leaves out.\nexport const GetLeagueJoinWarningInputSchema = z\n .object({\n leagueId: leagueIdSchema,\n userId: userIdSchema,\n targetTeamId: teamIdSchema.optional(),\n actedOn: leagueJoinWarningActedOnSchema.optional(),\n })\n .strict();\nexport type GetLeagueJoinWarningInput = z.infer<typeof GetLeagueJoinWarningInputSchema>;\n\nexport const GetLeagueJoinWarningResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n userId: userIdSchema,\n findings: z.array(leagueJoinWarningFindingSchema),\n })\n .strict();\nexport type GetLeagueJoinWarningResult = z.infer<typeof GetLeagueJoinWarningResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// Roster reconciliation recovery — an admin puts a team's failed roster obligations back to work.\n// ---------------------------------------------------------------------------------------------\n\nexport const AdminRetryLeagueTeamRosterSyncInputSchema = z.object({ teamId: teamIdSchema }).strict();\nexport type AdminRetryLeagueTeamRosterSyncInput = z.infer<typeof AdminRetryLeagueTeamRosterSyncInputSchema>;\n\nexport const AdminRetryLeagueTeamRosterSyncResultSchema = z\n .object({\n teamId: teamIdSchema,\n // Failed obligations put back to pending.\n retried: countSchema,\n // Of those and any already pending, how many the call itself finished.\n reconciled: countSchema,\n // Failed obligations left as they are because they fail their schema, by document id; a\n // damaged document's id is reported as stored, so it is not held to the membership id format.\n damagedTeamMembershipIds: z.array(z.string().min(1)),\n })\n .strict();\nexport type AdminRetryLeagueTeamRosterSyncResult = z.infer<typeof AdminRetryLeagueTeamRosterSyncResultSchema>;\n\n// ---------------------------------------------------------------------------------------------\n// Linking a ghost to a real account — `linkGhostPlayerToUser` in a league that is not closed, and\n// `adminLinkClosedLeagueGhostPlayer` in a closed one. Both are admin-only and act on one team. A link\n// takes no reason: the admin chooses the account and confirms, and the link's audit event records\n// who linked which ghost to whom and what moved (BACKEND-212). The ghost and the account are\n// ids the core checks itself, so a ghost id named as the account, or a real id named as the ghost,\n// is refused with a failure record rather than at the parse. Every name the link records is read\n// server-side, never sent.\n// ---------------------------------------------------------------------------------------------\n\nexport const LinkGhostPlayerInputSchema = z\n .object({\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n userId: userIdSchema,\n })\n .strict();\nexport type LinkGhostPlayerInput = z.infer<typeof LinkGhostPlayerInputSchema>;\n\n// `complete` is false when the call ran out of time part-way: the link stays under way, and the same\n// call by the same account continues it. `membershipOutcome` is present once it is complete.\n// `publicUserDeleted` is false when something else still names the ghost.\nexport const LinkGhostPlayerResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n userId: userIdSchema,\n complete: z.boolean(),\n gamesMoved: countSchema,\n membershipOutcome: z.enum(GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS).optional(),\n publicUserDeleted: z.boolean(),\n })\n .strict();\nexport type LinkGhostPlayerResult = z.infer<typeof LinkGhostPlayerResultSchema>;\n\nexport const AdminLinkClosedLeagueGhostPlayerInputSchema = LinkGhostPlayerInputSchema;\nexport type AdminLinkClosedLeagueGhostPlayerInput = LinkGhostPlayerInput;\nexport const AdminLinkClosedLeagueGhostPlayerResultSchema = LinkGhostPlayerResultSchema;\nexport type AdminLinkClosedLeagueGhostPlayerResult = LinkGhostPlayerResult;\n\n// ---------------------------------------------------------------------------------------------\n// Managing a team's members. A role change and a removal each have a member entry — the team's\n// captain or a co-captain, read from their membership — and an admin entry; changing the captain,\n// renaming the team, changing its type, setting its contact phone, and deleting it are admin-only.\n// Every target is named by id and read server-side; nothing here names who is acting (ARCH-106).\n// ---------------------------------------------------------------------------------------------\n\n/** A ghost id, refused for any other id, so a removal input cannot name a real account. */\nexport const ghostUserIdSchema = userIdSchema.refine(isGhostUserId, 'Not a ghost player.');\n\n// `updateTeamMembershipRole` (the captain) / `adminUpdateTeamMembershipRole`: promote a player to\n// co-captain, or demote a co-captain to player.\nexport const UpdateTeamMembershipRoleInputSchema = z\n .object({ teamId: teamIdSchema, userId: userIdSchema, role: z.enum(MEMBER_ASSIGNABLE_TEAM_ROLES) })\n .strict();\nexport type UpdateTeamMembershipRoleInput = z.infer<typeof UpdateTeamMembershipRoleInputSchema>;\n\n// `changed` is false when the member already held the role: nothing was written or recorded.\nexport const UpdateTeamMembershipRoleResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n userId: userIdSchema,\n role: teamRoleSchema,\n changed: z.boolean(),\n })\n .strict();\nexport type UpdateTeamMembershipRoleResult = z.infer<typeof UpdateTeamMembershipRoleResultSchema>;\n\n// `deleteTeamMembership` (the captain or a co-captain) / `adminDeleteTeamMembership`: remove a real\n// player from the team. A ghost is removed through its own action, below.\nexport const DeleteTeamMembershipInputSchema = z\n .object({\n teamId: teamIdSchema,\n userId: userIdSchema.refine((userId) => !isGhostUserId(userId), 'A ghost player is removed as a ghost player.'),\n })\n .strict();\nexport type DeleteTeamMembershipInput = z.infer<typeof DeleteTeamMembershipInputSchema>;\n\n// `deleted` is false when the person held no membership on the team: nothing was written. The\n// membership is gone either way; `rosterSyncStatus` is where its roster work stood on return.\nexport const DeleteTeamMembershipResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n userId: userIdSchema,\n deleted: z.boolean(),\n rosterSyncStatus: membershipRosterSyncStatusSchema,\n })\n .strict();\nexport type DeleteTeamMembershipResult = z.infer<typeof DeleteTeamMembershipResultSchema>;\n\n// `deleteTeamGhostPlayer` (the captain or a co-captain) / `adminDeleteTeamGhostPlayer`: remove a ghost\n// that has never played, completely. A never-played ghost holds no stat, so its removal is not a\n// repair and takes no reason; its audit event still records who removed what (BACKEND-212).\nexport const DeleteTeamGhostPlayerInputSchema = z\n .object({ teamId: teamIdSchema, ghostUserId: ghostUserIdSchema })\n .strict();\nexport type DeleteTeamGhostPlayerInput = z.infer<typeof DeleteTeamGhostPlayerInputSchema>;\n\n// `complete` is false when the call ran out of time part-way: the ghost's games stay held and the\n// same call finishes the removal. `finishedGameEntriesRemoved` is the whole removal's count so far,\n// never one call's share, so a later response replaces an earlier one. `publicUserDeleted` is false\n// when something else still names the ghost, so its name stays until that reference goes.\nexport const DeleteTeamGhostPlayerResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n ghostUserId: userIdSchema,\n complete: z.boolean(),\n finishedGameEntriesRemoved: countSchema,\n publicUserDeleted: z.boolean(),\n })\n .strict();\nexport type DeleteTeamGhostPlayerResult = z.infer<typeof DeleteTeamGhostPlayerResultSchema>;\n\n// The details of a ghost removal's designed refusal: its reason, and — for a refusal that stops a\n// removal already under way — `finishedGameEntriesRemoved`, the removal's count so far, as the result\n// counts it. Those entries stay removed.\nexport const GhostRemovalRefusalDetailsSchema = z\n .object({ reason: z.enum(GHOST_REMOVAL_REFUSAL_KEYS), finishedGameEntriesRemoved: countSchema.optional() })\n .strict();\nexport type GhostRemovalRefusalDetails = z.infer<typeof GhostRemovalRefusalDetailsSchema>;\n\n// `adminUpdateLeagueTeamCaptain`: make a member of the team its captain. Every other captain the team\n// holds becomes a player.\nexport const AdminUpdateLeagueTeamCaptainInputSchema = z\n .object({ teamId: teamIdSchema, captainUserId: userIdSchema })\n .strict();\nexport type AdminUpdateLeagueTeamCaptainInput = z.infer<typeof AdminUpdateLeagueTeamCaptainInputSchema>;\n\nexport const AdminUpdateLeagueTeamCaptainResultSchema = z\n .object({\n leagueId: leagueIdSchema,\n teamId: teamIdSchema,\n captainUserId: userIdSchema,\n demotedUserIds: z.array(userIdSchema),\n changed: z.boolean(),\n })\n .strict();\nexport type AdminUpdateLeagueTeamCaptainResult = z.infer<typeof AdminUpdateLeagueTeamCaptainResultSchema>;\n\n// `adminUpdateLeagueTeamName`: rename a team. The name lives on the team alone; nothing copies it.\nexport const AdminUpdateLeagueTeamNameInputSchema = z\n .object({ teamId: teamIdSchema, name: teamNameSchema })\n .strict();\nexport type AdminUpdateLeagueTeamNameInput = z.infer<typeof AdminUpdateLeagueTeamNameInputSchema>;\n\n// `adminUpdateLeagueTeamType`: change a team's type in a league that sorts its teams by type.\nexport const AdminUpdateLeagueTeamTypeInputSchema = z\n .object({ teamId: teamIdSchema, teamType: teamTypeSchema })\n .strict();\nexport type AdminUpdateLeagueTeamTypeInput = z.infer<typeof AdminUpdateLeagueTeamTypeInputSchema>;\n\n// The answer to either edit: `changed` is false when the team already held the value.\nexport const AdminUpdateLeagueTeamResultSchema = z\n .object({ leagueId: leagueIdSchema, teamId: teamIdSchema, changed: z.boolean() })\n .strict();\nexport type AdminUpdateLeagueTeamResult = z.infer<typeof AdminUpdateLeagueTeamResultSchema>;\n\n// `adminUpdateLeagueTeamContact`: set the team's contact phone on its admin-only contact document.\nexport const AdminUpdateLeagueTeamContactInputSchema = z\n .object({ teamId: teamIdSchema, contactPhone: contactPhoneSchema })\n .strict();\nexport type AdminUpdateLeagueTeamContactInput = z.infer<typeof AdminUpdateLeagueTeamContactInputSchema>;\n\nexport const AdminUpdateLeagueTeamContactResultSchema = AdminUpdateLeagueTeamResultSchema;\nexport type AdminUpdateLeagueTeamContactResult = AdminUpdateLeagueTeamResult;\n\n// `adminDeleteLeagueTeam`: delete a team that has never played, with everything that is only its.\n// A never-played team holds no stat, so its deletion is not a repair and takes no reason; its audit\n// event still records who deleted what (BACKEND-212).\nexport const AdminDeleteLeagueTeamInputSchema = z.object({ teamId: teamIdSchema }).strict();\nexport type AdminDeleteLeagueTeamInput = z.infer<typeof AdminDeleteLeagueTeamInputSchema>;\n\n// `complete` is false when the call ran out of time part-way: what is left stays, the team still\n// stands, and the same call finishes the deletion. `remainingGameCount` is the team's games still to\n// delete when it stopped.\nexport const AdminDeleteLeagueTeamResultSchema = z\n .object({\n teamId: teamIdSchema,\n complete: z.boolean(),\n remainingGameCount: countSchema,\n })\n .strict();\nexport type AdminDeleteLeagueTeamResult = z.infer<typeof AdminDeleteLeagueTeamResultSchema>;\n\n// Why a team's deletion was refused, in the refusal's details: the team has played — a completed\n// game, or a stat in one of its games — whether that is found before anything is deleted or only as a\n// later game is reached. `deletedGameCount` is the unplayed games this request had already deleted\n// when it found the play, 0 when it found it first; those games stay deleted.\nexport const LEAGUE_TEAM_DELETE_REFUSAL_KEYS = ['teamHasPlayed'] as const;\nexport type LeagueTeamDeleteRefusal = (typeof LEAGUE_TEAM_DELETE_REFUSAL_KEYS)[number];\nexport const LeagueTeamDeleteRefusalDetailsSchema = z\n .object({ reason: z.enum(LEAGUE_TEAM_DELETE_REFUSAL_KEYS), deletedGameCount: countSchema })\n .strict();\nexport type LeagueTeamDeleteRefusalDetails = z.infer<typeof LeagueTeamDeleteRefusalDetailsSchema>;\n"]}
@@ -43,7 +43,7 @@ export declare const STATS_INTEGRITY_REFUSAL_KEYS: readonly ["statsOutOfBand", "
43
43
  export type StatsIntegrityRefusal = (typeof STATS_INTEGRITY_REFUSAL_KEYS)[number];
44
44
  export declare const GAME_STATS_REPAIR_OUTCOME_KEYS: readonly ["reconciled", "unchanged", "alreadyApplied"];
45
45
  export type GameStatsRepairOutcome = (typeof GAME_STATS_REPAIR_OUTCOME_KEYS)[number];
46
- export declare const GAME_REPAIR_REFUSAL_KEYS: readonly ["eventUnreadable", "sourcesDisagree", "scoreAmbiguous", "fieldNotCorrectable", "lineNotRostered", "teamNotInGame", "gameTooLarge"];
46
+ export declare const GAME_REPAIR_REFUSAL_KEYS: readonly ["eventUnreadable", "eventSequenceGap", "sourcesDisagree", "scoreAmbiguous", "fieldNotCorrectable", "lineNotRostered", "teamNotInGame", "gameTooLarge"];
47
47
  export type GameRepairRefusal = (typeof GAME_REPAIR_REFUSAL_KEYS)[number];
48
48
  export declare const GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS: readonly ["handedOver", "created", "merged", "kept"];
49
49
  export type GhostLinkMembershipOutcome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A8B,CAAC,CAAC,MAAM,CAAC,CAAC;AAerF,eAAO,MAAM,wBAAwB,kKAS3B,CAAC;AACX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAM1E,eAAO,MAAM,kCAAkC,sDAAuD,CAAC;AACvG,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,kCAAkC,CAAC,CAAC,MAAM,CAAC,CAAC;AAI7F,eAAO,MAAM,4CAA4C,0CAA2C,CAAC;AACrG,MAAM,MAAM,mCAAmC,GAAG,CAAC,OAAO,4CAA4C,CAAC,CAAC,MAAM,CAAC,CAAC;AAMhH,eAAO,MAAM,0BAA0B,sGAAuG,CAAC;AAC/I,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -102,6 +102,8 @@ export const STATS_INTEGRITY_REFUSAL_KEYS = ['statsOutOfBand', 'finalRecordMissi
102
102
  export const GAME_STATS_REPAIR_OUTCOME_KEYS = ['reconciled', 'unchanged', 'alreadyApplied'];
103
103
  // Why a game repair in Fix stats was refused, in the refusal's details, so the form says what to do:
104
104
  // eventUnreadable an event document no longer parses or replays — fix it in the console first
105
+ // eventSequenceGap the events do not hold exactly the sequences 1..n — a gap or a repeat — which
106
+ // a repair never renumbers: fix the event documents in the console first
105
107
  // sourcesDisagree the record, the stored rollup, and the events all disagree: no one of them
106
108
  // says what finalize applied
107
109
  // scoreAmbiguous keep-stored: the team line's score and the score mirror were both edited, to
@@ -113,6 +115,7 @@ export const GAME_STATS_REPAIR_OUTCOME_KEYS = ['reconciled', 'unchanged', 'alrea
113
115
  // gameTooLarge the repair would not fit in one commit
114
116
  export const GAME_REPAIR_REFUSAL_KEYS = [
115
117
  'eventUnreadable',
118
+ 'eventSequenceGap',
116
119
  'sourcesDisagree',
117
120
  'scoreAmbiguous',
118
121
  'fieldNotCorrectable',
@@ -1 +1 @@
1
- {"version":3,"file":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qBAAqB,CAAU,CAAC","sourcesContent":["// Canonical unions of the stat event store and the stats operations (ARCH-102). What each sport's\n// own events and lines are is ./sports.ts; these are the sport-agnostic halves every sport shares.\n\nimport { CAPTAIN_TEAM_ROLES, SYSTEM_ROLE_KEYS } from './unions.js';\n\n// The two store-level events, members of every sport's event union. A void undoes the one event it\n// targets; a correction adds a signed value to one correctable field of one line.\nexport const STAT_VOID_EVENT_TYPE = 'STAT_VOID';\nexport const STAT_CORRECTION_EVENT_TYPE = 'STAT_CORRECTION';\nexport const STAT_STORE_EVENT_TYPE_KEYS = [STAT_VOID_EVENT_TYPE, STAT_CORRECTION_EVENT_TYPE] as const;\nexport type StatStoreEventType = (typeof STAT_STORE_EVENT_TYPE_KEYS)[number];\n\n// The fields of a stored stat event the writing core derives — its place in the replay, and who\n// recorded it under which authority — so a caller never sends them (ARCH-106).\nexport const STAT_EVENT_RECORDER_FIELD_KEYS = [\n 'sequence',\n 'acceptedAt',\n 'recordedByUserId',\n 'recordedByAuthority',\n 'recordedByTeamId',\n] as const;\nexport type StatEventRecorderField = (typeof STAT_EVENT_RECORDER_FIELD_KEYS)[number];\n\n// The name snapshots only a copied event carries; nothing writes one on a new event (SPORT-104).\nexport const STAT_EVENT_SNAPSHOT_FIELD_KEYS = ['displayNameSnapshot', 'assistedByDisplayNameSnapshot'] as const;\nexport type StatEventSnapshotField = (typeof STAT_EVENT_SNAPSHOT_FIELD_KEYS)[number];\n\n// Who appended a correction: an admin reconciling a game, or the copy that carries a recorded\n// result its events do not explain.\nexport const STAT_CORRECTION_SOURCE_KEYS = ['admin', 'migration'] as const;\nexport type StatCorrectionSource = (typeof STAT_CORRECTION_SOURCE_KEYS)[number];\n\n// The authority the writing core confirmed for an event: a global role, or a team role on one of\n// the game's teams.\nexport const STAT_EVENT_AUTHORITY_KEYS = [...SYSTEM_ROLE_KEYS, ...CAPTAIN_TEAM_ROLES] as const;\nexport type StatEventAuthority = (typeof STAT_EVENT_AUTHORITY_KEYS)[number];\n\n// Every kind of stat line: the four player kinds, then the two team kinds. A sport's line of each\n// kind is declared once, in `SPORT_LINE_SCHEMAS`; a kind a sport has no line for is `never` there.\nexport const PLAYER_STAT_LINE_KIND_KEYS = ['gamePlayer', 'membershipRow', 'lifetime', 'hallOfFame'] as const;\nexport const TEAM_STAT_LINE_KIND_KEYS = ['gameTeam', 'teamSeason'] as const;\nexport const STAT_LINE_KIND_KEYS = [...PLAYER_STAT_LINE_KIND_KEYS, ...TEAM_STAT_LINE_KIND_KEYS] as const;\nexport type StatLineKind = (typeof STAT_LINE_KIND_KEYS)[number];\nexport type PlayerStatLineKind = (typeof PLAYER_STAT_LINE_KIND_KEYS)[number];\n\n// One logical run of a stats action, recorded on its `statsOperations` document.\nexport const STATS_OPERATION_KIND_KEYS = [\n 'leagueStatsRebuild',\n 'lifetimeStatsRebuild',\n 'hallOfFameRebuild',\n 'statsValidation',\n 'gameStatsCorrection',\n 'gameStatsRecalculation',\n 'historicalStatsUpdate',\n 'ghostPlayerStats',\n 'gameDeletion',\n] as const;\nexport type StatsOperationKind = (typeof STATS_OPERATION_KIND_KEYS)[number];\n\n// The rebuilds: each replaces one destination from the finalized games, a unit at a time, and shares\n// one paged run.\nexport const STATS_REBUILD_OPERATION_KIND_KEYS = [\n 'leagueStatsRebuild',\n 'lifetimeStatsRebuild',\n 'hallOfFameRebuild',\n] as const satisfies readonly StatsOperationKind[];\nexport type StatsRebuildOperationKind = (typeof STATS_REBUILD_OPERATION_KIND_KEYS)[number];\n\nexport const STATS_OPERATION_STATUS_KEYS = ['running', 'complete', 'stopped'] as const;\nexport type StatsOperationStatus = (typeof STATS_OPERATION_STATUS_KEYS)[number];\n\n// A validation run checks every game first, then the destinations those games feed.\nexport const STATS_VALIDATION_PHASE_KEYS = ['games', 'destinations'] as const;\nexport type StatsValidationPhase = (typeof STATS_VALIDATION_PHASE_KEYS)[number];\n\n// A ghost has one operation for both of its ways out, so a link and a removal refuse each other.\nexport const GHOST_STATS_OPERATION_ACTION_KEYS = ['link', 'removal'] as const;\nexport type GhostStatsOperationAction = (typeof GHOST_STATS_OPERATION_ACTION_KEYS)[number];\n\n// Why a scoring write refused an event. The first ten are a sport adapter's `validate`; the last\n// four are the store driver's own: an id already stored, or earlier in the batch, with different\n// content; a void whose target is missing, a void, or a correction; a correction sent to a scoring\n// entry, which only the game-reconcile core appends; and a void that would leave a stat below zero,\n// because a later edit already moved its target's field down.\nexport const STAT_EVENT_REFUSAL_KEYS = [\n 'eventTypeNotInSport',\n 'teamNotInGame',\n 'playerNotRostered',\n 'assisterNotRostered',\n 'assistNotAllowed',\n 'playerNotAllowed',\n 'roundNotNext',\n 'roundsComplete',\n 'bulkValueInvalid',\n 'bulkStale',\n 'eventIdConflict',\n 'voidTargetNotSportEvent',\n 'correctionNotAccepted',\n 'undoBelowZero',\n] as const;\nexport type StatEventRefusalCode = (typeof STAT_EVENT_REFUSAL_KEYS)[number];\n\n// Why a game may not be finalized yet — a sport played in rounds with an end still unrecorded.\nexport const FINALIZATION_NOT_READY_KEYS = ['roundsIncomplete'] as const;\nexport type FinalizationNotReadyReason = (typeof FINALIZATION_NOT_READY_KEYS)[number];\n\n// The scoring panel a sport's adapter names; the scoring screen renders one component per kind.\nexport const SCORING_PANEL_KIND_KEYS = ['playerEvents', 'teamPoints', 'rounds'] as const;\nexport type ScoringPanelKind = (typeof SCORING_PANEL_KIND_KEYS)[number];\n\n// The bulk-entry form body a sport's adapter names; the bulk-entry dialog renders one per kind.\nexport const BULK_ENTRY_KIND_KEYS = ['playerLines', 'teamScores', 'rounds'] as const;\nexport type BulkEntryKind = (typeof BULK_ENTRY_KIND_KEYS)[number];\n\n// What a scoring write did with each event it was sent: stored it now, or found it already stored\n// by an earlier send and acknowledged it without applying it again.\nexport const RECORDED_STAT_EVENT_OUTCOME_KEYS = ['recorded', 'alreadyRecorded'] as const;\nexport type RecordedStatEventOutcome = (typeof RECORDED_STAT_EVENT_OUTCOME_KEYS)[number];\n\n// What finalize did: made the game's numbers permanent, or found it already finalized and changed\n// nothing (SPORT-203).\nexport const GAME_FINALIZE_OUTCOME_KEYS = ['finalized', 'alreadyFinalized'] as const;\nexport type GameFinalizeOutcome = (typeof GAME_FINALIZE_OUTCOME_KEYS)[number];\n\n// What reopen did: took a finalized game's numbers back out, or found the game already open and\n// changed nothing.\nexport const GAME_REOPEN_OUTCOME_KEYS = ['reopened', 'alreadyOpen'] as const;\nexport type GameReopenOutcome = (typeof GAME_REOPEN_OUTCOME_KEYS)[number];\n\n// Why a path that makes numbers permanent, or takes them back, refused a game whose stored numbers\n// disagree with what produced them — something changed them outside the app, and an admin\n// reconciles the game in Fix stats first. Finalize, reopen, and a ghost link never adopt or discard\n// an unexplained difference (ENG-009):\n// statsOutOfBand the rollup or score mirror is not the replay of the game's events or record\n// finalRecordMissing a completed game has no finalized record\n// aggregateBelowZero a stored derived line holds less than the game put into it\nexport const STATS_INTEGRITY_REFUSAL_KEYS = ['statsOutOfBand', 'finalRecordMissing', 'aggregateBelowZero'] as const;\nexport type StatsIntegrityRefusal = (typeof STATS_INTEGRITY_REFUSAL_KEYS)[number];\n\n// What a game repair in Fix stats did: changed the game (`reconciled`), found nothing to change\n// (`unchanged`), or found its operation already committed and acknowledged the retry\n// (`alreadyApplied`).\nexport const GAME_STATS_REPAIR_OUTCOME_KEYS = ['reconciled', 'unchanged', 'alreadyApplied'] as const;\nexport type GameStatsRepairOutcome = (typeof GAME_STATS_REPAIR_OUTCOME_KEYS)[number];\n\n// Why a game repair in Fix stats was refused, in the refusal's details, so the form says what to do:\n// eventUnreadable an event document no longer parses or replays — fix it in the console first\n// sourcesDisagree the record, the stored rollup, and the events all disagree: no one of them\n// says what finalize applied\n// scoreAmbiguous keep-stored: the team line's score and the score mirror were both edited, to\n// different values — give the score as a target instead\n// fieldNotCorrectable a field the sport's adapter does not let a correction change — restore from\n// the events instead, or reopen and re-score\n// lineNotRostered a line for someone not on the game's roster\n// teamNotInGame a target names a team the game does not hold\n// gameTooLarge the repair would not fit in one commit\nexport const GAME_REPAIR_REFUSAL_KEYS = [\n 'eventUnreadable',\n 'sourcesDisagree',\n 'scoreAmbiguous',\n 'fieldNotCorrectable',\n 'lineNotRostered',\n 'teamNotInGame',\n 'gameTooLarge',\n] as const;\nexport type GameRepairRefusal = (typeof GAME_REPAIR_REFUSAL_KEYS)[number];\n\n// What a ghost link did with the team's memberships: the ghost's membership became the account's\n// (`handedOver`); the account had none and the ghost none either, so the closed-league link gave the\n// account one (`created`); both held one and one survives with the higher role (`merged`); or only\n// the account held one, and it stands (`kept`).\nexport const GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS = ['handedOver', 'created', 'merged', 'kept'] as const;\nexport type GhostLinkMembershipOutcome = (typeof GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS)[number];\n\n// What the migration's placement of an unplaceable V1 stat line did: `alreadyResolved` when the game\n// already held the entry it would write — nothing was written.\nexport const UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS = ['resolved', 'alreadyResolved'] as const;\nexport type UnrosteredStatLineResolutionOutcome = (typeof UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS)[number];\n\n// Why a ghost's removal was refused, in the refusal's details, so the client answers each one: the\n// ghost has played (link it instead) or its removal stopped on finding it had; a game the removal\n// needs is held by another operation (try again shortly); the ghost is being, or was, linked; the\n// ghost is the team's captain (change the captain first).\nexport const GHOST_REMOVAL_REFUSAL_KEYS = ['ghostHasPlayed', 'removalStopped', 'gameHeld', 'ghostBeingLinked', 'captainNotRemovable'] as const;\nexport type GhostRemovalRefusal = (typeof GHOST_REMOVAL_REFUSAL_KEYS)[number];\n\n"]}
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/types/stats.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,mGAAmG;AAEnG,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEnE,mGAAmG;AACnG,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAo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GAAoG;AACpG,uCAAuC;AACvC,oGAAoG;AACpG,iEAAiE;AACjE,mFAAmF;AACnF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,CAAU,CAAC;AAGpH,gGAAgG;AAChG,qFAAqF;AACrF,sBAAsB;AACtB,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,gBAAgB,CAAU,CAAC;AAGrG,qGAAqG;AACrG,oGAAoG;AACpG,sGAAsG;AACtG,+FAA+F;AAC/F,mGAAmG;AACnG,mDAAmD;AACnD,qGAAqG;AACrG,8EAA8E;AAC9E,oGAAoG;AACpG,mEAAmE;AACnE,oEAAoE;AACpE,qEAAqE;AACrE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,iBAAiB;IACjB,eAAe;IACf,cAAc;CACN,CAAC;AAGX,iGAAiG;AACjG,qGAAqG;AACrG,mGAAmG;AACnG,gDAAgD;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAGvG,qGAAqG;AACrG,+DAA+D;AAC/D,MAAM,CAAC,MAAM,4CAA4C,GAAG,CAAC,UAAU,EAAE,iBAAiB,CAAU,CAAC;AAGrG,mGAAmG;AACnG,kGAAkG;AAClG,kGAAkG;AAClG,0DAA0D;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,kBAAkB,EAAE,qBAAqB,CAAU,CAAC","sourcesContent":["// Canonical unions of the stat event store and the stats operations (ARCH-102). What each sport's\n// own events and lines are is ./sports.ts; these are the sport-agnostic halves every sport shares.\n\nimport { CAPTAIN_TEAM_ROLES, SYSTEM_ROLE_KEYS } from './unions.js';\n\n// The two store-level events, members of every sport's event union. A void undoes the one event it\n// targets; a correction adds a signed value to one correctable field of one line.\nexport const STAT_VOID_EVENT_TYPE = 'STAT_VOID';\nexport const STAT_CORRECTION_EVENT_TYPE = 'STAT_CORRECTION';\nexport const STAT_STORE_EVENT_TYPE_KEYS = [STAT_VOID_EVENT_TYPE, STAT_CORRECTION_EVENT_TYPE] as const;\nexport type StatStoreEventType = (typeof STAT_STORE_EVENT_TYPE_KEYS)[number];\n\n// The fields of a stored stat event the writing core derives — its place in the replay, and who\n// recorded it under which authority — so a caller never sends them (ARCH-106).\nexport const STAT_EVENT_RECORDER_FIELD_KEYS = [\n 'sequence',\n 'acceptedAt',\n 'recordedByUserId',\n 'recordedByAuthority',\n 'recordedByTeamId',\n] as const;\nexport type StatEventRecorderField = (typeof STAT_EVENT_RECORDER_FIELD_KEYS)[number];\n\n// The name snapshots only a copied event carries; nothing writes one on a new event (SPORT-104).\nexport const STAT_EVENT_SNAPSHOT_FIELD_KEYS = ['displayNameSnapshot', 'assistedByDisplayNameSnapshot'] as const;\nexport type StatEventSnapshotField = (typeof STAT_EVENT_SNAPSHOT_FIELD_KEYS)[number];\n\n// Who appended a correction: an admin reconciling a game, or the copy that carries a recorded\n// result its events do not explain.\nexport const STAT_CORRECTION_SOURCE_KEYS = ['admin', 'migration'] as const;\nexport type StatCorrectionSource = (typeof STAT_CORRECTION_SOURCE_KEYS)[number];\n\n// The authority the writing core confirmed for an event: a global role, or a team role on one of\n// the game's teams.\nexport const STAT_EVENT_AUTHORITY_KEYS = [...SYSTEM_ROLE_KEYS, ...CAPTAIN_TEAM_ROLES] as const;\nexport type StatEventAuthority = (typeof STAT_EVENT_AUTHORITY_KEYS)[number];\n\n// Every kind of stat line: the four player kinds, then the two team kinds. A sport's line of each\n// kind is declared once, in `SPORT_LINE_SCHEMAS`; a kind a sport has no line for is `never` there.\nexport const PLAYER_STAT_LINE_KIND_KEYS = ['gamePlayer', 'membershipRow', 'lifetime', 'hallOfFame'] as const;\nexport const TEAM_STAT_LINE_KIND_KEYS = ['gameTeam', 'teamSeason'] as const;\nexport const STAT_LINE_KIND_KEYS = [...PLAYER_STAT_LINE_KIND_KEYS, ...TEAM_STAT_LINE_KIND_KEYS] as const;\nexport type StatLineKind = (typeof STAT_LINE_KIND_KEYS)[number];\nexport type PlayerStatLineKind = (typeof PLAYER_STAT_LINE_KIND_KEYS)[number];\n\n// One logical run of a stats action, recorded on its `statsOperations` document.\nexport const STATS_OPERATION_KIND_KEYS = [\n 'leagueStatsRebuild',\n 'lifetimeStatsRebuild',\n 'hallOfFameRebuild',\n 'statsValidation',\n 'gameStatsCorrection',\n 'gameStatsRecalculation',\n 'historicalStatsUpdate',\n 'ghostPlayerStats',\n 'gameDeletion',\n] as const;\nexport type StatsOperationKind = (typeof STATS_OPERATION_KIND_KEYS)[number];\n\n// The rebuilds: each replaces one destination from the finalized games, a unit at a time, and shares\n// one paged run.\nexport const STATS_REBUILD_OPERATION_KIND_KEYS = [\n 'leagueStatsRebuild',\n 'lifetimeStatsRebuild',\n 'hallOfFameRebuild',\n] as const satisfies readonly StatsOperationKind[];\nexport type StatsRebuildOperationKind = (typeof STATS_REBUILD_OPERATION_KIND_KEYS)[number];\n\nexport const STATS_OPERATION_STATUS_KEYS = ['running', 'complete', 'stopped'] as const;\nexport type StatsOperationStatus = (typeof STATS_OPERATION_STATUS_KEYS)[number];\n\n// A validation run checks every game first, then the destinations those games feed.\nexport const STATS_VALIDATION_PHASE_KEYS = ['games', 'destinations'] as const;\nexport type StatsValidationPhase = (typeof STATS_VALIDATION_PHASE_KEYS)[number];\n\n// A ghost has one operation for both of its ways out, so a link and a removal refuse each other.\nexport const GHOST_STATS_OPERATION_ACTION_KEYS = ['link', 'removal'] as const;\nexport type GhostStatsOperationAction = (typeof GHOST_STATS_OPERATION_ACTION_KEYS)[number];\n\n// Why a scoring write refused an event. The first ten are a sport adapter's `validate`; the last\n// four are the store driver's own: an id already stored, or earlier in the batch, with different\n// content; a void whose target is missing, a void, or a correction; a correction sent to a scoring\n// entry, which only the game-reconcile core appends; and a void that would leave a stat below zero,\n// because a later edit already moved its target's field down.\nexport const STAT_EVENT_REFUSAL_KEYS = [\n 'eventTypeNotInSport',\n 'teamNotInGame',\n 'playerNotRostered',\n 'assisterNotRostered',\n 'assistNotAllowed',\n 'playerNotAllowed',\n 'roundNotNext',\n 'roundsComplete',\n 'bulkValueInvalid',\n 'bulkStale',\n 'eventIdConflict',\n 'voidTargetNotSportEvent',\n 'correctionNotAccepted',\n 'undoBelowZero',\n] as const;\nexport type StatEventRefusalCode = (typeof STAT_EVENT_REFUSAL_KEYS)[number];\n\n// Why a game may not be finalized yet — a sport played in rounds with an end still unrecorded.\nexport const FINALIZATION_NOT_READY_KEYS = ['roundsIncomplete'] as const;\nexport type FinalizationNotReadyReason = (typeof FINALIZATION_NOT_READY_KEYS)[number];\n\n// The scoring panel a sport's adapter names; the scoring screen renders one component per kind.\nexport const SCORING_PANEL_KIND_KEYS = ['playerEvents', 'teamPoints', 'rounds'] as const;\nexport type ScoringPanelKind = (typeof SCORING_PANEL_KIND_KEYS)[number];\n\n// The bulk-entry form body a sport's adapter names; the bulk-entry dialog renders one per kind.\nexport const BULK_ENTRY_KIND_KEYS = ['playerLines', 'teamScores', 'rounds'] as const;\nexport type BulkEntryKind = (typeof BULK_ENTRY_KIND_KEYS)[number];\n\n// What a scoring write did with each event it was sent: stored it now, or found it already stored\n// by an earlier send and acknowledged it without applying it again.\nexport const RECORDED_STAT_EVENT_OUTCOME_KEYS = ['recorded', 'alreadyRecorded'] as const;\nexport type RecordedStatEventOutcome = (typeof RECORDED_STAT_EVENT_OUTCOME_KEYS)[number];\n\n// What finalize did: made the game's numbers permanent, or found it already finalized and changed\n// nothing (SPORT-203).\nexport const GAME_FINALIZE_OUTCOME_KEYS = ['finalized', 'alreadyFinalized'] as const;\nexport type GameFinalizeOutcome = (typeof GAME_FINALIZE_OUTCOME_KEYS)[number];\n\n// What reopen did: took a finalized game's numbers back out, or found the game already open and\n// changed nothing.\nexport const GAME_REOPEN_OUTCOME_KEYS = ['reopened', 'alreadyOpen'] as const;\nexport type GameReopenOutcome = (typeof GAME_REOPEN_OUTCOME_KEYS)[number];\n\n// Why a path that makes numbers permanent, or takes them back, refused a game whose stored numbers\n// disagree with what produced them — something changed them outside the app, and an admin\n// reconciles the game in Fix stats first. Finalize, reopen, and a ghost link never adopt or discard\n// an unexplained difference (ENG-009):\n// statsOutOfBand the rollup or score mirror is not the replay of the game's events or record\n// finalRecordMissing a completed game has no finalized record\n// aggregateBelowZero a stored derived line holds less than the game put into it\nexport const STATS_INTEGRITY_REFUSAL_KEYS = ['statsOutOfBand', 'finalRecordMissing', 'aggregateBelowZero'] as const;\nexport type StatsIntegrityRefusal = (typeof STATS_INTEGRITY_REFUSAL_KEYS)[number];\n\n// What a game repair in Fix stats did: changed the game (`reconciled`), found nothing to change\n// (`unchanged`), or found its operation already committed and acknowledged the retry\n// (`alreadyApplied`).\nexport const GAME_STATS_REPAIR_OUTCOME_KEYS = ['reconciled', 'unchanged', 'alreadyApplied'] as const;\nexport type GameStatsRepairOutcome = (typeof GAME_STATS_REPAIR_OUTCOME_KEYS)[number];\n\n// Why a game repair in Fix stats was refused, in the refusal's details, so the form says what to do:\n// eventUnreadable an event document no longer parses or replays — fix it in the console first\n// eventSequenceGap the events do not hold exactly the sequences 1..n — a gap or a repeat — which\n// a repair never renumbers: fix the event documents in the console first\n// sourcesDisagree the record, the stored rollup, and the events all disagree: no one of them\n// says what finalize applied\n// scoreAmbiguous keep-stored: the team line's score and the score mirror were both edited, to\n// different values — give the score as a target instead\n// fieldNotCorrectable a field the sport's adapter does not let a correction change — restore from\n// the events instead, or reopen and re-score\n// lineNotRostered a line for someone not on the game's roster\n// teamNotInGame a target names a team the game does not hold\n// gameTooLarge the repair would not fit in one commit\nexport const GAME_REPAIR_REFUSAL_KEYS = [\n 'eventUnreadable',\n 'eventSequenceGap',\n 'sourcesDisagree',\n 'scoreAmbiguous',\n 'fieldNotCorrectable',\n 'lineNotRostered',\n 'teamNotInGame',\n 'gameTooLarge',\n] as const;\nexport type GameRepairRefusal = (typeof GAME_REPAIR_REFUSAL_KEYS)[number];\n\n// What a ghost link did with the team's memberships: the ghost's membership became the account's\n// (`handedOver`); the account had none and the ghost none either, so the closed-league link gave the\n// account one (`created`); both held one and one survives with the higher role (`merged`); or only\n// the account held one, and it stands (`kept`).\nexport const GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS = ['handedOver', 'created', 'merged', 'kept'] as const;\nexport type GhostLinkMembershipOutcome = (typeof GHOST_LINK_MEMBERSHIP_OUTCOME_KEYS)[number];\n\n// What the migration's placement of an unplaceable V1 stat line did: `alreadyResolved` when the game\n// already held the entry it would write — nothing was written.\nexport const UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS = ['resolved', 'alreadyResolved'] as const;\nexport type UnrosteredStatLineResolutionOutcome = (typeof UNROSTERED_STAT_LINE_RESOLUTION_OUTCOME_KEYS)[number];\n\n// Why a ghost's removal was refused, in the refusal's details, so the client answers each one: the\n// ghost has played (link it instead) or its removal stopped on finding it had; a game the removal\n// needs is held by another operation (try again shortly); the ghost is being, or was, linked; the\n// ghost is the team's captain (change the captain first).\nexport const GHOST_REMOVAL_REFUSAL_KEYS = ['ghostHasPlayed', 'removalStopped', 'gameHeld', 'ghostBeingLinked', 'captainNotRemovable'] as const;\nexport type GhostRemovalRefusal = (typeof GHOST_REMOVAL_REFUSAL_KEYS)[number];\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/q-core",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Core types, Firestore path constants, zod schemas, and shared constants for Q-Sports",
5
5
  "repository": {
6
6
  "type": "git",