Function: toPeripheralDevice()
function toPeripheralDevice(row: {
connectionKind: string;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
deviceType: string;
drawerPin: number | null;
host: string | null;
id: string;
make: string | null;
metadata: JsonValue;
model: string | null;
name: string;
organizationId: string;
paperWidthChars: number | null;
port: number | null;
printerLanguage: string | null;
qzPrinterName: string | null;
stationId: string | null;
status: string;
statusUpdatedAt: Date;
statusUpdatedBy: string | null;
storeId: string | null;
updatedAt: Date;
updatedBy: string | null;
usbProductId: number | null;
usbSerialNumber: string | null;
usbVendorId: number | null;
}): {
connection: | {
kind: "webusb";
usbProductId: number;
usbSerialNumber?: string | null;
usbVendorId: number;
}
| {
host: string;
kind: "network";
port: number;
}
| {
kind: "qz";
printerName: string;
};
deviceType: "receipt_printer" | "cash_drawer" | "barcode_scanner";
drawerPin?: 2 | 5 | null;
id: string;
make?: string | null;
metadata?: Record<string, unknown> | null;
model?: string | null;
name: string;
organizationId: string;
paperWidthChars?: 32 | 35 | 42 | 44 | 48 | null;
printerLanguage?: "esc-pos" | "star-prnt" | "star-line" | null;
stationId?: string | null;
status: "active" | "inactive";
storeId?: string | null;
};Defined in: server/peripherals/models.ts:113
Map a Prisma row to the shared, Zod-validated PeripheralDevice shape
(flat columns → nested connection config). Throws INVALID_CONFIG when a
row is internally inconsistent (e.g. network kind with no host).
Parameters
| Parameter | Type |
|---|---|
row | { connectionKind: string; createdAt: Date; createdBy: string | null; deletedAt: Date | null; deletedBy: string | null; deviceType: string; drawerPin: number | null; host: string | null; id: string; make: string | null; metadata: JsonValue; model: string | null; name: string; organizationId: string; paperWidthChars: number | null; port: number | null; printerLanguage: string | null; qzPrinterName: string | null; stationId: string | null; status: string; statusUpdatedAt: Date; statusUpdatedBy: string | null; storeId: string | null; updatedAt: Date; updatedBy: string | null; usbProductId: number | null; usbSerialNumber: string | null; usbVendorId: number | null; } |
row.connectionKind | string |
row.createdAt | Date |
row.createdBy | string | null |
row.deletedAt | Date | null |
row.deletedBy | string | null |
row.deviceType | string |
row.drawerPin | number | null |
row.host | string | null |
row.id | string |
row.make | string | null |
row.metadata | JsonValue |
row.model | string | null |
row.name | string |
row.organizationId | string |
row.paperWidthChars | number | null |
row.port | number | null |
row.printerLanguage | string | null |
row.qzPrinterName | string | null |
row.stationId | string | null |
row.status | string |
row.statusUpdatedAt | Date |
row.statusUpdatedBy | string | null |
row.storeId | string | null |
row.updatedAt | Date |
row.updatedBy | string | null |
row.usbProductId | number | null |
row.usbSerialNumber | string | null |
row.usbVendorId | number | null |
Returns
connection
connection:
| {
kind: "webusb";
usbProductId: number;
usbSerialNumber?: string | null;
usbVendorId: number;
}
| {
host: string;
kind: "network";
port: number;
}
| {
kind: "qz";
printerName: string;
} = connectionConfigSchema;Union Members
Type Literal
{
kind: "webusb";
usbProductId: number;
usbSerialNumber?: string | null;
usbVendorId: number;
}kind
kind: "webusb";usbProductId
usbProductId: number;usbSerialNumber?
optional usbSerialNumber?: string | null;Distinguishes identical printers on the same station.
usbVendorId
usbVendorId: number;Type Literal
{
host: string;
kind: "network";
port: number;
}host
host: string;kind
kind: "network";port
port: number;Raw-socket printing port; 9100 is the near-universal default.
Type Literal
{
kind: "qz";
printerName: string;
}kind
kind: "qz";printerName
printerName: string;OS printer name as QZ Tray reports it.
deviceType
deviceType: "receipt_printer" | "cash_drawer" | "barcode_scanner" = peripheralDeviceTypeSchema;drawerPin?
optional drawerPin?: 2 | 5 | null;Drawer-kick pin — on printer rows (drawer wired to the printer) or standalone cash_drawer rows.
id
id: string;make?
optional make?: string | null;metadata?
optional metadata?: Record<string, unknown> | null;model?
optional model?: string | null;name
name: string;organizationId
organizationId: string;paperWidthChars?
optional paperWidthChars?: 32 | 35 | 42 | 44 | 48 | null;Character columns at the printer's default font.
printerLanguage?
optional printerLanguage?: "esc-pos" | "star-prnt" | "star-line" | null;Required for receipt printers; meaningless for scanners.
stationId?
optional stationId?: string | null;status
status: "active" | "inactive" = peripheralDeviceStatusSchema;storeId?
optional storeId?: string | null;