| 1 | import type * as agw2 from "@distilled.cloud/aws/apigatewayv2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { ApiGatewayV2Stage } from "./Stage.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for resetting a stage's authorizer result cache |
| 8 | * (`apigateway:DELETE` on `/apis/{apiId}/stages/{stageName}/cache/authorizers`). |
| 9 | * |
| 10 | * Bind a {@link Stage} inside a function runtime to drop cached Lambda |
| 11 | * authorizer verdicts — e.g. immediately revoking access after a |
| 12 | * permission change, without waiting out `authorizerResultTtl`. Provide |
| 13 | * `ApiGatewayV2.ResetAuthorizersCacheHttp` on the Function effect to |
| 14 | * implement the binding. |
| 15 | * |
| 16 | * ### Flushing caches |
| 17 | * **Example:** Revoke cached authorizer verdicts |
| 18 | * ```typescript |
| 19 | * // init |
| 20 | * const resetAuthorizersCache = yield* ApiGatewayV2.ResetAuthorizersCache(stage); |
| 21 | * |
| 22 | * // runtime |
| 23 | * yield* resetAuthorizersCache(); |
| 24 | * ``` |
| 25 | * |
| 26 | * @binding |
| 27 | */ |
| 28 | export interface ResetAuthorizersCache extends Binding.Service< |
| 29 | ResetAuthorizersCache, |
| 30 | "AWS.ApiGatewayV2.ResetAuthorizersCache", |
| 31 | <S extends ApiGatewayV2Stage>( |
| 32 | stage: S, |
| 33 | ) => Effect.Effect< |
| 34 | () => Effect.Effect< |
| 35 | agw2.ResetAuthorizersCacheResponse, |
| 36 | agw2.ResetAuthorizersCacheError |
| 37 | > |
| 38 | > |
| 39 | > {} |
| 40 | export const ResetAuthorizersCache = Binding.Service<ResetAuthorizersCache>( |
| 41 | "AWS.ApiGatewayV2.ResetAuthorizersCache", |
| 42 | ); |