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
package/lib/utils/base-path.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure `basePath` and URL path helpers. Nothing here imports `aws-cdk-lib` or
|
|
3
|
+
* touches the filesystem, so the adapter and runtime bundles can import it as
|
|
4
|
+
* well as the constructs.
|
|
5
|
+
*/
|
|
1
6
|
import { NextjsType } from "../constants";
|
|
2
7
|
/**
|
|
3
8
|
* Reduces a `basePath` to a bare path segment so values that address the same
|
|
@@ -5,6 +10,31 @@ import { NextjsType } from "../constants";
|
|
|
5
10
|
* without doubling separators.
|
|
6
11
|
*/
|
|
7
12
|
export declare function normalizeBasePath(basePath?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether `path` is `prefix` or under it on a segment boundary, so `/docsearch`
|
|
15
|
+
* is not under `/docs`. An empty `prefix` matches nothing. Both sides must be in
|
|
16
|
+
* the same form (both with or both without the leading `/`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function hasPathPrefix(path: string, prefix: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A `basePath` as Next.js spells it and URLs start with it: one leading slash,
|
|
21
|
+
* no trailing one ("/base"), `""` for none. Accepts any spelling
|
|
22
|
+
* {@link normalizeBasePath} does.
|
|
23
|
+
*/
|
|
24
|
+
export declare function basePathPrefix(basePath?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Invalidation paths covering every URI of the app: what a deploy invalidates,
|
|
27
|
+
* and what the cache handler's oversized batches, retries after a quota error,
|
|
28
|
+
* and tags whose routes could not all be named fall back to.
|
|
29
|
+
*
|
|
30
|
+
* `/*` is the whole app only without a `basePath`. `/base/*` matches neither the
|
|
31
|
+
* app's root, `/base`, nor its RSC payload, `/base?_rsc=…` - the same root the
|
|
32
|
+
* `revalidatePath("/")` that overflowed may have named - so those are spelled
|
|
33
|
+
* out. `/base*` would cover them for one wildcard, but also every sibling
|
|
34
|
+
* prefix (`/base2`, `/basement`), which may be another app on the same
|
|
35
|
+
* distribution.
|
|
36
|
+
*/
|
|
37
|
+
export declare function wholeAppInvalidationPaths(basePath?: string): string[];
|
|
8
38
|
/**
|
|
9
39
|
* Joins path parts with a single "/", normalizing each (so no leading or
|
|
10
40
|
* trailing slash survives, including on the result) and dropping the empty
|
|
@@ -12,18 +42,97 @@ export declare function normalizeBasePath(basePath?: string): string;
|
|
|
12
42
|
*/
|
|
13
43
|
export declare function joinPath(...parts: (string | undefined)[]): string;
|
|
14
44
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
45
|
+
* Prefixes an absolute app path (a health check path, say) with `basePath`,
|
|
46
|
+
* always returning a leading slash. An empty or unset `basePath` only
|
|
47
|
+
* normalizes that leading slash. Anything after the first segment is passed
|
|
48
|
+
* through as given, trailing slash included, since a `trailingSlash` app
|
|
49
|
+
* answers "/api/health" and "/api/health/" differently.
|
|
50
|
+
*
|
|
51
|
+
* Use this for paths handed to something that talks to the app directly — an ALB
|
|
52
|
+
* target group health check, the container's own health probe — since the app
|
|
53
|
+
* only answers under its own `basePath`.
|
|
19
54
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
55
|
+
* Prefixes unconditionally, so `path` has to arrive as the app routes it,
|
|
56
|
+
* without `basePath`: for an app based at "/base", "/base/api/health" becomes
|
|
57
|
+
* "/base/base/api/health". Deliberately not special-cased — an app can route
|
|
58
|
+
* "/base/base/..." legitimately, and accepting both spellings would give the
|
|
59
|
+
* path two meanings. See `docs/breaking-changes.md` (0.6.0), which tells users
|
|
60
|
+
* who prefixed `healthCheckPath` by hand to drop the prefix.
|
|
25
61
|
*/
|
|
26
|
-
export declare function
|
|
62
|
+
export declare function prefixWithBasePath(basePath: string | undefined, path: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* The app's own `assetPrefix` as a path with a leading and no trailing slash
|
|
65
|
+
* ("/cdn"), or `""` when the app sets none.
|
|
66
|
+
*
|
|
67
|
+
* Returns `""` for an absolute `assetPrefix` ("https://cdn.example.com", or the
|
|
68
|
+
* protocol-relative "//cdn.example.com") too: that names an origin cdk-nextjs
|
|
69
|
+
* does not control, and it is the supported way to serve assets from elsewhere,
|
|
70
|
+
* so nothing about it is worth warning about. Use {@link assetPrefixPath} for
|
|
71
|
+
* what the *distribution* has to answer on, which includes the path an absolute
|
|
72
|
+
* prefix carries.
|
|
73
|
+
*
|
|
74
|
+
* Next.js applies `assetPrefix` on top of, not under, `basePath`, so the result
|
|
75
|
+
* is the whole prefix of a `_next/static` URL and must not be joined with
|
|
76
|
+
* `basePath`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function relativeAssetPrefix(assetPrefix: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Whether a path-style `assetPrefix` would go unanswered on this `NextjsType`,
|
|
81
|
+
* i.e. whether every bundle would 404.
|
|
82
|
+
*
|
|
83
|
+
* `assetPrefix` moves every bundle URL to `<assetPrefix>/_next/static/...` while
|
|
84
|
+
* the objects keep their `<basePath>/_next/static/...` S3 keys. The Global
|
|
85
|
+
* `NextjsType`s answer that with a cache behavior of their own
|
|
86
|
+
* (`NextjsDistribution`); the regional ones have nothing that maps the prefix
|
|
87
|
+
* back — API Gateway's `_next/static` resource and the container's own files are
|
|
88
|
+
* both under the unprefixed path.
|
|
89
|
+
*
|
|
90
|
+
* A prefix equal to the app's own `basePath` is **not** unserved, because that is
|
|
91
|
+
* the value Next.js resolves `assetPrefix` to when `basePath` is set and
|
|
92
|
+
* `assetPrefix` is not: `.next/required-server-files.json` comes back as
|
|
93
|
+
* `{"assetPrefix":"/prod","basePath":"/prod"}` for an app that only ever set
|
|
94
|
+
* `basePath`. Without that exemption the warning fired on every regional
|
|
95
|
+
* deployment that sets a `basePath` at all — including `examples/regional-functions`
|
|
96
|
+
* — telling users their bundles would 404 at the one path that does serve them.
|
|
97
|
+
* `NextjsDistribution.resolveAssetPrefix` drops the prefix for the same reason.
|
|
98
|
+
*
|
|
99
|
+
* Both sides go through `normalizeBasePath` because they arrive in different
|
|
100
|
+
* shapes: `nextConfigAssetPrefix` carries a leading slash (`"/prod"`),
|
|
101
|
+
* `nextConfigBasePath` does not (`"prod"`).
|
|
102
|
+
*/
|
|
103
|
+
export declare function isAssetPrefixUnserved(nextjsType: NextjsType, nextConfigAssetPrefix: string, nextConfigBasePath?: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The *path* every bundle URL carries, whichever form `assetPrefix` takes: "/cdn"
|
|
106
|
+
* for `assetPrefix: "/cdn"` and for `assetPrefix:
|
|
107
|
+
* "https://cdn.example.com/cdn"` alike, `""` when there is none (an absolute
|
|
108
|
+
* prefix with no path, or no prefix at all).
|
|
109
|
+
*
|
|
110
|
+
* An absolute prefix's path counts because `next build` compiles a `beforeFiles`
|
|
111
|
+
* rewrite of its own for it — `/cdn/_next/:path+ → /_next/:path+` — so `next
|
|
112
|
+
* start` serves every bundle under that path as well as under `/_next`. A CDN
|
|
113
|
+
* fronting this deployment at that path therefore has to be answered, and the
|
|
114
|
+
* distribution's `assetPrefix` behavior is what answers it. Measured against
|
|
115
|
+
* `test/e2e/app-dir/asset-prefix-absolute`; see `docs/harness-coverage.md`.
|
|
116
|
+
* Shared with `NextjsDistribution`, whose `assetPrefix` prop a user can also
|
|
117
|
+
* set by hand.
|
|
118
|
+
*/
|
|
119
|
+
export declare function assetPrefixPath(assetPrefix: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* The path prefix API Gateway strips before matching resources, as far as synth
|
|
122
|
+
* can tell. Only read by `resolveBasePath` for `REGIONAL_FUNCTIONS`.
|
|
123
|
+
*/
|
|
124
|
+
export interface ApiGatewayPrefix {
|
|
125
|
+
/**
|
|
126
|
+
* The stage name on the execute-api endpoint, or the base path mapping on a
|
|
127
|
+
* custom domain (`""` when mapped at the root). `undefined` when it is not
|
|
128
|
+
* known at synth — a token — in which case nothing is derived.
|
|
129
|
+
*/
|
|
130
|
+
readonly strippedPrefix?: string;
|
|
131
|
+
/** Whether a custom domain is configured through `restApiProps.domainName`. */
|
|
132
|
+
readonly customDomain: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** `RestApi`'s own defaults: the `prod` stage, no custom domain. */
|
|
135
|
+
export declare const DEFAULT_API_GATEWAY_PREFIX: ApiGatewayPrefix;
|
|
27
136
|
/**
|
|
28
137
|
* Settles on the single `basePath` the infrastructure should be built around,
|
|
29
138
|
* given the CDK `basePath` prop and the Next.js app's own `basePath`
|
|
@@ -36,5 +145,8 @@ export declare function readNextConfigBasePath(dotNextPath: string): string;
|
|
|
36
145
|
* land under), the config is the prefix the app emits its own links and asset
|
|
37
146
|
* hrefs under — so how strictly they have to line up, and whether one can stand
|
|
38
147
|
* in for the other, depends on how the `NextjsType` routes static requests.
|
|
148
|
+
*
|
|
149
|
+
* `apiGateway` is only read for `REGIONAL_FUNCTIONS`, and only when the prop is
|
|
150
|
+
* unset: see `deriveApiGatewayBasePath`.
|
|
39
151
|
*/
|
|
40
|
-
export declare function resolveBasePath(nextjsType: NextjsType, propBasePath?: string, nextConfigBasePath?: string): string | undefined;
|
|
152
|
+
export declare function resolveBasePath(nextjsType: NextjsType, propBasePath?: string, nextConfigBasePath?: string, apiGateway?: ApiGatewayPrefix): string | undefined;
|