Skip to content

feat: expose save metadata via Story API (#97)#99

Merged
rohal12 merged 1 commit intomainfrom
feat/save-metadata-api-97
Mar 22, 2026
Merged

feat: expose save metadata via Story API (#97)#99
rohal12 merged 1 commit intomainfrom
feat/save-metadata-api-97

Conversation

@rohal12
Copy link
Owner

@rohal12 rohal12 commented Mar 22, 2026

Summary

  • save(slot?, custom?): Extended to accept custom metadata (e.g. { day: 3, phase: 'morning' }) that is stored alongside the save and merged on overwrite
  • getSaveInfo(slot?): New async method returning SaveInfo (slot, title, passage, createdAt, updatedAt, custom) for a specific slot
  • listSaves(): New async method returning SaveInfo[] for all known saves (default + named)
  • deleteSave(slot?): New method to delete a save and update knownSaves cache
  • SaveInfo type added to types/index.d.ts and pkg/types/index.d.ts

Games building custom save/load UIs can now display slot metadata like "Day 12 — Work Phase — saved 3:42 PM" without maintaining a parallel persistence layer.

Test plan

  • All 891 tests pass (12 new, no regressions)
  • New tests: getSlotSaveInfo (null/default/named/custom), listSlotSaves (empty/all), deleteSlotSave (named/default/populate-cleanup/no-op), quickSave custom metadata (new/merge)
  • TypeScript compiles cleanly (tsc --noEmit)

Closes #97

🤖 Generated with Claude Code

Add getSaveInfo(), listSaves(), deleteSave() to the Story API, and
extend save() to accept custom metadata. Games building custom save/load
UIs can now read slot timestamps, passage names, and custom fields
without maintaining a parallel localStorage store.

- SaveInfo type: slot, title, passage, createdAt, updatedAt, custom
- save(slot?, custom?) merges custom fields into save metadata
- getSaveInfo(slot?) returns metadata for a single slot
- listSaves() returns metadata for all known slots
- deleteSave(slot?) removes a save and updates knownSaves
- overwriteSave now preserves+merges custom metadata on update
- deleteSlotSave removes from slot index so populateKnownSaves stays accurate

Closes #97

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.92% 2401 / 3042
🔵 Statements 78.02% 2627 / 3367
🔵 Functions 70.91% 434 / 612
🔵 Branches 73.58% 1312 / 1783
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/store.ts 85.11% 76.4% 79.41% 87.08% 86, 120, 263-264, 327, 336-339, 370-375, 467, 501, 524-527, 541, 545-548, 560-584
src/story-api.ts 7.47% 0% 13.11% 7.92% 113-315, 342-347, 359-394
src/saves/save-manager.ts 92.74% 86.2% 93.93% 94.08% 372, 447-460
src/saves/types.ts 97.87% 98.38% 100% 100% 97
Generated in workflow #164 for commit c1569af by the Vitest Coverage Report Action

@rohal12 rohal12 merged commit bc2cef7 into main Mar 22, 2026
4 checks passed
@rohal12 rohal12 deleted the feat/save-metadata-api-97 branch March 22, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: expose save metadata (timestamp, passage, custom fields) via Story API

1 participant