import type { opensearchtypes } from "@opensearch-project/opensearch"; import type openapi from "openapi3-ts"; import type { BucketOptions } from "../bucket.js"; import type { Attributes } from "../entity/entity.js"; import type { CompositeKeyPart, EntityCompositeKeyPart, StreamQueryKey } from "../entity/key.js"; import type { FunctionBundleProps, FunctionRuntimeProps } from "../function-props.js"; import type { HttpMethod } from "../http-method.js"; import type { RestParams } from "../http/command.js"; import type { DurationSchedule } from "../schedule.js"; import type { SubscriptionFilter, SubscriptionRuntimeProps } from "../subscription.js"; import type { KeyDefinition } from "./entity.js"; import type { TaskSpec } from "./task.js"; /** * Specification for an Eventual application */ export interface ServiceSpec { /** * List of workflows */ workflows: WorkflowSpec[]; transactions: TransactionSpec[]; tasks: TaskSpec[]; commands: CommandSpec[]; sockets: SocketSpec[]; /** * Open API 3 schema definitions for all known Events in this Service. */ events: EventSpec[]; /** * Individually bundled {@link EventFunction}s containing a single `subscription` event handler. */ subscriptions: SubscriptionSpec[]; buckets: { buckets: BucketSpec[]; }; entities: { entities: EntitySpec[]; }; openApi: { info: openapi.InfoObject; }; search: { indices: IndexSpec[]; }; queues: QueueSpec[]; } export interface FunctionSpec { memorySize?: number; timeout?: DurationSchedule; } export interface SubscriptionSpec { /** * Unique name of this Subscription. */ name: Name; /** * Subscriptions this Event Handler is subscribed to. Any event flowing * through the Service's Event Bus that match these criteria will be * sent to this Lambda Function. */ filters: SubscriptionFilter[]; /** * Runtime configuration for this Event Handler. */ props?: SubscriptionRuntimeProps; /** * Only available during eventual-infer. */ sourceLocation?: SourceLocation; } export interface EventSpec { /** * The Event's globally unique name. */ readonly name: string; /** * An optional Schema of the Event. */ schema?: openapi.SchemaObject; } export interface CommandOutput { schema?: openapi.SchemaObject; description: string; /** * Status code of the output used in commands with a rest path. * * RPC commands always return a single 200 response. */ restStatusCode: number; } export interface CommandSpec extends FunctionRuntimeProps, FunctionBundleProps { name: Name; /** * Long description of the API, written to the description field of the generated open API spec. */ description?: string; /** * Short description of the API, written to the summary field of the generated open API spec. */ summary?: string; input?: openapi.SchemaObject; /** * Output used by RPC commands and Rest commands to define the output of the handler. * * RPC will always have a status code of 200, but can override the default description of "OK". * * The REST command will return a 200 response unless an alternative is provided. */ output?: CommandOutput; /** * Optional outputs provided by an http API command using passthrough mode. * * These commands return a {@link HttpResponse} which can define any number of outputs with custom status codes. * * The outputs are used to generate the {@link ApiSpecification}. */ outputs?: CommandOutput[]; path?: Path; method?: Method; params?: RestParams; sourceLocation?: SourceLocation; passThrough?: boolean; /** * Used to isolate rpc paths. * * /rpc[/namespace]/command */ namespace?: string; /** * Enable or disable schema validation. * * @default true */ validate?: boolean; } export declare function isSourceLocation(a: any): a is SourceLocation; export interface SourceLocation { fileName: string; exportName: string; } export interface Schemas { [schemaName: string]: openapi.SchemaObject; } export interface WorkflowSpec { /** * Globally unique ID of this {@link Workflow}. */ name: Name; } export interface BucketSpec { name: Name; handlers: BucketNotificationHandlerSpec[]; options: BucketOptions | undefined; } export interface IndexSpec extends opensearchtypes.IndicesIndexState { index: string; settings: opensearchtypes.IndicesIndexSettings; } export type BucketNotificationEventType = "put" | "copy" | "delete"; export interface BucketNotificationHandlerOptions extends FunctionRuntimeProps, FunctionBundleProps { /** * A list of operations to be send to the stream. * * @default All Operations */ eventTypes?: BucketNotificationEventType[]; /** * Filter objects in the stream by prefix or suffix. */ filters?: { prefix?: string; suffix?: string; }[]; } export interface BucketNotificationHandlerSpec { name: Name; bucketName: string; options?: BucketNotificationHandlerOptions; sourceLocation?: SourceLocation; } export interface EntitySpec { name: Name; key: KeyDefinition; /** * An Optional schema for the entity within an entity. */ attributes: openapi.SchemaObject; streams: EntityStreamSpec[]; indices: EntityIndexSpec[]; } export type EntityStreamOperation = "insert" | "modify" | "remove"; export interface EntityStreamOptions = EntityCompositeKeyPart, Sort extends EntityCompositeKeyPart | undefined = EntityCompositeKeyPart | undefined, Operations extends EntityStreamOperation[] = EntityStreamOperation[], IncludeOld extends boolean = false> extends FunctionRuntimeProps, FunctionBundleProps { /** * A list of operations to be send to the stream. * * @default All Operations */ operations?: Operations; /** * When true, the old value will be sent with the new value. */ includeOld?: IncludeOld; /** * One or more key queries that will be included in the stream. */ queryKeys?: StreamQueryKey[]; /** * Max batch size. Between 1 and 1000. * * @default: 100 */ batchSize?: number; /** * Amount of time to wait for the batch size before sending a batch. * * @default: 0 seconds. */ batchingWindow?: DurationSchedule; /** * Max age of an item before it is dropped. Duration between 1 hour and 24 hours. * * @default: 24 hours */ maxAge?: DurationSchedule; } export interface EntityStreamSpec = EntityCompositeKeyPart, Sort extends EntityCompositeKeyPart | undefined = EntityCompositeKeyPart | undefined> { name: Name; entityName: string; options?: EntityStreamOptions; sourceLocation?: SourceLocation; } export interface EntityIndexSpec { name: Name; entityName: string; key: KeyDefinition; partition?: CompositeKeyPart; sort?: CompositeKeyPart; } export interface TransactionSpec { name: Name; } /** * TODO: Support filter criteria. */ export interface QueueHandlerOptions extends FunctionRuntimeProps, FunctionBundleProps { /** * Max batch size. * * Queue - Between 1 and 10000. * Fifo Queue - Between 1 and 10 * * @default: 100 (Queue) 10 (Fifo Queue). */ batchSize?: number; /** * Amount of time to wait for the batch size before sending a batch. * * @default: 0 seconds. */ batchingWindow?: DurationSchedule; } export interface QueueHandlerSpec { options?: QueueHandlerOptions; sourceLocation?: SourceLocation; } export interface QueueSpec { contentBasedDeduplication?: boolean; delay?: DurationSchedule; encryption: boolean; fifo: boolean; handler: QueueHandlerSpec; name: Name; visibilityTimeout?: DurationSchedule; } export interface SocketSpec extends FunctionRuntimeProps, FunctionBundleProps { name: Name; sourceLocation?: SourceLocation; } //# sourceMappingURL=service-spec.d.ts.map