Adds comprehensive mock data repositories and seeding infrastructure
Implements polymorphic data seeding mechanism for initial application setup - Adds Mock repositories for Event, Booking, Customer, and Resource entities - Creates DataSeeder to automatically populate IndexedDB from JSON sources - Enhances index.ts initialization process with data seeding step - Adds mock JSON data files for comprehensive test data Improves offline-first and development testing capabilities
This commit is contained in:
parent
871f5c5682
commit
5648c7c304
11 changed files with 1641 additions and 40 deletions
|
|
@ -4,13 +4,13 @@ import { ISync, EntityType, SyncStatus } from '../types/CalendarTypes';
|
|||
* IEntityService<T> - Generic interface for entity services with sync capabilities
|
||||
*
|
||||
* All entity services (Event, Booking, Customer, Resource) implement this interface
|
||||
* to enable polymorphic sync status management in SyncManager.
|
||||
* to enable polymorphic operations across different entity types.
|
||||
*
|
||||
* ENCAPSULATION: Services encapsulate sync status manipulation.
|
||||
* SyncManager does NOT directly manipulate entity.syncStatus - it delegates to the service.
|
||||
*
|
||||
* POLYMORFI: SyncManager works with Array<IEntityService<any>> and uses
|
||||
* entityType property for runtime routing, avoiding switch statements.
|
||||
* POLYMORPHISM: Both SyncManager and DataSeeder work with Array<IEntityService<any>>
|
||||
* and use entityType property for runtime routing, avoiding switch statements.
|
||||
*/
|
||||
export interface IEntityService<T extends ISync> {
|
||||
/**
|
||||
|
|
@ -19,6 +19,30 @@ export interface IEntityService<T extends ISync> {
|
|||
*/
|
||||
readonly entityType: EntityType;
|
||||
|
||||
// ============================================================================
|
||||
// CRUD Operations (used by DataSeeder and other consumers)
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Get all entities from IndexedDB
|
||||
* Used by DataSeeder to check if store is empty before seeding
|
||||
*
|
||||
* @returns Promise<T[]> - Array of all entities
|
||||
*/
|
||||
getAll(): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Save an entity (create or update) to IndexedDB
|
||||
* Used by DataSeeder to persist fetched data
|
||||
*
|
||||
* @param entity - Entity to save
|
||||
*/
|
||||
save(entity: T): Promise<void>;
|
||||
|
||||
// ============================================================================
|
||||
// SYNC Methods (used by SyncManager)
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Mark entity as successfully synced with backend
|
||||
* Sets syncStatus = 'synced' and persists to IndexedDB
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue