circuit-bricks
Version:
A modular, Lego-style SVG circuit component system for React (ALPHA - Not for production use)
580 lines • 16.7 kB
TypeScript
/**
* ZOD schemas for Circuit-Bricks component types
*
* This module provides ZOD schemas for validating component schemas,
* component instances, wires, and other core types used in the library.
*/
import { z } from 'zod';
/**
* Schema for port type
*/
export declare const portTypeSchema: z.ZodEnum<["input", "output", "inout", "positive", "negative", "anode", "cathode", "collector", "base", "emitter", "drain", "gate", "source", "vcc", "vdd", "vss", "gnd", "clock", "reset", "enable"]>;
/**
* Schema for a 2D point
*/
export declare const pointSchema: z.ZodObject<{
x: z.ZodNumber;
y: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
x: number;
y: number;
}, {
x: number;
y: number;
}>;
/**
* Schema for size dimensions
*/
export declare const sizeSchema: z.ZodObject<{
width: z.ZodNumber;
height: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
width: number;
height: number;
}, {
width: number;
height: number;
}>;
/**
* Schema for a component port
*/
export declare const portSchema: z.ZodObject<{
id: z.ZodString;
x: z.ZodNumber;
y: z.ZodNumber;
type: z.ZodEnum<["input", "output", "inout", "positive", "negative", "anode", "cathode", "collector", "base", "emitter", "drain", "gate", "source", "vcc", "vdd", "vss", "gnd", "clock", "reset", "enable"]>;
label: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
x: number;
y: number;
type: "input" | "output" | "inout" | "positive" | "negative" | "anode" | "cathode" | "collector" | "base" | "emitter" | "drain" | "gate" | "source" | "vcc" | "vdd" | "vss" | "gnd" | "clock" | "reset" | "enable";
id: string;
label?: string | undefined;
}, {
x: number;
y: number;
type: "input" | "output" | "inout" | "positive" | "negative" | "anode" | "cathode" | "collector" | "base" | "emitter" | "drain" | "gate" | "source" | "vcc" | "vdd" | "vss" | "gnd" | "clock" | "reset" | "enable";
id: string;
label?: string | undefined;
}>;
/**
* Schema for a component property
*/
export declare const propertySchema: z.ZodObject<{
key: z.ZodString;
label: z.ZodString;
type: z.ZodEnum<["number", "boolean", "select", "text", "color"]>;
unit: z.ZodOptional<z.ZodString>;
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
value: z.ZodAny;
label: z.ZodString;
}, "strip", z.ZodTypeAny, {
label: string;
value?: any;
}, {
label: string;
value?: any;
}>, "many">>;
default: z.ZodAny;
min: z.ZodOptional<z.ZodNumber>;
max: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type: "number" | "boolean" | "select" | "text" | "color";
label: string;
key: string;
options?: {
label: string;
value?: any;
}[] | undefined;
unit?: string | undefined;
default?: any;
min?: number | undefined;
max?: number | undefined;
}, {
type: "number" | "boolean" | "select" | "text" | "color";
label: string;
key: string;
options?: {
label: string;
value?: any;
}[] | undefined;
unit?: string | undefined;
default?: any;
min?: number | undefined;
max?: number | undefined;
}>;
/**
* Schema for a component definition
*/
export declare const componentSchema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
category: z.ZodString;
description: z.ZodString;
defaultWidth: z.ZodNumber;
defaultHeight: z.ZodNumber;
ports: z.ZodArray<z.ZodObject<{
id: z.ZodString;
x: z.ZodNumber;
y: z.ZodNumber;
type: z.ZodEnum<["input", "output", "inout", "positive", "negative", "anode", "cathode", "collector", "base", "emitter", "drain", "gate", "source", "vcc", "vdd", "vss", "gnd", "clock", "reset", "enable"]>;
label: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
x: number;
y: number;
type: "input" | "output" | "inout" | "positive" | "negative" | "anode" | "cathode" | "collector" | "base" | "emitter" | "drain" | "gate" | "source" | "vcc" | "vdd" | "vss" | "gnd" | "clock" | "reset" | "enable";
id: string;
label?: string | undefined;
}, {
x: number;
y: number;
type: "input" | "output" | "inout" | "positive" | "negative" | "anode" | "cathode" | "collector" | "base" | "emitter" | "drain" | "gate" | "source" | "vcc" | "vdd" | "vss" | "gnd" | "clock" | "reset" | "enable";
id: string;
label?: string | undefined;
}>, "many">;
properties: z.ZodArray<z.ZodObject<{
key: z.ZodString;
label: z.ZodString;
type: z.ZodEnum<["number", "boolean", "select", "text", "color"]>;
unit: z.ZodOptional<z.ZodString>;
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
value: z.ZodAny;
label: z.ZodString;
}, "strip", z.ZodTypeAny, {
label: string;
value?: any;
}, {
label: string;
value?: any;
}>, "many">>;
default: z.ZodAny;
min: z.ZodOptional<z.ZodNumber>;
max: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type: "number" | "boolean" | "select" | "text" | "color";
label: string;
key: string;
options?: {
label: string;
value?: any;
}[] | undefined;
unit?: string | undefined;
default?: any;
min?: number | undefined;
max?: number | undefined;
}, {
type: "number" | "boolean" | "select" | "text" | "color";
label: string;
key: string;
options?: {
label: string;
value?: any;
}[] | undefined;
unit?: string | undefined;
default?: any;
min?: number | undefined;
max?: number | undefined;
}>, "many">;
svgPath: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
category: string;
description: string;
defaultWidth: number;
defaultHeight: number;
ports: {
x: number;
y: number;
type: "input" | "output" | "inout" | "positive" | "negative" | "anode" | "cathode" | "collector" | "base" | "emitter" | "drain" | "gate" | "source" | "vcc" | "vdd" | "vss" | "gnd" | "clock" | "reset" | "enable";
id: string;
label?: string | undefined;
}[];
properties: {
type: "number" | "boolean" | "select" | "text" | "color";
label: string;
key: string;
options?: {
label: string;
value?: any;
}[] | undefined;
unit?: string | undefined;
default?: any;
min?: number | undefined;
max?: number | undefined;
}[];
svgPath: string;
}, {
id: string;
name: string;
category: string;
description: string;
defaultWidth: number;
defaultHeight: number;
ports: {
x: number;
y: number;
type: "input" | "output" | "inout" | "positive" | "negative" | "anode" | "cathode" | "collector" | "base" | "emitter" | "drain" | "gate" | "source" | "vcc" | "vdd" | "vss" | "gnd" | "clock" | "reset" | "enable";
id: string;
label?: string | undefined;
}[];
properties: {
type: "number" | "boolean" | "select" | "text" | "color";
label: string;
key: string;
options?: {
label: string;
value?: any;
}[] | undefined;
unit?: string | undefined;
default?: any;
min?: number | undefined;
max?: number | undefined;
}[];
svgPath: string;
}>;
/**
* Schema for a component instance
*/
export declare const componentInstanceSchema: z.ZodObject<{
id: z.ZodString;
type: z.ZodString;
position: z.ZodObject<{
x: z.ZodNumber;
y: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
x: number;
y: number;
}, {
x: number;
y: number;
}>;
size: z.ZodOptional<z.ZodObject<{
width: z.ZodNumber;
height: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
width: number;
height: number;
}, {
width: number;
height: number;
}>>;
props: z.ZodRecord<z.ZodString, z.ZodAny>;
rotation: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
position: {
x: number;
y: number;
};
props: Record<string, any>;
size?: {
width: number;
height: number;
} | undefined;
rotation?: number | undefined;
}, {
type: string;
id: string;
position: {
x: number;
y: number;
};
props: Record<string, any>;
size?: {
width: number;
height: number;
} | undefined;
rotation?: number | undefined;
}>;
/**
* Schema for a wire connection
*/
export declare const wireSchema: z.ZodObject<{
id: z.ZodString;
from: z.ZodObject<{
componentId: z.ZodString;
portId: z.ZodString;
}, "strip", z.ZodTypeAny, {
componentId: string;
portId: string;
}, {
componentId: string;
portId: string;
}>;
to: z.ZodObject<{
componentId: z.ZodString;
portId: z.ZodString;
}, "strip", z.ZodTypeAny, {
componentId: string;
portId: string;
}, {
componentId: string;
portId: string;
}>;
style: z.ZodOptional<z.ZodObject<{
color: z.ZodOptional<z.ZodString>;
strokeWidth: z.ZodOptional<z.ZodNumber>;
dashArray: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
}, {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
id: string;
from: {
componentId: string;
portId: string;
};
to: {
componentId: string;
portId: string;
};
style?: {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
} | undefined;
}, {
id: string;
from: {
componentId: string;
portId: string;
};
to: {
componentId: string;
portId: string;
};
style?: {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
} | undefined;
}>;
/**
* Schema for the complete circuit state
*/
export declare const circuitStateSchema: z.ZodObject<{
components: z.ZodArray<z.ZodObject<{
id: z.ZodString;
type: z.ZodString;
position: z.ZodObject<{
x: z.ZodNumber;
y: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
x: number;
y: number;
}, {
x: number;
y: number;
}>;
size: z.ZodOptional<z.ZodObject<{
width: z.ZodNumber;
height: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
width: number;
height: number;
}, {
width: number;
height: number;
}>>;
props: z.ZodRecord<z.ZodString, z.ZodAny>;
rotation: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type: string;
id: string;
position: {
x: number;
y: number;
};
props: Record<string, any>;
size?: {
width: number;
height: number;
} | undefined;
rotation?: number | undefined;
}, {
type: string;
id: string;
position: {
x: number;
y: number;
};
props: Record<string, any>;
size?: {
width: number;
height: number;
} | undefined;
rotation?: number | undefined;
}>, "many">;
wires: z.ZodArray<z.ZodObject<{
id: z.ZodString;
from: z.ZodObject<{
componentId: z.ZodString;
portId: z.ZodString;
}, "strip", z.ZodTypeAny, {
componentId: string;
portId: string;
}, {
componentId: string;
portId: string;
}>;
to: z.ZodObject<{
componentId: z.ZodString;
portId: z.ZodString;
}, "strip", z.ZodTypeAny, {
componentId: string;
portId: string;
}, {
componentId: string;
portId: string;
}>;
style: z.ZodOptional<z.ZodObject<{
color: z.ZodOptional<z.ZodString>;
strokeWidth: z.ZodOptional<z.ZodNumber>;
dashArray: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
}, {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
id: string;
from: {
componentId: string;
portId: string;
};
to: {
componentId: string;
portId: string;
};
style?: {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
} | undefined;
}, {
id: string;
from: {
componentId: string;
portId: string;
};
to: {
componentId: string;
portId: string;
};
style?: {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
} | undefined;
}>, "many">;
selectedComponentIds: z.ZodArray<z.ZodString, "many">;
selectedWireIds: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
components: {
type: string;
id: string;
position: {
x: number;
y: number;
};
props: Record<string, any>;
size?: {
width: number;
height: number;
} | undefined;
rotation?: number | undefined;
}[];
wires: {
id: string;
from: {
componentId: string;
portId: string;
};
to: {
componentId: string;
portId: string;
};
style?: {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
} | undefined;
}[];
selectedComponentIds: string[];
selectedWireIds: string[];
}, {
components: {
type: string;
id: string;
position: {
x: number;
y: number;
};
props: Record<string, any>;
size?: {
width: number;
height: number;
} | undefined;
rotation?: number | undefined;
}[];
wires: {
id: string;
from: {
componentId: string;
portId: string;
};
to: {
componentId: string;
portId: string;
};
style?: {
color?: string | undefined;
strokeWidth?: number | undefined;
dashArray?: string | undefined;
} | undefined;
}[];
selectedComponentIds: string[];
selectedWireIds: string[];
}>;
/**
* Type for validation issues
*/
export declare const validationIssueSchema: z.ZodObject<{
type: z.ZodEnum<["error", "warning"]>;
message: z.ZodString;
componentId: z.ZodOptional<z.ZodString>;
wireId: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
message: string;
type: "error" | "warning";
componentId?: string | undefined;
wireId?: string | undefined;
}, {
message: string;
type: "error" | "warning";
componentId?: string | undefined;
wireId?: string | undefined;
}>;
export type PortType = z.infer<typeof portTypeSchema>;
export type Point = z.infer<typeof pointSchema>;
export type Size = z.infer<typeof sizeSchema>;
export type PortSchema = z.infer<typeof portSchema>;
export type PropertySchema = z.infer<typeof propertySchema>;
export type ComponentSchema = z.infer<typeof componentSchema>;
export type ComponentInstance = z.infer<typeof componentInstanceSchema>;
export type Wire = z.infer<typeof wireSchema>;
export type CircuitState = z.infer<typeof circuitStateSchema>;
export type ValidationIssue = z.infer<typeof validationIssueSchema>;
//# sourceMappingURL=componentSchema.d.ts.map