@altostra/core
Version:
Core library for shared types and logic
98 lines (97 loc) • 3.66 kB
TypeScript
import type { DNSName } from "../../common/CustomTypes/DNSName";
import type { NonEmptyString } from "../../common/CustomTypes/NonEmptyString";
import type { Integer, NaturalNumber } from "../../common/CustomTypes/Numerics";
import type { AwsResourceCommon, ExtendedSwagger2Definition, S3Location } from "../CloudFormation";
import type { MethodSetting } from "../CloudFormation/ApiGateway/common";
import type { CloudFormationValue } from "../CloudFormation/IntrinsicFunctions";
import type { Arn } from "../CustomTypes/Arn";
import type { ServerlessTags } from "./common";
export declare type ApiType = 'AWS::Serverless::Api';
export interface Api extends AwsResourceCommon {
Type: ApiType;
Properties: ApiProperties;
}
export interface ApiProperties {
Name?: string;
StageName: string;
DefinitionUri?: S3Location | string;
DefinitionBody?: ExtendedSwagger2Definition;
MergeDefinitions?: boolean;
Variables?: Record<string, string>;
MethodSettings?: MethodSetting[];
EndpointConfiguration?: EndpointConfiguration | string;
BinaryMediaTypes?: string[];
Cors?: CorsConfiguration | string;
Auth?: ApiAuth;
Domain?: DomainConfiguration;
MinimumCompressionSize?: number | null;
Tags?: ServerlessTags;
}
export interface CorsConfiguration {
AllowOrigin: string;
AllowMethods?: string;
AllowHeaders?: string;
MaxAge?: string;
}
export interface EndpointConfigurationPublic {
Type: EndpointConfigurationType;
}
export interface EndpointConfigurationPrivate {
Type: 'PRIVATE';
VPCEndpointIds: CloudFormationValue<string>[];
}
export declare type EndpointConfiguration = EndpointConfigurationPrivate | EndpointConfigurationPublic;
export declare type EndpointConfigurationType = 'EDGE' | 'REGIONAL';
export interface DomainConfiguration {
BasePath?: string[];
CertificateArn: CloudFormationValue<Arn>;
DomainName: CloudFormationValue<DNSName>;
EndpointConfiguration?: EndpointConfigurationType;
}
export interface ApiAuth {
AddDefaultAuthorizerToCorsPreflight?: boolean;
ApiKeyRequired?: boolean;
Authorizers?: Record<string, Authorizer>;
DefaultAuthorizer?: string;
InvokeRole?: InvokeRole;
ResourcePolicy?: object;
UsagePlan?: object;
}
export interface AuthorizerBase {
AuthorizationScopes?: string[];
}
export interface CognitoAuthorizer extends AuthorizerBase {
Identity?: CognitoAuthorizerIdentity;
UserPoolArn: CloudFormationValue<Arn>;
}
export interface CognitoAuthorizerIdentity {
Header?: NonEmptyString;
ReauthorizeEvery?: Integer;
ValidationExpression?: string;
}
export interface LambdaAuthorizerBase extends AuthorizerBase {
FunctionArn: CloudFormationValue<Arn>;
FunctionInvokeRole?: string;
FunctionPayloadType?: 'REQUEST' | 'TOKEN';
}
export interface LambdaTokenAuthorizer extends LambdaAuthorizerBase {
FunctionPayloadType?: 'TOKEN';
Identity?: LambdaTokenAuthorizationIdentity;
}
export interface LambdaTokenAuthorizationIdentity {
ReauthorizeEvery?: NaturalNumber | 0;
ValidationExpression?: string;
}
export interface LambdaRequestAuthorizer extends LambdaAuthorizerBase {
FunctionPayloadType: 'REQUEST';
Identity?: LambdaRequestAuthorizationIdentity;
}
export interface LambdaRequestAuthorizationIdentity {
ReauthorizeEvery?: NaturalNumber | 0;
Context?: string[];
Headers?: string[];
QueryStrings?: string[];
StageVariables?: string[];
}
export declare type Authorizer = CognitoAuthorizer | LambdaRequestAuthorizer | LambdaTokenAuthorizer;
export declare type InvokeRole = CloudFormationValue<Arn> | 'CALLER_CREDENTIALS' | 'NONE';