@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
74 lines (73 loc) • 3.89 kB
TypeScript
import { Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import { CloudFrontWebDistribution } from "aws-cdk-lib/aws-cloudfront";
import { Manifest, GeoprocessingFunctionMetadata, ProcessingFunctionMetadata } from "../manifest.js";
import { RestApi } from "aws-cdk-lib/aws-apigateway";
import { WebSocketApi } from "aws-cdk-lib/aws-apigatewayv2";
import { GpPublicBuckets, GpProjectFunctions, GpDynamoTables, SyncFunctionWithMeta, AsyncFunctionWithMeta, ProcessingFunctions } from "./types.js";
import { Bucket } from "aws-cdk-lib/aws-s3";
import { LambdaStack } from "./LambdaStack.js";
import { Function } from "aws-cdk-lib/aws-lambda";
/** StackProps extended with geoprocessing project metadata */
export interface GeoprocessingStackProps extends StackProps {
/** Name of the geoprocessing project */
projectName: string;
/** Path to top-level of geoprocessing project */
projectPath: string;
/** Manifest used to figure out what resources should be created for this stack */
manifest: Manifest;
/** maximum number of functions to allow per LambdaStack */
functionsPerStack?: number;
/** State of function stacks if already deployed (by function title) */
existingFunctionStacks?: string[][];
/** State of worker stacks if already deployed (by function title) */
existingWorkerStacks?: string[][];
}
/**
* A geoprocessing project is deployed as a single monolithic stack using CloudFormation.
* The stack inspects the manifest and creates stack resources
* Supports functions being sync or async in executionMode and preprocessor or geoprocessor in purpose
* Async + preprocessor combination is not supported
* Each project gets one API gateway, s3 bucket, and db table for tracking tasks and function run timeestimates
* If async functions also get a socket subscriptions db table and web socket machinery
* Each function gets a lambda and rest endpoint for sync mode, or a set of lambdas (start + run) for async mode
*/
export declare class GeoprocessingStack extends Stack {
props: GeoprocessingStackProps;
publicBuckets: GpPublicBuckets;
tables: GpDynamoTables;
projectFunctions: GpProjectFunctions;
restApi: RestApi;
socketApi?: WebSocketApi;
clientBucket?: Bucket;
clientDistribution?: CloudFrontWebDistribution;
lambdaStacks: LambdaStack[];
constructor(scope: Construct, id: string, props: GeoprocessingStackProps);
hasClients(): boolean;
/** Return metadata for all PreprocessingHandlers and sync GeoprocessingHandlers in manifest */
getSyncFunctionMetas(): ProcessingFunctionMetadata[];
/** Return metadata for all async GeoprocessingHandlers in manifest */
getAsyncFunctionMetas(): GeoprocessingFunctionMetadata[];
/** Returns true if manifest has sync functions metadata for all PreprocessingHandlers and GeoprocessingHandlers in manifest */
hasSyncFunctions(): boolean;
hasAsyncFunctions(): boolean;
/** aggregate and return sync lambda function meta from lambda stacks */
getSyncFunctionsWithMeta(): SyncFunctionWithMeta[];
/**
* @returns run functions across all lambda stacks
*/
getAsyncRunLambdas(): Function[];
/**
* @returns async lambda function meta from all lambda stacks
*/
getAsyncFunctionsWithMeta(): AsyncFunctionWithMeta[];
/** Returns true if sync function with meta and narrows type */
isSyncFunctionWithMeta(funcWithMeta: any): funcWithMeta is SyncFunctionWithMeta;
/** Returns true if async function with meta and narrows type */
isAsyncFunctionWithMeta(funcWithMeta: any): funcWithMeta is AsyncFunctionWithMeta;
getProcessingFunctions(): ProcessingFunctions;
}
/**
* Returns root lambda handler method pointer in module.function dot notation
*/
export declare function getHandlerPointer(funcMeta: ProcessingFunctionMetadata): string;