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.
- package/LICENSE +21 -0
- package/{dist/app.d.ts → app.d.ts} +8 -1
- package/app.js +122 -0
- package/{dist/bootstrap.d.ts → bootstrap.d.ts} +1 -0
- package/bootstrap.js +79 -0
- package/{dist/bus.d.ts → bus.d.ts} +0 -0
- package/{dist/bus.js → bus.js} +0 -0
- package/{dist/cache.d.ts → cache.d.ts} +0 -0
- package/{dist/cache.js → cache.js} +0 -0
- package/{dist/cdk → cdk}/cloudformation-deployments.d.ts +1 -1
- package/{dist/cdk → cdk}/cloudformation-deployments.js +1 -0
- package/{dist/cdk → cdk}/deploy-stack.d.ts +0 -0
- package/{dist/cdk → cdk}/deploy-stack.js +13 -6
- package/{dist/cli → cli}/commands/bind.d.ts +3 -1
- package/{dist/cli → cli}/commands/bind.js +8 -4
- package/{dist/cli → cli}/commands/build.d.ts +2 -0
- package/cli/commands/build.js +12 -0
- package/cli/commands/console.d.ts +9 -0
- package/cli/commands/console.js +15 -0
- package/{dist/cli → cli}/commands/deploy.d.ts +7 -1
- package/cli/commands/deploy.js +48 -0
- package/cli/commands/dev.d.ts +11 -0
- package/cli/commands/dev.js +188 -0
- package/cli/commands/env.d.ts +11 -0
- package/cli/commands/env.js +39 -0
- package/cli/commands/plugins/kysely.d.ts +1 -0
- package/cli/commands/plugins/kysely.js +91 -0
- package/cli/commands/plugins/pothos.d.ts +1 -0
- package/cli/commands/plugins/pothos.js +52 -0
- package/cli/commands/plugins/warmer.d.ts +1 -0
- package/cli/commands/plugins/warmer.js +33 -0
- package/cli/commands/remove.d.ts +13 -0
- package/cli/commands/remove.js +39 -0
- package/{dist/cli → cli}/commands/secrets/get.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/get.js +0 -0
- package/{dist/cli → cli}/commands/secrets/list.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/list.js +5 -5
- package/{dist/cli → cli}/commands/secrets/remove.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/remove.js +0 -0
- package/{dist/cli → cli}/commands/secrets/secrets.d.ts +0 -0
- package/{dist/cli → cli}/commands/secrets/secrets.js +0 -0
- package/{dist/cli → cli}/commands/secrets/set.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/set.js +13 -11
- package/{dist/cli → cli}/commands/update.d.ts +2 -0
- package/{dist/cli → cli}/commands/update.js +17 -21
- package/cli/local/router.d.ts +42 -0
- package/cli/local/router.js +43 -0
- package/cli/local/server.d.ts +20 -0
- package/cli/local/server.js +212 -0
- package/cli/program.d.ts +9 -0
- package/{dist/cli → cli}/program.js +6 -1
- package/{dist/cli → cli}/spinner.d.ts +0 -0
- package/{dist/cli → cli}/spinner.js +0 -0
- package/cli/sst.d.ts +2 -0
- package/{dist/cli → cli}/sst.js +27 -16
- package/cli/telemetry/environment.d.ts +15 -0
- package/cli/telemetry/environment.js +27 -0
- package/cli/telemetry/post-payload.d.ts +1 -0
- package/cli/telemetry/post-payload.js +18 -0
- package/cli/telemetry/project-id.d.ts +2 -0
- package/cli/telemetry/project-id.js +47 -0
- package/cli/telemetry/telemetry.d.ts +4 -0
- package/cli/telemetry/telemetry.js +90 -0
- package/cli/ui/deploy.d.ts +8 -0
- package/{dist/cli → cli}/ui/deploy.js +39 -1
- package/{dist/config.d.ts → config.d.ts} +0 -0
- package/{dist/config.js → config.js} +16 -4
- package/{dist/constructs → constructs}/Api.d.ts +98 -12
- package/{dist/constructs → constructs}/Api.js +93 -7
- package/{dist/constructs → constructs}/ApiGatewayV1Api.d.ts +0 -0
- package/{dist/constructs → constructs}/ApiGatewayV1Api.js +10 -5
- package/{dist/constructs → constructs}/App.d.ts +4 -26
- package/{dist/constructs → constructs}/App.js +119 -99
- package/{dist/constructs → constructs}/AppSyncApi.d.ts +3 -3
- package/{dist/constructs → constructs}/AppSyncApi.js +27 -20
- package/constructs/AstroSite.d.ts +25 -0
- package/constructs/AstroSite.js +111 -0
- package/constructs/AstroSite.tsdoc.d.ts +2 -0
- package/constructs/AstroSite.tsdoc.js +2 -0
- package/{dist/constructs → constructs}/Auth.d.ts +1 -1
- package/{dist/constructs → constructs}/Auth.js +6 -4
- package/{dist/constructs → constructs}/BaseSite.d.ts +0 -0
- package/{dist/constructs → constructs}/BaseSite.js +0 -0
- package/{dist/constructs → constructs}/Bucket.d.ts +0 -0
- package/{dist/constructs → constructs}/Bucket.js +6 -3
- package/{dist/constructs → constructs}/Cognito.d.ts +0 -0
- package/{dist/constructs → constructs}/Cognito.js +4 -1
- package/{dist/constructs → constructs}/Config.d.ts +0 -0
- package/{dist/constructs → constructs}/Config.js +0 -0
- package/{dist/constructs → constructs}/Construct.d.ts +0 -0
- package/{dist/constructs → constructs}/Construct.js +0 -0
- package/{dist/constructs → constructs}/Cron.d.ts +0 -0
- package/{dist/constructs → constructs}/Cron.js +7 -0
- package/{dist/constructs → constructs}/DebugApp.d.ts +2 -2
- package/{dist/constructs → constructs}/DebugApp.js +16 -0
- package/{dist/constructs → constructs}/DebugStack.d.ts +0 -0
- package/{dist/constructs → constructs}/DebugStack.js +4 -0
- package/{dist/constructs → constructs}/EdgeFunction.d.ts +1 -0
- package/{dist/constructs → constructs}/EdgeFunction.js +27 -22
- package/{dist/constructs → constructs}/EventBus.d.ts +0 -0
- package/{dist/constructs → constructs}/EventBus.js +7 -4
- package/{dist/constructs → constructs}/Function.d.ts +73 -174
- package/{dist/constructs → constructs}/Function.js +43 -83
- package/{dist/constructs → constructs}/FunctionalStack.d.ts +0 -0
- package/{dist/constructs → constructs}/FunctionalStack.js +5 -5
- package/{dist/constructs → constructs}/GraphQLApi.d.ts +11 -1
- package/{dist/constructs → constructs}/GraphQLApi.js +3 -0
- package/{dist/constructs → constructs}/Job.d.ts +0 -14
- package/{dist/constructs → constructs}/Job.js +50 -46
- package/{dist/constructs → constructs}/KinesisStream.d.ts +0 -0
- package/{dist/constructs → constructs}/KinesisStream.js +6 -3
- package/{dist/constructs → constructs}/Metadata.d.ts +1 -1
- package/{dist/constructs → constructs}/Metadata.js +0 -0
- package/constructs/NextjsSite.d.ts +33 -0
- package/constructs/NextjsSite.js +285 -0
- package/{dist/constructs → constructs}/Parameter.d.ts +0 -0
- package/{dist/constructs → constructs}/Parameter.js +3 -0
- package/{dist/constructs → constructs}/Queue.d.ts +0 -0
- package/{dist/constructs → constructs}/Queue.js +19 -12
- package/{dist/constructs → constructs}/RDS.d.ts +0 -0
- package/{dist/constructs → constructs}/RDS.js +26 -19
- package/{dist/constructs → constructs}/ReactStaticSite.d.ts +0 -0
- package/{dist/constructs → constructs}/ReactStaticSite.js +1 -1
- package/constructs/RemixSite.d.ts +28 -0
- package/constructs/RemixSite.js +150 -0
- package/constructs/RemixSite.tsdoc.d.ts +2 -0
- package/constructs/RemixSite.tsdoc.js +2 -0
- package/{dist/constructs → constructs}/Script/cfn-response.d.ts +0 -0
- package/{dist/constructs → constructs}/Script/cfn-response.js +0 -0
- package/{dist/constructs → constructs}/Script/index.d.ts +0 -0
- package/{dist/constructs → constructs}/Script/index.js +0 -0
- package/{dist/constructs → constructs}/Script/outbound.d.ts +1 -1
- package/{dist/constructs → constructs}/Script/outbound.js +0 -0
- package/{dist/constructs → constructs}/Script/util.d.ts +0 -0
- package/{dist/constructs → constructs}/Script/util.js +0 -0
- package/{dist/constructs → constructs}/Script.d.ts +0 -0
- package/{dist/constructs → constructs}/Script.js +13 -0
- package/{dist/constructs → constructs}/Secret.d.ts +0 -0
- package/{dist/constructs → constructs}/Secret.js +2 -0
- package/constructs/SolidStartSite.d.ts +24 -0
- package/constructs/SolidStartSite.js +103 -0
- package/constructs/SolidStartSite.tsdoc.d.ts +2 -0
- package/constructs/SolidStartSite.tsdoc.js +2 -0
- package/{dist/constructs/RemixSite.d.ts → constructs/SsrSite.d.ts} +69 -107
- package/{dist/constructs/RemixSite.js → constructs/SsrSite.js} +243 -446
- package/{dist/constructs → constructs}/Stack.d.ts +1 -1
- package/{dist/constructs → constructs}/Stack.js +19 -4
- package/{dist/constructs → constructs}/StaticSite.d.ts +44 -17
- package/{dist/constructs → constructs}/StaticSite.js +121 -72
- package/{dist/constructs → constructs}/Table.d.ts +0 -0
- package/{dist/constructs → constructs}/Table.js +9 -3
- package/{dist/constructs → constructs}/Topic.d.ts +0 -0
- package/{dist/constructs → constructs}/Topic.js +6 -3
- package/{dist/constructs → constructs}/ViteStaticSite.d.ts +0 -0
- package/{dist/constructs → constructs}/ViteStaticSite.js +2 -2
- package/{dist/constructs → constructs}/WebSocketApi.d.ts +0 -0
- package/{dist/constructs → constructs}/WebSocketApi.js +9 -4
- package/{dist/constructs → constructs}/context.d.ts +1 -1
- package/{dist/constructs → constructs}/context.js +0 -0
- package/{dist/constructs → constructs}/deferred_task.d.ts +0 -0
- package/{dist/constructs → constructs}/deferred_task.js +4 -2
- package/{dist/constructs → constructs/deprecated}/NextjsSite.d.ts +12 -8
- package/{dist/constructs → constructs/deprecated}/NextjsSite.js +112 -89
- package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.d.ts +0 -0
- package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.js +3 -3
- package/constructs/deprecated/index.d.ts +1 -0
- package/constructs/deprecated/index.js +1 -0
- package/{dist/constructs → constructs}/index.d.ts +3 -2
- package/{dist/constructs → constructs}/index.js +2 -0
- package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.js +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.js +4 -4
- package/{dist/constructs → constructs}/util/apiGatewayV2Cors.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2Cors.js +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2Domain.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2Domain.js +0 -0
- package/{dist/constructs → constructs}/util/appSyncApiDomain.d.ts +1 -1
- package/{dist/constructs → constructs}/util/appSyncApiDomain.js +15 -9
- package/{dist/constructs → constructs}/util/builder.d.ts +0 -0
- package/{dist/constructs → constructs}/util/builder.js +0 -0
- package/{dist/constructs → constructs}/util/duration.d.ts +0 -0
- package/{dist/constructs → constructs}/util/duration.js +0 -0
- package/{dist/constructs → constructs}/util/functionBinding.d.ts +0 -0
- package/{dist/constructs → constructs}/util/functionBinding.js +0 -0
- package/{dist/constructs → constructs}/util/functionUrlCors.d.ts +0 -0
- package/{dist/constructs → constructs}/util/functionUrlCors.js +0 -0
- package/{dist/constructs → constructs}/util/permission.d.ts +0 -0
- package/{dist/constructs → constructs}/util/permission.js +32 -16
- package/{dist/constructs → constructs}/util/python/bundling.d.ts +0 -0
- package/{dist/constructs → constructs}/util/python/bundling.js +0 -0
- package/{dist/constructs → constructs}/util/size.d.ts +0 -0
- package/{dist/constructs → constructs}/util/size.js +0 -0
- package/{dist/constructs → constructs}/util/warning.d.ts +0 -0
- package/{dist/constructs → constructs}/util/warning.js +0 -0
- package/{dist/context → context}/context.d.ts +1 -1
- package/{dist/context → context}/context.js +3 -4
- package/{dist/context → context}/handler.d.ts +0 -0
- package/{dist/context → context}/handler.js +1 -1
- package/{dist/context → context}/index.d.ts +0 -0
- package/{dist/context → context}/index.js +0 -0
- package/{dist/credentials.d.ts → credentials.d.ts} +3 -1
- package/{dist/credentials.js → credentials.js} +11 -3
- package/{dist/error.d.ts → error.d.ts} +0 -0
- package/{dist/error.js → error.js} +0 -0
- package/{dist/iot.d.ts → iot.d.ts} +0 -0
- package/{dist/iot.js → iot.js} +3 -0
- package/logger.d.ts +3 -0
- package/{dist/logger.js → logger.js} +12 -8
- package/node/api/index.d.ts +42 -0
- package/node/api/index.js +88 -0
- package/node/auth/adapter/adapter.d.ts +3 -0
- package/node/auth/adapter/adapter.js +3 -0
- package/node/auth/adapter/facebook.d.ts +2 -0
- package/node/auth/adapter/facebook.js +26 -0
- package/node/auth/adapter/github.d.ts +2 -0
- package/node/auth/adapter/github.js +21 -0
- package/node/auth/adapter/google.d.ts +9 -0
- package/node/auth/adapter/google.js +18 -0
- package/node/auth/adapter/link.d.ts +8 -0
- package/node/auth/adapter/link.js +39 -0
- package/node/auth/adapter/oauth.d.ts +25 -0
- package/node/auth/adapter/oauth.js +52 -0
- package/node/auth/adapter/oidc.d.ts +17 -0
- package/node/auth/adapter/oidc.js +50 -0
- package/node/auth/adapter/twitch.d.ts +2 -0
- package/node/auth/adapter/twitch.js +11 -0
- package/node/auth/auth.d.ts +24 -0
- package/node/auth/auth.js +118 -0
- package/node/auth/index.d.ts +10 -0
- package/node/auth/index.js +10 -0
- package/node/auth/session.d.ts +76 -0
- package/node/auth/session.js +109 -0
- package/node/bucket/index.d.ts +3 -0
- package/node/bucket/index.js +3 -0
- package/node/config/index.d.ts +13 -0
- package/node/config/index.js +88 -0
- package/node/event-bus/index.d.ts +3 -0
- package/node/event-bus/index.js +3 -0
- package/node/function/index.d.ts +3 -0
- package/node/function/index.js +3 -0
- package/node/graphql/index.d.ts +38 -0
- package/node/graphql/index.js +48 -0
- package/node/job/index.d.ts +34 -0
- package/node/job/index.js +51 -0
- package/node/kinesis-stream/index.d.ts +3 -0
- package/node/kinesis-stream/index.js +3 -0
- package/node/queue/index.d.ts +3 -0
- package/node/queue/index.js +3 -0
- package/node/rds/index.d.ts +3 -0
- package/node/rds/index.js +3 -0
- package/node/site/index.d.ts +15 -0
- package/node/site/index.js +64 -0
- package/node/table/index.d.ts +3 -0
- package/node/table/index.js +3 -0
- package/node/topic/index.d.ts +3 -0
- package/node/topic/index.js +3 -0
- package/node/util/index.d.ts +7 -0
- package/node/util/index.js +57 -0
- package/package.json +107 -40
- package/pothos.d.ts +8 -0
- package/pothos.js +156 -0
- package/runtime/handlers/dotnet.d.ts +1 -0
- package/runtime/handlers/dotnet.js +117 -0
- package/runtime/handlers/go.d.ts +1 -0
- package/runtime/handlers/go.js +105 -0
- package/runtime/handlers/java.d.ts +1 -0
- package/runtime/handlers/java.js +97 -0
- package/{dist/runtime → runtime/handlers}/node.d.ts +0 -0
- package/runtime/handlers/node.js +172 -0
- package/runtime/handlers/python.d.ts +1 -0
- package/runtime/handlers/python.js +89 -0
- package/{dist/runtime → runtime}/handlers.d.ts +30 -12
- package/runtime/handlers.js +117 -0
- package/{dist/runtime → runtime}/iot.d.ts +0 -0
- package/{dist/runtime → runtime}/iot.js +1 -1
- package/{dist/runtime → runtime}/runtime.d.ts +2 -0
- package/{dist/runtime → runtime}/runtime.js +0 -0
- package/{dist/runtime → runtime}/server.d.ts +0 -0
- package/{dist/runtime → runtime}/server.js +39 -3
- package/{dist/runtime → runtime}/workers.d.ts +1 -0
- package/{dist/runtime → runtime}/workers.js +12 -4
- package/{dist/cli/sst.d.ts → scrap.d.ts} +0 -0
- package/scrap.js +58 -0
- package/site-env.d.ts +13 -0
- package/site-env.js +47 -0
- package/sst.mjs +21848 -0
- package/{dist/stacks → stacks}/build.d.ts +0 -0
- package/{dist/stacks → stacks}/build.js +18 -9
- package/stacks/deploy.d.ts +8 -0
- package/stacks/deploy.js +105 -0
- package/stacks/index.d.ts +7 -0
- package/stacks/index.js +7 -0
- package/stacks/metadata.d.ts +9 -0
- package/{dist/stacks → stacks}/metadata.js +2 -14
- package/stacks/monitor.d.ts +27 -0
- package/stacks/monitor.js +111 -0
- package/stacks/remove.d.ts +8 -0
- package/stacks/remove.js +80 -0
- package/stacks/synth.d.ts +10 -0
- package/stacks/synth.js +77 -0
- package/support/astro-site-html-stub/index.html +99 -0
- package/support/base-site-archiver.cjs +12 -11
- package/support/base-site-archiver.mjs +20 -0
- package/support/bridge/bridge.mjs +59 -0
- package/{dist/support → support}/custom-resources/index.mjs +44209 -42781
- package/support/dotnet31-bootstrap/Program.cs +17 -0
- package/support/dotnet31-bootstrap/dotnet-bootstrap.csproj +12 -0
- package/support/dotnet31-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet31-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Text.Encodings.Web.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Text.Json.dll +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.deps.json +230 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.dll +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.pdb +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +9 -0
- package/support/dotnet6-bootstrap/Program.cs +17 -0
- package/support/dotnet6-bootstrap/dotnet-bootstrap.csproj +12 -0
- package/support/dotnet6-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet6-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +59 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.dll +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.pdb +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +12 -0
- package/support/edge-function/edge-lambda-version.mjs +3 -0
- package/support/edge-function/edge-lambda.mjs +3 -0
- package/support/edge-function/s3-bucket.mjs +3 -0
- package/{dist/support/base-site-custom-resource/cf-invalidate.py → support/edge-function-code-replacer/lambda-code-updater.py} +56 -30
- package/support/java-runtime/install.sh +25 -0
- package/support/java-runtime/pom.xml +39 -0
- package/support/java-runtime/release/aws-lambda-java-core-1.2.0.jar +0 -0
- package/support/java-runtime/release/aws-lambda-java-runtime-interface-client-1.1.0.jar +0 -0
- package/support/java-runtime/release/aws-lambda-java-serialization-1.0.0.jar +0 -0
- package/support/nextjs-site-html-stub/index.html +99 -0
- package/{dist/support → support}/nodejs-runtime/index.mjs +7822 -2771
- package/support/python-runtime/runtime.py +116 -0
- package/support/rds-migrator/index.mjs +28 -0
- package/support/remix-site-function/edge-server.js +158 -0
- package/support/remix-site-function/polyfill.js +24 -0
- package/support/remix-site-function/regional-server.js +162 -0
- package/support/remix-site-html-stub/index.html +99 -0
- package/support/sls-nextjs-site-build-helper/build.cjs +91 -0
- package/support/sls-nextjs-site-build-helper/index-wrapper.js +19 -0
- package/support/sls-nextjs-site-stub/index.html +99 -0
- package/support/solid-start-site-html-stub/index.html +99 -0
- package/support/ssr-site-function-stub/index.js +5 -0
- package/util/fs.d.ts +4 -0
- package/util/fs.js +46 -0
- package/util/module.d.ts +1 -0
- package/util/module.js +5 -0
- package/util/process.d.ts +2 -0
- package/util/process.js +3 -0
- package/{dist/watcher.d.ts → watcher.d.ts} +0 -0
- package/{dist/watcher.js → watcher.js} +1 -1
- package/.build/sst-debug.log +0 -10
- package/.turbo/turbo-build.log +0 -2
- package/CHANGELOG.md +0 -332
- package/analyze +0 -11090
- package/bin/sst.mjs +0 -3
- package/build.mjs +0 -116
- package/debug.log +0 -6
- package/dist/app.js +0 -92
- package/dist/bootstrap.js +0 -23
- package/dist/cli/commands/build.js +0 -8
- package/dist/cli/commands/deploy.js +0 -20
- package/dist/cli/commands/env.d.ts +0 -0
- package/dist/cli/commands/env.js +0 -1
- package/dist/cli/commands/scrap.d.ts +0 -5
- package/dist/cli/commands/scrap.js +0 -1
- package/dist/cli/commands/start.d.ts +0 -7
- package/dist/cli/commands/start.js +0 -136
- package/dist/cli/program.d.ts +0 -7
- package/dist/cli/ui/deploy.d.ts +0 -6
- package/dist/constructs/nextjs-site/custom-resource/cfn-response.d.ts +0 -19
- package/dist/constructs/nextjs-site/custom-resource/cfn-response.js +0 -94
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.js +0 -138
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda.js +0 -136
- package/dist/constructs/nextjs-site/custom-resource/s3-bucket.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/s3-bucket.js +0 -94
- package/dist/constructs/nextjs-site/custom-resource/util.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/util.js +0 -4
- package/dist/logger.d.ts +0 -9
- package/dist/runtime/handlers.js +0 -72
- package/dist/runtime/node.js +0 -99
- package/dist/sst.mjs +0 -164202
- package/dist/stacks/deploy.d.ts +0 -33
- package/dist/stacks/deploy.js +0 -168
- package/dist/stacks/index.d.ts +0 -21
- package/dist/stacks/index.js +0 -57
- package/dist/stacks/metadata.d.ts +0 -9
- package/dist/support/base-site-archiver.cjs +0 -115
- package/dist/support/base-site-custom-resource/s3-handler.py +0 -195
- package/dist/support/base-site-custom-resource/s3-upload.py +0 -91
- package/dist/support/bridge/bridge.mjs +0 -86
- package/dist/support/static-site-stub/index.html +0 -90
- package/src/app.ts +0 -140
- package/src/bootstrap.ts +0 -28
- package/src/bus.ts +0 -81
- package/src/cache.ts +0 -34
- package/src/cdk/cloudformation-deployments.ts +0 -730
- package/src/cdk/deploy-stack.ts +0 -1030
- package/src/cli/commands/bind.ts +0 -31
- package/src/cli/commands/build.ts +0 -16
- package/src/cli/commands/deploy.ts +0 -34
- package/src/cli/commands/env.ts +0 -0
- package/src/cli/commands/scrap.ts +0 -5
- package/src/cli/commands/secrets/get.ts +0 -50
- package/src/cli/commands/secrets/list.ts +0 -66
- package/src/cli/commands/secrets/remove.ts +0 -36
- package/src/cli/commands/secrets/secrets.ts +0 -17
- package/src/cli/commands/secrets/set.ts +0 -59
- package/src/cli/commands/start.tsx +0 -162
- package/src/cli/commands/update.ts +0 -100
- package/src/cli/program.ts +0 -22
- package/src/cli/spinner.ts +0 -14
- package/src/cli/sst.ts +0 -50
- package/src/cli/ui/deploy.tsx +0 -139
- package/src/config.ts +0 -226
- package/src/constructs/Api.ts +0 -1448
- package/src/constructs/ApiGatewayV1Api.ts +0 -1481
- package/src/constructs/App.ts +0 -744
- package/src/constructs/AppSyncApi.ts +0 -1045
- package/src/constructs/Auth.ts +0 -252
- package/src/constructs/BaseSite.ts +0 -146
- package/src/constructs/Bucket.ts +0 -670
- package/src/constructs/Cognito.ts +0 -708
- package/src/constructs/Config.ts +0 -4
- package/src/constructs/Construct.ts +0 -77
- package/src/constructs/Cron.ts +0 -235
- package/src/constructs/DebugApp.ts +0 -97
- package/src/constructs/DebugStack.ts +0 -182
- package/src/constructs/EdgeFunction.ts +0 -460
- package/src/constructs/EventBus.ts +0 -651
- package/src/constructs/Function.ts +0 -1329
- package/src/constructs/FunctionalStack.ts +0 -90
- package/src/constructs/GraphQLApi.ts +0 -140
- package/src/constructs/Job.ts +0 -557
- package/src/constructs/KinesisStream.ts +0 -388
- package/src/constructs/Metadata.ts +0 -75
- package/src/constructs/NextjsSite.ts +0 -1498
- package/src/constructs/Parameter.ts +0 -72
- package/src/constructs/Queue.ts +0 -360
- package/src/constructs/RDS.ts +0 -578
- package/src/constructs/ReactStaticSite.ts +0 -66
- package/src/constructs/RemixSite.ts +0 -1397
- package/src/constructs/Script/cfn-response.ts +0 -116
- package/src/constructs/Script/index.ts +0 -103
- package/src/constructs/Script/outbound.ts +0 -59
- package/src/constructs/Script/package.json +0 -3
- package/src/constructs/Script/util.ts +0 -19
- package/src/constructs/Script.ts +0 -270
- package/src/constructs/Secret.ts +0 -66
- package/src/constructs/Stack.ts +0 -319
- package/src/constructs/StaticSite.ts +0 -995
- package/src/constructs/Table.ts +0 -844
- package/src/constructs/Topic.ts +0 -486
- package/src/constructs/ViteStaticSite.ts +0 -99
- package/src/constructs/WebSocketApi.ts +0 -687
- package/src/constructs/context.ts +0 -12
- package/src/constructs/deferred_task.ts +0 -53
- package/src/constructs/descs.d.ts +0 -1
- package/src/constructs/index.ts +0 -39
- package/src/constructs/nextjs-site/cross-region-helper.ts +0 -189
- package/src/constructs/nextjs-site/custom-resource/cfn-response.ts +0 -146
- package/src/constructs/nextjs-site/custom-resource/edge-lambda-version.ts +0 -162
- package/src/constructs/nextjs-site/custom-resource/edge-lambda.ts +0 -167
- package/src/constructs/nextjs-site/custom-resource/s3-bucket.ts +0 -112
- package/src/constructs/nextjs-site/custom-resource/util.ts +0 -11
- package/src/constructs/util/apiGatewayV1AccessLog.ts +0 -106
- package/src/constructs/util/apiGatewayV2AccessLog.ts +0 -139
- package/src/constructs/util/apiGatewayV2Cors.ts +0 -94
- package/src/constructs/util/apiGatewayV2Domain.ts +0 -312
- package/src/constructs/util/appSyncApiDomain.ts +0 -204
- package/src/constructs/util/builder.ts +0 -17
- package/src/constructs/util/duration.ts +0 -27
- package/src/constructs/util/functionBinding.ts +0 -102
- package/src/constructs/util/functionUrlCors.ts +0 -96
- package/src/constructs/util/permission.ts +0 -299
- package/src/constructs/util/python/bundling.ts +0 -174
- package/src/constructs/util/size.ts +0 -13
- package/src/constructs/util/warning.ts +0 -20
- package/src/context/context.ts +0 -79
- package/src/context/handler.ts +0 -53
- package/src/context/index.ts +0 -2
- package/src/credentials.ts +0 -103
- package/src/error.ts +0 -5
- package/src/iot.ts +0 -105
- package/src/logger.ts +0 -35
- package/src/runtime/handlers.ts +0 -121
- package/src/runtime/iot.ts +0 -16
- package/src/runtime/node.ts +0 -111
- package/src/runtime/runtime.ts +0 -27
- package/src/runtime/server.ts +0 -149
- package/src/runtime/workers.ts +0 -96
- package/src/stacks/build.ts +0 -69
- package/src/stacks/deploy.ts +0 -232
- package/src/stacks/index.ts +0 -73
- package/src/stacks/metadata.ts +0 -125
- package/src/watcher.ts +0 -47
- package/sst.config.mjs +0 -6
- package/support/bridge/bridge.ts +0 -136
- package/support/bridge/build.mjs +0 -18
- package/support/custom-resources/auth-keys.ts +0 -113
- package/support/custom-resources/build.mjs +0 -18
- package/support/custom-resources/cfn-response.ts +0 -151
- package/support/custom-resources/index.ts +0 -18
- package/support/custom-resources/secrets-migration.ts +0 -82
- package/support/custom-resources/stack-metadata.ts +0 -75
- package/support/custom-resources/util.ts +0 -44
- package/support/nodejs-runtime/index.ts +0 -69
- package/support/tsconfig.json +0 -11
- package/tsconfig.json +0 -13
- package/yarn-error.log +0 -75
package/src/context/handler.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
APIGatewayProxyEventV2,
|
|
3
|
-
APIGatewayProxyStructuredResultV2,
|
|
4
|
-
Context as LambdaContext,
|
|
5
|
-
SQSBatchResponse,
|
|
6
|
-
SQSEvent
|
|
7
|
-
} from "aws-lambda";
|
|
8
|
-
import { Context } from "./context.js";
|
|
9
|
-
|
|
10
|
-
export interface Handlers {
|
|
11
|
-
api: {
|
|
12
|
-
event: APIGatewayProxyEventV2;
|
|
13
|
-
response: APIGatewayProxyStructuredResultV2;
|
|
14
|
-
};
|
|
15
|
-
sqs: {
|
|
16
|
-
event: SQSEvent;
|
|
17
|
-
response: SQSBatchResponse;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type HandlerTypes = keyof Handlers;
|
|
22
|
-
|
|
23
|
-
type Requests = {
|
|
24
|
-
[key in HandlerTypes]: {
|
|
25
|
-
type: key;
|
|
26
|
-
event: Handlers[key]["event"];
|
|
27
|
-
context: LambdaContext;
|
|
28
|
-
};
|
|
29
|
-
}[HandlerTypes];
|
|
30
|
-
|
|
31
|
-
const RequestContext = Context.create<Requests>();
|
|
32
|
-
|
|
33
|
-
export function useEvent<Type extends HandlerTypes>(type: Type) {
|
|
34
|
-
const ctx = RequestContext.use();
|
|
35
|
-
if (ctx.type !== type) throw new Error(`Expected ${type} event`);
|
|
36
|
-
return ctx.event as Handlers[Type]["event"];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function useLambdaContext() {
|
|
40
|
-
const ctx = RequestContext.use();
|
|
41
|
-
return ctx.context;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function Handler<
|
|
45
|
-
Type extends HandlerTypes,
|
|
46
|
-
Event = Handlers[Type]["event"],
|
|
47
|
-
Response = Handlers[Type]["response"]
|
|
48
|
-
>(type: Type, cb: (evt: Event, ctx: LambdaContext) => Promise<Response>) {
|
|
49
|
-
return function handler(event: Event, context: LambdaContext) {
|
|
50
|
-
RequestContext.provide({ type, event: event as any, context });
|
|
51
|
-
return cb(event, context);
|
|
52
|
-
};
|
|
53
|
-
}
|
package/src/context/index.ts
DELETED
package/src/credentials.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Context } from "@serverless-stack/node/context/index.js";
|
|
2
|
-
import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
|
|
3
|
-
import { Client } from "@aws-sdk/smithy-client";
|
|
4
|
-
import { RegionInputConfig } from "@aws-sdk/config-resolver";
|
|
5
|
-
import { RetryInputConfig } from "@aws-sdk/middleware-retry";
|
|
6
|
-
import { AwsAuthInputConfig } from "@aws-sdk/middleware-signing";
|
|
7
|
-
import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
|
|
8
|
-
import { Logger } from "./logger.js";
|
|
9
|
-
import { SdkProvider } from "aws-cdk/lib/api/aws-auth/sdk-provider.js";
|
|
10
|
-
import { StandardRetryStrategy } from "@aws-sdk/middleware-retry";
|
|
11
|
-
|
|
12
|
-
type Config = RegionInputConfig & RetryInputConfig & AwsAuthInputConfig;
|
|
13
|
-
|
|
14
|
-
export const useAWSCredentialsProvider = Context.memo(() => {
|
|
15
|
-
const project = useProject();
|
|
16
|
-
Logger.debug("Using AWS profile", project.profile);
|
|
17
|
-
const provider = fromNodeProviderChain({
|
|
18
|
-
profile: project.profile,
|
|
19
|
-
});
|
|
20
|
-
return provider;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const useAWSCredentials = () => {
|
|
24
|
-
const provider = useAWSCredentialsProvider();
|
|
25
|
-
return provider();
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const useSTSIdentity = Context.memo(async () => {
|
|
29
|
-
const sts = useAWSClient(STSClient);
|
|
30
|
-
const identity = await sts.send(new GetCallerIdentityCommand({}));
|
|
31
|
-
Logger.debug(
|
|
32
|
-
"Using identity",
|
|
33
|
-
"Account:",
|
|
34
|
-
identity.Account,
|
|
35
|
-
"User:",
|
|
36
|
-
identity.UserId
|
|
37
|
-
);
|
|
38
|
-
return identity;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const useClientCache = Context.memo(() => new Map<string, any>());
|
|
42
|
-
|
|
43
|
-
export function useAWSClient<C extends Client<any, any, any, any>>(
|
|
44
|
-
client: new (config: Config) => C,
|
|
45
|
-
force = false
|
|
46
|
-
) {
|
|
47
|
-
const cache = useClientCache();
|
|
48
|
-
const existing = cache.get(client.name);
|
|
49
|
-
if (existing && !force) return existing as C;
|
|
50
|
-
const [project, credentials] = [useProject(), useAWSCredentialsProvider()];
|
|
51
|
-
const result = new client({
|
|
52
|
-
region: project.region,
|
|
53
|
-
credentials: credentials,
|
|
54
|
-
retryStrategy: new StandardRetryStrategy(async () => 10000, {
|
|
55
|
-
delayDecider: (_, attempts) => {
|
|
56
|
-
return Math.min(1.5 ** attempts * 100, 5000);
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
cache.set(client.name, result);
|
|
61
|
-
Logger.debug("Created AWS client", client.name);
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
import aws from "aws-sdk";
|
|
66
|
-
import { useProject } from "./app.js";
|
|
67
|
-
const CredentialProviderChain = aws.CredentialProviderChain;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Do not use this. It is only used for AWS CDK compatibility.
|
|
71
|
-
*/
|
|
72
|
-
export const useAWSProvider = async () => {
|
|
73
|
-
Logger.debug("Loading v2 AWS SDK");
|
|
74
|
-
const project = useProject();
|
|
75
|
-
const creds = await useAWSCredentials();
|
|
76
|
-
const chain = new CredentialProviderChain([
|
|
77
|
-
() => ({
|
|
78
|
-
...creds,
|
|
79
|
-
get(cb) {
|
|
80
|
-
cb();
|
|
81
|
-
},
|
|
82
|
-
async getPromise() {},
|
|
83
|
-
needsRefresh() {
|
|
84
|
-
return false;
|
|
85
|
-
},
|
|
86
|
-
refresh(cb) {
|
|
87
|
-
cb();
|
|
88
|
-
},
|
|
89
|
-
async refreshPromise() {},
|
|
90
|
-
expired: false,
|
|
91
|
-
expireTime: creds.expiration!,
|
|
92
|
-
accessKeyId: creds.accessKeyId!,
|
|
93
|
-
sessionToken: creds.sessionToken!,
|
|
94
|
-
secretAccessKey: creds.secretAccessKey!,
|
|
95
|
-
}),
|
|
96
|
-
]);
|
|
97
|
-
const provider = new SdkProvider(chain, project.region!, {
|
|
98
|
-
maxRetries: 10000,
|
|
99
|
-
region: project.region,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return provider;
|
|
103
|
-
};
|
package/src/error.ts
DELETED
package/src/iot.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { IoTClient, DescribeEndpointCommand } from "@aws-sdk/client-iot";
|
|
2
|
-
import { Context } from "./context/context.js";
|
|
3
|
-
import { useAWSClient, useAWSCredentials } from "./credentials.js";
|
|
4
|
-
import { VisibleError } from "./error.js";
|
|
5
|
-
|
|
6
|
-
export const useIOTEndpoint = Context.memo(async () => {
|
|
7
|
-
const iot = useAWSClient(IoTClient);
|
|
8
|
-
Logger.debug("Getting IoT endpoint");
|
|
9
|
-
const response = await iot.send(
|
|
10
|
-
new DescribeEndpointCommand({
|
|
11
|
-
endpointType: "iot:Data-ATS",
|
|
12
|
-
})
|
|
13
|
-
);
|
|
14
|
-
Logger.debug("Using IoT endpoint:", response.endpointAddress);
|
|
15
|
-
|
|
16
|
-
if (!response.endpointAddress)
|
|
17
|
-
throw new VisibleError("IoT Endpoint address not found");
|
|
18
|
-
|
|
19
|
-
return response.endpointAddress;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
import iot from "aws-iot-device-sdk";
|
|
23
|
-
import { EventPayload, Events, EventTypes, useBus } from "./bus.js";
|
|
24
|
-
import { useProject } from "./app.js";
|
|
25
|
-
import { Logger } from "./logger.js";
|
|
26
|
-
|
|
27
|
-
interface Fragment {
|
|
28
|
-
id: string;
|
|
29
|
-
index: number;
|
|
30
|
-
count: number;
|
|
31
|
-
data: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const useIOT = Context.memo(async () => {
|
|
35
|
-
const bus = useBus();
|
|
36
|
-
|
|
37
|
-
const endpoint = await useIOTEndpoint();
|
|
38
|
-
const creds = await useAWSCredentials();
|
|
39
|
-
const project = useProject();
|
|
40
|
-
const device = new iot.device({
|
|
41
|
-
protocol: "wss",
|
|
42
|
-
host: endpoint,
|
|
43
|
-
accessKeyId: creds.accessKeyId,
|
|
44
|
-
secretKey: creds.secretAccessKey,
|
|
45
|
-
sessionToken: creds.sessionToken,
|
|
46
|
-
});
|
|
47
|
-
const PREFIX = `/sst/${project.name}/${project.stage}`;
|
|
48
|
-
device.subscribe(`${PREFIX}/events`);
|
|
49
|
-
|
|
50
|
-
const fragments = new Map<string, Map<number, Fragment>>();
|
|
51
|
-
|
|
52
|
-
device.on("message", (_topic, buffer: Buffer) => {
|
|
53
|
-
const fragment = JSON.parse(buffer.toString()) as Fragment;
|
|
54
|
-
let pending = fragments.get(fragment.id);
|
|
55
|
-
if (!pending) {
|
|
56
|
-
pending = new Map();
|
|
57
|
-
fragments.set(fragment.id, pending);
|
|
58
|
-
}
|
|
59
|
-
pending.set(fragment.index, fragment);
|
|
60
|
-
|
|
61
|
-
if (pending.size === fragment.count) {
|
|
62
|
-
const data = [...pending.values()]
|
|
63
|
-
.sort((a, b) => a.index - b.index)
|
|
64
|
-
.map((item) => item.data)
|
|
65
|
-
.join("");
|
|
66
|
-
fragments.delete(fragment.id);
|
|
67
|
-
const evt = JSON.parse(data) as EventPayload;
|
|
68
|
-
if (evt.sourceID === bus.sourceID) return;
|
|
69
|
-
bus.publish(evt.type, evt.properties);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
prefix: PREFIX,
|
|
75
|
-
publish<Type extends EventTypes>(
|
|
76
|
-
topic: string,
|
|
77
|
-
type: Type,
|
|
78
|
-
properties: Events[Type]
|
|
79
|
-
) {
|
|
80
|
-
const payload: EventPayload = {
|
|
81
|
-
type,
|
|
82
|
-
properties,
|
|
83
|
-
sourceID: bus.sourceID,
|
|
84
|
-
};
|
|
85
|
-
for (const fragment of encode(payload)) {
|
|
86
|
-
device.publish(topic, JSON.stringify(fragment), {
|
|
87
|
-
qos: 1,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
function encode(input: any) {
|
|
95
|
-
const json = JSON.stringify(input);
|
|
96
|
-
const parts = json.match(/.{1,100000}/g);
|
|
97
|
-
if (!parts) return [];
|
|
98
|
-
const id = Math.random().toString();
|
|
99
|
-
return parts.map((part, index) => ({
|
|
100
|
-
id,
|
|
101
|
-
index,
|
|
102
|
-
count: parts?.length,
|
|
103
|
-
data: part,
|
|
104
|
-
}));
|
|
105
|
-
}
|
package/src/logger.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import chalk, { ChalkInstance } from "chalk";
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
type Colors = {
|
|
6
|
-
[key in keyof typeof chalk]: typeof chalk[key] extends ChalkInstance
|
|
7
|
-
? key
|
|
8
|
-
: never;
|
|
9
|
-
}[keyof typeof chalk];
|
|
10
|
-
|
|
11
|
-
let previous = new Date();
|
|
12
|
-
|
|
13
|
-
const filePath = path.join("debug.log");
|
|
14
|
-
const file = await fs.open(filePath, "w");
|
|
15
|
-
|
|
16
|
-
export const Logger = {
|
|
17
|
-
ui<T extends Colors>(color: T, ...lines: string[]) {
|
|
18
|
-
console.log(chalk[color](lines.join("\n")));
|
|
19
|
-
},
|
|
20
|
-
async debug(...parts: any[]) {
|
|
21
|
-
const now = new Date();
|
|
22
|
-
const diff = now.getTime() - previous.getTime();
|
|
23
|
-
previous = now;
|
|
24
|
-
const line = [
|
|
25
|
-
new Date().toISOString(),
|
|
26
|
-
`+${diff}ms`.padStart(8),
|
|
27
|
-
"[debug]",
|
|
28
|
-
...parts.map((x) => {
|
|
29
|
-
if (typeof x === "string") return x;
|
|
30
|
-
return JSON.stringify(x);
|
|
31
|
-
}),
|
|
32
|
-
];
|
|
33
|
-
file.write(line.join(" ") + "\n");
|
|
34
|
-
},
|
|
35
|
-
};
|
package/src/runtime/handlers.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Context } from "@serverless-stack/node/context/context.js";
|
|
2
|
-
import { Logger } from "../logger.js";
|
|
3
|
-
import { useFunctions, useMetadata } from "../stacks/metadata.js";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import fs from "fs/promises";
|
|
6
|
-
import { useWatcher } from "../watcher.js";
|
|
7
|
-
import { useBus } from "../bus.js";
|
|
8
|
-
import { useProject } from "../app.js";
|
|
9
|
-
|
|
10
|
-
declare module "../bus.js" {
|
|
11
|
-
export interface Events {
|
|
12
|
-
"function.built": {
|
|
13
|
-
functionID: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface BuildInput {
|
|
19
|
-
functionID: string;
|
|
20
|
-
mode: "deploy" | "start";
|
|
21
|
-
srcPath: string;
|
|
22
|
-
handler: string;
|
|
23
|
-
out: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface StartWorkerInput {
|
|
27
|
-
url: string;
|
|
28
|
-
workerID: string;
|
|
29
|
-
environment: Record<string, string>;
|
|
30
|
-
out: string;
|
|
31
|
-
handler: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface ShouldBuildInput {
|
|
35
|
-
file: string;
|
|
36
|
-
functionID: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface RuntimeHandler {
|
|
40
|
-
startWorker: (worker: StartWorkerInput) => Promise<void>;
|
|
41
|
-
stopWorker: (workerID: string) => Promise<void>;
|
|
42
|
-
shouldBuild: (input: ShouldBuildInput) => boolean;
|
|
43
|
-
canHandle: (runtime: string) => boolean;
|
|
44
|
-
build: (input: BuildInput) => Promise<string>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const useRuntimeHandlers = Context.memo(() => {
|
|
48
|
-
const handlers: RuntimeHandler[] = [];
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
register: (handler: RuntimeHandler) => {
|
|
52
|
-
handlers.push(handler);
|
|
53
|
-
},
|
|
54
|
-
for: (runtime: string) => {
|
|
55
|
-
return handlers.find((x) => x.canHandle(runtime));
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
interface Artifact {
|
|
61
|
-
out: string;
|
|
62
|
-
handler: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const useFunctionBuilder = Context.memo(() => {
|
|
66
|
-
const artifacts = new Map<string, Artifact>();
|
|
67
|
-
const handlers = useRuntimeHandlers();
|
|
68
|
-
const bus = useBus();
|
|
69
|
-
const project = useProject();
|
|
70
|
-
const artifactPath = path.join(project.paths.out, "artifacts");
|
|
71
|
-
|
|
72
|
-
const result = {
|
|
73
|
-
subscribe: bus.forward("function.built"),
|
|
74
|
-
artifact: (functionID: string) => {
|
|
75
|
-
if (artifacts.has(functionID)) return artifacts.get(functionID)!;
|
|
76
|
-
return result.build(functionID);
|
|
77
|
-
},
|
|
78
|
-
build: async (functionID: string) => {
|
|
79
|
-
Logger.debug("Building function", functionID);
|
|
80
|
-
const handler = handlers.for("node");
|
|
81
|
-
const functions = await useFunctions();
|
|
82
|
-
const func = functions[functionID];
|
|
83
|
-
const out = path.join(artifactPath, functionID);
|
|
84
|
-
await fs.rm(out, { recursive: true });
|
|
85
|
-
await fs.mkdir(out, { recursive: true });
|
|
86
|
-
const result = await handler!.build({
|
|
87
|
-
functionID,
|
|
88
|
-
out,
|
|
89
|
-
mode: "start",
|
|
90
|
-
handler: func.data.handler,
|
|
91
|
-
srcPath: func.data.srcPath,
|
|
92
|
-
});
|
|
93
|
-
artifacts.set(functionID, {
|
|
94
|
-
out,
|
|
95
|
-
handler: result,
|
|
96
|
-
});
|
|
97
|
-
bus.publish("function.built", { functionID });
|
|
98
|
-
return artifacts.get(functionID)!;
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const watcher = useWatcher();
|
|
103
|
-
watcher.subscribe("file.changed", async (evt) => {
|
|
104
|
-
const functions = await useFunctions();
|
|
105
|
-
for (const [_, func] of Object.entries(functions)) {
|
|
106
|
-
const functionID = func.data.localId;
|
|
107
|
-
const handler = handlers.for("node");
|
|
108
|
-
if (
|
|
109
|
-
!handler?.shouldBuild({
|
|
110
|
-
functionID,
|
|
111
|
-
file: evt.properties.file,
|
|
112
|
-
})
|
|
113
|
-
)
|
|
114
|
-
continue;
|
|
115
|
-
await result.build(functionID);
|
|
116
|
-
Logger.debug("Rebuilt function", functionID);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return result;
|
|
121
|
-
});
|
package/src/runtime/iot.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Context } from "@serverless-stack/node/context/context.js";
|
|
2
|
-
import { useBus } from "../bus.js";
|
|
3
|
-
import { useIOT } from "../iot.js";
|
|
4
|
-
|
|
5
|
-
export const useIOTBridge = Context.memo(async () => {
|
|
6
|
-
const bus = useBus();
|
|
7
|
-
const iot = await useIOT();
|
|
8
|
-
const topic = `${iot.prefix}/events`;
|
|
9
|
-
|
|
10
|
-
bus.subscribe("function.success", async (evt) => {
|
|
11
|
-
iot.publish(topic, "function.success", evt.properties);
|
|
12
|
-
});
|
|
13
|
-
bus.subscribe("function.error", async (evt) => {
|
|
14
|
-
iot.publish(topic, "function.error", evt.properties);
|
|
15
|
-
});
|
|
16
|
-
});
|
package/src/runtime/node.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Context } from "@serverless-stack/node/context/context.js";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import { useProject } from "../app.js";
|
|
5
|
-
import esbuild from "esbuild";
|
|
6
|
-
import url from "url";
|
|
7
|
-
import { Worker } from "worker_threads";
|
|
8
|
-
import { useRuntimeHandlers } from "./handlers.js";
|
|
9
|
-
import { useRuntimeWorkers } from "./workers.js";
|
|
10
|
-
|
|
11
|
-
export const useNodeHandler = Context.memo(() => {
|
|
12
|
-
const handlers = useRuntimeHandlers();
|
|
13
|
-
const workers = useRuntimeWorkers();
|
|
14
|
-
const cache: Record<string, esbuild.BuildResult> = {};
|
|
15
|
-
const project = useProject();
|
|
16
|
-
const threads = new Map<string, Worker>();
|
|
17
|
-
|
|
18
|
-
handlers.register({
|
|
19
|
-
shouldBuild: (input) => {
|
|
20
|
-
const result = cache[input.functionID];
|
|
21
|
-
if (!result) return false;
|
|
22
|
-
const relative = path.relative(project.paths.root, input.file);
|
|
23
|
-
return Boolean(result.metafile?.inputs[relative]);
|
|
24
|
-
},
|
|
25
|
-
startWorker: async (input) => {
|
|
26
|
-
new Promise(async () => {
|
|
27
|
-
const worker = new Worker(
|
|
28
|
-
url.fileURLToPath(
|
|
29
|
-
new URL("./support/nodejs-runtime/index.mjs", import.meta.url)
|
|
30
|
-
),
|
|
31
|
-
{
|
|
32
|
-
env: input.environment,
|
|
33
|
-
workerData: input,
|
|
34
|
-
stdout: true,
|
|
35
|
-
stderr: true,
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
worker.stdout.on("data", (data: Buffer) => {
|
|
39
|
-
workers.stdout(input.workerID, data.toString());
|
|
40
|
-
});
|
|
41
|
-
worker.on("exit", () => workers.exited(input.workerID));
|
|
42
|
-
threads.set(input.workerID, worker);
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
canHandle: () => true,
|
|
46
|
-
stopWorker: async (workerID) => {
|
|
47
|
-
const worker = threads.get(workerID);
|
|
48
|
-
await worker?.terminate();
|
|
49
|
-
},
|
|
50
|
-
build: async (input) => {
|
|
51
|
-
const exists = cache[input.functionID];
|
|
52
|
-
const dir = path.dirname(input.handler);
|
|
53
|
-
const ext = path.extname(input.handler);
|
|
54
|
-
const base = path.basename(input.handler).split(".")[0];
|
|
55
|
-
const root = project.paths.root;
|
|
56
|
-
const file = [
|
|
57
|
-
".ts",
|
|
58
|
-
".tsx",
|
|
59
|
-
".mts",
|
|
60
|
-
".cts",
|
|
61
|
-
".js",
|
|
62
|
-
".jsx",
|
|
63
|
-
".mjs",
|
|
64
|
-
".cjs",
|
|
65
|
-
]
|
|
66
|
-
.map((ext) => path.join(dir, base + ext))
|
|
67
|
-
.find((file) => {
|
|
68
|
-
const p = path.join(input.srcPath, file);
|
|
69
|
-
return fs.existsSync(p);
|
|
70
|
-
})!;
|
|
71
|
-
const target = path.join(
|
|
72
|
-
input.out,
|
|
73
|
-
path
|
|
74
|
-
.relative(root, path.resolve(input.srcPath))
|
|
75
|
-
.split(path.sep)
|
|
76
|
-
.filter((x) => x !== "node_modules")
|
|
77
|
-
.join(path.sep),
|
|
78
|
-
path.dirname(file),
|
|
79
|
-
base + ".mjs"
|
|
80
|
-
);
|
|
81
|
-
const handler = path.relative(input.out, target.replace(".mjs", ext));
|
|
82
|
-
if (exists?.rebuild) {
|
|
83
|
-
const result = await exists.rebuild();
|
|
84
|
-
cache[input.functionID] = result;
|
|
85
|
-
return handler;
|
|
86
|
-
}
|
|
87
|
-
if (!file)
|
|
88
|
-
throw new Error(`Cannot find a handler file for "${input.handler}"`);
|
|
89
|
-
|
|
90
|
-
const result = await esbuild.build({
|
|
91
|
-
entryPoints: [path.join(input.srcPath, file)],
|
|
92
|
-
platform: "node",
|
|
93
|
-
format: "esm",
|
|
94
|
-
target: "esnext",
|
|
95
|
-
mainFields: ["module", "main"],
|
|
96
|
-
external: ["mjml"],
|
|
97
|
-
bundle: true,
|
|
98
|
-
metafile: true,
|
|
99
|
-
banner: {
|
|
100
|
-
js: [
|
|
101
|
-
`import { createRequire as topLevelCreateRequire } from 'module';`,
|
|
102
|
-
`const require = topLevelCreateRequire(import.meta.url);`,
|
|
103
|
-
].join("\n"),
|
|
104
|
-
},
|
|
105
|
-
outfile: target,
|
|
106
|
-
});
|
|
107
|
-
cache[input.functionID] = result;
|
|
108
|
-
return handler;
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
});
|
package/src/runtime/runtime.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import "../bus.js";
|
|
2
|
-
|
|
3
|
-
declare module "../bus.js" {
|
|
4
|
-
export interface Events {
|
|
5
|
-
"function.invoked": {
|
|
6
|
-
workerID: string;
|
|
7
|
-
functionID: string;
|
|
8
|
-
requestID: string;
|
|
9
|
-
env: Record<string, any>;
|
|
10
|
-
event: any;
|
|
11
|
-
context: any;
|
|
12
|
-
deadline: number;
|
|
13
|
-
};
|
|
14
|
-
"function.success": {
|
|
15
|
-
workerID: string;
|
|
16
|
-
functionID: string;
|
|
17
|
-
body: any;
|
|
18
|
-
};
|
|
19
|
-
"function.error": {
|
|
20
|
-
workerID: string;
|
|
21
|
-
functionID: string;
|
|
22
|
-
errorType: string;
|
|
23
|
-
errorMessage: string;
|
|
24
|
-
trace: string[];
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|