import { APIGatewayProxyResult } from "aws-lambda"; import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"; export declare const commonHeaders: { "Access-Control-Allow-Origin": string; "Access-Control-Allow-Credentials": boolean; "Cache-Control": string; }; export interface GeoprocessingTask { id: string; service: string; location: string; startedAt: string; duration?: number; logUriTemplate: string; geometryUri: string; status: GeoprocessingTaskStatus; /** websocket url */ wss: string; data?: ResultType; error?: string; estimate: number; disableCache?: boolean; } export interface MetricGroupItem { duration?: number; status: GeoprocessingTaskStatus; data?: ResultType; } export interface RootTaskItem extends MetricGroupItem { metricGroupItems: string[]; } export declare enum GeoprocessingTaskStatus { Pending = "pending", Completed = "completed", Failed = "failed" } /** * Task model responsible for managing task results and estimates in DynamoDB */ export default class TasksModel { /** task table */ table: string; /** task estimate table */ estimatesTable: string; /** database client */ db: DynamoDBDocument; constructor(table: string, estimatesTable: string, db: DynamoDBDocument); init(service: string, id?: string, /** websocket url */ wss?: string, startedAt?: string, duration?: number, status?: GeoprocessingTaskStatus): GeoprocessingTask; create(service: string, options?: { /** Unique identifier for this task, used as cache key. If not provided a uuid is created */ id?: string; /** websocket url */ wss?: string; disableCache?: boolean; }): Promise>; /** * @param task * @param results - JSON serializable object, with no string larger than 400KB without a space character. Spaces are used to chunk result * @param options * @returns */ complete(task: GeoprocessingTask, results: any, options?: { minSplitSizeBytes?: number; }): Promise; updateEstimate(task: GeoprocessingTask): Promise; fail(task: GeoprocessingTask, errorDescription: string, error?: Error): Promise; get(service: string, taskId: string): Promise; getMeanEstimate(task: GeoprocessingTask): Promise; /** * Transform valid JSON object into string and break into pieces no larger than minSplitSizeBytes * @param rootResult * @param minSplitSizeBytes maximum return substring size in bytes (default 350KB, below 400KB dynamodb limit) * @returns array of JSON substrings, in order for re-assembly */ private toJsonStrings; /** * Given array of partial JSON strings, joins them together and parses the result */ private fromJsonStrings; }