Skip to content

VesselManager

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:57

Manages vessel registration, lookup, and lifecycle events.

Creates and owns its own store. Every vessel passes through validateVessel so all stored entries carry post-transform brands for IDs, variant names, and action names. Invalid input is rejected: registerVessel returns { valid: false, issues } and does not mutate state or emit vessel_registered.

const manager = new VesselManager({ debug: true });
manager.events.on('vessel_registered', (e) => {
console.log(`Registered: ${e.vessel.id}`);
});
const result = manager.registerVessel(myVessel);
if (!result.valid) {
console.error(result.issues);
}

new VesselManager(options?): VesselManager

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:63

VesselManagerOptions = {}

VesselManager

readonly events: EventSubscriber<VesselManagerEvents>

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:60


readonly store: Store<VesselManagerState>

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:58

get size(): number

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:150

number

dispose(): void

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:158

void


get(vesselId): { defaultVariant: VariantName; description: string; id: VesselId; name: string; variants: z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<VariantName, string>>, z.ZodObject<{ actions: z.ZodArray<z.ZodObject<{ description: z.ZodString; idempotent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; name: z.ZodPipe<z.ZodString, z.ZodTransform<ActionName, string>>; parameters: z.ZodOptional<z.ZodArray<z.ZodObject<…, …>>>; transitionsTo: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<…, …>>>; }, z.core.$strip>>; description: z.ZodOptional<z.ZodString>; minSize: z.ZodObject<{ height: z.ZodNumber; width: z.ZodNumber; }, z.core.$strip>; props: z.ZodRecord<z.ZodString, z.ZodUnknown>; }, z.core.$strip>>; } | undefined

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:138

string

{ defaultVariant: VariantName; description: string; id: VesselId; name: string; variants: z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<VariantName, string>>, z.ZodObject<{ actions: z.ZodArray<z.ZodObject<{ description: z.ZodString; idempotent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; name: z.ZodPipe<z.ZodString, z.ZodTransform<ActionName, string>>; parameters: z.ZodOptional<z.ZodArray<z.ZodObject<…, …>>>; transitionsTo: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<…, …>>>; }, z.core.$strip>>; description: z.ZodOptional<z.ZodString>; minSize: z.ZodObject<{ height: z.ZodNumber; width: z.ZodNumber; }, z.core.$strip>; props: z.ZodRecord<z.ZodString, z.ZodUnknown>; }, z.core.$strip>>; } | undefined


getAll(): object[]

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:142

object[]


getRegisteredIds(): string[]

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:154

string[]


has(vesselId): boolean

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:146

string

boolean


registerVessel(vessel): VesselValidationResult

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:78

Registers a vessel. Always validates through the schema; on failure, returns the validation result without mutating state. Overwrites any existing vessel with the same ID.

VesselDefinition

VesselValidationResult


unregisterVessel(vesselId): { defaultVariant: VariantName; description: string; id: VesselId; name: string; variants: z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<VariantName, string>>, z.ZodObject<{ actions: z.ZodArray<z.ZodObject<{ description: z.ZodString; idempotent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; name: z.ZodPipe<z.ZodString, z.ZodTransform<ActionName, string>>; parameters: z.ZodOptional<z.ZodArray<z.ZodObject<…, …>>>; transitionsTo: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<…, …>>>; }, z.core.$strip>>; description: z.ZodOptional<z.ZodString>; minSize: z.ZodObject<{ height: z.ZodNumber; width: z.ZodNumber; }, z.core.$strip>; props: z.ZodRecord<z.ZodString, z.ZodUnknown>; }, z.core.$strip>>; } | undefined

Defined in: packages/client/src/lib/vessel-management/vessel-manager.ts:113

Unregisters a vessel by ID. Returns the removed vessel, or undefined.

string

{ defaultVariant: VariantName; description: string; id: VesselId; name: string; variants: z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<VariantName, string>>, z.ZodObject<{ actions: z.ZodArray<z.ZodObject<{ description: z.ZodString; idempotent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; name: z.ZodPipe<z.ZodString, z.ZodTransform<ActionName, string>>; parameters: z.ZodOptional<z.ZodArray<z.ZodObject<…, …>>>; transitionsTo: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<…, …>>>; }, z.core.$strip>>; description: z.ZodOptional<z.ZodString>; minSize: z.ZodObject<{ height: z.ZodNumber; width: z.ZodNumber; }, z.core.$strip>; props: z.ZodRecord<z.ZodString, z.ZodUnknown>; }, z.core.$strip>>; } | undefined