feat: data-driven page.server.ts with config merge logic (#36) #43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "36-data-driven-page-server"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Loads
t.contract_configandp.contract_overridesfrom the database in+page.server.ts, merges team defaults with player overrides via a pure function, and passes the merged config to the page for data-driven rendering.Changes
src/lib/contract-config.ts(NEW) — PuremergeContractConfig()function with full TypeScript interfaces (ContractConfig,ContractOverrides,MergedConfig,Tournament,Practice,PaymentSchedule,ContractSections). Implements all merge rules: monthly_fee cascade, tournament filtering by ID, practice/payment replacement, section shallow merge, note passthrough.src/lib/types.ts— Re-exports all config types fromcontract-config.ts. Addscontract_configandcontract_overridesfields to thePlayerinterface.src/routes/contract/[token]/+page.server.ts— Updated SQL SELECT to includet.contract_configandp.contract_overrides. CallsmergeContractConfig()and passesconfigto the page. Backwards compatible: null config triggers hardcoded fallback.tests/contract-config.test.ts(NEW) — 16 unit tests covering: null team config, no overrides passthrough, monthly_fee cascade (player > override > team default > 200), tournament filtering, practice/payment replacement, section shallow merge, note passthrough, combined overrides.Test Plan
npm test— 30 tests pass (16 new + 14 existing)npm run check— no new errors (12 pre-existing errors in db.ts/minio.ts/sign endpoint are unrelated)Review Checklist
npm test— 30/30)npm run check)Related Notes
Related
Closes #36
QA Review
Scope Check
Code Quality
contract-config.ts -- Clean pure function. All merge rules from the spec are implemented correctly:
types.ts -- Re-exports are clean.
import()type syntax for the two new Player fields avoids circular dependency issues.+page.server.ts -- SQL updated correctly.
t.contract_configadded from teams table. Merge called with correct argument order.configpassed to page return.Nit
p.contract_overridesis explicitly selected in the SQL, butp.*already includes all player columns. Not a bug -- Postgres handles it fine and it documents intent. No action needed.Tests
npm run checkhas no new errors (12 pre-existing in db.ts/minio.ts/sign)SOP Compliance
36-data-driven-page-server-- correct formatCloses #36presentVERDICT: APPROVED