diff --git a/types/aws-cloudfront-function/aws-cloudfront-function-tests.ts b/types/aws-cloudfront-function/aws-cloudfront-function-tests.ts index b5da066f0a0c0f..4f11a8637c4017 100644 --- a/types/aws-cloudfront-function/aws-cloudfront-function-tests.ts +++ b/types/aws-cloudfront-function/aws-cloudfront-function-tests.ts @@ -137,6 +137,10 @@ function handler2(event: AWSCloudFrontFunction.Event): AWSCloudFrontFunction.Req import cf from "cloudfront"; +// $ExpectType KVStore +cf.kvs(); + +// $ExpectType KVStore const kvsHandle = cf.kvs("example-kvs-id"); async function handler3( diff --git a/types/aws-cloudfront-function/index.d.ts b/types/aws-cloudfront-function/index.d.ts index aad317719bfc16..181ced62628402 100644 --- a/types/aws-cloudfront-function/index.d.ts +++ b/types/aws-cloudfront-function/index.d.ts @@ -62,9 +62,21 @@ 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 + * Retrieves the current Function's associated KeyValueStore. See the + * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-custom-methods.html | CloudFront Developer Guide}. + * @returns An instance of the associated KeyValueStore. + * @throws If no KeyValueStore is associated with the Function. + */ + function kvs(): KVStore; + + /** + * Retrieves a reference to the current Function's associated KeyValueStore by its ID. Though not documented + * in the {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-custom-methods.html | CloudFront Developer Guide}, + * this overload has been proven to work in practice and is shown in the + * {@link https://aws.amazon.com/blogs/aws/introducing-amazon-cloudfront-keyvaluestore-a-low-latency-datastore-for-cloudfront-functions/ | AWS News Blog announcement}. + * @param kvsId The identifier of an associated KeyValueStore. + * @returns An instance of the KeyValueStore. + * @throws If KeyValueStore does not exist or is not associated with the Function. */ function kvs(kvsId: string): KVStore;