import { BaseResponsiveProps } from "../../../responsive/type.js"; import { VendingBoard, VendingBoardMapping, VendingMachineConfiguration } from "./vendingConfiguration.js"; import React from "react"; //#region src/plus/saasDevice/appPeripheral/types.d.ts type DeviceKind = 'smart' | 'dumb' | 'integrated'; type DeviceStructure = 'standalone' | 'composite' | 'component' | string; type DeviceLinkStatus = 'linked' | 'unlinked' | string; type DeviceOnlineStatus = 'online' | 'offline' | 'unknown' | string; /** 多语言字段,后端可能返回字符串或语言字典。 */ type I18nText = string | { original?: string; 'zh-CN'?: string; 'zh-HK'?: string; en?: string; ja?: string; pt?: string; [key: string]: any; }; interface LockerMappingConnection { connectionId: number; sourceDeviceId: number; targetDeviceId: number; uuid: string; } type SmartLockerDoorMapping = Record; type SmartLockerBoardMapping = Record; interface LockerMappingGroup { id: string; name: string; boardId?: number; /** Earlier POS versions return the individual door addresses. */ doors?: { id: string; name: string; address?: SmartLockerDoorMapping[string]; }[]; } interface PeripheralNfcConfig { type: string; config: { sector: number; blockIndex: number; keyA?: string; keyB?: string; keyType?: 'A' | 'B'; dataFormat?: 'raw' | 'checked'; timeoutMs?: number; }; } type CardDispenserEjectMode = 'hold' | 'full'; interface PeripheralSettings { eject_mode?: CardDispenserEjectMode; nfc_configs?: PeripheralNfcConfig[]; [setting: string]: unknown; } /** 外设生命周期通知使用已提交的连接身份,删除后无需再查询绑定。 */ interface PeripheralLifecyclePayload { connectionId: number; sourceDeviceId: number; targetDeviceId: number; typeCode: string; physicalUuid?: string; } interface SaasAppPeripheralProps extends BaseResponsiveProps { /** undefined while the shop is loading; [] for a shop with no NFC defaults. */ nfcConfigs?: PeripheralNfcConfig[]; className?: string; style?: React.CSSProperties; showBack?: boolean; onBack?: () => void; onManageProfiles?: () => void; onTest?: (payload: PeripheralTestPayload) => void | Promise; /** 物理连接及必要设置保存成功后通知;回调失败不影响连接和设置。 */ onDone?: (payload: PeripheralLifecyclePayload) => void | Promise; /** 删除/forget 接口成功后、原生 remove 前通知;回调失败不阻断清理。 */ onDelete?: (payload: PeripheralLifecyclePayload) => void | Promise; /** 初始化校准及本地绑定保存完成后通知;与用户主动完成设置的 onDone 独立。 */ onCalibrated?: (payload: { sourceDeviceId: number; }) => void | Promise; lockerMappingAction?: { label: string; open: (connection: LockerMappingConnection) => void; loadSummary?: (connection: LockerMappingConnection, signal: AbortSignal) => Promise; }; /** 云端及本地组件绑定删除成功后的宿主通知,不负责原生 remove。 */ onComponentDeleted?: (payload: { connectionId: number; physicalUuid?: string; }) => void | Promise; } interface WorkAreaItem { id: number; tenant_id?: number; name: I18nText; description?: I18nText; sort: number; smart_devices_count?: number; dumb_devices_count?: number; integrated_devices_count?: number; created_at?: string; updated_at?: string; } interface DeviceBrandItem { id: number; code: string; name: I18nText; description?: I18nText; website?: string; status?: string; created_at?: string; updated_at?: string; deleted_at?: string | null; } interface DeviceTypeItem { id: number; kind: DeviceKind; code: string; icon?: string | null; name: I18nText; description?: I18nText; status?: string; sort?: number; active_models?: DeviceModelItem[]; } interface DeviceModelItem { id: number; brand_code?: string; type_code: string; type?: DeviceTypeItem; code: string; name: I18nText; description?: I18nText; data?: { profile_structure?: { required?: boolean; tabs?: unknown[]; }; connection_types?: string[]; [key: string]: unknown; } | null; status?: string; sort?: number; active_profiles?: DeviceProfileItem[]; brand?: DeviceBrandItem; } interface DeviceProfileItem { id: number; model_code?: string; template_code?: string; name?: I18nText; description?: I18nText; setting?: Record | null; status?: string; } interface DeviceItem { id: number; tenant_id?: number; workarea_id?: number; type_kind: DeviceKind; structure?: DeviceStructure; type_code: string; model_code: string; profile_id?: number | null; number?: string; name: I18nText; description?: I18nText | null; data?: Record | null; setting?: Record | null; link?: DeviceLinkStatus; status?: DeviceOnlineStatus; sort?: number; last_seen?: string; created_at?: string; updated_at?: string; type?: DeviceTypeItem; model?: DeviceModelItem; profile?: DeviceProfileItem | null; workarea?: WorkAreaItem; } interface DeviceConnectionConfig { connection_ip?: string; connection_type?: string; connection_method?: string; [key: string]: unknown; } type PeripheralConnectType = 'USB' | 'ETHERNET' | 'WIFI' | 'BLUETOOTH' | 'SERIAL' | 'SYSTEM'; type PeripheralUsage = 'label' | 'wristband'; /** 外设插件透传的扩展信息。 */ interface PeripheralDeviceMetadata extends Record { /** 原生细分设备类型,与 findList 入参 deviceType 一致;非空时优先精确匹配。 */ device_category?: string | null; /** 旧版设备类型;缺少有效 device_category 时保留原有大类匹配。 */ device_type?: string | null; /** 设备可能已被其他设备关联;仅明确为 true 时需要二次确认。 */ possibly_associated?: boolean; } /** 外设插件返回的物理设备结构,保持为宿主插件的最小兼容子集。 */ interface PeripheralDevice { boards?: VendingBoard[]; uuid: string; ip?: string; port?: string; mac?: string; is_connect: boolean; name: string; connect_type: PeripheralConnectType; status_code: string; metadata?: PeripheralDeviceMetadata; [key: string]: unknown; } /** 测试按钮对外透出的通用载荷,不绑定 POS 侧的打印机模型。 */ interface PeripheralTestPayload { vendingMachines?: VendingMachineConfiguration[]; vendingBoardMapping?: VendingBoardMapping; connection: DeviceConnectionItem; targetDevice?: DeviceItem | null; physicalDevice?: PeripheralDevice; peripheralUsage?: PeripheralUsage; } /** 设备连接业务类型;外设使用 `dumb`,内置组件使用 `component`。 */ type DeviceConnectionType = 'dumb' | 'component'; interface DeviceConnectionItem { id: number; tenant_id?: number; type?: DeviceConnectionType; source_device_id: number; target_device_id: number; data?: Record | null; config?: DeviceConnectionConfig | null; profile_ids?: number[]; status?: string | null; created_at?: string; updated_at?: string; source_device?: DeviceItem | null; target_device?: DeviceItem | null; profiles?: DeviceProfileItem[]; } //#endregion export { LockerMappingConnection, PeripheralLifecyclePayload, PeripheralNfcConfig, PeripheralSettings, SaasAppPeripheralProps, SmartLockerBoardMapping, SmartLockerDoorMapping };