/// /// import { IoTDataPlaneClient } from "@aws-sdk/client-iot-data-plane"; import { S3Client } from "@aws-sdk/client-s3"; import { MetricsCollector } from './aws-metrics-collector'; export declare enum BinaryStatus { YES = "yes", NO = "no" } export declare enum AWSStatus { SUCCESS = "OK", FAILED = "FAILED" } export declare enum Criteria { GREATER_THAN = "gt", GREATER_THAN_OR_EQUAL = "ge", EQUAL = "eq", LESS_THAN_OR_EQUAL = "le", LESS_THAN = "lt" } type CommandResultPayload = { status: string; ts: number; id: string; } | { restart: AWSStatus; } | { confidence_threshold: number; } | { criteria: Criteria; } | { threshold_filter_config: object; } | { model_info: object; } | { clear_cache: object; } | { clear_cache_file: object; } | { metrics_reset: AWSStatus; }; export declare function sanitizeYesNo(value?: string): BinaryStatus; export interface ModelParams { readonly [key: string]: any; } export interface ModelInfoJSON { model_name: string; model_version: string; model_params?: ModelParams; } export declare class ModelInfo { readonly name: string; readonly version: string; readonly params?: ModelParams | undefined; constructor(name: string, version: string, params?: ModelParams | undefined); toJSON(): ModelInfoJSON; } type ClassificationResult = { [k: string]: string | number; }; type BoundingBox = { label: string; value: number; x: number; y: number; width: number; height: number; }; type FreeformResult = number[][]; type BasePayload = { time_ms: number; info?: string; id: string; ts: number; inference_count: number; total_inferences: number; s3_bucket?: string; s3_prefix?: string; }; type DynamicPayload = { [key in AwsResultKey]?: AwsResult; }; export type AwsResult = ClassificationResult | BoundingBox[] | FreeformResult; export type AwsResultKey = 'c' | 'box' | 'grid' | 'freeform'; export type Payload = BasePayload & DynamicPayload; export declare class AWSIoTCoreConnector { private static readonly DEFAULT_METRICS_COLLECTION_TIME_MS; private static readonly DEFAULT_POLLING_TIME_MS; private static readonly DEFAULT_THRESHOLD_VALUE; private static readonly DEFAULT_THRESHOLD_CRITERIA; private _notSilent; private _inferenceOutputTopic; private _metricsOutputTopic; private _commandInputTopic; private _commandOutputTopic; private _iot; private _s3Client; private readonly _clientConfig; private _iotcoreQoS; private _delayCountdown; private _delayInferences; private _pollSleepTime; private readonly _opts; private readonly _enableWriteToFile; private readonly _writeToFileDir; private _metricsCollector; private _thresholdFilter; private _modelInfo; private _metricsDispatchSleepTimeMS; private readonly _enableWriteToS3; private readonly _s3Bucket; private readonly commands; constructor(opts: { appName: string; silentArgv: boolean; cleanArgv: boolean; apiKeyArgv: string | undefined; greengrassArgv: boolean; devArgv: boolean; hmacKeyArgv: string | undefined; connectProjectMsg: string; iotClient?: IoTDataPlaneClient; s3Client?: S3Client; }); sanitizeString(value: string): string; sanitizeDelayInferences(value: number): number; sanitizeQoS(value: number): number; private sanitizeThresholdValue; private sanitizeThresholdCriteria; initThresholdFilter(): void; initModelInfo(modelName: string, modelVersion: string, modelParams?: ModelParams): void; private s3Init; connect(): Promise; isConnected(): boolean; isEmptyInference(payload: Payload, key: AwsResultKey): boolean; initializeAsyncCollectors(): void; private clearRetainedQueue; processRestartCommand(): void; dispatchMetricsCollector(sleepMS: number): Promise; resetMetrics(): CommandResultPayload; dispatchCommandListener(topic: string | undefined, longPollSleepMS: number): Promise; private processCommand; private handleRestartCommand; private handleGetThresholdFilterConfidenceCommand; private handleSetThresholdFilterConfidenceCommand; private handleGetThresholdFilterCriteriaCommand; private handleSetThresholdFilterCriteriaCommand; private handleEnableThresholdFilterCommand; private handleDisableThresholdFilterCommand; private handleGetThresholdFilterConfigCommand; private handleGetModelInfoCommand; private handleClearCacheCommand; private handleClearFileInCacheCommand; private handleResetMetricsCommand; private logWarning; private logInfo; private logError; private sleep; sendCommandResult(payload: CommandResultPayload): Promise; updateInferenceMetrics(confidences: number[]): void; /** * Sends model metrics to IoT Core using the configured metrics topic * @param metrics The metrics payload to send (typically from MetricsCollector.toJSON()) * @returns Promise that resolves when the message is sent or rejects on error */ sendModelMetrics(metrics: MetricsCollector): Promise; saveToFile(payload: Payload, imgAsJpg: Buffer): Promise; createS3Prefix(): string; saveToS3(payload: Payload, imgAsJpg: Buffer): Promise; localFileCacheClearFileByUUID(uuid: string): Promise; s3CacheClearByUUID(uuid: string): Promise; localFileCacheClear(): Promise; s3CacheClear(): Promise; cacheInferenceImageAndJSON(payload: Payload, imgAsJpg: Buffer): Promise<{ local: AWSStatus; s3: AWSStatus; uuid: string; }>; cacheClearInferenceAndImageByUUID(uuid: string): Promise<{ local: AWSStatus; s3: AWSStatus; uuid: string; }>; cacheClear(): Promise<{ local: AWSStatus; s3: AWSStatus; }>; sendInference(meanConfidence: number, payload: Payload, key: AwsResultKey, imgAsJpg?: Buffer): Promise; } export {};