Menu

TypeScript Interfaces

Complete TypeScript type definitions for the Splice harness schema. Use these interfaces for type-safe integration with the Splice data format.

Enums

export enum PartKind {
  Connector = 'connector',
  Terminal = 'terminal',
  Wire = 'wire',
  Cable = 'cable',
  Assembly = 'assembly',
}

export enum Gender {
  Male = 'male',
  Female = 'female',
  None = 'none',
}

export enum ConnectorShape {
  Circular = 'circular',
  Rectangular = 'rectangular',
  DSub = 'dsub',
  TerminalBlock = 'terminal_block',
  Ferrule = 'ferrule',
  QuickDisconnect = 'quickdisconnect',
  Ring = 'ring',
  Button = 'button',
  Spade = 'spade',
  Lug = 'lug',
  Usb = 'usb',
  Barrel = 'barrel',
  Header = 'header',
  Coaxial = 'coaxial',
  Rj = 'rj',
  Other = 'other',
}

export enum ConductorType {
  Solid = 'solid',
  Stranded = 'stranded',
}

export enum ConnectionSide {
  Left = 'left',
  Right = 'right',
}

Main Working Harness Structure

export interface WorkingHarness {
  bom: Record<string, ExpandedBomItem>; // Key is instance_id (e.g., "X1", "W1", "C1")
  data: WorkingData;
  harness_id?: string;
  revision_id?: string;
}

export interface ExpandedBomItem {
  instance_id: string;
  part: any; // Full part data (JSON value) - see Part interface structure below
  unit: string;
}

Parts System

export interface Part {
  id: string; // UUID
  kind: PartKind;
  mpn: string;
  manufacturer: string;
  description?: string;
  img_url?: string;
  datasheet_url?: string;
  created_at?: string; // ISO datetime
  spec?: any;
}

export interface NewPart {
  kind: PartKind;
  mpn: string;
  manufacturer: string;
  description?: string;
  img_url?: string;
  datasheet_url?: string;
}

export interface AddPartDto {
  mpn: string;
  kind: 'connector' | 'wire' | 'terminal' | 'cable';
  unit?: string;
  id?: string; // Optional UUID to uniquely identify the part
}

// BOM item stored in database (uses part ID)
export interface BomItem {
  part_id: string; // UUID reference
  unit: string; // "each", "m", "ft", etc.
}

Connector Specifications

export interface ConnectorSpec {
  color?: string;
  contact_gender?: Gender;
  contact_termination?: string;
  fastening_type?: string;
  features?: string[];
  insulation_material?: string;
  mounting_type?: string;
  operating_temp_f?: string;
  pitch_mm?: number;
  positions: number;
  recommended_contacts?: string;
  row_spacing_mm?: number;
  rows?: number;
  series?: string;
  shape?: ConnectorShape;
  wire_awg_min?: number;
  wire_awg_max?: number;
  keying_code?: string;
  bridged_positions?: number[][];
  // Custom connector fields
  is_custom?: boolean;
  created_by_user_id?: string;
  is_public?: boolean;
  is_approved?: boolean | null;
  custom_svg?: CustomConnectorSvg;
  pin_mapping?: Record<string, any>; // Simple index->pin_number mapping
  custom_properties?: Record<string, any>;
}

export interface CustomConnectorSvg {
  mate_side: string;
  wire_side: string;
}

export interface ConnectorPart extends Part {
  kind: PartKind.Connector;
  spec: {
    connector: ConnectorSpec;
  };
}

Wire Specifications

export interface WireSpec {
  awg?: number;
  stranding?: string | null; // e.g., "7/30"
  color?: string | null;
  stripe?: string | null;
  conductor_type: ConductorType;
}

export interface WirePart extends Part {
  kind: PartKind.Wire;
  spec: {
    wire: WireSpec;
  };
}

Cable Specifications

export interface CableCore {
  core_no: number;
  awg?: number;
  stranding?: string;
  color?: string;
  conductor_type: ConductorType;
}

export interface CableSpec {
  core_count?: number;
  shielded?: boolean;
  shield_type?: string;
  outer_diameter_mm?: number;
  voltage_rating?: number;
  default_length_m?: number;
  jacket_material?: string;
  temperature_rating_c?: number;
  flexibility?: string;
  template_data?: any;
}

export interface CablePart extends Part {
  kind: PartKind.Cable;
  spec: {
    cable: CableSpec;
  };
}

export interface CableWithCores extends CablePart {
  cores: CableCore[];
}

Working Data Structure

export interface WorkingData {
  mapping: Record<string, Connection>; // Key is wire/cable instance_id (e.g., "W1", "C1")
  connector_positions: Record<string, ConnectorPosition>; // Key is connector instance_id (e.g., "X1", "X2")
  wire_anchors: Record<string, WireAnchor>; // Key is "connector1|connector2" (e.g., "X1|X2")
  cable_positions?: Record<string, ConnectorPosition>; // Key is cable instance_id
  design_notes?: DesignNote[]; // Optional for backward compatibility
  name?: string | null;
  description?: string | null;
  notes?: string | null;
  /** @deprecated Use wire_anchors[key].hidden instead. Kept for backward compatibility. */
  hidden_bundles?: string[];
}

Connection System

export interface Connection {
  end1?: ConnectionTermination;
  end2?: ConnectionTermination;
  label?: string;
  length_mm?: number;
}

export interface TerminationRouting {
  mode: string; // "auto" or "manual"
  waypoints?: WireAnchor[]; // waypoints for this termination
}

export type ConnectionTermination =
  | {
      type: 'connector_pin';
      connector_instance: string;
      pin: number;
      side: ConnectionSide;
      terminal_instance?: string;
      routing?: TerminationRouting;
    }
  | {
      type: 'cable_core';
      cable_instance: string;
      core_no: number;
      side: ConnectionSide;
      routing?: TerminationRouting;
    }
  | {
      type: 'flying_lead';
      termination_type: 'tinned' | 'bare' | 'heat_shrink';
      strip_length_mm?: number;
      tin_length_mm?: number;
      terminal_instance?: string;
      routing?: TerminationRouting;
    };

Position Types

export interface Position {
  x: number;
  y: number;
  width?: number; // Optional width for adjustable blocks
  height?: number; // Optional height for adjustable blocks
  collapsed?: boolean; // Optional collapse state for connectors/cables
  hidden?: boolean; // Optional hidden state for wire bundles
}

export type ConnectorPosition = Position;
export type WireAnchor = Position;

export interface DesignNote {
  id: string;
  x: number;
  y: number;
  content: string;
  created_at?: string;
  width?: number;
}

Harness Management

export interface Harness {
  id: string;
  owner_id: string;
  name: string;
  description?: string;
  is_public: boolean;
  share_token?: string;
  created_at: string;
  modified_at: string;
}

export interface NewHarness {
  name: string;
  description?: string;
  is_public: boolean;
}

export interface RevisionDoc {
  bom: Record<string, BomItem>;
  data: WorkingData;
}

TypeScript Example

const exampleHarness: WorkingHarness = {
  bom: {
    X1: {
      instance_id: 'X1',
      part: {
        id: '12345678-1234-1234-1234-123456789abc',
        kind: 'connector',
        mpn: '09-50-1031',
        manufacturer: 'Molex',
        description: '3 Position Wire to Board Connector',
        spec: {
          connector: {
            positions: 3,
            rows: 1,
            shape: 'rectangular',
            contact_gender: 'female',
            pitch_mm: 2.54,
          },
        },
      },
      unit: 'each',
    },
    W1: {
      instance_id: 'W1',
      part: {
        id: '11111111-2222-3333-4444-555555555555',
        kind: 'wire',
        mpn: 'AWG22-RED',
        manufacturer: 'Generic',
        description: '22 AWG Stranded Wire, Red',
        spec: {
          wire: {
            awg: 22,
            stranding: '7/30',
            color: 'red',
            conductor_type: 'stranded',
          },
        },
      },
      unit: 'ft',
    },
  },
  data: {
    mapping: {
      W1: {
        end1: {
          type: 'connector_pin',
          connector_instance: 'X1',
          pin: 1,
          side: 'right',
        },
        end2: {
          type: 'flying_lead',
          termination_type: 'tinned',
          strip_length_mm: 6,
          tin_length_mm: 3,
        },
        label: 'POWER',
        length_mm: 152.4,
      },
    },
    connector_positions: {
      X1: { x: 100, y: 200 },
    },
    wire_anchors: {},
    name: 'Example Harness',
    description: 'Simple harness example',
  },
};