UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

110 lines (103 loc) 4.66 kB
import { IManagedObject, IExternalIdentity, IdentityService, InventoryService, IIdentified } from '@c8y/client'; import { DashboardMetadata } from '@c8y/ngx-components/context-dashboard'; import { WidgetImportExportInjectorOptions } from '@c8y/ngx-components'; type ExportedAsset = IManagedObject & { externalIdentity: IExternalIdentity; }; type ImportedAsset = IManagedObject & { suggestedDevice: IManagedObject | null; }; declare function getExternalIdentityByTargetId(targetId: string | number, identityService: IdentityService): Promise<IExternalIdentity>; declare function targetDetails(targetId: string | number, inventoryService: InventoryService): Promise<IManagedObject>; declare function resolveSuggestedAsset(exportedDevice: ExportedAsset, contextDevice: IManagedObject): Promise<IManagedObject | null>; /** * Interface for any configuration that has a device property */ interface ConfigWithAsset { device?: IManagedObject | null; [key: string]: any; } /** * Configuration with exported asset information */ type ExportedConfigWithAsset<T extends ConfigWithAsset = ConfigWithAsset> = Omit<T, 'device'> & { device?: ExportedAsset | null; }; /** * Configuration with imported asset information */ type ImportedConfigWithAsset<T extends ConfigWithAsset = ConfigWithAsset> = Omit<T, 'device'> & { device?: ImportedAsset | null; }; /** * Check if a configuration has a valid device property */ declare function hasAssetProperty(config: any): config is ConfigWithAsset; /** * Exports a configuration with asset information enriched for export */ declare function exportConfigWithDevice<T extends ConfigWithAsset>(config: T, _dashboardData: DashboardMetadata, _options: WidgetImportExportInjectorOptions): Promise<ExportedConfigWithAsset<T>>; /** * Imports a configuration with asset information adapted to the current context */ declare function importConfigWithDevice<T extends ConfigWithAsset>(config: ExportedConfigWithAsset<T>, dashboardData: DashboardMetadata, _options: WidgetImportExportInjectorOptions): Promise<ImportedConfigWithAsset<T>>; /** * Type for any object that has a __target property */ interface WithTarget { __target: IIdentified | null; [key: string]: any; } /** * Represents a target-based object with export information */ type ExportedTargetObject<T extends WithTarget = WithTarget> = Omit<T, '__target'> & { __target: ExportedAsset; }; /** * Represents a target-based object with import information */ type ImportedTargetObject<T extends WithTarget = WithTarget> = Omit<T, '__target'> & { __target: ImportedAsset; }; /** * Helper type to identify arrays of objects with __target property */ type TargetObjectArray = WithTarget[]; /** * Transforms a type to replace arrays of objects with __target property to ExportedTargetObject[] */ type WithExportedTargets<T> = { [K in keyof T]: T[K] extends TargetObjectArray ? ExportedTargetObject<T[K][number]>[] : T[K]; }; /** * Transforms a type to replace arrays of objects with __target property to ImportedTargetObject[] */ type WithImportedTargets<T> = { [K in keyof T]: T[K] extends TargetObjectArray ? ImportedTargetObject<T[K][number]>[] : T[K]; }; /** * Generic config type that can have any properties with target objects */ interface ConfigWithTargets { [key: string]: any; } /** * Configuration type with target objects prepared for export */ type ExportedConfigWithTargets<T extends ConfigWithTargets = ConfigWithTargets> = WithExportedTargets<T>; /** * Configuration type with target objects prepared for import */ type ImportedConfigWithTargets<T extends ConfigWithTargets = ConfigWithTargets> = WithImportedTargets<T>; /** * Exports widget configuration with all target objects transformed for export */ declare function exportConfigWithTargets<T extends ConfigWithTargets>(config: T, _dashboardData: DashboardMetadata, _options: WidgetImportExportInjectorOptions): Promise<ExportedConfigWithTargets<T>>; /** * Imports widget configuration with all target objects transformed for the current context */ declare function importConfigWithTargets<T extends ConfigWithTargets>(config: ExportedConfigWithTargets<T>, dashboardData: DashboardMetadata, _options: WidgetImportExportInjectorOptions): Promise<ImportedConfigWithTargets<T>>; export { exportConfigWithDevice, exportConfigWithTargets, getExternalIdentityByTargetId, hasAssetProperty, importConfigWithDevice, importConfigWithTargets, resolveSuggestedAsset, targetDetails }; export type { ConfigWithAsset, ExportedAsset, ExportedConfigWithAsset, ImportedAsset, ImportedConfigWithAsset }; //# sourceMappingURL=index.d.ts.map