Kaizen
Browse modulesPeripheralsperipherals/serverClasses

Class: PeripheralDeviceService

Defined in: server/peripherals/peripheral-device-service.ts:102

Constructors

Constructor

new PeripheralDeviceService(deps: PeripheralsFeatureDeps): PeripheralDeviceService;

Defined in: server/peripherals/peripheral-device-service.ts:103

Parameters

ParameterType
depsPeripheralsFeatureDeps

Returns

PeripheralDeviceService

Methods

deactivate()

deactivate(id: string): Promise<{
  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/peripheral-device-service.ts:229

Parameters

ParameterType
idstring

Returns

Promise<{ 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; }>


getById()

getById(id: string): Promise<{
  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/peripheral-device-service.ts:158

Parameters

ParameterType
idstring

Returns

Promise<{ 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; }>


listForOrg()

listForOrg(organizationId: string, filter?: {
  deviceType?: "receipt_printer" | "cash_drawer" | "barcode_scanner";
  stationId?: string;
  status?: "active" | "inactive";
  storeId?: string;
}): Promise<{
  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/peripheral-device-service.ts:169

Rows that fail device validation (written before the rules existed, or edited out-of-band) are OMITTED rather than failing the whole list — one corrupt row must not take down a station's device enumeration. Use listInvalidForOrg to surface the omitted rows for repair.

Parameters

ParameterType
organizationIdstring
filter{ deviceType?: "receipt_printer" | "cash_drawer" | "barcode_scanner"; stationId?: string; status?: "active" | "inactive"; storeId?: string; }
filter.deviceType?"receipt_printer" | "cash_drawer" | "barcode_scanner"
filter.stationId?string
filter.status?"active" | "inactive"
filter.storeId?string

Returns

Promise<{ 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; }[]>


listForStation()

listForStation(organizationId: string, scope?: {
  deviceType?: "receipt_printer" | "cash_drawer" | "barcode_scanner";
  stationId?: string;
  storeId?: string;
}): Promise<{
  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/peripheral-device-service.ts:190

Active devices a station should offer: rows pinned to the station plus org-wide rows (no store/station pin). Rows pinned elsewhere are excluded; rows failing validation are omitted (see listForOrg).

Parameters

ParameterType
organizationIdstring
scope{ deviceType?: "receipt_printer" | "cash_drawer" | "barcode_scanner"; stationId?: string; storeId?: string; }
scope.deviceType?"receipt_printer" | "cash_drawer" | "barcode_scanner"
scope.stationId?string
scope.storeId?string

Returns

Promise<{ 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; }[]>


listInvalidForOrg()

listInvalidForOrg(organizationId: string): Promise<{
  id: string;
  name: string;
  reason: string;
}[]>;

Defined in: server/peripherals/peripheral-device-service.ts:210

The rows the list methods omit, with why — the admin recovery surface. Each entry's id can be fed to update (a repairing patch is accepted: the merged shape just has to validate) or softDelete.

Parameters

ParameterType
organizationIdstring

Returns

Promise<{ id: string; name: string; reason: string; }[]>


register()

register(input: {
  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;
  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;
  storeId?: string | null;
}): Promise<{
  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/peripheral-device-service.ts:109

Parameters

ParameterTypeDescription
input{ 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; 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; storeId?: string | null; }-
input.connection| { kind: "webusb"; usbProductId: number; usbSerialNumber?: string | null; usbVendorId: number; } | { host: string; kind: "network"; port: number; } | { kind: "qz"; printerName: string; }-
input.deviceType"receipt_printer" | "cash_drawer" | "barcode_scanner"-
input.drawerPin?2 | 5 | nullDrawer-kick pin — on printer rows (drawer wired to the printer) or standalone cash_drawer rows.
input.make?string | null-
input.metadata?Record<string, unknown> | null-
input.model?string | null-
input.namestring-
input.organizationIdstring-
input.paperWidthChars?32 | 35 | 42 | 44 | 48 | nullCharacter columns at the printer's default font.
input.printerLanguage?"esc-pos" | "star-prnt" | "star-line" | nullRequired for receipt printers; meaningless for scanners.
input.stationId?string | null-
input.storeId?string | null-

Returns

Promise<{ 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; }>


softDelete()

softDelete(id: string): Promise<void>;

Defined in: server/peripherals/peripheral-device-service.ts:233

Parameters

ParameterType
idstring

Returns

Promise<void>


update()

update(id: string, input: {
  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;
  make?: string | null;
  metadata?: Record<string, unknown> | null;
  model?: string | null;
  name?: 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;
}): Promise<{
  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/peripheral-device-service.ts:124

Parameters

ParameterTypeDescription
idstring-
input{ 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; make?: string | null; metadata?: Record<string, unknown> | null; model?: string | null; name?: 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; }-
input.connection?| { kind: "webusb"; usbProductId: number; usbSerialNumber?: string | null; usbVendorId: number; } | { host: string; kind: "network"; port: number; } | { kind: "qz"; printerName: string; }-
input.deviceType?"receipt_printer" | "cash_drawer" | "barcode_scanner"-
input.drawerPin?2 | 5 | nullDrawer-kick pin — on printer rows (drawer wired to the printer) or standalone cash_drawer rows.
input.make?string | null-
input.metadata?Record<string, unknown> | null-
input.model?string | null-
input.name?string-
input.paperWidthChars?32 | 35 | 42 | 44 | 48 | nullCharacter columns at the printer's default font.
input.printerLanguage?"esc-pos" | "star-prnt" | "star-line" | nullRequired for receipt printers; meaningless for scanners.
input.stationId?string | null-
input.status?"active" | "inactive"-
input.storeId?string | null-

Returns

Promise<{ 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; }>

On this page