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
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The implicit group every unassigned route falls into. Reserved as a group
|
|
3
|
+
* name: it is also the construct id suffix and the function whose URL backs the
|
|
4
|
+
* distribution's default behavior.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_FUNCTION_GROUP = "default";
|
|
7
|
+
/**
|
|
8
|
+
* How the resolved groups reach `onBuildComplete`, which cannot read CDK props —
|
|
9
|
+
* it runs inside `next build`. `CDK_NEXTJS_INIT_CACHE_DIR` is the precedent.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FUNCTION_GROUPS_ENV_VAR = "CDK_NEXTJS_FUNCTION_GROUPS";
|
|
12
|
+
/** The part of a group the build side needs. */
|
|
13
|
+
export interface FunctionGroupSpec {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly routes: string[];
|
|
16
|
+
}
|
|
17
|
+
/** One route template and the entrypoint it invokes. */
|
|
18
|
+
export interface RouteEntry {
|
|
19
|
+
/** Basepath-prefixed route template, exactly as `manifest.entrypoints` keys it. */
|
|
20
|
+
readonly template: string;
|
|
21
|
+
/**
|
|
22
|
+
* What identifies the entrypoint: the build side passes its `filePath`, since
|
|
23
|
+
* that is what gets staged. Two templates sharing one are never split apart.
|
|
24
|
+
*/
|
|
25
|
+
readonly entrypointId: string;
|
|
26
|
+
/**
|
|
27
|
+
* The entrypoint's `AdapterEntrypointType`. Only `"page"` changes anything: a
|
|
28
|
+
* Pages Router page is also requested at `/_next/data/<buildId>/<page>.json`,
|
|
29
|
+
* so that URL has to reach the page's group too.
|
|
30
|
+
*/
|
|
31
|
+
readonly type?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* One behavior the edge routes a group on. The Functions root constructs deploy
|
|
35
|
+
* exactly these, in order: a CloudFront behavior each, or the API Gateway
|
|
36
|
+
* resources for each distinct `route`.
|
|
37
|
+
*/
|
|
38
|
+
export interface GroupBehavior {
|
|
39
|
+
readonly group: string;
|
|
40
|
+
/**
|
|
41
|
+
* The group pattern (`/blog/**`) the behavior was generated from, or the
|
|
42
|
+
* optional catch-all parent {@link routedPatterns} added.
|
|
43
|
+
*/
|
|
44
|
+
readonly route: string;
|
|
45
|
+
/**
|
|
46
|
+
* The CloudFront path pattern, before basePath and without a leading slash
|
|
47
|
+
* (`blog/*`, `_next/data/<buildId>/blog/*`).
|
|
48
|
+
*/
|
|
49
|
+
readonly pattern: string;
|
|
50
|
+
}
|
|
51
|
+
/** What {@link assignRoutesToGroups} decided. */
|
|
52
|
+
export interface GroupAssignment {
|
|
53
|
+
/** Group name → the templates packaged into it, `default` included. */
|
|
54
|
+
readonly templates: Record<string, string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Every group behavior, most specific first: the order CloudFront has to see
|
|
57
|
+
* them in, since it stops at the first match. Recorded rather than
|
|
58
|
+
* recomputed at synth, so the behaviors deployed are the ones this
|
|
59
|
+
* assignment was checked against.
|
|
60
|
+
*/
|
|
61
|
+
readonly behaviors: GroupBehavior[];
|
|
62
|
+
}
|
|
63
|
+
/** What {@link assignRoutesToGroups} needs to know besides the routes. */
|
|
64
|
+
export interface AssignRoutesOptions {
|
|
65
|
+
/** `next.config` `basePath`, which every manifest template carries. */
|
|
66
|
+
readonly basePath: string;
|
|
67
|
+
/**
|
|
68
|
+
* Next.js's build ID — the segment in `/_next/data/<buildId>/…` URLs, which is
|
|
69
|
+
* `ctx.buildId` and `.next/BUILD_ID`, not cdk-nextjs's deployment-suffixed
|
|
70
|
+
* one. Required when any entry is a Pages Router page.
|
|
71
|
+
*/
|
|
72
|
+
readonly buildId?: string;
|
|
73
|
+
/** `next.config` `trailingSlash`. */
|
|
74
|
+
readonly trailingSlash?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* `ctx.routing`: the `next.config` rewrites whose source and destination
|
|
77
|
+
* have to land in one group, and Next.js's own dynamic route order, which
|
|
78
|
+
* decides the template a URL resolves to.
|
|
79
|
+
*/
|
|
80
|
+
readonly routing: RoutingRules;
|
|
81
|
+
}
|
|
82
|
+
/** One `ctx.routing` rewrite, reduced to the fields read here. */
|
|
83
|
+
export interface RewriteRule {
|
|
84
|
+
/** The path-to-regexp source, basePath included (`/old/:path*`). */
|
|
85
|
+
readonly source?: string;
|
|
86
|
+
readonly destination?: string;
|
|
87
|
+
}
|
|
88
|
+
/** The part of `ctx.routing` {@link assignRoutesToGroups} reads. */
|
|
89
|
+
export interface RoutingRules {
|
|
90
|
+
readonly beforeFiles?: readonly RewriteRule[];
|
|
91
|
+
readonly afterFiles?: readonly RewriteRule[];
|
|
92
|
+
readonly fallback?: readonly RewriteRule[];
|
|
93
|
+
/** Next.js's own template matchers, used to resolve a rewrite's destination. */
|
|
94
|
+
readonly dynamicRoutes?: readonly {
|
|
95
|
+
readonly sourceRegex: string;
|
|
96
|
+
readonly destination?: string;
|
|
97
|
+
}[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The literal characters a CloudFront path pattern may contain: its alphabet
|
|
101
|
+
* (`A-Z a-z 0-9 _ - . * $ / ~ " ' @ : +` and `&`) less the two wildcards, which
|
|
102
|
+
* `validateRoutePattern` only accepts as a trailing `/**`. `nextjs-distribution.ts`
|
|
103
|
+
* adds the wildcards back to encode `public/` names.
|
|
104
|
+
*
|
|
105
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistValuesCacheBehavior.html#DownloadDistValuesPathPattern
|
|
106
|
+
*/
|
|
107
|
+
export declare const PATH_PATTERN_LITERAL: RegExp;
|
|
108
|
+
/**
|
|
109
|
+
* Read {@link FUNCTION_GROUPS_ENV_VAR}. `undefined` — not the empty array — when
|
|
110
|
+
* unset, because "no splitting" and "split into nothing" are different requests
|
|
111
|
+
* and only the first is valid.
|
|
112
|
+
*/
|
|
113
|
+
export declare function parseFunctionGroupsEnv(value: string | undefined): FunctionGroupSpec[] | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Splitting and `i18n` are mutually exclusive, and it is a CloudFront limit
|
|
116
|
+
* again.
|
|
117
|
+
*
|
|
118
|
+
* With `i18n` configured, every route template is locale-prefixed
|
|
119
|
+
* (`/en/pricing`, `/de/pricing`), so honoring a `/pricing` group would take one
|
|
120
|
+
* behavior *per locale per pattern* — a budget of 75 behaviors spent in a handful
|
|
121
|
+
* of routes. The alternative, a `*` in the locale position, matches any first
|
|
122
|
+
* segment and would capture routes belonging to other groups. Neither is
|
|
123
|
+
* something to do silently, so refuse instead.
|
|
124
|
+
*/
|
|
125
|
+
export declare function assertNoI18nSplitting(i18n: unknown): void;
|
|
126
|
+
/**
|
|
127
|
+
* Reject everything that cannot be honored, at the earliest of the two sides to
|
|
128
|
+
* see it. Called from both, because either can be the first: `next build` runs
|
|
129
|
+
* before synth reads the manifest, but a `skipBuild: true` consumer inverts that.
|
|
130
|
+
*/
|
|
131
|
+
export declare function validateFunctionGroups(groups: readonly FunctionGroupSpec[]): void;
|
|
132
|
+
/**
|
|
133
|
+
* Split every route template across the groups, longest matching pattern first,
|
|
134
|
+
* then prove that the edge routes every URL each file serves to the group that
|
|
135
|
+
* file was packaged into.
|
|
136
|
+
*
|
|
137
|
+
* Its `templates` are keyed by group name and always contain
|
|
138
|
+
* {@link DEFAULT_FUNCTION_GROUP}, so callers can iterate them as the complete set
|
|
139
|
+
* of functions to deploy. The default group is allowed to be empty of *templates*
|
|
140
|
+
* — it still serves `/_next/image`, any static file, and anything the
|
|
141
|
+
* distribution's catch-all behavior sends it.
|
|
142
|
+
*
|
|
143
|
+
* `basePath` is prepended to each pattern before matching, because manifest
|
|
144
|
+
* templates are basePath-prefixed and consumers write the routes their app
|
|
145
|
+
* declares.
|
|
146
|
+
*
|
|
147
|
+
* Packaging matches patterns against *templates*, but CloudFront routes *URLs*,
|
|
148
|
+
* and a file answers URLs none of its templates spells: an optional catch-all's
|
|
149
|
+
* parent, the `trailingSlash` form, a Pages Router data URL, every other
|
|
150
|
+
* template it shares (root params synthesize `/en` and `/de` from one
|
|
151
|
+
* `[locale]` page). An interception route is worse: it is never requested at its
|
|
152
|
+
* own path at all. So after matching, intercepting files move to the group of
|
|
153
|
+
* the URL they intercept ({@link reassignInterceptingFiles}), and the result is
|
|
154
|
+
* replayed through the same behaviors `NextjsDistribution` deploys
|
|
155
|
+
* ({@link assertEdgeReachesEveryFile}, {@link assertRewritesStayInGroup}). A URL
|
|
156
|
+
* that would reach a function without its file throws here, during `next build`,
|
|
157
|
+
* rather than answering 404 once deployed.
|
|
158
|
+
*/
|
|
159
|
+
export declare function assignRoutesToGroups(groups: readonly FunctionGroupSpec[], entries: readonly RouteEntry[], options: AssignRoutesOptions): GroupAssignment;
|
|
160
|
+
/**
|
|
161
|
+
* The patterns a group is *routed* on: the ones it declares, plus the parent
|
|
162
|
+
* path of every optional catch-all a subtree pattern moved into it.
|
|
163
|
+
*
|
|
164
|
+
* `/blog/[[...slug]]` serves `/blog` as well as everything under it, and
|
|
165
|
+
* `/blog/**` moves the whole file — but deploys as `blog/*`, which does not
|
|
166
|
+
* match `/blog`. So the parent is routed automatically, as an exact pattern of
|
|
167
|
+
* its own; declaring `/blog` by hand is a pattern with no route of its own and
|
|
168
|
+
* is rejected as a typo, with a hint pointing here. Nothing else a subtree owns
|
|
169
|
+
* needs this: a file whose parent URL is its subtree's base can only be an
|
|
170
|
+
* optional catch-all, since Next.js rejects `app/blog/page.tsx` next to it.
|
|
171
|
+
*
|
|
172
|
+
* @param ownedTemplates the templates assigned to the group, basePath-prefixed
|
|
173
|
+
* as `manifest.groups` records them
|
|
174
|
+
*/
|
|
175
|
+
export declare function routedPatterns(routes: readonly string[], ownedTemplates: readonly string[], basePath: string): string[];
|
|
176
|
+
/**
|
|
177
|
+
* CloudFront path patterns for one group pattern, without a leading slash —
|
|
178
|
+
* the form `NextjsDistribution.getPathPattern` expects, so the basePath is
|
|
179
|
+
* added there rather than here.
|
|
180
|
+
*
|
|
181
|
+
* Two patterns come back when the group owns a Pages Router route: its RSC-era
|
|
182
|
+
* equivalent is a second URL space, `/_next/data/<buildId>/<route>.json`, which
|
|
183
|
+
* the default behavior would otherwise send to the default group.
|
|
184
|
+
*
|
|
185
|
+
* A third comes back for an exact route in a `trailingSlash` app, where the
|
|
186
|
+
* canonical URL is `/pricing/` rather than `/pricing`: the bare pattern does not
|
|
187
|
+
* match it, so without this every request for the route the user actually links to
|
|
188
|
+
* falls through to the default group's function — which, for a Pages Router API
|
|
189
|
+
* route, has no entrypoint for it at all. Subtree patterns need no variant
|
|
190
|
+
* (`pricing/*` already matches `/pricing/`), and neither do the data URLs, which
|
|
191
|
+
* never carry the slash.
|
|
192
|
+
*/
|
|
193
|
+
export declare function pathPatternsFor(route: string, options: {
|
|
194
|
+
hasDataRoutes: boolean;
|
|
195
|
+
trailingSlash?: boolean;
|
|
196
|
+
buildId?: string;
|
|
197
|
+
}): string[];
|
|
198
|
+
/**
|
|
199
|
+
* The route an interception route intercepts: `/feed/(..)photo/[id]` →
|
|
200
|
+
* `/photo/[id]`. `extractInterceptionRouteInformation` from
|
|
201
|
+
* `next/dist/shared/lib/router/utils/interception-routes.js`, restated because
|
|
202
|
+
* this file is bundled without `next`. The template is already a normalized app
|
|
203
|
+
* path (no route groups, no `@slot`s), so none of its normalization is needed.
|
|
204
|
+
* Next.js's interception rewrite matches exactly this path, and only with a
|
|
205
|
+
* `Next-Url` header — which CloudFront does not route on.
|
|
206
|
+
*/
|
|
207
|
+
export declare function interceptedRoute(path: string): string | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* CloudFront path pattern matching: anchored at both ends, `*` for any run of
|
|
210
|
+
* characters `/` included, `?` for exactly one, case-sensitive. `pattern` has to
|
|
211
|
+
* carry the leading slash CloudFront implies.
|
|
212
|
+
*
|
|
213
|
+
* @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistValuesCacheBehavior.html#DownloadDistValuesPathPattern
|
|
214
|
+
*/
|
|
215
|
+
export declare function cloudFrontPatternRegex(pattern: string): RegExp;
|