diff options
| author | Bobby <[email protected]> | 2026-04-22 07:51:18 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-04-22 07:51:18 +0530 |
| commit | 6e8adbaabedba12e81bf0fdfe3dc42108255bd11 (patch) | |
| tree | 6d0cb2f5d6d029ea93432a1f906ab74bcdfb7917 /persistence | |
| parent | 22912c4af19b9055ed95779c4d16020fe3a449eb (diff) | |
| download | hollowdark-6e8adbaabedba12e81bf0fdfe3dc42108255bd11.tar.xz hollowdark-6e8adbaabedba12e81bf0fdfe3dc42108255bd11.zip | |
Migrate remaining relative imports to @hollowdark/*; strip //-comments and doc references, JSDoc-only
Diffstat (limited to 'persistence')
| -rw-r--r-- | persistence/db.ts | 8 | ||||
| -rw-r--r-- | persistence/schema.ts | 19 |
2 files changed, 12 insertions, 15 deletions
diff --git a/persistence/db.ts b/persistence/db.ts index 213e19b..d8647b0 100644 --- a/persistence/db.ts +++ b/persistence/db.ts @@ -20,7 +20,7 @@ import { CONTENT_CACHE_SCHEMA_V1, USER_DATA_DB_NAME, USER_DATA_SCHEMA_V1 -} from './schema' +} from '@hollowdark/persistence/schema' /** * A single key/value pair on the Settings table. Keys are short slugs @@ -62,8 +62,8 @@ export interface CachedAudioTrack { /** * User save data — the player's world(s). Persists forever on device, - * untouched by content updates (technical/04-persistence.md §"Core - * decisions"). Changes to this schema require a migration. + * untouched by content updates. Changes to this schema require a + * migration in `persistence/migrations` (added later). */ export class HollowdarkUserData extends Dexie { worlds!: Table<World, string> @@ -88,7 +88,7 @@ export class HollowdarkUserData extends Dexie { /** * Content cache — the compiled JSON chunks the client fetched from the * CDN. Independently versioned from user data; can be cleared without - * touching saves (ARCHITECTURE.md §3). + * touching saves. */ export class HollowdarkContentCache extends Dexie { content!: Table<CachedContentChunk, string> diff --git a/persistence/schema.ts b/persistence/schema.ts index 4d11edd..8d381d0 100644 --- a/persistence/schema.ts +++ b/persistence/schema.ts @@ -1,23 +1,17 @@ /** - * IndexedDB schema strings for each of the three Dexie databases. + * IndexedDB schema for the user-data database. The string values follow + * Dexie's index notation: * - * The schema is versioned deliberately — any change here requires a - * migration in persistence/migrations.ts (added later). Snapshot tests - * lock these strings so accidental drift shows up as a failing test - * rather than a silent mismatch between code and on-device data. - * - * Index syntax recap: * &field primary key (unique) * ++id auto-incrementing primary key * field plain index on a scalar * [a+b] compound index * *field multi-entry index on an array field * - * See ARCHITECTURE.md §24 for the user-data schema and §7 for the content - * cache; technical/04-persistence.md for the two-database separation - * (user data persists forever, content is replaceable per update). + * Frozen at module load so a runtime typo on the wrong key throws rather + * than silently mutating the schema object. Snapshot tests lock these + * strings; any change here requires a migration. */ - export const USER_DATA_SCHEMA_V1 = Object.freeze({ worlds: '&id, seed, currentPlayerCharacterId', people: @@ -35,16 +29,19 @@ export const USER_DATA_SCHEMA_V1 = Object.freeze({ settings: '&key' }) +/** IndexedDB schema for the content cache — replaceable per content update. */ export const CONTENT_CACHE_SCHEMA_V1 = Object.freeze({ content: '&chunkId, version, fetchedAt', manifest: '&id' }) +/** IndexedDB schema for the audio cache — blobs + a manifest row. */ export const AUDIO_CACHE_SCHEMA_V1 = Object.freeze({ audio: '&trackId, version, fetchedAt', manifest: '&id' }) +/** Current persistence schema version. Bump when any schema above changes. */ export const SCHEMA_VERSION = 1 as const export const USER_DATA_DB_NAME = 'HollowdarkUserData' as const |
