@ttt-productions/q-core 0.1.55 → 0.1.57

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.
@@ -0,0 +1,3 @@
1
+ export declare const ANALYTICS_EVENT_NAMES: readonly ["page_view", "sign_up", "login", "game_finalized", "stat_recorded", "ghost_linked", "team_joined", "free_agent_signed_up", "free_agent_withdrawn"];
2
+ export type AnalyticsEventName = (typeof ANALYTICS_EVENT_NAMES)[number];
3
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/constants/analytics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,8JAUxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export const ANALYTICS_EVENT_NAMES = [
2
+ 'page_view',
3
+ 'sign_up',
4
+ 'login',
5
+ 'game_finalized',
6
+ 'stat_recorded',
7
+ 'ghost_linked',
8
+ 'team_joined',
9
+ 'free_agent_signed_up',
10
+ 'free_agent_withdrawn',
11
+ ];
12
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/constants/analytics.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW;IACX,SAAS;IACT,OAAO;IACP,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,aAAa;IACb,sBAAsB;IACtB,sBAAsB;CACd,CAAC","sourcesContent":["export const ANALYTICS_EVENT_NAMES = [\n 'page_view',\n 'sign_up',\n 'login',\n 'game_finalized',\n 'stat_recorded',\n 'ghost_linked',\n 'team_joined',\n 'free_agent_signed_up',\n 'free_agent_withdrawn',\n] as const;\n\nexport type AnalyticsEventName = (typeof ANALYTICS_EVENT_NAMES)[number];\n"]}
@@ -8,4 +8,5 @@ export * from './deployment.js';
8
8
  export * from './admin-views.js';
9
9
  export * from './pagination.js';
10
10
  export * from './text-fields.js';
11
+ export * from './analytics.js';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -8,4 +8,5 @@ export * from './deployment.js';
8
8
  export * from './admin-views.js';
9
9
  export * from './pagination.js';
10
10
  export * from './text-fields.js';
11
+ export * from './analytics.js';
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './business.js';\nexport * from './sports.js';\nexport * from './storage-keys.js';\nexport * from './media.js';\nexport * from './telemetry.js';\nexport * from './scheduled-jobs.js';\nexport * from './deployment.js';\nexport * from './admin-views.js';\nexport * from './pagination.js';\nexport * from './text-fields.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './business.js';\nexport * from './sports.js';\nexport * from './storage-keys.js';\nexport * from './media.js';\nexport * from './telemetry.js';\nexport * from './scheduled-jobs.js';\nexport * from './deployment.js';\nexport * from './admin-views.js';\nexport * from './pagination.js';\nexport * from './text-fields.js';\nexport * from './analytics.js';\n"]}
@@ -1,8 +1,10 @@
1
1
  import type { GameStatEvent } from '../doc-schemas/game-stats.js';
2
- import type { GameStatHistoryRecord } from '../doc-schemas/game-stat-history.js';
2
+ import { type GameStatHistoryRecord } from '../doc-schemas/game-stat-history.js';
3
3
  import type { FinalizedGame } from './contribution.js';
4
4
  import type { AnySportAdapter } from './sport-adapter.js';
5
5
  export type FinalizedRecordSnapshot = Omit<GameStatHistoryRecord, 'events'>;
6
+ export type FinalizedRecordFound = GameStatHistoryRecord | 'missing' | 'damaged';
7
+ export declare function parseFinalizedRecord(stored: unknown): FinalizedRecordFound;
6
8
  export declare function buildFinalizedRecord(events: readonly GameStatEvent[], snapshot: Pick<FinalizedGame, 'leagueType' | 'teamIds' | 'rosterPlayerIds' | 'absentRosterPlayerIds' | 'nonScoringRosterPlayerIds'>): GameStatHistoryRecord;
7
9
  export declare function finalizedGameFromRecord(adapter: AnySportAdapter, record: GameStatHistoryRecord): FinalizedGame;
8
10
  //# 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,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AAE5E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,QAAQ,EAAE,IAAI,CACZ,aAAa,EACX,YAAY,GACZ,SAAS,GACT,iBAAiB,GACjB,uBAAuB,GACvB,2BAA2B,CAC9B,GACA,qBAAqB,CAcvB;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,qBAAqB,GAC5B,aAAa,CAUf"}
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,EAEL,KAAK,qBAAqB,EAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AAG5E,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEjF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,oBAAoB,CAI1E;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,QAAQ,EAAE,IAAI,CACZ,aAAa,EACX,YAAY,GACZ,SAAS,GACT,iBAAiB,GACjB,uBAAuB,GACvB,2BAA2B,CAC9B,GACA,qBAAqB,CAcvB;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,qBAAqB,GAC5B,aAAa,CAUf"}
@@ -1,5 +1,12 @@
1
1
  import { MAX_STAT_EVENTS_PER_GAME } from '../constants/business.js';
2
+ import { GameStatHistoryRecordSchema, } from '../doc-schemas/game-stat-history.js';
2
3
  import { replayGameStats } from './replay.js';
4
+ export function parseFinalizedRecord(stored) {
5
+ if (stored === null || stored === undefined)
6
+ return 'missing';
7
+ const parsed = GameStatHistoryRecordSchema.safeParse(stored);
8
+ return parsed.success ? parsed.data : 'damaged';
9
+ }
3
10
  export function buildFinalizedRecord(events, snapshot) {
4
11
  if (events.length > MAX_STAT_EVENTS_PER_GAME) {
5
12
  throw new RangeError(`A finalized record holds at most ${MAX_STAT_EVENTS_PER_GAME} events, not ${events.length}.`);
@@ -1 +1 @@
1
- {"version":3,"file":"finalized-record.js","sourceRoot":"","sources":["../../src/sports/finalized-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAIpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAK9C,MAAM,UAAU,oBAAoB,CAClC,MAAgC,EAChC,QAOC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,wBAAwB,EAAE,CAAC;QAC7C,MAAM,IAAI,UAAU,CAClB,oCAAoC,wBAAwB,gBAAgB,MAAM,CAAC,MAAM,GAAG,CAC7F,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACzE,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC9B,eAAe,EAAE,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;QAC9C,qBAAqB,EAAE,CAAC,GAAG,QAAQ,CAAC,qBAAqB,CAAC;QAC1D,yBAAyB,EAAE,CAAC,GAAG,QAAQ,CAAC,yBAAyB,CAAC;KACnE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,OAAwB,EACxB,MAA6B;IAE7B,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC;IACvC,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC;QACjD,eAAe,EAAE,QAAQ,CAAC,eAAe;QACzC,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB;QACrD,yBAAyB,EAAE,QAAQ,CAAC,yBAAyB;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { MAX_STAT_EVENTS_PER_GAME } from '../constants/business.js';\nimport type { GameStatEvent } from '../doc-schemas/game-stats.js';\nimport type { GameStatHistoryRecord } from '../doc-schemas/game-stat-history.js';\nimport type { FinalizedGame } from './contribution.js';\nimport { replayGameStats } from './replay.js';\nimport type { AnySportAdapter } from './sport-adapter.js';\n\nexport type FinalizedRecordSnapshot = Omit<GameStatHistoryRecord, 'events'>;\n\nexport function buildFinalizedRecord(\n events: readonly GameStatEvent[],\n snapshot: Pick<\n FinalizedGame,\n | 'leagueType'\n | 'teamIds'\n | 'rosterPlayerIds'\n | 'absentRosterPlayerIds'\n | 'nonScoringRosterPlayerIds'\n >,\n): GameStatHistoryRecord {\n if (events.length > MAX_STAT_EVENTS_PER_GAME) {\n throw new RangeError(\n `A finalized record holds at most ${MAX_STAT_EVENTS_PER_GAME} events, not ${events.length}.`,\n );\n }\n return {\n events: [...events].sort((left, right) => left.sequence - right.sequence),\n leagueType: snapshot.leagueType,\n teamIds: [...snapshot.teamIds],\n rosterPlayerIds: [...snapshot.rosterPlayerIds],\n absentRosterPlayerIds: [...snapshot.absentRosterPlayerIds],\n nonScoringRosterPlayerIds: [...snapshot.nonScoringRosterPlayerIds],\n };\n}\n\nexport function finalizedGameFromRecord(\n adapter: AnySportAdapter,\n record: GameStatHistoryRecord,\n): FinalizedGame {\n const { events, ...snapshot } = record;\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"]}
1
+ {"version":3,"file":"finalized-record.js","sourceRoot":"","sources":["../../src/sports/finalized-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EACL,2BAA2B,GAE5B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAClD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9D,MAAM,MAAM,GAAG,2BAA2B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,MAAM,CAA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port type { GameStatEvent } from '../doc-schemas/game-stats.js';\nimport {\n GameStatHistoryRecordSchema,\n type GameStatHistoryRecord,\n} from '../doc-schemas/game-stat-history.js';\nimport type { FinalizedGame } from './contribution.js';\nimport { replayGameStats } from './replay.js';\nimport type { AnySportAdapter } from './sport-adapter.js';\n\nexport type FinalizedRecordSnapshot = Omit<GameStatHistoryRecord, 'events'>;\n\n// A stored record read back: none stored is 'missing', and one its schema refuses is 'damaged'.\nexport type FinalizedRecordFound = GameStatHistoryRecord | 'missing' | 'damaged';\n\nexport function parseFinalizedRecord(stored: unknown): FinalizedRecordFound {\n if (stored === null || stored === undefined) return 'missing';\n const parsed = GameStatHistoryRecordSchema.safeParse(stored);\n return parsed.success ? parsed.data : 'damaged';\n}\n\nexport function buildFinalizedRecord(\n events: readonly GameStatEvent[],\n snapshot: Pick<\n FinalizedGame,\n | 'leagueType'\n | 'teamIds'\n | 'rosterPlayerIds'\n | 'absentRosterPlayerIds'\n | 'nonScoringRosterPlayerIds'\n >,\n): GameStatHistoryRecord {\n if (events.length > MAX_STAT_EVENTS_PER_GAME) {\n throw new RangeError(\n `A finalized record holds at most ${MAX_STAT_EVENTS_PER_GAME} events, not ${events.length}.`,\n );\n }\n return {\n events: [...events].sort((left, right) => left.sequence - right.sequence),\n leagueType: snapshot.leagueType,\n teamIds: [...snapshot.teamIds],\n rosterPlayerIds: [...snapshot.rosterPlayerIds],\n absentRosterPlayerIds: [...snapshot.absentRosterPlayerIds],\n nonScoringRosterPlayerIds: [...snapshot.nonScoringRosterPlayerIds],\n };\n}\n\nexport function finalizedGameFromRecord(\n adapter: AnySportAdapter,\n record: GameStatHistoryRecord,\n): FinalizedGame {\n const { events, ...snapshot } = record;\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/q-core",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "Core types, Firestore path constants, zod schemas, and shared constants for Q-Sports",
5
5
  "repository": {
6
6
  "type": "git",