@types/aws-cloudfront-function
Advanced tools
Comparing version
@@ -56,1 +56,176 @@ declare namespace AWSCloudFrontFunction { | ||
} | ||
declare module "cloudfront" { | ||
/** | ||
* Retrieves a reference to a CloudFront Key-Value Store (KVS) by its ID. | ||
* @param kvsId The identifier of the KVS to use. | ||
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-custom-methods.html | ||
*/ | ||
function kvs(kvsId: string): KVStore; | ||
interface KVStore { | ||
/** | ||
* Retrieve a value from the store. | ||
* @param key Key to retrieve. | ||
* @throws If key does not exist. | ||
*/ | ||
get(key: string): Promise<string>; | ||
get(key: string, options: { format: "string" }): Promise<string>; | ||
get(key: string, options: { format: "bytes" }): Promise<Uint8Array>; | ||
get(key: string, options: { format: "json" }): Promise<unknown>; | ||
/** | ||
* Check if the key exists in the store. | ||
* @param key Key to check. | ||
*/ | ||
exists(key: string): Promise<boolean>; | ||
/** | ||
* Retrieve metadata about the key-value store. | ||
*/ | ||
meta(): Promise<{ | ||
creationDateTime: string; | ||
lastUpdatedDateTime: string; | ||
keyCount: number; | ||
}>; | ||
} | ||
interface OriginAccessControlConfig { | ||
enabled: boolean; | ||
signingBehavior: "always" | "never" | "no-override"; | ||
signingProtocol: "sigv4"; | ||
originType: "s3" | "mediapackagev2" | "mediastore" | "lambda"; | ||
} | ||
interface OriginShield { | ||
enabled: boolean; | ||
region: string; | ||
} | ||
interface Timeouts { | ||
/** | ||
* Max time (seconds) to wait for a response or next packet. (1–60) | ||
*/ | ||
readTimeout?: number; | ||
/** | ||
* Max time (seconds) to keep the connection alive after response. (1–60) | ||
*/ | ||
keepAliveTimeout?: number; | ||
/** | ||
* Max time (seconds) to wait for connection establishment. (1–10) | ||
*/ | ||
connectionTimeout?: number; | ||
} | ||
interface CustomOriginConfig { | ||
/** | ||
* Port number of the origin. e.g., 80 or 443 | ||
*/ | ||
port: number; | ||
/** | ||
* Protocol used to connect. Must be "http" or "https" | ||
*/ | ||
protocol: "http" | "https"; | ||
/** | ||
* Minimum TLS/SSL version to use for HTTPS connections. | ||
*/ | ||
sslProtocols: Array<"SSLv3" | "TLSv1" | "TLSv1.1" | "TLSv1.2">; | ||
} | ||
interface UpdateRequestOriginParams { | ||
/** | ||
* New origin's domain name. Optional if reusing existing origin's domain. | ||
*/ | ||
domainName?: string; | ||
/** | ||
* Path prefix to append when forwarding request to origin. | ||
*/ | ||
originPath?: string; | ||
/** | ||
* Override or clear custom headers for the origin request. | ||
*/ | ||
customHeaders?: Record<string, string>; | ||
/** | ||
* Number of connection attempts (1–3). | ||
*/ | ||
connectionAttempts?: number; | ||
/** | ||
* Origin Shield configuration. Enables shield layer if specified. | ||
*/ | ||
originShield?: OriginShield; | ||
/** | ||
* Origin Access Control (OAC) configuration. | ||
*/ | ||
originAccessControlConfig?: OriginAccessControlConfig; | ||
/** | ||
* Response and connection timeout configurations. | ||
*/ | ||
timeouts?: Timeouts; | ||
/** | ||
* Settings for non-S3 origins or S3 with static website hosting. | ||
*/ | ||
customOriginConfig?: CustomOriginConfig; | ||
} | ||
/** | ||
* Mutates the current request’s origin. | ||
* You can specify a new origin (e.g., S3 or ALB), change custom headers, enable OAC, or enable Origin Shield. | ||
* Missing fields will inherit values from the assigned origin. | ||
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/helper-functions-origin-modification.html#update-request-origin-helper-function | ||
*/ | ||
function updateRequestOrigin(params: UpdateRequestOriginParams): void; | ||
/** | ||
* Switches to another origin already defined in the distribution by origin ID. | ||
* This is more efficient than defining a new one via `updateRequestOrigin()`. | ||
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/helper-functions-origin-modification.html#select-request-origin-id-helper-function | ||
*/ | ||
function selectRequestOriginById(originId: string): void; | ||
interface CreateRequestOriginGroupParams { | ||
/** | ||
* Two origin IDs to form an origin group. | ||
* The first is primary; the second is used for failover. | ||
*/ | ||
originIds: [string, string]; | ||
/** | ||
* Failover selection strategy: default or media-quality-score. | ||
*/ | ||
selectionCriteria?: "default" | "media-quality-score"; | ||
/** | ||
* List of status codes that trigger failover to the secondary origin. | ||
*/ | ||
failoverCriteria: { | ||
statusCodes: number[]; | ||
}; | ||
} | ||
/** | ||
* Creates a new origin group for failover logic. | ||
* The origin group can be referenced later via origin ID. | ||
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/helper-functions-origin-modification.html#create-request-origin-group-helper-function | ||
*/ | ||
function createRequestOriginGroup(params: CreateRequestOriginGroupParams): void; | ||
const cf: { | ||
kvs: typeof kvs; | ||
updateRequestOrigin: typeof updateRequestOrigin; | ||
selectRequestOriginById: typeof selectRequestOriginById; | ||
createRequestOriginGroup: typeof createRequestOriginGroup; | ||
}; | ||
export default cf; | ||
} |
{ | ||
"name": "@types/aws-cloudfront-function", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "TypeScript definitions for aws-cloudfront-function", | ||
@@ -23,5 +23,6 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-cloudfront-function", | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "1305cfdee7f529d7046bae89520a97ff99003b0b6718577dd06a8a4c2f7b4cb1", | ||
"typeScriptVersion": "4.5", | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "b6c4e2382b6890262e8b02f51ca1e8013f4cf18659430d2793a6aef81505d6f9", | ||
"typeScriptVersion": "5.1", | ||
"nonNpm": true | ||
} |
@@ -9,64 +9,5 @@ # Installation | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-cloudfront-function. | ||
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-cloudfront-function/index.d.ts) | ||
````ts | ||
declare namespace AWSCloudFrontFunction { | ||
interface Event { | ||
version: "1.0"; | ||
context: Context; | ||
viewer: Viewer; | ||
request: Request; | ||
response: Response; | ||
} | ||
interface Context { | ||
distributionDomainName: string; | ||
distributionId: string; | ||
eventType: "viewer-request" | "viewer-response"; | ||
requestId: string; | ||
} | ||
interface Viewer { | ||
ip: string; | ||
} | ||
interface Request { | ||
method: string; | ||
uri: string; | ||
querystring: ValueObject; | ||
headers: ValueObject; | ||
cookies: ValueObject; | ||
} | ||
interface Response { | ||
statusCode: number; | ||
statusDescription?: string; | ||
headers?: ValueObject; | ||
cookies?: ResponseCookie; | ||
} | ||
interface ValueObject { | ||
[name: string]: { | ||
value: string; | ||
multiValue?: Array<{ | ||
value: string; | ||
}>; | ||
}; | ||
} | ||
interface ResponseCookie { | ||
[name: string]: { | ||
value: string; | ||
attributes: string; | ||
multiValue?: Array<{ | ||
value: string; | ||
attributes: string; | ||
}>; | ||
}; | ||
} | ||
} | ||
```` | ||
### Additional Details | ||
* Last updated: Mon, 06 Nov 2023 22:41:04 GMT | ||
* Last updated: Tue, 20 May 2025 23:33:31 GMT | ||
* Dependencies: none | ||
@@ -73,0 +14,0 @@ |
9375
83.39%196
300%16
-78.67%