@ttt-productions/q-core 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/sports.d.ts +1 -0
- package/dist/constants/sports.d.ts.map +1 -1
- package/dist/constants/sports.js +2 -0
- package/dist/constants/sports.js.map +1 -1
- package/dist/doc-schemas/admin-notifications.d.ts +1 -1
- package/dist/doc-schemas/audit-event.d.ts +2 -0
- package/dist/doc-schemas/audit-event.d.ts.map +1 -1
- package/dist/doc-schemas/award-group-grant.d.ts +2 -2
- package/dist/doc-schemas/gallery.d.ts.map +1 -1
- package/dist/doc-schemas/gallery.js +9 -3
- package/dist/doc-schemas/gallery.js.map +1 -1
- package/dist/doc-schemas/game-stat-history.js +2 -2
- package/dist/doc-schemas/game-stat-history.js.map +1 -1
- package/dist/doc-schemas/migration-console.d.ts +21 -5
- package/dist/doc-schemas/migration-console.d.ts.map +1 -1
- package/dist/doc-schemas/pending-media.d.ts.map +1 -1
- package/dist/doc-schemas/pending-media.js +8 -3
- package/dist/doc-schemas/pending-media.js.map +1 -1
- package/dist/doc-schemas/picture-retirement.d.ts.map +1 -1
- package/dist/doc-schemas/picture-retirement.js +8 -3
- package/dist/doc-schemas/picture-retirement.js.map +1 -1
- package/dist/doc-schemas/registry.d.ts +25 -14
- package/dist/doc-schemas/registry.d.ts.map +1 -1
- package/dist/doc-schemas/stats-operation.d.ts +22 -18
- package/dist/doc-schemas/stats-operation.d.ts.map +1 -1
- package/dist/doc-schemas/stats-operation.js +5 -0
- package/dist/doc-schemas/stats-operation.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/migration-console/action-ids.d.ts +4 -0
- package/dist/migration-console/action-ids.d.ts.map +1 -1
- package/dist/migration-console/action-ids.js +6 -0
- package/dist/migration-console/action-ids.js.map +1 -1
- package/dist/migration-console/console-lock.d.ts +10 -0
- package/dist/migration-console/console-lock.d.ts.map +1 -0
- package/dist/migration-console/console-lock.js +14 -0
- package/dist/migration-console/console-lock.js.map +1 -0
- package/dist/migration-console/consumed-source.d.ts +4 -0
- package/dist/migration-console/consumed-source.d.ts.map +1 -0
- package/dist/migration-console/consumed-source.js +10 -0
- package/dist/migration-console/consumed-source.js.map +1 -0
- package/dist/migration-console/manifest.d.ts +2 -0
- package/dist/migration-console/manifest.d.ts.map +1 -1
- package/dist/migration-console/manifest.js +173 -5
- package/dist/migration-console/manifest.js.map +1 -1
- package/dist/migration-console/run-state.d.ts +2 -0
- package/dist/migration-console/run-state.d.ts.map +1 -1
- package/dist/migration-console/run-state.js +3 -0
- package/dist/migration-console/run-state.js.map +1 -1
- package/dist/paths/picture-owner-paths.d.ts.map +1 -1
- package/dist/paths/picture-owner-paths.js +2 -1
- package/dist/paths/picture-owner-paths.js.map +1 -1
- package/dist/schemas/awards.d.ts +3 -3
- package/dist/schemas/migration-console.d.ts +58 -8
- package/dist/schemas/migration-console.d.ts.map +1 -1
- package/dist/schemas/migration-console.js +4 -0
- package/dist/schemas/migration-console.js.map +1 -1
- package/dist/schemas/scoring.d.ts +20 -20
- package/dist/schemas/stats.d.ts +12 -0
- package/dist/schemas/stats.d.ts.map +1 -1
- package/dist/schemas/stats.js +21 -1
- package/dist/schemas/stats.js.map +1 -1
- package/dist/sports/finalized-record.d.ts +2 -2
- package/dist/sports/finalized-record.d.ts.map +1 -1
- package/dist/sports/finalized-record.js +21 -2
- package/dist/sports/finalized-record.js.map +1 -1
- package/dist/types/audit.d.ts +1 -1
- package/dist/types/audit.d.ts.map +1 -1
- package/dist/types/audit.js +1 -0
- package/dist/types/audit.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/league-calendar.d.ts.map +1 -1
- package/dist/utils/league-calendar.js +6 -1
- package/dist/utils/league-calendar.js.map +1 -1
- package/dist/utils/stats-operation-request.d.ts +20 -0
- package/dist/utils/stats-operation-request.d.ts.map +1 -0
- package/dist/utils/stats-operation-request.js +10 -0
- package/dist/utils/stats-operation-request.js.map +1 -0
- package/package.json +2 -1
|
@@ -9,9 +9,9 @@ export interface FinalizedRecordPage {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function buildFinalizedRecordPages(events: readonly GameStatEvent[], snapshot: Pick<FinalizedGame, 'leagueType' | 'teamIds' | 'rosterPlayerIds' | 'absentRosterPlayerIds' | 'nonScoringRosterPlayerIds'>): FinalizedRecordPage[];
|
|
11
11
|
export declare function isFirstRecordPage(page: GameStatHistoryPage): page is GameStatHistoryFirstPage;
|
|
12
|
-
export declare function readFinalizedRecord(pages: readonly
|
|
12
|
+
export declare function readFinalizedRecord(pages: readonly FinalizedRecordPage[]): {
|
|
13
13
|
readonly snapshot: FinalizedRecordSnapshot;
|
|
14
14
|
readonly events: GameStatEvent[];
|
|
15
15
|
};
|
|
16
|
-
export declare function finalizedGameFromRecord(adapter: AnySportAdapter, pages: readonly
|
|
16
|
+
export declare function finalizedGameFromRecord(adapter: AnySportAdapter, pages: readonly FinalizedRecordPage[]): FinalizedGame;
|
|
17
17
|
//# sourceMappingURL=finalized-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finalized-record.d.ts","sourceRoot":"","sources":["../../src/sports/finalized-record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,WAAW,CAAC,CAAC;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uBAAuB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC;CAClC,CAkCA;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,SAAS,mBAAmB,EAAE,GACpC,aAAa,CAUf"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { STAT_HISTORY_PAGE_SIZE } from '../constants/sports.js';
|
|
1
|
+
import { MAX_STAT_HISTORY_PAGES, STAT_HISTORY_PAGE_SIZE } from '../constants/sports.js';
|
|
2
2
|
import { buildStatHistoryPageId } from '../ids/stat-event-ids.js';
|
|
3
3
|
import { replayGameStats } from './replay.js';
|
|
4
4
|
export function buildFinalizedRecordPages(events, snapshot) {
|
|
5
5
|
const ordered = [...events].sort((left, right) => left.sequence - right.sequence);
|
|
6
6
|
const pageCount = Math.max(1, Math.ceil(ordered.length / STAT_HISTORY_PAGE_SIZE));
|
|
7
|
+
if (pageCount > MAX_STAT_HISTORY_PAGES) {
|
|
8
|
+
throw new RangeError(`A finalized record holds at most ${MAX_STAT_HISTORY_PAGES} pages; ${ordered.length} events need ${pageCount}.`);
|
|
9
|
+
}
|
|
7
10
|
const pages = [];
|
|
8
11
|
for (let index = 0; index < pageCount; index += 1) {
|
|
9
12
|
const slice = ordered.slice(index * STAT_HISTORY_PAGE_SIZE, (index + 1) * STAT_HISTORY_PAGE_SIZE);
|
|
@@ -25,13 +28,29 @@ export function buildFinalizedRecordPages(events, snapshot) {
|
|
|
25
28
|
export function isFirstRecordPage(page) {
|
|
26
29
|
return 'pageCount' in page;
|
|
27
30
|
}
|
|
31
|
+
// The pages as the record's collection lists them, in id order. They are one whole record only as
|
|
32
|
+
// the exact set: the first page at `page_0000`, then a continuation page at each next id, as many in
|
|
33
|
+
// all as the first page counts.
|
|
28
34
|
export function readFinalizedRecord(pages) {
|
|
29
|
-
|
|
35
|
+
if (pages.length > MAX_STAT_HISTORY_PAGES) {
|
|
36
|
+
throw new Error(`A finalized record holds at most ${MAX_STAT_HISTORY_PAGES} pages.`);
|
|
37
|
+
}
|
|
38
|
+
const [firstEntry, ...restEntries] = pages;
|
|
39
|
+
const first = firstEntry?.page;
|
|
30
40
|
if (first === undefined || !isFirstRecordPage(first))
|
|
31
41
|
throw new Error('A finalized record starts with its first page.');
|
|
32
42
|
if (first.pageCount !== pages.length) {
|
|
33
43
|
throw new Error(`A finalized record of ${first.pageCount} pages was read as ${pages.length}.`);
|
|
34
44
|
}
|
|
45
|
+
pages.forEach(({ pageId, page }, index) => {
|
|
46
|
+
if (pageId !== buildStatHistoryPageId(index)) {
|
|
47
|
+
throw new Error(`A finalized record holds page ${pageId} at position ${index}.`);
|
|
48
|
+
}
|
|
49
|
+
if (index > 0 && isFirstRecordPage(page)) {
|
|
50
|
+
throw new Error(`A finalized record holds a second first page at ${pageId}.`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const rest = restEntries.map(({ page }) => page);
|
|
35
54
|
const events = [...first.events, ...rest.flatMap((page) => page.events)];
|
|
36
55
|
events.forEach((event, index) => {
|
|
37
56
|
if (index > 0 && events[index - 1].sequence >= event.sequence) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finalized-record.js","sourceRoot":"","sources":["../../src/sports/finalized-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"finalized-record.js","sourceRoot":"","sources":["../../src/sports/finalized-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAMxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,yBAAyB,CACvC,MAAgC,EAChC,QAOC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,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Y_PAGES, STAT_HISTORY_PAGE_SIZE } from '../constants/sports.js';\nimport type { GameStatEvent } from '../doc-schemas/game-stats.js';\nimport type {\n GameStatHistoryFirstPage,\n GameStatHistoryPage,\n} from '../doc-schemas/game-stat-history.js';\nimport { buildStatHistoryPageId } from '../ids/stat-event-ids.js';\nimport type { FinalizedGame } from './contribution.js';\nimport { replayGameStats } from './replay.js';\nimport type { AnySportAdapter } from './sport-adapter.js';\n\nexport type FinalizedRecordSnapshot = Omit<GameStatHistoryFirstPage, 'events' | 'pageCount'>;\n\nexport interface FinalizedRecordPage {\n readonly pageId: string;\n readonly page: GameStatHistoryPage;\n}\n\nexport function buildFinalizedRecordPages(\n events: readonly GameStatEvent[],\n snapshot: Pick<\n FinalizedGame,\n | 'leagueType'\n | 'teamIds'\n | 'rosterPlayerIds'\n | 'absentRosterPlayerIds'\n | 'nonScoringRosterPlayerIds'\n >,\n): FinalizedRecordPage[] {\n const ordered = [...events].sort((left, right) => left.sequence - right.sequence);\n const pageCount = Math.max(1, Math.ceil(ordered.length / STAT_HISTORY_PAGE_SIZE));\n if (pageCount > MAX_STAT_HISTORY_PAGES) {\n throw new RangeError(\n `A finalized record holds at most ${MAX_STAT_HISTORY_PAGES} pages; ${ordered.length} events need ${pageCount}.`,\n );\n }\n const pages: FinalizedRecordPage[] = [];\n for (let index = 0; index < pageCount; index += 1) {\n const slice = ordered.slice(\n index * STAT_HISTORY_PAGE_SIZE,\n (index + 1) * STAT_HISTORY_PAGE_SIZE,\n );\n const page: GameStatHistoryPage =\n index === 0\n ? {\n events: slice,\n pageCount,\n leagueType: snapshot.leagueType,\n teamIds: [...snapshot.teamIds],\n rosterPlayerIds: [...snapshot.rosterPlayerIds],\n absentRosterPlayerIds: [...snapshot.absentRosterPlayerIds],\n nonScoringRosterPlayerIds: [...snapshot.nonScoringRosterPlayerIds],\n }\n : { events: slice };\n pages.push({ pageId: buildStatHistoryPageId(index), page });\n }\n return pages;\n}\n\nexport function isFirstRecordPage(page: GameStatHistoryPage): page is GameStatHistoryFirstPage {\n return 'pageCount' in page;\n}\n\n// The pages as the record's collection lists them, in id order. They are one whole record only as\n// the exact set: the first page at `page_0000`, then a continuation page at each next id, as many in\n// all as the first page counts.\nexport function readFinalizedRecord(pages: readonly FinalizedRecordPage[]): {\n readonly snapshot: FinalizedRecordSnapshot;\n readonly events: GameStatEvent[];\n} {\n if (pages.length > MAX_STAT_HISTORY_PAGES) {\n throw new Error(`A finalized record holds at most ${MAX_STAT_HISTORY_PAGES} pages.`);\n }\n const [firstEntry, ...restEntries] = pages;\n const first = firstEntry?.page;\n if (first === undefined || !isFirstRecordPage(first))\n throw new Error('A finalized record starts with its first page.');\n if (first.pageCount !== pages.length) {\n throw new Error(`A finalized record of ${first.pageCount} pages was read as ${pages.length}.`);\n }\n pages.forEach(({ pageId, page }, index) => {\n if (pageId !== buildStatHistoryPageId(index)) {\n throw new Error(`A finalized record holds page ${pageId} at position ${index}.`);\n }\n if (index > 0 && isFirstRecordPage(page)) {\n throw new Error(`A finalized record holds a second first page at ${pageId}.`);\n }\n });\n const rest = restEntries.map(({ page }) => page);\n const events = [...first.events, ...rest.flatMap((page) => page.events)];\n events.forEach((event, index) => {\n if (index > 0 && (events[index - 1] as GameStatEvent).sequence >= event.sequence) {\n throw new Error(`A finalized record holds event ${event.eventId} out of sequence.`);\n }\n });\n const snapshot: FinalizedRecordSnapshot = {\n leagueType: first.leagueType,\n teamIds: first.teamIds,\n rosterPlayerIds: first.rosterPlayerIds,\n absentRosterPlayerIds: first.absentRosterPlayerIds,\n nonScoringRosterPlayerIds: first.nonScoringRosterPlayerIds,\n };\n return { snapshot, events };\n}\n\nexport function finalizedGameFromRecord(\n adapter: AnySportAdapter,\n pages: readonly FinalizedRecordPage[],\n): FinalizedGame {\n const { snapshot, events } = readFinalizedRecord(pages);\n return {\n leagueType: snapshot.leagueType,\n teamIds: snapshot.teamIds,\n stats: replayGameStats(adapter, snapshot, events),\n rosterPlayerIds: snapshot.rosterPlayerIds,\n absentRosterPlayerIds: snapshot.absentRosterPlayerIds,\n nonScoringRosterPlayerIds: snapshot.nonScoringRosterPlayerIds,\n };\n}\n"]}
|
package/dist/types/audit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SystemRole } from './unions.js';
|
|
2
2
|
import { CAPTAIN_TEAM_ROLES } from './unions.js';
|
|
3
|
-
export declare const AUDIT_EVENT_TYPE_KEYS: readonly ["user.accountRegistered", "user.displayNameChanged", "user.abandonedRegistrationDeleted", "user.signedIn", "user.passwordResetCompleted", "user.accountBanned", "user.accountUnbanned", "admin.systemRoleGranted", "admin.systemRoleRevoked", "admin.systemRoleClaimSynced", "appConfig.updated", "landingPage.updated", "league.created", "league.updated", "league.statusChanged", "league.modeSwitched", "waiverTemplate.created", "waiverTemplate.versionPublished", "waiverTemplate.retired", "waiverTemplate.deleted", "gameLocation.created", "gameLocation.updated", "gameLocation.deleted", "picture.added", "picture.replaced", "picture.moved", "picture.featuredChanged", "picture.removed", "award.created", "award.badgeReplaced", "award.deleted", "award.granted", "award.revoked", "hardwareLoanContract.created", "hardwareLoanContract.signed", "hardwareLoanContract.returned", "hardwareLoanContract.deleted", "leagueTeam.created", "ghostPlayer.created", "teamRoster.syncRetried", "teamMembership.roleChanged", "leagueTeam.captainChanged", "leagueTeam.updated", "leagueTeamContact.updated", "teamMembership.removed", "ghostPlayer.removed", "ghostPlayer.linked", "ghostPlayer.closedLeagueLinked", "leagueTeam.deleted", "ghostPlayer.removalStopped", "teamInvitation.created", "teamInvitation.cancelled", "teamInvitation.accepted", "teamInvitation.rejected", "teamJoinRequest.created", "teamJoinRequest.cancelled", "teamJoinRequest.accepted", "teamJoinRequest.rejected", "leagueFreeAgent.created", "leagueFreeAgent.deleted", "leagueFreeAgent.assigned", "signedWaiver.created", "scheduleWeek.created", "scheduleWeek.updated", "sportGame.created", "sportGame.updated", "sportGame.deleted", "sportGame.statEventsRejected", "sportGame.absenceChanged", "sportGame.memoUpdated", "sportGame.jumpBallChanged", "sportGame.finalized", "sportGame.reopened", "sportGame.statsCorrected", "sportGame.statsRecalculated", "stats.aggregateRecalculated", "stats.historicalStatsUpdated", "stats.validationRun", "stats.validationReportDeleted", "stats.unrosteredStatLineResolved", "adminNotification.archived", "adminNotification.archiveAllRequested", "system.manualIntervention", "migrationAction.pageRun", "migrationAction.writesCommitted", "migrationAction.controlRecorded", "migrationAction.checkpointRecorded", "migrationConsole.cutoverRecorded"];
|
|
3
|
+
export declare const AUDIT_EVENT_TYPE_KEYS: readonly ["user.accountRegistered", "user.displayNameChanged", "user.abandonedRegistrationDeleted", "user.signedIn", "user.passwordResetCompleted", "user.accountBanned", "user.accountUnbanned", "admin.systemRoleGranted", "admin.systemRoleRevoked", "admin.systemRoleClaimSynced", "appConfig.updated", "landingPage.updated", "league.created", "league.updated", "league.statusChanged", "league.modeSwitched", "waiverTemplate.created", "waiverTemplate.versionPublished", "waiverTemplate.retired", "waiverTemplate.deleted", "gameLocation.created", "gameLocation.updated", "gameLocation.deleted", "picture.added", "picture.replaced", "picture.moved", "picture.featuredChanged", "picture.removed", "award.created", "award.badgeReplaced", "award.deleted", "award.granted", "award.revoked", "award.groupDecisionOpened", "hardwareLoanContract.created", "hardwareLoanContract.signed", "hardwareLoanContract.returned", "hardwareLoanContract.deleted", "leagueTeam.created", "ghostPlayer.created", "teamRoster.syncRetried", "teamMembership.roleChanged", "leagueTeam.captainChanged", "leagueTeam.updated", "leagueTeamContact.updated", "teamMembership.removed", "ghostPlayer.removed", "ghostPlayer.linked", "ghostPlayer.closedLeagueLinked", "leagueTeam.deleted", "ghostPlayer.removalStopped", "teamInvitation.created", "teamInvitation.cancelled", "teamInvitation.accepted", "teamInvitation.rejected", "teamJoinRequest.created", "teamJoinRequest.cancelled", "teamJoinRequest.accepted", "teamJoinRequest.rejected", "leagueFreeAgent.created", "leagueFreeAgent.deleted", "leagueFreeAgent.assigned", "signedWaiver.created", "scheduleWeek.created", "scheduleWeek.updated", "sportGame.created", "sportGame.updated", "sportGame.deleted", "sportGame.statEventsRejected", "sportGame.absenceChanged", "sportGame.memoUpdated", "sportGame.jumpBallChanged", "sportGame.finalized", "sportGame.reopened", "sportGame.statsCorrected", "sportGame.statsRecalculated", "stats.aggregateRecalculated", "stats.historicalStatsUpdated", "stats.validationRun", "stats.validationReportDeleted", "stats.unrosteredStatLineResolved", "adminNotification.archived", "adminNotification.archiveAllRequested", "system.manualIntervention", "migrationAction.pageRun", "migrationAction.writesCommitted", "migrationAction.controlRecorded", "migrationAction.checkpointRecorded", "migrationConsole.cutoverRecorded"];
|
|
4
4
|
export type AuditEventType = (typeof AUDIT_EVENT_TYPE_KEYS)[number];
|
|
5
5
|
export declare const GHOST_LINK_AUDIT_EVENT_TYPE_KEYS: readonly ["ghostPlayer.linked", "ghostPlayer.closedLeagueLinked"];
|
|
6
6
|
export type GhostLinkAuditEventType = (typeof GHOST_LINK_AUDIT_EVENT_TYPE_KEYS)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/types/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/types/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,eAAO,MAAM,qBAAqB,uzEA0FxB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,eAAO,MAAM,gCAAgC,mEAGC,CAAC;AAC/C,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,gCAAgC,CAAC,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 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/types/audit.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,wBAAwB;IACxB,yBAAyB;IACzB,mCAAmC;IACnC,eAAe;IACf,6BAA6B;IAC7B,oBAAoB;IACpB,sBAAsB;IACtB,yBAAyB;IACzB,yBAAyB;IACzB,6BAA6B;IAC7B,mBAAmB;IACnB,qBAAqB;IACrB,gBAAgB;IAChB,gBAAgB;IAChB,sBAAsB;IACtB,qBAAqB;IACrB,wBAAwB;IACxB,iCAAiC;IACjC,wBAAwB;IACxB,wBAAwB;IACxB,sBAAsB;IACtB,sBAAsB;IACtB,sBAAsB;IACtB,eAAe;IACf,kBAAkB;IAClB,eAAe;IACf,yBAAyB;IACzB,iBAAiB;IACjB,eAAe;IACf,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,eAAe;IACf,8BAA8B;IAC9B,6BAA6B;IAC7B,+BAA+B;IAC/B,8BAA8B;IAC9B,oBAAoB;IACpB,qBAAqB;IACrB,wBAAwB;IACxB,4BAA4B;IAC5B,2BAA2B;IAC3B,oBAAoB;IACpB,2BAA2B;IAC3B,wBAAwB;IACxB,qBAAqB;IACrB,oBAAoB;IACpB,gCAAgC;IAChC,oBAAoB;IACpB,4BAA4B;IAC5B,wBAAwB;IACxB,0BAA0B;IAC1B,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,2BAA2B;IAC3B,0BAA0B;IAC1B,0BAA0B;IAC1B,yBAAyB;IACzB,yBAAyB;IACzB,0BAA0B;IAC1B,sBAAsB;IACtB,sBAAsB;IACtB,sBAAsB;IACtB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,0BAA0B;IAC1B,uBAAuB;IACvB,2BAA2B;IAC3B,qBAAqB;IACrB,oBAAoB;IACpB,0BAA0B;IAC1B,6BAA6B;IAC7B,6BAA6B;IAC7B,8BAA8B;IAC9B,qBAAqB;IACrB,+BAA+B;IAC/B,kCAAkC;IAClC,4BAA4B;IAC5B,uCAAuC;IACvC,2BAA2B;IAC3B,yBAAyB;IACzB,iCAAiC;IACjC,iCAAiC;IACjC,oCAAoC;IACpC,kCAAkC;CAC1B,CAAC;AAGX,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,oBAAoB;IACpB,gCAAgC;CACY,CAAC;AAG/C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM;IACN,cAAc;IACd,aAAa;IACb,eAAe;IACf,QAAQ;CACA,CAAC;AAGX,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,aAAa;IACb,eAAe;CAC6B,CAAC;AAG/C,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,MAAM;IACN,cAAc;IACd,QAAQ;CACoC,CAAC;AAG/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,WAAW,CAAU,CAAC;AAmB1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,SAAS,CAAU,CAAC","sourcesContent":["import type { SystemRole } from './unions.js';\nimport { CAPTAIN_TEAM_ROLES } from './unions.js';\n\nexport const AUDIT_EVENT_TYPE_KEYS = [\n 'user.accountRegistered',\n 'user.displayNameChanged',\n 'user.abandonedRegistrationDeleted',\n 'user.signedIn',\n 'user.passwordResetCompleted',\n 'user.accountBanned',\n 'user.accountUnbanned',\n 'admin.systemRoleGranted',\n 'admin.systemRoleRevoked',\n 'admin.systemRoleClaimSynced',\n 'appConfig.updated',\n 'landingPage.updated',\n 'league.created',\n 'league.updated',\n 'league.statusChanged',\n 'league.modeSwitched',\n 'waiverTemplate.created',\n 'waiverTemplate.versionPublished',\n 'waiverTemplate.retired',\n 'waiverTemplate.deleted',\n 'gameLocation.created',\n 'gameLocation.updated',\n 'gameLocation.deleted',\n 'picture.added',\n 'picture.replaced',\n 'picture.moved',\n 'picture.featuredChanged',\n 'picture.removed',\n 'award.created',\n 'award.badgeReplaced',\n 'award.deleted',\n 'award.granted',\n 'award.revoked',\n 'hardwareLoanContract.created',\n 'hardwareLoanContract.signed',\n 'hardwareLoanContract.returned',\n 'hardwareLoanContract.deleted',\n 'leagueTeam.created',\n 'ghostPlayer.created',\n 'teamRoster.syncRetried',\n 'teamMembership.roleChanged',\n 'leagueTeam.captainChanged',\n 'leagueTeam.updated',\n 'leagueTeamContact.updated',\n 'teamMembership.removed',\n 'ghostPlayer.removed',\n 'ghostPlayer.linked',\n 'ghostPlayer.closedLeagueLinked',\n 'leagueTeam.deleted',\n 'ghostPlayer.removalStopped',\n 'teamInvitation.created',\n 'teamInvitation.cancelled',\n 'teamInvitation.accepted',\n 'teamInvitation.rejected',\n 'teamJoinRequest.created',\n 'teamJoinRequest.cancelled',\n 'teamJoinRequest.accepted',\n 'teamJoinRequest.rejected',\n 'leagueFreeAgent.created',\n 'leagueFreeAgent.deleted',\n 'leagueFreeAgent.assigned',\n 'signedWaiver.created',\n 'scheduleWeek.created',\n 'scheduleWeek.updated',\n 'sportGame.created',\n 'sportGame.updated',\n 'sportGame.deleted',\n 'sportGame.statEventsRejected',\n 'sportGame.absenceChanged',\n 'sportGame.memoUpdated',\n 'sportGame.jumpBallChanged',\n 'sportGame.finalized',\n 'sportGame.reopened',\n 'sportGame.statsCorrected',\n 'sportGame.statsRecalculated',\n 'stats.aggregateRecalculated',\n 'stats.historicalStatsUpdated',\n 'stats.validationRun',\n 'stats.validationReportDeleted',\n 'stats.unrosteredStatLineResolved',\n 'adminNotification.archived',\n 'adminNotification.archiveAllRequested',\n 'system.manualIntervention',\n 'migrationAction.pageRun',\n 'migrationAction.writesCommitted',\n 'migrationAction.controlRecorded',\n 'migrationAction.checkpointRecorded',\n 'migrationConsole.cutoverRecorded',\n] as const;\nexport type AuditEventType = (typeof AUDIT_EVENT_TYPE_KEYS)[number];\n\nexport const GHOST_LINK_AUDIT_EVENT_TYPE_KEYS = [\n 'ghostPlayer.linked',\n 'ghostPlayer.closedLeagueLinked',\n] as const satisfies readonly AuditEventType[];\nexport type GhostLinkAuditEventType = (typeof GHOST_LINK_AUDIT_EVENT_TYPE_KEYS)[number];\n\nexport const AUDIT_ACTOR_MODE_KEYS = [\n 'user',\n 'teammateUser',\n 'adminReview',\n 'adminOverride',\n 'system',\n] as const;\nexport type AuditActorMode = (typeof AUDIT_ACTOR_MODE_KEYS)[number];\n\nexport const AUDIT_ADMIN_ACTOR_MODE_KEYS = [\n 'adminReview',\n 'adminOverride',\n] as const satisfies readonly AuditActorMode[];\nexport type AuditAdminActorMode = (typeof AUDIT_ADMIN_ACTOR_MODE_KEYS)[number];\n\nexport const AUDIT_NON_ADMIN_ACTOR_MODE_KEYS = [\n 'user',\n 'teammateUser',\n 'system',\n] as const satisfies readonly AuditActorMode[];\nexport type AuditNonAdminActorMode = (typeof AUDIT_NON_ADMIN_ACTOR_MODE_KEYS)[number];\n\nexport const AUDIT_SYSTEM_REASON_KEYS = ['trigger', 'scheduledJob', 'migration'] as const;\nexport type AuditSystemReason = (typeof AUDIT_SYSTEM_REASON_KEYS)[number];\n\nexport type CaptainTeamRole = (typeof CAPTAIN_TEAM_ROLES)[number];\n\nexport type AuditActor =\n | { uid: string | null; isAdmin: boolean; actorMode: AuditNonAdminActorMode; systemRole?: never }\n | {\n uid: string | null;\n isAdmin: boolean;\n actorMode: AuditAdminActorMode;\n systemRole: SystemRole;\n };\n\nexport interface AuditTarget {\n uid: string | null;\n ref: string | null;\n}\n\nexport const AUDIT_RESULT_KEYS = ['success', 'failure'] as const;\nexport type AuditResult = (typeof AUDIT_RESULT_KEYS)[number];\n"]}
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/types/audit.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,wBAAwB;IACxB,yBAAyB;IACzB,mCAAmC;IACnC,eAAe;IACf,6BAA6B;IAC7B,oBAAoB;IACpB,sBAAsB;I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AgC,GAAG;IAC9C,oBAAoB;IACpB,gCAAgC;CACY,CAAC;AAG/C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM;IACN,cAAc;IACd,aAAa;IACb,eAAe;IACf,QAAQ;CACA,CAAC;AAGX,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,aAAa;IACb,eAAe;CAC6B,CAAC;AAG/C,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,MAAM;IACN,cAAc;IACd,QAAQ;CACoC,CAAC;AAG/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,WAAW,CAAU,CAAC;AAmB1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,SAAS,CAAU,CAAC","sourcesContent":["import type { SystemRole } from './unions.js';\nimport { CAPTAIN_TEAM_ROLES } from './unions.js';\n\nexport const AUDIT_EVENT_TYPE_KEYS = [\n 'user.accountRegistered',\n 'user.displayNameChanged',\n 'user.abandonedRegistrationDeleted',\n 'user.signedIn',\n 'user.passwordResetCompleted',\n 'user.accountBanned',\n 'user.accountUnbanned',\n 'admin.systemRoleGranted',\n 'admin.systemRoleRevoked',\n 'admin.systemRoleClaimSynced',\n 'appConfig.updated',\n 'landingPage.updated',\n 'league.created',\n 'league.updated',\n 'league.statusChanged',\n 'league.modeSwitched',\n 'waiverTemplate.created',\n 'waiverTemplate.versionPublished',\n 'waiverTemplate.retired',\n 'waiverTemplate.deleted',\n 'gameLocation.created',\n 'gameLocation.updated',\n 'gameLocation.deleted',\n 'picture.added',\n 'picture.replaced',\n 'picture.moved',\n 'picture.featuredChanged',\n 'picture.removed',\n 'award.created',\n 'award.badgeReplaced',\n 'award.deleted',\n 'award.granted',\n 'award.revoked',\n 'award.groupDecisionOpened',\n 'hardwareLoanContract.created',\n 'hardwareLoanContract.signed',\n 'hardwareLoanContract.returned',\n 'hardwareLoanContract.deleted',\n 'leagueTeam.created',\n 'ghostPlayer.created',\n 'teamRoster.syncRetried',\n 'teamMembership.roleChanged',\n 'leagueTeam.captainChanged',\n 'leagueTeam.updated',\n 'leagueTeamContact.updated',\n 'teamMembership.removed',\n 'ghostPlayer.removed',\n 'ghostPlayer.linked',\n 'ghostPlayer.closedLeagueLinked',\n 'leagueTeam.deleted',\n 'ghostPlayer.removalStopped',\n 'teamInvitation.created',\n 'teamInvitation.cancelled',\n 'teamInvitation.accepted',\n 'teamInvitation.rejected',\n 'teamJoinRequest.created',\n 'teamJoinRequest.cancelled',\n 'teamJoinRequest.accepted',\n 'teamJoinRequest.rejected',\n 'leagueFreeAgent.created',\n 'leagueFreeAgent.deleted',\n 'leagueFreeAgent.assigned',\n 'signedWaiver.created',\n 'scheduleWeek.created',\n 'scheduleWeek.updated',\n 'sportGame.created',\n 'sportGame.updated',\n 'sportGame.deleted',\n 'sportGame.statEventsRejected',\n 'sportGame.absenceChanged',\n 'sportGame.memoUpdated',\n 'sportGame.jumpBallChanged',\n 'sportGame.finalized',\n 'sportGame.reopened',\n 'sportGame.statsCorrected',\n 'sportGame.statsRecalculated',\n 'stats.aggregateRecalculated',\n 'stats.historicalStatsUpdated',\n 'stats.validationRun',\n 'stats.validationReportDeleted',\n 'stats.unrosteredStatLineResolved',\n 'adminNotification.archived',\n 'adminNotification.archiveAllRequested',\n 'system.manualIntervention',\n 'migrationAction.pageRun',\n 'migrationAction.writesCommitted',\n 'migrationAction.controlRecorded',\n 'migrationAction.checkpointRecorded',\n 'migrationConsole.cutoverRecorded',\n] as const;\nexport type AuditEventType = (typeof AUDIT_EVENT_TYPE_KEYS)[number];\n\nexport const GHOST_LINK_AUDIT_EVENT_TYPE_KEYS = [\n 'ghostPlayer.linked',\n 'ghostPlayer.closedLeagueLinked',\n] as const satisfies readonly AuditEventType[];\nexport type GhostLinkAuditEventType = (typeof GHOST_LINK_AUDIT_EVENT_TYPE_KEYS)[number];\n\nexport const AUDIT_ACTOR_MODE_KEYS = [\n 'user',\n 'teammateUser',\n 'adminReview',\n 'adminOverride',\n 'system',\n] as const;\nexport type AuditActorMode = (typeof AUDIT_ACTOR_MODE_KEYS)[number];\n\nexport const AUDIT_ADMIN_ACTOR_MODE_KEYS = [\n 'adminReview',\n 'adminOverride',\n] as const satisfies readonly AuditActorMode[];\nexport type AuditAdminActorMode = (typeof AUDIT_ADMIN_ACTOR_MODE_KEYS)[number];\n\nexport const AUDIT_NON_ADMIN_ACTOR_MODE_KEYS = [\n 'user',\n 'teammateUser',\n 'system',\n] as const satisfies readonly AuditActorMode[];\nexport type AuditNonAdminActorMode = (typeof AUDIT_NON_ADMIN_ACTOR_MODE_KEYS)[number];\n\nexport const AUDIT_SYSTEM_REASON_KEYS = ['trigger', 'scheduledJob', 'migration'] as const;\nexport type AuditSystemReason = (typeof AUDIT_SYSTEM_REASON_KEYS)[number];\n\nexport type CaptainTeamRole = (typeof CAPTAIN_TEAM_ROLES)[number];\n\nexport type AuditActor =\n | { uid: string | null; isAdmin: boolean; actorMode: AuditNonAdminActorMode; systemRole?: never }\n | {\n uid: string | null;\n isAdmin: boolean;\n actorMode: AuditAdminActorMode;\n systemRole: SystemRole;\n };\n\nexport interface AuditTarget {\n uid: string | null;\n ref: string | null;\n}\n\nexport const AUDIT_RESULT_KEYS = ['success', 'failure'] as const;\nexport type AuditResult = (typeof AUDIT_RESULT_KEYS)[number];\n"]}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC"}
|
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './display-name.js';\nexport * from './app-config.js';\nexport * from './league-calendar.js';\nexport * from './team-creation.js';\nexport * from './account-status.js';\nexport * from './league-join-warning.js';\nexport * from './schedules.js';\nexport * from './team-member-actions.js';\nexport * from './league-mode.js';\nexport * from './league-joining.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC","sourcesContent":["export * from './display-name.js';\nexport * from './app-config.js';\nexport * from './league-calendar.js';\nexport * from './team-creation.js';\nexport * from './account-status.js';\nexport * from './league-join-warning.js';\nexport * from './schedules.js';\nexport * from './team-member-actions.js';\nexport * from './league-mode.js';\nexport * from './league-joining.js';\nexport * from './stats-operation-request.js';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"league-calendar.d.ts","sourceRoot":"","sources":["../../src/utils/league-calendar.ts"],"names":[],"mappings":"AAYA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpE;AAkCD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"league-calendar.d.ts","sourceRoot":"","sources":["../../src/utils/league-calendar.ts"],"names":[],"mappings":"AAYA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpE;AAkCD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAwBzE"}
|
|
@@ -55,6 +55,11 @@ export function leagueInstantOf(dayKey, timeOfDay) {
|
|
|
55
55
|
// The offset at the wall-clock reading taken as UTC is within a day of the right one; read again at
|
|
56
56
|
// the instant that offset gives, so a reading on the other side of a change settles on its own.
|
|
57
57
|
const firstGuess = wallClock - (leagueWallClockAsUtc(wallClock) - wallClock);
|
|
58
|
-
|
|
58
|
+
const instant = wallClock - (leagueWallClockAsUtc(firstGuess) - firstGuess);
|
|
59
|
+
// A reading the clocks skip forward over settles on another hour; only a real one reads back.
|
|
60
|
+
if (toLeagueDayKey(instant) !== dayKey || toLeagueTimeOfDay(instant) !== timeOfDay) {
|
|
61
|
+
throw new RangeError(`Not a time the league's clocks show: '${dayKey}' '${timeOfDay}'.`);
|
|
62
|
+
}
|
|
63
|
+
return instant;
|
|
59
64
|
}
|
|
60
65
|
//# sourceMappingURL=league-calendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"league-calendar.js","sourceRoot":"","sources":["../../src/utils/league-calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,0EAA0E;AAC1E,MAAM,iBAAiB,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;IACzD,QAAQ,EAAE,gBAAgB;IAC1B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;CACf,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEnC,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,iBAAiB,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,IAAY;IAC1D,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,MAAM,gBAAgB,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,UAAU,CAAC,yBAAyB,MAAM,IAAI,CAAC,CAAC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AAC;AACjB,CAAC","sourcesContent":["import { LEAGUE_TIME_ZONE } from '../constants/business.js';\n\n// `en-CA` formats a date as `YYYY-MM-DD`, the stored calendar-date shape.\nconst LEAGUE_DAY_FORMAT = new Intl.DateTimeFormat('en-CA', {\n timeZone: LEAGUE_TIME_ZONE,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n});\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\nexport function toLeagueDayKey(epochMs: number): string {\n return LEAGUE_DAY_FORMAT.format(new Date(epochMs));\n}\n\nexport function addCalendarDays(dayKey: string, days: number): string {\n const day = new Date(`${dayKey}T00:00:00.000Z`);\n if (Number.isNaN(day.getTime())) {\n throw new RangeError(`Not a calendar date: '${dayKey}'.`);\n }\n return new Date(day.getTime() + days * DAY_MS).toISOString().slice(0, 10);\n}\n\n// `h23` keeps midnight at hour 0.\nconst LEAGUE_WALL_CLOCK_FORMAT = new Intl.DateTimeFormat('en-US', {\n timeZone: LEAGUE_TIME_ZONE,\n hourCycle: 'h23',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n});\n\nconst CALENDAR_DAY_SHAPE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst TIME_OF_DAY_SHAPE = /^([01]\\d|2[0-3]):([0-5]\\d)$/;\n\nfunction leagueWallClockAsUtc(epochMs: number): number {\n const parts = Object.fromEntries(\n LEAGUE_WALL_CLOCK_FORMAT.formatToParts(new Date(epochMs)).map((part) => [\n part.type,\n part.value,\n ]),\n );\n return Date.UTC(\n Number(parts.year),\n Number(parts.month) - 1,\n Number(parts.day),\n Number(parts.hour),\n Number(parts.minute),\n Number(parts.second),\n );\n}\n\nexport function toLeagueTimeOfDay(epochMs: number): string {\n const wallClock = new Date(leagueWallClockAsUtc(epochMs));\n const hours = String(wallClock.getUTCHours()).padStart(2, '0');\n const minutes = String(wallClock.getUTCMinutes()).padStart(2, '0');\n return `${hours}:${minutes}`;\n}\n\nexport function leagueInstantOf(dayKey: string, timeOfDay: string): number {\n const day = CALENDAR_DAY_SHAPE.exec(dayKey);\n const time = TIME_OF_DAY_SHAPE.exec(timeOfDay);\n if (!day || !time)\n throw new RangeError(`Not a calendar day and time of day: '${dayKey}' '${timeOfDay}'.`);\n const wallClock = Date.UTC(\n Number(day[1]),\n Number(day[2]) - 1,\n Number(day[3]),\n Number(time[1]),\n Number(time[2]),\n );\n if (new Date(wallClock).toISOString().slice(0, 10) !== dayKey) {\n throw new RangeError(`Not a calendar day: '${dayKey}'.`);\n }\n // The offset at the wall-clock reading taken as UTC is within a day of the right one; read again at\n // the instant that offset gives, so a reading on the other side of a change settles on its own.\n const firstGuess = wallClock - (leagueWallClockAsUtc(wallClock) - wallClock);\n const instant = wallClock - (leagueWallClockAsUtc(firstGuess) - firstGuess);\n // A reading the clocks skip forward over settles on another hour; only a real one reads back.\n if (toLeagueDayKey(instant) !== dayKey || toLeagueTimeOfDay(instant) !== timeOfDay) {\n throw new RangeError(`Not a time the league's clocks show: '${dayKey}' '${timeOfDay}'.`);\n }\n return instant;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HistoricalStats } from '../doc-schemas/user-profile.js';
|
|
2
|
+
import type { GameStatsCorrectionTarget } from '../schemas/stats.js';
|
|
3
|
+
import type { SportKey } from '../types/sports.js';
|
|
4
|
+
export type StatsOperationRequest = {
|
|
5
|
+
kind: 'gameStatsCorrection';
|
|
6
|
+
scope: {
|
|
7
|
+
gameId: string;
|
|
8
|
+
};
|
|
9
|
+
targets?: readonly GameStatsCorrectionTarget[];
|
|
10
|
+
keepStored?: true;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'historicalStatsUpdate';
|
|
13
|
+
scope: {
|
|
14
|
+
userId: string;
|
|
15
|
+
sportKey: SportKey;
|
|
16
|
+
};
|
|
17
|
+
stats: HistoricalStats;
|
|
18
|
+
};
|
|
19
|
+
export declare function hashStatsOperationRequest(request: StatsOperationRequest): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=stats-operation-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats-operation-request.d.ts","sourceRoot":"","sources":["../../src/utils/stats-operation-request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,MAAM,qBAAqB,GAC7B;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAC/C,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB,GACD;IACE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;IAC9C,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAGN,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQzF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { canonicalize, hashPayload } from '@ttt-productions/edge-protocol-core';
|
|
2
|
+
// The same targets sent in another order are the same request.
|
|
3
|
+
export function hashStatsOperationRequest(request) {
|
|
4
|
+
if (request.kind !== 'gameStatsCorrection' || request.targets === undefined) {
|
|
5
|
+
return hashPayload(request);
|
|
6
|
+
}
|
|
7
|
+
const targets = [...request.targets].sort((left, right) => canonicalize(left) < canonicalize(right) ? -1 : 1);
|
|
8
|
+
return hashPayload({ ...request, targets });
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=stats-operation-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats-operation-request.js","sourceRoot":"","sources":["../../src/utils/stats-operation-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAmBhF,+DAA+D;AAC/D,MAAM,UAAU,yBAAyB,CAAC,OAA8B;IACtE,IAAI,OAAO,CAAC,IAAI,KAAK,qBAAqB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC5E,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACxD,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;IACF,OAAO,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import { canonicalize, hashPayload } from '@ttt-productions/edge-protocol-core';\nimport type { HistoricalStats } from '../doc-schemas/user-profile.js';\nimport type { GameStatsCorrectionTarget } from '../schemas/stats.js';\nimport type { SportKey } from '../types/sports.js';\n\n// What a held operation is bound to: its kind, scope, and values, never its reason.\nexport type StatsOperationRequest =\n | {\n kind: 'gameStatsCorrection';\n scope: { gameId: string };\n targets?: readonly GameStatsCorrectionTarget[];\n keepStored?: true;\n }\n | {\n kind: 'historicalStatsUpdate';\n scope: { userId: string; sportKey: SportKey };\n stats: HistoricalStats;\n };\n\n// The same targets sent in another order are the same request.\nexport function hashStatsOperationRequest(request: StatsOperationRequest): Promise<string> {\n if (request.kind !== 'gameStatsCorrection' || request.targets === undefined) {\n return hashPayload(request);\n }\n const targets = [...request.targets].sort((left, right) =>\n canonicalize(left) < canonicalize(right) ? -1 : 1,\n );\n return hashPayload({ ...request, targets });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/q-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "Core types, Firestore path constants, zod schemas, and shared constants for Q-Sports",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"test": "vitest run"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
+
"@ttt-productions/edge-protocol-core": "^0.1.15",
|
|
80
81
|
"@ttt-productions/input-format-core": "^0.1.4",
|
|
81
82
|
"@ttt-productions/media-schemas": "^0.14.14",
|
|
82
83
|
"@ttt-productions/notification-core": "^0.15.22",
|