cdk-nextjs 0.7.7 → 0.7.8

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.
Files changed (53) hide show
  1. package/.jsii +2 -2
  2. package/docs/adapter-runtime.md +1 -1
  3. package/docs/harness-coverage.md +153 -73
  4. package/lib/adapter/adapter.mjs +12 -3
  5. package/lib/adapter/aws-cache-store.d.ts +7 -0
  6. package/lib/adapter/aws-cache-store.js +12 -1
  7. package/lib/adapter/aws-cache-store.test.js +32 -1
  8. package/lib/adapter/cache-handler.d.ts +5 -3
  9. package/lib/adapter/cache-handler.js +16 -10
  10. package/lib/adapter/cache-handler.mjs +103 -26
  11. package/lib/adapter/cache-handler.test.js +44 -1
  12. package/lib/adapter/cache-utils.d.ts +22 -0
  13. package/lib/adapter/cache-utils.js +44 -1
  14. package/lib/adapter/function-groups.js +17 -4
  15. package/lib/adapter/function-groups.test.js +33 -1
  16. package/lib/adapter/memory-cache-handler.d.ts +5 -1
  17. package/lib/adapter/memory-cache-handler.js +6 -2
  18. package/lib/adapter/s3-cache-handler.d.ts +12 -1
  19. package/lib/adapter/s3-cache-handler.js +30 -8
  20. package/lib/adapter/s3-cache-handler.test.js +84 -2
  21. package/lib/adapter/use-cache-common.d.ts +13 -0
  22. package/lib/adapter/use-cache-common.js +22 -6
  23. package/lib/adapter/use-cache-common.test.js +37 -1
  24. package/lib/adapter/use-cache-default-handler.mjs +33 -10
  25. package/lib/adapter/use-cache-remote-handler.mjs +33 -12
  26. package/lib/nextjs-api.js +1 -1
  27. package/lib/nextjs-build/nextjs-build.js +1 -1
  28. package/lib/nextjs-cache.js +1 -1
  29. package/lib/nextjs-compute/nextjs-containers.js +1 -1
  30. package/lib/nextjs-compute/nextjs-functions.js +1 -1
  31. package/lib/nextjs-distribution.js +1 -1
  32. package/lib/nextjs-post-deploy.js +1 -1
  33. package/lib/nextjs-static-assets.js +1 -1
  34. package/lib/root-constructs/nextjs-base-construct.js +1 -1
  35. package/lib/root-constructs/nextjs-global-containers.js +1 -1
  36. package/lib/root-constructs/nextjs-global-functions.js +1 -1
  37. package/lib/root-constructs/nextjs-regional-containers.js +1 -1
  38. package/lib/root-constructs/nextjs-regional-functions.js +1 -1
  39. package/lib/runtime/core.js +3 -1
  40. package/lib/runtime/image-utils.d.ts +8 -9
  41. package/lib/runtime/image-utils.js +16 -1
  42. package/lib/runtime/image-utils.test.js +13 -1
  43. package/lib/runtime/image.js +9 -3
  44. package/lib/runtime/lambda.mjs +50 -15
  45. package/lib/runtime/server.mjs +50 -15
  46. package/lib/runtime/tag-manifest.d.ts +25 -0
  47. package/lib/runtime/tag-manifest.js +37 -2
  48. package/lib/runtime/tag-manifest.test.js +27 -1
  49. package/package.json +3 -3
  50. package/scripts/e2e-deploy.sh +7 -2
  51. package/scripts/e2e-harness/README.md +72 -35
  52. package/scripts/e2e-harness/screen.mjs +148 -7
  53. package/scripts/playwright-install-deps.sh +40 -0
@@ -46324,6 +46324,19 @@ function sha256Hex(value) {
46324
46324
  return createHash6("sha256").update(value).digest("hex");
46325
46325
  }
46326
46326
 
46327
+ // src/runtime/tag-manifest.ts
46328
+ var OUTSIDE_REQUEST_SYMBOL = /* @__PURE__ */ Symbol.for(
46329
+ "cdk-nextjs.outside-request-context"
46330
+ );
46331
+ function outsideRequest(fn) {
46332
+ const global = globalThis;
46333
+ const run = global[OUTSIDE_REQUEST_SYMBOL];
46334
+ return run ? run(fn) : fn();
46335
+ }
46336
+ var TAG_MANIFEST_SYMBOL = /* @__PURE__ */ Symbol.for(
46337
+ "cdk-nextjs.use-cache.tag-manifest"
46338
+ );
46339
+
46327
46340
  // src/adapter/aws-cache-store.ts
46328
46341
  function resolveAwsCacheConfig() {
46329
46342
  return {
@@ -46891,6 +46904,18 @@ var TrackedTagMarkers = class {
46891
46904
  }
46892
46905
  return this.caughtUpRender.run(true, render);
46893
46906
  }
46907
+ /**
46908
+ * Run `fn` outside the request's context (`outsideRequest`), keeping only
46909
+ * whether the render was {@link catchUp caught up}: a cache handler method
46910
+ * called from inside a staged render, whose clock reads and AWS SDK calls
46911
+ * would otherwise end its static stage.
46912
+ */
46913
+ outsideRender(fn) {
46914
+ const caughtUp = this.caughtUpRender.getStore();
46915
+ return outsideRequest(
46916
+ () => caughtUp ? this.caughtUpRender.run(caughtUp, fn) : fn()
46917
+ );
46918
+ }
46894
46919
  /** Whether `at` is more than the interval and the grace ago. */
46895
46920
  overdue(at) {
46896
46921
  return this.clock() - at > this.refreshIntervalMs + TAG_REFRESH_GRACE_MS;
@@ -47483,13 +47508,6 @@ var CacheBucket = class {
47483
47508
  // src/adapter/use-cache-common.ts
47484
47509
  var import_client_dynamodb2 = __toESM(require_dist_cjs20());
47485
47510
  var import_debug5 = __toESM(require_src());
47486
-
47487
- // src/runtime/tag-manifest.ts
47488
- var TAG_MANIFEST_SYMBOL = /* @__PURE__ */ Symbol.for(
47489
- "cdk-nextjs.use-cache.tag-manifest"
47490
- );
47491
-
47492
- // src/adapter/use-cache-common.ts
47493
47511
  function isBuildPhase() {
47494
47512
  return process.env.NEXT_PHASE === "phase-production-build";
47495
47513
  }
@@ -47704,15 +47722,18 @@ function tagMethods(tags, options = {}) {
47704
47722
  }
47705
47723
  };
47706
47724
  }
47725
+ function outsideRender(fn) {
47726
+ return outsideRequest(sharedTagManifest).outsideRender(fn);
47727
+ }
47707
47728
  function lazyHandler(create) {
47708
47729
  let handler;
47709
47730
  const instance = () => handler ??= create();
47710
47731
  return {
47711
- get: (cacheKey, softTags) => instance().get(cacheKey, softTags),
47712
- set: (cacheKey, pendingEntry) => instance().set(cacheKey, pendingEntry),
47713
- refreshTags: () => instance().refreshTags(),
47714
- getExpiration: (tags) => instance().getExpiration(tags),
47715
- updateTags: (tags, durations) => instance().updateTags(tags, durations)
47732
+ get: (cacheKey, softTags) => outsideRender(() => instance().get(cacheKey, softTags)),
47733
+ set: (cacheKey, pendingEntry) => outsideRender(() => instance().set(cacheKey, pendingEntry)),
47734
+ refreshTags: () => outsideRender(() => instance().refreshTags()),
47735
+ getExpiration: (tags) => outsideRender(() => instance().getExpiration(tags)),
47736
+ updateTags: (tags, durations) => outsideRender(() => instance().updateTags(tags, durations))
47716
47737
  };
47717
47738
  }
47718
47739
  function sharedTagManifest() {
package/lib/nextjs-api.js CHANGED
@@ -22,7 +22,7 @@ const API_PATH_PART = /^[a-zA-Z0-9:._\-$]+$/;
22
22
  * Creates an API Gateway REST API for Next.js applications
23
23
  */
24
24
  class NextjsApi extends constructs_1.Construct {
25
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsApi", version: "0.7.7" };
25
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsApi", version: "0.7.8" };
26
26
  /**
27
27
  * The API Gateway REST API
28
28
  */
@@ -65,7 +65,7 @@ function deploymentArchitecture(props) {
65
65
  * @link https://nextjs.org/docs/pages/api-reference/next-config-js/output
66
66
  */
67
67
  class NextjsBuild extends constructs_1.Construct {
68
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsBuild", version: "0.7.7" };
68
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsBuild", version: "0.7.8" };
69
69
  /**
70
70
  * Unique id for this deployment. Used to partition cache storage and as
71
71
  * metadata for static assets in S3 bucket.
@@ -86,7 +86,7 @@ function sizeOfDirectory(dir) {
86
86
  * Next.js Cache construct providing unified S3 and DynamoDB cache management.
87
87
  */
88
88
  class NextjsCache extends constructs_1.Construct {
89
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsCache", version: "0.7.7" };
89
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsCache", version: "0.7.8" };
90
90
  cacheBucket;
91
91
  revalidationTable;
92
92
  buildId;
@@ -19,7 +19,7 @@ const constants_1 = require("../constants");
19
19
  * Fargate.
20
20
  */
21
21
  class NextjsContainers extends constructs_1.Construct {
22
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsContainers", version: "0.7.7" };
22
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsContainers", version: "0.7.8" };
23
23
  albFargateService;
24
24
  ecsCluster;
25
25
  url;
@@ -23,7 +23,7 @@ const zip_directory_1 = require("../utils/zip-directory");
23
23
  * `awslambda.streamifyResponse` directly.
24
24
  */
25
25
  class NextjsFunctions extends constructs_1.Construct {
26
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsFunctions", version: "0.7.7" };
26
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsFunctions", version: "0.7.8" };
27
27
  /**
28
28
  * The `default` group's function: the one the distribution's default behavior
29
29
  * targets, and the only one at all unless `functionGroups` is used.
@@ -11,7 +11,7 @@ const function_groups_1 = require("./adapter/function-groups");
11
11
  const constants_1 = require("./constants");
12
12
  const base_path_1 = require("./utils/base-path");
13
13
  class NextjsDistribution extends constructs_1.Construct {
14
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsDistribution", version: "0.7.7" };
14
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsDistribution", version: "0.7.8" };
15
15
  distribution;
16
16
  props;
17
17
  /**
@@ -18,7 +18,7 @@ const base_path_1 = require("./utils/base-path");
18
18
  * current build id AND are older than `msTtl`
19
19
  */
20
20
  class NextjsPostDeploy extends constructs_1.Construct {
21
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsPostDeploy", version: "0.7.7" };
21
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsPostDeploy", version: "0.7.8" };
22
22
  customResource;
23
23
  lambdaFunction;
24
24
  props;
@@ -29,7 +29,7 @@ function staticAssetsObjectsPattern(keyPrefix) {
29
29
  * Creates S3 Bucket for public and _next/static assets and deploys them using S3Deployment.
30
30
  */
31
31
  class NextjsStaticAssets extends constructs_1.Construct {
32
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsStaticAssets", version: "0.7.7" };
32
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsStaticAssets", version: "0.7.8" };
33
33
  bucket;
34
34
  deployment;
35
35
  /**
@@ -15,7 +15,7 @@ const base_path_1 = require("../utils/base-path");
15
15
  * Base class for all Next.js root constructs
16
16
  */
17
17
  class NextjsBaseConstruct extends constructs_1.Construct {
18
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsBaseConstruct", version: "0.7.7" };
18
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsBaseConstruct", version: "0.7.8" };
19
19
  nextjsBuild;
20
20
  nextjsStaticAssets;
21
21
  nextjsCache;
@@ -14,7 +14,7 @@ const base_path_1 = require("../utils/base-path");
14
14
  * for containers.
15
15
  */
16
16
  class NextjsGlobalContainers extends nextjs_base_construct_1.NextjsBaseConstruct {
17
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsGlobalContainers", version: "0.7.7" };
17
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsGlobalContainers", version: "0.7.8" };
18
18
  nextjsContainers;
19
19
  nextjsDistribution;
20
20
  nextjsPostDeploy;
@@ -17,7 +17,7 @@ const base_path_1 = require("../utils/base-path");
17
17
  * for functions.
18
18
  */
19
19
  class NextjsGlobalFunctions extends nextjs_base_construct_1.NextjsBaseConstruct {
20
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsGlobalFunctions", version: "0.7.7" };
20
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsGlobalFunctions", version: "0.7.8" };
21
21
  nextjsFunctions;
22
22
  nextjsDistribution;
23
23
  nextjsPostDeploy;
@@ -13,7 +13,7 @@ const base_path_1 = require("../utils/base-path");
13
13
  * for containers.
14
14
  */
15
15
  class NextjsRegionalContainers extends nextjs_base_construct_1.NextjsBaseConstruct {
16
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsRegionalContainers", version: "0.7.7" };
16
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsRegionalContainers", version: "0.7.8" };
17
17
  nextjsContainers;
18
18
  nextjsPostDeploy;
19
19
  /**
@@ -11,7 +11,7 @@ const nextjs_base_construct_1 = require("./nextjs-base-construct");
11
11
  * for routing requests and AWS Lambda Functions for server-side rendering.
12
12
  */
13
13
  class NextjsRegionalFunctions extends nextjs_base_construct_1.NextjsBaseConstruct {
14
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsRegionalFunctions", version: "0.7.7" };
14
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-nextjs.NextjsRegionalFunctions", version: "0.7.8" };
15
15
  nextjsFunctions;
16
16
  nextjsApi;
17
17
  nextjsPostDeploy;