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.
Files changed (266) hide show
  1. package/.jsii +2467 -2714
  2. package/.jsii.tabl.json +1 -1
  3. package/API.md +1725 -1909
  4. package/CLAUDE.md +2 -1
  5. package/README.md +429 -130
  6. package/assets/lambdas/post-deploy/post-deploy.lambda/index.js +152 -170
  7. package/assets/lambdas/redeploy-stage/redeploy-stage.lambda/index.js +875 -0
  8. package/docs/adapter-runtime.md +185 -0
  9. package/docs/breaking-changes.md +687 -4
  10. package/docs/caching-guide.md +156 -112
  11. package/docs/cdk-nextjs-cfn-exec-policy.json +2 -1
  12. package/docs/development-guide.md +1 -1
  13. package/docs/harness-coverage.md +598 -0
  14. package/docs/init-cache-deployment.md +32 -1
  15. package/docs/next-build-output-guide.md +30 -20
  16. package/examples/README.md +5 -1
  17. package/lib/adapter/__fixtures__/app-playground-base-path.json +4926 -0
  18. package/lib/adapter/__fixtures__/app-playground.json +4917 -0
  19. package/lib/adapter/__fixtures__/pages-i18n.json +1728 -0
  20. package/lib/adapter/adapter.mjs +1548 -185
  21. package/lib/adapter/adapter.test.js +106 -0
  22. package/lib/adapter/aws-cache-store.d.ts +489 -0
  23. package/lib/adapter/aws-cache-store.js +1004 -0
  24. package/lib/adapter/aws-cache-store.test.d.ts +1 -0
  25. package/lib/adapter/aws-cache-store.test.js +361 -0
  26. package/lib/adapter/build-outputs.d.ts +80 -0
  27. package/lib/adapter/build-outputs.js +852 -0
  28. package/lib/adapter/build-outputs.test.d.ts +1 -0
  29. package/lib/adapter/build-outputs.test.js +861 -0
  30. package/lib/adapter/cache-handler.d.ts +9 -2
  31. package/lib/adapter/cache-handler.js +72 -96
  32. package/lib/adapter/cache-handler.mjs +18956 -17774
  33. package/lib/adapter/cache-handler.test.js +263 -31
  34. package/lib/adapter/cache-kinds.d.ts +32 -0
  35. package/lib/adapter/cache-kinds.js +35 -0
  36. package/lib/adapter/cache-kinds.test.d.ts +1 -0
  37. package/lib/adapter/cache-kinds.test.js +69 -0
  38. package/lib/adapter/cache-utils.d.ts +90 -0
  39. package/lib/adapter/cache-utils.js +199 -4
  40. package/lib/adapter/cache-utils.test.d.ts +1 -0
  41. package/lib/adapter/cache-utils.test.js +179 -0
  42. package/lib/adapter/function-groups.d.ts +215 -0
  43. package/lib/adapter/function-groups.js +1099 -0
  44. package/lib/adapter/function-groups.test.d.ts +1 -0
  45. package/lib/adapter/function-groups.test.js +743 -0
  46. package/lib/adapter/init-cache.d.ts +6 -0
  47. package/lib/adapter/init-cache.js +245 -0
  48. package/lib/adapter/init-cache.test.d.ts +1 -0
  49. package/lib/adapter/init-cache.test.js +137 -0
  50. package/lib/adapter/local-file-cache-handler.d.ts +23 -0
  51. package/lib/adapter/local-file-cache-handler.js +52 -1
  52. package/lib/adapter/memory-cache-handler.d.ts +26 -17
  53. package/lib/adapter/memory-cache-handler.js +32 -50
  54. package/lib/adapter/memory-cache-handler.test.js +105 -85
  55. package/lib/adapter/s3-cache-handler.d.ts +179 -40
  56. package/lib/adapter/s3-cache-handler.js +807 -277
  57. package/lib/adapter/s3-cache-handler.test.js +1186 -31
  58. package/lib/adapter/use-cache-common.d.ts +90 -0
  59. package/lib/adapter/use-cache-common.js +250 -0
  60. package/lib/adapter/use-cache-common.test.d.ts +1 -0
  61. package/lib/adapter/use-cache-common.test.js +646 -0
  62. package/lib/adapter/use-cache-default-handler.d.ts +24 -0
  63. package/lib/adapter/use-cache-default-handler.js +90 -0
  64. package/lib/adapter/use-cache-default-handler.mjs +38645 -0
  65. package/lib/adapter/use-cache-handlers.test.d.ts +1 -0
  66. package/lib/adapter/use-cache-handlers.test.js +349 -0
  67. package/lib/adapter/use-cache-remote-handler.d.ts +26 -0
  68. package/lib/adapter/use-cache-remote-handler.js +186 -0
  69. package/lib/{image-optimization/handler.mjs → adapter/use-cache-remote-handler.mjs} +33572 -38798
  70. package/lib/generated-structs/OptionalNextjsApiProps.d.ts +59 -0
  71. package/lib/generated-structs/OptionalNextjsApiProps.js +3 -0
  72. package/lib/generated-structs/OptionalNextjsCacheProps.d.ts +15 -6
  73. package/lib/generated-structs/OptionalNextjsCacheProps.js +1 -1
  74. package/lib/generated-structs/OptionalNextjsContainersProps.d.ts +25 -11
  75. package/lib/generated-structs/OptionalNextjsContainersProps.js +1 -1
  76. package/lib/generated-structs/OptionalNextjsDistributionProps.d.ts +31 -9
  77. package/lib/generated-structs/OptionalNextjsDistributionProps.js +1 -1
  78. package/lib/generated-structs/OptionalNextjsPostDeployProps.d.ts +13 -0
  79. package/lib/generated-structs/OptionalNextjsPostDeployProps.js +1 -1
  80. package/lib/generated-structs/OptionalPostDeployCustomResourceProperties.d.ts +11 -2
  81. package/lib/generated-structs/OptionalPostDeployCustomResourceProperties.js +1 -1
  82. package/lib/index.d.ts +6 -7
  83. package/lib/index.js +2 -4
  84. package/lib/lambdas/post-deploy/post-deploy.lambda.js +3 -2
  85. package/lib/lambdas/post-deploy/prune-cache-bucket.d.ts +7 -3
  86. package/lib/lambdas/post-deploy/prune-cache-bucket.js +57 -71
  87. package/lib/lambdas/post-deploy/prune-cache-bucket.test.d.ts +1 -0
  88. package/lib/lambdas/post-deploy/prune-cache-bucket.test.js +114 -0
  89. package/lib/lambdas/post-deploy/prune-revalidation-table.d.ts +1 -0
  90. package/lib/lambdas/post-deploy/prune-revalidation-table.js +23 -31
  91. package/lib/lambdas/post-deploy/prune-revalidation-table.test.d.ts +1 -0
  92. package/lib/lambdas/post-deploy/prune-revalidation-table.test.js +71 -0
  93. package/lib/lambdas/post-deploy/prune-s3.d.ts +19 -3
  94. package/lib/lambdas/post-deploy/prune-s3.js +54 -15
  95. package/lib/lambdas/post-deploy/prune-s3.test.d.ts +1 -0
  96. package/lib/lambdas/post-deploy/prune-s3.test.js +255 -0
  97. package/lib/lambdas/redeploy-stage/redeploy-stage-function.d.ts +13 -0
  98. package/lib/lambdas/redeploy-stage/redeploy-stage-function.js +55 -0
  99. package/lib/lambdas/redeploy-stage/redeploy-stage.d.ts +24 -0
  100. package/lib/lambdas/redeploy-stage/redeploy-stage.js +68 -0
  101. package/lib/lambdas/redeploy-stage/redeploy-stage.lambda.d.ts +20 -0
  102. package/lib/lambdas/redeploy-stage/redeploy-stage.lambda.js +24 -0
  103. package/lib/lambdas/redeploy-stage/redeploy-stage.test.d.ts +1 -0
  104. package/lib/lambdas/redeploy-stage/redeploy-stage.test.js +93 -0
  105. package/lib/nextjs-api.d.ts +107 -18
  106. package/lib/nextjs-api.js +349 -39
  107. package/lib/nextjs-api.test.js +582 -1
  108. package/lib/nextjs-build/global-containers.Dockerfile +15 -10
  109. package/lib/nextjs-build/nextjs-build.d.ts +339 -63
  110. package/lib/nextjs-build/nextjs-build.js +684 -327
  111. package/lib/nextjs-build/nextjs-build.test.d.ts +1 -0
  112. package/lib/nextjs-build/nextjs-build.test.js +412 -0
  113. package/lib/nextjs-build/patch-fetch.js +1 -1
  114. package/lib/nextjs-build/patch-fetch.test.js +166 -11
  115. package/lib/nextjs-build/regional-containers.Dockerfile +17 -10
  116. package/lib/nextjs-cache.d.ts +82 -4
  117. package/lib/nextjs-cache.js +186 -10
  118. package/lib/nextjs-cache.test.js +176 -1
  119. package/lib/nextjs-compute/nextjs-compute-base-props.d.ts +21 -8
  120. package/lib/nextjs-compute/nextjs-compute-base-props.js +41 -1
  121. package/lib/nextjs-compute/nextjs-compute-base-props.test.d.ts +1 -0
  122. package/lib/nextjs-compute/nextjs-compute-base-props.test.js +44 -0
  123. package/lib/nextjs-compute/nextjs-containers.d.ts +19 -0
  124. package/lib/nextjs-compute/nextjs-containers.js +57 -20
  125. package/lib/nextjs-compute/nextjs-functions.d.ts +122 -7
  126. package/lib/nextjs-compute/nextjs-functions.js +113 -67
  127. package/lib/nextjs-compute/nextjs-functions.test.d.ts +1 -0
  128. package/lib/nextjs-compute/nextjs-functions.test.js +99 -0
  129. package/lib/nextjs-distribution.d.ts +194 -23
  130. package/lib/nextjs-distribution.js +535 -62
  131. package/lib/nextjs-distribution.test.d.ts +1 -0
  132. package/lib/nextjs-distribution.test.js +697 -0
  133. package/lib/nextjs-post-deploy.d.ts +23 -3
  134. package/lib/nextjs-post-deploy.js +14 -10
  135. package/lib/nextjs-post-deploy.test.d.ts +1 -0
  136. package/lib/nextjs-post-deploy.test.js +34 -0
  137. package/lib/nextjs-static-assets.d.ts +23 -4
  138. package/lib/nextjs-static-assets.js +29 -6
  139. package/lib/nextjs-static-assets.test.js +20 -1
  140. package/lib/root-constructs/nextjs-base-construct.d.ts +105 -45
  141. package/lib/root-constructs/nextjs-base-construct.js +144 -34
  142. package/lib/root-constructs/nextjs-global-containers.d.ts +18 -20
  143. package/lib/root-constructs/nextjs-global-containers.js +20 -70
  144. package/lib/root-constructs/nextjs-global-functions.d.ts +26 -28
  145. package/lib/root-constructs/nextjs-global-functions.js +52 -69
  146. package/lib/root-constructs/nextjs-regional-containers.d.ts +25 -5
  147. package/lib/root-constructs/nextjs-regional-containers.js +17 -15
  148. package/lib/root-constructs/nextjs-regional-functions.d.ts +22 -18
  149. package/lib/root-constructs/nextjs-regional-functions.js +8 -25
  150. package/lib/runtime/api-gateway-path.d.ts +34 -0
  151. package/lib/runtime/api-gateway-path.js +71 -0
  152. package/lib/runtime/api-gateway-path.test.d.ts +1 -0
  153. package/lib/runtime/api-gateway-path.test.js +65 -0
  154. package/lib/runtime/case-redirect.d.ts +22 -0
  155. package/lib/runtime/case-redirect.js +63 -0
  156. package/lib/runtime/case-redirect.test.d.ts +1 -0
  157. package/lib/runtime/case-redirect.test.js +32 -0
  158. package/lib/runtime/core.d.ts +234 -0
  159. package/lib/runtime/core.js +1213 -0
  160. package/lib/runtime/core.test.d.ts +1 -0
  161. package/lib/runtime/core.test.js +1678 -0
  162. package/lib/runtime/deployment-root.d.ts +13 -0
  163. package/lib/runtime/deployment-root.js +29 -0
  164. package/lib/runtime/dispatch.d.ts +331 -0
  165. package/lib/runtime/dispatch.js +751 -0
  166. package/lib/runtime/dispatch.test.d.ts +1 -0
  167. package/lib/runtime/dispatch.test.js +853 -0
  168. package/lib/runtime/entrypoints.d.ts +57 -0
  169. package/lib/runtime/entrypoints.js +115 -0
  170. package/lib/runtime/http/abort-signal.d.ts +6 -0
  171. package/lib/runtime/http/abort-signal.js +19 -0
  172. package/lib/runtime/http/abort-signal.test.d.ts +1 -0
  173. package/lib/runtime/http/abort-signal.test.js +49 -0
  174. package/lib/runtime/http/node-server.d.ts +38 -0
  175. package/lib/runtime/http/node-server.js +99 -0
  176. package/lib/runtime/http/node-server.test.d.ts +1 -0
  177. package/lib/runtime/http/node-server.test.js +96 -0
  178. package/lib/runtime/http/node-sink.d.ts +16 -0
  179. package/lib/runtime/http/node-sink.js +48 -0
  180. package/lib/runtime/http/node-sink.test.d.ts +1 -0
  181. package/lib/runtime/http/node-sink.test.js +66 -0
  182. package/lib/runtime/http/request.d.ts +62 -0
  183. package/lib/runtime/http/request.js +134 -0
  184. package/lib/runtime/http/request.test.d.ts +1 -0
  185. package/lib/runtime/http/request.test.js +103 -0
  186. package/lib/runtime/http/response.d.ts +77 -0
  187. package/lib/runtime/http/response.js +229 -0
  188. package/lib/runtime/http/response.test.d.ts +1 -0
  189. package/lib/runtime/http/response.test.js +178 -0
  190. package/lib/runtime/http/sink.d.ts +73 -0
  191. package/lib/runtime/http/sink.js +188 -0
  192. package/lib/runtime/http/sink.test.d.ts +1 -0
  193. package/lib/runtime/http/sink.test.js +257 -0
  194. package/lib/runtime/image-utils.d.ts +78 -0
  195. package/lib/runtime/image-utils.js +129 -0
  196. package/lib/runtime/image-utils.test.d.ts +1 -0
  197. package/lib/runtime/image-utils.test.js +237 -0
  198. package/lib/runtime/image.d.ts +76 -0
  199. package/lib/runtime/image.js +296 -0
  200. package/lib/runtime/image.test.d.ts +1 -0
  201. package/lib/runtime/image.test.js +405 -0
  202. package/lib/runtime/lambda-event.d.ts +4 -0
  203. package/lib/runtime/lambda-event.js +113 -0
  204. package/lib/runtime/lambda-event.test.d.ts +1 -0
  205. package/lib/runtime/lambda-event.test.js +119 -0
  206. package/lib/runtime/lambda.mjs +41595 -0
  207. package/lib/runtime/load-module.d.ts +8 -0
  208. package/lib/runtime/load-module.js +35 -0
  209. package/lib/runtime/manifest.d.ts +215 -0
  210. package/lib/runtime/manifest.js +118 -0
  211. package/lib/runtime/middleware.d.ts +43 -0
  212. package/lib/runtime/middleware.js +113 -0
  213. package/lib/runtime/middleware.test.d.ts +1 -0
  214. package/lib/runtime/middleware.test.js +259 -0
  215. package/lib/runtime/next-modules.d.ts +55 -0
  216. package/lib/runtime/next-modules.js +124 -0
  217. package/lib/runtime/next-modules.test.d.ts +1 -0
  218. package/lib/runtime/next-modules.test.js +34 -0
  219. package/lib/runtime/public-files.d.ts +32 -0
  220. package/lib/runtime/public-files.js +117 -0
  221. package/lib/runtime/public-files.test.d.ts +1 -0
  222. package/lib/runtime/public-files.test.js +97 -0
  223. package/lib/runtime/server.mjs +41588 -0
  224. package/lib/runtime/static-files.d.ts +50 -0
  225. package/lib/runtime/static-files.js +266 -0
  226. package/lib/runtime/static-files.test.d.ts +1 -0
  227. package/lib/runtime/static-files.test.js +118 -0
  228. package/lib/runtime/util.d.ts +28 -0
  229. package/lib/runtime/util.js +79 -0
  230. package/lib/utils/base-path.d.ts +123 -11
  231. package/lib/utils/base-path.js +276 -39
  232. package/lib/utils/base-path.test.js +275 -50
  233. package/lib/utils/get-architecture.d.ts +7 -8
  234. package/lib/utils/get-architecture.js +12 -13
  235. package/lib/utils/zip-directory.d.ts +14 -0
  236. package/lib/utils/zip-directory.js +121 -0
  237. package/lib/utils/zip-directory.test.d.ts +1 -0
  238. package/lib/utils/zip-directory.test.js +99 -0
  239. package/package.json +22 -3
  240. package/scripts/capture-adapter-fixture.mjs +325 -0
  241. package/scripts/e2e-deploy.sh +398 -0
  242. package/scripts/e2e-harness/README.md +707 -0
  243. package/scripts/e2e-harness/app.js +370 -0
  244. package/scripts/e2e-harness/common.sh +249 -0
  245. package/scripts/e2e-harness/screen.mjs +302 -0
  246. package/scripts/e2e-harness/stage-proxy.mjs +145 -0
  247. package/scripts/e2e-harness/type-filters.mjs +47 -0
  248. package/scripts/e2e-logs.sh +75 -0
  249. package/scripts/e2e-offline.sh +91 -0
  250. package/scripts/e2e-sweep.sh +370 -0
  251. package/scripts/e2e-warm.sh +114 -0
  252. package/scripts/zero-config-build.mjs +418 -0
  253. package/docs/1k-concurrent-users-executions.png +0 -0
  254. package/docs/plans/adapter-runtime-release.md +0 -362
  255. package/docs/plans/phase-0-image-function-opt-in.md +0 -295
  256. package/lib/generated-structs/OptionalDockerImageFunctionProps.d.ts +0 -425
  257. package/lib/generated-structs/OptionalDockerImageFunctionProps.js +0 -3
  258. package/lib/image-optimization/handler-utils.d.ts +0 -34
  259. package/lib/image-optimization/handler-utils.js +0 -83
  260. package/lib/image-optimization/handler-utils.test.js +0 -178
  261. package/lib/nextjs-build/functions.Dockerfile +0 -31
  262. package/lib/nextjs-compute/nextjs-image-function.d.ts +0 -53
  263. package/lib/nextjs-compute/nextjs-image-function.js +0 -59
  264. package/lib/utils/experimental-flags.d.ts +0 -24
  265. package/lib/utils/experimental-flags.js +0 -30
  266. /package/lib/{image-optimization/handler-utils.test.d.ts → adapter/adapter.test.d.ts} +0 -0
@@ -0,0 +1,875 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
14
+ };
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
+ mod
34
+ ));
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
38
+ var require_ms = __commonJS({
39
+ "node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports2, module2) {
40
+ "use strict";
41
+ var s = 1e3;
42
+ var m = s * 60;
43
+ var h = m * 60;
44
+ var d = h * 24;
45
+ var w = d * 7;
46
+ var y = d * 365.25;
47
+ module2.exports = function(val, options) {
48
+ options = options || {};
49
+ var type = typeof val;
50
+ if (type === "string" && val.length > 0) {
51
+ return parse(val);
52
+ } else if (type === "number" && isFinite(val)) {
53
+ return options.long ? fmtLong(val) : fmtShort(val);
54
+ }
55
+ throw new Error(
56
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
57
+ );
58
+ };
59
+ function parse(str) {
60
+ str = String(str);
61
+ if (str.length > 100) {
62
+ return;
63
+ }
64
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
65
+ str
66
+ );
67
+ if (!match) {
68
+ return;
69
+ }
70
+ var n = parseFloat(match[1]);
71
+ var type = (match[2] || "ms").toLowerCase();
72
+ switch (type) {
73
+ case "years":
74
+ case "year":
75
+ case "yrs":
76
+ case "yr":
77
+ case "y":
78
+ return n * y;
79
+ case "weeks":
80
+ case "week":
81
+ case "w":
82
+ return n * w;
83
+ case "days":
84
+ case "day":
85
+ case "d":
86
+ return n * d;
87
+ case "hours":
88
+ case "hour":
89
+ case "hrs":
90
+ case "hr":
91
+ case "h":
92
+ return n * h;
93
+ case "minutes":
94
+ case "minute":
95
+ case "mins":
96
+ case "min":
97
+ case "m":
98
+ return n * m;
99
+ case "seconds":
100
+ case "second":
101
+ case "secs":
102
+ case "sec":
103
+ case "s":
104
+ return n * s;
105
+ case "milliseconds":
106
+ case "millisecond":
107
+ case "msecs":
108
+ case "msec":
109
+ case "ms":
110
+ return n;
111
+ default:
112
+ return void 0;
113
+ }
114
+ }
115
+ function fmtShort(ms) {
116
+ var msAbs = Math.abs(ms);
117
+ if (msAbs >= d) {
118
+ return Math.round(ms / d) + "d";
119
+ }
120
+ if (msAbs >= h) {
121
+ return Math.round(ms / h) + "h";
122
+ }
123
+ if (msAbs >= m) {
124
+ return Math.round(ms / m) + "m";
125
+ }
126
+ if (msAbs >= s) {
127
+ return Math.round(ms / s) + "s";
128
+ }
129
+ return ms + "ms";
130
+ }
131
+ function fmtLong(ms) {
132
+ var msAbs = Math.abs(ms);
133
+ if (msAbs >= d) {
134
+ return plural(ms, msAbs, d, "day");
135
+ }
136
+ if (msAbs >= h) {
137
+ return plural(ms, msAbs, h, "hour");
138
+ }
139
+ if (msAbs >= m) {
140
+ return plural(ms, msAbs, m, "minute");
141
+ }
142
+ if (msAbs >= s) {
143
+ return plural(ms, msAbs, s, "second");
144
+ }
145
+ return ms + " ms";
146
+ }
147
+ function plural(ms, msAbs, n, name) {
148
+ var isPlural = msAbs >= n * 1.5;
149
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
150
+ }
151
+ }
152
+ });
153
+
154
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
155
+ var require_common = __commonJS({
156
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
157
+ "use strict";
158
+ function setup(env) {
159
+ createDebug.debug = createDebug;
160
+ createDebug.default = createDebug;
161
+ createDebug.coerce = coerce;
162
+ createDebug.disable = disable;
163
+ createDebug.enable = enable;
164
+ createDebug.enabled = enabled;
165
+ createDebug.humanize = require_ms();
166
+ createDebug.destroy = destroy;
167
+ Object.keys(env).forEach((key) => {
168
+ createDebug[key] = env[key];
169
+ });
170
+ createDebug.names = [];
171
+ createDebug.skips = [];
172
+ createDebug.formatters = {};
173
+ function selectColor(namespace) {
174
+ let hash = 0;
175
+ for (let i = 0; i < namespace.length; i++) {
176
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
177
+ hash |= 0;
178
+ }
179
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
180
+ }
181
+ createDebug.selectColor = selectColor;
182
+ function createDebug(namespace) {
183
+ let prevTime;
184
+ let enableOverride = null;
185
+ let namespacesCache;
186
+ let enabledCache;
187
+ function debug2(...args) {
188
+ if (!debug2.enabled) {
189
+ return;
190
+ }
191
+ const self = debug2;
192
+ const curr = Number(/* @__PURE__ */ new Date());
193
+ const ms = curr - (prevTime || curr);
194
+ self.diff = ms;
195
+ self.prev = prevTime;
196
+ self.curr = curr;
197
+ prevTime = curr;
198
+ args[0] = createDebug.coerce(args[0]);
199
+ if (typeof args[0] !== "string") {
200
+ args.unshift("%O");
201
+ }
202
+ let index = 0;
203
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
204
+ if (match === "%%") {
205
+ return "%";
206
+ }
207
+ index++;
208
+ const formatter = createDebug.formatters[format];
209
+ if (typeof formatter === "function") {
210
+ const val = args[index];
211
+ match = formatter.call(self, val);
212
+ args.splice(index, 1);
213
+ index--;
214
+ }
215
+ return match;
216
+ });
217
+ createDebug.formatArgs.call(self, args);
218
+ const logFn = self.log || createDebug.log;
219
+ logFn.apply(self, args);
220
+ }
221
+ debug2.namespace = namespace;
222
+ debug2.useColors = createDebug.useColors();
223
+ debug2.color = createDebug.selectColor(namespace);
224
+ debug2.extend = extend;
225
+ debug2.destroy = createDebug.destroy;
226
+ Object.defineProperty(debug2, "enabled", {
227
+ enumerable: true,
228
+ configurable: false,
229
+ get: () => {
230
+ if (enableOverride !== null) {
231
+ return enableOverride;
232
+ }
233
+ if (namespacesCache !== createDebug.namespaces) {
234
+ namespacesCache = createDebug.namespaces;
235
+ enabledCache = createDebug.enabled(namespace);
236
+ }
237
+ return enabledCache;
238
+ },
239
+ set: (v) => {
240
+ enableOverride = v;
241
+ }
242
+ });
243
+ if (typeof createDebug.init === "function") {
244
+ createDebug.init(debug2);
245
+ }
246
+ return debug2;
247
+ }
248
+ function extend(namespace, delimiter) {
249
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
250
+ newDebug.log = this.log;
251
+ return newDebug;
252
+ }
253
+ function enable(namespaces) {
254
+ createDebug.save(namespaces);
255
+ createDebug.namespaces = namespaces;
256
+ createDebug.names = [];
257
+ createDebug.skips = [];
258
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
259
+ for (const ns of split) {
260
+ if (ns[0] === "-") {
261
+ createDebug.skips.push(ns.slice(1));
262
+ } else {
263
+ createDebug.names.push(ns);
264
+ }
265
+ }
266
+ }
267
+ function matchesTemplate(search, template) {
268
+ let searchIndex = 0;
269
+ let templateIndex = 0;
270
+ let starIndex = -1;
271
+ let matchIndex = 0;
272
+ while (searchIndex < search.length) {
273
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
274
+ if (template[templateIndex] === "*") {
275
+ starIndex = templateIndex;
276
+ matchIndex = searchIndex;
277
+ templateIndex++;
278
+ } else {
279
+ searchIndex++;
280
+ templateIndex++;
281
+ }
282
+ } else if (starIndex !== -1) {
283
+ templateIndex = starIndex + 1;
284
+ matchIndex++;
285
+ searchIndex = matchIndex;
286
+ } else {
287
+ return false;
288
+ }
289
+ }
290
+ while (templateIndex < template.length && template[templateIndex] === "*") {
291
+ templateIndex++;
292
+ }
293
+ return templateIndex === template.length;
294
+ }
295
+ function disable() {
296
+ const namespaces = [
297
+ ...createDebug.names,
298
+ ...createDebug.skips.map((namespace) => "-" + namespace)
299
+ ].join(",");
300
+ createDebug.enable("");
301
+ return namespaces;
302
+ }
303
+ function enabled(name) {
304
+ for (const skip of createDebug.skips) {
305
+ if (matchesTemplate(name, skip)) {
306
+ return false;
307
+ }
308
+ }
309
+ for (const ns of createDebug.names) {
310
+ if (matchesTemplate(name, ns)) {
311
+ return true;
312
+ }
313
+ }
314
+ return false;
315
+ }
316
+ function coerce(val) {
317
+ if (val instanceof Error) {
318
+ return val.stack || val.message;
319
+ }
320
+ return val;
321
+ }
322
+ function destroy() {
323
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
324
+ }
325
+ createDebug.enable(createDebug.load());
326
+ return createDebug;
327
+ }
328
+ module2.exports = setup;
329
+ }
330
+ });
331
+
332
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
333
+ var require_browser = __commonJS({
334
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
335
+ "use strict";
336
+ exports2.formatArgs = formatArgs;
337
+ exports2.save = save;
338
+ exports2.load = load;
339
+ exports2.useColors = useColors;
340
+ exports2.storage = localstorage();
341
+ exports2.destroy = /* @__PURE__ */ (() => {
342
+ let warned = false;
343
+ return () => {
344
+ if (!warned) {
345
+ warned = true;
346
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
347
+ }
348
+ };
349
+ })();
350
+ exports2.colors = [
351
+ "#0000CC",
352
+ "#0000FF",
353
+ "#0033CC",
354
+ "#0033FF",
355
+ "#0066CC",
356
+ "#0066FF",
357
+ "#0099CC",
358
+ "#0099FF",
359
+ "#00CC00",
360
+ "#00CC33",
361
+ "#00CC66",
362
+ "#00CC99",
363
+ "#00CCCC",
364
+ "#00CCFF",
365
+ "#3300CC",
366
+ "#3300FF",
367
+ "#3333CC",
368
+ "#3333FF",
369
+ "#3366CC",
370
+ "#3366FF",
371
+ "#3399CC",
372
+ "#3399FF",
373
+ "#33CC00",
374
+ "#33CC33",
375
+ "#33CC66",
376
+ "#33CC99",
377
+ "#33CCCC",
378
+ "#33CCFF",
379
+ "#6600CC",
380
+ "#6600FF",
381
+ "#6633CC",
382
+ "#6633FF",
383
+ "#66CC00",
384
+ "#66CC33",
385
+ "#9900CC",
386
+ "#9900FF",
387
+ "#9933CC",
388
+ "#9933FF",
389
+ "#99CC00",
390
+ "#99CC33",
391
+ "#CC0000",
392
+ "#CC0033",
393
+ "#CC0066",
394
+ "#CC0099",
395
+ "#CC00CC",
396
+ "#CC00FF",
397
+ "#CC3300",
398
+ "#CC3333",
399
+ "#CC3366",
400
+ "#CC3399",
401
+ "#CC33CC",
402
+ "#CC33FF",
403
+ "#CC6600",
404
+ "#CC6633",
405
+ "#CC9900",
406
+ "#CC9933",
407
+ "#CCCC00",
408
+ "#CCCC33",
409
+ "#FF0000",
410
+ "#FF0033",
411
+ "#FF0066",
412
+ "#FF0099",
413
+ "#FF00CC",
414
+ "#FF00FF",
415
+ "#FF3300",
416
+ "#FF3333",
417
+ "#FF3366",
418
+ "#FF3399",
419
+ "#FF33CC",
420
+ "#FF33FF",
421
+ "#FF6600",
422
+ "#FF6633",
423
+ "#FF9900",
424
+ "#FF9933",
425
+ "#FFCC00",
426
+ "#FFCC33"
427
+ ];
428
+ function useColors() {
429
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
430
+ return true;
431
+ }
432
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
433
+ return false;
434
+ }
435
+ let m;
436
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
437
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
438
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
439
+ typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
440
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
441
+ }
442
+ function formatArgs(args) {
443
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
444
+ if (!this.useColors) {
445
+ return;
446
+ }
447
+ const c = "color: " + this.color;
448
+ args.splice(1, 0, c, "color: inherit");
449
+ let index = 0;
450
+ let lastC = 0;
451
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
452
+ if (match === "%%") {
453
+ return;
454
+ }
455
+ index++;
456
+ if (match === "%c") {
457
+ lastC = index;
458
+ }
459
+ });
460
+ args.splice(lastC, 0, c);
461
+ }
462
+ exports2.log = console.debug || console.log || (() => {
463
+ });
464
+ function save(namespaces) {
465
+ try {
466
+ if (namespaces) {
467
+ exports2.storage.setItem("debug", namespaces);
468
+ } else {
469
+ exports2.storage.removeItem("debug");
470
+ }
471
+ } catch (error) {
472
+ }
473
+ }
474
+ function load() {
475
+ let r;
476
+ try {
477
+ r = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
478
+ } catch (error) {
479
+ }
480
+ if (!r && typeof process !== "undefined" && "env" in process) {
481
+ r = process.env.DEBUG;
482
+ }
483
+ return r;
484
+ }
485
+ function localstorage() {
486
+ try {
487
+ return localStorage;
488
+ } catch (error) {
489
+ }
490
+ }
491
+ module2.exports = require_common()(exports2);
492
+ var { formatters } = module2.exports;
493
+ formatters.j = function(v) {
494
+ try {
495
+ return JSON.stringify(v);
496
+ } catch (error) {
497
+ return "[UnexpectedJSONParseError]: " + error.message;
498
+ }
499
+ };
500
+ }
501
+ });
502
+
503
+ // node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js
504
+ var require_has_flag = __commonJS({
505
+ "node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js"(exports2, module2) {
506
+ "use strict";
507
+ module2.exports = (flag, argv) => {
508
+ argv = argv || process.argv;
509
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
510
+ const pos = argv.indexOf(prefix + flag);
511
+ const terminatorPos = argv.indexOf("--");
512
+ return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
513
+ };
514
+ }
515
+ });
516
+
517
+ // node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js
518
+ var require_supports_color = __commonJS({
519
+ "node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
520
+ "use strict";
521
+ var os = require("os");
522
+ var hasFlag = require_has_flag();
523
+ var env = process.env;
524
+ var forceColor;
525
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
526
+ forceColor = false;
527
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
528
+ forceColor = true;
529
+ }
530
+ if ("FORCE_COLOR" in env) {
531
+ forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
532
+ }
533
+ function translateLevel(level) {
534
+ if (level === 0) {
535
+ return false;
536
+ }
537
+ return {
538
+ level,
539
+ hasBasic: true,
540
+ has256: level >= 2,
541
+ has16m: level >= 3
542
+ };
543
+ }
544
+ function supportsColor(stream) {
545
+ if (forceColor === false) {
546
+ return 0;
547
+ }
548
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
549
+ return 3;
550
+ }
551
+ if (hasFlag("color=256")) {
552
+ return 2;
553
+ }
554
+ if (stream && !stream.isTTY && forceColor !== true) {
555
+ return 0;
556
+ }
557
+ const min = forceColor ? 1 : 0;
558
+ if (process.platform === "win32") {
559
+ const osRelease = os.release().split(".");
560
+ if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
561
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
562
+ }
563
+ return 1;
564
+ }
565
+ if ("CI" in env) {
566
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
567
+ return 1;
568
+ }
569
+ return min;
570
+ }
571
+ if ("TEAMCITY_VERSION" in env) {
572
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
573
+ }
574
+ if (env.COLORTERM === "truecolor") {
575
+ return 3;
576
+ }
577
+ if ("TERM_PROGRAM" in env) {
578
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
579
+ switch (env.TERM_PROGRAM) {
580
+ case "iTerm.app":
581
+ return version >= 3 ? 3 : 2;
582
+ case "Apple_Terminal":
583
+ return 2;
584
+ }
585
+ }
586
+ if (/-256(color)?$/i.test(env.TERM)) {
587
+ return 2;
588
+ }
589
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
590
+ return 1;
591
+ }
592
+ if ("COLORTERM" in env) {
593
+ return 1;
594
+ }
595
+ if (env.TERM === "dumb") {
596
+ return min;
597
+ }
598
+ return min;
599
+ }
600
+ function getSupportLevel(stream) {
601
+ const level = supportsColor(stream);
602
+ return translateLevel(level);
603
+ }
604
+ module2.exports = {
605
+ supportsColor: getSupportLevel,
606
+ stdout: getSupportLevel(process.stdout),
607
+ stderr: getSupportLevel(process.stderr)
608
+ };
609
+ }
610
+ });
611
+
612
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
613
+ var require_node = __commonJS({
614
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
615
+ "use strict";
616
+ var tty = require("tty");
617
+ var util = require("util");
618
+ exports2.init = init;
619
+ exports2.log = log;
620
+ exports2.formatArgs = formatArgs;
621
+ exports2.save = save;
622
+ exports2.load = load;
623
+ exports2.useColors = useColors;
624
+ exports2.destroy = util.deprecate(
625
+ () => {
626
+ },
627
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
628
+ );
629
+ exports2.colors = [6, 2, 3, 4, 5, 1];
630
+ try {
631
+ const supportsColor = require_supports_color();
632
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
633
+ exports2.colors = [
634
+ 20,
635
+ 21,
636
+ 26,
637
+ 27,
638
+ 32,
639
+ 33,
640
+ 38,
641
+ 39,
642
+ 40,
643
+ 41,
644
+ 42,
645
+ 43,
646
+ 44,
647
+ 45,
648
+ 56,
649
+ 57,
650
+ 62,
651
+ 63,
652
+ 68,
653
+ 69,
654
+ 74,
655
+ 75,
656
+ 76,
657
+ 77,
658
+ 78,
659
+ 79,
660
+ 80,
661
+ 81,
662
+ 92,
663
+ 93,
664
+ 98,
665
+ 99,
666
+ 112,
667
+ 113,
668
+ 128,
669
+ 129,
670
+ 134,
671
+ 135,
672
+ 148,
673
+ 149,
674
+ 160,
675
+ 161,
676
+ 162,
677
+ 163,
678
+ 164,
679
+ 165,
680
+ 166,
681
+ 167,
682
+ 168,
683
+ 169,
684
+ 170,
685
+ 171,
686
+ 172,
687
+ 173,
688
+ 178,
689
+ 179,
690
+ 184,
691
+ 185,
692
+ 196,
693
+ 197,
694
+ 198,
695
+ 199,
696
+ 200,
697
+ 201,
698
+ 202,
699
+ 203,
700
+ 204,
701
+ 205,
702
+ 206,
703
+ 207,
704
+ 208,
705
+ 209,
706
+ 214,
707
+ 215,
708
+ 220,
709
+ 221
710
+ ];
711
+ }
712
+ } catch (error) {
713
+ }
714
+ exports2.inspectOpts = Object.keys(process.env).filter((key) => {
715
+ return /^debug_/i.test(key);
716
+ }).reduce((obj, key) => {
717
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
718
+ return k.toUpperCase();
719
+ });
720
+ let val = process.env[key];
721
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
722
+ val = true;
723
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
724
+ val = false;
725
+ } else if (val === "null") {
726
+ val = null;
727
+ } else {
728
+ val = Number(val);
729
+ }
730
+ obj[prop] = val;
731
+ return obj;
732
+ }, {});
733
+ function useColors() {
734
+ return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
735
+ }
736
+ function formatArgs(args) {
737
+ const { namespace: name, useColors: useColors2 } = this;
738
+ if (useColors2) {
739
+ const c = this.color;
740
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
741
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
742
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
743
+ args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
744
+ } else {
745
+ args[0] = getDate() + name + " " + args[0];
746
+ }
747
+ }
748
+ function getDate() {
749
+ if (exports2.inspectOpts.hideDate) {
750
+ return "";
751
+ }
752
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
753
+ }
754
+ function log(...args) {
755
+ return process.stderr.write(util.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
756
+ }
757
+ function save(namespaces) {
758
+ if (namespaces) {
759
+ process.env.DEBUG = namespaces;
760
+ } else {
761
+ delete process.env.DEBUG;
762
+ }
763
+ }
764
+ function load() {
765
+ return process.env.DEBUG;
766
+ }
767
+ function init(debug2) {
768
+ debug2.inspectOpts = {};
769
+ const keys = Object.keys(exports2.inspectOpts);
770
+ for (let i = 0; i < keys.length; i++) {
771
+ debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
772
+ }
773
+ }
774
+ module2.exports = require_common()(exports2);
775
+ var { formatters } = module2.exports;
776
+ formatters.o = function(v) {
777
+ this.inspectOpts.colors = this.useColors;
778
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
779
+ };
780
+ formatters.O = function(v) {
781
+ this.inspectOpts.colors = this.useColors;
782
+ return util.inspect(v, this.inspectOpts);
783
+ };
784
+ }
785
+ });
786
+
787
+ // node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
788
+ var require_src = __commonJS({
789
+ "node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
790
+ "use strict";
791
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
792
+ module2.exports = require_browser();
793
+ } else {
794
+ module2.exports = require_node();
795
+ }
796
+ }
797
+ });
798
+
799
+ // src/lambdas/redeploy-stage/redeploy-stage.lambda.ts
800
+ var redeploy_stage_lambda_exports = {};
801
+ __export(redeploy_stage_lambda_exports, {
802
+ handler: () => handler
803
+ });
804
+ module.exports = __toCommonJS(redeploy_stage_lambda_exports);
805
+
806
+ // src/lambdas/redeploy-stage/redeploy-stage.ts
807
+ var import_client_api_gateway = require("@aws-sdk/client-api-gateway");
808
+ var import_debug = __toESM(require_src());
809
+ var debug = (0, import_debug.default)("cdk-nextjs:redeploy-stage");
810
+ var REDEPLOY_DESCRIPTION_PREFIX = "cdk-nextjs: redeploy after";
811
+ var apiGateway = new import_client_api_gateway.APIGatewayClient({});
812
+ async function redeployStage({
813
+ restApiId,
814
+ stageName,
815
+ stackStatus
816
+ }) {
817
+ const created = await apiGateway.send(
818
+ new import_client_api_gateway.CreateDeploymentCommand({
819
+ restApiId,
820
+ stageName,
821
+ description: `${REDEPLOY_DESCRIPTION_PREFIX} ${stackStatus}`
822
+ })
823
+ );
824
+ const deploymentId = created.id;
825
+ debug(`Deployed ${restApiId}/${stageName} as ${deploymentId}`);
826
+ const { item: stages = [] } = await apiGateway.send(
827
+ new import_client_api_gateway.GetStagesCommand({ restApiId })
828
+ );
829
+ const referenced = new Set(stages.map((stage) => stage.deploymentId));
830
+ let position;
831
+ do {
832
+ const page = await apiGateway.send(
833
+ new import_client_api_gateway.GetDeploymentsCommand({ restApiId, position, limit: 500 })
834
+ );
835
+ for (const deployment of page.items ?? []) {
836
+ if (!deployment.id || deployment.id === deploymentId || referenced.has(deployment.id) || !deployment.description?.startsWith(REDEPLOY_DESCRIPTION_PREFIX)) {
837
+ continue;
838
+ }
839
+ try {
840
+ await apiGateway.send(
841
+ new import_client_api_gateway.DeleteDeploymentCommand({
842
+ restApiId,
843
+ deploymentId: deployment.id
844
+ })
845
+ );
846
+ debug(`Deleted previous redeploy ${deployment.id}`);
847
+ } catch (error) {
848
+ console.warn(
849
+ `Could not delete deployment ${deployment.id} of ${restApiId}:`,
850
+ error
851
+ );
852
+ }
853
+ }
854
+ position = page.position;
855
+ } while (position);
856
+ return deploymentId;
857
+ }
858
+
859
+ // src/lambdas/redeploy-stage/redeploy-stage.lambda.ts
860
+ var handler = async (event) => {
861
+ const restApiId = process.env.REST_API_ID;
862
+ const stageName = process.env.STAGE_NAME;
863
+ if (!restApiId || !stageName) {
864
+ throw new Error("REST_API_ID and STAGE_NAME must be set.");
865
+ }
866
+ await redeployStage({
867
+ restApiId,
868
+ stageName,
869
+ stackStatus: event.detail["status-details"].status
870
+ });
871
+ };
872
+ // Annotate the CommonJS export names for ESM import in node:
873
+ 0 && (module.exports = {
874
+ handler
875
+ });