From a1e00a3734596b1d286a77b1a5844d92afaf56c4 Mon Sep 17 00:00:00 2001 From: wangshuaiswim Date: Thu, 12 Jan 2023 17:56:05 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=92=8C=E4=BA=A7=E5=93=81typing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/device/Instance/typings.d.ts | 84 ++++++++++++ src/views/device/Product/typings.d.ts | 179 +++++++++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 src/views/device/Instance/typings.d.ts create mode 100644 src/views/device/Product/typings.d.ts diff --git a/src/views/device/Instance/typings.d.ts b/src/views/device/Instance/typings.d.ts new file mode 100644 index 00000000..2fbe7f1c --- /dev/null +++ b/src/views/device/Instance/typings.d.ts @@ -0,0 +1,84 @@ +export type DeviceInstance = { + id: string; + name: string; + describe: string; + description: string; + productId: string; + productName: string; + protocolName: string; + security: any; + deriveMetadata: string; + metadata: string; + binds: any; + state: { + value: string; + text: string; + }; + creatorId: string; + creatorName: string; + createTime: number; + registryTime: string; + disabled?: boolean; + aloneConfiguration?: boolean; + deviceType: { + value: string; + text: string; + }; + transportProtocol: string; + messageProtocol: string; + orgId: string; + orgName: string; + configuration: Record; + relations?: any[]; + cachedConfiguration: any; + transport: string; + protocol: string; + address: string; + registerTime: number; + onlineTime: string | number; + offlineTime: string | number; + tags: any; + photoUrl: string; + independentMetadata?: boolean; + accessProvider?: string; + accessId?: string; + features?: any[]; + parentId?: string; + classifiedName?: string; +}; + +type Unit = { + id: string; + name: string; + symbol: string; + text: string; + type: string; + value: string; + description: string; +}; + +type PropertyData = { + data: { + value?: + | { + formatValue: string; + property: string; + value: any; + } + | any; + timeString: string; + timestamp: number; + formatValue: string; + property: string; + }; +}; + +type InstanceModel = { + current: Partial; + detail: Partial; + config: any; + metadataItem: MetadataItem; + params: Set; // 处理无限循环Card + active?: string; // 当前编辑的Card + selectedRows: Map; +} \ No newline at end of file diff --git a/src/views/device/Product/typings.d.ts b/src/views/device/Product/typings.d.ts new file mode 100644 index 00000000..d7b9c831 --- /dev/null +++ b/src/views/device/Product/typings.d.ts @@ -0,0 +1,179 @@ +import type { BaseItem, State } from '@/utils/typings'; + +type DeviceType = { + text: string; + value: string; +}; + +export type ProductItem = { + id: string; + name: string; + classifiedId: string | string[]; + classifiedName: string; + configuration: Record; + createTime: number; + updateTime: number; + creatorId: string; + deviceType: DeviceType; + deviceTypeId?: string; + count?: number; + messageProtocol: string; + metadata: string; + orgId: string; + protocolName: string; + state: number; + transportProtocol: string; + describe?: string; + accessId?: string; + accessName?: string; + photoUrl?: string; + storePolicy?: string; + accessProvider?: string; + modifyTime?: string; +}; + +export type ConfigProperty = { + property: string; + name: string; + description: string; + type: { + name: string; + id: string; + type: string; + elements?: any[]; + expands?: any; + }; + scopes: any[]; +}; + +export type ConfigMetadata = { + name: string; + description: string; + scopes: any[]; + properties: ConfigProperty[]; +}; + +export type MetadataType = 'events' | 'functions' | 'properties' | 'tags'; + +export type DeviceMetadata = { + events: Partial[]; + properties: Partial[]; + functions: Partial[]; + tags: Partial[]; +}; +export type MetadataItem = Partial & + Record; + +type EventMetadata = { + id: string; + name: string; + expands?: { + eventType?: string; + level?: string; + } & Record; + valueType: { + type: string; + properties: { + id: string; + name: string; + dataType: string; + valueType: { + type: string; + } & Record; + }[]; + }; + description: string; +}; +type FunctionMetadata = { + id: string; + name: string; + async: boolean; + output: Record; + inputs: ({ + id: string; + name: string; + valueType: { + type: string; + } & Record; + } & Record)[]; +}; +type PropertyMetadata = { + id: string; + name: string; + dataType?: string; + valueType: { + type: string; + } & Record; + expands: Record; + description?: string; + // 运行状态处需要数据 + list?: Record[]; +}; +type TagMetadata = { + id: string; + name: string; + valueType: { + type: string; + } & Record; + expands: Record; +}; + +type AlarmRule = { + actions: { + configuration: Record; + executor: string; + }[]; + productId: string; + productName: string; + properties: Record[]; + shakeLimit: Record; + triggers: Record[]; +} & BaseItem; + +type AlarmSetting = { + state: State; + createTime: number; + target: string; + targetId: string; + alarmRule: AlarmRule[]; +} & BaseItem; + +type AlarmRecord = { + id: string; + alarmId: string; + alarmName: string; + alarmTime: number; + description: string; + deviceId: string; + deviceName: string; + productId: string; + productName: string; + state: string; + updateTime: number; + alarmData: { + alarmId: string; + alarmName: string; + deviceId: string; + deviceName: string; + id: string; + productId: string; + productName: string; + timestamp: number; + } & Record; +}; + +type UnitType = { + id: string; + name: string; + description: string; + symbol: string; + text: string; + type: string; + value: string; +}; + +type ObserverMetadata = { + type: unknown[]; + subscribe: (data: any) => void; + next: (data: any) => void; +};