Moves port/cable/category/device-template data from per-diagram embedded storage to the global public/private catalog backed by Supabase, per organized-ideas.md's "live reference, not snapshot" decision. - domain/types.ts, project.ts, compatibility.ts, bom.ts: lookup functions now take an explicit Catalog parameter instead of deriving data from Project — Project is reduced to just diagram-scoped fields. - New CatalogRepository/SupabaseCatalogRepository (mirrors the DiagramRepository pattern) and catalogStore.ts, replacing the catalog-related actions that used to live in projectStore. - device_templates gets a plain-text manufacturer column for now (the normalized manufacturer catalog from organized-ideas.md §3 is its own future pass, not blocking this one). - domain/library.ts is no longer imported by the app — it's now only the source scripts/generate-seed.mjs reads to produce supabase/seed.sql. - Swept every UI call site via tsc -b until clean; oxlint clean; 23/23 pgTAP RLS tests still passing after a `supabase db reset`.
31 lines
1.6 KiB
TypeScript
31 lines
1.6 KiB
TypeScript
import type { Catalog, CableType, DeviceCategoryDef, DeviceTemplate, PortType } from '../domain/types'
|
|
|
|
/**
|
|
* Storage abstraction for the global port/cable/category/device-template
|
|
* catalog — mirrors DiagramRepository's role, but for catalog data instead
|
|
* of diagrams. Fetching returns everything the current user can see (public
|
|
* entries plus their own private ones); RLS does that filtering server-side,
|
|
* so implementations don't need to filter client-side.
|
|
*
|
|
* Only covers the "read + manage your own private entries" surface for now.
|
|
* Submitting a private entry for public review/promotion is a separate,
|
|
* not-yet-built workflow (organized-ideas.md §3/§9) — these `add*`/`update*`
|
|
* methods always create or edit is_public = false rows you own.
|
|
*/
|
|
export interface CatalogRepository {
|
|
/** Everything visible to the current user: public entries plus their own private ones. */
|
|
load(): Promise<Catalog>
|
|
|
|
addDeviceCategory(name: string): Promise<DeviceCategoryDef>
|
|
|
|
addPortType(portType: Omit<PortType, 'id' | 'custom'>): Promise<PortType>
|
|
updatePortType(id: string, patch: Partial<Omit<PortType, 'id' | 'custom'>>): Promise<void>
|
|
|
|
addCableType(cableType: Omit<CableType, 'id' | 'custom'>): Promise<CableType>
|
|
updateCableType(id: string, patch: Partial<Omit<CableType, 'id' | 'custom'>>): Promise<void>
|
|
|
|
addDeviceTemplate(template: Omit<DeviceTemplate, 'id' | 'custom'>): Promise<DeviceTemplate>
|
|
updateDeviceTemplate(id: string, patch: Partial<Omit<DeviceTemplate, 'id' | 'custom'>>): Promise<void>
|
|
removeDeviceTemplate(id: string): Promise<void>
|
|
}
|