cdk-nextjs 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +2467 -2714
- package/.jsii.tabl.json +1 -1
- package/API.md +1725 -1909
- package/CLAUDE.md +2 -1
- package/README.md +429 -130
- package/assets/lambdas/post-deploy/post-deploy.lambda/index.js +152 -170
- package/assets/lambdas/redeploy-stage/redeploy-stage.lambda/index.js +875 -0
- package/docs/adapter-runtime.md +185 -0
- package/docs/breaking-changes.md +687 -4
- package/docs/caching-guide.md +156 -112
- package/docs/cdk-nextjs-cfn-exec-policy.json +2 -1
- package/docs/development-guide.md +1 -1
- package/docs/harness-coverage.md +598 -0
- package/docs/init-cache-deployment.md +32 -1
- package/docs/next-build-output-guide.md +30 -20
- package/examples/README.md +5 -1
- package/lib/adapter/__fixtures__/app-playground-base-path.json +4926 -0
- package/lib/adapter/__fixtures__/app-playground.json +4917 -0
- package/lib/adapter/__fixtures__/pages-i18n.json +1728 -0
- package/lib/adapter/adapter.mjs +1548 -185
- package/lib/adapter/adapter.test.js +106 -0
- package/lib/adapter/aws-cache-store.d.ts +489 -0
- package/lib/adapter/aws-cache-store.js +1004 -0
- package/lib/adapter/aws-cache-store.test.d.ts +1 -0
- package/lib/adapter/aws-cache-store.test.js +361 -0
- package/lib/adapter/build-outputs.d.ts +80 -0
- package/lib/adapter/build-outputs.js +852 -0
- package/lib/adapter/build-outputs.test.d.ts +1 -0
- package/lib/adapter/build-outputs.test.js +861 -0
- package/lib/adapter/cache-handler.d.ts +9 -2
- package/lib/adapter/cache-handler.js +72 -96
- package/lib/adapter/cache-handler.mjs +18956 -17774
- package/lib/adapter/cache-handler.test.js +263 -31
- package/lib/adapter/cache-kinds.d.ts +32 -0
- package/lib/adapter/cache-kinds.js +35 -0
- package/lib/adapter/cache-kinds.test.d.ts +1 -0
- package/lib/adapter/cache-kinds.test.js +69 -0
- package/lib/adapter/cache-utils.d.ts +90 -0
- package/lib/adapter/cache-utils.js +199 -4
- package/lib/adapter/cache-utils.test.d.ts +1 -0
- package/lib/adapter/cache-utils.test.js +179 -0
- package/lib/adapter/function-groups.d.ts +215 -0
- package/lib/adapter/function-groups.js +1099 -0
- package/lib/adapter/function-groups.test.d.ts +1 -0
- package/lib/adapter/function-groups.test.js +743 -0
- package/lib/adapter/init-cache.d.ts +6 -0
- package/lib/adapter/init-cache.js +245 -0
- package/lib/adapter/init-cache.test.d.ts +1 -0
- package/lib/adapter/init-cache.test.js +137 -0
- package/lib/adapter/local-file-cache-handler.d.ts +23 -0
- package/lib/adapter/local-file-cache-handler.js +52 -1
- package/lib/adapter/memory-cache-handler.d.ts +26 -17
- package/lib/adapter/memory-cache-handler.js +32 -50
- package/lib/adapter/memory-cache-handler.test.js +105 -85
- package/lib/adapter/s3-cache-handler.d.ts +179 -40
- package/lib/adapter/s3-cache-handler.js +807 -277
- package/lib/adapter/s3-cache-handler.test.js +1186 -31
- package/lib/adapter/use-cache-common.d.ts +90 -0
- package/lib/adapter/use-cache-common.js +250 -0
- package/lib/adapter/use-cache-common.test.d.ts +1 -0
- package/lib/adapter/use-cache-common.test.js +646 -0
- package/lib/adapter/use-cache-default-handler.d.ts +24 -0
- package/lib/adapter/use-cache-default-handler.js +90 -0
- package/lib/adapter/use-cache-default-handler.mjs +38645 -0
- package/lib/adapter/use-cache-handlers.test.d.ts +1 -0
- package/lib/adapter/use-cache-handlers.test.js +349 -0
- package/lib/adapter/use-cache-remote-handler.d.ts +26 -0
- package/lib/adapter/use-cache-remote-handler.js +186 -0
- package/lib/{image-optimization/handler.mjs → adapter/use-cache-remote-handler.mjs} +33572 -38798
- package/lib/generated-structs/OptionalNextjsApiProps.d.ts +59 -0
- package/lib/generated-structs/OptionalNextjsApiProps.js +3 -0
- package/lib/generated-structs/OptionalNextjsCacheProps.d.ts +15 -6
- package/lib/generated-structs/OptionalNextjsCacheProps.js +1 -1
- package/lib/generated-structs/OptionalNextjsContainersProps.d.ts +25 -11
- package/lib/generated-structs/OptionalNextjsContainersProps.js +1 -1
- package/lib/generated-structs/OptionalNextjsDistributionProps.d.ts +31 -9
- package/lib/generated-structs/OptionalNextjsDistributionProps.js +1 -1
- package/lib/generated-structs/OptionalNextjsPostDeployProps.d.ts +13 -0
- package/lib/generated-structs/OptionalNextjsPostDeployProps.js +1 -1
- package/lib/generated-structs/OptionalPostDeployCustomResourceProperties.d.ts +11 -2
- package/lib/generated-structs/OptionalPostDeployCustomResourceProperties.js +1 -1
- package/lib/index.d.ts +6 -7
- package/lib/index.js +2 -4
- package/lib/lambdas/post-deploy/post-deploy.lambda.js +3 -2
- package/lib/lambdas/post-deploy/prune-cache-bucket.d.ts +7 -3
- package/lib/lambdas/post-deploy/prune-cache-bucket.js +57 -71
- package/lib/lambdas/post-deploy/prune-cache-bucket.test.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-cache-bucket.test.js +114 -0
- package/lib/lambdas/post-deploy/prune-revalidation-table.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-revalidation-table.js +23 -31
- package/lib/lambdas/post-deploy/prune-revalidation-table.test.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-revalidation-table.test.js +71 -0
- package/lib/lambdas/post-deploy/prune-s3.d.ts +19 -3
- package/lib/lambdas/post-deploy/prune-s3.js +54 -15
- package/lib/lambdas/post-deploy/prune-s3.test.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-s3.test.js +255 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage-function.d.ts +13 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage-function.js +55 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.d.ts +24 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.js +68 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.lambda.d.ts +20 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.lambda.js +24 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.test.d.ts +1 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.test.js +93 -0
- package/lib/nextjs-api.d.ts +107 -18
- package/lib/nextjs-api.js +349 -39
- package/lib/nextjs-api.test.js +582 -1
- package/lib/nextjs-build/global-containers.Dockerfile +15 -10
- package/lib/nextjs-build/nextjs-build.d.ts +339 -63
- package/lib/nextjs-build/nextjs-build.js +684 -327
- package/lib/nextjs-build/nextjs-build.test.d.ts +1 -0
- package/lib/nextjs-build/nextjs-build.test.js +412 -0
- package/lib/nextjs-build/patch-fetch.js +1 -1
- package/lib/nextjs-build/patch-fetch.test.js +166 -11
- package/lib/nextjs-build/regional-containers.Dockerfile +17 -10
- package/lib/nextjs-cache.d.ts +82 -4
- package/lib/nextjs-cache.js +186 -10
- package/lib/nextjs-cache.test.js +176 -1
- package/lib/nextjs-compute/nextjs-compute-base-props.d.ts +21 -8
- package/lib/nextjs-compute/nextjs-compute-base-props.js +41 -1
- package/lib/nextjs-compute/nextjs-compute-base-props.test.d.ts +1 -0
- package/lib/nextjs-compute/nextjs-compute-base-props.test.js +44 -0
- package/lib/nextjs-compute/nextjs-containers.d.ts +19 -0
- package/lib/nextjs-compute/nextjs-containers.js +57 -20
- package/lib/nextjs-compute/nextjs-functions.d.ts +122 -7
- package/lib/nextjs-compute/nextjs-functions.js +113 -67
- package/lib/nextjs-compute/nextjs-functions.test.d.ts +1 -0
- package/lib/nextjs-compute/nextjs-functions.test.js +99 -0
- package/lib/nextjs-distribution.d.ts +194 -23
- package/lib/nextjs-distribution.js +535 -62
- package/lib/nextjs-distribution.test.d.ts +1 -0
- package/lib/nextjs-distribution.test.js +697 -0
- package/lib/nextjs-post-deploy.d.ts +23 -3
- package/lib/nextjs-post-deploy.js +14 -10
- package/lib/nextjs-post-deploy.test.d.ts +1 -0
- package/lib/nextjs-post-deploy.test.js +34 -0
- package/lib/nextjs-static-assets.d.ts +23 -4
- package/lib/nextjs-static-assets.js +29 -6
- package/lib/nextjs-static-assets.test.js +20 -1
- package/lib/root-constructs/nextjs-base-construct.d.ts +105 -45
- package/lib/root-constructs/nextjs-base-construct.js +144 -34
- package/lib/root-constructs/nextjs-global-containers.d.ts +18 -20
- package/lib/root-constructs/nextjs-global-containers.js +20 -70
- package/lib/root-constructs/nextjs-global-functions.d.ts +26 -28
- package/lib/root-constructs/nextjs-global-functions.js +52 -69
- package/lib/root-constructs/nextjs-regional-containers.d.ts +25 -5
- package/lib/root-constructs/nextjs-regional-containers.js +17 -15
- package/lib/root-constructs/nextjs-regional-functions.d.ts +22 -18
- package/lib/root-constructs/nextjs-regional-functions.js +8 -25
- package/lib/runtime/api-gateway-path.d.ts +34 -0
- package/lib/runtime/api-gateway-path.js +71 -0
- package/lib/runtime/api-gateway-path.test.d.ts +1 -0
- package/lib/runtime/api-gateway-path.test.js +65 -0
- package/lib/runtime/case-redirect.d.ts +22 -0
- package/lib/runtime/case-redirect.js +63 -0
- package/lib/runtime/case-redirect.test.d.ts +1 -0
- package/lib/runtime/case-redirect.test.js +32 -0
- package/lib/runtime/core.d.ts +234 -0
- package/lib/runtime/core.js +1213 -0
- package/lib/runtime/core.test.d.ts +1 -0
- package/lib/runtime/core.test.js +1678 -0
- package/lib/runtime/deployment-root.d.ts +13 -0
- package/lib/runtime/deployment-root.js +29 -0
- package/lib/runtime/dispatch.d.ts +331 -0
- package/lib/runtime/dispatch.js +751 -0
- package/lib/runtime/dispatch.test.d.ts +1 -0
- package/lib/runtime/dispatch.test.js +853 -0
- package/lib/runtime/entrypoints.d.ts +57 -0
- package/lib/runtime/entrypoints.js +115 -0
- package/lib/runtime/http/abort-signal.d.ts +6 -0
- package/lib/runtime/http/abort-signal.js +19 -0
- package/lib/runtime/http/abort-signal.test.d.ts +1 -0
- package/lib/runtime/http/abort-signal.test.js +49 -0
- package/lib/runtime/http/node-server.d.ts +38 -0
- package/lib/runtime/http/node-server.js +99 -0
- package/lib/runtime/http/node-server.test.d.ts +1 -0
- package/lib/runtime/http/node-server.test.js +96 -0
- package/lib/runtime/http/node-sink.d.ts +16 -0
- package/lib/runtime/http/node-sink.js +48 -0
- package/lib/runtime/http/node-sink.test.d.ts +1 -0
- package/lib/runtime/http/node-sink.test.js +66 -0
- package/lib/runtime/http/request.d.ts +62 -0
- package/lib/runtime/http/request.js +134 -0
- package/lib/runtime/http/request.test.d.ts +1 -0
- package/lib/runtime/http/request.test.js +103 -0
- package/lib/runtime/http/response.d.ts +77 -0
- package/lib/runtime/http/response.js +229 -0
- package/lib/runtime/http/response.test.d.ts +1 -0
- package/lib/runtime/http/response.test.js +178 -0
- package/lib/runtime/http/sink.d.ts +73 -0
- package/lib/runtime/http/sink.js +188 -0
- package/lib/runtime/http/sink.test.d.ts +1 -0
- package/lib/runtime/http/sink.test.js +257 -0
- package/lib/runtime/image-utils.d.ts +78 -0
- package/lib/runtime/image-utils.js +129 -0
- package/lib/runtime/image-utils.test.d.ts +1 -0
- package/lib/runtime/image-utils.test.js +237 -0
- package/lib/runtime/image.d.ts +76 -0
- package/lib/runtime/image.js +296 -0
- package/lib/runtime/image.test.d.ts +1 -0
- package/lib/runtime/image.test.js +405 -0
- package/lib/runtime/lambda-event.d.ts +4 -0
- package/lib/runtime/lambda-event.js +113 -0
- package/lib/runtime/lambda-event.test.d.ts +1 -0
- package/lib/runtime/lambda-event.test.js +119 -0
- package/lib/runtime/lambda.mjs +41595 -0
- package/lib/runtime/load-module.d.ts +8 -0
- package/lib/runtime/load-module.js +35 -0
- package/lib/runtime/manifest.d.ts +215 -0
- package/lib/runtime/manifest.js +118 -0
- package/lib/runtime/middleware.d.ts +43 -0
- package/lib/runtime/middleware.js +113 -0
- package/lib/runtime/middleware.test.d.ts +1 -0
- package/lib/runtime/middleware.test.js +259 -0
- package/lib/runtime/next-modules.d.ts +55 -0
- package/lib/runtime/next-modules.js +124 -0
- package/lib/runtime/next-modules.test.d.ts +1 -0
- package/lib/runtime/next-modules.test.js +34 -0
- package/lib/runtime/public-files.d.ts +32 -0
- package/lib/runtime/public-files.js +117 -0
- package/lib/runtime/public-files.test.d.ts +1 -0
- package/lib/runtime/public-files.test.js +97 -0
- package/lib/runtime/server.mjs +41588 -0
- package/lib/runtime/static-files.d.ts +50 -0
- package/lib/runtime/static-files.js +266 -0
- package/lib/runtime/static-files.test.d.ts +1 -0
- package/lib/runtime/static-files.test.js +118 -0
- package/lib/runtime/util.d.ts +28 -0
- package/lib/runtime/util.js +79 -0
- package/lib/utils/base-path.d.ts +123 -11
- package/lib/utils/base-path.js +276 -39
- package/lib/utils/base-path.test.js +275 -50
- package/lib/utils/get-architecture.d.ts +7 -8
- package/lib/utils/get-architecture.js +12 -13
- package/lib/utils/zip-directory.d.ts +14 -0
- package/lib/utils/zip-directory.js +121 -0
- package/lib/utils/zip-directory.test.d.ts +1 -0
- package/lib/utils/zip-directory.test.js +99 -0
- package/package.json +22 -3
- package/scripts/capture-adapter-fixture.mjs +325 -0
- package/scripts/e2e-deploy.sh +398 -0
- package/scripts/e2e-harness/README.md +707 -0
- package/scripts/e2e-harness/app.js +370 -0
- package/scripts/e2e-harness/common.sh +249 -0
- package/scripts/e2e-harness/screen.mjs +302 -0
- package/scripts/e2e-harness/stage-proxy.mjs +145 -0
- package/scripts/e2e-harness/type-filters.mjs +47 -0
- package/scripts/e2e-logs.sh +75 -0
- package/scripts/e2e-offline.sh +91 -0
- package/scripts/e2e-sweep.sh +370 -0
- package/scripts/e2e-warm.sh +114 -0
- package/scripts/zero-config-build.mjs +418 -0
- package/docs/1k-concurrent-users-executions.png +0 -0
- package/docs/plans/adapter-runtime-release.md +0 -362
- package/docs/plans/phase-0-image-function-opt-in.md +0 -295
- package/lib/generated-structs/OptionalDockerImageFunctionProps.d.ts +0 -425
- package/lib/generated-structs/OptionalDockerImageFunctionProps.js +0 -3
- package/lib/image-optimization/handler-utils.d.ts +0 -34
- package/lib/image-optimization/handler-utils.js +0 -83
- package/lib/image-optimization/handler-utils.test.js +0 -178
- package/lib/nextjs-build/functions.Dockerfile +0 -31
- package/lib/nextjs-compute/nextjs-image-function.d.ts +0 -53
- package/lib/nextjs-compute/nextjs-image-function.js +0 -59
- package/lib/utils/experimental-flags.d.ts +0 -24
- package/lib/utils/experimental-flags.js +0 -30
- /package/lib/{image-optimization/handler-utils.test.d.ts → adapter/adapter.test.d.ts} +0 -0
|
@@ -1,68 +1,207 @@
|
|
|
1
1
|
import { CacheHandler, CacheHandlerValue, CacheHandlerContext } from "next/dist/server/lib/incremental-cache";
|
|
2
2
|
import { IncrementalCacheValue, GetIncrementalFetchCacheContext, GetIncrementalResponseCacheContext, SetIncrementalFetchCacheContext, SetIncrementalResponseCacheContext } from "next/dist/server/response-cache";
|
|
3
|
-
|
|
4
|
-
bucketName: string;
|
|
5
|
-
region: string;
|
|
6
|
-
buildId: string;
|
|
7
|
-
}
|
|
8
|
-
interface DynamoDBRevalidationConfig {
|
|
9
|
-
tableName: string;
|
|
10
|
-
region: string;
|
|
11
|
-
buildId: string;
|
|
12
|
-
}
|
|
13
|
-
interface CloudFrontInvalidationConfig {
|
|
14
|
-
/**
|
|
15
|
-
* Name (not value) of the SSM Parameter holding the distribution ID.
|
|
16
|
-
*
|
|
17
|
-
* The distribution ID itself can't be passed as a plain env var: CDK
|
|
18
|
-
* constructs the Lambda/Fargate task before the distribution exists (the
|
|
19
|
-
* distribution's origin references the compute's function URL/ALB), so
|
|
20
|
-
* embedding the distribution's physical ID directly in the compute's
|
|
21
|
-
* environment or IAM policy would create a circular CloudFormation
|
|
22
|
-
* dependency. The parameter *name* is static and known at synth time, so
|
|
23
|
-
* it can be safely embedded; only its *value* depends on the distribution.
|
|
24
|
-
*/
|
|
25
|
-
distributionIdParameterName: string;
|
|
26
|
-
region: string;
|
|
27
|
-
}
|
|
3
|
+
import { RevalidateDurations } from "./aws-cache-store";
|
|
28
4
|
export interface S3CacheHandlerOptions {
|
|
29
5
|
context: CacheHandlerContext;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The app's `basePath`, for tests: read from `required-server-files.json`
|
|
8
|
+
* otherwise.
|
|
9
|
+
*/
|
|
10
|
+
basePath?: string;
|
|
33
11
|
}
|
|
34
12
|
export declare class S3CacheHandler implements CacheHandler {
|
|
35
13
|
private s3Client;
|
|
36
14
|
private dynamoClient;
|
|
37
15
|
private cloudFrontClient;
|
|
38
16
|
private ssmClient;
|
|
39
|
-
private
|
|
40
|
-
private
|
|
17
|
+
private bucket;
|
|
18
|
+
private tags;
|
|
19
|
+
private config;
|
|
41
20
|
private cloudFrontConfig;
|
|
42
21
|
private debug;
|
|
43
22
|
private cachedDistributionId;
|
|
23
|
+
/**
|
|
24
|
+
* Cache keys this instance served stale because of a soft `revalidateTag`,
|
|
25
|
+
* whose regenerated entry `set` has yet to write.
|
|
26
|
+
*
|
|
27
|
+
* `revalidateTag(tag, profile)` invalidates CloudFront at once, but the next
|
|
28
|
+
* request is answered from the stale entry - stale-while-revalidate - and that
|
|
29
|
+
* response carries the entry's original `s-maxage`, so the edge caches the
|
|
30
|
+
* stale body again. The background render that replaces it runs in this same
|
|
31
|
+
* process, so `set` checks this set and invalidates the key's paths a second
|
|
32
|
+
* time once the fresh entry is in S3. Without that, the edge kept serving the
|
|
33
|
+
* pre-revalidation page for the whole `s-maxage`.
|
|
34
|
+
*
|
|
35
|
+
* Expiring soft-revalidated entries outright instead would also keep the edge
|
|
36
|
+
* right, but it turns every `revalidateTag(tag, "max")` into a blocking render
|
|
37
|
+
* at the origin, which is the thing a profile asks not to happen.
|
|
38
|
+
*/
|
|
39
|
+
private softRevalidatedKeys;
|
|
40
|
+
/** @see buildTagManifest */
|
|
41
|
+
private buildTags;
|
|
44
42
|
constructor(options: S3CacheHandlerOptions);
|
|
45
43
|
get(cacheKey: string, ctx: GetIncrementalFetchCacheContext | GetIncrementalResponseCacheContext): Promise<CacheHandlerValue | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a tag revalidation has expired `entry`, for a `get` with `ctx`.
|
|
46
|
+
*
|
|
47
|
+
* Public because the in-memory layer in front of this handler has to ask too:
|
|
48
|
+
* a memory hit never reaches {@link get}, and without this check an instance
|
|
49
|
+
* other than the one that ran `revalidateTag` kept answering from memory for
|
|
50
|
+
* the whole memory TTL - long enough for CloudFront to cache the stale page
|
|
51
|
+
* again after the invalidation.
|
|
52
|
+
*
|
|
53
|
+
* Which tags to check depends on the kind, and Next.js's own
|
|
54
|
+
* `FileSystemCache.get` splits the same two ways: a response entry is checked
|
|
55
|
+
* against the tags *it* was stored with, but a `fetch` entry is checked
|
|
56
|
+
* against `[...ctx.tags, ...ctx.softTags]` — the tags of the request asking
|
|
57
|
+
* for it. That distinction is load-bearing, because a `fetch` entry is only
|
|
58
|
+
* ever stored with its *explicit* `cache: { tags }` and never with the
|
|
59
|
+
* implicit `_N_T_/<path>` chain, which arrives only as `ctx.softTags`.
|
|
60
|
+
* Reading the stored tags for a `fetch` too meant an untagged `force-cache`
|
|
61
|
+
* fetch had `[]`, skipped the check entirely, and no `revalidatePath` could
|
|
62
|
+
* ever evict it: a `force-dynamic` page whose data comes from such a fetch
|
|
63
|
+
* re-rendered on every request and still served the same body forever.
|
|
64
|
+
* Measured against next.js's `test/e2e/app-dir/revalidate-path-with-rewrites`.
|
|
65
|
+
*
|
|
66
|
+
* `cacheKey` is the key the entry was read under. A response entry found
|
|
67
|
+
* stale is remembered by it, for `set` to invalidate CloudFront again once
|
|
68
|
+
* its regeneration lands: see {@link softRevalidatedKeys}.
|
|
69
|
+
*/
|
|
70
|
+
isRevalidated(entry: {
|
|
71
|
+
lastModified?: number;
|
|
72
|
+
tags?: string[];
|
|
73
|
+
value?: unknown;
|
|
74
|
+
}, ctx: GetIncrementalFetchCacheContext | GetIncrementalResponseCacheContext, cacheKey: string): Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Remember that `cacheKey` was served stale, when there is a distribution
|
|
77
|
+
* whose copy of it will need invalidating again. See
|
|
78
|
+
* {@link softRevalidatedKeys}.
|
|
79
|
+
*/
|
|
80
|
+
private noteSoftRevalidated;
|
|
46
81
|
set(cacheKey: string, data: IncrementalCacheValue | null, ctx: SetIncrementalFetchCacheContext | SetIncrementalResponseCacheContext): Promise<void>;
|
|
47
|
-
revalidateTag(tag: string | string[]): Promise<void>;
|
|
48
|
-
private revalidateSingleTag;
|
|
82
|
+
revalidateTag(tag: string | string[], durations?: RevalidateDurations): Promise<void>;
|
|
49
83
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
84
|
+
* The routes CloudFront could be holding a response for `tag` under -
|
|
85
|
+
* `truncated` when they could not all be named: more mapping rows than
|
|
86
|
+
* {@link MAX_TAG_QUERY_PAGES}, or no build tag manifest to read.
|
|
87
|
+
*/
|
|
88
|
+
private tagRoutes;
|
|
89
|
+
/**
|
|
90
|
+
* The build-time prerenders' cache keys by tag ({@link INIT_CACHE_TAG_MANIFEST}),
|
|
91
|
+
* read from the cache bucket once per instance, or `undefined` when that
|
|
92
|
+
* failed, to be read again next time. A prerender is written by the adapter,
|
|
93
|
+
* never through `set`, so this is the only record of which tags name its
|
|
94
|
+
* CloudFront paths, and it is served with a year-long `s-maxage`.
|
|
95
|
+
*/
|
|
96
|
+
private buildTagManifest;
|
|
97
|
+
/**
|
|
98
|
+
* Every mapping row for `tag`, following `LastEvaluatedKey`, and whether
|
|
99
|
+
* {@link MAX_TAG_QUERY_PAGES} cut the walk short.
|
|
100
|
+
*
|
|
101
|
+
* DynamoDB caps a Query at 1 MB of items regardless of how many match, and
|
|
102
|
+
* there is one row per tagged entry a runtime `set` wrote, so a large site
|
|
103
|
+
* passes 1 MB on a common tag. Stopping at the
|
|
104
|
+
* first page invalidates only that page's entries while still reporting
|
|
105
|
+
* success, which is indistinguishable from revalidation having worked.
|
|
106
|
+
*/
|
|
107
|
+
private queryTagMappings;
|
|
108
|
+
/**
|
|
109
|
+
* Reverses `buildS3Key` to recover the route the response was cached for, for
|
|
110
|
+
* {@link cdnInvalidationPaths} to turn into the URIs CloudFront holds it under, or
|
|
111
|
+
* `undefined` for a key that names no cached URI.
|
|
112
|
+
*
|
|
113
|
+
* Two kinds of mapping row do not: a dynamic route template (`blog/[slug].json`,
|
|
114
|
+
* which the adapter's seeded entries include), and a fetch-cache entry, whose
|
|
115
|
+
* key is an opaque hash rather than a route. Both would invalidate a URI that
|
|
116
|
+
* cannot exist, and each one costs one of the fifteen wildcard paths an
|
|
117
|
+
* invalidation may carry — so they are dropped here rather than crowding out
|
|
118
|
+
* the real ones.
|
|
53
119
|
*/
|
|
54
120
|
private s3KeyToInvalidationPath;
|
|
121
|
+
/**
|
|
122
|
+
* Invalidate `paths` in a single request, or the whole app
|
|
123
|
+
* ({@link wholeAppInvalidationPaths}) when they would not fit in one. See
|
|
124
|
+
* {@link MAX_WILDCARD_PATHS_PER_INVALIDATION}.
|
|
125
|
+
*/
|
|
55
126
|
private invalidateCloudFrontPaths;
|
|
56
127
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* for why
|
|
128
|
+
* The distribution's physical ID, from the environment or else SSM Parameter
|
|
129
|
+
* Store, cached for the lifetime of this instance. See
|
|
130
|
+
* `CloudFrontInvalidationConfig` for why Functions need the indirection.
|
|
60
131
|
*/
|
|
61
132
|
private getDistributionId;
|
|
62
133
|
resetRequestCache(): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Whether this deployment keeps `tag#s3Key` mapping rows at all.
|
|
136
|
+
*
|
|
137
|
+
* Their one reader is `revalidateTag`'s CloudFront invalidation, which needs
|
|
138
|
+
* the entries' paths - tag revalidation itself runs on the bare-tag marker
|
|
139
|
+
* rows. A deployment with no distribution (the Regional constructs) would pay
|
|
140
|
+
* a DynamoDB write per tag on every `set`, a Query per `revalidateTag`, and an
|
|
141
|
+
* extra S3 read before every delete, for rows nothing ever reads.
|
|
142
|
+
*/
|
|
143
|
+
private get mapsTagsToPaths();
|
|
144
|
+
/** Whether there is a distribution to invalidate. */
|
|
145
|
+
private get invalidatesCdn();
|
|
146
|
+
/** `{buildId}/{cacheKey}.json`; see {@link buildS3Key}. */
|
|
63
147
|
private buildS3Key;
|
|
64
148
|
private storeDynamoDBTagMappings;
|
|
149
|
+
/**
|
|
150
|
+
* Drop the `tag#s3Key` mapping rows for an entry that no longer exists.
|
|
151
|
+
*
|
|
152
|
+
* The counterpart of {@link storeDynamoDBTagMappings}, and the reason its
|
|
153
|
+
* caller has to know the entry's tags: a mapping row's sort key starts with
|
|
154
|
+
* the tag, so the rows belonging to one cache key cannot be queried for - only
|
|
155
|
+
* a full scan of the build's partition would find them.
|
|
156
|
+
*
|
|
157
|
+
* Left behind, a row still resolves to a cache key on the next
|
|
158
|
+
* `revalidateTag`, which spends one of CloudFront's fifteen wildcard paths
|
|
159
|
+
* invalidating a URI whose entry was deleted - crowding out the paths that do
|
|
160
|
+
* need it, and past {@link MAX_WILDCARD_PATHS_PER_INVALIDATION} collapsing the
|
|
161
|
+
* whole app into one wildcard. The rows also count against the 1 MB a tag's Query returns, so
|
|
162
|
+
* enough of them push live entries onto a page
|
|
163
|
+
* {@link MAX_TAG_QUERY_PAGES} may not reach.
|
|
164
|
+
*
|
|
165
|
+
* Only the mapping rows: the bare-`tag` marker row `revalidateTag`
|
|
166
|
+
* writes belongs to the tag rather than to any entry, and `checkIfRevalidated`
|
|
167
|
+
* reads it for every *other* entry carrying that tag.
|
|
168
|
+
*
|
|
169
|
+
* Deliberately no CloudFront invalidation for the deleted path. The edge copy
|
|
170
|
+
* does outlive the object, but this runs on every revalidated `fetch` entry as
|
|
171
|
+
* well, where the key names no URI, and an invalidation request per deleted
|
|
172
|
+
* entry is a cost the TTL already bounds.
|
|
173
|
+
*/
|
|
174
|
+
private deleteDynamoDBTagMappings;
|
|
175
|
+
/**
|
|
176
|
+
* The tags an entry about to be deleted was stored with.
|
|
177
|
+
*
|
|
178
|
+
* `ctx` carries them for a `fetch` delete, but a response delete arrives as
|
|
179
|
+
* `{ cacheControl, isRoutePPREnabled, isFallback }` - `ResponseCache.set`
|
|
180
|
+
* builds it that way - so the entry itself is the only source, and it has to
|
|
181
|
+
* be read before it is removed. That is one extra GET on a path that runs when
|
|
182
|
+
* a cached route starts answering `notFound()`: `IncrementalCache.set`
|
|
183
|
+
* forwards `ResponseCache`'s null value through to here.
|
|
184
|
+
*
|
|
185
|
+
* A page is also the case worth paying it for, since it carries the whole
|
|
186
|
+
* implicit `_N_T_/…` chain and therefore the most rows.
|
|
187
|
+
*/
|
|
188
|
+
private storedEntryTags;
|
|
189
|
+
/**
|
|
190
|
+
* Whether any of `tags` was revalidated after this entry was stored, and how.
|
|
191
|
+
*
|
|
192
|
+
* Reads the per-tag marker rows `revalidateTag` writes, as this instance
|
|
193
|
+
* tracks them: see `TrackedTagMarkers` for when they are read.
|
|
194
|
+
* Scanning the tag's mapping rows instead would answer the wrong question:
|
|
195
|
+
* those rows exist per cache *key*, so which one a `Limit: 1` query returned
|
|
196
|
+
* depended on sort order, and an entry could be judged against another
|
|
197
|
+
* entry's timestamp.
|
|
198
|
+
*
|
|
199
|
+
* A tag revalidated with a profile only makes the entry *stale*: that is
|
|
200
|
+
* reported to Next.js through its tag manifest (see {@link nextTagsManifest})
|
|
201
|
+
* and answered `"stale"` here, so the entry is served while a background
|
|
202
|
+
* render replaces it. When the manifest cannot be reached a stale entry is
|
|
203
|
+
* reported expired instead - a blocking render, never a stale page presented
|
|
204
|
+
* as fresh.
|
|
205
|
+
*/
|
|
65
206
|
private checkIfRevalidated;
|
|
66
|
-
private deleteS3Entry;
|
|
67
207
|
}
|
|
68
|
-
export {};
|