Wire the app to the shared Supabase catalog (public catalog read integration)

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`.
This commit is contained in:
2026-09-07 23:42:00 -05:00
parent 93cb4a9617
commit b97777444a
22 changed files with 656 additions and 323 deletions
+5 -4
View File
@@ -1,5 +1,5 @@
import { acceptedFamilies, getPortType, hasBridgingCableType } from './project'
import type { Connection, Device, PortType, Project } from './types'
import type { Catalog, Connection, Device, PortType, Project } from './types'
/**
* Two ports connect if the sets of families they each accept (their own
@@ -37,6 +37,7 @@ export interface ConnectionValidation {
*/
export function validateConnection(
project: Project,
catalog: Catalog,
candidate: ConnectionCandidate,
existingConnections: Connection[] = project.connections,
): ConnectionValidation {
@@ -62,15 +63,15 @@ export function validateConnection(
return { valid: false, reason: 'Cannot connect two output ports.' }
}
const sourcePortType = getPortType(project, sourcePort.portTypeId)
const targetPortType = getPortType(project, targetPort.portTypeId)
const sourcePortType = getPortType(catalog, sourcePort.portTypeId)
const targetPortType = getPortType(catalog, targetPort.portTypeId)
if (!sourcePortType || !targetPortType) {
return { valid: false, reason: 'Unknown port type.' }
}
// Directly compatible port types, or bridgeable by a specific adapter
// cable (different connectors on each end, e.g. XLR-to-TRS) even when the
// port types themselves declare no general compatibility.
if (!portTypesCompatible(sourcePortType, targetPortType) && !hasBridgingCableType(project, sourcePortType, targetPortType)) {
if (!portTypesCompatible(sourcePortType, targetPortType) && !hasBridgingCableType(catalog, sourcePortType, targetPortType)) {
return {
valid: false,
reason: `${sourcePortType.name} is not compatible with ${targetPortType.name}.`,