@aws-blocks/core 0.1.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 (394) hide show
  1. package/LICENSE +174 -0
  2. package/dist/api.d.ts +147 -0
  3. package/dist/api.d.ts.map +1 -0
  4. package/dist/api.js +10 -0
  5. package/dist/api.test.d.ts +2 -0
  6. package/dist/api.test.d.ts.map +1 -0
  7. package/dist/api.test.js +19 -0
  8. package/dist/bb-utils.d.ts +11 -0
  9. package/dist/bb-utils.d.ts.map +1 -0
  10. package/dist/bb-utils.js +12 -0
  11. package/dist/builtin-routes.d.ts +6 -0
  12. package/dist/builtin-routes.d.ts.map +1 -0
  13. package/dist/builtin-routes.js +57 -0
  14. package/dist/cdk/__fixtures__/factory-backend.d.ts +3 -0
  15. package/dist/cdk/__fixtures__/factory-backend.d.ts.map +1 -0
  16. package/dist/cdk/__fixtures__/factory-backend.js +6 -0
  17. package/dist/cdk/__fixtures__/fullid-construct-backend.d.ts +2 -0
  18. package/dist/cdk/__fixtures__/fullid-construct-backend.d.ts.map +1 -0
  19. package/dist/cdk/__fixtures__/fullid-construct-backend.js +37 -0
  20. package/dist/cdk/__fixtures__/handler.d.ts +5 -0
  21. package/dist/cdk/__fixtures__/handler.d.ts.map +1 -0
  22. package/dist/cdk/__fixtures__/handler.js +3 -0
  23. package/dist/cdk/__fixtures__/side-effect-backend.d.ts +2 -0
  24. package/dist/cdk/__fixtures__/side-effect-backend.d.ts.map +1 -0
  25. package/dist/cdk/__fixtures__/side-effect-backend.js +5 -0
  26. package/dist/cdk/blocks-backend.d.ts +68 -0
  27. package/dist/cdk/blocks-backend.d.ts.map +1 -0
  28. package/dist/cdk/blocks-backend.js +214 -0
  29. package/dist/cdk/blocks-backend.test.d.ts +2 -0
  30. package/dist/cdk/blocks-backend.test.d.ts.map +1 -0
  31. package/dist/cdk/blocks-backend.test.js +151 -0
  32. package/dist/cdk/blocks-stack.test.d.ts +2 -0
  33. package/dist/cdk/blocks-stack.test.d.ts.map +1 -0
  34. package/dist/cdk/blocks-stack.test.js +78 -0
  35. package/dist/cdk/config-registry.d.ts +26 -0
  36. package/dist/cdk/config-registry.d.ts.map +1 -0
  37. package/dist/cdk/config-registry.js +80 -0
  38. package/dist/cdk/index.d.ts +35 -0
  39. package/dist/cdk/index.d.ts.map +1 -0
  40. package/dist/cdk/index.js +90 -0
  41. package/dist/cdk/mixins.d.ts +28 -0
  42. package/dist/cdk/mixins.d.ts.map +1 -0
  43. package/dist/cdk/mixins.js +37 -0
  44. package/dist/cdk/mixins.test.d.ts +2 -0
  45. package/dist/cdk/mixins.test.d.ts.map +1 -0
  46. package/dist/cdk/mixins.test.js +108 -0
  47. package/dist/cdk/node-version.d.ts +14 -0
  48. package/dist/cdk/node-version.d.ts.map +1 -0
  49. package/dist/cdk/node-version.js +15 -0
  50. package/dist/cdk/stack-metadata.d.ts +12 -0
  51. package/dist/cdk/stack-metadata.d.ts.map +1 -0
  52. package/dist/cdk/stack-metadata.js +22 -0
  53. package/dist/cdk/stack-metadata.test.d.ts +2 -0
  54. package/dist/cdk/stack-metadata.test.d.ts.map +1 -0
  55. package/dist/cdk/stack-metadata.test.js +56 -0
  56. package/dist/cdk/synth-guard.d.ts +14 -0
  57. package/dist/cdk/synth-guard.d.ts.map +1 -0
  58. package/dist/cdk/synth-guard.js +20 -0
  59. package/dist/cdk/synth-guard.test.d.ts +2 -0
  60. package/dist/cdk/synth-guard.test.d.ts.map +1 -0
  61. package/dist/cdk/synth-guard.test.js +15 -0
  62. package/dist/client/index.d.ts +97 -0
  63. package/dist/client/index.d.ts.map +1 -0
  64. package/dist/client/index.js +238 -0
  65. package/dist/client/index.test.d.ts +2 -0
  66. package/dist/client/index.test.d.ts.map +1 -0
  67. package/dist/client/index.test.js +113 -0
  68. package/dist/common/config.d.ts +45 -0
  69. package/dist/common/config.d.ts.map +1 -0
  70. package/dist/common/config.js +154 -0
  71. package/dist/common/config.test.d.ts +2 -0
  72. package/dist/common/config.test.d.ts.map +1 -0
  73. package/dist/common/config.test.js +173 -0
  74. package/dist/common/constants.d.ts +11 -0
  75. package/dist/common/constants.d.ts.map +1 -0
  76. package/dist/common/constants.js +12 -0
  77. package/dist/common/crypto.d.ts +6 -0
  78. package/dist/common/crypto.d.ts.map +1 -0
  79. package/dist/common/crypto.js +14 -0
  80. package/dist/common/index.d.ts +220 -0
  81. package/dist/common/index.d.ts.map +1 -0
  82. package/dist/common/index.js +180 -0
  83. package/dist/common/index.test.d.ts +2 -0
  84. package/dist/common/index.test.d.ts.map +1 -0
  85. package/dist/common/index.test.js +195 -0
  86. package/dist/common/mock-data.d.ts +40 -0
  87. package/dist/common/mock-data.d.ts.map +1 -0
  88. package/dist/common/mock-data.js +39 -0
  89. package/dist/common/official-bb-names.generated.d.ts +7 -0
  90. package/dist/common/official-bb-names.generated.d.ts.map +1 -0
  91. package/dist/common/official-bb-names.generated.js +28 -0
  92. package/dist/common/sdk-registry.d.ts +136 -0
  93. package/dist/common/sdk-registry.d.ts.map +1 -0
  94. package/dist/common/sdk-registry.js +125 -0
  95. package/dist/constants.d.ts +27 -0
  96. package/dist/constants.d.ts.map +1 -0
  97. package/dist/constants.js +28 -0
  98. package/dist/cors.d.ts +39 -0
  99. package/dist/cors.d.ts.map +1 -0
  100. package/dist/cors.js +85 -0
  101. package/dist/cors.test.d.ts +2 -0
  102. package/dist/cors.test.d.ts.map +1 -0
  103. package/dist/cors.test.js +241 -0
  104. package/dist/db-naming.d.ts +21 -0
  105. package/dist/db-naming.d.ts.map +1 -0
  106. package/dist/db-naming.js +38 -0
  107. package/dist/db-naming.test.d.ts +2 -0
  108. package/dist/db-naming.test.d.ts.map +1 -0
  109. package/dist/db-naming.test.js +29 -0
  110. package/dist/errors.d.ts +67 -0
  111. package/dist/errors.d.ts.map +1 -0
  112. package/dist/errors.js +69 -0
  113. package/dist/hosting.d.ts +258 -0
  114. package/dist/hosting.d.ts.map +1 -0
  115. package/dist/hosting.js +340 -0
  116. package/dist/hosting.test.d.ts +2 -0
  117. package/dist/hosting.test.d.ts.map +1 -0
  118. package/dist/hosting.test.js +1077 -0
  119. package/dist/index.cdk.d.ts +13 -0
  120. package/dist/index.cdk.d.ts.map +1 -0
  121. package/dist/index.cdk.js +13 -0
  122. package/dist/index.d.ts +9 -0
  123. package/dist/index.d.ts.map +1 -0
  124. package/dist/index.js +10 -0
  125. package/dist/lambda-handler.d.ts +131 -0
  126. package/dist/lambda-handler.d.ts.map +1 -0
  127. package/dist/lambda-handler.js +610 -0
  128. package/dist/lambda-handler.test.d.ts +2 -0
  129. package/dist/lambda-handler.test.d.ts.map +1 -0
  130. package/dist/lambda-handler.test.js +835 -0
  131. package/dist/pipeline/index.d.ts +4 -0
  132. package/dist/pipeline/index.d.ts.map +1 -0
  133. package/dist/pipeline/index.js +3 -0
  134. package/dist/pipeline/pipeline-construct.d.ts +130 -0
  135. package/dist/pipeline/pipeline-construct.d.ts.map +1 -0
  136. package/dist/pipeline/pipeline-construct.js +484 -0
  137. package/dist/pipeline/pipeline.test.d.ts +2 -0
  138. package/dist/pipeline/pipeline.test.d.ts.map +1 -0
  139. package/dist/pipeline/pipeline.test.js +1231 -0
  140. package/dist/pipeline/types.d.ts +351 -0
  141. package/dist/pipeline/types.d.ts.map +1 -0
  142. package/dist/pipeline/types.js +3 -0
  143. package/dist/raw-route.cdk.d.ts +47 -0
  144. package/dist/raw-route.cdk.d.ts.map +1 -0
  145. package/dist/raw-route.cdk.js +51 -0
  146. package/dist/raw-route.d.ts +119 -0
  147. package/dist/raw-route.d.ts.map +1 -0
  148. package/dist/raw-route.js +239 -0
  149. package/dist/raw-route.mock.d.ts +47 -0
  150. package/dist/raw-route.mock.d.ts.map +1 -0
  151. package/dist/raw-route.mock.js +51 -0
  152. package/dist/raw-route.test.d.ts +2 -0
  153. package/dist/raw-route.test.d.ts.map +1 -0
  154. package/dist/raw-route.test.js +597 -0
  155. package/dist/redact.d.ts +51 -0
  156. package/dist/redact.d.ts.map +1 -0
  157. package/dist/redact.js +134 -0
  158. package/dist/redact.test.d.ts +2 -0
  159. package/dist/redact.test.d.ts.map +1 -0
  160. package/dist/redact.test.js +199 -0
  161. package/dist/rpc.d.ts +54 -0
  162. package/dist/rpc.d.ts.map +1 -0
  163. package/dist/rpc.js +127 -0
  164. package/dist/rpc.test.d.ts +2 -0
  165. package/dist/rpc.test.d.ts.map +1 -0
  166. package/dist/rpc.test.js +60 -0
  167. package/dist/scripts/cdk-telemetry-env.d.ts +13 -0
  168. package/dist/scripts/cdk-telemetry-env.d.ts.map +1 -0
  169. package/dist/scripts/cdk-telemetry-env.js +21 -0
  170. package/dist/scripts/cdk-telemetry-env.test.d.ts +2 -0
  171. package/dist/scripts/cdk-telemetry-env.test.d.ts.map +1 -0
  172. package/dist/scripts/cdk-telemetry-env.test.js +56 -0
  173. package/dist/scripts/cleanup.d.ts +3 -0
  174. package/dist/scripts/cleanup.d.ts.map +1 -0
  175. package/dist/scripts/cleanup.js +35 -0
  176. package/dist/scripts/console.d.ts +6 -0
  177. package/dist/scripts/console.d.ts.map +1 -0
  178. package/dist/scripts/console.js +25 -0
  179. package/dist/scripts/deploy.d.ts +6 -0
  180. package/dist/scripts/deploy.d.ts.map +1 -0
  181. package/dist/scripts/deploy.js +82 -0
  182. package/dist/scripts/destroy.d.ts +6 -0
  183. package/dist/scripts/destroy.d.ts.map +1 -0
  184. package/dist/scripts/destroy.js +30 -0
  185. package/dist/scripts/dev-server-cors.test.d.ts +2 -0
  186. package/dist/scripts/dev-server-cors.test.d.ts.map +1 -0
  187. package/dist/scripts/dev-server-cors.test.js +23 -0
  188. package/dist/scripts/dev-server-telemetry.test.d.ts +2 -0
  189. package/dist/scripts/dev-server-telemetry.test.d.ts.map +1 -0
  190. package/dist/scripts/dev-server-telemetry.test.js +113 -0
  191. package/dist/scripts/dev-server.d.ts +21 -0
  192. package/dist/scripts/dev-server.d.ts.map +1 -0
  193. package/dist/scripts/dev-server.js +456 -0
  194. package/dist/scripts/ensure-secrets.d.ts +31 -0
  195. package/dist/scripts/ensure-secrets.d.ts.map +1 -0
  196. package/dist/scripts/ensure-secrets.js +100 -0
  197. package/dist/scripts/ensure-secrets.test.d.ts +2 -0
  198. package/dist/scripts/ensure-secrets.test.d.ts.map +1 -0
  199. package/dist/scripts/ensure-secrets.test.js +44 -0
  200. package/dist/scripts/external-migrations-step.d.ts +62 -0
  201. package/dist/scripts/external-migrations-step.d.ts.map +1 -0
  202. package/dist/scripts/external-migrations-step.js +243 -0
  203. package/dist/scripts/external-migrations-step.test.d.ts +2 -0
  204. package/dist/scripts/external-migrations-step.test.d.ts.map +1 -0
  205. package/dist/scripts/external-migrations-step.test.js +47 -0
  206. package/dist/scripts/extract-ts-types.d.ts +65 -0
  207. package/dist/scripts/extract-ts-types.d.ts.map +1 -0
  208. package/dist/scripts/extract-ts-types.js +664 -0
  209. package/dist/scripts/extract-ts-types.test.d.ts +2 -0
  210. package/dist/scripts/extract-ts-types.test.d.ts.map +1 -0
  211. package/dist/scripts/extract-ts-types.test.js +497 -0
  212. package/dist/scripts/generate-client-worker.d.ts +2 -0
  213. package/dist/scripts/generate-client-worker.d.ts.map +1 -0
  214. package/dist/scripts/generate-client-worker.js +13 -0
  215. package/dist/scripts/generate-client.d.ts +14 -0
  216. package/dist/scripts/generate-client.d.ts.map +1 -0
  217. package/dist/scripts/generate-client.js +73 -0
  218. package/dist/scripts/generate-client.test.d.ts +2 -0
  219. package/dist/scripts/generate-client.test.d.ts.map +1 -0
  220. package/dist/scripts/generate-client.test.js +48 -0
  221. package/dist/scripts/generate-spec-cli.d.ts +3 -0
  222. package/dist/scripts/generate-spec-cli.d.ts.map +1 -0
  223. package/dist/scripts/generate-spec-cli.js +77 -0
  224. package/dist/scripts/generate-spec-cli.test.d.ts +14 -0
  225. package/dist/scripts/generate-spec-cli.test.d.ts.map +1 -0
  226. package/dist/scripts/generate-spec-cli.test.js +90 -0
  227. package/dist/scripts/generate-spec.d.ts +61 -0
  228. package/dist/scripts/generate-spec.d.ts.map +1 -0
  229. package/dist/scripts/generate-spec.js +746 -0
  230. package/dist/scripts/generate-spec.test.d.ts +12 -0
  231. package/dist/scripts/generate-spec.test.d.ts.map +1 -0
  232. package/dist/scripts/generate-spec.test.js +88 -0
  233. package/dist/scripts/index.d.ts +12 -0
  234. package/dist/scripts/index.d.ts.map +1 -0
  235. package/dist/scripts/index.js +13 -0
  236. package/dist/scripts/sandbox.d.ts +11 -0
  237. package/dist/scripts/sandbox.d.ts.map +1 -0
  238. package/dist/scripts/sandbox.js +200 -0
  239. package/dist/scripts/telemetry-cli.d.ts +3 -0
  240. package/dist/scripts/telemetry-cli.d.ts.map +1 -0
  241. package/dist/scripts/telemetry-cli.js +8 -0
  242. package/dist/scripts/telemetry.d.ts +17 -0
  243. package/dist/scripts/telemetry.d.ts.map +1 -0
  244. package/dist/scripts/telemetry.js +150 -0
  245. package/dist/scripts/telemetry.test.d.ts +2 -0
  246. package/dist/scripts/telemetry.test.d.ts.map +1 -0
  247. package/dist/scripts/telemetry.test.js +203 -0
  248. package/dist/scripts/validate-spec.d.ts +22 -0
  249. package/dist/scripts/validate-spec.d.ts.map +1 -0
  250. package/dist/scripts/validate-spec.js +159 -0
  251. package/dist/server/index.d.ts +3 -0
  252. package/dist/server/index.d.ts.map +1 -0
  253. package/dist/server/index.js +3 -0
  254. package/dist/server/withAuth.d.ts +142 -0
  255. package/dist/server/withAuth.d.ts.map +1 -0
  256. package/dist/server/withAuth.js +261 -0
  257. package/dist/server/withAuth.test.d.ts +2 -0
  258. package/dist/server/withAuth.test.d.ts.map +1 -0
  259. package/dist/server/withAuth.test.js +278 -0
  260. package/dist/telemetry/client.d.ts +59 -0
  261. package/dist/telemetry/client.d.ts.map +1 -0
  262. package/dist/telemetry/client.js +215 -0
  263. package/dist/telemetry/config-writer.d.ts +16 -0
  264. package/dist/telemetry/config-writer.d.ts.map +1 -0
  265. package/dist/telemetry/config-writer.js +36 -0
  266. package/dist/telemetry/consent-commands.test.d.ts +2 -0
  267. package/dist/telemetry/consent-commands.test.d.ts.map +1 -0
  268. package/dist/telemetry/consent-commands.test.js +161 -0
  269. package/dist/telemetry/consent.d.ts +60 -0
  270. package/dist/telemetry/consent.d.ts.map +1 -0
  271. package/dist/telemetry/consent.js +122 -0
  272. package/dist/telemetry/environment.d.ts +33 -0
  273. package/dist/telemetry/environment.d.ts.map +1 -0
  274. package/dist/telemetry/environment.js +87 -0
  275. package/dist/telemetry/identifiers.d.ts +20 -0
  276. package/dist/telemetry/identifiers.d.ts.map +1 -0
  277. package/dist/telemetry/identifiers.js +86 -0
  278. package/dist/telemetry/index.d.ts +6 -0
  279. package/dist/telemetry/index.d.ts.map +1 -0
  280. package/dist/telemetry/index.js +4 -0
  281. package/dist/telemetry/telemetry.test.d.ts +2 -0
  282. package/dist/telemetry/telemetry.test.d.ts.map +1 -0
  283. package/dist/telemetry/telemetry.test.js +1131 -0
  284. package/dist/telemetry/trackCommand.d.ts +32 -0
  285. package/dist/telemetry/trackCommand.d.ts.map +1 -0
  286. package/dist/telemetry/trackCommand.js +102 -0
  287. package/dist/telemetry/types.d.ts +92 -0
  288. package/dist/telemetry/types.d.ts.map +1 -0
  289. package/dist/telemetry/types.js +1 -0
  290. package/dist/types.d.ts +24 -0
  291. package/dist/types.d.ts.map +1 -0
  292. package/dist/types.js +3 -0
  293. package/dist/version.d.ts +2 -0
  294. package/dist/version.d.ts.map +1 -0
  295. package/dist/version.js +2 -0
  296. package/package.json +83 -0
  297. package/src/api.test.ts +25 -0
  298. package/src/api.ts +163 -0
  299. package/src/bb-utils.ts +13 -0
  300. package/src/builtin-routes.ts +62 -0
  301. package/src/cdk/__fixtures__/factory-backend.ts +8 -0
  302. package/src/cdk/__fixtures__/fullid-construct-backend.ts +42 -0
  303. package/src/cdk/__fixtures__/handler.ts +4 -0
  304. package/src/cdk/__fixtures__/side-effect-backend.ts +7 -0
  305. package/src/cdk/blocks-backend.test.ts +207 -0
  306. package/src/cdk/blocks-backend.ts +249 -0
  307. package/src/cdk/blocks-stack.test.ts +106 -0
  308. package/src/cdk/config-registry.ts +106 -0
  309. package/src/cdk/index.ts +115 -0
  310. package/src/cdk/mixins.test.ts +129 -0
  311. package/src/cdk/mixins.ts +41 -0
  312. package/src/cdk/node-version.ts +17 -0
  313. package/src/cdk/stack-metadata.test.ts +71 -0
  314. package/src/cdk/stack-metadata.ts +29 -0
  315. package/src/cdk/synth-guard.test.ts +21 -0
  316. package/src/cdk/synth-guard.ts +23 -0
  317. package/src/client/index.test.ts +118 -0
  318. package/src/client/index.ts +320 -0
  319. package/src/common/config.test.ts +236 -0
  320. package/src/common/config.ts +169 -0
  321. package/src/common/constants.ts +15 -0
  322. package/src/common/crypto.ts +15 -0
  323. package/src/common/index.test.ts +242 -0
  324. package/src/common/index.ts +335 -0
  325. package/src/common/mock-data.ts +52 -0
  326. package/src/common/official-bb-names.generated.ts +29 -0
  327. package/src/common/sdk-registry.ts +150 -0
  328. package/src/constants.ts +31 -0
  329. package/src/cors.test.ts +279 -0
  330. package/src/cors.ts +91 -0
  331. package/src/db-naming.test.ts +48 -0
  332. package/src/db-naming.ts +41 -0
  333. package/src/errors.ts +72 -0
  334. package/src/hosting.test.ts +1431 -0
  335. package/src/hosting.ts +626 -0
  336. package/src/index.cdk.ts +45 -0
  337. package/src/index.ts +22 -0
  338. package/src/lambda-handler.test.ts +1005 -0
  339. package/src/lambda-handler.ts +706 -0
  340. package/src/pipeline/index.ts +12 -0
  341. package/src/pipeline/pipeline-construct.ts +662 -0
  342. package/src/pipeline/pipeline.test.ts +1565 -0
  343. package/src/pipeline/types.ts +384 -0
  344. package/src/raw-route.cdk.ts +56 -0
  345. package/src/raw-route.mock.ts +56 -0
  346. package/src/raw-route.test.ts +819 -0
  347. package/src/raw-route.ts +316 -0
  348. package/src/redact.test.ts +222 -0
  349. package/src/redact.ts +143 -0
  350. package/src/rpc.test.ts +73 -0
  351. package/src/rpc.ts +174 -0
  352. package/src/scripts/cdk-telemetry-env.test.ts +75 -0
  353. package/src/scripts/cdk-telemetry-env.ts +23 -0
  354. package/src/scripts/cleanup.ts +39 -0
  355. package/src/scripts/console.ts +34 -0
  356. package/src/scripts/deploy.ts +106 -0
  357. package/src/scripts/destroy.ts +42 -0
  358. package/src/scripts/dev-server-cors.test.ts +28 -0
  359. package/src/scripts/dev-server-telemetry.test.ts +127 -0
  360. package/src/scripts/dev-server.ts +515 -0
  361. package/src/scripts/ensure-secrets.test.ts +50 -0
  362. package/src/scripts/ensure-secrets.ts +113 -0
  363. package/src/scripts/external-migrations-step.test.ts +64 -0
  364. package/src/scripts/external-migrations-step.ts +269 -0
  365. package/src/scripts/extract-ts-types.test.ts +516 -0
  366. package/src/scripts/extract-ts-types.ts +773 -0
  367. package/src/scripts/generate-client-worker.ts +15 -0
  368. package/src/scripts/generate-client.test.ts +69 -0
  369. package/src/scripts/generate-client.ts +86 -0
  370. package/src/scripts/generate-spec-cli.test.ts +106 -0
  371. package/src/scripts/generate-spec-cli.ts +92 -0
  372. package/src/scripts/generate-spec.test.ts +99 -0
  373. package/src/scripts/generate-spec.ts +833 -0
  374. package/src/scripts/index.ts +21 -0
  375. package/src/scripts/sandbox.ts +230 -0
  376. package/src/scripts/telemetry-cli.ts +10 -0
  377. package/src/scripts/telemetry.test.ts +239 -0
  378. package/src/scripts/telemetry.ts +173 -0
  379. package/src/scripts/validate-spec.ts +199 -0
  380. package/src/server/index.ts +5 -0
  381. package/src/server/withAuth.test.ts +348 -0
  382. package/src/server/withAuth.ts +323 -0
  383. package/src/telemetry/client.ts +226 -0
  384. package/src/telemetry/config-writer.ts +52 -0
  385. package/src/telemetry/consent-commands.test.ts +196 -0
  386. package/src/telemetry/consent.ts +154 -0
  387. package/src/telemetry/environment.ts +100 -0
  388. package/src/telemetry/identifiers.ts +94 -0
  389. package/src/telemetry/index.ts +11 -0
  390. package/src/telemetry/telemetry.test.ts +1343 -0
  391. package/src/telemetry/trackCommand.ts +110 -0
  392. package/src/telemetry/types.ts +92 -0
  393. package/src/types.ts +33 -0
  394. package/src/version.ts +2 -0
@@ -0,0 +1,351 @@
1
+ import type * as cdk from 'aws-cdk-lib';
2
+ import type * as codebuild from 'aws-cdk-lib/aws-codebuild';
3
+ /**
4
+ * Configuration for the pipeline source (GitHub/CodeConnections).
5
+ *
6
+ * Uses AWS CodeConnections (formerly CodeStar Connections) for OAuth-based
7
+ * access to GitHub repositories. No token management required — the
8
+ * connection is created once via the AWS Console.
9
+ */
10
+ export interface PipelineSourceConfig {
11
+ /**
12
+ * Repository in `owner/repo` format.
13
+ *
14
+ * @example 'my-org/my-app'
15
+ */
16
+ readonly repo: string;
17
+ /**
18
+ * ARN of the AWS CodeConnections connection.
19
+ *
20
+ * **Important:** This connection requires a one-time OAuth handshake via the
21
+ * AWS Console before it can be used. After creating the connection resource
22
+ * (via CDK, CLI, or Console), you must complete the OAuth flow in the
23
+ * Console under **Developer Tools → Connections** — the connection will be
24
+ * in `PENDING` status until authorized.
25
+ *
26
+ * Steps:
27
+ * 1. Create the connection (Console or CLI)
28
+ * 2. Navigate to **Developer Tools → Connections** in the AWS Console
29
+ * 3. Select the pending connection and click "Update pending connection"
30
+ * 4. Authorize the GitHub app and select your repository/organization
31
+ * 5. The status changes to `AVAILABLE` — the pipeline can now pull source
32
+ *
33
+ * @see https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-github.html
34
+ *
35
+ * @example 'arn:aws:codeconnections:us-east-1:123456789:connection/abc-def'
36
+ */
37
+ readonly connectionArn: string;
38
+ /**
39
+ * Whether to trigger the pipeline on push to the branch.
40
+ *
41
+ * @default true
42
+ */
43
+ readonly triggerOnPush?: boolean;
44
+ /**
45
+ * Path-based trigger filters for monorepo support.
46
+ *
47
+ * When specified, the pipeline only triggers on pushes that modify files
48
+ * matching these path patterns. Useful for monorepos where multiple
49
+ * pipelines share a single repository.
50
+ *
51
+ * @example ['packages/backend/**', 'shared/**']
52
+ */
53
+ readonly triggerFilters?: string[];
54
+ }
55
+ /**
56
+ * Configuration for the synth step (build + CDK synth).
57
+ *
58
+ * The synth step installs dependencies and runs `cdk synth` to produce
59
+ * the CloudFormation template. The pipeline is self-mutating: if the
60
+ * synth output changes the pipeline definition, it updates itself first.
61
+ */
62
+ export interface PipelineSynthConfig {
63
+ /**
64
+ * Shell commands to run during the synth step.
65
+ *
66
+ * @default ['npm ci', 'npx cdk synth'] — installs dependencies and synthesizes the CDK app.
67
+ * Override if you need Node version upgrades, custom build steps, or a non-standard cdk.json app path.
68
+ * If your app requires Node 22+, prepend `'n 22'` to commands or use {@link installCommands}.
69
+ */
70
+ readonly commands?: string[];
71
+ /**
72
+ * Commands to run in the CodeBuild install phase (before synth commands).
73
+ *
74
+ * @default [] — no install commands. The default build image (Amazon Linux 2023 standard:5.0)
75
+ * includes Node 22. Set this if you need additional global tools or a different Node version.
76
+ *
77
+ * @example ['n 20'] — downgrade Node to version 20
78
+ */
79
+ readonly installCommands?: string[];
80
+ /**
81
+ * The CodeBuild build image to use for the synth step.
82
+ *
83
+ * The default image (Amazon Linux 2023 standard:5.0) includes Node 22 and
84
+ * Amazon Linux 2023. Override this if you need a different OS or runtime set.
85
+ *
86
+ * @default codebuild.LinuxBuildImage.AMAZON_LINUX_2023_5
87
+ */
88
+ readonly buildImage?: codebuild.IBuildImage;
89
+ /**
90
+ * Environment variables available during synth.
91
+ *
92
+ * Note: `NODE_OPTIONS` is automatically prepended with `--conditions=cdk`
93
+ * (required for ESM conditional exports). Your custom NODE_OPTIONS will be
94
+ * appended after this flag.
95
+ */
96
+ readonly env?: Record<string, string>;
97
+ /**
98
+ * Primary output directory for the CDK cloud assembly.
99
+ *
100
+ * Override this for monorepos where `cdk synth` outputs to a
101
+ * subdirectory (e.g., `packages/infra/cdk.out`).
102
+ *
103
+ * @default 'cdk.out'
104
+ */
105
+ readonly primaryOutputDirectory?: string;
106
+ /**
107
+ * Whether to enable Docker for the synth step.
108
+ *
109
+ * Required when your CDK app uses Docker image assets (e.g., Lambda
110
+ * container images, ECS task definitions with Dockerfile builds).
111
+ *
112
+ * @default false
113
+ */
114
+ readonly dockerEnabled?: boolean;
115
+ /**
116
+ * CodeBuild compute type for the synth step.
117
+ *
118
+ * Controls the CPU/memory allocation for the build environment.
119
+ * Increase this if you encounter OOM (exit code 137) during synth/bundling.
120
+ *
121
+ * - `SMALL`: 2 vCPU, 3 GB
122
+ * - `MEDIUM`: 4 vCPU, 7 GB
123
+ * - `LARGE`: 8 vCPU, 15 GB
124
+ *
125
+ * @default ComputeType.MEDIUM (7GB RAM, 4 vCPU) — sufficient for most apps with
126
+ * Lambda bundling + frontend builds. Use SMALL for trivial apps or LARGE for monorepos.
127
+ */
128
+ readonly computeType?: codebuild.ComputeType;
129
+ }
130
+ /**
131
+ * Configuration for a deployment stage.
132
+ *
133
+ * Each stage represents a deployment environment (e.g., beta, prod).
134
+ * Stages are deployed in the order they appear in the `stages` array.
135
+ */
136
+ export interface PipelineStageConfig<TConfig = Record<string, unknown>> {
137
+ /**
138
+ * Logical name for this stage (e.g., 'beta', 'prod').
139
+ * Used as the CDK Stage construct id.
140
+ */
141
+ readonly name: string;
142
+ /**
143
+ * Target AWS account and region for this stage.
144
+ * When omitted, deploys to the pipeline's own account/region.
145
+ */
146
+ readonly env?: cdk.Environment;
147
+ /**
148
+ * Whether to require manual approval before deploying to this stage.
149
+ *
150
+ * @default false
151
+ */
152
+ readonly requireApproval?: boolean;
153
+ /**
154
+ * Optional comment shown in the approval notification.
155
+ * Only relevant when `requireApproval` is true.
156
+ */
157
+ readonly approvalComment?: string;
158
+ /**
159
+ * Optional baking time after deployment before proceeding.
160
+ * Useful for canary validation — gives time for alarms to fire.
161
+ *
162
+ * Implemented as a CodeBuild `sleep` step (~$0.005/min on
163
+ * `BUILD_GENERAL1_SMALL`). An explicit timeout of bakeTime + 10 minutes
164
+ * is set on the CodeBuild step to prevent pipeline hangs.
165
+ *
166
+ * For longer baking periods, use `requireApproval: true` with
167
+ * external monitoring/alerting instead.
168
+ */
169
+ readonly bakeTime?: cdk.Duration;
170
+ /**
171
+ * User-defined configuration passed through to the `stageFactory`.
172
+ *
173
+ * Use this for per-stage settings like domain names, feature flags,
174
+ * scaling parameters, etc.
175
+ *
176
+ * @example { domain: 'myapp.com', enableCanary: true }
177
+ */
178
+ readonly config?: TConfig;
179
+ /**
180
+ * Environment variables to set on `process.env` when importing the app file for this stage.
181
+ *
182
+ * These are synthesis-time variables (available during `cdk synth`), not deployment-time.
183
+ * Use this for per-stage configuration that your CDK app reads from `process.env`
184
+ * (e.g., domain names, feature flags). Only applies when using the `appFile` prop.
185
+ *
186
+ * @example { DOMAIN: 'myapp.com', ENABLE_CANARY: 'true' }
187
+ */
188
+ readonly environment?: Record<string, string>;
189
+ }
190
+ /**
191
+ * Configuration for a single branch pipeline.
192
+ *
193
+ * Each branch entry creates its own independent CodePipeline that triggers
194
+ * on pushes to the specified branch and deploys through its own ordered stages.
195
+ */
196
+ export interface BranchConfig<TConfig = Record<string, unknown>> {
197
+ /**
198
+ * Git branch that triggers this pipeline.
199
+ *
200
+ * @example 'main'
201
+ */
202
+ readonly branch: string;
203
+ /**
204
+ * Ordered list of deployment stages for this branch's pipeline.
205
+ */
206
+ readonly stages: Array<PipelineStageConfig<TConfig>>;
207
+ /**
208
+ * Whether to trigger this branch's pipeline on push.
209
+ *
210
+ * Overrides the top-level `source.triggerOnPush` for this specific branch.
211
+ * Useful when you want most branches to auto-trigger but disable it for
212
+ * specific branches (e.g., a release branch that deploys on manual trigger only).
213
+ *
214
+ * @default inherits from source.triggerOnPush (which defaults to true)
215
+ */
216
+ readonly triggerOnPush?: boolean;
217
+ }
218
+ /**
219
+ * Props for the {@link Pipeline} L3 construct.
220
+ *
221
+ * @example Multi-branch configuration
222
+ * ```ts
223
+ * new Pipeline(stack, 'Pipeline', {
224
+ * source: {
225
+ * repo: 'my-org/my-app',
226
+ * connectionArn: 'arn:aws:codeconnections:us-east-1:123456789:connection/abc',
227
+ * },
228
+ * branches: [
229
+ * {
230
+ * branch: 'main',
231
+ * stages: [
232
+ * { name: 'beta' },
233
+ * { name: 'prod', requireApproval: true, config: { domain: 'myapp.com' } },
234
+ * ],
235
+ * },
236
+ * {
237
+ * branch: 'develop',
238
+ * stages: [
239
+ * { name: 'alpha', config: { domain: 'alpha.myapp.com' } },
240
+ * ],
241
+ * },
242
+ * ],
243
+ * stageFactory: (scope, stageConfig) => {
244
+ * new MyAppStack(scope, 'App', {
245
+ * stackName: `my-app-${stageConfig.name}`,
246
+ * env: stageConfig.env,
247
+ * });
248
+ * },
249
+ * });
250
+ * ```
251
+ *
252
+ * @example With custom synth and bake time
253
+ * ```ts
254
+ * new Pipeline(stack, 'Pipeline', {
255
+ * source: {
256
+ * repo: 'my-org/my-app',
257
+ * connectionArn: 'arn:aws:codeconnections:...',
258
+ * },
259
+ * branches: [
260
+ * {
261
+ * branch: 'release',
262
+ * stages: [
263
+ * { name: 'beta' },
264
+ * { name: 'prod', requireApproval: true, bakeTime: Duration.minutes(30) },
265
+ * ],
266
+ * },
267
+ * ],
268
+ * synth: {
269
+ * commands: ['npm ci', 'npm run build', 'npx cdk synth'],
270
+ * },
271
+ * stageFactory: (scope, stageConfig) => {
272
+ * new MyAppStack(scope, 'App', { env: stageConfig.env });
273
+ * },
274
+ * });
275
+ * ```
276
+ */
277
+ export interface PipelineProps<TConfig = Record<string, unknown>> {
278
+ /** Source repository configuration. */
279
+ readonly source: PipelineSourceConfig;
280
+ /** Synth step configuration. */
281
+ readonly synth?: PipelineSynthConfig;
282
+ /**
283
+ * Branch configurations. Each entry creates a separate CodePipeline.
284
+ *
285
+ * A single source repository can have multiple branch pipelines, each
286
+ * with its own set of deployment stages and configuration.
287
+ */
288
+ readonly branches: Array<BranchConfig<TConfig>>;
289
+ /**
290
+ * Factory function that populates a CDK Stage with stacks.
291
+ *
292
+ * Called once per stage across all branches. The factory receives the Stage
293
+ * scope and the full stage configuration object (including `name`, `env`,
294
+ * and any user-defined `config`).
295
+ *
296
+ * May be async when using constructs that require async initialization
297
+ * (e.g., `BlocksStack.create()`). When async, use `Pipeline.create()` instead
298
+ * of `new Pipeline()` to ensure all stages are fully resolved before synth.
299
+ *
300
+ * Mutually exclusive with `appFile`. One of `stageFactory` or `appFile` must be provided
301
+ * for the sync constructor (`new Pipeline()`). When using `Pipeline.create()`, if neither
302
+ * is provided, `appFile` defaults to `'./index.cdk.ts'`.
303
+ *
304
+ * @param scope - The CDK Stage construct to add stacks to.
305
+ * @param stageConfig - The full stage configuration including name, env, and user-defined config.
306
+ */
307
+ readonly stageFactory?: (scope: cdk.Stage, stageConfig: PipelineStageConfig<TConfig>) => void | Promise<void>;
308
+ /**
309
+ * Path to the CDK app file to import for each stage.
310
+ *
311
+ * When provided, the pipeline will dynamically import this file once per stage,
312
+ * with the ambient `__PIPELINE_STAGE_SCOPE__` set on globalThis so that
313
+ * `BlocksStack.create()` automatically attaches to the correct stage scope.
314
+ *
315
+ * The path is resolved **relative to the calling file** (not CWD), using
316
+ * `Error.stack` to determine the caller's directory. Absolute paths are
317
+ * used as-is.
318
+ *
319
+ * Each stage's `environment` vars are set on `process.env` before the import
320
+ * and cleaned up afterward.
321
+ *
322
+ * Mutually exclusive with `stageFactory`. When using `Pipeline.create()` and
323
+ * neither `appFile` nor `stageFactory` is provided, defaults to `'./index.cdk.ts'`
324
+ * (resolved relative to the calling file).
325
+ *
326
+ * **Security:** This path is dynamically imported during CDK synth, executing
327
+ * the module's code in the synth process. It MUST originate from a trusted source
328
+ * (developer's pipeline definition file). Never wire this from external input
329
+ * (environment variables, build args, plugin configs, or user-supplied values).
330
+ * A path-containment check enforces that the resolved file stays within the
331
+ * project root, and only `.ts`, `.js`, `.mjs`, `.cjs` extensions are accepted.
332
+ *
333
+ * @default './index.cdk.ts' (when using Pipeline.create() without stageFactory)
334
+ * @example './infra/app.ts'
335
+ */
336
+ readonly appFile?: string;
337
+ /**
338
+ * Whether the pipeline should self-mutate (update its own definition).
339
+ *
340
+ * @default true
341
+ */
342
+ readonly selfMutation?: boolean;
343
+ /**
344
+ * Cross-account keys for artifact encryption.
345
+ * Enable when deploying to accounts different from the pipeline account.
346
+ *
347
+ * @default false
348
+ */
349
+ readonly crossAccountKeys?: boolean;
350
+ }
351
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pipeline/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1,47 @@
1
+ import { Scope } from './cdk/index.js';
2
+ import type { ScopeParent } from './common/index.js';
3
+ import { type RawRouteOptions } from './raw-route.js';
4
+ export { RawRouteErrors, type RawRouteOptions, type HttpMethod } from './raw-route.js';
5
+ /**
6
+ * Raw HTTP route Building Block (CDK).
7
+ *
8
+ * Provides raw HTTP endpoints with full request/response control, beyond the
9
+ * default RPC-only `POST /api` pattern. Routes are dispatched by the Lambda
10
+ * handler and dev server based on HTTP method + path pattern matching.
11
+ *
12
+ * ## Path
13
+ *
14
+ * When `path` is provided, it is used exactly as given. When omitted, the
15
+ * path is derived from the scope-chain IDs (excluding the root BlocksStack):
16
+ *
17
+ * ```typescript
18
+ * // Explicit path — used as-is
19
+ * new RawRoute(scope, 'health', { method: 'GET', path: '/health', handler });
20
+ *
21
+ * // Derived path — scope chain determines the URL
22
+ * new RawRoute(scope, 'health', { method: 'GET', handler });
23
+ * // If scope is the top-level Scope('my-app'), path becomes /health
24
+ * ```
25
+ *
26
+ * **Caution:** Changing the construct tree structure changes derived URLs.
27
+ * Use explicit paths for routes that must remain stable.
28
+ *
29
+ * ## Path syntax (when explicit)
30
+ *
31
+ * - `/health` — exact match
32
+ * - `/users/{id}` — named path parameter (captures one segment)
33
+ * - `/v1/*` — wildcard (captures everything after prefix)
34
+ *
35
+ * ## How it works
36
+ *
37
+ * - At construction time, the route is registered in a global registry.
38
+ * - The Lambda handler and dev server check the registry before falling through to RPC dispatch.
39
+ * - The CDK side only validates the route (duplicate detection). No additional AWS resources
40
+ * are created — the existing catch-all API Gateway proxy routes all paths to the Lambda.
41
+ */
42
+ export declare class RawRoute extends Scope {
43
+ /** The resolved path this route is registered at. */
44
+ readonly path: string;
45
+ constructor(scope: ScopeParent, id: string, options: RawRouteOptions);
46
+ }
47
+ //# sourceMappingURL=raw-route.cdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-route.cdk.d.ts","sourceRoot":"","sources":["../src/raw-route.cdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAmC,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,qDAAqD;IACrD,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe;CAKrE"}
@@ -0,0 +1,51 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Scope } from './cdk/index.js';
4
+ import { registerRoute, resolveRoutePath } from './raw-route.js';
5
+ export { RawRouteErrors } from './raw-route.js';
6
+ /**
7
+ * Raw HTTP route Building Block (CDK).
8
+ *
9
+ * Provides raw HTTP endpoints with full request/response control, beyond the
10
+ * default RPC-only `POST /api` pattern. Routes are dispatched by the Lambda
11
+ * handler and dev server based on HTTP method + path pattern matching.
12
+ *
13
+ * ## Path
14
+ *
15
+ * When `path` is provided, it is used exactly as given. When omitted, the
16
+ * path is derived from the scope-chain IDs (excluding the root BlocksStack):
17
+ *
18
+ * ```typescript
19
+ * // Explicit path — used as-is
20
+ * new RawRoute(scope, 'health', { method: 'GET', path: '/health', handler });
21
+ *
22
+ * // Derived path — scope chain determines the URL
23
+ * new RawRoute(scope, 'health', { method: 'GET', handler });
24
+ * // If scope is the top-level Scope('my-app'), path becomes /health
25
+ * ```
26
+ *
27
+ * **Caution:** Changing the construct tree structure changes derived URLs.
28
+ * Use explicit paths for routes that must remain stable.
29
+ *
30
+ * ## Path syntax (when explicit)
31
+ *
32
+ * - `/health` — exact match
33
+ * - `/users/{id}` — named path parameter (captures one segment)
34
+ * - `/v1/*` — wildcard (captures everything after prefix)
35
+ *
36
+ * ## How it works
37
+ *
38
+ * - At construction time, the route is registered in a global registry.
39
+ * - The Lambda handler and dev server check the registry before falling through to RPC dispatch.
40
+ * - The CDK side only validates the route (duplicate detection). No additional AWS resources
41
+ * are created — the existing catch-all API Gateway proxy routes all paths to the Lambda.
42
+ */
43
+ export class RawRoute extends Scope {
44
+ /** The resolved path this route is registered at. */
45
+ path;
46
+ constructor(scope, id, options) {
47
+ super(id, { parent: scope });
48
+ this.path = resolveRoutePath(scope, id, options);
49
+ registerRoute({ ...options, path: this.path });
50
+ }
51
+ }
@@ -0,0 +1,119 @@
1
+ import type { BlocksContext } from './api.js';
2
+ import type { ScopeParent } from './common/index.js';
3
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
4
+ export interface RawRouteOptions {
5
+ method: HttpMethod;
6
+ /**
7
+ * URL path pattern. When provided, used exactly as given.
8
+ * When omitted, derived from the scope-chain IDs.
9
+ *
10
+ * - `/health` — exact match
11
+ * - `/users/{id}` — named path parameter (captures one segment)
12
+ * - `/v1/*` — wildcard (captures everything after prefix)
13
+ *
14
+ * **Scope-chain derivation:** If omitted, the path is built by collecting
15
+ * each ancestor scope's `id` (excluding the root BlocksStack) and joining
16
+ * with `/`. For example, `BlocksStack('app') → Scope('v1') → RawRoute('health')`
17
+ * yields `/v1/health`.
18
+ */
19
+ path?: string;
20
+ handler: (context: BlocksContext) => Promise<void>;
21
+ }
22
+ /**
23
+ * Typed error constants for RawRoute. Use with `isBlocksError()` in catch blocks.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * try {
28
+ * new RawRoute(scope, 'dup', { method: 'GET', path: '/health', handler });
29
+ * } catch (e: unknown) {
30
+ * if (isBlocksError(e, RawRouteErrors.DuplicateRoute)) {
31
+ * // same method+path already registered
32
+ * }
33
+ * }
34
+ * ```
35
+ */
36
+ export declare const RawRouteErrors: {
37
+ readonly DuplicateRoute: "DuplicateRouteException";
38
+ };
39
+ /**
40
+ * Derive a URL path from the scope chain.
41
+ *
42
+ * Walks the parent chain from `scope` up to (but NOT including) the root
43
+ * BlocksStack or the top-level user Scope, collects each intermediate scope's
44
+ * `id`, URL-encodes segments, and joins with `/`. The RawRoute's own `id`
45
+ * is appended as the final segment.
46
+ *
47
+ * A scope is "root-level" if its parent has no `parent` property (i.e., it's
48
+ * the BlocksStack or the fallback `{ id: ... }` sentinel). Root-level scopes
49
+ * are excluded from the path — they represent the application boundary, not
50
+ * a URL segment.
51
+ *
52
+ * @example
53
+ * ```
54
+ * Scope('app') → RawRoute('health') → /health
55
+ * Scope('app') → Scope('v1') → RawRoute('users') → /v1/users
56
+ * Scope('app') → Scope('api') → Scope('v2') → RawRoute('items') → /api/v2/items
57
+ * ```
58
+ */
59
+ export declare function derivePathFromScope(scope: ScopeParent, id: string): string;
60
+ /**
61
+ * Resolve the effective path for a RawRoute — uses the explicit `path` if
62
+ * provided, otherwise derives it from the scope chain.
63
+ */
64
+ export declare function resolveRoutePath(scope: ScopeParent, id: string, options: RawRouteOptions): string;
65
+ export interface RegisteredRoute {
66
+ method: string;
67
+ /** Normalized path (trailing slashes removed, double slashes collapsed). */
68
+ path: string;
69
+ /** Compiled regex for matching incoming request paths. */
70
+ pattern: RegExp;
71
+ /** Extracted parameter names in capture-group order. */
72
+ paramNames: string[];
73
+ handler: (context: BlocksContext) => Promise<void>;
74
+ }
75
+ /** Prevent further route registration. Call after initialization is complete. */
76
+ export declare function lockRouteRegistry(): void;
77
+ /** Re-allow route registration (useful in tests after lock). */
78
+ export declare function unlockRouteRegistry(): void;
79
+ /**
80
+ * Register a raw HTTP route for runtime dispatch.
81
+ *
82
+ * **Internal.** The public API is `new RawRoute(scope, id, options)`.
83
+ * Path must be resolved before calling this function.
84
+ *
85
+ * @throws If registration is locked (after handler creation).
86
+ * @throws If the HTTP method is invalid.
87
+ * @throws If the path is under the reserved namespace (`/aws-blocks` or `/aws-blocks/api/*`).
88
+ * @throws {RawRouteErrors.DuplicateRoute} If the same method+path is registered twice.
89
+ */
90
+ export declare function registerRoute(options: RawRouteOptions & {
91
+ path: string;
92
+ }): void;
93
+ /** Return a read-only snapshot of all registered routes. */
94
+ export declare function getRegisteredRoutes(): readonly RegisteredRoute[];
95
+ /** Remove all registered routes and unlock registration (used by tests). */
96
+ export declare function clearRouteRegistry(): void;
97
+ /**
98
+ * Match an incoming HTTP request against registered routes.
99
+ *
100
+ * @returns The matched route and extracted path parameters, or `null` if no match.
101
+ */
102
+ export declare function matchRoute(method: string, path: string): {
103
+ route: RegisteredRoute;
104
+ params: Record<string, string>;
105
+ } | null;
106
+ /**
107
+ * Compile a path pattern into a RegExp and extract parameter names.
108
+ *
109
+ * Supported syntax:
110
+ * - `/health` → exact match
111
+ * - `/users/{id}` → captures one path segment as `id`
112
+ * - `/v1/*` → captures everything after `/v1/` as `*`
113
+ * - `/a/{x}/b/{y}` → multiple named parameters
114
+ */
115
+ export declare function compilePath(path: string): {
116
+ pattern: RegExp;
117
+ paramNames: string[];
118
+ };
119
+ //# sourceMappingURL=raw-route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-route.d.ts","sourceRoot":"","sources":["../src/raw-route.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1F,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc;;CAEjB,CAAC;AAIX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAc1E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAEjG;AAID,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAOD,iFAAiF;AACjF,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,gEAAgE;AAChE,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAuC/E;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,IAAI,SAAS,eAAe,EAAE,CAEhE;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,IAAI,IAAI,CAGzC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CAoBnE;AA6BD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAgEnF"}