sst 1.16.0 → 2.0.0-rc.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 (518) hide show
  1. package/LICENSE +21 -0
  2. package/{dist/app.d.ts → app.d.ts} +8 -1
  3. package/app.js +122 -0
  4. package/{dist/bootstrap.d.ts → bootstrap.d.ts} +1 -0
  5. package/bootstrap.js +79 -0
  6. package/{dist/bus.d.ts → bus.d.ts} +0 -0
  7. package/{dist/bus.js → bus.js} +0 -0
  8. package/{dist/cache.d.ts → cache.d.ts} +0 -0
  9. package/{dist/cache.js → cache.js} +0 -0
  10. package/{dist/cdk → cdk}/cloudformation-deployments.d.ts +1 -1
  11. package/{dist/cdk → cdk}/cloudformation-deployments.js +1 -0
  12. package/{dist/cdk → cdk}/deploy-stack.d.ts +0 -0
  13. package/{dist/cdk → cdk}/deploy-stack.js +13 -6
  14. package/{dist/cli → cli}/commands/bind.d.ts +3 -1
  15. package/{dist/cli → cli}/commands/bind.js +8 -4
  16. package/{dist/cli → cli}/commands/build.d.ts +2 -0
  17. package/cli/commands/build.js +12 -0
  18. package/cli/commands/console.d.ts +9 -0
  19. package/cli/commands/console.js +15 -0
  20. package/{dist/cli → cli}/commands/deploy.d.ts +7 -1
  21. package/cli/commands/deploy.js +48 -0
  22. package/cli/commands/dev.d.ts +11 -0
  23. package/cli/commands/dev.js +188 -0
  24. package/cli/commands/env.d.ts +11 -0
  25. package/cli/commands/env.js +39 -0
  26. package/cli/commands/plugins/kysely.d.ts +1 -0
  27. package/cli/commands/plugins/kysely.js +91 -0
  28. package/cli/commands/plugins/pothos.d.ts +1 -0
  29. package/cli/commands/plugins/pothos.js +52 -0
  30. package/cli/commands/plugins/warmer.d.ts +1 -0
  31. package/cli/commands/plugins/warmer.js +33 -0
  32. package/cli/commands/remove.d.ts +13 -0
  33. package/cli/commands/remove.js +39 -0
  34. package/{dist/cli → cli}/commands/secrets/get.d.ts +2 -0
  35. package/{dist/cli → cli}/commands/secrets/get.js +0 -0
  36. package/{dist/cli → cli}/commands/secrets/list.d.ts +2 -0
  37. package/{dist/cli → cli}/commands/secrets/list.js +5 -5
  38. package/{dist/cli → cli}/commands/secrets/remove.d.ts +2 -0
  39. package/{dist/cli → cli}/commands/secrets/remove.js +0 -0
  40. package/{dist/cli → cli}/commands/secrets/secrets.d.ts +0 -0
  41. package/{dist/cli → cli}/commands/secrets/secrets.js +0 -0
  42. package/{dist/cli → cli}/commands/secrets/set.d.ts +2 -0
  43. package/{dist/cli → cli}/commands/secrets/set.js +13 -11
  44. package/{dist/cli → cli}/commands/update.d.ts +2 -0
  45. package/{dist/cli → cli}/commands/update.js +17 -21
  46. package/cli/local/router.d.ts +42 -0
  47. package/cli/local/router.js +43 -0
  48. package/cli/local/server.d.ts +20 -0
  49. package/cli/local/server.js +212 -0
  50. package/cli/program.d.ts +9 -0
  51. package/{dist/cli → cli}/program.js +6 -1
  52. package/{dist/cli → cli}/spinner.d.ts +0 -0
  53. package/{dist/cli → cli}/spinner.js +0 -0
  54. package/cli/sst.d.ts +2 -0
  55. package/{dist/cli → cli}/sst.js +27 -16
  56. package/cli/telemetry/environment.d.ts +15 -0
  57. package/cli/telemetry/environment.js +27 -0
  58. package/cli/telemetry/post-payload.d.ts +1 -0
  59. package/cli/telemetry/post-payload.js +18 -0
  60. package/cli/telemetry/project-id.d.ts +2 -0
  61. package/cli/telemetry/project-id.js +47 -0
  62. package/cli/telemetry/telemetry.d.ts +4 -0
  63. package/cli/telemetry/telemetry.js +90 -0
  64. package/cli/ui/deploy.d.ts +8 -0
  65. package/{dist/cli → cli}/ui/deploy.js +39 -1
  66. package/{dist/config.d.ts → config.d.ts} +0 -0
  67. package/{dist/config.js → config.js} +16 -4
  68. package/{dist/constructs → constructs}/Api.d.ts +98 -12
  69. package/{dist/constructs → constructs}/Api.js +93 -7
  70. package/{dist/constructs → constructs}/ApiGatewayV1Api.d.ts +0 -0
  71. package/{dist/constructs → constructs}/ApiGatewayV1Api.js +10 -5
  72. package/{dist/constructs → constructs}/App.d.ts +4 -26
  73. package/{dist/constructs → constructs}/App.js +119 -99
  74. package/{dist/constructs → constructs}/AppSyncApi.d.ts +3 -3
  75. package/{dist/constructs → constructs}/AppSyncApi.js +27 -20
  76. package/constructs/AstroSite.d.ts +25 -0
  77. package/constructs/AstroSite.js +111 -0
  78. package/constructs/AstroSite.tsdoc.d.ts +2 -0
  79. package/constructs/AstroSite.tsdoc.js +2 -0
  80. package/{dist/constructs → constructs}/Auth.d.ts +1 -1
  81. package/{dist/constructs → constructs}/Auth.js +6 -4
  82. package/{dist/constructs → constructs}/BaseSite.d.ts +0 -0
  83. package/{dist/constructs → constructs}/BaseSite.js +0 -0
  84. package/{dist/constructs → constructs}/Bucket.d.ts +0 -0
  85. package/{dist/constructs → constructs}/Bucket.js +6 -3
  86. package/{dist/constructs → constructs}/Cognito.d.ts +0 -0
  87. package/{dist/constructs → constructs}/Cognito.js +4 -1
  88. package/{dist/constructs → constructs}/Config.d.ts +0 -0
  89. package/{dist/constructs → constructs}/Config.js +0 -0
  90. package/{dist/constructs → constructs}/Construct.d.ts +0 -0
  91. package/{dist/constructs → constructs}/Construct.js +0 -0
  92. package/{dist/constructs → constructs}/Cron.d.ts +0 -0
  93. package/{dist/constructs → constructs}/Cron.js +7 -0
  94. package/{dist/constructs → constructs}/DebugApp.d.ts +2 -2
  95. package/{dist/constructs → constructs}/DebugApp.js +16 -0
  96. package/{dist/constructs → constructs}/DebugStack.d.ts +0 -0
  97. package/{dist/constructs → constructs}/DebugStack.js +4 -0
  98. package/{dist/constructs → constructs}/EdgeFunction.d.ts +1 -0
  99. package/{dist/constructs → constructs}/EdgeFunction.js +27 -22
  100. package/{dist/constructs → constructs}/EventBus.d.ts +0 -0
  101. package/{dist/constructs → constructs}/EventBus.js +7 -4
  102. package/{dist/constructs → constructs}/Function.d.ts +73 -174
  103. package/{dist/constructs → constructs}/Function.js +43 -83
  104. package/{dist/constructs → constructs}/FunctionalStack.d.ts +0 -0
  105. package/{dist/constructs → constructs}/FunctionalStack.js +5 -5
  106. package/{dist/constructs → constructs}/GraphQLApi.d.ts +11 -1
  107. package/{dist/constructs → constructs}/GraphQLApi.js +3 -0
  108. package/{dist/constructs → constructs}/Job.d.ts +0 -14
  109. package/{dist/constructs → constructs}/Job.js +50 -46
  110. package/{dist/constructs → constructs}/KinesisStream.d.ts +0 -0
  111. package/{dist/constructs → constructs}/KinesisStream.js +6 -3
  112. package/{dist/constructs → constructs}/Metadata.d.ts +1 -1
  113. package/{dist/constructs → constructs}/Metadata.js +0 -0
  114. package/constructs/NextjsSite.d.ts +33 -0
  115. package/constructs/NextjsSite.js +285 -0
  116. package/{dist/constructs → constructs}/Parameter.d.ts +0 -0
  117. package/{dist/constructs → constructs}/Parameter.js +3 -0
  118. package/{dist/constructs → constructs}/Queue.d.ts +0 -0
  119. package/{dist/constructs → constructs}/Queue.js +19 -12
  120. package/{dist/constructs → constructs}/RDS.d.ts +0 -0
  121. package/{dist/constructs → constructs}/RDS.js +26 -19
  122. package/{dist/constructs → constructs}/ReactStaticSite.d.ts +0 -0
  123. package/{dist/constructs → constructs}/ReactStaticSite.js +1 -1
  124. package/constructs/RemixSite.d.ts +28 -0
  125. package/constructs/RemixSite.js +150 -0
  126. package/constructs/RemixSite.tsdoc.d.ts +2 -0
  127. package/constructs/RemixSite.tsdoc.js +2 -0
  128. package/{dist/constructs → constructs}/Script/cfn-response.d.ts +0 -0
  129. package/{dist/constructs → constructs}/Script/cfn-response.js +0 -0
  130. package/{dist/constructs → constructs}/Script/index.d.ts +0 -0
  131. package/{dist/constructs → constructs}/Script/index.js +0 -0
  132. package/{dist/constructs → constructs}/Script/outbound.d.ts +1 -1
  133. package/{dist/constructs → constructs}/Script/outbound.js +0 -0
  134. package/{dist/constructs → constructs}/Script/util.d.ts +0 -0
  135. package/{dist/constructs → constructs}/Script/util.js +0 -0
  136. package/{dist/constructs → constructs}/Script.d.ts +0 -0
  137. package/{dist/constructs → constructs}/Script.js +13 -0
  138. package/{dist/constructs → constructs}/Secret.d.ts +0 -0
  139. package/{dist/constructs → constructs}/Secret.js +2 -0
  140. package/constructs/SolidStartSite.d.ts +24 -0
  141. package/constructs/SolidStartSite.js +103 -0
  142. package/constructs/SolidStartSite.tsdoc.d.ts +2 -0
  143. package/constructs/SolidStartSite.tsdoc.js +2 -0
  144. package/{dist/constructs/RemixSite.d.ts → constructs/SsrSite.d.ts} +69 -107
  145. package/{dist/constructs/RemixSite.js → constructs/SsrSite.js} +243 -446
  146. package/{dist/constructs → constructs}/Stack.d.ts +1 -1
  147. package/{dist/constructs → constructs}/Stack.js +19 -4
  148. package/{dist/constructs → constructs}/StaticSite.d.ts +44 -17
  149. package/{dist/constructs → constructs}/StaticSite.js +121 -72
  150. package/{dist/constructs → constructs}/Table.d.ts +0 -0
  151. package/{dist/constructs → constructs}/Table.js +9 -3
  152. package/{dist/constructs → constructs}/Topic.d.ts +0 -0
  153. package/{dist/constructs → constructs}/Topic.js +6 -3
  154. package/{dist/constructs → constructs}/ViteStaticSite.d.ts +0 -0
  155. package/{dist/constructs → constructs}/ViteStaticSite.js +2 -2
  156. package/{dist/constructs → constructs}/WebSocketApi.d.ts +0 -0
  157. package/{dist/constructs → constructs}/WebSocketApi.js +9 -4
  158. package/{dist/constructs → constructs}/context.d.ts +1 -1
  159. package/{dist/constructs → constructs}/context.js +0 -0
  160. package/{dist/constructs → constructs}/deferred_task.d.ts +0 -0
  161. package/{dist/constructs → constructs}/deferred_task.js +4 -2
  162. package/{dist/constructs → constructs/deprecated}/NextjsSite.d.ts +12 -8
  163. package/{dist/constructs → constructs/deprecated}/NextjsSite.js +112 -89
  164. package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.d.ts +0 -0
  165. package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.js +3 -3
  166. package/constructs/deprecated/index.d.ts +1 -0
  167. package/constructs/deprecated/index.js +1 -0
  168. package/{dist/constructs → constructs}/index.d.ts +3 -2
  169. package/{dist/constructs → constructs}/index.js +2 -0
  170. package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.d.ts +0 -0
  171. package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.js +0 -0
  172. package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.d.ts +0 -0
  173. package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.js +4 -4
  174. package/{dist/constructs → constructs}/util/apiGatewayV2Cors.d.ts +0 -0
  175. package/{dist/constructs → constructs}/util/apiGatewayV2Cors.js +0 -0
  176. package/{dist/constructs → constructs}/util/apiGatewayV2Domain.d.ts +0 -0
  177. package/{dist/constructs → constructs}/util/apiGatewayV2Domain.js +0 -0
  178. package/{dist/constructs → constructs}/util/appSyncApiDomain.d.ts +1 -1
  179. package/{dist/constructs → constructs}/util/appSyncApiDomain.js +15 -9
  180. package/{dist/constructs → constructs}/util/builder.d.ts +0 -0
  181. package/{dist/constructs → constructs}/util/builder.js +0 -0
  182. package/{dist/constructs → constructs}/util/duration.d.ts +0 -0
  183. package/{dist/constructs → constructs}/util/duration.js +0 -0
  184. package/{dist/constructs → constructs}/util/functionBinding.d.ts +0 -0
  185. package/{dist/constructs → constructs}/util/functionBinding.js +0 -0
  186. package/{dist/constructs → constructs}/util/functionUrlCors.d.ts +0 -0
  187. package/{dist/constructs → constructs}/util/functionUrlCors.js +0 -0
  188. package/{dist/constructs → constructs}/util/permission.d.ts +0 -0
  189. package/{dist/constructs → constructs}/util/permission.js +32 -16
  190. package/{dist/constructs → constructs}/util/python/bundling.d.ts +0 -0
  191. package/{dist/constructs → constructs}/util/python/bundling.js +0 -0
  192. package/{dist/constructs → constructs}/util/size.d.ts +0 -0
  193. package/{dist/constructs → constructs}/util/size.js +0 -0
  194. package/{dist/constructs → constructs}/util/warning.d.ts +0 -0
  195. package/{dist/constructs → constructs}/util/warning.js +0 -0
  196. package/{dist/context → context}/context.d.ts +1 -1
  197. package/{dist/context → context}/context.js +3 -4
  198. package/{dist/context → context}/handler.d.ts +0 -0
  199. package/{dist/context → context}/handler.js +1 -1
  200. package/{dist/context → context}/index.d.ts +0 -0
  201. package/{dist/context → context}/index.js +0 -0
  202. package/{dist/credentials.d.ts → credentials.d.ts} +3 -1
  203. package/{dist/credentials.js → credentials.js} +11 -3
  204. package/{dist/error.d.ts → error.d.ts} +0 -0
  205. package/{dist/error.js → error.js} +0 -0
  206. package/{dist/iot.d.ts → iot.d.ts} +0 -0
  207. package/{dist/iot.js → iot.js} +3 -0
  208. package/logger.d.ts +3 -0
  209. package/{dist/logger.js → logger.js} +12 -8
  210. package/node/api/index.d.ts +42 -0
  211. package/node/api/index.js +88 -0
  212. package/node/auth/adapter/adapter.d.ts +3 -0
  213. package/node/auth/adapter/adapter.js +3 -0
  214. package/node/auth/adapter/facebook.d.ts +2 -0
  215. package/node/auth/adapter/facebook.js +26 -0
  216. package/node/auth/adapter/github.d.ts +2 -0
  217. package/node/auth/adapter/github.js +21 -0
  218. package/node/auth/adapter/google.d.ts +9 -0
  219. package/node/auth/adapter/google.js +18 -0
  220. package/node/auth/adapter/link.d.ts +8 -0
  221. package/node/auth/adapter/link.js +39 -0
  222. package/node/auth/adapter/oauth.d.ts +25 -0
  223. package/node/auth/adapter/oauth.js +52 -0
  224. package/node/auth/adapter/oidc.d.ts +17 -0
  225. package/node/auth/adapter/oidc.js +50 -0
  226. package/node/auth/adapter/twitch.d.ts +2 -0
  227. package/node/auth/adapter/twitch.js +11 -0
  228. package/node/auth/auth.d.ts +24 -0
  229. package/node/auth/auth.js +118 -0
  230. package/node/auth/index.d.ts +10 -0
  231. package/node/auth/index.js +10 -0
  232. package/node/auth/session.d.ts +76 -0
  233. package/node/auth/session.js +109 -0
  234. package/node/bucket/index.d.ts +3 -0
  235. package/node/bucket/index.js +3 -0
  236. package/node/config/index.d.ts +13 -0
  237. package/node/config/index.js +88 -0
  238. package/node/event-bus/index.d.ts +3 -0
  239. package/node/event-bus/index.js +3 -0
  240. package/node/function/index.d.ts +3 -0
  241. package/node/function/index.js +3 -0
  242. package/node/graphql/index.d.ts +38 -0
  243. package/node/graphql/index.js +48 -0
  244. package/node/job/index.d.ts +34 -0
  245. package/node/job/index.js +51 -0
  246. package/node/kinesis-stream/index.d.ts +3 -0
  247. package/node/kinesis-stream/index.js +3 -0
  248. package/node/queue/index.d.ts +3 -0
  249. package/node/queue/index.js +3 -0
  250. package/node/rds/index.d.ts +3 -0
  251. package/node/rds/index.js +3 -0
  252. package/node/site/index.d.ts +15 -0
  253. package/node/site/index.js +64 -0
  254. package/node/table/index.d.ts +3 -0
  255. package/node/table/index.js +3 -0
  256. package/node/topic/index.d.ts +3 -0
  257. package/node/topic/index.js +3 -0
  258. package/node/util/index.d.ts +7 -0
  259. package/node/util/index.js +57 -0
  260. package/package.json +107 -40
  261. package/pothos.d.ts +8 -0
  262. package/pothos.js +156 -0
  263. package/runtime/handlers/dotnet.d.ts +1 -0
  264. package/runtime/handlers/dotnet.js +117 -0
  265. package/runtime/handlers/go.d.ts +1 -0
  266. package/runtime/handlers/go.js +105 -0
  267. package/runtime/handlers/java.d.ts +1 -0
  268. package/runtime/handlers/java.js +97 -0
  269. package/{dist/runtime → runtime/handlers}/node.d.ts +0 -0
  270. package/runtime/handlers/node.js +172 -0
  271. package/runtime/handlers/python.d.ts +1 -0
  272. package/runtime/handlers/python.js +89 -0
  273. package/{dist/runtime → runtime}/handlers.d.ts +30 -12
  274. package/runtime/handlers.js +117 -0
  275. package/{dist/runtime → runtime}/iot.d.ts +0 -0
  276. package/{dist/runtime → runtime}/iot.js +1 -1
  277. package/{dist/runtime → runtime}/runtime.d.ts +2 -0
  278. package/{dist/runtime → runtime}/runtime.js +0 -0
  279. package/{dist/runtime → runtime}/server.d.ts +0 -0
  280. package/{dist/runtime → runtime}/server.js +39 -3
  281. package/{dist/runtime → runtime}/workers.d.ts +1 -0
  282. package/{dist/runtime → runtime}/workers.js +12 -4
  283. package/{dist/cli/sst.d.ts → scrap.d.ts} +0 -0
  284. package/scrap.js +58 -0
  285. package/site-env.d.ts +13 -0
  286. package/site-env.js +47 -0
  287. package/sst.mjs +21848 -0
  288. package/{dist/stacks → stacks}/build.d.ts +0 -0
  289. package/{dist/stacks → stacks}/build.js +18 -9
  290. package/stacks/deploy.d.ts +8 -0
  291. package/stacks/deploy.js +105 -0
  292. package/stacks/index.d.ts +7 -0
  293. package/stacks/index.js +7 -0
  294. package/stacks/metadata.d.ts +9 -0
  295. package/{dist/stacks → stacks}/metadata.js +2 -14
  296. package/stacks/monitor.d.ts +27 -0
  297. package/stacks/monitor.js +111 -0
  298. package/stacks/remove.d.ts +8 -0
  299. package/stacks/remove.js +80 -0
  300. package/stacks/synth.d.ts +10 -0
  301. package/stacks/synth.js +77 -0
  302. package/support/astro-site-html-stub/index.html +99 -0
  303. package/support/base-site-archiver.cjs +12 -11
  304. package/support/base-site-archiver.mjs +20 -0
  305. package/support/bridge/bridge.mjs +59 -0
  306. package/{dist/support → support}/custom-resources/index.mjs +44209 -42781
  307. package/support/dotnet31-bootstrap/Program.cs +17 -0
  308. package/support/dotnet31-bootstrap/dotnet-bootstrap.csproj +12 -0
  309. package/support/dotnet31-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
  310. package/support/dotnet31-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
  311. package/support/dotnet31-bootstrap/release/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  312. package/support/dotnet31-bootstrap/release/System.Text.Encodings.Web.dll +0 -0
  313. package/support/dotnet31-bootstrap/release/System.Text.Json.dll +0 -0
  314. package/support/dotnet31-bootstrap/release/dotnet-bootstrap +0 -0
  315. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.deps.json +230 -0
  316. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.dll +0 -0
  317. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.pdb +0 -0
  318. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +9 -0
  319. package/support/dotnet6-bootstrap/Program.cs +17 -0
  320. package/support/dotnet6-bootstrap/dotnet-bootstrap.csproj +12 -0
  321. package/support/dotnet6-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
  322. package/support/dotnet6-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
  323. package/support/dotnet6-bootstrap/release/dotnet-bootstrap +0 -0
  324. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +59 -0
  325. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.dll +0 -0
  326. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.pdb +0 -0
  327. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +12 -0
  328. package/support/edge-function/edge-lambda-version.mjs +3 -0
  329. package/support/edge-function/edge-lambda.mjs +3 -0
  330. package/support/edge-function/s3-bucket.mjs +3 -0
  331. package/{dist/support/base-site-custom-resource/cf-invalidate.py → support/edge-function-code-replacer/lambda-code-updater.py} +56 -30
  332. package/support/java-runtime/install.sh +25 -0
  333. package/support/java-runtime/pom.xml +39 -0
  334. package/support/java-runtime/release/aws-lambda-java-core-1.2.0.jar +0 -0
  335. package/support/java-runtime/release/aws-lambda-java-runtime-interface-client-1.1.0.jar +0 -0
  336. package/support/java-runtime/release/aws-lambda-java-serialization-1.0.0.jar +0 -0
  337. package/support/nextjs-site-html-stub/index.html +99 -0
  338. package/{dist/support → support}/nodejs-runtime/index.mjs +7822 -2771
  339. package/support/python-runtime/runtime.py +116 -0
  340. package/support/rds-migrator/index.mjs +28 -0
  341. package/support/remix-site-function/edge-server.js +158 -0
  342. package/support/remix-site-function/polyfill.js +24 -0
  343. package/support/remix-site-function/regional-server.js +162 -0
  344. package/support/remix-site-html-stub/index.html +99 -0
  345. package/support/sls-nextjs-site-build-helper/build.cjs +91 -0
  346. package/support/sls-nextjs-site-build-helper/index-wrapper.js +19 -0
  347. package/support/sls-nextjs-site-stub/index.html +99 -0
  348. package/support/solid-start-site-html-stub/index.html +99 -0
  349. package/support/ssr-site-function-stub/index.js +5 -0
  350. package/util/fs.d.ts +4 -0
  351. package/util/fs.js +46 -0
  352. package/util/module.d.ts +1 -0
  353. package/util/module.js +5 -0
  354. package/util/process.d.ts +2 -0
  355. package/util/process.js +3 -0
  356. package/{dist/watcher.d.ts → watcher.d.ts} +0 -0
  357. package/{dist/watcher.js → watcher.js} +1 -1
  358. package/.build/sst-debug.log +0 -10
  359. package/.turbo/turbo-build.log +0 -2
  360. package/CHANGELOG.md +0 -332
  361. package/analyze +0 -11090
  362. package/bin/sst.mjs +0 -3
  363. package/build.mjs +0 -116
  364. package/debug.log +0 -6
  365. package/dist/app.js +0 -92
  366. package/dist/bootstrap.js +0 -23
  367. package/dist/cli/commands/build.js +0 -8
  368. package/dist/cli/commands/deploy.js +0 -20
  369. package/dist/cli/commands/env.d.ts +0 -0
  370. package/dist/cli/commands/env.js +0 -1
  371. package/dist/cli/commands/scrap.d.ts +0 -5
  372. package/dist/cli/commands/scrap.js +0 -1
  373. package/dist/cli/commands/start.d.ts +0 -7
  374. package/dist/cli/commands/start.js +0 -136
  375. package/dist/cli/program.d.ts +0 -7
  376. package/dist/cli/ui/deploy.d.ts +0 -6
  377. package/dist/constructs/nextjs-site/custom-resource/cfn-response.d.ts +0 -19
  378. package/dist/constructs/nextjs-site/custom-resource/cfn-response.js +0 -94
  379. package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.d.ts +0 -1
  380. package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.js +0 -138
  381. package/dist/constructs/nextjs-site/custom-resource/edge-lambda.d.ts +0 -1
  382. package/dist/constructs/nextjs-site/custom-resource/edge-lambda.js +0 -136
  383. package/dist/constructs/nextjs-site/custom-resource/s3-bucket.d.ts +0 -1
  384. package/dist/constructs/nextjs-site/custom-resource/s3-bucket.js +0 -94
  385. package/dist/constructs/nextjs-site/custom-resource/util.d.ts +0 -1
  386. package/dist/constructs/nextjs-site/custom-resource/util.js +0 -4
  387. package/dist/logger.d.ts +0 -9
  388. package/dist/runtime/handlers.js +0 -72
  389. package/dist/runtime/node.js +0 -99
  390. package/dist/sst.mjs +0 -164202
  391. package/dist/stacks/deploy.d.ts +0 -33
  392. package/dist/stacks/deploy.js +0 -168
  393. package/dist/stacks/index.d.ts +0 -21
  394. package/dist/stacks/index.js +0 -57
  395. package/dist/stacks/metadata.d.ts +0 -9
  396. package/dist/support/base-site-archiver.cjs +0 -115
  397. package/dist/support/base-site-custom-resource/s3-handler.py +0 -195
  398. package/dist/support/base-site-custom-resource/s3-upload.py +0 -91
  399. package/dist/support/bridge/bridge.mjs +0 -86
  400. package/dist/support/static-site-stub/index.html +0 -90
  401. package/src/app.ts +0 -140
  402. package/src/bootstrap.ts +0 -28
  403. package/src/bus.ts +0 -81
  404. package/src/cache.ts +0 -34
  405. package/src/cdk/cloudformation-deployments.ts +0 -730
  406. package/src/cdk/deploy-stack.ts +0 -1030
  407. package/src/cli/commands/bind.ts +0 -31
  408. package/src/cli/commands/build.ts +0 -16
  409. package/src/cli/commands/deploy.ts +0 -34
  410. package/src/cli/commands/env.ts +0 -0
  411. package/src/cli/commands/scrap.ts +0 -5
  412. package/src/cli/commands/secrets/get.ts +0 -50
  413. package/src/cli/commands/secrets/list.ts +0 -66
  414. package/src/cli/commands/secrets/remove.ts +0 -36
  415. package/src/cli/commands/secrets/secrets.ts +0 -17
  416. package/src/cli/commands/secrets/set.ts +0 -59
  417. package/src/cli/commands/start.tsx +0 -162
  418. package/src/cli/commands/update.ts +0 -100
  419. package/src/cli/program.ts +0 -22
  420. package/src/cli/spinner.ts +0 -14
  421. package/src/cli/sst.ts +0 -50
  422. package/src/cli/ui/deploy.tsx +0 -139
  423. package/src/config.ts +0 -226
  424. package/src/constructs/Api.ts +0 -1448
  425. package/src/constructs/ApiGatewayV1Api.ts +0 -1481
  426. package/src/constructs/App.ts +0 -744
  427. package/src/constructs/AppSyncApi.ts +0 -1045
  428. package/src/constructs/Auth.ts +0 -252
  429. package/src/constructs/BaseSite.ts +0 -146
  430. package/src/constructs/Bucket.ts +0 -670
  431. package/src/constructs/Cognito.ts +0 -708
  432. package/src/constructs/Config.ts +0 -4
  433. package/src/constructs/Construct.ts +0 -77
  434. package/src/constructs/Cron.ts +0 -235
  435. package/src/constructs/DebugApp.ts +0 -97
  436. package/src/constructs/DebugStack.ts +0 -182
  437. package/src/constructs/EdgeFunction.ts +0 -460
  438. package/src/constructs/EventBus.ts +0 -651
  439. package/src/constructs/Function.ts +0 -1329
  440. package/src/constructs/FunctionalStack.ts +0 -90
  441. package/src/constructs/GraphQLApi.ts +0 -140
  442. package/src/constructs/Job.ts +0 -557
  443. package/src/constructs/KinesisStream.ts +0 -388
  444. package/src/constructs/Metadata.ts +0 -75
  445. package/src/constructs/NextjsSite.ts +0 -1498
  446. package/src/constructs/Parameter.ts +0 -72
  447. package/src/constructs/Queue.ts +0 -360
  448. package/src/constructs/RDS.ts +0 -578
  449. package/src/constructs/ReactStaticSite.ts +0 -66
  450. package/src/constructs/RemixSite.ts +0 -1397
  451. package/src/constructs/Script/cfn-response.ts +0 -116
  452. package/src/constructs/Script/index.ts +0 -103
  453. package/src/constructs/Script/outbound.ts +0 -59
  454. package/src/constructs/Script/package.json +0 -3
  455. package/src/constructs/Script/util.ts +0 -19
  456. package/src/constructs/Script.ts +0 -270
  457. package/src/constructs/Secret.ts +0 -66
  458. package/src/constructs/Stack.ts +0 -319
  459. package/src/constructs/StaticSite.ts +0 -995
  460. package/src/constructs/Table.ts +0 -844
  461. package/src/constructs/Topic.ts +0 -486
  462. package/src/constructs/ViteStaticSite.ts +0 -99
  463. package/src/constructs/WebSocketApi.ts +0 -687
  464. package/src/constructs/context.ts +0 -12
  465. package/src/constructs/deferred_task.ts +0 -53
  466. package/src/constructs/descs.d.ts +0 -1
  467. package/src/constructs/index.ts +0 -39
  468. package/src/constructs/nextjs-site/cross-region-helper.ts +0 -189
  469. package/src/constructs/nextjs-site/custom-resource/cfn-response.ts +0 -146
  470. package/src/constructs/nextjs-site/custom-resource/edge-lambda-version.ts +0 -162
  471. package/src/constructs/nextjs-site/custom-resource/edge-lambda.ts +0 -167
  472. package/src/constructs/nextjs-site/custom-resource/s3-bucket.ts +0 -112
  473. package/src/constructs/nextjs-site/custom-resource/util.ts +0 -11
  474. package/src/constructs/util/apiGatewayV1AccessLog.ts +0 -106
  475. package/src/constructs/util/apiGatewayV2AccessLog.ts +0 -139
  476. package/src/constructs/util/apiGatewayV2Cors.ts +0 -94
  477. package/src/constructs/util/apiGatewayV2Domain.ts +0 -312
  478. package/src/constructs/util/appSyncApiDomain.ts +0 -204
  479. package/src/constructs/util/builder.ts +0 -17
  480. package/src/constructs/util/duration.ts +0 -27
  481. package/src/constructs/util/functionBinding.ts +0 -102
  482. package/src/constructs/util/functionUrlCors.ts +0 -96
  483. package/src/constructs/util/permission.ts +0 -299
  484. package/src/constructs/util/python/bundling.ts +0 -174
  485. package/src/constructs/util/size.ts +0 -13
  486. package/src/constructs/util/warning.ts +0 -20
  487. package/src/context/context.ts +0 -79
  488. package/src/context/handler.ts +0 -53
  489. package/src/context/index.ts +0 -2
  490. package/src/credentials.ts +0 -103
  491. package/src/error.ts +0 -5
  492. package/src/iot.ts +0 -105
  493. package/src/logger.ts +0 -35
  494. package/src/runtime/handlers.ts +0 -121
  495. package/src/runtime/iot.ts +0 -16
  496. package/src/runtime/node.ts +0 -111
  497. package/src/runtime/runtime.ts +0 -27
  498. package/src/runtime/server.ts +0 -149
  499. package/src/runtime/workers.ts +0 -96
  500. package/src/stacks/build.ts +0 -69
  501. package/src/stacks/deploy.ts +0 -232
  502. package/src/stacks/index.ts +0 -73
  503. package/src/stacks/metadata.ts +0 -125
  504. package/src/watcher.ts +0 -47
  505. package/sst.config.mjs +0 -6
  506. package/support/bridge/bridge.ts +0 -136
  507. package/support/bridge/build.mjs +0 -18
  508. package/support/custom-resources/auth-keys.ts +0 -113
  509. package/support/custom-resources/build.mjs +0 -18
  510. package/support/custom-resources/cfn-response.ts +0 -151
  511. package/support/custom-resources/index.ts +0 -18
  512. package/support/custom-resources/secrets-migration.ts +0 -82
  513. package/support/custom-resources/stack-metadata.ts +0 -75
  514. package/support/custom-resources/util.ts +0 -44
  515. package/support/nodejs-runtime/index.ts +0 -69
  516. package/support/tsconfig.json +0 -11
  517. package/tsconfig.json +0 -13
  518. package/yarn-error.log +0 -75
@@ -1,96 +0,0 @@
1
- import { HttpMethod, FunctionUrlCorsOptions } from "aws-cdk-lib/aws-lambda";
2
- import { Duration, toCdkDuration } from "./duration.js";
3
-
4
- export interface CorsProps {
5
- /**
6
- * Specifies whether credentials are included in the CORS request.
7
- * @default false
8
- */
9
- allowCredentials?: boolean;
10
- /**
11
- * The collection of allowed headers.
12
- * @default Allow all headers.
13
- *
14
- * @example
15
- * ```js
16
- * // Allow all headers
17
- * allowHeaders: ["*"]
18
- *
19
- * // Allow specific headers
20
- * allowHeaders: ["Accept", "Content-Type", "Authorization"]
21
- * ```
22
- */
23
- allowHeaders?: string[];
24
- /**
25
- * The collection of allowed HTTP methods.
26
- * @default Allow all methods.
27
- *
28
- * @example
29
- * ```js
30
- * // Allow all methods
31
- * allowMethods: ["*"]
32
- *
33
- * // Allow specific methods
34
- * allowMethods: ["GET", "POST"]
35
- * ```
36
- */
37
- allowMethods?: (keyof Omit<typeof HttpMethod, "ALL"> | "*")[];
38
- /**
39
- * The collection of allowed origins.
40
- * @default Allow all origins.
41
- *
42
- * @example
43
- * ```js
44
- * // Allow all origins
45
- * allowOrigins: ["*"]
46
- *
47
- * // Allow specific origins. Note that the url protocol, ie. "https://", is required.
48
- * allowOrigins: ["https://domain.com"]
49
- * ```
50
- */
51
- allowOrigins?: string[];
52
- /**
53
- * The collection of exposed headers.
54
- * @default No expose headers are allowed.
55
- */
56
- exposeHeaders?: string[];
57
- /**
58
- * Specify how long the results of a preflight response can be cached
59
- * @default No caching
60
- *
61
- * @example
62
- * ```js
63
- * maxAge: "1 day"
64
- * ```
65
- */
66
- maxAge?: Duration;
67
- }
68
-
69
- export function buildCorsConfig(
70
- cors?: boolean | CorsProps
71
- ): FunctionUrlCorsOptions | undefined {
72
- // Handle cors: false
73
- if (cors === false) {
74
- return;
75
- }
76
-
77
- // Handle cors: true | undefined
78
- if (cors === undefined || cors === true) {
79
- cors = {} as CorsProps;
80
- }
81
-
82
- // Handle cors: CorsProps
83
- return {
84
- allowCredentials: cors.allowCredentials,
85
- allowedHeaders: cors.allowHeaders || ["*"],
86
- allowedMethods: (cors.allowMethods || ["*"]).map(
87
- (method) =>
88
- method === "*"
89
- ? HttpMethod.ALL
90
- : HttpMethod[method as keyof typeof HttpMethod]
91
- ),
92
- allowedOrigins: cors.allowOrigins || ["*"],
93
- exposedHeaders: cors.exposeHeaders,
94
- maxAge: cors.maxAge && toCdkDuration(cors.maxAge),
95
- };
96
- }
@@ -1,299 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment*/
2
-
3
- import { Construct, IConstruct } from "constructs";
4
- import * as iam from "aws-cdk-lib/aws-iam";
5
- import { getChildLogger } from "@serverless-stack/core";
6
- import {
7
- Api,
8
- Job,
9
- RDS,
10
- Table,
11
- Topic,
12
- Queue,
13
- Bucket,
14
- EventBus,
15
- Function,
16
- AppSyncApi,
17
- WebSocketApi,
18
- KinesisStream,
19
- ApiGatewayV1Api,
20
- Stack,
21
- } from "../index.js";
22
- import { isCDKConstruct, isCDKConstructOf } from "../Construct.js";
23
-
24
- const logger = getChildLogger("resources");
25
-
26
- export type Permissions = "*" | Permission[];
27
- type SupportedPermissions =
28
- | "execute-api"
29
- | "appsync"
30
- | "dynamodb"
31
- | "sns"
32
- | "sqs"
33
- | "events"
34
- | "kinesis"
35
- | "s3"
36
- | "rds-data"
37
- | "secretsmanager"
38
- | "lambda"
39
- | "ssm";
40
- type Permission =
41
- | SupportedPermissions
42
- | Omit<string, SupportedPermissions>
43
- | IConstruct
44
- | [IConstruct, string]
45
- | iam.PolicyStatement;
46
- type StatementsAndGrants = {
47
- statements: iam.PolicyStatement[];
48
- grants: [IConstruct, string][];
49
- }
50
-
51
- export function attachPermissionsToRole(
52
- role: iam.Role,
53
- permissions: Permissions
54
- ): void {
55
- const { statements, grants } = permissionsToStatementsAndGrants(permissions);
56
- statements.forEach((statement) => role.addToPolicy(statement));
57
- grants.forEach(grant => {
58
- const construct = grant[0] as Construct;
59
- const methodName = grant[1] as keyof Construct;
60
- (construct[methodName] as { (construct: Construct): void })(role);
61
- });
62
- }
63
-
64
- export function attachPermissionsToPolicy(
65
- policy: iam.Policy,
66
- permissions: Permissions
67
- ): void {
68
- const { statements, grants } = permissionsToStatementsAndGrants(permissions);
69
- statements.forEach((statement) => policy.addStatements(statement));
70
- grants.forEach(grant => {
71
- throw new Error(`Cannot attach the "${grant[1]}" permission to an IAM policy.`);
72
- });
73
- }
74
-
75
- function permissionsToStatementsAndGrants(permissions: Permissions): StatementsAndGrants {
76
- // Four patterns
77
- //
78
- // attachPermissions("*");
79
- // attachPermissions([ 'sns', 'sqs' ]);
80
- // attachPermissions([ event, queue ]);
81
- // attachPermissions([
82
- // [ event.snsTopic, 'grantPublish' ],
83
- // [ queue.sqsQueue, 'grantSendMessages' ],
84
- // ]);
85
- // attachPermissions([
86
- // new iam.PolicyStatement({
87
- // actions: ["s3:*"],
88
- // effect: iam.Effect.ALLOW,
89
- // resources: [
90
- // bucket.bucketArn + "/private/${cognito-identity.amazonaws.com:sub}/*",
91
- // ],
92
- // })
93
- // ]);
94
-
95
- ////////////////////////////////////
96
- // Case: 'admin' permissions => '*'
97
- ////////////////////////////////////
98
- if (permissions === "*") {
99
- return {
100
- statements: [buildPolicyStatement(permissions, ["*"])],
101
- grants: [],
102
- };
103
- }
104
-
105
- if (!Array.isArray(permissions)) {
106
- throw new Error(
107
- `The specified permissions are not supported. They are expected to be "*" or an array.`
108
- );
109
- }
110
-
111
- // Handle array of permissions
112
- const statements: iam.PolicyStatement[] = [];
113
- const grants: [IConstruct, string][] = [];
114
- permissions.forEach((permission: Permission) => {
115
- ////////////////////////////////////
116
- // Case: string ie. 's3' or 's3:*'
117
- ////////////////////////////////////
118
- if (typeof permission === "string") {
119
- const perm =
120
- permission.indexOf(":") === -1 ? `${permission}:*` : permission;
121
- statements.push(buildPolicyStatement(perm, ["*"]));
122
- }
123
- ////////////////////////////////////
124
- // Case: iam.PolicyStatement
125
- ////////////////////////////////////
126
- else if (
127
- isCDKConstructOf(
128
- permission as Construct,
129
- "aws-cdk-lib.aws_iam.PolicyStatement"
130
- )
131
- ) {
132
- statements.push(permission as iam.PolicyStatement);
133
- }
134
- ////////////////////////////////////
135
- // Case: SST construct
136
- ////////////////////////////////////
137
- else if (permission instanceof Api) {
138
- const httpApi = permission.cdk.httpApi;
139
- const { account, region } = Stack.of(httpApi);
140
- statements.push(
141
- buildPolicyStatement("execute-api:Invoke", [
142
- `arn:aws:execute-api:${region}:${account}:${httpApi.httpApiId}/*`,
143
- ])
144
- );
145
- } else if (permission instanceof ApiGatewayV1Api) {
146
- const restApi = permission.cdk.restApi;
147
- const { account, region } = Stack.of(restApi);
148
- statements.push(
149
- buildPolicyStatement("execute-api:Invoke", [
150
- `arn:aws:execute-api:${region}:${account}:${restApi.restApiId}/*`,
151
- ])
152
- );
153
- } else if (permission instanceof WebSocketApi) {
154
- const webSocketApi = permission.cdk.webSocketApi;
155
- const { account, region } = Stack.of(webSocketApi);
156
- statements.push(
157
- buildPolicyStatement("execute-api:Invoke", [
158
- `arn:aws:execute-api:${region}:${account}:${webSocketApi.apiId}/*`,
159
- ])
160
- );
161
- statements.push(
162
- buildPolicyStatement("execute-api:ManageConnections", [
163
- permission._connectionsArn,
164
- ])
165
- );
166
- } else if (permission instanceof AppSyncApi) {
167
- const graphqlApi = permission.cdk.graphqlApi;
168
- const { account, region } = Stack.of(graphqlApi);
169
- statements.push(
170
- buildPolicyStatement("appsync:GraphQL", [
171
- `arn:aws:appsync:${region}:${account}:apis/${graphqlApi.apiId}/*`,
172
- ])
173
- );
174
- } else if (permission instanceof Table) {
175
- const tableArn = permission.cdk.table.tableArn;
176
- statements.push(buildPolicyStatement("dynamodb:*", [tableArn, `${tableArn}/*`]));
177
- } else if (permission instanceof Topic) {
178
- statements.push(buildPolicyStatement("sns:*", [permission.cdk.topic.topicArn]));
179
- } else if (permission instanceof Queue) {
180
- statements.push(buildPolicyStatement("sqs:*", [permission.cdk.queue.queueArn]));
181
- } else if (permission instanceof EventBus) {
182
- statements.push(
183
- buildPolicyStatement("events:*", [permission.cdk.eventBus.eventBusArn])
184
- );
185
- } else if (permission instanceof KinesisStream) {
186
- statements.push(
187
- buildPolicyStatement("kinesis:*", [permission.cdk.stream.streamArn])
188
- );
189
- } else if (permission instanceof Bucket) {
190
- const bucketArn = permission.cdk.bucket.bucketArn;
191
- statements.push(buildPolicyStatement("s3:*", [bucketArn, `${bucketArn}/*`]));
192
- } else if (permission instanceof RDS) {
193
- statements.push(buildPolicyStatement("rds-data:*", [permission.clusterArn]));
194
- if (permission.cdk.cluster.secret) {
195
- statements.push(
196
- buildPolicyStatement(
197
- ["secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret"],
198
- [permission.cdk.cluster.secret.secretArn]
199
- )
200
- );
201
- }
202
- } else if (permission instanceof Function) {
203
- statements.push(buildPolicyStatement("lambda:*", [permission.functionArn]));
204
- } else if (permission instanceof Job) {
205
- statements.push(buildPolicyStatement("lambda:*", [permission._jobInvoker.functionArn]));
206
- }
207
- ////////////////////////////////////
208
- // Case: CDK constructs
209
- ////////////////////////////////////
210
- else if ((permission as any).tableArn && (permission as any).tableName) {
211
- // @ts-expect-error We do not want to import the cdk modules, just cast to any
212
- const tableArn = permission.tableArn;
213
- statements.push(buildPolicyStatement("dynamodb:*", [tableArn, `${tableArn}/*`]));
214
- } else if ((permission as any).topicArn && (permission as any).topicName) {
215
- // @ts-expect-error We do not want to import the cdk modules, just cast to any
216
- statements.push(buildPolicyStatement("sns:*", [permission.topicArn]));
217
- } else if ((permission as any).queueArn && (permission as any).queueName) {
218
- // @ts-expect-error We do not want to import the cdk modules, just cast to any
219
- statements.push(buildPolicyStatement("sqs:*", [permission.queueArn]));
220
- } else if (
221
- (permission as any).eventBusArn &&
222
- (permission as any).eventBusName
223
- ) {
224
- // @ts-expect-error We do not want to import the cdk modules, just cast to any
225
- statements.push(buildPolicyStatement("events:*", [permission.eventBusArn]));
226
- } else if (
227
- (permission as any).streamArn &&
228
- (permission as any).streamName
229
- ) {
230
- // @ts-expect-error We do not want to import the cdk modules, just cast to any
231
- statements.push(buildPolicyStatement("kinesis:*", [permission.streamArn]));
232
- } else if (
233
- (permission as any).deliveryStreamArn &&
234
- (permission as any).deliveryStreamName
235
- ) {
236
- statements.push(
237
- buildPolicyStatement("firehose:*", [(permission as any).deliveryStreamArn])
238
- );
239
- } else if (
240
- (permission as any).bucketArn &&
241
- (permission as any).bucketName
242
- ) {
243
- // @ts-expect-error We do not want to import the cdk modules, just cast to any
244
- const bucketArn = permission.bucketArn;
245
- statements.push(buildPolicyStatement("s3:*", [bucketArn, `${bucketArn}/*`]));
246
- } else if ((permission as any).clusterArn) {
247
- // For ServerlessCluster, we need to grant:
248
- // - permisssions to access the Data API;
249
- // - permisssions to access the Secret Manager (required by Data API).
250
- // No need to grant the permissions for IAM database authentication
251
- statements.push(
252
- buildPolicyStatement("rds-data:*", [(permission as any).clusterArn])
253
- );
254
- const secret = (permission as any).secret;
255
- if (secret) {
256
- statements.push(
257
- buildPolicyStatement(
258
- ["secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret"],
259
- [secret.secretArn]
260
- )
261
- );
262
- }
263
- }
264
- ////////////////////////////////////
265
- // Case: grant method
266
- ////////////////////////////////////
267
- else if (
268
- Array.isArray(permission) &&
269
- permission.length === 2 &&
270
- isCDKConstruct(permission[0]) &&
271
- typeof permission[1] === "string"
272
- ) {
273
- const construct = permission[0] as Construct;
274
- const methodName = permission[1] as keyof Construct;
275
- if (typeof construct[methodName] !== "function")
276
- throw new Error(
277
- `The specified grant method is incorrect.
278
- Check the available methods that prefixed with grants on the Construct`
279
- );
280
- grants.push(permission);
281
- } else {
282
- logger.debug("permission object", permission);
283
- throw new Error(`The specified permissions are not supported.`);
284
- }
285
- });
286
-
287
- return { statements, grants }
288
- }
289
-
290
- function buildPolicyStatement(
291
- actions: string | string[],
292
- resources: string[]
293
- ): iam.PolicyStatement {
294
- return new iam.PolicyStatement({
295
- effect: iam.Effect.ALLOW,
296
- actions: typeof actions === "string" ? [actions] : actions,
297
- resources,
298
- });
299
- }
@@ -1,174 +0,0 @@
1
- /**
2
- * This file is copied from https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-lambda-python/lib/bundling.ts
3
- */
4
- import fs from "fs";
5
- import url from "url";
6
- import path from "path";
7
- import * as cdk from "aws-cdk-lib";
8
- import * as lambda from "aws-cdk-lib/aws-lambda";
9
- const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
10
-
11
- /**
12
- * Dependency files to exclude from the asset hash.
13
- */
14
- export const DEPENDENCY_EXCLUDES = ["*.pyc"];
15
-
16
- /**
17
- * The location in the image that the bundler image caches dependencies.
18
- */
19
- export const BUNDLER_DEPENDENCIES_CACHE = "/var/dependencies";
20
-
21
- /**
22
- * Options for bundling
23
- */
24
- export interface BundlingOptions {
25
- /**
26
- * Entry path
27
- */
28
- readonly entry: string;
29
-
30
- /**
31
- * The runtime of the lambda function
32
- */
33
- readonly runtime: lambda.Runtime;
34
-
35
- /**
36
- * Output path suffix ('python' for a layer, '.' otherwise)
37
- */
38
- readonly outputPathSuffix: string;
39
-
40
- /**
41
- * Determines how asset hash is calculated. Assets will get rebuild and
42
- * uploaded only if their hash has changed.
43
- *
44
- * If asset hash is set to `SOURCE` (default), then only changes to the source
45
- * directory will cause the asset to rebuild. This means, for example, that in
46
- * order to pick up a new dependency version, a change must be made to the
47
- * source tree. Ideally, this can be implemented by including a dependency
48
- * lockfile in your source tree or using fixed dependencies.
49
- *
50
- * If the asset hash is set to `OUTPUT`, the hash is calculated after
51
- * bundling. This means that any change in the output will cause the asset to
52
- * be invalidated and uploaded. Bear in mind that `pip` adds timestamps to
53
- * dependencies it installs, which implies that in this mode Python bundles
54
- * will _always_ get rebuild and uploaded. Normally this is an anti-pattern
55
- * since build
56
- *
57
- * @default AssetHashType.SOURCE By default, hash is calculated based on the
58
- * contents of the source directory. If `assetHash` is also specified, the
59
- * default is `CUSTOM`. This means that only updates to the source will cause
60
- * the asset to rebuild.
61
- */
62
- readonly assetHashType?: cdk.AssetHashType;
63
-
64
- /**
65
- * Specify a custom hash for this asset. If `assetHashType` is set it must
66
- * be set to `AssetHashType.CUSTOM`. For consistency, this custom hash will
67
- * be SHA256 hashed and encoded as hex. The resulting hash will be the asset
68
- * hash.
69
- *
70
- * NOTE: the hash is used in order to identify a specific revision of the asset, and
71
- * used for optimizing and caching deployment activities related to this asset such as
72
- * packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will
73
- * need to make sure it is updated every time the asset changes, or otherwise it is
74
- * possible that some deployments will not be invalidated.
75
- *
76
- * @default - based on `assetHashType`
77
- */
78
- readonly assetHash?: string;
79
-
80
- readonly installCommands?: string[];
81
- }
82
-
83
- /**
84
- * Produce bundled Lambda asset code
85
- */
86
- export function bundle(options: BundlingOptions): lambda.AssetCode {
87
- const { entry, runtime, outputPathSuffix, installCommands } = options;
88
-
89
- const stagedir = cdk.FileSystem.mkdtemp("python-bundling-");
90
- const hasDeps = stageDependencies(entry, stagedir);
91
- const hasInstallCommands = stageInstallCommands(
92
- installCommands || [],
93
- stagedir
94
- );
95
-
96
- const depsCommand = chain([
97
- hasDeps || hasInstallCommands
98
- ? `rsync -r ${BUNDLER_DEPENDENCIES_CACHE}/. ${cdk.AssetStaging.BUNDLING_OUTPUT_DIR}/${outputPathSuffix}`
99
- : "",
100
- `rsync -r . ${cdk.AssetStaging.BUNDLING_OUTPUT_DIR}/${outputPathSuffix}`,
101
- ]);
102
-
103
- // Determine which dockerfile to use. When dependencies are present, we use a
104
- // Dockerfile that can create a cacheable layer. We can't use this Dockerfile
105
- // if there aren't dependencies or the Dockerfile will complain about missing
106
- // sources.
107
- const dockerfile = hasInstallCommands
108
- ? "Dockerfile.custom"
109
- : hasDeps
110
- ? "Dockerfile.dependencies"
111
- : "Dockerfile";
112
-
113
- // copy Dockerfile to workdir
114
- fs.copyFileSync(
115
- path.join(__dirname, "../../../assets/python", dockerfile),
116
- path.join(stagedir, dockerfile)
117
- );
118
-
119
- const image = cdk.DockerImage.fromBuild(stagedir, {
120
- buildArgs: {
121
- IMAGE: runtime.bundlingImage.image,
122
- },
123
- file: dockerfile,
124
- });
125
-
126
- return lambda.Code.fromAsset(entry, {
127
- assetHashType: options.assetHashType,
128
- assetHash: options.assetHash,
129
- exclude: DEPENDENCY_EXCLUDES,
130
- bundling: {
131
- image,
132
- command: ["bash", "-c", depsCommand],
133
- },
134
- });
135
- }
136
-
137
- /**
138
- * Checks to see if the `entry` directory contains a type of dependency that
139
- * we know how to install.
140
- */
141
- export function stageDependencies(entry: string, stagedir: string): boolean {
142
- const prefixes = ["Pipfile", "pyproject", "poetry", "requirements.txt"];
143
-
144
- let found = false;
145
- for (const file of fs.readdirSync(entry)) {
146
- for (const prefix of prefixes) {
147
- if (file.startsWith(prefix)) {
148
- fs.copyFileSync(path.join(entry, file), path.join(stagedir, file));
149
- found = true;
150
- }
151
- }
152
- }
153
-
154
- return found;
155
- }
156
-
157
- function stageInstallCommands(
158
- installCommands: string[],
159
- stagedir: string
160
- ): boolean {
161
- let found = false;
162
- if (installCommands.length > 0) {
163
- const filePath = path.join(stagedir, "sst-deps-install-command.sh");
164
- fs.writeFileSync(filePath, installCommands.join(" && "));
165
- fs.chmodSync(filePath, "755");
166
- found = true;
167
- }
168
-
169
- return found;
170
- }
171
-
172
- function chain(commands: string[]): string {
173
- return commands.filter((c) => !!c).join(" && ");
174
- }
@@ -1,13 +0,0 @@
1
- import * as cdk from "aws-cdk-lib";
2
- export type Size = `${number} ${"MB" | "GB"}`;
3
-
4
- export function toCdkSize(size: Size): cdk.Size {
5
- const [count, unit] = size.split(" ");
6
- const countNum = parseInt(count);
7
- if (unit === "MB") {
8
- return cdk.Size.mebibytes(countNum);
9
- } else if (unit === "GB") {
10
- return cdk.Size.gibibytes(countNum);
11
- }
12
- throw new Error(`Invalid size ${size}`);
13
- }
@@ -1,20 +0,0 @@
1
- import { createAppContext } from "../context.js";
2
-
3
- const WARNINGS = {
4
- "config.deprecated": `WARNING: The "config" prop is deprecated, and will be removed in SST v2. Pass Parameters and Secrets in through the "bind" prop. Read more about how to upgrade here — https://docs.serverless-stack.com/upgrade-guide#upgrade-to-v116`,
5
- "permissions.noConstructs": `WARNING: Passing SST constructs into "permissions" is deprecated, and will be removed in SST v2. Pass them into the "bind" prop. Read more about how to upgrade here — https://docs.serverless-stack.com/upgrade-guide#upgrade-to-v116`
6
- };
7
-
8
- export const useWarning = createAppContext(() => {
9
- const set = new Set<keyof typeof WARNINGS>();
10
- return {
11
- add(message: keyof typeof WARNINGS) {
12
- set.add(message);
13
- },
14
- print() {
15
- for (const key of set) {
16
- console.warn(WARNINGS[key]);
17
- }
18
- }
19
- };
20
- });
@@ -1,79 +0,0 @@
1
- export const Context = {
2
- create,
3
- reset,
4
- memo,
5
- };
6
-
7
- const state = {
8
- requestID: "",
9
- contexts: new Map<any, ContextInfo>(),
10
- tracking: [] as any[],
11
- };
12
-
13
- interface ContextInfo {
14
- value: any;
15
- dependants: Set<any>;
16
- }
17
-
18
- function create<C>(cb?: () => C) {
19
- const id = Symbol();
20
- return {
21
- use() {
22
- let result = state.contexts.get(id);
23
-
24
- if (!result) {
25
- if (!cb) throw new Error(`"${String(id)}" context must be provided.`);
26
- state.tracking.push(id);
27
- const value = cb();
28
- state.tracking.pop();
29
- result = {
30
- value,
31
- dependants: new Set(),
32
- };
33
- state.contexts.set(id, result);
34
- }
35
- const last = state.tracking[state.tracking.length - 1];
36
- // Use is being called within another context booting up so mark it as a dependent
37
- if (last) result!.dependants.add(last);
38
- return result!.value as C;
39
- },
40
- provide(value: C) {
41
- // If a new request has started, automatically clear all contexts
42
- const requestID = (global as any)[
43
- Symbol.for("aws.lambda.runtime.requestId")
44
- ];
45
- if (state.requestID !== requestID) {
46
- state.requestID = requestID;
47
- reset();
48
- }
49
-
50
- // If the context is already set, we need to reset its dependants
51
- resetDependencies(id);
52
-
53
- state.contexts.set(id, {
54
- value,
55
- dependants: new Set(),
56
- });
57
- },
58
- };
59
- }
60
-
61
- function reset() {
62
- state.contexts.clear();
63
- }
64
-
65
- function resetDependencies(id: any) {
66
- const info = state.contexts.get(id);
67
- if (!info) return;
68
- for (const dependantID of info.dependants) {
69
- resetDependencies(dependantID);
70
- state.contexts.delete(dependantID);
71
- }
72
- }
73
-
74
- export function memo<C>(cb: () => C) {
75
- const ctx = create(cb);
76
- return ctx.use;
77
- }
78
-
79
- 5;