diff --git a/.agents/skills/document-component/SKILL.md b/.agents/skills/document-component/SKILL.md deleted file mode 100644 index bae55d7774..0000000000 --- a/.agents/skills/document-component/SKILL.md +++ /dev/null @@ -1,22 +0,0 @@ -# Document Component - -Steps to add a new component to the SST docs. - -1. Register in docs generator - - Add the component `.ts` path to `entryPoints` in `www/generate.ts` - -2. Add matching public getters - - Ensure every property returned by `getSSTLink()` has a corresponding public getter on the class - - The generator crashes otherwise because `renderLinks()` looks for a getter with the same name - -3. Analyze docs for relevant places to link the component - - Search existing guides (e.g. `cloudflare.mdx`) and component overviews for lists of related components - - Add the new component link where appropriate - -4. Add to Astro sidebar - - Add the generated doc slug to the appropriate section in `www/astro.config.mjs` - - Follow the existing visual ordering: components are sorted from shortest to longest name (least to most characters) - -5. Generate docs - - Run `bun run docs:generate` - diff --git a/.air.toml b/.air.toml deleted file mode 100644 index f76accf02d..0000000000 --- a/.air.toml +++ /dev/null @@ -1,51 +0,0 @@ -root = "." -testdata_dir = "testdata" -tmp_dir = "tmp" - -[build] - args_bin = [] - bin = "./dist/sst" - cmd = "go build -o ./dist/sst ./cmd/sst" - delay = 1000 - exclude_dir = ["assets", "tmp", "vendor", "testdata", "node_modules", "examples"] - exclude_file = [] - exclude_regex = ["_test.go"] - exclude_unchanged = false - follow_symlink = false - full_bin = "" - include_dir = [] - include_ext = ["go", "tpl", "tmpl", "html"] - include_file = [] - kill_delay = "0s" - log = "build-errors.log" - poll = false - poll_interval = 0 - post_cmd = [] - pre_cmd = [] - rerun = false - rerun_delay = 500 - send_interrupt = false - stop_on_error = false - -[color] - app = "" - build = "yellow" - main = "magenta" - runner = "green" - watcher = "cyan" - -[log] - main_only = false - time = false - -[misc] - clean_on_exit = false - -[proxy] - app_port = 0 - enabled = false - proxy_port = 0 - -[screen] - clear_on_rebuild = false - keep_scroll = true diff --git a/.changeset/aggregate.mjs b/.changeset/aggregate.mjs new file mode 100644 index 0000000000..9c312e356b --- /dev/null +++ b/.changeset/aggregate.mjs @@ -0,0 +1,66 @@ +import fs from "node:fs/promises"; +import path from "node:path"; +import { execSync } from "node:child_process"; + +const THANKLESS_COMMITTERS = ["thdxr", "fwang", "jayair"]; + +const { version } = JSON.parse( + await fs.readFile("./packages/sst/package.json") +); + +const changesets = JSON.parse(await fs.readFile(".changeset/config.json")); +const packages = changesets.fixed[0]; + +const changes = new Set(); +for (const pkg of packages) { + const changelog = path.join( + "packages", + pkg.split("/").at(-1), + "CHANGELOG.md" + ); + const lines = (await fs.readFile(changelog)).toString().split("\n"); + let start = false; + for (let line of lines) { + if (!start) { + if (line === `## ${version}`) { + start = true; + continue; + } + } + + if (start) { + if (line.startsWith("-") || line.startsWith("*")) { + if (line.includes("Updated dependencies")) continue; + if (line.includes("@serverless-stack/")) continue; + + for (const user of THANKLESS_COMMITTERS) { + line = line.replace( + `Thanks [@${user}](https://github.com/${user})! `, + "" + ); + } + changes.add(line); + continue; + } + + if (line.startsWith("## ")) break; + } + } +} + +const notes = [ + "#### Changes", + ...changes, + `---`, + `Update using:`, + "``` sh", + "$ npx sst update " + version, + "$ yarn sst update " + version, + "```", +]; +console.log(notes.join("\n")); +console.log(`::set-output name=notes::${notes.join("%0A")}`); +console.log(`::set-output name=version::v${version}`); + +execSync(`git tag v${version}`); +execSync(`git push origin --tags`); diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000000..15c2e10228 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json", + "changelog": [ + "@changesets/changelog-github", + { "repo": "serverless-stack/sst" } + ], + "commit": false, + "fixed": [ + [ + "@serverless-stack/console", + "create-sst", + "sst", + "astro-sst", + "svelte-kit-sst", + "solid-start-sst" + ] + ], + "linked": [], + "access": "public", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.changeset/config.json.bak b/.changeset/config.json.bak new file mode 100644 index 0000000000..7d74ade5e3 --- /dev/null +++ b/.changeset/config.json.bak @@ -0,0 +1,25 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json", + "changelog": [ + "@changesets/changelog-github", + { "repo": "serverless-stack/sst" } + ], + "commit": false, + "fixed": [ + [ + "@serverless-stack/resources", + "@serverless-stack/cli", + "@serverless-stack/cli2", + "@serverless-stack/core", + "@serverless-stack/console", + "create-sst", + "@serverless-stack/node", + "@serverless-stack/static-site-env" + ] + ], + "linked": [], + "access": "restricted", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.changeset/release b/.changeset/release new file mode 100755 index 0000000000..7696069cd5 --- /dev/null +++ b/.changeset/release @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +pnpm build +cp packages/sst/package.json packages/sst/dist/package.json +cp packages/sst/README.md packages/sst/dist/README.md +sed -i.bak -e '2,5d' packages/sst/dist/package.json +pnpm changeset publish diff --git a/.changeset/snapshot b/.changeset/snapshot new file mode 100755 index 0000000000..1a5979ab6d --- /dev/null +++ b/.changeset/snapshot @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +pnpm build +sed -i.bak -e '3,6d' .changeset/config.json +pnpm changeset version --snapshot +cp packages/sst/package.json packages/sst/dist/package.json +sed -i.bak -e '2,5d' packages/sst/dist/package.json +pnpm changeset publish --no-git-tag --tag=snapshot +cp .changeset/config.json.bak .changeset/config.json +git checkout '**/package.json' '**/CHANGELOG.md' '.changeset' diff --git a/.changeset/version b/.changeset/version new file mode 100755 index 0000000000..f7da6542c7 --- /dev/null +++ b/.changeset/version @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +pnpm changeset version diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..7291274bfa --- /dev/null +++ b/.eslintignore @@ -0,0 +1,46 @@ +# Don't ever lint node_modules +node_modules + +# Don't lint build output (make sure it's set to your correct build folder name) +dist + +# Don't lint nyc coverage output +coverage + +# Don't lint cdk.out +cdk.out + +# Don't lint build outputs in test +/packages/cli/test/*/.build/** +/packages/cli/test/*/cdk.out/** + +# Don't lint templates +/packages/create-serverless-stack/templates/** + +# Don't lint browser console +/packages/cli/assets/console/** + +# Don't lint eslint tests that need to fail +/packages/cli/test/eslint-cdk-js/** +/packages/cli/test/eslint-cdk-ts/** +/packages/cli/test/eslint-lambda-js/** +/packages/cli/test/eslint-lambda-ts/** +/packages/cli/test/eslint-disabled-js/** +/packages/cli/test/eslint-disabled-ts/** +/packages/cli/test/eslint-ignore-rule-js/** +/packages/cli/test/eslint-ignore-rule-ts/** +/packages/cli/test/eslint-ignore-patterns/** +/packages/cli/test/eslint-lambda-override-eslintrc/** +/packages/cli/test/lambda-override-tsconfig/** +/packages/cli/test/start/src/** +/packages/cli/test/playground/src/sites/** + +# Docs build files +/www/build/** + +# Example React apps +/examples/**/frontend/ +/examples/** + +# Ignore presets +/packages/create-sst/** diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..42be01f41f --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Prettier bulk format +1a2f103016036a9fc99c37f252abc765c2256964 diff --git a/.github/workflows/assign-issues.yml b/.github/workflows/assign-issues.yml new file mode 100644 index 0000000000..44f94a018c --- /dev/null +++ b/.github/workflows/assign-issues.yml @@ -0,0 +1,20 @@ +name: Assign New Issues to Project + +on: + issues: + types: [opened, reopened] + +jobs: + issue_opened_or_reopened: + name: issue_opened_or_reopened + runs-on: ubuntu-latest + if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened') + steps: + - name: Move issue to project + uses: leonsteinhaeuser/project-beta-automations@v1.2.0 + with: + gh_token: ${{ secrets.FWANG_ASSIGN_ISSUES_TO_PROJECT_TOKEN }} + organization: serverless-stack + project_id: 1 + resource_node_id: ${{ github.event.issue.node_id }} + status_value: Triage diff --git a/.github/workflows/aws-cdk.yml b/.github/workflows/aws-cdk.yml new file mode 100644 index 0000000000..c13d9aa00b --- /dev/null +++ b/.github/workflows/aws-cdk.yml @@ -0,0 +1,71 @@ +name: aws-cdk + +on: + workflow_dispatch: + +jobs: + patch: + name: patch + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Setup Node.js + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 + with: + node-version: 16.x + registry-url: 'https://registry.npmjs.org' + + - name: Set up Git and GitHub credentials + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name "GitHub Actions Bot" + git config user.email "github-actions-bot@example.com" + + - name: patch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + #!/bin/bash + set -e + + mkdir tmp || true + cd tmp + + TAR_FILE=$(curl https://registry.npmjs.org/aws-cdk/latest | jq -r '.dist.tarball') + wget $TAR_FILE -O cdk.tar.gz + tar -xvf cdk.tar.gz + PACKAGE_JSON=./package/package.json + VERSION=$(jq -r .version $PACKAGE_JSON) + jq ' + .dependencies += {chalk: .devDependencies.chalk, yaml: .devDependencies.yaml, promptly: .devDependencies.promptly, archiver: .devDependencies.archiver } | + .name = "sst-aws-cdk" + ' $PACKAGE_JSON > tmp.json + mv tmp.json $PACKAGE_JSON + cd package + + if npm publish; then + echo "Successfully published to npm" + else + echo "Already published this version" + fi + + cd ../../ + rm -rf tmp + + git checkout -b update-aws-cdk-$VERSION + echo "Updating version to $VERSION" + jq " + .dependencies[\"sst-aws-cdk\"] = \"$VERSION\" + " ./packages/sst/package.json > tmp.json && mv tmp.json ./packages/sst/package.json + + git commit -am "Version updated" + git push origin HEAD + + gh pr create --title "Update sst-aws-cdk to $VERSION" --fill + + diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 128a071211..0000000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: check - -on: - pull_request: - branches: - - dev - types: [opened, synchronize, reopened] - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ">=1.23.2" - cache: true - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Install dependencies - run: bun install --frozen-lockfile - - - name: Download Go modules - run: go mod download - - - name: Check types - run: cd platform && bun tsc --noEmit - - - name: Build platform - run: ./platform/scripts/build - env: - DOCKER_PUSH: false - - - name: Setup uv - uses: astral-sh/setup-uv@v4 - with: - version: "latest" - - - name: Run Go tests - run: go test -vet=all ./... - - - name: Build CLI - run: go build -o sst ./cmd/sst - - - name: Build docs - run: cd www && bun run build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml new file mode 100644 index 0000000000..a7e5d267c5 --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,91 @@ +name: Examples + +on: + workflow_dispatch: + push: + tags: + - "*" + +jobs: + list: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - id: set-matrix + run: echo "::set-output name=matrix::$(ls packages/create-sst/bin/presets/examples/ | jq -R -s -c 'split("\n")[:-1]')" + generate: + needs: list + runs-on: ubuntu-latest + strategy: + matrix: + example: ${{ fromJson(needs.list.outputs.matrix) }} + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - uses: pnpm/action-setup@v2 + with: + version: 7 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Generate + run: | + rm -rf ./examples/${{ matrix.example }} + ./packages/create-sst/bin/create-sst.mjs --template=examples/${{ matrix.example }} ./examples/${{ matrix.example }} + find ./examples/${{ matrix.example }} + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.example }} + path: | + examples/${{ matrix.example}} + !examples/${{ matrix.example}}/node_modules + !examples/${{ matrix.example}}/package-lock.json + commit: + needs: generate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Clear + run: rm -rf examples/* + + - uses: actions/download-artifact@v3 + with: + path: examples/ + + - name: Commit files + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add . + git commit --allow-empty -m "Generated Examples" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + branch: ${{ github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 553257d0dd..fc1a2a487b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,135 +1,85 @@ -name: release +name: Release on: - workflow_dispatch: push: - tags: - - "*" + branches: + - master + - sst2 concurrency: ${{ github.workflow }}-${{ github.ref }} -permissions: - id-token: write - contents: write - packages: write - jobs: - goreleaser: + release: + name: Release runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout Repo + # https://github.com/actions/checkout uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - name: Setup Node - uses: actions/setup-node@v4 + - name: Setup Node.js + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 with: - node-version: "24" - registry-url: "https://registry.npmjs.org" + node-version: 16.x - - name: Login to GHCR - uses: docker/login-action@v2 + - uses: pnpm/action-setup@v2 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + version: 8 + run_install: false - - name: Fetch tags - run: git fetch --force --tags + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - name: Setup Go - uses: actions/setup-go@v5 + - uses: actions/cache@v3 + name: Setup pnpm cache with: - go-version: ">=1.23.2" - cache: true - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Download Go modules - run: go mod download + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: bun i --frozen-lockfile + run: pnpm install - - name: TypeScript check - run: cd platform && bun tsc --noEmit + - name: Check prettier + run: pnpm prettier --cache -c --loglevel=error . - - name: Build platform - run: ./platform/scripts/build - env: - DOCKER_PUSH: true - - - name: Setup uv - uses: astral-sh/setup-uv@v4 + - name: Create Release Pull Request or Publish to npm + id: changesets + # https://github.com/changesets/action + uses: changesets/action@v1 with: - version: "latest" - - - name: Run Go tests - run: go test -vet=all ./... - - - name: Release CLI - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser - version: latest - args: release --clean + createGithubReleases: false + version: pnpm run version + publish: pnpm run release env: - GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} - AUR_KEY: ${{ secrets.AUR_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Release JS SDK - run: | - cd sdk/js - bun run release + - name: View outputs + run: echo ${{join(steps.changesets.outputs.*, ' ')}} - - name: Authenticate crates.io - id: crates-auth - uses: rust-lang/crates-io-auth-action@v1 - - - name: Release Rust SDK - run: | - VERSION=$(jq -r .version dist/metadata.json) - cd sdk/rust - sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml - cargo publish --allow-dirty + - name: Aggregate + id: aggregate + if: steps.changesets.outputs.published == 'true' env: - CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }} - - - name: Build Python SDK + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: | - VERSION=$(jq -r .version dist/metadata.json) - cd sdk/python - sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml - uv build - - - name: Publish Python SDK - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: sdk/python/dist/ + node ./.changeset/aggregate.mjs - - name: Announce on Discord + - name: Create Release + if: steps.changesets.outputs.published == 'true' + uses: actions/create-release@v1 env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - TAG: ${{ github.ref_name }} - run: | - RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/$TAG" - NOTES=$(gh release view "$TAG" --json body --jq .body \ - | sed -E "s|\(#([0-9]+)\)|([#\1](https://github.com/${{ github.repository }}/pull/\1))|g" \ - | sed -E 's|^\* \[[a-f0-9]+\]\([^)]+\): ||' \ - | sed '/^## Changelog$/d' \ - | sed -E 's|^(.+)$|- \1|') - CONTENT=$(printf '🏷️ [**Release - %s**](%s)\n%s' "$TAG" "$RELEASE_URL" "$NOTES") - PAYLOAD=$(jq -n --arg c "$CONTENT" '{content:$c, flags:4}') - curl -fsS -X POST -H "Content-Type: application/json" \ - -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.aggregate.outputs.version }} + release_name: ${{ steps.aggregate.outputs.version }} + body: ${{ steps.aggregate.outputs.notes }} + draft: false + prerelease: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..dd20fa67df --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: Test + +on: + push + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + # https://github.com/actions/checkout + uses: actions/checkout@v3 + + - name: Setup Node.js + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Check prettier + run: pnpm prettier --cache -c --loglevel=error . + + - name: Build + run: pnpm build + working-directory: packages/sst + + + - name: Test + run: pnpm test + working-directory: packages/sst + diff --git a/.gitignore b/.gitignore index bdfb61622e..d5e1c0866b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,8 @@ -.sst -sst -dist -/sst -s node_modules - -# pulumi -Pulumi.*.yaml -Pulumi.yaml - -# osx +**/*.swp +.build +*.log +cdk.out .DS_Store - -.netlify -.env -tmp - -# coding agents -.termai -.opencode -.idea -.kiro - -# python -__pycache__ -uv.lock - -examples/**/sst-env.d.ts -examples/**/sst.pyi -www/src/content/docs/docs/examples.mdx -www/src/data/changelog.json -examples/**/bun.lock -examples/**/bun.lockb -examples/**/pnpm-lock.yaml -examples/**/package-lock.json -examples/**/uv.lock -examples/**/deno.lock -examples/**/Cargo.lock -examples/**/.env.* +dist +.vscode diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000000..0c55694513 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,7 @@ +# This configuration file was automatically generated by Gitpod. +# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file) +# and commit this file to your remote git repository to share the goodness with others. + +tasks: + - init: yarn install && yarn run build + command: yarn run watch diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 67a7c25fc9..0000000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,67 +0,0 @@ -version: 2 -project_name: sst -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - - windows - main: ./cmd/sst - -archives: - - formats: - - tar.gz - name_template: >- - sst- - {{- if eq .Os "darwin" }}mac- - {{- else if eq .Os "windows" }}windows- - {{- else if eq .Os "linux" }}linux-{{end}} - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "#86" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - format_overrides: - - goos: windows - formats: - - zip -checksum: - name_template: "checksums.txt" -snapshot: - version_template: "0.0.0-{{ .Timestamp }}" -aurs: - - homepage: "https://github.com/sst/sst" - description: "Deploy anything" - private_key: "{{ .Env.AUR_KEY }}" - git_url: "ssh://aur@aur.archlinux.org/sst-bin.git" - license: "MIT" - package: |- - install -Dm755 ./sst "${pkgdir}/usr/bin/sst" -brews: - - repository: - owner: sst - name: homebrew-tap -nfpms: - - maintainer: sst - description: the sst cli - formats: - - deb - - rpm - file_name_template: >- - {{ .ProjectName }}- - {{- if eq .Os "darwin" }}mac - {{- else }}{{ .Os }}{{ end }}-{{ .Arch }} - -changelog: - use: git - format: "[{{ .SHA }}](https://github.com/anomalyco/sst/commit/{{ .SHA }}): {{ .Message }}" - sort: asc - filters: - exclude: - - "^docs:" - - "^doc:" - - "^test:" - - "^ci:" - - "^ignore:" - - "^example:" - - "^wip:" diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..39dc70068e --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +# pnpm prettier diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..883c0a81a3 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +scripts-prepend-node-path=true +strict-peer-dependencies=false \ No newline at end of file diff --git a/.nvim.lua b/.nvim.lua deleted file mode 100644 index a50b3f4caa..0000000000 --- a/.nvim.lua +++ /dev/null @@ -1,5 +0,0 @@ -local opts = { noremap = true, silent = true } - -vim.keymap.set("n", "tb", function() - vim.cmd("!go build -o ./dist/sst ./cmd/sst && ./dist/sst") -end, opts) diff --git a/.prettierignore b/.prettierignore index 6d05b4987d..7a92e43d1b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,20 @@ +# Ignore CDK outputs +cdk.out +# Ignore SST outputs +.build +# Ignore package lockfile +package-lock.json +# Ignore templates +/packages/create-serverless-stack/templates/** # Ignore markdown files in the docs -/www/src/content/docs/docs/**/*.mdx \ No newline at end of file +# it breaks the formatting +/www/docs/**/*.md +# Ignore React outputs +/examples/**/build/**/*.* +/www/.docusaurus/**/*.* +/www/build/*.* +# Ignore Next.js outputs +/examples/**/.next/**/*.* +dist +build +pnpm-lock.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 23830fb423..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "git.ignoreLimitWarning": true -} diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 0000000000..65496704d2 --- /dev/null +++ b/.yarnrc @@ -0,0 +1,5 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +yarn-path ".yarn/releases/yarn-1.19.0.cjs" diff --git a/AGENTS.md b/AGENTS.md deleted file mode 120000 index 681311eb9c..0000000000 --- a/AGENTS.md +++ /dev/null @@ -1 +0,0 @@ -CLAUDE.md \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index f6de27996c..0000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,30 +0,0 @@ -## Layout - -- `platform/` β€” TS Pulumi components embedded via `//go:embed` (`platform/platform.go:16`) -- `examples/` β€” sample apps -- `cmd/sst/` β€” Go CLI entry, orchestrates everything -- `cmd/sst/mosaic/` β€” live dev TUI -- `pkg/server/` β€” JSON-RPC bridge for custom Pulumi dynamic providers (`rpc/rpc.ts` ↔ `pkg/server`) -- `pkg/bus/` β€” pub/sub event bus -- `sdk/js/` β€” runtime SDK for reading linked resources -- `www/` β€” docs site (auto-generated from JSDoc comments in platform and extracted from the Go CLI) - -## Commands - -- **Setup**: `bun run setup` -- **Build platform**: `bun run build:platform` -- **Build CLI**: `bun run build:cli` -- **Run CLI locally**: `cd examples/ && go run ../../cmd/sst ` -- **Go tests**: `bun run test:cli` -- **Typecheck**: `bun run typecheck` -- **Generate docs**: `bun run docs:generate` -- **Run docs locally**: `bun run docs:dev` - -## Verification - -1. Build the platform -2. `cd examples/ && bun install` -3. `go run ../../cmd/sst deploy` -4. Verify with `curl` or AWS CLI -5. Don't clean up unless told to -6. `sst dev --mode=basic` for dev mode diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..ea8aa32b24 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,248 @@ +# Contributing to SST + +Want to help improve SST? Thank you! Take a second to review this document before you get started. + +To be sure that you are not working on something that's already being worked on, make sure to either: + +- [Open a new issue][issue] about it +- Or [join us on Discord][discord] and send us a message + +## How to Contribute + +In this section we'll talk about the workflow we recommend while working on SST. It's based on how we work internally, but catered specifically for our community contributors. For more context on how we work, you can [check out this document](https://sst.dev/about/culture.html). + +### 1. Gather Requirements + +When assigned an issue, the first step is to get all the details and seek any necessary clarification. If the issue was brought up by a user, make sure you fully understand the requirement from the user. Contact the user on Discord or ask them on GitHub. Or, contact a member from the core team that opened the issue. + +### 2. Speccing + +Next, do the necessary research. Draft a plan for the implementation; the cases that need to be tested; and the docs required to be updated. + +Here is an example of a spec in action: + +#### Example Task: Allow users to customize eslint rules in SST + +- [ ] Research: How is it currently done in other popular frameworks, ie. Create React App. +- [ ] Implement: Add an eslint section in the `package.json` to allow users to specify a list of linting packages. +- [ ] Implement: Update the `create-sst` template to prefill the `package.json` with SST's default linting package. +- [ ] Test: Add a test with SST's default linting package and check the `no-unused-vars` rule is enforced. +- [ ] Test: Add a test with custom linting packages and check that the `no-unused-vars` rule is not enforced. +- [ ] Doc: Document the default linting package in "Working Locally" doc. +- [ ] Doc: Show an example of customizing linting packages. + +Then, add the spec to the GitHub issue. It's necessary to come up with this list **before** working on the task. This gives the core team a chance to propose changes. And, a good spec is one where it can be handed to anyone on the team. That person is then able to follow through and complete the implementation. + +If the solution isn’t obvious or is a bigger design change, get the core team involved. Before the group discussion, come up with a proposed solution. [More on this here](https://sst.dev/about/culture.html#our-design-process). + +The core team then reviews the spec. + +### 3. Implement + +Create a [Pull Request](#pull-requests). Inform the core team upon completion. And the core team will review the PR and merge it. + +--- + +## Running Locally + +Here's how to run SST locally. + +### Clone the repo + +To run this project locally, clone the repo and initialize the project. + +```bash +$ git clone https://github.com/serverless-stack/sst.git +$ cd sst +$ pnpm install +``` + +Build the project + +```bash +$ pnpm build +``` + +### SST + +If you are working on the `packages/sst` part, run the watcher at the root. + +```bash +$ pnpm watch +``` + +Finally, after making your changes, run all the tests in the `packages/sst` directory. + +```bash +$ pnpm test +``` + +Alternatively, you can run the tests for a specific construct. + +```bash +$ pnpm test +``` + +### Console + +If you are working on the `packages/console` just go ahead and make your changes. Then run your tests. + +```bash +$ cd packages/console +$ pnpm test +``` + +Alternatively, you can run a specific test. + +```bash +$ pnpm test +``` + +### Docs + +To run the docs site. + +```bash +$ cd www +$ pnpm start +``` + +## Pull Requests + +Make sure to add your changes as a pull request. Start by forking the repo. Then make your changes and submit a PR. + +- Use a descriptive name for the PR +- With the format, "[Construct/package name]: [Description]" +- For example, "Api: Add support for HTTP proxy routes" +- Pick a label for the PR from: + - `breaking`: These are for breaking changes + - `bug`: Bug fixes + - `enhancement`: New features + - `documentation`: Improvements to the docs or examples + - `skip changelog`: Don't mention this in the release notes + +If you are submitting the PR for the first time, we'll need to approve it to run the tests. + +## Releases + +To cut a release, start by merging the PRs that are going into this release. + +1. Generate changelog + + ```bash + $ pnpm changelog + ``` + + You'll need to configure the `GITHUB_AUTH` token locally to be able to run this. [Follow these steps](https://github.com/lerna/lerna-changelog#github-token) and configure the local environment variable. + +2. Publish a release to npm + + To publish the release to npm run: + + ```bash + $ pnpm release + ``` + + Pick the version you want (patch/minor/major). This is based on the type of changes in the changelog above. + + - `breaking` and major `enhancement` changes are a minor version update + - `bug` and minor `enhancement` changes are a patch version update + + We are not currently updating the major version until our 1.0 release. + + Verify that only the 5 core packages (`core`, `cli`, `resources`, `create-sst`, `static-site-env`) are getting published. + + Confirm and publish! + +3. Draft a new release + + Copy the changelog that was generated above and [draft a new release](https://github.com/serverless-stack/sst/releases/new). + + Make necessary edits to the changelog to make it more readable and helpful. + + - For `breaking` changes, add a message at the top clearly documenting the change ([example](https://github.com/serverless-stack/sst/releases/tag/v0.26.0)). + - For major `enhancement` changes, add a code snippet on how to use the feature ([example](https://github.com/serverless-stack/sst/releases/tag/v0.36.0)). + + Add this snippet at the bottom of the changelog and replace it with the version that's going to be released. + + ```` + --- + + Update using: + + ```sh + $ npm install --save --save-exact @serverless-stack/cli@x.x.x @serverless-stack/resources@x.x.x + ``` + ```` + +4. Publish GitHub release + + In the **Tag version** of the release draft, select the version that was just published to npm. + + Copy-paste that version as the **Release title**. And hit **Publish release**. + +### Canary Releases + +Optionally, you can publish a canary release to npm. + +This is useful if you'd like to test your release before pushing it live. + +Create a canary release by running. + +```bash +$ pnpm release-canary +``` + +## Deprecation + +Follow the checklist below when deprecating a Construct property or method. + +1. Docs: Label the old property name (or method) as deprecated. + ``` + oldProp (deprecated) + ``` +2. Docs: Add migration instructions under the old property (or method): + + ```` + `oldProp` has been renamed to `newProp` in v0.46.0. + + If you are configuring the `oldProp` like so: + + ```js + new Table(this, "Table", { + ... + oldProp: "value", + } + ``` + + Change it to: + + ```js + new Table(this, "Table", { + ... + newProp: "value", + } + ``` + ```` + +3. Construct code: Decorate the old property (or method) as deprecated. + ``` + /** + * @deprecated Use newProp + */ + ``` +4. Construct code: Ensure the old property (or method) will continue to work. +5. Construct code: Print a warning in verbose mode if the old property (or method) is used. + ``` + WARNING: The "oldProp" property has been renamed to "newProp". "oldProp" will continue to work but will be removed at a later date. More details on the deprecation - https://docs.sst.dev/constructs/Table#secondaryindexes-deprecated + ``` +6. Construct tests: Ensure tests added for both the old and the new property (or method). + +See the `Table` construct for a deprecation example of renaming `secondaryIndexes` to `globalIndexes`. + +--- + +Help us improve this doc. If you've had a chance to contribute to SST, feel free to edit this doc and submit a PR. + +[discord]: https://sst.dev/discord +[issue]: https://github.com/serverless-stack/sst/issues/new diff --git a/LICENSE b/LICENSE index c6eca6eed7..cd39173ad1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 SST +Copyright (c) 2020 SST Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index cbc6c8b796..6d8700fd22 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,48 @@

- SST + SST

- Discord + Discord npm - Build status + Build status

--- -Build full-stack apps on your own infrastructure. - -## Installation - -For JavaScript projects, install SST locally so the CLI version is tracked with your app. You can then run the CLI with the same package manager. - -```bash -npm install sst -# pnpm add sst -# bun add sst -# yarn add sst -``` - -If you are not using JavaScript, you can install the CLI globally. +SST makes it easy to build modern full-stack applications on AWS. Watch the [**SST in 100 seconds**](https://youtu.be/JY_d0vf-rfw) video to learn more. ```bash -curl -fsSL https://sst.dev/install | bash +$ npx create-sst@latest ``` -To install a specific version. - -```bash -curl -fsSL https://sst.dev/install | VERSION=0.0.403 bash -``` - -To use a package manager, [check out our docs](https://sst.dev/docs/reference/cli/). - -#### Manually +### Pick your frontend -Download the pre-compiled binaries from the [releases](https://github.com/sst/sst/releases/latest) page and copy to the desired location. +Deploy Next.js, Svelte, Remix, Astro, Solid, or any static site to AWS. -## Get Started +- [**Next.js**](https://docs.sst.dev/start/nextjs) +- [**Svelte**](https://docs.sst.dev/start/svelte) +- [**Remix**](https://docs.sst.dev/start/remix) +- [**Astro**](https://docs.sst.dev/start/astro) +- [**Solid**](https://docs.sst.dev/start/solid) -Get started with your favorite framework: +### Add any feature -- [Next.js](https://sst.dev/docs/start/aws/nextjs) -- [Remix](https://sst.dev/docs/start/aws/remix) -- [Astro](https://sst.dev/docs/start/aws/astro) -- [API](https://sst.dev/docs/start/aws/api) +SST gives you the full power of AWS. Making it easy to add any feature to your product. -## Learn More - -Learn more about some of the key concepts: - -- [Live](https://sst.dev/docs/live) -- [Linking](https://sst.dev/docs/linking) -- [Console](https://sst.dev/docs/console) -- [Components](https://sst.dev/docs/components) - -## Contributing - -Here's how you can contribute: - -- Help us improve our docs -- Find a bug? Open an issue -- Feature request? Submit a PR - -## Running Locally - -Run `bun run setup`. You need [Go](https://go.dev/) and [Bun](https://bun.sh/) installed. - -Now you can run the CLI locally on any of the `examples/` apps. - -```bash -cd examples/aws-api -go run ../../cmd/sst -``` +- [File uploads](https://docs.sst.dev/file-uploads) β€” Allow your users to upload files to S3. +- [Auth](https://docs.sst.dev/auth) β€” Authenticate your users through any auth provider. +- [Events](https://docs.sst.dev/events) β€” Run tasks after your app has returned to your user. +- [Databases](https://docs.sst.dev/databases) β€” Use a serverless SQL or NoSQL database to power your app. +- [Jobs](https://docs.sst.dev/cron-jobs) β€” Run cron jobs or long running jobs powered by serverless functions. +- [APIs](https://docs.sst.dev/apis) β€” Add a dedicated serverless REST, GraphQL, or WebSocket API to your app. -If you want to build the CLI binary, run `bun run build:cli`. This will create a `sst` binary that you can use. +### Collaborate with your team -For building the docs, run `bun run docs:generate` and `bun run docs:dev`. +Finally, you can `git push` to deploy using [_**Seed**_](https://seed.run), a service built by the team behind SST. And you can work on your apps together with your team with automatic preview environments. --- -**Join our community** [Discord](https://sst.dev/discord) | [YouTube](https://www.youtube.com/c/sst-dev) | [X.com](https://x.com/SST_dev) +**Join our community** [Discord](https://sst.dev/discord) | [YouTube](https://www.youtube.com/c/sst-dev) | [Twitter](https://twitter.com/SST_dev) | [Contribute](CONTRIBUTING.md) diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index 5470431b11..0000000000 Binary files a/bun.lockb and /dev/null differ diff --git a/cmd/sst/add_test.go b/cmd/sst/add_test.go deleted file mode 100644 index dbf4df960a..0000000000 --- a/cmd/sst/add_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "testing" - - "github.com/sst/sst/v3/pkg/project" -) - -func TestGetAliasName(t *testing.T) { - tests := []struct { - name string - entry *project.ProviderLockEntry - want string - }{ - { - name: "simple provider", - entry: &project.ProviderLockEntry{ - Name: "stripe", - Package: "pulumi-stripe", - Alias: "stripe", - }, - want: "stripe", - }, - { - name: "strip official suffix", - entry: &project.ProviderLockEntry{ - Name: "stripe-official", - Package: "@sst-provider/stripe-official", - Alias: "stripe", - }, - want: "stripe", - }, - { - name: "strip community suffix from alias", - entry: &project.ProviderLockEntry{ - Name: "@scope/pulumi-foo-community", - Package: "@scope/pulumi-foo-community", - Alias: "foocommunity", - }, - want: "foo", - }, - { - name: "package input still uses alias", - entry: &project.ProviderLockEntry{ - Name: "@paynearme/pulumi-jetstream", - Package: "@paynearme/pulumi-jetstream", - Alias: "jetstream", - }, - want: "jetstream", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getAliasName(tt.entry); got != tt.want { - t.Fatalf("got %q, want %q", got, tt.want) - } - }) - } -} diff --git a/cmd/sst/cert.go b/cmd/sst/cert.go deleted file mode 100644 index 337c447dc2..0000000000 --- a/cmd/sst/cert.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/pkg/global" - "github.com/sst/sst/v3/pkg/process" -) - -var CmdCert = &cli.Command{ - Name: "cert", - Description: cli.Description{ - Short: "Generate certificate for the Console", - Long: strings.Join([]string{ - "Generate a locally-trusted certificate to connect to the Console.", - "", - "The Console can show you local logs from `sst dev` by connecting to your CLI. Certain browsers like Safari and Brave require the local connection to be running on HTTPS.", - "", - "This command uses [mkcert](https://github.com/FiloSottile/mkcert) internally to generate a locally-trusted certificate for `localhost` and `127.0.0.1`.", - "", - "You'll only need to do this once on your machine.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - err := global.EnsureMkcert() - if err != nil { - return err - } - env := os.Environ() - env = append(env, "CAROOT="+global.CertPath()) - cmd := process.Command("mkcert", "-install") - cmd.Env = env - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err != nil { - return err - } - cmd = process.Command( - "mkcert", - "-key-file", filepath.Join(global.CertPath(), "key.pem"), - "-cert-file", filepath.Join(global.CertPath(), "cert.pem"), - "127.0.0.1", - "localhost", - ) - cmd.Env = env - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err != nil { - return err - } - return nil - }, -} diff --git a/cmd/sst/cli/cli.go b/cmd/sst/cli/cli.go deleted file mode 100644 index b9ea8403a0..0000000000 --- a/cmd/sst/cli/cli.go +++ /dev/null @@ -1,354 +0,0 @@ -package cli - -import ( - "context" - "fmt" - "os" - "os/user" - "path/filepath" - "strings" - - flag "github.com/spf13/pflag" - "golang.org/x/term" - - "github.com/charmbracelet/huh" - "github.com/fatih/color" - "github.com/joho/godotenv" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/project" -) - -type Cli struct { - version string - flags map[string]interface{} - arguments []string - path CommandPath - Context context.Context - cancel context.CancelFunc - env []string -} - -func New(ctx context.Context, cancel context.CancelFunc, root *Command, version string) (*Cli, error) { - env := os.Environ() - godotenv.Load() - parsedFlags := map[string]interface{}{} - root.init(parsedFlags) - flag.CommandLine.Init("sst", flag.ContinueOnError) - cliParseError := flag.CommandLine.Parse(os.Args[1:]) - positionals := []string{} - cmds := CommandPath{ - *root, - } - for i, arg := range flag.Args() { - var cmd *Command - - last := cmds[len(cmds)-1] - if len(last.Children) == 0 { - positionals = flag.Args()[i:] - break - } - for _, c := range last.Children { - if c.Name == arg { - cmd = c - break - } - } - if cmd == nil { - break - } - cmds = append(cmds, *cmd) - } - cli := &Cli{ - flags: parsedFlags, - version: version, - arguments: positionals, - path: cmds, - Context: ctx, - cancel: cancel, - env: env, - } - cli.configureLog() - if cliParseError != nil { - return nil, cli.PrintHelp() - } - cli.configureLog() - return cli, nil -} - -func (c *Cli) Run() error { - active := c.path[len(c.path)-1] - required := 0 - for _, arg := range active.Args { - if !arg.Required { - continue - } - required += 1 - } - if c.Bool("help") || active.Run == nil || len(c.arguments) < required { - return c.PrintHelp() - } else { - return active.Run(c) - } -} - -func (c *Cli) Cancel() { - c.cancel() -} - -func (c *Cli) Path() CommandPath { - return c.path -} - -func (c *Cli) String(name string) string { - if f, ok := c.flags[name]; ok { - return *f.(*string) - } - return "" -} - -func (c *Cli) Bool(name string) bool { - if f, ok := c.flags[name]; ok { - return *f.(*bool) - } - return false -} - -func (c *Cli) PrintHelp() error { - return c.path.PrintHelp() -} - -func (c *Cli) Arguments() []string { - return c.arguments -} - -func (c *Cli) Positional(index int) string { - if index >= len(c.arguments) { - return "" - } - return c.arguments[index] -} - -func (c *Cli) Env() []string { - return c.env -} - -type Command struct { - Name string `json:"name"` - Hidden bool `json:"hidden"` - Description Description `json:"description"` - Args ArgumentList `json:"args"` - Flags []Flag `json:"flags"` - Examples []Example `json:"examples"` - Children []*Command `json:"children"` - Run func(cli *Cli) error `json:"-"` -} - -func (c *Command) init(parsed map[string]interface{}) { - if c.Args == nil { - c.Args = ArgumentList{} - } - if c.Flags == nil { - c.Flags = []Flag{} - } - if c.Examples == nil { - c.Examples = []Example{} - } - if c.Children == nil { - c.Children = []*Command{} - } - for _, f := range c.Flags { - if parsed[f.Name] != nil { - continue - } - if f.Type == "string" { - parsed[f.Name] = flag.String(f.Name, "", "") - } - - if f.Type == "bool" { - parsed[f.Name] = flag.Bool(f.Name, false, "") - } - } - for _, child := range c.Children { - child.init(parsed) - } -} - -type Example struct { - Content string `json:"content"` - Description Description `json:"description"` -} - -type Argument struct { - Name string `json:"name"` - Required bool `json:"required"` - Description Description `json:"description"` -} - -type Description struct { - Short string `json:"short,omitempty"` - Long string `json:"long,omitempty"` -} - -type ArgumentList []Argument - -func (a ArgumentList) String() string { - args := []string{} - for _, arg := range a { - if arg.Required { - args = append(args, "<"+arg.Name+">") - } else { - args = append(args, "["+arg.Name+"]") - } - } - return strings.Join(args, " ") -} - -type Flag struct { - Name string `json:"name"` - Type string `json:"type"` - Description Description `json:"description"` -} - -type CommandPath []Command - -var ErrHelp = util.NewReadableError(nil, "") - -func (c CommandPath) PrintHelp() error { - prefix := []string{} - for _, cmd := range c { - prefix = append(prefix, cmd.Name) - } - active := c[len(c)-1] - - if len(active.Children) > 0 { - fmt.Print(strings.Join(prefix, " ") + ": ") - fmt.Println(color.WhiteString(c[len(c)-1].Description.Short)) - - maxSubcommand := 0 - for _, child := range active.Children { - if child.Hidden { - continue - } - next := len(child.Name) - if len(child.Args) > 0 { - next += len(child.Args.String()) + 1 - } - if next > maxSubcommand { - maxSubcommand = next - } - } - - fmt.Println() - for _, child := range active.Children { - if child.Hidden { - continue - } - fmt.Printf( - " %s %s %s\n", - strings.Join(prefix, " "), - color.New(color.FgWhite, color.Bold).Sprintf("%-*s", maxSubcommand, func() string { - if len(child.Args) > 0 { - return strings.Join([]string{child.Name, child.Args.String()}, " ") - } - return child.Name - }()), - child.Description.Short, - ) - } - } - - if len(active.Children) == 0 { - color.New(color.FgWhite, color.Bold).Print("Usage: ") - color.New(color.FgCyan).Print(strings.Join(prefix, " ")) - if len(active.Args) > 0 { - color.New(color.FgGreen).Print(" " + active.Args.String()) - } - fmt.Println() - fmt.Println() - - color.New(color.FgWhite, color.Bold).Print("Flags:\n") - maxFlag := 0 - for _, cmd := range c { - for _, f := range cmd.Flags { - l := len(f.Name) + 3 - if l > maxFlag { - maxFlag = l - } - } - } - - for _, cmd := range c { - for _, f := range cmd.Flags { - fmt.Printf( - " %s %s\n", - color.New(color.FgMagenta).Sprintf("--%-*s", maxFlag, f.Name), - f.Description.Short, - ) - } - } - - if len(active.Examples) > 0 { - fmt.Println() - color.New(color.FgWhite, color.Bold).Print("Examples:\n") - for _, example := range active.Examples { - fmt.Println(" " + example.Content) - } - } - } - - fmt.Println() - fmt.Printf("Learn more at %s\n", color.MagentaString("https://sst.dev")) - - return ErrHelp -} - -func (c *Cli) Stage(cfgPath string) (string, error) { - stage := c.String("stage") - if stage == "" { - stage = os.Getenv("SST_STAGE") - if stage == "" { - stage = project.LoadPersonalStage(cfgPath) - if stage == "" { - stage = guessStage() - if stage == "" { - if !term.IsTerminal(int(os.Stdout.Fd())) { - return "", util.NewReadableError(nil, "No stage specified. Pass it in with --stage or set the SST_STAGE environment variable. If this is a personal stage it can be set in `.sst/stage`.") - } - err := huh.NewForm( - huh.NewGroup( - huh.NewInput().Title(" Enter name for your personal stage").Prompt(" > ").Value(&stage).Validate(func(v string) error { - if project.InvalidStageRegex.MatchString(v) { - return fmt.Errorf("Invalid stage name") - } - return nil - }), - ), - ).WithTheme(huh.ThemeCatppuccin()).Run() - if err != nil { - return "", err - } - } - err := project.SetPersonalStage(cfgPath, stage) - if err != nil { - return "", err - } - } - } - } - godotenv.Overload(filepath.Join(filepath.Dir(cfgPath), ".env."+stage)) - return stage, nil -} - -func guessStage() string { - u, err := user.Current() - if err != nil { - return "" - } - stage := strings.ToLower(u.Username) - stage = project.InvalidStageRegex.ReplaceAllString(stage, "") - - if stage == "root" || stage == "admin" || stage == "prod" || stage == "dev" || stage == "production" { - return "" - } - return stage -} diff --git a/cmd/sst/cli/project.go b/cmd/sst/cli/project.go deleted file mode 100644 index e6dce082db..0000000000 --- a/cmd/sst/cli/project.go +++ /dev/null @@ -1,145 +0,0 @@ -package cli - -import ( - "fmt" - "io" - "log/slog" - "os" - "path/filepath" - "runtime/debug" - "time" - - "github.com/briandowns/spinner" - "github.com/joho/godotenv" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/project" -) - -var logFile = (func() *os.File { - tmpPath := flag.SST_LOG - if tmpPath == "" { - tmpPath = filepath.Join(os.TempDir(), fmt.Sprintf("sst-%s.log", time.Now().Format("2006-01-02-15-04-05"))) - } - logFile, err := os.Create(tmpPath) - if err != nil { - panic(err) - } - return logFile -})() - -func (c *Cli) Discover() (string, error) { - cfgPath := c.String("config") - if cfgPath != "" { - abs, err := filepath.Abs(cfgPath) - if err != nil { - return "", util.NewReadableError(err, "Could not find "+cfgPath) - } - if _, err := os.Stat(abs); os.IsNotExist(err) { - return "", util.NewReadableError(err, "Could not find "+abs) - } - return abs, nil - } - - match, err := project.Discover() - if err != nil { - return "", util.NewReadableError(err, "Could not find sst.config.ts") - } - return match, nil -} - -func (c *Cli) InitProject() (*project.Project, error) { - slog.Info("initializing project", "version", c.version) - - cfgPath, err := c.Discover() - if err != nil { - return nil, err - } - - stage, err := c.Stage(cfgPath) - if err != nil { - return nil, util.NewReadableError(err, "Could not find stage") - } - - p, err := project.New(&project.ProjectConfig{ - Version: c.version, - Stage: stage, - Config: cfgPath, - }) - if err != nil { - return nil, err - } - godotenv.Load(filepath.Join(p.PathRoot(), ".env")) - - if flag.SST_LOG == "" { - _, err = logFile.Seek(0, 0) - if err != nil { - return nil, err - } - sstLog := p.PathLog("sst") - logPath := p.PathLog("") - os.MkdirAll(logPath, 0755) - nextLogFile, err := os.Create(sstLog) - if err != nil { - return nil, util.NewReadableError(err, "Could not create log file") - } - _, err = io.Copy(nextLogFile, logFile) - if err != nil { - return nil, util.NewReadableError(err, "Could not copy log file") - } - logFile.Close() - defer func() { - err = os.RemoveAll(filepath.Join(os.TempDir(), logFile.Name())) - if err != nil { - slog.Error("failed to remove temp log file", "err", err) - } - }() - logFile = nextLogFile - } - c.configureLog() - - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond, spinner.WithWriterFile(os.Stderr)) - spin.Color("cyan") - defer spin.Stop() - if !p.CheckPlatform(c.version) { - spin.Suffix = " Upgrading project..." - spin.Start() - err := p.CopyPlatform(c.version) - if err != nil { - return nil, util.NewReadableError(err, "Could not copy platform code to project directory") - } - } - - if p.NeedsInstall() { - spin.Suffix = " Installing providers..." - spin.Start() - err = p.Install() - if err != nil { - return nil, err - } - } - - if err := p.LoadHome(); err != nil { - return nil, err - } - - app := p.App() - slog.Info("loaded config", "app", app.Name, "stage", app.Stage) - - c.configureLog() - return p, nil -} - -func (c *Cli) configureLog() { - writers := []io.Writer{logFile} - if c.Bool("print-logs") || flag.SST_PRINT_LOGS { - writers = append(writers, os.Stderr) - } - writer := io.MultiWriter(writers...) - slog.SetDefault( - slog.New(slog.NewTextHandler(writer, &slog.HandlerOptions{ - Level: slog.LevelInfo, - })), - ) - debug.SetCrashOutput(logFile, debug.CrashOptions{}) -} diff --git a/cmd/sst/deploy.go b/cmd/sst/deploy.go deleted file mode 100644 index f619dbcf0d..0000000000 --- a/cmd/sst/deploy.go +++ /dev/null @@ -1,200 +0,0 @@ -package main - -import ( - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -var CmdDeploy = &cli.Command{ - Name: "deploy", - Description: cli.Description{ - Short: "Deploy your application", - Long: strings.Join([]string{ - "Deploy your application. By default, it deploys to your personal stage.", - "You typically want to deploy it to a specific stage.", - "", - "```bash frame=\"none\"", - "sst deploy --stage production", - "```", - "", - "Optionally, deploy a specific component by passing in the name of the component from your `sst.config.ts`.", - "", - "```bash frame=\"none\"", - "sst deploy --target MyComponent", - "```", - "", - "Alternatively, exclude a specific component from the deploy.", - "", - "```bash frame=\"none\"", - "sst deploy --exclude MyComponent", - "```", - "", - "All the resources are deployed as concurrently as possible, based on their dependencies.", - "For resources like your container images, sites, and functions; it first builds them and then deploys the generated assets.", - "", - ":::tip", - "Configure the concurrency if your CI builds are running out of memory.", - ":::", - "", - "Since the build processes for some of these resources take a lot of memory, their concurrency is limited by default.", - "However, this can be configured.", - "", - "| Resource | Concurrency | Flag |", - "| -------- | ----------- | ---- |", - "| Sites | 1 | `SST_BUILD_CONCURRENCY_SITE` |", - "| Functions | 4 | `SST_BUILD_CONCURRENCY_FUNCTION` |", - "| Containers | 1 | `SST_BUILD_CONCURRENCY_CONTAINER` |", - "", - "So only one site is built at a time, 4 functions are built at a time, and only 1 container is built at a time.", - "", - "You can set the above environment variables to change this when you run `sst deploy`. This is useful for CI", - "environments where you want to control this based on how much memory your CI machine has.", - "", - "For example, to build a maximum of 2 sites concurrently.", - "", - "```bash frame=\"none\"", - "SST_BUILD_CONCURRENCY_SITE=2 sst deploy", - "```", - " Or to configure all these together.", - "", - "```bash frame=\"none\"", - "SST_BUILD_CONCURRENCY_SITE=2 SST_BUILD_CONCURRENCY_CONTAINER=2 SST_BUILD_CONCURRENCY_FUNCTION=8 sst deploy", - "```", - "Typically, this command exits when there's an error deploying a resource.", - "But sometimes you want to be able to `--continue` deploying as many resources as possible;", - "", - "```bash frame=\"none\"", - "sst deploy --continue", - "```", - "", - "This is useful when deploying a new stage with a lot of resources. You want", - "to be able to deploy as many resources as possible and then come back and", - "fix the errors.", - "", - "The `sst dev` command deploys your resources a little differently. It skips", - "deploying resources that are going to be run locally. Sometimes you want to", - "deploy a personal stage without starting `sst dev`.", - "", - "```bash frame=\"none\"", - "sst deploy --dev", - "```", - "The `--dev` flag will deploy your resources as if you were running `sst dev`.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - { - Name: "exclude", - Type: "string", - Description: cli.Description{ - Short: "Exclude a component", - Long: "Exclude the specified component from the operation.", - }, - }, - { - Name: "continue", - Type: "bool", - Description: cli.Description{ - Short: "Continue on error", - Long: "Continue on error and try to deploy as many resources as possible.", - }, - }, - { - Name: "dev", - Type: "bool", - Description: cli.Description{ - Short: "Deploy in dev mode", - Long: "Deploy resources like `sst dev` would.", - }, - }, - { - Name: "policy", - Type: "string", - Description: cli.Description{ - Short: "Path to policy pack", - Long: "Run policy pack validation against the preview changes.", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst deploy --stage production", - Description: cli.Description{ - Short: "Deploy to production", - }, - }, - { - Content: "sst deploy --stage production --policy ./policies/production", - Description: cli.Description{ - Short: "Deploy to production with policy validation", - }, - }, - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - exclude := []string{} - if c.String("exclude") != "" { - exclude = strings.Split(c.String("exclude"), ",") - } - - var wg errgroup.Group - defer wg.Wait() - out := make(chan interface{}) - defer close(out) - ui := ui.New(c.Context) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - events := bus.SubscribeAll() - defer close(events) - wg.Go(func() error { - for evt := range events { - ui.Event(evt) - } - return nil - }) - defer ui.Destroy() - defer c.Cancel() - err = p.Run(c.Context, &project.StackInput{ - Command: "deploy", - Target: target, - Exclude: exclude, - Dev: c.Bool("dev"), - ServerPort: s.Port, - Verbose: c.Bool("verbose"), - Continue: c.Bool("continue"), - PolicyPath: c.String("policy"), - }) - if err != nil { - return err - } - return nil - }, -} diff --git a/cmd/sst/diagnostic.go b/cmd/sst/diagnostic.go deleted file mode 100644 index 7d80daaf51..0000000000 --- a/cmd/sst/diagnostic.go +++ /dev/null @@ -1,106 +0,0 @@ -package main - -import ( - "archive/zip" - "fmt" - "io" - "os" - "path/filepath" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/id" - "github.com/sst/sst/v3/pkg/project" -) - -var CmdDiagnostic = &cli.Command{ - Name: "diagnostic", - Description: cli.Description{ - Short: "Generates a diagnostic report", - Long: strings.Join([]string{ - "Generates a diagnostic report based on the last command that was run.", - "", - "This takes the state of your app, its log files, and generates a zip file in the `.sst/` directory. This is for debugging purposes.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - cfg, err := c.Discover() - if err != nil { - return err - } - workingDir := project.ResolveWorkingDir(cfg) - logDir := project.ResolveLogDir(cfg) - logFiles, err := os.ReadDir(logDir) - fmt.Println(ui.TEXT_DIM.Render("Generating diagnostic report from last run...")) - zipFile, err := os.Create(filepath.Join(workingDir, "report.zip")) - if err != nil { - return err - } - defer zipFile.Close() - archive := zip.NewWriter(zipFile) - defer archive.Close() - - addFile := func(path string, name string) error { - fmt.Println(ui.TEXT_DIM.Render("- " + name)) - fileToZip, err := os.Open(path) - if err != nil { - return err - } - defer fileToZip.Close() - info, err := fileToZip.Stat() - if err != nil { - return err - } - header, err := zip.FileInfoHeader(info) - if err != nil { - return err - } - header.Name = name - header.Method = zip.Deflate - writer, err := archive.CreateHeader(header) - if err != nil { - return err - } - _, err = io.Copy(writer, fileToZip) - if err != nil { - return err - } - return nil - } - - if err != nil { - return err - } - for _, file := range logFiles { - if !file.IsDir() { - filePath := filepath.Join(logDir, file.Name()) - err := addFile(filePath, file.Name()) - if err != nil { - return err - } - } - } - p, err := c.InitProject() - if err != nil { - return err - } - workdir, err := p.NewWorkdir(id.Descending()) - if err != nil { - return err - } - defer workdir.Cleanup() - - statePath, err := workdir.Pull() - if err != nil { - return err - } - err = addFile(statePath, "state.json") - if err != nil { - return err - } - fmt.Println() - ui.Success("Report generated: " + zipFile.Name()) - return nil - }, -} diff --git a/cmd/sst/diff.go b/cmd/sst/diff.go deleted file mode 100644 index 2015cdd0db..0000000000 --- a/cmd/sst/diff.go +++ /dev/null @@ -1,302 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "sort" - "strings" - - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "github.com/yalp/jsonpath" - "golang.org/x/sync/errgroup" -) - -var CmdDiff = &cli.Command{ - Name: "diff", - Description: cli.Description{ - Short: "See what changes will be made", - Long: strings.Join([]string{ - "Builds your app to see what changes will be made when you deploy it.", - "", - "It displays a list of resources that will be created, updated, or deleted.", - "For each of these resources, it'll also show the properties that are changing.", - "", - ":::tip", - "Run a `sst diff` to see what changes will be made when you deploy your app.", - ":::", - "", - "This is useful for cases when you pull some changes from a teammate and want to", - "see what will be deployed; before doing the actual deploy.", - "", - "Optionally, you can diff a specific component by passing in the name of the component from your `sst.config.ts`.", - "", - "```bash frame=\"none\"", - "sst diff --target MyComponent", - "```", - "", - "Alternatively, exclude a specific component from the diff.", - "", - "```bash frame=\"none\"", - "sst diff --exclude MyComponent", - "```", - "", - "By default, this compares to the last deploy of the given stage as it would be", - "deployed using `sst deploy`. But if you are working in dev mode using `sst dev`,", - "you can use the `--dev` flag.", - "", - "```bash frame=\"none\"", - "sst diff --dev", - "```", - "", - "This is useful because in dev mode, you app is deployed a little differently.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - { - Name: "exclude", - Type: "string", - Description: cli.Description{ - Short: "Exclude a component", - Long: "Exclude the specified component from the operation.", - }, - }, - { - Name: "dev", - Type: "bool", - Description: cli.Description{ - Short: "Compare to sst dev", - Long: strings.Join([]string{ - "Compare to the dev version of this stage.", - }, "\n"), - }, - }, - { - Name: "policy", - Type: "string", - Description: cli.Description{ - Short: "Path to policy pack", - Long: "Run policy pack validation against the preview changes.", - }, - }, - { - Name: "json", - Type: "bool", - Description: cli.Description{ - Short: "Output as JSON", - Long: "Output the diff result as JSON to stdout. Useful for CI pipelines and scripting.", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst diff --stage production", - Description: cli.Description{ - Short: "See changes to production", - }, - }, - { - Content: "sst diff --stage production --policy ./policies/production", - Description: cli.Description{ - Short: "See changes to production with policy validation", - }, - }, - { - Content: "sst diff --json", - Description: cli.Description{ - Short: "Output changes as JSON", - }, - }, - }, - Run: func(c *cli.Cli) error { - jsonOutput := c.Bool("json") - - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - exclude := []string{} - if c.String("exclude") != "" { - exclude = strings.Split(c.String("exclude"), ",") - } - - var wg errgroup.Group - outputs := []*apitype.ResOutputsEvent{} - uiOptions := []ui.Option{} - if jsonOutput { - // Keep stdout machine-readable when attached to a TTY. - uiOptions = append(uiOptions, ui.WithSilent) - } - u := ui.New(c.Context, uiOptions...) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - - events := bus.SubscribeAll() - wg.Go(func() error { - for evt := range events { - if !jsonOutput { - u.Event(evt) - } - switch evt := evt.(type) { - case *apitype.ResOutputsEvent: - outputs = append(outputs, evt) - } - } - return nil - }) - defer u.Destroy() - err = p.Run(c.Context, &project.StackInput{ - Command: "diff", - ServerPort: s.Port, - Dev: c.Bool("dev"), - Target: target, - Exclude: exclude, - Verbose: c.Bool("verbose"), - PolicyPath: c.String("policy"), - }) - bus.Unsubscribe(events) - close(events) - c.Cancel() - if waitErr := wg.Wait(); waitErr != nil && err == nil { - err = waitErr - } - - if jsonOutput { - if jsonErr := renderDiffJSON(outputs); jsonErr != nil { - return jsonErr - } - return err - } - if err != nil { - return err - } - return renderDiffText(outputs, u) - }, -} - -func textDiffIcon(op apitype.OpType) string { - switch op { - case apitype.OpImport, apitype.OpReplace, apitype.OpCreate: - return ui.TEXT_SUCCESS_BOLD.Render("+") - case apitype.OpDelete: - return ui.TEXT_DANGER_BOLD.Render("-") - case apitype.OpUpdate: - return ui.TEXT_WARNING_BOLD.Render("*") - default: - return "" - } -} - -func renderDiffJSON(outputs []*apitype.ResOutputsEvent) error { - filtered := make([]apitype.StepEventMetadata, 0, len(outputs)) - for _, output := range outputs { - if output.Metadata.Op == apitype.OpSame { - continue - } - filtered = append(filtered, output.Metadata) - } - encoder := json.NewEncoder(os.Stdout) - encoder.SetIndent("", " ") - return encoder.Encode(filtered) -} - -func renderDiffText(outputs []*apitype.ResOutputsEvent, u *ui.UI) error { - rendered := make([]*apitype.ResOutputsEvent, 0, len(outputs)) - for _, output := range outputs { - if textDiffIcon(output.Metadata.Op) == "" { - continue - } - rendered = append(rendered, output) - } - if len(rendered) == 0 { - fmt.Println( - ui.TEXT_HIGHLIGHT_BOLD.Render("➜"), - ui.TEXT_NORMAL_BOLD.Render(" No changes"), - ) - fmt.Println() - return nil - } - for _, output := range rendered { - icon := textDiffIcon(output.Metadata.Op) - fmt.Println(icon, "", ui.TEXT_NORMAL_BOLD.Render(u.FormatURN(output.Metadata.URN))) - sorted := make([]string, 0, len(output.Metadata.DetailedDiff)) - for path := range output.Metadata.DetailedDiff { - sorted = append(sorted, path) - } - sort.Strings(sorted) - for _, path := range sorted { - diff := output.Metadata.DetailedDiff[path] - label := "" - if diff.Kind == apitype.DiffUpdate { - label = ui.TEXT_WARNING_BOLD.Render("*") - } - if diff.Kind == apitype.DiffDelete { - label = ui.TEXT_DANGER_BOLD.Render("-") - } - if diff.Kind == apitype.DiffAdd { - label = ui.TEXT_SUCCESS_BOLD.Render("+") - } - if diff.Kind == apitype.DiffAddReplace { - label = ui.TEXT_SUCCESS_BOLD.Render("+") - } - if diff.Kind == apitype.DiffUpdateReplace { - label = ui.TEXT_WARNING_BOLD.Render("*") - } - if diff.Kind == apitype.DiffDeleteReplace { - label = ui.TEXT_DANGER_BOLD.Render("-") - } - fmt.Print(" ", label+" ", strings.TrimSpace(path)) - value, _ := jsonpath.Read(output.Metadata.New.Outputs, "$."+path) - if path == "__provider" { - value = "code changed" - } - if value != nil { - formatted := "" - switch value.(type) { - case string: - formatted = value.(string) - default: - bytes, _ := json.MarshalIndent(value, "", " ") - formatted = string(bytes) - } - lines := strings.Split(string(formatted), "\n") - fmt.Print(" = ") - for index, line := range lines { - if index > 0 { - fmt.Print(" ") - } - fmt.Print(ui.TEXT_DIM.Render(line) + "\n") - } - } else { - fmt.Println() - } - } - fmt.Println() - } - return nil -} diff --git a/cmd/sst/diff_test.go b/cmd/sst/diff_test.go deleted file mode 100644 index a91df6cfca..0000000000 --- a/cmd/sst/diff_test.go +++ /dev/null @@ -1,135 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "io" - "os" - "testing" - - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" -) - -func captureStdout(t *testing.T, fn func()) string { - t.Helper() - old := os.Stdout - r, w, err := os.Pipe() - if err != nil { - t.Fatal(err) - } - os.Stdout = w - - fn() - - w.Close() - os.Stdout = old - - var buf bytes.Buffer - io.Copy(&buf, r) - return buf.String() -} - -func TestRenderDiffJSON_NoChanges(t *testing.T) { - out := captureStdout(t, func() { - if err := renderDiffJSON(nil); err != nil { - t.Fatal(err) - } - }) - - var result []apitype.StepEventMetadata - if err := json.Unmarshal([]byte(out), &result); err != nil { - t.Fatalf("invalid JSON: %v\noutput: %s", err, out) - } - if len(result) != 0 { - t.Fatalf("expected 0 changes, got %d", len(result)) - } -} - -func TestRenderDiffJSON_WithChanges(t *testing.T) { - outputs := []*apitype.ResOutputsEvent{ - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:ecs/service:Service::MyService", - Type: "aws:ecs/service:Service", - Op: apitype.OpUpdate, - DetailedDiff: map[string]apitype.PropertyDiff{ - "healthCheckGracePeriodSeconds": {Kind: apitype.DiffUpdate}, - "tags": {Kind: apitype.DiffAdd}, - }, - New: &apitype.StepEventStateMetadata{ - Outputs: map[string]interface{}{ - "healthCheckGracePeriodSeconds": 35, - "tags": map[string]interface{}{"env": "dev"}, - }, - }, - }, - }, - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:s3/bucket:Bucket::MyBucket", - Type: "aws:s3/bucket:Bucket", - Op: apitype.OpCreate, - }, - }, - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:ecs/service:Service::Replacement", - Type: "aws:ecs/service:Service", - Op: apitype.OpCreateReplacement, - }, - }, - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:lambda/function:Function::OldFn", - Type: "aws:lambda/function:Function", - Op: apitype.OpSame, - }, - }, - } - - out := captureStdout(t, func() { - if err := renderDiffJSON(outputs); err != nil { - t.Fatal(err) - } - }) - - var result []apitype.StepEventMetadata - if err := json.Unmarshal([]byte(out), &result); err != nil { - t.Fatalf("invalid JSON: %v\noutput: %s", err, out) - } - - // OpSame should be filtered out, but replacement steps should be kept. - if len(result) != 3 { - t.Fatalf("expected 3 changes, got %d", len(result)) - } - - update := result[0] - if update.Op != apitype.OpUpdate { - t.Errorf("expected op 'update', got %q", update.Op) - } - if update.URN != "urn:pulumi:dev::app::aws:ecs/service:Service::MyService" { - t.Errorf("unexpected URN: %s", update.URN) - } - if update.Type != "aws:ecs/service:Service" { - t.Errorf("unexpected type: %s", update.Type) - } - if len(update.DetailedDiff) != 2 { - t.Fatalf("expected 2 detailed diff entries, got %d", len(update.DetailedDiff)) - } - if update.DetailedDiff["healthCheckGracePeriodSeconds"].Kind != apitype.DiffUpdate { - t.Errorf("expected diff kind 'update', got %q", update.DetailedDiff["healthCheckGracePeriodSeconds"].Kind) - } - if update.DetailedDiff["tags"].Kind != apitype.DiffAdd { - t.Errorf("expected diff kind 'add', got %q", update.DetailedDiff["tags"].Kind) - } - - create := result[1] - if create.Op != apitype.OpCreate { - t.Errorf("expected op 'create', got %q", create.Op) - } - - replacement := result[2] - if replacement.Op != apitype.OpCreateReplacement { - t.Errorf("expected op 'create-replacement', got %q", replacement.Op) - } -} diff --git a/cmd/sst/init.go b/cmd/sst/init.go deleted file mode 100644 index 00c3abedd2..0000000000 --- a/cmd/sst/init.go +++ /dev/null @@ -1,310 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "log/slog" - "os" - "os/exec" - "slices" - "strings" - "time" - - "github.com/briandowns/spinner" - "github.com/fatih/color" - "github.com/manifoldco/promptui" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/npm" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" -) - -func CmdInit(cli *cli.Cli) error { - if _, err := os.Stat("sst.config.ts"); err == nil { - color.New(color.FgRed, color.Bold).Print("Γ—") - color.New(color.FgWhite, color.Bold).Println(" SST project already exists") - return nil - } - - logo := []string{ - ``, - ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—`, - ` β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•`, - ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ `, - ` β•šβ•β•β•β•β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ `, - ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ `, - ` β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β• β•šβ•β• `, - ``, - } - - fmt.Print("\033[?25l") - // orange - fmt.Print("\033[38;2;255;127;0m") - for _, line := range logo { - for _, char := range line { - fmt.Print(string(char)) - time.Sleep(5 * time.Millisecond) - } - fmt.Println() - } - fmt.Print("\033[?25h") - - var template string - - hints := []string{} - files, err := os.ReadDir(".") - if err != nil { - return err - } - for _, file := range files { - if file.IsDir() { - continue - } - hints = append(hints, file.Name()) - } - - color.New(color.FgBlue, color.Bold).Print(">") - switch { - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "next.config") }): - fmt.Println(" Next.js detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - modify the tsconfig.json") - fmt.Println(" - add sst to package.json") - template = "nextjs" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "react-router.config") }): - fmt.Println(" React Router detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - modify the tsconfig.json") - fmt.Println(" - add sst to package.json") - template = "react-router" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "astro.config") }): - fmt.Println(" Astro detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - modify the tsconfig.json") - fmt.Println(" - add sst to package.json") - template = "astro" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return strings.HasPrefix(s, "app.config") && fileContains(s, "@solidjs/start") - }): - fmt.Println(" SolidStart detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "solid-start" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return strings.HasPrefix(s, "app.config") && fileContains(s, "@tanstack/") - }): - fmt.Println(" TanStack Start detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "tanstack-start" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "nuxt.config") }): - fmt.Println(" Nuxt detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "nuxt" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "svelte.config") }): - fmt.Println(" SvelteKit detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "svelte-kit" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return strings.HasPrefix(s, "remix.config") || - (strings.HasPrefix(s, "vite.config") && fileContains(s, "@remix-run/dev")) - }): - fmt.Println(" Remix detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "remix" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return (strings.HasPrefix(s, "vite.config") && fileContains(s, "@analogjs/platform")) - }): - fmt.Println(" Analog detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "analog" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "angular.json") }): - fmt.Println(" Angular detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "angular" - break - - case slices.Contains(hints, "package.json"): - fmt.Println(" JS project detected. This will...") - fmt.Println(" - use the JS template") - fmt.Println(" - create an sst.config.ts") - template = "js" - break - - default: - fmt.Println(" No frontend detected. This will...") - fmt.Println(" - use the vanilla template") - fmt.Println(" - create an sst.config.ts") - template = "vanilla" - break - } - fmt.Println() - - p := promptui.Select{ - Items: []string{"Yes", "No"}, - Label: "β€β€β€Ž β€ŽContinue", - HideSelected: true, - HideHelp: true, - } - - if !cli.Bool("yes") { - _, confirm, err := p.Run() - if err != nil { - return util.NewReadableError(err, "") - } - if confirm == "No" { - return nil - } - } - - color.New(color.FgGreen, color.Bold).Print("βœ“") - color.New(color.FgWhite).Println(" Template:", template) - fmt.Println() - - home := "aws" - if template == "vanilla" || template == "js" { - p = promptui.Select{ - Label: "β€β€β€Ž β€ŽWhere do you want to deploy your app? You can change this later", - HideSelected: true, - Items: []string{"aws", "cloudflare"}, - HideHelp: true, - } - _, home, err = p.Run() - if err != nil { - return util.NewReadableError(err, "") - } - color.New(color.FgGreen, color.Bold).Print("βœ“") - color.New(color.FgWhite).Println(" Using: " + home) - fmt.Println() - } - - if template == "js" { - template = "js-" + home - } - - instructions, err := project.Create(template, home) - if err != nil { - return err - } - var cmd *exec.Cmd - - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - spin.Suffix = " Installing providers..." - spin.Start() - - cfgPath, err := cli.Discover() - if err != nil { - return err - } - proj, err := project.New(&project.ProjectConfig{ - Config: cfgPath, - Stage: "sst", - Version: version, - }) - if err != nil { - return err - } - if err := proj.CopyPlatform(version); err != nil { - return err - } - - if err := proj.Install(); err != nil { - return err - } - - cwd, err := os.Getwd() - mgr, _ := npm.DetectPackageManager(cwd) - if mgr != "" { - cmd = process.Command(mgr, "install") - spin.Suffix = " Installing dependencies..." - spin.Start() - slog.Info("installing deps", "args", cmd.Args) - cmd.Run() - spin.Stop() - } - - if template == "nextjs" { - hasEslint := slices.ContainsFunc(hints, func(s string) bool { - return strings.Contains(strings.ToLower(s), "eslint") - }) - - if hasEslint { - configFile := "sst.config.ts" - content, err := os.ReadFile(configFile) - if err != nil { - return err - } - - newContent := "// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n" + string(content) - err = os.WriteFile(configFile, []byte(newContent), 0644) - if err != nil { - return err - } - } - } - - spin.Stop() - - if len(instructions) == 0 { - color.New(color.FgGreen, color.Bold).Print("βœ“") - color.New(color.FgWhite).Println(" Done πŸŽ‰") - } - if len(instructions) > 0 { - for i, instruction := range instructions { - if i == 0 { - color.New(color.FgBlue, color.Bold).Print(">") - fmt.Println(" " + instruction) - continue - } - color.New(color.FgWhite).Println(" " + instruction) - } - } - fmt.Println() - return nil -} - -func fileContains(filePath string, str string) bool { - file, err := os.Open(filePath) - if err != nil { - return false - } - defer file.Close() - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - if strings.Contains(scanner.Text(), str) { - return true - } - } - - if err := scanner.Err(); err != nil { - return false - } - - return false -} diff --git a/cmd/sst/main.go b/cmd/sst/main.go deleted file mode 100644 index 134803cea1..0000000000 --- a/cmd/sst/main.go +++ /dev/null @@ -1,1041 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "log/slog" - "os" - "os/signal" - "os/user" - "path/filepath" - "strings" - "syscall" - "time" - - "github.com/briandowns/spinner" - "github.com/fatih/color" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/errors" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/global" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/telemetry" -) - -var version = "dev" - -func getAliasName(entry *project.ProviderLockEntry) string { - name := entry.Name - if entry.Name == entry.Package { - name = entry.Alias - } - for _, suffix := range []string{"official", "community"} { - if !strings.HasSuffix(entry.Name, "-"+suffix) && !strings.HasSuffix(entry.Package, "-"+suffix) { - continue - } - name = strings.TrimSuffix(name, "-"+suffix) - name = strings.TrimSuffix(name, suffix) - } - return name -} - -func main() { - // check if node_modules/.bin/sst exists - nodeModulesBinPath := filepath.Join("node_modules", ".bin", "sst") - binary, _ := os.Executable() - if _, err := os.Stat(nodeModulesBinPath); err == nil && !strings.Contains(binary, "node_modules") && os.Getenv("SST_SKIP_LOCAL") != "true" && version != "dev" { - // forward command to node_modules/.bin/sst - fmt.Fprintln(os.Stderr, ui.TEXT_WARNING_BOLD.Render("Warning: ")+"You are using a global installation of SST but you also have a local installation specified in your package.json. The local installation will be used but you should typically run it through your package manager.") - cmd := process.Command(nodeModulesBinPath, os.Args[1:]...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "SST_SKIP_LOCAL=true") - if err := cmd.Run(); err != nil { - os.Exit(1) - } - return - } - telemetry.SetVersion(version) - defer telemetry.Close() - defer process.Cleanup() - telemetry.Track("cli.start", map[string]interface{}{ - "args": os.Args[1:], - }) - err := run() - if err != nil { - err := errors.Transform(err) - errorMessage := err.Error() - truncated := errorMessage - if len(errorMessage) > 255 { - truncated = errorMessage[:255] - } - telemetry.Track("cli.error", map[string]interface{}{ - "error": truncated, - }) - if readableErr, ok := err.(*util.ReadableError); ok { - slog.Error("exited with error", "err", readableErr.Unwrap()) - msg := readableErr.Error() - if msg != "" { - ui.Error(readableErr.Error()) - if readableErr.IsHinted() { - fmt.Fprintln(os.Stderr, " "+ui.TEXT_DIM.Render(readableErr.Unwrap().Error())) - } - } - } else { - slog.Error("exited with error", "err", err) - // check if context cancelled error - if err != context.Canceled { - ui.Error("Unexpected error occurred. Please run with --print-logs or check .sst/log/sst.log if available.") - } - } - telemetry.Close() - os.Exit(1) - return - } - telemetry.Track("cli.success", map[string]interface{}{}) -} - -func run() error { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - interruptChannel := make(chan os.Signal, 1) - signal.Notify(interruptChannel, syscall.SIGINT, syscall.SIGTERM) - go func() { - <-interruptChannel - slog.Info("interrupted") - cancel() - }() - c, err := cli.New(ctx, cancel, root, version) - if err != nil { - return err - } - _, err = user.Current() - if err != nil { - return err - } - - if !flag.SST_SKIP_DEPENDENCY_CHECK { - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - spin.Suffix = " Download dependencies..." - if global.NeedsPulumi() { - spin.Suffix = " Installing pulumi..." - spin.Start() - err := global.InstallPulumi(ctx) - if err != nil { - spin.Stop() - return util.NewHintedError(err, "Could not install pulumi") - } - } - if global.NeedsBun() { - spin.Suffix = " Installing bun..." - spin.Start() - err := global.InstallBun(ctx) - if err != nil { - spin.Stop() - return util.NewHintedError(err, "Could not install bun") - } - } - spin.Stop() - } - return c.Run() -} - -var root = &cli.Command{ - Name: "sst", - Description: cli.Description{ - Short: "deploy anything", - Long: strings.Join([]string{ - "The CLI helps you manage your SST apps.", - "", - "If you are using SST as a part of your Node project, we recommend installing it locally.", - "```bash", - "npm install sst", - "```", - "---", - "If you are not using Node, you can install the CLI globally.", - "```bash", - "curl -fsSL https://sst.dev/install | bash", - "```", - "", - ":::note", - "The CLI currently supports macOS, Linux, and WSL. Windows support is in beta.", - ":::", - "", - "To install a specific version.", - "", - "```bash \"VERSION=0.0.403\"", - "curl -fsSL https://sst.dev/install | VERSION=0.0.403 bash", - "```", - "---", - "#### With a package manager", - "", - "You can also use a package manager to install the CLI.", - "", - "- **macOS**", - "", - " The CLI is available via a Homebrew Tap, and as downloadable binary in the [releases](https://github.com/sst/sst/releases/latest).", - "", - " ```bash", - " brew install sst/tap/sst", - "", - " # Upgrade", - " brew upgrade sst", - " ```", - "", - " You might have to run `brew upgrade sst`, before the update.", - "", - "- **Linux**", - "", - " The CLI is available as downloadable binaries in the [releases](https://github.com/sst/sst/releases/latest). Download the `.deb` or `.rpm` and install with `sudo dpkg -i` and `sudo rpm -i`.", - "", - " For Arch Linux, it's available in the [aur](https://aur.archlinux.org/packages/sst-bin).", - "---", - "#### Usage", - "", - "Once installed you can run the commands using.", - "", - "```bash", - "sst [command]", - "```", - "", - "The CLI takes a few global flags. For example, the deploy command takes the `--stage` flag", - "", - "```bash", - "sst deploy --stage production", - "```", - "---", - "#### Environment variables", - "", - "You can access any environment variables set in the CLI in your `sst.config.ts` file. For example, running:", - "", - "```bash", - "ENV_VAR=123 sst deploy", - "```", - "", - "Will let you access `ENV_VAR` through `process.env.ENV_VAR`.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "stage", - Type: "string", - Description: cli.Description{ - Short: "The stage to deploy to", - Long: strings.Join([]string{ - "Set the stage the CLI is running on.", - "", - "```bash frame=\"none\"", - "sst [command] --stage production", - "```", - "", - "The stage is a string that is used to prefix the resources in your app. This allows you to have multiple _environments_ of your app running in the same account.", - "", - ":::tip", - "Changing the stage will redeploy your app to a new stage with new resources. The old resources will still be around in the old stage.", - ":::", - "", - "You can also use the `SST_STAGE` environment variable.", - "```bash frame=\"none\"", - "SST_STAGE=dev sst [command]", - "```", - "This can also be declared in a `.env` file or in the CLI session.", - "", - "If the stage is not passed in, then the CLI will:", - "", - "1. Use the username on the local machine.", - " - If the username is `root`, `admin`, `prod`, `dev`, `production`, then it will prompt for a stage name.", - "2. Store this in the `.sst/stage` file and reads from it in the future.", - "", - "This stored stage is called your **personal stage**.", - }, "\n"), - }, - }, - { - Name: "verbose", - Type: "bool", - Description: cli.Description{ - Short: "Enable verbose logging", - Long: strings.Join([]string{ - "", - "Prints extra information to the log files in the `.sst/` directory.", - "", - "```bash", - "sst [command] --verbose", - "```", - "", - "To also view this on the screen, use the `--print-logs` flag.", - "", - }, "\n"), - }, - }, - { - Name: "print-logs", - Type: "bool", - Description: cli.Description{ - Short: "Print logs to stderr", - Long: strings.Join([]string{ - "", - "Print the logs to the screen. These are logs that are written to the `.sst/` directory.", - "", - "```bash", - "sst [command] --print-logs", - "```", - "It can also be set using the `SST_PRINT_LOGS` environment variable.", - "", - "```bash", - "SST_PRINT_LOGS=1 sst [command]", - "```", - "This is useful when running in a CI environment.", - "", - }, "\n"), - }, - }, - { - Name: "config", - Type: "string", - Description: cli.Description{ - Short: "Path to the config file", - Long: strings.Join([]string{ - "", - "Optionally, pass in a path to the SST config file. This default to", - "`sst.config.ts` in the current directory.", - "", - "```bash", - "sst --config path/to/config.ts [command]", - "```", - "", - "This is useful when your monorepo has multiple SST apps in it.", - "You can run the SST CLI for a specific app by passing in the path to", - "its config file.", - }, "\n"), - }, - }, - { - Name: "help", - Type: "bool", - Description: cli.Description{ - Short: "Print help", - Long: strings.Join([]string{ - "Prints help for the given command.", - "", - "```sh frame=\"none\"", - "sst [command] --help", - "```", - "", - "Or the global help.", - "", - "```sh frame=\"none\"", - "sst --help", - "```", - }, "\n"), - }, - }, - }, - Children: []*cli.Command{ - { - Name: "init", - Description: cli.Description{ - Short: "Initialize a new project", - Long: strings.Join([]string{ - "Initialize a new project in the current directory. This will create a `sst.config.ts` and `sst install` your providers.", - "", - "If this is run in a Next.js, Remix, Astro, or SvelteKit project, it'll init SST in drop-in mode.", - "", - "To skip the interactive confirmation after detecting the framework.", - "", - "```bash frame=\"none\"", - "sst init --yes", - "```", - }, "\n"), - }, - Run: CmdInit, - Flags: []cli.Flag{ - { - Name: "yes", - Type: "bool", - Description: cli.Description{ - Short: "Skip interactive confirmation", - Long: "Skip interactive confirmation for detected framework.", - }, - }, - }, - }, - { - Name: "ui", - Hidden: true, - Run: CmdUI, - Flags: []cli.Flag{ - { - Name: "filter", - Type: "string", - Description: cli.Description{ - Short: "Filter events", - Long: "Filter events.", - }, - }, - }, - }, - { - Name: "dev", - Description: cli.Description{ - Short: "Run in development mode", - Long: strings.Join([]string{ - "Run your app in dev mode. By default, this starts a multiplexer with processes that", - " deploy your app, run your functions, and start your frontend.", - "", - ":::note", - "The tabbed terminal UI is only available on Linux/macOS and WSL.", - ":::", - "", - "Each process is run in a separate tab that you can click on in the sidebar.", - "", - "![sst dev multiplexer mode](../../../../assets/docs/cli/sst-dev-multiplexer-mode.png)", - "", - "The multiplexer makes it so that you won't have to start your frontend or", - "your container applications separately.", - "", - "", - "", - "Here's what happens when you run `sst dev`.", - "", - "- Deploy most of your resources as-is.", - "- Except for components that have a `dev` prop.", - " - `Function` components are run [_Live_](/docs/live/) in the **Functions** tab.", - " - `Task` components have their _stub_ versions deployed that proxy the task", - " and run their `dev.command` in the **Tasks** tab.", - " - Frontends like `Nextjs`, `Remix`, `Astro`, `StaticSite`, etc. have their dev", - " servers started in a separate tab and are not deployed.", - " - `Service` components are not deployed, and instead their `dev.command` is", - " started in a separate tab.", - " - `Postgres`, `Aurora`, and `Redis` link to a local database if the `dev` prop is", - " set.", - "- Start an [`sst tunnel`](#tunnel) session in a new tab if your app has a `Vpc`", - " with `bastion` enabled.", - "- Load any [linked resources](/docs/linking) in the environment.", - "- Start a watcher for your `sst.config.ts` and redeploy any changes.", - "", - ":::note", - "The `Service` component and the frontends like `Nextjs` or `StaticSite` are not", - "deployed by `sst dev`.", - ":::", - "", - "Optionally, you can disable the multiplexer and not spawn any child", - "processes by running `sst dev` in basic mode.", - "", - "```bash frame=\"none\"", - "sst dev --mode=basic", - "```", - "", - "This will only deploy your app and run your functions. If you are coming from SST", - "v2, this is how `sst dev` used to work.", - "", - "However in `basic` mode, you'll need to start your frontend separately by running", - "`sst dev` in a separate terminal session by passing in the command. For example:", - "", - "```bash frame=\"none\"", - "sst dev next dev", - "```", - "", - "By wrapping your command, it'll load your [linked resources](/docs/linking) in the", - "environment.", - "", - "To pass in a flag to the command, use `--`.", - "", - "```bash frame=\"none\"", - "sst dev -- next dev --turbo", - "```", - "", - "You can also disable the tabbed terminal UI by running `sst dev` in", - "mono mode.", - "", - "```bash frame=\"none\"", - "sst dev --mode=mono", - "```", - "", - "Unlike `basic` mode, this'll spawn child processes. But instead of", - "a tabbed UI it'll show their outputs in a single stream.", - "", - "This is used by default in Windows.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "mode", - Type: "string", - Description: cli.Description{ - Short: "mode=mono to turn off multiplexer. mode=basic to not spawn any child processes", - Long: "Defaults to using `multi` mode. Use `mono` to get a single stream of all child process logs or `basic` to not spawn any child processes.", - }, - }, - { - Name: "policy", - Type: "string", - Description: cli.Description{ - Short: "Path to policy pack", - Long: "Run policy pack validation against the preview changes.", - }, - }, - }, - Args: []cli.Argument{ - { - Name: "command", - Description: cli.Description{ - Short: "The command to run", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst dev", - Description: cli.Description{ - Short: "Brings up your entire app - should be all you need", - }, - }, - { - Content: "sst dev next dev", - Description: cli.Description{ - Short: "Start a command connected to a running sst dev session", - }, - }, - { - Content: "sst dev -- next dev --turbo", - Description: cli.Description{ - Short: "Use -- to pass flags to the command", - }, - }, - }, - Run: CmdMosaic, - }, - CmdDeploy, - CmdDiff, - { - Name: "add", - Description: cli.Description{ - Short: "Add a new provider", - Long: strings.Join([]string{ - "Adds and installs the given provider. For example,", - "", - "```bash frame=\"none\"", - "sst add aws", - "```", - "", - "This command will:", - "", - "1. Installs the package for the AWS provider.", - "2. Add `aws` to the globals in your `sst.config.ts`.", - "3. And, add it to your `providers`.", - "", - "```ts title=\"sst.config.ts\"", - "{", - " providers: {", - " aws: {", - " package: \"@pulumi/aws\",", - " version: \"6.27.0\"", - " }", - " }", - "}", - "```", - "", - "You can use any provider listed in the [Directory](/docs/all-providers#directory).", - "", - ":::note", - "Running `sst add aws` above is the same as manually adding the provider to your config and running `sst install`.", - ":::", - "", - "By default, the latest version of the provider is installed. If you want to use a specific version, you can change it in your config.", - "", - "```ts title=\"sst.config.ts\"", - "{", - " providers: {", - " aws: {", - " package: \"@pulumi/aws\",", - " version: \"6.26.0\"", - " }", - " }", - "}", - "```", - "", - "You'll need to run `sst install` if you update the `providers` in your config.", - "", - "By default, these packages are fetched from the NPM registry. If you want to use a different registry, you can set the `NPM_REGISTRY` environment variable.", - "", - "```bash frame=\"none\"", - "NPM_REGISTRY=https://my-registry.com sst add aws", - "```", - "", - "You can also set the registry in your `.npmrc` file. If your registry requires authentication, SST supports `_authToken`, `_auth`, and `username`/`_password` from `.npmrc`.", - }, "\n"), - }, - Args: []cli.Argument{ - { - Name: "provider", - Required: true, - Description: cli.Description{ - Short: "The provider to add", - Long: "The provider to add.", - }, - }, - }, - Run: func(cli *cli.Cli) error { - pkg := cli.Positional(0) - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - spin.Suffix = " Adding provider..." - spin.Start() - defer spin.Stop() - cfgPath, err := cli.Discover() - if err != nil { - return err - } - stage, err := cli.Stage(cfgPath) - if err != nil { - return err - } - p, err := project.New(&project.ProjectConfig{ - Version: version, - Config: cfgPath, - Stage: stage, - }) - if err != nil { - return err - } - if !p.CheckPlatform(version) { - err := p.CopyPlatform(version) - if err != nil { - return err - } - } - entry, err := project.FindProvider(pkg, "latest", pkg) - if err != nil { - return util.NewReadableError(err, "Could not find provider "+pkg) - } - providerName := getAliasName(entry) - err = p.Add(providerName, entry.Version, entry.Package) - if err != nil { - return util.NewReadableError(err, err.Error()) - } - spin.Suffix = " Downloading provider..." - p, err = project.New(&project.ProjectConfig{ - Version: version, - Config: cfgPath, - Stage: stage, - }) - if err != nil { - return err - } - err = p.Install() - if err != nil { - return err - } - spin.Stop() - ui.Success(fmt.Sprintf("Added provider \"%s\". You can create resources with `new %s.SomeResource()`.", entry.Alias, entry.Alias)) - return nil - }, - }, - { - Name: "install", - Description: cli.Description{ - Short: "Install all the providers", - Long: strings.Join([]string{ - "Installs the providers in your `sst.config.ts`. You'll need this command when:", - "", - "1. You add a new provider to the `providers` or `home` in your config.", - "2. Or, when you want to install new providers after you `git pull` some changes.", - "", - ":::tip", - "The `sst install` command is similar to `npm install`.", - ":::", - "", - "Behind the scenes, it installs the packages for your providers and adds the providers to your globals.", - "", - "If you don't have a version specified for your providers in your `sst.config.ts`, it'll install their latest versions.", - }, "\n"), - }, - Run: func(cli *cli.Cli) error { - cfgPath, err := cli.Discover() - if err != nil { - return err - } - - stage, err := cli.Stage(cfgPath) - if err != nil { - return err - } - - p, err := project.New(&project.ProjectConfig{ - Version: version, - Config: cfgPath, - Stage: stage, - }) - if err != nil { - return err - } - - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - defer spin.Stop() - spin.Suffix = " Installing providers..." - spin.Start() - if !p.CheckPlatform(version) { - err := p.CopyPlatform(version) - if err != nil { - return err - } - } - - err = p.Install() - if err != nil { - return err - } - spin.Stop() - ui.Success("Installed providers") - return nil - }, - }, - { - Name: "secret", - Description: cli.Description{ - Short: "Manage secrets", - Long: strings.Join([]string{ - "Manage the secrets in your app defined with `sst.Secret`.", - "", - "", - "", - "The `--fallback` flag can be used to manage the fallback values of a secret.", - "", - "Applies to all the sub-commands in `sst secret`.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "fallback", - Type: "bool", - Description: cli.Description{ - Short: "Manage the fallback values of secrets", - Long: "Manage the fallback values of secrets.", - }, - }, - }, - Children: []*cli.Command{ - CmdSecretSet, - CmdSecretRemove, - CmdSecretLoad, - CmdSecretList, - }, - }, - { - Name: "shell", - Args: []cli.Argument{ - { - Name: "command", - Description: cli.Description{ - Short: "A command to run", - Long: "A command to run.", - }, - }, - }, - Flags: []cli.Flag{ - { - Name: "target", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - }, - Description: cli.Description{ - Short: "Run a command with linked resources", - Long: strings.Join([]string{ - "Run a command with **all the resources linked** to the environment. This is useful for running scripts against your infrastructure.", - "", - "For example, let's say you have the following resources in your app.", - "", - "```js title=\"sst.config.ts\" {5,9}", - "new sst.aws.Bucket(\"MyMainBucket\");", - "new sst.aws.Bucket(\"MyAdminBucket\");", - "```", - "", - "We can now write a script that'll can access both these resources with the [JS SDK](/docs/reference/sdk/).", - "", - "```js title=\"my-script.js\" \"Resource.MyMainBucket.name\" \"Resource.MyAdminBucket.name\"", - "import { Resource } from \"sst\";", - "", - "console.log(Resource.MyMainBucket.name, Resource.MyAdminBucket.name);", - "```", - "", - "And run the script with `sst shell`.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst shell node my-script.js", - "```", - "", - "This'll have access to all the buckets from above.", - "", - ":::tip", - "Run the command with `--` to pass arguments to it.", - ":::", - "", - "To pass arguments into the script, you'll need to prefix it using `--`.", - "", - "```bash frame=\"none\" frame=\"none\" /--(?!a)/", - "sst shell -- node my-script.js --arg1 --arg2", - "```", - "", - "If no command is passed in, it opens a shell session with the linked resources.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst shell", - "```", - "", - "This is useful if you want to run multiple commands, all while accessing the resources in your app.", - "", - "Optionally, you can run this for a specific component by passing in the name of the component.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst shell --target MyComponent", - "```", - "", - "Here the linked resources for `MyComponent` and its environment variables are available.", - }, "\n"), - }, - Examples: []cli.Example{ - { - Content: "sst shell", - Description: cli.Description{ - Short: "Open a shell session", - }, - }, - }, - Run: CmdShell, - }, - { - Name: "remove", - Description: cli.Description{ - Short: "Remove your application", - Long: strings.Join([]string{ - "Removes your application. By default, it removes your personal stage.", - "", - ":::tip", - "The resources in your app are removed based on the `removal` setting in your `sst.config.ts`.", - ":::", - "", - "This does not remove the SST _state_ and _bootstrap_ resources in your account as these might still be in use by other apps. You can remove them manually if you want to reset your account, [learn more](/docs/state/#reset).", - "", - "Optionally, remove your app from a specific stage.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst remove --stage production", - "```", - "You can also remove a specific component by passing in the name of the component from your `sst.config.ts`.", - "", - "```bash frame=\"none\"", - "sst remove --target MyComponent", - "```", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Type: "string", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - }, - Run: CmdRemove, - }, - { - Name: "unlock", - Description: cli.Description{ - Short: "Clear any locks on the app state", - Long: strings.Join([]string{ - "When you run `sst deploy`, it acquires a lock on your state file to prevent concurrent deploys.", - "", - "However, if something unexpectedly kills the `sst deploy` process, or if you manage to run `sst deploy` concurrently, the lock might not be released.", - "", - "This should not usually happen, but it can prevent you from deploying. You can run `sst unlock` to release the lock.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - err = p.ForceUnlock() - if err != nil { - return err - } - color.New(color.FgGreen, color.Bold).Print("βœ“ ") - color.New(color.FgWhite).Print(" Unlocked the app state for: ") - color.New(color.FgWhite, color.Bold).Println(p.App().Name, "/", p.App().Stage) - return nil - }, - }, - CmdVersion, - { - Name: "upgrade", - Description: cli.Description{ - Short: "Upgrade the CLI", - Long: strings.Join([]string{ - "Upgrade the CLI to the latest version. Or optionally, pass in a version to upgrade to.", - "", - "```bash frame=\"none\"", - "sst upgrade 0.10", - "```", - }, "\n"), - }, - Args: cli.ArgumentList{ - { - Name: "version", - Description: cli.Description{ - Short: "A version to upgrade to", - Long: "A version to upgrade to.", - }, - }, - }, - Run: CmdUpgrade, - }, - { - Name: "telemetry", Description: cli.Description{ - Short: "Manage telemetry settings", - Long: strings.Join([]string{ - "Manage telemetry settings.", - "", - "SST collects completely anonymous telemetry data about general usage. We track:", - "- Version of SST in use", - "- Command invoked, `sst dev`, `sst deploy`, etc.", - "- General machine information, like the number of CPUs, OS, CI/CD environment, etc.", - "", - "This is completely optional and can be disabled at any time.", - "", - "You can also opt-out by setting an environment variable: `SST_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.", - }, "\n"), - }, - Children: []*cli.Command{ - { - Name: "enable", - Description: cli.Description{ - Short: "Enable telemetry", - Long: "Enable telemetry.", - }, - Run: func(cli *cli.Cli) error { - return telemetry.Enable() - }, - }, - { - Name: "disable", - Description: cli.Description{ - Short: "Disable telemetry", - Long: "Disable telemetry.", - }, - Run: func(cli *cli.Cli) error { - return telemetry.Disable() - }, - }, - }, - }, - { - Name: "introspect", - Hidden: true, - Run: func(cli *cli.Cli) error { - data, err := json.MarshalIndent(cli.Path()[0], "", " ") - if err != nil { - return err - } - fmt.Println(string(data)) - return nil - }, - }, - { - Name: "print-and-not-quit", - Hidden: true, - Run: func(cli *cli.Cli) error { - lines := strings.Split(os.Getenv("SST_DEV_COMMAND_MESSAGE"), "\n") - for _, line := range lines { - fmt.Println(line) - } - <-cli.Context.Done() - return nil - }, - }, - { - Name: "refresh", - Description: cli.Description{ - Short: "Refresh the local app state", - Long: strings.Join([]string{ - "Compares your local state with the state of the resources in the cloud provider. Any changes that are found are adopted into your local state. It will:", - "", - "1. Go through every single resource in your state.", - "2. Make a call to the cloud provider to check the resource.", - " - If the configs are different, it'll **update the state** to reflect the change.", - " - If the resource doesn't exist anymore, it'll **remove it from the state**.", - "", - ":::note", - "The `sst refresh` does not make changes to the resources in the cloud provider.", - ":::", - "", - "By default, this refreshes the stage as it would be deployed using `sst deploy`. If the stage was deployed using `sst dev`, use the `--dev` flag.", - "", - "```bash frame=\"none\"", - "sst refresh --dev", - "```", - "", - "You can also refresh a specific component by passing in the name of the component.", - "", - "```bash frame=\"none\"", - "sst refresh --target MyComponent", - "```", - "", - "Alternatively, exclude a specific component from the refresh.", - "", - "```bash frame=\"none\"", - "sst refresh --exclude MyComponent", - "```", - "", - "This is useful for cases where you want to ensure that your local state is in sync with your cloud provider. [Learn more about how state works](/docs/providers/#how-state-works).", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Type: "string", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - { - Name: "exclude", - Type: "string", - Description: cli.Description{ - Short: "Exclude a component", - Long: "Exclude the specified component from the operation.", - }, - }, - { - Name: "dev", - Type: "bool", - Description: cli.Description{ - Short: "Refresh in dev mode", - Long: "Refresh the dev version of this stage.", - }, - }, - }, - Run: CmdRefresh, - }, - CmdState, - CmdCert, - CmdTunnel, - CmdDiagnostic, - }, -} diff --git a/cmd/sst/mosaic.go b/cmd/sst/mosaic.go deleted file mode 100644 index 17b62fcdb7..0000000000 --- a/cmd/sst/mosaic.go +++ /dev/null @@ -1,497 +0,0 @@ -package main - -import ( - "fmt" - "io" - "log/slog" - "os" - "os/exec" - "path/filepath" - goruntime "runtime" - "strings" - "time" - - "github.com/kballard/go-shellquote" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/cloudflare" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/monoplexer" - "github.com/sst/sst/v3/cmd/sst/mosaic/multiplexer" - "github.com/sst/sst/v3/cmd/sst/mosaic/socket" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/path" - "github.com/sst/sst/v3/pkg/runtime" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -func CmdMosaic(c *cli.Cli) error { - cwd, _ := os.Getwd() - var wg errgroup.Group - - child := os.Getenv("SST_CHILD") - // spawning child process - if len(c.Arguments()) > 0 || child != "" { - args := c.Arguments() - slog.Info("dev mode with target", "args", c.Arguments()) - cfgPath, err := c.Discover() - stage, err := c.Stage(cfgPath) - if err != nil { - return err - } - url, err := server.Discover(cfgPath, stage) - if err != nil { - return err - } - slog.Info("found server", "url", url) - evts, err := dev.Stream(c.Context, url, project.CompleteEvent{}) - if err != nil { - return err - } - cwd, _ := os.Getwd() - currentDir := cwd - for { - nodeBinPath := filepath.Join(currentDir, "node_modules", ".bin") - newPath := nodeBinPath + string(os.PathListSeparator) + os.Getenv("PATH") - os.Setenv("PATH", newPath) - parentDir := filepath.Dir(currentDir) - if parentDir == currentDir { - break - } - currentDir = parentDir - } - var cmd *exec.Cmd - var last *dev.EnvResponse - processExited := make(chan bool) - timeout := time.Minute * 50 - timer := time.NewTimer(timeout) - defer timer.Stop() - - for { - select { - case <-c.Context.Done(): - return nil - case <-processExited: - c.Cancel() - continue - case <-timer.C: - last = nil - go func() { - evts <- true - }() - fmt.Println("\n" + ui.TEXT_DIM.Render("[timeout]")) - timer.Reset(timeout) - continue - case _, ok := <-evts: - if !ok { - return nil - } - query := "directory=" + cwd - if child != "" { - query = "name=" + child - } - nextEnv, err := dev.Env(c.Context, query, url) - if err != nil { - return err - } - if _, ok := nextEnv.Env["AWS_ACCESS_KEY_ID"]; ok { - timeout = time.Minute * 45 - } - if last == nil || diff(last.Env, nextEnv.Env) || last.Command != nextEnv.Command { - if cmd != nil && cmd.Process != nil { - process.Kill(cmd.Process) - <-processExited - fmt.Println("\n[restarting]") - } - fields, _ := shellquote.Split(nextEnv.Command) - if len(args) > 0 { - fields = args - } - cmd = process.Command( - fields[0], - fields[1:]..., - ) - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "FORCE_COLOR=1") - for k, v := range nextEnv.Env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v)) - } - process.DetachSession(cmd) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if child != "" && flag.SST_LOG_CHILDREN { - slog.Info("creating log file for child process") - file, err := os.Create(filepath.Join(path.ResolveLogDir(cfgPath), child+".log")) - if err != nil { - return err - } - cmd.Stdout = io.MultiWriter(file, os.Stdout) - cmd.Stderr = io.MultiWriter(file, os.Stderr) - } - cmd.Start() - go func() { - cmd.Wait() - processExited <- true - }() - } - last = nextEnv - } - } - } - - if os.Getenv("SST_SERVER") != "" { - return util.NewReadableError(nil, "The dev command for this process does not look right. Check your dev script in package.json to make sure it is simply starting your process and not running `sst dev`. More info here: https://sst.dev/docs/reference/cli/#dev") - } - - p, err := c.InitProject() - if err != nil { - return err - } - if p.App().Protect { - return project.ErrProtectedDevStage - } - policyPath := c.String("policy") - if policyPath != "" { - if _, err := p.ResolvePolicyPackPath(policyPath); err != nil { - return util.NewReadableError(nil, err.Error()) - } - } - os.Setenv("SST_STAGE", p.App().Stage) - slog.Info("mosaic", "project", p.PathRoot()) - - wg.Go(func() error { - defer c.Cancel() - return watcher.Start(c.Context, watcher.WatchConfig{ - Root: p.PathRoot(), - Watch: p.App().Watch, - }) - }) - - server, err := server.New() - if err != nil { - return err - } - - wg.Go(func() error { - defer c.Cancel() - return dev.Start(c.Context, p, server) - }) - - wg.Go(func() error { - defer c.Cancel() - return socket.Start(c.Context, p, server) - }) - - wg.Go(func() error { - evts := bus.Subscribe(&runtime.BuildInput{}) - for { - select { - case <-c.Context.Done(): - return nil - case evt := <-evts: - switch evt := evt.(type) { - case *runtime.BuildInput: - p.Runtime.AddTarget(evt) - } - } - } - }) - - os.Setenv("SST_SERVER", fmt.Sprintf("http://localhost:%v", server.Port)) - for name, a := range p.App().Providers { - args := a - switch name { - case "aws": - if flag.SST_SKIP_APPSYNC { - continue - } - wg.Go(func() error { - defer c.Cancel() - return aws.Start(c.Context, p, server, args.(map[string]interface{})) - }) - case "cloudflare": - wg.Go(func() error { - defer c.Cancel() - return cloudflare.Start(c.Context, p, args.(map[string]interface{})) - }) - } - } - - wg.Go(func() error { - defer c.Cancel() - return server.Start(c.Context, p) - }) - - currentExecutable, _ := os.Executable() - - mode := c.String("mode") - - if mode == "" { - mode = "multi" - if goruntime.GOOS == "windows" { - mode = "mono" - } - } - - evts := bus.Subscribe(&project.CompleteEvent{}) - - wg.Go(func() error { - defer c.Cancel() - return deployer.Start(c.Context, p, server, policyPath) - }) - - if mode == "multi" { - multi, err := multiplexer.New() - if err != nil { - return err - } - multiEnv := append( - c.Env(), - fmt.Sprintf("SST_SERVER=http://localhost:%v", server.Port), - "SST_STAGE="+p.App().Stage, - ) - serverURL := fmt.Sprintf("http://localhost:%v", server.Port) - _, hasAWS := p.App().Providers["aws"] - showWorkers := p.App().Home == "cloudflare" && !hasAWS - fnTitle := "Functions" - fnFilter := "function" - if showWorkers { - fnTitle = "Workers" - fnFilter = "worker" - } - multi.AddProcess(multiplexer.PaneConfig{ - Key: "deploy", - Args: []string{currentExecutable, "ui", "--filter=sst"}, - Icon: "⑆", - Title: "SST", - Autostart: true, - Env: append(multiEnv, "SST_LOG="+p.PathLog("ui-deploy")), - }) - multi.AddProcess(multiplexer.PaneConfig{ - Key: "function", - Args: []string{currentExecutable, "ui", "--filter=" + fnFilter}, - Icon: "Ξ»", - Title: fnTitle, - Autostart: true, - Filterable: true, - FilterTitle: fnTitle, - FilterSubtitle: "Select to filter logs", - OnFilterChanged: func(value string) { - bus.Publish(&ui.PaneFilterEvent{PaneKey: "function", Value: value}) - }, - ListOptions: func() []multiplexer.FilterOption { - completed, err := dev.Completed(c.Context, serverURL) - if err != nil || completed == nil { - return nil - } - var options []multiplexer.FilterOption - for _, r := range completed.Resources { - if string(r.Type) == "sst:aws:Function" || string(r.Type) == "sst:cloudflare:Worker" { - name := r.URN.Name() - handler := name - if meta, ok := r.Outputs["_metadata"].(map[string]interface{}); ok { - if h, ok := meta["handler"].(string); ok { - handler = h - } - } - options = append(options, multiplexer.FilterOption{ - Label: name, - Description: handler, - Value: name, - }) - } - } - return options - }, - Env: append(multiEnv, "SST_LOG="+p.PathLog("ui-function")), - }) - defer func() { - multi.Exit() - }() - go func() { - multi.Start() - }() - wg.Go(func() error { - defer c.Cancel() - for { - select { - case <-c.Context.Done(): - return nil - case unknown := <-evts: - switch evt := unknown.(type) { - case *project.CompleteEvent: - for _, d := range evt.Devs { - if d.Command == "" { - continue - } - dir := filepath.Join(cwd, d.Directory) - title := d.Title - if title == "" { - title = d.Name - } - multi.AddProcess(multiplexer.PaneConfig{ - Key: d.Name, - Args: []string{currentExecutable, "dev"}, - Icon: "β†’", - Title: title, - Cwd: dir, - Killable: true, - Autostart: d.Autostart, - Env: append([]string{"SST_CHILD=" + d.Name}, multiEnv...), - }) - } - for name := range evt.Tunnels { - multi.AddProcess(multiplexer.PaneConfig{ - Key: "tunnel", - Args: []string{currentExecutable, "tunnel", "--stage", p.App().Stage}, - Icon: "β‡Œ", - Title: "Tunnel", - Killable: true, - Autostart: true, - Env: append(multiEnv, "SST_LOG="+p.PathLog("tunnel_"+name)), - }) - } - if len(evt.Tasks) > 0 { - multi.AddProcess(multiplexer.PaneConfig{ - Key: "task", - Args: []string{currentExecutable, "ui", "--filter=task"}, - Icon: "⧉", - Title: "Tasks", - Autostart: true, - Filterable: true, - FilterTitle: "Tasks", - FilterSubtitle: "Select a task to filter logs", - OnFilterChanged: func(value string) { - bus.Publish(&ui.PaneFilterEvent{PaneKey: "task", Value: value}) - }, - ListOptions: func() []multiplexer.FilterOption { - completed, err := dev.Completed(c.Context, serverURL) - if err != nil || completed == nil { - return nil - } - var options []multiplexer.FilterOption - for name, t := range completed.Tasks { - desc := "" - if t.Command != nil { - desc = *t.Command - } - options = append(options, multiplexer.FilterOption{ - Label: name, - Description: desc, - Value: name, - }) - } - return options - }, - Env: append(multiEnv, "SST_LOG="+p.PathLog("ui-task")), - }) - } - var fnNames []string - for _, r := range evt.Resources { - if string(r.Type) == "sst:aws:Function" || string(r.Type) == "sst:cloudflare:Worker" { - fnNames = append(fnNames, r.URN.Name()) - } - } - multi.CheckFilter("function", fnNames) - var taskNames []string - for name := range evt.Tasks { - taskNames = append(taskNames, name) - } - multi.CheckFilter("task", taskNames) - break - } - } - } - }) - } - - if mode == "basic" { - wg.Go(func() error { - <-server.Ready - return CmdUI(c) - }) - } - - if mode == "mono" { - mono := monoplexer.New() - _, hasAWS := p.App().Providers["aws"] - fnTitle := "Function" - fnFilter := "function" - if p.App().Home == "cloudflare" && !hasAWS { - fnTitle = "Worker" - fnFilter = "worker" - } - mono.AddProcess("deploy", []string{currentExecutable, "ui", "--filter=sst"}, "", "SST", true) - mono.AddProcess("function", []string{currentExecutable, "ui", "--filter=" + fnFilter}, "", fnTitle, true) - - wg.Go(func() error { - defer c.Cancel() - return mono.Start(c.Context) - }) - - wg.Go(func() error { - defer c.Cancel() - for { - select { - case <-c.Context.Done(): - return nil - case unknown := <-evts: - switch evt := unknown.(type) { - case *project.CompleteEvent: - for _, d := range evt.Devs { - if d.Command == "" { - continue - } - dir := filepath.Join(cwd, d.Directory) - words, _ := shellquote.Split(d.Command) - title := d.Title - if title == "" { - title = d.Name - } - mono.AddProcess( - d.Name, - append([]string{currentExecutable, "dev", "--"}, words...), - dir, - title, - d.Autostart, - "SST_CHILD="+d.Name, - ) - } - for range evt.Tunnels { - mono.AddProcess("tunnel", []string{currentExecutable, "tunnel", "--stage", p.App().Stage}, "", "Tunnel", true) - } - break - } - } - } - }) - } - - err = wg.Wait() - slog.Info("done mosaic", "err", err) - return err -} - -func diff(a map[string]string, b map[string]string) bool { - if len(a) != len(b) { - return true - } - for k, v := range a { - if strings.HasPrefix(k, "AWS_") { - continue - } - if b[k] != v { - return true - } - } - return false -} diff --git a/cmd/sst/mosaic/aws/appsync/appsync.go b/cmd/sst/mosaic/aws/appsync/appsync.go deleted file mode 100644 index f2bb97726c..0000000000 --- a/cmd/sst/mosaic/aws/appsync/appsync.go +++ /dev/null @@ -1,393 +0,0 @@ -package appsync - -import ( - "bytes" - "context" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "encoding/json" - "fmt" - "io" - "log/slog" - "net/http" - "net/url" - "os" - "sync" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" - "github.com/gorilla/websocket" - "github.com/sst/sst/v3/pkg/id" -) - -var log = slog.Default().With("service", "appsync.connection") - -var ErrSubscriptionFailed = fmt.Errorf("appsync subscription failed") -var ErrConnectionFailed = fmt.Errorf("appsync connection failed") - -func getProxyURL(isHTTPS bool) (*url.URL, error) { - var proxyEnv string - - if isHTTPS { - proxyEnv = os.Getenv("HTTPS_PROXY") - if proxyEnv == "" { - proxyEnv = os.Getenv("https_proxy") - } - } - - if proxyEnv == "" { - proxyEnv = os.Getenv("HTTP_PROXY") - if proxyEnv == "" { - proxyEnv = os.Getenv("http_proxy") - } - } - - if proxyEnv != "" { - noProxy := os.Getenv("NO_PROXY") - if noProxy == "" { - noProxy = os.Getenv("no_proxy") - } - - if noProxy == "*" { - return nil, nil - } - } - - if proxyEnv == "" { - return nil, nil - } - - return url.Parse(proxyEnv) -} - -func getHTTPClient() *http.Client { - proxyURL, err := getProxyURL(true) - if err != nil { - log.Warn("failed to parse proxy URL", "err", err) - return http.DefaultClient - } - - if proxyURL == nil { - return http.DefaultClient - } - - log.Info("using proxy for HTTP requests", "proxy", proxyURL.String()) - return &http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyURL(proxyURL), - }, - } -} - -type Connection struct { - conn *websocket.Conn - cfg aws.Config - httpEndpoint string - realtimeEndpoint string - subscriptions map[string]SubscriptionInfo - lock sync.Mutex -} - -type SubscriptionInfo struct { - Channel string - Out chan string -} - -type SubscribeEvent struct { - Type string `json:"type"` - ID string `json:"id"` - Channel string `json:"channel"` - Authorization interface{} `json:"authorization"` -} - -func Dial( - ctx context.Context, - cfg aws.Config, - httpEndpoint string, - realtimeEndpoint string, -) (*Connection, error) { - result := &Connection{ - cfg: cfg, - httpEndpoint: httpEndpoint, - realtimeEndpoint: realtimeEndpoint, - subscriptions: map[string]SubscriptionInfo{}, - } - - err := result.connect(ctx) - if err != nil { - return nil, err - } - - go func() { - <-ctx.Done() - if result.conn != nil { - result.conn.Close() - } - for _, item := range result.subscriptions { - close(item.Out) - } - }() - return result, nil -} - -func (c *Connection) connect(ctx context.Context) error { - log.Info("connecting") - auth, err := c.getAuth(ctx, map[string]interface{}{}) - if err != nil { - return err - } - authJson, err := json.Marshal(auth) - if err != nil { - return err - } - auth64 := base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString(authJson) - - // Configure WebSocket dialer with proxy support - dialer := websocket.Dialer{ - Subprotocols: []string{"aws-appsync-event-ws", "header-" + auth64}, - } - - // Add proxy support to WebSocket dialer - proxyURL, err := getProxyURL(true) // WebSocket uses wss:// (HTTPS) - if err != nil { - log.Warn("failed to parse proxy URL", "err", err) - } else if proxyURL != nil { - dialer.Proxy = http.ProxyURL(proxyURL) - log.Info("using proxy for WebSocket connection", "proxy", proxyURL.String()) - } - - conn, _, err := dialer.DialContext(ctx, "wss://"+c.realtimeEndpoint+"/event/realtime", nil) - if err != nil { - return err - } - conn.WriteJSON(map[string]interface{}{ - "type": "connection_init", - }) - c.conn = conn - - msg := map[string]interface{}{} - err = conn.ReadJSON(&msg) - if err != nil { - log.Error("write to connection failed", "err", err) - return ErrConnectionFailed - } - log.Info("connect message", "msg", msg) - if msg["type"] != "connection_ack" { - return ErrConnectionFailed - } - duration := time.Millisecond * time.Duration(msg["connectionTimeoutMs"].(float64)) - - timer := time.NewTimer(duration) - go func() { - select { - case <-ctx.Done(): - return - case <-timer.C: - log.Info("connection timeout") - conn.Close() - for { - select { - case <-ctx.Done(): - return - default: - err := c.connect(ctx) - if err != nil { - log.Info("failed to reconnect", "err", err) - time.Sleep(time.Second * 5) - continue - } - for id, sub := range c.subscriptions { - log.Info("resubscribing", "channel", sub.Channel, "id", id) - err := c.subscribe(ctx, sub.Channel, id) - if err != nil { - log.Error("failed to resubscribe", "err", err) - continue - } - } - return - } - } - } - }() - - go func() { - for { - msg := map[string]interface{}{} - err := conn.ReadJSON(&msg) - if err != nil { - log.Info("connection closed") - timer.Reset(1 * time.Millisecond) - return - } - log.Info("msg", "type", msg["type"], "id", msg["id"]) - - if msg["type"] == "connection_ack" { - duration = time.Millisecond * time.Duration(msg["connectionTimeoutMs"].(float64)) - log.Info("keep alive set", "duration", duration.Seconds()) - timer.Reset(duration) - } - - if msg["type"] == "ka" { - timer.Reset(duration) - } - - if msg["type"] == "subscribe_success" { - id := msg["id"].(string) - if item, ok := c.subscriptions[id]; ok { - item.Out <- "ok" - } - } - if t := msg["type"]; t == "data" { - id := msg["id"].(string) - if item, ok := c.subscriptions[id]; ok { - item.Out <- msg["event"].(string) - } - } - } - }() - - return nil -} - -func (c *Connection) Subscribe(ctx context.Context, channel string) (chan string, error) { - out := make(chan string, 1000) - subscriptionID := id.Ascending() - c.subscriptions[subscriptionID] = SubscriptionInfo{ - Channel: channel, - Out: out, - } - err := c.subscribe(ctx, channel, subscriptionID) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *Connection) subscribe(ctx context.Context, channel string, subscriptionID string) error { - c.lock.Lock() - defer c.lock.Unlock() - auth, err := c.getAuth(ctx, map[string]interface{}{ - "channel": channel, - }) - if err != nil { - return err - } - old := c.subscriptions[subscriptionID].Out - tmp := make(chan string, 1) - defer func() { - c.subscriptions[subscriptionID] = SubscriptionInfo{ - Channel: channel, - Out: old, - } - }() - c.subscriptions[subscriptionID] = SubscriptionInfo{ - Channel: channel, - Out: tmp, - } - c.conn.WriteJSON(map[string]interface{}{ - "type": "subscribe", - "id": subscriptionID, - "channel": channel, - "authorization": auth, - }) - select { - case <-tmp: - log.Info("subscribed", "channel", channel, "id", subscriptionID) - return nil - case <-time.After(time.Second * 3): - return ErrSubscriptionFailed - } -} - -func (c *Connection) getAuth(ctx context.Context, body interface{}) (interface{}, error) { - credentials, err := c.cfg.Credentials.Retrieve(ctx) - if err != nil { - return nil, err - } - bodyJson, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader := bytes.NewReader(bodyJson) - req, err := http.NewRequest("POST", - "https://"+c.httpEndpoint+"/event", - bodyReader) - if err != nil { - return nil, err - } - req.Header.Set("accept", "application/json, text/javascript") - req.Header.Set("content-encoding", "amz-1.0") - req.Header.Set("content-type", "application/json; charset=UTF-8") - - // Compute SHA256 hash of the payload - h := sha256.New() - h.Write(bodyJson) - payloadHash := hex.EncodeToString(h.Sum(nil)) - - signer := v4.NewSigner() - err = signer.SignHTTP(ctx, - credentials, - req, - payloadHash, - "appsync", - c.cfg.Region, - time.Now(), - ) - auth := map[string]string{ - "accept": req.Header.Get("accept"), - "content-encoding": req.Header.Get("content-encoding"), - "content-type": req.Header.Get("content-type"), - "host": req.Host, - "x-amz-date": req.Header.Get("x-amz-date"), - "Authorization": req.Header.Get("Authorization"), - } - if req.Header.Get("X-Amz-Security-Token") != "" { - auth["X-Amz-Security-Token"] = req.Header.Get("X-Amz-Security-Token") - } - return auth, nil -} - -func (c *Connection) Publish(ctx context.Context, channel string, event interface{}) error { - credentials, err := c.cfg.Credentials.Retrieve(ctx) - if err != nil { - return err - } - eventJson, err := json.Marshal(event) - body, err := json.Marshal(map[string]interface{}{ - "channel": channel, - "events": []string{string(eventJson)}, - }) - if err != nil { - return err - } - req, err := http.NewRequest("POST", "https://"+c.httpEndpoint+"/event", bytes.NewReader(body)) - if err != nil { - return err - } - req.Header.Set("Content-Type", "application/json") - signer := v4.NewSigner() - h := sha256.New() - h.Write(body) - payloadHash := hex.EncodeToString(h.Sum(nil)) - err = signer.SignHTTP(ctx, credentials, req, payloadHash, "appsync", c.cfg.Region, time.Now()) - if err != nil { - return err - } - - // Use HTTP client that respects proxy settings - client := getHTTPClient() - resp, err := client.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - bodyBytes, _ := io.ReadAll(resp.Body) - return fmt.Errorf("request failed with status %d: %s", resp.StatusCode, string(bodyBytes)) - } - - return nil -} diff --git a/cmd/sst/mosaic/aws/aws.go b/cmd/sst/mosaic/aws/aws.go deleted file mode 100644 index c035d7238f..0000000000 --- a/cmd/sst/mosaic/aws/aws.go +++ /dev/null @@ -1,91 +0,0 @@ -package aws - -import ( - "context" - "fmt" - "log/slog" - "net/http" - "time" - - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/appsync" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/bridge" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/server" -) - -var ErrIoTDelay = fmt.Errorf("iot not available") -var ErrAppsyncNotReady = fmt.Errorf("appsync not ready") - -func Start( - ctx context.Context, - p *project.Project, - s *server.Server, - args map[string]interface{}, -) error { - uncasted, _ := p.Provider("aws") - prov := uncasted.(*provider.AwsProvider) - config := prov.Config() - slog.Info("getting endpoint") - prefix := fmt.Sprintf("/sst/%s/%s", p.App().Name, p.App().Stage) - - rest, realtime, err := prov.ResolveAppSync(ctx) - if err != nil { - return err - } - slog.Info("found appsync", "rest", rest, "realtime", realtime) - - now := time.Now() - for { - slog.Info("checking if appsync is ready") - _, err := http.Get("https://" + rest) - if err != nil { - slog.Error("appsync not ready", "err", err) - if time.Since(now) > time.Second*10 { - return ErrAppsyncNotReady - } - select { - case <-ctx.Done(): - return nil - case <-time.After(time.Second): - continue - } - } - break - } - conn, err := appsync.Dial(ctx, config, rest, realtime) - if err != nil { - return err - } - client := bridge.NewClient(ctx, conn, "dev", prefix) - - functionsChan := make(chan bridge.Message, 1000) - tasksChan := make(chan bridge.Message, 1000) - - in := input{ - config: config, - server: s, - client: client, - project: p, - prefix: prefix, - } - - in.msg = functionsChan - go function(ctx, in) - - in.msg = tasksChan - go task(ctx, in) - - for { - select { - case <-ctx.Done(): - return nil - case msg := <-client.Read(): - if msg.Source == "dev" { - continue - } - functionsChan <- msg - tasksChan <- msg - } - } -} diff --git a/cmd/sst/mosaic/aws/bridge/bridge.go b/cmd/sst/mosaic/aws/bridge/bridge.go deleted file mode 100644 index c6abb6edb8..0000000000 --- a/cmd/sst/mosaic/aws/bridge/bridge.go +++ /dev/null @@ -1,282 +0,0 @@ -package bridge - -import ( - "context" - "encoding/base64" - "encoding/json" - "io" - "iter" - "log/slog" - - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/appsync" - "github.com/sst/sst/v3/pkg/id" -) - -type Packet struct { - Type MessageType `json:"type"` - Source string `json:"source"` - ID string `json:"id"` - Index int `json:"index"` - Data string `json:"data"` - Final bool `json:"final"` -} - -type MessageType int - -const ( - MessageInit MessageType = iota - MessagePing - MessageNext - MessageResponse - MessageError - MessageReboot - MessageInitError - - MessageTaskStart - MessageTaskComplete -) - -type Message struct { - ID string - Type MessageType - Source string - Body io.Reader -} - -type Writer struct { - conn *appsync.Connection - message MessageType - source string - channel string - event string - buffer []byte - position int - index int - id string - streaming bool -} - -type InitBody struct { - FunctionID string `json:"functionID"` - Environment []string `json:"environment"` -} - -type TaskStartBody struct { - TaskID string `json:"taskID"` - Environment []string `json:"environment"` -} - -type TaskCompleteBody struct { -} - -type PingBody struct { -} - -type RebootBody struct { -} - -func newWriter(conn *appsync.Connection, source string, channel string, message MessageType) *Writer { - return &Writer{ - id: id.Ascending(), - conn: conn, - source: source, - message: message, - channel: channel, - buffer: make([]byte, BUFFER_SIZE), - position: 0, - index: 0, - } -} - -func (w *Writer) SetID(id string) { - w.id = id -} - -func (w *Writer) SetStreaming(streaming bool) { - w.streaming = streaming -} - -const BUFFER_SIZE = 1024 * 128 - -func (w *Writer) Write(p []byte) (int, error) { - total := 0 - - for total < len(p) { - space := cap(w.buffer) - w.position - toWrite := min(space, len(p)-total) - copy(w.buffer[w.position:], p[total:total+toWrite]) - w.position += toWrite - total += toWrite - if w.position == len(w.buffer) { - if err := w.Flush(false); err != nil { - return total, err - } - } - } - if w.streaming && w.position > 0 { - if err := w.Flush(false); err != nil { - return total, err - } - } - return total, nil -} - -func (w *Writer) Flush(final bool) error { - if !final && w.position == 0 { - return nil - } - encoded := base64.StdEncoding.EncodeToString(w.buffer[:w.position]) - err := w.conn.Publish(context.Background(), w.channel, Packet{ - ID: w.id, - Index: w.index, - Type: w.message, - Source: w.source, - Data: encoded, - Final: final, - }) - w.index++ - if err != nil { - return err - } - w.buffer = make([]byte, BUFFER_SIZE) - w.position = 0 - return nil -} - -func (w *Writer) Close() error { - return w.Flush(true) -} - -type Client struct { - as *appsync.Connection - prefix string - pending map[string]chan []byte - out chan Message - source string -} - -func NewClient(ctx context.Context, as *appsync.Connection, source string, prefix string) *Client { - slog.Info("subscribing to", "prefix", prefix+"/in") - sub, _ := as.Subscribe(ctx, prefix+"/in") - result := &Client{ - as: as, - source: source, - prefix: prefix, - pending: map[string]chan []byte{}, - out: make(chan Message, 1000), - } - go func() { - for packet := range sorted(ctx, sub) { - pending, ok := result.pending[packet.ID] - if !ok { - pending = make(chan []byte, 100) - result.pending[packet.ID] = pending - result.out <- Message{ - Type: packet.Type, - ID: packet.ID, - Source: packet.Source, - Body: NewChannelReader(ctx, pending), - } - } - bytes, err := base64.StdEncoding.DecodeString(packet.Data) - if err != nil { - continue - } - pending <- bytes - if packet.Final { - close(pending) - delete(result.pending, packet.ID) - } - } - }() - - return result -} - -func (c *Client) Read() <-chan Message { - return c.out -} - -func (c *Client) NewWriter(message MessageType, destination string) *Writer { - writer := newWriter(c.as, c.source, destination, message) - return writer -} - -type ChannelReader struct { - ch chan []byte - buffer []byte - err error - ctx context.Context -} - -func NewChannelReader(ctx context.Context, ch chan []byte) *ChannelReader { - return &ChannelReader{ - ch: ch, - buffer: nil, - err: nil, - ctx: ctx, - } -} - -func (r *ChannelReader) Read(p []byte) (n int, err error) { - if len(r.buffer) == 0 && r.err == nil { - select { - case chunk, ok := <-r.ch: - if !ok { - return 0, io.EOF - } - r.buffer = chunk - case <-r.ctx.Done(): - return 0, io.EOF - } - } - if len(r.buffer) > 0 { - n = copy(p, r.buffer) - r.buffer = r.buffer[n:] - return n, nil - } - - if r.err != nil { - return 0, r.err - } - return 0, io.EOF -} - -func sorted(ctx context.Context, sub chan string) iter.Seq[Packet] { - return func(yield func(Packet) bool) { - history := make(map[string]map[int]Packet) - next := map[string]int{} - for { - select { - case <-ctx.Done(): - return - case msg := <-sub: - var packet Packet - json.Unmarshal([]byte(msg), &packet) - slog.Info("got packet", "id", packet.ID, "type", packet.Type, "from", packet.Source) - unprocessed, ok := history[packet.ID] - if !ok { - unprocessed = map[int]Packet{} - history[packet.ID] = unprocessed - } - unprocessed[packet.Index] = packet - for { - index := next[packet.ID] - envelope, ok := unprocessed[index] - if !ok { - break - } - delete(unprocessed, index) - next[envelope.ID] = index + 1 - if !yield(envelope) { - return - } - if envelope.Final { - delete(history, envelope.ID) - } - } - } - - } - } -} diff --git a/cmd/sst/mosaic/aws/function.go b/cmd/sst/mosaic/aws/function.go deleted file mode 100644 index ae7406d761..0000000000 --- a/cmd/sst/mosaic/aws/function.go +++ /dev/null @@ -1,481 +0,0 @@ -package aws - -import ( - "bufio" - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "log/slog" - "net/http" - "os" - "path/filepath" - "strings" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/bridge" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/runtime" - "github.com/sst/sst/v3/pkg/server" -) - -type FunctionInvokedEvent struct { - FunctionID string - WorkerID string - RequestID string - Input []byte -} - -type FunctionResponseEvent struct { - FunctionID string - WorkerID string - RequestID string - Output []byte -} - -type FunctionErrorEvent struct { - FunctionID string - WorkerID string - RequestID string - ErrorType string `json:"errorType"` - ErrorMessage string `json:"errorMessage"` - Trace []string `json:"trace"` -} - -type FunctionBuildEvent struct { - FunctionID string - Errors []string -} - -type FunctionLogEvent struct { - FunctionID string - WorkerID string - RequestID string - Line string -} - -type input struct { - config aws.Config - project *project.Project - server *server.Server - client *bridge.Client - msg chan bridge.Message - prefix string -} - -func function(ctx context.Context, input input) { - log := slog.Default().With("service", "aws.function") - server := fmt.Sprintf("localhost:%d/lambda/", input.server.Port) - type WorkerInfo struct { - FunctionID string - WorkerID string - Worker runtime.Worker - CurrentRequestID string - Env []string - Streaming bool - } - workerShutdownChan := make(chan *WorkerInfo, 1000) - nextChan := map[string]chan io.Reader{} - workers := map[string]*WorkerInfo{} - evts := bus.Subscribe(&watcher.FileChangedEvent{}, &project.CompleteEvent{}, &runtime.BuildInput{}, &FunctionInvokedEvent{}) - go fileLogger(input.project) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/invocation/next`, func(w http.ResponseWriter, r *http.Request) { - log.Info("got next request", "workerID", r.PathValue("workerID")) - workerID := r.PathValue("workerID") - ch := nextChan[workerID] - select { - case <-r.Context().Done(): - log.Info("worker disconnected", "workerID", workerID) - return - case reader := <-ch: - log.Info("worker got next request", "workerID", workerID) - resp, _ := http.ReadResponse(bufio.NewReader(reader), r) - requestID := resp.Header.Get("lambda-runtime-aws-request-id") - for key, values := range resp.Header { - for _, value := range values { - w.Header().Add(key, value) - } - } - w.WriteHeader(resp.StatusCode) - - var buf bytes.Buffer - tee := io.TeeReader(resp.Body, &buf) - io.Copy(w, tee) - workerInfo, ok := workers[workerID] - if ok { - bus.Publish(&FunctionInvokedEvent{ - FunctionID: workerInfo.FunctionID, - WorkerID: workerID, - RequestID: requestID, - Input: buf.Bytes(), - }) - } - } - }) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/init/error`, func(w http.ResponseWriter, r *http.Request) { - workerID := r.PathValue("workerID") - log.Info("got init error", "workerID", workerID, "requestID", r.PathValue("requestID")) - writer := input.client.NewWriter(bridge.MessageInitError, input.prefix+"/"+workerID+"/in") - var buf bytes.Buffer - tee := io.TeeReader(r.Body, &buf) - io.Copy(writer, tee) - writer.Close() - w.WriteHeader(200) - info, ok := workers[workerID] - if ok { - fee := &FunctionErrorEvent{ - FunctionID: info.FunctionID, - WorkerID: info.WorkerID, - } - json.Unmarshal(buf.Bytes(), &fee) - bus.Publish(fee) - } - }) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/invocation/{requestID}/response`, func(w http.ResponseWriter, r *http.Request) { - workerID := r.PathValue("workerID") - requestID := r.PathValue("requestID") - log.Info("got response", "workerID", workerID, "requestID", r.PathValue("requestID")) - writer := input.client.NewWriter(bridge.MessageResponse, input.prefix+"/"+workerID+"/in") - writer.SetID(requestID) - info, ok := workers[workerID] - if ok && info.Streaming { - writer.SetStreaming(true) - io.Copy(writer, r.Body) - writer.Close() - w.WriteHeader(202) - bus.Publish(&FunctionResponseEvent{ - FunctionID: info.FunctionID, - WorkerID: workerID, - RequestID: requestID, - Output: []byte("[streaming response]"), - }) - } else { - var buf bytes.Buffer - tee := io.TeeReader(r.Body, &buf) - io.Copy(writer, tee) - writer.Close() - w.WriteHeader(202) - if ok { - bus.Publish(&FunctionResponseEvent{ - FunctionID: info.FunctionID, - WorkerID: workerID, - RequestID: requestID, - Output: buf.Bytes(), - }) - } - } - }) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/invocation/{requestID}/error`, func(w http.ResponseWriter, r *http.Request) { - workerID := r.PathValue("workerID") - requestID := r.PathValue("requestID") - log.Info("got error", "workerID", workerID, "requestID", r.PathValue("requestID")) - writer := input.client.NewWriter(bridge.MessageError, input.prefix+"/"+workerID+"/in") - writer.SetID(requestID) - var buf bytes.Buffer - tee := io.TeeReader(r.Body, &buf) - io.Copy(writer, tee) - writer.Close() - w.WriteHeader(202) - info, ok := workers[workerID] - if ok { - fee := &FunctionErrorEvent{ - FunctionID: info.FunctionID, - WorkerID: info.WorkerID, - RequestID: requestID, - } - json.Unmarshal(buf.Bytes(), &fee) - bus.Publish(fee) - } - }) - - workerEnv := map[string][]string{} - builds := map[string]*runtime.BuildOutput{} - targets := map[string]*runtime.BuildInput{} - - getBuildOutput := func(functionID string) *runtime.BuildOutput { - build := builds[functionID] - if build != nil { - return build - } - target, _ := targets[functionID] - build, err := input.project.Runtime.Build(ctx, target) - if err == nil { - bus.Publish(&FunctionBuildEvent{ - FunctionID: functionID, - Errors: build.Errors, - }) - } else { - bus.Publish(&FunctionBuildEvent{ - FunctionID: functionID, - Errors: []string{err.Error()}, - }) - } - if err != nil || len(build.Errors) > 0 { - delete(builds, functionID) - return nil - } - builds[functionID] = build - return build - } - - startWorker := func(functionID string, workerID string) bool { - build := getBuildOutput(functionID) - if build == nil { - return false - } - target, ok := targets[functionID] - if !ok { - return false - } - worker, err := input.project.Runtime.Run(ctx, &runtime.RunInput{ - CfgPath: input.project.PathConfig(), - Runtime: target.Runtime, - Server: server + workerID, - WorkerID: workerID, - FunctionID: functionID, - Build: build, - Env: workerEnv[workerID], - }) - if err != nil { - log.Error("failed to run worker", "error", err) - return false - } - streaming := false - for _, e := range workerEnv[workerID] { - if e == "SST_FUNCTION_STREAMING=true" { - streaming = true - break - } - } - info := &WorkerInfo{ - FunctionID: functionID, - Worker: worker, - WorkerID: workerID, - Streaming: streaming, - } - go func() { - logs := worker.Logs() - scanner := bufio.NewScanner(logs) - for scanner.Scan() { - line := scanner.Text() - bus.Publish(&FunctionLogEvent{ - FunctionID: functionID, - WorkerID: workerID, - RequestID: info.CurrentRequestID, - Line: line, - }) - } - workerShutdownChan <- info - }() - workers[workerID] = info - - return true - } - - restartOrDeferWorker := func(workerID string, info *WorkerInfo) { - target, ok := targets[info.FunctionID] - if !ok { - return - } - if input.project.Runtime.ShouldRunEagerly(target.Runtime) { - startWorker(info.FunctionID, workerID) - } else { - log.Info("lazy startup: deferring worker restart until invoked", "workerID", workerID, "functionID", info.FunctionID) - delete(workers, workerID) - } - } - - for { - select { - case <-ctx.Done(): - return - case msg := <-input.msg: - switch msg.Type { - case bridge.MessageInit: - ch, ok := nextChan[msg.Source] - if !ok { - ch = make(chan io.Reader, 100) - nextChan[msg.Source] = ch - } - init := bridge.InitBody{} - json.NewDecoder(msg.Body).Decode(&init) - if _, ok := targets[init.FunctionID]; !ok { - log.Error("function not found", "functionID", init.FunctionID) - continue - } - workerID := msg.Source - if _, ok := workers[workerID]; ok { - log.Error("got reboot but worker already exists", "workerID", workerID, "functionID", init.FunctionID) - continue - } - log.Info("worker init", "workerID", msg.Source, "functionID", init.FunctionID) - workerEnv[workerID] = init.Environment - if ok := startWorker(init.FunctionID, workerID); !ok { - result, err := http.Post("http://"+server+workerID+"/runtime/init/error", "application/json", strings.NewReader(`{"errorMessage":"Function failed to build"}`)) - if err != nil { - continue - } - defer result.Body.Close() - body, err := io.ReadAll(result.Body) - if err != nil { - continue - } - log.Info("error", "body", string(body), "status", result.StatusCode) - - if result.StatusCode != 202 { - result, err := http.Get("http://" + server + workerID + "/runtime/invocation/next") - if err != nil { - continue - } - requestID := result.Header.Get("lambda-runtime-aws-request-id") - result, err = http.Post("http://"+server+workerID+"/runtime/invocation/"+requestID+"/error", "application/json", strings.NewReader(`{"errorMessage":"Function failed to build"}`)) - if err != nil { - continue - } - defer result.Body.Close() - body, err := io.ReadAll(result.Body) - if err != nil { - continue - } - log.Info("error", "body", string(body), "status", result.StatusCode) - } - } - case bridge.MessageNext: - writer := input.client.NewWriter(bridge.MessagePing, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.PingBody{}) - writer.Close() - ch, ok := nextChan[msg.Source] - if !ok { - ch = make(chan io.Reader, 100) - nextChan[msg.Source] = ch - } - _, ok = workers[msg.Source] - if !ok { - log.Info("asking for reboot", "workerID", msg.Source) - writer := input.client.NewWriter(bridge.MessageReboot, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.RebootBody{}) - writer.Close() - } - ch <- msg.Body - continue - } - - case info := <-workerShutdownChan: - log.Info("worker died", "workerID", info.WorkerID) - existing, ok := workers[info.WorkerID] - if !ok { - continue - } - // only delete if a new worker hasn't already been started - if existing == info { - log.Info("deleting worker", "workerID", info.WorkerID) - delete(workers, info.WorkerID) - delete(nextChan, info.WorkerID) - } - break - case unknown := <-evts: - switch evt := unknown.(type) { - case *FunctionInvokedEvent: - info, ok := workers[evt.WorkerID] - if !ok { - continue - } - info.CurrentRequestID = evt.RequestID - case *project.CompleteEvent: - if evt.Old { - continue - } - for _, info := range workers { - info.Worker.Stop() - } - builds = map[string]*runtime.BuildOutput{} - for workerID, info := range workers { - restartOrDeferWorker(workerID, info) - } - case *runtime.BuildInput: - targets[evt.FunctionID] = evt - case *watcher.FileChangedEvent: - log.Info("checking if code needs to be rebuilt", "file", evt.Path) - toBuild := map[string]bool{} - - for functionID := range builds { - target, ok := targets[functionID] - if !ok { - continue - } - if input.project.Runtime.ShouldRebuild(target.Runtime, target.FunctionID, evt.Path) { - for _, worker := range workers { - if worker.FunctionID == functionID { - log.Info("stopping", "workerID", worker.WorkerID, "functionID", worker.FunctionID) - worker.Worker.Stop() - } - } - delete(builds, functionID) - toBuild[functionID] = true - } - } - - for functionID := range toBuild { - output := getBuildOutput(functionID) - if output == nil { - delete(toBuild, functionID) - } - } - - for workerID, info := range workers { - if toBuild[info.FunctionID] { - restartOrDeferWorker(workerID, info) - } - } - break - } - } - } -} - -func fileLogger(p *project.Project) { - evts := bus.Subscribe(&FunctionLogEvent{}, &FunctionInvokedEvent{}, &FunctionResponseEvent{}, &FunctionErrorEvent{}, &FunctionBuildEvent{}) - logs := map[string]*os.File{} - - getLog := func(functionID string, requestID string) *os.File { - log, ok := logs[requestID] - if !ok { - path := p.PathLog(fmt.Sprintf("lambda/%s/%d-%s", functionID, time.Now().Unix(), requestID)) - os.MkdirAll(filepath.Dir(path), 0755) - log, _ = os.Create(path) - logs[requestID] = log - } - return log - } - - for range evts { - for evt := range evts { - switch evt := evt.(type) { - case *FunctionInvokedEvent: - log := getLog(evt.FunctionID, evt.RequestID) - log.WriteString("invocation " + evt.RequestID + "\n") - log.WriteString(string(evt.Input)) - log.WriteString("\n") - case *FunctionLogEvent: - getLog(evt.FunctionID, evt.RequestID).WriteString(evt.Line + "\n") - case *FunctionResponseEvent: - log := getLog(evt.FunctionID, evt.RequestID) - log.WriteString("response " + evt.RequestID + "\n") - log.WriteString(string(evt.Output)) - log.WriteString("\n") - delete(logs, evt.RequestID) - case *FunctionErrorEvent: - getLog(evt.FunctionID, evt.RequestID).WriteString(evt.ErrorType + ": " + evt.ErrorMessage + "\n") - delete(logs, evt.RequestID) - } - } - } -} diff --git a/cmd/sst/mosaic/aws/task.go b/cmd/sst/mosaic/aws/task.go deleted file mode 100644 index 53a21cbd3c..0000000000 --- a/cmd/sst/mosaic/aws/task.go +++ /dev/null @@ -1,206 +0,0 @@ -package aws - -import ( - "bufio" - "context" - "encoding/json" - "log/slog" - "os" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/ecs" - "github.com/aws/aws-sdk-go-v2/service/ecs/types" - "github.com/kballard/go-shellquote" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/bridge" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" -) - -type TaskProvisionEvent struct { - Name string -} - -type TaskStartEvent struct { - TaskID string - WorkerID string - Command string -} - -type TaskLogEvent struct { - TaskID string - WorkerID string - Line string -} - -type TaskCompleteEvent struct { - TaskID string - WorkerID string -} - -type TaskMissingCommandEvent struct { - Name string -} - -func task(ctx context.Context, input input) { - log := slog.Default().With("service", "aws.task") - log.Info("starting") - defer log.Info("done") - events := bus.Subscribe(&project.CompleteEvent{}) - var complete *project.CompleteEvent - - ticker := time.NewTicker(time.Second * 3) - defer ticker.Stop() - - ecsClient := ecs.NewFromConfig(input.config) - trackedTasks := map[string]bool{} - - for { - select { - case <-ticker.C: - if complete == nil || len(complete.Tasks) == 0 { - continue - } - for _, item := range complete.Resources { - if item.URN.Type() != "aws:ecs/cluster:Cluster" { - continue - } - name := item.Outputs["name"] - tasks, err := ecsClient.ListTasks(ctx, &ecs.ListTasksInput{ - Cluster: aws.String(name.(string)), - DesiredStatus: types.DesiredStatusRunning, - }) - if err != nil { - continue - } - dirty := []string{} - for _, task := range tasks.TaskArns { - if _, ok := trackedTasks[task]; !ok { - dirty = append(dirty, task) - trackedTasks[task] = true - continue - } - } - if len(dirty) == 0 { - continue - } - log.Info("describing tasks", "tasks", dirty) - described, err := ecsClient.DescribeTasks(ctx, &ecs.DescribeTasksInput{ - Tasks: dirty, - Cluster: aws.String(name.(string)), - }) - if err != nil { - continue - } - for _, item := range described.Tasks { - bus.Publish(&TaskProvisionEvent{ - Name: *item.Containers[0].Name, - }) - log.Info("task status", "status", *item.LastStatus, "desired", *item.LastStatus, "tags", item.Tags) - if err != nil { - continue - } - } - } - break - - case <-ctx.Done(): - return - - case msg := <-input.msg: - if complete == nil { - continue - } - switch msg.Type { - case bridge.MessageTaskStart: - log.Info("starting task", "task", task) - body := bridge.TaskStartBody{} - json.NewDecoder(msg.Body).Decode(&body) - task, ok := complete.Tasks[body.TaskID] - if !ok { - continue - } - if task.Command == nil { - bus.Publish(&TaskMissingCommandEvent{ - Name: task.Name, - }) - continue - } - fields, err := shellquote.Split(*task.Command) - if err != nil { - log.Error("failed to parse command", "err", err) - continue - } - cmd := process.Command(fields[0], fields[1:]...) - cmd.Dir = task.Directory - cmd.Env = append(os.Environ(), body.Environment...) - stdout, _ := cmd.StdoutPipe() - stderr, _ := cmd.StderrPipe() - go func() { - scanner := bufio.NewScanner(stdout) - for scanner.Scan() { - line := scanner.Text() - bus.Publish(&TaskLogEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - Line: line, - }) - } - }() - go func() { - scanner := bufio.NewScanner(stderr) - for scanner.Scan() { - line := scanner.Text() - bus.Publish(&TaskLogEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - Line: line, - }) - } - }() - go func() { - done := make(chan struct{}) - cmd.Start() - bus.Publish(&TaskStartEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - Command: cmd.String(), - }) - go func() { - cmd.Wait() - done <- struct{}{} - }() - for { - writer := input.client.NewWriter(bridge.MessagePing, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.PingBody{}) - writer.Close() - select { - case <-done: - writer := input.client.NewWriter(bridge.MessageTaskComplete, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.TaskCompleteBody{}) - writer.Close() - bus.Publish(&TaskCompleteEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - }) - return - case <-ctx.Done(): - return - case <-time.After(time.Second * 5): - continue - } - } - }() - } - break - - case unknown := <-events: - switch evt := unknown.(type) { - case *project.CompleteEvent: - complete = evt - } - break - } - } -} diff --git a/cmd/sst/mosaic/cloudflare/cloudflare.go b/cmd/sst/mosaic/cloudflare/cloudflare.go deleted file mode 100644 index f67c1f8054..0000000000 --- a/cmd/sst/mosaic/cloudflare/cloudflare.go +++ /dev/null @@ -1,158 +0,0 @@ -package cloudflare - -import ( - "context" - "encoding/json" - "log/slog" - "net/http" - "os" - "path/filepath" - - "github.com/cloudflare/cloudflare-go" - "github.com/gorilla/websocket" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/runtime" - "github.com/sst/sst/v3/pkg/runtime/worker" -) - -type WorkerBuildEvent struct { - WorkerID string - Errors []string -} - -type WorkerUpdatedEvent struct { - WorkerID string -} - -type WorkerInvokedEvent struct { - WorkerID string - TailEvent *TailEvent -} - -func Start(ctx context.Context, proj *project.Project, args map[string]interface{}) error { - prov, ok := proj.Provider("cloudflare") - if !ok { - return util.NewReadableError(nil, "Cloudflare provider not found in project configuration") - } - api := prov.(*provider.CloudflareProvider).Api() - evts := bus.Subscribe(&project.CompleteEvent{}, &watcher.FileChangedEvent{}, &runtime.BuildInput{}) - builds := map[string]*runtime.BuildOutput{} - targets := map[string]*runtime.BuildInput{} - type tailRef struct { - ID string - ScriptName string - Account *cloudflare.ResourceContainer - } - tails := map[string]tailRef{} - -exit: - for { - select { - case <-ctx.Done(): - break exit - case unknown := <-evts: - switch evt := unknown.(type) { - case *runtime.BuildInput: - target := evt - if target.Runtime != "worker" { - continue - } - targets[target.FunctionID] = target - var properties worker.Properties - json.Unmarshal(target.Properties, &properties) - account := cloudflare.AccountIdentifier(properties.AccountID) - if _, ok := tails[target.FunctionID]; !ok { - slog.Info("cloudflare tail creating", "functionID", target.FunctionID) - tail, err := api.StartWorkersTail(ctx, account, properties.ScriptName) - if err != nil { - slog.Error("error creating tail", "error", err) - continue - } - tails[target.FunctionID] = tailRef{ - ID: tail.ID, - ScriptName: properties.ScriptName, - Account: account, - } - conn, _, err := websocket.DefaultDialer.DialContext(ctx, tail.URL, http.Header{ - "Sec-WebSocket-Protocol": []string{"trace-v1"}, - }) - if err != nil { - slog.Info("error dialing websocket", "error", err) - continue - } - go func(functionID string) { - defer delete(tails, functionID) - for { - msg := &TailEvent{} - err := conn.ReadJSON(msg) - if err != nil { - slog.Info("error reading websocket", "error", err) - return - } - bus.Publish(&WorkerInvokedEvent{ - WorkerID: functionID, - TailEvent: msg, - }) - } - }(target.FunctionID) - } - if _, ok := builds[target.FunctionID]; ok { - continue - } - output, err := proj.Runtime.Build(ctx, target) - if err != nil { - continue - } - builds[target.FunctionID] = output - case *watcher.FileChangedEvent: - for workerID, target := range targets { - if proj.Runtime.ShouldRebuild(target.Runtime, workerID, evt.Path) { - output, err := proj.Runtime.Build(ctx, target) - if err != nil { - continue - } - bus.Publish(&WorkerBuildEvent{ - WorkerID: target.FunctionID, - Errors: output.Errors, - }) - builds[target.FunctionID] = output - var properties worker.Properties - json.Unmarshal(target.Properties, &properties) - account := cloudflare.AccountIdentifier(properties.AccountID) - - content, err := os.ReadFile(filepath.Join(output.Out, output.Handler)) - if err != nil { - slog.Info("error reading file", "error", err, "out", filepath.Join(output.Out, output.Handler)) - continue - } - slog.Info("updating worker script", "functionID", target.FunctionID) - _, err = api.UpdateWorkersScriptContent(ctx, account, cloudflare.UpdateWorkersScriptContentParams{ - ScriptName: properties.ScriptName, - Script: string(content), - Module: true, - }) - if err != nil { - slog.Info("error updating worker script", "error", err) - } - slog.Info("done worker script", "functionID", target.FunctionID) - bus.Publish(&WorkerUpdatedEvent{ - WorkerID: target.FunctionID, - }) - - } - } - break - } - } - } - - for _, tail := range tails { - api.DeleteWorkersTail(ctx, tail.Account, tail.ScriptName, tail.ID) - } - - return nil -} diff --git a/cmd/sst/mosaic/cloudflare/tail.go b/cmd/sst/mosaic/cloudflare/tail.go deleted file mode 100644 index bb26e86fd1..0000000000 --- a/cmd/sst/mosaic/cloudflare/tail.go +++ /dev/null @@ -1,99 +0,0 @@ -package cloudflare - -type TailEvent struct { - DiagnosticsChannelEvents []any `json:"diagnosticsChannelEvents"` - Event struct { - Request struct { - Cf struct { - AsOrganization string `json:"asOrganization"` - Asn int `json:"asn"` - City string `json:"city"` - ClientAcceptEncoding string `json:"clientAcceptEncoding"` - Colo string `json:"colo"` - Continent string `json:"continent"` - Country string `json:"country"` - EdgeRequestKeepAliveStatus int `json:"edgeRequestKeepAliveStatus"` - HTTPProtocol string `json:"httpProtocol"` - Latitude string `json:"latitude"` - Longitude string `json:"longitude"` - MetroCode string `json:"metroCode"` - PostalCode string `json:"postalCode"` - Region string `json:"region"` - RegionCode string `json:"regionCode"` - RequestPriority string `json:"requestPriority"` - Timezone string `json:"timezone"` - TLSCipher string `json:"tlsCipher"` - TLSClientAuth struct { - CertFingerprintSHA1 string `json:"certFingerprintSHA1"` - CertFingerprintSHA256 string `json:"certFingerprintSHA256"` - CertIssuerDN string `json:"certIssuerDN"` - CertIssuerDNLegacy string `json:"certIssuerDNLegacy"` - CertIssuerDNRFC2253 string `json:"certIssuerDNRFC2253"` - CertIssuerSKI string `json:"certIssuerSKI"` - CertIssuerSerial string `json:"certIssuerSerial"` - CertNotAfter string `json:"certNotAfter"` - CertNotBefore string `json:"certNotBefore"` - CertPresented string `json:"certPresented"` - CertRevoked string `json:"certRevoked"` - CertSKI string `json:"certSKI"` - CertSerial string `json:"certSerial"` - CertSubjectDN string `json:"certSubjectDN"` - CertSubjectDNLegacy string `json:"certSubjectDNLegacy"` - CertSubjectDNRFC2253 string `json:"certSubjectDNRFC2253"` - CertVerified string `json:"certVerified"` - } `json:"tlsClientAuth"` - TLSClientExtensionsSha1 string `json:"tlsClientExtensionsSha1"` - TLSClientHelloLength string `json:"tlsClientHelloLength"` - TLSClientRandom string `json:"tlsClientRandom"` - TLSExportedAuthenticator struct { - ClientFinished string `json:"clientFinished"` - ClientHandshake string `json:"clientHandshake"` - ServerFinished string `json:"serverFinished"` - ServerHandshake string `json:"serverHandshake"` - } `json:"tlsExportedAuthenticator"` - TLSVersion string `json:"tlsVersion"` - VerifiedBotCategory string `json:"verifiedBotCategory"` - } `json:"cf"` - Headers struct { - Accept string `json:"accept"` - AcceptEncoding string `json:"accept-encoding"` - AcceptLanguage string `json:"accept-language"` - CfConnectingIP string `json:"cf-connecting-ip"` - CfIpcountry string `json:"cf-ipcountry"` - CfRay string `json:"cf-ray"` - CfVisitor string `json:"cf-visitor"` - Connection string `json:"connection"` - Host string `json:"host"` - Priority string `json:"priority"` - SecChUa string `json:"sec-ch-ua"` - SecChUaMobile string `json:"sec-ch-ua-mobile"` - SecChUaPlatform string `json:"sec-ch-ua-platform"` - SecFetchDest string `json:"sec-fetch-dest"` - SecFetchMode string `json:"sec-fetch-mode"` - SecFetchSite string `json:"sec-fetch-site"` - SecFetchUser string `json:"sec-fetch-user"` - UpgradeInsecureRequests string `json:"upgrade-insecure-requests"` - UserAgent string `json:"user-agent"` - XForwardedProto string `json:"x-forwarded-proto"` - XRealIP string `json:"x-real-ip"` - } `json:"headers"` - Method string `json:"method"` - URL string `json:"url"` - } `json:"request"` - Response struct { - Status int `json:"status"` - } `json:"response"` - } `json:"event"` - EventTimestamp int64 `json:"eventTimestamp"` - Exceptions []any `json:"exceptions"` - Logs []struct { - Level string `json:"level"` - Message []interface{} `json:"message"` - Timestamp int64 `json:"timestamp"` - } `json:"logs"` - Outcome string `json:"outcome"` - ScriptName string `json:"scriptName"` - ScriptVersion struct { - ID string `json:"id"` - } `json:"scriptVersion"` -} diff --git a/cmd/sst/mosaic/deployer/deployer.go b/cmd/sst/mosaic/deployer/deployer.go deleted file mode 100644 index ff507c0142..0000000000 --- a/cmd/sst/mosaic/deployer/deployer.go +++ /dev/null @@ -1,93 +0,0 @@ -package deployer - -import ( - "context" - "log/slog" - "reflect" - - "github.com/sst/sst/v3/cmd/sst/mosaic/errors" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" -) - -type DeployRequestedEvent struct{} -type DeployFailedEvent struct { - Error string -} - -func Start(ctx context.Context, p *project.Project, server *server.Server, policyPath string) error { - log := slog.Default().With("service", "deployer") - log.Info("starting") - defer log.Info("done") - watchedFiles := make(map[string]bool) - events := bus.Subscribe(ctx, &watcher.FileChangedEvent{}, &DeployRequestedEvent{}, &project.BuildSuccessEvent{}) - lastBuildHash := "" - for { - log.Info("waiting for trigger") - select { - case <-ctx.Done(): - return nil - case evt := <-events: - switch evt := evt.(type) { - case *project.BuildSuccessEvent: - lastBuildHash = evt.Hash - log.Info("build hash", "hash", lastBuildHash) - for _, file := range evt.Files { - watchedFiles[file] = true - } - continue - case *watcher.FileChangedEvent, *DeployRequestedEvent: - if evt, ok := evt.(*watcher.FileChangedEvent); !ok || watchedFiles[evt.Path] { - log.Info("deploying") - err := p.Run(ctx, &project.StackInput{ - Command: "deploy", - Dev: true, - ServerPort: server.Port, - SkipHash: lastBuildHash, - PolicyPath: policyPath, - }) - if err != nil { - log.Error("stack deploy error", "error", err) - transformed := errors.Transform(err) - if _, ok := transformed.(*util.ReadableError); ok && transformed.Error() != "" { - bus.Publish(&DeployFailedEvent{Error: transformed.Error()}) - } - } - } - } - continue - } - } -} - -func publishFields(v interface{}) { - val := reflect.ValueOf(v) - - if val.Kind() == reflect.Ptr { - val = val.Elem() - } - - if val.Kind() != reflect.Struct { - bus.Publish(v) - return - } - - for i := 0; i < val.NumField(); i++ { - field := val.Field(i) - switch field.Kind() { - case reflect.Struct: - publishFields(field.Interface()) - break - case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan, reflect.Func: - if !field.IsNil() { - bus.Publish(field.Interface()) - } - break - default: - // bus.Publish(field.Interface()) - } - } -} diff --git a/cmd/sst/mosaic/dev/dev.go b/cmd/sst/mosaic/dev/dev.go deleted file mode 100644 index 5b2b419392..0000000000 --- a/cmd/sst/mosaic/dev/dev.go +++ /dev/null @@ -1,238 +0,0 @@ -package dev - -import ( - "context" - "encoding/json" - "log/slog" - "net/http" - "os" - "path/filepath" - "reflect" - - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -type Message struct { - Type string `json:"type"` - Event json.RawMessage `json:"event"` -} - -func Start(ctx context.Context, p *project.Project, server *server.Server) error { - var complete *project.CompleteEvent - var wg errgroup.Group - - log := slog.Default().With("service", "dev") - log.Info("starting") - defer log.Info("done") - - wg.Go(func() error { - evts := bus.Subscribe(&project.CompleteEvent{}) - for { - select { - case <-ctx.Done(): - return nil - case evt := <-evts: - complete = evt.(*project.CompleteEvent) - } - } - }) - - server.Mux.HandleFunc("/stream", func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("content-type", "application/x-ndjson") - w.WriteHeader(http.StatusOK) - log.Info("subscribed", "addr", r.RemoteAddr) - flusher, _ := w.(http.Flusher) - flusher.Flush() - ctx := r.Context() - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - if complete != nil { - go func() { - events <- complete - }() - } - for { - select { - case <-ctx.Done(): - return - case event := <-events: - t := reflect.TypeOf(event) - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - bytes, _ := json.Marshal(event) - data, _ := json.Marshal(&Message{ - Type: t.String(), - Event: json.RawMessage(bytes), - }) - w.Write(data) - flusher.Flush() - } - } - }) - - server.Mux.HandleFunc(("/api/deploy"), func(w http.ResponseWriter, r *http.Request) { - log.Info("deploy requested") - bus.Publish(&deployer.DeployRequestedEvent{}) - }) - - server.Mux.HandleFunc("/api/env", func(w http.ResponseWriter, r *http.Request) { - directory := r.URL.Query().Get("directory") - name := r.URL.Query().Get("name") - resolved := complete - latest, err := p.GetCompleted(ctx) - if err == nil && (resolved == nil || resolved.Old) { - resolved = latest - } - if resolved == nil { - http.Error(w, "dev state not ready", http.StatusServiceUnavailable) - return - } - cwd, _ := os.Getwd() - for _, d := range resolved.Devs { - full := filepath.Join(cwd, d.Directory) - log.Info("matching dev", "full", full, "directory", directory) - if (directory != "" && full == directory) || (name != "" && d.Name == name) { - env, err := p.EnvFor(ctx, resolved, d.Name) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - body, err := json.Marshal(map[string]interface{}{ - "env": env, - "command": d.Command, - }) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - w.Write(body) - return - } - } - log.Info("dev not found", "directory", directory) - http.Error(w, "dev not found", http.StatusNotFound) - return - }) - - server.Mux.HandleFunc("/api/completed", func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("content-type", "application/json") - w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(complete) - return - }) - - return wg.Wait() -} - -func Stream(ctx context.Context, url string, types ...interface{}) (chan any, error) { - out := make(chan any) - req, err := http.NewRequestWithContext(ctx, "GET", url+"/stream", nil) - if err != nil { - return nil, err - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - decoder := json.NewDecoder(resp.Body) - - registry := map[string]reflect.Type{} - for _, v := range types { - t := reflect.TypeOf(v) - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - name := t.String() - registry[name] = t - } - - go func() { - defer close(out) - defer resp.Body.Close() - for { - select { - case <-ctx.Done(): - return - default: - var msg Message - err := decoder.Decode(&msg) - if err != nil { - return - } - prototype, ok := registry[msg.Type] - if !ok { - continue - } - target := reflect.New(prototype).Interface() - err = json.Unmarshal(msg.Event, target) - if err != nil { - continue - } - out <- target - } - } - }() - - return out, nil -} - -type EnvResponse struct { - Env map[string]string `json:"env"` - Command string `json:"command"` -} - -func Env(ctx context.Context, query string, url string) (*EnvResponse, error) { - req, err := http.NewRequestWithContext(ctx, "GET", url+"/api/env?"+query, nil) - if err != nil { - return nil, err - } - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - var result EnvResponse - err = json.NewDecoder(resp.Body).Decode(&result) - if err != nil { - return nil, err - } - return &result, nil -} - -func Deploy(ctx context.Context, url string) error { - req, err := http.NewRequestWithContext(ctx, "POST", url+"/api/deploy", nil) - if err != nil { - return err - } - _, err = http.DefaultClient.Do(req) - if err != nil { - return err - } - return nil -} - -func Completed(ctx context.Context, url string) (*project.CompleteEvent, error) { - req, err := http.NewRequestWithContext(ctx, "GET", url+"/api/completed", nil) - if err != nil { - return nil, err - } - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - var result project.CompleteEvent - err = json.NewDecoder(resp.Body).Decode(&result) - if err != nil { - return nil, err - } - return &result, nil -} diff --git a/cmd/sst/mosaic/errors/errors.go b/cmd/sst/mosaic/errors/errors.go deleted file mode 100644 index 635b1081f1..0000000000 --- a/cmd/sst/mosaic/errors/errors.go +++ /dev/null @@ -1,109 +0,0 @@ -package errors - -import ( - "errors" - "fmt" - "strings" - - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/appsync" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/js" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/server" -) - -type ErrorTransformer = func(err error) (bool, error) - -var transformers = []ErrorTransformer{ - exact(appsync.ErrSubscriptionFailed, "Failed to subscribe to appsync websocket endpoint which powers live lambda. Check to see if you have proper appsync permissions."), - exact(project.ErrInvalidStageName, "The stage name is invalid. It must start with a letter and can only contain alphanumeric characters and hyphens."), - exact(project.ErrInvalidAppName, "The app name is invalid. It must start with a letter and can only contain alphanumeric characters and hyphens."), - exact(project.ErrAppNameChanged, "The app name has changed.\n\nIf you want to rename the app, make sure to run `sst remove` to remove the old app first. Alternatively, remove the \".sst\" folder and try again.\n"), - exact(project.ErrV2Config, "You are using sst v3 and this looks like an sst v2 config"), - exact(project.ErrStageNotFound, "Stage not found"), - exact(project.ErrPassphraseInvalid, "The passphrase for this app / stage is missing or invalid"), - exact(aws.ErrIoTDelay, "This aws account has not had iot initialized in it before which sst depends on. It may take a few minutes before it is ready."), - exact(project.ErrStackRunFailed, ""), - exact(project.ErrPolicyViolation, ""), - exact(project.ErrPolicyConfigError, ""), - exact(provider.ErrLockExists, ""), - exact(project.ErrVersionInvalid, "The version range defined in the config is invalid"), - exact(provider.ErrCloudflareMissingAccount, "The Cloudflare Account ID was not able to be determined from this token. Make sure it has permissions to fetch account information or you can set the CLOUDFLARE_DEFAULT_ACCOUNT_ID environment variable to the account id you want to use."), - exact(server.ErrServerNotFound, "Could not find an `sst dev` session to connect to. Since you are running a command outside of the multiplexer be sure to start `sst dev` first."), - exact(provider.ErrBucketMissing, "The state bucket is missing, it may have been accidentally deleted. Go to https://console.aws.amazon.com/systems-manager/parameters/%252Fsst%252Fbootstrap/description?tab=Table and check if the state bucket mentioned there exists. If it doesn't you can recreate it or delete the `/sst/bootstrap` key to force recreation."), - exact(project.ErrProtectedStage, "Cannot remove protected stage. To remove a protected stage edit your sst.config.ts and remove the `protect` property."), - exact(project.ErrProtectedDevStage, "Cannot run `sst dev` on a protected stage."), - exact(provider.ErrLockNotFound, "This app / stage is not locked"), - exact(aws.ErrAppsyncNotReady, "SST creates an appsync event api to power live lambda. After 10 seconds of waiting this cli could not connect to it."), - exact(js.ErrTopLevelImport, "Your sst.config.ts has top level imports - this is not allowed. Move imports inside the function they are used and do a dynamic import: `const mod = await import(\"./mod\")`"), - match(func(err *project.ErrBuildFailed) string { - result := "Failed to build sst.config.ts" - for _, msg := range err.Errors { - result += "\n - " - if msg.Location != nil { - result += msg.Location.File + ":" + fmt.Sprint(msg.Location.Line) + ":" + fmt.Sprint(msg.Location.Column) + " " - } - result += msg.Text - } - return result - }), - match(func(err *project.ErrProviderVersionTooLow) string { - return fmt.Sprintf("You specified version %s of the \"%s\" provider. SST needs %s or higher.", err.Version, err.Name, err.Needed) - }), - match(func(err *project.ErrVersionMismatch) string { - return fmt.Sprintf("You are using v%s which does not match v%s in your \"sst.config.ts\".", err.Needed, err.Received) - }), - func(err error) (bool, error) { - msg := err.Error() - if !strings.HasPrefix(msg, "aws:") { - return false, nil - } - if strings.Contains(msg, "cached SSO token is expired") { - return true, util.NewHintedError(err, "It looks like you are using AWS SSO but your credentials have expired. Try running `aws sso login` to refresh your credentials.") - } - if strings.Contains(msg, "no EC2 IMDS role found") { - return true, util.NewHintedError(err, "AWS credentials are not configured. Try configuring your profile in `~/.aws/config` and setting the `AWS_PROFILE` environment variable or specifying `providers.aws.profile` in your sst.config.ts") - } - return false, nil - }, -} - -func Transform(err error) error { - for _, t := range transformers { - if ok, err := t(err); ok { - return err - } - } - return err -} - -func match[T error](transformer func(T) string) ErrorTransformer { - return func(err error) (bool, error) { - var match T - if errors.As(err, &match) { - str := transformer(match) - return true, util.NewReadableError(err, str) - } - return false, nil - } -} - -func exact(compare error, msg string) ErrorTransformer { - return func(err error) (bool, error) { - if errors.Is(err, compare) { - return true, util.NewReadableError(err, msg) - } - return false, nil - } -} - -func passthrough(compare error) ErrorTransformer { - return func(err error) (bool, error) { - if errors.Is(err, compare) { - return true, util.NewReadableError(err, err.Error()) - } - return false, nil - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer.go b/cmd/sst/mosaic/monoplexer/monoplexer.go deleted file mode 100644 index 702ba84f7a..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer.go +++ /dev/null @@ -1,136 +0,0 @@ -package monoplexer - -import ( - "bufio" - "context" - "fmt" - "io" - "os" - "os/exec" - - "github.com/sst/sst/v3/pkg/process" -) - -type Monoplexer struct { - processes map[string]*Process - lines chan Line -} - -type Line struct { - process string - line string -} - -type Process struct { - name string - title string - command []string - cmd *exec.Cmd - dir string - env []string - started bool -} - -func (p *Process) IsDifferent(title string, command []string, directory string) bool { - if len(command) != len(p.command) { - return true - } - for i := range command { - if command[i] != p.command[i] { - return true - } - } - if title != p.title { - return true - } - if directory != p.dir { - return true - } - return false -} - -func New() *Monoplexer { - return &Monoplexer{ - processes: map[string]*Process{}, - lines: make(chan Line, 32), - } -} - -func (p *Process) start(lines chan Line) { - r, w := io.Pipe() - cmd := process.Command(p.command[0], p.command[1:]...) - cmd.SysProcAttr = getProcAttr() - cmd.Stdout = w - cmd.Stderr = w - if p.dir != "" { - cmd.Dir = p.dir - } - if len(p.env) > 0 { - cmd.Env = append(os.Environ(), p.env...) - } - go func() { - // read r line by line - scanner := bufio.NewScanner(r) - for scanner.Scan() { - lines <- Line{ - line: scanner.Text(), - process: p.name, - } - } - }() - cmd.Start() - p.cmd = cmd - p.started = true -} - -func (m *Monoplexer) AddProcess(name string, command []string, directory string, title string, autostart bool, env ...string) { - exists, ok := m.processes[name] - if ok { - if !exists.IsDifferent(title, command, directory) { - if !exists.started && autostart { - exists.start(m.lines) - } - return - } - if exists.started { - m.lines <- Line{ - line: "dev config changed, restarting...", - process: name, - } - process.Kill(exists.cmd.Process) - } - delete(m.processes, name) - } - - proc := &Process{ - name: name, - title: title, - command: command, - dir: directory, - env: env, - } - m.processes[name] = proc - if autostart { - proc.start(m.lines) - return - } - m.lines <- Line{ - line: "auto-start disabled", - process: name, - } -} - -func (m *Monoplexer) Start(ctx context.Context) error { - for { - select { - case line := <-m.lines: - match, ok := m.processes[line.process] - if !ok { - continue - } - fmt.Println("["+match.title+"]", line.line) - case <-ctx.Done(): - return nil - } - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer_test.go b/cmd/sst/mosaic/monoplexer/monoplexer_test.go deleted file mode 100644 index 93f7e40b6e..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package monoplexer - -import ( - "strings" - "testing" - "time" - - "github.com/sst/sst/v3/pkg/process" -) - -func TestAddProcessAutostartFalse(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", false) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if proc.started { - t.Fatal("expected process to remain stopped") - } - - select { - case line := <-m.lines: - if line.process != "web" { - t.Fatalf("expected message for web, got %q", line.process) - } - if !strings.Contains(line.line, "auto-start disabled") { - t.Fatalf("expected disabled message, got %q", line.line) - } - case <-time.After(time.Second): - t.Fatal("expected disabled message") - } -} - -func TestAddProcessAutostartTrue(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", true) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if !proc.started { - t.Fatal("expected process to start") - } - if proc.cmd == nil || proc.cmd.Process == nil { - t.Fatal("expected child process to be running") - } - - defer process.Kill(proc.cmd.Process) -} - -func TestAddProcessStartsWhenAutostartEnabledLater(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", false) - <-m.lines - - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", true) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if !proc.started { - t.Fatal("expected process to start when autostart becomes enabled") - } - if proc.cmd == nil || proc.cmd.Process == nil { - t.Fatal("expected child process to be running") - } - - defer process.Kill(proc.cmd.Process) -} - -func TestAddProcessConfigChangeKeepsProcessStopped(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", false) - <-m.lines - - m.AddProcess("web", []string{"sh", "-c", "sleep 10"}, "", "Web", false) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if proc.started { - t.Fatal("expected process to remain stopped after config change") - } - - select { - case line := <-m.lines: - if !strings.Contains(line.line, "auto-start disabled") { - t.Fatalf("expected disabled message, got %q", line.line) - } - case <-time.After(time.Second): - t.Fatal("expected disabled message after config change") - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer_unix.go b/cmd/sst/mosaic/monoplexer/monoplexer_unix.go deleted file mode 100644 index cb5eed0555..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer_unix.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !windows -// +build !windows - -package monoplexer - -import "syscall" - -func getProcAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{ - Setpgid: true, - Pgid: 0, - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer_windows.go b/cmd/sst/mosaic/monoplexer/monoplexer_windows.go deleted file mode 100644 index 9949429e70..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer_windows.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build windows -// +build windows - -package monoplexer - -import "syscall" - -func getProcAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{} -} diff --git a/cmd/sst/mosaic/multiplexer/draw.go b/cmd/sst/mosaic/multiplexer/draw.go deleted file mode 100644 index 0142598ac6..0000000000 --- a/cmd/sst/mosaic/multiplexer/draw.go +++ /dev/null @@ -1,288 +0,0 @@ -package multiplexer - -import ( - "fmt" - "slices" - "sort" - "strings" - "unicode/utf8" - - "github.com/gdamore/tcell/v2" - "github.com/gdamore/tcell/v2/views" -) - -func (s *Multiplexer) draw() { - defer s.screen.Show() - s.screen.Clear() - softGray := tcell.NewRGBColor(138, 138, 138) - for _, w := range s.stack.Widgets() { - s.stack.RemoveWidget(w) - } - selected := s.selectedProcess() - - for index, item := range s.processes { - if index > 0 && !s.processes[index-1].dead && item.dead { - spacer := views.NewTextBar() - spacer.SetLeft("──────────────────────", tcell.StyleDefault.Foreground(tcell.ColorGray)) - s.stack.AddWidget(spacer, 0) - } - style := tcell.StyleDefault - if item.dead { - style = style.Foreground(tcell.ColorGray) - } - if index == s.selected { - style = style.Bold(true) - if !s.focused { - if item.dead { - style = style.Foreground(tcell.ColorOrange).Dim(true) - } else { - style = style.Foreground(tcell.ColorOrange) - } - } - } - label := item.Title - textStyle := style - if item.filter != "" { - label = item.filter - textStyle = textStyle.Italic(true) - } - title := views.NewTextBar() - title.SetStyle(style) - title.SetLeft(item.Icon+" "+label, textStyle) - s.stack.AddWidget(title, 0) - } - s.stack.AddWidget(views.NewSpacer(), 1) - - hotkeys := map[string]string{} - if s.filtering && s.filterSearching { - hotkeys["esc"] = "cancel" - hotkeys["enter"] = "confirm" - } else if s.filtering { - hotkeys["j/k/↓/↑"] = "move" - hotkeys["enter"] = "select" - hotkeys["/"] = "search" - hotkeys["esc"] = "clear" - } else { - if selected != nil && selected.Killable && !s.focused { - if !selected.dead { - hotkeys["x"] = "kill" - hotkeys["enter"] = "focus" - } - - if selected.dead { - hotkeys["enter"] = "start" - } - } - if !s.focused { - hotkeys["j/k/↓/↑"] = "up/down" - } - if s.focused { - hotkeys["ctrl-z"] = "sidebar" - } - if selected != nil && selected.vt.HasSelection() { - hotkeys["enter"] = "copy" - } - hotkeys["ctrl-u/d"] = "scroll" - if selected != nil && selected.isScrolling() { - hotkeys["ctrl-g"] = "bottom" - } - hotkeys["ctrl-l"] = "clear" - if selected != nil && !s.focused && selected.Filterable && selected.filterAvailable { - hotkeys["f"] = "filter" - } - } - // sort hotkeys - keys := make([]string, 0, len(hotkeys)) - for key := range hotkeys { - keys = append(keys, key) - } - slices.SortFunc(keys, func(i, j string) int { - ilength := utf8.RuneCountInString(i) - jlength := utf8.RuneCountInString(j) - if ilength != jlength { - return ilength - jlength - } - return strings.Compare(i, j) - }) - for _, key := range keys { - label := hotkeys[key] - title := views.NewTextBar() - title.SetStyle(tcell.StyleDefault.Foreground(softGray)) - title.SetLeft(key, tcell.StyleDefault.Foreground(softGray).Bold(true)) - title.SetRight(label+" ", tcell.StyleDefault) - s.stack.AddWidget(title, 0) - } - s.stack.Draw() - - borderStyle := tcell.StyleDefault.Foreground(tcell.ColorGray).Dim(true) - for i := PAD_HEIGHT; i < s.height-PAD_HEIGHT; i++ { - s.screen.SetContent(SIDEBAR_WIDTH, i, 'β”‚', nil, borderStyle) - } - - // render virtual terminal - if selected != nil && !s.filtering { - selected.vt.Draw() - if s.focused { - y, x, _, _ := selected.vt.Cursor() - s.screen.ShowCursor(s.mainX()+x, y+s.contentY()) - } - if !s.focused { - s.screen.HideCursor() - } - } - - if s.filtering { - if !s.filterSearching { - s.screen.HideCursor() - } - s.drawFilterSelect(selected) - } -} - -func (s *Multiplexer) drawFilterSelect(selected *pane) { - startX := s.mainX() - startY := s.contentY() - endY := s.height - s.contentY() - mainW := s.mainWidth() - softGray := tcell.NewRGBColor(138, 138, 138) - dimStyle := tcell.StyleDefault.Foreground(tcell.ColorGray) - grayStyle := tcell.StyleDefault.Foreground(softGray) - tealStyle := tcell.StyleDefault.Foreground(tcell.ColorTeal).Bold(true) - tealDimStyle := tcell.StyleDefault.Foreground(tcell.ColorTeal).Dim(true) - normalStyle := tcell.StyleDefault.Foreground(tcell.ColorWhite) - - // clear main area - for y := startY; y < endY; y++ { - for x := startX; x < s.width; x++ { - s.screen.SetContent(x, y, ' ', nil, tcell.StyleDefault) - } - } - - y := startY - s.drawLine(startX, y, selected.FilterTitle, tealStyle, mainW) - y++ // blank - y++ - - if s.filterSearching { - x := s.drawLine(startX, y, "Search: ", grayStyle, mainW) - x = s.drawLine(x, y, s.filterQuery, normalStyle, mainW-(x-startX)) - s.screen.ShowCursor(x, y) - } else if s.filterQuery != "" { - x := s.drawLine(startX, y, "Search: ", grayStyle, mainW) - s.drawLine(x, y, s.filterQuery, normalStyle.Italic(true), mainW-(x-startX)) - } else { - s.drawLine(startX, y, selected.FilterSubtitle, grayStyle, mainW) - } - y++ // blank - y++ - - total := len(s.filterFiltered) - - if total > 0 && s.filterScroll > 0 { - s.drawLine(startX, y, fmt.Sprintf("↑ %d more", s.filterScroll), dimStyle, mainW) - } - y++ - - if total == 0 { - s.drawLine(startX, y, "No results found.", dimStyle, mainW) - return - } - - visible := s.filterVisibleRows() - end := min(s.filterScroll+visible, total) - - for fi := s.filterScroll; fi < end && y < endY-1; fi++ { - opt := s.filterOptions[s.filterFiltered[fi]] - style := normalStyle - descStyle := dimStyle - prefix := " " - if fi == s.filterSelected { - style = tealStyle - descStyle = tealDimStyle - prefix = "> " - } - x := s.drawLine(startX, y, prefix+opt.Label, style, mainW) - if opt.Description != "" { - s.drawLine(x, y, " "+opt.Description, descStyle, mainW-(x-startX)) - } - y++ - } - - if end < total && y < endY { - s.drawLine(startX, y, fmt.Sprintf("↓ %d more", total-end), dimStyle, mainW) - } -} - -func (s *Multiplexer) drawLine(startX, y int, text string, style tcell.Style, maxW int) int { - x := startX - for _, ch := range text { - if x-startX >= maxW { - break - } - s.screen.SetContent(x, y, ch, nil, style) - x++ - } - return x -} - -func (s *Multiplexer) move(offset int) { - index := s.selected + offset - if index < 0 { - index = 0 - } - if index >= len(s.processes) { - index = len(s.processes) - 1 - } - s.selected = index - s.draw() -} - -func (s *Multiplexer) focus() { - s.focused = true - s.draw() -} - -func (s *Multiplexer) blur() { - s.focused = false - selected := s.selectedProcess() - if selected != nil { - selected.scrollReset() - } - s.screen.HideCursor() - s.draw() -} - -func (s *Multiplexer) sort() { - if len(s.processes) == 0 { - return - } - key := s.selectedProcess().Key - sort.Slice(s.processes, func(i, j int) bool { - if !s.processes[i].Killable && s.processes[j].Killable { - return true - } - if s.processes[i].Killable && !s.processes[j].Killable { - return false - } - if !s.processes[i].dead && s.processes[j].dead { - return true - } - if s.processes[i].dead && !s.processes[j].dead { - return false - } - return len(s.processes[i].Title) < len(s.processes[j].Title) - }) - for i, p := range s.processes { - if p.Key == key { - s.selected = i - return - } - } -} - -func (s *Multiplexer) selectedProcess() *pane { - if s.selected >= len(s.processes) { - return nil - } - return s.processes[s.selected] -} diff --git a/cmd/sst/mosaic/multiplexer/keycode.go b/cmd/sst/mosaic/multiplexer/keycode.go deleted file mode 100644 index 0452e2ceb9..0000000000 --- a/cmd/sst/mosaic/multiplexer/keycode.go +++ /dev/null @@ -1,691 +0,0 @@ -package multiplexer - -import ( - "strings" - - "github.com/gdamore/tcell/v2" -) - -func keyCode(ev *tcell.EventKey) string { - key := strings.Builder{} - switch ev.Modifiers() { - case tcell.ModNone: - switch ev.Key() { - case tcell.KeyRune: - key.WriteRune(ev.Rune()) - default: - if str, ok := keyCodes[ev.Key()]; ok { - key.WriteString(str) - } else { - key.WriteRune(rune(ev.Key())) - } - } - case tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyShfEnd) - case tcell.KeyInsert: - key.WriteString(info.KeyShfInsert) - case tcell.KeyDelete: - key.WriteString(info.KeyShfDelete) - case tcell.KeyPgUp: - key.WriteString(info.KeyShfPgUp) - case tcell.KeyPgDn: - key.WriteString(info.KeyShfPgDn) - case tcell.KeyF1: - key.WriteString(info.KeyF13) - case tcell.KeyF2: - key.WriteString(info.KeyF14) - case tcell.KeyF3: - key.WriteString(info.KeyF15) - case tcell.KeyF4: - key.WriteString(info.KeyF16) - case tcell.KeyF5: - key.WriteString(info.KeyF17) - case tcell.KeyF6: - key.WriteString(info.KeyF18) - case tcell.KeyF7: - key.WriteString(info.KeyF19) - case tcell.KeyF8: - key.WriteString(info.KeyF20) - case tcell.KeyF9: - key.WriteString(info.KeyF21) - case tcell.KeyF10: - key.WriteString(info.KeyF22) - case tcell.KeyF11: - key.WriteString(info.KeyF23) - case tcell.KeyF12: - key.WriteString(info.KeyF24) - } - case tcell.ModAlt: - switch ev.Key() { - case tcell.KeyRune: - key.WriteString("\x1b") - key.WriteRune(ev.Rune()) - case tcell.KeyUp: - key.WriteString(info.KeyAltUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF49) - case tcell.KeyF2: - key.WriteString(info.KeyF50) - case tcell.KeyF3: - key.WriteString(info.KeyF51) - case tcell.KeyF4: - key.WriteString(info.KeyF53) - case tcell.KeyF5: - key.WriteString(info.KeyF54) - case tcell.KeyF6: - key.WriteString(info.KeyF55) - case tcell.KeyF7: - key.WriteString(info.KeyF56) - case tcell.KeyF8: - key.WriteString(info.KeyF57) - case tcell.KeyF9: - key.WriteString(info.KeyF58) - case tcell.KeyF10: - key.WriteString(info.KeyF59) - case tcell.KeyF11: - key.WriteString(info.KeyF60) - case tcell.KeyF12: - key.WriteString(info.KeyF61) - } - case tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF25) - case tcell.KeyF2: - key.WriteString(info.KeyF26) - case tcell.KeyF3: - key.WriteString(info.KeyF27) - case tcell.KeyF4: - key.WriteString(info.KeyF28) - case tcell.KeyF5: - key.WriteString(info.KeyF29) - case tcell.KeyF6: - key.WriteString(info.KeyF30) - case tcell.KeyF7: - key.WriteString(info.KeyF31) - case tcell.KeyF8: - key.WriteString(info.KeyF32) - case tcell.KeyF9: - key.WriteString(info.KeyF33) - case tcell.KeyF10: - key.WriteString(info.KeyF34) - case tcell.KeyF11: - key.WriteString(info.KeyF35) - case tcell.KeyF12: - key.WriteString(info.KeyF36) - default: - key.WriteRune(ev.Rune()) - } - case tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF37) - case tcell.KeyF2: - key.WriteString(info.KeyF38) - case tcell.KeyF3: - key.WriteString(info.KeyF39) - case tcell.KeyF4: - key.WriteString(info.KeyF40) - case tcell.KeyF5: - key.WriteString(info.KeyF41) - case tcell.KeyF6: - key.WriteString(info.KeyF42) - case tcell.KeyF7: - key.WriteString(info.KeyF43) - case tcell.KeyF8: - key.WriteString(info.KeyF44) - case tcell.KeyF9: - key.WriteString(info.KeyF45) - case tcell.KeyF10: - key.WriteString(info.KeyF46) - case tcell.KeyF11: - key.WriteString(info.KeyF47) - case tcell.KeyF12: - key.WriteString(info.KeyF48) - } - case tcell.ModAlt | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyAltShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF61) - case tcell.KeyF2: - key.WriteString(info.KeyF62) - case tcell.KeyF3: - key.WriteString(info.KeyF63) - case tcell.KeyF4: - key.WriteString(info.KeyF64) - } - case tcell.ModAlt | tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltPgDown) - } - case tcell.ModAlt | tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltShfUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltShfDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltShfRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltShfLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltShfHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltShfPgDown) - } - case tcell.ModMeta: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";9~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;9") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";10~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;10") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";11~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;11") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";12~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;12") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";13~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;13") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";14~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;14") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";15~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;15") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";16~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;16") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - } - return key.String() -} - -var keyCodes = map[tcell.Key]string{ - tcell.KeyBackspace: info.KeyBackspace, - tcell.KeyF1: info.KeyF1, - tcell.KeyF2: info.KeyF2, - tcell.KeyF3: info.KeyF3, - tcell.KeyF4: info.KeyF4, - tcell.KeyF5: info.KeyF5, - tcell.KeyF6: info.KeyF6, - tcell.KeyF7: info.KeyF7, - tcell.KeyF8: info.KeyF8, - tcell.KeyF9: info.KeyF9, - tcell.KeyF10: info.KeyF10, - tcell.KeyF11: info.KeyF11, - tcell.KeyF12: info.KeyF12, - tcell.KeyF13: info.KeyF13, - tcell.KeyF14: info.KeyF14, - tcell.KeyF15: info.KeyF15, - tcell.KeyF16: info.KeyF16, - tcell.KeyF17: info.KeyF17, - tcell.KeyF18: info.KeyF18, - tcell.KeyF19: info.KeyF19, - tcell.KeyF20: info.KeyF20, - tcell.KeyF21: info.KeyF21, - tcell.KeyF22: info.KeyF22, - tcell.KeyF23: info.KeyF23, - tcell.KeyF24: info.KeyF24, - tcell.KeyF25: info.KeyF25, - tcell.KeyF26: info.KeyF26, - tcell.KeyF27: info.KeyF27, - tcell.KeyF28: info.KeyF28, - tcell.KeyF29: info.KeyF29, - tcell.KeyF30: info.KeyF30, - tcell.KeyF31: info.KeyF31, - tcell.KeyF32: info.KeyF32, - tcell.KeyF33: info.KeyF33, - tcell.KeyF34: info.KeyF34, - tcell.KeyF35: info.KeyF35, - tcell.KeyF36: info.KeyF36, - tcell.KeyF37: info.KeyF37, - tcell.KeyF38: info.KeyF38, - tcell.KeyF39: info.KeyF39, - tcell.KeyF40: info.KeyF40, - tcell.KeyF41: info.KeyF41, - tcell.KeyF42: info.KeyF42, - tcell.KeyF43: info.KeyF43, - tcell.KeyF44: info.KeyF44, - tcell.KeyF45: info.KeyF45, - tcell.KeyF46: info.KeyF46, - tcell.KeyF47: info.KeyF47, - tcell.KeyF48: info.KeyF48, - tcell.KeyF49: info.KeyF49, - tcell.KeyF50: info.KeyF50, - tcell.KeyF51: info.KeyF51, - tcell.KeyF52: info.KeyF52, - tcell.KeyF53: info.KeyF53, - tcell.KeyF54: info.KeyF54, - tcell.KeyF55: info.KeyF55, - tcell.KeyF56: info.KeyF56, - tcell.KeyF57: info.KeyF57, - tcell.KeyF58: info.KeyF58, - tcell.KeyF59: info.KeyF59, - tcell.KeyF60: info.KeyF60, - tcell.KeyF61: info.KeyF61, - tcell.KeyF62: info.KeyF62, - tcell.KeyF63: info.KeyF63, - tcell.KeyF64: info.KeyF64, - tcell.KeyInsert: info.KeyInsert, - tcell.KeyDelete: info.KeyDelete, - tcell.KeyHome: info.KeyHome, - tcell.KeyEnd: info.KeyEnd, - tcell.KeyHelp: info.KeyHelp, - tcell.KeyPgUp: info.KeyPgUp, - tcell.KeyPgDn: info.KeyPgDn, - tcell.KeyUp: info.KeyUp, - tcell.KeyDown: info.KeyDown, - tcell.KeyLeft: info.KeyLeft, - tcell.KeyRight: info.KeyRight, - tcell.KeyBacktab: info.KeyBacktab, - tcell.KeyExit: info.KeyExit, - tcell.KeyClear: info.KeyClear, - tcell.KeyPrint: info.KeyPrint, - tcell.KeyCancel: info.KeyCancel, -} diff --git a/cmd/sst/mosaic/multiplexer/multiplexer.go b/cmd/sst/mosaic/multiplexer/multiplexer.go deleted file mode 100644 index cba7a37a44..0000000000 --- a/cmd/sst/mosaic/multiplexer/multiplexer.go +++ /dev/null @@ -1,734 +0,0 @@ -package multiplexer - -import ( - "encoding/base64" - "fmt" - "log/slog" - "os" - "runtime/debug" - "strings" - "syscall" - "time" - - "github.com/gdamore/tcell/v2" - "github.com/gdamore/tcell/v2/views" - tcellterm "github.com/sst/sst/v3/cmd/sst/mosaic/multiplexer/tcell-term" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/process" -) - -var PAD_HEIGHT = 1 -var PAD_WIDTH = 1 -var MAIN_PAD_WIDTH = 3 -var CONTENT_PAD_HEIGHT = 0 -var SIDEBAR_WIDTH = 24 - -type Multiplexer struct { - focused bool - width int - height int - selected int - processes []*pane - screen tcell.Screen - root *views.ViewPort - main *views.ViewPort - stack *views.BoxLayout - - dragging bool - click *tcell.EventMouse - scrollTicker *time.Ticker - scrollDone chan struct{} - scrollDir int - lastDragX int - - filtering bool - filterOptions []FilterOption - filterFiltered []int - filterSelected int - filterScroll int - filterSearching bool - filterQuery string -} - -type FilterOption struct { - Label string - Description string - Value string -} - -func New() (*Multiplexer, error) { - var err error - result := &Multiplexer{} - result.processes = []*pane{} - result.screen, err = tcell.NewScreen() - if err != nil { - return nil, err - } - result.screen.Init() - result.screen.EnableMouse() - result.screen.Show() - width, height := result.screen.Size() - result.width = width - result.height = height - result.root = views.NewViewPort(result.screen, 0, 0, 0, 0) - result.main = views.NewViewPort(result.screen, 0, 0, 0, 0) - result.stack = views.NewBoxLayout(views.Vertical) - result.stack.SetView(result.root) - if os.Getenv("TMUX") != "" { - process.Command("tmux", "set-option", "-p", "set-clipboard", "on").Run() - } - return result, nil -} - -func (s *Multiplexer) mainRect() (int, int) { - return s.mainWidth(), s.mainHeight() -} - -func (s *Multiplexer) mainX() int { - return SIDEBAR_WIDTH + 1 + MAIN_PAD_WIDTH -} - -func (s *Multiplexer) mainWidth() int { - return max(0, s.width-s.mainX()-MAIN_PAD_WIDTH) -} - -func (s *Multiplexer) contentY() int { - return PAD_HEIGHT + CONTENT_PAD_HEIGHT -} - -func (s *Multiplexer) mainHeight() int { - return max(0, s.height-s.contentY()*2) -} - -func (s *Multiplexer) sidebarWidth() int { - return SIDEBAR_WIDTH - PAD_WIDTH - 1 -} - -func (s *Multiplexer) resize(width int, height int) { - s.width = width - s.height = height - s.root.Resize(PAD_WIDTH, s.contentY(), s.sidebarWidth(), s.mainHeight()) - s.main.Resize(s.mainX(), s.contentY(), s.mainWidth(), s.mainHeight()) - mw, mh := s.main.Size() - for _, p := range s.processes { - p.vt.Resize(mw, mh) - } -} - -func (s *Multiplexer) Start() { - defer func() { - s.stopAutoScroll() - s.screen.Fini() - }() - - s.resize(s.screen.Size()) - - for { - unknown := s.screen.PollEvent() - if unknown == nil { - continue - } - shouldBreak := false - func() { - defer func() { - if r := recover(); r != nil { - slog.Error("mutliplexer panic", "err", r, "stack", string(debug.Stack())) - } - }() - - selected := s.selectedProcess() - - switch evt := unknown.(type) { - - case *tcell.EventInterrupt: - if s.scrollDir != 0 && s.dragging && selected != nil { - if s.scrollDir < 0 { - s.scrollUp(1) - selected.vt.SelectEnd(s.lastDragX, 0) - } else { - s.scrollDown(1) - selected.vt.SelectEnd(s.lastDragX, max(0, s.mainHeight()-1)) - } - } - return - - case *EventExit: - shouldBreak = true - return - - case *EventCheckFilter: - for _, p := range s.processes { - if p.Key != evt.PaneKey || !p.Filterable { - continue - } - p.filterAvailable = len(evt.Names) > 0 - if p.filter == "" { - continue - } - found := false - for _, name := range evt.Names { - if name == p.filter { - found = true - break - } - } - if !found { - s.clearPaneFilter(p) - } - } - s.draw() - return - - case *EventProcess: - for _, p := range s.processes { - if p.Key == evt.Key { - if p.dead && evt.Autostart { - p.start() - s.sort() - s.draw() - } - return - } - } - proc := &pane{PaneConfig: evt.PaneConfig} - term := tcellterm.New() - term.SetSurface(s.main) - term.Attach(func(ev tcell.Event) { - s.screen.PostEvent(ev) - }) - proc.vt = term - if evt.Autostart { - proc.start() - } - if !evt.Autostart { - proc.vt.Start(process.Command("echo", ui.TEXT_DIM.Render(evt.Key+" has auto-start disabled, press enter to start."))) - proc.dead = true - } - s.processes = append(s.processes, proc) - s.sort() - s.draw() - break - - case *tcell.EventMouse: - if evt.Buttons()&tcell.WheelUp != 0 { - s.scrollUp(3) - return - } - if evt.Buttons()&tcell.WheelDown != 0 { - s.scrollDown(3) - return - } - if evt.Buttons() == tcell.ButtonNone { - s.stopAutoScroll() - if s.dragging && selected != nil { - s.copy() - } - s.dragging = false - return - } - if evt.Buttons()&tcell.ButtonPrimary != 0 { - x, y := evt.Position() - contentY := y - s.contentY() - maxContentY := max(0, s.mainHeight()-1) - if x < s.mainX() && s.dragging && selected != nil { - if y < s.contentY() { - s.scrollUp(1) - s.startAutoScroll(-1) - selected.vt.SelectEnd(0, 0) - s.draw() - } else if y >= s.height-s.contentY() { - s.scrollDown(1) - s.startAutoScroll(1) - selected.vt.SelectEnd(0, maxContentY) - s.draw() - } else if contentY >= 0 && contentY <= maxContentY { - s.stopAutoScroll() - selected.vt.SelectEnd(0, contentY) - s.draw() - } - return - } - if x < SIDEBAR_WIDTH && !s.dragging { - if contentY < 0 || contentY > maxContentY { - return - } - y = contentY - alive := 0 - for _, p := range s.processes { - if !p.dead { - alive++ - } - } - if alive != len(s.processes) { - if y == alive { - return - } - if y > alive { - y-- - } - } - if y >= len(s.processes) { - return - } - s.selected = y - s.blur() - return - } - if x >= s.mainX() { - if selected == nil { - return - } - if !s.dragging && (contentY < 0 || contentY > maxContentY) { - return - } - if !s.dragging && s.click != nil && time.Since(s.click.When()) < time.Millisecond*500 { - oldX, oldY := s.click.Position() - if oldX == x && oldY == y { - selected.vt.SelectStart(0, contentY) - selected.vt.SelectEnd(s.width-1, contentY) - s.dragging = true - s.draw() - return - } - } - s.click = evt - offsetX := x - s.mainX() - s.lastDragX = offsetX - if s.dragging { - if y < s.contentY() { - s.scrollUp(1) - s.startAutoScroll(-1) - } else if y >= s.height-s.contentY() { - s.scrollDown(1) - s.startAutoScroll(1) - } else { - s.stopAutoScroll() - } - selected.vt.SelectEnd(offsetX, min(max(contentY, 0), maxContentY)) - } - if !s.dragging { - s.dragging = true - selected.vt.SelectStart(offsetX, contentY) - } - s.draw() - return - } - } - break - - case *tcell.EventResize: - slog.Info("resize") - s.resize(evt.Size()) - s.draw() - s.screen.Sync() - return - - case *tcellterm.EventRedraw: - if s.filtering { - return - } - if selected != nil && selected.vt == evt.VT() { - selected.vt.Draw() - s.screen.Show() - } - return - - case *tcellterm.EventClosed: - for index, proc := range s.processes { - if proc.vt == evt.VT() { - if !proc.dead { - proc.vt.Start(process.Command("echo", "\n"+ui.TEXT_DIM.Render("[process exited]"))) - proc.dead = true - s.sort() - if index == s.selected { - s.blur() - } - } - } - } - s.draw() - return - - case *tcell.EventKey: - if s.filtering && evt.Key() != tcell.KeyCtrlC { - s.handleFilterKey(evt) - return - } - switch evt.Key() { - case 256: - switch evt.Rune() { - case 'j': - if !s.focused { - s.move(1) - return - } - case 'k': - if !s.focused { - s.move(-1) - return - } - case 'x': - if selected.Killable && !selected.dead && !s.focused { - selected.Kill() - } - case 'f': - if !s.focused && selected != nil && selected.Filterable && selected.filterAvailable && selected.ListOptions != nil { - options := selected.ListOptions() - if len(options) == 0 { - return - } - s.filterOptions = options - s.filterFiltered = make([]int, len(options)) - for i := range options { - s.filterFiltered[i] = i - } - s.filterSelected = 0 - for i, opt := range s.filterOptions { - if opt.Value == selected.filter { - s.filterSelected = i - break - } - } - s.filterScroll = 0 - s.filterSearching = false - s.filterQuery = "" - s.filtering = true - s.filterEnsureVisible() - s.draw() - return - } - } - case tcell.KeyUp: - if !s.focused { - s.move(-1) - return - } - case tcell.KeyDown: - if !s.focused { - s.move(1) - return - } - case tcell.KeyCtrlU: - if selected != nil { - s.scrollUp(s.mainHeight()/2 + 1) - return - } - case tcell.KeyCtrlD: - if selected != nil { - s.scrollDown(s.mainHeight()/2 + 1) - return - } - case tcell.KeyEnter: - if selected != nil && selected.vt.HasSelection() { - s.copy() - selected.vt.ClearSelection() - s.draw() - return - } - if !s.focused { - if selected.Killable { - if selected.dead { - selected.start() - s.sort() - s.draw() - return - } - s.focus() - } - return - } - case tcell.KeyCtrlC: - if !s.focused { - s.move(-99999) - pid := os.Getpid() - process, _ := os.FindProcess(pid) - process.Signal(syscall.SIGINT) - return - } - case tcell.KeyEscape: - if !s.focused && selected != nil && selected.filter != "" { - s.clearPaneFilter(selected) - return - } - case tcell.KeyCtrlZ: - if s.focused { - s.blur() - return - } - case tcell.KeyCtrlG: - if selected != nil && selected.isScrolling() { - selected.scrollReset() - s.draw() - s.screen.Sync() - return - } - case tcell.KeyCtrlL: - if selected != nil { - selected.Clear() - s.draw() - return - } - } - - if selected != nil && s.focused && !selected.isScrolling() { - selected.vt.HandleEvent(evt) - s.draw() - } - } - }() - if shouldBreak { - return - } - } -} - -func (s *Multiplexer) handleFilterKey(evt *tcell.EventKey) { - if s.filterSearching { - s.handleFilterSearchKey(evt) - return - } - switch evt.Key() { - case tcell.KeyEscape: - selected := s.selectedProcess() - if selected != nil && selected.filter != "" { - s.clearPaneFilter(selected) - } - s.filtering = false - s.draw() - case tcell.KeyEnter: - if len(s.filterFiltered) == 0 { - return - } - value := s.filterOptions[s.filterFiltered[s.filterSelected]].Value - selected := s.selectedProcess() - if selected != nil && selected.filter == value { - value = "" - } - s.applyFilter(value) - s.filtering = false - s.draw() - case tcell.KeyUp: - if s.filterSelected > 0 { - s.filterSelected-- - s.filterEnsureVisible() - s.draw() - } - case tcell.KeyDown: - if s.filterSelected < len(s.filterFiltered)-1 { - s.filterSelected++ - s.filterEnsureVisible() - s.draw() - } - case tcell.KeyRune: - switch evt.Rune() { - case 'j': - if s.filterSelected < len(s.filterFiltered)-1 { - s.filterSelected++ - s.filterEnsureVisible() - s.draw() - } - case 'k': - if s.filterSelected > 0 { - s.filterSelected-- - s.filterEnsureVisible() - s.draw() - } - case '/': - s.filterSearching = true - s.filterQuery = "" - s.draw() - } - } -} - -func (s *Multiplexer) handleFilterSearchKey(evt *tcell.EventKey) { - switch evt.Key() { - case tcell.KeyEscape: - s.filterSearching = false - s.filterQuery = "" - s.refilterOptions() - s.draw() - case tcell.KeyEnter: - if len(s.filterFiltered) == 1 { - value := s.filterOptions[s.filterFiltered[0]].Value - selected := s.selectedProcess() - if selected != nil && selected.filter == value { - value = "" - } - s.applyFilter(value) - s.filtering = false - s.filterSearching = false - s.draw() - return - } - s.filterSearching = false - s.draw() - case tcell.KeyBackspace, tcell.KeyBackspace2: - if len(s.filterQuery) > 0 { - s.filterQuery = s.filterQuery[:len(s.filterQuery)-1] - s.refilterOptions() - s.draw() - } - case tcell.KeyRune: - s.filterQuery += string(evt.Rune()) - s.refilterOptions() - s.draw() - } -} - -func (s *Multiplexer) refilterOptions() { - q := strings.ToLower(s.filterQuery) - s.filterFiltered = s.filterFiltered[:0] - for i, opt := range s.filterOptions { - if q == "" || strings.Contains(strings.ToLower(opt.Label), q) || strings.Contains(strings.ToLower(opt.Description), q) { - s.filterFiltered = append(s.filterFiltered, i) - } - } - if s.filterSelected >= len(s.filterFiltered) { - s.filterSelected = max(0, len(s.filterFiltered)-1) - } - s.filterEnsureVisible() -} - -func (s *Multiplexer) filterVisibleRows() int { - // header (y=0) + blank + subtitle (y=2) + blank + ↑/blank (y=4) = list starts at y=5 - // reserve 1 row at bottom for ↓ indicator + 6 rows padding - rows := s.mainHeight() - 5 - 1 - 6 - if rows < 1 { - rows = 1 - } - return rows -} - -func (s *Multiplexer) filterEnsureVisible() { - visible := s.filterVisibleRows() - if s.filterSelected < s.filterScroll { - s.filterScroll = s.filterSelected - } - if s.filterSelected >= s.filterScroll+visible { - s.filterScroll = s.filterSelected - visible + 1 - } - if s.filterScroll < 0 { - s.filterScroll = 0 - } -} - -func (s *Multiplexer) clearPaneFilter(p *pane) { - if p.filter == "" { - return - } - p.filter = "" - if p.OnFilterChanged != nil { - p.OnFilterChanged("") - } - s.draw() -} - -func (s *Multiplexer) applyFilter(value string) { - selected := s.selectedProcess() - if selected == nil { - return - } - if selected.filter == value { - return - } - selected.filter = value - if selected.OnFilterChanged != nil { - selected.OnFilterChanged(value) - } -} - -type EventExit struct { - when time.Time -} - -func (e *EventExit) When() time.Time { - return e.when -} - -func (s *Multiplexer) Exit() { - s.screen.PostEvent(&EventExit{}) -} - -type EventCheckFilter struct { - tcell.EventTime - PaneKey string - Names []string -} - -func (s *Multiplexer) CheckFilter(paneKey string, names []string) { - s.screen.PostEvent(&EventCheckFilter{PaneKey: paneKey, Names: names}) -} - -func (s *Multiplexer) stopAutoScroll() { - if s.scrollTicker != nil { - s.scrollTicker.Stop() - close(s.scrollDone) - s.scrollTicker = nil - s.scrollDone = nil - s.scrollDir = 0 - } -} - -func (s *Multiplexer) startAutoScroll(dir int) { - if s.scrollDir == dir && s.scrollTicker != nil { - return - } - s.stopAutoScroll() - s.scrollDir = dir - s.scrollTicker = time.NewTicker(50 * time.Millisecond) - s.scrollDone = make(chan struct{}) - go func() { - for { - select { - case <-s.scrollDone: - return - case <-s.scrollTicker.C: - s.screen.PostEvent(tcell.NewEventInterrupt(nil)) - } - } - }() -} - -func (s *Multiplexer) scrollDown(n int) { - selected := s.selectedProcess() - if selected == nil { - return - } - selected.scrollDown(n) - s.draw() - s.screen.Sync() -} - -func (s *Multiplexer) scrollUp(n int) { - selected := s.selectedProcess() - if selected == nil { - return - } - selected.scrollUp(n) - s.draw() -} - -func (s *Multiplexer) copy() { - selected := s.selectedProcess() - if selected == nil { - return - } - data := selected.vt.Copy() - if data == "" { - return - } - // check if mac terminal - if os.Getenv("TERM_PROGRAM") == "Apple_Terminal" { - // use pbcopy - cmd := process.Command("pbcopy") - cmd.Stdin = strings.NewReader(data) - err := cmd.Run() - if err != nil { - fmt.Fprintf(os.Stderr, "failed to copy to clipboard: %v\n", err) - } - return - } - encoded := base64.StdEncoding.EncodeToString([]byte(data)) - fmt.Fprintf(os.Stdout, "\x1b]52;c;%s\x07", encoded) -} diff --git a/cmd/sst/mosaic/multiplexer/process.go b/cmd/sst/mosaic/multiplexer/process.go deleted file mode 100644 index c929bbfaa3..0000000000 --- a/cmd/sst/mosaic/multiplexer/process.go +++ /dev/null @@ -1,90 +0,0 @@ -package multiplexer - -import ( - "os/exec" - - "github.com/gdamore/tcell/v2" - tcellterm "github.com/sst/sst/v3/cmd/sst/mosaic/multiplexer/tcell-term" - "github.com/sst/sst/v3/pkg/process" -) - -type PaneConfig struct { - Key string - Args []string - Icon string - Title string - Cwd string - Killable bool - Autostart bool - Env []string - Filterable bool - FilterTitle string - FilterSubtitle string - ListOptions func() []FilterOption - OnFilterChanged func(string) -} - -type pane struct { - PaneConfig - filterAvailable bool - vt *tcellterm.VT - dead bool - cmd *exec.Cmd - filter string -} - -type EventProcess struct { - tcell.EventTime - PaneConfig -} - -func (s *Multiplexer) AddProcess(cfg PaneConfig) { - s.screen.PostEventWait(&EventProcess{ - PaneConfig: cfg, - }) -} - -func (p *pane) start() error { - p.cmd = process.Command(p.Args[0], p.Args[1:]...) - p.cmd.Env = p.Env - if p.Cwd != "" { - p.cmd.Dir = p.Cwd - } - p.vt.Clear() - err := p.vt.Start(p.cmd) - if err != nil { - return err - } - p.dead = false - return nil -} - -func (p *pane) Kill() { - p.vt.Close() -} - -func (s *pane) scrollUp(offset int) { - s.vt.ScrollUp(offset) -} - -func (s *pane) scrollDown(offset int) { - s.vt.ScrollDown(offset) -} - -func (s *pane) scrollReset() { - s.vt.ScrollReset() -} - -func (s *pane) isScrolling() bool { - return s.vt.IsScrolling() -} - -func (s *pane) scrollable() bool { - return s.vt.Scrollable() -} - -func (s *pane) Clear() { - s.vt.Clear() - s.vt.ScrollReset() - s.vt.ClearScrollback() -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/LICENSE b/cmd/sst/mosaic/multiplexer/tcell-term/LICENSE deleted file mode 100644 index 677ccc536c..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2023 Tim Culverhouse - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/c0.go b/cmd/sst/mosaic/multiplexer/tcell-term/c0.go deleted file mode 100644 index 7bcd00cff8..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/c0.go +++ /dev/null @@ -1,72 +0,0 @@ -package tcellterm - -func (vt *VT) c0(r rune) { - switch r { - case 0x07: - vt.postEvent(EventBell{ - EventTerminal: newEventTerminal(vt), - }) - case 0x08: - vt.bs() - case 0x09: - vt.ht() - case 0x0A: - vt.lf() - case 0x0B: - vt.vt() - case 0x0C: - vt.ff() - case 0x0D: - vt.cr() - case 0x0E: - vt.charsets.selected = g1 - case 0x0F: - vt.charsets.selected = g2 - } -} - -// Backspace 0x08 -func (vt *VT) bs() { - vt.lastCol = false - if vt.cursor.col == vt.margin.left { - if vt.cursor.row == vt.margin.top { - return - } - // reverse wrap - vt.cursor.col = vt.margin.right - vt.cursor.row -= 1 - return - } - vt.cursor.col -= 1 -} - -// Horizontal tab 0x09 -func (vt *VT) ht() { - vt.cht(1) -} - -// Linefeed 0x10 -func (vt *VT) lf() { - vt.ind() - - if vt.mode&lnm != lnm { - return - } - vt.cursor.col = vt.margin.left -} - -// Vertical tabulation 0x11 -func (vt *VT) vt() { - vt.lf() -} - -// Form feed 0x12 -func (vt *VT) ff() { - vt.lf() -} - -// Carriage return 0x13 -func (vt *VT) cr() { - vt.lastCol = false - vt.cursor.col = vt.margin.left -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/c0_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/c0_test.go deleted file mode 100644 index 6daea85d55..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/c0_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestBS(t *testing.T) { - vt := New() - vt.Resize(4, 1) - vt.cursor.col = 1 - vt.bs() - assert.Equal(t, column(0), vt.cursor.col) - vt.bs() - assert.Equal(t, column(0), vt.cursor.col) -} - -func TestLF(t *testing.T) { - t.Run("LNM reset", func(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.lf() - assert.Equal(t, "vt\n ", vt.String()) - assert.Equal(t, column(1), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - }) - - t.Run("LNM set", func(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.mode |= lnm - vt.lf() - assert.Equal(t, "vt\n ", vt.String()) - assert.Equal(t, column(0), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - - vt.print('x') - vt.lf() - assert.Equal(t, "x \n ", vt.String()) - assert.Equal(t, column(0), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - }) -} - -// // Linefeed 0x10 -// func (vt *vt) LF() { -// switch { -// case vt.cursor.row == vt.margin.bottom: -// vt.ScrollUp(1) -// default: -// vt.cursor.row += 1 -// } -// -// if vt.mode&LNM != LNM { -// return -// } -// vt.cursor.col = vt.margin.left -// } diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/cell.go b/cmd/sst/mosaic/multiplexer/tcell-term/cell.go deleted file mode 100644 index fc32b8a324..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/cell.go +++ /dev/null @@ -1,33 +0,0 @@ -package tcellterm - -import "github.com/gdamore/tcell/v2" - -type cell struct { - content rune - combining []rune - width int - attrs tcell.Style - wrapped bool -} - -func (c *cell) rune() rune { - if c.content == rune(0) { - return ' ' - } - return c.content -} - -// Erasing removes characters from the screen without affecting other characters -// on the screen. Erased characters are lost. The cursor position does not -// change when erasing characters or lines. Erasing resets the attributes, but -// applies the background color of the passed style -func (c *cell) erase(s tcell.Style) { - _, bg, _ := s.Decompose() - c.content = 0 - c.attrs = tcell.StyleDefault.Background(bg) -} - -// selectiveErase removes the cell content, but keeps the attributes -func (c *cell) selectiveErase() { - c.content = 0 -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/charset.go b/cmd/sst/mosaic/multiplexer/tcell-term/charset.go deleted file mode 100644 index 058aa0e58f..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/charset.go +++ /dev/null @@ -1,59 +0,0 @@ -package tcellterm - -type charset int - -const ( - ascii charset = iota - decSpecialAndLineDrawing -) - -type charsets struct { - selected charsetDesignator - saved charsetDesignator - designations map[charsetDesignator]charset - singleShift bool -} - -type charsetDesignator int - -const ( - g0 = iota - g1 - g2 - g3 -) - -var decSpecial = map[rune]rune{ - 0x5f: 0x00A0, // NO-BREAK SPACE - 0x60: 0x25C6, // BLACK DIAMOND - 0x61: 0x2592, // MEDIUM SHADE - 0x62: 0x2409, // SYMBOL FOR HORIZONTAL TABULATION - 0x63: 0x240C, // SYMBOL FOR FORM FEED - 0x64: 0x240D, // SYMBOL FOR CARRIAGE RETURN - 0x65: 0x240A, // SYMBOL FOR LINE FEED - 0x66: 0x00B0, // DEGREE SIGN - 0x67: 0x00B1, // PLUS-MINUS SIGN - 0x68: 0x2424, // SYMBOL FOR NEWLINE - 0x69: 0x240B, // SYMBOL FOR VERTICAL TABULATION - 0x6a: 0x2518, // BOX DRAWINGS LIGHT UP AND LEFT - 0x6b: 0x2510, // BOX DRAWINGS LIGHT DOWN AND LEFT - 0x6c: 0x250C, // BOX DRAWINGS LIGHT DOWN AND RIGHT - 0x6d: 0x2514, // BOX DRAWINGS LIGHT UP AND RIGHT - 0x6e: 0x253C, // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL - 0x6f: 0x23BA, // HORIZONTAL SCAN LINE-1 - 0x70: 0x23BB, // HORIZONTAL SCAN LINE-3 - 0x71: 0x2500, // BOX DRAWINGS LIGHT HORIZONTAL - 0x72: 0x23BC, // HORIZONTAL SCAN LINE-7 - 0x73: 0x23BD, // HORIZONTAL SCAN LINE-9 - 0x74: 0x251C, // BOX DRAWINGS LIGHT VERTICAL AND RIGHT - 0x75: 0x2524, // BOX DRAWINGS LIGHT VERTICAL AND LEFT - 0x76: 0x2534, // BOX DRAWINGS LIGHT UP AND HORIZONTAL - 0x77: 0x252C, // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL - 0x78: 0x2502, // BOX DRAWINGS LIGHT VERTICAL - 0x79: 0x2264, // LESS-THAN OR EQUAL TO - 0x7a: 0x2265, // GREATER-THAN OR EQUAL TO - 0x7b: 0x03C0, // GREEK SMALL LETTER PI - 0x7c: 0x2260, // NOT EQUAL TO - 0x7d: 0x00A3, // POUND SIGN - 0x7e: 0x00B7, // MIDDLE DOT -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/csi.go b/cmd/sst/mosaic/multiplexer/tcell-term/csi.go deleted file mode 100644 index fe2d6ee31e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/csi.go +++ /dev/null @@ -1,634 +0,0 @@ -package tcellterm - -import ( - "fmt" - "strings" - - "github.com/gdamore/tcell/v2" -) - -func (vt *VT) csi(csi string, params []int) { - switch csi { - case "@": - vt.ich(ps(params)) - case "A": - vt.cuu(ps(params)) - case "B": - vt.cud(ps(params)) - case "C": - vt.cuf(ps(params)) - case "D": - vt.cub(ps(params)) - case "E": - vt.cnl(ps(params)) - case "F": - vt.cpl(ps(params)) - case "G": - vt.cha(ps(params)) - case "H": - vt.cup(params) - case "I": - vt.cht(ps(params)) - case "J": - vt.ed(ps(params)) - case "K": - vt.el(ps(params)) - case "L": - vt.il(ps(params)) - case "M": - vt.dl(ps(params)) - case "P": - vt.dch(ps(params)) - case "S": - ps := ps(params) - if ps == 0 { - ps = 1 - } - vt.scrollUp(ps) - case "T": - // 5 params is XTHIMOUSE, ignore - if len(params) == 5 { - return - } - ps := ps(params) - if ps == 0 { - ps = 1 - } - vt.scrollDown(ps) - case "X": - vt.ech(ps(params)) - case "Z": - vt.cbt(ps(params)) - case "`": - vt.hpa(ps(params)) - case "a": - vt.hpr(ps(params)) - case "b": - vt.rep(ps(params)) - case "c": - // Send device attributes - resp := strings.Builder{} - // Response introducer - resp.WriteString("\x1B[?") - // We are a vt220 - resp.WriteString("62;") - // We have sixel support - resp.WriteString("4;") - // We have ANSI color support - resp.WriteString("22") - // Response terminator - resp.WriteString("c") - vt.pty.WriteString(resp.String()) - case "d": - vt.vpa(ps(params)) - case "e": - vt.vpr(ps(params)) - case "f": - // Same as CUP - vt.cup(params) - case "g": - vt.tbc(ps(params)) - case "h": - vt.sm(params) - case "?h": - vt.decset(params) - case "l": - vt.rm(params) - case "?l": - vt.decrst(params) - case "m": - vt.sgr(params) - case "n": - // Send device status report - switch ps(params) { - case 5: - // "Ok" - vt.pty.WriteString("\x1B[0n") - case 6: - // report cursor position - // This sequence can be identical to a function key? - // CSI r ; c R - resp := fmt.Sprintf("\x1B[%d;%dR", vt.cursor.row+1, vt.cursor.col+1) - vt.pty.WriteString(resp) - } - case "r": - vt.decstbm(params) - case "s": - vt.decsc() - case "u": - vt.decrc() - case " q": - ps(params) - vt.cursor.style = tcell.CursorStyle(ps(params)) - } -} - -// Returns a single parameter from a slice of parameters, or 0 if the slice is -// empty -func ps(params []int) int { - var ps int - if len(params) > 0 { - ps = params[0] - } - return ps -} - -// Insert Blank Character (ICH) CSI Ps @ -// Insert Ps blank characters. Cursor does not change position. -func (vt *VT) ich(ps int) { - if ps == 0 { - ps = 1 - } - col := vt.cursor.col - row := vt.cursor.row - line := vt.activeScreen[row] - for i := vt.margin.right; i > col; i -= 1 { - if col+i > column(vt.width()-1) { - break - } - if (i - column(ps)) < 0 { - continue - } - line[i] = line[i-column(ps)] - } - for i := 0; i < ps; i += 1 { - if int(col)+i >= (vt.width() - 1) { - break - } - line[col+column(i)] = cell{ - content: ' ', - width: 1, - } - } -} - -// Cursur Up (CUU) CSI Ps A -// Move cursor up in same column, stopping at top margin -func (vt *VT) cuu(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - clamp := row(0) - if vt.cursor.row >= vt.margin.top { - clamp = vt.margin.top - } - vt.cursor.row -= row(ps) - if vt.cursor.row < clamp { - vt.cursor.row = clamp - } -} - -// Cursur Down (CUD) CSI Ps B -// Move cursor down in same column, stopping at bottom margin -func (vt *VT) cud(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.row += row(ps) - if vt.cursor.row > vt.margin.bottom { - vt.cursor.row = vt.margin.bottom - } -} - -// Cursur Forward (CUF) CSI Ps C -// Move cursor forward Ps columns, stopping at the right margin -func (vt *VT) cuf(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col += column(ps) - if vt.cursor.col > vt.margin.right { - vt.cursor.col = vt.margin.right - } -} - -// Cursur Backward (CUB) CSI Ps D -// Move cursor backward Ps columns, stopping at the left margin -func (vt *VT) cub(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col -= column(ps) - if vt.cursor.col < vt.margin.left { - vt.cursor.col = vt.margin.left - } -} - -// Cursor Next Line (CNL) CSI Ps E -// Move cursor to left margin Ps lines down, scrolling if necessary -func (vt *VT) cnl(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - for i := 0; i < ps; i += 1 { - vt.nel() - } -} - -// Cursor Preceding Line (CPL) CSI Ps F -// Move cursor to left margin Ps lines down, scrolling if necessary -func (vt *VT) cpl(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - for i := 0; i < ps; i += 1 { - vt.ri() - } - vt.cursor.col = vt.margin.left -} - -// Cursor Character Absolute (CHA) CSI Ps G -// Move cursor to Ps column, stopping at right/left margin. Default is 1, but we -// default to 0 since our columns our 0 indexed -func (vt *VT) cha(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col = column(ps - 1) - if vt.cursor.col > vt.margin.right { - vt.cursor.col = vt.margin.right - } - if vt.cursor.col < vt.margin.left { - vt.cursor.col = vt.margin.left - } -} - -// Cursor Position (CUP) CSI Ps;Ps H -// Move cursor to the absolute position -func (vt *VT) cup(pm []int) { - vt.lastCol = false - switch len(pm) { - case 0: - pm = []int{1, 1} - case 1: - pm = []int{pm[0], 1} - case 2: - default: - return - } - vt.cursor.row = row(pm[0] - 1) - vt.cursor.col = column(pm[1] - 1) - if vt.cursor.col > column(vt.width()-1) { - vt.cursor.col = column(vt.width() - 1) - } - if vt.cursor.row > row(vt.height()-1) { - vt.cursor.row = row(vt.height() - 1) - } -} - -// Cursor Forward Tabulation (CHT) CSI Ps I -// Move cursor forward Ps tab stops -func (vt *VT) cht(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - n := 0 - for _, ts := range vt.tabStop { - if n == ps { - break - } - if vt.cursor.col > ts { - continue - } - vt.cursor.col = ts - n += 1 - } -} - -// Erase in Display (ED) CSI Ps J -func (vt *VT) ed(ps int) { - switch ps { - - // Erases from the cursor to the end of the screen, including the cursor - // position. Line attribute becomes single-height, single-width for all - // completely erased lines. - case 0: - vt.lastCol = false - for r := vt.cursor.row; r < row(vt.height()); r += 1 { - for col := column(0); col < column(vt.width()); col += 1 { - if r == vt.cursor.row && col < vt.cursor.col { - // Don't erase current row before cursor - continue - } - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - - // Erases from the beginning of the screen to the cursor, including the - // cursor position. Line attribute becomes single-height, single-width - // for all completely erased lines. - case 1: - vt.lastCol = false - for r := row(0); r <= vt.cursor.row; r += 1 { - for col := column(0); col < column(vt.width()); col += 1 { - if r == vt.cursor.row && col > vt.cursor.col { - // Don't erase current row after current - // column - break - } - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - - // Erases the complete display. All lines are erased and changed to - // single-width. The cursor does not move. - case 2: - vt.lastCol = false - for r := row(0); r < row(vt.height()); r += 1 { - for col := column(0); col < column(vt.width()); col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - } -} - -// Erase in Line (EL) CSI Ps K -func (vt *VT) el(ps int) { - r := vt.cursor.row - vt.lastCol = false - switch ps { - // Erases from the cursor to the end of the line, including the cursor - // position. Line attribute is not affected. - case 0: - for col := vt.cursor.col; col < column(vt.width()); col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - - // Erases from the beginning of the line to the cursor, including the - // cursor position. Line attribute is not affected. - case 1: - for col := column(0); col <= vt.cursor.col; col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - - // Erases the complete line. - case 2: - for col := column(0); col < column(vt.width()); col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } -} - -// Insert Lines (IL) CSI Ps L -// -// Insert Ps lines at the cursor. If fewer than Ps lines remain from the current -// line to the end of the scrolling region, the number of lines inserted is the -// lesser number. Lines within the scrolling region at and below the cursor move -// down. Lines moved past the bottom margin are lost. The cursor is reset to the -// first column. This sequence is ignored when the cursor is outside the -// scrolling region. -func (vt *VT) il(ps int) { - vt.lastCol = false - if vt.cursor.row < vt.margin.top { - return - } - if vt.cursor.row > vt.margin.bottom { - return - } - if vt.cursor.col < vt.margin.left { - return - } - if vt.cursor.col > vt.margin.right { - return - } - - if ps == 0 { - ps = 1 - } - - if int(vt.margin.bottom-vt.cursor.row) < (ps - 1) { - ps = int(vt.margin.bottom - vt.cursor.row) - } - - // move the lines first - for r := vt.margin.bottom; r >= (vt.cursor.row + row(ps)); r -= 1 { - copy(vt.activeScreen[r], vt.activeScreen[r-row(ps)]) - } - - // insert the blank lines (we do this by erasing the cells) - for r := row(0); r < row(ps); r += 1 { - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[vt.cursor.row+r][col].erase(vt.cursor.attrs) - } - } - vt.cursor.col = vt.margin.left -} - -// Delete Line (DL) CSI Ps M -// -// Deletes Ps lines starting at the line with the cursor. If fewer than Ps lines -// remain from the current line to the end of the scrolling region, the number -// of lines deleted is the lesser number. As lines are deleted, lines within the -// scrolling region and below the cursor move up, and blank lines are added at -// the bottom of the scrolling region. The cursor is reset to the first column. -// This sequence is ignored when the cursor is outside the scrolling region. -func (vt *VT) dl(ps int) { - vt.lastCol = false - if vt.cursor.row < vt.margin.top { - return - } - if vt.cursor.row > vt.margin.bottom { - return - } - if vt.cursor.col < vt.margin.left { - return - } - if vt.cursor.col > vt.margin.right { - return - } - - if ps == 0 { - ps = 1 - } - - if int(vt.margin.bottom-vt.cursor.row) < (ps - 1) { - ps = int(vt.margin.bottom - vt.cursor.row) - } - - for r := vt.cursor.row; r <= vt.margin.bottom; r += 1 { - if r <= vt.margin.bottom-row(ps) { - copy(vt.activeScreen[r], vt.activeScreen[r+row(ps)]) - continue - } - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - vt.cursor.col = vt.margin.left -} - -// Delete Characters (DCH) CSI Ps P -// -// Deletes Ps characters starting with the character at the cursor position. -// When a character is deleted, all characters to the right of the cursor move -// to the left. This creates a space character at the right margin for each -// character deleted. Character attributes move with the characters. The spaces -// created at the end of the line have all their character attributes off. -func (vt *VT) dch(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - row := vt.cursor.row - for col := vt.cursor.col; col <= vt.margin.right; col += 1 { - if col+column(ps) > vt.margin.right { - vt.activeScreen[row][col].erase(vt.cursor.attrs) - continue - } - vt.activeScreen[row][col] = vt.activeScreen[row][col+column(ps)] - } -} - -// Erase Characters (ECH) CSI Ps X -// -// Erases characters at the cursor position and the next Ps-1 characters. A -// parameter of 0 or 1 erases a single character. Character attributes are set -// to normal. No reformatting of data on the line occurs. The cursor remains in -// the same position. -func (vt *VT) ech(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - - for i := column(0); i < column(ps); i += 1 { - if vt.cursor.col+i == column(vt.width())-1 { - return - } - vt.activeScreen[vt.cursor.row][vt.cursor.col+i].erase(vt.cursor.attrs) - } -} - -// Cursor Backward Tabulation (CBT) CSI Ps Z -// -// Move cursor backward Ps tabulations -func (vt *VT) cbt(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - n := 0 - for i := len(vt.tabStop) - 1; i >= 0; i -= 1 { - if n == ps { - break - } - if vt.cursor.col < vt.tabStop[i] { - break - } - vt.cursor.col = vt.tabStop[i] - n += 1 - } -} - -// Tab Clear (TBC) CSI Ps g -func (vt *VT) tbc(ps int) { - switch ps { - case 0: - tabs := []column{} - for _, tab := range vt.tabStop { - if tab == vt.cursor.col { - continue - } - tabs = append(tabs, tab) - } - vt.tabStop = tabs - case 3: - vt.tabStop = []column{} - } -} - -// Line Position Absolute (VPA) CSI Ps d -// -// Move cursor to line Ps -func (vt *VT) vpa(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.row = row(ps - 1) - if vt.cursor.row > row(vt.height()-1) { - vt.cursor.row = row(vt.height() - 1) - } -} - -// Line Position Relative (VPR) CSI Ps e -// -// Move down Ps lines -func (vt *VT) vpr(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.row += row(ps) - if vt.cursor.row > row(vt.height()-1) { - vt.cursor.row = row(vt.height() - 1) - } -} - -// Character Position Absolute (HPA) CSI Ps ` -// -// Move cursor to column Ps -func (vt *VT) hpa(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col = column(ps - 1) - if vt.cursor.col > column(vt.width()-1) { - vt.cursor.col = column(vt.width() - 1) - } -} - -// Character Position Relative (HPR) CSI Ps a -// -// Move cursor to the right Ps times -func (vt *VT) hpr(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col += column(ps) - if vt.cursor.col > column(vt.width()-1) { - vt.cursor.col = column(vt.width() - 1) - } -} - -// Repeat (REP) CSI Ps b -// -// Repeat preceding graphic character Ps times -func (vt *VT) rep(ps int) { - vt.lastCol = false - col := vt.cursor.col - if col == 0 { - return - } - ch := vt.activeScreen[vt.cursor.row][col-1] - for i := 0; i < ps; i += 1 { - if col+column(i) == vt.margin.right { - return - } - vt.activeScreen[vt.cursor.row][vt.cursor.col+column(i)].content = ch.content - } -} - -// Set top and bottom margins CSI Ps ; Ps r -func (vt *VT) decstbm(pm []int) { - vt.lastCol = false - if len(pm) != 2 { - vt.margin.top = 0 - vt.margin.bottom = row(vt.height()) - 1 - return - } - vt.margin.top = row(pm[0]) - 1 - vt.margin.bottom = row(pm[1]) - 1 - vt.cursor.row = 0 - vt.cursor.col = 0 -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/csi_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/csi_test.go deleted file mode 100644 index cc4a076000..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/csi_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestICH(t *testing.T) { - vt := New() - vt.Resize(2, 1) - vt.mode = 0 - - vt.print('a') - vt.print('b') - assert.Equal(t, "ab", vt.String()) - vt.cursor.col = 0 - vt.ich(0) - assert.Equal(t, " a", vt.String()) - assert.Equal(t, column(0), vt.cursor.col) -} - -func TestCUU(t *testing.T) { - vt := New() - vt.Resize(2, 2) - - vt.cursor.row = 1 - vt.cursor.col = 1 - assert.Equal(t, column(1), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - vt.cuu(0) - - assert.Equal(t, row(0), vt.cursor.row) - assert.Equal(t, column(1), vt.cursor.col) - vt.cuu(0) - assert.Equal(t, row(0), vt.cursor.row) - assert.Equal(t, column(1), vt.cursor.col) -} - -func TestIL(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('a') - vt.print('b') - vt.cursor.col = 0 - vt.cursor.row = 0 - - vt.il(1) - assert.Equal(t, " \nab", vt.String()) - - vt = New() - vt.Resize(2, 2) - vt.print('a') - vt.print('b') - vt.cursor.col = 0 - vt.cursor.row = 0 - - vt.il(2) - assert.Equal(t, " \n ", vt.String()) -} - -func TestDL(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.cursor.row = 1 - vt.print('a') - vt.print('b') - assert.Equal(t, " \nab", vt.String()) - vt.cursor.col = 0 - vt.cursor.row = 0 - - vt.dl(1) - assert.Equal(t, "ab\n ", vt.String()) - - vt = New() - vt.Resize(2, 2) - vt.cursor.row = 1 - vt.print('a') - vt.print('b') - assert.Equal(t, " \nab", vt.String()) - vt.cursor.col = 0 - vt.cursor.row = 0 - vt.dl(2) - assert.Equal(t, " \n ", vt.String()) -} - -func TestDCH(t *testing.T) { - vt := New() - vt.Resize(4, 1) - vt.print('a') - vt.print('b') - vt.print('c') - vt.print('d') - assert.Equal(t, "abcd", vt.String()) - - vt.dch(1) - assert.Equal(t, "abc ", vt.String()) - vt.dch(2) - assert.Equal(t, "abc ", vt.String()) - vt.print('d') - assert.Equal(t, "abcd", vt.String()) - vt.cursor.col = 1 - vt.dch(2) - assert.Equal(t, "ad ", vt.String()) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/cursor.go b/cmd/sst/mosaic/multiplexer/tcell-term/cursor.go deleted file mode 100644 index d5ae235fa1..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/cursor.go +++ /dev/null @@ -1,14 +0,0 @@ -package tcellterm - -import ( - "github.com/gdamore/tcell/v2" -) - -type cursor struct { - attrs tcell.Style - style tcell.CursorStyle - - // position - row row // 0-indexed - col column // 0-indexed -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/esc.go b/cmd/sst/mosaic/multiplexer/tcell-term/esc.go deleted file mode 100644 index fde23ecae3..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/esc.go +++ /dev/null @@ -1,187 +0,0 @@ -package tcellterm - -func (vt *VT) esc(esc string) { - switch esc { - case "7": - vt.decsc() - case "8": - vt.decrc() - case "D": - vt.ind() - case "E": - vt.nel() - case "H": - vt.hts() - case "M": - vt.ri() - case "N": - vt.charsets.singleShift = true - vt.charsets.selected = g2 - case "O": - vt.charsets.singleShift = true - vt.charsets.selected = g3 - case "=": - // DECKPAM - case ">": - // DECKPNM - case "c": - vt.ris() - case "(0": - vt.charsets.designations[g0] = decSpecialAndLineDrawing - case ")0": - vt.charsets.designations[g1] = decSpecialAndLineDrawing - case "*0": - vt.charsets.designations[g2] = decSpecialAndLineDrawing - case "+0": - vt.charsets.designations[g3] = decSpecialAndLineDrawing - case "(B": - vt.charsets.designations[g0] = ascii - case ")B": - vt.charsets.designations[g1] = ascii - case "*B": - vt.charsets.designations[g2] = ascii - case "+B": - vt.charsets.designations[g3] = ascii - case "#8": - // DECALN - // Fill the screen with capital Es - // Not supported - } -} - -// Index ESC-D -func (vt *VT) ind() { - vt.lastCol = false - if vt.cursor.row == vt.margin.bottom { - vt.scrollUp(1) - return - } - if vt.cursor.row >= row(vt.height()-1) { - // don't let row go beyond the height - - return - } - vt.cursor.row += 1 -} - -// Next line ESC-E -// Moves cursor to the left margin of the next line, scrolling if necessary -func (vt *VT) nel() { - vt.ind() - vt.cursor.col = vt.margin.left -} - -// Horizontal tab set ESC-H -func (vt *VT) hts() { - vt.tabStop = append(vt.tabStop, vt.cursor.col) -} - -// Reverse Index ESC-M -func (vt *VT) ri() { - vt.lastCol = false - if vt.cursor.row < 0 { - return - } - if vt.cursor.row == vt.margin.top { - vt.scrollDown(1) - return - } - vt.cursor.row -= 1 -} - -// Save Cursor DECSC ESC-7 -func (vt *VT) decsc() { - state := cursorState{ - cursor: vt.cursor, - decawm: vt.mode&decawm != 0, - decom: vt.mode&decom != 0, - charsets: charsets{ - selected: vt.charsets.selected, - saved: vt.charsets.saved, - designations: map[charsetDesignator]charset{ - g0: vt.charsets.designations[g0], - g1: vt.charsets.designations[g1], - g2: vt.charsets.designations[g2], - g3: vt.charsets.designations[g3], - }, - }, - } - switch { - case vt.mode&smcup != 0: - // We are in alt screen - vt.altState = state - default: - vt.primaryState = state - } -} - -// Restore Cursor DECRC ESC-8 -func (vt *VT) decrc() { - var state cursorState - switch { - case vt.mode&smcup != 0: - // In the alt screen - state = vt.altState - default: - state = vt.primaryState - } - - vt.cursor = state.cursor - vt.charsets = charsets{ - selected: state.charsets.selected, - saved: state.charsets.saved, - designations: map[charsetDesignator]charset{ - g0: state.charsets.designations[g0], - g1: state.charsets.designations[g1], - g2: state.charsets.designations[g2], - g3: state.charsets.designations[g3], - }, - } - - switch state.decawm { - case true: - vt.mode |= decawm - case false: - vt.mode &^= decawm - } - - switch state.decom { - case true: - vt.mode |= decom - case false: - vt.mode &^= decom - } -} - -// Reset Initial State (RIS) ESC-c -func (vt *VT) ris() { - w := vt.width() - h := vt.height() - vt.altScreen = make([][]cell, h) - vt.primaryScreen = make([][]cell, h) - for i := range vt.altScreen { - vt.altScreen[i] = make([]cell, w) - vt.primaryScreen[i] = make([]cell, w) - } - vt.margin.bottom = row(h) - 1 - vt.margin.right = column(w) - 1 - vt.cursor.row = 0 - vt.cursor.col = 0 - vt.lastCol = false - vt.activeScreen = vt.primaryScreen - vt.charsets = charsets{ - selected: 0, - saved: 0, - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - } - vt.mode = decawm | dectcem - vt.tabStop = []column{} - for i := 7; i < (50 * 7); i += 8 { - vt.tabStop = append(vt.tabStop, column(i)) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/events.go b/cmd/sst/mosaic/multiplexer/tcell-term/events.go deleted file mode 100644 index 2072741984..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/events.go +++ /dev/null @@ -1,69 +0,0 @@ -package tcellterm - -import ( - "time" - - "github.com/gdamore/tcell/v2" -) - -// EventTerminal is a generic terminal event -type EventTerminal struct { - when time.Time - vt *VT -} - -func newEventTerminal(vt *VT) *EventTerminal { - return &EventTerminal{ - when: time.Now(), - vt: vt, - } -} - -func (ev *EventTerminal) When() time.Time { - return ev.when -} - -func (ev *EventTerminal) VT() *VT { - return ev.vt -} - -// EventRedraw is emitted when the terminal requires redrawing -type EventRedraw struct { - *EventTerminal -} - -// EventClosed is emitted when the terminal exits -type EventClosed struct { - *EventTerminal -} - -// EventTitle is emitted when the terminal's title changes -type EventTitle struct { - *EventTerminal - title string -} - -func (ev *EventTitle) Title() string { - return ev.title -} - -// EventMouseMode is emitted when the terminal mouse mode changes -type EventMouseMode struct { - modes []tcell.MouseFlags - - *EventTerminal -} - -func (ev *EventMouseMode) Flags() []tcell.MouseFlags { - return ev.modes -} - -// EventBell is emitted when BEL is received -type EventBell struct { - *EventTerminal -} - -type EventPanic struct { - *EventTerminal - Error error -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/key.go b/cmd/sst/mosaic/multiplexer/tcell-term/key.go deleted file mode 100644 index ec9549533e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/key.go +++ /dev/null @@ -1,691 +0,0 @@ -package tcellterm - -import ( - "strings" - - "github.com/gdamore/tcell/v2" -) - -func keyCode(ev *tcell.EventKey) string { - key := strings.Builder{} - switch ev.Modifiers() { - case tcell.ModNone: - switch ev.Key() { - case tcell.KeyRune: - key.WriteRune(ev.Rune()) - default: - if str, ok := keyCodes[ev.Key()]; ok { - key.WriteString(str) - } else { - key.WriteRune(rune(ev.Key())) - } - } - case tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyShfEnd) - case tcell.KeyInsert: - key.WriteString(info.KeyShfInsert) - case tcell.KeyDelete: - key.WriteString(info.KeyShfDelete) - case tcell.KeyPgUp: - key.WriteString(info.KeyShfPgUp) - case tcell.KeyPgDn: - key.WriteString(info.KeyShfPgDn) - case tcell.KeyF1: - key.WriteString(info.KeyF13) - case tcell.KeyF2: - key.WriteString(info.KeyF14) - case tcell.KeyF3: - key.WriteString(info.KeyF15) - case tcell.KeyF4: - key.WriteString(info.KeyF16) - case tcell.KeyF5: - key.WriteString(info.KeyF17) - case tcell.KeyF6: - key.WriteString(info.KeyF18) - case tcell.KeyF7: - key.WriteString(info.KeyF19) - case tcell.KeyF8: - key.WriteString(info.KeyF20) - case tcell.KeyF9: - key.WriteString(info.KeyF21) - case tcell.KeyF10: - key.WriteString(info.KeyF22) - case tcell.KeyF11: - key.WriteString(info.KeyF23) - case tcell.KeyF12: - key.WriteString(info.KeyF24) - } - case tcell.ModAlt: - switch ev.Key() { - case tcell.KeyRune: - key.WriteString("\x1b") - key.WriteRune(ev.Rune()) - case tcell.KeyUp: - key.WriteString(info.KeyAltUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF49) - case tcell.KeyF2: - key.WriteString(info.KeyF50) - case tcell.KeyF3: - key.WriteString(info.KeyF51) - case tcell.KeyF4: - key.WriteString(info.KeyF53) - case tcell.KeyF5: - key.WriteString(info.KeyF54) - case tcell.KeyF6: - key.WriteString(info.KeyF55) - case tcell.KeyF7: - key.WriteString(info.KeyF56) - case tcell.KeyF8: - key.WriteString(info.KeyF57) - case tcell.KeyF9: - key.WriteString(info.KeyF58) - case tcell.KeyF10: - key.WriteString(info.KeyF59) - case tcell.KeyF11: - key.WriteString(info.KeyF60) - case tcell.KeyF12: - key.WriteString(info.KeyF61) - } - case tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF25) - case tcell.KeyF2: - key.WriteString(info.KeyF26) - case tcell.KeyF3: - key.WriteString(info.KeyF27) - case tcell.KeyF4: - key.WriteString(info.KeyF28) - case tcell.KeyF5: - key.WriteString(info.KeyF29) - case tcell.KeyF6: - key.WriteString(info.KeyF30) - case tcell.KeyF7: - key.WriteString(info.KeyF31) - case tcell.KeyF8: - key.WriteString(info.KeyF32) - case tcell.KeyF9: - key.WriteString(info.KeyF33) - case tcell.KeyF10: - key.WriteString(info.KeyF34) - case tcell.KeyF11: - key.WriteString(info.KeyF35) - case tcell.KeyF12: - key.WriteString(info.KeyF36) - default: - key.WriteRune(ev.Rune()) - } - case tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF37) - case tcell.KeyF2: - key.WriteString(info.KeyF38) - case tcell.KeyF3: - key.WriteString(info.KeyF39) - case tcell.KeyF4: - key.WriteString(info.KeyF40) - case tcell.KeyF5: - key.WriteString(info.KeyF41) - case tcell.KeyF6: - key.WriteString(info.KeyF42) - case tcell.KeyF7: - key.WriteString(info.KeyF43) - case tcell.KeyF8: - key.WriteString(info.KeyF44) - case tcell.KeyF9: - key.WriteString(info.KeyF45) - case tcell.KeyF10: - key.WriteString(info.KeyF46) - case tcell.KeyF11: - key.WriteString(info.KeyF47) - case tcell.KeyF12: - key.WriteString(info.KeyF48) - } - case tcell.ModAlt | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyAltShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF61) - case tcell.KeyF2: - key.WriteString(info.KeyF62) - case tcell.KeyF3: - key.WriteString(info.KeyF63) - case tcell.KeyF4: - key.WriteString(info.KeyF64) - } - case tcell.ModAlt | tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltPgDown) - } - case tcell.ModAlt | tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltShfUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltShfDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltShfRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltShfLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltShfHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltShfPgDown) - } - case tcell.ModMeta: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";9~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;9") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";10~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;10") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";11~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;11") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";12~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;12") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";13~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;13") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";14~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;14") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";15~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;15") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";16~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;16") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - } - return key.String() -} - -var keyCodes = map[tcell.Key]string{ - tcell.KeyBackspace: info.KeyBackspace, - tcell.KeyF1: info.KeyF1, - tcell.KeyF2: info.KeyF2, - tcell.KeyF3: info.KeyF3, - tcell.KeyF4: info.KeyF4, - tcell.KeyF5: info.KeyF5, - tcell.KeyF6: info.KeyF6, - tcell.KeyF7: info.KeyF7, - tcell.KeyF8: info.KeyF8, - tcell.KeyF9: info.KeyF9, - tcell.KeyF10: info.KeyF10, - tcell.KeyF11: info.KeyF11, - tcell.KeyF12: info.KeyF12, - tcell.KeyF13: info.KeyF13, - tcell.KeyF14: info.KeyF14, - tcell.KeyF15: info.KeyF15, - tcell.KeyF16: info.KeyF16, - tcell.KeyF17: info.KeyF17, - tcell.KeyF18: info.KeyF18, - tcell.KeyF19: info.KeyF19, - tcell.KeyF20: info.KeyF20, - tcell.KeyF21: info.KeyF21, - tcell.KeyF22: info.KeyF22, - tcell.KeyF23: info.KeyF23, - tcell.KeyF24: info.KeyF24, - tcell.KeyF25: info.KeyF25, - tcell.KeyF26: info.KeyF26, - tcell.KeyF27: info.KeyF27, - tcell.KeyF28: info.KeyF28, - tcell.KeyF29: info.KeyF29, - tcell.KeyF30: info.KeyF30, - tcell.KeyF31: info.KeyF31, - tcell.KeyF32: info.KeyF32, - tcell.KeyF33: info.KeyF33, - tcell.KeyF34: info.KeyF34, - tcell.KeyF35: info.KeyF35, - tcell.KeyF36: info.KeyF36, - tcell.KeyF37: info.KeyF37, - tcell.KeyF38: info.KeyF38, - tcell.KeyF39: info.KeyF39, - tcell.KeyF40: info.KeyF40, - tcell.KeyF41: info.KeyF41, - tcell.KeyF42: info.KeyF42, - tcell.KeyF43: info.KeyF43, - tcell.KeyF44: info.KeyF44, - tcell.KeyF45: info.KeyF45, - tcell.KeyF46: info.KeyF46, - tcell.KeyF47: info.KeyF47, - tcell.KeyF48: info.KeyF48, - tcell.KeyF49: info.KeyF49, - tcell.KeyF50: info.KeyF50, - tcell.KeyF51: info.KeyF51, - tcell.KeyF52: info.KeyF52, - tcell.KeyF53: info.KeyF53, - tcell.KeyF54: info.KeyF54, - tcell.KeyF55: info.KeyF55, - tcell.KeyF56: info.KeyF56, - tcell.KeyF57: info.KeyF57, - tcell.KeyF58: info.KeyF58, - tcell.KeyF59: info.KeyF59, - tcell.KeyF60: info.KeyF60, - tcell.KeyF61: info.KeyF61, - tcell.KeyF62: info.KeyF62, - tcell.KeyF63: info.KeyF63, - tcell.KeyF64: info.KeyF64, - tcell.KeyInsert: info.KeyInsert, - tcell.KeyDelete: info.KeyDelete, - tcell.KeyHome: info.KeyHome, - tcell.KeyEnd: info.KeyEnd, - tcell.KeyHelp: info.KeyHelp, - tcell.KeyPgUp: info.KeyPgUp, - tcell.KeyPgDn: info.KeyPgDn, - tcell.KeyUp: info.KeyUp, - tcell.KeyDown: info.KeyDown, - tcell.KeyLeft: info.KeyLeft, - tcell.KeyRight: info.KeyRight, - tcell.KeyBacktab: info.KeyBacktab, - tcell.KeyExit: info.KeyExit, - tcell.KeyClear: info.KeyClear, - tcell.KeyPrint: info.KeyPrint, - tcell.KeyCancel: info.KeyCancel, -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/key_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/key_test.go deleted file mode 100644 index 19e1ce920e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/key_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/gdamore/tcell/v2" - "github.com/stretchr/testify/assert" -) - -func TestKey(t *testing.T) { - tests := []struct { - name string - event *tcell.EventKey - expected string - }{ - { - name: "rune", - event: tcell.NewEventKey( - tcell.KeyRune, - 'j', - tcell.ModNone, - ), - expected: "j", - }, - { - name: "F1", - event: tcell.NewEventKey( - tcell.KeyF1, - 0, - tcell.ModNone, - ), - expected: "\x1bOP", - }, - { - name: "Shift-right", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift, - ), - expected: "\x1b[1;2C", - }, - { - name: "Ctrl-Shift-right", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift|tcell.ModCtrl, - ), - expected: "\x1b[1;6C", - }, - { - name: "Alt-Shift-right", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift|tcell.ModAlt, - ), - expected: "\x1b[1;4C", - }, - { - name: "rune + mod alt", - event: tcell.NewEventKey( - tcell.KeyRune, - 'j', - tcell.ModAlt, - ), - expected: "\x1Bj", - }, - { - name: "rune + mod ctrl", - event: tcell.NewEventKey( - tcell.KeyCtrlJ, - 0x0A, - tcell.ModCtrl, - ), - expected: "\n", - }, - { - name: "shift + f5", - event: tcell.NewEventKey( - tcell.KeyF5, - 0, - tcell.ModShift, - ), - expected: "\x1B[15;2~", - }, - { - name: "shift + arrow", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift, - ), - expected: "\x1B[1;2C", - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - actual := keyCode(test.event) - assert.Equal(t, test.expected, actual) - }) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/mode.go b/cmd/sst/mosaic/multiplexer/tcell-term/mode.go deleted file mode 100644 index 26401ca9de..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/mode.go +++ /dev/null @@ -1,178 +0,0 @@ -package tcellterm - -type mode int - -const ( - // ANSI-Standardized modes - // - // Keyboard Action mode - kam mode = 1 << iota - // Insert/Replace mode - irm - // Send/Receive mode - srm - // Line feed/new line mode - lnm - - // ANSI-Compatible DEC Private Modes - // - // Cursor Key mode - decckm - // ANSI/VT52 mode - decanm - // Column mode - deccolm - // Scroll mode - decsclm - // Origin mode - decom - // Autowrap mode - decawm - // Autorepeat mode - decarm - // Printer form feed mode - decpff - // Printer extent mode - decpex - // Text Cursor Enable mode - dectcem - // National replacement character sets - decnrcm - - // xterm - // - // Use alternate screen - smcup - // Bracketed paste - paste - // vt220 mouse - mouseButtons - // vt220 + drag - mouseDrag - // vt220 + all motion - mouseMotion - // Mouse SGR mode - mouseSGR - // Alternate scroll - altScroll -) - -func (vt *VT) sm(params []int) { - for _, param := range params { - switch param { - case 2: - vt.mode |= kam - case 4: - vt.mode |= irm - case 12: - vt.mode |= srm - case 20: - vt.mode |= lnm - } - } -} - -func (vt *VT) rm(params []int) { - for _, param := range params { - switch param { - case 2: - vt.mode &^= kam - case 4: - vt.mode &^= irm - case 12: - vt.mode &^= srm - case 20: - vt.mode &^= lnm - } - } -} - -func (vt *VT) decset(params []int) { - for _, param := range params { - switch param { - case 1: - vt.mode |= decckm - case 2: - vt.mode |= decanm - case 3: - vt.mode |= deccolm - case 4: - vt.mode |= decsclm - case 5: - case 6: - vt.mode |= decom - case 7: - vt.mode |= decawm - vt.lastCol = false - case 8: - vt.mode |= decarm - case 25: - vt.mode |= dectcem - case 1000: - vt.mode |= mouseButtons - case 1002: - vt.mode |= mouseDrag - case 1003: - vt.mode |= mouseMotion - case 1006: - vt.mode |= mouseSGR - case 1007: - vt.mode |= altScroll - case 1049: - vt.decsc() - vt.activeScreen = vt.altScreen - vt.mode |= smcup - // Enable altScroll in the alt screen. This is only used - // if the application doesn't enable mouse - vt.mode |= altScroll - case 2004: - vt.mode |= paste - } - } -} - -func (vt *VT) decrst(params []int) { - for _, param := range params { - switch param { - case 1: - vt.mode &^= decckm - case 2: - vt.mode &^= decanm - case 3: - vt.mode &^= deccolm - case 4: - vt.mode &^= decsclm - case 5: - case 6: - vt.mode &^= decom - case 7: - vt.mode &^= decawm - vt.lastCol = false - case 8: - vt.mode &^= decarm - case 25: - vt.mode &^= dectcem - case 1000: - vt.mode &^= mouseButtons - case 1002: - vt.mode &^= mouseDrag - case 1003: - vt.mode &^= mouseMotion - case 1006: - vt.mode &^= mouseSGR - case 1007: - vt.mode &^= altScroll - case 1049: - if vt.mode&smcup != 0 { - // Only clear if we were in the alternate - vt.ed(2) - } - vt.activeScreen = vt.primaryScreen - vt.mode &^= smcup - vt.mode &^= altScroll - vt.decrc() - case 2004: - vt.mode &^= paste - } - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/mouse.go b/cmd/sst/mosaic/multiplexer/tcell-term/mouse.go deleted file mode 100644 index 36a1384bf4..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/mouse.go +++ /dev/null @@ -1,109 +0,0 @@ -package tcellterm - -import ( - "fmt" - - "github.com/gdamore/tcell/v2" -) - -func (vt *VT) handleMouse(ev *tcell.EventMouse) string { - if vt.mode&mouseButtons == 0 && vt.mode&mouseDrag == 0 && vt.mode&mouseMotion == 0 && vt.mode&mouseSGR == 0 { - if vt.mode&altScroll != 0 && vt.mode&smcup != 0 { - // Translate wheel motion into arrows up and down - // 3x rows - if ev.Buttons()&tcell.WheelUp != 0 { - vt.pty.WriteString(info.KeyUp) - vt.pty.WriteString(info.KeyUp) - vt.pty.WriteString(info.KeyUp) - } - if ev.Buttons()&tcell.WheelDown != 0 { - vt.pty.WriteString(info.KeyDown) - vt.pty.WriteString(info.KeyDown) - vt.pty.WriteString(info.KeyDown) - } - } - return "" - } - // Return early if we aren't reporting motion or drag events - if vt.mode&mouseButtons != 0 && vt.mouseBtn == ev.Buttons() { - // motion or drag - return "" - } - - if vt.mode&mouseDrag != 0 && vt.mouseBtn == tcell.ButtonNone && ev.Buttons() == tcell.ButtonNone { - // Motion event - return "" - } - - // Encode the button - var b int - if ev.Buttons()&tcell.Button1 != 0 { - b += 0 - } - if ev.Buttons()&tcell.Button3 != 0 { - b += 1 - } - if ev.Buttons()&tcell.Button2 != 0 { - b += 2 - } - if ev.Buttons() == tcell.ButtonNone { - b += 3 - } - if ev.Buttons()&tcell.WheelUp != 0 { - b += 0 + 64 - } - if ev.Buttons()&tcell.WheelDown != 0 { - b += 1 + 64 - } - if ev.Modifiers()&tcell.ModShift != 0 { - b += 4 - } - if ev.Modifiers()&tcell.ModAlt != 0 { - b += 8 - } - if ev.Modifiers()&tcell.ModCtrl != 0 { - b += 16 - } - - if vt.mode&mouseButtons == 0 && vt.mouseBtn != tcell.ButtonNone && ev.Buttons() != tcell.ButtonNone { - // drag event - b += 32 - } - - col, row := ev.Position() - - if vt.mode&mouseSGR != 0 { - switch { - case ev.Buttons()&tcell.WheelUp != 0: - return fmt.Sprintf("\x1b[<%d;%d;%dM", b, col+1, row+1) - - case ev.Buttons()&tcell.WheelDown != 0: - return fmt.Sprintf("\x1b[<%d;%d;%dM", b, col+1, row+1) - - case ev.Buttons() == tcell.ButtonNone && vt.mouseBtn != tcell.ButtonNone: - // Button was in, and now it's not - var button int - switch vt.mouseBtn { - case tcell.Button1: - button = 0 - case tcell.Button3: - button = 1 - case tcell.Button2: - button = 2 - } - vt.mouseBtn = ev.Buttons() - return fmt.Sprintf("\x1b[<%d;%d;%dm", button, col+1, row+1) - - default: - vt.mouseBtn = ev.Buttons() - return fmt.Sprintf("\x1b[<%d;%d;%dM", b, col+1, row+1) - } - } - - encodedCol := 32 + col + 1 - encodedRow := 32 + row + 1 - b += 32 - - vt.mouseBtn = ev.Buttons() - return fmt.Sprintf("\x1b[M%c%c%c", b, encodedCol, encodedRow) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/mouse_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/mouse_test.go deleted file mode 100644 index 30972fcf83..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/mouse_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/gdamore/tcell/v2" - "github.com/stretchr/testify/assert" -) - -func TestHandleMouse(t *testing.T) { - tests := []struct { - name string - mode mode - button tcell.ButtonMask - event *tcell.EventMouse - expected string - }{ - { - name: "button 1", - mode: mouseButtons, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "\x1b[M !!", - }, - { - name: "button 1 + shift", - mode: mouseButtons, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModShift), - expected: "\x1b[M$!!", - }, - { - name: "button 1 drag, in normal mode", - mode: mouseButtons, - button: tcell.Button1, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "", - }, - { - name: "button 1 release, in normal mode", - mode: mouseButtons, - button: tcell.Button1, - event: tcell.NewEventMouse(0, 0, tcell.ButtonNone, tcell.ModNone), - expected: "\x1b[M#!!", - }, - { - name: "button 1 drag, in drag mode", - mode: mouseDrag, - button: tcell.Button1, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "\x1b[M@!!", - }, - { - name: "button 1 sgr", - mode: mouseSGR, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "\x1b[<0;1;1M", - }, - { - name: "no button motion sgr", - mode: mouseSGR, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.ButtonNone, tcell.ModNone), - expected: "\x1b[<3;1;1M", - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - vt := New() - vt.mouseBtn = test.button - vt.mode |= test.mode - actual := vt.handleMouse(test.event) - assert.Equal(t, test.expected, actual) - }) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/osc.go b/cmd/sst/mosaic/multiplexer/tcell-term/osc.go deleted file mode 100644 index 53a7278042..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/osc.go +++ /dev/null @@ -1,56 +0,0 @@ -package tcellterm - -import ( - "strings" -) - -func (vt *VT) osc(data string) { - selector, val, found := cutString(data, ";") - if !found { - return - } - switch selector { - case "0", "2": - ev := &EventTitle{ - EventTerminal: newEventTerminal(vt), - title: val, - } - vt.postEvent(ev) - case "8": - if vt.OSC8 { - url, id := osc8(val) - vt.cursor.attrs = vt.cursor.attrs.Url(url) - vt.cursor.attrs = vt.cursor.attrs.UrlId(id) - } - } -} - -// parses an osc8 payload into the URL and optional ID -func osc8(val string) (string, string) { - // OSC 8 ; params ; url ST - // params: key1=value1:key2=value2 - var id string - params, url, found := cutString(val, ";") - if !found { - return "", "" - } - for _, param := range strings.Split(params, ":") { - key, val, found := cutString(param, "=") - if !found { - continue - } - switch key { - case "id": - id = val - } - } - return url, id -} - -// Copied from stdlib to here for go 1.16 compat -func cutString(s string, sep string) (before string, after string, found bool) { - if i := strings.Index(s, sep); i >= 0 { - return s[:i], s[i+len(sep):], true - } - return s, "", false -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/osc_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/osc_test.go deleted file mode 100644 index 6bd5567ae4..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/osc_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestParseOSC8(t *testing.T) { - tests := []struct { - name string - input string - expected string - expectedID string - }{ - { - name: "no semicolon in URI", - input: "8;;https://example.com", - expected: "https://example.com", - expectedID: "", - }, - { - name: "no semicolon in URI, with id", - input: "8;id=hello;https://example.com", - expected: "https://example.com", - expectedID: "hello", - }, - { - name: "semicolon in URI", - input: "8;;https://example.com/semi;colon", - expected: "https://example.com/semi;colon", - expectedID: "", - }, - { - name: "multiple semicolons in URI", - input: "8;;https://example.com/s;e;m;i;colon", - expected: "https://example.com/s;e;m;i;colon", - expectedID: "", - }, - { - name: "semicolon in URI, with id", - input: "8;id=hello;https://example.com/semi;colon", - expected: "https://example.com/semi;colon", - expectedID: "hello", - }, - { - name: "terminating sequence", - input: "8;;", - expected: "", - expectedID: "", - }, - { - name: "terminating sequence with id", - input: "8;id=hello;", - expected: "", - expectedID: "hello", - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // Simulate vt.osc - selector, val, found := cutString(test.input, ";") - if !found { - return - } - assert.Equal(t, "8", selector) - // parse the result - url, id := osc8(val) - assert.Equal(t, test.expected, url) - assert.Equal(t, test.expectedID, id) - }) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/parse.go b/cmd/sst/mosaic/multiplexer/tcell-term/parse.go deleted file mode 100644 index 6a75b076b9..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/parse.go +++ /dev/null @@ -1,850 +0,0 @@ -package tcellterm - -import ( - "bufio" - "fmt" - "io" - "strconv" - "strings" - "unicode" -) - -const eof rune = -1 - -// https://vt100.net/emu/dec_ansi_parser -// -// parser is an implementation of Paul Flo Williams' VT500-series -// parser, as seen [here](https://vt100.net/emu/dec_ansi_parser). The -// architecture is designed after Rob Pike's text/template parser, with a -// few modifications. -// -// Many of the comments are directly from Paul Flo Williams description of -// the parser, licensed undo [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) -type Parser struct { - r *bufio.Reader - sequences chan Sequence - state stateFn - exit func() - intermediate []rune - params []rune - final rune - - oscData []rune -} - -func NewParser(r io.Reader) *Parser { - parser := &Parser{ - r: bufio.NewReader(r), - sequences: make(chan Sequence, 2), - state: ground, - } - // Rob Pike didn't use concurrency since he wanted templates to be able - // to happen in init() functions, but we don't care about that. - go parser.run() - return parser -} - -// Next returns the next Sequence. Sequences will be of the following types: -// -// error Sent on any parsing error -// Print Print the character to the screen -// C0 Execute the C0 code -// ESC Execute the ESC sequence -// CSI Execute the CSI sequence -// OSCStart Signals the start of an OSC sequence -// OSCData Characters from the OSC sequence -// OSCEnd Signals end of the OSC sequence -// DCS Signals start of a DCS sequence, and DCS params/intermediates -// DCSData Raw DCS passthrough data -// DCSEndOfData Signals end of DCS sequence -// EOF Sent at end of input -func (p *Parser) Next() Sequence { - return <-p.sequences -} - -func (p *Parser) run() { - for { - r := p.readRune() - p.state = anywhere(r, p) - if p.state == nil { - break - } - } - p.emit(EOF{}) - close(p.sequences) -} - -func (p *Parser) readRune() rune { - r, _, err := p.r.ReadRune() - if r == unicode.ReplacementChar { - // If invalid UTF-8, let's read the byte and deliver - // it as is - err = p.r.UnreadRune() - if err != nil { - return eof - } - b, err := p.r.ReadByte() - if err != nil { - return eof - } - r = rune(b) - } - if err != nil { - return eof - } - return r -} - -func (p *Parser) emit(seq Sequence) { - p.sequences <- seq -} - -// This action only occurs in ground state. The current code should be mapped to -// a glyph according to the character set mappings and shift states in effect, -// and that glyph should be displayed. 20 (SP) and 7F (DEL) have special -// behaviour in later VT series, as described in ground. -func (p *Parser) print(r rune) { - p.emit(Print(r)) -} - -// The C0 or C1 control function should be executed, which may have any one of a -// variety of effects, including changing the cursor position, suspending or -// resuming communications or changing the shift states in effect. There are no -// parameters to this action. -func (p *Parser) execute(r rune) { - if in(r, 0x00, 0x1F) { - p.emit(C0(r)) - return - } -} - -// This action causes the current private flag, intermediate characters, final -// character and parameters to be forgotten. This occurs on entry to the escape, -// csi entry and dcs entry states, so that erroneous sequences like CSI 3 ; 1 -// CSI 2 J are handled correctly. -func (p *Parser) clear() { - p.intermediate = []rune{} - p.final = rune(0) - p.params = []rune{} -} - -// The private marker or intermediate character should be stored for later -// use in selecting a control function to be executed when a final -// character arrives. X3.64 doesn’t place any limit on the number of -// intermediate characters allowed before a final character, although it -// doesn’t define any control sequences with more than one. Digital defined -// escape sequences with two intermediate characters, and control sequences -// and device control strings with one. If more than two intermediate -// characters arrive, the parser can just flag this so that the dispatch -// can be turned into a null operation. -func (p *Parser) collect(r rune) { - p.intermediate = append(p.intermediate, r) -} - -// The final character of an escape sequence has arrived, so determined the -// control function to be executed from the intermediate character(s) and -// final character, and execute it. The intermediate characters are -// available because collect stored them as they arrived. -func (p *Parser) escapeDispatch(r rune) { - p.emit(ESC{ - Final: r, - Intermediate: p.intermediate, - }) - return -} - -// This action collects the characters of a parameter string for a control -// sequence or device control sequence and builds a list of parameters. The -// characters processed by this action are the digits 0-9 (codes 30-39) and -// the semicolon (code 3B). The semicolon separates parameters. There is no -// limit to the number of characters in a parameter string, although a -// maximum of 16 parameters need be stored. If more than 16 parameters -// arrive, all the extra parameters are silently ignored. -// -// Most control functions support default values for their parameters. The -// default value for a parameter is given by either leaving the parameter -// blank, or specifying a value of zero. Judging by previous threads on the -// newsgroup comp.terminals, this causes some confusion, with the -// occasional assertion that zero is the default parameter value for -// control functions. This is not the case: many control functions have a -// default value of 1, one (GSM) has a default value of 100, and some have -// no default. However, in all cases the default value is represented by -// either zero or a blank value. -// -// In the standard ECMA-48, which can be considered X3.64’s successorΒ², -// there is a distinction between a parameter with an empty value -// (representing the default value), and one that has the value zero. There -// used to be a mode, ZDM (Zero Default Mode), in which the two cases were -// treated identically, but that is now deprecated in the fifth edition -// (1991). Although a VT500 parser needs to treat both empty and zero -// parameters as representing the default, it is worth considering future -// extensions by distinguishing them internally -func (p *Parser) param(r rune) { - p.params = append(p.params, r) -} - -// A final character has arrived, so determine the control function to be -// executed from private marker, intermediate character(s) and final -// character, and execute it, passing in the parameter list. -// -// csiDispatch will normalize SGR RGB sequences to a maximum of 5 parameters. IE -// '38:2::0:0:0' will return []int{38,2,0,0,0} -func (p *Parser) csiDispatch(r rune) { - csi := CSI{ - Final: r, - Intermediate: p.intermediate, - Parameters: []int{}, - } - if len(p.params) == 0 { - p.emit(csi) - return - } - paramStrRaw := strings.Split(string(p.params), ";") - paramStr := make([]string, 0, len(paramStrRaw)) - for _, param := range paramStrRaw { - if !strings.Contains(param, ":") { - paramStr = append(paramStr, param) - continue - } - // Contains an RGB param string. Preprocess this to normalize to - // a length of 5 - paramsRGB := strings.Split(param, ":") - switch len(paramsRGB) { - case 2: - // Could be an underline sequence CSI 4:Ps m. We only - // support underline, so drop the second param - paramStr = append(paramStr, paramsRGB[0]) - case 5: - paramStr = append(paramStr, paramsRGB...) - case 6: - for i, p := range paramsRGB { - if i == 2 { - continue - } - paramStr = append(paramStr, p) - } - } - } - params := make([]int, 0, len(paramStr)) - for _, param := range paramStr { - if param == "" { - params = append(params, 0) - continue - } - val, err := strconv.Atoi(param) - if err != nil { - p.emit(fmt.Errorf("csiDispatch: %w", err)) - return - } - params = append(params, val) - } - csi.Parameters = params - p.emit(csi) -} - -// When the control function OSC (Operating System Command) is recognised, -// this action initializes an external parser (the β€œOSC Handler”) to handle -// the characters from the control string. OSC control strings are not -// structured in the same way as device control strings, so there is no -// choice of parsers. -// -// oscStart registers oscEnd as the exit function. This will be called on when -// the state moves from oscString to any other state -func (p *Parser) oscStart() { - // p.emit(OSCStart{}) - p.exit = p.oscEnd -} - -// This action passes characters from the control string to the OSC Handler -// as they arrive. There is therefore no need to buffer characters until -// the end of the control string is recognised. -func (p *Parser) oscPut(r rune) { - p.oscData = append(p.oscData, r) - // p.emit(OSCData(r)) -} - -// This action is called when the OSC string is terminated by ST, CAN, SUB -// or ESC, to allow the OSC handler to finish neatly. -func (p *Parser) oscEnd() { - p.emit(OSC{ - Payload: p.oscData, - }) - p.oscData = []rune{} -} - -// This action is invoked when a final character arrives in the first part -// of a device control string. It determines the control function from the -// private marker, intermediate character(s) and final character, and -// executes it, passing in the parameter list. It also selects a handler -// function for the rest of the characters in the control string. This -// handler function will be called by the put action for every character in -// the control string as it arrives. -// -// This way of handling device control strings has been selected because it -// allows the simple plugging-in of extra parsers as functionality is -// added. Support for a fairly simple control string like DECDLD (Downline -// Load) could be added into the main parser if soft characters were -// required, but the main parser is no place for complicated protocols like -// ReGIS. -// -// hook registers unhook as the exit function. This will be called on when -// the state moves from dcsPassthrough to any other state -func (p *Parser) hook(r rune) { - p.exit = p.unhook - dcs := DCS{ - Final: r, - Intermediate: p.intermediate, - Parameters: []int{}, - } - if len(p.params) == 0 { - p.emit(dcs) - return - } - paramStr := strings.Split(string(p.params), ";") - params := make([]int, 0, len(paramStr)) - for _, param := range paramStr { - if param == "" { - params = append(params, 0) - continue - } - val, err := strconv.Atoi(param) - if err != nil { - p.emit(fmt.Errorf("hook: %w", err)) - return - } - params = append(params, val) - } - dcs.Parameters = params - p.emit(dcs) -} - -// This action passes characters from the data string part of a device -// control string to a handler that has previously been selected by the -// hook action. C0 controls are also passed to the handler. -func (p *Parser) put(r rune) { - p.emit(DCSData(r)) -} - -// When a device control string is terminated by ST, CAN, SUB or ESC, this -// action calls the previously selected handler function with an β€œend of -// data” parameter. This allows the handler to finish neatly. -func (p *Parser) unhook() { - p.emit(DCSEndOfData{}) -} - -// in returns true if the rune lies within the range, inclusive of the endpoints -func in(r rune, min int32, max int32) bool { - if r >= min && r <= max { - return true - } - return false -} - -// is returns true of the rune matches any of the provided values -func is(r rune, vals ...int32) bool { - for _, val := range vals { - if r == val { - return true - } - } - return false -} - -// State functions - -type stateFn func(rune, *Parser) stateFn - -// This isn’t a real state. It is used on the state diagram to show -// transitions that can occur from any state to some other state. -func anywhere(r rune, p *Parser) stateFn { - switch { - case r == eof: - if p.exit != nil { - p.exit() - p.exit = nil - } - p.emit(nil) - return nil - case is(r, 0x18, 0x1A): - if p.exit != nil { - p.exit() - p.exit = nil - } - p.execute(r) - return ground - case is(r, 0x1B): - if p.exit != nil { - p.exit() - p.exit = nil - } - p.clear() - return escape - default: - return p.state(r, p) - } -} - -// This state is entered when the control function CSI is recognised, in -// 7-bit or 8-bit form. This state will only deal with the first character -// of a control sequence, because the characters 3C-3F can only appear as -// the first character of a control sequence, if they appear at all. -// Strictly speaking, X3.64 says that the entire string is β€œsubject to -// private or experimental interpretation” if the first character is one of -// 3C-3F, which allows sequences like CSI ?::) and 3F (?) were used by Digital. -// -// C0 controls are executed immediately during the recognition of a control -// sequence. C1 controls will cancel the sequence and then be executed. I -// imagine this treatment of C1 controls is prompted by the consideration -// that the 7-bit (ESC Fe) and 8-bit representations of C1 controls should -// act in the same way. When the first character of the 7-bit -// representation, ESC, is received, it will cancel the control sequence, -// so the 8-bit representation should do so as well. -func csiEntry(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiEntry - case is(r, 0x7F): - // ignore - return csiEntry - case in(r, 0x30, 0x39), is(r, 0x3B, 0x3A): - // 0x3A is not per the PFW, but using colons is valid SGR - // syntax for separating params when including colorspace. The - // colorspace should be ignored - p.param(r) - return csiParam - case in(r, 0x3C, 0x3F): - p.collect(r) - return csiParam - // case is(r, 0x3A): - // return csiIgnore - case in(r, 0x20, 0x2F): - p.collect(r) - return csiIntermediate - case in(r, 0x40, 0x7E): - p.csiDispatch(r) - return ground - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is entered when a parameter character is recognised in a -// control sequence. It then recognises other parameter characters until an -// intermediate or final character appears. Further occurrences of the -// private-marker characters 3C-3F or the character 3A, which has no -// standardised meaning, will cause transition to the csi ignore state. -func csiParam(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiParam - case is(r, 0x7F): - // ignore - return csiParam - case in(r, 0x30, 0x39), is(r, 0x3B, 0x3A): - // 0x3A is not per the PFW, but using colons is valid SGR - // syntax for separating params when including colorspace. The - // colorspace should be ignored - p.param(r) - return csiParam - case in(r, 0x40, 0x7E): - p.csiDispatch(r) - return ground - case in(r, 0x20, 0x2F): - p.collect(r) - return csiIntermediate - case in(r, 0x3C, 0x3F): - return csiIgnore - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is used to consume remaining characters of a control sequence -// that is still being recognised, but has already been disregarded as -// malformed. This state will only exit when a final character is -// recognised, at which point it transitions to ground state without -// dispatching the control function. This state may be entered because: -// -// 1. a private-marker character 3C-3F is recognised in any place other -// than the first character of the control sequence, -// 2. the character 3A appears anywhere, or -// 3. a parameter character 30-3F occurs after an intermediate -// character has been recognised. -// -// C0 controls will still be executed while a control sequence is being -// ignored -func csiIgnore(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiIgnore - case is(r, 0x7F): - // ignore - return csiIgnore - case in(r, 0x40, 0x7E): - return ground - default: - return csiIgnore - } -} - -// This state is entered when an intermediate character is recognised in a -// control sequence. It then recognises other intermediate characters until -// a final character appears. If any more parameter characters appear, this -// is an error condition which will cause a transition to the csi ignore -// state. -func csiIntermediate(r rune, p *Parser) stateFn { - switch { - case r == eof: - return nil - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiIntermediate - case is(r, 0x7F): - // ignore - return csiIntermediate - case in(r, 0x20, 0x2F): - p.collect(r) - return csiIntermediate - case in(r, 0x30, 0x3F): - return csiIgnore - case in(r, 0x40, 0x7E): - p.csiDispatch(r) - return ground - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is entered when the control function DCS is recognised, in -// 7-bit or 8-bit form. X3.64 doesn’t define any structure for device -// control strings, but Digital made them appear like control sequences -// followed by a data string, with a form and length dependent on the -// control function. This state is only used to recognise the first -// character of the control string, mirroring the csi entry state. -// -// C0 controls other than CAN, SUB and ESC are not executed while -// recognising the first part of a device control string. -func dcsEntry(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsEntry - case is(r, 0x7F): - // ignore - return dcsEntry - case in(r, 0x20, 0x2F): - p.collect(r) - return dcsIntermediate - case is(r, 0x3A): - return dcsIgnore - case in(r, 0x30, 0x39), is(r, 0x3B): - p.param(r) - return dcsParam - case in(r, 0x3C, 0x3F): - p.collect(r) - return dcsParam - case in(r, 0x40, 0x7E): - p.hook(r) - return dcsPassthrough - default: - p.hook(r) - return dcsPassthrough - } -} - -// This state is entered when an intermediate character is recognised in a -// device control string. It then recognises other intermediate characters -// until a final character appears. If any more parameter characters -// appear, this is an error condition which will cause a transition to the -// dcs ignore state. -func dcsIntermediate(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsIntermediate - case in(r, 0x20, 0x2F): - p.collect(r) - return dcsIntermediate - case is(r, 0x7F): - // ignore - return dcsIntermediate - case in(r, 0x30, 0x3F): - return dcsIgnore - case in(r, 0x40, 0x7E): - p.hook(r) - return dcsPassthrough - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is entered when a parameter character is recognised in a -// device control string. It then recognises other parameter characters -// until an intermediate or final character appears. Occurrences of the -// private-marker characters 3C-3F or the undefined character 3A will cause -// a transition to the dcs ignore state. -func dcsParam(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsParam - case in(r, 0x30, 0x39), is(r, 0x3B): - p.param(r) - return dcsParam - case is(r, 0x7F): - // ignore - return dcsParam - case in(r, 0x20, 0x2F): - p.collect(r) - return dcsIntermediate - case is(r, 0x3A), in(r, 0x3C, 0x3F): - return dcsIgnore - case in(r, 0x40, 0x7E): - p.hook(r) - return dcsPassthrough - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is used to consume remaining characters of a device control -// string that is still being recognised, but has already been disregarded -// as malformed. This state will only exit when the control function ST is -// recognised, at which point it transitions to ground state. This state -// may be entered because: -// -// 1. a private-marker character 3C-3F is recognised in any place other -// than the first character of the control string, -// 2. the character 3A appears anywhere, or -// 3. a parameter character 30-3F occurs after an intermediate -// character has been recognised. -// -// These conditions are only errors in the first part of the control -// string, until a final character has been recognised. The data string -// that follows is not checked by this parser. -func dcsIgnore(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsIgnore - case in(r, 0x20, 0x7F): - // ignore - return dcsIgnore - default: - // ignore - return dcsIgnore - } -} - -// This state is a shortcut for writing state machines for all possible -// device control strings into the main parser. When a final character has -// been recognised in a device control string, this state will establish a -// channel to a handler for the appropriate control function, and then pass -// all subsequent characters through to this alternate handler, until the -// data string is terminated (usually by recognising the ST control -// function). -// -// This state has an exit action so that the control function handler can -// be informed when the data string has come to an end. This is so that the -// last soft character in a DECDLD string can be completed when there is no -// other means of knowing that its definition has ended, for example. -func dcsPassthrough(r rune, p *Parser) stateFn { - p.exit = p.unhook - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.put(r) - return dcsPassthrough - case in(r, 0x20, 0x7E): - p.put(r) - return dcsPassthrough - case is(r, 0x7F): - // ignore - return dcsPassthrough - default: - p.put(r) - return dcsPassthrough - } -} - -// This state is entered whenever the C0 control ESC is received. This will -// immediately cancel any escape sequence, control sequence or control -// string in progress. If an escape sequence or control sequence was in -// progress, β€œcancel” means that the sequence will have no effect, because -// the final character that determines the control function (in conjunction -// with any intermediates) will not have been received. However, the ESC -// that cancels a control string may occur after the control function has -// been determined and the following string has had some effect on terminal -// state. For example, some soft characters may already have been defined. -// Cancelling a control string does not undo these effects. -// -// A control string that started with DCS, OSC, PM or APC is usually -// terminated by the C1 control ST (String Terminator). In a 7-bit -// environment, ST will be represented by ESC \ (1B 5C). However, receiving -// the ESC character will β€œcancel” the control string, so the ST control -// function that is invoked by the arrival of the following β€œ\” is -// essentially a β€œno-op” function. Does this point seem like pure trivia? -// Maybe, but I worried for ages about whether the control string -// recogniser needed a one character lookahead in order to know whether ESC -// \ was going to terminate it. The actual solution became clear when I was -// using ReGIS on a VT330: sending ESC immediately caused the graphics -// output cursor to disappear from the screen, so I knew that the control -// string had already finished before the β€œ\” arrived. Many of the clues -// that enabled me to derive this state diagram have been as subtle as -// that. -func escape(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return escape - case is(r, 0x7F): - // ignore - return escape - case in(r, 0x20, 0x2F): - p.collect(r) - return escapeIntermediate - case in(r, 0x30, 0x4F), - in(r, 0x51, 0x57), - is(r, 0x59, 0x5A, 0x5C), - in(r, 0x60, 0x7E): - p.escapeDispatch(r) - return ground - case is(r, 0x50): - p.clear() - return dcsEntry - case is(r, 0x58, 0x5E, 0x5F): - return sosPmApc - case is(r, 0x5B): - p.clear() - return csiEntry - case is(r, 0x5D): - p.oscStart() - return oscString - default: - // Return to ground on unexpected characters - return ground - } -} - -// This state is entered when an intermediate character arrives in an -// escape sequence. Escape sequences have no parameters, so the control -// function to be invoked is determined by the intermediate and final -// characters. In this parser there is just one escape intermediate, and -// the parser uses the collect action to remember intermediate characters -// as they arrive, for processing by the esc_dispatch action when the final -// character arrives. An alternate approach (and the one adopted by xterm) -// is to have multiple copies of this state and choose the next appropriate -// one as each intermediate character arrives. I think that this alternate -// approach is merely an optimisation; the approach presented here doesn’t -// require any more states if the repertoire of supported control functions -// increases. -// -// This state is only split from the escape state because certain escape -// sequences are the 7-bit representations of C1 controls that change the -// state of the parser. Without these β€œcompatibility sequences”, there -// could just be one escape state to collect intermediates and dispatch the -// sequence when a final character was received. -func escapeIntermediate(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return escapeIntermediate - case is(r, 0x7F): - // ignore - return escapeIntermediate - case in(r, 0x20, 0x2F): - p.collect(r) - return escapeIntermediate - case in(r, 0x30, 0x7E): - p.escapeDispatch(r) - return ground - default: - // Return to ground on unexpected characters - return ground - } -} - -// The VT500 doesn’t define any function for these control strings, so this -// state ignores all received characters until the control function ST is -// recognised. -func sosPmApc(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return sosPmApc - default: - return sosPmApc - } -} - -// This is the initial state of the parser, and the state used to consume -// all characters other than components of escape and control sequences. -// -// GL characters (20 to 7F) are printed. I have included 20 (SP) and 7F -// (DEL) in this area, although both codes have special behaviour. If a -// 94-character set is mapped into GL, 20 will cause a space to be -// displayed, and 7F will be ignored. When a 96-character set is mapped -// into GL, both 20 and 7F may cause a character to be displayed. Later -// models of the VT220 included the DEC Multinational Character Set (MCS), -// which has 94 characters in its supplemental set (i.e. the characters -// supplied in addition to ASCII), so terminals only claiming VT220 -// compatibility can always ignore 7F. The VT320 introduced ISO Latin-1, -// which has 96 characters in its supplemental set, so emulators with a -// VT320 compatibility mode need to treat 7F as a printable character. -func ground(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return ground - case in(r, 0x20, 0x7F): - p.print(r) - return ground - default: - // Catchall for UTF-8 - p.print(r) - return ground - } -} - -// This state is entered when the control function OSC (Operating System -// Command) is recognised. On entry it prepares an external parser for OSC -// strings and passes all printable characters to a handler function. C0 -// controls other than CAN, SUB and ESC are ignored during reception of the -// control string. -// -// The only control functions invoked by OSC strings are DECSIN (Set Icon -// Name) and DECSWT (Set Window Title), present on the multisession VT520 -// and VT525 terminals. Earlier terminals treat OSC in the same way as PM -// and APC, ignoring the entire control string. -func oscString(r rune, p *Parser) stateFn { - switch { - case is(r, 0x07): - p.exit() - p.exit = nil - return ground - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return oscString - case in(r, 0x20, 0x7F): - p.oscPut(r) - return oscString - default: - // catch all for UTF-8 - p.oscPut(r) - return oscString - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/parse_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/parse_test.go deleted file mode 100644 index 6bc42331bf..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/parse_test.go +++ /dev/null @@ -1,885 +0,0 @@ -package tcellterm - -import ( - "bytes" - "reflect" - "strings" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestUTF8(t *testing.T) { - tests := []struct { - name string - input string - expected []Sequence - }{ - { - name: "UTF-8", - input: "πŸ”₯", - expected: []Sequence{ - Print('πŸ”₯'), - }, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - r := strings.NewReader(test.input) - parse := NewParser(r) - i := 0 - for { - seq := parse.Next() - if seq == nil { - assert.Equal(t, len(test.expected), i, "wrong amount of sequences") - break - } - if i < len(test.expected) { - assert.Equal(t, test.expected[i], seq) - } - i += 1 - } - }) - } -} - -func TestIn(t *testing.T) { - tests := []struct { - name string - inRange []rune - input rune - expected bool - }{ - { - name: "endpoint min", - inRange: []rune{0x00, 0x20}, - input: 0x00, - expected: true, - }, - { - name: "endpoint max", - inRange: []rune{0x00, 0x20}, - input: 0x20, - expected: true, - }, - { - name: "within", - inRange: []rune{0x00, 0x20}, - input: 0x19, - expected: true, - }, - { - name: "outside", - inRange: []rune{0x00, 0x20}, - input: 0x21, - expected: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - actual := in(test.input, test.inRange[0], test.inRange[1]) - assert.Equal(t, test.expected, actual) - }) - } -} - -func TestIs(t *testing.T) { - tests := []struct { - name string - isVals []rune - input rune - expected bool - }{ - { - name: "multiple", - isVals: []rune{0x00, 0x20}, - input: 0x00, - expected: true, - }, - { - name: "single", - isVals: []rune{0x00}, - input: 0x00, - expected: true, - }, - { - name: "false multiple", - isVals: []rune{0x00, 0x20}, - input: 0x19, - expected: false, - }, - { - name: "false single", - isVals: []rune{0x00}, - input: 0x21, - expected: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - actual := is(test.input, test.isVals...) - assert.Equal(t, test.expected, actual) - }) - } -} - -func TestAnywhere(t *testing.T) { - tests := []struct { - name string - input rune - expected stateFn - }{ - { - name: "0x18", - input: 0x18, - expected: ground, - }, - { - name: "0x1A", - input: 0x1A, - expected: ground, - }, - { - name: "0x1B", - input: 0x1B, - expected: escape, - }, - { - name: "eof", - input: eof, - expected: nil, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - r := bytes.NewBuffer(nil) - parse := NewParser(r) - called := false - parse.exit = func() { - called = true - } - actual := anywhere(test.input, parse) - act := reflect.ValueOf(actual).Pointer() - exp := reflect.ValueOf(test.expected).Pointer() - assert.Equal(t, exp, act, "wrong return function") - if test.expected != nil { - assert.True(t, called, "exit function not called") - } - }) - } -} - -func TestCSI(t *testing.T) { - tests := []struct { - name string - input string - expected []Sequence - }{ - { - name: "CSI Entry + C0", - input: "a\x1b[\x00", - expected: []Sequence{ - Print('a'), - C0(0x00), - }, - }, - { - name: "CSI Entry + escape", - input: "a\x1b[\x1b", - expected: []Sequence{ - Print('a'), - }, - }, - { - name: "CSI Entry + ignore", - input: "a\x1b[\x7F", - expected: []Sequence{ - Print('a'), - }, - }, - { - name: "CSI Entry + dispatch", - input: "a\x1b[c", - expected: []Sequence{ - Print('a'), - CSI{ - Final: 'c', - Intermediate: []rune{}, - Parameters: []int{}, - }, - }, - }, - { - name: "CSI Param with collect first", - input: "a\x1b[ lastLine { -// continue -// } -// -// visible = append(visible, visibleSixel{ -// ViewLineOffset: int(sixelImage.Y) - int(firstLine), -// Sixel: sixelImage, -// }) -// } -// -// return visible -// } -// -// func (t *Terminal) handleSixel(readChan chan measuredRune) (renderRequired bool) { -// var data []rune -// -// var inEscape bool -// -// for { -// r := <-readChan -// -// switch r.rune { -// case 0x1b: -// inEscape = true -// continue -// case 0x5c: -// if inEscape { -// t.activeBuffer.addSixel([]byte(string(data))) -// return true -// } -// } -// -// inEscape = false -// -// data = append(data, r.rune) -// } -// } diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/surface.go b/cmd/sst/mosaic/multiplexer/tcell-term/surface.go deleted file mode 100644 index ea79fccd84..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/surface.go +++ /dev/null @@ -1,15 +0,0 @@ -package tcellterm - -import "github.com/gdamore/tcell/v2" - -// Surface represents a logical view on an area. It uses a subset of methods -// from a tcell.Screen or a views.View, in order to be a more broad -// implementation. Both a Screen and a View are also a Surface -type Surface interface { - // SetContent is used to update the content of the Surface at the given - // location. - SetContent(x int, y int, ch rune, comb []rune, style tcell.Style) - - // Size represents the visible size. - Size() (int, int) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tcell-term.info b/cmd/sst/mosaic/multiplexer/tcell-term/tcell-term.info deleted file mode 100644 index 8d608d71cf..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tcell-term.info +++ /dev/null @@ -1,47 +0,0 @@ -tcell-term|tcell-term embeddable terminal, - am, bce, bw, mir, msgr, xenl, - colors#1000000, cols#80, it#8, lines#24, pairs#1000000, - acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, - bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, - clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r, - csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, - cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, - cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, - cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, - dl=\E[%p1%dM, dl1=\E[M, dsl=\E]2;\E\\, ech=\E[%p1%dX, - ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG, - ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, - il1=\E[L, ind=\n, indn=\E[%p1%dS, kDC=\E[3;2~, - kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, - kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kbs=^?, - kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, - kdch1=\E[3~, kend=\EOF, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, - kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, - kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~, - kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, - kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, - kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, - kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, - kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, - kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, - kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, - kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, - kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, - kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, - kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, - kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, - kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, - kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, - kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~, - kind=\E[1;2B, kmous=\E[<, knp=\E[6~, kpp=\E[5~, - kri=\E[1;2A, op=\E[39;49m, rc=\E8, rep=%p1%c\E[%p2%{1}%-%db, - rev=\E[7m, ri=\EM, rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E(B, - rmam=\E[?7l, rmcup=\E[?1049l,rmir=\E[4l, rmkx=\E[?1l\E>, - rmso=\E[27m, rmul=\E[24m, rs1=\Ec, sc=\E7, - setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m, - setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m, - sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, - sgr0=\E(B\E[m, sitm=\E[3m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, - smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, - BD=\E[?2004l, BE=\E[?2004h, PE=\E[201~, PS=\E[200~ - Se=\E[0 q, Ss=\E[%p1%d q, diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/terminfo.go b/cmd/sst/mosaic/multiplexer/tcell-term/terminfo.go deleted file mode 100644 index e3f0cbbf3b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/terminfo.go +++ /dev/null @@ -1,289 +0,0 @@ -package tcellterm - -import "github.com/gdamore/tcell/v2/terminfo" - -// extended terminfo defines additional keys in a singular place, if missing -// from the terminfo.Terminfo struct -type extendedTerminfo struct { - KeyAltInsert string - KeyAltDelete string - KeyAltPgUp string - KeyAltPgDown string - - KeyCtrlInsert string - KeyCtrlDelete string - KeyCtrlPgUp string - KeyCtrlPgDown string - - KeyCtrlShfInsert string - KeyCtrlShfDelete string - KeyCtrlShfPgUp string - KeyCtrlShfPgDown string - - KeyAltShfInsert string - KeyAltShfDelete string - KeyAltShfPgUp string - KeyAltShfPgDown string - - KeyCtrlAltUp string - KeyCtrlAltDown string - KeyCtrlAltRight string - KeyCtrlAltLeft string - KeyCtrlAltHome string - KeyCtrlAltEnd string - KeyCtrlAltInsert string - KeyCtrlAltDelete string - KeyCtrlAltPgUp string - KeyCtrlAltPgDown string - - KeyCtrlAltShfUp string - KeyCtrlAltShfDown string - KeyCtrlAltShfRight string - KeyCtrlAltShfLeft string - KeyCtrlAltShfHome string - KeyCtrlAltShfEnd string - KeyCtrlAltShfInsert string - KeyCtrlAltShfDelete string - KeyCtrlAltShfPgUp string - KeyCtrlAltShfPgDown string -} - -var extendedInfo = &extendedTerminfo{ - KeyAltInsert: "\x1b[2;3~", - KeyAltDelete: "\x1b[3;3~", - KeyAltPgUp: "\x1b[5;3~", - KeyAltPgDown: "\x1b[6;3~", - - KeyCtrlInsert: "\x1b[2;5~", - KeyCtrlDelete: "\x1b[3;5~", - KeyCtrlPgUp: "\x1b[5;5~", - KeyCtrlPgDown: "\x1b[6;5~", - - KeyCtrlShfInsert: "\x1b[2;6~", - KeyCtrlShfDelete: "\x1b[3;6~", - KeyCtrlShfPgUp: "\x1b[5;6~", - KeyCtrlShfPgDown: "\x1b[6;6~", - - KeyAltShfInsert: "\x1b[2;4~", - KeyAltShfDelete: "\x1b[3;4~", - KeyAltShfPgUp: "\x1b[5;4~", - KeyAltShfPgDown: "\x1b[6;4~", - - KeyCtrlAltUp: "\x1b[1;7A", - KeyCtrlAltDown: "\x1b[1;7B", - KeyCtrlAltRight: "\x1b[1;7C", - KeyCtrlAltLeft: "\x1b[1;7D", - KeyCtrlAltHome: "\x1b[1;7H", - KeyCtrlAltEnd: "\x1b[1;7F", - KeyCtrlAltInsert: "\x1b[2;7~", - KeyCtrlAltDelete: "\x1b[3;7~", - KeyCtrlAltPgUp: "\x1b[5;7~", - KeyCtrlAltPgDown: "\x1b[6;7~", - - KeyCtrlAltShfUp: "\x1b[1;8A", - KeyCtrlAltShfDown: "\x1b[1;8B", - KeyCtrlAltShfRight: "\x1b[1;8C", - KeyCtrlAltShfLeft: "\x1b[1;8D", - KeyCtrlAltShfHome: "\x1b[1;8H", - KeyCtrlAltShfEnd: "\x1b[1;8F", - KeyCtrlAltShfInsert: "\x1b[2;8~", - KeyCtrlAltShfDelete: "\x1b[3;8~", - KeyCtrlAltShfPgUp: "\x1b[5;8~", - KeyCtrlAltShfPgDown: "\x1b[6;8~", -} - -var info = &terminfo.Terminfo{ - Name: "tcell-term", - Aliases: []string{}, - Columns: 80, // cols - Lines: 24, // lines - Colors: 256, // colors - Bell: "\a", // bell - Clear: "\x1b[H\x1b[2J", // clear - EnterCA: "\x1b[?1049h", // smcup - ExitCA: "\x1b[?1049l", // rmcup - ShowCursor: "\x1b[?12l\x1b[?25h", // cnorm - HideCursor: "\x1b[?25l", // civis - AttrOff: "\x1b(B\x1b[m", // sgr0 - Underline: "\x1b[4m", // smul - Bold: "\x1b[1m", // bold - Blink: "\x1b[5m", // blink - Reverse: "\x1b[7m", // rev - Dim: "\x1b[2m", // dim - Italic: "\x1b[3m", // sitm - EnterKeypad: "", // smkx - ExitKeypad: "", // rmkx - - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m", // setaf - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m", // setab - - ResetFgBg: "\x1b[39;49m", // op - SetCursor: "\x1b[%i%p1%d;%p2%dH", // cup - CursorBack1: "\b", // cub1 - CursorUp1: "\x1b[A", // cuu1 - PadChar: "\x00", // pad - KeyBackspace: "\x7F", // kbs - KeyF1: "\x1bOP", // kf1 - KeyF2: "\x1bOQ", // kf2 - KeyF3: "\x1bOR", // kf3 - KeyF4: "\x1bOS", // kf4 - KeyF5: "\x1b[15~", // kf5 - KeyF6: "\x1b[17~", // kf6 - KeyF7: "\x1b[18~", // kf7 - KeyF8: "\x1b[19~", // kf8 - KeyF9: "\x1b[20~", // kf9 - KeyF10: "\x1b[21~", // kf10 - KeyF11: "\x1b[23~", // kf11 - KeyF12: "\x1b[24~", // kf12 - KeyF13: "\x1b[1;2P", // kf13 - KeyF14: "\x1b[1;2Q", // kf14 - KeyF15: "\x1b[1;2R", // kf15 - KeyF16: "\x1b[1;2S", // kf16 - KeyF17: "\x1b[15;2~", // kf17 - KeyF18: "\x1b[17;2~", // kf18 - KeyF19: "\x1b[18;2~", // kf19 - KeyF20: "\x1b[19;2~", // kf20 - KeyF21: "\x1b[20;2~", // kf21 - KeyF22: "\x1b[21;2~", // kf22 - KeyF23: "\x1b[23;2~", // kf23 - KeyF24: "\x1b[24;2~", // kf24 - KeyF25: "\x1b[1;5P", // kf25 - KeyF26: "\x1b[1;5Q", // kf26 - KeyF27: "\x1b[1;5R", // kf27 - KeyF28: "\x1b[1;5S", // kf28 - KeyF29: "\x1b[15;5~", // kf29 - KeyF30: "\x1b[17;5~", // kf30 - KeyF31: "\x1b[18;5~", // kf31 - KeyF32: "\x1b[19;5~", // kf32 - KeyF33: "\x1b[20;5~", // kf33 - KeyF34: "\x1b[21;5~", // kf34 - KeyF35: "\x1b[23;5~", // kf35 - KeyF36: "\x1b[24;5~", // kf36 - KeyF37: "\x1b[1;6P", // kf37 - KeyF38: "\x1b[1;6Q", // kf38 - KeyF39: "\x1b[1;6R", // kf39 - KeyF40: "\x1b[1;6S", // kf40 - KeyF41: "\x1b[15;6~", // kf41 - KeyF42: "\x1b[17;6~", // kf42 - KeyF43: "\x1b[18;6~", // kf43 - KeyF44: "\x1b[19;6~", // kf44 - KeyF45: "\x1b[20;6~", // kf45 - KeyF46: "\x1b[21;6~", // kf46 - KeyF47: "\x1b[23;6~", // kf47 - KeyF48: "\x1b[24;6~", // kf48 - KeyF49: "\x1b[1;3P", // kf49 - KeyF50: "\x1b[1;3Q", // kf50 - KeyF51: "\x1b[1;3R", // kf51 - KeyF52: "\x1b[1;3S", // kf52 - KeyF53: "\x1b[15;3~", // kf53 - KeyF54: "\x1b[17;3~", // kf54 - KeyF55: "\x1b[18;3~", // kf55 - KeyF56: "\x1b[19;3~", // kf56 - KeyF57: "\x1b[20;3~", // kf57 - KeyF58: "\x1b[21;3~", // kf58 - KeyF59: "\x1b[23;3~", // kf59 - KeyF60: "\x1b[24;3~", // kf60 - KeyF61: "\x1b[1;4P", // kf61 - KeyF62: "\x1b[1;4Q", // kf62 - KeyF63: "\x1b[1;4R", // kf63 - KeyF64: "\x1b[1;4S", // kf64 - KeyInsert: "\x1b[2~", // kich1 - KeyDelete: "\x1b[3~", // kdch1 - KeyHome: "\x1bOH", // khome - KeyEnd: "\x1bOF", // kend - KeyHelp: "", // khlp - KeyPgUp: "\x1b[5~", // kpp - KeyPgDn: "\x1b[6~", // knp - KeyUp: "\x1bOA", // kcuu1 - KeyDown: "\x1bOB", // kcud1 - KeyRight: "\x1bOC", // kcuf1 - KeyLeft: "\x1bOD", // kcub1 - KeyBacktab: "\x1b[Z", // kcbt - KeyExit: "", // kext - KeyClear: "", // kclr - KeyPrint: "", // kprt - KeyCancel: "", // kcan - Mouse: "\x1b[<", // kmous - AltChars: "", // acsc - EnterAcs: "\x1b(0", // smacs - ExitAcs: "\x1b(B", // rmacs - EnableAcs: "", // enacs - KeyShfUp: "\x1b[1;2A", // kri - KeyShfDown: "\x1b[1;2B", // kind - KeyShfRight: "\x1b[1;2C", // kRIT - KeyShfLeft: "\x1b[1;2D", // kLFT - KeyShfHome: "\x1b[1;2H", // kHOM - KeyShfEnd: "\x1b[1;2F", // kEND - KeyShfInsert: "\x1b[2;2~", // kIC - KeyShfDelete: "\x1b[3;2~", // kDC - - // These are non-standard extensions to terminfo. This includes - // true color support, and some additional keys. Its kind of bizarre - // that shifted variants of left and right exist, but not up and down. - // Terminal support for these are going to vary amongst XTerm - // emulations, so don't depend too much on them in your application. - - StrikeThrough: "", // smxx - - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48:5:%p2%d%;m", // setfgbg - - SetFgBgRGB: "", // setfgbgrgb - SetFgRGB: "", // setfrgb - SetBgRGB: "", // setbrgb - KeyShfPgUp: "\x1b[5;2~", // kPRV - KeyShfPgDn: "\x1b[6;2~", // kNXT - KeyCtrlUp: "\x1b[1;5A", // ctrl-up - KeyCtrlDown: "\x1b[1;5B", // ctrl-left - KeyCtrlRight: "\x1b[1;5C", // ctrl-right - KeyCtrlLeft: "\x1b[1;5D", // ctrl-left - KeyMetaUp: "\x1b[1;9A", // meta-up - KeyMetaDown: "\x1b[1;9B", // meta-left - KeyMetaRight: "\x1b[1;9C", // meta-right - KeyMetaLeft: "\x1b[1;9D", // meta-left - KeyAltUp: "\x1b[1;3A", // alt-up - KeyAltDown: "\x1b[1;3B", // alt-left - KeyAltRight: "\x1b[1;3C", // alt-right - KeyAltLeft: "\x1b[1;3D", // alt-left - KeyCtrlHome: "\x1b[1;5H", - KeyCtrlEnd: "\x1b[1;5F", - KeyMetaHome: "\x1b[1;9H", - KeyMetaEnd: "\x1b[1;9F", - KeyAltHome: "\x1b[1;3H", - KeyAltEnd: "\x1b[1;3F", - KeyAltShfUp: "\x1b[1;4A", - KeyAltShfDown: "\x1b[1;4B", - KeyAltShfRight: "\x1b[1;4C", - KeyAltShfLeft: "\x1b[1;4D", - KeyMetaShfUp: "\x1b[1;10A", - KeyMetaShfDown: "\x1b[1;10B", - KeyMetaShfLeft: "\x1b[1;10C", - KeyMetaShfRight: "\x1b[1;10D", - KeyCtrlShfUp: "\x1b[1;6A", - KeyCtrlShfDown: "\x1b[1;6B", - KeyCtrlShfRight: "\x1b[1;6C", - KeyCtrlShfLeft: "\x1b[1;6D", - KeyCtrlShfHome: "\x1b[1;6H", - KeyCtrlShfEnd: "\x1b[1;6F", - KeyAltShfHome: "\x1b[1;4H", - KeyAltShfEnd: "\x1b[1;4F", - KeyMetaShfHome: "\x1b[1;10H", - KeyMetaShfEnd: "\x1b[1;10F", - EnablePaste: "\x1b[?2004h", // BE - DisablePaste: "\x1b[?2004l", // BD - PasteStart: "\x1b[200~", // PS - PasteEnd: "\x1b[201~", // PE - Modifiers: 1, - InsertChar: "\x1b[@", // string to insert a character (ich1) - AutoMargin: true, // true if writing to last cell in line advances - TrueColor: true, // true if the terminal supports direct color - CursorDefault: "\x1b[0 q", // Se - CursorBlinkingBlock: "\x1b[1 q", - CursorSteadyBlock: "\x1b[2 q", - CursorBlinkingUnderline: "\x1b[3 q", - CursorSteadyUnderline: "\x1b[4 q", - CursorBlinkingBar: "\x1b[5 q", - CursorSteadyBar: "\x1b[6 q", - EnterUrl: "\x1b]8;%p2%s;%p1%s\x1b\\", - ExitUrl: "\x1b]8;;\x1b\\", - SetWindowSize: "", -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/README b/cmd/sst/mosaic/multiplexer/tcell-term/tests/README deleted file mode 100644 index 5e3c219a60..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/README +++ /dev/null @@ -1,6 +0,0 @@ -All tests in this directory should be compared against a known good terminal. -Personally, I compare to foot, but alacritty is known to be good too. The tests -can be run by 'cat'ing them to the terminal - -These tests are pulled from: -https://github.com/alacritty/alacritty/tree/master/alacritty_terminal/tests/ref diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/alt_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/alt_reset deleted file mode 100644 index eb23719e15..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/alt_reset +++ /dev/null @@ -1,6 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ cargo cat ../alacritty.recording -[?2004l [?2004h[kchibisov@NightLord forks]$ [kchibisov@NightLord forks]$ [kchibisov@NightLord forks]$ princd Developer/rust/forks/alacritty htopprintf "\e[31;1;7;4;9mTEST asd\n" -[?2004l TEST asd -[?2004h[kchibisov@NightLord forks]$ [kchibisov@NightLord forks]$ htop -[?2004l [?1049h(B[?7h[?1h=[?25l[?1000h[?2004h[kchibisov@NightLord alacritty]$ [?2004l -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/clear_undlerine b/cmd/sst/mosaic/multiplexer/tcell-term/tests/clear_undlerine deleted file mode 100644 index be36a43e2f..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/clear_undlerine +++ /dev/null @@ -1,5 +0,0 @@ -[undeadleech@undeadlap alacritty]$ echo -e "\e[4mUNDERLINED" -UNDERLINED -[undeadleech@undeadlap alacritty]$ clear -[undeadleech@undeadlap alacritty]$ exit -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_reset deleted file mode 100644 index b8fca085cb..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_reset +++ /dev/null @@ -1,3 +0,0 @@ -[undeadleech@archhq colored_reset]$ printf "\e[41m" -[undeadleech@archhq colored_reset]$ [undeadleech@archhq colored_reset]$ printf "\e[0m" -[undeadleech@archhq colored_reset]$ ls - \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_underline b/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_underline deleted file mode 100644 index 662d07c6dc..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_underline +++ /dev/null @@ -1,3 +0,0 @@ -% ]133;A]2;kchibisov@Zodiac:~/src/rust/alacritty-workspace/fork fork on ξ‚  colored-underlines-v3 via πŸ¦€ v1.59.0 ➜ [?2004hcargo run -- --ref-test --config-file /dev/null -o scrolling.history=0echo -e '\e[58;2;255;0;255m\e[4:1mUNDERLINE\e[4:2mDOUBLE\e[58:5:196m\e[4:3mUhΜ·Μ—ERCURL\e[4:4mDOTTED\e[4:5mDASHED\e[59mNOT_COLORED_DASH\e[0m'[?2004l -]2;echo -e '\e[58;2;255;0;255m\e[4:1mUNDERLINE\e[4:2mDOUBLE\e[58:5:196m\e[4:3mUhΜ·Μ—ERCURL\e[4:4mDOTTED\e[4:5mDASHED\e[59mNOT_COLORED_DASH\e[0m'[4:1mUNDERLINE[4:2mDOUBLE[58:5:196m[4:3mUhΜ·Μ—ERCURL[4:4mDOTTED[4:5mDASHEDNOT_COLORED_DASH -% ]133;A]2;kchibisov@Zodiac:~/src/rust/alacritty-workspace/fork fork on ξ‚  colored-underlines-v3 via πŸ¦€ v1.59.0 ➜ [?2004h[?2004l diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/csi_rep b/cmd/sst/mosaic/multiplexer/tcell-term/tests/csi_rep deleted file mode 100644 index 9c78a0b649..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/csi_rep +++ /dev/null @@ -1,2 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h -bck-i-search: _printf "f\e[10b"p_prr_prii_inn_ntt_tff_printf "f\e[10b" [?1l>[?2004l ]2;printf "f\e[10b"]1;printff% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/deccolm_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/deccolm_reset deleted file mode 100644 index d30a08d06e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/deccolm_reset +++ /dev/null @@ -1,30 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ echo -e "\033[?3h"printf "\e[31;1;7;4;9mTEST asd\n" -[?2004l TEST asd -[?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;7;4;9mTEST asd\n"echo -e "\033[?3h" -[?2004l [?3h -[?2004h[kchibisov@NightLord alacritty]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_chars_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_chars_reset deleted file mode 100644 index 1f6929a601..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_chars_reset +++ /dev/null @@ -1,3 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ printf "\e[31;1;7;4;9md\n" -[?2004l d -[?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;7;4;9md\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n" \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_lines b/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_lines deleted file mode 100644 index 2541d8feb6..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_lines +++ /dev/null @@ -1,38 +0,0 @@ -[undeadleech@archhq alacritty]$ ls -lah -total 240K -drwxr-xr-x 17 undeadleech undeadleech 620 Nov 15 21:10 . -drwxrwxrwt 12 root root 300 Nov 15 21:08 .. --rw-r--r-- 1 undeadleech undeadleech 10 Nov 15 20:33 .agignore -drwxr-xr-x 3 undeadleech undeadleech 100 Nov 15 20:33 alacritty --rw-r--r-- 1 undeadleech undeadleech 41 Nov 15 21:10 alacritty.recording -drwxr-xr-x 4 undeadleech undeadleech 120 Nov 15 20:33 alacritty_terminal --rw-r--r-- 1 undeadleech undeadleech 17K Nov 15 20:33 alacritty.yml --rw-r--r-- 1 undeadleech undeadleech 128K Nov 15 20:33 Cargo.lock --rw-r--r-- 1 undeadleech undeadleech 245 Nov 15 20:33 Cargo.toml --rw-r--r-- 1 undeadleech undeadleech 22K Nov 15 20:38 CHANGELOG.md -drwxr-xr-x 4 undeadleech undeadleech 140 Nov 15 20:33 ci --rw-r--r-- 1 undeadleech undeadleech 5.5K Nov 15 20:33 CONTRIBUTING.md -drwxr-xr-x 2 undeadleech undeadleech 60 Nov 15 20:33 .copr -drwxr-xr-x 4 undeadleech undeadleech 160 Nov 15 20:33 copypasta -drwxr-xr-x 2 undeadleech undeadleech 60 Nov 15 20:33 docs -drwxr-xr-x 7 undeadleech undeadleech 180 Nov 15 20:33 extra -drwxr-xr-x 3 undeadleech undeadleech 80 Nov 15 20:33 font -drwxr-xr-x 8 undeadleech undeadleech 300 Nov 15 21:09 .git -drwxr-xr-x 2 undeadleech undeadleech 60 Nov 15 20:33 .github --rw-r--r-- 1 undeadleech undeadleech 333 Nov 15 20:33 .gitignore --rw-r--r-- 1 undeadleech undeadleech 9.1K Nov 15 20:33 INSTALL.md --rw-r--r-- 1 undeadleech undeadleech 11K Nov 15 20:33 LICENSE-APACHE --rw-r--r-- 1 undeadleech undeadleech 1.5K Nov 15 20:33 Makefile --rw-r--r-- 1 undeadleech undeadleech 6.8K Nov 15 20:33 README.md -drwxr-xr-x 2 undeadleech undeadleech 120 Nov 15 20:33 res --rw-r--r-- 1 undeadleech undeadleech 358 Nov 15 20:33 rustfmt.toml -drwxr-xr-x 2 undeadleech undeadleech 180 Nov 15 20:33 scripts -drwxr-xr-x 3 undeadleech undeadleech 100 Nov 15 20:33 servo-freetype-proxy -drwxr-xr-x 3 undeadleech undeadleech 80 Nov 15 20:36 target --rw-r--r-- 1 undeadleech undeadleech 1.7K Nov 15 20:33 .travis.yml -drwxr-xr-x 3 undeadleech undeadleech 100 Nov 15 20:33 winpty -[undeadleech@archhq alacritty]$ echo -[ "e "\e[10H" - -[undeadleech@archhq alacritty]$ echo -e "\e[1000M" - -[undeadleech@archhq alacritty]$ diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_chars_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_chars_reset deleted file mode 100644 index ebe08116f5..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_chars_reset +++ /dev/null @@ -1,5 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ echo -e "hello world" "\033[10;D" "\033[4;X" printf "\e[31;1;4;9mTEST asd\n" -[?2004l TEST asd -[?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;4;9mTEST asd\n"echo -e "hello world" "\033[10;D" "\033[4;X" -[?2004l hello world   -[?2004h[kchibisov@NightLord alacritty]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_in_line b/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_in_line deleted file mode 100644 index c140222023..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_in_line +++ /dev/null @@ -1,8 +0,0 @@ -[?2004h[undeadleech@archhq erase_in_line]$ s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[0Kb' s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[0Kb' -[?2004l 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49a+b -[?2004h[undeadleech@archhq erase_in_line]$ s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[1Kb' s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[1Kb' -[?2004l 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49a+b -[?2004h[undeadleech@archhq erase_in_line]$ s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[2Kb' s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[2Kb' -[?2004l 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49a+b -[?2004h[undeadleech@archhq erase_in_line]$ [?2004l -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/fish_cc b/cmd/sst/mosaic/multiplexer/tcell-term/tests/fish_cc deleted file mode 100644 index d6cae7b89b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/fish_cc +++ /dev/null @@ -1,6 +0,0 @@ -]50;CursorShape=0]0;fish alacritty(BWelcome to fish, the friendly interactive shell -Type help for instructions on how to use fish -]50;CursorShape=0]50;CursorShape=0]0;fish alacritty(B⏎(B [I](B ➜ alacritty git:(master) βœ—(B aa(B52dec (B^C -]0;fish alacritty(B [I](B ➜ alacritty git:(master) βœ—(B aa(B52dec (Ba(Bfire (Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(B^C - [I](B ➜ alacritty git:(master) βœ—(B ]0;fish alacritty(B [I](B ➜ alacritty git:(master) βœ—(B aa(B52dec (Ba(Bfire (Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(B^C -]0;fish alacritty(B [I](B ➜ alacritty git:(master) βœ—(B  diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/grid_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/grid_reset deleted file mode 100644 index 0e70d2dc90..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/grid_reset +++ /dev/null @@ -1,103 +0,0 @@ -%  UL  ~/…/tests/ref/grid_reset  dynamic-alloc  [?2004hfor i in {0..100}; do echo $i; donefor i in {0..100}; do echo $i; done[?2004l -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -c]104[!p[?3;4l> %  UL  ~/…/tests/ref/grid_reset  dynamic-alloc  [?2004h diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/hyperlinks b/cmd/sst/mosaic/multiplexer/tcell-term/tests/hyperlinks deleted file mode 100644 index f4d3bc9af3..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/hyperlinks +++ /dev/null @@ -1,14 +0,0 @@ -sh-5.2$ cat alacritty? _tir  erminal/tests/ref/hyperlinks/alacritty.recording -[?2004hsh-5.1$ printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' -[?2004l ]8;;https://example.com\foo]8;;\ -[?2004hsh-5.1$ printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' -[?2004l ]8;;https://example.com\foo]8;;\ -[?2004hsh-5.1$ printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' -[?2004l ]8;id=42;https://example.com\bar]8;;\ -[?2004hsh-5.1$ printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' -[?2004l ]8;id=42;https://example.com\bar]8;;\ -[?2004hsh-5.1$ [?2004l -exit -sh-5.2$ printf '\e]8;id=hello;http://example.com/naoheu;ntahoeu\e\\This is a link\e]8;id=hello;\e\\\n' -]8;id=hello;http://example.com/naoheu;ntahoeu\This is a link]8;id=hello;\ -sh-5.2$ exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/indexed_256_colors b/cmd/sst/mosaic/multiplexer/tcell-term/tests/indexed_256_colors deleted file mode 100644 index 6f2fb459f5..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/indexed_256_colors +++ /dev/null @@ -1,15 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h.././ccoolloorrss..p./colors.pl[?1l>[?2004l -]4;16;rgb:00/00/00\]4;17;rgb:00/00/5f\]4;18;rgb:00/00/87\]4;19;rgb:00/00/af\]4;20;rgb:00/00/d7\]4;21;rgb:00/00/ff\]4;22;rgb:00/5f/00\]4;23;rgb:00/5f/5f\]4;24;rgb:00/5f/87\]4;25;rgb:00/5f/af\]4;26;rgb:00/5f/d7\]4;27;rgb:00/5f/ff\]4;28;rgb:00/87/00\]4;29;rgb:00/87/5f\]4;30;rgb:00/87/87\]4;31;rgb:00/87/af\]4;32;rgb:00/87/d7\]4;33;rgb:00/87/ff\]4;34;rgb:00/af/00\]4;35;rgb:00/af/5f\]4;36;rgb:00/af/87\]4;37;rgb:00/af/af\]4;38;rgb:00/af/d7\]4;39;rgb:00/af/ff\]4;40;rgb:00/d7/00\]4;41;rgb:00/d7/5f\]4;42;rgb:00/d7/87\]4;43;rgb:00/d7/af\]4;44;rgb:00/d7/d7\]4;45;rgb:00/d7/ff\]4;46;rgb:00/ff/00\]4;47;rgb:00/ff/5f\]4;48;rgb:00/ff/87\]4;49;rgb:00/ff/af\]4;50;rgb:00/ff/d7\]4;51;rgb:00/ff/ff\]4;52;rgb:5f/00/00\]4;53;rgb:5f/00/5f\]4;54;rgb:5f/00/87\]4;55;rgb:5f/00/af\]4;56;rgb:5f/00/d7\]4;57;rgb:5f/00/ff\]4;58;rgb:5f/5f/00\]4;59;rgb:5f/5f/5f\]4;60;rgb:5f/5f/87\]4;61;rgb:5f/5f/af\]4;62;rgb:5f/5f/d7\]4;63;rgb:5f/5f/ff\]4;64;rgb:5f/87/00\]4;65;rgb:5f/87/5f\]4;66;rgb:5f/87/87\]4;67;rgb:5f/87/af\]4;68;rgb:5f/87/d7\]4;69;rgb:5f/87/ff\]4;70;rgb:5f/af/00\]4;71;rgb:5f/af/5f\]4;72;rgb:5f/af/87\]4;73;rgb:5f/af/af\]4;74;rgb:5f/af/d7\]4;75;rgb:5f/af/ff\]4;76;rgb:5f/d7/00\]4;77;rgb:5f/d7/5f\]4;78;rgb:5f/d7/87\]4;79;rgb:5f/d7/af\]4;80;rgb:5f/d7/d7\]4;81;rgb:5f/d7/ff\]4;82;rgb:5f/ff/00\]4;83;rgb:5f/ff/5f\]4;84;rgb:5f/ff/87\]4;85;rgb:5f/ff/af\]4;86;rgb:5f/ff/d7\]4;87;rgb:5f/ff/ff\]4;88;rgb:87/00/00\]4;89;rgb:87/00/5f\]4;90;rgb:87/00/87\]4;91;rgb:87/00/af\]4;92;rgb:87/00/d7\]4;93;rgb:87/00/ff\]4;94;rgb:87/5f/00\]4;95;rgb:87/5f/5f\]4;96;rgb:87/5f/87\]4;97;rgb:87/5f/af\]4;98;rgb:87/5f/d7\]4;99;rgb:87/5f/ff\]4;100;rgb:87/87/00\]4;101;rgb:87/87/5f\]4;102;rgb:87/87/87\]4;103;rgb:87/87/af\]4;104;rgb:87/87/d7\]4;105;rgb:87/87/ff\]4;106;rgb:87/af/00\]4;107;rgb:87/af/5f\]4;108;rgb:87/af/87\]4;109;rgb:87/af/af\]4;110;rgb:87/af/d7\]4;111;rgb:87/af/ff\]4;112;rgb:87/d7/00\]4;113;rgb:87/d7/5f\]4;114;rgb:87/d7/87\]4;115;rgb:87/d7/af\]4;116;rgb:87/d7/d7\]4;117;rgb:87/d7/ff\]4;118;rgb:87/ff/00\]4;119;rgb:87/ff/5f\]4;120;rgb:87/ff/87\]4;121;rgb:87/ff/af\]4;122;rgb:87/ff/d7\]4;123;rgb:87/ff/ff\]4;124;rgb:af/00/00\]4;125;rgb:af/00/5f\]4;126;rgb:af/00/87\]4;127;rgb:af/00/af\]4;128;rgb:af/00/d7\]4;129;rgb:af/00/ff\]4;130;rgb:af/5f/00\]4;131;rgb:af/5f/5f\]4;132;rgb:af/5f/87\]4;133;rgb:af/5f/af\]4;134;rgb:af/5f/d7\]4;135;rgb:af/5f/ff\]4;136;rgb:af/87/00\]4;137;rgb:af/87/5f\]4;138;rgb:af/87/87\]4;139;rgb:af/87/af\]4;140;rgb:af/87/d7\]4;141;rgb:af/87/ff\]4;142;rgb:af/af/00\]4;143;rgb:af/af/5f\]4;144;rgb:af/af/87\]4;145;rgb:af/af/af\]4;146;rgb:af/af/d7\]4;147;rgb:af/af/ff\]4;148;rgb:af/d7/00\]4;149;rgb:af/d7/5f\]4;150;rgb:af/d7/87\]4;151;rgb:af/d7/af\]4;152;rgb:af/d7/d7\]4;153;rgb:af/d7/ff\]4;154;rgb:af/ff/00\]4;155;rgb:af/ff/5f\]4;156;rgb:af/ff/87\]4;157;rgb:af/ff/af\]4;158;rgb:af/ff/d7\]4;159;rgb:af/ff/ff\]4;160;rgb:d7/00/00\]4;161;rgb:d7/00/5f\]4;162;rgb:d7/00/87\]4;163;rgb:d7/00/af\]4;164;rgb:d7/00/d7\]4;165;rgb:d7/00/ff\]4;166;rgb:d7/5f/00\]4;167;rgb:d7/5f/5f\]4;168;rgb:d7/5f/87\]4;169;rgb:d7/5f/af\]4;170;rgb:d7/5f/d7\]4;171;rgb:d7/5f/ff\]4;172;rgb:d7/87/00\]4;173;rgb:d7/87/5f\]4;174;rgb:d7/87/87\]4;175;rgb:d7/87/af\]4;176;rgb:d7/87/d7\]4;177;rgb:d7/87/ff\]4;178;rgb:d7/af/00\]4;179;rgb:d7/af/5f\]4;180;rgb:d7/af/87\]4;181;rgb:d7/af/af\]4;182;rgb:d7/af/d7\]4;183;rgb:d7/af/ff\]4;184;rgb:d7/d7/00\]4;185;rgb:d7/d7/5f\]4;186;rgb:d7/d7/87\]4;187;rgb:d7/d7/af\]4;188;rgb:d7/d7/d7\]4;189;rgb:d7/d7/ff\]4;190;rgb:d7/ff/00\]4;191;rgb:d7/ff/5f\]4;192;rgb:d7/ff/87\]4;193;rgb:d7/ff/af\]4;194;rgb:d7/ff/d7\]4;195;rgb:d7/ff/ff\]4;196;rgb:ff/00/00\]4;197;rgb:ff/00/5f\]4;198;rgb:ff/00/87\]4;199;rgb:ff/00/af\]4;200;rgb:ff/00/d7\]4;201;rgb:ff/00/ff\]4;202;rgb:ff/5f/00\]4;203;rgb:ff/5f/5f\]4;204;rgb:ff/5f/87\]4;205;rgb:ff/5f/af\]4;206;rgb:ff/5f/d7\]4;207;rgb:ff/5f/ff\]4;208;rgb:ff/87/00\]4;209;rgb:ff/87/5f\]4;210;rgb:ff/87/87\]4;211;rgb:ff/87/af\]4;212;rgb:ff/87/d7\]4;213;rgb:ff/87/ff\]4;214;rgb:ff/af/00\]4;215;rgb:ff/af/5f\]4;216;rgb:ff/af/87\]4;217;rgb:ff/af/af\]4;218;rgb:ff/af/d7\]4;219;rgb:ff/af/ff\]4;220;rgb:ff/d7/00\]4;221;rgb:ff/d7/5f\]4;222;rgb:ff/d7/87\]4;223;rgb:ff/d7/af\]4;224;rgb:ff/d7/d7\]4;225;rgb:ff/d7/ff\]4;226;rgb:ff/ff/00\]4;227;rgb:ff/ff/5f\]4;228;rgb:ff/ff/87\]4;229;rgb:ff/ff/af\]4;230;rgb:ff/ff/d7\]4;231;rgb:ff/ff/ff\]4;232;rgb:08/08/08\]4;233;rgb:12/12/12\]4;234;rgb:1c/1c/1c\]4;235;rgb:26/26/26\]4;236;rgb:30/30/30\]4;237;rgb:3a/3a/3a\]4;238;rgb:44/44/44\]4;239;rgb:4e/4e/4e\]4;240;rgb:58/58/58\]4;241;rgb:62/62/62\]4;242;rgb:6c/6c/6c\]4;243;rgb:76/76/76\]4;244;rgb:80/80/80\]4;245;rgb:8a/8a/8a\]4;246;rgb:94/94/94\]4;247;rgb:9e/9e/9e\]4;248;rgb:a8/a8/a8\]4;249;rgb:b2/b2/b2\]4;250;rgb:bc/bc/bc\]4;251;rgb:c6/c6/c6\]4;252;rgb:d0/d0/d0\]4;253;rgb:da/da/da\]4;254;rgb:e4/e4/e4\]4;255;rgb:ee/ee/ee\System colors: -         -         - -Color cube, 6x6x6: -                                          -                                          -                                          -                                          -                                          -                                          -Grayscale ramp: -                         -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/insert_blank_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/insert_blank_reset deleted file mode 100644 index 6750852a27..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/insert_blank_reset +++ /dev/null @@ -1,5 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ resetprintf "\e[41;1;4;9mTEST asd\n"resetprintf "\e[41;1;4;9mTEST asd\n"[1@3 -[?2004l TEST asd -[?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;4;9mTEST asd\n"resetprintf "\e[41;1;4;9mTEST asd\n"resetecho -e "\033[100;@" -[?2004l [100;@ -[?2004h[kchibisov@NightLord alacritty]$ diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/issue_855 b/cmd/sst/mosaic/multiplexer/tcell-term/tests/issue_855 deleted file mode 100644 index 2fa3494684..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/issue_855 +++ /dev/null @@ -1 +0,0 @@ -bck-i-search: t_tput cup 20 bck-i-search: tp_   tpuu_utt_sr 3 7tput [?1l>[?2004l ]2;tput csr 3 7]1;tput% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/kakoune b/cmd/sst/mosaic/multiplexer/tcell-term/tests/kakoune deleted file mode 100644 index d7d4d52894..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/kakoune +++ /dev/null @@ -1,3 +0,0 @@ -  -7~ $ [?25l8[5 q%  ~ $ [5 q[?25l ~ $ [?12l[?25h[5 q[?2004hkkakak[?2004l -]0;kak\[?1049h[?1004h[>4;1m[>5u[?25l=[?2026$p[?1006h[?1000h[?1002h]2;*scratch* 1:1 [scratch] 1 sel - client0@[70515] - Kakoune ╭──────────────────────────────────────Kakoune v2022.10.31β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β• β”‚ β€’ Kakoune v2022.10.31 β”‚ β”‚ Β»  does not end macro recording anymore, use Q β”‚ β”‚ Β» pipe commands do not append final end-of-lines anymore β”‚ β”‚ Β» complete-command to configure command completion β”‚ β”‚ Β» p, P, ! and  now select the inserted text β”‚ β”‚ Β» x now uses  behaviour β”‚ β”‚ Β»  and , have been swapped β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2021.11.07 β”‚ β”‚ Β» colored and curly underlines support (undocumented in 20210828) β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2021.10.28 β”‚ β”‚ Β» g and v do not auto-convert to lowercase anymore β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2021.08.28 β”‚ β”‚ Β» write  will refuse to overwrite without -force β”‚ β”‚ Β» $kak_command_fifo support β”‚ β”‚ Β» set-option -remove support β”‚ β”‚ Β» prompts auto select menu completions on space β”‚ β”‚ Β» explicit completion support (...) in prompts β”‚ β”‚ Β» write -atomic was replaced with write -method  β”‚ β”‚  β”‚ ╭──╠│ β€’ Kakoune v2020.09.01 β”‚ β”‚ β”‚ β”‚ Β» daemon mode does not fork anymore β”‚ @ @ β•­β”‚  β”‚ β”‚β”‚ β”‚β”‚ β”‚β”‚ β€’ Kakoune v2020.08.04 β”‚ β”‚β”‚ β”‚β”‚ β•―β”‚ Β» User hook support β”‚ │╰─╯│ β”‚ Β» Removed bold and italic faces from colorschemes β”‚ ╰───╯ β”‚ Β» Read from stdin support for clients β”‚ β”‚ Β» rgba:RRGGBBAA faces and alpha blending β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2020.01.16 β”‚ β”‚ Β» InsertCompletionHide parameter is now the list of inserted ranges β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2019.12.10 β”‚ β”‚ Β» ModeChange parameter has changed to contain push/pop β”‚ β”‚ Β» ModeBegin/ModeEnd hooks were removed β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2019.07.01 β”‚ β”‚ Β» %file{} expansions to read files β”‚ β”‚ Β» echo -to-file  to write to file β”‚ β”‚ Β» completions option have an on select command instead of a docstring β”‚ β”‚ Β» Function key syntax do not accept lower case f anymore β”‚ β”‚ Β» shell quoting of list options is now opt-in with $kak_quoted_... β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2019.01.20 β”‚ β”‚ Β» named capture groups in regex β”‚ β”‚ Β» auto_complete option renamed to autocomplete β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2018.10.27 β”‚ β”‚ Β» define-commands -shell-completion and -shell-candidates has been renamed β”‚ β”‚ Β» exclusive face attributes is replaced with final (fg/bg/attr) β”‚ ╰─┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄─╯*scratch* 1:1 [scratch] 1 sel - client0@[70515]]2;*scratch* 1:1 [scratch] 1 sel - client0@[70515] - Kakoune ╭──────────────────────────────────────Kakoune v2022.10.31β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β• β”‚ β€’ Kakoune v2022.10.31 β”‚ β”‚ Β»  does not end macro recording anymore, use Q β”‚ β”‚ Β» pipe commands do not append final end-of-lines anymore β”‚ β”‚ Β» complete-command to configure command completion β”‚ β”‚ Β» p, P, ! and  now select the inserted text β”‚ β”‚ Β» x now uses  behaviour β”‚ β”‚ Β»  and , have been swapped β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2021.11.07 β”‚ β”‚ Β» colored and curly underlines support (undocumented in 20210828) β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2021.10.28 β”‚ β”‚ Β» g and v do not auto-convert to lowercase anymore β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2021.08.28 β”‚ β”‚ Β» write  will refuse to overwrite without -force β”‚ β”‚ Β» $kak_command_fifo support β”‚ β”‚ Β» set-option -remove support β”‚ β”‚ Β» prompts auto select menu completions on space β”‚ β”‚ Β» explicit completion support (...) in prompts β”‚ β”‚ Β» write -atomic was replaced with write -method  β”‚ β”‚  β”‚ ╭──╠│ β€’ Kakoune v2020.09.01 β”‚ β”‚ β”‚ β”‚ Β» daemon mode does not fork anymore β”‚ @ @ β•­β”‚  β”‚ β”‚β”‚ β”‚β”‚ β”‚β”‚ β€’ Kakoune v2020.08.04 β”‚ β”‚β”‚ β”‚β”‚ β•―β”‚ Β» User hook support β”‚ │╰─╯│ β”‚ Β» Removed bold and italic faces from colorschemes β”‚ ╰───╯ β”‚ Β» Read from stdin support for clients β”‚ β”‚ Β» rgba:RRGGBBAA faces and alpha blending β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2020.01.16 β”‚ β”‚ Β» InsertCompletionHide parameter is now the list of inserted ranges β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2019.12.10 β”‚ β”‚ Β» ModeChange parameter has changed to contain push/pop β”‚ β”‚ Β» ModeBegin/ModeEnd hooks were removed β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2019.07.01 β”‚ β”‚ Β» %file{} expansions to read files β”‚ β”‚ Β» echo -to-file  to write to file β”‚ β”‚ Β» completions option have an on select command instead of a docstring β”‚ β”‚ Β» Function key syntax do not accept lower case f anymore β”‚ β”‚ Β» shell quoting of list options is now opt-in with $kak_quoted_... β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2019.01.20 β”‚ β”‚ Β» named capture groups in regex β”‚ β”‚ Β» auto_complete option renamed to autocomplete β”‚ β”‚  β”‚ β”‚ β€’ Kakoune v2018.10.27 β”‚ β”‚ Β» define-commands -shell-completion and -shell-candidates has been renamed β”‚ β”‚ Β» exclusive face attributes is replaced with final (fg/bg/attr) β”‚ ╰─┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄─╯*scratch* 1:1 [scratch] 1 sel - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakoune*** this is a *scratch* buffer which won't be automatically saved ****** use it for notes or open a file buffer with the :edit command ***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~: *scratch* 1:1 [scratch] prompt - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakouneadd-highlighterbcomment-lineβ–ˆaddhlbncomplβ–ˆaliasbpcomplete-commandβ–ˆalign-selections-leftbufferctags-completeβ–‘arrange-buffersbuffer-nextctags-disable-autocompleteβ–‘autorestore-disablebuffer-previousctags-disable-autoinfoβ–‘autorestore-purge-backupscdctags-enable-autocompleteβ–‘autorestore-restore-bufferchange-directoryctags-enable-autoinfoβ–‘autowrap-disablecolorschemectags-funcinfoβ–‘autowrap-enablecomment-blockctags-generateβ–‘: *scratch* 1:1 [scratch] prompt - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakoune:q *scratch* 1:1 [scratch] prompt - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakoune~ ╭──╠╭──────────────────────────────────────────────quitβ”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β• β”‚ β”‚ β”‚ quit []: quit current client, and the kakoune session if the client is the last ( β”‚ @ @ β•­β”‚ if not running in daemon mode). An optional integer parameter can set the client exit status β”‚ β”‚β”‚ β”‚β”‚ β”‚β”‚ Aliases: q β”‚ β”‚β”‚ β”‚β”‚ ╯╰────────────────────────────────────────────────────────────────────────────────────────────────╯ │╰─╯│  ╰───╯ qquitwrite-quitwrite-all-quit wq!waqβ–ˆq!quit!write-quit!wqrequire-moduleβ–ˆ:q *scratch* 1:1 [scratch] prompt - client0@[70515][?1002l[?1000l[?1006l>[?25h[?1004l[?1049l% ~ $ [5 q[?25l ~ $ [?12l[?25h[5 q[?2004h ~ $  \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/ll b/cmd/sst/mosaic/multiplexer/tcell-term/tests/ll deleted file mode 100644 index 8421359ce4..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/ll +++ /dev/null @@ -1,27 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004hlll[?1l>[?2004l -total 16440 -drwxr-xr-x 3 jwilm staff 102B Nov 2 10:54 Alacritty.app --rw-r--r-- 1 jwilm staff 53K Nov 19 14:27 Cargo.lock --rw-r--r-- 1 jwilm staff 746B Nov 19 14:24 Cargo.toml --rw-r--r-- 1 jwilm staff 11K Jun 30 10:44 LICENSE-APACHE --rw-r--r-- 1 jwilm staff 1.6K Nov 2 10:52 Makefile --rw-r--r-- 1 jwilm staff 49B Jun 9 18:56 TASKS.md --rwxr-xr-x 1 jwilm staff 1.7M Sep 26 10:49 alacritty-pre-eloop --rw-r--r-- 1 jwilm staff 255B Nov 19 14:31 alacritty.recording --rw-r--r-- 1 jwilm staff 6.5K Nov 17 17:18 alacritty.yml --rw-r--r-- 1 jwilm staff 1.1K Jun 30 10:44 build.rs -drwxr-xr-x 6 jwilm staff 204B Oct 10 10:46 copypasta -drwxr-xr-x 3 jwilm staff 102B Jun 9 18:56 docs --rwxr-xr-x 1 jwilm staff 2.2M Nov 11 17:53 exitter -drwxr-xr-x 5 jwilm staff 170B Jun 28 14:50 font --rwxr-xr-x 1 jwilm staff 2.2M Nov 14 13:27 hardcoded_bindings_alacritty -drwxr-xr-x 6 jwilm staff 204B Nov 2 10:54 macos -drwxr-xr-x 4 jwilm staff 136B Oct 27 17:59 res --rw-r--r-- 1 jwilm staff 19B Nov 11 16:55 rustc-version -drwxr-xr-x 5 jwilm staff 170B Oct 10 10:46 scripts -drwxr-xr-x 17 jwilm staff 578B Nov 19 14:30 src -drwxr-xr-x 5 jwilm staff 170B Jun 28 15:49 target --rw-r--r-- 1 jwilm staff 8.1K Nov 17 11:13 thing.log --rw-r--r-- 1 jwilm staff 3.5K Sep 1 11:27 tmux-client-23038.log --rwxr-xr-x 1 jwilm staff 1.8M Sep 22 12:03 with_parallel -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/newline_with_cursor_beyond_scroll_region b/cmd/sst/mosaic/multiplexer/tcell-term/tests/newline_with_cursor_beyond_scroll_region deleted file mode 100644 index f9b23863fc..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/newline_with_cursor_beyond_scroll_region +++ /dev/null @@ -1,4 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h -bck-i-search: _clear; cat ~/Downloads/xtest.txt; sleep 100c_caa_att_clearcat ~/Downloads/xtest.txtsleep [?1l>[?2004l ]2;clear; cat ~/Downloads/xtest.txt; sleep 100]1;clear; - 58 getprogname());  59 exit 9 9 - 59 !!!! diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/region_scroll_down b/cmd/sst/mosaic/multiplexer/tcell-term/tests/region_scroll_down deleted file mode 100644 index 34fc7f8be3..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/region_scroll_down +++ /dev/null @@ -1,46 +0,0 @@ -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho -ne "\e[10000T" && sleep infinityecho "test"                           test"[?2004l -test -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hlsls -lah-lah[?2004l -total 12K -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 23:58 . -drwxr-xr-x 37 undeadleech undeadleech 4.0K Jun 24 23:57 .. --rw-r--r-- 1 undeadleech undeadleech 1.3K Jun 24 23:58 alacritty.recording -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hls -lah[?2004l -total 12K -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 23:58 . -drwxr-xr-x 37 undeadleech undeadleech 4.0K Jun 24 23:57 .. --rw-r--r-- 1 undeadleech undeadleech 1.9K Jun 24 23:58 alacritty.recording -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hls -lahls -lah bin/snapshot.undo/      ./mov/.. ./../..[?2004l -total 300K -drwxr-xr-x 15 undeadleech undeadleech 4.0K Jun 24 23:53 . -drwxr-xr-x 34 undeadleech undeadleech 4.0K Jun 18 03:26 .. --rw-r--r-- 1 undeadleech undeadleech 10 Feb 8 2019 .agignore -drwxr-xr-x 3 undeadleech undeadleech 4.0K Jun 24 23:24 alacritty -drwxr-xr-x 4 undeadleech undeadleech 4.0K Jun 24 23:24 alacritty_terminal --rw-r--r-- 1 undeadleech undeadleech 21K Jun 24 23:24 alacritty.yml -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 18:47 .builds --rw-r--r-- 1 undeadleech undeadleech 116K Jun 24 23:24 Cargo.lock --rw-r--r-- 1 undeadleech undeadleech 141 Jun 23 21:20 Cargo.toml --rw-r--r-- 1 undeadleech undeadleech 30K Jun 24 23:53 CHANGELOG.md -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 18:47 ci --rw-r--r-- 1 undeadleech undeadleech 7.3K Jun 23 21:20 CONTRIBUTING.md -drwxr-xr-x 2 undeadleech undeadleech 4.0K Mar 6 00:06 .copr -drwxr-xr-x 2 undeadleech undeadleech 4.0K Feb 8 2019 docs -drwxr-xr-x 7 undeadleech undeadleech 4.0K Jun 23 21:20 extra -drwxr-xr-x 3 undeadleech undeadleech 4.0K Jun 23 21:20 font -drwxr-xr-x 8 undeadleech undeadleech 4.0K Jun 24 23:58 .git --rw-r--r-- 1 undeadleech undeadleech 26 Jun 23 21:20 .gitattributes -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 .github --rw-r--r-- 1 undeadleech undeadleech 341 Jun 23 21:20 .gitignore --rw-r--r-- 1 undeadleech undeadleech 8.9K Jun 23 21:20 INSTALL.md --rw-r--r-- 1 undeadleech undeadleech 11K Jun 23 21:20 LICENSE-APACHE --rw-r--r-- 1 undeadleech undeadleech 1.5K Jun 23 21:20 Makefile --rw-r--r-- 1 undeadleech undeadleech 7.1K Jun 23 21:20 README.md -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 res --rw-r--r-- 1 undeadleech undeadleech 358 Mar 6 00:06 rustfmt.toml -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 scripts -drwxr-xr-x 4 undeadleech undeadleech 4.0K Jun 20 23:09 target --rw-r--r-- 1 undeadleech undeadleech 2.6K Jun 24 18:47 .travis.yml -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho "test"echo -ne "\e[10000T" && sleep infinitye "\e[1  "\e[1001[e\" ne "\e[10000T" && sleep infinityne "\e[10000T" && sleep infinity[?2004l -^C -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho -ne "\e[10000T" && sleep infinityexit                                  it[?2004l diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/row_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/row_reset deleted file mode 100644 index 7619aeb3ff..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/row_reset +++ /dev/null @@ -1,616 +0,0 @@ -[undeadleech@archhq row_reset]$ cat ~/downloads/dmesg.txt -[228741.085647] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[228741.091432] wlp3s0: authenticate with 00:00:00:00:00:00 -[228741.097335] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[228741.135972] wlp3s0: authenticated -[228741.141525] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[228741.142955] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[228741.144318] wlp3s0: associated -[228741.154942] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[228918.086333] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229303.946685] wlp3s0: authenticated -[229303.947705] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229303.948917] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229303.949916] wlp3s0: associated -[229304.048604] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[229396.541447] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229398.267553] wlp3s0: authenticate with 00:00:00:00:00:00 -[229398.273829] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229398.314512] wlp3s0: authenticated -[229398.315473] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229398.316742] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[229398.318551] wlp3s0: associated -[229398.373686] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[229430.169385] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[229430.209398] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209406] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209409] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209411] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209414] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209417] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209419] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209421] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209424] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209426] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209429] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209431] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209433] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209435] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209441] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209444] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209446] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209447] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209449] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209451] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209453] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209455] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209457] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209458] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209462] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209464] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209466] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209468] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209470] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209472] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209474] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209476] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209478] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209480] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209481] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209483] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209485] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209487] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209490] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209493] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209495] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209500] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209503] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209506] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213606] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213610] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213612] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213614] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213616] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213617] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213619] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213621] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213623] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213624] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213626] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213628] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213630] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213632] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213634] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213635] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213639] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213641] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213642] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213644] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213646] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213649] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213651] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213654] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213656] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213658] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213661] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213663] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213666] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213668] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213670] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213673] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213674] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213676] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213678] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213680] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213681] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213683] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213685] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213689] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213691] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213693] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213694] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213696] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213698] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213700] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213701] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213704] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213706] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213708] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213711] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213713] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213716] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218481] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218509] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218521] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218528] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218546] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218551] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218561] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218566] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218590] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218597] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218609] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218614] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218622] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218626] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218635] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218639] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218647] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218650] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218660] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218663] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218673] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218677] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218681] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218685] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218697] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218700] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218707] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218710] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218716] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218723] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218726] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218733] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218736] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218743] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218747] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219801] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219834] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219853] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219858] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219866] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219870] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219878] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.221124] wlp3s0: authenticate with 00:00:00:00:00:00 -[229430.222243] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229430.262505] wlp3s0: authenticated -[229430.263310] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229430.264564] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229430.266358] wlp3s0: associated -[229430.307441] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[229517.132398] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229518.888561] wlp3s0: authenticate with 00:00:00:00:00:00 -[229518.894662] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229518.937199] wlp3s0: authenticated -[229518.939160] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229518.940460] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[229518.942378] wlp3s0: associated -[229519.001616] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[229824.281089] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[229824.291293] wlp3s0: authenticate with 00:00:00:00:00:00 -[229824.297136] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229824.336092] wlp3s0: authenticated -[229824.338750] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229824.340205] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229824.341469] wlp3s0: associated -[229824.343528] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[229879.108005] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229880.382542] wlp3s0: authenticate with 00:00:00:00:00:00 -[229880.389268] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229880.429992] wlp3s0: authenticated -[229880.433634] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229880.434832] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[229880.436867] wlp3s0: associated -[229880.475867] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[229893.920859] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[229893.927177] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927189] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927191] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927194] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927196] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927198] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927201] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.930495] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930531] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930536] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930541] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930548] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930552] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930557] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.935133] wlp3s0: authenticate with 00:00:00:00:00:00 -[229893.940801] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229893.981689] wlp3s0: authenticated -[229893.986136] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229893.989747] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229893.992245] wlp3s0: associated -[229894.077777] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[230231.830965] CPU9: Core temperature above threshold, cpu clock throttled (total events = 15794) -[230231.830966] CPU8: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.830967] CPU3: Core temperature above threshold, cpu clock throttled (total events = 15794) -[230231.830968] CPU2: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.830969] CPU3: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.830972] CPU9: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831043] CPU0: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831044] CPU1: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831045] CPU7: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831047] CPU10: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831047] CPU6: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831049] CPU4: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831051] CPU11: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831052] CPU5: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.837979] CPU3: Core temperature/speed normal -[230231.837980] CPU9: Core temperature/speed normal -[230231.837981] CPU2: Package temperature/speed normal -[230231.837982] CPU8: Package temperature/speed normal -[230231.837983] CPU6: Package temperature/speed normal -[230231.837984] CPU0: Package temperature/speed normal -[230231.837985] CPU5: Package temperature/speed normal -[230231.837987] CPU10: Package temperature/speed normal -[230231.837988] CPU1: Package temperature/speed normal -[230231.837989] CPU11: Package temperature/speed normal -[230231.837991] CPU7: Package temperature/speed normal -[230231.837992] CPU4: Package temperature/speed normal -[230231.837994] CPU9: Package temperature/speed normal -[230231.838001] CPU3: Package temperature/speed normal -[230236.392394] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 3=DEAUTH_LEAVING) -[230237.780651] wlp3s0: authenticate with 00:00:00:00:00:00 -[230237.787938] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230237.828603] wlp3s0: authenticated -[230237.832087] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230237.833363] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[230237.834675] wlp3s0: associated -[230237.854441] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[230257.232908] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[230257.238433] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238455] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238511] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238519] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238530] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238537] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238562] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238572] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238586] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238595] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.240338] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240418] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240471] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240489] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240506] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240525] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240557] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240571] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240606] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240618] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240635] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240653] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240688] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240714] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240741] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240755] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240774] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243219] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243261] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243279] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243291] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243304] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243318] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243334] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243346] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243362] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243374] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243388] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243400] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243422] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243435] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243448] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243458] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243491] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243504] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243533] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243544] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243558] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243568] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243581] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243590] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243600] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243611] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243641] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243650] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243671] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243680] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243691] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243700] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243719] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243728] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247443] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247471] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247484] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247492] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247501] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247509] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247517] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247525] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247550] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247559] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247567] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247575] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247596] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247604] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247612] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247620] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247629] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247637] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247648] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247655] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247663] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247671] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247680] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247688] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247698] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247707] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247716] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247723] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247733] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247741] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247749] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247756] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247765] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247773] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247781] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247788] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247809] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247817] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251792] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251818] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251832] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251842] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251851] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251860] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251897] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251908] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251919] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251928] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251939] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251949] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251960] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251970] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251982] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252017] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252032] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252042] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252054] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252065] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252076] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252086] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252101] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252111] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252123] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252133] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252140] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252147] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252157] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252167] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252178] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252187] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252197] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252207] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252220] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252230] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252240] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252250] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252265] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252276] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252287] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252294] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252302] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256114] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256136] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256148] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256158] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256168] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256176] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256185] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256192] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256210] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256220] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256230] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256240] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256251] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256259] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256266] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256273] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256281] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256288] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256295] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256302] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256310] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256317] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256325] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256332] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256343] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256353] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256376] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256384] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256392] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256407] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256419] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256426] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256433] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256441] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256448] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256456] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256465] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256472] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256480] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256488] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256499] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256510] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256520] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256527] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256535] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256542] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256549] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256556] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256564] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256571] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256579] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260414] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260471] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260502] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260515] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260559] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260574] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260590] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260606] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260622] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260632] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260646] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260671] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260685] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260696] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260710] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260722] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260742] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260768] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260782] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260792] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260815] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260827] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260843] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260855] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260869] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260880] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260891] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260903] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260916] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260928] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260947] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260962] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260975] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260986] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264813] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264838] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264851] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264862] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264873] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264883] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264892] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264899] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264907] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264914] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264921] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264933] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264946] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264953] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264961] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264968] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264984] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264992] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264999] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265006] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265014] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265021] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265028] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265036] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265044] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265051] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265062] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265069] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265078] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265087] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265103] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265110] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265120] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265127] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265135] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265142] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265151] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265158] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269374] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269404] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269418] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269429] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269439] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269448] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269458] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269467] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269476] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269485] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269502] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269511] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269520] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269529] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269539] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269550] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269561] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269570] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269582] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269592] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269603] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269613] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269627] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269637] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269650] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269659] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269677] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269686] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269697] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269708] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269740] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269749] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269762] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269771] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269783] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269793] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269807] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269817] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269829] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269839] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269851] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269860] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269874] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.275363] wlp3s0: authenticate with 00:00:00:00:00:00 -[230257.281231] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230257.326172] wlp3s0: authenticated -[230257.332040] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230257.333311] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[230257.334472] wlp3s0: associated -[230257.393437] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[230356.680918] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 3=DEAUTH_LEAVING) -[230359.780467] wlp3s0: authenticate with 00:00:00:00:00:00 -[230359.786813] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230359.827649] wlp3s0: authenticated -[230359.831632] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230359.832798] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[230359.834228] wlp3s0: associated -[230359.915722] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[230391.707400] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[230391.710358] wlp3s0: authenticate with 00:00:00:00:00:00 -[230391.716647] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230391.756364] wlp3s0: authenticated -[230391.759536] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230391.760897] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[230391.762833] wlp3s0: associated -[230391.844511] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[231412.503669] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[231412.513884] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[231412.513892] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[231412.515316] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515352] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515359] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515363] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515368] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515373] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516316] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516327] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516333] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516338] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516343] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516347] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517875] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517893] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517909] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517921] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517940] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517951] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518917] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518942] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518961] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518975] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.519007] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.519022] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.523892] wlp3s0: authenticate with 00:00:00:00:00:00 -[231412.529652] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[231412.575449] wlp3s0: authenticated -[undeadleech@archhq row_reset]$ exit -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/runner.go b/cmd/sst/mosaic/multiplexer/tcell-term/tests/runner.go deleted file mode 100644 index b572a988e0..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/runner.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build ignore -// +build ignore - -package main - -import ( - "bufio" - "fmt" - "log" - "os" - "time" -) - -func main() { - if len(os.Args) < 2 { - log.Fatal("must pass a filename") - } - f, err := os.Open(os.Args[1]) - if err != nil { - log.Fatal(err) - } - buf := bufio.NewReader(f) - for { - r, _, err := buf.ReadRune() - if err != nil { - log.Fatal(err) - } - - fmt.Printf("%c", r) - time.Sleep(10 * time.Millisecond) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor b/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor deleted file mode 100644 index 102d7a631b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor +++ /dev/null @@ -1,6 +0,0 @@ -[undeadleech@archhq saved_cursor]$ echo -e "\e7 \e(0 test \e8 xxx" -7 (0 test 8 xxx -[undeadleech@archhq saved_cursor]$ echo -e "\e[?1049h \e(0 test \e[?1049l xxx" -[?1049h (0 test [?1049l xxx -[undeadleech@archhq saved_cursor]$ echo -e "\e7 \e(0 \e[?1049h test \e[?1049l \e8 xxx" -7 (0 [?1049h test [?1049l 8 xxx diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor_alt b/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor_alt deleted file mode 100644 index fb71b1d17e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor_alt +++ /dev/null @@ -1 +0,0 @@ -(0 [?1049h7 [?1049l (B [?1049h test8xxx diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/scroll_up_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/scroll_up_reset deleted file mode 100644 index 5d838a6445..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/scroll_up_reset +++ /dev/null @@ -1,105 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ ls -lah -[?2004l total 308K -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 16 05:14 . -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 15 23:21 .. --rw-r--r-- 1 kchibisov kchibisov 10 Sep 26 16:22 .agignore -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty --rw-r--r-- 1 kchibisov kchibisov 133 Nov 16 05:14 alacritty.recording -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty_terminal --rw-r--r-- 1 kchibisov kchibisov 17K Nov 13 20:02 alacritty.yml --rw-r--r-- 1 kchibisov kchibisov 128K Nov 13 20:02 Cargo.lock --rw-r--r-- 1 kchibisov kchibisov 245 Nov 3 09:50 Cargo.toml --rw-r--r-- 1 kchibisov kchibisov 22K Nov 16 04:47 CHANGELOG.md -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 ci --rw-r--r-- 1 kchibisov kchibisov 5.5K Nov 13 20:02 CONTRIBUTING.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 .copr -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 copypasta -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 docs -drwxr-xr-x 7 kchibisov kchibisov 4.0K Nov 13 20:02 extra -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 font -drwxr-xr-x 8 kchibisov kchibisov 4.0K Nov 16 05:08 .git -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 .github --rw-r--r-- 1 kchibisov kchibisov 333 Nov 3 09:50 .gitignore --rw-r--r-- 1 kchibisov kchibisov 9.1K Nov 13 20:02 INSTALL.md --rw-r--r-- 1 kchibisov kchibisov 11K Sep 26 16:22 LICENSE-APACHE --rw-r--r-- 1 kchibisov kchibisov 1.5K Nov 5 10:25 Makefile --rw-r--r-- 1 kchibisov kchibisov 6.8K Nov 13 20:02 README.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 res --rw-r--r-- 1 kchibisov kchibisov 358 Nov 13 20:02 rustfmt.toml -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 scripts -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 3 09:50 servo-freetype-proxy -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 12 16:22 target --rw-r--r-- 1 kchibisov kchibisov 1.7K Nov 13 20:02 .travis.yml -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 winpty -[?2004h[kchibisov@NightLord alacritty]$ ls -lah -[?2004l total 308K -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 16 05:14 . -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 15 23:21 .. --rw-r--r-- 1 kchibisov kchibisov 10 Sep 26 16:22 .agignore -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty --rw-r--r-- 1 kchibisov kchibisov 2.2K Nov 16 05:14 alacritty.recording -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty_terminal --rw-r--r-- 1 kchibisov kchibisov 17K Nov 13 20:02 alacritty.yml --rw-r--r-- 1 kchibisov kchibisov 128K Nov 13 20:02 Cargo.lock --rw-r--r-- 1 kchibisov kchibisov 245 Nov 3 09:50 Cargo.toml --rw-r--r-- 1 kchibisov kchibisov 22K Nov 16 04:47 CHANGELOG.md -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 ci --rw-r--r-- 1 kchibisov kchibisov 5.5K Nov 13 20:02 CONTRIBUTING.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 .copr -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 copypasta -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 docs -drwxr-xr-x 7 kchibisov kchibisov 4.0K Nov 13 20:02 extra -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 font -drwxr-xr-x 8 kchibisov kchibisov 4.0K Nov 16 05:08 .git -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 .github --rw-r--r-- 1 kchibisov kchibisov 333 Nov 3 09:50 .gitignore --rw-r--r-- 1 kchibisov kchibisov 9.1K Nov 13 20:02 INSTALL.md --rw-r--r-- 1 kchibisov kchibisov 11K Sep 26 16:22 LICENSE-APACHE --rw-r--r-- 1 kchibisov kchibisov 1.5K Nov 5 10:25 Makefile --rw-r--r-- 1 kchibisov kchibisov 6.8K Nov 13 20:02 README.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 res --rw-r--r-- 1 kchibisov kchibisov 358 Nov 13 20:02 rustfmt.toml -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 scripts -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 3 09:50 servo-freetype-proxy -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 12 16:22 target --rw-r--r-- 1 kchibisov kchibisov 1.7K Nov 13 20:02 .travis.yml -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 winpty -[?2004h[kchibisov@NightLord alacritty]$ ls - lah -[?2004l total 312K -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 16 05:14 . -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 15 23:21 .. --rw-r--r-- 1 kchibisov kchibisov 10 Sep 26 16:22 .agignore -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty --rw-r--r-- 1 kchibisov kchibisov 4.1K Nov 16 05:14 alacritty.recording -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty_terminal --rw-r--r-- 1 kchibisov kchibisov 17K Nov 13 20:02 alacritty.yml --rw-r--r-- 1 kchibisov kchibisov 128K Nov 13 20:02 Cargo.lock --rw-r--r-- 1 kchibisov kchibisov 245 Nov 3 09:50 Cargo.toml --rw-r--r-- 1 kchibisov kchibisov 22K Nov 16 04:47 CHANGELOG.md -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 ci --rw-r--r-- 1 kchibisov kchibisov 5.5K Nov 13 20:02 CONTRIBUTING.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 .copr -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 copypasta -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 docs -drwxr-xr-x 7 kchibisov kchibisov 4.0K Nov 13 20:02 extra -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 font -drwxr-xr-x 8 kchibisov kchibisov 4.0K Nov 16 05:08 .git -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 .github --rw-r--r-- 1 kchibisov kchibisov 333 Nov 3 09:50 .gitignore --rw-r--r-- 1 kchibisov kchibisov 9.1K Nov 13 20:02 INSTALL.md --rw-r--r-- 1 kchibisov kchibisov 11K Sep 26 16:22 LICENSE-APACHE --rw-r--r-- 1 kchibisov kchibisov 1.5K Nov 5 10:25 Makefile --rw-r--r-- 1 kchibisov kchibisov 6.8K Nov 13 20:02 README.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 res --rw-r--r-- 1 kchibisov kchibisov 358 Nov 13 20:02 rustfmt.toml -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 scripts -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 3 09:50 servo-freetype-proxy -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 12 16:22 target --rw-r--r-- 1 kchibisov kchibisov 1.7K Nov 13 20:02 .travis.yml -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 winpty -[?2004h[kchibisov@NightLord alacritty]$ echo -e "\ (reverse-i-search)`':[24@p': printf "\e[31;1;4;9m"[1@r[1@i [8@[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ echo =e "-e \{"\e[10H" -[?2004l  -[?2004h[kchibisov@NightLord alacritty]$ echo -e "\p\e[[1-0M" -[?2004l  -[?2004h[kchibisov@NightLord alacritty]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/selective_erasure b/cmd/sst/mosaic/multiplexer/tcell-term/tests/selective_erasure deleted file mode 100644 index aae1560ffe..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/selective_erasure +++ /dev/null @@ -1,2 +0,0 @@ -A[1"qB[2"qC[?2J -A[1"qB[2"qC[?2K diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/sgr b/cmd/sst/mosaic/multiplexer/tcell-term/tests/sgr deleted file mode 100644 index 18bc4885e7..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/sgr +++ /dev/null @@ -1,26 +0,0 @@ -[undeadleech@archhq sgr]$ echo -e "\e[9;38:2:255:0:255;4mTEST\e[0m" -[9;38:2:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38:2:0:255:0:255;4mTEST\e[0m" -[9;38:2:0:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38:5:1;4mTEST\e[0m" -[9;38:5:1;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48:2:255:0:255;4mTEST\e[0m" -[9;48:2:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48:2:0:255:0:255;4mTEST\e[0m" -[9;48:2:0:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48:5:1;4mTEST\e[0m" -[9;48:5:1;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38;2;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38;2;0;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38;5;1;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48;2;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48;2;0;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48;5;1;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ exit -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tab_rendering b/cmd/sst/mosaic/multiplexer/tcell-term/tests/tab_rendering deleted file mode 100644 index 6ad299da4b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tab_rendering +++ /dev/null @@ -1,13 +0,0 @@ -%  UL  ~/…/tests/ref/tab_rendering  copy-tabs  [?2004hecho '\tb\na\tb\naa\tb\naaa\tb\naaaa\tb\naaaaa\tb\naaaaaa\tb\naaaaaaa\tb\naaaaaaaa\tb\naaaaaaaaa\tb\naaaaaaaaaa\tb'[?2004l - b -a b -aa b -aaa b -aaaa b -aaaaa b -aaaaaa b -aaaaaaa b -aaaaaaaa b -aaaaaaaaa b -aaaaaaaaaa b -%  UL  ~/…/tests/ref/tab_rendering  copy-tabs  [?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_git_log b/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_git_log deleted file mode 100644 index e1baaa781c..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_git_log +++ /dev/null @@ -1,85 +0,0 @@ -[?1049h(B[?1l>[?12l[?25h[?1000l[?1002l[?1006l[?1005l]112[?25l - - - - - - - - - - - - - - - - - - - - - - -1:reattach-to-user-namespace* (B[?12l[?25hg[?25l1:zsh* (B[?12l[?25h%(B  - - -jwilm@kurast.local ➜ ~/code/alacritty (B [?1h=[?2004hg(Bgi(Bgit(B lg[?1l> -[?2004l[?25l - - - - - - - - - - - - - - - - - - - - - -[?12l[?25h[?1h=* bdd2181(B - (2 hours ago)(B Add support for recording/running ref tests - Joe Wilm(B  (HEAD -> ref-tests, origin/ref-tests) -(B| * d629f72(B - (2 days ago)(B WIP on master: d97996e Make bindings configurable f rom alacritty.yml - Joe Wilm(B (refs/stash) -(B| |\ -|/ / -|(B * 5908bde(B - (2 days ago)(B index on master: d97996e Make bindings configurable f rom alacritty.yml - Joe Wilm -(B|/ -* d97996e(B - (4 days (Bago)(B Make bindings configurable from alacritty.yml - Joe Wil(B m(B (o(Brigin/master, origin/bindings-v2, origin/HEAD, master, bindings-v2) -(B* cb2bc4e(B - (4 days ago)(B Fix test for Cell layout - Joe Wilm -(B* cbb9167(B - (5 days ago)(B Redraw screen on focus - Joe Wilm -(B* 8360ab4(B - (8 days ago)(B Fallback to received chars when no bindings - Joe Wilm -(B* 6925daa(B - (8 days ago)(B Fix/add some keybindings - Jo(Be Wilm -(B* e426013(B - (8 days ago)(B Fix alacritty shutdown when shell exits on macOS - Joe (B Wilm -(B* 8cbd768(B - (8 days ago)(B Fix resize on macOS leaving screen blank - Joe Wilm -(B* a652b4a(B - (8 days ago)(B Rustup - Joe Wilm -(B* 3e0b2b6(B - (8 days ago)(B Fix config file reloading on macOS - (BJoe Wilm -(B* be036ed(B - (8 days ago)(B Workaround for cutoff glyphs - Joe Wilm(B -* 82c8804(B - (3 weeks ago)(B Update default config - Joe Wilm(B -:[?25l -1:git* (B[?12l[?25h * a81152c(B - (3 weeks ago)(B Support drawing bold test with bright colors - Joe Wil(B : m(B -: * 7cd8a6c(B - (3 weeks ago)(B Merge branch 'reload-colors' - Joe Wilm(B -: |\ -: | * f8cb6d4(B - (3 weeks ago)(B Set colors on CPU - Joe Wilm(B -: | * cb2fa27(B - (3 weeks ago)(B Dynamically update render_timer config - Joe Wilm(B -: | * 06ea6c8(B - (3 weeks ago)(B Move config reloading to separate thread - Joe Wilm(B -: | * 0958c0f(B - (4 weeks ago)(B Move color indexing to vertex shader - Joe Wilm(B -: | * e9304af(B - (4 weeks ago)(B Expand cell::Color layout tests - Joe Wilm(B -: | * 741a8b3(B - (4 weeks ago)(B Fix some compiler warnings - Joe Wilm(B -: | * b29eed2(B - (4 weeks ago)(B Add discriminant_value test for cell::Color - Joe Wi(Bi(B : lm(B -: | * 5876b4b(B - (4 weeks ago)(B Proof of concept live reloading for colors - Joe Wil(Bl(B : m(B -: * | e503baf(B - (3 weeks ago)(B Live shader reloading is now a feature - Joe Wilm(B -: |/ -: | * 655e8f4(B - (4 weeks ago)(B WIP color management - Joe Wilm(B (live-reload-(Bcolors)(B -: |/ -: * ea07f03(B - (5 weeks ago)(B Add test exhibiting SIGBUS on my machine - Joe Wilm(B -: M* a652b4a(B - (8 days ago)(B Rustup - Joe Wilm(B: M* 8cbd768(B - (8 days ago)(B Fix resize on macOS leaving screen blank - Joe Wilm(B: MWilm(B: M* e426013(B - (8 days ago)(B Fix alacritty shutdown when shell exits on macOS - Joe (B: M* 6925daa(B - (8 days ago)(B Fix/add some keybindings - Joe Wilm(B: M* 8360ab4(B - (8 days ago)(B Fallback to received chars when no bindings - Joe Wilm(B: M* cbb9167(B - (5 days ago)(B Redraw screen on focus - Joe Wilm(B: M* cb2bc4e(B - (4 days ago)(B Fix test for Cell layout - Joe Wilm(B: Mm(B (origin/master, origin/bindings-v2, origin/HEAD, master, bindings-v2) -(B: M* d97996e(B - (4 days ago)(B Make bindings configurable from alacritty.yml - Joe Wil(B: M|/ : Mrom alacritty.yml - Joe Wilm(B: M| * 5908bde(B - (2 days ago)(B index on master: d97996e Make bindings configurable f: M|/ / : M| |\ : Mrom alacritty.yml - Joe Wilm(B (refs/stash)(B: M| * d629f72(B - (2 days ago)(B WIP on master: d97996e Make bindings configurable f: M (HEAD -> ref-tests, origin/ref-tests)(B: M* bdd2181(B - (2 hours ago)(B Add support for recording/running ref tests - Joe Wilm(B: : : : : : : : : : : : : diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_htop b/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_htop deleted file mode 100644 index 9f6b754128..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_htop +++ /dev/null @@ -1,118 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004httmtmutmux[?1l>[?2004l -[?1049h(B[?1l>[?12l[?25h[?1000l[?1002l[?1006l[?1005l]112[?25l - - - - - - - - - - - - - - - - - - - - - - -1:reattach-to-user-namespace* (B[?12l[?25h%(B   -jwilm@kurast.local ➜ ~/code/alacritty (B [?25l1:zsh* (B[?12l[?25h[?1h=[?2004hh(Bht(Bhto(Bhtop(B[?1l> -[?2004l[?25l - - - - - - - - - - - - - - - - - - - - - -[?1006h[?1000h[?1h= - 0 [ nan%](B Tasks: 363(B1:htop* (B, 1608(B thr; 1(B running1 [ nan(B%](B Load average: 1.71 1.83 (B1.80 2 [ (Bnan%](B Uptime: 2 days, 06:35:30(B3 [ nan%(B](BMem[(B|||||||||||||||||||9.25G/16.0G](BSwp(B[(B||||||||||||||| 1000M/2.00G](B PID USER PRI NI VIRT RES S (BCPU% MEM% TIME+ Command 29826 jwilm 17 0 9621M 7392 R 0 0.0 0:00.(B01 htop 29749 jwilm40 0 9630M 19040 R  nan 0.0 0:00.21 -zsh -29748 jwilm25 0 9554M 4528 R  nan 0.0 0:00.00 tmux -29617 jwilm40 0 9630M 19456 R  nan 0.0 0:00.27 /usr/local/bin/zsh -29598 jwilm26 0 10.1G (B 131M R  nan 0.2 0:00.55 target/debug/alacritty -29597 jwilm32 0 9577M 22608 R (B nan 0.0 0:00.01 cargo -29567 jwilm17 0 13.1G (B 443M R  nan 0.7 0:01.48 /Applications/Google Ch29565 jwilm17 0 9756M 36784 R  nan 0.1 0:00.09 /System/Library/Private29477 jwilm25 0 9630M 22192 R  nan 0.0 0:00.51 -zsh -29466 jwilm17 0  9.6G (B51936 R  nan 0.1 0:00.04 /System/Library/Framewo29368 root(B (B 17 0 0 0 R  0.0 0.0 0:00.00 com.apple.audio. -29349 root (B 17 0 0 0 R  0.0 0.0 0:00.00 ocspd -29240 jwilm17 0 13.8G (B 823M R (B nan 1.3 0:59.28 /Applications/Google ChF1Help F2Setup F3SearchF4FilterF5Tree F6SortByF7Nice -(BF8Nice +F9Kill F10Quit [1@t(B||||7.91(B||2.0(B|||(B5.91(B||2.0(B 114126 0 10.4G 226M (BR 3.3 0.3 11:34.48 target/release/alacritt 58017752M 58368 R  2.7  0.1 7:38.67 tmux24017 0 13.6G (B 825M R  2.0 1.3 0:59.30 /Applications/Google Ch59826 0 10.1G (B 132M R  1.9 0.257 target/debug/alacritty220173.2G (B 585M R  0.5 0.9 0:14.68 /Applications/Google Ch 92317 0 15.6G (B1800M R  0.3 2.7 51:50.80 /Applications/Google Ch199302G (B 584M R  0.3 0.9 1:00.2982624621M 7408 R  0.3 0.02 htop -1324817 0 13.8G (B 445M R  0.2 0.7 6:24.39 /Applications/Google Ch214113.3G (B 517M R  0.2 0.8 1:05.32 /Applications/Google Ch 433 jwilm  9.7G (B458562 0.1 2:35.94 /Applications/Karabiner 396 jwilm   9.8G (B74242 0.1 3:06.10 /System/Library/CoreSer187130G (B 529M R  0.1 0.8 0:31.53| 53323(B5G 227M R 2.7(B51400 R  18598260.1G (B 132M R (B 1.5 0.2 0:00.59 target/debug/alacritty  915146.3G (B 825M R  0.7 1.3  9:38.59 /Applications/Slack.app49459678M 13088 R  0.4 0.0 0:21.21 postgres: stats collect 9235.6G (B18004 2.7 51:50.80 9155244.9G (B1263 1.9  1h(B18:35Slack.app132488G (B 4457 6:24.40 -1993013.2G (B 584M 9 1:00.29Google Ch2214113.3G (B 517M 8 1:05.32 /Applications/Google Ch 396 9.8G (B74240 R  0.2 0.1 3:06.10 /System/Library/CoreSer07 182 1.85 (B1.81| 4.0(B3 1(B1.931637036029240173.6G (B 82690:59.31Google Ch5 - 8 9.6G (B 112M 2 0:37.22 /System/Library/Framewo322141173.3G (B 5172 0.8 1:05.32Google Ch 8543 9.9G (B 1372 0:39.54 /System/Library/Framewo32488G (B 4457 6:24.40 -199302G (B 5849 1:00.30 1141 jwilm 26 0 10.5G (B 227M R  1.9 0.3 11:34.53 target/release/alacritt 580 jwilm 17 0 9752M 58416 R 1.3 0.1 7:38.70 tmux (B 580 jwilm 17 0 9752M 58416 R  1.3 0.1 7:38.70 tmux -29598 jwilm (B 26 0 10.1G 132M R 1.3 0.2 0:00.60 target/debug/alacritty (B98(B|634(B|6(B554812533626700412306515(B29598 jwilm 26 0 10.1G (B 132M R  1.5 0.2 0:00.63 target/debug/alacritty 29240 jwilm 17 0 13.6G 823M R 0.6 1.3 0:59.32 /Applications/Google Ch(B29240 jwilm 17 0 13.6G (B 823M R  0.6 1.3 0:59.32 /Applications/Google Ch29220 jwilm 17 0 13.2G 586M R 0.5 0.9 0:14.70 /Applications/Google Ch(B29220 jwilm 17 0 13.2G (B 586M R  0.5 0.9 0:14.70 /Applications/Google Ch 8453 jwilm 17 0 9.6G 112M R 0.0 0.2 0:37.22 /System/Library/Framewo(B87362.5(B6764232.36241 - 8453 jwilm 17 0  9.6G (B 112M R  0.0 0.2 0:37.22 /System/Library/Framewo 923 jwilm 17 0 15.6G 1800M R 0.2 2.7 51:50.81 /Applications/Google Ch(B33823131 923 jwilm 17 0 15.6G (B1800M R  0.2 2.7 51:50.81 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.3 0.0 0:00.03 htop (B7(B29826 jwilm 24 0 9621M 7408 R  0.3 0.0 0:00.03 htop22141 jwilm 17 0 13.3G 518M R 0.2 0.8 1:05.33 /Applications/Google Ch(B4.4 536 0.7(B2980 R (B 0.840(B1.585733(B522 -22141 jwilm 17 0 13.3G (B 518M R  0.1 0.8 1:05.33 /Applications/Google Ch 8543 jwilm 17 0 9.9G 137M R 0.0 0.2 0:39.54 /System/Library/Framewo(B311 8543 jwilm 17 0  9.9G (B 137M R  0.0 0.2 0:39.54 /System/Library/Framewo13248 jwilm 17 0 13.8G 446M R 0.3 0.7 6:24.41 /Applications/Google Ch(B8(B13248 jwilm 17 0 13.8G (B 446M R  0.3 0.7 6:24.41 /Applications/Google Ch19930 jwilm 17 0 13.2G 585M R 0.2 0.9 1:00.31 /Applications/Google Ch(B74(B|2.87(B|1.8(B86196 R  1.262.67122032019930 jwilm 17 0 13.2G (B 585M R  0.2 0.9 1:00.31 /Applications/Google Ch 396 jwilm 17 0 9.8G 74240 R 0.2 0.1 3:06.11 /System/Library/CoreSer(B9(B19930 jwilm 17 0 13.2G 585M R 0.2 0.9 1:00.31 /Applications/Google Ch(B 396 jwilm 17 0  9.8G (B74240 R  0.2 0.1 3:06.11 /System/Library/CoreSer13248 jwilm 17 0 13.8G 446M R 0.0 0.7 6:24.41 /Applications/Google Ch19930 jwilm  17 0 13.2G (B 585M R  0.2 0.9 1:00.31 /Applications/Google Ch 8543 jwilm 17 0 9.9G 137M R 0.0 0.2 0:39.54 /System/Library/Framewo13248 jwilm  17 0 13.8G (B 446M R  0.0 0.7 6:24.41 /Applications/Google Ch22141 jwilm 17 0 13.3G 518M R 0.2 0.8 1:05.33 /Applications/Google Ch 8543 jwilm  17 0  9.9G (B 137M R  0.0 0.2 0:39.54 /System/Library/Framewo29826 jwilm 24 0 9621M 7408 R 0.3 0.0 0:00.03 htop 22141 jwilm  17 0 13.3G (B 518M R  0.2 0.8 1:05.33 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.0 2.7 51:50.82 /Applications/Google Ch29826 jwilm  24 0 9621M 7408 R  0.3 0.0 0:00.03 htop 8453 jwilm 17 0 9.6G 112M R 0.0 0.2 0:37.22 /System/Library/Framewo 923 jwilm  17 0 15.6G (B1800M R  0.0 2.7 51:50.82 /Applications/Google Ch29220 jwilm 17 0 13.2G 583M R 0.4 0.9 0:14.72 /Applications/Google Ch 8453 jwilm  17 0  9.6G (B 112M R  0.0 0.2 0:37.22 /System/Library/Framewo29240 jwilm 17 0 13.6G 825M R 0.2 1.3 0:59.33 /Applications/Google Ch29220 jwilm  17 0 13.2G (B 583M R  0.4 0.9 0:14.72 /Applications/Google Ch29598 jwilm 26 0 10.0G 132M R 2.6 0.2 0:00.71 target/debug/alacritty 29240 jwilm  17 0 13.6G (B 825M R  0.2 1.3 0:59.33 /Applications/Google Ch 580 jwilm 17 0 9752M 58496 R 1.2 0.1 7:38.76 tmux 29598 jwilm  26 0 10.0G (B 132M R  2.6 0.2 0:00.71 target/debug/alacritty  1141 jwilm 26 0 10.5G 227M R 1.8 0.3 11:34.61 target/release/alacritt 580 jwilm  17 0 9752M 58496 R  1.2 0.1 7:38.76 tmux||8.22(B||6.6402(B3.16544 R  2.1804.7946553435434323|7.1 1.8 1.913.5(B29240(B173.6G 826M R 1.7 1.3 0:59.35 /Applications/Google Ch114126 0 10.5G (B 227M R  1.5 0.3 11:34.67 target/release/alacritt1.480 - 589752M 58544 R  1.0 0.1 7:38.80 tmux49 -2214113.3G (B 515(B6 0.8 1:05.34 /Applications/Google Ch199303.2G (B 5855 0.9 1:00.31 92317 0 15.6G (B1800M 2.7 51:50.83 /Applications/Google Ch982624 0 9621M 7408 R  0.4 0.0 0:00.04 htop - 3968G (B74(B240 R  0.3 0.1 3:06.12CoreSer7616G (B 3646 0:46.964337G (B458562:35.96 /Applications/Karabin| 4.03(B|2.0(B|3(B2 1.0(B 1141260.5G 2276 0.3 11:34.69 target/release/alacritt(B295980G (B 1322 0:00.82debug/alacritty  58017 0 9752M 58560 R  1.2 0.1 7:38.81 tmux -292213.2G (B 584M (BR  0.4 0.9 0:14.73 /Applications/Google Ch 9235.6G (B18003 2.7 51:50.83 -2982624 0 9621M 7408 R  0.2 0.0 0:00.05 htop -199303.2G (B 5852 0.9 1:00.32 -1324817 0 13.8G (B 446M R (B 0.2 0.7 6:24.42 /Applications/Google Ch2924013.6G (B 826M R  0.2 1.3 0:59.36 /Applications/Google Ch 9155244.9G (B12652 1.9  1h(B18:35Slack.app 396 9.8G (B74240 R  0.2 0.1 3:06.12 /System/Library/CoreSer187113.0G (B 529M 8 0:31.54Google Ch76 1.84 (B1.80 1141 jwilm 26 0 10.5G (B 227M R (B 1.6 0.3 11:34.69 target/release/alacritt29598 jwilm 26 0 10.0G 132M R 1.5 0.2 0:00.82 target/debu(Bg/alacritty (B3(B29598 jwilm 26 0 10.0G (B 132M R  1.5 0.2 0:00.82 target/debug/alacritty  580 jwilm 17 0 9752M 58560 R 1.2 0.1 7:38.81 tmux (B||||12.303.1(B||||10.7(B|2.3(B62.4722.35 - 580 jwilm 17 0 9752M 58592 R  1.9 0.1 7:38.84 tmux -29220 jwilm 17 0 13.2G 584M R 0.3 0.(B9 0:14.74 /Applications/Google Ch41317597011.1529220 jwilm 17 0 13.2G (B 584M R  0.3 0.9 0:14.74 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.3 2.7 51:50.84 /Applications/Google Ch(B 923 jwilm 17 0 15.6G (B1800M R  0.3 2.7 51:50.84 /Applications/Google Ch22141 jwilm 17 0 13.3G 515M R 0.1 0.8 1:05.34 /Applications/Google Ch(B4(B22141 jwilm 17 0 13.3G (B 515M R  0.1 0.8 1:05.34 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.3 0.0 0:00.05 htop (B||  8.75961.8(B|  5.36(B25986245625 -29826 jwilm 24 0 9621M 7408 R  0.3 0.0 0:00.05 htop -19930 jwilm 17 0 13.2G 586M R 0.2 0.9 1:00.32 /Application(Bs/Google Ch1127M R  0.2619930 jwilm 17 0 13.2G (B 586M R  0.2 0.9 1:00.32 /Applications/Google Ch13248 jwilm 17 0 13.8G 447M R 0.2 0.7 6:24.42 /Applications/Google Ch(B5(B13248 jwilm 17 0 13.8G (B 447M R  0.2 0.7 6:24.42 /Applications/Google Ch29240 jwilm 17 0 13.6G 825M R 0.1 1.3 0:59.37 /Applications/Google Ch(B29240 jwilm 17 0 13.6G (B 825M R  0.1 1.3 0:59.37 /Applications/Google Ch 9155 jwilm 24 0 14.9G 1265M R 0.1 1.9 1h18:35 /Applications/Slack.app(B| 66022.5(B| 4.21.7(B71.7729140275M R  1.15263688 - 9155 jwilm 24 0 14.9G (B1265M R (B 0.0 1.9  1h(B18:35 /Applications/Slack.app 396 jwilm 17 0 9.8G 74240 R 0.1 (B 0.1 3:06.12 /System/Library/CoreSer16(B 396 jwilm 17 0  9.8G (B74240 R  0.1 0.1  3:06.12 /System/Library/CoreSer18713 jwilm 17 0 13.0G 527M R 0.1 0.8 0:31.56 /Applications/Google C(Bh(B5.112.972.2(B483M R  1.5356080.36553243499332(B 396 jwilm 17 0 9.8G 74240 R 0.3 0.1 3:06.13 /System/Library/CoreSer18713 jwilm  17 0 13.0G (B 527M R  0.2 0.8 0:31.56 /Applications/Google Ch0 1.82(B 9155 jwilm 24 0 14.9G 1265M R 0.0 1.9 1h18:35 /Applications/Slack.app(B 396 jwilm 17 0  9.8G (B74240 R  0.3 0.1 3:06.13 /System/Library/CoreSer29240 jwilm 17 0 13.6G 826M R 0.9 1.3 0:59.39 /Applications/Google Ch 9155 jwilm  24 0 14.9G (B1265M R  0.0 1.9  1h(B18:35 /Applications/Slack.app13248 jwilm 17 0 13.8G 447M R 0.4 0.7 6:24.43 /Applications/Google Ch29240 jwilm  17 0 13.6G (B 826M R  0.9 1.3 0:59.39 /Applications/Google Ch19930 jwilm 17 0 13.2G 586M R 0.4 0.9 1:00.33 /Applications/Google Ch13248 jwilm  17 0 13.8G (B 447M R  0.4 0.7 6:24.43 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.2 0.0 0:00.06 htop 19930 jwilm  17 0 13.2G (B 586M R  0.4 0.9 1:00.33 /Applications/Google Ch22141 jwilm 17 0 13.3G 515M R 0.3 0.8 1:05.35 /Applications/Google Ch29826 jwilm  24 0 9621M 7408 R  0.2 0.0 0:00.06 htop 923 jwilm 17 0 15.6G 1800M R 0.5 2.7 51:50.85 /Applications/Google Ch22141 jwilm  17 0 13.3G (B 515M R  0.3 0.8 1:05.35 /Applications/Google Ch29220 jwilm 17 0 13.2G 585M R 0.3 0.9 0:14.76 /Applications/Google Ch 923 jwilm  17 0 15.6G (B1800M R  0.5 2.7 51:50.85 /Applications/Google Ch 580 jwilm 17 0 9752M 58656 R 1.0 0.1 7:38.88 tmux 29220 jwilm  17 0 13.2G (B 585M R  0.3 0.9 0:14.76 /Applications/Google Ch29598 jwilm 26 0 10.0G 133M R 1.5 0.2 0:00.93 target/debug/alacritty  580 jwilm  17 0 9752M 58656 R  1.0 0.1 7:38.88 tmux 1141 jwilm 26 0 10.5G 227M R 1.4 0.3 11:34.78 target/release/alacritt29598 jwilm  26 0 10.0G (B 133M R  1.5 0.2 0:00.93 target/debug/alacritty |||9.843.3(B||88(B3.3(B295980G 133M R 72 0:01.02debug/alacritty  11415G (B 227M R  5.1 0.3 11:34.85release/alacritt704 R  3.59382624 0 9621M 7408 R  0.8 0.0 0:00.07 htop352 5 (B 9.6G (B12880 0.0 1:24.87 /System/Library/CoreSer 9235.6G (B18002.7 51:50.8622017 0 13.2G (B 586M R  0.3 0.9 0:14.76 /Applications/Google Ch 4806 9.5G (B 6352 R  0.2 0.0 0:29.98 /System/Library/Private2 -19932G (B 582 0.9 1:00.33 -29240173.6G (B 8262 1.3 0:59.39Google Ch2214113.3G (B 515M (BR  0.2 0.8 1:05.36 /Applications/Google Ch| 5.0 2.0(B| 3.09 1.0(B 11415G 227M R 1.8 0.3 11:34.86release/alacritt 58017 0 9752M 58720 R  1.4 0.1 7:38.94 tmux -2959826 0 10.0G (B 133M (BR  1.4 0.2 0:01.03 target/debug/alacritty24017 0 13.6G (B 828M R  0.9 1.3 0:59.40 /Applications/Google Ch923 0 15.6G (B1800M R  0.4 2.7 51:50.86 /Applications/Google Ch292203.2G (B 5864 0.9 0:14.77 -19931:00.33 -298224 0 9621M 7408300.07 htop 433 9.7G (B45(B856 1 2:35.97Karabiner21413G (B 5150.8 1:05.36 -  396 9.8G (B74240 1 3:06.13 /System/Library/CoreSer 91575.3G (B 8151.2 3:14.92Slack.app7(B|450(B|2.9(B2.083664 -187131G (B 527M R  1.2 0.8 0:31.57 -199303.2G (B 5866 0.9 1:00.345 -221413G (B 515 0.8 1:05.36 - 43317 0  9.7G (B458561 2:35.97 /Applications/Karabiner 9235.6G (B18003 2.7 51:50.86 -2982624 0 9621M 74083 0.0 0:00.07 htop -292406G (B 8281.3 0:59.41 -1324813.8G (B 448M 7 6:24.44 /Applications/Google Ch269412.9G (B 5601 0.9 0:08.17Google Ch 131 1.0(B1.490 -2959826 0 10.0G (B 133M R  1.3 0.2 0:01.06 target/debug/alacritty - 58017 0 9752M 58768 R  1.1 0.1 7:38.97 tmux -292406G (B 8(B0 1.3 0:59.42 -292240:14.78 - 9235.6G (B18004 2.7 51:50.82982624 0 9621M 7408 R  0.3 0.0 0:00.08 htop -2214113.3G (B 516M R  0.2 0.8 1:05.36Google Ch132483.8G (B 4482 0.7 6:24.44 -1993017 0 13.2G (B 586M R  0.2 0.9 1:00.34 /Applications/Google Ch 396 9.8G (B74240 0.1 3:06.13 /System/Library/CoreSer87131G (B 5271 0.8 0:31.58 -176103.6G (B 3656 0:46.9 -||10.96(B|2.9(B|(B72(B|3(B2.029(B34448598260.0G (B 1333 0.2 0:01.07 target/debug/alacritty 35132488G (B 4487 6:24.44 -292406G (B 8271.3 0:59.42433 jwilm17 0  9.7G (B45888 R  0.2 0.1 2:35.97 /Applications/Karabiner221413G (B 518 1:05.37 -1993013.2G (B 586M 9 1:00.34 /Applications/Google Ch 9155244.9G (B12662 1.9  1h(B18:35Slack.app 396 9.8G (B74240 R  0.2 0.1 3:06.13 /System/Library/CoreSer3 1.83(B 1141 jwilm 26 0 10.5G (B 227M R  2.0 0.3 11:34.92 target/release/alacritt 580 jwilm 17 0 9752M 59344 R 1.4 0.1 7:38.98 tmux (B||  7.151(B|13(B1.9(B81.64 - 580 jwilm 17 0 9752M 59344 R  1.1  0.1 7:39.00 tmux -29598 jwilm 26 0 10.0G 133M R 1.4 0.2 0:01.09 target/debug/alacritty (B46982435973137350144(B29598 jwilm 26 0 10.0G (B 133M R  1.4 0.2 0:01.09 target/debug/alacritty 29220 jwilm 17 0 13.2G 584M R 0.6 0.9 0:14.79 /Applications/Google Ch(B29220 jwilm 17 0 13.2G (B 584M R  0.6 0.9 0:14.79 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.4 2.7 51:50.88 /Applications/Google Ch(B 923 jwilm 17 0 15.6G (B1800M R  0.4 2.7 51:50.88 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.2 0.0 0:00.08 htop (B29826 jwilm 24 0 9621M 7408 R  0.2 0.0 0:00.08 htop -13248 jwilm (B 17 0 13.8G 444M R 0.3 0.7 6:24.45 /Applications/Google Ch(B55992.85.62.8(B27823.6134339 -13248 jwilm 17 0 13.8G (B 444M R  0.2 0.7 6:24.45 /Applications/Google Ch29240 jwilm 17 0 13.6G 828M R 0.9 1.3 0:59.44 /Applications/Google Ch(B8225(B29240 jwilm 17 0 13.6G (B 828M R  0.9 1.3 0:59.44 /Applications/Google Ch 433 jwilm 17 0 9.7G 45888 R 0.1 0.1 2:35.98 /Applications/Karabiner(B 433 jwilm 17 0  9.7G (B45888 R  0.1 0.1 2:35.98 /Applications/Karabiner22141 jwilm 17 0 13.3G 516M R 0.2 0.8 1:05.37 /Applications/Google Ch(B22141 jwilm 17 0 13.3G (B 516M R  0.2 0.8 1:05.37 /Applications/Google Ch19930 jwilm 17 0 13.2G 587M R 0.3 0.9 1:00.35 /Applications/Google Ch(B19930 jwilm 17 0 13.2G (B 587M R  0.3 0.9 1:00.35 /Applications/Google Ch 9155 jwilm 24 0 14.9G 1266M R 0.0 1.9 1h18:35 /Applications/Slack.app(B19930 jwilm 17 0 13.2G 587M R 0.3 0.9 1:00.35 /Applications/Google Ch 9155 jwilm  24 0 14.9G (B1266M R  0.0 1.9  1h(B18:35 /Applications/Slack.app|8.36021.961.9(B85.009487804532 -22141 jwilm 17 0 13.(B3G 516M R 0.2 0.8 1:05.38 /Applications/Google Ch19930 jwilm 17 0 13.2G (B 587(BM R  0.2 0.9 1:00.35 /Applications/Google Ch4 433 jwilm 17 0 9.7G 45888 R 0.2 0.1 2:35.98 /Applications/Karabiner22141 jwilm  17 0 13.3G (B 516M R  0.2 0.8 1:05.38 /Applications/Google Ch29240 jwilm 17 0 13.6G 828M R 0.3 1.3 0:59.44 /Applications/Google Ch 433 jwilm  17 0  9.7G (B45888 R  0.2 0.1 2:35.98 /Applications/Karabiner13248 jwilm 17 0 13.8G 445M R 0.2 0.7 6:24.45 /Applications/Google Ch29240 jwilm  17 0 13.6G (B 828M R  0.3 1.3 0:59.44 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.4 0.0 0:00.09 htop 13248 jwilm  17 0 13.8G (B 445M R  0.2 0.7 6:24.45 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.3 2.7 51:50.88 /Applications/Google Ch29826 jwilm  24 0 9621M 7408 R  0.4 0.0 0:00.09 htop29220 jwilm 17 0 13.2G 584M R 0.4 0.9 0:14.80 /Applications/Google Ch 923 jwilm  17 0 15.6G (B1800M R  0.3 2.7 51:50.88 /Applications/Google Ch29598 jwilm 26 0 10.0G 133M R 3.8 0.2 0:01.17 target/debug/alacritty 29220 jwilm  17 0 13.2G (B 584M R  0.4 0.9 0:14.80 /Applications/Google Ch 580 jwilm 17 0 9752M 59344 R 1.9 0.1 7:39.04 tmux 29598 jwilm  26 0 10.0G (B 133M R  3.8 0.2 0:01.17 target/debug/alacritty  1141 jwilm 26 0 10.5G 227M R 2.8 0.3 11:35.00 target/release/alacritt 580 jwilm  17 0 9752M 59344 R  1.9 0.1 7:39.04 tmux||||14.5(B||5.8(B||(B10.1(B||5.7(B295980G 133M R 11.0 0.2 0:01.25debug/a(Blacritty 114126 0 10.5G (B 227M R  7.5 0.3 11:35.05 target/release/alacritt 58017 0 9752M 59344 R  5.5 0.1 7:39.08 tmux82624  0 9621M 7408 R  1.1 0.0 0:00.10 htop352 5  9.6G (B12(B880 R  0.7 0.0 1:24.89 /System/Library/CoreSer 48017 0  9.5G (B 6(B35229.98 /System/Library/Private233901.4G (B 2501 0.4 0:53.98Spotify.a 91575.3G (B 8151 1.2 3:14.93Slack.app1 - 91584.2G (B 5412:26.15Slack.app 17029656M 1(B392 R  0.1 0.0 0:47.83 redis-server *:19201 154617 0 9624M 1328 R (B 0.1 0.0 0:47.98 redis-server *:637997G (B169761 0.0 0:30.63 /Applications/Seil.app/|  5.0599 1.067 1.81 (B1.79|(B  4.07 1.0(B 11415G 227M R 2.4 0.3 11:35.08(Brelease/alacritt 58017 0 9752M 59344 R  11 7:39.09 tmux2959826 0 10.0G (B 133M R  12 0:01.26 target/debug/alacritty24017 0 13.6G (B 829M R  0.9 1.3 0:59.45 /Applications/Google Ch9158 0 14.2G (B 546M R  0.5 0.8 2:26.15 /Applications/Slack.app2922013.2G (B 584M 9 0:14.80 /Applications/Google Ch 9235.6G (B180(B3 2.7 51:50.89Google Ch199303.2G (B 5873 0.9 1:00.36Google Ch2982624 0 9621M 7403 0.0 0:00.10 htop -221413.3G (B 51(B21:05.38Google Ch8453 9.6G (B 112M R  0.2 0.2 0:37.23 /System/Library/Framewo1324813.8G (B 445M R  0.2 0.7 6:24.45 /Applications/Google Ch68G (B742402 0.1 3:06.14 /System/Library/CoreSer -9608(B|28(B|(B2(B9110114822G (B 5856 0.9 0:14.81 - 288 9.6G (B46016 R  0.5 0.1 0:18.70 /System/Library/Private221413G (B 5168 1:05.3813248 jwilm17 0 13.8G (B 445M R  0.3 0.7 6:24.46 /Applications/Google Ch187131G (B 5280:31.59 -2924013.6G (B 8291.3 0:59.45 /Applications/Google Ch99302G (B 5879 1:00.364337G (B458882:35.98 /Applications/Karabin3.07 2.99(B81.72(B2959826 0 10.0G (B 133M R  1.4 0.2 0:01.29 target/debug/alacritty - 58017 0 9752M 59344 R  1.2 0.1 7:39.12 tmux46G (B 828(BM R  1.1 1.3 0:59.46 -2922013.2G (B 585M R  0.4 0.9 0:14.81 /Applications/Google Ch982624 0 9621M 7408 0 0:00.11 htop -2214117 0 13.3G (B 517M R  0.2 0.8 1:05.38 /Applications/Google Ch99302G (B 5872 0.9 1:00.3 -132488G (B 4457 6:24.46 - 396 9.8G (B74240 0.1 3:06.15 /System/Library/CoreSer 433 9.7G (B45888 R  0.1 0.1 2:35.98Karabiner2339011.4G (B 250M (BR  0.1 0.4 0:53Spotify.a6:00(B 1141 jwilm 26 0 10.5G (B 227M R  1.7 0.3 11:35.12 target/release/alacritt29598 jwilm 26 0 10.0G 133M R 1.4 0.2 0:01.29 target/debug/alacritty (B|||7.86(B|3.0 (B9(B2.34 -29598 jwilm 26 0 10.0G (B 133M R  2.2 0.2 0:01.31 target/debug/alacritty  580 jwilm 17 0 9752M 59344 R 1.7 0.1 7:39.14 tmux (B0.2752903913991(B 580 jwilm 17 0 9752M 59344 R  1.7 0.1 7:39.14 tmux29240 jwilm 17 0 13.6G 828M R 0.2 1.3 0:59.47 /Applications/Google Ch(B29240 jwilm 17 0 13.6G (B 828M R  0.2 1.3 0:59.47 /Applications/Google Ch29220 jwilm 17 0 13.2G 585M R 0.5 0.9 0:14.82 /Applications/Google Ch(B| 4.7549(B|1.6(B151.640.857M R  1.08 -29220 jwilm 17 0 13.2G (B 586M R  0.8 0.9 0:14.83 /Applications/Google Ch 923 jwilm 17 0 15.(B6G 1800M R 0.5 2.7 51:50.90 /Applications/Google Ch24473562||5.96 1.01 1.8003(B 0(B060.769M R  0.99531283627661|||||20.03(B|5.9(B||||(B13.94(B||5.9(B0.872.2786243.74324022 \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/underline b/cmd/sst/mosaic/multiplexer/tcell-term/tests/underline deleted file mode 100644 index 6d34de2eb2..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/underline +++ /dev/null @@ -1,13 +0,0 @@ -[undeadleech@undeadlap underline]$ [undeadleech@undeadlap underline]$ echo -e "\e[4mUNDERLINED\e[0m" -UNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4:1mUNDERLINED\e[4:0m" -[4:1mUNDERLINED[4:0m -[undeadleech@undeadlap underline]$ echo -e "\e[4:2mUNDERLINED\e[24m" -[4:2mUNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4:3mUNDERLINED\e[21m";mUNDERLINED\e[21m"2mUNDERLINED\e[21m"1mUNDERLINED\e[21m"m"m"0m" -[4:3;21mUNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4;4:2mUNDERLINED\e[0m" -[4;4:2mUNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4;4:2mUNDERLINED\e[0m":;4:2mUNDERLINED\e[0m"1;4:2mUNDERLINED\e[0m";4:2mUNDERLINED\e[0m"2;4:2mUNDERLINED\e[0m"mUNDERLINED\e[0m"1mUNDERLINED\e[0m" -[4:2;4:1mUNDERLINED -[undeadleech@undeadlap underline]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_24bitcolors_bce b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_24bitcolors_bce deleted file mode 100644 index bb8c3d0584..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_24bitcolors_bce +++ /dev/null @@ -1,1227 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h -bck-i-search: _mv ../../../{grid.json,size.json,alacritty.recording} ./v_cd vim_large_window_scroll i_imm_     vvivim ssrrcc//rreenndderer/r [?1l>[?2004l [?1049h[?1h=β–½ [?12;25h[?12l[?25h[?25l"src/renderer" is a directory[>c" ============================================================================   -" Netrw Directory Listing (netrw v156)   -" /Users/jwilm/code/alacritty/src/renderer  -" Sorted by name  -" Sort sequence: [\/]$,\,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$ -" Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:special  -" ==============================================================================  -../ ./  -mod.rs  -~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 8,1All[?12l[?25h[?25l../ ./ 9[?12l[?25h[?25l./ mod.rs 10,1[?12l[?25h[?25l~/code/alacritty/src/renderer/mod.rs"1354L, 40527C 864  }   - 865    - 866  pub fn deactivate(&self) {    - 867  unsafe {    - 868  gl::UseProgram(0);   869  }   - 870  }   - 871    - 872  pub fn new(   - 873  config: &Config,  874 size: Size<Pixels<u32>>   875 ) -> Result<ShaderProgram, ShaderCreationError> {   876 let vertex_source = if cfg!(feature = "live-shader-reload") {   877 None   878 } else {   879 Some(TEXT_SHADER_V)   880 };   881 let vertex_shader = ShaderProgram::create_shader(   882 TEXT_SHADER_V_PATH,   883 gl::VERTEX_SHADER,   884 vertex_source   885 )?;   886 let frag_source = if cfg!(feature = "live-shader-reload") {   887 None   888 } else {   889 Some(TEXT_SHADER_F)   890 };   891 let fragment_shader = ShaderProgram::create_shader(   892 TEXT_SHADER_F_PATH,   893 gl::FRAGMENT_SHADER,   894 frag_source   895 )?;   896 let program = ShaderProgram::create_program(vertex_shader, fragment_shader);   897   898 unsafe {   899 gl::DeleteShader(vertex_shader);   900 gl::DeleteShader(fragment_shader);   901 gl::UseProgram(program);   902 }   903   904 macro_rules! cptr {   905 ($thing:expr) => { $thing.as_ptr() as *const _ }   906 }   907   908 macro_rules! assert_uniform_valid {   909 ($uniform:expr) => {   910 assert!($uniform != gl::INVALID_VALUE as i32);   911 assert!($uniform != gl::INVALID_OPERATION as i32);   912 };   913 ( $( $uniform:expr ),* ) => {   914 $( assert_uniform_valid!($uniform); )*   915 };   916 }   917   918 // get uniform locations   919 let (projection, term_dim, cell_dim, visual_bell, background) = unsafe {  891,166%[?12l[?25h[?25l 1 // Copyright 2016 Joe Wilm, The Alacritty Project Contributors  - 2 //  - 3 // Licensed under the Apache License, Version 2.0 (the "License");  - 4 // you may not use this file except in compliance with the License.  - 5 // You may obtain a copy of the License at  - 6 //  - 7 // http://www.apache.org/licenses/LICENSE-2.0  - 8 //  - 9 // Unless required by applicable law or agreed to in writing, software  - 10 // distributed under the License is distributed on an "AS IS" BASIS,  - 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  - 12 // See the License for the specific language governing permissions and  - 13 // limitations under the License.  - 14 use std::collections::HashMap;  - 15 use std::hash::BuildHasherDefault;  - 16 use std::fs::File;  - 17 use std::io::{self, Read};  - 18 use std::mem::size_of;  - 19 use std::path::{PathBuf};  - 20 use std::ptr;  - 21 use std::sync::mpsc;  - 22   - 23 use cgmath;  - 24 use fnv::FnvHasher;  - 25 use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, FontKey};  - 26 use gl::types::*;  - 27 use gl;  - 28 use index::{Line, Column, RangeInclusive};  - 29 use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};  - 30   - 31 use config::{self, Config, Delta};  - 32 use term::{self, cell, RenderableCell};  - 33 use window::{Size, Pixels};  - 34   - 35 use Rgb;  - 36   - 37 // Shader paths for live reload  - 38 static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");   - 39 static TEXT_SHADER_V_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl");   - 40   - 41 // Shader source which is used when live-shader-reload feature is disable  - 42 static TEXT_SHADER_F: &'static str = include_str!(  - 43  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl")  - 44 );  - 45 static TEXT_SHADER_V: &'static str = include_str!(  - 46  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl")  - 47 );  - 48   - 49 /// `LoadGlyph` allows for copying a rasterized glyph into graphics memory  - 50 pub trait LoadGlyph {  - 51  /// Load the rasterized glyph into GPU memory  - 52  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph;  - 53 }  - 54   - 55 enum Msg {  - 56  ShaderReload, 1,1Top[?12l[?25h[?25l:[?12l[?25hs[?25l[?12l[?25he[?25l[?12l[?25ht[?25l[?12l[?25h[?25l ft=yaml[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25hc[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25hc[?25l[?12l[?25ho[?25l[?12l[?25hl[?25l[?12l[?25ho[?25l[?12l[?25hr[?25l[?12l[?25hs[?25l[?12l[?25hh[?25l[?12l[?25h[?25l[?12l[?25hc[?25l[?12l[?25hh[?25l[?12l[?25he[?25l[?12l[?25hm[?25l[?12l[?25he[?25l[?12l[?25h[?25l [?12l[?25h...[?25lTomorrow-Night-Bright[?12l[?25h...[?25lblue[?12l[?25h...[?25ldarkblue[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25ht[?25l[?12l[?25h...[?25lTomorrow-Night-Bright[?12l[?25h...[?25ltende[?12l[?25h [?25l 1 // Copyright 2016 Joe Wilm, The Alacritty Project Contributors  - 2 //  - 3 // Licensed under the Apache License, Version 2.0 (the "License");  - 4 // you may not use this file except in compliance with the License.  - 5 // You may obtain a copy of the License at  - 6 //  - 7 // http://www.apache.org/licenses/LICENSE-2.0  - 8 //  - 9 // Unless required by applicable law or agreed to in writing, software  - 10 // distributed under the License is distributed on an "AS IS" BASIS,  - 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  - 12 // See the License for the specific language governing permissions and  - 13 // limitations under the License.  - 14 use std::collections::HashMap;  - 15 use std::hash::BuildHasherDefault;  - 16 use std::fs::File;  - 17 use std::io::{self, Read};  - 18 use std::mem::size_of;  - 19 use std::path::{PathBuf};  - 20 use std::ptr;  - 21 use std::sync::mpsc;  - 22   - 23 use cgmath;  - 24 use fnv::FnvHasher;  - 25 use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, FontKey};  - 26 use gl::types::*;  - 27 use gl;  - 28 use index::{Line, Column, RangeInclusive};  - 29 use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};  - 30   - 31 use config::{self, Config, Delta};  - 32 use term::{self, cell, RenderableCell};  - 33 use window::{Size, Pixels};  - 34   - 35 use Rgb;  - 36   - 37 // Shader paths for live reload  - 38 static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");   - 39 static TEXT_SHADER_V_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl");   - 40   - 41 // Shader source which is used when live-shader-reload feature is disable  - 42 static TEXT_SHADER_F: &'static str = include_str!(  - 43  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl")  - 44 );  - 45 static TEXT_SHADER_V: &'static str = include_str!(  - 46  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl")  - 47 );  - 48   - 49 /// `LoadGlyph` allows for copying a rasterized glyph into graphics memory  - 50 pub trait LoadGlyph {  - 51  /// Load the rasterized glyph into GPU memory  - 52  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph;  - 53 }  - 54   - 55 enum Msg {  - 56  ShaderReload, 1,1Top[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l10,1[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l20[?12l[?25h[?25l1[?12l[?25h[?25l2,0-1[?12l[?25h[?25l3,1 [?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l30,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6,0-1[?12l[?25h[?25l7,1 [?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l40,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l()4[?12l[?25h[?25l( );5[?12l[?25h[?25l6[?12l[?25h[?25l()7[?12l[?25h[?25l( );8,0-1[?12l[?25h[?25l9,1 [?12l[?25h[?25l50[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l{}3[?12l[?25h[?25l{ } 4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6[?12l[?25h[?25l -{ - - 57 } 57,10%[?12l[?25h[?25l -{ } - 58  58,0-10%[?12l[?25h[?25l - 59 #[derive(Debug)] 59,10%[?12l[?25h[?25l - 60 pub enum Error { 60,10%[?12l[?25h[?25l - 61  ShaderCreation(ShaderCreationError), 61,10%[?12l[?25h[?25l -{ - - 62 } 62,10%[?12l[?25h[?25l -{ } - 63  63,0-10%[?12l[?25h[?25l - 64 impl ::std::error::Error for Error { 64,10%[?12l[?25h[?25l - 65  fn cause(&self) -> Option<&::std::error::Error> { 65,10%[?12l[?25h[?25l - 66 match *self { 66,10%[?12l[?25h[?25l - 67 Error::ShaderCreation(ref err) => Some(err), 67,10%[?12l[?25h[?25l - 68 } 68,10%[?12l[?25h[?25l - 69  } 69,11%[?12l[?25h[?25l - 70  70,0-11%[?12l[?25h[?25l - 71  fn description(&self) -> &str { 71,11%[?12l[?25h[?25l - 72 match *self { 72,11%[?12l[?25h[?25l - 73 Error::ShaderCreation(ref err) => err.description(), 73,11%[?12l[?25h[?25l - 74 } 74,11%[?12l[?25h[?25l - 75  } 75,11%[?12l[?25h[?25l -{ 76 } 76,11%[?12l[?25h[?25l -{ } - 77  77,0-11%[?12l[?25h[?25l - 78 impl ::std::fmt::Display for Error { 78,11%[?12l[?25h[?25l - 79  fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 79,11%[?12l[?25h[?25l - 80 match *self { 80,11%[?12l[?25h[?25l - 81 Error::ShaderCreation(ref err) => { 81,11%[?12l[?25h[?25l - 82 write!(f, "There was an error initializing the shaders: {}", err) 82,12%[?12l[?25h[?25l - 83 } 83,12%[?12l[?25h[?25l - 84 } 84,12%[?12l[?25h[?25l - 85  } 85,12%[?12l[?25h[?25l -{ 86 } 86,12%[?12l[?25h[?25l -{ } - 87  87,0-12%[?12l[?25h[?25l - 88 impl From<ShaderCreationError> for Error { 88,12%[?12l[?25h[?25l - 89  fn from(val: ShaderCreationError) -> Error { 89,12%[?12l[?25h[?25l - 90 Error::ShaderCreation(val) 90,12%[?12l[?25h[?25l - 91  } 91,12%[?12l[?25h[?25l -{ 92 } 92,12%[?12l[?25h[?25l -{ } - 93  93,0-12%[?12l[?25h[?25l - 94  94,0-12%[?12l[?25h[?25l - 95 /// Text drawing program 95,13%[?12l[?25h[?25l - 96 /// 96,13%[?12l[?25h[?25l - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a". 97,13%[?12l[?25h[?25l - 98 #[derive(Debug)] 98,13%[?12l[?25h[?25l - 99 pub struct ShaderProgram { 99,13%[?12l[?25h[?25l - 100  // Program id 100,13%[?12l[?25h[?25l - 101  id: GLuint, 101,13%[?12l[?25h[?25l - 102  102,0-13%[?12l[?25h[?25l - 103  /// projection matrix uniform 103,13%[?12l[?25h[?25l - 104  u_projection: GLint, 104,13%[?12l[?25h[?25l - 105  105,0-13%[?12l[?25h[?25l - 106  /// Terminal dimensions (pixels) 106,13%[?12l[?25h[?25l - 107  u_term_dim: GLint, 107,13%[?12l[?25h[?25l - 108  108,0-14%[?12l[?25h[?25l - 109  /// Cell dimensions (pixels) 109,14%[?12l[?25h[?25l - 110  u_cell_dim: GLint, 110,14%[?12l[?25h[?25l - 111  111,0-14%[?12l[?25h[?25l - 112  /// Visual bell 112,14%[?12l[?25h[?25l - 113  u_visual_bell: GLint, 113,14%[?12l[?25h[?25l - 114  114,0-14%[?12l[?25h[?25l - 115  /// Background pass flag 115,14%[?12l[?25h[?25l - 116  /// 116,14%[?12l[?25h[?25l - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text 117,14%[?12l[?25h[?25l - 118  u_background: GLint, 118,14%[?12l[?25h[?25l - 119  119,0-14%[?12l[?25h[?25l - 120  padding_x: f32, 120,14%[?12l[?25h[?25l - 121  padding_y: f32, 121,15%[?12l[?25h[?25l -{ 122 } 122,15%[?12l[?25h[?25l -{ } - 123  123,0-15%[?12l[?25h[?25l - 124  124,0-15%[?12l[?25h[?25l - 125 #[derive(Debug, Clone)] 125,15%[?12l[?25h[?25l - 126 pub struct Glyph { 126,15%[?12l[?25h[?25l - 127  tex_id: GLuint, 127,15%[?12l[?25h[?25l - 128  top: f32, 128,15%[?12l[?25h[?25l - 129  left: f32, 129,15%[?12l[?25h[?25l - 130  width: f32, 130,15%[?12l[?25h[?25l - 131  height: f32, 131,15%[?12l[?25h[?25l - 132  uv_bot: f32, 132,15%[?12l[?25h[?25l - 133  uv_left: f32, 133,15%[?12l[?25h[?25l - 134  uv_width: f32, 134,16%[?12l[?25h[?25l - 135  uv_height: f32, 135,16%[?12l[?25h[?25l -{ 136 } 136,16%[?12l[?25h[?25l -{ } - 137  137,0-16%[?12l[?25h[?25l - 138 /// NaΓ―ve glyph cache 138,16%[?12l[?25h[?25l - 139 /// 139,16%[?12l[?25h[?25l - 140 /// Currently only keyed by `char`, and thus not possible to hold different 140,16%[?12l[?25h[?25l - 141 /// representations of the same code point. 141,16%[?12l[?25h[?25l - 142 pub struct GlyphCache { 142,16%[?12l[?25h[?25l - 143  /// Cache of buffered glyphs 143,16%[?12l[?25h[?25l - 144  cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>, 144,16%[?12l[?25h[?25l - 145  145,0-16%[?12l[?25h[?25l - 146  /// Rasterizer for loading new glyphs 146,16%[?12l[?25h[?25l - 147  rasterizer: Rasterizer, 147,17%[?12l[?25h[?25l - 148  148,0-17%[?12l[?25h[?25l - 149  /// regular font 149,17%[?12l[?25h[?25l - 150  font_key: FontKey, 150,17%[?12l[?25h[?25l - 151  151,0-17%[?12l[?25h[?25l - 152  /// italic font 152,17%[?12l[?25h[?25l - 153  italic_key: FontKey, 153,17%[?12l[?25h[?25l - 154  154,0-17%[?12l[?25h[?25l - 155  /// bold font 155,17%[?12l[?25h[?25l - 156  bold_key: FontKey, 156,17%[?12l[?25h[?25l - 157  157,0-17%[?12l[?25h[?25l - 158  /// font size 158,17%[?12l[?25h[?25l - 159  font_size: font::Size, 159,17%[?12l[?25h[?25l - 160  160,0-18%[?12l[?25h[?25l - 161  /// glyph offset 161,18%[?12l[?25h[?25l - 162  glyph_offset: Delta, 162,18%[?12l[?25h[?25l - 163  163,0-18%[?12l[?25h[?25l - 164  metrics: ::font::Metrics, 164,18%[?12l[?25h[?25l -{ 165 } 165,18%[?12l[?25h[?25l -{ } - 166  166,0-18%[?12l[?25h[?25l - 167 impl GlyphCache { 167,18%[?12l[?25h[?25l - 168  pub fn new<L>( 168,18%[?12l[?25h[?25l - 169 mut rasterizer: Rasterizer, 169,18%[?12l[?25h[?25l - 170 config: &Config, 170,18%[?12l[?25h[?25l - 171 loader: &mut L 171,18%[?12l[?25h[?25l - 172  ) -> Result<GlyphCache, font::Error> 172,18%[?12l[?25h[?25l - 173 where L: LoadGlyph 173,19%[?12l[?25h[?25l - 174  { 174,19%[?12l[?25h[?25l - 175 let font = config.font(); 175,19%[?12l[?25h[?25l - 176 let size = font.size(); 176,19%[?12l[?25h[?25l - 177 let glyph_offset = *font.glyph_offset(); 177,19%[?12l[?25h[?25l - 178  178,0-19%[?12l[?25h[?25l - 179 fn make_desc( 179,19%[?12l[?25h[?25l - 180 desc: &config::FontDescription, 180,19%[?12l[?25h[?25l - 181 slant: font::Slant, 181,19%[?12l[?25h[?25l - 182 weight: font::Weight, 182,19%[?12l[?25h[?25l - 183 ) -> FontDesc 183,19%[?12l[?25h[?25l - 184 { 184,19%[?12l[?25h[?25l - 185 let style = if let Some(ref spec) = desc.style { 185,19%[?12l[?25h[?25l - 186 font::Style::Specific(spec.to_owned()) 186,110%[?12l[?25h[?25l - 187 } else { 187,110%[?12l[?25h[?25l - 188 font::Style::Description {slant:slant, weight:weight} 188,110%[?12l[?25h[?25l - 189 }; 189,110%[?12l[?25h[?25l - 190 FontDesc::new(&desc.family[..], style) 190,110%[?12l[?25h[?25l - 191 } 191,110%[?12l[?25h[?25l - 192  192,0-110%[?12l[?25h[?25l - 193 // Load regular font 193,110%[?12l[?25h[?25l - 194 let regular_desc = make_desc(&font.normal, font::Slant::Normal, font::Weight::Normal);  194,110%[?12l[?25h[?25l - 195  195,0-110%[?12l[?25h[?25l - 196 let regular = rasterizer 196,110%[?12l[?25h[?25l - 197 .load_font(®ular_desc, size)?; 197,110%[?12l[?25h[?25l - 198  198,0-110%[?12l[?25h[?25l - 199 // helper to load a description if it is not the regular_desc 199,111%[?12l[?25h[?25l - 200 let load_or_regular = |desc:FontDesc, rasterizer: &mut Rasterizer| { 200,111%[?12l[?25h[?25l - 201 if desc == regular_desc { 201,111%[?12l[?25h[?25l - 202 regular 202,111%[?12l[?25h[?25l - 203 } else { 203,111%[?12l[?25h[?25l - 204 rasterizer.load_font(&desc, size).unwrap_or_else(|_| regular) 204,111%[?12l[?25h[?25l - 205 } 205,111%[?12l[?25h[?25l - 206 }; 206,111%[?12l[?25h[?25l - 207  207,0-111%[?12l[?25h[?25l - 208 // Load bold font 208,111%[?12l[?25h[?25l - 209 let bold_desc = make_desc(&font.bold, font::Slant::Normal, font::Weight::Bold); 209,111%[?12l[?25h[?25l - 210  210,0-111%[?12l[?25h[?25l - 211 let bold = load_or_regular(bold_desc, &mut rasterizer); 211,111%[?12l[?25h[?25l - 212  212,0-112%[?12l[?25h[?25l - 213 // Load italic font 213,112%[?12l[?25h[?25l - 214 let italic_desc = make_desc(&font.italic, font::Slant::Italic, font::Weight::Normal); 214,112%[?12l[?25h[?25l - 215  215,0-112%[?12l[?25h[?25l - 216 let italic = load_or_regular(italic_desc, &mut rasterizer); 216,112%[?12l[?25h[?25l - 217  217,0-112%[?12l[?25h[?25l - 218 // Need to load at least one glyph for the face before calling metrics. 218,112%[?12l[?25h[?25l - 219 // The glyph requested here ('m' at the time of writing) has no special 219,112%[?12l[?25h[?25l - 220 // meaning. 220,112%[?12l[?25h[?25l - 221 rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?; 221,112%[?12l[?25h[?25l - 222 let metrics = rasterizer.metrics(regular)?; 222,112%[?12l[?25h[?25l - 223  223,0-112%[?12l[?25h[?25l - 224 let mut cache = GlyphCache { 224,112%[?12l[?25h[?25l - 225 cache: HashMap::default(), 225,113%[?12l[?25h[?25l - 226 rasterizer: rasterizer, 226,113%[?12l[?25h[?25l - 227 font_size: font.size(), 227,113%[?12l[?25h[?25l - 228 font_key: regular, 228,113%[?12l[?25h[?25l - 229 bold_key: bold, 229,113%[?12l[?25h[?25l - 230 italic_key: italic, 230,113%[?12l[?25h[?25l - 231 glyph_offset: glyph_offset, 231,113%[?12l[?25h[?25l - 232 metrics: metrics 232,113%[?12l[?25h[?25l - 233 }; 233,113%[?12l[?25h[?25l - 234  234,0-113%[?12l[?25h[?25l - 235 macro_rules! load_glyphs_for_font { 235,113%[?12l[?25h[?25l - 236 ($font:expr) => { 236,113%[?12l[?25h[?25l - 237 for i in RangeInclusive::new(32u8, 128u8) { 237,113%[?12l[?25h[?25l - 238 cache.get(&GlyphKey { 238,114%[?12l[?25h[?25l - 239 font_key: $font, 239,114%[?12l[?25h[?25l - 240 c: i as char, 240,114%[?12l[?25h[?25l - 241 size: font.size() 241,114%[?12l[?25h[?25l - 242 }, loader); 242,114%[?12l[?25h[?25l - 243 } 243,114%[?12l[?25h[?25l - 244 } 244,114%[?12l[?25h[?25l - 245 } 245,114%[?12l[?25h[?25l - 246  246,0-114%[?12l[?25h[?25l - 247 load_glyphs_for_font!(regular); 247,114%[?12l[?25h[?25l - 248 load_glyphs_for_font!(bold); 248,114%[?12l[?25h[?25l - 249 load_glyphs_for_font!(italic); 249,114%[?12l[?25h[?25l - 250  250,0-114%[?12l[?25h[?25l - 251 Ok(cache) 251,115%[?12l[?25h[?25l - 252  } 252,115%[?12l[?25h[?25l - 253  253,0-115%[?12l[?25h[?25l - 254  pub fn font_metrics(&self) -> font::Metrics { 254,115%[?12l[?25h[?25l - 255 self.rasterizer 255,115%[?12l[?25h[?25l - 256 .metrics(self.font_key) 256,115%[?12l[?25h[?25l - 257 .expect("metrics load since font is loaded at glyph cache creation") 257,115%[?12l[?25h[?25l - 258  } 258,115%[?12l[?25h[?25l - 259  259,0-115%[?12l[?25h[?25l - 260  pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph 260,115%[?12l[?25h[?25l - 261 where L: LoadGlyph 261,115%[?12l[?25h[?25l - 262  { 262,115%[?12l[?25h[?25l - 263 let glyph_offset = self.glyph_offset; 263,115%[?12l[?25h[?25l - 264 let rasterizer = &mut self.rasterizer; 264,116%[?12l[?25h[?25l - 265 let metrics = &self.metrics; 265,116%[?12l[?25h[?25l - 266 self.cache 266,116%[?12l[?25h[?25l - 267 .entry(*glyph_key) 267,116%[?12l[?25h[?25l - 268 .or_insert_with(|| { 268,116%[?12l[?25h[?25l - 269 let mut rasterized = rasterizer.get_glyph(&glyph_key) 269,116%[?12l[?25h[?25l - 270 .unwrap_or_else(|_| Default::default()); 270,116%[?12l[?25h[?25l - 271  271,0-116%[?12l[?25h[?25l - 272 rasterized.left += glyph_offset.x as i32; 272,116%[?12l[?25h[?25l - 273 rasterized.top += glyph_offset.y as i32; 273,116%[?12l[?25h[?25l - 274 rasterized.top -= metrics.descent as i32; 274,116%[?12l[?25h[?25l - 275  275,0-116%[?12l[?25h[?25l - 276 loader.load_glyph(&rasterized) 276,116%[?12l[?25h[?25l - 277 }) 277,117%[?12l[?25h[?25l - 278  } 278,117%[?12l[?25h[?25l - 279 } 279,117%[?12l[?25h[?25l - 280  280,0-117%[?12l[?25h[?25l - 281 #[derive(Debug)] 281,117%[?12l[?25h[?25l - 282 #[repr(C)] 282,117%[?12l[?25h[?25l - 283 struct InstanceData { 283,117%[?12l[?25h[?25l - 284  // coords 284,117%[?12l[?25h[?25l - 285  col: f32, 285,117%[?12l[?25h[?25l - 286  row: f32, 286,117%[?12l[?25h[?25l - 287  // glyph offset 287,117%[?12l[?25h[?25l - 288  left: f32, 288,117%[?12l[?25h[?25l - 289  top: f32, 289,117%[?12l[?25h[?25l - 290  // glyph scale 290,118%[?12l[?25h[?25l - 291  width: f32, 291,118%[?12l[?25h[?25l - 292  height: f32, 292,118%[?12l[?25h[?25l - 293  // uv offset 293,118%[?12l[?25h[?25l - 294  uv_left: f32, 294,118%[?12l[?25h[?25l - 295  uv_bot: f32, 295,118%[?12l[?25h[?25l - 296  // uv scale 296,118%[?12l[?25h[?25l - 297  uv_width: f32, 297,118%[?12l[?25h[?25l - 298  uv_height: f32, 298,118%[?12l[?25h[?25l - 299  // color 299,118%[?12l[?25h[?25l - 300  r: f32, 300,118%[?12l[?25h[?25l - 301  g: f32, 301,118%[?12l[?25h[?25l - 302  b: f32, 302,118%[?12l[?25h[?25l - 303  // background color 303,119%[?12l[?25h[?25l - 304  bg_r: f32, 304,119%[?12l[?25h[?25l - 305  bg_g: f32, 305,119%[?12l[?25h[?25l - 306  bg_b: f32, 306,119%[?12l[?25h[?25l -{ 307 } 307,119%[?12l[?25h[?25l -{ } - 308  308,0-119%[?12l[?25h[?25l - 309 #[derive(Debug)] 309,119%[?12l[?25h[?25l - 310 pub struct QuadRenderer { 310,119%[?12l[?25h[?25l - 311  program: ShaderProgram, 311,119%[?12l[?25h[?25l - 312  vao: GLuint, 312,119%[?12l[?25h[?25l - 313  vbo: GLuint, 313,119%[?12l[?25h[?25l - 314  ebo: GLuint, 314,119%[?12l[?25h[?25l - 315  vbo_instance: GLuint, 315,119%[?12l[?25h[?25l - 316  atlas: Vec<Atlas>, 316,120%[?12l[?25h[?25l - 317  active_tex: GLuint, 317,120%[?12l[?25h[?25l - 318  batch: Batch, 318,120%[?12l[?25h[?25l - 319  rx: mpsc::Receiver<Msg>, 319,120%[?12l[?25h[?25l -{ 320 } 320,120%[?12l[?25h[?25l -{ } - 321  321,0-120%[?12l[?25h[?25l - 322 #[derive(Debug)] 322,120%[?12l[?25h[?25l - 323 pub struct RenderApi<'a> { 323,120%[?12l[?25h[?25l - 324  active_tex: &'a mut GLuint, 324,120%[?12l[?25h[?25l - 325  batch: &'a mut Batch, 325,120%[?12l[?25h[?25l - 326  atlas: &'a mut Vec<Atlas>, 326,120%[?12l[?25h[?25l - 327  program: &'a mut ShaderProgram, 327,120%[?12l[?25h[?25l - 328  config: &'a Config, 328,120%[?12l[?25h[?25l - 329  visual_bell_intensity: f32 329,121%[?12l[?25h[?25l -{ 330 } 330,121%[?12l[?25h[?25l -{ } - 331  331,0-121%[?12l[?25h[?25l - 332 #[derive(Debug)] 332,121%[?12l[?25h[?25l - 333 pub struct LoaderApi<'a> { 333,121%[?12l[?25h[?25l - 334  active_tex: &'a mut GLuint, 334,121%[?12l[?25h[?25l - 335  atlas: &'a mut Vec<Atlas>, 335,121%[?12l[?25h[?25l -{ - - - 336 } 336,121%[?12l[?25h[?25l -{ } - 337  337,0-121%[?12l[?25h[?25l - 338 #[derive(Debug)] 338,121%[?12l[?25h[?25l - 339 pub struct PackedVertex { 339,121%[?12l[?25h[?25l - 340  x: f32, 340,121%[?12l[?25h[?25l - 341  y: f32, 341,121%[?12l[?25h[?25l -{ - - - 342 } 342,122%[?12l[?25h[?25l -{ } - 343  343,0-122%[?12l[?25h[?25l - 344 #[derive(Debug)] 344,122%[?12l[?25h[?25l - 345 pub struct Batch { 345,122%[?12l[?25h[?25l - 346  tex: GLuint, 346,122%[?12l[?25h[?25l - 347  instances: Vec<InstanceData>, 347,122%[?12l[?25h[?25l 348 }  - 349   - 350 impl Batch {  - 351  #[inline]  - 352  pub fn new() -> Batch {  - 353 Batch {  - 354 tex: 0,  - 355 instances: Vec::with_capacity(BATCH_MAX),  - 356 }  - 357  }  - 358   - 359  pub fn add_item(  - 360 &mut self,  - 361 cell: &RenderableCell,  - 362 glyph: &Glyph,  - 363  ) {  - 364 if self.is_empty() {  - 365 self.tex = glyph.tex_id;  - 366 }  - 367   - 368 self.instances.push(InstanceData {  - 369 col: cell.column.0 as f32,  - 370 row: cell.line.0 as f32,  - 371   - 372 top: glyph.top,  - 373 left: glyph.left,  - 374 width: glyph.width,  - 375 height: glyph.height, 375,1324%[?12l[?25h[?25l 376   - 377 uv_bot: glyph.uv_bot,  - 378 uv_left: glyph.uv_left,  - 379 uv_width: glyph.uv_width,  - 380 uv_height: glyph.uv_height,  - 381   - 382 r: cell.fg.r as f32,  - 383 g: cell.fg.g as f32,  - 384 b: cell.fg.b as f32,  - 385   - 386 bg_r: cell.bg.r as f32,  - 387 bg_g: cell.bg.g as f32,  - 388 bg_b: cell.bg.b as f32,  - 389 });  - 390  }  - 391   - 392  #[inline]  - 393  pub fn full(&self) -> bool {  - 394 self.capacity() == self.len()  - 395  }  - 396   - 397  #[inline]  - 398  pub fn len(&self) -> usize {  - 399 self.instances.len()  - 400  }  - 401   - 402  #[inline]  - 403  pub fn capacity(&self) -> usize { 403,526%[?12l[?25h[?25l 404 BATCH_MAX  - 405  }  - 406   - 407  #[inline]  - 408  pub fn is_empty(&self) -> bool {  - 409 self.len() == 0  - 410  }  - 411   - 412  #[inline]  - 413  pub fn size(&self) -> usize {  - 414 self.len() * size_of::<InstanceData>()  - 415  }  - 416   - 417  pub fn clear(&mut self) {  - 418 self.tex = 0;  - 419 self.instances.clear();  - 420  }  - 421 }  - 422   - 423 /// Maximum items to be drawn in a batch.  - 424 const BATCH_MAX: usize = 65_536;  - 425 const ATLAS_SIZE: i32 = 1024;  - 426   - 427 impl QuadRenderer {  - 428  // TODO should probably hand this a transform instead of width/height  - 429  pub fn new(config: &Config, size: Size<Pixels<u32>>) -> Result<QuadRenderer, Error> {  - 430 let program = ShaderProgram::new(config, size)?;  - 431  431,0-128%[?12l[?25h[?25l 432 let mut vao: GLuint = 0;  - 433 let mut vbo: GLuint = 0;  - 434 let mut ebo: GLuint = 0;  - 435   - 436 let mut vbo_instance: GLuint = 0;  - 437   - 438 unsafe {  - 439 gl::Enable(gl::BLEND);  - 440 gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR);  - 441 gl::Enable(gl::MULTISAMPLE);  - 442   - 443 gl::GenVertexArrays(1, &mut vao);  - 444 gl::GenBuffers(1, &mut vbo);  - 445 gl::GenBuffers(1, &mut ebo);  - 446 gl::GenBuffers(1, &mut vbo_instance);  - 447 gl::BindVertexArray(vao);  - 448   - 449 // ----------------------------  - 450 // setup vertex position buffer  - 451 // ----------------------------  - 452 // Top right, Bottom right, Bottom left, Top left  - 453 let vertices = [  - 454 PackedVertex { x: 1.0, y: 1.0 },  - 455 PackedVertex { x: 1.0, y: 0.0 },  - 456 PackedVertex { x: 0.0, y: 0.0 },  - 457 PackedVertex { x: 0.0, y: 1.0 },  - 458 ];  - 459  459,0-131%[?12l[?25h[?25l 460 gl::BindBuffer(gl::ARRAY_BUFFER, vbo);  - 461   - 462 gl::VertexAttribPointer(0, 2,  - 463 gl::FLOAT, gl::FALSE,  - 464 size_of::<PackedVertex>() as i32,  - 465 ptr::null());  - 466 gl::EnableVertexAttribArray(0);  - 467   - 468 gl::BufferData(gl::ARRAY_BUFFER,  - 469 (size_of::<PackedVertex>() * vertices.len()) as GLsizeiptr,  - 470 vertices.as_ptr() as *const _,  - 471 gl::STATIC_DRAW);  - 472   - 473 // ---------------------  - 474 // Set up element buffer  - 475 // ---------------------  - 476 let indices: [u32; 6] = [0, 1, 3,  - 477 1, 2, 3];  - 478   - 479 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo);  - 480 gl::BufferData(gl::ELEMENT_ARRAY_BUFFER,  - 481 (6 * size_of::<u32>()) as isize,  - 482 indices.as_ptr() as *const _,  - 483 gl::STATIC_DRAW);  - 484   - 485 // ----------------------------  - 486 // Setup vertex instance buffer  - 487 // ---------------------------- 487,1333%[?12l[?25h[?25l 488 gl::BindBuffer(gl::ARRAY_BUFFER, vbo_instance);  - 489 gl::BufferData(gl::ARRAY_BUFFER,  - 490 (BATCH_MAX * size_of::<InstanceData>()) as isize,  - 491 ptr::null(), gl::STREAM_DRAW);  - 492 // coords  - 493 gl::VertexAttribPointer(1, 2,  - 494 gl::FLOAT, gl::FALSE,  - 495 size_of::<InstanceData>() as i32,  - 496 ptr::null());  - 497 gl::EnableVertexAttribArray(1);  - 498 gl::VertexAttribDivisor(1, 1);  - 499 // glyphoffset  - 500 gl::VertexAttribPointer(2, 4,  - 501 gl::FLOAT, gl::FALSE,  - 502 size_of::<InstanceData>() as i32,  - 503 (2 * size_of::<f32>()) as *const _);  - 504 gl::EnableVertexAttribArray(2);  - 505 gl::VertexAttribDivisor(2, 1);  - 506 // uv  - 507 gl::VertexAttribPointer(3, 4,  - 508 gl::FLOAT, gl::FALSE,  - 509 size_of::<InstanceData>() as i32,  - 510 (6 * size_of::<f32>()) as *const _);  - 511 gl::EnableVertexAttribArray(3);  - 512 gl::VertexAttribDivisor(3, 1);  - 513 // color  - 514 gl::VertexAttribPointer(4, 3,  - 515 gl::FLOAT, gl::FALSE, 515,3735%[?12l[?25h[?25l 516 size_of::<InstanceData>() as i32,  - 517 (10 * size_of::<f32>()) as *const _);  - 518 gl::EnableVertexAttribArray(4);  - 519 gl::VertexAttribDivisor(4, 1);  - 520 // color  - 521 gl::VertexAttribPointer(5, 3,  - 522 gl::FLOAT, gl::FALSE,  - 523 size_of::<InstanceData>() as i32,  - 524 (13 * size_of::<f32>()) as *const _);  - 525 gl::EnableVertexAttribArray(5);  - 526 gl::VertexAttribDivisor(5, 1);  - 527   - 528 gl::BindVertexArray(0);  - 529 gl::BindBuffer(gl::ARRAY_BUFFER, 0);  - 530 }  - 531   - 532 let (msg_tx, msg_rx) = mpsc::channel();  - 533   - 534 if cfg!(feature = "live-shader-reload") {  - 535 ::std::thread::spawn(move || {  - 536 let (tx, rx) = ::std::sync::mpsc::channel();  - 537 let mut watcher = Watcher::new(tx).expect("create file watcher");  - 538 watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader");  - 539 watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader");  - 540   - 541 loop {  - 542 let event = rx.recv().expect("watcher event");  - 543 let ::notify::Event { path, op } = event; 543,2137%[?12l[?25h[?25l 544   - 545 if let Ok(op) = op {  - 546 if op.contains(op::RENAME) {  - 547 continue;  - 548 }  - 549   - 550 if op.contains(op::IGNORED) {  - 551 if let Some(path) = path.as_ref() {  - 552 if let Err(err) = watcher.watch(path) {  - 553 warn!("failed to establish watch on {:?}: {:?}", path, err);   - 554 }  - 555 }  - 556   - 557 msg_tx.send(Msg::ShaderReload)  - 558 .expect("msg send ok");  - 559 }  - 560 }  - 561 }  - 562 });  - 563 }  - 564   - 565 let mut renderer = QuadRenderer {  - 566 program: program,  - 567 vao: vao,  - 568 vbo: vbo,  - 569 ebo: ebo,  - 570 vbo_instance: vbo_instance,  - 571 atlas: Vec::new(), 571,1339%[?12l[?25h[?25l 572 active_tex: 0,  - 573 batch: Batch::new(),  - 574 rx: msg_rx,  - 575 };  - 576   - 577 let atlas = Atlas::new(ATLAS_SIZE);  - 578 renderer.atlas.push(atlas);  - 579   - 580 Ok(renderer)  - 581  }  - 582   - 583  pub fn with_api<F, T>(  - 584 &mut self,  - 585 config: &Config,  - 586 props: &term::SizeInfo,  - 587 visual_bell_intensity: f64,  - 588 func: F  - 589  ) -> T  - 590 where F: FnOnce(RenderApi) -> T  - 591  {  - 592 while let Ok(msg) = self.rx.try_recv() {  - 593 match msg {  - 594 Msg::ShaderReload => {  - 595 self.reload_shaders(&config, Size {  - 596 width: Pixels(props.width as u32),  - 597 height: Pixels(props.height as u32)  - 598 });  - 599 } 599,1741%[?12l[?25h[?25l{ } - 600 }  - 601 }  - 602   - 603 unsafe {  - 604 self.program.activate();  - 605 self.program.set_term_uniforms(props);  - 606 self.program.set_visual_bell(visual_bell_intensity as _);  - 607   - 608 gl::BindVertexArray(self.vao);  - 609 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo);  - 610 gl::BindBuffer(gl::ARRAY_BUFFER, self.vbo_instance);  - 611 gl::ActiveTexture(gl::TEXTURE0);  - 612 }  - 613   - 614 let res = func(RenderApi {  - 615 active_tex: &mut self.active_tex,  - 616 batch: &mut self.batch,  - 617 atlas: &mut self.atlas,  - 618 program: &mut self.program,  - 619 visual_bell_intensity: visual_bell_intensity as _,  - 620 config: config,  - 621 });  - 622   - 623 unsafe {  - 624 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, 0);  - 625 gl::BindBuffer(gl::ARRAY_BUFFER, 0);  - 626 gl::BindVertexArray(0);  - 627  627,0-143%[?12l[?25h[?25l 628 self.program.deactivate();  - 629 }  - 630   - 631 res  - 632  }  - 633   - 634  pub fn with_loader<F, T>(&mut self, func: F) -> T  - 635 where F: FnOnce(LoaderApi) -> T  - 636  {  - 637 unsafe {  - 638 gl::ActiveTexture(gl::TEXTURE0);  - 639 }  - 640   - 641 func(LoaderApi {  - 642 active_tex: &mut self.active_tex,  - 643 atlas: &mut self.atlas,  - 644 })  - 645  }  - 646   - 647  pub fn reload_shaders(&mut self, config: &Config, size: Size<Pixels<u32>>) {  - 648 info!("Reloading shaders");  - 649 let program = match ShaderProgram::new(config, size) {  - 650 Ok(program) => program,  - 651 Err(err) => {  - 652 match err {  - 653 ShaderCreationError::Io(err) => {  - 654 error!("Error reading shader file: {}", err);  - 655 }, 655,2146%[?12l[?25h[?25l 572 active_tex: 0,  - 573 batch: Batch::new(),  - 574 rx: msg_rx,  - 575 };  - 576   - 577 let atlas = Atlas::new(ATLAS_SIZE);  - 578 renderer.atlas.push(atlas);  - 579   - 580 Ok(renderer)  - 581  }  - 582   - 583  pub fn with_api<F, T>(  - 584 &mut self,  - 585 config: &Config,  - 586 props: &term::SizeInfo,  - 587 visual_bell_intensity: f64,  - 588 func: F  - 589  ) -> T  - 590 where F: FnOnce(RenderApi) -> T  - 591  {  - 592 while let Ok(msg) = self.rx.try_recv() {  - 593 match msg {  - 594 Msg::ShaderReload => {  - 595 self.reload_shaders(&config, Size {  - 596 width: Pixels(props.width as u32),  - 597 height: Pixels(props.height as u32)  - 598 });  - 599 } 627,0-143%[?12l[?25h[?25l 544   - 545 if let Ok(op) = op {  - 546 if op.contains(op::RENAME) {  - 547 continue;  - 548 }  - 549   - 550 if op.contains(op::IGNORED) {  - 551 if let Some(path) = path.as_ref() {  - 552 if let Err(err) = watcher.watch(path) {  - 553 warn!("failed to establish watch on {:?}: {:?}", path, err);   - 554 }  - 555 }  - 556   - 557 msg_tx.send(Msg::ShaderReload)  - 558 .expect("msg send ok");  - 559 }  - 560 }  - 561 }  - 562 });  - 563 }  - 564   - 565 let mut renderer = QuadRenderer {  - 566 program: program,  - 567 vao: vao,  - 568 vbo: vbo,  - 569 ebo: ebo,  - 570 vbo_instance: vbo_instance,  - 571 atlas: Vec::new(), {}599,1741%[?12l[?25h[?25l 516 size_of::<InstanceData>() as i32,  - 517 (10 * size_of::<f32>()) as *const _);  - 518 gl::EnableVertexAttribArray(4);  - 519 gl::VertexAttribDivisor(4, 1);  - 520 // color  - 521 gl::VertexAttribPointer(5, 3,  - 522 gl::FLOAT, gl::FALSE,  - 523 size_of::<InstanceData>() as i32,  - 524 (13 * size_of::<f32>()) as *const _);  - 525 gl::EnableVertexAttribArray(5);  - 526 gl::VertexAttribDivisor(5, 1);  - 527   - 528 gl::BindVertexArray(0);  - 529 gl::BindBuffer(gl::ARRAY_BUFFER, 0);  - 530 }  - 531   - 532 let (msg_tx, msg_rx) = mpsc::channel();  - 533   - 534 if cfg!(feature = "live-shader-reload") {  - 535 ::std::thread::spawn(move || {  - 536 let (tx, rx) = ::std::sync::mpsc::channel();  - 537 let mut watcher = Watcher::new(tx).expect("create file watcher");  - 538 watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader");  - 539 watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader");  - 540   - 541 loop {  - 542 let event = rx.recv().expect("watcher event");  - 543 let ::notify::Event { path, op } = event; 571,1339%[?12l[?25h[?25l 488 gl::BindBuffer(gl::ARRAY_BUFFER, vbo_instance);  - 489 gl::BufferData(gl::ARRAY_BUFFER,  - 490 (BATCH_MAX * size_of::<InstanceData>()) as isize,  - 491 ptr::null(), gl::STREAM_DRAW);  - 492 // coords  - 493 gl::VertexAttribPointer(1, 2,  - 494 gl::FLOAT, gl::FALSE,  - 495 size_of::<InstanceData>() as i32,  - 496 ptr::null());  - 497 gl::EnableVertexAttribArray(1);  - 498 gl::VertexAttribDivisor(1, 1);  - 499 // glyphoffset  - 500 gl::VertexAttribPointer(2, 4,  - 501 gl::FLOAT, gl::FALSE,  - 502 size_of::<InstanceData>() as i32,  - 503 (2 * size_of::<f32>()) as *const _);  - 504 gl::EnableVertexAttribArray(2);  - 505 gl::VertexAttribDivisor(2, 1);  - 506 // uv  - 507 gl::VertexAttribPointer(3, 4,  - 508 gl::FLOAT, gl::FALSE,  - 509 size_of::<InstanceData>() as i32,  - 510 (6 * size_of::<f32>()) as *const _);  - 511 gl::EnableVertexAttribArray(3);  - 512 gl::VertexAttribDivisor(3, 1);  - 513 // color  - 514 gl::VertexAttribPointer(4, 3,  - 515 gl::FLOAT, gl::FALSE, 543,2137%[?12l[?25h[?25l 460 gl::BindBuffer(gl::ARRAY_BUFFER, vbo);  - 461   - 462 gl::VertexAttribPointer(0, 2,  - 463 gl::FLOAT, gl::FALSE,  - 464 size_of::<PackedVertex>() as i32,  - 465 ptr::null());  - 466 gl::EnableVertexAttribArray(0);  - 467   - 468 gl::BufferData(gl::ARRAY_BUFFER,  - 469 (size_of::<PackedVertex>() * vertices.len()) as GLsizeiptr,  - 470 vertices.as_ptr() as *const _,  - 471 gl::STATIC_DRAW);  - 472   - 473 // ---------------------  - 474 // Set up element buffer  - 475 // ---------------------  - 476 let indices: [u32; 6] = [0, 1, 3,  - 477 1, 2, 3];  - 478   - 479 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo);  - 480 gl::BufferData(gl::ELEMENT_ARRAY_BUFFER,  - 481 (6 * size_of::<u32>()) as isize,  - 482 indices.as_ptr() as *const _,  - 483 gl::STATIC_DRAW);  - 484   - 485 // ----------------------------  - 486 // Setup vertex instance buffer  - 487 // ---------------------------- 515,3735%[?12l[?25h[?25l 432 let mut vao: GLuint = 0;  - 433 let mut vbo: GLuint = 0;  - 434 let mut ebo: GLuint = 0;  - 435   - 436 let mut vbo_instance: GLuint = 0;  - 437   - 438 unsafe {  - 439 gl::Enable(gl::BLEND);  - 440 gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR);  - 441 gl::Enable(gl::MULTISAMPLE);  - 442   - 443 gl::GenVertexArrays(1, &mut vao);  - 444 gl::GenBuffers(1, &mut vbo);  - 445 gl::GenBuffers(1, &mut ebo);  - 446 gl::GenBuffers(1, &mut vbo_instance);  - 447 gl::BindVertexArray(vao);  - 448   - 449 // ----------------------------  - 450 // setup vertex position buffer  - 451 // ----------------------------  - 452 // Top right, Bottom right, Bottom left, Top left  - 453 let vertices = [  - 454 PackedVertex { x: 1.0, y: 1.0 },  - 455 PackedVertex { x: 1.0, y: 0.0 },  - 456 PackedVertex { x: 0.0, y: 0.0 },  - 457 PackedVertex { x: 0.0, y: 1.0 },  - 458 ];  - 459  487,1333%[?12l[?25h[?25l 404 BATCH_MAX  - 405  }  - 406   - 407  #[inline]  - 408  pub fn is_empty(&self) -> bool {  - 409 self.len() == 0  - 410  }  - 411   - 412  #[inline]  - 413  pub fn size(&self) -> usize {  - 414 self.len() * size_of::<InstanceData>()  - 415  }  - 416   - 417  pub fn clear(&mut self) {  - 418 self.tex = 0;  - 419 self.instances.clear();  - 420  }  - 421 }  - 422   - 423 /// Maximum items to be drawn in a batch.  - 424 const BATCH_MAX: usize = 65_536;  - 425 const ATLAS_SIZE: i32 = 1024;  - 426   - 427 impl QuadRenderer {  - 428  // TODO should probably hand this a transform instead of width/height  - 429  pub fn new(config: &Config, size: Size<Pixels<u32>>) -> Result<QuadRenderer, Error> {  - 430 let program = ShaderProgram::new(config, size)?;  - 431  459,0-131%[?12l[?25h[?25l 376   - 377 uv_bot: glyph.uv_bot,  - 378 uv_left: glyph.uv_left,  - 379 uv_width: glyph.uv_width,  - 380 uv_height: glyph.uv_height,  - 381   - 382 r: cell.fg.r as f32,  - 383 g: cell.fg.g as f32,  - 384 b: cell.fg.b as f32,  - 385   - 386 bg_r: cell.bg.r as f32,  - 387 bg_g: cell.bg.g as f32,  - 388 bg_b: cell.bg.b as f32,  - 389 });  - 390  }  - 391   - 392  #[inline]  - 393  pub fn full(&self) -> bool {  - 394 self.capacity() == self.len()  - 395  }  - 396   - 397  #[inline]  - 398  pub fn len(&self) -> usize {  - 399 self.instances.len()  - 400  }  - 401   - 402  #[inline]  - 403  pub fn capacity(&self) -> usize { 431,0-128%[?12l[?25h[?25l 348 }  - 349   - 350 impl Batch {  - 351  #[inline]  - 352  pub fn new() -> Batch {  - 353 Batch {  - 354 tex: 0,  - 355 instances: Vec::with_capacity(BATCH_MAX),  - 356 }  - 357  }  - 358   - 359  pub fn add_item(  - 360 &mut self,  - 361 cell: &RenderableCell,  - 362 glyph: &Glyph,  - 363  ) {  - 364 if self.is_empty() {  - 365 self.tex = glyph.tex_id;  - 366 }  - 367   - 368 self.instances.push(InstanceData {  - 369 col: cell.column.0 as f32,  - 370 row: cell.line.0 as f32,  - 371   - 372 top: glyph.top,  - 373 left: glyph.left,  - 374 width: glyph.width,  - 375 height: glyph.height, 403,526%[?12l[?25h[?25l 320 }  - 321   - 322 #[derive(Debug)]  - 323 pub struct RenderApi<'a> {  - 324  active_tex: &'a mut GLuint,  - 325  batch: &'a mut Batch,  - 326  atlas: &'a mut Vec<Atlas>,  - 327  program: &'a mut ShaderProgram,  - 328  config: &'a Config,  - 329  visual_bell_intensity: f32  - 330 }  - 331   - 332 #[derive(Debug)]  - 333 pub struct LoaderApi<'a> {  - 334  active_tex: &'a mut GLuint,  - 335  atlas: &'a mut Vec<Atlas>,  - 336 }  - 337   - 338 #[derive(Debug)]  - 339 pub struct PackedVertex {  - 340  x: f32,  - 341  y: f32,  - 342 }  - 343   - 344 #[derive(Debug)]  - 345 pub struct Batch {  - 346  tex: GLuint,  - 347  instances: Vec<InstanceData>, 375,1324%[?12l[?25h[?25l 292  height: f32,  - 293  // uv offset  - 294  uv_left: f32,  - 295  uv_bot: f32,  - 296  // uv scale  - 297  uv_width: f32,  - 298  uv_height: f32,  - 299  // color  - 300  r: f32,  - 301  g: f32,  - 302  b: f32,  - 303  // background color  - 304  bg_r: f32,  - 305  bg_g: f32,  - 306  bg_b: f32,  - 307 }  - 308   - 309 #[derive(Debug)]  - 310 pub struct QuadRenderer {  - 311  program: ShaderProgram,  - 312  vao: GLuint,  - 313  vbo: GLuint,  - 314  ebo: GLuint,  - 315  vbo_instance: GLuint,  - 316  atlas: Vec<Atlas>,  - 317  active_tex: GLuint,  - 318  batch: Batch,  - 319  rx: mpsc::Receiver<Msg>, 347,522%[?12l[?25h[?25l 264 let rasterizer = &mut self.rasterizer;  - 265 let metrics = &self.metrics;  - 266 self.cache  - 267 .entry(*glyph_key)  - 268 .or_insert_with(|| {  - 269 let mut rasterized = rasterizer.get_glyph(&glyph_key)  - 270 .unwrap_or_else(|_| Default::default());  - 271   - 272 rasterized.left += glyph_offset.x as i32;  - 273 rasterized.top += glyph_offset.y as i32;  - 274 rasterized.top -= metrics.descent as i32;  - 275   - 276 loader.load_glyph(&rasterized)  - 277 })  - 278  }  - 279 }  - 280   - 281 #[derive(Debug)]  - 282 #[repr(C)]  - 283 struct InstanceData {  - 284  // coords  - 285  col: f32,  - 286  row: f32,  - 287  // glyph offset  - 288  left: f32,  - 289  top: f32,  - 290  // glyph scale  - 291  width: f32, 319,520%[?12l[?25h[?25l 236 ($font:expr) => {  - 237 for i in RangeInclusive::new(32u8, 128u8) {  - 238 cache.get(&GlyphKey {  - 239 font_key: $font,  - 240 c: i as char,  - 241 size: font.size()  - 242 }, loader);  - 243 }  - 244 }  - 245 }  - 246   - 247 load_glyphs_for_font!(regular);  - 248 load_glyphs_for_font!(bold);  - 249 load_glyphs_for_font!(italic);  - 250   - 251 Ok(cache)  - 252  }  - 253   - 254  pub fn font_metrics(&self) -> font::Metrics {  - 255 self.rasterizer  - 256 .metrics(self.font_key)  - 257 .expect("metrics load since font is loaded at glyph cache creation")  - 258  }  - 259   - 260  pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph  - 261 where L: LoadGlyph  - 262  {  - 263 let glyph_offset = self.glyph_offset; 291,518%[?12l[?25h[?25l 208 // Load bold font  - 209 let bold_desc = make_desc(&font.bold, font::Slant::Normal, font::Weight::Bold);  - 210   - 211 let bold = load_or_regular(bold_desc, &mut rasterizer);  - 212   - 213 // Load italic font  - 214 let italic_desc = make_desc(&font.italic, font::Slant::Italic, font::Weight::Normal);  - 215   - 216 let italic = load_or_regular(italic_desc, &mut rasterizer);  - 217   - 218 // Need to load at least one glyph for the face before calling metrics.  - 219 // The glyph requested here ('m' at the time of writing) has no special  - 220 // meaning.  - 221 rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?;  - 222 let metrics = rasterizer.metrics(regular)?;  - 223   - 224 let mut cache = GlyphCache {  - 225 cache: HashMap::default(),  - 226 rasterizer: rasterizer,  - 227 font_size: font.size(),  - 228 font_key: regular,  - 229 bold_key: bold,  - 230 italic_key: italic,  - 231 glyph_offset: glyph_offset,  - 232 metrics: metrics  - 233 };  - 234   - 235 macro_rules! load_glyphs_for_font { 263,915%[?12l[?25h[?25l 180 desc: &config::FontDescription,  - 181 slant: font::Slant,  - 182 weight: font::Weight,  - 183 ) -> FontDesc  - 184 {  - 185 let style = if let Some(ref spec) = desc.style {  - 186 font::Style::Specific(spec.to_owned())  - 187 } else {  - 188 font::Style::Description {slant:slant, weight:weight}  - 189 };  - 190 FontDesc::new(&desc.family[..], style)  - 191 }  - 192   - 193 // Load regular font  - 194 let regular_desc = make_desc(&font.normal, font::Slant::Normal, font::Weight::Normal);   - 195   - 196 let regular = rasterizer  - 197 .load_font(®ular_desc, size)?;  - 198   - 199 // helper to load a description if it is not the regular_desc  - 200 let load_or_regular = |desc:FontDesc, rasterizer: &mut Rasterizer| {  - 201 if desc == regular_desc {  - 202 regular  - 203 } else {  - 204 rasterizer.load_font(&desc, size).unwrap_or_else(|_| regular)  - 205 }  - 206 };  - 207  235,913%[?12l[?25h[?25l 152  /// italic font  - 153  italic_key: FontKey,  - 154   - 155  /// bold font  - 156  bold_key: FontKey,  - 157   - 158  /// font size  - 159  font_size: font::Size,  - 160   - 161  /// glyph offset  - 162  glyph_offset: Delta,  - 163   - 164  metrics: ::font::Metrics,  - 165 }  - 166   - 167 impl GlyphCache {  - 168  pub fn new<L>(  - 169 mut rasterizer: Rasterizer,  - 170 config: &Config,  - 171 loader: &mut L  - 172  ) -> Result<GlyphCache, font::Error>  - 173 where L: LoadGlyph  - 174  {  - 175 let font = config.font();  - 176 let size = font.size();  - 177 let glyph_offset = *font.glyph_offset();  - 178   - 179 fn make_desc( 207,0-111%[?12l[?25h[?25l 124   - 125 #[derive(Debug, Clone)]  - 126 pub struct Glyph {  - 127  tex_id: GLuint,  - 128  top: f32,  - 129  left: f32,  - 130  width: f32,  - 131  height: f32,  - 132  uv_bot: f32,  - 133  uv_left: f32,  - 134  uv_width: f32,  - 135  uv_height: f32,  - 136 }  - 137   - 138 /// NaΓ―ve glyph cache  - 139 ///  - 140 /// Currently only keyed by `char`, and thus not possible to hold different  - 141 /// representations of the same code point.  - 142 pub struct GlyphCache {  - 143  /// Cache of buffered glyphs  - 144  cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>,  - 145   - 146  /// Rasterizer for loading new glyphs  - 147  rasterizer: Rasterizer,  - 148   - 149  /// regular font  - 150  font_key: FontKey,  - 151  179,99%[?12l[?25h[?25l 96 ///  - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a".  - 98 #[derive(Debug)]  - 99 pub struct ShaderProgram {  - 100  // Program id  - 101  id: GLuint,  - 102   - 103  /// projection matrix uniform  - 104  u_projection: GLint,  - 105   - 106  /// Terminal dimensions (pixels)  - 107  u_term_dim: GLint,  - 108   - 109  /// Cell dimensions (pixels)  - 110  u_cell_dim: GLint,  - 111   - 112  /// Visual bell  - 113  u_visual_bell: GLint,  - 114   - 115  /// Background pass flag  - 116  ///  - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text  - 118  u_background: GLint,  - 119   - 120  padding_x: f32,  - 121  padding_y: f32,  - 122 }  - 123  151,0-17%[?12l[?25h[?25l:[?12l[?25hq[?25l[?12l[?25h[?25l[?12l[?25h [?25l151,0-17%[?12l[?25h diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_large_window_scroll b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_large_window_scroll deleted file mode 100644 index 2da4636fb1..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_large_window_scroll +++ /dev/null @@ -1,977 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004hvvivim ssrrcc//rreennderer//mmood.rs  [?1l>[?2004l -[?1049h[?1h=β–½ [?12;25h[?12l[?25h[?25l"src/renderer/mod.rs" 1354L, 40527C[>c 78 impl ::std::fmt::Display for Error {  - 79  fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {  - 80 match *self {  - 81 Error::ShaderCreation(ref err) => {  - 82 write!(f, "There was an error initializing the shaders: {}", err)  - 83 }  - 84 }  - 85  }  - 86 }  - 87   - 88 impl From<ShaderCreationError> for Error {  - 89  fn from(val: ShaderCreationError) -> Error {  - 90 Error::ShaderCreation(val)  - 91  }  - 92 }  - 93   - 94   - 95 /// Text drawing program  - 96 ///  - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a".  - 98 #[derive(Debug)]  - 99 pub struct ShaderProgram {  - 100  // Program id  - 101  id: GLuint,  - 102   - 103  /// projection matrix uniform  - 104  u_projection: GLint,  - 105   - 106  /// Terminal dimensions (pixels)  - 107  u_term_dim: GLint,  - 108   - 109  /// Cell dimensions (pixels)  - 110  u_cell_dim: GLint,  - 111   - 112  /// Visual bell  - 113  u_visual_bell: GLint,  - 114   - 115  /// Background pass flag  - 116  ///  - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text  - 118  u_background: GLint,  - 119   - 120  padding_x: f32,  - 121  padding_y: f32,  - 122 }  - 123   - 124   - 125 #[derive(Debug, Clone)]  - 126 pub struct Glyph {  - 127  tex_id: GLuint,  - 128  top: f32,  - 129  left: f32,  - 130  width: f32,  - 131  height: f32,  - 132  uv_bot: f32,  - 133  uv_left: f32, 105,0-15%[?12l[?25h[?25l 1 // Copyright 2016 Joe Wilm, The Alacritty Project Contributors  - 2 //  - 3 // Licensed under the Apache License, Version 2.0 (the "License");  - 4 // you may not use this file except in compliance with the License.  - 5 // You may obtain a copy of the License at  - 6 //  - 7 // http://www.apache.org/licenses/LICENSE-2.0  - 8 //  - 9 // Unless required by applicable law or agreed to in writing, software  - 10 // distributed under the License is distributed on an "AS IS" BASIS,  - 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  - 12 // See the License for the specific language governing permissions and  - 13 // limitations under the License.  - 14 use std::collections::HashMap;  - 15 use std::hash::BuildHasherDefault;  - 16 use std::fs::File;  - 17 use std::io::{self, Read};  - 18 use std::mem::size_of;  - 19 use std::path::{PathBuf};  - 20 use std::ptr;  - 21 use std::sync::mpsc;  - 22   - 23 use cgmath;  - 24 use fnv::FnvHasher;  - 25 use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, FontKey};  - 26 use gl::types::*;  - 27 use gl;  - 28 use index::{Line, Column, RangeInclusive};  - 29 use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};  - 30   - 31 use config::{self, Config, Delta};  - 32 use term::{self, cell, RenderableCell};  - 33 use window::{Size, Pixels};  - 34   - 35 use Rgb;  - 36   - 37 // Shader paths for live reload  - 38 static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");   - 39 static TEXT_SHADER_V_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl");   - 40   - 41 // Shader source which is used when live-shader-reload feature is disable  - 42 static TEXT_SHADER_F: &'static str = include_str!(  - 43  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl")  - 44 );  - 45 static TEXT_SHADER_V: &'static str = include_str!(  - 46  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl")  - 47 );  - 48   - 49 /// `LoadGlyph` allows for copying a rasterized glyph into graphics memory  - 50 pub trait LoadGlyph {  - 51  /// Load the rasterized glyph into GPU memory  - 52  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph;  - 53 }  - 54   - 55 enum Msg {  - 56  ShaderReload, 1,1Top[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l10,1[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l20[?12l[?25h[?25l1[?12l[?25h[?25l2,0-1[?12l[?25h[?25l3,1 [?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l30,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6,0-1[?12l[?25h[?25l7,1 [?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l40,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l()4[?12l[?25h[?25l()5[?12l[?25h[?25l6[?12l[?25h[?25l()7[?12l[?25h[?25l()8,0-1[?12l[?25h[?25l9,1 [?12l[?25h[?25l50[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l{}3[?12l[?25h[?25l{}4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6[?12l[?25h[?25l -{ - - 57 } 57,10%[?12l[?25h[?25l -{} - 58  58,0-10%[?12l[?25h[?25l - 59 #[derive(Debug)] 59,10%[?12l[?25h[?25l - 60 pub enum Error { 60,10%[?12l[?25h[?25l - 61  ShaderCreation(ShaderCreationError), 61,10%[?12l[?25h[?25l -{ - - 62 } 62,10%[?12l[?25h[?25l -{} - 63  63,0-10%[?12l[?25h[?25l - 64 impl ::std::error::Error for Error { 64,10%[?12l[?25h[?25l - 65  fn cause(&self) -> Option<&::std::error::Error> { 65,10%[?12l[?25h[?25l - 66 match *self { 66,10%[?12l[?25h[?25l - 67 Error::ShaderCreation(ref err) => Some(err), 67,10%[?12l[?25h[?25l - 68 } 68,10%[?12l[?25h[?25l - 69  } 69,11%[?12l[?25h[?25l - 70  70,0-11%[?12l[?25h[?25l - 71  fn description(&self) -> &str { 71,11%[?12l[?25h[?25l - 72 match *self { 72,11%[?12l[?25h[?25l - 73 Error::ShaderCreation(ref err) => err.description(), 73,11%[?12l[?25h[?25l - 74 } 74,11%[?12l[?25h[?25l - 75  } 75,11%[?12l[?25h[?25l -{ 76 } 76,11%[?12l[?25h[?25l -{} - 77  77,0-11%[?12l[?25h[?25l - 78 impl ::std::fmt::Display for Error { 78,11%[?12l[?25h[?25l - 79  fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 79,11%[?12l[?25h[?25l - 80 match *self { 80,11%[?12l[?25h[?25l - 81 Error::ShaderCreation(ref err) => { 81,11%[?12l[?25h[?25l - 82 write!(f, "There was an error initializing the shaders: {}", err) 82,12%[?12l[?25h[?25l - 83 } 83,12%[?12l[?25h[?25l - 84 } 84,12%[?12l[?25h[?25l - 85  } 85,12%[?12l[?25h[?25l -{ 86 } 86,12%[?12l[?25h[?25l -{} - 87  87,0-12%[?12l[?25h[?25l - 88 impl From<ShaderCreationError> for Error { 88,12%[?12l[?25h[?25l - 89  fn from(val: ShaderCreationError) -> Error { 89,12%[?12l[?25h[?25l - 90 Error::ShaderCreation(val) 90,12%[?12l[?25h[?25l - 91  } 91,12%[?12l[?25h[?25l -{ 92 } 92,12%[?12l[?25h[?25l -{} - 93  93,0-12%[?12l[?25h[?25l - 94  94,0-12%[?12l[?25h[?25l - 95 /// Text drawing program 95,13%[?12l[?25h[?25l - 96 /// 96,13%[?12l[?25h[?25l - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a". 97,13%[?12l[?25h[?25l - 98 #[derive(Debug)] 98,13%[?12l[?25h[?25l - 99 pub struct ShaderProgram { 99,13%[?12l[?25h[?25l - 100  // Program id 100,13%[?12l[?25h[?25l - 101  id: GLuint, 101,13%[?12l[?25h[?25l - 102  102,0-13%[?12l[?25h[?25l - 103  /// projection matrix uniform 103,13%[?12l[?25h[?25l - 104  u_projection: GLint, 104,13%[?12l[?25h[?25l - 105  105,0-13%[?12l[?25h[?25l - 106  /// Terminal dimensions (pixels) 106,13%[?12l[?25h[?25l - 107  u_term_dim: GLint, 107,13%[?12l[?25h[?25l - 108  108,0-14%[?12l[?25h[?25l - 109  /// Cell dimensions (pixels) 109,14%[?12l[?25h[?25l - 110  u_cell_dim: GLint, 110,14%[?12l[?25h[?25l - 111  111,0-14%[?12l[?25h[?25l - 112  /// Visual bell 112,14%[?12l[?25h[?25l - 113  u_visual_bell: GLint, 113,14%[?12l[?25h[?25l - 114  114,0-14%[?12l[?25h[?25l - 115  /// Background pass flag 115,14%[?12l[?25h[?25l - 116  /// 116,14%[?12l[?25h[?25l - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text 117,14%[?12l[?25h[?25l - 118  u_background: GLint, 118,14%[?12l[?25h[?25l - 119  119,0-14%[?12l[?25h[?25l - 120  padding_x: f32, 120,14%[?12l[?25h[?25l - 121  padding_y: f32, 121,15%[?12l[?25h[?25l -{ 122 } 122,15%[?12l[?25h[?25l -{} - 123  123,0-15%[?12l[?25h[?25l - 124  124,0-15%[?12l[?25h[?25l - 125 #[derive(Debug, Clone)] 125,15%[?12l[?25h[?25l - 126 pub struct Glyph { 126,15%[?12l[?25h[?25l - 127  tex_id: GLuint, 127,15%[?12l[?25h[?25l - 128  top: f32, 128,15%[?12l[?25h[?25l - 129  left: f32, 129,15%[?12l[?25h[?25l - 130  width: f32, 130,15%[?12l[?25h[?25l - 131  height: f32, 131,15%[?12l[?25h[?25l - 132  uv_bot: f32, 132,15%[?12l[?25h[?25l - 133  uv_left: f32, 133,15%[?12l[?25h[?25l - 134  uv_width: f32, 134,16%[?12l[?25h[?25l - 135  uv_height: f32, 135,16%[?12l[?25h[?25l -{ 136 } 136,16%[?12l[?25h[?25l -{} - 137  137,0-16%[?12l[?25h[?25l - 138 /// NaΓ―ve glyph cache 138,16%[?12l[?25h[?25l - 139 /// 139,16%[?12l[?25h[?25l - 140 /// Currently only keyed by `char`, and thus not possible to hold different 140,16%[?12l[?25h[?25l - 141 /// representations of the same code point. 141,16%[?12l[?25h[?25l - 142 pub struct GlyphCache { 142,16%[?12l[?25h[?25l - 143  /// Cache of buffered glyphs 143,16%[?12l[?25h[?25l - 144  cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>, 144,16%[?12l[?25h[?25l - 145  145,0-16%[?12l[?25h[?25l - 146  /// Rasterizer for loading new glyphs 146,16%[?12l[?25h[?25l - 147  rasterizer: Rasterizer, 147,17%[?12l[?25h[?25l - 148  148,0-17%[?12l[?25h[?25l - 149  /// regular font 149,17%[?12l[?25h[?25l - 150  font_key: FontKey, 150,17%[?12l[?25h[?25l - 151  151,0-17%[?12l[?25h[?25l - 152  /// italic font 152,17%[?12l[?25h[?25l - 153  italic_key: FontKey, 153,17%[?12l[?25h[?25l - 154  154,0-17%[?12l[?25h[?25l - 155  /// bold font 155,17%[?12l[?25h[?25l - 156  bold_key: FontKey, 156,17%[?12l[?25h[?25l - 157  157,0-17%[?12l[?25h[?25l - 158  /// font size 158,17%[?12l[?25h[?25l - 159  font_size: font::Size, 159,17%[?12l[?25h[?25l - 160  160,0-18%[?12l[?25h[?25l - 161  /// glyph offset 161,18%[?12l[?25h[?25l - 162  glyph_offset: Delta, 162,18%[?12l[?25h[?25l - 163  163,0-18%[?12l[?25h[?25l - 164  metrics: ::font::Metrics, 164,18%[?12l[?25h[?25l -{ 165 } 165,18%[?12l[?25h[?25l -{} - 166  166,0-18%[?12l[?25h[?25l - 167 impl GlyphCache { 167,18%[?12l[?25h[?25l - 168  pub fn new<L>( 168,18%[?12l[?25h[?25l - 169 mut rasterizer: Rasterizer, 169,18%[?12l[?25h[?25l - 170 config: &Config, 170,18%[?12l[?25h[?25l - 171 loader: &mut L 171,18%[?12l[?25h[?25l - 172  ) -> Result<GlyphCache, font::Error> 172,18%[?12l[?25h[?25l - 173 where L: LoadGlyph 173,19%[?12l[?25h[?25l - 174  { 174,19%[?12l[?25h[?25l - 175 let font = config.font(); 175,19%[?12l[?25h[?25l - 176 let size = font.size(); 176,19%[?12l[?25h[?25l - 177 let glyph_offset = *font.glyph_offset(); 177,19%[?12l[?25h[?25l - 178  178,0-19%[?12l[?25h[?25l - 179 fn make_desc( 179,19%[?12l[?25h[?25l - 180 desc: &config::FontDescription, 180,19%[?12l[?25h[?25l - 181 slant: font::Slant, 181,19%[?12l[?25h[?25l - 182 weight: font::Weight, 182,19%[?12l[?25h[?25l - 183 ) -> FontDesc 183,19%[?12l[?25h[?25l - 184 { 184,19%[?12l[?25h[?25l - 185 let style = if let Some(ref spec) = desc.style { 185,19%[?12l[?25h[?25l - 186 font::Style::Specific(spec.to_owned()) 186,110%[?12l[?25h[?25l - 187 } else { 187,110%[?12l[?25h[?25l - 188 font::Style::Description {slant:slant, weight:weight} 188,110%[?12l[?25h[?25l - 189 }; 189,110%[?12l[?25h[?25l - 190 FontDesc::new(&desc.family[..], style) 190,110%[?12l[?25h[?25l - 191 } 191,110%[?12l[?25h[?25l - 192  192,0-110%[?12l[?25h[?25l - 193 // Load regular font 193,110%[?12l[?25h[?25l - 194 let regular_desc = make_desc(&font.normal, font::Slant::Normal, font::Weight::Normal);  194,110%[?12l[?25h[?25l - 195  195,0-110%[?12l[?25h[?25l - 196 let regular = rasterizer 196,110%[?12l[?25h[?25l - 197 .load_font(&regular_desc, size)?; 197,110%[?12l[?25h[?25l - 198  198,0-110%[?12l[?25h[?25l - 199 // helper to load a description if it is not the regular_desc 199,111%[?12l[?25h[?25l - 200 let load_or_regular = |desc:FontDesc, rasterizer: &mut Rasterizer| { 200,111%[?12l[?25h[?25l - 201 if desc == regular_desc { 201,111%[?12l[?25h[?25l - 202 regular 202,111%[?12l[?25h[?25l - 203 } else { 203,111%[?12l[?25h[?25l - 204 rasterizer.load_font(&desc, size).unwrap_or_else(|_| regular) 204,111%[?12l[?25h[?25l - 205 } 205,111%[?12l[?25h[?25l - 206 }; 206,111%[?12l[?25h[?25l - 207  207,0-111%[?12l[?25h[?25l - 208 // Load bold font 208,111%[?12l[?25h[?25l - 209 let bold_desc = make_desc(&font.bold, font::Slant::Normal, font::Weight::Bold); 209,111%[?12l[?25h[?25l - 210  210,0-111%[?12l[?25h[?25l - 211 let bold = load_or_regular(bold_desc, &mut rasterizer); 211,111%[?12l[?25h[?25l - 212  212,0-112%[?12l[?25h[?25l - 213 // Load italic font 213,112%[?12l[?25h[?25l - 214 let italic_desc = make_desc(&font.italic, font::Slant::Italic, font::Weight::Normal); 214,112%[?12l[?25h[?25l - 215  215,0-112%[?12l[?25h[?25l - 216 let italic = load_or_regular(italic_desc, &mut rasterizer); 216,112%[?12l[?25h[?25l - 217  217,0-112%[?12l[?25h[?25l - 218 // Need to load at least one glyph for the face before calling metrics. 218,112%[?12l[?25h[?25l - 219 // The glyph requested here ('m' at the time of writing) has no special 219,112%[?12l[?25h[?25l - 220 // meaning. 220,112%[?12l[?25h[?25l - 221 rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?; 221,112%[?12l[?25h[?25l - 222 let metrics = rasterizer.metrics(regular)?; 222,112%[?12l[?25h[?25l - 223  223,0-112%[?12l[?25h[?25l - 224 let mut cache = GlyphCache { 224,112%[?12l[?25h[?25l - 225 cache: HashMap::default(), 225,113%[?12l[?25h[?25l - 226 rasterizer: rasterizer, 226,113%[?12l[?25h[?25l - 227 font_size: font.size(), 227,113%[?12l[?25h[?25l - 228 font_key: regular, 228,113%[?12l[?25h[?25l - 229 bold_key: bold, 229,113%[?12l[?25h[?25l - 230 italic_key: italic, 230,113%[?12l[?25h[?25l - 231 glyph_offset: glyph_offset, 231,113%[?12l[?25h[?25l - 232 metrics: metrics 232,113%[?12l[?25h[?25l - 233 }; 233,113%[?12l[?25h[?25l - 234  234,0-113%[?12l[?25h[?25l - 235 macro_rules! load_glyphs_for_font { 235,113%[?12l[?25h[?25l - 236 ($font:expr) => { 236,113%[?12l[?25h[?25l - 237 for i in RangeInclusive::new(32u8, 128u8) { 237,113%[?12l[?25h[?25l - 238 cache.get(&GlyphKey { 238,114%[?12l[?25h[?25l - 239 font_key: $font, 239,114%[?12l[?25h[?25l - 240 c: i as char, 240,114%[?12l[?25h[?25l - 241 size: font.size() 241,114%[?12l[?25h[?25l - 242 }, loader); 242,114%[?12l[?25h[?25l - 243 } 243,114%[?12l[?25h[?25l - 244 } 244,114%[?12l[?25h[?25l - 245 } 245,114%[?12l[?25h[?25l - 246  246,0-114%[?12l[?25h[?25l - 247 load_glyphs_for_font!(regular); 247,114%[?12l[?25h[?25l - 248 load_glyphs_for_font!(bold); 248,114%[?12l[?25h[?25l - 249 load_glyphs_for_font!(italic); 249,114%[?12l[?25h[?25l - 250  250,0-114%[?12l[?25h[?25l - 251 Ok(cache) 251,115%[?12l[?25h[?25l - 252  } 252,115%[?12l[?25h[?25l - 253  253,0-115%[?12l[?25h[?25l - 254  pub fn font_metrics(&self) -> font::Metrics { 254,115%[?12l[?25h[?25l - 255 self.rasterizer 255,115%[?12l[?25h[?25l - 256 .metrics(self.font_key) 256,115%[?12l[?25h[?25l - 257 .expect("metrics load since font is loaded at glyph cache creation") 257,115%[?12l[?25h[?25l - 258  } 258,115%[?12l[?25h[?25l - 259  259,0-115%[?12l[?25h[?25l - 260  pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph 260,115%[?12l[?25h[?25l - 261 where L: LoadGlyph 261,115%[?12l[?25h[?25l - 262  { 262,115%[?12l[?25h[?25l - 263 let glyph_offset = self.glyph_offset; 263,115%[?12l[?25h[?25l - 264 let rasterizer = &mut self.rasterizer; 264,116%[?12l[?25h[?25l - 265 let metrics = &self.metrics; 265,116%[?12l[?25h[?25l - 266 self.cache 266,116%[?12l[?25h[?25l - 267 .entry(*glyph_key) 267,116%[?12l[?25h[?25l - 268 .or_insert_with(|| { 268,116%[?12l[?25h[?25l - 269 let mut rasterized = rasterizer.get_glyph(&glyph_key) 269,116%[?12l[?25h[?25l - 270 .unwrap_or_else(|_| Default::default()); 270,116%[?12l[?25h[?25l - 271  271,0-116%[?12l[?25h[?25l - 272 rasterized.left += glyph_offset.x as i32; 272,116%[?12l[?25h[?25l - 273 rasterized.top += glyph_offset.y as i32; 273,116%[?12l[?25h[?25l - 274 rasterized.top -= metrics.descent as i32; 274,116%[?12l[?25h[?25l - 275  275,0-116%[?12l[?25h[?25l - 276 loader.load_glyph(&rasterized) 276,116%[?12l[?25h[?25l - 277 }) 277,117%[?12l[?25h[?25l - 278  } 278,117%[?12l[?25h[?25l - 279 } 279,117%[?12l[?25h[?25l - 280  280,0-117%[?12l[?25h[?25l - 281 #[derive(Debug)] 281,117%[?12l[?25h[?25l - 282 #[repr(C)] 282,117%[?12l[?25h[?25l - 283 struct InstanceData { 283,117%[?12l[?25h[?25l - 284  // coords 284,117%[?12l[?25h[?25l - 285  col: f32, 285,117%[?12l[?25h[?25l - 286  row: f32, 286,117%[?12l[?25h[?25l - 287  // glyph offset 287,117%[?12l[?25h[?25l - 288  left: f32, 288,117%[?12l[?25h[?25l - 289  top: f32, 289,117%[?12l[?25h[?25l - 290  // glyph scale 290,118%[?12l[?25h[?25l - 291  width: f32, 291,118%[?12l[?25h[?25l - 292  height: f32, 292,118%[?12l[?25h[?25l - 293  // uv offset 293,118%[?12l[?25h[?25l - 294  uv_left: f32, 294,118%[?12l[?25h[?25l - 295  uv_bot: f32, 295,118%[?12l[?25h[?25l - 296  // uv scale 296,118%[?12l[?25h[?25l - 297  uv_width: f32, 297,118%[?12l[?25h[?25l - 298  uv_height: f32, 298,118%[?12l[?25h[?25l - 299  // color 299,118%[?12l[?25h[?25l - 300  r: f32, 300,118%[?12l[?25h[?25l - 301  g: f32, 301,118%[?12l[?25h[?25l - 302  b: f32, 302,118%[?12l[?25h[?25l - 303  // background color 303,119%[?12l[?25h[?25l - 304  bg_r: f32, 304,119%[?12l[?25h[?25l - 305  bg_g: f32, 305,119%[?12l[?25h[?25l - 306  bg_b: f32, 306,119%[?12l[?25h[?25l -{ 307 } 307,119%[?12l[?25h[?25l -{} - 308  308,0-119%[?12l[?25h[?25l - 309 #[derive(Debug)] 309,119%[?12l[?25h[?25l - 310 pub struct QuadRenderer { 310,119%[?12l[?25h[?25l - 311  program: ShaderProgram, 311,119%[?12l[?25h[?25l - 312  vao: GLuint, 312,119%[?12l[?25h[?25l - 313  vbo: GLuint, 313,119%[?12l[?25h[?25l - 314  ebo: GLuint, 314,119%[?12l[?25h[?25l - 315  vbo_instance: GLuint, 315,119%[?12l[?25h[?25l - 316  atlas: Vec<Atlas>, 316,120%[?12l[?25h[?25l - 317  active_tex: GLuint, 317,120%[?12l[?25h[?25l - 318  batch: Batch, 318,120%[?12l[?25h[?25l - 319  rx: mpsc::Receiver<Msg>, 319,120%[?12l[?25h[?25l -{ 320 } 320,120%[?12l[?25h[?25l -{} - 321  321,0-120%[?12l[?25h[?25l - 322 #[derive(Debug)] 322,120%[?12l[?25h[?25l - 323 pub struct RenderApi<'a> { 323,120%[?12l[?25h[?25l - 324  active_tex: &'a mut GLuint, 324,120%[?12l[?25h[?25l - 325  batch: &'a mut Batch, 325,120%[?12l[?25h[?25l - 326  atlas: &'a mut Vec<Atlas>, 326,120%[?12l[?25h[?25l - 327  program: &'a mut ShaderProgram, 327,120%[?12l[?25h[?25l - 328  config: &'a Config, 328,120%[?12l[?25h[?25l - 329  visual_bell_intensity: f32 329,121%[?12l[?25h[?25l -{ 330 } 330,121%[?12l[?25h[?25l -{} - 331  331,0-121%[?12l[?25h[?25l - 332 #[derive(Debug)] 332,121%[?12l[?25h[?25l - 333 pub struct LoaderApi<'a> { 333,121%[?12l[?25h[?25l - 334  active_tex: &'a mut GLuint, 334,121%[?12l[?25h[?25l - 335  atlas: &'a mut Vec<Atlas>, 335,121%[?12l[?25h[?25l -{ - - - 336 } 336,121%[?12l[?25h[?25l -{} - 337  337,0-121%[?12l[?25h[?25l - 338 #[derive(Debug)] 338,121%[?12l[?25h[?25l - 339 pub struct PackedVertex { 339,121%[?12l[?25h[?25l - 340  x: f32, 340,121%[?12l[?25h[?25l - 341  y: f32, 341,121%[?12l[?25h[?25l -{ - - - 342 } 342,122%[?12l[?25h[?25l -{} - 343  343,0-122%[?12l[?25h[?25l - 344 #[derive(Debug)] 344,122%[?12l[?25h[?25l - 345 pub struct Batch { 345,122%[?12l[?25h[?25l - 346  tex: GLuint, 346,122%[?12l[?25h[?25l - 347  instances: Vec<InstanceData>, 347,122%[?12l[?25h[?25l -{ - - - 348 } 348,122%[?12l[?25h[?25l -{} - 349  349,0-122%[?12l[?25h[?25l - 350 impl Batch { 350,122%[?12l[?25h[?25l - 351  #[inline] 351,122%[?12l[?25h[?25l - 352  pub fn new() -> Batch { 352,122%[?12l[?25h[?25l - 353 Batch { 353,122%[?12l[?25h[?25l - 354 tex: 0, 354,122%[?12l[?25h[?25l - 355 instances: Vec::with_capacity(BATCH_MAX), 355,123%[?12l[?25h[?25l - 356 } 356,123%[?12l[?25h[?25l - 357  } 357,123%[?12l[?25h[?25l - 358  358,0-123%[?12l[?25h[?25l - 359  pub fn add_item( 359,123%[?12l[?25h[?25l - 360 &mut self, 360,123%[?12l[?25h[?25l - 361 cell: &RenderableCell, 361,123%[?12l[?25h[?25l - 362 glyph: &Glyph, 362,123%[?12l[?25h[?25l - 363  ) { 363,123%[?12l[?25h[?25l - 364 if self.is_empty() { 364,123%[?12l[?25h[?25l - 365 self.tex = glyph.tex_id; 365,123%[?12l[?25h[?25l - 366 } 366,123%[?12l[?25h[?25l - 367  367,0-123%[?12l[?25h[?25l - 368 self.instances.push(InstanceData { 368,124%[?12l[?25h[?25l - 369 col: cell.column.0 as f32, 369,124%[?12l[?25h[?25l - 370 row: cell.line.0 as f32, 370,124%[?12l[?25h[?25l - 371  371,0-124%[?12l[?25h[?25l - 372 top: glyph.top, 372,124%[?12l[?25h[?25l - 373 left: glyph.left, 373,124%[?12l[?25h[?25l - 374 width: glyph.width, 374,124%[?12l[?25h[?25l - 375 height: glyph.height, 375,124%[?12l[?25h[?25l - 376  376,0-124%[?12l[?25h[?25l - 377 uv_bot: glyph.uv_bot, 377,124%[?12l[?25h[?25l - 378 uv_left: glyph.uv_left, 378,124%[?12l[?25h[?25l - 379 uv_width: glyph.uv_width, 379,124%[?12l[?25h[?25l - 380 uv_height: glyph.uv_height, 380,124%[?12l[?25h[?25l - 381  381,0-125%[?12l[?25h[?25l - 382 r: cell.fg.r as f32, 382,125%[?12l[?25h[?25l - 383 g: cell.fg.g as f32, 383,125%[?12l[?25h[?25l - 384 b: cell.fg.b as f32, 384,125%[?12l[?25h[?25l - 385  385,0-125%[?12l[?25h[?25l - 386 bg_r: cell.bg.r as f32, 386,125%[?12l[?25h[?25l - 387 bg_g: cell.bg.g as f32, 387,125%[?12l[?25h[?25l - 388 bg_b: cell.bg.b as f32, 388,125%[?12l[?25h[?25l - 389 }); 389,125%[?12l[?25h[?25l - 390  } 390,125%[?12l[?25h[?25l - 391  391,0-125%[?12l[?25h[?25l - 392  #[inline] 392,125%[?12l[?25h[?25l - 393  pub fn full(&self) -> bool { 393,125%[?12l[?25h[?25l - 394 self.capacity() == self.len() 394,126%[?12l[?25h[?25l - 395  } 395,126%[?12l[?25h[?25l - 396  396,0-126%[?12l[?25h[?25l - 397  #[inline] 397,126%[?12l[?25h[?25l - 398  pub fn len(&self) -> usize { 398,126%[?12l[?25h[?25l - 399 self.instances.len() 399,126%[?12l[?25h[?25l - 400  } 400,126%[?12l[?25h[?25l - 401  401,0-126%[?12l[?25h[?25l - 402  #[inline] 402,126%[?12l[?25h[?25l - 403  pub fn capacity(&self) -> usize { 403,126%[?12l[?25h[?25l - 404 BATCH_MAX 404,126%[?12l[?25h[?25l - 405  } 405,126%[?12l[?25h[?25l - 406  406,0-126%[?12l[?25h[?25l - 407  #[inline] 407,127%[?12l[?25h[?25l - 408  pub fn is_empty(&self) -> bool { 408,127%[?12l[?25h[?25l - 409 self.len() == 0 409,127%[?12l[?25h[?25l - 410  } 410,127%[?12l[?25h[?25l - 411  411,0-127%[?12l[?25h[?25l - 412  #[inline] 412,127%[?12l[?25h[?25l - 413  pub fn size(&self) -> usize { 413,127%[?12l[?25h[?25l - 414 self.len() * size_of::<InstanceData>() 414,127%[?12l[?25h[?25l - 415  } 415,127%[?12l[?25h[?25l - 416  416,0-127%[?12l[?25h[?25l - 417  pub fn clear(&mut self) { 417,127%[?12l[?25h[?25l - 418 self.tex = 0; 418,127%[?12l[?25h[?25l - 419 self.instances.clear(); 419,127%[?12l[?25h[?25l - 420  } 420,128%[?12l[?25h[?25l - 421 } 421,128%[?12l[?25h[?25l - 422  422,0-128%[?12l[?25h[?25l - 423 /// Maximum items to be drawn in a batch. 423,128%[?12l[?25h[?25l - 424 const BATCH_MAX: usize = 65_536; 424,128%[?12l[?25h[?25l - 425 const ATLAS_SIZE: i32 = 1024; 425,128%[?12l[?25h[?25l - 426  426,0-128%[?12l[?25h[?25l - 427 impl QuadRenderer { 427,128%[?12l[?25h[?25l - 428  // TODO should probably hand this a transform instead of width/height 428,128%[?12l[?25h[?25l - 429  pub fn new(config: &Config, size: Size<Pixels<u32>>) -> Result<QuadRenderer, Error> { 429,128%[?12l[?25h[?25l - 430 let program = ShaderProgram::new(config, size)?; 430,128%[?12l[?25h[?25l - 431  431,0-128%[?12l[?25h[?25l - 432 let mut vao: GLuint = 0; 432,128%[?12l[?25h[?25l - 433 let mut vbo: GLuint = 0; 433,129%[?12l[?25h[?25l - 434 let mut ebo: GLuint = 0; 434,129%[?12l[?25h[?25l - 435  435,0-129%[?12l[?25h[?25l - 436 let mut vbo_instance: GLuint = 0; 436,129%[?12l[?25h[?25l - 437  437,0-129%[?12l[?25h[?25l - 438 unsafe { 438,129%[?12l[?25h[?25l - 439 gl::Enable(gl::BLEND); 439,129%[?12l[?25h[?25l - 440 gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR); 440,129%[?12l[?25h[?25l - 441 gl::Enable(gl::MULTISAMPLE); 441,129%[?12l[?25h[?25l - 442  442,0-129%[?12l[?25h[?25l - 443 gl::GenVertexArrays(1, &mut vao); 443,129%[?12l[?25h[?25l - 444 gl::GenBuffers(1, &mut vbo); 444,129%[?12l[?25h[?25l - 445 gl::GenBuffers(1, &mut ebo); 445,129%[?12l[?25h[?25l - 446 gl::GenBuffers(1, &mut vbo_instance); 446,130%[?12l[?25h[?25l - 447 gl::BindVertexArray(vao); 447,130%[?12l[?25h[?25l - 448  448,0-130%[?12l[?25h[?25l - 449 // ---------------------------- 449,130%[?12l[?25h[?25l - 450 // setup vertex position buffer 450,130%[?12l[?25h[?25l - 451 // ---------------------------- 451,130%[?12l[?25h[?25l - 452 // Top right, Bottom right, Bottom left, Top left 452,130%[?12l[?25h[?25l - 453 let vertices = [ 453,130%[?12l[?25h[?25l - 454 PackedVertex { x: 1.0, y: 1.0 }, 454,130%[?12l[?25h[?25l - 455 PackedVertex { x: 1.0, y: 0.0 }, 455,130%[?12l[?25h[?25l - 456 PackedVertex { x: 0.0, y: 0.0 }, 456,130%[?12l[?25h[?25l - 457 PackedVertex { x: 0.0, y: 1.0 }, 457,130%[?12l[?25h[?25l - 458 ]; 458,130%[?12l[?25h[?25l - 459  459,0-131%[?12l[?25h[?25l - 460 gl::BindBuffer(gl::ARRAY_BUFFER, vbo); 460,131%[?12l[?25h[?25l - 461  461,0-131%[?12l[?25h[?25l - 462 gl::VertexAttribPointer(0, 2, 462,131%[?12l[?25h[?25l - 463 gl::FLOAT, gl::FALSE, 463,131%[?12l[?25h[?25l - 464 size_of::<PackedVertex>() as i32, 464,131%[?12l[?25h[?25l - 465 ptr::null()); 465,131%[?12l[?25h[?25l - 466 gl::EnableVertexAttribArray(0); 466,131%[?12l[?25h[?25l - 467  467,0-131%[?12l[?25h[?25l - 468 gl::BufferData(gl::ARRAY_BUFFER, 468,131%[?12l[?25h[?25l - 469 (size_of::<PackedVertex>() * vertices.len()) as GLsizeiptr, 469,131%[?12l[?25h[?25l - 470 vertices.as_ptr() as *const _, 470,131%[?12l[?25h[?25l - 471 gl::STATIC_DRAW); 471,131%[?12l[?25h[?25l - 472  472,0-132%[?12l[?25h[?25l - 473 // --------------------- 473,132%[?12l[?25h[?25l - 474 // Set up element buffer 474,132%[?12l[?25h[?25l - 475 // --------------------- 475,132%[?12l[?25h[?25l - 476 let indices: [u32; 6] = [0, 1, 3, 476,132%[?12l[?25h[?25l - 477 1, 2, 3]; 477,132%[?12l[?25h[?25l - 478  478,0-132%[?12l[?25h[?25l - 479 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo); 479,132%[?12l[?25h[?25l - 480 gl::BufferData(gl::ELEMENT_ARRAY_BUFFER, 480,132%[?12l[?25h[?25l - 481 (6 * size_of::<u32>()) as isize, 481,132%[?12l[?25h[?25l - 482 indices.as_ptr() as *const _, 482,132%[?12l[?25h[?25l - 483 gl::STATIC_DRAW); 483,132%[?12l[?25h[?25l - 484  484,0-132%[?12l[?25h[?25l - 485 // ---------------------------- 485,133%[?12l[?25h[?25l - 486 // Setup vertex instance buffer 486,133%[?12l[?25h[?25l - 487 // ---------------------------- 487,133%[?12l[?25h[?25l - 488 gl::BindBuffer(gl::ARRAY_BUFFER, vbo_instance); 488,133%[?12l[?25h[?25l - 489 gl::BufferData(gl::ARRAY_BUFFER, 489,133%[?12l[?25h[?25l - 490 (BATCH_MAX * size_of::<InstanceData>()) as isize, 490,133%[?12l[?25h[?25l - 491 ptr::null(), gl::STREAM_DRAW); 491,133%[?12l[?25h[?25l - 492 // coords 492,133%[?12l[?25h[?25l - 493 gl::VertexAttribPointer(1, 2, 493,133%[?12l[?25h[?25l - 494 gl::FLOAT, gl::FALSE, 494,133%[?12l[?25h[?25l - 495 size_of::<InstanceData>() as i32, 495,133%[?12l[?25h[?25l - 496 ptr::null()); 496,133%[?12l[?25h[?25l - 497 gl::EnableVertexAttribArray(1); 497,133%[?12l[?25h[?25l - 498 gl::VertexAttribDivisor(1, 1); 498,134%[?12l[?25h[?25l - 499 // glyphoffset 499,134%[?12l[?25h[?25l - 500 gl::VertexAttribPointer(2, 4, 500,134%[?12l[?25h[?25l - 501 gl::FLOAT, gl::FALSE, 501,134%[?12l[?25h[?25l - 502 size_of::<InstanceData>() as i32, 502,134%[?12l[?25h[?25l - 503 (2 * size_of::<f32>()) as *const _); 503,134%[?12l[?25h[?25l - 504 gl::EnableVertexAttribArray(2); 504,134%[?12l[?25h[?25l - 505 gl::VertexAttribDivisor(2, 1); 505,134%[?12l[?25h[?25l - 506 // uv 506,134%[?12l[?25h[?25l - 507 gl::VertexAttribPointer(3, 4, 507,134%[?12l[?25h[?25l - 508 gl::FLOAT, gl::FALSE, 508,134%[?12l[?25h[?25l - 509 size_of::<InstanceData>() as i32, 509,134%[?12l[?25h[?25l - 510 (6 * size_of::<f32>()) as *const _); 510,134%[?12l[?25h[?25l - 511 gl::EnableVertexAttribArray(3); 511,135%[?12l[?25h[?25l - 512 gl::VertexAttribDivisor(3, 1); 512,135%[?12l[?25h[?25l - 513 // color 513,135%[?12l[?25h[?25l - 514 gl::VertexAttribPointer(4, 3, 514,135%[?12l[?25h[?25l - 515 gl::FLOAT, gl::FALSE, 515,135%[?12l[?25h[?25l - 516 size_of::<InstanceData>() as i32, 516,135%[?12l[?25h[?25l - 517 (10 * size_of::<f32>()) as *const _); 517,135%[?12l[?25h[?25l - 518 gl::EnableVertexAttribArray(4); 518,135%[?12l[?25h[?25l - 519 gl::VertexAttribDivisor(4, 1); 519,135%[?12l[?25h[?25l - 520 // color 520,135%[?12l[?25h[?25l - 521 gl::VertexAttribPointer(5, 3, 521,135%[?12l[?25h[?25l - 522 gl::FLOAT, gl::FALSE,[48;2;42;42;42m 522,135%[?12l[?25h[?25l - 523 size_of::<InstanceData>() as i32, 523,135%[?12l[?25h[?25l - 524 (13 * size_of::<f32>()) as *const _); 524,136%[?12l[?25h[?25l - 525 gl::EnableVertexAttribArray(5); 525,136%[?12l[?25h[?25l - 526 gl::VertexAttribDivisor(5, 1); 526,136%[?12l[?25h[?25l - 527  527,0-136%[?12l[?25h[?25l - 528 gl::BindVertexArray(0); 528,136%[?12l[?25h[?25l - 529 gl::BindBuffer(gl::ARRAY_BUFFER, 0); 529,136%[?12l[?25h[?25l - 530 } 530,136%[?12l[?25h[?25l - 531  531,0-136%[?12l[?25h[?25l - 532 let (msg_tx, msg_rx) = mpsc::channel(); 532,136%[?12l[?25h[?25l - 533  533,0-136%[?12l[?25h[?25l - 534 if cfg!(feature = "live-shader-reload") { 534,136%[?12l[?25h[?25l - 535 ::std::thread::spawn(move || { 535,136%[?12l[?25h[?25l - 536 let (tx, rx) = ::std::sync::mpsc::channel(); 536,136%[?12l[?25h[?25l - 537 let mut watcher = Watcher::new(tx).expect("create file watcher"); 537,137%[?12l[?25h[?25l - 538 watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader"); 538,137%[?12l[?25h[?25l - 539 watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader"); 539,137%[?12l[?25h[?25l - 540  540,0-137%[?12l[?25h[?25l - 541 loop { 541,137%[?12l[?25h[?25l - 542 let event = rx.recv().expect("watcher event"); 542,137%[?12l[?25h[?25l - 543 let ::notify::Event { path, op } = event; 543,137%[?12l[?25h[?25l - 544  544,0-137%[?12l[?25h[?25l - 545 if let Ok(op) = op { 545,137%[?12l[?25h[?25l - 546 if op.contains(op::RENAME) { 546,137%[?12l[?25h[?25l - 547 continue; 547,137%[?12l[?25h[?25l - 548 } 548,137%[?12l[?25h[?25l - 549  549,0-137%[?12l[?25h[?25l - 550 if op.contains(op::IGNORED) { 550,138%[?12l[?25h[?25l - 551 if let Some(path) = path.as_ref() { 551,138%[?12l[?25h[?25l - 552 if let Err(err) = watcher.watch(path) { 552,138%[?12l[?25h[?25l - 553 warn!("failed to establish watch on {:?}: {:?}", path, err);  553,138%[?12l[?25h[?25l - 554 } 554,138%[?12l[?25h[?25l - 555 } 555,138%[?12l[?25h[?25l - 556  556,0-138%[?12l[?25h[?25l - 557 msg_tx.send(Msg::ShaderReload) 557,138%[?12l[?25h[?25l - 558 .expect("msg send ok"); 558,138%[?12l[?25h[?25l - 559 } 559,138%[?12l[?25h[?25l - 560 } 560,138%[?12l[?25h[?25l - 561 } 561,138%[?12l[?25h[?25l - 562 }); 562,138%[?12l[?25h[?25l - 563 } 563,139%[?12l[?25h[?25l - 564  564,0-139%[?12l[?25h[?25l - 565 let mut renderer = QuadRenderer { 565,139%[?12l[?25h[?25l - 566 program: program, 566,139%[?12l[?25h[?25l - 567 vao: vao, 567,139%[?12l[?25h[?25l - 568 vbo: vbo, 568,139%[?12l[?25h[?25l - 569 ebo: ebo, 569,139%[?12l[?25h[?25l - 570 vbo_instance: vbo_instance, 570,139%[?12l[?25h[?25l - 571 atlas: Vec::new(), 571,139%[?12l[?25h[?25l - 572 active_tex: 0, 572,139%[?12l[?25h[?25l - 573 batch: Batch::new(), 573,139%[?12l[?25h[?25l - 574 rx: msg_rx, 574,139%[?12l[?25h[?25l - 575 }; 575,139%[?12l[?25h[?25l - 576  576,0-140%[?12l[?25h[?25l - 577 let atlas = Atlas::new(ATLAS_SIZE); 577,140%[?12l[?25h[?25l - 578 renderer.atlas.push(atlas); 578,140%[?12l[?25h[?25l - 579  579,0-140%[?12l[?25h[?25l - 580 Ok(renderer) 580,140%[?12l[?25h[?25l - 581  } 581,140%[?12l[?25h[?25l - 582  582,0-140%[?12l[?25h[?25l - 583  pub fn with_api<F, T>( 583,140%[?12l[?25h[?25l - 584 &mut self, 584,140%[?12l[?25h[?25l - 585 config: &Config, 585,140%[?12l[?25h[?25l - 586 props: &term::SizeInfo, 586,140%[?12l[?25h[?25l - 587 visual_bell_intensity: f64, 587,140%[?12l[?25h[?25l - 588 func: F 588,140%[?12l[?25h[?25l - 589  ) -> T 589,141%[?12l[?25h[?25l - 590 where F: FnOnce(RenderApi) -> T 590,141%[?12l[?25h[?25l - 591  { 591,141%[?12l[?25h[?25l - 592 while let Ok(msg) = self.rx.try_recv() { 592,141%[?12l[?25h[?25l - 593 match msg { 593,141%[?12l[?25h[?25l - 594 Msg::ShaderReload => { 594,141%[?12l[?25h[?25l - 595 self.reload_shaders(&config, Size { 595,141%[?12l[?25h[?25l - 596 width: Pixels(props.width as u32), 596,141%[?12l[?25h[?25l - 597 height: Pixels(props.height as u32) 597,141%[?12l[?25h[?25l - 598 }); 598,141%[?12l[?25h[?25l - 599 } 599,141%[?12l[?25h[?25l - 600 } 600,141%[?12l[?25h[?25l - 601 } 601,141%[?12l[?25h[?25l - 602  602,0-142%[?12l[?25h[?25l - 603 unsafe { 603,142%[?12l[?25h[?25l - 604 self.program.activate(); 604,142%[?12l[?25h[?25l - 605 self.program.set_term_uniforms(props); 605,142%[?12l[?25h[?25l - 606 self.program.set_visual_bell(visual_bell_intensity as _); 606,142%[?12l[?25h[?25l - 607  607,0-142%[?12l[?25h[?25l - 608 gl::BindVertexArray(self.vao); 608,142%[?12l[?25h[?25l - 609 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo); 609,142%[?12l[?25h[?25l - 610 gl::BindBuffer(gl::ARRAY_BUFFER, self.vbo_instance); 610,142%[?12l[?25h[?25l - 611 gl::ActiveTexture(gl::TEXTURE0); 611,142%[?12l[?25h[?25l - 612 } 612,142%[?12l[?25h[?25l - 613  613,0-142%[?12l[?25h[?25l - 614 let res = func(RenderApi { 614,142%[?12l[?25h[?25l - 615 active_tex: &mut self.active_tex, 615,143%[?12l[?25h[?25l - 616 batch: &mut self.batch, 616,143%[?12l[?25h[?25l - 617 atlas: &mut self.atlas, 617,143%[?12l[?25h[?25l - 618 program: &mut self.program, 618,143%[?12l[?25h[?25l - 619 visual_bell_intensity: visual_bell_intensity as _, 619,143%[?12l[?25h[?25l - 620 config: config, 620,143%[?12l[?25h[?25l - 621 }); 621,143%[?12l[?25h[?25l - 622  622,0-143%[?12l[?25h[?25l - 623 unsafe { 623,143%[?12l[?25h[?25l - 624 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, 0); 624,143%[?12l[?25h[?25l - 625 gl::BindBuffer(gl::ARRAY_BUFFER, 0); 625,143%[?12l[?25h[?25l - 626 gl::BindVertexArray(0); 626,143%[?12l[?25h[?25l - 627  627,0-143%[?12l[?25h[?25l - 628 self.program.deactivate(); 628,144%[?12l[?25h[?25l - 629 } 629,144%[?12l[?25h[?25l - 630  630,0-144%[?12l[?25h[?25l - 631 res 631,144%[?12l[?25h[?25l - 632  } 632,144%[?12l[?25h[?25l - 633  633,0-144%[?12l[?25h[?25l - 634  pub fn with_loader<F, T>(&mut self, func: F) -> T 634,144%[?12l[?25h[?25l - 635 where F: FnOnce(LoaderApi) -> T 635,144%[?12l[?25h[?25l - 636  { 636,144%[?12l[?25h[?25l - 637 unsafe { 637,144%[?12l[?25h[?25l - 638 gl::ActiveTexture(gl::TEXTURE0); 638,144%[?12l[?25h[?25l - 639 } 639,144%[?12l[?25h[?25l - 640  640,0-144%[?12l[?25h[?25l - 641 func(LoaderApi { 641,145%[?12l[?25h[?25l - 642 active_tex: &mut self.active_tex, 642,145%[?12l[?25h[?25l - 643 atlas: &mut self.atlas, 643,145%[?12l[?25h[?25l - 644 }) 644,145%[?12l[?25h[?25l - 645  } 645,145%[?12l[?25h[?25l - 646  646,0-145%[?12l[?25h[?25l - 647  pub fn reload_shaders(&mut self, config: &Config, size: Size<Pixels<u32>>) { 647,145%[?12l[?25h[?25l - 648 info!("Reloading shaders"); 648,145%[?12l[?25h[?25l - 649 let program = match ShaderProgram::new(config, size) { 649,145%[?12l[?25h[?25l - 650 Ok(program) => program, 650,145%[?12l[?25h[?25l - 651 Err(err) => { 651,145%[?12l[?25h[?25l - 652 match err { 652,145%[?12l[?25h[?25l - 653 ShaderCreationError::Io(err) => { 653,145%[?12l[?25h[?25l - 654 error!("Error reading shader file: {}", err); 654,146%[?12l[?25h[?25l - 655 }, 655,146%[?12l[?25h[?25l - 656 ShaderCreationError::Compile(path, log) => { 656,146%[?12l[?25h[?25l - 657 error!("Error compiling shader at {:?}", path); 657,146%[?12l[?25h[?25l - 658 let _ = io::copy(&mut log.as_bytes(), &mut io::stdout()); 658,146%[?12l[?25h[?25l - 659 } 659,146%[?12l[?25h[?25l - 660 } 660,146%[?12l[?25h[?25l - 661  661,0-146%[?12l[?25h[?25l - 662 return; 662,146%[?12l[?25h[?25l - 663 } 663,146%[?12l[?25h[?25l - 664 }; 664,146%[?12l[?25h[?25l - 665  665,0-146%[?12l[?25h[?25l - 666 self.active_tex = 0; 666,146%[?12l[?25h[?25l - 667 self.program = program; 667,147%[?12l[?25h[?25l - 668  } 668,147%[?12l[?25h[?25l - 669  669,0-147%[?12l[?25h[?25l - 670  pub fn resize(&mut self, width: i32, height: i32) { 670,147%[?12l[?25h[?25l - 671 let padding_x = self.program.padding_x as i32; 671,147%[?12l[?25h[?25l - 672 let padding_y = self.program.padding_y as i32; 672,147%[?12l[?25h[?25l - 673  673,0-147%[?12l[?25h[?25l - 674 // viewport 674,147%[?12l[?25h[?25l - 675 unsafe { 675,147%[?12l[?25h[?25l - 676 gl::Viewport(padding_x, padding_y, width - 2 * padding_x, height - 2 * padding_y);  676,147%[?12l[?25h[?25l - 677 } 677,147%[?12l[?25h[?25l - 678  678,0-147%[?12l[?25h[?25l - 679 // update projection 679,147%[?12l[?25h[?25l - 680 self.program.activate(); 680,148%[?12l[?25h[?25l - 681 self.program.update_projection(width as f32, height as f32); 681,148%[?12l[?25h[?25l - 682 self.program.deactivate(); 682,148%[?12l[?25h[?25l - 683  } 683,148%[?12l[?25h[?25l - 684 } 684,148%[?12l[?25h[?25l - 685  685,0-148%[?12l[?25h[?25l - 686 impl<'a> RenderApi<'a> { 686,148%[?12l[?25h[?25l - 687  pub fn clear(&self, color: Rgb) { 687,148%[?12l[?25h[?25l - 688 unsafe { 688,148%[?12l[?25h[?25l - 689 gl::ClearColor( 689,148%[?12l[?25h[?25l - 690 (self.visual_bell_intensity + color.r as f32 / 255.0).min(1.0), 690,148%[?12l[?25h[?25l - 691 (self.visual_bell_intensity + color.g as f32 / 255.0).min(1.0), 691,148%[?12l[?25h[?25l - 692 (self.visual_bell_intensity + color.b as f32 / 255.0).min(1.0), 692,148%[?12l[?25h[?25l - 693 1.0 693,149%[?12l[?25h[?25l - 694 ); 694,149%[?12l[?25h[?25l - 695 gl::Clear(gl::COLOR_BUFFER_BIT); 695,149%[?12l[?25h[?25l - 696 } 696,149%[?12l[?25h[?25l - 697  } 697,149%[?12l[?25h[?25l - 698  698,0-149%[?12l[?25h[?25l - 699  fn render_batch(&mut self) { 699,149%[?12l[?25h[?25l - 700 unsafe { 700,149%[?12l[?25h[?25l - 701 gl::BufferSubData(gl::ARRAY_BUFFER, 0, self.batch.size() as isize, 701,149%[?12l[?25h[?25l - 702 self.batch.instances.as_ptr() as *const _); 702,149%[?12l[?25h[?25l - 703 } 703,149%[?12l[?25h[?25l - 704  704,0-149%[?12l[?25h[?25l - 705 // Bind texture if necessary 705,150%[?12l[?25h[?25l - 706 if *self.active_tex != self.batch.tex { 706,150%[?12l[?25h[?25l - 707 unsafe { 707,150%[?12l[?25h[?25l - 708 gl::BindTexture(gl::TEXTURE_2D, self.batch.tex); 708,150%[?12l[?25h[?25l - 709 } 709,150%[?12l[?25h[?25l - 710 *self.active_tex = self.batch.tex; 710,150%[?12l[?25h[?25l - 711 } 711,150%[?12l[?25h[?25l - 712  712,0-150%[?12l[?25h[?25l - 713 unsafe { 713,150%[?12l[?25h[?25l - 714 self.program.set_background_pass(true); 714,150%[?12l[?25h[?25l - 715 gl::DrawElementsInstanced(gl::TRIANGLES, 715,150%[?12l[?25h[?25l - 716 6, gl::UNSIGNED_INT, ptr::null(), 716,150%[?12l[?25h[?25l - 717 self.batch.len() as GLsizei); 717,150%[?12l[?25h[?25l - 718 self.program.set_background_pass(false); 718,151%[?12l[?25h[?25l - 719 gl::DrawElementsInstanced(gl::TRIANGLES, 719,151%[?12l[?25h[?25l - 720 6, gl::UNSIGNED_INT, ptr::null(), 720,151%[?12l[?25h[?25l - 721 self.batch.len() as GLsizei); 721,151%[?12l[?25h[?25l - 722 } 722,151%[?12l[?25h[?25l - 723  723,0-151%[?12l[?25h[?25l - 724 self.batch.clear(); 724,151%[?12l[?25h[?25l - 725  } 725,151%[?12l[?25h[?25l - 726  /// Render a string in a predefined location. Used for printing render time for profiling and  726,151%[?12l[?25h[?25l - 727  /// optimization. 727,151%[?12l[?25h[?25l - 728  pub fn render_string( 728,151%[?12l[?25h[?25l - 729 &mut self, 729,151%[?12l[?25h[?25l - 730 string: &str, 730,151%[?12l[?25h[?25l - 731 glyph_cache: &mut GlyphCache, 731,152%[?12l[?25h[?25l - 732 color: Rgb, 732,152%[?12l[?25h[?25l - 733  ) { 733,152%[?12l[?25h[?25l - 734 let line = Line(23); 734,152%[?12l[?25h[?25l - 735 let col = Column(0); 735,152%[?12l[?25h[?25l - 736  736,0-152%[?12l[?25h[?25l - 737 let cells = string.chars() 737,152%[?12l[?25h[?25l - 738 .enumerate() 738,152%[?12l[?25h[?25l - 739 .map(|(i, c)| RenderableCell { 739,152%[?12l[?25h[?25l - 740 line: line, 740,152%[?12l[?25h[?25l - 741 column: col + i, 741,152%[?12l[?25h[?25l - 742 c: c, 742,152%[?12l[?25h[?25l - 743 bg: color, 743,152%[?12l[?25h[?25l - 744 fg: Rgb { r: 0, g: 0, b: 0 }, 744,153%[?12l[?25h[?25l - 745 flags: cell::Flags::empty(), 745,153%[?12l[?25h[?25l - 746 }) 746,153%[?12l[?25h[?25l - 747 .collect::<Vec<_>>(); 747,153%[?12l[?25h[?25l - 748  748,0-153%[?12l[?25h[?25l - 749 self.render_cells(cells.into_iter(), glyph_cache); 749,153%[?12l[?25h[?25l - 750  } 750,153%[?12l[?25h[?25l - 751  751,0-153%[?12l[?25h[?25l - 752  #[inline] 752,153%[?12l[?25h[?25l - 753  fn add_render_item(&mut self, cell: &RenderableCell, glyph: &Glyph) { 753,153%[?12l[?25h[?25l - 754 // Flush batch if tex changing 754,153%[?12l[?25h[?25l - 755 if !self.batch.is_empty() && self.batch.tex != glyph.tex_id { 755,153%[?12l[?25h[?25l - 756 self.render_batch(); 756,153%[?12l[?25h[?25l - 757 } 757,154%[?12l[?25h[?25l - 758  758,0-154%[?12l[?25h[?25l - 759 self.batch.add_item(cell, glyph); 759,154%[?12l[?25h[?25l - 760  760,0-154%[?12l[?25h[?25l - 761 // Render batch and clear if it's full 761,154%[?12l[?25h[?25l - 762 if self.batch.full() { 762,154%[?12l[?25h[?25l - 763 self.render_batch(); 763,154%[?12l[?25h[?25l - 764 } 764,154%[?12l[?25h[?25l - 765  } 765,154%[?12l[?25h[?25l - 766  766,0-154%[?12l[?25h[?25l - 767  pub fn render_cells<I>( 767,154%[?12l[?25h[?25l - 768 &mut self, 768,154%[?12l[?25h[?25l - 769 cells: I, 769,154%[?12l[?25h[?25l - 770 glyph_cache: &mut GlyphCache 770,155%[?12l[?25h[?25l - 771  ) 771,155%[?12l[?25h[?25l - 772 where I: Iterator<Item=RenderableCell> 772,155%[?12l[?25h[?25l - 773  { 773,155%[?12l[?25h[?25l - 774 for cell in cells { 774,155%[?12l[?25h[?25l - 775 // Get font key for cell 775,155%[?12l[?25h[?25l - 776 // FIXME this is super inefficient. 776,155%[?12l[?25h[?25l - 777 let mut font_key = glyph_cache.font_key; 777,155%[?12l[?25h[?25l - 778 if cell.flags.contains(cell::BOLD) { 778,155%[?12l[?25h[?25l - 779 font_key = glyph_cache.bold_key; 779,155%[?12l[?25h[?25l - 780 } else if cell.flags.contains(cell::ITALIC) { 780,155%[?12l[?25h[?25l - 781 font_key = glyph_cache.italic_key; 781,155%[?12l[?25h[?25l - 782 } 782,155%[?12l[?25h[?25l - 783  783,0-156%[?12l[?25h[?25l - 784 let glyph_key = GlyphKey { 784,156%[?12l[?25h[?25l - 785 font_key: font_key, 785,156%[?12l[?25h[?25l - 786 size: glyph_cache.font_size, 786,156%[?12l[?25h[?25l - 787 c: cell.c 787,156%[?12l[?25h[?25l - 788 }; 788,156%[?12l[?25h[?25l - 789  789,0-156%[?12l[?25h[?25l - 790 // Add cell to batch 790,156%[?12l[?25h[?25l - 791 { 791,156%[?12l[?25h[?25l - 792 let glyph = glyph_cache.get(&glyph_key, self); 792,156%[?12l[?25h[?25l - 793 self.add_render_item(&cell, glyph); 793,156%[?12l[?25h[?25l - 794 } 794,156%[?12l[?25h[?25l - 795  795,0-156%[?12l[?25h[?25l - 796 // FIXME This is a super hacky way to do underlined text. During 796,157%[?12l[?25h[?25l - 797 // a time crunch to release 0.1, this seemed like a really 797,157%[?12l[?25h[?25l - 798 // easy, clean hack. 798,157%[?12l[?25h[?25l - 799 if cell.flags.contains(cell::UNDERLINE) { 799,157%[?12l[?25h[?25l - 800 let glyph_key = GlyphKey { 800,157%[?12l[?25h[?25l - 801 font_key: font_key, 801,157%[?12l[?25h[?25l - 802 size: glyph_cache.font_size, 802,157%[?12l[?25h[?25l - 803 c: '_' 803,157%[?12l[?25h[?25l - 804 }; 804,157%[?12l[?25h[?25l - 805  805,0-157%[?12l[?25h[?25l - 806 let underscore = glyph_cache.get(&glyph_key, self); 806,157%[?12l[?25h[?25l - 807 self.add_render_item(&cell, underscore); 807,157%[?12l[?25h[?25l - 808 } 808,157%[?12l[?25h[?25l - 809 } 809,158%[?12l[?25h[?25l - 810  } 810,158%[?12l[?25h[?25l - 811 } 811,158%[?12l[?25h[?25l - 812  812,0-158%[?12l[?25h[?25l - 813 impl<'a> LoadGlyph for LoaderApi<'a> { 813,158%[?12l[?25h[?25l - 814  /// Load a glyph into a texture atlas 814,158%[?12l[?25h[?25l - 815  /// 815,158%[?12l[?25h[?25l - 816  /// If the current atlas is full, a new one will be created. 816,158%[?12l[?25h[?25l - 817  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph { 817,158%[?12l[?25h[?25l - 818 // At least one atlas is guaranteed to be in the `self.atlas` list; thus 818,158%[?12l[?25h[?25l - 819 // the unwrap should always be ok. 819,158%[?12l[?25h[?25l - 820 match self.atlas.last_mut().unwrap().insert(rasterized, &mut self.active_tex) { 820,158%[?12l[?25h[?25l - 821 Ok(glyph) => glyph, 821,158%[?12l[?25h[?25l - 822 Err(_) => { 822,159%[?12l[?25h[?25l - 823 let atlas = Atlas::new(ATLAS_SIZE); 823,159%[?12l[?25h[?25l - 824 *self.active_tex = 0; // Atlas::new binds a texture. Ugh this is sloppy. 824,159%[?12l[?25h[?25l - 825 self.atlas.push(atlas); 825,159%[?12l[?25h[?25l - 826 self.load_glyph(rasterized) 826,159%[?12l[?25h[?25l - 827 } 827,159%[?12l[?25h[?25l - 828 } 828,159%[?12l[?25h[?25l - 829  } 829,159%[?12l[?25h[?25l -{ 830 } 830,159%[?12l[?25h[?25l -{} - 831  831,0-159%[?12l[?25h[?25l - 832 impl<'a> LoadGlyph for RenderApi<'a> { 832,159%[?12l[?25h[?25l - 833  /// Load a glyph into a texture atlas 833,159%[?12l[?25h[?25l - 834  /// 834,159%[?12l[?25h[?25l - 835  /// If the current atlas is full, a new one will be created. 835,160%[?12l[?25h[?25l - 836  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph { 836,160%[?12l[?25h[?25l - 837 // At least one atlas is guaranteed to be in the `self.atlas` list; thus 837,160%[?12l[?25h[?25l - 838 // the unwrap. 838,160%[?12l[?25h[?25l - 839 match self.atlas.last_mut().unwrap().insert(rasterized, &mut self.active_tex) { 839,160%[?12l[?25h[?25l - 840 Ok(glyph) => glyph, 840,160%[?12l[?25h[?25l - 841 Err(_) => { 841,160%[?12l[?25h[?25l - 842 let atlas = Atlas::new(ATLAS_SIZE); 842,160%[?12l[?25h[?25l - 843 *self.active_tex = 0; // Atlas::new binds a texture. Ugh this is sloppy. 843,160%[?12l[?25h[?25l - 844 self.atlas.push(atlas); 844,160%[?12l[?25h[?25l - 845 self.load_glyph(rasterized) 845,160%[?12l[?25h[?25l - 846 } 846,160%[?12l[?25h[?25l - 847 } 847,160%[?12l[?25h[?25l - 848  } 848,161%[?12l[?25h[?25l -{ 849 } 849,161%[?12l[?25h[?25l -{} - 850  850,0-161%[?12l[?25h[?25l - 851 impl<'a> Drop for RenderApi<'a> { 851,161%[?12l[?25h[?25l - 852  fn drop(&mut self) { 852,161%[?12l[?25h[?25l - 853 if !self.batch.is_empty() { 853,161%[?12l[?25h[?25l - 854 self.render_batch(); 854,161%[?12l[?25h[?25l - 855 } 855,161%[?12l[?25h[?25l - 856  } 856,161%[?12l[?25h[?25l -{ 857 } 857,161%[?12l[?25h[?25l -{} - 858  858,0-161%[?12l[?25h[?25l - 859 impl ShaderProgram { 859,161%[?12l[?25h[?25l - 860  pub fn activate(&self) { 860,161%[?12l[?25h[?25l - 861 unsafe { 861,162%[?12l[?25h[?25l - 862 gl::UseProgram(self.id); 862,162%[?12l[?25h[?25l - 863 } 863,162%[?12l[?25h[?25l - 864  } 864,162%[?12l[?25h[?25l - 865  865,0-162%[?12l[?25h[?25l - 866  pub fn deactivate(&self) { 866,162%[?12l[?25h[?25l - 867 unsafe { 867,162%[?12l[?25h[?25l - 868 gl::UseProgram(0); 868,162%[?12l[?25h[?25l - 869 } 869,162%[?12l[?25h[?25l - 870  } 870,162%[?12l[?25h[?25l - 871  871,0-162%[?12l[?25h[?25l - 872  pub fn new( 872,162%[?12l[?25h[?25l - 873 config: &Config, 873,162%[?12l[?25h[?25l - 874 size: Size<Pixels<u32>> 874,163%[?12l[?25h[?25l - 875  ) -> Result<ShaderProgram, ShaderCreationError> { 875,163%[?12l[?25h[?25l - 876 let vertex_source = if cfg!(feature = "live-shader-reload") { 876,163%[?12l[?25h[?25l - 877 None 877,163%[?12l[?25h[?25l - 878 } else { 878,163%[?12l[?25h[?25l - 879 Some(TEXT_SHADER_V) 879,163%[?12l[?25h[?25l - 880 }; 880,163%[?12l[?25h[?25l - 881 let vertex_shader = ShaderProgram::create_shader( 881,163%[?12l[?25h[?25l - 882 TEXT_SHADER_V_PATH, 882,163%[?12l[?25h[?25l - 883 gl::VERTEX_SHADER, 883,163%[?12l[?25h[?25l - 884 vertex_source 884,163%[?12l[?25h[?25l - 885 )?; 885,163%[?12l[?25h[?25l - 886 let frag_source = if cfg!(feature = "live-shader-reload") { 886,163%[?12l[?25h[?25l - 887 None 887,164%[?12l[?25h[?25l - 888 } else { 888,164%[?12l[?25h[?25l - 889 Some(TEXT_SHADER_F) 889,164%[?12l[?25h[?25l - 890 }; 890,164%[?12l[?25h[?25l - 891 let fragment_shader = ShaderProgram::create_shader( 891,164%[?12l[?25h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_simple_edit b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_simple_edit deleted file mode 100644 index 8f5c2c397e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_simple_edit +++ /dev/null @@ -1,6 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004hvvivim[?1l>[?2004l -]2;vim]1;vim[?1049h[?1h=β–½ [?12;25h[?12l[?25h[>c[?25l 1 -~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 0,0-1AllVIM - Vi IMprovedversion 7.4.1832by Bram Moolenaar et al.Vim is open source and freely distributableBecome a registered Vim user!type :help register for information type :q to exit type :help or  for on-line helptype :help version7 for version info[?12l[?25h[?25l-- INSERT --0,1All         [?12l[?25h[?25lH1,2[?12l[?25h[?25le3[?12l[?25h[?25ll4[?12l[?25h[?25ll5[?12l[?25h[?25lo6[?12l[?25h[?25l,7[?12l[?25h[?25lΒ·8[?12l[?25h[?25l w9[?12l[?25h[?25lo10[?12l[?25h[?25lr1[?12l[?25h[?25ll2[?12l[?25h[?25ld3[?12l[?25h[?25l.4[?12l[?25h[?25l.5[?12l[?25h[?25l - 2 2,1 [?12l[?25h[?25l - 3 3[?12l[?25h[?25l - 4 4[?12l[?25h[?25lO2[?12l[?25h[?25lk3[?12l[?25h[?25l.4[?12l[?25h[?25l4,3All[?12l[?25h[?25l3,0-1[?12l[?25h[?25l:[?12l[?25hw[?25l[?12l[?25h[?25l3,0-1All[?12l[?25h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_cursor_movement_1 b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_cursor_movement_1 deleted file mode 100644 index 6d51cfdfae..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_cursor_movement_1 +++ /dev/null @@ -1,33 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004hvvtvttteesvttest[?1l>[?2004l -]2;vttest]1;vttest[?1l[?3l[?4l[?5l[?6l[?7h[?8l[?40h[?45lVT100 test program, version 2.7 (20140305)Line speed 38400bd Choose test type: - - 0. Exit - 1. Test of cursor movements - 2. Test of screen features - 3. Test of character sets - 4. Test of double-sized characters - 5. Test of keyboard - 6. Test of terminal reports - 7. Test of VT52 mode - 8. Test of VT102 features (Insert/Delete Char/Line) - 9. Test of known bugs - 10. Test of reset and self-test - 11. Test non-VT100 (e.g., VT220, XTERM) terminals - 12. Modify test-parameters - - Enter choice number (0 - 12): 1 -[?3l#8****************************************************************************************************************************************************************+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M**E**E**E**E**E**E**E**E** -** -** -** -** -** -** -** -** -** -** -** -** -** -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++      The screen should be cleared, and have an unbroken bor-der of *'s and +'s around the edge, and exactly in themiddle there should be a frame of E's around this textwith one (1) free position around it. Push \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_insert b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_insert deleted file mode 100644 index 2986c82b4a..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_insert +++ /dev/null @@ -1,21 +0,0 @@ -% jwilm@sanctuary.local ➜  ~/code/alacritty  [?1h=[?2004hvvtvttteesvttest[?1l>[?2004l -[?1l[?3l[?4l[?5l[?6l[?7h[?8l[?40h[?45lVT100 test program, version 2.7 (20140305)Choose test type: - - 0. Exit - 1. Test of cursor movements - 2. Test of screen features - 3. Test of character sets - 4. Test of double-sized characters - 5. Test of keyboard - 6. Test of terminal reports - 7. Test of VT52 mode - 8. Test of VT102 features (Insert/Delete Char/Line) - 9. Test of known bugs - 10. Test of reset and self-test - 11. Test non-VT100 (e.g., VT220, XTERM) terminals - 12. Modify test-parameters - - Enter choice number (0 - 12): 8 -[?3lAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXScreen accordion test (Insert & Delete Line). Push -M[?6h[?6lTop line: A's, bottom line: X's, this line, nothing more. Push -B******************************************************************************Test of 'Insert Mode'. The top line should be 'A*** ... ***B'. Push \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/zsh_tab_completion b/cmd/sst/mosaic/multiplexer/tcell-term/tests/zsh_tab_completion deleted file mode 100644 index 47b7c6298e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/zsh_tab_completion +++ /dev/null @@ -1,2 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004hccacat cc -Cargo.lock Cargo.toml colors.pl* copypasta/ cat c \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt.go deleted file mode 100644 index a36af4dc9b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt.go +++ /dev/null @@ -1,673 +0,0 @@ -package tcellterm - -import ( - "fmt" - "io" - "log" - "os" - "os/exec" - "runtime/debug" - "strings" - "sync" - "unicode" - - "github.com/creack/pty" - "github.com/gdamore/tcell/v2" - "github.com/mattn/go-runewidth" - "github.com/sst/sst/v3/pkg/process" -) - -type ( - column int - row int -) - -// VT models a virtual terminal -type VT struct { - Logger *log.Logger - // If true, OSC8 enables the output of OSC8 strings. Otherwise, any OSC8 - // sequences will be stripped - OSC8 bool - // Set the TERM environment variable to be passed to the command's - // environment. If not set, xterm-256color will be used - TERM string - - mu sync.Mutex - - activeScreen [][]cell - altScreen [][]cell - primaryScreen [][]cell - primaryScrollback [][]cell - - scroll int - - charsets charsets - cursor cursor - margin margin - mode mode - sShift charset - tabStop []column - // lastCol is a flag indicating we printed in the last col - lastCol bool - - primaryState cursorState - altState cursorState - - cmd *exec.Cmd - dirty bool - eventHandler func(tcell.Event) - parser *Parser - pty *os.File - surface Surface - events chan tcell.Event - - mouseBtn tcell.ButtonMask - - selection *selection -} - -type selection struct { - content strings.Builder - startX int - startY int - endX int - endY int -} - -type cursorState struct { - cursor cursor - decawm bool - decom bool - charsets charsets -} - -type margin struct { - top row - bottom row - left column - right column -} - -func New() *VT { - tabs := []column{} - for i := 7; i < (50 * 7); i += 8 { - tabs = append(tabs, column(i)) - } - return &VT{ - Logger: log.New(io.Discard, "", log.Flags()), - OSC8: true, - scroll: -1, - selection: &selection{ - startX: 0, - startY: 0, - endX: -1, - endY: -1, - }, - charsets: charsets{ - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - }, - mode: decawm | dectcem, - primaryState: cursorState{ - charsets: charsets{ - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - }, - decawm: true, - }, - altState: cursorState{ - charsets: charsets{ - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - }, - decawm: true, - }, - tabStop: tabs, - eventHandler: func(ev tcell.Event) { return }, - // Buffering to 2 events. If there is ever a case where one - // sequence can trigger two events, this should be increased - events: make(chan tcell.Event, 2), - } -} - -// Start starts the terminal with the specified command. Start returns when the -// command has been successfully started. -func (vt *VT) Start(cmd *exec.Cmd) error { - if cmd == nil { - return fmt.Errorf("no command to run") - } - vt.cmd = cmd - vt.mu.Lock() - w, h := vt.surface.Size() - vt.mu.Unlock() - - if vt.TERM == "" { - vt.TERM = "xterm-256color" - } - - cmd.Env = append(cmd.Env, "TERM="+vt.TERM) - - // Start the command with a pty. - var err error - winsize := pty.Winsize{ - Cols: uint16(w), - Rows: uint16(h), - } - vt.pty, err = pty.StartWithAttrs(cmd, &winsize, getPtyAttr()) - if err != nil { - return err - } - - vt.Resize(w, h) - vt.parser = NewParser(vt.pty) - go func() { - defer vt.recover() - for { - select { - case ev := <-vt.events: - vt.eventHandler(ev) - default: - seq := vt.parser.Next() - switch seq := seq.(type) { - case EOF: - vt.eventHandler(&EventClosed{ - EventTerminal: newEventTerminal(vt), - }) - return - default: - vt.update(seq) - } - } - } - }() - return nil -} - -func (vt *VT) update(seq Sequence) { - vt.mu.Lock() - defer vt.mu.Unlock() - switch seq := seq.(type) { - case Print: - vt.print(rune(seq)) - case C0: - vt.c0(rune(seq)) - case ESC: - esc := append(seq.Intermediate, seq.Final) - vt.esc(string(esc)) - case CSI: - csi := append(seq.Intermediate, seq.Final) - vt.csi(string(csi), seq.Parameters) - case OSC: - vt.osc(string(seq.Payload)) - case DCS: - case DCSData: - case DCSEndOfData: - } - // TODO optimize when we post EventRedraw - if !vt.dirty { - vt.dirty = true - vt.postEvent(&EventRedraw{ - EventTerminal: newEventTerminal(vt), - }) - } -} - -func (vt *VT) String() string { - vt.mu.Lock() - defer vt.mu.Unlock() - str := strings.Builder{} - for row := range vt.activeScreen { - for col := range vt.activeScreen[row] { - _, _ = str.WriteRune(vt.activeScreen[row][col].rune()) - for _, comb := range vt.activeScreen[row][col].combining { - _, _ = str.WriteRune(comb) - } - } - if row < vt.height()-1 { - str.WriteRune('\n') - } - } - return str.String() -} - -func (vt *VT) recover() { - err := recover() - if err == nil { - return - } - ret := strings.Builder{} - ret.WriteString(fmt.Sprintf("cursor row=%d col=%d\n", vt.cursor.row, vt.cursor.col)) - ret.WriteString(fmt.Sprintf("margin left=%d right=%d\n", vt.margin.left, vt.margin.right)) - ret.WriteString(fmt.Sprintf("%s\n", err)) - ret.Write(debug.Stack()) - - vt.postEvent(&EventPanic{ - EventTerminal: newEventTerminal(vt), - Error: fmt.Errorf("%s", ret.String()), - }) - vt.Close() -} - -// row, col, style, vis -func (vt *VT) Cursor() (int, int, tcell.CursorStyle, bool) { - vt.mu.Lock() - defer vt.mu.Unlock() - vis := vt.mode&dectcem > 0 - return int(vt.cursor.row), int(vt.cursor.col), vt.cursor.style, vis -} - -func (vt *VT) Resize(w int, h int) { - primary := vt.primaryScreen - vt.altScreen = make([][]cell, h) - vt.primaryScreen = make([][]cell, h) - for i := range vt.altScreen { - vt.altScreen[i] = make([]cell, w) - vt.primaryScreen[i] = make([]cell, w) - } - last := vt.cursor.row - vt.margin.bottom = row(h) - 1 - vt.margin.right = column(w) - 1 - vt.cursor.row = 0 - vt.cursor.col = 0 - vt.lastCol = false - vt.activeScreen = vt.primaryScreen - - // transfer primary to new, skipping the last row - for row := 0; row < len(primary); row += 1 { - if row == int(last) { - break - } - wrapped := false - for col := 0; col < len(primary[0]); col += 1 { - cell := primary[row][col] - vt.cursor.attrs = cell.attrs - vt.print(cell.content) - wrapped = cell.wrapped - } - if !wrapped { - vt.nel() - } - } - switch vt.mode & smcup { - case 0: - vt.activeScreen = vt.primaryScreen - default: - vt.activeScreen = vt.altScreen - } - /* - nextScrollback := [][]cell{} - currentRow := []cell{} - for _, row := range vt.primaryScrollback { - for col, c := range row { - if col >= w { - nextScrollback = append(nextScrollback, currentRow) - currentRow = []cell{} - } - currentRow = append(currentRow, c) - } - } - vt.primaryScrollback = nextScrollback - */ - - _ = pty.Setsize(vt.pty, &pty.Winsize{ - Cols: uint16(w), - Rows: uint16(h), - }) -} - -func (vt *VT) width() int { - if len(vt.activeScreen) > 0 { - return len(vt.activeScreen[0]) - } - return 0 -} - -func (vt *VT) height() int { - return len(vt.activeScreen) -} - -// print sets the current cell contents to the given rune. The attributes will -// be copied from the current cursor attributes -func (vt *VT) print(r rune) { - if vt.charsets.designations[vt.charsets.selected] == decSpecialAndLineDrawing { - shifted, ok := decSpecial[r] - if ok { - r = shifted - } - } - - // If we are single-shifted, move the previous charset into the current - if vt.charsets.singleShift { - vt.charsets.selected = vt.charsets.saved - } - - if vt.cursor.col == vt.margin.right && vt.lastCol { - col := vt.cursor.col - rw := vt.cursor.row - vt.activeScreen[rw][col].wrapped = true - vt.nel() - } - - col := vt.cursor.col - rw := vt.cursor.row - w := runewidth.RuneWidth(r) - - if vt.mode&irm != 0 { - line := vt.activeScreen[rw] - for i := vt.margin.right; i > col; i -= 1 { - line[i] = line[i-column(w)] - } - } - if col > column(vt.width())-1 { - col = column(vt.width()) - 1 - } - if rw > row(vt.height()-1) { - rw = row(vt.height() - 1) - } - - if w == 0 { - if col-1 < 0 { - return - } - vt.activeScreen[rw][col-1].combining = append(vt.activeScreen[rw][col-1].combining, r) - return - } - cell := cell{ - content: r, - width: w, - attrs: vt.cursor.attrs, - } - - vt.activeScreen[rw][col] = cell - - // Set trailing cells to a space if wide rune - for i := column(1); i < column(w); i += 1 { - if col+i > vt.margin.right { - break - } - vt.activeScreen[rw][col+i].content = ' ' - vt.activeScreen[rw][col+i].attrs = vt.cursor.attrs - } - - switch { - case vt.mode&decawm != 0 && col == vt.margin.right: - vt.lastCol = true - case col == vt.margin.right: - // don't move the cursor - default: - vt.cursor.col += column(w) - } -} - -// scrollUp shifts all text upward by n rows. Semantically, this is backwards - -// usually scroll up would mean you shift rows down -func (vt *VT) scrollUp(n int) { - for i := 0; i < n; i += 1 { - history := make([]cell, len(vt.activeScreen[i])) - copy(history, vt.activeScreen[i]) - vt.primaryScrollback = append(vt.primaryScrollback, history) - } - for row := range vt.activeScreen { - if row > int(vt.margin.bottom) { - continue - } - if row < int(vt.margin.top) { - continue - } - if row+n > int(vt.margin.bottom) { - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[row][col].erase(vt.cursor.attrs) - } - continue - } - copy(vt.activeScreen[row], vt.activeScreen[row+n]) - } -} - -// scrollDown shifts all lines down by n rows. -func (vt *VT) scrollDown(n int) { - for r := vt.margin.bottom; r >= vt.margin.top; r -= 1 { - if r-row(n) < vt.margin.top { - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - continue - } - copy(vt.activeScreen[r], vt.activeScreen[r-row(n)]) - } -} - -func (vt *VT) Close() { - if vt.cmd != nil && vt.cmd.Process != nil { - process.Kill(vt.cmd.Process) - } - vt.mu.Lock() - defer vt.mu.Unlock() - vt.pty.Close() -} - -func (vt *VT) Attach(fn func(ev tcell.Event)) { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.eventHandler = fn -} - -func (vt *VT) Detach() { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.eventHandler = func(ev tcell.Event) { - return - } -} - -func (vt *VT) postEvent(ev tcell.Event) { - vt.events <- ev -} - -func (vt *VT) SetSurface(srf Surface) { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.surface = srf -} - -func (vt *VT) ScrollUp(offset int) { - if !vt.IsScrolling() { - if len(vt.primaryScrollback) == 0 { - return - } - vt.scroll = len(vt.primaryScrollback) - } - vt.scroll = vt.scroll - offset - vt.scroll = max(0, vt.scroll) -} - -func (vt *VT) ScrollDown(offset int) { - if !vt.IsScrolling() { - return - } - vt.scroll = vt.scroll + offset - if vt.scroll >= len(vt.primaryScrollback) { - vt.ScrollReset() - } -} - -func (vt *VT) ScrollReset() { - vt.scroll = -1 -} - -func (vt *VT) ClearScrollback() { - vt.primaryScrollback = [][]cell{} -} - -func (vt *VT) Scrollable() bool { - return len(vt.primaryScrollback) > 0 -} - -func (vt *VT) IsScrolling() bool { - return vt.scroll != -1 -} - -func (vt *VT) Draw() { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.dirty = false - if vt.surface == nil { - return - } - offset := 0 - vt.selection.content = strings.Builder{} - if vt.IsScrolling() { - for x := vt.scroll; x < len(vt.primaryScrollback); x += 1 { - if offset >= vt.height() { - break - } - vt.drawRow(offset, vt.primaryScrollback[x]) - offset += 1 - } - } - for cols := range vt.activeScreen { - if offset >= vt.height() { - break - } - vt.drawRow(offset, vt.activeScreen[cols]) - offset++ - } -} - -func (vt *VT) drawRow(row int, cols []cell) { - scrollOffset := len(vt.primaryScrollback) - if vt.scroll != -1 { - scrollOffset = vt.scroll - } - builder := strings.Builder{} - for col := 0; col < len(cols); { - cell := cols[col] - w := cell.width - content := cell.content - if cell.content == '\x00' { - content = ' ' - w = 1 - } - style := cell.attrs - if vt.selection != nil && isCellSelected(col, row+scrollOffset, vt.selection.startX, vt.selection.startY, vt.selection.endX, vt.selection.endY) { - style = style.Reverse(true) - builder.WriteRune(content) - } - vt.surface.SetContent(col, row, content, cell.combining, style) - if w == 0 { - w = 1 - } - col += 1 - } - if builder.Len() > 0 { - vt.selection.content.WriteString(strings.TrimRight(builder.String(), " ")) - vt.selection.content.WriteRune('\n') - } -} - -func (vt *VT) HandleEvent(e tcell.Event) bool { - vt.mu.Lock() - defer vt.mu.Unlock() - switch e := e.(type) { - case *tcell.EventKey: - vt.pty.WriteString(keyCode(e)) - return true - case *tcell.EventPaste: - switch { - case vt.mode&paste == 0: - return false - case e.Start(): - vt.pty.WriteString(info.PasteStart) - return true - case e.End(): - vt.pty.WriteString(info.PasteEnd) - return true - } - case *tcell.EventMouse: - str := vt.handleMouse(e) - vt.pty.WriteString(str) - } - return false -} - -func (vt *VT) Clear() { - vt.ris() -} - -func (vt *VT) Copy() string { - return strings.TrimRightFunc(vt.selection.content.String(), unicode.IsSpace) -} - -func (vt *VT) SelectStart(x int, y int) { - scrollOffset := len(vt.primaryScrollback) - if vt.scroll != -1 { - scrollOffset = vt.scroll - } - y += scrollOffset - vt.selection = &selection{ - startX: x, - startY: y, - endX: -1, - endY: -1, - } -} - -func (vt *VT) SelectEnd(x int, y int) { - scrollOffset := len(vt.primaryScrollback) - if vt.scroll != -1 { - scrollOffset = vt.scroll - } - y += scrollOffset - vt.selection.endX = x - vt.selection.endY = y -} - -func (vt *VT) HasSelection() bool { - return vt.selection.endX != -1 && vt.selection.endY != -1 -} - -func (vt *VT) ClearSelection() { - vt.selection.startX = 0 - vt.selection.startY = 0 - vt.selection.endX = -1 - vt.selection.endY = -1 -} - -func isCellSelected(x, y, startX, startY, endX, endY int) bool { - if endX < 0 || endY < 0 { - return false - } - // Normalize the selection coordinates - minY, maxY := startY, endY - minX, maxX := startX, endX - if endY < startY || endY == startY && endX < startX { - minY, maxY = endY, startY - minX, maxX = endX, startX - } - // Check if the cell is within the selection - if y > minY && y < maxY { - return true // Full line selected - } - if y == minY && y == maxY { - return x >= minX && x <= maxX // Single line selection - } - if y == minY { - return x >= minX // First line of multi-line selection - } - if y == maxY { - return x <= maxX // Last line of multi-line selection - } - return false -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt_test.go deleted file mode 100644 index 54e24ccc63..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt_test.go +++ /dev/null @@ -1,148 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestResize(t *testing.T) { - vt := New() - w := 4 - h := 1 - vt.Resize(w, h) - assert.Equal(t, h, len(vt.activeScreen)) - assert.Equal(t, w, len(vt.activeScreen[0])) -} - -func TestString(t *testing.T) { - vt := New() - w := 2 - h := 1 - vt.Resize(w, h) - assert.Equal(t, " ", vt.String()) - - vt.activeScreen[0][0].content = 'v' - vt.activeScreen[0][1].content = 't' - assert.Equal(t, "vt", vt.String()) -} - -func TestPrint(t *testing.T) { - t.Run("No modes", func(t *testing.T) { - vt := New() - vt.mode = 0 - w := 2 - h := 1 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt", vt.String()) - assert.Equal(t, column(1), vt.cursor.col) - vt.print('x') - assert.Equal(t, "vx", vt.String()) - }) - - t.Run("IRM = set", func(t *testing.T) { - vt := New() - w := 4 - h := 1 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - vt.bs() - vt.bs() - assert.Equal(t, column(0), vt.cursor.col) - assert.Equal(t, "vt ", vt.String()) - vt.mode |= irm - vt.print('i') - assert.Equal(t, "ivt ", vt.String()) - vt.print('j') - vt.print('k') - assert.Equal(t, "ijkv", vt.String()) - }) - - t.Run("DECAWM = set", func(t *testing.T) { - vt := New() - w := 3 - h := 2 - vt.Resize(w, h) - vt.mode |= decawm - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt \n ", vt.String()) - vt.print('i') - assert.Equal(t, "vti\n ", vt.String()) - vt.print('j') - assert.Equal(t, "vti\nj ", vt.String()) - }) - - t.Run("Wide character", func(t *testing.T) { - vt := New() - w := 1 - h := 1 - vt.Resize(w, h) - - vt.print('぀') - assert.Equal(t, "぀", vt.String()) - }) -} - -func TestScrollUp(t *testing.T) { - vt := New() - vt.mode = 0 - w := 2 - h := 2 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.scrollUp(1) - assert.Equal(t, " \n ", vt.String()) - - vt = New() - w = 1 - h = 8 - vt.Resize(w, h) - - vt.cursor.row = 4 - vt.print('v') - vt.lastCol = false - vt.cursor.row = 7 - vt.print('t') - vt.margin.bottom = 5 - assert.Equal(t, " \n \n \n \nv\n \n \nt", vt.String()) - vt.scrollUp(1) - assert.Equal(t, " \n \n \nv\n \n \n \nt", vt.String()) -} - -func TestScrollDown(t *testing.T) { - vt := New() - w := 2 - h := 2 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.scrollDown(1) - assert.Equal(t, " \nvt", vt.String()) - vt.lastCol = false - vt.print('b') - assert.Equal(t, " b\nvt", vt.String()) - vt.scrollDown(1) - assert.Equal(t, " \n b", vt.String()) -} - -func TestCombiningRunes(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('h') - vt.print(0x337) - vt.print(0x317) - - assert.Equal(t, "hΜ·Μ— \n ", vt.String()) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt_unix.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt_unix.go deleted file mode 100644 index b5494ad00b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt_unix.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !windows -// +build !windows - -package tcellterm - -import "syscall" - -func getPtyAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{ - Setsid: true, - Setctty: true, - Ctty: 1, - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt_windows.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt_windows.go deleted file mode 100644 index 50fdcee4f5..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt_windows.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build windows -// +build windows - -package tcellterm - -import "syscall" - -func getPtyAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{} -} diff --git a/cmd/sst/mosaic/multiplexer/terminfo.go b/cmd/sst/mosaic/multiplexer/terminfo.go deleted file mode 100644 index f980a4773e..0000000000 --- a/cmd/sst/mosaic/multiplexer/terminfo.go +++ /dev/null @@ -1,289 +0,0 @@ -package multiplexer - -import "github.com/gdamore/tcell/v2/terminfo" - -// extended terminfo defines additional keys in a singular place, if missing -// from the terminfo.Terminfo struct -type extendedTerminfo struct { - KeyAltInsert string - KeyAltDelete string - KeyAltPgUp string - KeyAltPgDown string - - KeyCtrlInsert string - KeyCtrlDelete string - KeyCtrlPgUp string - KeyCtrlPgDown string - - KeyCtrlShfInsert string - KeyCtrlShfDelete string - KeyCtrlShfPgUp string - KeyCtrlShfPgDown string - - KeyAltShfInsert string - KeyAltShfDelete string - KeyAltShfPgUp string - KeyAltShfPgDown string - - KeyCtrlAltUp string - KeyCtrlAltDown string - KeyCtrlAltRight string - KeyCtrlAltLeft string - KeyCtrlAltHome string - KeyCtrlAltEnd string - KeyCtrlAltInsert string - KeyCtrlAltDelete string - KeyCtrlAltPgUp string - KeyCtrlAltPgDown string - - KeyCtrlAltShfUp string - KeyCtrlAltShfDown string - KeyCtrlAltShfRight string - KeyCtrlAltShfLeft string - KeyCtrlAltShfHome string - KeyCtrlAltShfEnd string - KeyCtrlAltShfInsert string - KeyCtrlAltShfDelete string - KeyCtrlAltShfPgUp string - KeyCtrlAltShfPgDown string -} - -var extendedInfo = &extendedTerminfo{ - KeyAltInsert: "\x1b[2;3~", - KeyAltDelete: "\x1b[3;3~", - KeyAltPgUp: "\x1b[5;3~", - KeyAltPgDown: "\x1b[6;3~", - - KeyCtrlInsert: "\x1b[2;5~", - KeyCtrlDelete: "\x1b[3;5~", - KeyCtrlPgUp: "\x1b[5;5~", - KeyCtrlPgDown: "\x1b[6;5~", - - KeyCtrlShfInsert: "\x1b[2;6~", - KeyCtrlShfDelete: "\x1b[3;6~", - KeyCtrlShfPgUp: "\x1b[5;6~", - KeyCtrlShfPgDown: "\x1b[6;6~", - - KeyAltShfInsert: "\x1b[2;4~", - KeyAltShfDelete: "\x1b[3;4~", - KeyAltShfPgUp: "\x1b[5;4~", - KeyAltShfPgDown: "\x1b[6;4~", - - KeyCtrlAltUp: "\x1b[1;7A", - KeyCtrlAltDown: "\x1b[1;7B", - KeyCtrlAltRight: "\x1b[1;7C", - KeyCtrlAltLeft: "\x1b[1;7D", - KeyCtrlAltHome: "\x1b[1;7H", - KeyCtrlAltEnd: "\x1b[1;7F", - KeyCtrlAltInsert: "\x1b[2;7~", - KeyCtrlAltDelete: "\x1b[3;7~", - KeyCtrlAltPgUp: "\x1b[5;7~", - KeyCtrlAltPgDown: "\x1b[6;7~", - - KeyCtrlAltShfUp: "\x1b[1;8A", - KeyCtrlAltShfDown: "\x1b[1;8B", - KeyCtrlAltShfRight: "\x1b[1;8C", - KeyCtrlAltShfLeft: "\x1b[1;8D", - KeyCtrlAltShfHome: "\x1b[1;8H", - KeyCtrlAltShfEnd: "\x1b[1;8F", - KeyCtrlAltShfInsert: "\x1b[2;8~", - KeyCtrlAltShfDelete: "\x1b[3;8~", - KeyCtrlAltShfPgUp: "\x1b[5;8~", - KeyCtrlAltShfPgDown: "\x1b[6;8~", -} - -var info = &terminfo.Terminfo{ - Name: "tcell-term", - Aliases: []string{}, - Columns: 80, // cols - Lines: 24, // lines - Colors: 256, // colors - Bell: "\a", // bell - Clear: "\x1b[H\x1b[2J", // clear - EnterCA: "\x1b[?1049h", // smcup - ExitCA: "\x1b[?1049l", // rmcup - ShowCursor: "\x1b[?12l\x1b[?25h", // cnorm - HideCursor: "\x1b[?25l", // civis - AttrOff: "\x1b(B\x1b[m", // sgr0 - Underline: "\x1b[4m", // smul - Bold: "\x1b[1m", // bold - Blink: "\x1b[5m", // blink - Reverse: "\x1b[7m", // rev - Dim: "\x1b[2m", // dim - Italic: "\x1b[3m", // sitm - EnterKeypad: "", // smkx - ExitKeypad: "", // rmkx - - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m", // setaf - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m", // setab - - ResetFgBg: "\x1b[39;49m", // op - SetCursor: "\x1b[%i%p1%d;%p2%dH", // cup - CursorBack1: "\b", // cub1 - CursorUp1: "\x1b[A", // cuu1 - PadChar: "\x00", // pad - KeyBackspace: "\x7F", // kbs - KeyF1: "\x1bOP", // kf1 - KeyF2: "\x1bOQ", // kf2 - KeyF3: "\x1bOR", // kf3 - KeyF4: "\x1bOS", // kf4 - KeyF5: "\x1b[15~", // kf5 - KeyF6: "\x1b[17~", // kf6 - KeyF7: "\x1b[18~", // kf7 - KeyF8: "\x1b[19~", // kf8 - KeyF9: "\x1b[20~", // kf9 - KeyF10: "\x1b[21~", // kf10 - KeyF11: "\x1b[23~", // kf11 - KeyF12: "\x1b[24~", // kf12 - KeyF13: "\x1b[1;2P", // kf13 - KeyF14: "\x1b[1;2Q", // kf14 - KeyF15: "\x1b[1;2R", // kf15 - KeyF16: "\x1b[1;2S", // kf16 - KeyF17: "\x1b[15;2~", // kf17 - KeyF18: "\x1b[17;2~", // kf18 - KeyF19: "\x1b[18;2~", // kf19 - KeyF20: "\x1b[19;2~", // kf20 - KeyF21: "\x1b[20;2~", // kf21 - KeyF22: "\x1b[21;2~", // kf22 - KeyF23: "\x1b[23;2~", // kf23 - KeyF24: "\x1b[24;2~", // kf24 - KeyF25: "\x1b[1;5P", // kf25 - KeyF26: "\x1b[1;5Q", // kf26 - KeyF27: "\x1b[1;5R", // kf27 - KeyF28: "\x1b[1;5S", // kf28 - KeyF29: "\x1b[15;5~", // kf29 - KeyF30: "\x1b[17;5~", // kf30 - KeyF31: "\x1b[18;5~", // kf31 - KeyF32: "\x1b[19;5~", // kf32 - KeyF33: "\x1b[20;5~", // kf33 - KeyF34: "\x1b[21;5~", // kf34 - KeyF35: "\x1b[23;5~", // kf35 - KeyF36: "\x1b[24;5~", // kf36 - KeyF37: "\x1b[1;6P", // kf37 - KeyF38: "\x1b[1;6Q", // kf38 - KeyF39: "\x1b[1;6R", // kf39 - KeyF40: "\x1b[1;6S", // kf40 - KeyF41: "\x1b[15;6~", // kf41 - KeyF42: "\x1b[17;6~", // kf42 - KeyF43: "\x1b[18;6~", // kf43 - KeyF44: "\x1b[19;6~", // kf44 - KeyF45: "\x1b[20;6~", // kf45 - KeyF46: "\x1b[21;6~", // kf46 - KeyF47: "\x1b[23;6~", // kf47 - KeyF48: "\x1b[24;6~", // kf48 - KeyF49: "\x1b[1;3P", // kf49 - KeyF50: "\x1b[1;3Q", // kf50 - KeyF51: "\x1b[1;3R", // kf51 - KeyF52: "\x1b[1;3S", // kf52 - KeyF53: "\x1b[15;3~", // kf53 - KeyF54: "\x1b[17;3~", // kf54 - KeyF55: "\x1b[18;3~", // kf55 - KeyF56: "\x1b[19;3~", // kf56 - KeyF57: "\x1b[20;3~", // kf57 - KeyF58: "\x1b[21;3~", // kf58 - KeyF59: "\x1b[23;3~", // kf59 - KeyF60: "\x1b[24;3~", // kf60 - KeyF61: "\x1b[1;4P", // kf61 - KeyF62: "\x1b[1;4Q", // kf62 - KeyF63: "\x1b[1;4R", // kf63 - KeyF64: "\x1b[1;4S", // kf64 - KeyInsert: "\x1b[2~", // kich1 - KeyDelete: "\x1b[3~", // kdch1 - KeyHome: "\x1bOH", // khome - KeyEnd: "\x1bOF", // kend - KeyHelp: "", // khlp - KeyPgUp: "\x1b[5~", // kpp - KeyPgDn: "\x1b[6~", // knp - KeyUp: "\x1bOA", // kcuu1 - KeyDown: "\x1bOB", // kcud1 - KeyRight: "\x1bOC", // kcuf1 - KeyLeft: "\x1bOD", // kcub1 - KeyBacktab: "\x1b[Z", // kcbt - KeyExit: "", // kext - KeyClear: "", // kclr - KeyPrint: "", // kprt - KeyCancel: "", // kcan - Mouse: "\x1b[<", // kmous - AltChars: "", // acsc - EnterAcs: "\x1b(0", // smacs - ExitAcs: "\x1b(B", // rmacs - EnableAcs: "", // enacs - KeyShfUp: "\x1b[1;2A", // kri - KeyShfDown: "\x1b[1;2B", // kind - KeyShfRight: "\x1b[1;2C", // kRIT - KeyShfLeft: "\x1b[1;2D", // kLFT - KeyShfHome: "\x1b[1;2H", // kHOM - KeyShfEnd: "\x1b[1;2F", // kEND - KeyShfInsert: "\x1b[2;2~", // kIC - KeyShfDelete: "\x1b[3;2~", // kDC - - // These are non-standard extensions to terminfo. This includes - // true color support, and some additional keys. Its kind of bizarre - // that shifted variants of left and right exist, but not up and down. - // Terminal support for these are going to vary amongst XTerm - // emulations, so don't depend too much on them in your application. - - StrikeThrough: "", // smxx - - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48:5:%p2%d%;m", // setfgbg - - SetFgBgRGB: "", // setfgbgrgb - SetFgRGB: "", // setfrgb - SetBgRGB: "", // setbrgb - KeyShfPgUp: "\x1b[5;2~", // kPRV - KeyShfPgDn: "\x1b[6;2~", // kNXT - KeyCtrlUp: "\x1b[1;5A", // ctrl-up - KeyCtrlDown: "\x1b[1;5B", // ctrl-left - KeyCtrlRight: "\x1b[1;5C", // ctrl-right - KeyCtrlLeft: "\x1b[1;5D", // ctrl-left - KeyMetaUp: "\x1b[1;9A", // meta-up - KeyMetaDown: "\x1b[1;9B", // meta-left - KeyMetaRight: "\x1b[1;9C", // meta-right - KeyMetaLeft: "\x1b[1;9D", // meta-left - KeyAltUp: "\x1b[1;3A", // alt-up - KeyAltDown: "\x1b[1;3B", // alt-left - KeyAltRight: "\x1b[1;3C", // alt-right - KeyAltLeft: "\x1b[1;3D", // alt-left - KeyCtrlHome: "\x1b[1;5H", - KeyCtrlEnd: "\x1b[1;5F", - KeyMetaHome: "\x1b[1;9H", - KeyMetaEnd: "\x1b[1;9F", - KeyAltHome: "\x1b[1;3H", - KeyAltEnd: "\x1b[1;3F", - KeyAltShfUp: "\x1b[1;4A", - KeyAltShfDown: "\x1b[1;4B", - KeyAltShfRight: "\x1b[1;4C", - KeyAltShfLeft: "\x1b[1;4D", - KeyMetaShfUp: "\x1b[1;10A", - KeyMetaShfDown: "\x1b[1;10B", - KeyMetaShfLeft: "\x1b[1;10C", - KeyMetaShfRight: "\x1b[1;10D", - KeyCtrlShfUp: "\x1b[1;6A", - KeyCtrlShfDown: "\x1b[1;6B", - KeyCtrlShfRight: "\x1b[1;6C", - KeyCtrlShfLeft: "\x1b[1;6D", - KeyCtrlShfHome: "\x1b[1;6H", - KeyCtrlShfEnd: "\x1b[1;6F", - KeyAltShfHome: "\x1b[1;4H", - KeyAltShfEnd: "\x1b[1;4F", - KeyMetaShfHome: "\x1b[1;10H", - KeyMetaShfEnd: "\x1b[1;10F", - EnablePaste: "\x1b[?2004h", // BE - DisablePaste: "\x1b[?2004l", // BD - PasteStart: "\x1b[200~", // PS - PasteEnd: "\x1b[201~", // PE - Modifiers: 1, - InsertChar: "\x1b[@", // string to insert a character (ich1) - AutoMargin: true, // true if writing to last cell in line advances - TrueColor: true, // true if the terminal supports direct color - CursorDefault: "\x1b[0 q", // Se - CursorBlinkingBlock: "\x1b[1 q", - CursorSteadyBlock: "\x1b[2 q", - CursorBlinkingUnderline: "\x1b[3 q", - CursorSteadyUnderline: "\x1b[4 q", - CursorBlinkingBar: "\x1b[5 q", - CursorSteadyBar: "\x1b[6 q", - EnterUrl: "\x1b]8;%p2%s;%p1%s\x1b\\", - ExitUrl: "\x1b]8;;\x1b\\", - SetWindowSize: "", -} diff --git a/cmd/sst/mosaic/socket/socket.go b/cmd/sst/mosaic/socket/socket.go deleted file mode 100644 index b8c34dfdd4..0000000000 --- a/cmd/sst/mosaic/socket/socket.go +++ /dev/null @@ -1,241 +0,0 @@ -package socket - -import ( - "context" - "encoding/json" - "log/slog" - "net/http" - "time" - - "github.com/charmbracelet/x/ansi" - "github.com/gorilla/websocket" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" -) - -var upgrader = websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { return true }, -} - -type CliDevEvent struct { - App string `json:"app"` - Stage string `json:"stage"` - Region string `json:"region"` -} - -type Invocation struct { - ID string `json:"id,omitempty"` - Source string `json:"source,omitempty"` - Cold bool `json:"cold,omitempty"` - Input json.RawMessage `json:"input,omitempty"` - Output interface{} `json:"output,omitempty"` - Start int64 `json:"start,omitempty"` - End int64 `json:"end,omitempty"` - Errors []InvocationError `json:"errors"` - Logs []InvocationLog `json:"logs"` - Report *InvocationReport `json:"report,omitempty"` -} - -type InvocationLog struct { - ID string `json:"id,omitempty"` - Timestamp int64 `json:"timestamp,omitempty"` - Message string `json:"message,omitempty"` -} - -type InvocationReport struct { - Duration int64 `json:"duration"` - Init int64 `json:"init"` - Size int64 `json:"size"` - Memory int64 `json:"memory"` - Xray string `json:"xray"` -} - -type InvocationError struct { - ID string `json:"id"` - Error string `json:"error"` - Message string `json:"message"` - Stack []Frame `json:"stack"` - Failed bool `json:"failed"` -} - -type Frame struct { - Raw string `json:"raw"` -} - -func Start(ctx context.Context, p *project.Project, server *server.Server) error { - log := slog.Default().With("service", "socket") - connected := make(chan *websocket.Conn) - disconnected := make(chan *websocket.Conn) - invocationClear := make(chan string) - server.Mux.HandleFunc("/socket", func(w http.ResponseWriter, r *http.Request) { - log.Info("socket upgrading", "addr", r.RemoteAddr) - ws, err := upgrader.Upgrade(w, r, nil) - if err != nil { - return - } - defer ws.Close() - - connected <- ws - defer func() { - disconnected <- ws - }() - - for { - _, data, err := ws.ReadMessage() - if err != nil { - log.Info("socket error", "err", err) - break - } - - log.Info("socket message", "message", string(data)) - var message map[string]interface{} - err = json.Unmarshal(data, &message) - if err != nil { - continue - } - - if message["type"] == "log.cleared" { - source := message["properties"].(map[string]interface{})["source"].(string) - invocationClear <- source - } - - } - }) - sockets := make(map[*websocket.Conn]struct{}) - invocations := make(map[string]*Invocation) - - evts := bus.SubscribeAll() - - publish := func(evt interface{}) { - for ws := range sockets { - ws.WriteJSON(evt) - } - } - - publishInvocation := func(invocation *Invocation) { - publish(map[string]interface{}{ - "type": "invocation", - "properties": []*Invocation{ - invocation, - }, - }) - } - - var complete *project.CompleteEvent - - for { - select { - case <-ctx.Done(): - return nil - case source := <-invocationClear: - if source == "all" { - invocations = map[string]*Invocation{} - break - } - for id, invocation := range invocations { - if invocation.Source == source { - delete(invocations, id) - } - } - break - - case unknown := <-evts: - switch evt := unknown.(type) { - case *project.CompleteEvent: - complete = evt - break - case *aws.FunctionInvokedEvent: - source := "" - if complete != nil { - for _, resource := range complete.Resources { - if resource.URN.Name() == evt.FunctionID && resource.Type == "sst:aws:Function" { - source = string(resource.URN) - } - } - } - invocation := &Invocation{ - ID: evt.RequestID, - Source: source, - Input: json.RawMessage(evt.Input), - Start: time.Now().UnixMilli(), - Errors: []InvocationError{}, - Logs: []InvocationLog{}, - } - invocations[evt.RequestID] = invocation - publishInvocation(invocation) - break - case *aws.FunctionResponseEvent: - invocation, ok := invocations[evt.RequestID] - if ok { - invocation.Output = json.RawMessage(evt.Output) - invocation.End = time.Now().UnixMilli() - invocation.Report = &InvocationReport{ - Duration: invocation.End - invocation.Start, - } - publishInvocation(invocation) - } - break - case *aws.FunctionErrorEvent: - invocation, ok := invocations[evt.RequestID] - if ok { - invocation.End = time.Now().UnixMilli() - invocation.Report = &InvocationReport{ - Duration: invocation.End - invocation.Start, - } - error := InvocationError{ - Message: evt.ErrorMessage, - Error: evt.ErrorType, - Failed: true, - Stack: []Frame{}, - } - for _, frame := range evt.Trace { - error.Stack = append(error.Stack, Frame{ - Raw: frame, - }) - } - invocation.Errors = append(invocation.Errors, error) - publishInvocation(invocation) - } - break - case *aws.FunctionLogEvent: - invocation, ok := invocations[evt.RequestID] - if ok { - invocation.Logs = append(invocation.Logs, InvocationLog{ - ID: time.Now().String(), - Timestamp: time.Now().UnixMilli(), - Message: ansi.Strip(evt.Line), - }) - publishInvocation(invocation) - } - break - } - case ws := <-connected: - log.Info("socket connected", "addr", ws.RemoteAddr()) - sockets[ws] = struct{}{} - ws.WriteJSON(map[string]interface{}{ - "type": "cli.dev", - "properties": CliDevEvent{ - App: p.App().Name, - Stage: p.App().Stage, - }, - }) - all := []*Invocation{} - for _, invocation := range invocations { - all = append(all, invocation) - } - log.Info("sending invocations", "count", len(all)) - ws.WriteJSON(map[string]interface{}{ - "type": "invocation", - "properties": all, - }) - break - case ws := <-disconnected: - log.Info("socket disconnected", "addr", ws.RemoteAddr()) - delete(sockets, ws) - break - } - } - -} diff --git a/cmd/sst/mosaic/ui/common/common.go b/cmd/sst/mosaic/ui/common/common.go deleted file mode 100644 index 3afb323c5b..0000000000 --- a/cmd/sst/mosaic/ui/common/common.go +++ /dev/null @@ -1,5 +0,0 @@ -package common - -type StdoutEvent struct { - Line string -} diff --git a/cmd/sst/mosaic/ui/diff.go b/cmd/sst/mosaic/ui/diff.go deleted file mode 100644 index e3387903a3..0000000000 --- a/cmd/sst/mosaic/ui/diff.go +++ /dev/null @@ -1,95 +0,0 @@ -package ui - -import ( - "fmt" - "reflect" - "strings" -) - -type DiffEntry struct { - Path string - Old interface{} - New interface{} -} - -func Diff(old map[string]interface{}, new map[string]interface{}, path ...string) []DiffEntry { - var result []DiffEntry - - for key, newValue := range new { - newPath := append(path, key) - pathString := strings.Join(newPath, ".") - - oldValue, exists := old[key] - if !exists { - result = append(result, DiffEntry{Path: pathString, Old: nil, New: newValue}) - continue - } - - switch typedNew := newValue.(type) { - case map[string]interface{}: - if typedOld, ok := oldValue.(map[string]interface{}); ok { - result = append(result, Diff(typedOld, typedNew, newPath...)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - case []interface{}: - if typedOld, ok := oldValue.([]interface{}); ok { - result = append(result, diffArray(typedOld, typedNew, newPath)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - default: - if !reflect.DeepEqual(oldValue, newValue) { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - } - } - - for key, oldValue := range old { - if _, exists := new[key]; !exists { - deletedPath := append(path, key) - result = append(result, DiffEntry{Path: strings.Join(deletedPath, "."), Old: oldValue, New: nil}) - } - } - - return result -} - -func diffArray(old []interface{}, new []interface{}, path []string) []DiffEntry { - var result []DiffEntry - - for i := 0; i < len(new) || i < len(old); i++ { - indexPath := append(path, fmt.Sprintf("[%d]", i)) - pathString := strings.Join(indexPath, ".") - - if i >= len(old) { - result = append(result, DiffEntry{Path: pathString, Old: nil, New: new[i]}) - } else if i >= len(new) { - result = append(result, DiffEntry{Path: pathString, Old: old[i], New: nil}) - } else { - oldValue := old[i] - newValue := new[i] - - switch typedNew := newValue.(type) { - case map[string]interface{}: - if typedOld, ok := oldValue.(map[string]interface{}); ok { - result = append(result, Diff(typedOld, typedNew, indexPath...)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - case []interface{}: - if typedOld, ok := oldValue.([]interface{}); ok { - result = append(result, diffArray(typedOld, typedNew, indexPath)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - default: - if !reflect.DeepEqual(oldValue, newValue) { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - } - } - } - - return result -} diff --git a/cmd/sst/mosaic/ui/error.go b/cmd/sst/mosaic/ui/error.go deleted file mode 100644 index a07f92d5a6..0000000000 --- a/cmd/sst/mosaic/ui/error.go +++ /dev/null @@ -1,59 +0,0 @@ -package ui - -import ( - "regexp" - "strings" -) - -func parseError(input string) []string { - input = strings.TrimRight(input, "\n") - if strings.Contains(input, "failed with an unhandled exception") { - input = regexp.MustCompile(`(?m)^Running program .*$\n?`).ReplaceAllString(input, "") - input = regexp.MustCompile(`\s*`).ReplaceAllString(input, "") - input = strings.TrimSpace(input) - lines := strings.Split(input, "\n") - - // Remove the "VisibleError: " prefix from the first line if it exists - if strings.HasPrefix(lines[0], "VisibleError: ") { - lines[0] = strings.TrimPrefix(lines[0], "VisibleError: ") - - // Find the first line that starts with spaces followed by "at" and - // remove that line and all following lines - for i, line := range lines { - trimmed := strings.TrimLeft(line, " ") - if strings.HasPrefix(trimmed, "at") { - // Remove all lines starting from this point - return lines[:i] - } - } - } - - return lines - } - - if strings.Contains(input, "occurred:") { - lines := []string{} - sections := strings.Split(input, "*") - for _, section := range sections[1:] { - for _, line := range strings.Split(section, "\n") { - line = strings.TrimSpace(line) - - // matches ExampleError: some thing went wrong - match := regexp.MustCompile(`\s[A-Z][a-zA-z]+\:.+`).FindString(line) - if match != "" { - lines = append(lines, strings.TrimSpace(match)) - continue - } - - // if json object is printed stop parsing - if line == "{" { - break - } - - lines = append(lines, line) - } - } - return lines - } - return []string{input} -} diff --git a/cmd/sst/mosaic/ui/error_test.go b/cmd/sst/mosaic/ui/error_test.go deleted file mode 100644 index 3fe25b1473..0000000000 --- a/cmd/sst/mosaic/ui/error_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package ui - -import ( - "reflect" - "testing" -) - -var examples = map[string][]string{ - "1 error occurred:\n\t* creating EventBridge Target (nextjs-frank-WebWarmerRule-WebWarmerTarget-1d76e5b): InvalidParameter: 1 validation error(s) found.\n- minimum field value of 60, PutTargetsInput.Targets[0].RetryPolicy.MaximumEventAgeInSeconds.\n\n\n\n": { - "InvalidParameter: 1 validation error(s) found.", - "- minimum field value of 60, PutTargetsInput.Targets[0].RetryPolicy.MaximumEventAgeInSeconds.", - }, - "1 error occurred:\n\t* creating Lambda Event Source Mapping (arn:aws:sqs:us-east-1:058264306954:stacks-ils-ion-aboza-BookEmbeddingQueueQueue): InvalidParameterValueException: Queue visibility timeout: 30 seconds is less than Function timeout: 900 seconds\n{\n RespMetadata: {\n StatusCode: 400,\n RequestID: \"4b3c8415-400f-437c-b1ea-af1a5c771c41\"\n },\n Message_: \"Queue visibility timeout: 30 seconds is less than Function timeout: 900 seconds\",\n Type: \"User\"\n}\n\n\n": { - "InvalidParameterValueException: Queue visibility timeout: 30 seconds is less than Function timeout: 900 seconds", - }, -} - -func TestParseError(t *testing.T) { - for input, expected := range examples { - result := parseError(input) - if !reflect.DeepEqual(result, expected) { - t.Errorf("Expected %v, got %v", expected, result) - } - } -} diff --git a/cmd/sst/mosaic/ui/footer.go b/cmd/sst/mosaic/ui/footer.go deleted file mode 100644 index 490a33367f..0000000000 --- a/cmd/sst/mosaic/ui/footer.go +++ /dev/null @@ -1,370 +0,0 @@ -package ui - -import ( - "bytes" - "context" - "fmt" - "os" - "slices" - "sort" - "strings" - "time" - - "github.com/charmbracelet/bubbles/spinner" - "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/x/ansi" - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/pkg/project" - "golang.org/x/crypto/ssh/terminal" -) - -type footer struct { - started bool - mode ProgressMode - complete *project.CompleteEvent - parents map[string]string - summary bool - pending []*apitype.ResourcePreEvent - downloading map[string]*apitype.ProgressEvent - skipped int - cancelled bool - - spinner int - - input chan any - - previous string -} - -type op struct { - urn string -} - -func NewFooter() *footer { - f := footer{ - input: make(chan any), - } - f.Reset() - return &f -} - -func (m *footer) Send(input any) { - m.input <- input -} - -type spinnerTick struct{} - -func (m *footer) Start(ctx context.Context) { - ticker := time.NewTicker(time.Millisecond * 100) - defer ticker.Stop() - go func() { - for range ticker.C { - m.Send(&spinnerTick{}) - } - }() - os.Stdout.WriteString("\033[2l") - os.Stdout.WriteString(ansi.HideCursor) - for { - select { - case <-ctx.Done(): - m.cancelled = true - break - case val, ok := <-m.input: - if !ok { - return - } - width, _, _ := terminal.GetSize(int(os.Stdout.Fd())) - switch evt := val.(type) { - case lineMsg: - m.clear() - fmt.Println(evt) - default: - m.Update(val) - } - next := m.View(width) - m.Render(width, next) - } - } -} - -func (m *footer) clear() { - if m.previous == "" { - return - } - oldLines := strings.Split(m.previous, "\n") - out := &bytes.Buffer{} - if len(oldLines) > 0 { - for i := range oldLines { - out.WriteString(ansi.EraseEntireLine) - if i < len(oldLines)-1 { - out.WriteString(ansi.CursorUp1) - } - } - } - os.Stdout.Write(out.Bytes()) - m.previous = "" -} - -func (m *footer) Render(width int, next string) { - if next == m.previous { - return - } - - var oldLines []string - if m.previous != "" { - oldLines = strings.Split(m.previous, "\n") - } - - var nextLines []string - if next != "" { - nextLines = strings.Split(next, "\n") - } - - out := &bytes.Buffer{} - - if len(oldLines) > 0 { - for i := range oldLines { - if i < len(oldLines)-len(nextLines) { - out.WriteString(ansi.EraseEntireLine) - } - if i < len(oldLines)-1 { - out.WriteString(ansi.CursorUp1) - } - } - } - - for i, line := range nextLines { - if i == 0 { - out.WriteByte('\r') - } - out.WriteString(ansi.Truncate(line, width, "…")) - out.WriteString(ansi.EraseLine(0)) - if i < len(nextLines)-1 { - out.WriteString("\r\n") - } - } - if out.Len() > 0 { - out.WriteString(ansi.CursorLeft(10000)) - os.Stdout.Write(out.Bytes()) - } - m.previous = next -} - -func (m *footer) Reset() { - m.started = false - m.skipped = 0 - m.parents = map[string]string{} - m.pending = []*apitype.ResourcePreEvent{} - m.downloading = map[string]*apitype.ProgressEvent{} - m.complete = nil - m.summary = false - m.cancelled = false -} - -func (m *footer) Update(msg any) { - switch msg := msg.(type) { - case *spinnerTick: - m.spinner++ - case *project.CancelledEvent: - m.cancelled = true - case *project.StackCommandEvent: - m.Reset() - m.started = true - if msg.Command == "diff" { - m.mode = ProgressModeDiff - } - if msg.Command == "refresh" { - m.mode = ProgressModeRefresh - } - if msg.Command == "remove" { - m.mode = ProgressModeRemove - } - if msg.Command == "deploy" { - m.mode = ProgressModeDeploy - } - case *project.CompleteEvent: - if msg.Old { - break - } - m.complete = msg - case *project.ConcurrentUpdateEvent: - m.Reset() - break - case *deployer.DeployFailedEvent: - m.Reset() - break - case *project.SkipEvent: - m.Reset() - break - case *apitype.ResourcePreEvent: - if slices.Contains(IGNORED_RESOURCES, msg.Metadata.Type) { - break - } - if msg.Metadata.Old != nil && msg.Metadata.Old.Parent != "" { - m.parents[msg.Metadata.URN] = msg.Metadata.Old.Parent - } - if msg.Metadata.New != nil && msg.Metadata.New.Parent != "" { - m.parents[msg.Metadata.URN] = msg.Metadata.New.Parent - } - if msg.Metadata.Op == apitype.OpSame || msg.Metadata.Op == apitype.OpRead { - m.skipped++ - } - if msg.Metadata.Op != apitype.OpSame && msg.Metadata.Op != apitype.OpRead { - m.pending = append(m.pending, msg) - } - case *apitype.ProgressEvent: - if msg.Type == apitype.PluginDownload { - m.downloading[msg.ID] = msg - } - case *apitype.SummaryEvent: - m.summary = true - case *apitype.ResOutputsEvent: - m.removePending(msg.Metadata.URN) - case *apitype.DiagnosticEvent: - if msg.URN != "" { - m.removePending(msg.URN) - } - } -} - -func (m *footer) Destroy() { - fmt.Print(ansi.ShowCursor) -} - -var TEXT_HIGHLIGHT = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) -var TEXT_HIGHLIGHT_BOLD = TEXT_HIGHLIGHT.Copy().Bold(true) - -var SPINNER_STYLE = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) - -var TEXT_DIM = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) -var TEXT_DIM_BOLD = TEXT_DIM.Copy().Bold(true) -var TEXT_GRAY = lipgloss.NewStyle().Foreground(lipgloss.Color("245")) -var TEXT_GRAY_BOLD = TEXT_GRAY.Copy().Bold(true) - -var TEXT_NORMAL = lipgloss.NewStyle() -var TEXT_NORMAL_BOLD = TEXT_NORMAL.Copy().Bold(true) - -var TEXT_WARNING = lipgloss.NewStyle().Foreground(lipgloss.Color("11")) -var TEXT_WARNING_BOLD = TEXT_WARNING.Copy().Bold(true) -var TEXT_WARNING_DIM = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) - -var TEXT_DANGER = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) -var TEXT_DANGER_BOLD = TEXT_DANGER.Copy().Bold(true) - -var TEXT_SUCCESS = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) -var TEXT_SUCCESS_BOLD = TEXT_SUCCESS.Copy().Bold(true) - -var TEXT_INFO = lipgloss.NewStyle().Foreground(lipgloss.Color("4")) -var TEXT_INFO_BOLD = TEXT_INFO.Copy().Bold(true) - -func (m *footer) View(width int) string { - if !m.started || m.complete != nil { - return "" - } - spinner := SPINNER_STYLE.Render(spinner.MiniDot.Frames[m.spinner%len(spinner.MiniDot.Frames)]) - result := []string{} - keys := make([]string, 0, len(m.downloading)) - for k := range m.downloading { - keys = append(keys, k) - } - sort.Strings(keys) - - for _, key := range keys { - progress := m.downloading[key] - if progress.Done { - continue - } - splits := strings.Split(progress.ID, ":") - percentage := int(float64(progress.Completed) / float64(progress.Total) * 100) - result = append(result, fmt.Sprintf("%s %-11s %s %d%%", spinner, "Downloading", splits[1], percentage)) - } - for _, r := range m.pending { - label := "Creating" - if r.Metadata.Op == apitype.OpUpdate { - label = "Updating" - } - if r.Metadata.Op == apitype.OpDelete { - label = "Deleting" - } - if r.Metadata.Op == apitype.OpReplace { - label = "Creating" - } - if r.Metadata.Op == apitype.OpRefresh { - label = "Refreshing" - } - if r.Metadata.Op == apitype.OpCreate { - label = "Creating" - } - result = append(result, fmt.Sprintf("%s %-11s %s", spinner, label, m.formatURN(r.Metadata.URN))) - } - label := "Finalizing" - if !m.summary { - if m.mode == ProgressModeDiff { - label = "Generating" - } - if m.mode == ProgressModeRemove { - label = "Removing" - } - if m.mode == ProgressModeRefresh { - label = "Refreshing" - } - if m.mode == ProgressModeDeploy { - label = "Deploying" - } - if m.cancelled { - label = "Cancelling Waiting for pending operations to complete. Press ctrl+c again to force cancel." - } - } - if m.skipped > 0 && !m.cancelled { - label = fmt.Sprintf("%-11s", label) - label += TEXT_DIM.Render(fmt.Sprintf(" %d skipped", m.skipped)) - } - result = append(result, spinner+" "+label) - return lipgloss.NewStyle().MaxWidth(width).Render(lipgloss.JoinVertical(lipgloss.Top, result...)) -} - -func (u *footer) removePending(urn string) { - next := []*apitype.ResourcePreEvent{} - for _, r := range u.pending { - if r.Metadata.URN == urn { - continue - } - next = append(next, r) - } - u.pending = next -} - -func (u *footer) formatURN(urn string) string { - if urn == "" { - return "" - } - - child := resource.URN(urn) - name := child.Name() - typeName := child.Type().DisplayName() - splits := strings.SplitN(child.Name(), ".", 2) - if len(splits) > 1 { - name = splits[0] - typeName = strings.ReplaceAll(splits[1], ".", ":") - } - result := name + " " + typeName - - for { - parent := resource.URN(u.parents[string(child)]) - if parent == "" { - break - } - if parent.Type().DisplayName() == "pulumi:pulumi:Stack" { - break - } - child = parent - } - if string(child) != urn { - result = child.Name() + " " + child.Type().DisplayName() + " β†’ " + result - } - return result -} - -type lineMsg = string diff --git a/cmd/sst/mosaic/ui/logs.go b/cmd/sst/mosaic/ui/logs.go deleted file mode 100644 index 8ab7167ded..0000000000 --- a/cmd/sst/mosaic/ui/logs.go +++ /dev/null @@ -1,74 +0,0 @@ -package ui - -import ( - "encoding/json" -) - -func compactWorkflowLogLine(line string) (string, bool) { - var parsed map[string]any - if err := json.Unmarshal([]byte(line), &parsed); err != nil { - return "", false - } - - if !isWorkflowLogEnvelope(parsed) { - return "", false - } - - message, ok := parsed["message"] - if !ok { - return "", false - } - - switch value := message.(type) { - case string: - return value, true - default: - data, err := json.Marshal(value) - if err != nil { - return "", false - } - return string(data), true - } -} - -func isWorkflowLogEnvelope(parsed map[string]any) bool { - if _, hasMessage := parsed["message"]; !hasMessage { - return false - } - - if !hasStringField(parsed, "timestamp") { - return false - } - - if !hasStringField(parsed, "level") { - return false - } - - if !hasStringField(parsed, "requestId") && !hasStringField(parsed, "AWSrequestId") { - return false - } - - if hasStringField(parsed, "executionArn") { - return true - } - - if hasStringField(parsed, "execution_arn") { - return true - } - - return false -} - -func hasStringField(parsed map[string]any, key string) bool { - value, ok := parsed[key].(string) - return ok && value != "" -} - -func (u *UI) formatFunctionLogLine(line string) string { - formatted, ok := compactWorkflowLogLine(line) - if !ok { - return line - } - - return formatted -} diff --git a/cmd/sst/mosaic/ui/logs_test.go b/cmd/sst/mosaic/ui/logs_test.go deleted file mode 100644 index 33b7d0a07c..0000000000 --- a/cmd/sst/mosaic/ui/logs_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package ui - -import ( - "testing" -) - -func TestCompactWorkflowLogLine(t *testing.T) { - tests := []struct { - name string - input string - expected string - ok bool - }{ - { - name: "plain text passthrough", - input: "Executing step 1: Hello from the invoker", - expected: "", - ok: false, - }, - { - name: "workflow string message", - input: `{"requestId":"a8220e1b-1f9b-4529-a40f-9e3419bc494f","timestamp":"2026-04-07T15:20:59.866Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","operationId":"c4ca4238a0b92382","attempt":1,"message":"Executing step 1: Hello from the invoker"}`, - expected: "Executing step 1: Hello from the invoker", - ok: true, - }, - { - name: "workflow object message", - input: `{"requestId":"a8220e1b-1f9b-4529-a40f-9e3419bc494f","timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","operationId":"eccbc87e4b5ce2fe","attempt":1,"message":{"callbackResult":"{\"message\":\"Hello from the invoker\"}","step1":"Hello from the invoker"}}`, - expected: `{"callbackResult":"{\"message\":\"Hello from the invoker\"}","step1":"Hello from the invoker"}`, - ok: true, - }, - { - name: "python workflow message", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","execution_arn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":{"step":"complete","ok":true},"requestId":"req-123"}`, - expected: `{"ok":true,"step":"complete"}`, - ok: true, - }, - { - name: "raw user json passthrough", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","message":{"step":"complete","ok":true},"requestId":"req-123"}`, - expected: "", - ok: false, - }, - { - name: "custom json with execution arn passthrough", - input: `{"executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":{"step":"complete","ok":true}}`, - expected: "", - ok: false, - }, - { - name: "missing request id passthrough", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":"hello"}`, - expected: "", - ok: false, - }, - { - name: "malformed json passthrough", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","message":`, - expected: "", - ok: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - actual, ok := compactWorkflowLogLine(tt.input) - if ok != tt.ok { - t.Fatalf("expected ok=%v, got %v", tt.ok, ok) - } - if actual != tt.expected { - t.Fatalf("expected %q, got %q", tt.expected, actual) - } - }) - } -} - -func TestFormatFunctionLogLine(t *testing.T) { - line := `{"timestamp":"2026-04-07T15:20:59.866Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":"Executing step 1: Hello from the invoker","requestId":"req-123"}` - - u := &UI{} - - if actual := u.formatFunctionLogLine(line); actual != "Executing step 1: Hello from the invoker" { - t.Fatalf("expected compacted workflow log, got %q", actual) - } - - rawJSON := `{"timestamp":"2026-04-07T15:20:59.866Z","level":"INFO","message":{"user":true},"requestId":"req-123"}` - if actual := u.formatFunctionLogLine(rawJSON); actual != rawJSON { - t.Fatalf("expected raw user json to be unchanged, got %q", actual) - } -} diff --git a/cmd/sst/mosaic/ui/ui.go b/cmd/sst/mosaic/ui/ui.go deleted file mode 100644 index 0a17f05d49..0000000000 --- a/cmd/sst/mosaic/ui/ui.go +++ /dev/null @@ -1,727 +0,0 @@ -package ui - -import ( - "context" - "encoding/json" - "fmt" - "log/slog" - "net/url" - "os" - "slices" - "strings" - "time" - "unicode" - - "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/x/ansi" - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/cloudflare" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui/common" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/types/typescript" - - "golang.org/x/crypto/ssh/terminal" -) - -type ProgressMode string - -var IGNORED_RESOURCES = []string{"sst:sst:Version", "sst:sst:LinkRef", "pulumi:pulumi:Stack"} - -const ( - ProgressModeDeploy ProgressMode = "deploy" - ProgressModeRemove ProgressMode = "remove" - ProgressModeRefresh ProgressMode = "refresh" - ProgressModeDiff ProgressMode = "diff" -) - -const ( - IconX = "βœ•" - IconCheck = "βœ“" -) - -type UI struct { - mode ProgressMode - dedupe map[string]bool - timing map[string]time.Time - parents map[string]string - workerTime map[string]time.Time - complete *project.CompleteEvent - footer *footer - buffer []interface{} - hasBlank bool - hasHeader bool - options *Options - log *os.File -} - -type Options struct { - Silent bool - Log *os.File - Filter string -} - -type PaneFilterEvent struct { - PaneKey string `json:"paneKey"` - Value string `json:"value"` -} - -type Option func(*Options) - -func WithSilent(u *Options) { - u.Silent = true -} - -func (u *UI) SetFilter(filter string, paneKey string) { - icons := map[string]string{"function": "Ξ»", "task": "⧉"} - icon := icons[paneKey] - u.options.Filter = filter - u.blank() - if filter != "" { - u.println(TEXT_HIGHLIGHT.Render(icon), " ", TEXT_NORMAL_BOLD.Render("Filter"), " ", TEXT_GRAY.Render(filter)) - } else { - u.println(TEXT_DANGER.Render(icon), " ", TEXT_NORMAL_BOLD.Render("Filter"), " ", TEXT_DIM.Render("Removed")) - } - u.blank() -} - -func WithLog(file *os.File) Option { - return func(opts *Options) { - opts.Log = file - } -} - -func New(ctx context.Context, options ...Option) *UI { - opts := &Options{} - for _, option := range options { - option(opts) - } - isTTY := terminal.IsTerminal(int(os.Stdout.Fd())) - slog.Info("initializing ui", "isTTY", isTTY) - result := &UI{ - workerTime: map[string]time.Time{}, - hasBlank: false, - options: opts, - } - if opts.Log != nil { - result.log = opts.Log - } - if isTTY && !opts.Silent { - result.footer = NewFooter() - go result.footer.Start(ctx) - } - result.reset() - return result -} - -func (u *UI) print(args ...interface{}) { - u.buffer = append(u.buffer, args...) -} - -func (u *UI) printf(tmpl string, args ...interface{}) { - u.buffer = append(u.buffer, fmt.Sprintf(tmpl, args...)) -} - -func (u *UI) println(args ...interface{}) { - u.buffer = append(u.buffer, args...) - line := fmt.Sprint(u.buffer...) - if u.footer == nil { - fmt.Println(line) - } - if u.footer != nil { - u.footer.Send(lineMsg(line)) - } - if u.log != nil { - stripped := ansi.Strip(line) - u.log.WriteString(stripped + "\n") - } - u.buffer = []interface{}{} - u.hasBlank = false -} - -func (u *UI) blank() { - if u.hasBlank { - return - } - u.println() - u.hasBlank = true -} - -func (u *UI) reset() { - u.complete = nil - u.parents = map[string]string{} - u.dedupe = map[string]bool{} - u.timing = map[string]time.Time{} - u.buffer = []interface{}{} -} - -func (u *UI) Event(unknown interface{}) { - if u.footer != nil { - defer u.footer.Send(unknown) - } - switch evt := unknown.(type) { - - case *common.StdoutEvent: - u.println(evt.Line) - - case *aws.TaskProvisionEvent: - if !u.matchFilter(evt.Name) { - return - } - u.printEvent(GetColor(""), fmt.Sprintf("%-11s", "Provision"), evt.Name) - - case *aws.TaskStartEvent: - if !u.matchFilter(evt.TaskID) { - return - } - u.workerTime[evt.WorkerID] = time.Now() - u.printEvent(GetColor(evt.WorkerID), fmt.Sprintf("%-11s", "Start"), evt.Command) - - case *aws.TaskLogEvent: - if !u.matchFilter(evt.TaskID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("%.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), formattedDuration, evt.Line) - - case *aws.TaskCompleteEvent: - if !u.matchFilter(evt.TaskID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("took %.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), "Done", formattedDuration) - - case *aws.TaskMissingCommandEvent: - if !u.matchFilter(evt.Name) { - return - } - u.printEvent(TEXT_DANGER, fmt.Sprintf("%-11s", "Missing"), fmt.Sprintf("Dev command not configured for the \"%s\" task. Set `dev.command` to configure how the task works in `sst dev`.", evt.Name)) - - case *aws.FunctionInvokedEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - u.workerTime[evt.WorkerID] = time.Now() - u.printEvent(GetColor(evt.WorkerID), TEXT_NORMAL_BOLD.Render(fmt.Sprintf("%-11s", "Invoke")), u.functionName(evt.FunctionID)) - - case *aws.FunctionResponseEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("took %.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), "Done", formattedDuration) - - case *aws.FunctionLogEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("%.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), formattedDuration, u.formatFunctionLogLine(evt.Line)) - - case *aws.FunctionBuildEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - if len(evt.Errors) > 0 { - u.printEvent(TEXT_DANGER, "Build Error", u.functionName(evt.FunctionID)) - for _, item := range evt.Errors { - u.printEvent(TEXT_DANGER, "", " "+strings.TrimSpace(item)) - } - return - } - u.printEvent(TEXT_SUCCESS, "Build", u.functionName(evt.FunctionID)) - - case *aws.FunctionErrorEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - u.printEvent(GetColor(evt.WorkerID), TEXT_DANGER.Render(fmt.Sprintf("%-11s", "Error")), u.functionName(evt.FunctionID)) - u.printEvent(GetColor(evt.WorkerID), "", evt.ErrorMessage) - for _, item := range evt.Trace { - if strings.Contains(item, "Error:") { - continue - } - u.printEvent(GetColor(evt.WorkerID), "", "↳ "+strings.TrimSpace(item)) - } - - case *project.ConcurrentUpdateEvent: - u.reset() - u.printEvent(TEXT_DANGER, "Locked", "A concurrent update was detected on the app. Run `sst unlock` to remove the lock and try again.") - - case *deployer.DeployFailedEvent: - u.reset() - if evt.Error != "" { - u.printEvent(TEXT_DANGER, "Error", evt.Error) - } - - case *project.PolicyAdvisoryEvent: - u.printEvent(TEXT_WARNING, "Warning", u.FormatURN(evt.URN)+" "+evt.Policy+": "+evt.Message) - - case *typescript.WarningEvent: - u.printEvent(TEXT_WARNING, "Warning", evt.Message) - - case *project.StackCommandEvent: - u.reset() - u.header(evt.Version, evt.App, evt.Stage) - u.blank() - if evt.Command == "deploy" { - u.mode = ProgressModeDeploy - u.println( - TEXT_WARNING_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Deploy"), - ) - } - if evt.Command == "remove" { - u.mode = ProgressModeRemove - u.println( - TEXT_DANGER_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Remove"), - ) - } - if evt.Command == "refresh" { - u.mode = ProgressModeRefresh - u.println( - TEXT_INFO_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Refresh"), - ) - } - if evt.Command == "diff" { - u.mode = ProgressModeDiff - u.println( - TEXT_INFO_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Diff"), - ) - } - u.blank() - - case *project.BuildFailedEvent: - u.reset() - u.printEvent(TEXT_DANGER, "Error", evt.Error) - break - - case *project.SkipEvent: - u.println( - TEXT_INFO_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" No changes"), - ) - u.reset() - break - - case *apitype.ResourcePreEvent: - u.timing[evt.Metadata.URN] = time.Now() - if slices.Contains(IGNORED_RESOURCES, evt.Metadata.Type) { - return - } - - if evt.Metadata.Old != nil && evt.Metadata.Old.Parent != "" { - u.parents[evt.Metadata.URN] = evt.Metadata.Old.Parent - } - - if evt.Metadata.New != nil && evt.Metadata.New.Parent != "" { - u.parents[evt.Metadata.URN] = evt.Metadata.New.Parent - } - - if evt.Metadata.Op == apitype.OpSame { - return - } - - case *apitype.ResOpFailedEvent: - break - - case *apitype.ResOutputsEvent: - if slices.Contains(IGNORED_RESOURCES, evt.Metadata.Type) { - return - } - - duration := time.Since(u.timing[evt.Metadata.URN]).Round(time.Millisecond) - if evt.Metadata.Op == apitype.OpSame && u.mode == ProgressModeRefresh { - u.printProgress( - TEXT_SUCCESS, - "Refreshed", - duration, - evt.Metadata.URN, - ) - return - } - if evt.Metadata.Op == apitype.OpImport { - u.printProgress( - TEXT_SUCCESS, - "Imported", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpCreate { - u.printProgress( - TEXT_SUCCESS, - "Created", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpUpdate { - u.printProgress( - TEXT_SUCCESS, - "Updated", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpDelete { - u.printProgress( - TEXT_DIM, - "Deleted", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpDeleteReplaced { - u.printProgress( - TEXT_DIM, - "Deleted", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpCreateReplacement { - u.printProgress( - TEXT_SUCCESS, - "Created", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpReplace { - } - - case *apitype.DiagnosticEvent: - if evt.Severity == "error" { - message := []string{u.FormatURN(evt.URN)} - message = append(message, parseError(strings.TrimSpace(evt.Message))...) - u.printEvent(TEXT_DANGER, "Error", message...) - } - - if evt.Severity == "info" { - for _, line := range strings.Split(strings.TrimRightFunc(ansi.Strip(evt.Message), unicode.IsSpace), "\n") { - u.println(TEXT_DIM.Render(line)) - } - } - - if evt.Severity == "info#err" { - u.println(strings.TrimRightFunc(ansi.Strip(evt.Message), unicode.IsSpace)) - } - - case *apitype.ProgressEvent: - if evt.Done && evt.Type == apitype.PluginDownload { - splits := strings.Split(evt.ID, ":") - u.printEvent(TEXT_INFO, "Info", "Downloaded provider "+splits[1]) - } - - case *project.CompleteEvent: - u.complete = evt - if evt.Old { - break - } - - u.blank() - if len(evt.Errors) == 0 && evt.Finished { - u.print(TEXT_SUCCESS_BOLD.Render(IconCheck)) - if len(u.timing) == 0 { - if u.mode == ProgressModeRemove { - u.print(TEXT_NORMAL_BOLD.Render(" No resources to remove")) - } else { - u.print(TEXT_NORMAL_BOLD.Render(" No changes")) - } - } - if len(u.timing) > 0 { - label := "" - if u.mode == ProgressModeRemove { - label = "Removed" - } - if u.mode == ProgressModeDeploy { - label = "Complete" - } - if u.mode == ProgressModeRefresh { - label = "Refreshed" - } - if u.mode == ProgressModeDiff { - label = "Generated" - } - u.print(TEXT_NORMAL_BOLD.Render(" " + label + " ")) - } - u.println() - if len(evt.Hints) > 0 { - for k, v := range evt.Hints { - splits := strings.Split(k, "::") - u.println( - TEXT_GRAY_BOLD.Render(" "), - TEXT_GRAY_BOLD.Render(splits[len(splits)-1]+": "), - TEXT_NORMAL.Render(v), - ) - } - } - if len(evt.Outputs) > 0 { - if len(evt.Hints) > 0 { - u.println(TEXT_GRAY_BOLD.Render(" ---")) - } - for k, v := range evt.Outputs { - u.println( - TEXT_GRAY_BOLD.Render(" "), - TEXT_GRAY_BOLD.Render(k+": "), - TEXT_NORMAL.Render(fmt.Sprint(v)), - ) - } - } - } - if len(evt.Errors) == 0 && !evt.Finished { - u.println( - TEXT_DANGER_BOLD.Render(IconX), - TEXT_NORMAL_BOLD.Render(" Interrupted "), - ) - } - if len(evt.Errors) > 0 { - u.println( - TEXT_DANGER_BOLD.Render(IconX), - TEXT_NORMAL_BOLD.Render(" Failed "), - ) - - u.blank() - for _, status := range evt.Errors { - if status.URN != "" { - u.println(TEXT_DANGER_BOLD.Render(u.FormatURN(status.URN))) - } - for _, line := range parseError(status.Message) { - u.println(TEXT_NORMAL.Render(line)) - } - for i, line := range status.Help { - if i == 0 { - u.println() - } - u.println(TEXT_NORMAL.Render(line)) - } - - importDiffs, ok := evt.ImportDiffs[status.URN] - if ok { - isSSTComponent := strings.Contains(status.URN, "::sst") - if isSSTComponent { - u.println(TEXT_NORMAL.Render("\n\nSet the following in your transform:")) - } - if !isSSTComponent { - u.println(TEXT_NORMAL.Render("\n\nSet the following:")) - } - for _, diff := range importDiffs { - value, _ := json.Marshal(diff.Old) - if diff.Old == nil { - value = []byte("undefined") - } - u.print(TEXT_NORMAL.Render(" - ")) - if isSSTComponent { - u.print(TEXT_INFO.Render("`args." + string(diff.Input) + " = " + string(value) + ";`")) - } - if !isSSTComponent { - u.print(TEXT_INFO.Render("`" + string(diff.Input) + ": " + string(value) + ",`")) - } - u.blank() - } - } else { - u.blank() - } - } - - } - u.blank() - case *cloudflare.WorkerBuildEvent: - if !u.matchFilter(evt.WorkerID) { - return - } - if len(evt.Errors) > 0 { - u.printEvent(TEXT_DANGER, "Build Error", u.functionName(evt.WorkerID)+" "+strings.Join(evt.Errors, "\n")) - return - } - u.printEvent(TEXT_INFO, "Build", u.functionName(evt.WorkerID)) - case *cloudflare.WorkerUpdatedEvent: - if !u.matchFilter(evt.WorkerID) { - return - } - u.printEvent(TEXT_INFO, "Reload", u.functionName(evt.WorkerID)) - case *cloudflare.WorkerInvokedEvent: - if !u.matchFilter(evt.WorkerID) { - return - } - url, _ := url.Parse(evt.TailEvent.Event.Request.URL) - u.printEvent( - GetColor(evt.WorkerID), - TEXT_NORMAL_BOLD.Render(fmt.Sprintf("%-11s", "Invoke")), - u.functionName(evt.WorkerID)+" "+evt.TailEvent.Event.Request.Method+" "+url.Path, - ) - for _, log := range evt.TailEvent.Logs { - duration := time.UnixMilli(log.Timestamp).Sub(time.UnixMilli(evt.TailEvent.EventTimestamp)) - formattedDuration := fmt.Sprintf("%.9s", fmt.Sprintf("+%v", duration)) - - line := []string{} - for _, part := range log.Message { - switch v := part.(type) { - case string: - line = append(line, v) - case map[string]interface{}: - data, _ := json.Marshal(v) - line = append(line, string(data)) - } - } - - for _, item := range strings.Split(strings.Join(line, " "), "\n") { - u.printEvent(GetColor(evt.WorkerID), formattedDuration, item) - } - } - u.printEvent(GetColor(evt.WorkerID), "Done", evt.TailEvent.Outcome) - } - -} - -var Colors = []lipgloss.Style{ - lipgloss.NewStyle().Foreground(lipgloss.Color("13")), - lipgloss.NewStyle().Foreground(lipgloss.Color("14")), - lipgloss.NewStyle().Foreground(lipgloss.Color("2")), - lipgloss.NewStyle().Foreground(lipgloss.Color("12")), -} - -func GetColor(input string) lipgloss.Style { - hash := 0 - for _, c := range input { - hash += int(c) - } - return Colors[hash%len(Colors)] -} - -func (u *UI) functionName(functionID string) string { - if u.complete == nil { - return functionID - } - for _, resource := range u.complete.Resources { - if resource.Type == "sst:aws:Function" && resource.URN.Name() == functionID { - return strings.TrimPrefix(resource.Outputs["_metadata"].(map[string]interface{})["handler"].(string), "./") - } - if resource.Type == "sst:cloudflare:Worker" && resource.URN.Name() == functionID { - return strings.TrimPrefix(resource.Outputs["_metadata"].(map[string]interface{})["handler"].(string), "./") - } - } - return functionID -} - -func (u *UI) printProgress(barColor lipgloss.Style, label string, duration time.Duration, urn string) { - message := u.FormatURN(urn) - if duration > time.Second { - message += fmt.Sprintf(" (%.1fs)", duration.Seconds()) - } - u.printEvent(barColor, label, message) -} - -func (u *UI) printEvent(barColor lipgloss.Style, label string, message ...string) { - u.print(barColor.Copy().Bold(true).Render("| ")) - if label != "" { - u.print(TEXT_DIM.Render(fmt.Sprint(fmt.Sprintf("%-11s", label), " "))) - } - if len(message) > 0 { - u.print(TEXT_NORMAL.Render(message[0])) - } - u.println() - for _, msg := range message[1:] { - u.println(TEXT_NORMAL.Render(msg)) - } -} - -func (u *UI) Destroy() { - if u.footer != nil { - u.footer.Destroy() - } - if u.log != nil { - u.log.Close() - } -} - -func (u *UI) header(version, app, stage string) { - if u.hasHeader { - return - } - if flag.SST_EXPERIMENTAL { - version = version + " (experimental)" - } - u.println( - TEXT_HIGHLIGHT_BOLD.Render("SST "+version), - TEXT_GRAY.Render(" ready!"), - ) - u.blank() - u.println( - TEXT_HIGHLIGHT_BOLD.Render("➜ "), - TEXT_NORMAL_BOLD.Render(fmt.Sprintf("%-12s", "App:")), - TEXT_GRAY.Render(app), - ) - u.println( - TEXT_NORMAL_BOLD.Render(fmt.Sprintf(" %-12s", "Stage:")), - TEXT_GRAY.Render(stage), - ) - - u.blank() - u.hasHeader = true -} - -func (u *UI) FormatURN(urn string) string { - if urn == "" { - return "" - } - - child := resource.URN(urn) - name := child.Name() - typeName := child.Type().DisplayName() - splits := strings.SplitN(child.Name(), ".", 2) - if len(splits) > 1 { - name = splits[0] - typeName = strings.ReplaceAll(splits[1], ".", ":") - } - result := name + " " + typeName - - for { - parent := resource.URN(u.parents[string(child)]) - if parent == "" { - break - } - if slices.Contains(IGNORED_RESOURCES, parent.Type().DisplayName()) { - break - } - child = parent - } - if string(child) != urn { - result = child.Name() + " " + child.Type().DisplayName() + " β†’ " + result - } - return result -} - -func Success(msg string) { - fmt.Fprintln(os.Stderr, strings.TrimSpace(TEXT_SUCCESS_BOLD.Render(IconCheck)+" "+TEXT_NORMAL.Render(msg))) -} - -func Error(msg string) { - fmt.Fprintln(os.Stderr, strings.TrimSpace(TEXT_DANGER_BOLD.Render(IconX)+" "+TEXT_NORMAL.Render(msg))) -} - -func (u *UI) matchFilter(id string) bool { - if u.options.Filter == "" { - return true - } - filter := strings.ToLower(u.options.Filter) - if strings.Contains(strings.ToLower(id), filter) { - return true - } - name := u.functionName(id) - if strings.Contains(strings.ToLower(name), filter) { - return true - } - return false -} diff --git a/cmd/sst/mosaic/watcher/watcher.go b/cmd/sst/mosaic/watcher/watcher.go deleted file mode 100644 index 48176d8dbf..0000000000 --- a/cmd/sst/mosaic/watcher/watcher.go +++ /dev/null @@ -1,380 +0,0 @@ -package watcher - -import ( - "context" - "log/slog" - "os" - pathpkg "path" - "path/filepath" - "strings" - "time" - - "github.com/fsnotify/fsnotify" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" -) - -type FileChangedEvent struct { - Path string -} - -type WatchConfig struct { - Root string - Watch project.Watch -} - -type fileChange struct { - timestamp time.Time - discovered bool -} - -func resolveWatch(root string, watch project.Watch) ([]string, []string, error) { - root = filepath.Clean(root) - paths := watch.Paths - if watch.UsesLegacyArray() { - var err error - paths, err = expandLegacyPaths(root, paths) - if err != nil { - return nil, nil, err - } - } - - roots, err := resolveRoots(root, paths) - if err != nil { - return nil, nil, err - } - - ignore := make([]string, 0, len(watch.Ignore)) - for _, path := range watch.Ignore { - ignore = append(ignore, normalizePath(path)) - } - - return roots, ignore, nil -} - -func expandLegacyPaths(root string, paths []string) ([]string, error) { - expanded := make([]string, 0, len(paths)) - seen := map[string]bool{} - for _, path := range paths { - matches := []string{path} - if strings.ContainsAny(path, "*?[") { - resolved, err := filepath.Glob(filepath.Join(root, filepath.FromSlash(path))) - if err != nil { - return nil, err - } - matches = nil - for _, match := range resolved { - watchPath, err := legacyWatchPath(root, match) - if err != nil { - return nil, err - } - matches = append(matches, watchPath) - } - } - - for _, match := range matches { - match = filepath.ToSlash(filepath.Clean(match)) - if seen[match] { - continue - } - seen[match] = true - expanded = append(expanded, match) - } - } - - return expanded, nil -} - -func legacyWatchPath(root string, path string) (string, error) { - resolved := path - if !filepath.IsAbs(resolved) { - resolved = filepath.Join(root, filepath.FromSlash(path)) - } - - info, err := os.Stat(resolved) - if err == nil && !info.IsDir() { - resolved = filepath.Dir(resolved) - } - if err != nil && !os.IsNotExist(err) { - return "", err - } - - rel, err := filepath.Rel(root, resolved) - if err != nil { - return "", err - } - - return filepath.ToSlash(rel), nil -} - -func resolveRoots(root string, paths []string) ([]string, error) { - if len(paths) == 0 { - paths = []string{"."} - } - - seen := map[string]bool{} - var roots []string - - for _, path := range paths { - resolved := filepath.Clean(filepath.Join(root, filepath.FromSlash(path))) - if seen[resolved] { - continue - } - - info, err := os.Stat(resolved) - if err != nil { - if os.IsNotExist(err) { - continue - } - return nil, err - } - - if !info.IsDir() { - continue - } - - seen[resolved] = true - roots = append(roots, resolved) - } - - return roots, nil -} - -func shouldSkipDir(root string, ignore []string, path string, info os.FileInfo) bool { - if !info.IsDir() { - return false - } - - if strings.HasPrefix(info.Name(), ".") { - return true - } - - if strings.Contains(path, "node_modules") { - return true - } - - return isIgnored(root, ignore, path) -} - -func isIgnored(root string, ignore []string, path string) bool { - if len(ignore) == 0 { - return false - } - - rel, err := filepath.Rel(root, path) - if err != nil { - return false - } - - rel = normalizePath(rel) - for _, prefix := range ignore { - if matchesIgnore(prefix, rel) { - return true - } - } - - return false -} - -func matchesIgnore(pattern string, path string) bool { - if pattern == "." { - return true - } - - if strings.Contains(pattern, "/") { - return path == pattern || strings.HasPrefix(path, pattern+"/") - } - - for part := range strings.SplitSeq(path, "/") { - matched, err := pathpkg.Match(pattern, part) - if err == nil && matched { - return true - } - } - - return false -} - -func isWatchedPath(roots []string, path string) bool { - for _, root := range roots { - if isWithinPath(root, path) { - return true - } - } - - return false -} - -func shouldWatchDir(projectRoot string, roots []string, path string) bool { - if filepath.Clean(path) == filepath.Clean(projectRoot) { - return true - } - if isWatchedPath(roots, path) { - return true - } - if !isWithinPath(projectRoot, path) { - return false - } - - for _, root := range roots { - if isWithinPath(path, root) { - return true - } - } - - return false -} - -func normalizePath(path string) string { - path = filepath.ToSlash(filepath.Clean(path)) - if path == "./" { - return "." - } - return strings.TrimPrefix(path, "./") -} - -func Start(ctx context.Context, config WatchConfig) error { - log := slog.Default().With("service", "watcher") - log.Info("starting", "root", config.Root) - defer log.Info("done") - - roots, ignore, err := resolveWatch(config.Root, config.Watch) - if err != nil { - return err - } - watcher, err := fsnotify.NewWatcher() - if err != nil { - return err - } - defer watcher.Close() - - err = watcher.AddWith(config.Root) - if err != nil { - return err - } - - limiter := map[string]fileChange{} - - publishChange := func(path string, discovered bool) { - last, ok := limiter[path] - if ok && time.Since(last.timestamp) <= 500*time.Millisecond { - if discovered || !last.discovered { - return - } - } - - limiter[path] = fileChange{timestamp: time.Now(), discovered: discovered} - bus.Publish(&FileChangedEvent{Path: path}) - } - - watchTree := func(path string, publish bool) error { - return filepath.Walk(path, func(path string, info os.FileInfo, err error) error { - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - - if info.IsDir() { - if shouldSkipDir(config.Root, ignore, path, info) { - return filepath.SkipDir - } - if !shouldWatchDir(config.Root, roots, path) { - return filepath.SkipDir - } - - log.Info("watching", "path", path) - return watcher.Add(path) - } - - if publish && isWatchedPath(roots, path) && !isIgnored(config.Root, ignore, path) { - log.Info("discovered new file in directory", "path", path) - publishChange(path, true) - } - - return nil - }) - } - - err = watchTree(config.Root, false) - if err != nil { - return err - } - - for _, match := range roots { - if isWithinPath(config.Root, match) { - continue - } - err = watchTree(match, false) - if err != nil { - return err - } - } - - headFile := filepath.Join(config.Root, ".git/HEAD") - watcher.Add(headFile) - for { - select { - case event, ok := <-watcher.Events: - if !ok { - return nil - } - if event.Op&(fsnotify.Write|fsnotify.Create) == 0 { - log.Info("ignoring file event", "path", event.Name, "op", event.Op) - continue - } - if event.Op&fsnotify.Create != 0 { - info, err := os.Stat(event.Name) - if err != nil && !os.IsNotExist(err) { - return err - } - if err == nil && info.IsDir() { - if shouldSkipDir(config.Root, ignore, event.Name, info) || !shouldWatchDir(config.Root, roots, event.Name) { - log.Info("ignoring created directory", "path", event.Name) - continue - } - - err = watchTree(event.Name, true) - if err != nil { - return err - } - - // Catch nested dirs/files created while fsnotify attaches to the new dir. - select { - case <-time.After(50 * time.Millisecond): - case <-ctx.Done(): - return nil - } - err = watchTree(event.Name, true) - if err != nil { - return err - } - continue - } - } - if !isWatchedPath(roots, event.Name) { - log.Info("ignoring unwatched file event", "path", event.Name, "op", event.Op) - continue - } - if isIgnored(config.Root, ignore, event.Name) { - log.Info("ignoring ignored file event", "path", event.Name, "op", event.Op) - continue - } - log.Info("file event", "path", event.Name, "op", event.Op) - publishChange(event.Name, false) - case <-ctx.Done(): - return nil - } - } -} - -func isWithinPath(root string, path string) bool { - rel, err := filepath.Rel(root, path) - if err != nil { - return false - } - - rel = normalizePath(rel) - return rel == "." || (!strings.HasPrefix(rel, "../") && rel != "..") -} diff --git a/cmd/sst/mosaic/watcher/watcher_test.go b/cmd/sst/mosaic/watcher/watcher_test.go deleted file mode 100644 index 3b645b1c66..0000000000 --- a/cmd/sst/mosaic/watcher/watcher_test.go +++ /dev/null @@ -1,284 +0,0 @@ -package watcher - -import ( - "context" - "encoding/json" - "os" - "path/filepath" - "testing" - "time" - - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestResolveWatchDefaultsToProjectRoot(t *testing.T) { - root := t.TempDir() - roots, ignore, err := resolveWatch(root, project.Watch{}) - require.NoError(t, err) - assert.Equal(t, []string{root}, roots) - assert.False(t, isIgnored(root, ignore, filepath.Join(root, "sst.config.ts"))) -} - -func TestResolveWatchResolvesExternalIncludeRoots(t *testing.T) { - workspace := t.TempDir() - root := filepath.Join(workspace, "app") - external := filepath.Join(workspace, "external-package") - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "api"), 0755)) - require.NoError(t, os.MkdirAll(external, 0755)) - - roots, _, err := resolveWatch(root, project.Watch{ - Paths: []string{"packages/api", "../external-package"}, - }) - require.NoError(t, err) - assert.ElementsMatch(t, []string{filepath.Join(root, "packages", "api"), external}, roots) -} - -func TestResolveWatchExpandsLegacyArrayGlobs(t *testing.T) { - root := t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "api"), 0755)) - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "web"), 0755)) - - var watch project.Watch - require.NoError(t, json.Unmarshal([]byte(`["packages/*"]`), &watch)) - - roots, _, err := resolveWatch(root, watch) - require.NoError(t, err) - assert.ElementsMatch(t, []string{filepath.Join(root, "packages", "api"), filepath.Join(root, "packages", "web")}, roots) -} - -func TestResolveWatchExpandsLegacyArrayFileGlobsToParentDirs(t *testing.T) { - root := t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(root, "src"), 0755)) - require.NoError(t, os.WriteFile(filepath.Join(root, "src", "index.ts"), []byte("export {}\n"), 0644)) - - var watch project.Watch - require.NoError(t, json.Unmarshal([]byte(`["src/*"]`), &watch)) - - roots, _, err := resolveWatch(root, watch) - require.NoError(t, err) - assert.Equal(t, []string{filepath.Join(root, "src")}, roots) -} - -func TestResolveWatchMatchesIgnorePaths(t *testing.T) { - workspace := t.TempDir() - root := filepath.Join(workspace, "app") - external := filepath.Join(workspace, "external-package") - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "api", "generated"), 0755)) - require.NoError(t, os.MkdirAll(filepath.Join(external, "dist"), 0755)) - - _, ignore, err := resolveWatch(root, project.Watch{ - Ignore: []string{"packages/api/generated", "../external-package/dist"}, - }) - require.NoError(t, err) - - generated := mustInfo(t, filepath.Join(root, "packages", "api", "generated")) - dist := mustInfo(t, filepath.Join(external, "dist")) - - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, "packages", "api", "generated"), generated)) - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(external, "dist"), dist)) - assert.True(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", "generated", "index.ts"))) - assert.True(t, isIgnored(root, ignore, filepath.Join(external, "dist", "index.js"))) - assert.False(t, isIgnored(root, ignore, filepath.Join(root, "sst.config.ts"))) -} - -func TestResolveWatchMatchesIgnoreNamesAnywhere(t *testing.T) { - root := t.TempDir() - _, ignore, err := resolveWatch(root, project.Watch{ - Ignore: []string{".env", "*.egg-info"}, - }) - require.NoError(t, err) - - eggInfo := mustInfo(t, filepath.Join(root, "packages", "api", "foo.egg-info")) - - assert.True(t, isIgnored(root, ignore, filepath.Join(root, ".env"))) - assert.True(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", ".env"))) - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, "packages", "api", "foo.egg-info"), eggInfo)) - assert.True(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", "foo.egg-info", "PKG-INFO"))) - assert.False(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", ".env.local"))) -} - -func TestResolveWatchSkipsBuiltInDirs(t *testing.T) { - root := t.TempDir() - _, ignore, err := resolveWatch(root, project.Watch{}) - require.NoError(t, err) - - hidden := mustInfo(t, filepath.Join(root, ".sst")) - nodeModules := mustInfo(t, filepath.Join(root, "node_modules")) - normal := mustInfo(t, filepath.Join(root, "src")) - - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, ".sst"), hidden)) - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, "node_modules"), nodeModules)) - assert.False(t, shouldSkipDir(root, ignore, filepath.Join(root, "src"), normal)) -} - -func TestStartDiscoversFilesInNewDirectories(t *testing.T) { - root := t.TempDir() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{Root: root, Watch: project.Watch{}}) - }() - - waitForWatcherReady(t, filepath.Join(root, "watcher-ready.txt"), events) - - path := filepath.Join(root, "src", "newpkg", "handler.go") - require.NoError(t, os.MkdirAll(filepath.Dir(path), 0755)) - - deadline := time.Now().Add(5 * time.Second) - for time.Now().Before(deadline) { - require.NoError(t, os.WriteFile(path, []byte(time.Now().String()), 0644)) - if waitForFileChangedEvent(events, path, 200*time.Millisecond) { - cancel() - require.NoError(t, <-errCh) - return - } - time.Sleep(50 * time.Millisecond) - } - - t.Fatalf("expected file change for %s", path) -} - -func TestStartWatchesNewDirectories(t *testing.T) { - root := t.TempDir() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{Root: root, Watch: project.Watch{}}) - }() - - waitForWatcherReady(t, filepath.Join(root, "watcher-ready.txt"), events) - - dir := filepath.Join(root, "src", "newpkg") - require.NoError(t, os.MkdirAll(dir, 0755)) - - path := filepath.Join(dir, "handler.go") - deadline := time.Now().Add(5 * time.Second) - for time.Now().Before(deadline) { - require.NoError(t, os.WriteFile(path, []byte(time.Now().String()), 0644)) - if waitForFileChangedEvent(events, path, 200*time.Millisecond) { - cancel() - require.NoError(t, <-errCh) - return - } - time.Sleep(50 * time.Millisecond) - } - - t.Fatalf("expected file change for %s", path) -} - -func TestStartPicksUpImmediateEditsAfterNewFileDiscovery(t *testing.T) { - root := t.TempDir() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{Root: root, Watch: project.Watch{}}) - }() - - waitForWatcherReady(t, filepath.Join(root, "watcher-ready.txt"), events) - - dir := filepath.Join(root, "src", "newpkg") - require.NoError(t, os.MkdirAll(dir, 0755)) - - path := filepath.Join(dir, "handler.go") - require.NoError(t, os.WriteFile(path, []byte("package newpkg\n"), 0644)) - require.True(t, waitForFileChangedEvent(events, path, 5*time.Second), "expected initial file change for %s", path) - - require.NoError(t, os.WriteFile(path, []byte("package newpkg\n\nfunc Handler() {}\n"), 0644)) - require.True(t, waitForFileChangedEvent(events, path, 1*time.Second), "expected immediate follow-up file change for %s", path) - - cancel() - require.NoError(t, <-errCh) -} - -func TestStartOnlyWatchesConfiguredPaths(t *testing.T) { - root := t.TempDir() - watchedDir := filepath.Join(root, "packages", "api") - require.NoError(t, os.MkdirAll(watchedDir, 0755)) - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{ - Root: root, - Watch: project.Watch{ - Paths: []string{"packages/api"}, - }, - }) - }() - - waitForWatcherReady(t, filepath.Join(watchedDir, "watcher-ready.txt"), events) - - unwatched := filepath.Join(root, "docs", "guide.md") - require.NoError(t, os.MkdirAll(filepath.Dir(unwatched), 0755)) - require.NoError(t, os.WriteFile(unwatched, []byte("# docs\n"), 0644)) - assert.False(t, waitForFileChangedEvent(events, unwatched, 750*time.Millisecond), "did not expect file change for %s", unwatched) - - watched := filepath.Join(watchedDir, "handler.go") - require.NoError(t, os.WriteFile(watched, []byte("package api\n"), 0644)) - require.True(t, waitForFileChangedEvent(events, watched, 5*time.Second), "expected file change for %s", watched) - - cancel() - require.NoError(t, <-errCh) -} - -func mustInfo(t *testing.T, path string) os.FileInfo { - t.Helper() - require.NoError(t, os.MkdirAll(path, 0755)) - info, err := os.Stat(path) - require.NoError(t, err) - return info -} - -func waitForWatcherReady(t *testing.T, probe string, events <-chan interface{}) { - t.Helper() - - require.NoError(t, os.MkdirAll(filepath.Dir(probe), 0755)) - deadline := time.Now().Add(5 * time.Second) - for time.Now().Before(deadline) { - require.NoError(t, os.WriteFile(probe, []byte(time.Now().String()), 0644)) - if waitForFileChangedEvent(events, probe, 200*time.Millisecond) { - return - } - time.Sleep(50 * time.Millisecond) - } - - t.Fatalf("timed out waiting for watcher startup") -} - -func waitForFileChangedEvent(events <-chan interface{}, path string, timeout time.Duration) bool { - deadline := time.After(timeout) - for { - select { - case evt := <-events: - changed, ok := evt.(*FileChangedEvent) - if ok && changed.Path == path { - return true - } - case <-deadline: - return false - } - } -} diff --git a/cmd/sst/refresh.go b/cmd/sst/refresh.go deleted file mode 100644 index 35fddc9aee..0000000000 --- a/cmd/sst/refresh.go +++ /dev/null @@ -1,64 +0,0 @@ -package main - -import ( - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -func CmdRefresh(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - exclude := []string{} - if c.String("exclude") != "" { - exclude = strings.Split(c.String("exclude"), ",") - } - - var wg errgroup.Group - defer wg.Wait() - ui := ui.New(c.Context) - events := bus.SubscribeAll() - defer close(events) - wg.Go(func() error { - for evt := range events { - ui.Event(evt) - } - return nil - }) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - defer ui.Destroy() - defer c.Cancel() - err = p.Run(c.Context, &project.StackInput{ - Command: "refresh", - Target: target, - Exclude: exclude, - ServerPort: s.Port, - Dev: c.Bool("dev"), - Verbose: c.Bool("verbose"), - }) - if err != nil { - return err - } - return nil -} diff --git a/cmd/sst/remove.go b/cmd/sst/remove.go deleted file mode 100644 index c7394e0d41..0000000000 --- a/cmd/sst/remove.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -func CmdRemove(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - var wg errgroup.Group - defer wg.Wait() - ui := ui.New(c.Context) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - events := bus.SubscribeAll() - defer close(events) - wg.Go(func() error { - for evt := range events { - ui.Event(evt) - } - return nil - }) - defer ui.Destroy() - defer c.Cancel() - err = p.Run(c.Context, &project.StackInput{ - Command: "remove", - Target: target, - ServerPort: s.Port, - Verbose: c.Bool("verbose"), - }) - if err != nil { - return err - } - return nil -} diff --git a/cmd/sst/secret.go b/cmd/sst/secret.go deleted file mode 100644 index 794858dd34..0000000000 --- a/cmd/sst/secret.go +++ /dev/null @@ -1,491 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "io" - "os" - "regexp" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -var CmdSecretList = &cli.Command{ - Name: "list", - Description: cli.Description{ - Short: "List all secrets", - Long: strings.Join([]string{ - "Lists all the secrets.", - "", - "Optionally, list the secrets in a specific stage.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst secret list --stage production", - "```", - "", - "List only the fallback secrets.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst secret list --fallback", - "```", - }, "\n"), - }, - Examples: []cli.Example{ - { - Content: "sst secret list --stage production", - Description: cli.Description{ - Short: "List the secrets in production", - }, - }, - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - backend := p.Backend() - secrets := map[string]string{} - fallback := map[string]string{} - wg := errgroup.Group{} - if !c.Bool("fallback") { - wg.Go(func() error { - secrets, err = provider.GetSecrets(backend, p.App().Name, p.App().Stage) - if err != nil { - return err - } - return nil - }) - } - wg.Go(func() error { - fallback, err = provider.GetSecrets(backend, p.App().Name, "") - if err != nil { - return err - } - return nil - }) - if err := wg.Wait(); err != nil { - return err - } - if len(secrets) == 0 && len(fallback) == 0 { - return util.NewReadableError(nil, "No secrets found") - } - if len(fallback) > 0 { - fmt.Println(ui.TEXT_DIM.Render("# fallback")) - for key, value := range fallback { - fmt.Println(key + "=" + value) - } - } - if len(secrets) > 0 { - if len(fallback) > 0 { - fmt.Println() - } - fmt.Println(ui.TEXT_DIM.Render(fmt.Sprintf("# %s/%s", p.App().Name, p.App().Stage))) - for key, value := range secrets { - fmt.Println(key + "=" + value) - } - } - return nil - }, -} - -var CmdSecretLoad = &cli.Command{ - Name: "load", - Description: cli.Description{ - Short: "Set multiple secrets from file", - Long: strings.Join([]string{ - "Load all the secrets from a file and set them.", - "", - "```bash frame=\"none\"", - "sst secret load ./secrets.env", - "```", - "", - "The file needs to be in the _dotenv_ or bash format of key-value pairs.", - "", - "```sh title=\"secrets.env\"", - "KEY_1=VALUE1", - "KEY_2=VALUE2", - "```", - "", - "Optionally, set the secrets in a specific stage.", - "", - "```bash frame=\"none\"", - "sst secret load --stage production ./prod.env", - "```", - "", - "Set these secrets as _fallback_ values.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst secret load ./secrets.env --fallback", - "```", - "", - "This command can be paired with the `secret list` command to get all the", - "secrets from one stage and load them into another.", - "", - "```bash frame=\"none\"", - "sst secret list > ./secrets.env", - "sst secret load --stage production ./secrets.env", - "```", - "", - "This works because `secret list` outputs the secrets in the right format.", - }, "\n"), - }, - Args: []cli.Argument{ - { - Name: "file", - Required: true, - Description: cli.Description{ - Short: "The file to load secrets from", - Long: "The file to load the secrets from.", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst secret load ./secrets.env", - Description: cli.Description{ - Short: "Loads all secrets from the file", - }, - }, - { - Content: "sst secret load ./prod.env --stage production", - Description: cli.Description{ - Short: "Set secrets for production", - }, - }, - }, - Run: func(c *cli.Cli) error { - filePath := c.Positional(0) - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - backend := p.Backend() - stage := p.App().Stage - if c.Bool("fallback") { - stage = "" - } - secrets, err := provider.GetSecrets(backend, p.App().Name, stage) - if err != nil { - return util.NewReadableError(err, "Could not get secrets") - } - file, err := os.Open(filePath) - if err != nil { - return util.NewReadableError(err, fmt.Sprintf("Could not open file %s", filePath)) - } - defer file.Close() - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - line := scanner.Text() - // Skip comments and empty lines - if strings.HasPrefix(line, "#") || strings.TrimSpace(line) == "" { - continue - } - parts := strings.SplitN(line, "=", 2) - if len(parts) == 2 { - key := strings.TrimSpace(parts[0]) - value := strings.TrimSpace(parts[1]) - - // Handle quoted values (both single and double quotes) - if len(value) >= 2 { - // Check for double quotes - if strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"") { - // Remove the quotes - value = value[1 : len(value)-1] - // Handle escaped characters within double quotes - value = strings.ReplaceAll(value, "\\\"", "\"") - value = strings.ReplaceAll(value, "\\n", "\n") - value = strings.ReplaceAll(value, "\\r", "\r") - value = strings.ReplaceAll(value, "\\t", "\t") - // Check for single quotes - } else if strings.HasPrefix(value, "'") && strings.HasSuffix(value, "'") { - // Remove the quotes - single quotes typically don't process escapes in .env files - value = value[1 : len(value)-1] - } - } - - ui.Success(fmt.Sprintf("Setting %s", key)) - secrets[key] = value - } - } - err = provider.PutSecrets(backend, p.App().Name, stage, secrets) - if err != nil { - return util.NewReadableError(err, "Could not set secret") - } - url, _ := server.Discover(p.PathConfig(), p.App().Stage) - if url != "" { - dev.Deploy(c.Context, url) - return nil - } - - ui.Success("Run \"sst deploy\" to update.") - return nil - }, -} - -var CmdSecretSet = &cli.Command{ - Name: "set", - Description: cli.Description{ - Short: "Set a secret", - Long: strings.Join([]string{ - "Set the value of the secret.", - "", - "The secrets are encrypted and stored in an S3 Bucket in your AWS account. They are also stored in the package of the functions using the secret.", - "", - ":::tip", - "If you are not running `sst dev`, you'll need to `sst deploy` to apply the secret.", - ":::", - "", - "For example, set the `sst.Secret` called `StripeSecret` to `123456789`.", - "", - "```bash frame=\"none\"", - "sst secret set StripeSecret dev_123456789", - "```", - "", - "Optionally, set the secret in a specific stage.", - "", - "```bash frame=\"none\"", - "sst secret set StripeSecret prod_123456789 --stage production", - "```", - "", - "You can also set a _fallback_ value for a secret with `--fallback`.", - "", - "```bash frame=\"none\"", - "sst secret set StripeSecret dev_123456789 --fallback", - "```", - "", - "So if the secret is not set for a specific stage, it'll use the fallback instead.", - "This only works for stages that are in the same AWS account.", - "", - ":::tip", - "Set fallback values for your PR stages.", - ":::", - "", - "This is useful for preview environments that are automatically deployed.", - "You won't have to set the secret for the stage after it's deployed.", - "", - "To set something like an RSA key, you can first save it to a file.", - "", - "```bash frame=\"none\"", - "cat > tmp.txt < 0 && args[0] != "cmd" { - // Try to find the executable directly - if execPath, err := exec.LookPath(args[0]); err == nil { - // Use exec.Command directly instead of process.Command to avoid potential issues - cmd = exec.Command(execPath, args[1:]...) - // Track it manually since we're not using process.Command - // (Note: this skips the process tracking in the process package) - } else { - cmd = process.Command(args[0], args[1:]...) - } - } else { - cmd = process.Command(args[0], args[1:]...) - } - // Initialize with current environment variables - cmd.Env = os.Environ() - // Add SST-specific environment variables - cmd.Env = append(cmd.Env, - fmt.Sprintf("PS1=%s/%s> ", p.App().Name, p.App().Stage), - ) - complete, err := p.GetCompleted(c.Context) - if err != nil { - return err - } - - target := c.String("target") - if target != "" { - cmd.Env = append(cmd.Env, c.Env()...) - env, err := p.EnvFor(c.Context, complete, target) - if err != nil { - return err - } - for key, value := range env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, value)) - } - } - if target == "" { - // On Windows, always use a consolidated environment variable because - // Windows uppercases all environment variable names, breaking - // case-sensitive resource lookups. - if runtime.GOOS == "windows" { - // Create a single JSON with all resources - allResources := make(map[string]any) - for resource, value := range complete.Links { - allResources[resource] = value.Properties - } - allResources["App"] = map[string]string{ - "name": p.App().Name, - "stage": p.App().Stage, - } - - jsonData, err := json.Marshal(allResources) - if err != nil { - return err - } - - // Set as single environment variable that the SDK can parse - resourcesEnv := fmt.Sprintf("SST_RESOURCES_JSON=%s", string(jsonData)) - cmd.Env = append(cmd.Env, resourcesEnv) - } else { - // Original approach: Add individual SST resource environment variables - for resource, value := range complete.Links { - jsonValue, err := json.Marshal(value.Properties) - if err != nil { - return err - } - envVar := fmt.Sprintf("SST_RESOURCE_%s=%s", resource, string(jsonValue)) - cmd.Env = append(cmd.Env, envVar) - } - appEnv := fmt.Sprintf("SST_RESOURCE_App=%s", fmt.Sprintf(`{"name": "%s", "stage": "%s" }`, p.App().Name, p.App().Stage)) - cmd.Env = append(cmd.Env, appEnv) - } - - aws, ok := p.Provider("aws") - if ok { - // Remove AWS_PROFILE from environment - filteredEnv := []string{} - for _, envVar := range cmd.Env { - if !strings.HasPrefix(envVar, "AWS_PROFILE=") { - filteredEnv = append(filteredEnv, envVar) - } - } - cmd.Env = filteredEnv - - provider := aws.(*provider.AwsProvider) - cfg := provider.Config() - creds, err := cfg.Credentials.Retrieve(c.Context) - if err != nil { - return err - } - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_ACCESS_KEY_ID=%s", creds.AccessKeyID)) - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_SECRET_ACCESS_KEY=%s", creds.SecretAccessKey)) - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_SESSION_TOKEN=%s", creds.SessionToken)) - if cfg.Region != "" { - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_REGION=%s", cfg.Region)) - } - } - } - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err != nil { - return util.NewReadableError(err, err.Error()) - } - return nil -} diff --git a/cmd/sst/state.go b/cmd/sst/state.go deleted file mode 100644 index 88140eb8a3..0000000000 --- a/cmd/sst/state.go +++ /dev/null @@ -1,445 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "strings" - "time" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/id" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/state" -) - -var CmdState = &cli.Command{ - Name: "state", - Description: cli.Description{ - Short: "Manage state of your app", - }, - Children: []*cli.Command{ - { - Name: "edit", - Description: cli.Description{ - Short: "Edit the state of your app", - Long: strings.Join([]string{ - "Edit the raw state of your app directly.", - "", - "This opens your state file in your local editor (`$EDITOR`, or `vim` by default).", - "When you save and exit, SST pushes those changes back to your backend.", - "", - ":::danger", - "This command is dangerous. If you make an invalid change, you can corrupt your state and break deploys.", - "Only use this if you understand the state format and know exactly what you are changing.", - "Consider using safer commands like `sst state remove` or `sst state repair` first.", - ":::", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - update, err := p.Lock("edit") - if err != nil { - return util.NewReadableError(err, "Could not lock state") - } - defer p.Unlock() - defer func() { - update.TimeCompleted = time.Now().UTC().Format(time.RFC3339) - provider.PutUpdate(p.Backend(), p.App().Name, p.App().Stage, update) - }() - workdir, err := p.NewWorkdir(update.ID) - if err != nil { - return err - } - defer workdir.Cleanup() - - path, err := workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - editor := os.Getenv("EDITOR") - if editor == "" { - editor = "vim" - } - editorArgs := append(strings.Fields(editor), path) - fmt.Println(editorArgs) - cmd := process.Command(editorArgs[0], editorArgs[1:]...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Start(); err != nil { - return util.NewReadableError(err, "Could not start editor") - } - if err := cmd.Wait(); err != nil { - return util.NewReadableError(err, "Editor exited with error") - } - - return workdir.Push(update.ID) - }, - }, - { - Name: "export", - Flags: []cli.Flag{ - { - Name: "decrypt", - Type: "bool", - Description: cli.Description{ - Short: "Decrypt the state", - Long: "Decrypt the state before printing it out.", - }, - }, - }, - Description: cli.Description{ - Short: "Prints the state of your app", - Long: strings.Join([]string{ - "Prints the state of your app.", - "", - "This pull the state of your app from the cloud provider and then prints it out.", - "You can write this to a file or view it directly in your terminal.", - "", - "This can be run for specific stages as well.", - "", - "```bash frame=\"none\"", - "sst state export --stage production", - "```", - "", - "By default, it runs on your personal stage.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - workdir, err := p.NewWorkdir(id.Descending()) - if err != nil { - return err - } - defer workdir.Cleanup() - - _, err = workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - exported, err := workdir.Export() - if err != nil { - return err - } - if c.Bool("decrypt") { - passphrase, err := provider.GetPassphrase(p.Backend(), p.App().Name, p.App().Stage) - if err != nil { - return err - } - exported, err = state.Decrypt(c.Context, passphrase, exported) - if err != nil { - return err - } - } - encoder := json.NewEncoder(os.Stdout) - encoder.SetIndent("", " ") - return encoder.Encode(exported) - }, - }, - { - Name: "list", - Description: cli.Description{ - Short: "List all deployed stages", - Long: strings.Join([]string{ - "Lists all the stages of your app for the current set of credentials.", - "", - ":::note", - "This does not list the stages that are deployed in other accounts.", - ":::", - "", - "This pulls the state of your app from the cloud provider and then prints out all the stages that are listed in the state.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - backend := p.Backend() - currentStage := p.App().Stage - - stages, err := provider.ListStages(backend, p.App().Name) - if err != nil { - return err - } - - lines, err := provider.Info(backend) - if err != nil { - ui.Error("Failed to load provider information") - return err - } - - renderKeyValue("App", p.App().Name) - - for _, line := range lines { - renderKeyValue(line.Key, line.Value) - } - - if len(stages) == 0 { - fmt.Println( - ui.TEXT_NORMAL_BOLD.Render(indent("Stages:")) + - ui.TEXT_NORMAL.Render(currentStage) + " " + ui.TEXT_WARNING_DIM.Render("(not deployed)"), - ) - return nil - } - - currentDeployed := false - for i, stage := range stages { - rendered := ui.TEXT_GRAY.Render(stage) - if stage == currentStage { - rendered = ui.TEXT_NORMAL.Render(stage) - currentDeployed = true - } - - if i == 0 { - fmt.Println(ui.TEXT_NORMAL_BOLD.Render(indent("Stages:")) + rendered) - continue - } - - fmt.Println(indent("") + rendered) - } - - if !currentDeployed { - fmt.Println(indent("") + ui.TEXT_NORMAL.Render(currentStage) + " " + ui.TEXT_WARNING_DIM.Render("(not deployed)")) - } - - return nil - }, - }, - { - Name: "remove", - Args: []cli.Argument{ - { - Name: "target", - Required: true, - Description: cli.Description{ - Short: "The name of the resource to remove", - Long: "The name of the resource to remove.", - }, - }, - }, - Description: cli.Description{ - Short: "Remove a resource from only the state", - Long: strings.Join([]string{ - "Removes the reference for the given resource from the state.", - "", - ":::note", - "This does not remove the resource itself.", - ":::", - "", - "This does not remove the resource itself, it only edits the state of your app.", - "", - "```bash frame=\"none\"", - "sst state remove MyBucket", - "```", - "", - "Here, `MyBucket` is the name of the resource as defined in your `sst.config.ts`.", - "", - "```ts title=\"sst.config.ts\"", - "new sst.aws.Bucket(\"MyBucket\");", - "```", - "", - "This command will:", - "", - "1. Find the resource with the given name in the state.", - "2. Remove that from the state. It does not remove the children of this resource.", - "3. Runs a `repair` to remove any dependencies to this resource.", - "", - "You can run this for specific stages as well.", - "", - "```bash frame=\"none\"", - "sst state remove MyBucket --stage production", - "```", - "", - "By default, it runs on your personal stage.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - update, err := p.Lock("edit") - if err != nil { - return util.NewReadableError(err, "Could not lock state") - } - defer p.Unlock() - defer func() { - update.TimeCompleted = time.Now().UTC().Format(time.RFC3339) - provider.PutUpdate(p.Backend(), p.App().Name, p.App().Stage, update) - }() - workdir, err := p.NewWorkdir(update.ID) - if err != nil { - return err - } - defer workdir.Cleanup() - - _, err = workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - - checkpoint, err := workdir.Export() - if err != nil { - return util.NewReadableError(err, "Could not export state") - } - - target := c.Positional(0) - muts := state.Remove(target, checkpoint) - err = confirmMutations(muts) - if err != nil { - return err - } - - err = workdir.Import(checkpoint) - if err != nil { - return util.NewReadableError(err, "Could not import state") - } - - err = workdir.Push(update.ID) - if err != nil { - return err - } - ui.Success("Resource removed") - return nil - }, - }, - { - Name: "repair", - Description: cli.Description{ - Short: "Repair the state of your app", - Long: strings.Join([]string{ - "Repairs the state of your app if it's corrupted.", - "", - "Sometimes, if something goes wrong with your app, or if the state was directly", - "edited, the state can become corrupted. This will cause your `sst deploy` command", - "to fail.", - "", - "This command looks for the following issues and fixes them.", - "", - "1. Since the state is a list of resources, if one resource depends on another,", - " it needs to be listed after the one it depends on. This command finds resources", - " that depend on each other but are not ordered correctly and **reorders them**.", - "", - "2. If resource B depends on resource A, but resource A is not listed in the state,", - " it'll **remove the dependency**.", - "", - "This command does this by going through all the resources in the state, fixing the", - "issues and updating the state.", - "", - "You can run this for specific stages as well.", - "", - "```bash frame=\"none\"", - "sst state repair --stage production", - "```", - "", - "By default, it runs on your personal stage.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - update, err := p.Lock("repair") - if err != nil { - return util.NewReadableError(err, "Could not lock state") - } - defer p.Unlock() - defer func() { - update.TimeCompleted = time.Now().UTC().Format(time.RFC3339) - provider.PutUpdate(p.Backend(), p.App().Name, p.App().Stage, update) - }() - workdir, err := p.NewWorkdir(update.ID) - if err != nil { - return err - } - defer workdir.Cleanup() - - _, err = workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - - checkpoint, err := workdir.Export() - if err != nil { - return util.NewReadableError(err, "Could not export state") - } - - muts := state.Repair(checkpoint) - err = confirmMutations(muts) - if err != nil { - return err - } - - err = workdir.Import(checkpoint) - if err != nil { - return util.NewReadableError(err, "Could not import state") - } - - err = workdir.Push(update.ID) - if err != nil { - return err - } - ui.Success("State repaired") - return nil - }, - }, - }, -} - -func confirmMutations(muts []state.Mutation) error { - if len(muts) == 0 { - return util.NewReadableError(nil, "No changes made") - } - fmt.Println("Removing:") - for _, item := range muts { - if item.Remove != nil { - fmt.Printf("- %s β†’ %s\n", item.Remove.Resource.Type().DisplayName(), item.Remove.Resource.Name()) - } - if item.RemoveDependency != nil { - fmt.Printf("- dependency from %s β†’ %s on %s β†’ %s\n", item.RemoveDependency.Resource.Type().DisplayName(), item.RemoveDependency.Resource.Name(), item.RemoveDependency.Dependency.Type().DisplayName(), item.RemoveDependency.Dependency.Name()) - } - if item.RemoveProperty != nil { - fmt.Printf("- property dependency from %s β†’ %s β†’ %s on %s β†’ %s\n", item.RemoveProperty.Resource.URNName(), item.RemoveProperty.Resource.Name(), item.RemoveProperty.Property, item.RemoveProperty.Dependency.Type().DisplayName(), item.RemoveProperty.Dependency.Name()) - } - } - - // prompt for confirmation to continue - fmt.Print("Do you want to commit these changes? (Y/n): ") - var response string - _, err := fmt.Scanln(&response) - if err != nil { - return util.NewReadableError(err, "failed to read user input") - } - if strings.ToLower(response) != "y" { - return util.NewReadableError(nil, "Abandoning changes") - } - return nil -} - -func indent(key string) string { - return fmt.Sprintf("%-12s", key) -} - -func renderKeyValue(key string, value string) { - fmt.Println(ui.TEXT_NORMAL_BOLD.Render(indent(key+":")) + ui.TEXT_GRAY.Render(value)) -} diff --git a/cmd/sst/tunnel.go b/cmd/sst/tunnel.go deleted file mode 100644 index a03cb18786..0000000000 --- a/cmd/sst/tunnel.go +++ /dev/null @@ -1,261 +0,0 @@ -package main - -import ( - "fmt" - "io" - "log/slog" - "os" - "os/user" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "github.com/sst/sst/v3/pkg/tunnel" -) - -var CmdTunnel = &cli.Command{ - Name: "tunnel", - Description: cli.Description{ - Short: "Start a tunnel", - Long: strings.Join([]string{ - "Start a tunnel.", - "", - "```bash frame=\"none\"", - "sst tunnel", - "```", - "", - "If your app has a VPC with `bastion` enabled, you can use this to connect to it.", - "This will forward traffic from the following ranges over SSH:", - "- `10.0.4.0/22`", - "- `10.0.12.0/22`", - "- `10.0.0.0/22`", - "- `10.0.8.0/22`", - "", - "The tunnel allows your local machine to access resources that are in the VPC.", - "", - ":::note", - "The tunnel is only available for apps that have a VPC with `bastion` enabled.", - ":::", - "", - "If you are running `sst dev`, this tunnel will be started automatically under the", - "_Tunnel_ tab in the sidebar.", - "", - ":::tip", - "This is automatically started when you run `sst dev`.", - ":::", - "", - "You can start this manually if you want to connect to a different stage.", - "", - "```bash frame=\"none\"", - "sst tunnel --stage production", - "```", - "", - "This needs a network interface on your local machine. You can create this", - "with the `sst tunnel install` command.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - if tunnel.NeedsInstall() { - return util.NewReadableError(nil, "The sst tunnel needs to be installed or upgraded. Run `sudo sst tunnel install`") - } - - if tunnel.IsRunning() { - return util.NewReadableError(nil, "Another tunnel process is already running. Stop it before starting a new one.") - } - - cfgPath, err := c.Discover() - if err != nil { - return err - } - - slog.Info("starting tunnel") - - var completed *project.CompleteEvent - - stage, err := c.Stage(cfgPath) - if err != nil { - return err - } - - if url, err := server.Discover(cfgPath, stage); err == nil { - completed, err = dev.Completed(c.Context, url) - if err != nil { - return err - } - } else { - proj, err := c.InitProject() - if err != nil { - return err - } - completed, err = proj.GetCompleted(c.Context) - if err != nil { - return err - } - } - - if err != nil { - return err - } - if len(completed.Tunnels) == 0 { - return util.NewReadableError(nil, "No tunnels found for stage "+stage) - } - var tun project.Tunnel - for _, item := range completed.Tunnels { - tun = item - } - subnets := strings.Join(tun.Subnets, ",") - // run as root - tunnelCmd := process.CommandContext( - c.Context, - "sudo", "-n", "-E", - tunnel.BINARY_PATH, "tunnel", "start", - "--subnets", subnets, - "--host", tun.IP, - "--user", tun.Username, - "--print-logs", - ) - tunnelCmd.Env = append( - os.Environ(), - "SST_SKIP_LOCAL=true", - "SST_SKIP_DEPENDENCY_CHECK=true", - "SSH_PRIVATE_KEY="+tun.PrivateKey, - "SST_LOG="+strings.ReplaceAll(os.Getenv("SST_LOG"), ".log", "_sudo.log"), - ) - tunnelCmd.Stdout = os.Stdout - slog.Info("starting tunnel", "cmd", tunnelCmd.Args) - fmt.Println(ui.TEXT_HIGHLIGHT_BOLD.Render("Tunnel")) - fmt.Println() - fmt.Print(ui.TEXT_HIGHLIGHT_BOLD.Render("β–€")) - fmt.Println(ui.TEXT_NORMAL.Render(" " + tun.IP)) - fmt.Println() - fmt.Print(ui.TEXT_SUCCESS_BOLD.Render("➜")) - fmt.Println(ui.TEXT_NORMAL.Render(" Ranges")) - for _, subnet := range tun.Subnets { - fmt.Println(ui.TEXT_DIM.Render(" " + subnet)) - } - fmt.Println() - fmt.Println(ui.TEXT_DIM.Render("Waiting for connections...")) - fmt.Println() - stderr, _ := tunnelCmd.StderrPipe() - tunnelCmd.Start() - output, _ := io.ReadAll(stderr) - if strings.Contains(string(output), "password is required") { - return util.NewReadableError(nil, "Make sure you have installed the tunnel with `sudo sst tunnel install`") - } - return nil - }, - Children: []*cli.Command{ - { - Name: "install", - Description: cli.Description{ - Short: "Install the tunnel", - Long: strings.Join([]string{ - "Install the tunnel.", - "", - "To be able to create a tunnel, SST needs to create a network interface on your local", - - "", - "```bash \"sudo\"", - "sudo sst tunnel install", - "```", - "", - "You only need to run this once on your machine.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - currentUser, err := user.Current() - if err != nil { - return err - } - if currentUser.Uid != "0" { - return util.NewReadableError(nil, "You need to run this command as root") - } - err = tunnel.Install() - if err != nil { - return err - } - ui.Success("Tunnel installed successfully.") - return nil - }, - }, - { - Name: "start", - Description: cli.Description{ - Short: "Start the tunnel", - Long: strings.Join([]string{ - "Start the tunnel.", - "", - "This will start the tunnel.", - "", - "This is required for the tunnel to work.", - }, "\n"), - }, - Hidden: true, - Flags: []cli.Flag{ - { - Name: "subnets", - Type: "string", - Description: cli.Description{ - Short: "The subnet to use for the tunnel", - Long: "The subnet to use for the tunnel", - }, - }, - { - Name: "host", - Type: "string", - Description: cli.Description{ - Short: "The host to use for the tunnel", - Long: "The host to use for the tunnel", - }, - }, - { - Name: "port", - Type: "string", - Description: cli.Description{ - Short: "The port to use for the tunnel", - Long: "The port to use for the tunnel", - }, - }, - { - Name: "user", - Type: "string", - Description: cli.Description{ - Short: "The user to use for the tunnel", - Long: "The user to use for the tunnel", - }, - }, - }, - Run: func(c *cli.Cli) error { - subnets := strings.Split(c.String("subnets"), ",") - host := c.String("host") - port := c.String("port") - user := c.String("user") - if port == "" { - port = "22" - } - slog.Info("starting tunnel", "subnet", subnets, "host", host, "port", port) - err := tunnel.Start(subnets...) - if err != nil { - return err - } - defer tunnel.Stop() - slog.Info("tunnel started") - err = tunnel.StartProxy( - c.Context, - user, - host+":"+port, - []byte(os.Getenv("SSH_PRIVATE_KEY")), - ) - if err != nil { - slog.Error("failed to start tunnel", "error", err) - } - return nil - }, - }, - }, -} diff --git a/cmd/sst/ui.go b/cmd/sst/ui.go deleted file mode 100644 index fb913a7b9e..0000000000 --- a/cmd/sst/ui.go +++ /dev/null @@ -1,125 +0,0 @@ -package main - -import ( - "fmt" - "log/slog" - - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/cloudflare" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui/common" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "github.com/sst/sst/v3/pkg/types/typescript" -) - -func CmdUI(c *cli.Cli) error { - url, err := server.Discover("", "") - if err != nil { - return err - } - types := []interface{}{} - filter := c.String("filter") - isWorker := filter == "worker" - if isWorker { - filter = "function" - } - var u *ui.UI - opts := []ui.Option{} - if filter == "function" || filter == "" { - if filter != "" { - title := "Function Logs" - if isWorker { - title = "Worker Logs" - } - fmt.Println(ui.TEXT_HIGHLIGHT_BOLD.Render(title)) - fmt.Println() - fmt.Println(ui.TEXT_GRAY.Render("Waiting for invocations...")) - fmt.Println() - } - types = append(types, - cloudflare.WorkerBuildEvent{}, - cloudflare.WorkerUpdatedEvent{}, - cloudflare.WorkerInvokedEvent{}, - project.CompleteEvent{}, - aws.FunctionInvokedEvent{}, - aws.FunctionResponseEvent{}, - aws.FunctionErrorEvent{}, - aws.FunctionLogEvent{}, - aws.FunctionBuildEvent{}, - ) - } - if filter == "task" || filter == "" { - if filter != "" { - fmt.Println(ui.TEXT_HIGHLIGHT_BOLD.Render("Task Logs")) - fmt.Println() - fmt.Println(ui.TEXT_GRAY.Render("Waiting for tasks...")) - fmt.Println() - } - types = append(types, - aws.TaskProvisionEvent{}, - aws.TaskStartEvent{}, - aws.TaskLogEvent{}, - aws.TaskCompleteEvent{}, - aws.TaskMissingCommandEvent{}, - ) - } - if filter == "function" || filter == "task" { - types = append(types, ui.PaneFilterEvent{}) - } - if filter == "sst" || filter == "" { - u = ui.New(c.Context) - types = append(types, - common.StdoutEvent{}, - deployer.DeployFailedEvent{}, - project.StackCommandEvent{}, - project.CancelledEvent{}, - project.ConcurrentUpdateEvent{}, - project.StackCommandEvent{}, - project.BuildFailedEvent{}, - project.SkipEvent{}, - apitype.ResourcePreEvent{}, - apitype.ResOpFailedEvent{}, - apitype.ResOutputsEvent{}, - apitype.DiagnosticEvent{}, - project.CompleteEvent{}, - typescript.WarningEvent{}, - ) - } - evts, err := dev.Stream(c.Context, url, types...) - if err != nil { - return err - } - u = ui.New(c.Context, opts...) - slog.Info("initialized ui") - if filter == "sst" || filter == "" { - err = dev.Deploy(c.Context, url) - } - if err != nil { - return err - } - for { - select { - case <-c.Context.Done(): - u.Destroy() - return nil - case evt, ok := <-evts: - if !ok { - c.Cancel() - return nil - } - switch e := evt.(type) { - case *ui.PaneFilterEvent: - if e.PaneKey == filter { - u.SetFilter(e.Value, e.PaneKey) - } - default: - u.Event(evt) - } - } - } -} diff --git a/cmd/sst/upgrade.go b/cmd/sst/upgrade.go deleted file mode 100644 index 4ea3b1bffc..0000000000 --- a/cmd/sst/upgrade.go +++ /dev/null @@ -1,67 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - - "github.com/fatih/color" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/global" - "github.com/sst/sst/v3/pkg/npm" - "github.com/sst/sst/v3/pkg/process" -) - -func CmdUpgrade(c *cli.Cli) error { - if os.Getenv("npm_config_user_agent") != "" { - updated, err := global.UpgradeNode( - version, - c.Positional(0), - ) - if err != nil { - return err - } - hasAny := false - for file, newVersion := range updated { - fmt.Print(ui.TEXT_SUCCESS_BOLD.Render(ui.IconCheck) + " ") - fmt.Println(ui.TEXT_NORMAL.Render(file)) - fmt.Println(" " + ui.TEXT_DIM.Render(newVersion)) - if newVersion != version { - hasAny = true - } - } - if hasAny { - cwd, _ := os.Getwd() - mgr, _ := npm.DetectPackageManager(cwd) - if mgr != "" { - cmd := process.Command(mgr, "install") - fmt.Println() - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err := cmd.Run() - if err != nil { - return err - } - } - } - return nil - } - newVersion, err := global.Upgrade( - version, - c.Positional(0), - ) - if err != nil { - return err - } - newVersion = strings.TrimPrefix(newVersion, "v") - fmt.Print(ui.TEXT_SUCCESS_BOLD.Render(ui.IconCheck)) - if newVersion == version { - color.New(color.FgWhite).Printf(" Already on latest %s\n", version) - } else { - color.New(color.FgWhite).Printf(" Upgraded %s ➜ ", version) - color.New(color.FgCyan, color.Bold).Println(newVersion) - } - return nil -} diff --git a/cmd/sst/version.go b/cmd/sst/version.go deleted file mode 100644 index ca772a4299..0000000000 --- a/cmd/sst/version.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "runtime" - - "github.com/pulumi/pulumi/sdk/v3" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/pkg/global" -) - -var CmdVersion = &cli.Command{ - Name: "version", - Description: cli.Description{ - Short: "Print the version of the CLI", - Long: `Prints the current version of the CLI.`, - }, - Run: func(cli *cli.Cli) error { - fmt.Println("sst", version) - if cli.Bool("verbose") { - fmt.Println("pulumi", sdk.Version) - fmt.Println("config", global.ConfigDir()) - fmt.Println("GOARCH", runtime.GOARCH) - fmt.Println("GOOS", runtime.GOOS) - } - return nil - }, -} diff --git a/console/.gitignore b/console/.gitignore new file mode 100644 index 0000000000..997e81c27b --- /dev/null +++ b/console/.gitignore @@ -0,0 +1,12 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# misc +.DS_Store + +# local env files +.env*.local \ No newline at end of file diff --git a/console/package.json b/console/package.json new file mode 100644 index 0000000000..46d3521329 --- /dev/null +++ b/console/package.json @@ -0,0 +1,26 @@ +{ + "name": "console", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "sso": "aws sso login --sso-session=sst", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "2.7.2", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.0.4", + "@tsconfig/node16": "^1.0.3" + }, + "workspaces": [ + "packages/*", + "packages/web/*" + ] +} diff --git a/console/packages/core/drizzle.config.ts b/console/packages/core/drizzle.config.ts new file mode 100644 index 0000000000..dbdc5f7c66 --- /dev/null +++ b/console/packages/core/drizzle.config.ts @@ -0,0 +1,12 @@ +import type { Config } from "drizzle-kit"; + +const connection = { + user: process.env["SST_Secret_value_PLANETSCALE_USERNAME"], + password: process.env["SST_Secret_value_PLANETSCALE_PASSWORD"], + host: process.env["SST_Secret_value_PLANETSCALE_HOST"], +}; +export default { + out: "./migrations/", + schema: "./src/**/*.sql.ts", + connectionString: `mysql://${connection.user}:${connection.password}@${connection.host}:3306/sst?ssl={"rejectUnauthorized":true}`, +} satisfies Config; diff --git a/console/packages/core/package.json b/console/packages/core/package.json new file mode 100644 index 0000000000..5312e8d4b3 --- /dev/null +++ b/console/packages/core/package.json @@ -0,0 +1,29 @@ +{ + "name": "@console/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit", + "db:push": "sst bind drizzle-kit push:mysql" + }, + "devDependencies": { + "@types/node": "^18.16.0", + "drizzle-kit": "0.17.6-76e73f3", + "sst": "2.7.2", + "vitest": "^0.25.3" + }, + "dependencies": { + "@aws-sdk/client-cloudformation": "^3.326.0", + "@aws-sdk/client-eventbridge": "^3.325.0", + "@aws-sdk/client-s3": "^3.326.0", + "@aws-sdk/client-sts": "^3.321.1", + "@octokit/rest": "^19.0.7", + "@paralleldrive/cuid2": "^2.2.0", + "@planetscale/database": "^1.7.0", + "drizzle-orm": "0.25.3", + "drizzle-zod": "0.4.1", + "undici": "^5.22.0", + "zod": "^3.21.4" + } +} \ No newline at end of file diff --git a/console/packages/core/src/account/account.sql.ts b/console/packages/core/src/account/account.sql.ts new file mode 100644 index 0000000000..5d29a64c2b --- /dev/null +++ b/console/packages/core/src/account/account.sql.ts @@ -0,0 +1,20 @@ +import { + mysqlTable, + primaryKey, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; +import { id, timestamps } from "../util/sql"; + +export const account = mysqlTable( + "account", + { + ...id, + email: varchar("email", { length: 255 }).notNull(), + ...timestamps, + }, + (user) => ({ + primary: primaryKey(user.id), + email: uniqueIndex("email").on(user.email), + }) +); diff --git a/console/packages/core/src/account/index.ts b/console/packages/core/src/account/index.ts new file mode 100644 index 0000000000..f0e2d3e62d --- /dev/null +++ b/console/packages/core/src/account/index.ts @@ -0,0 +1,54 @@ +export * as Account from "./"; + +import { createSelectSchema } from "drizzle-zod"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createId } from "@paralleldrive/cuid2"; +import { db } from "../drizzle"; +import { eq } from "drizzle-orm"; +import { useTransaction } from "../util/transaction"; +import { account } from "./account.sql"; + +export const Info = createSelectSchema(account, { + id: (schema) => schema.id.cuid2(), + email: (schema) => schema.email.email(), +}); +export type Info = z.infer; + +export const create = zod( + Info.pick({ email: true, id: true }).partial({ + id: true, + }), + async (input) => { + const id = input.id ?? createId(); + return useTransaction(async (tx) => { + await tx.insert(account).values({ + id, + email: input.email, + }); + return id; + }); + } +); + +export const fromID = zod(Info.shape.id, async (id) => + db.transaction(async (tx) => { + return tx + .select() + .from(account) + .where(eq(account.id, id)) + .execute() + .then((rows) => rows[0]); + }) +); + +export const fromEmail = zod(Info.shape.email, async (email) => + db.transaction(async (tx) => { + return tx + .select() + .from(account) + .where(eq(account.email, email)) + .execute() + .then((rows) => rows[0]); + }) +); diff --git a/console/packages/core/src/actor.ts b/console/packages/core/src/actor.ts new file mode 100644 index 0000000000..769d045653 --- /dev/null +++ b/console/packages/core/src/actor.ts @@ -0,0 +1,62 @@ +import { Context } from "sst/context"; +import { z } from "zod"; + +export const PublicActor = z.object({ + type: z.literal("public"), + properties: z.object({}), +}); +export type PublicActor = z.infer; + +export const AccountActor = z.object({ + type: z.literal("account"), + properties: z.object({ + accountID: z.string().cuid2(), + email: z.string().email(), + }), +}); +export type AccountActor = z.infer; + +export const UserActor = z.object({ + type: z.literal("user"), + properties: z.object({ + userID: z.string().cuid2(), + workspaceID: z.string().cuid2(), + }), +}); +export type UserActor = z.infer; + +export const SystemActor = z.object({ + type: z.literal("system"), + properties: z.object({ + workspaceID: z.string().cuid2(), + }), +}); +export type SystemActor = z.infer; + +export const Actor = z.discriminatedUnion("type", [ + UserActor, + AccountActor, + PublicActor, + SystemActor, +]); +export type Actor = z.infer; + +const ActorContext = Context.create("actor"); + +export const useActor = ActorContext.use; +export const provideActor = ActorContext.provide; + +export function assertActor(type: T) { + const actor = useActor(); + if (actor.type !== type) { + throw new Error(`Expected actor type ${type}, got ${actor.type}`); + } + + return actor as Extract; +} + +export function useWorkspace() { + const actor = useActor(); + if ("workspaceID" in actor.properties) return actor.properties.workspaceID; + throw new Error(`Expected actor to have workspaceID`); +} diff --git a/console/packages/core/src/app/app.sql.ts b/console/packages/core/src/app/app.sql.ts new file mode 100644 index 0000000000..b818aa30f4 --- /dev/null +++ b/console/packages/core/src/app/app.sql.ts @@ -0,0 +1,57 @@ +import { + index, + json, + mysqlTable, + primaryKey, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; +import { timestamps, id, workspaceID, cuid } from "../util/sql"; + +export const app = mysqlTable( + "app", + { + ...workspaceID, + ...timestamps, + name: varchar("name", { length: 255 }).notNull(), + }, + (table) => ({ + primary: primaryKey(table.id, table.workspaceID), + name: uniqueIndex("name").on(table.workspaceID, table.name), + updated: index("updated").on(table.timeUpdated), + }) +); + +export const stage = mysqlTable( + "stage", + { + ...workspaceID, + ...timestamps, + appID: cuid("app_id").notNull(), + awsAccountID: varchar("aws_account_id", { length: 255 }).notNull(), + region: varchar("region", { length: 255 }).notNull(), + name: varchar("name", { length: 255 }).notNull(), + }, + (table) => ({ + primary: primaryKey(table.id, table.workspaceID), + name: uniqueIndex("name").on(table.appID, table.name, table.region), + updated: index("updated").on(table.timeUpdated), + }) +); + +export const resource = mysqlTable( + "resource", + { + ...workspaceID, + ...timestamps, + type: varchar("type", { length: 255 }).notNull(), + stackID: varchar("stack_id", { length: 255 }).notNull(), + cfnID: varchar("cfn_id", { length: 255 }).notNull(), + stageID: cuid("stage_id").notNull(), + addr: varchar("addr", { length: 255 }).notNull(), + data: json("data").notNull(), + }, + (table) => ({ + primary: primaryKey(table.id, table.workspaceID), + }) +); diff --git a/console/packages/core/src/app/index.ts b/console/packages/core/src/app/index.ts new file mode 100644 index 0000000000..632894dea0 --- /dev/null +++ b/console/packages/core/src/app/index.ts @@ -0,0 +1,65 @@ +export * as App from "./"; +export { Stage } from "./stage"; + +import { createSelectSchema } from "drizzle-zod"; +import { app, stage, resource } from "./app.sql"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createId } from "@paralleldrive/cuid2"; +import { db } from "../drizzle"; +import { eq, and } from "drizzle-orm"; +import { useTransaction } from "../util/transaction"; +import { useWorkspace } from "../actor"; +import { AWS } from "../aws"; +import { + GetObjectCommand, + ListObjectsV2Command, + S3Client, +} from "@aws-sdk/client-s3"; +import { awsAccount } from "../aws/aws.sql"; + +export const Info = createSelectSchema(app, { + id: (schema) => schema.id.cuid2(), +}).omit({ + workspaceID: true, +}); +export type Info = z.infer; + +export const create = zod( + Info.pick({ name: true, id: true }).partial({ + id: true, + }), + async (input) => { + const id = input.id ?? createId(); + return useTransaction(async (tx) => { + await tx.insert(app).values({ + id, + workspaceID: useWorkspace(), + name: input.name, + }); + return id; + }); + } +); + +export const fromID = zod(Info.shape.id, async (id) => + db.transaction(async (tx) => { + return tx + .select() + .from(app) + .where(and(eq(app.id, id), eq(app.workspaceID, useWorkspace()))) + .execute() + .then((rows) => rows[0]); + }) +); + +export const fromName = zod(Info.shape.name, async (name) => + db.transaction(async (tx) => { + return tx + .select() + .from(app) + .where(and(eq(app.name, name), eq(app.workspaceID, useWorkspace()))) + .execute() + .then((rows) => rows[0]); + }) +); diff --git a/console/packages/core/src/app/stage.ts b/console/packages/core/src/app/stage.ts new file mode 100644 index 0000000000..17fd7b7e45 --- /dev/null +++ b/console/packages/core/src/app/stage.ts @@ -0,0 +1,157 @@ +import { createSelectSchema } from "drizzle-zod"; +import { app, resource, stage } from "./app.sql"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createTransactionEffect, useTransaction } from "../util/transaction"; +import { createId } from "@paralleldrive/cuid2"; +import { useWorkspace } from "../actor"; +import { awsAccount } from "../aws/aws.sql"; +import { and, eq } from "drizzle-orm"; +import { AWS } from "../aws"; +import { + GetObjectCommand, + ListObjectsV2Command, + S3Client, +} from "@aws-sdk/client-s3"; +import { Bus, createEvent } from "../bus"; + +export * as Stage from "./stage"; + +export const Events = { + Connected: createEvent("app.stage.connected", { + stageID: z.string().nonempty(), + }), +}; + +export const Info = createSelectSchema(stage, { + id: (schema) => schema.id.cuid2(), +}); +export type Info = z.infer; + +export const connect = zod( + Info.pick({ + name: true, + appID: true, + id: true, + awsAccountID: true, + region: true, + }).partial({ + id: true, + }), + async (input) => { + const id = input.id ?? createId(); + return useTransaction(async (tx) => { + const result = await tx + .insert(stage) + .values({ + id, + appID: input.appID, + workspaceID: useWorkspace(), + awsAccountID: input.awsAccountID, + name: input.name, + region: input.region, + }) + .onDuplicateKeyUpdate({ + set: { + awsAccountID: input.awsAccountID, + region: input.region, + }, + }) + .execute(); + const { insertID } = await tx + .select({ insertID: stage.id }) + .from(stage) + .where( + and( + eq(stage.workspaceID, useWorkspace()), + eq(stage.appID, input.appID), + eq(stage.name, input.name), + eq(stage.region, input.region) + ) + ) + .execute() + .then((x) => x[0]!); + createTransactionEffect(() => + Bus.publish("app.stage.connected", { + stageID: insertID, + }) + ); + return insertID; + }); + } +); + +export const syncMetadata = zod(Info.shape.id, async (stageID) => + useTransaction(async (tx) => { + console.log("syncing metadata", stageID); + const row = await tx + .select({ + app: app.name, + accountID: awsAccount.accountID, + stage: stage.name, + region: stage.region, + }) + .from(stage) + .innerJoin(app, eq(stage.appID, app.id)) + .innerJoin(awsAccount, eq(stage.awsAccountID, awsAccount.id)) + .where(and(eq(stage.id, stageID), eq(stage.workspaceID, useWorkspace()))) + .execute() + .then((x) => x[0]); + if (!row) { + return; + } + console.log(row.app, row.stage, row.region, row.accountID); + const credentials = await AWS.assumeRole(row.accountID); + const { bucket } = await AWS.Account.bootstrap(credentials); + const s3 = new S3Client({ + credentials, + region: row.region, + }); + const key = `stackMetadata/app.${row.app}/stage.${row.stage}/`; + const list = await s3.send( + new ListObjectsV2Command({ + Prefix: key, + Bucket: bucket, + }) + ); + console.log("found", list.Contents?.length, "resources"); + useTransaction(async (tx) => { + await Promise.all( + list.Contents?.map(async (obj) => { + const stackID = obj.Key?.split("/").pop()!; + const result = await s3.send( + new GetObjectCommand({ + Key: obj.Key!, + Bucket: bucket, + }) + ); + const body = await result.Body!.transformToString(); + await tx + .delete(resource) + .where( + and( + eq(resource.stackID, stackID), + eq(resource.workspaceID, useWorkspace()) + ) + ) + .execute(); + for (let res of JSON.parse(body)) { + await tx + .insert(resource) + .values({ + workspaceID: useWorkspace(), + cfnID: res.id, + addr: res.addr, + stackID, + stageID, + id: createId(), + type: res.type, + data: res.data, + }) + .execute(); + } + }) || [] + ); + }); + }) +); diff --git a/console/packages/core/src/aws/account.ts b/console/packages/core/src/aws/account.ts new file mode 100644 index 0000000000..03be02d215 --- /dev/null +++ b/console/packages/core/src/aws/account.ts @@ -0,0 +1,95 @@ +export * as Account from "./account"; + +import { createSelectSchema } from "drizzle-zod"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createId } from "@paralleldrive/cuid2"; +import { createTransactionEffect, useTransaction } from "../util/transaction"; +import { awsAccount } from "./aws.sql"; +import { useWorkspace } from "../actor"; +import { and, eq } from "drizzle-orm"; +import { Bus, createEvent } from "../bus"; +import { assumeRole } from "."; +import { + CloudFormationClient, + DescribeStacksCommand, +} from "@aws-sdk/client-cloudformation"; + +export const Info = createSelectSchema(awsAccount, { + id: (schema) => schema.id.cuid2(), + accountID: (schema) => schema.accountID.regex(/^[0-9]{12}$/), +}); +export type Info = z.infer; + +export const Events = { + Created: createEvent("aws.account.created", { + awsAccountID: z.string(), + }), +}; + +export const create = zod( + Info.pick({ id: true, accountID: true }).partial({ + id: true, + }), + async (input) => + useTransaction(async (tx) => { + const id = input.id ?? createId(); + await tx.insert(awsAccount).values({ + id, + workspaceID: useWorkspace(), + accountID: input.accountID, + }); + createTransactionEffect(() => + Events.Created.publish({ + awsAccountID: id, + }) + ); + return id; + }) +); + +export const fromAccountID = zod(Info.shape.accountID, async (accountID) => + useTransaction((tx) => + tx + .select() + .from(awsAccount) + .where( + and( + eq(awsAccount.accountID, accountID), + eq(awsAccount.workspaceID, useWorkspace()) + ) + ) + .execute() + .then((rows) => rows[0]) + ) +); + +export const bootstrap = zod( + z.custom>>(), + async (credentials) => { + const cf = new CloudFormationClient({ + credentials, + }); + + const bootstrap = await cf + .send( + new DescribeStacksCommand({ + StackName: "SSTBootstrap", + }) + ) + .then((x) => x?.Stacks?.[0]); + if (!bootstrap) { + throw new Error("Bootstrap stack not found"); + } + + const bucket = bootstrap.Outputs?.find( + (x) => x.OutputKey === "BucketName" + )?.OutputValue; + + if (!bucket) throw new Error("BucketName not found"); + + return { + bucket, + }; + } +); diff --git a/console/packages/core/src/aws/aws.sql.ts b/console/packages/core/src/aws/aws.sql.ts new file mode 100644 index 0000000000..bbfd815a92 --- /dev/null +++ b/console/packages/core/src/aws/aws.sql.ts @@ -0,0 +1,22 @@ +import { + index, + mysqlTable, + primaryKey, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; +import { timestamps, workspaceID } from "../util/sql"; + +export const awsAccount = mysqlTable( + "aws_account", + { + ...workspaceID, + ...timestamps, + accountID: varchar("account_id", { length: 12 }).notNull(), + }, + (table) => ({ + primary: primaryKey(table.id, table.workspaceID), + accountID: uniqueIndex("account_id").on(table.workspaceID, table.accountID), + updated: index("updated").on(table.timeUpdated), + }) +); diff --git a/console/packages/core/src/aws/index.ts b/console/packages/core/src/aws/index.ts new file mode 100644 index 0000000000..1238602275 --- /dev/null +++ b/console/packages/core/src/aws/index.ts @@ -0,0 +1,25 @@ +import { z } from "zod"; +import { zod } from "../util/zod"; + +export { Account } from "./account"; +import { AssumeRoleCommand, STSClient } from "@aws-sdk/client-sts"; + +export * as AWS from "."; + +const sts = new STSClient({}); + +export const assumeRole = zod(z.string(), async (id) => { + console.log("assuming role for account", id); + const result = await sts.send( + new AssumeRoleCommand({ + RoleArn: `arn:aws:iam::${id}:role/sst`, + RoleSessionName: "sst", + DurationSeconds: 900, + }) + ); + return { + secretAccessKey: result.Credentials!.SecretAccessKey!, + accessKeyId: result.Credentials!.AccessKeyId!, + sessionToken: result.Credentials!.SessionToken!, + }; +}); diff --git a/console/packages/core/src/bus/index.ts b/console/packages/core/src/bus/index.ts new file mode 100644 index 0000000000..13c2bd7b70 --- /dev/null +++ b/console/packages/core/src/bus/index.ts @@ -0,0 +1,72 @@ +export * as Bus from "./index"; + +import { + EventBridgeClient, + PutEventsCommand, +} from "@aws-sdk/client-eventbridge"; +import { EventBus } from "sst/node/event-bus"; +import { useActor } from "../actor"; +import { ZodAny, ZodObject, ZodRawShape, z } from "zod"; + +const client = new EventBridgeClient({}); + +export interface Events {} + +export type EventName = keyof Events; + +export async function publish( + name: Name, + properties: Events[Name] +) { + console.log("publishing event", name, properties); + await client.send( + new PutEventsCommand({ + Entries: [ + { + EventBusName: EventBus.bus.eventBusName, + Source: "console", + Detail: JSON.stringify({ + properties, + actor: useActor(), + }), + DetailType: name, + }, + ], + }) + ); +} + +export function createEvent< + Type extends string, + Shape extends ZodRawShape, + Properties = z.infer> +>(type: Type, properties: Shape) { + async function publish(properties: Properties) { + await client.send( + new PutEventsCommand({ + Entries: [ + { + EventBusName: EventBus.bus.eventBusName, + Source: "console", + Detail: JSON.stringify({ + properties, + actor: useActor(), + }), + DetailType: type, + }, + ], + }) + ); + } + + return { + publish, + type, + shape: z.object(properties), + }; +} + +const event = createEvent("my.event", { foo: z.string() }); +type inferEvent }> = z.infer; + +type Payload = inferEvent; diff --git a/console/packages/core/src/business/business.sql.ts b/console/packages/core/src/business/business.sql.ts new file mode 100644 index 0000000000..22ee8b4714 --- /dev/null +++ b/console/packages/core/src/business/business.sql.ts @@ -0,0 +1,24 @@ +import { + mysqlTable, + primaryKey, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; +import { timestamps, id } from "../util/sql"; + +export const business = mysqlTable( + "business", + { + ...id, + ...timestamps, + namespace: varchar("namespace", { length: 255 }).notNull(), + name: varchar("name", { length: 255 }).notNull(), + }, + (table) => ({ + primary: primaryKey(table.id), + namespace: uniqueIndex("namespace").on(table.namespace), + }) +); + +// name: StatMuse +// namespace: statmuse diff --git a/console/packages/core/src/business/index.ts b/console/packages/core/src/business/index.ts new file mode 100644 index 0000000000..1311c3f150 --- /dev/null +++ b/console/packages/core/src/business/index.ts @@ -0,0 +1,54 @@ +export * as Business from "./"; + +import { createSelectSchema } from "drizzle-zod"; +import { business } from "./business.sql"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createId } from "@paralleldrive/cuid2"; +import { db } from "../drizzle"; +import { eq } from "drizzle-orm"; +import { useTransaction } from "../util/transaction"; +import { Workspace } from "../workspace"; + +export const Info = createSelectSchema(business, { + id: (schema) => schema.id.cuid2(), + name: (schema) => schema.name.nonempty(), + namespace: (schema) => schema.namespace.nonempty(), +}); +export type Info = z.infer; + +export const create = zod( + Info.pick({ name: true, id: true }).partial({ + id: true, + }), + async (input) => { + const id = input.id ?? createId(); + let namespace = input.name + .toLowerCase() + .replace(/[^\w\s]/g, "") + .replace(/\s/g, "-"); + return useTransaction(async (tx) => { + await tx.insert(business).values({ + id, + name: input.name, + namespace, + }); + await Workspace.create({ + slug: "", + businessID: id, + }); + return id; + }); + } +); + +export const fromID = zod(Info.shape.id, async (id) => + db.transaction(async (tx) => { + return tx + .select() + .from(business) + .where(eq(business.id, id)) + .execute() + .then((rows) => rows[0]); + }) +); diff --git a/console/packages/core/src/drizzle/index.ts b/console/packages/core/src/drizzle/index.ts new file mode 100644 index 0000000000..ba360a5115 --- /dev/null +++ b/console/packages/core/src/drizzle/index.ts @@ -0,0 +1,13 @@ +import { drizzle } from "drizzle-orm/planetscale-serverless"; +import { connect } from "@planetscale/database"; +import { Config } from "sst/node/config"; +import { fetch } from "undici"; + +const connection = connect({ + host: Config.PLANETSCALE_HOST, + username: Config.PLANETSCALE_USERNAME, + password: Config.PLANETSCALE_PASSWORD, + fetch, +}); + +export const db = drizzle(connection); diff --git a/console/packages/core/src/new.ts b/console/packages/core/src/new.ts new file mode 100644 index 0000000000..4924361fe8 --- /dev/null +++ b/console/packages/core/src/new.ts @@ -0,0 +1,9 @@ +declare module "./bus" { + export interface Events { + "new.event": { + stageID: string; + }; + } +} + +export {}; diff --git a/console/packages/core/src/replicache/index.ts b/console/packages/core/src/replicache/index.ts new file mode 100644 index 0000000000..935541cb96 --- /dev/null +++ b/console/packages/core/src/replicache/index.ts @@ -0,0 +1,42 @@ +export * as Replicache from "."; + +import { z } from "zod"; +import { zod } from "../util/zod"; +import { useTransaction } from "../util/transaction"; +import { replicache_client } from "./replicache.sql"; +import { eq } from "drizzle-orm"; + +export const fromID = zod(z.string(), (input) => + useTransaction(async (tx) => { + return tx + .select() + .from(replicache_client) + .where(eq(replicache_client.id, input)) + .then((x) => x.at(0)); + }) +); + +export const create = zod(z.string(), (input) => + useTransaction(async (tx) => { + return tx.insert(replicache_client).values({ + id: input, + mutationID: 0, + }); + }) +); + +export const setMutationID = zod( + z.object({ + clientID: z.string(), + mutationID: z.number(), + }), + (input) => + useTransaction(async (tx) => { + return tx + .update(replicache_client) + .set({ + mutationID: input.mutationID, + }) + .where(eq(replicache_client.id, input.clientID)); + }) +); diff --git a/console/packages/core/src/replicache/replicache.sql.ts b/console/packages/core/src/replicache/replicache.sql.ts new file mode 100644 index 0000000000..c8c80dd146 --- /dev/null +++ b/console/packages/core/src/replicache/replicache.sql.ts @@ -0,0 +1,12 @@ +import { bigint, char, mysqlTable } from "drizzle-orm/mysql-core"; +import { timestamps, id } from "../util/sql"; + +export const replicache_client = mysqlTable("replicache_client", { + id: char("id", { length: 36 }).primaryKey(), + mutationID: bigint("mutation_id", { + mode: "number", + }) + .default(0) + .notNull(), + ...timestamps, +}); diff --git a/console/packages/core/src/user/index.ts b/console/packages/core/src/user/index.ts new file mode 100644 index 0000000000..51be77b44f --- /dev/null +++ b/console/packages/core/src/user/index.ts @@ -0,0 +1,56 @@ +export * as User from "./"; + +import { createSelectSchema } from "drizzle-zod"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createId } from "@paralleldrive/cuid2"; +import { db } from "../drizzle"; +import { and, eq } from "drizzle-orm"; +import { useTransaction } from "../util/transaction"; +import { user } from "./user.sql"; +import { useWorkspace } from "../actor"; + +export const Info = createSelectSchema(user, { + id: (schema) => schema.id.cuid2(), + email: (schema) => schema.email.email(), +}); +export type Info = z.infer; + +export const create = zod( + Info.pick({ email: true, id: true }).partial({ + id: true, + }), + async (input) => { + const id = input.id ?? createId(); + return useTransaction(async (tx) => { + await tx.insert(user).values({ + id, + email: input.email, + workspaceID: useWorkspace(), + }); + return id; + }); + } +); + +export const fromID = zod(Info.shape.id, async (id) => + db.transaction(async (tx) => { + return tx + .select() + .from(user) + .where(and(eq(user.id, id), eq(user.workspaceID, useWorkspace()))) + .execute() + .then((rows) => rows[0]); + }) +); + +export const fromEmail = zod(Info.shape.email, async (email) => + db.transaction(async (tx) => { + return tx + .select() + .from(user) + .where(and(eq(user.email, email), eq(user.workspaceID, useWorkspace()))) + .execute() + .then((rows) => rows[0]); + }) +); diff --git a/console/packages/core/src/user/user.sql.ts b/console/packages/core/src/user/user.sql.ts new file mode 100644 index 0000000000..21574f671d --- /dev/null +++ b/console/packages/core/src/user/user.sql.ts @@ -0,0 +1,21 @@ +import { + mysqlTable, + primaryKey, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; +import { cuid, id, timestamps } from "../util/sql"; + +export const user = mysqlTable( + "user", + { + ...id, + workspaceID: cuid("workspace_id").notNull(), + ...timestamps, + email: varchar("email", { length: 255 }).notNull(), + }, + (user) => ({ + primary: primaryKey(user.id, user.workspaceID), + email: uniqueIndex("email").on(user.email, user.workspaceID), + }) +); diff --git a/console/packages/core/src/util/sql.ts b/console/packages/core/src/util/sql.ts new file mode 100644 index 0000000000..da2ab03821 --- /dev/null +++ b/console/packages/core/src/util/sql.ts @@ -0,0 +1,30 @@ +import { char, timestamp, datetime } from "drizzle-orm/mysql-core"; +import { sql } from "drizzle-orm"; + +export { createId } from "@paralleldrive/cuid2"; +export const cuid = (name: string) => char(name, { length: 24 }); +export const id = { + id: cuid("id").notNull(), +}; + +export const workspaceID = { + ...id, + workspaceID: cuid("workspace_id").notNull(), +}; + +export const timestamps = { + timeCreated: timestamp("time_created", { + mode: "string", + }) + .notNull() + .default(sql`CURRENT_TIMESTAMP`), + timeUpdated: timestamp("time_updated", { + mode: "string", + }) + .notNull() + .default(sql`CURRENT_TIMESTAMP`) + .onUpdateNow(), + timeDeleted: timestamp("time_deleted", { + mode: "string", + }), +}; diff --git a/console/packages/core/src/util/transaction.ts b/console/packages/core/src/util/transaction.ts new file mode 100644 index 0000000000..5797599869 --- /dev/null +++ b/console/packages/core/src/util/transaction.ts @@ -0,0 +1,42 @@ +import { MySqlTransaction } from "drizzle-orm/mysql-core"; +import { + PlanetScalePreparedQueryHKT, + PlanetscaleQueryResultHKT, +} from "drizzle-orm/planetscale-serverless"; +import { Context } from "sst/context"; +import { db } from "../drizzle"; + +export type Transaction = MySqlTransaction< + PlanetscaleQueryResultHKT, + PlanetScalePreparedQueryHKT +>; + +const TransactionContext = Context.create<{ + tx: Transaction; + effects: (() => void | Promise)[]; +}>(); + +export function useTransaction(callback: (trx: Transaction) => Promise) { + try { + const { tx } = TransactionContext.use(); + return callback(tx); + } catch { + return db.transaction( + async (tx) => { + const effects: (() => void | Promise)[] = []; + TransactionContext.provide({ tx, effects: effects }); + const result = await callback(tx); + await Promise.all(effects.map((x) => x())); + return result; + }, + { + isolationLevel: "serializable", + } + ); + } +} + +export function createTransactionEffect(effect: () => void | Promise) { + const { effects } = TransactionContext.use(); + effects.push(effect); +} diff --git a/console/packages/core/src/util/zod.ts b/console/packages/core/src/util/zod.ts new file mode 100644 index 0000000000..d154dea538 --- /dev/null +++ b/console/packages/core/src/util/zod.ts @@ -0,0 +1,13 @@ +import { z } from "zod"; + +export function zod< + Schema extends z.ZodSchema, + Return extends any +>(schema: Schema, func: (value: z.infer) => Return) { + const result = (input: z.infer) => { + const parsed = schema.parse(input); + return func(parsed); + }; + result.schema = schema; + return result; +} diff --git a/console/packages/core/src/workspace/index.ts b/console/packages/core/src/workspace/index.ts new file mode 100644 index 0000000000..17fd0ae2d3 --- /dev/null +++ b/console/packages/core/src/workspace/index.ts @@ -0,0 +1,52 @@ +export * as Workspace from "./"; + +import { createSelectSchema } from "drizzle-zod"; +import { workspace } from "./workspace.sql"; +import { z } from "zod"; +import { zod } from "../util/zod"; +import { createId } from "@paralleldrive/cuid2"; +import { db } from "../drizzle"; +import { eq } from "drizzle-orm"; +import { useTransaction } from "../util/transaction"; + +export const Info = createSelectSchema(workspace, { + id: (schema) => schema.id.cuid2(), +}); +export type Info = z.infer; + +export const create = zod( + Info.pick({ slug: true, id: true, businessID: true }).partial({ + id: true, + }), + async (input) => { + const id = input.id ?? createId(); + return useTransaction(async (tx) => { + await tx.insert(workspace).values({ + id, + slug: input.slug, + }); + return id; + }); + } +); + +export const fromID = zod(Info.shape.id, async (id) => + db.transaction(async (tx) => { + return tx + .select() + .from(workspace) + .where(eq(workspace.id, id)) + .execute() + .then((rows) => rows[0]); + }) +); + +export const forBusiness = zod(Info.shape.businessID, async (businessID) => + db.transaction(async (tx) => { + return tx + .select() + .from(workspace) + .where(eq(workspace.businessID, businessID)) + .execute(); + }) +); diff --git a/console/packages/core/src/workspace/workspace.sql.ts b/console/packages/core/src/workspace/workspace.sql.ts new file mode 100644 index 0000000000..6f0dbe2bd8 --- /dev/null +++ b/console/packages/core/src/workspace/workspace.sql.ts @@ -0,0 +1,19 @@ +import { + mysqlTable, + primaryKey, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; +import { timestamps, id, cuid } from "../util/sql"; + +export const workspace = mysqlTable( + "workspace", + { + ...id, + ...timestamps, + slug: varchar("slug", { length: 255 }).notNull(), + }, + (table) => ({ + primary: primaryKey(table.id), + }) +); diff --git a/console/packages/core/sst-env.d.ts b/console/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/console/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/console/packages/core/test/account.test.ts b/console/packages/core/test/account.test.ts new file mode 100644 index 0000000000..66fe214de5 --- /dev/null +++ b/console/packages/core/test/account.test.ts @@ -0,0 +1,15 @@ +import { expect, it } from "vitest"; +import { createId } from "@paralleldrive/cuid2"; +import { Account } from "../src/account"; + +it("create account", async (ctx) => { + const email = createId() + "@example.com"; + const accountID = createId(); + const account = await Account.create({ + email, + id: accountID, + }); + + expect(await Account.fromID(accountID).then((x) => x?.id)).toEqual(accountID); + expect(await Account.fromEmail(email).then((x) => x?.email)).toEqual(email); +}); diff --git a/console/packages/core/tsconfig.json b/console/packages/core/tsconfig.json new file mode 100644 index 0000000000..bd643ad90f --- /dev/null +++ b/console/packages/core/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "noUncheckedIndexedAccess": true + } +} diff --git a/console/packages/functions/package.json b/console/packages/functions/package.json new file mode 100644 index 0000000000..5d8331fe51 --- /dev/null +++ b/console/packages/functions/package.json @@ -0,0 +1,23 @@ +{ + "name": "@console/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/aws-lambda": "^8.10.114", + "@types/node": "^18.16.0", + "sst": "2.7.2" + }, + "dependencies": { + "@aws-sdk/client-lambda": "^3.332.0", + "@aws-sdk/client-sqs": "^3.332.0", + "@octokit/rest": "^19.0.7", + "drizzle-orm": "0.25.3", + "fast-jwt": "^2.2.1", + "replicache": "^12.2.1", + "zod": "^3.21.4" + } +} \ No newline at end of file diff --git a/console/packages/functions/src/api.ts b/console/packages/functions/src/api.ts new file mode 100644 index 0000000000..469341967c --- /dev/null +++ b/console/packages/functions/src/api.ts @@ -0,0 +1,35 @@ +import { useSession } from "sst/node/future/auth"; +import { assertActor, provideActor } from "@console/core/actor"; +import { useHeader } from "sst/node/api"; +import { User } from "@console/core/user"; + +export async function useApiAuth() { + const session = useSession(); + provideActor(session); + + const workspaceID = useHeader("x-sst-workspace"); + if (workspaceID) { + console.log("auth workspace", workspaceID); + const account = assertActor("account"); + provideActor({ + type: "system", + properties: { + workspaceID, + }, + }); + const user = await User.fromEmail(account.properties.email); + if (!user) + throw new Error( + `User not found for email ${account.properties.email} in workspace ${workspaceID}` + ); + + console.log("using user actor", user.id); + provideActor({ + type: "user", + properties: { + workspaceID, + userID: user.id, + }, + }); + } +} diff --git a/console/packages/functions/src/auth.ts b/console/packages/functions/src/auth.ts new file mode 100644 index 0000000000..f0049290ba --- /dev/null +++ b/console/packages/functions/src/auth.ts @@ -0,0 +1,83 @@ +import { AuthHandler, GithubAdapter, useSession } from "sst/node/future/auth"; +import { Config } from "sst/node/config"; +import { Octokit } from "@octokit/rest"; +import { Account } from "@console/core/account"; +import { Workspace } from "@console/core/workspace"; +import { User } from "@console/core/user"; +import { useTransaction } from "@console/core/util/transaction"; +import { createId } from "@console/core/util/sql"; +import { provideActor } from "@console/core/actor"; + +declare module "sst/node/future/auth" { + export interface SessionTypes { + account: { + accountID: string; + email: string; + }; + } +} + +export const handler = AuthHandler({ + providers: { + github: GithubAdapter({ + mode: "oauth", + scope: "read:user user:email", + clientID: Config.GITHUB_CLIENT_ID, + clientSecret: Config.GITHUB_CLIENT_SECRET, + }), + }, + async clients() { + return { + solid: "", + }; + }, + onSuccess: async (input) => { + let email: string | undefined; + + if (input.provider === "github") { + const o = new Octokit({ + auth: input.tokenset.access_token, + }); + const emails = await o.request("GET /user/emails"); + email = emails.data.find((x) => x.primary)?.email; + } + if (!email) throw new Error("No email found"); + + let accountID = await Account.fromEmail(email).then((x) => x?.id); + if (!accountID) { + await useTransaction(async () => { + accountID = await Account.create({ + email: email!, + }); + + const workspaceID = createId(); + await Workspace.create({ + slug: workspaceID, + id: workspaceID, + }); + + provideActor({ + type: "system", + properties: { + workspaceID, + }, + }); + + await User.create({ + email: email!, + }); + }); + } + + return { + type: "account", + properties: { + accountID: accountID!, + email: email!, + }, + }; + }, + onError: async () => ({ + statusCode: 401, + }), +}); diff --git a/console/packages/functions/src/events/app-stage-connected.ts b/console/packages/functions/src/events/app-stage-connected.ts new file mode 100644 index 0000000000..a1df7c325c --- /dev/null +++ b/console/packages/functions/src/events/app-stage-connected.ts @@ -0,0 +1,11 @@ +import { provideActor } from "@console/core/actor"; +import { EventHandler } from "./handler"; +import { Stage } from "@console/core/app/stage"; + +export const handler = EventHandler( + Stage.Events.Connected, + async (properties, actor) => { + provideActor(actor); + Stage.syncMetadata(properties.stageID); + } +); diff --git a/console/packages/functions/src/events/aws-account-created.ts b/console/packages/functions/src/events/aws-account-created.ts new file mode 100644 index 0000000000..aba111892c --- /dev/null +++ b/console/packages/functions/src/events/aws-account-created.ts @@ -0,0 +1,11 @@ +import { provideActor } from "@console/core/actor"; +import { EventHandler } from "./handler"; +import { AWS } from "@console/core/aws"; + +export const handler = EventHandler( + AWS.Account.Events.Created, + async (properties, actor) => { + provideActor(actor); + console.log("AWS Account Created", properties, actor); + } +); diff --git a/console/packages/functions/src/events/dlq.ts b/console/packages/functions/src/events/dlq.ts new file mode 100644 index 0000000000..3ae25fea71 --- /dev/null +++ b/console/packages/functions/src/events/dlq.ts @@ -0,0 +1,31 @@ +import { Handler } from "sst/context"; +import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; +import { Queue } from "sst/node/queue"; + +const sqs = new SQSClient({}); +export async function handler(evt: any) { + console.log("event failure", JSON.stringify(evt, null, 4)); + const attempt = (evt.requestPayload.attempts || 0) + 1; + evt.requestPayload.attempts = attempt; + const seconds = delay(attempt, 1, 60 * 15, 1); + console.log("delaying retry by ", seconds, "seconds"); + await sqs.send( + new SendMessageCommand({ + QueueUrl: Queue["bus-redriver"].queueUrl, + MessageBody: JSON.stringify(evt), + DelaySeconds: seconds, + }) + ); +} + +function delay( + attempt: number, + baseDelay: number, + maxDelay: number, + jitterFactor: number +): number { + const backoffTime = Math.min(maxDelay, baseDelay * Math.pow(2, attempt)); + const jitter = Math.random() * backoffTime * jitterFactor; + const delay = backoffTime + jitter; + return Math.floor(delay); +} diff --git a/console/packages/functions/src/events/handler.ts b/console/packages/functions/src/events/handler.ts new file mode 100644 index 0000000000..622fdfb49c --- /dev/null +++ b/console/packages/functions/src/events/handler.ts @@ -0,0 +1,23 @@ +import { Actor } from "@console/core/actor"; +import { EventBridgeHandler, EventBridgeEvent, SQSEvent } from "aws-lambda"; +import { ZodObject, ZodRawShape, z } from "zod"; + +export function EventHandler< + Event extends { + type: string; + shape: ZodObject; + } +>( + _events: Event, + cb: (properties: z.infer, actor: Actor) => Promise +) { + return async ( + event: EventBridgeEvent< + Event["type"], + { properties: z.infer; actor: Actor } + > + ) => { + console.log(event); + await cb(event.detail.properties, event.detail.actor); + }; +} diff --git a/console/packages/functions/src/events/redriver.ts b/console/packages/functions/src/events/redriver.ts new file mode 100644 index 0000000000..f33dab7a11 --- /dev/null +++ b/console/packages/functions/src/events/redriver.ts @@ -0,0 +1,17 @@ +import { Handler } from "sst/context"; +import { Lambda, LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda"; + +const lambda = new LambdaClient({}); +export const handler = Handler("sqs", async (evt) => { + for (const record of evt.Records) { + console.log("record", JSON.stringify(record, null, 4)); + const parsed = JSON.parse(record.body); + await lambda.send( + new InvokeCommand({ + InvocationType: "Event", + Payload: Buffer.from(JSON.stringify(parsed.requestPayload)), + FunctionName: parsed.requestContext.functionArn, + }) + ); + } +}); diff --git a/console/packages/functions/src/events/test.ts b/console/packages/functions/src/events/test.ts new file mode 100644 index 0000000000..df92347bed --- /dev/null +++ b/console/packages/functions/src/events/test.ts @@ -0,0 +1,5 @@ +import { EventHandler } from "./handler"; + +export const handler = EventHandler("test.event", async (properties, actor) => { + console.log("event", properties, actor); +}); diff --git a/console/packages/functions/src/lambda.ts b/console/packages/functions/src/lambda.ts new file mode 100644 index 0000000000..77bb963bc3 --- /dev/null +++ b/console/packages/functions/src/lambda.ts @@ -0,0 +1,8 @@ +import { ApiHandler } from "sst/node/api"; +import { Time } from "@console/core/time"; + +export const handler = ApiHandler(async (_evt) => { + return { + body: `Hello world. The time is ${Time.now()}`, + }; +}); diff --git a/console/packages/functions/src/replicache/framework.ts b/console/packages/functions/src/replicache/framework.ts new file mode 100644 index 0000000000..a9afdbef3e --- /dev/null +++ b/console/packages/functions/src/replicache/framework.ts @@ -0,0 +1,91 @@ +import { z, ZodAny, ZodObject, ZodRawShape, ZodSchema } from "zod"; +import { WriteTransaction } from "replicache"; + +interface Mutation { + name: Name; + input: Input; +} + +export class Server { + private mutations = new Map< + string, + { + input: ZodSchema; + fn: (input: any) => Promise; + } + >(); + + public mutation< + Name extends string, + Shape extends ZodRawShape, + Args = z.infer> + >( + name: Name, + shape: Shape, + fn: (input: z.infer>) => Promise + ): Server }> { + this.mutations.set(name as string, { + fn: async (args) => { + const parsed = args; + return fn(parsed); + }, + input: z.object(shape), + }); + return this; + } + + public expose< + Name extends string, + Shape extends ZodRawShape, + Args = z.infer> + >( + name: Name, + fn: (( + input: z.infer> + ) => Promise) & { + schema: { + shape: Shape; + }; + } + ): Server }> { + this.mutations.set(name as string, { + fn, + input: z.object(fn.schema.shape), + }); + return this; + } + + public execute(name: string, args: unknown) { + const mut = this.mutations.get(name as string); + if (!mut) throw new Error(`Mutation "${name}" not found`); + return mut.fn(args); + } +} + +type ExtractMutations> = S extends Server + ? M + : never; + +export class Client< + S extends Server, + Mutations extends Record = ExtractMutations +> { + private mutations = new Map Promise>(); + + public mutation< + Name extends keyof Mutations, + Input extends ZodRawShape = Mutations[Name]["input"] + >(name: Name, fn: (tx: WriteTransaction, input: Input) => Promise) { + this.mutations.set(name as string, fn); + return this; + } + + public build(): { + [key in keyof Mutations]: ( + ctx: WriteTransaction, + args: Mutations[key]["input"] + ) => Promise; + } { + return Object.fromEntries(this.mutations.entries()) as any; + } +} diff --git a/console/packages/functions/src/replicache/pull.ts b/console/packages/functions/src/replicache/pull.ts new file mode 100644 index 0000000000..5166b17e1c --- /dev/null +++ b/console/packages/functions/src/replicache/pull.ts @@ -0,0 +1,228 @@ +import { useActor, useWorkspace } from "@console/core/actor"; +import { Replicache } from "@console/core/replicache"; +import { user } from "@console/core/user/user.sql"; +import { useTransaction } from "@console/core/util/transaction"; +import { useApiAuth } from "src/api"; +import { ApiHandler, useJsonBody } from "sst/node/api"; +import { eq, and, gt } from "drizzle-orm"; +import { workspace } from "@console/core/workspace/workspace.sql"; +import { app, resource, stage } from "@console/core/app/app.sql"; +import { awsAccount } from "@console/core/aws/aws.sql"; + +const VERSION = 1; +export const handler = ApiHandler(async () => { + await useApiAuth(); + const actor = useActor(); + + if (actor.type === "public") { + return { + statusCode: 401, + }; + } + + const body = useJsonBody(); + const lastSync = + body.cookie && body.cookie.version === VERSION + ? body.cookie.lastSync + : new Date(0).toISOString(); + console.log("lastSync", lastSync); + const result = { + patch: [] as any[], + lastSync, + }; + + if (new Date(lastSync).getTime() === 0) { + result.patch.push({ + op: "clear", + }); + } + + return await useTransaction(async (tx) => { + const client = await Replicache.fromID(body.clientID); + + if (actor.type === "user") { + const workspaceID = useWorkspace(); + console.log("syncing user", actor.properties); + const [workspaces, users, awsAccounts, apps, stages, resources] = + await Promise.all([ + await tx + .select() + .from(workspace) + .where( + and( + eq(workspace.id, useWorkspace()), + gt(workspace.timeUpdated, lastSync) + ) + ) + .execute(), + await tx + .select() + .from(user) + .where( + and( + eq(user.workspaceID, useWorkspace()), + gt(user.timeUpdated, lastSync) + ) + ) + .execute(), + await tx + .select() + .from(awsAccount) + .where( + and( + eq(awsAccount.workspaceID, workspaceID), + gt(awsAccount.timeUpdated, lastSync) + ) + ) + .execute(), + await tx + .select() + .from(app) + .where( + and( + eq(app.workspaceID, workspaceID), + gt(app.timeUpdated, lastSync) + ) + ) + .execute(), + await tx + .select() + .from(stage) + .where( + and( + eq(stage.workspaceID, workspaceID), + gt(stage.timeUpdated, lastSync) + ) + ) + .execute(), + await tx + .select() + .from(resource) + .where( + and( + eq(resource.workspaceID, workspaceID), + gt(resource.timeUpdated, lastSync) + ) + ) + .execute(), + ]); + result.patch.push( + ...users.map((item) => ({ + op: "put", + key: `/user/${item.id}`, + value: item, + })), + ...workspaces.map((item) => ({ + op: "put", + key: `/workspace/${item.id}`, + value: item, + })), + ...apps.map((item) => ({ + op: "put", + key: `/app/${item.id}`, + value: item, + })), + ...stages.map((item) => ({ + op: "put", + key: `/stage/${item.id}`, + value: item, + })), + ...awsAccounts.map((item) => ({ + op: "put", + key: `/aws_account/${item.id}`, + value: item, + })), + ...resources.map((item) => ({ + op: "put", + key: `/resource/${item.id}`, + value: item, + })) + ); + result.lastSync = + result.patch + .filter((x) => x.op === "put") + .sort((a, b) => + (b.value.timeUpdated || "") > (a.value.timeUpdated || "") ? 1 : -1 + )[0]?.value?.timeUpdated || lastSync; + } + + if (actor.type === "account") { + console.log("syncing account", actor.properties); + const [users] = await Promise.all([ + await tx + .select() + .from(user) + .where( + and( + eq(user.email, actor.properties.email), + gt(user.timeUpdated, lastSync) + ) + ) + .execute(), + ]); + + const workspaces = await tx + .select() + .from(workspace) + .leftJoin(user, eq(user.workspaceID, workspace.id)) + .where( + and( + eq(user.email, actor.properties.email), + gt(workspace.timeUpdated, lastSync) + ) + ) + .execute() + .then((rows) => rows.map((row) => row.workspace)); + console.log("workspaces", workspaces); + + /* + const workspaces = + users.length > 0 + ? await tx + .select() + .from(workspace) + .where( + and( + inArray( + workspace.id, + users.map((u) => u.workspaceID) + ), + gt(workspace.timeUpdated, lastSync) + ) + ) + .execute() + : []; + */ + console.log("found workspaces", workspaces); + + result.patch.push( + ...users.map((item) => ({ + op: "put", + key: `/user/${item.id}`, + value: item, + })), + ...workspaces.map((item) => ({ + op: "put", + key: `/workspace/${item.id}`, + value: item, + })) + ); + result.lastSync = + [...workspaces, ...users].sort((a, b) => + b.timeUpdated > a.timeUpdated ? 1 : -1 + )[0]?.timeUpdated || lastSync; + } + + return { + statusCode: 200, + body: JSON.stringify({ + lastMutationID: client?.mutationID || 0, + patch: result.patch, + cookie: { + version: VERSION, + lastSync: result.lastSync, + }, + }), + }; + }); +}); diff --git a/console/packages/functions/src/replicache/push.ts b/console/packages/functions/src/replicache/push.ts new file mode 100644 index 0000000000..3680d3af4b --- /dev/null +++ b/console/packages/functions/src/replicache/push.ts @@ -0,0 +1,55 @@ +import { useApiAuth } from "src/api"; +import { ApiHandler, useJsonBody } from "sst/node/api"; +import { useTransaction } from "@console/core/util/transaction"; +import { Replicache } from "@console/core/replicache"; +import { server } from "./server"; +import { useActor } from "@console/core/actor"; + +export const handler = ApiHandler(async () => { + await useApiAuth(); + console.log("Pushing for", useActor()); + + const body = useJsonBody(); + await useTransaction(async (tx) => { + let mutationID = await (async function () { + const result = await Replicache.fromID(body.clientID); + if (result) return result.mutationID; + await Replicache.create(body.clientID); + return 0; + })(); + + for (const mutation of body.mutations) { + const expectedMutationID = mutationID + 1; + + if (mutation.id < expectedMutationID) { + console.log( + `Mutation ${mutation.id} has already been processed - skipping` + ); + continue; + } + + if (mutation.id > expectedMutationID) { + console.warn(`Mutation ${mutation.id} is from the future - aborting`); + break; + } + + const { args, name } = mutation; + try { + await server.execute(name, args); + } catch (ex) { + console.error(ex); + } + + mutationID = expectedMutationID; + } + + await Replicache.setMutationID({ + clientID: body.clientID, + mutationID, + }); + }); + + return { + statusCode: 200, + }; +}); diff --git a/console/packages/functions/src/replicache/server.ts b/console/packages/functions/src/replicache/server.ts new file mode 100644 index 0000000000..3c40c1de7c --- /dev/null +++ b/console/packages/functions/src/replicache/server.ts @@ -0,0 +1,39 @@ +import { Server } from "./framework"; +import { App } from "@console/core/app"; +import { AWS } from "@console/core/aws"; +import { User } from "@console/core/user"; +import { z } from "zod"; + +export const server = new Server() + .mutation( + "connect", + { + app: z.string(), + aws_account_id: z.string(), + stage: z.string(), + region: z.string(), + }, + async (input) => { + let appID = await App.fromName(input.app).then((x) => x?.id); + if (!appID) appID = await App.create({ name: input.app }); + + let awsID = await AWS.Account.fromAccountID(input.aws_account_id).then( + (x) => x?.id + ); + + if (!awsID) + awsID = await AWS.Account.create({ + accountID: input.aws_account_id, + }); + + await App.Stage.connect({ + appID, + name: input.stage, + awsAccountID: awsID, + region: input.region, + }); + } + ) + .expose(User.create); + +export type ServerType = typeof server; diff --git a/console/packages/functions/sst-env.d.ts b/console/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/console/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/console/packages/functions/tsconfig.json b/console/packages/functions/tsconfig.json new file mode 100644 index 0000000000..41918dfc32 --- /dev/null +++ b/console/packages/functions/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "noUncheckedIndexedAccess": true, + "module": "esnext", + "baseUrl": ".", + "paths": { + "@console/core/*": ["../core/src/*"] + } + } +} diff --git a/console/packages/scripts/package.json b/console/packages/scripts/package.json new file mode 100644 index 0000000000..fd5fcdf353 --- /dev/null +++ b/console/packages/scripts/package.json @@ -0,0 +1,13 @@ +{ + "name": "@console/scripts", + "version": "0.0.0", + "type": "module", + "scripts": { + "start": "sst bind tsx" + }, + "dependencies": { + "@tsconfig/node16": "^1.0.3", + "sst": "2.7.2", + "tsx": "^3.12.7" + } +} diff --git a/console/packages/scripts/src/scrap.ts b/console/packages/scripts/src/scrap.ts new file mode 100644 index 0000000000..769379a1a0 --- /dev/null +++ b/console/packages/scripts/src/scrap.ts @@ -0,0 +1,15 @@ +import { provideActor } from "@console/core/actor"; +import { App, Stage } from "@console/core/app"; +import { User } from "@console/core/user"; + +provideActor({ + type: "system", + properties: { + workspaceID: "a8hf2o91zf79zbnt6wodqxq0", + }, +}); + +await Stage.Events.Connected.publish({ + stageID: "vdapvhs9olt0fdzsfja99x5t", +}); +// const result = await App.Stage.syncMetadata("vdapvhs9olt0fdzsfja99x5t"); diff --git a/console/packages/scripts/tsconfig.json b/console/packages/scripts/tsconfig.json new file mode 100644 index 0000000000..41918dfc32 --- /dev/null +++ b/console/packages/scripts/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "noUncheckedIndexedAccess": true, + "module": "esnext", + "baseUrl": ".", + "paths": { + "@console/core/*": ["../core/src/*"] + } + } +} diff --git a/console/packages/web/workspace/.gitignore b/console/packages/web/workspace/.gitignore new file mode 100644 index 0000000000..76add878f8 --- /dev/null +++ b/console/packages/web/workspace/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/console/packages/web/workspace/README.md b/console/packages/web/workspace/README.md new file mode 100644 index 0000000000..434f7bb9df --- /dev/null +++ b/console/packages/web/workspace/README.md @@ -0,0 +1,34 @@ +## Usage + +Those templates dependencies are maintained via [pnpm](https://pnpm.io) via `pnpm up -Lri`. + +This is the reason you see a `pnpm-lock.yaml`. That being said, any package manager will work. This file can be safely be removed once you clone a template. + +```bash +$ npm install # or pnpm install or yarn install +``` + +### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs) + +## Available Scripts + +In the project directory, you can run: + +### `npm dev` or `npm start` + +Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.
+ +### `npm run build` + +Builds the app for production to the `dist` folder.
+It correctly bundles Solid in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.
+Your app is ready to be deployed! + +## Deployment + +You can deploy the `dist` folder to any static host provider (netlify, surge, now, etc.) diff --git a/console/packages/web/workspace/index.html b/console/packages/web/workspace/index.html new file mode 100644 index 0000000000..48c59fc124 --- /dev/null +++ b/console/packages/web/workspace/index.html @@ -0,0 +1,16 @@ + + + + + + + + Solid App + + + +
+ + + + diff --git a/console/packages/web/workspace/package.json b/console/packages/web/workspace/package.json new file mode 100644 index 0000000000..7d2508cc00 --- /dev/null +++ b/console/packages/web/workspace/package.json @@ -0,0 +1,29 @@ +{ + "name": "@console/workspace", + "version": "0.0.0", + "description": "", + "scripts": { + "start": "vite", + "dev": "sst bind vite", + "build": "vite build", + "serve": "vite preview" + }, + "license": "MIT", + "devDependencies": { + "@macaron-css/vite": "^1.3.0", + "sst": "2.7.2", + "typescript": "^4.9.5", + "vite": "3", + "vite-plugin-solid": "^2.7.0" + }, + "dependencies": { + "@fontsource/ibm-plex-mono": "^4.5.13", + "@macaron-css/core": "^1.2.0", + "@macaron-css/solid": "^1.0.1", + "@paralleldrive/cuid2": "^2.2.0", + "@solidjs/router": "^0.8.2", + "modern-normalize": "^1.1.0", + "replicache": "^12.2.1", + "solid-js": "^1.7.3" + } +} diff --git a/console/packages/web/workspace/src/App.tsx b/console/packages/web/workspace/src/App.tsx new file mode 100644 index 0000000000..566e34ac31 --- /dev/null +++ b/console/packages/web/workspace/src/App.tsx @@ -0,0 +1,94 @@ +import "@fontsource/ibm-plex-mono/latin.css"; + +import { Component, For } from "solid-js"; +import { Link, Route, Router, Routes } from "@solidjs/router"; +import { AuthProvider, useAuth } from "./data/auth"; +import { createSubscription } from "./data/replicache"; +import { UserStore } from "./data/user"; +import { WorkspaceStore } from "./data/workspace"; +import { Workspace } from "./pages/workspace"; +import { Connect } from "./pages/connect"; +import { Debug } from "./pages/debug"; +import { styled } from "@macaron-css/solid"; +import { globalStyle } from "@macaron-css/core"; +import { lightClass } from "./ui/theme"; + +console.log(import.meta.env.VITE_API_URL); +const Root = styled("div", { + base: { + inset: 0, + position: "fixed", + }, +}); + +globalStyle("*:focus", { + border: 0, + outline: 0, +}); + +export const App: Component = () => { + return ( + + + + + + + + + + + + + ); +}; + +function Header() { + const auth = useAuth(); + + return ( + + {(entry) => { + const users = createSubscription( + UserStore.list, + [], + () => entry.replicache + ); + return ( +
    +
  1. {users()[0]?.email}
  2. +
      + + {(user) => { + const workspace = createSubscription( + () => WorkspaceStore.fromID(user.workspaceID), + undefined, + () => entry.replicache + ); + return ( +
    1. + + {" "} + Workspace: {workspace()?.slug} + +
    2. + ); + }} +
      +
    +
+ ); + }} +
+ ); +} + +// App +// -> look for any login tokens +// -> redirect to default +// -> if none found, redirect to login +// Workspace +// -> make sure the login token exists + works +// -> otherwise redirect to login diff --git a/console/packages/web/workspace/src/assets/favicon.ico b/console/packages/web/workspace/src/assets/favicon.ico new file mode 100644 index 0000000000..b836b2bcca Binary files /dev/null and b/console/packages/web/workspace/src/assets/favicon.ico differ diff --git a/console/packages/web/workspace/src/data/app.ts b/console/packages/web/workspace/src/data/app.ts new file mode 100644 index 0000000000..fc38cf1ea3 --- /dev/null +++ b/console/packages/web/workspace/src/data/app.ts @@ -0,0 +1,29 @@ +import { ReadTransaction, WriteTransaction } from "replicache"; +import type { App } from "@console/core/app"; + +export function list() { + return async (tx: ReadTransaction) => { + const result = await tx.scan({ prefix: `/app/` }).toArray(); + return (result || []) as App.Info[]; + }; +} + +export function fromID(id: string) { + return async (tx: ReadTransaction) => { + const result = await tx.get(`/app/${id}`); + return result as App.Info; + }; +} + +export async function put(tx: WriteTransaction, app: App.Info) { + await tx.put(`/app/${app}`, app); +} + +export function fromName(name: string) { + return async (tx: ReadTransaction) => { + const all = await list()(tx); + return all.find((item) => item.name === name); + }; +} + +export * as AppStore from "./app"; diff --git a/console/packages/web/workspace/src/data/auth.tsx b/console/packages/web/workspace/src/data/auth.tsx new file mode 100644 index 0000000000..3802617b06 --- /dev/null +++ b/console/packages/web/workspace/src/data/auth.tsx @@ -0,0 +1,91 @@ +import { Navigate } from "@solidjs/router"; +import { Replicache } from "replicache"; +import { ParentProps, createContext, useContext } from "solid-js"; + +export * as AuthStore from "./auth"; + +interface AuthData { + [accountID: string]: Token; +} + +interface Token { + email: string; + accountID: string; + token: string; +} + +function get() { + return JSON.parse(localStorage.getItem("auth") || "{}") as AuthData; +} + +function set(auth: AuthData) { + return localStorage.setItem("auth", JSON.stringify(auth)); +} + +function login() { + const params = new URLSearchParams({ + client_id: "solid", + redirect_uri: location.origin + "/", + response_type: "token", + provider: "github", + }); + const url = import.meta.env.VITE_AUTH_URL + "/authorize?" + params.toString(); + return url; +} + +type AuthContextType = Record< + string, + { + token: Token; + replicache: Replicache; + } +>; +const AuthContext = createContext(); + +export function AuthProvider(props: ParentProps) { + const tokens = get(); + const fragment = new URLSearchParams(location.hash.substring(1)); + const access_token = fragment.get("access_token"); + if (access_token) { + const [_headerEncoded, payloadEncoded] = access_token.split("."); + const payload = JSON.parse( + atob(payloadEncoded.replace(/-/g, "+").replace(/_/g, "/")) + ); + tokens[payload.properties.accountID] = { + token: access_token, + ...payload.properties, + }; + set(tokens); + } + + console.log("Auth Info", tokens); + + if (Object.values(tokens).length === 0) { + location.href = login(); + return; + } + + const stores: AuthContextType = {}; + for (const token of Object.values(tokens)) { + stores[token.accountID] = { + token, + replicache: new Replicache({ + name: token.accountID, + auth: `Bearer ${token.token}`, + licenseKey: "l24ea5a24b71247c1b2bb78fa2bca2336", + pullURL: import.meta.env.VITE_API_URL + "/replicache/pull", + pushURL: import.meta.env.VITE_API_URL + "/replicache/push", + }), + }; + } + + return ( + {props.children} + ); +} + +export function useAuth() { + const result = useContext(AuthContext); + if (!result) throw new Error("useAuth must be used within a AuthProvider"); + return result; +} diff --git a/console/packages/web/workspace/src/data/aws/account.ts b/console/packages/web/workspace/src/data/aws/account.ts new file mode 100644 index 0000000000..36df43a02d --- /dev/null +++ b/console/packages/web/workspace/src/data/aws/account.ts @@ -0,0 +1,25 @@ +import { ReadTransaction } from "replicache"; +import type { Account } from "@console/core/aws/account"; + +export function list() { + return async (tx: ReadTransaction) => { + const result = await tx.scan({ prefix: `/aws_account/` }).toArray(); + return (result || []) as unknown as Account.Info[]; + }; +} + +export function fromID(id: string) { + return async (tx: ReadTransaction) => { + const result = await tx.get(`/aws_account/${id}`); + return result as unknown as Account.Info; + }; +} + +export function fromAccountID(accountID: string) { + return async (tx: ReadTransaction) => { + const all = await list()(tx); + return all.find((item) => item.accountID === accountID); + }; +} + +export * as AccountStore from "./account"; diff --git a/console/packages/web/workspace/src/data/aws/index.ts b/console/packages/web/workspace/src/data/aws/index.ts new file mode 100644 index 0000000000..5ec71a1b17 --- /dev/null +++ b/console/packages/web/workspace/src/data/aws/index.ts @@ -0,0 +1,3 @@ +export * as AWS from "./account"; + +export { AccountStore } from "./account"; diff --git a/console/packages/web/workspace/src/data/replicache.tsx b/console/packages/web/workspace/src/data/replicache.tsx new file mode 100644 index 0000000000..30d21c7772 --- /dev/null +++ b/console/packages/web/workspace/src/data/replicache.tsx @@ -0,0 +1,120 @@ +import { Replicache, ReadTransaction } from "replicache"; +import { + ParentProps, + Show, + createContext, + createEffect, + createMemo, + onCleanup, + useContext, +} from "solid-js"; +import { createStore, reconcile } from "solid-js/store"; +import { useAuth } from "./auth"; +import type { ServerType } from "@console/functions/replicache/server"; +import { Client } from "../../../../functions/src/replicache/framework"; + +const mutators = new Client() + .mutation("connect", async (tx, input) => {}) + .build(); + +const ReplicacheContext = + createContext<() => ReturnType>(); + +function createReplicache(workspaceID: string, token: string) { + const replicache = new Replicache({ + name: workspaceID, + auth: `Bearer ${token}`, + licenseKey: "l24ea5a24b71247c1b2bb78fa2bca2336", + pullURL: import.meta.env.VITE_API_URL + "/replicache/pull", + pushURL: import.meta.env.VITE_API_URL + "/replicache/push", + pullInterval: 10 * 1000, + mutators, + }); + + replicache.subscribe( + (tx) => { + return tx.scan({ prefix: "" }).entries().toArray(); + }, + { + onData: console.log, + } + ); + + const oldPuller = replicache.puller; + replicache.puller = (opts) => { + opts.headers.append("x-sst-workspace", workspaceID); + return oldPuller(opts); + }; + + const oldPusher = replicache.pusher; + replicache.pusher = (opts) => { + opts.headers.append("x-sst-workspace", workspaceID); + return oldPusher(opts); + }; + + return replicache; +} + +export function ReplicacheProvider( + props: ParentProps<{ accountID: string; workspaceID: string }> +) { + const tokens = useAuth(); + const token = createMemo(() => tokens[props.accountID]?.token.token); + + const rep = createMemo(() => { + return createReplicache(props.workspaceID, token()!); + }); + + onCleanup(() => { + rep().close(); + }); + + return ( + + + {props.children} + + + ); +} + +export function useReplicache() { + const result = useContext(ReplicacheContext); + if (!result) { + throw new Error("useReplicache must be used within a ReplicacheProvider"); + } + + return result; +} + +export function createSubscription( + body: () => (tx: ReadTransaction) => Promise, + initial?: D, + replicache?: () => Replicache +) { + const [store, setStore] = createStore({ result: initial as any }); + + let unsubscribe: () => void; + + createEffect(() => { + if (unsubscribe) unsubscribe(); + setStore({ result: initial as any }); + + const r = replicache ? replicache() : useReplicache()(); + unsubscribe = r.subscribe( + // @ts-expect-error + body(), + { + onData: (val) => { + setStore(reconcile({ result: val })); + }, + } + ); + }); + + onCleanup(() => { + if (unsubscribe) unsubscribe(); + }); + + return () => store.result as R | D; +} diff --git a/console/packages/web/workspace/src/data/stage.ts b/console/packages/web/workspace/src/data/stage.ts new file mode 100644 index 0000000000..7bb069a239 --- /dev/null +++ b/console/packages/web/workspace/src/data/stage.ts @@ -0,0 +1,25 @@ +import { ReadTransaction } from "replicache"; +import type { Stage } from "@console/core/app/stage"; + +export function list() { + return async (tx: ReadTransaction) => { + const result = await tx.scan({ prefix: `/stage/` }).toArray(); + return (result || []) as unknown as Stage.Info[]; + }; +} + +export function fromID(id: string) { + return async (tx: ReadTransaction) => { + const result = await tx.get(`/stage/${id}`); + return result as unknown as Stage.Info; + }; +} + +export function forApp(appID: string) { + return async (tx: ReadTransaction) => { + const all = await list()(tx); + return all.filter((stage) => stage.appID === appID); + }; +} + +export * as StageStore from "./stage"; diff --git a/console/packages/web/workspace/src/data/user.ts b/console/packages/web/workspace/src/data/user.ts new file mode 100644 index 0000000000..692bcac943 --- /dev/null +++ b/console/packages/web/workspace/src/data/user.ts @@ -0,0 +1,20 @@ +import { ReadTransaction } from "replicache"; +import type { User } from "../../../../core/src/user"; + +export function list() { + return async (tx: ReadTransaction) => { + const result = await tx.scan({ prefix: `/user/` }).toArray(); + return (result || []) as unknown as User.Info[]; + }; +} + +export function fromID(id: string) { + return async (tx: ReadTransaction) => { + const result = await tx.get(`/user/${id}`); + return result as unknown as User.Info; + }; +} + +export type UserInfo = User.Info; + +export * as UserStore from "./user"; diff --git a/console/packages/web/workspace/src/data/workspace.ts b/console/packages/web/workspace/src/data/workspace.ts new file mode 100644 index 0000000000..02ce1df6a0 --- /dev/null +++ b/console/packages/web/workspace/src/data/workspace.ts @@ -0,0 +1,18 @@ +import { ReadTransaction } from "replicache"; +import type { Workspace } from "../../../../core/src/workspace"; + +export function list() { + return async (tx: ReadTransaction) => { + const result = await tx.scan({ prefix: `/workspace/` }).toArray(); + return (result || []) as unknown as Workspace.Info[]; + }; +} + +export function fromID(id: string) { + return async (tx: ReadTransaction) => { + const result = await tx.get(`/workspace/${id}`); + return result as unknown as Workspace.Info; + }; +} + +export * as WorkspaceStore from "./workspace"; diff --git a/console/packages/web/workspace/src/index.css b/console/packages/web/workspace/src/index.css new file mode 100644 index 0000000000..e8cae275ca --- /dev/null +++ b/console/packages/web/workspace/src/index.css @@ -0,0 +1,14 @@ + +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} diff --git a/console/packages/web/workspace/src/index.tsx b/console/packages/web/workspace/src/index.tsx new file mode 100644 index 0000000000..bbb12fa216 --- /dev/null +++ b/console/packages/web/workspace/src/index.tsx @@ -0,0 +1,16 @@ +/* @refresh reload */ +import { render } from "solid-js/web"; + +import "./index.css"; +import "modern-normalize/modern-normalize.css"; +import { App } from "./App"; + +const root = document.getElementById("root"); + +if (import.meta.env.DEV && !(root instanceof HTMLElement)) { + throw new Error( + "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got mispelled?" + ); +} + +render(() => , root!); diff --git a/console/packages/web/workspace/src/logo.svg b/console/packages/web/workspace/src/logo.svg new file mode 100644 index 0000000000..025aa303c5 --- /dev/null +++ b/console/packages/web/workspace/src/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/console/packages/web/workspace/src/pages/auth/index.tsx b/console/packages/web/workspace/src/pages/auth/index.tsx new file mode 100644 index 0000000000..87453cce8d --- /dev/null +++ b/console/packages/web/workspace/src/pages/auth/index.tsx @@ -0,0 +1,50 @@ +import { Route, Routes, Navigate } from "@solidjs/router"; +import { useReplicache } from "../../data/replicache"; + +export function Auth() { + return ( + + + + + ); +} + +function Provider() { + const params = { + client_id: "solid", + redirect_uri: location.origin + "/auth/workspaces", + response_type: "token", + }; + + return ( +
    +
  1. + + Github + +
  2. +
+ ); +} + +function Workspaces() { + const params = new URLSearchParams(location.hash.slice(1)); + const replicache = useReplicache(); + const access_token = params.get("access_token"); + if (!access_token) return ; + replicache.auth = access_token; + location.hash = ""; + replicache.pull(); + + return

Workspaces

; +} diff --git a/console/packages/web/workspace/src/pages/connect/index.tsx b/console/packages/web/workspace/src/pages/connect/index.tsx new file mode 100644 index 0000000000..4ea9ed9ad6 --- /dev/null +++ b/console/packages/web/workspace/src/pages/connect/index.tsx @@ -0,0 +1,51 @@ +import { Link, useSearchParams } from "@solidjs/router"; +import { createSubscription, useReplicache } from "../../data/replicache"; +import { useAuth } from "../../data/auth"; +import { For } from "solid-js"; +import { UserStore } from "../../data/user"; +import { WorkspaceStore } from "../../data/workspace"; + +export function Connect() { + const auth = useAuth(); + return ( +
+ Which workspace should we connect to? + + {(entry) => { + const users = createSubscription( + UserStore.list, + [], + () => entry.replicache + ); + return ( +
    +
  1. {users()[0]?.email}
  2. +
      + + {(user) => { + const workspace = createSubscription( + () => WorkspaceStore.fromID(user.workspaceID), + () => entry.replicache + ); + return ( +
    1. + + {" "} + Workspace: {workspace()?.slug} + +
    2. + ); + }} +
      +
    +
+ ); + }} +
+
+ ); +} diff --git a/console/packages/web/workspace/src/pages/debug/index.tsx b/console/packages/web/workspace/src/pages/debug/index.tsx new file mode 100644 index 0000000000..e8f4aa275d --- /dev/null +++ b/console/packages/web/workspace/src/pages/debug/index.tsx @@ -0,0 +1,11 @@ +import { Stack } from "../../ui/layout"; + +export function Debug() { + return ( + +
Hello
+
Bye
+
a
+
+ ); +} diff --git a/console/packages/web/workspace/src/pages/workspace/apps/index.tsx b/console/packages/web/workspace/src/pages/workspace/apps/index.tsx new file mode 100644 index 0000000000..51fd6ab23e --- /dev/null +++ b/console/packages/web/workspace/src/pages/workspace/apps/index.tsx @@ -0,0 +1,39 @@ +import { Link, Navigate, Route, Routes, useParams } from "@solidjs/router"; +import { Stages } from "./stages"; +import { createSubscription } from "../../../data/replicache"; +import { AppStore } from "../../../data/app"; +import { For } from "solid-js"; + +export function Apps() { + return ( + + + + + ); +} + +export function List() { + const apps = createSubscription(AppStore.list); + + return ( +
    + + {(app) => ( +
  • + {app.name} +
  • + )} +
    +
+ ); +} + +export function Single() { + return ( + + + } /> + + ); +} diff --git a/console/packages/web/workspace/src/pages/workspace/apps/stages/index.tsx b/console/packages/web/workspace/src/pages/workspace/apps/stages/index.tsx new file mode 100644 index 0000000000..2b0791b83e --- /dev/null +++ b/console/packages/web/workspace/src/pages/workspace/apps/stages/index.tsx @@ -0,0 +1,30 @@ +import { Link, Route, Routes, useParams } from "@solidjs/router"; +import { createSubscription } from "../../../../data/replicache"; +import { StageStore } from "../../../../data/stage"; +import { For } from "solid-js"; +import { Single } from "./single"; + +export function Stages() { + return ( + + + + + ); +} + +export function List() { + const params = useParams(); + const stages = createSubscription(() => StageStore.forApp(params.appID)); + return ( +
    + + {(stage) => ( +
  • + {stage.name} +
  • + )} +
    +
+ ); +} diff --git a/console/packages/web/workspace/src/pages/workspace/apps/stages/single.tsx b/console/packages/web/workspace/src/pages/workspace/apps/stages/single.tsx new file mode 100644 index 0000000000..79b8b4b495 --- /dev/null +++ b/console/packages/web/workspace/src/pages/workspace/apps/stages/single.tsx @@ -0,0 +1,48 @@ +import { styled } from "@macaron-css/solid"; +import { Button } from "../../../../ui/button"; +import { theme } from "../../../../ui/theme"; + +const Root = styled("div", { + base: { + position: "fixed", + inset: 0, + display: "flex", + }, +}); + +const Sidebar = styled("div", { + base: { + width: "240px", + flexShrink: 0, + borderRight: "1px solid hsl(240deg 28% 14% / 8%)", + }, +}); + +const SidebarHeader = styled("div", { + base: { + padding: theme.space[4], + }, +}); + +const SidebarAvatar = styled("div", { + base: { + width: 36, + aspectRatio: "1/1", + background: "black", + borderRadius: 4, + }, +}); +export function Single() { + return ( + + + + + + +
+ +
+
+ ); +} diff --git a/console/packages/web/workspace/src/pages/workspace/command-bar.tsx b/console/packages/web/workspace/src/pages/workspace/command-bar.tsx new file mode 100644 index 0000000000..9b1770fc3e --- /dev/null +++ b/console/packages/web/workspace/src/pages/workspace/command-bar.tsx @@ -0,0 +1,11 @@ +import { Router } from "@solidjs/router"; + +interface Action { + path: string[]; +} + +const STATIC_ACTIONS: Action[] = []; + +export function CommandBar() { + return
; +} diff --git a/console/packages/web/workspace/src/pages/workspace/connect.tsx b/console/packages/web/workspace/src/pages/workspace/connect.tsx new file mode 100644 index 0000000000..ef628cc6cf --- /dev/null +++ b/console/packages/web/workspace/src/pages/workspace/connect.tsx @@ -0,0 +1,30 @@ +import { useParams, useSearchParams } from "@solidjs/router"; +import { useReplicache } from "../../data/replicache"; +import { createId } from "@paralleldrive/cuid2"; + +export function Connect() { + const params = useParams(); + const replicache = useReplicache(); + const [query] = useSearchParams(); + + return ( +
+
Account: {query.aws_account_id}
+
App: {query.app}
+
Stage: {query.stage}
+
Region: {query.region}
+ +
+ ); +} diff --git a/console/packages/web/workspace/src/pages/workspace/index.tsx b/console/packages/web/workspace/src/pages/workspace/index.tsx new file mode 100644 index 0000000000..f63bbb23b2 --- /dev/null +++ b/console/packages/web/workspace/src/pages/workspace/index.tsx @@ -0,0 +1,23 @@ +import { Link, Navigate, Route, Routes, useParams } from "@solidjs/router"; +import { ReplicacheProvider, createSubscription } from "../../data/replicache"; +import { Connect } from "./connect"; +import { Apps } from "./apps"; +import { AppStore } from "../../data/app"; +import { For } from "solid-js"; + +export function Workspace() { + const params = useParams(); + + return ( + + + + + } /> + + + ); +} diff --git a/console/packages/web/workspace/src/sst-env.d.ts b/console/packages/web/workspace/src/sst-env.d.ts new file mode 100644 index 0000000000..e130b870ea --- /dev/null +++ b/console/packages/web/workspace/src/sst-env.d.ts @@ -0,0 +1,8 @@ +/// +interface ImportMetaEnv { + readonly VITE_API_URL: string + readonly VITE_AUTH_URL: string +} +interface ImportMeta { + readonly env: ImportMetaEnv +} \ No newline at end of file diff --git a/console/packages/web/workspace/src/ui/button.tsx b/console/packages/web/workspace/src/ui/button.tsx new file mode 100644 index 0000000000..0971cb87cb --- /dev/null +++ b/console/packages/web/workspace/src/ui/button.tsx @@ -0,0 +1,39 @@ +import { styled } from "@macaron-css/solid"; +import { theme } from "./theme"; + +export const Button = styled("button", { + base: { + appearance: "none", + borderRadius: 4, + border: "1px solid", + padding: `0.625rem 1rem`, + fontSize: `0.8125rem`, + fontWeight: 500, + lineHeight: 1, + fontFamily: theme.font.mono, + transitionDelay: "0s, 0s", + transitionDuration: "0.2s, 0.2s", + transitionProperty: "background-color, border", + transitionTimingFunction: "ease-out, ease-out", + }, + variants: { + color: { + danger: { + backgroundColor: theme.color.danger.surface, + borderColor: theme.color.danger.border, + boxShadow: theme.color.danger.shadow, + color: theme.color.danger.foreground, + ":hover": { + borderColor: theme.color.danger.hover.border, + backgroundColor: theme.color.danger.hover.surface, + }, + ":active": { + borderColor: theme.color.danger.active.border, + backgroundColor: theme.color.danger.active.surface, + transform: "translateY(1px)", + boxShadow: "none", + }, + }, + }, + }, +}); diff --git a/examples/sst-transform/index.ts b/console/packages/web/workspace/src/ui/index.ts similarity index 100% rename from examples/sst-transform/index.ts rename to console/packages/web/workspace/src/ui/index.ts diff --git a/console/packages/web/workspace/src/ui/layout.tsx b/console/packages/web/workspace/src/ui/layout.tsx new file mode 100644 index 0000000000..35a6fe25a9 --- /dev/null +++ b/console/packages/web/workspace/src/ui/layout.tsx @@ -0,0 +1,43 @@ +import { styled } from "@macaron-css/solid"; +import { theme } from "./theme"; + +export const Stack = styled("div", { + base: { + display: "flex", + flexDirection: "column", + }, + variants: { + space: (() => { + const result = {} as Record<`${keyof (typeof theme)["space"]}`, any>; + for (const key in theme.space) { + const value = theme.space[key as keyof typeof theme.space]; + result[key as keyof typeof theme.space] = { + gap: value, + }; + } + return result; + })(), + horizontal: { + center: { + alignItems: "center", + }, + start: { + alignItems: "flex-start", + }, + end: { + alignItems: "flex-end", + }, + }, + vertical: { + center: { + justifyContent: "center", + }, + start: { + justifyContent: "flex-start", + }, + end: { + justifyContent: "flex-end", + }, + }, + }, +}); diff --git a/console/packages/web/workspace/src/ui/theme.ts b/console/packages/web/workspace/src/ui/theme.ts new file mode 100644 index 0000000000..f70e1d4cda --- /dev/null +++ b/console/packages/web/workspace/src/ui/theme.ts @@ -0,0 +1,69 @@ +import { + createGlobalTheme, + createThemeContract, + createTheme, +} from "@macaron-css/core"; + +export const [lightClass, theme] = createTheme({ + color: { + danger: { + border: "hsl(2deg 84% 43%)", + surface: "hsl(2deg 84% 55%)", + foreground: "hsl(0deg 0% 100% / 93%)", + shadow: + "hsl(2.11deg 84.52% 67.06% / 80%) 0px 1px 0px 0px inset, hsl(240deg 29.41% 10% / 10%) 0px 1px 1px 0px, hsl(240deg 29.41% 10% / 10%) 0px 2px 2px 0px", + hover: { + surface: "hsl(2deg 84% 61%)", + border: "hsl(2deg 84% 49%)", + }, + active: { + surface: "hsl(2deg 84% 49%)", + border: "transparent", + }, + }, + }, + font: { + mono: "IBM Plex Mono", + }, + space: { + px: "1px", + 0: "0px", + 0.5: "0.125rem", + 1: "0.25rem", + 1.5: "0.375rem", + 2: "0.5rem", + 2.5: "0.625rem", + 3: "0.75rem", + 3.5: "0.875rem", + 4: "1rem", + 5: "1.25rem", + 6: "1.5rem", + 7: "1.75rem", + 8: "2rem", + 9: "2.25rem", + 10: "2.5rem", + 11: "2.75rem", + 12: "3rem", + 14: "3.5rem", + 16: "4rem", + 20: "5rem", + 24: "6rem", + 28: "7rem", + 32: "8rem", + 36: "9rem", + 40: "10rem", + 44: "11rem", + 48: "12rem", + 52: "13rem", + 56: "14rem", + 60: "15rem", + 64: "16rem", + 72: "18rem", + 80: "20rem", + 96: "24rem", + }, +}); + +export const darkClass = createTheme(theme, { + ...theme, +}); diff --git a/console/packages/web/workspace/tsconfig.json b/console/packages/web/workspace/tsconfig.json new file mode 100644 index 0000000000..161a8e4575 --- /dev/null +++ b/console/packages/web/workspace/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + "types": ["vite/client"], + "noEmit": true, + "isolatedModules": true, + "baseUrl": ".", + "paths": { + "@console/functions/*": ["../../functions/src/*"], + "@console/core/*": ["../../core/src/*"] + } + + } +} diff --git a/console/packages/web/workspace/vite.config.ts b/console/packages/web/workspace/vite.config.ts new file mode 100644 index 0000000000..0ce2580573 --- /dev/null +++ b/console/packages/web/workspace/vite.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from "vite"; +import solidPlugin from "vite-plugin-solid"; +import { macaronVitePlugin } from "@macaron-css/vite"; +import path from "path"; + +export default defineConfig({ + plugins: [macaronVitePlugin(), solidPlugin()], + server: { + port: 3000, + }, + build: { + target: "esnext", + }, + resolve: { + alias: { + "@console/functions": path.resolve(__dirname, "../../functions/src"), + "@console/core": path.resolve(__dirname, "../../core/src"), + }, + }, +}); diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml new file mode 100644 index 0000000000..40fab18905 --- /dev/null +++ b/console/pnpm-lock.yaml @@ -0,0 +1,8422 @@ +lockfileVersion: '6.0' + +importers: + + .: + devDependencies: + '@tsconfig/node16': + specifier: ^1.0.3 + version: 1.0.3 + aws-cdk-lib: + specifier: 2.72.1 + version: 2.72.1(constructs@10.1.156) + constructs: + specifier: 10.1.156 + version: 10.1.156 + sst: + specifier: 2.7.2 + version: 2.7.2 + typescript: + specifier: ^5.0.4 + version: 5.0.4 + + packages/core: + dependencies: + '@aws-sdk/client-cloudformation': + specifier: ^3.326.0 + version: 3.326.0 + '@aws-sdk/client-eventbridge': + specifier: ^3.325.0 + version: 3.325.0 + '@aws-sdk/client-s3': + specifier: ^3.326.0 + version: 3.326.0(@aws-sdk/signature-v4-crt@3.310.0) + '@aws-sdk/client-sts': + specifier: ^3.321.1 + version: 3.321.1 + '@octokit/rest': + specifier: ^19.0.7 + version: 19.0.7 + '@paralleldrive/cuid2': + specifier: ^2.2.0 + version: 2.2.0 + '@planetscale/database': + specifier: ^1.7.0 + version: 1.7.0 + drizzle-orm: + specifier: 0.25.3 + version: 0.25.3(@aws-sdk/client-rds-data@3.319.0)(@planetscale/database@1.7.0)(kysely@0.23.5) + drizzle-zod: + specifier: 0.4.1 + version: 0.4.1(drizzle-orm@0.25.3)(zod@3.21.4) + undici: + specifier: ^5.22.0 + version: 5.22.0 + zod: + specifier: ^3.21.4 + version: 3.21.4 + devDependencies: + '@types/node': + specifier: ^18.16.0 + version: 18.16.0 + drizzle-kit: + specifier: 0.17.6-76e73f3 + version: 0.17.6-76e73f3 + sst: + specifier: 2.7.2 + version: 2.7.2 + vitest: + specifier: ^0.25.3 + version: 0.25.3 + + packages/functions: + dependencies: + '@aws-sdk/client-lambda': + specifier: ^3.332.0 + version: 3.332.0 + '@aws-sdk/client-sqs': + specifier: ^3.332.0 + version: 3.332.0 + '@octokit/rest': + specifier: ^19.0.7 + version: 19.0.7 + drizzle-orm: + specifier: 0.25.3 + version: 0.25.3(@aws-sdk/client-rds-data@3.319.0)(@planetscale/database@1.7.0)(kysely@0.23.5) + fast-jwt: + specifier: ^2.2.1 + version: 2.2.1 + replicache: + specifier: ^12.2.1 + version: 12.2.1 + zod: + specifier: ^3.21.4 + version: 3.21.4 + devDependencies: + '@types/aws-lambda': + specifier: ^8.10.114 + version: 8.10.114 + '@types/node': + specifier: ^18.16.0 + version: 18.16.0 + sst: + specifier: 2.7.2 + version: 2.7.2 + + packages/scripts: + dependencies: + '@tsconfig/node16': + specifier: ^1.0.3 + version: 1.0.3 + sst: + specifier: 2.7.2 + version: 2.7.2 + tsx: + specifier: ^3.12.7 + version: 3.12.7 + + packages/web/workspace: + dependencies: + '@fontsource/ibm-plex-mono': + specifier: ^4.5.13 + version: 4.5.13 + '@macaron-css/core': + specifier: ^1.2.0 + version: 1.2.0 + '@macaron-css/solid': + specifier: ^1.0.1 + version: 1.0.1(@vanilla-extract/recipes@0.2.5)(solid-js@1.7.3) + '@paralleldrive/cuid2': + specifier: ^2.2.0 + version: 2.2.0 + '@solidjs/router': + specifier: ^0.8.2 + version: 0.8.2(solid-js@1.7.3) + modern-normalize: + specifier: ^1.1.0 + version: 1.1.0 + replicache: + specifier: ^12.2.1 + version: 12.2.1 + solid-js: + specifier: ^1.7.3 + version: 1.7.3 + devDependencies: + '@macaron-css/vite': + specifier: ^1.3.0 + version: 1.3.0(vite@3.2.6) + sst: + specifier: 2.7.2 + version: 2.7.2 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + vite: + specifier: '3' + version: 3.2.6(@types/node@18.16.0) + vite-plugin-solid: + specifier: ^2.7.0 + version: 2.7.0(solid-js@1.7.3)(vite@3.2.6) + +packages: + + /@ampproject/remapping@2.2.1: + resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.18 + + /@aws-cdk/asset-awscli-v1@2.2.149: + resolution: {integrity: sha512-vndvY78xsO3S8mGF5eqKdLCBJALuV2h90tWA80xNgXqI3X95Z0tUxgFtI9LrxcH3147dAcar1c1gWMMFdY5zoQ==} + + /@aws-cdk/asset-kubectl-v20@2.1.1: + resolution: {integrity: sha512-U1ntiX8XiMRRRH5J1IdC+1t5CE89015cwyt5U63Cpk0GnMlN5+h9WsWMlKlPXZR4rdq/m806JRlBMRpBUB2Dhw==} + + /@aws-cdk/asset-node-proxy-agent-v5@2.0.126: + resolution: {integrity: sha512-NzMIFA6VdX0JDnTU3UPZhwYC/tQqSn5yEeDNfACxoiZ4Ey+z8pIkQ3DBldqdAw8+YMKxblmyaA6pBy2xzqLLOg==} + + /@aws-cdk/aws-apigatewayv2-alpha@2.72.1-alpha.0(aws-cdk-lib@2.72.1)(constructs@10.1.156): + resolution: {integrity: sha512-3DIUZjqLsPEzewlbXyYXrhrVPfQV+VR4sU1slgwXal/D27+PuM/E3g6R2Oq3V9mwaSrJaTlGP0o+y5i8o/aQtQ==} + engines: {node: '>= 14.15.0'} + peerDependencies: + aws-cdk-lib: ^2.72.1 + constructs: ^10.0.0 + dependencies: + aws-cdk-lib: 2.72.1(constructs@10.1.156) + constructs: 10.1.156 + + /@aws-cdk/aws-apigatewayv2-authorizers-alpha@2.72.1-alpha.0(@aws-cdk/aws-apigatewayv2-alpha@2.72.1-alpha.0)(aws-cdk-lib@2.72.1)(constructs@10.1.156): + resolution: {integrity: sha512-a7Ljs69uF4iV/myy0BirPd4vP9teAykvg6qGmvJY3XJEyZtkQ++ipxa4MIS54HGL1GWua0wVno5Ta97hhiqYeg==} + engines: {node: '>= 14.15.0'} + peerDependencies: + '@aws-cdk/aws-apigatewayv2-alpha': 2.72.1-alpha.0 + aws-cdk-lib: ^2.72.1 + constructs: ^10.0.0 + dependencies: + '@aws-cdk/aws-apigatewayv2-alpha': 2.72.1-alpha.0(aws-cdk-lib@2.72.1)(constructs@10.1.156) + aws-cdk-lib: 2.72.1(constructs@10.1.156) + constructs: 10.1.156 + + /@aws-cdk/aws-apigatewayv2-integrations-alpha@2.72.1-alpha.0(@aws-cdk/aws-apigatewayv2-alpha@2.72.1-alpha.0)(aws-cdk-lib@2.72.1)(constructs@10.1.156): + resolution: {integrity: sha512-KbPy/P6BduZZ32E0xzm1EobGAhgMklWPfSJ1DGQ8eKZ9KhcP1BoDqbA7zg8TnI84QAItArvMfai3XYe9Q78gjA==} + engines: {node: '>= 14.15.0'} + peerDependencies: + '@aws-cdk/aws-apigatewayv2-alpha': 2.72.1-alpha.0 + aws-cdk-lib: ^2.72.1 + constructs: ^10.0.0 + dependencies: + '@aws-cdk/aws-apigatewayv2-alpha': 2.72.1-alpha.0(aws-cdk-lib@2.72.1)(constructs@10.1.156) + aws-cdk-lib: 2.72.1(constructs@10.1.156) + constructs: 10.1.156 + + /@aws-cdk/cfnspec@2.72.1: + resolution: {integrity: sha512-qF6zQXXJPpRwI3uS5+whGtJdQFwxH7gSwW6Xa8xdXWWEUazDEgKOLt9isw8As8vH8bCRAxukOkogGq1+xMG30w==} + dependencies: + fs-extra: 9.1.0 + md5: 2.3.0 + + /@aws-cdk/cloud-assembly-schema@2.72.1: + resolution: {integrity: sha512-sffYNtKZbhGACfRX6BnDlp4ruHaqkuElwEnMIaiaih4ro2Z0+a960wKkpC6P5tKf/KWUkNocu91qeKgqvIxYmA==} + engines: {node: '>= 14.15.0'} + dependencies: + jsonschema: 1.4.1 + semver: 7.5.0 + bundledDependencies: + - jsonschema + - semver + + /@aws-cdk/cloudformation-diff@2.72.1: + resolution: {integrity: sha512-Clou31yR6xNEcaxJx8+PCNRmqMEWEh9F59txjC9UlvtWCGHNi94LsScdunJRTFIwoiUNxXrNWQFZrOq362+RbA==} + engines: {node: '>= 14.15.0'} + dependencies: + '@aws-cdk/cfnspec': 2.72.1 + chalk: 4.1.2 + diff: 5.1.0 + fast-deep-equal: 3.1.3 + string-width: 4.2.3 + table: 6.8.1 + + /@aws-cdk/cx-api@2.72.1(@aws-cdk/cloud-assembly-schema@2.72.1): + resolution: {integrity: sha512-ATNdCF0mqXvF1oj0B4SD7gcadOqt12y1jt1agtor4CKw3C3hH4gjG5CuRvtY5F4Sc1YEhssE7y8gtr6WJgYsCA==} + engines: {node: '>= 14.15.0'} + peerDependencies: + '@aws-cdk/cloud-assembly-schema': 2.72.1 + dependencies: + '@aws-cdk/cloud-assembly-schema': 2.72.1 + semver: 7.5.0 + bundledDependencies: + - semver + + /@aws-crypto/crc32@3.0.0: + resolution: {integrity: sha512-IzSgsrxUcsrejQbPVilIKy16kAT52EwB6zSaI+M3xxIhKh5+aldEyvI+z6erM7TCLB2BJsFrtHjp6/4/sr+3dA==} + dependencies: + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.329.0 + tslib: 1.14.1 + + /@aws-crypto/crc32c@3.0.0: + resolution: {integrity: sha512-ENNPPManmnVJ4BTXlOjAgD7URidbAznURqD0KvfREyc4o20DPYdEldU1f5cQ7Jbj0CJJSPaMIk/9ZshdB3210w==} + dependencies: + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.329.0 + tslib: 1.14.1 + + /@aws-crypto/ie11-detection@3.0.0: + resolution: {integrity: sha512-341lBBkiY1DfDNKai/wXM3aujNBkXR7tq1URPQDL9wi3AUbI80NR74uF1TXHMm7po1AcnFk8iu2S2IeU/+/A+Q==} + dependencies: + tslib: 1.14.1 + + /@aws-crypto/sha1-browser@3.0.0: + resolution: {integrity: sha512-NJth5c997GLHs6nOYTzFKTbYdMNA6/1XlKVgnZoaZcQ7z7UJlOgj2JdbHE8tiYLS3fzXNCguct77SPGat2raSw==} + dependencies: + '@aws-crypto/ie11-detection': 3.0.0 + '@aws-crypto/supports-web-crypto': 3.0.0 + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-locate-window': 3.310.0 + '@aws-sdk/util-utf8-browser': 3.259.0 + tslib: 1.14.1 + + /@aws-crypto/sha256-browser@3.0.0: + resolution: {integrity: sha512-8VLmW2B+gjFbU5uMeqtQM6Nj0/F1bro80xQXCW6CQBWgosFWXTx77aeOF5CAIAmbOK64SdMBJdNr6J41yP5mvQ==} + dependencies: + '@aws-crypto/ie11-detection': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-crypto/supports-web-crypto': 3.0.0 + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-locate-window': 3.310.0 + '@aws-sdk/util-utf8-browser': 3.259.0 + tslib: 1.14.1 + + /@aws-crypto/sha256-js@3.0.0: + resolution: {integrity: sha512-PnNN7os0+yd1XvXAy23CFOmTbMaDxgxXtTKHybrJ39Y8kGzBATgBFibWJKH6BhytLI/Zyszs87xCOBNyBig6vQ==} + dependencies: + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.329.0 + tslib: 1.14.1 + + /@aws-crypto/supports-web-crypto@3.0.0: + resolution: {integrity: sha512-06hBdMwUAb2WFTuGG73LSC0wfPu93xWwo5vL2et9eymgmu3Id5vFAHBbajVWiGhPO37qcsdCap/FqXvJGJWPIg==} + dependencies: + tslib: 1.14.1 + + /@aws-crypto/util@3.0.0: + resolution: {integrity: sha512-2OJlpeJpCR48CC8r+uKVChzs9Iungj9wkZrl8Z041DWEWvyIHILYKCPNzJghKsivj+S3mLo6BVc7mBNzdxA46w==} + dependencies: + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-utf8-browser': 3.259.0 + tslib: 1.14.1 + + /@aws-sdk/abort-controller@3.310.0: + resolution: {integrity: sha512-v1zrRQxDLA1MdPim159Vx/CPHqsB4uybSxRi1CnfHO5ZjHryx3a5htW2gdGAykVCul40+yJXvfpufMrELVxH+g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/abort-controller@3.329.0: + resolution: {integrity: sha512-hzrjPNQcJoSPe0oS20V5i98oiEZSM3mKNiR6P3xHTHTPI/F23lyjGZ+/CSkCmJbSWfGZ5sHZZcU6AWuS7xBdTw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/chunked-blob-reader@3.310.0: + resolution: {integrity: sha512-CrJS3exo4mWaLnWxfCH+w88Ou0IcAZSIkk4QbmxiHl/5Dq705OLoxf4385MVyExpqpeVJYOYQ2WaD8i/pQZ2fg==} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/client-cloudformation@3.326.0: + resolution: {integrity: sha512-Sc8E5m9xbKoouZ82kr0w9BTvZwD9TdMnzV/Tn1sw5v+Y/kJ5SGoMlOD61PXk+9S1vu06WrRY1ffILu1tuyVZgQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.326.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.326.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + '@aws-sdk/util-waiter': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + uuid: 8.3.2 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-cognito-identity@3.319.0: + resolution: {integrity: sha512-rOLKrCFP6j23MBCd1DEKPzHOvrS7oiWmAfJmGAuX+7qo/Dbx3j99KOVyZLgL1uTJQhtGRkWB+fwmubCaBN8Arw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.319.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-eventbridge@3.325.0: + resolution: {integrity: sha512-1tPvXbigH/rpiM+IZywRHCaSK9UPVN/rWt+/3bkAxUqpkuZp0MwOt1JqxS9RytolUx7TO3WWb5YMR/7kMIkGNg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.325.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.325.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/signature-v4-multi-region': 3.310.0(@aws-sdk/signature-v4-crt@3.310.0) + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - '@aws-sdk/signature-v4-crt' + - aws-crt + dev: false + + /@aws-sdk/client-iot-data-plane@3.319.0: + resolution: {integrity: sha512-Lpeug5dB950j9j0EVFdizACVFD9Aws+BdpIY1+v66tehaS2y4qizLe/LlWxewSsx2Ild0kr2wqZU0scdzazh4A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.319.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-iot@3.319.0: + resolution: {integrity: sha512-n7/sNNmAoGhg38xgxRCY9SgFWt77fPndeSVtvmZMckOYp5pViuTTdS6128t1HbBu58y5208HLt5H527wOjGOQQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.319.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + uuid: 8.3.2 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-lambda@3.332.0: + resolution: {integrity: sha512-7W0Dkgm8n6QyRzVzZDLqSGc52p4HByHfIL9fEXq96Opn0bB2tzH19+PMYaelnaRpq/L/NaFiIVzvxN7GiZ8m4A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.332.0 + '@aws-sdk/config-resolver': 3.329.0 + '@aws-sdk/credential-provider-node': 3.332.0 + '@aws-sdk/eventstream-serde-browser': 3.329.0 + '@aws-sdk/eventstream-serde-config-resolver': 3.329.0 + '@aws-sdk/eventstream-serde-node': 3.329.0 + '@aws-sdk/fetch-http-handler': 3.329.0 + '@aws-sdk/hash-node': 3.329.0 + '@aws-sdk/invalid-dependency': 3.329.0 + '@aws-sdk/middleware-content-length': 3.329.0 + '@aws-sdk/middleware-endpoint': 3.329.0 + '@aws-sdk/middleware-host-header': 3.329.0 + '@aws-sdk/middleware-logger': 3.329.0 + '@aws-sdk/middleware-recursion-detection': 3.329.0 + '@aws-sdk/middleware-retry': 3.329.0 + '@aws-sdk/middleware-serde': 3.329.0 + '@aws-sdk/middleware-signing': 3.329.0 + '@aws-sdk/middleware-stack': 3.329.0 + '@aws-sdk/middleware-user-agent': 3.332.0 + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/node-http-handler': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/smithy-client': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.329.0 + '@aws-sdk/util-defaults-mode-node': 3.329.0 + '@aws-sdk/util-endpoints': 3.332.0 + '@aws-sdk/util-retry': 3.329.0 + '@aws-sdk/util-user-agent-browser': 3.329.0 + '@aws-sdk/util-user-agent-node': 3.329.0 + '@aws-sdk/util-utf8': 3.310.0 + '@aws-sdk/util-waiter': 3.329.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-rds-data@3.319.0: + resolution: {integrity: sha512-Ld7Vl24mv5akK88ZX9bNjzwdx66PZ87rBDrd2gWdUr++6ptTxo5yS5LsTnqfD45uUL0P8kl7b7C0RxJmJNZJ+w==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.319.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-s3@3.326.0(@aws-sdk/signature-v4-crt@3.310.0): + resolution: {integrity: sha512-fRlwZoerdRw+xHf6n+xFc0rRDmofjVdJl2hRD+nqXk8IVp5pRbG0OqtJGT/0KRc0Eoobk66+nHvh2dvEPdIGlw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha1-browser': 3.0.0 + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.326.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.326.0 + '@aws-sdk/eventstream-serde-browser': 3.310.0 + '@aws-sdk/eventstream-serde-config-resolver': 3.310.0 + '@aws-sdk/eventstream-serde-node': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-blob-browser': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/hash-stream-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/md5-js': 3.310.0 + '@aws-sdk/middleware-bucket-endpoint': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-expect-continue': 3.325.0 + '@aws-sdk/middleware-flexible-checksums': 3.326.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-location-constraint': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-sdk-s3': 3.326.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/middleware-ssec': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/signature-v4-multi-region': 3.310.0(@aws-sdk/signature-v4-crt@3.310.0) + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-stream-browser': 3.310.0 + '@aws-sdk/util-stream-node': 3.321.1 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + '@aws-sdk/util-waiter': 3.310.0 + '@aws-sdk/xml-builder': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - '@aws-sdk/signature-v4-crt' + - aws-crt + + /@aws-sdk/client-sqs@3.332.0: + resolution: {integrity: sha512-mn7xBZw//TSTVeJqpd8URucoYtHqdk7qnYaoZTKhhAfJ4xq41Trogwufi3G1hzohKPHFDmZrR7oi9S4pAj9GrA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.332.0 + '@aws-sdk/config-resolver': 3.329.0 + '@aws-sdk/credential-provider-node': 3.332.0 + '@aws-sdk/fetch-http-handler': 3.329.0 + '@aws-sdk/hash-node': 3.329.0 + '@aws-sdk/invalid-dependency': 3.329.0 + '@aws-sdk/md5-js': 3.329.0 + '@aws-sdk/middleware-content-length': 3.329.0 + '@aws-sdk/middleware-endpoint': 3.329.0 + '@aws-sdk/middleware-host-header': 3.329.0 + '@aws-sdk/middleware-logger': 3.329.0 + '@aws-sdk/middleware-recursion-detection': 3.329.0 + '@aws-sdk/middleware-retry': 3.329.0 + '@aws-sdk/middleware-sdk-sqs': 3.329.0 + '@aws-sdk/middleware-serde': 3.329.0 + '@aws-sdk/middleware-signing': 3.329.0 + '@aws-sdk/middleware-stack': 3.329.0 + '@aws-sdk/middleware-user-agent': 3.332.0 + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/node-http-handler': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/smithy-client': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.329.0 + '@aws-sdk/util-defaults-mode-node': 3.329.0 + '@aws-sdk/util-endpoints': 3.332.0 + '@aws-sdk/util-retry': 3.329.0 + '@aws-sdk/util-user-agent-browser': 3.329.0 + '@aws-sdk/util-user-agent-node': 3.329.0 + '@aws-sdk/util-utf8': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/client-ssm@3.319.0: + resolution: {integrity: sha512-4sfqJt9ip30vK5A0GC/sZwipljDwr6WhPfqhBn+cUdvRHCXlbv/i+lyFuW2ThF7xwiiTn2Mqm70ppyYi7WaApQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.319.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + '@aws-sdk/util-waiter': 3.310.0 + tslib: 2.5.0 + uuid: 8.3.2 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso-oidc@3.319.0: + resolution: {integrity: sha512-GJBgT/tephRZY3oTbDBMv+G9taoqKUIvGPn+7shmzz2P1SerutsRSfKfDXV+VptPNRoGmjjCLPmWjMFYbFKILQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso-oidc@3.321.1: + resolution: {integrity: sha512-PBVfHQbyrsfzbnO6u9d9Sik8JlXGLhHj3zLd87iBkYXBdHwD5NuvwWu7OtjUtrHjP4SfzodVwfjmTbDAFqbtzw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso-oidc@3.325.0: + resolution: {integrity: sha512-D20mpgiZ5/O/CAR18F16h7hJlcmPvOjh6IcjtZexte0NhkSO4oV1MzgmXT/aWOo2zIeovPRzZTNULAH24sosNQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/client-sso-oidc@3.326.0: + resolution: {integrity: sha512-JLxIiWDKYUExYOzsxSPV8nf9w4mmgkkZ495GtSF6YnZhh0Ryxp3yB7KjsEgF3opOVo7uXkkgz4y30GWFzD1pEg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso-oidc@3.332.0: + resolution: {integrity: sha512-tz8k8Yqm4TScIfit0Tum2zWAq1md+gZKr747CSixd4Zwcp7Vwh75cRoL7Rz1ZHSEn1Yo983MWREevVez3SubLw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.329.0 + '@aws-sdk/fetch-http-handler': 3.329.0 + '@aws-sdk/hash-node': 3.329.0 + '@aws-sdk/invalid-dependency': 3.329.0 + '@aws-sdk/middleware-content-length': 3.329.0 + '@aws-sdk/middleware-endpoint': 3.329.0 + '@aws-sdk/middleware-host-header': 3.329.0 + '@aws-sdk/middleware-logger': 3.329.0 + '@aws-sdk/middleware-recursion-detection': 3.329.0 + '@aws-sdk/middleware-retry': 3.329.0 + '@aws-sdk/middleware-serde': 3.329.0 + '@aws-sdk/middleware-stack': 3.329.0 + '@aws-sdk/middleware-user-agent': 3.332.0 + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/node-http-handler': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/smithy-client': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.329.0 + '@aws-sdk/util-defaults-mode-node': 3.329.0 + '@aws-sdk/util-endpoints': 3.332.0 + '@aws-sdk/util-retry': 3.329.0 + '@aws-sdk/util-user-agent-browser': 3.329.0 + '@aws-sdk/util-user-agent-node': 3.329.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso@3.319.0: + resolution: {integrity: sha512-g46KgAjRiYBS8Oi85DPwSAQpt+Hgmw/YFgGVwZqMfTL70KNJwLFKRa5D9UocQd7t7OjPRdKF7g0Gp5peyAK9dw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso@3.321.1: + resolution: {integrity: sha512-ecoT4tBGtRJR5G7oLBTMXZmgZZlff1amhSdKPEtkWxv6kWc8VPb5rRuRgVPsDR9HuesI6ZVlODptvGtnfkIJwA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso@3.325.0: + resolution: {integrity: sha512-ajxL7cVtK0OPQz37hnKDbL6hPBNv3+sTgyZ+RTuBxjS3MKh/TVu/yXfrL+hfFFMijk494b7CctgRZrTABEvWdw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/client-sso@3.326.0: + resolution: {integrity: sha512-dLV9JyTvalh/0vIMd+eJ93n4lvmXcBqXuSFJkyFnyFN/HAB/zC8XB3ccZ1DbwydWMpyVevW6h8+z2gGcq6mweQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sso@3.332.0: + resolution: {integrity: sha512-4q1Nko8M6YVANdEiLYvdv1qb00j4xN4ppE/6d4xpGp7DxHYlm0GA762h0/TR2dun+2I+SMnwj4Fv6BxOmzBaEw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.329.0 + '@aws-sdk/fetch-http-handler': 3.329.0 + '@aws-sdk/hash-node': 3.329.0 + '@aws-sdk/invalid-dependency': 3.329.0 + '@aws-sdk/middleware-content-length': 3.329.0 + '@aws-sdk/middleware-endpoint': 3.329.0 + '@aws-sdk/middleware-host-header': 3.329.0 + '@aws-sdk/middleware-logger': 3.329.0 + '@aws-sdk/middleware-recursion-detection': 3.329.0 + '@aws-sdk/middleware-retry': 3.329.0 + '@aws-sdk/middleware-serde': 3.329.0 + '@aws-sdk/middleware-stack': 3.329.0 + '@aws-sdk/middleware-user-agent': 3.332.0 + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/node-http-handler': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/smithy-client': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.329.0 + '@aws-sdk/util-defaults-mode-node': 3.329.0 + '@aws-sdk/util-endpoints': 3.332.0 + '@aws-sdk/util-retry': 3.329.0 + '@aws-sdk/util-user-agent-browser': 3.329.0 + '@aws-sdk/util-user-agent-node': 3.329.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sts@3.319.0: + resolution: {integrity: sha512-PRGGKCSKtyM3x629J9j4DMsH1cQT8UGW+R67u9Q5HrMK05gfjpmg+X1DQ3pgve4D8MI4R/Cm3NkYl2eUTbQHQg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-sdk-sts': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sts@3.321.1: + resolution: {integrity: sha512-AB+N4a1TVEKl9Sd5O2TxTprEZp7Va6zPZLMraFAYMdmJVBmCmmwyBs7ygju685DpQ1dos5PRsKCRcossyY5pDQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.321.1 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.310.0 + '@aws-sdk/middleware-endpoint': 3.310.0 + '@aws-sdk/middleware-host-header': 3.310.0 + '@aws-sdk/middleware-logger': 3.310.0 + '@aws-sdk/middleware-recursion-detection': 3.310.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-sdk-sts': 3.310.0 + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/middleware-user-agent': 3.319.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.316.0 + '@aws-sdk/util-defaults-mode-node': 3.316.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sts@3.325.0: + resolution: {integrity: sha512-5ZOScg5EvyLV59mDUxSbL9x10cUbZsoSqvNETGLruyXILHaRHa8WS00wffcDA/dRzKIk9xQwJNwplcWnpT8WUw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.325.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-sdk-sts': 3.325.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/client-sts@3.326.0: + resolution: {integrity: sha512-kVxqOqfoTsObH085AbD6MVdizju03h9bmxDNRXm8ehGtQUDN6B3aqZ78Hp4DryBC87W8SdlehzuRkByW8gQL4A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-node': 3.326.0 + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/hash-node': 3.310.0 + '@aws-sdk/invalid-dependency': 3.310.0 + '@aws-sdk/middleware-content-length': 3.325.0 + '@aws-sdk/middleware-endpoint': 3.325.0 + '@aws-sdk/middleware-host-header': 3.325.0 + '@aws-sdk/middleware-logger': 3.325.0 + '@aws-sdk/middleware-recursion-detection': 3.325.0 + '@aws-sdk/middleware-retry': 3.325.0 + '@aws-sdk/middleware-sdk-sts': 3.326.0 + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/middleware-user-agent': 3.325.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/smithy-client': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.325.0 + '@aws-sdk/util-defaults-mode-node': 3.325.0 + '@aws-sdk/util-endpoints': 3.319.0 + '@aws-sdk/util-retry': 3.310.0 + '@aws-sdk/util-user-agent-browser': 3.310.0 + '@aws-sdk/util-user-agent-node': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/client-sts@3.332.0: + resolution: {integrity: sha512-uVobnXIzMcEhwBDyk6iOt36N/TRNI8hwq7MQugjYGj7Inma9g4vnR09hXJ24HxyKCoVUoIgMbEguQ43+/+uvDQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/config-resolver': 3.329.0 + '@aws-sdk/credential-provider-node': 3.332.0 + '@aws-sdk/fetch-http-handler': 3.329.0 + '@aws-sdk/hash-node': 3.329.0 + '@aws-sdk/invalid-dependency': 3.329.0 + '@aws-sdk/middleware-content-length': 3.329.0 + '@aws-sdk/middleware-endpoint': 3.329.0 + '@aws-sdk/middleware-host-header': 3.329.0 + '@aws-sdk/middleware-logger': 3.329.0 + '@aws-sdk/middleware-recursion-detection': 3.329.0 + '@aws-sdk/middleware-retry': 3.329.0 + '@aws-sdk/middleware-sdk-sts': 3.329.0 + '@aws-sdk/middleware-serde': 3.329.0 + '@aws-sdk/middleware-signing': 3.329.0 + '@aws-sdk/middleware-stack': 3.329.0 + '@aws-sdk/middleware-user-agent': 3.332.0 + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/node-http-handler': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/smithy-client': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-body-length-browser': 3.310.0 + '@aws-sdk/util-body-length-node': 3.310.0 + '@aws-sdk/util-defaults-mode-browser': 3.329.0 + '@aws-sdk/util-defaults-mode-node': 3.329.0 + '@aws-sdk/util-endpoints': 3.332.0 + '@aws-sdk/util-retry': 3.329.0 + '@aws-sdk/util-user-agent-browser': 3.329.0 + '@aws-sdk/util-user-agent-node': 3.329.0 + '@aws-sdk/util-utf8': 3.310.0 + fast-xml-parser: 4.1.2 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/config-resolver@3.310.0: + resolution: {integrity: sha512-8vsT+/50lOqfDxka9m/rRt6oxv1WuGZoP8oPMk0Dt+TxXMbAzf4+rejBgiB96wshI1k3gLokYRjSQZn+dDtT8g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-config-provider': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/config-resolver@3.329.0: + resolution: {integrity: sha512-Oj6eiT3q+Jn685yvUrfRi8PhB3fb81hasJqdrsEivA8IP8qAgnVUTJzXsh8O2UX8UM2MF6A1gTgToSgneJuw2Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-config-provider': 3.310.0 + '@aws-sdk/util-middleware': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-cognito-identity@3.319.0: + resolution: {integrity: sha512-TbNeV4jJXwBtsVackghUGVgTJ3YPb+9saZ7KJD60FMoTWsoRsftPDFVY58KezSaVvfy8xg+RPLkX+s8r43qaMg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-cognito-identity': 3.319.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-env@3.310.0: + resolution: {integrity: sha512-vvIPQpI16fj95xwS7M3D48F7QhZJBnnCgB5lR+b7So+vsG9ibm1mZRVGzVpdxCvgyOhHFbvrby9aalNJmmIP1A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-env@3.329.0: + resolution: {integrity: sha512-B4orC9hMt9hG82vAR0TAnQqjk6cFDbO2S14RdzUj2n2NPlGWW4Blkv3NTo86K0lq011VRhtqaLcuTwn5EJD5Sg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-imds@3.310.0: + resolution: {integrity: sha512-baxK7Zp6dai5AGW01FIW27xS2KAaPUmKLIXv5SvFYsUgXXvNW55im4uG3b+2gA0F7V+hXvVBH08OEqmwW6we5w==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-imds@3.329.0: + resolution: {integrity: sha512-ggPlnd7QROPTid0CwT01TYYGvstRRTpzTGsQ/B31wkh30IrRXE81W3S4xrOYuqQD3u0RnflSxnvhs+EayJEYjg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-ini@3.319.0: + resolution: {integrity: sha512-pzx388Fw1KlSgmIMUyRY8DJVYM3aXpwzjprD4RiQVPJeAI+t7oQmEvd2FiUZEuHDjWXcuonxgU+dk7i7HUk/HQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.319.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-ini@3.321.1: + resolution: {integrity: sha512-prndSVQhiikNaI40bYnM2Q8PkC35FCwhbQnBk6KXNvdtfo9RqatMC639F+6oryb3BuMy++Ij4Yoi8WnPBs5Sww==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.321.1 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-ini@3.325.0: + resolution: {integrity: sha512-jvNEHU4zEBbtvf2JqiC2ENb0Y55BurA5X6KVBP1vA3mvn7+zIGH9qD1nAkpvrRelzuorbC5Ey7AmZshR+AugTg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.325.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/credential-provider-ini@3.326.0: + resolution: {integrity: sha512-6iaDk2W1HOtQMMynbSy3VHumfGG8jkbAZ0tXPAbIXxN7w65GObOsamOkUBRp+Y6A+JuZYJyu1CRFHASENluJOA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.326.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-ini@3.332.0: + resolution: {integrity: sha512-DTW6d6rcqizPVyvcIrwvxecQ7e5GONtVc5Wyf0RTfqf41sDOVZYmn6G+zEFSpBLW0975uZbJS0lyLWtJe2VujQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.329.0 + '@aws-sdk/credential-provider-imds': 3.329.0 + '@aws-sdk/credential-provider-process': 3.329.0 + '@aws-sdk/credential-provider-sso': 3.332.0 + '@aws-sdk/credential-provider-web-identity': 3.329.0 + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/shared-ini-file-loader': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-node@3.319.0: + resolution: {integrity: sha512-DS4a0Rdd7ZtMshoeE+zuSgbC05YBcdzd0h89u/eX+1Yqx+HCjeb8WXkbXsz0Mwx8q9TE04aS8f6Bw9J4x4mO5g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-ini': 3.319.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.319.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-node@3.321.1: + resolution: {integrity: sha512-5B1waOwSvY2JMLGRebo7IUqnTaGoCnby9cRbG/dhi7Ke97M3V8380S9THDJ/bktjL8zHEVfBVZy7HhXHzhSjEg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-ini': 3.321.1 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.321.1 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-node@3.325.0: + resolution: {integrity: sha512-SG3F3yywnSzYcG5diErez9ukG8tToQIksedL/pM/gYFJ1zKYH560VJRc7Rkt0yjnl2cPFewazvPoDLBN/5Azbw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-ini': 3.325.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.325.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/credential-provider-node@3.326.0: + resolution: {integrity: sha512-7wopivXUgx5rcUSSUD4Zf5UQtFZEw/AFh1/DBjA/gWFjwKVdNUN0WxciV3g7zhIhZp2ffe4hTtlmHl3GuDR+zA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-ini': 3.326.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.326.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-node@3.332.0: + resolution: {integrity: sha512-KkBayS9k4WyJTvC86ngeRM+RmWxNCS1BHvudkR6PLXfnsNPDzxySDVY0UgxVhbNYDYsO561fXZt9ccpKyVWjgg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/credential-provider-env': 3.329.0 + '@aws-sdk/credential-provider-imds': 3.329.0 + '@aws-sdk/credential-provider-ini': 3.332.0 + '@aws-sdk/credential-provider-process': 3.329.0 + '@aws-sdk/credential-provider-sso': 3.332.0 + '@aws-sdk/credential-provider-web-identity': 3.329.0 + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/shared-ini-file-loader': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-process@3.310.0: + resolution: {integrity: sha512-h73sg6GPMUWC+3zMCbA1nZ2O03nNJt7G96JdmnantiXBwHpRKWW8nBTLzx5uhXn6hTuTaoQRP/P+oxQJKYdMmA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-process@3.329.0: + resolution: {integrity: sha512-5oO220qoFc2pMdZDQa6XN/mVhp669I3+LqMbbscGtX/UgLJPSOb7YzPld9Wjv12L5rf+sD3G1PF3LZXO0vKLFA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/shared-ini-file-loader': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-sso@3.319.0: + resolution: {integrity: sha512-gAUnWH41lxkIbANXu+Rz5zS0Iavjjmpf3C56vAMT7oaYZ3Cg/Ys5l2SwAucQGOCA2DdS2hDiSI8E+Yhr4F5toA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso': 3.319.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/token-providers': 3.319.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-sso@3.321.1: + resolution: {integrity: sha512-kg0rc1OacJFgAvmZj0TOu+BSc+yRdnC5dO/RAag3XU6+hlQI5/C080RQp9Qj6V7ga0HtAJMRwJcUlCPA3RJPug==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso': 3.321.1 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/token-providers': 3.321.1 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-sso@3.325.0: + resolution: {integrity: sha512-Te7jxJwjVGJAPWN3jCq2xcYrX8d4WkZFIqSIWSmrHqGKgWPc8+QgUkpRQkHaM+4NeNBJadRG1XbJNfu22gjDWA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso': 3.325.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/token-providers': 3.325.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/credential-provider-sso@3.326.0: + resolution: {integrity: sha512-GYCcFH6wsXdV6ULYUC5oZDtigaoPdDxOG8/ny1QQvNCo0MhQ35v+2xYf+84FgtQDPba0B/or4ErzHdPkPHM39g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso': 3.326.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/token-providers': 3.326.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-sso@3.332.0: + resolution: {integrity: sha512-SaKXl48af3n6LRitcaEqbeg1YDXwQ0A5QziC1xQyYPraEIj3IZ/GyTjx04Lo2jxNYHuEOE8u4aTw1+IK1GDKbg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso': 3.332.0 + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/shared-ini-file-loader': 3.329.0 + '@aws-sdk/token-providers': 3.332.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/credential-provider-web-identity@3.310.0: + resolution: {integrity: sha512-H4SzuZXILNhK6/IR1uVvsUDZvzc051hem7GLyYghBCu8mU+tq28YhKE8MfSroi6eL2e5Vujloij1OM2EQQkPkw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/credential-provider-web-identity@3.329.0: + resolution: {integrity: sha512-lcEibZD7AlutCacpQ6DyNUqElZJDq+ylaIo5a8MH9jGh7Pg2WpDg0Sy+B6FbGCkVn4eIjdHxeX54JM245nhESg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/credential-providers@3.319.0: + resolution: {integrity: sha512-H0bGABK7Ky6wSUoH+7SxOdt9G3lsU8J4Nufp9pPMuLiJX43rOzfCLvmKYdDuTdrr+ihnii4TexQqcrkJKN7Crw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-cognito-identity': 3.319.0 + '@aws-sdk/client-sso': 3.319.0 + '@aws-sdk/client-sts': 3.319.0 + '@aws-sdk/credential-provider-cognito-identity': 3.319.0 + '@aws-sdk/credential-provider-env': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/credential-provider-ini': 3.319.0 + '@aws-sdk/credential-provider-node': 3.319.0 + '@aws-sdk/credential-provider-process': 3.310.0 + '@aws-sdk/credential-provider-sso': 3.319.0 + '@aws-sdk/credential-provider-web-identity': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/eventstream-codec@3.310.0: + resolution: {integrity: sha512-clIeSgWbZbxwtsxZ/yoedNM0/kJFSIjjHPikuDGhxhqc+vP6TN3oYyVMFrYwFaTFhk2+S5wZcWYMw8Op1pWo+A==} + dependencies: + '@aws-crypto/crc32': 3.0.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-hex-encoding': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-codec@3.329.0: + resolution: {integrity: sha512-1r+6MNfye0za35FNLxMR5V9zpKY1lyzwySyu7o7aj8lnStBaCcjOEe7iHboP/z3DH73KJbxR++O2N+UC/XHFrg==} + dependencies: + '@aws-crypto/crc32': 3.0.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-hex-encoding': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-browser@3.310.0: + resolution: {integrity: sha512-3S6ziuQVALgEyz0TANGtYDVeG8ArK4Y05mcgrs8qUTmsvlDIXX37cR/DvmVbNB76M4IrsZeSAIajL9644CywkA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/eventstream-serde-universal': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-browser@3.329.0: + resolution: {integrity: sha512-oWFSn4o6sxlbFF0AIuDJYf7N0fkiOyWvYgRW3VTX9FSbd66f/KnDspdxIasaDPDUzJl5YRMwUvQbPWw8y9ZQfQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/eventstream-serde-universal': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-config-resolver@3.310.0: + resolution: {integrity: sha512-8s1Qdn9STj+sV75nUp9yt0W6fHS4BZ2jTm4Z/1Pcbvh2Gqs0WjH5n2StS+pDW5Y9J/HSGBl0ogmUr5lC5bXFHg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-config-resolver@3.329.0: + resolution: {integrity: sha512-iQguqvTtxWXAIniaWmmAO0Qy8080fqnS309p9jbYzz7KaT90sNSCX+CxGFHPy5F0QY36uklDdHn1d1fwWTZciA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-node@3.310.0: + resolution: {integrity: sha512-kSnRomCgW43K9TmQYuwN9+AoYPnhyOKroanUMyZEzJk7rpCPMj4OzaUpXfDYOvznFNYn7NLaH6nHLJAr0VPlJA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/eventstream-serde-universal': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-node@3.329.0: + resolution: {integrity: sha512-+DFia0wdZiHpdOKjBcl1baZjtzPKf4U4MvOpsUpC6CeW1kSy0hoikKzJstNvRb1qxrTSamElT4gKkMHxxVhPBQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/eventstream-serde-universal': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-universal@3.310.0: + resolution: {integrity: sha512-Qyjt5k/waV5cDukpgT824ISZAz5U0pwzLz5ztR409u85AGNkF/9n7MS+LSyBUBSb0WJ5pUeSD47WBk+nLq9Nhw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/eventstream-codec': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/eventstream-serde-universal@3.329.0: + resolution: {integrity: sha512-n9UzW6HKAhVD5wuz3FMC1ew3VI/vUvRSPXGUpKReMiR2z+YyjmuW8UM4nn7q6i7A/I4QHBt1TC/ax/J2yupgPg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/eventstream-codec': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/fetch-http-handler@3.310.0: + resolution: {integrity: sha512-Bi9vIwzdkw1zMcvi/zGzlWS9KfIEnAq4NNhsnCxbQ4OoIRU9wvU+WGZdBBhxg0ZxZmpp1j1aZhU53lLjA07MHw==} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/querystring-builder': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/fetch-http-handler@3.329.0: + resolution: {integrity: sha512-9jfIeJhYCcTX4ScXOueRTB3S/tVce0bRsKxKDP0PnTxnGYOwKXoM9lAPmiYItzYmQ/+QzjTI8xfkA9Usz2SK/Q==} + dependencies: + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/querystring-builder': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-base64': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/hash-blob-browser@3.310.0: + resolution: {integrity: sha512-OoR8p0cbypToysLT0v3o2oyjy6+DKrY7GNCAzHOHJK9xmqXCt+DsjKoPeiY7o1sWX2aN6Plmvubj/zWxMKEn/A==} + dependencies: + '@aws-sdk/chunked-blob-reader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/hash-node@3.310.0: + resolution: {integrity: sha512-NvE2fhRc8GRwCXBfDehxVAWCmVwVMILliAKVPAEr4yz2CkYs0tqU51S48x23dtna07H4qHtgpeNqVTthcIQOEQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-buffer-from': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/hash-node@3.329.0: + resolution: {integrity: sha512-6RmnWXNWpi7yAs0oRDQlkMn2wfXOStr/8kTCgiAiqrk1KopGSBkC2veKiKRSfv02FTd1yV/ISqYNIRqW1VLyxg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-buffer-from': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/hash-stream-node@3.310.0: + resolution: {integrity: sha512-ZoXdybNgvMz1Hl6k/e32xVL3jmG5p2IEk5mTtLfFEuskTJ74Z+VMYKkkF1whyy7KQfH83H+TQGnsGtlRCchQKw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/invalid-dependency@3.310.0: + resolution: {integrity: sha512-1s5RG5rSPXoa/aZ/Kqr5U/7lqpx+Ry81GprQ2bxWqJvWQIJ0IRUwo5pk8XFxbKVr/2a+4lZT/c3OGoBOM1yRRA==} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/invalid-dependency@3.329.0: + resolution: {integrity: sha512-UXynGusDxN/HxLma5ByJ7u+XnuMd47NbHOjJgYsaAjb1CVZT7hEPXOB+mcZ+Ku7To5SCOKu2QbRn7m4bGespBg==} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/is-array-buffer@3.310.0: + resolution: {integrity: sha512-urnbcCR+h9NWUnmOtet/s4ghvzsidFmspfhYaHAmSRdy9yDjdjBJMFjjsn85A1ODUktztm+cVncXjQ38WCMjMQ==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/md5-js@3.310.0: + resolution: {integrity: sha512-x5sRBUrEfLWAS1EhwbbDQ7cXq6uvBxh3qR2XAsnGvFFceTeAadk7cVogWxlk3PC+OCeeym7c3/6Bv2HQ2f1YyQ==} + dependencies: + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/md5-js@3.329.0: + resolution: {integrity: sha512-newSeHd+CO2hNmXhQOrUk5Y1hH7BsJ5J4IldcqHKY93UwWqvQNiepRowSa2bV5EuS1qx3kfXhD66PFNRprrIlQ==} + dependencies: + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + dev: false + + /@aws-sdk/middleware-bucket-endpoint@3.310.0: + resolution: {integrity: sha512-uJJfHI7v4AgbJZRLtyI8ap2QRWkBokGc3iyUoQ+dVNT3/CE2ZCu694A6W+H0dRqg79dIE+f9CRNdtLGa/Ehhvg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-arn-parser': 3.310.0 + '@aws-sdk/util-config-provider': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-content-length@3.310.0: + resolution: {integrity: sha512-P8tQZxgDt6CAh1wd/W6WPzjc+uWPJwQkm+F7rAwRlM+k9q17HrhnksGDKcpuuLyIhPQYdmOMIkpKVgXGa4avhQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-content-length@3.325.0: + resolution: {integrity: sha512-t38VBKCpNqSKqSu0OfWMJs7cwaRHFGQxIF9lV8JMCM/2lyUpN4JcfuzSTK+MFN2eDZEHp5DiNg8w07GXXusRYg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-content-length@3.329.0: + resolution: {integrity: sha512-7kCd+CvY/4KbyXB0uyL7jCwPjMi2yERMALFdEH9dsUciwmxIQT6eSc4aF6wImC4UrbafaqmXvvHErABKMVBTKA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-endpoint@3.310.0: + resolution: {integrity: sha512-Z+N2vOL8K354/lstkClxLLsr6hCpVRh+0tCMXrVj66/NtKysCEZ/0b9LmqOwD9pWHNiI2mJqXwY0gxNlKAroUg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-serde': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-endpoint@3.325.0: + resolution: {integrity: sha512-3CavuOHCKiWUnCtzrUFbhbEP26qIgzzRs5C3vpOJhDUhugBubIWgPGGRLpbnIro+P4XJPwM3pMziNzhKVuSDlQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-serde': 3.325.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/url-parser': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-endpoint@3.329.0: + resolution: {integrity: sha512-hdJRoNdCM0BT4W+rrtee+kfFRgGPGXQDgtbIQlf/FuuuYz2sdef7/SYWr0mxuncnVBW5WkYSPP8h6q07whSKbg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-serde': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/url-parser': 3.329.0 + '@aws-sdk/util-middleware': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-expect-continue@3.325.0: + resolution: {integrity: sha512-Hj4D+zeet4gdUpSiMeHZfIzcnXkZI2krGyUw4U1psPzCqOp7WP5307g+1NWXOlVu3H3tF5r3rEgthQOQj2zNfA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-flexible-checksums@3.326.0: + resolution: {integrity: sha512-MtcvSU+wKu4/a/trIJmb4Tfb682U9uP5YYA5aXzdhxOxG11wj86uBIeQrdbUxhtTXMgmvwn1193dvTi91EUEaQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-crypto/crc32': 3.0.0 + '@aws-crypto/crc32c': 3.0.0 + '@aws-sdk/is-array-buffer': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-host-header@3.310.0: + resolution: {integrity: sha512-QWSA+46/hXorXyWa61ic2K7qZzwHTiwfk2e9mRRjeIRepUgI3qxFjsYqrWtrOGBjmFmq0pYIY8Bb/DCJuQqcoA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-host-header@3.325.0: + resolution: {integrity: sha512-IN28gsxcRy4J+FxxCHvzb2NORBx8uMA+h9QYS4BBZfpKVYIZh+mudHgYcdNHWlKXmlTGjhWBNWTeByhzuSKAiA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-host-header@3.329.0: + resolution: {integrity: sha512-JrHeUdTIpTCfXDo9JpbAbZTS1x4mt63CCytJRq0mpWp+FlP9hjckBcNxWdR/wSKEzP9pDRnTri638BOwWH7O8w==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-location-constraint@3.325.0: + resolution: {integrity: sha512-T2OrpXXY9I1nHvIGSlQD6qj1FDG3WDFSu65+Bh4pMl+zVh0IqIEajiK++TfrdQl+sJxRGQd/euoeXXL4JYw9JA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-logger@3.310.0: + resolution: {integrity: sha512-Lurm8XofrASBRnAVtiSNuDSRsRqPNg27RIFLLsLp/pqog9nFJ0vz0kgdb9S5Z+zw83Mm+UlqOe6D8NTUNp4fVg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-logger@3.325.0: + resolution: {integrity: sha512-S8rWgTpN2b/+UDDm+yZMFM6rw1zwO8KT0GAIQbAhB96shyD5eKen/UfihCTB7YMvbD2piebymwJTvxv6bn1VqQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-logger@3.329.0: + resolution: {integrity: sha512-lKeeTXsYC1NiwmxrXsZepcwNXPoQxTNNbeD1qaCELPGK2cJlrGoeAP2YRWzpwO2kNZWrDLaGAPT/EUEhqw+d1w==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-recursion-detection@3.310.0: + resolution: {integrity: sha512-SuB75/xk/gyue24gkriTwO2jFd7YcUGZDClQYuRejgbXSa3CO0lWyawQtfLcSSEBp9izrEVXuFH24K1eAft5nQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-recursion-detection@3.325.0: + resolution: {integrity: sha512-2l1ABF7KePsoKz8KaNvD2uxo1zHqkFHK4PL/wW/FbcwOcE08f0R7qX++st/bPpVjXX/j/5vWTnNNgJOIOrZhyw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-recursion-detection@3.329.0: + resolution: {integrity: sha512-0/TYOJwrj1Z8s+Y7thibD23hggBq/K/01NwPk32CwWG/G+1vWozs5DefknEl++w0vuV+39pkY4KHI8m/+wOCpg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-retry@3.310.0: + resolution: {integrity: sha512-oTPsRy2W4s+dfxbJPW7Km+hHtv/OMsNsVfThAq8DDYKC13qlr1aAyOqGLD+dpBy2aKe7ss517Sy2HcHtHqm7/g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/service-error-classification': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + '@aws-sdk/util-retry': 3.310.0 + tslib: 2.5.0 + uuid: 8.3.2 + + /@aws-sdk/middleware-retry@3.325.0: + resolution: {integrity: sha512-oQM5AI3vkNQuCakBMgdohOcvRnVYcBBlv+KzCCj07ue9gk0x2dHOZY2pqTQ2CYilRqS/X1PtLogJXoyHP5Wvwg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/service-error-classification': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + '@aws-sdk/util-retry': 3.310.0 + tslib: 2.5.0 + uuid: 8.3.2 + + /@aws-sdk/middleware-retry@3.329.0: + resolution: {integrity: sha512-cB3D7GlhHUcHGOlygOYxD9cPhwsTYEAMcohK38An8+RHNp6VQEWezzLFCmHVKUSeCQ+wkjZfPA40jOG0rbjSgQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/service-error-classification': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-middleware': 3.329.0 + '@aws-sdk/util-retry': 3.329.0 + tslib: 2.5.0 + uuid: 8.3.2 + + /@aws-sdk/middleware-sdk-s3@3.326.0: + resolution: {integrity: sha512-IyonHEiDMn0fdYWxA/TAnNj8M/xG5EJWvoOKcakl891f+JPaWeRsV2oE1fIjqM/waM3jqNXLDTrm06QfAYmgBQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-arn-parser': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-sdk-sqs@3.329.0: + resolution: {integrity: sha512-xyU5G9V6KWtv+5ZjYe3m88OOUPycURBOo3Mvgzcxyc4kQgUu8I0HQqdB1hYeL9k+MvPaAe1qz/oVNC7QIYjK2A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-hex-encoding': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + dev: false + + /@aws-sdk/middleware-sdk-sts@3.310.0: + resolution: {integrity: sha512-+5PFwlYNLvLLIfw0ASAoWV/iIF8Zv6R6QGtyP0CclhRSvNjgbQDVnV0g95MC5qvh+GB/Yjlkt8qAjLSPjHfsrQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-sdk-sts@3.325.0: + resolution: {integrity: sha512-deRK1ZuNueQ6OOTEhBZ9bLmjPema/N3cwbtO+tDVwpi7MipjE4EZDXX8WL0xza5YLRnz9kxcHuyfL47vvKgO3A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + dev: false + + /@aws-sdk/middleware-sdk-sts@3.326.0: + resolution: {integrity: sha512-suOkuXxyAfOH0hznK63ZU10EoytKX5YPs9amO416VbgYFtuIeliCmntYfnl1jUvutp0fctGGpEGE9OnoYI+fhw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-signing': 3.325.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-sdk-sts@3.329.0: + resolution: {integrity: sha512-bqtZuhkH8pANb2Gb4FEM1p27o+BoDBmVhEWm8sWH+APsyOor3jc6eUG2GxkfoO6D5tGNIuyCC/GuvW9XDIe4Kg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-signing': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-serde@3.310.0: + resolution: {integrity: sha512-RNeeTVWSLTaentUeCgQKZhAl+C6hxtwD78cQWS10UymWpQFwbaxztzKUu4UQS5xA2j6PxwPRRUjqa4jcFjfLsg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-serde@3.325.0: + resolution: {integrity: sha512-QAZYaFfAw1a06Vg39JiYIq0kSJ6EuUPOiKfK/Goj0cBv78lrXWuKdf04UF3U8Rqk/4mamnsTqUSwf4NoKkF0hw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-serde@3.329.0: + resolution: {integrity: sha512-tvM9NdPuRPCozPjTGNOeYZeLlyx3BcEyajrkRorCRf1YzG/mXdB6I1stote7i4q1doFtYTz0sYL8bqW3LUPn9A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-signing@3.310.0: + resolution: {integrity: sha512-f9mKq+XMdW207Af3hKjdTnpNhdtwqWuvFs/ZyXoOkp/g1MY1O6L23Jy6i52m29LxbT4AuNRG1oKODfXM0vYVjQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/signature-v4': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-signing@3.325.0: + resolution: {integrity: sha512-SOwPwaCE3vSCGwFzkIlnOUSkeCUzKTyIQnFVjlQkqGuMxMX/iDaQQGaX+HUbuGIuULCEQqjZH4dLKZcor8eVZw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/signature-v4': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-signing@3.329.0: + resolution: {integrity: sha512-bL1nI+EUcF5B1ipwDXxiKL+Uw02Mbt/TNX54PbzunBGZIyO6DZG/H+M3U296bYbvPlwlZhp26O830g6K7VEWsA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/signature-v4': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-middleware': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-ssec@3.325.0: + resolution: {integrity: sha512-hxmvvWVfVrbfUw8pDEPlsR6Sb+IUdhq0cOJc7SL5XO9ddRXJ5DjT2Z2ao9FB424hJgAcOrqIO5ECjdIRs+O4FQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-stack@3.310.0: + resolution: {integrity: sha512-010O1PD+UAcZVKRvqEusE1KJqN96wwrf6QsqbRM0ywsKQ21NDweaHvEDlds2VHpgmofxkRLRu/IDrlPkKRQrRg==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/middleware-stack@3.325.0: + resolution: {integrity: sha512-cZWehA4grGvX1IKlY9atJgD0bq3ew7YRJgY7GA6DSgsU7GrZ61Qvi+H7IuGx5AdeAwaTnbnTGN4qCaA2EfxNhA==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/middleware-stack@3.329.0: + resolution: {integrity: sha512-2huFLhJ45td2nuiIOjpc9JKJbFNn5CYmw9U8YDITTcydpteRN62CzCpeqroDvF89VOLWxh0ZFtuLCGUr7liSWQ==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/middleware-user-agent@3.319.0: + resolution: {integrity: sha512-ytaLx2dlR5AdMSne6FuDCISVg8hjyKj+cHU20b2CRA/E/z+XXrLrssp4JrCgizRKPPUep0psMIa22Zd6osTT5Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-endpoints': 3.319.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-user-agent@3.325.0: + resolution: {integrity: sha512-2aIdGId4o8eIStm1J1aWZwNDf6nvrwg5Nx7BomLAxKZ4lkH8knzXDtxaZR4ElcTsBlBcYxz2gbsrScMyKRDTGA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-endpoints': 3.319.0 + tslib: 2.5.0 + + /@aws-sdk/middleware-user-agent@3.332.0: + resolution: {integrity: sha512-rSL1xP4QmcMOsunN1p5ZDR9GT3vvoSCnYa4iPvMSjP8Jx7l4ff/aVctwfZkMs/up12+68Jqwj4TvtaCvCFXdUA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-endpoints': 3.332.0 + tslib: 2.5.0 + + /@aws-sdk/node-config-provider@3.310.0: + resolution: {integrity: sha512-T/Pp6htc6hq/Cq+MLNDSyiwWCMVF6GqbBbXKVlO5L8rdHx4sq9xPdoPveZhGWrxvkanjA6eCwUp6E0riBOSVng==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/node-config-provider@3.329.0: + resolution: {integrity: sha512-hg9rGNlkzh8aeR/sQbijrkFx2BIO53j4Z6qDxPNWwSGpl05jri1VHxHx2HZMwgbY6Zy/DSguETN/BL8vdFqyLg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/shared-ini-file-loader': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/node-http-handler@3.310.0: + resolution: {integrity: sha512-irv9mbcM9xC2xYjArQF5SYmHBMu4ciMWtGsoHII1nRuFOl9FoT4ffTvEPuLlfC6pznzvKt9zvnm6xXj7gDChKg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/abort-controller': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/querystring-builder': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/node-http-handler@3.321.1: + resolution: {integrity: sha512-DdQBrtFFDNtzphJIN3s93Vf+qd9LHSzH6WTQRrWoXhTDMHDzSI2Cn+c5KWfk89Nggp/n3+OTwUPQeCiBT5EBuw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/abort-controller': 3.310.0 + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/querystring-builder': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/node-http-handler@3.329.0: + resolution: {integrity: sha512-OrjaHjU2ZTPfoHa5DruRvTIbeHH/cc0wvh4ml+FwDpWaPaBpOhLiluhZ3anqX1l5QjrXNiQnL8FxSM5OV/zVCA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/abort-controller': 3.329.0 + '@aws-sdk/protocol-http': 3.329.0 + '@aws-sdk/querystring-builder': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/property-provider@3.310.0: + resolution: {integrity: sha512-3lxDb0akV6BBzmFe4nLPaoliQbAifyWJhuvuDOu7e8NzouvpQXs0275w9LePhhcgjKAEVXUIse05ZW2DLbxo/g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/property-provider@3.329.0: + resolution: {integrity: sha512-1cHLTV6yyMGaMSWWDW/p4vTkJ1cc5BOEO+A0eHuAcoSOk+LDe9IKhUG3/ZOvvYKQYcqIj5jjGSni/noXNCl/qw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/protocol-http@3.310.0: + resolution: {integrity: sha512-fgZ1aw/irQtnrsR58pS8ThKOWo57Py3xX6giRvwSgZDEcxHfVzuQjy9yPuV++v04fdmdtgpbGf8WfvAAJ11yXQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/protocol-http@3.329.0: + resolution: {integrity: sha512-0rLEHY6QTHTUUcVxzGbPUSmCKlXWplxT/fcYRh0bcc5MBK4naKfcQft1O6Ajp8uqs/9YPZ7XCVCn90pDeJfeaw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/querystring-builder@3.310.0: + resolution: {integrity: sha512-ZHH8GV/80+pWGo7DzsvwvXR5xVxUHXUvPJPFAkhr6nCf78igdoF8gR10ScFoEKbtEapoNTaZlKHPXxpD8aPG7A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-uri-escape': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/querystring-builder@3.329.0: + resolution: {integrity: sha512-UWgMKkS5trliaDJG4nPv3onu8Y0aBuwRo7RdIgggguOiU8pU6pq1I113nH2FBNWy+Me1bwf+bcviJh0pCo6bEg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-uri-escape': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/querystring-parser@3.310.0: + resolution: {integrity: sha512-YkIznoP6lsiIUHinx++/lbb3tlMURGGqMpo0Pnn32zYzGrJXA6eC3D0as2EcMjo55onTfuLcIiX4qzXes2MYOA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/querystring-parser@3.329.0: + resolution: {integrity: sha512-9mkK+FB7snJ2G7H3CqtprDwYIRhzm6jEezffCwUWrC+lbqHBbErbhE9IeU/MKxILmf0RbC2riXEY1MHGspjRrQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/service-error-classification@3.310.0: + resolution: {integrity: sha512-PuyC7k3qfIKeH2LCnDwbttMOKq3qAx4buvg0yfnJtQOz6t1AR8gsnAq0CjKXXyfkXwNKWTqCpE6lVNUIkXgsMw==} + engines: {node: '>=14.0.0'} + + /@aws-sdk/service-error-classification@3.329.0: + resolution: {integrity: sha512-TSNr0flOcCLe71aPp7MjblKNGsmxpTU4xR5772MDX9Cz9GUTNZCPFtvrcqd+wzEPP/AC7XwNXe8KjoXooZImUQ==} + engines: {node: '>=14.0.0'} + + /@aws-sdk/shared-ini-file-loader@3.310.0: + resolution: {integrity: sha512-N0q9pG0xSjQwc690YQND5bofm+4nfUviQ/Ppgan2kU6aU0WUq8KwgHJBto/YEEI+VlrME30jZJnxtOvcZJc2XA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/shared-ini-file-loader@3.329.0: + resolution: {integrity: sha512-e0hyd75fbjMd4aCoRwpP2/HR+0oScwogErVArIkq3F42c/hyNCQP3sph4JImuXIjuo6HNnpKpf20CEPPhNna8A==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/signature-v4-crt@3.310.0: + resolution: {integrity: sha512-CwVKIi0vmxn2ceiYx0pNrgpeiUjntwAaeQW6K5M8V4vikwxiohC6FiKYqN+t5UG062SzIb7s2mpt2imXRa627w==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/querystring-parser': 3.310.0 + '@aws-sdk/signature-v4': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + aws-crt: 1.15.15 + tslib: 2.5.0 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + + /@aws-sdk/signature-v4-multi-region@3.310.0(@aws-sdk/signature-v4-crt@3.310.0): + resolution: {integrity: sha512-q8W+RIomTS/q85Ntgks/CoDElwqkC9+4OCicee5YznNHjQ4gtNWhUkYIyIRWRmXa/qx/AUreW9DM8FAecCOdng==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@aws-sdk/signature-v4-crt': ^3.118.0 + peerDependenciesMeta: + '@aws-sdk/signature-v4-crt': + optional: true + dependencies: + '@aws-sdk/protocol-http': 3.310.0 + '@aws-sdk/signature-v4': 3.310.0 + '@aws-sdk/signature-v4-crt': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/signature-v4@3.310.0: + resolution: {integrity: sha512-1M60P1ZBNAjCFv9sYW29OF6okktaeibWyW3lMXqzoHF70lHBZh+838iUchznXUA5FLabfn4jBFWMRxlAXJUY2Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/is-array-buffer': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-hex-encoding': 3.310.0 + '@aws-sdk/util-middleware': 3.310.0 + '@aws-sdk/util-uri-escape': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/signature-v4@3.329.0: + resolution: {integrity: sha512-9EnLoyOD5nFtCRAp+QRllDgQASCfY7jLHVhwht7jzwE80wE65Z9Ym5Z/mwTd4IyTz/xXfCvcE2VwClsBt0Ybdw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/is-array-buffer': 3.310.0 + '@aws-sdk/types': 3.329.0 + '@aws-sdk/util-hex-encoding': 3.310.0 + '@aws-sdk/util-middleware': 3.329.0 + '@aws-sdk/util-uri-escape': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/smithy-client@3.316.0: + resolution: {integrity: sha512-6YXOKbRnXeS8r8RWzuL6JMBolDYM5Wa4fD/VY6x/wK78i2xErHOvqzHgyyeLI1MMw4uqyd4wRNJNWC9TMPduXw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-stack': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/smithy-client@3.325.0: + resolution: {integrity: sha512-sqDFuhjxd8+Q9qI8MmXe/g1/FgoViwetv14K+bpHK7pGlOIvDyT7TboDNClfgqSLdgTDCEaoC3JRSi9Y5RgbmA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-stack': 3.325.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/smithy-client@3.329.0: + resolution: {integrity: sha512-7E0fGpBKxwFqHHAOqNbgNsHSEmCZLuvmU9yvG9DXKVzrS4P48O/PfOro123WpcFZs3STyOVgH8wjUPftHAVKmg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/middleware-stack': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/token-providers@3.319.0: + resolution: {integrity: sha512-5utg6VL6Pl0uiLUn8ZJPYYxzCb9VRPsgJmGXktRUwq0YlTJ6ABcaxTXwZcC++sjh/qyCQDK5PPLNU5kIBttHMQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso-oidc': 3.319.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/token-providers@3.321.1: + resolution: {integrity: sha512-I1sXS4qXirSvgvrOIPf+e1D7GvC83DdeyMxHZvuhHgeMCqDAzToS8OLxOX0enN9xZRHWAQYja8xyeGbDL2I0Zw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso-oidc': 3.321.1 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/token-providers@3.325.0: + resolution: {integrity: sha512-h/ecgqXaMwEkUWo+SZJNcOMWJkAknjonWWpK/vQ4uz+qE9rBqRugsIeIiey+Ij7zCtwh6WhtpfCpt5RbxRHe6g==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso-oidc': 3.325.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + dev: false + + /@aws-sdk/token-providers@3.326.0: + resolution: {integrity: sha512-Ghe4K6KgMWb5sx5HUzshJGjTMHUbzrxrjCwpEj2DHSMFivpy6LADS0+Ch3WR7w9CIu2V2tK20YrCPj4JC64dvA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso-oidc': 3.326.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/shared-ini-file-loader': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/token-providers@3.332.0: + resolution: {integrity: sha512-fccbg6OSl0l658pxl2p1MoU9gEePo5B361+JNaN0zfRMu7c5HBXCpdl4djlFxAHjltrX9f1+BKqfGHYgI3h8SQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/client-sso-oidc': 3.332.0 + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/shared-ini-file-loader': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + transitivePeerDependencies: + - aws-crt + + /@aws-sdk/types@3.310.0: + resolution: {integrity: sha512-j8eamQJ7YcIhw7fneUfs8LYl3t01k4uHi4ZDmNRgtbmbmTTG3FZc2MotStZnp3nZB6vLiPF1o5aoJxWVvkzS6A==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/types@3.329.0: + resolution: {integrity: sha512-wFBW4yciDfzQBSFmWNaEvHShnSGLMxSu9Lls6EUf6xDMavxSB36bsrVRX6CyAo/W0NeIIyEOW1LclGPgJV1okg==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/url-parser@3.310.0: + resolution: {integrity: sha512-mCLnCaSB9rQvAgx33u0DujLvr4d5yEm/W5r789GblwwQnlNXedVu50QRizMLTpltYWyAUoXjJgQnJHmJMaKXhw==} + dependencies: + '@aws-sdk/querystring-parser': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/url-parser@3.329.0: + resolution: {integrity: sha512-/VcfL7vNJKJGSjYYHVQF3bYCDFs4fSzB7j5qeVDwRdWr870gE7O1Dar+sLWBRKFF3AX+4VzplqzUfpu9t44JVA==} + dependencies: + '@aws-sdk/querystring-parser': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/util-arn-parser@3.310.0: + resolution: {integrity: sha512-jL8509owp/xB9+Or0pvn3Fe+b94qfklc2yPowZZIFAkFcCSIdkIglz18cPDWnYAcy9JGewpMS1COXKIUhZkJsA==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-base64@3.310.0: + resolution: {integrity: sha512-v3+HBKQvqgdzcbL+pFswlx5HQsd9L6ZTlyPVL2LS9nNXnCcR3XgGz9jRskikRUuUvUXtkSG1J88GAOnJ/apTPg==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/util-buffer-from': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-body-length-browser@3.310.0: + resolution: {integrity: sha512-sxsC3lPBGfpHtNTUoGXMQXLwjmR0zVpx0rSvzTPAuoVILVsp5AU/w5FphNPxD5OVIjNbZv9KsKTuvNTiZjDp9g==} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-body-length-node@3.310.0: + resolution: {integrity: sha512-2tqGXdyKhyA6w4zz7UPoS8Ip+7sayOg9BwHNidiGm2ikbDxm1YrCfYXvCBdwaJxa4hJfRVz+aL9e+d3GqPI9pQ==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-buffer-from@3.310.0: + resolution: {integrity: sha512-i6LVeXFtGih5Zs8enLrt+ExXY92QV25jtEnTKHsmlFqFAuL3VBeod6boeMXkN2p9lbSVVQ1sAOOYZOHYbYkntw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/is-array-buffer': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-config-provider@3.310.0: + resolution: {integrity: sha512-xIBaYo8dwiojCw8vnUcIL4Z5tyfb1v3yjqyJKJWV/dqKUFOOS0U591plmXbM+M/QkXyML3ypon1f8+BoaDExrg==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-defaults-mode-browser@3.316.0: + resolution: {integrity: sha512-6FSqLhYmaihtH2n1s4b2rlLW0ABU8N6VZIfzLfe2ING4PF0MzfaMMhnTFUHVXfKCVGoR8yP6iyFTRCyHGVEL1w==} + engines: {node: '>= 10.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + bowser: 2.11.0 + tslib: 2.5.0 + + /@aws-sdk/util-defaults-mode-browser@3.325.0: + resolution: {integrity: sha512-gcowpXTo8E8N3jxD2KW+csiicJ7HPkhWnpL925xgwe0oq091OpATsKFrBOL18h72VfRWf4FAsR9lVwxSQ78zSA==} + engines: {node: '>= 10.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + bowser: 2.11.0 + tslib: 2.5.0 + + /@aws-sdk/util-defaults-mode-browser@3.329.0: + resolution: {integrity: sha512-2iSiy/pzX3OXMhtSxtAzOiEFr3viQEFnYOTeZuiheuyS+cea2L79F6SlZ1110b/nOIU/UOrxxtz83HVad8YFMQ==} + engines: {node: '>= 10.0.0'} + dependencies: + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/types': 3.329.0 + bowser: 2.11.0 + tslib: 2.5.0 + + /@aws-sdk/util-defaults-mode-node@3.316.0: + resolution: {integrity: sha512-dkYy10hdjPSScXXvnjGpZpnJxllkb6ICHgLMwZ4JczLHhPM12T/4PQ758YN8HS+muiYDGX1Bl2z1jd/bMcewBQ==} + engines: {node: '>= 10.0.0'} + dependencies: + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-defaults-mode-node@3.325.0: + resolution: {integrity: sha512-/5uoOrgNxoUxv3AwsdXjMA3f6KJA6fi69otA0RiINjilCdcbOxq5GI11AFEyRio/+e+imriX4+UYjsguUR+f4g==} + engines: {node: '>= 10.0.0'} + dependencies: + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-provider-imds': 3.310.0 + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/property-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-defaults-mode-node@3.329.0: + resolution: {integrity: sha512-7A6C7YKjkZtmKtH29isYEtOCbhd7IcXPP8lftN8WAWlLOiZE4gV7PHveagUj7QserJzgRKGwwTQbBj53n18HYg==} + engines: {node: '>= 10.0.0'} + dependencies: + '@aws-sdk/config-resolver': 3.329.0 + '@aws-sdk/credential-provider-imds': 3.329.0 + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/property-provider': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/util-endpoints@3.319.0: + resolution: {integrity: sha512-3I64UMoYA2e2++oOUJXRcFtYLpLylnZFRltWfPo1B3dLlf+MIWat9djT+mMus+hW1ntLsvAIVu1hLVePJC0gvw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-endpoints@3.332.0: + resolution: {integrity: sha512-nQx7AiOroMU2hj6h+umWOSZ+WECwxupaxFUK/PPKGW6NY/VdQE6LluYnXOtF5awlr8w1nPksT0Lq05PZutMDLA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/util-hex-encoding@3.310.0: + resolution: {integrity: sha512-sVN7mcCCDSJ67pI1ZMtk84SKGqyix6/0A1Ab163YKn+lFBQRMKexleZzpYzNGxYzmQS6VanP/cfU7NiLQOaSfA==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-locate-window@3.310.0: + resolution: {integrity: sha512-qo2t/vBTnoXpjKxlsC2e1gBrRm80M3bId27r0BRB2VniSSe7bL1mmzM+/HFtujm0iAxtPM+aLEflLJlJeDPg0w==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-middleware@3.310.0: + resolution: {integrity: sha512-FTSUKL/eRb9X6uEZClrTe27QFXUNNp7fxYrPndZwk1hlaOP5ix+MIHBcI7pIiiY/JPfOUmPyZOu+HetlFXjWog==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-middleware@3.329.0: + resolution: {integrity: sha512-RhBOBaxzkTUghi4MSqr8S5qeeBCjgJ0XPJ6jIYkVkj1saCmqkuZCgl3zFaYdyhdxxPV6nflkFer+1HUoqT+Fqw==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-retry@3.310.0: + resolution: {integrity: sha512-FwWGhCBLfoivTMUHu1LIn4NjrN9JLJ/aX5aZmbcPIOhZVFJj638j0qDgZXyfvVqBuBZh7M8kGq0Oahy3dp69OA==} + engines: {node: '>= 14.0.0'} + dependencies: + '@aws-sdk/service-error-classification': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-retry@3.329.0: + resolution: {integrity: sha512-+3VQ9HZLinysnmryUs9Xjt1YVh4TYYHLt30ilu4iUnIHFQoamdzIbRCWseSVFPCxGroen9M9qmAleAsytHEKuA==} + engines: {node: '>= 14.0.0'} + dependencies: + '@aws-sdk/service-error-classification': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/util-stream-browser@3.310.0: + resolution: {integrity: sha512-bysXZHwFwvbqOTCScCdCnoLk1K3GCo0HRIYEZuL7O7MHrQmfaYRXcaft/p22+GUv9VeFXS/eJJZ5r4u32az94w==} + dependencies: + '@aws-sdk/fetch-http-handler': 3.310.0 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-base64': 3.310.0 + '@aws-sdk/util-hex-encoding': 3.310.0 + '@aws-sdk/util-utf8': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-stream-node@3.321.1: + resolution: {integrity: sha512-jvfff1zeA8q16hQWSC0BGwcHJPCwoh+bwiuAjihfl9q1tFLYuqaTzJzzkL1bntUsbW+y/ac5DO7fWcYPq0jWkw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/node-http-handler': 3.321.1 + '@aws-sdk/types': 3.310.0 + '@aws-sdk/util-buffer-from': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-uri-escape@3.310.0: + resolution: {integrity: sha512-drzt+aB2qo2LgtDoiy/3sVG8w63cgLkqFIa2NFlGpUgHFWTXkqtbgf4L5QdjRGKWhmZsnqkbtL7vkSWEcYDJ4Q==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-user-agent-browser@3.310.0: + resolution: {integrity: sha512-yU/4QnHHuQ5z3vsUqMQVfYLbZGYwpYblPiuZx4Zo9+x0PBkNjYMqctdDcrpoH9Z2xZiDN16AmQGK1tix117ZKw==} + dependencies: + '@aws-sdk/types': 3.310.0 + bowser: 2.11.0 + tslib: 2.5.0 + + /@aws-sdk/util-user-agent-browser@3.329.0: + resolution: {integrity: sha512-8hLSmMCl8aw2++0Zuba8ELq8FkK6/VNyx470St201IpMn2GMbQMDl/rLolRKiTgji6wc+T3pOTidkJkz8/cIXA==} + dependencies: + '@aws-sdk/types': 3.329.0 + bowser: 2.11.0 + tslib: 2.5.0 + + /@aws-sdk/util-user-agent-node@3.310.0: + resolution: {integrity: sha512-Ra3pEl+Gn2BpeE7KiDGpi4zj7WJXZA5GXnGo3mjbi9+Y3zrbuhJAbdZO3mO/o7xDgMC6ph4xCTbaSGzU6b6EDg==} + engines: {node: '>=14.0.0'} + peerDependencies: + aws-crt: '>=1.0.0' + peerDependenciesMeta: + aws-crt: + optional: true + dependencies: + '@aws-sdk/node-config-provider': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-user-agent-node@3.329.0: + resolution: {integrity: sha512-C50Zaeodc0+psEP+L4WpElrH8epuLWJPVN4hDOTORcM0cSoU2o025Ost9mbcU7UdoHNxF9vitLnzORGN9SHolg==} + engines: {node: '>=14.0.0'} + peerDependencies: + aws-crt: '>=1.0.0' + peerDependenciesMeta: + aws-crt: + optional: true + dependencies: + '@aws-sdk/node-config-provider': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/util-utf8-browser@3.259.0: + resolution: {integrity: sha512-UvFa/vR+e19XookZF8RzFZBrw2EUkQWxiBW0yYQAhvk3C+QVGl0H3ouca8LDBlBfQKXwmW3huo/59H8rwb1wJw==} + dependencies: + tslib: 2.5.0 + + /@aws-sdk/util-utf8@3.310.0: + resolution: {integrity: sha512-DnLfFT8uCO22uOJc0pt0DsSNau1GTisngBCDw8jQuWT5CqogMJu4b/uXmwEqfj8B3GX6Xsz8zOd6JpRlPftQoA==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/util-buffer-from': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-waiter@3.310.0: + resolution: {integrity: sha512-AV5j3guH/Y4REu+Qh3eXQU9igljHuU4XjX2sADAgf54C0kkhcCCkkiuzk3IsX089nyJCqIcj5idbjdvpnH88Vw==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/abort-controller': 3.310.0 + '@aws-sdk/types': 3.310.0 + tslib: 2.5.0 + + /@aws-sdk/util-waiter@3.329.0: + resolution: {integrity: sha512-MIGs7snNL0ZV55zo1BDVPlrmbinUGV3260hp6HrW4zUbpYVoeIOGeewtrwAsF6FJ+vpZCxljPBB0X2jYR7Q7ZQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@aws-sdk/abort-controller': 3.329.0 + '@aws-sdk/types': 3.329.0 + tslib: 2.5.0 + + /@aws-sdk/xml-builder@3.310.0: + resolution: {integrity: sha512-TqELu4mOuSIKQCqj63fGVs86Yh+vBx5nHRpWKNUNhB2nPTpfbziTs5c1X358be3peVWA4wPxW7Nt53KIg1tnNw==} + engines: {node: '>=14.0.0'} + dependencies: + tslib: 2.5.0 + + /@babel/code-frame@7.21.4: + resolution: {integrity: sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/highlight': 7.18.6 + + /@babel/compat-data@7.21.4: + resolution: {integrity: sha512-/DYyDpeCfaVinT40FPGdkkb+lYSKvsVuMjDAG7jPOWWiM1ibOaB9CXJAlc4d1QpP/U2q2P9jbrSlClKSErd55g==} + engines: {node: '>=6.9.0'} + + /@babel/core@7.21.4: + resolution: {integrity: sha512-qt/YV149Jman/6AfmlxJ04LMIu8bMoyl3RB91yTFrxQmgbrSvQMy7cI8Q62FHx1t8wJ8B5fu0UDoLwHAhUo1QA==} + engines: {node: '>=6.9.0'} + dependencies: + '@ampproject/remapping': 2.2.1 + '@babel/code-frame': 7.21.4 + '@babel/generator': 7.21.4 + '@babel/helper-compilation-targets': 7.21.4(@babel/core@7.21.4) + '@babel/helper-module-transforms': 7.21.2 + '@babel/helpers': 7.21.0 + '@babel/parser': 7.21.4 + '@babel/template': 7.20.7 + '@babel/traverse': 7.21.4 + '@babel/types': 7.21.4 + convert-source-map: 1.9.0 + debug: 4.3.4 + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.0 + transitivePeerDependencies: + - supports-color + + /@babel/generator@7.21.4: + resolution: {integrity: sha512-NieM3pVIYW2SwGzKoqfPrQsf4xGs9M9AIG3ThppsSRmO+m7eQhmI6amajKMUeIO37wFfsvnvcxQFx6x6iqxDnA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.18 + jsesc: 2.5.2 + + /@babel/helper-annotate-as-pure@7.18.6: + resolution: {integrity: sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@babel/helper-compilation-targets@7.21.4(@babel/core@7.21.4): + resolution: {integrity: sha512-Fa0tTuOXZ1iL8IeDFUWCzjZcn+sJGd9RZdH9esYVjEejGmzf+FFYQpMi/kZUk2kPy/q1H3/GPw7np8qar/stfg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/compat-data': 7.21.4 + '@babel/core': 7.21.4 + '@babel/helper-validator-option': 7.21.0 + browserslist: 4.21.5 + lru-cache: 5.1.1 + semver: 6.3.0 + + /@babel/helper-create-class-features-plugin@7.21.4(@babel/core@7.21.4): + resolution: {integrity: sha512-46QrX2CQlaFRF4TkwfTt6nJD7IHq8539cCL7SDpqWSDeJKY1xylKKY5F/33mJhLZ3mFvKv2gGrVS6NkyF6qs+Q==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-annotate-as-pure': 7.18.6 + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-function-name': 7.21.0 + '@babel/helper-member-expression-to-functions': 7.21.0 + '@babel/helper-optimise-call-expression': 7.18.6 + '@babel/helper-replace-supers': 7.20.7 + '@babel/helper-skip-transparent-expression-wrappers': 7.20.0 + '@babel/helper-split-export-declaration': 7.18.6 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-environment-visitor@7.18.9: + resolution: {integrity: sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==} + engines: {node: '>=6.9.0'} + + /@babel/helper-function-name@7.21.0: + resolution: {integrity: sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/template': 7.20.7 + '@babel/types': 7.21.4 + + /@babel/helper-hoist-variables@7.18.6: + resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + + /@babel/helper-member-expression-to-functions@7.21.0: + resolution: {integrity: sha512-Muu8cdZwNN6mRRNG6lAYErJ5X3bRevgYR2O8wN0yn7jJSnGDu6eG59RfT29JHxGUovyfrh6Pj0XzmR7drNVL3Q==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@babel/helper-module-imports@7.18.6: + resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@babel/helper-module-imports@7.21.4: + resolution: {integrity: sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + + /@babel/helper-module-transforms@7.21.2: + resolution: {integrity: sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-module-imports': 7.21.4 + '@babel/helper-simple-access': 7.20.2 + '@babel/helper-split-export-declaration': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 + '@babel/template': 7.20.7 + '@babel/traverse': 7.21.4 + '@babel/types': 7.21.4 + transitivePeerDependencies: + - supports-color + + /@babel/helper-optimise-call-expression@7.18.6: + resolution: {integrity: sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@babel/helper-plugin-utils@7.20.2: + resolution: {integrity: sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helper-replace-supers@7.20.7: + resolution: {integrity: sha512-vujDMtB6LVfNW13jhlCrp48QNslK6JXi7lQG736HVbHz/mbf4Dc7tIRh1Xf5C0rF7BP8iiSxGMCmY6Ci1ven3A==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-member-expression-to-functions': 7.21.0 + '@babel/helper-optimise-call-expression': 7.18.6 + '@babel/template': 7.20.7 + '@babel/traverse': 7.21.4 + '@babel/types': 7.21.4 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-simple-access@7.20.2: + resolution: {integrity: sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + + /@babel/helper-skip-transparent-expression-wrappers@7.20.0: + resolution: {integrity: sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@babel/helper-split-export-declaration@7.18.6: + resolution: {integrity: sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.4 + + /@babel/helper-string-parser@7.19.4: + resolution: {integrity: sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==} + engines: {node: '>=6.9.0'} + + /@babel/helper-validator-identifier@7.19.1: + resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} + engines: {node: '>=6.9.0'} + + /@babel/helper-validator-option@7.21.0: + resolution: {integrity: sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==} + engines: {node: '>=6.9.0'} + + /@babel/helpers@7.21.0: + resolution: {integrity: sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/template': 7.20.7 + '@babel/traverse': 7.21.4 + '@babel/types': 7.21.4 + transitivePeerDependencies: + - supports-color + + /@babel/highlight@7.18.6: + resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.19.1 + chalk: 2.4.2 + js-tokens: 4.0.0 + + /@babel/parser@7.21.4: + resolution: {integrity: sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==} + engines: {node: '>=6.0.0'} + hasBin: true + dependencies: + '@babel/types': 7.21.4 + + /@babel/plugin-syntax-jsx@7.21.4(@babel/core@7.21.4): + resolution: {integrity: sha512-5hewiLct5OKyh6PLKEYaFclcqtIgCb6bmELouxjF6up5q3Sov7rOayW4RwhbaBL0dit8rA80GNfY+UuDp2mBbQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-plugin-utils': 7.20.2 + dev: true + + /@babel/plugin-syntax-typescript@7.21.4(@babel/core@7.21.4): + resolution: {integrity: sha512-xz0D39NvhQn4t4RNsHmDnnsaQizIlUkdtYvLs8La1BlfjQ6JEwxkJGeqJMW2tAXx+q6H+WFuUTXNdYVpEya0YA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-plugin-utils': 7.20.2 + dev: true + + /@babel/plugin-transform-modules-commonjs@7.21.2(@babel/core@7.21.4): + resolution: {integrity: sha512-Cln+Yy04Gxua7iPdj6nOV96smLGjpElir5YwzF0LBPKoPlLDNJePNlrGGaybAJkd0zKRnOVXOgizSqPYMNYkzA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-module-transforms': 7.21.2 + '@babel/helper-plugin-utils': 7.20.2 + '@babel/helper-simple-access': 7.20.2 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/plugin-transform-typescript@7.21.3(@babel/core@7.21.4): + resolution: {integrity: sha512-RQxPz6Iqt8T0uw/WsJNReuBpWpBqs/n7mNo18sKLoTbMp+UrEekhH+pKSVC7gWz+DNjo9gryfV8YzCiT45RgMw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-annotate-as-pure': 7.18.6 + '@babel/helper-create-class-features-plugin': 7.21.4(@babel/core@7.21.4) + '@babel/helper-plugin-utils': 7.20.2 + '@babel/plugin-syntax-typescript': 7.21.4(@babel/core@7.21.4) + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/preset-typescript@7.21.4(@babel/core@7.21.4): + resolution: {integrity: sha512-sMLNWY37TCdRH/bJ6ZeeOH1nPuanED7Ai9Y/vH31IPqalioJ6ZNFUWONsakhv4r4n+I6gm5lmoE0olkgib/j/A==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-plugin-utils': 7.20.2 + '@babel/helper-validator-option': 7.21.0 + '@babel/plugin-syntax-jsx': 7.21.4(@babel/core@7.21.4) + '@babel/plugin-transform-modules-commonjs': 7.21.2(@babel/core@7.21.4) + '@babel/plugin-transform-typescript': 7.21.3(@babel/core@7.21.4) + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/runtime@7.21.0: + resolution: {integrity: sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.13.11 + + /@babel/template@7.20.7: + resolution: {integrity: sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.21.4 + '@babel/parser': 7.21.4 + '@babel/types': 7.21.4 + + /@babel/traverse@7.21.4: + resolution: {integrity: sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.21.4 + '@babel/generator': 7.21.4 + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-function-name': 7.21.0 + '@babel/helper-hoist-variables': 7.18.6 + '@babel/helper-split-export-declaration': 7.18.6 + '@babel/parser': 7.21.4 + '@babel/types': 7.21.4 + debug: 4.3.4 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + + /@babel/types@7.21.4: + resolution: {integrity: sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.19.4 + '@babel/helper-validator-identifier': 7.19.1 + to-fast-properties: 2.0.0 + + /@balena/dockerignore@1.0.2: + resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==} + + /@emotion/hash@0.8.0: + resolution: {integrity: sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==} + dev: true + + /@emotion/hash@0.9.0: + resolution: {integrity: sha512-14FtKiHhy2QoPIzdTcvh//8OyBlknNs2nXRwIhG904opCby3l+9Xaf/wuPvICBF0rc1ZCNBd3nKe9cd2mecVkQ==} + + /@envelop/core@3.0.6: + resolution: {integrity: sha512-06t1xCPXq6QFN7W1JUEf68aCwYN0OUDNAIoJe7bAqhaoa2vn7NCcuX1VHkJ/OWpmElUgCsRO6RiBbIru1in0Ig==} + dependencies: + '@envelop/types': 3.0.2 + tslib: 2.5.0 + + /@envelop/types@3.0.2: + resolution: {integrity: sha512-pOFea9ha0EkURWxJ/35axoH9fDGP5S2cUu/5Mmo9pb8zUf+TaEot8vB670XXihFEn/92759BMjLJNWBKmNhyng==} + dependencies: + tslib: 2.5.0 + + /@envelop/validation-cache@5.1.3(@envelop/core@3.0.6)(graphql@16.6.0): + resolution: {integrity: sha512-MkzcScQHJJQ/9YCAPdWShEi3xZv4F4neTs+NszzSrZOdlU8z/THuRt7gZ0sO0y2be+sx+SKjHQP8Gq3VXXcTTg==} + peerDependencies: + '@envelop/core': ^3.0.6 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 + dependencies: + '@envelop/core': 3.0.6 + graphql: 16.6.0 + hash-it: 6.0.0 + lru-cache: 6.0.0 + tslib: 2.5.0 + + /@esbuild-kit/cjs-loader@2.4.2: + resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} + dependencies: + '@esbuild-kit/core-utils': 3.1.0 + get-tsconfig: 4.5.0 + dev: false + + /@esbuild-kit/core-utils@3.1.0: + resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==} + dependencies: + esbuild: 0.17.18 + source-map-support: 0.5.21 + dev: false + + /@esbuild-kit/esm-loader@2.5.5: + resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==} + dependencies: + '@esbuild-kit/core-utils': 3.1.0 + get-tsconfig: 4.5.0 + dev: false + + /@esbuild/android-arm64@0.16.13: + resolution: {integrity: sha512-r4xetsd1ez1NF9/9R2f9Q6AlxqiZLwUqo7ICOcvEVwopVkXUcspIjEbJk0EVTgT6Cp5+ymzGPT6YNV0ievx4yA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + optional: true + + /@esbuild/android-arm64@0.17.18: + resolution: {integrity: sha512-/iq0aK0eeHgSC3z55ucMAHO05OIqmQehiGay8eP5l/5l+iEr4EIbh4/MI8xD9qRFjqzgkc0JkX0LculNC9mXBw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + optional: true + + /@esbuild/android-arm64@0.17.6: + resolution: {integrity: sha512-YnYSCceN/dUzUr5kdtUzB+wZprCafuD89Hs0Aqv9QSdwhYQybhXTaSTcrl6X/aWThn1a/j0eEpUBGOE7269REg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm@0.15.18: + resolution: {integrity: sha512-5GT+kcs2WVGjVs7+boataCkO5Fg0y4kCjzkB5bAip7H4jfnOS3dA6KPiww9W1OEKTKeAcUVhdZGvgI65OXmUnw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm@0.16.13: + resolution: {integrity: sha512-JmtqThupn9Yf+FzANE+GG73ASUkssnPwOsndUElhp23685QzRK+MO1UompOlBaXV9D5FTuYcPnw7p4mCq2YbZQ==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + optional: true + + /@esbuild/android-arm@0.17.18: + resolution: {integrity: sha512-EmwL+vUBZJ7mhFCs5lA4ZimpUH3WMAoqvOIYhVQwdIgSpHC8ImHdsRyhHAVxpDYUSm0lWvd63z0XH1IlImS2Qw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + optional: true + + /@esbuild/android-arm@0.17.6: + resolution: {integrity: sha512-bSC9YVUjADDy1gae8RrioINU6e1lCkg3VGVwm0QQ2E1CWcC4gnMce9+B6RpxuSsrsXsk1yojn7sp1fnG8erE2g==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64@0.16.13: + resolution: {integrity: sha512-hKt1bFht/Vtp0xJ0ZVzFMnPy1y1ycmM3KNnp3zsyZfQmw7nhs2WLO4vxdR5YG+6RsHKCb2zbZ3VwlC0Tij0qyA==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + optional: true + + /@esbuild/android-x64@0.17.18: + resolution: {integrity: sha512-x+0efYNBF3NPW2Xc5bFOSFW7tTXdAcpfEg2nXmxegm4mJuVeS+i109m/7HMiOQ6M12aVGGFlqJX3RhNdYM2lWg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + optional: true + + /@esbuild/android-x64@0.17.6: + resolution: {integrity: sha512-MVcYcgSO7pfu/x34uX9u2QIZHmXAB7dEiLQC5bBl5Ryqtpj9lT2sg3gNDEsrPEmimSJW2FXIaxqSQ501YLDsZQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64@0.16.13: + resolution: {integrity: sha512-ogrVuNi2URocrr3Ps20f075EMm9V7IeenOi9FRj4qdbT6mQlwLuP4l90PW2iBrKERx0oRkcZprEUNsz/3xd7ww==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + optional: true + + /@esbuild/darwin-arm64@0.17.18: + resolution: {integrity: sha512-6tY+djEAdF48M1ONWnQb1C+6LiXrKjmqjzPNPWXhu/GzOHTHX2nh8Mo2ZAmBFg0kIodHhciEgUBtcYCAIjGbjQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + optional: true + + /@esbuild/darwin-arm64@0.17.6: + resolution: {integrity: sha512-bsDRvlbKMQMt6Wl08nHtFz++yoZHsyTOxnjfB2Q95gato+Yi4WnRl13oC2/PJJA9yLCoRv9gqT/EYX0/zDsyMA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-x64@0.16.13: + resolution: {integrity: sha512-Agajik9SBGiKD7FPXE+ExW6x3MgA/dUdpZnXa9y1tyfE4lKQx+eQiknSdrBnWPeqa9wL0AOvkhghmYhpVkyqkA==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + optional: true + + /@esbuild/darwin-x64@0.17.18: + resolution: {integrity: sha512-Qq84ykvLvya3dO49wVC9FFCNUfSrQJLbxhoQk/TE1r6MjHo3sFF2tlJCwMjhkBVq3/ahUisj7+EpRSz0/+8+9A==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + optional: true + + /@esbuild/darwin-x64@0.17.6: + resolution: {integrity: sha512-xh2A5oPrYRfMFz74QXIQTQo8uA+hYzGWJFoeTE8EvoZGHb+idyV4ATaukaUvnnxJiauhs/fPx3vYhU4wiGfosg==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64@0.16.13: + resolution: {integrity: sha512-KxMO3/XihBcHM+xQUM6nQZO1SgQuOsd1DCnKF1a4SIf/i5VD45vrqN3k8ePgFrEbMi7m5JeGmvNqwJXinF0a4Q==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + optional: true + + /@esbuild/freebsd-arm64@0.17.18: + resolution: {integrity: sha512-fw/ZfxfAzuHfaQeMDhbzxp9mc+mHn1Y94VDHFHjGvt2Uxl10mT4CDavHm+/L9KG441t1QdABqkVYwakMUeyLRA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + optional: true + + /@esbuild/freebsd-arm64@0.17.6: + resolution: {integrity: sha512-EnUwjRc1inT4ccZh4pB3v1cIhohE2S4YXlt1OvI7sw/+pD+dIE4smwekZlEPIwY6PhU6oDWwITrQQm5S2/iZgg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-x64@0.16.13: + resolution: {integrity: sha512-Ez15oqV1vwvZ30cVLeBW14BsWq/fdWNQGMOxxqaSJVQVLqHhvgfQ7gxGDiN9tpJdeQhqJO+Q0r02/Tce5+USNg==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + optional: true + + /@esbuild/freebsd-x64@0.17.18: + resolution: {integrity: sha512-FQFbRtTaEi8ZBi/A6kxOC0V0E9B/97vPdYjY9NdawyLd4Qk5VD5g2pbWN2VR1c0xhzcJm74HWpObPszWC+qTew==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + optional: true + + /@esbuild/freebsd-x64@0.17.6: + resolution: {integrity: sha512-Uh3HLWGzH6FwpviUcLMKPCbZUAFzv67Wj5MTwK6jn89b576SR2IbEp+tqUHTr8DIl0iDmBAf51MVaP7pw6PY5Q==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm64@0.16.13: + resolution: {integrity: sha512-qi5n7KwcGViyJeZeQnu8fB6dC3Mlm5PGaqSv2HhQDDx/MPvVfQGNMcv7zcBL4qk3FkuWhGVwXkjQ76x7R0PWlA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-arm64@0.17.18: + resolution: {integrity: sha512-R7pZvQZFOY2sxUG8P6A21eq6q+eBv7JPQYIybHVf1XkQYC+lT7nDBdC7wWKTrbvMXKRaGudp/dzZCwL/863mZQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-arm64@0.17.6: + resolution: {integrity: sha512-bUR58IFOMJX523aDVozswnlp5yry7+0cRLCXDsxnUeQYJik1DukMY+apBsLOZJblpH+K7ox7YrKrHmJoWqVR9w==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm@0.16.13: + resolution: {integrity: sha512-18dLd2L3mda+iFj6sswyBMSh2UwniamD9M4DwPv8VM+9apRFlQ5IGKxBdumnTuOI4NvwwAernmUseWhYQ9k+rg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-arm@0.17.18: + resolution: {integrity: sha512-jW+UCM40LzHcouIaqv3e/oRs0JM76JfhHjCavPxMUti7VAPh8CaGSlS7cmyrdpzSk7A+8f0hiedHqr/LMnfijg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-arm@0.17.6: + resolution: {integrity: sha512-7YdGiurNt7lqO0Bf/U9/arrPWPqdPqcV6JCZda4LZgEn+PTQ5SMEI4MGR52Bfn3+d6bNEGcWFzlIxiQdS48YUw==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ia32@0.16.13: + resolution: {integrity: sha512-2489Xad9sr+6GD7nB913fUqpCsSwVwgskkQTq4Or2mZntSPYPebyJm8l1YruHo7oqYMTGV6RiwGE4gRo3H+EPQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-ia32@0.17.18: + resolution: {integrity: sha512-ygIMc3I7wxgXIxk6j3V00VlABIjq260i967Cp9BNAk5pOOpIXmd1RFQJQX9Io7KRsthDrQYrtcx7QCof4o3ZoQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-ia32@0.17.6: + resolution: {integrity: sha512-ujp8uoQCM9FRcbDfkqECoARsLnLfCUhKARTP56TFPog8ie9JG83D5GVKjQ6yVrEVdMie1djH86fm98eY3quQkQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.14.54: + resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.15.18: + resolution: {integrity: sha512-L4jVKS82XVhw2nvzLg/19ClLWg0y27ulRwuP7lcyL6AbUWB5aPglXY3M21mauDQMDfRLs8cQmeT03r/+X3cZYQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.16.13: + resolution: {integrity: sha512-x8KplRu9Y43Px8I9YS+sPBwQ+fw44Mvp2BPVADopKDWz+h3fcj1BvRU58kxb89WObmwKX9sWdtYzepL4Fmx03A==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-loong64@0.17.18: + resolution: {integrity: sha512-bvPG+MyFs5ZlwYclCG1D744oHk1Pv7j8psF5TfYx7otCVmcJsEXgFEhQkbhNW8otDHL1a2KDINW20cfCgnzgMQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-loong64@0.17.6: + resolution: {integrity: sha512-y2NX1+X/Nt+izj9bLoiaYB9YXT/LoaQFYvCkVD77G/4F+/yuVXYCWz4SE9yr5CBMbOxOfBcy/xFL4LlOeNlzYQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-mips64el@0.16.13: + resolution: {integrity: sha512-qhhdWph9FLwD9rVVC/nUf7k2U4NZIA6/mGx0B7+O6PFV0GjmPA2E3zDQ4NUjq9P26E0DeAZy9akH9dYcUBRU7A==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-mips64el@0.17.18: + resolution: {integrity: sha512-oVqckATOAGuiUOa6wr8TXaVPSa+6IwVJrGidmNZS1cZVx0HqkTMkqFGD2HIx9H1RvOwFeWYdaYbdY6B89KUMxA==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-mips64el@0.17.6: + resolution: {integrity: sha512-09AXKB1HDOzXD+j3FdXCiL/MWmZP0Ex9eR8DLMBVcHorrWJxWmY8Nms2Nm41iRM64WVx7bA/JVHMv081iP2kUA==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ppc64@0.16.13: + resolution: {integrity: sha512-cVWAPKsrRVxI1jCeJHnYSbE3BrEU+pZTZK2gfao9HRxuc+3m4+RLfs3EVEpGLmMKEcWfVCB9wZ3yNxnknutGKQ==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-ppc64@0.17.18: + resolution: {integrity: sha512-3dLlQO+b/LnQNxgH4l9rqa2/IwRJVN9u/bK63FhOPB4xqiRqlQAU0qDU3JJuf0BmaH0yytTBdoSBHrb2jqc5qQ==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-ppc64@0.17.6: + resolution: {integrity: sha512-AmLhMzkM8JuqTIOhxnX4ubh0XWJIznEynRnZAVdA2mMKE6FAfwT2TWKTwdqMG+qEaeyDPtfNoZRpJbD4ZBv0Tg==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64@0.16.13: + resolution: {integrity: sha512-Agb7dbRyZWnmPn5Vvf0eyqaEUqSsaIUwwyInu2EoFTaIDRp093QU2M5alUyOooMLkRbD1WvqQNwx08Z/g+SAcQ==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-riscv64@0.17.18: + resolution: {integrity: sha512-/x7leOyDPjZV3TcsdfrSI107zItVnsX1q2nho7hbbQoKnmoeUWjs+08rKKt4AUXju7+3aRZSsKrJtaRmsdL1xA==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-riscv64@0.17.6: + resolution: {integrity: sha512-Y4Ri62PfavhLQhFbqucysHOmRamlTVK10zPWlqjNbj2XMea+BOs4w6ASKwQwAiqf9ZqcY9Ab7NOU4wIgpxwoSQ==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-s390x@0.16.13: + resolution: {integrity: sha512-AqRBIrc/+kl08ahliNG+EyU+j41wIzQfwBTKpi80cCDiYvYFPuXjvzZsD9muiu58Isj0RVni9VgC4xK/AnSW4g==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-s390x@0.17.18: + resolution: {integrity: sha512-cX0I8Q9xQkL/6F5zWdYmVf5JSQt+ZfZD2bJudZrWD+4mnUvoZ3TDDXtDX2mUaq6upMFv9FlfIh4Gfun0tbGzuw==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-s390x@0.17.6: + resolution: {integrity: sha512-SPUiz4fDbnNEm3JSdUW8pBJ/vkop3M1YwZAVwvdwlFLoJwKEZ9L98l3tzeyMzq27CyepDQ3Qgoba44StgbiN5Q==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-x64@0.16.13: + resolution: {integrity: sha512-S4wn2BimuhPcoArRtVrdHUKIymCCZcYAXQE47kUiX4yrUrEX2/ifn5eKNbZ5c1jJKUlh1gC2ESIN+iw3wQax3g==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-x64@0.17.18: + resolution: {integrity: sha512-66RmRsPlYy4jFl0vG80GcNRdirx4nVWAzJmXkevgphP1qf4dsLQCpSKGM3DUQCojwU1hnepI63gNZdrr02wHUA==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@esbuild/linux-x64@0.17.6: + resolution: {integrity: sha512-a3yHLmOodHrzuNgdpB7peFGPx1iJ2x6m+uDvhP2CKdr2CwOaqEFMeSqYAHU7hG+RjCq8r2NFujcd/YsEsFgTGw==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/netbsd-x64@0.16.13: + resolution: {integrity: sha512-2c8JWgfUMlQHTdaR5X3xNMwqOyad8kgeCupuVkdm3QkUOzGREjlTETQsK6oHifocYzDCo9FeKcUwsK356SdR+g==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + optional: true + + /@esbuild/netbsd-x64@0.17.18: + resolution: {integrity: sha512-95IRY7mI2yrkLlTLb1gpDxdC5WLC5mZDi+kA9dmM5XAGxCME0F8i4bYH4jZreaJ6lIZ0B8hTrweqG1fUyW7jbg==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + optional: true + + /@esbuild/netbsd-x64@0.17.6: + resolution: {integrity: sha512-EanJqcU/4uZIBreTrnbnre2DXgXSa+Gjap7ifRfllpmyAU7YMvaXmljdArptTHmjrkkKm9BK6GH5D5Yo+p6y5A==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64@0.16.13: + resolution: {integrity: sha512-Bwh+PmKD/LK+xBjqIpnYnKYj0fIyQJ0YpRxsn0F+WfzvQ2OA+GKDlf8AHosiCns26Q4Dje388jQVwfOBZ1GaFw==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + optional: true + + /@esbuild/openbsd-x64@0.17.18: + resolution: {integrity: sha512-WevVOgcng+8hSZ4Q3BKL3n1xTv5H6Nb53cBrtzzEjDbbnOmucEVcZeGCsCOi9bAOcDYEeBZbD2SJNBxlfP3qiA==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + optional: true + + /@esbuild/openbsd-x64@0.17.6: + resolution: {integrity: sha512-xaxeSunhQRsTNGFanoOkkLtnmMn5QbA0qBhNet/XLVsc+OVkpIWPHcr3zTW2gxVU5YOHFbIHR9ODuaUdNza2Vw==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64@0.16.13: + resolution: {integrity: sha512-8wwk6f9XGnhrF94/DBdFM4Xm1JeCyGTCj67r516VS9yvBVQf3Rar54L+XPVDs/oZOokwH+XsktrgkuTMAmjntg==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + optional: true + + /@esbuild/sunos-x64@0.17.18: + resolution: {integrity: sha512-Rzf4QfQagnwhQXVBS3BYUlxmEbcV7MY+BH5vfDZekU5eYpcffHSyjU8T0xucKVuOcdCsMo+Ur5wmgQJH2GfNrg==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + optional: true + + /@esbuild/sunos-x64@0.17.6: + resolution: {integrity: sha512-gnMnMPg5pfMkZvhHee21KbKdc6W3GR8/JuE0Da1kjwpK6oiFU3nqfHuVPgUX2rsOx9N2SadSQTIYV1CIjYG+xw==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-arm64@0.16.13: + resolution: {integrity: sha512-Jmwbp/5ArLCiRAHC33ODfcrlIcbP/exXkOEUVkADNJC4e/so2jm+i8IQFvVX/lA2GWvK3GdgcN0VFfp9YITAbg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + optional: true + + /@esbuild/win32-arm64@0.17.18: + resolution: {integrity: sha512-Kb3Ko/KKaWhjeAm2YoT/cNZaHaD1Yk/pa3FTsmqo9uFh1D1Rfco7BBLIPdDOozrObj2sahslFuAQGvWbgWldAg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + optional: true + + /@esbuild/win32-arm64@0.17.6: + resolution: {integrity: sha512-G95n7vP1UnGJPsVdKXllAJPtqjMvFYbN20e8RK8LVLhlTiSOH1sd7+Gt7rm70xiG+I5tM58nYgwWrLs6I1jHqg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32@0.16.13: + resolution: {integrity: sha512-AX6WjntGjhJHzrPSVvjMD7grxt41koHfAOx6lxLorrpDwwIKKPaGDASPZgvFIZHTbwhOtILW6vAXxYPDsKpDJA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + optional: true + + /@esbuild/win32-ia32@0.17.18: + resolution: {integrity: sha512-0/xUMIdkVHwkvxfbd5+lfG7mHOf2FRrxNbPiKWg9C4fFrB8H0guClmaM3BFiRUYrznVoyxTIyC/Ou2B7QQSwmw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + optional: true + + /@esbuild/win32-ia32@0.17.6: + resolution: {integrity: sha512-96yEFzLhq5bv9jJo5JhTs1gI+1cKQ83cUpyxHuGqXVwQtY5Eq54ZEsKs8veKtiKwlrNimtckHEkj4mRh4pPjsg==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-x64@0.16.13: + resolution: {integrity: sha512-A+U4gM6OOkPS03UgVU08GTpAAAxPsP/8Z4FmneGo4TaVSD99bK9gVJXlqUEPMO/htFXEAht2O6pX4ErtLY5tVg==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + optional: true + + /@esbuild/win32-x64@0.17.18: + resolution: {integrity: sha512-qU25Ma1I3NqTSHJUOKi9sAH1/Mzuvlke0ioMJRthLXKm7JiSKVwFghlGbDLOO2sARECGhja4xYfRAZNPAkooYg==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + optional: true + + /@esbuild/win32-x64@0.17.6: + resolution: {integrity: sha512-n6d8MOyUrNp6G4VSpRcgjs5xj4A91svJSaiwLIDWVWEsZtpN5FA9NlBbZHDmAJc2e8e6SF4tkBD3HAvPF+7igA==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@fontsource/ibm-plex-mono@4.5.13: + resolution: {integrity: sha512-KAE7X2LgCV4X6p7vj1h2phRnhPX4YUa8FBAB0Jj9xW7Q+p+k2ce4HEAMJJ2RFHI075ClgQx+KZuDBNuiKgp5yw==} + dev: false + + /@graphql-tools/executor@0.0.18(graphql@16.6.0): + resolution: {integrity: sha512-xZC0C+/npXoSHBB5bsJdwxDLgtl1Gu4fL9J2TPQmXoZC3L2N506KJoppf9LgWdHU/xK04luJrhP6WjhfkIN0pQ==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 + dependencies: + '@graphql-tools/utils': 9.2.1(graphql@16.6.0) + '@graphql-typed-document-node/core': 3.2.0(graphql@16.6.0) + '@repeaterjs/repeater': 3.0.4 + graphql: 16.6.0 + tslib: 2.5.0 + value-or-promise: 1.0.12 + + /@graphql-tools/merge@8.4.1(graphql@16.6.0): + resolution: {integrity: sha512-hssnPpZ818mxgl5+GfyOOSnnflAxiaTn1A1AojZcIbh4J52sS1Q0gSuBR5VrnUDjuxiqoCotpXdAQl+K+U6KLQ==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 + dependencies: + '@graphql-tools/utils': 9.2.1(graphql@16.6.0) + graphql: 16.6.0 + tslib: 2.5.0 + + /@graphql-tools/schema@9.0.19(graphql@16.6.0): + resolution: {integrity: sha512-oBRPoNBtCkk0zbUsyP4GaIzCt8C0aCI4ycIRUL67KK5pOHljKLBBtGT+Jr6hkzA74C8Gco8bpZPe7aWFjiaK2w==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 + dependencies: + '@graphql-tools/merge': 8.4.1(graphql@16.6.0) + '@graphql-tools/utils': 9.2.1(graphql@16.6.0) + graphql: 16.6.0 + tslib: 2.5.0 + value-or-promise: 1.0.12 + + /@graphql-tools/utils@9.2.1(graphql@16.6.0): + resolution: {integrity: sha512-WUw506Ql6xzmOORlriNrD6Ugx+HjVgYxt9KCXD9mHAak+eaXSwuGGPyE60hy9xaDEoXKBsG7SkG69ybitaVl6A==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 + dependencies: + '@graphql-typed-document-node/core': 3.2.0(graphql@16.6.0) + graphql: 16.6.0 + tslib: 2.5.0 + + /@graphql-typed-document-node/core@3.2.0(graphql@16.6.0): + resolution: {integrity: sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==} + peerDependencies: + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 + dependencies: + graphql: 16.6.0 + + /@graphql-yoga/logger@0.0.1: + resolution: {integrity: sha512-6npFz7eZz33mXgSm1waBLMjUNG0D5hTc/p5Hcs1mojkT3KsLpCOFokzTEKboNsBhKevYcaVa/xeA7WBj4UYMLg==} + dependencies: + tslib: 2.5.0 + + /@graphql-yoga/subscription@3.1.0: + resolution: {integrity: sha512-Vc9lh8KzIHyS3n4jBlCbz7zCjcbtQnOBpsymcRvHhFr2cuH+knmRn0EmzimMQ58jQ8kxoRXXC3KJS3RIxSdPIg==} + dependencies: + '@graphql-yoga/typed-event-target': 1.0.0 + '@repeaterjs/repeater': 3.0.4 + '@whatwg-node/events': 0.0.2 + tslib: 2.5.0 + + /@graphql-yoga/typed-event-target@1.0.0: + resolution: {integrity: sha512-Mqni6AEvl3VbpMtKw+TIjc9qS9a8hKhiAjFtqX488yq5oJtj9TkNlFTIacAVS3vnPiswNsmDiQqvwUOcJgi1DA==} + dependencies: + '@repeaterjs/repeater': 3.0.4 + tslib: 2.5.0 + + /@httptoolkit/websocket-stream@6.0.1: + resolution: {integrity: sha512-A0NOZI+Glp3Xgcz6Na7i7o09+/+xm2m0UCU8gdtM2nIv6/cjLmhMZMqehSpTlgbx9omtLmV8LVqOskPEyWnmZQ==} + dependencies: + '@types/ws': 8.5.4 + duplexify: 3.7.1 + inherits: 2.0.4 + isomorphic-ws: 4.0.1(ws@8.13.0) + readable-stream: 2.3.8 + safe-buffer: 5.2.1 + ws: 8.13.0 + xtend: 4.0.2 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /@jridgewell/gen-mapping@0.3.3: + resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/set-array': 1.1.2 + '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/trace-mapping': 0.3.18 + + /@jridgewell/resolve-uri@3.1.0: + resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} + engines: {node: '>=6.0.0'} + + /@jridgewell/set-array@1.1.2: + resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} + engines: {node: '>=6.0.0'} + + /@jridgewell/sourcemap-codec@1.4.14: + resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} + + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + + /@jridgewell/trace-mapping@0.3.18: + resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} + dependencies: + '@jridgewell/resolve-uri': 3.1.0 + '@jridgewell/sourcemap-codec': 1.4.14 + + /@macaron-css/babel@1.1.3: + resolution: {integrity: sha512-KTmNqWcwe9Az9+sHrhX8ASOJpmXmEnUnsXkHImbLVTq93kn/33u751trUyi3oCktMs+P2GoQ2eI+qZVrSX+ZxA==} + dependencies: + '@babel/core': 7.21.4 + '@babel/generator': 7.21.4 + '@babel/helper-module-imports': 7.21.4 + '@babel/preset-typescript': 7.21.4(@babel/core@7.21.4) + '@emotion/hash': 0.8.0 + '@types/babel__core': 7.20.0 + transitivePeerDependencies: + - supports-color + dev: true + + /@macaron-css/core@1.2.0: + resolution: {integrity: sha512-SIyibI+Aw5fMI17PGK+9U0sfC5/+KBGjVAdLU8RzOEkA97HXf4QuqBlRfonUQrplLaVFHSilFkKrreFoUHsH2w==} + dependencies: + '@vanilla-extract/css': 1.11.0 + '@vanilla-extract/dynamic': 2.0.3 + '@vanilla-extract/recipes': 0.2.5(@vanilla-extract/css@1.11.0) + dev: false + + /@macaron-css/integration@1.3.0: + resolution: {integrity: sha512-lE1T2CTpZRf6hd7ptb6zHXr6As4mFrBqDWLWXuqcLXiQNQg8Iqe5qkES4zh9e4bN+iiX1HCFsBUHj602LHvN/g==} + dependencies: + '@babel/core': 7.21.4 + '@babel/plugin-syntax-jsx': 7.21.4(@babel/core@7.21.4) + '@macaron-css/babel': 1.1.3 + '@vanilla-extract/integration': 6.2.1 + esbuild: 0.14.54 + transitivePeerDependencies: + - '@types/node' + - less + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /@macaron-css/solid@1.0.1(@vanilla-extract/recipes@0.2.5)(solid-js@1.7.3): + resolution: {integrity: sha512-M/NOsagaNFYbYASMVRNRe+vpSzv1UAT1c601cE7BqnTyUZ8NyWTXVTzZlbThPTfNNRuvTcoirk0fF/iUshzGNw==} + peerDependencies: + '@vanilla-extract/recipes': ^0.2.5 + solid-js: ^1.4.3 + dependencies: + '@vanilla-extract/recipes': 0.2.5(@vanilla-extract/css@1.11.0) + solid-js: 1.7.3 + dev: false + + /@macaron-css/vite@1.3.0(vite@3.2.6): + resolution: {integrity: sha512-eIc4cemgtZJaLMBo2auXC7hOTMAw+UEddQV1/ZPGArrRoYKNOBJiGDuh46AeBTrvGQSkKYUp7PR86aHCzSBLUA==} + dependencies: + '@macaron-css/integration': 1.3.0 + '@vanilla-extract/integration': 6.2.1 + '@vanilla-extract/vite-plugin': 3.8.0(vite@3.2.6) + transitivePeerDependencies: + - '@types/node' + - less + - sass + - stylus + - sugarss + - supports-color + - terser + - ts-node + - vite + dev: true + + /@noble/hashes@1.3.0: + resolution: {integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==} + dev: false + + /@octokit/auth-token@3.0.3: + resolution: {integrity: sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA==} + engines: {node: '>= 14'} + dependencies: + '@octokit/types': 9.1.2 + dev: false + + /@octokit/core@4.2.0: + resolution: {integrity: sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg==} + engines: {node: '>= 14'} + dependencies: + '@octokit/auth-token': 3.0.3 + '@octokit/graphql': 5.0.5 + '@octokit/request': 6.2.3 + '@octokit/request-error': 3.0.3 + '@octokit/types': 9.1.2 + before-after-hook: 2.2.3 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/endpoint@7.0.5: + resolution: {integrity: sha512-LG4o4HMY1Xoaec87IqQ41TQ+glvIeTKqfjkCEmt5AIwDZJwQeVZFIEYXrYY6yLwK+pAScb9Gj4q+Nz2qSw1roA==} + engines: {node: '>= 14'} + dependencies: + '@octokit/types': 9.1.2 + is-plain-object: 5.0.0 + universal-user-agent: 6.0.0 + dev: false + + /@octokit/graphql@5.0.5: + resolution: {integrity: sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ==} + engines: {node: '>= 14'} + dependencies: + '@octokit/request': 6.2.3 + '@octokit/types': 9.1.2 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/openapi-types@17.0.0: + resolution: {integrity: sha512-V8BVJGN0ZmMlURF55VFHFd/L92XQQ43KvFjNmY1IYbCN3V/h/uUFV6iQi19WEHM395Nn+1qhUbViCAD/1czzog==} + dev: false + + /@octokit/plugin-paginate-rest@6.0.0(@octokit/core@4.2.0): + resolution: {integrity: sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw==} + engines: {node: '>= 14'} + peerDependencies: + '@octokit/core': '>=4' + dependencies: + '@octokit/core': 4.2.0 + '@octokit/types': 9.1.2 + dev: false + + /@octokit/plugin-request-log@1.0.4(@octokit/core@4.2.0): + resolution: {integrity: sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==} + peerDependencies: + '@octokit/core': '>=3' + dependencies: + '@octokit/core': 4.2.0 + dev: false + + /@octokit/plugin-rest-endpoint-methods@7.0.1(@octokit/core@4.2.0): + resolution: {integrity: sha512-pnCaLwZBudK5xCdrR823xHGNgqOzRnJ/mpC/76YPpNP7DybdsJtP7mdOwh+wYZxK5jqeQuhu59ogMI4NRlBUvA==} + engines: {node: '>= 14'} + peerDependencies: + '@octokit/core': '>=3' + dependencies: + '@octokit/core': 4.2.0 + '@octokit/types': 9.1.2 + deprecation: 2.3.1 + dev: false + + /@octokit/request-error@3.0.3: + resolution: {integrity: sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ==} + engines: {node: '>= 14'} + dependencies: + '@octokit/types': 9.1.2 + deprecation: 2.3.1 + once: 1.4.0 + dev: false + + /@octokit/request@6.2.3: + resolution: {integrity: sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA==} + engines: {node: '>= 14'} + dependencies: + '@octokit/endpoint': 7.0.5 + '@octokit/request-error': 3.0.3 + '@octokit/types': 9.1.2 + is-plain-object: 5.0.0 + node-fetch: 2.6.9 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/rest@19.0.7: + resolution: {integrity: sha512-HRtSfjrWmWVNp2uAkEpQnuGMJsu/+dBr47dRc5QVgsCbnIc1+GFEaoKBWkYG+zjrsHpSqcAElMio+n10c0b5JA==} + engines: {node: '>= 14'} + dependencies: + '@octokit/core': 4.2.0 + '@octokit/plugin-paginate-rest': 6.0.0(@octokit/core@4.2.0) + '@octokit/plugin-request-log': 1.0.4(@octokit/core@4.2.0) + '@octokit/plugin-rest-endpoint-methods': 7.0.1(@octokit/core@4.2.0) + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/types@9.1.2: + resolution: {integrity: sha512-LPbJIuu1WNoRHbN4UMysEdlissRFpTCWyoKT7kHPufI8T+XX33/qilfMWJo3mCOjNIKu0+43oSQPf+HJa0+TTQ==} + dependencies: + '@octokit/openapi-types': 17.0.0 + dev: false + + /@paralleldrive/cuid2@2.2.0: + resolution: {integrity: sha512-CVQDpPIUHrUGGLdrMGz1NmqZvqmsB2j2rCIQEu1EvxWjlFh4fhvEGmgR409cY20/67/WlJsggenq0no3p3kYsw==} + dependencies: + '@noble/hashes': 1.3.0 + dev: false + + /@peculiar/asn1-schema@2.3.6: + resolution: {integrity: sha512-izNRxPoaeJeg/AyH8hER6s+H7p4itk+03QCa4sbxI3lNdseQYCuxzgsuNK8bTXChtLTjpJz6NmXKA73qLa3rCA==} + dependencies: + asn1js: 3.0.5 + pvtsutils: 1.3.2 + tslib: 2.5.0 + + /@peculiar/json-schema@1.1.12: + resolution: {integrity: sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==} + engines: {node: '>=8.0.0'} + dependencies: + tslib: 2.5.0 + + /@peculiar/webcrypto@1.4.3: + resolution: {integrity: sha512-VtaY4spKTdN5LjJ04im/d/joXuvLbQdgy5Z4DXF4MFZhQ+MTrejbNMkfZBp1Bs3O5+bFqnJgyGdPuZQflvIa5A==} + engines: {node: '>=10.12.0'} + dependencies: + '@peculiar/asn1-schema': 2.3.6 + '@peculiar/json-schema': 1.1.12 + pvtsutils: 1.3.2 + tslib: 2.5.0 + webcrypto-core: 1.7.7 + + /@planetscale/database@1.7.0: + resolution: {integrity: sha512-lWR6biXChUyQnxsT4RT1CIeR3ZJvwTQXiQ+158MnY3VjLwjHEGakDzdH9kwUGPk6CHvu6UeqRXp1DgUOVHJFTw==} + engines: {node: '>=16'} + dev: false + + /@repeaterjs/repeater@3.0.4: + resolution: {integrity: sha512-AW8PKd6iX3vAZ0vA43nOUOnbq/X5ihgU+mSXXqunMkeQADGiqw/PY0JNeYtD5sr0PAy51YPgAPbDoeapv9r8WA==} + + /@solidjs/router@0.8.2(solid-js@1.7.3): + resolution: {integrity: sha512-gUKW+LZqxtX6y/Aw6JKyy4gQ9E7dLqp513oB9pSYJR1HM5c56Pf7eijzyXX+b3WuXig18Cxqah4tMtF0YGu80w==} + peerDependencies: + solid-js: ^1.5.3 + dependencies: + solid-js: 1.7.3 + dev: false + + /@trpc/server@9.16.0: + resolution: {integrity: sha512-IENsJs41ZR4oeFUJhsNNTSgEOtuRN0m9u7ec4u3eG/qOc7bIoo1nDoYtx4bl6OJJSQYEytG9tlcVz9G8OAaHbg==} + dependencies: + tslib: 2.5.0 + + /@tsconfig/node16@1.0.3: + resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} + + /@types/aws-lambda@8.10.114: + resolution: {integrity: sha512-M8WpEGfC9iQ6V2Ccq6nGIXoQgeVc6z0Ngk8yCOL5V/TYIxshvb0MWQYLFFTZDesL0zmsoBc4OBjG9DB/4rei6w==} + dev: true + + /@types/babel__core@7.20.0: + resolution: {integrity: sha512-+n8dL/9GWblDO0iU6eZAwEIJVr5DWigtle+Q6HLOrh/pdbXOhOtqzq8VPPE2zvNJzSKY4vH/z3iT3tn0A3ypiQ==} + dependencies: + '@babel/parser': 7.21.4 + '@babel/types': 7.21.4 + '@types/babel__generator': 7.6.4 + '@types/babel__template': 7.4.1 + '@types/babel__traverse': 7.18.4 + dev: true + + /@types/babel__generator@7.6.4: + resolution: {integrity: sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@types/babel__template@7.4.1: + resolution: {integrity: sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==} + dependencies: + '@babel/parser': 7.21.4 + '@babel/types': 7.21.4 + dev: true + + /@types/babel__traverse@7.18.4: + resolution: {integrity: sha512-TLG7CsGZZmX9aDF78UuJxnNTfQyRUFU0OYIVyIblr0/wd/HvsIo8wmuB90CszeD2MtLLAE9Tt4cWvk+KVkyGIw==} + dependencies: + '@babel/types': 7.21.4 + dev: true + + /@types/chai-subset@1.3.3: + resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} + dependencies: + '@types/chai': 4.3.4 + dev: true + + /@types/chai@4.3.4: + resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==} + dev: true + + /@types/node@18.16.0: + resolution: {integrity: sha512-BsAaKhB+7X+H4GnSjGhJG9Qi8Tw+inU9nJDwmD5CgOmBLEI6ArdhikpLX7DjbjDRDTbqZzU2LSQNZg8WGPiSZQ==} + + /@types/ws@8.5.4: + resolution: {integrity: sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==} + dependencies: + '@types/node': 18.16.0 + + /@vanilla-extract/babel-plugin-debug-ids@1.0.2: + resolution: {integrity: sha512-LjnbQWGeMwaydmovx8jWUR8BxLtLiPyq0xz5C8G5OvFhsuJxvavLdrBHNNizvr1dq7/3qZGlPv0znsvU4P44YA==} + dependencies: + '@babel/core': 7.21.4 + transitivePeerDependencies: + - supports-color + dev: true + + /@vanilla-extract/css@1.11.0: + resolution: {integrity: sha512-uohj+8cGWbnrVzTfrjlJeXqdGjH3d3TcscdQxKe3h5bb5QQXTpPSq+c+SeWADIGiZybzcW0CBvZV8jsy1ywY9w==} + dependencies: + '@emotion/hash': 0.9.0 + '@vanilla-extract/private': 1.0.3 + ahocorasick: 1.0.2 + chalk: 4.1.2 + css-what: 5.1.0 + cssesc: 3.0.0 + csstype: 3.1.2 + deep-object-diff: 1.1.9 + deepmerge: 4.3.1 + media-query-parser: 2.0.2 + outdent: 0.8.0 + + /@vanilla-extract/dynamic@2.0.3: + resolution: {integrity: sha512-Rglfw2gXAYiBzAQ4jgUG7rBgE2c88e/zcG27ZVoIqMHVq56wf2C1katGMm1yFMNBgzqM7oBNYzz4YOMzznydkg==} + dependencies: + '@vanilla-extract/private': 1.0.3 + dev: false + + /@vanilla-extract/integration@6.2.1: + resolution: {integrity: sha512-+xYJz07G7TFAMZGrOqArOsURG+xcYvqctujEkANjw2McCBvGEK505RxQqOuNiA9Mi9hgGdNp2JedSa94f3eoLg==} + dependencies: + '@babel/core': 7.21.4 + '@babel/plugin-syntax-typescript': 7.21.4(@babel/core@7.21.4) + '@vanilla-extract/babel-plugin-debug-ids': 1.0.2 + '@vanilla-extract/css': 1.11.0 + esbuild: 0.17.6 + eval: 0.1.6 + find-up: 5.0.0 + javascript-stringify: 2.1.0 + lodash: 4.17.21 + mlly: 1.2.0 + outdent: 0.8.0 + vite: 4.3.3 + vite-node: 0.28.5 + transitivePeerDependencies: + - '@types/node' + - less + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /@vanilla-extract/private@1.0.3: + resolution: {integrity: sha512-17kVyLq3ePTKOkveHxXuIJZtGYs+cSoev7BlP+Lf4916qfDhk/HBjvlYDe8egrea7LNPHKwSZJK/bzZC+Q6AwQ==} + + /@vanilla-extract/recipes@0.2.5(@vanilla-extract/css@1.11.0): + resolution: {integrity: sha512-OWXUUiFJdswD3+Xg8f8avuw/vAHZRFS4oHqFeoV1TcO8cfbDQ0zmkreBHvyspoJU+qsyWK48yPHKSptqNRPy9Q==} + peerDependencies: + '@vanilla-extract/css': ^1.0.0 + dependencies: + '@vanilla-extract/css': 1.11.0 + dev: false + + /@vanilla-extract/vite-plugin@3.8.0(vite@3.2.6): + resolution: {integrity: sha512-HBCecR4eTbweo7wQPq9g/HBvxUi6Cua8O4Xk6t1by4W/imgEsHbRCCa9SowzZwg8lub7uJHBAdzWWpqY+LdH0w==} + peerDependencies: + vite: ^2.2.3 || ^3.0.0 || ^4.0.3 + dependencies: + '@vanilla-extract/integration': 6.2.1 + outdent: 0.8.0 + postcss: 8.4.23 + postcss-load-config: 3.1.4(postcss@8.4.23) + vite: 3.2.6(@types/node@18.16.0) + transitivePeerDependencies: + - '@types/node' + - less + - sass + - stylus + - sugarss + - supports-color + - terser + - ts-node + dev: true + + /@whatwg-node/events@0.0.2: + resolution: {integrity: sha512-WKj/lI4QjnLuPrim0cfO7i+HsDSXHxNv1y0CrJhdntuO3hxWZmnXCwNDnwOvry11OjRin6cgWNF+j/9Pn8TN4w==} + + /@whatwg-node/events@0.0.3: + resolution: {integrity: sha512-IqnKIDWfXBJkvy/k6tzskWTc2NK3LcqHlb+KHGCrjOCH4jfQckRX0NAiIcC/vIqQkzLYw2r2CTSwAxcrtcD6lA==} + + /@whatwg-node/fetch@0.8.8: + resolution: {integrity: sha512-CdcjGC2vdKhc13KKxgsc6/616BQ7ooDIgPeTuAiE8qfCnS0mGzcfCOoZXypQSz73nxI+GWc7ZReIAVhxoE1KCg==} + dependencies: + '@peculiar/webcrypto': 1.4.3 + '@whatwg-node/node-fetch': 0.3.6 + busboy: 1.6.0 + urlpattern-polyfill: 8.0.2 + web-streams-polyfill: 3.2.1 + + /@whatwg-node/node-fetch@0.3.6: + resolution: {integrity: sha512-w9wKgDO4C95qnXZRwZTfCmLWqyRnooGjcIwG0wADWjw9/HN0p7dtvtgSvItZtUyNteEvgTrd8QojNEqV6DAGTA==} + dependencies: + '@whatwg-node/events': 0.0.3 + busboy: 1.6.0 + fast-querystring: 1.1.1 + fast-url-parser: 1.1.3 + tslib: 2.5.0 + + /@whatwg-node/server@0.7.5: + resolution: {integrity: sha512-xTDJdPqr/wULxW3mGXQXD92SRXUm6jwQxqIvyHG17dykRTd21HuCaS2ggBn5lSAM/sYjjrT+OYv3fXbtS4+Mjw==} + dependencies: + '@whatwg-node/fetch': 0.8.8 + tslib: 2.5.0 + + /accepts@1.3.8: + resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} + engines: {node: '>= 0.6'} + dependencies: + mime-types: 2.1.35 + negotiator: 0.6.3 + + /acorn-walk@8.2.0: + resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} + engines: {node: '>=0.4.0'} + dev: true + + /acorn@8.8.2: + resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + + /ahocorasick@1.0.2: + resolution: {integrity: sha512-hCOfMzbFx5IDutmWLAt6MZwOUjIfSM9G9FyVxytmE4Rs/5YDPWQrD/+IR1w+FweD9H2oOZEnv36TmkjhNURBVA==} + + /ajv-formats@2.1.1(ajv@8.12.0): + resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + dependencies: + ajv: 8.12.0 + + /ajv@8.12.0: + resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + + /ansi-escapes@6.2.0: + resolution: {integrity: sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==} + engines: {node: '>=14.16'} + dependencies: + type-fest: 3.8.0 + + /ansi-regex@2.1.1: + resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==} + engines: {node: '>=0.10.0'} + + /ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + + /ansi-regex@6.0.1: + resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} + engines: {node: '>=12'} + + /ansi-styles@3.2.1: + resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} + engines: {node: '>=4'} + dependencies: + color-convert: 1.9.3 + + /ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + dependencies: + color-convert: 2.0.1 + + /ansi-styles@6.2.1: + resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} + engines: {node: '>=12'} + + /ansi@0.3.1: + resolution: {integrity: sha512-iFY7JCgHbepc0b82yLaw4IMortylNb6wG4kL+4R0C3iv6i+RHGHux/yUX5BTiRvSX/shMnngjR1YyNMnXEFh5A==} + + /anymatch@3.1.3: + resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} + engines: {node: '>= 8'} + dependencies: + normalize-path: 3.0.0 + picomatch: 2.3.1 + + /archiver-utils@2.1.0: + resolution: {integrity: sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==} + engines: {node: '>= 6'} + dependencies: + glob: 7.2.3 + graceful-fs: 4.2.11 + lazystream: 1.0.1 + lodash.defaults: 4.2.0 + lodash.difference: 4.5.0 + lodash.flatten: 4.4.0 + lodash.isplainobject: 4.0.6 + lodash.union: 4.6.0 + normalize-path: 3.0.0 + readable-stream: 2.3.8 + + /archiver@5.3.1: + resolution: {integrity: sha512-8KyabkmbYrH+9ibcTScQ1xCJC/CGcugdVIwB+53f5sZziXgwUh3iXlAlANMxcZyDEfTHMe6+Z5FofV8nopXP7w==} + engines: {node: '>= 10'} + dependencies: + archiver-utils: 2.1.0 + async: 3.2.4 + buffer-crc32: 0.2.13 + readable-stream: 3.6.2 + readdir-glob: 1.1.3 + tar-stream: 2.2.0 + zip-stream: 4.1.0 + + /are-we-there-yet@1.0.6: + resolution: {integrity: sha512-Zfw6bteqM9gQXZ1BIWOgM8xEwMrUGoyL8nW13+O+OOgNX3YhuDN1GDgg1NzdTlmm3j+9sHy7uBZ12r+z9lXnZQ==} + dependencies: + delegates: 1.0.0 + readable-stream: 2.3.8 + + /array-flatten@1.1.1: + resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==} + + /asn1.js@5.4.1: + resolution: {integrity: sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==} + dependencies: + bn.js: 4.12.0 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + safer-buffer: 2.1.2 + + /asn1js@3.0.5: + resolution: {integrity: sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==} + engines: {node: '>=12.0.0'} + dependencies: + pvtsutils: 1.3.2 + pvutils: 1.1.3 + tslib: 2.5.0 + + /assertion-error@1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + dev: true + + /astral-regex@2.0.0: + resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} + engines: {node: '>=8'} + + /async-limiter@1.0.1: + resolution: {integrity: sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==} + + /async@1.5.2: + resolution: {integrity: sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==} + + /async@3.2.4: + resolution: {integrity: sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==} + + /at-least-node@1.0.0: + resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} + engines: {node: '>= 4.0.0'} + + /atomically@1.7.0: + resolution: {integrity: sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==} + engines: {node: '>=10.12.0'} + + /auto-bind@5.0.1: + resolution: {integrity: sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + /available-typed-arrays@1.0.5: + resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} + engines: {node: '>= 0.4'} + + /aws-cdk-lib@2.72.1(constructs@10.1.156): + resolution: {integrity: sha512-uZJTXkZFFYoJsfzrvTMVCJH5x64DVw/7PiMHahCOIguipUFMzQI5sb3jmNkO7vgZIX/obQkuUl7C33rB/xfpcQ==} + engines: {node: '>= 14.15.0'} + peerDependencies: + constructs: ^10.0.0 + dependencies: + '@aws-cdk/asset-awscli-v1': 2.2.149 + '@aws-cdk/asset-kubectl-v20': 2.1.1 + '@aws-cdk/asset-node-proxy-agent-v5': 2.0.126 + '@balena/dockerignore': 1.0.2 + case: 1.6.3 + constructs: 10.1.156 + fs-extra: 9.1.0 + ignore: 5.2.4 + jsonschema: 1.4.1 + minimatch: 3.1.2 + punycode: 2.3.0 + semver: 7.5.0 + table: 6.8.1 + yaml: 1.10.2 + bundledDependencies: + - '@balena/dockerignore' + - case + - fs-extra + - ignore + - jsonschema + - minimatch + - punycode + - semver + - table + - yaml + + /aws-crt@1.15.15: + resolution: {integrity: sha512-StdpO3MREZLpAvkGs+PQNMLn0tvBagfl9iaeo7FYSHV0hQvnD5XoOARE2esQg1RxIH+2yRPvg4ccqLFNWC2qGw==} + requiresBuild: true + dependencies: + '@aws-sdk/util-utf8-browser': 3.259.0 + '@httptoolkit/websocket-stream': 6.0.1 + axios: 0.24.0 + buffer: 6.0.3 + cmake-js: 6.3.2 + crypto-js: 4.1.1 + mqtt: 4.3.7 + process: 0.11.10 + tar: 6.1.13 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + + /aws-iot-device-sdk@2.2.12: + resolution: {integrity: sha512-OcUI6Hq1N3PhAMgceWV3nFhDNkOFmSYPuv1CCqZhQAcWQ7UOhPmA5QSE4aiQcVN3wSIzTEO0UU4sh6ubjMOjPA==} + engines: {node: '>=4.0.0'} + dependencies: + crypto-js: 4.0.0 + minimist: 1.2.6 + mqtt: 4.2.8 + websocket-stream: 5.5.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /aws-sdk@2.1365.0: + resolution: {integrity: sha512-GRwHfzYufi7BhBtgyzeHvqS5yCMRC5ZCqmDU/TBMnr8IaH6sabSG2iAhVn1Kkpjv3tDnWHwDr5s8wNMTzJLPmg==} + engines: {node: '>= 10.0.0'} + dependencies: + buffer: 4.9.2 + events: 1.1.1 + ieee754: 1.1.13 + jmespath: 0.16.0 + querystring: 0.2.0 + sax: 1.2.1 + url: 0.10.3 + util: 0.12.5 + uuid: 8.0.0 + xml2js: 0.5.0 + + /axios@0.21.4(debug@4.3.4): + resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==} + dependencies: + follow-redirects: 1.15.2(debug@4.3.4) + transitivePeerDependencies: + - debug + + /axios@0.24.0: + resolution: {integrity: sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==} + dependencies: + follow-redirects: 1.15.2(debug@4.3.4) + transitivePeerDependencies: + - debug + + /babel-plugin-jsx-dom-expressions@0.36.10(@babel/core@7.21.4): + resolution: {integrity: sha512-QA2k/14WGw+RgcGGnEuLWwnu4em6CGhjeXtjvgOYyFHYS2a+CzPeaVQHDOlfuiBcjq/3hWMspHMIMnPEOIzdBg==} + peerDependencies: + '@babel/core': ^7.20.12 + dependencies: + '@babel/core': 7.21.4 + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.21.4(@babel/core@7.21.4) + '@babel/types': 7.21.4 + html-entities: 2.3.3 + validate-html-nesting: 1.2.2 + dev: true + + /babel-preset-solid@1.7.3(@babel/core@7.21.4): + resolution: {integrity: sha512-HOdyrij99zo+CBrmtDxSexBAl54vCBCfBoyueLBvcfVniaEXNd4ftKqSN6XQcLvFfCY28UFO+DHaigXzWKOfzg==} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/core': 7.21.4 + babel-plugin-jsx-dom-expressions: 0.36.10(@babel/core@7.21.4) + dev: true + + /balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + /base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + + /before-after-hook@2.2.3: + resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} + dev: false + + /big-integer@1.6.51: + resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==} + engines: {node: '>=0.6'} + + /binary-extensions@2.2.0: + resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} + engines: {node: '>=8'} + + /binary@0.3.0: + resolution: {integrity: sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==} + dependencies: + buffers: 0.1.1 + chainsaw: 0.1.0 + + /bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + + /bl@5.1.0: + resolution: {integrity: sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ==} + dependencies: + buffer: 6.0.3 + inherits: 2.0.4 + readable-stream: 3.6.2 + + /bluebird@3.4.7: + resolution: {integrity: sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==} + + /bluebird@3.7.2: + resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==} + + /bn.js@4.12.0: + resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} + + /body-parser@1.20.1: + resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==} + engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + dependencies: + bytes: 3.1.2 + content-type: 1.0.5 + debug: 2.6.9 + depd: 2.0.0 + destroy: 1.2.0 + http-errors: 2.0.0 + iconv-lite: 0.4.24 + on-finished: 2.4.1 + qs: 6.11.0 + raw-body: 2.5.1 + type-is: 1.6.18 + unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color + + /bowser@2.11.0: + resolution: {integrity: sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==} + + /brace-expansion@1.1.11: + resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + /brace-expansion@2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + + /braces@3.0.2: + resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} + engines: {node: '>=8'} + dependencies: + fill-range: 7.0.1 + + /browserslist@4.21.5: + resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + dependencies: + caniuse-lite: 1.0.30001481 + electron-to-chromium: 1.4.369 + node-releases: 2.0.10 + update-browserslist-db: 1.0.11(browserslist@4.21.5) + + /buffer-crc32@0.2.13: + resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} + + /buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + + /buffer-indexof-polyfill@1.0.2: + resolution: {integrity: sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==} + engines: {node: '>=0.10'} + + /buffer-shims@1.0.0: + resolution: {integrity: sha512-Zy8ZXMyxIT6RMTeY7OP/bDndfj6bwCan7SS98CEndS6deHwWPpseeHlwarNcBim+etXnF9HBc1non5JgDaJU1g==} + + /buffer@4.9.2: + resolution: {integrity: sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + isarray: 1.0.0 + + /buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + /buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + /buffers@0.1.1: + resolution: {integrity: sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==} + engines: {node: '>=0.2.0'} + + /builtin-modules@3.2.0: + resolution: {integrity: sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==} + engines: {node: '>=6'} + + /busboy@1.6.0: + resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} + engines: {node: '>=10.16.0'} + dependencies: + streamsearch: 1.1.0 + + /bytes@3.1.2: + resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} + engines: {node: '>= 0.8'} + + /cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + dev: true + + /call-bind@1.0.2: + resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} + dependencies: + function-bind: 1.1.1 + get-intrinsic: 1.2.0 + + /camelcase@2.1.1: + resolution: {integrity: sha512-DLIsRzJVBQu72meAKPkWQOLcujdXT32hwdfnkI1frSiSRMK1MofjKHf+MEx0SB6fjEFXL8fBDv1dKymBlOp4Qw==} + engines: {node: '>=0.10.0'} + + /camelcase@7.0.1: + resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==} + engines: {node: '>=14.16'} + dev: true + + /caniuse-lite@1.0.30001481: + resolution: {integrity: sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==} + + /case@1.6.3: + resolution: {integrity: sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ==} + engines: {node: '>= 0.8.0'} + + /cdk-assets@2.72.1: + resolution: {integrity: sha512-qxKgIBAdJhBJV23WAGLcQ4x89k/zmYhWeQeZW3TEbv//TZFIRWlgpkz6XnTzNIuluWghxMOvHym/LoRMpSaJcg==} + engines: {node: '>= 14.15.0'} + hasBin: true + dependencies: + '@aws-cdk/cloud-assembly-schema': 2.72.1 + '@aws-cdk/cx-api': 2.72.1(@aws-cdk/cloud-assembly-schema@2.72.1) + archiver: 5.3.1 + aws-sdk: 2.1365.0 + glob: 7.2.3 + mime: 2.6.0 + yargs: 16.2.0 + + /chai@4.3.7: + resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==} + engines: {node: '>=4'} + dependencies: + assertion-error: 1.1.0 + check-error: 1.0.2 + deep-eql: 4.1.3 + get-func-name: 2.0.0 + loupe: 2.3.6 + pathval: 1.1.1 + type-detect: 4.0.8 + dev: true + + /chainsaw@0.1.0: + resolution: {integrity: sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==} + dependencies: + traverse: 0.3.9 + + /chalk@2.4.2: + resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} + engines: {node: '>=4'} + dependencies: + ansi-styles: 3.2.1 + escape-string-regexp: 1.0.5 + supports-color: 5.5.0 + + /chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + + /chalk@5.2.0: + resolution: {integrity: sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + + /charenc@0.0.2: + resolution: {integrity: sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==} + + /check-error@1.0.2: + resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==} + dev: true + + /chokidar@3.5.3: + resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} + engines: {node: '>= 8.10.0'} + dependencies: + anymatch: 3.1.3 + braces: 3.0.2 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.2 + + /chownr@1.1.4: + resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + + /chownr@2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + + /ci-info@3.8.0: + resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==} + engines: {node: '>=8'} + + /cli-boxes@3.0.0: + resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==} + engines: {node: '>=10'} + + /cli-color@2.0.3: + resolution: {integrity: sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==} + engines: {node: '>=0.10'} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-iterator: 2.0.3 + memoizee: 0.4.15 + timers-ext: 0.1.7 + dev: true + + /cli-cursor@4.0.0: + resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + restore-cursor: 4.0.0 + + /cli-spinners@2.8.0: + resolution: {integrity: sha512-/eG5sJcvEIwxcdYM86k5tPwn0MUzkX5YY3eImTGpJOZgVe4SdTMY14vQpcxgBzJ0wXwAYrS8E+c3uHeK4JNyzQ==} + engines: {node: '>=6'} + + /cli-truncate@3.1.0: + resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + slice-ansi: 5.0.0 + string-width: 5.1.2 + + /cliui@3.2.0: + resolution: {integrity: sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==} + dependencies: + string-width: 1.0.2 + strip-ansi: 3.0.1 + wrap-ansi: 2.1.0 + + /cliui@7.0.4: + resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + + /cliui@8.0.1: + resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} + engines: {node: '>=12'} + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + + /clone@1.0.4: + resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} + engines: {node: '>=0.8'} + + /cmake-js@6.3.2: + resolution: {integrity: sha512-7MfiQ/ijzeE2kO+WFB9bv4QP5Dn2yVaAP2acFJr4NIFy2hT4w6O4EpOTLNcohR5IPX7M4wNf/5taIqMj7UA9ug==} + engines: {node: '>= 10.0.0'} + hasBin: true + dependencies: + axios: 0.21.4(debug@4.3.4) + bluebird: 3.7.2 + debug: 4.3.4 + fs-extra: 5.0.0 + is-iojs: 1.1.0 + lodash: 4.17.21 + memory-stream: 0.0.3 + npmlog: 1.2.1 + rc: 1.2.8 + semver: 5.7.1 + splitargs: 0.0.7 + tar: 4.4.19 + unzipper: 0.8.14 + url-join: 0.0.1 + which: 1.3.1 + yargs: 3.32.0 + transitivePeerDependencies: + - supports-color + + /code-excerpt@4.0.0: + resolution: {integrity: sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + convert-to-spaces: 2.0.1 + + /code-point-at@1.1.0: + resolution: {integrity: sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==} + engines: {node: '>=0.10.0'} + + /color-convert@1.9.3: + resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} + dependencies: + color-name: 1.1.3 + + /color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + dependencies: + color-name: 1.1.4 + + /color-name@1.1.3: + resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} + + /color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + /colorette@2.0.20: + resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} + + /commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + dev: true + + /commist@1.1.0: + resolution: {integrity: sha512-rraC8NXWOEjhADbZe9QBNzLAN5Q3fsTPQtBV+fEVj6xKIgDgNiEVE6ZNfHpZOqfQ21YUzfVNUXLOEZquYvQPPg==} + dependencies: + leven: 2.1.0 + minimist: 1.2.8 + + /compress-commons@4.1.1: + resolution: {integrity: sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==} + engines: {node: '>= 10'} + dependencies: + buffer-crc32: 0.2.13 + crc32-stream: 4.0.2 + normalize-path: 3.0.0 + readable-stream: 3.6.2 + + /concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + + /concat-stream@2.0.0: + resolution: {integrity: sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==} + engines: {'0': node >= 6.0} + dependencies: + buffer-from: 1.1.2 + inherits: 2.0.4 + readable-stream: 3.6.2 + typedarray: 0.0.6 + + /conf@10.2.0: + resolution: {integrity: sha512-8fLl9F04EJqjSqH+QjITQfJF8BrOVaYr1jewVgSRAEWePfxT0sku4w2hrGQ60BC/TNLGQ2pgxNlTbWQmMPFvXg==} + engines: {node: '>=12'} + dependencies: + ajv: 8.12.0 + ajv-formats: 2.1.1(ajv@8.12.0) + atomically: 1.7.0 + debounce-fn: 4.0.0 + dot-prop: 6.0.1 + env-paths: 2.2.1 + json-schema-typed: 7.0.3 + onetime: 5.1.2 + pkg-up: 3.1.0 + semver: 7.5.0 + + /constructs@10.1.156: + resolution: {integrity: sha512-BTZ3Kyt++/YFlph/ioqbDhzSKVMqHRHvc99FxU4b705ZP6s2IkDxMLCMinC70USMTJWFbO1p02Egux7sk4q07A==} + engines: {node: '>= 14.17.0'} + + /content-disposition@0.5.4: + resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==} + engines: {node: '>= 0.6'} + dependencies: + safe-buffer: 5.2.1 + + /content-type@1.0.5: + resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} + engines: {node: '>= 0.6'} + + /convert-source-map@1.9.0: + resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} + + /convert-to-spaces@2.0.1: + resolution: {integrity: sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + /cookie-signature@1.0.6: + resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} + + /cookie@0.5.0: + resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} + engines: {node: '>= 0.6'} + + /core-util-is@1.0.3: + resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + + /crc-32@1.2.2: + resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} + engines: {node: '>=0.8'} + hasBin: true + + /crc32-stream@4.0.2: + resolution: {integrity: sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==} + engines: {node: '>= 10'} + dependencies: + crc-32: 1.2.2 + readable-stream: 3.6.2 + + /cross-spawn@7.0.3: + resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + engines: {node: '>= 8'} + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + /crypt@0.0.2: + resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==} + + /crypto-js@4.0.0: + resolution: {integrity: sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==} + + /crypto-js@4.1.1: + resolution: {integrity: sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==} + + /css-what@5.1.0: + resolution: {integrity: sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==} + engines: {node: '>= 6'} + + /cssesc@3.0.0: + resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} + engines: {node: '>=4'} + hasBin: true + + /csstype@3.1.2: + resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} + + /d@1.0.1: + resolution: {integrity: sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==} + dependencies: + es5-ext: 0.10.62 + type: 1.2.0 + dev: true + + /debounce-fn@4.0.0: + resolution: {integrity: sha512-8pYCQiL9Xdcg0UPSD3d+0KMlOjp+KGU5EPwYddgzQ7DATsg4fuUDjQtsYLmWjnk2obnNHgV3vE2Y4jejSOJVBQ==} + engines: {node: '>=10'} + dependencies: + mimic-fn: 3.1.0 + + /debug@2.6.9: + resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.0.0 + + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + + /decamelize@1.2.0: + resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==} + engines: {node: '>=0.10.0'} + + /deep-eql@4.1.3: + resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} + engines: {node: '>=6'} + dependencies: + type-detect: 4.0.8 + dev: true + + /deep-extend@0.6.0: + resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} + engines: {node: '>=4.0.0'} + + /deep-object-diff@1.1.9: + resolution: {integrity: sha512-Rn+RuwkmkDwCi2/oXOFS9Gsr5lJZu/yTGpK7wAaAIE75CC+LCGEZHpY6VQJa/RoJcrmaA/docWJZvYohlNkWPA==} + + /deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} + engines: {node: '>=0.10.0'} + + /defaults@1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} + dependencies: + clone: 1.0.4 + + /delegates@1.0.0: + resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} + + /dendriform-immer-patch-optimiser@2.1.3(immer@9.0.21): + resolution: {integrity: sha512-QG2IegUCdlhycVwsBOJ7SNd18PgzyWPxBivTzuF0E1KFxaU47fHy/frud74A9E66a4WXyFFp9FLLC2XQDkVj7g==} + engines: {node: '>=10'} + peerDependencies: + immer: '9' + dependencies: + immer: 9.0.21 + + /depd@2.0.0: + resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} + engines: {node: '>= 0.8'} + + /deprecation@2.3.1: + resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} + dev: false + + /destroy@1.2.0: + resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} + engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + + /diff@5.1.0: + resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} + engines: {node: '>=0.3.1'} + + /difflib@0.2.4: + resolution: {integrity: sha512-9YVwmMb0wQHQNr5J9m6BSj6fk4pfGITGQOOs+D9Fl+INODWFOfvhIU1hNv6GgR1RBoC/9NJcwu77zShxV0kT7w==} + dependencies: + heap: 0.2.7 + dev: true + + /dot-prop@6.0.1: + resolution: {integrity: sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==} + engines: {node: '>=10'} + dependencies: + is-obj: 2.0.0 + + /dotenv@16.0.3: + resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + engines: {node: '>=12'} + + /dreamopt@0.8.0: + resolution: {integrity: sha512-vyJTp8+mC+G+5dfgsY+r3ckxlz+QMX40VjPQsZc5gxVAxLmi64TBoVkP54A/pRAXMXsbu2GMMBrZPxNv23waMg==} + engines: {node: '>=0.4.0'} + dependencies: + wordwrap: 1.0.0 + dev: true + + /drizzle-kit@0.17.6-76e73f3: + resolution: {integrity: sha512-HmsTYbm4Y3gfv2jlzRQ04mbepnP9eKHWWFPnzEInrVEJJ85k0hxldGpbql03flZPII4W0z5FwuGUC9ROOLhVNw==} + hasBin: true + dependencies: + camelcase: 7.0.1 + chalk: 5.2.0 + commander: 9.5.0 + esbuild: 0.15.18 + esbuild-register: 3.4.2(esbuild@0.15.18) + glob: 8.1.0 + hanji: 0.0.5 + json-diff: 0.9.0 + minimatch: 7.4.6 + zod: 3.21.4 + transitivePeerDependencies: + - supports-color + dev: true + + /drizzle-orm@0.25.3(@aws-sdk/client-rds-data@3.319.0)(@planetscale/database@1.7.0)(kysely@0.23.5): + resolution: {integrity: sha512-0LX4Tjh3+3zm8E9T/h+ayj/3KEzNPItpONHfKnKOzBCjW9C1X0T7uUuRdPE+ssXIVLNuk6rvKCKTL3o9caxnKg==} + peerDependencies: + '@aws-sdk/client-rds-data': '>=3' + '@cloudflare/workers-types': '>=3' + '@libsql/client': '*' + '@neondatabase/serverless': '>=0.1' + '@planetscale/database': '>=1' + '@types/better-sqlite3': '*' + '@types/pg': '*' + '@types/sql.js': '*' + better-sqlite3: '>=7' + bun-types: '*' + knex: '*' + kysely: '*' + mysql2: '>=2' + pg: '>=8' + postgres: '>=3' + sql.js: '>=1' + sqlite3: '>=5' + peerDependenciesMeta: + '@aws-sdk/client-rds-data': + optional: true + '@cloudflare/workers-types': + optional: true + '@libsql/client': + optional: true + '@neondatabase/serverless': + optional: true + '@planetscale/database': + optional: true + '@types/better-sqlite3': + optional: true + '@types/pg': + optional: true + '@types/sql.js': + optional: true + better-sqlite3: + optional: true + bun-types: + optional: true + knex: + optional: true + kysely: + optional: true + mysql2: + optional: true + pg: + optional: true + postgres: + optional: true + sql.js: + optional: true + sqlite3: + optional: true + dependencies: + '@aws-sdk/client-rds-data': 3.319.0 + '@planetscale/database': 1.7.0 + kysely: 0.23.5 + dev: false + + /drizzle-zod@0.4.1(drizzle-orm@0.25.3)(zod@3.21.4): + resolution: {integrity: sha512-0SoW2YwQwh+9QUNezzPAg179qO6OinbmLJFLjCjxfBpNDD39YH2hlSRK/rrkzskyBSORKraSrim/abynQ4k79w==} + peerDependencies: + drizzle-orm: '>=0.23.13' + zod: '*' + dependencies: + drizzle-orm: 0.25.3(@aws-sdk/client-rds-data@3.319.0)(@planetscale/database@1.7.0)(kysely@0.23.5) + zod: 3.21.4 + dev: false + + /dset@3.1.2: + resolution: {integrity: sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==} + engines: {node: '>=4'} + + /duplexer2@0.1.4: + resolution: {integrity: sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==} + dependencies: + readable-stream: 2.3.8 + + /duplexify@3.7.1: + resolution: {integrity: sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==} + dependencies: + end-of-stream: 1.4.4 + inherits: 2.0.4 + readable-stream: 2.3.8 + stream-shift: 1.0.1 + + /duplexify@4.1.2: + resolution: {integrity: sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==} + dependencies: + end-of-stream: 1.4.4 + inherits: 2.0.4 + readable-stream: 3.6.2 + stream-shift: 1.0.1 + + /eastasianwidth@0.2.0: + resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + + /ecdsa-sig-formatter@1.0.11: + resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} + dependencies: + safe-buffer: 5.2.1 + + /ee-first@1.1.1: + resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} + + /electron-to-chromium@1.4.369: + resolution: {integrity: sha512-LfxbHXdA/S+qyoTEA4EbhxGjrxx7WK2h6yb5K2v0UCOufUKX+VZaHbl3svlzZfv9sGseym/g3Ne4DpsgRULmqg==} + + /emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + + /emoji-regex@9.2.2: + resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + + /encodeurl@1.0.2: + resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} + engines: {node: '>= 0.8'} + + /end-of-stream@1.4.4: + resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} + dependencies: + once: 1.4.0 + + /env-paths@2.2.1: + resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} + engines: {node: '>=6'} + + /es5-ext@0.10.62: + resolution: {integrity: sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==} + engines: {node: '>=0.10'} + requiresBuild: true + dependencies: + es6-iterator: 2.0.3 + es6-symbol: 3.1.3 + next-tick: 1.1.0 + dev: true + + /es6-iterator@2.0.3: + resolution: {integrity: sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-symbol: 3.1.3 + dev: true + + /es6-symbol@3.1.3: + resolution: {integrity: sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==} + dependencies: + d: 1.0.1 + ext: 1.7.0 + dev: true + + /es6-weak-map@2.0.3: + resolution: {integrity: sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-iterator: 2.0.3 + es6-symbol: 3.1.3 + dev: true + + /esbuild-android-64@0.14.54: + resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-android-64@0.15.18: + resolution: {integrity: sha512-wnpt3OXRhcjfIDSZu9bnzT4/TNTDsOUvip0foZOUBG7QbSt//w3QV4FInVJxNhKc/ErhUxc5z4QjHtMi7/TbgA==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-android-arm64@0.14.54: + resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-android-arm64@0.15.18: + resolution: {integrity: sha512-G4xu89B8FCzav9XU8EjsXacCKSG2FT7wW9J6hOc18soEHJdtWu03L3TQDGf0geNxfLTtxENKBzMSq9LlbjS8OQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-darwin-64@0.14.54: + resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /esbuild-darwin-64@0.15.18: + resolution: {integrity: sha512-2WAvs95uPnVJPuYKP0Eqx+Dl/jaYseZEUUT1sjg97TJa4oBtbAKnPnl3b5M9l51/nbx7+QAEtuummJZW0sBEmg==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /esbuild-darwin-arm64@0.14.54: + resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /esbuild-darwin-arm64@0.15.18: + resolution: {integrity: sha512-tKPSxcTJ5OmNb1btVikATJ8NftlyNlc8BVNtyT/UAr62JFOhwHlnoPrhYWz09akBLHI9nElFVfWSTSRsrZiDUA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /esbuild-freebsd-64@0.14.54: + resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-freebsd-64@0.15.18: + resolution: {integrity: sha512-TT3uBUxkteAjR1QbsmvSsjpKjOX6UkCstr8nMr+q7zi3NuZ1oIpa8U41Y8I8dJH2fJgdC3Dj3CXO5biLQpfdZA==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-freebsd-arm64@0.14.54: + resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-freebsd-arm64@0.15.18: + resolution: {integrity: sha512-R/oVr+X3Tkh+S0+tL41wRMbdWtpWB8hEAMsOXDumSSa6qJR89U0S/PpLXrGF7Wk/JykfpWNokERUpCeHDl47wA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-32@0.14.54: + resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-32@0.15.18: + resolution: {integrity: sha512-lphF3HiCSYtaa9p1DtXndiQEeQDKPl9eN/XNoBf2amEghugNuqXNZA/ZovthNE2aa4EN43WroO0B85xVSjYkbg==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-64@0.14.54: + resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-64@0.15.18: + resolution: {integrity: sha512-hNSeP97IviD7oxLKFuii5sDPJ+QHeiFTFLoLm7NZQligur8poNOWGIgpQ7Qf8Balb69hptMZzyOBIPtY09GZYw==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-arm64@0.14.54: + resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-arm64@0.15.18: + resolution: {integrity: sha512-54qr8kg/6ilcxd+0V3h9rjT4qmjc0CccMVWrjOEM/pEcUzt8X62HfBSeZfT2ECpM7104mk4yfQXkosY8Quptug==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-arm@0.14.54: + resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-arm@0.15.18: + resolution: {integrity: sha512-UH779gstRblS4aoS2qpMl3wjg7U0j+ygu3GjIeTonCcN79ZvpPee12Qun3vcdxX+37O5LFxz39XeW2I9bybMVA==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-mips64le@0.14.54: + resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-mips64le@0.15.18: + resolution: {integrity: sha512-Mk6Ppwzzz3YbMl/ZZL2P0q1tnYqh/trYZ1VfNP47C31yT0K8t9s7Z077QrDA/guU60tGNp2GOwCQnp+DYv7bxQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-ppc64le@0.14.54: + resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-ppc64le@0.15.18: + resolution: {integrity: sha512-b0XkN4pL9WUulPTa/VKHx2wLCgvIAbgwABGnKMY19WhKZPT+8BxhZdqz6EgkqCLld7X5qiCY2F/bfpUUlnFZ9w==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-riscv64@0.14.54: + resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-riscv64@0.15.18: + resolution: {integrity: sha512-ba2COaoF5wL6VLZWn04k+ACZjZ6NYniMSQStodFKH/Pu6RxzQqzsmjR1t9QC89VYJxBeyVPTaHuBMCejl3O/xg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-s390x@0.14.54: + resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-s390x@0.15.18: + resolution: {integrity: sha512-VbpGuXEl5FCs1wDVp93O8UIzl3ZrglgnSQ+Hu79g7hZu6te6/YHgVJxCM2SqfIila0J3k0csfnf8VD2W7u2kzQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-netbsd-64@0.14.54: + resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-netbsd-64@0.15.18: + resolution: {integrity: sha512-98ukeCdvdX7wr1vUYQzKo4kQ0N2p27H7I11maINv73fVEXt2kyh4K4m9f35U1K43Xc2QGXlzAw0K9yoU7JUjOg==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-openbsd-64@0.14.54: + resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-openbsd-64@0.15.18: + resolution: {integrity: sha512-yK5NCcH31Uae076AyQAXeJzt/vxIo9+omZRKj1pauhk3ITuADzuOx5N2fdHrAKPxN+zH3w96uFKlY7yIn490xQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-register@3.4.2(esbuild@0.15.18): + resolution: {integrity: sha512-kG/XyTDyz6+YDuyfB9ZoSIOOmgyFCH+xPRtsCa8W85HLRV5Csp+o3jWVbOSHgSLfyLc5DmP+KFDNwty4mEjC+Q==} + peerDependencies: + esbuild: '>=0.12 <1' + dependencies: + debug: 4.3.4 + esbuild: 0.15.18 + transitivePeerDependencies: + - supports-color + dev: true + + /esbuild-sunos-64@0.14.54: + resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /esbuild-sunos-64@0.15.18: + resolution: {integrity: sha512-On22LLFlBeLNj/YF3FT+cXcyKPEI263nflYlAhz5crxtp3yRG1Ugfr7ITyxmCmjm4vbN/dGrb/B7w7U8yJR9yw==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-32@0.14.54: + resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-32@0.15.18: + resolution: {integrity: sha512-o+eyLu2MjVny/nt+E0uPnBxYuJHBvho8vWsC2lV61A7wwTWC3jkN2w36jtA+yv1UgYkHRihPuQsL23hsCYGcOQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-64@0.14.54: + resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-64@0.15.18: + resolution: {integrity: sha512-qinug1iTTaIIrCorAUjR0fcBk24fjzEedFYhhispP8Oc7SFvs+XeW3YpAKiKp8dRpizl4YYAhxMjlftAMJiaUw==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-arm64@0.14.54: + resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-arm64@0.15.18: + resolution: {integrity: sha512-q9bsYzegpZcLziq0zgUi5KqGVtfhjxGbnksaBFYmWLxeV/S1fK4OLdq2DFYnXcLMjlZw2L0jLsk1eGoB522WXQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild@0.14.54: + resolution: {integrity: sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/linux-loong64': 0.14.54 + esbuild-android-64: 0.14.54 + esbuild-android-arm64: 0.14.54 + esbuild-darwin-64: 0.14.54 + esbuild-darwin-arm64: 0.14.54 + esbuild-freebsd-64: 0.14.54 + esbuild-freebsd-arm64: 0.14.54 + esbuild-linux-32: 0.14.54 + esbuild-linux-64: 0.14.54 + esbuild-linux-arm: 0.14.54 + esbuild-linux-arm64: 0.14.54 + esbuild-linux-mips64le: 0.14.54 + esbuild-linux-ppc64le: 0.14.54 + esbuild-linux-riscv64: 0.14.54 + esbuild-linux-s390x: 0.14.54 + esbuild-netbsd-64: 0.14.54 + esbuild-openbsd-64: 0.14.54 + esbuild-sunos-64: 0.14.54 + esbuild-windows-32: 0.14.54 + esbuild-windows-64: 0.14.54 + esbuild-windows-arm64: 0.14.54 + dev: true + + /esbuild@0.15.18: + resolution: {integrity: sha512-x/R72SmW3sSFRm5zrrIjAhCeQSAWoni3CmHEqfQrZIQTM3lVCdehdwuIqaOtfC2slvpdlLa62GYoN8SxT23m6Q==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.15.18 + '@esbuild/linux-loong64': 0.15.18 + esbuild-android-64: 0.15.18 + esbuild-android-arm64: 0.15.18 + esbuild-darwin-64: 0.15.18 + esbuild-darwin-arm64: 0.15.18 + esbuild-freebsd-64: 0.15.18 + esbuild-freebsd-arm64: 0.15.18 + esbuild-linux-32: 0.15.18 + esbuild-linux-64: 0.15.18 + esbuild-linux-arm: 0.15.18 + esbuild-linux-arm64: 0.15.18 + esbuild-linux-mips64le: 0.15.18 + esbuild-linux-ppc64le: 0.15.18 + esbuild-linux-riscv64: 0.15.18 + esbuild-linux-s390x: 0.15.18 + esbuild-netbsd-64: 0.15.18 + esbuild-openbsd-64: 0.15.18 + esbuild-sunos-64: 0.15.18 + esbuild-windows-32: 0.15.18 + esbuild-windows-64: 0.15.18 + esbuild-windows-arm64: 0.15.18 + dev: true + + /esbuild@0.16.13: + resolution: {integrity: sha512-oYwFdSEIoKM1oYzyem1osgKJAvg5447XF+05ava21fOtilyb2HeQQh26/74K4WeAk5dZmj/Mx10zUqUnI14jhA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.16.13 + '@esbuild/android-arm64': 0.16.13 + '@esbuild/android-x64': 0.16.13 + '@esbuild/darwin-arm64': 0.16.13 + '@esbuild/darwin-x64': 0.16.13 + '@esbuild/freebsd-arm64': 0.16.13 + '@esbuild/freebsd-x64': 0.16.13 + '@esbuild/linux-arm': 0.16.13 + '@esbuild/linux-arm64': 0.16.13 + '@esbuild/linux-ia32': 0.16.13 + '@esbuild/linux-loong64': 0.16.13 + '@esbuild/linux-mips64el': 0.16.13 + '@esbuild/linux-ppc64': 0.16.13 + '@esbuild/linux-riscv64': 0.16.13 + '@esbuild/linux-s390x': 0.16.13 + '@esbuild/linux-x64': 0.16.13 + '@esbuild/netbsd-x64': 0.16.13 + '@esbuild/openbsd-x64': 0.16.13 + '@esbuild/sunos-x64': 0.16.13 + '@esbuild/win32-arm64': 0.16.13 + '@esbuild/win32-ia32': 0.16.13 + '@esbuild/win32-x64': 0.16.13 + + /esbuild@0.17.18: + resolution: {integrity: sha512-z1lix43jBs6UKjcZVKOw2xx69ffE2aG0PygLL5qJ9OS/gy0Ewd1gW/PUQIOIQGXBHWNywSc0floSKoMFF8aK2w==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.17.18 + '@esbuild/android-arm64': 0.17.18 + '@esbuild/android-x64': 0.17.18 + '@esbuild/darwin-arm64': 0.17.18 + '@esbuild/darwin-x64': 0.17.18 + '@esbuild/freebsd-arm64': 0.17.18 + '@esbuild/freebsd-x64': 0.17.18 + '@esbuild/linux-arm': 0.17.18 + '@esbuild/linux-arm64': 0.17.18 + '@esbuild/linux-ia32': 0.17.18 + '@esbuild/linux-loong64': 0.17.18 + '@esbuild/linux-mips64el': 0.17.18 + '@esbuild/linux-ppc64': 0.17.18 + '@esbuild/linux-riscv64': 0.17.18 + '@esbuild/linux-s390x': 0.17.18 + '@esbuild/linux-x64': 0.17.18 + '@esbuild/netbsd-x64': 0.17.18 + '@esbuild/openbsd-x64': 0.17.18 + '@esbuild/sunos-x64': 0.17.18 + '@esbuild/win32-arm64': 0.17.18 + '@esbuild/win32-ia32': 0.17.18 + '@esbuild/win32-x64': 0.17.18 + + /esbuild@0.17.6: + resolution: {integrity: sha512-TKFRp9TxrJDdRWfSsSERKEovm6v30iHnrjlcGhLBOtReE28Yp1VSBRfO3GTaOFMoxsNerx4TjrhzSuma9ha83Q==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.17.6 + '@esbuild/android-arm64': 0.17.6 + '@esbuild/android-x64': 0.17.6 + '@esbuild/darwin-arm64': 0.17.6 + '@esbuild/darwin-x64': 0.17.6 + '@esbuild/freebsd-arm64': 0.17.6 + '@esbuild/freebsd-x64': 0.17.6 + '@esbuild/linux-arm': 0.17.6 + '@esbuild/linux-arm64': 0.17.6 + '@esbuild/linux-ia32': 0.17.6 + '@esbuild/linux-loong64': 0.17.6 + '@esbuild/linux-mips64el': 0.17.6 + '@esbuild/linux-ppc64': 0.17.6 + '@esbuild/linux-riscv64': 0.17.6 + '@esbuild/linux-s390x': 0.17.6 + '@esbuild/linux-x64': 0.17.6 + '@esbuild/netbsd-x64': 0.17.6 + '@esbuild/openbsd-x64': 0.17.6 + '@esbuild/sunos-x64': 0.17.6 + '@esbuild/win32-arm64': 0.17.6 + '@esbuild/win32-ia32': 0.17.6 + '@esbuild/win32-x64': 0.17.6 + dev: true + + /escalade@3.1.1: + resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} + engines: {node: '>=6'} + + /escape-html@1.0.3: + resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} + + /escape-string-regexp@1.0.5: + resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} + engines: {node: '>=0.8.0'} + + /escape-string-regexp@2.0.0: + resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} + engines: {node: '>=8'} + + /etag@1.8.1: + resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} + engines: {node: '>= 0.6'} + + /eval@0.1.6: + resolution: {integrity: sha512-o0XUw+5OGkXw4pJZzQoXUk+H87DHuC+7ZE//oSrRGtatTmr12oTnLfg6QOq9DyTt0c/p4TwzgmkKrBzWTSizyQ==} + engines: {node: '>= 0.8'} + dependencies: + require-like: 0.1.2 + dev: true + + /event-emitter@0.3.5: + resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + dev: true + + /events@1.1.1: + resolution: {integrity: sha512-kEcvvCBByWXGnZy6JUlgAp2gBIUjfCAV6P6TgT1/aaQKcmuAEC4OZTV1I4EWQLz2gxZw76atuVyvHhTxvi0Flw==} + engines: {node: '>=0.4.x'} + + /express@4.18.2: + resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==} + engines: {node: '>= 0.10.0'} + dependencies: + accepts: 1.3.8 + array-flatten: 1.1.1 + body-parser: 1.20.1 + content-disposition: 0.5.4 + content-type: 1.0.5 + cookie: 0.5.0 + cookie-signature: 1.0.6 + debug: 2.6.9 + depd: 2.0.0 + encodeurl: 1.0.2 + escape-html: 1.0.3 + etag: 1.8.1 + finalhandler: 1.2.0 + fresh: 0.5.2 + http-errors: 2.0.0 + merge-descriptors: 1.0.1 + methods: 1.1.2 + on-finished: 2.4.1 + parseurl: 1.3.3 + path-to-regexp: 0.1.7 + proxy-addr: 2.0.7 + qs: 6.11.0 + range-parser: 1.2.1 + safe-buffer: 5.2.1 + send: 0.18.0 + serve-static: 1.15.0 + setprototypeof: 1.2.0 + statuses: 2.0.1 + type-is: 1.6.18 + utils-merge: 1.0.1 + vary: 1.1.2 + transitivePeerDependencies: + - supports-color + + /ext@1.7.0: + resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==} + dependencies: + type: 2.7.2 + dev: true + + /fast-decode-uri-component@1.0.1: + resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==} + + /fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + /fast-jwt@1.7.2: + resolution: {integrity: sha512-OEInypGXJhtURzq9GbFM5KaALUu9+4IV3kJEbWPuqOBN5JBe7A51Tx0CaQYHGC9GNfZnr5npA0lCIMaWiZmz/A==} + engines: {node: '>=14 <20'} + dependencies: + asn1.js: 5.4.1 + ecdsa-sig-formatter: 1.0.11 + mnemonist: 0.39.5 + + /fast-jwt@2.2.1: + resolution: {integrity: sha512-r5zKugIE/4ZgGv98fE6wtIglkOwMVJOlYVa/nXyivAV56sLtAtH1eJX+WiZAwOgy387PJeZdBQsjfJhoPwOqvA==} + engines: {node: '>=14 <20'} + dependencies: + asn1.js: 5.4.1 + ecdsa-sig-formatter: 1.0.11 + mnemonist: 0.39.5 + dev: false + + /fast-querystring@1.1.1: + resolution: {integrity: sha512-qR2r+e3HvhEFmpdHMv//U8FnFlnYjaC6QKDuaXALDkw2kvHO8WDjxH+f/rHGR4Me4pnk8p9JAkRNTjYHAKRn2Q==} + dependencies: + fast-decode-uri-component: 1.0.1 + + /fast-url-parser@1.1.3: + resolution: {integrity: sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==} + dependencies: + punycode: 1.4.1 + + /fast-xml-parser@4.1.2: + resolution: {integrity: sha512-CDYeykkle1LiA/uqQyNwYpFbyF6Axec6YapmpUP+/RHWIoR1zKjocdvNaTsxCxZzQ6v9MLXaSYm9Qq0thv0DHg==} + hasBin: true + dependencies: + strnum: 1.0.5 + + /fill-range@7.0.1: + resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} + engines: {node: '>=8'} + dependencies: + to-regex-range: 5.0.1 + + /finalhandler@1.2.0: + resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==} + engines: {node: '>= 0.8'} + dependencies: + debug: 2.6.9 + encodeurl: 1.0.2 + escape-html: 1.0.3 + on-finished: 2.4.1 + parseurl: 1.3.3 + statuses: 2.0.1 + unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color + + /find-up@3.0.0: + resolution: {integrity: sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==} + engines: {node: '>=6'} + dependencies: + locate-path: 3.0.0 + + /find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + dev: true + + /follow-redirects@1.15.2(debug@4.3.4): + resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dependencies: + debug: 4.3.4 + + /for-each@0.3.3: + resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} + dependencies: + is-callable: 1.2.7 + + /forwarded@0.2.0: + resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} + engines: {node: '>= 0.6'} + + /fresh@0.5.2: + resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} + engines: {node: '>= 0.6'} + + /fs-constants@1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + + /fs-extra@5.0.0: + resolution: {integrity: sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + + /fs-extra@9.1.0: + resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} + engines: {node: '>=10'} + dependencies: + at-least-node: 1.0.0 + graceful-fs: 4.2.11 + jsonfile: 6.1.0 + universalify: 2.0.0 + + /fs-minipass@1.2.7: + resolution: {integrity: sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==} + dependencies: + minipass: 2.9.0 + + /fs-minipass@2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.3.6 + + /fs.realpath@1.0.0: + resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + + /fsevents@2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + optional: true + + /fstream@1.0.12: + resolution: {integrity: sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==} + engines: {node: '>=0.6'} + dependencies: + graceful-fs: 4.2.11 + inherits: 2.0.4 + mkdirp: 0.5.6 + rimraf: 2.7.1 + + /function-bind@1.1.1: + resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + + /gauge@1.2.7: + resolution: {integrity: sha512-fVbU2wRE91yDvKUnrIaQlHKAWKY5e08PmztCrwuH5YVQ+Z/p3d0ny2T48o6uvAAXHIUnfaQdHkmxYbQft1eHVA==} + dependencies: + ansi: 0.3.1 + has-unicode: 2.0.1 + lodash.pad: 4.5.1 + lodash.padend: 4.6.1 + lodash.padstart: 4.6.1 + + /gensync@1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + + /get-caller-file@2.0.5: + resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} + engines: {node: 6.* || 8.* || >= 10.*} + + /get-func-name@2.0.0: + resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} + dev: true + + /get-intrinsic@1.2.0: + resolution: {integrity: sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==} + dependencies: + function-bind: 1.1.1 + has: 1.0.3 + has-symbols: 1.0.3 + + /get-port@6.1.2: + resolution: {integrity: sha512-BrGGraKm2uPqurfGVj/z97/zv8dPleC6x9JBNRTrDNtCkkRF4rPwrQXFgL7+I+q8QSdU4ntLQX2D7KIxSy8nGw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + /get-tsconfig@4.5.0: + resolution: {integrity: sha512-MjhiaIWCJ1sAU4pIQ5i5OfOuHHxVo1oYeNsWTON7jxYkod8pHocXeh+SSbmu5OZZZK73B6cbJ2XADzXehLyovQ==} + dev: false + + /glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + dependencies: + is-glob: 4.0.3 + + /glob@7.2.3: + resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 + + /glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + + /globals@11.12.0: + resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} + engines: {node: '>=4'} + + /gopd@1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + dependencies: + get-intrinsic: 1.2.0 + + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + /graphql-yoga@3.9.1(graphql@16.6.0): + resolution: {integrity: sha512-BB6EkN64VBTXWmf9Kym2OsVZFzBC0mAsQNo9eNB5xIr3t+x7qepQ34xW5A353NWol3Js3xpzxwIKFVF6l9VsPg==} + peerDependencies: + graphql: ^15.2.0 || ^16.0.0 + dependencies: + '@envelop/core': 3.0.6 + '@envelop/validation-cache': 5.1.3(@envelop/core@3.0.6)(graphql@16.6.0) + '@graphql-tools/executor': 0.0.18(graphql@16.6.0) + '@graphql-tools/schema': 9.0.19(graphql@16.6.0) + '@graphql-tools/utils': 9.2.1(graphql@16.6.0) + '@graphql-yoga/logger': 0.0.1 + '@graphql-yoga/subscription': 3.1.0 + '@whatwg-node/fetch': 0.8.8 + '@whatwg-node/server': 0.7.5 + dset: 3.1.2 + graphql: 16.6.0 + lru-cache: 7.18.3 + tslib: 2.5.0 + + /graphql@16.6.0: + resolution: {integrity: sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==} + engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} + + /hanji@0.0.5: + resolution: {integrity: sha512-Abxw1Lq+TnYiL4BueXqMau222fPSPMFtya8HdpWsz/xVAhifXou71mPh/kY2+08RgFcVccjG3uZHs6K5HAe3zw==} + dependencies: + lodash.throttle: 4.1.1 + sisteransi: 1.0.5 + dev: true + + /has-flag@3.0.0: + resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} + engines: {node: '>=4'} + + /has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + /has-symbols@1.0.3: + resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} + engines: {node: '>= 0.4'} + + /has-tostringtag@1.0.0: + resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.3 + + /has-unicode@2.0.1: + resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==} + + /has@1.0.3: + resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} + engines: {node: '>= 0.4.0'} + dependencies: + function-bind: 1.1.1 + + /hash-it@6.0.0: + resolution: {integrity: sha512-KHzmSFx1KwyMPw0kXeeUD752q/Kfbzhy6dAZrjXV9kAIXGqzGvv8vhkUqj+2MGZldTo0IBpw6v7iWE7uxsvH0w==} + + /heap@0.2.7: + resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} + dev: true + + /help-me@3.0.0: + resolution: {integrity: sha512-hx73jClhyk910sidBB7ERlnhMlFsJJIBqSVMFDwPN8o2v9nmp5KgLq1Xz1Bf1fCMMZ6mPrX159iG0VLy/fPMtQ==} + dependencies: + glob: 7.2.3 + readable-stream: 3.6.2 + + /html-entities@2.3.3: + resolution: {integrity: sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==} + dev: true + + /http-errors@2.0.0: + resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} + engines: {node: '>= 0.8'} + dependencies: + depd: 2.0.0 + inherits: 2.0.4 + setprototypeof: 1.2.0 + statuses: 2.0.1 + toidentifier: 1.0.1 + + /iconv-lite@0.4.24: + resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} + engines: {node: '>=0.10.0'} + dependencies: + safer-buffer: 2.1.2 + + /ieee754@1.1.13: + resolution: {integrity: sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==} + + /ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + + /ignore@5.2.4: + resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} + engines: {node: '>= 4'} + + /immer@9.0.21: + resolution: {integrity: sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==} + + /indent-string@5.0.0: + resolution: {integrity: sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==} + engines: {node: '>=12'} + + /inflight@1.0.6: + resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + + /inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + + /ini@1.3.8: + resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} + + /ink-spinner@5.0.0(ink@4.2.0)(react@18.2.0): + resolution: {integrity: sha512-EYEasbEjkqLGyPOUc8hBJZNuC5GvXGMLu0w5gdTNskPc7Izc5vO3tdQEYnzvshucyGCBXc86ig0ujXPMWaQCdA==} + engines: {node: '>=14.16'} + peerDependencies: + ink: '>=4.0.0' + react: '>=18.0.0' + dependencies: + cli-spinners: 2.8.0 + ink: 4.2.0(react@18.2.0) + react: 18.2.0 + + /ink@4.2.0(react@18.2.0): + resolution: {integrity: sha512-q7SeFAEFMyKxTblyVI+CsxHzfiMMP9JUDG0cRmOKEAmJiYrtrDW1YYTv129RXqfn7fMKcVc4h/LbAJvqvZIuEQ==} + engines: {node: '>=14.16'} + peerDependencies: + '@types/react': '>=18.0.0' + react: '>=18.0.0' + react-devtools-core: ^4.19.1 + peerDependenciesMeta: + '@types/react': + optional: true + react-devtools-core: + optional: true + dependencies: + ansi-escapes: 6.2.0 + auto-bind: 5.0.1 + chalk: 5.2.0 + cli-boxes: 3.0.0 + cli-cursor: 4.0.0 + cli-truncate: 3.1.0 + code-excerpt: 4.0.0 + indent-string: 5.0.0 + is-ci: 3.0.1 + is-lower-case: 2.0.2 + is-upper-case: 2.0.2 + lodash: 4.17.21 + patch-console: 2.0.0 + react: 18.2.0 + react-reconciler: 0.29.0(react@18.2.0) + scheduler: 0.23.0 + signal-exit: 3.0.7 + slice-ansi: 6.0.0 + stack-utils: 2.0.6 + string-width: 5.1.2 + type-fest: 0.12.0 + widest-line: 4.0.1 + wrap-ansi: 8.1.0 + ws: 8.13.0 + yoga-wasm-web: 0.3.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /invert-kv@1.0.0: + resolution: {integrity: sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==} + engines: {node: '>=0.10.0'} + + /ipaddr.js@1.9.1: + resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} + engines: {node: '>= 0.10'} + + /is-arguments@1.1.1: + resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + has-tostringtag: 1.0.0 + + /is-binary-path@2.1.0: + resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} + engines: {node: '>=8'} + dependencies: + binary-extensions: 2.2.0 + + /is-buffer@1.1.6: + resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} + + /is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + + /is-ci@3.0.1: + resolution: {integrity: sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==} + hasBin: true + dependencies: + ci-info: 3.8.0 + + /is-core-module@2.12.0: + resolution: {integrity: sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==} + dependencies: + has: 1.0.3 + dev: true + + /is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + /is-fullwidth-code-point@1.0.0: + resolution: {integrity: sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==} + engines: {node: '>=0.10.0'} + dependencies: + number-is-nan: 1.0.1 + + /is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + + /is-fullwidth-code-point@4.0.0: + resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==} + engines: {node: '>=12'} + + /is-generator-function@1.0.10: + resolution: {integrity: sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.0 + + /is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + dependencies: + is-extglob: 2.1.1 + + /is-interactive@2.0.0: + resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==} + engines: {node: '>=12'} + + /is-iojs@1.1.0: + resolution: {integrity: sha512-tLn1j3wYSL6DkvEI+V/j0pKohpa5jk+ER74v6S4SgCXnjS0WA+DoZbwZBrrhgwksMvtuwndyGeG5F8YMsoBzSA==} + + /is-lower-case@2.0.2: + resolution: {integrity: sha512-bVcMJy4X5Og6VZfdOZstSexlEy20Sr0k/p/b2IlQJlfdKAQuMpiv5w2Ccxb8sKdRUNAG1PnHVHjFSdRDVS6NlQ==} + dependencies: + tslib: 2.5.0 + + /is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + + /is-obj@2.0.0: + resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==} + engines: {node: '>=8'} + + /is-plain-object@5.0.0: + resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} + engines: {node: '>=0.10.0'} + dev: false + + /is-promise@2.2.2: + resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==} + dev: true + + /is-typed-array@1.1.10: + resolution: {integrity: sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + + /is-unicode-supported@1.3.0: + resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==} + engines: {node: '>=12'} + + /is-upper-case@2.0.2: + resolution: {integrity: sha512-44pxmxAvnnAOwBg4tHPnkfvgjPwbc5QIsSstNU+YcJ1ovxVzCWpSGosPJOZh/a1tdl81fbgnLc9LLv+x2ywbPQ==} + dependencies: + tslib: 2.5.0 + + /is-what@4.1.8: + resolution: {integrity: sha512-yq8gMao5upkPoGEU9LsB2P+K3Kt8Q3fQFCGyNCWOAnJAMzEXVV9drYb0TXr42TTliLLhKIBvulgAXgtLLnwzGA==} + engines: {node: '>=12.13'} + dev: true + + /isarray@0.0.1: + resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} + + /isarray@1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + + /isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + /isomorphic-ws@4.0.1(ws@8.13.0): + resolution: {integrity: sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==} + peerDependencies: + ws: '*' + dependencies: + ws: 8.13.0 + + /javascript-stringify@2.1.0: + resolution: {integrity: sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg==} + dev: true + + /jmespath@0.16.0: + resolution: {integrity: sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==} + engines: {node: '>= 0.6.0'} + + /jose@4.14.2: + resolution: {integrity: sha512-Fcbi5lskAiSvs8qhdQBusANZWwyATdp7IxgHJTXiaU74sbVjX9uAw+myDPvI8pNo2wXKHECXCR63hqhRkN/SSQ==} + + /js-sdsl@4.3.0: + resolution: {integrity: sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==} + + /js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + /jsesc@2.5.2: + resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} + engines: {node: '>=4'} + hasBin: true + + /json-diff@0.9.0: + resolution: {integrity: sha512-cVnggDrVkAAA3OvFfHpFEhOnmcsUpleEKq4d4O8sQWWSH40MBrWstKigVB1kGrgLWzuom+7rRdaCsnBD6VyObQ==} + hasBin: true + dependencies: + cli-color: 2.0.3 + difflib: 0.2.4 + dreamopt: 0.8.0 + dev: true + + /json-schema-traverse@1.0.0: + resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} + + /json-schema-typed@7.0.3: + resolution: {integrity: sha512-7DE8mpG+/fVw+dTpjbxnx47TaMnDfOI1jwft9g1VybltZCduyRQPJPvc+zzKY9WPHxhPWczyFuYa6I8Mw4iU5A==} + + /json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + + /jsonc-parser@3.2.0: + resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} + dev: true + + /jsonfile@4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + optionalDependencies: + graceful-fs: 4.2.11 + + /jsonfile@6.1.0: + resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} + dependencies: + universalify: 2.0.0 + optionalDependencies: + graceful-fs: 4.2.11 + + /jsonschema@1.4.1: + resolution: {integrity: sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ==} + + /jszip@2.7.0: + resolution: {integrity: sha512-JIsRKRVC3gTRo2vM4Wy9WBC3TRcfnIZU8k65Phi3izkvPH975FowRYtKGT6PxevA0XnJ/yO8b0QwV0ydVyQwfw==} + dependencies: + pako: 1.0.11 + + /kysely-codegen@0.9.0(kysely@0.23.5): + resolution: {integrity: sha512-VCkrEY0WPwObvT4LGJkwLn29DXmvwG2oAv94qa+yAXDPAWtYTfO8NQSqyeEiNHEWmuKI+Sl+ANSn63by2Xn1tw==} + hasBin: true + peerDependencies: + better-sqlite3: '>=7.6.2' + kysely: '>=0.19.12' + mysql2: ^2.3.3 + pg: ^8.8.0 + peerDependenciesMeta: + better-sqlite3: + optional: true + mysql2: + optional: true + pg: + optional: true + dependencies: + chalk: 4.1.2 + dotenv: 16.0.3 + kysely: 0.23.5 + micromatch: 4.0.5 + minimist: 1.2.8 + + /kysely-data-api@0.2.0(@aws-sdk/client-rds-data@3.319.0)(kysely@0.23.5): + resolution: {integrity: sha512-Jkuqoxs8XInYeUnKDFKraA1lmuW8flY5hse59EmFIKbWDv0diRjkthCrc21egEwpfqVmLYq0/zj+SWWrH8a0hw==} + peerDependencies: + '@aws-sdk/client-rds-data': 3.x + kysely: 0.x + dependencies: + '@aws-sdk/client-rds-data': 3.319.0 + kysely: 0.23.5 + + /kysely@0.23.5: + resolution: {integrity: sha512-TH+b56pVXQq0tsyooYLeNfV11j6ih7D50dyN8tkM0e7ndiUH28Nziojiog3qRFlmEj9XePYdZUrNJ2079Qjdow==} + engines: {node: '>=14.0.0'} + + /lazystream@1.0.1: + resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} + engines: {node: '>= 0.6.3'} + dependencies: + readable-stream: 2.3.8 + + /lcid@1.0.0: + resolution: {integrity: sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==} + engines: {node: '>=0.10.0'} + dependencies: + invert-kv: 1.0.0 + + /leven@2.1.0: + resolution: {integrity: sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA==} + engines: {node: '>=0.10.0'} + + /lilconfig@2.1.0: + resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==} + engines: {node: '>=10'} + dev: true + + /listenercount@1.0.1: + resolution: {integrity: sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==} + + /local-pkg@0.4.3: + resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} + engines: {node: '>=14'} + dev: true + + /locate-path@3.0.0: + resolution: {integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==} + engines: {node: '>=6'} + dependencies: + p-locate: 3.0.0 + path-exists: 3.0.0 + + /locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + dependencies: + p-locate: 5.0.0 + dev: true + + /lodash.defaults@4.2.0: + resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} + + /lodash.difference@4.5.0: + resolution: {integrity: sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==} + + /lodash.flatten@4.4.0: + resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==} + + /lodash.isplainobject@4.0.6: + resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} + + /lodash.pad@4.5.1: + resolution: {integrity: sha512-mvUHifnLqM+03YNzeTBS1/Gr6JRFjd3rRx88FHWUvamVaT9k2O/kXha3yBSOwB9/DTQrSTLJNHvLBBt2FdX7Mg==} + + /lodash.padend@4.6.1: + resolution: {integrity: sha512-sOQs2aqGpbl27tmCS1QNZA09Uqp01ZzWfDUoD+xzTii0E7dSQfRKcRetFwa+uXaxaqL+TKm7CgD2JdKP7aZBSw==} + + /lodash.padstart@4.6.1: + resolution: {integrity: sha512-sW73O6S8+Tg66eY56DBk85aQzzUJDtpoXFBgELMd5P/SotAguo+1kYO6RuYgXxA4HJH3LFTFPASX6ET6bjfriw==} + + /lodash.throttle@4.1.1: + resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} + dev: true + + /lodash.truncate@4.4.2: + resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} + + /lodash.union@4.6.0: + resolution: {integrity: sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==} + + /lodash@4.17.21: + resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + + /log-symbols@5.1.0: + resolution: {integrity: sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==} + engines: {node: '>=12'} + dependencies: + chalk: 5.2.0 + is-unicode-supported: 1.3.0 + + /loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + dependencies: + js-tokens: 4.0.0 + + /loupe@2.3.6: + resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} + dependencies: + get-func-name: 2.0.0 + dev: true + + /lru-cache@5.1.1: + resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + dependencies: + yallist: 3.1.1 + + /lru-cache@6.0.0: + resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} + engines: {node: '>=10'} + dependencies: + yallist: 4.0.0 + + /lru-cache@7.18.3: + resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} + engines: {node: '>=12'} + + /lru-queue@0.1.0: + resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==} + dependencies: + es5-ext: 0.10.62 + dev: true + + /md5@2.3.0: + resolution: {integrity: sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==} + dependencies: + charenc: 0.0.2 + crypt: 0.0.2 + is-buffer: 1.1.6 + + /media-query-parser@2.0.2: + resolution: {integrity: sha512-1N4qp+jE0pL5Xv4uEcwVUhIkwdUO3S/9gML90nqKA7v7FcOS5vUtatfzok9S9U1EJU8dHWlcv95WLnKmmxZI9w==} + dependencies: + '@babel/runtime': 7.21.0 + + /media-typer@0.3.0: + resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} + engines: {node: '>= 0.6'} + + /memoizee@0.4.15: + resolution: {integrity: sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-weak-map: 2.0.3 + event-emitter: 0.3.5 + is-promise: 2.2.2 + lru-queue: 0.1.0 + next-tick: 1.1.0 + timers-ext: 0.1.7 + dev: true + + /memory-stream@0.0.3: + resolution: {integrity: sha512-q0D3m846qY6ZkIt+19ZemU5vH56lpOZZwoJc3AICARKh/menBuayQUjAGPrqtHQQMUYERSdOrej92J9kz7LgYA==} + dependencies: + readable-stream: 1.0.34 + + /merge-anything@5.1.5: + resolution: {integrity: sha512-9lquMsJxgaef2BXYUy8VnqHmuLYaEiGd7SULqOTuDFA9Lw6g6Hmdsblc6+yqshdJOQKkn9I106+3D5mnQMstvg==} + engines: {node: '>=12.13'} + dependencies: + is-what: 4.1.8 + dev: true + + /merge-descriptors@1.0.1: + resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==} + + /methods@1.1.2: + resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} + engines: {node: '>= 0.6'} + + /micromatch@4.0.5: + resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} + engines: {node: '>=8.6'} + dependencies: + braces: 3.0.2 + picomatch: 2.3.1 + + /mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + + /mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + + /mime@1.6.0: + resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} + engines: {node: '>=4'} + hasBin: true + + /mime@2.6.0: + resolution: {integrity: sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==} + engines: {node: '>=4.0.0'} + hasBin: true + + /mimic-fn@2.1.0: + resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} + engines: {node: '>=6'} + + /mimic-fn@3.1.0: + resolution: {integrity: sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ==} + engines: {node: '>=8'} + + /minimalistic-assert@1.0.1: + resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} + + /minimatch@3.1.2: + resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + dependencies: + brace-expansion: 1.1.11 + + /minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + + /minimatch@6.2.0: + resolution: {integrity: sha512-sauLxniAmvnhhRjFwPNnJKaPFYyddAgbYdeUpHULtCT/GhzdCx/MDNy+Y40lBxTQUrMzDE8e0S43Z5uqfO0REg==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + + /minimatch@7.4.6: + resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: true + + /minimist@1.2.6: + resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} + + /minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + /minipass@2.9.0: + resolution: {integrity: sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==} + dependencies: + safe-buffer: 5.2.1 + yallist: 3.1.1 + + /minipass@3.3.6: + resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} + engines: {node: '>=8'} + dependencies: + yallist: 4.0.0 + + /minipass@4.2.8: + resolution: {integrity: sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==} + engines: {node: '>=8'} + + /minizlib@1.3.3: + resolution: {integrity: sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==} + dependencies: + minipass: 2.9.0 + + /minizlib@2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.3.6 + yallist: 4.0.0 + + /mkdirp@0.5.6: + resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} + hasBin: true + dependencies: + minimist: 1.2.8 + + /mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + + /mlly@1.2.0: + resolution: {integrity: sha512-+c7A3CV0KGdKcylsI6khWyts/CYrGTrRVo4R/I7u/cUsy0Conxa6LUhiEzVKIw14lc2L5aiO4+SeVe4TeGRKww==} + dependencies: + acorn: 8.8.2 + pathe: 1.1.0 + pkg-types: 1.0.2 + ufo: 1.1.1 + dev: true + + /mnemonist@0.39.5: + resolution: {integrity: sha512-FPUtkhtJ0efmEFGpU14x7jGbTB+s18LrzRL2KgoWz9YvcY3cPomz8tih01GbHwnGk/OmkOKfqd/RAQoc8Lm7DQ==} + dependencies: + obliterator: 2.0.4 + + /modern-normalize@1.1.0: + resolution: {integrity: sha512-2lMlY1Yc1+CUy0gw4H95uNN7vjbpoED7NNRSBHE25nWfLBdmMzFCsPshlzbxHz+gYMcBEUN8V4pU16prcdPSgA==} + engines: {node: '>=6'} + dev: false + + /mqtt-packet@6.10.0: + resolution: {integrity: sha512-ja8+mFKIHdB1Tpl6vac+sktqy3gA8t9Mduom1BA75cI+R9AHnZOiaBQwpGiWnaVJLDGRdNhQmFaAqd7tkKSMGA==} + dependencies: + bl: 4.1.0 + debug: 4.3.4 + process-nextick-args: 2.0.1 + transitivePeerDependencies: + - supports-color + + /mqtt@4.2.8: + resolution: {integrity: sha512-DJYjlXODVXtSDecN8jnNzi6ItX3+ufGsEs9OB3YV24HtkRrh7kpx8L5M1LuyF0KzaiGtWr2PzDcMGAY60KGOSA==} + engines: {node: '>=10.0.0'} + hasBin: true + dependencies: + commist: 1.1.0 + concat-stream: 2.0.0 + debug: 4.3.4 + duplexify: 4.1.2 + help-me: 3.0.0 + inherits: 2.0.4 + minimist: 1.2.8 + mqtt-packet: 6.10.0 + pump: 3.0.0 + readable-stream: 3.6.2 + reinterval: 1.1.0 + split2: 3.2.2 + ws: 7.5.9 + xtend: 4.0.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /mqtt@4.3.7: + resolution: {integrity: sha512-ew3qwG/TJRorTz47eW46vZ5oBw5MEYbQZVaEji44j5lAUSQSqIEoul7Kua/BatBW0H0kKQcC9kwUHa1qzaWHSw==} + engines: {node: '>=10.0.0'} + hasBin: true + dependencies: + commist: 1.1.0 + concat-stream: 2.0.0 + debug: 4.3.4 + duplexify: 4.1.2 + help-me: 3.0.0 + inherits: 2.0.4 + lru-cache: 6.0.0 + minimist: 1.2.8 + mqtt-packet: 6.10.0 + number-allocator: 1.0.14 + pump: 3.0.0 + readable-stream: 3.6.2 + reinterval: 1.1.0 + rfdc: 1.3.0 + split2: 3.2.2 + ws: 7.5.9 + xtend: 4.0.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + /ms@2.0.0: + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} + + /ms@2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + + /ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + /mute-stream@0.0.8: + resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} + + /nanoid@3.3.6: + resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: true + + /negotiator@0.6.3: + resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} + engines: {node: '>= 0.6'} + + /next-tick@1.1.0: + resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} + dev: true + + /node-fetch@2.6.9: + resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + dependencies: + whatwg-url: 5.0.0 + dev: false + + /node-releases@2.0.10: + resolution: {integrity: sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==} + + /normalize-path@3.0.0: + resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} + engines: {node: '>=0.10.0'} + + /npmlog@1.2.1: + resolution: {integrity: sha512-1J5KqSRvESP6XbjPaXt2H6qDzgizLTM7x0y1cXIjP2PpvdCqyNC7TO3cPRKsuYlElbi/DwkzRRdG2zpmE0IktQ==} + dependencies: + ansi: 0.3.1 + are-we-there-yet: 1.0.6 + gauge: 1.2.7 + + /number-allocator@1.0.14: + resolution: {integrity: sha512-OrL44UTVAvkKdOdRQZIJpLkAdjXGTRda052sN4sO77bKEzYYqWKMBjQvrJFzqygI99gL6Z4u2xctPW1tB8ErvA==} + dependencies: + debug: 4.3.4 + js-sdsl: 4.3.0 + transitivePeerDependencies: + - supports-color + + /number-is-nan@1.0.1: + resolution: {integrity: sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==} + engines: {node: '>=0.10.0'} + + /object-hash@2.2.0: + resolution: {integrity: sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==} + engines: {node: '>= 6'} + + /object-inspect@1.12.3: + resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} + + /obliterator@2.0.4: + resolution: {integrity: sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ==} + + /oidc-token-hash@5.0.3: + resolution: {integrity: sha512-IF4PcGgzAr6XXSff26Sk/+P4KZFJVuHAJZj3wgO3vX2bMdNVp/QXTP3P7CEm9V1IdG8lDLY3HhiqpsE/nOwpPw==} + engines: {node: ^10.13.0 || >=12.0.0} + + /on-finished@2.4.1: + resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} + engines: {node: '>= 0.8'} + dependencies: + ee-first: 1.1.1 + + /once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + dependencies: + wrappy: 1.0.2 + + /onetime@5.1.2: + resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} + engines: {node: '>=6'} + dependencies: + mimic-fn: 2.1.0 + + /openid-client@5.4.2: + resolution: {integrity: sha512-lIhsdPvJ2RneBm3nGBBhQchpe3Uka//xf7WPHTIglery8gnckvW7Bd9IaQzekzXJvWthCMyi/xVEyGW0RFPytw==} + dependencies: + jose: 4.14.2 + lru-cache: 6.0.0 + object-hash: 2.2.0 + oidc-token-hash: 5.0.3 + + /ora@6.3.0: + resolution: {integrity: sha512-1/D8uRFY0ay2kgBpmAwmSA404w4OoPVhHMqRqtjvrcK/dnzcEZxMJ+V4DUbyICu8IIVRclHcOf5wlD1tMY4GUQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + chalk: 5.2.0 + cli-cursor: 4.0.0 + cli-spinners: 2.8.0 + is-interactive: 2.0.0 + is-unicode-supported: 1.3.0 + log-symbols: 5.1.0 + stdin-discarder: 0.1.0 + strip-ansi: 7.0.1 + wcwidth: 1.0.1 + + /os-locale@1.4.0: + resolution: {integrity: sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==} + engines: {node: '>=0.10.0'} + dependencies: + lcid: 1.0.0 + + /outdent@0.8.0: + resolution: {integrity: sha512-KiOAIsdpUTcAXuykya5fnVVT+/5uS0Q1mrkRHcF89tpieSmY33O/tmc54CqwA+bfhbtEfZUNLHaPUiB9X3jt1A==} + + /p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + dependencies: + p-try: 2.2.0 + + /p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + dependencies: + yocto-queue: 0.1.0 + dev: true + + /p-locate@3.0.0: + resolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==} + engines: {node: '>=6'} + dependencies: + p-limit: 2.3.0 + + /p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + dependencies: + p-limit: 3.1.0 + dev: true + + /p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + + /pako@1.0.11: + resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} + + /parseurl@1.3.3: + resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} + engines: {node: '>= 0.8'} + + /patch-console@2.0.0: + resolution: {integrity: sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + /path-exists@3.0.0: + resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} + engines: {node: '>=4'} + + /path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + dev: true + + /path-is-absolute@1.0.1: + resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} + engines: {node: '>=0.10.0'} + + /path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + /path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + dev: true + + /path-to-regexp@0.1.7: + resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} + + /pathe@1.1.0: + resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==} + dev: true + + /pathval@1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + dev: true + + /picocolors@1.0.0: + resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} + + /picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + + /pkg-types@1.0.2: + resolution: {integrity: sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==} + dependencies: + jsonc-parser: 3.2.0 + mlly: 1.2.0 + pathe: 1.1.0 + dev: true + + /pkg-up@3.1.0: + resolution: {integrity: sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==} + engines: {node: '>=8'} + dependencies: + find-up: 3.0.0 + + /postcss-load-config@3.1.4(postcss@8.4.23): + resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} + engines: {node: '>= 10'} + peerDependencies: + postcss: '>=8.0.9' + ts-node: '>=9.0.0' + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + dependencies: + lilconfig: 2.1.0 + postcss: 8.4.23 + yaml: 1.10.2 + dev: true + + /postcss@8.4.23: + resolution: {integrity: sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.6 + picocolors: 1.0.0 + source-map-js: 1.0.2 + dev: true + + /process-nextick-args@1.0.7: + resolution: {integrity: sha512-yN0WQmuCX63LP/TMvAg31nvT6m4vDqJEiiv2CAZqWOGNWutc9DfDk1NPYYmKUFmaVM2UwDowH4u5AHWYP/jxKw==} + + /process-nextick-args@2.0.1: + resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + + /process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + + /promptly@3.2.0: + resolution: {integrity: sha512-WnR9obtgW+rG4oUV3hSnNGl1pHm3V1H/qD9iJBumGSmVsSC5HpZOLuu8qdMb6yCItGfT7dcRszejr/5P3i9Pug==} + dependencies: + read: 1.0.7 + + /proxy-addr@2.0.7: + resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} + engines: {node: '>= 0.10'} + dependencies: + forwarded: 0.2.0 + ipaddr.js: 1.9.1 + + /pump@3.0.0: + resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} + dependencies: + end-of-stream: 1.4.4 + once: 1.4.0 + + /punycode@1.3.2: + resolution: {integrity: sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==} + + /punycode@1.4.1: + resolution: {integrity: sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==} + + /punycode@2.3.0: + resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} + engines: {node: '>=6'} + + /pvtsutils@1.3.2: + resolution: {integrity: sha512-+Ipe2iNUyrZz+8K/2IOo+kKikdtfhRKzNpQbruF2URmqPtoqAs8g3xS7TJvFF2GcPXjh7DkqMnpVveRFq4PgEQ==} + dependencies: + tslib: 2.5.0 + + /pvutils@1.1.3: + resolution: {integrity: sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==} + engines: {node: '>=6.0.0'} + + /q@1.5.1: + resolution: {integrity: sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==} + engines: {node: '>=0.6.0', teleport: '>=0.2.0'} + + /qs@6.11.0: + resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==} + engines: {node: '>=0.6'} + dependencies: + side-channel: 1.0.4 + + /querystring@0.2.0: + resolution: {integrity: sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==} + engines: {node: '>=0.4.x'} + deprecated: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. + + /range-parser@1.2.1: + resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} + engines: {node: '>= 0.6'} + + /raw-body@2.5.1: + resolution: {integrity: sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==} + engines: {node: '>= 0.8'} + dependencies: + bytes: 3.1.2 + http-errors: 2.0.0 + iconv-lite: 0.4.24 + unpipe: 1.0.0 + + /rc@1.2.8: + resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} + hasBin: true + dependencies: + deep-extend: 0.6.0 + ini: 1.3.8 + minimist: 1.2.8 + strip-json-comments: 2.0.1 + + /react-reconciler@0.29.0(react@18.2.0): + resolution: {integrity: sha512-wa0fGj7Zht1EYMRhKWwoo1H9GApxYLBuhoAuXN0TlltESAjDssB+Apf0T/DngVqaMyPypDmabL37vw/2aRM98Q==} + engines: {node: '>=0.10.0'} + peerDependencies: + react: ^18.2.0 + dependencies: + loose-envify: 1.4.0 + react: 18.2.0 + scheduler: 0.23.0 + + /react@18.2.0: + resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==} + engines: {node: '>=0.10.0'} + dependencies: + loose-envify: 1.4.0 + + /read@1.0.7: + resolution: {integrity: sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ==} + engines: {node: '>=0.8'} + dependencies: + mute-stream: 0.0.8 + + /readable-stream@1.0.34: + resolution: {integrity: sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==} + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 0.0.1 + string_decoder: 0.10.31 + + /readable-stream@2.1.5: + resolution: {integrity: sha512-NkXT2AER7VKXeXtJNSaWLpWIhmtSE3K2PguaLEeWr4JILghcIKqoLt1A3wHrnpDC5+ekf8gfk1GKWkFXe4odMw==} + dependencies: + buffer-shims: 1.0.0 + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 1.0.7 + string_decoder: 0.10.31 + util-deprecate: 1.0.2 + + /readable-stream@2.3.8: + resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 2.0.1 + safe-buffer: 5.1.2 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + + /readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + dependencies: + inherits: 2.0.4 + string_decoder: 1.3.0 + util-deprecate: 1.0.2 + + /readdir-glob@1.1.3: + resolution: {integrity: sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==} + dependencies: + minimatch: 5.1.6 + + /readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + dependencies: + picomatch: 2.3.1 + + /regenerator-runtime@0.13.11: + resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} + + /reinterval@1.1.0: + resolution: {integrity: sha512-QIRet3SYrGp0HUHO88jVskiG6seqUGC5iAG7AwI/BV4ypGcuqk9Du6YQBUOUqm9c8pw1eyLoIaONifRua1lsEQ==} + + /remeda@1.14.0: + resolution: {integrity: sha512-AFPpCRtlYAcSzW4cI8sOw+x+BtbvX6tIwL3lhRxUO9YuPXRe06N1woIMPq/O1cNNy5n4a0TwbIHIciqnswkaQg==} + + /replicache@12.2.1: + resolution: {integrity: sha512-IQSAorWVgaEpGuI3HEGDmnBT4oQq7OYteWH0ZNp5U6g8gDTNLvsO/16aBgQdHhHGHJRx2ULoxjovyJGlu+NYjg==} + engines: {node: '>=14.8.0'} + hasBin: true + dev: false + + /require-directory@2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + + /require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + + /require-like@0.1.2: + resolution: {integrity: sha512-oyrU88skkMtDdauHDuKVrgR+zuItqr6/c//FXzvmxRGMexSDc6hNvJInGW3LL46n+8b50RykrvwSUIIQH2LQ5A==} + dev: true + + /resolve@1.22.2: + resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==} + hasBin: true + dependencies: + is-core-module: 2.12.0 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: true + + /restore-cursor@4.0.0: + resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + onetime: 5.1.2 + signal-exit: 3.0.7 + + /rfdc@1.3.0: + resolution: {integrity: sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==} + + /rimraf@2.7.1: + resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + hasBin: true + dependencies: + glob: 7.2.3 + + /rollup@2.79.1: + resolution: {integrity: sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==} + engines: {node: '>=10.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /rollup@3.21.0: + resolution: {integrity: sha512-ANPhVcyeHvYdQMUyCbczy33nbLzI7RzrBje4uvNiTDJGIMtlKoOStmympwr9OtS1LZxiDmE2wvxHyVhoLtf1KQ==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /safe-buffer@5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + + /safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + /safer-buffer@2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + + /sax@1.2.1: + resolution: {integrity: sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA==} + + /scheduler@0.23.0: + resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} + dependencies: + loose-envify: 1.4.0 + + /semver@5.7.1: + resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==} + hasBin: true + + /semver@6.3.0: + resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} + hasBin: true + + /semver@7.5.0: + resolution: {integrity: sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + + /send@0.18.0: + resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==} + engines: {node: '>= 0.8.0'} + dependencies: + debug: 2.6.9 + depd: 2.0.0 + destroy: 1.2.0 + encodeurl: 1.0.2 + escape-html: 1.0.3 + etag: 1.8.1 + fresh: 0.5.2 + http-errors: 2.0.0 + mime: 1.6.0 + ms: 2.1.3 + on-finished: 2.4.1 + range-parser: 1.2.1 + statuses: 2.0.1 + transitivePeerDependencies: + - supports-color + + /seroval@0.5.1: + resolution: {integrity: sha512-ZfhQVB59hmIauJG5Ydynupy8KHyr5imGNtdDhbZG68Ufh1Ynkv9KOYOAABf71oVbQxJ8VkWnMHAjEHE7fWkH5g==} + engines: {node: '>=10'} + + /serve-static@1.15.0: + resolution: {integrity: sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==} + engines: {node: '>= 0.8.0'} + dependencies: + encodeurl: 1.0.2 + escape-html: 1.0.3 + parseurl: 1.3.3 + send: 0.18.0 + transitivePeerDependencies: + - supports-color + + /setimmediate@1.0.5: + resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} + + /setprototypeof@1.2.0: + resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} + + /shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + dependencies: + shebang-regex: 3.0.0 + + /shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + /side-channel@1.0.4: + resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.2.0 + object-inspect: 1.12.3 + + /signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + + /sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + dev: true + + /slice-ansi@4.0.0: + resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + astral-regex: 2.0.0 + is-fullwidth-code-point: 3.0.0 + + /slice-ansi@5.0.0: + resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} + engines: {node: '>=12'} + dependencies: + ansi-styles: 6.2.1 + is-fullwidth-code-point: 4.0.0 + + /slice-ansi@6.0.0: + resolution: {integrity: sha512-6bn4hRfkTvDfUoEQYkERg0BVF1D0vrX9HEkMl08uDiNWvVvjylLHvZFZWkDo6wjT8tUctbYl1nCOuE66ZTaUtA==} + engines: {node: '>=14.16'} + dependencies: + ansi-styles: 6.2.1 + is-fullwidth-code-point: 4.0.0 + + /solid-js@1.7.3: + resolution: {integrity: sha512-4hwaF/zV/xbNeBBIYDyu3dcReOZBECbO//mrra6GqOrKy4Soyo+fnKjpZSa0nODm6j1aL0iQRh/7ofYowH+jzw==} + dependencies: + csstype: 3.1.2 + seroval: 0.5.1 + + /solid-refresh@0.5.2(solid-js@1.7.3): + resolution: {integrity: sha512-I69HmFj0LsGRJ3n8CEMVjyQFgVtuM2bSjznu2hCnsY+i5oOxh8ioWj00nnHBv0UYD3WpE/Sq4Q3TNw2IKmKN7A==} + peerDependencies: + solid-js: ^1.3 + dependencies: + '@babel/generator': 7.21.4 + '@babel/helper-module-imports': 7.21.4 + '@babel/types': 7.21.4 + solid-js: 1.7.3 + dev: true + + /source-map-js@1.0.2: + resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + engines: {node: '>=0.10.0'} + dev: true + + /source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + + /source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + /split2@3.2.2: + resolution: {integrity: sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==} + dependencies: + readable-stream: 3.6.2 + + /splitargs@0.0.7: + resolution: {integrity: sha512-UUFYD2oWbNwULH6WoVtLUOw8ch586B+HUqcsAjjjeoBQAM1bD4wZRXu01koaxyd8UeYpybWqW4h+lO1Okv40Tg==} + + /sst-aws-cdk@2.62.2-3: + resolution: {integrity: sha512-scNMkuwTm7Gr/8l8/lCNIxVD2z8TX+4Yr5Mb5OzsUeumYCmF0KGegNy/0pYgYArObAExEnbju8kRuB/VwJRhUQ==} + engines: {node: '>= 14.15.0'} + hasBin: true + dependencies: + archiver: 5.3.1 + chalk: 4.1.2 + promptly: 3.2.0 + yaml: 1.10.2 + optionalDependencies: + fsevents: 2.3.2 + + /sst@2.7.2: + resolution: {integrity: sha512-T7v7lvMUWy6G2o98H77JD8EWvAgvrDE5docIGKLbDdxzhjdYeTG8Cni2xKWc4FzFB1BsuPEJ4GlZb3CeglHlMQ==} + hasBin: true + peerDependencies: + '@sls-next/lambda-at-edge': ^3.7.0 + peerDependenciesMeta: + '@sls-next/lambda-at-edge': + optional: true + dependencies: + '@aws-cdk/aws-apigatewayv2-alpha': 2.72.1-alpha.0(aws-cdk-lib@2.72.1)(constructs@10.1.156) + '@aws-cdk/aws-apigatewayv2-authorizers-alpha': 2.72.1-alpha.0(@aws-cdk/aws-apigatewayv2-alpha@2.72.1-alpha.0)(aws-cdk-lib@2.72.1)(constructs@10.1.156) + '@aws-cdk/aws-apigatewayv2-integrations-alpha': 2.72.1-alpha.0(@aws-cdk/aws-apigatewayv2-alpha@2.72.1-alpha.0)(aws-cdk-lib@2.72.1)(constructs@10.1.156) + '@aws-cdk/cloud-assembly-schema': 2.72.1 + '@aws-cdk/cloudformation-diff': 2.72.1 + '@aws-cdk/cx-api': 2.72.1(@aws-cdk/cloud-assembly-schema@2.72.1) + '@aws-sdk/client-cloudformation': 3.326.0 + '@aws-sdk/client-iot': 3.319.0 + '@aws-sdk/client-iot-data-plane': 3.319.0 + '@aws-sdk/client-lambda': 3.332.0 + '@aws-sdk/client-rds-data': 3.319.0 + '@aws-sdk/client-s3': 3.326.0(@aws-sdk/signature-v4-crt@3.310.0) + '@aws-sdk/client-ssm': 3.319.0 + '@aws-sdk/client-sts': 3.321.1 + '@aws-sdk/config-resolver': 3.310.0 + '@aws-sdk/credential-providers': 3.319.0 + '@aws-sdk/middleware-retry': 3.310.0 + '@aws-sdk/middleware-signing': 3.310.0 + '@aws-sdk/signature-v4-crt': 3.310.0 + '@aws-sdk/smithy-client': 3.316.0 + '@babel/core': 7.21.4 + '@babel/generator': 7.21.4 + '@trpc/server': 9.16.0 + aws-cdk-lib: 2.72.1(constructs@10.1.156) + aws-iot-device-sdk: 2.2.12 + aws-sdk: 2.1365.0 + builtin-modules: 3.2.0 + cdk-assets: 2.72.1 + chalk: 5.2.0 + chokidar: 3.5.3 + ci-info: 3.8.0 + colorette: 2.0.20 + conf: 10.2.0 + constructs: 10.1.156 + cross-spawn: 7.0.3 + dendriform-immer-patch-optimiser: 2.1.3(immer@9.0.21) + dotenv: 16.0.3 + esbuild: 0.16.13 + express: 4.18.2 + fast-jwt: 1.7.2 + get-port: 6.1.2 + glob: 8.1.0 + graphql: 16.6.0 + graphql-yoga: 3.9.1(graphql@16.6.0) + immer: 9.0.21 + ink: 4.2.0(react@18.2.0) + ink-spinner: 5.0.0(ink@4.2.0)(react@18.2.0) + kysely: 0.23.5 + kysely-codegen: 0.9.0(kysely@0.23.5) + kysely-data-api: 0.2.0(@aws-sdk/client-rds-data@3.319.0)(kysely@0.23.5) + minimatch: 6.2.0 + openid-client: 5.4.2 + ora: 6.3.0 + react: 18.2.0 + remeda: 1.14.0 + sst-aws-cdk: 2.62.2-3 + tree-kill: 1.2.2 + undici: 5.22.0 + uuid: 9.0.0 + ws: 8.13.0 + yargs: 17.7.1 + zip-local: 0.3.5 + transitivePeerDependencies: + - '@types/react' + - aws-crt + - better-sqlite3 + - bufferutil + - debug + - mysql2 + - pg + - react-devtools-core + - supports-color + - utf-8-validate + + /stack-utils@2.0.6: + resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} + engines: {node: '>=10'} + dependencies: + escape-string-regexp: 2.0.0 + + /statuses@2.0.1: + resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} + engines: {node: '>= 0.8'} + + /stdin-discarder@0.1.0: + resolution: {integrity: sha512-xhV7w8S+bUwlPTb4bAOUQhv8/cSS5offJuX8GQGq32ONF0ZtDWKfkdomM3HMRA+LhX6um/FZ0COqlwsjD53LeQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + bl: 5.1.0 + + /stream-shift@1.0.1: + resolution: {integrity: sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==} + + /streamsearch@1.1.0: + resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} + engines: {node: '>=10.0.0'} + + /string-width@1.0.2: + resolution: {integrity: sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==} + engines: {node: '>=0.10.0'} + dependencies: + code-point-at: 1.1.0 + is-fullwidth-code-point: 1.0.0 + strip-ansi: 3.0.1 + + /string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + dependencies: + emoji-regex: 8.0.0 + is-fullwidth-code-point: 3.0.0 + strip-ansi: 6.0.1 + + /string-width@5.1.2: + resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} + engines: {node: '>=12'} + dependencies: + eastasianwidth: 0.2.0 + emoji-regex: 9.2.2 + strip-ansi: 7.0.1 + + /string_decoder@0.10.31: + resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==} + + /string_decoder@1.1.1: + resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} + dependencies: + safe-buffer: 5.1.2 + + /string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + dependencies: + safe-buffer: 5.2.1 + + /strip-ansi@3.0.1: + resolution: {integrity: sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==} + engines: {node: '>=0.10.0'} + dependencies: + ansi-regex: 2.1.1 + + /strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + dependencies: + ansi-regex: 5.0.1 + + /strip-ansi@7.0.1: + resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==} + engines: {node: '>=12'} + dependencies: + ansi-regex: 6.0.1 + + /strip-json-comments@2.0.1: + resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} + engines: {node: '>=0.10.0'} + + /strip-literal@0.4.2: + resolution: {integrity: sha512-pv48ybn4iE1O9RLgCAN0iU4Xv7RlBTiit6DKmMiErbs9x1wH6vXBs45tWc0H5wUIF6TLTrKweqkmYF/iraQKNw==} + dependencies: + acorn: 8.8.2 + dev: true + + /strnum@1.0.5: + resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} + + /supports-color@5.5.0: + resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} + engines: {node: '>=4'} + dependencies: + has-flag: 3.0.0 + + /supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + dependencies: + has-flag: 4.0.0 + + /supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + dev: true + + /table@6.8.1: + resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} + engines: {node: '>=10.0.0'} + dependencies: + ajv: 8.12.0 + lodash.truncate: 4.4.2 + slice-ansi: 4.0.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + + /tar-stream@2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.4 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + + /tar@4.4.19: + resolution: {integrity: sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==} + engines: {node: '>=4.5'} + dependencies: + chownr: 1.1.4 + fs-minipass: 1.2.7 + minipass: 2.9.0 + minizlib: 1.3.3 + mkdirp: 0.5.6 + safe-buffer: 5.2.1 + yallist: 3.1.1 + + /tar@6.1.13: + resolution: {integrity: sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==} + engines: {node: '>=10'} + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 4.2.8 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + + /timers-ext@0.1.7: + resolution: {integrity: sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==} + dependencies: + es5-ext: 0.10.62 + next-tick: 1.1.0 + dev: true + + /tinybench@2.4.0: + resolution: {integrity: sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==} + dev: true + + /tinypool@0.3.1: + resolution: {integrity: sha512-zLA1ZXlstbU2rlpA4CIeVaqvWq41MTWqLY3FfsAXgC8+f7Pk7zroaJQxDgxn1xNudKW6Kmj4808rPFShUlIRmQ==} + engines: {node: '>=14.0.0'} + dev: true + + /tinyspy@1.1.1: + resolution: {integrity: sha512-UVq5AXt/gQlti7oxoIg5oi/9r0WpF7DGEVwXgqWSMmyN16+e3tl5lIvTaOpJ3TAtu5xFzWccFRM4R5NaWHF+4g==} + engines: {node: '>=14.0.0'} + dev: true + + /to-fast-properties@2.0.0: + resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} + engines: {node: '>=4'} + + /to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + dependencies: + is-number: 7.0.0 + + /toidentifier@1.0.1: + resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} + engines: {node: '>=0.6'} + + /tr46@0.0.3: + resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + dev: false + + /traverse@0.3.9: + resolution: {integrity: sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==} + + /tree-kill@1.2.2: + resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} + hasBin: true + + /tslib@1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + + /tslib@2.5.0: + resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} + + /tsx@3.12.7: + resolution: {integrity: sha512-C2Ip+jPmqKd1GWVQDvz/Eyc6QJbGfE7NrR3fx5BpEHMZsEHoIxHL1j+lKdGobr8ovEyqeNkPLSKp6SCSOt7gmw==} + hasBin: true + dependencies: + '@esbuild-kit/cjs-loader': 2.4.2 + '@esbuild-kit/core-utils': 3.1.0 + '@esbuild-kit/esm-loader': 2.5.5 + optionalDependencies: + fsevents: 2.3.2 + dev: false + + /type-detect@4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + dev: true + + /type-fest@0.12.0: + resolution: {integrity: sha512-53RyidyjvkGpnWPMF9bQgFtWp+Sl8O2Rp13VavmJgfAP9WWG6q6TkrKU8iyJdnwnfgHI6k2hTlgqH4aSdjoTbg==} + engines: {node: '>=10'} + + /type-fest@3.8.0: + resolution: {integrity: sha512-FVNSzGQz9Th+/9R6Lvv7WIAkstylfHN2/JYxkyhhmKFYh9At2DST8t6L6Lref9eYO8PXFTfG9Sg1Agg0K3vq3Q==} + engines: {node: '>=14.16'} + + /type-is@1.6.18: + resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} + engines: {node: '>= 0.6'} + dependencies: + media-typer: 0.3.0 + mime-types: 2.1.35 + + /type@1.2.0: + resolution: {integrity: sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==} + dev: true + + /type@2.7.2: + resolution: {integrity: sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==} + dev: true + + /typedarray@0.0.6: + resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} + + /typescript@4.9.5: + resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} + engines: {node: '>=4.2.0'} + hasBin: true + dev: true + + /typescript@5.0.4: + resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} + engines: {node: '>=12.20'} + hasBin: true + dev: true + + /ufo@1.1.1: + resolution: {integrity: sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==} + dev: true + + /ultron@1.1.1: + resolution: {integrity: sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==} + + /undici@5.22.0: + resolution: {integrity: sha512-fR9RXCc+6Dxav4P9VV/sp5w3eFiSdOjJYsbtWfd4s5L5C4ogyuVpdKIVHeW0vV1MloM65/f7W45nR9ZxwVdyiA==} + engines: {node: '>=14.0'} + dependencies: + busboy: 1.6.0 + + /universal-user-agent@6.0.0: + resolution: {integrity: sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==} + dev: false + + /universalify@0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + + /universalify@2.0.0: + resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==} + engines: {node: '>= 10.0.0'} + + /unpipe@1.0.0: + resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} + engines: {node: '>= 0.8'} + + /unzipper@0.8.14: + resolution: {integrity: sha512-8rFtE7EP5ssOwGpN2dt1Q4njl0N1hUXJ7sSPz0leU2hRdq6+pra57z4YPBlVqm40vcgv6ooKZEAx48fMTv9x4w==} + dependencies: + big-integer: 1.6.51 + binary: 0.3.0 + bluebird: 3.4.7 + buffer-indexof-polyfill: 1.0.2 + duplexer2: 0.1.4 + fstream: 1.0.12 + listenercount: 1.0.1 + readable-stream: 2.1.5 + setimmediate: 1.0.5 + + /update-browserslist-db@1.0.11(browserslist@4.21.5): + resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + dependencies: + browserslist: 4.21.5 + escalade: 3.1.1 + picocolors: 1.0.0 + + /uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + dependencies: + punycode: 2.3.0 + + /url-join@0.0.1: + resolution: {integrity: sha512-H6dnQ/yPAAVzMQRvEvyz01hhfQL5qRWSEt7BX8t9DqnPw9BjMb64fjIRq76Uvf1hkHp+mTZvEVJ5guXOT0Xqaw==} + + /url@0.10.3: + resolution: {integrity: sha512-hzSUW2q06EqL1gKM/a+obYHLIO6ct2hwPuviqTTOcfFVc61UbfJ2Q32+uGL/HCPxKqrdGB5QUwIe7UqlDgwsOQ==} + dependencies: + punycode: 1.3.2 + querystring: 0.2.0 + + /urlpattern-polyfill@8.0.2: + resolution: {integrity: sha512-Qp95D4TPJl1kC9SKigDcqgyM2VDVO4RiJc2d4qe5GrYm+zbIQCWWKAFaJNQ4BhdFeDGwBmAxqJBwWSJDb9T3BQ==} + + /util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + + /util@0.12.5: + resolution: {integrity: sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==} + dependencies: + inherits: 2.0.4 + is-arguments: 1.1.1 + is-generator-function: 1.0.10 + is-typed-array: 1.1.10 + which-typed-array: 1.1.9 + + /utils-merge@1.0.1: + resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} + engines: {node: '>= 0.4.0'} + + /uuid@8.0.0: + resolution: {integrity: sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==} + hasBin: true + + /uuid@8.3.2: + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} + hasBin: true + + /uuid@9.0.0: + resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==} + hasBin: true + + /validate-html-nesting@1.2.2: + resolution: {integrity: sha512-hGdgQozCsQJMyfK5urgFcWEqsSSrK63Awe0t/IMR0bZ0QMtnuaiHzThW81guu3qx9abLi99NEuiaN6P9gVYsNg==} + dev: true + + /value-or-promise@1.0.12: + resolution: {integrity: sha512-Z6Uz+TYwEqE7ZN50gwn+1LCVo9ZVrpxRPOhOLnncYkY1ZzOYtrX8Fwf/rFktZ8R5mJms6EZf5TqNOMeZmnPq9Q==} + engines: {node: '>=12'} + + /vary@1.1.2: + resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} + engines: {node: '>= 0.8'} + + /vite-node@0.28.5: + resolution: {integrity: sha512-LmXb9saMGlrMZbXTvOveJKwMTBTNUH66c8rJnQ0ZPNX+myPEol64+szRzXtV5ORb0Hb/91yq+/D3oERoyAt6LA==} + engines: {node: '>=v14.16.0'} + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.4 + mlly: 1.2.0 + pathe: 1.1.0 + picocolors: 1.0.0 + source-map: 0.6.1 + source-map-support: 0.5.21 + vite: 3.2.6(@types/node@18.16.0) + transitivePeerDependencies: + - '@types/node' + - less + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /vite-plugin-solid@2.7.0(solid-js@1.7.3)(vite@3.2.6): + resolution: {integrity: sha512-avp/Jl5zOp/Itfo67xtDB2O61U7idviaIp4mLsjhCa13PjKNasz+IID0jYTyqUp9SFx6/PmBr6v4KgDppqompg==} + peerDependencies: + solid-js: ^1.7.2 + vite: ^3.0.0 || ^4.0.0 + dependencies: + '@babel/core': 7.21.4 + '@babel/preset-typescript': 7.21.4(@babel/core@7.21.4) + '@types/babel__core': 7.20.0 + babel-preset-solid: 1.7.3(@babel/core@7.21.4) + merge-anything: 5.1.5 + solid-js: 1.7.3 + solid-refresh: 0.5.2(solid-js@1.7.3) + vite: 3.2.6(@types/node@18.16.0) + vitefu: 0.2.4(vite@3.2.6) + transitivePeerDependencies: + - supports-color + dev: true + + /vite@3.2.6(@types/node@18.16.0): + resolution: {integrity: sha512-nTXTxYVvaQNLoW5BQ8PNNQ3lPia57gzsQU/Khv+JvzKPku8kNZL6NMUR/qwXhMG6E+g1idqEPanomJ+VZgixEg==} + engines: {node: ^14.18.0 || >=16.0.0} + hasBin: true + peerDependencies: + '@types/node': '>= 14' + less: '*' + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 18.16.0 + esbuild: 0.15.18 + postcss: 8.4.23 + resolve: 1.22.2 + rollup: 2.79.1 + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /vite@4.3.3: + resolution: {integrity: sha512-MwFlLBO4udZXd+VBcezo3u8mC77YQk+ik+fbc0GZWGgzfbPP+8Kf0fldhARqvSYmtIWoAJ5BXPClUbMTlqFxrA==} + engines: {node: ^14.18.0 || >=16.0.0} + hasBin: true + peerDependencies: + '@types/node': '>= 14' + less: '*' + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.17.18 + postcss: 8.4.23 + rollup: 3.21.0 + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /vitefu@0.2.4(vite@3.2.6): + resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==} + peerDependencies: + vite: ^3.0.0 || ^4.0.0 + peerDependenciesMeta: + vite: + optional: true + dependencies: + vite: 3.2.6(@types/node@18.16.0) + dev: true + + /vitest@0.25.3: + resolution: {integrity: sha512-/UzHfXIKsELZhL7OaM2xFlRF8HRZgAHtPctacvNK8H4vOcbJJAMEgbWNGSAK7Y9b1NBe5SeM7VTuz2RsTHFJJA==} + engines: {node: '>=v14.16.0'} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@vitest/browser': '*' + '@vitest/ui': '*' + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/chai': 4.3.4 + '@types/chai-subset': 1.3.3 + '@types/node': 18.16.0 + acorn: 8.8.2 + acorn-walk: 8.2.0 + chai: 4.3.7 + debug: 4.3.4 + local-pkg: 0.4.3 + source-map: 0.6.1 + strip-literal: 0.4.2 + tinybench: 2.4.0 + tinypool: 0.3.1 + tinyspy: 1.1.1 + vite: 3.2.6(@types/node@18.16.0) + transitivePeerDependencies: + - less + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /wcwidth@1.0.1: + resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + dependencies: + defaults: 1.0.4 + + /web-streams-polyfill@3.2.1: + resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} + engines: {node: '>= 8'} + + /webcrypto-core@1.7.7: + resolution: {integrity: sha512-7FjigXNsBfopEj+5DV2nhNpfic2vumtjjgPmeDKk45z+MJwXKKfhPB7118Pfzrmh4jqOMST6Ch37iPAHoImg5g==} + dependencies: + '@peculiar/asn1-schema': 2.3.6 + '@peculiar/json-schema': 1.1.12 + asn1js: 3.0.5 + pvtsutils: 1.3.2 + tslib: 2.5.0 + + /webidl-conversions@3.0.1: + resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + dev: false + + /websocket-stream@5.5.2: + resolution: {integrity: sha512-8z49MKIHbGk3C4HtuHWDtYX8mYej1wWabjthC/RupM9ngeukU4IWoM46dgth1UOS/T4/IqgEdCDJuMe2039OQQ==} + dependencies: + duplexify: 3.7.1 + inherits: 2.0.4 + readable-stream: 2.3.8 + safe-buffer: 5.2.1 + ws: 3.3.3 + xtend: 4.0.2 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + /whatwg-url@5.0.0: + resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + dependencies: + tr46: 0.0.3 + webidl-conversions: 3.0.1 + dev: false + + /which-typed-array@1.1.9: + resolution: {integrity: sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + is-typed-array: 1.1.10 + + /which@1.3.1: + resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} + hasBin: true + dependencies: + isexe: 2.0.0 + + /which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + dependencies: + isexe: 2.0.0 + + /widest-line@4.0.1: + resolution: {integrity: sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==} + engines: {node: '>=12'} + dependencies: + string-width: 5.1.2 + + /window-size@0.1.4: + resolution: {integrity: sha512-2thx4pB0cV3h+Bw7QmMXcEbdmOzv9t0HFplJH/Lz6yu60hXYy5RT8rUu+wlIreVxWsGN20mo+MHeCSfUpQBwPw==} + engines: {node: '>= 0.10.0'} + hasBin: true + + /wordwrap@1.0.0: + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} + dev: true + + /wrap-ansi@2.1.0: + resolution: {integrity: sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==} + engines: {node: '>=0.10.0'} + dependencies: + string-width: 1.0.2 + strip-ansi: 3.0.1 + + /wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + + /wrap-ansi@8.1.0: + resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} + engines: {node: '>=12'} + dependencies: + ansi-styles: 6.2.1 + string-width: 5.1.2 + strip-ansi: 7.0.1 + + /wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + /ws@3.3.3: + resolution: {integrity: sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dependencies: + async-limiter: 1.0.1 + safe-buffer: 5.1.2 + ultron: 1.1.1 + + /ws@7.5.9: + resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + /ws@8.13.0: + resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + /xml2js@0.5.0: + resolution: {integrity: sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==} + engines: {node: '>=4.0.0'} + dependencies: + sax: 1.2.1 + xmlbuilder: 11.0.1 + + /xmlbuilder@11.0.1: + resolution: {integrity: sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==} + engines: {node: '>=4.0'} + + /xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + + /y18n@3.2.2: + resolution: {integrity: sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==} + + /y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + + /yallist@3.1.1: + resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + + /yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + + /yaml@1.10.2: + resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} + engines: {node: '>= 6'} + + /yargs-parser@20.2.9: + resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} + engines: {node: '>=10'} + + /yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + + /yargs@16.2.0: + resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} + engines: {node: '>=10'} + dependencies: + cliui: 7.0.4 + escalade: 3.1.1 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 20.2.9 + + /yargs@17.7.1: + resolution: {integrity: sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==} + engines: {node: '>=12'} + dependencies: + cliui: 8.0.1 + escalade: 3.1.1 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 21.1.1 + + /yargs@3.32.0: + resolution: {integrity: sha512-ONJZiimStfZzhKamYvR/xvmgW3uEkAUFSP91y2caTEPhzF6uP2JfPiVZcq66b/YR0C3uitxSV7+T1x8p5bkmMg==} + dependencies: + camelcase: 2.1.1 + cliui: 3.2.0 + decamelize: 1.2.0 + os-locale: 1.4.0 + string-width: 1.0.2 + window-size: 0.1.4 + y18n: 3.2.2 + + /yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + dev: true + + /yoga-wasm-web@0.3.3: + resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==} + + /zip-local@0.3.5: + resolution: {integrity: sha512-GRV3D5TJY+/PqyeRm5CYBs7xVrKTKzljBoEXvocZu0HJ7tPEcgpSOYa2zFIsCZWgKWMuc4U3yMFgFkERGFIB9w==} + dependencies: + async: 1.5.2 + graceful-fs: 4.2.11 + jszip: 2.7.0 + q: 1.5.1 + + /zip-stream@4.1.0: + resolution: {integrity: sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==} + engines: {node: '>= 10'} + dependencies: + archiver-utils: 2.1.0 + compress-commons: 4.1.1 + readable-stream: 3.6.2 + + /zod@3.21.4: + resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==} diff --git a/console/pnpm-workspace.yaml b/console/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/console/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/console/sst.config.ts b/console/sst.config.ts new file mode 100644 index 0000000000..0cee143517 --- /dev/null +++ b/console/sst.config.ts @@ -0,0 +1,19 @@ +import { SSTConfig } from "sst"; +import { API } from "./stacks/api"; +import { Web } from "./stacks/web"; +import { Auth } from "./stacks/auth"; +import { Secrets } from "./stacks/secrets"; +import { Events } from "./stacks/events"; + +export default { + config(_input) { + return { + name: "console", + region: "us-east-1", + profile: "sst-dev", + }; + }, + stacks(app) { + app.stack(Secrets).stack(Auth).stack(Events).stack(API).stack(Web); + }, +} satisfies SSTConfig; diff --git a/console/stacks/api.ts b/console/stacks/api.ts new file mode 100644 index 0000000000..762f5cc750 --- /dev/null +++ b/console/stacks/api.ts @@ -0,0 +1,29 @@ +import { StackContext, Api, use } from "sst/constructs"; +import { Auth } from "./auth"; +import { Secrets } from "./secrets"; +import { Events } from "./events"; + +export function API({ stack }: StackContext) { + const auth = use(Auth); + const secrets = use(Secrets); + const bus = use(Events); + + const api = new Api(stack, "api", { + defaults: { + function: { + bind: [auth, ...Object.values(secrets.database), bus], + }, + }, + routes: { + "GET /": "packages/functions/src/lambda.handler", + "POST /replicache/pull": "packages/functions/src/replicache/pull.handler", + "POST /replicache/push": "packages/functions/src/replicache/push.handler", + }, + }); + + stack.addOutputs({ + ApiEndpoint: api.url, + }); + + return api; +} diff --git a/console/stacks/auth.ts b/console/stacks/auth.ts new file mode 100644 index 0000000000..174b0cdf74 --- /dev/null +++ b/console/stacks/auth.ts @@ -0,0 +1,25 @@ +import { StackContext, use } from "sst/constructs"; +import { Auth as SSTAuth } from "sst/constructs/future"; +import { Secrets } from "./secrets"; + +export function Auth({ stack }: StackContext) { + const { github, database } = use(Secrets); + const auth = new SSTAuth(stack, "auth", { + authenticator: { + handler: "packages/functions/src/auth.handler", + bind: [ + github.GITHUB_CLIENT_ID, + github.GITHUB_CLIENT_SECRET, + database.PLANETSCALE_HOST, + database.PLANETSCALE_PASSWORD, + database.PLANETSCALE_USERNAME, + ], + }, + }); + + stack.addOutputs({ + AuthEndpoint: auth.url, + }); + + return auth; +} diff --git a/console/stacks/events.ts b/console/stacks/events.ts new file mode 100644 index 0000000000..4d386e58a0 --- /dev/null +++ b/console/stacks/events.ts @@ -0,0 +1,62 @@ +import { + EventBus, + FunctionProps, + Queue, + StackContext, + Function, + toCdkDuration, + use, +} from "sst/constructs"; +import { Secrets } from "./secrets"; +import { LambdaDestination } from "aws-cdk-lib/aws-lambda-destinations"; + +export function Events({ stack }: StackContext) { + const bus = new EventBus(stack, "bus"); + + const redriver = new Queue(stack, `bus-redriver`, { + consumer: { + function: { + handler: "packages/functions/src/events/redriver.handler", + permissions: ["lambda"], + }, + }, + }); + + const onFailure = new Function(stack, `bus-onFailure`, { + handler: "packages/functions/src/events/dlq.handler", + bind: [redriver], + }); + + function subscribe(name: string, fn: FunctionProps) { + const stripped = name.replace(/\./g, "_"); + bus.addRules(stack, { + [stripped]: { + pattern: { + detailType: [name], + }, + targets: { + handler: { + function: { + ...fn, + onFailure: new LambdaDestination(onFailure), + }, + }, + }, + }, + }); + } + + const secrets = use(Secrets); + + subscribe("aws.account.created", { + handler: "packages/functions/src/events/aws-account-created.handler", + }); + + subscribe("app.stage.connected", { + handler: "packages/functions/src/events/app-stage-connected.handler", + bind: [...Object.values(secrets.database)], + permissions: ["sts"], + }); + + return bus; +} diff --git a/console/stacks/secrets.ts b/console/stacks/secrets.ts new file mode 100644 index 0000000000..8ef32a95ff --- /dev/null +++ b/console/stacks/secrets.ts @@ -0,0 +1,17 @@ +import { Config, StackContext } from "sst/constructs"; + +export function Secrets(ctx: StackContext) { + return { + database: Config.Secret.create( + ctx.stack, + "PLANETSCALE_HOST", + "PLANETSCALE_USERNAME", + "PLANETSCALE_PASSWORD" + ), + github: Config.Secret.create( + ctx.stack, + "GITHUB_CLIENT_ID", + "GITHUB_CLIENT_SECRET" + ), + }; +} diff --git a/console/stacks/web.ts b/console/stacks/web.ts new file mode 100644 index 0000000000..fd9dc12374 --- /dev/null +++ b/console/stacks/web.ts @@ -0,0 +1,13 @@ +import { Api, StackContext, StaticSite, use } from "sst/constructs"; +import { API } from "./api"; +import { Auth } from "./auth"; + +export function Web(ctx: StackContext) { + const workspace = new StaticSite(ctx.stack, "workspace", { + path: "./packages/web/workspace", + environment: { + VITE_API_URL: use(API).url, + VITE_AUTH_URL: use(Auth).url, + }, + }); +} diff --git a/console/tsconfig.json b/console/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/console/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index bae80fcfad..0000000000 --- a/examples/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -pnpm-lock.yaml -package-lock.json -yarn.lock -bun.lockb diff --git a/examples/api-auth-auth0/.gitignore b/examples/api-auth-auth0/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-auth0/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-auth0/.vscode/launch.json b/examples/api-auth-auth0/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-auth0/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-auth0/.vscode/settings.json b/examples/api-auth-auth0/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-auth0/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-auth0/README.md b/examples/api-auth-auth0/README.md new file mode 100644 index 0000000000..2b85b2df71 --- /dev/null +++ b/examples/api-auth-auth0/README.md @@ -0,0 +1,40 @@ +# How to add Auth0 authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-auth0-authentication-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-auth0 +# Or with Yarn +$ yarn create sst --template=examples/api-auth-auth0 +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-auth0/package.json b/examples/api-auth-auth0/package.json new file mode 100644 index 0000000000..1d3702d60d --- /dev/null +++ b/examples/api-auth-auth0/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-auth0", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-auth0/packages/core/package.json b/examples/api-auth-auth0/packages/core/package.json new file mode 100644 index 0000000000..9322b9777f --- /dev/null +++ b/examples/api-auth-auth0/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-auth0/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-auth0/packages/core/sst-env.d.ts b/examples/api-auth-auth0/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-auth0/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-auth0/packages/core/tsconfig.json b/examples/api-auth-auth0/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-auth0/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-auth0/packages/functions/package.json b/examples/api-auth-auth0/packages/functions/package.json new file mode 100644 index 0000000000..8e3ae0897d --- /dev/null +++ b/examples/api-auth-auth0/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-auth0/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-auth0/packages/functions/src/private.ts b/examples/api-auth-auth0/packages/functions/src/private.ts new file mode 100644 index 0000000000..fddf773355 --- /dev/null +++ b/examples/api-auth-auth0/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.iam.cognitoIdentity.identityId}!`, + }; +}; diff --git a/examples/api-auth-auth0/packages/functions/src/public.ts b/examples/api-auth-auth0/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-auth0/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-auth0/packages/functions/sst-env.d.ts b/examples/api-auth-auth0/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-auth0/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-auth0/packages/functions/tsconfig.json b/examples/api-auth-auth0/packages/functions/tsconfig.json new file mode 100644 index 0000000000..ff791a520c --- /dev/null +++ b/examples/api-auth-auth0/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-auth0/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-auth0/pnpm-workspace.yaml b/examples/api-auth-auth0/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-auth0/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-auth0/sst.config.ts b/examples/api-auth-auth0/sst.config.ts new file mode 100644 index 0000000000..dc8650622d --- /dev/null +++ b/examples/api-auth-auth0/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-auth0", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-auth0/stacks/ExampleStack.ts b/examples/api-auth-auth0/stacks/ExampleStack.ts new file mode 100644 index 0000000000..c235f6607c --- /dev/null +++ b/examples/api-auth-auth0/stacks/ExampleStack.ts @@ -0,0 +1,36 @@ +import { StackContext, Api, Cognito } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + defaults: { + authorizer: "iam", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // Create auth provider + const auth = new Cognito(stack, "Auth", { + identityPoolFederation: { + auth0: { + domain: "https://myorg.us.auth0.com", + clientId: "UsGRQJJz5sDfPQDs6bhQ9Oc3hNISuVif", + }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + IdentityPoolId: auth.cognitoIdentityPoolId, + }); +} diff --git a/examples/api-auth-auth0/tsconfig.json b/examples/api-auth-auth0/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-auth0/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-cognito/.gitignore b/examples/api-auth-cognito/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-cognito/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-cognito/.vscode/launch.json b/examples/api-auth-cognito/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-cognito/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-cognito/.vscode/settings.json b/examples/api-auth-cognito/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-cognito/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-cognito/README.md b/examples/api-auth-cognito/README.md new file mode 100644 index 0000000000..bbe292f269 --- /dev/null +++ b/examples/api-auth-cognito/README.md @@ -0,0 +1,40 @@ +# How to add Cognito authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-cognito-authentication-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-cognito +# Or with Yarn +$ yarn create sst --template=examples/api-auth-cognito +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-cognito/package.json b/examples/api-auth-cognito/package.json new file mode 100644 index 0000000000..bf799affed --- /dev/null +++ b/examples/api-auth-cognito/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-cognito", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-cognito/packages/core/package.json b/examples/api-auth-cognito/packages/core/package.json new file mode 100644 index 0000000000..393c880695 --- /dev/null +++ b/examples/api-auth-cognito/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-cognito/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-cognito/packages/core/sst-env.d.ts b/examples/api-auth-cognito/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-cognito/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-cognito/packages/core/tsconfig.json b/examples/api-auth-cognito/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-cognito/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-cognito/packages/functions/package.json b/examples/api-auth-cognito/packages/functions/package.json new file mode 100644 index 0000000000..a043770a22 --- /dev/null +++ b/examples/api-auth-cognito/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-cognito/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-cognito/packages/functions/src/private.ts b/examples/api-auth-cognito/packages/functions/src/private.ts new file mode 100644 index 0000000000..fddf773355 --- /dev/null +++ b/examples/api-auth-cognito/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.iam.cognitoIdentity.identityId}!`, + }; +}; diff --git a/examples/api-auth-cognito/packages/functions/src/public.ts b/examples/api-auth-cognito/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-cognito/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-cognito/packages/functions/sst-env.d.ts b/examples/api-auth-cognito/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-cognito/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-cognito/packages/functions/tsconfig.json b/examples/api-auth-cognito/packages/functions/tsconfig.json new file mode 100644 index 0000000000..0408cf089d --- /dev/null +++ b/examples/api-auth-cognito/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-cognito/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-cognito/pnpm-workspace.yaml b/examples/api-auth-cognito/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-cognito/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-cognito/sst.config.ts b/examples/api-auth-cognito/sst.config.ts new file mode 100644 index 0000000000..e7519ca9ed --- /dev/null +++ b/examples/api-auth-cognito/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-cognito", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-cognito/stacks/ExampleStack.ts b/examples/api-auth-cognito/stacks/ExampleStack.ts new file mode 100644 index 0000000000..049a9920e9 --- /dev/null +++ b/examples/api-auth-cognito/stacks/ExampleStack.ts @@ -0,0 +1,33 @@ +import { Api, Cognito, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + defaults: { + authorizer: "iam", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // Create auth provider + const auth = new Cognito(stack, "Auth", { + login: ["email"], + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + UserPoolId: auth.userPoolId, + UserPoolClientId: auth.userPoolClientId, + IdentityPoolId: auth.cognitoIdentityPoolId, + }); +} diff --git a/examples/api-auth-cognito/tsconfig.json b/examples/api-auth-cognito/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-cognito/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-facebook/.gitignore b/examples/api-auth-facebook/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-facebook/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-facebook/.vscode/launch.json b/examples/api-auth-facebook/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-facebook/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-facebook/.vscode/settings.json b/examples/api-auth-facebook/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-facebook/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-facebook/README.md b/examples/api-auth-facebook/README.md new file mode 100644 index 0000000000..5db1e5b37d --- /dev/null +++ b/examples/api-auth-facebook/README.md @@ -0,0 +1,40 @@ +# How to add Facebook authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-facebook-authentication-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-facebook +# Or with Yarn +$ yarn create sst --template=examples/api-auth-facebook +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-facebook/package.json b/examples/api-auth-facebook/package.json new file mode 100644 index 0000000000..3820456ed5 --- /dev/null +++ b/examples/api-auth-facebook/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-facebook", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-facebook/packages/core/package.json b/examples/api-auth-facebook/packages/core/package.json new file mode 100644 index 0000000000..4dd8105da8 --- /dev/null +++ b/examples/api-auth-facebook/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-facebook/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-facebook/packages/core/sst-env.d.ts b/examples/api-auth-facebook/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-facebook/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-facebook/packages/core/tsconfig.json b/examples/api-auth-facebook/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-facebook/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-facebook/packages/functions/package.json b/examples/api-auth-facebook/packages/functions/package.json new file mode 100644 index 0000000000..01d2287995 --- /dev/null +++ b/examples/api-auth-facebook/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-facebook/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-facebook/packages/functions/src/private.ts b/examples/api-auth-facebook/packages/functions/src/private.ts new file mode 100644 index 0000000000..fddf773355 --- /dev/null +++ b/examples/api-auth-facebook/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.iam.cognitoIdentity.identityId}!`, + }; +}; diff --git a/examples/api-auth-facebook/packages/functions/src/public.ts b/examples/api-auth-facebook/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-facebook/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-facebook/packages/functions/sst-env.d.ts b/examples/api-auth-facebook/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-facebook/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-facebook/packages/functions/tsconfig.json b/examples/api-auth-facebook/packages/functions/tsconfig.json new file mode 100644 index 0000000000..9b3015d8e9 --- /dev/null +++ b/examples/api-auth-facebook/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-facebook/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-facebook/pnpm-workspace.yaml b/examples/api-auth-facebook/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-facebook/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-facebook/sst.config.ts b/examples/api-auth-facebook/sst.config.ts new file mode 100644 index 0000000000..21d8ec3c47 --- /dev/null +++ b/examples/api-auth-facebook/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-facebook", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-facebook/stacks/ExampleStack.ts b/examples/api-auth-facebook/stacks/ExampleStack.ts new file mode 100644 index 0000000000..6ec67eb249 --- /dev/null +++ b/examples/api-auth-facebook/stacks/ExampleStack.ts @@ -0,0 +1,33 @@ +import { Api, Cognito, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + defaults: { + authorizer: "iam", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // Create auth provider + const auth = new Cognito(stack, "Auth", { + identityPoolFederation: { + facebook: { appId: "419718329085014" }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + IdentityPoolId: auth.cognitoIdentityPoolId, + }); +} diff --git a/examples/api-auth-facebook/tsconfig.json b/examples/api-auth-facebook/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-facebook/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-google/.gitignore b/examples/api-auth-google/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-google/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-google/.vscode/launch.json b/examples/api-auth-google/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-google/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-google/.vscode/settings.json b/examples/api-auth-google/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-google/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-google/README.md b/examples/api-auth-google/README.md new file mode 100644 index 0000000000..961050bae1 --- /dev/null +++ b/examples/api-auth-google/README.md @@ -0,0 +1,40 @@ +# How to add Google authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-google-authentication-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-google +# Or with Yarn +$ yarn create sst --template=examples/api-auth-google +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-google/package.json b/examples/api-auth-google/package.json new file mode 100644 index 0000000000..75803efb21 --- /dev/null +++ b/examples/api-auth-google/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-google", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-google/packages/core/package.json b/examples/api-auth-google/packages/core/package.json new file mode 100644 index 0000000000..1a3837f0c2 --- /dev/null +++ b/examples/api-auth-google/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-google/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-google/packages/core/sst-env.d.ts b/examples/api-auth-google/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-google/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-google/packages/core/tsconfig.json b/examples/api-auth-google/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-google/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-google/packages/functions/package.json b/examples/api-auth-google/packages/functions/package.json new file mode 100644 index 0000000000..901b5d60cc --- /dev/null +++ b/examples/api-auth-google/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-google/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-google/packages/functions/src/private.ts b/examples/api-auth-google/packages/functions/src/private.ts new file mode 100644 index 0000000000..fddf773355 --- /dev/null +++ b/examples/api-auth-google/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.iam.cognitoIdentity.identityId}!`, + }; +}; diff --git a/examples/api-auth-google/packages/functions/src/public.ts b/examples/api-auth-google/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-google/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-google/packages/functions/sst-env.d.ts b/examples/api-auth-google/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-google/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-google/packages/functions/tsconfig.json b/examples/api-auth-google/packages/functions/tsconfig.json new file mode 100644 index 0000000000..b59e8d6d81 --- /dev/null +++ b/examples/api-auth-google/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-google/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-google/pnpm-workspace.yaml b/examples/api-auth-google/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-google/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-google/sst.config.ts b/examples/api-auth-google/sst.config.ts new file mode 100644 index 0000000000..0c45f0a849 --- /dev/null +++ b/examples/api-auth-google/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-google", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-google/stacks/ExampleStack.ts b/examples/api-auth-google/stacks/ExampleStack.ts new file mode 100644 index 0000000000..731b782799 --- /dev/null +++ b/examples/api-auth-google/stacks/ExampleStack.ts @@ -0,0 +1,36 @@ +import { Api, Cognito, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + defaults: { + authorizer: "iam", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // Create auth provider + const auth = new Cognito(this, "Auth", { + identityPoolFederation: { + google: { + clientId: + "38017095028-abcdjaaaidbgt3kfhuoh3n5ts08vodt3.apps.googleusercontent.com", + }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + IdentityPoolId: auth.cognitoIdentityPoolId, + }); +} diff --git a/examples/api-auth-google/tsconfig.json b/examples/api-auth-google/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-google/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-jwt-auth0/.gitignore b/examples/api-auth-jwt-auth0/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-jwt-auth0/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-jwt-auth0/.vscode/launch.json b/examples/api-auth-jwt-auth0/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-jwt-auth0/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-jwt-auth0/.vscode/settings.json b/examples/api-auth-jwt-auth0/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-jwt-auth0/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-jwt-auth0/README.md b/examples/api-auth-jwt-auth0/README.md new file mode 100644 index 0000000000..f0d1d5c249 --- /dev/null +++ b/examples/api-auth-jwt-auth0/README.md @@ -0,0 +1,40 @@ +# How to add JWT authorization with Auth0 to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-jwt-authorization-with-auth0-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-jwt-auth0 +# Or with Yarn +$ yarn create sst --template=examples/api-auth-jwt-auth0 +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-jwt-auth0/package.json b/examples/api-auth-jwt-auth0/package.json new file mode 100644 index 0000000000..e695effc19 --- /dev/null +++ b/examples/api-auth-jwt-auth0/package.json @@ -0,0 +1,27 @@ +{ + "name": "api-auth-jwt-auth0", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@types/node": "^20.3.1" + } +} \ No newline at end of file diff --git a/examples/api-auth-jwt-auth0/packages/core/package.json b/examples/api-auth-jwt-auth0/packages/core/package.json new file mode 100644 index 0000000000..45e40e7f47 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-jwt-auth0/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-jwt-auth0/packages/core/sst-env.d.ts b/examples/api-auth-jwt-auth0/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-jwt-auth0/packages/core/tsconfig.json b/examples/api-auth-jwt-auth0/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/aws-auth-react/packages/web/.gitignore b/examples/api-auth-jwt-auth0/packages/frontend/.gitignore similarity index 100% rename from examples/aws-auth-react/packages/web/.gitignore rename to examples/api-auth-jwt-auth0/packages/frontend/.gitignore diff --git a/examples/api-auth-jwt-auth0/packages/frontend/index.html b/examples/api-auth-jwt-auth0/packages/frontend/index.html new file mode 100644 index 0000000000..e7977b3e86 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/index.html @@ -0,0 +1,19 @@ + + + + + + + Vite App + + +
+ + + + diff --git a/examples/api-auth-jwt-auth0/packages/frontend/package.json b/examples/api-auth-jwt-auth0/packages/frontend/package.json new file mode 100644 index 0000000000..8ee2a64543 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/package.json @@ -0,0 +1,22 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@auth0/auth0-react": "^1.10.1", + "aws-amplify": "^4.3.23", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.9" + } +} diff --git a/examples/api-auth-jwt-auth0/packages/frontend/src/App.jsx b/examples/api-auth-jwt-auth0/packages/frontend/src/App.jsx new file mode 100644 index 0000000000..2c45de7088 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/src/App.jsx @@ -0,0 +1,62 @@ +import { API } from "aws-amplify"; +import React from "react"; +import { useAuth0 } from "@auth0/auth0-react"; + +const App = () => { + const { + loginWithRedirect, + logout, + user, + isAuthenticated, + isLoading, + getAccessTokenSilently, + } = useAuth0(); + + const publicRequest = async () => { + const response = await API.get("api", "/public"); + alert(JSON.stringify(response)); + }; + + const privateRequest = async () => { + try { + const accessToken = await getAccessTokenSilently({ + audience: `https://${import.meta.env.VITE_APP_AUTH0_DOMAIN}/api/v2/`, + scope: "read:current_user", + }); + const response = await API.get("api", "/private", { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); + alert(JSON.stringify(response)); + } catch (error) { + alert(error); + } + }; + + if (isLoading) return
Loading...
; + + return ( +
+

SST + Auth0 + React

+ {isAuthenticated ? ( +
+

Welcome!

+

{user.email}

+ +
+ ) : ( +
+

Not signed in

+ +
+ )} +
+ + +
+
+ ); +}; + +export default App; diff --git a/examples/api-auth-jwt-auth0/packages/frontend/src/favicon.svg b/examples/api-auth-jwt-auth0/packages/frontend/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-auth-jwt-auth0/packages/frontend/src/index.css b/examples/api-auth-jwt-auth0/packages/frontend/src/index.css new file mode 100644 index 0000000000..46638585ec --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/src/index.css @@ -0,0 +1,51 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 120px; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} +.api-section { + width: 100%; + margin-top: 20px; + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} + +.api-section > button { + background-color: darkorange; +} diff --git a/examples/api-auth-jwt-auth0/packages/frontend/src/logo.svg b/examples/api-auth-jwt-auth0/packages/frontend/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-auth-jwt-auth0/packages/frontend/src/main.jsx b/examples/api-auth-jwt-auth0/packages/frontend/src/main.jsx new file mode 100644 index 0000000000..f105a6dc5b --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/src/main.jsx @@ -0,0 +1,32 @@ +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App"; +import "./index.css"; +import { Auth0Provider } from "@auth0/auth0-react"; +import Amplify from "aws-amplify"; + +Amplify.configure({ + API: { + endpoints: [ + { + name: "api", + endpoint: import.meta.env.VITE_APP_API_URL, + region: import.meta.env.VITE_APP_REGION, + }, + ], + }, +}); + +ReactDOM.createRoot(document.getElementById("root")).render( + + + + + +); diff --git a/examples/api-auth-jwt-auth0/packages/frontend/src/sst-env.d.ts b/examples/api-auth-jwt-auth0/packages/frontend/src/sst-env.d.ts new file mode 100644 index 0000000000..afa5be7980 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/src/sst-env.d.ts @@ -0,0 +1,12 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_AUTH0_DOMAIN: string; + readonly VITE_APP_AUTH0_CLIENT_ID: string; + readonly VITE_APP_API_URL: string; + readonly VITE_APP_REGION: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/examples/api-auth-jwt-auth0/packages/frontend/vite.config.js b/examples/api-auth-jwt-auth0/packages/frontend/vite.config.js new file mode 100644 index 0000000000..6c2d354db1 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/frontend/vite.config.js @@ -0,0 +1,12 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + resolve: { + alias: { + "./runtimeConfig": "./runtimeConfig.browser", + }, + }, + plugins: [react()], +}); diff --git a/examples/api-auth-jwt-auth0/packages/functions/package.json b/examples/api-auth-jwt-auth0/packages/functions/package.json new file mode 100644 index 0000000000..ace06ce321 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-jwt-auth0/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-jwt-auth0/packages/functions/src/private.ts b/examples/api-auth-jwt-auth0/packages/functions/src/private.ts new file mode 100644 index 0000000000..a2c8800755 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/functions/src/private.ts @@ -0,0 +1,10 @@ +import { APIGatewayProxyHandlerV2WithJWTAuthorizer } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2WithJWTAuthorizer = async ( + event +) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.jwt.claims.sub}!`, + }; +}; diff --git a/examples/api-auth-jwt-auth0/packages/functions/src/public.ts b/examples/api-auth-jwt-auth0/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-jwt-auth0/packages/functions/sst-env.d.ts b/examples/api-auth-jwt-auth0/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-jwt-auth0/packages/functions/tsconfig.json b/examples/api-auth-jwt-auth0/packages/functions/tsconfig.json new file mode 100644 index 0000000000..6d4fc40489 --- /dev/null +++ b/examples/api-auth-jwt-auth0/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-jwt-auth0/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-jwt-auth0/pnpm-workspace.yaml b/examples/api-auth-jwt-auth0/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-jwt-auth0/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-jwt-auth0/sst.config.ts b/examples/api-auth-jwt-auth0/sst.config.ts new file mode 100644 index 0000000000..48797811b3 --- /dev/null +++ b/examples/api-auth-jwt-auth0/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-jwt-auth0", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-jwt-auth0/stacks/ExampleStack.ts b/examples/api-auth-jwt-auth0/stacks/ExampleStack.ts new file mode 100644 index 0000000000..e2b1431eb2 --- /dev/null +++ b/examples/api-auth-jwt-auth0/stacks/ExampleStack.ts @@ -0,0 +1,44 @@ +import { StackContext, Api, StaticSite } from "sst/constructs"; + +export function ExampleStack({ stack, app }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + authorizers: { + auth0: { + type: "jwt", + jwt: { + issuer: process.env.AUTH0_DOMAIN!, + audience: [process.env.AUTH0_DOMAIN + "api/v2/"], + }, + }, + }, + defaults: { + authorizer: "auth0", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + const site = new StaticSite(stack, "Site", { + path: "packages/frontend", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_AUTH0_DOMAIN: process.env.AUTH0_DOMAIN!, + VITE_APP_AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID!, + VITE_APP_API_URL: api.url, + VITE_APP_REGION: app.region, + }, + }); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + SiteUrl: site.url, + }); +} diff --git a/examples/api-auth-jwt-auth0/tsconfig.json b/examples/api-auth-jwt-auth0/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-jwt-auth0/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-jwt-cognito-user-pool/.gitignore b/examples/api-auth-jwt-cognito-user-pool/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-jwt-cognito-user-pool/.vscode/launch.json b/examples/api-auth-jwt-cognito-user-pool/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-jwt-cognito-user-pool/.vscode/settings.json b/examples/api-auth-jwt-cognito-user-pool/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-jwt-cognito-user-pool/README.md b/examples/api-auth-jwt-cognito-user-pool/README.md new file mode 100644 index 0000000000..32c044cd1c --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/README.md @@ -0,0 +1,40 @@ +# How to add JWT authorization with Cognito User Pool to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-jwt-authorization-with-cognito-user-pool-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-jwt-cognito-user-pool +# Or with Yarn +$ yarn create sst --template=examples/api-auth-jwt-cognito-user-pool +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-jwt-cognito-user-pool/package.json b/examples/api-auth-jwt-cognito-user-pool/package.json new file mode 100644 index 0000000000..48ee8d1e0c --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-jwt-cognito-user-pool", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/core/package.json b/examples/api-auth-jwt-cognito-user-pool/packages/core/package.json new file mode 100644 index 0000000000..c55f3f624e --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-jwt-cognito-user-pool/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/core/sst-env.d.ts b/examples/api-auth-jwt-cognito-user-pool/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/core/tsconfig.json b/examples/api-auth-jwt-cognito-user-pool/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/aws-realtime/web/.gitignore b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/.gitignore similarity index 100% rename from examples/aws-realtime/web/.gitignore rename to examples/api-auth-jwt-cognito-user-pool/packages/frontend/.gitignore diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/index.html b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/index.html new file mode 100644 index 0000000000..e7977b3e86 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/index.html @@ -0,0 +1,19 @@ + + + + + + + Vite App + + +
+ + + + diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/package.json b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/package.json new file mode 100644 index 0000000000..7f760e06be --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/package.json @@ -0,0 +1,21 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "aws-amplify": "^4.3.24", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.9" + } +} diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/App.jsx b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/App.jsx new file mode 100644 index 0000000000..e230f3b28b --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/App.jsx @@ -0,0 +1,79 @@ +import { Auth, API } from "aws-amplify"; +import React, { useState, useEffect } from "react"; +import Login from "./components/Login"; +import Signup from "./components/Signup"; + +const App = () => { + const [user, setUser] = useState(null); + const [loading, setLoading] = useState(true); + const [screen, setScreen] = useState("signup"); + + // Get the current logged in user info + const getUser = async () => { + const user = await Auth.currentUserInfo(); + if (user) setUser(user); + setLoading(false); + }; + + // Logout the authenticated user + const signOut = async () => { + await Auth.signOut(); + setUser(null); + }; + + // Send an API call to the /public endpoint + const publicRequest = async () => { + const response = await API.get("api", "/public"); + alert(JSON.stringify(response)); + }; + + // Send an API call to the /private endpoint with authentication details. + const privateRequest = async () => { + try { + const response = await API.get("api", "/private", { + headers: { + Authorization: `Bearer ${(await Auth.currentSession()) + .getAccessToken() + .getJwtToken()}`, + }, + }); + alert(JSON.stringify(response)); + } catch (error) { + alert(error); + } + }; + + // Check if there's any user on mount + useEffect(() => { + getUser(); + }, []); + + if (loading) return
Loading...
; + + return ( +
+

SST + Cognito + React

+ {user ? ( +
+

Welcome {user.attributes.given_name}!

+

{user.attributes.email}

+ +
+ ) : ( +
+ {screen === "signup" ? ( + + ) : ( + + )} +
+ )} +
+ + +
+
+ ); +}; + +export default App; diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/components/Login.jsx b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/components/Login.jsx new file mode 100644 index 0000000000..2f7c078a67 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/components/Login.jsx @@ -0,0 +1,36 @@ +import { useState } from "react"; +import { Auth } from "aws-amplify"; + +export default function Login({ setScreen, setUser }) { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + + return ( +
+ setEmail(e.target.value)} + /> + setPassword(e.target.value)} + /> + + + setScreen("signup")}> + Don't have an account? Sign up + +
+ ); +} diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/components/Signup.jsx b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/components/Signup.jsx new file mode 100644 index 0000000000..fffe3afde4 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/components/Signup.jsx @@ -0,0 +1,54 @@ +import { useState } from "react"; +import { Auth } from "aws-amplify"; + +export default function Signup({ setScreen }) { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [code, setCode] = useState(""); + const [verifying, setVerifying] = useState(false); + + return ( +
+ setEmail(e.target.value)} + /> + setPassword(e.target.value)} + /> + {verifying && ( + setCode(e.target.value)} + /> + )} + + setScreen("login")}> + Already have an account? Login + +
+ ); +} diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/favicon.svg b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/index.css b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/index.css new file mode 100644 index 0000000000..41c7c8cc21 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/index.css @@ -0,0 +1,68 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 120px; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} +.api-section { + width: 100%; + margin-top: 20px; + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} + +.api-section > button { + background-color: darkorange; +} + +input { + width: 100%; + padding: 10px; + border: none; + border-radius: 4px; + font-size: 16px; + cursor: pointer; +} + +.signup, +.login { + display: flex; + flex-direction: column; + gap: 20px; + align-items: center; +} diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/logo.svg b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/main.jsx b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/main.jsx new file mode 100644 index 0000000000..dbbbfa09c5 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/main.jsx @@ -0,0 +1,28 @@ +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App"; +import "./index.css"; +import Amplify from "aws-amplify"; + +Amplify.configure({ + Auth: { + region: import.meta.env.VITE_APP_REGION, + userPoolId: import.meta.env.VITE_APP_USER_POOL_ID, + userPoolWebClientId: import.meta.env.VITE_APP_USER_POOL_CLIENT_ID, + }, + API: { + endpoints: [ + { + name: "api", + endpoint: import.meta.env.VITE_APP_API_URL, + region: import.meta.env.VITE_APP_REGION, + }, + ], + }, +}); + +ReactDOM.createRoot(document.getElementById("root")).render( + + + +); diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/sst-env.d.ts b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/sst-env.d.ts new file mode 100644 index 0000000000..6b86bd69f1 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/src/sst-env.d.ts @@ -0,0 +1,12 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_API_URL: string; + readonly VITE_APP_REGION: string; + readonly VITE_APP_USER_POOL_ID: string; + readonly VITE_APP_USER_POOL_CLIENT_ID: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/frontend/vite.config.js b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/vite.config.js new file mode 100644 index 0000000000..6c2d354db1 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/frontend/vite.config.js @@ -0,0 +1,12 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + resolve: { + alias: { + "./runtimeConfig": "./runtimeConfig.browser", + }, + }, + plugins: [react()], +}); diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/functions/package.json b/examples/api-auth-jwt-cognito-user-pool/packages/functions/package.json new file mode 100644 index 0000000000..81a1f6e007 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-jwt-cognito-user-pool/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/functions/src/private.ts b/examples/api-auth-jwt-cognito-user-pool/packages/functions/src/private.ts new file mode 100644 index 0000000000..a2c8800755 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/functions/src/private.ts @@ -0,0 +1,10 @@ +import { APIGatewayProxyHandlerV2WithJWTAuthorizer } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2WithJWTAuthorizer = async ( + event +) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.jwt.claims.sub}!`, + }; +}; diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/functions/src/public.ts b/examples/api-auth-jwt-cognito-user-pool/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/functions/sst-env.d.ts b/examples/api-auth-jwt-cognito-user-pool/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-jwt-cognito-user-pool/packages/functions/tsconfig.json b/examples/api-auth-jwt-cognito-user-pool/packages/functions/tsconfig.json new file mode 100644 index 0000000000..7897db8e51 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-jwt-cognito-user-pool/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-jwt-cognito-user-pool/pnpm-workspace.yaml b/examples/api-auth-jwt-cognito-user-pool/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-jwt-cognito-user-pool/sst.config.ts b/examples/api-auth-jwt-cognito-user-pool/sst.config.ts new file mode 100644 index 0000000000..869dc1662b --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-jwt-cognito-user-pool", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-jwt-cognito-user-pool/stacks/ExampleStack.ts b/examples/api-auth-jwt-cognito-user-pool/stacks/ExampleStack.ts new file mode 100644 index 0000000000..43842c5ccf --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/stacks/ExampleStack.ts @@ -0,0 +1,54 @@ +import { Api, Cognito, StaticSite, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack, app }: StackContext) { + // Create User Pool + const auth = new Cognito(stack, "Auth", { + login: ["email"], + }); + + // Create Api + const api = new Api(stack, "Api", { + authorizers: { + jwt: { + type: "user_pool", + userPool: { + id: auth.userPoolId, + clientIds: [auth.userPoolClientId], + }, + }, + }, + defaults: { + authorizer: "jwt", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // attach permissions for authenticated users to the api + auth.attachPermissionsForAuthUsers(stack, [api]); + + const site = new StaticSite(stack, "Site", { + path: "packages/frontend", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_API_URL: api.url, + VITE_APP_REGION: app.region, + VITE_APP_USER_POOL_ID: auth.userPoolId, + VITE_APP_USER_POOL_CLIENT_ID: auth.userPoolClientId, + }, + }); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + UserPoolId: auth.userPoolId, + UserPoolClientId: auth.userPoolClientId, + SiteUrl: site.url, + }); +} diff --git a/examples/api-auth-jwt-cognito-user-pool/tsconfig.json b/examples/api-auth-jwt-cognito-user-pool/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-jwt-cognito-user-pool/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/.gitignore b/examples/api-auth-lambda-authorizer-iam-response/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-lambda-authorizer-iam-response/.vscode/launch.json b/examples/api-auth-lambda-authorizer-iam-response/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/.vscode/settings.json b/examples/api-auth-lambda-authorizer-iam-response/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/README.md b/examples/api-auth-lambda-authorizer-iam-response/README.md new file mode 100644 index 0000000000..35d56b5214 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/README.md @@ -0,0 +1,66 @@ +# How to add Lambda authorizer with IAM policy response to a serverless API + +An example serverless app created with SST. + +This example creates an Api endpoint with a `/private` route and a `/public` route. The `/private` route is protected with a Lambda authorizer. The authorizer checks for the Authentication header, and authorizes the request if the Basic auth username is `admin` and the password is `password`. + +## Getting Started + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-lambda-authorizer-iam-response +# Or with Yarn +$ yarn create sst --template=examples/api-auth-lambda-authorizer-iam-response +``` + +Start the Live Lambda Development environment. + +```bash +$ npm run dev +``` + +Test the `/public` endpoint. + +```bash +$ curl https://xxxxxxxxxx.execute-api.region.amazonaws.com/public +``` + +Test the `/private` endpoint with an invalid username and password. + +```bash +$ curl -u foo:password https://xxxxxxxxxx.execute-api.region.amazonaws.com/private +``` + +Test the `/private` endpoint with a valid username and password. + +```bash +$ curl -u admin:password https://xxxxxxxxxx.execute-api.region.amazonaws.com/private +``` + +Note that the first time you hit the `/private` endpoint with a given username and password, the Lambda authorizer gets invoked to check the credentials. The authorization response will be cached for 5 minutes. Subsequent requests to `/private` with `foo:password` would fail right away without invoking the authorizer function. Similarly, subsequent requests to `/private` with `admin:password` would bypass the authorizer function. + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-lambda-authorizer-iam-response/package.json b/examples/api-auth-lambda-authorizer-iam-response/package.json new file mode 100644 index 0000000000..f55a25ff31 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-lambda-authorizer-iam-response", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/core/package.json b/examples/api-auth-lambda-authorizer-iam-response/packages/core/package.json new file mode 100644 index 0000000000..ff7e8aefff --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-lambda-authorizer-iam-response/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/core/sst-env.d.ts b/examples/api-auth-lambda-authorizer-iam-response/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/core/tsconfig.json b/examples/api-auth-lambda-authorizer-iam-response/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/functions/package.json b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/package.json new file mode 100644 index 0000000000..7eaf7fb544 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-lambda-authorizer-iam-response/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/authorizer.ts b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/authorizer.ts new file mode 100644 index 0000000000..ee6f296a05 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/authorizer.ts @@ -0,0 +1,27 @@ +export const main = async (event) => { + // Get authorization header + const authHeader = event.headers.authorization; + // Parse for username and password + const base64Info = authHeader.split(" ")[1]; + // Stored as 'username:password' in base64 + const userInfo = Buffer.from(base64Info, "base64").toString(); + const [username, password] = userInfo.split(":"); + + return { + principalId: username, + policyDocument: { + Version: "2012-10-17", + Statement: [ + { + Action: "execute-api:Invoke", + Effect: + username === "admin" && password === "password" ? "Allow" : "Deny", + Resource: "*", + }, + ], + }, + context: { + username, + }, + }; +}; diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/private.ts b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/private.ts new file mode 100644 index 0000000000..3fca2aed33 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.lambda.username}!`, + }; +}; diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/public.ts b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/functions/sst-env.d.ts b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-lambda-authorizer-iam-response/packages/functions/tsconfig.json b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/tsconfig.json new file mode 100644 index 0000000000..2e3cd60da3 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-lambda-authorizer-iam-response/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/pnpm-workspace.yaml b/examples/api-auth-lambda-authorizer-iam-response/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-lambda-authorizer-iam-response/sst.config.ts b/examples/api-auth-lambda-authorizer-iam-response/sst.config.ts new file mode 100644 index 0000000000..4c22144cf4 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-lambda-authorizer-iam-response", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-lambda-authorizer-iam-response/stacks/ExampleStack.ts b/examples/api-auth-lambda-authorizer-iam-response/stacks/ExampleStack.ts new file mode 100644 index 0000000000..300aa40815 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/stacks/ExampleStack.ts @@ -0,0 +1,30 @@ +import { Api, StackContext, Function } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + authorizers: { + lambda: { + type: "lambda", + function: new Function(stack, "authorizer", { + handler: "packages/functions/src/authorizer.main", + }), + }, + }, + defaults: { + authorizer: "lambda", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + }); +} diff --git a/examples/api-auth-lambda-authorizer-iam-response/tsconfig.json b/examples/api-auth-lambda-authorizer-iam-response/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-lambda-authorizer-iam-response/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/.gitignore b/examples/api-auth-lambda-authorizer-simple-response/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-lambda-authorizer-simple-response/.vscode/launch.json b/examples/api-auth-lambda-authorizer-simple-response/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/.vscode/settings.json b/examples/api-auth-lambda-authorizer-simple-response/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/README.md b/examples/api-auth-lambda-authorizer-simple-response/README.md new file mode 100644 index 0000000000..73eb79e78e --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/README.md @@ -0,0 +1,66 @@ +# How to add Lambda authorizer with simple response to a serverless API + +An example serverless app created with SST. + +This example creates an Api endpoint with a `/private` route and a `/public` route. The `/private` route is protected with a Lambda authorizer. The authorizer checks for the Authentication header, and authorizes the request if the Basic auth username is `admin` and the password is `password`. + +## Getting Started + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-lambda-authorizer-simple-response +# Or with Yarn +$ yarn create sst --template=examples/api-auth-lambda-authorizer-simple-response +``` + +Start the Live Lambda Development environment. + +```bash +$ npm run dev +``` + +Test the `/public` endpoint. + +```bash +$ curl https://xxxxxxxxxx.execute-api.region.amazonaws.com/public +``` + +Test the `/private` endpoint with an invalid username and password. + +```bash +$ curl -u foo:password https://xxxxxxxxxx.execute-api.region.amazonaws.com/private +``` + +Test the `/private` endpoint with a valid username and password. + +```bash +$ curl -u admin:password https://xxxxxxxxxx.execute-api.region.amazonaws.com/private +``` + +Note that the first time you hit the `/private` endpoint with a given username and password, the Lambda authorizer gets invoked to check the credentials. The authorization response will be cached for 5 minutes. Subsequent requests to `/private` with `foo:password` would fail right away without invoking the authorizer function. Similarly, subsequent requests to `/private` with `admin:password` would bypass the authorizer function. + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-lambda-authorizer-simple-response/package.json b/examples/api-auth-lambda-authorizer-simple-response/package.json new file mode 100644 index 0000000000..2acd36c4b4 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-lambda-authorizer-simple-response", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/core/package.json b/examples/api-auth-lambda-authorizer-simple-response/packages/core/package.json new file mode 100644 index 0000000000..0a3eb1504f --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-lambda-authorizer-simple-response/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/core/sst-env.d.ts b/examples/api-auth-lambda-authorizer-simple-response/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/core/tsconfig.json b/examples/api-auth-lambda-authorizer-simple-response/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/functions/package.json b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/package.json new file mode 100644 index 0000000000..2f0c7bcf07 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-lambda-authorizer-simple-response/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/authorizer.ts b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/authorizer.ts new file mode 100644 index 0000000000..05cc52b45d --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/authorizer.ts @@ -0,0 +1,20 @@ +export const main = async (event) => { + // Get authorization header + const authHeader = event.headers.authorization; + + // Parse for username and password + let username, password; + if (authHeader) { + const base64Info = authHeader.split(" ")[1]; + // Stored as 'username:password' in base64 + const userInfo = Buffer.from(base64Info, "base64").toString(); + [username, password] = userInfo.split(":"); + } + + return { + isAuthorized: username === "admin" && password === "password", + context: { + username, + }, + }; +}; diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/private.ts b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/private.ts new file mode 100644 index 0000000000..3fca2aed33 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.lambda.username}!`, + }; +}; diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/public.ts b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/functions/sst-env.d.ts b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-lambda-authorizer-simple-response/packages/functions/tsconfig.json b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/tsconfig.json new file mode 100644 index 0000000000..b692982eb5 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-lambda-authorizer-simple-response/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/pnpm-workspace.yaml b/examples/api-auth-lambda-authorizer-simple-response/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-lambda-authorizer-simple-response/sst.config.ts b/examples/api-auth-lambda-authorizer-simple-response/sst.config.ts new file mode 100644 index 0000000000..7c23564f5f --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-lambda-authorizer-simple-response", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-lambda-authorizer-simple-response/stacks/ExampleStack.ts b/examples/api-auth-lambda-authorizer-simple-response/stacks/ExampleStack.ts new file mode 100644 index 0000000000..f9a0b53a7a --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/stacks/ExampleStack.ts @@ -0,0 +1,31 @@ +import { Api, StackContext, Function } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + authorizers: { + lambda: { + type: "lambda", + responseTypes: ["simple"], + function: new Function(stack, "Authorizer", { + handler: "packages/functions/src/authorizer.main", + }), + }, + }, + defaults: { + authorizer: "lambda", + }, + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "none", + }, + }, + }); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + }); +} diff --git a/examples/api-auth-lambda-authorizer-simple-response/tsconfig.json b/examples/api-auth-lambda-authorizer-simple-response/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-lambda-authorizer-simple-response/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-auth-twitter/.gitignore b/examples/api-auth-twitter/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-auth-twitter/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-auth-twitter/.vscode/launch.json b/examples/api-auth-twitter/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-auth-twitter/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-auth-twitter/.vscode/settings.json b/examples/api-auth-twitter/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-auth-twitter/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-auth-twitter/README.md b/examples/api-auth-twitter/README.md new file mode 100644 index 0000000000..beb78fae11 --- /dev/null +++ b/examples/api-auth-twitter/README.md @@ -0,0 +1,40 @@ +# How to add Twitter authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-twitter-authentication-to-a-serverless-api.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-auth-twitter +# Or with Yarn +$ yarn create sst --template=examples/api-auth-twitter +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-auth-twitter/package.json b/examples/api-auth-twitter/package.json new file mode 100644 index 0000000000..77725eb670 --- /dev/null +++ b/examples/api-auth-twitter/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-auth-twitter", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-auth-twitter/packages/core/package.json b/examples/api-auth-twitter/packages/core/package.json new file mode 100644 index 0000000000..cdfd1dee02 --- /dev/null +++ b/examples/api-auth-twitter/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-auth-twitter/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-twitter/packages/core/sst-env.d.ts b/examples/api-auth-twitter/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-twitter/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-twitter/packages/core/tsconfig.json b/examples/api-auth-twitter/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-auth-twitter/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-auth-twitter/packages/functions/package.json b/examples/api-auth-twitter/packages/functions/package.json new file mode 100644 index 0000000000..e6a965a749 --- /dev/null +++ b/examples/api-auth-twitter/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-auth-twitter/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-auth-twitter/packages/functions/src/private.ts b/examples/api-auth-twitter/packages/functions/src/private.ts new file mode 100644 index 0000000000..fddf773355 --- /dev/null +++ b/examples/api-auth-twitter/packages/functions/src/private.ts @@ -0,0 +1,8 @@ +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const main: APIGatewayProxyHandlerV2 = async (event) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.iam.cognitoIdentity.identityId}!`, + }; +}; diff --git a/examples/api-auth-twitter/packages/functions/src/public.ts b/examples/api-auth-twitter/packages/functions/src/public.ts new file mode 100644 index 0000000000..dc380d3c83 --- /dev/null +++ b/examples/api-auth-twitter/packages/functions/src/public.ts @@ -0,0 +1,6 @@ +export async function main() { + return { + statusCode: 200, + body: "Hello stranger!", + }; +} diff --git a/examples/api-auth-twitter/packages/functions/sst-env.d.ts b/examples/api-auth-twitter/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-auth-twitter/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-auth-twitter/packages/functions/tsconfig.json b/examples/api-auth-twitter/packages/functions/tsconfig.json new file mode 100644 index 0000000000..7e09b3f17c --- /dev/null +++ b/examples/api-auth-twitter/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-auth-twitter/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-auth-twitter/pnpm-workspace.yaml b/examples/api-auth-twitter/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-auth-twitter/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-auth-twitter/sst.config.ts b/examples/api-auth-twitter/sst.config.ts new file mode 100644 index 0000000000..7b1156a488 --- /dev/null +++ b/examples/api-auth-twitter/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-auth-twitter", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-auth-twitter/stacks/ExampleStack.ts b/examples/api-auth-twitter/stacks/ExampleStack.ts new file mode 100644 index 0000000000..ae5e576691 --- /dev/null +++ b/examples/api-auth-twitter/stacks/ExampleStack.ts @@ -0,0 +1,33 @@ +import { Api, Cognito, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create Api + const api = new Api(stack, "Api", { + routes: { + "GET /private": "packages/functions/src/private.main", + "GET /public": { + function: "packages/functions/src/public.main", + authorizer: "iam", + }, + }, + }); + + // Create auth provider + const auth = new Cognito(stack, "Auth", { + identityPoolFederation: { + twitter: { + consumerKey: "gyMbPOiwefr6x63SjIW8NN0d1", + consumerSecret: "qxld8zic5c2eyahqK3gjGLGQaOTogGfAgHh17MYOIcOUR9l2Nz", + }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + IdentityPoolId: auth.cognitoIdentityPoolId, + }); +} diff --git a/examples/api-auth-twitter/tsconfig.json b/examples/api-auth-twitter/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-auth-twitter/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-oauth-facebook/.gitignore b/examples/api-oauth-facebook/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-oauth-facebook/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-oauth-facebook/.vscode/launch.json b/examples/api-oauth-facebook/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-oauth-facebook/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-oauth-facebook/.vscode/settings.json b/examples/api-oauth-facebook/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-oauth-facebook/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-oauth-facebook/README.md b/examples/api-oauth-facebook/README.md new file mode 100644 index 0000000000..e6092911be --- /dev/null +++ b/examples/api-oauth-facebook/README.md @@ -0,0 +1,50 @@ +# How to add Facebook OAuth to a serverless app + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-facebook-login-to-your-cognito-user-pool.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-oauth-facebook +# Or with Yarn +$ yarn create sst --template=examples/api-oauth-facebook +``` + +## Commands + +### `yarn run start` + +Starts the local Lambda development environment. + +### `yarn run build` + +Build your app and synthesize your stacks. + +Generates a `.build/` directory with the compiled files and a `.build/cdk.out/` directory with the synthesized CloudFormation stacks. + +### `yarn run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `yarn run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +### `yarn run test` + +Runs your tests using Jest. Takes all the [Jest CLI options](https://jestjs.io/docs/en/cli). + +## Documentation + +Learn more about SST. + +- [Docs](https://docs.sst.dev) +- [sst](https://docs.sst.dev/packages/sst) + +## Community + +[Follow us on Twitter](https://twitter.com/sst_dev) or [post on our forums](https://discourse.sst.dev). diff --git a/examples/api-oauth-facebook/package.json b/examples/api-oauth-facebook/package.json new file mode 100644 index 0000000000..907fd41d9b --- /dev/null +++ b/examples/api-oauth-facebook/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-oauth-facebook", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-oauth-facebook/packages/core/package.json b/examples/api-oauth-facebook/packages/core/package.json new file mode 100644 index 0000000000..bdfe1899d3 --- /dev/null +++ b/examples/api-oauth-facebook/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-oauth-facebook/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-oauth-facebook/packages/core/sst-env.d.ts b/examples/api-oauth-facebook/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-oauth-facebook/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-oauth-facebook/packages/core/tsconfig.json b/examples/api-oauth-facebook/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-oauth-facebook/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/aws-vite/.gitignore b/examples/api-oauth-facebook/packages/frontend/.gitignore similarity index 100% rename from examples/aws-vite/.gitignore rename to examples/api-oauth-facebook/packages/frontend/.gitignore diff --git a/examples/api-oauth-facebook/packages/frontend/index.html b/examples/api-oauth-facebook/packages/frontend/index.html new file mode 100644 index 0000000000..e7977b3e86 --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/index.html @@ -0,0 +1,19 @@ + + + + + + + Vite App + + +
+ + + + diff --git a/examples/api-oauth-facebook/packages/frontend/package.json b/examples/api-oauth-facebook/packages/frontend/package.json new file mode 100644 index 0000000000..7f760e06be --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/package.json @@ -0,0 +1,21 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "aws-amplify": "^4.3.24", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.9" + } +} diff --git a/examples/api-oauth-facebook/packages/frontend/src/App.jsx b/examples/api-oauth-facebook/packages/frontend/src/App.jsx new file mode 100644 index 0000000000..601229480f --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/src/App.jsx @@ -0,0 +1,70 @@ +import { Auth, API } from "aws-amplify"; +import React, { useState, useEffect } from "react"; + +const App = () => { + const [user, setUser] = useState(null); + const [loading, setLoading] = useState(true); + + const getUser = async () => { + const user = await Auth.currentUserInfo(); + if (user) setUser(user); + setLoading(false); + }; + + const signIn = async () => + await Auth.federatedSignIn({ + provider: "Facebook", + }); + + const signOut = async () => await Auth.signOut(); + + const publicRequest = async () => { + const response = await API.get("api", "/public"); + alert(JSON.stringify(response)); + }; + + const privateRequest = async () => { + try { + const response = await API.get("api", "/private", { + headers: { + Authorization: `Bearer ${(await Auth.currentSession()) + .getAccessToken() + .getJwtToken()}`, + }, + }); + alert(JSON.stringify(response)); + } catch (error) { + alert(error); + } + }; + + useEffect(() => { + getUser(); + }, []); + + if (loading) return
Loading...
; + + return ( +
+

SST + Cognito + Facebook OAuth + React

+ {user ? ( +
+

Welcome {user.attributes.given_name}!

+

{user.attributes.email}

+ +
+ ) : ( +
+

Not signed in

+ +
+ )} +
+ + +
+
+ ); +}; + +export default App; diff --git a/examples/api-oauth-facebook/packages/frontend/src/favicon.svg b/examples/api-oauth-facebook/packages/frontend/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-oauth-facebook/packages/frontend/src/index.css b/examples/api-oauth-facebook/packages/frontend/src/index.css new file mode 100644 index 0000000000..46638585ec --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/src/index.css @@ -0,0 +1,51 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 120px; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} +.api-section { + width: 100%; + margin-top: 20px; + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} + +.api-section > button { + background-color: darkorange; +} diff --git a/examples/api-oauth-facebook/packages/frontend/src/logo.svg b/examples/api-oauth-facebook/packages/frontend/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-oauth-facebook/packages/frontend/src/main.jsx b/examples/api-oauth-facebook/packages/frontend/src/main.jsx new file mode 100644 index 0000000000..ee726ad5f1 --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/src/main.jsx @@ -0,0 +1,42 @@ +/* eslint-disable no-undef */ +import React from "react"; +import ReactDOM from "react-dom"; +import "./index.css"; +import App from "./App"; +import Amplify from "aws-amplify"; + +Amplify.configure({ + Auth: { + region: import.meta.env.VITE_APP_REGION, + userPoolId: import.meta.env.VITE_APP_USER_POOL_ID, + userPoolWebClientId: import.meta.env.VITE_APP_USER_POOL_CLIENT_ID, + mandatorySignIn: false, + oauth: { + domain: `${ + import.meta.env.VITE_APP_COGNITO_DOMAIN + + ".auth." + + import.meta.env.VITE_APP_REGION + + ".amazoncognito.com" + }`, + redirectSignIn: "http://localhost:3000", // Make sure to use the exact URL + redirectSignOut: "http://localhost:3000", // Make sure to use the exact URL + responseType: "token", // or 'token', note that REFRESH token will only be generated when the responseType is code + }, + }, + API: { + endpoints: [ + { + name: "api", + endpoint: import.meta.env.VITE_APP_API_URL, + region: import.meta.env.VITE_APP_REGION, + }, + ], + }, +}); + +ReactDOM.render( + + + , + document.getElementById("root") +); diff --git a/examples/api-oauth-facebook/packages/frontend/src/sst-env.d.ts b/examples/api-oauth-facebook/packages/frontend/src/sst-env.d.ts new file mode 100644 index 0000000000..3899f9a1b0 --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/src/sst-env.d.ts @@ -0,0 +1,14 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_COGNITO_DOMAIN: string; + readonly VITE_APP_API_URL: string; + readonly VITE_APP_REGION: string; + readonly VITE_APP_USER_POOL_ID: string; + readonly VITE_APP_IDENTITY_POOL_ID: string; + readonly VITE_APP_USER_POOL_CLIENT_ID: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/examples/api-oauth-facebook/packages/frontend/vite.config.js b/examples/api-oauth-facebook/packages/frontend/vite.config.js new file mode 100644 index 0000000000..6c2d354db1 --- /dev/null +++ b/examples/api-oauth-facebook/packages/frontend/vite.config.js @@ -0,0 +1,12 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + resolve: { + alias: { + "./runtimeConfig": "./runtimeConfig.browser", + }, + }, + plugins: [react()], +}); diff --git a/examples/api-oauth-facebook/packages/functions/package.json b/examples/api-oauth-facebook/packages/functions/package.json new file mode 100644 index 0000000000..c6a16a6d1d --- /dev/null +++ b/examples/api-oauth-facebook/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-oauth-facebook/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-oauth-facebook/packages/functions/src/private.ts b/examples/api-oauth-facebook/packages/functions/src/private.ts new file mode 100644 index 0000000000..4badf52a2b --- /dev/null +++ b/examples/api-oauth-facebook/packages/functions/src/private.ts @@ -0,0 +1,10 @@ +import { APIGatewayProxyHandlerV2WithJWTAuthorizer } from "aws-lambda"; + +export const handler: APIGatewayProxyHandlerV2WithJWTAuthorizer = async ( + event +) => { + return { + statusCode: 200, + body: `Hello ${event.requestContext.authorizer.jwt.claims.sub}!`, + }; +}; diff --git a/examples/api-oauth-facebook/packages/functions/src/public.ts b/examples/api-oauth-facebook/packages/functions/src/public.ts new file mode 100644 index 0000000000..58f35077b4 --- /dev/null +++ b/examples/api-oauth-facebook/packages/functions/src/public.ts @@ -0,0 +1,7 @@ +export async function handler() { + return { + statusCode: 200, + headers: { "Content-Type": "text/plain" }, + body: `Hello, Stranger!`, + }; +} diff --git a/examples/api-oauth-facebook/packages/functions/sst-env.d.ts b/examples/api-oauth-facebook/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-oauth-facebook/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-oauth-facebook/packages/functions/tsconfig.json b/examples/api-oauth-facebook/packages/functions/tsconfig.json new file mode 100644 index 0000000000..b7916791f5 --- /dev/null +++ b/examples/api-oauth-facebook/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-oauth-facebook/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-oauth-facebook/pnpm-workspace.yaml b/examples/api-oauth-facebook/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-oauth-facebook/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-oauth-facebook/sst.config.ts b/examples/api-oauth-facebook/sst.config.ts new file mode 100644 index 0000000000..7f294610b1 --- /dev/null +++ b/examples/api-oauth-facebook/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-oauth-facebook", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-oauth-facebook/stacks/ExampleStack.ts b/examples/api-oauth-facebook/stacks/ExampleStack.ts new file mode 100644 index 0000000000..4c4e7b1726 --- /dev/null +++ b/examples/api-oauth-facebook/stacks/ExampleStack.ts @@ -0,0 +1,105 @@ +import * as cognito from "aws-cdk-lib/aws-cognito"; +import { Api, Cognito, StaticSite, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack, app }: StackContext) { + // Create auth + const auth = new Cognito(stack, "Auth", { + cdk: { + userPoolClient: { + supportedIdentityProviders: [ + cognito.UserPoolClientIdentityProvider.FACEBOOK, + ], + oAuth: { + callbackUrls: [ + app.stage === "prod" + ? "prodDomainNameUrl" + : "http://localhost:3000", + ], + logoutUrls: [ + app.stage === "prod" + ? "prodDomainNameUrl" + : "http://localhost:3000", + ], + }, + }, + }, + }); + + // Throw error if App ID & secret are not provided + if (!process.env.FACEBOOK_APP_ID || !process.env.FACEBOOK_APP_SECRET) + throw new Error("Please set FACEBOOK_APP_ID and FACEBOOK_APP_SECRET"); + + // Create a Facebook OAuth provider + const provider = new cognito.UserPoolIdentityProviderFacebook( + stack, + "Facebook", + { + clientId: process.env.FACEBOOK_APP_ID, + clientSecret: process.env.FACEBOOK_APP_SECRET, + userPool: auth.cdk.userPool, + attributeMapping: { + email: cognito.ProviderAttribute.FACEBOOK_EMAIL, + givenName: cognito.ProviderAttribute.FACEBOOK_NAME, + }, + } + ); + + // attach the created provider to our userpool + auth.cdk.userPoolClient.node.addDependency(provider); + + // Create a cognito userpool domain + const domain = auth.cdk.userPool.addDomain("AuthDomain", { + cognitoDomain: { + domainPrefix: `${app.stage}-fb-demo-auth-domain`, + }, + }); + + // Create a HTTP API + const api = new Api(stack, "Api", { + authorizers: { + userPool: { + type: "user_pool", + userPool: { + id: auth.userPoolId, + clientIds: [auth.userPoolClientId], + }, + }, + }, + defaults: { + authorizer: "userPool", + }, + routes: { + "GET /private": "packages/functions/src/private.handler", + "GET /public": { + function: "packages/functions/src/public.handler", + authorizer: "none", + }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Create a React Static Site + const site = new StaticSite(stack, "Site", { + path: "packages/frontend", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_COGNITO_DOMAIN: domain.domainName, + VITE_APP_API_URL: api.url, + VITE_APP_REGION: app.region, + VITE_APP_USER_POOL_ID: auth.userPoolId, + VITE_APP_IDENTITY_POOL_ID: auth.cognitoIdentityPoolId!, + VITE_APP_USER_POOL_CLIENT_ID: auth.userPoolClientId, + }, + }); + + // Show the endpoint in the output + stack.addOutputs({ + api_url: api.url, + auth_client_id: auth.userPoolClientId, + auth_domain: `https://${domain.domainName}.auth.${app.region}.amazoncognito.com`, + site_url: site.url, + }); +} diff --git a/examples/api-oauth-facebook/tsconfig.json b/examples/api-oauth-facebook/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-oauth-facebook/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-oauth-github/.gitignore b/examples/api-oauth-github/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-oauth-github/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-oauth-github/.vscode/launch.json b/examples/api-oauth-github/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-oauth-github/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-oauth-github/.vscode/settings.json b/examples/api-oauth-github/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-oauth-github/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-oauth-github/README.md b/examples/api-oauth-github/README.md new file mode 100644 index 0000000000..abb4131b59 --- /dev/null +++ b/examples/api-oauth-github/README.md @@ -0,0 +1,50 @@ +# How to add GitHub OAuth to a serverless app + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-github-login-to-your-cognito-user-pool.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-oauth-github +# Or with Yarn +$ yarn create sst --template=examples/api-oauth-github +``` + +## Commands + +### `yarn run start` + +Starts the local Lambda development environment. + +### `yarn run build` + +Build your app and synthesize your stacks. + +Generates a `.build/` directory with the compiled files and a `.build/cdk.out/` directory with the synthesized CloudFormation stacks. + +### `yarn run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `yarn run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +### `yarn run test` + +Runs your tests using Jest. Takes all the [Jest CLI options](https://jestjs.io/docs/en/cli). + +## Documentation + +Learn more about SST. + +- [Docs](https://docs.sst.dev) +- [sst](https://docs.sst.dev/packages/sst) + +## Community + +[Follow us on Twitter](https://twitter.com/sst_dev) or [post on our forums](https://discourse.sst.dev). diff --git a/examples/api-oauth-github/package.json b/examples/api-oauth-github/package.json new file mode 100644 index 0000000000..07de8f4995 --- /dev/null +++ b/examples/api-oauth-github/package.json @@ -0,0 +1,28 @@ +{ + "name": "api-oauth-github", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ], + "dependencies": { + "node-fetch": "^3.3.1", + "lambda-multipart-parser": "^1.0.1" + } +} \ No newline at end of file diff --git a/examples/api-oauth-github/packages/core/package.json b/examples/api-oauth-github/packages/core/package.json new file mode 100644 index 0000000000..d5e59f641d --- /dev/null +++ b/examples/api-oauth-github/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-oauth-github/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-oauth-github/packages/core/sst-env.d.ts b/examples/api-oauth-github/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-oauth-github/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-oauth-github/packages/core/tsconfig.json b/examples/api-oauth-github/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-oauth-github/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-oauth-github/packages/frontend/.gitignore b/examples/api-oauth-github/packages/frontend/.gitignore new file mode 100644 index 0000000000..a547bf36d8 --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/api-oauth-github/packages/frontend/index.html b/examples/api-oauth-github/packages/frontend/index.html new file mode 100644 index 0000000000..5862bf3783 --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/index.html @@ -0,0 +1,19 @@ + + + + + + + Vite App + + + +
+ + + diff --git a/examples/api-oauth-github/packages/frontend/package.json b/examples/api-oauth-github/packages/frontend/package.json new file mode 100644 index 0000000000..6cd6fa8726 --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/package.json @@ -0,0 +1,21 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "aws-amplify": "^4.3.21", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.7" + } +} diff --git a/examples/api-oauth-github/packages/frontend/src/App.jsx b/examples/api-oauth-github/packages/frontend/src/App.jsx new file mode 100644 index 0000000000..684f97b94a --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/src/App.jsx @@ -0,0 +1,78 @@ +import React, { useState, useEffect } from "react"; +import { Auth, API } from "aws-amplify"; + +const App = () => { + const [user, setUser] = useState(null); + const [loading, setLoading] = useState(true); + + const getUser = async () => { + const user = await Auth.currentUserInfo(); + console.log(user); + if (user) setUser(user); + setLoading(false); + }; + + const signIn = async () => + await Auth.federatedSignIn({ + provider: "GitHub", + }); + + const signOut = async () => await Auth.signOut(); + + const publicRequest = async () => { + const response = await API.get("api", "/public"); + alert(JSON.stringify(response)); + }; + + const privateRequest = async () => { + try { + const response = await API.get("api", "/private", { + headers: { + Authorization: `Bearer ${(await Auth.currentSession()) + .getAccessToken() + .getJwtToken()}`, + }, + }); + alert(JSON.stringify(response)); + } catch (error) { + alert(error); + } + }; + + useEffect(() => { + getUser(); + }, []); + + if (loading) return
Loading...
; + + return ( +
+

SST + Cognito + GitHub OAuth + React

+ {user ? ( +
+

Welcome {user.attributes.name}!

+ +

{user.attributes.email}

+ +
+ ) : ( +
+

Not signed in

+ +
+ )} +
+ + +
+
+ ); +}; + +export default App; diff --git a/examples/api-oauth-github/packages/frontend/src/favicon.svg b/examples/api-oauth-github/packages/frontend/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-oauth-github/packages/frontend/src/index.css b/examples/api-oauth-github/packages/frontend/src/index.css new file mode 100644 index 0000000000..46638585ec --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/src/index.css @@ -0,0 +1,51 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 120px; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} +.api-section { + width: 100%; + margin-top: 20px; + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} + +.api-section > button { + background-color: darkorange; +} diff --git a/examples/api-oauth-github/packages/frontend/src/logo.svg b/examples/api-oauth-github/packages/frontend/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-oauth-github/packages/frontend/src/main.jsx b/examples/api-oauth-github/packages/frontend/src/main.jsx new file mode 100644 index 0000000000..44f7e5818a --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/src/main.jsx @@ -0,0 +1,49 @@ +/* eslint-disable no-undef */ +import React from "react"; +import ReactDOM from "react-dom"; +import "./index.css"; +import App from "./App"; +import Amplify from "aws-amplify"; + +Amplify.configure({ + Auth: { + region: import.meta.env.VITE_APP_REGION, + userPoolId: import.meta.env.VITE_APP_USER_POOL_ID, + userPoolWebClientId: import.meta.env.VITE_APP_USER_POOL_CLIENT_ID, + mandatorySignIn: false, + oauth: { + domain: `${ + import.meta.env.VITE_APP_COGNITO_DOMAIN + + ".auth." + + import.meta.env.VITE_APP_REGION + + ".amazoncognito.com" + }`, + scope: ["email", "profile", "openid", "aws.cognito.signin.user.admin"], + redirectSignIn: + import.meta.env.VITE_APP_STAGE === "prod" + ? "production-url" + : "http://localhost:3000", // Make sure to use the exact URL + redirectSignOut: + import.meta.env.VITE_APP_STAGE === "prod" + ? "production-url" + : "http://localhost:3000", // Make sure to use the exact URL + responseType: "token", // or 'token', note that REFRESH token will only be generated when the responseType is code + }, + }, + API: { + endpoints: [ + { + name: "api", + endpoint: import.meta.env.VITE_APP_API_URL, + region: import.meta.env.VITE_APP_REGION, + }, + ], + }, +}); + +ReactDOM.render( + + + , + document.getElementById("root") +); diff --git a/examples/api-oauth-github/packages/frontend/src/sst-env.d.ts b/examples/api-oauth-github/packages/frontend/src/sst-env.d.ts new file mode 100644 index 0000000000..3899f9a1b0 --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/src/sst-env.d.ts @@ -0,0 +1,14 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_COGNITO_DOMAIN: string; + readonly VITE_APP_API_URL: string; + readonly VITE_APP_REGION: string; + readonly VITE_APP_USER_POOL_ID: string; + readonly VITE_APP_IDENTITY_POOL_ID: string; + readonly VITE_APP_USER_POOL_CLIENT_ID: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/examples/api-oauth-github/packages/frontend/vite.config.js b/examples/api-oauth-github/packages/frontend/vite.config.js new file mode 100644 index 0000000000..9cc50ead1c --- /dev/null +++ b/examples/api-oauth-github/packages/frontend/vite.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/examples/api-oauth-github/packages/functions/package.json b/examples/api-oauth-github/packages/functions/package.json new file mode 100644 index 0000000000..b735779689 --- /dev/null +++ b/examples/api-oauth-github/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-oauth-github/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-oauth-github/packages/functions/src/private.ts b/examples/api-oauth-github/packages/functions/src/private.ts new file mode 100644 index 0000000000..f1da545b7c --- /dev/null +++ b/examples/api-oauth-github/packages/functions/src/private.ts @@ -0,0 +1,7 @@ +export async function handler() { + return { + statusCode: 200, + headers: { "Content-Type": "text/plain" }, + body: `Hello, User!`, + }; +} diff --git a/examples/api-oauth-github/packages/functions/src/public.ts b/examples/api-oauth-github/packages/functions/src/public.ts new file mode 100644 index 0000000000..58f35077b4 --- /dev/null +++ b/examples/api-oauth-github/packages/functions/src/public.ts @@ -0,0 +1,7 @@ +export async function handler() { + return { + statusCode: 200, + headers: { "Content-Type": "text/plain" }, + body: `Hello, Stranger!`, + }; +} diff --git a/examples/api-oauth-github/packages/functions/src/token.ts b/examples/api-oauth-github/packages/functions/src/token.ts new file mode 100644 index 0000000000..3a16ab8754 --- /dev/null +++ b/examples/api-oauth-github/packages/functions/src/token.ts @@ -0,0 +1,21 @@ +import fetch from "node-fetch"; +import parser from "lambda-multipart-parser"; + +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const handler: APIGatewayProxyHandlerV2 = async (event) => { + const result = await parser.parse(event); + const token = await ( + await fetch( + `https://github.com/login/oauth/access_token?client_id=${result.client_id}&client_secret=${result.client_secret}&code=${result.code}`, + { + method: "POST", + headers: { + accept: "application/json", + }, + } + ) + ).json(); + + return token; +}; diff --git a/examples/api-oauth-github/packages/functions/src/user.ts b/examples/api-oauth-github/packages/functions/src/user.ts new file mode 100644 index 0000000000..e05e4abd95 --- /dev/null +++ b/examples/api-oauth-github/packages/functions/src/user.ts @@ -0,0 +1,21 @@ +import fetch from "node-fetch"; + +import { APIGatewayProxyHandlerV2 } from "aws-lambda"; + +export const handler: APIGatewayProxyHandlerV2 = async (event) => { + const token = await ( + await fetch("https://api.github.com/user", { + method: "GET", + headers: { + authorization: + "token " + event.headers["authorization"].split("Bearer ")[1], + accept: "application/json", + }, + }) + ).json(); + + return { + sub: token.id, + ...token, + }; +}; diff --git a/examples/api-oauth-github/packages/functions/sst-env.d.ts b/examples/api-oauth-github/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-oauth-github/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-oauth-github/packages/functions/tsconfig.json b/examples/api-oauth-github/packages/functions/tsconfig.json new file mode 100644 index 0000000000..2bd85450a3 --- /dev/null +++ b/examples/api-oauth-github/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-oauth-github/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-oauth-github/pnpm-workspace.yaml b/examples/api-oauth-github/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-oauth-github/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-oauth-github/sst.config.ts b/examples/api-oauth-github/sst.config.ts new file mode 100644 index 0000000000..1fee514f76 --- /dev/null +++ b/examples/api-oauth-github/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-oauth-github", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-oauth-github/stacks/ExampleStack.ts b/examples/api-oauth-github/stacks/ExampleStack.ts new file mode 100644 index 0000000000..777c7c82a2 --- /dev/null +++ b/examples/api-oauth-github/stacks/ExampleStack.ts @@ -0,0 +1,120 @@ +import { Api, Cognito, StaticSite, StackContext } from "sst/constructs"; +import * as cognito from "aws-cdk-lib/aws-cognito"; + +export function ExampleStack({ stack, app }: StackContext) { + const auth = new Cognito(stack, "Auth", { + cdk: { + userPoolClient: { + supportedIdentityProviders: [ + { + name: "GitHub", + }, + ], + oAuth: { + callbackUrls: [ + app.stage === "prod" + ? "https://my-app.com" + : "http://localhost:3000", + ], + logoutUrls: [ + app.stage === "prod" + ? "https://my-app.com" + : "http://localhost:3000", + ], + }, + }, + }, + }); + + const api = new Api(stack, "api", { + authorizers: { + userPool: { + type: "user_pool", + userPool: { + id: auth.userPoolId, + clientIds: [auth.userPoolClientId], + }, + }, + }, + defaults: { + authorizer: "none", + }, + routes: { + "GET /public": "packages/functions/src/public.handler", + "GET /user": "packages/functions/src/user.handler", + "POST /token": "packages/functions/src/token.handler", + "GET /private": { + function: "packages/functions/src/private.handler", + authorizer: "userPool", + }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Throw error if client ID & secret are not provided + if (!process.env.GITHUB_CLIENT_ID || !process.env.GITHUB_CLIENT_SECRET) + throw new Error("Please set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET"); + + // Create a GitHub OIDC IDP + const idp = new cognito.CfnUserPoolIdentityProvider( + stack, + "GitHubIdentityProvider", + { + providerName: "GitHub", + providerType: "OIDC", + userPoolId: auth.userPoolId, + providerDetails: { + client_id: process.env.GITHUB_CLIENT_ID, + client_secret: process.env.GITHUB_CLIENT_SECRET, + attributes_request_method: "GET", + oidc_issuer: "https://github.com", + authorize_scopes: "openid user", + authorize_url: "https://github.com/login/oauth/authorize", + token_url: api.url + "/token", + attributes_url: api.url + "/user", + jwks_uri: api.url + "/token", + }, + attributeMapping: { + email: "email", + name: "name", + picture: "avatar_url", + }, + } + ); + + // attach the IDP to the client + auth.cdk.userPoolClient.node.addDependency(idp); + + // Create a cognito userpool domain + const domain = auth.cdk.userPool.addDomain("AuthDomain", { + cognitoDomain: { + domainPrefix: `${app.stage}-github-demo-oauth`, + }, + }); + + // Create a React Static Site + const site = new StaticSite(stack, "Site", { + path: "packages/frontend", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_COGNITO_DOMAIN: domain.domainName, + VITE_APP_STAGE: app.stage, + VITE_APP_API_URL: api.url, + VITE_APP_REGION: app.region, + VITE_APP_USER_POOL_ID: auth.userPoolId, + VITE_APP_IDENTITY_POOL_ID: auth.cognitoIdentityPoolId, + VITE_APP_USER_POOL_CLIENT_ID: auth.userPoolClientId, + }, + }); + + // Show the endpoint in the output + stack.addOutputs({ + api_endpoint: api.url, + auth_client_id: auth.userPoolClientId, + domain: domain.domainName, + site_url: site.url, + }); +} diff --git a/examples/api-oauth-github/tsconfig.json b/examples/api-oauth-github/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-oauth-github/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-oauth-google/.gitignore b/examples/api-oauth-google/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-oauth-google/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-oauth-google/.vscode/launch.json b/examples/api-oauth-google/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-oauth-google/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-oauth-google/.vscode/settings.json b/examples/api-oauth-google/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-oauth-google/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-oauth-google/README.md b/examples/api-oauth-google/README.md new file mode 100644 index 0000000000..6eaf954a53 --- /dev/null +++ b/examples/api-oauth-google/README.md @@ -0,0 +1,50 @@ +# How to add Google OAuth to a serverless app + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-google-login-to-your-cognito-user-pool.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-oauth-google +# Or with Yarn +$ yarn create sst --template=examples/api-oauth-google +``` + +## Commands + +### `yarn run start` + +Starts the local Lambda development environment. + +### `yarn run build` + +Build your app and synthesize your stacks. + +Generates a `.build/` directory with the compiled files and a `.build/cdk.out/` directory with the synthesized CloudFormation stacks. + +### `yarn run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `yarn run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +### `yarn run test` + +Runs your tests using Jest. Takes all the [Jest CLI options](https://jestjs.io/docs/en/cli). + +## Documentation + +Learn more about SST. + +- [Docs](https://docs.sst.dev) +- [sst](https://docs.sst.dev/packages/sst) + +## Community + +[Follow us on Twitter](https://twitter.com/sst_dev) or [post on our forums](https://discourse.sst.dev). diff --git a/examples/api-oauth-google/package.json b/examples/api-oauth-google/package.json new file mode 100644 index 0000000000..f200341836 --- /dev/null +++ b/examples/api-oauth-google/package.json @@ -0,0 +1,24 @@ +{ + "name": "api-oauth-google", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*" + ] +} \ No newline at end of file diff --git a/examples/api-oauth-google/packages/core/package.json b/examples/api-oauth-google/packages/core/package.json new file mode 100644 index 0000000000..c24030ff56 --- /dev/null +++ b/examples/api-oauth-google/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-oauth-google/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-oauth-google/packages/core/sst-env.d.ts b/examples/api-oauth-google/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-oauth-google/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-oauth-google/packages/core/tsconfig.json b/examples/api-oauth-google/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-oauth-google/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-oauth-google/packages/frontend/.gitignore b/examples/api-oauth-google/packages/frontend/.gitignore new file mode 100644 index 0000000000..a547bf36d8 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/api-oauth-google/packages/frontend/index.html b/examples/api-oauth-google/packages/frontend/index.html new file mode 100644 index 0000000000..e7977b3e86 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/index.html @@ -0,0 +1,19 @@ + + + + + + + Vite App + + +
+ + + + diff --git a/examples/api-oauth-google/packages/frontend/package.json b/examples/api-oauth-google/packages/frontend/package.json new file mode 100644 index 0000000000..18c52b6240 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/package.json @@ -0,0 +1,19 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "aws-amplify": "^4.3.19", + "react": "^17.0.2", + "react-dom": "^17.0.2" + }, + "devDependencies": { + "@vitejs/plugin-react": "^1.0.7", + "vite": "^2.8.0" + } +} diff --git a/examples/api-oauth-google/packages/frontend/src/App.jsx b/examples/api-oauth-google/packages/frontend/src/App.jsx new file mode 100644 index 0000000000..03a12667e4 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/src/App.jsx @@ -0,0 +1,77 @@ +import { Auth, API } from "aws-amplify"; +import React, { useState, useEffect } from "react"; + +const App = () => { + const [user, setUser] = useState(null); + const [loading, setLoading] = useState(true); + + const getUser = async () => { + const user = await Auth.currentUserInfo(); + if (user) setUser(user); + setLoading(false); + }; + + const signIn = async () => + await Auth.federatedSignIn({ + provider: "Google", + }); + + const signOut = async () => await Auth.signOut(); + + const publicRequest = async () => { + const response = await API.get("api", "/public"); + alert(JSON.stringify(response)); + }; + + const privateRequest = async () => { + try { + const response = await API.get("api", "/private", { + headers: { + Authorization: `Bearer ${(await Auth.currentSession()) + .getAccessToken() + .getJwtToken()}`, + }, + }); + alert(JSON.stringify(response)); + } catch (error) { + alert(error); + } + }; + + useEffect(() => { + getUser(); + }, []); + + if (loading) return
Loading...
; + + return ( +
+

SST + Cognito + Google OAuth + React

+ {user ? ( +
+

Welcome {user.attributes.given_name}!

+ +

{user.attributes.email}

+ +
+ ) : ( +
+

Not signed in

+ +
+ )} +
+ + +
+
+ ); +}; + +export default App; diff --git a/examples/api-oauth-google/packages/frontend/src/favicon.svg b/examples/api-oauth-google/packages/frontend/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-oauth-google/packages/frontend/src/index.css b/examples/api-oauth-google/packages/frontend/src/index.css new file mode 100644 index 0000000000..46638585ec --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/src/index.css @@ -0,0 +1,51 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 120px; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} +.api-section { + width: 100%; + margin-top: 20px; + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} + +.api-section > button { + background-color: darkorange; +} diff --git a/examples/api-oauth-google/packages/frontend/src/logo.svg b/examples/api-oauth-google/packages/frontend/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-oauth-google/packages/frontend/src/main.jsx b/examples/api-oauth-google/packages/frontend/src/main.jsx new file mode 100644 index 0000000000..04244c0807 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/src/main.jsx @@ -0,0 +1,43 @@ +/* eslint-disable no-undef */ +import React from "react"; +import ReactDOM from "react-dom"; +import "./index.css"; +import App from "./App"; +import Amplify from "aws-amplify"; + +Amplify.configure({ + Auth: { + region: import.meta.env.VITE_APP_REGION, + userPoolId: import.meta.env.VITE_APP_USER_POOL_ID, + userPoolWebClientId: import.meta.env.VITE_APP_USER_POOL_CLIENT_ID, + mandatorySignIn: false, + oauth: { + domain: `${ + import.meta.env.VITE_APP_COGNITO_DOMAIN + + ".auth." + + import.meta.env.VITE_APP_REGION + + ".amazoncognito.com" + }`, + scope: ["email", "profile", "openid", "aws.cognito.signin.user.admin"], + redirectSignIn: "http://localhost:3000", // Make sure to use the exact URL + redirectSignOut: "http://localhost:3000", // Make sure to use the exact URL + responseType: "token", // or 'token', note that REFRESH token will only be generated when the responseType is code + }, + }, + API: { + endpoints: [ + { + name: "api", + endpoint: import.meta.env.VITE_APP_API_URL, + region: import.meta.env.VITE_APP_REGION, + }, + ], + }, +}); + +ReactDOM.render( + + + , + document.getElementById("root") +); diff --git a/examples/api-oauth-google/packages/frontend/src/sst-env.d.ts b/examples/api-oauth-google/packages/frontend/src/sst-env.d.ts new file mode 100644 index 0000000000..3899f9a1b0 --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/src/sst-env.d.ts @@ -0,0 +1,14 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_COGNITO_DOMAIN: string; + readonly VITE_APP_API_URL: string; + readonly VITE_APP_REGION: string; + readonly VITE_APP_USER_POOL_ID: string; + readonly VITE_APP_IDENTITY_POOL_ID: string; + readonly VITE_APP_USER_POOL_CLIENT_ID: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/examples/api-oauth-google/packages/frontend/vite.config.js b/examples/api-oauth-google/packages/frontend/vite.config.js new file mode 100644 index 0000000000..9cc50ead1c --- /dev/null +++ b/examples/api-oauth-google/packages/frontend/vite.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}); diff --git a/examples/api-oauth-google/packages/functions/package.json b/examples/api-oauth-google/packages/functions/package.json new file mode 100644 index 0000000000..eb9c9080e2 --- /dev/null +++ b/examples/api-oauth-google/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-oauth-google/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-oauth-google/packages/functions/src/private.ts b/examples/api-oauth-google/packages/functions/src/private.ts new file mode 100644 index 0000000000..f1da545b7c --- /dev/null +++ b/examples/api-oauth-google/packages/functions/src/private.ts @@ -0,0 +1,7 @@ +export async function handler() { + return { + statusCode: 200, + headers: { "Content-Type": "text/plain" }, + body: `Hello, User!`, + }; +} diff --git a/examples/api-oauth-google/packages/functions/src/public.ts b/examples/api-oauth-google/packages/functions/src/public.ts new file mode 100644 index 0000000000..58f35077b4 --- /dev/null +++ b/examples/api-oauth-google/packages/functions/src/public.ts @@ -0,0 +1,7 @@ +export async function handler() { + return { + statusCode: 200, + headers: { "Content-Type": "text/plain" }, + body: `Hello, Stranger!`, + }; +} diff --git a/examples/api-oauth-google/packages/functions/sst-env.d.ts b/examples/api-oauth-google/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-oauth-google/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-oauth-google/packages/functions/tsconfig.json b/examples/api-oauth-google/packages/functions/tsconfig.json new file mode 100644 index 0000000000..ac4e417e24 --- /dev/null +++ b/examples/api-oauth-google/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-oauth-google/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-oauth-google/pnpm-workspace.yaml b/examples/api-oauth-google/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-oauth-google/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-oauth-google/sst.config.ts b/examples/api-oauth-google/sst.config.ts new file mode 100644 index 0000000000..0a9188f7e8 --- /dev/null +++ b/examples/api-oauth-google/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-oauth-google", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-oauth-google/stacks/ExampleStack.ts b/examples/api-oauth-google/stacks/ExampleStack.ts new file mode 100644 index 0000000000..a18516581f --- /dev/null +++ b/examples/api-oauth-google/stacks/ExampleStack.ts @@ -0,0 +1,104 @@ +import * as cognito from "aws-cdk-lib/aws-cognito"; +import { Api, Cognito, StaticSite, StackContext } from "sst/constructs"; + +export function ExampleStack({ stack, app }: StackContext) { + // Create auth + const auth = new Cognito(stack, "Auth", { + cdk: { + userPoolClient: { + supportedIdentityProviders: [ + cognito.UserPoolClientIdentityProvider.GOOGLE, + ], + oAuth: { + callbackUrls: [ + app.stage === "prod" + ? "prodDomainNameUrl" + : "http://localhost:3000", + ], + logoutUrls: [ + app.stage === "prod" + ? "prodDomainNameUrl" + : "http://localhost:3000", + ], + }, + }, + }, + }); + + // Throw error if client ID & secret are not provided + if (!process.env.GOOGLE_CLIENT_ID || !process.env.GOOGLE_CLIENT_SECRET) + throw new Error("Please set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET"); + + // Create a Google OAuth provider + const provider = new cognito.UserPoolIdentityProviderGoogle(stack, "Google", { + clientId: process.env.GOOGLE_CLIENT_ID, + clientSecret: process.env.GOOGLE_CLIENT_SECRET, + userPool: auth.cdk.userPool, + scopes: ["profile", "email", "openid"], + attributeMapping: { + email: cognito.ProviderAttribute.GOOGLE_EMAIL, + givenName: cognito.ProviderAttribute.GOOGLE_GIVEN_NAME, + familyName: cognito.ProviderAttribute.GOOGLE_FAMILY_NAME, + profilePicture: cognito.ProviderAttribute.GOOGLE_PICTURE, + }, + }); + + // attach the created provider to our userpool + auth.cdk.userPoolClient.node.addDependency(provider); + + // Create a cognito userpool domain + const domain = auth.cdk.userPool.addDomain("AuthDomain", { + cognitoDomain: { + domainPrefix: `${app.stage}-demo-auth-domain`, + }, + }); + + // Create a HTTP API + const api = new Api(stack, "Api", { + authorizers: { + userPool: { + type: "user_pool", + userPool: { + id: auth.userPoolId, + clientIds: [auth.userPoolClientId], + }, + }, + }, + defaults: { + authorizer: "userPool", + }, + routes: { + "GET /private": "packages/functions/src/private.handler", + "GET /public": { + function: "packages/functions/src/public.handler", + authorizer: "none", + }, + }, + }); + + // Allow authenticated users invoke API + auth.attachPermissionsForAuthUsers(stack, [api]); + + // Create a React Static Site + const site = new StaticSite(stack, "Site", { + path: "packages/frontend", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_COGNITO_DOMAIN: domain.domainName, + VITE_APP_API_URL: api.url, + VITE_APP_REGION: app.region, + VITE_APP_USER_POOL_ID: auth.userPoolId, + VITE_APP_IDENTITY_POOL_ID: auth.cognitoIdentityPoolId, + VITE_APP_USER_POOL_CLIENT_ID: auth.userPoolClientId, + }, + }); + + // Show the endpoint in the output + stack.addOutputs({ + ApiEndpoint: api.url, + authClientId: auth.userPoolClientId, + domain: domain.domainName, + site_url: site.url, + }); +} diff --git a/examples/api-oauth-google/tsconfig.json b/examples/api-oauth-google/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-oauth-google/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-sst-auth-facebook/.gitignore b/examples/api-sst-auth-facebook/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-sst-auth-facebook/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-sst-auth-facebook/.vscode/launch.json b/examples/api-sst-auth-facebook/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-sst-auth-facebook/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-sst-auth-facebook/.vscode/settings.json b/examples/api-sst-auth-facebook/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-sst-auth-facebook/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-sst-auth-facebook/README.md b/examples/api-sst-auth-facebook/README.md new file mode 100644 index 0000000000..036598847e --- /dev/null +++ b/examples/api-sst-auth-facebook/README.md @@ -0,0 +1,40 @@ +# How to add Google authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-facebook-login-to-your-sst-app-with-sst-auth.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-sst-auth-facebook +# Or with Yarn +$ yarn create sst --template=examples/api-sst-auth-facebook +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-sst-auth-facebook/package.json b/examples/api-sst-auth-facebook/package.json new file mode 100644 index 0000000000..f85c5547a7 --- /dev/null +++ b/examples/api-sst-auth-facebook/package.json @@ -0,0 +1,29 @@ +{ + "name": "api-sst-auth-facebook", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.79.1", + "constructs": "10.1.156", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*", + "web" + ], + "dependencies": { + "@aws-sdk/client-dynamodb": "^3.354.0", + "@aws-sdk/util-dynamodb": "^3.354.0" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-facebook/packages/core/package.json b/examples/api-sst-auth-facebook/packages/core/package.json new file mode 100644 index 0000000000..aef06d8d9b --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-sst-auth-facebook/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-facebook/packages/core/sst-env.d.ts b/examples/api-sst-auth-facebook/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-sst-auth-facebook/packages/core/tsconfig.json b/examples/api-sst-auth-facebook/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-sst-auth-facebook/packages/functions/package.json b/examples/api-sst-auth-facebook/packages/functions/package.json new file mode 100644 index 0000000000..ef4799d24b --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-sst-auth-facebook/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-facebook/packages/functions/src/auth.ts b/examples/api-sst-auth-facebook/packages/functions/src/auth.ts new file mode 100644 index 0000000000..ebe4b2e4c2 --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/functions/src/auth.ts @@ -0,0 +1,48 @@ +import { Session, AuthHandler, FacebookAdapter } from "sst/node/auth"; +import { Table } from "sst/node/table"; +import { Config } from "sst/node/config"; +import { StaticSite } from "sst/node/site"; +import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; +import { marshall } from "@aws-sdk/util-dynamodb"; + +declare module "sst/node/auth" { + export interface SessionTypes { + user: { + userID: string; + }; + } +} + +export const handler = AuthHandler({ + providers: { + facebook: FacebookAdapter({ + clientID: Config.FACEBOOK_APP_ID, + clientSecret: Config.FACEBOOK_APP_SECRET, + scope: "openid email", + onSuccess: async (tokenset) => { + const claims = tokenset.claims(); + + const ddb = new DynamoDBClient({}); + await ddb.send( + new PutItemCommand({ + TableName: Table.users.tableName, + Item: marshall({ + userId: claims.sub, + email: claims.email, + picture: claims.picture, + name: claims.given_name, + }), + }) + ); + + return Session.parameter({ + redirect: StaticSite.site.url || "http://127.0.0.1:5173", + type: "user", + properties: { + userID: claims.sub, + }, + }); + }, + }), + }, +}); diff --git a/examples/api-sst-auth-facebook/packages/functions/src/session.ts b/examples/api-sst-auth-facebook/packages/functions/src/session.ts new file mode 100644 index 0000000000..c4d024ea02 --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/functions/src/session.ts @@ -0,0 +1,29 @@ +import { Table } from "sst/node/table"; +import { ApiHandler } from "sst/node/api"; +import { useSession } from "sst/node/auth"; +import { marshall, unmarshall } from "@aws-sdk/util-dynamodb"; +import { DynamoDBClient, GetItemCommand } from "@aws-sdk/client-dynamodb"; + +export const handler = ApiHandler(async () => { + const session = useSession(); + + // Check user is authenticated + if (session.type !== "user") { + throw new Error("Not authenticated"); + } + + const ddb = new DynamoDBClient({}); + const data = await ddb.send( + new GetItemCommand({ + TableName: Table.users.tableName, + Key: marshall({ + userId: session.properties.userID, + }), + }) + ); + + return { + statusCode: 200, + body: JSON.stringify(unmarshall(data.Item!)), + }; +}); diff --git a/examples/api-sst-auth-facebook/packages/functions/sst-env.d.ts b/examples/api-sst-auth-facebook/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-sst-auth-facebook/packages/functions/tsconfig.json b/examples/api-sst-auth-facebook/packages/functions/tsconfig.json new file mode 100644 index 0000000000..d0a5707d6d --- /dev/null +++ b/examples/api-sst-auth-facebook/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-sst-auth-facebook/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-sst-auth-facebook/pnpm-workspace.yaml b/examples/api-sst-auth-facebook/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-sst-auth-facebook/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-sst-auth-facebook/sst.config.ts b/examples/api-sst-auth-facebook/sst.config.ts new file mode 100644 index 0000000000..7656b4fb5d --- /dev/null +++ b/examples/api-sst-auth-facebook/sst.config.ts @@ -0,0 +1,14 @@ +import { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-sst-auth-facebook", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-sst-auth-facebook/stacks/ExampleStack.ts b/examples/api-sst-auth-facebook/stacks/ExampleStack.ts new file mode 100644 index 0000000000..0a5b666273 --- /dev/null +++ b/examples/api-sst-auth-facebook/stacks/ExampleStack.ts @@ -0,0 +1,63 @@ +import { + StackContext, + Api, + Auth, + Config, + StaticSite, + Table, +} from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create a database Table + const table = new Table(stack, "users", { + fields: { + userId: "string", + }, + primaryIndex: { partitionKey: "userId" }, + }); + + // Create Api + const api = new Api(stack, "api", { + defaults: { + function: { + bind: [table], + }, + }, + routes: { + "GET /": "packages/functions/src/lambda.handler", + "GET /session": "packages/functions/src/session.handler", + }, + }); + + // Create a React site + const site = new StaticSite(stack, "site", { + path: "web", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_API_URL: api.url, + }, + }); + + // Create Auth provider + const auth = new Auth(stack, "auth", { + authenticator: { + handler: "packages/functions/src/auth.handler", + bind: [ + new Config.Secret(stack, "FACEBOOK_APP_ID"), + new Config.Secret(stack, "FACEBOOK_APP_SECRET"), + site, + ], + }, + }); + auth.attach(stack, { + api, + prefix: "/auth", + }); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + SiteURL: site.url, + }); +} diff --git a/examples/api-sst-auth-facebook/tsconfig.json b/examples/api-sst-auth-facebook/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-sst-auth-facebook/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-sst-auth-facebook/web/.gitignore b/examples/api-sst-auth-facebook/web/.gitignore new file mode 100644 index 0000000000..a547bf36d8 --- /dev/null +++ b/examples/api-sst-auth-facebook/web/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/api-sst-auth-facebook/web/index.html b/examples/api-sst-auth-facebook/web/index.html new file mode 100644 index 0000000000..b46ab83364 --- /dev/null +++ b/examples/api-sst-auth-facebook/web/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/examples/api-sst-auth-facebook/web/package.json b/examples/api-sst-auth-facebook/web/package.json new file mode 100644 index 0000000000..de0d93e597 --- /dev/null +++ b/examples/api-sst-auth-facebook/web/package.json @@ -0,0 +1,20 @@ +{ + "name": "web", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.15" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-facebook/web/src/App.css b/examples/api-sst-auth-facebook/web/src/App.css new file mode 100644 index 0000000000..8da3fde63d --- /dev/null +++ b/examples/api-sst-auth-facebook/web/src/App.css @@ -0,0 +1,42 @@ +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +@media (prefers-reduced-motion: no-preference) { + .App-logo { + animation: App-logo-spin infinite 20s linear; + } +} + +.App-header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.App-link { + color: #61dafb; +} + +@keyframes App-logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +button { + font-size: calc(10px + 2vmin); +} diff --git a/examples/api-sst-auth-facebook/web/src/App.jsx b/examples/api-sst-auth-facebook/web/src/App.jsx new file mode 100644 index 0000000000..e0da4495da --- /dev/null +++ b/examples/api-sst-auth-facebook/web/src/App.jsx @@ -0,0 +1,84 @@ +import { useEffect, useState } from "react"; + +const App = () => { + const [session, setSession] = useState(null); + const [loading, setLoading] = useState(true); + + const getSession = async () => { + const token = localStorage.getItem("session"); + if (token) { + const user = await getUserInfo(token); + if (user) setSession(user); + } + setLoading(false); + }; + + useEffect(() => { + getSession(); + }, []); + + useEffect(() => { + const search = window.location.search; + const params = new URLSearchParams(search); + const token = params.get("token"); + if (token) { + localStorage.setItem("session", token); + window.location.replace(window.location.origin); + } + }, []); + + const getUserInfo = async (session) => { + try { + const response = await fetch( + `${import.meta.env.VITE_APP_API_URL}/session`, + { + method: "GET", + headers: { + Authorization: `Bearer ${session}`, + }, + } + ); + return response.json(); + } catch (error) { + alert(error); + } + }; + + const signOut = async () => { + localStorage.removeItem("session"); + setSession(null); + }; + + if (loading) return
Loading...
; + + return ( +
+

SST Auth Example

+ {session ? ( +
+

Welcome {session.name}!

+ +

{session.email}

+ +
+ ) : ( + + )} +
+ ); +}; + +export default App; diff --git a/examples/api-sst-auth-facebook/web/src/favicon.svg b/examples/api-sst-auth-facebook/web/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-sst-auth-facebook/web/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-sst-auth-facebook/web/src/index.css b/examples/api-sst-auth-facebook/web/src/index.css new file mode 100644 index 0000000000..143b311a25 --- /dev/null +++ b/examples/api-sst-auth-facebook/web/src/index.css @@ -0,0 +1,34 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 100%; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} diff --git a/examples/api-sst-auth-facebook/web/src/logo.svg b/examples/api-sst-auth-facebook/web/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-sst-auth-facebook/web/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-sst-auth-facebook/web/src/main.jsx b/examples/api-sst-auth-facebook/web/src/main.jsx new file mode 100644 index 0000000000..9af0bb638e --- /dev/null +++ b/examples/api-sst-auth-facebook/web/src/main.jsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import App from './App' +import './index.css' + +ReactDOM.createRoot(document.getElementById('root')).render( + + + +) diff --git a/examples/api-sst-auth-facebook/web/vite.config.js b/examples/api-sst-auth-facebook/web/vite.config.js new file mode 100644 index 0000000000..b1b5f91e5f --- /dev/null +++ b/examples/api-sst-auth-facebook/web/vite.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()] +}) diff --git a/examples/api-sst-auth-google/.gitignore b/examples/api-sst-auth-google/.gitignore new file mode 100644 index 0000000000..37b9471a01 --- /dev/null +++ b/examples/api-sst-auth-google/.gitignore @@ -0,0 +1,15 @@ +# dependencies +node_modules + +# sst +.sst +.build + +# opennext +.open-next + +# misc +.DS_Store + +# local env files +.env*.local diff --git a/examples/api-sst-auth-google/.vscode/launch.json b/examples/api-sst-auth-google/.vscode/launch.json new file mode 100644 index 0000000000..58b32d117e --- /dev/null +++ b/examples/api-sst-auth-google/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"], + "env": {} + } + ] +} diff --git a/examples/api-sst-auth-google/.vscode/settings.json b/examples/api-sst-auth-google/.vscode/settings.json new file mode 100644 index 0000000000..3b42f010e9 --- /dev/null +++ b/examples/api-sst-auth-google/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "search.exclude": { + "**/.sst": true + } +} diff --git a/examples/api-sst-auth-google/README.md b/examples/api-sst-auth-google/README.md new file mode 100644 index 0000000000..b2e1d8a9ba --- /dev/null +++ b/examples/api-sst-auth-google/README.md @@ -0,0 +1,40 @@ +# How to add Google authentication to a serverless API + +An example serverless app created with SST. + +## Getting Started + +[**Read the tutorial**](https://sst.dev/examples/how-to-add-google-login-to-your-sst-app-with-sst-auth.html) + +Install the example. + +```bash +$ npx create-sst@latest --template=examples/api-sst-auth-google +# Or with Yarn +$ yarn create sst --template=examples/api-sst-auth-google +``` + +## Commands + +### `npm run dev` + +Starts the Live Lambda Development environment. + +### `npm run build` + +Build your app and synthesize your stacks. + +### `npm run deploy [stack]` + +Deploy all your stacks to AWS. Or optionally deploy, a specific stack. + +### `npm run remove [stack]` + +Remove all your stacks and all of their resources from AWS. Or optionally removes, a specific stack. + +## Documentation + +Learn more about the SST. + +- [Docs](https://docs.sst.dev/) +- [sst](https://docs.sst.dev/packages/sst) diff --git a/examples/api-sst-auth-google/package.json b/examples/api-sst-auth-google/package.json new file mode 100644 index 0000000000..8bbfad454a --- /dev/null +++ b/examples/api-sst-auth-google/package.json @@ -0,0 +1,29 @@ +{ + "name": "api-sst-auth-google", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "sst": "^2.13.9", + "aws-cdk-lib": "2.85.0", + "constructs": "10.2.61", + "typescript": "^5.1.3", + "@tsconfig/node16": "^1.0.4" + }, + "workspaces": [ + "packages/*", + "web" + ], + "dependencies": { + "@aws-sdk/client-dynamodb": "^3.354.0", + "@aws-sdk/util-dynamodb": "^3.354.0" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-google/packages/core/package.json b/examples/api-sst-auth-google/packages/core/package.json new file mode 100644 index 0000000000..d35d980e69 --- /dev/null +++ b/examples/api-sst-auth-google/packages/core/package.json @@ -0,0 +1,14 @@ +{ + "name": "@api-sst-auth-google/core", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "vitest": "^0.32.2", + "@types/node": "^20.3.1", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-google/packages/core/sst-env.d.ts b/examples/api-sst-auth-google/packages/core/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-sst-auth-google/packages/core/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-sst-auth-google/packages/core/tsconfig.json b/examples/api-sst-auth-google/packages/core/tsconfig.json new file mode 100644 index 0000000000..3a1245de20 --- /dev/null +++ b/examples/api-sst-auth-google/packages/core/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext" + } +} diff --git a/examples/api-sst-auth-google/packages/functions/package.json b/examples/api-sst-auth-google/packages/functions/package.json new file mode 100644 index 0000000000..6af8ec49bf --- /dev/null +++ b/examples/api-sst-auth-google/packages/functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "@api-sst-auth-google/functions", + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "sst bind vitest", + "typecheck": "tsc -noEmit" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "@types/aws-lambda": "^8.10.119", + "vitest": "^0.32.2", + "sst": "^2.13.9" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-google/packages/functions/src/auth.ts b/examples/api-sst-auth-google/packages/functions/src/auth.ts new file mode 100644 index 0000000000..59c59836f1 --- /dev/null +++ b/examples/api-sst-auth-google/packages/functions/src/auth.ts @@ -0,0 +1,49 @@ +import { Session, AuthHandler, GoogleAdapter } from "sst/node/auth"; +import { Table } from "sst/node/table"; +import { StaticSite } from "sst/node/site"; +import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; +import { marshall } from "@aws-sdk/util-dynamodb"; + +const GOOGLE_CLIENT_ID = + "1051197502784-vjtbj1rnckpagefmcoqnaon0cbglsdac.apps.googleusercontent.com"; + +declare module "sst/node/auth" { + export interface SessionTypes { + user: { + userID: string; + }; + } +} + +export const handler = AuthHandler({ + providers: { + google: GoogleAdapter({ + mode: "oidc", + clientID: GOOGLE_CLIENT_ID, + onSuccess: async (tokenset) => { + const claims = tokenset.claims(); + + const ddb = new DynamoDBClient({}); + await ddb.send( + new PutItemCommand({ + TableName: Table.users.tableName, + Item: marshall({ + userId: claims.sub, + email: claims.email, + picture: claims.picture, + name: claims.given_name, + }), + }) + ); + + return Session.parameter({ + redirect: StaticSite.site.url || "http://127.0.0.1:5173", + type: "user", + properties: { + userID: claims.sub, + }, + }); + }, + }), + }, +}); diff --git a/examples/api-sst-auth-google/packages/functions/src/session.ts b/examples/api-sst-auth-google/packages/functions/src/session.ts new file mode 100644 index 0000000000..c4d024ea02 --- /dev/null +++ b/examples/api-sst-auth-google/packages/functions/src/session.ts @@ -0,0 +1,29 @@ +import { Table } from "sst/node/table"; +import { ApiHandler } from "sst/node/api"; +import { useSession } from "sst/node/auth"; +import { marshall, unmarshall } from "@aws-sdk/util-dynamodb"; +import { DynamoDBClient, GetItemCommand } from "@aws-sdk/client-dynamodb"; + +export const handler = ApiHandler(async () => { + const session = useSession(); + + // Check user is authenticated + if (session.type !== "user") { + throw new Error("Not authenticated"); + } + + const ddb = new DynamoDBClient({}); + const data = await ddb.send( + new GetItemCommand({ + TableName: Table.users.tableName, + Key: marshall({ + userId: session.properties.userID, + }), + }) + ); + + return { + statusCode: 200, + body: JSON.stringify(unmarshall(data.Item!)), + }; +}); diff --git a/examples/api-sst-auth-google/packages/functions/sst-env.d.ts b/examples/api-sst-auth-google/packages/functions/sst-env.d.ts new file mode 100644 index 0000000000..a9187e8568 --- /dev/null +++ b/examples/api-sst-auth-google/packages/functions/sst-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/api-sst-auth-google/packages/functions/tsconfig.json b/examples/api-sst-auth-google/packages/functions/tsconfig.json new file mode 100644 index 0000000000..0f1a245539 --- /dev/null +++ b/examples/api-sst-auth-google/packages/functions/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "@api-sst-auth-google/core/*": ["../core/src/*"] + } + } +} diff --git a/examples/api-sst-auth-google/pnpm-workspace.yaml b/examples/api-sst-auth-google/pnpm-workspace.yaml new file mode 100644 index 0000000000..a4e134d3e2 --- /dev/null +++ b/examples/api-sst-auth-google/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "packages/**/*" diff --git a/examples/api-sst-auth-google/sst.config.ts b/examples/api-sst-auth-google/sst.config.ts new file mode 100644 index 0000000000..1019b16fc6 --- /dev/null +++ b/examples/api-sst-auth-google/sst.config.ts @@ -0,0 +1,14 @@ +import type { SSTConfig } from "sst"; +import { ExampleStack } from "./stacks/ExampleStack"; + +export default { + config(_input) { + return { + name: "api-sst-auth-google", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(ExampleStack); + } +} satisfies SSTConfig; diff --git a/examples/api-sst-auth-google/stacks/ExampleStack.ts b/examples/api-sst-auth-google/stacks/ExampleStack.ts new file mode 100644 index 0000000000..f9604785db --- /dev/null +++ b/examples/api-sst-auth-google/stacks/ExampleStack.ts @@ -0,0 +1,52 @@ +import { StackContext, Api, Auth, StaticSite, Table } from "sst/constructs"; + +export function ExampleStack({ stack }: StackContext) { + // Create a database Table + const table = new Table(stack, "users", { + fields: { + userId: "string", + }, + primaryIndex: { partitionKey: "userId" }, + }); + + // Create Api + const api = new Api(stack, "api", { + defaults: { + function: { + bind: [table], + }, + }, + routes: { + "GET /": "packages/functions/src/auth.handler", + "GET /session": "packages/functions/src/session.handler", + }, + }); + + // Create a React site + const site = new StaticSite(stack, "site", { + path: "web", + buildCommand: "npm run build", + buildOutput: "dist", + environment: { + VITE_APP_API_URL: api.url, + }, + }); + + // Create Auth provider + const auth = new Auth(stack, "auth", { + authenticator: { + handler: "packages/functions/src/auth.handler", + bind: [site], + }, + }); + auth.attach(stack, { + api, + prefix: "/auth", + }); + + // Show the API endpoint and other info in the output + stack.addOutputs({ + ApiEndpoint: api.url, + SiteURL: site.url, + }); +} diff --git a/examples/api-sst-auth-google/tsconfig.json b/examples/api-sst-auth-google/tsconfig.json new file mode 100644 index 0000000000..3da429095f --- /dev/null +++ b/examples/api-sst-auth-google/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "exclude": ["packages"] +} diff --git a/examples/api-sst-auth-google/web/.gitignore b/examples/api-sst-auth-google/web/.gitignore new file mode 100644 index 0000000000..a547bf36d8 --- /dev/null +++ b/examples/api-sst-auth-google/web/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/api-sst-auth-google/web/index.html b/examples/api-sst-auth-google/web/index.html new file mode 100644 index 0000000000..b46ab83364 --- /dev/null +++ b/examples/api-sst-auth-google/web/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/examples/api-sst-auth-google/web/package.json b/examples/api-sst-auth-google/web/package.json new file mode 100644 index 0000000000..de0d93e597 --- /dev/null +++ b/examples/api-sst-auth-google/web/package.json @@ -0,0 +1,20 @@ +{ + "name": "web", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "sst bind vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.15" + } +} \ No newline at end of file diff --git a/examples/api-sst-auth-google/web/src/App.css b/examples/api-sst-auth-google/web/src/App.css new file mode 100644 index 0000000000..8da3fde63d --- /dev/null +++ b/examples/api-sst-auth-google/web/src/App.css @@ -0,0 +1,42 @@ +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +@media (prefers-reduced-motion: no-preference) { + .App-logo { + animation: App-logo-spin infinite 20s linear; + } +} + +.App-header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.App-link { + color: #61dafb; +} + +@keyframes App-logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +button { + font-size: calc(10px + 2vmin); +} diff --git a/examples/api-sst-auth-google/web/src/App.jsx b/examples/api-sst-auth-google/web/src/App.jsx new file mode 100644 index 0000000000..7a9c7a2613 --- /dev/null +++ b/examples/api-sst-auth-google/web/src/App.jsx @@ -0,0 +1,84 @@ +import { useEffect, useState } from "react"; + +const App = () => { + const [session, setSession] = useState(null); + const [loading, setLoading] = useState(true); + + const getSession = async () => { + const token = localStorage.getItem("session"); + if (token) { + const user = await getUserInfo(token); + if (user) setSession(user); + } + setLoading(false); + }; + + useEffect(() => { + getSession(); + }, []); + + useEffect(() => { + const search = window.location.search; + const params = new URLSearchParams(search); + const token = params.get("token"); + if (token) { + localStorage.setItem("session", token); + window.location.replace(window.location.origin); + } + }, []); + + const getUserInfo = async (session) => { + try { + const response = await fetch( + `${import.meta.env.VITE_APP_API_URL}/session`, + { + method: "GET", + headers: { + Authorization: `Bearer ${session}`, + }, + } + ); + return response.json(); + } catch (error) { + alert(error); + } + }; + + const signOut = async () => { + localStorage.removeItem("session"); + setSession(null); + }; + + if (loading) return
Loading...
; + + return ( +
+

SST Auth Example

+ {session ? ( +
+

Welcome {session.name}!

+ +

{session.email}

+ +
+ ) : ( + + )} +
+ ); +}; + +export default App; diff --git a/examples/api-sst-auth-google/web/src/favicon.svg b/examples/api-sst-auth-google/web/src/favicon.svg new file mode 100644 index 0000000000..de4aeddc12 --- /dev/null +++ b/examples/api-sst-auth-google/web/src/favicon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/api-sst-auth-google/web/src/index.css b/examples/api-sst-auth-google/web/src/index.css new file mode 100644 index 0000000000..143b311a25 --- /dev/null +++ b/examples/api-sst-auth-google/web/src/index.css @@ -0,0 +1,34 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +button { + width: 100%; + padding: 10px; + border: none; + border-radius: 4px; + background-color: #000; + color: #fff; + font-size: 16px; + cursor: pointer; +} + +.profile { + border: 1px solid #ccc; + padding: 20px; + border-radius: 4px; +} diff --git a/examples/api-sst-auth-google/web/src/logo.svg b/examples/api-sst-auth-google/web/src/logo.svg new file mode 100644 index 0000000000..6b60c1042f --- /dev/null +++ b/examples/api-sst-auth-google/web/src/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/api-sst-auth-google/web/src/main.jsx b/examples/api-sst-auth-google/web/src/main.jsx new file mode 100644 index 0000000000..9af0bb638e --- /dev/null +++ b/examples/api-sst-auth-google/web/src/main.jsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import App from './App' +import './index.css' + +ReactDOM.createRoot(document.getElementById('root')).render( + + + +) diff --git a/examples/api-sst-auth-google/web/vite.config.js b/examples/api-sst-auth-google/web/vite.config.js new file mode 100644 index 0000000000..b1b5f91e5f --- /dev/null +++ b/examples/api-sst-auth-google/web/vite.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()] +}) diff --git a/examples/aws-analog/.editorconfig b/examples/aws-analog/.editorconfig deleted file mode 100644 index 59d9a3a3e7..0000000000 --- a/examples/aws-analog/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/examples/aws-analog/.gitignore b/examples/aws-analog/.gitignore deleted file mode 100644 index c48ce743bf..0000000000 --- a/examples/aws-analog/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# Compiled output -/dist -/tmp -/out-tsc -/bazel-out - -# Node -/node_modules -npm-debug.log -yarn-error.log - -# IDEs and editors -.idea/ -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# Visual Studio Code -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history/* - -# Miscellaneous -/.angular/cache -/.nx/cache -/.nx/workspace-data -.sass-cache/ -/connect.lock -/coverage -/libpeerconnection.log -testem.log -/typings - -# System files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-analog/.vscode/extensions.json b/examples/aws-analog/.vscode/extensions.json deleted file mode 100644 index e4679f326a..0000000000 --- a/examples/aws-analog/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 - "recommendations": ["angular.ng-template", "analogjs.vscode-analog"] -} diff --git a/examples/aws-analog/.vscode/launch.json b/examples/aws-analog/.vscode/launch.json deleted file mode 100644 index 57dbf761ec..0000000000 --- a/examples/aws-analog/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "ng serve", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: start", - "url": "http://localhost:5173/" - }, - { - "name": "ng test", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: test" - } - ] -} diff --git a/examples/aws-analog/.vscode/tasks.json b/examples/aws-analog/.vscode/tasks.json deleted file mode 100644 index a298b5bd87..0000000000 --- a/examples/aws-analog/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "start", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - }, - { - "type": "npm", - "script": "test", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - } - ] -} diff --git a/examples/aws-analog/angular.json b/examples/aws-analog/angular.json deleted file mode 100644 index 60b166f354..0000000000 --- a/examples/aws-analog/angular.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "my-app": { - "projectType": "application", - "root": ".", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@analogjs/platform:vite", - "options": { - "configFile": "vite.config.ts", - "main": "src/main.ts", - "outputPath": "dist/client", - "tsConfig": "tsconfig.app.json" - }, - "defaultConfiguration": "production", - "configurations": { - "development": { - "mode": "development" - }, - "production": { - "sourcemap": false, - "mode": "production" - } - } - }, - "serve": { - "builder": "@analogjs/platform:vite-dev-server", - "defaultConfiguration": "development", - "options": { - "buildTarget": "my-app:build", - "port": 5173 - }, - "configurations": { - "development": { - "buildTarget": "my-app:build:development", - "hmr": true - }, - "production": { - "buildTarget": "my-app:build:production" - } - } - }, - "test": { - "builder": "@analogjs/vitest-angular:test" - } - } - } - } -} diff --git a/examples/aws-analog/index.html b/examples/aws-analog/index.html deleted file mode 100644 index 5facc429a4..0000000000 --- a/examples/aws-analog/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - My App - - - - - - - - - - diff --git a/examples/aws-analog/package.json b/examples/aws-analog/package.json deleted file mode 100644 index f56f53e377..0000000000 --- a/examples/aws-analog/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "aws-analog", - "version": "0.0.0", - "type": "module", - "engines": { - "node": ">=18.19.1" - }, - "scripts": { - "build": "ng build", - "dev": "ng serve", - "ng": "ng", - "start": "npm run dev", - "test": "ng test", - "watch": "ng build --watch --configuration development" - }, - "private": true, - "dependencies": { - "@analogjs/content": "^1.8.1", - "@analogjs/router": "^1.8.1", - "@angular/animations": "^18.0.0", - "@angular/build": "^18.0.0", - "@angular/common": "^18.0.0", - "@angular/compiler": "^18.0.0", - "@angular/core": "^18.0.0", - "@angular/forms": "^18.0.0", - "@angular/platform-browser": "^18.0.0", - "@angular/platform-browser-dynamic": "^18.0.0", - "@angular/platform-server": "^18.0.0", - "@angular/router": "^18.0.0", - "@aws-sdk/client-s3": "^3.654.0", - "@aws-sdk/s3-request-presigner": "^3.654.0", - "front-matter": "^4.0.2", - "marked": "^5.0.2", - "marked-gfm-heading-id": "^3.1.0", - "marked-highlight": "^2.0.1", - "marked-mangle": "^1.1.7", - "prismjs": "^1.29.0", - "rxjs": "~7.8.0", - "sst": "file:../../sdk/js", - "tslib": "^2.3.0", - "zone.js": "~0.14.3" - }, - "devDependencies": { - "@analogjs/platform": "^1.8.1", - "@analogjs/vite-plugin-angular": "^1.8.1", - "@analogjs/vitest-angular": "^1.8.1", - "@angular/cli": "^18.0.0", - "@angular/compiler-cli": "^18.0.0", - "jsdom": "^22.0.0", - "typescript": "~5.4.2", - "vite": "^5.0.0", - "vite-tsconfig-paths": "^4.2.0", - "vitest": "^1.3.1" - } -} diff --git a/examples/aws-analog/public/analog.svg b/examples/aws-analog/public/analog.svg deleted file mode 100644 index e4f555aa7d..0000000000 --- a/examples/aws-analog/public/analog.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-analog/public/favicon.ico b/examples/aws-analog/public/favicon.ico deleted file mode 100644 index 997406ad22..0000000000 Binary files a/examples/aws-analog/public/favicon.ico and /dev/null differ diff --git a/examples/aws-analog/src/app/app.component.spec.ts b/examples/aws-analog/src/app/app.component.spec.ts deleted file mode 100644 index 9a08b4b25f..0000000000 --- a/examples/aws-analog/src/app/app.component.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { provideRouter } from '@angular/router'; -import { provideLocationMocks } from '@angular/common/testing'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppComponent], - providers: [provideRouter([]), provideLocationMocks()], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); -}); diff --git a/examples/aws-analog/src/app/app.component.ts b/examples/aws-analog/src/app/app.component.ts deleted file mode 100644 index 2e02d16044..0000000000 --- a/examples/aws-analog/src/app/app.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; - -@Component({ - selector: 'app-root', - standalone: true, - imports: [RouterOutlet], - template: ` `, - styles: [ - ` - :host { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; - } - `, - ], -}) -export class AppComponent {} diff --git a/examples/aws-analog/src/app/app.config.server.ts b/examples/aws-analog/src/app/app.config.server.ts deleted file mode 100644 index 0da63b09b0..0000000000 --- a/examples/aws-analog/src/app/app.config.server.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; -import { provideServerRendering } from '@angular/platform-server'; - -import { appConfig } from './app.config'; - -const serverConfig: ApplicationConfig = { - providers: [provideServerRendering()], -}; - -export const config = mergeApplicationConfig(appConfig, serverConfig); diff --git a/examples/aws-analog/src/app/app.config.ts b/examples/aws-analog/src/app/app.config.ts deleted file mode 100644 index a1a58ee8fc..0000000000 --- a/examples/aws-analog/src/app/app.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - provideHttpClient, - withFetch, - withInterceptors, -} from '@angular/common/http'; -import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; -import { provideClientHydration } from '@angular/platform-browser'; -import { provideFileRouter, requestContextInterceptor } from '@analogjs/router'; - -export const appConfig: ApplicationConfig = { - providers: [ - provideZoneChangeDetection({ eventCoalescing: true }), - provideFileRouter(), - provideHttpClient( - withFetch(), - withInterceptors([requestContextInterceptor]) - ), - provideClientHydration(), - ], -}; diff --git a/examples/aws-analog/src/app/pages/index.page.ts b/examples/aws-analog/src/app/pages/index.page.ts deleted file mode 100644 index 56b2cfb557..0000000000 --- a/examples/aws-analog/src/app/pages/index.page.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Component } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { injectLoad } from '@analogjs/router'; -import { toSignal } from '@angular/core/rxjs-interop'; - -import { load } from './index.server'; - -@Component({ - selector: 'app-home', - standalone: true, - imports: [FormsModule], - template: ` -
- - -
- `, -}) -export default class HomeComponent { - data = toSignal(injectLoad(), { requireSync: true }); - - async onSubmit(event: Event): Promise { - const file = (event.target as HTMLFormElement)['file'].files?.[0]!; - - const image = await fetch(this.data().url, { - body: file, - method: 'PUT', - headers: { - 'Content-Type': file.type, - 'Content-Disposition': `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split('?')[0]; - } -} diff --git a/examples/aws-analog/src/app/pages/index.server.ts b/examples/aws-analog/src/app/pages/index.server.ts deleted file mode 100644 index a120302365..0000000000 --- a/examples/aws-analog/src/app/pages/index.server.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from 'sst'; -import { PageServerLoad } from '@analogjs/router'; -import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'; - -export const load = async ({ }: PageServerLoad) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - // @ts-ignore: Generated on deploy - Bucket: Resource.MyBucket.name, - }); - - const url = await getSignedUrl(new S3Client({}), command); - - return { - url - }; -}; diff --git a/examples/aws-analog/src/main.server.ts b/examples/aws-analog/src/main.server.ts deleted file mode 100644 index 2b6d4d14b5..0000000000 --- a/examples/aws-analog/src/main.server.ts +++ /dev/null @@ -1,32 +0,0 @@ -import 'zone.js/node'; -import '@angular/platform-server/init'; -import { enableProdMode } from '@angular/core'; -import { bootstrapApplication } from '@angular/platform-browser'; -import { renderApplication } from '@angular/platform-server'; -import { provideServerContext } from '@analogjs/router/server'; -import { ServerContext } from '@analogjs/router/tokens'; - -import { config } from './app/app.config.server'; -import { AppComponent } from './app/app.component'; - -if (import.meta.env.PROD) { - enableProdMode(); -} - -export function bootstrap() { - return bootstrapApplication(AppComponent, config); -} - -export default async function render( - url: string, - document: string, - serverContext: ServerContext -) { - const html = await renderApplication(bootstrap, { - document, - url, - platformProviders: [provideServerContext(serverContext)], - }); - - return html; -} diff --git a/examples/aws-analog/src/main.ts b/examples/aws-analog/src/main.ts deleted file mode 100644 index e774611399..0000000000 --- a/examples/aws-analog/src/main.ts +++ /dev/null @@ -1,7 +0,0 @@ -import 'zone.js'; -import { bootstrapApplication } from '@angular/platform-browser'; - -import { AppComponent } from './app/app.component'; -import { appConfig } from './app/app.config'; - -bootstrapApplication(AppComponent, appConfig); diff --git a/examples/aws-analog/src/server/routes/v1/hello.ts b/examples/aws-analog/src/server/routes/v1/hello.ts deleted file mode 100644 index 594c5d716d..0000000000 --- a/examples/aws-analog/src/server/routes/v1/hello.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineEventHandler } from 'h3'; - -export default defineEventHandler(() => ({ message: 'Hello World' })); diff --git a/examples/aws-analog/src/styles.css b/examples/aws-analog/src/styles.css deleted file mode 100644 index 8e92f8fcdc..0000000000 --- a/examples/aws-analog/src/styles.css +++ /dev/null @@ -1,75 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ -:root { - font-family: Inter, Avenir, Helvetica, Arial, sans-serif; - font-size: 16px; - line-height: 24px; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -webkit-text-size-adjust: 100%; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -.card { - padding: 2em; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/examples/aws-analog/src/test-setup.ts b/examples/aws-analog/src/test-setup.ts deleted file mode 100644 index 318c3b9d71..0000000000 --- a/examples/aws-analog/src/test-setup.ts +++ /dev/null @@ -1,12 +0,0 @@ -import '@analogjs/vitest-angular/setup-zone'; - -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting, -} from '@angular/platform-browser-dynamic/testing'; -import { getTestBed } from '@angular/core/testing'; - -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); diff --git a/examples/aws-analog/sst.config.ts b/examples/aws-analog/sst.config.ts deleted file mode 100644 index e7256be079..0000000000 --- a/examples/aws-analog/sst.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-analog", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - - new sst.aws.Analog("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-analog/tsconfig.app.json b/examples/aws-analog/tsconfig.app.json deleted file mode 100644 index ad965f67de..0000000000 --- a/examples/aws-analog/tsconfig.app.json +++ /dev/null @@ -1,14 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/app", - "types": [] - }, - "files": ["src/main.ts", "src/main.server.ts"], - "include": [ - "src/**/*.d.ts", - "src/app/pages/**/*.page.ts", - "src/server/middleware/**/*.ts" - ] -} diff --git a/examples/aws-analog/tsconfig.json b/examples/aws-analog/tsconfig.json deleted file mode 100644 index 94e11863a1..0000000000 --- a/examples/aws-analog/tsconfig.json +++ /dev/null @@ -1,31 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "moduleResolution": "node", - "importHelpers": true, - "target": "ES2022", - "module": "ES2022", - "lib": ["ES2022", "dom"], - "useDefineForClassFields": false, - "skipLibCheck": true - }, - "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/examples/aws-analog/tsconfig.spec.json b/examples/aws-analog/tsconfig.spec.json deleted file mode 100644 index 06eb7cae61..0000000000 --- a/examples/aws-analog/tsconfig.spec.json +++ /dev/null @@ -1,11 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/spec", - "target": "es2016", - "types": ["node", "vitest/globals"] - }, - "files": ["src/test-setup.ts"], - "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] -} diff --git a/examples/aws-analog/vite.config.ts b/examples/aws-analog/vite.config.ts deleted file mode 100644 index bb4ee185dd..0000000000 --- a/examples/aws-analog/vite.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -import { defineConfig } from 'vite'; -import analog from '@analogjs/platform'; - -// https://vitejs.dev/config/ -export default defineConfig(({ mode }) => ({ - build: { - target: ['es2020'], - }, - resolve: { - mainFields: ['module'], - }, - plugins: [analog({ - nitro: { - preset: "aws-lambda", - } - })], - test: { - globals: true, - environment: 'jsdom', - setupFiles: ['src/test-setup.ts'], - include: ['**/*.spec.ts'], - reporters: ['default'], - }, - define: { - 'import.meta.vitest': mode !== 'production', - }, -})); diff --git a/examples/aws-angular/.editorconfig b/examples/aws-angular/.editorconfig deleted file mode 100644 index 59d9a3a3e7..0000000000 --- a/examples/aws-angular/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/examples/aws-angular/.gitignore b/examples/aws-angular/.gitignore deleted file mode 100644 index c23cd03a2f..0000000000 --- a/examples/aws-angular/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ -# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. - -# Compiled output -/dist -/tmp -/out-tsc -/bazel-out - -# Node -/node_modules -npm-debug.log -yarn-error.log - -# IDEs and editors -.idea/ -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# Visual Studio Code -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history/* - -# Miscellaneous -/.angular/cache -.sass-cache/ -/connect.lock -/coverage -/libpeerconnection.log -testem.log -/typings - -# System files -.DS_Store -Thumbs.db - -.sst diff --git a/examples/aws-angular/.vscode/extensions.json b/examples/aws-angular/.vscode/extensions.json deleted file mode 100644 index 77b374577d..0000000000 --- a/examples/aws-angular/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 - "recommendations": ["angular.ng-template"] -} diff --git a/examples/aws-angular/.vscode/launch.json b/examples/aws-angular/.vscode/launch.json deleted file mode 100644 index 925af83705..0000000000 --- a/examples/aws-angular/.vscode/launch.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "ng serve", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: start", - "url": "http://localhost:4200/" - }, - { - "name": "ng test", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: test", - "url": "http://localhost:9876/debug.html" - } - ] -} diff --git a/examples/aws-angular/.vscode/tasks.json b/examples/aws-angular/.vscode/tasks.json deleted file mode 100644 index a298b5bd87..0000000000 --- a/examples/aws-angular/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "start", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - }, - { - "type": "npm", - "script": "test", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - } - ] -} diff --git a/examples/aws-angular/angular.json b/examples/aws-angular/angular.json deleted file mode 100644 index e928c0184f..0000000000 --- a/examples/aws-angular/angular.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "aws-angular": { - "projectType": "application", - "schematics": {}, - "root": "", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@ngx-env/builder:application", - "options": { - "outputPath": "dist/aws-angular", - "index": "src/index.html", - "browser": "src/main.ts", - "polyfills": [ - "zone.js" - ], - "tsConfig": "tsconfig.app.json", - "assets": [ - { - "glob": "**/*", - "input": "public" - } - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "initial", - "maximumWarning": "500kB", - "maximumError": "1MB" - }, - { - "type": "anyComponentStyle", - "maximumWarning": "2kB", - "maximumError": "4kB" - } - ], - "outputHashing": "all" - }, - "development": { - "optimization": false, - "extractLicenses": false, - "sourceMap": true - } - }, - "defaultConfiguration": "production" - }, - "serve": { - "builder": "@ngx-env/builder:dev-server", - "configurations": { - "production": { - "buildTarget": "aws-angular:build:production" - }, - "development": { - "buildTarget": "aws-angular:build:development" - } - }, - "defaultConfiguration": "development" - }, - "extract-i18n": { - "builder": "@ngx-env/builder:extract-i18n" - }, - "test": { - "builder": "@ngx-env/builder:karma", - "options": { - "polyfills": [ - "zone.js", - "zone.js/testing" - ], - "tsConfig": "tsconfig.spec.json", - "assets": [ - { - "glob": "**/*", - "input": "public" - } - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - } - } - } - } - } -} \ No newline at end of file diff --git a/examples/aws-angular/functions/presigned.ts b/examples/aws-angular/functions/presigned.ts deleted file mode 100644 index 063e82b94f..0000000000 --- a/examples/aws-angular/functions/presigned.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export async function handler() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 200, - body: await getSignedUrl(new S3Client({}), command), - }; -} diff --git a/examples/aws-angular/package.json b/examples/aws-angular/package.json deleted file mode 100644 index 26c545ea06..0000000000 --- a/examples/aws-angular/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "aws-angular", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test" - }, - "private": true, - "dependencies": { - "@angular/animations": "^18.2.0", - "@angular/common": "^18.2.0", - "@angular/compiler": "^18.2.0", - "@angular/core": "^18.2.0", - "@angular/forms": "^18.2.0", - "@angular/platform-browser": "^18.2.0", - "@angular/platform-browser-dynamic": "^18.2.0", - "@angular/router": "^18.2.0", - "@aws-sdk/client-s3": "^3.637.0", - "@aws-sdk/s3-request-presigner": "^3.637.0", - "rxjs": "~7.8.0", - "tslib": "^2.3.0", - "zone.js": "~0.14.10" - }, - "devDependencies": { - "@angular-devkit/build-angular": "^18.2.2", - "@angular/cli": "^18.2.2", - "@angular/compiler-cli": "^18.2.0", - "@ngx-env/builder": "^18.0.1", - "@types/jasmine": "~5.1.0", - "jasmine-core": "~5.2.0", - "karma": "~6.4.0", - "karma-chrome-launcher": "~3.2.0", - "karma-coverage": "~2.2.0", - "karma-jasmine": "~5.1.0", - "karma-jasmine-html-reporter": "~2.1.0", - "sst": "file:../../sdk/js", - "typescript": "~5.5.2" - } -} diff --git a/examples/aws-angular/public/favicon.ico b/examples/aws-angular/public/favicon.ico deleted file mode 100644 index 57614f9c96..0000000000 Binary files a/examples/aws-angular/public/favicon.ico and /dev/null differ diff --git a/examples/aws-angular/src/app/app.component.html b/examples/aws-angular/src/app/app.component.html deleted file mode 100644 index 8a552a3da8..0000000000 --- a/examples/aws-angular/src/app/app.component.html +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - - - - - - -
-
-
- -

Hello, {{ title }}

-

Congratulations! Your app is running. πŸŽ‰

-
- -
-
- @for (item of [ - { title: 'Explore the Docs', link: 'https://angular.dev' }, - { title: 'Learn with Tutorials', link: 'https://angular.dev/tutorials' }, - { title: 'CLI Docs', link: 'https://angular.dev/tools/cli' }, - { title: 'Angular Language Service', link: 'https://angular.dev/tools/language-service' }, - { title: 'Angular DevTools', link: 'https://angular.dev/tools/devtools' }, - ]; track item.title) { - - {{ item.title }} - - - - - } -
- -
-
-
- - - - - - - - - - - diff --git a/examples/aws-angular/src/app/app.component.spec.ts b/examples/aws-angular/src/app/app.component.spec.ts deleted file mode 100644 index c2e1a61504..0000000000 --- a/examples/aws-angular/src/app/app.component.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppComponent], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have the 'aws-angular' title`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('aws-angular'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Hello, aws-angular'); - }); -}); diff --git a/examples/aws-angular/src/app/app.component.ts b/examples/aws-angular/src/app/app.component.ts deleted file mode 100644 index 8ed480a4d4..0000000000 --- a/examples/aws-angular/src/app/app.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; -import { FileUploadComponent } from './file-upload.component'; - -@Component({ - selector: 'app-root', - standalone: true, - imports: [RouterOutlet, FileUploadComponent], - template: ` -
- -
- - `, - styles: [` - main { - margin: auto; - padding: 1.5rem; - max-width: 60ch; - } - `], -}) -export class AppComponent { } diff --git a/examples/aws-angular/src/app/app.config.ts b/examples/aws-angular/src/app/app.config.ts deleted file mode 100644 index 138d4e9d95..0000000000 --- a/examples/aws-angular/src/app/app.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; -import { provideHttpClient, withFetch } from '@angular/common/http'; -import { provideRouter } from '@angular/router'; - -import { routes } from './app.routes'; - -export const appConfig: ApplicationConfig = { - providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideHttpClient(withFetch())] -}; diff --git a/examples/aws-angular/src/app/app.routes.ts b/examples/aws-angular/src/app/app.routes.ts deleted file mode 100644 index dc39edb5f2..0000000000 --- a/examples/aws-angular/src/app/app.routes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Routes } from '@angular/router'; - -export const routes: Routes = []; diff --git a/examples/aws-angular/src/app/file-upload.component.ts b/examples/aws-angular/src/app/file-upload.component.ts deleted file mode 100644 index 25d34d1e5e..0000000000 --- a/examples/aws-angular/src/app/file-upload.component.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Component, inject } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; - -@Component({ - selector: 'app-file-upload', - standalone: true, - imports: [FormsModule], - template: ` -
- - -
- `, - styles: [` - form { - color: white; - padding: 2rem; - display: flex; - align-items: center; - justify-content: space-between; - background-color: #23262d; - background-image: none; - background-size: 400%; - border-radius: 0.6rem; - background-position: 100%; - box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); - } - button { - appearance: none; - border: 0; - font-weight: 500; - border-radius: 5px; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - background-color: white; - color: black; - } - button:active:enabled { - background-color: #EEE; - } - `] -}) -export class FileUploadComponent { - private http = inject(HttpClient); - - presignedApi = import.meta.env['NG_APP_PRESIGNED_API']; - - async onSubmit(event: Event): Promise { - const file = (event.target as HTMLFormElement)['file'].files?.[0]!; - - this.http.get(this.presignedApi, { responseType: 'text' }).subscribe({ - next: async (url: string) => { - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }, - }); - } -} diff --git a/examples/aws-angular/src/env.d.ts b/examples/aws-angular/src/env.d.ts deleted file mode 100644 index f27c3a9850..0000000000 --- a/examples/aws-angular/src/env.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Define the type of the environment variables. -declare interface Env { - readonly NODE_ENV: string; - // Replace the following with your own environment variables. - // Example: NGX_VERSION: string; - [key: string]: any; -} - -// Choose how to access the environment variables. -// Remove the unused options. - -// 1. Use import.meta.env.YOUR_ENV_VAR in your code. (conventional) -declare interface ImportMeta { - readonly env: Env; -} - -// 2. Use _NGX_ENV_.YOUR_ENV_VAR in your code. (customizable) -// You can modify the name of the variable in angular.json. -// ngxEnv: { -// define: '_NGX_ENV_', -// } -declare const _NGX_ENV_: Env; - -// 3. Use process.env.YOUR_ENV_VAR in your code. (deprecated) -declare namespace NodeJS { - export interface ProcessEnv extends Env {} -} diff --git a/examples/aws-angular/src/index.html b/examples/aws-angular/src/index.html deleted file mode 100644 index 21b153fb31..0000000000 --- a/examples/aws-angular/src/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - AwsAngular - - - - - - - - diff --git a/examples/aws-angular/src/main.ts b/examples/aws-angular/src/main.ts deleted file mode 100644 index 35b00f3463..0000000000 --- a/examples/aws-angular/src/main.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { bootstrapApplication } from '@angular/platform-browser'; -import { appConfig } from './app/app.config'; -import { AppComponent } from './app/app.component'; - -bootstrapApplication(AppComponent, appConfig) - .catch((err) => console.error(err)); diff --git a/examples/aws-angular/src/styles.css b/examples/aws-angular/src/styles.css deleted file mode 100644 index 90d4ee0072..0000000000 --- a/examples/aws-angular/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/examples/aws-angular/sst.config.ts b/examples/aws-angular/sst.config.ts deleted file mode 100644 index 2a2628ce96..0000000000 --- a/examples/aws-angular/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-angular", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const pre = new sst.aws.Function("MyFunction", { - url: true, - link: [bucket], - handler: "functions/presigned.handler", - }); - - new sst.aws.StaticSite("MyWeb", { - dev: { - command: "npm run start", - }, - build: { - output: "dist/browser", - command: "ng build --output-path dist", - }, - environment: { - NG_APP_PRESIGNED_API: pre.url - } - }); - }, -}); - diff --git a/examples/aws-angular/tsconfig.app.json b/examples/aws-angular/tsconfig.app.json deleted file mode 100644 index 3775b37e3b..0000000000 --- a/examples/aws-angular/tsconfig.app.json +++ /dev/null @@ -1,15 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/app", - "types": [] - }, - "files": [ - "src/main.ts" - ], - "include": [ - "src/**/*.d.ts" - ] -} diff --git a/examples/aws-angular/tsconfig.json b/examples/aws-angular/tsconfig.json deleted file mode 100644 index a8bb65b6e2..0000000000 --- a/examples/aws-angular/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "compileOnSave": false, - "compilerOptions": { - "outDir": "./dist/out-tsc", - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "skipLibCheck": true, - "isolatedModules": true, - "esModuleInterop": true, - "sourceMap": true, - "declaration": false, - "experimentalDecorators": true, - "moduleResolution": "bundler", - "importHelpers": true, - "target": "ES2022", - "module": "ES2022", - "lib": [ - "ES2022", - "dom" - ] - }, - "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/examples/aws-angular/tsconfig.spec.json b/examples/aws-angular/tsconfig.spec.json deleted file mode 100644 index 5fb748d920..0000000000 --- a/examples/aws-angular/tsconfig.spec.json +++ /dev/null @@ -1,15 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/spec", - "types": [ - "jasmine" - ] - }, - "include": [ - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/examples/aws-api/.gitignore b/examples/aws-api/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-api/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-api/index.ts b/examples/aws-api/index.ts deleted file mode 100644 index 4c760bfc12..0000000000 --- a/examples/aws-api/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client({}); - -export async function upload() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 200, - body: await getSignedUrl(s3, command), - }; -} - -export async function latest() { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }) - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0) - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 302, - headers: { - Location: await getSignedUrl(s3, command), - }, - }; -} diff --git a/examples/aws-api/package.json b/examples/aws-api/package.json deleted file mode 100644 index 544351cff4..0000000000 --- a/examples/aws-api/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-api", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.142" - } -} diff --git a/examples/aws-api/sst.config.ts b/examples/aws-api/sst.config.ts deleted file mode 100644 index 5a8f1ddcb3..0000000000 --- a/examples/aws-api/sst.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-api", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - const api = new sst.aws.ApiGatewayV2("MyApi"); - api.route("GET /", { - link: [bucket], - handler: "index.upload", - }); - api.route("GET /latest", { - link: [bucket], - handler: "index.latest", - }); - }, -}); diff --git a/examples/aws-api/tsconfig.json b/examples/aws-api/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-api/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-apig-auth/package.json b/examples/aws-apig-auth/package.json deleted file mode 100644 index 7776c8ad27..0000000000 --- a/examples/aws-apig-auth/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-apig-auth", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apig-auth/route.ts b/examples/aws-apig-auth/route.ts deleted file mode 100644 index 3bc5653e3a..0000000000 --- a/examples/aws-apig-auth/route.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const handler = async (event) => { - console.log(event); - return { - statusCode: 200, - body: JSON.stringify({ route: event.routeKey, status: "ok" }, null, 2), - }; -}; diff --git a/examples/aws-apig-auth/sst.config.ts b/examples/aws-apig-auth/sst.config.ts deleted file mode 100644 index 4c07cb077f..0000000000 --- a/examples/aws-apig-auth/sst.config.ts +++ /dev/null @@ -1,43 +0,0 @@ -/// - -/** - * ## API Gateway auth - * - * Enable IAM and JWT authorizers for API Gateway routes. - * - */ -export default $config({ - app(input) { - return { - name: "aws-apig-auth", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV2("MyApi", { - domain: { - name: "api.ion.sst.sh", - path: "v1", - }, - }); - api.route("GET /", { - handler: "route.handler", - }); - api.route("GET /foo", "route.handler", { auth: { iam: true } }); - api.route("GET /bar", "route.handler", { - auth: { - jwt: { - issuer: - "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Rq4d8zILG", - audiences: ["user@example.com"], - }, - }, - }); - api.route("$default", "route.handler"); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-apig-websocket/.gitignore b/examples/aws-apig-websocket/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-apig-websocket/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-apig-websocket/lambda.ts b/examples/aws-apig-websocket/lambda.ts deleted file mode 100644 index 9755466b92..0000000000 --- a/examples/aws-apig-websocket/lambda.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Resource } from "sst"; -import { - ApiGatewayManagementApiClient, - PostToConnectionCommand, -} from "@aws-sdk/client-apigatewaymanagementapi"; - -export async function connect(event) { - console.log("!!! connect"); - - // If subprotocols are requested, return the allowed protocol. In this example, we only - // allow "MY_ALLOWED_PROTOCOL". - const protocolHeader = event.headers["Sec-WebSocket-Protocol"]; - if (protocolHeader) { - const subprotocols = protocolHeader.split(",").map((p) => p.trim()); - return subprotocols.includes("MY_ALLOWED_PROTOCOL") - ? { - statusCode: 200, - headers: { "Sec-WebSocket-Protocol": "MY_ALLOWED_PROTOCOL" }, - } - : { statusCode: 400 }; - } - - return { statusCode: 200 }; -} - -export async function disconnect(event) { - console.log("!!! disconnect"); - return { statusCode: 200 }; -} - -export async function sendMessage(event) { - console.log("!!! sendMessage"); - return { statusCode: 200 }; -} - -export async function catchAll(event) { - console.log("!!! default"); - - // Send a message back to the client - const client = new ApiGatewayManagementApiClient({ - endpoint: Resource.MyApi.managementEndpoint, - }); - await client.send( - new PostToConnectionCommand({ - ConnectionId: event.requestContext.connectionId, - Data: "Hey! What is this?", - }) - ); - - return { statusCode: 200 }; -} diff --git a/examples/aws-apig-websocket/package.json b/examples/aws-apig-websocket/package.json deleted file mode 100644 index 3b0dba2a21..0000000000 --- a/examples/aws-apig-websocket/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-apig-websocket", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-apigatewaymanagementapi": "^3.699.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apig-websocket/sst.config.ts b/examples/aws-apig-websocket/sst.config.ts deleted file mode 100644 index ebc05181b7..0000000000 --- a/examples/aws-apig-websocket/sst.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-apig-websocket", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayWebSocket("MyApi", {}); - api.route("$connect", "lambda.connect"); - api.route("$disconnect", "lambda.disconnect"); - api.route("$default", { handler: "lambda.catchAll", link: [api] }); - api.route("sendmessage", "lambda.sendMessage"); - - return { - managementEndpoint: api.managementEndpoint, - }; - }, -}); diff --git a/examples/aws-apig-websocket/tsconfig.json b/examples/aws-apig-websocket/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-apig-websocket/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-apigv1-stream/hono.ts b/examples/aws-apigv1-stream/hono.ts deleted file mode 100644 index a80f1f5cbc..0000000000 --- a/examples/aws-apigv1-stream/hono.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Hono } from "hono"; -import { streamText } from "hono/streaming"; -import { streamHandle } from "hono/aws-lambda"; - -const app = new Hono().get("/hono", (c) => { - return streamText(c, async (stream) => { - await stream.writeln("Hello"); - await stream.sleep(3000); - await stream.writeln("World"); - }); -}); - -export const handler = streamHandle(app); diff --git a/examples/aws-apigv1-stream/index.ts b/examples/aws-apigv1-stream/index.ts deleted file mode 100644 index fb8e0b89d2..0000000000 --- a/examples/aws-apigv1-stream/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const handler = awslambda.streamifyResponse( - async (event, stream) => { - stream = awslambda.HttpResponseStream.from(stream, { - statusCode: 200, - headers: { - "Content-Type": "text/plain; charset=UTF-8", - "X-Content-Type-Options": "nosniff", - }, - }); - - stream.write("Hello "); - await new Promise((resolve) => setTimeout(resolve, 3000)); - stream.write("World"); - - stream.end(); - }, -); diff --git a/examples/aws-apigv1-stream/package.json b/examples/aws-apigv1-stream/package.json deleted file mode 100644 index 6669ffcf77..0000000000 --- a/examples/aws-apigv1-stream/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "aws-apigv1-stream", - "version": "1.0.0", - "dependencies": { - "@types/aws-lambda": "^8.10.161", - "hono": "^4", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apigv1-stream/sst.config.ts b/examples/aws-apigv1-stream/sst.config.ts deleted file mode 100644 index 8e27d03985..0000000000 --- a/examples/aws-apigv1-stream/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## AWS API Gateway V1 streaming - * - * An example on how to enable streaming for API Gateway REST API routes. - * - * ```ts title="sst.config.ts" - * api.route("GET /", { - * handler: "index.handler", - * streaming: true, - * }); - * ``` - * - * The handler uses the native `awslambda.streamifyResponse` and - * `awslambda.HttpResponseStream.from` to stream responses through API Gateway. - * - * ```ts title="index.ts" - * export const handler = awslambda.streamifyResponse( - * async (event, stream) => { - * stream = awslambda.HttpResponseStream.from(stream, { - * statusCode: 200, - * headers: { - * "Content-Type": "text/plain; charset=UTF-8", - * "X-Content-Type-Options": "nosniff", - * }, - * }); - * - * stream.write("Hello "); - * await new Promise((resolve) => setTimeout(resolve, 3000)); - * stream.write("World"); - * - * stream.end(); - * }, - * ); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-apigv1-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV1("MyApi"); - api.route("GET /", { - handler: "index.handler", - streaming: true, - }); - api.route("GET /hono", { - handler: "hono.handler", - streaming: true, - }); - api.deploy(); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-apigv1-stream/tsconfig.json b/examples/aws-apigv1-stream/tsconfig.json deleted file mode 100644 index 853c71f05c..0000000000 --- a/examples/aws-apigv1-stream/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true - } -} diff --git a/examples/aws-apigv1/.gitignore b/examples/aws-apigv1/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-apigv1/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-apigv1/index.ts b/examples/aws-apigv1/index.ts deleted file mode 100644 index 149485da7a..0000000000 --- a/examples/aws-apigv1/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -export async function handler() { - return { - statusCode: 200, - body: "hello world", - }; -} - -export async function authorizer(event, context) { - const authHeader = event.authorizationToken; - let username, password; - - if (authHeader) { - const base64Info = authHeader.split(" ")[1]; - // Stored as 'username:password' in base64 - const userInfo = Buffer.from(base64Info, "base64").toString(); - [username, password] = userInfo.split(":"); - } - - return username === "hello" && password === "world" - ? { - principalId: "*", - policyDocument: { - Version: "2012-10-17", - Statement: [ - { - Action: "execute-api:Invoke", - Effect: "Allow", - Resource: "*", - }, - ], - }, - } - : "Unauthorized"; -} diff --git a/examples/aws-apigv1/package.json b/examples/aws-apigv1/package.json deleted file mode 100644 index 132ea3562d..0000000000 --- a/examples/aws-apigv1/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-apigv1", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apigv1/sst.config.ts b/examples/aws-apigv1/sst.config.ts deleted file mode 100644 index d2991e0ed3..0000000000 --- a/examples/aws-apigv1/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-apigv1", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV1("MyApi"); - const authorizer = api.addAuthorizer({ - name: "MyAuthorizer", - tokenFunction: "index.authorizer", - }); - api.route("GET /", "index.handler"); - api.route("GET /iam", "index.handler", { - auth: { iam: true }, - }); - api.route("GET /token", "index.handler", { - auth: { custom: authorizer.id }, - }); - api.route("GET /{proxy+}", "index.handler"); - api.deploy(); - }, -}); diff --git a/examples/aws-apigv1/tsconfig.json b/examples/aws-apigv1/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-apigv1/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-app-sync/lambda.ts b/examples/aws-app-sync/lambda.ts deleted file mode 100644 index 08136570e8..0000000000 --- a/examples/aws-app-sync/lambda.ts +++ /dev/null @@ -1,10 +0,0 @@ -type AppSyncEvent = { - info: { - fieldName: string; - }; -}; - -export async function main(event: AppSyncEvent) { - console.log(event); - return { status: "ok" }; -} diff --git a/examples/aws-app-sync/package.json b/examples/aws-app-sync/package.json deleted file mode 100644 index 36cadba873..0000000000 --- a/examples/aws-app-sync/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-app-sync", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-app-sync/schema.graphql b/examples/aws-app-sync/schema.graphql deleted file mode 100644 index b2c0cef549..0000000000 --- a/examples/aws-app-sync/schema.graphql +++ /dev/null @@ -1,5 +0,0 @@ -type Query { - license: String - user: String - pipeline: String -} diff --git a/examples/aws-app-sync/sst.config.ts b/examples/aws-app-sync/sst.config.ts deleted file mode 100644 index 53412e24a2..0000000000 --- a/examples/aws-app-sync/sst.config.ts +++ /dev/null @@ -1,47 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-app-sync", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const table = new sst.aws.Dynamo("MyTable", { - fields: { - userId: "string", - }, - primaryIndex: { hashKey: "userId" }, - }); - - const api = new sst.aws.AppSync("MyApi", { - schema: "schema.graphql", - domain: "appsync.ion.sst.sh", - }); - const lambdaDS = api.addDataSource({ - name: "lambda", - lambda: "lambda.main", - }); - const dynamoDS = api.addDataSource({ name: "dyanmo", dynamodb: table.arn }); - api.addResolver("Query license", { dataSource: lambdaDS.name }); - api.addResolver("Query user", { - dataSource: dynamoDS.name, - requestTemplate: `{ - "version": "2017-02-28", - "operation": "Scan", - }`, - responseTemplate: `{ - "users": $utils.toJson($context.result.items) - }`, - }); - - const apiKey = new aws.appsync.ApiKey("MyApiKey", { - apiId: api.id, - }); - return { - API_KEY: apiKey.key, - }; - }, -}); diff --git a/examples/aws-astro-container/.dockerignore b/examples/aws-astro-container/.dockerignore deleted file mode 100644 index cf88ac3dd3..0000000000 --- a/examples/aws-astro-container/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -node_modules -dist - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-astro-container/.gitignore b/examples/aws-astro-container/.gitignore deleted file mode 100644 index 12ff1bf9ce..0000000000 --- a/examples/aws-astro-container/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ - -# sst -.sst diff --git a/examples/aws-astro-container/.vscode/extensions.json b/examples/aws-astro-container/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro-container/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro-container/.vscode/launch.json b/examples/aws-astro-container/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro-container/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro-container/Dockerfile b/examples/aws-astro-container/Dockerfile deleted file mode 100644 index f096fbb0b5..0000000000 --- a/examples/aws-astro-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base -WORKDIR /app - -COPY package.json package-lock.json ./ - -FROM base AS prod-deps -RUN npm install --omit=dev - -FROM base AS build-deps -RUN npm install - -FROM build-deps AS build -COPY . . -RUN npm run build - -FROM base AS runtime -COPY --from=prod-deps /app/node_modules ./node_modules -COPY --from=build /app/dist ./dist - -ENV HOST=0.0.0.0 -ENV PORT=4321 -EXPOSE 4321 -CMD node ./dist/server/entry.mjs diff --git a/examples/aws-astro-container/astro.config.mjs b/examples/aws-astro-container/astro.config.mjs deleted file mode 100644 index af450f938d..0000000000 --- a/examples/aws-astro-container/astro.config.mjs +++ /dev/null @@ -1,14 +0,0 @@ -// @ts-check -// @ts-check -import { defineConfig } from 'astro/config'; - -import node from '@astrojs/node'; - -// https://astro.build/config -export default defineConfig({ - output: 'server', - - adapter: node({ - mode: 'standalone' - }) -}); diff --git a/examples/aws-astro-container/package.json b/examples/aws-astro-container/package.json deleted file mode 100644 index 1bd6f7c6b7..0000000000 --- a/examples/aws-astro-container/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro-container", - "type": "module", - "version": "0.0.1", - "scripts": { - "astro": "astro", - "build": "astro check && astro build", - "dev": "astro dev", - "preview": "astro preview" - }, - "dependencies": { - "@astrojs/check": "^0.9.4", - "@astrojs/node": "^8.3.4", - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "astro": "^4.16.16", - "astro-sst": "2.43.5", - "sst": "file:../../sdk/js", - "typescript": "^5.7.2" - } -} diff --git a/examples/aws-astro-container/src/assets/astro.svg b/examples/aws-astro-container/src/assets/astro.svg deleted file mode 100644 index 8cf8fb0c7d..0000000000 --- a/examples/aws-astro-container/src/assets/astro.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-astro-container/src/assets/background.svg b/examples/aws-astro-container/src/assets/background.svg deleted file mode 100644 index 4b2be0ac0e..0000000000 --- a/examples/aws-astro-container/src/assets/background.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-astro-container/src/components/Welcome.astro b/examples/aws-astro-container/src/components/Welcome.astro deleted file mode 100644 index d08955687f..0000000000 --- a/examples/aws-astro-container/src/components/Welcome.astro +++ /dev/null @@ -1,209 +0,0 @@ ---- -import astroLogo from '../assets/astro.svg'; -import background from '../assets/background.svg'; ---- - - - - diff --git a/examples/aws-astro-container/src/env.d.ts b/examples/aws-astro-container/src/env.d.ts deleted file mode 100644 index 9bc5cb41c2..0000000000 --- a/examples/aws-astro-container/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/examples/aws-astro-container/src/layouts/Layout.astro b/examples/aws-astro-container/src/layouts/Layout.astro deleted file mode 100644 index e455c61067..0000000000 --- a/examples/aws-astro-container/src/layouts/Layout.astro +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - Astro Basics - - - - - - - diff --git a/examples/aws-astro-container/src/pages/index.astro b/examples/aws-astro-container/src/pages/index.astro deleted file mode 100644 index cb2889fa2a..0000000000 --- a/examples/aws-astro-container/src/pages/index.astro +++ /dev/null @@ -1,74 +0,0 @@ ---- -import { Resource } from "sst"; -import Layout from '../layouts/Layout.astro'; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- - - -
-
- - -
- -
-
- - diff --git a/examples/aws-astro-container/sst.config.ts b/examples/aws-astro-container/sst.config.ts deleted file mode 100644 index 4190fc3729..0000000000 --- a/examples/aws-astro-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-astro-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "4321/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-astro-container/tsconfig.json b/examples/aws-astro-container/tsconfig.json deleted file mode 100644 index 96e2f10d1c..0000000000 --- a/examples/aws-astro-container/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict", - "include": [ - ".astro/types.d.ts", - "**/*" - ], - "exclude": [ - "dist","sst.config.ts" - ] -} diff --git a/examples/aws-astro-redis/.dockerignore b/examples/aws-astro-redis/.dockerignore deleted file mode 100644 index cf88ac3dd3..0000000000 --- a/examples/aws-astro-redis/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -node_modules -dist - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-astro-redis/.gitignore b/examples/aws-astro-redis/.gitignore deleted file mode 100644 index 12ff1bf9ce..0000000000 --- a/examples/aws-astro-redis/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ - -# sst -.sst diff --git a/examples/aws-astro-redis/.vscode/extensions.json b/examples/aws-astro-redis/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro-redis/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro-redis/.vscode/launch.json b/examples/aws-astro-redis/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro-redis/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro-redis/Dockerfile b/examples/aws-astro-redis/Dockerfile deleted file mode 100644 index 843b983342..0000000000 --- a/examples/aws-astro-redis/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# From https://docs.astro.build/en/recipes/docker/ - -FROM node:lts AS base -WORKDIR /app - -# By copying only the package.json and package-lock.json here, we ensure that the following `-deps` steps are independent of the source code. -# Therefore, the `-deps` steps will be skipped if only the source code changes. -COPY package.json package-lock.json ./ - -FROM base AS prod-deps -RUN npm install --omit=dev - -FROM base AS build-deps -RUN npm install - -FROM build-deps AS build -COPY . . -RUN npm run build - -FROM base AS runtime -COPY --from=prod-deps /app/node_modules ./node_modules -COPY --from=build /app/dist ./dist - -ENV HOST=0.0.0.0 -ENV PORT=4321 -EXPOSE 4321 -CMD node ./dist/server/entry.mjs diff --git a/examples/aws-astro-redis/astro.config.mjs b/examples/aws-astro-redis/astro.config.mjs deleted file mode 100644 index b806b438e1..0000000000 --- a/examples/aws-astro-redis/astro.config.mjs +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-check -import { defineConfig } from 'astro/config'; - -import node from '@astrojs/node'; - -// https://astro.build/config -export default defineConfig({ - output: 'server', - - adapter: node({ - mode: 'standalone' - }) -}); \ No newline at end of file diff --git a/examples/aws-astro-redis/package.json b/examples/aws-astro-redis/package.json deleted file mode 100644 index 24ddfc5ac6..0000000000 --- a/examples/aws-astro-redis/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro-redis", - "type": "module", - "version": "0.0.1", - "scripts": { - "astro": "astro", - "build": "astro check && astro build", - "dev": "astro dev", - "preview": "astro preview", - "start": "astro dev" - }, - "dependencies": { - "@astrojs/check": "^0.9.4", - "@astrojs/node": "^8.3.4", - "astro": "^4.16.3", - "astro-sst": "2.43.5", - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js", - "typescript": "^5.6.3" - } -} diff --git a/examples/aws-astro-redis/src/components/Card.astro b/examples/aws-astro-redis/src/components/Card.astro deleted file mode 100644 index bd6d5971eb..0000000000 --- a/examples/aws-astro-redis/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/examples/aws-astro-redis/src/env.d.ts b/examples/aws-astro-redis/src/env.d.ts deleted file mode 100644 index 9bc5cb41c2..0000000000 --- a/examples/aws-astro-redis/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/examples/aws-astro-redis/src/layouts/Layout.astro b/examples/aws-astro-redis/src/layouts/Layout.astro deleted file mode 100644 index 181097125d..0000000000 --- a/examples/aws-astro-redis/src/layouts/Layout.astro +++ /dev/null @@ -1,50 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - - - - - diff --git a/examples/aws-astro-redis/src/pages/index.astro b/examples/aws-astro-redis/src/pages/index.astro deleted file mode 100644 index d6602d4bce..0000000000 --- a/examples/aws-astro-redis/src/pages/index.astro +++ /dev/null @@ -1,44 +0,0 @@ ---- -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import Layout from '../layouts/Layout.astro'; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -const counter = await redis.incr("counter"); ---- - - -
-

Hit counter: {counter}

-
-
- - diff --git a/examples/aws-astro-redis/sst.config.ts b/examples/aws-astro-redis/sst.config.ts deleted file mode 100644 index 621ca85c0a..0000000000 --- a/examples/aws-astro-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Astro container with Redis - * - * Creates a hit counter app with Astro and Redis. - * - * This deploys Astro as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:4321` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by adding the `Dockerfile` that's included in this example and - * running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-astro-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "4321/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-astro-redis/tsconfig.json b/examples/aws-astro-redis/tsconfig.json deleted file mode 100644 index ddbfe3e6f3..0000000000 --- a/examples/aws-astro-redis/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict", - "exclude": ["sst.config.ts"] -} diff --git a/examples/aws-astro-stream/.gitignore b/examples/aws-astro-stream/.gitignore deleted file mode 100644 index 12ff1bf9ce..0000000000 --- a/examples/aws-astro-stream/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ - -# sst -.sst diff --git a/examples/aws-astro-stream/.vscode/extensions.json b/examples/aws-astro-stream/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro-stream/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro-stream/.vscode/launch.json b/examples/aws-astro-stream/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro-stream/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro-stream/astro.config.mjs b/examples/aws-astro-stream/astro.config.mjs deleted file mode 100644 index d08eebd972..0000000000 --- a/examples/aws-astro-stream/astro.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-check -import aws from "astro-sst"; -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - output: "server", - adapter: aws({ - responseMode: "stream", - }), -}); diff --git a/examples/aws-astro-stream/package.json b/examples/aws-astro-stream/package.json deleted file mode 100644 index d2ee3a1fb7..0000000000 --- a/examples/aws-astro-stream/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-astro-stream", - "type": "module", - "version": "0.0.1", - "scripts": { - "astro": "astro", - "build": "astro check && astro build", - "dev": "astro dev", - "preview": "astro preview", - "start": "astro dev" - }, - "dependencies": { - "@astrojs/check": "^0.9.3", - "astro": "^4.15.9", - "astro-sst": "2.43.5", - "sst": "file:../../sdk/js", - "typescript": "^5.6.2" - } -} diff --git a/examples/aws-astro-stream/public/favicon.svg b/examples/aws-astro-stream/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-astro-stream/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-astro-stream/public/mr-krabs.png b/examples/aws-astro-stream/public/mr-krabs.png deleted file mode 100644 index e94ea64054..0000000000 Binary files a/examples/aws-astro-stream/public/mr-krabs.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/patrick.png b/examples/aws-astro-stream/public/patrick.png deleted file mode 100644 index 030eaaf8a3..0000000000 Binary files a/examples/aws-astro-stream/public/patrick.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/sandy.png b/examples/aws-astro-stream/public/sandy.png deleted file mode 100644 index eb7a9cc324..0000000000 Binary files a/examples/aws-astro-stream/public/sandy.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/spongebob.png b/examples/aws-astro-stream/public/spongebob.png deleted file mode 100644 index 18f7df537e..0000000000 Binary files a/examples/aws-astro-stream/public/spongebob.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/squidward.png b/examples/aws-astro-stream/public/squidward.png deleted file mode 100644 index 4af85e000b..0000000000 Binary files a/examples/aws-astro-stream/public/squidward.png and /dev/null differ diff --git a/examples/aws-astro-stream/src/components/Bio.astro b/examples/aws-astro-stream/src/components/Bio.astro deleted file mode 100644 index 0cac88361e..0000000000 --- a/examples/aws-astro-stream/src/components/Bio.astro +++ /dev/null @@ -1,35 +0,0 @@ ---- -import type { Character } from "./character"; - -const spongebob: Character = { - name: "SpongeBob SquarePants", - description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.", - image: "spongebob.png", -}; ---- -
-

{spongebob.name}

-
-
-

{spongebob.description}

-
- {spongebob.name} -
-
- - diff --git a/examples/aws-astro-stream/src/components/Friends.astro b/examples/aws-astro-stream/src/components/Friends.astro deleted file mode 100644 index b3f69f2815..0000000000 --- a/examples/aws-astro-stream/src/components/Friends.astro +++ /dev/null @@ -1,43 +0,0 @@ ---- -import type { Character } from "./character"; - -const friends: Character[] = await new Promise((resolve) => setTimeout(() => { - setTimeout(() => { - resolve( - [ - { name: "Patrick Star", image: "patrick.png" }, - { name: "Sandy Cheeks", image: "sandy.png" }, - { name: "Squidward Tentacles", image: "squidward.png" }, - { name: "Mr. Krabs", image: "mr-krabs.png" }, - ] - ); - }, 3000); -})); ---- -
- {friends.map((friend) => ( -
- {friend.name} -

{friend.name}

-
- ))} -
- - diff --git a/examples/aws-astro-stream/src/components/character.ts b/examples/aws-astro-stream/src/components/character.ts deleted file mode 100644 index b1c51ce400..0000000000 --- a/examples/aws-astro-stream/src/components/character.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface Character { - name: string; - image: string; - description?: string; -} diff --git a/examples/aws-astro-stream/src/env.d.ts b/examples/aws-astro-stream/src/env.d.ts deleted file mode 100644 index 9bc5cb41c2..0000000000 --- a/examples/aws-astro-stream/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/examples/aws-astro-stream/src/layouts/Layout.astro b/examples/aws-astro-stream/src/layouts/Layout.astro deleted file mode 100644 index 9b3c662692..0000000000 --- a/examples/aws-astro-stream/src/layouts/Layout.astro +++ /dev/null @@ -1,39 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - -
- -
- - - diff --git a/examples/aws-astro-stream/src/pages/index.astro b/examples/aws-astro-stream/src/pages/index.astro deleted file mode 100644 index 8b90a967db..0000000000 --- a/examples/aws-astro-stream/src/pages/index.astro +++ /dev/null @@ -1,73 +0,0 @@ ---- -import Layout from '../layouts/Layout.astro'; -import Bio from '../components/Bio.astro'; -import Friends from '../components/Friends.astro'; ---- - - - - -
-

Friends from Bikini Bottom

- -
-
- - diff --git a/examples/aws-astro-stream/sst.config.ts b/examples/aws-astro-stream/sst.config.ts deleted file mode 100644 index 856fce0412..0000000000 --- a/examples/aws-astro-stream/sst.config.ts +++ /dev/null @@ -1,70 +0,0 @@ -/// - -/** - * ## AWS Astro streaming - * - * Follows the [Astro Streaming](https://docs.astro.build/en/recipes/streaming-improve-page-performance/) guide to create an app that streams HTML. - * - * The `responseMode` in the [`astro-sst`](https://www.npmjs.com/package/astro-sst) adapter - * is set to enable streaming. - * - * - * ```ts title="astro.config.mjs" - * adapter: aws({ - * responseMode: "stream" - * }) - * ``` - * - * Now any components that return promises will be streamed. - * - * ```astro title="src/components/Friends.astro" - * --- - * import type { Character } from "./character"; - * - * const friends: Character[] = await new Promise((resolve) => setTimeout(() => { - * setTimeout(() => { - * resolve( - * [ - * { name: "Patrick Star", image: "patrick.png" }, - * { name: "Sandy Cheeks", image: "sandy.png" }, - * { name: "Squidward Tentacles", image: "squidward.png" }, - * { name: "Mr. Krabs", image: "mr-krabs.png" }, - * ] - * ); - * }, 3000); - * })); - * --- - *
- * {friends.map((friend) => ( - *
- * {friend.name} - *

{friend.name}

- *
- * ))} - *
- * ``` - * - * You should see the _friends_ section load after a 3 second delay. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - * - * There's nothing to configure for streaming in the `Astro` component. - */ -export default $config({ - app(input) { - return { - name: "aws-astro-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Astro("MyWeb"); - }, -}); diff --git a/examples/aws-astro-stream/tsconfig.json b/examples/aws-astro-stream/tsconfig.json deleted file mode 100644 index 77da9dd009..0000000000 --- a/examples/aws-astro-stream/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -} \ No newline at end of file diff --git a/examples/aws-astro/.vscode/extensions.json b/examples/aws-astro/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro/.vscode/launch.json b/examples/aws-astro/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro/astro.config.mjs b/examples/aws-astro/astro.config.mjs deleted file mode 100644 index b4f287b9a8..0000000000 --- a/examples/aws-astro/astro.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from "astro/config"; -import aws from "astro-sst"; - -export default defineConfig({ - output: "server", - adapter: aws(), -}); diff --git a/examples/aws-astro/package.json b/examples/aws-astro/package.json deleted file mode 100644 index 6c677d9e32..0000000000 --- a/examples/aws-astro/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro", - "type": "module", - "version": "0.0.1", - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro check && astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/check": "^0.5.10", - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "astro": "^4.5.9", - "astro-sst": "^2.41.2", - "sst": "file:../../sdk/js", - "typescript": "^5.4.3" - } -} diff --git a/examples/aws-astro/public/favicon.svg b/examples/aws-astro/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-astro/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-astro/src/components/Card.astro b/examples/aws-astro/src/components/Card.astro deleted file mode 100644 index bd6d5971eb..0000000000 --- a/examples/aws-astro/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/examples/aws-astro/src/layouts/Layout.astro b/examples/aws-astro/src/layouts/Layout.astro deleted file mode 100644 index 7b552be19b..0000000000 --- a/examples/aws-astro/src/layouts/Layout.astro +++ /dev/null @@ -1,51 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - - - - - diff --git a/examples/aws-astro/src/pages/index.astro b/examples/aws-astro/src/pages/index.astro deleted file mode 100644 index cb2889fa2a..0000000000 --- a/examples/aws-astro/src/pages/index.astro +++ /dev/null @@ -1,74 +0,0 @@ ---- -import { Resource } from "sst"; -import Layout from '../layouts/Layout.astro'; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- - - -
-
- - -
- -
-
- - diff --git a/examples/aws-astro/sst.config.ts b/examples/aws-astro/sst.config.ts deleted file mode 100644 index f115965f2c..0000000000 --- a/examples/aws-astro/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-astro", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - new sst.aws.Astro("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-astro/tsconfig.json b/examples/aws-astro/tsconfig.json deleted file mode 100644 index 77da9dd009..0000000000 --- a/examples/aws-astro/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -} \ No newline at end of file diff --git a/examples/aws-aurora-local/.gitignore b/examples/aws-aurora-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-aurora-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-aurora-local/index.ts b/examples/aws-aurora-local/index.ts deleted file mode 100644 index b0f7a15ddd..0000000000 --- a/examples/aws-aurora-local/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import postgres from "postgres"; -import { Resource } from "sst"; - -const sql = postgres({ - username: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, -}); - -export async function handler() { - const result = await sql`SELECT NOW()`; - - return { - statusCode: 200, - body: `Querying ${Resource.MyPostgres.host}\n\n` + result.rows[0].now, - }; -} diff --git a/examples/aws-aurora-local/package.json b/examples/aws-aurora-local/package.json deleted file mode 100644 index d1dee66d4c..0000000000 --- a/examples/aws-aurora-local/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-aurora-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "postgres": "^3.4.5", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-aurora-local/sst.config.ts b/examples/aws-aurora-local/sst.config.ts deleted file mode 100644 index 940240acb1..0000000000 --- a/examples/aws-aurora-local/sst.config.ts +++ /dev/null @@ -1,87 +0,0 @@ -/// - -/** - * ## AWS Aurora local - * - * In this example, we connect to a locally running Postgres instance for dev. While - * on deploy, we use RDS Aurora. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local container with Postgres. You don't have to use Docker, you can use - * Postgres.app or any other way to run Postgres locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 5432:5432 \ - * -v $(pwd)/.sst/storage/postgres:/var/lib/postgresql/data \ - * -e POSTGRES_USER=postgres \ - * -e POSTGRES_PASSWORD=password \ - * -e POSTGRES_DB=local \ - * postgres:16.4 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `Aurora` component with the settings for the - * local Postgres instance. - * - * ```ts title="sst.config.ts" - * dev: { - * username: "postgres", - * password: "password", - * database: "local", - * port: 5432, - * } - * ``` - * - * By providing the `dev` prop for Postgres, SST will use the local Postgres instance and - * not deploy a new RDS database when running `sst dev`. - * - * It also allows us to access the database through a Resource `link` without having to - * conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const pool = new Pool({ - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-aurora-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const database = new sst.aws.Aurora("MyPostgres", { - engine: "postgres", - dev: { - username: "postgres", - password: "password", - database: "local", - host: "localhost", - port: 5432, - }, - vpc, - }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [database], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-aurora-local/tsconfig.json b/examples/aws-aurora-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-aurora-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-aurora-mysql/index.ts b/examples/aws-aurora-mysql/index.ts deleted file mode 100644 index dcfc68e8b2..0000000000 --- a/examples/aws-aurora-mysql/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Resource } from "sst"; -import mysql from "mysql2/promise"; - -const connection = await mysql.createConnection({ - database: Resource.MyDatabase.database, - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, -}); - -export async function handler() { - const [rows] = await connection.query("SELECT ? as message", [ - "Hello world!", - ]); - return { - statusCode: 200, - body: rows[0].message, - }; -} diff --git a/examples/aws-aurora-mysql/package.json b/examples/aws-aurora-mysql/package.json deleted file mode 100644 index e1996251eb..0000000000 --- a/examples/aws-aurora-mysql/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-aurora-mysql", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "mysql2": "^3.12.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-aurora-mysql/sst.config.ts b/examples/aws-aurora-mysql/sst.config.ts deleted file mode 100644 index 72f57b73ac..0000000000 --- a/examples/aws-aurora-mysql/sst.config.ts +++ /dev/null @@ -1,83 +0,0 @@ -/// - -/** - * ## AWS Aurora MySQL - * - * In this example, we deploy a Aurora MySQL database. - * - * ```ts title="sst.config.ts" - * const mysql = new sst.aws.Aurora("MyDatabase", { - * engine: "mysql", - * vpc, - * }); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyApp", { - * handler: "index.handler", - * link: [mysql], - * url: true, - * vpc, - * }); - * ``` - * - * Now in the function we can access the database. - * - * ```ts title="index.ts" - * const connection = await mysql.createConnection({ - * database: Resource.MyDatabase.database, - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * user: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * }); - * ``` - * - * We also enable the `bastion` option for the VPC. This allows us to connect to the database - * from our local machine with the `sst tunnel` CLI. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * Now you can run `npx sst dev` and you can connect to the database from your local machine. - * - */ -export default $config({ - app(input) { - return { - name: "aws-aurora-mysql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { - nat: "ec2", - bastion: true, - }); - const mysql = new sst.aws.Aurora("MyDatabase", { - engine: "mysql", - vpc, - }); - new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [mysql], - url: true, - vpc, - }); - - return { - host: mysql.host, - port: mysql.port, - username: mysql.username, - password: mysql.password, - database: mysql.database, - }; - }, -}); diff --git a/examples/aws-aurora-postgres/index.ts b/examples/aws-aurora-postgres/index.ts deleted file mode 100644 index cf76e8201a..0000000000 --- a/examples/aws-aurora-postgres/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import postgres from "postgres"; -import { Resource } from "sst"; - -const sql = postgres({ - username: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, -}); - -export async function handler() { - const res = await sql`SELECT ${"Hello world!"}::text as message`; - return { - statusCode: 200, - body: res.at(0)?.message, - }; -} diff --git a/examples/aws-aurora-postgres/package.json b/examples/aws-aurora-postgres/package.json deleted file mode 100644 index 941512a6ae..0000000000 --- a/examples/aws-aurora-postgres/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-aurora-postgres", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "postgres": "^3.4.5", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-aurora-postgres/sst.config.ts b/examples/aws-aurora-postgres/sst.config.ts deleted file mode 100644 index 55cfeda634..0000000000 --- a/examples/aws-aurora-postgres/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS Aurora Postgres - * - * In this example, we deploy a Aurora Postgres database. - * - * ```ts title="sst.config.ts" - * const postgres = new sst.aws.Aurora("MyDatabase", { - * engine: "postgres", - * vpc, - * }); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyApp", { - * handler: "index.handler", - * link: [postgres], - * url: true, - * vpc, - * }); - * ``` - * - * In the function we use the [`postgres`](https://www.npmjs.com/package/postgres) package. - * - * ```ts title="index.ts" - * import postgres from "postgres"; - * import { Resource } from "sst"; - * - * const sql = postgres({ - * username: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * database: Resource.MyDatabase.database, - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * }); - * ``` - * - * We also enable the `bastion` option for the VPC. This allows us to connect to the database - * from our local machine with the `sst tunnel` CLI. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * Now you can run `npx sst dev` and you can connect to the database from your local machine. - * - */ -export default $config({ - app(input) { - return { - name: "aws-aurora-postgres", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { - nat: "ec2", - bastion: true, - }); - const postgres = new sst.aws.Aurora("MyDatabase", { - engine: "postgres", - vpc, - }); - new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [postgres], - url: true, - vpc, - }); - - return { - host: postgres.host, - port: postgres.port, - username: postgres.username, - password: postgres.password, - database: postgres.database, - }; - }, -}); diff --git a/examples/aws-auth-nextjs/.gitignore b/examples/aws-auth-nextjs/.gitignore deleted file mode 100644 index 845fae0e4b..0000000000 --- a/examples/aws-auth-nextjs/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# env files (can opt-in for committing if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-auth-nextjs/app/actions.ts b/examples/aws-auth-nextjs/app/actions.ts deleted file mode 100644 index 1a3e291c37..0000000000 --- a/examples/aws-auth-nextjs/app/actions.ts +++ /dev/null @@ -1,62 +0,0 @@ -"use server"; - -import { redirect } from "next/navigation"; -import { headers as getHeaders, cookies as getCookies } from "next/headers"; -import { subjects } from "../auth/subjects"; -import { client, setTokens } from "./auth"; - -export async function auth() { - const cookies = await getCookies(); - const accessToken = cookies.get("access_token"); - const refreshToken = cookies.get("refresh_token"); - - if (!accessToken) { - return false; - } - - const verified = await client.verify(subjects, accessToken.value, { - refresh: refreshToken?.value, - }); - - if (verified.err) { - return false; - } - if (verified.tokens) { - await setTokens(verified.tokens.access, verified.tokens.refresh); - } - - return verified.subject; -} - -export async function login() { - const cookies = await getCookies(); - const accessToken = cookies.get("access_token"); - const refreshToken = cookies.get("refresh_token"); - - if (accessToken) { - const verified = await client.verify(subjects, accessToken.value, { - refresh: refreshToken?.value, - }); - if (!verified.err && verified.tokens) { - await setTokens(verified.tokens.access, verified.tokens.refresh); - redirect("/"); - } - } - - const headers = await getHeaders(); - const host = headers.get("host"); - const protocol = host?.includes("localhost") ? "http" : "https"; - const { url } = await client.authorize( - `${protocol}://${host}/api/callback`, - "code", - ); - redirect(url); -} - -export async function logout() { - const cookies = await getCookies(); - cookies.delete("access_token"); - cookies.delete("refresh_token"); - - redirect("/"); -} diff --git a/examples/aws-auth-nextjs/app/api/callback/route.ts b/examples/aws-auth-nextjs/app/api/callback/route.ts deleted file mode 100644 index 6bcce834a7..0000000000 --- a/examples/aws-auth-nextjs/app/api/callback/route.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { client, setTokens } from "../../auth"; -import { type NextRequest, NextResponse } from "next/server"; - -export async function GET(req: NextRequest) { - const url = new URL(req.url); - const code = url.searchParams.get("code"); - - const exchanged = await client.exchange(code!, `${url.origin}/api/callback`); - - if (exchanged.err) return NextResponse.json(exchanged.err, { status: 400 }); - - await setTokens(exchanged.tokens.access, exchanged.tokens.refresh); - - return NextResponse.redirect(`${url.origin}/`); -} diff --git a/examples/aws-auth-nextjs/app/auth.ts b/examples/aws-auth-nextjs/app/auth.ts deleted file mode 100644 index 792ad3aeea..0000000000 --- a/examples/aws-auth-nextjs/app/auth.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Resource } from "sst"; -import { createClient } from "@openauthjs/openauth/client"; -import { cookies as getCookies } from "next/headers"; - -export const client = createClient({ - clientID: "nextjs", - issuer: Resource.MyAuth.url, -}); - -export async function setTokens(access: string, refresh: string) { - const cookies = await getCookies(); - - cookies.set({ - name: "access_token", - value: access, - httpOnly: true, - sameSite: "lax", - path: "/", - maxAge: 34560000, - }); - cookies.set({ - name: "refresh_token", - value: refresh, - httpOnly: true, - sameSite: "lax", - path: "/", - maxAge: 34560000, - }); -} diff --git a/examples/aws-auth-nextjs/app/globals.css b/examples/aws-auth-nextjs/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-auth-nextjs/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-auth-nextjs/app/layout.tsx b/examples/aws-auth-nextjs/app/layout.tsx deleted file mode 100644 index 8cdb9eb3b3..0000000000 --- a/examples/aws-auth-nextjs/app/layout.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import type { Metadata } from "next" -import { Geist, Geist_Mono } from "next/font/google" -import "./globals.css" - -const geistSans = Geist({ - variable: "--font-geist-sans", - subsets: ["latin"], -}) - -const geistMono = Geist_Mono({ - variable: "--font-geist-mono", - subsets: ["latin"], -}) - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -} - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode -}>) { - return ( - - - {children} - - - ) -} diff --git a/examples/aws-auth-nextjs/app/page.module.css b/examples/aws-auth-nextjs/app/page.module.css deleted file mode 100644 index 1f4ec4aaf0..0000000000 --- a/examples/aws-auth-nextjs/app/page.module.css +++ /dev/null @@ -1,200 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} - -.ctas button { - appearance: none; - background: transparent; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -button.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -button.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} diff --git a/examples/aws-auth-nextjs/app/page.tsx b/examples/aws-auth-nextjs/app/page.tsx deleted file mode 100644 index 0916983bd4..0000000000 --- a/examples/aws-auth-nextjs/app/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Image from "next/image"; -import styles from "./page.module.css"; -import { auth, login, logout } from "./actions"; - -export default async function Home() { - const subject = await auth(); - - return ( -
-
- Next.js logo -
    - {subject ? ( - <> -
  1. - Logged in as {subject.properties.id}. -
  2. -
  3. - And then check out app/page.tsx. -
  4. - - ) : ( - <> -
  5. Login with your email and password.
  6. -
  7. - And then check out app/page.tsx. -
  8. - - )} -
- -
- {subject ? ( -
- -
- ) : ( -
- -
- )} -
-
-
- ); -} diff --git a/examples/aws-auth-nextjs/auth/index.ts b/examples/aws-auth-nextjs/auth/index.ts deleted file mode 100644 index 7e298f674d..0000000000 --- a/examples/aws-auth-nextjs/auth/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { handle } from "hono/aws-lambda"; -import { issuer } from "@openauthjs/openauth"; -import { CodeUI } from "@openauthjs/openauth/ui/code"; -import { CodeProvider } from "@openauthjs/openauth/provider/code"; -import { subjects } from "./subjects"; - -async function getUser(email: string) { - // Get user from database and return user ID - return "123"; -} - -const app = issuer({ - subjects, - // Remove after setting custom domain - allow: async () => true, - providers: { - code: CodeProvider( - CodeUI({ - sendCode: async (email, code) => { - console.log(email, code); - }, - }), - ), - }, - success: async (ctx, value) => { - if (value.provider === "code") { - return ctx.subject("user", { - id: await getUser(value.claims.email), - }); - } - throw new Error("Invalid provider"); - }, -}); - -export const handler = handle(app); diff --git a/examples/aws-auth-nextjs/auth/subjects.ts b/examples/aws-auth-nextjs/auth/subjects.ts deleted file mode 100644 index f8e6ed2f57..0000000000 --- a/examples/aws-auth-nextjs/auth/subjects.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { object, string } from "valibot"; -import { createSubjects } from "@openauthjs/openauth/subject"; - -export const subjects = createSubjects({ - user: object({ - id: string(), - }), -}); diff --git a/examples/aws-auth-nextjs/next.config.ts b/examples/aws-auth-nextjs/next.config.ts deleted file mode 100644 index 3b84f68abf..0000000000 --- a/examples/aws-auth-nextjs/next.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { NextConfig } from "next" - -const nextConfig: NextConfig = { - /* config options here */ -} - -export default nextConfig diff --git a/examples/aws-auth-nextjs/package.json b/examples/aws-auth-nextjs/package.json deleted file mode 100644 index 0c83c699ac..0000000000 --- a/examples/aws-auth-nextjs/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "aws-auth-nextjs", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@openauthjs/openauth": "latest", - "hono": "^4.6.16", - "next": "15.1.4", - "react": "^19.0.0", - "react-dom": "^19.0.0", - "sst": "file:../../sdk/js", - "valibot": "^1.0.0-beta.11" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^19", - "@types/react-dom": "^19", - "typescript": "^5" - } -} diff --git a/examples/aws-auth-nextjs/public/file.svg b/examples/aws-auth-nextjs/public/file.svg deleted file mode 100644 index 004145cddf..0000000000 --- a/examples/aws-auth-nextjs/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/globe.svg b/examples/aws-auth-nextjs/public/globe.svg deleted file mode 100644 index 567f17b0d7..0000000000 --- a/examples/aws-auth-nextjs/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/vercel.svg b/examples/aws-auth-nextjs/public/vercel.svg deleted file mode 100644 index 7705396033..0000000000 --- a/examples/aws-auth-nextjs/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/window.svg b/examples/aws-auth-nextjs/public/window.svg deleted file mode 100644 index b2b2a44f6e..0000000000 --- a/examples/aws-auth-nextjs/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/sst.config.ts b/examples/aws-auth-nextjs/sst.config.ts deleted file mode 100644 index 17a8c02f8a..0000000000 --- a/examples/aws-auth-nextjs/sst.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-auth-nextjs", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const auth = new sst.aws.Auth("MyAuth", { - issuer: "auth/index.handler", - }); - - new sst.aws.Nextjs("MyWeb", { - link: [auth], - }); - }, -}); diff --git a/examples/aws-auth-nextjs/tsconfig.json b/examples/aws-auth-nextjs/tsconfig.json deleted file mode 100644 index 30ced59690..0000000000 --- a/examples/aws-auth-nextjs/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules", "sst.config.ts"] -} diff --git a/examples/aws-auth-react/.gitignore b/examples/aws-auth-react/.gitignore deleted file mode 100644 index e2ead72a02..0000000000 --- a/examples/aws-auth-react/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# dependencies -node_modules - -# sst -.sst - -# tmp files -.#* - -# env -.env*.local -.env - -# opennext -.open-next - -# misc -.DS_Store diff --git a/examples/aws-auth-react/LICENSE b/examples/aws-auth-react/LICENSE deleted file mode 100644 index c6eca6eed7..0000000000 --- a/examples/aws-auth-react/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 SST - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/examples/aws-auth-react/infra/api.ts b/examples/aws-auth-react/infra/api.ts deleted file mode 100644 index e3e4d07413..0000000000 --- a/examples/aws-auth-react/infra/api.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { auth } from "./auth"; - -export const api = new sst.aws.Function("MyApi", { - url: true, - link: [auth], - handler: "packages/functions/src/api.handler", -}); diff --git a/examples/aws-auth-react/infra/auth.ts b/examples/aws-auth-react/infra/auth.ts deleted file mode 100644 index 96e0d2c7af..0000000000 --- a/examples/aws-auth-react/infra/auth.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const auth = new sst.aws.Auth("MyAuth", { - issuer: "packages/functions/src/auth.handler", -}); - diff --git a/examples/aws-auth-react/infra/web.ts b/examples/aws-auth-react/infra/web.ts deleted file mode 100644 index c49c45496d..0000000000 --- a/examples/aws-auth-react/infra/web.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { api } from "./api"; -import { auth } from "./auth"; - -export const web = new sst.aws.StaticSite("MyWeb", { - path: "packages/web", - build: { - output: "dist", - command: "npm run build", - }, - environment: { - VITE_API_URL: api.url, - VITE_AUTH_URL: auth.url, - }, -}); - diff --git a/examples/aws-auth-react/package.json b/examples/aws-auth-react/package.json deleted file mode 100644 index 1f1027b316..0000000000 --- a/examples/aws-auth-react/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-auth-react", - "version": "0.0.0", - "workspaces": [ - "packages/*" - ], - "scripts": {}, - "devDependencies": { - "@tsconfig/node22": "^22", - "typescript": "^5" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-auth-react/packages/core/package.json b/examples/aws-auth-react/packages/core/package.json deleted file mode 100644 index e7d239d85e..0000000000 --- a/examples/aws-auth-react/packages/core/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@aws-auth-react/core", - "type": "module", - "version": "0.0.0", - "scripts": { - "test": "sst shell vitest" - }, - "exports": { - "./*": [ - "./src/*/index.ts", - "./src/*.ts" - ] - }, - "dependencies": { - "sst": "file:../../../../sdk/js" - }, - "devDependencies": { - "vitest": "^2" - } -} diff --git a/examples/aws-auth-react/packages/core/src/example/index.ts b/examples/aws-auth-react/packages/core/src/example/index.ts deleted file mode 100644 index 9cb1c03477..0000000000 --- a/examples/aws-auth-react/packages/core/src/example/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export namespace Example { - export function hello() { - return "Hello, world!"; - } -} diff --git a/examples/aws-auth-react/packages/core/src/example/test/index.test.ts b/examples/aws-auth-react/packages/core/src/example/test/index.test.ts deleted file mode 100644 index 18d84d117b..0000000000 --- a/examples/aws-auth-react/packages/core/src/example/test/index.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, test } from "vitest"; -import { Example } from "../"; - -test("Hello test", () => { - const expected = "Hello, world!"; - - expect(Example.hello()).toEqual(expected); -}); diff --git a/examples/aws-auth-react/packages/core/tsconfig.json b/examples/aws-auth-react/packages/core/tsconfig.json deleted file mode 100644 index be3c6ace73..0000000000 --- a/examples/aws-auth-react/packages/core/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-auth-react/packages/functions/package.json b/examples/aws-auth-react/packages/functions/package.json deleted file mode 100644 index c6348f56a0..0000000000 --- a/examples/aws-auth-react/packages/functions/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@aws-auth-react/functions", - "version": "0.0.0", - "type": "module", - "dependencies": { - "@aws-auth-react/core": "*", - "@openauthjs/openauth": "^0.3.6", - "hono": "^4.6.18", - "sst": "file:../../../../sdk/js", - "valibot": "^1.0.0-beta.14" - }, - "devDependencies": { - "@types/aws-lambda": "^8" - } -} diff --git a/examples/aws-auth-react/packages/functions/src/api.ts b/examples/aws-auth-react/packages/functions/src/api.ts deleted file mode 100644 index ee2410c0c3..0000000000 --- a/examples/aws-auth-react/packages/functions/src/api.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Hono } from "hono"; -import { Resource } from "sst"; -import { handle } from "hono/aws-lambda"; -import { createClient } from "@openauthjs/openauth/client"; -import { subjects } from "./subjects"; - -const client = createClient({ - clientID: "jwt-api", - issuer: Resource.MyAuth.url, -}); - -async function getUserInfo(userId: string) { - // Get user from database - return { - userId, - name: "Patrick Star", - }; -} - -const app = new Hono(); - -app.get("/me", async (c) => { - const authHeader = c.req.header("Authorization"); - - if (!authHeader) { - return c.status(401); - } - - const token = authHeader.split(" ")[1]; - const verified = await client.verify(subjects, token); - - if (verified.err) { - return c.status(401); - } - - return c.json(await getUserInfo(verified.subject.properties.id)); -}); - -export const handler = handle(app); diff --git a/examples/aws-auth-react/packages/functions/src/auth.ts b/examples/aws-auth-react/packages/functions/src/auth.ts deleted file mode 100644 index 7e298f674d..0000000000 --- a/examples/aws-auth-react/packages/functions/src/auth.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { handle } from "hono/aws-lambda"; -import { issuer } from "@openauthjs/openauth"; -import { CodeUI } from "@openauthjs/openauth/ui/code"; -import { CodeProvider } from "@openauthjs/openauth/provider/code"; -import { subjects } from "./subjects"; - -async function getUser(email: string) { - // Get user from database and return user ID - return "123"; -} - -const app = issuer({ - subjects, - // Remove after setting custom domain - allow: async () => true, - providers: { - code: CodeProvider( - CodeUI({ - sendCode: async (email, code) => { - console.log(email, code); - }, - }), - ), - }, - success: async (ctx, value) => { - if (value.provider === "code") { - return ctx.subject("user", { - id: await getUser(value.claims.email), - }); - } - throw new Error("Invalid provider"); - }, -}); - -export const handler = handle(app); diff --git a/examples/aws-auth-react/packages/functions/src/subjects.ts b/examples/aws-auth-react/packages/functions/src/subjects.ts deleted file mode 100644 index f8e6ed2f57..0000000000 --- a/examples/aws-auth-react/packages/functions/src/subjects.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { object, string } from "valibot"; -import { createSubjects } from "@openauthjs/openauth/subject"; - -export const subjects = createSubjects({ - user: object({ - id: string(), - }), -}); diff --git a/examples/aws-auth-react/packages/functions/tsconfig.json b/examples/aws-auth-react/packages/functions/tsconfig.json deleted file mode 100644 index be3c6ace73..0000000000 --- a/examples/aws-auth-react/packages/functions/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-auth-react/packages/scripts/package.json b/examples/aws-auth-react/packages/scripts/package.json deleted file mode 100644 index 39ae89e8c4..0000000000 --- a/examples/aws-auth-react/packages/scripts/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@aws-auth-react/scripts", - "version": "0.0.0", - "type": "module", - "dependencies": { - "@aws-auth-react/core": "*", - "sst": "file:../../../../sdk/js" - }, - "scripts": { - "shell": "sst shell tsx" - }, - "devDependencies": { - "@types/node": "^22", - "tsx": "^4" - } -} diff --git a/examples/aws-auth-react/packages/scripts/src/example.ts b/examples/aws-auth-react/packages/scripts/src/example.ts deleted file mode 100644 index 44c3c0263b..0000000000 --- a/examples/aws-auth-react/packages/scripts/src/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Resource } from "sst"; -import { Example } from "@aws-auth-react/core/example"; - -console.log(`${Example.hello()} Linked to ${Resource.MyBucket.name}.`); diff --git a/examples/aws-auth-react/packages/scripts/tsconfig.json b/examples/aws-auth-react/packages/scripts/tsconfig.json deleted file mode 100644 index be3c6ace73..0000000000 --- a/examples/aws-auth-react/packages/scripts/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-auth-react/packages/web/eslint.config.js b/examples/aws-auth-react/packages/web/eslint.config.js deleted file mode 100644 index 092408a9f0..0000000000 --- a/examples/aws-auth-react/packages/web/eslint.config.js +++ /dev/null @@ -1,28 +0,0 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' - -export default tseslint.config( - { ignores: ['dist'] }, - { - extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - }, - plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, - }, -) diff --git a/examples/aws-auth-react/packages/web/index.html b/examples/aws-auth-react/packages/web/index.html deleted file mode 100644 index e4b78eae12..0000000000 --- a/examples/aws-auth-react/packages/web/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + React + TS - - -
- - - diff --git a/examples/aws-auth-react/packages/web/package.json b/examples/aws-auth-react/packages/web/package.json deleted file mode 100644 index 4afc4bb251..0000000000 --- a/examples/aws-auth-react/packages/web/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "web", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc -b && vite build", - "lint": "eslint .", - "preview": "vite preview" - }, - "dependencies": { - "@openauthjs/openauth": "^0.3.8", - "react": "^18.3.1", - "react-dom": "^18.3.1" - }, - "devDependencies": { - "@eslint/js": "^9.17.0", - "@types/react": "^18.3.18", - "@types/react-dom": "^18.3.5", - "@vitejs/plugin-react": "^4.3.4", - "eslint": "^9.17.0", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.16", - "globals": "^15.14.0", - "typescript": "~5.6.2", - "typescript-eslint": "^8.18.2", - "vite": "^6.0.5" - } -} diff --git a/examples/aws-auth-react/packages/web/public/vite.svg b/examples/aws-auth-react/packages/web/public/vite.svg deleted file mode 100644 index e7b8dfb1b2..0000000000 --- a/examples/aws-auth-react/packages/web/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-react/packages/web/src/App.css b/examples/aws-auth-react/packages/web/src/App.css deleted file mode 100644 index 79f55915a0..0000000000 --- a/examples/aws-auth-react/packages/web/src/App.css +++ /dev/null @@ -1,48 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} - -.controls { - display: flex; - justify-content: center; - gap: 1rem; -} diff --git a/examples/aws-auth-react/packages/web/src/App.tsx b/examples/aws-auth-react/packages/web/src/App.tsx deleted file mode 100644 index e049b006ec..0000000000 --- a/examples/aws-auth-react/packages/web/src/App.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { useState } from "react"; -import { useAuth } from "./AuthContext"; -import "./App.css"; - -function App() { - const auth = useAuth(); - const [status, setStatus] = useState(""); - - async function callApi() { - const res = await fetch(`${import.meta.env.VITE_API_URL}me`, { - headers: { - Authorization: `Bearer ${await auth.getToken()}`, - }, - }); - - setStatus(res.ok ? await res.text() : "error"); - } - - return !auth.loaded ? ( -
Loading...
- ) : ( -
- {auth.loggedIn ? ( -
-

- Logged in - {auth.userId && as {auth.userId}} -

- {status !== "" &&

API call: {status}

} -
- - -
-
- ) : ( - - )} -
- ); -} - -export default App; diff --git a/examples/aws-auth-react/packages/web/src/AuthContext.tsx b/examples/aws-auth-react/packages/web/src/AuthContext.tsx deleted file mode 100644 index 821757a6f9..0000000000 --- a/examples/aws-auth-react/packages/web/src/AuthContext.tsx +++ /dev/null @@ -1,156 +0,0 @@ -import { - useRef, - useState, - ReactNode, - useEffect, - useContext, - createContext, -} from "react"; -import { createClient } from "@openauthjs/openauth/client"; - -const client = createClient({ - clientID: "web", - issuer: import.meta.env.VITE_AUTH_URL, -}); - -interface AuthContextType { - userId?: string; - loaded: boolean; - loggedIn: boolean; - logout: () => void; - login: () => Promise; - getToken: () => Promise; -} - -const AuthContext = createContext({} as AuthContextType); - -export function AuthProvider({ children }: { children: ReactNode }) { - const initializing = useRef(true); - const [loaded, setLoaded] = useState(false); - const [loggedIn, setLoggedIn] = useState(false); - const token = useRef(undefined); - const [userId, setUserId] = useState(); - - useEffect(() => { - const hash = new URLSearchParams(location.search.slice(1)); - const code = hash.get("code"); - const state = hash.get("state"); - - if (!initializing.current) { - return; - } - - initializing.current = false; - - if (code && state) { - callback(code, state); - return; - } - - auth(); - }, []); - - async function auth() { - const token = await refreshTokens(); - - if (token) { - await user(); - } - - setLoaded(true); - } - - async function refreshTokens() { - const refresh = localStorage.getItem("refresh"); - if (!refresh) return; - const next = await client.refresh(refresh, { - access: token.current, - }); - if (next.err) return; - if (!next.tokens) return token.current; - - localStorage.setItem("refresh", next.tokens.refresh); - token.current = next.tokens.access; - - return next.tokens.access; - } - - async function getToken() { - const token = await refreshTokens(); - - if (!token) { - await login(); - return; - } - - return token; - } - - async function login() { - const { challenge, url } = await client.authorize(location.origin, "code", { - pkce: true, - }); - sessionStorage.setItem("challenge", JSON.stringify(challenge)); - location.href = url; - } - - async function callback(code: string, state: string) { - console.log("callback", code, state); - const challenge = JSON.parse(sessionStorage.getItem("challenge")!); - if (code) { - if (state === challenge.state && challenge.verifier) { - const exchanged = await client.exchange( - code!, - location.origin, - challenge.verifier, - ); - if (!exchanged.err) { - token.current = exchanged.tokens?.access; - localStorage.setItem("refresh", exchanged.tokens.refresh); - } - } - window.location.replace("/"); - } - } - - async function user() { - const res = await fetch(`${import.meta.env.VITE_API_URL}me`, { - headers: { - Authorization: `Bearer ${token.current}`, - }, - }); - - if (res.ok) { - const user = await res.json(); - - setUserId(user.userId); - setLoggedIn(true); - } - } - - function logout() { - localStorage.removeItem("refresh"); - token.current = undefined; - - window.location.replace("/"); - } - - return ( - - {children} - - ); -} - -export function useAuth() { - return useContext(AuthContext); -} diff --git a/examples/aws-auth-react/packages/web/src/index.css b/examples/aws-auth-react/packages/web/src/index.css deleted file mode 100644 index 6119ad9a8f..0000000000 --- a/examples/aws-auth-react/packages/web/src/index.css +++ /dev/null @@ -1,68 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/examples/aws-auth-react/packages/web/src/main.tsx b/examples/aws-auth-react/packages/web/src/main.tsx deleted file mode 100644 index 2778110c85..0000000000 --- a/examples/aws-auth-react/packages/web/src/main.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { StrictMode } from "react"; -import { createRoot } from "react-dom/client"; -import { AuthProvider } from "./AuthContext"; -import "./index.css"; -import App from "./App.tsx"; - -createRoot(document.getElementById("root")!).render( - - - - - , -); diff --git a/examples/aws-auth-react/packages/web/tsconfig.app.json b/examples/aws-auth-react/packages/web/tsconfig.app.json deleted file mode 100644 index 358ca9ba93..0000000000 --- a/examples/aws-auth-react/packages/web/tsconfig.app.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["src"] -} diff --git a/examples/aws-auth-react/packages/web/tsconfig.json b/examples/aws-auth-react/packages/web/tsconfig.json deleted file mode 100644 index 1ffef600d9..0000000000 --- a/examples/aws-auth-react/packages/web/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files": [], - "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } - ] -} diff --git a/examples/aws-auth-react/packages/web/tsconfig.node.json b/examples/aws-auth-react/packages/web/tsconfig.node.json deleted file mode 100644 index db0becc8b0..0000000000 --- a/examples/aws-auth-react/packages/web/tsconfig.node.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2022", - "lib": ["ES2023"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/examples/aws-auth-react/packages/web/vite.config.ts b/examples/aws-auth-react/packages/web/vite.config.ts deleted file mode 100644 index 8b0f57b91a..0000000000 --- a/examples/aws-auth-react/packages/web/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' - -// https://vite.dev/config/ -export default defineConfig({ - plugins: [react()], -}) diff --git a/examples/aws-auth-react/sst.config.ts b/examples/aws-auth-react/sst.config.ts deleted file mode 100644 index ac4f254171..0000000000 --- a/examples/aws-auth-react/sst.config.ts +++ /dev/null @@ -1,116 +0,0 @@ -/// - -/** - * ## AWS OpenAuth React SPA - * - * This is a full-stack monorepo app shows the OpenAuth flow for a single-page app - * and an authenticated API. It has: - * - * - React SPA built with Vite and the `StaticSite` component in the `packages/web` - * directory. - * ```ts title="infra/web.ts" - * export const web = new sst.aws.StaticSite("MyWeb", { - * path: "packages/web", - * build: { - * output: "dist", - * command: "npm run build", - * }, - * environment: { - * VITE_API_URL: api.url, - * VITE_AUTH_URL: auth.url, - * }, - * }); - * ``` - * - * - API with Hono and the `Function` component in `packages/functions/src/api.ts`. - * ```ts title="infra/api.ts" - * export const api = new sst.aws.Function("MyApi", { - * url: true, - * link: [auth], - * handler: "packages/functions/src/api.handler", - * }); - * ``` - * - * - OpenAuth with the `Auth` component in `packages/functions/src/auth.ts`. - * ```ts title="infra/auth.ts" - * export const auth = new sst.aws.Auth("MyAuth", { - * issuer: "packages/functions/src/auth.handler", - * }); - * ``` - * - * The React frontend uses a `AuthContext` provider to manage the auth flow. - * - * ```tsx title="packages/web/src/AuthContext.tsx" - * - * {children} - * - * ``` - * - * Now in `App.tsx`, we can use the `useAuth` hook. - * - * ```tsx title="packages/web/src/App.tsx" - * const auth = useAuth(); - * - * return !auth.loaded ? ( - *
Loading...
- * ) : ( - *
- * {auth.loggedIn ? ( - *
- *

- * Logged in - * {auth.userId && as {auth.userId}} - *

- *
- * ) : ( - * - * )} - *
- * ); - * ``` - * - * Once authenticated, we can call our authenticated API by passing in the access - * token. - * - * ```tsx title="packages/web/src/App.tsx" {3} - * await fetch(`${import.meta.env.VITE_API_URL}me`, { - * headers: { - * Authorization: `Bearer ${await auth.getToken()}`, - * }, - * }); - * ``` - * - * The API uses the OpenAuth client to verify the token. - * - * ```ts title="packages/functions/src/api.ts" {3} - * const authHeader = c.req.header("Authorization"); - * const token = authHeader.split(" ")[1]; - * const verified = await client.verify(subjects, token); - * ``` - * - * The `sst.config.ts` dynamically imports all the `infra/` files. - */ -export default $config({ - app(input) { - return { - name: "aws-auth-react", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - await import("./infra/auth"); - await import("./infra/api"); - await import("./infra/web"); - }, -}); diff --git a/examples/aws-auth-react/tsconfig.json b/examples/aws-auth-react/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-auth-react/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-base/.gitignore b/examples/aws-base/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-base/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-base/package.json b/examples/aws-base/package.json deleted file mode 100644 index 8721162115..0000000000 --- a/examples/aws-base/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-base", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-base/sst.config.ts b/examples/aws-base/sst.config.ts deleted file mode 100644 index 825dc1c077..0000000000 --- a/examples/aws-base/sst.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-base", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() {}, -}); diff --git a/examples/aws-base/tsconfig.json b/examples/aws-base/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-base/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-bucket-lifecycle-rules/package.json b/examples/aws-bucket-lifecycle-rules/package.json deleted file mode 100644 index 5a92f09ea9..0000000000 --- a/examples/aws-bucket-lifecycle-rules/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-lifecycle-rules", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-lifecycle-rules/sst.config.ts b/examples/aws-bucket-lifecycle-rules/sst.config.ts deleted file mode 100644 index 012b5fd95c..0000000000 --- a/examples/aws-bucket-lifecycle-rules/sst.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -/** - * ## Bucket lifecycle policies - * - * Configure S3 bucket lifecycle policies to expire objects automatically. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-lifecycle-rules", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - lifecycle: [ - { - expiresIn: "60 days", - }, - { - id: "expire-tmp-files", - prefix: "tmp/", - expiresIn: "30 days", - }, - { - prefix: "data/", - expiresAt: "2028-12-31", - }, - ], - }); - - return { - bucket: bucket.name, - }; - }, -}); diff --git a/examples/aws-bucket-policy/package.json b/examples/aws-bucket-policy/package.json deleted file mode 100644 index a336ca8ce1..0000000000 --- a/examples/aws-bucket-policy/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-policy", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-policy/sst.config.ts b/examples/aws-bucket-policy/sst.config.ts deleted file mode 100644 index 85140112f0..0000000000 --- a/examples/aws-bucket-policy/sst.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -/** - * ## Bucket policy - * - * Create an S3 bucket and transform its bucket policy. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-policy", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - transform: { - policy: (args) => { - // use sst.aws.iamEdit helper function to manipulate IAM policy - // containing Output values from components - args.policy = sst.aws.iamEdit(args.policy, (policy) => { - policy.Statement.push({ - Effect: "Allow", - Principal: { Service: "ses.amazonaws.com" }, - Action: "s3:PutObject", - Resource: $interpolate`arn:aws:s3:::${args.bucket}/*`, - }); - }); - }, - }, - }); - - return { - bucket: bucket.name, - }; - }, -}); diff --git a/examples/aws-bucket-queue-subscriber/package.json b/examples/aws-bucket-queue-subscriber/package.json deleted file mode 100644 index f0361aa21e..0000000000 --- a/examples/aws-bucket-queue-subscriber/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-bucket-queue-subscriber", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.149", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-queue-subscriber/sst.config.ts b/examples/aws-bucket-queue-subscriber/sst.config.ts deleted file mode 100644 index 4b10069241..0000000000 --- a/examples/aws-bucket-queue-subscriber/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -/** - * ## Bucket queue notifications - * - * Create an S3 bucket and subscribe to its events with an SQS queue. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-queue-subscriber", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const queue = new sst.aws.Queue("MyQueue"); - queue.subscribe("subscriber.handler"); - - const bucket = new sst.aws.Bucket("MyBucket"); - bucket.notify({ - notifications: [ - { - name: "MySubscriber", - queue, - events: ["s3:ObjectCreated:*"], - }, - ], - }); - - return { - bucket: bucket.name, - queue: queue.url, - }; - }, -}); diff --git a/examples/aws-bucket-queue-subscriber/subscriber.ts b/examples/aws-bucket-queue-subscriber/subscriber.ts deleted file mode 100644 index c4264f003f..0000000000 --- a/examples/aws-bucket-queue-subscriber/subscriber.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { SQSEvent } from "aws-lambda"; - -export const handler = async (event: SQSEvent) => { - console.log(event); - return "ok"; -}; diff --git a/examples/aws-bucket-subscriber/package.json b/examples/aws-bucket-subscriber/package.json deleted file mode 100644 index 4cdabdf595..0000000000 --- a/examples/aws-bucket-subscriber/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-subscriber", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-subscriber/sst.config.ts b/examples/aws-bucket-subscriber/sst.config.ts deleted file mode 100644 index 2b8b5ef585..0000000000 --- a/examples/aws-bucket-subscriber/sst.config.ts +++ /dev/null @@ -1,32 +0,0 @@ -/// - -/** - * ## Bucket notifications - * - * Create an S3 bucket and subscribe to its events with a function. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-subscriber", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - bucket.notify({ - notifications: [ - { - name: "MySubscriber", - function: "subscriber.handler", - events: ["s3:ObjectCreated:*"], - }, - ], - }); - - return { - bucket: bucket.name, - }; - }, -}); diff --git a/examples/aws-bucket-subscriber/subscriber.ts b/examples/aws-bucket-subscriber/subscriber.ts deleted file mode 100644 index f9e60137f3..0000000000 --- a/examples/aws-bucket-subscriber/subscriber.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Handler, S3Event } from 'aws-lambda'; - -export const handler: Handler = async (event) => { - console.log(event); - return "ok"; -}; diff --git a/examples/aws-bucket-topic-subscriber/package.json b/examples/aws-bucket-topic-subscriber/package.json deleted file mode 100644 index c54f3182da..0000000000 --- a/examples/aws-bucket-topic-subscriber/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-topic-subscriber", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-topic-subscriber/sst.config.ts b/examples/aws-bucket-topic-subscriber/sst.config.ts deleted file mode 100644 index 25e481759d..0000000000 --- a/examples/aws-bucket-topic-subscriber/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -/** - * ## Bucket topic notifications - * - * Create an S3 bucket and subscribe to its events with an SNS topic. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-topic-subscriber", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const topic = new sst.aws.SnsTopic("MyTopic"); - topic.subscribe("MySubscriber", "subscriber.handler"); - - const bucket = new sst.aws.Bucket("MyBucket"); - bucket.notify({ - notifications: [ - { - name: "MySubscriber", - topic, - events: ["s3:ObjectCreated:*"], - }, - ], - }); - - return { - bucket: bucket.name, - topic: topic.name, - }; - }, -}); diff --git a/examples/aws-bucket-topic-subscriber/subscriber.ts b/examples/aws-bucket-topic-subscriber/subscriber.ts deleted file mode 100644 index 118f4371ad..0000000000 --- a/examples/aws-bucket-topic-subscriber/subscriber.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const handler = async (event) => { - console.log(event); - return "ok"; -}; diff --git a/examples/aws-bun-elysia/.dockerignore b/examples/aws-bun-elysia/.dockerignore deleted file mode 100644 index d13a1cca01..0000000000 --- a/examples/aws-bun-elysia/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -node_modules diff --git a/examples/aws-bun-elysia/.gitignore b/examples/aws-bun-elysia/.gitignore deleted file mode 100644 index 92b10320b7..0000000000 --- a/examples/aws-bun-elysia/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel - -**/*.trace -**/*.zip -**/*.tar.gz -**/*.tgz -**/*.log -package-lock.json -**/*.bun - -# sst -.sst diff --git a/examples/aws-bun-elysia/Dockerfile b/examples/aws-bun-elysia/Dockerfile deleted file mode 100644 index 4af145b928..0000000000 --- a/examples/aws-bun-elysia/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -# https://elysiajs.com/patterns/deployment.html#docker - -FROM oven/bun AS build - -WORKDIR /app - -# Cache packages installation -COPY package.json package.json -COPY bun.lockb bun.lockb - -RUN bun install - -COPY ./src ./src - -ENV NODE_ENV=production - -RUN bun build \ - --compile \ - --minify-whitespace \ - --minify-syntax \ - --target bun \ - --outfile server \ - ./src/index.ts - -FROM gcr.io/distroless/base - -WORKDIR /app - -COPY --from=build /app/server server - -ENV NODE_ENV=production - -CMD ["./server"] - -EXPOSE 3000 diff --git a/examples/aws-bun-elysia/elysia.png b/examples/aws-bun-elysia/elysia.png deleted file mode 100644 index 64dc586344..0000000000 Binary files a/examples/aws-bun-elysia/elysia.png and /dev/null differ diff --git a/examples/aws-bun-elysia/package.json b/examples/aws-bun-elysia/package.json deleted file mode 100644 index 931c1cff18..0000000000 --- a/examples/aws-bun-elysia/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-bun-elysia", - "version": "1.0.50", - "scripts": { - "dev": "bun run --watch src/index.ts", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.658.1", - "@aws-sdk/lib-storage": "^3.658.1", - "@aws-sdk/s3-request-presigner": "^3.658.1", - "elysia": "latest", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "bun-types": "latest" - }, - "module": "src/index.js" -} diff --git a/examples/aws-bun-elysia/src/index.ts b/examples/aws-bun-elysia/src/index.ts deleted file mode 100644 index cebfd22b9c..0000000000 --- a/examples/aws-bun-elysia/src/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Elysia } from "elysia"; -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); - -const app = new Elysia() - .get("/", () => "Hello Elysia") - .post("/", async ({ body: { file } }: { body: { file: File } }) => { - const params = { - Bucket: Resource.MyBucket.name, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return "File uploaded successfully."; - }) - .get("/latest", async ({ redirect }) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return redirect(await getSignedUrl(s3, command)); - }) - .listen(3000); - -console.log( - `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}` -); diff --git a/examples/aws-bun-elysia/sst.config.ts b/examples/aws-bun-elysia/sst.config.ts deleted file mode 100644 index 794730233c..0000000000 --- a/examples/aws-bun-elysia/sst.config.ts +++ /dev/null @@ -1,69 +0,0 @@ -/// - -/** - * ## AWS Bun Elysia container - * - * Deploys a Bun [Elysia](https://elysiajs.com/) API to AWS. - * - * You can get started by running. - * - * ```bash - * bun create elysia aws-bun-elysia - * cd aws-bun-elysia - * bunx sst init - * ``` - * - * Now you can add a service. - * - * ```ts title="sst.config.ts" - * new sst.aws.Service("MyService", { - * cluster, - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "bun dev", - * }, - * }); - * ``` - * - * Start your app locally. - * - * ```bash - * bun sst dev - * ``` - * - * This example lets you upload a file to S3 and then download it. - * - * ```bash - * curl -F file=@elysia.png http://localhost:3000/ - * curl http://localhost:3000/latest - * ``` - * - * Finally, you can deploy it using `bun sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-bun-elysia", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - link: [bucket], - }); - }, -}); diff --git a/examples/aws-bun-elysia/tsconfig.json b/examples/aws-bun-elysia/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-bun-elysia/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-bun-redis/.dockerignore b/examples/aws-bun-redis/.dockerignore deleted file mode 100644 index 8c3bacfca9..0000000000 --- a/examples/aws-bun-redis/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -.git -.gitignore -README.md -Dockerfile* - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-bun-redis/.gitignore b/examples/aws-bun-redis/.gitignore deleted file mode 100644 index 1426860d41..0000000000 --- a/examples/aws-bun-redis/.gitignore +++ /dev/null @@ -1,178 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store - -# sst -.sst diff --git a/examples/aws-bun-redis/Dockerfile b/examples/aws-bun-redis/Dockerfile deleted file mode 100644 index a50d40e263..0000000000 --- a/examples/aws-bun-redis/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM oven/bun:1 AS base -WORKDIR /usr/src/app - -# install dependencies into temp directory -# this will cache them and speed up future builds -FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lockb /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lockb /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM base AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -# [optional] tests & build -ENV NODE_ENV=production -# RUN bun test -RUN bun run build - -# copy production dependencies and source code into final image -FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/index.ts . -COPY --from=prerelease /usr/src/app/package.json . - -# run the app -USER bun -EXPOSE 3000/tcp -ENTRYPOINT [ "bun", "run", "index.ts" ] diff --git a/examples/aws-bun-redis/index.ts b/examples/aws-bun-redis/index.ts deleted file mode 100644 index 0168d45220..0000000000 --- a/examples/aws-bun-redis/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -const server = Bun.serve({ - async fetch(req) { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - const counter = await redis.incr("counter"); - return new Response(`Hit counter: ${counter}`); - } - - return new Response("404!"); - }, -}); - -console.log(`Listening on ${server.url}`); diff --git a/examples/aws-bun-redis/package.json b/examples/aws-bun-redis/package.json deleted file mode 100644 index c4aa0fa55c..0000000000 --- a/examples/aws-bun-redis/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-bun-redis", - "module": "index.ts", - "type": "module", - "scripts": { - "build": "bun build --target bun index.ts", - "dev": "bun run --watch index.ts" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bun-redis/sst.config.ts b/examples/aws-bun-redis/sst.config.ts deleted file mode 100644 index 6ca2730f76..0000000000 --- a/examples/aws-bun-redis/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS Bun Redis - * - * Creates a hit counter app with Bun and Redis. - * - * This deploys Bun as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {9} - * new sst.aws.Service("MyService", { - * cluster, - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "bun dev", - * }, - * link: [redis], - * }); - * ``` - * - * We also have a couple of scripts. A `dev` script with a watcher and a `build` script - * that used when we deploy to production. - * - * ```json title="package.json" - * { - * "scripts": { - * "dev": "bun run --watch index.ts", - * "build": "bun build --target bun index.ts" - * }, - * } - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo bun sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * bun sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `bun sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: "aws-bun-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - }); - }, -}); diff --git a/examples/aws-bun-redis/tsconfig.json b/examples/aws-bun-redis/tsconfig.json deleted file mode 100644 index 238655f2ce..0000000000 --- a/examples/aws-bun-redis/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-bun/.dockerignore b/examples/aws-bun/.dockerignore deleted file mode 100644 index 8c3bacfca9..0000000000 --- a/examples/aws-bun/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -.git -.gitignore -README.md -Dockerfile* - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-bun/.gitignore b/examples/aws-bun/.gitignore deleted file mode 100644 index 1426860d41..0000000000 --- a/examples/aws-bun/.gitignore +++ /dev/null @@ -1,178 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store - -# sst -.sst diff --git a/examples/aws-bun/Dockerfile b/examples/aws-bun/Dockerfile deleted file mode 100644 index 457b544c5c..0000000000 --- a/examples/aws-bun/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM oven/bun - -COPY bun.lockb . -COPY package.json . - -RUN bun install --frozen-lockfile - -COPY . . - -EXPOSE 3000 -CMD ["bun", "index.ts"] diff --git a/examples/aws-bun/index.ts b/examples/aws-bun/index.ts deleted file mode 100644 index c552d40423..0000000000 --- a/examples/aws-bun/index.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); - -const server = Bun.serve({ - async fetch(req) { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - return new Response("Hello World!"); - } - - if (url.pathname === "/" && req.method === "POST") { - const formData = await req.formData(); - const file = formData.get("file")! as File; - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return new Response("File uploaded successfully."); - } - - if (url.pathname === "/latest" && req.method === "GET") { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return Response.redirect(await getSignedUrl(s3, command)); - } - - return new Response("404!"); - }, -}); - -console.log(`Listening on ${server.url}`); diff --git a/examples/aws-bun/package.json b/examples/aws-bun/package.json deleted file mode 100644 index d2c2c3afb3..0000000000 --- a/examples/aws-bun/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-bun", - "module": "index.ts", - "type": "module", - "scripts": { - "dev": "bun run --watch index.ts" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.658.1", - "@aws-sdk/lib-storage": "^3.658.1", - "@aws-sdk/s3-request-presigner": "^3.658.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bun/sst.config.ts b/examples/aws-bun/sst.config.ts deleted file mode 100644 index 6a75af0d44..0000000000 --- a/examples/aws-bun/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-bun", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - link: [bucket], - }); - }, -}); diff --git a/examples/aws-bun/tsconfig.json b/examples/aws-bun/tsconfig.json deleted file mode 100644 index 238655f2ce..0000000000 --- a/examples/aws-bun/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-bundle/.gitignore b/examples/aws-bundle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-bundle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-bundle/package.json b/examples/aws-bundle/package.json deleted file mode 100644 index 737d546186..0000000000 --- a/examples/aws-bundle/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "aws-bundle", - "version": "0.0.0", - "type": "module", - "dependencies": { - "@types/node": "^22.13.2", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bundle/src/file.json b/examples/aws-bundle/src/file.json deleted file mode 100644 index 29c5f233a6..0000000000 --- a/examples/aws-bundle/src/file.json +++ /dev/null @@ -1 +0,0 @@ -{ "test": "foo" } diff --git a/examples/aws-bundle/src/index.mjs b/examples/aws-bundle/src/index.mjs deleted file mode 100644 index 91c8642eba..0000000000 --- a/examples/aws-bundle/src/index.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import { readFileSync } from "fs"; - -const data = readFileSync(new URL("./file.json", import.meta.url)); - -export async function handler() { - return { - statusCode: 200, - body: data.toString(), - }; -} diff --git a/examples/aws-bundle/src/resource.enc b/examples/aws-bundle/src/resource.enc deleted file mode 100644 index a34504402c..0000000000 --- a/examples/aws-bundle/src/resource.enc +++ /dev/null @@ -1 +0,0 @@ -aΚ™· N‹X\SMΟ» jω \ No newline at end of file diff --git a/examples/aws-bundle/sst.config.ts b/examples/aws-bundle/sst.config.ts deleted file mode 100644 index 76ee71699c..0000000000 --- a/examples/aws-bundle/sst.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-bundle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Function("Function", { - bundle: "./src", - handler: "index.handler", - url: true, - }); - }, -}); diff --git a/examples/aws-bundle/tsconfig.json b/examples/aws-bundle/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-bundle/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-bus/.gitignore b/examples/aws-bus/.gitignore deleted file mode 100644 index 9a902f0c53..0000000000 --- a/examples/aws-bus/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# sst -.sst diff --git a/examples/aws-bus/package.json b/examples/aws-bus/package.json deleted file mode 100644 index 17ef5c7687..0000000000 --- a/examples/aws-bus/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "aws-bus", - "version": "0.0.0", - "dependencies": { - "@aws-sdk/client-eventbridge": "^3.582.0", - "sst": "file:../../sdk/js", - "zod": "^4.1.13" - }, - "devDependencies": { - "typescript": "^5.9.3" - } -} diff --git a/examples/aws-bus/src/events.ts b/examples/aws-bus/src/events.ts deleted file mode 100644 index 596f081190..0000000000 --- a/examples/aws-bus/src/events.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { event } from "sst/event"; -import { ZodValidator } from "sst/event/validator"; -import { z } from "zod"; - -const defineEvent = event.builder({ - validator: ZodValidator, - metadata: () => { - return { - timestamp: Date.now(), - }; - }, -}); - -export const MyEvent = defineEvent( - "app.myevent", - z.object({ - foo: z.string(), - }), -); diff --git a/examples/aws-bus/src/publisher.ts b/examples/aws-bus/src/publisher.ts deleted file mode 100644 index 228ff26366..0000000000 --- a/examples/aws-bus/src/publisher.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { bus } from "sst/aws/bus"; -import { z } from "zod"; -import { Resource } from "sst"; -import { MyEvent } from "./events"; - -export async function handler() { - await bus.publish(Resource.Bus, MyEvent, { foo: "hello" }); - - return { - statusCode: 200, - }; -} diff --git a/examples/aws-bus/src/receiver.ts b/examples/aws-bus/src/receiver.ts deleted file mode 100644 index 7d6230d6ea..0000000000 --- a/examples/aws-bus/src/receiver.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { bus } from "sst/aws/bus"; -import { MyEvent } from "./events"; - -export const handler = bus.subscriber([MyEvent], async (event) => { - console.log({ event }); -}); diff --git a/examples/aws-bus/sst.config.ts b/examples/aws-bus/sst.config.ts deleted file mode 100644 index 0e8840a675..0000000000 --- a/examples/aws-bus/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -/** - * ## AWS Bus subscriptions - * - * Subscribe bus events with AWS Lambda functions. - */ -export default $config({ - app(input) { - return { - name: "aws-bus", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bus = new sst.aws.Bus("Bus"); - - const publisher = new sst.aws.Function("Publisher", { - handler: "./src/publisher.handler", - url: true, - link: [bus], - }); - - bus.subscribe("Example", "./src/receiver.handler"); - }, -}); diff --git a/examples/aws-bus/tsconfig.json b/examples/aws-bus/tsconfig.json deleted file mode 100644 index 62526ee80a..0000000000 --- a/examples/aws-bus/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler" - } -} diff --git a/examples/aws-cloudflare-combined/.gitignore b/examples/aws-cloudflare-combined/.gitignore deleted file mode 100644 index f4d5339fb2..0000000000 --- a/examples/aws-cloudflare-combined/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -.env -.sst diff --git a/examples/aws-cloudflare-combined/package.json b/examples/aws-cloudflare-combined/package.json deleted file mode 100644 index 0b47f9bf35..0000000000 --- a/examples/aws-cloudflare-combined/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "aws-cloudflare-combined", - "type": "module", - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "@cloudflare/workers-types": "^4.20240403.0", - "hono": "^4.6.12", - "sst": "../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146" - } -} diff --git a/examples/aws-cloudflare-combined/src/index.ts b/examples/aws-cloudflare-combined/src/index.ts deleted file mode 100644 index cb7ac2f0ae..0000000000 --- a/examples/aws-cloudflare-combined/src/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Hono } from "hono"; -import { handle } from "hono/aws-lambda"; -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client(); - -const app = new Hono(); - -app.get("/", async (c) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return c.text(await getSignedUrl(s3, command)); -}); - -app.get("/latest", async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return c.redirect(await getSignedUrl(s3, command)); -}); - -export const handler = handle(app); diff --git a/examples/aws-cloudflare-combined/sst.config.ts b/examples/aws-cloudflare-combined/sst.config.ts deleted file mode 100644 index 32c74ea0f1..0000000000 --- a/examples/aws-cloudflare-combined/sst.config.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-cloudflare-combined", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - cloudflare: "6.13.0", - }, - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - const api = new sst.aws.Function("Hono", { - url: true, - link: [bucket], - handler: "src/index.handler", - }); - - // Add a Cloudflare Bucket and link it to the worker - const cfBucket = new sst.cloudflare.Bucket("CfBucket"); - const worker = new sst.cloudflare.Worker("MyWorker", { - handler: "./worker.ts", - link: [cfBucket], - url: true, - }); - - return { - api: api.url, - worker: worker.url, - }; - }, -}); diff --git a/examples/aws-cloudflare-combined/tsconfig.json b/examples/aws-cloudflare-combined/tsconfig.json deleted file mode 100644 index 95a44f83fe..0000000000 --- a/examples/aws-cloudflare-combined/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "types": ["node"] - } -} diff --git a/examples/aws-cloudflare-combined/worker.ts b/examples/aws-cloudflare-combined/worker.ts deleted file mode 100644 index abea65a222..0000000000 --- a/examples/aws-cloudflare-combined/worker.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Resource } from "sst"; - -export default { - async fetch(req: Request) { - if (req.method === "PUT") { - const key = crypto.randomUUID(); - await Resource.CfBucket.put(key, req.body, { - httpMetadata: { - contentType: req.headers.get("content-type"), - }, - }); - return new Response(`Object created with key: ${key}`); - } - - if (req.method === "GET") { - const first = await Resource.CfBucket.list().then( - (res) => - res.objects.toSorted( - (a, b) => a.uploaded.getTime() - b.uploaded.getTime(), - )[0], - ); - if (!first) { - return new Response("No objects found"); - } - const result = await Resource.CfBucket.get(first.key); - return new Response(result.body, { - headers: { - "content-type": result.httpMetadata.contentType, - }, - }); - } - - return new Response("Hello from Cloudflare Worker!"); - }, -}; diff --git a/examples/aws-cluster-autoscaling/.dockerignore b/examples/aws-cluster-autoscaling/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-autoscaling/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-autoscaling/Dockerfile b/examples/aws-cluster-autoscaling/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-autoscaling/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-autoscaling/index.mjs b/examples/aws-cluster-autoscaling/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-autoscaling/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-autoscaling/package.json b/examples/aws-cluster-autoscaling/package.json deleted file mode 100644 index 6afabf1390..0000000000 --- a/examples/aws-cluster-autoscaling/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-cluster-autoscaling", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "@aws-sdk/client-sqs": "^3.682.0", - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-cluster-autoscaling/queue.ts b/examples/aws-cluster-autoscaling/queue.ts deleted file mode 100644 index f9e07dd59e..0000000000 --- a/examples/aws-cluster-autoscaling/queue.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Resource } from "sst"; -import { - SQSClient, - SendMessageBatchCommand, - PurgeQueueCommand, -} from "@aws-sdk/client-sqs"; -const client = new SQSClient(); - -export const seeder = async () => { - await client.send( - new SendMessageBatchCommand({ - QueueUrl: Resource.MyQueue.url, - Entries: [ - { Id: "1", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "2", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "3", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "4", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "5", MessageBody: JSON.stringify({ foo: "bar" }) }, - ], - }) - ); - - return { statusCode: 200, body: "seeded" }; -}; - -export const purger = async () => { - await client.send( - new PurgeQueueCommand({ - QueueUrl: Resource.MyQueue.url, - }) - ); - - return { statusCode: 200, body: "purged" }; -}; diff --git a/examples/aws-cluster-autoscaling/sst.config.ts b/examples/aws-cluster-autoscaling/sst.config.ts deleted file mode 100644 index 2f5905f030..0000000000 --- a/examples/aws-cluster-autoscaling/sst.config.ts +++ /dev/null @@ -1,175 +0,0 @@ -/// - -/** - * ## AWS Cluster custom autoscaling - * - * In this example, we'll create a cluster that autoscales based on a custom - * metric. In this case, the number of messages in a queue. - * - * We'll create a queue, and two functions that'll seed and purge the queue. We'll - * also create two policies. - * - * One that scales it up. - * - * ```ts title="sst.config.ts" - * const scaleUpPolicy = new aws.appautoscaling.Policy("ScaleUpPolicy", { - * serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - * scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - * resourceId: service.nodes.autoScalingTarget.resourceId, - * policyType: "StepScaling", - * stepScalingPolicyConfiguration: { - * adjustmentType: "ChangeInCapacity", - * cooldown: 5, - * stepAdjustments: [ - * { - * metricIntervalLowerBound: "0", - * scalingAdjustment: 1, - * }, - * ], - * }, - * }); - * ``` - * - * And one that scales it down. - * - * ```ts title="sst.config.ts" - * const scaleDownPolicy = new aws.appautoscaling.Policy("ScaleDownPolicy", { - * serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - * scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - * resourceId: service.nodes.autoScalingTarget.resourceId, - * policyType: "StepScaling", - * stepScalingPolicyConfiguration: { - * adjustmentType: "ChangeInCapacity", - * cooldown: 5, - * stepAdjustments: [ - * { - * metricIntervalUpperBound: "0", - * scalingAdjustment: -1, - * }, - * ], - * }, - * }); - * ``` - * - * We'll add a CloudWatch metric alarm that triggers the scaling policies if the - * queue depth exceeds 3 messages. - * - * ```ts title="sst.config.ts" - * new aws.cloudwatch.MetricAlarm("QueueDepthAlarm", { - * comparisonOperator: "GreaterThanThreshold", - * evaluationPeriods: 1, - * metricName: "ApproximateNumberOfMessagesVisible", - * namespace: "AWS/SQS", - * period: 10, - * statistic: "Average", - * threshold: 3, - * dimensions: { - * QueueName: queue.nodes.queue.name, - * }, - * alarmDescription: "Scale up when queue depth exceeds 3 messages", - * alarmActions: [scaleUpPolicy.arn], - * okActions: [scaleDownPolicy.arn], - * }); - * ``` - * - * To test this example, first deploy your app then: - * - * 1. Invoke the `MyQueueSeeder` URL. This will cause the service to scale up to 5 - * instances in a few minutes. - * 2. Then invoke the `MyQueuePurger` URL. This will cause the service to scale - * down to 1 instance in a few minutes. - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-autoscaling", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - // Create a queue and two functions to seed and purge the queue - const queue = new sst.aws.Queue("MyQueue"); - new sst.aws.Function("MyQueueSeeder", { - handler: "queue.seeder", - link: [queue], - url: true, - }); - new sst.aws.Function("MyQueuePurger", { - handler: "queue.purger", - link: [queue], - url: true, - }); - - // Create a cluster and disable default scaling on CPU and memory utilization - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - scaling: { - min: 1, - max: 5, - cpuUtilization: false, - memoryUtilization: false, - }, - }); - - // Create a scale up policy that scales up by 1 instance at a time - const scaleUpPolicy = new aws.appautoscaling.Policy("ScaleUpPolicy", { - serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - resourceId: service.nodes.autoScalingTarget.resourceId, - policyType: "StepScaling", - stepScalingPolicyConfiguration: { - adjustmentType: "ChangeInCapacity", - cooldown: 5, - stepAdjustments: [ - { - metricIntervalLowerBound: "0", - scalingAdjustment: 1, - }, - ], - }, - }); - - // Create a scale down policy that scales down by 1 instance at a time - const scaleDownPolicy = new aws.appautoscaling.Policy("ScaleDownPolicy", { - serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - resourceId: service.nodes.autoScalingTarget.resourceId, - policyType: "StepScaling", - stepScalingPolicyConfiguration: { - adjustmentType: "ChangeInCapacity", - cooldown: 5, - stepAdjustments: [ - { - metricIntervalUpperBound: "0", - scalingAdjustment: -1, - }, - ], - }, - }); - - // Create an alarm that scales up when the queue depth exceeds 3 messages - // and scales down when the queue depth is less than 3 messages - new aws.cloudwatch.MetricAlarm("QueueDepthAlarm", { - comparisonOperator: "GreaterThanThreshold", - evaluationPeriods: 1, - metricName: "ApproximateNumberOfMessagesVisible", - namespace: "AWS/SQS", - period: 10, - statistic: "Average", - threshold: 3, - dimensions: { - QueueName: queue.nodes.queue.name, - }, - alarmDescription: "Scale up when queue depth exceeds 3 messages", - alarmActions: [scaleUpPolicy.arn], - okActions: [scaleDownPolicy.arn], - }); - }, -}); diff --git a/examples/aws-cluster-internal/.dockerignore b/examples/aws-cluster-internal/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-internal/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-internal/Dockerfile b/examples/aws-cluster-internal/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-internal/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-internal/index.mjs b/examples/aws-cluster-internal/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-internal/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-internal/package.json b/examples/aws-cluster-internal/package.json deleted file mode 100644 index 5b900c19c6..0000000000 --- a/examples/aws-cluster-internal/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-cluster-internal", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-cluster-internal/sst.config.ts b/examples/aws-cluster-internal/sst.config.ts deleted file mode 100644 index b218497fa3..0000000000 --- a/examples/aws-cluster-internal/sst.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -/** - * ## AWS Cluster private service - * - * Adds a private load balancer to a service by setting the `loadBalancer.public` prop to - * `false`. - * - * This allows you to create internal services that can only be accessed inside a VPC. - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-internal", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - public: false, - ports: [{ listen: "80/http" }], - }, - }); - }, -}); diff --git a/examples/aws-cluster-spot/.dockerignore b/examples/aws-cluster-spot/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-spot/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-spot/Dockerfile b/examples/aws-cluster-spot/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-spot/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-spot/index.mjs b/examples/aws-cluster-spot/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-spot/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-spot/package.json b/examples/aws-cluster-spot/package.json deleted file mode 100644 index 4efa76a9ce..0000000000 --- a/examples/aws-cluster-spot/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-cluster-spot", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-cluster-spot/sst.config.ts b/examples/aws-cluster-spot/sst.config.ts deleted file mode 100644 index c3dc6f0d3f..0000000000 --- a/examples/aws-cluster-spot/sst.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -/** - * ## AWS Cluster Spot capacity - * - * This example, shows how to use the Fargate Spot capacity provider for your services. - * - * We have it set to use only Fargate Spot instances for all non-production stages. Learn more - * about the [`capacity`](/docs/component/aws/cluster#capacity) prop. - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-spot", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - capacity: $app.stage === "production" ? undefined : "spot", - }); - }, -}); diff --git a/examples/aws-cluster-vpclink/.dockerignore b/examples/aws-cluster-vpclink/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-vpclink/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-vpclink/Dockerfile b/examples/aws-cluster-vpclink/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-vpclink/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-vpclink/index.mjs b/examples/aws-cluster-vpclink/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-vpclink/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-vpclink/package.json b/examples/aws-cluster-vpclink/package.json deleted file mode 100644 index dfafa8b64a..0000000000 --- a/examples/aws-cluster-vpclink/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-cluster-vpclink", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-cluster-vpclink/sst.config.ts b/examples/aws-cluster-vpclink/sst.config.ts deleted file mode 100644 index f616f0017d..0000000000 --- a/examples/aws-cluster-vpclink/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Cluster with API Gateway - * - * Expose a service through API Gateway HTTP API using a VPC link. - * - * This is an alternative to using a load balancer. Since API Gateway is pay per request, it - * works out a lot cheaper for services that don't get a lot of traffic. - * - * You need to specify which port in your service will be exposed through API Gateway. - * - * ```ts title="sst.config.ts" {4} - * const service = new sst.aws.Service("MyService", { - * cluster, - * serviceRegistry: { - * port: 80, - * }, - * }); - * ``` - * - * A couple of things to note: - * - * 1. Your API Gateway HTTP API also needs to be in the **same VPC** as the service. - * - * 2. You also need to verify that your VPC's [**availability zones support VPC link**](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html#http-api-vpc-link-availability). - * - * 3. Run `aws ec2 describe-availability-zones` to get a list of AZs for your - * account. - * - * 4. Only list the AZ ID's that support VPC link. - * ```ts title="sst.config.ts" {4} - * vpc: { - * az: ["eu-west-3a", "eu-west-3c"] - * } - * ``` - * If the VPC picks an AZ automatically that doesn't support VPC link, you'll get - * the following error: - * ``` - * operation error ApiGatewayV2: BadRequestException: Subnet is in Availability - * Zone 'euw3-az2' where service is not available - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-vpclink", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { - // Pick at least two AZs that support VPC link - // az: ["eu-west-3a", "eu-west-3c"], - }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = new sst.aws.Service("MyService", { - cluster, - serviceRegistry: { - port: 80, - }, - }); - - const api = new sst.aws.ApiGatewayV2("MyApi", { vpc }); - api.routePrivate("$default", service.nodes.cloudmapService.arn); - }, -}); diff --git a/examples/aws-cognito/package.json b/examples/aws-cognito/package.json deleted file mode 100644 index 0710943f9c..0000000000 --- a/examples/aws-cognito/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-cognito", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-cognito/sst.config.ts b/examples/aws-cognito/sst.config.ts deleted file mode 100644 index e1392fcf95..0000000000 --- a/examples/aws-cognito/sst.config.ts +++ /dev/null @@ -1,49 +0,0 @@ -/// - -/** - * ## AWS Cognito User Pool - * - * Create a Cognito User Pool with a hosted UI domain, client, and identity pool. - * - */ -export default $config({ - app(input) { - return { - name: "aws-cognito", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const userPool = new sst.aws.CognitoUserPool("MyUserPool", { - domain: { - prefix: `my-app-${$app.stage}`, - }, - triggers: { - preSignUp: { - handler: "index.handler", - }, - }, - }); - - const client = userPool.addClient("Web", { - callbackUrls: ['https://example.com/auth/callback'] - }); - - const identityPool = new sst.aws.CognitoIdentityPool("MyIdentityPool", { - userPools: [ - { - userPool: userPool.id, - client: client.id, - }, - ], - }); - - return { - UserPool: userPool.id, - Client: client.id, - IdentityPool: identityPool.id, - DomainUrl: userPool.domainUrl, - }; - }, -}); diff --git a/examples/aws-copy-files/.gitignore b/examples/aws-copy-files/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-copy-files/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-copy-files/files/foo.json b/examples/aws-copy-files/files/foo.json deleted file mode 100644 index c8c4105eb5..0000000000 --- a/examples/aws-copy-files/files/foo.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "foo": "bar" -} diff --git a/examples/aws-copy-files/index.ts b/examples/aws-copy-files/index.ts deleted file mode 100644 index ce0c87f62d..0000000000 --- a/examples/aws-copy-files/index.ts +++ /dev/null @@ -1 +0,0 @@ -export async function handler() {} diff --git a/examples/aws-copy-files/package.json b/examples/aws-copy-files/package.json deleted file mode 100644 index e343eb1f30..0000000000 --- a/examples/aws-copy-files/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-copy-files", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-copy-files/sst.config.ts b/examples/aws-copy-files/sst.config.ts deleted file mode 100644 index f828e9beab..0000000000 --- a/examples/aws-copy-files/sst.config.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-copy-files", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const fn = new sst.aws.Function("MyFunction", { - handler: "index.handler", - url: true, - copyFiles: [ - { - from: "./files", - }, - ], - }); - return { - url: fn.url, - }; - }, -}); diff --git a/examples/aws-copy-files/tsconfig.json b/examples/aws-copy-files/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-copy-files/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-dart-api/.gitignore b/examples/aws-dart-api/.gitignore deleted file mode 100644 index 214545df01..0000000000 --- a/examples/aws-dart-api/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ - -# Avoid committing pubspec.lock for library packages; see -# https://dart.dev/guides/libraries/private-files#pubspeclock. -pubspec.lock - -# sst -.sst diff --git a/examples/aws-dart-api/CHANGELOG.md b/examples/aws-dart-api/CHANGELOG.md deleted file mode 100644 index effe43c82c..0000000000 --- a/examples/aws-dart-api/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/examples/aws-dart-api/analysis_options.yaml b/examples/aws-dart-api/analysis_options.yaml deleted file mode 100644 index dee8927aaf..0000000000 --- a/examples/aws-dart-api/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/examples/aws-dart-api/build.sh b/examples/aws-dart-api/build.sh deleted file mode 100755 index 4de7c08a2a..0000000000 --- a/examples/aws-dart-api/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Install dependencies -dart pub get - -# build the binary -dart compile exe lib/src/main.dart -o .build/bootstrap - -# Exit -exit \ No newline at end of file diff --git a/examples/aws-dart-api/lib/src/main.dart b/examples/aws-dart-api/lib/src/main.dart deleted file mode 100644 index 56eb949b05..0000000000 --- a/examples/aws-dart-api/lib/src/main.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:aws_lambda_dart_runtime/aws_lambda_dart_runtime.dart'; -import 'package:aws_lambda_dart_runtime/runtime/context.dart'; - -void main() async { - /// This demo's handling an API Gateway request. - hello(Context context, AwsApiGatewayEvent event) async { - final response = { - "message": "Hello from Dart!", - }; - return AwsApiGatewayResponse.fromJson(response); - } - - /// The Runtime is a singleton. You can define the handlers as you wish. - Runtime() - ..registerHandler( - 'hello', - hello, - ) - ..invoke(); -} diff --git a/examples/aws-dart-api/pubspec.yaml b/examples/aws-dart-api/pubspec.yaml deleted file mode 100644 index ed5c78ed7c..0000000000 --- a/examples/aws-dart-api/pubspec.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: aws_dart_api -description: A starting point for an AWS Serverless Api using Dart and SST ION. -version: 1.0.0 -publish_to: none - -environment: - sdk: ^3.4.0 - -dependencies: - aws_lambda_dart_runtime: - git: - url: https://github.com/katallaxie/aws-lambda-dart-runtime - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/examples/aws-dart-api/sst.config.ts b/examples/aws-dart-api/sst.config.ts deleted file mode 100644 index d9b4232604..0000000000 --- a/examples/aws-dart-api/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-dart-api", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV2("MyApi"); - api.route("GET /", { - runtime: "provided.al2023", - architecture: process.arch === "arm64" ? "arm64" : "x86_64", - bundle: build(), - handler: "hello", - }); - }, -}); - -function build() { - require("child_process").execSync(` -mkdir -p .build -docker run -v $PWD:/app -w /app --entrypoint ./build.sh dart:stable-sdk -`); - return `.build/`; -} diff --git a/examples/aws-dead-letter-queue/package.json b/examples/aws-dead-letter-queue/package.json deleted file mode 100644 index f2b2de79e4..0000000000 --- a/examples/aws-dead-letter-queue/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-dead-letter-queue", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.149", - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-sqs": "^3.515.0" - } -} diff --git a/examples/aws-dead-letter-queue/publisher.ts b/examples/aws-dead-letter-queue/publisher.ts deleted file mode 100644 index 3d71dac18d..0000000000 --- a/examples/aws-dead-letter-queue/publisher.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; -const client = new SQSClient(); - -export const handler = async (event) => { - // send a message - await client.send( - new SendMessageCommand({ - QueueUrl: Resource.MyQueue.url, - MessageBody: "Hello from the subscriber", - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-dead-letter-queue/sst.config.ts b/examples/aws-dead-letter-queue/sst.config.ts deleted file mode 100644 index c9ebbb6f2b..0000000000 --- a/examples/aws-dead-letter-queue/sst.config.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -/** - * ## Subscribe to queues with dead-letter queue - * - * Messages not processed successfully by the primary subscriber function will be sent to the dead-letter queue after the retry limit is reached. - */ -export default $config({ - app(input) { - return { - name: "aws-dead-letter-queue", - home: "aws", - removal: input.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // create dead letter queue - const dlq = new sst.aws.Queue("DeadLetterQueue"); - dlq.subscribe("subscriber.dlq"); - - // create main queue - const queue = new sst.aws.Queue("MyQueue", { - dlq: dlq.arn, - }); - queue.subscribe("subscriber.main"); - - const app = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - link: [queue], - url: true, - }); - - return { - app: app.url, - queue: queue.url, - dlq: dlq.url, - }; - }, -}); diff --git a/examples/aws-dead-letter-queue/subscriber.ts b/examples/aws-dead-letter-queue/subscriber.ts deleted file mode 100644 index c4b7967f0f..0000000000 --- a/examples/aws-dead-letter-queue/subscriber.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { SQSEvent, SQSHandler } from "aws-lambda"; - -export const main = async (event) => { - console.log(event); - throw new Error("Manual error"); -}; - -export const dlq: SQSHandler = async (event: SQSEvent) => { - console.log(event); - return; -}; diff --git a/examples/aws-deno-redis/.gitignore b/examples/aws-deno-redis/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-deno-redis/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-deno-redis/Dockerfile b/examples/aws-deno-redis/Dockerfile deleted file mode 100644 index b5d22eb996..0000000000 --- a/examples/aws-deno-redis/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM denoland/deno - -EXPOSE 8000 - -USER deno - -WORKDIR /app - -ADD . /app - -RUN deno install --entrypoint main.ts - -CMD ["run", "--allow-all", "main.ts"] diff --git a/examples/aws-deno-redis/deno.json b/examples/aws-deno-redis/deno.json deleted file mode 100644 index 322530bdf8..0000000000 --- a/examples/aws-deno-redis/deno.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "tasks": { - "dev": "deno run --watch --allow-all main.ts" - }, - "imports": { - "@std/assert": "jsr:@std/assert@1", - "ioredis": "npm:ioredis@^5.4.1", - "sst": "npm:sst@latest" - } -} diff --git a/examples/aws-deno-redis/main.ts b/examples/aws-deno-redis/main.ts deleted file mode 100644 index 54cc884fe1..0000000000 --- a/examples/aws-deno-redis/main.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - }, -); - -Deno.serve(async (_req) => { - const counter = await redis.incr("counter"); - return new Response(`Hit counter: ${counter}`); -}); diff --git a/examples/aws-deno-redis/main_test.ts b/examples/aws-deno-redis/main_test.ts deleted file mode 100644 index 3d981e9bed..0000000000 --- a/examples/aws-deno-redis/main_test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { assertEquals } from "@std/assert"; -import { add } from "./main.ts"; - -Deno.test(function addTest() { - assertEquals(add(2, 3), 5); -}); diff --git a/examples/aws-deno-redis/sst.config.ts b/examples/aws-deno-redis/sst.config.ts deleted file mode 100644 index ab583c5152..0000000000 --- a/examples/aws-deno-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Deno Redis - * - * Creates a hit counter app with Deno and Redis. - * - * This deploys Deno as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "8000/http" }], - * }, - * dev: { - * command: "deno task dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * sst dev - * ``` - * - * Now if you go to `http://localhost:8000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: "aws-deno-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "8000/http" }], - }, - dev: { - command: "deno task dev", - }, - }); - }, -}); diff --git a/examples/aws-deno/.dockerignore b/examples/aws-deno/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-deno/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-deno/.gitignore b/examples/aws-deno/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-deno/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-deno/Dockerfile b/examples/aws-deno/Dockerfile deleted file mode 100644 index b5d22eb996..0000000000 --- a/examples/aws-deno/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM denoland/deno - -EXPOSE 8000 - -USER deno - -WORKDIR /app - -ADD . /app - -RUN deno install --entrypoint main.ts - -CMD ["run", "--allow-all", "main.ts"] diff --git a/examples/aws-deno/deno.json b/examples/aws-deno/deno.json deleted file mode 100644 index bfc899069e..0000000000 --- a/examples/aws-deno/deno.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "tasks": { - "dev": "deno run --allow-all --watch main.ts" - }, - "imports": { - "@aws-sdk/client-s3": "npm:@aws-sdk/client-s3@^3.705.0", - "@aws-sdk/lib-storage": "npm:@aws-sdk/lib-storage@^3.705.0", - "@aws-sdk/s3-request-presigner": "npm:@aws-sdk/s3-request-presigner@^3.705.0", - "@std/assert": "jsr:@std/assert@1", - "sst": "npm:sst@latest" - } -} diff --git a/examples/aws-deno/main.ts b/examples/aws-deno/main.ts deleted file mode 100644 index 1518555c6a..0000000000 --- a/examples/aws-deno/main.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); - -Deno.serve(async (req) => { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - return new Response("Hello World!"); - } - - if (url.pathname === "/" && req.method === "POST") { - const formData: FormData = await req.formData(); - const file: File | null = formData?.get("file") as File; - - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return new Response("File uploaded successfully."); - } - - if (url.pathname === "/latest" && req.method === "GET") { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return Response.redirect(await getSignedUrl(s3, command)); - } - - return new Response("404!"); -}); diff --git a/examples/aws-deno/sst.config.ts b/examples/aws-deno/sst.config.ts deleted file mode 100644 index a414477373..0000000000 --- a/examples/aws-deno/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-deno", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "8000/http" }], - }, - dev: { - command: "deno task dev", - }, - }); - }, -}); diff --git a/examples/aws-drizzle-migrations/.gitignore b/examples/aws-drizzle-migrations/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-drizzle-migrations/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-drizzle-migrations/drizzle.config.ts b/examples/aws-drizzle-migrations/drizzle.config.ts deleted file mode 100644 index 373785baed..0000000000 --- a/examples/aws-drizzle-migrations/drizzle.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - // Pick up all our schema files - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - ssl: { - rejectUnauthorized: false, - }, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, -}); diff --git a/examples/aws-drizzle-migrations/migrations/0000_lethal_justin_hammer.sql b/examples/aws-drizzle-migrations/migrations/0000_lethal_justin_hammer.sql deleted file mode 100644 index db52d6f17f..0000000000 --- a/examples/aws-drizzle-migrations/migrations/0000_lethal_justin_hammer.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS "todo" ( - "id" serial PRIMARY KEY NOT NULL, - "title" text NOT NULL, - "description" text -); diff --git a/examples/aws-drizzle-migrations/migrations/meta/0000_snapshot.json b/examples/aws-drizzle-migrations/migrations/meta/0000_snapshot.json deleted file mode 100644 index 816f447c30..0000000000 --- a/examples/aws-drizzle-migrations/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "89cd0e0e-59a6-42ec-a876-c44671efc130", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.todo": { - "name": "todo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/examples/aws-drizzle-migrations/migrations/meta/_journal.json b/examples/aws-drizzle-migrations/migrations/meta/_journal.json deleted file mode 100644 index d1f9a2ea91..0000000000 --- a/examples/aws-drizzle-migrations/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1729181504948, - "tag": "0000_lethal_justin_hammer", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/examples/aws-drizzle-migrations/package.json b/examples/aws-drizzle-migrations/package.json deleted file mode 100644 index 1e6443a3ed..0000000000 --- a/examples/aws-drizzle-migrations/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-drizzle-migrations", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit" - }, - "dependencies": { - "@types/aws-lambda": "^8.10.142", - "@types/pg": "^8.11.10", - "drizzle-kit": "^0.26.2", - "drizzle-orm": "^0.35.1", - "pg": "^8.13.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-drizzle-migrations/src/api.ts b/examples/aws-drizzle-migrations/src/api.ts deleted file mode 100644 index 1cfb345fc0..0000000000 --- a/examples/aws-drizzle-migrations/src/api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; diff --git a/examples/aws-drizzle-migrations/src/drizzle.ts b/examples/aws-drizzle-migrations/src/drizzle.ts deleted file mode 100644 index c556a2c74a..0000000000 --- a/examples/aws-drizzle-migrations/src/drizzle.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { drizzle } from "drizzle-orm/node-postgres"; -import { Pool } from "pg"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-drizzle-migrations/src/migrator.ts b/examples/aws-drizzle-migrations/src/migrator.ts deleted file mode 100644 index d24594b9f2..0000000000 --- a/examples/aws-drizzle-migrations/src/migrator.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { db } from "./drizzle"; -import { migrate } from "drizzle-orm/postgres-js/migrator"; - -export const handler = async (event: any) => { - await migrate(db, { - migrationsFolder: "./migrations", - }); -}; \ No newline at end of file diff --git a/examples/aws-drizzle-migrations/src/scrap.ts b/examples/aws-drizzle-migrations/src/scrap.ts deleted file mode 100644 index ab59ad1118..0000000000 --- a/examples/aws-drizzle-migrations/src/scrap.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { eq } from "drizzle-orm"; -import { db } from "./drizzle"; -import { user } from "./todo.sql"; - -const uuid = "d997d46d-5769-4c78-9a35-93acadbe6076"; -await db.query.user.findMany({ - where: eq(user.id, uuid), - with: { - todos: { - with: { - todo: true, - }, - }, - }, -}); diff --git a/examples/aws-drizzle-migrations/src/todo.sql.ts b/examples/aws-drizzle-migrations/src/todo.sql.ts deleted file mode 100644 index 593829b61b..0000000000 --- a/examples/aws-drizzle-migrations/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { text, serial, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-drizzle-migrations/sst.config.ts b/examples/aws-drizzle-migrations/sst.config.ts deleted file mode 100644 index c19a4bb35c..0000000000 --- a/examples/aws-drizzle-migrations/sst.config.ts +++ /dev/null @@ -1,95 +0,0 @@ -/// - -/** - * ## Drizzle migrations in CI/CD - * - * An example on how to run Drizzle migrations as a part of your CI/CD. - * - * Start by creating a function that runs migrations. - * - * ```ts title="sst.config.ts" - * const migrator = new sst.aws.Function("DatabaseMigrator", { - * handler: "src/migrator.handler", - * link: [rds], - * vpc, - * copyFiles: [ - * { - * from: "migrations", - * to: "./migrations", - * }, - * ], - * }); - * ``` - * - * Where `src/migrator.ts` looks like. - * - * ```ts title="src/migrator.ts" - * import { db } from "./drizzle"; - * import { migrate } from "drizzle-orm/postgres-js/migrator"; - * - * export const handler = async (event: any) => { - * await migrate(db, { - * migrationsFolder: "./migrations", - * }); - * }; - * ``` - * - * And we can set it up to run on every deploy. - * - * ```ts title="sst.config.ts" - * if (!$dev){ - * new aws.lambda.Invocation("DatabaseMigratorInvocation", { - * input: Date.now().toString(), - * functionName: migrator.name, - * }); - * } - * ``` - * - * We use the current time to make sure the function runs on every deploy. - */ -export default $config({ - app(input) { - return { - name: "aws-drizzle-migrations", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - - new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - handler: "src/api.handler", - }); - - const migrator = new sst.aws.Function("DatabaseMigrator", { - handler: "src/migrator.handler", - link: [rds], - vpc, - copyFiles: [ - { - from: "migrations", - to: "./migrations", - }, - ], - }); - - if (!$dev) { - new aws.lambda.Invocation("DatabaseMigratorInvocation", { - input: Date.now().toString(), - functionName: migrator.name, - }); - } - - new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, - }); - }, -}); diff --git a/examples/aws-drizzle-migrations/tsconfig.json b/examples/aws-drizzle-migrations/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-drizzle-migrations/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-drizzle/.gitignore b/examples/aws-drizzle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-drizzle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-drizzle/drizzle.config.ts b/examples/aws-drizzle/drizzle.config.ts deleted file mode 100644 index 373785baed..0000000000 --- a/examples/aws-drizzle/drizzle.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - // Pick up all our schema files - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - ssl: { - rejectUnauthorized: false, - }, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, -}); diff --git a/examples/aws-drizzle/migrations/0000_lethal_justin_hammer.sql b/examples/aws-drizzle/migrations/0000_lethal_justin_hammer.sql deleted file mode 100644 index db52d6f17f..0000000000 --- a/examples/aws-drizzle/migrations/0000_lethal_justin_hammer.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS "todo" ( - "id" serial PRIMARY KEY NOT NULL, - "title" text NOT NULL, - "description" text -); diff --git a/examples/aws-drizzle/migrations/meta/0000_snapshot.json b/examples/aws-drizzle/migrations/meta/0000_snapshot.json deleted file mode 100644 index 816f447c30..0000000000 --- a/examples/aws-drizzle/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "89cd0e0e-59a6-42ec-a876-c44671efc130", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.todo": { - "name": "todo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/examples/aws-drizzle/migrations/meta/_journal.json b/examples/aws-drizzle/migrations/meta/_journal.json deleted file mode 100644 index d1f9a2ea91..0000000000 --- a/examples/aws-drizzle/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1729181504948, - "tag": "0000_lethal_justin_hammer", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/examples/aws-drizzle/package.json b/examples/aws-drizzle/package.json deleted file mode 100644 index fde9d0b941..0000000000 --- a/examples/aws-drizzle/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-drizzle", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit" - }, - "dependencies": { - "@types/aws-lambda": "^8.10.142", - "@types/pg": "^8.11.10", - "drizzle-kit": "^0.26.2", - "drizzle-orm": "^0.35.1", - "pg": "^8.13.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-drizzle/src/api.ts b/examples/aws-drizzle/src/api.ts deleted file mode 100644 index 1cfb345fc0..0000000000 --- a/examples/aws-drizzle/src/api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; diff --git a/examples/aws-drizzle/src/drizzle.ts b/examples/aws-drizzle/src/drizzle.ts deleted file mode 100644 index c556a2c74a..0000000000 --- a/examples/aws-drizzle/src/drizzle.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { drizzle } from "drizzle-orm/node-postgres"; -import { Pool } from "pg"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-drizzle/src/scrap.ts b/examples/aws-drizzle/src/scrap.ts deleted file mode 100644 index ab59ad1118..0000000000 --- a/examples/aws-drizzle/src/scrap.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { eq } from "drizzle-orm"; -import { db } from "./drizzle"; -import { user } from "./todo.sql"; - -const uuid = "d997d46d-5769-4c78-9a35-93acadbe6076"; -await db.query.user.findMany({ - where: eq(user.id, uuid), - with: { - todos: { - with: { - todo: true, - }, - }, - }, -}); diff --git a/examples/aws-drizzle/src/todo.sql.ts b/examples/aws-drizzle/src/todo.sql.ts deleted file mode 100644 index 593829b61b..0000000000 --- a/examples/aws-drizzle/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { text, serial, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-drizzle/sst.config.ts b/examples/aws-drizzle/sst.config.ts deleted file mode 100644 index cc3b885b7c..0000000000 --- a/examples/aws-drizzle/sst.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-drizzle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - - new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - handler: "src/api.handler", - }); - - new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, - }); - }, -}); diff --git a/examples/aws-drizzle/tsconfig.json b/examples/aws-drizzle/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-drizzle/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-dsql-drizzle/.gitignore b/examples/aws-dsql-drizzle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-dsql-drizzle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-dsql-drizzle/drizzle.config.ts b/examples/aws-dsql-drizzle/drizzle.config.ts deleted file mode 100644 index ba08a3f2c4..0000000000 --- a/examples/aws-dsql-drizzle/drizzle.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - host: Resource.MyCluster.endpoint, - port: 5432, - user: "admin", - password: process.env.DSQL_TOKEN!, - database: "postgres", - ssl: { - rejectUnauthorized: false, - }, - }, -}); diff --git a/examples/aws-dsql-drizzle/package.json b/examples/aws-dsql-drizzle/package.json deleted file mode 100644 index 6b24eb27a5..0000000000 --- a/examples/aws-dsql-drizzle/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-dsql-drizzle", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws-sdk/dsql-signer": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "@types/aws-lambda": "^8.10.142", - "@types/pg": "^8.11.10", - "drizzle-kit": "^0.26.2", - "drizzle-orm": "^0.35.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-dsql-drizzle/push.ts b/examples/aws-dsql-drizzle/push.ts deleted file mode 100644 index 8481e544ad..0000000000 --- a/examples/aws-dsql-drizzle/push.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { DsqlSigner } from "@aws-sdk/dsql-signer"; -import { Resource } from "sst"; -import { execSync } from "child_process"; - -const signer = new DsqlSigner({ - region: Resource.MyCluster.region, - hostname: Resource.MyCluster.endpoint, -}); - -const token = await signer.getDbConnectAdminAuthToken(); - -execSync("bunx drizzle-kit push", { - stdio: "inherit", - env: { - ...process.env, - DSQL_TOKEN: token, - }, -}); diff --git a/examples/aws-dsql-drizzle/src/api.ts b/examples/aws-dsql-drizzle/src/api.ts deleted file mode 100644 index 1cfb345fc0..0000000000 --- a/examples/aws-dsql-drizzle/src/api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; diff --git a/examples/aws-dsql-drizzle/src/drizzle.ts b/examples/aws-dsql-drizzle/src/drizzle.ts deleted file mode 100644 index 705e8e91e7..0000000000 --- a/examples/aws-dsql-drizzle/src/drizzle.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { drizzle } from "drizzle-orm/node-postgres"; -import { AuroraDSQLPool } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new AuroraDSQLPool({ - host: Resource.MyCluster.endpoint, - user: "admin", -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-dsql-drizzle/src/todo.sql.ts b/examples/aws-dsql-drizzle/src/todo.sql.ts deleted file mode 100644 index b04e165a5c..0000000000 --- a/examples/aws-dsql-drizzle/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { text, bigint, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: bigint("id", { mode: "number" }).primaryKey().generatedAlwaysAsIdentity(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-dsql-drizzle/sst.config.ts b/examples/aws-dsql-drizzle/sst.config.ts deleted file mode 100644 index 4edaefc62a..0000000000 --- a/examples/aws-dsql-drizzle/sst.config.ts +++ /dev/null @@ -1,66 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL with Drizzle - * - * In this example, we use Drizzle ORM with an Aurora DSQL cluster. - * - * ```ts title="sst.config.ts" - * const cluster = new sst.aws.Dsql("MyCluster"); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyApi", { - * handler: "src/api.handler", - * link: [cluster], - * url: true, - * }); - * ``` - * - * Push the Drizzle schema to the database. - * - * ```bash - * sst shell -- bun run push.ts - * ``` - * - * Now in the function we can connect to the cluster using Drizzle with the DSQL connector. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="src/drizzle.ts" - * import { drizzle } from "drizzle-orm/node-postgres"; - * import { AuroraDSQLPool } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * const pool = new AuroraDSQLPool({ - * host: Resource.MyCluster.endpoint, - * user: "admin", - * }); - * - * export const db = drizzle(pool, { schema }); - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-dsql-drizzle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const cluster = new sst.aws.Dsql("MyCluster"); - - new sst.aws.Function("MyApi", { - handler: "src/api.handler", - link: [cluster], - url: true, - }); - - return { - endpoint: cluster.endpoint, - region: cluster.region, - }; - }, -}); diff --git a/examples/aws-dsql-drizzle/tsconfig.json b/examples/aws-dsql-drizzle/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-dsql-drizzle/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-dsql-multiregion/.gitignore b/examples/aws-dsql-multiregion/.gitignore deleted file mode 100644 index 2060062401..0000000000 --- a/examples/aws-dsql-multiregion/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# sst -.sst -bun.lock \ No newline at end of file diff --git a/examples/aws-dsql-multiregion/lambda.ts b/examples/aws-dsql-multiregion/lambda.ts deleted file mode 100644 index 28e5441dd8..0000000000 --- a/examples/aws-dsql-multiregion/lambda.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; - -async function connectToCluster(endpoint: string) { - const client = new AuroraDSQLClient({ - host: endpoint, - user: "admin", - }); - - await client.connect(); - const result = await client.query("SELECT NOW() as now"); - await client.end(); - - return result.rows[0].now; -} - -export const handler = async () => { - try { - const usEast1Time = await connectToCluster(Resource.MultiRegion.endpoint); - - const usEast2Time = await connectToCluster(Resource.MultiRegion.peer.endpoint); - - return { - statusCode: 200, - body: JSON.stringify({ - message: "Successfully connected to both DSQL clusters.", - usEast1Time, - usEast2Time, - }), - }; - } catch (error) { - console.error("Error accessing DSQL clusters:", error); - return { - statusCode: 500, - body: JSON.stringify({ - error: "Failed to access DSQL clusters", - details: error instanceof Error ? error.message : String(error), - }), - }; - } -}; diff --git a/examples/aws-dsql-multiregion/package.json b/examples/aws-dsql-multiregion/package.json deleted file mode 100644 index ad0e8cdc63..0000000000 --- a/examples/aws-dsql-multiregion/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-dsql-multiregion", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev", - "deploy": "sst deploy", - "remove": "sst remove" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.133", - "@types/pg": "^8.10.9" - } -} diff --git a/examples/aws-dsql-multiregion/sst.config.ts b/examples/aws-dsql-multiregion/sst.config.ts deleted file mode 100644 index 8d09ff4867..0000000000 --- a/examples/aws-dsql-multiregion/sst.config.ts +++ /dev/null @@ -1,82 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL Multi-Region - * - * In this example, we deploy a multi-region Aurora DSQL cluster and connect to both - * clusters from a Lambda function. - * - * :::note - * Multi-region with VPCs is not currently supported. - * ::: - * - * Create the cluster with a witness region and a peer region. The witness must differ - * from both cluster regions. - * - * ```ts title="sst.config.ts" - * const cluster = new sst.aws.Dsql("MultiRegion", { - * regions: { - * witness: "us-west-2", - * peer: "us-east-2", - * }, - * }); - * ``` - * - * Connect to both clusters from your function using the DSQL connector. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="lambda.ts" - * import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * async function connectToCluster(endpoint: string) { - * const client = new AuroraDSQLClient({ host: endpoint, user: "admin" }); - * await client.connect(); - * return client; - * } - * - * // Cluster in us-east-1 - * const usEast1 = await connectToCluster(Resource.MultiRegion.endpoint); - * - * // Cluster in us-east-2 - * const usEast2 = await connectToCluster(Resource.MultiRegion.peer.endpoint); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-dsql-multiregion", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { region: "us-east-1" }, - }, - }; - }, - async run() { - const cluster = new sst.aws.Dsql("MultiRegion", { - backup: true, - regions: { - witness: "us-west-2", - peer: "us-east-2", - }, - }); - - const fn = new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - link: [cluster], - url: true, - }); - - return { - url: fn.url, - arn: cluster.arn, - endpoint: cluster.endpoint, - region: cluster.region, - peerArn: cluster.peer.arn, - peerEndpoint: cluster.peer.endpoint, - peerRegion: cluster.peer.region, - }; - }, -}); diff --git a/examples/aws-dsql-vpc/.gitignore b/examples/aws-dsql-vpc/.gitignore deleted file mode 100644 index 2060062401..0000000000 --- a/examples/aws-dsql-vpc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# sst -.sst -bun.lock \ No newline at end of file diff --git a/examples/aws-dsql-vpc/lambda.ts b/examples/aws-dsql-vpc/lambda.ts deleted file mode 100644 index 6c8c676be8..0000000000 --- a/examples/aws-dsql-vpc/lambda.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; - -export const handler = async () => { - try { - const client = new AuroraDSQLClient({ - host: Resource.MyCluster.endpoint, - user: "admin", - }); - - await client.connect(); - const now = await client.query("SELECT NOW() as now"); - await client.end(); - - return { - statusCode: 200, - body: JSON.stringify({ - message: "Successfully connected to DSQL cluster.", - now: now.rows[0].now, - }), - }; - } catch (error) { - console.error("Error accessing DSQL cluster:", error); - return { - statusCode: 500, - body: JSON.stringify({ - error: "Failed to access DSQL cluster", - details: error instanceof Error ? error.message : String(error), - }), - }; - } -}; diff --git a/examples/aws-dsql-vpc/package.json b/examples/aws-dsql-vpc/package.json deleted file mode 100644 index fe05e2ec1b..0000000000 --- a/examples/aws-dsql-vpc/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-dsql-vpc", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev", - "deploy": "sst deploy", - "remove": "sst remove" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.133", - "@types/pg": "^8.10.9" - } -} diff --git a/examples/aws-dsql-vpc/sst.config.ts b/examples/aws-dsql-vpc/sst.config.ts deleted file mode 100644 index 390c868187..0000000000 --- a/examples/aws-dsql-vpc/sst.config.ts +++ /dev/null @@ -1,84 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL in a VPC - * - * In this example, we connect to an Aurora DSQL cluster privately from a Lambda - * function using VPC endpoints, without routing traffic over the public internet. - * - * Create a VPC, then create the cluster with a connection endpoint inside it. - * - * ```ts title="sst.config.ts" - * const vpc = new sst.aws.Vpc("MyVpc"); - * - * const cluster = new sst.aws.Dsql("MyCluster", { - * vpc: { - * instance: vpc, - * endpoints: { connection: true }, - * }, - * }); - * ``` - * - * Link the cluster to a function that's also in the VPC. The linked `endpoint` will - * automatically resolve to the private VPC endpoint hostname instead of the public one. - * - * ```ts title="sst.config.ts" - * new sst.aws.Function("MyFunction", { - * handler: "lambda.handler", - * vpc, - * link: [cluster], - * }); - * ``` - * - * Connect from your function using the DSQL connector β€” no config changes needed. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="lambda.ts" - * import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * const client = new AuroraDSQLClient({ - * host: Resource.MyCluster.endpoint, - * user: "admin", - * }); - * - * await client.connect(); - * const result = await client.query("SELECT NOW()"); - * await client.end(); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-dsql-vpc", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("singleClusterVpc"); - - const cluster = new sst.aws.Dsql("MyCluster", { - vpc: { - instance: vpc, - endpoints: { - connection: true, - management: false, - }, - }, - }); - - const fn = new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - vpc, - link: [cluster], - url: true, - }); - - return { - endpoint: cluster.endpoint, - region: cluster.region, - }; - }, -}); diff --git a/examples/aws-dsql/.gitignore b/examples/aws-dsql/.gitignore deleted file mode 100644 index 2060062401..0000000000 --- a/examples/aws-dsql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# sst -.sst -bun.lock \ No newline at end of file diff --git a/examples/aws-dsql/lambda.ts b/examples/aws-dsql/lambda.ts deleted file mode 100644 index 6c8c676be8..0000000000 --- a/examples/aws-dsql/lambda.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; - -export const handler = async () => { - try { - const client = new AuroraDSQLClient({ - host: Resource.MyCluster.endpoint, - user: "admin", - }); - - await client.connect(); - const now = await client.query("SELECT NOW() as now"); - await client.end(); - - return { - statusCode: 200, - body: JSON.stringify({ - message: "Successfully connected to DSQL cluster.", - now: now.rows[0].now, - }), - }; - } catch (error) { - console.error("Error accessing DSQL cluster:", error); - return { - statusCode: 500, - body: JSON.stringify({ - error: "Failed to access DSQL cluster", - details: error instanceof Error ? error.message : String(error), - }), - }; - } -}; diff --git a/examples/aws-dsql/package.json b/examples/aws-dsql/package.json deleted file mode 100644 index 3038223d17..0000000000 --- a/examples/aws-dsql/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-dsql", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev", - "deploy": "sst deploy", - "remove": "sst remove" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.133", - "@types/pg": "^8.10.9" - } -} diff --git a/examples/aws-dsql/sst.config.ts b/examples/aws-dsql/sst.config.ts deleted file mode 100644 index cc3477e4f3..0000000000 --- a/examples/aws-dsql/sst.config.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL - * - * In this example, we deploy an Aurora DSQL cluster. - * - * ```ts title="sst.config.ts" - * const cluster = new sst.aws.Dsql("MyCluster"); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyFunction", { - * handler: "lambda.handler", - * link: [cluster], - * url: true, - * }); - * ``` - * - * Now in the function we can connect to the cluster using the DSQL connector. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="lambda.ts" - * import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * const client = new AuroraDSQLClient({ - * host: Resource.MyCluster.endpoint, - * user: "admin", - * }); - * - * await client.connect(); - * const result = await client.query("SELECT NOW()"); - * await client.end(); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-dsql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const cluster = new sst.aws.Dsql("MyCluster", {}); - - const fn = new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - link: [cluster], - url: true, - }); - - return { - endpoint: cluster.endpoint, - region: cluster.region, - }; - }, -}); \ No newline at end of file diff --git a/examples/aws-dynamo-composite-keys/creator.ts b/examples/aws-dynamo-composite-keys/creator.ts deleted file mode 100644 index 4a9365b223..0000000000 --- a/examples/aws-dynamo-composite-keys/creator.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async () => { - await client.send( - new PutItemCommand({ - TableName: Resource.MyTable.name, - Item: { - userId: { S: "user1" }, - noteId: { S: Date.now().toString() }, - region: { S: "us-east" }, - category: { S: "notes" }, - createdAt: { N: Date.now().toString() }, - }, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-dynamo-composite-keys/package.json b/examples/aws-dynamo-composite-keys/package.json deleted file mode 100644 index 1269793242..0000000000 --- a/examples/aws-dynamo-composite-keys/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-dynamo-composite-keys", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-dynamodb": "^3.515.0" - } -} diff --git a/examples/aws-dynamo-composite-keys/reader.ts b/examples/aws-dynamo-composite-keys/reader.ts deleted file mode 100644 index dfb2b1527b..0000000000 --- a/examples/aws-dynamo-composite-keys/reader.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, QueryCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async () => { - const result = await client.send( - new QueryCommand({ - TableName: Resource.MyTable.name, - IndexName: "RegionCategoryIndex", - KeyConditionExpression: "#r = :region AND #c = :category", - ExpressionAttributeNames: { - "#r": "region", - "#c": "category", - }, - ExpressionAttributeValues: { - ":region": { S: "us-east" }, - ":category": { S: "notes" }, - }, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify(result.Items, null, 2), - }; -}; diff --git a/examples/aws-dynamo-composite-keys/sst.config.ts b/examples/aws-dynamo-composite-keys/sst.config.ts deleted file mode 100644 index dfea2ec245..0000000000 --- a/examples/aws-dynamo-composite-keys/sst.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -/** - * ## DynamoDB composite keys - * - * Create a DynamoDB table with multi-attribute composite keys in a global secondary index. - */ -export default $config({ - app(input) { - return { - name: "aws-dynamo-composite-keys", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const table = new sst.aws.Dynamo("MyTable", { - fields: { - userId: "string", - noteId: "string", - region: "string", - category: "string", - createdAt: "number", - }, - primaryIndex: { hashKey: "userId", rangeKey: "noteId" }, - globalIndexes: { - RegionCategoryIndex: { - hashKey: ["region", "category"], - rangeKey: "createdAt", - }, - }, - }); - - const creator = new sst.aws.Function("MyCreator", { - handler: "creator.handler", - link: [table], - url: true, - }); - - const reader = new sst.aws.Function("MyReader", { - handler: "reader.handler", - link: [table], - url: true, - }); - - return { - creator: creator.url, - reader: reader.url, - table: table.name, - }; - }, -}); diff --git a/examples/aws-dynamo/creator.ts b/examples/aws-dynamo/creator.ts deleted file mode 100644 index f90ac02884..0000000000 --- a/examples/aws-dynamo/creator.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async (event) => { - await client.send( - new PutItemCommand({ - TableName: Resource.MyTable.name, - Item: { - id: { S: Date.now().toString() }, - message: { S: "Hello" }, - }, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-dynamo/package.json b/examples/aws-dynamo/package.json deleted file mode 100644 index fd944c5262..0000000000 --- a/examples/aws-dynamo/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-dynamo", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-dynamodb": "^3.515.0" - } -} diff --git a/examples/aws-dynamo/reader.ts b/examples/aws-dynamo/reader.ts deleted file mode 100644 index fd68d74ea7..0000000000 --- a/examples/aws-dynamo/reader.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, ScanCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async () => { - const result = await client.send( - new ScanCommand({ - TableName: Resource.MyTable.name, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify(result.Items, null, 2), - }; -}; diff --git a/examples/aws-dynamo/sst.config.ts b/examples/aws-dynamo/sst.config.ts deleted file mode 100644 index 9d9ff5d5b2..0000000000 --- a/examples/aws-dynamo/sst.config.ts +++ /dev/null @@ -1,56 +0,0 @@ -/// - -/** - * ## DynamoDB streams - * - * Create a DynamoDB table, enable streams, and subscribe to it with a function. - */ -export default $config({ - app(input) { - return { - name: "aws-dynamo", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const table = new sst.aws.Dynamo("MyTable", { - fields: { - id: "string", - }, - primaryIndex: { hashKey: "id" }, - stream: "new-and-old-images", - }); - table.subscribe("MySubscriber", "subscriber.handler", { - filters: [ - { - dynamodb: { - NewImage: { - message: { - S: ["Hello"], - }, - }, - }, - }, - ], - }); - - const creator = new sst.aws.Function("MyCreator", { - handler: "creator.handler", - link: [table], - url: true, - }); - - const reader = new sst.aws.Function("MyReader", { - handler: "reader.handler", - link: [table], - url: true, - }); - - return { - creator: creator.url, - reader: reader.url, - table: table.name, - }; - }, -}); diff --git a/examples/aws-dynamo/subscriber.ts b/examples/aws-dynamo/subscriber.ts deleted file mode 100644 index 342cf63a05..0000000000 --- a/examples/aws-dynamo/subscriber.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const handler = async (event) => { - console.log(JSON.stringify(event, null, 2)); - return "ok"; -}; diff --git a/examples/aws-ec2-pulumi/package.json b/examples/aws-ec2-pulumi/package.json deleted file mode 100644 index b4ad3bd51e..0000000000 --- a/examples/aws-ec2-pulumi/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-ec2-pulumi", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - } -} diff --git a/examples/aws-ec2-pulumi/sst.config.ts b/examples/aws-ec2-pulumi/sst.config.ts deleted file mode 100644 index 0987879b00..0000000000 --- a/examples/aws-ec2-pulumi/sst.config.ts +++ /dev/null @@ -1,59 +0,0 @@ -/// - -/** - * ## EC2 with Pulumi - * - * Use raw Pulumi resources to create an EC2 instance. - */ -export default $config({ - app(input) { - return { - name: "aws-ec2-pulumi", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // Notice you don't need to import pulumi, it is already part of sst. - const securityGroup = new aws.ec2.SecurityGroup("web-secgrp", { - ingress: [ - { - protocol: "tcp", - fromPort: 80, - toPort: 80, - cidrBlocks: ["0.0.0.0/0"], - }, - ], - }); - - // Find the latest Ubuntu AMI - const ami = aws.ec2.getAmi({ - filters: [ - { - name: "name", - values: ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"], - }, - ], - mostRecent: true, - owners: ["099720109477"], // Canonical - }); - - // User data to set up a simple web server - const userData = `#!/bin/bash - echo "Hello, World!" > index.html - nohup python3 -m http.server 80 &`; - - // Create an EC2 instance - const server = new aws.ec2.Instance("web-server", { - instanceType: "t2.micro", - ami: ami.then((ami) => ami.id), - userData: userData, - vpcSecurityGroupIds: [securityGroup.id], - associatePublicIpAddress: true, - }); - - return { - app: server.publicIp, - }; - }, -}); diff --git a/examples/aws-efs-sqlite/.gitignore b/examples/aws-efs-sqlite/.gitignore deleted file mode 100644 index 9b1ee42e84..0000000000 --- a/examples/aws-efs-sqlite/.gitignore +++ /dev/null @@ -1,175 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store diff --git a/examples/aws-efs-sqlite/index.ts b/examples/aws-efs-sqlite/index.ts deleted file mode 100644 index f407e5a1fd..0000000000 --- a/examples/aws-efs-sqlite/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -import sqlite3 from "better-sqlite3"; -const db = sqlite3("/mnt/efs/mydb.sqlite"); - -export const handler = async () => { - db.exec(` - CREATE TABLE IF NOT EXISTS visits ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - timestamp TEXT NOT NULL - ); - `); - - // Record a visit - db.prepare("INSERT INTO visits (timestamp) VALUES (CURRENT_TIMESTAMP)").run(); - - // Get recent visits - const visits = db - .prepare("SELECT * FROM visits ORDER BY timestamp DESC LIMIT 10") - .all(); - - return { - statusCode: 200, - body: JSON.stringify({ "10 Most recent visits": visits }, null, 2), - }; -}; diff --git a/examples/aws-efs-sqlite/package.json b/examples/aws-efs-sqlite/package.json deleted file mode 100644 index 821d9ef6ab..0000000000 --- a/examples/aws-efs-sqlite/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-efs-sqlite", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "better-sqlite3": "^11.4.0" - } -} diff --git a/examples/aws-efs-sqlite/sst.config.ts b/examples/aws-efs-sqlite/sst.config.ts deleted file mode 100644 index ec903fa266..0000000000 --- a/examples/aws-efs-sqlite/sst.config.ts +++ /dev/null @@ -1,50 +0,0 @@ -/// - -/** - * ## AWS EFS with SQLite - * - * Mount an EFS file system to a function and write to a SQLite database. - * - * ```js title="index.ts" - * const db = sqlite3("/mnt/efs/mydb.sqlite"); - * ``` - * - * The file system is mounted to `/mnt/efs` in the function. - * - * :::note - * Given the performance of EFS, it's not recommended to use it for databases. - * ::: - * - * This example is for demonstration purposes only. It's not recommended to use - * EFS for databases in production. - */ -export default $config({ - app(input) { - return { - name: "aws-efs-sqlite", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - // Create an EFS file system to store the SQLite database - const efs = new sst.aws.Efs("MyEfs", { vpc }); - - // Create a Lambda function that queries the database - new sst.aws.Function("MyFunction", { - vpc, - url: true, - volume: { - efs, - path: "/mnt/efs", - }, - handler: "index.handler", - nodejs: { - install: ["better-sqlite3"], - }, - }); - }, -}); diff --git a/examples/aws-efs-sqlite/tsconfig.json b/examples/aws-efs-sqlite/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-efs-sqlite/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-efs-surrealdb/.gitignore b/examples/aws-efs-surrealdb/.gitignore deleted file mode 100644 index f3c8b5fb20..0000000000 --- a/examples/aws-efs-surrealdb/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ - -# sst -.sst - -.envrc -shell.nix -pnpm-* \ No newline at end of file diff --git a/examples/aws-efs-surrealdb/index.ts b/examples/aws-efs-surrealdb/index.ts deleted file mode 100644 index fe20791598..0000000000 --- a/examples/aws-efs-surrealdb/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import Surreal from "surrealdb"; -import { Resource } from "sst"; - -export const handler = async () => { - const endpoint = `http://${Resource.MyConfig.host}:${Resource.MyConfig.port}`; - - console.log(`Connecting to`, endpoint); - - const db = new Surreal(); - await db.connect(endpoint); - - await db.use({ - namespace: Resource.MyConfig.namespace, - database: Resource.MyConfig.database, - }); - - await db.signin({ - username: Resource.MyConfig.username, - password: Resource.MyConfig.password, - }); - - await db.query(`INSERT INTO visits { when: time::now() }`); - - const visits = await db.query( - `SELECT * FROM visits ORDER BY when DESC LIMIT 10` - ); - - return { - statusCode: 200, - body: JSON.stringify({ "10 Most recent visits": visits[0] }, null, 2), - }; -}; diff --git a/examples/aws-efs-surrealdb/package.json b/examples/aws-efs-surrealdb/package.json deleted file mode 100644 index adccacafad..0000000000 --- a/examples/aws-efs-surrealdb/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-efs-surrealdb", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js", - "surrealdb": "^1.0.1" - } -} diff --git a/examples/aws-efs-surrealdb/sst.config.ts b/examples/aws-efs-surrealdb/sst.config.ts deleted file mode 100644 index d68d38b264..0000000000 --- a/examples/aws-efs-surrealdb/sst.config.ts +++ /dev/null @@ -1,106 +0,0 @@ -/// -/** - * ## AWS EFS with SurrealDB - * - * We use the SurrealDB docker image to run a server in a container and use EFS as the file - * system. - * - * ```ts title="sst.config.ts" - * const server = new sst.aws.Service("MyService", { - * cluster, - * architecture: "arm64", - * image: "surrealdb/surrealdb:v2.0.2", - * // ... - * volumes: [ - * { efs, path: "/data" }, - * ], - * }); - * ``` - * - * We then connect to the server from a Lambda function. - * - * ```js title="index.ts" - * const endpoint = `http://${Resource.MyConfig.host}:${Resource.MyConfig.port}`; - * - * const db = new Surreal(); - * await db.connect(endpoint); - * ``` - * - * This uses the SurrealDB client to connect to the server. - * - * :::note - * Given the performance of EFS, it's not recommended to use it for databases. - * ::: - * - * This example is for demonstration purposes only. It's not recommended to use - * EFS for databases in production. - */ -export default $config({ - app(input) { - return { - name: "aws-efs-surrealdb", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { "@pulumi/random": "4.16.7" }, - }; - }, - async run() { - const { RandomPassword } = await import("@pulumi/random"); - - // SurrealDB Credentials - const PORT = 8080; - const NAMESPACE = "test"; - const DATABASE = "test"; - const USERNAME = "root"; - const PASSWORD = new RandomPassword("Password", { - length: 32, - }).result; - - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - // Store SurrealDB data in EFS - const efs = new sst.aws.Efs("MyEfs", { vpc }); - - // Run SurrealDB server in a container - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const server = new sst.aws.Service("MyService", { - cluster, - architecture: "arm64", - image: "surrealdb/surrealdb:v2.0.2", - command: [ - "start", - "--bind", - $interpolate`0.0.0.0:${PORT}`, - "--log", - "info", - "--user", - USERNAME, - "--pass", - PASSWORD, - "surrealkv://data/data.skv", - "--allow-scripting", - ], - volumes: [{ efs, path: "/data" }], - }); - - // Lambda client to connect to SurrealDB - const config = new sst.Linkable("MyConfig", { - properties: { - username: USERNAME, - password: PASSWORD, - namespace: NAMESPACE, - database: DATABASE, - port: PORT, - host: server.service, - }, - }); - - new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [config], - url: true, - vpc, - }); - }, -}); diff --git a/examples/aws-efs-surrealdb/tsconfig.json b/examples/aws-efs-surrealdb/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-efs-surrealdb/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-efs/.dockerignore b/examples/aws-efs/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-efs/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-efs/Dockerfile b/examples/aws-efs/Dockerfile deleted file mode 100644 index fdf9535d4a..0000000000 --- a/examples/aws-efs/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY service.mjs /app -COPY common.mjs /app - -ENTRYPOINT ["node", "service.mjs"] \ No newline at end of file diff --git a/examples/aws-efs/common.mjs b/examples/aws-efs/common.mjs deleted file mode 100644 index 3edae33c5e..0000000000 --- a/examples/aws-efs/common.mjs +++ /dev/null @@ -1,20 +0,0 @@ -import { readFile, writeFile } from "fs/promises"; - -export async function increment() { - // read the counter file from EFS - let oldValue = 0; - try { - oldValue = parseInt(await readFile("/mnt/efs/counter", "utf8")); - oldValue = isNaN(oldValue) ? 0 : oldValue; - } catch (e) { - // file doesn't exist - } - - // increment the counter - const newValue = oldValue + 1; - - // write the counter file to EFS - await writeFile("/mnt/efs/counter", newValue.toString()); - - return newValue; -} diff --git a/examples/aws-efs/lambda.ts b/examples/aws-efs/lambda.ts deleted file mode 100644 index a77e93aa24..0000000000 --- a/examples/aws-efs/lambda.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { increment } from "./common.mjs"; - -export const handler = async () => { - const counter = await increment(); - console.log("COUNTER", counter); - return { - statusCode: 200, - body: JSON.stringify({ - counter, - }), - }; -}; diff --git a/examples/aws-efs/package.json b/examples/aws-efs/package.json deleted file mode 100644 index 50dfa020a3..0000000000 --- a/examples/aws-efs/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "aws-efs", - "version": "1.0.0", - "description": "", - "main": "index.js", - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.19.2" - } -} diff --git a/examples/aws-efs/service.mjs b/examples/aws-efs/service.mjs deleted file mode 100644 index 6f8866d20d..0000000000 --- a/examples/aws-efs/service.mjs +++ /dev/null @@ -1,18 +0,0 @@ -import express from "express"; -import { increment } from "./common.mjs"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send( - JSON.stringify({ - counter: await increment(), - }) - ); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-efs/sst.config.ts b/examples/aws-efs/sst.config.ts deleted file mode 100644 index 352852780e..0000000000 --- a/examples/aws-efs/sst.config.ts +++ /dev/null @@ -1,58 +0,0 @@ -/// - -/** - * ## AWS EFS - * - * Mount an EFS file system to a function and a container. - * - * This allows both your function and the container to access the same file system. Here they - * both update a counter that's stored in the file system. - * - * ```js title="common.mjs" - * await writeFile("/mnt/efs/counter", newValue.toString()); - * ``` - * - * The file system is mounted to `/mnt/efs` in both the function and the container. - */ -export default $config({ - app(input) { - return { - name: "aws-efs", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - // Create an EFS file system to store a counter - const efs = new sst.aws.Efs("MyEfs", { vpc }); - - // Create a Lambda function that increments the counter - new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - url: true, - vpc, - volume: { - efs, - path: "/mnt/efs", - }, - }); - - // Create a service that increments the same counter - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - volumes: [ - { - efs, - path: "/mnt/efs", - }, - ], - }); - }, -}); diff --git a/examples/aws-email/package.json b/examples/aws-email/package.json deleted file mode 100644 index c24cf0273c..0000000000 --- a/examples/aws-email/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-email", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-sesv2": "^3.515.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.142" - } -} diff --git a/examples/aws-email/sender.ts b/examples/aws-email/sender.ts deleted file mode 100644 index a1c2827b1c..0000000000 --- a/examples/aws-email/sender.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Resource } from "sst"; -import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; - -const client = new SESv2Client(); - -export const handler = async () => { - await client.send( - new SendEmailCommand({ - FromEmailAddress: Resource.MyEmail.sender, - Destination: { - ToAddresses: [Resource.MyEmail.sender], - }, - Content: { - Simple: { - Subject: { - Data: "Hello World!", - }, - Body: { - Text: { - Data: "Sent from my SST app.", - }, - }, - }, - }, - }) - ); - - return { - statusCode: 200, - body: "Sent!" - }; -}; diff --git a/examples/aws-email/sst.config.ts b/examples/aws-email/sst.config.ts deleted file mode 100644 index bd9602537a..0000000000 --- a/examples/aws-email/sst.config.ts +++ /dev/null @@ -1,26 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-email", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const email = new sst.aws.Email("MyEmail", { - sender: "email@example.com", - }); - - const api = new sst.aws.Function("MyApi", { - handler: "sender.handler", - link: [email], - url: true, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-email/tsconfig.json b/examples/aws-email/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-email/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-express-redis/.dockerignore b/examples/aws-express-redis/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-express-redis/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-express-redis/.gitignore b/examples/aws-express-redis/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-express-redis/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-express-redis/Dockerfile b/examples/aws-express-redis/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-express-redis/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-express-redis/index.mjs b/examples/aws-express-redis/index.mjs deleted file mode 100644 index a951c70253..0000000000 --- a/examples/aws-express-redis/index.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import express from "express"; -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const PORT = 80; - -const app = express(); - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -app.get("/", async (req, res) => { - const counter = await redis.incr("counter"); - res.send(`Hit counter: ${counter}`); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-express-redis/package.json b/examples/aws-express-redis/package.json deleted file mode 100644 index 376035cecd..0000000000 --- a/examples/aws-express-redis/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-express-redis", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.21.0", - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-express-redis/sst.config.ts b/examples/aws-express-redis/sst.config.ts deleted file mode 100644 index edf565f96c..0000000000 --- a/examples/aws-express-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Express Redis - * - * Creates a hit counter app with Express and Redis. - * - * This deploys Express as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {9} - * new sst.aws.Service("MyService", { - * cluster, - * loadBalancer: { - * ports: [{ listen: "80/http" }], - * }, - * dev: { - * command: "node --watch index.mjs", - * }, - * link: [redis], - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:80` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `npx sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: "aws-express-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); - }, -}); diff --git a/examples/aws-express-redis/tsconfig.json b/examples/aws-express-redis/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-express-redis/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-express/.dockerignore b/examples/aws-express/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-express/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-express/.gitignore b/examples/aws-express/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-express/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-express/Dockerfile b/examples/aws-express/Dockerfile deleted file mode 100644 index 1d16aa3311..0000000000 --- a/examples/aws-express/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:lts-alpine - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-express/index.mjs b/examples/aws-express/index.mjs deleted file mode 100644 index 507250ec18..0000000000 --- a/examples/aws-express/index.mjs +++ /dev/null @@ -1,63 +0,0 @@ -import multer from "multer"; -import express from "express"; -import { Resource } from "sst"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const PORT = 80; - -const app = express(); -const s3 = new S3Client({}); -const upload = multer({ storage: multer.memoryStorage() }); - -app.get("/", (req, res) => { - res.send("Hello World!") -}); - -app.post("/", upload.single("file"), async (req, res) => { - const file = req.file; - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.mimetype, - Key: file.originalname, - Body: file.buffer, - }; - - const upload = new Upload({ - params, - client: s3, - }); - - await upload.done(); - - res.status(200).send("File uploaded successfully."); -}); - -app.get("/latest", async (req, res) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents.sort( - (a, b) => b.LastModified - a.LastModified, - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(s3, command); - - res.redirect(url); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-express/package.json b/examples/aws-express/package.json deleted file mode 100644 index ad4e1fbccb..0000000000 --- a/examples/aws-express/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "aws-express", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.705.0", - "@aws-sdk/lib-storage": "^3.705.0", - "@aws-sdk/s3-request-presigner": "^3.705.0", - "express": "^4.21.1", - "multer": "^1.4.5-lts.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146" - } -} diff --git a/examples/aws-express/sst.config.ts b/examples/aws-express/sst.config.ts deleted file mode 100644 index 1dd9704d68..0000000000 --- a/examples/aws-express/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-express", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); - }, -}); diff --git a/examples/aws-express/tsconfig.json b/examples/aws-express/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-express/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-fastapi/.gitignore b/examples/aws-fastapi/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-fastapi/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-fastapi/core/pyproject.toml b/examples/aws-fastapi/core/pyproject.toml deleted file mode 100644 index 4d9ed5884e..0000000000 --- a/examples/aws-fastapi/core/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "core" -version = "0.1.0" -description = "Add your description here" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -requires-python = "==3.11.*" -dependencies = ["requests>=2.32.3"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-fastapi/core/src/core/__init__.py b/examples/aws-fastapi/core/src/core/__init__.py deleted file mode 100644 index 437615c6c1..0000000000 --- a/examples/aws-fastapi/core/src/core/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from core.db import get_user - - -def hello() -> str: - return "Hello from core!" - - -__all__ = ["get_user", "hello"] diff --git a/examples/aws-fastapi/core/src/core/db.py b/examples/aws-fastapi/core/src/core/db.py deleted file mode 100644 index c719b87ba4..0000000000 --- a/examples/aws-fastapi/core/src/core/db.py +++ /dev/null @@ -1,5 +0,0 @@ -def get_user(user_id: str) -> dict: - return { - "user_id": user_id, - "name": "John Doe", - } diff --git a/examples/aws-fastapi/core/src/core/ping.py b/examples/aws-fastapi/core/src/core/ping.py deleted file mode 100644 index c13cfd5726..0000000000 --- a/examples/aws-fastapi/core/src/core/ping.py +++ /dev/null @@ -1,5 +0,0 @@ -import requests - - -def ping(): - return requests.get("https://api.github.com").status_code diff --git a/examples/aws-fastapi/functions/pyproject.toml b/examples/aws-fastapi/functions/pyproject.toml deleted file mode 100644 index ac5a78c4b8..0000000000 --- a/examples/aws-fastapi/functions/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "Lambda function handlers" -dependencies = ["core", "sst-sdk", "fastapi==0.115.8", "mangum==0.19.0"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-fastapi/functions/src/functions/api.py b/examples/aws-fastapi/functions/src/functions/api.py deleted file mode 100644 index 56fb5c8fe7..0000000000 --- a/examples/aws-fastapi/functions/src/functions/api.py +++ /dev/null @@ -1,39 +0,0 @@ -from fastapi import FastAPI -from mangum import Mangum -from sst import Resource -from functions.shared import foo -from core.db import get_user -from core.ping import ping - -# Create FastAPI app with JSON configuration -app = FastAPI( - title="SST FastAPI App", - json_encoder=None # Use FastAPI's default JSON encoder -) - -# Create a route -@app.get("/") -async def root(): - print("Function invoked from Python") - - # Share code within the same workspace package - result = foo() - print(result) - - # Share code between workspace packages - res = ping() - user = get_user("1234") - print(user) - print("Ping result:", res) - - # Use the SST SDK to access resources - resource_value = Resource.MyLinkableValue.foo - print(f"Resource.MyLinkableValue.foo: {resource_value}") - - return { - "message": f"{resource_value} from Python!", - - } - -# Create handler for AWS Lambda with specific configuration -handler = Mangum(app, api_gateway_base_path=None, lifespan="off") diff --git a/examples/aws-fastapi/functions/src/functions/shared.py b/examples/aws-fastapi/functions/src/functions/shared.py deleted file mode 100644 index 1f022956c6..0000000000 --- a/examples/aws-fastapi/functions/src/functions/shared.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - return "bar" diff --git a/examples/aws-fastapi/package.json b/examples/aws-fastapi/package.json deleted file mode 100644 index ff07a387c7..0000000000 --- a/examples/aws-fastapi/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-fastapi", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-fastapi/pyproject.toml b/examples/aws-fastapi/pyproject.toml deleted file mode 100644 index c7a1678eeb..0000000000 --- a/examples/aws-fastapi/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-fastapi" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.11.*" - -[tool.uv.workspace] -members = ["functions", "core"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-fastapi/sst.config.ts b/examples/aws-fastapi/sst.config.ts deleted file mode 100644 index 4624a75bff..0000000000 --- a/examples/aws-fastapi/sst.config.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// - -/** - * ## FastAPI - * - * Deploy a Python FastAPI app as a Lambda function with a linked value. - */ -export default $config({ - app(input) { - return { - name: "aws-fastapi", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: true, - }, - }; - }, - async run() { - const linkableValue = new sst.Linkable("MyLinkableValue", { - properties: { - foo: "Hello World", - }, - }); - - const fastapi = new sst.aws.Function("FastAPI", { - handler: "functions/src/functions/api.handler", - runtime: "python3.11", - url: true, - link: [linkableValue], - }); - - return { - fastapi: fastapi.url, - }; - }, -}); diff --git a/examples/aws-fastapi/tsconfig.json b/examples/aws-fastapi/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-fastapi/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-ffmpeg/.gitignore b/examples/aws-ffmpeg/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-ffmpeg/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-ffmpeg/clip.mp4 b/examples/aws-ffmpeg/clip.mp4 deleted file mode 100644 index 9efdbf0110..0000000000 Binary files a/examples/aws-ffmpeg/clip.mp4 and /dev/null differ diff --git a/examples/aws-ffmpeg/index.ts b/examples/aws-ffmpeg/index.ts deleted file mode 100644 index f0be094605..0000000000 --- a/examples/aws-ffmpeg/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import path from "path"; -import ffmpeg from "ffmpeg-static"; -import { promises as fs } from "fs"; -import { spawnSync } from "child_process"; - -export async function handler() { - const videoPath = "clip.mp4"; - - const outputFile = "thumbnail.jpg"; - const outputPath = process.env.SST_DEV - ? outputFile - : path.join("/tmp", outputFile); - - const ffmpegParams = [ - "-ss", - "1", - "-i", - videoPath, - "-vf", - "thumbnail,scale=960:540", - "-vframes", - "1", - outputPath, - ]; - - spawnSync(ffmpeg, ffmpegParams, { stdio: "pipe" }); - - const img = await fs.readFile(outputPath); - const body = Buffer.from(img).toString("base64"); - - return { - body, - statusCode: 200, - isBase64Encoded: true, - headers: { - "Content-Type": "image/jpeg", - "Content-Disposition": "inline", - }, - }; -} diff --git a/examples/aws-ffmpeg/package.json b/examples/aws-ffmpeg/package.json deleted file mode 100644 index 4bee839366..0000000000 --- a/examples/aws-ffmpeg/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-ffmpeg", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ffmpeg-static": "^5.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-ffmpeg/sst.config.ts b/examples/aws-ffmpeg/sst.config.ts deleted file mode 100644 index 01e1a3b46c..0000000000 --- a/examples/aws-ffmpeg/sst.config.ts +++ /dev/null @@ -1,59 +0,0 @@ -/// - -/** - * ## FFmpeg in Lambda - * - * Uses [FFmpeg](https://ffmpeg.org/) to process videos. In this example, it takes a `clip.mp4` - * and grabs a single frame from it. - * - * :::tip - * You don't need to use a Lambda layer to use FFmpeg. - * ::: - * - * We use the [`ffmpeg-static`](https://www.npmjs.com/package/ffmpeg-static) package that - * contains pre-built binaries for all architectures. - * - * ```ts title="index.ts" - * import ffmpeg from "ffmpeg-static"; - * ``` - * - * We can use this to spawn a child process and run FFmpeg. - * - * ```ts title="index.ts" - * spawnSync(ffmpeg, ffmpegParams, { stdio: "pipe" }); - * ``` - * - * We don't need a layer when we deploy this because SST will use the right binary for the - * target Lambda architecture; including `arm64`. - * - * ```json title="sst.config.ts" - * { - * nodejs: { install: ["ffmpeg-static"] } - * } - * ``` - * - * All this is handled by [`nodejs.install`](/docs/component/aws/function#nodejs-install). - */ -export default $config({ - app(input) { - return { - name: "aws-ffmpeg", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const func = new sst.aws.Function("MyFunction", { - url: true, - memory: "2 GB", - timeout: "15 minutes", - handler: "index.handler", - copyFiles: [{ from: "clip.mp4" }], - nodejs: { install: ["ffmpeg-static"] }, - }); - - return { - url: func.url, - }; - }, -}); diff --git a/examples/aws-ffmpeg/tsconfig.json b/examples/aws-ffmpeg/tsconfig.json deleted file mode 100644 index 2f98042715..0000000000 --- a/examples/aws-ffmpeg/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/examples/aws-flutter-web/.gitignore b/examples/aws-flutter-web/.gitignore deleted file mode 100644 index 41160e58d7..0000000000 --- a/examples/aws-flutter-web/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# sst -.sst diff --git a/examples/aws-flutter-web/.metadata b/examples/aws-flutter-web/.metadata deleted file mode 100644 index cbf1dc0e0d..0000000000 --- a/examples/aws-flutter-web/.metadata +++ /dev/null @@ -1,45 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3" - channel: "stable" - -project_type: app - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: android - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: ios - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: linux - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: macos - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: web - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: windows - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/examples/aws-flutter-web/analysis_options.yaml b/examples/aws-flutter-web/analysis_options.yaml deleted file mode 100644 index 0d2902135c..0000000000 --- a/examples/aws-flutter-web/analysis_options.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/examples/aws-flutter-web/android/app/build.gradle b/examples/aws-flutter-web/android/app/build.gradle deleted file mode 100644 index b68da4a58e..0000000000 --- a/examples/aws-flutter-web/android/app/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -plugins { - id "com.android.application" - id "kotlin-android" - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. - id "dev.flutter.flutter-gradle-plugin" -} - -def localProperties = new Properties() -def localPropertiesFile = rootProject.file("local.properties") -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader("UTF-8") { reader -> - localProperties.load(reader) - } -} - -def flutterVersionCode = localProperties.getProperty("flutter.versionCode") -if (flutterVersionCode == null) { - flutterVersionCode = "1" -} - -def flutterVersionName = localProperties.getProperty("flutter.versionName") -if (flutterVersionName == null) { - flutterVersionName = "1.0" -} - -android { - namespace = "com.example.aws_flutter_web" - compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.example.aws_flutter_web" - // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdk = flutter.minSdkVersion - targetSdk = flutter.targetSdkVersion - versionCode = flutterVersionCode.toInteger() - versionName = flutterVersionName - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.debug - } - } -} - -flutter { - source = "../.." -} diff --git a/examples/aws-flutter-web/android/app/src/debug/AndroidManifest.xml b/examples/aws-flutter-web/android/app/src/debug/AndroidManifest.xml deleted file mode 100644 index 399f6981d5..0000000000 --- a/examples/aws-flutter-web/android/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/AndroidManifest.xml b/examples/aws-flutter-web/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index 6a5ac6fe10..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/kotlin/com/example/aws_flutter_web/MainActivity.kt b/examples/aws-flutter-web/android/app/src/main/kotlin/com/example/aws_flutter_web/MainActivity.kt deleted file mode 100644 index c85c87a074..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/kotlin/com/example/aws_flutter_web/MainActivity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.example.aws_flutter_web - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity: FlutterActivity() diff --git a/examples/aws-flutter-web/android/app/src/main/res/values-night/styles.xml b/examples/aws-flutter-web/android/app/src/main/res/values-night/styles.xml deleted file mode 100644 index 06952be745..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/res/values-night/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/res/values/styles.xml b/examples/aws-flutter-web/android/app/src/main/res/values/styles.xml deleted file mode 100644 index cb1ef88056..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/profile/AndroidManifest.xml b/examples/aws-flutter-web/android/app/src/profile/AndroidManifest.xml deleted file mode 100644 index 399f6981d5..0000000000 --- a/examples/aws-flutter-web/android/app/src/profile/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/examples/aws-flutter-web/android/build.gradle b/examples/aws-flutter-web/android/build.gradle deleted file mode 100644 index d2ffbffa4c..0000000000 --- a/examples/aws-flutter-web/android/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -allprojects { - repositories { - google() - mavenCentral() - } -} - -rootProject.buildDir = "../build" -subprojects { - project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { - project.evaluationDependsOn(":app") -} - -tasks.register("clean", Delete) { - delete rootProject.buildDir -} diff --git a/examples/aws-flutter-web/android/gradle.properties b/examples/aws-flutter-web/android/gradle.properties deleted file mode 100644 index 3b5b324f6e..0000000000 --- a/examples/aws-flutter-web/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError -android.useAndroidX=true -android.enableJetifier=true diff --git a/examples/aws-flutter-web/android/gradle/wrapper/gradle-wrapper.properties b/examples/aws-flutter-web/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e1ca574ef0..0000000000 --- a/examples/aws-flutter-web/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip diff --git a/examples/aws-flutter-web/android/settings.gradle b/examples/aws-flutter-web/android/settings.gradle deleted file mode 100644 index 536165d35a..0000000000 --- a/examples/aws-flutter-web/android/settings.gradle +++ /dev/null @@ -1,25 +0,0 @@ -pluginManagement { - def flutterSdkPath = { - def properties = new Properties() - file("local.properties").withInputStream { properties.load(it) } - def flutterSdkPath = properties.getProperty("flutter.sdk") - assert flutterSdkPath != null, "flutter.sdk not set in local.properties" - return flutterSdkPath - }() - - includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") - - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} - -plugins { - id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false -} - -include ":app" diff --git a/examples/aws-flutter-web/ios/.gitignore b/examples/aws-flutter-web/ios/.gitignore deleted file mode 100644 index 7a7f9873ad..0000000000 --- a/examples/aws-flutter-web/ios/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -**/dgph -*.mode1v3 -*.mode2v3 -*.moved-aside -*.pbxuser -*.perspectivev3 -**/*sync/ -.sconsign.dblite -.tags* -**/.vagrant/ -**/DerivedData/ -Icon? -**/Pods/ -**/.symlinks/ -profile -xcuserdata -**/.generated/ -Flutter/App.framework -Flutter/Flutter.framework -Flutter/Flutter.podspec -Flutter/Generated.xcconfig -Flutter/ephemeral/ -Flutter/app.flx -Flutter/app.zip -Flutter/flutter_assets/ -Flutter/flutter_export_environment.sh -ServiceDefinitions.json -Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!default.mode1v3 -!default.mode2v3 -!default.pbxuser -!default.perspectivev3 diff --git a/examples/aws-flutter-web/ios/Flutter/AppFrameworkInfo.plist b/examples/aws-flutter-web/ios/Flutter/AppFrameworkInfo.plist deleted file mode 100644 index 7c56964006..0000000000 --- a/examples/aws-flutter-web/ios/Flutter/AppFrameworkInfo.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - App - CFBundleIdentifier - io.flutter.flutter.app - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - App - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 12.0 - - diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.pbxproj b/examples/aws-flutter-web/ios/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index 332b360542..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,616 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 54; - objects = { - -/* Begin PBXBuildFile section */ - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; - 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; - 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 97C146E61CF9000F007C117D /* Project object */; - proxyType = 1; - remoteGlobalIDString = 97C146ED1CF9000F007C117D; - remoteInfo = Runner; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 9705A1C41CF9048500538489 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; - 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; - 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 97C146EB1CF9000F007C117D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 331C8082294A63A400263BE5 /* RunnerTests */ = { - isa = PBXGroup; - children = ( - 331C807B294A618700263BE5 /* RunnerTests.swift */, - ); - path = RunnerTests; - sourceTree = ""; - }; - 9740EEB11CF90186004384FC /* Flutter */ = { - isa = PBXGroup; - children = ( - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 9740EEB31CF90195004384FC /* Generated.xcconfig */, - ); - name = Flutter; - sourceTree = ""; - }; - 97C146E51CF9000F007C117D = { - isa = PBXGroup; - children = ( - 9740EEB11CF90186004384FC /* Flutter */, - 97C146F01CF9000F007C117D /* Runner */, - 97C146EF1CF9000F007C117D /* Products */, - 331C8082294A63A400263BE5 /* RunnerTests */, - ); - sourceTree = ""; - }; - 97C146EF1CF9000F007C117D /* Products */ = { - isa = PBXGroup; - children = ( - 97C146EE1CF9000F007C117D /* Runner.app */, - 331C8081294A63A400263BE5 /* RunnerTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 97C146F01CF9000F007C117D /* Runner */ = { - isa = PBXGroup; - children = ( - 97C146FA1CF9000F007C117D /* Main.storyboard */, - 97C146FD1CF9000F007C117D /* Assets.xcassets */, - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, - 97C147021CF9000F007C117D /* Info.plist */, - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, - ); - path = Runner; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 331C8080294A63A400263BE5 /* RunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; - buildPhases = ( - 331C807D294A63A400263BE5 /* Sources */, - 331C807F294A63A400263BE5 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 331C8086294A63A400263BE5 /* PBXTargetDependency */, - ); - name = RunnerTests; - productName = RunnerTests; - productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 97C146ED1CF9000F007C117D /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - 9740EEB61CF901F6004384FC /* Run Script */, - 97C146EA1CF9000F007C117D /* Sources */, - 97C146EB1CF9000F007C117D /* Frameworks */, - 97C146EC1CF9000F007C117D /* Resources */, - 9705A1C41CF9048500538489 /* Embed Frameworks */, - 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Runner; - productName = Runner; - productReference = 97C146EE1CF9000F007C117D /* Runner.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 97C146E61CF9000F007C117D /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1510; - ORGANIZATIONNAME = ""; - TargetAttributes = { - 331C8080294A63A400263BE5 = { - CreatedOnToolsVersion = 14.0; - TestTargetID = 97C146ED1CF9000F007C117D; - }; - 97C146ED1CF9000F007C117D = { - CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1100; - }; - }; - }; - buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 97C146E51CF9000F007C117D; - productRefGroup = 97C146EF1CF9000F007C117D /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 97C146ED1CF9000F007C117D /* Runner */, - 331C8080294A63A400263BE5 /* RunnerTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 331C807F294A63A400263BE5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 97C146EC1CF9000F007C117D /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; - }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 331C807D294A63A400263BE5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 97C146EA1CF9000F007C117D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 97C146ED1CF9000F007C117D /* Runner */; - targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 97C146FA1CF9000F007C117D /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 97C146FB1CF9000F007C117D /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 97C147001CF9000F007C117D /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 249021D3217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Profile; - }; - 249021D4217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Profile; - }; - 331C8088294A63A400263BE5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; - }; - name = Debug; - }; - 331C8089294A63A400263BE5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; - }; - name = Release; - }; - 331C808A294A63A400263BE5 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; - }; - name = Profile; - }; - 97C147031CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 97C147041CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 97C147061CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Debug; - }; - 97C147071CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 331C8088294A63A400263BE5 /* Debug */, - 331C8089294A63A400263BE5 /* Release */, - 331C808A294A63A400263BE5 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 97C147031CF9000F007C117D /* Debug */, - 97C147041CF9000F007C117D /* Release */, - 249021D3217E4FDB00AE95B9 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 97C147061CF9000F007C117D /* Debug */, - 97C147071CF9000F007C117D /* Release */, - 249021D4217E4FDB00AE95B9 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 97C146E61CF9000F007C117D /* Project object */; -} diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/aws-flutter-web/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index 8e3ca5dfe1..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/ios/Runner/AppDelegate.swift b/examples/aws-flutter-web/ios/Runner/AppDelegate.swift deleted file mode 100644 index 9074fee929..0000000000 --- a/examples/aws-flutter-web/ios/Runner/AppDelegate.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Flutter -import UIKit - -@UIApplicationMain -@objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } -} diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index d36b1fab2d..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "images" : [ - { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" - }, - { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "Icon-App-20x20@3x.png", - "scale" : "3x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@3x.png", - "scale" : "3x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "Icon-App-40x40@3x.png", - "scale" : "3x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "Icon-App-60x60@2x.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "Icon-App-60x60@3x.png", - "scale" : "3x" - }, - { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "Icon-App-20x20@1x.png", - "scale" : "1x" - }, - { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "Icon-App-40x40@1x.png", - "scale" : "1x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "Icon-App-76x76@1x.png", - "scale" : "1x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "Icon-App-76x76@2x.png", - "scale" : "2x" - }, - { - "size" : "83.5x83.5", - "idiom" : "ipad", - "filename" : "Icon-App-83.5x83.5@2x.png", - "scale" : "2x" - }, - { - "size" : "1024x1024", - "idiom" : "ios-marketing", - "filename" : "Icon-App-1024x1024@1x.png", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png deleted file mode 100644 index 7353c41ecf..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png deleted file mode 100644 index 797d452e45..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png deleted file mode 100644 index 6ed2d933e1..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png deleted file mode 100644 index 4cd7b0099c..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png deleted file mode 100644 index fe730945a0..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png deleted file mode 100644 index 321773cd85..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png deleted file mode 100644 index 797d452e45..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png deleted file mode 100644 index 502f463a9b..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png deleted file mode 100644 index 0ec3034392..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png deleted file mode 100644 index 0ec3034392..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png deleted file mode 100644 index e9f5fea27c..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png deleted file mode 100644 index 84ac32ae7d..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png deleted file mode 100644 index 8953cba090..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png deleted file mode 100644 index 0467bf12aa..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json deleted file mode 100644 index 0bedcf2fd4..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "LaunchImage.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "LaunchImage@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "filename" : "LaunchImage@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/examples/aws-flutter-web/ios/Runner/Info.plist b/examples/aws-flutter-web/ios/Runner/Info.plist deleted file mode 100644 index fae703d438..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Info.plist +++ /dev/null @@ -1,49 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Aws Flutter Web - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - aws_flutter_web - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - - - diff --git a/examples/aws-flutter-web/ios/RunnerTests/RunnerTests.swift b/examples/aws-flutter-web/ios/RunnerTests/RunnerTests.swift deleted file mode 100644 index 86a7c3b1b6..0000000000 --- a/examples/aws-flutter-web/ios/RunnerTests/RunnerTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Flutter -import UIKit -import XCTest - -class RunnerTests: XCTestCase { - - func testExample() { - // If you add code to the Runner application, consider adding tests here. - // See https://developer.apple.com/documentation/xctest for more information about using XCTest. - } - -} diff --git a/examples/aws-flutter-web/lib/main.dart b/examples/aws-flutter-web/lib/main.dart deleted file mode 100644 index 8e94089121..0000000000 --- a/examples/aws-flutter-web/lib/main.dart +++ /dev/null @@ -1,125 +0,0 @@ -import 'package:flutter/material.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // TRY THIS: Try running your application with "flutter run". You'll see - // the application has a purple toolbar. Then, without quitting the app, - // try changing the seedColor in the colorScheme below to Colors.green - // and then invoke "hot reload" (save your changes or press the "hot - // reload" button in a Flutter-supported IDE, or press "r" if you used - // the command line to start the app). - // - // Notice that the counter didn't reset back to zero; the application - // state is not lost during the reload. To reset the state, use hot - // restart instead. - // - // This works for code too, not just values: Most code changes can be - // tested with just a hot reload. - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - useMaterial3: true, - ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // TRY THIS: Try changing the color here to a specific color (to - // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar - // change color while the other colors stay the same. - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - // - // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" - // action in the IDE, or press "p" in the console), to see the - // wireframe for each widget. - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } -} diff --git a/examples/aws-flutter-web/linux/.gitignore b/examples/aws-flutter-web/linux/.gitignore deleted file mode 100644 index d3896c9844..0000000000 --- a/examples/aws-flutter-web/linux/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/examples/aws-flutter-web/linux/CMakeLists.txt b/examples/aws-flutter-web/linux/CMakeLists.txt deleted file mode 100644 index a147894dec..0000000000 --- a/examples/aws-flutter-web/linux/CMakeLists.txt +++ /dev/null @@ -1,145 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.10) -project(runner LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "aws_flutter_web") -# The unique GTK application identifier for this application. See: -# https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "com.example.aws_flutter_web") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(SET CMP0063 NEW) - -# Load bundled libraries from the lib/ directory relative to the binary. -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Root filesystem for cross-building. -if(FLUTTER_TARGET_PLATFORM_SYSROOT) - set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) - set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -endif() - -# Define build configuration options. -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") -endif() - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_14) - target_compile_options(${TARGET} PRIVATE -Wall -Werror) - target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") - target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) - -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") - -# Define the application target. To change its name, change BINARY_NAME above, -# not the value here, or `flutter run` will no longer work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} - "main.cc" - "my_application.cc" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" -) - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add dependency libraries. Add any application-specific dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) - -# Only the install-generated bundle's copy of the executable will launch -# correctly, since the resources must in the right relative locations. To avoid -# people trying to run the unbundled copy, put it in a subdirectory instead of -# the default top-level location. -set_target_properties(${BINARY_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" -) - - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# By default, "installing" just makes a relocatable bundle in the build -# directory. -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -# Start with a clean build bundle directory every time. -install(CODE " - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") - " COMPONENT Runtime) - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) - install(FILES "${bundled_library}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endforeach(bundled_library) - -# Copy the native assets provided by the build.dart from all packages. -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") -install(DIRECTORY "${NATIVE_ASSETS_DIR}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() diff --git a/examples/aws-flutter-web/linux/flutter/CMakeLists.txt b/examples/aws-flutter-web/linux/flutter/CMakeLists.txt deleted file mode 100644 index d5bd01648a..0000000000 --- a/examples/aws-flutter-web/linux/flutter/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.10) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. - -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), -# which isn't available in 3.10. -function(list_prepend LIST_NAME PREFIX) - set(NEW_LIST "") - foreach(element ${${LIST_NAME}}) - list(APPEND NEW_LIST "${PREFIX}${element}") - endforeach(element) - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) -endfunction() - -# === Flutter Library === -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) - -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "fl_basic_message_channel.h" - "fl_binary_codec.h" - "fl_binary_messenger.h" - "fl_dart_project.h" - "fl_engine.h" - "fl_json_message_codec.h" - "fl_json_method_codec.h" - "fl_message_codec.h" - "fl_method_call.h" - "fl_method_channel.h" - "fl_method_codec.h" - "fl_method_response.h" - "fl_plugin_registrar.h" - "fl_plugin_registry.h" - "fl_standard_message_codec.h" - "fl_standard_method_codec.h" - "fl_string_codec.h" - "fl_value.h" - "fl_view.h" - "flutter_linux.h" -) -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") -target_link_libraries(flutter INTERFACE - PkgConfig::GTK - PkgConfig::GLIB - PkgConfig::GIO -) -add_dependencies(flutter flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" - ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} -) diff --git a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.cc b/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index e71a16d23d..0000000000 --- a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void fl_register_plugins(FlPluginRegistry* registry) { -} diff --git a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.h b/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc0..0000000000 --- a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/examples/aws-flutter-web/linux/flutter/generated_plugins.cmake b/examples/aws-flutter-web/linux/flutter/generated_plugins.cmake deleted file mode 100644 index 2e1de87a7e..0000000000 --- a/examples/aws-flutter-web/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/examples/aws-flutter-web/linux/main.cc b/examples/aws-flutter-web/linux/main.cc deleted file mode 100644 index e7c5c54370..0000000000 --- a/examples/aws-flutter-web/linux/main.cc +++ /dev/null @@ -1,6 +0,0 @@ -#include "my_application.h" - -int main(int argc, char** argv) { - g_autoptr(MyApplication) app = my_application_new(); - return g_application_run(G_APPLICATION(app), argc, argv); -} diff --git a/examples/aws-flutter-web/linux/my_application.cc b/examples/aws-flutter-web/linux/my_application.cc deleted file mode 100644 index 809b553a5a..0000000000 --- a/examples/aws-flutter-web/linux/my_application.cc +++ /dev/null @@ -1,124 +0,0 @@ -#include "my_application.h" - -#include -#ifdef GDK_WINDOWING_X11 -#include -#endif - -#include "flutter/generated_plugin_registrant.h" - -struct _MyApplication { - GtkApplication parent_instance; - char** dart_entrypoint_arguments; -}; - -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) - -// Implements GApplication::activate. -static void my_application_activate(GApplication* application) { - MyApplication* self = MY_APPLICATION(application); - GtkWindow* window = - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - - // Use a header bar when running in GNOME as this is the common style used - // by applications and is the setup most users will be using (e.g. Ubuntu - // desktop). - // If running on X and not using GNOME then just use a traditional title bar - // in case the window manager does more exotic layout, e.g. tiling. - // If running on Wayland assume the header bar will work (may need changing - // if future cases occur). - gboolean use_header_bar = TRUE; -#ifdef GDK_WINDOWING_X11 - GdkScreen* screen = gtk_window_get_screen(window); - if (GDK_IS_X11_SCREEN(screen)) { - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); - if (g_strcmp0(wm_name, "GNOME Shell") != 0) { - use_header_bar = FALSE; - } - } -#endif - if (use_header_bar) { - GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); - gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "aws_flutter_web"); - gtk_header_bar_set_show_close_button(header_bar, TRUE); - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); - } else { - gtk_window_set_title(window, "aws_flutter_web"); - } - - gtk_window_set_default_size(window, 1280, 720); - gtk_widget_show(GTK_WIDGET(window)); - - g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); - - FlView* view = fl_view_new(project); - gtk_widget_show(GTK_WIDGET(view)); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); - - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); - - gtk_widget_grab_focus(GTK_WIDGET(view)); -} - -// Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { - MyApplication* self = MY_APPLICATION(application); - // Strip out the first argument as it is the binary name. - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); - - g_autoptr(GError) error = nullptr; - if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; - } - - g_application_activate(application); - *exit_status = 0; - - return TRUE; -} - -// Implements GApplication::startup. -static void my_application_startup(GApplication* application) { - //MyApplication* self = MY_APPLICATION(object); - - // Perform any actions required at application startup. - - G_APPLICATION_CLASS(my_application_parent_class)->startup(application); -} - -// Implements GApplication::shutdown. -static void my_application_shutdown(GApplication* application) { - //MyApplication* self = MY_APPLICATION(object); - - // Perform any actions required at application shutdown. - - G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); -} - -// Implements GObject::dispose. -static void my_application_dispose(GObject* object) { - MyApplication* self = MY_APPLICATION(object); - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); -} - -static void my_application_class_init(MyApplicationClass* klass) { - G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; - G_APPLICATION_CLASS(klass)->startup = my_application_startup; - G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; -} - -static void my_application_init(MyApplication* self) {} - -MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - "flags", G_APPLICATION_NON_UNIQUE, - nullptr)); -} diff --git a/examples/aws-flutter-web/linux/my_application.h b/examples/aws-flutter-web/linux/my_application.h deleted file mode 100644 index 72271d5e41..0000000000 --- a/examples/aws-flutter-web/linux/my_application.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FLUTTER_MY_APPLICATION_H_ -#define FLUTTER_MY_APPLICATION_H_ - -#include - -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, - GtkApplication) - -/** - * my_application_new: - * - * Creates a new Flutter-based application. - * - * Returns: a new #MyApplication. - */ -MyApplication* my_application_new(); - -#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/examples/aws-flutter-web/macos/.gitignore b/examples/aws-flutter-web/macos/.gitignore deleted file mode 100644 index 746adbb6b9..0000000000 --- a/examples/aws-flutter-web/macos/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Flutter-related -**/Flutter/ephemeral/ -**/Pods/ - -# Xcode-related -**/dgph -**/xcuserdata/ diff --git a/examples/aws-flutter-web/macos/Runner.xcodeproj/project.pbxproj b/examples/aws-flutter-web/macos/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index 1745b1b23b..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,705 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 54; - objects = { - -/* Begin PBXAggregateTarget section */ - 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; - buildPhases = ( - 33CC111E2044C6BF0003C045 /* ShellScript */, - ); - dependencies = ( - ); - name = "Flutter Assemble"; - productName = FLX; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC10EC2044A3C60003C045; - remoteInfo = Runner; - }; - 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC111A2044C6BA0003C045; - remoteInfo = FLX; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 33CC110E2044A8840003C045 /* Bundle Framework */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Bundle Framework"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* aws_flutter_web.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "aws_flutter_web.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; - 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; - 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; - 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 331C80D2294CF70F00263BE5 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10EA2044A3C60003C045 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 331C80D6294CF71000263BE5 /* RunnerTests */ = { - isa = PBXGroup; - children = ( - 331C80D7294CF71000263BE5 /* RunnerTests.swift */, - ); - path = RunnerTests; - sourceTree = ""; - }; - 33BA886A226E78AF003329D5 /* Configs */ = { - isa = PBXGroup; - children = ( - 33E5194F232828860026EE4D /* AppInfo.xcconfig */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, - ); - path = Configs; - sourceTree = ""; - }; - 33CC10E42044A3C60003C045 = { - isa = PBXGroup; - children = ( - 33FAB671232836740065AC1E /* Runner */, - 33CEB47122A05771004F2AC0 /* Flutter */, - 331C80D6294CF71000263BE5 /* RunnerTests */, - 33CC10EE2044A3C60003C045 /* Products */, - D73912EC22F37F3D000D13A0 /* Frameworks */, - ); - sourceTree = ""; - }; - 33CC10EE2044A3C60003C045 /* Products */ = { - isa = PBXGroup; - children = ( - 33CC10ED2044A3C60003C045 /* aws_flutter_web.app */, - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 33CC11242044D66E0003C045 /* Resources */ = { - isa = PBXGroup; - children = ( - 33CC10F22044A3C60003C045 /* Assets.xcassets */, - 33CC10F42044A3C60003C045 /* MainMenu.xib */, - 33CC10F72044A3C60003C045 /* Info.plist */, - ); - name = Resources; - path = ..; - sourceTree = ""; - }; - 33CEB47122A05771004F2AC0 /* Flutter */ = { - isa = PBXGroup; - children = ( - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - ); - path = Flutter; - sourceTree = ""; - }; - 33FAB671232836740065AC1E /* Runner */ = { - isa = PBXGroup; - children = ( - 33CC10F02044A3C60003C045 /* AppDelegate.swift */, - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, - 33E51913231747F40026EE4D /* DebugProfile.entitlements */, - 33E51914231749380026EE4D /* Release.entitlements */, - 33CC11242044D66E0003C045 /* Resources */, - 33BA886A226E78AF003329D5 /* Configs */, - ); - path = Runner; - sourceTree = ""; - }; - D73912EC22F37F3D000D13A0 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 331C80D4294CF70F00263BE5 /* RunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; - buildPhases = ( - 331C80D1294CF70F00263BE5 /* Sources */, - 331C80D2294CF70F00263BE5 /* Frameworks */, - 331C80D3294CF70F00263BE5 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 331C80DA294CF71000263BE5 /* PBXTargetDependency */, - ); - name = RunnerTests; - productName = RunnerTests; - productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 33CC10EC2044A3C60003C045 /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - 33CC10E92044A3C60003C045 /* Sources */, - 33CC10EA2044A3C60003C045 /* Frameworks */, - 33CC10EB2044A3C60003C045 /* Resources */, - 33CC110E2044A8840003C045 /* Bundle Framework */, - 3399D490228B24CF009A79C7 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 33CC11202044C79F0003C045 /* PBXTargetDependency */, - ); - name = Runner; - productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* aws_flutter_web.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 33CC10E52044A3C60003C045 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = YES; - LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1510; - ORGANIZATIONNAME = ""; - TargetAttributes = { - 331C80D4294CF70F00263BE5 = { - CreatedOnToolsVersion = 14.0; - TestTargetID = 33CC10EC2044A3C60003C045; - }; - 33CC10EC2044A3C60003C045 = { - CreatedOnToolsVersion = 9.2; - LastSwiftMigration = 1100; - ProvisioningStyle = Automatic; - SystemCapabilities = { - com.apple.Sandbox = { - enabled = 1; - }; - }; - }; - 33CC111A2044C6BA0003C045 = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Manual; - }; - }; - }; - buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 33CC10E42044A3C60003C045; - productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 33CC10EC2044A3C60003C045 /* Runner */, - 331C80D4294CF70F00263BE5 /* RunnerTests */, - 33CC111A2044C6BA0003C045 /* Flutter Assemble */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 331C80D3294CF70F00263BE5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10EB2044A3C60003C045 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 3399D490228B24CF009A79C7 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; - }; - 33CC111E2044C6BF0003C045 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - Flutter/ephemeral/FlutterInputs.xcfilelist, - ); - inputPaths = ( - Flutter/ephemeral/tripwire, - ); - outputFileListPaths = ( - Flutter/ephemeral/FlutterOutputs.xcfilelist, - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 331C80D1294CF70F00263BE5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10E92044A3C60003C045 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC10EC2044A3C60003C045 /* Runner */; - targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; - }; - 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; - targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 33CC10F52044A3C60003C045 /* Base */, - ); - name = MainMenu.xib; - path = Runner; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 331C80DB294CF71000263BE5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/aws_flutter_web.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/aws_flutter_web"; - }; - name = Debug; - }; - 331C80DC294CF71000263BE5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/aws_flutter_web.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/aws_flutter_web"; - }; - name = Release; - }; - 331C80DD294CF71000263BE5 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/aws_flutter_web.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/aws_flutter_web"; - }; - name = Profile; - }; - 338D0CE9231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Profile; - }; - 338D0CEA231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Profile; - }; - 338D0CEB231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Profile; - }; - 33CC10F92044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 33CC10FA2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; - 33CC10FC2044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 33CC10FD2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; - 33CC111C2044C6BA0003C045 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 33CC111D2044C6BA0003C045 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 331C80DB294CF71000263BE5 /* Debug */, - 331C80DC294CF71000263BE5 /* Release */, - 331C80DD294CF71000263BE5 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10F92044A3C60003C045 /* Debug */, - 33CC10FA2044A3C60003C045 /* Release */, - 338D0CE9231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10FC2044A3C60003C045 /* Debug */, - 33CC10FD2044A3C60003C045 /* Release */, - 338D0CEA231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC111C2044C6BA0003C045 /* Debug */, - 33CC111D2044C6BA0003C045 /* Release */, - 338D0CEB231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 33CC10E52044A3C60003C045 /* Project object */; -} diff --git a/examples/aws-flutter-web/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/aws-flutter-web/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index d57ff0ed0a..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index a2ec33f19f..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "images" : [ - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "app_icon_16.png", - "scale" : "1x" - }, - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "app_icon_32.png", - "scale" : "2x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "app_icon_32.png", - "scale" : "1x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "app_icon_64.png", - "scale" : "2x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "app_icon_128.png", - "scale" : "1x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "app_icon_256.png", - "scale" : "2x" - }, - { - "size" : "256x256", - "idiom" : "mac", - "filename" : "app_icon_256.png", - "scale" : "1x" - }, - { - "size" : "256x256", - "idiom" : "mac", - "filename" : "app_icon_512.png", - "scale" : "2x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "app_icon_512.png", - "scale" : "1x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "app_icon_1024.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png deleted file mode 100644 index 82b6f9d9a3..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png deleted file mode 100644 index 13b35eba55..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png deleted file mode 100644 index 0a3f5fa40f..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png deleted file mode 100644 index bdb57226d5..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png deleted file mode 100644 index f083318e09..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png deleted file mode 100644 index 326c0e72c9..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png deleted file mode 100644 index 2f1632cfdd..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Base.lproj/MainMenu.xib b/examples/aws-flutter-web/macos/Runner/Base.lproj/MainMenu.xib deleted file mode 100644 index 80e867a4e0..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/macos/Runner/Configs/AppInfo.xcconfig b/examples/aws-flutter-web/macos/Runner/Configs/AppInfo.xcconfig deleted file mode 100644 index c979ba0a98..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Configs/AppInfo.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// Application-level settings for the Runner target. -// -// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the -// future. If not, the values below would default to using the project name when this becomes a -// 'flutter create' template. - -// The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = aws_flutter_web - -// The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb - -// The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright Β© 2024 com.example. All rights reserved. diff --git a/examples/aws-flutter-web/macos/Runner/MainFlutterWindow.swift b/examples/aws-flutter-web/macos/Runner/MainFlutterWindow.swift deleted file mode 100644 index 3cc05eb234..0000000000 --- a/examples/aws-flutter-web/macos/Runner/MainFlutterWindow.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Cocoa -import FlutterMacOS - -class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) - - RegisterGeneratedPlugins(registry: flutterViewController) - - super.awakeFromNib() - } -} diff --git a/examples/aws-flutter-web/macos/RunnerTests/RunnerTests.swift b/examples/aws-flutter-web/macos/RunnerTests/RunnerTests.swift deleted file mode 100644 index 61f3bd1fc5..0000000000 --- a/examples/aws-flutter-web/macos/RunnerTests/RunnerTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Cocoa -import FlutterMacOS -import XCTest - -class RunnerTests: XCTestCase { - - func testExample() { - // If you add code to the Runner application, consider adding tests here. - // See https://developer.apple.com/documentation/xctest for more information about using XCTest. - } - -} diff --git a/examples/aws-flutter-web/pubspec.lock b/examples/aws-flutter-web/pubspec.lock deleted file mode 100644 index 5a8354a000..0000000000 --- a/examples/aws-flutter-web/pubspec.lock +++ /dev/null @@ -1,213 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 - url: "https://pub.dev" - source: hosted - version: "1.0.8" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" - url: "https://pub.dev" - source: hosted - version: "3.0.2" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" - url: "https://pub.dev" - source: hosted - version: "10.0.4" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" - url: "https://pub.dev" - source: hosted - version: "3.0.3" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" - url: "https://pub.dev" - source: hosted - version: "3.0.1" - lints: - dependency: transitive - description: - name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 - url: "https://pub.dev" - source: hosted - version: "3.0.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb - url: "https://pub.dev" - source: hosted - version: "0.12.16+1" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" - url: "https://pub.dev" - source: hosted - version: "0.8.0" - meta: - dependency: transitive - description: - name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" - url: "https://pub.dev" - source: hosted - version: "1.12.0" - path: - dependency: transitive - description: - name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" - url: "https://pub.dev" - source: hosted - version: "14.2.1" -sdks: - dart: ">=3.4.1 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" diff --git a/examples/aws-flutter-web/pubspec.yaml b/examples/aws-flutter-web/pubspec.yaml deleted file mode 100644 index b2467bbe68..0000000000 --- a/examples/aws-flutter-web/pubspec.yaml +++ /dev/null @@ -1,90 +0,0 @@ -name: aws_flutter_web -description: "A new Flutter project." -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 - -environment: - sdk: '>=3.4.1 <4.0.0' - -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. -dependencies: - flutter: - sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.6 - -dev_dependencies: - flutter_test: - sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^3.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/examples/aws-flutter-web/sst.config.ts b/examples/aws-flutter-web/sst.config.ts deleted file mode 100644 index 688d10a07c..0000000000 --- a/examples/aws-flutter-web/sst.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -/** - * ## Flutter web - * - * Deploy a Flutter web app as a static site to S3 and CloudFront. - */ -export default $config({ - app(input) { - return { - name: "aws-flutter-web", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.StaticSite("MySite", { - build: { - command: "flutter build web", - output: "build/web", - }, - }); - }, -}); diff --git a/examples/aws-flutter-web/test/widget_test.dart b/examples/aws-flutter-web/test/widget_test.dart deleted file mode 100644 index c538691767..0000000000 --- a/examples/aws-flutter-web/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:aws_flutter_web/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/examples/aws-flutter-web/web/index.html b/examples/aws-flutter-web/web/index.html deleted file mode 100644 index 4ba5cb2465..0000000000 --- a/examples/aws-flutter-web/web/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - aws_flutter_web - - - - - - diff --git a/examples/aws-flutter-web/web/manifest.json b/examples/aws-flutter-web/web/manifest.json deleted file mode 100644 index c27ccaa1dc..0000000000 --- a/examples/aws-flutter-web/web/manifest.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "aws_flutter_web", - "short_name": "aws_flutter_web", - "start_url": ".", - "display": "standalone", - "background_color": "#0175C2", - "theme_color": "#0175C2", - "description": "A new Flutter project.", - "orientation": "portrait-primary", - "prefer_related_applications": false, - "icons": [ - { - "src": "icons/Icon-192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "icons/Icon-512.png", - "sizes": "512x512", - "type": "image/png" - }, - { - "src": "icons/Icon-maskable-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "maskable" - }, - { - "src": "icons/Icon-maskable-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "maskable" - } - ] -} diff --git a/examples/aws-flutter-web/windows/.gitignore b/examples/aws-flutter-web/windows/.gitignore deleted file mode 100644 index d492d0d98c..0000000000 --- a/examples/aws-flutter-web/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ephemeral/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/examples/aws-flutter-web/windows/CMakeLists.txt b/examples/aws-flutter-web/windows/CMakeLists.txt deleted file mode 100644 index d98ad262f1..0000000000 --- a/examples/aws-flutter-web/windows/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.14) -project(aws_flutter_web LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "aws_flutter_web") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(VERSION 3.14...3.25) - -# Define build configuration option. -get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(IS_MULTICONFIG) - set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" - CACHE STRING "" FORCE) -else() - if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") - endif() -endif() -# Define settings for the Profile build mode. -set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") -set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") -set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") - -# Use Unicode for all projects. -add_definitions(-DUNICODE -D_UNICODE) - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_17) - target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") - target_compile_options(${TARGET} PRIVATE /EHsc) - target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") - target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# Application build; see runner/CMakeLists.txt. -add_subdirectory("runner") - - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# Support files are copied into place next to the executable, so that it can -# run in place. This is done instead of making a separate bundle (as on Linux) -# so that building and running from within Visual Studio will work. -set(BUILD_BUNDLE_DIR "$") -# Make the "install" step default, as it's required to run. -set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -if(PLUGIN_BUNDLED_LIBRARIES) - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() - -# Copy the native assets provided by the build.dart from all packages. -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") -install(DIRECTORY "${NATIVE_ASSETS_DIR}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - CONFIGURATIONS Profile;Release - COMPONENT Runtime) diff --git a/examples/aws-flutter-web/windows/flutter/CMakeLists.txt b/examples/aws-flutter-web/windows/flutter/CMakeLists.txt deleted file mode 100644 index 903f4899d6..0000000000 --- a/examples/aws-flutter-web/windows/flutter/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.14) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. -set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") - -# Set fallback configurations for older versions of the flutter tool. -if (NOT DEFINED FLUTTER_TARGET_PLATFORM) - set(FLUTTER_TARGET_PLATFORM "windows-x64") -endif() - -# === Flutter Library === -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "flutter_export.h" - "flutter_windows.h" - "flutter_messenger.h" - "flutter_plugin_registrar.h" - "flutter_texture_registrar.h" -) -list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") -add_dependencies(flutter flutter_assemble) - -# === Wrapper === -list(APPEND CPP_WRAPPER_SOURCES_CORE - "core_implementations.cc" - "standard_codec.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_PLUGIN - "plugin_registrar.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_APP - "flutter_engine.cc" - "flutter_view_controller.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") - -# Wrapper sources needed for a plugin. -add_library(flutter_wrapper_plugin STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} -) -apply_standard_settings(flutter_wrapper_plugin) -set_target_properties(flutter_wrapper_plugin PROPERTIES - POSITION_INDEPENDENT_CODE ON) -set_target_properties(flutter_wrapper_plugin PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) -target_include_directories(flutter_wrapper_plugin PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_plugin flutter_assemble) - -# Wrapper sources needed for the runner. -add_library(flutter_wrapper_app STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_APP} -) -apply_standard_settings(flutter_wrapper_app) -target_link_libraries(flutter_wrapper_app PUBLIC flutter) -target_include_directories(flutter_wrapper_app PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_app flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") -set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} - ${PHONY_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" - ${FLUTTER_TARGET_PLATFORM} $ - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} -) diff --git a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.cc b/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 8b6d4680af..0000000000 --- a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void RegisterPlugins(flutter::PluginRegistry* registry) { -} diff --git a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.h b/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a9..0000000000 --- a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/examples/aws-flutter-web/windows/flutter/generated_plugins.cmake b/examples/aws-flutter-web/windows/flutter/generated_plugins.cmake deleted file mode 100644 index b93c4c30c1..0000000000 --- a/examples/aws-flutter-web/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/examples/aws-flutter-web/windows/runner/CMakeLists.txt b/examples/aws-flutter-web/windows/runner/CMakeLists.txt deleted file mode 100644 index 394917c053..0000000000 --- a/examples/aws-flutter-web/windows/runner/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(runner LANGUAGES CXX) - -# Define the application target. To change its name, change BINARY_NAME in the -# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer -# work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} WIN32 - "flutter_window.cpp" - "main.cpp" - "utils.cpp" - "win32_window.cpp" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" - "Runner.rc" - "runner.exe.manifest" -) - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add preprocessor definitions for the build version. -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") - -# Disable Windows macros that collide with C++ standard library functions. -target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") - -# Add dependency libraries and include directories. Add any application-specific -# dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) -target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") -target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/examples/aws-flutter-web/windows/runner/Runner.rc b/examples/aws-flutter-web/windows/runner/Runner.rc deleted file mode 100644 index 92f602fc3c..0000000000 --- a/examples/aws-flutter-web/windows/runner/Runner.rc +++ /dev/null @@ -1,121 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#pragma code_page(65001) -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_APP_ICON ICON "resources\\app_icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) -#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD -#else -#define VERSION_AS_NUMBER 1,0,0,0 -#endif - -#if defined(FLUTTER_VERSION) -#define VERSION_AS_STRING FLUTTER_VERSION -#else -#define VERSION_AS_STRING "1.0.0" -#endif - -VS_VERSION_INFO VERSIONINFO - FILEVERSION VERSION_AS_NUMBER - PRODUCTVERSION VERSION_AS_NUMBER - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "com.example" "\0" - VALUE "FileDescription", "aws_flutter_web" "\0" - VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "aws_flutter_web" "\0" - VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" - VALUE "OriginalFilename", "aws_flutter_web.exe" "\0" - VALUE "ProductName", "aws_flutter_web" "\0" - VALUE "ProductVersion", VERSION_AS_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/examples/aws-flutter-web/windows/runner/flutter_window.cpp b/examples/aws-flutter-web/windows/runner/flutter_window.cpp deleted file mode 100644 index 955ee3038f..0000000000 --- a/examples/aws-flutter-web/windows/runner/flutter_window.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "flutter_window.h" - -#include - -#include "flutter/generated_plugin_registrant.h" - -FlutterWindow::FlutterWindow(const flutter::DartProject& project) - : project_(project) {} - -FlutterWindow::~FlutterWindow() {} - -bool FlutterWindow::OnCreate() { - if (!Win32Window::OnCreate()) { - return false; - } - - RECT frame = GetClientArea(); - - // The size here must match the window dimensions to avoid unnecessary surface - // creation / destruction in the startup path. - flutter_controller_ = std::make_unique( - frame.right - frame.left, frame.bottom - frame.top, project_); - // Ensure that basic setup of the controller was successful. - if (!flutter_controller_->engine() || !flutter_controller_->view()) { - return false; - } - RegisterPlugins(flutter_controller_->engine()); - SetChildContent(flutter_controller_->view()->GetNativeWindow()); - - flutter_controller_->engine()->SetNextFrameCallback([&]() { - this->Show(); - }); - - // Flutter can complete the first frame before the "show window" callback is - // registered. The following call ensures a frame is pending to ensure the - // window is shown. It is a no-op if the first frame hasn't completed yet. - flutter_controller_->ForceRedraw(); - - return true; -} - -void FlutterWindow::OnDestroy() { - if (flutter_controller_) { - flutter_controller_ = nullptr; - } - - Win32Window::OnDestroy(); -} - -LRESULT -FlutterWindow::MessageHandler(HWND hwnd, UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - // Give Flutter, including plugins, an opportunity to handle window messages. - if (flutter_controller_) { - std::optional result = - flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, - lparam); - if (result) { - return *result; - } - } - - switch (message) { - case WM_FONTCHANGE: - flutter_controller_->engine()->ReloadSystemFonts(); - break; - } - - return Win32Window::MessageHandler(hwnd, message, wparam, lparam); -} diff --git a/examples/aws-flutter-web/windows/runner/flutter_window.h b/examples/aws-flutter-web/windows/runner/flutter_window.h deleted file mode 100644 index 6da0652f05..0000000000 --- a/examples/aws-flutter-web/windows/runner/flutter_window.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef RUNNER_FLUTTER_WINDOW_H_ -#define RUNNER_FLUTTER_WINDOW_H_ - -#include -#include - -#include - -#include "win32_window.h" - -// A window that does nothing but host a Flutter view. -class FlutterWindow : public Win32Window { - public: - // Creates a new FlutterWindow hosting a Flutter view running |project|. - explicit FlutterWindow(const flutter::DartProject& project); - virtual ~FlutterWindow(); - - protected: - // Win32Window: - bool OnCreate() override; - void OnDestroy() override; - LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, - LPARAM const lparam) noexcept override; - - private: - // The project to run. - flutter::DartProject project_; - - // The Flutter instance hosted by this window. - std::unique_ptr flutter_controller_; -}; - -#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/examples/aws-flutter-web/windows/runner/main.cpp b/examples/aws-flutter-web/windows/runner/main.cpp deleted file mode 100644 index 420f00b523..0000000000 --- a/examples/aws-flutter-web/windows/runner/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -#include "flutter_window.h" -#include "utils.h" - -int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, - _In_ wchar_t *command_line, _In_ int show_command) { - // Attach to console when present (e.g., 'flutter run') or create a - // new console when running with a debugger. - if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { - CreateAndAttachConsole(); - } - - // Initialize COM, so that it is available for use in the library and/or - // plugins. - ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); - - flutter::DartProject project(L"data"); - - std::vector command_line_arguments = - GetCommandLineArguments(); - - project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); - - FlutterWindow window(project); - Win32Window::Point origin(10, 10); - Win32Window::Size size(1280, 720); - if (!window.Create(L"aws_flutter_web", origin, size)) { - return EXIT_FAILURE; - } - window.SetQuitOnClose(true); - - ::MSG msg; - while (::GetMessage(&msg, nullptr, 0, 0)) { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - - ::CoUninitialize(); - return EXIT_SUCCESS; -} diff --git a/examples/aws-flutter-web/windows/runner/resource.h b/examples/aws-flutter-web/windows/runner/resource.h deleted file mode 100644 index 66a65d1e4a..0000000000 --- a/examples/aws-flutter-web/windows/runner/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Runner.rc -// -#define IDI_APP_ICON 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/examples/aws-flutter-web/windows/runner/resources/app_icon.ico b/examples/aws-flutter-web/windows/runner/resources/app_icon.ico deleted file mode 100644 index c04e20caf6..0000000000 Binary files a/examples/aws-flutter-web/windows/runner/resources/app_icon.ico and /dev/null differ diff --git a/examples/aws-flutter-web/windows/runner/runner.exe.manifest b/examples/aws-flutter-web/windows/runner/runner.exe.manifest deleted file mode 100644 index a42ea7687c..0000000000 --- a/examples/aws-flutter-web/windows/runner/runner.exe.manifest +++ /dev/null @@ -1,20 +0,0 @@ - - - - - PerMonitorV2 - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/windows/runner/utils.cpp b/examples/aws-flutter-web/windows/runner/utils.cpp deleted file mode 100644 index 3a0b46511a..0000000000 --- a/examples/aws-flutter-web/windows/runner/utils.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "utils.h" - -#include -#include -#include -#include - -#include - -void CreateAndAttachConsole() { - if (::AllocConsole()) { - FILE *unused; - if (freopen_s(&unused, "CONOUT$", "w", stdout)) { - _dup2(_fileno(stdout), 1); - } - if (freopen_s(&unused, "CONOUT$", "w", stderr)) { - _dup2(_fileno(stdout), 2); - } - std::ios::sync_with_stdio(); - FlutterDesktopResyncOutputStreams(); - } -} - -std::vector GetCommandLineArguments() { - // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. - int argc; - wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - if (argv == nullptr) { - return std::vector(); - } - - std::vector command_line_arguments; - - // Skip the first argument as it's the binary name. - for (int i = 1; i < argc; i++) { - command_line_arguments.push_back(Utf8FromUtf16(argv[i])); - } - - ::LocalFree(argv); - - return command_line_arguments; -} - -std::string Utf8FromUtf16(const wchar_t* utf16_string) { - if (utf16_string == nullptr) { - return std::string(); - } - unsigned int target_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr) - -1; // remove the trailing null character - int input_length = (int)wcslen(utf16_string); - std::string utf8_string; - if (target_length == 0 || target_length > utf8_string.max_size()) { - return utf8_string; - } - utf8_string.resize(target_length); - int converted_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - input_length, utf8_string.data(), target_length, nullptr, nullptr); - if (converted_length == 0) { - return std::string(); - } - return utf8_string; -} diff --git a/examples/aws-flutter-web/windows/runner/utils.h b/examples/aws-flutter-web/windows/runner/utils.h deleted file mode 100644 index 3879d54755..0000000000 --- a/examples/aws-flutter-web/windows/runner/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RUNNER_UTILS_H_ -#define RUNNER_UTILS_H_ - -#include -#include - -// Creates a console for the process, and redirects stdout and stderr to -// it for both the runner and the Flutter library. -void CreateAndAttachConsole(); - -// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string -// encoded in UTF-8. Returns an empty std::string on failure. -std::string Utf8FromUtf16(const wchar_t* utf16_string); - -// Gets the command line arguments passed in as a std::vector, -// encoded in UTF-8. Returns an empty std::vector on failure. -std::vector GetCommandLineArguments(); - -#endif // RUNNER_UTILS_H_ diff --git a/examples/aws-flutter-web/windows/runner/win32_window.cpp b/examples/aws-flutter-web/windows/runner/win32_window.cpp deleted file mode 100644 index 60608d0fe5..0000000000 --- a/examples/aws-flutter-web/windows/runner/win32_window.cpp +++ /dev/null @@ -1,288 +0,0 @@ -#include "win32_window.h" - -#include -#include - -#include "resource.h" - -namespace { - -/// Window attribute that enables dark mode window decorations. -/// -/// Redefined in case the developer's machine has a Windows SDK older than -/// version 10.0.22000.0. -/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute -#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 -#endif - -constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; - -/// Registry key for app theme preference. -/// -/// A value of 0 indicates apps should use dark mode. A non-zero or missing -/// value indicates apps should use light mode. -constexpr const wchar_t kGetPreferredBrightnessRegKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; -constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; - -// The number of Win32Window objects that currently exist. -static int g_active_window_count = 0; - -using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); - -// Scale helper to convert logical scaler values to physical using passed in -// scale factor -int Scale(int source, double scale_factor) { - return static_cast(source * scale_factor); -} - -// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. -// This API is only needed for PerMonitor V1 awareness mode. -void EnableFullDpiSupportIfAvailable(HWND hwnd) { - HMODULE user32_module = LoadLibraryA("User32.dll"); - if (!user32_module) { - return; - } - auto enable_non_client_dpi_scaling = - reinterpret_cast( - GetProcAddress(user32_module, "EnableNonClientDpiScaling")); - if (enable_non_client_dpi_scaling != nullptr) { - enable_non_client_dpi_scaling(hwnd); - } - FreeLibrary(user32_module); -} - -} // namespace - -// Manages the Win32Window's window class registration. -class WindowClassRegistrar { - public: - ~WindowClassRegistrar() = default; - - // Returns the singleton registrar instance. - static WindowClassRegistrar* GetInstance() { - if (!instance_) { - instance_ = new WindowClassRegistrar(); - } - return instance_; - } - - // Returns the name of the window class, registering the class if it hasn't - // previously been registered. - const wchar_t* GetWindowClass(); - - // Unregisters the window class. Should only be called if there are no - // instances of the window. - void UnregisterWindowClass(); - - private: - WindowClassRegistrar() = default; - - static WindowClassRegistrar* instance_; - - bool class_registered_ = false; -}; - -WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; - -const wchar_t* WindowClassRegistrar::GetWindowClass() { - if (!class_registered_) { - WNDCLASS window_class{}; - window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); - window_class.lpszClassName = kWindowClassName; - window_class.style = CS_HREDRAW | CS_VREDRAW; - window_class.cbClsExtra = 0; - window_class.cbWndExtra = 0; - window_class.hInstance = GetModuleHandle(nullptr); - window_class.hIcon = - LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); - window_class.hbrBackground = 0; - window_class.lpszMenuName = nullptr; - window_class.lpfnWndProc = Win32Window::WndProc; - RegisterClass(&window_class); - class_registered_ = true; - } - return kWindowClassName; -} - -void WindowClassRegistrar::UnregisterWindowClass() { - UnregisterClass(kWindowClassName, nullptr); - class_registered_ = false; -} - -Win32Window::Win32Window() { - ++g_active_window_count; -} - -Win32Window::~Win32Window() { - --g_active_window_count; - Destroy(); -} - -bool Win32Window::Create(const std::wstring& title, - const Point& origin, - const Size& size) { - Destroy(); - - const wchar_t* window_class = - WindowClassRegistrar::GetInstance()->GetWindowClass(); - - const POINT target_point = {static_cast(origin.x), - static_cast(origin.y)}; - HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); - UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); - double scale_factor = dpi / 96.0; - - HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW, - Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), - Scale(size.width, scale_factor), Scale(size.height, scale_factor), - nullptr, nullptr, GetModuleHandle(nullptr), this); - - if (!window) { - return false; - } - - UpdateTheme(window); - - return OnCreate(); -} - -bool Win32Window::Show() { - return ShowWindow(window_handle_, SW_SHOWNORMAL); -} - -// static -LRESULT CALLBACK Win32Window::WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - if (message == WM_NCCREATE) { - auto window_struct = reinterpret_cast(lparam); - SetWindowLongPtr(window, GWLP_USERDATA, - reinterpret_cast(window_struct->lpCreateParams)); - - auto that = static_cast(window_struct->lpCreateParams); - EnableFullDpiSupportIfAvailable(window); - that->window_handle_ = window; - } else if (Win32Window* that = GetThisFromHandle(window)) { - return that->MessageHandler(window, message, wparam, lparam); - } - - return DefWindowProc(window, message, wparam, lparam); -} - -LRESULT -Win32Window::MessageHandler(HWND hwnd, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - switch (message) { - case WM_DESTROY: - window_handle_ = nullptr; - Destroy(); - if (quit_on_close_) { - PostQuitMessage(0); - } - return 0; - - case WM_DPICHANGED: { - auto newRectSize = reinterpret_cast(lparam); - LONG newWidth = newRectSize->right - newRectSize->left; - LONG newHeight = newRectSize->bottom - newRectSize->top; - - SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, - newHeight, SWP_NOZORDER | SWP_NOACTIVATE); - - return 0; - } - case WM_SIZE: { - RECT rect = GetClientArea(); - if (child_content_ != nullptr) { - // Size and position the child window. - MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, - rect.bottom - rect.top, TRUE); - } - return 0; - } - - case WM_ACTIVATE: - if (child_content_ != nullptr) { - SetFocus(child_content_); - } - return 0; - - case WM_DWMCOLORIZATIONCOLORCHANGED: - UpdateTheme(hwnd); - return 0; - } - - return DefWindowProc(window_handle_, message, wparam, lparam); -} - -void Win32Window::Destroy() { - OnDestroy(); - - if (window_handle_) { - DestroyWindow(window_handle_); - window_handle_ = nullptr; - } - if (g_active_window_count == 0) { - WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); - } -} - -Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { - return reinterpret_cast( - GetWindowLongPtr(window, GWLP_USERDATA)); -} - -void Win32Window::SetChildContent(HWND content) { - child_content_ = content; - SetParent(content, window_handle_); - RECT frame = GetClientArea(); - - MoveWindow(content, frame.left, frame.top, frame.right - frame.left, - frame.bottom - frame.top, true); - - SetFocus(child_content_); -} - -RECT Win32Window::GetClientArea() { - RECT frame; - GetClientRect(window_handle_, &frame); - return frame; -} - -HWND Win32Window::GetHandle() { - return window_handle_; -} - -void Win32Window::SetQuitOnClose(bool quit_on_close) { - quit_on_close_ = quit_on_close; -} - -bool Win32Window::OnCreate() { - // No-op; provided for subclasses. - return true; -} - -void Win32Window::OnDestroy() { - // No-op; provided for subclasses. -} - -void Win32Window::UpdateTheme(HWND const window) { - DWORD light_mode; - DWORD light_mode_size = sizeof(light_mode); - LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, - kGetPreferredBrightnessRegValue, - RRF_RT_REG_DWORD, nullptr, &light_mode, - &light_mode_size); - - if (result == ERROR_SUCCESS) { - BOOL enable_dark_mode = light_mode == 0; - DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, - &enable_dark_mode, sizeof(enable_dark_mode)); - } -} diff --git a/examples/aws-flutter-web/windows/runner/win32_window.h b/examples/aws-flutter-web/windows/runner/win32_window.h deleted file mode 100644 index e901dde684..0000000000 --- a/examples/aws-flutter-web/windows/runner/win32_window.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef RUNNER_WIN32_WINDOW_H_ -#define RUNNER_WIN32_WINDOW_H_ - -#include - -#include -#include -#include - -// A class abstraction for a high DPI-aware Win32 Window. Intended to be -// inherited from by classes that wish to specialize with custom -// rendering and input handling -class Win32Window { - public: - struct Point { - unsigned int x; - unsigned int y; - Point(unsigned int x, unsigned int y) : x(x), y(y) {} - }; - - struct Size { - unsigned int width; - unsigned int height; - Size(unsigned int width, unsigned int height) - : width(width), height(height) {} - }; - - Win32Window(); - virtual ~Win32Window(); - - // Creates a win32 window with |title| that is positioned and sized using - // |origin| and |size|. New windows are created on the default monitor. Window - // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size this function will scale the inputted width and height as - // as appropriate for the default monitor. The window is invisible until - // |Show| is called. Returns true if the window was created successfully. - bool Create(const std::wstring& title, const Point& origin, const Size& size); - - // Show the current window. Returns true if the window was successfully shown. - bool Show(); - - // Release OS resources associated with window. - void Destroy(); - - // Inserts |content| into the window tree. - void SetChildContent(HWND content); - - // Returns the backing Window handle to enable clients to set icon and other - // window properties. Returns nullptr if the window has been destroyed. - HWND GetHandle(); - - // If true, closing this window will quit the application. - void SetQuitOnClose(bool quit_on_close); - - // Return a RECT representing the bounds of the current client area. - RECT GetClientArea(); - - protected: - // Processes and route salient window messages for mouse handling, - // size change and DPI. Delegates handling of these to member overloads that - // inheriting classes can handle. - virtual LRESULT MessageHandler(HWND window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Called when CreateAndShow is called, allowing subclass window-related - // setup. Subclasses should return false if setup fails. - virtual bool OnCreate(); - - // Called when Destroy is called. - virtual void OnDestroy(); - - private: - friend class WindowClassRegistrar; - - // OS callback called by message pump. Handles the WM_NCCREATE message which - // is passed when the non-client area is being created and enables automatic - // non-client DPI scaling so that the non-client area automatically - // responds to changes in DPI. All other messages are handled by - // MessageHandler. - static LRESULT CALLBACK WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Retrieves a class instance pointer for |window| - static Win32Window* GetThisFromHandle(HWND const window) noexcept; - - // Update the window frame's theme to match the system theme. - static void UpdateTheme(HWND const window); - - bool quit_on_close_ = false; - - // window handle for top level window. - HWND window_handle_ = nullptr; - - // window handle for hosted content. - HWND child_content_ = nullptr; -}; - -#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/examples/aws-go-api-gateway-v2/package.json b/examples/aws-go-api-gateway-v2/package.json deleted file mode 100644 index 73e5fb2b94..0000000000 --- a/examples/aws-go-api-gateway-v2/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-go-api-gateway-v2", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "sst": "file:../../sdk/js" - }, - "scripts": { - "dev": "bun sst dev" - } -} \ No newline at end of file diff --git a/examples/aws-go-api-gateway-v2/src/go.mod b/examples/aws-go-api-gateway-v2/src/go.mod deleted file mode 100644 index 518c0cb85f..0000000000 --- a/examples/aws-go-api-gateway-v2/src/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module sst-go-api - -go 1.23.3 - -require ( - github.com/aws/aws-lambda-go v1.47.0 // indirect - github.com/awslabs/aws-lambda-go-api-proxy v0.16.2 // indirect -) diff --git a/examples/aws-go-api-gateway-v2/src/go.sum b/examples/aws-go-api-gateway-v2/src/go.sum deleted file mode 100644 index 778c713c31..0000000000 --- a/examples/aws-go-api-gateway-v2/src/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/awslabs/aws-lambda-go-api-proxy v0.16.2 h1:CJyGEyO1CIwOnXTU40urf0mchf6t3voxpvUDikOU9LY= -github.com/awslabs/aws-lambda-go-api-proxy v0.16.2/go.mod h1:vxxjwBHe/KbgFeNlAP/Tvp4SsVRL3WQamcWRxqVh0z0= diff --git a/examples/aws-go-api-gateway-v2/src/main.go b/examples/aws-go-api-gateway-v2/src/main.go deleted file mode 100644 index 4ec3d6b278..0000000000 --- a/examples/aws-go-api-gateway-v2/src/main.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - - "github.com/aws/aws-lambda-go/lambda" - "github.com/awslabs/aws-lambda-go-api-proxy/httpadapter" -) - -func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { - encoder := json.NewEncoder(w) - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(code) - encoder.Encode(payload) - -} - -func router() *http.ServeMux { - mux := http.NewServeMux() - - mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusOK, map[string]string{"message": "hello world"}) - return - }) - mux.HandleFunc("/my-ping", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusOK, map[string]string{"message": "pong"}) - return - }) - - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusNotFound, map[string]string{"message": "not found"}) - return - }) - mux.HandleFunc("/{$}", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusOK, map[string]string{"message": "home page"}) - }) - - return mux -} - -func main() { - - lambda.Start(httpadapter.NewV2(router()).ProxyWithContext) - -} diff --git a/examples/aws-go-api-gateway-v2/sst.config.ts b/examples/aws-go-api-gateway-v2/sst.config.ts deleted file mode 100644 index 4eb7a35105..0000000000 --- a/examples/aws-go-api-gateway-v2/sst.config.ts +++ /dev/null @@ -1,54 +0,0 @@ -/// - -/** - * ## AWS ApiGatewayV2 Go - * - * Uses [aws-lambda-go-api-proxy](https://github.com/awslabs/aws-lambda-go-api-proxy/tree/master) to allow you to run a Go API with API Gateway V2. - * - * :::tip - * We use the `aws-lambda-go-api-proxy` package to handle the API Gateway V2 event. - * ::: - * - * So you write your Go function as you normally would and then use the package to handle the API Gateway V2 event. - * - * ```go title="main.go" - * import ( - * "github.com/aws/aws-lambda-go/lambda" - * "github.com/awslabs/aws-lambda-go-api-proxy/httpadapter" - * ) - * - * func router() *http.ServeMux { - * mux := http.NewServeMux() - * - * mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - * w.Header().Set("Content-Type", "application/json") - * w.WriteHeader(http.StatusOK) - * w.Write([]byte(`{"message": "hello world"}`)) - * }) - * - * return mux - * } - * - * func main() { - * lambda.Start(httpadapter.NewV2(router()).ProxyWithContext) - * } - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-go-api-gateway-v2", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV2("GoApi"); - - api.route("$default", { - handler: "src/", - runtime: "go", - }); - }, -}); diff --git a/examples/aws-go-api-gateway-v2/tsconfig.json b/examples/aws-go-api-gateway-v2/tsconfig.json deleted file mode 100644 index fd521c7b05..0000000000 --- a/examples/aws-go-api-gateway-v2/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-go-lambda-bucket-presigned-url/package.json b/examples/aws-go-lambda-bucket-presigned-url/package.json deleted file mode 100644 index 4c65464398..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-go-lambda-bucket-presigned-url", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-go-lambda-bucket-presigned-url/src/go.mod b/examples/aws-go-lambda-bucket-presigned-url/src/go.mod deleted file mode 100644 index 6325fc595d..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/src/go.mod +++ /dev/null @@ -1,31 +0,0 @@ -module sst-go-file-upload - -go 1.23.3 - -require ( - github.com/aws/aws-lambda-go v1.47.0 - github.com/aws/aws-sdk-go v1.44.298 - github.com/aws/aws-sdk-go-v2/config v1.28.7 - github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1 - github.com/google/uuid v1.6.0 - github.com/sst/sst/v3 v3.4.27 -) - -require ( - github.com/aws/aws-sdk-go-v2 v1.32.7 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.48 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect - github.com/aws/smithy-go v1.22.1 // indirect -) diff --git a/examples/aws-go-lambda-bucket-presigned-url/src/go.sum b/examples/aws-go-lambda-bucket-presigned-url/src/go.sum deleted file mode 100644 index 8d659a9d1d..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/src/go.sum +++ /dev/null @@ -1,87 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/aws/aws-sdk-go v1.44.298 h1:5qTxdubgV7PptZJmp/2qDwD2JL187ePL7VOxsSh1i3g= -github.com/aws/aws-sdk-go v1.44.298/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw= -github.com/aws/aws-sdk-go-v2 v1.32.7/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc= -github.com/aws/aws-sdk-go-v2/config v1.28.7 h1:GduUnoTXlhkgnxTD93g1nv4tVPILbdNQOzav+Wpg7AE= -github.com/aws/aws-sdk-go-v2/config v1.28.7/go.mod h1:vZGX6GVkIE8uECSUHB6MWAUsd4ZcG2Yq/dMa4refR3M= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48 h1:IYdLD1qTJ0zanRavulofmqut4afs45mOWEI+MzZtTfQ= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48/go.mod h1:tOscxHN3CGmuX9idQ3+qbkzrjVIx32lqDSU1/0d/qXs= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 h1:kqOrpojG71DxJm/KDPO+Z/y1phm1JlC8/iT+5XRmAn8= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22/go.mod h1:NtSFajXVVL8TA2QNngagVZmUtXciyrHOt7xgz4faS/M= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26/go.mod h1:3o2Wpy0bogG1kyOPrgkXA8pgIfEEv0+m19O9D5+W8y8= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 h1:GeNJsIFHB+WW5ap2Tec4K6dzcVTsRbsT1Lra46Hv9ME= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26/go.mod h1:zfgMpwHDXX2WGoG84xG2H+ZlPTkJUU4YUvx2svLQYWo= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 h1:tB4tNw83KcajNAzaIMhkhVI2Nt8fAZd5A5ro113FEMY= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7/go.mod h1:lvpyBGkZ3tZ9iSsUIcC2EWp+0ywa7aK3BLT+FwZi+mQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 h1:8eUsivBQzZHqe/3FE+cqwfH+0p5Jo8PFM/QYQSmeZ+M= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7/go.mod h1:kLPQvGUmxn/fqiCrDeohwG33bq2pQpGeY62yRO6Nrh0= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEHWM0bJ1QcBzxLrL/k2DHvGYhb8+W1w= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c= -github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1 h1:aOVVZJgWbaH+EJYPvEgkNhCEbXXvH7+oML36oaPK3zE= -github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1/go.mod h1:r+xl5yzMk9083rMR+sJ5TYj9Tihvf/l1oxzZXDgGj2Q= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 h1:CvuUmnXI7ebaUAhbJcDy9YQx8wHR69eZ9I7q5hszt/g= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8/go.mod h1:XDeGv1opzwm8ubxddF0cgqkZWsyOtw4lr6dxwmb6YQg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 h1:F2rBfNAL5UyswqoeWv9zs74N/NanhK16ydHW1pahX6E= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7/go.mod h1:JfyQ0g2JG8+Krq0EuZNnRwX0mU0HrwY/tG6JNfcqh4k= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 h1:Xgv/hyNgvLda/M9l9qxXc4UFSgppnRczLxlMs5Ae/QY= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3/go.mod h1:5Gn+d+VaaRgsjewpMvGazt0WfcFO+Md4wLOuBfGR9Bc= -github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= -github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sst/sst/v3 v3.4.27 h1:LRPqw1HRhLZQ8EoL8rXacOkavZlf1k/Am8CZ0uEdMXg= -github.com/sst/sst/v3 v3.4.27/go.mod h1:rxQ4Pi7xaYAbyfLt0rFREzQDLE72clWKxudGKG9Xpt4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/aws-go-lambda-bucket-presigned-url/src/main.go b/examples/aws-go-lambda-bucket-presigned-url/src/main.go deleted file mode 100644 index 2604490c67..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/src/main.go +++ /dev/null @@ -1,98 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "os" - "time" - - "github.com/aws/aws-lambda-go/events" - "github.com/aws/aws-lambda-go/lambda" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/aws/aws-sdk-go/aws" - "github.com/google/uuid" - "github.com/sst/sst/v3/sdk/golang/resource" -) - -type App struct { - client *s3.Client - presignedClient *s3.PresignClient - bucketName string -} - -func NewApp() *App { - cfg, err := config.LoadDefaultConfig(context.Background(), func(opts *config.LoadOptions) error { - opts.Region = os.Getenv("AWS_REGION") - return nil - }) - if err != nil { - panic(err) - } - client := s3.NewFromConfig(cfg) - presignedClient := s3.NewPresignClient(client) - - bucketName, err := resource.Get("Bucket", "name") - if err != nil { - panic(err) - } - - return &App{ - client: client, - presignedClient: presignedClient, - bucketName: bucketName.(string), - } -} - -func (app *App) handler(ctx context.Context, r events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) { - - filename := r.QueryStringParameters["filename"] - filetype := r.QueryStringParameters["filetype"] - - id := uuid.New() - key := fmt.Sprintf("%s-%s", id, filename) - - url, err := app.presignedClient.PresignPutObject(context.Background(), &s3.PutObjectInput{ - Bucket: aws.String(app.bucketName), - Key: aws.String(key), - ContentType: aws.String(filetype), - }, func(opts *s3.PresignOptions) { - opts.Expires = 600 * time.Second // 10 minutes - }) - - if err != nil { - return apiErrorResponse(http.StatusInternalServerError, "Internal Server Error"), nil - } - - var response struct { - URL string `json:"url"` - } - response.URL = url.URL - body, err := json.Marshal(response) - if err != nil { - return apiErrorResponse(http.StatusInternalServerError, "Internal Server Error"), nil - } - - return events.APIGatewayV2HTTPResponse{ - StatusCode: http.StatusOK, - Headers: map[string]string{"Content-Type": "application/json"}, - Body: string(body), - }, nil - -} - -func main() { - app := NewApp() - lambda.Start(app.handler) -} - -func apiErrorResponse(statusCode int, message string) events.APIGatewayV2HTTPResponse { - body, _ := json.Marshal(map[string]string{"message": message}) - return events.APIGatewayV2HTTPResponse{ - StatusCode: statusCode, - Headers: map[string]string{"Content-Type": "application/json"}, - Body: string(body), - } -} diff --git a/examples/aws-go-lambda-bucket-presigned-url/sst.config.ts b/examples/aws-go-lambda-bucket-presigned-url/sst.config.ts deleted file mode 100644 index 0ad00c8fdb..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/sst.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -/** - * ## AWS Lambda Go S3 Presigned - * - * Generates a presigned URL for the linked S3 bucket in a Go Lambda function. - * - * Configure the S3 Client and the PresignedClient. - * - * ```go title="main.go" - * cfg, err := config.LoadDefaultConfig(context.TODO()) - * if err != nil { - * panic(err) - * } - * - * client := s3.NewFromConfig(cfg) - * presignedClient := s3.NewPresignClient(client) - * ``` - * - * Generate the presigned URL. - * - * ```go title="main.go" - * bucketName, err := resource.Get("Bucket", "name") - * if err != nil { - * panic(err) - * } - * url, err := presignedClient.PresignPutObject(context.TODO(), &s3.PutObjectInput{ - * Bucket: aws.String(bucket.(string)), - * Key: aws.String(key), - * }) - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-go-lambda-bucket-presigned-url", - removal: "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("Bucket"); - - const api = new sst.aws.ApiGatewayV2("Api"); - - api.route("GET /upload-url", { - handler: "src/", - runtime: "go", - link: [bucket], - }); - }, -}); diff --git a/examples/aws-go-lambda-bucket-presigned-url/tsconfig.json b/examples/aws-go-lambda-bucket-presigned-url/tsconfig.json deleted file mode 100644 index df2b488923..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags - "noUnusedLocals": true, - "noUnusedParameters": true, - "noPropertyAccessFromIndexSignature": true - } -} diff --git a/examples/aws-go-lambda-dynamo/package.json b/examples/aws-go-lambda-dynamo/package.json deleted file mode 100644 index d230289740..0000000000 --- a/examples/aws-go-lambda-dynamo/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-go-lambda-dynamo", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "sst": "file:../../sdk/js" - }, - "scripts": { - "dev": "bun sst dev" - } -} diff --git a/examples/aws-go-lambda-dynamo/src/go.mod b/examples/aws-go-lambda-dynamo/src/go.mod deleted file mode 100644 index 9cde0324f9..0000000000 --- a/examples/aws-go-lambda-dynamo/src/go.mod +++ /dev/null @@ -1,28 +0,0 @@ -module sst-go-lambda-dynamo - -go 1.23.3 - -require ( - github.com/aws/aws-lambda-go v1.47.0 // indirect - github.com/aws/aws-sdk-go-v2 v1.32.7 // indirect - github.com/aws/aws-sdk-go-v2/config v1.28.7 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.48 // indirect - github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.22 // indirect - github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.57 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1 // indirect - github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.24.10 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect - github.com/aws/smithy-go v1.22.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/sst/sst/v3 v3.4.27 // indirect -) diff --git a/examples/aws-go-lambda-dynamo/src/go.sum b/examples/aws-go-lambda-dynamo/src/go.sum deleted file mode 100644 index 81468832e1..0000000000 --- a/examples/aws-go-lambda-dynamo/src/go.sum +++ /dev/null @@ -1,50 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw= -github.com/aws/aws-sdk-go-v2 v1.32.7/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= -github.com/aws/aws-sdk-go-v2/config v1.28.7 h1:GduUnoTXlhkgnxTD93g1nv4tVPILbdNQOzav+Wpg7AE= -github.com/aws/aws-sdk-go-v2/config v1.28.7/go.mod h1:vZGX6GVkIE8uECSUHB6MWAUsd4ZcG2Yq/dMa4refR3M= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48 h1:IYdLD1qTJ0zanRavulofmqut4afs45mOWEI+MzZtTfQ= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48/go.mod h1:tOscxHN3CGmuX9idQ3+qbkzrjVIx32lqDSU1/0d/qXs= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.22 h1:p2LDiYhvM9mMExEY1meHMAmjmVlzD1J1jVG+fGut+mE= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.22/go.mod h1:fo5T2fYMHVF2rHrym50h7Ue/+SECRJlUHUFZLjSX18g= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.57 h1:5Pkmgr/HIgteZAXGHln1Y1X7wpI9+fyLe7T88utRRPk= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.57/go.mod h1:bCsUt9VsF1M4bb3ZKnpq88rvvq/XxtBJSt6/QUZzIKU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 h1:kqOrpojG71DxJm/KDPO+Z/y1phm1JlC8/iT+5XRmAn8= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22/go.mod h1:NtSFajXVVL8TA2QNngagVZmUtXciyrHOt7xgz4faS/M= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26/go.mod h1:3o2Wpy0bogG1kyOPrgkXA8pgIfEEv0+m19O9D5+W8y8= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1 h1:AnSNs7Ogi0LXHPMDBx4RE7imU4/JmzWFziqkMKJA2AY= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1/go.mod h1:J8xqRbx7HIc8ids2P8JbrKx9irONPEYq7Z1FpLDpi3I= -github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.24.10 h1:aWEbNPNdGiTGSR6/Yy9S0Ad07sMVaT/CFaVq7GuDGx4= -github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.24.10/go.mod h1:HywkMgYwY0uaybPvvctx6fkm3L1ssRKeGv7TPZ6OQ/M= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.7 h1:EqGlayejoCRXmnVC6lXl6phCm9R2+k35e0gWsO9G5DI= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.7/go.mod h1:BTw+t+/E5F3ZnDai/wSOYM54WUVjSdewE7Jvwtb7o+w= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 h1:8eUsivBQzZHqe/3FE+cqwfH+0p5Jo8PFM/QYQSmeZ+M= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7/go.mod h1:kLPQvGUmxn/fqiCrDeohwG33bq2pQpGeY62yRO6Nrh0= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 h1:CvuUmnXI7ebaUAhbJcDy9YQx8wHR69eZ9I7q5hszt/g= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8/go.mod h1:XDeGv1opzwm8ubxddF0cgqkZWsyOtw4lr6dxwmb6YQg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 h1:F2rBfNAL5UyswqoeWv9zs74N/NanhK16ydHW1pahX6E= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7/go.mod h1:JfyQ0g2JG8+Krq0EuZNnRwX0mU0HrwY/tG6JNfcqh4k= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 h1:Xgv/hyNgvLda/M9l9qxXc4UFSgppnRczLxlMs5Ae/QY= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3/go.mod h1:5Gn+d+VaaRgsjewpMvGazt0WfcFO+Md4wLOuBfGR9Bc= -github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= -github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sst/sst/v3 v3.4.27 h1:LRPqw1HRhLZQ8EoL8rXacOkavZlf1k/Am8CZ0uEdMXg= -github.com/sst/sst/v3 v3.4.27/go.mod h1:rxQ4Pi7xaYAbyfLt0rFREzQDLE72clWKxudGKG9Xpt4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/examples/aws-go-lambda-dynamo/src/handlers/handlers.go b/examples/aws-go-lambda-dynamo/src/handlers/handlers.go deleted file mode 100644 index 9a5f742d8d..0000000000 --- a/examples/aws-go-lambda-dynamo/src/handlers/handlers.go +++ /dev/null @@ -1,118 +0,0 @@ -package handlers - -import ( - "context" - "encoding/json" - "net/http" - "sst-go-lambda-dynamo/models" - "sst-go-lambda-dynamo/repository" - - "github.com/aws/aws-lambda-go/events" -) - -type Handlers struct { - userRepo repository.UserRepository -} - -func NewHandlers(userRepo repository.UserRepository) *Handlers { - return &Handlers{userRepo: userRepo} -} - -func (h *Handlers) GetUser(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - - queryString := r.QueryStringParameters - if queryString == nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusBadRequest, - Body: `{"message": "Missing query string"}`, - }, nil - } - - id := queryString["id"] - - user, err := h.userRepo.GetUser(ctx, id) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusNotFound, - Body: `{"message": "User not found"}`, - }, nil - } - - userJSON, err := json.Marshal(user) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusInternalServerError, - Body: `{"message": "Failed to marshal user"}`, - }, err - } - - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusOK, - Body: string(userJSON), - }, nil -} - -type PostUserRequestData struct { - Name string `json:"name"` - Email string `json:"email"` -} - -func (h *Handlers) CreateUser(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - - var data PostUserRequestData - if err := json.Unmarshal([]byte(r.Body), &data); err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: 400, - Body: `{"message": "Invalid request body"}`, - }, err - } - - user, err := h.userRepo.CreateUser(ctx, models.UserCreate{ - Name: data.Name, - Email: data.Email, - }) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: 500, - Body: `{"message": "Failed to create user"}`, - }, err - } - - userJSON, err := json.Marshal(user) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: 500, - Body: `{"message": "Failed to marshal user"}`, - }, err - } - - return events.LambdaFunctionURLResponse{ - StatusCode: 201, - Body: string(userJSON), - }, nil -} - -func (h *Handlers) DeleteUser(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - - queryString := r.QueryStringParameters - if queryString == nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusBadRequest, - Body: `{"message": "Missing query string"}`, - }, nil - } - - id := queryString["id"] - - if err := h.userRepo.DeleteUser(ctx, id); err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusInternalServerError, - Body: `{"message": "Failed to delete user"}`, - }, err - } - - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusOK, - Body: `{"message": "User deleted"}`, - }, nil -} diff --git a/examples/aws-go-lambda-dynamo/src/main.go b/examples/aws-go-lambda-dynamo/src/main.go deleted file mode 100644 index 59d8e6270d..0000000000 --- a/examples/aws-go-lambda-dynamo/src/main.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "context" - "net/http" - "os" - "sst-go-lambda-dynamo/handlers" - "sst-go-lambda-dynamo/repository" - - "github.com/aws/aws-lambda-go/events" - "github.com/aws/aws-lambda-go/lambda" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" - "github.com/sst/sst/v3/sdk/golang/resource" -) - -type App struct { - handlers *handlers.Handlers -} - -func NewApp() *App { - cfg, err := config.LoadDefaultConfig(context.Background(), func(opts *config.LoadOptions) error { - // example of setting region from environment variable - opts.Region = os.Getenv("AWS_REGION") - return nil - }) - if err != nil { - panic(err) - } - client := dynamodb.NewFromConfig(cfg) - - tableName, err := resource.Get("Table", "name") - if err != nil { - panic(err) - } - - userRepo := repository.NewDynamoDBRepository(client, tableName.(string)) - handlers := handlers.NewHandlers(userRepo) - - return &App{handlers: handlers} -} - -func (app *App) handler(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - switch r.RequestContext.HTTP.Method { - case http.MethodGet: - return app.handlers.GetUser(ctx, r) - case http.MethodPost: - return app.handlers.CreateUser(ctx, r) - case http.MethodDelete: - return app.handlers.DeleteUser(ctx, r) - default: - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusMethodNotAllowed, - Headers: map[string]string{"Content-Type": "application/json"}, - Body: `{"message": "Method Not Allowed"}`, - }, nil - } -} - -func main() { - app := NewApp() - lambda.Start(app.handler) -} diff --git a/examples/aws-go-lambda-dynamo/src/models/user.go b/examples/aws-go-lambda-dynamo/src/models/user.go deleted file mode 100644 index addac21e76..0000000000 --- a/examples/aws-go-lambda-dynamo/src/models/user.go +++ /dev/null @@ -1,18 +0,0 @@ -package models - -import ( - "time" -) - -type User struct { - ID string `json:"id" dynamodbav:"id"` - Name string `json:"name" dynamodbav:"name"` - Email string `json:"email" dynamodbav:"email"` - CreatedAt time.Time `json:"created_at" dynamodbav:"created_at"` - UpdatedAt time.Time `json:"updated_at" dynamodbav:"updated_at"` -} - -type UserCreate struct { - Name string - Email string -} diff --git a/examples/aws-go-lambda-dynamo/src/repository/dynamodb.go b/examples/aws-go-lambda-dynamo/src/repository/dynamodb.go deleted file mode 100644 index 062b0b7135..0000000000 --- a/examples/aws-go-lambda-dynamo/src/repository/dynamodb.go +++ /dev/null @@ -1,126 +0,0 @@ -package repository - -import ( - "context" - "fmt" - "sst-go-lambda-dynamo/models" - "time" - - "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" - "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "github.com/google/uuid" -) - -type DynamoUser struct { - models.User - PK string `dynamodbav:"PK"` - SK string `dynamodbav:"SK"` - TYPE string `dynamodbav:"TYPE"` -} - -func getKey(id string) (map[string]types.AttributeValue, error) { - return attributevalue.MarshalMap(map[string]string{ - "PK": "USER#" + id, - "SK": "USER#" + id, - }) -} - -func formatTo(u models.User) DynamoUser { - return DynamoUser{ - User: u, - PK: "USER#" + u.ID, - SK: "USER#" + u.ID, - TYPE: "USER", - } -} - -func formatFrom(item map[string]types.AttributeValue) (models.User, error) { - var user models.User - err := attributevalue.UnmarshalMap(item, &user) - return user, err -} - -type DynamoDBRepository struct { - client *dynamodb.Client - tableName string -} - -func NewDynamoDBRepository(client *dynamodb.Client, tableName string) UserRepository { - return &DynamoDBRepository{ - client: client, - tableName: tableName, - } -} - -func (r *DynamoDBRepository) GetUser(ctx context.Context, id string) (*models.User, error) { - key, err := getKey(id) - if err != nil { - return nil, fmt.Errorf("failed to get key: %w", err) - } - output, err := r.client.GetItem(ctx, &dynamodb.GetItemInput{ - TableName: &r.tableName, - Key: key, - }) - if err != nil { - return nil, fmt.Errorf("failed to get user: %w", err) - } - - if output.Item == nil { - return nil, fmt.Errorf("user not found") - } - - user, err := formatFrom(output.Item) - if err != nil { - return nil, fmt.Errorf("failed to format user: %w", err) - } - - return &user, nil -} - -func (r *DynamoDBRepository) CreateUser(ctx context.Context, user models.UserCreate) (*models.User, error) { - - id, err := uuid.NewV7() - if err != nil { - return nil, fmt.Errorf("failed to generate id: %w", err) - } - now := time.Now() - newUser := models.User{ - ID: id.String(), - Name: user.Name, - Email: user.Email, - CreatedAt: now, - UpdatedAt: now, - } - - dynamoUser := formatTo(newUser) - item, err := attributevalue.MarshalMap(dynamoUser) - if err != nil { - return nil, fmt.Errorf("failed to marshal user: %w", err) - } - _, err = r.client.PutItem(ctx, &dynamodb.PutItemInput{ - TableName: &r.tableName, - Item: item, - }) - if err != nil { - return nil, fmt.Errorf("failed to put user: %w", err) - } - - return &newUser, nil -} - -func (r *DynamoDBRepository) DeleteUser(ctx context.Context, id string) error { - key, err := getKey(id) - if err != nil { - return fmt.Errorf("failed to get key: %w", err) - } - - _, err = r.client.DeleteItem(ctx, &dynamodb.DeleteItemInput{ - TableName: &r.tableName, - Key: key, - }) - if err != nil { - return fmt.Errorf("failed to delete user: %w", err) - } - return nil -} diff --git a/examples/aws-go-lambda-dynamo/src/repository/repository.go b/examples/aws-go-lambda-dynamo/src/repository/repository.go deleted file mode 100644 index 5c6ee70503..0000000000 --- a/examples/aws-go-lambda-dynamo/src/repository/repository.go +++ /dev/null @@ -1,12 +0,0 @@ -package repository - -import ( - "context" - "sst-go-lambda-dynamo/models" -) - -type UserRepository interface { - GetUser(ctx context.Context, id string) (*models.User, error) - CreateUser(ctx context.Context, user models.UserCreate) (*models.User, error) - DeleteUser(ctx context.Context, id string) error -} diff --git a/examples/aws-go-lambda-dynamo/sst.config.ts b/examples/aws-go-lambda-dynamo/sst.config.ts deleted file mode 100644 index d1c97887bc..0000000000 --- a/examples/aws-go-lambda-dynamo/sst.config.ts +++ /dev/null @@ -1,69 +0,0 @@ -/// - -/** - * ## AWS Lambda Go DynamoDB - * - * An example on how to use a Go runtime Lambda with DynamoDB. - * - * You configure the DynamoDB client. - * - * ```go title="src/main.go" - * import ( - * "github.com/sst/sst/v3/sdk/golang/resource" - * ) - * - * func main() { - * cfg, err := config.LoadDefaultConfig(context.Background()) - * if err != nil { - * panic(err) - * } - * client := dynamodb.NewFromConfig(cfg) - * - * - * tableName, err := resource.Get("Table", "name") - * if err != nil { - * panic(err) - * } - * } - * ``` - * - * And make a request to DynamoDB. - * - * ```go title="src/main.go" - * _, err = r.client.PutItem(ctx, &dynamodb.PutItemInput{ - * TableName: tableName.(string), - * Item: item, - * }) - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-go-lambda-dynamo", - removal: "remove", - home: "aws", - providers: { - aws: { - region: "us-east-2", - }, - }, - }; - }, - async run() { - const table = new sst.aws.Dynamo("Table", { - fields: { - PK: "string", - SK: "string", - }, - primaryIndex: { hashKey: "PK", rangeKey: "SK" }, - }); - - new sst.aws.Function("GoFunction", { - url: true, - runtime: "go", - handler: "./src", - link: [table], - }); - }, -}); diff --git a/examples/aws-go-lambda-dynamo/tsconfig.json b/examples/aws-go-lambda-dynamo/tsconfig.json deleted file mode 100644 index fdc4236bd1..0000000000 --- a/examples/aws-go-lambda-dynamo/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - //Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, - "noImplicitOverride": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-hono-container/.dockerignore b/examples/aws-hono-container/.dockerignore deleted file mode 100644 index 5eae331bf4..0000000000 --- a/examples/aws-hono-container/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -.git - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-hono-container/.gitignore b/examples/aws-hono-container/.gitignore deleted file mode 100644 index 349b782160..0000000000 --- a/examples/aws-hono-container/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ - -# env -.env -.env.production - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# misc -.DS_Store - -# sst -.sst diff --git a/examples/aws-hono-container/Dockerfile b/examples/aws-hono-container/Dockerfile deleted file mode 100644 index 84684fd82a..0000000000 --- a/examples/aws-hono-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts-alpine AS base - -FROM base AS builder -RUN apk add --no-cache gcompat -WORKDIR /app -COPY package*json tsconfig.json src ./ -# Copy over generated types -COPY sst-env.d.ts* ./ -RUN npm ci && \ - npm run build && \ - npm prune --production - -FROM base AS runner -WORKDIR /app -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 hono -COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules -COPY --from=builder --chown=hono:nodejs /app/dist /app/dist -COPY --from=builder --chown=hono:nodejs /app/package.json /app/package.json - -USER hono -EXPOSE 3000 -CMD ["node", "/app/dist/index.js"] diff --git a/examples/aws-hono-container/package.json b/examples/aws-hono-container/package.json deleted file mode 100644 index 565f26f302..0000000000 --- a/examples/aws-hono-container/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-hono-container", - "type": "module", - "scripts": { - "dev": "tsx watch src/index.ts", - "build": "tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/lib-storage": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "@hono/node-server": "^1.13.7", - "hono": "^4.6.12", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/node": "^20.11.17", - "tsx": "^4.7.1", - "typescript": "^5.7.2" - } -} diff --git a/examples/aws-hono-container/src/index.ts b/examples/aws-hono-container/src/index.ts deleted file mode 100644 index 30af78b446..0000000000 --- a/examples/aws-hono-container/src/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { serve } from '@hono/node-server' -import { Hono } from 'hono' -import { Resource } from 'sst' -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3' -import { Upload } from '@aws-sdk/lib-storage' -import { getSignedUrl } from '@aws-sdk/s3-request-presigner' - -const s3 = new S3Client(); - -const app = new Hono() - -app.get('/', (c) => { - return c.text('Hello Hono!') -}) - -app.post('/', async (c) => { - const body = await c.req.parseBody(); - const file = body['file'] as File; - - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return c.text('File uploaded successfully.'); -}); - -app.get('/latest', async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return c.redirect(await getSignedUrl(s3, command)); -}); - -const port = 3000 -console.log(`Server is running on http://localhost:${port}`) - -serve({ - fetch: app.fetch, - port -}) diff --git a/examples/aws-hono-container/sst.config.ts b/examples/aws-hono-container/sst.config.ts deleted file mode 100644 index 67b166954e..0000000000 --- a/examples/aws-hono-container/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-hono-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-hono-container/tsconfig.json b/examples/aws-hono-container/tsconfig.json deleted file mode 100644 index b55223e0d5..0000000000 --- a/examples/aws-hono-container/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "NodeNext", - "strict": true, - "verbatimModuleSyntax": true, - "skipLibCheck": true, - "types": [ - "node" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - "outDir": "./dist" - }, - "exclude": ["node_modules"] -} diff --git a/examples/aws-hono-redis/.dockerignore b/examples/aws-hono-redis/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-hono-redis/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-hono-redis/.gitignore b/examples/aws-hono-redis/.gitignore deleted file mode 100644 index 349b782160..0000000000 --- a/examples/aws-hono-redis/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ - -# env -.env -.env.production - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# misc -.DS_Store - -# sst -.sst diff --git a/examples/aws-hono-redis/Dockerfile b/examples/aws-hono-redis/Dockerfile deleted file mode 100644 index e63bc0b843..0000000000 --- a/examples/aws-hono-redis/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM node:20-alpine AS base - -FROM base AS builder - -RUN apk add --no-cache gcompat -WORKDIR /app - -COPY package*json tsconfig.json src ./ - -# Copy over generated types -COPY sst-env.d.ts* ./ - -RUN npm ci && \ - npm run build && \ - npm prune --production - -FROM base AS runner -WORKDIR /app - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 hono - -COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules -COPY --from=builder --chown=hono:nodejs /app/dist /app/dist -COPY --from=builder --chown=hono:nodejs /app/package.json /app/package.json - -USER hono -EXPOSE 3000 - -CMD ["node", "/app/dist/index.js"] diff --git a/examples/aws-hono-redis/package.json b/examples/aws-hono-redis/package.json deleted file mode 100644 index 7048149d5a..0000000000 --- a/examples/aws-hono-redis/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-hono-redis", - "type": "module", - "scripts": { - "build": "tsc", - "dev": "tsx watch src/index.ts" - }, - "dependencies": { - "@hono/node-server": "^1.13.2", - "hono": "^4.6.5", - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/node": "^20.11.17", - "tsx": "^4.7.1", - "typescript": "^5.6.3" - } -} diff --git a/examples/aws-hono-redis/src/index.ts b/examples/aws-hono-redis/src/index.ts deleted file mode 100644 index eb89ae5adc..0000000000 --- a/examples/aws-hono-redis/src/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Hono } from "hono"; -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { serve } from "@hono/node-server"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - }, -); - -const app = new Hono(); - -app.get("/", async (c) => { - const counter = await redis.incr("counter"); - return c.text(`Hit counter: ${counter}`); -}); - -const port = 3000; -console.log(`Server is running on port ${port}`); - -serve({ - fetch: app.fetch, - port, -}); diff --git a/examples/aws-hono-redis/sst.config.ts b/examples/aws-hono-redis/sst.config.ts deleted file mode 100644 index d39e5dcf86..0000000000 --- a/examples/aws-hono-redis/sst.config.ts +++ /dev/null @@ -1,97 +0,0 @@ -/// - -/** - * ## AWS Hono container with Redis - * - * Creates a hit counter app with Hono and Redis. - * - * This deploys Hono API as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {2} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by: - - * 1. Using the `Dockerfile` that's included in this example. - * - * 2. This compiles our TypeScript file, so we'll need add the following to the `tsconfig.json`. - * - * ```diff lang="json" title="tsconfig.json" {4,6} - * { - * "compilerOptions": { - * // ... - * + "outDir": "./dist" - * }, - * + "exclude": ["node_modules"] - * } - * ``` - * - * 3. Install TypeScript. - * - * ```bash - * npm install typescript --save-dev - * ``` - * - * 3. And add a `build` script to our `package.json`. - * - * ```diff lang="json" title="package.json" - * "scripts": { - * // ... - * + "build": "tsc" - * } - * ``` - * And finally, running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-hono-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-hono-redis/tsconfig.json b/examples/aws-hono-redis/tsconfig.json deleted file mode 100644 index 25d91658cc..0000000000 --- a/examples/aws-hono-redis/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "NodeNext", - "strict": true, - "outDir": "./dist", - "verbatimModuleSyntax": true, - "skipLibCheck": true, - "types": [ - "node" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - }, - "exclude": ["node_modules"] -} diff --git a/examples/aws-hono-stream/.gitignore b/examples/aws-hono-stream/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-hono-stream/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-hono-stream/index.ts b/examples/aws-hono-stream/index.ts deleted file mode 100644 index 5a9239a382..0000000000 --- a/examples/aws-hono-stream/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Hono } from "hono"; -import { streamText } from "hono/streaming"; -import { streamHandle } from "hono/aws-lambda"; - -const app = new Hono() - .get("/", (c) => { - return streamText(c, async (stream) => { - await stream.writeln("Hello"); - await stream.sleep(3000); - await stream.writeln("World"); - }) - }); - -export const handler = streamHandle(app); diff --git a/examples/aws-hono-stream/package.json b/examples/aws-hono-stream/package.json deleted file mode 100644 index 51c7dd4fe7..0000000000 --- a/examples/aws-hono-stream/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-hono-stream", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "hono": "^4.6.2", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-hono-stream/sst.config.ts b/examples/aws-hono-stream/sst.config.ts deleted file mode 100644 index 005d16ee1a..0000000000 --- a/examples/aws-hono-stream/sst.config.ts +++ /dev/null @@ -1,46 +0,0 @@ -/// - -/** - * ## AWS Hono streaming - * - * An example on how to enable streaming for Lambda functions using Hono. - * - * ```ts title="sst.config.ts" - * { - * streaming: true - * } - * ``` - * - * ```ts title="index.ts" - * export const handler = streamHandle(app); - * ``` - * - * To test this in your terminal, use the `curl` command with the `--no-buffer` option. - * - * ```bash "--no-buffer" - * curl --no-buffer https://u3dyblk457ghskwbmzrbylpxoi0ayrbb.lambda-url.us-east-1.on.aws - * ``` - * - * Streaming is also supported through API Gateway REST API. - * - */ -export default $config({ - app(input) { - return { - name: "aws-hono-stream", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const hono = new sst.aws.Function("Hono", { - url: true, - streaming: true, - timeout: "15 minutes", - handler: "index.handler", - }); - return { - api: hono.url, - }; - }, -}); diff --git a/examples/aws-hono-stream/tsconfig.json b/examples/aws-hono-stream/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-hono-stream/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-hono/.gitignore b/examples/aws-hono/.gitignore deleted file mode 100644 index c84fd38455..0000000000 --- a/examples/aws-hono/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -# prod -dist/ -lambda.zip - -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ - -# env -.env -.env.production - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# misc -.DS_Store - -# sst -.sst diff --git a/examples/aws-hono/package.json b/examples/aws-hono/package.json deleted file mode 100644 index 6ed2c8e0c7..0000000000 --- a/examples/aws-hono/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-hono", - "type": "module", - "scripts": { - "build": "esbuild --bundle --outfile=./dist/index.js --platform=node --target=node20 ./src/index.ts", - "deploy": "run-s build zip update", - "update": "aws lambda update-function-code --zip-file fileb://lambda.zip --function-name hello", - "zip": "zip -j lambda.zip dist/index.js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "esbuild": "^0.21.4", - "npm-run-all2": "^6.2.0" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "hono": "^4.6.12", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-hono/src/index.ts b/examples/aws-hono/src/index.ts deleted file mode 100644 index cb7ac2f0ae..0000000000 --- a/examples/aws-hono/src/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Hono } from "hono"; -import { handle } from "hono/aws-lambda"; -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client(); - -const app = new Hono(); - -app.get("/", async (c) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return c.text(await getSignedUrl(s3, command)); -}); - -app.get("/latest", async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return c.redirect(await getSignedUrl(s3, command)); -}); - -export const handler = handle(app); diff --git a/examples/aws-hono/sst.config.ts b/examples/aws-hono/sst.config.ts deleted file mode 100644 index 2c9f1db7b1..0000000000 --- a/examples/aws-hono/sst.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-hono", - removal: input?.stage === "production" ? "retain" : "remove", - protect: input?.stage === "production", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - new sst.aws.Function("Hono", { - url: true, - link: [bucket], - handler: "src/index.handler", - }); - }, -}); diff --git a/examples/aws-hono/tsconfig.json b/examples/aws-hono/tsconfig.json deleted file mode 100644 index 667b7e7e6d..0000000000 --- a/examples/aws-hono/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "types": [ - "node" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - } -} \ No newline at end of file diff --git a/examples/aws-iam-permission-boundary/index.ts b/examples/aws-iam-permission-boundary/index.ts deleted file mode 100644 index 09995bf3ca..0000000000 --- a/examples/aws-iam-permission-boundary/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3"; -import { SQSClient, ListQueuesCommand } from "@aws-sdk/client-sqs"; -const s3 = new S3Client(); -const sqs = new SQSClient(); - -export const handler = async () => { - const response = []; - - // List buckets - try { - await s3.send(new ListBucketsCommand()); - response.push("s3:ListBuckets - success"); - } catch (e: any) { - response.push(`s3:ListBuckets - failed (${e.message})`); - } - - // List queues - try { - await sqs.send(new ListQueuesCommand()); - response.push("sqs:ListQueues - success"); - } catch (e: any) { - response.push(`sqs:ListQueues - failed (${e.message})`); - } - - return { - statusCode: 200, - body: `
${JSON.stringify(response, null, 2)}
`, - }; -}; diff --git a/examples/aws-iam-permission-boundary/package.json b/examples/aws-iam-permission-boundary/package.json deleted file mode 100644 index 347231b033..0000000000 --- a/examples/aws-iam-permission-boundary/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-iam-permission-boundary", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.564.0", - "@aws-sdk/client-sqs": "^3.564.0" - } -} diff --git a/examples/aws-iam-permission-boundary/sst.config.ts b/examples/aws-iam-permission-boundary/sst.config.ts deleted file mode 100644 index 953b39ad0a..0000000000 --- a/examples/aws-iam-permission-boundary/sst.config.ts +++ /dev/null @@ -1,61 +0,0 @@ -/// - -/** - * ## IAM permissions boundaries - * - * Use permissions boundaries to set the maximum permissions for all IAM roles that'll be - * created in your app. - * - * In this example, the Function has the `s3:ListAllMyBuckets` and `sqs:ListQueues` - * permissions. However, we create a permissions boundary that only allows `s3:ListAllMyBuckets`. - * And we apply it to all Roles in the app using the global - * [`$transform`](/docs/reference/global/#transform). - * - * As a result, the Function is only allowed to list S3 buckets. If you open the deployed URL, - * you'll see that the SQS list call fails. - * - * Learn more about [AWS IAM permissions boundaries](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html). - */ -export default $config({ - app(input) { - return { - name: "aws-iam-permission-boundary", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // Create a permission boundary - const permissionsBoundary = new aws.iam.Policy("MyPermissionsBoundary", { - policy: aws.iam.getPolicyDocumentOutput({ - statements: [ - { - actions: ["s3:ListAllMyBuckets"], - resources: ["*"], - }, - ], - }).json, - }); - - // Apply the boundary to all roles - $transform(aws.iam.Role, (args) => { - args.permissionsBoundary = permissionsBoundary; - }); - - // The boundary automatically applies to this Function's role - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - permissions: [ - { - actions: ["s3:ListAllMyBuckets", "sqs:ListQueues"], - resources: ["*"], - }, - ], - url: true, - }); - - return { - app: app.url, - }; - }, -}); diff --git a/examples/aws-import/.gitignore b/examples/aws-import/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-import/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-import/package.json b/examples/aws-import/package.json deleted file mode 100644 index 62f02b1660..0000000000 --- a/examples/aws-import/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-import", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-import/sst.config.ts b/examples/aws-import/sst.config.ts deleted file mode 100644 index c8d3b84e1e..0000000000 --- a/examples/aws-import/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -/** - * ## Import existing resource - * - * Import an existing AWS resource using the `transform` option with `opts.import`. - */ -export default $config({ - app(input) { - return { - name: "aws-import", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Bucket("MyBucket", { - transform: { - bucket(args, opts) { - opts.import = "aws-import-my-bucket"; - args.bucket = "aws-import-my-bucket"; - args.forceDestroy = undefined; - }, - }, - }); - }, -}); diff --git a/examples/aws-import/tsconfig.json b/examples/aws-import/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-import/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-info/package.json b/examples/aws-info/package.json deleted file mode 100644 index 9802a5872a..0000000000 --- a/examples/aws-info/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-info", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-info/sst.config.ts b/examples/aws-info/sst.config.ts deleted file mode 100644 index 3c09c1ee88..0000000000 --- a/examples/aws-info/sst.config.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -/** - * ## Current AWS account - * - * You can use the `aws.getXXXXOutput()` provider functions to get info about the current - * AWS account. - * Learn more about [provider functions](/docs/providers/#functions). - */ -export default $config({ - app(input) { - return { - name: "aws-info", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - return { - region: aws.getRegionOutput().region, - account: aws.getCallerIdentityOutput({}).accountId, - }; - }, -}); - diff --git a/examples/aws-jsx-email/.gitignore b/examples/aws-jsx-email/.gitignore deleted file mode 100644 index fccbe3fea3..0000000000 --- a/examples/aws-jsx-email/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -node_modules - -# env -.env - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# sst -.sst diff --git a/examples/aws-jsx-email/index.ts b/examples/aws-jsx-email/index.ts deleted file mode 100644 index 907afeca8b..0000000000 --- a/examples/aws-jsx-email/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Resource } from "sst"; -import { render } from "jsx-email"; -import { Template } from "./templates/email"; -import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; - -const client = new SESv2Client(); - -export const handler = async () => { - await client.send( - new SendEmailCommand({ - FromEmailAddress: Resource.MyEmail.sender, - Destination: { - ToAddresses: [Resource.MyEmail.sender], - }, - Content: { - Simple: { - Subject: { - Data: "Hello World!", - }, - Body: { - Html: { - Data: await render(Template({ - email: "spongebob@example.com", - name: "Spongebob Squarepants" - })), - }, - }, - }, - }, - }) - ); - - return { - statusCode: 200, - body: "Sent!" - }; -}; diff --git a/examples/aws-jsx-email/package.json b/examples/aws-jsx-email/package.json deleted file mode 100644 index 25b27b978c..0000000000 --- a/examples/aws-jsx-email/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-jsx-email", - "version": "0.0.0", - "private": true, - "description": "A simple starter for jsx-email", - "scripts": { - "build": "email build ./templates", - "create": "email create", - "dev": "email preview ./templates" - }, - "dependencies": { - "@aws-sdk/client-sesv2": "^3.651.1", - "jsx-email": "^1.10.11", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/react": "^18.2.0", - "react": "^18.2.0", - "typescript": "^5.2.2" - } -} diff --git a/examples/aws-jsx-email/sst.config.ts b/examples/aws-jsx-email/sst.config.ts deleted file mode 100644 index a17fd32f97..0000000000 --- a/examples/aws-jsx-email/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## AWS JSX Email - * - * Uses [JSX Email](https://jsx.email) and the `Email` component to design and send emails. - * - * To test this example, change the `sst.config.ts` to use your own email address. - * - * ```ts title="sst.config.ts" - * sender: "email@example.com" - * ``` - * - * Then run. - * - * ```bash - * npm install - * npx sst dev - * ``` - * - * You'll get an email from AWS asking you to confirm your email address. Click the link to - * verify it. - * - * Next, go to the URL in the `sst dev` CLI output. You should now receive an email rendered - * using JSX Email. - * - * ```ts title="index.ts" - * import { Template } from "./templates/email"; - * - * await render(Template({ - * email: "spongebob@example.com", - * name: "Spongebob Squarepants" - * })) - * ``` - * - * Once you are ready to go to production, you can: - * - * - [Request production access](https://docs.aws.amazon.com/ses/latest/dg/request-production-access.html) for SES - * - And [use your domain](/docs/component/aws/email/) to send emails - */ -export default $config({ - app(input) { - return { - name: "aws-jsx-email", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const email = new sst.aws.Email("MyEmail", { - sender: "email@example.com", - }); - const api = new sst.aws.Function("MyApi", { - handler: "index.handler", - link: [email], - url: true, - }); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-jsx-email/templates/email.tsx b/examples/aws-jsx-email/templates/email.tsx deleted file mode 100644 index 4c4591a9e9..0000000000 --- a/examples/aws-jsx-email/templates/email.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { - Body, - Button, - Container, - Head, - Hr, - Html, - Link, - Preview, - Section, - Text -} from 'jsx-email'; - - -export type TemplateProps = { - email: string; - name: string; -} - -const main = { - backgroundColor: '#f6f9fc', - fontFamily: - '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Ubuntu,sans-serif' -}; - -const container = { - backgroundColor: '#ffffff', - margin: '0 auto', - marginBottom: '64px', - padding: '20px 0 48px' -}; - -const box = { - padding: '0 48px' -}; - -const hr = { - borderColor: '#e6ebf1', - margin: '20px 0' -}; - -const paragraph = { - color: '#777', - fontSize: '16px', - lineHeight: '24px', - textAlign: 'left' as const -}; - -const anchor = { - color: '#777' -}; - -const button = { - backgroundColor: 'coral', - borderRadius: '5px', - color: '#fff', - display: 'block', - fontSize: '16px', - fontWeight: 'bold', - textAlign: 'center' as const, - textDecoration: 'none', - width: '100%', - padding: '10px' -}; - -export const defaultProps = { - email: 'batman@example.com', - name: 'Bruce Wayne' -} as TemplateProps; - -export const templateName = 'aws-jsx-email'; - -export const Template = ({ email, name }: TemplateProps) => ( - - - This is our email preview text for {name} <{email}> - - -
- This is our email body text - -
- - This is text content with a{' '} - - link - - . - -
-
- - -); diff --git a/examples/aws-jsx-email/tsconfig.json b/examples/aws-jsx-email/tsconfig.json deleted file mode 100644 index b49214f869..0000000000 --- a/examples/aws-jsx-email/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "compilerOptions": { - "declaration": true, - "declarationMap": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "lib": ["ES2023"], - "module": "ESNext", - "moduleResolution": "node", - "noEmitOnError": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "preserveSymlinks": true, - "preserveWatchOutput": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true, - "strictNullChecks": true, - "target": "ESNext" - }, - "exclude": ["**/dist", "**/node_modules", "sst.config.ts"], - "include": ["templates", "index.ts", "sst-env.d.ts"] -} diff --git a/examples/aws-kinesis-stream/package.json b/examples/aws-kinesis-stream/package.json deleted file mode 100644 index 5cf5cc605b..0000000000 --- a/examples/aws-kinesis-stream/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-kinesis-stream", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-kinesis": "^3.598.0" - } -} diff --git a/examples/aws-kinesis-stream/publisher.ts b/examples/aws-kinesis-stream/publisher.ts deleted file mode 100644 index 1ef13cba14..0000000000 --- a/examples/aws-kinesis-stream/publisher.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { KinesisClient, PutRecordsCommand } from "@aws-sdk/client-kinesis"; -import { Resource } from "sst"; - -export const handler = async (event) => { - const client = new KinesisClient(); - - await client.send( - new PutRecordsCommand({ - Records: [ - { - Data: JSON.stringify({ type: "foo" }), - PartitionKey: "1", - }, - { - Data: JSON.stringify({ type: "bar" }), - PartitionKey: "1", - }, - ], - StreamName: Resource.MyStream.name, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-kinesis-stream/sst.config.ts b/examples/aws-kinesis-stream/sst.config.ts deleted file mode 100644 index 4e116e92d4..0000000000 --- a/examples/aws-kinesis-stream/sst.config.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -/** - * ## Kinesis streams - * - * Create a Kinesis stream, and subscribe to it with a function. - */ -export default $config({ - app(input) { - return { - name: "aws-kinesis-stream", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const stream = new sst.aws.KinesisStream("MyStream"); - - // Create a function subscribing to all events - stream.subscribe("AllSub", "subscriber.all"); - - // Create a function subscribing to events of `bar` type - stream.subscribe("FilteredSub", "subscriber.filtered", { - filters: [ - { - data: { - type: ["bar"], - }, - }, - ], - }); - - const app = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - link: [stream], - url: true, - }); - - return { - app: app.url, - stream: stream.name, - }; - }, -}); diff --git a/examples/aws-kinesis-stream/subscriber.ts b/examples/aws-kinesis-stream/subscriber.ts deleted file mode 100644 index 8042f2aafc..0000000000 --- a/examples/aws-kinesis-stream/subscriber.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { KinesisStreamHandler } from "aws-lambda"; - -export const all: KinesisStreamHandler = async (event) => { - for (const record of event.Records) { - const data = Buffer.from(record.kinesis.data, "base64").toString(); - console.log(`"All" subscriber received:`, data); - } -}; - -export const filtered: KinesisStreamHandler = async (event) => { - for (const record of event.Records) { - const data = Buffer.from(record.kinesis.data, "base64").toString(); - console.log(`"Filtered" subscriber received:`, data); - } -}; diff --git a/examples/aws-lambda-ai-stream/index.ts b/examples/aws-lambda-ai-stream/index.ts deleted file mode 100644 index 07cbaf48d0..0000000000 --- a/examples/aws-lambda-ai-stream/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { streamText } from 'ai'; - -export const handler = awslambda.streamifyResponse(async (_event, responseStream) => { - const result = streamText({ - model: 'amazon/nova-micro', - prompt: 'Write a poem about clouds that is twenty paragraphs long.', - }); - - responseStream.setContentType('text/plain'); - for await (const chunk of result.textStream) { - responseStream.write(chunk); - process.stdout.write(chunk); - } - responseStream.end(); -}); diff --git a/examples/aws-lambda-ai-stream/package.json b/examples/aws-lambda-ai-stream/package.json deleted file mode 100644 index dbb40556da..0000000000 --- a/examples/aws-lambda-ai-stream/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "aws-lambda-ai-stream", - "type": "module", - "dependencies": { - "ai": "^6.0.116", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-lambda-ai-stream/sst.config.ts b/examples/aws-lambda-ai-stream/sst.config.ts deleted file mode 100644 index 97e6c3feb7..0000000000 --- a/examples/aws-lambda-ai-stream/sst.config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// - -/** - * ## AWS Lambda AI streaming - * - * An example on how to stream AI responses from a Lambda function using the - * [AI SDK](https://ai-sdk.dev). - * - * Uses `streamText` from the AI SDK to stream a response - * through a Lambda function URL. - * - * ```ts title="sst.config.ts" - * { - * streaming: true - * } - * ``` - * - * The handler uses `awslambda.streamifyResponse` to stream the AI response - * back to the client as it's generated. - * - * ```ts title="index.ts" - * export const handler = awslambda.streamifyResponse( - * async (_event, responseStream) => { - * const result = streamText({ - * model: "amazon/nova-micro", - * prompt: "Write a poem about clouds that is twenty paragraphs long.", - * }); - * - * responseStream.setContentType("text/plain"); - * for await (const chunk of result.textStream) { - * responseStream.write(chunk); - * } - * responseStream.end(); - * }, - * ); - * ``` - * - * Set the API key for the AI gateway. - * - * ```bash - * sst secret set AiGatewayApiKey your-api-key-here - * ``` - * - * Use the "Run Client" dev command in the multiplexer to invoke the server and see - * the streamed response. - * - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-ai-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const server = new sst.aws.Function("Server", { - url: true, - streaming: true, - timeout: "15 minutes", - handler: "index.handler", - environment: { - AI_GATEWAY_API_KEY: new sst.Secret("AiGatewayApiKey").value, - }, - }); - - new sst.x.DevCommand("Client", { - dev: { - autostart: false, - command: $interpolate`curl --no-buffer ${server.url}`, - title: "Run Client", - }, - }); - - return { - url: server.url, - }; - }, -}); diff --git a/examples/aws-lambda-cron/cron.ts b/examples/aws-lambda-cron/cron.ts deleted file mode 100644 index 8fabb78be5..0000000000 --- a/examples/aws-lambda-cron/cron.ts +++ /dev/null @@ -1,4 +0,0 @@ -export async function handler(event: any) { - console.log("Cron triggered", JSON.stringify(event)); - return { statusCode: 200 }; -} diff --git a/examples/aws-lambda-cron/package.json b/examples/aws-lambda-cron/package.json deleted file mode 100644 index 1725914407..0000000000 --- a/examples/aws-lambda-cron/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-cron-lambda", - "private": true, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-lambda-cron/sst.config.ts b/examples/aws-lambda-cron/sst.config.ts deleted file mode 100644 index f3fc0b6ccc..0000000000 --- a/examples/aws-lambda-cron/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-lambda-cron", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const queue = new sst.aws.Queue("MyDLQ"); - - const cron = new sst.aws.CronV2("MyCron", { - schedule: "rate(1 minute)", - function: "cron.handler", - timezone: "America/New_York", - retries: 3, - dlq: queue.arn, - }); - - return { - function: cron.nodes.function.name, - dlq: queue.arn, - }; - }, -}); diff --git a/examples/aws-lambda-cron/tsconfig.json b/examples/aws-lambda-cron/tsconfig.json deleted file mode 100644 index 6ec1c39406..0000000000 --- a/examples/aws-lambda-cron/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "esModuleInterop": true - } -} diff --git a/examples/aws-lambda-golang/src/go.mod b/examples/aws-lambda-golang/src/go.mod deleted file mode 100644 index a7eafea675..0000000000 --- a/examples/aws-lambda-golang/src/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module aws-lambda - -go 1.23.4 - -require ( - github.com/aws/aws-lambda-go v1.47.0 - github.com/sst/sst/v3 v3.4.24-0.20241218234311-d6f5cc752318 -) diff --git a/examples/aws-lambda-golang/src/go.sum b/examples/aws-lambda-golang/src/go.sum deleted file mode 100644 index f3a3bcaf9f..0000000000 --- a/examples/aws-lambda-golang/src/go.sum +++ /dev/null @@ -1,12 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sst/sst/v3 v3.4.24-0.20241218234311-d6f5cc752318 h1:9qjY8XcNVRM6/Hbx+z3GdhkPgFImgUDJy1uWObko2h4= -github.com/sst/sst/v3 v3.4.24-0.20241218234311-d6f5cc752318/go.mod h1:rxQ4Pi7xaYAbyfLt0rFREzQDLE72clWKxudGKG9Xpt4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/aws-lambda-golang/src/main.go b/examples/aws-lambda-golang/src/main.go deleted file mode 100644 index f19721e58c..0000000000 --- a/examples/aws-lambda-golang/src/main.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "github.com/aws/aws-lambda-go/lambda" - "github.com/sst/sst/v3/sdk/golang/resource" -) - -func handler() (string, error) { - bucket, err := resource.Get("MyBucket", "name") - if err != nil { - return "", err - } - return bucket.(string), nil -} - -func main() { - lambda.Start(handler) -} diff --git a/examples/aws-lambda-golang/sst.config.ts b/examples/aws-lambda-golang/sst.config.ts deleted file mode 100644 index 19d2c1301e..0000000000 --- a/examples/aws-lambda-golang/sst.config.ts +++ /dev/null @@ -1,60 +0,0 @@ -/// - -/** - * ## AWS Lambda Go - * - * This example shows how to use the [`go`](https://golang.org/) runtime in your Lambda - * functions. - * - * Our Go function is in the `src` directory and we point to it in our function. - * - * ```ts title="sst.config.ts" {5} - * new sst.aws.Function("MyFunction", { - * url: true, - * runtime: "go", - * link: [bucket], - * handler: "./src", - * }); - * ``` - * - * We are also linking it to an S3 bucket. We can reference the bucket in our function. - * - * ```go title="src/main.go" {2} - * func handler() (string, error) { - * bucket, err := resource.Get("MyBucket", "name") - * if err != nil { - * return "", err - * } - * return bucket.(string), nil - * } - * ``` - * - * The `resource.Get` function is from the SST Go SDK. - * - * ```go title="src/main.go" {2} - * import ( - * "github.com/sst/sst/v3/sdk/golang/resource" - * ) - * ``` - * - * The `sst dev` CLI also supports running your Go function [_Live_](/docs/live). - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-golang", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - - new sst.aws.Function("MyFunction", { - url: true, - runtime: "go", - link: [bucket], - handler: "./src", - }); - }, -}); diff --git a/examples/aws-lambda-hook/.gitignore b/examples/aws-lambda-hook/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-lambda-hook/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-lambda-hook/index.js b/examples/aws-lambda-hook/index.js deleted file mode 100644 index e65fb38036..0000000000 --- a/examples/aws-lambda-hook/index.js +++ /dev/null @@ -1,7 +0,0 @@ -export async function handler(event,) { - console.log(event); - return { - statusCode: 200, - body: 'Hello World', - }; -} diff --git a/examples/aws-lambda-hook/package.json b/examples/aws-lambda-hook/package.json deleted file mode 100644 index 90bae21e53..0000000000 --- a/examples/aws-lambda-hook/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-lambda-hook", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "type": "commonjs", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.149" - } -} diff --git a/examples/aws-lambda-hook/sst.config.ts b/examples/aws-lambda-hook/sst.config.ts deleted file mode 100644 index 3935f30d6a..0000000000 --- a/examples/aws-lambda-hook/sst.config.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// - -/** - * ## AWS Lambda build hook - * - * In this example we hook into the Lambda function build process with - * `hook.postbuild`. - * - * This is useful for modifying the generated Lambda function code before it's - * uploaded to AWS. It can also be used for uploading the generated sourcemaps - * to a service like Sentry. - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-hook", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - new sst.aws.Function("MyFunction", { - url: true, - handler: "index.handler", - hook: { - async postbuild(dir) { - console.log(`postbuild ------- ${dir}`); - }, - }, - }); - }, -}); diff --git a/examples/aws-lambda-hook/tsconfig.json b/examples/aws-lambda-hook/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-hook/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-lambda-retry-with-queues/package.json b/examples/aws-lambda-retry-with-queues/package.json deleted file mode 100644 index 64cfdc9882..0000000000 --- a/examples/aws-lambda-retry-with-queues/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-lambda-retry-with-queues", - "version": "1.0.0", - "description": "", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146" - }, - "dependencies": { - "sst": "file:../../sdk/js", - "@aws-sdk/client-lambda": "^3.714.0", - "@aws-sdk/client-sqs": "^3.714.0", - "zod": "^3.24.1" - } -} diff --git a/examples/aws-lambda-retry-with-queues/src/bus-subscriber.ts b/examples/aws-lambda-retry-with-queues/src/bus-subscriber.ts deleted file mode 100644 index fe11df3db3..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/bus-subscriber.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { bus } from "sst/aws/bus"; -import { testEvent } from "./event"; - -export const handler = bus.subscriber([testEvent], async (evt, raw) => { - console.log("event", evt, raw, process.env); - const message = evt.properties.message; - - if (message !== "hello") { - throw new Error("🚨 bus subscriber failed"); - } -}); diff --git a/examples/aws-lambda-retry-with-queues/src/event.ts b/examples/aws-lambda-retry-with-queues/src/event.ts deleted file mode 100644 index 5cf54e780b..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/event.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { event } from "sst/event"; -import crypto from "node:crypto"; -import { z } from "zod"; - -export const defineEvent = event.builder({ - validator: (schema) => { - return (input) => { - return schema.parse(input); - }; - }, - metadata: () => { - return { - idempotencyKey: crypto.randomUUID(), - timestamp: new Date().toISOString(), - }; - }, -}); - -export const testEvent = defineEvent( - "test", - z.object({ - message: z.string(), - }) -); diff --git a/examples/aws-lambda-retry-with-queues/src/publisher.ts b/examples/aws-lambda-retry-with-queues/src/publisher.ts deleted file mode 100644 index de80c2f044..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/publisher.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { LambdaFunctionURLHandler } from "aws-lambda"; -import { bus } from "sst/aws/bus"; -import { Resource } from "sst"; -import { testEvent } from "./event"; - -// This function sends a message to the bus. This could be any other service which pugliches message to the bus. -export const handler: LambdaFunctionURLHandler = async (evt) => { - if (!evt.body) { - return { - statusCode: 400, - body: JSON.stringify({ message: "missing body" }), - }; - } - - try { - const body = JSON.parse(evt.body); - const message = body.message; - if (typeof message !== "string") { - return { - statusCode: 400, - body: JSON.stringify({ message: "message must be a string" }), - }; - } - bus.publish(Resource.bus.name, testEvent, { message }); - } catch (e) { - console.error(e); - return { - statusCode: 500, - body: JSON.stringify({ message: "error" }), - }; - } - - return { - statusCode: 200, - }; -}; diff --git a/examples/aws-lambda-retry-with-queues/src/retry.ts b/examples/aws-lambda-retry-with-queues/src/retry.ts deleted file mode 100644 index 93685227c5..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/retry.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { - LambdaClient, - InvokeCommand, - GetFunctionCommand, - ResourceNotFoundException, -} from "@aws-sdk/client-lambda"; -import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; -import type { SQSHandler } from "aws-lambda"; -import { Resource } from "sst"; - -const lambda = new LambdaClient({}); -lambda.middlewareStack.remove("recursionDetectionMiddleware"); -const sqs = new SQSClient({}); -sqs.middlewareStack.remove("recursionDetectionMiddleware"); - -export const handler: SQSHandler = async (evt) => { - for (const record of evt.Records) { - const parsed = JSON.parse(record.body); - console.log("body", parsed); - const functionName = parsed.requestContext.functionArn - .replace(":$LATEST", "") - .split(":") - .pop(); - if (parsed.responsePayload) { - const attempt = (parsed.requestPayload.attempts || 0) + 1; - - const info = await lambda.send( - new GetFunctionCommand({ - FunctionName: functionName, - }), - ); - const max = - Number.parseInt( - info.Configuration?.Environment?.Variables?.RETRIES || "", - ) || 0; - console.log("max retries", max); - if (attempt > max) { - console.log(`giving up after ${attempt} retries`); - // send to dlq - await sqs.send( - new SendMessageCommand({ - QueueUrl: Resource.dlq.url, - MessageBody: JSON.stringify({ - requestPayload: parsed.requestPayload, - requestContext: parsed.requestContext, - responsePayload: parsed.responsePayload, - }), - }), - ); - return; - } - const seconds = Math.min(Math.pow(2, attempt), 900); - console.log( - "delaying retry by ", - seconds, - "seconds for attempt", - attempt, - ); - parsed.requestPayload.attempts = attempt; - await sqs.send( - new SendMessageCommand({ - QueueUrl: Resource.retryQueue.url, - DelaySeconds: seconds, - MessageBody: JSON.stringify({ - requestPayload: parsed.requestPayload, - requestContext: parsed.requestContext, - }), - }), - ); - } - - if (!parsed.responsePayload) { - console.log("triggering function"); - try { - await lambda.send( - new InvokeCommand({ - InvocationType: "Event", - Payload: Buffer.from(JSON.stringify(parsed.requestPayload)), - FunctionName: functionName, - }), - ); - } catch (e) { - if (e instanceof ResourceNotFoundException) { - return; - } - throw e; - } - } - } -}; diff --git a/examples/aws-lambda-retry-with-queues/sst.config.ts b/examples/aws-lambda-retry-with-queues/sst.config.ts deleted file mode 100644 index 2f912c2147..0000000000 --- a/examples/aws-lambda-retry-with-queues/sst.config.ts +++ /dev/null @@ -1,223 +0,0 @@ -/// - -/** - * ## AWS Lambda retry with queues - * - * An example on how to retry Lambda invocations using SQS queues. - * - * Create a SQS retry queue which will be set as the destination for the Lambda function. - * - * ```ts title="src/retry.ts" - * const retryQueue = new sst.aws.Queue("retryQueue"); - * - * const bus = new sst.aws.Bus("bus"); - * - * const busSubscriber = bus.subscribe("busSubscriber", { - * handler: "src/bus-subscriber.handler", - * environment: { - * RETRIES: "2", // set the number of retries - * }, - * link: [retryQueue], // so the function can send messages to the retry queue - * }); - * - * new aws.lambda.FunctionEventInvokeConfig("eventConfig", { - * functionName: $resolve([busSubscriber.nodes.function.name]).apply( - * ([name]) => name, - * ), - * maximumRetryAttempts: 2, // default is 2, must be between 0 and 2 - * destinationConfig: { - * onFailure: { - * destination: retryQueue.arn, - * }, - * }, - * }); - * ``` - * - * Create a bus subscriber which will publish messages to the bus. Include a DLQ for messages that continue to fail. - * - * ```ts title="sst.config.ts" - * - * const dlq = new sst.aws.Queue("dlq"); - * - * retryQueue.subscribe({ - * handler: "src/retry.handler", - * link: [busSubscriber.nodes.function, retryQueue, dlq], - * timeout: "30 seconds", - * environment: { - * RETRIER_QUEUE_URL: retryQueue.url, - * }, - * permissions: [ - * { - * actions: ["lambda:GetFunction", "lambda:InvokeFunction"], - * resources: [ - * $interpolate`arn:aws:lambda:${aws.getRegionOutput().region}:${ - * aws.getCallerIdentityOutput().accountId - * }:function:*`, - * ], - * }, - * ], - * transform: { - * function: { - * deadLetterConfig: { - * targetArn: dlq.arn, - * }, - * }, - * }, - * }); - * ``` - * - * - * The Retry function will read mesaages and send back to the queue to be retried with a backoff. - * - * ```ts title="src/retry.ts" - * export const handler: SQSHandler = async (evt) => { - * for (const record of evt.Records) { - * const parsed = JSON.parse(record.body); - * console.log("body", parsed); - * const functionName = parsed.requestContext.functionArn - * .replace(":$LATEST", "") - * .split(":") - * .pop(); - * if (parsed.responsePayload) { - * const attempt = (parsed.requestPayload.attempts || 0) + 1; - * - * const info = await lambda.send( - * new GetFunctionCommand({ - * FunctionName: functionName, - * }), - * ); - * const max = - * Number.parseInt( - * info.Configuration?.Environment?.Variables?.RETRIES || "", - * ) || 0; - * console.log("max retries", max); - * if (attempt > max) { - * console.log(`giving up after ${attempt} retries`); - * // send to dlq - * await sqs.send( - * new SendMessageCommand({ - * QueueUrl: Resource.dlq.url, - * MessageBody: JSON.stringify({ - * requestPayload: parsed.requestPayload, - * requestContext: parsed.requestContext, - * responsePayload: parsed.responsePayload, - * }), - * }), - * ); - * return; - * } - * const seconds = Math.min(Math.pow(2, attempt), 900); - * console.log( - * "delaying retry by ", - * seconds, - * "seconds for attempt", - * attempt, - * ); - * parsed.requestPayload.attempts = attempt; - * await sqs.send( - * new SendMessageCommand({ - * QueueUrl: Resource.retryQueue.url, - * DelaySeconds: seconds, - * MessageBody: JSON.stringify({ - * requestPayload: parsed.requestPayload, - * requestContext: parsed.requestContext, - * }), - * }), - * ); - * } - * - * if (!parsed.responsePayload) { - * console.log("triggering function"); - * try { - * await lambda.send( - * new InvokeCommand({ - * InvocationType: "Event", - * Payload: Buffer.from(JSON.stringify(parsed.requestPayload)), - * FunctionName: functionName, - * }), - * ); - * } catch (e) { - * if (e instanceof ResourceNotFoundException) { - * return; - * } - * throw e; - * } - * } - * } - * }; - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-retry-with-queues", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const dlq = new sst.aws.Queue("dlq"); - - const retryQueue = new sst.aws.Queue("retryQueue"); - - const bus = new sst.aws.Bus("bus"); - - const busSubscriber = bus.subscribe("busSubscriber", { - handler: "src/bus-subscriber.handler", - environment: { - RETRIES: "2", - }, - link: [retryQueue], // so the function can send messages to the queue - }); - - const publisher = new sst.aws.Function("publisher", { - handler: "src/publisher.handler", - link: [bus], - url: true, - }); - - new aws.lambda.FunctionEventInvokeConfig("eventConfig", { - functionName: $resolve([busSubscriber.nodes.function.name]).apply( - ([name]) => name, - ), - maximumRetryAttempts: 1, - destinationConfig: { - onFailure: { - destination: retryQueue.arn, - }, - }, - }); - - retryQueue.subscribe({ - handler: "src/retry.handler", - link: [busSubscriber.nodes.function, retryQueue, dlq], - timeout: "30 seconds", - environment: { - RETRIER_QUEUE_URL: retryQueue.url, - }, - permissions: [ - { - actions: ["lambda:GetFunction", "lambda:InvokeFunction"], - resources: [ - $interpolate`arn:aws:lambda:${aws.getRegionOutput().region}:${ - aws.getCallerIdentityOutput().accountId - }:function:*`, - ], - }, - ], - transform: { - function: { - deadLetterConfig: { - targetArn: dlq.arn, - }, - }, - }, - }); - - return { - publisher: publisher.url, - dlq: dlq.url, - retryQueue: retryQueue.url, - }; - }, -}); diff --git a/examples/aws-lambda-retry-with-queues/tsconfig.json b/examples/aws-lambda-retry-with-queues/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-retry-with-queues/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-lambda-rust-multiple-binaries/.gitignore b/examples/aws-lambda-rust-multiple-binaries/.gitignore deleted file mode 100644 index 2a7be17e50..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target - -# sst -.sst diff --git a/examples/aws-lambda-rust-multiple-binaries/Cargo.toml b/examples/aws-lambda-rust-multiple-binaries/Cargo.toml deleted file mode 100644 index 0c41f4ac1e..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "aws-lambda-rust-multi-bin" -version = "0.1.0" -edition = "2021" - -[dependencies] -aws-config = { version = "1.5.16", features = ["behavior-version-latest"] } -aws-sdk-s3 = "1.73.0" -lambda_runtime = "0.13.0" -serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.138" -# this will break when not in this repo. -sst_sdk = { version = "0.1.0", path = "../../sdk/rust" } -# sst_sdk = "0.1.0" -tokio = { version = "1", features = ["macros"] } -uuid = { version = "1.13.1", features = ["v4"] } - -[[bin]] -name = "push" -path = "src/push.rs" - -[[bin]] -name = "pop" -path = "src/pop.rs" diff --git a/examples/aws-lambda-rust-multiple-binaries/src/pop.rs b/examples/aws-lambda-rust-multiple-binaries/src/pop.rs deleted file mode 100644 index 9106c96e6c..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/src/pop.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::time::Duration; - -use aws_sdk_s3::presigning::PresigningConfig; -use lambda_runtime::{service_fn, Error, LambdaEvent}; -use serde::Deserialize; -use serde_json::Value; -use sst_sdk::Resource; - -#[derive(Deserialize, Debug)] -struct Bucket { - name: String, -} - -async fn latest(_event: LambdaEvent) -> Result { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let objects = client.list_objects().bucket(&name).send().await.unwrap(); - let latest = objects - .contents() - .into_iter() - .min_by_key(|o| o.last_modified().unwrap()) - .unwrap(); - - let url = client - .get_object() - .bucket(name) - .key(latest.key().unwrap()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - Ok(url.uri().to_string()) -} - -#[tokio::main] -async fn main() -> Result<(), Error> { - let func = service_fn(latest); - lambda_runtime::run(func).await?; - Ok(()) -} diff --git a/examples/aws-lambda-rust-multiple-binaries/src/push.rs b/examples/aws-lambda-rust-multiple-binaries/src/push.rs deleted file mode 100644 index 7ee767072c..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/src/push.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::time::Duration; - -use aws_sdk_s3::presigning::PresigningConfig; -use lambda_runtime::{service_fn, Error, LambdaEvent}; -use serde::Deserialize; -use serde_json::Value; -use sst_sdk::Resource; - -#[derive(Deserialize, Debug)] -struct Bucket { - name: String, -} - -async fn presigned_url(_event: LambdaEvent) -> Result { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let url = client - .put_object() - .bucket(name) - .key(uuid::Uuid::new_v4()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - Ok(url.uri().to_string()) -} - -#[tokio::main] -async fn main() -> Result<(), Error> { - let func = service_fn(presigned_url); - lambda_runtime::run(func).await?; - Ok(()) -} diff --git a/examples/aws-lambda-rust-multiple-binaries/sst.config.ts b/examples/aws-lambda-rust-multiple-binaries/sst.config.ts deleted file mode 100644 index f229ab5948..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS Lamda Rust multiple-binaries - * - * This example shows how to deploy multiple binary rust project to AWS Lambda. - * - * SST relies on the work of [cargo lambda](https://cargo-lambda) to build and deploy Rust Lambda functions. - * - * What is special about the following file is that we are defining multiple binaries using the `[[bin]]` section in the `Cargo.toml` file. - * - * ```toml title="Cargo.toml" {13,14,15,17,18,19} - * [package] - * name = "aws-lambda-rust-multi-bin" - * version = "0.1.0" - * edition = "2021" - * - * [dependencies] - * lambda_runtime = "0.13.0" - * serde = { version = "1.0.217", features = ["derive"] } - * serde_json = "1.0.138" - * tokio = { version = "1", features = ["macros"] } - * # -- please note ommited dependencies -- - * - * [[bin]] - * name = "push" - * path = "src/push.rs" - * - * [[bin]] - * name = "pop" - * path = "src/pop.rs" - * ``` - * - * We then utilise the . syntax to specify the handler binary - * - * ```ts title="sst.config.ts" {5,11} - * new sst.aws.Function("push", { - * url: true, - * runtime: "rust", - * link: [bucket], - * handler: "./.push", - * }); - * new sst.aws.Function("pop", { - * url: true, - * runtime: "rust", - * link: [bucket], - * handler: "./.pop", - * }); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-lambda-rust-multiple-binaries", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("Bucket"); - const push = new sst.aws.Function("push", { - runtime: "rust", - handler: "./.push", - url: true, - architecture: "arm64", - link: [bucket], - }); - const pop = new sst.aws.Function("pop", { - runtime: "rust", - handler: "./.pop", - url: true, - architecture: "arm64", - link: [bucket], - }); - - return { push_url: push.url, pop_url: pop.url }; - }, -}); diff --git a/examples/aws-lambda-stream/.gitignore b/examples/aws-lambda-stream/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-lambda-stream/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-lambda-stream/index.ts b/examples/aws-lambda-stream/index.ts deleted file mode 100644 index fb8e0b89d2..0000000000 --- a/examples/aws-lambda-stream/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const handler = awslambda.streamifyResponse( - async (event, stream) => { - stream = awslambda.HttpResponseStream.from(stream, { - statusCode: 200, - headers: { - "Content-Type": "text/plain; charset=UTF-8", - "X-Content-Type-Options": "nosniff", - }, - }); - - stream.write("Hello "); - await new Promise((resolve) => setTimeout(resolve, 3000)); - stream.write("World"); - - stream.end(); - }, -); diff --git a/examples/aws-lambda-stream/package.json b/examples/aws-lambda-stream/package.json deleted file mode 100644 index bda03c194b..0000000000 --- a/examples/aws-lambda-stream/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-lambda-stream", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.161" - } -} diff --git a/examples/aws-lambda-stream/sst.config.ts b/examples/aws-lambda-stream/sst.config.ts deleted file mode 100644 index 8bea35f559..0000000000 --- a/examples/aws-lambda-stream/sst.config.ts +++ /dev/null @@ -1,60 +0,0 @@ -/// - -/** - * ## AWS Lambda streaming - * - * An example on how to enable streaming for Lambda functions. - * - * ```ts title="sst.config.ts" - * { - * streaming: true - * } - * ``` - * - * Use the `awslambda.streamifyResponse` function to wrap your handler. The `awslambda` - * global is provided by the Lambda execution environment at runtime, and SST provides it - * automatically during `sst dev` as well. For TypeScript types, importing from - * `@types/aws-lambda` will augment the global namespace. - * - * ```ts title="index.ts" - * export const handler = awslambda.streamifyResponse( - * async (event, stream) => { - * stream = awslambda.HttpResponseStream.from(stream, { - * statusCode: 200, - * headers: { - * "Content-Type": "text/plain; charset=UTF-8", - * "X-Content-Type-Options": "nosniff", - * }, - * }); - * - * stream.write("Hello "); - * await new Promise((resolve) => setTimeout(resolve, 3000)); - * stream.write("World"); - * - * stream.end(); - * }, - * ); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const fn = new sst.aws.Function("MyFunction", { - url: true, - streaming: true, - timeout: "15 minutes", - handler: "index.handler", - }); - - return { - url: fn.url, - }; - }, -}); diff --git a/examples/aws-lambda-stream/tsconfig.json b/examples/aws-lambda-stream/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-stream/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-lambda-trpc-stream/package.json b/examples/aws-lambda-trpc-stream/package.json deleted file mode 100644 index 94bc5f1505..0000000000 --- a/examples/aws-lambda-trpc-stream/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "aws-lambda-trpc-stream", - "type": "module", - "dependencies": { - "@trpc/client": "^11.11.0", - "@trpc/server": "^11.11.0", - "sst": "file:../../sdk/js", - "zod": "^4.3.6" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-lambda-trpc-stream/sst.config.ts b/examples/aws-lambda-trpc-stream/sst.config.ts deleted file mode 100644 index 0d59f8a635..0000000000 --- a/examples/aws-lambda-trpc-stream/sst.config.ts +++ /dev/null @@ -1,48 +0,0 @@ -/// - -/** - * ## AWS Lambda tRPC streaming - * - * An example on how to use tRPC with Lambda streaming. - * - * Uses `@trpc/server`'s `awsLambdaStreamingRequestHandler` adapter to handle - * streaming responses through Lambda function URLs. - * - * The `trpc-server` function defines a tRPC router and streams responses. - * The `trpc-client` function invokes the server using `httpBatchStreamLink`. - * - * Streaming is supported in both `sst dev` and `sst deploy`. - * - */ -export default $config({ - app(input) { - return { - name: 'aws-lambda-trpc-stream', - removal: input?.stage === 'production' ? 'retain' : 'remove', - home: 'aws', - }; - }, - async run() { - const trpcServer = new sst.aws.Function('TrpcServer', { - handler: 'trpc-server.handler', - streaming: true, - url: true, - runtime: 'nodejs24.x', - }); - - new sst.x.DevCommand('Client', { - dev: { - autostart: false, - command: $interpolate`npx tsx trpc-client.ts`, - title: 'Run Client', - }, - environment: { - TRPC_SERVER_URL: trpcServer.url, - }, - }); - - return { - serverUrl: trpcServer.url, - }; - }, -}); diff --git a/examples/aws-lambda-trpc-stream/trpc-client.ts b/examples/aws-lambda-trpc-stream/trpc-client.ts deleted file mode 100644 index aec7000b10..0000000000 --- a/examples/aws-lambda-trpc-stream/trpc-client.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { - createTRPCClient, - httpBatchStreamLink, - TRPCClientError, -} from "@trpc/client"; -import { ApiRouter } from "./trpc-server"; - -const client = createTRPCClient({ - links: [ - httpBatchStreamLink({ - url: process.env.TRPC_SERVER_URL, - methodOverride: "POST", - }), - ], -}); - -export const main = async () => { - await Promise.all( - Array.from({ length: 10 }, async (_, idx) => { - const delay = Math.random() * 8_000; - console.log("sending request", idx); - try { - const res = await client.getById.query({ delay, idx }); - console.log("got response", res.idx); - } catch (err) { - if (isTrpcError(err)) { - console.error("received error", idx, err.shape.message); - } else { - console.error("received unexpecte error", idx); - } - } - }), - ); -}; - -const isTrpcError = (err: unknown): err is TRPCClientError => { - return !!err && err instanceof TRPCClientError; -}; - -main().catch(console.error); diff --git a/examples/aws-lambda-trpc-stream/trpc-server.ts b/examples/aws-lambda-trpc-stream/trpc-server.ts deleted file mode 100644 index 6fb341e390..0000000000 --- a/examples/aws-lambda-trpc-stream/trpc-server.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { initTRPC, TRPCError } from '@trpc/server'; -import { awsLambdaStreamingRequestHandler } from '@trpc/server/adapters/aws-lambda'; -import z from 'zod'; - -const { router, procedure } = initTRPC.create(); - -const apiRouter = router({ - getById: procedure - .input( - z.object({ - delay: z.number(), - idx: z.number(), - }), - ) - .query(async ({ input }) => { - await new Promise((r) => setTimeout(r, input.delay)); - if (Math.random() < 0.5) { - console.log('sending response', input.delay); - return { id: Math.random(), idx: input.idx }; - } - console.log('sending error', input.idx); - throw new TRPCError({ - code: 'BAD_REQUEST', - message: 'Random failure', - }); - }), -}); - -export type ApiRouter = typeof apiRouter; - -export const handler = awslambda.streamifyResponse( - awsLambdaStreamingRequestHandler({ - router: apiRouter, - allowMethodOverride: true, - }), -); diff --git a/examples/aws-lambda-vpc/.gitignore b/examples/aws-lambda-vpc/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-lambda-vpc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-lambda-vpc/index.ts b/examples/aws-lambda-vpc/index.ts deleted file mode 100644 index 4cb5e4819a..0000000000 --- a/examples/aws-lambda-vpc/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export const handler = async () => { - const counter = await redis.incr("counter"); - return { - statusCode: 200, - body: `Hit counter: ${counter}` - }; -}; diff --git a/examples/aws-lambda-vpc/package.json b/examples/aws-lambda-vpc/package.json deleted file mode 100644 index 38b2e18d93..0000000000 --- a/examples/aws-lambda-vpc/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-lambda-vpc", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-lambda-vpc/sst.config.ts b/examples/aws-lambda-vpc/sst.config.ts deleted file mode 100644 index 6fef731bf9..0000000000 --- a/examples/aws-lambda-vpc/sst.config.ts +++ /dev/null @@ -1,66 +0,0 @@ -/// - -/** - * ## AWS Lambda in a VPC - * - * You can use SST to locally work on Lambda functions that are in a VPC. To do so, you'll - * need to enable `bastion` and `nat` on the `Vpc` component. - * - * ```ts title="sst.config.ts" - * new sst.aws.Vpc("MyVpc", { bastion: true, nat: "managed" }); - * ``` - * - * The NAT gateway is necessary to allow your Lambda function to connect to the internet. While, - * the bastion host is necessary for your local machine to be able to tunnel to the VPC. - * - * You'll need to install the tunnel, if you haven't done this before. - * - * ```bash "sudo" - * sudo sst tunnel install - * ``` - * - * This needs _sudo_ to create the network interface on your machine. You'll only need to do - * this once. - * - * Now you can run `sst dev`, your function can access resources in the VPC. For example, here - * we are connecting to a Redis cluster. - * - * ```ts title="index.ts" - * const redis = new Cluster( - * [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - * { - * dnsLookup: (address, callback) => callback(null, address), - * redisOptions: { - * tls: {}, - * username: Resource.MyRedis.username, - * password: Resource.MyRedis.password, - * }, - * } - * ); - * ``` - * - * The Redis cluster is in the same VPC as the function. - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-vpc", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "managed" }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const api = new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [redis], - handler: "index.handler" - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-lambda-vpc/tsconfig.json b/examples/aws-lambda-vpc/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-vpc/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-linkable-env/.gitignore b/examples/aws-linkable-env/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-linkable-env/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-linkable-env/package.json b/examples/aws-linkable-env/package.json deleted file mode 100644 index 9febdd34d5..0000000000 --- a/examples/aws-linkable-env/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-linkable-env", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-linkable-env/sst.config.ts b/examples/aws-linkable-env/sst.config.ts deleted file mode 100644 index 20acdfcd00..0000000000 --- a/examples/aws-linkable-env/sst.config.ts +++ /dev/null @@ -1,70 +0,0 @@ -/// - -/** - * ## Linkable env vars - * - * Pass SST link env vars to a native `aws.ecs.TaskDefinition` container using - * `sst.Linkable.env()`. This lets `Resource.MyResource` work at runtime - * in compute not managed by SST. - * - */ -export default $config({ - app(input) { - return { - name: "aws-linkable-env", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // Create an SST bucket - const bucket = new sst.aws.Bucket("MyBucket"); - - // Create a custom linkable - const linkable = new sst.Linkable("MyLinkable", { - properties: { - foo: "bar", - }, - }); - - // Create VPC and ECS cluster using native AWS resources - const vpc = new aws.ec2.Vpc("Vpc", { cidrBlock: "10.0.0.0/16" }); - const subnet = new aws.ec2.Subnet("Subnet", { - vpcId: vpc.id, - cidrBlock: "10.0.0.0/24", - }); - const cluster = new aws.ecs.Cluster("Cluster"); - - // Linkable.env() returns a Record, but ECS expects - // environment as an array of { name, value } objects - const environment = sst.Linkable.env([bucket, linkable]).apply((env) => - Object.entries(env).map(([name, value]) => ({ name, value })), - ); - - const taskDefinition = new aws.ecs.TaskDefinition("TaskDefinition", { - family: $interpolate`${$app.name}-${$app.stage}`, - cpu: "256", - memory: "512", - networkMode: "awsvpc", - requiresCompatibilities: ["FARGATE"], - containerDefinitions: $jsonStringify([ - { - name: "app", - image: "public.ecr.aws/docker/library/node:20-slim", - essential: true, - environment, - }, - ]), - }); - - new aws.ecs.Service("Service", { - cluster: cluster.arn, - taskDefinition: taskDefinition.arn, - desiredCount: 0, - launchType: "FARGATE", - networkConfiguration: { - subnets: [subnet.id], - }, - }); - }, -}); diff --git a/examples/aws-linkable-env/tsconfig.json b/examples/aws-linkable-env/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-linkable-env/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-linkable/.gitignore b/examples/aws-linkable/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-linkable/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-linkable/index.ts b/examples/aws-linkable/index.ts deleted file mode 100644 index 1498966a26..0000000000 --- a/examples/aws-linkable/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Resource } from "sst"; - -export async function handler() { - console.log("Hello World!"); - console.log("topic", Resource.Topic.arn); - console.log( - "existingResources", - Resource.ExistingResources.queueName, - Resource.ExistingResources.bucketName, - ); -} diff --git a/examples/aws-linkable/package.json b/examples/aws-linkable/package.json deleted file mode 100644 index ccedf4fe7b..0000000000 --- a/examples/aws-linkable/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-linkable", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-linkable/sst.config.ts b/examples/aws-linkable/sst.config.ts deleted file mode 100644 index 3a27854d1c..0000000000 --- a/examples/aws-linkable/sst.config.ts +++ /dev/null @@ -1,46 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-linkable", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // make a native resource linkable - sst.Linkable.wrap(aws.sns.Topic, (resource) => ({ - // these properties will be available when linked - properties: { - arn: resource.arn, - name: resource.name, - }, - })); - const topic = new aws.sns.Topic("Topic"); - - // create something that can be linked - const existingResources = new sst.Linkable("ExistingResources", { - properties: { - bucketName: "existing-bucket", - queueName: "existing-queue", - }, - include: [ - sst.aws.permission({ - actions: ["s3:GetObject", "sns:Publish"], - resources: ["*"], - }), - ], - }); - - const fn = new sst.aws.Function("Function", { - handler: "index.handler", - link: [topic, existingResources], - url: true, - }); - - return { - url: fn.url, - }; - }, -}); diff --git a/examples/aws-linkable/tsconfig.json b/examples/aws-linkable/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-linkable/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-load-balancer-waf/package.json b/examples/aws-load-balancer-waf/package.json deleted file mode 100644 index 668890f41c..0000000000 --- a/examples/aws-load-balancer-waf/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-load-balancer-waf", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-load-balancer-waf/sst.config.ts b/examples/aws-load-balancer-waf/sst.config.ts deleted file mode 100644 index 1a5fecc363..0000000000 --- a/examples/aws-load-balancer-waf/sst.config.ts +++ /dev/null @@ -1,85 +0,0 @@ -/// - -/** - * ## AWS Load Balancer Web Application Firewall (WAF) - * - * Enable WAF for an AWS Load Balancer. - * - * The WAF is configured to enable a rate limit and enables AWS managed rules. - * - */ -export default $config({ - app(input) { - return { - name: "aws-load-balancer-waf", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = cluster.addService("MyAppService", { - image: { - context: "./", - dockerfile: "packages/server/Dockerfile", - }, - }); - - const rateLimitRule = { - name: "RateLimitRule", - statement: { - rateBasedStatement: { - limit: 200, - aggregateKeyType: "IP", - }, - }, - priority: 1, - action: { block: {} }, - visibilityConfig: { - cloudwatchMetricsEnabled: true, - sampledRequestsEnabled: true, - metricName: "MyAppRateLimitRule", - }, - }; - - const awsManagedRules = { - name: "AWSManagedRules", - statement: { - managedRuleGroupStatement: { - name: "AWSManagedRulesCommonRuleSet", - vendorName: "AWS", - }, - }, - priority: 2, - overrideAction: { - none: {}, - }, - visibilityConfig: { - cloudwatchMetricsEnabled: true, - sampledRequestsEnabled: true, - metricName: "MyAppAWSManagedRules", - }, - }; - - const webAcl = new aws.wafv2.WebAcl("AppAlbWebAcl", { - defaultAction: { allow: {} }, - scope: "REGIONAL", - visibilityConfig: { - cloudwatchMetricsEnabled: true, - sampledRequestsEnabled: true, - metricName: "AppAlbWebAcl", - }, - rules: [rateLimitRule, awsManagedRules], - }); - - service.nodes.loadBalancer.arn.apply((arn) => { - new aws.wafv2.WebAclAssociation("MyAppAlbWebAclAssociation", { - resourceArn: arn, - webAclArn: webAcl.arn, - }); - }); - - return {}; - }, -}); diff --git a/examples/aws-monorepo/.gitignore b/examples/aws-monorepo/.gitignore deleted file mode 100644 index c4a0d6f07c..0000000000 --- a/examples/aws-monorepo/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules - -# sst -.sst - -# temporary files -.#* diff --git a/examples/aws-monorepo/infra/api.ts b/examples/aws-monorepo/infra/api.ts deleted file mode 100644 index 2d09eeae8b..0000000000 --- a/examples/aws-monorepo/infra/api.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { database } from "./database"; - -export const api = new sst.aws.Function("Api", { - url: true, - link: [database], - handler: "./packages/functions/src/api.handler", - environment: { - foo: "9", - }, -}); diff --git a/examples/aws-monorepo/infra/astro.ts b/examples/aws-monorepo/infra/astro.ts deleted file mode 100644 index 1b7671fa07..0000000000 --- a/examples/aws-monorepo/infra/astro.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { api } from "./api"; - -const bucket = new sst.aws.Bucket("MyBucket"); -export const astro = new sst.aws.Astro("Astro", { - path: "packages/astro", - link: [bucket], - environment: { - VITE_API_URL: api.url, - }, -}); diff --git a/examples/aws-monorepo/infra/database.ts b/examples/aws-monorepo/infra/database.ts deleted file mode 100644 index 420a14a240..0000000000 --- a/examples/aws-monorepo/infra/database.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const database = new sst.aws.Dynamo("Database", { - fields: { - PK: "string", - SK: "string", - }, - primaryIndex: { - hashKey: "PK", - rangeKey: "SK", - }, -}); diff --git a/examples/aws-monorepo/infra/frontend.ts b/examples/aws-monorepo/infra/frontend.ts deleted file mode 100644 index c32a095522..0000000000 --- a/examples/aws-monorepo/infra/frontend.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { api } from "./api"; - -export const web = new sst.aws.StaticSite("StaticSite", { - path: "packages/frontend", - build: { - output: "dist", - command: "npm run build", - }, - environment: { - VITE_API_URL: api.url, - }, -}); diff --git a/examples/aws-monorepo/infra/index.ts b/examples/aws-monorepo/infra/index.ts deleted file mode 100644 index f29a75d8b1..0000000000 --- a/examples/aws-monorepo/infra/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./api"; -export * from "./database"; -export * from "./frontend"; -export * from "./astro"; diff --git a/examples/aws-monorepo/package.json b/examples/aws-monorepo/package.json deleted file mode 100644 index 9f1076e6a4..0000000000 --- a/examples/aws-monorepo/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-monorepo", - "version": "0.0.0", - "workspaces": [ - "packages/*" - ], - "scripts": { - "dev": "sst dev" - }, - "devDependencies": { - "@tsconfig/node20": "^20.1.4", - "typescript": "5.3.3" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/astro/.vscode/extensions.json b/examples/aws-monorepo/packages/astro/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-monorepo/packages/astro/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-monorepo/packages/astro/.vscode/launch.json b/examples/aws-monorepo/packages/astro/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-monorepo/packages/astro/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-monorepo/packages/astro/astro.config.mjs b/examples/aws-monorepo/packages/astro/astro.config.mjs deleted file mode 100644 index b4f287b9a8..0000000000 --- a/examples/aws-monorepo/packages/astro/astro.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from "astro/config"; -import aws from "astro-sst"; - -export default defineConfig({ - output: "server", - adapter: aws(), -}); diff --git a/examples/aws-monorepo/packages/astro/package.json b/examples/aws-monorepo/packages/astro/package.json deleted file mode 100644 index 677f362509..0000000000 --- a/examples/aws-monorepo/packages/astro/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro", - "type": "module", - "version": "0.0.1", - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/check": "^0.5.10", - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "astro": "^4.5.9", - "astro-sst": "^2.41.2", - "sst": "file:../../../../sdk/js", - "typescript": "^5.4.3" - } -} diff --git a/examples/aws-monorepo/packages/astro/public/favicon.svg b/examples/aws-monorepo/packages/astro/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-monorepo/packages/astro/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-monorepo/packages/astro/src/components/Card.astro b/examples/aws-monorepo/packages/astro/src/components/Card.astro deleted file mode 100644 index bd6d5971eb..0000000000 --- a/examples/aws-monorepo/packages/astro/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/examples/aws-monorepo/packages/astro/src/env.d.ts b/examples/aws-monorepo/packages/astro/src/env.d.ts deleted file mode 100644 index acef35f175..0000000000 --- a/examples/aws-monorepo/packages/astro/src/env.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/examples/aws-monorepo/packages/astro/src/layouts/Layout.astro b/examples/aws-monorepo/packages/astro/src/layouts/Layout.astro deleted file mode 100644 index 7b552be19b..0000000000 --- a/examples/aws-monorepo/packages/astro/src/layouts/Layout.astro +++ /dev/null @@ -1,51 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - - - - - diff --git a/examples/aws-monorepo/packages/astro/src/pages/index.astro b/examples/aws-monorepo/packages/astro/src/pages/index.astro deleted file mode 100644 index bd93563ed4..0000000000 --- a/examples/aws-monorepo/packages/astro/src/pages/index.astro +++ /dev/null @@ -1,75 +0,0 @@ ---- -import { Resource } from "sst"; -import Layout from '../layouts/Layout.astro'; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- - - -
-
- - -
- -
-
- - diff --git a/examples/aws-monorepo/packages/astro/tsconfig.json b/examples/aws-monorepo/packages/astro/tsconfig.json deleted file mode 100644 index 77da9dd009..0000000000 --- a/examples/aws-monorepo/packages/astro/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -} \ No newline at end of file diff --git a/examples/aws-monorepo/packages/core/package.json b/examples/aws-monorepo/packages/core/package.json deleted file mode 100644 index bfd1c917de..0000000000 --- a/examples/aws-monorepo/packages/core/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@aws-monorepo/core", - "version": "0.0.0", - "exports": { - "./*": [ - "./src/*/index.ts", - "./src/*.ts" - ] - }, - "devDependencies": { - "sst": "file:../../../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/core/src/example/index.ts b/examples/aws-monorepo/packages/core/src/example/index.ts deleted file mode 100644 index 9cb1c03477..0000000000 --- a/examples/aws-monorepo/packages/core/src/example/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export namespace Example { - export function hello() { - return "Hello, world!"; - } -} diff --git a/examples/aws-monorepo/packages/core/tsconfig.json b/examples/aws-monorepo/packages/core/tsconfig.json deleted file mode 100644 index ea59875db2..0000000000 --- a/examples/aws-monorepo/packages/core/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-monorepo/packages/frontend/index.html b/examples/aws-monorepo/packages/frontend/index.html deleted file mode 100644 index 800ee5dbc2..0000000000 --- a/examples/aws-monorepo/packages/frontend/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Vite App - - -

Vite is running in %MODE%

-

api: %VITE_API_URL%

- - - diff --git a/examples/aws-monorepo/packages/frontend/package.json b/examples/aws-monorepo/packages/frontend/package.json deleted file mode 100644 index 6a6424629f..0000000000 --- a/examples/aws-monorepo/packages/frontend/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@aws-monorepo/frontend", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite dev", - "build": "vite build" - }, - "devDependencies": { - "vite": "^5.2.8", - "sst": "file:../../../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/frontend/vite.config.ts b/examples/aws-monorepo/packages/frontend/vite.config.ts deleted file mode 100644 index 0c4b848dbd..0000000000 --- a/examples/aws-monorepo/packages/frontend/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from "vite"; - -export default defineConfig({ - server: { - host: "0.0.0.0", - }, -}); diff --git a/examples/aws-monorepo/packages/functions/package.json b/examples/aws-monorepo/packages/functions/package.json deleted file mode 100644 index 9fd4eb3af9..0000000000 --- a/examples/aws-monorepo/packages/functions/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@aws-monorepo/functions", - "version": "0.0.0", - "dependencies": { - "@aws-monorepo/core": "*", - "sst": "file:../../../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.137", - "sst": "file:../../../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/functions/src/api.ts b/examples/aws-monorepo/packages/functions/src/api.ts deleted file mode 100644 index 4b1bf2a200..0000000000 --- a/examples/aws-monorepo/packages/functions/src/api.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Resource } from "sst"; -import { Handler } from "aws-lambda"; -import { Example } from "@aws-monorepo/core/example"; - -export const handler: Handler = async (event) => { - console.log( - "this is a long time as a test for the long and to see if it wraps and here cool wow", - ); - return { - statusCode: 200, - body: `${Example.hello()} Linked to ${Resource.Database.name}.`, - }; -}; diff --git a/examples/aws-monorepo/packages/functions/tsconfig.json b/examples/aws-monorepo/packages/functions/tsconfig.json deleted file mode 100644 index ea59875db2..0000000000 --- a/examples/aws-monorepo/packages/functions/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-monorepo/packages/scripts/package.json b/examples/aws-monorepo/packages/scripts/package.json deleted file mode 100644 index c8b78ff82a..0000000000 --- a/examples/aws-monorepo/packages/scripts/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@aws-monorepo/scripts", - "version": "0.0.0", - "dependencies": { - "@aws-monorepo/core": "*", - "sst": "file:../../../../sdk/js" - }, - "scripts": { - "shell": "sst shell tsx" - }, - "devDependencies": { - "tsx": "^4.7.2" - } -} diff --git a/examples/aws-monorepo/packages/scripts/src/example.ts b/examples/aws-monorepo/packages/scripts/src/example.ts deleted file mode 100644 index 1e9ac7bb9a..0000000000 --- a/examples/aws-monorepo/packages/scripts/src/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Resource } from "sst"; -import { Example } from "@aws-monorepo/core/example"; - -console.log(`${Example.hello()} Linked to ${Resource.Database.name}.`); diff --git a/examples/aws-monorepo/packages/scripts/tsconfig.json b/examples/aws-monorepo/packages/scripts/tsconfig.json deleted file mode 100644 index ea59875db2..0000000000 --- a/examples/aws-monorepo/packages/scripts/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-monorepo/sst.config.ts b/examples/aws-monorepo/sst.config.ts deleted file mode 100644 index 724d416c16..0000000000 --- a/examples/aws-monorepo/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-monorepo", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const infra = await import("./infra"); - - return { - api: infra.api.url, - astro: infra.astro.url, - }; - }, -}); diff --git a/examples/aws-monorepo/tsconfig.json b/examples/aws-monorepo/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-monorepo/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-multi-region/index.ts b/examples/aws-multi-region/index.ts deleted file mode 100644 index 0f59768d5e..0000000000 --- a/examples/aws-multi-region/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export async function handler() { - return { - statusCode: 200, - body: `Hello from ${process.env.AWS_REGION}`, - }; -} diff --git a/examples/aws-multi-region/package.json b/examples/aws-multi-region/package.json deleted file mode 100644 index b2370c5519..0000000000 --- a/examples/aws-multi-region/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-multi-region", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.145", - "@types/node": "^22.5.4" - } -} diff --git a/examples/aws-multi-region/sst.config.ts b/examples/aws-multi-region/sst.config.ts deleted file mode 100644 index a11d183110..0000000000 --- a/examples/aws-multi-region/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -/** - * ## AWS multi-region - * - * To deploy resources to multiple AWS regions, you can create a new provider for the region - * you want to deploy to. - * - * ```ts title="sst.config.ts" - * const provider = new aws.Provider("MyProvider", { region: "us-west-2" }); - * ``` - * - * And then pass that in to the resource. - * - * ```ts title="sst.config.ts" - * new sst.aws.Function("MyFunction", { handler: "index.handler" }, { provider }); - * ``` - * - * If no provider is passed in, the default provider will be used. And if no region is - * specified, the default region from your credentials will be used. - */ -export default $config({ - app(input) { - return { - name: "aws-multi-region", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const east = new sst.aws.Function("MyEastFunction", { - url: true, - handler: "index.handler", - }); - - const provider = new aws.Provider("MyWestProvider", { region: "us-west-2" }); - const west = new sst.aws.Function( - "MyWestFunction", - { - url: true, - handler: "index.handler", - }, - { provider } - ); - - return { - east: east.url, - west: west.url, - }; - }, -}); diff --git a/examples/aws-mysql-local/.gitignore b/examples/aws-mysql-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-mysql-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-mysql-local/index.ts b/examples/aws-mysql-local/index.ts deleted file mode 100644 index 7d1712321c..0000000000 --- a/examples/aws-mysql-local/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import mysql from "mysql2/promise"; -import { Resource } from "sst"; - -const connection = await mysql.createConnection({ - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, -}); - -export async function handler() { - const [rows] = await connection.query("SELECT NOW()"); - return { - statusCode: 200, - body: `Querying ${Resource.MyDatabase.host}\n\n` + rows[0].now, - }; -} diff --git a/examples/aws-mysql-local/package.json b/examples/aws-mysql-local/package.json deleted file mode 100644 index 10eb83dc38..0000000000 --- a/examples/aws-mysql-local/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-mysql-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "mysql2": "3.14.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-mysql-local/sst.config.ts b/examples/aws-mysql-local/sst.config.ts deleted file mode 100644 index 374825c605..0000000000 --- a/examples/aws-mysql-local/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS MySQL local - * - * In this example, we connect to a locally running MySQL instance for dev. While - * on deploy, we use RDS. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local container with MySQL. You don't have to use Docker, you can use - * any other way to run MySQL locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 3306:3306 \ - * -v $(pwd)/.sst/storage/mysql:/var/lib/mysql/data \ - * -e MYSQL_ROOT_PASSWORD=password \ - * -e MYSQL_DATABASE=local \ - * mysql:8.0 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `Mysql` component with the settings for the - * local MySQL instance. - * - * ```ts title="sst.config.ts" - * dev: { - * username: "root", - * password: "password", - * database: "local", - * host: "localhost", - * port: 3306, - * } - * ``` - * - * By providing the `dev` prop for Mysql, SST will use the local MySQL instance and - * not deploy a new RDS database when running `sst dev`. - * - * It also allows us to access the database through a Resource `link` without having to - * conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const pool = new Pool({ - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * user: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * database: Resource.MyDatabase.database, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-mysql-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const mysql = new sst.aws.Mysql("MyDatabase", { - dev: { - username: "root", - password: "password", - database: "local", - host: "localhost", - port: 3306, - }, - vpc, - }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [mysql], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-mysql-local/tsconfig.json b/examples/aws-mysql-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-mysql-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-mysql/index.ts b/examples/aws-mysql/index.ts deleted file mode 100644 index e589834de9..0000000000 --- a/examples/aws-mysql/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import mysql from "mysql2/promise"; -import { Resource } from "sst"; - -const connection = await mysql.createConnection({ - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, -}); - -export async function handler() { - const [rows] = await connection.execute("SELECT NOW()"); - return { - statusCode: 200, - body: `Querying ${Resource.MyDatabase.host}\n\n` + rows[0]['NOW()'], - }; -} diff --git a/examples/aws-mysql/package.json b/examples/aws-mysql/package.json deleted file mode 100644 index cdf175cd3c..0000000000 --- a/examples/aws-mysql/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-mysql", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "mysql2": "3.14.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-mysql/sst.config.ts b/examples/aws-mysql/sst.config.ts deleted file mode 100644 index f5baedce72..0000000000 --- a/examples/aws-mysql/sst.config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// - -/** - * ## AWS MySQL - * - * In this example, we deploy an RDS MySQL database. - * - * ```ts title="sst.config.ts" - * const mysql = new sst.aws.Mysql("MyDatabase", { - * vpc, - * }); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Function("MyApp", { - * handler: "index.handler", - * link: [mysql], - * url: true, - * vpc, - * }); - * ``` - * - * Now in the function we can access the database. - * - * ```ts title="index.ts" - * const connection = await mysql.createConnection({ - * database: Resource.MyDatabase.database, - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * user: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * }); - * ``` - * - * We also enable the `bastion` option for the VPC. This allows us to connect to - * the database from our local machine with the `sst tunnel` CLI. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only - * need to do this once on your machine. - * - * Now you can run `npx sst dev` and you can connect to the database from your local machine. - * - */ -export default $config({ - app(input) { - return { - name: "aws-mysql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2", bastion: true }); - const mysql = new sst.aws.Mysql("MyDatabase", { - vpc, - }); - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [mysql], - url: true, - vpc, - }); - - return { - app: app.url, - host: mysql.host, - port: mysql.port, - username: mysql.username, - password: mysql.password, - database: mysql.database, - }; - }, -}); diff --git a/examples/aws-nestjs-container/.dockerignore b/examples/aws-nestjs-container/.dockerignore deleted file mode 100644 index 3b5d5cb550..0000000000 --- a/examples/aws-nestjs-container/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -dist -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nestjs-container/.eslintrc.js b/examples/aws-nestjs-container/.eslintrc.js deleted file mode 100644 index 259de13c73..0000000000 --- a/examples/aws-nestjs-container/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, -}; diff --git a/examples/aws-nestjs-container/.gitignore b/examples/aws-nestjs-container/.gitignore deleted file mode 100644 index 8e0d8ec3b0..0000000000 --- a/examples/aws-nestjs-container/.gitignore +++ /dev/null @@ -1,59 +0,0 @@ -# compiled output -/dist -/node_modules -/build - -# Logs -logs -*.log -npm-debug.log* -pnpm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# OS -.DS_Store - -# Tests -/coverage -/.nyc_output - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# temp directory -.temp -.tmp - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# sst -.sst diff --git a/examples/aws-nestjs-container/.prettierrc b/examples/aws-nestjs-container/.prettierrc deleted file mode 100644 index dcb72794f5..0000000000 --- a/examples/aws-nestjs-container/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file diff --git a/examples/aws-nestjs-container/Dockerfile b/examples/aws-nestjs-container/Dockerfile deleted file mode 100644 index 143907a2df..0000000000 --- a/examples/aws-nestjs-container/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:22 - -WORKDIR /usr/src/app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build - -EXPOSE 3000 -CMD ["node", "dist/main"] diff --git a/examples/aws-nestjs-container/nest-cli.json b/examples/aws-nestjs-container/nest-cli.json deleted file mode 100644 index f9aa683b1a..0000000000 --- a/examples/aws-nestjs-container/nest-cli.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/nest-cli", - "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "deleteOutDir": true - } -} diff --git a/examples/aws-nestjs-container/package.json b/examples/aws-nestjs-container/package.json deleted file mode 100644 index 0beae8372e..0000000000 --- a/examples/aws-nestjs-container/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "aws-nestjs-container", - "version": "0.0.1", - "description": "", - "author": "", - "private": true, - "license": "UNLICENSED", - "scripts": { - "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "start": "nest start", - "start:debug": "nest start --debug --watch", - "start:dev": "nest start --watch", - "start:prod": "node dist/main", - "test": "jest", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json", - "test:watch": "jest --watch" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.717.0", - "@aws-sdk/lib-storage": "^3.717.0", - "@aws-sdk/s3-request-presigner": "^3.717.0", - "@nestjs/common": "^10.0.0", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "reflect-metadata": "^0.2.0", - "rxjs": "^7.8.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/aws-lambda": "8.10.146", - "@types/express": "^5.0.0", - "@types/jest": "^29.5.2", - "@types/multer": "^1.4.12", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^8.0.0", - "@typescript-eslint/parser": "^8.0.0", - "eslint": "^8.0.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.5.0", - "prettier": "^3.0.0", - "source-map-support": "^0.5.21", - "supertest": "^7.0.0", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" - }, - "jest": { - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testEnvironment": "node", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } - } -} diff --git a/examples/aws-nestjs-container/src/app.controller.spec.ts b/examples/aws-nestjs-container/src/app.controller.spec.ts deleted file mode 100644 index d22f3890a3..0000000000 --- a/examples/aws-nestjs-container/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/examples/aws-nestjs-container/src/app.controller.ts b/examples/aws-nestjs-container/src/app.controller.ts deleted file mode 100644 index 1c84dea417..0000000000 --- a/examples/aws-nestjs-container/src/app.controller.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3'; -import { Resource } from 'sst'; -import { Express } from 'express'; -import { Upload } from '@aws-sdk/lib-storage'; -import { FileInterceptor } from '@nestjs/platform-express'; -import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -import { Controller, Get, Post, Redirect, UploadedFile, UseInterceptors } from '@nestjs/common'; -import { AppService } from './app.service'; - -const s3 = new S3Client({}); - -@Controller() -export class AppController { - constructor(private readonly appService: AppService) { } - - @Get() - getHello(): string { - return this.appService.getHello(); - } - - @Post() - @UseInterceptors(FileInterceptor('file')) - async uploadFile(@UploadedFile() file: Express.Multer.File): Promise { - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.mimetype, - Key: file.originalname, - Body: file.buffer, - }; - - const upload = new Upload({ - params, - client: s3, - }); - - await upload.done(); - - return 'File uploaded successfully.'; - } - - @Get('latest') - @Redirect('/', 302) - async getLatestFile() { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents.sort( - (a, b) => b.LastModified.getTime() - a.LastModified.getTime(), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(s3, command); - - return { url }; - } -} diff --git a/examples/aws-nestjs-container/src/app.module.ts b/examples/aws-nestjs-container/src/app.module.ts deleted file mode 100644 index 86628031ca..0000000000 --- a/examples/aws-nestjs-container/src/app.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -@Module({ - imports: [], - controllers: [AppController], - providers: [AppService], -}) -export class AppModule {} diff --git a/examples/aws-nestjs-container/src/app.service.ts b/examples/aws-nestjs-container/src/app.service.ts deleted file mode 100644 index 927d7cca0b..0000000000 --- a/examples/aws-nestjs-container/src/app.service.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Injectable } from '@nestjs/common'; - -@Injectable() -export class AppService { - getHello(): string { - return 'Hello World!'; - } -} diff --git a/examples/aws-nestjs-container/src/main.ts b/examples/aws-nestjs-container/src/main.ts deleted file mode 100644 index f76bc8d977..0000000000 --- a/examples/aws-nestjs-container/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; - -async function bootstrap() { - const app = await NestFactory.create(AppModule); - await app.listen(process.env.PORT ?? 3000); -} -bootstrap(); diff --git a/examples/aws-nestjs-container/sst.config.ts b/examples/aws-nestjs-container/sst.config.ts deleted file mode 100644 index a5f5a85951..0000000000 --- a/examples/aws-nestjs-container/sst.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: 'aws-nestjs-container', - removal: input?.stage === 'production' ? 'retain' : 'remove', - protect: ['production'].includes(input?.stage), - home: 'aws', - }; - }, - async run() { - const vpc = new sst.aws.Vpc('MyVpc'); - const bucket = new sst.aws.Bucket('MyBucket'); - - const cluster = new sst.aws.Cluster('MyCluster', { vpc }); - - new sst.aws.Service('MyService', { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: '80/http', forward: '3000/http' }], - }, - dev: { - command: 'npm run start:dev', - }, - }); - }, -}); diff --git a/examples/aws-nestjs-container/test/app.e2e-spec.ts b/examples/aws-nestjs-container/test/app.e2e-spec.ts deleted file mode 100644 index 50cda62332..0000000000 --- a/examples/aws-nestjs-container/test/app.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from './../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); -}); diff --git a/examples/aws-nestjs-container/test/jest-e2e.json b/examples/aws-nestjs-container/test/jest-e2e.json deleted file mode 100644 index e9d912f3e3..0000000000 --- a/examples/aws-nestjs-container/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -} diff --git a/examples/aws-nestjs-container/tsconfig.build.json b/examples/aws-nestjs-container/tsconfig.build.json deleted file mode 100644 index 64f86c6bd2..0000000000 --- a/examples/aws-nestjs-container/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] -} diff --git a/examples/aws-nestjs-container/tsconfig.json b/examples/aws-nestjs-container/tsconfig.json deleted file mode 100644 index 162793367a..0000000000 --- a/examples/aws-nestjs-container/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false - }, - "include": ["src/**/*", "test/**/*", "sst-env.d.ts"] -} diff --git a/examples/aws-nestjs-redis/.dockerignore b/examples/aws-nestjs-redis/.dockerignore deleted file mode 100644 index 533d93408b..0000000000 --- a/examples/aws-nestjs-redis/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -dist - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nestjs-redis/.eslintrc.js b/examples/aws-nestjs-redis/.eslintrc.js deleted file mode 100644 index 259de13c73..0000000000 --- a/examples/aws-nestjs-redis/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, -}; diff --git a/examples/aws-nestjs-redis/.gitignore b/examples/aws-nestjs-redis/.gitignore deleted file mode 100644 index 8e0d8ec3b0..0000000000 --- a/examples/aws-nestjs-redis/.gitignore +++ /dev/null @@ -1,59 +0,0 @@ -# compiled output -/dist -/node_modules -/build - -# Logs -logs -*.log -npm-debug.log* -pnpm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# OS -.DS_Store - -# Tests -/coverage -/.nyc_output - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# temp directory -.temp -.tmp - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# sst -.sst diff --git a/examples/aws-nestjs-redis/.prettierrc b/examples/aws-nestjs-redis/.prettierrc deleted file mode 100644 index dcb72794f5..0000000000 --- a/examples/aws-nestjs-redis/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file diff --git a/examples/aws-nestjs-redis/Dockerfile b/examples/aws-nestjs-redis/Dockerfile deleted file mode 100644 index 143907a2df..0000000000 --- a/examples/aws-nestjs-redis/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:22 - -WORKDIR /usr/src/app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build - -EXPOSE 3000 -CMD ["node", "dist/main"] diff --git a/examples/aws-nestjs-redis/nest-cli.json b/examples/aws-nestjs-redis/nest-cli.json deleted file mode 100644 index f9aa683b1a..0000000000 --- a/examples/aws-nestjs-redis/nest-cli.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/nest-cli", - "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "deleteOutDir": true - } -} diff --git a/examples/aws-nestjs-redis/package.json b/examples/aws-nestjs-redis/package.json deleted file mode 100644 index 83fae61d50..0000000000 --- a/examples/aws-nestjs-redis/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "aws-nestjs-redis", - "version": "0.0.1", - "description": "", - "author": "", - "private": true, - "license": "UNLICENSED", - "scripts": { - "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "start": "nest start", - "start:debug": "nest start --debug --watch", - "start:dev": "nest start --watch", - "start:prod": "node dist/main", - "test": "jest", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json", - "test:watch": "jest --watch" - }, - "dependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "ioredis": "^5.4.1", - "reflect-metadata": "^0.2.0", - "rxjs": "^7.8.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/aws-lambda": "8.10.145", - "@types/express": "^4.17.17", - "@types/jest": "^29.5.2", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^8.0.0", - "@typescript-eslint/parser": "^8.0.0", - "eslint": "^8.42.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.5.0", - "prettier": "^3.0.0", - "source-map-support": "^0.5.21", - "supertest": "^7.0.0", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" - }, - "jest": { - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testEnvironment": "node", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } - } -} diff --git a/examples/aws-nestjs-redis/src/app.controller.spec.ts b/examples/aws-nestjs-redis/src/app.controller.spec.ts deleted file mode 100644 index d22f3890a3..0000000000 --- a/examples/aws-nestjs-redis/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/examples/aws-nestjs-redis/src/app.controller.ts b/examples/aws-nestjs-redis/src/app.controller.ts deleted file mode 100644 index e821e40746..0000000000 --- a/examples/aws-nestjs-redis/src/app.controller.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Controller, Get } from '@nestjs/common'; -import { AppService } from './app.service'; - -@Controller() -export class AppController { - constructor(private readonly appService: AppService) { } - - @Get() - async getCounter(): Promise { - return (await this.appService.getCounter()).toString(); - } -} diff --git a/examples/aws-nestjs-redis/src/app.module.ts b/examples/aws-nestjs-redis/src/app.module.ts deleted file mode 100644 index 86628031ca..0000000000 --- a/examples/aws-nestjs-redis/src/app.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -@Module({ - imports: [], - controllers: [AppController], - providers: [AppService], -}) -export class AppModule {} diff --git a/examples/aws-nestjs-redis/src/app.service.ts b/examples/aws-nestjs-redis/src/app.service.ts deleted file mode 100644 index 25a01b7010..0000000000 --- a/examples/aws-nestjs-redis/src/app.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -@Injectable() -export class AppService { - getHello(): string { - return 'Hello World!'; - } - - async getCounter(): Promise { - return await redis.incr("counter"); - } -} diff --git a/examples/aws-nestjs-redis/src/main.ts b/examples/aws-nestjs-redis/src/main.ts deleted file mode 100644 index 13cad38cff..0000000000 --- a/examples/aws-nestjs-redis/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; - -async function bootstrap() { - const app = await NestFactory.create(AppModule); - await app.listen(3000); -} -bootstrap(); diff --git a/examples/aws-nestjs-redis/sst.config.ts b/examples/aws-nestjs-redis/sst.config.ts deleted file mode 100644 index dcc3f4aa0f..0000000000 --- a/examples/aws-nestjs-redis/sst.config.ts +++ /dev/null @@ -1,75 +0,0 @@ -/// - -/** - * ## AWS NestJS with Redis - * - * Creates a hit counter app with NestJS and Redis. - * - * :::note - * You need Node 22.12 or higher for this example to work. - * ::: - * - * Also make sure you have Node 22.12. Or set the `--experimental-require-module` flag. - * This'll allow NestJS to import the SST SDK. - * - * This deploys NestJS as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run start:dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `npx sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: 'aws-nestjs-redis', - removal: input?.stage === 'production' ? 'retain' : 'remove', - home: 'aws', - }; - }, - async run() { - const vpc = new sst.aws.Vpc('MyVpc', { bastion: true }); - const redis = new sst.aws.Redis('MyRedis', { vpc }); - const cluster = new sst.aws.Cluster('MyCluster', { vpc }); - - new sst.aws.Service('MyService', { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: '80/http', forward: '3000/http' }], - }, - dev: { - command: 'npm run start:dev', - }, - }); - }, -}); diff --git a/examples/aws-nestjs-redis/test/app.e2e-spec.ts b/examples/aws-nestjs-redis/test/app.e2e-spec.ts deleted file mode 100644 index 50cda62332..0000000000 --- a/examples/aws-nestjs-redis/test/app.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from './../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); -}); diff --git a/examples/aws-nestjs-redis/test/jest-e2e.json b/examples/aws-nestjs-redis/test/jest-e2e.json deleted file mode 100644 index e9d912f3e3..0000000000 --- a/examples/aws-nestjs-redis/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -} diff --git a/examples/aws-nestjs-redis/tsconfig.build.json b/examples/aws-nestjs-redis/tsconfig.build.json deleted file mode 100644 index 64f86c6bd2..0000000000 --- a/examples/aws-nestjs-redis/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] -} diff --git a/examples/aws-nestjs-redis/tsconfig.json b/examples/aws-nestjs-redis/tsconfig.json deleted file mode 100644 index bf0b1c3ad8..0000000000 --- a/examples/aws-nestjs-redis/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false - }, - "include": ["src/**/*", "test/**/*", "sst-env.d.ts"], -} diff --git a/examples/aws-nextjs-add-behavior/.gitignore b/examples/aws-nextjs-add-behavior/.gitignore deleted file mode 100644 index 3ecba30f1c..0000000000 --- a/examples/aws-nextjs-add-behavior/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# env files (can opt-in for commiting if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-add-behavior/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-add-behavior/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-add-behavior/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-add-behavior/app/fonts/GeistVF.woff b/examples/aws-nextjs-add-behavior/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-add-behavior/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-add-behavior/app/globals.css b/examples/aws-nextjs-add-behavior/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-add-behavior/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-add-behavior/app/layout.tsx b/examples/aws-nextjs-add-behavior/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-add-behavior/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-add-behavior/app/page.module.css b/examples/aws-nextjs-add-behavior/app/page.module.css deleted file mode 100644 index ee9b8e6339..0000000000 --- a/examples/aws-nextjs-add-behavior/app/page.module.css +++ /dev/null @@ -1,168 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs-add-behavior/app/page.tsx b/examples/aws-nextjs-add-behavior/app/page.tsx deleted file mode 100644 index 52bd15ee7f..0000000000 --- a/examples/aws-nextjs-add-behavior/app/page.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import Image from "next/image"; -import styles from "./page.module.css"; - -export default function Home() { - return ( -
-
- Next.js logo -
    -
  1. - Get started by editing app/page.tsx. -
  2. -
  3. Save and see your changes instantly.
  4. -
- - -
- -
- ); -} diff --git a/examples/aws-nextjs-add-behavior/next.config.ts b/examples/aws-nextjs-add-behavior/next.config.ts deleted file mode 100644 index e9ffa3083a..0000000000 --- a/examples/aws-nextjs-add-behavior/next.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - /* config options here */ -}; - -export default nextConfig; diff --git a/examples/aws-nextjs-add-behavior/package.json b/examples/aws-nextjs-add-behavior/package.json deleted file mode 100644 index aae5dbed9e..0000000000 --- a/examples/aws-nextjs-add-behavior/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "aws-nextjs-add-behavior", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "next": "15.0.1", - "react": "19.0.0-rc-69d4b800-20241021", - "react-dom": "19.0.0-rc-69d4b800-20241021", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-add-behavior/public/file.svg b/examples/aws-nextjs-add-behavior/public/file.svg deleted file mode 100644 index 004145cddf..0000000000 --- a/examples/aws-nextjs-add-behavior/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/globe.svg b/examples/aws-nextjs-add-behavior/public/globe.svg deleted file mode 100644 index 567f17b0d7..0000000000 --- a/examples/aws-nextjs-add-behavior/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/vercel.svg b/examples/aws-nextjs-add-behavior/public/vercel.svg deleted file mode 100644 index 7705396033..0000000000 --- a/examples/aws-nextjs-add-behavior/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/window.svg b/examples/aws-nextjs-add-behavior/public/window.svg deleted file mode 100644 index b2b2a44f6e..0000000000 --- a/examples/aws-nextjs-add-behavior/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/sst.config.ts b/examples/aws-nextjs-add-behavior/sst.config.ts deleted file mode 100644 index c50649d7d4..0000000000 --- a/examples/aws-nextjs-add-behavior/sst.config.ts +++ /dev/null @@ -1,73 +0,0 @@ -/// - -/** - * ## AWS Next.js add behavior - * - * Here's how to add additional routes or cache behaviors to the CDN of a Next.js app deployed - * with OpenNext to AWS. - * - * Specify the path pattern that you want to forward to your new origin. For example, to forward - * all requests to the `/blog` path to a different origin. - * - * ```ts title="sst.config.ts" - * pathPattern: "/blog/*" - * ``` - * - * And then specify the domain of the new origin. - * - * ```ts title="sst.config.ts" - * domainName: "blog.example.com" - * ``` - * - * We use this to `transform` our site's CDN and add the additional behaviors. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-add-behavior", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const blogOrigin = { - // The domain of the new origin - domainName: "blog.example.com", - originId: "blogCustomOrigin", - customOriginConfig: { - httpPort: 80, - httpsPort: 443, - originSslProtocols: ["TLSv1.2"], - // If HTTPS is supported - originProtocolPolicy: "https-only", - }, - }; - - const cacheBehavior = { - // The path to forward to the new origin - pathPattern: "/blog/*", - targetOriginId: blogOrigin.originId, - viewerProtocolPolicy: "redirect-to-https", - allowedMethods: ["GET", "HEAD", "OPTIONS"], - cachedMethods: ["GET", "HEAD"], - forwardedValues: { - queryString: true, - cookies: { - forward: "all", - }, - }, - }; - - new sst.aws.Nextjs("MyWeb", { - transform: { - cdn: (options: sst.aws.CdnArgs) => { - options.origins = $resolve(options.origins).apply(val => [...val, blogOrigin]); - - options.orderedCacheBehaviors = $resolve( - options.orderedCacheBehaviors || [] - ).apply(val => [...val, cacheBehavior]); - }, - }, - }); - }, -}); diff --git a/examples/aws-nextjs-add-behavior/tsconfig.json b/examples/aws-nextjs-add-behavior/tsconfig.json deleted file mode 100644 index 3577577791..0000000000 --- a/examples/aws-nextjs-add-behavior/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-basic-auth/.eslintrc.json b/examples/aws-nextjs-basic-auth/.eslintrc.json deleted file mode 100644 index 3722418549..0000000000 --- a/examples/aws-nextjs-basic-auth/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["next/core-web-vitals", "next/typescript"] -} diff --git a/examples/aws-nextjs-basic-auth/.gitignore b/examples/aws-nextjs-basic-auth/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs-basic-auth/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-basic-auth/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-basic-auth/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-basic-auth/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-basic-auth/app/fonts/GeistVF.woff b/examples/aws-nextjs-basic-auth/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-basic-auth/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-basic-auth/app/globals.css b/examples/aws-nextjs-basic-auth/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-basic-auth/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-basic-auth/app/layout.tsx b/examples/aws-nextjs-basic-auth/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-basic-auth/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-basic-auth/app/page.module.css b/examples/aws-nextjs-basic-auth/app/page.module.css deleted file mode 100644 index 8a460419f9..0000000000 --- a/examples/aws-nextjs-basic-auth/app/page.module.css +++ /dev/null @@ -1,165 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: background 0.2s, color 0.2s, border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs-basic-auth/app/page.tsx b/examples/aws-nextjs-basic-auth/app/page.tsx deleted file mode 100644 index df5d042428..0000000000 --- a/examples/aws-nextjs-basic-auth/app/page.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import Image from "next/image"; -import styles from "./page.module.css"; - -export default function Home() { - return ( -
-
- Next.js logo -
    -
  1. - Get started by editing app/page.tsx. -
  2. -
  3. Save and see your changes instantly.
  4. -
- - -
- -
- ); -} diff --git a/examples/aws-nextjs-basic-auth/next.config.mjs b/examples/aws-nextjs-basic-auth/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-nextjs-basic-auth/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-nextjs-basic-auth/package.json b/examples/aws-nextjs-basic-auth/package.json deleted file mode 100644 index f9239740de..0000000000 --- a/examples/aws-nextjs-basic-auth/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-nextjs-basic-auth", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "next": "14.2.9", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "eslint": "^8", - "eslint-config-next": "14.2.9", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-basic-auth/sst.config.ts b/examples/aws-nextjs-basic-auth/sst.config.ts deleted file mode 100644 index 775cdb274d..0000000000 --- a/examples/aws-nextjs-basic-auth/sst.config.ts +++ /dev/null @@ -1,85 +0,0 @@ -/// - -/** - * ## AWS Next.js basic auth - * - * Deploys a simple Next.js app and adds basic auth to it. - * - * This is useful for dev environments where you want to share your app your team but ensure - * that it's not publicly accessible. - * - * :::tip - * You can use this for all the SSR sites, like Astro, Remix, SvelteKit, etc. - * ::: - * - * This works by injecting some code into a CloudFront function that checks the basic auth - * header and matches it against the `USERNAME` and `PASSWORD` secrets. - * - * ```ts title="sst.config.ts" - * { - * injection: $interpolate` - * if ( - * !event.request.headers.authorization - * || event.request.headers.authorization.value !== "Basic ${basicAuth}" - * ) { - * return { - * statusCode: 401, - * headers: { - * "www-authenticate": { value: "Basic" } - * } - * }; - * }`, - * } - * ``` - * - * To deploy this, you need to first set the `USERNAME` and `PASSWORD` secrets. - * - * ```bash - * sst secret set USERNAME my-username - * sst secret set PASSWORD my-password - * ``` - * - * If you are deploying this to preview environments, you might want to set the secrets using - * the [`--fallback`](/docs/reference/cli#secret) flag. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-basic-auth", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const username = new sst.Secret("USERNAME"); - const password = new sst.Secret("PASSWORD"); - const basicAuth = $resolve([username.value, password.value]).apply( - ([username, password]) => - Buffer.from(`${username}:${password}`).toString("base64") - ); - - new sst.aws.Nextjs("MyWeb", { - server: { - // Don't password protect prod - edge: $app.stage !== "production" - ? { - viewerRequest: { - injection: $interpolate` - if ( - !event.request.headers.authorization - || event.request.headers.authorization.value !== "Basic ${basicAuth}" - ) { - return { - statusCode: 401, - headers: { - "www-authenticate": { value: "Basic" } - } - }; - }`, - }, - } - : undefined, - }, - }); - }, -}); diff --git a/examples/aws-nextjs-basic-auth/tsconfig.json b/examples/aws-nextjs-basic-auth/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs-basic-auth/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-container/.dockerignore b/examples/aws-nextjs-container/.dockerignore deleted file mode 100644 index d0a41b0f28..0000000000 --- a/examples/aws-nextjs-container/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -.next -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nextjs-container/.gitignore b/examples/aws-nextjs-container/.gitignore deleted file mode 100644 index e1f9fd2d79..0000000000 --- a/examples/aws-nextjs-container/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# env files (can opt-in for committing if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-container/Dockerfile b/examples/aws-nextjs-container/Dockerfile deleted file mode 100644 index ff80689629..0000000000 --- a/examples/aws-nextjs-container/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# https://github.com/nextjs/deploy-sst/blob/main/Dockerfile -FROM node:lts-alpine AS base - -# Stage 1: Install dependencies -FROM base AS deps -WORKDIR /app -COPY package.json package-lock.json* ./ -COPY sst-env.d.ts* ./ -RUN npm ci - -# Stage 2: Build the application -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . -RUN npm run build - -# Stage 3: Production server -FROM base AS runner -WORKDIR /app -ENV NODE_ENV=production -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static - -EXPOSE 3000 -CMD ["node", "server.js"] diff --git a/examples/aws-nextjs-container/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-container/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-container/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-container/app/fonts/GeistVF.woff b/examples/aws-nextjs-container/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-container/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-container/app/globals.css b/examples/aws-nextjs-container/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-container/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-container/app/layout.tsx b/examples/aws-nextjs-container/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-container/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-container/app/page.module.css b/examples/aws-nextjs-container/app/page.module.css deleted file mode 100644 index ee9b8e6339..0000000000 --- a/examples/aws-nextjs-container/app/page.module.css +++ /dev/null @@ -1,168 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs-container/app/page.tsx b/examples/aws-nextjs-container/app/page.tsx deleted file mode 100644 index a7ce977382..0000000000 --- a/examples/aws-nextjs-container/app/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { Resource } from "sst"; -import Form from "@/components/form"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -import styles from "./page.module.css"; - -export const dynamic = "force-dynamic"; - -export default async function Home() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return ( -
-
-
-
-
- ); -} diff --git a/examples/aws-nextjs-container/components/form.module.css b/examples/aws-nextjs-container/components/form.module.css deleted file mode 100644 index 6a12c9ae58..0000000000 --- a/examples/aws-nextjs-container/components/form.module.css +++ /dev/null @@ -1,24 +0,0 @@ -.form { - padding: 2rem; - border-radius: 0.5rem; - background-color: var(--gray-alpha-100); -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - background-color: transparent; - font-family: var(--font-geist-sans); - border: 1px solid var(--gray-alpha-200); -} - -.form button:active:enabled { - background-color: var(--gray-alpha-200); -} diff --git a/examples/aws-nextjs-container/components/form.tsx b/examples/aws-nextjs-container/components/form.tsx deleted file mode 100644 index adaa22afdc..0000000000 --- a/examples/aws-nextjs-container/components/form.tsx +++ /dev/null @@ -1,30 +0,0 @@ -"use client"; - -import styles from "./form.module.css"; - -export default function Form({ url }: { url: string }) { - return ( - { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - - - ); -} diff --git a/examples/aws-nextjs-container/next.config.ts b/examples/aws-nextjs-container/next.config.ts deleted file mode 100644 index e23d70d906..0000000000 --- a/examples/aws-nextjs-container/next.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - /* config options here */ - output: "standalone" -}; - -export default nextConfig; diff --git a/examples/aws-nextjs-container/package.json b/examples/aws-nextjs-container/package.json deleted file mode 100644 index 9e89772fb6..0000000000 --- a/examples/aws-nextjs-container/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-nextjs-container", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "next": "15.0.3", - "react": "19.0.0-rc-66855b96-20241106", - "react-dom": "19.0.0-rc-66855b96-20241106", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-container/public/file.svg b/examples/aws-nextjs-container/public/file.svg deleted file mode 100644 index 004145cddf..0000000000 --- a/examples/aws-nextjs-container/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/globe.svg b/examples/aws-nextjs-container/public/globe.svg deleted file mode 100644 index 567f17b0d7..0000000000 --- a/examples/aws-nextjs-container/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/vercel.svg b/examples/aws-nextjs-container/public/vercel.svg deleted file mode 100644 index 7705396033..0000000000 --- a/examples/aws-nextjs-container/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/window.svg b/examples/aws-nextjs-container/public/window.svg deleted file mode 100644 index b2b2a44f6e..0000000000 --- a/examples/aws-nextjs-container/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/sst.config.ts b/examples/aws-nextjs-container/sst.config.ts deleted file mode 100644 index 5550e64e57..0000000000 --- a/examples/aws-nextjs-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nextjs-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - link: [bucket], - }); - }, -}); diff --git a/examples/aws-nextjs-container/tsconfig.json b/examples/aws-nextjs-container/tsconfig.json deleted file mode 100644 index 3577577791..0000000000 --- a/examples/aws-nextjs-container/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-redis/.dockerignore b/examples/aws-nextjs-redis/.dockerignore deleted file mode 100644 index ff7df5d861..0000000000 --- a/examples/aws-nextjs-redis/.dockerignore +++ /dev/null @@ -1,12 +0,0 @@ -Dockerfile -.dockerignore -node_modules -npm-debug.log -README.md -.next -docker -.git - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nextjs-redis/.gitignore b/examples/aws-nextjs-redis/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs-redis/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-redis/Dockerfile b/examples/aws-nextjs-redis/Dockerfile deleted file mode 100644 index 2d16514a6d..0000000000 --- a/examples/aws-nextjs-redis/Dockerfile +++ /dev/null @@ -1,75 +0,0 @@ -# https://github.com/vercel/next.js/tree/canary/examples/with-docker - -FROM node:18-alpine AS base - -# Install dependencies only when needed -FROM base AS deps -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -RUN apk add --no-cache libc6-compat -WORKDIR /app - -COPY sst-env.d.ts* ./ - -# Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Rebuild the source code only when needed -FROM base AS builder - -# Add linked resources to the environment -ARG SST_RESOURCE_MyRedis - -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry during the build. -# ENV NEXT_TELEMETRY_DISABLED=1 - -RUN \ - if [ -f yarn.lock ]; then yarn run build; \ - elif [ -f package-lock.json ]; then npm run build; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Production image, copy all the files and run next -FROM base AS runner -WORKDIR /app - -ENV NODE_ENV=production -# Uncomment the following line in case you want to disable telemetry during runtime. -# ENV NEXT_TELEMETRY_DISABLED=1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder /app/public* ./public - -# Set the correct permission for prerender cache -RUN mkdir .next -RUN chown nextjs:nodejs .next - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static - -USER nextjs - -EXPOSE 3000 - -ENV PORT=3000 - -# server.js is created by next build from the standalone output -# https://nextjs.org/docs/pages/api-reference/next-config-js/output -ENV HOSTNAME="0.0.0.0" -CMD ["node", "server.js"] diff --git a/examples/aws-nextjs-redis/app/favicon.ico b/examples/aws-nextjs-redis/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-redis/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-redis/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-redis/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-redis/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-redis/app/fonts/GeistVF.woff b/examples/aws-nextjs-redis/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-redis/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-redis/app/globals.css b/examples/aws-nextjs-redis/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-redis/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-redis/app/layout.tsx b/examples/aws-nextjs-redis/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-redis/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-redis/app/page.module.css b/examples/aws-nextjs-redis/app/page.module.css deleted file mode 100644 index 51ed5f08db..0000000000 --- a/examples/aws-nextjs-redis/app/page.module.css +++ /dev/null @@ -1,41 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main p { - font-family: var(--font-geist-mono); - font-size: 14px; - letter-spacing: -0.01em; -} diff --git a/examples/aws-nextjs-redis/app/page.tsx b/examples/aws-nextjs-redis/app/page.tsx deleted file mode 100644 index 09eda0ef92..0000000000 --- a/examples/aws-nextjs-redis/app/page.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import styles from "./page.module.css"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export const dynamic = "force-dynamic"; - -export default async function Home() { - const counter = await redis.incr("counter"); - - return ( -
-
-

Hit counter: {counter}

-
-
- ); -} diff --git a/examples/aws-nextjs-redis/next.config.mjs b/examples/aws-nextjs-redis/next.config.mjs deleted file mode 100644 index 68dea63186..0000000000 --- a/examples/aws-nextjs-redis/next.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = { - output: "standalone" -}; - -export default nextConfig; diff --git a/examples/aws-nextjs-redis/package.json b/examples/aws-nextjs-redis/package.json deleted file mode 100644 index cc3f62615b..0000000000 --- a/examples/aws-nextjs-redis/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-nextjs-redis", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "ioredis": "^5.4.1", - "next": "14.2.14", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-redis/sst.config.ts b/examples/aws-nextjs-redis/sst.config.ts deleted file mode 100644 index edc3bb7886..0000000000 --- a/examples/aws-nextjs-redis/sst.config.ts +++ /dev/null @@ -1,71 +0,0 @@ -/// - -/** - * ## AWS Next.js container with Redis - * - * Creates a hit counter app with Next.js and Redis. - * - * This deploys Next.js as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by: - * - * 1. Setting `output: "standalone"` in your `next.config.mjs` file. - * 2. Adding a `Dockerfile` that's included in this example. - * 3. Running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-nextjs-redis/tsconfig.json b/examples/aws-nextjs-redis/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs-redis/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-stream/.gitignore b/examples/aws-nextjs-stream/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs-stream/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-stream/app/favicon.ico b/examples/aws-nextjs-stream/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-stream/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-stream/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-stream/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-stream/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-stream/app/fonts/GeistVF.woff b/examples/aws-nextjs-stream/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-stream/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-stream/app/globals.css b/examples/aws-nextjs-stream/app/globals.css deleted file mode 100644 index 8f2485f332..0000000000 --- a/examples/aws-nextjs-stream/app/globals.css +++ /dev/null @@ -1,8 +0,0 @@ -body { - font-family: Arial, sans-serif; - margin: 0; - padding: 0; - background-color: #f0f8ff; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} diff --git a/examples/aws-nextjs-stream/app/layout.tsx b/examples/aws-nextjs-stream/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-stream/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-stream/app/page.module.css b/examples/aws-nextjs-stream/app/page.module.css deleted file mode 100644 index 579a1e6288..0000000000 --- a/examples/aws-nextjs-stream/app/page.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.container { - max-width: 800px; - margin: 0 auto; - padding: 20px; -} diff --git a/examples/aws-nextjs-stream/app/page.tsx b/examples/aws-nextjs-stream/app/page.tsx deleted file mode 100644 index 00597dbc40..0000000000 --- a/examples/aws-nextjs-stream/app/page.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Suspense } from "react"; -import Bio from "@/components/bio"; -import Friends from "@/components/friends"; -import styles from "./page.module.css"; - -export const dynamic = "force-dynamic"; - -export default async function Home() { - return ( -
- - -
-

Friends from Bikini Bottom

- Loading...
}> - - - -
- ); -} diff --git a/examples/aws-nextjs-stream/components/bio.module.css b/examples/aws-nextjs-stream/components/bio.module.css deleted file mode 100644 index e07167d438..0000000000 --- a/examples/aws-nextjs-stream/components/bio.module.css +++ /dev/null @@ -1,15 +0,0 @@ -.section { - background-color: #fff; - padding: 20px; - margin-bottom: 20px; - border-radius: 10px; -} -.content { - display: flex; - align-items: center; -} -.text { - flex: 1; - padding-right: 20px; -} - diff --git a/examples/aws-nextjs-stream/components/bio.tsx b/examples/aws-nextjs-stream/components/bio.tsx deleted file mode 100644 index 8c116ce0f7..0000000000 --- a/examples/aws-nextjs-stream/components/bio.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import styles from "./bio.module.css"; - -const spongebob = { - name: "SpongeBob SquarePants", - description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.", - image: "spongebob.png", -}; - -export default function Bio({ }) { - return ( -
-

{spongebob.name}

-
-
-

{spongebob.description}

-
- {spongebob.name} -
-
- ); -} diff --git a/examples/aws-nextjs-stream/components/friends.module.css b/examples/aws-nextjs-stream/components/friends.module.css deleted file mode 100644 index c04d006655..0000000000 --- a/examples/aws-nextjs-stream/components/friends.module.css +++ /dev/null @@ -1,16 +0,0 @@ -.grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); - gap: 20px; -} -.card { - background-color: #fff; - padding: 10px; - border-radius: 5px; - text-align: center; -} -.img { - max-width: 100%; - height: auto; - border-radius: 5px; -} diff --git a/examples/aws-nextjs-stream/components/friends.tsx b/examples/aws-nextjs-stream/components/friends.tsx deleted file mode 100644 index ee01bd962c..0000000000 --- a/examples/aws-nextjs-stream/components/friends.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import styles from "./friends.module.css"; - -interface Character { - name: string; - image: string; -} - -function friendsPromise() { - return new Promise((resolve) => { - setTimeout(() => { - resolve( - [ - { name: "Patrick Star", image: "patrick.png" }, - { name: "Sandy Cheeks", image: "sandy.png" }, - { name: "Squidward Tentacles", image: "squidward.png" }, - { name: "Mr. Krabs", image: "mr-krabs.png" }, - ] - ); - }, 3000); - }); -} - -export default async function Friends() { - const friends = await friendsPromise() as Character[]; - - return ( -
- {friends.map((friend) => ( -
- {friend.name} -

{friend.name}

-
- ))} -
- ); -} diff --git a/examples/aws-nextjs-stream/next.config.mjs b/examples/aws-nextjs-stream/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-nextjs-stream/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-nextjs-stream/open-next.config.ts b/examples/aws-nextjs-stream/open-next.config.ts deleted file mode 100644 index 15aa84d402..0000000000 --- a/examples/aws-nextjs-stream/open-next.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -const config = { - default: { - override: { - wrapper: "aws-lambda-streaming", - }, - }, -}; - -export default config; diff --git a/examples/aws-nextjs-stream/package.json b/examples/aws-nextjs-stream/package.json deleted file mode 100644 index 324de7960c..0000000000 --- a/examples/aws-nextjs-stream/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "aws-nextjs-stream", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "next": "14.2.12", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-stream/public/mr-krabs.png b/examples/aws-nextjs-stream/public/mr-krabs.png deleted file mode 100644 index e94ea64054..0000000000 Binary files a/examples/aws-nextjs-stream/public/mr-krabs.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/patrick.png b/examples/aws-nextjs-stream/public/patrick.png deleted file mode 100644 index 030eaaf8a3..0000000000 Binary files a/examples/aws-nextjs-stream/public/patrick.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/sandy.png b/examples/aws-nextjs-stream/public/sandy.png deleted file mode 100644 index eb7a9cc324..0000000000 Binary files a/examples/aws-nextjs-stream/public/sandy.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/spongebob.png b/examples/aws-nextjs-stream/public/spongebob.png deleted file mode 100644 index 18f7df537e..0000000000 Binary files a/examples/aws-nextjs-stream/public/spongebob.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/squidward.png b/examples/aws-nextjs-stream/public/squidward.png deleted file mode 100644 index 4af85e000b..0000000000 Binary files a/examples/aws-nextjs-stream/public/squidward.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/sst.config.ts b/examples/aws-nextjs-stream/sst.config.ts deleted file mode 100644 index 866bda8298..0000000000 --- a/examples/aws-nextjs-stream/sst.config.ts +++ /dev/null @@ -1,53 +0,0 @@ -/// - -/** - * ## AWS Next.js streaming - * - * An example of how to use streaming Next.js RSC. Uses `Suspense` to stream an async component. - * - * ```tsx title="app/page.tsx" - * Loading...}> - * - * - * ``` - * - * For this demo we also need to make sure the route is not statically built. - * - * ```ts title="app/page.tsx" - * export const dynamic = "force-dynamic"; - * ``` - * - * This is deployed with OpenNext, which needs a config to enable streaming. - * - * ```ts title="open-next.config.ts" {4} - * export default { - * default: { - * override: { - * wrapper: "aws-lambda-streaming" - * } - * } - * }; - * ``` - * - * You should see the _friends_ section load after a 3 second delay. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Nextjs("MyWeb"); - }, -}); diff --git a/examples/aws-nextjs-stream/tsconfig.json b/examples/aws-nextjs-stream/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs-stream/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs/.gitignore b/examples/aws-nextjs/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs/app/favicon.ico b/examples/aws-nextjs/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs/app/fonts/GeistVF.woff b/examples/aws-nextjs/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs/app/globals.css b/examples/aws-nextjs/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs/app/layout.tsx b/examples/aws-nextjs/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs/app/page.module.css b/examples/aws-nextjs/app/page.module.css deleted file mode 100644 index 8a460419f9..0000000000 --- a/examples/aws-nextjs/app/page.module.css +++ /dev/null @@ -1,165 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: background 0.2s, color 0.2s, border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs/app/page.tsx b/examples/aws-nextjs/app/page.tsx deleted file mode 100644 index a7ce977382..0000000000 --- a/examples/aws-nextjs/app/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { Resource } from "sst"; -import Form from "@/components/form"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -import styles from "./page.module.css"; - -export const dynamic = "force-dynamic"; - -export default async function Home() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return ( -
-
-
-
-
- ); -} diff --git a/examples/aws-nextjs/components/form.module.css b/examples/aws-nextjs/components/form.module.css deleted file mode 100644 index 6a12c9ae58..0000000000 --- a/examples/aws-nextjs/components/form.module.css +++ /dev/null @@ -1,24 +0,0 @@ -.form { - padding: 2rem; - border-radius: 0.5rem; - background-color: var(--gray-alpha-100); -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - background-color: transparent; - font-family: var(--font-geist-sans); - border: 1px solid var(--gray-alpha-200); -} - -.form button:active:enabled { - background-color: var(--gray-alpha-200); -} diff --git a/examples/aws-nextjs/components/form.tsx b/examples/aws-nextjs/components/form.tsx deleted file mode 100644 index adaa22afdc..0000000000 --- a/examples/aws-nextjs/components/form.tsx +++ /dev/null @@ -1,30 +0,0 @@ -"use client"; - -import styles from "./form.module.css"; - -export default function Form({ url }: { url: string }) { - return ( - { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - - - ); -} diff --git a/examples/aws-nextjs/next.config.mjs b/examples/aws-nextjs/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-nextjs/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-nextjs/package.json b/examples/aws-nextjs/package.json deleted file mode 100644 index 5c3a68a25a..0000000000 --- a/examples/aws-nextjs/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-nextjs", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.668.0", - "@aws-sdk/s3-request-presigner": "^3.668.0", - "next": "14.2.15", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs/sst.config.ts b/examples/aws-nextjs/sst.config.ts deleted file mode 100644 index fd9b633273..0000000000 --- a/examples/aws-nextjs/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nextjs", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.Nextjs("MyWeb", { - link: [bucket] - }); - } -}); diff --git a/examples/aws-nextjs/tsconfig.json b/examples/aws-nextjs/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nuxt-container/.dockerignore b/examples/aws-nuxt-container/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-nuxt-container/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nuxt-container/.gitignore b/examples/aws-nuxt-container/.gitignore deleted file mode 100644 index cf7b41ed76..0000000000 --- a/examples/aws-nuxt-container/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Nuxt dev/build outputs -.output -.data -.nuxt -.nitro -.cache -dist - -# Node dependencies -node_modules - -# Logs -logs -*.log - -# Misc -.DS_Store -.fleet -.idea - -# Local env files -.env -.env.* -!.env.example - -# sst -.sst diff --git a/examples/aws-nuxt-container/Dockerfile b/examples/aws-nuxt-container/Dockerfile deleted file mode 100644 index eb842b02d5..0000000000 --- a/examples/aws-nuxt-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] diff --git a/examples/aws-nuxt-container/app.vue b/examples/aws-nuxt-container/app.vue deleted file mode 100644 index 66c4a4c37a..0000000000 --- a/examples/aws-nuxt-container/app.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/examples/aws-nuxt-container/nuxt.config.ts b/examples/aws-nuxt-container/nuxt.config.ts deleted file mode 100644 index 6425fa7cd8..0000000000 --- a/examples/aws-nuxt-container/nuxt.config.ts +++ /dev/null @@ -1,5 +0,0 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config -export default defineNuxtConfig({ - compatibilityDate: '2024-04-03', - devtools: { enabled: true } -}) diff --git a/examples/aws-nuxt-container/package.json b/examples/aws-nuxt-container/package.json deleted file mode 100644 index 962195505a..0000000000 --- a/examples/aws-nuxt-container/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-nuxt-container", - "private": true, - "type": "module", - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "postinstall": "nuxt prepare", - "preview": "nuxt preview" - }, - "dependencies": { - "ioredis": "^5.4.1", - "nuxt": "^3.13.0", - "sst": "file:../../sdk/js", - "vue": "latest", - "vue-router": "latest" - }, - "overrides": { - "nitropack": "npm:nitropack-nightly@latest" - } -} diff --git a/examples/aws-nuxt-container/public/favicon.ico b/examples/aws-nuxt-container/public/favicon.ico deleted file mode 100644 index 18993ad91c..0000000000 Binary files a/examples/aws-nuxt-container/public/favicon.ico and /dev/null differ diff --git a/examples/aws-nuxt-container/public/robots.txt b/examples/aws-nuxt-container/public/robots.txt deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-nuxt-container/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-nuxt-container/server/api/counter.ts b/examples/aws-nuxt-container/server/api/counter.ts deleted file mode 100644 index b46ecd1276..0000000000 --- a/examples/aws-nuxt-container/server/api/counter.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export default defineEventHandler(async () => { - return await redis.incr("counter"); -}) diff --git a/examples/aws-nuxt-container/server/tsconfig.json b/examples/aws-nuxt-container/server/tsconfig.json deleted file mode 100644 index b9ed69c19e..0000000000 --- a/examples/aws-nuxt-container/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -} diff --git a/examples/aws-nuxt-container/sst.config.ts b/examples/aws-nuxt-container/sst.config.ts deleted file mode 100644 index ef36277d5d..0000000000 --- a/examples/aws-nuxt-container/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nuxt-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-nuxt-container/tsconfig.json b/examples/aws-nuxt-container/tsconfig.json deleted file mode 100644 index a746f2a70c..0000000000 --- a/examples/aws-nuxt-container/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://nuxt.com/docs/guide/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/aws-nuxt-stream/.gitignore b/examples/aws-nuxt-stream/.gitignore deleted file mode 100644 index cf7b41ed76..0000000000 --- a/examples/aws-nuxt-stream/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Nuxt dev/build outputs -.output -.data -.nuxt -.nitro -.cache -dist - -# Node dependencies -node_modules - -# Logs -logs -*.log - -# Misc -.DS_Store -.fleet -.idea - -# Local env files -.env -.env.* -!.env.example - -# sst -.sst diff --git a/examples/aws-nuxt-stream/app.vue b/examples/aws-nuxt-stream/app.vue deleted file mode 100644 index c7e6100872..0000000000 --- a/examples/aws-nuxt-stream/app.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - diff --git a/examples/aws-nuxt-stream/nuxt.config.ts b/examples/aws-nuxt-stream/nuxt.config.ts deleted file mode 100644 index c67efbbe32..0000000000 --- a/examples/aws-nuxt-stream/nuxt.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config -export default defineNuxtConfig({ - ignore: ['**/.sst/**'], - compatibilityDate: '2025-05-15', - nitro: { - preset: 'aws-lambda', - awsLambda: { - streaming: true - } - }, - devtools: { enabled: true } -}) diff --git a/examples/aws-nuxt-stream/package.json b/examples/aws-nuxt-stream/package.json deleted file mode 100644 index 34569ea7a4..0000000000 --- a/examples/aws-nuxt-stream/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "nuxt-app", - "private": true, - "type": "module", - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "postinstall": "nuxt prepare", - "preview": "nuxt preview" - }, - "dependencies": { - "nuxt": "^3.15.5", - "sst": "file:../../sdk/js", - "vue": "latest", - "vue-router": "latest" - } -} diff --git a/examples/aws-nuxt-stream/public/favicon.ico b/examples/aws-nuxt-stream/public/favicon.ico deleted file mode 100644 index 18993ad91c..0000000000 Binary files a/examples/aws-nuxt-stream/public/favicon.ico and /dev/null differ diff --git a/examples/aws-nuxt-stream/public/robots.txt b/examples/aws-nuxt-stream/public/robots.txt deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-nuxt-stream/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-nuxt-stream/server/api/streaming.ts b/examples/aws-nuxt-stream/server/api/streaming.ts deleted file mode 100644 index d237103432..0000000000 --- a/examples/aws-nuxt-stream/server/api/streaming.ts +++ /dev/null @@ -1,20 +0,0 @@ -export default defineEventHandler(async (event) => { - const eventStream = createEventStream(event); - - eventStream.push("Start\n\n"); - - const interval = setInterval(async () => { - await eventStream.push(`Random: ${Math.random().toFixed(5)} `); - }, 1000); - - setTimeout(async () => { - clearInterval(interval); - await eventStream.close(); - }, 10000); - - eventStream.onClosed(() => { - clearInterval(interval); - }); - - return eventStream.send(); -}) diff --git a/examples/aws-nuxt-stream/server/tsconfig.json b/examples/aws-nuxt-stream/server/tsconfig.json deleted file mode 100644 index b9ed69c19e..0000000000 --- a/examples/aws-nuxt-stream/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -} diff --git a/examples/aws-nuxt-stream/sst.config.ts b/examples/aws-nuxt-stream/sst.config.ts deleted file mode 100644 index cb1615d890..0000000000 --- a/examples/aws-nuxt-stream/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS Nuxt streaming - * - * An example of how to use streaming with Nuxt.js. Uses `createEventStream` to stream data from a server API. - * - * ```ts title="server/api/streaming.ts" - * export default defineEventHandler(async (event) => { - * const eventStream = createEventStream(event); - * eventStream.push("Start\n\n"); - * - * // Send a message every second - * const interval = setInterval(async () => { - * await eventStream.push(`Random: ${Math.random().toFixed(5)} `); - * }, 1000); - * } - * ``` - * - * The client uses the Fetch API to consume the stream. - * - * ```vue title="app.vue" - * - * - * - * ``` - * - * Make sure to have your nuxt.config.ts set up to handle the streaming API correctly. - * - * ```ts title="nuxt.config.ts" {4-6} - * export default defineNuxtConfig({ - * nitro: { - * preset: 'aws-lambda', - * awsLambda: { - * streaming: true - * } - * } - * }); - * ``` - * - * You should see random numbers streamed to the page every second for 10 seconds. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - */ -export default $config({ - app(input) { - return { - name: "aws-nuxt-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Nuxt("MyWeb"); - }, -}); diff --git a/examples/aws-nuxt-stream/tsconfig.json b/examples/aws-nuxt-stream/tsconfig.json deleted file mode 100644 index a746f2a70c..0000000000 --- a/examples/aws-nuxt-stream/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://nuxt.com/docs/guide/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/aws-nuxt/.gitignore b/examples/aws-nuxt/.gitignore deleted file mode 100644 index cf7b41ed76..0000000000 --- a/examples/aws-nuxt/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Nuxt dev/build outputs -.output -.data -.nuxt -.nitro -.cache -dist - -# Node dependencies -node_modules - -# Logs -logs -*.log - -# Misc -.DS_Store -.fleet -.idea - -# Local env files -.env -.env.* -!.env.example - -# sst -.sst diff --git a/examples/aws-nuxt/app.vue b/examples/aws-nuxt/app.vue deleted file mode 100644 index 5947ef77d1..0000000000 --- a/examples/aws-nuxt/app.vue +++ /dev/null @@ -1,24 +0,0 @@ - - diff --git a/examples/aws-nuxt/nuxt.config.ts b/examples/aws-nuxt/nuxt.config.ts deleted file mode 100644 index f4c5faca38..0000000000 --- a/examples/aws-nuxt/nuxt.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config -export default defineNuxtConfig({ - compatibilityDate: '2024-04-03', - nitro: { - preset: 'aws-lambda' - }, - devtools: { enabled: true } -}) diff --git a/examples/aws-nuxt/package.json b/examples/aws-nuxt/package.json deleted file mode 100644 index 2001ffcfb3..0000000000 --- a/examples/aws-nuxt/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-nuxt", - "private": true, - "type": "module", - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "postinstall": "nuxt prepare", - "preview": "nuxt preview" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.651.1", - "@aws-sdk/s3-request-presigner": "^3.651.1", - "nuxt": "^3.13.0", - "sst": "file:../../sdk/js", - "vue": "latest", - "vue-router": "latest" - } -} diff --git a/examples/aws-nuxt/public/favicon.ico b/examples/aws-nuxt/public/favicon.ico deleted file mode 100644 index 18993ad91c..0000000000 Binary files a/examples/aws-nuxt/public/favicon.ico and /dev/null differ diff --git a/examples/aws-nuxt/public/robots.txt b/examples/aws-nuxt/public/robots.txt deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-nuxt/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-nuxt/server/api/presigned.ts b/examples/aws-nuxt/server/api/presigned.ts deleted file mode 100644 index b8c29a2e5b..0000000000 --- a/examples/aws-nuxt/server/api/presigned.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export default defineEventHandler(async () => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return await getSignedUrl(new S3Client({}), command); -}) diff --git a/examples/aws-nuxt/server/tsconfig.json b/examples/aws-nuxt/server/tsconfig.json deleted file mode 100644 index b9ed69c19e..0000000000 --- a/examples/aws-nuxt/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -} diff --git a/examples/aws-nuxt/sst.config.ts b/examples/aws-nuxt/sst.config.ts deleted file mode 100644 index 462d330512..0000000000 --- a/examples/aws-nuxt/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nuxt", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - new sst.aws.Nuxt("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-nuxt/tsconfig.json b/examples/aws-nuxt/tsconfig.json deleted file mode 100644 index a746f2a70c..0000000000 --- a/examples/aws-nuxt/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://nuxt.com/docs/guide/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/aws-open-search-local/.gitignore b/examples/aws-open-search-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-open-search-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-open-search-local/index.ts b/examples/aws-open-search-local/index.ts deleted file mode 100644 index a31d07708e..0000000000 --- a/examples/aws-open-search-local/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Resource } from "sst"; -import { Client } from "@opensearch-project/opensearch"; - -const client = new Client({ - node: Resource.MySearch.url, - auth: { - username: Resource.MySearch.username, - password: Resource.MySearch.password, - }, -}); - -export async function handler() { - // Add a document - await client.index({ - index: "my-index", - body: { message: "Hello world!" }, - }); - - // Search for documents - const result = await client.search({ - index: "my-index", - body: { query: { match: { message: "world" } } }, - }); - - return { - statusCode: 200, - body: - `Querying ${Resource.MySearch.url}\n\n` + - JSON.stringify(result.body.hits, null, 2), - }; -} diff --git a/examples/aws-open-search-local/package.json b/examples/aws-open-search-local/package.json deleted file mode 100644 index 599559797b..0000000000 --- a/examples/aws-open-search-local/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-open-search-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@opensearch-project/opensearch": "^3.5.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-open-search-local/sst.config.ts b/examples/aws-open-search-local/sst.config.ts deleted file mode 100644 index 19429f8814..0000000000 --- a/examples/aws-open-search-local/sst.config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// - -/** - * ## AWS OpenSearch local - * - * In this example, we connect to a locally running OpenSearch process for dev. While - * on deploy, we use AWS' OpenSearch Service. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) - * CLI to start a local container with OpenSearch. You don't have to use Docker, you can use - * any other way to run OpenSearch locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 9200:9200 \ - * -v $(pwd)/.sst/storage/opensearch:/usr/share/opensearch/data \ - * -e discovery.type=single-node \ - * -e plugins.security.disabled=true \ - * -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=^Passw0rd^ \ - * opensearchproject/opensearch:2.17.0 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `OpenSearch` component with the settings for - * the local OpenSearch instance. - * - * ```ts title="sst.config.ts" - * dev: { - * url: "http://localhost:9200", - * username: "admin", - * password: "^Passw0rd^" - * } - * ``` - * - * By providing the `dev` prop for OpenSearch, SST will use the local OpenSearch process and - * not deploy a new OpenSearch domain when running `sst dev`. - * - * It also allows us to access the local process through a Resource `link` without having - * to conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const client = new Client({ - * node: Resource.MySearch.url, - * auth: { - * username: Resource.MySearch.username, - * password: Resource.MySearch.password, - * }, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-open-search-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const search = new sst.aws.OpenSearch("MySearch", { - dev: { - url: "http://localhost:9200", - username: "admin", - password: "^Passw0rd^", - }, - }); - - new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - link: [search], - }); - }, -}); diff --git a/examples/aws-open-search-local/tsconfig.json b/examples/aws-open-search-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-open-search-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-open-search/index.ts b/examples/aws-open-search/index.ts deleted file mode 100644 index a31d07708e..0000000000 --- a/examples/aws-open-search/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Resource } from "sst"; -import { Client } from "@opensearch-project/opensearch"; - -const client = new Client({ - node: Resource.MySearch.url, - auth: { - username: Resource.MySearch.username, - password: Resource.MySearch.password, - }, -}); - -export async function handler() { - // Add a document - await client.index({ - index: "my-index", - body: { message: "Hello world!" }, - }); - - // Search for documents - const result = await client.search({ - index: "my-index", - body: { query: { match: { message: "world" } } }, - }); - - return { - statusCode: 200, - body: - `Querying ${Resource.MySearch.url}\n\n` + - JSON.stringify(result.body.hits, null, 2), - }; -} diff --git a/examples/aws-open-search/package.json b/examples/aws-open-search/package.json deleted file mode 100644 index 8776398850..0000000000 --- a/examples/aws-open-search/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-open-search", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "@opensearch-project/opensearch": "^3.5.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-open-search/sst.config.ts b/examples/aws-open-search/sst.config.ts deleted file mode 100644 index 009e1491fb..0000000000 --- a/examples/aws-open-search/sst.config.ts +++ /dev/null @@ -1,55 +0,0 @@ -/// - -/** - * ## AWS OpenSearch - * - * In this example we create a new OpenSearch domain, link it to a function, and - * then query it. - * - * Start by creating a new OpenSearch domain. - * - * ```ts title="sst.config.ts" - * const search = new sst.aws.OpenSearch("MySearch"); - * ``` - * - * Once linked to a function, we can connect to it. - * - * ```ts title="index.ts" - * import { Resource } from "sst"; - * import { Client } from "@opensearch-project/opensearch"; - * - * const client = new Client({ - * node: Resource.MySearch.url, - * auth: { - * username: Resource.MySearch.username, - * password: Resource.MySearch.password - * } - * }); - * ``` - * - * This is using the [OpenSearch JS SDK](https://docs.opensearch.org/docs/latest/clients/javascript/index) to connect to the OpenSearch domain.. - */ -export default $config({ - app(input) { - return { - name: "aws-open-search", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const search = new sst.aws.OpenSearch("MySearch"); - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - link: [search], - }); - - return { - app: app.url, - url: search.url, - username: search.username, - password: search.password, - }; - }, -}); diff --git a/examples/aws-planetscale-drizzle-mysql/.gitignore b/examples/aws-planetscale-drizzle-mysql/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-planetscale-drizzle-mysql/drizzle.config.ts b/examples/aws-planetscale-drizzle-mysql/drizzle.config.ts deleted file mode 100644 index 1fd6c1a4d3..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/drizzle.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "drizzle-kit"; -import { Resource } from "sst"; - -export default defineConfig({ - dialect: "mysql", - dbCredentials: { - url: `mysql://${Resource.Database.username}:${Resource.Database.password}@${Resource.Database.host}/${Resource.Database.database}?ssl={"rejectUnauthorized":true}`, - }, - schema: ["./src/schema.ts"], -}); diff --git a/examples/aws-planetscale-drizzle-mysql/package.json b/examples/aws-planetscale-drizzle-mysql/package.json deleted file mode 100644 index 760c01bdce..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-planetscale-drizzle-mysql", - "version": "0.0.0", - "scripts": { - "db": "sst shell drizzle-kit", - "db:push": "sst shell drizzle-kit push", - "db:studio": "sst shell drizzle-kit studio" - }, - "dependencies": { - "@planetscale/database": "^1.19.0", - "drizzle-kit": "^0.31.10", - "drizzle-orm": "^0.45.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-planetscale-drizzle-mysql/src/api.ts b/examples/aws-planetscale-drizzle-mysql/src/api.ts deleted file mode 100644 index 025826383a..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/src/api.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { db } from "./drizzle"; -import { todosTable } from "./schema"; -import { APIGatewayProxyHandlerV2 } from "aws-lambda"; - -export const handler: APIGatewayProxyHandlerV2 = async (evt) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todosTable).execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - if (evt.requestContext.http.method === "POST") { - await db.insert(todosTable).values({ title: "new todosTable" }).execute(); - return { - statusCode: 200, - body: "created", - }; - } - - return { - statusCode: 404, - body: "not found", - }; -}; diff --git a/examples/aws-planetscale-drizzle-mysql/src/drizzle.ts b/examples/aws-planetscale-drizzle-mysql/src/drizzle.ts deleted file mode 100644 index bd89904058..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/src/drizzle.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { drizzle } from "drizzle-orm/planetscale-serverless"; -import { Resource } from "sst"; - -export const db = drizzle({ - connection: { - host: Resource.Database.host, - username: Resource.Database.username, - password: Resource.Database.password, - }, -}); diff --git a/examples/aws-planetscale-drizzle-mysql/src/schema.ts b/examples/aws-planetscale-drizzle-mysql/src/schema.ts deleted file mode 100644 index d987a283ee..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/src/schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { mysqlTable, int, text, varchar } from "drizzle-orm/mysql-core"; - -export const todosTable = mysqlTable("todo", { - id: int("id").primaryKey().autoincrement(), - title: varchar("title", { length: 255 }).notNull(), - description: text("description"), -}); diff --git a/examples/aws-planetscale-drizzle-mysql/sst.config.ts b/examples/aws-planetscale-drizzle-mysql/sst.config.ts deleted file mode 100644 index 1778249823..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/sst.config.ts +++ /dev/null @@ -1,122 +0,0 @@ -/// - -/** - * ## AWS PlanetScale Drizzle MySQL - * - * In this example, we use PlanetScale with a branch-per-stage pattern. Every stage gets its own - * database branch β€” so each PR can have an isolated database. - * - * ```ts title="sst.config.ts" - * const db = planetscale.getDatabaseVitessOutput({ - * id: "mydb", - * organization: "myorg", - * }); - * - * const branch = - * $app.stage === "production" - * ? planetscale.getVitessBranchOutput({ - * id: db.defaultBranch, - * organization: db.organization, - * database: db.name, - * }) - * : new planetscale.VitessBranch("DatabaseBranch", { - * database: db.name, - * organization: db.organization, - * name: $app.stage, - * parentBranch: db.defaultBranch, - * }); - * ``` - * - * We then create a password and wrap it in a `Linkable` to link it to a function. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Function("Api", { - * handler: "src/api.handler", - * link: [database], - * url: true, - * }); - * ``` - * - * You can push your Drizzle schema changes to PlanetScale with: - * - * ```bash - * bun run db:push - * ``` - * - * In the function we use [Drizzle ORM](https://orm.drizzle.team) with the - * [`Resource`](/docs/reference/sdk/#resource) helper. - * - * ```ts title="src/drizzle.ts" - * import { drizzle } from "drizzle-orm/planetscale-serverless"; - * import { Resource } from "sst"; - * - * export const db = drizzle({ - * connection: { - * host: Resource.Database.host, - * username: Resource.Database.username, - * password: Resource.Database.password, - * }, - * }); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-planetscale-drizzle-mysql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - planetscale: "1.0.0", - }, - }; - }, - async run() { - const db = planetscale.getDatabaseVitessOutput({ - id: "example", - organization: "vimtor", - }); - - const branch = - $app.stage === "production" - ? planetscale.getVitessBranchOutput({ - id: db.defaultBranch, - organization: db.organization, - database: db.name, - }) - : new planetscale.VitessBranch("DatabaseBranch", { - database: db.name, - organization: db.organization, - name: $app.stage, - parentBranch: db.defaultBranch, - }); - - const password = new planetscale.VitessBranchPassword("DatabasePassword", { - database: db.name, - organization: db.organization, - branch: branch.name, - role: "admin", - name: `${$app.name}-${$app.stage}`, - }); - - const database = new sst.Linkable("Database", { - properties: { - host: password.accessHostUrl, - username: password.username, - password: password.plainText, - database: db.name, - port: 3306, - }, - }); - - const api = new sst.aws.Function("Api", { - handler: "src/api.handler", - link: [database], - url: true, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-planetscale-drizzle-mysql/tsconfig.json b/examples/aws-planetscale-drizzle-mysql/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-planetscale-drizzle-postgres/.gitignore b/examples/aws-planetscale-drizzle-postgres/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-planetscale-drizzle-postgres/drizzle.config.ts b/examples/aws-planetscale-drizzle-postgres/drizzle.config.ts deleted file mode 100644 index 03f4e900e9..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/drizzle.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "drizzle-kit"; -import { Resource } from "sst"; - -export default defineConfig({ - dialect: "postgresql", - dbCredentials: { - url: `postgresql://${Resource.Database.username}:${Resource.Database.password}@${Resource.Database.host}/${Resource.Database.database}?sslmode=require`, - }, - schema: ["./src/schema.ts"], -}); diff --git a/examples/aws-planetscale-drizzle-postgres/package.json b/examples/aws-planetscale-drizzle-postgres/package.json deleted file mode 100644 index 8c4f0ecd74..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-planetscale-drizzle-postgres", - "version": "0.0.0", - "scripts": { - "db": "sst shell drizzle-kit", - "db:push": "sst shell drizzle-kit push", - "db:studio": "sst shell drizzle-kit studio" - }, - "dependencies": { - "@neondatabase/serverless": "^1.0.2", - "drizzle-kit": "^0.31.10", - "drizzle-orm": "^0.45.1", - "postgres": "^3.4.5", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-planetscale-drizzle-postgres/src/api.ts b/examples/aws-planetscale-drizzle-postgres/src/api.ts deleted file mode 100644 index 025826383a..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/src/api.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { db } from "./drizzle"; -import { todosTable } from "./schema"; -import { APIGatewayProxyHandlerV2 } from "aws-lambda"; - -export const handler: APIGatewayProxyHandlerV2 = async (evt) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todosTable).execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - if (evt.requestContext.http.method === "POST") { - await db.insert(todosTable).values({ title: "new todosTable" }).execute(); - return { - statusCode: 200, - body: "created", - }; - } - - return { - statusCode: 404, - body: "not found", - }; -}; diff --git a/examples/aws-planetscale-drizzle-postgres/src/drizzle.ts b/examples/aws-planetscale-drizzle-postgres/src/drizzle.ts deleted file mode 100644 index a521bdc43f..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/src/drizzle.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Resource } from "sst"; -import { neon, neonConfig } from "@neondatabase/serverless"; -import { drizzle } from "drizzle-orm/neon-http"; - -// Required for PlanetScale Postgres connections -neonConfig.fetchEndpoint = (host) => `https://${host}/sql`; -const sql = neon( - `postgresql://${Resource.Database.username}:${Resource.Database.password}@${Resource.Database.host}:${Resource.Database.port}/postgres?sslmode=verify-full`, -); - -export const db = drizzle({ client: sql }); diff --git a/examples/aws-planetscale-drizzle-postgres/src/schema.ts b/examples/aws-planetscale-drizzle-postgres/src/schema.ts deleted file mode 100644 index f75c5cd19e..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/src/schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core"; - -export const todosTable = pgTable("todo", { - id: serial("id").primaryKey(), - title: varchar("title", { length: 255 }).notNull(), - description: text("description"), -}); diff --git a/examples/aws-planetscale-drizzle-postgres/sst.config.ts b/examples/aws-planetscale-drizzle-postgres/sst.config.ts deleted file mode 100644 index 3128227068..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/sst.config.ts +++ /dev/null @@ -1,128 +0,0 @@ -/// - -/** - * ## AWS PlanetScale Drizzle Postgres - * - * In this example, we use PlanetScale Postgres with a branch-per-stage pattern. Every stage - * gets its own database branch β€” so each PR can have an isolated database. - * - * ```ts title="sst.config.ts" - * const db = planetscale.getDatabasePostgresOutput({ - * id: "mydb", - * organization: "myorg", - * }); - * - * const branch = - * $app.stage === "production" - * ? planetscale.getPostgresBranchOutput({ - * id: db.defaultBranch, - * organization: db.organization, - * database: db.name, - * }) - * : new planetscale.PostgresBranch("DatabaseBranch", { - * database: db.name, - * organization: db.organization, - * name: $app.stage, - * parentBranch: db.defaultBranch, - * }); - * ``` - * - * We then create a role and wrap it in a `Linkable` to link it to a function. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Function("Api", { - * handler: "src/api.handler", - * link: [database], - * url: true, - * }); - * ``` - * - * You can push your Drizzle schema changes to PlanetScale with: - * - * ```bash - * bun run db:push - * ``` - * - * In the function we use [Drizzle ORM](https://orm.drizzle.team) with the - * [`Resource`](/docs/reference/sdk/#resource) helper. - * - * ```ts title="src/drizzle.ts" - * import { drizzle } from "drizzle-orm/postgres-js"; - * import { Resource } from "sst"; - * import postgres from "postgres"; - * - * const client = postgres({ - * host: Resource.Database.host, - * username: Resource.Database.username, - * password: Resource.Database.password, - * database: Resource.Database.database, - * }); - * - * export const db = drizzle(client); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-planetscale-drizzle-postgres", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - planetscale: "1.0.0", - }, - }; - }, - async run() { - const db = planetscale.getDatabasePostgresOutput({ - id: "mydb", - organization: "myorg", - }); - - const branch = - $app.stage === "production" - ? planetscale.getPostgresBranchOutput({ - id: db.defaultBranch, - organization: db.organization, - database: db.name, - }) - : new planetscale.PostgresBranch("DatabaseBranch", { - database: db.name, - organization: db.organization, - name: $app.stage, - parentBranch: db.defaultBranch, - }); - - const role = new planetscale.PostgresBranchRole("DatabaseRole", { - database: db.name, - organization: db.organization, - branch: branch.name, - name: `${$app.name}-${$app.stage}`, - inheritedRoles: [ - "pg_read_all_data", - "pg_write_all_data", - "postgres", // Only needed for pushing schema changes - ], - }); - - const database = new sst.Linkable("Database", { - properties: { - host: role.accessHostUrl, - username: role.username, - password: role.password, - database: role.databaseName, - port: 6432, // Use 5432 for direct connection instead of PgBouncer - }, - }); - - const api = new sst.aws.Function("Api", { - handler: "src/api.handler", - link: [database], - url: true, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-planetscale-drizzle-postgres/tsconfig.json b/examples/aws-planetscale-drizzle-postgres/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-policy-pack/package.json b/examples/aws-policy-pack/package.json deleted file mode 100644 index b984f65082..0000000000 --- a/examples/aws-policy-pack/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-policy-pack", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-policy-pack/policy-pack/.gitignore b/examples/aws-policy-pack/policy-pack/.gitignore deleted file mode 100644 index 6ba7daaf94..0000000000 --- a/examples/aws-policy-pack/policy-pack/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/bin/ -/node_modules/ -bun.lock diff --git a/examples/aws-policy-pack/policy-pack/PulumiPolicy.yaml b/examples/aws-policy-pack/policy-pack/PulumiPolicy.yaml deleted file mode 100644 index c6c1e5b116..0000000000 --- a/examples/aws-policy-pack/policy-pack/PulumiPolicy.yaml +++ /dev/null @@ -1,3 +0,0 @@ -description: A minimal Policy Pack for AWS using TypeScript. -runtime: nodejs -main: dist/index.js diff --git a/examples/aws-policy-pack/policy-pack/index.ts b/examples/aws-policy-pack/policy-pack/index.ts deleted file mode 100644 index a684f3ff21..0000000000 --- a/examples/aws-policy-pack/policy-pack/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import * as aws from "@pulumi/aws"; -import { PolicyPack, validateResourceOfType } from "@pulumi/policy"; - -new PolicyPack("iam-roles-policies", { - policies: [ - { - name: "iam-role-requires-permission-boundary", - description: "IAM roles must have a permission boundary.", - enforcementLevel: "mandatory", - validateResource: validateResourceOfType( - aws.iam.Role, - (role, _args, reportViolation) => { - if (!role.permissionsBoundary) { - reportViolation( - "Permission boundaries are important for limiting the maximum permissions that can be granted to an IAM role." - ); - } - }, - ), - }, - { - name: "iam-role-policy-no-wildcard-resources", - description: - "IAM role policies should avoid wildcard resources for better security.", - enforcementLevel: "advisory", - validateResource: validateResourceOfType( - aws.iam.RolePolicy, - (policy, _args, reportViolation) => { - if (policy.policy && typeof policy.policy === "string") { - try { - const policyDoc = JSON.parse(policy.policy); - const statements = policyDoc.Statement || []; - for (const statement of statements) { - const resources = Array.isArray(statement.Resource) - ? statement.Resource - : [statement.Resource]; - if (resources.includes("*")) { - reportViolation( - "IAM role policies should not use wildcard (*) for resources. Specify explicit resource ARNs to follow the principle of least privilege." - ); - break; - } - } - } catch (e) {} - } - }, - ), - }, - ], -}); diff --git a/examples/aws-policy-pack/policy-pack/package.json b/examples/aws-policy-pack/policy-pack/package.json deleted file mode 100644 index 2210bd57a9..0000000000 --- a/examples/aws-policy-pack/policy-pack/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "policy-pack", - "version": "0.0.1", - "dependencies": { - "@pulumi/aws": "^6.0.0", - "@pulumi/policy": "^1.20.0" - }, - "devDependencies": { - "@types/node": "^10.0.0" - } -} diff --git a/examples/aws-policy-pack/policy-pack/tsconfig.json b/examples/aws-policy-pack/policy-pack/tsconfig.json deleted file mode 100644 index ecb951b692..0000000000 --- a/examples/aws-policy-pack/policy-pack/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "CommonJS", - "moduleResolution": "node", - "declaration": true, - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "outDir": "dist" - }, - "include": ["index.ts"] -} diff --git a/examples/aws-policy-pack/sst.config.ts b/examples/aws-policy-pack/sst.config.ts deleted file mode 100644 index 7430ea092a..0000000000 --- a/examples/aws-policy-pack/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## Policy Pack Validation - * - * You can use Pulumi Policy Packs to enforce compliance and security policies on your - * infrastructure before deployment. Created policies with and enforcement level of "mandatory" will block the deployment. - * - * This example shows how to use the `--policy` flag with `sst diff` and `sst deploy` to - * validate your infrastructure against a policy pack. - * - * Run the diff command with a policy pack to preview changes and check for violations: - * - * ```bash - * sst diff --policy ./policy-pack --stage prod - * ``` - * - * Deploy with policy validation: - * - * ```bash - * sst deploy --policy ./policy-pack --stage prod - * ``` - * - * To get started you can create a new policy pack for AWS using: - * - * ```bash - * mkdir policy-pack - * cd policy-pack - * pulumi policy new aws-typescript - * ``` - * - * The example policy pack (check the full example) enforces that all IAM roles must have a permission boundary, blocking the deployment in this sst example. - */ -export default $config({ - app(input) { - return { - name: "aws-policy-pack", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const role = new aws.iam.Role("ExampleRoleWithBoundary", { - assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ - Service: "lambda.amazonaws.com", - }), - // To make this compliant with the policy example, uncomment the following line: - // permissionsBoundary: "arn:aws:iam::aws:policy/PowerUserAccess", - }); - - new aws.iam.RolePolicy("S3GetItemPolicy", { - role: role.id, - policy: aws.iam.getPolicyDocumentOutput({ - statements: [ - { - actions: ["s3:GetObject"], - resources: ["*"], - }, - ], - }).json, - }); - }, -}); diff --git a/examples/aws-policy-pack/tsconfig.json b/examples/aws-policy-pack/tsconfig.json deleted file mode 100644 index 7811c6e56f..0000000000 --- a/examples/aws-policy-pack/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "node", - "esModuleInterop": true, - "strict": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "outDir": ".build" - }, - "include": ["**/*.ts"] -} diff --git a/examples/aws-postgres-local/.gitignore b/examples/aws-postgres-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-postgres-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-postgres-local/index.ts b/examples/aws-postgres-local/index.ts deleted file mode 100644 index 318f08fefa..0000000000 --- a/examples/aws-postgres-local/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Pool } from "pg"; -import { Resource } from "sst"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export async function handler() { - const client = await pool.connect(); - const result = await client.query('SELECT NOW()'); - client.release(); - - return { - statusCode: 200, - body: `Querying ${Resource.MyPostgres.host}\n\n` - + result.rows[0].now, - }; -} diff --git a/examples/aws-postgres-local/package.json b/examples/aws-postgres-local/package.json deleted file mode 100644 index b5d4a4644c..0000000000 --- a/examples/aws-postgres-local/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-postgres-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "pg": "^8.13.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/pg": "^8.11.10" - } -} diff --git a/examples/aws-postgres-local/sst.config.ts b/examples/aws-postgres-local/sst.config.ts deleted file mode 100644 index a88ea4a37b..0000000000 --- a/examples/aws-postgres-local/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS Postgres local - * - * In this example, we connect to a locally running Postgres instance for dev. While - * on deploy, we use RDS. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local container with Postgres. You don't have to use Docker, you can use - * Postgres.app or any other way to run Postgres locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 5432:5432 \ - * -v $(pwd)/.sst/storage/postgres:/var/lib/postgresql/data \ - * -e POSTGRES_USER=postgres \ - * -e POSTGRES_PASSWORD=password \ - * -e POSTGRES_DB=local \ - * postgres:16.4 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `Postgres` component with the settings for the - * local Postgres instance. - * - * ```ts title="sst.config.ts" - * dev: { - * username: "postgres", - * password: "password", - * database: "local", - * port: 5432, - * } - * ``` - * - * By providing the `dev` prop for Postgres, SST will use the local Postgres instance and - * not deploy a new RDS database when running `sst dev`. - * - * It also allows us to access the database through a Resource `link` without having to - * conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const pool = new Pool({ - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-postgres-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const rds = new sst.aws.Postgres("MyPostgres", { - dev: { - username: "postgres", - password: "password", - database: "local", - host: "localhost", - port: 5432, - }, - vpc, - }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [rds], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-postgres-local/tsconfig.json b/examples/aws-postgres-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-postgres-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-postgres-shared-parameter-group/sst.config.ts b/examples/aws-postgres-shared-parameter-group/sst.config.ts deleted file mode 100644 index ab0e7dc8e6..0000000000 --- a/examples/aws-postgres-shared-parameter-group/sst.config.ts +++ /dev/null @@ -1,72 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-postgres-shared-pg", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - // Alternative: create a standalone parameter group and reference it - // - // const sharedParameterGroup = new aws.rds.ParameterGroup( - // "SharedParameterGroup", - // { - // name: "shared-parameter-group", - // family: "postgres17", - // parameters: [ - // { name: "rds.force_ssl", value: "0" }, - // { name: "log_min_duration_statement", value: "1000" }, - // ], - // }, - // ); - // - // Then use in each Postgres: - // transform: { - // instance: { parameterGroupName: sharedParameterGroup.name }, - // } - - // First database with custom parameters - const db1 = new sst.aws.Postgres("Database1", { - vpc, - transform: { - parameterGroup: { - parameters: [ - { - name: "rds.force_ssl", - value: "0", - }, - { - name: "rds.logical_replication", - value: "1", - applyMethod: "pending-reboot", - }, - { - name: "log_min_duration_statement", - value: "1000", - }, - ], - }, - }, - }); - - // Second database reuses db1's parameter group - const db2 = new sst.aws.Postgres("Database2", { - vpc, - transform: { - instance: { - parameterGroupName: db1.nodes.instance.parameterGroupName, - }, - }, - }); - - return { - db1Host: db1.host, - db2Host: db2.host, - }; - }, -}); diff --git a/examples/aws-postgres/index.ts b/examples/aws-postgres/index.ts deleted file mode 100644 index 1c6dfd2185..0000000000 --- a/examples/aws-postgres/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import pg from "pg"; -import { Resource } from "sst"; -const { Client } = pg; -const client = new Client({ - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, -}); -await client.connect(); - -export async function handler() { - const res = await client.query("SELECT $1::text as message", [ - "Hello world!", - ]); - return { - statusCode: 200, - body: res.rows[0].message, - }; -} diff --git a/examples/aws-postgres/package.json b/examples/aws-postgres/package.json deleted file mode 100644 index b90c7345e2..0000000000 --- a/examples/aws-postgres/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-postgres", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "pg": "^8.13.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-postgres/sst.config.ts b/examples/aws-postgres/sst.config.ts deleted file mode 100644 index 8a82eda60b..0000000000 --- a/examples/aws-postgres/sst.config.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-postgres", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const postgres = new sst.aws.Postgres("MyDatabase", { - vpc, - }); - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - link: [postgres], - nodejs: { - esbuild: { - external: ["pg"], - }, - }, - }); - - return { - app: app.url, - host: postgres.host, - port: postgres.port, - username: postgres.username, - password: postgres.password, - database: postgres.database, - }; - }, -}); diff --git a/examples/aws-pothos-graphql/.gitignore b/examples/aws-pothos-graphql/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-pothos-graphql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-pothos-graphql/client.ts b/examples/aws-pothos-graphql/client.ts deleted file mode 100644 index 4216224d56..0000000000 --- a/examples/aws-pothos-graphql/client.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Resource } from "sst"; -import { createClient } from "./graphql/genql"; - -const client = createClient({ - url: `${Resource.Api.url}/graphql`, -}); - -export async function handler() { - const createGiraffe = await client.mutation({ - createGiraffe: { - __args: { - name: "Jonny", - }, - name: true, - }, - }); - - return { - statusCode: 200, - body: createGiraffe, - }; -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/batcher.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/batcher.ts deleted file mode 100644 index c092551010..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/batcher.ts +++ /dev/null @@ -1,275 +0,0 @@ -// @ts-nocheck -import type { GraphqlOperation } from './generateGraphqlOperation' -import { GenqlError } from './error' - -type Variables = Record - -type QueryError = Error & { - message: string - - locations?: Array<{ - line: number - column: number - }> - path?: any - rid: string - details?: Record -} -type Result = { - data: Record - errors: Array -} -type Fetcher = ( - batchedQuery: GraphqlOperation | Array, -) => Promise> -type Options = { - batchInterval?: number - shouldBatch?: boolean - maxBatchSize?: number -} -type Queue = Array<{ - request: GraphqlOperation - resolve: (...args: Array) => any - reject: (...args: Array) => any -}> - -/** - * takes a list of requests (queue) and batches them into a single server request. - * It will then resolve each individual requests promise with the appropriate data. - * @private - * @param {QueryBatcher} client - the client to use - * @param {Queue} queue - the list of requests to batch - */ -function dispatchQueueBatch(client: QueryBatcher, queue: Queue): void { - let batchedQuery: any = queue.map((item) => item.request) - - if (batchedQuery.length === 1) { - batchedQuery = batchedQuery[0] - } - (() => { - try { - return client.fetcher(batchedQuery); - } catch(e) { - return Promise.reject(e); - } - })().then((responses: any) => { - if (queue.length === 1 && !Array.isArray(responses)) { - if (responses.errors && responses.errors.length) { - queue[0].reject( - new GenqlError(responses.errors, responses.data), - ) - return - } - - queue[0].resolve(responses) - return - } else if (responses.length !== queue.length) { - throw new Error('response length did not match query length') - } - - for (let i = 0; i < queue.length; i++) { - if (responses[i].errors && responses[i].errors.length) { - queue[i].reject( - new GenqlError(responses[i].errors, responses[i].data), - ) - } else { - queue[i].resolve(responses[i]) - } - } - }) - .catch((e) => { - for (let i = 0; i < queue.length; i++) { - queue[i].reject(e) - } - }); -} - -/** - * creates a list of requests to batch according to max batch size. - * @private - * @param {QueryBatcher} client - the client to create list of requests from from - * @param {Options} options - the options for the batch - */ -function dispatchQueue(client: QueryBatcher, options: Options): void { - const queue = client._queue - const maxBatchSize = options.maxBatchSize || 0 - client._queue = [] - - if (maxBatchSize > 0 && maxBatchSize < queue.length) { - for (let i = 0; i < queue.length / maxBatchSize; i++) { - dispatchQueueBatch( - client, - queue.slice(i * maxBatchSize, (i + 1) * maxBatchSize), - ) - } - } else { - dispatchQueueBatch(client, queue) - } -} -/** - * Create a batcher client. - * @param {Fetcher} fetcher - A function that can handle the network requests to graphql endpoint - * @param {Options} options - the options to be used by client - * @param {boolean} options.shouldBatch - should the client batch requests. (default true) - * @param {integer} options.batchInterval - duration (in MS) of each batch window. (default 6) - * @param {integer} options.maxBatchSize - max number of requests in a batch. (default 0) - * @param {boolean} options.defaultHeaders - default headers to include with every request - * - * @example - * const fetcher = batchedQuery => fetch('path/to/graphql', { - * method: 'post', - * headers: { - * Accept: 'application/json', - * 'Content-Type': 'application/json', - * }, - * body: JSON.stringify(batchedQuery), - * credentials: 'include', - * }) - * .then(response => response.json()) - * - * const client = new QueryBatcher(fetcher, { maxBatchSize: 10 }) - */ - -export class QueryBatcher { - fetcher: Fetcher - _options: Options - _queue: Queue - - constructor( - fetcher: Fetcher, - { - batchInterval = 6, - shouldBatch = true, - maxBatchSize = 0, - }: Options = {}, - ) { - this.fetcher = fetcher - this._options = { - batchInterval, - shouldBatch, - maxBatchSize, - } - this._queue = [] - } - - /** - * Fetch will send a graphql request and return the parsed json. - * @param {string} query - the graphql query. - * @param {Variables} variables - any variables you wish to inject as key/value pairs. - * @param {[string]} operationName - the graphql operationName. - * @param {Options} overrides - the client options overrides. - * - * @return {promise} resolves to parsed json of server response - * - * @example - * client.fetch(` - * query getHuman($id: ID!) { - * human(id: $id) { - * name - * height - * } - * } - * `, { id: "1001" }, 'getHuman') - * .then(human => { - * // do something with human - * console.log(human); - * }); - */ - fetch( - query: string, - variables?: Variables, - operationName?: string, - overrides: Options = {}, - ): Promise { - const request: GraphqlOperation = { - query, - } - const options = Object.assign({}, this._options, overrides) - - if (variables) { - request.variables = variables - } - - if (operationName) { - request.operationName = operationName - } - - const promise = new Promise((resolve, reject) => { - this._queue.push({ - request, - resolve, - reject, - }) - - if (this._queue.length === 1) { - if (options.shouldBatch) { - setTimeout( - () => dispatchQueue(this, options), - options.batchInterval, - ) - } else { - dispatchQueue(this, options) - } - } - }) - return promise - } - - /** - * Fetch will send a graphql request and return the parsed json. - * @param {string} query - the graphql query. - * @param {Variables} variables - any variables you wish to inject as key/value pairs. - * @param {[string]} operationName - the graphql operationName. - * @param {Options} overrides - the client options overrides. - * - * @return {Promise>} resolves to parsed json of server response - * - * @example - * client.forceFetch(` - * query getHuman($id: ID!) { - * human(id: $id) { - * name - * height - * } - * } - * `, { id: "1001" }, 'getHuman') - * .then(human => { - * // do something with human - * console.log(human); - * }); - */ - forceFetch( - query: string, - variables?: Variables, - operationName?: string, - overrides: Options = {}, - ): Promise { - const request: GraphqlOperation = { - query, - } - const options = Object.assign({}, this._options, overrides, { - shouldBatch: false, - }) - - if (variables) { - request.variables = variables - } - - if (operationName) { - request.operationName = operationName - } - - const promise = new Promise((resolve, reject) => { - const client = new QueryBatcher(this.fetcher, this._options) - client._queue = [ - { - request, - resolve, - reject, - }, - ] - dispatchQueue(client, options) - }) - return promise - } -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/fetcher.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/fetcher.ts deleted file mode 100644 index 74e6d4ce9a..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/fetcher.ts +++ /dev/null @@ -1,97 +0,0 @@ -// @ts-nocheck -import { QueryBatcher } from './batcher' - -import type { ClientOptions } from './createClient' -import type { GraphqlOperation } from './generateGraphqlOperation' -import { GenqlError } from './error' - -export interface Fetcher { - (gql: GraphqlOperation): Promise -} - -export type BatchOptions = { - batchInterval?: number // ms - maxBatchSize?: number -} - -const DEFAULT_BATCH_OPTIONS = { - maxBatchSize: 10, - batchInterval: 40, -} - -export const createFetcher = ({ - url, - headers = {}, - fetcher, - fetch: _fetch, - batch = false, - ...rest -}: ClientOptions): Fetcher => { - if (!url && !fetcher) { - throw new Error('url or fetcher is required') - } - - fetcher = fetcher || (async (body) => { - let headersObject = - typeof headers == 'function' ? await headers() : headers - headersObject = headersObject || {} - if (typeof fetch === 'undefined' && !_fetch) { - throw new Error( - 'Global `fetch` function is not available, pass a fetch polyfill to Genql `createClient`', - ) - } - let fetchImpl = _fetch || fetch - const res = await fetchImpl(url!, { - headers: { - 'Content-Type': 'application/json', - ...headersObject, - }, - method: 'POST', - body: JSON.stringify(body), - ...rest, - }) - if (!res.ok) { - throw new Error(`${res.statusText}: ${await res.text()}`) - } - const json = await res.json() - return json - }) - - if (!batch) { - return async (body) => { - const json = await fetcher!(body) - if (Array.isArray(json)) { - return json.map((json) => { - if (json?.errors?.length) { - throw new GenqlError(json.errors || [], json.data) - } - return json.data - }) - } else { - if (json?.errors?.length) { - throw new GenqlError(json.errors || [], json.data) - } - return json.data - } - } - } - - const batcher = new QueryBatcher( - async (batchedQuery) => { - // console.log(batchedQuery) // [{ query: 'query{user{age}}', variables: {} }, ...] - const json = await fetcher!(batchedQuery) - return json as any - }, - batch === true ? DEFAULT_BATCH_OPTIONS : batch, - ) - - return async ({ query, variables }) => { - const json = await batcher.fetch(query, variables) - if (json?.data) { - return json.data - } - throw new Error( - 'Genql batch fetcher returned unexpected result ' + JSON.stringify(json), - ) - } -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/linkTypeMap.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/linkTypeMap.ts deleted file mode 100644 index 3e12c54598..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/linkTypeMap.ts +++ /dev/null @@ -1,156 +0,0 @@ -// @ts-nocheck -import type { - CompressedType, - CompressedTypeMap, - LinkedArgMap, - LinkedField, - LinkedType, - LinkedTypeMap, -} from './types' - -export interface PartialLinkedFieldMap { - [field: string]: { - type: string - args?: LinkedArgMap - } -} - -export const linkTypeMap = ( - typeMap: CompressedTypeMap, -): LinkedTypeMap => { - const indexToName: Record = Object.assign( - {}, - ...Object.keys(typeMap.types).map((k, i) => ({ [i]: k })), - ) - - let intermediaryTypeMap = Object.assign( - {}, - ...Object.keys(typeMap.types || {}).map( - (k): Record => { - const type: CompressedType = typeMap.types[k]! - const fields = type || {} - return { - [k]: { - name: k, - // type scalar properties - scalar: Object.keys(fields).filter((f) => { - const [type] = fields[f] || [] - - const isScalar = - type && typeMap.scalars.includes(type) - if (!isScalar) { - return false - } - const args = fields[f]?.[1] - const argTypes = Object.values(args || {}) - .map((x) => x?.[1]) - .filter(Boolean) - - const hasRequiredArgs = argTypes.some( - (str) => str && str.endsWith('!'), - ) - if (hasRequiredArgs) { - return false - } - return true - }), - // fields with corresponding `type` and `args` - fields: Object.assign( - {}, - ...Object.keys(fields).map( - (f): PartialLinkedFieldMap => { - const [typeIndex, args] = fields[f] || [] - if (typeIndex == null) { - return {} - } - return { - [f]: { - // replace index with type name - type: indexToName[typeIndex], - args: Object.assign( - {}, - ...Object.keys(args || {}).map( - (k) => { - // if argTypeString == argTypeName, argTypeString is missing, need to readd it - if (!args || !args[k]) { - return - } - const [ - argTypeName, - argTypeString, - ] = args[k] as any - return { - [k]: [ - indexToName[ - argTypeName - ], - argTypeString || - indexToName[ - argTypeName - ], - ], - } - }, - ), - ), - }, - } - }, - ), - ), - }, - } - }, - ), - ) - const res = resolveConcreteTypes(intermediaryTypeMap) - return res -} - -// replace typename with concrete type -export const resolveConcreteTypes = (linkedTypeMap: LinkedTypeMap) => { - Object.keys(linkedTypeMap).forEach((typeNameFromKey) => { - const type: LinkedType = linkedTypeMap[typeNameFromKey]! - // type.name = typeNameFromKey - if (!type.fields) { - return - } - - const fields = type.fields - - Object.keys(fields).forEach((f) => { - const field: LinkedField = fields[f]! - - if (field.args) { - const args = field.args - Object.keys(args).forEach((key) => { - const arg = args[key] - - if (arg) { - const [typeName] = arg - - if (typeof typeName === 'string') { - if (!linkedTypeMap[typeName]) { - linkedTypeMap[typeName] = { name: typeName } - } - - arg[0] = linkedTypeMap[typeName]! - } - } - }) - } - - const typeName = field.type as LinkedType | string - - if (typeof typeName === 'string') { - if (!linkedTypeMap[typeName]) { - linkedTypeMap[typeName] = { name: typeName } - } - - field.type = linkedTypeMap[typeName]! - } - }) - }) - - return linkedTypeMap -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/typeSelection.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/typeSelection.ts deleted file mode 100644 index a021d00bf5..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/typeSelection.ts +++ /dev/null @@ -1,95 +0,0 @@ -// @ts-nocheck -////////////////////////////////////////////////// - -// SOME THINGS TO KNOW BEFORE DIVING IN -/* -0. DST is the request type, SRC is the response type - -1. FieldsSelection uses an object because currently is impossible to make recursive types - -2. FieldsSelection is a recursive type that makes a type based on request type and fields - -3. HandleObject handles object types - -4. Handle__scalar adds all scalar properties excluding non scalar props -*/ - -export type FieldsSelection | undefined, DST> = { - scalar: SRC - union: Handle__isUnion - object: HandleObject - array: SRC extends Nil - ? never - : SRC extends Array - ? Array> - : never - __scalar: Handle__scalar - never: never -}[DST extends Nil - ? 'never' - : DST extends false | 0 - ? 'never' - : SRC extends Scalar - ? 'scalar' - : SRC extends any[] - ? 'array' - : SRC extends { __isUnion?: any } - ? 'union' - : DST extends { __scalar?: any } - ? '__scalar' - : DST extends {} - ? 'object' - : 'never'] - -type HandleObject, DST> = DST extends boolean - ? SRC - : SRC extends Nil - ? never - : Pick< - { - // using keyof SRC to maintain ?: relations of SRC type - [Key in keyof SRC]: Key extends keyof DST - ? FieldsSelection> - : SRC[Key] - }, - Exclude - // { - // // remove falsy values - // [Key in keyof DST]: DST[Key] extends false | 0 ? never : Key - // }[keyof DST] - > - -type Handle__scalar, DST> = SRC extends Nil - ? never - : Pick< - // continue processing fields that are in DST, directly pass SRC type if not in DST - { - [Key in keyof SRC]: Key extends keyof DST - ? FieldsSelection - : SRC[Key] - }, - // remove fields that are not scalars or are not in DST - { - [Key in keyof SRC]: SRC[Key] extends Nil - ? never - : Key extends FieldsToRemove - ? never - : SRC[Key] extends Scalar - ? Key - : Key extends keyof DST - ? Key - : never - }[keyof SRC] - > - -type Handle__isUnion, DST> = SRC extends Nil - ? never - : Omit // just return the union type - -type Scalar = string | number | Date | boolean | null | undefined - -type Anify = { [P in keyof T]?: any } - -type FieldsToRemove = '__isUnion' | '__scalar' | '__name' | '__args' - -type Nil = undefined | null diff --git a/examples/aws-pothos-graphql/graphql/genql/schema.graphql b/examples/aws-pothos-graphql/graphql/genql/schema.graphql deleted file mode 100644 index 017afa4426..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/schema.graphql +++ /dev/null @@ -1,12 +0,0 @@ -"""Long necks, cool patterns, taller than you.""" -type Giraffe { - name: String! -} - -type Mutation { - createGiraffe(name: String!): Giraffe! -} - -type Query { - giraffe: Giraffe! -} \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/genql/schema.ts b/examples/aws-pothos-graphql/graphql/genql/schema.ts deleted file mode 100644 index 9677818f0e..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/schema.ts +++ /dev/null @@ -1,70 +0,0 @@ -// @ts-nocheck -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type Scalars = { - String: string, - Boolean: boolean, -} - - -/** Long necks, cool patterns, taller than you. */ -export interface Giraffe { - name: Scalars['String'] - __typename: 'Giraffe' -} - -export interface Mutation { - createGiraffe: Giraffe - __typename: 'Mutation' -} - -export interface Query { - giraffe: Giraffe - __typename: 'Query' -} - - -/** Long necks, cool patterns, taller than you. */ -export interface GiraffeGenqlSelection{ - name?: boolean | number - __typename?: boolean | number - __scalar?: boolean | number -} - -export interface MutationGenqlSelection{ - createGiraffe?: (GiraffeGenqlSelection & { __args: {name: Scalars['String']} }) - __typename?: boolean | number - __scalar?: boolean | number -} - -export interface QueryGenqlSelection{ - giraffe?: GiraffeGenqlSelection - __typename?: boolean | number - __scalar?: boolean | number -} - - - const Giraffe_possibleTypes: string[] = ['Giraffe'] - export const isGiraffe = (obj?: { __typename?: any } | null): obj is Giraffe => { - if (!obj?.__typename) throw new Error('__typename is missing in "isGiraffe"') - return Giraffe_possibleTypes.includes(obj.__typename) - } - - - - const Mutation_possibleTypes: string[] = ['Mutation'] - export const isMutation = (obj?: { __typename?: any } | null): obj is Mutation => { - if (!obj?.__typename) throw new Error('__typename is missing in "isMutation"') - return Mutation_possibleTypes.includes(obj.__typename) - } - - - - const Query_possibleTypes: string[] = ['Query'] - export const isQuery = (obj?: { __typename?: any } | null): obj is Query => { - if (!obj?.__typename) throw new Error('__typename is missing in "isQuery"') - return Query_possibleTypes.includes(obj.__typename) - } - \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/genql/types.ts b/examples/aws-pothos-graphql/graphql/genql/types.ts deleted file mode 100644 index 8ddc017cce..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/types.ts +++ /dev/null @@ -1,40 +0,0 @@ -export default { - "scalars": [ - 1, - 4 - ], - "types": { - "Giraffe": { - "name": [ - 1 - ], - "__typename": [ - 1 - ] - }, - "String": {}, - "Mutation": { - "createGiraffe": [ - 0, - { - "name": [ - 1, - "String!" - ] - } - ], - "__typename": [ - 1 - ] - }, - "Query": { - "giraffe": [ - 0 - ], - "__typename": [ - 1 - ] - }, - "Boolean": {} - } -} \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/schema.graphql b/examples/aws-pothos-graphql/graphql/schema.graphql deleted file mode 100644 index 017afa4426..0000000000 --- a/examples/aws-pothos-graphql/graphql/schema.graphql +++ /dev/null @@ -1,12 +0,0 @@ -"""Long necks, cool patterns, taller than you.""" -type Giraffe { - name: String! -} - -type Mutation { - createGiraffe(name: String!): Giraffe! -} - -type Query { - giraffe: Giraffe! -} \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/urql.ts b/examples/aws-pothos-graphql/graphql/urql.ts deleted file mode 100644 index 60833df69e..0000000000 --- a/examples/aws-pothos-graphql/graphql/urql.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { - useQuery, - useClient, - createRequest, - RequestPolicy, - OperationResult, - UseMutationState, - OperationContext, - UseMutationResponse, -} from "urql"; -import { useEffect, useState, useCallback, useRef } from "react"; -import { - QueryResult, - QueryGenqlSelection, - MutationResult, - MutationGenqlSelection, - generateQueryOp, - generateMutationOp, -} from "./genql"; - -import { pipe, toPromise } from "wonka"; - -export function useTypedQuery(opts: { - query: Query; - pause?: boolean; - requestPolicy?: RequestPolicy; - context?: Partial; -}) { - const { query, variables } = generateQueryOp(opts.query); - return useQuery>({ - ...opts, - query, - variables, - }); -} - -const initialState = { - stale: false, - fetching: false, - data: undefined, - error: undefined, - operation: undefined, - extensions: undefined, -}; - -export function useTypedMutation< - Variables extends Record, - Mutation extends MutationGenqlSelection, - Data extends MutationResult ->( - builder: (vars: Variables) => Mutation, - opts?: Partial -): UseMutationResponse { - const client = useClient(); - const isMounted = useRef(true); - const [state, setState] = - useState>(initialState); - const executeMutation = useCallback( - ( - vars?: Variables, - context?: Partial - ): Promise> => { - setState({ ...initialState, fetching: true }); - const buildArgs = vars || ({} as Variables); - const built = builder(buildArgs); - const { query, variables } = generateMutationOp(built); - return pipe( - client.executeMutation( - createRequest(query, variables as Variables), - { ...opts, ...context } - ), - toPromise - ).then((result: OperationResult) => { - if (isMounted.current) { - setState({ - fetching: false, - stale: !!result.stale, - data: result.data, - error: result.error, - extensions: result.extensions, - operation: result.operation, - }); - } - return result; - }); - }, - [state, setState] - ); - - useEffect(() => { - isMounted.current = true; - return () => { - isMounted.current = false; - }; - }, []); - - return [state, executeMutation]; -} diff --git a/examples/aws-pothos-graphql/package.json b/examples/aws-pothos-graphql/package.json deleted file mode 100644 index cb287214e0..0000000000 --- a/examples/aws-pothos-graphql/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-pothos-graphql", - "dependencies": { - "@pothos/core": "^3.41.1", - "@urql/core": "^5.0.4", - "graphql-yoga": "^5.3.1", - "react": "^18.3.1", - "sst": "file:../../sdk/js", - "urql": "^4.1.0", - "wonka": "^6.3.4" - }, - "devDependencies": { - "@genql/cli": "^6.3.3", - "@types/aws-lambda": "8.10.138", - "@types/react": "^18.3.3" - } -} diff --git a/examples/aws-pothos-graphql/pothos/extract.ts b/examples/aws-pothos-graphql/pothos/extract.ts deleted file mode 100644 index 0326d4a3fa..0000000000 --- a/examples/aws-pothos-graphql/pothos/extract.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { lexicographicSortSchema, printSchema } from "graphql"; -import path from "path"; -import { schema } from "./schema"; - -async function extract() { - const schemaAsString = printSchema(lexicographicSortSchema(schema)); - - await Bun.write("./graphql/schema.graphql", schemaAsString); - - const proc = Bun.spawn( - [ - "bun", - "x", - "@genql/cli", - "--output", - "./genql", - "--schema", - "./schema.graphql", - "--esm", - ], - { - cwd: "./graphql", - } - ); - - const exitCode = await proc.exited; - if (exitCode !== 0) { - throw Error(`Genegration faild with code ${exitCode}`); - } -} - -extract() - .then(() => { - console.log("Pothos schema extracted successfully."); - }) - .catch((error) => { - console.error("Failed to extract pothos schema the database:", error); - }); diff --git a/examples/aws-pothos-graphql/pothos/graphql.ts b/examples/aws-pothos-graphql/pothos/graphql.ts deleted file mode 100644 index a11cb0cfb7..0000000000 --- a/examples/aws-pothos-graphql/pothos/graphql.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { schema } from "./schema"; -import { awsLambdaRequestHandler } from "./server"; - -export const handler = awsLambdaRequestHandler({ - schema, -}); diff --git a/examples/aws-pothos-graphql/pothos/schema.ts b/examples/aws-pothos-graphql/pothos/schema.ts deleted file mode 100644 index fb2921ffe5..0000000000 --- a/examples/aws-pothos-graphql/pothos/schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { builder } from "./builder"; - -import "./types/giraffe"; - -export const schema = builder.toSchema({}); diff --git a/examples/aws-pothos-graphql/pothos/server.ts b/examples/aws-pothos-graphql/pothos/server.ts deleted file mode 100644 index 56536f2bc6..0000000000 --- a/examples/aws-pothos-graphql/pothos/server.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - APIGatewayProxyEventV2, - APIGatewayProxyResult, - Context, -} from "aws-lambda"; -import { createYoga, YogaServerOptions } from "graphql-yoga"; - -type ServerContext = { - event: APIGatewayProxyEventV2; - context: Context; -}; - -export function awsLambdaRequestHandler( - options: YogaServerOptions -) { - const yoga = createYoga({ - ...options, - }); - - return async ( - event: APIGatewayProxyEventV2, - lambdaContext: Context - ): Promise => { - const parameters = new URLSearchParams( - (event.queryStringParameters as Record) || {} - ).toString(); - - const url = `${event.rawPath}?${parameters}`; - - const request: RequestInit = { - method: event.requestContext.http.method, - headers: event.headers as HeadersInit, - body: event.body - ? Buffer.from(event.body, event.isBase64Encoded ? "base64" : "utf8") - : undefined, - }; - - const serverContext: ServerContext = { - event, - context: lambdaContext, - }; - - const response = await yoga.fetch(url, request, serverContext); - const responseHeaders = Object.fromEntries(response.headers.entries()); - - return { - statusCode: response.status, - headers: responseHeaders, - body: await response.text(), - isBase64Encoded: false, - }; - }; -} diff --git a/examples/aws-pothos-graphql/pothos/types/giraffe.ts b/examples/aws-pothos-graphql/pothos/types/giraffe.ts deleted file mode 100644 index d0dbeab188..0000000000 --- a/examples/aws-pothos-graphql/pothos/types/giraffe.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { builder } from "../builder"; - -export class Giraffe { - name: string; - - constructor(name: string) { - this.name = name; - } -} - -builder.objectType(Giraffe, { - name: "Giraffe", - description: "Long necks, cool patterns, taller than you.", - fields: (t) => ({ - name: t.exposeString("name", {}), - }), -}); - -builder.queryFields((t) => ({ - giraffe: t.field({ - type: Giraffe, - resolve: () => new Giraffe("James"), - }), -})); - -builder.mutationFields((t) => ({ - createGiraffe: t.field({ - type: Giraffe, - args: { - name: t.arg.string({ required: true }), - }, - resolve: async (root, args) => { - const giraffe = { name: args.name }; - - return giraffe; - }, - }), -})); diff --git a/examples/aws-pothos-graphql/sst.config.ts b/examples/aws-pothos-graphql/sst.config.ts deleted file mode 100644 index ef154806d8..0000000000 --- a/examples/aws-pothos-graphql/sst.config.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-pothos-graphql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - if ($dev) { - new sst.x.DevCommand("PothosGraphqlExtractor", { - dev: { - command: "bun --watch run pothos/extract.ts", - autostart: true, - }, - }); - } - - const api = new sst.aws.ApiGatewayV2("Api"); - api.route("POST /graphql", "pothos/graphql.handler"); - - const client = new sst.aws.Function("Client", { - url: true, - link: [api], - handler: "client.handler", - }); - - return { - api: api.url, - client: client.url, - }; - }, -}); diff --git a/examples/aws-pothos-graphql/tsconfig.json b/examples/aws-pothos-graphql/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-pothos-graphql/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-prisma-lambda/.gitignore b/examples/aws-prisma-lambda/.gitignore deleted file mode 100644 index 11ddd8dbe6..0000000000 --- a/examples/aws-prisma-lambda/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -# Keep environment variables out of version control -.env diff --git a/examples/aws-prisma-lambda/index.ts b/examples/aws-prisma-lambda/index.ts deleted file mode 100644 index 99633c21b1..0000000000 --- a/examples/aws-prisma-lambda/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { prisma } from "./prisma"; - -async function createUser(name: string, email: string) { - return prisma.user.create({ - data: { name, email }, - }); -} - -export async function handler() { - const user = await createUser("Alice", `alice-${crypto.randomUUID()}@example.com`); - return { - statusCode: 201, - body: JSON.stringify({ user }), - }; -} diff --git a/examples/aws-prisma-lambda/package.json b/examples/aws-prisma-lambda/package.json deleted file mode 100644 index 423d683d52..0000000000 --- a/examples/aws-prisma-lambda/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-prisma-lambda", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "postinstall": "prisma generate", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.145", - "@types/node": "^22.5.4", - "prisma": "^5.19.1", - "ts-node": "^10.9.2", - "typescript": "^5.5.4" - }, - "dependencies": { - "@prisma/client": "^5.19.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-prisma-lambda/prisma.ts b/examples/aws-prisma-lambda/prisma.ts deleted file mode 100644 index 4a1ae94b80..0000000000 --- a/examples/aws-prisma-lambda/prisma.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Resource } from "sst"; -import { PrismaClient } from '@prisma/client'; - -const globalForPrisma = global as unknown as { prisma: PrismaClient } - -export const prisma = globalForPrisma.prisma || - new PrismaClient({ - datasources: { - db: { - url: `postgresql://${Resource.MyPostgres.username}:${Resource.MyPostgres.password}@${Resource.MyPostgres.host}:${Resource.MyPostgres.port}/${Resource.MyPostgres.database}?connection_limit=1`, - }, - }, - }); - -// Create single client in `sst dev` -if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma diff --git a/examples/aws-prisma-lambda/prisma/migrations/0_init/migration.sql b/examples/aws-prisma-lambda/prisma/migrations/0_init/migration.sql deleted file mode 100644 index 1e9eb8fd02..0000000000 --- a/examples/aws-prisma-lambda/prisma/migrations/0_init/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" SERIAL NOT NULL, - "name" TEXT, - "email" TEXT NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/examples/aws-prisma-lambda/prisma/schema.prisma b/examples/aws-prisma-lambda/prisma/schema.prisma deleted file mode 100644 index c377c80546..0000000000 --- a/examples/aws-prisma-lambda/prisma/schema.prisma +++ /dev/null @@ -1,18 +0,0 @@ -generator client { - provider = "prisma-client-js" - // For x86 - binaryTargets = ["native", "rhel-openssl-3.0.x"] - // For ARM - // binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") -} - -model User { - id Int @id @default(autoincrement()) - name String? - email String @unique -} diff --git a/examples/aws-prisma-lambda/sst.config.ts b/examples/aws-prisma-lambda/sst.config.ts deleted file mode 100644 index a10fb65e69..0000000000 --- a/examples/aws-prisma-lambda/sst.config.ts +++ /dev/null @@ -1,98 +0,0 @@ -/// - -/** - * ## Prisma in Lambda - * - * To use Prisma in a Lambda function you need to - * - * - Generate the Prisma Client with the right architecture - * - Copy the generated client to the function - * - Run the function inside a VPC - * - * You can set the architecture using the `binaryTargets` option in `prisma/schema.prisma`. - * - * ```prisma title="prisma/schema.prisma" - * // For x86 - * binaryTargets = ["native", "rhel-openssl-3.0.x"] - * // For ARM - * // binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] - * ``` - * - * You can also switch to ARM, just make sure to also change the function architecture in your - * `sst.config.ts`. - * - * ```ts title="sst.config.ts" - * { - * // For ARM - * architecture: "arm64" - * } - * ``` - * - * To generate the client, you need to run `prisma generate` when you make changes to the - * schema. - * - * Since this [needs to be done on every deploy](https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/vercel-caching-issue#a-custom-postinstall-script), we add a `postinstall` script to the `package.json`. - * - * ```json title="package.json" - * "scripts": { - * "postinstall": "prisma generate" - * } - * ``` - * - * This runs the command on `npm install`. - * - * We then need to copy the generated client to the function when we deploy. - * - * ```ts title="sst.config.ts" - * { - * copyFiles: [{ from: "node_modules/.prisma/client/" }] - * } - * ``` - * - * Our function also needs to run inside a VPC, since Prisma doesn't support the Data API. - * - * ```ts title="sst.config.ts" - * { - * vpc - * } - * ``` - * - * #### Prisma in serverless environments - * - * Prisma is [not great in serverless environments](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas). For a couple of reasons: - * - * 1. It doesn't support Data API, so you need to manage the connection pool on your own. - * 2. Without the Data API, your functions need to run inside a VPC. - * - You cannot use `sst dev` without [connecting to the VPC](/docs/live#using-a-vpc). - * 3. Due to the internal architecture of their client, it's also has slower cold starts. - * - * Instead we recommend using [Drizzle](https://orm.drizzle.team). This example is here for - * reference for people that are already using Prisma. - */ -export default $config({ - app(input) { - return { - name: "aws-prisma-lambda", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc }); - - const api = new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - // For ARM - // architecture: "arm64", - handler: "index.handler", - copyFiles: [{ from: "node_modules/.prisma/client/" }], - }); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-prisma-lambda/tsconfig.json b/examples/aws-prisma-lambda/tsconfig.json deleted file mode 100644 index 8bb6097f80..0000000000 --- a/examples/aws-prisma-lambda/tsconfig.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} diff --git a/examples/aws-prisma/.dockerignore b/examples/aws-prisma/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-prisma/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-prisma/.gitignore b/examples/aws-prisma/.gitignore deleted file mode 100644 index 033b3ef1cc..0000000000 --- a/examples/aws-prisma/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -# Keep environment variables out of version control -.env - -# sst -.sst diff --git a/examples/aws-prisma/Dockerfile b/examples/aws-prisma/Dockerfile deleted file mode 100644 index c532d99a54..0000000000 --- a/examples/aws-prisma/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json index.mjs prisma /app/ -RUN npm install - -RUN npx prisma generate - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-prisma/index.mjs b/examples/aws-prisma/index.mjs deleted file mode 100644 index f90c0e4a50..0000000000 --- a/examples/aws-prisma/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import express from "express"; -import { PrismaClient } from '@prisma/client'; - -const PORT = 80; - -const app = express(); -const prisma = new PrismaClient(); - -app.get("/", async (_req, res) => { - const user = await prisma.user.create({ - data: { - name: "Alice", - email: `alice-${crypto.randomUUID()}@example.com` - }, - }); - res.send(JSON.stringify(user)); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-prisma/package.json b/examples/aws-prisma/package.json deleted file mode 100644 index 6be9028453..0000000000 --- a/examples/aws-prisma/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-prisma", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/node": "^22.7.8", - "prisma": "^5.21.1", - "ts-node": "^10.9.2", - "typescript": "^5.6.3" - }, - "dependencies": { - "@prisma/client": "^5.21.1", - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-prisma/prisma/migrations/20241022202928_init/migration.sql b/examples/aws-prisma/prisma/migrations/20241022202928_init/migration.sql deleted file mode 100644 index 1e9eb8fd02..0000000000 --- a/examples/aws-prisma/prisma/migrations/20241022202928_init/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" SERIAL NOT NULL, - "name" TEXT, - "email" TEXT NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/examples/aws-prisma/prisma/migrations/migration_lock.toml b/examples/aws-prisma/prisma/migrations/migration_lock.toml deleted file mode 100644 index fbffa92c2b..0000000000 --- a/examples/aws-prisma/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "postgresql" \ No newline at end of file diff --git a/examples/aws-prisma/prisma/schema.prisma b/examples/aws-prisma/prisma/schema.prisma deleted file mode 100644 index 3c4e2ed8f5..0000000000 --- a/examples/aws-prisma/prisma/schema.prisma +++ /dev/null @@ -1,20 +0,0 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - -// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? -// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init - -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") -} - -model User { - id Int @id @default(autoincrement()) - name String? - email String @unique -} diff --git a/examples/aws-prisma/sst.config.ts b/examples/aws-prisma/sst.config.ts deleted file mode 100644 index 0b72a75085..0000000000 --- a/examples/aws-prisma/sst.config.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-prisma", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc }); - - const DATABASE_URL = $interpolate`postgresql://${rds.username}:${rds.password}@${rds.host}:${rds.port}/${rds.database}`; - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [rds], - environment: { DATABASE_URL }, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); - - new sst.x.DevCommand("Prisma", { - environment: { DATABASE_URL }, - dev: { - autostart: false, - command: "npx prisma studio", - }, - }); - }, -}); diff --git a/examples/aws-prisma/tsconfig.json b/examples/aws-prisma/tsconfig.json deleted file mode 100644 index 56a8ab8109..0000000000 --- a/examples/aws-prisma/tsconfig.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} diff --git a/examples/aws-puppeteer/.gitignore b/examples/aws-puppeteer/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-puppeteer/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-puppeteer/index.ts b/examples/aws-puppeteer/index.ts deleted file mode 100644 index da3500de7c..0000000000 --- a/examples/aws-puppeteer/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -import puppeteer from "puppeteer-core"; -import chromium from "@sparticuz/chromium"; - -// This is the path to the local Chromium binary -const YOUR_LOCAL_CHROMIUM_PATH = - "/tmp/localChromium/chromium/mac_arm-1350406/chrome-mac/Chromium.app/Contents/MacOS/Chromium"; - -export async function handler() { - const url = "https://sst.dev"; - const width = 1024; - const height = 768; - - const browser = await puppeteer.launch({ - args: chromium.args, - defaultViewport: chromium.defaultViewport, - executablePath: process.env.SST_DEV - ? YOUR_LOCAL_CHROMIUM_PATH - : await chromium.executablePath(), - headless: chromium.headless, - }); - - const page = await browser.newPage(); - - await page.setViewport({ - width: width, - height: height, - }); - - await page.goto(url!); - - const screenshot = (await page.screenshot({ encoding: "base64" })) as string; - - return { - statusCode: 200, - body: screenshot, - isBase64Encoded: true, - headers: { - "Content-Type": "image/png", - "Content-Disposition": "inline", - }, - }; -} diff --git a/examples/aws-puppeteer/package.json b/examples/aws-puppeteer/package.json deleted file mode 100644 index 892b488539..0000000000 --- a/examples/aws-puppeteer/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-puppeteer", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@sparticuz/chromium": "^127.0.0", - "puppeteer-core": "^23.1.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-puppeteer/sst.config.ts b/examples/aws-puppeteer/sst.config.ts deleted file mode 100644 index b65b788afd..0000000000 --- a/examples/aws-puppeteer/sst.config.ts +++ /dev/null @@ -1,108 +0,0 @@ -/// - -/** - * ## Puppeteer in Lambda - * - * To use Puppeteer in a Lambda function you need: - * - * 1. [`puppeteer-core`](https://www.npmjs.com/package/puppeteer-core) - * 2. Chromium - * - In `sst dev`, we'll use a locally installed Chromium version. - * - In `sst deploy`, we'll use the [`@sparticuz/chromium`](https://github.com/sparticuz/chromium) package. It comes with a pre-built binary for Lambda. - * - * #### Chromium version - * - * Since Puppeteer has a preferred version of Chromium, we'll need to check the version of - * Chrome that a given version of Puppeteer supports. Head over to the - * [Puppeteer's Chromium Support page](https://pptr.dev/chromium-support) and check which - * versions work together. - * - * For example, Puppeteer v23.1.1 supports Chrome for Testing 127.0.6533.119. So, we'll use the - * v127 of `@sparticuz/chromium`. - * - * ```bash - * npm install puppeteer-core@23.1.1 @sparticuz/chromium@127.0.0 - * ``` - * - * #### Install Chromium locally - * - * To use this locally, you'll need to install Chromium. - * - * ```bash - * npx @puppeteer/browsers install chromium@latest --path /tmp/localChromium - * ``` - * - * Once installed you'll see the location of the Chromium binary, `/tmp/localChromium/chromium/mac_arm-1350406/chrome-mac/Chromium.app/Contents/MacOS/Chromium`. - * - * Update this in your Lambda function. - * - * ```ts title="index.ts" - * // This is the path to the local Chromium binary - * const YOUR_LOCAL_CHROMIUM_PATH = "/tmp/localChromium/chromium/mac_arm-1350406/chrome-mac/Chromium.app/Contents/MacOS/Chromium"; - * ``` - * - * You'll notice we are using the right binary with the `SST_DEV` environment variable. - * - * ```ts title="index.ts" {4-6} - * const browser = await puppeteer.launch({ - * args: chromium.args, - * defaultViewport: chromium.defaultViewport, - * executablePath: process.env.SST_DEV - * ? YOUR_LOCAL_CHROMIUM_PATH - * : await chromium.executablePath(), - * headless: chromium.headless, - * }); - * ``` - * - * #### Deploy - * - * We don't need a layer to deploy this because `@sparticuz/chromium` comes with a pre-built - * binary for Lambda. - * - * :::note - * As of writing this, `arm64` is not supported by `@sparticuz/chromium`. - * ::: - * - * We just need to set it in the [`nodejs.install`](/docs/component/aws/function#nodejs-install). - * - * ```ts title="sst.config.ts" - * { - * nodejs: { - * install: ["@sparticuz/chromium"] - * } - * } - * ``` - * - * And on deploy, SST will use the right binary. - * - * :::tip - * You don't need to use a Lambda layer to use Puppeteer. - * ::: - * - * We are giving our function more memory and a longer timeout since running Puppeteer can - * take a while. - */ -export default $config({ - app(input) { - return { - name: "aws-puppeteer", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.Function("MyFunction", { - url: true, - memory: "2 GB", - timeout: "15 minutes", - handler: "index.handler", - nodejs: { - install: ["@sparticuz/chromium"], - }, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-puppeteer/tsconfig.json b/examples/aws-puppeteer/tsconfig.json deleted file mode 100644 index 2f98042715..0000000000 --- a/examples/aws-puppeteer/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/examples/aws-python-container/.gitignore b/examples/aws-python-container/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-python-container/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-python-container/core/pyproject.toml b/examples/aws-python-container/core/pyproject.toml deleted file mode 100644 index 4d9ed5884e..0000000000 --- a/examples/aws-python-container/core/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "core" -version = "0.1.0" -description = "Add your description here" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -requires-python = "==3.11.*" -dependencies = ["requests>=2.32.3"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-python-container/core/src/core/__init__.py b/examples/aws-python-container/core/src/core/__init__.py deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-python-container/core/src/core/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-python-container/core/src/core/ping.py b/examples/aws-python-container/core/src/core/ping.py deleted file mode 100644 index c13cfd5726..0000000000 --- a/examples/aws-python-container/core/src/core/ping.py +++ /dev/null @@ -1,5 +0,0 @@ -import requests - - -def ping(): - return requests.get("https://api.github.com").status_code diff --git a/examples/aws-python-container/custom_dockerfile/Dockerfile b/examples/aws-python-container/custom_dockerfile/Dockerfile deleted file mode 100644 index a8383a707c..0000000000 --- a/examples/aws-python-container/custom_dockerfile/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# The python version to use is supplied as an arg from SST -ARG PYTHON_VERSION=3.11 - -# Use an official AWS Lambda base image for Python -FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} - -# # Ensure git is installed so we can install git based dependencies (such as sst) -RUN if command -v dnf > /dev/null 2>&1; then \ - dnf update -y && dnf install -y git gcc && dnf clean all; \ - elif command -v yum > /dev/null 2>&1; then \ - yum install -y git gcc && yum clean all; \ - fi - -# Install UV to manage your python runtime -COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - -# Copy everything first so workspace packages (referenced as ./pkg in requirements.txt) -# are available during dependency installation -COPY . ${LAMBDA_TASK_ROOT} - -# Install the dependencies to the lambda runtime -RUN uv pip install -r requirements.txt --target ${LAMBDA_TASK_ROOT} --system - -# Perform any steps that you want here: -# Example: pre-bake in model weights from huggingface to image - -# No need to configure the handler or entrypoint - SST will do that diff --git a/examples/aws-python-container/custom_dockerfile/pyproject.toml b/examples/aws-python-container/custom_dockerfile/pyproject.toml deleted file mode 100644 index feae2e5b61..0000000000 --- a/examples/aws-python-container/custom_dockerfile/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "custom_dockerfile" -version = "0.1.0" -description = "Custom Dockerfile" -dependencies = ["core", "sst-sdk"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/__init__.py b/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/api.py b/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/api.py deleted file mode 100644 index 62a8ff638b..0000000000 --- a/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/api.py +++ /dev/null @@ -1,12 +0,0 @@ -from core.ping import ping -from sst import Resource - - -def handler(event, context): - response_code = ping() - print(f"Response code: {response_code}") - - return { - "statusCode": 200, - "body": f"Hello, World! - Linkable value: {Resource.MyLinkableValue.foo}", - } diff --git a/examples/aws-python-container/functions/pyproject.toml b/examples/aws-python-container/functions/pyproject.toml deleted file mode 100644 index 8eefe8e19d..0000000000 --- a/examples/aws-python-container/functions/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "Lambda function (container-mode)handlers" -dependencies = ["core", "sst-sdk"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-python-container/functions/src/functions/__init__.py b/examples/aws-python-container/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python-container/functions/src/functions/api.py b/examples/aws-python-container/functions/src/functions/api.py deleted file mode 100644 index 62a8ff638b..0000000000 --- a/examples/aws-python-container/functions/src/functions/api.py +++ /dev/null @@ -1,12 +0,0 @@ -from core.ping import ping -from sst import Resource - - -def handler(event, context): - response_code = ping() - print(f"Response code: {response_code}") - - return { - "statusCode": 200, - "body": f"Hello, World! - Linkable value: {Resource.MyLinkableValue.foo}", - } diff --git a/examples/aws-python-container/pyproject.toml b/examples/aws-python-container/pyproject.toml deleted file mode 100644 index 4cd1c70628..0000000000 --- a/examples/aws-python-container/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-python-container" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.11.*" - -[tool.uv.workspace] -members = ["functions", "core", "custom_dockerfile"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-python-container/sst.config.ts b/examples/aws-python-container/sst.config.ts deleted file mode 100644 index f49506a8f5..0000000000 --- a/examples/aws-python-container/sst.config.ts +++ /dev/null @@ -1,118 +0,0 @@ -/// - -/** - * ## AWS Lambda Python container - * - * Python Lambda function that use large dependencies like `numpy` and `pandas`, can - * hit the 250MB Lambda package limit. To work around this, you can deploy them - * as a container image to Lambda. - * - * :::tip - * Container images on Lambda have a limit of 10GB. - * ::: - * - * In this example, we deploy two functions as container image. - * - * ```ts title="sst.config.ts" {2-4} - * const base = new sst.aws.Function("PythonFn", { - * python: { - * container: true, - * }, - * handler: "./functions/src/functions/api.handler", - * runtime: "python3.11", - * link: [linkableValue], - * url: true, - * }); - * ``` - * - * Now when you run `sst deploy`, it uses a built-in Dockerfile to build the image - * and deploy it. You'll need to have the Docker daemon running. - * - * :::note - * You need to have the Docker daemon running locally. - * ::: - * - * To use a custom Dockerfile, you can place a `Dockerfile` in the root of the - * uv workspace for your function. - * - * ```ts title="sst.config.ts" {5} - * const custom = new sst.aws.Function("PythonFnCustom", { - * python: { - * container: true, - * }, - * handler: "./custom_dockerfile/src/custom_dockerfile/api.handler", - * runtime: "python3.11", - * link: [linkableValue], - * url: true, - * }); - * ``` - * - * Here we have a `Dockerfile` in the `custom_dockerfile/` directory. - * - * ```dockerfile title="custom_dockerfile/Dockerfile" - * # The python version to use is supplied as an arg from SST - * ARG PYTHON_VERSION=3.11 - * - * # Use an official AWS Lambda base image for Python - * FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} - * - * # ... - * ``` - * - * The project structure looks something like this. - * - * ```txt {5} - * β”œβ”€β”€ sst.config.ts - * β”œβ”€β”€ pyproject.toml - * └── custom_dockerfile - * β”œβ”€β”€ pyproject.toml - * β”œβ”€β”€ Dockerfile - * └── src - * └── custom_dockerfile - * └── api.py - * ``` - * - * Locally, you want to set the Python version in your `pyproject.toml` to make sure - * that `sst dev` uses the same version as `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-python-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const linkableValue = new sst.Linkable("MyLinkableValue", { - properties: { - foo: "Hello World", - }, - }); - - const base = new sst.aws.Function("PythonFn", { - python: { - container: true, - }, - handler: "./functions/src/functions/api.handler", - runtime: "python3.11", - link: [linkableValue], - url: true, - }); - - const custom = new sst.aws.Function("PythonFnCustom", { - python: { - container: true, - }, - handler: "./custom_dockerfile/src/custom_dockerfile/api.handler", - runtime: "python3.11", - link: [linkableValue], - url: true, - }); - - return { - base: base.url, - custom: custom.url, - }; - }, -}); diff --git a/examples/aws-python-container/tsconfig.json b/examples/aws-python-container/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-python-container/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-python-huggingface/.gitignore b/examples/aws-python-huggingface/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-python-huggingface/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-python-huggingface/functions/Dockerfile b/examples/aws-python-huggingface/functions/Dockerfile deleted file mode 100644 index b7f8c97a6e..0000000000 --- a/examples/aws-python-huggingface/functions/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -# If any docker wizard is interested, a multi-stage build would be better for caching -# and reducing the size of the final image - -# The python version to use is supplied as an arg from SST -ARG PYTHON_VERSION=3.12 - -# Use an official AWS Lambda base image for Python -FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} as builder - -# # Ensure git is installed so we can install git based dependencies (such as sst) -ARG PYTHON_RUNTIME - -# Install git and gcc using appropriate package manager based on Python version -RUN dnf install -y git gcc gcc-c++ openssl-devel - -# Install Rust using rustup -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y - -# Add Cargo to PATH -ENV PATH="/root/.cargo/bin:${PATH}" - -# Install UV to manage your python runtime -COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - -# Copy everything first so workspace package references (e.g., ./functions) -# in requirements.txt resolve correctly during installation -COPY . ${LAMBDA_TASK_ROOT} - -# Install the dependencies to the lambda runtime -RUN uv pip install -r requirements.txt --target ${LAMBDA_TASK_ROOT} --system --no-verify-hashes - -FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} - -ENV HF_HOME=/tmp/transformers_cache - -# Copy installed dependencies and application code from the builder stage -COPY --from=builder ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT} - -# Copy the rest of the code -COPY . ${LAMBDA_TASK_ROOT} - -# No need to configure the handler or entrypoint - SST will do that \ No newline at end of file diff --git a/examples/aws-python-huggingface/functions/pyproject.toml b/examples/aws-python-huggingface/functions/pyproject.toml deleted file mode 100644 index 1c8df57c9a..0000000000 --- a/examples/aws-python-huggingface/functions/pyproject.toml +++ /dev/null @@ -1,22 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = ["transformers>=4.44.2", "torch==2.3.1"] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.12.*" - -[tool.uv.sources] -torch = [{ index = "pytorch-cpu", marker = "platform_system != 'Darwin'" }] - -[[tool.uv.index]] -name = "pytorch-cpu" -url = "https://download.pytorch.org/whl/cpu" -explicit = true - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-python-huggingface/functions/src/functions/__init__.py b/examples/aws-python-huggingface/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python-huggingface/functions/src/functions/api.py b/examples/aws-python-huggingface/functions/src/functions/api.py deleted file mode 100644 index c25dc9af41..0000000000 --- a/examples/aws-python-huggingface/functions/src/functions/api.py +++ /dev/null @@ -1,29 +0,0 @@ -from transformers import pipeline -import json - -# Initialize the pipeline once (outside the handler) to avoid reloading the model on each request -pipe = pipeline("text-generation", model="roneneldan/TinyStories-1M") - - -def handler(event, context): - # Define the prompt for text generation - prompt = "Write a short story about the magical framework SST that makes the cloud so easy to use!" - - # Generate text using the pipeline - response = pipe( - prompt, - max_length=150, - num_return_sequences=1, - temperature=0.6, - top_k=50, - do_sample=True, - ) - - # Extract the generated text - generated_text = response[0]["generated_text"] - - # Return the response with a status code and JSON-encoded body - return { - "statusCode": 200, - "body": json.dumps({"story": generated_text}), - } diff --git a/examples/aws-python-huggingface/pyproject.toml b/examples/aws-python-huggingface/pyproject.toml deleted file mode 100644 index fb335d9b8f..0000000000 --- a/examples/aws-python-huggingface/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-python-huggingface" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.12.*" - -[tool.uv.workspace] -members = ["functions"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-python-huggingface/sst.config.ts b/examples/aws-python-huggingface/sst.config.ts deleted file mode 100644 index 14d3b52c6e..0000000000 --- a/examples/aws-python-huggingface/sst.config.ts +++ /dev/null @@ -1,43 +0,0 @@ -/// - -/** - * ## AWS Lambda Python Hugging Face - * - * Uses a Python Lambda container image to deploy a lightweight - * [Hugging Face](https://huggingface.co/) model. - * - * Uses the [transformers](https://github.com/huggingface/transformers) library to - * generate text using the - * [TinyStories-33M](https://huggingface.co/roneneldan/TinyStories-33M) model. The - * backend is the pytorch cpu runtime. - * - * :::note - * This is not a production ready example. - * ::: - * - * This example also shows how it is possible to use custom index resolution to get - * dependencies from a private pypi server such as the pytorch cpu link. This - * example also shows how to use a custom Dockerfile to handle complex builds such - * as installing pytorch and pruning the build size. - */ -export default $config({ - app(input) { - return { - name: "aws-python-huggingface", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Function("PythonFunction", { - python: { - container: true, - }, - handler: "functions/src/functions/api.handler", - runtime: "python3.12", - memory: "2048 MB", - timeout: "120 seconds", - url: true, - }); - }, -}); diff --git a/examples/aws-python-huggingface/tsconfig.json b/examples/aws-python-huggingface/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-python-huggingface/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-python/.gitignore b/examples/aws-python/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-python/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-python/core/pyproject.toml b/examples/aws-python/core/pyproject.toml deleted file mode 100644 index 4d9ed5884e..0000000000 --- a/examples/aws-python/core/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "core" -version = "0.1.0" -description = "Add your description here" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -requires-python = "==3.11.*" -dependencies = ["requests>=2.32.3"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-python/core/src/core/__init__.py b/examples/aws-python/core/src/core/__init__.py deleted file mode 100644 index 437615c6c1..0000000000 --- a/examples/aws-python/core/src/core/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from core.db import get_user - - -def hello() -> str: - return "Hello from core!" - - -__all__ = ["get_user", "hello"] diff --git a/examples/aws-python/core/src/core/db.py b/examples/aws-python/core/src/core/db.py deleted file mode 100644 index c719b87ba4..0000000000 --- a/examples/aws-python/core/src/core/db.py +++ /dev/null @@ -1,5 +0,0 @@ -def get_user(user_id: str) -> dict: - return { - "user_id": user_id, - "name": "John Doe", - } diff --git a/examples/aws-python/core/src/core/ping.py b/examples/aws-python/core/src/core/ping.py deleted file mode 100644 index c13cfd5726..0000000000 --- a/examples/aws-python/core/src/core/ping.py +++ /dev/null @@ -1,5 +0,0 @@ -import requests - - -def ping(): - return requests.get("https://api.github.com").status_code diff --git a/examples/aws-python/core/src/core/py.typed b/examples/aws-python/core/src/core/py.typed deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python/functions/pyproject.toml b/examples/aws-python/functions/pyproject.toml deleted file mode 100644 index 2d8dfe7819..0000000000 --- a/examples/aws-python/functions/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "Lambda function handlers" -dependencies = ["core", "sst-sdk"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-python/functions/src/functions/__init__.py b/examples/aws-python/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python/functions/src/functions/api.py b/examples/aws-python/functions/src/functions/api.py deleted file mode 100644 index dec26af61f..0000000000 --- a/examples/aws-python/functions/src/functions/api.py +++ /dev/null @@ -1,23 +0,0 @@ -from sst import Resource -from functions.shared import foo -from core.db import get_user -from core.ping import ping - -def handler(event, context): - print("Function invoked from Python") - - # Share code within the same workspace package - print(foo()) - - # Share code between workspace packages - res = ping() - print(get_user("1234")) - print("Ping result:", res) - - # Use the SST SDK to access resources - print(f"Resource.MyLinkableValue.foo: {Resource.MyLinkableValue.foo}") - - return { - "statusCode": 200, - "body": f"{Resource.MyLinkableValue.foo} from Python!", - } diff --git a/examples/aws-python/functions/src/functions/shared.py b/examples/aws-python/functions/src/functions/shared.py deleted file mode 100644 index 1f022956c6..0000000000 --- a/examples/aws-python/functions/src/functions/shared.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - return "bar" diff --git a/examples/aws-python/pyproject.toml b/examples/aws-python/pyproject.toml deleted file mode 100644 index 177fb56105..0000000000 --- a/examples/aws-python/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-python" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.11.*" - -[tool.uv.workspace] -members = ["functions", "core"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-python/sst.config.ts b/examples/aws-python/sst.config.ts deleted file mode 100644 index fc3f7c2cc0..0000000000 --- a/examples/aws-python/sst.config.ts +++ /dev/null @@ -1,102 +0,0 @@ -/// - -/** - * ## AWS Lambda Python - * - * SST uses [uv](https://docs.astral.sh/uv/) to manage your Python runtime, make - * sure you have it [installed](https://docs.astral.sh/uv/getting-started/installation/). - * - * Any [uv workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/#workspace-sources) - * package can be built and deployed as a Lambda function using SST. Drop-in mode - * is currently not supported. - * - * :::note - * Each function is packaged with only the dependencies from its own `pyproject.toml` - * and any workspace packages it depends on. - * ::: - * - * In this example we deploy a handler from the `functions/` directory. It depends - * on shared code from another uv workspace in the `core/` directory. - * - * ```txt - * β”œβ”€β”€ sst.config.ts - * β”œβ”€β”€ pyproject.toml - * β”œβ”€β”€ core - * β”‚ β”œβ”€β”€ pyproject.toml - * β”‚ └── src - * β”‚ └── core - * β”‚ └── __init__.py - * └── functions - * β”œβ”€β”€ pyproject.toml - * └── src - * └── functions - * β”œβ”€β”€ __init__.py - * └── api.py - * ``` - * - * The `handler` is the path to the handler file and the name of the handler function - * in it. - * - * ```ts title="sst.config.ts" {2} - * new sst.aws.Function("PythonFunction", { - * handler: "functions/src/functions/api.handler", - * runtime: "python3.11", - * link: [linkableValue], - * url: true, - * }); - * ``` - * - * SST will traverse up from the handler path and look for the nearest - * `pyproject.toml`. And will throw an error if it can't find one. - * - * To access linked resources, you can use the SST SDK. - * - * ```py title="functions/src/functions/api.py" {1} - * from sst import Resource - * - * def handler(event, context): - * print(Resource.MyLinkableValue.foo) - * ``` - * - * Where the `sst-sdk` package can be added to your `pyproject.toml`. - * - * ```toml title="functions/pyproject.toml" - * [project] - * dependencies = ["sst-sdk"] - * - * [tool.uv.sources] - * sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } - * ``` - * - * You also want to set the Python version in your `pyproject.toml` to the same - * version as the one in Lambda. - * - * ```toml title="functions/pyproject.toml" - * requires-python = "==3.11.*" - * ``` - * - * This makes sure that your functions work the same in `sst dev` as `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-python", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const linkableValue = new sst.Linkable("MyLinkableValue", { - properties: { - foo: "Hello World", - }, - }); - - new sst.aws.Function("PythonFunction", { - handler: "functions/src/functions/api.handler", - runtime: "python3.11", - link: [linkableValue], - url: true, - }); - }, -}); diff --git a/examples/aws-python/tsconfig.json b/examples/aws-python/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-python/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-queue/package.json b/examples/aws-queue/package.json deleted file mode 100644 index def9afd4f2..0000000000 --- a/examples/aws-queue/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-queue", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.149", - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-sqs": "^3.515.0" - } -} diff --git a/examples/aws-queue/publisher.ts b/examples/aws-queue/publisher.ts deleted file mode 100644 index 3d71dac18d..0000000000 --- a/examples/aws-queue/publisher.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; -const client = new SQSClient(); - -export const handler = async (event) => { - // send a message - await client.send( - new SendMessageCommand({ - QueueUrl: Resource.MyQueue.url, - MessageBody: "Hello from the subscriber", - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-queue/sst.config.ts b/examples/aws-queue/sst.config.ts deleted file mode 100644 index 8e9cb97906..0000000000 --- a/examples/aws-queue/sst.config.ts +++ /dev/null @@ -1,102 +0,0 @@ -/// - -/** - * ## Subscribe to queues - * - * Create an SQS queue, subscribe to it, and publish to it from a function. - * - * ```ts title="sst.config.ts" - * const queue = new sst.aws.Queue("MyQueue"); - * queue.subscribe("subscriber.handler"); - * - * const app = new sst.aws.Function("MyApp", { - * handler: "publisher.handler", - * link: [queue], - * url: true, - * }); - * - * return { - * app: app.url, - * queue: queue.url, - * }; - * ``` - * - * The subscriber will read messages from the queue in batches. This array of messages exists on the `Records` property of the `SQSEvent`. - * - * ```ts title="subscriber.ts" - * import type { SQSEvent, SQSHandler } from "aws-lambda"; - * - * export const handler: SQSHandler = async (event: SQSEvent) => { - * for (const record of event.Records){ - * // Message bodies are always strings - * console.log(record.body) - * } - * return; - * }; - * ``` - * - * By default, all messages in the batch become visible in the queue again if an error occurs. This can lead to unnecessary extra processing and messages being processed more than once. The solution is to enable [partial batch responsese](https://docs.aws.amazon.com/lambda/latest/dg/services-sqs-errorhandling.html#services-sqs-batchfailurereporting) and return which specific messages within the batch should be made visible again in the queue. - * - * Update the queue subscriber. - * - * ```ts title="sst.config.ts" - * queue.subscribe("subscriber.handler", { - * batch: { - * partialResponses: true, - * } - * }); - * ``` - * - * Then update the handler to return the failed items. - * - * ```ts title="subscriber.ts" - * import type { SQSEvent, SQSHandler } from "aws-lambda"; - * - * export const handler: SQSHandler = async (event: SQSEvent) => { - * const batchItemFailures = [] - * for (const record of event.Records){ - * try { - * console.log(record.body) - * if (Math.random() < 0.1){ - * throw new Error("An error occurred") - * } - * } - * catch (e) { - * batchItemFailures.push({ itemIdentifier: record.messageId }); - * } - * } - * - * // Failed items will be made visible in the queue again - * return { batchItemFailures }; - * }; - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-queue", - home: "aws", - removal: input.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const queue = new sst.aws.Queue("MyQueue"); - queue.subscribe("subscriber.handler", { - batch: { - partialResponses: true, - } - }); - - const app = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - link: [queue], - url: true, - }); - - return { - app: app.url, - queue: queue.url, - }; - }, -}); diff --git a/examples/aws-queue/subscriber.ts b/examples/aws-queue/subscriber.ts deleted file mode 100644 index 7fbec8d5c1..0000000000 --- a/examples/aws-queue/subscriber.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { SQSEvent, SQSHandler } from "aws-lambda"; - -export const handler: SQSHandler = async (event: SQSEvent) => { - const batchItemFailures = [] - for (const record of event.Records){ - try { - console.log(record.body) - if (Math.random() < 0.1){ - throw new Error("An error occurred") - } - } - catch (e) { - batchItemFailures.push({ itemIdentifier: record.messageId }); - } - } - - // Failed items will be made visible in the queue again - return { batchItemFailures }; -}; diff --git a/examples/aws-quota-increase/package.json b/examples/aws-quota-increase/package.json deleted file mode 100644 index ddfcda6b92..0000000000 --- a/examples/aws-quota-increase/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-quota-increase", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-quota-increase/sst.config.ts b/examples/aws-quota-increase/sst.config.ts deleted file mode 100644 index 6ce0343ca3..0000000000 --- a/examples/aws-quota-increase/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -/** - * ## AWS Quota Increase - * - * Use the Pulumi AWS provider to request an increase to an AWS service quota. - * In this example, we increase the Lambda concurrent executions quota. - * - * You can find service and quota codes in the - * [AWS Service Quotas console](https://console.aws.amazon.com/servicequotas) or by running - * `aws service-quotas list-service-quotas --service-code `. - */ -export default $config({ - app(input) { - return { - name: "aws-quota-increase", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - new aws.servicequotas.ServiceQuota("LambdaConcurrentExecutions", { - serviceCode: "lambda", - quotaCode: "L-B99A9384", - value: 2000, - }); - }, -}); diff --git a/examples/aws-rails/.dockerignore b/examples/aws-rails/.dockerignore deleted file mode 100644 index 00ce171646..0000000000 --- a/examples/aws-rails/.dockerignore +++ /dev/null @@ -1,52 +0,0 @@ -# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. - -# Ignore git directory. -/.git/ -/.gitignore - -# Ignore bundler config. -/.bundle - -# Ignore all environment files (except templates). -/.env* -!/.env*.erb - -# Ignore all default key files. -/config/master.key -/config/credentials/*.key - -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep - -# Ignore pidfiles, but keep the directory. -/tmp/pids/* -!/tmp/pids/.keep - -# Ignore storage (uploaded files in development and any SQLite databases). -/storage/* -!/storage/.keep -/tmp/storage/* -!/tmp/storage/.keep - -# Ignore assets. -/node_modules/ -/app/assets/builds/* -!/app/assets/builds/.keep -/public/assets - -# Ignore CI service files. -/.github - -# Ignore development files -/.devcontainer - -# Ignore Docker-related files -/.dockerignore -/Dockerfile* - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-rails/.gitattributes b/examples/aws-rails/.gitattributes deleted file mode 100644 index 8dc4323435..0000000000 --- a/examples/aws-rails/.gitattributes +++ /dev/null @@ -1,9 +0,0 @@ -# See https://git-scm.com/docs/gitattributes for more about git attribute files. - -# Mark the database schema as having been generated. -db/schema.rb linguist-generated - -# Mark any vendored files as having been vendored. -vendor/* linguist-vendored -config/credentials/*.yml.enc diff=rails_credentials -config/credentials.yml.enc diff=rails_credentials diff --git a/examples/aws-rails/.github/dependabot.yml b/examples/aws-rails/.github/dependabot.yml deleted file mode 100644 index f0527e6be1..0000000000 --- a/examples/aws-rails/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 diff --git a/examples/aws-rails/.github/workflows/ci.yml b/examples/aws-rails/.github/workflows/ci.yml deleted file mode 100644 index 00af91f692..0000000000 --- a/examples/aws-rails/.github/workflows/ci.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: [ main ] - -jobs: - scan_ruby: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Scan for common Rails security vulnerabilities using static analysis - run: bin/brakeman --no-pager - - scan_js: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Scan for security vulnerabilities in JavaScript dependencies - run: bin/importmap audit - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Lint code for consistent style - run: bin/rubocop -f github - - test: - runs-on: ubuntu-latest - - # services: - # redis: - # image: redis - # ports: - # - 6379:6379 - # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - - name: Install packages - run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Run tests - env: - RAILS_ENV: test - # REDIS_URL: redis://localhost:6379/0 - run: bin/rails db:test:prepare test test:system - - - name: Keep screenshots from failed system tests - uses: actions/upload-artifact@v4 - if: failure() - with: - name: screenshots - path: ${{ github.workspace }}/tmp/screenshots - if-no-files-found: ignore diff --git a/examples/aws-rails/.gitignore b/examples/aws-rails/.gitignore deleted file mode 100644 index 4aaf1022e5..0000000000 --- a/examples/aws-rails/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -# See https://help.github.com/articles/ignoring-files for more about ignoring files. -# -# Temporary files generated by your text editor or operating system -# belong in git's global ignore instead: -# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` - -# Ignore bundler config. -/.bundle - -# Ignore all environment files (except templates). -/.env* -!/.env*.erb - -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep - -# Ignore pidfiles, but keep the directory. -/tmp/pids/* -!/tmp/pids/ -!/tmp/pids/.keep - -# Ignore storage (uploaded files in development and any SQLite databases). -/storage/* -!/storage/.keep -/tmp/storage/* -!/tmp/storage/ -!/tmp/storage/.keep - -/public/assets - -# Ignore master key for decrypting credentials and more. -/config/master.key diff --git a/examples/aws-rails/.rubocop.yml b/examples/aws-rails/.rubocop.yml deleted file mode 100644 index f9d86d4a54..0000000000 --- a/examples/aws-rails/.rubocop.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Omakase Ruby styling for Rails -inherit_gem: { rubocop-rails-omakase: rubocop.yml } - -# Overwrite or add rules to create your own house style -# -# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` -# Layout/SpaceInsideArrayLiteralBrackets: -# Enabled: false diff --git a/examples/aws-rails/.ruby-version b/examples/aws-rails/.ruby-version deleted file mode 100644 index 6d5369b963..0000000000 --- a/examples/aws-rails/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-3.3.4 diff --git a/examples/aws-rails/Dockerfile b/examples/aws-rails/Dockerfile deleted file mode 100644 index 2cb400ed0c..0000000000 --- a/examples/aws-rails/Dockerfile +++ /dev/null @@ -1,69 +0,0 @@ -# syntax = docker/dockerfile:1 - -# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand: -# docker build -t my-app . -# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY= my-app - -# Make sure RUBY_VERSION matches the Ruby version in .ruby-version -ARG RUBY_VERSION=3.3.4 -FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base - -# Rails app lives here -WORKDIR /rails - -# Install base packages -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives - -# Set production environment -ENV RAILS_ENV="production" \ - BUNDLE_DEPLOYMENT="1" \ - BUNDLE_PATH="/usr/local/bundle" \ - BUNDLE_WITHOUT="development" - -# Throw-away build stage to reduce size of final image -FROM base AS build - -# Install packages needed to build gems -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git pkg-config && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives - -# Install application gems -COPY Gemfile Gemfile.lock ./ -RUN bundle install && \ - rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ - bundle exec bootsnap precompile --gemfile - -# Copy application code -COPY . . - -# Precompile bootsnap code for faster boot times -RUN bundle exec bootsnap precompile app/ lib/ - -# Precompiling assets for production without requiring secret RAILS_MASTER_KEY -RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile - - - - -# Final stage for app image -FROM base - -# Copy built artifacts: gems, application -COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" -COPY --from=build /rails /rails - -# Run and own only the runtime files as a non-root user for security -RUN groupadd --system --gid 1000 rails && \ - useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ - chown -R rails:rails db log storage tmp -USER 1000:1000 - -# Entrypoint prepares the database. -ENTRYPOINT ["/rails/bin/docker-entrypoint"] - -# Start the server by default, this can be overwritten at runtime -EXPOSE 3000 -CMD ["./bin/rails", "server"] diff --git a/examples/aws-rails/Gemfile b/examples/aws-rails/Gemfile deleted file mode 100644 index 6f0b5c34d8..0000000000 --- a/examples/aws-rails/Gemfile +++ /dev/null @@ -1,59 +0,0 @@ -source "https://rubygems.org" - -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.2.1" -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" -# Use sqlite3 as the database for Active Record -gem "sqlite3", ">= 1.4" -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" -# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" -# Build JSON APIs with ease [https://github.com/rails/jbuilder] -gem "jbuilder" -# Use Redis adapter to run Action Cable in production -# gem "redis", ">= 4.0.1" - -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" - -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] - -# Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false - -# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] -# gem "image_processing", "~> 1.2" - -group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" - - # Static analysis for security vulnerabilities [https://brakemanscanner.org/] - gem "brakeman", require: false - - # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] - gem "rubocop-rails-omakase", require: false -end - -group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" -end - -group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" - gem "selenium-webdriver" -end - -gem "aws-sdk-s3", "~> 1.166" diff --git a/examples/aws-rails/Gemfile.lock b/examples/aws-rails/Gemfile.lock deleted file mode 100644 index b1e77a3e8c..0000000000 --- a/examples/aws-rails/Gemfile.lock +++ /dev/null @@ -1,344 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.2.1) - actionpack (= 7.2.1) - activesupport (= 7.2.1) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.2.1) - actionpack (= 7.2.1) - activejob (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) - mail (>= 2.8.0) - actionmailer (7.2.1) - actionpack (= 7.2.1) - actionview (= 7.2.1) - activejob (= 7.2.1) - activesupport (= 7.2.1) - mail (>= 2.8.0) - rails-dom-testing (~> 2.2) - actionpack (7.2.1) - actionview (= 7.2.1) - activesupport (= 7.2.1) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.2) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - useragent (~> 0.16) - actiontext (7.2.1) - actionpack (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.2.1) - activesupport (= 7.2.1) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.2.1) - activesupport (= 7.2.1) - globalid (>= 0.3.6) - activemodel (7.2.1) - activesupport (= 7.2.1) - activerecord (7.2.1) - activemodel (= 7.2.1) - activesupport (= 7.2.1) - timeout (>= 0.4.0) - activestorage (7.2.1) - actionpack (= 7.2.1) - activejob (= 7.2.1) - activerecord (= 7.2.1) - activesupport (= 7.2.1) - marcel (~> 1.0) - activesupport (7.2.1) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - ast (2.4.2) - aws-eventstream (1.3.0) - aws-partitions (1.978.0) - aws-sdk-core (3.209.0) - aws-eventstream (~> 1, >= 1.3.0) - aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.9) - jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.94.0) - aws-sdk-core (~> 3, >= 3.207.0) - aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.166.0) - aws-sdk-core (~> 3, >= 3.207.0) - aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.5) - aws-sigv4 (1.10.0) - aws-eventstream (~> 1, >= 1.0.2) - base64 (0.2.0) - bigdecimal (3.1.8) - bindex (0.8.1) - bootsnap (1.18.4) - msgpack (~> 1.2) - brakeman (6.2.1) - racc - builder (3.3.0) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) - crass (1.0.6) - date (3.3.4) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) - drb (2.2.1) - erubi (1.13.0) - globalid (1.2.1) - activesupport (>= 6.1) - i18n (1.14.6) - concurrent-ruby (~> 1.0) - importmap-rails (2.0.1) - actionpack (>= 6.0.0) - activesupport (>= 6.0.0) - railties (>= 6.0.0) - io-console (0.7.2) - irb (1.14.0) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jbuilder (2.13.0) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) - jmespath (1.6.2) - json (2.7.2) - language_server-protocol (3.17.0.3) - logger (1.6.1) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - matrix (0.4.2) - mini_mime (1.1.5) - minitest (5.25.1) - msgpack (1.7.2) - net-imap (0.4.16) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.0) - net-protocol - nio4r (2.7.3) - nokogiri (1.16.7-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86-linux) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) - racc (~> 1.4) - parallel (1.26.3) - parser (3.3.5.0) - ast (~> 2.4.1) - racc - psych (5.1.2) - stringio - public_suffix (6.0.1) - puma (6.4.3) - nio4r (~> 2.0) - racc (1.8.1) - rack (3.1.7) - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.2.1) - actioncable (= 7.2.1) - actionmailbox (= 7.2.1) - actionmailer (= 7.2.1) - actionpack (= 7.2.1) - actiontext (= 7.2.1) - actionview (= 7.2.1) - activejob (= 7.2.1) - activemodel (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) - bundler (>= 1.15.0) - railties (= 7.2.1) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.2.1) - actionpack (= 7.2.1) - activesupport (= 7.2.1) - irb (~> 1.13) - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rainbow (3.1.1) - rake (13.2.1) - rdoc (6.7.0) - psych (>= 4.0.0) - regexp_parser (2.9.2) - reline (0.5.10) - io-console (~> 0.5) - rexml (3.3.7) - rubocop (1.66.1) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) - parser (>= 3.3.1.0) - rubocop-minitest (0.36.0) - rubocop (>= 1.61, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-performance (1.22.1) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.26.2) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.52.0, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails-omakase (1.0.0) - rubocop - rubocop-minitest - rubocop-performance - rubocop-rails - ruby-progressbar (1.13.0) - rubyzip (2.3.2) - securerandom (0.3.1) - selenium-webdriver (4.25.0) - base64 (~> 0.2) - logger (~> 1.4) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - sqlite3 (2.0.4-aarch64-linux-gnu) - sqlite3 (2.0.4-aarch64-linux-musl) - sqlite3 (2.0.4-arm-linux-gnu) - sqlite3 (2.0.4-arm-linux-musl) - sqlite3 (2.0.4-arm64-darwin) - sqlite3 (2.0.4-x86-linux-gnu) - sqlite3 (2.0.4-x86-linux-musl) - sqlite3 (2.0.4-x86_64-darwin) - sqlite3 (2.0.4-x86_64-linux-gnu) - sqlite3 (2.0.4-x86_64-linux-musl) - stimulus-rails (1.3.4) - railties (>= 6.0.0) - stringio (3.1.1) - thor (1.3.2) - timeout (0.4.1) - turbo-rails (2.0.10) - actionpack (>= 6.0.0) - railties (>= 6.0.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - unicode-display_width (2.6.0) - useragent (0.16.10) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - webrick (1.8.2) - websocket (1.2.11) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - zeitwerk (2.6.18) - -PLATFORMS - aarch64-linux - aarch64-linux-gnu - aarch64-linux-musl - arm-linux - arm-linux-gnu - arm-linux-musl - arm64-darwin - x86-linux - x86-linux-gnu - x86-linux-musl - x86_64-darwin - x86_64-linux - x86_64-linux-gnu - x86_64-linux-musl - -DEPENDENCIES - aws-sdk-s3 (~> 1.166) - bootsnap - brakeman - capybara - debug - importmap-rails - jbuilder - puma (>= 5.0) - rails (~> 7.2.1) - rubocop-rails-omakase - selenium-webdriver - sprockets-rails - sqlite3 (>= 1.4) - stimulus-rails - turbo-rails - tzinfo-data - web-console - -BUNDLED WITH - 2.5.11 diff --git a/examples/aws-rails/Rakefile b/examples/aws-rails/Rakefile deleted file mode 100644 index 9a5ea7383a..0000000000 --- a/examples/aws-rails/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require_relative "config/application" - -Rails.application.load_tasks diff --git a/examples/aws-rails/app/assets/config/manifest.js b/examples/aws-rails/app/assets/config/manifest.js deleted file mode 100644 index ddd546a0be..0000000000 --- a/examples/aws-rails/app/assets/config/manifest.js +++ /dev/null @@ -1,4 +0,0 @@ -//= link_tree ../images -//= link_directory ../stylesheets .css -//= link_tree ../../javascript .js -//= link_tree ../../../vendor/javascript .js diff --git a/examples/aws-rails/app/assets/images/.keep b/examples/aws-rails/app/assets/images/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/app/assets/stylesheets/application.css b/examples/aws-rails/app/assets/stylesheets/application.css deleted file mode 100644 index 288b9ab718..0000000000 --- a/examples/aws-rails/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's - * vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/examples/aws-rails/app/channels/application_cable/channel.rb b/examples/aws-rails/app/channels/application_cable/channel.rb deleted file mode 100644 index d672697283..0000000000 --- a/examples/aws-rails/app/channels/application_cable/channel.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Channel < ActionCable::Channel::Base - end -end diff --git a/examples/aws-rails/app/channels/application_cable/connection.rb b/examples/aws-rails/app/channels/application_cable/connection.rb deleted file mode 100644 index 0ff5442f47..0000000000 --- a/examples/aws-rails/app/channels/application_cable/connection.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Connection < ActionCable::Connection::Base - end -end diff --git a/examples/aws-rails/app/controllers/application_controller.rb b/examples/aws-rails/app/controllers/application_controller.rb deleted file mode 100644 index 0d95db22b4..0000000000 --- a/examples/aws-rails/app/controllers/application_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationController < ActionController::Base - # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. - allow_browser versions: :modern -end diff --git a/examples/aws-rails/app/controllers/concerns/.keep b/examples/aws-rails/app/controllers/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/app/controllers/uploads_controller.rb b/examples/aws-rails/app/controllers/uploads_controller.rb deleted file mode 100644 index ed99b774d6..0000000000 --- a/examples/aws-rails/app/controllers/uploads_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -class UploadsController < ApplicationController - skip_before_action :verify_authenticity_token - - def new - end - - def create - blob = ActiveStorage::Blob.create_and_upload!( - io: params[:file].tempfile, - filename: params[:file].original_filename, - content_type: params[:file].content_type - ) - url = "https://#{ActiveStorage::Blob.service.bucket.name}.s3.amazonaws.com/#{blob.key}" - redirect_to root_path(uploaded_url: url) - end -end diff --git a/examples/aws-rails/app/helpers/application_helper.rb b/examples/aws-rails/app/helpers/application_helper.rb deleted file mode 100644 index de6be7945c..0000000000 --- a/examples/aws-rails/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/examples/aws-rails/app/helpers/uploads_helper.rb b/examples/aws-rails/app/helpers/uploads_helper.rb deleted file mode 100644 index f4f8250f5e..0000000000 --- a/examples/aws-rails/app/helpers/uploads_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UploadsHelper -end diff --git a/examples/aws-rails/app/javascript/application.js b/examples/aws-rails/app/javascript/application.js deleted file mode 100644 index 0d7b49404c..0000000000 --- a/examples/aws-rails/app/javascript/application.js +++ /dev/null @@ -1,3 +0,0 @@ -// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails -import "@hotwired/turbo-rails" -import "controllers" diff --git a/examples/aws-rails/app/javascript/controllers/application.js b/examples/aws-rails/app/javascript/controllers/application.js deleted file mode 100644 index 1213e85c7a..0000000000 --- a/examples/aws-rails/app/javascript/controllers/application.js +++ /dev/null @@ -1,9 +0,0 @@ -import { Application } from "@hotwired/stimulus" - -const application = Application.start() - -// Configure Stimulus development experience -application.debug = false -window.Stimulus = application - -export { application } diff --git a/examples/aws-rails/app/javascript/controllers/hello_controller.js b/examples/aws-rails/app/javascript/controllers/hello_controller.js deleted file mode 100644 index 5975c0789d..0000000000 --- a/examples/aws-rails/app/javascript/controllers/hello_controller.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - connect() { - this.element.textContent = "Hello World!" - } -} diff --git a/examples/aws-rails/app/javascript/controllers/index.js b/examples/aws-rails/app/javascript/controllers/index.js deleted file mode 100644 index 1156bf8362..0000000000 --- a/examples/aws-rails/app/javascript/controllers/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// Import and register all your controllers from the importmap via controllers/**/*_controller -import { application } from "controllers/application" -import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" -eagerLoadControllersFrom("controllers", application) diff --git a/examples/aws-rails/app/jobs/application_job.rb b/examples/aws-rails/app/jobs/application_job.rb deleted file mode 100644 index d394c3d106..0000000000 --- a/examples/aws-rails/app/jobs/application_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ApplicationJob < ActiveJob::Base - # Automatically retry jobs that encountered a deadlock - # retry_on ActiveRecord::Deadlocked - - # Most jobs are safe to ignore if the underlying records are no longer available - # discard_on ActiveJob::DeserializationError -end diff --git a/examples/aws-rails/app/mailers/application_mailer.rb b/examples/aws-rails/app/mailers/application_mailer.rb deleted file mode 100644 index 3c34c8148f..0000000000 --- a/examples/aws-rails/app/mailers/application_mailer.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" - layout "mailer" -end diff --git a/examples/aws-rails/app/models/application_record.rb b/examples/aws-rails/app/models/application_record.rb deleted file mode 100644 index b63caeb8a5..0000000000 --- a/examples/aws-rails/app/models/application_record.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ApplicationRecord < ActiveRecord::Base - primary_abstract_class -end diff --git a/examples/aws-rails/app/models/concerns/.keep b/examples/aws-rails/app/models/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/app/views/layouts/application.html.erb b/examples/aws-rails/app/views/layouts/application.html.erb deleted file mode 100644 index bcf1d45a7d..0000000000 --- a/examples/aws-rails/app/views/layouts/application.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - - <%= content_for(:title) || "Aws Rails" %> - - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= yield :head %> - - - - - - <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - <%= javascript_importmap_tags %> - - - - <%= yield %> - - diff --git a/examples/aws-rails/app/views/layouts/mailer.html.erb b/examples/aws-rails/app/views/layouts/mailer.html.erb deleted file mode 100644 index 3aac9002ed..0000000000 --- a/examples/aws-rails/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - <%= yield %> - - diff --git a/examples/aws-rails/app/views/layouts/mailer.text.erb b/examples/aws-rails/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bddbd7..0000000000 --- a/examples/aws-rails/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/examples/aws-rails/app/views/pwa/manifest.json.erb b/examples/aws-rails/app/views/pwa/manifest.json.erb deleted file mode 100644 index 107dff4398..0000000000 --- a/examples/aws-rails/app/views/pwa/manifest.json.erb +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "AwsRails", - "icons": [ - { - "src": "/icon.png", - "type": "image/png", - "sizes": "512x512" - }, - { - "src": "/icon.png", - "type": "image/png", - "sizes": "512x512", - "purpose": "maskable" - } - ], - "start_url": "/", - "display": "standalone", - "scope": "/", - "description": "AwsRails.", - "theme_color": "red", - "background_color": "red" -} diff --git a/examples/aws-rails/app/views/pwa/service-worker.js b/examples/aws-rails/app/views/pwa/service-worker.js deleted file mode 100644 index b3a13fb7bb..0000000000 --- a/examples/aws-rails/app/views/pwa/service-worker.js +++ /dev/null @@ -1,26 +0,0 @@ -// Add a service worker for processing Web Push notifications: -// -// self.addEventListener("push", async (event) => { -// const { title, options } = await event.data.json() -// event.waitUntil(self.registration.showNotification(title, options)) -// }) -// -// self.addEventListener("notificationclick", function(event) { -// event.notification.close() -// event.waitUntil( -// clients.matchAll({ type: "window" }).then((clientList) => { -// for (let i = 0; i < clientList.length; i++) { -// let client = clientList[i] -// let clientPath = (new URL(client.url)).pathname -// -// if (clientPath == event.notification.data.path && "focus" in client) { -// return client.focus() -// } -// } -// -// if (clients.openWindow) { -// return clients.openWindow(event.notification.data.path) -// } -// }) -// ) -// }) diff --git a/examples/aws-rails/app/views/uploads/create.html.erb b/examples/aws-rails/app/views/uploads/create.html.erb deleted file mode 100644 index 40f4a011c9..0000000000 --- a/examples/aws-rails/app/views/uploads/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Uploads#create

-

Find me in app/views/uploads/create.html.erb

diff --git a/examples/aws-rails/app/views/uploads/new.html.erb b/examples/aws-rails/app/views/uploads/new.html.erb deleted file mode 100644 index ff92b3994d..0000000000 --- a/examples/aws-rails/app/views/uploads/new.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

Upload an Image

- -<%= form_with(url: upload_path, local: true, multipart: true) do |form| %> -
- <%= form.label :file %> - <%= form.file_field :file %> -
- - <%= form.submit 'Upload Image' %> -<% end %> - -<% if params[:uploaded_url].present? %> -

Your file has been uploaded! You can access it here:

- <%= link_to params[:uploaded_url], params[:uploaded_url], target: '_blank' %> -<% end %> \ No newline at end of file diff --git a/examples/aws-rails/bin/brakeman b/examples/aws-rails/bin/brakeman deleted file mode 100755 index ace1c9ba08..0000000000 --- a/examples/aws-rails/bin/brakeman +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ruby -require "rubygems" -require "bundler/setup" - -ARGV.unshift("--ensure-latest") - -load Gem.bin_path("brakeman", "brakeman") diff --git a/examples/aws-rails/bin/bundle b/examples/aws-rails/bin/bundle deleted file mode 100755 index 50da5fdf9e..0000000000 --- a/examples/aws-rails/bin/bundle +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'bundle' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "rubygems" - -m = Module.new do - module_function - - def invoked_as_script? - File.expand_path($0) == File.expand_path(__FILE__) - end - - def env_var_version - ENV["BUNDLER_VERSION"] - end - - def cli_arg_version - return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` - bundler_version = nil - update_index = nil - ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) - bundler_version = a - end - next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 - update_index = i - end - bundler_version - end - - def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] - return gemfile if gemfile && !gemfile.empty? - - File.expand_path("../Gemfile", __dir__) - end - - def lockfile - lockfile = - case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") - else "#{gemfile}.lock" - end - File.expand_path(lockfile) - end - - def lockfile_version - return unless File.file?(lockfile) - lockfile_contents = File.read(lockfile) - return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ - Regexp.last_match(1) - end - - def bundler_requirement - @bundler_requirement ||= - env_var_version || - cli_arg_version || - bundler_requirement_for(lockfile_version) - end - - def bundler_requirement_for(version) - return "#{Gem::Requirement.default}.a" unless version - - bundler_gem_version = Gem::Version.new(version) - - bundler_gem_version.approximate_recommendation - end - - def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile - - activate_bundler - end - - def activate_bundler - gem_error = activation_error_handling do - gem "bundler", bundler_requirement - end - return if gem_error.nil? - require_error = activation_error_handling do - require "bundler/version" - end - return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) - warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" - exit 42 - end - - def activation_error_handling - yield - nil - rescue StandardError, LoadError => e - e - end -end - -m.load_bundler! - -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end diff --git a/examples/aws-rails/bin/docker-entrypoint b/examples/aws-rails/bin/docker-entrypoint deleted file mode 100755 index 840d093a9a..0000000000 --- a/examples/aws-rails/bin/docker-entrypoint +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -e - -# Enable jemalloc for reduced memory usage and latency. -if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then - export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)" -fi - -# If running the rails server then create or migrate existing database -if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then - ./bin/rails db:prepare -fi - -exec "${@}" diff --git a/examples/aws-rails/bin/importmap b/examples/aws-rails/bin/importmap deleted file mode 100755 index 36502ab16c..0000000000 --- a/examples/aws-rails/bin/importmap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../config/application" -require "importmap/commands" diff --git a/examples/aws-rails/bin/rails b/examples/aws-rails/bin/rails deleted file mode 100755 index efc0377492..0000000000 --- a/examples/aws-rails/bin/rails +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" diff --git a/examples/aws-rails/bin/rake b/examples/aws-rails/bin/rake deleted file mode 100755 index 4fbf10b960..0000000000 --- a/examples/aws-rails/bin/rake +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" -Rake.application.run diff --git a/examples/aws-rails/bin/rubocop b/examples/aws-rails/bin/rubocop deleted file mode 100755 index 40330c0ff1..0000000000 --- a/examples/aws-rails/bin/rubocop +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -require "rubygems" -require "bundler/setup" - -# explicit rubocop config increases performance slightly while avoiding config confusion. -ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) - -load Gem.bin_path("rubocop", "rubocop") diff --git a/examples/aws-rails/bin/setup b/examples/aws-rails/bin/setup deleted file mode 100755 index ee2b54d365..0000000000 --- a/examples/aws-rails/bin/setup +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env ruby -require "fileutils" - -APP_ROOT = File.expand_path("..", __dir__) -APP_NAME = "aws-rails" - -def system!(*args) - system(*args, exception: true) -end - -FileUtils.chdir APP_ROOT do - # This script is a way to set up or update your development environment automatically. - # This script is idempotent, so that you can run it at any time and get an expectable outcome. - # Add necessary setup steps to this file. - - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") - - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" - # end - - puts "\n== Preparing database ==" - system! "bin/rails db:prepare" - - puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" - - puts "\n== Restarting application server ==" - system! "bin/rails restart" - - # puts "\n== Configuring puma-dev ==" - # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" - # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" -end diff --git a/examples/aws-rails/config.ru b/examples/aws-rails/config.ru deleted file mode 100644 index 4a3c09a688..0000000000 --- a/examples/aws-rails/config.ru +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require_relative "config/environment" - -run Rails.application -Rails.application.load_server diff --git a/examples/aws-rails/config/application.rb b/examples/aws-rails/config/application.rb deleted file mode 100644 index 2cfa3ae1b8..0000000000 --- a/examples/aws-rails/config/application.rb +++ /dev/null @@ -1,27 +0,0 @@ -require_relative "boot" - -require "rails/all" - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) - -module AwsRails - class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.2 - - # Please, add to the `ignore` list any other `lib` subdirectories that do - # not contain `.rb` files, or that should not be reloaded or eager loaded. - # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w[assets tasks]) - - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - end -end diff --git a/examples/aws-rails/config/boot.rb b/examples/aws-rails/config/boot.rb deleted file mode 100644 index 988a5ddc46..0000000000 --- a/examples/aws-rails/config/boot.rb +++ /dev/null @@ -1,4 +0,0 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) - -require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/examples/aws-rails/config/cable.yml b/examples/aws-rails/config/cable.yml deleted file mode 100644 index 054e1be48a..0000000000 --- a/examples/aws-rails/config/cable.yml +++ /dev/null @@ -1,10 +0,0 @@ -development: - adapter: async - -test: - adapter: test - -production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: aws_rails_production diff --git a/examples/aws-rails/config/credentials.yml.enc b/examples/aws-rails/config/credentials.yml.enc deleted file mode 100644 index d4211c0f89..0000000000 --- a/examples/aws-rails/config/credentials.yml.enc +++ /dev/null @@ -1 +0,0 @@ -vEY6y3HLNkBS+aarod5P3ix27Cd3nK+QXtCvgMCUsEh1EmWcwsCRYJk/hBzwZyKtjHjTIUTJ7oeF2NkzKbYeAPOTBazpjAg7GC5oVAy1GLYVTZM+h0c58AWMLCjww8v1/i4Ju4AgcigPyNSlary4KnCjJO6HGsBXGHCH9FxHIasacQYz6ZvblHWQ1qEshmdfY3OWStRjyNCJS3a6KzTrFDwpMwP1s6ZyJxGCUj4ldqTI8s/EUyWdRcNg+CRyaXA/ElwgF78uvQe8RSHtC0ited59VtgaUIXRyKnrJ3Tz1kNYFICmERrny5rrOUFpnEbaujGdPj4xLhiMGQtuafzW1c32dZgFehchE7fIuR2jP+nDpIbglJ3z5MXnLNPanIkai4Xq6X2UVlZwCXhFUOE2cEc3eVUm--KhoSxVW3jXtFnuv8--AoRt1fW/zNvGsMnm7tOOZQ== \ No newline at end of file diff --git a/examples/aws-rails/config/database.yml b/examples/aws-rails/config/database.yml deleted file mode 100644 index c480dcb827..0000000000 --- a/examples/aws-rails/config/database.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem "sqlite3" -# -default: &default - adapter: sqlite3 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 - -development: - <<: *default - database: storage/development.sqlite3 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default - database: storage/test.sqlite3 - -# SQLite3 write its data on the local filesystem, as such it requires -# persistent disks. If you are deploying to a managed service, you should -# make sure it provides disk persistence, as many don't. -# -# Similarly, if you deploy your application as a Docker container, you must -# ensure the database is located in a persisted volume. -production: - <<: *default - database: /tmp/production.sqlite3 diff --git a/examples/aws-rails/config/environment.rb b/examples/aws-rails/config/environment.rb deleted file mode 100644 index cac5315775..0000000000 --- a/examples/aws-rails/config/environment.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the Rails application. -require_relative "application" - -# Initialize the Rails application. -Rails.application.initialize! diff --git a/examples/aws-rails/config/environments/development.rb b/examples/aws-rails/config/environments/development.rb deleted file mode 100644 index fc5d7282e3..0000000000 --- a/examples/aws-rails/config/environments/development.rb +++ /dev/null @@ -1,81 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.enable_reloading = true - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports. - config.consider_all_requests_local = true - - # Enable server timing. - config.server_timing = true - - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? - config.action_controller.perform_caching = true - config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } - else - config.action_controller.perform_caching = false - - config.cache_store = :null_store - end - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :amazon - - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - - config.action_mailer.default_url_options = { host: "localhost", port: 3000 } - - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load - - # Highlight code that triggered database queries in logs. - config.active_record.verbose_query_logs = true - - # Highlight code that enqueued background job in logs. - config.active_job.verbose_enqueue_logs = true - - # Suppress logger output for asset requests. - config.assets.quiet = true - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - config.action_view.annotate_rendered_view_with_filenames = true - - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true - - # Raise error when a before_action's only/except options reference missing actions. - config.action_controller.raise_on_missing_callback_actions = true - - # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. - # config.generators.apply_rubocop_autocorrect_after_generate! -end diff --git a/examples/aws-rails/config/environments/production.rb b/examples/aws-rails/config/environments/production.rb deleted file mode 100644 index ff26add9ba..0000000000 --- a/examples/aws-rails/config/environments/production.rb +++ /dev/null @@ -1,102 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.enable_reloading = false - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment - # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. - # config.public_file_server.enabled = false - - # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass - - # Do not fall back to assets pipeline if a precompiled asset is missed. - config.assets.compile = false - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :amazon - - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # Assume all access to the app is happening through a SSL-terminating reverse proxy. - # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. - # config.assume_ssl = true - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Skip http-to-https redirect for the default health check endpoint. - # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - - # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] - - # "info" includes generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "aws_rails_production" - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Don't log any deprecations. - config.active_support.report_deprecations = false - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false - - # Enable DNS rebinding protection and other `Host` header attacks. - # config.hosts = [ - # "example.com", # Allow requests from example.com - # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` - # ] - # Skip DNS rebinding protection for the default health check endpoint. - # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } -end diff --git a/examples/aws-rails/config/environments/test.rb b/examples/aws-rails/config/environments/test.rb deleted file mode 100644 index 0c616a1bf5..0000000000 --- a/examples/aws-rails/config/environments/test.rb +++ /dev/null @@ -1,67 +0,0 @@ -require "active_support/core_ext/integer/time" - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # While tests run files are not watched, reloading is not necessary. - config.enable_reloading = false - - # Eager loading loads your entire application. When running a single test locally, - # this is usually not necessary, and can slow down your test suite. However, it's - # recommended that you enable it in continuous integration systems to ensure eager - # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? - - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } - - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.cache_store = :null_store - - # Render exception templates for rescuable exceptions and raise for other exceptions. - config.action_dispatch.show_exceptions = :rescuable - - # Disable request forgery protection in test environment. - config.action_controller.allow_forgery_protection = false - - # Store uploaded files on the local file system in a temporary directory. - config.active_storage.service = :test - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - - # Unlike controllers, the mailer instance doesn't have any context about the - # incoming request so you'll need to provide the :host parameter yourself. - config.action_mailer.default_url_options = { host: "www.example.com" } - - # Print deprecation notices to the stderr. - config.active_support.deprecation = :stderr - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true - - # Raise error when a before_action's only/except options reference missing actions. - config.action_controller.raise_on_missing_callback_actions = true -end diff --git a/examples/aws-rails/config/importmap.rb b/examples/aws-rails/config/importmap.rb deleted file mode 100644 index 909dfc542d..0000000000 --- a/examples/aws-rails/config/importmap.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Pin npm packages by running ./bin/importmap - -pin "application" -pin "@hotwired/turbo-rails", to: "turbo.min.js" -pin "@hotwired/stimulus", to: "stimulus.min.js" -pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" -pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/examples/aws-rails/config/initializers/assets.rb b/examples/aws-rails/config/initializers/assets.rb deleted file mode 100644 index bd5bcd2b6a..0000000000 --- a/examples/aws-rails/config/initializers/assets.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = "1.0" - -# Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path - -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in the app/assets -# folder are already added. -# Rails.application.config.assets.precompile += %w[ admin.js admin.css ] diff --git a/examples/aws-rails/config/initializers/content_security_policy.rb b/examples/aws-rails/config/initializers/content_security_policy.rb deleted file mode 100644 index b3076b38fe..0000000000 --- a/examples/aws-rails/config/initializers/content_security_policy.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide content security policy. -# See the Securing Rails Applications Guide for more information: -# https://guides.rubyonrails.org/security.html#content-security-policy-header - -# Rails.application.configure do -# config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # Generate session nonces for permitted importmap, inline scripts, and inline styles. -# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src style-src) -# -# # Report violations without enforcing the policy. -# # config.content_security_policy_report_only = true -# end diff --git a/examples/aws-rails/config/initializers/filter_parameter_logging.rb b/examples/aws-rails/config/initializers/filter_parameter_logging.rb deleted file mode 100644 index c010b83ddd..0000000000 --- a/examples/aws-rails/config/initializers/filter_parameter_logging.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. -# Use this to limit dissemination of sensitive information. -# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. -Rails.application.config.filter_parameters += [ - :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn -] diff --git a/examples/aws-rails/config/initializers/inflections.rb b/examples/aws-rails/config/initializers/inflections.rb deleted file mode 100644 index 3860f659ea..0000000000 --- a/examples/aws-rails/config/initializers/inflections.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format. Inflections -# are locale specific, and you may define rules for as many different -# locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, "\\1en" -# inflect.singular /^(ox)en/i, "\\1" -# inflect.irregular "person", "people" -# inflect.uncountable %w( fish sheep ) -# end - -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym "RESTful" -# end diff --git a/examples/aws-rails/config/initializers/permissions_policy.rb b/examples/aws-rails/config/initializers/permissions_policy.rb deleted file mode 100644 index 7db3b9577e..0000000000 --- a/examples/aws-rails/config/initializers/permissions_policy.rb +++ /dev/null @@ -1,13 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide HTTP permissions policy. For further -# information see: https://developers.google.com/web/updates/2018/06/feature-policy - -# Rails.application.config.permissions_policy do |policy| -# policy.camera :none -# policy.gyroscope :none -# policy.microphone :none -# policy.usb :none -# policy.fullscreen :self -# policy.payment :self, "https://secure.example.com" -# end diff --git a/examples/aws-rails/config/locales/en.yml b/examples/aws-rails/config/locales/en.yml deleted file mode 100644 index 6c349ae5e3..0000000000 --- a/examples/aws-rails/config/locales/en.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Files in the config/locales directory are used for internationalization and -# are automatically loaded by Rails. If you want to use locales other than -# English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t "hello" -# -# In views, this is aliased to just `t`: -# -# <%= t("hello") %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# To learn more about the API, please read the Rails Internationalization guide -# at https://guides.rubyonrails.org/i18n.html. -# -# Be aware that YAML interprets the following case-insensitive strings as -# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings -# must be quoted to be interpreted as strings. For example: -# -# en: -# "yes": yup -# enabled: "ON" - -en: - hello: "Hello world" diff --git a/examples/aws-rails/config/puma.rb b/examples/aws-rails/config/puma.rb deleted file mode 100644 index 03c166f4cf..0000000000 --- a/examples/aws-rails/config/puma.rb +++ /dev/null @@ -1,34 +0,0 @@ -# This configuration file will be evaluated by Puma. The top-level methods that -# are invoked here are part of Puma's configuration DSL. For more information -# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. - -# Puma starts a configurable number of processes (workers) and each process -# serves each request in a thread from an internal thread pool. -# -# The ideal number of threads per worker depends both on how much time the -# application spends waiting for IO operations and on how much you wish to -# to prioritize throughput over latency. -# -# As a rule of thumb, increasing the number of threads will increase how much -# traffic a given process can handle (throughput), but due to CRuby's -# Global VM Lock (GVL) it has diminishing returns and will degrade the -# response time (latency) of the application. -# -# The default is set to 3 threads as it's deemed a decent compromise between -# throughput and latency for the average Rails application. -# -# Any libraries that use a connection pool or another resource pool should -# be configured to provide at least as many connections as the number of -# threads. This includes Active Record's `pool` parameter in `database.yml`. -threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) -threads threads_count, threads_count - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch("PORT", 3000) - -# Allow puma to be restarted by `bin/rails restart` command. -plugin :tmp_restart - -# Specify the PID file. Defaults to tmp/pids/server.pid in development. -# In other environments, only set the PID file if requested. -pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/examples/aws-rails/config/routes.rb b/examples/aws-rails/config/routes.rb deleted file mode 100644 index 0a9237b608..0000000000 --- a/examples/aws-rails/config/routes.rb +++ /dev/null @@ -1,16 +0,0 @@ -Rails.application.routes.draw do - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - root 'uploads#new' - post 'upload', to: 'uploads#create' - - # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. - # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", as: :rails_health_check - - # Render dynamic PWA files from app/views/pwa/* - get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker - get "manifest" => "rails/pwa#manifest", as: :pwa_manifest - - # Defines the root path route ("/") - # root "posts#index" -end diff --git a/examples/aws-rails/config/storage.yml b/examples/aws-rails/config/storage.yml deleted file mode 100644 index 823aa5f7ff..0000000000 --- a/examples/aws-rails/config/storage.yml +++ /dev/null @@ -1,34 +0,0 @@ -test: - service: Disk - root: <%= Rails.root.join("tmp/storage") %> - -local: - service: Disk - root: <%= Rails.root.join("storage") %> - -# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) -amazon: - service: S3 - # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> - # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> - # region: us-east-1 - bucket: <%= JSON.parse(ENV["SST_RESOURCE_MyBucket"])["name"] %> - -# Remember not to checkin your GCS keyfile to a repository -# google: -# service: GCS -# project: your_project -# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> -# bucket: your_own_bucket-<%= Rails.env %> - -# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) -# microsoft: -# service: AzureStorage -# storage_account_name: your_account_name -# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> -# container: your_container_name-<%= Rails.env %> - -# mirror: -# service: Mirror -# primary: local -# mirrors: [ amazon, google, microsoft ] diff --git a/examples/aws-rails/db/migrate/20240925124201_create_active_storage_tables.active_storage.rb b/examples/aws-rails/db/migrate/20240925124201_create_active_storage_tables.active_storage.rb deleted file mode 100644 index 6bd8bd082a..0000000000 --- a/examples/aws-rails/db/migrate/20240925124201_create_active_storage_tables.active_storage.rb +++ /dev/null @@ -1,57 +0,0 @@ -# This migration comes from active_storage (originally 20170806125915) -class CreateActiveStorageTables < ActiveRecord::Migration[7.0] - def change - # Use Active Record's configured type for primary and foreign keys - primary_key_type, foreign_key_type = primary_and_foreign_key_types - - create_table :active_storage_blobs, id: primary_key_type do |t| - t.string :key, null: false - t.string :filename, null: false - t.string :content_type - t.text :metadata - t.string :service_name, null: false - t.bigint :byte_size, null: false - t.string :checksum - - if connection.supports_datetime_with_precision? - t.datetime :created_at, precision: 6, null: false - else - t.datetime :created_at, null: false - end - - t.index [ :key ], unique: true - end - - create_table :active_storage_attachments, id: primary_key_type do |t| - t.string :name, null: false - t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type - t.references :blob, null: false, type: foreign_key_type - - if connection.supports_datetime_with_precision? - t.datetime :created_at, precision: 6, null: false - else - t.datetime :created_at, null: false - end - - t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - - create_table :active_storage_variant_records, id: primary_key_type do |t| - t.belongs_to :blob, null: false, index: false, type: foreign_key_type - t.string :variation_digest, null: false - - t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - end - - private - def primary_and_foreign_key_types - config = Rails.configuration.generators - setting = config.options[config.orm][:primary_key_type] - primary_key_type = setting || :primary_key - foreign_key_type = setting || :bigint - [ primary_key_type, foreign_key_type ] - end -end diff --git a/examples/aws-rails/db/schema.rb b/examples/aws-rails/db/schema.rb deleted file mode 100644 index 19ba58775c..0000000000 --- a/examples/aws-rails/db/schema.rb +++ /dev/null @@ -1,44 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.2].define(version: 2024_09_25_124201) do - create_table "active_storage_attachments", force: :cascade do |t| - t.string "name", null: false - t.string "record_type", null: false - t.bigint "record_id", null: false - t.bigint "blob_id", null: false - t.datetime "created_at", null: false - t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" - t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true - end - - create_table "active_storage_blobs", force: :cascade do |t| - t.string "key", null: false - t.string "filename", null: false - t.string "content_type" - t.text "metadata" - t.string "service_name", null: false - t.bigint "byte_size", null: false - t.string "checksum" - t.datetime "created_at", null: false - t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true - end - - create_table "active_storage_variant_records", force: :cascade do |t| - t.bigint "blob_id", null: false - t.string "variation_digest", null: false - t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true - end - - add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" - add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" -end diff --git a/examples/aws-rails/db/seeds.rb b/examples/aws-rails/db/seeds.rb deleted file mode 100644 index 4fbd6ed970..0000000000 --- a/examples/aws-rails/db/seeds.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This file should ensure the existence of records required to run the application in every environment (production, -# development, test). The code here should be idempotent so that it can be executed at any point in every environment. -# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). -# -# Example: -# -# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| -# MovieGenre.find_or_create_by!(name: genre_name) -# end diff --git a/examples/aws-rails/lib/assets/.keep b/examples/aws-rails/lib/assets/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/lib/sst.rb b/examples/aws-rails/lib/sst.rb deleted file mode 100644 index 6b5cda9152..0000000000 --- a/examples/aws-rails/lib/sst.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'json' -module SST - class << self - private - - def parse_resource(resource_name) - env_var = "SST_RESOURCE_#{resource_name}" - parse_json(ENV[env_var]) - end - - def parse_json(json_string) - return nil if json_string.nil? - JSON.parse(json_string) - rescue JSON::ParserError - json_string # Return the original string if it's not valid JSON - end - - end - - def MyService - @MyService ||= parse_resource('MyService') - end - - def MyVpc - @MyVpc ||= parse_resource('MyVpc') - end - - def MyBucket - @MyBucket ||= parse_resource('MyBucket') - end - -end diff --git a/examples/aws-rails/lib/tasks/.keep b/examples/aws-rails/lib/tasks/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/log/.keep b/examples/aws-rails/log/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/public/404.html b/examples/aws-rails/public/404.html deleted file mode 100644 index 2be3af26fc..0000000000 --- a/examples/aws-rails/public/404.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/examples/aws-rails/public/406-unsupported-browser.html b/examples/aws-rails/public/406-unsupported-browser.html deleted file mode 100644 index 7cf1e168e6..0000000000 --- a/examples/aws-rails/public/406-unsupported-browser.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - Your browser is not supported (406) - - - - - - -
-
-

Your browser is not supported.

-

Please upgrade your browser to continue.

-
-
- - diff --git a/examples/aws-rails/public/422.html b/examples/aws-rails/public/422.html deleted file mode 100644 index c08eac0d1d..0000000000 --- a/examples/aws-rails/public/422.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/examples/aws-rails/public/500.html b/examples/aws-rails/public/500.html deleted file mode 100644 index 78a030af22..0000000000 --- a/examples/aws-rails/public/500.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/examples/aws-rails/public/icon.png b/examples/aws-rails/public/icon.png deleted file mode 100644 index f3b5abcbde..0000000000 Binary files a/examples/aws-rails/public/icon.png and /dev/null differ diff --git a/examples/aws-rails/public/icon.svg b/examples/aws-rails/public/icon.svg deleted file mode 100644 index 78307ccd4b..0000000000 --- a/examples/aws-rails/public/icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/aws-rails/public/robots.txt b/examples/aws-rails/public/robots.txt deleted file mode 100644 index c19f78ab68..0000000000 --- a/examples/aws-rails/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ -# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/examples/aws-rails/sst.config.ts b/examples/aws-rails/sst.config.ts deleted file mode 100644 index 9e2658ee3f..0000000000 --- a/examples/aws-rails/sst.config.ts +++ /dev/null @@ -1,41 +0,0 @@ -/// - -/** - * ## Rails container - * - * Deploy a Ruby on Rails app in a container with a linked public S3 bucket. - */ -export default $config({ - app(input) { - return { - name: "aws-rails", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - environment: { - RAILS_MASTER_KEY: (await import("fs")).readFileSync( - "config/master.key", - "utf8" - ), - }, - dev: { - command: "bin/rails server", - }, - link: [bucket], - }); - return { vpc: vpc.id }; - }, -}); diff --git a/examples/aws-rails/storage/.keep b/examples/aws-rails/storage/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/application_system_test_case.rb b/examples/aws-rails/test/application_system_test_case.rb deleted file mode 100644 index cee29fd214..0000000000 --- a/examples/aws-rails/test/application_system_test_case.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "test_helper" - -class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] -end diff --git a/examples/aws-rails/test/channels/application_cable/connection_test.rb b/examples/aws-rails/test/channels/application_cable/connection_test.rb deleted file mode 100644 index 6340bf9c04..0000000000 --- a/examples/aws-rails/test/channels/application_cable/connection_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "test_helper" - -module ApplicationCable - class ConnectionTest < ActionCable::Connection::TestCase - # test "connects with cookies" do - # cookies.signed[:user_id] = 42 - # - # connect - # - # assert_equal connection.user_id, "42" - # end - end -end diff --git a/examples/aws-rails/test/controllers/.keep b/examples/aws-rails/test/controllers/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/controllers/uploads_controller_test.rb b/examples/aws-rails/test/controllers/uploads_controller_test.rb deleted file mode 100644 index c46b10c54e..0000000000 --- a/examples/aws-rails/test/controllers/uploads_controller_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "test_helper" - -class UploadsControllerTest < ActionDispatch::IntegrationTest - test "should get new" do - get uploads_new_url - assert_response :success - end - - test "should get create" do - get uploads_create_url - assert_response :success - end -end diff --git a/examples/aws-rails/test/fixtures/files/.keep b/examples/aws-rails/test/fixtures/files/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/helpers/.keep b/examples/aws-rails/test/helpers/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/integration/.keep b/examples/aws-rails/test/integration/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/mailers/.keep b/examples/aws-rails/test/mailers/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/models/.keep b/examples/aws-rails/test/models/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/system/.keep b/examples/aws-rails/test/system/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/test_helper.rb b/examples/aws-rails/test/test_helper.rb deleted file mode 100644 index 0c22470ec1..0000000000 --- a/examples/aws-rails/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -ENV["RAILS_ENV"] ||= "test" -require_relative "../config/environment" -require "rails/test_help" - -module ActiveSupport - class TestCase - # Run tests in parallel with specified workers - parallelize(workers: :number_of_processors) - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... - end -end diff --git a/examples/aws-rails/vendor/.keep b/examples/aws-rails/vendor/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/vendor/javascript/.keep b/examples/aws-rails/vendor/javascript/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rds-instance-mysql-public/.gitignore b/examples/aws-rds-instance-mysql-public/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-rds-instance-mysql-public/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-rds-instance-mysql-public/package.json b/examples/aws-rds-instance-mysql-public/package.json deleted file mode 100644 index 041968a701..0000000000 --- a/examples/aws-rds-instance-mysql-public/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-rds-instance-mysql-public-example", - "version": "1.0.0", - "description": "", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - } -} diff --git a/examples/aws-rds-instance-mysql-public/sst.config.ts b/examples/aws-rds-instance-mysql-public/sst.config.ts deleted file mode 100644 index 1fa876189a..0000000000 --- a/examples/aws-rds-instance-mysql-public/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## AWS RDS MySQL public - * - * Create a publicly accessible MySQL RDS instance with a security group that - * allows external connections. - */ -export default $config({ - app(input) { - return { - name: "aws-rds-instance-mysql-public", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const MYSQL_PORT = 3306; - const ALL_IPS = '0.0.0.0/0'; - const publicSecurityGroup = new aws.ec2.SecurityGroup( - 'MyPublicSecurityGroup', - { - ingress: [ - { - // Expose to public connection. Remove if not needed - protocol: 'tcp', - fromPort: MYSQL_PORT, - toPort: MYSQL_PORT, - cidrBlocks: [ALL_IPS], - }, - ], - }, - ); - - const identifier = 'my-db-instance'; - - const database = new aws.rds.Instance( - 'MyDbInstanceMySQL', - { - identifier, - engine: 'mysql', - // free-tier - instanceClass: 'db.t3.micro', - allocatedStorage: 20, // free-tier 20GB - // credentials - username: 'dev-user', - password: 'dev-password', - dbName: 'dev-database', - // settings - tags: { Name: identifier }, - skipFinalSnapshot: true, - - // allow public access - vpcSecurityGroupIds: [publicSecurityGroup.id], - publiclyAccessible: true, - }, - ); - - return { - Database: database.address - }; - }, -}); diff --git a/examples/aws-rds-instance-mysql-public/tsconfig.json b/examples/aws-rds-instance-mysql-public/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-rds-instance-mysql-public/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-react-router/.dockerignore b/examples/aws-react-router/.dockerignore deleted file mode 100644 index 9b8d514712..0000000000 --- a/examples/aws-react-router/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -.react-router -build -node_modules -README.md \ No newline at end of file diff --git a/examples/aws-react-router/.gitignore b/examples/aws-react-router/.gitignore deleted file mode 100644 index 5913deaa94..0000000000 --- a/examples/aws-react-router/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -/node_modules/ - -# React Router -/.react-router/ -/build/ - -# sst -.sst diff --git a/examples/aws-react-router/Dockerfile b/examples/aws-react-router/Dockerfile deleted file mode 100644 index 207bf937e3..0000000000 --- a/examples/aws-react-router/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM node:20-alpine AS development-dependencies-env -COPY . /app -WORKDIR /app -RUN npm ci - -FROM node:20-alpine AS production-dependencies-env -COPY ./package.json package-lock.json /app/ -WORKDIR /app -RUN npm ci --omit=dev - -FROM node:20-alpine AS build-env -COPY . /app/ -COPY --from=development-dependencies-env /app/node_modules /app/node_modules -WORKDIR /app -RUN npm run build - -FROM node:20-alpine -COPY ./package.json package-lock.json /app/ -COPY --from=production-dependencies-env /app/node_modules /app/node_modules -COPY --from=build-env /app/build /app/build -WORKDIR /app -CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/examples/aws-react-router/app/app.css b/examples/aws-react-router/app/app.css deleted file mode 100644 index 99345d8218..0000000000 --- a/examples/aws-react-router/app/app.css +++ /dev/null @@ -1,15 +0,0 @@ -@import "tailwindcss"; - -@theme { - --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif, - "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; -} - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-react-router/app/root.tsx b/examples/aws-react-router/app/root.tsx deleted file mode 100644 index 9fc663618c..0000000000 --- a/examples/aws-react-router/app/root.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { - isRouteErrorResponse, - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "react-router"; - -import type { Route } from "./+types/root"; -import "./app.css"; - -export const links: Route.LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} - -export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { - let message = "Oops!"; - let details = "An unexpected error occurred."; - let stack: string | undefined; - - if (isRouteErrorResponse(error)) { - message = error.status === 404 ? "404" : "Error"; - details = - error.status === 404 - ? "The requested page could not be found." - : error.statusText || details; - } else if (import.meta.env.DEV && error && error instanceof Error) { - details = error.message; - stack = error.stack; - } - - return ( -
-

{message}

-

{details}

- {stack && ( -
-          {stack}
-        
- )} -
- ); -} diff --git a/examples/aws-react-router/app/routes.ts b/examples/aws-react-router/app/routes.ts deleted file mode 100644 index 102b402587..0000000000 --- a/examples/aws-react-router/app/routes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { type RouteConfig, index } from "@react-router/dev/routes"; - -export default [index("routes/home.tsx")] satisfies RouteConfig; diff --git a/examples/aws-react-router/app/routes/home.tsx b/examples/aws-react-router/app/routes/home.tsx deleted file mode 100644 index c61efecfa8..0000000000 --- a/examples/aws-react-router/app/routes/home.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -import type { Route } from "./+types/home"; -import { Welcome } from "../welcome/welcome"; - -export function meta({}: Route.MetaArgs) { - return [ - { title: "New React Router App" }, - { name: "description", content: "Welcome to React Router!" }, - ]; -} - -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} - -export default function Home({ loaderData }: Route.ComponentProps) { - const { url } = loaderData; - return ( -
-
-

- Welcome to React Router! -

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
-
- ); -} diff --git a/examples/aws-react-router/app/welcome/logo-dark.svg b/examples/aws-react-router/app/welcome/logo-dark.svg deleted file mode 100644 index dd82028944..0000000000 --- a/examples/aws-react-router/app/welcome/logo-dark.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-react-router/app/welcome/logo-light.svg b/examples/aws-react-router/app/welcome/logo-light.svg deleted file mode 100644 index 73284929d3..0000000000 --- a/examples/aws-react-router/app/welcome/logo-light.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-react-router/app/welcome/welcome.tsx b/examples/aws-react-router/app/welcome/welcome.tsx deleted file mode 100644 index 8ac6e1d30b..0000000000 --- a/examples/aws-react-router/app/welcome/welcome.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import logoDark from "./logo-dark.svg"; -import logoLight from "./logo-light.svg"; - -export function Welcome() { - return ( -
-
-
-
- React Router - React Router -
-
-
- -
-
-
- ); -} - -const resources = [ - { - href: "https://reactrouter.com/docs", - text: "React Router Docs", - icon: ( - - - - ), - }, - { - href: "https://rmx.as/discord", - text: "Join Discord", - icon: ( - - - - ), - }, -]; diff --git a/examples/aws-react-router/package.json b/examples/aws-react-router/package.json deleted file mode 100644 index eb7861a131..0000000000 --- a/examples/aws-react-router/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "aws-react-router", - "private": true, - "type": "module", - "scripts": { - "build": "react-router build", - "dev": "react-router dev", - "start": "react-router-serve ./build/server/index.js", - "typecheck": "react-router typegen && tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.796.0", - "@aws-sdk/s3-request-presigner": "^3.796.0", - "@react-router/node": "^7.5.2", - "@react-router/serve": "^7.5.2", - "isbot": "^5.1.17", - "react": "^19.0.0", - "react-dom": "^19.0.0", - "react-router": "^7.5.2", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@react-router/dev": "^7.5.2", - "@tailwindcss/vite": "^4.0.0", - "@types/node": "^20", - "@types/react": "^19.0.1", - "@types/react-dom": "^19.0.1", - "react-router-devtools": "^1.1.0", - "tailwindcss": "^4.0.0", - "typescript": "^5.7.2", - "vite": "^5.4.11", - "vite-tsconfig-paths": "^5.1.4" - } -} diff --git a/examples/aws-react-router/public/favicon.ico b/examples/aws-react-router/public/favicon.ico deleted file mode 100644 index 5dbdfcddcb..0000000000 Binary files a/examples/aws-react-router/public/favicon.ico and /dev/null differ diff --git a/examples/aws-react-router/react-router.config.ts b/examples/aws-react-router/react-router.config.ts deleted file mode 100644 index 6ff16f9177..0000000000 --- a/examples/aws-react-router/react-router.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { Config } from "@react-router/dev/config"; - -export default { - // Config options... - // Server-side render by default, to enable SPA mode set this to `false` - ssr: true, -} satisfies Config; diff --git a/examples/aws-react-router/sst.config.ts b/examples/aws-react-router/sst.config.ts deleted file mode 100644 index 97ecb1054f..0000000000 --- a/examples/aws-react-router/sst.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-react-router", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - new sst.aws.React("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-react-router/tsconfig.json b/examples/aws-react-router/tsconfig.json deleted file mode 100644 index 65fa16a18d..0000000000 --- a/examples/aws-react-router/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "include": [ - "**/*", - "**/.server/**/*", - "**/.client/**/*", - ".react-router/types/**/*" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["node", "vite/client"], - "target": "ES2022", - "module": "ES2022", - "moduleResolution": "bundler", - "jsx": "react-jsx", - "rootDirs": [".", "./.react-router/types"], - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - "esModuleInterop": true, - "verbatimModuleSyntax": true, - "noEmit": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true - },"exclude":["sst.config.ts"] -} diff --git a/examples/aws-react-router/vite.config.ts b/examples/aws-react-router/vite.config.ts deleted file mode 100644 index 4a88d5871c..0000000000 --- a/examples/aws-react-router/vite.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { reactRouter } from "@react-router/dev/vite"; -import tailwindcss from "@tailwindcss/vite"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -export default defineConfig({ - plugins: [tailwindcss(), reactRouter(), tsconfigPaths()], -}); diff --git a/examples/aws-realtime-nextjs/.gitignore b/examples/aws-realtime-nextjs/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-realtime-nextjs/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-realtime-nextjs/app/favicon.ico b/examples/aws-realtime-nextjs/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-realtime-nextjs/app/favicon.ico and /dev/null differ diff --git a/examples/aws-realtime-nextjs/app/globals.css b/examples/aws-realtime-nextjs/app/globals.css deleted file mode 100644 index f4bd77c0cc..0000000000 --- a/examples/aws-realtime-nextjs/app/globals.css +++ /dev/null @@ -1,107 +0,0 @@ -:root { - --max-width: 1100px; - --border-radius: 12px; - --font-mono: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", - "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", - "Fira Mono", "Droid Sans Mono", "Courier New", monospace; - - --foreground-rgb: 0, 0, 0; - --background-start-rgb: 214, 219, 220; - --background-end-rgb: 255, 255, 255; - - --primary-glow: conic-gradient( - from 180deg at 50% 50%, - #16abff33 0deg, - #0885ff33 55deg, - #54d6ff33 120deg, - #0071ff33 160deg, - transparent 360deg - ); - --secondary-glow: radial-gradient( - rgba(255, 255, 255, 1), - rgba(255, 255, 255, 0) - ); - - --tile-start-rgb: 239, 245, 249; - --tile-end-rgb: 228, 232, 233; - --tile-border: conic-gradient( - #00000080, - #00000040, - #00000030, - #00000020, - #00000010, - #00000010, - #00000080 - ); - - --callout-rgb: 238, 240, 241; - --callout-border-rgb: 172, 175, 176; - --card-rgb: 180, 185, 188; - --card-border-rgb: 131, 134, 135; -} - -@media (prefers-color-scheme: dark) { - :root { - --foreground-rgb: 255, 255, 255; - --background-start-rgb: 0, 0, 0; - --background-end-rgb: 0, 0, 0; - - --primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0)); - --secondary-glow: linear-gradient( - to bottom right, - rgba(1, 65, 255, 0), - rgba(1, 65, 255, 0), - rgba(1, 65, 255, 0.3) - ); - - --tile-start-rgb: 2, 13, 46; - --tile-end-rgb: 2, 5, 19; - --tile-border: conic-gradient( - #ffffff80, - #ffffff40, - #ffffff30, - #ffffff20, - #ffffff10, - #ffffff10, - #ffffff80 - ); - - --callout-rgb: 20, 20, 20; - --callout-border-rgb: 108, 108, 108; - --card-rgb: 100, 100, 100; - --card-border-rgb: 200, 200, 200; - } -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: rgb(var(--foreground-rgb)); - background: linear-gradient( - to bottom, - transparent, - rgb(var(--background-end-rgb)) - ) - rgb(var(--background-start-rgb)); -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-realtime-nextjs/app/layout.tsx b/examples/aws-realtime-nextjs/app/layout.tsx deleted file mode 100644 index 3314e4780a..0000000000 --- a/examples/aws-realtime-nextjs/app/layout.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "./globals.css"; - -const inter = Inter({ subsets: ["latin"] }); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - {children} - - ); -} diff --git a/examples/aws-realtime-nextjs/app/page.module.css b/examples/aws-realtime-nextjs/app/page.module.css deleted file mode 100644 index 5c4b1e6a2c..0000000000 --- a/examples/aws-realtime-nextjs/app/page.module.css +++ /dev/null @@ -1,230 +0,0 @@ -.main { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: center; - padding: 6rem; - min-height: 100vh; -} - -.description { - display: inherit; - justify-content: inherit; - align-items: inherit; - font-size: 0.85rem; - max-width: var(--max-width); - width: 100%; - z-index: 2; - font-family: var(--font-mono); -} - -.description a { - display: flex; - justify-content: center; - align-items: center; - gap: 0.5rem; -} - -.description p { - position: relative; - margin: 0; - padding: 1rem; - background-color: rgba(var(--callout-rgb), 0.5); - border: 1px solid rgba(var(--callout-border-rgb), 0.3); - border-radius: var(--border-radius); -} - -.code { - font-weight: 700; - font-family: var(--font-mono); -} - -.grid { - display: grid; - grid-template-columns: repeat(4, minmax(25%, auto)); - max-width: 100%; - width: var(--max-width); -} - -.card { - padding: 1rem 1.2rem; - border-radius: var(--border-radius); - background: rgba(var(--card-rgb), 0); - border: 1px solid rgba(var(--card-border-rgb), 0); - transition: background 200ms, border 200ms; -} - -.card span { - display: inline-block; - transition: transform 200ms; -} - -.card h2 { - font-weight: 600; - margin-bottom: 0.7rem; -} - -.card p { - margin: 0; - opacity: 0.6; - font-size: 0.9rem; - line-height: 1.5; - max-width: 30ch; - text-wrap: balance; -} - -.center { - display: flex; - justify-content: center; - align-items: center; - position: relative; - padding: 4rem 0; -} - -.center::before { - background: var(--secondary-glow); - border-radius: 50%; - width: 480px; - height: 360px; - margin-left: -400px; -} - -.center::after { - background: var(--primary-glow); - width: 240px; - height: 180px; - z-index: -1; -} - -.center::before, -.center::after { - content: ""; - left: 50%; - position: absolute; - filter: blur(45px); - transform: translateZ(0); -} - -.logo { - position: relative; -} -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - .card:hover { - background: rgba(var(--card-rgb), 0.1); - border: 1px solid rgba(var(--card-border-rgb), 0.15); - } - - .card:hover span { - transform: translateX(4px); - } -} - -@media (prefers-reduced-motion) { - .card:hover span { - transform: none; - } -} - -/* Mobile */ -@media (max-width: 700px) { - .content { - padding: 4rem; - } - - .grid { - grid-template-columns: 1fr; - margin-bottom: 120px; - max-width: 320px; - text-align: center; - } - - .card { - padding: 1rem 2.5rem; - } - - .card h2 { - margin-bottom: 0.5rem; - } - - .center { - padding: 8rem 0 6rem; - } - - .center::before { - transform: none; - height: 300px; - } - - .description { - font-size: 0.8rem; - } - - .description a { - padding: 1rem; - } - - .description p, - .description div { - display: flex; - justify-content: center; - position: fixed; - width: 100%; - } - - .description p { - align-items: center; - inset: 0 0 auto; - padding: 2rem 1rem 1.4rem; - border-radius: 0; - border: none; - border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.25); - background: linear-gradient( - to bottom, - rgba(var(--background-start-rgb), 1), - rgba(var(--callout-rgb), 0.5) - ); - background-clip: padding-box; - backdrop-filter: blur(24px); - } - - .description div { - align-items: flex-end; - pointer-events: none; - inset: auto 0 0; - padding: 2rem; - height: 200px; - background: linear-gradient( - to bottom, - transparent 0%, - rgb(var(--background-end-rgb)) 40% - ); - z-index: 1; - } -} - -/* Tablet and Smaller Desktop */ -@media (min-width: 701px) and (max-width: 1120px) { - .grid { - grid-template-columns: repeat(2, 50%); - } -} - -@media (prefers-color-scheme: dark) { - .vercelLogo { - filter: invert(1); - } - - .logo { - filter: invert(1) drop-shadow(0 0 0.3rem #ffffff70); - } -} - -@keyframes rotate { - from { - transform: rotate(360deg); - } - to { - transform: rotate(0deg); - } -} diff --git a/examples/aws-realtime-nextjs/app/page.tsx b/examples/aws-realtime-nextjs/app/page.tsx deleted file mode 100644 index 34bd2ddd90..0000000000 --- a/examples/aws-realtime-nextjs/app/page.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Resource } from "sst"; -import Image from "next/image"; -import Chat from "@/components/chat"; -import styles from "./page.module.css"; - -const topic = "sst-chat"; - -export default function Home() { - return ( -
- -
- Next.js Logo -
- -
- -
- -
- ); -} diff --git a/examples/aws-realtime-nextjs/authorizer.ts b/examples/aws-realtime-nextjs/authorizer.ts deleted file mode 100644 index f415e08b67..0000000000 --- a/examples/aws-realtime-nextjs/authorizer.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { realtime } from "sst/aws/realtime"; - -export const handler = realtime.authorizer(async (token) => { - const prefix = `${Resource.App.name}/${Resource.App.stage}`; - - const isValid = token === "PLACEHOLDER_TOKEN"; - - return isValid - ? { - publish: [`${prefix}/*`], - subscribe: [`${prefix}/*`], - } - : { - publish: [], - subscribe: [], - }; -}); diff --git a/examples/aws-realtime-nextjs/components/chat.module.css b/examples/aws-realtime-nextjs/components/chat.module.css deleted file mode 100644 index f5c6e5b1b7..0000000000 --- a/examples/aws-realtime-nextjs/components/chat.module.css +++ /dev/null @@ -1,50 +0,0 @@ -.chat { - gap: 1rem; - width: 30rem; - display: flex; - padding: 1rem; - flex-direction: column; - border-radius: var(--border-radius); - background-color: rgba(var(--callout-rgb), 0.5); - border: 1px solid rgba(var(--callout-border-rgb), 0.3); -} - -.messages { - padding-bottom: 0.125rem; - border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.3); -} -.messages > div { - line-height: 1.1; - padding-bottom: 0.625rem; -} - -.form { - display: flex; - gap: 0.625rem; -} -.form input { - flex: 1; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - border-radius: calc(1rem - var(--border-radius)); - border: 1px solid rgba(var(--callout-border-rgb), 1); -} -.form button { - font-weight: 500; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - border-radius: calc(1rem - var(--border-radius)); - background: linear-gradient( - to bottom right, - rgba(var(--tile-start-rgb), 1), - rgba(var(--tile-end-rgb), 1) - ); - border: 1px solid rgba(var(--callout-border-rgb), 1); -} -.form button:active:enabled { - background: linear-gradient( - to top left, - rgba(var(--tile-start-rgb), 1), - rgba(var(--tile-end-rgb), 1) - ); -} diff --git a/examples/aws-realtime-nextjs/components/chat.tsx b/examples/aws-realtime-nextjs/components/chat.tsx deleted file mode 100644 index 299f4596a6..0000000000 --- a/examples/aws-realtime-nextjs/components/chat.tsx +++ /dev/null @@ -1,83 +0,0 @@ -"use client"; - -import mqtt from "mqtt"; -import { useState, useEffect } from "react"; -import styles from "./chat.module.css"; - -function createConnection(endpoint: string, authorizer: string) { - return mqtt.connect(`wss://${endpoint}/mqtt?x-amz-customauthorizer-name=${authorizer}`, { - protocolVersion: 5, - manualConnect: true, - username: "", // Must be empty for the authorizer - password: "PLACEHOLDER_TOKEN", // Passed as the token to the authorizer - clientId: `client_${window.crypto.randomUUID()}`, - }); -} - -export default function Chat( - { topic, endpoint, authorizer }: { topic: string, endpoint: string, authorizer: string } -) { - const [messages, setMessages] = useState([]); - const [connection, setConnection] = useState(null); - - useEffect(() => { - const connection = createConnection(endpoint, authorizer); - - connection.on("connect", async () => { - try { - await connection.subscribeAsync(topic, { qos: 1 }); - setConnection(connection); - } catch (e) { } - }); - connection.on("message", (_fullTopic, payload) => { - const message = new TextDecoder("utf8").decode(new Uint8Array(payload)); - setMessages((prev) => [...prev, message]); - }); - connection.on("error", console.error); - - connection.connect(); - - return () => { - connection.end(); - setConnection(null); - }; - }, [topic, endpoint, authorizer]); - - return ( -
- {connection && messages.length > 0 && -
- {messages.map((msg, i) => ( -
{JSON.parse(msg).message}
- ))} -
- } -
{ - e.preventDefault(); - - const input = (e.target as HTMLFormElement).message; - - connection!.publish( - topic, - JSON.stringify({ message: input.value }), - { qos: 1 } - ); - input.value = ""; - }} - > - - -
-
- ); -} diff --git a/examples/aws-realtime-nextjs/next.config.mjs b/examples/aws-realtime-nextjs/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-realtime-nextjs/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-realtime-nextjs/package.json b/examples/aws-realtime-nextjs/package.json deleted file mode 100644 index 3cce662c8b..0000000000 --- a/examples/aws-realtime-nextjs/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-realtime-nextjs", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "mqtt": "^5.10.1", - "next": "14.2.3", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-realtime-nextjs/public/next.svg b/examples/aws-realtime-nextjs/public/next.svg deleted file mode 100644 index 5174b28c56..0000000000 --- a/examples/aws-realtime-nextjs/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime-nextjs/sst.config.ts b/examples/aws-realtime-nextjs/sst.config.ts deleted file mode 100644 index f65031cdd1..0000000000 --- a/examples/aws-realtime-nextjs/sst.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-realtime-nextjs", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const realtime = new sst.aws.Realtime("MyRealtime", { - authorizer: "authorizer.handler", - }); - - new sst.aws.Nextjs("MyWeb", { - link: [realtime], - }); - }, -}); diff --git a/examples/aws-realtime-nextjs/tsconfig.json b/examples/aws-realtime-nextjs/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-realtime-nextjs/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-realtime/authorizer.ts b/examples/aws-realtime/authorizer.ts deleted file mode 100644 index 27f8b1266d..0000000000 --- a/examples/aws-realtime/authorizer.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { RealtimeAuthHandler } from "sst"; - -export const handler = RealtimeAuthHandler(async () => { - return { - subscribe: [process.env.SST_TOPIC], - publish: [process.env.SST_TOPIC], - }; -}); diff --git a/examples/aws-realtime/package.json b/examples/aws-realtime/package.json deleted file mode 100644 index 5d2271a4b7..0000000000 --- a/examples/aws-realtime/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-realtime", - "workspaces": [ - "web" - ], - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-iot-data-plane": "^3.569.0" - } -} diff --git a/examples/aws-realtime/publisher.ts b/examples/aws-realtime/publisher.ts deleted file mode 100644 index 0651e2f725..0000000000 --- a/examples/aws-realtime/publisher.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - IoTDataPlaneClient, - PublishCommand, -} from "@aws-sdk/client-iot-data-plane"; -const data = new IoTDataPlaneClient({}); - -export const handler = async () => { - await data.send( - new PublishCommand({ - payload: Buffer.from( - JSON.stringify({ message: "A greeting from Lambda" }) - ), - topic: process.env.SST_TOPIC, - }) - ); - return { - statusCode: 200, - body: "Sent", - }; -}; diff --git a/examples/aws-realtime/sst.config.ts b/examples/aws-realtime/sst.config.ts deleted file mode 100644 index 2a511b418f..0000000000 --- a/examples/aws-realtime/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-realtime", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const topic = `${$app.name}/${$app.stage}/chat`; - const realtime = new sst.aws.Realtime("MyRealtime", { - authorizer: { - handler: "authorizer.handler", - environment: { - SST_TOPIC: topic, - }, - }, - }); - realtime.subscribe("subscriber.handler", { - filter: topic, - }); - - new sst.aws.StaticSite("Web", { - path: "web", - build: { - command: "npm run build", - output: "dist", - }, - environment: { - VITE_REALTIME_ENDPOINT: realtime.endpoint, - VITE_TOPIC: topic, - VITE_AUTHORIZER: realtime.authorizer, - }, - }); - - const publisher = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - environment: { - SST_TOPIC: topic, - }, - url: true, - link: [realtime], - }); - - return { - publisher: publisher.url, - }; - }, -}); diff --git a/examples/aws-realtime/subscriber.ts b/examples/aws-realtime/subscriber.ts deleted file mode 100644 index a33af0f71e..0000000000 --- a/examples/aws-realtime/subscriber.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const handler = async (event: any) => { - console.log(event); -}; diff --git a/examples/aws-realtime/tsconfig.json b/examples/aws-realtime/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-realtime/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-realtime/web/index.html b/examples/aws-realtime/web/index.html deleted file mode 100644 index 44a933506f..0000000000 --- a/examples/aws-realtime/web/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + TS - - -
- - - diff --git a/examples/aws-realtime/web/package.json b/examples/aws-realtime/web/package.json deleted file mode 100644 index 9cb15e316e..0000000000 --- a/examples/aws-realtime/web/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "web", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev vite", - "build": "tsc && vite build", - "preview": "vite preview" - }, - "dependencies": { - "@paralleldrive/cuid2": "^2.2.2", - "aws-iot-device-sdk-v2": "1.13.1", - "events": "^3.3.0" - }, - "devDependencies": { - "typescript": "^5.2.2", - "vite": "^5.2.0" - } -} diff --git a/examples/aws-realtime/web/public/vite.svg b/examples/aws-realtime/web/public/vite.svg deleted file mode 100644 index e7b8dfb1b2..0000000000 --- a/examples/aws-realtime/web/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime/web/src/main.ts b/examples/aws-realtime/web/src/main.ts deleted file mode 100644 index 3a546f7575..0000000000 --- a/examples/aws-realtime/web/src/main.ts +++ /dev/null @@ -1,73 +0,0 @@ -import "./style.css"; -import { iot, mqtt } from "aws-iot-device-sdk-v2"; -import { createId } from "@paralleldrive/cuid2"; - -const endpoint = import.meta.env.VITE_REALTIME_ENDPOINT; -const topic = import.meta.env.VITE_TOPIC; -const authorizer = import.meta.env.VITE_AUTHORIZER; - -const messages: string[] = []; - -// Setup MQTT connection -let connection: mqtt.MqttClientConnection; -async function createConnection() { - const config = iot.AwsIotMqttConnectionConfigBuilder.new_with_websockets() - .with_clean_session(true) - .with_client_id("client_" + createId()) - .with_endpoint(endpoint) - .with_custom_authorizer("", authorizer, "", "PLACEHOLDER_TOKEN") - .with_keep_alive_seconds(1200) - .build(); - const client = new mqtt.MqttClient(); - connection = client.new_connection(config); - connection.on("connect", async () => { - console.log("WS connected"); - await connection.subscribe(topic, mqtt.QoS.AtLeastOnce); - console.log("WS subscribed to chat"); - }); - connection.on("interrupt", (e) => { - console.log("interrupted, restarting", e, JSON.stringify(e)); - createConnection(); - }); - connection.on("error", (e) => { - console.log("connection error", e); - }); - connection.on("resume", console.log); - connection.on("message", (_fullTopic, payload) => { - const message = new TextDecoder("utf8").decode(new Uint8Array(payload)); - addMessage(message); - }); - connection.on("disconnect", console.log); - await connection.connect(); -} -createConnection(); - -const addMessage = (message: string) => { - messages.push(message); - document.querySelector("#messages")!.innerHTML = messages - .map((m) => `
${m}
`) - .join(""); -}; - -document.querySelector("#app")!.innerHTML = ` -
-

Realtime Demo

-
-
- -
-
-`; - -const input = document.querySelector("#message")!; -input.addEventListener("keypress", (event: KeyboardEvent) => { - const message = input.value.trim(); - if (event.key === "Enter" && message.length > 0) { - connection.publish( - topic, - JSON.stringify({ message }), - mqtt.QoS.AtLeastOnce - ); - input.value = ""; - } -}); diff --git a/examples/aws-realtime/web/src/style.css b/examples/aws-realtime/web/src/style.css deleted file mode 100644 index f9c7350248..0000000000 --- a/examples/aws-realtime/web/src/style.css +++ /dev/null @@ -1,96 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -#app { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.vanilla:hover { - filter: drop-shadow(0 0 2em #3178c6aa); -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/examples/aws-realtime/web/src/typescript.svg b/examples/aws-realtime/web/src/typescript.svg deleted file mode 100644 index d91c910cc3..0000000000 --- a/examples/aws-realtime/web/src/typescript.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime/web/tsconfig.json b/examples/aws-realtime/web/tsconfig.json deleted file mode 100644 index 75abdef265..0000000000 --- a/examples/aws-realtime/web/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"] -} diff --git a/examples/aws-redis-local/index.ts b/examples/aws-redis-local/index.ts deleted file mode 100644 index cebc9ce47b..0000000000 --- a/examples/aws-redis-local/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Redis, Cluster } from "ioredis"; -import { Resource } from "sst"; - -const client = - Resource.MyRedis.host === "localhost" - ? new Redis({ - host: Resource.MyRedis.host, - port: Resource.MyRedis.port, - }) - : new Cluster( - [{ - host: Resource.MyRedis.host, - port: Resource.MyRedis.port, - }], - { - redisOptions: { - tls: { checkServerIdentity: () => undefined }, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - }, - ); - -export async function handler() { - await client.set("foo", `bar-${Date.now()}`); - return { - statusCode: 200, - body: JSON.stringify({ - foo: await client.get("foo"), - }), - }; -} diff --git a/examples/aws-redis-local/package.json b/examples/aws-redis-local/package.json deleted file mode 100644 index 128e5439f7..0000000000 --- a/examples/aws-redis-local/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-redis-local", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-redis-local/sst.config.ts b/examples/aws-redis-local/sst.config.ts deleted file mode 100644 index b32f069188..0000000000 --- a/examples/aws-redis-local/sst.config.ts +++ /dev/null @@ -1,89 +0,0 @@ -/// - -/** - * ## AWS Redis local - * - * In this example, we connect to a local Docker Redis instance for dev. While on deploy, we use - * Redis ElastiCache. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local Redis server. You don't have to use Docker, you can run it locally any way - * you want. - * - * ```bash - * docker run \ - * --rm \ - * -p 6379:6379 \ - * -v $(pwd)/.sst/storage/redis:/data \ - * redis:latest - * ``` - * - * The data is persisted to the `.sst/storage` directory. So if you restart the dev server, - * the data will still be there. - * - * We then configure the `dev` property of the `Redis` component with the settings for the - * local Redis server. - * - * ```ts title="sst.config.ts" - * dev: { - * host: "localhost", - * port: 6379 - * } - * ``` - * - * By providing the `dev` prop for Redis, SST will use the local Redis server and - * not deploy a new Redis ElastiCache cluster when running `sst dev`. - * - * It also allows us to access Redis through a Resource `link`. - * - * ```ts title="index.ts" - * const client = Resource.MyRedis.host === "localhost" - * ? new Redis({ - * host: Resource.MyRedis.host, - * port: Resource.MyRedis.port, - * }) - * : new Cluster( - * [{ - * host: Resource.MyRedis.host, - * port: Resource.MyRedis.port, - * }], - * { - * redisOptions: { - * tls: { checkServerIdentity: () => undefined }, - * username: Resource.MyRedis.username, - * password: Resource.MyRedis.password, - * }, - * }, - * ); - * ``` - * - * The local Redis server is running in `standalone` mode, whereas on deploy it'll be in - * `cluster` mode. So our Lambda function needs to connect using the right config. - */ -export default $config({ - app(input) { - return { - name: "aws-redis-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - const redis = new sst.aws.Redis("MyRedis", { - dev: { - host: "localhost", - port: 6379, - }, - vpc, - }); - - new sst.aws.Function("MyApp", { - vpc, - url: true, - link: [redis], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-redis-local/tsconfig.json b/examples/aws-redis-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-redis-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-redis/index.ts b/examples/aws-redis/index.ts deleted file mode 100644 index 07da57201f..0000000000 --- a/examples/aws-redis/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Cluster } from "ioredis"; -import { Resource } from "sst"; - -const client = new Cluster( - [ - { - host: Resource.MyRedis.host, - port: Resource.MyRedis.port, - }, - ], - { - redisOptions: { - tls: { - checkServerIdentity: () => undefined, - }, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export async function handler() { - await client.set("foo", `bar-${Date.now()}`); - return { - statusCode: 200, - body: JSON.stringify({ - foo: await client.get("foo"), - }), - }; -} diff --git a/examples/aws-redis/package.json b/examples/aws-redis/package.json deleted file mode 100644 index b888afbfcc..0000000000 --- a/examples/aws-redis/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-redis", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-redis/sst.config.ts b/examples/aws-redis/sst.config.ts deleted file mode 100644 index ac7a05e258..0000000000 --- a/examples/aws-redis/sst.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - vpc, - link: [redis], - }); - }, -}); diff --git a/examples/aws-remix-container/.dockerignore b/examples/aws-remix-container/.dockerignore deleted file mode 100644 index d0a41b0f28..0000000000 --- a/examples/aws-remix-container/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -.next -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-remix-container/.eslintrc.cjs b/examples/aws-remix-container/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix-container/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix-container/.gitignore b/examples/aws-remix-container/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix-container/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix-container/Dockerfile b/examples/aws-remix-container/Dockerfile deleted file mode 100644 index c910cea1b6..0000000000 --- a/examples/aws-remix-container/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Based on https://github.com/remix-run/blues-stack/blob/main/Dockerfile - -FROM node:lts-alpine as base -ENV NODE_ENV production - -# Stage 1: Install all node_modules, including dev dependencies -FROM base as deps -WORKDIR /myapp -ADD package.json ./ -RUN npm install --include=dev - -# Stage 2: Setup production node_modules -FROM base as production-deps -WORKDIR /myapp -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json ./ -RUN npm prune --omit=dev - -# Stage 3: Build the app -FROM base as build -WORKDIR /myapp -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD . . -RUN npm run build - -# Stage 4: Build the production image -FROM base -WORKDIR /myapp -COPY --from=production-deps /myapp/node_modules /myapp/node_modules -COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public -ADD . . - -CMD ["npm", "start"] diff --git a/examples/aws-remix-container/app/entry.server.tsx b/examples/aws-remix-container/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix-container/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix-container/app/root.tsx b/examples/aws-remix-container/app/root.tsx deleted file mode 100644 index 61c8b983d2..0000000000 --- a/examples/aws-remix-container/app/root.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; - -import "./tailwind.css"; - -export const links: LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix-container/app/routes/_index.tsx b/examples/aws-remix-container/app/routes/_index.tsx deleted file mode 100644 index 38db41f396..0000000000 --- a/examples/aws-remix-container/app/routes/_index.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Resource } from "sst"; -import { useLoaderData } from "@remix-run/react"; -import type { MetaFunction } from "@remix-run/node"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export const meta: MetaFunction = () => { - return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, - ]; -}; - -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} - -export default function Index() { - const data = useLoaderData(); - return ( -
-
-

- Welcome to Remix -

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(data.url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
-
- ); -} diff --git a/examples/aws-remix-container/app/tailwind.css b/examples/aws-remix-container/app/tailwind.css deleted file mode 100644 index 303fe158fc..0000000000 --- a/examples/aws-remix-container/app/tailwind.css +++ /dev/null @@ -1,12 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-remix-container/package.json b/examples/aws-remix-container/package.json deleted file mode 100644 index 8fdad703fa..0000000000 --- a/examples/aws-remix-container/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "aws-remix-container", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "@remix-run/node": "^2.15.0", - "@remix-run/react": "^2.15.0", - "@remix-run/serve": "^2.15.0", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.15.0", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.19", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.4", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=20.0.0" - }, - "overrides": { - "valibot": "^0.41.0" - } -} diff --git a/examples/aws-remix-container/postcss.config.js b/examples/aws-remix-container/postcss.config.js deleted file mode 100644 index 2aa7205d4b..0000000000 --- a/examples/aws-remix-container/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/examples/aws-remix-container/public/logo-dark.png b/examples/aws-remix-container/public/logo-dark.png deleted file mode 100644 index b24c7aee3a..0000000000 Binary files a/examples/aws-remix-container/public/logo-dark.png and /dev/null differ diff --git a/examples/aws-remix-container/public/logo-light.png b/examples/aws-remix-container/public/logo-light.png deleted file mode 100644 index 4490ae7930..0000000000 Binary files a/examples/aws-remix-container/public/logo-light.png and /dev/null differ diff --git a/examples/aws-remix-container/sst.config.ts b/examples/aws-remix-container/sst.config.ts deleted file mode 100644 index 9f55a2d505..0000000000 --- a/examples/aws-remix-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-remix-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-remix-container/tailwind.config.ts b/examples/aws-remix-container/tailwind.config.ts deleted file mode 100644 index 5f06ad4ba5..0000000000 --- a/examples/aws-remix-container/tailwind.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Config } from "tailwindcss"; - -export default { - content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"], - theme: { - extend: { - fontFamily: { - sans: [ - "Inter", - "ui-sans-serif", - "system-ui", - "sans-serif", - "Apple Color Emoji", - "Segoe UI Emoji", - "Segoe UI Symbol", - "Noto Color Emoji", - ], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-remix-container/tsconfig.json b/examples/aws-remix-container/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix-container/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix-container/vite.config.ts b/examples/aws-remix-container/vite.config.ts deleted file mode 100644 index e4e8cefc3b..0000000000 --- a/examples/aws-remix-container/vite.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -declare module "@remix-run/node" { - interface Future { - v3_singleFetch: true; - } -} - -export default defineConfig({ - plugins: [ - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - v3_singleFetch: true, - v3_lazyRouteDiscovery: true, - }, - }), - tsconfigPaths(), - ], -}); diff --git a/examples/aws-remix-redis/.dockerignore b/examples/aws-remix-redis/.dockerignore deleted file mode 100644 index 25316b7aa8..0000000000 --- a/examples/aws-remix-redis/.dockerignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -.cache -build -public/build - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-remix-redis/.eslintrc.cjs b/examples/aws-remix-redis/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix-redis/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix-redis/.gitignore b/examples/aws-remix-redis/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix-redis/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix-redis/Dockerfile b/examples/aws-remix-redis/Dockerfile deleted file mode 100644 index 026c033291..0000000000 --- a/examples/aws-remix-redis/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -# base node image -FROM node:18-bullseye-slim as base - -# set for base and all layer that inherit from it -ENV NODE_ENV production - -# Install all node_modules, including dev dependencies -FROM base as deps - -WORKDIR /myapp - -ADD package.json ./ -RUN npm install --include=dev - -# Setup production node_modules -FROM base as production-deps - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json ./ -RUN npm prune --omit=dev - -# Build the app -FROM base as build - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules - -ADD . . -RUN npm run build - -# Finally, build the production image with minimal footprint -FROM base - -WORKDIR /myapp - -COPY --from=production-deps /myapp/node_modules /myapp/node_modules - -COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public -ADD . . - -CMD ["npm", "start"] diff --git a/examples/aws-remix-redis/app/entry.server.tsx b/examples/aws-remix-redis/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix-redis/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix-redis/app/root.tsx b/examples/aws-remix-redis/app/root.tsx deleted file mode 100644 index 61c8b983d2..0000000000 --- a/examples/aws-remix-redis/app/root.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; - -import "./tailwind.css"; - -export const links: LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix-redis/app/routes/_index.tsx b/examples/aws-remix-redis/app/routes/_index.tsx deleted file mode 100644 index b5be858188..0000000000 --- a/examples/aws-remix-redis/app/routes/_index.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { json } from "@remix-run/node"; -import type { MetaFunction } from "@remix-run/node"; -import { useLoaderData } from "@remix-run/react"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export const meta: MetaFunction = () => { - return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, - ]; -}; - -export async function loader() { - const counter = await redis.incr("counter"); - - return json({ counter }); -} - -export default function Index() { - const data = useLoaderData(); - return ( -

- Hit counter: {data.counter} -

- ); -} diff --git a/examples/aws-remix-redis/app/tailwind.css b/examples/aws-remix-redis/app/tailwind.css deleted file mode 100644 index 303fe158fc..0000000000 --- a/examples/aws-remix-redis/app/tailwind.css +++ /dev/null @@ -1,12 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-remix-redis/package.json b/examples/aws-remix-redis/package.json deleted file mode 100644 index 22a6d322b2..0000000000 --- a/examples/aws-remix-redis/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "aws-remix-redis", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@remix-run/node": "^2.12.1", - "@remix-run/react": "^2.12.1", - "@remix-run/serve": "^2.12.1", - "ioredis": "^5.4.1", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.12.1", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.19", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.4", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=20.0.0" - } -} diff --git a/examples/aws-remix-redis/postcss.config.js b/examples/aws-remix-redis/postcss.config.js deleted file mode 100644 index 2aa7205d4b..0000000000 --- a/examples/aws-remix-redis/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/examples/aws-remix-redis/public/logo-dark.png b/examples/aws-remix-redis/public/logo-dark.png deleted file mode 100644 index b24c7aee3a..0000000000 Binary files a/examples/aws-remix-redis/public/logo-dark.png and /dev/null differ diff --git a/examples/aws-remix-redis/public/logo-light.png b/examples/aws-remix-redis/public/logo-light.png deleted file mode 100644 index 4490ae7930..0000000000 Binary files a/examples/aws-remix-redis/public/logo-light.png and /dev/null differ diff --git a/examples/aws-remix-redis/sst.config.ts b/examples/aws-remix-redis/sst.config.ts deleted file mode 100644 index 8abd9c423f..0000000000 --- a/examples/aws-remix-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Remix container with Redis - * - * Creates a hit counter app with Remix and Redis. - * - * This deploys Remix as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:5173` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by adding the `Dockerfile` that's included in this example and - * running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-remix-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-remix-redis/tailwind.config.ts b/examples/aws-remix-redis/tailwind.config.ts deleted file mode 100644 index 14d0f00ce6..0000000000 --- a/examples/aws-remix-redis/tailwind.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Config } from "tailwindcss"; - -export default { - content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"], - theme: { - extend: { - fontFamily: { - sans: [ - '"Inter"', - "ui-sans-serif", - "system-ui", - "sans-serif", - '"Apple Color Emoji"', - '"Segoe UI Emoji"', - '"Segoe UI Symbol"', - '"Noto Color Emoji"', - ], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-remix-redis/tsconfig.json b/examples/aws-remix-redis/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix-redis/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix-redis/vite.config.ts b/examples/aws-remix-redis/vite.config.ts deleted file mode 100644 index 54066fb7ad..0000000000 --- a/examples/aws-remix-redis/vite.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -export default defineConfig({ - plugins: [ - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - }, - }), - tsconfigPaths(), - ], -}); diff --git a/examples/aws-remix-stream/.eslintrc.cjs b/examples/aws-remix-stream/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix-stream/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix-stream/.gitignore b/examples/aws-remix-stream/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix-stream/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix-stream/app/entry.client.tsx b/examples/aws-remix-stream/app/entry.client.tsx deleted file mode 100644 index 94d5dc0de0..0000000000 --- a/examples/aws-remix-stream/app/entry.client.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * By default, Remix will handle hydrating your app on the client for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.client - */ - -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/examples/aws-remix-stream/app/entry.server.tsx b/examples/aws-remix-stream/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix-stream/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix-stream/app/root.tsx b/examples/aws-remix-stream/app/root.tsx deleted file mode 100644 index e82f26fd17..0000000000 --- a/examples/aws-remix-stream/app/root.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix-stream/app/routes/_index.tsx b/examples/aws-remix-stream/app/routes/_index.tsx deleted file mode 100644 index df765aae81..0000000000 --- a/examples/aws-remix-stream/app/routes/_index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { Suspense } from "react"; -import { Await, useLoaderData } from "@remix-run/react"; -import { defer, LoaderFunction } from "@remix-run/node"; -import styles from "~/styles/index.css?url"; - -export const links = () => [ - { rel: "stylesheet", href: styles }, -]; - -interface Character { - name: string; - image: string; - description?: string; -} - -interface LoaderData { - spongebob: Character; - friends: Character[]; -} - -export const loader: LoaderFunction = async () => { - const spongebob = { - name: "SpongeBob SquarePants", - description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.", - image: "spongebob.png", - }; - const friendsPromise = new Promise((resolve) => { - setTimeout(() => { - resolve( - [ - { name: "Patrick Star", image: "patrick.png" }, - { name: "Sandy Cheeks", image: "sandy.png" }, - { name: "Squidward Tentacles", image: "squidward.png" }, - { name: "Mr. Krabs", image: "mr-krabs.png" }, - ] - ); - }, 3000); - }); - - return defer({ - spongebob, - friends: friendsPromise, - }); -}; - -export default function Index() { - const { spongebob, friends } = useLoaderData(); - - return ( -
-
-

{spongebob.name}

-
-
-

{spongebob.description}

-
- {spongebob.name} -
-
- -
-

Friends from Bikini Bottom

- Loading...
}> - - {(friends) => ( -
- {friends.map((friend) => ( -
- {friend.name} -

{friend.name}

-
- ))} -
- )} -
- - - - ); -} diff --git a/examples/aws-remix-stream/app/styles/index.css b/examples/aws-remix-stream/app/styles/index.css deleted file mode 100644 index 8e562771e4..0000000000 --- a/examples/aws-remix-stream/app/styles/index.css +++ /dev/null @@ -1,41 +0,0 @@ -body { - font-family: Arial, sans-serif; - margin: 0; - padding: 0; - background-color: #f0f8ff; -} -.container { - max-width: 800px; - margin: 0 auto; - padding: 20px; -} -.bio-section { - background-color: #fff; - padding: 20px; - margin-bottom: 20px; - border-radius: 10px; -} -.bio-content { - display: flex; - align-items: center; -} -.bio-text { - flex: 1; - padding-right: 20px; -} -.character-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); - gap: 20px; -} -.character-card { - background-color: #fff; - padding: 10px; - border-radius: 5px; - text-align: center; -} -img { - max-width: 100%; - height: auto; - border-radius: 5px; -} diff --git a/examples/aws-remix-stream/package.json b/examples/aws-remix-stream/package.json deleted file mode 100644 index b3f71965b1..0000000000 --- a/examples/aws-remix-stream/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "aws-remix-stream", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@remix-run/node": "^2.12.1", - "@remix-run/react": "^2.12.1", - "@remix-run/serve": "^2.12.1", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.12.1", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=18.0.0" - } -} diff --git a/examples/aws-remix-stream/public/mr-krabs.png b/examples/aws-remix-stream/public/mr-krabs.png deleted file mode 100644 index e94ea64054..0000000000 Binary files a/examples/aws-remix-stream/public/mr-krabs.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/patrick.png b/examples/aws-remix-stream/public/patrick.png deleted file mode 100644 index 030eaaf8a3..0000000000 Binary files a/examples/aws-remix-stream/public/patrick.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/sandy.png b/examples/aws-remix-stream/public/sandy.png deleted file mode 100644 index eb7a9cc324..0000000000 Binary files a/examples/aws-remix-stream/public/sandy.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/spongebob.png b/examples/aws-remix-stream/public/spongebob.png deleted file mode 100644 index 18f7df537e..0000000000 Binary files a/examples/aws-remix-stream/public/spongebob.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/squidward.png b/examples/aws-remix-stream/public/squidward.png deleted file mode 100644 index 4af85e000b..0000000000 Binary files a/examples/aws-remix-stream/public/squidward.png and /dev/null differ diff --git a/examples/aws-remix-stream/sst.config.ts b/examples/aws-remix-stream/sst.config.ts deleted file mode 100644 index 23d914db47..0000000000 --- a/examples/aws-remix-stream/sst.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -/** - * ## AWS Remix streaming - * - * Follows the [Remix Streaming](https://remix.run/docs/en/main/guides/streaming) guide to create - * an app that streams data. - * - * Uses the `defer` utility to stream data through the `loader` function. - * - * ```tsx title="app/routes/_index.tsx" - * return defer({ - * spongebob, - * friends: friendsPromise, - * }); - * ``` - * - * Then uses the the `Suspense` and `Await` components to render the data. - * - * ```tsx title="app/routes/_index.tsx" - * Loading...}> - * - * { /* ... *\/ } - * - * - * ``` - * - * You should see the _friends_ section load after a 3 second delay. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - * - * Streaming works out of the box with the `Remix` component. - * - */ -export default $config({ - app(input) { - return { - name: "aws-remix-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Remix("MyWeb"); - }, -}); diff --git a/examples/aws-remix-stream/tsconfig.json b/examples/aws-remix-stream/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix-stream/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix-stream/vite.config.ts b/examples/aws-remix-stream/vite.config.ts deleted file mode 100644 index 2b6aff9872..0000000000 --- a/examples/aws-remix-stream/vite.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { installGlobals } from "@remix-run/node"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -installGlobals(); - -export default defineConfig({ - plugins: [remix(), tsconfigPaths()], -}); diff --git a/examples/aws-remix/.eslintrc.cjs b/examples/aws-remix/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix/.gitignore b/examples/aws-remix/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix/app/entry.client.tsx b/examples/aws-remix/app/entry.client.tsx deleted file mode 100644 index 94d5dc0de0..0000000000 --- a/examples/aws-remix/app/entry.client.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * By default, Remix will handle hydrating your app on the client for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.client - */ - -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/examples/aws-remix/app/entry.server.tsx b/examples/aws-remix/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix/app/root.tsx b/examples/aws-remix/app/root.tsx deleted file mode 100644 index 61c8b983d2..0000000000 --- a/examples/aws-remix/app/root.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; - -import "./tailwind.css"; - -export const links: LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix/app/routes/_index.tsx b/examples/aws-remix/app/routes/_index.tsx deleted file mode 100644 index 38db41f396..0000000000 --- a/examples/aws-remix/app/routes/_index.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Resource } from "sst"; -import { useLoaderData } from "@remix-run/react"; -import type { MetaFunction } from "@remix-run/node"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export const meta: MetaFunction = () => { - return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, - ]; -}; - -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} - -export default function Index() { - const data = useLoaderData(); - return ( -
-
-

- Welcome to Remix -

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(data.url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
-
- ); -} diff --git a/examples/aws-remix/app/tailwind.css b/examples/aws-remix/app/tailwind.css deleted file mode 100644 index 303fe158fc..0000000000 --- a/examples/aws-remix/app/tailwind.css +++ /dev/null @@ -1,12 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-remix/package.json b/examples/aws-remix/package.json deleted file mode 100644 index b0cc925225..0000000000 --- a/examples/aws-remix/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "aws-remix", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.699.0", - "@aws-sdk/s3-request-presigner": "^3.699.0", - "@remix-run/node": "^2.15.0", - "@remix-run/react": "^2.15.0", - "@remix-run/serve": "^2.15.0", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.15.0", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.19", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.4", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=20.0.0" - }, - "overrides": { - "valibot": "^0.41.0" - } -} diff --git a/examples/aws-remix/postcss.config.js b/examples/aws-remix/postcss.config.js deleted file mode 100644 index 2aa7205d4b..0000000000 --- a/examples/aws-remix/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/examples/aws-remix/public/logo-dark.png b/examples/aws-remix/public/logo-dark.png deleted file mode 100644 index b24c7aee3a..0000000000 Binary files a/examples/aws-remix/public/logo-dark.png and /dev/null differ diff --git a/examples/aws-remix/public/logo-light.png b/examples/aws-remix/public/logo-light.png deleted file mode 100644 index 4490ae7930..0000000000 Binary files a/examples/aws-remix/public/logo-light.png and /dev/null differ diff --git a/examples/aws-remix/sst.config.ts b/examples/aws-remix/sst.config.ts deleted file mode 100644 index 71ea60c142..0000000000 --- a/examples/aws-remix/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-remix", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.Remix("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-remix/tailwind.config.ts b/examples/aws-remix/tailwind.config.ts deleted file mode 100644 index 5f06ad4ba5..0000000000 --- a/examples/aws-remix/tailwind.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Config } from "tailwindcss"; - -export default { - content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"], - theme: { - extend: { - fontFamily: { - sans: [ - "Inter", - "ui-sans-serif", - "system-ui", - "sans-serif", - "Apple Color Emoji", - "Segoe UI Emoji", - "Segoe UI Symbol", - "Noto Color Emoji", - ], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-remix/tsconfig.json b/examples/aws-remix/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix/vite.config.ts b/examples/aws-remix/vite.config.ts deleted file mode 100644 index e4e8cefc3b..0000000000 --- a/examples/aws-remix/vite.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -declare module "@remix-run/node" { - interface Future { - v3_singleFetch: true; - } -} - -export default defineConfig({ - plugins: [ - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - v3_singleFetch: true, - v3_lazyRouteDiscovery: true, - }, - }), - tsconfigPaths(), - ], -}); diff --git a/examples/aws-router-bucket/package.json b/examples/aws-router-bucket/package.json deleted file mode 100644 index 8870a7c91c..0000000000 --- a/examples/aws-router-bucket/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-router-bucket", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-router-bucket/spongebob.svg b/examples/aws-router-bucket/spongebob.svg deleted file mode 100644 index a9dd142f31..0000000000 --- a/examples/aws-router-bucket/spongebob.svg +++ /dev/null @@ -1 +0,0 @@ -Don’tflop character artwork \ No newline at end of file diff --git a/examples/aws-router-bucket/sst.config.ts b/examples/aws-router-bucket/sst.config.ts deleted file mode 100644 index b1382a1f62..0000000000 --- a/examples/aws-router-bucket/sst.config.ts +++ /dev/null @@ -1,45 +0,0 @@ -/// - -import path from "path"; - -/** - * ## Router and bucket - * - * Creates a router that serves static files from the `public` folder of a given bucket. - */ -export default $config({ - app(input) { - return { - name: "aws-router-bucket", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // Create a bucket that CloudFront can access - const bucket = new sst.aws.Bucket("MyBucket", { - access: "cloudfront", - }); - - // Upload the image to the `public` folder - new aws.s3.BucketObjectv2("MyImage", { - bucket: bucket.name, - key: "public/spongebob.svg", - contentType: "image/svg+xml", - source: $asset("spongebob.svg"), - }); - - const router = new sst.aws.Router("MyRouter", { - routes: { - "/*": { - bucket, - rewrite: { regex: "^/(.*)$", to: "/public/$1" }, - }, - }, - }); - - return { - image: $interpolate`${router.url}/spongebob.svg`, - }; - }, -}); diff --git a/examples/aws-router-protection/api.ts b/examples/aws-router-protection/api.ts deleted file mode 100644 index bb310ecba1..0000000000 --- a/examples/aws-router-protection/api.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const handler = async (event: any) => { - return { - statusCode: 200, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(event.headers), - }; -}; diff --git a/examples/aws-router-protection/package.json b/examples/aws-router-protection/package.json deleted file mode 100644 index 6e962323f7..0000000000 --- a/examples/aws-router-protection/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-router-protection", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-router-protection/sst.config.ts b/examples/aws-router-protection/sst.config.ts deleted file mode 100644 index ee813c3267..0000000000 --- a/examples/aws-router-protection/sst.config.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// - -/** - * ## Router protection with OAC - * - * Creates a router with Origin Access Control (OAC) to secure Lambda function URLs - * behind CloudFront. Direct access to the Lambda URL returns 403. - */ -export default $config({ - app(input) { - return { - name: "aws-router-protection", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const router = new sst.aws.Router("MyRouter", { - protection: "oac", - }); - - const api = new sst.aws.Function("MyApi", { - handler: "api.handler", - url: { - router: { instance: router, path: "/api" }, - }, - }); - - return { - router: router.url, - api: api.url, - }; - }, -}); diff --git a/examples/aws-router-waf/api.ts b/examples/aws-router-waf/api.ts deleted file mode 100644 index fb693b1801..0000000000 --- a/examples/aws-router-waf/api.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const handler = async (event: any) => { - return { - statusCode: 200, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ message: "Hello from WAF-protected Router!" }), - }; -}; diff --git a/examples/aws-router-waf/sst.config.ts b/examples/aws-router-waf/sst.config.ts deleted file mode 100644 index 793edf49ff..0000000000 --- a/examples/aws-router-waf/sst.config.ts +++ /dev/null @@ -1,47 +0,0 @@ -/// - -/** - * ## Router with WAF - * - * Enable WAF (Web Application Firewall) for a Router to protect against common - * web exploits and bots. - * - * WAF includes rate limiting per IP, and AWS managed rules for core rule set, - * known bad inputs, and SQL injection protection. - * - * You can also enable WAF logging to CloudWatch to monitor requests. - */ -export default $config({ - app(input) { - return { - name: "aws-router-waf", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const api = new sst.aws.Function("MyApi", { - handler: "api.handler", - url: true, - }); - - const router = new sst.aws.Router("MyRouter", { - routes: { - "/*": api.url, - }, - waf: { - rateLimitPerIp: 1000, - managedRules: { - coreRuleSet: true, - knownBadInputs: true, - sqlInjection: true, - }, - logging: true, - }, - }); - - return { - url: router.url, - }; - }, -}); diff --git a/examples/aws-router/api.ts b/examples/aws-router/api.ts deleted file mode 100644 index bb310ecba1..0000000000 --- a/examples/aws-router/api.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const handler = async (event: any) => { - return { - statusCode: 200, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(event.headers), - }; -}; diff --git a/examples/aws-router/package.json b/examples/aws-router/package.json deleted file mode 100644 index 87a5d86ce2..0000000000 --- a/examples/aws-router/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-router", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-router/sst.config.ts b/examples/aws-router/sst.config.ts deleted file mode 100644 index 5db6f2d75c..0000000000 --- a/examples/aws-router/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -/** - * ## Router and function URL - * - * Creates a router that routes all requests to a function with a URL. - */ -export default $config({ - app(input) { - return { - name: "aws-router", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const api = new sst.aws.Function("MyApi", { - handler: "api.handler", - url: true, - }); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - const router = new sst.aws.Router("MyRouter", { - routes: { - "/api/*": api.url, - "/*": $interpolate`https://${bucket.domain}`, - }, - }); - - return { - router: router.url, - bucket: bucket.domain, - }; - }, -}); diff --git a/examples/aws-rust-api/.gitignore b/examples/aws-rust-api/.gitignore deleted file mode 100644 index 2a7be17e50..0000000000 --- a/examples/aws-rust-api/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target - -# sst -.sst diff --git a/examples/aws-rust-api/Cargo.toml b/examples/aws-rust-api/Cargo.toml deleted file mode 100644 index 72282cdc91..0000000000 --- a/examples/aws-rust-api/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "aws-rust-lambda" -version = "0.1.0" -edition = "2021" - -[dependencies] -aws-config = { version = "1.5.16", features = ["behavior-version-latest"] } -aws-sdk-s3 = "1.73.0" -axum = "0.8.1" -lambda_http = "0.13.0" -serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.138" -# this will break when not in this repo. -sst_sdk = { version = "0.1.0", path = "../../sdk/rust" } -# sst_sdk = "0.1.0" -tokio = { version = "1", features = ["macros"] } -uuid = { version = "1.13.1", features = ["v4"] } diff --git a/examples/aws-rust-api/src/main.rs b/examples/aws-rust-api/src/main.rs deleted file mode 100644 index 7675ea7282..0000000000 --- a/examples/aws-rust-api/src/main.rs +++ /dev/null @@ -1,82 +0,0 @@ -use std::{env::set_var, time::Duration}; - -use aws_sdk_s3::presigning::PresigningConfig; -use axum::{routing::get, Router}; -use lambda_http::{run, tracing, Error}; -use serde::Deserialize; -use sst_sdk::Resource; - -#[derive(Deserialize, Debug)] -struct Bucket { - name: String, -} - -async fn presigned_url() -> String { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let url = client - .put_object() - .bucket(name) - .key(uuid::Uuid::new_v4()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - url.uri().to_string() -} - -async fn latest() -> String { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let objects = client.list_objects().bucket(&name).send().await.unwrap(); - let latest = objects - .contents() - .into_iter() - .min_by_key(|o| o.last_modified().unwrap()) - .unwrap(); - - let url = client - .get_object() - .bucket(name) - .key(latest.key().unwrap()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - url.uri().to_string() -} - -#[tokio::main] -async fn main() -> Result<(), Error> { - // If you use API Gateway stages, the Rust Runtime will include the stage name - // as part of the path that your application receives. - // Setting the following environment variable, you can remove the stage from the path. - // This variable only applies to API Gateway stages, - // you can remove it if you don't use them. - // i.e with: `GET /test-stage/todo/id/123` without: `GET /todo/id/123` - set_var("AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH", "true"); - - tracing::init_default_subscriber(); - - let app = Router::new() - .route("/", get(presigned_url)) - .route("/latest", get(latest)); - - run(app).await -} diff --git a/examples/aws-rust-api/sst.config.ts b/examples/aws-rust-api/sst.config.ts deleted file mode 100644 index de11b367dc..0000000000 --- a/examples/aws-rust-api/sst.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -/** - * ## Rust function - * - * Deploy a Rust Lambda function with a function URL and a linked S3 bucket. - */ -export default $config({ - app(input) { - return { - name: "aws-rust-api", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("Bucket"); - const lambda = new sst.aws.Function("RustFunction", { - runtime: "rust", - handler: "./", - url: true, - architecture: "arm64", - link: [bucket], - }); - - return { url: lambda.url }; - }, -}); diff --git a/examples/aws-rust-cluster/.dockerignore b/examples/aws-rust-cluster/.dockerignore deleted file mode 100644 index 3821f7cc63..0000000000 --- a/examples/aws-rust-cluster/.dockerignore +++ /dev/null @@ -1,24 +0,0 @@ -# rust -/target - -# dotfiles -*.env -.git -.gitignore -.dockerignore -.build - -# misc -Dockerfile -docker-compose.yml -README.md - -# node -node_modules -package.json -package-lock.json -tsconfig.json - -# sst -sst.config.ts -.sst \ No newline at end of file diff --git a/examples/aws-rust-cluster/.gitignore b/examples/aws-rust-cluster/.gitignore deleted file mode 100644 index 6b247dbcba..0000000000 --- a/examples/aws-rust-cluster/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# sst -.sst - -# rust -Cargo.lock -target/ \ No newline at end of file diff --git a/examples/aws-rust-cluster/Cargo.toml b/examples/aws-rust-cluster/Cargo.toml deleted file mode 100644 index 36a109f013..0000000000 --- a/examples/aws-rust-cluster/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "aws_rust_cluster" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = "1.0.86" -axum = "0.7.5" -serde = { version = "1.0.209", features = ["derive"] } -tokio = { version = "1.40.0", features = ["rt-multi-thread", "macros", "net"] } diff --git a/examples/aws-rust-cluster/Dockerfile b/examples/aws-rust-cluster/Dockerfile deleted file mode 100644 index 679bdab9e4..0000000000 --- a/examples/aws-rust-cluster/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM rust:slim AS chef - -# install build tools -RUN apt-get update -y && \ - apt-get install -y pkg-config make g++ libssl-dev && \ - rustup target add x86_64-unknown-linux-gnu - -# add cargo chef (this installs only once on first build) -RUN cargo install cargo-chef -WORKDIR /app - -FROM chef AS planner -COPY . . -RUN cargo chef prepare --recipe-path recipe.json - -FROM chef AS builder -COPY --from=planner /app/recipe.json recipe.json -# build docker caching layer -RUN cargo chef cook --release --recipe-path recipe.json - -# build binary -COPY . . -RUN cargo build --release --target x86_64-unknown-linux-gnu - -# distroless image; launch app -FROM gcr.io/distroless/cc -COPY --from=builder /app/target/x86_64-unknown-linux-gnu/release/aws_rust_cluster /bin/aws_rust_cluster -ENTRYPOINT [ "/bin/aws_rust_cluster" ] diff --git a/examples/aws-rust-cluster/docker-compose.yml b/examples/aws-rust-cluster/docker-compose.yml deleted file mode 100644 index 7b22f1ec37..0000000000 --- a/examples/aws-rust-cluster/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - api: - build: - context: . - dockerfile: ./Dockerfile - ports: - - 80:80 - expose: - - 80 \ No newline at end of file diff --git a/examples/aws-rust-cluster/package.json b/examples/aws-rust-cluster/package.json deleted file mode 100644 index 3523728cc7..0000000000 --- a/examples/aws-rust-cluster/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-rust-cluster", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "sst": "file:../../sdk/js", - "sst-linux-x64": "^4" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-rust-cluster/src/main.rs b/examples/aws-rust-cluster/src/main.rs deleted file mode 100644 index f8a4e7649f..0000000000 --- a/examples/aws-rust-cluster/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -use anyhow::Result; -use axum::{http::StatusCode, response::IntoResponse, routing::get, Json, Router}; -use serde::Serialize; -use tokio::net::TcpListener; - -#[derive(Serialize)] -pub struct Ping { - message: &'static str, -} - -pub async fn ping() -> impl IntoResponse { - ( - StatusCode::IM_A_TEAPOT, - Json(Ping { - message: "hello from rust :)", - }), - ) -} - -#[tokio::main] -async fn main() -> Result<()> { - let api = Router::new().route("/", get(ping)); - let addr = match cfg!(debug_assertions) { - true => "0.0.0.0:3000", - false => "0.0.0.0:80", - }; - let listener = TcpListener::bind(addr).await?; - Ok(axum::serve(listener, api).await?) -} diff --git a/examples/aws-rust-cluster/sst.config.ts b/examples/aws-rust-cluster/sst.config.ts deleted file mode 100644 index 0641cf6a35..0000000000 --- a/examples/aws-rust-cluster/sst.config.ts +++ /dev/null @@ -1,42 +0,0 @@ -/// - -/** - * ## Rust container - * - * Deploy a Rust app in a container with a load balancer using a Dockerfile. - */ -export default $config({ - app(input) { - return { - name: "aws-rust-cluster", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { region: "us-east-1" }, - }, - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "gateway" }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - const service = new sst.aws.Service("MyService", { - cluster, - image: { - context: "./", - dockerfile: "Dockerfile", - }, - loadBalancer: { - domain: "rust.dockerfile.dev.sst.dev", - ports: [ - { listen: "80/http" }, - { listen: "443/https", forward: "80/http" }, - ], - }, - }); - - return { - url: service.url, - }; - }, -}); diff --git a/examples/aws-rust-cluster/tsconfig.json b/examples/aws-rust-cluster/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-rust-cluster/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-rust-loco/.dockerignore b/examples/aws-rust-loco/.dockerignore deleted file mode 100644 index f403586fdf..0000000000 --- a/examples/aws-rust-loco/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -target -dockerfile -.dockerignore -.git -.gitignore -.cargo - -# sst -.sst diff --git a/examples/aws-rust-loco/.github/workflows/ci.yaml b/examples/aws-rust-loco/.github/workflows/ci.yaml deleted file mode 100644 index b2e3e1162d..0000000000 --- a/examples/aws-rust-loco/.github/workflows/ci.yaml +++ /dev/null @@ -1,101 +0,0 @@ -name: CI -on: - push: - branches: - - master - - main - pull_request: - -env: - RUST_TOOLCHAIN: stable - TOOLCHAIN_PROFILE: minimal - -jobs: - rustfmt: - name: Check Style - runs-on: ubuntu-latest - - permissions: - contents: read - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt - - name: Run cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Run Clippy - runs-on: ubuntu-latest - - permissions: - contents: read - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - name: Run cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms - - test: - name: Run Tests - runs-on: ubuntu-latest - - permissions: - contents: read - - services: - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - "6379:6379" - postgres: - image: postgres - env: - POSTGRES_DB: postgres_test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - # Set health checks to wait until postgres has started - options: --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features --all - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test diff --git a/examples/aws-rust-loco/.gitignore b/examples/aws-rust-loco/.gitignore deleted file mode 100644 index 1902da3f36..0000000000 --- a/examples/aws-rust-loco/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -**/config/local.yaml -**/config/*.local.yaml -**/config/production.yaml - -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# include cargo lock -!Cargo.lock -.cargo - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -*.sqlite - -# sst -.sst diff --git a/examples/aws-rust-loco/.rustfmt.toml b/examples/aws-rust-loco/.rustfmt.toml deleted file mode 100644 index d862e08106..0000000000 --- a/examples/aws-rust-loco/.rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -max_width = 100 -use_small_heuristics = "Default" diff --git a/examples/aws-rust-loco/Cargo.toml b/examples/aws-rust-loco/Cargo.toml deleted file mode 100644 index 52b82829ee..0000000000 --- a/examples/aws-rust-loco/Cargo.toml +++ /dev/null @@ -1,50 +0,0 @@ -[workspace] - -[package] -name = "server" -version = "0.1.0" -edition = "2021" -publish = false -default-run = "server-cli" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - -loco-rs = { version = "0.9.0" } -migration = { path = "migration" } - -serde = { version = "1", features = ["derive"] } -serde_json = "1" -tokio = { version = "1.33.0", default-features = false } -async-trait = "0.1.74" -tracing = "0.1.40" -chrono = "0.4" -validator = { version = "0.16" } -sea-orm = { version = "1.0.0", features = [ - "sqlx-sqlite", - "sqlx-postgres", - "runtime-tokio-rustls", - "macros", -] } - -axum = "0.7.5" -include_dir = "0.7" -uuid = { version = "1.6.0", features = ["v4"] } -tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] } - -[[bin]] -name = "server-cli" -path = "src/bin/main.rs" -required-features = [] - -[[bin]] -name = "tool" -path = "src/bin/tool.rs" -required-features = [] - -[dev-dependencies] -serial_test = "3.1.1" -rstest = "0.21.0" -loco-rs = { version = "0.9.0", features = ["testing"] } -insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] } diff --git a/examples/aws-rust-loco/Dockerfile b/examples/aws-rust-loco/Dockerfile deleted file mode 100644 index 99315f26d2..0000000000 --- a/examples/aws-rust-loco/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:1.74-slim as builder - -WORKDIR /usr/src/ - -COPY . . - -RUN cargo build --release - -FROM debian:bookworm-slim - -WORKDIR /usr/app - -COPY --from=builder /usr/src/config /usr/app/config -COPY --from=builder /usr/src/target/release/server-cli /usr/app/server-cli - -ENTRYPOINT ["/usr/app/server-cli"] \ No newline at end of file diff --git a/examples/aws-rust-loco/Justfile b/examples/aws-rust-loco/Justfile deleted file mode 100644 index 1c1d9b2d59..0000000000 --- a/examples/aws-rust-loco/Justfile +++ /dev/null @@ -1,24 +0,0 @@ -# Command to run SST, process SST_RESOURCE_LocoDatabase, and run cargo loco start -dev stage="production": - #!/usr/bin/env bash - set -euo pipefail - - # Run SST shell and capture its output - SST_OUTPUT=$(pnpm sst shell --stage={{stage}} -- env) - - # Extract SST_RESOURCE_LocoDatabase from SST output - SST_RESOURCE_LocoDatabase=$(echo "$SST_OUTPUT" | grep SST_RESOURCE_LocoDatabase | cut -d '=' -f2-) - - # Ensure the environment variable exists - if [ -z "${SST_RESOURCE_LocoDatabase:-}" ]; then - echo "Error: SST_RESOURCE_LocoDatabase is not set" >&2 - exit 1 - fi - - # Use jq to parse the JSON and construct the DATABASE_URL - export DATABASE_URL=$(echo "$SST_RESOURCE_LocoDatabase" | jq -r ' - "postgres://\(.username):\(.password | @uri)@\(.host):\(.port)/\(.database)" - ') - - # Run cargo loco start with the processed DATABASE_URL - pnpm sst shell --stage={{stage}} -- cargo loco start diff --git a/examples/aws-rust-loco/config/development.yaml b/examples/aws-rust-loco/config/development.yaml deleted file mode 100644 index 940e654b71..0000000000 --- a/examples/aws-rust-loco/config/development.yaml +++ /dev/null @@ -1,145 +0,0 @@ -# Loco configuration file documentation - -# Application logging configuration -logger: - # Enable or disable logging. - enable: true - # Enable pretty backtrace (sets RUST_BACKTRACE=1) - pretty_backtrace: false - # Log level, options: trace, debug, info, warn or error. - level: info - # Define the logging format. options: compact, pretty or json - format: json - # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries - # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters. - # override_filter: trace - -# Web server configuration -server: - # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} - port: 5150 - binding: 0.0.0.0 - # The UI hostname or IP address that mailers will point to. - host: http://localhost - # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block - middlewares: - # Enable Etag cache header middleware - etag: - enable: true - # Allows to limit the payload size request. payload that bigger than this file will blocked the request. - limit_payload: - # Enable/Disable the middleware. - enable: true - # the limit size. can be b,kb,kib,mb,mib,gb,gib - body_limit: 5mb - # set secure headers - secure_headers: - preset: github - # calculate remote IP based on `X-Forwarded-For` when behind a proxy or load balancer - # use RemoteIP(..) extractor to get the remote IP. - # without this middleware, you'll get the proxy IP instead. - # For more: https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/middleware/remote_ip.rb - # - # NOTE! only enable when under a proxy, otherwise this can lead to IP spoofing vulnerabilities - # trust me, you'll know if you need this middleware. - remote_ip: - enable: false - # # replace the default trusted proxies: - # trusted_proxies: - # - ip range 1 - # - ip range 2 .. - # Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details. - logger: - # Enable/Disable the middleware. - enable: true - # when your code is panicked, the request still returns 500 status code. - catch_panic: - # Enable/Disable the middleware. - enable: true - # Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned. - timeout_request: - # Enable/Disable the middleware. - enable: false - # Duration time in milliseconds. - timeout: 5000 - cors: - enable: true - # Set the value of the [`Access-Control-Allow-Origin`][mdn] header - # allow_origins: - # - https://loco.rs - # Set the value of the [`Access-Control-Allow-Headers`][mdn] header - # allow_headers: - # - Content-Type - # Set the value of the [`Access-Control-Allow-Methods`][mdn] header - # allow_methods: - # - POST - # Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds - # max_age: 3600 - -# Worker Configuration -workers: - # specifies the worker mode. Options: - # - BackgroundQueue - Workers operate asynchronously in the background, processing queued. - # - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed. - # - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities. - mode: BackgroundQueue - -# Mailer Configuration. -mailer: - # SMTP mailer configuration. - smtp: - # Enable/Disable smtp mailer. - enable: false - # SMTP server host. e.x localhost, smtp.gmail.com - host: {{ get_env(name="MAILER_HOST", default="localhost") }} - # SMTP server port - port: 1025 - # Use secure connection (SSL/TLS). - secure: false - # auth: - # user: - # password: - -# Initializers Configuration -# initializers: -# oauth2: -# authorization_code: # Authorization code grant type -# - client_identifier: google # Identifier for the OAuth2 provider. Replace 'google' with your provider's name if different, must be unique within the oauth2 config. -# ... other fields - -# Database Configuration -database: - # Database connection URI - uri: {{ get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/server_development") }} - # When enabled, the sql query will be logged. - enable_logging: false - # Set the timeout duration when acquiring a connection. - connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }} - # Set the idle duration before closing a connection. - idle_timeout: 500 - # Minimum number of connections for a pool. - min_connections: 1 - # Maximum number of connections for a pool. - max_connections: 1 - # Run migration up when application loaded - auto_migrate: false - # Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_truncate: false - # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_recreate: false - -# Queue Configuration -queue: - # Redis connection URI - uri: {{ get_env(name="REDIS_URL", default="redis://127.0.0.1") }} - # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_flush: false - -# Authentication Configuration -auth: - # JWT authentication - jwt: - # Secret key for token generation and verification - secret: KRVK4VAddJ3zV8IkOCTh - # Token expiration time in seconds - expiration: 604800 # 7 days diff --git a/examples/aws-rust-loco/config/test.yaml b/examples/aws-rust-loco/config/test.yaml deleted file mode 100644 index 947d5b1de5..0000000000 --- a/examples/aws-rust-loco/config/test.yaml +++ /dev/null @@ -1,126 +0,0 @@ -# Loco configuration file documentation - -# Application logging configuration -logger: - # Enable or disable logging. - enable: false - # Log level, options: trace, debug, info, warn or error. - level: debug - # Define the logging format. options: compact, pretty or json - format: compact - # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries - # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters. - # override_filter: trace - -# Web server configuration -server: - # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} - port: 5150 - # The UI hostname or IP address that mailers will point to. - host: http://localhost - # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block - middlewares: - # Allows to limit the payload size request. payload that bigger than this file will blocked the request. - limit_payload: - # Enable/Disable the middleware. - enable: true - # the limit size. can be b,kb,kib,mb,mib,gb,gib - body_limit: 5mb - # Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details. - logger: - # Enable/Disable the middleware. - enable: true - # when your code is panicked, the request still returns 500 status code. - catch_panic: - # Enable/Disable the middleware. - enable: true - # Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned. - timeout_request: - # Enable/Disable the middleware. - enable: false - # Duration time in milliseconds. - timeout: 5000 - cors: - enable: true - # Set the value of the [`Access-Control-Allow-Origin`][mdn] header - # allow_origins: - # - https://loco.rs - # Set the value of the [`Access-Control-Allow-Headers`][mdn] header - # allow_headers: - # - Content-Type - # Set the value of the [`Access-Control-Allow-Methods`][mdn] header - # allow_methods: - # - POST - # Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds - # max_age: 3600 - -# Worker Configuration -workers: - # specifies the worker mode. Options: - # - BackgroundQueue - Workers operate asynchronously in the background, processing queued. - # - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed. - # - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities. - mode: ForegroundBlocking - -# Mailer Configuration. -mailer: - # SMTP mailer configuration. - smtp: - # Enable/Disable smtp mailer. - enable: true - # SMTP server host. e.x localhost, smtp.gmail.com - host: localhost - # SMTP server port - port: 1025 - # Use secure connection (SSL/TLS). - secure: false - # auth: - # user: - # password: - stub: true - -# Initializers Configuration -# initializers: -# oauth2: -# authorization_code: # Authorization code grant type -# - client_identifier: google # Identifier for the OAuth2 provider. Replace 'google' with your provider's name if different, must be unique within the oauth2 config. -# ... other fields - - -# Database Configuration -database: - # Database connection URI - uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/server_test")}} - # When enabled, the sql query will be logged. - enable_logging: false - # Set the timeout duration when acquiring a connection. - connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }} - # Set the idle duration before closing a connection. - idle_timeout: 500 - # Minimum number of connections for a pool. - min_connections: 1 - # Maximum number of connections for a pool. - max_connections: 1 - # Run migration up when application loaded - auto_migrate: true - # Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_truncate: true - # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_recreate: false - -# Queue Configuration -queue: - # Redis connection URI - uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} - # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_flush: false - -# Authentication Configuration -auth: - # JWT authentication - jwt: - # Secret key for token generation and verification - secret: jFb88JjbJsVEsVdwNa8U - # Token expiration time in seconds - expiration: 604800 # 7 days - diff --git a/examples/aws-rust-loco/examples/playground.rs b/examples/aws-rust-loco/examples/playground.rs deleted file mode 100644 index 4dc0bb3873..0000000000 --- a/examples/aws-rust-loco/examples/playground.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[allow(unused_imports)] -use loco_rs::{cli::playground, prelude::*}; -use server::app::App; - -#[tokio::main] -async fn main() -> loco_rs::Result<()> { - let _ctx = playground::().await?; - - // let active_model: articles::ActiveModel = ActiveModel { - // title: Set(Some("how to build apps in 3 steps".to_string())), - // content: Set(Some("use Loco: https://loco.rs".to_string())), - // ..Default::default() - // }; - // active_model.insert(&ctx.db).await.unwrap(); - - // let res = articles::Entity::find().all(&ctx.db).await.unwrap(); - // println!("{:?}", res); - println!("welcome to playground. edit me at `examples/playground.rs`"); - - Ok(()) -} diff --git a/examples/aws-rust-loco/migration/Cargo.toml b/examples/aws-rust-loco/migration/Cargo.toml deleted file mode 100644 index 723b73ccf4..0000000000 --- a/examples/aws-rust-loco/migration/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "migration" -version = "0.1.0" -edition = "2021" -publish = false - -[lib] -name = "migration" -path = "src/lib.rs" - -[dependencies] -async-std = { version = "1", features = ["attributes", "tokio1"] } -loco-rs = { version = "0.9.0" } - -[dependencies.sea-orm-migration] -version = "1.0.0" -features = [ - # Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI. - # View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime. - # e.g. - "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature -] diff --git a/examples/aws-rust-loco/migration/src/lib.rs b/examples/aws-rust-loco/migration/src/lib.rs deleted file mode 100644 index 3352f5c573..0000000000 --- a/examples/aws-rust-loco/migration/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![allow(elided_lifetimes_in_paths)] -#![allow(clippy::wildcard_imports)] -pub use sea_orm_migration::prelude::*; - -mod m20220101_000001_users; -mod m20231103_114510_notes; - -pub struct Migrator; - -#[async_trait::async_trait] -impl MigratorTrait for Migrator { - fn migrations() -> Vec> { - vec![ - Box::new(m20220101_000001_users::Migration), - Box::new(m20231103_114510_notes::Migration), - ] - } -} diff --git a/examples/aws-rust-loco/migration/src/m20220101_000001_users.rs b/examples/aws-rust-loco/migration/src/m20220101_000001_users.rs deleted file mode 100644 index 936ad3d0cb..0000000000 --- a/examples/aws-rust-loco/migration/src/m20220101_000001_users.rs +++ /dev/null @@ -1,50 +0,0 @@ -use loco_rs::schema::table_auto_tz; -use sea_orm_migration::{prelude::*, schema::*}; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - let table = table_auto_tz(Users::Table) - .col(pk_auto(Users::Id)) - .col(uuid(Users::Pid)) - .col(string_uniq(Users::Email)) - .col(string(Users::Password)) - .col(string(Users::ApiKey).unique_key()) - .col(string(Users::Name)) - .col(string_null(Users::ResetToken)) - .col(timestamp_with_time_zone_null(Users::ResetSentAt)) - .col(string_null(Users::EmailVerificationToken)) - .col(timestamp_with_time_zone_null( - Users::EmailVerificationSentAt, - )) - .col(timestamp_with_time_zone_null(Users::EmailVerifiedAt)) - .to_owned(); - manager.create_table(table).await?; - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Users::Table).to_owned()) - .await - } -} - -#[derive(Iden)] -pub enum Users { - Table, - Id, - Pid, - Email, - Name, - Password, - ApiKey, - ResetToken, - ResetSentAt, - EmailVerificationToken, - EmailVerificationSentAt, - EmailVerifiedAt, -} diff --git a/examples/aws-rust-loco/migration/src/m20231103_114510_notes.rs b/examples/aws-rust-loco/migration/src/m20231103_114510_notes.rs deleted file mode 100644 index d0d8a5a0f7..0000000000 --- a/examples/aws-rust-loco/migration/src/m20231103_114510_notes.rs +++ /dev/null @@ -1,34 +0,0 @@ -use loco_rs::schema::table_auto_tz; -use sea_orm_migration::{prelude::*, schema::*}; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - table_auto_tz(Notes::Table) - .col(pk_auto(Notes::Id)) - .col(string_null(Notes::Title)) - .col(string_null(Notes::Content)) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Notes::Table).to_owned()) - .await - } -} - -#[derive(DeriveIden)] -enum Notes { - Table, - Id, - Title, - Content, -} diff --git a/examples/aws-rust-loco/src/app.rs b/examples/aws-rust-loco/src/app.rs deleted file mode 100644 index 4b76c503bc..0000000000 --- a/examples/aws-rust-loco/src/app.rs +++ /dev/null @@ -1,72 +0,0 @@ -use std::path::Path; - -use async_trait::async_trait; -use loco_rs::{ - app::{AppContext, Hooks}, - boot::{create_app, BootResult, StartMode}, - controller::AppRoutes, - db::{self, truncate_table}, - environment::Environment, - task::Tasks, - worker::{AppWorker, Processor}, - Result, -}; -use migration::Migrator; -use sea_orm::DatabaseConnection; - -use crate::{ - controllers, - models::_entities::{notes, users}, - tasks, - workers::downloader::DownloadWorker, -}; - -pub struct App; -#[async_trait] -impl Hooks for App { - fn app_name() -> &'static str { - env!("CARGO_CRATE_NAME") - } - - fn app_version() -> String { - format!( - "{} ({})", - env!("CARGO_PKG_VERSION"), - option_env!("BUILD_SHA") - .or(option_env!("GITHUB_SHA")) - .unwrap_or("dev") - ) - } - - async fn boot(mode: StartMode, environment: &Environment) -> Result { - create_app::(mode, environment).await - } - - fn routes(_ctx: &AppContext) -> AppRoutes { - AppRoutes::with_default_routes() - .add_route(controllers::health::routes()) - .add_route(controllers::notes::routes()) - .add_route(controllers::auth::routes()) - .add_route(controllers::user::routes()) - } - - fn connect_workers<'a>(p: &'a mut Processor, ctx: &'a AppContext) { - p.register(DownloadWorker::build(ctx)); - } - - fn register_tasks(tasks: &mut Tasks) { - tasks.register(tasks::seed::SeedData); - } - - async fn truncate(db: &DatabaseConnection) -> Result<()> { - truncate_table(db, users::Entity).await?; - truncate_table(db, notes::Entity).await?; - Ok(()) - } - - async fn seed(db: &DatabaseConnection, base: &Path) -> Result<()> { - db::seed::(db, &base.join("users.yaml").display().to_string()).await?; - db::seed::(db, &base.join("notes.yaml").display().to_string()).await?; - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/bin/main.rs b/examples/aws-rust-loco/src/bin/main.rs deleted file mode 100644 index 9b895c1be2..0000000000 --- a/examples/aws-rust-loco/src/bin/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -use loco_rs::cli; -use server::app::App; -use migration::Migrator; - -#[tokio::main] -async fn main() -> loco_rs::Result<()> { - cli::main::().await -} diff --git a/examples/aws-rust-loco/src/bin/tool.rs b/examples/aws-rust-loco/src/bin/tool.rs deleted file mode 100644 index 9b895c1be2..0000000000 --- a/examples/aws-rust-loco/src/bin/tool.rs +++ /dev/null @@ -1,8 +0,0 @@ -use loco_rs::cli; -use server::app::App; -use migration::Migrator; - -#[tokio::main] -async fn main() -> loco_rs::Result<()> { - cli::main::().await -} diff --git a/examples/aws-rust-loco/src/controllers/auth.rs b/examples/aws-rust-loco/src/controllers/auth.rs deleted file mode 100644 index dba78a3e90..0000000000 --- a/examples/aws-rust-loco/src/controllers/auth.rs +++ /dev/null @@ -1,150 +0,0 @@ -use axum::debug_handler; -use loco_rs::prelude::*; -use serde::{Deserialize, Serialize}; - -use crate::{ - mailers::auth::AuthMailer, - models::{ - _entities::users, - users::{LoginParams, RegisterParams}, - }, - views::auth::LoginResponse, -}; -#[derive(Debug, Deserialize, Serialize)] -pub struct VerifyParams { - pub token: String, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct ForgotParams { - pub email: String, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct ResetParams { - pub token: String, - pub password: String, -} - -/// Register function creates a new user with the given parameters and sends a -/// welcome email to the user -#[debug_handler] -async fn register( - State(ctx): State, - Json(params): Json, -) -> Result { - let res = users::Model::create_with_password(&ctx.db, ¶ms).await; - - let user = match res { - Ok(user) => user, - Err(err) => { - tracing::info!( - message = err.to_string(), - user_email = ¶ms.email, - "could not register user", - ); - return format::json(()); - } - }; - - let user = user - .into_active_model() - .set_email_verification_sent(&ctx.db) - .await?; - - AuthMailer::send_welcome(&ctx, &user).await?; - - format::json(()) -} - -/// Verify register user. if the user not verified his email, he can't login to -/// the system. -#[debug_handler] -async fn verify( - State(ctx): State, - Json(params): Json, -) -> Result { - let user = users::Model::find_by_verification_token(&ctx.db, ¶ms.token).await?; - - if user.email_verified_at.is_some() { - tracing::info!(pid = user.pid.to_string(), "user already verified"); - } else { - let active_model = user.into_active_model(); - let user = active_model.verified(&ctx.db).await?; - tracing::info!(pid = user.pid.to_string(), "user verified"); - } - - format::json(()) -} - -/// In case the user forgot his password this endpoints generate a forgot token -/// and send email to the user. In case the email not found in our DB, we are -/// returning a valid request for for security reasons (not exposing users DB -/// list). -#[debug_handler] -async fn forgot( - State(ctx): State, - Json(params): Json, -) -> Result { - let Ok(user) = users::Model::find_by_email(&ctx.db, ¶ms.email).await else { - // we don't want to expose our users email. if the email is invalid we still - // returning success to the caller - return format::json(()); - }; - - let user = user - .into_active_model() - .set_forgot_password_sent(&ctx.db) - .await?; - - AuthMailer::forgot_password(&ctx, &user).await?; - - format::json(()) -} - -/// reset user password by the given parameters -#[debug_handler] -async fn reset(State(ctx): State, Json(params): Json) -> Result { - let Ok(user) = users::Model::find_by_reset_token(&ctx.db, ¶ms.token).await else { - // we don't want to expose our users email. if the email is invalid we still - // returning success to the caller - tracing::info!("reset token not found"); - - return format::json(()); - }; - user.into_active_model() - .reset_password(&ctx.db, ¶ms.password) - .await?; - - format::json(()) -} - -/// Creates a user login and returns a token -#[debug_handler] -async fn login(State(ctx): State, Json(params): Json) -> Result { - let user = users::Model::find_by_email(&ctx.db, ¶ms.email).await?; - - let valid = user.verify_password(¶ms.password); - - if !valid { - return unauthorized("unauthorized!"); - } - - let jwt_secret = ctx.config.get_jwt_config()?; - - let token = user - .generate_jwt(&jwt_secret.secret, &jwt_secret.expiration) - .or_else(|_| unauthorized("unauthorized!"))?; - - format::json(LoginResponse::new(&user, &token)) -} - -pub fn routes() -> Routes { - Routes::new() - .prefix("auth") - .add("/register", post(register)) - .add("/verify", post(verify)) - .add("/login", post(login)) - .add("/forgot", post(forgot)) - .add("/reset", post(reset)) -} diff --git a/examples/aws-rust-loco/src/controllers/health.rs b/examples/aws-rust-loco/src/controllers/health.rs deleted file mode 100644 index 09858ee4b0..0000000000 --- a/examples/aws-rust-loco/src/controllers/health.rs +++ /dev/null @@ -1,10 +0,0 @@ -use loco_rs::prelude::*; -use serde_json::json; - -async fn check() -> Result { - format::json(json!({ "message": "ok" })) -} - -pub fn routes() -> Routes { - Routes::new().add("/", get(check)) -} diff --git a/examples/aws-rust-loco/src/controllers/mod.rs b/examples/aws-rust-loco/src/controllers/mod.rs deleted file mode 100644 index 5cbdcb54e5..0000000000 --- a/examples/aws-rust-loco/src/controllers/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod auth; -pub mod health; -pub mod notes; -pub mod user; diff --git a/examples/aws-rust-loco/src/controllers/notes.rs b/examples/aws-rust-loco/src/controllers/notes.rs deleted file mode 100644 index f378fb4d8d..0000000000 --- a/examples/aws-rust-loco/src/controllers/notes.rs +++ /dev/null @@ -1,75 +0,0 @@ -#![allow(clippy::missing_errors_doc)] -#![allow(clippy::unnecessary_struct_initialization)] -#![allow(clippy::unused_async)] -use axum::debug_handler; -use loco_rs::prelude::*; -use serde::{Deserialize, Serialize}; - -use crate::models::_entities::notes::{ActiveModel, Entity, Model}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct Params { - pub title: Option, - pub content: Option, -} - -impl Params { - fn update(&self, item: &mut ActiveModel) { - item.title = Set(self.title.clone()); - item.content = Set(self.content.clone()); - } -} - -async fn load_item(ctx: &AppContext, id: i32) -> Result { - let item = Entity::find_by_id(id).one(&ctx.db).await?; - item.ok_or_else(|| Error::NotFound) -} - -#[debug_handler] -pub async fn list(State(ctx): State) -> Result { - format::json(Entity::find().all(&ctx.db).await?) -} - -#[debug_handler] -pub async fn add(State(ctx): State, Json(params): Json) -> Result { - let mut item = ActiveModel { - ..Default::default() - }; - params.update(&mut item); - let item = item.insert(&ctx.db).await?; - format::json(item) -} - -#[debug_handler] -pub async fn update( - Path(id): Path, - State(ctx): State, - Json(params): Json, -) -> Result { - let item = load_item(&ctx, id).await?; - let mut item = item.into_active_model(); - params.update(&mut item); - let item = item.update(&ctx.db).await?; - format::json(item) -} - -#[debug_handler] -pub async fn remove(Path(id): Path, State(ctx): State) -> Result { - load_item(&ctx, id).await?.delete(&ctx.db).await?; - format::empty() -} - -#[debug_handler] -pub async fn get_one(Path(id): Path, State(ctx): State) -> Result { - format::json(load_item(&ctx, id).await?) -} - -pub fn routes() -> Routes { - Routes::new() - .prefix("notes") - .add("/", get(list)) - .add("/", post(add)) - .add("/:id", get(get_one)) - .add("/:id", delete(remove)) - .add("/:id", post(update)) -} diff --git a/examples/aws-rust-loco/src/controllers/user.rs b/examples/aws-rust-loco/src/controllers/user.rs deleted file mode 100644 index 1f432ae9ef..0000000000 --- a/examples/aws-rust-loco/src/controllers/user.rs +++ /dev/null @@ -1,14 +0,0 @@ -use axum::debug_handler; -use loco_rs::prelude::*; - -use crate::{models::_entities::users, views::user::CurrentResponse}; - -#[debug_handler] -async fn current(auth: auth::JWT, State(ctx): State) -> Result { - let user = users::Model::find_by_pid(&ctx.db, &auth.claims.pid).await?; - format::json(CurrentResponse::new(&user)) -} - -pub fn routes() -> Routes { - Routes::new().prefix("user").add("/current", get(current)) -} diff --git a/examples/aws-rust-loco/src/fixtures/notes.yaml b/examples/aws-rust-loco/src/fixtures/notes.yaml deleted file mode 100644 index 0e66c95314..0000000000 --- a/examples/aws-rust-loco/src/fixtures/notes.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- id: 1 - title: Loco note 1 - content: Loco note 1 content - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" -- id: 2 - title: Loco note 2 - content: Loco note 2 content - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" diff --git a/examples/aws-rust-loco/src/fixtures/users.yaml b/examples/aws-rust-loco/src/fixtures/users.yaml deleted file mode 100644 index 8f5b5ed2e2..0000000000 --- a/examples/aws-rust-loco/src/fixtures/users.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- id: 1 - pid: 11111111-1111-1111-1111-111111111111 - email: user1@example.com - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc" - api_key: lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758 - name: user1 - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" -- id: 2 - pid: 22222222-2222-2222-2222-222222222222 - email: user2@example.com - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc" - api_key: lo-153561ca-fa84-4e1b-813a-c62526d0a77e - name: user2 - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" diff --git a/examples/aws-rust-loco/src/lib.rs b/examples/aws-rust-loco/src/lib.rs deleted file mode 100644 index bcd9cbed82..0000000000 --- a/examples/aws-rust-loco/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod app; -pub mod controllers; -pub mod mailers; -pub mod models; -pub mod tasks; -pub mod views; -pub mod workers; diff --git a/examples/aws-rust-loco/src/mailers/auth.rs b/examples/aws-rust-loco/src/mailers/auth.rs deleted file mode 100644 index 30bb1bf2f5..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth.rs +++ /dev/null @@ -1,65 +0,0 @@ -// auth mailer -#![allow(non_upper_case_globals)] - -use loco_rs::prelude::*; -use serde_json::json; - -use crate::models::users; - -static welcome: Dir<'_> = include_dir!("src/mailers/auth/welcome"); -static forgot: Dir<'_> = include_dir!("src/mailers/auth/forgot"); -// #[derive(Mailer)] // -- disabled for faster build speed. it works. but lets -// move on for now. - -#[allow(clippy::module_name_repetitions)] -pub struct AuthMailer {} -impl Mailer for AuthMailer {} -impl AuthMailer { - /// Sending welcome email the the given user - /// - /// # Errors - /// - /// When email sending is failed - pub async fn send_welcome(ctx: &AppContext, user: &users::Model) -> Result<()> { - Self::mail_template( - ctx, - &welcome, - mailer::Args { - to: user.email.to_string(), - locals: json!({ - "name": user.name, - "verifyToken": user.email_verification_token, - "domain": ctx.config.server.full_url() - }), - ..Default::default() - }, - ) - .await?; - - Ok(()) - } - - /// Sending forgot password email - /// - /// # Errors - /// - /// When email sending is failed - pub async fn forgot_password(ctx: &AppContext, user: &users::Model) -> Result<()> { - Self::mail_template( - ctx, - &forgot, - mailer::Args { - to: user.email.to_string(), - locals: json!({ - "name": user.name, - "resetToken": user.reset_token, - "domain": ctx.config.server.full_url() - }), - ..Default::default() - }, - ) - .await?; - - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/mailers/auth/forgot/html.t b/examples/aws-rust-loco/src/mailers/auth/forgot/html.t deleted file mode 100644 index 221dd60205..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/forgot/html.t +++ /dev/null @@ -1,11 +0,0 @@ -; - - - Hey {{name}}, - Forgot your password? No worries! You can reset it by clicking the link below: - Reset Your Password - If you didn't request a password reset, please ignore this email. - Best regards,
The Loco Team
- - - diff --git a/examples/aws-rust-loco/src/mailers/auth/forgot/subject.t b/examples/aws-rust-loco/src/mailers/auth/forgot/subject.t deleted file mode 100644 index 4938df1e30..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/forgot/subject.t +++ /dev/null @@ -1 +0,0 @@ -Your reset password link diff --git a/examples/aws-rust-loco/src/mailers/auth/forgot/text.t b/examples/aws-rust-loco/src/mailers/auth/forgot/text.t deleted file mode 100644 index 58c30fd8d1..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/forgot/text.t +++ /dev/null @@ -1,3 +0,0 @@ -Reset your password with this link: - -http://localhost/reset#{{resetToken}} diff --git a/examples/aws-rust-loco/src/mailers/auth/welcome/html.t b/examples/aws-rust-loco/src/mailers/auth/welcome/html.t deleted file mode 100644 index ae4c41c654..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/welcome/html.t +++ /dev/null @@ -1,13 +0,0 @@ -; - - - Dear {{name}}, - Welcome to Loco! You can now log in to your account. - Before you get started, please verify your account by clicking the link below: - - Verify Your Account - -

Best regards,
The Loco Team

- - - diff --git a/examples/aws-rust-loco/src/mailers/auth/welcome/subject.t b/examples/aws-rust-loco/src/mailers/auth/welcome/subject.t deleted file mode 100644 index 82cc6fbf7b..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/welcome/subject.t +++ /dev/null @@ -1 +0,0 @@ -Welcome {{name}} diff --git a/examples/aws-rust-loco/src/mailers/auth/welcome/text.t b/examples/aws-rust-loco/src/mailers/auth/welcome/text.t deleted file mode 100644 index 63beefd565..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/welcome/text.t +++ /dev/null @@ -1,4 +0,0 @@ -Welcome {{name}}, you can now log in. - Verify your account with the link below: - - http://localhost/verify#{{verifyToken}} diff --git a/examples/aws-rust-loco/src/mailers/mod.rs b/examples/aws-rust-loco/src/mailers/mod.rs deleted file mode 100644 index 0e4a05d597..0000000000 --- a/examples/aws-rust-loco/src/mailers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod auth; diff --git a/examples/aws-rust-loco/src/models/_entities/mod.rs b/examples/aws-rust-loco/src/models/_entities/mod.rs deleted file mode 100644 index c04afbb655..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -pub mod prelude; - -pub mod notes; -pub mod users; diff --git a/examples/aws-rust-loco/src/models/_entities/notes.rs b/examples/aws-rust-loco/src/models/_entities/notes.rs deleted file mode 100644 index a803353897..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/notes.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -use sea_orm::entity::prelude::*; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] -#[sea_orm(table_name = "notes")] -pub struct Model { - pub created_at: DateTimeWithTimeZone, - pub updated_at: DateTimeWithTimeZone, - #[sea_orm(primary_key)] - pub id: i32, - pub title: Option, - pub content: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} diff --git a/examples/aws-rust-loco/src/models/_entities/prelude.rs b/examples/aws-rust-loco/src/models/_entities/prelude.rs deleted file mode 100644 index 4d1101962e..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/prelude.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -pub use super::notes::Entity as Notes; -pub use super::users::Entity as Users; diff --git a/examples/aws-rust-loco/src/models/_entities/users.rs b/examples/aws-rust-loco/src/models/_entities/users.rs deleted file mode 100644 index 120b1a1b1f..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/users.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -use sea_orm::entity::prelude::*; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] -#[sea_orm(table_name = "users")] -pub struct Model { - pub created_at: DateTimeWithTimeZone, - pub updated_at: DateTimeWithTimeZone, - #[sea_orm(primary_key)] - pub id: i32, - pub pid: Uuid, - #[sea_orm(unique)] - pub email: String, - pub password: String, - #[sea_orm(unique)] - pub api_key: String, - pub name: String, - pub reset_token: Option, - pub reset_sent_at: Option, - pub email_verification_token: Option, - pub email_verification_sent_at: Option, - pub email_verified_at: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} diff --git a/examples/aws-rust-loco/src/models/mod.rs b/examples/aws-rust-loco/src/models/mod.rs deleted file mode 100644 index 917969b1c7..0000000000 --- a/examples/aws-rust-loco/src/models/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod _entities; -pub mod notes; -pub mod users; diff --git a/examples/aws-rust-loco/src/models/notes.rs b/examples/aws-rust-loco/src/models/notes.rs deleted file mode 100644 index 1102598236..0000000000 --- a/examples/aws-rust-loco/src/models/notes.rs +++ /dev/null @@ -1,7 +0,0 @@ -use sea_orm::entity::prelude::*; - -use super::_entities::notes::ActiveModel; - -impl ActiveModelBehavior for ActiveModel { - // extend activemodel below (keep comment for generators) -} diff --git a/examples/aws-rust-loco/src/models/users.rs b/examples/aws-rust-loco/src/models/users.rs deleted file mode 100644 index 510802e0bb..0000000000 --- a/examples/aws-rust-loco/src/models/users.rs +++ /dev/null @@ -1,297 +0,0 @@ -use async_trait::async_trait; -use chrono::offset::Local; -use loco_rs::{auth::jwt, hash, prelude::*}; -use serde::{Deserialize, Serialize}; -use uuid::Uuid; - -pub use super::_entities::users::{self, ActiveModel, Entity, Model}; - -#[derive(Debug, Deserialize, Serialize)] -pub struct LoginParams { - pub email: String, - pub password: String, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct RegisterParams { - pub email: String, - pub password: String, - pub name: String, -} - -#[derive(Debug, Validate, Deserialize)] -pub struct Validator { - #[validate(length(min = 2, message = "Name must be at least 2 characters long."))] - pub name: String, - #[validate(custom = "validation::is_valid_email")] - pub email: String, -} - -impl Validatable for super::_entities::users::ActiveModel { - fn validator(&self) -> Box { - Box::new(Validator { - name: self.name.as_ref().to_owned(), - email: self.email.as_ref().to_owned(), - }) - } -} - -#[async_trait::async_trait] -impl ActiveModelBehavior for super::_entities::users::ActiveModel { - async fn before_save(self, _db: &C, insert: bool) -> Result - where - C: ConnectionTrait, - { - self.validate()?; - if insert { - let mut this = self; - this.pid = ActiveValue::Set(Uuid::new_v4()); - this.api_key = ActiveValue::Set(format!("lo-{}", Uuid::new_v4())); - Ok(this) - } else { - Ok(self) - } - } -} - -#[async_trait] -impl Authenticable for super::_entities::users::Model { - async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::ApiKey, api_key) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - async fn find_by_claims_key(db: &DatabaseConnection, claims_key: &str) -> ModelResult { - Self::find_by_pid(db, claims_key).await - } -} - -impl super::_entities::users::Model { - /// finds a user by the provided email - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_email(db: &DatabaseConnection, email: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::Email, email) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// finds a user by the provided verification token - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_verification_token( - db: &DatabaseConnection, - token: &str, - ) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::EmailVerificationToken, token) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// /// finds a user by the provided reset token - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_reset_token(db: &DatabaseConnection, token: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::ResetToken, token) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// finds a user by the provided pid - /// - /// # Errors - /// - /// When could not find user or DB query error - pub async fn find_by_pid(db: &DatabaseConnection, pid: &str) -> ModelResult { - let parse_uuid = Uuid::parse_str(pid).map_err(|e| ModelError::Any(e.into()))?; - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::Pid, parse_uuid) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// finds a user by the provided api key - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::ApiKey, api_key) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// Verifies whether the provided plain password matches the hashed password - /// - /// # Errors - /// - /// when could not verify password - #[must_use] - pub fn verify_password(&self, password: &str) -> bool { - hash::verify_password(password, &self.password) - } - - /// Asynchronously creates a user with a password and saves it to the - /// database. - /// - /// # Errors - /// - /// When could not save the user into the DB - pub async fn create_with_password( - db: &DatabaseConnection, - params: &RegisterParams, - ) -> ModelResult { - let txn = db.begin().await?; - - if users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::Email, ¶ms.email) - .build(), - ) - .one(&txn) - .await? - .is_some() - { - return Err(ModelError::EntityAlreadyExists {}); - } - - let password_hash = - hash::hash_password(¶ms.password).map_err(|e| ModelError::Any(e.into()))?; - let user = users::ActiveModel { - email: ActiveValue::set(params.email.to_string()), - password: ActiveValue::set(password_hash), - name: ActiveValue::set(params.name.to_string()), - ..Default::default() - } - .insert(&txn) - .await?; - - txn.commit().await?; - - Ok(user) - } - - /// Creates a JWT - /// - /// # Errors - /// - /// when could not convert user claims to jwt token - pub fn generate_jwt(&self, secret: &str, expiration: &u64) -> ModelResult { - Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string(), None)?) - } -} - -impl super::_entities::users::ActiveModel { - /// Sets the email verification information for the user and - /// updates it in the database. - /// - /// This method is used to record the timestamp when the email verification - /// was sent and generate a unique verification token for the user. - /// - /// # Errors - /// - /// when has DB query error - pub async fn set_email_verification_sent( - mut self, - db: &DatabaseConnection, - ) -> ModelResult { - self.email_verification_sent_at = ActiveValue::set(Some(Local::now().into())); - self.email_verification_token = ActiveValue::Set(Some(Uuid::new_v4().to_string())); - Ok(self.update(db).await?) - } - - /// Sets the information for a reset password request, - /// generates a unique reset password token, and updates it in the - /// database. - /// - /// This method records the timestamp when the reset password token is sent - /// and generates a unique token for the user. - /// - /// # Arguments - /// - /// # Errors - /// - /// when has DB query error - pub async fn set_forgot_password_sent(mut self, db: &DatabaseConnection) -> ModelResult { - self.reset_sent_at = ActiveValue::set(Some(Local::now().into())); - self.reset_token = ActiveValue::Set(Some(Uuid::new_v4().to_string())); - Ok(self.update(db).await?) - } - - /// Records the verification time when a user verifies their - /// email and updates it in the database. - /// - /// This method sets the timestamp when the user successfully verifies their - /// email. - /// - /// # Errors - /// - /// when has DB query error - pub async fn verified(mut self, db: &DatabaseConnection) -> ModelResult { - self.email_verified_at = ActiveValue::set(Some(Local::now().into())); - Ok(self.update(db).await?) - } - - /// Resets the current user password with a new password and - /// updates it in the database. - /// - /// This method hashes the provided password and sets it as the new password - /// for the user. - /// # Errors - /// - /// when has DB query error or could not hashed the given password - pub async fn reset_password( - mut self, - db: &DatabaseConnection, - password: &str, - ) -> ModelResult { - self.password = - ActiveValue::set(hash::hash_password(password).map_err(|e| ModelError::Any(e.into()))?); - self.reset_token = ActiveValue::Set(None); - self.reset_sent_at = ActiveValue::Set(None); - Ok(self.update(db).await?) - } -} diff --git a/examples/aws-rust-loco/src/tasks/mod.rs b/examples/aws-rust-loco/src/tasks/mod.rs deleted file mode 100644 index 01fbddaa29..0000000000 --- a/examples/aws-rust-loco/src/tasks/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod seed; diff --git a/examples/aws-rust-loco/src/tasks/seed.rs b/examples/aws-rust-loco/src/tasks/seed.rs deleted file mode 100644 index 1647beb84c..0000000000 --- a/examples/aws-rust-loco/src/tasks/seed.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This task implements data seeding functionality for initializing new -//! development/demo environments. -//! -//! # Example -//! -//! Run the task with the following command: -//! ```sh -//! cargo run task -//! ``` -//! -//! To override existing data and reset the data structure, use the following -//! command with the `refresh:true` argument: -//! ```sh -//! cargo run task seed_data refresh:true -//! ``` - -use loco_rs::{db, prelude::*}; -use migration::Migrator; - -use crate::app::App; - -#[allow(clippy::module_name_repetitions)] -pub struct SeedData; -#[async_trait] -impl Task for SeedData { - fn task(&self) -> TaskInfo { - TaskInfo { - name: "seed_data".to_string(), - detail: "Task for seeding data".to_string(), - } - } - - async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> { - let refresh = vars - .cli_arg("refresh") - .is_ok_and(|refresh| refresh == "true"); - - if refresh { - db::reset::(&app_context.db).await?; - } - let path = std::path::Path::new("src/fixtures"); - db::run_app_seed::(&app_context.db, path).await?; - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/views/auth.rs b/examples/aws-rust-loco/src/views/auth.rs deleted file mode 100644 index 2240a5087e..0000000000 --- a/examples/aws-rust-loco/src/views/auth.rs +++ /dev/null @@ -1,23 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::models::_entities::users; - -#[derive(Debug, Deserialize, Serialize)] -pub struct LoginResponse { - pub token: String, - pub pid: String, - pub name: String, - pub is_verified: bool, -} - -impl LoginResponse { - #[must_use] - pub fn new(user: &users::Model, token: &String) -> Self { - Self { - token: token.to_string(), - pid: user.pid.to_string(), - name: user.name.clone(), - is_verified: user.email_verified_at.is_some(), - } - } -} diff --git a/examples/aws-rust-loco/src/views/mod.rs b/examples/aws-rust-loco/src/views/mod.rs deleted file mode 100644 index f9bae3db2a..0000000000 --- a/examples/aws-rust-loco/src/views/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod auth; -pub mod user; diff --git a/examples/aws-rust-loco/src/views/user.rs b/examples/aws-rust-loco/src/views/user.rs deleted file mode 100644 index 9d830410fb..0000000000 --- a/examples/aws-rust-loco/src/views/user.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::models::_entities::users; - -#[derive(Debug, Deserialize, Serialize)] -pub struct CurrentResponse { - pub pid: String, - pub name: String, - pub email: String, -} - -impl CurrentResponse { - #[must_use] - pub fn new(user: &users::Model) -> Self { - Self { - pid: user.pid.to_string(), - name: user.name.clone(), - email: user.email.clone(), - } - } -} diff --git a/examples/aws-rust-loco/src/workers/downloader.rs b/examples/aws-rust-loco/src/workers/downloader.rs deleted file mode 100644 index 42c0bd7a46..0000000000 --- a/examples/aws-rust-loco/src/workers/downloader.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::time::Duration; - -use loco_rs::prelude::*; -use serde::{Deserialize, Serialize}; -use tokio::time::sleep; - -use crate::models::users; - -pub struct DownloadWorker { - pub ctx: AppContext, -} - -#[derive(Deserialize, Debug, Serialize)] -pub struct DownloadWorkerArgs { - pub user_guid: String, -} - -impl worker::AppWorker for DownloadWorker { - fn build(ctx: &AppContext) -> Self { - Self { ctx: ctx.clone() } - } -} - -#[async_trait] -impl worker::Worker for DownloadWorker { - async fn perform(&self, args: DownloadWorkerArgs) -> worker::Result<()> { - // TODO: Some actual work goes here... - println!("================================================"); - println!("Sending payment report to user {}", args.user_guid); - - sleep(Duration::from_millis(2000)).await; - - let all = users::Entity::find() - .all(&self.ctx.db) - .await - .map_err(Box::from)?; - for user in &all { - println!("user: {}", user.id); - } - println!("================================================"); - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/workers/mod.rs b/examples/aws-rust-loco/src/workers/mod.rs deleted file mode 100644 index acb5733da2..0000000000 --- a/examples/aws-rust-loco/src/workers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod downloader; diff --git a/examples/aws-rust-loco/sst.config.ts b/examples/aws-rust-loco/sst.config.ts deleted file mode 100644 index bc9a6289d8..0000000000 --- a/examples/aws-rust-loco/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## Rust Loco - * - * Deploy a Rust Loco app with a Postgres database, Redis, and a background worker - * service. - */ -export default $config({ - app(input) { - return { - name: "aws-rust-loco", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("LocoVpc", { - bastion: true, - }); - - const database = new sst.aws.Postgres("LocoDatabase", { vpc }); - - const redis = new sst.aws.Redis("LocoRedis", { vpc }); - - const DATABASE_URL = $interpolate`postgres://${ - database.username - }:${database.password.apply(encodeURIComponent)}@${database.host}:${ - database.port - }/${database.database}`; - const REDIS_URL = $interpolate`redis://${ - redis.username - }:${redis.password.apply(encodeURIComponent)}@${redis.host}:${redis.port}`; - - const locoCluster = new sst.aws.Cluster("LocoCluster", { vpc }); - - // external facing http service - const locoServer = new sst.aws.Service("LocoApp", { - cluster: locoCluster, - architecture: "x86_64", - scaling: { min: 2, max: 4 }, - command: ["start"], - loadBalancer: { - ports: [{ listen: "80/http", forward: "5150/http" }], - }, - environment: { - DATABASE_URL, - REDIS_URL, - }, - link: [database, redis], - dev: { - command: "cargo loco start", - }, - }); - - // add a worker that uses redis to process jobs off a queue - new sst.aws.Service("LocoWorker", { - cluster: locoCluster, - architecture: "x86_64", - command: ["start", "--worker"], - environment: { - DATABASE_URL, - REDIS_URL, - }, - link: [database, redis], - }); - }, -}); diff --git a/examples/aws-rust-loco/tests/mod.rs b/examples/aws-rust-loco/tests/mod.rs deleted file mode 100644 index e56e882575..0000000000 --- a/examples/aws-rust-loco/tests/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod models; -mod requests; -mod tasks; diff --git a/examples/aws-rust-loco/tests/models/mod.rs b/examples/aws-rust-loco/tests/models/mod.rs deleted file mode 100644 index 59759880db..0000000000 --- a/examples/aws-rust-loco/tests/models/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod users; diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_create_with_password@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_create_with_password@users.snap deleted file mode 100644 index 6e66fd35ae..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_create_with_password@users.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tests/models/users.rs -expression: res ---- -Ok( - Model { - created_at: DATE, - updated_at: DATE, - id: ID - pid: PID, - email: "test@framework.com", - password: "PASSWORD", - api_key: "lo-PID", - name: "framework", - reset_token: None, - reset_sent_at: None, - email_verification_token: None, - email_verification_sent_at: None, - email_verified_at: None, - }, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email-2@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email-2@users.snap deleted file mode 100644 index 83dc06e1d9..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email-2@users.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/main.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users-2.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users-2.snap deleted file mode 100644 index 25c700a5a8..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users-2.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/users.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users.snap deleted file mode 100644 index 067d0e7521..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tests/models/users.rs -expression: existing_user ---- -Ok( - Model { - created_at: 2023-11-12T12:34:56.789+00:00, - updated_at: 2023-11-12T12:34:56.789+00:00, - id: 1, - pid: 11111111-1111-1111-1111-111111111111, - email: "user1@example.com", - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc", - api_key: "lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758", - name: "user1", - reset_token: None, - reset_sent_at: None, - email_verification_token: None, - email_verification_sent_at: None, - email_verified_at: None, - }, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid-2@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid-2@users.snap deleted file mode 100644 index 83dc06e1d9..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid-2@users.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/main.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users-2.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users-2.snap deleted file mode 100644 index 25c700a5a8..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users-2.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/users.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users.snap deleted file mode 100644 index 067d0e7521..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tests/models/users.rs -expression: existing_user ---- -Ok( - Model { - created_at: 2023-11-12T12:34:56.789+00:00, - updated_at: 2023-11-12T12:34:56.789+00:00, - id: 1, - pid: 11111111-1111-1111-1111-111111111111, - email: "user1@example.com", - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc", - api_key: "lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758", - name: "user1", - reset_token: None, - reset_sent_at: None, - email_verification_token: None, - email_verification_sent_at: None, - email_verified_at: None, - }, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_validate_model@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_validate_model@users.snap deleted file mode 100644 index 4d457a7032..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_validate_model@users.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: tests/models/main.rs -expression: res ---- -Err( - Custom( - "{\"email\":[{\"code\":\"invalid email\",\"message\":null}],\"name\":[{\"code\":\"length\",\"message\":\"Name must be at least 2 characters long.\"}]}", - ), -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/handle_create_with_password_with_duplicate@users.snap b/examples/aws-rust-loco/tests/models/snapshots/handle_create_with_password_with_duplicate@users.snap deleted file mode 100644 index ff28ea196a..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/handle_create_with_password_with_duplicate@users.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/users.rs -expression: new_user ---- -Err( - EntityAlreadyExists, -) diff --git a/examples/aws-rust-loco/tests/models/users.rs b/examples/aws-rust-loco/tests/models/users.rs deleted file mode 100644 index f57a32213e..0000000000 --- a/examples/aws-rust-loco/tests/models/users.rs +++ /dev/null @@ -1,223 +0,0 @@ -use insta::assert_debug_snapshot; -use loco_rs::{model::ModelError, testing}; -use server::{ - app::App, - models::users::{self, Model, RegisterParams}, -}; -use sea_orm::{ActiveModelTrait, ActiveValue, IntoActiveModel}; -use serial_test::serial; - -macro_rules! configure_insta { - ($($expr:expr),*) => { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("users"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn test_can_validate_model() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - - let res = users::ActiveModel { - name: ActiveValue::set("1".to_string()), - email: ActiveValue::set("invalid-email".to_string()), - ..Default::default() - } - .insert(&boot.app_context.db) - .await; - - assert_debug_snapshot!(res); -} - -#[tokio::test] -#[serial] -async fn can_create_with_password() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - - let params = RegisterParams { - email: "test@framework.com".to_string(), - password: "1234".to_string(), - name: "framework".to_string(), - }; - let res = Model::create_with_password(&boot.app_context.db, ¶ms).await; - - insta::with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!(res); - }); -} - -#[tokio::test] -#[serial] -async fn handle_create_with_password_with_duplicate() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let new_user: Result = Model::create_with_password( - &boot.app_context.db, - &RegisterParams { - email: "user1@example.com".to_string(), - password: "1234".to_string(), - name: "framework".to_string(), - }, - ) - .await; - assert_debug_snapshot!(new_user); -} - -#[tokio::test] -#[serial] -async fn can_find_by_email() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let existing_user = Model::find_by_email(&boot.app_context.db, "user1@example.com").await; - let non_existing_user_results = - Model::find_by_email(&boot.app_context.db, "un@existing-email.com").await; - - assert_debug_snapshot!(existing_user); - assert_debug_snapshot!(non_existing_user_results); -} - -#[tokio::test] -#[serial] -async fn can_find_by_pid() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let existing_user = - Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111").await; - let non_existing_user_results = - Model::find_by_pid(&boot.app_context.db, "23232323-2323-2323-2323-232323232323").await; - - assert_debug_snapshot!(existing_user); - assert_debug_snapshot!(non_existing_user_results); -} - -#[tokio::test] -#[serial] -async fn can_verification_token() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verification_sent_at.is_none()); - assert!(user.email_verification_token.is_none()); - - assert!(user - .into_active_model() - .set_email_verification_sent(&boot.app_context.db) - .await - .is_ok()); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verification_sent_at.is_some()); - assert!(user.email_verification_token.is_some()); -} - -#[tokio::test] -#[serial] -async fn can_set_forgot_password_sent() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.reset_sent_at.is_none()); - assert!(user.reset_token.is_none()); - - assert!(user - .into_active_model() - .set_forgot_password_sent(&boot.app_context.db) - .await - .is_ok()); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.reset_sent_at.is_some()); - assert!(user.reset_token.is_some()); -} - -#[tokio::test] -#[serial] -async fn can_verified() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verified_at.is_none()); - - assert!(user - .into_active_model() - .verified(&boot.app_context.db) - .await - .is_ok()); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verified_at.is_some()); -} - -#[tokio::test] -#[serial] -async fn can_reset_password() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.verify_password("12341234")); - - assert!(user - .clone() - .into_active_model() - .reset_password(&boot.app_context.db, "new-password") - .await - .is_ok()); - - assert!( - Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap() - .verify_password("new-password") - ); -} diff --git a/examples/aws-rust-loco/tests/requests/auth.rs b/examples/aws-rust-loco/tests/requests/auth.rs deleted file mode 100644 index 43352ed1c7..0000000000 --- a/examples/aws-rust-loco/tests/requests/auth.rs +++ /dev/null @@ -1,195 +0,0 @@ -use insta::{assert_debug_snapshot, with_settings}; -use loco_rs::testing; -use server::{app::App, models::users}; -use rstest::rstest; -use serial_test::serial; - -use super::prepare_data; - -// TODO: see how to dedup / extract this to app-local test utils -// not to framework, because that would require a runtime dep on insta -macro_rules! configure_insta { - ($($expr:expr),*) => { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("auth_request"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn can_register() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let email = "test@loco.com"; - let payload = serde_json::json!({ - "name": "loco", - "email": email, - "password": "12341234" - }); - - let _response = request.post("/api/auth/register").json(&payload).await; - let saved_user = users::Model::find_by_email(&ctx.db, email).await; - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!(saved_user); - }); - - with_settings!({ - filters => testing::cleanup_email() - }, { - assert_debug_snapshot!(ctx.mailer.unwrap().deliveries()); - }); - }) - .await; -} - -#[rstest] -#[case("login_with_valid_password", "12341234")] -#[case("login_with_invalid_password", "invalid-password")] -#[tokio::test] -#[serial] -async fn can_login_with_verify(#[case] test_name: &str, #[case] password: &str) { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let email = "test@loco.com"; - let register_payload = serde_json::json!({ - "name": "loco", - "email": email, - "password": "12341234" - }); - - //Creating a new user - _ = request - .post("/api/auth/register") - .json(®ister_payload) - .await; - - let user = users::Model::find_by_email(&ctx.db, email).await.unwrap(); - let verify_payload = serde_json::json!({ - "token": user.email_verification_token, - }); - request.post("/api/auth/verify").json(&verify_payload).await; - - //verify user request - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": email, - "password": password - })) - .await; - - // Make sure email_verified_at is set - assert!(users::Model::find_by_email(&ctx.db, email) - .await - .unwrap() - .email_verified_at - .is_some()); - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!(test_name, (response.status_code(), response.text())); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_login_without_verify() { - configure_insta!(); - - testing::request::(|request, _ctx| async move { - let email = "test@loco.com"; - let password = "12341234"; - let register_payload = serde_json::json!({ - "name": "loco", - "email": email, - "password": password - }); - - //Creating a new user - _ = request - .post("/api/auth/register") - .json(®ister_payload) - .await; - - //verify user request - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": email, - "password": password - })) - .await; - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!((response.status_code(), response.text())); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_reset_password() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let login_data = prepare_data::init_user_login(&request, &ctx).await; - - let forgot_payload = serde_json::json!({ - "email": login_data.user.email, - }); - _ = request.post("/api/auth/forgot").json(&forgot_payload).await; - - let user = users::Model::find_by_email(&ctx.db, &login_data.user.email) - .await - .unwrap(); - assert!(user.reset_token.is_some()); - assert!(user.reset_sent_at.is_some()); - - let new_password = "new-password"; - let reset_payload = serde_json::json!({ - "token": user.reset_token, - "password": new_password, - }); - - let reset_response = request.post("/api/auth/reset").json(&reset_payload).await; - - let user = users::Model::find_by_email(&ctx.db, &user.email) - .await - .unwrap(); - - assert!(user.reset_token.is_none()); - assert!(user.reset_sent_at.is_none()); - - assert_debug_snapshot!((reset_response.status_code(), reset_response.text())); - - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": user.email, - "password": new_password - })) - .await; - - assert_eq!(response.status_code(), 200); - - with_settings!({ - filters => testing::cleanup_email() - }, { - assert_debug_snapshot!(ctx.mailer.unwrap().deliveries()); - }); - }) - .await; -} diff --git a/examples/aws-rust-loco/tests/requests/mod.rs b/examples/aws-rust-loco/tests/requests/mod.rs deleted file mode 100644 index 81ed68f960..0000000000 --- a/examples/aws-rust-loco/tests/requests/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod auth; -mod notes; -mod prepare_data; -mod user; diff --git a/examples/aws-rust-loco/tests/requests/notes.rs b/examples/aws-rust-loco/tests/requests/notes.rs deleted file mode 100644 index 4709cf6f47..0000000000 --- a/examples/aws-rust-loco/tests/requests/notes.rs +++ /dev/null @@ -1,123 +0,0 @@ -use insta::{assert_debug_snapshot, with_settings}; -use loco_rs::testing; -use server::{app::App, models::_entities::notes::Entity}; -use sea_orm::entity::prelude::*; -use serial_test::serial; - -// TODO: see how to dedup / extract this to app-local test utils -// not to framework, because that would require a runtime dep on insta -macro_rules! configure_insta { - ($($expr:expr),*) => { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("notes_request"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn can_get_notes() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - testing::seed::(&ctx.db).await.unwrap(); - - let notes = request.get("/api/notes").await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (notes.status_code(), notes.text()) - ); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_add_note() { - configure_insta!(); - - testing::request::(|request, _ctx| async move { - let payload = serde_json::json!({ - "title": "loco", - "content": "loco note test", - }); - - let add_note_request = request.post("/api/notes").json(&payload).await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (add_note_request.status_code(), add_note_request.text()) - ); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_get_note() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - testing::seed::(&ctx.db).await.unwrap(); - - let add_note_request = request.get("/api/notes/1").await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (add_note_request.status_code(), add_note_request.text()) - ); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_delete_note() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - testing::seed::(&ctx.db).await.unwrap(); - - let count_before_delete = Entity::find().all(&ctx.db).await.unwrap().len(); - let delete_note_request = request.delete("/api/notes/1").await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (delete_note_request.status_code(), delete_note_request.text()) - ); - }); - - let count_after_delete = Entity::find().all(&ctx.db).await.unwrap().len(); - assert_eq!(count_after_delete, count_before_delete - 1); - }) - .await; -} diff --git a/examples/aws-rust-loco/tests/requests/prepare_data.rs b/examples/aws-rust-loco/tests/requests/prepare_data.rs deleted file mode 100644 index 13f9940a7a..0000000000 --- a/examples/aws-rust-loco/tests/requests/prepare_data.rs +++ /dev/null @@ -1,57 +0,0 @@ -use axum::http::{HeaderName, HeaderValue}; -use loco_rs::{app::AppContext, TestServer}; -use server::{models::users, views::auth::LoginResponse}; - -const USER_EMAIL: &str = "test@loco.com"; -const USER_PASSWORD: &str = "1234"; - -pub struct LoggedInUser { - pub user: users::Model, - pub token: String, -} - -pub async fn init_user_login(request: &TestServer, ctx: &AppContext) -> LoggedInUser { - let register_payload = serde_json::json!({ - "name": "loco", - "email": USER_EMAIL, - "password": USER_PASSWORD - }); - - //Creating a new user - request - .post("/api/auth/register") - .json(®ister_payload) - .await; - let user = users::Model::find_by_email(&ctx.db, USER_EMAIL) - .await - .unwrap(); - - let verify_payload = serde_json::json!({ - "token": user.email_verification_token, - }); - - request.post("/api/auth/verify").json(&verify_payload).await; - - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": USER_EMAIL, - "password": USER_PASSWORD - })) - .await; - - let login_response: LoginResponse = serde_json::from_str(&response.text()).unwrap(); - - LoggedInUser { - user: users::Model::find_by_email(&ctx.db, USER_EMAIL) - .await - .unwrap(), - token: login_response.token, - } -} - -pub fn auth_header(token: &str) -> (HeaderName, HeaderValue) { - let auth_header_value = HeaderValue::from_str(&format!("Bearer {}", &token)).unwrap(); - - (HeaderName::from_static("authorization"), auth_header_value) -} diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_add_note@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_add_note@notes_request.snap deleted file mode 100644 index f8457d7a47..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_add_note@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(add_note_request.status_code(), add_note_request.text())" ---- -( - 200, - "{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"loco\",\"content\":\"loco note test\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_delete_note@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_delete_note@notes_request.snap deleted file mode 100644 index 3481fc36d8..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_delete_note@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(delete_note_request.status_code(), delete_note_request.text())" ---- -( - 200, - "", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user@user_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user@user_request.snap deleted file mode 100644 index 85d53db17c..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user@user_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/user.rs -expression: "(response.status_code(), response.text())" ---- -( - 200, - "{\"pid\":\"PID\",\"name\":\"loco\",\"email\":\"test@loco.com\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user_with_api_key@user_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user_with_api_key@user_request.snap deleted file mode 100644 index 85d53db17c..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user_with_api_key@user_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/user.rs -expression: "(response.status_code(), response.text())" ---- -( - 200, - "{\"pid\":\"PID\",\"name\":\"loco\",\"email\":\"test@loco.com\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_note@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_note@notes_request.snap deleted file mode 100644 index 8af1604c96..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_note@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(add_note_request.status_code(), add_note_request.text())" ---- -( - 200, - "{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"Loco note 1\",\"content\":\"Loco note 1 content\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_notes@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_notes@notes_request.snap deleted file mode 100644 index 014b75c03d..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_notes@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(notes.status_code(), notes.text())" ---- -( - 200, - "[{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"Loco note 1\",\"content\":\"Loco note 1 content\"},{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"Loco note 2\",\"content\":\"Loco note 2 content\"}]", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_login_without_verify@auth_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_login_without_verify@auth_request.snap deleted file mode 100644 index ef54ba6711..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_login_without_verify@auth_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/auth.rs -expression: "(response.status_code(), response.text())" ---- -( - 200, - "{\"token\":\"TOKEN\",\"pid\":\"PID\",\"name\":\"loco\",\"is_verified\":false}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_register@auth_request-2.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_register@auth_request-2.snap deleted file mode 100644 index 45c63cb14c..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_register@auth_request-2.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: tests/requests/auth.rs -expression: ctx.mailer.unwrap().deliveries() ---- -Deliveries { - count: 1, - messages: [ - "From: System \r\nTo: test@loco.com\r\nSubject: Welcome =?utf-8?b?bG9jbwo=?=\r\nMIME-Version: 1.0\r\nDate: DATE\r\nContent-Type: multipart/alternative;\r\n boundary=\"IDENTIFIER\"\r\n\r\n--IDENTIFIER\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nWelcome loco, you can now log in.\r\n Verify your account with the link below:\r\n\r\n http://localhost/verify#RANDOM_ID\r\n\r\n--IDENTIFIER\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n;\r\n\r\n\r\n Dear loco,\r\n Welcome to Loco! You can now log in to your account.\r\n Before you get started, please verify your account by clicking the link b=\r\nelow:\r\n \r\nTo: test@loco.com\r\nSubject: Welcome =?utf-8?b?bG9jbwo=?=\r\nMIME-Version: 1.0\r\nDate: DATE\r\nContent-Type: multipart/alternative;\r\n boundary=\"IDENTIFIER\"\r\n\r\n--IDENTIFIER\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nWelcome loco, you can now log in.\r\n Verify your account with the link below:\r\n\r\n http://localhost/verify#RANDOM_ID\r\n\r\n--IDENTIFIER\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n;\r\n\r\n\r\n Dear loco,\r\n Welcome to Loco! You can now log in to your account.\r\n Before you get started, please verify your account by clicking the link b=\r\nelow:\r\n \r\nTo: test@loco.com\r\nSubject: Your reset password =?utf-8?b?bGluawo=?=\r\nMIME-Version: 1.0\r\nDate: DATE\r\nContent-Type: multipart/alternative;\r\n boundary=\"IDENTIFIER\"\r\n\r\n--IDENTIFIER\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nReset your password with this link:\r\n\r\nhttp://localhost/reset#RANDOM_ID\r\n\r\n--IDENTIFIER\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n;\r\n\r\n\r\n Hey loco,\r\n Forgot your password? No worries! You can reset it by clicking the link b=\r\nelow:\r\n { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("user_request"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn can_get_current_user() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let user = prepare_data::init_user_login(&request, &ctx).await; - - let (auth_key, auth_value) = prepare_data::auth_header(&user.token); - let response = request - .get("/api/user/current") - .add_header(auth_key, auth_value) - .await; - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!((response.status_code(), response.text())); - }); - }) - .await; -} diff --git a/examples/aws-rust-loco/tests/tasks/mod.rs b/examples/aws-rust-loco/tests/tasks/mod.rs deleted file mode 100644 index 01fbddaa29..0000000000 --- a/examples/aws-rust-loco/tests/tasks/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod seed; diff --git a/examples/aws-rust-loco/tests/tasks/seed.rs b/examples/aws-rust-loco/tests/tasks/seed.rs deleted file mode 100644 index 444c53b697..0000000000 --- a/examples/aws-rust-loco/tests/tasks/seed.rs +++ /dev/null @@ -1,17 +0,0 @@ -use loco_rs::{boot::run_task, task, testing}; -use server::app::App; -use serial_test::serial; - -#[tokio::test] -#[serial] -async fn test_can_seed_data() { - let boot = testing::boot_test::().await.unwrap(); - - assert!(run_task::( - &boot.app_context, - Some(&"seed_data".to_string()), - &task::Vars::default() - ) - .await - .is_ok()); -} diff --git a/examples/aws-service-discovery/.dockerignore b/examples/aws-service-discovery/.dockerignore deleted file mode 100644 index 52467addcf..0000000000 --- a/examples/aws-service-discovery/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules - -# sst -.sst diff --git a/examples/aws-service-discovery/.gitignore b/examples/aws-service-discovery/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-service-discovery/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-service-discovery/Dockerfile b/examples/aws-service-discovery/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-service-discovery/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-service-discovery/index.mjs b/examples/aws-service-discovery/index.mjs deleted file mode 100644 index 4bedf3130f..0000000000 --- a/examples/aws-service-discovery/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", (_req, res) => { - res.send(`Hello from http://localhost:${PORT}`) -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-service-discovery/lambda.ts b/examples/aws-service-discovery/lambda.ts deleted file mode 100644 index f7a871f838..0000000000 --- a/examples/aws-service-discovery/lambda.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Resource } from "sst"; - -export async function handler() { - const response = await fetch( - `http://${Resource.MyService.service}` - ); - - return { - statusCode: 200, - body: await response.text(), - }; -} diff --git a/examples/aws-service-discovery/package.json b/examples/aws-service-discovery/package.json deleted file mode 100644 index 078810d63a..0000000000 --- a/examples/aws-service-discovery/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-service-discovery", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.21.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-service-discovery/sst.config.ts b/examples/aws-service-discovery/sst.config.ts deleted file mode 100644 index 8e2fc28f1a..0000000000 --- a/examples/aws-service-discovery/sst.config.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// - -/** - * ## AWS Cluster Service Discovery - * - * In this example, we are connecting to a service running on a cluster using its AWS Cloud - * Map service host name. This is useful for service discovery. - * - * We are deploying a service to a cluster in a VPC. And we can access it within the VPC using - * the service's cloud map hostname. - * - * ```ts title="lambda.ts" - * const response = await fetch(`http://${Resource.MyService.service}`); - * ``` - * - * Here we are accessing it through a Lambda function that's linked to the service and is - * deployed to the same VPC. - */ -export default $config({ - app(input) { - return { - name: "aws-service-discovery", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = new sst.aws.Service("MyService", { cluster }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [service], - handler: "lambda.handler", - }); - }, -}); diff --git a/examples/aws-service-discovery/tsconfig.json b/examples/aws-service-discovery/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-service-discovery/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-service-transform-container/.dockerignore b/examples/aws-service-transform-container/.dockerignore deleted file mode 100644 index 52467addcf..0000000000 --- a/examples/aws-service-transform-container/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules - -# sst -.sst diff --git a/examples/aws-service-transform-container/.gitignore b/examples/aws-service-transform-container/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-service-transform-container/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-service-transform-container/Dockerfile b/examples/aws-service-transform-container/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-service-transform-container/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-service-transform-container/index.mjs b/examples/aws-service-transform-container/index.mjs deleted file mode 100644 index 4bedf3130f..0000000000 --- a/examples/aws-service-transform-container/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", (_req, res) => { - res.send(`Hello from http://localhost:${PORT}`) -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-service-transform-container/package.json b/examples/aws-service-transform-container/package.json deleted file mode 100644 index 7dad309412..0000000000 --- a/examples/aws-service-transform-container/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-service-transform-container", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-service-transform-container/sst.config.ts b/examples/aws-service-transform-container/sst.config.ts deleted file mode 100644 index 6b64bedb9c..0000000000 --- a/examples/aws-service-transform-container/sst.config.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-service-transform-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - transform: { - taskDefinition: (args) => { - // "containerDefinitions" is a JSON string, parse first - let value = $jsonParse(args.containerDefinitions); - - // Update "portMappings" - value = value.apply((containerDefinitions) => { - containerDefinitions[0].portMappings = [ - { - containerPort: 80, - protocol: "tcp", - }, - ]; - return containerDefinitions; - }); - - // Convert back to JSON string - args.containerDefinitions = $jsonStringify(value); - }, - }, - }); - }, -}); diff --git a/examples/aws-service-transform-container/tsconfig.json b/examples/aws-service-transform-container/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-service-transform-container/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-shared-alb-static/api/.dockerignore b/examples/aws-shared-alb-static/api/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb-static/api/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb-static/api/Dockerfile b/examples/aws-shared-alb-static/api/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb-static/api/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb-static/api/index.mjs b/examples/aws-shared-alb-static/api/index.mjs deleted file mode 100644 index 68f1eb62b0..0000000000 --- a/examples/aws-shared-alb-static/api/index.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/api", (req, res) => { - res.json({ service: "api", message: "Hello from the API service" }); -}); - -app.get("/api/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/api/greeting", (req, res) => { - res.json({ service: "api", message: "Hello from the API service" }); -}); - -app.get("/api/*", (req, res) => { - res.json({ service: "api", path: req.path }); -}); - -app.listen(PORT, () => { - console.log(`API service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb-static/api/package.json b/examples/aws-shared-alb-static/api/package.json deleted file mode 100644 index bf11689dd1..0000000000 --- a/examples/aws-shared-alb-static/api/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "api", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-shared-alb-static/package.json b/examples/aws-shared-alb-static/package.json deleted file mode 100644 index 138aaa3168..0000000000 --- a/examples/aws-shared-alb-static/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-shared-alb-static", - "version": "1.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-shared-alb-static/sst.config.ts b/examples/aws-shared-alb-static/sst.config.ts deleted file mode 100644 index 87fd8c4550..0000000000 --- a/examples/aws-shared-alb-static/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS Shared ALB - * - * Creates a standalone ALB that is shared across stages. In dev, the ALB is - * referenced via `Alb.get()`. In production, it's created fresh. - * - * Uses the `$dev ? get : new` pattern to share infrastructure across stages. - */ -export default $config({ - app(input) { - return { - name: "aws-shared-alb", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { - region: "us-east-1", - }, - }, - }; - }, - async run() { - const vpc = $dev - ? sst.aws.Vpc.get("MyVpc", "vpc-xxx") - : new sst.aws.Vpc("MyVpc"); - - const cluster = $dev - ? sst.aws.Cluster.get("MyCluster", { id: "cluster-xxx", vpc }) - : new sst.aws.Cluster("MyCluster", { vpc }); - - const alb = $dev - ? sst.aws.Alb.get("SharedAlb", "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/xxx") - : new sst.aws.Alb("SharedAlb", { - vpc, - listeners: [ - { port: 80, protocol: "http" }, - ], - }); - - if ($dev) { - new sst.aws.Service("Web", { - cluster, - image: { context: "web/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/app/*" }, - priority: 200, - }, - ], - }, - }); - } - - new sst.aws.Service("Api", { - cluster, - image: { context: "api/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/api/*" }, - priority: 100, - }, - ], - }, - }); - - return { - url: alb.url, - }; - }, -}); diff --git a/examples/aws-shared-alb-static/web/.dockerignore b/examples/aws-shared-alb-static/web/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb-static/web/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb-static/web/Dockerfile b/examples/aws-shared-alb-static/web/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb-static/web/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb-static/web/index.mjs b/examples/aws-shared-alb-static/web/index.mjs deleted file mode 100644 index 0d64a1452d..0000000000 --- a/examples/aws-shared-alb-static/web/index.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/app", (req, res) => { - res.send("

Web App

Hello from the Web service

"); -}); - -app.get("/app/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/app/greeting", (req, res) => { - res.send("

Web App

Hello from the Web service

"); -}); - -app.get("/app/*", (req, res) => { - res.send(`

Web App

Path: ${req.path}

`); -}); - -app.listen(PORT, () => { - console.log(`Web service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb-static/web/package.json b/examples/aws-shared-alb-static/web/package.json deleted file mode 100644 index 9c43fe9bb1..0000000000 --- a/examples/aws-shared-alb-static/web/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "web", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-shared-alb/api/.dockerignore b/examples/aws-shared-alb/api/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb/api/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb/api/Dockerfile b/examples/aws-shared-alb/api/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb/api/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb/api/index.mjs b/examples/aws-shared-alb/api/index.mjs deleted file mode 100644 index d229500c93..0000000000 --- a/examples/aws-shared-alb/api/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/api", (req, res) => { - res.json({ service: "api", message: "Hello from the API service" }); -}); - -app.get("/api/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/api/*", (req, res) => { - res.json({ service: "api", path: req.path }); -}); - -app.listen(PORT, () => { - console.log(`API service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb/api/package.json b/examples/aws-shared-alb/api/package.json deleted file mode 100644 index bf11689dd1..0000000000 --- a/examples/aws-shared-alb/api/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "api", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-shared-alb/package.json b/examples/aws-shared-alb/package.json deleted file mode 100644 index 0f75962a1a..0000000000 --- a/examples/aws-shared-alb/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-shared-alb", - "version": "1.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-shared-alb/sst.config.ts b/examples/aws-shared-alb/sst.config.ts deleted file mode 100644 index 34f2c072f1..0000000000 --- a/examples/aws-shared-alb/sst.config.ts +++ /dev/null @@ -1,124 +0,0 @@ -/// - -/** - * ## AWS Shared ALB - * - * Creates a standalone ALB shared across multiple services. - * Shows advanced routing with path conditions, header conditions, and health checks. - * - * ```ts title="sst.config.ts" - * const alb = new sst.aws.Alb("SharedAlb", { - * vpc, - * listeners: [ - * { port: 80, protocol: "http" }, - * ], - * }); - * ``` - * - * Services can use header-based routing in addition to path-based: - * - * ```ts title="sst.config.ts" - * new sst.aws.Service("InternalApi", { - * cluster, - * image: { context: "api/" }, - * loadBalancer: { - * instance: alb, - * rules: [ - * { - * listen: "80/http", - * forward: "3000/http", - * conditions: { - * path: "/api/*", - * header: { name: "x-internal", values: ["true"] }, - * }, - * priority: 50, - * }, - * ], - * }, - * }); - * ``` - * - * This example creates: - * - A shared ALB with an HTTP listener - * - An API service with path-based routing and custom health check - * - A Web service with path-based routing - * - Both services share the same ALB - */ -export default $config({ - app(input) { - return { - name: "aws-shared-alb", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { - region: "us-east-1", - }, - }, - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - // Create a shared ALB with an HTTP listener - const alb = new sst.aws.Alb("SharedAlb", { - vpc, - listeners: [{ port: 80, protocol: "http" }], - }); - - // API service β€” handles /api/* with a custom health check path - new sst.aws.Service("Api", { - cluster, - image: { context: "api/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/api/*" }, - priority: 100, - }, - ], - health: { - "3000/http": { - path: "/api/health", - interval: "10 seconds", - timeout: "5 seconds", - healthyThreshold: 2, - unhealthyThreshold: 3, - }, - }, - }, - }); - - // Web service β€” handles everything else under /app/* - new sst.aws.Service("Web", { - cluster, - image: { context: "web/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/app/*" }, - priority: 200, - }, - ], - health: { - "3000/http": { - path: "/app/health", - interval: "10 seconds", - timeout: "5 seconds", - }, - }, - }, - }); - - return { - url: alb.url, - }; - }, -}); diff --git a/examples/aws-shared-alb/test.sh b/examples/aws-shared-alb/test.sh deleted file mode 100755 index 2f7495c709..0000000000 --- a/examples/aws-shared-alb/test.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Test the shared ALB example endpoints after deployment. -# -# Usage: -# ./test.sh [alb-url] -# -# If no URL is provided, attempts to read it from sst output. - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR" - -# Get ALB URL from argument or sst output -if [ -n "${1:-}" ]; then - ALB_URL="$1" -else - echo "Fetching ALB URL from sst output..." - ALB_URL=$(npx sst output url 2>/dev/null || true) - if [ -z "$ALB_URL" ]; then - echo "ERROR: Could not determine ALB URL." - echo "Usage: ./test.sh " - echo " e.g. ./test.sh http://SharedAlb-123456.us-east-1.elb.amazonaws.com" - exit 1 - fi -fi - -# Strip trailing slash -ALB_URL="${ALB_URL%/}" - -echo "=== Testing Shared ALB Example ===" -echo "ALB URL: $ALB_URL" -echo "" - -PASS=0 -FAIL=0 - -run_test() { - local name="$1" - local url="$2" - local expected="$3" - - echo -n "TEST: $name ... " - HTTP_CODE=$(curl -s -o /tmp/alb_test_response -w "%{http_code}" --max-time 10 "$url" 2>/dev/null || echo "000") - BODY=$(cat /tmp/alb_test_response 2>/dev/null || echo "") - - if [ "$HTTP_CODE" = "000" ]; then - echo "FAIL (connection error)" - FAIL=$((FAIL + 1)) - return - fi - - if echo "$BODY" | grep -q "$expected"; then - echo "OK (HTTP $HTTP_CODE) β†’ $BODY" - PASS=$((PASS + 1)) - else - echo "FAIL (HTTP $HTTP_CODE, expected '$expected')" - echo " Got: $BODY" - FAIL=$((FAIL + 1)) - fi -} - -# Note: ALB path pattern "/api/*" matches "/api/" but NOT "/api" itself. -# Tests use paths with a trailing segment to match the wildcard. - -# Test 1: API service β€” /api/health returns { "status": "ok" } -run_test "API health (/api/health)" "$ALB_URL/api/health" '"status":"ok"' - -# Test 2: API service β€” /api/users returns { "service": "api", "path": "/api/users" } -run_test "API routing (/api/users)" "$ALB_URL/api/users" '"service":"api"' - -# Test 3: API service β€” /api/greeting returns path info -run_test "API greeting (/api/greeting)" "$ALB_URL/api/greeting" "/api/greeting" - -# Test 4: Web service β€” /app/health returns { "status": "ok" } -run_test "Web health (/app/health)" "$ALB_URL/app/health" '"status":"ok"' - -# Test 5: Web service β€” /app/dashboard returns HTML with path -run_test "Web routing (/app/dashboard)" "$ALB_URL/app/dashboard" "/app/dashboard" - -# Test 6: Web service β€” /app/greeting returns path info -run_test "Web greeting (/app/greeting)" "$ALB_URL/app/greeting" "/app/greeting" - -# Test 7: Default action β€” / should return 404 (ALB default) -echo -n "TEST: Default action (/) ... " -HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$ALB_URL/" 2>/dev/null || echo "000") -if [ "$HTTP_CODE" = "403" ]; then - echo "PASS (HTTP 403 as expected)" - PASS=$((PASS + 1)) -else - echo "FAIL (expected 403, got HTTP $HTTP_CODE)" - FAIL=$((FAIL + 1)) -fi - -echo "" -echo "=== Results: $PASS passed, $FAIL failed ===" - -if [ "$FAIL" -gt 0 ]; then - exit 1 -fi diff --git a/examples/aws-shared-alb/web/.dockerignore b/examples/aws-shared-alb/web/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb/web/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb/web/Dockerfile b/examples/aws-shared-alb/web/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb/web/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb/web/index.mjs b/examples/aws-shared-alb/web/index.mjs deleted file mode 100644 index 6640bec96f..0000000000 --- a/examples/aws-shared-alb/web/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/app", (req, res) => { - res.send("

Web App

Hello from the Web service

"); -}); - -app.get("/app/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/app/*", (req, res) => { - res.send(`

Web App

Path: ${req.path}

`); -}); - -app.listen(PORT, () => { - console.log(`Web service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb/web/package.json b/examples/aws-shared-alb/web/package.json deleted file mode 100644 index 9c43fe9bb1..0000000000 --- a/examples/aws-shared-alb/web/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "web", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-sharp/.gitignore b/examples/aws-sharp/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-sharp/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-sharp/index.ts b/examples/aws-sharp/index.ts deleted file mode 100644 index 7bb58fff18..0000000000 --- a/examples/aws-sharp/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import sharp from "sharp"; -import { promises as fs } from "fs"; - -export async function handler() { - const imagePath = "logo.png"; - - try { - // Read the image file - const imageBuffer = await fs.readFile(imagePath); - - // Resize the image - const resizedImage = await sharp(imageBuffer) - .resize(100, 100) // Resize to 100x100 - .toBuffer(); - - // Convert the buffer to base64 - const body = resizedImage.toString("base64"); - - console.log("Successfully resized logo.png"); - - return { - body, - statusCode: 200, - headers: { - "Content-Type": "image/png", - "Content-Disposition": "inline" - }, - isBase64Encoded: true - }; - } catch (error) { - console.log(error); - return { - statusCode: 500, - body: JSON.stringify("Error resizing image: " + error.message), - }; - } -} diff --git a/examples/aws-sharp/logo.png b/examples/aws-sharp/logo.png deleted file mode 100644 index 4a98ec9023..0000000000 Binary files a/examples/aws-sharp/logo.png and /dev/null differ diff --git a/examples/aws-sharp/package.json b/examples/aws-sharp/package.json deleted file mode 100644 index 941e53db73..0000000000 --- a/examples/aws-sharp/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-sharp", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sharp": "^0.33.5", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-sharp/sst.config.ts b/examples/aws-sharp/sst.config.ts deleted file mode 100644 index 533c44b782..0000000000 --- a/examples/aws-sharp/sst.config.ts +++ /dev/null @@ -1,55 +0,0 @@ -/// - -/** - * ## Sharp in Lambda - * - * Uses the [Sharp](https://sharp.pixelplumbing.com/) library to resize images. In this example, - * it resizes a `logo.png` local file to 100x100 pixels. - * - * ```json title="sst.config.ts" - * { - * nodejs: { install: ["sharp"] } - * } - * ``` - * - * We don't need a layer to deploy this because `sharp` comes with a pre-built binary for Lambda. - * This is handled by [`nodejs.install`](/docs/component/aws/function#nodejs-install). - * - * :::tip - * You don't need to use a Lambda layer to use Sharp. - * ::: - * - * In dev, this uses the sharp npm package locally. - * - * ```json title="package.json" - * { - * "dependencies": { - * "sharp": "^0.33.5" - * } - * } - * ``` - * - * On deploy, SST will use the right binary from the sharp package for the target Lambda - * architecture. - */ -export default $config({ - app(input) { - return { - name: "aws-sharp", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const func = new sst.aws.Function("MyFunction", { - url: true, - handler: "index.handler", - nodejs: { install: ["sharp"] }, - copyFiles: [{ from: "logo.png" }], - }); - - return { - url: func.url, - }; - }, -}); diff --git a/examples/aws-sharp/tsconfig.json b/examples/aws-sharp/tsconfig.json deleted file mode 100644 index 2f98042715..0000000000 --- a/examples/aws-sharp/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/examples/aws-solid-container-ws/.dockerignore b/examples/aws-solid-container-ws/.dockerignore deleted file mode 100644 index 89e3d841fd..0000000000 --- a/examples/aws-solid-container-ws/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -# sst -.sst diff --git a/examples/aws-solid-container-ws/.gitignore b/examples/aws-solid-container-ws/.gitignore deleted file mode 100644 index 8ebae30246..0000000000 --- a/examples/aws-solid-container-ws/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ - -dist -.solid -.output -.vercel -.netlify -.vinxi -app.config.timestamp_*.js - -# Environment -.env -.env*.local - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -*.launch -.settings/ - -# Temp -gitignore - -# System Files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-solid-container-ws/Dockerfile b/examples/aws-solid-container-ws/Dockerfile deleted file mode 100644 index eb842b02d5..0000000000 --- a/examples/aws-solid-container-ws/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] diff --git a/examples/aws-solid-container-ws/app.config.ts b/examples/aws-solid-container-ws/app.config.ts deleted file mode 100644 index 792fe7a649..0000000000 --- a/examples/aws-solid-container-ws/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({ - server: { - experimental: { - websocket: true, - }, - }, -}).addRouter({ - name: "ws", - type: "http", - handler: "./src/ws.ts", - target: "server", - base: "/ws", -}); diff --git a/examples/aws-solid-container-ws/package.json b/examples/aws-solid-container-ws/package.json deleted file mode 100644 index 27a783d39f..0000000000 --- a/examples/aws-solid-container-ws/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-solid-container-ws", - "type": "module", - "scripts": { - "build": "vinxi build", - "dev": "vinxi dev", - "start": "vinxi start", - "version": "vinxi version" - }, - "dependencies": { - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.14.7", - "@solidjs/start": "^1.0.8", - "solid-js": "^1.9.1", - "sst": "file:../../sdk/js", - "vinxi": "^0.4.3" - }, - "engines": { - "node": ">=18" - } -} diff --git a/examples/aws-solid-container-ws/src/app.css b/examples/aws-solid-container-ws/src/app.css deleted file mode 100644 index 8596998a49..0000000000 --- a/examples/aws-solid-container-ws/src/app.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/examples/aws-solid-container-ws/src/app.tsx b/examples/aws-solid-container-ws/src/app.tsx deleted file mode 100644 index d1359c8d82..0000000000 --- a/examples/aws-solid-container-ws/src/app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { MetaProvider, Title } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; -import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; -import "./app.css"; - -export default function App() { - return ( - ( - - SolidStart - Basic -
Index - About - {props.children} - - )} - > - - - ); -} diff --git a/examples/aws-solid-container-ws/src/components/Counter.css b/examples/aws-solid-container-ws/src/components/Counter.css deleted file mode 100644 index 220e179460..0000000000 --- a/examples/aws-solid-container-ws/src/components/Counter.css +++ /dev/null @@ -1,21 +0,0 @@ -.increment { - font-family: inherit; - font-size: inherit; - padding: 1em 2em; - color: #335d92; - background-color: rgba(68, 107, 158, 0.1); - border-radius: 2em; - border: 2px solid rgba(68, 107, 158, 0); - outline: none; - width: 200px; - font-variant-numeric: tabular-nums; - cursor: pointer; -} - -.increment:focus { - border: 2px solid #335d92; -} - -.increment:active { - background-color: rgba(68, 107, 158, 0.2); -} \ No newline at end of file diff --git a/examples/aws-solid-container-ws/src/components/Counter.tsx b/examples/aws-solid-container-ws/src/components/Counter.tsx deleted file mode 100644 index 091fc5d0bc..0000000000 --- a/examples/aws-solid-container-ws/src/components/Counter.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createSignal } from "solid-js"; -import "./Counter.css"; - -export default function Counter() { - const [count, setCount] = createSignal(0); - return ( - - ); -} diff --git a/examples/aws-solid-container-ws/src/entry-client.tsx b/examples/aws-solid-container-ws/src/entry-client.tsx deleted file mode 100644 index 0ca4e3c300..0000000000 --- a/examples/aws-solid-container-ws/src/entry-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// @refresh reload -import { mount, StartClient } from "@solidjs/start/client"; - -mount(() => , document.getElementById("app")!); diff --git a/examples/aws-solid-container-ws/src/entry-server.tsx b/examples/aws-solid-container-ws/src/entry-server.tsx deleted file mode 100644 index 401eff83fd..0000000000 --- a/examples/aws-solid-container-ws/src/entry-server.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server"; - -export default createHandler(() => ( - ( - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> -)); diff --git a/examples/aws-solid-container-ws/src/global.d.ts b/examples/aws-solid-container-ws/src/global.d.ts deleted file mode 100644 index dc6f10c226..0000000000 --- a/examples/aws-solid-container-ws/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-solid-container-ws/src/routes/[...404].tsx b/examples/aws-solid-container-ws/src/routes/[...404].tsx deleted file mode 100644 index 4ea71ec7fe..0000000000 --- a/examples/aws-solid-container-ws/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; - -export default function NotFound() { - return ( -
- Not Found - -

Page Not Found

-

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid-container-ws/src/routes/about.tsx b/examples/aws-solid-container-ws/src/routes/about.tsx deleted file mode 100644 index 8371d911cd..0000000000 --- a/examples/aws-solid-container-ws/src/routes/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Title } from "@solidjs/meta"; - -export default function Home() { - return ( -
- About -

About

-
- ); -} diff --git a/examples/aws-solid-container-ws/src/routes/index.tsx b/examples/aws-solid-container-ws/src/routes/index.tsx deleted file mode 100644 index 5d557d819f..0000000000 --- a/examples/aws-solid-container-ws/src/routes/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import Counter from "~/components/Counter"; - -export default function Home() { - return ( -
- Hello World -

Hello world!

- -

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid-container-ws/src/ws.ts b/examples/aws-solid-container-ws/src/ws.ts deleted file mode 100644 index 7ee8d34f4c..0000000000 --- a/examples/aws-solid-container-ws/src/ws.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { eventHandler } from "vinxi/http"; -export default eventHandler({ - handler() { }, - websocket: { - async open(peer) { - console.log("open", peer.id, peer.url); - }, - async message(peer, msg) { - const message = msg.text(); - console.log("msg", peer.id, peer.url, message); - - setTimeout(() => { - peer.send("Message received from: #" + peer.id); - }, 3000); - }, - async close(peer, _details) { - console.log("close", peer.id, peer.url); - }, - async error(peer, error) { - console.log("error", peer.id, peer.url, error); - }, - }, -}); diff --git a/examples/aws-solid-container-ws/sst.config.ts b/examples/aws-solid-container-ws/sst.config.ts deleted file mode 100644 index 2b1905639e..0000000000 --- a/examples/aws-solid-container-ws/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -/** - * ## AWS SolidStart WebSocket endpoint - * - * Deploys a SolidStart app with a [WebSocket endpoint](https://docs.solidjs.com/solid-start/advanced/websocket) - * in a container to AWS. - * - * Uses the experimental WebSocket support in Nitro. - * - * ```ts title="app.config.ts" {4} - * export default defineConfig({ - * server: { - * experimental: { - * websocket: true, - * }, - * }, - * }).addRouter({ - * name: "ws", - * type: "http", - * handler: "./src/ws.ts", - * target: "server", - * base: "/ws", - * }); - * ``` - * - * Once deployed you can test the `/ws` endpoint and it'll send a message back after a 3s delay. - */ -export default $config({ - app(input) { - return { - name: "aws-solid-container-ws", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-solid-container-ws/tsconfig.json b/examples/aws-solid-container-ws/tsconfig.json deleted file mode 100644 index 7d5871a07a..0000000000 --- a/examples/aws-solid-container-ws/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "preserve", - "jsxImportSource": "solid-js", - "allowJs": true, - "strict": true, - "noEmit": true, - "types": ["vinxi/types/client"], - "isolatedModules": true, - "paths": { - "~/*": ["./src/*"] - } - } -} diff --git a/examples/aws-solid-container/.dockerignore b/examples/aws-solid-container/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-solid-container/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-solid-container/.gitignore b/examples/aws-solid-container/.gitignore deleted file mode 100644 index 8ebae30246..0000000000 --- a/examples/aws-solid-container/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ - -dist -.solid -.output -.vercel -.netlify -.vinxi -app.config.timestamp_*.js - -# Environment -.env -.env*.local - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -*.launch -.settings/ - -# Temp -gitignore - -# System Files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-solid-container/Dockerfile b/examples/aws-solid-container/Dockerfile deleted file mode 100644 index eb842b02d5..0000000000 --- a/examples/aws-solid-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] diff --git a/examples/aws-solid-container/app.config.ts b/examples/aws-solid-container/app.config.ts deleted file mode 100644 index de7f83103a..0000000000 --- a/examples/aws-solid-container/app.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({}); diff --git a/examples/aws-solid-container/package.json b/examples/aws-solid-container/package.json deleted file mode 100644 index 3f3f4c9222..0000000000 --- a/examples/aws-solid-container/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-solid-container", - "type": "module", - "scripts": { - "build": "vinxi build", - "dev": "vinxi dev", - "start": "vinxi start", - "version": "vinxi version" - }, - "dependencies": { - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.14.8", - "@solidjs/start": "^1.0.8", - "ioredis": "^5.4.1", - "solid-js": "^1.9.1", - "sst": "file:../../sdk/js", - "vinxi": "^0.4.3" - }, - "engines": { - "node": ">=18" - }, - "overrides": { - "nitropack": "npm:nitropack-nightly@latest" - } -} diff --git a/examples/aws-solid-container/src/app.css b/examples/aws-solid-container/src/app.css deleted file mode 100644 index 8596998a49..0000000000 --- a/examples/aws-solid-container/src/app.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/examples/aws-solid-container/src/app.tsx b/examples/aws-solid-container/src/app.tsx deleted file mode 100644 index d1359c8d82..0000000000 --- a/examples/aws-solid-container/src/app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { MetaProvider, Title } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; -import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; -import "./app.css"; - -export default function App() { - return ( - ( - - SolidStart - Basic - Index - About - {props.children} - - )} - > - - - ); -} diff --git a/examples/aws-solid-container/src/components/Counter.css b/examples/aws-solid-container/src/components/Counter.css deleted file mode 100644 index 220e179460..0000000000 --- a/examples/aws-solid-container/src/components/Counter.css +++ /dev/null @@ -1,21 +0,0 @@ -.increment { - font-family: inherit; - font-size: inherit; - padding: 1em 2em; - color: #335d92; - background-color: rgba(68, 107, 158, 0.1); - border-radius: 2em; - border: 2px solid rgba(68, 107, 158, 0); - outline: none; - width: 200px; - font-variant-numeric: tabular-nums; - cursor: pointer; -} - -.increment:focus { - border: 2px solid #335d92; -} - -.increment:active { - background-color: rgba(68, 107, 158, 0.2); -} \ No newline at end of file diff --git a/examples/aws-solid-container/src/components/Counter.tsx b/examples/aws-solid-container/src/components/Counter.tsx deleted file mode 100644 index 091fc5d0bc..0000000000 --- a/examples/aws-solid-container/src/components/Counter.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createSignal } from "solid-js"; -import "./Counter.css"; - -export default function Counter() { - const [count, setCount] = createSignal(0); - return ( - - ); -} diff --git a/examples/aws-solid-container/src/entry-client.tsx b/examples/aws-solid-container/src/entry-client.tsx deleted file mode 100644 index 0ca4e3c300..0000000000 --- a/examples/aws-solid-container/src/entry-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// @refresh reload -import { mount, StartClient } from "@solidjs/start/client"; - -mount(() => , document.getElementById("app")!); diff --git a/examples/aws-solid-container/src/entry-server.tsx b/examples/aws-solid-container/src/entry-server.tsx deleted file mode 100644 index 401eff83fd..0000000000 --- a/examples/aws-solid-container/src/entry-server.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server"; - -export default createHandler(() => ( - ( - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> -)); diff --git a/examples/aws-solid-container/src/global.d.ts b/examples/aws-solid-container/src/global.d.ts deleted file mode 100644 index dc6f10c226..0000000000 --- a/examples/aws-solid-container/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-solid-container/src/routes/[...404].tsx b/examples/aws-solid-container/src/routes/[...404].tsx deleted file mode 100644 index 4ea71ec7fe..0000000000 --- a/examples/aws-solid-container/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; - -export default function NotFound() { - return ( -
- Not Found - -

Page Not Found

-

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid-container/src/routes/about.tsx b/examples/aws-solid-container/src/routes/about.tsx deleted file mode 100644 index 8371d911cd..0000000000 --- a/examples/aws-solid-container/src/routes/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Title } from "@solidjs/meta"; - -export default function Home() { - return ( -
- About -

About

-
- ); -} diff --git a/examples/aws-solid-container/src/routes/index.tsx b/examples/aws-solid-container/src/routes/index.tsx deleted file mode 100644 index ff472de40e..0000000000 --- a/examples/aws-solid-container/src/routes/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { createAsync, cache } from "@solidjs/router"; - -const getCounter = cache(async () => { - "use server"; - const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } - ); - - return await redis.incr("counter"); -}, "counter"); - -export const route = { - load: () => getCounter(), -}; - -export default function Page() { - const counter = createAsync(() => getCounter()); - - return

Hit counter: {counter()}

; -} diff --git a/examples/aws-solid-container/sst.config.ts b/examples/aws-solid-container/sst.config.ts deleted file mode 100644 index 34e9e92282..0000000000 --- a/examples/aws-solid-container/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-solid-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-solid-container/tsconfig.json b/examples/aws-solid-container/tsconfig.json deleted file mode 100644 index 7d5871a07a..0000000000 --- a/examples/aws-solid-container/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "preserve", - "jsxImportSource": "solid-js", - "allowJs": true, - "strict": true, - "noEmit": true, - "types": ["vinxi/types/client"], - "isolatedModules": true, - "paths": { - "~/*": ["./src/*"] - } - } -} diff --git a/examples/aws-solid/.gitignore b/examples/aws-solid/.gitignore deleted file mode 100644 index 8ebae30246..0000000000 --- a/examples/aws-solid/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ - -dist -.solid -.output -.vercel -.netlify -.vinxi -app.config.timestamp_*.js - -# Environment -.env -.env*.local - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -*.launch -.settings/ - -# Temp -gitignore - -# System Files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-solid/app.config.ts b/examples/aws-solid/app.config.ts deleted file mode 100644 index 499d53e43b..0000000000 --- a/examples/aws-solid/app.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({ - server: { - preset: "aws-lambda", - awsLambda: { - streaming: true, - }, - }, -}); diff --git a/examples/aws-solid/package.json b/examples/aws-solid/package.json deleted file mode 100644 index a9fa8b8ca3..0000000000 --- a/examples/aws-solid/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "aws-solid", - "type": "module", - "scripts": { - "build": "vinxi build", - "dev": "vinxi dev", - "start": "vinxi start", - "version": "vinxi version" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.670.0", - "@aws-sdk/s3-request-presigner": "^3.670.0", - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.14.8", - "@solidjs/start": "^1.0.8", - "solid-js": "^1.9.1", - "sst": "file:../../sdk/js", - "vinxi": "^0.4.3" - }, - "engines": { - "node": ">=18" - }, - "overrides": { - "nitropack": "npm:nitropack-nightly@latest" - } -} diff --git a/examples/aws-solid/public/favicon.ico b/examples/aws-solid/public/favicon.ico deleted file mode 100644 index fb282da071..0000000000 Binary files a/examples/aws-solid/public/favicon.ico and /dev/null differ diff --git a/examples/aws-solid/src/app.css b/examples/aws-solid/src/app.css deleted file mode 100644 index 8596998a49..0000000000 --- a/examples/aws-solid/src/app.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/examples/aws-solid/src/app.tsx b/examples/aws-solid/src/app.tsx deleted file mode 100644 index d1359c8d82..0000000000 --- a/examples/aws-solid/src/app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { MetaProvider, Title } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; -import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; -import "./app.css"; - -export default function App() { - return ( - ( - - SolidStart - Basic - Index - About - {props.children} - - )} - > - - - ); -} diff --git a/examples/aws-solid/src/components/Counter.css b/examples/aws-solid/src/components/Counter.css deleted file mode 100644 index 220e179460..0000000000 --- a/examples/aws-solid/src/components/Counter.css +++ /dev/null @@ -1,21 +0,0 @@ -.increment { - font-family: inherit; - font-size: inherit; - padding: 1em 2em; - color: #335d92; - background-color: rgba(68, 107, 158, 0.1); - border-radius: 2em; - border: 2px solid rgba(68, 107, 158, 0); - outline: none; - width: 200px; - font-variant-numeric: tabular-nums; - cursor: pointer; -} - -.increment:focus { - border: 2px solid #335d92; -} - -.increment:active { - background-color: rgba(68, 107, 158, 0.2); -} \ No newline at end of file diff --git a/examples/aws-solid/src/components/Counter.tsx b/examples/aws-solid/src/components/Counter.tsx deleted file mode 100644 index 091fc5d0bc..0000000000 --- a/examples/aws-solid/src/components/Counter.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createSignal } from "solid-js"; -import "./Counter.css"; - -export default function Counter() { - const [count, setCount] = createSignal(0); - return ( - - ); -} diff --git a/examples/aws-solid/src/entry-client.tsx b/examples/aws-solid/src/entry-client.tsx deleted file mode 100644 index 0ca4e3c300..0000000000 --- a/examples/aws-solid/src/entry-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// @refresh reload -import { mount, StartClient } from "@solidjs/start/client"; - -mount(() => , document.getElementById("app")!); diff --git a/examples/aws-solid/src/entry-server.tsx b/examples/aws-solid/src/entry-server.tsx deleted file mode 100644 index 401eff83fd..0000000000 --- a/examples/aws-solid/src/entry-server.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server"; - -export default createHandler(() => ( - ( - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> -)); diff --git a/examples/aws-solid/src/global.d.ts b/examples/aws-solid/src/global.d.ts deleted file mode 100644 index dc6f10c226..0000000000 --- a/examples/aws-solid/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-solid/src/routes/[...404].tsx b/examples/aws-solid/src/routes/[...404].tsx deleted file mode 100644 index 4ea71ec7fe..0000000000 --- a/examples/aws-solid/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; - -export default function NotFound() { - return ( -
- Not Found - -

Page Not Found

-

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid/src/routes/about.tsx b/examples/aws-solid/src/routes/about.tsx deleted file mode 100644 index 8371d911cd..0000000000 --- a/examples/aws-solid/src/routes/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Title } from "@solidjs/meta"; - -export default function Home() { - return ( -
- About -

About

-
- ); -} diff --git a/examples/aws-solid/src/routes/index.tsx b/examples/aws-solid/src/routes/index.tsx deleted file mode 100644 index 9d59f86dee..0000000000 --- a/examples/aws-solid/src/routes/index.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { Resource } from "sst"; -import { createAsync } from "@solidjs/router"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -async function presignedUrl() { - "use server"; - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - return await getSignedUrl(new S3Client({}), command); -} - -export const route = { - load: () => presignedUrl(), -}; - -export default function Home() { - const url = createAsync(() => presignedUrl()); - - return ( -
-

Hello world!

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(url() as string, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
- ); -} diff --git a/examples/aws-solid/sst.config.ts b/examples/aws-solid/sst.config.ts deleted file mode 100644 index b14575b398..0000000000 --- a/examples/aws-solid/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-solid", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.SolidStart("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-solid/tsconfig.json b/examples/aws-solid/tsconfig.json deleted file mode 100644 index 7d5871a07a..0000000000 --- a/examples/aws-solid/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "preserve", - "jsxImportSource": "solid-js", - "allowJs": true, - "strict": true, - "noEmit": true, - "types": ["vinxi/types/client"], - "isolatedModules": true, - "paths": { - "~/*": ["./src/*"] - } - } -} diff --git a/examples/aws-static-site-basic-auth/package.json b/examples/aws-static-site-basic-auth/package.json deleted file mode 100644 index da474b02d6..0000000000 --- a/examples/aws-static-site-basic-auth/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-static-site-basic-auth", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-static-site-basic-auth/site/index.html b/examples/aws-static-site-basic-auth/site/index.html deleted file mode 100644 index 781e1c2cf4..0000000000 --- a/examples/aws-static-site-basic-auth/site/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

hello world!

- - diff --git a/examples/aws-static-site-basic-auth/sst.config.ts b/examples/aws-static-site-basic-auth/sst.config.ts deleted file mode 100644 index 212e65f84c..0000000000 --- a/examples/aws-static-site-basic-auth/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS static site basic auth - * - * This deploys a simple static site and adds basic auth to it. - * - * This is useful for dev environments where you want to share a static site with your team but - * ensure that it's not publicly accessible. - * - * This works by injecting some code into a CloudFront function that checks the basic auth - * header and matches it against the `USERNAME` and `PASSWORD` secrets. - * - * ```ts title="sst.config.ts" - * { - * injection: $interpolate` - * if ( - * !event.request.headers.authorization - * || event.request.headers.authorization.value !== "Basic ${basicAuth}" - * ) { - * return { - * statusCode: 401, - * headers: { - * "www-authenticate": { value: "Basic" } - * } - * }; - * }`, - * } - * ``` - * - * To deploy this, you need to first set the `USERNAME` and `PASSWORD` secrets. - * - * ```bash - * sst secret set USERNAME my-username - * sst secret set PASSWORD my-password - * ``` - * - * If you are deploying this to preview environments, you might want to set the secrets using - * the [`--fallback`](/docs/reference/cli#secret) flag. - */ -export default $config({ - app(input) { - return { - name: "aws-static-site-basic-auth", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const username = new sst.Secret("USERNAME"); - const password = new sst.Secret("PASSWORD"); - const basicAuth = $resolve([username.value, password.value]).apply( - ([username, password]) => - Buffer.from(`${username}:${password}`).toString("base64") - ); - - new sst.aws.StaticSite("MySite", { - path: "site", - // Don't password protect prod - edge: $app.stage !== "production" - ? { - viewerRequest: { - injection: $interpolate` - if ( - !event.request.headers.authorization - || event.request.headers.authorization.value !== "Basic ${basicAuth}" - ) { - return { - statusCode: 401, - headers: { - "www-authenticate": { value: "Basic" } - } - }; - }`, - }, - } - : undefined, - }); - }, -}); diff --git a/examples/aws-static-site/package.json b/examples/aws-static-site/package.json deleted file mode 100644 index 5e4a51b0c2..0000000000 --- a/examples/aws-static-site/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-static-site", - "version": "1.0.0", - "main": "index.js", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "scripts": { - "dev": "npx --yes serve ./site" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "" -} diff --git a/examples/aws-static-site/site/404.html b/examples/aws-static-site/site/404.html deleted file mode 100644 index e1dc7559af..0000000000 --- a/examples/aws-static-site/site/404.html +++ /dev/null @@ -1,7 +0,0 @@ - - - 404 Not Found - -

404 - Page Not Found

- - diff --git a/examples/aws-static-site/site/index.html b/examples/aws-static-site/site/index.html deleted file mode 100644 index 9605cebdeb..0000000000 --- a/examples/aws-static-site/site/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

Hello World!

- - diff --git a/examples/aws-static-site/sst.config.ts b/examples/aws-static-site/sst.config.ts deleted file mode 100644 index 2cde0b1837..0000000000 --- a/examples/aws-static-site/sst.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -/** - * ## AWS static site - * - * Deploy a simple HTML file as a static site with S3 and CloudFront. The website is stored in - * the `site/` directory. - */ -export default $config({ - app(input) { - return { - name: "aws-static-site", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - new sst.aws.StaticSite("MySite", { - path: "site", - errorPage: "404.html", - }); - }, -}); diff --git a/examples/aws-step-functions-task-token/.gitignore b/examples/aws-step-functions-task-token/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-step-functions-task-token/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-step-functions-task-token/index.ts b/examples/aws-step-functions-task-token/index.ts deleted file mode 100644 index 4019bcbab7..0000000000 --- a/examples/aws-step-functions-task-token/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { SQSEvent } from "aws-lambda"; -import { SFNClient, SendTaskSuccessCommand } from "@aws-sdk/client-sfn"; - -const sfn = new SFNClient(); - -export async function handler(e: SQSEvent) { - // Parse the task token - const { body } = e.Records[0]; - const { MyTaskToken } = JSON.parse(body); - - // Do some work - await new Promise((resolve) => setTimeout(resolve, 1000)); - - // Call `SendTaskSuccess` to mark the task done - await sfn.send( - new SendTaskSuccessCommand({ - taskToken: MyTaskToken, - output: JSON.stringify({ result: "foo" }), - }) - ); - - return "ok"; -} diff --git a/examples/aws-step-functions-task-token/package.json b/examples/aws-step-functions-task-token/package.json deleted file mode 100644 index 6f54d1065d..0000000000 --- a/examples/aws-step-functions-task-token/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-step-functions-task-token", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-sfn": "^3.812.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.11" - } -} diff --git a/examples/aws-step-functions-task-token/sst.config.ts b/examples/aws-step-functions-task-token/sst.config.ts deleted file mode 100644 index bb47484940..0000000000 --- a/examples/aws-step-functions-task-token/sst.config.ts +++ /dev/null @@ -1,45 +0,0 @@ -/// - -/** - * ## AWS Step Functions task token - * - * Use Step Functions with task tokens to pause execution, send a message to an - * SQS queue, and resume after processing. - */ -export default $config({ - app(input) { - return { - name: "aws-step-functions-task-token", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // Create a queue the state machine will send messages to - const queue = new sst.aws.Queue("MyQueue"); - - // Define all the states of the state machine - const sendMessage = sst.aws.StepFunctions.sqsSendMessage({ - name: "SendMessage", - integration: "token", - queue, - messageBody: { - // Task token passed in the message body - MyTaskToken: "{% $states.context.Task.Token %}", - }, - }); - const success = sst.aws.StepFunctions.succeed({ name: "Succeed" }); - - // Create the state machine - const stepFunction = new sst.aws.StepFunctions("MyStateMachine", { - definition: sendMessage.next(success), - }); - - // Create a function that will receive messages from the queue - queue.subscribe({ - handler: "index.handler", - // Linking the state machine to grant permissions to call `SendTaskSuccess` - link: [stepFunction], - }); - }, -}); diff --git a/examples/aws-step-functions-task-token/tsconfig.json b/examples/aws-step-functions-task-token/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-step-functions-task-token/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-step-functions/.gitignore b/examples/aws-step-functions/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-step-functions/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-step-functions/index.ts b/examples/aws-step-functions/index.ts deleted file mode 100644 index 6e7064b8d5..0000000000 --- a/examples/aws-step-functions/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export async function handler() { - return { - message: "v1", - }; -} diff --git a/examples/aws-step-functions/package.json b/examples/aws-step-functions/package.json deleted file mode 100644 index f1d60f0a31..0000000000 --- a/examples/aws-step-functions/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-step-functions", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-step-functions/sst.config.ts b/examples/aws-step-functions/sst.config.ts deleted file mode 100644 index e8982e1878..0000000000 --- a/examples/aws-step-functions/sst.config.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-step-functions", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // Create a function to be invoked by the state machine - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - }); - - // Define all the states of the state machine - const lambdaInvoke = sst.aws.StepFunctions.lambdaInvoke({ - name: "LambdaInvoke", - function: app, - payload: { - foo: "bar", - }, - }); - const pass = sst.aws.StepFunctions.pass({ name: "Pass" }); - const wait = sst.aws.StepFunctions.wait({ - name: "Wait", - time: "2 seconds", - }); - const choice = sst.aws.StepFunctions.choice({ name: "Choice" }); - const parallel = sst.aws.StepFunctions.parallel({ name: "Parallel" }); - const parallelA = sst.aws.StepFunctions.pass({ name: "ParallelA" }); - const parallelB = sst.aws.StepFunctions.pass({ name: "ParallelB" }); - const parallelC = sst.aws.StepFunctions.pass({ name: "ParallelC" }); - const mapA = sst.aws.StepFunctions.pass({ name: "MapA" }); - const mapB = sst.aws.StepFunctions.pass({ name: "MapB" }); - const map = sst.aws.StepFunctions.map({ - name: "Map", - processor: mapA.next(mapB), - items: ["a", "b", "c"], - }); - const success = sst.aws.StepFunctions.succeed({ name: "Succeed" }); - const fail = sst.aws.StepFunctions.fail({ name: "Fail" }); - const last = sst.aws.StepFunctions.pass({ name: "Last" }); - - // Create the state machine - new sst.aws.StepFunctions("MyStateMachine", { - definition: lambdaInvoke - .catch(fail) - .next(pass) - .next(wait) - .next(parallel.branch(parallelA.next(parallelB)).branch(parallelC)) - .next(map) - .next( - choice - .when("{% 1+1 = 2 %}", success) - .when("{% 1+1 = 3 %}", fail) - .otherwise(last) - ), - }); - }, -}); diff --git a/examples/aws-step-functions/tsconfig.json b/examples/aws-step-functions/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-step-functions/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-supabase-drizzle/.gitignore b/examples/aws-supabase-drizzle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-supabase-drizzle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-supabase-drizzle/drizzle.config.ts b/examples/aws-supabase-drizzle/drizzle.config.ts deleted file mode 100644 index 7f110ab1ad..0000000000 --- a/examples/aws-supabase-drizzle/drizzle.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { defineConfig } from "drizzle-kit"; -import { Resource } from "sst"; -export default defineConfig({ - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dialect: "postgresql", - dbCredentials: { - host: Resource.Database.host, - database: Resource.Database.database, - port: Resource.Database.port, - user: Resource.Database.user, - password: Resource.Database.password, - }, -}); diff --git a/examples/aws-supabase-drizzle/migrations/0000_great_solo.sql b/examples/aws-supabase-drizzle/migrations/0000_great_solo.sql deleted file mode 100644 index db52d6f17f..0000000000 --- a/examples/aws-supabase-drizzle/migrations/0000_great_solo.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS "todo" ( - "id" serial PRIMARY KEY NOT NULL, - "title" text NOT NULL, - "description" text -); diff --git a/examples/aws-supabase-drizzle/migrations/meta/0000_snapshot.json b/examples/aws-supabase-drizzle/migrations/meta/0000_snapshot.json deleted file mode 100644 index 64994dcf98..0000000000 --- a/examples/aws-supabase-drizzle/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "id": "60c8abb1-7e2d-4b3d-8bc3-68b4a51c8fb8", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "6", - "dialect": "postgresql", - "tables": { - "public.todo": { - "name": "todo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/examples/aws-supabase-drizzle/migrations/meta/_journal.json b/examples/aws-supabase-drizzle/migrations/meta/_journal.json deleted file mode 100644 index 6088d1cbd8..0000000000 --- a/examples/aws-supabase-drizzle/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "5", - "dialect": "pg", - "entries": [ - { - "idx": 0, - "version": "6", - "when": 1715012302701, - "tag": "0000_great_solo", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/examples/aws-supabase-drizzle/package.json b/examples/aws-supabase-drizzle/package.json deleted file mode 100644 index 9439872cd4..0000000000 --- a/examples/aws-supabase-drizzle/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-supabase-drizzle", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit", - "db:studio": "sst shell drizzle-kit studio", - "db:migrate": "sst shell drizzle-kit migrate" - }, - "dependencies": { - "@aws-sdk/client-rds-data": "^3.564.0", - "drizzle-kit": "0.20.17-679add7", - "drizzle-orm": "^0.30.9", - "postgres": "^3.4.4", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-supabase-drizzle/src/api.ts b/examples/aws-supabase-drizzle/src/api.ts deleted file mode 100644 index b4abb9a66d..0000000000 --- a/examples/aws-supabase-drizzle/src/api.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyHandlerV2 } from "aws-lambda"; -import { randomUUID } from "node:crypto"; - -export const handler: APIGatewayProxyHandlerV2 = async (evt) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "new todo " + randomUUID() }) - .returning() - .execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - return { - statusCode: 404, - body: "not found", - }; -}; diff --git a/examples/aws-supabase-drizzle/src/drizzle.ts b/examples/aws-supabase-drizzle/src/drizzle.ts deleted file mode 100644 index 72efbb6aa3..0000000000 --- a/examples/aws-supabase-drizzle/src/drizzle.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { drizzle } from "drizzle-orm/postgres-js"; -import { Resource } from "sst"; -import postgres from "postgres"; - -const client = postgres({ - password: Resource.Database.password, - user: Resource.Database.user, - port: Resource.Database.port, - host: Resource.Database.host, - db: "postgres", -}); - -export const db = drizzle(client); diff --git a/examples/aws-supabase-drizzle/src/todo.sql.ts b/examples/aws-supabase-drizzle/src/todo.sql.ts deleted file mode 100644 index 1de457f10b..0000000000 --- a/examples/aws-supabase-drizzle/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { pgTable, text, serial } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-supabase-drizzle/sst.config.ts b/examples/aws-supabase-drizzle/sst.config.ts deleted file mode 100644 index 232b2e7e53..0000000000 --- a/examples/aws-supabase-drizzle/sst.config.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-supabase-drizzle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - random: true, - supabase: true, - }, - }; - }, - async run() { - sst.Linkable.wrap(supabase.Project, function (item) { - return { - properties: { - user: $interpolate`postgres.${item.id}`, - password: item.databasePassword, - host: $interpolate`aws-0-${item.region}.pooler.supabase.com`, - port: 5432, - database: "postgres", - }, - }; - }); - const project = new supabase.Project("Database", { - name: $interpolate`${$app.name}-${$app.stage}`, - region: "us-east-1", - organizationId: process.env.SUPABASE_ORG_ID!, - databasePassword: new random.RandomString("DatabasePassword", { - length: 16, - }).result, - }); - const api = new sst.aws.Function("Api", { - url: true, - handler: "src/api.handler", - link: [project], - }); - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-supabase-drizzle/tsconfig.json b/examples/aws-supabase-drizzle/tsconfig.json deleted file mode 100644 index b6955c086e..0000000000 --- a/examples/aws-supabase-drizzle/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true, - } -} diff --git a/examples/aws-svelte-container/.dockerignore b/examples/aws-svelte-container/.dockerignore deleted file mode 100644 index 54159dd073..0000000000 --- a/examples/aws-svelte-container/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -.DS_Store -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-svelte-container/.gitignore b/examples/aws-svelte-container/.gitignore deleted file mode 100644 index 82ed85c1d6..0000000000 --- a/examples/aws-svelte-container/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst diff --git a/examples/aws-svelte-container/.npmrc b/examples/aws-svelte-container/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-container/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-container/Dockerfile b/examples/aws-svelte-container/Dockerfile deleted file mode 100644 index 6c82f47358..0000000000 --- a/examples/aws-svelte-container/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:18.18.0-alpine AS builder - -WORKDIR /app -COPY package*.json . -RUN npm install -COPY . . -RUN npm run build -RUN npm prune --prod - -FROM builder AS deployer - -WORKDIR /app -COPY --from=builder /app/build build/ -COPY --from=builder /app/package.json . -EXPOSE 3000 -ENV NODE_ENV=production -CMD [ "node", "build" ] diff --git a/examples/aws-svelte-container/package.json b/examples/aws-svelte-container/package.json deleted file mode 100644 index f62de0b433..0000000000 --- a/examples/aws-svelte-container/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "aws-svelte-container", - "version": "0.0.1", - "type": "module", - "scripts": { - "build": "vite build", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "dev": "vite dev", - "preview": "vite preview" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.2.9", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^4.0.0", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "sst": "file:../../sdk/js", - "svelte-kit-sst": "2.43.5" - } -} diff --git a/examples/aws-svelte-container/src/app.d.ts b/examples/aws-svelte-container/src/app.d.ts deleted file mode 100644 index da08e6da59..0000000000 --- a/examples/aws-svelte-container/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://svelte.dev/docs/kit/types#app.d.ts -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-container/src/app.html b/examples/aws-svelte-container/src/app.html deleted file mode 100644 index 77a5ff52c9..0000000000 --- a/examples/aws-svelte-container/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-container/src/lib/index.ts b/examples/aws-svelte-container/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/examples/aws-svelte-container/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/examples/aws-svelte-container/src/routes/+page.server.ts b/examples/aws-svelte-container/src/routes/+page.server.ts deleted file mode 100644 index d5ff41caed..0000000000 --- a/examples/aws-svelte-container/src/routes/+page.server.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} diff --git a/examples/aws-svelte-container/src/routes/+page.svelte b/examples/aws-svelte-container/src/routes/+page.svelte deleted file mode 100644 index cbc3260f8b..0000000000 --- a/examples/aws-svelte-container/src/routes/+page.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - -
-
- - -
-
diff --git a/examples/aws-svelte-container/sst.config.ts b/examples/aws-svelte-container/sst.config.ts deleted file mode 100644 index dac8837874..0000000000 --- a/examples/aws-svelte-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-svelte-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-svelte-container/svelte.config.js b/examples/aws-svelte-container/svelte.config.js deleted file mode 100644 index e0a641ee7f..0000000000 --- a/examples/aws-svelte-container/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from '@sveltejs/adapter-node'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } -}; - -export default config; diff --git a/examples/aws-svelte-container/tsconfig.json b/examples/aws-svelte-container/tsconfig.json deleted file mode 100644 index 0b2d8865f4..0000000000 --- a/examples/aws-svelte-container/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/examples/aws-svelte-kit-remote-functions/.gitignore b/examples/aws-svelte-kit-remote-functions/.gitignore deleted file mode 100644 index 37e9161d16..0000000000 --- a/examples/aws-svelte-kit-remote-functions/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst - diff --git a/examples/aws-svelte-kit-remote-functions/.npmrc b/examples/aws-svelte-kit-remote-functions/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-kit-remote-functions/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-kit-remote-functions/package.json b/examples/aws-svelte-kit-remote-functions/package.json deleted file mode 100644 index 2996b0ffc1..0000000000 --- a/examples/aws-svelte-kit-remote-functions/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "aws-svelte-kit-remote-functions", - "private": true, - "version": "0.0.1", - "type": "module", - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "prepare": "svelte-kit sync || echo ''", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^6.1.0", - "@sveltejs/kit": "^2.43.2", - "@sveltejs/vite-plugin-svelte": "^6.2.0", - "@tailwindcss/vite": "^4.1.13", - "svelte": "^5.39.5", - "svelte-check": "^4.3.2", - "tailwindcss": "^4.1.13", - "typescript": "^5.9.2", - "vite": "^7.1.7" - }, - "dependencies": { - "sst": "file:../../sdk/js", - "svelte-kit-sst": "latest" - } -} diff --git a/examples/aws-svelte-kit-remote-functions/src/app.css b/examples/aws-svelte-kit-remote-functions/src/app.css deleted file mode 100644 index d4b5078586..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/app.css +++ /dev/null @@ -1 +0,0 @@ -@import 'tailwindcss'; diff --git a/examples/aws-svelte-kit-remote-functions/src/app.d.ts b/examples/aws-svelte-kit-remote-functions/src/app.d.ts deleted file mode 100644 index da08e6da59..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://svelte.dev/docs/kit/types#app.d.ts -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-kit-remote-functions/src/app.html b/examples/aws-svelte-kit-remote-functions/src/app.html deleted file mode 100644 index f273cc58f7..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/app.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-kit-remote-functions/src/lib/assets/favicon.svg b/examples/aws-svelte-kit-remote-functions/src/lib/assets/favicon.svg deleted file mode 100644 index cc5dc66a3a..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/lib/assets/favicon.svg +++ /dev/null @@ -1 +0,0 @@ -svelte-logo \ No newline at end of file diff --git a/examples/aws-svelte-kit-remote-functions/src/routes/+page.svelte b/examples/aws-svelte-kit-remote-functions/src/routes/+page.svelte deleted file mode 100644 index 9890126cad..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/routes/+page.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - - - {#snippet pending()} -

Loading...

- {/snippet} - - {#snippet failed(err, reset)} -

Error: {err}

- - {/snippet} - -
    - {#each await getArbitraryData() as item} -
  • {item}
  • - {/each} -
-
diff --git a/examples/aws-svelte-kit-remote-functions/src/routes/home.remote.ts b/examples/aws-svelte-kit-remote-functions/src/routes/home.remote.ts deleted file mode 100644 index b36e1eb5c7..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/routes/home.remote.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { query } from "$app/server"; - -export const getArbitraryData = query(async () => { - await new Promise((resolve) => setTimeout(resolve, 2000)); - return ["foo", "bar", "baz"]; -}); diff --git a/examples/aws-svelte-kit-remote-functions/sst.config.ts b/examples/aws-svelte-kit-remote-functions/sst.config.ts deleted file mode 100644 index b50ebbfb2b..0000000000 --- a/examples/aws-svelte-kit-remote-functions/sst.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-svelte-kit-remote-functions", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.SvelteKit("MyWeb", { - dev: { - command: "bun run dev", - }, - }); - }, -}); diff --git a/examples/aws-svelte-kit-remote-functions/static/robots.txt b/examples/aws-svelte-kit-remote-functions/static/robots.txt deleted file mode 100644 index b6dd6670cb..0000000000 --- a/examples/aws-svelte-kit-remote-functions/static/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# allow crawling everything by default -User-agent: * -Disallow: diff --git a/examples/aws-svelte-kit-remote-functions/svelte.config.js b/examples/aws-svelte-kit-remote-functions/svelte.config.js deleted file mode 100644 index 77f720c3d8..0000000000 --- a/examples/aws-svelte-kit-remote-functions/svelte.config.js +++ /dev/null @@ -1,25 +0,0 @@ -import adapter from "svelte-kit-sst"; -import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), - compilerOptions: { - experimental: { - async: true, - }, - }, - kit: { - experimental: { - remoteFunctions: true, - }, - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter(), - }, -}; - -export default config; diff --git a/examples/aws-svelte-kit-remote-functions/tsconfig.json b/examples/aws-svelte-kit-remote-functions/tsconfig.json deleted file mode 100644 index a5567ee6bb..0000000000 --- a/examples/aws-svelte-kit-remote-functions/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // To make changes to top-level options such as include and exclude, we recommend extending - // the generated config; see https://svelte.dev/docs/kit/configuration#typescript -} diff --git a/examples/aws-svelte-kit-remote-functions/vite.config.ts b/examples/aws-svelte-kit-remote-functions/vite.config.ts deleted file mode 100644 index 2d35c4f5af..0000000000 --- a/examples/aws-svelte-kit-remote-functions/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import tailwindcss from '@tailwindcss/vite'; -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [tailwindcss(), sveltekit()] -}); diff --git a/examples/aws-svelte-kit/.gitignore b/examples/aws-svelte-kit/.gitignore deleted file mode 100644 index 82ed85c1d6..0000000000 --- a/examples/aws-svelte-kit/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst diff --git a/examples/aws-svelte-kit/.npmrc b/examples/aws-svelte-kit/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-kit/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-kit/package.json b/examples/aws-svelte-kit/package.json deleted file mode 100644 index 7db901eb05..0000000000 --- a/examples/aws-svelte-kit/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "aws-svelte-kit", - "version": "0.0.1", - "type": "module", - "scripts": { - "build": "vite build", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "dev": "vite dev", - "preview": "vite preview" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^4.0.0", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.700.0", - "@aws-sdk/s3-request-presigner": "^3.700.0", - "sst": "file:../../sdk/js", - "svelte-kit-sst": "2.43.5" - } -} diff --git a/examples/aws-svelte-kit/src/app.d.ts b/examples/aws-svelte-kit/src/app.d.ts deleted file mode 100644 index da08e6da59..0000000000 --- a/examples/aws-svelte-kit/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://svelte.dev/docs/kit/types#app.d.ts -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-kit/src/app.html b/examples/aws-svelte-kit/src/app.html deleted file mode 100644 index 77a5ff52c9..0000000000 --- a/examples/aws-svelte-kit/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-kit/src/lib/index.ts b/examples/aws-svelte-kit/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/examples/aws-svelte-kit/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/examples/aws-svelte-kit/src/routes/+page.server.ts b/examples/aws-svelte-kit/src/routes/+page.server.ts deleted file mode 100644 index d5ff41caed..0000000000 --- a/examples/aws-svelte-kit/src/routes/+page.server.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} diff --git a/examples/aws-svelte-kit/src/routes/+page.svelte b/examples/aws-svelte-kit/src/routes/+page.svelte deleted file mode 100644 index cbc3260f8b..0000000000 --- a/examples/aws-svelte-kit/src/routes/+page.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - -
-
- - -
-
diff --git a/examples/aws-svelte-kit/sst.config.ts b/examples/aws-svelte-kit/sst.config.ts deleted file mode 100644 index ac35800175..0000000000 --- a/examples/aws-svelte-kit/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-svelte-kit", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.SvelteKit("MyWeb", { - link: [bucket] - }); - }, -}); diff --git a/examples/aws-svelte-kit/svelte.config.js b/examples/aws-svelte-kit/svelte.config.js deleted file mode 100644 index 7ea4b69156..0000000000 --- a/examples/aws-svelte-kit/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from "svelte-kit-sst"; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } -}; - -export default config; diff --git a/examples/aws-svelte-kit/tsconfig.json b/examples/aws-svelte-kit/tsconfig.json deleted file mode 100644 index 0b2d8865f4..0000000000 --- a/examples/aws-svelte-kit/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/examples/aws-svelte-redis/.dockerignore b/examples/aws-svelte-redis/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-svelte-redis/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-svelte-redis/.gitignore b/examples/aws-svelte-redis/.gitignore deleted file mode 100644 index 82ed85c1d6..0000000000 --- a/examples/aws-svelte-redis/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst diff --git a/examples/aws-svelte-redis/.npmrc b/examples/aws-svelte-redis/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-redis/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-redis/Dockerfile b/examples/aws-svelte-redis/Dockerfile deleted file mode 100644 index 442e34ca15..0000000000 --- a/examples/aws-svelte-redis/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM node:lts-alpine AS builder - -# Add linked resources to the environment -ARG SST_RESOURCE_MyRedis - -WORKDIR /app - -COPY package*.json . - -RUN npm install - -COPY . . - -RUN npm run build -RUN npm prune --prod - -FROM builder AS deployer - -WORKDIR /app - -COPY --from=builder /app/build build/ -COPY --from=builder /app/package.json . - -EXPOSE 3000 - -ENV NODE_ENV=production - -CMD [ "node", "build" ] diff --git a/examples/aws-svelte-redis/package.json b/examples/aws-svelte-redis/package.json deleted file mode 100644 index 4eee5e0d29..0000000000 --- a/examples/aws-svelte-redis/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "aws-svelte-redis", - "version": "0.0.1", - "private": true, - "scripts": { - "build": "vite build", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "dev": "vite dev", - "preview": "vite preview" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.2.6", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^3.0.0", - "svelte": "^4.2.7", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "type": "module", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js", - "svelte-kit-sst": "2.43.5" - } -} diff --git a/examples/aws-svelte-redis/src/app.d.ts b/examples/aws-svelte-redis/src/app.d.ts deleted file mode 100644 index 743f07b2e5..0000000000 --- a/examples/aws-svelte-redis/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-redis/src/app.html b/examples/aws-svelte-redis/src/app.html deleted file mode 100644 index 77a5ff52c9..0000000000 --- a/examples/aws-svelte-redis/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-redis/src/lib/index.ts b/examples/aws-svelte-redis/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/examples/aws-svelte-redis/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/examples/aws-svelte-redis/src/routes/+page.server.ts b/examples/aws-svelte-redis/src/routes/+page.server.ts deleted file mode 100644 index 237509c421..0000000000 --- a/examples/aws-svelte-redis/src/routes/+page.server.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const counter = await redis.incr("counter"); - - return { counter }; -} diff --git a/examples/aws-svelte-redis/src/routes/+page.svelte b/examples/aws-svelte-redis/src/routes/+page.svelte deleted file mode 100644 index d128445512..0000000000 --- a/examples/aws-svelte-redis/src/routes/+page.svelte +++ /dev/null @@ -1,6 +0,0 @@ - - -

Hit counter: {data.counter}

diff --git a/examples/aws-svelte-redis/sst.config.ts b/examples/aws-svelte-redis/sst.config.ts deleted file mode 100644 index dba368da71..0000000000 --- a/examples/aws-svelte-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS SvelteKit container with Redis - * - * Creates a hit counter app with SvelteKit and Redis. - * - * This deploys SvelteKit as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:5173` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by adding the `Dockerfile` that's included in this example and - * running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-svelte-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-svelte-redis/static/favicon.png b/examples/aws-svelte-redis/static/favicon.png deleted file mode 100644 index 825b9e65af..0000000000 Binary files a/examples/aws-svelte-redis/static/favicon.png and /dev/null differ diff --git a/examples/aws-svelte-redis/svelte.config.js b/examples/aws-svelte-redis/svelte.config.js deleted file mode 100644 index fffb8494ec..0000000000 --- a/examples/aws-svelte-redis/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from '@sveltejs/adapter-node'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://kit.svelte.dev/docs/integrations#preprocessors - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() - } -}; - -export default config; diff --git a/examples/aws-svelte-redis/tsconfig.json b/examples/aws-svelte-redis/tsconfig.json deleted file mode 100644 index 60c2cf6020..0000000000 --- a/examples/aws-svelte-redis/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "include": [ - "ambient.d.ts", - "non-ambient.d.ts", - "./types/**/$types.d.ts", - "../sst-env.d.ts", - "../vite.config.js", - "../vite.config.ts", - "../src/**/*.js", - "../src/**/*.ts", - "../src/**/*.svelte", - "../tests/**/*.js", - "../tests/**/*.ts", - "../tests/**/*.svelte" - ], - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias - // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/examples/aws-svelte-redis/vite.config.ts b/examples/aws-svelte-redis/vite.config.ts deleted file mode 100644 index bbf8c7da43..0000000000 --- a/examples/aws-svelte-redis/vite.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [sveltekit()] -}); diff --git a/examples/aws-swift/.gitignore b/examples/aws-swift/.gitignore deleted file mode 100644 index 170c6abc12..0000000000 --- a/examples/aws-swift/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.DS_Store -/.build -/Packages -xcuserdata/ -DerivedData/ -.swiftpm/configuration/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc - -# sst -.sst diff --git a/examples/aws-swift/Package.resolved b/examples/aws-swift/Package.resolved deleted file mode 100644 index cdd70ce01d..0000000000 --- a/examples/aws-swift/Package.resolved +++ /dev/null @@ -1,69 +0,0 @@ -{ - "originHash" : "3450710b2977c7d009c49e0f4520bf340c82a58cf41f2fbcfa9012df78a27936", - "pins" : [ - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "cd142fd2f64be2100422d658e7411e39489da985", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-aws-lambda-events", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/swift-aws-lambda-events.git", - "state" : { - "branch" : "main", - "revision" : "5b4633d1cc511a179ace6793d45fb973232b2c6c" - } - }, - { - "identity" : "swift-aws-lambda-runtime", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/swift-aws-lambda-runtime.git", - "state" : { - "branch" : "main", - "revision" : "e6a59c2cf0f35740d4ea72a702f69e45c20a974d" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5", - "version" : "1.5.4" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", - "state" : { - "revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982", - "version" : "2.64.0" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "025bcb1165deab2e20d4eaba79967ce73013f496", - "version" : "1.2.1" - } - } - ], - "version" : 3 -} diff --git a/examples/aws-swift/Package.swift b/examples/aws-swift/Package.swift deleted file mode 100644 index 00ce5fb110..0000000000 --- a/examples/aws-swift/Package.swift +++ /dev/null @@ -1,23 +0,0 @@ -// swift-tools-version: 5.10 - -import PackageDescription - -let package = Package( - name: "swift", - platforms: [ - .macOS(.v14) - ], - dependencies: [ - .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"), - .package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main"), - ], - targets: [ - .executableTarget( - name: "app", - dependencies: [ - .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), - .product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"), - ] - ) - ] -) diff --git a/examples/aws-swift/Sources/App.swift b/examples/aws-swift/Sources/App.swift deleted file mode 100644 index 0ca9f498f3..0000000000 --- a/examples/aws-swift/Sources/App.swift +++ /dev/null @@ -1,15 +0,0 @@ -import AWSLambdaEvents -import AWSLambdaRuntime - -@main -struct App: SimpleLambdaHandler { - func handle( - _ event: APIGatewayV2Request, context: LambdaContext - ) async throws -> APIGatewayV2Response { - .init( - statusCode: .ok, - headers: ["Content-Type": "text/plain"], - body: "Hello, Swift" - ) - } -} diff --git a/examples/aws-swift/sst.config.ts b/examples/aws-swift/sst.config.ts deleted file mode 100644 index 7ed8591bfd..0000000000 --- a/examples/aws-swift/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -const swiftVersion = "5.10"; - -/** - * ## Swift in Lambda - * - * Deploys a simple Swift application to Lambda using the `al2023` runtime. - * - * :::note - * Building this function requires Docker. - * ::: - * - * Check out the README in the repo for more details. - */ -export default $config({ - app(input) { - return { - name: "aws-swift", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const swift = new sst.aws.Function("Swift", { - runtime: "provided.al2023", - architecture: process.arch === "arm64" ? "arm64" : "x86_64", - bundle: build("app"), - handler: "bootstrap", - url: true, - }); - const router = new sst.aws.Router("SwiftRouter", { - routes: { - "/*": swift.url, - }, - domain: "swift.dev.sst.dev", - }); - return { - url: router.url, - }; - }, -}); - -function build(target: string) { - require("child_process").execSync(` - swift package --disable-sandbox archive --products ${target} --swift-version ${swiftVersion} - mkdir -p .build/lambda/${target} - cp .build/release/${target} .build/lambda/${target}/bootstrap - `); - return `.build/lambda/${target}`; -} diff --git a/examples/aws-t3/.eslintrc.cjs b/examples/aws-t3/.eslintrc.cjs deleted file mode 100644 index 88c180dda5..0000000000 --- a/examples/aws-t3/.eslintrc.cjs +++ /dev/null @@ -1,61 +0,0 @@ -/** @type {import("eslint").Linter.Config} */ -const config = { - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": true - }, - "plugins": [ - "@typescript-eslint", - "drizzle" - ], - "extends": [ - "next/core-web-vitals", - "plugin:@typescript-eslint/recommended-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked" - ], - "rules": { - "@typescript-eslint/array-type": "off", - "@typescript-eslint/consistent-type-definitions": "off", - "@typescript-eslint/consistent-type-imports": [ - "warn", - { - "prefer": "type-imports", - "fixStyle": "inline-type-imports" - } - ], - "@typescript-eslint/no-unused-vars": [ - "warn", - { - "argsIgnorePattern": "^_" - } - ], - "@typescript-eslint/require-await": "off", - "@typescript-eslint/no-misused-promises": [ - "error", - { - "checksVoidReturn": { - "attributes": false - } - } - ], - "drizzle/enforce-delete-with-where": [ - "error", - { - "drizzleObjectName": [ - "db", - "ctx.db" - ] - } - ], - "drizzle/enforce-update-with-where": [ - "error", - { - "drizzleObjectName": [ - "db", - "ctx.db" - ] - } - ] - } -} -module.exports = config; \ No newline at end of file diff --git a/examples/aws-t3/.gitignore b/examples/aws-t3/.gitignore deleted file mode 100644 index 9b3f2f5fbc..0000000000 --- a/examples/aws-t3/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# database -/prisma/db.sqlite -/prisma/db.sqlite-journal -db.sqlite - -# next.js -/.next/ -/out/ -next-env.d.ts - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# local env files -# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables -.env -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo - -# idea files -.idea - -# sst -.sst - - -# open-next -.open-next diff --git a/examples/aws-t3/drizzle.config.ts b/examples/aws-t3/drizzle.config.ts deleted file mode 100644 index d66cca49e1..0000000000 --- a/examples/aws-t3/drizzle.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { type Config } from "drizzle-kit"; - -export default { - schema: "./src/server/db/schema.ts", - dialect: "postgresql", - dbCredentials: { - ssl: { - rejectUnauthorized: false, - }, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, - tablesFilter: ["aws-t3_*"], -} satisfies Config; diff --git a/examples/aws-t3/next.config.js b/examples/aws-t3/next.config.js deleted file mode 100644 index 9bfe4a0e2a..0000000000 --- a/examples/aws-t3/next.config.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful - * for Docker builds. - */ -await import("./src/env.js"); - -/** @type {import("next").NextConfig} */ -const config = {}; - -export default config; diff --git a/examples/aws-t3/package.json b/examples/aws-t3/package.json deleted file mode 100644 index 101bfcffd5..0000000000 --- a/examples/aws-t3/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "aws-t3", - "version": "0.1.0", - "private": true, - "type": "module", - "scripts": { - "build": "next build", - "db:generate": "sst shell drizzle-kit generate", - "db:migrate": "sst shell drizzle-kit migrate", - "db:push": "sst shell drizzle-kit push", - "db:studio": "sst shell drizzle-kit studio", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@t3-oss/env-nextjs": "^0.10.1", - "@tanstack/react-query": "^5.50.0", - "@trpc/client": "^11.0.0-rc.446", - "@trpc/react-query": "^11.0.0-rc.446", - "@trpc/server": "^11.0.0-rc.446", - "drizzle-orm": "^0.35.1", - "geist": "^1.3.0", - "next": "^14.2.4", - "pg": "^8.13.1", - "postgres": "^3.4.4", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "server-only": "^0.0.1", - "sst": "file:../../sdk/js", - "superjson": "^2.2.1", - "zod": "^3.23.3" - }, - "devDependencies": { - "@types/eslint": "^8.56.10", - "@types/node": "^20.14.10", - "@types/pg": "^8.11.10", - "@types/react": "^18.3.3", - "@types/react-dom": "^18.3.0", - "@typescript-eslint/eslint-plugin": "^8.1.0", - "@typescript-eslint/parser": "^8.1.0", - "drizzle-kit": "^0.26.2", - "eslint": "^8.57.0", - "eslint-config-next": "^14.2.4", - "eslint-plugin-drizzle": "^0.2.3", - "postcss": "^8.4.39", - "prettier": "^3.3.2", - "prettier-plugin-tailwindcss": "^0.6.5", - "tailwindcss": "^3.4.3", - "typescript": "^5.5.3" - }, - "ct3aMetadata": { - "initVersion": "7.37.0" - }, - "packageManager": "npm@10.2.4" -} diff --git a/examples/aws-t3/postcss.config.cjs b/examples/aws-t3/postcss.config.cjs deleted file mode 100644 index 4cdb2f430f..0000000000 --- a/examples/aws-t3/postcss.config.cjs +++ /dev/null @@ -1,7 +0,0 @@ -const config = { - plugins: { - tailwindcss: {}, - }, -}; - -module.exports = config; diff --git a/examples/aws-t3/prettier.config.js b/examples/aws-t3/prettier.config.js deleted file mode 100644 index b2d59b460f..0000000000 --- a/examples/aws-t3/prettier.config.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */ -const config = { - plugins: ["prettier-plugin-tailwindcss"], -}; - -export default config; diff --git a/examples/aws-t3/public/favicon.ico b/examples/aws-t3/public/favicon.ico deleted file mode 100644 index 60c702aac1..0000000000 Binary files a/examples/aws-t3/public/favicon.ico and /dev/null differ diff --git a/examples/aws-t3/src/app/_components/post.tsx b/examples/aws-t3/src/app/_components/post.tsx deleted file mode 100644 index ebe15eab4a..0000000000 --- a/examples/aws-t3/src/app/_components/post.tsx +++ /dev/null @@ -1,50 +0,0 @@ -"use client"; - -import { useState } from "react"; - -import { api } from "~/trpc/react"; - -export function LatestPost() { - const [latestPost] = api.post.getLatest.useSuspenseQuery(); - - const utils = api.useUtils(); - const [name, setName] = useState(""); - const createPost = api.post.create.useMutation({ - onSuccess: async () => { - await utils.post.invalidate(); - setName(""); - }, - }); - - return ( -
- {latestPost ? ( -

Your most recent post: {latestPost.name}

- ) : ( -

You have no posts yet.

- )} -
{ - e.preventDefault(); - createPost.mutate({ name }); - }} - className="flex flex-col gap-2" - > - setName(e.target.value)} - className="w-full rounded-full px-4 py-2 text-black" - /> - -
-
- ); -} diff --git a/examples/aws-t3/src/app/api/trpc/[trpc]/route.ts b/examples/aws-t3/src/app/api/trpc/[trpc]/route.ts deleted file mode 100644 index 5fbd827d90..0000000000 --- a/examples/aws-t3/src/app/api/trpc/[trpc]/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; -import { type NextRequest } from "next/server"; - -import { env } from "~/env"; -import { appRouter } from "~/server/api/root"; -import { createTRPCContext } from "~/server/api/trpc"; - -/** - * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when - * handling a HTTP request (e.g. when you make requests from Client Components). - */ -const createContext = async (req: NextRequest) => { - return createTRPCContext({ - headers: req.headers, - }); -}; - -const handler = (req: NextRequest) => - fetchRequestHandler({ - endpoint: "/api/trpc", - req, - router: appRouter, - createContext: () => createContext(req), - onError: - env.NODE_ENV === "development" - ? ({ path, error }) => { - console.error( - `❌ tRPC failed on ${path ?? ""}: ${error.message}` - ); - } - : undefined, - }); - -export { handler as GET, handler as POST }; diff --git a/examples/aws-t3/src/app/layout.tsx b/examples/aws-t3/src/app/layout.tsx deleted file mode 100644 index c2215fff12..0000000000 --- a/examples/aws-t3/src/app/layout.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import "~/styles/globals.css"; - -import { GeistSans } from "geist/font/sans"; -import { type Metadata } from "next"; - -import { TRPCReactProvider } from "~/trpc/react"; - -export const metadata: Metadata = { - title: "Create T3 App", - description: "Generated by create-t3-app", - icons: [{ rel: "icon", url: "/favicon.ico" }], -}; - -export default function RootLayout({ - children, -}: Readonly<{ children: React.ReactNode }>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-t3/src/app/page.tsx b/examples/aws-t3/src/app/page.tsx deleted file mode 100644 index d7121d83d6..0000000000 --- a/examples/aws-t3/src/app/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Link from "next/link"; - -import { LatestPost } from "~/app/_components/post"; -import { api, HydrateClient } from "~/trpc/server"; - -export default async function Home() { - const hello = await api.post.hello({ text: "from tRPC" }); - - void api.post.getLatest.prefetch(); - - return ( - -
-
-

- Create T3 App -

-
- -

First Steps β†’

-
- Just the basics - Everything you need to know to set up your - database and authentication. -
- - -

Documentation β†’

-
- Learn more about Create T3 App, the libraries it uses, and how - to deploy it. -
- -
-
-

- {hello ? hello.greeting : "Loading tRPC query..."} -

-
- - -
-
-
- ); -} diff --git a/examples/aws-t3/src/env.js b/examples/aws-t3/src/env.js deleted file mode 100644 index c884758c63..0000000000 --- a/examples/aws-t3/src/env.js +++ /dev/null @@ -1,44 +0,0 @@ -import { createEnv } from "@t3-oss/env-nextjs"; -import { z } from "zod"; - -export const env = createEnv({ - /** - * Specify your server-side environment variables schema here. This way you can ensure the app - * isn't built with invalid env vars. - */ - server: { - // DATABASE_URL: z.string().url(), - NODE_ENV: z - .enum(["development", "test", "production"]) - .default("development"), - }, - - /** - * Specify your client-side environment variables schema here. This way you can ensure the app - * isn't built with invalid env vars. To expose them to the client, prefix them with - * `NEXT_PUBLIC_`. - */ - client: { - // NEXT_PUBLIC_CLIENTVAR: z.string(), - }, - - /** - * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g. - * middlewares) or client-side so we need to destruct manually. - */ - runtimeEnv: { - // DATABASE_URL: process.env.DATABASE_URL, - NODE_ENV: process.env.NODE_ENV, - // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, - }, - /** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially - * useful for Docker builds. - */ - skipValidation: !!process.env.SKIP_ENV_VALIDATION, - /** - * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and - * `SOME_VAR=''` will throw an error. - */ - emptyStringAsUndefined: true, -}); diff --git a/examples/aws-t3/src/server/api/root.ts b/examples/aws-t3/src/server/api/root.ts deleted file mode 100644 index b341fc4d64..0000000000 --- a/examples/aws-t3/src/server/api/root.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { postRouter } from "~/server/api/routers/post"; -import { createCallerFactory, createTRPCRouter } from "~/server/api/trpc"; - -/** - * This is the primary router for your server. - * - * All routers added in /api/routers should be manually added here. - */ -export const appRouter = createTRPCRouter({ - post: postRouter, -}); - -// export type definition of API -export type AppRouter = typeof appRouter; - -/** - * Create a server-side caller for the tRPC API. - * @example - * const trpc = createCaller(createContext); - * const res = await trpc.post.all(); - * ^? Post[] - */ -export const createCaller = createCallerFactory(appRouter); diff --git a/examples/aws-t3/src/server/api/routers/post.ts b/examples/aws-t3/src/server/api/routers/post.ts deleted file mode 100644 index 4bbf615b31..0000000000 --- a/examples/aws-t3/src/server/api/routers/post.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { z } from "zod"; - -import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; -import { posts } from "~/server/db/schema"; - -export const postRouter = createTRPCRouter({ - hello: publicProcedure - .input(z.object({ text: z.string() })) - .query(({ input }) => { - return { - greeting: `Hello ${input.text}`, - }; - }), - - create: publicProcedure - .input(z.object({ name: z.string().min(1) })) - .mutation(async ({ ctx, input }) => { - await ctx.db.insert(posts).values({ - name: input.name, - }); - }), - - getLatest: publicProcedure.query(async ({ ctx }) => { - const post = await ctx.db.query.posts.findFirst({ - orderBy: (posts, { desc }) => [desc(posts.createdAt)], - }); - - return post ?? null; - }), -}); diff --git a/examples/aws-t3/src/server/api/trpc.ts b/examples/aws-t3/src/server/api/trpc.ts deleted file mode 100644 index 4e24ba4373..0000000000 --- a/examples/aws-t3/src/server/api/trpc.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS: - * 1. You want to modify request context (see Part 1). - * 2. You want to create a new middleware or type of procedure (see Part 3). - * - * TL;DR - This is where all the tRPC server stuff is created and plugged in. The pieces you will - * need to use are documented accordingly near the end. - */ -import { initTRPC } from "@trpc/server"; -import superjson from "superjson"; -import { ZodError } from "zod"; - -import { db } from "~/server/db"; - -/** - * 1. CONTEXT - * - * This section defines the "contexts" that are available in the backend API. - * - * These allow you to access things when processing a request, like the database, the session, etc. - * - * This helper generates the "internals" for a tRPC context. The API handler and RSC clients each - * wrap this and provides the required context. - * - * @see https://trpc.io/docs/server/context - */ -export const createTRPCContext = async (opts: { headers: Headers }) => { - return { - db, - ...opts, - }; -}; - -/** - * 2. INITIALIZATION - * - * This is where the tRPC API is initialized, connecting the context and transformer. We also parse - * ZodErrors so that you get typesafety on the frontend if your procedure fails due to validation - * errors on the backend. - */ -const t = initTRPC.context().create({ - transformer: superjson, - errorFormatter({ shape, error }) { - return { - ...shape, - data: { - ...shape.data, - zodError: - error.cause instanceof ZodError ? error.cause.flatten() : null, - }, - }; - }, -}); - -/** - * Create a server-side caller. - * - * @see https://trpc.io/docs/server/server-side-calls - */ -export const createCallerFactory = t.createCallerFactory; - -/** - * 3. ROUTER & PROCEDURE (THE IMPORTANT BIT) - * - * These are the pieces you use to build your tRPC API. You should import these a lot in the - * "/src/server/api/routers" directory. - */ - -/** - * This is how you create new routers and sub-routers in your tRPC API. - * - * @see https://trpc.io/docs/router - */ -export const createTRPCRouter = t.router; - -/** - * Middleware for timing procedure execution and adding an artificial delay in development. - * - * You can remove this if you don't like it, but it can help catch unwanted waterfalls by simulating - * network latency that would occur in production but not in local development. - */ -const timingMiddleware = t.middleware(async ({ next, path }) => { - const start = Date.now(); - - if (t._config.isDev) { - // artificial delay in dev - const waitMs = Math.floor(Math.random() * 400) + 100; - await new Promise((resolve) => setTimeout(resolve, waitMs)); - } - - const result = await next(); - - const end = Date.now(); - console.log(`[TRPC] ${path} took ${end - start}ms to execute`); - - return result; -}); - -/** - * Public (unauthenticated) procedure - * - * This is the base piece you use to build new queries and mutations on your tRPC API. It does not - * guarantee that a user querying is authorized, but you can still access user session data if they - * are logged in. - */ -export const publicProcedure = t.procedure.use(timingMiddleware); diff --git a/examples/aws-t3/src/server/db/index.ts b/examples/aws-t3/src/server/db/index.ts deleted file mode 100644 index 580dbfc0ff..0000000000 --- a/examples/aws-t3/src/server/db/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Pool } from "pg"; -import { Resource } from "sst"; -import { drizzle } from "drizzle-orm/node-postgres"; - -import * as schema from "./schema"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-t3/src/server/db/schema.ts b/examples/aws-t3/src/server/db/schema.ts deleted file mode 100644 index 19ffe2a0c7..0000000000 --- a/examples/aws-t3/src/server/db/schema.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Example model schema from the Drizzle docs -// https://orm.drizzle.team/docs/sql-schema-declaration - -import { sql } from "drizzle-orm"; -import { - index, - pgTableCreator, - serial, - timestamp, - varchar, -} from "drizzle-orm/pg-core"; - -/** - * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same - * database instance for multiple projects. - * - * @see https://orm.drizzle.team/docs/goodies#multi-project-schema - */ -export const createTable = pgTableCreator((name) => `aws-t3_${name}`); - -export const posts = createTable( - "post", - { - id: serial("id").primaryKey(), - name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at", { withTimezone: true }) - .default(sql`CURRENT_TIMESTAMP`) - .notNull(), - updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate( - () => new Date() - ), - }, - (example) => ({ - nameIndex: index("name_idx").on(example.name), - }) -); diff --git a/examples/aws-t3/src/styles/globals.css b/examples/aws-t3/src/styles/globals.css deleted file mode 100644 index b5c61c9567..0000000000 --- a/examples/aws-t3/src/styles/globals.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; diff --git a/examples/aws-t3/src/trpc/query-client.ts b/examples/aws-t3/src/trpc/query-client.ts deleted file mode 100644 index bda64397ca..0000000000 --- a/examples/aws-t3/src/trpc/query-client.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { - defaultShouldDehydrateQuery, - QueryClient, -} from "@tanstack/react-query"; -import SuperJSON from "superjson"; - -export const createQueryClient = () => - new QueryClient({ - defaultOptions: { - queries: { - // With SSR, we usually want to set some default staleTime - // above 0 to avoid refetching immediately on the client - staleTime: 30 * 1000, - }, - dehydrate: { - serializeData: SuperJSON.serialize, - shouldDehydrateQuery: (query) => - defaultShouldDehydrateQuery(query) || - query.state.status === "pending", - }, - hydrate: { - deserializeData: SuperJSON.deserialize, - }, - }, - }); diff --git a/examples/aws-t3/src/trpc/react.tsx b/examples/aws-t3/src/trpc/react.tsx deleted file mode 100644 index 8c0521a74e..0000000000 --- a/examples/aws-t3/src/trpc/react.tsx +++ /dev/null @@ -1,76 +0,0 @@ -"use client"; - -import { QueryClientProvider, type QueryClient } from "@tanstack/react-query"; -import { loggerLink, unstable_httpBatchStreamLink } from "@trpc/client"; -import { createTRPCReact } from "@trpc/react-query"; -import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server"; -import { useState } from "react"; -import SuperJSON from "superjson"; - -import { type AppRouter } from "~/server/api/root"; -import { createQueryClient } from "./query-client"; - -let clientQueryClientSingleton: QueryClient | undefined = undefined; -const getQueryClient = () => { - if (typeof window === "undefined") { - // Server: always make a new query client - return createQueryClient(); - } - // Browser: use singleton pattern to keep the same query client - return (clientQueryClientSingleton ??= createQueryClient()); -}; - -export const api = createTRPCReact(); - -/** - * Inference helper for inputs. - * - * @example type HelloInput = RouterInputs['example']['hello'] - */ -export type RouterInputs = inferRouterInputs; - -/** - * Inference helper for outputs. - * - * @example type HelloOutput = RouterOutputs['example']['hello'] - */ -export type RouterOutputs = inferRouterOutputs; - -export function TRPCReactProvider(props: { children: React.ReactNode }) { - const queryClient = getQueryClient(); - - const [trpcClient] = useState(() => - api.createClient({ - links: [ - loggerLink({ - enabled: (op) => - process.env.NODE_ENV === "development" || - (op.direction === "down" && op.result instanceof Error), - }), - unstable_httpBatchStreamLink({ - transformer: SuperJSON, - url: getBaseUrl() + "/api/trpc", - headers: () => { - const headers = new Headers(); - headers.set("x-trpc-source", "nextjs-react"); - return headers; - }, - }), - ], - }) - ); - - return ( - - - {props.children} - - - ); -} - -function getBaseUrl() { - if (typeof window !== "undefined") return window.location.origin; - if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; - return `http://localhost:${process.env.PORT ?? 3000}`; -} diff --git a/examples/aws-t3/src/trpc/server.ts b/examples/aws-t3/src/trpc/server.ts deleted file mode 100644 index 59300a638b..0000000000 --- a/examples/aws-t3/src/trpc/server.ts +++ /dev/null @@ -1,30 +0,0 @@ -import "server-only"; - -import { createHydrationHelpers } from "@trpc/react-query/rsc"; -import { headers } from "next/headers"; -import { cache } from "react"; - -import { createCaller, type AppRouter } from "~/server/api/root"; -import { createTRPCContext } from "~/server/api/trpc"; -import { createQueryClient } from "./query-client"; - -/** - * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when - * handling a tRPC call from a React Server Component. - */ -const createContext = cache(() => { - const heads = new Headers(headers()); - heads.set("x-trpc-source", "rsc"); - - return createTRPCContext({ - headers: heads, - }); -}); - -const getQueryClient = cache(createQueryClient); -const caller = createCaller(createContext); - -export const { trpc: api, HydrateClient } = createHydrationHelpers( - caller, - getQueryClient -); diff --git a/examples/aws-t3/sst.config.ts b/examples/aws-t3/sst.config.ts deleted file mode 100644 index 240886315c..0000000000 --- a/examples/aws-t3/sst.config.ts +++ /dev/null @@ -1,145 +0,0 @@ -/// - -/** - * ## T3 Stack in AWS - * - * Deploy [T3 stack](https://create.t3.gg) with Drizzle and Postgres to AWS. - * - * This example was created using `create-t3-app` and the following options: tRPC, Drizzle, - * no auth, Tailwind, Postgres, and the App Router. - * - * Instead of a local database, we'll be using an RDS Postgres database. - * - * ```ts title="src/server/db/index.ts" {2-6} - * const pool = new Pool({ - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }); - * ``` - * - * Similarly, for Drizzle Kit. - * - * ```ts title="drizzle.config.ts" {8-12} - * export default { - * schema: "./src/server/db/schema.ts", - * dialect: "postgresql", - * dbCredentials: { - * ssl: { - * rejectUnauthorized: false, - * }, - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }, - * tablesFilter: ["aws-t3_*"], - * } satisfies Config; - * ``` - * - * In our Next.js app we can access our Postgres database because we [link them](/docs/linking/) - * both. We don't need to use our `.env` files. - * - * ```ts title="sst.config.ts" {5} - * const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - * - * new sst.aws.Nextjs("MyWeb", { - * vpc, - * link: [rds] - * }); - * ``` - * - * To run this in dev mode run: - * - * ```bash - * npm install - * npx sst dev - * ``` - * - * It'll take a few minutes to deploy the database and the VPC. - * - * This also starts a tunnel to let your local machine connect to the RDS Postgres database. - * Make sure you have it installed, you only need to do this once for your local machine. - * - * ```bash - * sudo npx sst tunnel install - * ``` - * - * Now in a new terminal you can run the database migrations. - * - * ```bash - * npm run db:push - * ``` - * - * We also have the Drizzle Studio start automatically in dev mode under the **Studio** tab. - * - * ```ts title="sst.config.ts" - * new sst.x.DevCommand("Studio", { - * link: [rds], - * dev: { - * command: "npx drizzle-kit studio", - * }, - * }); - * ``` - * - * And to make sure our credentials are available, we update our `package.json` - * with the [`sst shell`](/docs/reference/cli) CLI. - * - * ```json title="package.json" - * "db:generate": "sst shell drizzle-kit generate", - * "db:migrate": "sst shell drizzle-kit migrate", - * "db:push": "sst shell drizzle-kit push", - * "db:studio": "sst shell drizzle-kit studio", - * ``` - * - * So running `npm run db:push` will run Drizzle Kit with the right credentials. - * - * To deploy this to production run: - * - * ```bash - * npx sst deploy --stage production - * ``` - * - * Then run the migrations. - * - * ```bash - * npx sst shell --stage production npx drizzle-kit push - * ``` - * - * If you are running this locally, you'll need to have a tunnel running. - * - * ```bash - * npx sst tunnel --stage production - * ``` - * - * If you are doing this in a CI/CD pipeline, you'd want your build containers to be in the - * same VPC. - */ -export default $config({ - app(input) { - return { - name: "aws-t3", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - - new sst.aws.Nextjs("MyWeb", { - vpc, - link: [rds] - }); - - new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, - }); - }, -}); diff --git a/examples/aws-t3/start-database.sh b/examples/aws-t3/start-database.sh deleted file mode 100755 index 610f54b3f5..0000000000 --- a/examples/aws-t3/start-database.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# Use this script to start a docker container for a local development database - -# TO RUN ON WINDOWS: -# 1. Install WSL (Windows Subsystem for Linux) - https://learn.microsoft.com/en-us/windows/wsl/install -# 2. Install Docker Desktop for Windows - https://docs.docker.com/docker-for-windows/install/ -# 3. Open WSL - `wsl` -# 4. Run this script - `./start-database.sh` - -# On Linux and macOS you can run this script directly - `./start-database.sh` - -DB_CONTAINER_NAME="aws-t3-postgres" - -if ! [ -x "$(command -v docker)" ]; then - echo -e "Docker is not installed. Please install docker and try again.\nDocker install guide: https://docs.docker.com/engine/install/" - exit 1 -fi - -if [ "$(docker ps -q -f name=$DB_CONTAINER_NAME)" ]; then - echo "Database container '$DB_CONTAINER_NAME' already running" - exit 0 -fi - -if [ "$(docker ps -q -a -f name=$DB_CONTAINER_NAME)" ]; then - docker start "$DB_CONTAINER_NAME" - echo "Existing database container '$DB_CONTAINER_NAME' started" - exit 0 -fi - -# import env variables from .env -set -a -source .env - -DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}') -DB_PORT=$(echo "$DATABASE_URL" | awk -F':' '{print $4}' | awk -F'\/' '{print $1}') - -if [ "$DB_PASSWORD" = "password" ]; then - echo "You are using the default database password" - read -p "Should we generate a random password for you? [y/N]: " -r REPLY - if ! [[ $REPLY =~ ^[Yy]$ ]]; then - echo "Please change the default password in the .env file and try again" - exit 1 - fi - # Generate a random URL-safe password - DB_PASSWORD=$(openssl rand -base64 12 | tr '+/' '-_') - sed -i -e "s#:password@#:$DB_PASSWORD@#" .env -fi - -docker run -d \ - --name $DB_CONTAINER_NAME \ - -e POSTGRES_USER="postgres" \ - -e POSTGRES_PASSWORD="$DB_PASSWORD" \ - -e POSTGRES_DB=aws-t3 \ - -p "$DB_PORT":5432 \ - docker.io/postgres && echo "Database container '$DB_CONTAINER_NAME' was successfully created" diff --git a/examples/aws-t3/tailwind.config.ts b/examples/aws-t3/tailwind.config.ts deleted file mode 100644 index 5fd44e8f23..0000000000 --- a/examples/aws-t3/tailwind.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { type Config } from "tailwindcss"; -import { fontFamily } from "tailwindcss/defaultTheme"; - -export default { - content: ["./src/**/*.tsx"], - theme: { - extend: { - fontFamily: { - sans: ["var(--font-geist-sans)", ...fontFamily.sans], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-t3/tsconfig.json b/examples/aws-t3/tsconfig.json deleted file mode 100644 index ba905904d9..0000000000 --- a/examples/aws-t3/tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "compilerOptions": { - /* Base Options: */ - "esModuleInterop": true, - "skipLibCheck": true, - "target": "es2022", - "allowJs": true, - "resolveJsonModule": true, - "moduleDetection": "force", - "isolatedModules": true, - - /* Strictness */ - "strict": true, - "noUncheckedIndexedAccess": true, - "checkJs": true, - - /* Bundled projects */ - "lib": ["dom", "dom.iterable", "ES2022"], - "noEmit": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "jsx": "preserve", - "plugins": [{ "name": "next" }], - "incremental": true, - - /* Path Aliases */ - "baseUrl": ".", - "paths": { - "~/*": ["./src/*"] - } - }, - "include": [ - ".eslintrc.cjs", - "next-env.d.ts", - "**/*.ts", - "**/*.tsx", - "**/*.cjs", - "**/*.js", - ".next/types/**/*.ts" - ], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-tanstack-start/.cta.json b/examples/aws-tanstack-start/.cta.json deleted file mode 100644 index 82493fe963..0000000000 --- a/examples/aws-tanstack-start/.cta.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "projectName": "app", - "mode": "file-router", - "typescript": true, - "tailwind": true, - "packageManager": "pnpm", - "addOnOptions": {}, - "git": true, - "version": 1, - "framework": "react-cra", - "chosenAddOns": [ - "eslint", - "nitro", - "start", - "form", - "shadcn", - "tanstack-query" - ] -} \ No newline at end of file diff --git a/examples/aws-tanstack-start/.cursorrules b/examples/aws-tanstack-start/.cursorrules deleted file mode 100644 index 1472639b19..0000000000 --- a/examples/aws-tanstack-start/.cursorrules +++ /dev/null @@ -1,7 +0,0 @@ -# shadcn instructions - -Use the latest version of Shadcn to install new components, like this command to add a button component: - -```bash -pnpx shadcn@latest add button -``` diff --git a/examples/aws-tanstack-start/.gitignore b/examples/aws-tanstack-start/.gitignore deleted file mode 100644 index b4687f1d19..0000000000 --- a/examples/aws-tanstack-start/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.sst -node_modules -.DS_Store -dist -dist-ssr -*.local -count.txt -.env -.nitro -.tanstack -.wrangler -.output -.vinxi -todos.json diff --git a/examples/aws-tanstack-start/.prettierignore b/examples/aws-tanstack-start/.prettierignore deleted file mode 100644 index 5322d7feea..0000000000 --- a/examples/aws-tanstack-start/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -package-lock.json -pnpm-lock.yaml -yarn.lock \ No newline at end of file diff --git a/examples/aws-tanstack-start/.vscode/settings.json b/examples/aws-tanstack-start/.vscode/settings.json deleted file mode 100644 index 00b5278e58..0000000000 --- a/examples/aws-tanstack-start/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "files.watcherExclude": { - "**/routeTree.gen.ts": true - }, - "search.exclude": { - "**/routeTree.gen.ts": true - }, - "files.readonlyInclude": { - "**/routeTree.gen.ts": true - } -} diff --git a/examples/aws-tanstack-start/components.json b/examples/aws-tanstack-start/components.json deleted file mode 100644 index 6998bdfb97..0000000000 --- a/examples/aws-tanstack-start/components.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "new-york", - "rsc": false, - "tsx": true, - "tailwind": { - "config": "", - "css": "src/styles.css", - "baseColor": "zinc", - "cssVariables": true, - "prefix": "" - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils", - "ui": "@/components/ui", - "lib": "@/lib", - "hooks": "@/hooks" - }, - "iconLibrary": "lucide" -} \ No newline at end of file diff --git a/examples/aws-tanstack-start/eslint.config.js b/examples/aws-tanstack-start/eslint.config.js deleted file mode 100644 index 676b32a87f..0000000000 --- a/examples/aws-tanstack-start/eslint.config.js +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-check - -import { tanstackConfig } from '@tanstack/eslint-config' - -export default [...tanstackConfig] diff --git a/examples/aws-tanstack-start/package.json b/examples/aws-tanstack-start/package.json deleted file mode 100644 index 854758a5ea..0000000000 --- a/examples/aws-tanstack-start/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "aws-tanstack-start", - "private": true, - "type": "module", - "scripts": { - "dev": "vite dev --port 3000", - "build": "vite build", - "serve": "vite preview", - "test": "vitest run", - "lint": "eslint", - "format": "prettier", - "check": "prettier --write . && eslint --fix" - }, - "dependencies": { - "@radix-ui/react-label": "^2.1.8", - "@radix-ui/react-select": "^2.2.6", - "@radix-ui/react-slider": "^1.3.6", - "@radix-ui/react-slot": "^1.2.4", - "@radix-ui/react-switch": "^1.2.6", - "@tailwindcss/vite": "^4.0.6", - "@tanstack/react-devtools": "^0.7.0", - "@tanstack/react-form": "^1.0.0", - "@tanstack/react-query": "^5.66.5", - "@tanstack/react-query-devtools": "^5.84.2", - "@tanstack/react-router": "^1.132.0", - "@tanstack/react-router-devtools": "^1.132.0", - "@tanstack/react-router-ssr-query": "^1.131.7", - "@tanstack/react-start": "^1.132.0", - "@tanstack/router-plugin": "^1.132.0", - "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", - "lucide-react": "^0.544.0", - "nitro": "latest", - "react": "^19.2.0", - "react-dom": "^19.2.0", - "sst": "file:../../sdk/js", - "tailwind-merge": "^3.0.2", - "tailwindcss": "^4.0.6", - "tw-animate-css": "^1.3.6", - "vite-tsconfig-paths": "^5.1.4", - "zod": "^4.1.11" - }, - "devDependencies": { - "@tanstack/devtools-vite": "^0.3.11", - "@tanstack/eslint-config": "^0.3.0", - "@testing-library/dom": "^10.4.0", - "@testing-library/react": "^16.2.0", - "@types/node": "^22.10.2", - "@types/react": "^19.2.0", - "@types/react-dom": "^19.2.0", - "@vitejs/plugin-react": "^5.0.4", - "jsdom": "^27.0.0", - "prettier": "^3.5.3", - "typescript": "^5.7.2", - "vite": "^7.1.7", - "vitest": "^3.0.5", - "web-vitals": "^5.1.0" - } -} \ No newline at end of file diff --git a/examples/aws-tanstack-start/prettier.config.js b/examples/aws-tanstack-start/prettier.config.js deleted file mode 100644 index aea1c4804b..0000000000 --- a/examples/aws-tanstack-start/prettier.config.js +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-check - -/** @type {import('prettier').Config} */ -const config = { - semi: false, - singleQuote: true, - trailingComma: "all", -}; - -export default config; diff --git a/examples/aws-tanstack-start/public/manifest.json b/examples/aws-tanstack-start/public/manifest.json deleted file mode 100644 index 078ef50116..0000000000 --- a/examples/aws-tanstack-start/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "TanStack App", - "name": "Create TanStack App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/aws-tanstack-start/public/tanstack-circle-logo.png b/examples/aws-tanstack-start/public/tanstack-circle-logo.png deleted file mode 100644 index 9db3e67bad..0000000000 Binary files a/examples/aws-tanstack-start/public/tanstack-circle-logo.png and /dev/null differ diff --git a/examples/aws-tanstack-start/public/tanstack-word-logo-white.svg b/examples/aws-tanstack-start/public/tanstack-word-logo-white.svg deleted file mode 100644 index b6ec5086c2..0000000000 --- a/examples/aws-tanstack-start/public/tanstack-word-logo-white.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-tanstack-start/src/components/Header.tsx b/examples/aws-tanstack-start/src/components/Header.tsx deleted file mode 100644 index b6e0cd0d4f..0000000000 --- a/examples/aws-tanstack-start/src/components/Header.tsx +++ /dev/null @@ -1,217 +0,0 @@ -import { Link } from '@tanstack/react-router' - -import { useState } from 'react' -import { - ChevronDown, - ChevronRight, - ClipboardType, - Home, - Menu, - Network, - SquareFunction, - StickyNote, - X, -} from 'lucide-react' - -export default function Header() { - const [isOpen, setIsOpen] = useState(false) - const [groupedExpanded, setGroupedExpanded] = useState< - Record - >({}) - - return ( - <> -
- -

- - TanStack Logo - -

-
- - - - ) -} diff --git a/examples/aws-tanstack-start/src/components/demo.FormComponents.tsx b/examples/aws-tanstack-start/src/components/demo.FormComponents.tsx deleted file mode 100644 index 0419620dff..0000000000 --- a/examples/aws-tanstack-start/src/components/demo.FormComponents.tsx +++ /dev/null @@ -1,174 +0,0 @@ -import { useStore } from '@tanstack/react-form' - -import { useFieldContext, useFormContext } from '@/hooks/demo.form-context' - -import { Button } from '@/components/ui/button' -import { Input } from '@/components/ui/input' -import { Textarea as ShadcnTextarea } from '@/components/ui/textarea' -import * as ShadcnSelect from '@/components/ui/select' -import { Slider as ShadcnSlider } from '@/components/ui/slider' -import { Switch as ShadcnSwitch } from '@/components/ui/switch' -import { Label } from '@/components/ui/label' - -export function SubscribeButton({ label }: { label: string }) { - const form = useFormContext() - return ( - state.isSubmitting}> - {(isSubmitting) => ( - - )} - - ) -} - -function ErrorMessages({ - errors, -}: { - errors: Array -}) { - return ( - <> - {errors.map((error) => ( -
- {typeof error === 'string' ? error : error.message} -
- ))} - - ) -} - -export function TextField({ - label, - placeholder, -}: { - label: string - placeholder?: string -}) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- - field.handleChange(e.target.value)} - /> - {field.state.meta.isTouched && } -
- ) -} - -export function TextArea({ - label, - rows = 3, -}: { - label: string - rows?: number -}) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- - field.handleChange(e.target.value)} - /> - {field.state.meta.isTouched && } -
- ) -} - -export function Select({ - label, - values, - placeholder, -}: { - label: string - values: Array<{ label: string; value: string }> - placeholder?: string -}) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- field.handleChange(value)} - > - - - - - - {label} - {values.map((value) => ( - - {value.label} - - ))} - - - - {field.state.meta.isTouched && } -
- ) -} - -export function Slider({ label }: { label: string }) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- - field.handleChange(value[0])} - /> - {field.state.meta.isTouched && } -
- ) -} - -export function Switch({ label }: { label: string }) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
-
- field.handleChange(checked)} - /> - -
- {field.state.meta.isTouched && } -
- ) -} diff --git a/examples/aws-tanstack-start/src/components/ui/button.tsx b/examples/aws-tanstack-start/src/components/ui/button.tsx deleted file mode 100644 index 21409a0666..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/button.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" - -import { cn } from "@/lib/utils" - -const buttonVariants = cva( - "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", - { - variants: { - variant: { - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: - "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", - outline: - "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50", - secondary: - "bg-secondary text-secondary-foreground hover:bg-secondary/80", - ghost: - "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", - link: "text-primary underline-offset-4 hover:underline", - }, - size: { - default: "h-9 px-4 py-2 has-[>svg]:px-3", - sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5", - lg: "h-10 rounded-md px-6 has-[>svg]:px-4", - icon: "size-9", - "icon-sm": "size-8", - "icon-lg": "size-10", - }, - }, - defaultVariants: { - variant: "default", - size: "default", - }, - } -) - -function Button({ - className, - variant, - size, - asChild = false, - ...props -}: React.ComponentProps<"button"> & - VariantProps & { - asChild?: boolean - }) { - const Comp = asChild ? Slot : "button" - - return ( - - ) -} - -export { Button, buttonVariants } diff --git a/examples/aws-tanstack-start/src/components/ui/input.tsx b/examples/aws-tanstack-start/src/components/ui/input.tsx deleted file mode 100644 index 89169058d0..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/input.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -function Input({ className, type, ...props }: React.ComponentProps<"input">) { - return ( - - ) -} - -export { Input } diff --git a/examples/aws-tanstack-start/src/components/ui/label.tsx b/examples/aws-tanstack-start/src/components/ui/label.tsx deleted file mode 100644 index fb5fbc3eee..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/label.tsx +++ /dev/null @@ -1,24 +0,0 @@ -"use client" - -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" - -import { cn } from "@/lib/utils" - -function Label({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} - -export { Label } diff --git a/examples/aws-tanstack-start/src/components/ui/select.tsx b/examples/aws-tanstack-start/src/components/ui/select.tsx deleted file mode 100644 index d34798fafe..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/select.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import * as React from "react" -import * as SelectPrimitive from "@radix-ui/react-select" -import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" - -import { cn } from "@/lib/utils" - -function Select({ - ...props -}: React.ComponentProps) { - return -} - -function SelectGroup({ - ...props -}: React.ComponentProps) { - return -} - -function SelectValue({ - ...props -}: React.ComponentProps) { - return -} - -function SelectTrigger({ - className, - size = "default", - children, - ...props -}: React.ComponentProps & { - size?: "sm" | "default" -}) { - return ( - - {children} - - - - - ) -} - -function SelectContent({ - className, - children, - position = "popper", - align = "center", - ...props -}: React.ComponentProps) { - return ( - - - - - {children} - - - - - ) -} - -function SelectLabel({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} - -function SelectItem({ - className, - children, - ...props -}: React.ComponentProps) { - return ( - - - - - - - {children} - - ) -} - -function SelectSeparator({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} - -function SelectScrollUpButton({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - ) -} - -function SelectScrollDownButton({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - ) -} - -export { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectScrollDownButton, - SelectScrollUpButton, - SelectSeparator, - SelectTrigger, - SelectValue, -} diff --git a/examples/aws-tanstack-start/src/components/ui/slider.tsx b/examples/aws-tanstack-start/src/components/ui/slider.tsx deleted file mode 100644 index 1a1bd735a2..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/slider.tsx +++ /dev/null @@ -1,63 +0,0 @@ -"use client" - -import * as React from "react" -import * as SliderPrimitive from "@radix-ui/react-slider" - -import { cn } from "@/lib/utils" - -function Slider({ - className, - defaultValue, - value, - min = 0, - max = 100, - ...props -}: React.ComponentProps) { - const _values = React.useMemo( - () => - Array.isArray(value) - ? value - : Array.isArray(defaultValue) - ? defaultValue - : [min, max], - [value, defaultValue, min, max] - ) - - return ( - - - - - {Array.from({ length: _values.length }, (_, index) => ( - - ))} - - ) -} - -export { Slider } diff --git a/examples/aws-tanstack-start/src/components/ui/switch.tsx b/examples/aws-tanstack-start/src/components/ui/switch.tsx deleted file mode 100644 index b0363e3f86..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/switch.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import * as React from "react" -import * as SwitchPrimitive from "@radix-ui/react-switch" - -import { cn } from "@/lib/utils" - -function Switch({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - ) -} - -export { Switch } diff --git a/examples/aws-tanstack-start/src/components/ui/textarea.tsx b/examples/aws-tanstack-start/src/components/ui/textarea.tsx deleted file mode 100644 index 7f21b5e78a..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/textarea.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -function Textarea({ className, ...props }: React.ComponentProps<"textarea">) { - return ( - + + +``` + +There are a couple of things of note here. + +- We are rendering a textarea where the user can type in a comment. When they submit the form, we grab the comment text from the `FormData` and call our mutation hook, `addComment`. +- The button to submit the form is a custom component that comes with this starter, called `Button`. Aside from being styled, it allows us to display a little spinner when the request is being made. We set this using the `loading` prop. + +Let's import this `Button` component and a couple of other things. + + + +Replace the `useTypedQuery` import in `packages/web/pages/Article.tsx` with this: + + + +```ts title="packages/web/src/pages/Article.tsx" +import { useMemo } from "react"; +import { useTypedQuery, useTypedMutation } from "@my-sst-app/graphql/urql"; +import Button from "../components/Button"; +``` + +Our components also need some styles, let's add that next. + +--- + +## Style comments + + + +Add the following at the end of `packages/web/pages/Article.module.css`. + + + +```css title="packages/web/src/pages/Article.module.css" +.comments { + padding: 0; + margin: 1rem 0 0; + list-style: none; +} + +.comment { + padding: 0.75rem 0; + border-bottom: 1px solid var(--color-divider); +} + +.form { + margin-top: 1rem; +} + +.field { + width: 100%; + display: block; + max-width: 600px; +} + +.button { + margin-top: 1rem; +} +``` + +Now if you refresh the app, and head over to an article page, you'll see the comment form. + +--- + +## Test adding comments + +Try adding your first comment. + +![New comment added in the article page](/img/make-updates/new-comment-added-in-the-articles-page.png) + +You'll notice it gets rendered right away. And the button shows a little loading spinner while the request is being made. + +--- + +## Auto refetching queries + +If you've been following along closely, you might've noticed something interesting. We aren't doing anything special to render the newly added comment! + +The `addComment` mutation returns the type `Comment`. Recall that we told Urql that this `Comment` type has been cached as a part of the `article` query. + +```ts +const context = useMemo(() => ({ additionalTypenames: ["Comment"] }), []); +const [article] = useTypedQuery({ + ... +``` + +So it'll refetch this query in the background and the `useTypedQuery` hook will re-render the component. + +Urql also sets the `article.stale` flag to `true` while refetching. We use this flag to display the loading spinner on our button. + +```tsx {5} + +``` + +This allows us to show the loading spinner while the comment is being posted, and while the comments are refetched. + +
+Behind the scenes + +The `addComment` mutation returns an object with `__typename`, `Comment`. If you inspect the network requests, it'll look something like this. + +```json +{ + "data": { + "addComment": { + "id": "01GB6C5DK6YBDDYE9CSZGF8DN4", + "__typename": "Comment" + } + } +} +``` + +We als tell Urql that our `article` query contains the type `Comments` by passing in the `additionalTypenames` as a context. + +```ts +const context = useMemo(() => ({ additionalTypenames: ["Comment"] }), []); +``` + +Recall that we need to do this because initially the `article` query might not have any comments. So it won't be able to rely on the `__typename` that's returned. + +Now when Urql sees a mutation that affects the `Comment` type, it'll look for all the queries on the page that contain that type and refetch them in the background. + +
+ +--- + +Our app is now ready to be shipped! So let's deploy it to production! diff --git a/www/docs/learn/project-structure.md b/www/docs/learn/project-structure.md new file mode 100644 index 0000000000..6b084ae858 --- /dev/null +++ b/www/docs/learn/project-structure.md @@ -0,0 +1,221 @@ +--- +title: Project Structure +--- + +While we wait for our local environment to start up, let's look at the starter the [`create sst`](../packages/create-sst.md) CLI has set up for us. + +:::tip +This chapter goes into a lot of detail to help you get familiar with this setup. + +If you are just trying to get an overview of SST, feel free to skim this chapter and skip ahead. +::: + +--- + +## Monorepo + +Your project will look something like this. + +``` +my-sst-app +β”œβ”€ package.json +β”œβ”€ sst.config.ts +β”œβ”€ packages +β”‚Β Β β”œβ”€ core +β”‚Β Β β”‚ └─ migrations +β”‚Β Β β”œβ”€ functions +β”‚Β Β β”œβ”€ graphql +│  └─ web +└─ stacks +``` + +We are using a monorepo setup. We recommend using it because it's the best way to manage a growing project with interconnected parts (like the backend, frontend, and infrastructure). + +It may seem a bit heavy upfront but it makes it easy to add new features while keeping things organized. + +:::info +The `create sst` setup generates a [monorepo](https://en.wikipedia.org/wiki/Monorepo) + [Workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) setup. +::: + +We'll look at how our monorepo is split up with [Workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) below. But first, let's start by looking at what these directories do. + +--- + +## `stacks/` + +The `stacks/` directory contains the app's infrastructure as defined as code. Or what is known as [Infrastructure as Code](https://sst.dev/chapters/what-is-infrastructure-as-code.html) (IaC). SST by default uses TypeScript to define your infrastructure. You can also use JavaScript. + +We typically group related resources together into stacks. In the `stacks/` directory there are a couple of files: + +- `Database.ts` creates a PostgreSQL database cluster. + + ```ts title="stacks/Database.ts" + export function Database({ stack }: StackContext) { + const rds = new RDS(stack, "db", { + engine: "postgresql11.13", + + // ... + ``` + + Stacks also allow us to return props that we can reference in other stacks. + + ```ts + return rds; + ``` + +- `Api.ts` creates an API with a GraphQL endpoint at `/graphql` using [API Gateway](https://aws.amazon.com/api-gateway/). + + ```ts title="stacks/Api.ts" + export function Api({ stack }: StackContext) { + const rds = use(Database); + + const api = new ApiGateway(stack, "api", { + + // ... + ``` + + The `use(Database)` call gives this stack access to the props that the `Database` stack returns. So `rds` is coming from the return statement of our `Database` stack. + + We _bind_ the database to our API so that the functions that power our API have access to it. + + ```ts {2} + function: { + bind: [rds], + }, + ``` + + The `bind` prop does two things for us. It gives our functions permissions to access the database. Also our functions are loaded with the database details required to query it. You can [read more about Resource Binding](../resource-binding.md). + +- `Web.ts` creates a [Vite](https://vitejs.dev) static site hosted on [S3](https://aws.amazon.com/s3/), and serves the contents through a CDN using [CloudFront](https://aws.amazon.com/cloudfront/). + + ```ts title="stacks/Web.ts" + export function Web({ stack }: StackContext) { + const api = use(Api); + + const site = new StaticSite(stack, "site", { + + // ... + ``` + + We get the `Api` stack to set the GraphQL API URL as an environment variable for our frontend to use. + + ```ts {2} + environment: { + VITE_GRAPHQL_URL: api.url + "/graphql", + }, + ``` + +--- + +## `packages/` + +The `packages/` directory houses everything that powers our backend. This includes our GraphQL API, but also all your business logic, and whatever else you need. + +- `packages/core` contains all of your business logic. The `create sst` setup encourages [Domain Driven Design](domain-driven-design.md). It helps you keep your business logic separate from your API and Lambda functions. This allows you to write simple, maintainable code. It implements all the things your application can do. These are then called by external facing services β€” like an API. + +- `packages/core/migrations` is created by default to house your SQL migrations. + +- `packages/web` contains a React application created with [Vite](https://vitejs.dev/). It's already wired up to be able to talk to the GraphQL API. If you are using a different frontend, for example NextJS, you can delete this folder and provision it yourself. + +- `packages/functions` is where you can place all the code for your Lambda functions. Your functions should generally be fairly simple. They should mostly be calling into code previously defined in `services/core`. + +- `packages/graphql` contains the outputs of GraphQL related code generation. Typically you won't be touching this but it needs to be committed to Git. It contains code shared between the frontend and backend. + +:::info +Our starter is structured to encourage [Domain Driven Design](domain-driven-design.md). +::: + +--- + +## `package.json` + +The `package.json` for our app is relatively simple. But there are a couple of things of note. + +--- + +#### Workspaces + +As we had mentioned above, we are using [Workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) to organize our monorepo setup. + +Workspaces are now supported in both [npm](https://docs.npmjs.com/cli/v7/using-npm/workspaces) and [Yarn](https://classic.yarnpkg.com/lang/en/docs/workspaces/) and you can learn more about them in their docs. In a nutshell, they help you manage dependencies for separate _packages_ inside your repo that have their own `package.json` files. + +We have workspaces in our setup. + +```json title="package.json" +"workspaces": [ + "packages/*", +] +``` + +You'll notice that all these directories have their own `package.json` file. + +So when you need to install/uninstall a dependency in one of those workspaces, you can do the following from the project root. + +```bash +$ npm install -W +$ npm uninstall -W +``` + +Or you can do the regular `npm install` in the workspace's directory. + +For Yarn, you'll need to run `yarn add` in the workspace directory. And at the root you'll need to run `yarn add` with [the `-W` flag](https://classic.yarnpkg.com/lang/en/docs/cli/add/). + +--- + +#### Scripts + +Our starter also comes with a few helpful scripts. + +```json title="package.json" +"scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit", + "test": "sst bind -- vitest run", + "gen": "hygen" +}, +``` + +Here's what these scripts do: + +- `dev`: Start the [Live Lambda Dev](../live-lambda-development.md) environment for the _default_ stage. +- `build`: Build the [CloudFormation](https://aws.amazon.com/cloudformation/) for the infrastructure of the app for the _default_ stage. It converts the SST constructs to CloudFormation and packages the necessary assets, but it doesn't deploy them. This is helpful to check what's going to be deployed without actually deploying it. +- `deploy`: Build the infrastructure and deploy the app to AWS. +- `remove`: Completely remove the app's infrastructure from AWS for the _default_ stage. Use with caution! +- `console`: Start the [SST Console](../console.md) for the _default_ stage. Useful for managing _non-local_ stages. +- `typecheck`: Run typecheck for the entire project. By default, our editor should automatically typecheck our code using the `tsconfig.json` in our project root. However, this script lets you explicitly run typecheck as a part of our CI process. +- `test`: Load our `Config` and run our tests. Our starter uses [Vitest](https://vitest.dev). +- `gen`: Uses [Hygen](http://www.hygen.io) to run built-in code gen tasks. Currently only supports `npm run gen migration new`. This will help you code gen a new migration. + +:::note +The _default_ stage that we are referring to above, is the one that you selected while first [creating the app](create-a-new-project.md). +::: + +This might seem like a lot of scripts but we don't need to worry about them now. We'll look at them in detail when necessary. + +--- + +## `sst.config.ts` + +Finally, the `sst.config.ts` defines the project config and the stacks in the app. + +```ts title="sst.config.ts" +export default { + config(_input) { + return { + name: "my-sst-app", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(Database).stack(Api).stack(Web); + }, +} satisfies SSTConfig; +``` + +--- + +By now your `sst dev` process should be complete. So let's run our first migration and initialize our database! diff --git a/www/docs/learn/queries-and-mutations.md b/www/docs/learn/queries-and-mutations.md new file mode 100644 index 0000000000..46d18af41a --- /dev/null +++ b/www/docs/learn/queries-and-mutations.md @@ -0,0 +1,129 @@ +--- +title: Queries and Mutations +--- + +import ChangeText from "@site/src/components/ChangeText"; + +In GraphQL APIs, the actions you can take are broken down into _Queries_ and _Mutations_. Queries are used for reading data, while Mutations are for writing data or triggering actions. + +Let's look at how these work in our app. + +--- + +## Define queries + +To start with we have two queries. One to fetch a single article, called `article`. And another to fetch all the articles, called `articles`. + +```ts title="packages/functions/src/graphql/types/article.ts" {2,11} +builder.queryFields((t) => ({ + article: t.field({ + type: ArticleType, + args: { + articleID: t.arg.string({ required: true }), + }, + resolve: async (_, args) => { + // ... + }, + }), + articles: t.field({ + type: [ArticleType], + resolve: () => Article.list(), + }), +})); +``` + +A query needs to define: + +1. The return `type`. +2. A function on how to `resolve` the query. +3. And optionally take any `args` needed to resolve the query. + +The `article` query above returns a single article given an article id. + +- The return `type` here is the `ArticleType`, that we defined in the [last chapter](add-api-types.md#defining-types). +- It needs the article id as an argument. So we define `articleID` in the `args`. We also specify its type as a string and set it as `required: true`. +- Finally, we have a function to `resolve` the query. It grabs the `articleID` and calls the `Article.get()` domain function in `packages/core/src/article.ts`. + +On the other hand, the `articles` query returns a list of articles of type `ArticleType` with a resolver that calls the `Article.list()` domain function. + +--- + +## Define mutations + +Mutations are similar to queries but are meant for writing data or for triggering actions. For our app, we need a mutation that can create an article. + +```ts title="packages/functions/src/graphql/types/article.ts" +builder.mutationFields((t) => ({ + createArticle: t.field({ + type: ArticleType, + args: { + title: t.arg.string({ required: true }), + url: t.arg.string({ required: true }), + }, + resolve: (_, args) => Article.create(args.title, args.url), + }), +})); +``` + +Just like queries; mutations have a `resolve` function that takes `args` and has a return `type`. + +The `createArticle` mutation, we take two arguments, `title` and `url`. It then calls our domain function `Article.create()` and returns the newly created article of type `ArticleType`. + +That at a very high level is how GraphQL works. You define the type for an object, add a query for how to fetch it, and a mutation for how to create or update it. + +--- + +## Create a new mutation + +Let's add a mutation to create a comment. + + + +In `packages/functions/src/graphql/types/article.ts`, add this above the `createArticle` mutation: + + + +```ts title="packages/functions/src/graphql/types/article.ts" +addComment: t.field({ + type: CommentType, + args: { + articleID: t.arg.string({ required: true }), + text: t.arg.string({ required: true }), + }, + resolve: (_, args) => Article.addComment(args.articleID, args.text), +}), +``` + +Similar to the `createArticle` mutation, it takes the `articleID` and `text` as `args`. And calls `Article.addComment()` domain function to create a new comment. It returns the new comment of type `CommentType`. Recall that we added the new `CommentType` in the [last chapter](add-api-types.md#create-a-comment-type). + +
+Behind the scenes + +We have some tips on how to design GraphQL APIs before we move on. + +GraphQL API design is a little different from REST API design. + +In the case of REST APIs, you are designing around single HTTP requests. So it makes more sense to create endpoints that do a lot of things together. + +However, in GraphQL, clients can always batch multiple calls together in a single request. So it's important to be thoughtful about how you design your API. + +Queries tend to be a bit more straight forward. You typically are just describing all the entities in your system and how they relate. + +While, mutations can be a bit trickier to design. It makes more sense to provide specific mutations that correlate to business actions. + +For example, instead of a generic `updateArticle` method, it makes more sense to write specific mutations like `updateArticleTitle` and `updateArticleUrl`. This is because: + +1. Our frontend can make granular changes. +2. And if we trigger both the mutations, the frontend GraphQL client can just batch them together. + +So we get the best of both worlds! + +If you want to learn more about GraphQL schema design, make sure to [check out this fantastic video](https://youtu.be/pJamhW2xPYw). + +
+ +Our API is now complete! It supports our new comments feature! + +--- + +Let's connect these to our frontend React app. diff --git a/www/docs/learn/render-queries.md b/www/docs/learn/render-queries.md new file mode 100644 index 0000000000..4cc5af2d4c --- /dev/null +++ b/www/docs/learn/render-queries.md @@ -0,0 +1,203 @@ +--- +title: Render Queries +--- + +import ChangeText from "@site/src/components/ChangeText"; + +Let's now add the comments feature to our frontend React app. + +--- + +## Update GraphQL query + +We'll start by updating our homepage to show the number of comments in each article. To do this, we need to update the GraphQL query the homepage is making. + + + +In `packages/web/src/pages/Home.tsx`, replace the `useTypedQuery` with: + + + +```ts {4,13-15} title="packages/web/src/pages/Home.tsx" +// Handle empty document cache +// https://formidable.com/open-source/urql/docs/basics/document-caching/#adding-typenames +const context = useMemo( + () => ({ additionalTypenames: ["Article", "Comments"] }), + [] +); +const [articles] = useTypedQuery({ + query: { + articles: { + id: true, + url: true, + title: true, + comments: { + id: true, + }, + }, + }, + context, +}); +``` + +Here we are adding `comments` to our query. You'll notice we aren't writing a typical GraphQL query. We are writing the query as an object. It's using a typesafe GraphQL client. + +We are also making a change to `additionalTypenames`. This is to fix a quirk of Urql's [Document Cache](https://formidable.com/open-source/urql/docs/basics/document-caching/#document-cache-gotchas), we'll look at this in the next chapter. + +--- + +## Typesafe GraphQL client + +To make a GraphQL query, we are using a [React Hook](https://reactjs.org/docs/hooks-overview.html) called `useTypedQuery`. + +It's making the `articles` query that we looked at in the [last chapter](queries-and-mutations.md). The change here is that we are now requesting the `comments` field as well. + +You'll notice that our code editor can autocomplete all the fields in this query and the new `comments` field is automatically available. Our code editor can also point out if we make a mistake in our query! + +
+Behind the scenes + +Let's look at how our typesafe frontend GraphQL client works behind the scenes. + +SST uses [Urql](https://formidable.com/open-source/urql/), one of the most popular GraphQL clients. The `useTypedQuery` hook wraps around Urql's [`useQuery`](https://formidable.com/open-source/urql/docs/api/urql/) hook while using the types that [Genql](https://genql.vercel.app) generates based on our GraphQL schema. + +The types are code-genned automatically. We looked at this process back in the [GraphQL API](graphql-api.md) chapter. + +The `useTypedQuery` hook is imported from the `graphql/` directory in our app. This directory is mostly code-genned but is meant to be committed to Git. + +```ts +import { useTypedQuery } from "@my-sst-app/graphql/urql"; +``` + +The `useTypedQuery` hook needs an instance of our GraphQL client to make the queries. We define this in `packages/web/src/main.tsx`. + +```ts title="packages/web/src/main.tsx" +const urql = new Client({ + url: import.meta.env.VITE_GRAPHQL_URL, + exchanges: [cacheExchange, fetchExchange], +}); +``` + +Where `VITE_GRAPHQL_URL` is an environment variable that's passed in through our stacks. We looked at this back in the [Project Structure](project-structure.md) chapter. + +To ensure that the `useTypedQuery` hook is able to access our Urql client across our app, we wrap it around our app using the [React Context](https://reactjs.org/docs/context.html). + +```tsx title="packages/web/src/main.tsx" + + + + + +``` + +
+ +--- + +## Render comment count + +Now we need to render the results. The `Home` component renders each article on the homepage as a `
  • `. + + + +Replace the `
  • ` tag in the `return` statement of the `Home` component with. + + + +```tsx {11-15} title="packages/web/src/pages/Home.tsx" +
  • + +
    + {article.comments.length} + + View Comments +
    +
  • +``` + +Here we are rendering the count of the comments and linking to the article page. + +--- + +## Client-side routing + +The article page is available at `/articles/:id`. Since our app is a frontend [SPA](https://en.wikipedia.org/wiki/Single-page_application) (single-page application) we use a client-side router, called [React Router](https://reactrouter.com) to handle these routes. + +
    +Behind the scenes + +Let's look at how our router is configured. + +We currently have two pages in our application: + +1. Homepage β€” `/` +2. Articles page β€” `/articles/:id` + +We also need a route to handle _404_ pages. For now, we'll redirect everything that doesn't match β€” `*`, to the homepage. + +All of this is configured on the app level in `packages/web/src/main.tsx`. + +```tsx title="packages/web/src/main.tsx" +function App() { + return ( + + + } /> + } /> + } /> + + + ); +} +``` + +In our article page, we can grab the id of the article from the URL. We do this using the [`useParams`](https://v5.reactrouter.com/web/api/Hooks/useparams) React Router hook. + +```ts file="packages/web/src/pages/Article.tsx" +import { useParams } from "react-router-dom"; + +export default function Article() { + const { id = "" } = useParams(); + + // ... +``` + +
    + +--- + +## Styling components + +We also need to add a couple of styles to render the comments count in our homepage. + + + +Add this to the bottom of our stylesheet in `packages/web/src/pages/Home.module.css`. + + + +```css title="packages/web/src/pages/Home.module.css" +.footer { + margin-top: 0.8rem; +} + +.footerSeparator { + margin: 0 0.5rem; +} +``` + +Now if you refresh the app, you should see the comment count being displayed under each article. + +![Comment count for articles in homepage](/img/render-queries/comment-count-for-articles-in-homepage.png) + +--- + +Next, let's allow our users to view the comments and post them! diff --git a/www/docs/learn/start-the-frontend.md b/www/docs/learn/start-the-frontend.md new file mode 100644 index 0000000000..00b95bbd8d --- /dev/null +++ b/www/docs/learn/start-the-frontend.md @@ -0,0 +1,94 @@ +--- +title: Start the Frontend +--- + +import ChangeText from "@site/src/components/ChangeText"; + +We are now ready to move on to the frontend. + +You can start your frontend app locally, like you normally would. And it can connect to the API that's running using SST's [Live Lambda Dev](../live-lambda-development.md). That way you can make changes live in your API and it'll reflect right away in the frontend. + +--- + +## Start frontend + +So let's go ahead and start our frontend. + + + +Run the following in your project root. + + + +```bash +cd packages/web +npm run dev +``` + +You'll recall from the [Project Structure](project-structure.md#web) chapter that the starter comes with a React app created using [Vite](https://vitejs.dev/). + +Once our React app is up and running, you should see the following in your terminal. + +```bash +vite v2.9.12 dev server running at: + +> Local: http://localhost:3000/ +> Network: use `--host` to expose + +ready in 346ms. +``` + +Open that link in your browser, `http://localhost:3000/`. You should see the homepage of our app. + +--- + +## Load the homepage + +It displays a list of articles. We currently don't have any links in the system, so this list should be empty. + +![Frontend load homepage](/img/start-frontend/load-homepage.png) + +Over on the Console; you'll find the [Live Lambda](../live-lambda-development.md) logs in the **Local** tab. + +There, should see a `POST /graphql` request that was made. And the response body should say `"articles":[]`. + +![Console load articles log](/img/start-frontend/console-load-articles-log.png) + +
    +Behind the scenes + +This seemingly simple workflow deserves a quick _behind the scenes_ look. Here's what's happening: + +1. Your frontend is running locally. +2. It makes a request to a GraphQL endpoint that's running in AWS. +3. That invokes a Lambda function in AWS. +4. The Lambda function request is then proxied to your local machine. +5. The local version of that function is run. +6. It makes a query to an RDS Postgres database that's in AWS. +7. The logs for the function execution are displayed in the Console. +8. The results of that execution are sent back to AWS. +9. Your frontend then renders those results. + +Note that everything here happens in real-time. There's no polling or syncing! + +
    + +Let's try posting an article. + +--- + +## Post an article + +Type in `Learning SST` as the title, and `https://sst.dev` for the URL. Click **Submit**. + +![Create article](/img/start-frontend/create-article.png) + +You should see a page with the new article. + +Again if we head back to the Console, you should see a new `POST /graphql` request. This time, creating creating the new article. + +![Console create article log](/img/start-frontend/console-create-article-log.png) + +--- + +Next, let's quickly test our local dev environment by setting a breakpoint. diff --git a/www/docs/learn/write-to-dynamodb.md b/www/docs/learn/write-to-dynamodb.md new file mode 100644 index 0000000000..8f09edf490 --- /dev/null +++ b/www/docs/learn/write-to-dynamodb.md @@ -0,0 +1,117 @@ +--- +title: Write to DynamoDB +--- + +If you've selected DynamoDB as your database of choice, this chapter will look at how to store our comments in DynamoDB. + +If this is your first time using DynamoDB, it's quite different from relational databases like PostgreSQL or MySQL. It's best used with a pattern called Single Table Design. + +### Single Table Design + +[Single Table Design](https://www.alexdebrie.com/posts/dynamodb-single-table/) can be a bit of work to learn but `create sst` ships with an excellent library called [ElectroDB](https://github.com/tywalch/electrodb). It provides a simplified way of using the pattern. + +:::info +ElectroDB helps us get started and use Single Table Design in DynamoDB. +::: + +While you should eventually dig deeper and learn the underlying pattern, ElectroDB helps you quickly get started and scales well to the most advanced use cases. + +### Define Schema + +In ElectroDB each concept in your data model is called an `Entity` and you can specify right in your application code. + + + +Let's start by creating a new Entity for comments in `services/core/article.ts`. + + + +```js title="services/core/article.ts" +const CommentEntity = new Entity( + { + model: { + version: "1", + entity: "Comment", + service: "myapp", + }, + attributes: { + commentID: { + type: "string", + required: true, + readOnly: true, + }, + articleID: { + type: "string", + required: true, + readOnly: true, + }, + text: { + type: "string", + required: true, + }, + }, + indexes: { + primary: { + pk: { + field: "pk", + composite: ["commentID"], + }, + sk: { + field: "sk", + composite: [], + }, + }, + byArticle: { + index: "gsi1", + pk: { + field: "gsi1pk", + composite: ["articleID"], + }, + sk: { + field: "gsi1sk", + composite: ["commentID"], + }, + }, + }, + }, + Dynamo.Configuration +); +``` + +We are doing a couple of things here: + +- We define a new `CommentEntity` with the fields `articleID`, `commentID`, and `text`. Where `articleID` and `commentID` are marked as `required` and `readOnly`. This means that it cannot be changed after creation. + + Additionally, it uses the indexes defined in `stacks/Database.ts` to implement some useful functionality. The primary index, which is required, will allow querying this object by the `commentID` to retreive a single comment given its `ID`. + +- The `byArticle` is a secondary index that allows fetching a list of comments given the `articleID`. ElectroDB handles implementing these indexes through Single Table Design and you can [learn more about this here](https://github.com/tywalch/electrodb#indexes). + +### Implementation + +Now let's implement the `addComment` and `comments` functions that we created back in the Scaffold Business Logic chapter. + + + +Replace the two placeholder functions in `services/core/article.ts` with: + + + +```js title="services/core/article.ts" {2-6,10-12} +export async function addComment(articleID: string, text: string) { + return CommentEntity.create({ + articleID, + commentID: ulid(), + text, + }).go(); +} + +export async function comments(articleID: string) { + return CommentEntity.query + .byArticle({ + articleID, + }) + .go(); +} +``` + +Now with our business logic implemented, we are ready to hook up our API. diff --git a/www/docs/learn/write-to-the-database.md b/www/docs/learn/write-to-the-database.md new file mode 100644 index 0000000000..ef4d24642d --- /dev/null +++ b/www/docs/learn/write-to-the-database.md @@ -0,0 +1,232 @@ +--- +title: Write to the Database +--- + +import ChangeText from "@site/src/components/ChangeText"; + +We are ready to add our new comments feature. + +--- + +## Scaffold business logic + +We'll start by scaffolding the domain code first. As mentioned in the [last chapter](domain-driven-design.md), we'll add this to our `core` package. + + + +Open up `packages/core/src/article.ts` and add the following two functions to the bottom of the file. + + + +```js +export function addComment(articleID: string, text: string) { + // code for adding a comment to an article +} + +export function comments(articleID: string) { + // code for getting a list of comments of an article +} +``` + +Before we can implement them, we'll need to create a new table to store the comments. + +--- + +## Create a migration + +Let's create a new migration for this. + + + +Run this in the **root of the project** to create a new migration + + + +```bash +npm run gen migration new +``` + + + +It'll ask you to name your migration. Type in **`comment`**. + + + +```bash +? Migration name β€Ί comment +``` + +Once the migration is created, you should see the following in your terminal. + +```bash +βœ” Migration name Β· comment + +Loaded templates: _templates + added: packages/core/migrations/1661988563371_comment.mjs +``` + + + +Open up the new migration script and replace its content with: + + + +```ts title="packages/core/migrations/1661988563371_comment.mjs" +import { Kysely } from "kysely"; + +/** + * @param db {Kysely} + */ +export async function up(db) { + await db.schema + .createTable("comment") + .addColumn("commentID", "text", (col) => col.primaryKey()) + .addColumn("articleID", "text", (col) => col.notNull()) + .addColumn("text", "text", (col) => col.notNull()) + .execute(); +} + +/** + * @param db {Kysely} + */ +export async function down(db) { + await db.schema.dropTable("comment").execute(); +} +``` + +This migration will create a new table called `comment`. While undoing the migration will drop the table. + +--- + +## Run a migration + +Let's go ahead and run the migration. + + + +Go to the RDS tab in SST Console and click **Apply** on our `comment` migration. + + + +![Console run migration](/img/implement-rds/run-migration.png) + +To verify that the table has been created; enter the following in the query editor, and hit **Execute**. + +```sql +SELECT * FROM comment +``` + +![Console query comments table](/img/implement-rds/console-query-comment.png) + +You should see **0 rows** being returned. + +--- + +## Query the table + +We are now ready to implement the `addComment` and `comments` functions. + + + +Replace the two placeholder functions in `packages/core/src/article.ts` with: + + + +```ts {2-9,13-16} title="packages/core/src/article.ts" +export function addComment(articleID: string, text: string) { + return SQL.DB.insertInto("comment") + .values({ + commentID: ulid(), + articleID, + text, + }) + .returningAll() + .executeTakeFirstOrThrow(); +} + +export function comments(articleID: string) { + return SQL.DB.selectFrom("comment") + .selectAll() + .where("articleID", "=", articleID) + .execute(); +} +``` + +We are using [Kysely](https://kysely-org.github.io/kysely/) to run typesafe queries against our database. + +
    +Behind the scenes + +There are a couple of interesting details here, let's dig in: + +1. `SQL.DB` is the Kysely instance imported from `packages/core/src/sql.ts`. + + ```ts title="packages/core/src/sql.ts" + export const DB = new Kysely({ + dialect: new DataApiDialect({ + mode: "postgres", + driver: { + secretArn: RDS.db.secretArn, + resourceArn: RDS.db.clusterArn, + database: RDS.db.defaultDatabaseName, + client: new RDSDataService(), + }, + }), + }); + ``` + +2. `RDS` is coming from the SST Node client package. + + ```ts title="packages/core/src/sql.ts" + import { RDS } from "sst/node/rds"; + ``` + + It has access to the config of our database, thanks to [Resource Binding](../resource-binding.md). You might recall us **binding** our database to the functions in our API back in the [Project Structure](project-structure.md#stacks) chapter. + + ```ts title="stacks/Api.ts" {2} + function: { + bind: [rds], + }, + ``` + + By binding the `rds` cluster to our API in `stacks/Api.ts`, our API can access the database ARN (an ARN is an AWS identifier), database name, and ARN of the secret to access the database in our functions. + +3. The Kysely instance also needs a `Database` type. This is coming from `packages/core/src/sql.generated.ts`. + + ```ts title="packages/core/src/sql.generated.ts" + export interface Database { + article: Article; + comment: Comment; + } + ``` + + The keys of this interface are the table names in our database. And they in turn point to other interfaces that list the column types of the respective tables. For example, here's the new `Comment` table we just created: + + ```ts + export interface Comment { + articleID: string; + commentID: string; + text: string; + } + ``` + +4. The `sql.generated.ts` types file, as you might've guessed in auto-generated. Our infrastructure code generates this when a new migration is run! + + It's defined in `stacks/Database.ts`. + + ```ts title="stacks/Database.ts" {4} + const rds = new RDS(stack, "rds", { + engine: "postgresql11.13", + migrations: "packages/core/migrations", + types: "packages/core/src/sql.generated.ts", + defaultDatabaseName: "main", + }); + ``` + + Even though this file is auto-generated, you should check it into Git. We'll be relying on it later on in this tutorial. + +
    + +--- + +Now with our business logic and database queries implemented, we are ready to hook up our API. diff --git a/www/docs/live-lambda-development.md b/www/docs/live-lambda-development.md new file mode 100644 index 0000000000..0c2e978fa1 --- /dev/null +++ b/www/docs/live-lambda-development.md @@ -0,0 +1,342 @@ +--- +title: Live Lambda Development +sidebar_label: Live Lambda +description: Live Lambda Development allows you to debug and test your Lambda functions locally. +--- + +import config from "../config"; +import styles from "./video.module.css"; +import useBaseUrl from "@docusaurus/useBaseUrl"; +import HeadlineText from "@site/src/components/HeadlineText"; + + + +SST features a local development environment that lets you debug and test your Lambda functions locally. + + + +
    + +
    + +--- + +## Overview + +Live Lambda Development or Live Lambda is feature of SST that allows you to **debug and test your Lambda functions locally**, while being **invoked remotely by resources in AWS**. It works by proxying requests from your AWS account to your local machine. + +Changes are automatically detected, built, and **live reloaded** in under 10 milliseconds. You can also use **breakpoints to debug** your functions live with your favorite IDE. + +--- + +## Quick start + +To give it a try, create a new SST app by running `npx create-sst@latest`. Once the app is created, install the dependencies. + +To start the Live Lambda Development environment run: + +```bash +npx sst dev +``` + +The first time you run this, it'll deploy your app to AWS. This can take a couple of minutes. + +
    +Behind the scenes + +When this command is first run for a project, you will be prompted for a default stage name. + +```txt +Look like you’re running sst for the first time in this directory. +Please enter a stage name you’d like to use locally. +Or hit enter to use the one based on your AWS credentials (spongebob): +``` + +It'll suggest that you use a stage name based on your AWS username. This value is stored in a `.sst` directory in the project root and should not be checked into source control. + +A stage ensures that you are working in an environment that is separate from the other people on your team. Or from your production environment. It's meant to be unique. + +
    + +The starter deploys a Lambda function with an API endpoint. You'll see something like this in your terminal. + +```bash +Outputs: + ApiEndpoint: https://s8gecmmzxf.execute-api.us-east-1.amazonaws.com +``` + +If you head over to the endpoint, it'll invoke the Lambda function in `packages/functions/src/lambda.js`. You can try changing this file and hitting the endpoint again. You should **see your changes reflected right away**! + +Before we look at how Live Lambda works behind the scenes, let's start with a little bit of background. + +--- + +## Background + +Working on Lambda functions locally can be painful. You have to either: + +1. Locally mock all the services that your Lambda function uses + + Like API Gateway, SNS, SQS, etc. This is hard to do. If you are using a tool that mocks a specific service (like API Gateway), you won't be able to test a Lambda that's invoked by a different service (like SNS). On the other hand a service like [LocalStack](https://localstack.cloud), that tries to mock a whole suite of services, is slow and the mocked services can be out of date. + +2. Or, you'll need to deploy your changes to test them + + Each deployment can take at least a minute. And repeatedly deploying to test a change really slows down the feedback loop. + +--- + +## How it works + +To fix this, we created Live Lambda β€” a local development environment for Lambda functions. It works by proxying requests from Lambda functions to your local machine. This allows SST to run the local version of a function with the event, context, and credentials of the remote Lambda function. + +SST uses [AWS IoT over WebSocket](https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html) to communicate between your local machine and the remote Lambda function. Every AWS account comes with a AWS IoT Core endpoint by default. You can publish events and subscribe to them. + +:::info Live Lambda v1 + +Prior to SST v2, Live Lambda was implemented using a WebSocket API and a DynamoDB table. These were deployed to your account as a separate stack in your app. + +This new IoT approach is a lot faster, roughly 2-3x. And it does not require any additional infrastructure. + +::: + +Here's how it works. + +1. When you run `sst dev`, it deploys your app and replaces the Lambda functions with a _stub_ version. +2. It also starts up a local WebSocket client and connects to your AWS accounts' IoT endpoint. +3. Now, when a Lambda function in your app is invoked, it publishes an event, where the payload is the Lambda function request. +4. Your local WebSocket client receives this event. It publishes an event acknowledging that it received the request. +5. Next, it runs the local version of the function and publishes an event with the function response as the payload. The local version is run as a Node.js Worker. +6. Finally, the stub Lambda function receives the event and responds with the payload. + +
    +Behind the scenes + +The AWS IoT events are published using the format `/sst///`. Where `app` is the name of the app and `stage` is the stage `sst dev` is deployed to. + +Each Lambda function invocation is made up of three events; the original request fired by the remote Lambda function, the local CLI acknowledging the request, and the response fired by the local CLI. + +If the payload of the events are larger than 50kb, they get chunked into separate events. + +
    + +So while the local Lambda function is executed, from the outside it looks like it was run in AWS. This approach has [several advantages](#advantages) that we'll look at below. + +--- + +### Cost + +AWS IoT that powers Live Lambda is **completely serverless**. So you don't get charged when it's not in use. + +It's also pretty cheap. With a free tier of 500k events per month and roughly $1.00 per million for the next billion messages. You can [check out the details here](https://aws.amazon.com/iot-core/pricing/). + +As a result this approach works great even when [there are multiple developers on your team](working-with-your-team.md). + +--- + +### Privacy + +All the data stays between your local machine and your AWS account. There are **no 3rd party services** that are used. + +Live Lambda also supports connecting to AWS resources inside a VPC. We'll [look at this below](#working-with-a-vpc). + +--- + +### Languages + +Live Lambda and setting breakpoints are supported in the following languages. + +| Language | Live Lambda | Set breakpoints | +| ---------- | -------------------------------- | -------------------------------- | +| JavaScript | | | +| TypeScript | | | +| Python | | | +| Golang | | | +| Java | | | +| C# | | | +| F# | | | + + Officially supported   + Community support   + Not supported   + +--- + +## Advantages + +The Live Lambda approach has a couple of advantages. + +1. You can work on your Lambda functions locally and set breakpoints in VS Code. +2. Interact with the entire infrastructure of your app as it has been deployed to AWS. This is really useful for **testing webhooks** because you have an endpoint that is not on localhost. +3. Supports all **Lambda triggers**, so there's no need to mock API Gateway, SQS, SNS, etc. +4. Supports real Lambda **environment variables**. +5. Supports Lambda **IAM permissions**, so if a Lambda fails on AWS due to the lack of IAM permissions, it would fail locally as well. +6. And it's fast! It's **50-100x faster** than alternatives like [SAM Accelerate](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/accelerate.html) or [CDK Watch](https://aws.amazon.com/blogs/developer/increasing-development-speed-with-cdk-watch/). + +--- + +## How Live Lambda is different + +The other serverless frameworks have tried to address the problem of local development with Lambda functions. Let's look at how Live Lambda is different. + +--- + +### Serverless Offline + +[Serverless Framework](https://www.serverless.com/framework) has a plugin called [Serverless Offline](https://www.serverless.com/plugins/serverless-offline) that developers use to work on their applications locally. + +It **emulates Lambda** and API Gateway locally. Unfortunately, this doesn't work if your functions are triggered by other AWS services. So you'll need to create mock Lambda events. + +--- + +### SAM Accelerate + +[AWS SAM](https://aws.amazon.com/serverless/sam/) features [SAM Accelerate](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/accelerate.html) to help with local development. It directly updates your Lambda functions without doing a full deployment of your app. + +However, this is still **too slow** because it needs to bundle and upload your Lambda function code to AWS. It can take a few seconds. Live Lambda in comparison is 50-100x faster. + +--- + +### CDK Watch + +[AWS CDK](https://aws.amazon.com/cdk/) has something called [CDK Watch](https://aws.amazon.com/blogs/developer/increasing-development-speed-with-cdk-watch/) to speed up local development. It watches for file changes and updates your Lambda functions without having to do a full deployment. + +However, this is **too slow** because it needs to bundle and upload your Lambda function code. It can take a few seconds. Live Lambda in comparison is 50-100x faster. + +--- + +## Debugging With VS Code + +The Live Lambda Development environment runs a Node.js process locally. This allows you to use [Visual Studio Code](https://code.visualstudio.com) to debug your serverless apps live. + +Let's look at how to set this up. + +
    + +
    + +--- + +#### Launch configurations + +Add the following to `.vscode/launch.json`. + +```json title="launch.json" +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Dev", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["dev", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"] + } + ] +} +``` + +This contains the launch configuration to run the `sst dev` command in debug mode. Allowing you to set breakpoints to your Lambda functions. We also have an example project with a VS Code setup that you can use as a reference. + +:::tip +If you are using one of our starters, you should already have a `.vscode` directory in your project root. +::: + +--- + +#### Debug Lambda functions + +Next, head over to the **Run And Debug** tab and for the debug configuration select **Debug SST Dev**. + +VS Code debug SST Dev + +Now you can set a breakpoint and start your app by pressing `F5` or by clicking **Run** > **Start Debugging**. Then triggering your Lambda function will cause VS Code to stop at your breakpoint. + +--- + +#### Increasing timeouts + +By default the timeout for a Lambda function might not be long enough for you to view the breakpoint info. So we need to increase this. We use the [`--increase-timeout`](packages/sst.md#sst-dev) option for the `sst dev` command in our `launch.json`. + +```js title="launch.json +"runtimeArgs": ["dev", "--increase-timeout"], +``` + +This increases our Lambda function timeouts to their maximum value of 15 minutes. For APIs the timeout cannot be increased more than 30 seconds. But you can continue debugging the Lambda function, even after the API request times out. + +--- + +## Debugging with WebStorm + +You can also set breakpoints and debug your Lambda functions locally with [WebStorm](http://www.jetbrains.com/webstorm/). [Check out this tutorial for more details](https://sst.dev/examples/how-to-debug-lambda-functions-with-webstorm.html). + +
    + +
    + +:::note +In some versions of WebStorm you might need to disable stepping through library scripts. You can do this by heading to **Preferences** > **Build, Execution, Deployment** > **Debugger** > **Stepping** > unchecking **Do not step into library scripts**. +::: + +--- + +## Debugging with IntelliJ IDEA + +If you are using [IntelliJ IDEA](https://www.jetbrains.com/idea/), [follow this tutorial to set breakpoints in your Lambda functions](https://sst.dev/examples/how-to-debug-lambda-functions-with-intellij-idea.html). + +
    + +
    + +--- + +## Built-in environment variables + +SST sets the `IS_LOCAL` environment variable to `true` for functions running inside `sst dev`. + +```js title="src/lambda.js" {2} +export async function main(event) { + const body = process.env.IS_LOCAL ? "Hello, Local!" : "Hello, World!"; + + return { + body, + statusCode: 200, + headers: { "Content-Type": "text/plain" }, + }; +} +``` + +--- + +## Working with a VPC + +If you have resources like RDS instances deployed inside a VPC, and you are not using the Data API to talk to the database, you have the following options. + +--- + +#### Connect to a VPC + +By default your local Lambda function cannot connect to the database in a VPC. You need to: + +1. Setup a VPN connection from your local machine to your VPC network. You can use the AWS Client VPN service to set it up. [Follow the Mutual authentication section in this doc](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/client-authentication.html#mutual) to setup the certificates and import them into your Amazon Certificate Manager. +2. Then [create a Client VPC Endpoint](https://aws.amazon.com/blogs/networking-and-content-delivery/introducing-aws-client-vpn-to-securely-access-aws-and-on-premises-resources/), and associate it with your VPC. +3. And, finally install [Tunnelblick](https://tunnelblick.net) locally to establish the VPN connection. + +Note that, the AWS Client VPC service is billed on an hourly basis but it's fairly inexpensive. [Read more on the pricing here](https://aws.amazon.com/vpn/pricing/). + +--- + +#### Connect to a local DB + +Alternatively, you can run the database server locally (ie. MySQL or PostgreSQL). And in your function code, you can connect to a local server if [`IS_LOCAL`](#built-in-environment-variables) is set: + +```js +const dbHost = process.env.IS_LOCAL + ? "localhost" + : "amazon-string.rds.amazonaws.com"; +``` + +## Infrastructure changes + +In addition to the changes made to your Lambda functions, `sst dev` also watches for infrastructure changes and will automatically redeploy them. diff --git a/www/docs/long-running-jobs.md b/www/docs/long-running-jobs.md new file mode 100644 index 0000000000..f5779a4a19 --- /dev/null +++ b/www/docs/long-running-jobs.md @@ -0,0 +1,308 @@ +--- +title: Long Running Jobs +description: "Learn how to run long running jobs in your SST apps." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; + + + +Run functions for longer than Lambda's 15 minute time limit. + + + +--- + +## Overview + +Sometimes you might want to run some code for longer than the 15 minute Lambda limit. But you might not want to manage a container just for that. For example, tasks related to video processing, ETL, and ML. + +SST makes it easy to do this with the [`Job`](constructs/Job.md) construct. + +1. Define a new `Job` construct in your stacks +2. Create a (long running) function for the job +3. Invoke the job from your frontend or API + +Let's look at it in detail. + +--- + +#### Get started + +Start by creating a new SST + Next.js app by running the following command in your terminal. We are using Next.js for this example but you can use your favorite frontend. + +```bash +npx create-sst@latest --template standard/nextjs +``` + +--- + +## Create a job + +Let's start by adding a job to our app. + +```ts title="stacks/Default.ts" +const job = new Job(stack, "factorial", { + handler: "packages/functions/src/job.handler", +}); +``` + +Make sure to import the [`Job`](constructs/Job.md) construct. + +```diff title="stacks/Default.ts" +- import { StackContext, NextjsSite } from "sst/constructs"; ++ import { Job, StackContext, NextjsSite } from "sst/constructs"; +``` + +--- + +## Bind the job + +After adding the job, bind your Next.js app to it. + +```diff title="stacks/Default.ts" +const site = new NextjsSite(stack, "site", { + path: "packages/web", ++ bind: [job], +}); +``` + +This allows us to invoke the job in our Next.js app. + +--- + +## Add the job handler + +Now let's add our long running function. In this example we'll simply return the factorial of a given number. It'll take a _"payload"_ (input) and compute the factorial. + +--- + +#### Define the payload type + +Let's define the type for the payload. + +```ts title="packages/functions/src/job.ts" +import { JobHandler } from "sst/node/job"; + +declare module "sst/node/job" { + export interface JobTypes { + factorial: { + num: number; + }; + } +} +``` + +--- + +#### Define the function + +Add the handler function + +```ts title="packages/functions/src/job.ts" +export const handler = JobHandler("factorial", async (payload) => { + let result = 1; + for (let i = 2; i <= payload.num; i++) { + result = result * i; + } + + console.log(`Factorial of ${payload.num} is ${result}`); +}); +``` + +--- + +## Invoke the job + +Finally we can invoke the job in our Next.js app. Here we'll invoke it when we call our API. This is useful for cases when you want to return to the user right away but trigger the a long running job in the background. + +```ts title="packages/web/pages/api/hello.ts" +export default async function handler( + req: NextApiRequest, + res: NextApiResponse +) { + await Job.factorial.run({ + payload: { + num: 10, + }, + }); + + res.status(200).send("Job started!"); +} +``` + +Now if you hit the API in your browser, you'll see the factorial printed in the `sst dev` terminal. + +--- + +## How it works + +Let's look at how `Job` works. It uses a few resources behind the scenes: + +1. An [**AWS CodeBuild**](https://aws.amazon.com/codebuild/) project that runs the handler function inside a docker container. +2. An **invoker Lambda** function that triggers the CodeBuild project. + +--- + +### Runtime environment + +The job function runs inside a docker container, using the official [`aws-lambda-nodejs`](https://hub.docker.com/r/amazon/aws-lambda-nodejs) Node.js 16 container image. This image is **similar to the AWS Lambda execution environment**. + +Jobs currently only support Node.js runtimes, and they are always bundled by esbuild with the `esm` format. If you are interested in other runtimes, talk to us on Discord. + +You can optionally configure the memory size and the timeout for the job. + +```ts {3,4} +const job = new Job(stack, "factorial", { + handler: "packages/functions/src/job.handler", + timeout: "1 hour", + memorySize: "7GB", +}); +``` + +See a full list of [memory size](constructs/Job.md#memorysize) and [timeout](constructs/Job.md#timeout) configurations. + +--- + +### Binding resources + +Similar to Functions, you can use the `bind` fields to pass other resources to your job, and reference them at runtime. + +```ts {4} +const table = new Table(stack, "table", { /* ... */ }); + +new Job (stack, "factorial, { + bind: [table], // bind table to job + handler: "packages/functions/src/job.handler", +}); +``` + +--- + +### `sst deploy` + +1. Calling `new Job()` creates the above resources. + +2. When binding to the frontend, API, or any other function. The function is granted the IAM permission to invoke the invoker Lambda function. The invoker Lambda's function name is also passed into the original function as a Lambda environment variable, `SST_Job_functionName_factorial`. + +3. At runtime, when running the job: + + ```ts + await Job.factorial.run({ + payload: { + num: 100, + }, + }); + ``` + + `Job.factorial.run` gets the name of the invoker function from `process.env.SST_Job_functionName_factorial`, and invokes the function with the payload. + +4. The invoker function then triggers the CodeBuild job. The function payload is JSON stringified and passed to the CodeBuild job as environment variable, `SST_PAYLOAD`. + +5. Finally, the CodeBuild job decodes `process.env.SST_PAYLOAD`, and runs the job handler with the decoded payload in a Lambda execution environment. + +--- + +### `sst dev` + +On `sst dev`, the invoker function is replaced with a stub function. The stub function sends the request to your local machine, and the local version of the job function is executed. This is similar to how [Live Lambda Development](live-lambda-development.md) works for a [`Function`](constructs/Function.md). + +:::info +Your locally invoked job has the **same IAM permissions** as the deployed CodeBuild job. +::: + +--- + +### SST Console + +The job can be found in the console under the **Functions** tab. And you can manually invoke the job. + +![SST Console Functions tab](/img/long-running-jobs/sst-console-job.png) + +Here we are passing in `{"num":5}` as the payload for the job. + +--- + +### Typesafe payload + +In our example, we defined the job type in `packages/functions/src/job.ts`. + +```ts title="packages/functions/src/job.ts" +export interface JobTypes { + factorial: { + num: number; + }; +} +``` + +This is being used in two places to ensure typesafety. + +1. When running the job, the payload is validated against the job type. + + ```ts {2-4} + await Job.factorial.run({ + payload: { + num: 100, + }, + }); + ``` + +2. And, when defining the `JobHandler`, the `payload` argument is automatically typed. Your editor can also autocomplete `payload.num` for you, and reports a type error if an undefined field is accessed by mistake. + + ```ts + export const handler = JobHandler("factorial", async (payload) => { + // Editor can autocomplete "num" + console.log(payload.num); + + // Editor shows a type error + console.log(payload.foo); + }); + ``` + +--- + +## FAQ + +Here are some frequently asked questions about `Job`. + +--- + +### How much does it cost to use `Job`? + +CodeBuild has a free tier of 100 build minutes per month. After that, you are charged per build minute. You can find the full pricing here β€” https://aws.amazon.com/codebuild/pricing/. The `general1` instance types are used. + +--- + +### When should I use `Job` vs `Function`? + +`Job` is a good fit for running functions that takes longer than 15 minutes, such as + +- ML jobs +- ETL jobs +- Video processing + +Note that, `Jobs` have a much **longer cold start** time. When a job starts up, CodeBuild has to download the docker image before running the code. This process can take around 30 seconds. `Job` is not a good choice if you are looking to run something right away. + +--- + +### Is `Job` a good fit for batch jobs? + +There are a few AWS services that can help you schedule running batch jobs: AWS Batch and Step Functions, etc. + +Setting up AWS Batch and Step Functions requires using multiple AWS services, and requires more experience to wire up all the moving parts. + +For one off jobs, where you just want to run something longer than 15 minutes, use `Job`. And if you need to run certain jobs on a regular basis, you can explore the above options. + +--- + +### Why CodeBuild instead of Fargate? + +We evaluated both CodeBuild and ECS Fargate as the backing service for `Job`. + +Both services are similar in the way that they can run code inside a docker container environment. We decided to go with CodeBuild because: + +- It can be deployed without a VPC +- It offers a free tier of 100 build minutes per month (for the general1.small instance type, general1.medium and general1.large aren't included in the free-tier) +- A CodeBuild project is a single AWS resource, and is much faster to deploy + +As we collect more feedback on the usage, we are open to switching to using Fargate. When we do, it will be a seamless switch as the implementation details are not exposed. diff --git a/www/docs/migrating/cdk.md b/www/docs/migrating/cdk.md new file mode 100644 index 0000000000..6caba89a79 --- /dev/null +++ b/www/docs/migrating/cdk.md @@ -0,0 +1,69 @@ +--- +title: Migrating From CDK +sidebar_label: CDK +description: "Migrating from AWS CDK to SST." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; + + + +A guide to migrating your CDK app to SST. + + + +--- + +SST is an extension of [AWS CDK](https://aws.amazon.com/cdk/). It's fairly simple to move a CDK app to SST. You just need to account for a couple of small differences: + +1. There is no `cdk.json` + + If you have a `context` block in your `cdk.json`, you can move it to a `cdk.context.json`. You can [read more about this here](https://docs.aws.amazon.com/cdk/latest/guide/context.html). You'll also need to add a `sst.json` config file, as [talked about here](../learn/project-structure.md#sstjson). Here is a sample config for reference. + + ```json + { + "name": "my-sst-app", + "stage": "dev", + "region": "us-east-1" + } + ``` + +2. There is no `bin/*.js` + + Instead there is a `stacks/index.js` that has a default export function where you can add your stacks. SST creates the App object for you. This is what allows SST to ensure that the stage, region, and AWS accounts are set uniformly across all the stacks. Here is a sample `stacks/index.js` for reference. + + ```js + import MyStack from "./MyStack"; + + export default function main(app) { + new MyStack(app, "my-stack"); + + // Add more stacks + } + ``` + +3. Stacks are written as functions + + Your classes are written as functions instead of `cdk.Stack`. Here is what the JavaScript version looks like. + + ```js + import * as sst from "sst/constructs"; + + export function MyStack(ctx) {} + ``` + + And in TypeScript. + + ```ts + import * as sst from "sst/constructs"; + + export function MyStack(ctx: sst.StackContext) {} + ``` + +4. Lambdas use `sst.Function` + + Use the [`sst.Function`](constructs/Function.md) construct instead of `cdk.lambda.NodejsFunction`. + +5. Include the right packages + + You don't need the `aws-cdk` package in your `package.json`. Instead you'll need [`sst`](packages/sst.md) package. diff --git a/www/docs/migrating/serverless-framework.md b/www/docs/migrating/serverless-framework.md new file mode 100644 index 0000000000..7c54a7b9f8 --- /dev/null +++ b/www/docs/migrating/serverless-framework.md @@ -0,0 +1,1058 @@ +--- +title: Migrating From Serverless Framework +sidebar_label: Serverless Framework +description: "Migrate your from Serverless Framework app to SST." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; + + + +A guide to migrating your Serverless Framework app to SST. + + + +--- + +This document is a work in progress. If you have experience migrating your Serverless Framework app to SST, please consider contributing. + +## Incrementally Adopting SST + +SST has been designed to be incrementally adopted. This means that you can continue using your existing Serverless Framework app while slowly moving over resources to SST. By starting small and incrementally adding more resources, you can avoid a wholesale rewrite. + +Let's assume you have an existing Serverless Framework app. To get started, we'll first set up a new SST project in the same directory. + +### A hybrid Serverless Framework and SST app + +To make it an easier transition, we'll start by merging your existing Serverless Framework app with a newly created SST app. + +Your existing app can either have one service or be a monorepo with multiple services. + +1. In a temporary location, run `npm init sst` +2. Copy the `sst.json` file and the `src/` and `stacks/` directories. +3. Copy the `scripts`, `dependencies`, and `devDependencies` from the `package.json` file in the new SST project root. +4. Copy the `.gitignore` file and append it to your existing `.gitignore` file. +5. If you are using TypeScript, you can also copy the `tsconfig.json`. +6. Run `npm install`. + +Now your directory structure should look something like this. The `src/` directory is where all the Lambda functions in your Serverless Framework app are placed. + +``` +serverless-app +β”œβ”€β”€ node_modules +β”œβ”€β”€ .gitignore +β”œβ”€β”€ package.json +β”œβ”€β”€ serverless.yml +β”œβ”€β”€ sst.json +β”œβ”€β”€ stacks +| β”œβ”€β”€ MyStack.js +| └── index.js +└── src + β”œβ”€β”€ lambda1.js + └── lambda2.js +``` + +And from your project root you can run both the Serverless Framework and SST commands. + +This also allows you to easily create functions in your new SST app by pointing to the handlers in your existing app. + +Say you have a Lambda function defined in your `serverless.yml`. + +```yml title="serverless.yml" +functions: + hello: + handler: src/lambda1.main +``` + +You can now create a function in your SST app using the same source. + +```js title="SST" +new sst.Function(stack, "MySnsLambda", { + handler: "src/lambda1.main", +}); +``` + +### Monorepo with multiple Serverless Framework services + +If you have multiple Serverless Framework services in the same repo, you can still follow the steps above to create a single SST app. This is because you can define multiple stacks in the same SST app. Whereas each Serverless Framework service can only contain a single stack. + +After the SST app is created, your directory structure should look something like this. + +``` +serverless-app +β”œβ”€β”€ node_modules +β”œβ”€β”€ .gitignore +β”œβ”€β”€ package.json +β”œβ”€β”€ sst.json +β”œβ”€β”€ stacks +| β”œβ”€β”€ MyStack.js +| └── index.js +└── services + β”œβ”€β”€ serviceA + | β”œβ”€β”€ serverless.yml + | β”œβ”€β”€ lambda1.js + | └── lambda2.js + └── serviceB + β”œβ”€β”€ serverless.yml + β”œβ”€β”€ lambda3.js + └── lambda4.js +``` + +The `src/` directory is where all the Lambda functions in your Serverless Framework app are placed. + +### Add new services to SST + +Next, if you need to add a new service or resource to your Serverless Framework app, you can instead do it directly in SST. + +For example, say you want to add a new SQS queue resource. + +1. Start by creating a new stack in the `stacks/` directory. Something like, `stacks/MyNewQueueService.js`. +2. Add the new stack to the list in `stacks/index.js`. + +### Reference stack outputs + +Now that you have two separate apps side-by-side, you might find yourself needing to reference stack outputs between each other. + +#### Reference a Serverless Framework stack output in SST + +To reference a Serverless Framework stack output in SST, you can use the [`cdk.Fn.import_value`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Fn.html#static-importwbrvaluesharedvaluetoimport) function. + +For example: + +```js +// This imports an S3 bucket ARN and sets it as an environment variable for +// all the Lambda functions in the new API. +import { Fn } from "aws-cdk-lib"; + +new sst.Api(stack, "MyApi", { + defaults: + function: { + environment: { + myKey: Fn.importValue("exported_key_in_serverless_framework") + } + } + }, + routes: { + "GET /notes" : "src/list.main", + "POST /notes" : "src/create.main", + "GET /notes/{id}" : "src/get.main", + "PUT /notes/{id}" : "src/update.main", + "DELETE /notes/{id}" : "src/delete.main", + } +}); +``` + +#### Reference SST stack outputs in Serverless Framework + +You might also want to reference a newly created resource in SST in Serverless Framework. + +```js title="SST" +// Export in an SST stack +stack.addOutputs({ + TableName: { + value: bucket.bucketArn, + exportName: "MyBucketArn", + }, +}); +``` + +```js title="Serverless Framework" +// Importing in serverless.yml +!ImportValue MyBucketArn +``` + +#### Referencing SST stack outputs in other SST stacks + +And finally, to reference stack outputs across stacks in your SST app. + +```js title="StackA.js" +import { StackContext, Bucket } from "sst/constructs"; + +export function StackA({ stack }: StackContext) { + const bucket = new s3.Bucket(stack, "MyBucket"); + + return { bucket }; +} +``` + +```js title="StackB.js" +import { StackContext, use } from "sst/constructs"; +import { StackA } from "./StackA"; + +export function StackB({ stack }: StackContext) { + // stackA's return value is passed to stackB + const { bucket } = use(StackA); + + // SST will implicitly set the exports in stackA + // and imports in stackB + bucket.bucketArn; +} +``` + +### Reference Serverless Framework resources + +The next step would be to use the resources that are created in your Serverless Framework app. You can reference them directly in your SST app, so you don't have to recreate them. + +For example, if you've already created an SNS topic in your Serverless Framework app, and you want to add a new function to subscribe to it: + +```js +import { Topic } from "aws-cdk-lib/aws-sns"; + +// Lookup the existing SNS topic +const snsTopic = Topic.fromTopicArn( + stack, + "ImportTopic", + "arn:aws:sns:us-east-2:444455556666:MyTopic" +); + +// Add 2 new subscribers +new sst.Topic(stack, "MyTopic", { + snsTopic, + subscribers: { + subscriber1: "src/subscriber1.main", + subscriber2: "src/subscriber2.main", + }, +}); +``` + +### Migrate existing services to SST + +There are a couple of strategies if you want to migrate your Serverless Framework resources to your SST app. + +#### Proxying + +This applies to API endpoints and it allows you to incrementally migrate API endpoints to SST. + +:::note +Support for this strategy hasn't been implemented in SST yet. +::: + +Suppose you have a couple of routes in your `serverless.yml`. + +```yaml +functions: + usersList: + handler: src/usersList.main + events: + - httpApi: + method: GET + path: /users + + usersGet: + handler: src/usersGet.main + events: + - httpApi: + method: GET + path: /users/{userId} +``` + +And you are ready to migrate the `/users` endpoint but don't want to touch the other endpoints yet. + +You can add the route you want to migrate, and set a catch all route to proxy requests the rest to the old API. + +```js +const api = new sst.Api(stack, "Api", { + routes: { + "GET /users": "src/usersList.main", + // "$default" : proxy to old api, + }, +}); +``` + +Now you can use the new API endpoint in your frontend application. And remove the old route from the Serverless Framework app. + +#### Resource swapping + +This is suitable for migrating resources that don't have persistent data. So, SNS topics, SQS queues, and the like. + +Imagine you have an existing SNS topic named `MyTopic`. + +1. Create a new topic in SST called `MyTopic.sst` and add a subscriber with the same function code. + +2. Now in your app, start publishing to the `MyTopic.sst` instead of `MyTopic`. + +3. Remove the old `MyTopic` resource from the Serverless Framework app. + +Optionally, you can now create another new topic in SST called `MyTopic` and follow the steps above to remove the temporary `MyTopic.sst` topic. + +#### Migrate only the functions + +Now for resources that have persistent data like DynamoDB and S3, it won't be possible to remove them and recreate them. For these cases you have two choices: + +1. Use them as-is by referencing them +2. Or, migrate them over + +We talk about this in detail over on our doc on [Importing resources](../advanced/importing-resources.md). + +Here's an example of referencing a resource for DynamoDB streams. Assume you have a DynamoDB table that is named based on the stage it's deployed to. + +```yml title="serverless.yml" +resources: + Resources: + MyTable: + Type: AWS::DynamoDB::Table + Properties: + TableName: ${self:custom.stage}-MyTable + AttributeDefinitions: + - AttributeName: userId + AttributeType: S + - AttributeName: noteId + AttributeType: S + KeySchema: + - AttributeName: userId + KeyType: HASH + - AttributeName: noteId + KeyType: RANGE + BillingMode: 'PAY_PER_REQUEST' + StreamSpecification: + StreamViewType: NEW_IMAGE +``` + +Now in SST, you can reference the table and create an SST function to subscribe to its streams. + +```js +// Import table +const table = dynamodb.fromTableName( + stack, + "MyTable", + `${this.node.root.stage}-MyTable` +); + +// Create a Lambda function +const processor = new sst.Function(stack, "Processor", "processor.main"); + +// Subscribe function to the streams +processor.addEventSource( + new DynamoEventSource(table, { + startingPosition: lambda.StartingPosition.TRIM_HORIZON, + }) +); +``` + +If you want to completely migrate over a resource, it is a manual process but it'll give you full control. You can [follow these steps](../advanced/importing-resources.md#migrate-resources). + +## Workflow + +A lot of the commands that you are used to using in Serverless Framework translate well to SST. + +| Serverless Framework | SST | +| ------------------------- | ------------ | +| `serverless invoke local` | `sst dev` | +| `serverless package` | `sst build` | +| `serverless deploy` | `sst deploy` | +| `serverless remove` | `sst remove` | + +SST also supports the `IS_LOCAL` environment variable that gets set in your Lambda functions when run locally. + +### Invoking locally + +With the Serverless Framework you need to run the following command `serverless invoke local -f function_name` to invoke a function locally. + +With SST this can be done via PostMan, Hopscotch, curl or any other API client. However, with this event you are actually sending a request to API Gateway which then invokes your Lambda. + +## CI/CD + +If you are using GitHub Actions, Circle CI, etc., to deploy Serverless Framework apps, you can now add the SST versions to your build scripts. + +```bash +# Deploy the defaults +npx sst deploy + +# To a specific stage +npx sst deploy --stage prod + +# To a specific stage and region +npx sst deploy --stage prod --region us-west-1 + +# With a different AWS profile +AWS_PROFILE=production npx sst deploy --stage prod --region us-west-1 +``` + +## Serverless Dashboard + +If you are using the Serverless Dashboard, you can try out [Seed](https://seed.run) instead. It supports Serverless Framework and SST. So you can deploy the hybrid app that we've created here. + +Seed has a fully-managed CI/CD pipeline, monitoring, real-time alerts, and deploys a lot faster thanks to the [Incremental Deploys](https://seed.run/docs/what-are-incremental-deploys). It also gives you a great birds eye view of all your environments. + +## Lambda Function Triggers + +Following is a list of all the Lambda function triggers available in Serverless Framework. And the support status in SST (or CDK). + +| Type | Status | +| ---------------------- | ---------------------------------- | +| HTTP API | [Available](#http-api) | +| API Gateway REST API | [Available](#api-gateway-rest-api) | +| WebSocket API | [Available](#websocket) | +| Schedule | [Available](#schedule) | +| SNS | [Available](#sns) | +| SQS | [Available](#sqs) | +| DynamoDB | [Available](#dynamodb) | +| Kinesis | [Available](#kinesis) | +| S3 | [Available](#s3) | +| CloudWatch Events | [Available](#cloudwatch-events) | +| CloudWatch Logs | [Available](#cloudwatch-logs) | +| EventBus Event. | [Available](#eventbus-event) | +| EventBridge Event | [Available](#eventbridge-event) | +| Cognito User Pool | [Available](#cognito-user-pool) | +| ALB | Available | +| Alexa Skill | Available | +| Alexa Smart Home | Available | +| IoT | Available | +| CloudFront | _Coming soon_ | +| IoT Fleet Provisioning | _Coming soon_ | +| Kafka | _Coming soon_ | +| MSK | _Coming soon_ | + +## Plugins + +Serverless Framework supports a long list of popular plugins. In this section we'll look at how to adopt their functionality to SST. + +To start with, let's look at the very popular [serverless-offline](https://github.com/dherault/serverless-offline) plugin. It's used to emulate a Lambda function locally but it's fairly limited in the workflows it supports. There are also a number of other plugins that work with serverless-offline to support various other Lambda triggers. + +Thanks to `sst dev`, you don't need to worry about using them anymore. + +| Plugin | Alternative | +| ------------------------------------------------------------------------------------------------------------------------- | ----------- | +| [serverless-offline](https://github.com/dherault/serverless-offline) | `sst dev` | +| [serverless-offline-sns](https://github.com/mj1618/serverless-offline-sns) | `sst dev` | +| [serverless-offline-ssm](https://github.com/janders223/serverless-offline-ssm) | `sst dev` | +| [serverless-dynamodb-local](https://github.com/99x/serverless-dynamodb-local) | `sst dev` | +| [serverless-offline-scheduler](https://github.com/ajmath/serverless-offline-scheduler) | `sst dev` | +| [serverless-step-functions-offline](https://github.com/vkkis93/serverless-step-functions-offline) | `sst dev` | +| [serverless-offline-direct-lambda](https://github.com/civicteam/serverless-offline-direct-lambda) | `sst dev` | +| [CoorpAcademy/serverless-plugins](https://github.com/CoorpAcademy/serverless-plugins) | `sst dev` | +| [serverless-plugin-offline-dynamodb-stream](https://github.com/orchestrated-io/serverless-plugin-offline-dynamodb-stream) | `sst dev` | + +Let's look at the other popular Serverless Framework plugins and how to set them up in SST. + +| Plugin | Status | +| --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | +| [serverless-webpack](https://github.com/serverless-heaven/serverless-webpack) | SST uses esbuild to automatically bundle your functions | +| [serverless-domain-manager](https://github.com/amplify-education/serverless-domain-manager) | [`sst.Api` supports custom domains](#serverless-domain-manager) | +| [serverless-pseudo-parameters](https://github.com/svdgraaf/serverless-pseudo-parameters) | [CloudFormation pseudo parameters are not necessary in CDK](#serverless-pseudo-parameters) | +| [serverless-step-functions](https://github.com/serverless-operations/serverless-step-functions) | [Available in CDK](#serverless-step-functions) | +| [serverless-plugin-aws-alerts](https://github.com/ACloudGuru/serverless-plugin-aws-alerts) | [Available in CDK](#serverless-plugin-aws-alerts) | +| [serverless-plugin-typescript](https://github.com/graphcool/serverless-plugin-typescript) | SST natively supports TypeScript | +| [serverless-apigw-binary](https://github.com/maciejtreder/serverless-apigw-binary) | Available in CDK | +| [serverless-plugin-tracing](https://github.com/alex-murashkin/serverless-plugin-tracing) | Supported by SST | +| [serverless-aws-documentation](https://github.com/deliveryhero/serverless-aws-documentation) | _Coming soon_ | +| [serverless-dotenv-plugin](https://github.com/infrontlabs/serverless-dotenv-plugin) | _Coming soon_ | +| [serverless-plugin-split-stacks](https://github.com/dougmoscrop/serverless-plugin-split-stacks) | _Coming soon_ | +| [serverless-plugin-include-dependencies](https://github.com/dougmoscrop/serverless-plugin-include-dependencies) | _Coming soon_ | +| [serverless-iam-roles-per-function](https://github.com/functionalone/serverless-iam-roles-per-function) | Supported by SST | +| [serverless-plugin-monorepo](https://github.com/Butterwire/serverless-plugin-monorepo) | SST supports monorepo setups automatically | +| [serverless-log-forwarding](https://github.com/amplify-education/serverless-log-forwarding) | Available in CDK | +| [serverless-plugin-lambda-dead-letter](https://github.com/gmetzker/serverless-plugin-lambda-dead-letter) | Available in CDK | +| [serverless-plugin-stage-variables](https://github.com/svdgraaf/serverless-plugin-stage-variables) | Available in CDK | +| [serverless-stack-output](https://github.com/sbstjn/serverless-stack-output) | Supported by SST | +| [serverless-plugin-scripts](https://github.com/mvila/serverless-plugin-scripts) | _Coming soon_ | +| [serverless-finch](https://github.com/fernando-mc/serverless-finch) | Available in CDK | +| [serverless-stage-manager](https://github.com/jeremydaly/serverless-stage-manager) | [Supported by SST](#serverless-stage-manager) | +| [serverless-plugin-log-subscription](https://github.com/dougmoscrop/serverless-plugin-log-subscription) | Available in CDK | +| [serverless-plugin-git-variables](https://github.com/jacob-meacham/serverless-plugin-git-variables) | Available in CDK | +| [serverless-dynamodb-autoscaling](https://github.com/sbstjn/serverless-dynamodb-autoscaling) | Available in CDK | +| [serverless-aws-alias](https://github.com/serverless-heaven/serverless-aws-alias) | Available in CDK | +| [serverless-s3-remover](https://github.com/sinofseven/serverless-s3-remover) | _Coming soon_ | +| [serverless-s3-sync](https://github.com/k1LoW/serverless-s3-sync) | _Coming soon_ | +| [serverless-appsync-plugin](https://github.com/sid88in/serverless-appsync-plugin) | Available in CDK | +| [serverless-scriptable-plugin](https://github.com/weixu365/serverless-scriptable-plugin) | _Coming soon_ | +| [serverless-mysql](https://github.com/jeremydaly/serverless-mysql) | _Coming soon_ | +| [serverless-plugin-canary-deployments](https://github.com/davidgf/serverless-plugin-canary-deployments) | _Coming soon_ | +| [serverless-prune-plugin](https://github.com/claygregory/serverless-prune-plugin) | _Coming soon_ | + +## Examples + +A list of examples showing how to use Serverless Framework triggers or plugins in SST. + +### Triggers + +#### HTTP API + +```yml title="serverless.yml" +functions: + listUsers: + handler: listUsers.main + events: + - httpApi: + method: GET + path: /users + + createUser: + handler: createUser.main + events: + - httpApi: + method: POST + path: /users + + getUser: + handler: getUser.main + events: + - httpApi: + method: GET + path: /users/{id} +``` + +```js title="SST" +new Api(stack, "Api", { + routes: { + "GET /users": "listUsers.main", + "POST /users": "createUser.main", + "GET /users/{id}": "getUser.main", + }, +}); +``` + +#### API Gateway REST API + +```yml title="serverless.yml" +functions: + listUsers: + handler: listUsers.main + events: + - http: + method: GET + path: /users + + createUser: + handler: createUser.main + events: + - http: + method: POST + path: /users + + getUser: + handler: getUser.main + events: + - http: + method: GET + path: /users/{id} +``` + +```js title="SST" +new ApiGatewayV1Api(stack, "Api", { + routes: { + "GET /users": "listUsers.main", + "POST /users": "createUser.main", + "GET /users/{id}": "getUser.main", + }, +}); +``` + +#### WebSocket + +```yml title="serverless.yml" +functions: + connectHandler: + handler: connect.main + events: + - websocket: $connect + + disconnectHandler: + handler: disconnect.main + events: + - websocket: + route: $disconnect + + defaultHandler: + handler: default.main + events: + - websocket: + route: $default + + sendMessageHandler: + handler: sendMessage.main + events: + - websocket: + route: sendMessage +``` + +```js title="SST" +new WebSocketApi(stack, "Api", { + routes: { + $connect: "src/connect.main", + $default: "src/default.main", + $disconnect: "src/disconnect.main", + sendMessage: "src/sendMessage.main", + }, +}); +``` + +#### Schedule + +```yml title="serverless.yml" +functions: + crawl: + handler: crawl.main + events: + - schedule: rate(2 hours) +``` + +```js title="SST" +new Cron(stack, "Crawl", { + schedule: "rate(2 hours)", + job: "crawl.main", +}); +``` + +#### SNS + +```yml title="serverless.yml" +functions: + subscriber: + handler: subscriber.main + events: + - sns: dispatch + subscriber2: + handler: subscriber2.main + events: + - sns: dispatch +``` + +```js title="SST" +new Topic(stack, "Dispatch", { + subscribers: { + subscriber1: "subscriber.main", + subscriber2: "subscriber2.main", + }, +}); +``` + +#### SQS + +```yml title="serverless.yml" +functions: + consumer: + handler: consumer.main + events: + - sqs: + arn: + Fn::GetAtt: + - MyQueue + - Arn + +resources: + Resources: + MyQueue: + Type: "AWS::SQS::Queue" + Properties: + QueueName: ${self:custom.stage}-MyQueue +``` + +```js title="SST" +new Queue(stack, "MyQueue", { + consumer: "consumer.main", +}); +``` + +#### DynamoDB + +```yml title="serverless.yml" +functions: + processor: + handler: processor.main + events: + - stream: + type: dynamodb + arn: + Fn::GetAtt: + - MyTable + - StreamArn + +resources: + Resources: + MyTable: + Type: AWS::DynamoDB::Table + Properties: + TableName: ${self:custom.stage}-MyTable + AttributeDefinitions: + - AttributeName: userId + AttributeType: S + - AttributeName: noteId + AttributeType: S + KeySchema: + - AttributeName: userId + KeyType: HASH + - AttributeName: noteId + KeyType: RANGE + BillingMode: 'PAY_PER_REQUEST' + StreamSpecification: + StreamViewType: NEW_AND_OLD_IMAGES +``` + +```js title="SST" +new Table(stack, "MyTable", { + fields: { + userId: TableFieldType.STRING, + noteId: TableFieldType.STRING, + }, + primaryIndex: { partitionKey: "noteId", sortKey: "userId" }, + stream: true, + consumers: ["processor.main"], +}); +``` + +#### Kinesis + +```yml title="serverless.yml" +functions: + processor: + handler: processor.main + events: + - stream: + type: kinesis + arn: + Fn::Join: + - ":" + - - arn + - aws + - kinesis + - Ref: AWS::Region + - Ref: AWS::AccountId + - stream/MyKinesisStream +``` + +```js title="SST" +// Create stream +const stream = new kinesis.Stream(stack, "MyStream"); + +// Create Lambda function +const processor = new sst.Function(stack, "Processor", "processor.main"); + +// Subscribe function to streams +processor.addEventSource( + new KinesisEventSource(stream, { + startingPosition: lambda.StartingPosition.TRIM_HORIZON, + }) +); +``` + +#### S3 + +```yml title="serverless.yml" +functions: + processor: + handler: processor.main + events: + - s3: + bucket: MyBucket + event: s3:ObjectCreated:* + rules: + - prefix: uploads/ +``` + +```js title="SST" +// Create bucket +const bucket = new s3.Bucket(stack, "MyBucket"); + +// Create Lambda function +const processor = new sst.Function(stack, "Processor", "processor.main"); + +// Subscribe function to streams +processor.addEventSource( + new S3EventSource(bucket, { + events: [s3.EventType.OBJECT_CREATED], + filters: [{ prefix: "uploads/" }], + }) +); +``` + +#### CloudWatch Events + +```yml title="serverless.yml" +functions: + myCloudWatch: + handler: myCloudWatch.handler + events: + - cloudwatchEvent: + event: + source: + - "aws.ec2" + detail-type: + - "EC2 Instance State-change Notification" + detail: + state: + - pending +``` + +```js title="SST" +const processor = new sst.Function(stack, "Processor", "processor.main"); +const rule = new events.Rule(stack, "Rule", { + eventPattern: { + source: ["aws.ec2"], + detailType: ["EC2 Instance State-change Notification"], + }, +}); +rule.addTarget(new targets.LambdaFunction(processor)); +``` + +#### CloudWatch Logs + +```yml title="serverless.yml" +functions: + processor: + handler: processor.main + events: + - cloudwatchLog: + logGroup: "/aws/lambda/hello" + filter: "{$.error = true}" +``` + +```js title="SST" +const processor = new sst.Function(stack, "Processor", "processor.main"); +new SubscriptionFilter(stack, "Subscription", { + logGroup, + destination: new LogsDestinations.LambdaDestination(processor), + filterPattern: FilterPattern.booleanValue("$.error", true), +}); +``` + +#### EventBus Event + +```yml title="serverless.yml" +functions: + myFunction: + handler: processor.main + events: + - eventBridge: + eventBus: + Fn::GetAtt: + - MyEventBus + - Arn + pattern: + source: + - acme.transactions.xyz + +resources: + Resources: + MyEventBus: + Type: AWS::Events::EventBus + Properties: + Name: MyEventBus +``` + +```js title="SST" +const processor = new sst.Function(stack, "Processor", "processor.main"); +const rule = new events.Rule(stack, "MyEventRule", { + eventBus: new events.EventBus(stack, "MyEventBus"), + eventPattern: { + source: ["acme.transactions.xyz"], + }, +}); +rule.addTarget(new targets.LambdaFunction(processor)); +``` + +#### EventBridge Event + +```yml title="serverless.yml" +functions: + myFunction: + handler: processor.main + events: + - eventBridge: + pattern: + source: + - aws.cloudformation + detail-type: + - AWS API Call via CloudTrail + detail: + eventSource: + - cloudformation.amazonaws.com +``` + +```js title="SST" +const processor = new sst.Function(stack, "Processor", "processor.main"); +const rule = new events.Rule(stack, "rule", { + eventPattern: { + source: ["aws.cloudformation"], + detailType: ["AWS API Call via CloudTrail"], + detail: { + eventSource: ["cloudformation.amazonaws.com"], + }, + }, +}); +rule.addTarget(new targets.LambdaFunction(processor)); +``` + +#### Cognito User Pool + +```yml title="serverless.yml" +functions: + preSignUp: + handler: preSignUp.main + events: + - cognitoUserPool: + pool: MyUserPool + trigger: PreSignUp + existing: true +``` + +```js title="SST" +new sst.Auth(stack, "Auth", { + triggers: { + preSignUp: "src/preSignUp.main", + }, +}); +``` + +### Plugins + +#### serverless-domain-manager + +```yml title="serverless.yml" +plugins: + - serverless-domain-manager + +custom: + customDomain: + domainName: api.domain.com + +function: + listUsers: + handler: src/listUsers.main + events: + - httpApi: + method: GET + path: /users +``` + +```js title="SST" +new Api(stack, "Api", { + customDomain: "api.domain.com", + routes: { + "GET /users": "src/listUsers.main", + }, +}); +``` + +#### serverless-pseudo-parameters + +```yml title="serverless.yml" +plugins: + - serverless-pseudo-parameters + +resources: + Resources: + S3Bucket: + Type: AWS::S3::Bucket, + DeleteionPolicy: Retain + Properties: + BucketName: photos-#{AWS::AccountId} +``` + +```js title="SST" +new s3.Bucket(stack, "S3Bucket", { + bucketName: `photos-${stack.account}` +}; +``` + +#### serverless-step-functions + +```yml title="serverless.yml" +plugins: + - serverless-step-functions + +functions: + hello: + handler: hello.main + +StartAt: Wait +States: + Wait: + Type: Wait + Seconds: 300 + Next: Hello + Hello: + Type: Task + Resource: + Fn::GetAtt: + - hello + - Arn + Next: Decide + Decide: + Type: Choice + Choices: + - Variable: $.status + StringEquals: Approved + Next: Success + Default: Failed + Success: + Type: Succeed + Failed: + Type: Fail +``` + +```js title="SST" +// Define each state +const sWait = new sfn.Wait(stack, "Wait", { + time: sfn.WaitTime.duration(cdk.Duration.seconds(300)), +}); +const sHello = new tasks.LambdaInvoke(stack, "Hello", { + lambdaFunction: new sst.Function(stack, "Hello", "hello.main"), +}); +const sFailed = new sfn.Fail(stack, "Failed"); +const sSuccess = new sfn.Succeed(stack, "Success"); + +// Define state machine +new sfn.StateMachine(stack, "StateMachine", { + definition: sWait + .next(sHello) + .next( + new sfn.Choice(stack, "Job Approved?") + .when(sfn.Condition.stringEquals("$.status", "Approved"), sSuccess) + .otherwise(sFailed) + ), +}); +``` + +#### serverless-plugin-aws-alerts + +```yml title="serverless.yml" +plugins: + - serverless-plugin-aws-alerts + +custom: + alerts: + stages: + - production + topics: + alarm: + topic: ${self:service}-${opt:stage}-alerts-alarm + notifications: + - protocol: email + endpoint: foo@bar.com + alarms: + - functionErrors +``` + +```js title="SST" +// Send an email when a message is received +const topic = new sns.Topic(stack, "AlarmTopic"); +topic.addSubscription(new subscriptions.EmailSubscription("foo@bar.com")); + +// Post a message to topic when an alarm breaches +new cloudwatch.Alarm(stack, "Alarm", { + metric: lambda.metricAllErrors(), + threshold: 100, + evaluationPeriods: 2, +}); +alarm.addAlarmAction(new cloudwatchActions.SnsAction(topic)); +``` + +#### serverless-stage-manager + +```yml title="serverless.yml" +plugins: + - serverless-stage-manager + +custom: + stages: + - dev + - staging + - prod +``` + +```js title="SST" +if (!["dev", "staging", "prod"].includes(app.stage)) { + throw new Error("Invalid stage"); +} +``` diff --git a/www/docs/migrating/vercel.md b/www/docs/migrating/vercel.md new file mode 100644 index 0000000000..a44e14b63e --- /dev/null +++ b/www/docs/migrating/vercel.md @@ -0,0 +1,137 @@ +--- +title: Migrating From Vercel +sidebar_label: Vercel +description: "Migrate your Next.js app from Vercel to SST with OpenNext." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; + + + +A guide to migrating your Next.js app from Vercel to SST. + + + +--- + +## Why use SST instead of Vercel + +There are a couple of reasons why you might want to migrate your Next.js app from [Vercel](https://vercel.com) to SST. Since SST uses [OpenNext](https://open-next.js.org) to deploy to your AWS account: + +- It seamlessly integrates with your other AWS resources. This means that you can easily add other features to your Next.js app; like queues, databases, file uploads, or cron jobs. +- You also get more control over your infrastructure and the ability to customize it. +- Your data will never leave your AWS account. +- Finally, AWS is also a far cheaper option than Vercel. This is especially true for high traffic sites. + +--- + +## Add SST to your Next.js app + +Let's assume your Next.js app looks something like this: + +```txt +my-nextjs-app/ +β”œβ”€β”€ pages/ +β”‚ β”œβ”€β”€ index.ts +β”‚ └── about.ts +β”œβ”€β”€ next.config.js +└── package.json +``` + +Simply run the following in your package root. + +```bash +npx create-sst@latest +``` + +This will detect that it's running in a Next.js app and will add a `sst.config.ts` to the root. + +```txt {5} +my-nextjs-app/ +β”œβ”€β”€ pages/ +β”‚ β”œβ”€β”€ index.ts +β”‚ └── about.ts +β”œβ”€β”€ sst.config.ts +β”œβ”€β”€ next.config.js +└── package.json +``` + +The `sst.config.ts`, initializes this as an SST app and adds Next.js to it. + +```ts title="sst.config.ts" +const site = new NextjsSite(stack, "site"); +``` + +It'll also add the following packages to your `package.json` β€” `sst`, `aws-cdk-lib`, and `constructs`. And changes your Next.js `dev` script. + +```diff title="package.json" +- "dev": "next dev", ++ "dev": "sst bind next dev", +``` + +This allows your Next.js app to connect to AWS when it runs locally. + +--- + +#### Start the local environment + +Now to start your local environment, start SST. + +```bash +npx sst dev +``` + +Then start Next.js in another terminal. + +```bash +npm run dev +``` + +--- + +## Deploy your Next.js app to AWS + +With SST initialized in your Next.js app, you can deploy it to prod by running: + +```bash +npx sst deploy --stage prod +``` + +This will deploy your app to your AWS account using your [local AWS credentials](../advanced/iam-credentials.md#loading-from-a-file). Once deployed, you'll get an auto-generated URL that looks like β€” `https://d3j4c16hczgtjw.cloudfront.net`. + +At this point your app is deployed using both Vercel and SST. You can check and make sure that it's working properly before moving ahead. + +--- + +## Migrate your custom domain + +Next you might want to migrate your custom domain. If you have it on Vercel, you'll first need to [transfer it out of Vercel](https://vercel.com/guides/how-do-i-transfer-my-domain-out-of-vercel). Then you can [migrate it to Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-transfer-to-route-53.html). + +And add it to your `sst.config.ts`. + +```ts title="sst.config.ts" {2} +const site = new NextjsSite(stack, "site", { + customDomain: "my-nextjs-app.com", +}); +``` + +--- + +## Configure preview environments + +The SST CLI supports deploying to multiple stages (or environments). Simply pass in a stage name when you deploy your app. + +```bash +# Deploy to staging +npx sst deploy --stage staging +# Deploy to prod +npx sst deploy --stage prod +# Deploy a PR stage +npx sst deploy --stage pr123 +``` + +You can configure this with GitHub Actions. Alternatively, you can use [**_SEED_**](https://seed.run) β€” a service built by the SST team. You can connect your Git repo and it'll deploy your SST app when you `git push`. It also supports preview environments out of the box. + +--- + +Now that you've migrated your Next.js app to SST, you might want to add other backend features to it, or connect it to your other AWS resources. [Head over here to get started](../start/nextjs.md). diff --git a/www/docs/packages/create-sst.md b/www/docs/packages/create-sst.md new file mode 100644 index 0000000000..09e7e51c6a --- /dev/null +++ b/www/docs/packages/create-sst.md @@ -0,0 +1,113 @@ +--- +title: create-sst +description: "Reference docs for the create-sst CLI." +--- + +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; + + + +A simple CLI to create new SST projects. + + + +--- + +## Usage + +There's no need to install this CLI. Just use it directly to create your projects. + + + + +```bash +npx create-sst@latest +``` + + + + +```bash +yarn create sst +``` + + + + +```bash +pnpm create sst +``` + + + + +This will prompt you for a name and bootstrap a new project in that directory. + +--- + +## Options + +Pass in the following (optional) options. + +### `--template` + +Instead of the standard starter, you can choose to use one of our minimal setups or examples as the template to bootstrap. + + + + +```bash +npx create-sst@latest --template=other/go +``` + + + + +```bash +yarn create sst --template=other/go +``` + + + + +```bash +pnpm create sst --template=other/go +``` + + + + +--- + +## Arguments + +### `` + +Specify a project name, instead of typing it into the interactive prompt. + + + + +```bash +npx create-sst@latest my-sst-app +``` + + + + +```bash +yarn create sst my-sst-app +``` + + + + +```bash +pnpm create sst my-sst-app +``` + + + diff --git a/www/docs/packages/sst.md b/www/docs/packages/sst.md new file mode 100644 index 0000000000..6c07c40042 --- /dev/null +++ b/www/docs/packages/sst.md @@ -0,0 +1,503 @@ +--- +title: SST CLI +sidebar_label: sst +description: "Reference docs for the SST CLI." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +The SST CLI allows you to build, deploy, test, and manage SST apps. + + + +--- + +## Installation + +Install the [`sst`](https://www.npmjs.com/package/sst) npm package in your project root. + + + + +```bash +npm install sst --save-exact +``` + + + + +```bash +yarn add sst --exact +``` + + + + +```bash +pnpm add sst --save-exact +``` + + + + +If you are using our starters, the `sst` package should already be installed. + +--- + +## Usage + +Once installed, you can run the commands using. + + + + +```bash +npx sst +``` + + + + +```bash +yarn sst +``` + + + + +```bash +pnpm sst +``` + + + + +This will run the commands using the locally installed version of SST. + +--- + +### AWS profile + +Specify the AWS account you want to deploy to by using the `--profile` option. If not specified, uses the default AWS profile. [Read more about AWS profiles here](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-format). For example: + +```bash +npx sst deploy --profile=production +``` + +Where `production` is a profile defined locally in your `~/.aws/credentials`. + +Or, use the `AWS_PROFILE` CLI environment variable + +```bash +AWS_PROFILE=production npx sst deploy +``` + +--- + +## Commands + +Let's look at the commands in the SST CLI. + +--- + +### `sst dev` + +Starts up a local development environment for your Lambda functions, powered by [Live Lambda Dev](../live-lambda-development.md). It allows you to make changes and test your functions without having to deploy them. + +```bash +npx sst dev [options] +``` + +In addition to the [global options](#global-options), the following options are supported. + +#### Options + +- **`--rollback`** + + _Default_: `true` + + By default SST enables rollback on failure. This is so that any mistakes do not leave your infrastructure in an inconsistent state. To override this behavior pass in `--rollback=false`. + +- **`--increase-timeout`** + + _Default_: Default Lambda function timeout + + Pass in the `--increase-timeout` option if you want to increase the timeout value for all the Lambda functions in your app to 15 minutes (the maximum value). This gives you more time to inspect your breakpoints before the functions timeout. + + This option is meant to be used when debugging with VS Code or other debuggers that can set breakpoints. + + A couple of things to note when `--increase-timeout` option is enabled: + + - APIs have a timeout of 30 seconds. So if the Lambda function does not return after 30 seconds, the API request will timeout. However, you can continue to debug your Lambda functions. The request might fail but the breakpoint context is still preserved for 15 minutes. + - Queues need to have a [visibility timeout](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) that is longer than the timeout of the subscribing Lambda function. If the visibility timeout is configured to less than 15 minutes, it'll be increased to 15 minutes as well. + +--- + +### `sst diff` + +Compares the current version of the stacks in your app with the ones that've been deployed to AWS. This can be helpful in doing a quick check before deploying your changes to prod. + +```bash +npx sst diff [stacks..] [options] +``` + +You can diff against a stage. + +```bash +npx sst diff --stage prod +``` + +You can also optionally compare a list of stacks. + +```bash +npx sst diff stack-a stack-b +``` + +#### Options + +- **`--dev`** + + By default, SST will diff against the target stage as it would be deployed using `sst deploy`. If you are running a stage locally using [`sst dev`](../live-lambda-development.md), then pass in `--dev` to diff against the dev version. + +--- + +### `sst bind` + +Bind your app's resources to the given `command`. This allows the [`sst/node`](clients/index.md) client to work as if it was running inside a Lambda function. + +```bash +npx sst bind [options] +``` + +So for example, you can start your frontend with all the binding values. + +```bash +npx sst bind next dev +``` + +`sst bind` auto-detects the following frontend frameworks. + +- Angular: detects `angular.json` +- Astro: detects `astro.config.js` +- Create React App: detects `react-scripts` in `package.json` +- Ember: detects `ember-cli-build.js` +- Gatsby: detects `gatsby-config.js` +- Next.js: detects `next.config.js` +- Plain HTML: detects `index.html` +- Preact: detects `@preact/preset-vite` in `vite.config.js` +- React: detects `plugin-react` in `vite.config.js` +- Remix: detects `remix.config.js` +- Solid: detects `solid-start` in `vite.config.js` +- Svelte: detects `svelte.config.js` +- Vue: detects `plugin-vue` in `vite.config.js` + +When detected, `sst bind` will load the site's bound resources, environment variables, and the IAM permissions granted to the site. + +If a frontend framework is not detected in the current directory, `sst bind` will bind all the resources in your app and use it to run the command. + +For example, you can use it to [run your tests](../testing.md). + +```bash +npx sst bind vitest run +``` + +You can also use the `sst bind` to run any scripts. + +#### Options + +- **`--site`** + + If your framework is not auto-detected by SST, then pass in `--site` to signal to SST that you are starting your frontend. + + ```bash + npx sst bind --site npm run start + ``` + +- **`--script`** + + Similarly, if SST has detected a frontend framework in the current directory, but you are not starting your frontend, then pass in `--script`. This is useful when you are running a script inside your frontend directory. + + ```bash + npx sst bind --script npm run build + ``` + +--- + +### `sst build` + +Build your app and synthesize your stacks. Builds the assets for your functions and sites. And generates a `.sst/dist/` directory with the synthesized CloudFormation stacks. + +```bash +npx sst build [options] +``` + +In addition to the [global options](#global-options), the following options are supported. + +#### Options + +- **`--to`** + + _Default_: `.sst/dist/` + + Pass in a path for the build output. This lets you split up the deploy process and deploy without having to build the app again. + +--- + +#### Build concurrency + +SST will build your assets concurrently using the number of cores available. This can be changed using the `SST_BUILD_CONCURRENCY` environment variable. Where `SST_BUILD_CONCURRENCY` defaults to the `number of cores - 1`. + +--- + +### `sst deploy` + +Deploys your app to AWS. Or optionally deploy a specific stack by passing in a `filter`. + +```bash +npx sst deploy [filter] [options] +``` + +By default, it first builds your app and then deploys it. It also respects the [`SST_BUILD_CONCURRENCY`](#build-concurrency) environment variable. + +In addition to the [global options](#global-options), the following options are supported. + +#### Options + +- **`--from`** + + _Default_: none + + Pass in a path for the build output. This lets you split up the deploy process and deploy without having to build the app again. + +--- + +### `sst remove` + +Remove your app and all their resources from AWS. Or optionally deploy a specific stack by passing in a `filter`. + +```bash +npx sst remove [filter] [options] +``` + +:::info Removal Policy +By default, AWS does not remove resources like S3 buckets or DynamoDB tables. To let SST remove these, you'd need to [set the default removal policy](../advanced/removal-policy.md). +::: + +--- + +### `sst update` + +Updates the SST and CDK packages in your `package.json` to the latest version. Or optionally to the given `version`. + +```bash +npx sst update [version] [options] +``` + +--- + +### `sst version` + +Prints the version of SST your app is using. Also, prints the version of CDK that SST is using internally. + +```bash +npx sst version +``` + +:::info +When installing additional CDK packages make sure to use the same version as the one from the `sst verion` command. +::: + +--- + +### `sst console` + +```bash +npx sst console [options] +``` + +Launches the [SST Console](../console.md) to manage stages that are not running locally. It uses your local credentials (or the ones you specify) to make calls to AWS. + +For more context; if you run [`sst dev`](#dev) and fire up the Console, you'll see the logs for the local invocations of your functions. Whereas with the `sst console` command, you'll see their [CloudWatch](https://aws.amazon.com/cloudwatch/) logs instead. This allows you to use the Console against your production or staging environments. + +:::info +This command does not instrument your code. It simply uses your local credentials to make calls to AWS. +::: + +#### Options + +- **`--stage`** + + _Default_: Your local stage + + The stage you want connect to. If this is not specified, it will default to your local stage. + + Connecting to a different stage. + + ```bash + npx sst console --stage=staging + ``` + + Using a different aws profile if your stage is in another AWS account. + + ```bash + npx sst console --stage=production --profile=acme-production + ``` + +--- + +### `sst secrets` + +Manage secrets in your app. + +```bash +npx sst secrets [options] +``` + +For example, you can set a secret. + +```bash +npx sst secrets set MY_SECRET abc +``` + +Get the secret. + +```bash +npx sst secrets get MY_SECRET +``` + +And remove the secret. + +```bash +npx sst secrets remove MY_SECRET +``` + +#### Options + +- **`--fallback`** + + _Default_: false + + Set this option if you want to `get`, `set`, `list`, or `remove` the fallback version of a secret. For example, to get the fallback of a secret. + + ```bash + npx sst secrets get --fallback STRIPE_KEY + ``` + + Note that, the fallback value can only be inherited by stages deployed in the same AWS account and region. [Read more about fallback values](../config.md#fallback-values). + +`sst secrets` takes the following commands. + +--- + +#### `sst secrets get` + +Decrypts and prints the value of the secret with the given `name`. + +```bash +npx sst secrets get [options] +``` + +--- + +#### `sst secrets set` + +Sets the `value` of a secret with the given `name`. + +```bash +npx sst secrets set [options] +``` + +--- + +#### `sst secrets load` + +Loads secrets from an .env file. + +```bash +npx sst secrets load +``` + +--- + +#### `sst secrets list` + +Decrypts and prints out all the secrets with the given `format`; `table`, `json`, or `env`. Where `env` is the dotenv format. Defaults to `table`. + +```bash +npx sst secrets list [format] [options] +``` + +--- + +#### `sst secrets remove` + +Removes the secret with the given `name`. + +```bash +npx sst secrets remove [options] +``` + +--- + +### `sst telemetry` + +SST [collects completely anonymous telemetry](../anonymous-telemetry.md) data about general usage. + +```bash +npx sst telemetry [options] +``` + +You can opt-out of this if you'd not like to share any information. + +```bash +npx sst telemetry disable +``` + +You can also re-enable telemetry if you'd like to re-join the program. + +```bash +npx sst telemetry enable +``` + +--- + +## Global options + +- **`--stage`** + + _Default_: Your personal stage + + The stage you want to deploy to. If this is not specified, it will default to the stage configured during the initial run of the CLI. This is cached in the `.sst/` directory. + + This option applies to the `dev`, `build`, `deploy`, `remove`, and `secrets` commands. + +- **`--profile`** + + _Default_: The `default` profile in your AWS credentials file. + + The AWS profile you want to use for deployment. Defaults to the `default` profile in your AWS credentials file. + +- **`--region`** + + _Default_: Stage set in the SST config. + + The region you want to deploy to. Defaults to the one specified in your `sst.json`. Or uses `us-east-1`. + + This option applies to the `dev`, `build`, `deploy`, `remove`, and `secrets` commands. + +- **`--verbose`** + + _Default_: `false` + + Prints verbose logs. + +- **`--role`** + + ARN of the IAM Role to use when invoking AWS. This role must be assumable by the AWS account being used. + + This option applies to the `start`, `deploy`, and `remove` commands. diff --git a/www/docs/queues.md b/www/docs/queues.md new file mode 100644 index 0000000000..faededbb29 --- /dev/null +++ b/www/docs/queues.md @@ -0,0 +1,154 @@ +--- +title: Queues +description: "Queue up work to be processed" +--- + +import HeadlineText from "@site/src/components/HeadlineText"; + + + +Queue up work in your SST app. + + + +--- + +## Overview + +Typically most async scenarios should be handled with [Events](./events). However if you want more control over processing you can use Queues. + +Let's look at it in detail. + +--- + +#### Get started + +Start by creating a new SST + Next.js app by running the following command in your terminal. We are using Next.js for this example but you can use your favorite frontend. + +```bash +npx create-sst@latest --template standard/nextjs +``` + +--- + +## Create a queue + +Let's start by adding a queue to our app. + +```ts title="stacks/Default.ts" +const queue = new Queue(stack, "queue", { + consumer: "packages/functions/src/consumer.handler", +}); +``` + +:::info +A Queue can have only one consumer that can pull the messages from the queue. +::: + +Make sure to import the [`Queue`](constructs/Queue.md) construct. + +```diff title="stacks/Default.ts" +- import { StackContext, NextjsSite } from "sst/constructs"; ++ import { Queue, StackContext, NextjsSite } from "sst/constructs"; +``` + +This construct uses the [Amazon Simple Queue Service (SQS)](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html). + +--- + +## Bind the queue + +After adding the queue, bind your Next.js app to it. + +```diff title="stacks/Default.ts" +const site = new NextjsSite(stack, "site", { + path: "packages/web", ++ bind: [queue], +}); +``` + +This allows us to access the queue in our Next.js app. + +--- + +## Send to the queue + +Now in our Next.js API we'll send a message to the queue. + +```ts title="packages/web/pages/api/hello.ts" {8} +const sqs = new SQSClient({}); + +export default async function handler( + req: NextApiRequest, + res: NextApiResponse +) { + const command = new SendMessageCommand({ + QueueUrl: Queue.queue.queueUrl, + MessageBody: "Hello from Next.js!", + }); + await sqs.send(command); + + res.status(200).send("Hello World!"); +} +``` + +--- + +#### Add the imports + +Import the required packages. + +```ts title="packages/web/pages/api/hello.ts" +import { Queue } from "sst/node/queue"; +import type { NextApiRequest, NextApiResponse } from "next"; +import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; +``` + +Make sure to install the AWS SDK. + +```bash +npm install @aws-sdk/client-sqs +``` + +--- + +## Add the queue handler + +Finally, we can create the Lambda function that'll get invoked when things get sent to the queue. + +```ts title="packages/functions/src/consumer.ts" +import { SQSEvent } from "aws-lambda"; + +export async function handler(event: SQSEvent) { + const records: any[] = event.Records; + console.log(`Message processed: "${records[0].body}"`); + + return {}; +} +``` + +Now if you go to the API endpoint in your browser β€” `http://localhost:3000/api/hello`, you can go to your terminal and you'll notice that the message in the queue has been processed. + +--- + +## Other options + +Aside from queues you have a couple of other options for handling more complex asynchronous tasks in your app. + +### KinesisStream + +The [`KinesisStream`](constructs/KinesisStream.md) construct uses [Amazon Kinesis Data Streams](https://docs.aws.amazon.com/streams/latest/dev/introduction.html). + +```ts title="stacks/Default.ts" +import { KinesisStream } from "sst/constructs"; + +new KinesisStream(stack, "stream", { + consumers: { + consumer1: "packages/functions/src/consumer1.handler", + consumer2: "packages/functions/src/consumer2.handler", + }, +}); +``` + +It's similar to the [`Queue`](constructs/Queue.md) in that the consumer pulls the messages, but it's designed to allow for multiple consumers. A KinesisStream also keeps a **record of historical messages** for up to 365 days, and consumers can **re-process them**. This makes it a good fit for cases where you are dealing with a large number of events. + diff --git a/www/docs/resource-binding.md b/www/docs/resource-binding.md new file mode 100644 index 0000000000..a4538e105b --- /dev/null +++ b/www/docs/resource-binding.md @@ -0,0 +1,493 @@ +--- +title: Resource Binding +description: "Access the resources in your SST app in a secure and typesafe way." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; + + + +Access the resources in your app in a secure and typesafe way. + + + +--- + +## Overview + +**Resource Binding** allows you to connect your infrastructure to your frontends and functions. This is done in two steps: + +1. Bind a resource to your frontend or API through the `bind` prop. +2. Use the [`sst/node`](clients/index.md) package to access the resource in your function. + +--- + +## Quick start + +To see how Resource Binding works, we are going to create an S3 bucket and bind it to a Next.js frontend. + +To follow along, you can create a new SST app by running `npx create-sst@latest`. Alternatively, you can refer to [this example repo](https://github.com/serverless-stack/sst/tree/master/examples/standard-nextjs) that's based on the same template. + +1. To create a new bucket, open up `stacks/Default.ts` and add a [`Bucket`](constructs/Bucket.md) construct below the [`NextjsSite`](constructs/NextjsSite.md). + + ```ts title="stacks/Default.ts" + const bucket = new Bucket(stack, "public"); + ``` + + You'll also need to import `Bucket` at the top. + + ```ts + import { Bucket } from "sst/constructs"; + ``` + +2. Then, bind the `bucket` to the `site`. + + ```diff title="stacks/Default.ts" + const site = new NextjsSite(stack, "site", { + path: "packages/next", + + bind: [bucket], + }); + ``` + +3. Now we can access the bucket's name in our frontend using the [`Bucket`](clients/bucket.md) helper. Add this to `packages/next/pages/index.ts` to generate a presigned URL. + + ```ts title="packages/next/pages/index.ts" {10} + import crypto from "crypto"; + import { Bucket } from "sst/node/bucket"; + import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; + import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; + + export async function getServerSideProps() { + const command = new PutObjectCommand({ + ACL: "public-read", + Key: crypto.randomUUID(), + Bucket: Bucket.public.bucketName, + }); + const url = await getSignedUrl(new S3Client({}), command); + + return { props: { url } }; + } + ``` + + And install the AWS SDK for this example. + + ```bash + npm install --save @aws-sdk/client-s3 @aws-sdk/s3-request-presigner + ``` + + That's it! + +:::tip +Since we are dealing with sensitive info, resource binding is only supported in the frontend's server side functions. To access these on the client side, [check out the section below](#client-side-environment-variables). +::: + +While we are using the [`NextjsSite`](constructs/NextjsSite.md) in this example, resource binding is supported in all SST functions and SSR frontends. With the exception of the [`RemixSite`](constructs/RemixSite.md), since Remix does not fully support top-level await yet. + +--- + +## Features + +Let's take a look at some of the key features of Resource Binding, and how it makes building apps fun and easy again. + +--- + +### Typesafety + +In the above example, the `Bucket` object that's imported from `sst/node/bucket` is typesafe. Your editor should be able to autocomplete the bucket name `public`, as well as its property `bucketName`. + +
    +Behind the scenes + +Let's take a look at how this is all wired up. + +1. First, the `sst/node/table` package predefines an interface. + + ```ts + export interface BucketResources {} + ``` + +2. When SST builds the app, it generates a type file and adds the bucket name to the `BucketResources` interface. + + ```ts title=".sst/types/index.ts" + import "sst/node/bucket"; + declare module "sst/node/bucket" { + export interface BucketResources { + public: { + bucketName: string; + }; + } + } + ``` + +3. So when the `Bucket` object is imported from `sst/node/bucket`, it has the type `BucketResources`. + +
    + +--- + +### Error handling + +If you reference a resource that doesn't exist in your SST app, or hasn't been bound to the frontend, you'll get a runtime error. + +For example, if you forget to bind the `bucket` to the `site`, you'll get the following error when the function is invoked. + +``` +Cannot use Bucket.public. Please make sure it is bound to this function. +``` + +--- + +### Testing + +When testing your code, you can use the [`sst bind`](packages/sst.md#sst-bind) CLI to bind the resources to your tests. + +```bash +sst bind vitest run +``` + +This allows the [`sst/node`](clients/index.md) helper library to work as if it was running inside a Lambda function. + +[Read more about testing](testing.md) and [learn about the `sst bind` CLI](testing.md#how-sst-bind-works). + +--- + +### Permissions + +When a resource is bound to a Lambda function, the permissions to access that resource are automatically granted to the function. + +```ts +site.bind([bucket]); +``` + +Here, by binding the `bucket` to the `site`, the frontend is able to perform file download, upload, delete, and other actions against the bucket. + +
    +Behind the scenes + +An IAM policy is added to the Lambda function's role, allowing it to perform `s3:*` actions on the S3 bucket's ARN. + +The IAM policy statement looks like: + +```yml +{ + "Action": "s3:*", + "Resource": ["arn:aws:s3:::{BUCKET_NAME}", "arn:aws:s3:::{BUCKET_NAME}/*"], + "Effect": "Allow", +} +``` + +
    + +--- + +### Construct support + +Resource Binding works across all [SST constructs](constructs/index.md). Here are a few more examples. + +- DynamoDB table name + + ```ts + import { Table } from "sst/node/table"; + + Table.myTable.tableName; + ``` + +- RDS cluster data + + ```ts + import { RDS } from "sst/node/rds"; + + RDS.myDB.clusterArn; + RDS.myDB.secretArn; + RDS.myDB.defaultDatabaseName; + ``` + +See the [full list of helpers](clients/index.md). + +--- + +## Binding other resources + +So far we've seen how Resource Binding allows your frontend to access values from other SST constructs. But there are 2 other types of values you might want to access in your frontend. + +1. Secrets, because you can't define the value of the secrets in your frontend. +2. Values from non-SST constructs, for example static values or values from CDK constructs. + +For these you can use [`Config`](config.md). Here are a couple of examples. + +--- + +#### Binding secrets + +To bind a secret to our frontend, start by creating a `Config.Secret` construct. + +```ts +const STRIPE_KEY = new Config.Secret(stack, "STRIPE_KEY"); +``` + +And continuing with our example, bind it to the `site`. + +```diff +const site = new NextjsSite(stack, "site", { + path: "packages/next", ++ bind: [STRIPE_KEY], +}); +``` + +Now set the secret value using the SST CLI. + +```bash +npx sst secrets set STRIPE_KEY sk_test_abc123 +``` + +And access the value in the function. + +```ts +import { Config } from "sst/node/config"; + +Config.STRIPE_KEY; +``` + +You can [read more about secrets](config.md#secrets). + +--- + +#### Binding CDK resources + +Assuming you have an ECS cluster in your app and you need to pass the cluster name to your function. + +Since SST doesn't have a construct for ECS, create a `Config.Parameter` construct with the cluster name being the value. + +```ts +const cluster = new ecs.Cluster(stack, "myCluster"); + +const MY_CLUSTER_NAME = new Config.Parameter(stack, "MY_CLUSTER_NAME", { + value: cluster.clusterName, +}); +``` + +Then bind it to the `site` from our example. + +```diff +const site = new NextjsSite(stack, "site", { + path: "packages/next", ++ bind: [MY_CLUSTER_NAME], +}); +``` + +And you can access the value in your function. + +```ts +import { Config } from "sst/node/config"; + +Config.MY_CLUSTER_NAME; +``` + +--- + +## Client side access + +So far we've looked at how you can use the [`sst/node`](clients/index.md) client in your functions or in your frontend's server side functions. But there might be cases where you want to access something on the client side. + +To do this, you can pass props from the server functions to the client side. Using the example from above. + +```ts {4} +export async function getServerSideProps() { + return { + props: { + bucketName: Bucket.public.bucketName, + }, + }; +} +``` + +:::caution +Be careful not to pass any secrets or sensitive info to the client. +::: + +We can read the bucket name in the `getServerSideProps` function and pass it as a prop to our component. + +```ts {1} +export default function Home({ bucketName }: { bucketName: string }) { + // Render component +} +``` + +Alternatively, you can set directly set client side environment variables. + +--- + +#### Client side environment variables + +However, Frontends (like Next.js, Remix, etc.) can read from an environment variable purely on the client side. SST supports setting these client side environment variables as well. + +This is useful if you have a completely static frontend and you want to pass in the outputs of other constructs in your SST app. Let's look at how. + +Imagine you have an S3 bucket created using the [`Bucket`](constructs/Bucket.md) construct, and you want to access the name of the bucket in your client side code. You can use the `environment` property in your [`NextjsSite`](constructs/NextjsSite.md) construct. + +```ts {4-6} +const bucket = new Bucket(stack, "Bucket"); + +new NextjsSite(stack, "Site", { + environment: { + NEXT_PUBLIC_BUCKET_NAME: bucket.bucketName, + }, +}); +``` + +Now you can access the bucket's name in your client side code. + +```ts +console.log(process.env.NEXT_PUBLIC_BUCKET_NAME); +``` + +In Next.js, only environment variables prefixed with `NEXT_PUBLIC_` are available in your client side code. [Read more about using environment variables](https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser). + +--- + +## How it works + +When a resource is bound to a Lambda function, the resource values are stored as environment variables for the function. In our example, the bucket name is stored as a Lambda environment variable named `SST_Bucket_bucketName_myBucket`. + +At runtime, the `sst/node/bucket` package uses [top-level await](https://v8.dev/features/top-level-await) to read the value `process.env.SST_Bucket_bucketName_myBucket` and make it accessible via `Bucket.myBucket.bucketName`. + +SST also stores a copy of the bucket name in [AWS SSM](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html). In this case, an SSM parameter of the type `String` is created with the name `/sst/{appName}/{stageName}/Bucket/myBucket/bucketName`, where `{appName}` is the name of your SST app, and `{stageName}` is the stage. The parameter value is the name of the bucket stored in plain text. + +Storing the bucket name in SSM might seem redundant. But it provides a convenient way to fetch all the bound resources in your application. This can be extremely useful for testing. This isn't possible when using Lambda environment variables and [we are going to see why](#resource-binding-or-lambda-environment-variables). + +--- + +#### Binding sensitive values + +When binding resources that contain sensitive values, placeholders are stored in the Lambda environment variables. The actual values are stored inside SSM. At runtime, the values are fetched from SSM when the Lambda container first boots up using top-level await. And the values are cached for subsequent invocations. This is similar to how [`Config.Secret`](config.md#secrets) works. + +--- + +#### Typesafety + +When running `sst build`, `sst deploy`, or `sst dev`, types are generated for the defined resources and `Config` properties in the `.sst` directory. + +:::tip +If you are using one of our starters, this should be done automatically for you. +::: + +To use these types, place the following `sst-env.d.ts` file in any package that needs the types. + +```js title="sst-env.d.ts" +/// +``` + +Make sure you specify the path to the `.sst` directory correctly. With this in place, your IDE should recognize the generated types and autocomplete them. + +--- + +#### Client side environment variables + +On `sst deploy` client side environment variables will first be replaced by placeholder values, ie. `{{ NEXT_PUBLIC_BUCKET_NAME }}`, when building the Next.js app. And after the S3 bucket has been created, the placeholders in the HTML and JS files will then be replaced with the actual values. + +:::caution +Since the actual values are determined at deploy time, you should not rely on the values at build time. For example, you cannot reference `process.env.NEXT_PUBLIC_BUCKET_NAME` inside `getStaticProps()` at build time. + +There are a couple of workarounds: + +- Hardcode the bucket name +- Read the bucket name dynamically at build time (ie. from an SSM value) +- Use [fallback pages](https://nextjs.org/docs/basic-features/data-fetching#fallback-pages) to generate the page on the fly + +::: + +Note that since edge functions don't support Lambda environment variables, the above token replace method is also used. + +--- + +#### Working locally + +Resource binding works a little differently for the frontend sites because SST does not run them locally. Instead you wrap your frontend local dev command with `sst bind`. For example, you run `sst bind next dev` for Next.js. + +```json title="package.json" {2} +"scripts": { + "dev": "sst bind next dev", + "build": "next build", + "start": "next start" +}, +``` + +Note that, `sst bind` only works if the Next.js app is located inside the SST app or inside one of its subdirectories. For example: + +``` +/ + sst.config.ts + my-next-app/ +``` + +There are a couple of things happening behind the scenes here: + +1. The `sst dev` command generates stores all the bound resources and environment variables in your AWS account as something called the _stack metadata_. +2. The `sst bind` CLI loads these environment variables and sets them for your frontend's local development environment. It also gets an IAM role similar to the one that your SSR function will have when deployed. +3. When you call `sst/node` in your frontend, it'll use the IAM role to fetch the resources you are trying to access from the _stack metadata_. + +--- + +## Cost + +Resource Binding values are stored in AWS SSM with the _Standard Parameter type_ and _Standard Throughput_. This makes AWS SSM [free to use](https://aws.amazon.com/systems-manager/pricing/) in your SST apps. However when storing a `Config.Secret` the value is encrypted by AWS KMS. These are retrieved at runtime in your Lambda functions when it starts up. AWS KMS has a [free tier](https://aws.amazon.com/kms/pricing/#Free_tier) of 20,000 API calls per month. And it costs $0.03 for every 10,000 subsequent API calls. This is worth keeping in mind as these secrets are fetched per Lambda function cold start. + +--- + +## FAQ + +Here are some frequently asked questions about Resource Binding. + +--- + +### Resource Binding or Lambda environment variables? + +Prior to Resource Binding, people used Lambda environment variables to pass information to their functions. + +Aside from the lack of typesafety and error handling, Lambda environment variables have a few drawbacks. Imagine you have a Lambda function that looks like this. + +```ts title="packages/functions/src/updated.ts" +export const handler = async () => { + if (process.env.TOPIC_NAME !== "UserUpdated") { + return; + } + + // ... +}; +``` + +Where `TOPIC_NAME` is stored as a Lambda environment variable. You'll need to handle the following: + +1. When testing this function, locally or in your CI, you need to figure out the value for `TOPIC_NAME` and set it as an environment variable. + +2. In addition, imagine you have another function that also has a `TOPIC_NAME` Lambda environment variable, but with a different value. + + ```ts title="packages/functions/src/charged.ts" + export const handler = async () => { + if (process.env.TOPIC_NAME !== "InvoiceCharged") { + return; + } + + // ... + }; + ``` + + What should the `TOPIC_NAME` be in your tests? + +With Resource Binding, the value for the topic name is also stored in SSM. When running tests, SST can automatically fetch this from SSM using the `sst bind` CLI. + +--- + +### Does this make my Lambda functions slower? + +No. The resource values are stored as environment variables for the function. At runtime, reading from environment variables is instantaneous. + +For sensitive values, the values are stored in AWS SSM. When the Lambda container first boots up, the values are fetched from SSM and are cached for subsequent invocations. + +--- + +### What if I'm not using Node.js runtime? + +For non-Node.js runtimes, you can continue to use Lambda environment variables. + +If you want to use Resource Binding, you would need to read the bound values from the Lambda environment variable and AWS SSM directly. Refer to the [`sst/node`](clients/index.md) package to see how it is done in Node.js. diff --git a/www/docs/setting-up-aws.md b/www/docs/setting-up-aws.md new file mode 100644 index 0000000000..262efc17b5 --- /dev/null +++ b/www/docs/setting-up-aws.md @@ -0,0 +1,169 @@ +--- +title: Setting up AWS +description: "Learn how to correctly sign up for and set up your AWS account." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +Set up your AWS account and manage your environments and credentials in a simple and secure way. + + + +--- + +## Overview + +If you go through the default onboarding for AWS you'll likely miss a few features that will make your team's lives a whole lot easier. If you're currently using IAM users or have api keys in credentials files, that's a sign you should read this guide. + +:::tip +If you are using IAM users or have credential files, you should follow this guide. +::: + +The ideal setup is multiple AWS accounts grouped under a single AWS Organization while human users authenticate through SSO for both Console and CLI access. + +--- + +## Setup + +All this sounds complicated but it is a one time process and you'll never have to think about it again. + +Let's get started. + +--- + +### Create a management account + +1. The first step is to [create a management account](https://portal.aws.amazon.com/billing/signup?type=enterprise#/start/email). + + - Ideally use a work email alias - for example `aws@acme.com` that forwards to your real email. This allows you to give other people access in the future. + - The account name should just be your company name - for example `acme` + - These credentials are overly powerful - you should rarely ever need them again. Feel free to throw away the password after completing this guide. You can always do a password reset if it's needed. + - Enter your billing info and confirm your identity + - Choose basic support - can upgrade later if needed + +2. Once you're done you should be able to login and access the AWS Console. Search "AWS Organization" in the search bar to go to the organizations section and click **Create an organization**. That should be pretty immediate and you'll see the management account you're currently in is already in the organization. + +3. This management account won't have anything deployed to it besides IAM Identity Center which is how you'll manage your users. Search "IAM Identity Center" and go to its dashboard. Click **Enable** to set it up. + + - Note the region you're in in the top right. IAM Identity Center will be created in one region and you cannot change it. However, it doesn't matter too much which one it is. + - Click **Enable** + - This will give your organization a unique URL to login at. This is autogenerated but you can click **Customize** to select a unique name. You will want to bookmark this for later. + - Click **Users** on the left and then **Add user** to create your first user - yourself. Make your username your work email - eg `dax@acme.com` and fill out the required fields. + - Skip adding user to groups and finish creating the user. + +4. The user is created but doesn't actually have access to any AWS accounts. To add them, go to the left panel and click **AWS Accounts**. + + - Select your management account (should be tagged management account) and click **Assign users or groups**. + - Select the Users tab, make sure your user is selected and hit **Next** + - We'll need to create a new permission set - this is a one time task. Click **Create permission set** + - In the new tab select "Predefined permission set" and "AdministratorAccess". Click **Next** + - Increase session duration to 12 hours (this is most convenient). Click **Next** and then **Create**. + - Close the tab, return to the previous one and hit the refresh icon. Select AdministratorAccess and click **Next** and then **Submit** + - Although this was complicated, all we did was grant the user to assume an "AdministratorAccess role" into the management account. You can add more users in the future by following these same steps but you can reuse the AdministratorAccess role you created. + +:::tip +If you already have an SSO provider (eg Google) you can allow your team to "Login with Google" instead of managing separate passwords. We haven't documented this yet but join our [Discord](https://sst.dev/discord) and ask about it. +::: + +5. Now you're ready to login. Check your email and you should have an invitation to login. + + - Accept the invite and create a new password. Be sure to save it in your password manager - this one is important. + - Sign in and you should see your organization with a list of accounts below. + - You'll currently only have access to the management account we setup so click it and you should see the AdministratorAccess role. + - Click **Management Console** to login to the AWS Console + +You're now done setting up the root account! + +--- + +### Create dev and prod accounts + +As mentioned earlier, your management account isn't meant to actually host any resources. A good initial setup is to create separate `dev` and `production` accounts to create some isolation. The `dev` account will be shared between your team while the `production` account is just for production. You can get fancier with a staging account or an account per dev but we'll start simple. + +1. Navigation back to "AWS Organizations" by searching it in the console. + + - Click _Add an AWS account_ + - For the account name append `-dev` to whatever you called your management account. For example `acme-dev` + - For the email address choose a new email alias - if you're using Google for email you can simply do `aws+dev@acme.com` and it'll still go to your `aws@acme.com` email. + - Click **Create AWS account** + - Repeat this step for `-production` as well. + +2. It'll take a few seconds to finish creating but once it's done head over to "IAM Identity Center" to grant your user access. + + - Select the "AWS Accounts" tab on the left + - Select your newly created `acme-dev` and `acme-production` accounts and click **Assign users or groups** + - In the "Users" tab select your user and click **Next** + - Select the "AdministratorAccess" permission set and click **Next** and **Submit** + +3. Once that's complete go back to your SSO url (if you forgot to bookmark this you can click "Dashboard" to see the URL on the right). You should now see three different accounts and you'll be able to login to whichever one you want. + +--- + +### Setup the AWS CLI + +What's great about this setup is you no longer need to generate API keys for your local machine - you can just use SSO. A single configuration file will work for the AWS CLI, SST, and any random scripts you want to run and there will never be any long lived credentials stored on disk. + +1. Create a file at `~/.aws/config` and add an `[sso-session]` block like this + + ```bash title="~/.aws/config" + [sso-session acme] + sso_start_url = https://acme.awsapps.com/start + sso_region = us-east-1 + ``` + +Be sure to update the URL with your SSO url that you bookmarked and the region where you created IAM Identity Center. + +2. Then add an entry for each environment - `dev` and `production`. + + ```bash title="~/.aws/config" + [profile acme-dev] + sso_session = acme + sso_account_id = + sso_role_name = AdministratorAccess + region = us-east-1 + + [profile acme-production] + sso_session = acme + sso_account_id = + sso_role_name = AdministratorAccess + region = us-east-1 + ``` + +You can find the account ID from your SSO login url. If you expand the account you will see it listed with a `#` sign. The region specified in the config is the default region the CLI will use when one isn't specified. + +3. Now you can login by running `aws sso login --sso-session=acme`. This will open your browser and prompt you to allow access. The sessions will last 12 hours as configured in previous steps so you will have to run this once a day. It can be helpful to add this to a `package.json` script so people can just run `pnpm sso` to login. + +4. Test that everything is working with a simple cli command targeted at your dev account + + ```bash + aws sts get-caller-identity --profile=acme-dev + ``` + +--- + +### Configure SST + +If you have an SST project there's some useful configuration you can add to make everything work smoothly. + +1. In your `sst.config.ts` file you can conditionally choose the right profile depending on the stage you are deploying to. + + ```js title="sst.config.ts" {5} + config(input) { + return { + name: "my-sst-app", + region: "us-east-1", + profile: input.stage === "production" ? "acme-production" : "acme-dev", + }; + } + ``` + +This will use the `acme-production` profile just for production and use `acme-dev` for everything else. + +2. Do a production deploy + + ``` + sst deploy --stage=production + ``` diff --git a/www/docs/start/astro.md b/www/docs/start/astro.md new file mode 100644 index 0000000000..ec9cc2d35d --- /dev/null +++ b/www/docs/start/astro.md @@ -0,0 +1,300 @@ +--- +sidebar_label: Astro +title: Use Astro with SST +description: "Create and deploy an Astro site to AWS with SST." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +Create and deploy an Astro site to AWS with SST. + + + +--- + +## Prerequisites + +You'll need at least [Node.js 16](https://nodejs.org/) and [npm 7](https://www.npmjs.com/). You also need to have an AWS account and [**AWS credentials configured locally**](advanced/iam-credentials.md#loading-from-a-file). + +--- + +## 1. Create a new site + +Create a new Astro site. + + + + +```bash +npx create-astro@latest +``` + + + + +```bash +yarn create astro +``` + + + + +```bash +pnpm create astro +``` + + + + +Now initialize SST in your project root. + + + + +```bash +cd astro-project +npx create-sst@latest +``` + + + + +```bash +cd astro-project +yarn create sst +``` + + + + +```bash +cd astro-project +pnpm create sst +``` + + + + +:::tip Ready to deploy +Your Astro site is now ready to be deployed to AWS! Just run β€” `npx sst deploy`. But let's take a second to look at how SST makes it easy to add other features to your site. +::: + +Start your local dev environment. + + + + +```bash +# Start SST locally +npx sst dev +# Start Astro locally +npm run dev +``` + + + + +```bash +# Start SST locally +yarn sst dev +# Start Astro locally +yarn run dev +``` + + + + +```bash +# Start SST locally +pnpm sst dev +# Start Astro locally +pnpm run dev +``` + + + + +--- + +## 2. Add file uploads + +Let's add a file upload feature to our Astro site. + +--- + +#### Add an S3 bucket + +Add an S3 bucket to your `sst.config.ts`. + +```ts title="sst.config.ts" +const bucket = new Bucket(stack, "public"); +``` + +Bind it to your Astro site. + +```diff title="sst.config.ts" +const site = new AstroSite(stack, "site", { ++ bind: [bucket], +}); +``` + +--- + +#### Generate a presigned URL + +To upload a file to S3 we'll generate a presigned URL. Add this to the front matter of `pages/index.astro`. + +```ts title="pages/index.astro" {4} +const command = new PutObjectCommand({ + ACL: "public-read", + Key: crypto.randomUUID(), + Bucket: Bucket.public.bucketName, +}); +const url = await getSignedUrl(new S3Client({}), command); +``` + +:::tip +With SST we can access our infrastructure in a typesafe way β€” `Bucket.public.bucketName`. [Learn more](resource-binding.md). +::: + +--- + +#### Add an upload form + +Let's add the form. Replace the `Layout` component in `pages/index.astro` with. + +```html title="pages/index.astro" + +
    +
    + + +
    + +
    +
    +``` + +This will upload an image and redirect to it! + +--- + +## 3. Add a cron job + +Next, we'll add a cron job to remove the uploaded files every day. Add this to `sst.config.ts`. + +```ts title="sst.config.ts" {5} +new Cron(stack, "cron", { + schedule: "rate(1 day)", + job: { + function: { + bind: [bucket], + handler: "functions/delete.handler", + }, + }, +}); +``` + +Just like our Astro site, we are binding the S3 bucket to our cron job. + +--- + +#### Add a cron function + +Add a function to `functions/delete.ts` that'll go through all the files in the bucket and remove them. + +```ts title="functions/delete.ts" +export async function handler() { + const client = new S3Client({}); + + const list = await client.send( + new ListObjectsCommand({ + Bucket: Bucket.public.bucketName, + }) + ); + + await Promise.all( + (list.Contents || []).map((file) => + client.send( + new DeleteObjectCommand({ + Key: file.Key, + Bucket: Bucket.public.bucketName, + }) + ) + ) + ); +} +``` + +And that's it. We have a simple Astro site that uploads files to S3 and runs a cron job to delete them! + +--- + +## 4. Deploy to prod + +Let's end with deploying our site to production. + + + + +```bash +npx sst deploy --stage prod +``` + + + + +```bash +yarn sst deploy --stage prod +``` + + + + +```bash +pnpm sst deploy --stage prod +``` + + + + +![Astro site deployed to AWS with SST](/img/start/astro-site-deployed-to-aws-with-sst.png) + +:::info +[View the source](https://github.com/serverless-stack/sst/tree/master/examples/quickstart-astro) for this example on GitHub. +::: + +--- + +## Next steps + +1. Learn more about SST + - [`Cron`](../constructs/Cron.md) β€” Add a cron job to your app + - [`Bucket`](../constructs/Bucket.md) β€” Add S3 buckets to your app + - [`AstroSite`](../constructs/AstroSite.md) β€” Deploy Astro sites to AWS + - [Live Lambda Dev](../live-lambda-development.md) β€” SST's local dev environment + - [Resource Binding](../resource-binding.md) β€” Typesafe access to your resources +2. Ready to dive into the details of SST? [**Check out our tutorial**](../learn/index.md). diff --git a/www/docs/start/nextjs.md b/www/docs/start/nextjs.md new file mode 100644 index 0000000000..2eef449476 --- /dev/null +++ b/www/docs/start/nextjs.md @@ -0,0 +1,309 @@ +--- +sidebar_label: Next.js +title: Use Next.js with SST +description: "Create and deploy a Next.js app to AWS with SST and OpenNext." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +Create and deploy a Next.js app to AWS with SST and [OpenNext](https://open-next.js.org). + + + +--- + +## Prerequisites + +You'll need at least [Node.js 16](https://nodejs.org/) and [npm 7](https://www.npmjs.com/). You also need to have an AWS account and [**AWS credentials configured locally**](advanced/iam-credentials.md#loading-from-a-file). + +--- + +## 1. Create a new app + +Create a new Next.js app. + + + + +```bash +npx create-next-app@latest +``` + + + + +```bash +yarn create next-app +``` + + + + +```bash +pnpm create next-app +``` + + + + +Now initialize SST in your project root. + + + + +```bash +cd my-app +npx create-sst@latest +``` + + + + +```bash +cd my-app +yarn create sst +``` + + + + +```bash +cd my-app +pnpm create sst +``` + + + + +:::tip Ready to deploy +Your Next.js app is now ready to be deployed to AWS! Just run β€” `npx sst deploy`. But let's take a second to look at how SST makes it easy to add other features to your app. +::: + +Start your local dev environment. + + + + +```bash +# Start SST locally +npx sst dev +# Start Next.js locally +npm run dev +``` + + + + +```bash +# Start SST locally +yarn sst dev +# Start Next.js locally +yarn run dev +``` + + + + +```bash +# Start SST locally +pnpm sst dev +# Start Next.js locally +pnpm run dev +``` + + + + +--- + +## 2. Add file uploads + +Let's add a file upload feature to our Next.js app. + +--- + +#### Add an S3 bucket + +Add an S3 bucket to your `sst.config.ts`. + +```ts title="sst.config.ts" +const bucket = new Bucket(stack, "public"); +``` + +Bind it to your Next.js app. + +```diff title="sst.config.ts" +const site = new NextjsSite(stack, "site", { ++ bind: [bucket], +}); +``` + +--- + +#### Generate a presigned URL + +To upload a file to S3 we'll generate a presigned URL. Add this to `pages/index.tsx`. + +```ts title="pages/index.tsx" {5} +export async function getServerSideProps() { + const command = new PutObjectCommand({ + ACL: "public-read", + Key: crypto.randomUUID(), + Bucket: Bucket.public.bucketName, + }); + const url = await getSignedUrl(new S3Client({}), command); + + return { props: { url } }; +} +``` + +:::tip +With SST we can access our infrastructure in a typesafe way β€” `Bucket.public.bucketName`. [Learn more](resource-binding.md). +::: + +--- + +#### Add an upload form + +Let's add the form. Replace the `Home` component in `pages/index.tsx` with. + +```tsx title="pages/index.tsx" +export default function Home({ url }: { url: string }) { + return ( +
    +
    { + e.preventDefault(); + + const file = (e.target as HTMLFormElement).file.files?.[0]!; + + const image = await fetch(url, { + body: file, + method: "PUT", + headers: { + "Content-Type": file.type, + "Content-Disposition": `attachment; filename="${file.name}"`, + }, + }); + + window.location.href = image.url.split("?")[0]; + }} + > + + +
    +
    + ); +} +``` + +This will upload an image and redirect to it! + +--- + +## 3. Add a cron job + +Next, we'll add a cron job to remove the uploaded files every day. Add this to `sst.config.ts`. + +```ts title="sst.config.ts" {5} +new Cron(stack, "cron", { + schedule: "rate(1 day)", + job: { + function: { + bind: [bucket], + handler: "functions/delete.handler", + }, + }, +}); +``` + +Just like our Next.js app, we are binding the S3 bucket to our cron job. + +--- + +#### Add a cron function + +Add a function to `functions/delete.ts` that'll go through all the files in the bucket and remove them. + +```ts title="functions/delete.ts" +export async function handler() { + const client = new S3Client({}); + + const list = await client.send( + new ListObjectsCommand({ + Bucket: Bucket.public.bucketName, + }) + ); + + await Promise.all( + (list.Contents || []).map((file) => + client.send( + new DeleteObjectCommand({ + Key: file.Key, + Bucket: Bucket.public.bucketName, + }) + ) + ) + ); +} +``` + +And that's it. We have a simple Next.js app that uploads files to S3 and runs a cron job to delete them! + +--- + +## 4. Deploy to prod + +Let's end with deploying our app to production. + + + + +```bash +npx sst deploy --stage prod +``` + + + + +```bash +yarn sst deploy --stage prod +``` + + + + +```bash +pnpm sst deploy --stage prod +``` + + + + +:::note +The `sst deploy` command internally uses OpenNext to build your app. +::: + +![Next.js app deployed to AWS with SST](/img/start/nextjs-app-deployed-to-aws-with-sst.png) + +:::info +[View the source](https://github.com/serverless-stack/sst/tree/master/examples/quickstart-nextjs) for this example on GitHub. +::: + +--- + +## Next steps + +1. Learn more about SST + - [`Cron`](../constructs/Cron.md) β€” Add a cron job to your app + - [`Bucket`](../constructs/Bucket.md) β€” Add S3 buckets to your app + - [`NextjsSite`](../constructs/NextjsSite.md) β€” Deploy Next.js apps to AWS + - [Live Lambda Dev](../live-lambda-development.md) β€” SST's local dev environment + - [Resource Binding](../resource-binding.md) β€” Typesafe access to your resources +2. Have a Next.js app on Vercel? [**Migrate it to SST**](../migrating/vercel.md). +3. Ready to dive into the details of SST? [**Check out our tutorial**](../learn/index.md). diff --git a/www/docs/start/remix.md b/www/docs/start/remix.md new file mode 100644 index 0000000000..67132ad102 --- /dev/null +++ b/www/docs/start/remix.md @@ -0,0 +1,307 @@ +--- +sidebar_label: Remix +title: Use Remix with SST +description: "Create and deploy a Remix app to AWS with SST." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +Create and deploy a Remix app to AWS with SST. + + + +--- + +## Prerequisites + +You'll need at least [Node.js 16](https://nodejs.org/) and [npm 7](https://www.npmjs.com/). You also need to have an AWS account and [**AWS credentials configured locally**](advanced/iam-credentials.md#loading-from-a-file). + +--- + +## 1. Create a new app + +Create a new Remix app. + + + + +```bash +npx create-remix@latest +``` + + + + +```bash +yarn create remix +``` + + + + +```bash +pnpm create remix +``` + + + + +Now initialize SST in your project root. + + + + +```bash +cd my-remix-app +npx create-sst@latest +``` + + + + +```bash +cd my-remix-app +yarn create sst +``` + + + + +```bash +cd my-remix-app +pnpm create sst +``` + + + + +:::tip Ready to deploy +Your Remix app is now ready to be deployed to AWS! Just run β€” `npx sst deploy`. But let's take a second to look at how SST makes it easy to add other features to your app. +::: + +Start your local dev environment. + + + + +```bash +# Start SST locally +npx sst dev +# Start Remix locally +npm run dev +``` + + + + +```bash +# Start SST locally +yarn sst dev +# Start Remix locally +yarn run dev +``` + + + + +```bash +# Start SST locally +pnpm sst dev +# Start Remix locally +pnpm run dev +``` + + + + +--- + +## 2. Add file uploads + +Let's add a file upload feature to our Remix app. + +--- + +#### Add an S3 bucket + +Add an S3 bucket to your `sst.config.ts`. + +```ts title="sst.config.ts" +const bucket = new Bucket(stack, "public"); +``` + +Let your Remix app access the bucket. + +```diff title="sst.config.ts" +const site = new RemixSite(stack, "site", { ++ permissions: [bucket], ++ environment: { ++ BUCKET_NAME: bucket.bucketName, ++ }, +}); +``` + +--- + +#### Generate a presigned URL + +To upload a file to S3 we'll generate a presigned URL. Add this to `app/_index.tsx`. + +```ts title="app/_index.tsx" {5} +export async function loader() { + const command = new PutObjectCommand({ + ACL: "public-read", + Key: crypto.randomUUID(), + Bucket: process.env.BUCKET_NAME, + }); + const url = await getSignedUrl(new S3Client({}), command); + + return json({ url }); +} +``` + +--- + +#### Add an upload form + +Let's add the form. Replace the `Index` component in `app/_index.tsx` with. + +```tsx title="app/_index.tsx" +export default function Index() { + const data = useLoaderData(); + return ( +
    +

    Welcome to Remix

    +
    { + e.preventDefault(); + + const file = (e.target as HTMLFormElement).file.files?.[0]!; + + const image = await fetch(data.url, { + body: file, + method: "PUT", + headers: { + "Content-Type": file.type, + "Content-Disposition": `attachment; filename="${file.name}"`, + }, + }); + + window.location.href = image.url.split("?")[0]; + }} + > + + +
    +
    + ); +} +``` + +This will upload an image and redirect to it! + +--- + +## 3. Add a cron job + +Next, we'll add a cron job to remove the uploaded files every day. Add this to `sst.config.ts`. + +```ts title="sst.config.ts" +new Cron(stack, "cron", { + schedule: "rate(1 minute)", + job: { + function: { + permissions: [bucket], + environment: { + BUCKET_NAME: bucket.bucketName, + }, + handler: "functions/delete.handler", + }, + }, +}); +``` + +Just like our Remix app, we are letting our cron job access the S3 bucket. + +--- + +#### Add a cron function + +Add a function to `functions/delete.ts` that'll go through all the files in the bucket and remove them. + +```ts title="functions/delete.ts" +export async function handler() { + const client = new S3Client({}); + + const list = await client.send( + new ListObjectsCommand({ + Bucket: process.env.BUCKET_NAME, + }) + ); + + await Promise.all( + (list.Contents || []).map((file) => + client.send( + new DeleteObjectCommand({ + Key: file.Key, + Bucket: process.env.BUCKET_NAME, + }) + ) + ) + ); +} +``` + +And that's it. We have a simple Remix app that uploads files to S3 and runs a cron job to delete them! + +--- + +## 4. Deploy to prod + +Let's end with deploying our app to production. + + + + +```bash +npx sst deploy --stage prod +``` + + + + +```bash +yarn sst deploy --stage prod +``` + + + + +```bash +pnpm sst deploy --stage prod +``` + + + + +![Remix app deployed to AWS with SST](/img/start/remix-app-deployed-to-aws-with-sst.png) + +:::info +[View the source](https://github.com/serverless-stack/sst/tree/master/examples/quickstart-remix) for this example on GitHub. +::: + +--- + +## Next steps + +1. Learn more about SST + - [`Cron`](../constructs/Cron.md) β€” Add a cron job to your app + - [`Bucket`](../constructs/Bucket.md) β€” Add S3 buckets to your app + - [`RemixSite`](../constructs/RemixSite.md) β€” Deploy Remix apps to AWS + - [Live Lambda Dev](../live-lambda-development.md) β€” SST's local dev environment +2. Ready to dive into the details of SST? [**Check out our tutorial**](../learn/index.md). diff --git a/www/docs/start/solid.md b/www/docs/start/solid.md new file mode 100644 index 0000000000..de241673db --- /dev/null +++ b/www/docs/start/solid.md @@ -0,0 +1,304 @@ +--- +sidebar_label: Solid +title: Use SolidStart with SST +description: "Create and deploy a SolidStart app to AWS with SST." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +Create and deploy a SolidStart app to AWS with SST. + + + +--- + +## Prerequisites + +You'll need at least [Node.js 16](https://nodejs.org/) and [npm 7](https://www.npmjs.com/). You also need to have an AWS account and [**AWS credentials configured locally**](advanced/iam-credentials.md#loading-from-a-file). + +--- + +## 1. Create a new app + +Create a new SolidStart app. + + + + +```bash +npx create-solid@latest +``` + + + + +```bash +yarn create solid +``` + + + + +```bash +pnpm create solid +``` + + + + +Now initialize SST in your project root. + + + + +```bash +npx create-sst@latest +``` + + + + +```bash +yarn create sst +``` + + + + +```bash +pnpm create sst +``` + + + + +:::tip Ready to deploy +Your SolidStart app is now ready to be deployed to AWS! Just run β€” `npx sst deploy`. But let's take a second to look at how SST makes it easy to add other features to your app. +::: + +Start your local dev environment. + + + + +```bash +# Start SST locally +npx sst dev +# Start Solid locally +npm run dev +``` + + + + +```bash +# Start SST locally +yarn sst dev +# Start Solid locally +yarn run dev +``` + + + + +```bash +# Start SST locally +pnpm sst dev +# Start Solid locally +pnpm run dev +``` + + + + +--- + +## 2. Add file uploads + +Let's add a file upload feature to our Solid app. + +--- + +#### Add an S3 bucket + +Add an S3 bucket to your `sst.config.ts`. + +```ts title="sst.config.ts" +const bucket = new Bucket(stack, "public"); +``` + +Bind it to your Solid app. + +```diff title="sst.config.ts" +const site = new SolidStartSite(stack, "site", { ++ bind: [bucket], +}); +``` + +--- + +#### Generate a presigned URL + +To upload a file to S3 we'll generate a presigned URL. Add this to `src/routes/index.tsx`. + +```ts title="src/routes/index.tsx" {6} +export function routeData() { + return createServerData$(async () => { + const command = new PutObjectCommand({ + ACL: "public-read", + Key: crypto.randomUUID(), + Bucket: Bucket.public.bucketName, + }); + return await getSignedUrl(new S3Client({}), command); + }); +} +``` + +:::tip +With SST we can access our infrastructure in a typesafe way β€” `Bucket.public.bucketName`. [Learn more](resource-binding.md). +::: + +--- + +#### Add an upload form + +Let's add the form. Replace the Home component in `src/routes/index.tsx` with. + +```tsx title="src/routes/index.tsx" +export default function Home() { + const url = useRouteData(); + + return ( +
    +

    Hello world!

    +
    { + e.preventDefault(); + + const file = (e.target as HTMLFormElement).file.files?.[0]!; + + const image = await fetch(url() as string, { + body: file, + method: "PUT", + headers: { + "Content-Type": file.type, + "Content-Disposition": `attachment; filename="${file.name}"`, + }, + }); + + window.location.href = image.url.split("?")[0]; + }} + > + + +
    +
    + ); +} +``` + +This will upload an image and redirect to it! + +--- + +## 3. Add a cron job + +Next, we'll add a cron job to remove the uploaded files every day. Add this to `sst.config.ts`. + +```ts title="sst.config.ts" {5} +new Cron(stack, "cron", { + schedule: "rate(1 day)", + job: { + function: { + bind: [bucket], + handler: "src/functions/delete.handler", + }, + }, +}); +``` + +Just like our SolidStart app, we are binding the S3 bucket to our cron job. + +--- + +#### Add a cron function + +Add a function to `src/functions/delete.ts` that'll go through all the files in the bucket and remove them. + +```ts title="src/functions/delete.ts" +export async function handler() { + const client = new S3Client({}); + + const list = await client.send( + new ListObjectsCommand({ + Bucket: Bucket.public.bucketName, + }) + ); + + await Promise.all( + (list.Contents || []).map((file) => + client.send( + new DeleteObjectCommand({ + Key: file.Key, + Bucket: Bucket.public.bucketName, + }) + ) + ) + ); +} +``` + +And that's it. We have a simple SolidStart app that uploads files to S3 and runs a cron job to delete them! + +--- + +## 4. Deploy to prod + +Let's end with deploying our app to production. + + + + +```bash +npx sst deploy --stage prod +``` + + + + +```bash +yarn sst deploy --stage prod +``` + + + + +```bash +pnpm sst deploy --stage prod +``` + + + + +![SolidStart app deployed to AWS with SST](/img/start/solidstart-app-deployed-to-aws-with-sst.png) + +:::info +[View the source](https://github.com/serverless-stack/sst/tree/master/examples/quickstart-solidstart) for this example on GitHub. +::: + +--- + +## Next steps + +1. Learn more about SST + - [`Cron`](../constructs/Cron.md) β€” Add a cron job to your app + - [`Bucket`](../constructs/Bucket.md) β€” Add S3 buckets to your app + - [`SolidStartSite`](../constructs/SolidStartSite.md) β€” Deploy SolidStart apps to AWS + - [Live Lambda Dev](../live-lambda-development.md) β€” SST's local dev environment + - [Resource Binding](../resource-binding.md) β€” Typesafe access to your resources +2. Ready to dive into the details of SST? [**Check out our tutorial**](../learn/index.md). diff --git a/www/docs/start/standalone.md b/www/docs/start/standalone.md new file mode 100644 index 0000000000..822f3a1c45 --- /dev/null +++ b/www/docs/start/standalone.md @@ -0,0 +1,252 @@ +--- +id: standalone +sidebar_label: Standalone +title: Create a Standalone SST App +description: "Create and deploy your first SST app." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + +export const ConsoleUrl = ({url}) => +{url.replace("https://","").replace(/\/$/, "")}; + + + +Take SST for a spin and create your first project. + + + +--- + +## Prerequisites + +You'll need at least [Node.js 16](https://nodejs.org/) and [npm 7](https://www.npmjs.com/). You also need to have an AWS account and [**AWS credentials configured locally**](advanced/iam-credentials.md#loading-from-a-file). + +--- + +## 1. Create a new app + +Create a new SST app. + + + + +```bash +npx create-sst@latest my-sst-app +``` + + + + +```bash +yarn create sst my-sst-app +``` + + + + +```bash +pnpm create sst my-sst-app +``` + + + + +Start your [local dev environment](live-lambda-development.md). + + + + +```bash +npx sst dev +``` + + + + +```bash +yarn sst dev +``` + + + + +```bash +pnpm sst dev +``` + + + + +This will give you an API endpoint like β€” `https://m69caok4q0.execute-api.us-east-1.amazonaws.com`. + +--- + +## 2. Edit the API + +Let's make a change to our API. Replace the following in `packages/functions/src/lambda.ts`. + +```diff title="packages/functions/src/lambda.ts" +export const handler = ApiHandler(async (_evt) => { + return { +- body: `Hello world. The time is ${new Date().toISOString()}`, ++ statusCode: 200, ++ body: `Hi from SST ${new Date().toISOString()}`, + }; +}); +``` + +Now if you hit your API again, you should see the new message! + +--- + +## 3. Add a frontend + +Let's now add a frontend to our app. + +--- + +#### Create a new Vite React app + +Run the following in `packages/` and name your project `web`. + + + + +```bash +npm create vite@latest +``` + + + + +```bash +yarn create vite +``` + + + + +```bash +pnpm create vite +``` + + + + +Add it to your stacks and link the API to it. + +```ts title="stacks/MyStack.ts" {6} +const web = new StaticSite(stack, "web", { + path: "packages/web", + buildOutput: "dist", + buildCommand: "npm run build", + environment: { + VITE_APP_API_URL: api.url, + }, +}); +``` + +--- + +#### Call your API + +Start Vite locally and bind SST to it. + + + + +```bash +npx sst bind vite +``` + + + + +```bash +yarn sst bind vite +``` + + + + +```bash +pnpm sst bind vite +``` + + + + +Make a call to the API in your React app. Replace the `App` component in `src/App.tsx`. + +```tsx title="packages/web/src/App.tsx" {5} +function App() { + const [message, setMessage] = useState("Hi πŸ‘‹"); + + function onClick() { + fetch(import.meta.env.VITE_APP_API_URL) + .then((response) => response.text()) + .then(setMessage); + } + + return ( +
    +
    + +
    +
    + ); +} +``` + +--- + +## 4. Deploy to prod + +Let's end with deploying our app to production. + + + + +```bash +npx sst deploy --stage prod +``` + + + + +```bash +yarn sst deploy --stage prod +``` + + + + +```bash +pnpm sst deploy --stage prod +``` + + + + +![Standalone SST app deployed to AWS](/img/start/standalone-sst-app-deployed-to-aws.png) + +:::info +[View the source](https://github.com/serverless-stack/sst/tree/master/examples/quickstart-standalone) for this example on GitHub. +::: + +--- + +## Next steps + +1. Learn more about SST + - [`Api`](../constructs/Api.md) β€” Add an API to your app + - [`StaticSite`](../constructs/StaticSite.md) β€” Deploy a static site to AWS + - [Live Lambda Dev](../live-lambda-development.md) β€” SST's local dev environment + - [Resource Binding](../resource-binding.md) β€” Typesafe access to your resources +2. Ready to dive into the details of SST? [**Check out our tutorial**](../learn/index.md). diff --git a/www/docs/start/svelte.md b/www/docs/start/svelte.md new file mode 100644 index 0000000000..46e2ad6811 --- /dev/null +++ b/www/docs/start/svelte.md @@ -0,0 +1,304 @@ +--- +sidebar_label: Svelte +title: Use SvelteKit with SST +description: "Create and deploy a SvelteKit app to AWS with SST." +--- + +import config from "../../config"; +import TabItem from "@theme/TabItem"; +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +Create and deploy a SvelteKit app to AWS with SST. + + + +--- + +## Prerequisites + +You'll need at least [Node.js 16](https://nodejs.org/) and [npm 7](https://www.npmjs.com/). You also need to have an AWS account and [**AWS credentials configured locally**](advanced/iam-credentials.md#loading-from-a-file). + +--- + +## 1. Create a new app + +Create a new SvelteKit app. + + + + +```bash +npx create-svelte@latest +``` + + + + +```bash +yarn create svelte +``` + + + + +```bash +pnpm create svelte +``` + + + + +Now initialize SST in your project root. + + + + +```bash +npx create-sst@latest +``` + + + + +```bash +yarn create sst +``` + + + + +```bash +pnpm create sst +``` + + + + +:::tip Ready to deploy +Your SvelteKit app is now ready to be deployed to AWS! Just run β€” `npx sst deploy`. But let's take a second to look at how SST makes it easy to add other features to your app. +::: + +Start your local dev environment. + + + + +```bash +# Start SST locally +npx sst dev +# Start Svelte locally +npm run dev +``` + + + + +```bash +# Start SST locally +yarn sst dev +# Start Svelte locally +yarn run dev +``` + + + + +```bash +# Start SST locally +pnpm sst dev +# Start Svelte locally +pnpm run dev +``` + + + + +--- + +## 2. Add file uploads + +Let's add a file upload feature to our Svelte app. + +--- + +#### Add an S3 bucket + +Add an S3 bucket to your `sst.config.ts`. + +```ts title="sst.config.ts" +const bucket = new Bucket(stack, "public"); +``` + +Bind it to your Svelte app. + +```diff title="sst.config.ts" +const site = new SvelteKitSite(stack, "site", { ++ bind: [bucket], +}); +``` + +--- + +#### Generate a presigned URL + +To upload a file to S3 we'll generate a presigned URL. Add this to `src/routes/+page.server.ts`. + +```ts title="src/routes/+page.server.ts" {5} +export const load = (async () => { + const command = new PutObjectCommand({ + ACL: "public-read", + Key: crypto.randomUUID(), + Bucket: Bucket.public.bucketName, + }); + const url = await getSignedUrl(new S3Client({}), command); + + return { url }; +}) satisfies PageServerLoad; +``` + +:::tip +With SST we can access our infrastructure in a typesafe way β€” `Bucket.public.bucketName`. [Learn more](resource-binding.md). +::: + +--- + +#### Add an upload form + +Let's add the form. Replace our `src/routes/+page.svelte` with. + +```tsx title="src/routes/+page.svelte" +
    +
    + + +
    +
    +``` + +Add the upload handler. + +```ts title="src/routes/+page.svelte" +const handleSubmit = async (e: SubmitEvent) => { + const formData = new FormData(e.target as HTMLFormElement); + const file = formData.get("file") as File; + + const image = await fetch(data.url, { + body: file, + method: "PUT", + headers: { + "Content-Type": file.type, + "Content-Disposition": `attachment; filename="${file.name}"`, + }, + }); + + window.location.href = image.url.split("?")[0]; +}; +``` + +:::note +We need to set `prerender` to `false` in `src/routes/+page.ts` since we want to generate the presigned URL on page load. +::: + +This will upload an image and redirect to it! + +--- + +## 3. Add a cron job + +Next, we'll add a cron job to remove the uploaded files every day. Add this to `sst.config.ts`. + +```ts title="sst.config.ts" {5} +new Cron(stack, "cron", { + schedule: "rate(1 day)", + job: { + function: { + bind: [bucket], + handler: "src/functions/delete.handler", + }, + }, +}); +``` + +Just like our SvelteKit app, we are binding the S3 bucket to our cron job. + +--- + +#### Add a cron function + +Add a function to `src/functions/delete.ts` that'll go through all the files in the bucket and remove them. + +```ts title="src/functions/delete.ts" +export async function handler() { + const client = new S3Client({}); + + const list = await client.send( + new ListObjectsCommand({ + Bucket: Bucket.public.bucketName, + }) + ); + + await Promise.all( + (list.Contents || []).map((file) => + client.send( + new DeleteObjectCommand({ + Key: file.Key, + Bucket: Bucket.public.bucketName, + }) + ) + ) + ); +} +``` + +And that's it. We have a simple SvelteKit app that uploads files to S3 and runs a cron job to delete them! + +--- + +## 4. Deploy to prod + +Let's end with deploying our app to production. + + + + +```bash +npx sst deploy --stage prod +``` + + + + +```bash +yarn sst deploy --stage prod +``` + + + + +```bash +pnpm sst deploy --stage prod +``` + + + + +![SvelteKit app deployed to AWS with SST](/img/start/sveltekit-app-deployed-to-aws-with-sst.png) + +:::info +[View the source](https://github.com/serverless-stack/sst/tree/master/examples/quickstart-sveltekit) for this example on GitHub. +::: + +--- + +## Next steps + +1. Learn more about SST + - [`Cron`](../constructs/Cron.md) β€” Add a cron job to your app + - [`Bucket`](../constructs/Bucket.md) β€” Add S3 buckets to your app + - [`SvelteKitSite`](../constructs/SvelteKitSite.md) β€” Deploy SvelteKit apps to AWS + - [Live Lambda Dev](../live-lambda-development.md) β€” SST's local dev environment + - [Resource Binding](../resource-binding.md) β€” Typesafe access to your resources +2. Ready to dive into the details of SST? [**Check out our tutorial**](../learn/index.md). diff --git a/www/docs/testing.md b/www/docs/testing.md new file mode 100644 index 0000000000..feffa1b558 --- /dev/null +++ b/www/docs/testing.md @@ -0,0 +1,288 @@ +--- +title: Testing +description: "Learn how to write tests for your SST apps." +--- + +import HeadlineText from "@site/src/components/HeadlineText"; +import MultiPackagerCode from "@site/src/components/MultiPackagerCode"; + + + +SST apps come with a great setup for writing tests. + + + +:::tip +Want to learn more about testing in SST? Check out the [livestream we did on YouTube](https://youtu.be/YtaxDURRjHA). +::: + +--- + +## Overview + +To start, there are 3 types of tests you can write for your SST apps: + +1. Tests for your domain code. We recommend [Domain Driven Design](learn/domain-driven-design.md). +2. Tests for your APIs, the endpoints handling requests. +3. Tests for your stacks, the code that creates your infrastructure. + +SST uses [Vitest](https://vitest.dev) to help you write these tests. And it uses the [`sst bind`](packages/sst.md#sst-bind) CLI to bind the resources to your tests. This allows the [`sst/node`](clients/index.md) helper library to work as if the tests were running inside a Lambda function. + +:::info +Due to [the way sst bind works](#how-sst-bind-works), it does not support Vitest in threaded mode. We recommend disabling threads by [setting the `threads` config option](https://vitest.dev/config/#threads) to false or by using the flag `--threads=false`. +::: + +--- + +### Test script + +If you created your app with `create-sst` a [Vitest](https://vitest.dev/config/) config is added for you, with a test script in your `package.json`: + +```json {8} title="package.json" +"scripts": { + "dev": "sst dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove", + "console": "sst console", + "typecheck": "tsc --noEmit", + "test": "sst bind vitest run" +}, +``` + +We'll look at how the `sst bind` CLI works a little in the chapter. + +:::note +The `sst bind` CLI will join any argument that is not a flag but won't join flags. This means that `sst bind vitest run path/to/test.ts` is valid, but `sst bind vitest run --threads=false` is not! To pass in flags, wrap the command in quotes: `sst bind "vitest run --threads=false"`. +::: + +You can now run your tests using. + + + + +```bash +npm test +``` + + + + +```bash +yarn test +``` + + + + +```bash +pnpm test +``` + + + + +--- + +## Quick start + +In this chapter we'll look at the different types of tests and share some tips on how to write them. + +To follow along, you can create the GraphQL starter by running `npx create-sst@latest --example graphql/dynamo` > `graphql` > `DynamoDB`. Alternatively, you can refer to [this example repo](https://github.com/serverless-stack/sst/tree/master/examples/graphql-dynamo) based on the same template. + +If you are new to the GraphQL starter, it creates a very simple Reddit clone. You can submit links and it'll display all the links that have been submitted. + +--- + +### Testing domain code + +Open up `packages/core/src/article.ts`, it contains a `create()` function to create an article, and a `list()` function to list all submitted articles. This code is responsible for the _article domain_. + +Let's write a test for our _article domain_ code. Create a new file at `packages/core/test/article.test.ts`: + +```ts title="packages/core/test/article.test.ts" +import { expect, it } from "vitest"; +import { Article } from "@my-sst-app/core/article"; + +it("create an article", async () => { + // Create a new article + const article = await Article.create("Hello world", "https://example.com"); + + // List all articles + const list = await Article.list(); + + // Check the newly created article exists + expect(list.find((a) => a.articleID === article.articleID)).not.toBeNull(); +}); +``` + +Both the `create()` and `list()` functions call `packages/core/src/dynamo.ts` to talk to the database. And `packages/core/src/dynamo.ts` references `Table.table.tableName`. + +
    +Behind the scenes + +The above test only works if we run `sst bind vitest run`. The `sst bind` CLI fetches the value for the `Table.table.tableName` and passes it to the test. If we run `vitest run` directly, we'll get an error complaining that `Table.table.tableName` cannot be resolved. + +
    + +--- + +### Testing API endpoints + +We can rewrite the above test so that instead of calling `Article.create()`, you make a request to the GraphQL API to create the article. In fact, the GraphQL stack template already includes this test. + +Open `packages/functions/test/graphql/article.test.ts`, you can see the test is similar to our domain function test above. + +```ts +import { expect, it } from "vitest"; +import { Api } from "sst/node/api"; +import { createClient } from "@my-sst-app/graphql/genql"; +import { Article } from "@my-sst-app/core/article"; + +it("create an article", async () => { + const client = createClient({ + url: Api.api.url + "/graphql", + }); + + // Call the API to create a new article + const article = await client.mutation({ + createArticle: [ + { title: "Hello world", url: "https://example.com" }, + { + id: true, + }, + ], + }); + + // List all articles + const list = await Article.list(); + + // Check the newly created article exists + expect( + list.find((a) => a.articleID === article.createArticle.id) + ).not.toBeNull(); +}); +``` + +Again, just like the domain test above, this only works if we run [`sst bind vitest run`](#how-sst-bind-works). + +:::tip +Testing APIs are often more useful than testing Domain code because they test the app from the perspective of a user. Ignoring most of the implementation details. +::: + +Note that this test is very similar to the request frontend makes when a user tries to submit a link. + +--- + +### Testing infrastructure + +Both domain function tests and API tests are for testing your business logic code. Stack tests on the other hand allows you to test your infrastructure settings. + +Let's write a test for our `Database` stack to ensure that [point-in-time recovery](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery.html) is enabled for our DynamoDB table. + +Create a new file at `stacks/test/Database.test.ts`: + +```ts +import { it } from "vitest"; +import { Template } from "aws-cdk-lib/assertions"; +import { initProject } from "sst/project"; +import { App, getStack } from "sst/constructs"; +import { Database } from "../Database"; + +it("point-in-time recovery is enabled", async () => { + await initProject({}); + const app = new App({ mode: "deploy" }); + // Create the Database stack + app.stack(Database); + + // Get the CloudFormation template of the stack + const stack = getStack(Database); + const template = Template.fromStack(stack); + + // Check point-in-time recovery is enabled + template.hasResourceProperties("AWS::DynamoDB::Table", { + PointInTimeRecoverySpecification: { + PointInTimeRecoveryEnabled: true, + }, + }); +}); +``` + +The `aws-cdk-lib/assertions` import is a CDK helper library that makes it easy to test against AWS resources created inside a stack. In the test above, we are checking if there is a DynamoDB table created with `PointInTimeRecoveryEnabled` set to `true`. + +--- + +#### Why test stacks + +Like the test above, you can test for things like: + +- Are the functions running with at least 1024MB of memory? +- Did I accidentally change the database name, and the data will be wiped out on deploy? + +It allows us to ensure that our team doesn't accidentally change some infrastructure settings. It also allows you to enforce specific infrastructure policies across your app. + +:::tip +Here are a couple of reference docs from AWS that should help you write stack tests. + +- [CDK assertions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions-readme.html) +- [CloudFormation resource definitions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) + +::: + +--- + +## Tips + +Now that you know how to test various parts of your app. Here are a couple of tips on writing effective tests. + +--- + +### Don't test implementation details + +In this chapter, we used DynamoDB as our database choice. We could've selected PostgreSQL and our tests would've remained the same. + +Your tests should be unaware of things like what table data is being written, and instead just call domain functions to verify their input and output. This will minimize how often you need to rewrite your tests as the implementation details change. + +--- + +### Isolate tests to run them in parallel + +Tests need to be structured in a way that they can be run reliably in parallel. In our domain function and API tests above, we checked to see if the created article exists: + +```ts +// Check the newly created article exists +expect( + list.find((a) => a.articleID === article.createArticle.id) +).not.toBeNull(); +``` + +Instead, if we had checked for the total article count, the test might fail if other tests were also creating articles. + +```ts +expect(list.length).toBe(1); +``` + +The best way to isolate tests is to create separate scopes for each test. In our example, the articles are stored globally. If the articles were stored within a user's scope, you can create a new user per test. This way, tests can run in parallel without affecting each other. + +--- + +## How `sst bind` works + +When testing your code, you have to ensure the testing environment has the same environment variable values as the Lambda environment. In the past, people would manually maintain a `.env.test` file with environment values. SST has built-in support for automatically loading the secrets and environment values that are managed by [`Resource Binding`](resource-binding.md). + +The [`sst bind`](packages/sst.md#sst-bind) CLI fetches all the resource values, and invokes the `vitest run` with the values configured as environment variables. + +
    +Behind the scenes + +The `sst bind` CLI sets the following environment variables: + +- `SST_APP` with the name of your SST app +- `SST_STAGE` with the stage +- It fetches all SSM Parameters prefixed with `/sst/{appName}/{stageName}/*`, and sets the environment variables prefixed with `SST_*`. Ie. In our example above, `SST_Table_tableName_table` is created with value from `/sst/{appName}/{stageName}/Table/table/tableName` +- For [`Secrets`](constructs/Secret.md), fallback values are also fetched from SSM Parameters prefixed with `/sst/{appName}/.fallback/Secret/*`. +- To do this, `sst bind` spawns child processes. This is why Vitest's threaded mode is not supported. Since it also spawns child processes, the combination of different threads might cause tests to fail intermittently. + +
    + +This allows the [`sst/node`](clients/index.md) helper library to work as if it was running inside a Lambda function. diff --git a/www/docs/upgrade-guide.md b/www/docs/upgrade-guide.md new file mode 100644 index 0000000000..b1f06d9f12 --- /dev/null +++ b/www/docs/upgrade-guide.md @@ -0,0 +1,486 @@ +--- +title: Upgrade Guide +description: "Upgrade guide for all notable SST releases." +--- + +import config from "../config"; +import HeadlineText from "@site/src/components/HeadlineText"; + + + +Upgrade guide for all notable SST releases. + + + +To view the latest release and all historical releases, head over to our GitHub release page. + +--- + +## Upgrade to v2.3.0 + +[Resource Binding](resource-binding.md) now lets you bind resources to your frontend frameworks. It simplifies accessing the resources in the server side rendered (SSR) code. For example, here's how we bind the bucket to the Next.js app: + +```diff +const bucket = new Bucket(stack, "myFiles"); + +new NextjsSite(stack, "mySite", { +- environment: { +- BUCKET_NAME: bucket.bucketName, +- }, +- permissions: [bucket], ++ bind: [bucket], +}); +``` + +And here's how we access it in our SSR code. + +```diff ++ import { Bucket } from "sst/node/bucket"; + +- process.env.BUCKET_NAME ++ Bucket.myFiles.bucketName +``` + +Following are the steps to upgrade. + +1. **`sst env` has been renamed to `sst bind`** (although both will work). `sst env` will be removed in SST v3 + + ```diff + - sst env next dev + + sst bind next dev + ``` +## Upgrade to v2.0 + +The 2.0 upgrade is primarily ergonomic and should not result in any infrastructure changes. + +#### Packages + +1. SST is now a monorepo, remove all packages referencing `@serverless-stack/resources` `@serverless-stack/cli` `@serverless-stack/node` and `@serverless-stack/static-site-env`. Install the `sst` package + + ```diff + { + "devDependencies": { + - "@serverless-stack/resources": "xxx", + - "@serverless-stack/cli": "xxx", + - "@serverless-stack/static-site-env": "xxx", + - "@serverless-stack/node": "xxx", + + "sst": "2.x", + + "constructs": "10.1.156" + } + } + ``` + +2. Ensure `"constructs": "10.1.156"` is installed +3. In your stacks code replace all imports from `@serverless-stack/resources` to `sst/constructs` + ```diff + - import { Function } from "@serverless-stack/resources" + + import { Function } from "sst/constructs" + ``` +4. If you were using `@serverless-stack/static-site-env` for your frontend, replace it with the `sst env ''` command + ```diff + "scripts": { + - "dev": "static-site-env -- vite dev", + + "dev": "sst env vite dev", + } + ``` + +#### App configuration + +`sst.json` is now specified as a `sst.config.ts` file. The `main` field has been replaced with a function that can directly import your stacks. + +```js +import type { SSTConfig } from "sst" +import { Api } from "./stacks/Api.js" +import { Dynamo } from "./stacks/Dynamo.js" + +export default { + config(input) { + return { + name: "myapp", + region: "us-east-1", + profile: "my-company-dev" + } + }, + stacks(app) { + app.setDefaultFunctionProps({ + runtime: "nodejs18.x", + architecture: "arm_64", + }) + + app + .stack(Api) + .stack(Dynamo) + }, +} satisfies SSTConfig +``` + +#### CLI + +1. `sst start` has been renamed to `sst dev` (although both will work) +2. `sst load-config` has been removed β€” [see v1.16](#upgrade-to-v116) +3. `sst dev` requires additional IAM permissions: + + - iot:Connect + - iot:DescribeEndpoint + - iot:Publish + - iot:Receive + - iot:Subscribe + + [View the complete list of permissions](./advanced/iam-credentials.md#cli-permissions) required by the CLI. + +#### Stacks code + +1. In stacks code, process.env.IS_LOCAL is no longer available. Please use app.mode to see if it's running in "dev" mode. `app.local` will continue to work but likely will be deprecated at some point. +1. SST no longer requires a DebugStack to be deployed - feel free to delete this from your AWS console. +1. Function + 1. Default runtime is `nodejs16.x` + 1. Default format is `esm` instead of `cjs`. However, you might have some dependencies that have not properly supported `esm` yet. To get around this you can set the [`format`](constructs/Function.md#format) to `cjs` in your default function props. While v2 doesn't need you to upgrade to `esm`, the SST [Node client](clients/index.md) requires `esm` because of their use of top-level await. So it's recommended that you move over in the near future. + ```ts title="sst.config.ts" + app.setDefaultFunctionProps({ + nodejs: { + format: "cjs", + }, + }); + ``` + 1. We've made changes to the `FunctionProps` API so you should be seeing type errors around the `bundle` property. Most of the options there have been moved to a `nodejs` property instead. + ```diff + const fn = new Function(stack, "fn", { + - bundle: { + - format: "esm", + - }, + + nodejs: { + + format: "esm" + + } + }) + ``` + 1. We've removed the need for `srcPath` in function definitions but all your handler paths need to be specified relative to the root of the project. + ```diff + new Function(stack, "fn", { + - srcPath: "services", + - handler: "path/to/func.handler" + + handler: "services/path/to/func.handler" + }) + ``` + 1. Removed `config` prop β€” [see v1.16](#upgrade-to-v116) +1. Api: removed the `pothos` route type β€” [see v1.18](#upgrade-to-v118) +1. StaticSite, NextjsSite, and RemixSite + + 1. Following attributes were renamed: + - `bucketArn` renamed to `cdk.bucket.bucketArn` + - `bucketName` renamed to `cdk.bucket.bucketName` + - `distributionId` renamed to `cdk.distribution.distributionId` + - `distributionDomain` renamed to `cdk.distribution.distributionDomainName` + ```diff + const site = new StaticSite(stack, "MySite"); + - site.bucketArn + - site.bucketName + - site.distributionId + - site.distributionDomain + + site.cdk.bucket.bucketArn + + site.cdk.bucket.bucketName + + site.cdk.distribution.distributionId + + site.cdk.distribution.distributionDomainName + ``` + 1. Running `sst dev` no longer deploys a placeholder site + - `site.url` is `undefined` in dev mode + - `site.customDomainUrl` is `undefined` in dev mode + 1. `waitForInvalidation` now defaults to `false` + +1. NextjsSite + 1. in SST v1, the `NextjsSite` construct uses the [`@sls-next/lambda-at-edge package`](https://github.com/serverless-nextjs/serverless-next.js/tree/master/packages/libs/lambda-at-edge) package from the [`serverless-next.js`](https://github.com/serverless-nextjs/serverless-next.js) project to build and package your Next.js app so that it can be deployed to AWS. The project is no longer maintained. SST v2 uses the [`OpenNext`](https://open-next.js.org) project. You can still use the old `NextjsSite` construct like this: + ```ts + import { NextjsSite } from "sst/constructs/deprecated"; + ``` + 2. `commandHooks.afterBuild` renamed to `buildCommand` + ```diff + new NextjsSite(stack, "NextSite", { + path: "path/to/site", + - commandHooks: { + - afterBuild: ["npx next-sitemap"], + - } + + buildCommand: "npx open-next@latest build && npx next-sitemap" + }); + ``` +1. Removed ViteStaticSite and ReactStaticSite β€” [see v1.18](#upgrade-to-v118) +1. Removed GraphQLApi β€” [see v1.18](#upgrade-to-v118) + +#### Function code + +1. In your functions code replace all imports from `@serverless-stack/node/xxx` to `sst/node/xxx` + ```diff + - import { Bucket } from "@serverless-stack/node/bucket" + + import { Bucket } from "sst/node/bucket" + ``` +1. If you're using function binding we moved type generation into a `.sst` folder. To include this place an `sst-env.d.ts` file in any package that needs the types that contains the following: + ```js + /// + ``` + Make sure you specify the path correctly + +#### Secrets + +1. The SSM parameter path for storing the secret values have changed in v1.16. If you are upgrading from a version prior to v1.16, run this `sst transform` command in each stage with secrets set: + ```bash + sst transform resource-binding-secrets + ``` + +#### Say bye to debug stack πŸ‘‹ + +In v1, SST used to deploy a debug stack in your AWS account when you ran `sst start`. Debug stack contains resources required for [Live Lambda Development](./live-lambda-development.md) to work. In v2, SST no longer need the debug stack. You can remove it by going to your AWS CloudFormation console. Find the stack named `{stageName}-{appName}-debug-stack`, where `{stageName}` is the name of the stage, and `{appName}` is the name of your SST app. And remove the stack. + +--- + +## Upgrade to v1.18 + +#### Constructs + +1. Api: The **`pothos` route type is renamed to `graphql`**, and will be removed in SST v2. + + ```diff + new Api(stack, "api", { + routes: { + "POST /graphql": { + - type: "pothos", + + type: "graphql", + function: handler: "functions/graphql/graphql.ts", + - schema: "backend/functions/graphql/schema.ts", + - output: "graphql/schema.graphql", + - commands: [ + - "./genql graphql/graphql.schema graphql/ + - ] + + pothos: { + + schema: "backend/functions/graphql/schema.ts", + + output: "graphql/schema.graphql", + + commands: [ + + "./genql graphql/graphql.schema graphql/ + + ] + + } + } + } + }); + ``` + +2. GraphQLApi: The `GraphQLApi` construct is deprecated, and will be removed in SST v2. **Use the `Api` construct with a `graphql` route instead**. + + ```diff + - new GraphQLApi(stack, "api", { + - server: "src/graphql.handler", + - }); + + + new Api(stack, "api", { + + routes: { + + "POST /": { + + type: "graphql", + + function: "src/graphql.handler", + + } + + } + + }); + ``` + + Note that the `GraphQLApi` construct used to create both `GET` and `POST` routes. In most cases, only `POST` is used. You can also create the `GET` route like this: + + ```diff + new Api(stack, "api", { + routes: { + + "GET /": { + + type: "graphql", + + function: "src/graphql.handler", + + }, + "POST /": { + type: "graphql", + function: "src/graphql.handler", + } + } + }); + ``` + +3. ViteStaticSite: The `ViteStaticSite` construct is deprecated, and will be removed in SST v2. **Use the `StaticSite` construct instead. Specify `buildCommand`, `buildOutput`, and rename `typesPath` to `vite.types`**. + + ```diff + - new ViteStaticSite(stack, "frontend", { + + new StaticSite(stack, "frontend", { + path: "path/to/src", + + buildCommand: "npm run build", // or "yarn build" + + buildOutput: "dist", + customDomain: "mydomain.com", + environment: { + VITE_API_URL: api.url, + }, + - typesPath: "types/my-env.d.ts", + + vite: { + + types: "types/my-env.d.ts", + + } + }); + ``` + +4. ReactStaticSite: The `ReactStaticSite` construct is deprecated, and will be removed in SST v2. **Use the `StaticSite` construct instead. Specify `buildCommand` and `buildOutput`**. + + ```diff + - new ReactStaticSite(stack, "frontend", { + + new StaticSite(stack, "frontend", { + path: "path/to/src", + + buildCommand: "npm run build", // or "yarn build" + + buildOutput: "build", + customDomain: "mydomain.com", + environment: { + REACT_APP_API_URL: api.url, + }, + }); + ``` + +--- + +## Upgrade to v1.16 + +[Resource Binding](resource-binding.md) was introduced in this release. It simplifies accessing the resources in your app. For example, here's how we bind the bucket to the function: + +```diff +const bucket = new Bucket(stack, "myFiles"); + +new Function(stack, "myFunction", { + handler: "lambda.handler", +- environment: { +- BUCKET_NAME: bucket.bucketName, +- }, +- permissions: [bucket], ++ bind: [bucket], +}); +``` + +And here's how we access it in our function. + +```diff ++ import { Bucket } from "@serverless-stack/node/bucket"; + +- process.env.BUCKET_NAME ++ Bucket.myFiles.bucketName +``` + +Following are the steps to upgrade. + +1. **CLI** + + 1. The path for the SSM parameters that stores the secrets has changed. So you'll **need to run `sst deploy` or `sst dev`** before using the [`sst secrets`](packages/sst.md#sst-secrets) CLI. + + 2. **The `sst load-config` command is being renamed to `sst bind`** and will be removed in SST v2 + + ```diff + - sst load-config -- vitest run + + sst bind -- vitest run + ``` + +2. **Constructs** + + 1. **Construct IDs need to be unique** and match the pattern `[a-zA-Z]([a-zA-Z0-9-_])+`. If you have constructs with clashing IDs, change to a unique ID. And pass the old ID into `cdk.id` to ensure CloudFormation does not recreate the resource. + + For example, if you have two buckets with the same id. + + ```diff + - new Bucket(stack, "bucket"); + - new Bucket(stack, "bucket"); + + + new Bucket(stack, "usersFiles", { + + cdk: { id: "bucket" }, + + }); + + new Bucket(stack, "adminFiles", { + + cdk: { id: "bucket" }, + + }); + ``` + + 2. Function/Job: **Pass Secrets and Parameters into `bind`** instead of `config`. The `config` option will be removed in SST v2. + + ```diff + new Function(stack, "myFn", { + - config: [MY_STRIPE_KEY], + + bind: [MY_STRIPE_KEY], + }); + + new Job(stack, "myJob", { + - config: [MY_STRIPE_KEY], + + bind: [MY_STRIPE_KEY], + }); + ``` + + 3. Function/Job: **Pass SST Constructs into `bind`** instead of `permissions` to grant permissions. `permissions` will not accept SST Constructs in SST v2. + + ```diff + new Function(stack, "myFn", { + - permissions: [myTopic], + + bind: [myTopic], + }); + + new Job(stack, "myJob", { + - permissions: [myTopic], + + bind: [myTopic], + }); + ``` + + 4. App/Stack: **Pass Secrets and Parameters into `addDefaultFunctionBinding`** instead of `addDefaultFunctionConfig`. `addDefaultFunctionConfig` will be removed in SST v2 + + ```diff + - app.addDefaultFunctionConfig([MY_STRIPE_KEY]); + + app.addDefaultFunctionBinding([MY_STRIPE_KEY]); + + - stack.addDefaultFunctionConfig([MY_STRIPE_KEY]); + + stack.addDefaultFunctionBinding([MY_STRIPE_KEY]); + ``` + + 5. App/Stack: **Pass SST Constructs into `addDefaultFunctionBinding`** instead of `addDefaultFunctionPermissions` to grant permissions. `addDefaultFunctionPermissions` will not accept SST Constructs in SST v2. + + ```diff + - app.addDefaultFunctionPermissions([myTopic]); + + app.addDefaultFunctionBinding([myTopic]); + + - stack.addDefaultFunctionPermissions([myTopic]); + + stack.addDefaultFunctionBinding([myTopic]); + ``` + +3. **Client** + + 1. **Change `Job.run("myJob")` to `Job.myJob.run()`** in your functions code. + + ```diff + - Job.run("myJob", { payload }); + + Job.myJob.run({ payload }); + ``` + +--- + +## Upgrade to v1.10 + +#### Constructs + +- The old `Auth` construct has been renamed to `Cognito` construct. + + ```diff + - new Auth(stack, "auth", { + + new Cognito(stack, "auth", { + login: ["email"], + }); + ``` + +--- + +## Upgrade to v1.3 + +#### Constructs + +- Auth: `attachPermissionsForAuthUsers()` and `attachPermissionsForUnauthUsers()` now take a scope as the first argument. + + ```diff + const auth = new Auth(stack, "auth", { + login: ["email"], + }); + + - auth.attachPermissionsForAuthUsers(["s3", "sns"]); + + auth.attachPermissionsForAuthUsers(auth, ["s3", "sns"]); + + - auth.attachPermissionsForUnauthUsers(["s3"]); + + auth.attachPermissionsForUnauthUsers([auth, "s3"]); + ``` + +--- + +## Migrate to v1.0 + +[View the full migration guide](./constructs/v0/migration.md) diff --git a/www/docs/video.module.css b/www/docs/video.module.css new file mode 100644 index 0000000000..1eba1b53cb --- /dev/null +++ b/www/docs/video.module.css @@ -0,0 +1,13 @@ +.videoWrapper { + position: relative; + padding-bottom: 56.25%; /* 16:9 */ + height: 0; + margin-bottom: var(--ifm-leading); +} +.videoWrapper iframe { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} diff --git a/www/docs/what-is-sst.md b/www/docs/what-is-sst.md new file mode 100644 index 0000000000..36e61aabef --- /dev/null +++ b/www/docs/what-is-sst.md @@ -0,0 +1,417 @@ +--- +title: What is SST +description: "SST is a framework that makes it easy to build modern full-stack applications on AWS." +--- + +import styles from "./video.module.css"; +import HeadlineText from "@site/src/components/HeadlineText"; + + + +SST is a framework that makes it easy to build modern full-stack applications on AWS. + + + +Deploy a serverless Next.js, Svelte, Remix, Astro, or Solid app to your AWS account and add any backend feature to it. + +--- + +## Frontend + +Start by defining, **_in code_**, the frontend you are using. SST supports the following. + +--- + +### Next.js + +```ts +new NextjsSite(stack, "site", { + customDomain: "my-next-app.com", +}); +``` + +Behind the scenes, [`NextjsSite`](constructs/NextjsSite.md) will create the infrastructure to host your serverless [Next.js](https://nextjs.org/) app on AWS. You can also configure it with your custom domain. + +--- + +### Svelte + +Similarly there's [`SvelteKitSite`](constructs/SvelteKitSite.md) for [Svelte](https://svelte.dev). + +```ts +new SvelteKitSite(stack, "site", { + customDomain: "my-svelte-app.com", +}); +``` + +--- + +### Remix + +Or the [`RemixSite`](constructs/RemixSite.md) for [Remix](https://remix.run). + +```ts +new RemixSite(stack, "site", { + customDomain: "my-remix-app.com", +}); +``` + +--- + +### Astro + +Or the [`AstroSite`](constructs/AstroSite.md) for [Astro](https://astro.build). + +```ts +new AstroSite(stack, "site", { + customDomain: "my-astro-app.com", +}); +``` + +--- + +### Solid + +And the [`SolidStartSite`](constructs/SolidStartSite.md) for [Solid](https://www.solidjs.com). + +```ts +new SolidStartSite(stack, "site", { + customDomain: "my-solid-app.com", +}); +``` + +--- + +### Static sites + +There's also the [`StaticSite`](constructs/StaticSite.md) for any static site builder. + +```ts {3,4} +new StaticSite(stack, "site", { + path: "web", + buildOutput: "dist", + buildCommand: "npm run build", + customDomain: "my-static-site.com", +}); +``` + +Just specify the build command and point to where the output is generated. + +--- + +## Infrastructure + +The above snippets are a way of defining the features of your application in code. You can define any feature of your application, not just the frontend. + +You can add backend features like APIs, databases, cron jobs, and more. All **without ever using the AWS Console**. + +--- + +#### Constructs + +These snippets are called [**Constructs**](constructs/index.md). They are **TypeScript** or **JavaScript** classes, where each class corresponds to a feature and it can be configured through its props. + +```ts +const site = new NextjsSite(stack, "site", { + /** props **/ +}); +``` + +We recommend using TypeScript because it allows for **full type safety** while configuring your application. + +--- + +#### Stacks + +Constructs are grouped into stacks. They allow you to organize the infrastructure in your application. + +```ts title="stacks/Web.ts" +export function Web({ stack }: StackContext) { + const site = new NextjsSite(stack, "site"); +} +``` + +Each stack is just a function that creates a set of constructs. + +--- + +#### App + +Finally, you add all your stacks to your app in the `sst.config.ts`. + +```ts title="sst.config.ts" {9} +export default { + config() { + return { + name: "my-sst-app", + region: "us-east-1", + }; + }, + stacks(app) { + app.stack(Database).stack(Api).stack(Web); + }, +} satisfies SSTConfig; +``` + +Now let's look at how you can add the backend for your app with these constructs. + +--- + +## Backend + +SST has constructs for most backend features. And you can even use any AWS service in your app. + +--- + +### APIs + +For example, with the [`Api`](constructs/Api.md) construct you can define an API in a few lines. + +```js +new Api(stack, "api", { + routes: { + "GET /notes": "functions/list.main", + "POST /notes": "functions/create.main", + }, +}); +``` + +Behind the scenes, this creates a serverless API using [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html), where each route points to a Lambda function. + +--- + +### Functions + +So when a user hits the `/notes` route in your API. + +```ts +"GET /notes": "functions/list.main" +``` + +The `main` function in `functions/list.ts` gets executed. The API then responds with what's returned. + +```ts title="functions/list.ts" +export async function main() { + return { + statusCode: 200, + body: JSON.stringify([ + /** list of notes **/ + ]), + }; +} +``` + +Your functions can be in **TypeScript**, **JavaScript**, **Python**, **Golang**, **Java**, or **C#**. + +--- + +### Databases + +You can add a serverless database to your app. For example, the [`RDS`](constructs/RDS.md) construct configures a new [Amazon RDS](https://aws.amazon.com/rds/) serverless PostgreSQL cluster. + +```ts +new RDS(stack, "notesDb", { + engine: "postgresql11.13", + defaultDatabaseName: "main", + migrations: "services/migrations", +}); +``` + +In addition to SQL databases, SST also supports [Amazon DynamoDB](constructs/Table.md), a NoSQL serverless database. + +--- + +### File uploads + +Or create S3 buckets to support file uploads in your application. + +```ts +new Bucket(stack, "public"); +``` + +--- + +### Cron jobs + +And add cron jobs to your application with a few lines. Here's a cron job that calls a function every minute. + +```ts +new Cron(stack, "cron", { + schedule: "rate(1 minute)", + job: "functions/cronjob.main", +}); +``` + +SST also has constructs for [**Auth**](constructs/Auth.md), [**Queues**](constructs/Queue.md), [**Pub/Sub**](constructs/Topic.md), [**Data Streams**](constructs/KinesisStream.md), and more. + +--- + +### All AWS services + +Aside from the features that SST's constructs support, you can **add any AWS service** to your app. This is because SST is built on top of [AWS CDK](https://aws.amazon.com/cdk/) and you can use any CDK construct in SST. + +Here we are defining an [Amazon ECS](https://aws.amazon.com/ecs/) cluster with an [AWS CDK construct](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns-readme.html). + +```ts +import * as ecs from "aws-cdk-lib/aws-ecs"; + +const cluster = new ecs.Cluster(stack, "Cluster", { + vpc, +}); +``` + +This ensures that as your app grows, you'll be able to add any feature you need. + +--- + +## Connecting everything + +Once you've added a couple of features, SST can help you connect them together. This is great because you **won't need to hardcode** anything in your app. + +For example, you can [_bind_](resource-binding.md) an S3 bucket to your Next.js app. + +```ts {1,5} +const bucket = new Bucket(stack, "public"); + +new NextjsSite(stack, "site", { + // ... + bind: [bucket], +}); +``` + +You can then connect to the S3 bucket in Next.js without hardcoding the bucket name. + +```ts title="pages/index.tsx" {4} +import { Bucket } from "sst/node/bucket"; + +export async function getServerSideProps() { + const name = Bucket.public.bucketName; +} +``` + +Behind the scenes SST also adds the required [**permissions**](https://aws.amazon.com/iam/), so only your Next.js app has access to the bucket. + +--- + +## Project structure + +We've looked at a couple of different types of files. Let's take a step back and see what an SST app looks like in practice. + +--- + +#### Standalone mode + +Running [`npm create sst`](packages/create-sst.md) generates a _standalone_ SST app. It's monorepo by default. + +``` +my-sst-app +β”œβ”€ sst.config.ts +β”œβ”€ package.json +β”œβ”€ packages +β”‚Β Β β”œβ”€ functions +β”‚Β Β β”œβ”€ core +│  └─ web +└─ stacks +``` + +Where you can add your frontend to the `packages/web/` directory, `packages/functions/` are for backend functions, `packages/core/` is for any shared business logic. Finally, `stacks/` has your infrastructure definitions. + +--- + +#### Drop-in mode + +SST can also be used as a part of your frontend app. For example, if you run `npm create sst` inside a Next.js app, it'll drop a `sst.config.ts` in your project. + +```text {3} +my-nextjs-app +β”œβ”€ next.config.js +β”œβ”€ sst.config.ts +β”œβ”€ package.json +β”œβ”€ public +β”œβ”€ styles +└─ pages +``` + +This is great if you have a simple Next.js app and you just want to deploy it to AWS with SST. + +--- + +## SST CLI + +To help with building and deploying your app, SST comes with a [CLI](packages/sst.md). + +--- + +### Local dev + +The [`sst dev`](live-lambda-development.md) command starts a local development environment called [Live Lambda](live-lambda-development.md), that connects directly to AWS. Letting you [set breakpoints and test your functions locally](live-lambda-development.md#debugging-with-vs-code). + +```bash +npx sst dev +``` + +Now you can start your frontend with the [`sst bind`](packages/sst.md#sst-bind) command and it'll connect your frontend to the backend. + +```bash +sst bind next dev +``` + +With this you can **make changes to your backend on AWS**, and see them **directly in your frontend**! + +--- + +### SST Console + +The `sst dev` CLI also powers a **web based dashboard** called the [SST Console](console.md). + +![SST Console homescreen](/img/console/sst-console-homescreen.png) + +With the Console you can view and interact with your application in real-time. You can manually invoke functions, view logs, replay invocations, and do things like query your database and run migrations. + +--- + +### Deployment + +To deploy your application to AWS, you use the [`sst deploy`](packages/sst.md#sst-deploy) command. It uses your local [IAM credentials](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html) and **deploys to your AWS account**. + +```bash +npx sst deploy +``` + +Since everything in your app is connected, this single command is all you need. Once complete, it'll print out your app's URL! + +```bash {3} +Outputs: + ApiEndpoint: https://ck198mfop1.execute-api.us-east-1.amazonaws.com + SiteUrl: https://my-next-app.com +``` + +Behind the scenes, it compiles the constructs to [AWS CloudFormation](https://aws.amazon.com/cloudformation/), packages your frontend assets and functions, uploads it to AWS, and creates your app's infrastructure. + +--- + +### Environments + +The `sst deploy` command can also deploy your app to a specific _stage_ or environment. This lets you **create separate environments** for development, production, pull-requests, or branches. + +```bash +# Deploy to dev +npx sst deploy --stage dev + +# Deploy to production +npx sst deploy --stage prod +``` + +You can use this in your GitHub Actions workflow to generate pull-request based environments. + +Or, you can get **automatic preview environments** with [**_SEED_**](https://seed.run), a service built by the SST team. + +--- + +## Next steps + +1. Create your first SST app + - [Create a standalone SST app](start/standalone.md) + - [Use SST with your Next.js app](start/nextjs.md) + - [Use SST with your Astro site](start/astro.md) +2. Ready to dive into the details of SST? [**Check out our tutorial**](learn/index.md). diff --git a/www/docs/working-with-your-team.md b/www/docs/working-with-your-team.md new file mode 100644 index 0000000000..dc820286db --- /dev/null +++ b/www/docs/working-with-your-team.md @@ -0,0 +1,205 @@ +--- +title: Working With Your Team +description: "How to use SST with a team of developers." +--- + +When using SST with a team of developers, there are a few different workflows you can choose to keep things organized. We've documented the three most common patterns below. We've also listed the various tradeoffs in security, complexity, and safety. + +:::info +In this doc we refer to the concept of an _"AWS Account"_. This is not the individual accounts tied to a user but rather the AWS account that was created for your organization to deploy resources into. +::: + +## AWS SSO + +Regardless of the workflow you choose, we strongly recommend setting up [AWS SSO](https://aws.amazon.com/blogs/security/how-to-create-and-manage-users-within-aws-sso/). Historically, you would issue [IAM credentials](https://sst.dev/chapters/create-an-iam-user.html) to each developer on your team. However, these credentials usually had static keys associated with them that are easy to leak. + +AWS SSO is built on issuing temporary credentials and implements best practices around credential management. It can be used stand-alone or with your existing SSO provider (Okta, Google Workspace, etc). + +## Workflows + +Let's look at the common workflows. + +### Single AWS Account + +The simplest setup is a single AWS account to house all of your environments. This means local environments, development, staging, and production are all in the same account. They are separated by including the name of the stage in the stacks. + +You also need to create separate IAM accounts for each of your developers. + +#### Local Development + +For local development run. + +```bash +npx sst dev +``` + +This will prompt you for a local stage name when you first run it and will prefix all the stacks with it. You can [read more about this here](live-lambda-development.md#starting-the-local-environment). + +Typically this corresponds to a developer's name so their stacks will look like: `tom-myapp-stack1`, or `$user_name-$app_name-$stack_name`. This ensures that two developers deploying their local environments will not conflict with each other, since they are using different stage names. + +:::note +SST is designed to give each developer their own isolated development environment. If two people run `sst dev` with the same stage name, the person that connected first will get disconnected when the second person connects. +::: + +#### Staging + +For deploying to staging, you explicitly pass in the stage name. + +```bash +npx sst deploy --stage staging +``` + +This will deploy stacks that look like this `staging-myapp-stack1`, instead of using the local stage name. + +#### Production + +For deploying to production, similarly you pass in the stage name. + +```bash +npx sst deploy --stage production +``` + +This deploys stacks that look like, `production-myapp-stack`. + +#### Pros + +- This is the simplest option. + +#### Cons + +- Poor security: Developers have access to all environments. +- Poor safety: Development resources are side by side production resources. It's easy to accidentally touch production data. +- Hard to understand costs between different environments. + +### AWS Account per environment + +A moderately complex setup involves creating a new AWS Account for each environment - typically `dev`, `staging`, and `production`. Spinning up multiple AWS Accounts might seem strange but is actually best practice. + +AWS makes this easy to do with [AWS Organizations](https://sst.dev/chapters/manage-aws-accounts-using-aws-organizations.html). You can create a master account associated with an organization and then easily create sub-accounts for each of your environments. Note, AWS SSO should be configured in the master account. + +#### Local Development + +For local development you can start SST by specifying the profile associated with the dev environment. + +``` +AWS_PROFILE=dev-profile npx sst dev +``` + +Just like in the [Single AWS Account](#single-aws-account) setup, this will [prompt you for a local stage name](live-lambda-development.md#starting-the-local-environment) when first run and prefix all your stacks. + +Locally you can set this profile as the `default` one in your `~/.aws/credentials`. + +```bash +[default] +aws_access_key_id = BNMYJSSP5PTLBDBRSWPO +aws_secret_access_key = 7yuIM8xNf17ue+DDyOcQizDCKaTVhYevKflZONTe + +[dev-profile] +aws_access_key_id = BNMYJSSP5PTLBDBRSWPO +aws_secret_access_key = 7yuIM8xNf17ue+DDyOcQizDCKaTVhYevKflZONTe +``` + +Allowing you to run `npx sst dev` just as before. + +#### Staging + +For deploying to staging, you need to pass in the profile associated with staging as well as the stage name. + +```bash +AWS_PROFILE=staging-profile npx sst deploy --stage staging +``` + +This will deploy stacks that look like, `staging-myapp-stack1` into the staging account. + +#### Production + +For deploying to production, similarly you can pass in the production profile and stage name + +```bash +AWS_PROFILE=production-profile npx sst deploy --stage production +``` + +This deploys stacks that look like, `production-myapp-stack` into the production account. + +#### Pros + +- Better security: You can restrict access to just the dev account. +- Better safety: With restricted access, developers cannot accidentally touch production resources. + +#### Cons + +- Added complexity of managing multiple AWS accounts. +- Difficult to manage resource constraints per developer. +- Developers can still touch resources that other developers are using. + +### AWS Account per environment and developer + +This is the most complex setup and involves creating a new AWS Account for each environment - typically `dev`, `staging`, and `production`, and also one per developer. The benefits of doing this is that you can make sure developers do not accidentally touch each other's resources. Additionally, you can see billing easily broken down per developer, to ensure that nobody is misusing resources. + +AWS makes it easy to spin up multiple environments with [AWS Organizations](https://sst.dev/chapters/manage-aws-accounts-using-aws-organizations.html). You can create a master account associated with an organization and then easily create sub-accounts for each of your environments and developers. Note, AWS SSO should be configured in the master account. + +#### Local Development + +For local development you can start SST by specifying the profile associated with your personal AWS account and specifying a dev stage. + +```bash +AWS_PROFILE=personal-profile npx sst dev --stage dev +``` + +We can take this a step further. Locally you can set this profile as the `default` one in your `~/.aws/credentials`. + +```bash +[default] +aws_access_key_id = BNMYJSSP5PTLBDBRSWPO +aws_secret_access_key = 7yuIM8xNf17ue+DDyOcQizDCKaTVhYevKflZONTe +[personal-profile] +aws_access_key_id = BNMYJSSP5PTLBDBRSWPO +aws_secret_access_key = 7yuIM8xNf17ue+DDyOcQizDCKaTVhYevKflZONTe +``` + +Update the `start` script in your `package.json`. + +```json +"scripts": { + "test": "sst test", + "dev": "sst dev --stage dev", + "build": "sst build", + "deploy": "sst deploy", + "remove": "sst remove" +}, +``` + +Allowing everybody on your team to just run `npx sst dev`. + +Note that, we don't need a unique stage name, since there are no other developers in your account. + +#### Staging + +For deploying to staging, you can pass in the profile associated with staging as well as a stage name. + +```bash +AWS_PROFILE=staging-profile npx sst deploy --stage staging +``` + +This will deploy stacks that look like, `staging-myapp-stack1` into the staging account. + +#### Production + +For deploying to production, similarly you can pass in the production profile and stage name. + +```bash +AWS_PROFILE=production-profile npx sst deploy --stage production +``` + +This deploys stacks that look like, `production-myapp-stack` into the production account. + +#### Pros + +- Most secure: Developers only have access to their personal environments. +- Most safe: Developers cannot accidentally affect other resources. +- Full visibility into development costs + +#### Cons + +- Added complexity of managing multiple AWS accounts per developer. +- Cannot share dev resources easily. For example, a seeded database for development. diff --git a/www/docusaurus.config.js b/www/docusaurus.config.js new file mode 100644 index 0000000000..8911d61774 --- /dev/null +++ b/www/docusaurus.config.js @@ -0,0 +1,262 @@ +const config = require("./config"); + +module.exports = { + title: "SST", + tagline: "SST Docs", + url: "https://docs.sst.dev", + baseUrl: "/", + onBrokenLinks: "throw", + onBrokenMarkdownLinks: "throw", + favicon: "img/favicon.ico", + organizationName: "serverless-stack", // Usually your GitHub org/user name. + projectName: "sst", // Usually your repo name. + scripts: [ + { + src: "https://kit.fontawesome.com/18c82fcd4d.js", + crossorigin: "anonymous", + }, + ], + stylesheets: [ + "https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;700&family=JetBrains+Mono:wght@400;700&family=Source+Sans+Pro:wght@300;400;600;700&display=swap", + ], + themeConfig: { + prism: { + additionalLanguages: ["csharp"], + theme: require("prism-react-renderer").themes.github, + darkTheme: require("prism-react-renderer").themes.dracula, + }, + // The following are used as defaults but are overriden by + // the "socialCardsUrl" in the "customFields" below. + image: "img/og-image.png", + metaImage: "img/og-image.png", + announcementBar: { + id: "v2", + content: `SST v2 is now available! Check out the upgrade guide.`, + backgroundColor: "#395C6B", + textColor: "#FFFFFF", + isCloseable: false, + }, + navbar: { + title: "", + logo: { + alt: "SST Logo", + src: "img/logo.svg", + }, + items: [ + { + to: "/", + label: "Home", + position: "left", + activeBaseRegex: "^/(?!(constructs|clients|learn))", + }, + { + to: "/learn", + label: "Learn", + position: "left", + activeBaseRegex: "^/learn", + }, + { + href: config.examples, + label: "Examples", + position: "left", + }, + { + to: "/constructs", + label: "Constructs", + position: "left", + activeBaseRegex: "^/constructs$|^/constructs/(?!v0|v1)", + }, + { + to: "/clients", + label: "Clients", + position: "left", + activeBaseRegex: "^/clients", + }, + { + href: config.discord, + position: "right", + "aria-label": "Discord community", + className: "navbar__link__slack", + }, + { + href: config.github, + position: "right", + "aria-label": "GitHub repository", + className: "navbar__link__github", + }, + ], + }, + footer: { + style: "light", + links: [ + { + title: "Docs", + items: [ + { + label: "Get Started", + to: "/", + }, + { + label: "What is SST", + to: "what-is-sst", + }, + { + label: "Live Lambda Dev", + to: "live-lambda-development", + }, + { + label: "Frequently Asked Questions", + to: "faq", + }, + ], + }, + { + title: "Community", + items: [ + { + label: "GitHub", + href: config.github, + }, + { + label: "Twitter", + href: config.twitter, + }, + { + label: "Discord", + href: config.discord, + }, + { + label: "YouTube", + href: config.youtube, + }, + ], + }, + { + title: "Company", + items: [ + { + label: "Blog", + href: "https://sst.dev/blog/", + }, + { + label: "About us", + href: "https://sst.dev/about.html", + }, + { + label: "Contact us", + href: `mailto:${config.email}`, + }, + { + label: "Join our team!", + href: "https://sst.dev/careers.html", + }, + ], + }, + ], + //copyright: `Β© ${new Date().getFullYear()} Anomaly Innovations`, + }, + algolia: { + appId: "8HCQAJFJQZ", + indexName: "docs-serverless-stack", + apiKey: "42ee2027a8dbe57a09913af0c27df9ad", + // Turn on when we have versions + //contextualSearch: true, + // Had to update this in Aloglia's crawler editor to have it picked up + // by Algolia - https://crawler.algolia.com + exclusionPatterns: [ + // Exclude the "v0" and "v1" constructs docs from search results + "https://docs.sst.dev/constructs/v0/**", + "https://docs.sst.dev/constructs/v1/**", + ], + }, + }, + presets: [ + [ + "@docusaurus/preset-classic", + { + docs: { + routeBasePath: "/", + // exclude these pages from user accessing them + exclude: [ + "**.about.md", + "**.tsdoc.md", + "advanced/monorepo-project-structure.md", + ], + sidebarCollapsible: false, + sidebarPath: require.resolve("./sidebars.js"), + showLastUpdateTime: true, + // Please change this to your repo. + editUrl: (params) => { + if (params.docPath.startsWith("constructs")) { + const splits = params.docPath.split("/"); + const name = splits[splits.length - 1].replace(".md", ".ts"); + return ( + "https://github.com/serverless-stack/sst/blob/master/packages/sst/src/constructs/" + + name + ); + } + return ( + "https://github.com/serverless-stack/sst/blob/master/www/docs/" + + params.docPath + ); + }, + }, + theme: { + customCss: require.resolve("./src/css/custom.css"), + }, + gtag: { + trackingID: "G-SCRGH28XB4", + }, + }, + ], + ], + plugins: [ + [ + "@docusaurus/plugin-client-redirects", + { + redirects: [ + { + to: "/start/standalone", + from: "/quick-start", + }, + { + to: "/live-lambda-development", + from: "/working-locally", + }, + { + to: "/constructs/Api", + from: "/constructs/ApolloApi", + }, + { + to: "/", + from: "/deploying-your-app", + }, + { + to: "/live-lambda-development", + from: "/debugging-with-vscode", + }, + { + to: "/advanced/iam-credentials", + from: "/managing-iam-credentials", + }, + { + to: "/advanced/monitoring", + from: "/monitoring-your-app-in-prod", + }, + { + to: "/migrating/cdk", + from: "/migrating-from-cdk", + }, + { + to: "/migrating/serverless-framework", + from: "/migrating-from-serverless-framework", + }, + ], + }, + ], + ], + customFields: { + // Used in "src/theme/DocItem/index.js" to add og:image tags dynamically + socialCardsUrl: "https://social-cards.sst.dev", + }, +}; diff --git a/www/drafts/_monorepo-project-structure.md b/www/drafts/_monorepo-project-structure.md new file mode 100644 index 0000000000..91a15ce3f0 --- /dev/null +++ b/www/drafts/_monorepo-project-structure.md @@ -0,0 +1,99 @@ +--- +title: Monorepo Project Structure +description: "We explore an opinionated monorepo project structure for your SST apps." +--- + +import config from "../../config"; + +SST gives you the flexibility to configure your projects in many different ways. However, as projects grow large, there's a need to better organize them. In this document we cover an opinionated setup that uses TypeScript and [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/). + +We have a starter repo that we are using for reference. You can install it by running: + +``` bash +yarn create serverless-stack --use-yarn --example typescript-monorepo +``` + +There are some decisions made in this repo that reflect certain tradeoffs. We've picked what we feel makes sense for most teams and documented our thought process. + +## Why monorepo + +CI - which is an important part of serverless - is a lot easier when all the code that needs to be built exists in the same repo. It avoids having to figure out how to resolve cross repository dependencies and versioning. + +That said, we've structured the repo in a way where components can be extracted into their own repositories once the boundaries become more clear. + +To do this we are using [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/), which allows us to place multiple packages in this repo without the overhead of managing `node_modules` in each one. Running `yarn` at the root will install all the dependencies across all sub-packages. + +## Separate packages + +Since we're using Yarn Workspaces, it can be tempting to split up your project into many sub-packages; one per domain, one per service, etc. + +The reality is, there isn't much benefit to creating multiple packages. The one technical advantage is it allows having different versions of dependencies for different pieces of your system. While this is true, it's not a common situation. + +When using TypeScript, creating discrete boundaries has additional costs: + +1. You lose the ability to take advantage of features like TypeScript's renaming, to rename all references to a variable or function. +2. Packages need to be built before they can be imported, which means if working across multiple packages you'll need a complex TypeScript watcher setup. +3. More configuration to manage. You'll need a `tsconfig.json` per package to get things working exactly right. + +However, it's still helpful to have discrete boundaries. In our setup, we emulate multiple packages without the costs through the use of TypeScript package aliases. Code in the `core` folder can be imported using `import { Foo } from @acme/core`. See backend/tsconfig.json to see how this works. + +## Project structure + +We've chosen to make two packages in the backend: `core` and `services`. + +### `core` + +This should contain all the business logic for your application. A developer on your team should be able to import this package and do everything that your application can do. It should **not contain** any specific interface information, like REST API details or GraphQL schemas. It should also **not depend** on any other code in this repo. + +This roughly reflects [Domain Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design). For a Todo application, `core` might look like this: + +``` +/core + /user + /todo + /notification + index.ts +``` + +Each folder contains all the implementation details for the domain. And exports only what is expected to be public to other domains. The `index.ts` should then export the domains that are public to the rest of the application. + +### `services` + +This package is for services that will be deployed to AWS. These can be Lambda functions that power your API, triggers for your event bus rules, and the like. It should **not contain** any business logic on its own. It should import domains from `core` and only contain the minimal code necessary to call them and forward results back. + +Here's an example of what this can look like. + +``` +/services + /auth + cognito_triggers.ts + /api + user.ts + todo.ts + /notification + bus_triggers.ts +``` + +## TypeScript + +Instead of specifying `tsconfig.json` details directly, we've added a dependency on `@tsconfig/node14` which includes common defaults for Node 14. Every `tsconfig.json` in the repo extends it. + +The config located at backend/tsconfig.json includes the configuration for aliases to emulate separate packages. If you add additional packages or wish to change the structure you can do so by adding to the `"paths"` patterns. + +Additionally, we use the `include` setting to narrow what is processed. This is helpful to make sure when typechecking your SST stack you're not also wasting time typechecking application code which will be checked later anyway. + +## Testing + +The `backend` folder contains minimal configuration to set up [Jest](https://jestjs.io/) which is a testing framework. The tests can be run using `yarn test` from inside the `backend` folder. Additionally, we are using `esbuild-runner` instead of `ts-jest` to compile the code, making it significantly faster. + +## Scripts + +Full-stack serverless means a lot of your resources are in the cloud. It can be helpful to have scripts to do things like insert data into the database or push items onto a queue. + +We provide a scripts folder to create these scripts - they can import code directly from `@acme/core`. This is an example of why it's helpful to separate your business logic from your lambda code. It allows it to be used in scripting scenarios without having to try and trigger lambdas housing the business logic. + +We take advantage of `esbuild-runner` to execute the TypeScript code directly. You can use the included yarn script to run a script like: + +``` bash +yarn script ./scripts/example.ts +``` diff --git a/www/drafts/_storage.md b/www/drafts/_storage.md new file mode 100644 index 0000000000..aeef28f893 --- /dev/null +++ b/www/drafts/_storage.md @@ -0,0 +1,164 @@ +--- +title: Storage +description: "Learn to store files in your SST app." +--- + +SST provides a simple way to store and serve files using the [`Bucket`](constructs/Bucket.md) construct powered by [Amazon S3](https://aws.amazon.com/s3/). + +Here are a few key terms to understand about S3. + +- **Files** are just like the files on your computer. They can be text documents, images, videos, or any data files. It is best practice to store files outside of your database because of their sizes. + +- **Folders** are a way to organize your files. A folder can also contain other folders. + +- **Buckets** are distinct containers for files and folders. AWS account has soft limit of 100 buckets per AWS account. You can request to have the limit raised. + +You can use the [SST Console](console.md) to manage your files in your buckets. + +![SST Console Buckets tab](/img/console/sst-console-buckets-tab.png) + +It allows you upload, delete, and download files. You can also create and delete folders. + +## Creating a Bucket + +```js +import { Bucket } from "sst/constructs"; + +new Bucket(stack, "myFiles"); +``` + +## Accessing files in Lambda Functions + +To access your files inside a Lambda Function, you need to bind the bucket to the function. + +```js {10,12} +import { Bucket, Function } from "sst/constructs"; + +// Create a Bucket +const bucket = new Bucket(stack, "myFiles"); + +// Create a Function that will access the Bucket +new Function(stack, "Function", { + handler: "src/lambda.main", + bind: [bucket], +}); +``` + +You can then use the AWS S3 SDK to access files in the Bucket. + +```js title="src/lambda.js" +import { Bucket } from "sst/node/bucket"; +import AWS from "aws-sdk"; +const S3 = new AWS.S3(); + +export async function main(event) { + // Download file + const file = S3.getObject({ + Bucket: Bucket.myFiles.bucketName, + Key: "path/to/file.png", + }); + + // ... +} +``` + +## Accessing files in a web app + +### Granting access with presigned URL + +Your users won't have direct access to files in your Bucket. You need to create an API endpoint that generates presigned URLs for the file they want to upload. + +```js +const bucket = new Bucket(stack, "myFiles"); + +new Api(stack, "Api", { + bind: [bucket], + routes: { + "POST /presigned-url": "src/generatePresignedUrl.main", + }, +}); +``` + +And the Lambda function requests a URL from S3. + +```js +import { Bucket } from "sst/node/bucket"; +import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; + +const signedUrl = s3.getSignedUrl("putObject", { + Bucket: Bucket.myFiles.bucketName, + Key: "path/to/folder", +}); +``` + +Then in your web app, we can make a request to the signed url to upload the file. + +```js +const formData = new FormData(); + +formData.append("Content-Type", fileType); +formData.append("file", fileContents); + +fetch(signedUrl, { + method: "POST", + body: formData, +}); +``` + +### Granting access with Cognito Identity Pool + +Another option is to use Cognito Identity Pool to grant temporary IAM permissions for both the authenticated and unauthenticated users in your web app. If you are using the [`Cognito`](constructs/Cognito.md) construct to manage your users, you can grant the permissions like so: + +```js +const bucket = new Bucket(stack, "myFiles"); + +const auth = new Cognito(stack, "Auth", { ... }); + +// Granting permissions to authenticated users +auth.attachPermissionsForAuthUsers(stack, [bucket]); +``` + +You can also grant authenticated users access to a specific folder. + +```js +auth.attachPermissionsForAuthUsers(stack, [ + // Policy granting access to the folder named with their user id + new iam.PolicyStatement({ + actions: ["s3:*"], + effect: iam.Effect.ALLOW, + resources: [ + bucket.bucketArn + "/private/${cognito-identity.amazonaws.com:sub}/*", + ], + }), +]); +``` + +Then in your web app, you can use the [aws-amplify](https://www.npmjs.com/package/aws-amplify) package to upload to the Bucket. + +```js +import { Storage } from "aws-amplify"; + +await Storage.vault.put(filename, file, { + contentType: file.type, +}); +``` + +## Bucket notifications + +You can receive notifications when certain events happen in the Bucket. These can be used to trigger a Lambda function. + +```js +new Bucket(stack, "myFiles", { + notifications: ["src/s3Notification.main"], +}); +``` + +Check out more Bucket notification examples over on the [`Bucket`](constructs/Bucket.md#enabling-s3-event-notifications) construct doc. + +:::tip Example + +Read this tutorial on automatically resizing images uploaded to a Bucket. + +[READ TUTORIAL](https://sst.dev/examples/how-to-automatically-resize-images-with-serverless.html) + +::: diff --git a/www/generate.mjs b/www/generate.mjs new file mode 100644 index 0000000000..42724d7c9a --- /dev/null +++ b/www/generate.mjs @@ -0,0 +1,603 @@ +import fs from "fs/promises"; +import { + Application, + TSConfigReader, + JSONOutput, + ProjectReflection, + ReflectionKind, +} from "typedoc"; +import path from "path"; +import { exit } from "process"; + +const cmd = process.argv[2]; + +const CDK_DOCS_MAP = { + AppProps: "", + IGrantable: "aws_iam", + RetentionDays: "aws_logs", + Duration: "", + Stack: "", + StackProps: "", + CfnOutputProps: "", + IVpc: "aws_ec2", + ISecurityGroup: "aws_ec2", + SubnetSelection: "aws_ec2", + FunctionUrlOptions: "aws_lambda", + LogGroup: "aws_logs", + LogGroupProps: "aws_logs", + ILogGroup: "aws_logs", + IHostedZone: "aws_route53", + ISecret: "aws_secretsmanager", + IApplicationListener: "aws_elasticloadbalancingv2", + INetworkListener: "aws_elasticloadbalancingv2", + Certificate: "aws_certificatemanager", + ICertificate: "aws_certificatemanager", + DnsValidatedCertificate: "aws_certificatemanager", + RestApi: "aws_apigateway", + IRestApi: "aws_apigateway", + Endpoint: "aws_apigateway", + DomainName: "aws_apigateway", + IDomainName: "aws_apigateway", + RestApiProps: "aws_apigateway", + MethodOptions: "aws_apigateway", + TokenAuthorizer: "aws_apigateway", + LambdaIntegrationOptions: "aws_apigateway", + CognitoUserPoolsAuthorizer: "aws_apigateway", + ServerlessCluster: "aws_rds", + IServerlessCluster: "aws_rds", + Role: "aws_iam", + IRole: "aws_iam", + IUserPool: "aws_cognito", + SignInAliases: "aws_cognito", + UserPoolProps: "aws_cognito", + CfnIdentityPool: "aws_cognito", + CfnIdentityPoolRoleAttachment: "aws_cognito", + IUserPoolClient: "aws_cognito", + UserPoolClientOptions: "aws_cognito", + Bucket: "aws_s3", + BucketProps: "aws_s3", + IBucket: "aws_s3", + Rule: "aws_events", + RuleProps: "aws_events", + IEventBus: "aws_events", + CronOptions: "aws_events", + EventBusProps: "aws_events", + SqsQueueProps: "aws_events_targets", + LambdaFunctionProps: "aws_events_targets", + IStream: "aws_kinesis", + StreamProps: "aws_kinesis", + Queue: "aws_sqs", + IQueue: "aws_sqs", + QueueProps: "aws_sqs", + Table: "aws_dynamodb", + ITable: "aws_dynamodb", + TableProps: "aws_dynamodb", + LocalSecondaryIndexProps: "aws_dynamodb", + GlobalSecondaryIndexProps: "aws_dynamodb", + ITopic: "aws_sns", + TopicProps: "aws_sns", + Subscription: "aws_sns", + SqsSubscriptionProps: "aws_sns_subscriptions", + LambdaSubscriptionProps: "aws_sns_subscriptions", + Runtime: "aws_lambda", + Tracing: "aws_lambda", + Function: "aws_lambda", + IFunction: "aws_lambda", + ILayerVersion: "aws_lambda", + FunctionProps: "aws_lambda", + FunctionOptions: "aws_lambda", + SqsEventSourceProps: "aws_lambda_event_sources", + DynamoEventSourceProps: "aws_lambda", + KinesisEventSourceProps: "aws_lambda", + ICommandHooks: "aws_lambda_nodejs", + Distribution: "aws_cloudfront", + IDistribution: "aws_cloudfront", + ICachePolicy: "aws_cloudfront", + CachePolicyProps: "aws_cloudfront", + IOriginRequestPolicy: "aws_cloudfront", + OriginRequestPolicyProps: "aws_cloudfront", + AddBehaviorOptions: "aws_cloudfront", + IResponseHeadersPolicy: "aws_cloudfront", + GraphqlApi: "aws_appsync", + IGraphqlApi: "aws_appsync", + ResolverProps: "aws_appsync", + AwsIamConfig: "aws_appsync", + IDomain: "aws_opensearchservice", +}; + +const app = new Application(); +app.options.addReader(new TSConfigReader()); +app.bootstrap({ + entryPoints: [ + "../packages/sst/src/constructs/Stack.ts", + "../packages/sst/src/constructs/Api.ts", + "../packages/sst/src/constructs/ApiGatewayV1Api.ts", + "../packages/sst/src/constructs/App.ts", + "../packages/sst/src/constructs/Auth.ts", + "../packages/sst/src/constructs/Cognito.ts", + "../packages/sst/src/constructs/Bucket.ts", + "../packages/sst/src/constructs/Cron.ts", + "../packages/sst/src/constructs/Config.ts", + "../packages/sst/src/constructs/Job.ts", + "../packages/sst/src/constructs/RDS.ts", + "../packages/sst/src/constructs/Table.ts", + "../packages/sst/src/constructs/Topic.ts", + "../packages/sst/src/constructs/Parameter.ts", + "../packages/sst/src/constructs/Script.ts", + "../packages/sst/src/constructs/Secret.ts", + "../packages/sst/src/constructs/Queue.ts", + "../packages/sst/src/constructs/Function.ts", + "../packages/sst/src/constructs/EventBus.ts", + "../packages/sst/src/constructs/StaticSite.ts", + "../packages/sst/src/constructs/NextjsSite.ts", + "../packages/sst/src/constructs/AppSyncApi.ts", + "../packages/sst/src/constructs/KinesisStream.ts", + "../packages/sst/src/constructs/WebSocketApi.ts", + "../packages/sst/src/constructs/AstroSite.tsdoc.ts", + "../packages/sst/src/constructs/SolidStartSite.tsdoc.ts", + "../packages/sst/src/constructs/SvelteKitSite.tsdoc.ts", + "../packages/sst/src/constructs/RemixSite.tsdoc.ts", + ], + tsconfig: path.resolve("../packages/sst/tsconfig.json"), + preserveWatchOutput: true, +}); + +if (cmd === "watch") { + // Triggers twice on file change for some reason + app.convertAndWatch(async (reflection) => { + await app.generateJson(reflection, "out.json"); + const json = await fs.readFile("./out.json").then(JSON.parse); + await run(json); + console.log("Generated docs"); + }); +} + +if (cmd === "build") { + console.log("Generating docs..."); + const reflection = app.convert(); + await app.generateJson(reflection, "out.json"); + const json = await fs.readFile("./out.json").then(JSON.parse); + await run(json); + console.log("Generated docs"); +} + +/** @param json {JSONOutput.ModelToObject} */ +async function run(json) { + for (const file of json.children) { + // Class + /** @type {(string | string[] | undefined)[]} */ + const lines = []; + + // Handle classes that extend other class, ie. RemixSite extends SsrSite. + // We need to create a new file ie. RemixSite.tsdoc.ts, export * from + // both files, and generate docs for the new file. + if (file.name.endsWith(".tsdoc")) { + file.name = file.name.replace(".tsdoc", ""); + } + + // get the construct class object in file + const construct = file.children?.find((c) => c.kindString === "Class"); + if (!construct) { + console.log("Skipping", file.name); + continue; + } + lines.push( + `` + ); + + // Constructor + const constructor = construct.children?.find( + (c) => c.kindString === "Constructor" + ); + if (!constructor) + throw new Error(`Could not find Constructor in ${file.name}`); + const isInternal = + constructor.signatures[0].comment?.modifierTags?.includes("@internal"); + if (!isInternal) { + lines.push("\n## Constructor"); + for (const signature of constructor.signatures) { + let constructorName = signature.name; + if (constructorName === "new Secret") { + constructorName = "new Config.Secret"; + } else if (constructorName === "new Parameter") { + constructorName = "new Config.Parameter"; + } + lines.push("```ts"); + lines.push( + `${constructorName}(${signature.parameters + .map((p) => `${p.name}`) + .join(", ")})` + ); + lines.push("```"); + + lines.push("_Parameters_"); + lines.push(); + for (let parameter of signature.parameters) { + lines.push( + `- __${parameter.name}__ ${renderType( + file, + json.children, + parameter.name, + parameter.type + )}` + ); + } + } + } + + const props = []; + lines.push(props); + + // Properties + const classProperties = renderProperties( + file, + json.children, + construct.children, + "", + true + ); + if (classProperties.length > 0) { + lines.push( + "## Properties", + `An instance of \`${construct.name}\` has the following properties.`, + ...classProperties + ); + } + + // Methods + const methods = (construct.children || []) + .filter((c) => c.kindString === "Method") + .filter( + (c) => c.flags.isPublic && !c.flags.isExternal && !c.implementationOf + ) + .filter( + (c) => !c.signatures[0].comment?.modifierTags?.includes("@internal") + ); + if (methods.length) { + lines.push("## Methods"); + lines.push( + `An instance of \`${construct.name}\` has the following methods.` + ); + for (const method of methods) { + lines.push(`### ${method.name}\n`); + for (const signature of method.signatures) { + lines.push( + ...(signatureIsDeprecated(signature) + ? renderSignatureForDeprecated(file, method, signature) + : renderSignature(file, json.children, method, signature)) + ); + } + } + } + + // Interfaces + (file.children || []) + .sort((a, b) => a.name.length - b.name.length) + .filter((c) => c.kindString === "Interface") + .filter((c) => !c.comment?.modifierTags?.includes("@internal")) + .forEach((c) => { + const hoisted = c.name === `${file.name}Props` ? props : lines; + hoisted.push(`## ${c.name}`); + hoisted.push(...(c.comment?.summary || []).map((e) => e.text)); + hoisted.push(...(c.comment?.blockTags || []).map(renderTag)); + hoisted.push(...renderProperties(file, json.children, c.children)); + }); + + const output = lines.flat(100).join("\n"); + const path = `docs/constructs/${file.name}.tsdoc.md`; + await fs.writeFile(path, output); + console.log("Wrote file", path); + } +} + +/** + * @param tag {JSONOutput.CommentTag} + */ +function renderTag(tag) { + return (tag.content || []).map((e) => e.text).join("\n"); +} + +/** + * @param file {JSONOutput.DeclarationReflection} + * @param files {JSONOutput.DeclarationReflection[]} + * @param prefix {string} + * @param parameter {JSONOutput.ParameterReflection["type"]} + * + * @returns {string} + */ +function renderType(file, files, prefix, parameter) { + if (!parameter) { + // TODO + console.log("= = File", JSON.stringify({ prefix, file }, null, 2)); + console.log("= = = Parameter", JSON.stringify({ parameter }, null, 2)); + console.trace(); + throw new Error("No parameter"); + //return ""; + } + if (!parameter.type) throw new Error(`No type for ${parameter}`); + if (parameter.type === "conditional") + return renderType(file, files, prefix, parameter.checkType); + if (parameter.type === "array") + return ( + "Array<" + + renderType(file, files, prefix, parameter.elementType) + + ">" + ); + // Note: intrinsic parameters can have type "reference",for now + // manually exclude the names commonly used for intrinsic parameters + if (parameter.type === "intrinsic" || parameter.name === "T") + return `${parameter.name}`; + if (parameter.type === "literal") + return `"${parameter.value}"`; + if (parameter.type === "template-literal") { + const joined = [ + parameter.head, + ...parameter.tail.map((x) => `$\{${x[0].name}\}${x[1]}`), + ].join(""); + return `${joined}`; + } + if ( + parameter.type === "reflection" && + parameter.declaration && + parameter.declaration.signatures + ) { + const sig = parameter.declaration.signatures[0]; + if (sig.kind === ReflectionKind.CallSignature) { + return `${sig.parameters + .map((p) => renderType(file, files, prefix, p.type)) + .join(", ")} => ${renderType(file, files, prefix, sig.type)}`; + } + } + if (parameter.type === "reflection" && prefix) { + return ( + "\n" + + renderProperties( + file, + files, + parameter.declaration?.children, + prefix + ).join("\n") + ); + } + if (parameter.type === "union") { + return parameter.types + .map((t) => renderType(file, files, prefix, t)) + .filter((x) => x) + .join(" | "); + } + if (parameter.type === "reference") { + if (parameter.package === "typescript") + return `${parameter.name}<${parameter.typeArguments + .map((x) => renderType(file, files, prefix, x)) + .join(", ")}>`; + + if (parameter.package) { + if (parameter.package === "constructs") + return `[${parameter.name}](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.${parameter.name}.html)`; + if (parameter.package === "aws-cdk-lib") { + const pkg = CDK_DOCS_MAP[parameter.name]; + if (pkg == null) throw new Error(`No package for ${parameter.name}`); + if (!pkg) + return `[${parameter.name}](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.${parameter.name}.html)`; + if (pkg) + return `[${parameter.name}](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.${pkg}.${parameter.name}.html)`; + } + if (parameter.package.startsWith("@aws-cdk")) { + const [_, pkg] = parameter.package.split("/"); + return `[${parameter.name}](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_${pkg}.${parameter.name}.html)`; + } + if (parameter.package === "esbuild") + return `[${ + parameter.name + }](https://esbuild.github.io/api/#${parameter.name.toLowerCase()})`; + if (parameter.package === ".pnpm") return ".pnpm"; + + throw "Did not implement handler for package " + parameter.package; + } + + // Find generic params + const cls = file.children?.find((x) => x.kindString === "Class"); + if (cls) { + const cons = cls.children?.find((x) => x.kindString === "Constructor"); + if (cons) { + const sig = cons.signatures?.find( + (x) => x.kindString === "Constructor signature" + ); + if (sig) { + const param = sig.typeParameter?.find( + (x) => x.name === parameter.name + ); + if (param) return renderType(file, files, prefix, param.type); + } + } + } + + const id = parameter.id; + const ref = files + .flatMap((x) => x.children || []) + .find((c) => c.id === id && c.kindString === "Type alias"); + if (ref?.kindString === "Type alias") + return renderType(file, files, prefix, ref.type); + + const link = (() => { + // Do not show link for "SSTConstruct" param type + if (parameter.name === "SSTConstruct") { + return undefined; + } + if (file.children?.find((c) => c.id === id)) + return `#${parameter.name.toLowerCase()}`; + const otherFile = files.find((x) => x.children?.find((c) => c.id === id)); + if (otherFile) return otherFile.name + "#" + parameter.name.toLowerCase(); + return parameter.name; + })(); + if (!link) return `${parameter.name}`; + if (parameter.name === "SsrFunction") return ""; + return `[${parameter.name}](${link})`; + } + return ""; +} + +/** + * @param file {JSONOutput.DeclarationReflection} + * @param files {JSONOutput.DeclarationReflection[]} + * @param properties {JSONOutput.DeclarationReflection[]} + * @param prefix {string} + * @param onlyPublic {boolean} + * + * @returns {string} + */ +function renderProperties(file, files, properties, prefix, onlyPublic) { + const filtered = + properties?.filter( + (c) => + !c.name.startsWith("_") && + (c.kindString === "Property" || c.kindString === "Accessor") && + !c.flags.isExternal && + (!onlyPublic || c.flags.isPublic) && + !c.comment?.modifierTags?.includes("@internal") + ) || []; + const lines = []; + for (const property of filtered.sort((a, b) => { + if (a.name.startsWith("cdk")) return 1; + if (b.name.startsWith("cdk")) return -1; + return a.name.localeCompare(b.name); + })) { + const signature = property.getSignature || property; + const nextPrefix = [prefix, property.name].filter((x) => x).join("."); + if (signature.type?.type !== "reflection") + lines.push(`### ${nextPrefix}${signature.flags.isOptional ? "?" : ""}\n`); + lines.push( + (signature.type?.type === "reflection" ? "" : "_Type_ : ") + + renderType(file, files, nextPrefix, signature.type) + + "\n" + ); + if (signature.comment) { + const def = signature.comment.modifierTags?.find( + (x) => x.tag === "@default" + ); + if (def) + lines.push( + `_Default_ : ${def.content[0].text.trim()}\n` + ); + lines.push(...(signature.comment.summary || []).map((e) => e.text)); + const tags = signature.comment.blockTags || []; + const examples = tags.filter((x) => x.tag === "@example"); + if (examples.length) { + lines.push( + ...examples + .map(renderTag) + .map((x) => x.replace(/new .+\(/g, `new ${file.name}(`)) + ); + } + lines.push( + ...tags + .filter((x) => x.tag !== "@example" && x.tag !== "@default") + .map(renderTag) + ); + } + } + return lines; +} + +/** + * @param file {JSONOutput.DeclarationReflection} + * @param children {JSONOutput.DeclarationReflection[]} + * @param method {JSONOutput.DeclarationReflection} + * @param signature {JSONOutput.DeclarationReflection} + * + * @returns {string} + */ +function renderSignature(file, children, method, signature) { + const lines = []; + lines.push("```ts"); + lines.push( + `${method.flags.isStatic ? "static " : ""}${signature.name}(${ + signature.parameters?.map((p) => `${p.name}`).join(", ") || "" + })` + ); + lines.push("```"); + if (signature.parameters) { + lines.push("_Parameters_"); + lines.push(); + for (let parameter of signature.parameters) { + lines.push( + `- __${parameter.name}__ ${renderType( + file, + children, + parameter.name, + parameter.type + )}` + ); + } + } + if (signature.comment) { + lines.push("\n"); + lines.push(...(signature.comment.summary || []).map((e) => e.text)); + const tags = signature.comment.blockTags || []; + const examples = tags.filter((x) => x.tag === "@example"); + if (examples.length) { + lines.push( + ...examples + .map(renderTag) + .map((x) => x.replace(/new .+\(/g, `new ${file.name}(`)) + ); + } + lines.push(...tags.filter((x) => x.tag !== "@example").map(renderTag)); + } + return lines; +} + +/** + * @param file {JSONOutput.DeclarationReflection} + * @param children {JSONOutput.DeclarationReflection[]} + * @param signature {JSONOutput.DeclarationReflection} + * + * @returns {string} + */ +function renderSignatureForDeprecated(file, method, signature) { + const lines = []; + lines.push(":::caution"); + lines.push("This function signature has been deprecated."); + + lines.push("```ts"); + lines.push( + `${method.flags.isStatic ? "static " : ""}${signature.name}(${ + signature.parameters?.map((p) => `${p.name}`).join(", ") || "" + })` + ); + lines.push("```"); + + if (signature.comment) { + lines.push("\n"); + lines.push(...(signature.comment.summary || []).map((e) => e.text)); + const tags = signature.comment.blockTags || []; + const examples = tags.filter((x) => x.tag === "@example"); + if (examples.length) { + lines.push( + ...examples + .map(renderTag) + .map((x) => x.replace(/new .+\(/g, `new ${file.name}(`)) + ); + } + lines.push(...tags.filter((x) => x.tag !== "@example").map(renderTag)); + } + + lines.push(":::"); + + return lines; +} + +/** + * @param signature {JSONOutput.DeclarationReflection} + * + * @returns {boolean} + */ +function signatureIsDeprecated(signature) { + return signature.comment?.modifierTags?.includes("@deprecated"); +} diff --git a/www/generate.ts b/www/generate.ts deleted file mode 100644 index 6d500cddc7..0000000000 --- a/www/generate.ts +++ /dev/null @@ -1,2654 +0,0 @@ -import * as path from "path"; -import * as fs from "fs"; -import * as TypeDoc from "typedoc"; -import config from "./config"; - -process.on("uncaughtException", (err) => { - restoreCode(); - console.error("There was an uncaught error", err); - process.exit(1); -}); -process.on("unhandledRejection", (reason, promise) => { - restoreCode(); - console.error("Unhandled Rejection at:", promise, "reason:", reason); - process.exit(1); -}); - -type CliCommand = { - name: string; - hidden: boolean; - description: { short: string; long?: string }; - args: { - name: string; - description: { short: string; long?: string }; - required: boolean; - }[]; - flags: { - name: string; - description: { short: string; long?: string }; - type: "string" | "bool"; - }[]; - examples: { - content: string; - }[]; - children: CliCommand[]; -}; - -const cmd = process.argv[2]; -const linkHashes = new Map< - TypeDoc.DeclarationReflection, - Map ->(); -const externalTypeDocLinks = new Map([ - [ - "@aws/durable-execution-sdk-js:DurableContext", - "[the AWS Durable Execution SDK docs](https://docs.aws.amazon.com/durable-functions/sdk-reference/)", - ], -]); -function useLinkHashes(module: TypeDoc.DeclarationReflection) { - const v = - linkHashes.get(module) ?? new Map(); - linkHashes.set(module, v); - return v; -} - -configureLogger(); -patchCode(); -if (!cmd || cmd === "components") { - const [components, sdks] = await Promise.all([ - buildComponents(), - buildSdk(), - ]); - - for (const component of components) { - const sourceFile = component.sources![0].fileName; - // Skip - generated into the global-config doc - if (sourceFile.endsWith("/aws/iam-edit.ts")) continue; - else if (sourceFile === "platform/src/global-config.d.ts") { - const iamEditComponent = components.find((c) => - c.sources![0].fileName.endsWith("/aws/iam-edit.ts") - ); - await generateGlobalConfigDoc(component, iamEditComponent!); - } else if (sourceFile === "platform/src/config.ts") { - await generateConfigDoc(component); - } else if (sourceFile.endsWith("/dns.ts")) await generateDnsDoc(component); - else if ( - sourceFile.endsWith("/aws/permission.ts") || - sourceFile.endsWith("/cloudflare/binding.ts") - ) { - await generateLinkableDoc(component); - } else { - const componentProvider = component.name.split("/")[1]; - const sdkName = component.name.split("/")[2]; - const sdk = sdks.find( - (s) => - // ie. vector - s.name === sdkName || - // ie. aws/realtime - (componentProvider === "aws" && s.name === `aws/${sdkName}`) - ); - const sdkNamespace = sdk && useModuleOrNamespace(sdk); - // Handle SDK modules are namespaced (ie. aws/realtime) - await generateComponentDoc(component, sdkNamespace); - } - } -} -if (!cmd || cmd === "cli") await generateCliDoc(); -if (!cmd || cmd === "examples") { - await generateExamplesDocs(); - await generateIndividualExampleDocs(); -} -if (!cmd || cmd === "changelog") await generateChangelog(); -restoreCode(); - -function generateCliDoc() { - const content = fs.readFileSync("cli-doc.json"); - const json = JSON.parse(content.toString()) as CliCommand; - const outputFilePath = `src/content/docs/docs/reference/cli.mdx`; - - fs.writeFileSync( - outputFilePath, - [ - renderHeader("CLI", "Reference doc for the SST CLI."), - renderSourceMessage("cmd/sst/main.go"), - renderImports(outputFilePath), - renderBodyBegin(), - renderCliAbout(), - renderCliGlobalFlags(), - renderCliCommands(), - renderBodyEnd(), - ] - .flat() - .join("\n") - ); - - function renderCliAbout() { - console.debug(` - about`); - const lines = []; - - lines.push( - ``, - `
    `, - renderCliDescription(json.description), - `
    `, - ``, - `---` - ); - return lines; - } - - function renderCliGlobalFlags() { - const lines: string[] = []; - if (!json.flags.length) return lines; - - lines.push(``, `## Global Flags`); - - for (const f of json.flags) { - console.debug(` - global flag ${f.name}`); - lines.push( - ``, - `### ${f.name}`, - ``, - `
    `, - ``, - `**Type** ${renderCliFlagType(f.type)}`, - ``, - `
    `, - renderCliDescription(f.description), - `
    ` - ); - } - return lines; - } - - function renderCliCommands() { - const lines: string[] = []; - if (!json.children.length) return lines; - - lines.push(``, `## Commands`); - - for (const cmd of json.children.filter((cmd) => !cmd.hidden)) { - console.debug(` - command ${cmd.name}`); - lines.push(``, `### ${cmd.name}`, ``); - - // usage - if (!cmd.children.length) { - lines.push( - `
    `, - '```sh frame="none"', - `sst ${renderCliCommandUsage(cmd)}`, - "```", - `
    ` - ); - } - - // args - if (cmd.args.length) { - lines.push( - ``, - `
    `, - `#### Args`, - ...cmd.args.flatMap((a) => [ - `-

    ${renderCliArgName(a)}

    `, - `

    ${renderCliDescription(a.description)}

    `, - ]), - `
    ` - ); - } - - // flags - if (cmd.flags.length) { - lines.push( - ``, - `
    `, - `#### Flags`, - ...cmd.flags.flatMap((f) => [ - `-

    ${f.name} ${renderCliFlagType( - f.type - )}

    `, - `

    ${renderCliDescription(f.description)}

    `, - ]), - `
    ` - ); - } - - // subcommands - if (cmd.children.length) { - lines.push( - ``, - `
    `, - `#### Subcommands`, - ...cmd.children - .filter((s) => !s.hidden) - .flatMap((s) => [ - `-

    [${s.name}](#${cmd.name}-${s.name})

    `, - ]), - `
    ` - ); - } - - // description - lines.push(renderCliDescription(cmd.description), `
    `); - - // subcommands details - cmd.children - .filter((subcmd) => !subcmd.hidden) - .flatMap((subcmd) => { - lines.push( - `${subcmd.name}`, - `` - ); - - // usage - lines.push( - `
    `, - '```sh frame="none"', - `sst ${cmd.name} ${renderCliCommandUsage(subcmd)}`, - "```", - `
    ` - ); - - // subcommand args - if (subcmd.args.length) { - lines.push( - `
    `, - `#### Args`, - ...subcmd.args.flatMap((a) => [ - `-

    ${a.name}

    `, - `

    ${renderCliDescription(a.description)}

    `, - ]), - `
    ` - ); - } - - // subcommand flags - if (subcmd.flags.length) { - lines.push( - `
    `, - `#### Flags`, - ...subcmd.flags.flatMap((f) => [ - `-

    ${f.name}

    `, - `

    ${renderCliDescription(f.description)}

    `, - ]), - `
    ` - ); - } - - // subcommands description - lines.push(renderCliDescription(subcmd.description), `
    `); - }); - } - return lines; - } - - function renderCliDescription(description: CliCommand["description"]) { - return description.long ?? description.short; - } - - function renderCliArgName(prop: CliCommand["args"][number]) { - return `${prop.name}${prop.required ? "" : "?"}`; - } - - function renderCliCommandUsage(command: CliCommand) { - const parts: string[] = []; - - parts.push(command.name); - command.args.forEach((arg) => - arg.required ? parts.push(`<${arg.name}>`) : parts.push(`[${arg.name}]`) - ); - return parts.join(" "); - } - - function renderCliFlagType(type: CliCommand["flags"][number]["type"]) { - if (type.startsWith("[") && type.endsWith("]")) { - return type - .substring(1, type.length - 1) - .split(",") - .map((t: string) => - [ - ``, - `${t}`, - ``, - ].join("") - ) - .join(` | `); - } - - if (type === "bool") return `boolean`; - return `${type}`; - } -} - -async function generateChangelog() { - console.info(`Generating changelog...`); - - const REPO = "sst/sst"; - const MIN_MAJOR = 4; - const PER_PAGE = 100; - const outputFilePath = `src/data/changelog.json`; - - type GithubRelease = { - tag_name: string; - published_at: string; - created_at: string; - html_url: string; - body: string | null; - draft: boolean; - prerelease: boolean; - }; - - type ChangelogEntry = { - tag: string; - publishedAt: string; - url: string; - body: string; - }; - - const headers: Record = { - Accept: "application/vnd.github+json", - "X-GitHub-Api-Version": "2022-11-28", - "User-Agent": "sst-docs-changelog-generator", - }; - const token = process.env.GITHUB_TOKEN; - if (token) headers.Authorization = `Bearer ${token}`; - - const releases: GithubRelease[] = []; - for (let page = 1; ; page++) { - const url = `https://api.github.com/repos/${REPO}/releases?per_page=${PER_PAGE}&page=${page}`; - const res = await fetch(url, { headers }); - if (!res.ok) { - const text = await res.text().catch(() => ""); - throw new Error( - `GitHub API ${res.status} ${res.statusText} on ${url}: ${text}` - ); - } - const batch = (await res.json()) as GithubRelease[]; - releases.push(...batch); - if (batch.length < PER_PAGE) break; - - // Stop early once we've gone past the v4 cutoff to save calls. - const passedCutoff = batch.every((r) => { - const major = parseMajor(r.tag_name); - return major !== null && major < MIN_MAJOR; - }); - if (passedCutoff) break; - } - console.debug(` - fetched ${releases.length} total releases`); - - const filtered = releases - .filter((r) => !r.draft) - .filter((r) => { - const major = parseMajor(r.tag_name); - return major !== null && major >= MIN_MAJOR; - }) - .sort( - (a, b) => - new Date(b.published_at).getTime() - - new Date(a.published_at).getTime() - ); - console.debug(` - ${filtered.length} releases match v${MIN_MAJOR}+`); - - const entries: ChangelogEntry[] = filtered.map((r) => ({ - tag: r.tag_name, - publishedAt: r.published_at, - url: r.html_url, - body: cleanBody(r.body), - })); - - fs.mkdirSync(path.dirname(outputFilePath), { recursive: true }); - fs.writeFileSync(outputFilePath, JSON.stringify(entries, null, 2) + "\n"); - - function parseMajor(tag: string): number | null { - const m = /^v(\d+)\./.exec(tag); - return m ? Number(m[1]) : null; - } - - function cleanBody(body: string | null): string { - if (!body) return ""; - let text = body.replace(/\r\n/g, "\n"); - - // Strip the trailing "## Changelog" section heading and any blank lines - // immediately preceding it, but keep the bullets that follow. - text = text.replace(/\n*^##\s+Changelog\s*$/im, ""); - - const lines = text.split("\n").map((line) => { - // Match a leading bullet, an optional [hash](url) or bare hash, - // an optional ":" or whitespace separator, then the subject. - // Handles all observed formats: - // * abc1234 subject - // * abc1234: subject - // * [abc1234](https://...): subject - // * [abc1234](https://...) subject - const m = line.match( - /^(\s*[-*]\s+)(?:\[[0-9a-f]{7,40}\](?:\([^)]+\))?|[0-9a-f]{7,40})[:\s]\s*(.*)$/i - ); - if (m) return `${m[1]}${m[2]}`; - return line; - }); - - let result = lines.join("\n"); - - // Strip trailing "(@username)" author attributions from each line. - result = result.replace(/[ \t]*\(@[\w-]+\)[ \t]*$/gm, ""); - - result = result.trim(); - - // Linkify GitHub PR/issue references (#1234) so they remain clickable. - // Skip refs that are already inside a markdown link `[#1234]` or part of - // a URL path (`/issues/1234#anchor` etc). - result = result.replace( - /(^|[^\[\/\w])#(\d{2,})(?!\])/g, - (_, prefix, num) => - `${prefix}[#${num}](https://github.com/${REPO}/issues/${num})` - ); - - // Unwrap parentheses around inline PR/issue links: "([#1234](url))" β†’ "[#1234](url)". - result = result.replace(/\(\[#(\d+)\]\(([^)]+)\)\)/g, "[#$1]($2)"); - - return result; - } -} - -async function generateExamplesDocs() { - const modules = await buildExamples(); - const outputFilePath = `src/content/docs/docs/examples.mdx`; - fs.writeFileSync( - outputFilePath, - [ - renderHeader("Examples", "A collection of example apps for reference."), - renderSourceMessage("examples/"), - renderImports(outputFilePath), - renderIntro(), - ...modules.map((module) => { - console.info(`Generating example ${module.name.split("/")[0]}...`); - return [ - ``, - `---`, - renderExampleComment(module.children![0].comment?.summary!), - ...renderRunFunction(module), - ``, - `View the [full example](${config.github}/tree/dev/examples/${ - module.name.split("/")[0] - }).`, - ``, - ]; - }), - ] - .flat() - .join("\n") - ); - - function renderIntro() { - return [ - `Below is a collection of example SST apps. These are available in the [\`examples/\`](${config.github}/tree/dev/examples) directory of the repo.`, - "", - ":::tip", - "This doc is best viewed through the site search or through the _AI_.", - ":::", - "", - "The descriptions for these examples are generated using the comments in the `sst.config.ts` of the app.", - "", - "#### Contributing", - `To contribute an example or to edit one, submit a PR to the [repo](${config.github}).`, - "Make sure to document the `sst.config.ts` in your example.", - "", - ]; - } - - function renderRunFunction(module: TypeDoc.DeclarationReflection) { - const lines = fs - .readFileSync(path.join(`../examples`, module.sources![0].fileName)) - .toString() - .replace(/\t/g, " ") - .split("\n"); - return [ - '```ts title="sst.config.ts"', - ...extractRunSnippet(lines), - "```", - ]; - } -} - -async function generateIndividualExampleDocs() { - const HANDLER_EXTENSIONS: Record = { - ".ts": "ts", - ".js": "js", - ".py": "python", - ".go": "go", - ".rs": "rs", - }; - - function resolveHandlerFiles( - runBody: string, - exampleDir: string - ): { relPath: string; content: string; lang: string }[] { - const strings = [...runBody.matchAll(/"([^"]+)"/g)].map((m) => m[1]); - const seen = new Set(); - const results: { relPath: string; content: string; lang: string }[] = []; - - for (const str of strings) { - if (str.includes(" ") || str.includes(":") || str.includes("*")) continue; - - const candidates: string[] = []; - const ext = path.extname(str); - if (ext in HANDLER_EXTENSIONS) { - candidates.push(str); - } else { - const lastDot = str.lastIndexOf("."); - if (lastDot > 0) { - const base = str.substring(0, lastDot); - for (const ext of Object.keys(HANDLER_EXTENSIONS)) { - candidates.push(base + ext); - } - } - } - - for (const candidate of candidates) { - const normalized = candidate.replace(/^\.\//, ""); - if (seen.has(normalized)) continue; - const fullPath = path.join(exampleDir, normalized); - try { - if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) { - seen.add(normalized); - const fileExt = path.extname(normalized); - results.push({ - relPath: normalized, - content: fs.readFileSync(fullPath).toString().trimEnd(), - lang: HANDLER_EXTENSIONS[fileExt] || "ts", - }); - break; - } - } catch { - // skip unresolvable paths - } - } - } - - return results; - } - const modules = await buildExamples(); - const outputDir = `src/content/docs/docs/examples`; - fs.mkdirSync(outputDir, { recursive: true }); - - for (const module of modules) { - const dirName = module.name.split("/")[0]; - const comment = module.children![0].comment!; - const commentText = renderExampleComment(comment.summary); - - // Extract title from the ## heading in the comment - const titleMatch = commentText.match(/^##\s+(.+)/m); - if (!titleMatch) continue; - const title = titleMatch[1].trim(); - - // Description is everything after the ## heading - const description = commentText - .replace(/^##\s+.+\n*/m, "") - .trim(); - - const lines = fs - .readFileSync(path.join(`../examples`, module.sources![0].fileName)) - .toString() - .replace(/\t/g, " ") - .split("\n"); - const start = lines.indexOf(" async run() {"); - const end = lines.lastIndexOf(" },"); - const codeBlock = [ - '```ts title="sst.config.ts"', - ...extractRunSnippet(lines), - "```", - ]; - - // Detect handler files referenced in sst.config.ts - const exampleDir = path.join(`../examples`, dirName); - const runBody = lines.slice(start + 1, end).join("\n"); - const handlerFiles = resolveHandlerFiles(runBody, exampleDir) - .filter(({ relPath }) => !description.includes(`title="${relPath}"`)); - - const outputFilePath = path.join(outputDir, `${dirName}.mdx`); - console.info(`Generating individual example page: ${dirName}...`); - fs.writeFileSync( - outputFilePath, - [ - `---`, - `title: "${title}"`, - `description: "${description.split("\n\n")[0].replace(/\n/g, " ").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/`/g, "").replace(/"/g, '\\"')}"`, - `---`, - ``, - `{/* DO NOT EDIT. AUTO-GENERATED FROM "examples/${dirName}" */}`, - ``, - `:::tip`, - `This page is best viewed through the site search or through the _AI_.`, - `:::`, - ``, - description, - ``, - ...codeBlock, - ...handlerFiles.flatMap(({ relPath, content, lang }) => [ - ``, - `\`\`\`${lang} title="${relPath}"`, - content, - `\`\`\``, - ]), - ``, - `View the [full example](${config.github}/tree/dev/examples/${dirName}).`, - ``, - ].join("\n") - ); - } -} - -function extractRunSnippet(lines: string[]) { - const start = lines.indexOf(" async run() {"); - const end = lines.lastIndexOf(" },"); - return stripTopLevelReturnObject( - lines.slice(start + 1, end).map((l) => l.substring(4)) - ); -} - -function stripTopLevelReturnObject(lines: string[]) { - const start = lines.findIndex((line) => /^return\s*\{/.test(line)); - if (start === -1) return trimTrailingBlankLines(lines); - - const end = findReturnObjectEnd(lines, start); - if (end === -1) return trimTrailingBlankLines(lines); - - const before = trimTrailingBlankLines(lines.slice(0, start)); - return trimTrailingBlankLines([...before, ...lines.slice(end + 1)]); -} - -function findReturnObjectEnd(lines: string[], start: number) { - let depth = 0; - - for (let i = start; i < lines.length; i++) { - for (const char of lines[i]) { - if (char === "{") depth++; - if (char === "}") depth--; - } - if (depth === 0 && /}\s*;?\s*$/.test(lines[i])) return i; - } - - return -1; -} - -function trimTrailingBlankLines(lines: string[]) { - const result = [...lines]; - while (result.length && result[result.length - 1].trim() === "") result.pop(); - return result; -} - -async function generateGlobalConfigDoc( - module: TypeDoc.DeclarationReflection, - iamEditComponent: TypeDoc.DeclarationReflection -) { - console.info(`Generating Global...`); - const outputFilePath = `src/content/docs/docs/reference/global.mdx`; - fs.writeFileSync( - outputFilePath, - [ - renderHeader("Global", "Reference doc for the Global `$` library."), - renderSourceMessage("platform/src/global.d.ts"), - renderImports(outputFilePath), - renderBodyBegin(), - renderAbout(useModuleComment(module)), - renderVariables(module, { title: "Variables" }), - renderFunctions(module, useModuleFunctions(module), { - title: "Functions", - }), - renderFunctions(module, useModuleFunctions(iamEditComponent), { - title: "AWS", - }), - renderBodyEnd(), - ] - .flat() - .join("\n") - ); -} - -async function generateConfigDoc(module: TypeDoc.DeclarationReflection) { - console.info(`Generating Config...`); - const sourceFile = module.sources![0].fileName; - const outputFilePath = `src/content/docs/docs/reference/config.mdx`; - fs.writeFileSync( - outputFilePath, - [ - renderHeader("Config", "Reference doc for the `sst.config.ts`."), - renderSourceMessage(sourceFile), - renderImports(outputFilePath), - renderBodyBegin(), - renderAbout(useModuleComment(module)), - renderInterfacesAtH2Level(module, { filter: (c) => c.name === "Config" }), - renderInterfacesAtH2Level(module, { filter: (c) => c.name !== "Config" }), - renderBodyEnd(), - ] - .flat() - .join("\n") - ); -} - -async function generateDnsDoc(module: TypeDoc.DeclarationReflection) { - const dnsProvider = module.name.split("/")[1]; - const sourceFile = module.sources![0].fileName; - const outputFilePath = `src/content/docs/docs/component/${dnsProvider}/dns.mdx`; - const title = - { - aws: "AWS", - cloudflare: "Cloudflare", - vercel: "Vercel", - }[dnsProvider] || dnsProvider; - - const dir = path.dirname(outputFilePath); - fs.mkdirSync(dir, { recursive: true }); - - fs.writeFileSync( - outputFilePath, - [ - renderHeader( - `${title} DNS Adapter`, - `Reference doc for the \`sst.${dnsProvider}.dns\` adapter.` - ), - renderSourceMessage(sourceFile), - renderImports(outputFilePath), - renderBodyBegin(), - renderAbout(useModuleComment(module)), - renderFunctions(module, useModuleFunctions(module), { - title: "Functions", - }), - renderInterfacesAtH2Level(module), - renderBodyEnd(), - ] - .flat() - .join("\n") - ); -} - -async function generateLinkableDoc(module: TypeDoc.DeclarationReflection) { - const name = module.name.split("/")[1]; - const sourceFile = module.sources![0].fileName; - const outputFilePath = path.join( - "src/content/docs/docs/component", - `${module.name.split("/").slice(1).join("/")}.mdx` - ); - const copy = { - "components/aws/permission": { - title: "AWS", - namespace: "sst.aws.permission", - }, - "components/cloudflare/binding": { - title: "Cloudflare", - namespace: "sst.cloudflare.binding", - }, - }[module.name]!; - - const dir = path.dirname(outputFilePath); - fs.mkdirSync(dir, { recursive: true }); - - fs.writeFileSync( - outputFilePath, - [ - renderHeader( - `${copy.title} Linkable helper`, - `Reference doc for the \`${copy.namespace}\` helper.` - ), - renderSourceMessage(sourceFile), - renderImports(outputFilePath), - renderBodyBegin(), - renderAbout(useModuleComment(module)), - renderFunctions(module, useModuleFunctions(module), { - title: "Functions", - }), - renderInterfacesAtH2Level(module), - renderBodyEnd(), - ] - .flat() - .join("\n") - ); -} - -async function generateComponentDoc( - component: TypeDoc.DeclarationReflection, - sdk?: TypeDoc.DeclarationReflection -) { - console.info(`Generating ${component.name}...`); - - const sourceFile = component.sources![0].fileName; - const className = useClassName(component); - const fullClassName = `${useClassProviderNamespace(component)}.${className}`; - const matchRet = component.name.match(/-(v\d+)$/); - const version = matchRet && !className.toLowerCase().endsWith(matchRet[1]) ? `.${matchRet[1]}` : ""; - - // Remove leading `components/` - // module.name = "components/aws/bucket" - // module.name = "components/secret" - const outputFilePath = path.join( - "src/content/docs/docs/component", - `${component.name.split("/").slice(1).join("/")}.mdx` - ); - - const dir = path.dirname(outputFilePath); - fs.mkdirSync(dir, { recursive: true }); - - fs.writeFileSync( - outputFilePath, - [ - renderHeader( - useClassName(component) + version, - `Reference doc for the \`${fullClassName + version}\` component.` - ), - renderSourceMessage(sourceFile), - renderImports(outputFilePath), - renderBodyBegin(), - renderAbout(useClassComment(component)), - renderConstructor(component) - .join("\n") - .replace(`new ${className}`, `new ${className}${version}`), - renderInterfacesAtH2Level(component, { - filter: (c) => c.name === `${className}Args`, - }), - renderProperties(component), - ...(() => { - const lines = [ - ...renderLinks(component), - ...renderCloudflareBindings(component), - ...(["realtime", "task", "workflow"].includes(sdk?.name!) - ? renderAbout(useModuleComment(sdk!)) - : []), - ...(sdk - ? renderFunctions( - sdk, - useModuleFunctions(sdk), - ["realtime", "task", "workflow"].includes(sdk.name) - ? { prefix: sdk.name } - : undefined - ) - : []), - ...(sdk ? renderInterfacesAtH3Level(sdk) : []), - ]; - return lines.length - ? [ - ``, - `## SDK`, - ``, - `Use the [SDK](/docs/reference/sdk/) in your runtime to interact with your infrastructure.`, - ``, - `---`, - ...lines, - ] - : []; - })(), - renderMethods(component), - renderInterfacesAtH2Level(component, { - filter: (c) => c.name !== `${className}Args`, - }), - renderBodyEnd(), - ] - .flat() - .join("\n") - ); -} - -/*************************/ -/** Helps with rendering */ -/*************************/ - -function renderHeader(title: string, description: string) { - return [`---`, `title: ${title}`, `description: ${description}`, `---`]; -} - -function renderSourceMessage(source: string) { - return [``, `{/* DO NOT EDIT. AUTO-GENERATED FROM "${source}" */}`]; -} - -function renderBodyBegin() { - return ['
    ']; -} - -function renderImports(outputFilePath: string) { - const relativePath = path.relative(outputFilePath, "src"); - return [ - ``, - `import { Tabs, TabItem } from '@astrojs/starlight/components';`, - `import VideoAside from '${relativePath}/src/components/VideoAside.astro';`, - `import Segment from '${relativePath}/src/components/tsdoc/Segment.astro';`, - `import Section from '${relativePath}/src/components/tsdoc/Section.astro';`, - `import NestedTitle from '${relativePath}/src/components/tsdoc/NestedTitle.astro';`, - `import InlineSection from '${relativePath}/src/components/tsdoc/InlineSection.astro';`, - "", - ]; -} - -function renderTdComment(parts: TypeDoc.CommentDisplayPart[]) { - return parts.map((part) => part.text).join(""); -} - -function renderExampleComment(parts: TypeDoc.CommentDisplayPart[]) { - return stripSstConfigReturns(renderTdComment(parts)); -} - -function stripSstConfigReturns(markdown: string) { - return markdown.replace( - /```([^\n]*\btitle=(["'])sst\.config\.ts\2[^\n]*)\n([\s\S]*?)```/g, - (_, meta: string, _quote: string, code: string) => { - const stripped = stripTopLevelReturnObject(code.split("\n")).join("\n"); - return `\`\`\`${meta}\n${stripped}\n\`\`\``; - } - ); -} - -function renderBodyEnd() { - return ["
    "]; -} - -function renderType( - module: TypeDoc.DeclarationReflection, - type: - | TypeDoc.DeclarationReflection - | TypeDoc.SignatureReflection - | TypeDoc.ParameterReflection, - opts: { - ignoreOutput?: boolean; - } = {} -) { - // Check for type override - // ie. SST SDK uses @see [@aws-sdk/client-ecs.DescribeTasksResponse](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/DescribeTasksResponse/) - // to override the type of the `any` type. - const see = type.comment?.blockTags.find((t) => t.tag === "@see"); - if (see?.content.length === 1) { - const match = see.content[0].text.match( - /^\[(@aws-sdk\/client-.+)\]\((.+)\)$/ - ); - if (match) { - return `[${match[1]}](${match[2]})`; - } - } - - return renderSomeType(type.type!); - - function renderSomeType(type: TypeDoc.SomeType): string { - if (type.type === "intrinsic") return renderIntrisicType(type); - if (type.type === "literal") return renderLiteralType(type); - if (type.type === "templateLiteral") return renderTemplateLiteralType(type); - if (type.type === "union") return renderUnionType(type); - if (type.type === "indexedAccess") return renderIndexedAccessType(type); - if (type.type === "array") return renderArrayType(type); - if (type.type === "tuple") return renderTupleType(type); - if (type.type === "reference" && type.package === "typescript") { - return renderTypescriptType(type); - } - if (type.type === "reference" && type.package === "@sst/platform") { - return renderSstComponentType(type); - } - if (type.type === "reference" && type.package === "sst") { - return renderSstSdkType(type); - } - if (type.type === "reference" && type.package === "@pulumi/pulumi") { - return renderPulumiType(type); - } - if (type.type === "reference" && type.package?.startsWith("@pulumi/")) { - return renderPulumiProviderType(type); - } - if (type.type === "reference" && type.package === "@pulumiverse/vercel") { - return renderVercelType(type); - } - if (type.type === "reference" && type.package === "@types/aws-lambda") { - return renderAwsLambdaType(type); - } - if (type.type === "reference" && type.package === "esbuild") { - return renderEsbuildType(type); - } - if ( - // when bun is installed globally, package is `bun-types` - (type.type === "reference" && type.package === "bun-types") || - // when bun is installed locally (in CI), package is undefined - (type.type === "reference" && type.qualifiedName === "Shell") - ) { - return renderBunShellType(type); - } - if (type.type === "reference") { - return renderReferenceType(type); - } - if (type.type === "reflection" && type.declaration.signatures) { - return renderCallbackType(type); - } - if (type.type === "reflection" && type.declaration.children?.length) { - return renderObjectType(type); - } - if (type.type === "unknown") { - return renderUnknownType(type as TypeDoc.SomeType & { name?: string }); - } - - // @ts-expect-error - delete type._project; - console.log(type); - throw new Error(`Unsupported type "${type.type}"`); - } - function renderUnknownType(type: TypeDoc.SomeType & { name?: string }) { - return `${(type.name ?? "unknown") - .replace(/&/g, "&") - .replace(//g, ">")}`; - } - function renderIntrisicType(type: TypeDoc.IntrinsicType) { - return `${type.name}`; - } - function renderLiteralType(type: TypeDoc.LiteralType) { - // Intrisic values: don't print in quotes - // ie. - // { - // "type": "literal", - // "value": false - // } - if (type.value === true || type.value === false) { - return `${type.value}`; - } - if (typeof type.value !== "string") { - return `${String(type.value)}`; - } - // String value - // ie. - // { - // "type": "literal", - // "value": "arm64" - // } - const sanitized = - typeof type.value === "string" - ? type.value!.replace(/([*:])/g, "\\$1") - : type.value; - return `${sanitized}`; - } - function renderTemplateLiteralType(type: TypeDoc.TemplateLiteralType) { - // ie. memory: `${number} MB` - // { - // "type": "templateLiteral", - // "head": "", - // "tail": [ - // [ - // { - // "type": "intrinsic", - // "name": "number" - // }, - // " MB" - // ] - // ] - // }, - if ( - typeof type.head !== "string" || - type.tail.length !== 1 || - type.tail[0].length !== 2 || - type.tail[0][0].type !== "intrinsic" || - typeof type.tail[0][1] !== "string" - ) { - console.error(type); - throw new Error(`Unsupported templateLiteral type`); - } - const head = type.head.replace("{", "\\{").replace("}", "\\}"); - const tail = type.tail[0][1].replace("{", "\\{").replace("}", "\\}"); - return `${head}$\\{${type.tail[0][0].name}\\}${tail}`; - } - function renderIndexedAccessType(type: TypeDoc.IndexedAccessType) { - return `${renderSomeType(type.objectType)}[${renderSomeType(type.indexType)}]`; - } - function renderUnionType(type: TypeDoc.UnionType) { - return type.types - .map((t) => renderSomeType(t)) - .join(` | `); - } - function renderArrayType(type: TypeDoc.ArrayType) { - return type.elementType.type === "union" - ? `(${renderSomeType( - type.elementType - )})[]` - : `${renderSomeType(type.elementType)}[]`; - } - function renderTupleType(type: TypeDoc.TupleType) { - return `${renderSomeType(type.elements[0])}[]`; - } - function renderTypescriptType(type: TypeDoc.ReferenceType) { - // ie. Record - return [ - `${type.name}`, - `<`, - type.typeArguments?.map((t) => renderSomeType(t)).join(", "), - `>`, - ].join(""); - } - function renderReferenceType(type: TypeDoc.ReferenceType) { - return [ - `${type.name}`, - ...(type.typeArguments?.length - ? [ - `<`, - type.typeArguments.map((t) => renderSomeType(t)).join(", "), - `>`, - ] - : []), - ].join(""); - } - function renderSstComponentType(type: TypeDoc.ReferenceType) { - if (type.name === "Transform") { - const renderedType = renderSomeType(type.typeArguments?.[0]!); - return [ - renderedType, - ` | `, - `(`, - `args`, - `: `, - renderedType, - `, `, - `opts`, - `: `, - `[ComponentResourceOptions](https://www.pulumi.com/docs/concepts/options/)`, - `, `, - `name`, - `: `, - `string`, - `)`, - ` => `, - `void`, - ].join(""); - } - if (type.name === "Input") { - return [ - `${type.name}`, - `<`, - renderSomeType(type.typeArguments?.[0]!), - `>`, - ].join(""); - } - const dnsProvider = { - AwsDns: "aws", - CloudflareDns: "cloudflare", - VercelDns: "vercel", - }[type.name]; - if (dnsProvider) { - return `[sst.${dnsProvider}.dns](/docs/component/${dnsProvider}/dns/)`; - } - const linkableProvider = { - AwsPermission: { - doc: "aws/permission/", - namespace: "sst.aws.permission", - }, - CloudflareBinding: { - doc: "cloudflare/binding/", - namespace: "sst.cloudflare.binding", - }, - }[type.name]; - if (linkableProvider) { - return `[${linkableProvider.namespace}](/docs/component/${linkableProvider.doc})`; - } - if (type.name === "FunctionArn") { - return [ - '"arn:aws:lambda:${string}"', - ].join(""); - } - if (type.name === "SsrSite") { - return ['All SSR sites'].join(""); - } - // types in the same doc (links to the class ie. `subscribe()` return type) - if (isModuleComponent(module) && type.name === useClassName(module)) { - return `[${type.name}](.)`; - } - // types in the same doc (links to an interface) - if (useModuleInterfaces(module).find((i) => i.name === type.name)) { - return `[${ - type.name - }](#${type.name.toLowerCase()})`; - } - - // types in different doc - const fileName = - (type.reflection as TypeDoc.DeclarationReflection)?.sources?.[0].fileName || - // Some local helper types only carry a ReflectionSymbolId target. - ((type as any)._target?.fileName as string | undefined); - if (fileName?.startsWith("platform/src/components/")) { - const docHash = type.name.endsWith("Args") - ? `#${type.name.toLowerCase()}` - : ""; - const docLink = fileName.replace( - /platform\/src\/components\/(.*)\.ts/, - "/docs/component/$1" - ); - return `[${type.name}](${docLink}${docHash})`; - } - - // types in different doc without their own doc page - if ( - type.name === "Resource" || - type.name === "Constructor" || - type.name === "EsbuildOptions" - ) { - return `${type.name}`; - } - - // @ts-expect-error - delete type._project; - console.error(type); - throw new Error(`Unsupported SST component type`); - } - function renderSstSdkType(type: TypeDoc.ReferenceType) { - // types in the same doc (links to an interface) - if (useModuleInterfaces(module).find((i) => i.name === type.name)) { - return `[${ - type.name - }](#${type.name.toLowerCase()})`; - } - const fileName = - (type.reflection as TypeDoc.DeclarationReflection)?.sources?.[0].fileName || - ((type as any)._target?.fileName as string | undefined); - if ( - fileName?.startsWith("sdk/js/src/") || - fileName?.includes("/sdk/js/src/") - ) { - return renderReferenceType(type); - } - if (type.refersToTypeParameter || (module.children ?? []).find((c) => c.name === type.name)) { - return renderReferenceType(type); - } - if (type.name === "T") { - return `string`; - } - - // @ts-expect-error - delete type._project; - console.error(type); - throw new Error(`Unsupported SST SDK type`); - } - function renderPulumiType(type: TypeDoc.ReferenceType) { - if (type.name === "T") { - return `${type.name}`; - } - if ( - type.name === "Output" || - type.name === "OutputInstance" || - type.name === "Input" - ) { - return opts.ignoreOutput - ? renderSomeType(type.typeArguments?.[0]!) - : [ - `${ - type.name === "OutputInstance" ? "Output" : type.name - }`, - `<`, - renderSomeType(type.typeArguments?.[0]!), - `>`, - ].join(""); - } - if ( - type.name === "UnwrappedObject" || - type.name === "UnwrappedArray" || - type.name === "Unwrap" - ) { - return renderSomeType(type.typeArguments?.[0]!); - } - if (type.name === "ComponentResourceOptions") { - return `[${type.name}](https://www.pulumi.com/docs/concepts/options/)`; - } - if (type.name === "CustomResourceOptions") { - return `[${type.name}](https://www.pulumi.com/docs/iac/concepts/resources/dynamic-providers/)`; - } - if (type.name === "FileAsset") { - return `[${type.name}](https://www.pulumi.com/docs/iac/concepts/assets-archives/#assets)`; - } - if (type.name === "FileArchive") { - return `[${type.name}](https://www.pulumi.com/docs/iac/concepts/assets-archives/#archives)`; - } - // Handle $util type in global.d.ts - if (type.name === "__module") { - return `[@pulumi/pulumi](https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/)`; - } - - // @ts-expect-error - delete type._project; - console.error(type); - throw new Error(`Unsupported @pulumi/pulumi type`); - } - function renderPulumiProviderType(type: TypeDoc.ReferenceType) { - const ret = ((type as any)._target.fileName as string).match( - "node_modules/@pulumi/([^/]+)/(.+).d.ts" - )!; - const provider = ret[1].toLocaleLowerCase(); // ie. aws - const cls = ret[2].toLocaleLowerCase(); // ie. s3/Bucket - if (cls === "types/input") { - // Input types - // ie. errorResponses?: aws.types.input.cloudfront.DistributionCustomErrorResponse[]; - //{ - // type: 'reference', - // refersToTypeParameter: false, - // preferValues: false, - // name: 'DistributionCustomErrorResponse', - // _target: ReflectionSymbolId { - // fileName: '/Users/frank/Sites/ion/platform/node_modules/@pulumi/aws/types/input.d.ts', - // qualifiedName: 'cloudfront.DistributionCustomErrorResponse', - // pos: 427276, - // transientId: NaN - // }, - // qualifiedName: 'cloudfront.DistributionCustomErrorResponse', - // package: '@pulumi/aws', - // typeArguments: undefined - //} - const link = { - DistributionOrigin: "cloudfront/distribution", - DistributionOriginGroup: "cloudfront/distribution", - DistributionCustomErrorResponse: "cloudfront/distribution", - DistributionDefaultCacheBehavior: "cloudfront/distribution", - DistributionOrderedCacheBehavior: "cloudfront/distribution", - PolicyDocument: "iam/getpolicydocument", - }[type.name]; - if (!link) { - // @ts-expect-error - delete type._project; - console.error(type); - throw new Error(`Unsupported @pulumi provider input type`); - } - return `[${ - type.name - }](https://www.pulumi.com/registry/packages/${provider}/api-docs/${link}/#${type.name.toLowerCase()})`; - } else if (cls.startsWith("types/")) { - console.error(type); - throw new Error(`Unsupported @pulumi provider class type`); - } else { - // Resource types - // ie. bucket?: aws.s3.BucketV2; - //{ - // type: 'reference', - // refersToTypeParameter: false, - // preferValues: false, - // name: 'BucketV2', - // _target: ReflectionSymbolId { - // fileName: '/Users/frank/Sites/ion/platform/node_modules/@pulumi/aws/s3/bucketV2.d.ts', - // qualifiedName: 'BucketV2', - // pos: 127, - // transientId: NaN - // }, - // qualifiedName: 'BucketV2', - // package: '@pulumi/aws', - // typeArguments: [] - //} - } - const hash = type.name.endsWith("Args") ? `#inputs` : ""; - return `[${type.name}](https://www.pulumi.com/registry/packages/${provider}/api-docs/${cls}/${hash})`; - } - function renderAwsLambdaType(type: TypeDoc.ReferenceType) { - const ret = ((type as any)._target.fileName as string).match( - "node_modules/@types/aws-lambda/(.+)" - )!; - const filePath = ret[1]; - // Resource types - //{ - // type: 'reference', - // refersToTypeParameter: false, - // preferValues: false, - // name: 'IoTCustomAuthorizerHandler', - // _target: ReflectionSymbolId { - // fileName: '/Users/frank/Sites/ion/node_modules/@types/aws-lambda/trigger/iot-authorizer.d.ts', - // qualifiedName: 'IoTCustomAuthorizerHandler', - // pos: 152, - // transientId: NaN - // }, - // qualifiedName: 'IoTCustomAuthorizerHandler', - // package: '@types/aws-lambda', - // typeArguments: undefined - //} - return `[${type.name}](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/aws-lambda/${filePath})`; - } - function renderVercelType(type: TypeDoc.ReferenceType) { - const ret = ((type as any)._target.fileName as string).match( - "node_modules/@pulumiverse/([^/]+)/(.+).d.ts" - )!; - const provider = ret[1].toLocaleLowerCase(); // ie. vercel - const cls = ret[2].toLocaleLowerCase(); // ie. dnsRecord - // Resource types - //{ - // type: 'reference', - // name: 'DnsRecord', - // _target: ReflectionSymbolId { - // fileName: '/Users/frank/Sites/ion/node_modules/@pulumiverse/vercel/dnsRecord.d.ts', - // qualifiedName: 'DnsRecord', - // pos: 125, - // transientId: NaN - // }, - // qualifiedName: 'DnsRecord', - // package: '@pulumiverse/vercel', - //} - const hash = type.name.endsWith("Args") ? `#inputs` : ""; - return `[${type.name}](https://www.pulumi.com/registry/packages/${provider}/api-docs/${cls}/${hash})`; - } - function renderEsbuildType(type: TypeDoc.ReferenceType) { - const hash = type.name === "Loader" ? `#loader` : "#build"; - return `[${type.name}](https://esbuild.github.io/api/${hash})`; - } - function renderBunShellType(type: TypeDoc.ReferenceType) { - return `[Bun Shell](https://bun.sh/docs/runtime/shell)`; - } - function renderCallbackType(type: TypeDoc.ReflectionType) { - const signature = type.declaration.signatures![0]; - const parameters = (signature.parameters ?? []) - .map( - (parameter) => - `${renderSignatureArg(parameter)}: ${renderSomeType(parameter.type!)}` - ) - .join(", "); - return `(${parameters}) => ${renderSomeType( - signature.type! - )}`; - } - function renderObjectType(type: TypeDoc.ReflectionType) { - return `Object`; - } -} - -function renderVariables( - module: TypeDoc.DeclarationReflection, - opts?: { title?: string } -) { - const lines: string[] = []; - const vars = (module.children ?? []).filter( - (c) => - c.kind === TypeDoc.ReflectionKind.Variable && - !c.comment?.modifierTags.has("@internal") && - !c.comment?.blockTags.find((t) => t.tag === "@deprecated") - ); - - if (!vars.length) return lines; - - // $app's type is Simplify<$APP>, and there's no way to get the flattened type - // in TypeDoc. So we'll replace $app's type with the $APP interface. - const type$app = vars.find((v) => v.name === "$app"); - const interface$app = useModuleInterfaces(module).find( - (i) => i.name === "$APP" - ); - if (type$app && interface$app) { - // @ts-expect-error - type$app.type = { - type: "reflection", - declaration: interface$app, - }; - } - - if (opts?.title) lines.push(``, `## ${opts.title}`); - - for (const v of vars) { - console.debug(` - variable ${v.name}`); - lines.push( - ``, - `### ${renderName(v)}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, v)}`, - ``, - ...renderNestedTypeList(module, v), - `
    `, - ...renderDescription(v), - ...renderExamples(v), - `
    `, - // nested props (ie. `.nodes`) - ...useNestedTypes(v.type!, v.name).flatMap( - ({ depth, prefix, subType }) => [ - `${renderName(subType)}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, subType)}`, - ``, - `
    `, - ...renderDescription(subType), - `
    `, - ] - ) - ); - } - return lines; -} - -function renderFunctions( - module: TypeDoc.DeclarationReflection, - fns: TypeDoc.DeclarationReflection[], - opts?: { title?: string; prefix?: string } -) { - const lines: string[] = []; - - if (!fns.length) return lines; - - if (opts?.title) lines.push(``, `## ${opts?.title}`); - - for (const f of fns) { - console.debug(` - function ${f.name}`); - lines.push(``, `### ${renderName(f)}`, ``); - - // signature - lines.push( - `
    `, - "```ts", - (opts?.prefix ? `${opts.prefix}.` : "") + - renderSignature(f.signatures![0]), - "```", - `
    ` - ); - - // parameters - if (f.signatures![0].parameters?.length) { - lines.push( - ``, - `
    `, - `#### Parameters`, - ...f.signatures![0].parameters.flatMap((param) => { - let type; - // HACK: special handle for $jsonParse's reviver param b/c - // it's a function type. - if (f.name === "$jsonParse" && param.name === "reviver") { - type = renderJsonParseReviverType(); - } else if (f.name === "$jsonStringify" && param.name === "replacer") { - type = renderJsonStringifyReplacerType(); - } else if (f.name === "$transform" && param.name === "resource") { - type = renderTransformResourceType(); - } else if (f.name === "$transform" && param.name === "cb") { - type = renderTransformCallbackType(); - } else { - type = renderType(module, param); - } - - return [ - `-

    ${renderSignatureArg( - param - )} ${type}

    `, - ...renderDescription(param), - ]; - }), - `
    ` - ); - } - - lines.push( - ...renderReturnValue(module, f.signatures![0]), - ...renderDescription(f.signatures![0]), - ``, - ...renderExamples(f.signatures![0]), - `
    ` - ); - } - return lines; -} - -function renderAbout(comment: TypeDoc.Comment) { - console.debug(` - about`); - const lines = []; - - lines.push(``, `
    `); - - // description - lines.push(renderTdComment(comment.summary)); - - // examples - const examples = comment.blockTags.filter((tag) => tag.tag === "@example"); - if (examples.length) { - lines.push( - ``, - ...examples.map((example) => renderTdComment(example.content)) - ); - } - - lines.push(`
    `, ``, `---`); - return lines; -} - -function renderConstructor(module: TypeDoc.DeclarationReflection) { - console.debug(` - constructor`); - const lines = []; - const signature = useClassConstructor(module).signatures![0]; - - lines.push(``, `## Constructor`, ``, ``); - - // signature - lines.push( - `
    `, - "```ts", - renderSignature(signature), - "```", - `
    ` - ); - - // parameters - if (signature.parameters?.length) { - lines.push( - ``, - `
    `, - `#### Parameters`, - ...signature.parameters.flatMap((param) => [ - `-

    ${renderSignatureArg( - param - )} ${renderType(module, param)}

    `, - ...renderDescription(param), - ]), - `
    ` - ); - } - - lines.push(`
    `); - return lines; -} - -function renderMethods(module: TypeDoc.DeclarationReflection) { - const lines: string[] = []; - const methods = useClassMethods(module); - if (!methods?.length) return lines; - - return [ - ``, - `## Methods`, - ...methods.flatMap((m) => - renderMethod(module, m, { - methodTitle: `### ${m.flags.isStatic ? "static " : ""}${renderName(m)}`, - parametersTitle: `#### Parameters`, - }) - ), - ]; -} - -function renderMethod( - module: TypeDoc.DeclarationReflection, - method: TypeDoc.DeclarationReflection, - opts: { methodTitle: string; parametersTitle: string } -) { - if (method.kind !== TypeDoc.ReflectionKind.Method) return []; - const lines = []; - lines.push( - ``, - opts.methodTitle, - ``, - `
    `, - "```ts", - (method.flags.isStatic ? `${useClassName(module)}.` : "") + - renderSignature(method.signatures![0]), - "```", - `
    ` - ); - - // parameters - if (method.signatures![0].parameters?.length) { - lines.push( - ``, - `
    `, - opts.parametersTitle, - ...method.signatures![0].parameters.flatMap((param) => [ - `-

    ${renderSignatureArg( - param - )} ${renderType(module, param)}

    `, - ...renderDescription(param), - ]), - `
    ` - ); - } - - lines.push( - ...renderReturnValue(module, method.signatures![0]), - ...renderDescription(method.signatures![0]), - ``, - ...renderExamples(method.signatures![0]), - `
    ` - ); - return lines; -} - -function renderProperties(module: TypeDoc.DeclarationReflection) { - const lines: string[] = []; - const getters = useClassGetters(module).filter( - (c) => - c.getSignature && - !c.getSignature.comment?.modifierTags.has("@internal") && - !c.getSignature.comment?.blockTags.find((t) => t.tag === "@deprecated") - ); - if (!getters.length) return lines; - - lines.push(``, `## Properties`); - - for (const g of getters) { - console.debug(` - property ${g.name}`); - lines.push( - ``, - `### ${renderName(g)}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, g.getSignature!)}`, - ``, - ...renderNestedTypeList(module, g.getSignature!), - `
    `, - ...renderDescription(g.getSignature!), - `
    `, - // nested props (ie. `.nodes`) - ...useNestedTypes(g.getSignature!.type!, g.name).flatMap( - ({ depth, prefix, subType }) => [ - `${renderName(subType)}`, - ``, - `
    `, - ``, - `**Type** ${ - subType.kind === TypeDoc.ReflectionKind.Property - ? renderType(module, subType) - : renderType(module, subType.getSignature!) - }`, - ``, - `
    `, - ...(subType.kind === TypeDoc.ReflectionKind.Property - ? renderDescription(subType) - : renderDescription(subType.getSignature!)), - `
    `, - ] - ) - ); - } - return lines; -} - -function renderLinks(module: TypeDoc.DeclarationReflection) { - const lines: string[] = []; - const method = useClassMethodByName(module, "getSSTLink"); - if (!method) return lines; - - // Get `getSSTLink()` return type - const returnType = method.signatures![0].type as TypeDoc.ReflectionType; - if (!returnType.declaration) return lines; - - // Get `getSSTLink().properties` type - const properties = returnType.declaration.children?.find( - (c) => c.name === "properties" - ); - if (!properties) return lines; - - // Filter out private `properties` - const propertiesType = properties.type as TypeDoc.ReflectionType; - if (propertiesType.declaration === undefined) { - console.log(properties); - } - const links = (propertiesType.declaration.children || []).filter( - (c) => !c.comment?.modifierTags.has("@internal") - ); - if (!links.length) return lines; - - lines.push( - ``, - `### Links`, - `This is accessible through the \`Resource\` object in the [SDK](/docs/reference/sdk/#links).`, - ``, - `
    `, - ...links.flatMap((link) => { - console.debug(` - link ${link.name}`); - - // Find the getter property that matches the link name - const getter = useClassGetters(module).find((g) => g.name === link.name); - if (!getter) { - throw new Error( - `Failed to render link ${link.name} b/c cannot find a getter property with the matching name` - ); - } - - return [ - `-

    ${renderName(link)} ${renderType( - module, - link, - { ignoreOutput: true } - )}

    `, - "", // Needed to indent the description - ...renderDescription(getter.getSignature!, { indent: true }), - ]; - }), - `
    `, - `
    ` - ); - - return lines; -} - -function renderCloudflareBindings(module: TypeDoc.DeclarationReflection) { - const lines: string[] = []; - const method = useClassMethodByName(module, "getSSTLink"); - if (!method) return lines; - - // Get `getSSTLink()` return type - const returnType = method.signatures![0].type as TypeDoc.ReflectionType; - if (!returnType.declaration) return lines; - - // Get `getSSTLink().include` type - const include = returnType.declaration.children?.find( - (c) => c.name === "include" - ); - if (!include) return lines; - - // Filter out `getSSTLink().include[].type` is `cloudflare.binding` - const includeArrayType = include.type as TypeDoc.ArrayType; - const includeType = includeArrayType.elementType as TypeDoc.ReflectionType; - const isCloudflareBinding = includeType.declaration.children?.some( - (c) => - c.name === "type" && - (c.type as TypeDoc.LiteralType)?.value === "cloudflare.binding" - ); - if (!isCloudflareBinding) return lines; - - lines.push( - ``, - `### Bindings`, - ``, - ...renderDescription(method.signatures![0]), - ``, - ...renderExamples(method.signatures![0]), - `` - ); - - return lines; -} - -function renderInterfacesAtH2Level( - module: TypeDoc.DeclarationReflection, - opts: { - filter?: (c: TypeDoc.DeclarationReflection) => boolean; - } = {} -) { - const lines: string[] = []; - const interfaces = useModuleInterfaces(module) - .filter((c) => !c.comment?.modifierTags.has("@internal")) - .filter((c) => !c.comment?.blockTags.find((t) => t.tag === "@deprecated")) - .filter((c) => !opts.filter || opts.filter(c)) - .filter((c) => c.children?.length); - - for (const int of interfaces) { - console.debug(` - interface ${int.name}`); - // interface name - lines.push(``, `## ${int.name}`); - - // description - if (int.comment?.summary) { - lines.push(``, renderTdComment(int.comment?.summary!)); - } - lines.push(...renderInterfaceInheritedApiSummary(int)); - - // props - for (const prop of useInterfaceProps(int)) { - if (prop.kind === TypeDoc.ReflectionKind.Property) { - console.debug(` - interface prop ${prop.name}`); - lines.push( - `### ${renderName(prop)}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, prop)}`, - ``, - ...renderNestedTypeList(module, prop), - `
    `, - ...renderDefaultTag(module, prop), - ...renderDescription(prop), - ``, - ...renderExamples(prop), - `
    `, - // nested props (ie. `.domain`, `.transform`) - ...useNestedTypes(prop.type!, prop.name).flatMap( - ({ depth, prefix, subType }) => { - return subType.kind === TypeDoc.ReflectionKind.Method - ? renderMethod(module, subType, { - methodTitle: `${renderName( - subType - )}`, - parametersTitle: `**Parameters**`, - }) - : [ - `${renderName( - subType - )}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, subType)}`, - ``, - `
    `, - ...renderDefaultTag(module, subType), - ...renderDescription(subType), - ``, - ...renderExamples(subType), - `
    `, - ]; - } - ) - ); - } else if (prop.kind === TypeDoc.ReflectionKind.Method) { - console.debug(` - interface method ${prop.name}`); - lines.push( - ...renderMethod(module, prop, { - methodTitle: `### ${ - prop.flags.isStatic ? "static " : "" - }${renderName(prop)}`, - parametersTitle: `#### Parameters`, - }) - ); - } - } - } - - return lines; -} - -function renderInterfacesAtH3Level(module: TypeDoc.DeclarationReflection) { - const lines: string[] = []; - const interfaces = useModuleInterfaces(module) - .filter((c) => !c.comment?.modifierTags.has("@internal")) - .filter((c) => !c.comment?.blockTags.find((t) => t.tag === "@deprecated")); - - // props - //for (const prop of useInterfaceProps(int)) { - for (const i of interfaces) { - // fake interface as an Object type so we can reuse the nested type logic - const int = { - name: i.name, - type: { type: "reflection", declaration: i }, - } as TypeDoc.DeclarationReflection; - console.debug(` - interface ${int.name}`); - lines.push( - `### ${int.name}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, int)}`, - ``, - ...renderInterfaceInheritedApiInline(i), - ...renderNestedTypeList(module, int), - `
    `, - `
    `, - // nested props (ie. `.domain`, `.transform`) - ...useNestedTypes(int.type!, int.name).flatMap( - ({ depth, prefix, subType }) => { - return subType.kind === TypeDoc.ReflectionKind.Method - ? renderMethod(module, subType, { - methodTitle: `${renderName( - subType - )}`, - parametersTitle: `**Parameters**`, - }) - : [ - `${renderName(subType)}`, - ``, - `
    `, - ``, - `**Type** ${renderType(module, subType)}`, - ``, - `
    `, - ...renderDefaultTag(module, subType), - ...renderDescription(subType), - ``, - ...renderExamples(subType), - `
    `, - ]; - } - ) - ); - } - - return lines; -} - -function renderName(prop: TypeDoc.DeclarationReflection) { - return `${prop.name}${prop.flags.isOptional ? "?" : ""}`; -} - -function renderSignatureArg(prop: TypeDoc.ParameterReflection) { - if (prop.defaultValue && prop.defaultValue !== "{}") { - throw new Error( - [ - `Unsupported default value "${prop.defaultValue}" for name "${prop.name}".`, - ``, - `Function signature parameters can be defined as optional in one of two ways:`, - ` - flag.isOptional is set, ie. "(args?: FooArgs)"`, - ` - defaultValue is set, ie. "(args: FooArgs = {})`, - ``, - `But in this case, the default value is not "{}". Hence not supported.`, - ].join("\n") - ); - } - - return [ - prop.type?.type === "tuple" ? "..." : "", - prop.name, - prop.flags.isOptional || prop.defaultValue ? "?" : "", - ].join(""); -} - -function renderDescription( - prop: - | TypeDoc.DeclarationReflection - | TypeDoc.ParameterReflection - | TypeDoc.SignatureReflection, - opts?: { indent: true } -) { - if (!prop.comment?.summary) return []; - const str = renderTdComment(prop.comment?.summary); - return opts?.indent - ? [ - str - .split("\n") - .map((line) => ` ${line}`) - .join("\n"), - ] - : [str]; -} - -function renderDefaultTag( - module: TypeDoc.DeclarationReflection, - prop: TypeDoc.DeclarationReflection -) { - const defaultTag = prop.comment?.blockTags.find( - (tag) => tag.tag === "@default" - ); - if (!defaultTag) return []; - return [ - ``, - ``, - // If default tag is just a value, render it as a type ie. false - // Otherwise render it as a comment ie. No domains configured - defaultTag.content.length === 1 && defaultTag.content[0].kind === "code" - ? `**Default** ${renderType(module, { - type: { - type: "intrinsic", - name: defaultTag.content[0].text - .replace(/`/g, "") - .replace(/{/g, "{") - .replace(/}/g, "}"), - }, - } as unknown as TypeDoc.DeclarationReflection)}` - : `**Default** ${renderTdComment(defaultTag.content)}`, - ``, - ]; -} - -function renderReturnValue( - module: TypeDoc.DeclarationReflection, - prop: TypeDoc.SignatureReflection -) { - return [ - ``, - ``, - `**Returns** ${renderType(module, prop)}`, - ``, - ]; -} - -function renderNestedTypeList( - module: TypeDoc.DeclarationReflection, - prop: TypeDoc.DeclarationReflection | TypeDoc.SignatureReflection -) { - return useNestedTypes(prop.type!, prop.name).map( - ({ depth, prefix, subType }) => { - const hasChildren = - subType.kind === TypeDoc.ReflectionKind.Property - ? useNestedTypes(subType.type!).length - : subType.kind === TypeDoc.ReflectionKind.Method - ? useNestedTypes(subType.signatures![0].type!).length - : useNestedTypes(subType.getSignature?.type!).length; - const type = hasChildren ? ` ${renderType(module, subType)}` : ""; - const generateHash = (counter = 0): string => { - const hash = - `${prefix}.${subType.name}` - .toLowerCase() - .replace(/[^a-z0-9\.]/g, "") - .replace(/\./g, "-") + (counter > 0 ? `-${counter}` : ""); - return Array.from(useLinkHashes(module).values()).includes(hash) - ? generateHash(counter + 1) - : hash; - }; - const hash = generateHash(); - useLinkHashes(module).set(subType, hash); - return `${" ".repeat(depth * 2)}-

    [${renderName( - subType - )}](#${hash})${type}

    `; - } - ); -} - -function renderExamples( - prop: TypeDoc.DeclarationReflection | TypeDoc.SignatureReflection -) { - return (prop.comment?.blockTags ?? []) - .filter((tag) => tag.tag === "@example") - .flatMap((tag) => renderTdComment(tag.content)); -} - -function renderSignature(signature: TypeDoc.SignatureReflection) { - const parameters = (signature.parameters ?? []) - .map(renderSignatureArg) - .join(", "); - return `${signature.name}(${parameters})`; -} -function renderInterfaceInheritedApiInline(int: TypeDoc.DeclarationReflection) { - const links = renderExternalExtendedTypeLinks(int); - if (!links.length) return []; - - return [ - ``, - `Only showing custom SDK methods here. For the full API, see ${links.join(", ")}.`, - ``, - ]; -} -function renderInterfaceInheritedApiSummary(int: TypeDoc.DeclarationReflection) { - const links = renderExternalExtendedTypeLinks(int); - if (!links.length) return []; - - return [ - ``, - `Only showing custom SDK methods here. For the full API, see ${links.join(", ")}.`, - ]; -} -function renderExternalExtendedTypeLinks(int: TypeDoc.DeclarationReflection) { - return (int.extendedTypes ?? []) - .filter( - (type): type is TypeDoc.ReferenceType => - type.type === "reference" && Boolean(type.package) - ) - .map((type) => { - const link = externalTypeDocLinks.get(`${type.package}:${type.name}`); - if (!link) return undefined; - return link; - }) - .filter((type): type is string => Boolean(type)); -} -function renderJsonParseReviverType() { - return `[JSON.parse reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#reviver)`; -} -function renderJsonStringifyReplacerType() { - return `[JSON.stringify replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#replacer)`; -} -function renderTransformResourceType() { - return `Component Class`; -} -function renderTransformCallbackType() { - return `(args, opts, name) => void`; -} - -/***************************************/ -/** Helps with parsing TypeDoc objects */ -/***************************************/ - -function isModuleComponent(module: TypeDoc.DeclarationReflection) { - const sourceFile = module.sources![0].fileName; - return ( - sourceFile !== "platform/src/config.ts" && - sourceFile !== "platform/src/global-config.d.ts" && - !sourceFile.endsWith("/dns.ts") && - !sourceFile.endsWith("/aws/permission.ts") && - !sourceFile.endsWith("/cloudflare/binding.ts") - ); -} -function useModuleComment(module: TypeDoc.DeclarationReflection) { - const comment = module.comment; - if (!comment) throw new Error("Class comment not found"); - return comment; -} -function useModuleInterfaces(module: TypeDoc.DeclarationReflection) { - return module.getChildrenByKind(TypeDoc.ReflectionKind.Interface); -} -function useModuleFunctions(module: TypeDoc.DeclarationReflection) { - return module - .getChildrenByKind(TypeDoc.ReflectionKind.Function) - .filter((f) => !f.signatures![0].comment?.modifierTags.has("@internal")); -} -function useModuleOrNamespace(module: TypeDoc.DeclarationReflection) { - // Handle SDK modules are namespaced (ie. aws/realtime) - const namespaces = module.getChildrenByKind(TypeDoc.ReflectionKind.Namespace); - return namespaces.length ? namespaces[0] : module; -} -function useClass(module: TypeDoc.DeclarationReflection) { - const c = module.getChildrenByKind(TypeDoc.ReflectionKind.Class); - if (!c.length) throw new Error("Class not found"); - return c[0]; -} -function useClassName(module: TypeDoc.DeclarationReflection) { - return useClass(module).name; -} -function useClassProviderNamespace(module: TypeDoc.DeclarationReflection) { - // "sources": [ - // { - // "fileName": "platform/src/components/aws/astro.ts", - // "line": 280, - // "character": 13, - // "url": "https://github.com/sst/ion/blob/0776cea/platform/src/components/aws/astro.ts#L280" - // } - // ], - const fileName = useClass(module).sources![0].fileName; - if (!fileName.startsWith("platform/src/components/")) { - throw new Error( - `Fail to generate class namespace from class fileName ${fileName}. Expected to start with "platform/src/components/"` - ); - } - - const namespace = fileName.split("/").slice(-2, -1)[0]; - return namespace === "components" ? "sst" : `sst.${namespace}`; -} -function useClassComment(module: TypeDoc.DeclarationReflection) { - const comment = useClass(module).comment; - if (!comment) throw new Error("Class comment not found"); - return comment; -} -function useClassConstructor(module: TypeDoc.DeclarationReflection) { - const constructor = useClass(module).children?.find( - (c) => c.kind === TypeDoc.ReflectionKind.Constructor - ); - if (!constructor) throw new Error("Constructor not found"); - return constructor; -} -function useClassMethods(module: TypeDoc.DeclarationReflection) { - return useClass(module) - .getChildrenByKind(TypeDoc.ReflectionKind.Method) - .filter( - (c) => - !c.flags.isExternal && - !c.flags.isPrivate && - !c.flags.isProtected && - c.signatures && - !c.signatures[0].comment?.modifierTags.has("@internal") && - !c.signatures[0].comment?.blockTags.find((t) => t.tag === "@deprecated") - ); -} -function useClassMethodByName( - module: TypeDoc.DeclarationReflection, - methodName: string -) { - return useClass(module) - .getChildrenByKind(TypeDoc.ReflectionKind.Method) - .find((c) => !c.flags.isExternal && c.signatures?.[0].name === methodName); -} -function useClassGetters(module: TypeDoc.DeclarationReflection) { - return (useClass(module).children ?? []).filter( - (c) => c.kind === TypeDoc.ReflectionKind.Accessor && c.flags.isPublic - ); -} -function useInterfaceProps(i: TypeDoc.DeclarationReflection) { - if (!i.children?.length) throw new Error(`Interface ${i.name} has no props`); - - return i.children - .filter((c) => !c.flags.isExternal) - .filter((c) => !c.comment?.modifierTags.has("@internal")) - .filter((c) => !c.comment?.blockTags.find((t) => t.tag === "@deprecated")); -} -function useNestedTypes( - type: TypeDoc.SomeType, - prefix: string = "", - depth: number = 0 -): { - subType: TypeDoc.DeclarationReflection; - prefix: string; - depth: number; -}[] { - if (type.type === "union") { - return type.types.flatMap((t) => useNestedTypes(t, prefix, depth)); - } - if (type.type === "array") { - return useNestedTypes(type.elementType, `${prefix}[]`, depth); - } - if (type.type === "reference") { - return (type.typeArguments ?? []).flatMap((t) => - type.package === "typescript" && type.name === "Record" - ? useNestedTypes(t, `${prefix}[]`, depth) - : useNestedTypes(t, prefix, depth) - ); - } - if (type.type === "reflection" && type.declaration.children?.length) { - return type.declaration - .children! - .filter((c) => !c.flags.isExternal) - .filter((c) => !c.comment?.modifierTags.has("@internal")) - .filter((c) => !c.comment?.blockTags.find((t) => t.tag === "@deprecated")) - .flatMap((subType) => [ - { prefix, subType, depth }, - ...(subType.kind === TypeDoc.ReflectionKind.Property - ? useNestedTypes( - subType.type!, - `${prefix}.${subType.name}`, - depth + 1 - ) - : []), - ...(subType.kind === TypeDoc.ReflectionKind.Accessor - ? useNestedTypes( - subType.getSignature?.type!, - `${prefix}.${subType.name}`, - depth + 1 - ) - : []), - ]); - } - - return []; -} - -/********************/ -/** Other functions */ -/********************/ - -function configureLogger() { - if (process.env.DEBUG) return; - console.debug = () => {}; -} - -function patchCode() { - // patch Input - fs.renameSync( - "../platform/src/components/input.ts", - "../platform/src/components/input.ts.bk" - ); - fs.copyFileSync("./input-patch.ts", "../platform/src/components/input.ts"); - // patch global - const globalType = fs.readFileSync("../platform/src/global.d.ts"); - fs.writeFileSync( - "../platform/src/global-config.d.ts", - globalType - .toString() - .trim() - // move all exports out of `declare global {}`, b/c TypeDoc doesn't support it - .replace("declare global {", "") - .replace(/}$/, "") - // change `export import $util` to `export const $util` b/c TypeDoc - // tries to traverse the import and fails. We don't need to look into $util - // anyways as we will link to the pulumi docs. - .replace("export import $util", "export const $util") - // change `export function $resolve` to `function $resolve` b/c TypeDoc - // search multiple lines - .replace( - /export function \$resolve[\s\S]*?(?=\/\*\*)/, - "export const $resolve: typeof util.all;\n" - ) - ); - // patch Linkable - fs.cpSync( - "../platform/src/components/linkable.ts", - "../platform/src/components/linkable.ts.bk" - ); - fs.writeFileSync( - "../platform/src/components/linkable.ts", - fs - .readFileSync("../platform/src/components/linkable.ts") - .toString() - .trim() - // replace generic - .replace("properties: Properties", "properties: Record") - .replace( - "public get properties() {", - "public get properties(): Record {" - ) - // replace generic - .replaceAll(`cls: { new (...args: any[]): Resource }`, `cls: Constructor`) - // replace Definition.include - .replace( - /include\?\: \{[^}]*\}/, - `include?: (AwsPermission | CloudflareBinding)` - ) + - "\ntype Constructor = {};\n" + - "\ntype AwsPermission = {};\n" + - "\ntype CloudflareBinding = {};\n" - ); - // patch StepFunctions - ["map.ts", "parallel.ts", "pass.ts", "task.ts", "wait.ts"].forEach((file) => { - fs.cpSync( - `../platform/src/components/aws/step-functions/${file}`, - `../platform/src/components/aws/step-functions/${file}.bk` - ); - fs.writeFileSync( - `../platform/src/components/aws/step-functions/${file}`, - fs - .readFileSync(`../platform/src/components/aws/step-functions/${file}`) - .toString() - .trim() - .replace( - "public next(state: T): T {", - "public next(state: State): State {" - ) - ); - }); -} - -function restoreCode() { - // restore Input - fs.renameSync( - "../platform/src/components/input.ts.bk", - "../platform/src/components/input.ts" - ); - // restore global - fs.rmSync("../platform/src/global-config.d.ts"); - // restore Linkable - fs.renameSync( - "../platform/src/components/linkable.ts.bk", - "../platform/src/components/linkable.ts" - ); - // restore StepFunctions - ["map.ts", "parallel.ts", "pass.ts", "task.ts", "wait.ts"].forEach((file) => { - fs.renameSync( - `../platform/src/components/aws/step-functions/${file}.bk`, - `../platform/src/components/aws/step-functions/${file}` - ); - }); -} - -async function buildComponents() { - // Generate project reflection - const app = await TypeDoc.Application.bootstrap({ - // Ignore type errors caused by patching `Input<>`. - skipErrorChecking: true, - // Disable parsing @default tags as ```ts block code. - jsDocCompatibility: { - defaultTag: false, - }, - entryPoints: [ - "../platform/src/config.ts", - "../platform/src/global-config.d.ts", - "../platform/src/components/experimental/dev-command.ts", - "../platform/src/components/linkable.ts", - "../platform/src/components/secret.ts", - "../platform/src/components/aws/analog.ts", - "../platform/src/components/aws/apigateway-websocket.ts", - "../platform/src/components/aws/apigateway-websocket-route.ts", - "../platform/src/components/aws/apigatewayv1.ts", - "../platform/src/components/aws/apigatewayv1-api-key.ts", - "../platform/src/components/aws/apigatewayv1-authorizer.ts", - "../platform/src/components/aws/apigatewayv1-integration-route.ts", - "../platform/src/components/aws/apigatewayv1-lambda-route.ts", - "../platform/src/components/aws/apigatewayv1-usage-plan.ts", - "../platform/src/components/aws/apigatewayv2.ts", - "../platform/src/components/aws/apigatewayv2-authorizer.ts", - "../platform/src/components/aws/apigatewayv2-lambda-route.ts", - "../platform/src/components/aws/apigatewayv2-private-route.ts", - "../platform/src/components/aws/apigatewayv2-url-route.ts", - "../platform/src/components/aws/app-sync.ts", - "../platform/src/components/aws/app-sync-data-source.ts", - "../platform/src/components/aws/app-sync-function.ts", - "../platform/src/components/aws/app-sync-resolver.ts", - "../platform/src/components/aws/auth.ts", - "../platform/src/components/aws/aurora.ts", - "../platform/src/components/aws/bucket.ts", - "../platform/src/components/aws/bucket-notification.ts", - "../platform/src/components/aws/bus.ts", - "../platform/src/components/aws/bus-lambda-subscriber.ts", - "../platform/src/components/aws/bus-queue-subscriber.ts", - "../platform/src/components/aws/cluster.ts", - "../platform/src/components/aws/cluster-v1.ts", - "../platform/src/components/aws/cognito-identity-pool.ts", - "../platform/src/components/aws/cognito-identity-provider.ts", - "../platform/src/components/aws/cognito-user-pool.ts", - "../platform/src/components/aws/cognito-user-pool-client.ts", - "../platform/src/components/aws/cron.ts", - "../platform/src/components/aws/cron-v2.ts", - "../platform/src/components/aws/dynamo.ts", - "../platform/src/components/aws/dynamo-lambda-subscriber.ts", - "../platform/src/components/aws/efs.ts", - "../platform/src/components/aws/email.ts", - "../platform/src/components/aws/function.ts", - "../platform/src/components/aws/mysql.ts", - "../platform/src/components/aws/postgres.ts", - "../platform/src/components/aws/postgres-v1.ts", - "../platform/src/components/aws/step-functions.ts", - "../platform/src/components/aws/vector.ts", - "../platform/src/components/aws/astro.ts", - "../platform/src/components/aws/nextjs.ts", - "../platform/src/components/aws/nuxt.ts", - "../platform/src/components/aws/dsql.ts", - "../platform/src/components/aws/realtime.ts", - "../platform/src/components/aws/realtime-lambda-subscriber.ts", - "../platform/src/components/aws/react.ts", - "../platform/src/components/aws/redis.ts", - "../platform/src/components/aws/redis-v1.ts", - "../platform/src/components/aws/remix.ts", - "../platform/src/components/aws/queue.ts", - "../platform/src/components/aws/queue-lambda-subscriber.ts", - "../platform/src/components/aws/kinesis-stream.ts", - "../platform/src/components/aws/kinesis-stream-lambda-subscriber.ts", - "../platform/src/components/aws/opencontrol.ts", - "../platform/src/components/aws/open-search.ts", - "../platform/src/components/aws/router.ts", - "../platform/src/components/aws/service.ts", - "../platform/src/components/aws/service-v1.ts", - "../platform/src/components/aws/sns-topic.ts", - "../platform/src/components/aws/sns-topic-lambda-subscriber.ts", - "../platform/src/components/aws/sns-topic-queue-subscriber.ts", - "../platform/src/components/aws/solid-start.ts", - "../platform/src/components/aws/static-site.ts", - "../platform/src/components/aws/svelte-kit.ts", - "../platform/src/components/aws/tan-stack-start.ts", - "../platform/src/components/aws/task.ts", - "../platform/src/components/aws/vpc.ts", - "../platform/src/components/aws/vpc-v1.ts", - "../platform/src/components/aws/workflow.ts", - "../platform/src/components/cloudflare/ai.ts", - "../platform/src/components/cloudflare/astro.ts", - "../platform/src/components/cloudflare/bucket.ts", - "../platform/src/components/cloudflare/cron.ts", - "../platform/src/components/cloudflare/d1.ts", - "../platform/src/components/cloudflare/hyperdrive.ts", - "../platform/src/components/cloudflare/kv.ts", - "../platform/src/components/cloudflare/queue.ts", - "../platform/src/components/cloudflare/queue-worker-subscriber.ts", - "../platform/src/components/cloudflare/react-router.ts", - "../platform/src/components/cloudflare/worker.ts", - "../platform/src/components/cloudflare/workflow.ts", - "../platform/src/components/cloudflare/rate-limit.ts", - "../platform/src/components/cloudflare/static-site.ts", - "../platform/src/components/cloudflare/static-site-v2.ts", - "../platform/src/components/cloudflare/tan-stack-start.ts", - // internal - "../platform/src/components/aws/alb.ts", - "../platform/src/components/aws/cdn.ts", - "../platform/src/components/aws/dns.ts", - "../platform/src/components/aws/iam-edit.ts", - "../platform/src/components/aws/permission.ts", - "../platform/src/components/aws/providers/function-environment-update.ts", - "../platform/src/components/aws/step-functions/choice.ts", - "../platform/src/components/aws/step-functions/fail.ts", - "../platform/src/components/aws/step-functions/map.ts", - "../platform/src/components/aws/step-functions/parallel.ts", - "../platform/src/components/aws/step-functions/pass.ts", - "../platform/src/components/aws/step-functions/state.ts", - "../platform/src/components/aws/step-functions/succeed.ts", - "../platform/src/components/aws/step-functions/task.ts", - "../platform/src/components/aws/step-functions/wait.ts", - "../platform/src/components/cloudflare/binding.ts", - "../platform/src/components/cloudflare/dns.ts", - "../platform/src/components/vercel/dns.ts", - ], - tsconfig: "../platform/tsconfig.json", - }); - - const project = await app.convert(); - if (!project) throw new Error("Failed to convert project"); - - // sort StepFunctions methods - (() => { - const c = project - .getChildrenByKind(TypeDoc.ReflectionKind.Module) - .find((c) => c.name === "components/aws/step-functions") - ?.getChildByName("StepFunctions") as TypeDoc.DeclarationReflection; - const taskChildren: TypeDoc.DeclarationReflection[] = []; - const otherChildren: TypeDoc.DeclarationReflection[] = []; - c.children?.forEach((c) => - c.kind === TypeDoc.ReflectionKind.Method && - [ - "task", - "choice", - "parallel", - "map", - "pass", - "succeed", - "fail", - "wait", - ].includes(c.name) - ? taskChildren.push(c) - : otherChildren.push(c) - ); - c.children = [...taskChildren, ...otherChildren]; - })(); - - // Generate JSON (generated for debugging purposes) - if (process.env.DEBUG) await app.generateJson(project, "components-doc.json"); - - return project.getChildrenByKind(TypeDoc.ReflectionKind.Module); -} - -async function buildSdk() { - // Generate project reflection - const app = await TypeDoc.Application.bootstrap({ - // Ignore type errors caused by patching `Input<>`. - skipErrorChecking: true, - // Disable parsing @default tags as ```ts block code. - jsDocCompatibility: { - defaultTag: false, - }, - entryPoints: [ - "../sdk/js/src/aws/realtime.ts", - "../sdk/js/src/aws/task.ts", - "../sdk/js/src/aws/workflow.ts", - "../sdk/js/src/vector/index.ts", - ], - tsconfig: "../sdk/js/tsconfig.json", - }); - - const project = await app.convert(); - if (!project) throw new Error("Failed to convert project"); - - // Generate JSON (generated for debugging purposes) - if (process.env.DEBUG) await app.generateJson(project, "sdk-doc.json"); - - return project.getChildrenByKind(TypeDoc.ReflectionKind.Module); -} - -async function buildExamples() { - // Generate project reflection - const app = await TypeDoc.Application.bootstrap({ - // Ignore type errors caused by patching `Input<>`. - skipErrorChecking: true, - // Disable parsing @default tags as ```ts block code. - jsDocCompatibility: { - defaultTag: false, - }, - entryPoints: ["../examples/*/sst.config.ts"], - tsconfig: "../examples/tsconfig.json", - }); - - const project = await app.convert(); - if (!project) throw new Error("Failed to convert project"); - - // Generate JSON (generated for debugging purposes) - if (process.env.DEBUG) await app.generateJson(project, "examples-doc.json"); - - return project.children!.filter( - (c) => - c.kind === TypeDoc.ReflectionKind.Module && - c.children?.length === 1 && - c.children[0].comment - ); -} diff --git a/www/input-patch.ts b/www/input-patch.ts deleted file mode 100644 index c3a141afc6..0000000000 --- a/www/input-patch.ts +++ /dev/null @@ -1 +0,0 @@ -export type Input = Array; diff --git a/www/package.json b/www/package.json index 7a9b3ef6dd..87380b2454 100644 --- a/www/package.json +++ b/www/package.json @@ -1,40 +1,45 @@ { - "name": "www", - "type": "module", - "version": "0.0.1", + "name": "@serverless-stack/docs", + "version": "2.3.4", + "private": true, "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "bun generate && astro build", - "preview": "astro preview", - "astro": "astro", - "generate": "bun generate-cli-json && bun ./generate.ts", - "generate-changelog": "bun ./generate.ts changelog", - "generate-components": "bun ./generate.ts components", - "generate-examples": "bun ./generate.ts examples", - "generate-cli": "bun generate-cli-json && bun ./generate.ts cli", - "generate-cli-json": "go run ../cmd/sst introspect > cli-doc.json" + "docusaurus": "docusaurus", + "start": "docusaurus start", + "watch": "node ./generate.mjs watch", + "build": "cd ../packages/sst && pnpm run build && cd ../../www && node ./generate.mjs build && docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "serve": "docusaurus serve", + "clear": "docusaurus clear" }, "dependencies": { - "@astro-community/astro-embed-youtube": "^0.5.3", - "@astrojs/check": "^0.9.2", - "@astrojs/markdown-remark": "^5.3.0", - "@astrojs/sitemap": "^3.1.6", - "@astrojs/starlight": "^0.34.1", - "@fontsource-variable/roboto-mono": "^5.0.17", - "@fontsource-variable/rubik": "^5.0.20", - "@fontsource/ibm-plex-mono": "^5.0.8", - "astro": "^5.7.0", - "astro-expressive-code": "^0.41.2", - "astro-sst": "^3.1.3", - "js-base64": "^3.7.6", - "rehype-autolink-headings": "^7.1.0", - "sharp": "^0.33.3", - "sst": "3.13.20" + "@docusaurus/core": "2.0.0-beta.18", + "@docusaurus/plugin-client-redirects": "2.0.0-beta.18", + "@docusaurus/plugin-google-gtag": "^2.4.1", + "@docusaurus/preset-classic": "2.0.0-beta.18", + "@jridgewell/gen-mapping": "^0.3.2", + "@mdx-js/react": "^1.6.21", + "clsx": "^1.1.1", + "js-base64": "^3.6.1", + "react": "^17.0.2", + "react-dom": "^17.0.2" + }, + "browserslist": { + "production": [ + ">0.5%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] }, "devDependencies": { - "@types/node": "^20.10.5", - "typedoc": "0.25.7", - "typescript": "5.3.3" + "constructs": "10.1.156", + "prism-react-renderer": "^2.0.5", + "typedoc": "^0.23.21", + "typescript": "^4.9.5" } } diff --git a/www/public/favicon.ico b/www/public/favicon.ico deleted file mode 100644 index 2c6490d006..0000000000 Binary files a/www/public/favicon.ico and /dev/null differ diff --git a/www/public/favicon.svg b/www/public/favicon.svg deleted file mode 100644 index b46eb7f9a2..0000000000 --- a/www/public/favicon.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/www/public/logo-square.png b/www/public/logo-square.png deleted file mode 100644 index 1aaf6abef8..0000000000 Binary files a/www/public/logo-square.png and /dev/null differ diff --git a/www/public/social-cards/blog/case-study-buildforce.png b/www/public/social-cards/blog/case-study-buildforce.png deleted file mode 100644 index 43193f67bf..0000000000 Binary files a/www/public/social-cards/blog/case-study-buildforce.png and /dev/null differ diff --git a/www/public/social-cards/blog/case-study-doorvest.png b/www/public/social-cards/blog/case-study-doorvest.png deleted file mode 100644 index 70f90a15c2..0000000000 Binary files a/www/public/social-cards/blog/case-study-doorvest.png and /dev/null differ diff --git a/www/public/social-cards/blog/case-study-henry-schein-one.png b/www/public/social-cards/blog/case-study-henry-schein-one.png deleted file mode 100644 index 868ed11656..0000000000 Binary files a/www/public/social-cards/blog/case-study-henry-schein-one.png and /dev/null differ diff --git a/www/public/social-cards/blog/case-study-leadent.png b/www/public/social-cards/blog/case-study-leadent.png deleted file mode 100644 index 735d72097a..0000000000 Binary files a/www/public/social-cards/blog/case-study-leadent.png and /dev/null differ diff --git a/www/public/social-cards/blog/is-serverless-ready.png b/www/public/social-cards/blog/is-serverless-ready.png deleted file mode 100644 index 08f2fdc031..0000000000 Binary files a/www/public/social-cards/blog/is-serverless-ready.png and /dev/null differ diff --git a/www/public/social-cards/blog/learn-sst.png b/www/public/social-cards/blog/learn-sst.png deleted file mode 100644 index b652912447..0000000000 Binary files a/www/public/social-cards/blog/learn-sst.png and /dev/null differ diff --git a/www/public/social-cards/blog/remixsite-construct.png b/www/public/social-cards/blog/remixsite-construct.png deleted file mode 100644 index 5d82c261ee..0000000000 Binary files a/www/public/social-cards/blog/remixsite-construct.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-1-0-conf-replay.png b/www/public/social-cards/blog/sst-1-0-conf-replay.png deleted file mode 100644 index 36bfa35099..0000000000 Binary files a/www/public/social-cards/blog/sst-1-0-conf-replay.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-1-0-conf.png b/www/public/social-cards/blog/sst-1-0-conf.png deleted file mode 100644 index 026265f1ff..0000000000 Binary files a/www/public/social-cards/blog/sst-1-0-conf.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-auth.png b/www/public/social-cards/blog/sst-auth.png deleted file mode 100644 index beda27fc21..0000000000 Binary files a/www/public/social-cards/blog/sst-auth.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-config.png b/www/public/social-cards/blog/sst-config.png deleted file mode 100644 index 654feb7cbf..0000000000 Binary files a/www/public/social-cards/blog/sst-config.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-job.png b/www/public/social-cards/blog/sst-job.png deleted file mode 100644 index 77dc417e5f..0000000000 Binary files a/www/public/social-cards/blog/sst-job.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-testing.png b/www/public/social-cards/blog/sst-testing.png deleted file mode 100644 index 4ce0002922..0000000000 Binary files a/www/public/social-cards/blog/sst-testing.png and /dev/null differ diff --git a/www/public/social-cards/blog/sst-v2.png b/www/public/social-cards/blog/sst-v2.png deleted file mode 100644 index 53e272704d..0000000000 Binary files a/www/public/social-cards/blog/sst-v2.png and /dev/null differ diff --git a/www/public/testimonials/marv.webp b/www/public/testimonials/marv.webp deleted file mode 100644 index c3ee077eba..0000000000 Binary files a/www/public/testimonials/marv.webp and /dev/null differ diff --git a/www/public/testimonials/rodrigo.webp b/www/public/testimonials/rodrigo.webp deleted file mode 100644 index bdce8b21a4..0000000000 Binary files a/www/public/testimonials/rodrigo.webp and /dev/null differ diff --git a/www/public/testimonials/sockthedev.webp b/www/public/testimonials/sockthedev.webp deleted file mode 100644 index d7dae9a0cd..0000000000 Binary files a/www/public/testimonials/sockthedev.webp and /dev/null differ diff --git a/www/public/testimonials/waterbear.webp b/www/public/testimonials/waterbear.webp deleted file mode 100644 index bbeb566e47..0000000000 Binary files a/www/public/testimonials/waterbear.webp and /dev/null differ diff --git a/www/public/testimonials/zac.webp b/www/public/testimonials/zac.webp deleted file mode 100644 index cccdc96118..0000000000 Binary files a/www/public/testimonials/zac.webp and /dev/null differ diff --git a/www/sidebars.js b/www/sidebars.js new file mode 100644 index 0000000000..e2a1e30292 --- /dev/null +++ b/www/sidebars.js @@ -0,0 +1,333 @@ +module.exports = { + docs: [ + { + " ": [ + "index", + "what-is-sst", + { + type: "category", + label: "Get Started", + collapsible: true, + collapsed: false, + items: [ + "start/standalone", + "start/nextjs", + "start/remix", + "start/svelte", + "start/astro", + "start/solid", + ], + }, + ], + }, + // { + // "Get Started": [ + // "start/basics", + // "start/nextjs", + // "start/astro", + // "start/vite", + // ], + // }, + // { + // Features: [ + // { + // type: "category", + // label: "Databases", + // collapsible: true, + // collapsed: true, + // link: {type: "doc", id: "databases/index"}, + // items: [ + // "databases/postgresql", + // "databases/dynamodb", + // ] + // }, + // "apis", + // "auth", + // { + // type: "category", + // label: "Jobs", + // collapsible: true, + // collapsed: true, + // link: {type: "doc", id: "jobs/index"}, + // items: [ + // "jobs/cron-jobs", + // "jobs/long-running-jobs", + // ] + // }, + // "config", + // "queues", + // "file-uploads", + // ] + // }, + { + "How-Tos": [ + "apis", + "auth", + "config", + "events", + "queues", + "cron-jobs", + "databases", + "file-uploads", + "long-running-jobs", + ], + }, + { + Info: [ + "testing", + "console", + "live-lambda-development", + "setting-up-aws", + "configuring-sst", + "custom-domains", + "design-principles", + "resource-binding", + "editor-integration", + "going-to-production", + "faq", + { + type: "category", + label: "Advanced", + collapsible: true, + collapsed: true, + items: [ + "advanced/monitoring", + "advanced/source-maps", + "known-issues", + "advanced/bootstrapping", + "advanced/extending-sst", + "upgrade-guide", + "advanced/removal-policy", + "advanced/lambda-layers", + "advanced/iam-credentials", + "advanced/tagging-resources", + "advanced/importing-resources", + "advanced/connecting-via-proxy", + "advanced/permission-boundary", + "anonymous-telemetry", + "advanced/cross-stack-references", + "working-with-your-team", + "advanced/linting-and-type-checking", + "advanced/customizing-ssm-parameters", + //"advanced/monorepo-project-structure", + "advanced/environment-specific-resources", + ], + }, + ], + }, + { + "Migrating From": [ + "migrating/cdk", + "migrating/vercel", + "migrating/serverless-framework", + ], + }, + { + CLI: ["packages/sst", "packages/create-sst"], + }, + ], + learn: [ + "learn/index", + { + type: "category", + label: "1 - Installation", + items: [ + "learn/create-a-new-project", + "learn/project-structure", + "learn/initialize-the-database", + "learn/start-the-frontend", + "learn/breakpoint-debugging", + ], + }, + { + type: "category", + label: "2 - Add a New Feature", + items: ["learn/domain-driven-design", "learn/write-to-the-database"], + }, + { + type: "category", + label: "3 - Add to the API", + items: [ + "learn/graphql-api", + "learn/add-api-types", + "learn/queries-and-mutations", + ], + }, + { + type: "category", + label: "4 - Update the Frontend", + items: ["learn/render-queries", "learn/make-updates"], + }, + { + type: "category", + label: "5 - Deployment", + items: ["learn/deploy-to-prod"], + }, + ], + constructs: [ + { + " ": ["constructs/index"], + }, + { + Core: [ + "constructs/App", + "constructs/Stack", + "constructs/Function", + { + type: "category", + label: "Config", + collapsible: true, + collapsed: true, + items: ["constructs/Secret", "constructs/Parameter"], + }, + ], + Frontend: [ + "constructs/StaticSite", + "constructs/NextjsSite", + "constructs/SvelteKitSite", + "constructs/RemixSite", + "constructs/AstroSite", + "constructs/SolidStartSite", + ], + Database: ["constructs/RDS", "constructs/Table"], + Api: [ + "constructs/Api", + "constructs/AppSyncApi", + "constructs/WebSocketApi", + ], + Async: [ + "constructs/Job", + "constructs/Cron", + "constructs/Topic", + "constructs/Queue", + "constructs/EventBus", + "constructs/KinesisStream", + ], + Storage: ["constructs/Bucket"], + Auth: ["constructs/Auth", "constructs/Cognito"], + Types: [ + "constructs/Size", + "constructs/Duration", + "constructs/Permissions", + ], + Other: [ + "constructs/Script", + "constructs/ApiGatewayV1Api", + "constructs/v1/index", + "constructs/v0/index", + ], + }, + ], + clients: [ + { + " ": ["clients/index"], + Modules: [ + "clients/api", + "clients/rds", + "clients/job", + "clients/site", + "clients/auth", + "clients/table", + "clients/topic", + "clients/config", + "clients/queue", + "clients/bucket", + "clients/graphql", + "clients/function", + "clients/event-bus", + "clients/kinesis-stream", + ], + }, + ], + constructsv1: [ + { + " ": ["constructs/v1/index"], + }, + { + Core: [ + "constructs/v1/App", + "constructs/v1/Stack", + "constructs/v1/Function", + { + type: "category", + label: "Config", + collapsible: true, + collapsed: true, + items: ["constructs/v1/Secret", "constructs/v1/Parameter"], + }, + ], + Api: [ + "constructs/v1/Api", + "constructs/v1/AppSyncApi", + "constructs/v1/WebSocketApi", + ], + Frontend: [ + "constructs/v1/StaticSite", + "constructs/v1/NextjsSite", + "constructs/v1/RemixSite", + ], + Database: ["constructs/v1/RDS", "constructs/v1/Table"], + Async: [ + "constructs/v1/Cron", + "constructs/v1/Topic", + "constructs/v1/Queue", + "constructs/v1/EventBus", + "constructs/v1/KinesisStream", + ], + Storage: ["constructs/v1/Bucket"], + Auth: ["constructs/v1/Auth", "constructs/v1/Cognito"], + Types: [ + "constructs/v1/Size", + "constructs/v1/Duration", + "constructs/v1/Permissions", + ], + Other: [ + "constructs/v1/Job", + "constructs/v1/Script", + "constructs/v1/DebugApp", + "constructs/v1/DebugStack", + "constructs/v1/GraphQLApi", + "constructs/v1/ViteStaticSite", + "constructs/v1/ReactStaticSite", + "constructs/v1/ApiGatewayV1Api", + ], + }, + ], + constructsv0: [ + { + " ": ["constructs/v0/index", "constructs/v0/migration"], + }, + { + Constructs: [ + "constructs/v0/Api", + "constructs/v0/App", + "constructs/v0/RDS", + "constructs/v0/Cron", + "constructs/v0/Auth", + "constructs/v0/Table", + "constructs/v0/Topic", + "constructs/v0/Stack", + "constructs/v0/Script", // shorter in length viewed in browser + "constructs/v0/Queue", + "constructs/v0/Bucket", + "constructs/v0/Function", + "constructs/v0/EventBus", + "constructs/v0/StaticSite", // shorter in length viewed in browser + "constructs/v0/NextjsSite", + "constructs/v0/AppSyncApi", + "constructs/v0/GraphQLApi", + "constructs/v0/ViteStaticSite", // shorter in length viewed in browser + "constructs/v0/KinesisStream", // shorter in length viewed in browser + "constructs/v0/WebSocketApi", + "constructs/v0/ReactStaticSite", + "constructs/v0/ApiGatewayV1Api", + ], + }, + { + Util: ["constructs/v0/Permissions"], + }, + { + Internals: ["constructs/v0/DebugApp", "constructs/v0/DebugStack"], + }, + ], +}; diff --git a/www/src/assets/about/sv-angel.svg b/www/src/assets/about/sv-angel.svg deleted file mode 100644 index 31c8262f5a..0000000000 --- a/www/src/assets/about/sv-angel.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/www/src/assets/about/yc.svg b/www/src/assets/about/yc.svg deleted file mode 100644 index 9884b93018..0000000000 --- a/www/src/assets/about/yc.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/blog/frontends-are-hard/cloudfront-announcement-tweet-dark.png b/www/src/assets/blog/frontends-are-hard/cloudfront-announcement-tweet-dark.png deleted file mode 100644 index 65fb178f15..0000000000 Binary files a/www/src/assets/blog/frontends-are-hard/cloudfront-announcement-tweet-dark.png and /dev/null differ diff --git a/www/src/assets/blog/frontends-are-hard/cloudfront-announcement-tweet-light.png b/www/src/assets/blog/frontends-are-hard/cloudfront-announcement-tweet-light.png deleted file mode 100644 index 2a458fe323..0000000000 Binary files a/www/src/assets/blog/frontends-are-hard/cloudfront-announcement-tweet-light.png and /dev/null differ diff --git a/www/src/assets/blog/frontends-are-hard/framework-market-map.svg b/www/src/assets/blog/frontends-are-hard/framework-market-map.svg deleted file mode 100644 index 2a360ae51f..0000000000 --- a/www/src/assets/blog/frontends-are-hard/framework-market-map.svg +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/blog/frontends-are-hard/spa-architecture-diagram.svg b/www/src/assets/blog/frontends-are-hard/spa-architecture-diagram.svg deleted file mode 100644 index 1371ef1ae1..0000000000 --- a/www/src/assets/blog/frontends-are-hard/spa-architecture-diagram.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/www/src/assets/blog/frontends-are-hard/ssr-architecture-diagram.svg b/www/src/assets/blog/frontends-are-hard/ssr-architecture-diagram.svg deleted file mode 100644 index e0b13a57f9..0000000000 --- a/www/src/assets/blog/frontends-are-hard/ssr-architecture-diagram.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/blog/is-serverless-ready.png b/www/src/assets/blog/is-serverless-ready.png deleted file mode 100644 index 08f2fdc031..0000000000 Binary files a/www/src/assets/blog/is-serverless-ready.png and /dev/null differ diff --git a/www/src/assets/blog/sst-console-container-issues.png b/www/src/assets/blog/sst-console-container-issues.png deleted file mode 100644 index b8f110ba2e..0000000000 Binary files a/www/src/assets/blog/sst-console-container-issues.png and /dev/null differ diff --git a/www/src/assets/blog/sst-console-logs-dark.png b/www/src/assets/blog/sst-console-logs-dark.png deleted file mode 100644 index 4d1fb0a51a..0000000000 Binary files a/www/src/assets/blog/sst-console-logs-dark.png and /dev/null differ diff --git a/www/src/assets/blog/sst-console-logs-light.png b/www/src/assets/blog/sst-console-logs-light.png deleted file mode 100644 index 3a03f58d24..0000000000 Binary files a/www/src/assets/blog/sst-console-logs-light.png and /dev/null differ diff --git a/www/src/assets/blog/sst-console-updates-dark.png b/www/src/assets/blog/sst-console-updates-dark.png deleted file mode 100644 index 7495a478e4..0000000000 Binary files a/www/src/assets/blog/sst-console-updates-dark.png and /dev/null differ diff --git a/www/src/assets/blog/sst-console-updates-light.png b/www/src/assets/blog/sst-console-updates-light.png deleted file mode 100644 index 6b17476f91..0000000000 Binary files a/www/src/assets/blog/sst-console-updates-light.png and /dev/null differ diff --git a/www/src/assets/blog/sst-ion-movies-demo-ai-app.png b/www/src/assets/blog/sst-ion-movies-demo-ai-app.png deleted file mode 100644 index 645e9c1957..0000000000 Binary files a/www/src/assets/blog/sst-ion-movies-demo-ai-app.png and /dev/null differ diff --git a/www/src/assets/blog/sst-pulumi-tweet.png b/www/src/assets/blog/sst-pulumi-tweet.png deleted file mode 100644 index 519f4d5b45..0000000000 Binary files a/www/src/assets/blog/sst-pulumi-tweet.png and /dev/null differ diff --git a/www/src/assets/blog/task-cli.png b/www/src/assets/blog/task-cli.png deleted file mode 100644 index 6d20438f7a..0000000000 Binary files a/www/src/assets/blog/task-cli.png and /dev/null differ diff --git a/www/src/assets/blog/task-console.png b/www/src/assets/blog/task-console.png deleted file mode 100644 index 31d493e771..0000000000 Binary files a/www/src/assets/blog/task-console.png and /dev/null differ diff --git a/www/src/assets/docs/basics/editor-autocomplete.png b/www/src/assets/docs/basics/editor-autocomplete.png deleted file mode 100644 index f021187d3e..0000000000 Binary files a/www/src/assets/docs/basics/editor-autocomplete.png and /dev/null differ diff --git a/www/src/assets/docs/basics/editor-help.png b/www/src/assets/docs/basics/editor-help.png deleted file mode 100644 index 78e6280337..0000000000 Binary files a/www/src/assets/docs/basics/editor-help.png and /dev/null differ diff --git a/www/src/assets/docs/basics/editor-typecheck.png b/www/src/assets/docs/basics/editor-typecheck.png deleted file mode 100644 index 5f5c77aa21..0000000000 Binary files a/www/src/assets/docs/basics/editor-typecheck.png and /dev/null differ diff --git a/www/src/assets/docs/basics/sst-console-autodeploy.png b/www/src/assets/docs/basics/sst-console-autodeploy.png deleted file mode 100644 index e6b8f48add..0000000000 Binary files a/www/src/assets/docs/basics/sst-console-autodeploy.png and /dev/null differ diff --git a/www/src/assets/docs/cli/sst-dev-multiplexer-mode.png b/www/src/assets/docs/cli/sst-dev-multiplexer-mode.png deleted file mode 100644 index ca3147197d..0000000000 Binary files a/www/src/assets/docs/cli/sst-dev-multiplexer-mode.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-autodeploy-dark.png b/www/src/assets/docs/console/sst-console-autodeploy-dark.png deleted file mode 100644 index e0b52e703a..0000000000 Binary files a/www/src/assets/docs/console/sst-console-autodeploy-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-autodeploy-light.png b/www/src/assets/docs/console/sst-console-autodeploy-light.png deleted file mode 100644 index c64403afcc..0000000000 Binary files a/www/src/assets/docs/console/sst-console-autodeploy-light.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-home-dark.png b/www/src/assets/docs/console/sst-console-home-dark.png deleted file mode 100644 index c8757fb5ca..0000000000 Binary files a/www/src/assets/docs/console/sst-console-home-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-home-light.png b/www/src/assets/docs/console/sst-console-home-light.png deleted file mode 100644 index 15af9eb3e1..0000000000 Binary files a/www/src/assets/docs/console/sst-console-home-light.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-issues-dark.png b/www/src/assets/docs/console/sst-console-issues-dark.png deleted file mode 100644 index 6db368f6d7..0000000000 Binary files a/www/src/assets/docs/console/sst-console-issues-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-issues-light.png b/www/src/assets/docs/console/sst-console-issues-light.png deleted file mode 100644 index 9422053470..0000000000 Binary files a/www/src/assets/docs/console/sst-console-issues-light.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-local-dark.png b/www/src/assets/docs/console/sst-console-local-dark.png deleted file mode 100644 index e70d71d759..0000000000 Binary files a/www/src/assets/docs/console/sst-console-local-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-local-light.png b/www/src/assets/docs/console/sst-console-local-light.png deleted file mode 100644 index 71029e9894..0000000000 Binary files a/www/src/assets/docs/console/sst-console-local-light.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-logs-dark.png b/www/src/assets/docs/console/sst-console-logs-dark.png deleted file mode 100644 index 4d1fb0a51a..0000000000 Binary files a/www/src/assets/docs/console/sst-console-logs-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-logs-light.png b/www/src/assets/docs/console/sst-console-logs-light.png deleted file mode 100644 index 3a03f58d24..0000000000 Binary files a/www/src/assets/docs/console/sst-console-logs-light.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-resources-dark.png b/www/src/assets/docs/console/sst-console-resources-dark.png deleted file mode 100644 index 31ed5b4756..0000000000 Binary files a/www/src/assets/docs/console/sst-console-resources-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-resources-light.png b/www/src/assets/docs/console/sst-console-resources-light.png deleted file mode 100644 index fac73ce625..0000000000 Binary files a/www/src/assets/docs/console/sst-console-resources-light.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-updates-dark.png b/www/src/assets/docs/console/sst-console-updates-dark.png deleted file mode 100644 index 7495a478e4..0000000000 Binary files a/www/src/assets/docs/console/sst-console-updates-dark.png and /dev/null differ diff --git a/www/src/assets/docs/console/sst-console-updates-light.png b/www/src/assets/docs/console/sst-console-updates-light.png deleted file mode 100644 index 6b17476f91..0000000000 Binary files a/www/src/assets/docs/console/sst-console-updates-light.png and /dev/null differ diff --git a/www/src/assets/docs/live/vs-code-enable-auto-attach.png b/www/src/assets/docs/live/vs-code-enable-auto-attach.png deleted file mode 100644 index 07d02dcf52..0000000000 Binary files a/www/src/assets/docs/live/vs-code-enable-auto-attach.png and /dev/null differ diff --git a/www/src/assets/docs/router/dev-architecture.svg b/www/src/assets/docs/router/dev-architecture.svg deleted file mode 100644 index 754ceba043..0000000000 --- a/www/src/assets/docs/router/dev-architecture.svg +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/docs/router/prod-architecture.svg b/www/src/assets/docs/router/prod-architecture.svg deleted file mode 100644 index 6b0b5fa74d..0000000000 --- a/www/src/assets/docs/router/prod-architecture.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/docs/sst-console-home.png b/www/src/assets/docs/sst-console-home.png deleted file mode 100644 index a34b09ab02..0000000000 Binary files a/www/src/assets/docs/sst-console-home.png and /dev/null differ diff --git a/www/src/assets/docs/start/email-sent-from-sst.png b/www/src/assets/docs/start/email-sent-from-sst.png deleted file mode 100644 index 6b61121bcd..0000000000 Binary files a/www/src/assets/docs/start/email-sent-from-sst.png and /dev/null differ diff --git a/www/src/assets/docs/start/initial-drizzle-studio-with-sst.png b/www/src/assets/docs/start/initial-drizzle-studio-with-sst.png deleted file mode 100644 index 76e60e5a81..0000000000 Binary files a/www/src/assets/docs/start/initial-drizzle-studio-with-sst.png and /dev/null differ diff --git a/www/src/assets/docs/start/initial-prisma-studio-with-sst.png b/www/src/assets/docs/start/initial-prisma-studio-with-sst.png deleted file mode 100644 index 85d6379712..0000000000 Binary files a/www/src/assets/docs/start/initial-prisma-studio-with-sst.png and /dev/null differ diff --git a/www/src/assets/docs/start/openauth-nextjs.png b/www/src/assets/docs/start/openauth-nextjs.png deleted file mode 100644 index bfacde2b2e..0000000000 Binary files a/www/src/assets/docs/start/openauth-nextjs.png and /dev/null differ diff --git a/www/src/assets/docs/start/sst-console-autodeploy.png b/www/src/assets/docs/start/sst-console-autodeploy.png deleted file mode 100644 index e6b8f48add..0000000000 Binary files a/www/src/assets/docs/start/sst-console-autodeploy.png and /dev/null differ diff --git a/www/src/assets/docs/start/sst-realtime-nextjs-app.png b/www/src/assets/docs/start/sst-realtime-nextjs-app.png deleted file mode 100644 index a421c5f4d7..0000000000 Binary files a/www/src/assets/docs/start/sst-realtime-nextjs-app.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-astro-local-container.png b/www/src/assets/docs/start/start-astro-local-container.png deleted file mode 100644 index d376327e05..0000000000 Binary files a/www/src/assets/docs/start/start-astro-local-container.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-astro-local.png b/www/src/assets/docs/start/start-astro-local.png deleted file mode 100644 index d376327e05..0000000000 Binary files a/www/src/assets/docs/start/start-astro-local.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-bun-app-file-upload.png b/www/src/assets/docs/start/start-bun-app-file-upload.png deleted file mode 100644 index a06d855e18..0000000000 Binary files a/www/src/assets/docs/start/start-bun-app-file-upload.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-nextjs-local-container.png b/www/src/assets/docs/start/start-nextjs-local-container.png deleted file mode 100644 index 040a023bb7..0000000000 Binary files a/www/src/assets/docs/start/start-nextjs-local-container.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-nextjs-local.png b/www/src/assets/docs/start/start-nextjs-local.png deleted file mode 100644 index 040a023bb7..0000000000 Binary files a/www/src/assets/docs/start/start-nextjs-local.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-nuxt-container.png b/www/src/assets/docs/start/start-nuxt-container.png deleted file mode 100644 index 66ba6944ba..0000000000 Binary files a/www/src/assets/docs/start/start-nuxt-container.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-nuxt.png b/www/src/assets/docs/start/start-nuxt.png deleted file mode 100644 index a1628e425a..0000000000 Binary files a/www/src/assets/docs/start/start-nuxt.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-react-router-start-local.png b/www/src/assets/docs/start/start-react-router-start-local.png deleted file mode 100644 index e5227db762..0000000000 Binary files a/www/src/assets/docs/start/start-react-router-start-local.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-remix-local-container.png b/www/src/assets/docs/start/start-remix-local-container.png deleted file mode 100644 index fe6a2803c6..0000000000 Binary files a/www/src/assets/docs/start/start-remix-local-container.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-remix-local.png b/www/src/assets/docs/start/start-remix-local.png deleted file mode 100644 index fe6a2803c6..0000000000 Binary files a/www/src/assets/docs/start/start-remix-local.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-solidstart-container.png b/www/src/assets/docs/start/start-solidstart-container.png deleted file mode 100644 index dff4d2f58a..0000000000 Binary files a/www/src/assets/docs/start/start-solidstart-container.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-solidstart.png b/www/src/assets/docs/start/start-solidstart.png deleted file mode 100644 index 8b5cc2c573..0000000000 Binary files a/www/src/assets/docs/start/start-solidstart.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-svelte-kit-local-container.png b/www/src/assets/docs/start/start-svelte-kit-local-container.png deleted file mode 100644 index 2bc5e04a37..0000000000 Binary files a/www/src/assets/docs/start/start-svelte-kit-local-container.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-svelte-kit-local.png b/www/src/assets/docs/start/start-svelte-kit-local.png deleted file mode 100644 index 2bc5e04a37..0000000000 Binary files a/www/src/assets/docs/start/start-svelte-kit-local.png and /dev/null differ diff --git a/www/src/assets/docs/start/start-tanstack-start-local.png b/www/src/assets/docs/start/start-tanstack-start-local.png deleted file mode 100644 index 7bf73aa8bb..0000000000 Binary files a/www/src/assets/docs/start/start-tanstack-start-local.png and /dev/null differ diff --git a/www/src/assets/docs/start/todo-created-with-drizzle-in-sst.png b/www/src/assets/docs/start/todo-created-with-drizzle-in-sst.png deleted file mode 100644 index 07692eeba1..0000000000 Binary files a/www/src/assets/docs/start/todo-created-with-drizzle-in-sst.png and /dev/null differ diff --git a/www/src/assets/docs/start/user-created-with-prisma-in-sst.png b/www/src/assets/docs/start/user-created-with-prisma-in-sst.png deleted file mode 100644 index ad298f7968..0000000000 Binary files a/www/src/assets/docs/start/user-created-with-prisma-in-sst.png and /dev/null differ diff --git a/www/src/assets/docs/start/verify-your-email-with-sst.png b/www/src/assets/docs/start/verify-your-email-with-sst.png deleted file mode 100644 index d78ef5356f..0000000000 Binary files a/www/src/assets/docs/start/verify-your-email-with-sst.png and /dev/null differ diff --git a/www/src/assets/lander/amazon.svg b/www/src/assets/lander/amazon.svg deleted file mode 100644 index 42d6594329..0000000000 --- a/www/src/assets/lander/amazon.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/lander/analog-devices.svg b/www/src/assets/lander/analog-devices.svg deleted file mode 100644 index 09408b0acf..0000000000 --- a/www/src/assets/lander/analog-devices.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/www/src/assets/lander/check.svg b/www/src/assets/lander/check.svg deleted file mode 100644 index 82b6fb75e4..0000000000 --- a/www/src/assets/lander/check.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/www/src/assets/lander/comcast.svg b/www/src/assets/lander/comcast.svg deleted file mode 100644 index 7c1b07f64f..0000000000 --- a/www/src/assets/lander/comcast.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/src/assets/lander/copy.svg b/www/src/assets/lander/copy.svg deleted file mode 100644 index 6721ece188..0000000000 --- a/www/src/assets/lander/copy.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/www/src/assets/lander/hbo.svg b/www/src/assets/lander/hbo.svg deleted file mode 100644 index 46d031dc22..0000000000 --- a/www/src/assets/lander/hbo.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/www/src/assets/lander/shell.svg b/www/src/assets/lander/shell.svg deleted file mode 100644 index 76b765a683..0000000000 --- a/www/src/assets/lander/shell.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/www/src/assets/logo-dark.svg b/www/src/assets/logo-dark.svg deleted file mode 100644 index a6a29424f4..0000000000 --- a/www/src/assets/logo-dark.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/www/src/assets/logo-light.svg b/www/src/assets/logo-light.svg deleted file mode 100644 index 7212c0f779..0000000000 --- a/www/src/assets/logo-light.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/www/src/components/About.astro b/www/src/components/About.astro deleted file mode 100644 index 1804819be8..0000000000 --- a/www/src/components/About.astro +++ /dev/null @@ -1,152 +0,0 @@ ---- -import yc from "../assets/about/yc.svg?raw"; -import sv from "../assets/about/sv-angel.svg?raw"; - -import config from "../../config.ts"; ---- -
    -
    -

    Launched in 2021 with the goal of helping developers build applications that scale from idea to IPO.

    -
    -

    Our team also works on opencode, an open-source AI coding agent; OpenNext, a community effort to maintain open-source Next.js adapters; and OpenAuth, an open-source standards-based auth provider.

    -
    -
    -
    -

    We are lucky to have some of the greatest investors of Silicon Valley on our side.

    -
    - - -
    - -
    - -
    -
    - - diff --git a/www/src/components/ChangeText.js b/www/src/components/ChangeText.js new file mode 100644 index 0000000000..8637e958f6 --- /dev/null +++ b/www/src/components/ChangeText.js @@ -0,0 +1,6 @@ +import React from "react"; +import styles from "./ChangeText.module.css"; + +export default function ChangeText(props) { + return
    {props.children}
    ; +} diff --git a/www/src/components/ChangeText.module.css b/www/src/components/ChangeText.module.css new file mode 100644 index 0000000000..b9d988026c --- /dev/null +++ b/www/src/components/ChangeText.module.css @@ -0,0 +1,15 @@ +.text :global p { + position: relative; + padding-left: 24px; +} +.text :global p::before { + left: 0; + top: 6px; + content: ""; + width: 18px; + height: 18px; + position: absolute; + background-size: 18px 18px; + background-repeat: no-repeat; + background-image: url("/img/components/keyboard.svg"); +} diff --git a/www/src/components/Changelog.astro b/www/src/components/Changelog.astro deleted file mode 100644 index 1911b8f9ce..0000000000 --- a/www/src/components/Changelog.astro +++ /dev/null @@ -1,152 +0,0 @@ ---- -import { createMarkdownProcessor } from "@astrojs/markdown-remark"; -import data from "../data/changelog.json"; - -type Entry = { - tag: string; - publishedAt: string; - url: string; - body: string; -}; - -const entries = data as Entry[]; - -const processor = await createMarkdownProcessor(); - -const dateFormatter = new Intl.DateTimeFormat("en-US", { - year: "numeric", - month: "long", - day: "numeric", -}); - -function formatTag(tag: string): string { - return tag.replace(/^v/, ""); -} - -const rendered = await Promise.all( - entries.map(async (entry) => { - const html = entry.body - ? (await processor.render(entry.body)).code - : ""; - return { - ...entry, - html, - label: formatTag(entry.tag), - anchor: formatTag(entry.tag), - formattedDate: dateFormatter.format(new Date(entry.publishedAt)), - }; - }), -); - -const releases = rendered.map((entry, index) => ({ - ...entry, - showDate: entry.formattedDate !== rendered[index - 1]?.formattedDate, -})); ---- - -
      - {releases.map((entry) => ( -
    • -
      -

      - {entry.label} -

      - -
      -
      - {entry.html - ? - :

      No release notes.

      - } -
      -
    • - ))} -
    - - diff --git a/www/src/components/Footer.astro b/www/src/components/Footer.astro deleted file mode 100644 index 84d6c7d82f..0000000000 --- a/www/src/components/Footer.astro +++ /dev/null @@ -1,247 +0,0 @@ ---- -import userConfig from 'virtual:starlight/user-config'; -import type { Props } from '@astrojs/starlight/props'; -import { Icon } from '@astrojs/starlight/components'; -import config from '../../config'; - -const slug = Astro.url.pathname.replace(/^\//, "").replace(/\/$/, ""); -const editLink = userConfig.editLink.baseUrl; - -const { - lang, - lastUpdated, - entry: { - data: { template }, - }, -} = Astro.locals.starlightRoute; - -let editUrl = Astro.locals.starlightRoute.editUrl; - -// Change path for component source files -if (slug.startsWith("docs/component/")) { - editUrl = new URL( - `platform/src/components/${slug.replace("docs/component/", "")}.ts`, editLink - ); -} -// Change path for reference source files -else if (slug === "docs/reference/config") { - editUrl = new URL("platform/src/config.ts", editLink); -} -else if (slug === "docs/reference/global") { - editUrl = new URL("platform/src/global.d.ts", editLink); -} -else if (slug === "docs/reference/cli") { - editUrl = new URL("cmd/sst/main.go", editLink); -} -else if (slug === "docs/examples") { - editUrl = new URL("examples", editLink); -} ---- - -{ - template === "doc" && ( - - ) -} -{ - template === "splash" && ( - - ) -} - - diff --git a/www/src/components/Head.astro b/www/src/components/Head.astro deleted file mode 100644 index 3e6ca71e53..0000000000 --- a/www/src/components/Head.astro +++ /dev/null @@ -1,50 +0,0 @@ ---- -import { Base64 } from "js-base64"; -import type { Props } from '@astrojs/starlight/props' -import Default from '@astrojs/starlight/components/Head.astro' -import config from '../../config'; - -const slug = Astro.url.pathname.replace(/^\//, "").replace(/\/$/, ""); -const { - cover, - entry: { - data: { title }, - }, -} = Astro.locals.starlightRoute; - -const encodedTitle = encodeURIComponent( - Base64.encode( - // Convert to ASCII - encodeURIComponent( - // Truncate to fit S3's max key size - slug === "" || slug === "404" - ? config.tagline - : title.substring(0, 700) - ) - ) -); - -const ogImageUrl = cover - ? `${import.meta.env.SITE}${cover}` - // Get the URL of the generated image for the current page using its - // ID and replace the file extension with `.png`. - : slug.startsWith("docs") - ? `${config.socialCard}/v3-docs/${encodedTitle}.png` - : slug.startsWith("blog/") - ? `${config.socialCard}/v3-blog/${encodedTitle}.png` - : `${config.socialCard}/v3-lander/${encodedTitle}.png`; ---- - -{ slug === "" && ( - {title} -)} - - - - - - diff --git a/www/src/components/Header.astro b/www/src/components/Header.astro deleted file mode 100644 index 516a18e3fe..0000000000 --- a/www/src/components/Header.astro +++ /dev/null @@ -1,185 +0,0 @@ ---- -import type { Props } from '@astrojs/starlight/props'; - -import { Icon } from '@astrojs/starlight/components'; -import Search from "@astrojs/starlight/components/Search.astro"; -import SiteTitle from "@astrojs/starlight/components/SiteTitle.astro"; - -import config from '../../config'; - -import HeaderLinks from "./HeaderLinks.astro"; ---- - -
    -
    - -
    -
    -
    - -
    -
    - -
    - - diff --git a/www/src/components/HeaderLinks.astro b/www/src/components/HeaderLinks.astro deleted file mode 100644 index e4e115ea7a..0000000000 --- a/www/src/components/HeaderLinks.astro +++ /dev/null @@ -1,21 +0,0 @@ -Blog -Docs -Examples - - diff --git a/www/src/components/HeadlineText.js b/www/src/components/HeadlineText.js new file mode 100644 index 0000000000..641a6bf95e --- /dev/null +++ b/www/src/components/HeadlineText.js @@ -0,0 +1,6 @@ +import React from "react"; +import styles from "./HeadlineText.module.css"; + +export default function HeadlineText(props) { + return
    {props.children}
    ; +} diff --git a/www/src/components/HeadlineText.module.css b/www/src/components/HeadlineText.module.css new file mode 100644 index 0000000000..326195d433 --- /dev/null +++ b/www/src/components/HeadlineText.module.css @@ -0,0 +1,4 @@ +.text { + font-size: 130%; + line-height: 1.5; +} diff --git a/www/src/components/Hero.astro b/www/src/components/Hero.astro deleted file mode 100644 index 055c693f7a..0000000000 --- a/www/src/components/Hero.astro +++ /dev/null @@ -1,15 +0,0 @@ ---- -import Lander from './Lander.astro'; -import Default from '@astrojs/starlight/components/Hero.astro'; - -const slug = Astro.url.pathname.replace(/^\//, "").replace(/\/$/, ""); -const isLander = slug === ""; -const isAboutPage = slug === "about"; ---- - -{ isLander - ? - : isAboutPage - ? null - : -} diff --git a/www/src/components/Lander.astro b/www/src/components/Lander.astro deleted file mode 100644 index fab8af8a88..0000000000 --- a/www/src/components/Lander.astro +++ /dev/null @@ -1,465 +0,0 @@ ---- -import type { Props } from '@astrojs/starlight/props'; -import { Code } from 'astro-expressive-code/components'; -import { Icon } from '@astrojs/starlight/components'; -import config from '../../config'; - -import copy from "../assets/lander/copy.svg?raw"; -import check from "../assets/lander/check.svg?raw"; -import logoHbo from "../assets/lander/hbo.svg?raw"; -import logoShell from "../assets/lander/shell.svg?raw"; -import logoAmazon from "../assets/lander/amazon.svg?raw"; -import logoComcast from "../assets/lander/comcast.svg?raw"; -import logoAnalogDevices from "../assets/lander/analog-devices.svg?raw"; - -const download = config.npm; - -const code = ` -const db = new planetscale.Database("Db") - -const email = new sst.aws.Email("Email", { - sender: "mail@example.com" -}) - -const api = new sst.aws.Service("Api", { - memory: "4 GB", - image: "./rails", - link: [db, email] -}) - -const web = new sst.aws.Nextjs("Web", { - link: [api], - path: "./nextjs", - domain: "example.com", - dns: sst.cloudflare.dns() -}) -`; ---- -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -

    {config.tagline}

    -

    Deploy everything your app needs with a single config.

    -
    -
    - -
    -
    - - -
    -

    Loved by thousands of teams

    -
    - - - - - -
    -
    -
    -
    -
    -
    -
    - - - - - diff --git a/www/src/components/MobileMenuFooter.astro b/www/src/components/MobileMenuFooter.astro deleted file mode 100644 index b128627d5a..0000000000 --- a/www/src/components/MobileMenuFooter.astro +++ /dev/null @@ -1,46 +0,0 @@ ---- -import type { Props } from '@astrojs/starlight/props'; - -import SocialIcons from "@astrojs/starlight/components/SocialIcons.astro"; -import ThemeSelect from "@astrojs/starlight/components/ThemeSelect.astro"; - -import HeaderLinks from "./HeaderLinks.astro"; ---- - - -
    - - -
    - - - diff --git a/www/src/components/MultiApiCode.js b/www/src/components/MultiApiCode.js new file mode 100644 index 0000000000..2591f1b25f --- /dev/null +++ b/www/src/components/MultiApiCode.js @@ -0,0 +1,18 @@ +import React from "react"; +import Tabs from "@theme/Tabs"; + +export default function MultiApiCode(props) { + return ( + + {props.children} + + ); +} diff --git a/www/src/components/MultiLanguageCode.js b/www/src/components/MultiLanguageCode.js new file mode 100644 index 0000000000..e68de88805 --- /dev/null +++ b/www/src/components/MultiLanguageCode.js @@ -0,0 +1,17 @@ +import React from "react"; +import Tabs from "@theme/Tabs"; + +export default function MultiLanguageCode(props) { + return ( + + {props.children} + + ); +} diff --git a/www/src/components/MultiPackagerCode.js b/www/src/components/MultiPackagerCode.js new file mode 100644 index 0000000000..f867e440fd --- /dev/null +++ b/www/src/components/MultiPackagerCode.js @@ -0,0 +1,18 @@ +import React from "react"; +import Tabs from "@theme/Tabs"; + +export default function MultiPackagerCode(props) { + return ( + + {props.children} + + ); +} diff --git a/www/src/components/MultiSiteCode.js b/www/src/components/MultiSiteCode.js new file mode 100644 index 0000000000..4ac51e910c --- /dev/null +++ b/www/src/components/MultiSiteCode.js @@ -0,0 +1,17 @@ +import React from "react"; +import Tabs from "@theme/Tabs"; + +export default function MultiSiteCode(props) { + return ( + + {props.children} + + ); +} diff --git a/www/src/components/PageSidebar.astro b/www/src/components/PageSidebar.astro deleted file mode 100644 index 7ebfe3ec24..0000000000 --- a/www/src/components/PageSidebar.astro +++ /dev/null @@ -1,48 +0,0 @@ ---- -import Default from "@astrojs/starlight/components/PageSidebar.astro"; -import changelog from "../data/changelog.json"; - -type Release = { - tag: string; -}; - -function isMinorOrMajor(tag: string): boolean { - return /^v\d+\.\d+\.0$/.test(tag); -} - -function formatTag(tag: string): string { - return tag.replace(/^v/, ""); -} - -const slug = Astro.url.pathname.replace(/^\//, "").replace(/\/$/, ""); -const route = Astro.locals.starlightRoute; -const isChangelog = slug === "docs/changelog"; - -if (isChangelog && route.toc) { - route.toc = { - ...route.toc, - items: (changelog as Release[]) - .filter((release) => isMinorOrMajor(release.tag)) - .map((release) => ({ - depth: 2, - slug: formatTag(release.tag), - text: formatTag(release.tag), - children: [], - })), - }; -} ---- - -
    - -
    - - diff --git a/www/src/components/PageTitle.astro b/www/src/components/PageTitle.astro deleted file mode 100644 index ba71fa2f5f..0000000000 --- a/www/src/components/PageTitle.astro +++ /dev/null @@ -1,90 +0,0 @@ ---- -import type { Props } from '@astrojs/starlight/props'; -import config from '../../config.ts'; - -const options = { - year: 'numeric', - month: 'long', - day: 'numeric' -}; - -const { - description, - lastUpdated, - entry: { - data: { title, author }, - }, -} = Astro.locals.starlightRoute; -const slug = Astro.url.pathname.replace(/^\//, "").replace(/\/$/, ""); - -const isBlogPost = slug.startsWith('blog/'); ---- - -{ isBlogPost - ? - Blog -

    {title}

    -
    - - {config.authors[author].name} - - - { lastUpdated - ? lastUpdated.toLocaleDateString('en-US', options) - : "1971-01-01" - } - -
    -
    - : -

    {title}

    - { description &&

    {description}

    } -
    -} - - diff --git a/www/src/components/PostList.astro b/www/src/components/PostList.astro deleted file mode 100644 index fa85af4fdc..0000000000 --- a/www/src/components/PostList.astro +++ /dev/null @@ -1,77 +0,0 @@ ---- -import { getCollection } from 'astro:content'; -import config from '../../config.ts'; - -const options = { - year: 'numeric', - month: 'long', - day: 'numeric' -}; - -const blog = (await getCollection('docs', ({ data, slug }) => { - return slug.startsWith('blog/') && data.draft !== true; -})).sort( - (a, b) => a.data.lastUpdated && b.data.lastUpdated - ? b.data.lastUpdated.getTime() - a.data.lastUpdated.getTime() - : 0 -); ---- - - - - diff --git a/www/src/components/TestimonialWall.astro b/www/src/components/TestimonialWall.astro deleted file mode 100644 index bf0d9cae1c..0000000000 --- a/www/src/components/TestimonialWall.astro +++ /dev/null @@ -1,103 +0,0 @@ ---- -interface Testimonial { - name: string; - avatar: string; - text: string; - url?: string; -} - -interface Props { - testimonials: Testimonial[]; -} - -const { testimonials } = Astro.props; ---- - -
    - {testimonials.map((t) => { - const Tag = t.url ? 'a' : 'div'; - return ( - -

    {t.text}

    -
    - {t.name} - {t.name} -
    -
    - ); - })} -
    - - diff --git a/www/src/components/VideoAside.astro b/www/src/components/VideoAside.astro deleted file mode 100644 index 1471cec238..0000000000 --- a/www/src/components/VideoAside.astro +++ /dev/null @@ -1,20 +0,0 @@ ---- -import { Icon } from '@astrojs/starlight/components'; - -interface Props { - title?: string; - href: string; -} - -const { title = 'Watch a video', href } = Astro.props; ---- - - diff --git a/www/src/components/tsdoc/InlineSection.astro b/www/src/components/tsdoc/InlineSection.astro deleted file mode 100644 index 64ef7114ee..0000000000 --- a/www/src/components/tsdoc/InlineSection.astro +++ /dev/null @@ -1 +0,0 @@ -
    diff --git a/www/src/components/tsdoc/NestedTitle.astro b/www/src/components/tsdoc/NestedTitle.astro deleted file mode 100644 index d62a5d6fec..0000000000 --- a/www/src/components/tsdoc/NestedTitle.astro +++ /dev/null @@ -1,6 +0,0 @@ ---- -const { id, Tag, parent } = Astro.props; ---- - - {parent} - diff --git a/www/src/components/tsdoc/Section.astro b/www/src/components/tsdoc/Section.astro deleted file mode 100644 index 1c8981571b..0000000000 --- a/www/src/components/tsdoc/Section.astro +++ /dev/null @@ -1,8 +0,0 @@ ---- -interface Props { - type: "about" | "signature" | "parameters"; -} - -const { type } = Astro.props; ---- -
    diff --git a/www/src/components/tsdoc/Segment.astro b/www/src/components/tsdoc/Segment.astro deleted file mode 100644 index 99a4aa924b..0000000000 --- a/www/src/components/tsdoc/Segment.astro +++ /dev/null @@ -1,2 +0,0 @@ -
    - diff --git a/www/src/content/config.ts b/www/src/content/config.ts deleted file mode 100644 index 2a95722352..0000000000 --- a/www/src/content/config.ts +++ /dev/null @@ -1,28 +0,0 @@ -import config from "../../config.ts"; -import { z, getCollection, defineCollection } from "astro:content"; -import { docsSchema, i18nSchema } from "@astrojs/starlight/schema"; - -const authors = Object.keys(config.authors) as [string, ...string[]]; - -export const collections = { - docs: defineCollection({ - schema: docsSchema({ - extend: z.object({ - cover: z.string().optional(), - pagefind: z.boolean().optional(), - template: z.enum(["doc", "splash"]).optional(), - author: z.enum(authors as [string, ...string[]]).optional(), - }) - .refine((data) => { - if (data.template === "splash") { - return data.pagefind === false; - } - return true; - }, { - message: "pagefind must be false when template is 'splash'", - path: ['pagefind'], - }), - }) - }), - //i18n: defineCollection({ type: "data", schema: i18nSchema() }), -}; diff --git a/www/src/content/docs/404.mdx b/www/src/content/docs/404.mdx deleted file mode 100644 index 8335419d54..0000000000 --- a/www/src/content/docs/404.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: '404' -template: splash -pagefind: false -hero: - title: '404' - tagline: Page not found. Check the URL and try again. ---- diff --git a/www/src/content/docs/about.mdx b/www/src/content/docs/about.mdx deleted file mode 100644 index 1cd4db9075..0000000000 --- a/www/src/content/docs/about.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: About -template: splash -description: Learn about the team behind SST. -pagefind: false -hero: - title: "n/a" ---- - -import About from "../../components/About.astro"; - - diff --git a/www/src/content/docs/blog/announcing-sst-1-0-conf.mdx b/www/src/content/docs/blog/announcing-sst-1-0-conf.mdx deleted file mode 100644 index d20bb524c3..0000000000 --- a/www/src/content/docs/blog/announcing-sst-1-0-conf.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Announcing SST 1.0 Conf -description: The first-ever SST conference! -author: jay -template: splash -image: /social-cards/blog/sst-1-0-conf.png -lastUpdated: 2022-05-05 -pagefind: false ---- - -You might’ve [heard about our v1 release](https://github.com/sst/sst/releases/tag/v1.0.0-beta.26). As SST enters into a new phase, we wanted to do something special for our community. We are putting together a virtual community event to commemorate the launch! - -[**SST 1.0 Conf**](https://v1conf.sst.dev) is a free virtual event happening on May 17th, 2022 at 9am PDT. [Register for the conference now](https://v1conf.sst.dev). - -It’ll feature talks from the SST community about how they are using SST and serverless in their projects. Including folks from **Comcast**, **The LEGO Group**, **Analog Devices**, and **Shell**. We’ll also have a couple of live demos and workshops from the SST team. - -We know you are all very busy and we don’t want to take up your entire day. So we decided to make the talks really short, around 10 minutes each. We hope you’ll be able to join us. - -While most of the schedule has been finalized, we are looking for a couple more speakers. If you’d like to share something with the community, [fill out this short form](https://forms.gle/KTdbCLUy5oNwos2m7) and we’ll get in touch with you! - -We want to use this event as a way to bring our community together. To share what we’ve all learnt over the last year of using SST. - -## Next Steps - -- Head over to the [SST 1.0 Conf](https://v1conf.sst.dev) site and register. -- Join the SST Slack (if you haven’t done so already). -- Share on Twitter or LinkedIn that you’ll be joining [SST 1.0 Conf](https://v1conf.sst.dev). - -_Psst!_ Check out the domain [the conference website](https://v1conf.sst.dev) is hosted on. It might be a sign of things to come! diff --git a/www/src/content/docs/blog/aurora-serverless-in-v3.mdx b/www/src/content/docs/blog/aurora-serverless-in-v3.mdx deleted file mode 100644 index f5a0228342..0000000000 --- a/www/src/content/docs/blog/aurora-serverless-in-v3.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -template: splash -title: Aurora Serverless in v3 -description: We are adding a new component for Amazon Aurora Serverless v2. -author: jay -lastUpdated: 2025-01-05 -pagefind: false ---- - -import { Image } from 'astro:assets'; -import { YouTube } from '@astro-community/astro-embed-youtube'; - -We are adding [`Aurora`](/docs/component/aws/aurora), a new component for [Amazon Aurora Serverless v2](https://aws.amazon.com/rds/aurora/serverless/). Recently, AWS announced that Aurora Serverless v2 can [scale to 0](https://aws.amazon.com/blogs/database/introducing-scaling-to-0-capacity-with-amazon-aurora-serverless-v2/) and auto-pause. This is good for dev or PR stages. - -There are some differences between this and the [`Postgres`](/docs/component/aws/postgres) RDS component. We talk about it here in this video. - - - ---- - -## Getting started - -To get started, you can add the `Aurora` component to your app. - -```ts title="sst.config.ts" -const vpc = new sst.aws.Vpc("MyVpc"); - -const database = new sst.aws.Aurora("MyDatabase", { - engine: "postgres", - vpc -}); -``` - -Read more about the [`Aurora`](/docs/component/aws/aurora) component. - ---- - -#### Scaling - -By default, this has a `min` of 0 ACUs and a `max` of 4 ACUs. - -An ACU or Aurora Capacity Unit is roughly equivalent to 2 GB of memory. So pick the minimum and maximum based on the baseline and peak memory usage of your app. - -```ts title="sst.config.ts" {3-6} -new sst.aws.Aurora("MyDatabase", { - engine: "postgres", - scaling: { - min: "2 ACU", - max: "128 ACU" - }, - vpc -}); -``` - -If you set a min of 0 ACUs, the database will be paused when there are no active connections in the `pauseAfter` specified time period. - -Read more about the [`scaling`](/docs/component/aws/aurora#scaling) config. - ---- - -#### Dev mode - -Aside from scaling to 0, you can also configure the `Aurora` component to not deploy the database in `sst dev`. Instead it can link to your locally running database, if you enable the `dev` prop. - -```ts title="sst.config.ts" {3-9} -new sst.aws.Aurora("MyDatabase", { - engine: "postgres", - dev: { - username: "postgres", - password: "password", - database: "local", - host: "localhost", - port: 5432 - }, - vpc -}); -``` - -Read more about the [`dev`](/docs/component/aws/aurora#dev) config. - ---- - -## Cost - -Each ACU costs $0.12 per hour for both `postgres` and `mysql` engine. The storage costs $0.01 per GB per month for standard storage. - -So if your database is constantly using 1GB of memory or 0.5 ACUs, then you are charged $0.12 x 0.5 x 24 x 30 or **$43 per month**. And add the storage costs to this as well. - -If your database scales to 0 ACUs and is auto-paused, you are not charged for the ACUs. - -Read more about the [cost of using Aurora](/docs/component/aws/aurora#cost). - ---- - -## Examples - -We also have a few examples that you can check out. - -- [Aurora Postgres](/docs/examples/#aws-aurora-postgres) -- [Aurora MySQL](/docs/examples/#aws-aurora-mysql) -- [Aurora local](/docs/examples/#aws-aurora-local) diff --git a/www/src/content/docs/blog/auth.mdx b/www/src/content/docs/blog/auth.mdx deleted file mode 100644 index 48a0103a74..0000000000 --- a/www/src/content/docs/blog/auth.mdx +++ /dev/null @@ -1,64 +0,0 @@ ---- -template: splash -title: Auth -description: We are launching a modern lightweight authentication library for your SST apps. -author: jay -pagefind: false -image: /social-cards/blog/sst-auth.png -lastUpdated: 2022-09-01 ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -Today we are launching `Auth` β€” a modern lightweight authentication library for your SST apps. - -With a simple set of configuration, it'll create a function that'll handle various authentication flows. You can then attach this function to your API and SST will help you manage the session tokens. - -`Auth` is completely stateless, standards based, and free to use. - -You can read more about it over on our docs. - -## Overview - -`Auth` is made up of the following pieces: - -1. `Auth` β€” a construct that creates the necessary infrastructure. - - - The API routes to handle the authentication flows. - - Securely generates a RSA public/private keypair to sign sessions. - - Stores the RSA keypair as secrets in the app's `Config`. - -2. `AuthHandler` β€” a Lambda handler function that can handle authentication flows for various providers. - - - High level adapters for common providers like Google, GitHub, Twitch, etc. - - OIDC and OAuth adapters that work with any compatible service. - - A `LinkAdapter` to generate login links that can be sent over email or SMS. - - Can be extended with custom adapters to support more complex workflows, like multi-tenant SSO. - -3. Session β€” a library for issuing and validating authentication sessions in your Lambda function code. - - - Implemented with stateless JWT tokens that are signed with the RSA keypairs mentioned above. - - Support for passing tokens to the frontend via a cookie or the query string. - - Full typesafety for issuing and validating sessions with the `useSession` hook. - -## Launch event - -We hosted a [launch livestream on YouTube](https://www.youtube.com/watch?v=cO9Chk6sUW4) where we did a demo and a deep dive into the internals. - - - -The video is timestamped and here's roughly what we covered. - -1. Intro -2. What is Auth? -3. Setting up the construct -4. Configuring the AuthHandler function -5. Magic link adapter -6. Issuing a session -7. Validating a session -8. Behind the scenes -9. Outro - -## Get started - -Follow the **Setup** section in our docs to get started. diff --git a/www/src/content/docs/blog/buildforce-is-creating-the-first-ever-career-platform-for-the-construction-trade-with-sst.mdx b/www/src/content/docs/blog/buildforce-is-creating-the-first-ever-career-platform-for-the-construction-trade-with-sst.mdx deleted file mode 100644 index 962b42fcbc..0000000000 --- a/www/src/content/docs/blog/buildforce-is-creating-the-first-ever-career-platform-for-the-construction-trade-with-sst.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: Buildforce & SST -description: We are talking to Michael Orcutt, the founder of Buildforce about their experience building with SST and Seed. -pagefind: false -author: jay -template: splash -image: /social-cards/blog/case-study-buildforce.png -lastUpdated: 2021-10-28 ---- - -We are talking to Michael Orcutt, a co-founder of [Buildforce](https://buildforce.com) about their experience building with [SST](/) and [Seed](https://seed.run). - -### About Buildforce - -[Buildforce](https://buildforce.com) is building the first ever career platform for people in the construction trades, starting with those in the electrical trade. Its end-to-end platform enables people in the construction trades to maintain consistent work at fair pay and with employee benefits with our construction partners, an arrangement that is out of reach for many in the construction industry today. - -Since their launch in 2020, Buildforce has become the go-to partner helping dozens of the largest contractors across its focus geographies connect with this workforce. - -Buildforce currently operates in the state of Texas, has raised $5.5M to date, and is growing 10% week over week in 2021. Michael Orcutt is one of the founders of the company and is leading the engineering efforts. He is also highly involved in product and design as they build their web apps, mobile apps, and marketing site. - -### The Challenge - -The Buildforce team knew they wanted to build their applications using serverless due to the inherent benefits. They originally started out with Serverless Framework. But over time Serverless Framework became a headache. Everything from the deployment process to testing was cumbersome. _"We felt we were slow, velocity was down as the speed of development wasn't great"_, says Michael. _"We also found creating infrastructure in YAML challenging"_. They realized this just wouldn't work as they scaled the team. - -### Enter SST - -Around 2 months ago the team came together and decided they needed to make a change. They had heard about [SST](/) and the SST Guide. They decided they needed to take a deeper look. - -As they tried out SST, _"We were blown away by the local development environment"_, says Michael. The entire team decided to move to SST. - -> "We were blown away by the local development environment." - -They decided to start a new SST app from scratch. They spent some time testing SST and within a month they had moved over completely. The new setup Michael says is _"Such a great experience. We are at least 1.5 to 2 times faster than before"_. - -> "We are at least 1.5 to 2 times faster than before." - -They also use [Seed](https://seed.run) for their deployment workflow. They typically branch from main, work locally, push to a feature branch. The feature branches get deployed through [Seed](https://seed.run) and connects to dev resources. Finally they rebase with master and that deploys to production. The dev and prod environments are on separate AWS accounts. - -### Looking Ahead - -Michael says they really need to grow the team. As more and more electricians are onboarded, they need to make sure every construction worker has a great experience and our operations team has the right tools to manage our workforce. - -From an architecture perspective, their single web application will most likely be split into multiple SST apps; one for their electricians, one for the contractors, and one for the ops team. They will also be introducing ElasticSearch for better search functionality. - -Thanks to SST their entire development setup works seamlessly, allowing them to focus on the needs of a fast growing business. - -### Learn More - -[Learn more about the job opportunities at Buildforce](https://joinbuildforce.recruitee.com). - ---- - -[Read more about SST](/) and get started today. diff --git a/www/src/content/docs/blog/config.mdx b/www/src/content/docs/blog/config.mdx deleted file mode 100644 index 0423c93875..0000000000 --- a/www/src/content/docs/blog/config.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: Config -author: jay -image: /social-cards/blog/sst-config.png -template: splash -description: We are launching a set of tools to securely manage secrets and environment variables in your SST apps. -pagefind: false -lastUpdated: 2022-08-22 ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -We are launching a set of tools to securely manage secrets and environment variables in your SST apps, called `Config`. - -You can [**read more about it in detail over on our docs**](/docs/). The `Config` libraries include: - -1. Constructs to define them - 1. `Config.Secret` - 2. `Config.Parameter` -2. CLI to set secrets `sst secrets [action]` -3. Lambda helpers to fetch them `@serverless-stack/node/config` - - Throws an error if they are not defined - - Fetches them automatically at runtime - - Provides typesafety and autocomplete - -Behind the scenes, Secrets and Parameters are stored as [AWS SSM](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html) Parameters in your AWS account. They are stored with the _Standard Parameter type_ and _Standard Throughput_. - -This makes Config [**free to use**](https://aws.amazon.com/systems-manager/pricing/) in your SST apps. - -## Launch event - -We hosted a [launch livestream on YouTube](https://www.youtube.com/watch?v=6sMTfoeshLo) where we did a deep dive of the Config and its internals. - - - -The video is timestamped and here's roughly what we covered. - -1. Intro -2. Demo -3. Deep Dive - 1. Deep dive into the Parameters code - 1. Parameter vs Lambda environment variables - 1. Deep dive into the Secrets code - 1. IAM permission for fetching secrets - 1. CLI command `sst secrets` - 1. Secrets fallback -4. Q&A - 1. Q: What is the AWS cost of using Config? - 1. Q: What does the SSM path look like? - 1. Q: Managing secrets in my CI pipeline - 1. Q: Managing secrets across AWS accounts - 1. Q: Accessing Config inside or outside the handler - 1. Q: Would changing a secret require redeployment? - 1. Q: Using Config for tests - 1. Q: SSM vs Secret Manager - 1. Q: Export secrets to a .env file - 1. Q: Reference Config across multiple SST apps - -## Get started - -To get started, define a secret in your stacks. - -```typescript -import { Config, StackContext } from "@serverless-stack/resources"; - -export default function SecretsStack({ stack }: StackContext) { - const STRIPE_KEY = new Config.Secret(stack, "STRIPE_KEY"); - - return { STRIPE_KEY }; -} -``` - -Use the config option to pass the secret into the function. - -```typescript -import { use, Function, StackContext } as sst from "@serverless-stack/resources"; -import SecretsStack from "./SecretsStack"; - -export default function MyStack({ stack }: StackContext) { - const { STRIPE_KEY } = use(SecretsStack); - - new Function(stack, "MyFunction", { - handler: "lambda.handler", - config: [STRIPE_KEY], - } -}; -``` - -In your terminal, run the `sst secrets` command to set a value for the secret: - -```bash -$ npx sst secrets set STRIPE_KEY sk_test_abc123 -``` - -Finally in your function code, use the `@serverless-stack/node/config` library to reference the secret value: - -```typescript -import { Config } from "@serverless-stack/node/config"; - -export const handler = async () => { - console.log(Config.STRIPE_KEY); - - // ... -}; -``` - -To learn more [**check out our docs**](/docs/). diff --git a/www/src/content/docs/blog/configure-autodeploy-workflow.mdx b/www/src/content/docs/blog/configure-autodeploy-workflow.mdx deleted file mode 100644 index aacd6e5559..0000000000 --- a/www/src/content/docs/blog/configure-autodeploy-workflow.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -template: splash -title: Configure Autodeploy workflow -description: You can now completely control the build process when the Console auto-deploys your app. -author: jay -pagefind: false -lastUpdated: 2025-01-30 ---- - -You can now completely control the build process when auto-deploying your app through the [Console](/docs/console). - -##### Background - -After you've enabled [Autodeploy](/docs/console#autodeploy), the Console will start a build process, check out your code, detect your package manager, install dependencies, and run `sst deploy`; all without needing a config. - -However, there are times where you want to configure the build process. For example, to run your tests, or run some post-deploy script. - -You can now do that with the new `autodeploy.workflow` prop. - ---- - -### Workflow - -The [**`autodeploy.workflow`**](/docs/reference/config#console-autodeploy-workflow) prop allows you to completely take over control of the build process and run any commands you want. - -```ts title="sst.config.ts" {6-11} -export default $config({ - app(input) { /* ... */ }, - async run() { /* ... */ }, - console: { - autodeploy: { - async workflow({ $, event }) { - await $`npm i`; - event.action === "removed" - ? await $`npm sst remove` - : await $`npm sst deploy`; - } - } - } -}); -``` - -The problem with CI/CD scripts has always been that they are bash commands embedded in a YAML config. This can be hard to write and maintain. - -Even though the SST config is in TypeScript, it's still cumbersome to write shell scripts in Node. - ---- - -#### Bun Shell - -To address this we run the `workflow` function in a Bun process. `$` is the [Bun Shell](https://bun.sh/docs/runtime/shell), a _bash-like_ shell that makes it easy to write scripts in TypeScript and JavaScript. - -```ts title="sst.config.ts" -async workflow({ $, event }) { - await $`npm i -g pnpm`; - await $`pnpm i`; - - const { exitCode } = await $`pnpm test`.nothrow(); - if (exitCode !== 0) { - // Process the test report and then fail the build - throw new Error("Failed to run tests"); - } - - event.action === "removed" - ? await $`pnpm sst remove` - : await $`pnpm sst deploy`; -} -``` - -This simplifies the shell commands in your deployment scripts. - ---- - -#### Errors - -In the above example, we are throwing an error after we handle a failed command. - -```ts -throw new Error("Failed to run tests"); -``` - -This will fail the build and display this error message in the Console. - ---- - -#### Learn more - -You can see the new `workflow` prop in action in how the [Console is deployed](https://github.com/sst/sst/blob/dev/www/sst.config.ts); since the Console auto-deploys itself! - -```ts title="sst.config.ts" -async workflow({ $, event }) { - await $`bun i`; - await $`goenv install 1.21.3 && goenv global 1.21.3`; - await $`cd ../platform && ./scripts/build`; - await $`bun i sst-linux-x64`; - event.action === "removed" - ? await $`bun sst remove` - : await $`bun sst deploy`; -} -``` - -[Learn more](/docs/reference/config#console-autodeploy-workflow) about the new `workflow` prop in the docs. - ---- - -### Other updates - -We also rolled out a couple of other updates to Autodeploy: - -- We implemented a workaround so you won't get the annoying Docker Hub rate limit errors while deploying the `Service` component. -- You can now return multiple stages in [`autodeploy.target`](/docs/reference/config#console-autodeploy-target). This means that when you git push to your repo, the Console can deploy to multiple stages. - -You can learn more about the [Console](/docs/console) and [Autodeploy](/docs/console#autodeploy) in the docs. diff --git a/www/src/content/docs/blog/console-container-updates.mdx b/www/src/content/docs/blog/console-container-updates.mdx deleted file mode 100644 index 5de9c88ad7..0000000000 --- a/www/src/content/docs/blog/console-container-updates.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -template: splash -title: Console container updates -description: Updates to the Console to better support container applications. -author: jay -lastUpdated: 2024-11-25 -pagefind: false ---- - -We are rolling out some updates to the [Console](/docs/console) to better support container applications. - -### Logs - -You can now see **logs from your containers** in the Console. In addition to the logs from your functions. Head over to your **App** > **Stage** > **Logs**. - -As a bonus, you can see logs from any CloudWatch log group that your app creates. - -### Autodeploy - -The Console can auto-deploy your apps when you _git push_ to your GitHub repo. We added the following updates recently. - -- **VPC**: You can now configure Autodeploy to run in your VPC using [`autodeploy.runner.vpc`](/docs/reference/config#vpc). This is useful if your builds need to access private resources. -- **Caching**: You can now configure files or directories to be cached as a part of your build process with [`autodeploy.runner.cache`](/docs/reference/config#cache). This can help speed up builds. -- **Extended timeouts**: Autodeploys now have a maximum timeout of 36 hours. This is useful for apps that take a long time to build. -- **New runner sizes**: There are new `xlarge` and `2xlarge` sizes with around 70GB and 145GB of memory; helpful for large applications. - -Check out the updated [`console.autodeploy`](/docs/reference/config#console-autodeploy) config. - -### Other updates - -While not strictly related to containers we also added support for: - -- **Manual deploys**: You can now manually trigger a deployment from **App** > **Autodeploy** > hitting the **Deploy** button. You can pass in a Git ref and the stage you want to deploy to. -- **Redeploys**: You can now redeploy any past deploy through the Console. -- **Cancel deploys**: You can also cancel a deploy that's in progress through the Console. - ---- - -### About Autodeploy - -If you haven't used Autodeploy before, we designed it to be a better fit for SST apps when compared to alternatives like GitHub Actions or CircleCI. - -1. **Easy to get started**, supports branch and PR workflow out of the box. -2. **Configurable**, customize your workflow through your `sst.config.ts`. -3. **Runs in your AWS account**, builds are run in your AWS account and can use your VPC. - -And it integrates with the rest of the SST Console. [Learn more about Autodeploy](/docs/console#autodeploy) to get started. diff --git a/www/src/content/docs/blog/console-pricing-update.mdx b/www/src/content/docs/blog/console-pricing-update.mdx deleted file mode 100644 index 5fe392b4bf..0000000000 --- a/www/src/content/docs/blog/console-pricing-update.mdx +++ /dev/null @@ -1,112 +0,0 @@ ---- -template: splash -title: Console pricing update -description: We are rolling out an update to the pricing of the Console. -author: jay -lastUpdated: 2025-01-23 -pagefind: false ---- - -:::note[Update] -_Feb 10, 2025: We added a way to handle PR and other epehemeral stages. [See FAQ](#faq)._ -::: - -Starting Feb 1, we'll be rolling out a new pricing model for the Console. Currently the pricing is based on the number of times the Lambda functions in your apps are invoked. Moving forward, it'll be based on the **number of active resources** in your apps. - ---- - -### Why the change? - -When SST was first released, there was a big focus on serverless and Lambda functions. The [Issues](/docs/console#issues) feature was also the focal point of the Console. So it made sense to tie the pricing to the number of Lambda function invocations in your apps. - -Over the last few months, we added the ability to [Autodeploy](/docs/console#autodeploy) your apps. And added broader support for [container services](/blog/container-support). So a Lambda specific metric doesn't really make sense anymore. - -We think the number of active resources will be more representative of your usage. - ---- - -### How does it work? - -At the start of every month, or billing cycle, the Console will keep track of the stages that are updated across your workspace, add up the resources in those stages, and apply the following rate. - -| Resources | Rate per resource | -|-----------|-----------| -| First 2000 | $0.086 | -| 2000+ | $0.032 | - -**Free Tier**: Workspaces with 350 active resources or fewer. - ---- - -#### Examples - -So for example, if you have the following number of active resources in your workspace: - -| Resources | Cost per month | -|----------|------| -| 350 | You are in the free tier, so you'll be charged $0. | -| 500 | You are above the free tier, so you'll be charged $0.086 x 500 = $43. | -| 2500 | You are in a higher tier, so $0.086 x 2000 + $0.032 x (2500 - 2000) = $188. | - -The count of the active resources in your workspace resets at the start of every billing cycle. - ---- - -### FAQ - -1. Do I need to use the Console to use SST? - - You **don't need the Console** to use SST. It compliments the CLI and has some features that help with managing your apps in production. - - That said, it is completely free to get started. You can create an account and invite your team, **without** having to add a **credit card**. - -2. I'm still trying out the Console. Can I continue using it? - - You can continue using the Console as a part of the free tier. If you go over the free tier, you won't be able to access the _production_ or deployed stages. - - However, you can continue to **access your personal stages**. Just make sure you have `sst dev` running locally. Otherwise the Console won't be able to detect that it's a personal stage. - - -3. What is an active resource? - - Resources are what SST creates in your cloud provider. This includes the resources created by both SST's built-in components, like `Function`, `Nextjs`, `Bucket`, and the ones created by any other Terraform/Pulumi provider. - - Some components, like `Nextjs` and `StaticSite`, create multiple resources. In general, the more complex the component, the more resources it'll create. - - You can see a [full list of resources](/docs/console#resources) if you go to an app in your Console and navigate to a stage in it. - - For some context, the Console is itself a pretty large [SST app](https://github.com/sst/console) and it has around 320 resources. - - A resource is considered active if the stage it belongs to has been updated during the billing cycle. However, if the only update to a stage was to remove it, the resources in that stage will not be counted as active. - -4. What about PR stages? - - A stage has to be around for at least 2 weeks before the resources in it are counted as active. So if a PR stage is created and removed within 2 weeks, they don't count. - - However, if you remove a stage and create a new one with the same name, it does not reset the 2 week initial period. - - -5. Does this apply to SST v2 and v3 apps? - - Yes, it applies to any kind of SST app. - -6. What if I'm on the old plan? - - If you are on the old plan, you don't have to switch and you won't be automatically switched over either. - - You can go to the workspace settings and check out how much you'll be billed based on both the plans. To switch over, you can cancel your current plan and then subscribe to the new plan. - - At some point in the future, we'll remove the old plan. But there's no specific timeline for it yet. - -7. Are there any volume pricing options? - - Yes you can [contact us][contact-us] and we can figure out a pricing plan that works for you. - -[**Learn more about the new pricing in our docs**](/docs/console#pricing). - ---- - - If you've got any questions about the new pricing, or about the Console in general, feel free to [get in touch][contact-us]. - - -[contact-us]: mailto:hello@sst.dev diff --git a/www/src/content/docs/blog/container-spot-capacity.mdx b/www/src/content/docs/blog/container-spot-capacity.mdx deleted file mode 100644 index 0ca3e5ebf0..0000000000 --- a/www/src/content/docs/blog/container-spot-capacity.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -template: splash -title: Container Spot capacity -description: We are adding support for using the Fargate Spot capacity provider for services. -author: jay -lastUpdated: 2025-01-13 -pagefind: false ---- - -import { YouTube } from "@astro-community/astro-embed-youtube"; - -We are adding support for using Spot instances when you create a Fargate service with the [`Cluster`](/docs/component/aws/cluster) component through the [`capacity`](/docs/component/aws/cluster#capacity) prop. Spot instances can be around 50% cheaper and we talk about how they work here. - - - -## Background - -You can create container services with ECS and Fargate in SST with the [`Cluster`](/docs/component/aws/cluster) component. - -You are charged per hour of vCPU and GB of memory used. With our base config, this works out to around $12 per month. - -Spot instances are spare capacity that AWS has and it's available at a discounted rate, around $6 per month. - ---- - -## Spot - -You can enable this using the new [`capacity`](/docs/component/aws/cluster#capacity) prop. - -```ts title="sst.config.ts" {8} -const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - -new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - capacity: "spot", -}); -``` - -You can also configure the % of regular Fargate vs Spot capacity you want to use. - -```ts title="sst.config.ts" {7} -capacity: { - fargate: { weight: 1 }, - spot: { weight: 1 } -} -``` - -Learn more about the [**`capacity`**](/docs/component/aws/cluster#capacity) prop. - ---- - -#### Caveats - -There are a couple of caveats. - -1. AWS may reclaim this capacity and turn off your service after a two-minute warning. This is rare, but it can happen. -2. If there’s no spare capacity, you’ll get an error. - -This makes Fargate Spot a good option for dev or PR environments. - -```ts title="sst.config.ts" -capacity: $app.stage === "production" ? undefined : "spot"; -``` - ---- - -## Get started - -Get started by checking out the [**Fargate Spot capacity example**](/docs/examples/#aws-cluster-spot-capacity). - -You can also check out our container service quick starts. - -- [Bun](/docs/start/aws/bun) -- [Deno](/docs/start/aws/deno) -- [NestJS](/docs/start/aws/nestjs) -- [Express](/docs/start/aws/express) - -These will help you get started with building container services. diff --git a/www/src/content/docs/blog/container-support.mdx b/www/src/content/docs/blog/container-support.mdx deleted file mode 100644 index 92b9ae5fb2..0000000000 --- a/www/src/content/docs/blog/container-support.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -template: splash -title: Container support -description: SST now natively supports building containerized applications. -author: jay -lastUpdated: 2024-11-08 -pagefind: false ---- - -import { YouTube } from "@astro-community/astro-embed-youtube"; - -Historically, SST has primarily supported deploying serverless applications. But over the last month we've slowly expanded native support for containers on AWS. - - - -This includes changes across the entire SST platform. - ---- - -### 1. Components - -There's a new family of components that'll help you build with containers. - -- [`Cluster`](/docs/component/aws/cluster) & [`Service`](/docs/component/aws/service) - - These help you deploy your containerized applications to AWS using ECS and Fargate. - - ```ts title="sst.config.ts" - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - ``` - - In addition to configuring ECS and Fargate, this also configures [**service discovery**](https://x.com/jayair/status/1853848336538673606) for your applications. - -- [`Vpc`](/docs/component/aws/vpc) - - Container applications are usually deployed in a VPC. So this component makes it easy to create a VPC. And optionally add a bastion host or a NAT gateway. - - ```ts title="sst.config.ts" - new sst.aws.Vpc("MyVpc", { bastion: true, nat: "managed" }); - ``` - -- [`Postgres`](/docs/component/aws/postgres), [`Redis`](/docs/component/aws/redis), & [`Efs`](/docs/component/aws/efs) - - While these components are not specifically for containers, they've been designed to work well with the above `Cluster` and `Vpc` components. - ---- - -#### Cost - -Unlike our serverless components, that are pay-per-use, these components have a more traditional pricing structure. We've taken special care to ensure that these components are as cost effective as possible to get started with. While still allowing you to scale with them. - -Unfortunately, AWS' pricing pages for these services is not great. So the above components have a new _Cost_ section in their docs. For example, here's what the [cost of using the `Vpc` component looks like](/docs/component/aws/vpc#cost). - -You can [read more about what we've done here](https://x.com/jayair/status/1851019182122652125). - ---- - -### 2. CLI - -There are two big things we've done with our CLI to support containers. - -1. The `dev` prop allows you to run your application locally in a new tab in the `sst dev` multiplexer. - -2. The new [`sst tunnel`](/docs/reference/cli#tunnel) command allows your local machine to connect to resources that've been deployed in a VPC. This is helpful because most of the container related components need a VPC. You can [check it out in action here](https://x.com/jayair/status/1844055259729007084). - ---- - -### 3. Console - -The [SST Console](/docs/console) now shows you logs for your containers. And [Autodeploy](/docs/console#autodeploy) will support running in the same VPC as your app. This will allow your deploy process to have access to all the resources in your app. - ---- - -## Get started - -We've updated all our tutorials to help you get started with the new containers. - -- [Bun](/docs/start/aws/bun) -- [Nuxt](/docs/start/aws/nuxt) -- [Solid](/docs/start/aws/solid) -- [Deno](/docs/start/aws/deno) -- [Hono](/docs/start/aws/hono) -- [Astro](/docs/start/aws/astro) -- [Remix](/docs/start/aws/remix) -- [Svelte](/docs/start/aws/svelte) -- [Next.js](/docs/start/aws/nextjs) -- [Drizzle](/docs/start/aws/drizzle) -- [Prisma](/docs/start/aws/prisma) -- [Express](/docs/start/aws/express) - -The frontends now support deploying to both serverless and containers. - ---- - -## What's next - -Over the next few weeks we'll extend support to other languages and frameworks. Like Rails, Laravel, Python, Elixir, Go, and more. diff --git a/www/src/content/docs/blog/create-sst.mdx b/www/src/content/docs/blog/create-sst.mdx deleted file mode 100644 index 7dd46c846e..0000000000 --- a/www/src/content/docs/blog/create-sst.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: create sst -author: jay -template: splash -description: We are launching a CLI that helps you get started with SST easily. -lastUpdated: 2022-06-28 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -Today we are launching [`create sst`](https://github.com/sst/sst/tree/master/packages/create-sst) β€” a CLI that helps you get started with SST. It creates a full-stack starter that you can use to build your serverless applications. - -While serverless has been around for a few years, there isn't a [Twelve-Factor App](https://12factor.net) setup for it. - -With `create sst`, we are trying to bake a lot of these principles into a starter that you can use right away. Simply run: - -```bash -npm init sst -``` - -This will bootstrap a full-stack serverless application with end to end type-safety: - -- RDS as the database (with an option to use DynamoDB) - - [Kysely](https://github.com/koskimas/kysely) for SQL - - [ElectroDB](https://github.com/tywalch/electrodb) for DynamoDB -- GraphQL as the API - - [Pothos](https://pothos-graphql.dev) for building GraphQL schemas -- React as the frontend - -It also does a few other things that you can step through using a new tutorial we added in our docs. - -## Launch event - -We livestreamed the `create sst` launch event. You can [check it out on YouTube](https://www.youtube.com/watch?v=wBTDkLIyMhw). - - - -Here's roughly what we covered during the launch: - -- Backstory -- Demo of `create sst` -- [Tyler W. Walch](https://twitter.com/tinkertamper) from [ElectroDB](https://github.com/tywalch/electrodb) -- [Michael Hayes](https://twitter.com/yavascript) from [Pothos](https://pothos-graphql.dev) -- Looking ahead -- Q&A - -The video is timestamped, so you can jump ahead. - - -## Looking ahead - -With `create sst` we are planning to address most of the common concerns of application development; including handling authentication, managing secrets, writing tests, and more. As a team we are able to spend a lot more time on little details to get this setup in a place that makes your team as productive as possible. We'll also be open sourcing a codebase that we are working on internally that uses `create sst`. We'd like it to serve as an example of a real world production application. - -While `create sst` helps you get started with SST easily, it's better thought of as an opinionated way to assemble the primitives that SST provides. You might want to tweak this setup or use a different one entirely. - -We've got a lot more in store and we can't wait to share it with you all! diff --git a/www/src/content/docs/blog/doorvest-is-using-sst-to-simplify-real-estate-investing.mdx b/www/src/content/docs/blog/doorvest-is-using-sst-to-simplify-real-estate-investing.mdx deleted file mode 100644 index 4d27a3f1e3..0000000000 --- a/www/src/content/docs/blog/doorvest-is-using-sst-to-simplify-real-estate-investing.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -template: splash -title: Doorvest & SST -description: In this post we are talking to Orlando Hui from Doorvest about how they are using SST and Seed to simplify real estate investing. -author: jay -cover: /social-cards/blog/case-study-doorvest.png -lastUpdated: 2021-10-27 -pagefind: false ---- - -In this post we are talking to Orlando Hui from [Doorvest](https://doorvest.com) about how they are using [SST](/) and [Seed](https://seed.run) to simplify real estate investing. - - -### About Doorvest - -[Doorvest](https://doorvest.com) creates a modern way for people to own high-yield rental homes completely online. Doorvest gets to know a customer and their investment goals before identifying and buying a home on their behalf. It handles renovations and places a resident in it, then sells the home to the customer. - -Doorvest is a VC backed company with 30 plus employees. Orlando Hui is the lead engineer on the team and was responsible for implementing SST across their stack. - -### The Challenge - -While the original version of the Doorvest client was built using Serverless Framework, the dev workflow was really painful. _"Deployments took 7 minutes"_, says Orlando. For most cases they had to deploy to test their changes. So the commit, deploy, feedback loop was something that they couldn't continue to use. - -The original application also connected to resources that were not created in YAML and were created through the AWS Console. This was partly because it seemed easier to create them through the console, as opposed to working with the CloudFormation YAML that Serverless Framework uses. - -### Using SST - -The Doorvest team had been following [SST](/) since it's Hacker News launch back in February, 2021. But they were unable to find an excuse to use it internally. Then a couple of months ago they needed to build an application for the general contractors on Doorvest. This allowed them to try out SST in production. - -The team built everything from scratch, used the constructs in SST and CDK to define all their infrastructure as code. They also followed the best practices of separating their environments by AWS accounts. So each developer has their own AWS account, the staging and production environments are also in separate accounts. Their SST apps are deployed through [Seed](https://seed.run), and the combination of the two worked perfectly for them. - -_"SST doesn't have anything that's missing for us. We have everything we need."_, says Orlando. _"We don't have to do YAML anymore. The Live Lambda Dev is incredible."_ - -> "The Live Lambda Dev is incredible." - -Comparing their workflow from before, Orlando thinks, _"it's improved our productivity by at least 3 times"_. - -> "It's improved our productivity by at least 3 times." -> - -He also found the SST Slack community while working on it. _"The Slack group has been super incredible"_, says Orlando. - -> "The Slack group has been super incredible." - -Recently, he was looking for WebSocket authorizer support and _"it got built almost instantly after I brought it up"_. - -### Looking Ahead - -_"Now everybody on the team just wants to migrate away from Serverless Framework"_, says Orlando. As a part of their current sprint they are figuring out how to move over to SST completely. - -The Doorvest engineering team is looking to grow 4x in 2022 and are actively seeking new engineers. They added 3 new folks recently and _"having everybody use SST has been great, especially the new engineers"_. - -### Learn More - -Learn more about the [job opportunities at Doorvest](https://www.builtinsf.com/company/doorvest) and help them in their cause to simplify real eastate investing. - ---- - -[Read more about SST](/) and get started today. diff --git a/www/src/content/docs/blog/frontends-are-hard.mdx b/www/src/content/docs/blog/frontends-are-hard.mdx deleted file mode 100644 index c3ffc62b02..0000000000 --- a/www/src/content/docs/blog/frontends-are-hard.mdx +++ /dev/null @@ -1,290 +0,0 @@ ---- -title: Frontends are hard -description: Modern serverless frontends are hard to deploy and here's why. -template: splash -author: jay -lastUpdated: 2025-05-02 -pagefind: false ---- - -import { Image } from "astro:assets" - -import SpaDiagram from "../../../assets/blog/frontends-are-hard/spa-architecture-diagram.svg"; -import SsrDiagram from "../../../assets/blog/frontends-are-hard/ssr-architecture-diagram.svg"; -import MarketMap from "../../../assets/blog/frontends-are-hard/framework-market-map.svg"; - -import tweetDark from "../../../assets/blog/frontends-are-hard/cloudfront-announcement-tweet-dark.png"; -import tweetLight from "../../../assets/blog/frontends-are-hard/cloudfront-announcement-tweet-light.png"; - -Modern frontends like Next.js, Svelte, Remix, Astro, etc. are hard to deploy. There are services like [Netlify](https://www.netlify.com/) and [Vercel](https://vercel.com/) that have built [custom infrastructure](https://vercel.com/blog/framework-defined-infrastructure) just to do this. - -In this post we look at why frontends have become **so hard to deploy** and why even the **giant cloud providers** like AWS, GCP, or Azure have **really poor support**. - -We also look at how some recent changes have made it possible for SST to better support them. - ---- - -## Background - -Back in the 2010s frontends were single-page apps. Hosting them was really easy. You just uploaded it to an S3 bucket and shared the URL with your users. To get fancy, you could add a CDN. - - - -You could do this on any cloud provider. Like AWS or GCP, and it was the **simplest part of your stack**. - -Modern frontends now need a combination of infrastructure like S3 buckets, serverless functions, databases, CDNs, edge functions, edge data stores, and more. - - - -There are also a dozen or so competing frameworks. - - - -This is complicated enough that even AWS and GCP's services like [Amplify](https://aws.amazon.com/amplify/) and [Firebase](https://firebase.google.com/) have really poor support for them. They only support a couple of frameworks, don't support their latest versions, and don't cover all their features. - -As a result, most people use secondary cloud providers like Netlify or Vercel. These services have their own custom infrastructure **built on top of the major cloud providers**. They've used this approach to grow to impressive scales. Both of these companies are reportedly doing around $100M in ARR. - -But why do we need dedicated services? What's so hard about deploying a frontend? How come even the giant cloud providers are unable to keep up? - ---- - -## Why is it so hard? - -There are a few main reasons why frontends are hard to deploy and host: - -1. **Complicated infrastructure** - - With single-page apps, it's all just static files. But modern frontends have evolved to support server-side rendering, API routes, image optimization, edge support, middleware, and a lot more. They are now closer to full-stack apps. - - > Modern frontends are now closer to full-stack apps. - - This needs a combination of infrastructure like S3 buckets, serverless functions, databases, CDNs, edge functions, edge KV stores, etc. - - There is no **one-size-fits-all piece of infrastructure** for hosting a modern frontend. - -2. **Dozen different frameworks** - - From Next.js to Astro, SvelteKit, Remix, SolidStart, to recent ones like TanStack Start or React Router v7 in Framework mode. There are at least a **dozen competing frameworks** with different features or areas of focus. - - This leads AWS and GCP to pick which ones they support. - -3. **Faster pace of updates** - - All these frameworks are also constantly being updated. - - The big cloud providers are slow to release updates on their end. Meaning that the versions they support are almost **always out of date**. - -#### Caveats - -You could self-host most of these frameworks in a container, or self-host as a single-page app. But these modes of deployment have their limitations and are clearly sub-optimal compared to using a dedicated service. - ---- - -## Open source for the win - -When we had first started building SST, deploying frontends was a small part of what we did. But as we grew, we started to get more requests for better frontend support. - -> Self-hosting frontends is a perfect fit for an OSS project. - -We looked at the above problems; not having a one-size-fits-all solution and a long tail of frameworks and features. And realized that this was a perfect fit for an OSS project. - -So here's what we did: - -1. **Break down the problem** - - Deploying a frontend is a combination of generating a build output through something called an adapter. And then using that to deploy the infrastructure. - - While the infrastructure is specific to the provider, the adapter could potentially be shared. - - So when we wanted to support frontends in SST, we decided to **separate the two steps**, and open source the adapters. - - This is led us to start the [OpenNext](https://opennext.js.org) project. - - Now providers like Cloudflare, and even Netlify and Vercel, can contribute to the project and help keep it up to date. - -2. **Open source everything** - - Aside from adapters, even the infrastructure SST uses to deploy frontends is open source. You can just look at our repo to see how we deploy them. - - This allows people to contribute and makes it so that **SST supports a large number of frameworks**, covers all their features, and remains up to date with new releases. - -3. **Work closely with the framework authors** - - Since everything is open source, it also makes it easier for us to collaborate with the framework authors directly. - -This made SST the best available option for people that want to deploy their frontend to their infrastructure. - ---- - -#### Good or good enough? - -The infrastructure that SST creates when you self-host your frontend is **a little different** from what Netlify or Vercel creates. - -It stems from the fact that Netlify and Vercel are _multi-tenant_ and can share some bits of infrastructure across all their users. - -Whereas SST creates a completely isolated setup for your frontend where nothing is shared between your sites and you are of course isolated from other SST users. - -The downside of our approach is that we **recreate all the infrastructure**, like the CDN distribution, for each of your sites. This means it can take 15-20 mins to create one of these. So if you have multiple frontends or if you were creating preview environments, your deployments will be slower. - -And somewhat related, SST didn't really support deploying your frontend to multiple regions. - -We had been looking for ways to improve our setup. And now we can, [thanks to this](https://aws.amazon.com/about-aws/whats-new/2024/11/amazon-cloudfront-origin-modifications-cloudfront-functions/). - - - - - CloudFront announcement tweet - - ---- - -## A new approach - -A seemingly trivial _pre:Invent_ announcement made CloudFront a lot more _programmable_. This paved the way for us to support setups that are far **more flexible than Netlify or Vercel**. - -The key change here is that you can now use CloudFront Functions in tandem with a CloudFront KeyValueStore to modify the origin of requests. This lets you create custom policies for how traffic is routed from the CDN to your application. - -In the past, you'd have to use a Lambda@Edge function and a DynamoDB table which is both a lot more expensive and a lot slower. - ---- - -### Introducing Router - -We used this change to build the [`Router`](/docs/component/aws/router/) component. This component lets you use a single CloudFront distribution for your entire app. - -```ts title="sst.config.ts" -const router = new sst.aws.Router("MyRouter", { - domain: { - name: "example.com", - aliases: ["*.example.com"] - } -}); -``` - -With it: - -1. You can **set up routes** to your frontends. - - ```ts title="sst.config.ts" {3} - const web = new sst.aws.Nextjs("MyWeb", { - router: { - instance: router - } - }); - ``` - - Or functions. - - ```ts title="sst.config.ts" {4,5} - const api = new sst.aws.Function("MyApi", { - url: true, - router: { - instance: router, - path: "/api" - } - }); - ``` - - Or S3 buckets. - - ```ts title="sst.config.ts" {5} - const bucket = new sst.aws.Bucket("MyBucket", { - access: "cloudfront" - }); - - router.routeBucket("/files", bucket); - ``` - - Or any URL. - - ```ts title="sst.config.ts" - router.route("/external", "https://some-external-service.com"); - ``` - -2. You can configure it to **serve a subdomain**. - - ```ts title="sst.config.ts" {4} - new sst.aws.Nextjs("MyWeb", { - router: { - instance: router, - domain: "docs.example.com" - } - }); - ``` - - Or **a path**. - - ```ts title="sst.config.ts" {4} - new sst.aws.Nextjs("MyWeb", { - router: { - instance: router, - path: "/docs" - } - }); - ``` - - For this, you'll also need to set the `basePath` in your `next.config.js`. - -3. You can share a router across stages. So your **preview environments can deployed almost instantly**. - - ```ts title="sst.config.ts" - const router = $app.stage === "production" - ? new sst.aws.Router("MyRouter", { - domain: { - name: "example.com", - aliases: ["*.example.com"] - } - }) - : sst.aws.Router.get("MyRouter", "A2WQRGCYGTFB7Z"); - ``` -4. You can also deploy your frontends to **multiple regions** and it'll route requests to the server function that's nearest to your user. - - ```ts title="sst.config.ts" {2} - new sst.aws.Nextjs("MyWeb", { - regions: ["us-east-1", "eu-west-1"], - router: { - instance: router - } - }); - ``` - ---- - -#### How it works - -The Router uses a CloudFront KeyValueStore to store the routing data and a CloudFront Function to route the request. As routes are added, the store is updated. - -So when a request comes in, it does a lookup in the store and dynamically sets the origin based on the routing data. For frontends, that have their server functions deployed to multiple regions, it routes to the closest region based on the user's location. - ---- - -### Why this matters - -Taking a step back for a second, a dedicated service like Netlify or Vercel is still likely to give you a better out-of-the-box experience. - -Where SST shines, is when you start to grow. You start adding multiple frontends. You want serve your API from the same domain. Or you want your preview environments to include more than just your frontend. - -This new setup allows you to do all of that. This is an example of one of SST's design principles. You can start with the simplest setup, without using a Router. Then grow to adding it. And eventually customize it. All through code. - ---- - -### Learn more - -You can learn more about this new setup: - -- [`Router`](/docs/component/aws/router/) component docs -- Guide on [**configuring a router**](/docs/configure-a-router) -- The [`router`](/docs/component/aws/nextjs/#router) prop in your frontend -- Multiple [`regions`](/docs/component/aws/nextjs/#regions) in your frontend - ---- - -## Final thoughts - -There are also some broader questions like: - -- Why are there so many frameworks? -- Why do these frameworks change all the time? -- And do frontends need to be this complicated? - -These are good questions that are worth having nuanced discussions about. We might tackle them in a future post. Or if you have some thoughts, we would love to hear them. diff --git a/www/src/content/docs/blog/go-runtime-support.mdx b/www/src/content/docs/blog/go-runtime-support.mdx deleted file mode 100644 index 35f02a24bb..0000000000 --- a/www/src/content/docs/blog/go-runtime-support.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -template: splash -title: Go runtime support -description: SST v3 now supports the Golang runtime for Lambda functions. -author: jay -pagefind: false -lastUpdated: 2024-12-20 ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -SST v3 now supports the [`go`](/docs/component/aws/function#runtime) runtime for your Lambda functions. Golang is a great option for tasks that are more compute intensive and it also has faster cold starts. We talk about it here: - - - -You can use Go in SST by setting the `runtime` prop and pointing the `handler` to the directory with your Go function. - -```ts title="sst.config.ts" -new sst.aws.Function("MyFunction", { - runtime: "go", - link: [bucket], - handler: "./src" -}); -``` - -For more details, check out our [**Go example**](/docs/examples/#aws-lambda-go). - ---- - -Also in this update: - -1. The [`sst dev`](/docs/reference/cli/#dev) CLI supports running your Go functions [_Live_](/docs/live/). - -2. You can use our new [Go SDK](/docs/reference/sdk/#golang) to access linked resources in your Go functions or container applications. - - ```go title="src/main.go" - import ( - "github.com/sst/sst/v3/sdk/golang/resource" - ) - - resource.Get("MyBucket", "name") - ``` - - The Go SDK does not support the [clients](/docs/reference/sdk/#clients) that are available in the JS SDK. - -3. You can view Go function logs in the [Console](/docs/console/). Support for [Issues](/docs/console/#issues) is coming soon. diff --git a/www/src/content/docs/blog/henry-schein-one-the-worlds-largest-dental-practice-management-software-company-is-building-with-sst.mdx b/www/src/content/docs/blog/henry-schein-one-the-worlds-largest-dental-practice-management-software-company-is-building-with-sst.mdx deleted file mode 100644 index 14ec15a85a..0000000000 --- a/www/src/content/docs/blog/henry-schein-one-the-worlds-largest-dental-practice-management-software-company-is-building-with-sst.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -template: splash -title: Henry Schein One & SST -description: In this post we are talking to Jack Fraser, a Software Engineering Manager at Henry Schein One; the world's largest dental practice management software company. -author: jay -image: /social-cards/blog/case-study-henry-schein-one.png -lastUpdated: 2021-11-16 -pagefind: false ---- - -In this post we are talking to Jack Fraser, a Software Engineering Manager at [Henry Schein One](https://henryscheinone.com). They are using [SST](/) and [Seed](https://seed.run) to power the patient booking experience and the management software used by thousands of dental practices globally. - -## About Henry Schein One - -[Henry Schein One](https://henryscheinone.com) is the world’s largest dental practice management software company. Founded in 2018, Henry Schein One launched a new era of integrated dental technology by merging the market-leading practice management, patient communication and marketing systems of Henry Schein and Internet Brands into one company. - -Henry Schein, Inc. (Nasdaq: HSIC), Henry Schein One's parent company, is the largest wholesaler of dental and medical products to office-based practitioners. The company has been established for approximately 90 years, with a presence in 32 countries to offer hundreds of thousands of products to customers globally. The company is a Fortune World's Most Admired Company and is ranked number one in its industry for social responsibility by Fortune magazine. - -Jack Fraser is a Software Engineering Manager at Henry Schein One. His team is building out applications that'll power the patient booking experience and the management software for thousands of dental practices globally. - -## The Challenge - -As more dental practices around the world start to rely on digital services to manage their practices and patient booking; the challenge is then to _"build applications that are snappy and easy to use for patients"_, says Jack Fraser. Each practice brings in roughly 3000 patients and so they need to be able to scale rapidly as these will be rolled out globally. - -They felt AWS made sense and serverless would help them with their scaling needs. So a year ago, Jack's team built out a serverless application in Serverless Framework. It had around 14 separate services. - -However the experience wasn't great. The local development workflow was painful and using YAML to define the infrastructure didn't make as much sense. - -In addition, their frontend applications were deployed as static sites to AWS through the AWS CLI. As Serverless Framework didn't have great support for this. - -## Switching to SST - -This is around when they found SST and it made perfect sense for them. _"It was based on CDK, and while CDK is great it is really verbose"_, says Jack. - -> "CDK is great but it is really verbose" - -The other aspect that they found really appealing was the Live Lambda Development environment. _"We loved the Live Lambda debugging in SST"_. - -> "We loved the Live Lambda debugging in SST" - -Now they have 15 stacks in their SST app. With over 200 endpoints in their API. It also includes 4 Angular apps that use SST's StaticSite construct. - -They also decided to move to GraphQL to manage their APIs. _"We are already using SST's ApolloApi construct"_, says Phil Astle, a Senior Software Engineer on the team. - -It's also all deployed through [Seed](https://seed.run). _"We want to have a consistent release process"_, says Jack. Each developer on the team has 2 stages, a local one and a deployed one. There's also a sandbox environment and a production environment. - -The PR workflow in Seed allows them to do code reviews and usability testing. It also allows them to spin up new environments to show changes to customers and get direct feedback. - -Thanks to what SST and Seed offers, they decided to _"make a big bet on SST"_, says Jack. And they've gone all in on SST. - -> "We have gone all-in on SST" - -## Looking Ahead - -Jack's team is going to be creating multiple prod environments, one for a section of the practices for early rollouts and the second for the rest of their customers. They also need to setup multi-region deployments as they'll be entering new markets soon. - -They are looking to double the team over the next couple of months. So Jack thinks that they need a dev environment thats _"easy and intuitive"_. And a deployment workflow that just works. _"We are a talent dense team, so it's important to have great tooling to be as productive as possible"_, says Jack. - -## Learn More - -Learn about the [job opportunities at Henry Schein One](https://dentr.co.uk/jobs) and join the world's largest dental practice management software company. - ---- - -[Read more about SST](/) and get started today. diff --git a/www/src/content/docs/blog/index.mdx b/www/src/content/docs/blog/index.mdx deleted file mode 100644 index 654fb8018c..0000000000 --- a/www/src/content/docs/blog/index.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Blog -template: splash -description: News and updates from the SST team. -pagefind: false ---- - -import PostList from "../../../components/PostList.astro"; - - diff --git a/www/src/content/docs/blog/is-serverless-ready-episode-1.mdx b/www/src/content/docs/blog/is-serverless-ready-episode-1.mdx deleted file mode 100644 index 1486c98e30..0000000000 --- a/www/src/content/docs/blog/is-serverless-ready-episode-1.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -template: splash -title: Is serverless ready? -lastUpdated: 2022-12-05 -description: We are launching a new livestream series showcasing the next generation of serverless tools and creators. -image: /social-cards/blog/is-serverless-ready.png -author: jay -pagefind: false ---- - -Today we are launching a new livestream series called β€” _"Is serverless ready?"_, where we'll be showcasing the next generation of serverless tools and creators. - -[![Is serverless ready?](../../../assets/blog/is-serverless-ready.png)](https://isserverlessready.com) - -Over the next few weeks, we'll have speakers from Astro, Solid, Bun, PlanetScale, Mongo, SST, and more. - -It's a chance for these tools and services to show off what they are working on and how they are making _serverless ready_. - -So head over to [**isserverlessready.com**](https://isserverlessready.com) and register. We'll send you an email when the next episode is coming out! diff --git a/www/src/content/docs/blog/issues-container-support.mdx b/www/src/content/docs/blog/issues-container-support.mdx deleted file mode 100644 index 2aeddcb587..0000000000 --- a/www/src/content/docs/blog/issues-container-support.mdx +++ /dev/null @@ -1,52 +0,0 @@ ---- -template: splash -title: Issues container support -description: Issues now reports errors from container applications. -author: jay -lastUpdated: 2025-03-04 -pagefind: false ---- - -import { Image } from "astro:assets" - -import issues from '../../../assets/blog/sst-console-container-issues.png'; - -[Issues](/docs/console#issues) now reports errors from Node.js container applications. Previously, only errors from Lambda functions were reported. - -SST Console Container Issues - ---- - -### Reporting errors - -For the Console to automatically report errors, you need to `console.error` an error object. - -```js title="src/index.ts" -console.error(new Error("my-error")); -``` - -In container applications, your code needs to also import the [SST JS SDK](/docs/reference/sdk/). - -```js title="src/index.ts" {1} -import "sst"; - -console.error(new Error("my-error")); -``` - -This applies a polyfill to the `console` object to prepend the log lines with a marker that allows Issues to detect errors. - -:::note -You'll need to update your SDK version to `3.9.24` or higher. -::: - -If you are already importing the SDK, you won't need to add an additional import. - ---- - -### How it works - -Issues works by adding a log subscriber to the CloudWatch Log groups in your SST apps. This has a filter that matches anything that looks like an error. - -In the case of Lambda functions, the Lambda runtime automatically adds a marker to the logs that the filter matches for. For containers, the SST SDK polyfills the `console` object to add the marker. - -[Learn more about Issues](/docs/console#issues). diff --git a/www/src/content/docs/blog/leadent-digital-is-transforming-field-service-operations-with-sst.mdx b/www/src/content/docs/blog/leadent-digital-is-transforming-field-service-operations-with-sst.mdx deleted file mode 100644 index 935cdb1095..0000000000 --- a/www/src/content/docs/blog/leadent-digital-is-transforming-field-service-operations-with-sst.mdx +++ /dev/null @@ -1,74 +0,0 @@ ---- -template: splash -title: Leadent Digital & SST -description: In this post we are talking to Ross Coundon, CTO of Leadent Digital about how they are using SST to transform field service operations. -author: jay -image: /social-cards/blog/case-study-leadent.png -lastUpdated: 2021-11-11 -pagefind: false ---- - -In this post we are talking to Ross Coundon, CTO of [Leadent Digital](https://leadent.digital) about how they are using [SST](/) and [Seed](https://seed.run) to transform field service operations. - -### About Leadent Digital - -[Leadent Digital](https://leadent.digital) provides the full spectrum of services from consulting advice to software development for field service operations. Their flagship product, the On My Way app provides real-time updates to customers on appointment visits, including expected time of arrival, appointment details and much more. Leadent's customers include Foxtel and Bosch Thermotechnology, and many others through a partnership with IFS. - -Ross Coundon, is the CTO at Leadent Digital and leads their software development -efforts. Ross has been building software for over 20 years, and after years of building -on-premise software was looking for a way to focus on solving business problems and not have to manage any servers. - -## The Challenge - -In their quest for reducing the operational overhead of building large applications, Ross -and his team experimented with AWS Elastic Beanstalk and Docker briefly before realizing that Lambda allowed them to build their MVPs far more easily and in a more cost effective -way. - -Some of the very early serverless applications at Leadent were built using Claudia.js -and it was fine for a handful of Lambda functions. But it was hard to test in a real-world context. - -This led them to Serverless Framework and serverless-offline. But there was _"no -confidence in going from an emulated offline environment to production"_, says Ross. It -wasn't testing the permissions or any of the connections within the app. _"You had to punt it over to AWS to find what was broken"_. - -He also didn't think YAML was the right way to define infrastructure. He was looking for -type support and looked at using `serverless.ts` with Serverless Framework. But felt the -documentation was lacking, and for anything that was not directly supported by Serverless -Framework, he needed to rely on a combination of guesswork and the AWS docs to piece the two together. - -This painful process of developing and testing led them to look at SST. - -## Enter SST - - -The constructs in SST made a lot of sense to Ross and his team. It allowed them to define all the infrastructure in one place and not have to use any YAML configuration. Better still, with full type support and IDE intellisense. - -They were also impressed with the Live Lambda Development environment. _"Knowing -that when I run an SST application I'm using real AWS infrastructure and my computer -is a part of the pipe was incredible"_, says Ross. - -SST allowed them to set breakpoints in their code and debug in real-time, which meant that _"you can iterate faster and build so much faster"_, says Ross. - -> "You can iterate faster and build so much faster." - -The entire SST local development process was a revelation for the team. _"I hadn't found anything like SST and haven't seen anything like it since"_, says Ross. - -> "I hadn't found anything like SST and haven't seen anything like it since." - -They also use [Seed](https://seed.run) to deploy their SST apps. All their major customers have separate deployments of their application. These are also deployed to separate AWS accounts. They use a PR based workflow in Seed and once their changes are merged to master, it gets deployed to all their customer accounts. - -They just recently completed migrating their flagship product completely to SST. And -next week one of their larger customers will be using the new version of their -application. - -## The Future - -The next 6 to 12 months is an exciting time for Ross and Leadent. They are looking to grow the team. They are also looking to expand the capabilities of their flagship product by adding live chat, so customers will be able to interact with the field service reps in real-time and they’ll be relying on SST for building this out. - -## Learn More - -Learn more about [Leadent Digital and their work here](https://leadent.digital). - ---- - -[Read more about SST](/) and get started today. diff --git a/www/src/content/docs/blog/learn-to-build-with-sst.mdx b/www/src/content/docs/blog/learn-to-build-with-sst.mdx deleted file mode 100644 index dcffb8d84f..0000000000 --- a/www/src/content/docs/blog/learn-to-build-with-sst.mdx +++ /dev/null @@ -1,35 +0,0 @@ ---- -template: splash -title: Learn to build with SST -description: We have a brand new tutorial that teaches you the basics of SST. -author: jay -image: /social-cards/blog/learn-sst.png -lastUpdated: 2022-09-12 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -We have a brand new tutorial that teaches you the basics of SST. And you can watch it as a video as well! - -### New Tutorial - -You can check out the new tutorial here β€” **docs.sst.dev/learn** - -This new tutorial uses a GraphQL starter, to build a simple Reddit clone. We go through the workflow of adding a new feature. - -In addition to covering the basics of SST, this tutorial sets you up with all the other tools and packages you need to build a full-stack serverless application. - -So if you are just getting started with SST, or serverless, or you want to learn how to build full-stack applications; this tutorial is for you! - -### Video Tutorial - -We hosted a [livestream on YouTube](https://www.youtube.com/watch?v=i7xEKHWTKNk) where we worked through the tutorial and talked about it in detail. - -This will help if you want to follow along with the tutorial as a video. - - - ---- - -We'll be putting out more _"101"_ style videos to help you get started with SST. Make sure to **subscribe to our YouTube channel** to get notified! diff --git a/www/src/content/docs/blog/long-running-jobs.mdx b/www/src/content/docs/blog/long-running-jobs.mdx deleted file mode 100644 index 6ceff67876..0000000000 --- a/www/src/content/docs/blog/long-running-jobs.mdx +++ /dev/null @@ -1,92 +0,0 @@ ---- -template: splash -title: Long running jobs -description: We launched a new construct that makes it easy to run functions longer than 15 minutes. -author: jay -image: assets/social-cards/sst-job.png -lastUpdated: 2022-09-23 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -We launched a new construct that makes it easy to run functions longer than 15 minutes β€” `Job` - -These are useful for cases where you are running async tasks like video processing, ETL, and ML. A `Job` can run for up to 8 hours. - -`Job` is made up of: - -1. `Job` β€” a construct that creates the necessary infrastructure. -2. `JobHandler` β€” a handler function that wraps around your function code in a typesafe way. -3. `Job.run` β€” a helper function to invoke the job. - -## Launch event - -We hosted a [launch livestream](https://www.youtube.com/watch?v=7sYdSbmi-ik) where we demoed the new construct, did a deep dive, and answered some questions. - - - -The video is timestamped and here's roughly what we covered. - -1. Intro -2. Demo -3. Deep Dive - - Deep dive into the construct - - Granting permissions for running the job - - Typesafety - - Defining the job handler - - Running the job - - Live debugging the job -4. Q&A - - Q: When should I use `Job` vs `Function`? - - Q: Is `Job` a good fit for batch jobs? - - Q: Why CodeBuild instead of Fargate? - -## Get started - -Here's how you use the new `Job` construct. Start by creating a new job. - -```typescript -import { Job } from "@serverless-stack/resources"; - -const job = new Job(stack, "MyJob", { - srcPath: "services", - handler: "functions/myJob.handler", -}); -``` - -Add the job handler. - -```typescript -import { JobHandler } from "@serverless-stack/node/job"; - -declare module "@serverless-stack/node/job" { - export interface JobTypes { - MyJob: { - foo: string; - }; - } -} - -export const handler = JobHandler("MyJob", async (payload) => { - // Do the job -}); -``` - -Finally invoke the job. - -```typescript -import { Job } from "@serverless-stack/node/job"; - -function someFunction() { - await Job.run("MyJob", { - payload: { - foo: "Hello World", - }, - }); -} -``` - -Note that the `payload` and job name `MyJob` here are typesafe. - -For a full tutorial check out the **Quick Start** in the docs. diff --git a/www/src/content/docs/blog/moving-away-from-cdk.mdx b/www/src/content/docs/blog/moving-away-from-cdk.mdx deleted file mode 100644 index a8b6328340..0000000000 --- a/www/src/content/docs/blog/moving-away-from-cdk.mdx +++ /dev/null @@ -1,601 +0,0 @@ ---- -title: Moving away from CDK -description: We are working on a new version of SST that’s not based on CDK. -template: splash -author: jay -lastUpdated: 2024-01-29 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; -import pulumiTweet from '../../../assets/blog/sst-pulumi-tweet.png'; - -You might've heard that we are working on a new version of SST (called [Ion](https://github.com/sst/ion)), that's not based on CDK. In this post we'll talk about why we are moving away from CDK and what's going to change. - -You might've also seen the demo AI app we built with it β€” [movies.sst.dev](https://movies.sst.dev) - -[![SST Ion Movies demo AI app](../../../assets/blog/sst-ion-movies-demo-ai-app.png)](https://movies.sst.dev) - -This is going to be a fairly long post, so here's an outline of what we'll be covering. - -1. [What is Ion](#what-is-ion) -2. [What’s Wrong With CDK & CFN?](#whats-wrong-with-cdk--cfn) - - [Design Flaws](#design-flaws) - 1. [CFN Is a Black Box](#1-cfn-is-a-black-box) - 2. [CDK Is Not IaC, It’s a CFN Hack](#2-cdk-is-not-iac-its-a-cfn-hack) - - [Practical Problems](#practical-problems) - 1. [Linking Resources](#1-linking-resources) - 2. [Cyclical Dependencies](#2-cyclical-dependencies) - 3. [Export in Use](#3-export-in-use) - 4. [Swallowing Errors](#4-swallowing-errors) - 5. [Custom Resource Hacks](#5-custom-resource-hacks) - 6. [Rollback Hell](#6-rollback-hell) - 7. [Double Builds](#7-double-builds) - 8. [Stack Resource Limits](#8-stack-resource-limits) - 9. [Orphan Stacks](#9-orphan-stacks) - 10. [Importing Resources](#10-importing-resources) - 11. [Slowness](#11-slowness) -3. [Why The Change](#why-the-change) - - [Background](#background) - - [Supporting Non-AWS Providers](#supporting-non-aws-providers) - - [What Changed](#what-changed) - - [Working With Pulumi](#working-with-pulumi) -4. [How Does Ion Work](#how-does-ion-work) -5. [Roadmap](#roadmap) - - [Step 0: Ion Prototype Demo](#step-0-ion-prototype-demo) - - [Step 1: Ion General Release](#step-1-ion-general-release) - - [Step 2: Ion β†’ SST v3](#step-2-ion--sst-v3) -6. [What About SST v2](#what-about-sst-v2) -7. [What About Migrating](#what-about-migrating) - - [Is Ion Right For Me](#is-ion-right-for-me) - - [What Ion Is Not](#what-ion-is-not) -8. [What’s Our Goal](#whats-our-goal) -9. [FAQ](#faq) - -We also covered this post on a livestream. - - - ---- - -## What Is Ion? - -Ion is a code name for a new engine for deploying SST applications. The constructs (or components) are defined using [Terraform](https://www.terraform.io) providers and deployed using [Pulumi](https://www.pulumi.com); as opposed to CDK and CloudFormation (CFN). - -The components look roughly the same as they do today and it'll still be completely open source. But there are some differences. The biggest one being that you cannot use a CDK construct in Ion. You'll need to migrate it over. - -Once Ion is stable, it'll be released as SST v3. This is a huge change, so let's look at why we are doing this. - ---- - -## What's Wrong With CDK & CFN? - -If you've spent time in the SST community or if you've talked to other SST users, you've probably heard complaints about CDK or CloudFormation being slow. Or you've run into deployment failures and rollbacks. While these are annoying, is it enough to switch? - -In the following sections I'll outline some of the underlying design flaws with the CDK & CFN model. I'll also talk about the practical implications of these problems and how some of these have turned into deal-breakers for us. - -### Design Flaws - -Most of the problems with CDK & CFN stem from two specific design flaws. Let's start with the basics. This is what deploying a CDK (and SST) app roughly looks like. - -```txt -CDK Constructs > CloudFormation Templates > CloudFormation Deployment -``` - -Your CDK constructs generate a CloudFormation template (JSON), that is then sent to CloudFormation (the service) and it deploys your infrastructure. It's important to understand that this is a two step process. - -The CloudFormation template defines *what* infrastructure you want to create. It does not describe *how* to create it. That is determined completely by AWS CloudFormation, the service. - -#### 1. CFN Is a Black Box - -You give AWS CloudFormation a list of resources to create. It'll internally call the AWS SDK to create a resource. Then poll it until it's complete. It'll also maintain state of the resources it's managing. - -Both the process it runs and the state it maintains are completely opaque and handled on the AWS side. CloudFormation does not run locally. You cannot customize it as a user and as we'll see later, neither can CDK. - -> CloudFormation is a black box that does not run locally. - -As a framework author that's trying to build a better developer experience on AWS, this limits what we can do. And this turns out to be a deal-breaker. We'll look at why below. We'll also look at the alternative from the Terraform world. - -#### 2. CDK Is Not IaC, It's a CFN Hack - -On the CDK side, we write TypeScript code that defines our infrastructure. But CDK doesn't *create* the infrastructure you define. It generates a CloudFormation template (JSON) that CloudFormation will use to create your infrastructure. - -> CDK doesn't create the infrastructure you define. - -The distinction might seem subtle but it's a big reason for a lot of problems people run into. Let's look at an example with some *CDK like* code. - -```ts -const fn = new Function(); - -const dist = new CloudFront(); - -fn.addEnvironment({ - key: "endpoint", - value: dist.url, -}); -``` - -Here, CDK converts your function and CloudFront distribution definition into a CloudFormation JSON block for each resource, it fills in the unknown values (distribution URL that the function environment needs) with *tokens* that'll be resolved once the resources are deployed. It also uses this to figure out the order in which your resources need to be created. - -This has two key implications: - -1. The order you write your code in, is not the order in which it'll be deployed. Here the distribution will be created first. -2. Since this is converted into a large JSON object, you cannot do certain operations in your CDK code. - -This odd behaviour makes a lot more sense when you realize that CDK is masquerading as a an IaC. When in reality it's just a CloudFormation hack. - -One other place where this hack becomes apparent is in CDK's concept of an *app*. A CDK app is a collection of multiple stacks. CloudFormation doesn't have a concept of an app. So CDK has to hack your stacks together to make them seem like an app. - -We'll look at the practical implications of this design flaw below. We'll also look at an alternative design that sidesteps all these issues. - -### Practical Problems - -The above might sound like *theoretical* problems and you might be wondering how this impacts me as a user. Let's look at the practical implications of these design flaws. - -The list below is not comprehensive but they make up most of our support cases. - -#### 1. Linking Resources - -Say you have a Next.js app that shows a list of blog posts; where these posts are stored in a DynamoDB table. When your Next.js app builds, it'll generate this page by querying your database for these posts. So to generate your Next.js build, you'll need to deploy the table first. But CloudFormation needs you to provide the assets that your resources need (the Next.js site) to do a deploy. - -Effectively meaning that you need to first deploy your database before deploying your Next.js site. This needs two deploys. It applies to any two resources where an asset for one depends on another (there's a Custom Resource hack that's used for cases like this but it won't work here and has its own problems). - -This problem is a deal-breaker for users that are deploying to multiple environments. Since every time they create a new environment, they'll need to deploy their app in two steps. - -> You'll need to deploy your app in two steps, this makes it a deal-breaker. - -Let's assume you are able to put up with this at your company. You'll run into a new problem. Let's say your Next.js site depends on the value of a resource that's set as a part of the deploy process. Something like a [Config Parameter](https://v2.sst.dev/config). SST needs to pull this value before the deploy, to build your Next.js site. But since this hasn't been re-deployed yet, it can only fetch its previously deployed value. This can be really hard to debug because it's not immediately apparent what's going on. - -SST exists today because of two main reasons; [Live Lambda](https://v2.sst.dev/live-lambda-development) & [Resource Binding](https://v2.sst.dev/resource-binding). And due to the CDK & CFN deployment model we cannot do Resource Binding well. - -#### 2. Cyclical Dependencies - -There's another similar problem that's turning into a deal-breaker for our users. Recall that CDK isn't truly IaC, it's a JSON generator. This means that it'll generate JSON CloudFormation templates that won't work. A very common failure case is where some resources depend on each other. These are called cyclical dependencies. They come in two flavours. - -##### Type 1: Resources - -Similar to the example we used above, let's say you create a Lambda function with a function URL and you create a CloudFront distribution that points to the function's URL. And you want the function to have an environment variable with the CloudFront distribution URL. - -```ts -const fn = new Function(); -const dist = new CloudFront({ - route: { - "/my-function": fn.url, - }, -}); - -// You cannot do this -fn.addEnvironment({ - key: "endpoint", - value: dist.url, -}); -``` - -This looks perfectly fine in CDK code but cannot be expressed in a JSON CloudFormation template. This is because the three resources now reference one another. It's a cyclical dependency. - -Unfortunately this comes up in our support pretty often. A *solution* for this is telling people to configure a custom domain so they know the URL before it's deployed. Or storing the distribution URL somewhere that can be later fetched inside the Lambda function. We have ways to make this easier but it requires *top level await* and that doesn't work in many environments and frameworks. - -##### Type 2: Stacks - -There's another version of this that's even more confusing. Let's say we are creating a queue and a function. The function needs to know the queue URL and the queue has a consumer that needs to know the function URL. - -```ts -const q = new SQS(); -const fn = new Function({ - environment: { - q: q.url, - } -}); - -q.consumer = new Function({ - environment: { - fn: fn.url, - } -}); -``` - -This isn't a cyclical dependency. The reasoning is subtle but related to the underlying resources that are being created. It looks the same as the one above in terms of CDK code but it's not the same when written in CloudFormation. - -CloudFormation stacks have resource limits. Meaning that if you have more than 500 resources in a stack, you need to move them out to a new stack. This happens with larger teams. They'll need to refactor their stacks often. - -Say you split this into two stacks. One for the functions: - -```ts -function FnStack() { - const fn = new Function(); - - return fn; -} -``` - -And one for the queues: - -```ts -function QStack() { - const fn = use(FnStack); - - const q = new SQS(); - q.consumer = new Function({ - environment: { - fn: fn.url, - } - }); - - fn.addEnvironment({ - q: q.url, - }); - - return q; -} -``` - -When you deploy an app with these two stacks, you'll get a different cyclical dependency error. Here CloudFormation cannot deploy this because these stacks depend on each other. - -A fix for this is to refactor it in a way that the queue stack can be deployed first. - -```ts -function QStack() { - const q = new SQS(); - - return q; -} -``` - -And then deploy the function stack. - -```ts -function FnStack() { - const q = use(QStack); - - const fn = new Function({ - environment: { - q: q.url, - }, - }); - - q.consumer = new Function({ - environment: { - fn: fn.url, - } - }); - - return fn; -} -``` - -Try and look at these two cases again. They look basically the same, yet one works and the other doesn't. - -The reason for this is subtle. The `addEnvironment` call in the first case *modifies* an existing resource definition. While the `q.consumer` call *adds* a new resource definition. Something that's non-obvious from looking at the code. - -> CDK is leaking implementation details from CloudFormation. - -The core problem is that CDK is leaking an implementation detail from CloudFormation. A sign that the system is poorly designed. - -#### 3. Export in Use - -Like the cyclical dependency issue `Export in use` is another dreaded error. It usually looks like this. - -```txt -Export stackA:ExportsOutput****** cannot be deleted as it is in use by stackB -``` - -Let's say there is a Bucket in theΒ `stackA`, andΒ `stackB` references itsΒ `bucket.bucketName`. You now want to remove the bucket. But if you do, you'll run into the error above. - -To fix this, you need to do two deploys. You'll need to create a *fake* export with `bucket.bucketName` in `stackA`, remove the reference in `stackB`, and deploy. Then remove the bucket and the fake export in `stackA` and deploy again. - -This happens when the references between the stacks in your CDK app change. CDK makes it really easy to share references between stacks in your app. It's a hack on top of CloudFormation that makes exports easier to use. CloudFormation also doesn't have a concept of an *app*. So it doesn't know this export has been removed in a stack that is about to be deployed. - -This error happens frequently and is incredibly non-obvious to people that are new to CDK. We realized that it's almost impossible to explain this through our docs or through support. So we built a feature in SST to auto-detect this and add the *fake* export for you. - -> CDK creates a hack on top of CloudFormation to make it easier to use. SST then adds a hack to unwind the damage caused by that hack to make CDK easier to use. - -This specific error and its subsequent handling is a microcosm of the problem with the entire model. CDK creates a hack on top of CloudFormation to make it easier to use. SST then adds a hack to unwind the damage caused by that hack to make CDK easier to use. - -#### 4. Swallowing Errors - -A consequence of CloudFormation being a black box is that it handles any errors internally. So you'll see the error from CloudFormation as opposed to the underlying error with the resource. This is the reason why many AWS deployment errors are cryptic and vague. - -Here's an example. - -```txt -Error Message: 18:59:16 UTC-0500 CREATE_FAILED AWS::Route53::RecordSetGroup DatabaseDNSRecord Invalid request -``` - -What's happening here is that there was an error within CloudFormation while creating the resource. But it swallows the real error and instead gives you the generic `Invalid request` error. - -> As a framework author, it's these types of things that drive you crazy. - -The *workaround* for this is to look at AWS CloudTrail, their audit log service. It'll show you the original event and error message. As a framework author, it's these types of things that drive you crazy. - -#### 5. Custom Resource Hacks - -So we know that CDK translates to CloudFormation that then gets executed. But what if you wanted some custom logic. For example, you have an S3 bucket that your users use for file uploads and you want to remove all the files in it when you remove your app. - -You might think you can just write some CDK code that does this. But you cannot do this natively because it cannot be expressed as a CloudFormation JSON template. To fix this there's an escape hatch called a Custom Resource. It's a Lambda function that can execute as a part of the deployment process. - -The reason it needs to be a Lambda function is because CloudFormation is a black box and it cannot run any local code. You'll need to package it up as a Lambda function. - -Still, this sounds passable. Just run some extra scripts as a workaround. In practice though, Custom resources have their own set of problems; they are slow, have side effects, and when they fail it can be crippling. Unfortunately, the CDK community (and us included) need to rely on this for basically anything that isn't supported. - -##### Hacking Multi-Region - -Custom Resources get used for something seemingly trivial like emptying a bucket to something as crazy as multi-region deployments. CDK *supports* multi-region deployments. But it does this via a Custom Resource. The problem is that CloudFormation is a single-region service. There's no way to link stacks across regions. So when you deploy stacks across regions you'll rely on Custom Resources to share references across them. - -You can see the design flaw with the CDK & CFN model here. CloudFormation is a black box and CDK has to create these hacks to work around it. - -##### Orphan Log Groups - -The Lambda functions in Custom Resources create Log Groups in CloudWatch that they write to. When you remove your app, you want to remove these Log Groups, but you can't completely remove them. If your Custom Resource tries to remove its Log Group, it'll recreate it after it finishes running. There's a similar issue with setting the log retention for Lambda functions. - -> Custom Resources are trying to create another deployment model on top of CloudFormation. - -There are other problems with Custom Resources but the core issue is that these are hacking together another deployment model on top of CloudFormation. That's a huge red flag. - -#### 6. Rollback Hell - -CloudFormation can sometimes run into issues when deploying a stack. When it does, it'll rollback all the changes it makes. This sounds good but it has two problems: - -1. It's really slow. CloudFormation deployments in general take very long and when they try to roll back, they take even longer. -2. Rollbacks can fail and get stuck because some resources might fail to rollback. If this happens you are in *rollback hell*. You won't be able to redeploy the stack. You'll need to go to the AWS Console and try to redo the rollback. If it still fails, you'll need to specifically pick the resources that are failing to rollback and tell it not to rollback. - -This is a pretty serious problem and we've gotten plenty of panicked support messages from teams that get stuck in this when they are deploying a big update to prod. People complained about this enough that CloudFormation added a setting to skip rollbacks in the case of failures. - -However, we tried this as a default with SST and immediately we had a bunch of users get into states that they couldn't get out of. We were forced to revert the change. - -Fun fact, if a Custom Resource has some faulty code you are guaranteed to be stuck in *rollback hell*. This is because on deploy, the faulty resource will fail, then it'll try to rollback the stack, and the faulty resource will run again and fail again. - -#### 7. Double Builds - -CDK will sometimes do a lookup for a resource and save that information in a `cdk.context.json`. This file is meant to be committed and acts as a cache. If the cache doesn't exist, it'll build your app to create that cache, then build again while using the cached values. You need to commit this file to your Git repo. - -However, if your deploys to prod are run in a CI environment and prod happens to be a separate AWS account, it'll always do a double build. As a developer on the team, you might not have access to prod from your local machine, meaning that you can't generate this file locally and commit it. Or commit the changes when it needs to be updated. - -> CDK tries to maintain its own state on top of CloudFormation. - -This again stems from the design flaws of the system. CloudFormation maintains state internally for your deployed resources. But since it's a black box, CDK tries to maintain its own state on top of it. - -#### 8. Stack Resource Limits - -As mentioned above, there's a resource limit of 500 for each CloudFormation stack. Say you have a Next.js site and a DynamoDB table, you might think that's 2 resources. But resources are counted in terms of the low level infrastructure that AWS needs to create these. The Next.js site creates around 68 resources. So you end up hitting this pretty quickly. - -Once you hit this limit, you'll need to split resources into multiple stacks. But that process is not intuitive. You'll likely run into the cyclical dependency issue that we mentioned above. - -#### 9. Orphan Stacks - -When you are trying to refactor your stacks, you'll be tempted to rename a stack. If you do that, CDK will just recreate all the resources in that stack with new names. And the old stack and its resources will be orphaned. - -People run into this *gotcha* all the time. The right approach here is to delete the old stack and create a new one. But what if you have resources that cannot be removed; like your database. Well you can't change the stack name. You'll need to tell CDK not to generate a new stack name and continue to use the old stack name. Your infrastructure definition will now forever have this line in it. - -Unless you reimport the resources into your new stack, which is not easy as we'll see. - -#### 10. Importing Resources - -CloudFormation keeps state internally of the resources its managing in a stack. But because this is not available locally, it introduces some problems. The biggest one is importing resources. As in, adding a previously created resource to a CloudFormation stack. SST users try to do this frequently because they need to link to previously created resources in their app. - -In theory an import should be simple. Just tell CloudFormation about a new resource and it'll manage it moving forward. In practice though it's extremely painful. You need to mock the resource in your current app, generate the CloudFormation template for your app, remove any extra info from the template, go to the CloudFormation console and ask it to import resources, set a unique ID for the resource, run a diff to see if your local stack is similar to the version that CloudFormation has, and finally do a drift check to make sure they are in sync. - -In short, most people don't do this. This hurts SST as a framework, as it limits how effective it can be for an existing AWS user. - -#### 11. Slowness - -I won't spend too much time here but for a myriad of reasons CDK and CloudFormation are extremely slow. There is slow, as-in something is noticeably slow. And then there is *CloudFormation slow*. It's behaviour altering. This was maybe acceptable for a world where you bring up servers and clusters, those are expected to be slow. But if you are dealing with managed services, it really shouldn't be this slow. - -> There is slow, as-in something is noticeably slow. And then there is "CloudFormation slow". - -What's frustrating to us as framework authors is that we have no control over this. CloudFormation arbitrarily waits for resources to get updated because they optimize for the lowest common denominator use case. Imagine migrating from something like Vercel and waiting for 30 minutes for your first SST deployment. - ---- - -## Why The Change - -We've looked at all the problems that we are facing with the current CDK & CFN model. But these are not new issues. So why did we decide to make a change now? - -### Background - -Before we get into that, let me give you some background. We've worked on SST for 3 years now. You may also know us as the creators of [Seed](https://seed.run) β€” a *git push to deploy* service for serverless apps. We started Seed in 2017. Prior to it supporting SST, Seed was exclusively for [Serverless Framework](https://www.serverless.com) apps. We've seen the ups and downs of Serverless Framework and their misstep with the [Serverless Components](https://github.com/serverless/components) idea. - -If you are not familiar with that story, I'll give you the gist of it. Serverless Framework uses CloudFormation to deploy your serverless apps. At some point they decided to launch their own infrastructure deployment service, called Serverless Components. It was not based on CloudFormation or Terraform. It would run deployments through their servers (though there was a way to opt out of that). Long story short, it did not work. - -At this point you are probably wondering if we are just repeating that mistake. Having lived through that it took us a really long time to consider options outside CDK. The problems listed above, are not new, we've known them for the better part of 2 years. We've also played around with Terraform versions of SST in the past. - -There's also… - -### Supporting Non-AWS Providers - -Back in 2017, AWS had a complete stranglehold on the serverless space. And rightfully so. Today in 2024, that is less true. Other providers now have services that are better than the AWS versions. Most notably Cloudflare. Slowly but steadily they've gotten better. To the point that there is now genuine demand from the SST community wanting to use Cloudflare. We are also seeing companies that are using serverless to build their applications and they are completely not on AWS. - -To do this with the current CDK & CFN model we'd have to create Custom Resources for these providers. And as we have seen above, the Custom Resource hack is not worth it. That effectively means we'd have to go outside this model. - -We've known in the back of our minds that at some point we were going to have to do this. However this was going to be such a big change that we basically avoided thinking about it too hard. - -### What Changed - -Then something shifted over the last year, we launched [OpenNext](https://open-next.js.org). Suddenly SST became the best way to deploy not just Next.js, but Remix, Astro, SvelteKit, and more to your AWS account. - -Now some of the largest Next.js sites in the world are deployed through SST. The resource linking problem that we described up top went from a fringe concern to something that I personally have to deal with in support every single week. - -Added to that we had to ask ourselves, if we weren't limited to the CDK & CFN model could we potentially build a better Next.js experience than Vercel. And we realized that we could. Vercel has to run some complicated infrastructure to support their multi-tenant use case. SST doesn't. Next.js apps deployed with SST are not just cheaper (Vercel's enterprise pricing is absurd) but also faster. - -#### Working With Pulumi - -Also this happened. - -[SST Pulumi tweet](https://twitter.com/funcOfJoe/status/1690115160877535232) - -We decided to build a prototype a couple of months ago. We worked with the Pulumi team and founders closely to understand how their system works. We figured out how we could create a fully open source deployment experience with the Pulumi deployment engine and their bridged Terraform providers. - -You simply install the SST CLI globally, create an `sst.config.ts`, and run `sst deploy`. There's nothing else to install, there are no `node_modules`, no CDK version conflicts, no services to sign up for, and no black boxes. Everything runs on your local machine. - ---- - -## How Does Ion Work - -In Ion you define your infrastructure almost exactly like you do in SST today. Except instead of using CDK underneath it uses a TS version of the underlying Terraform provider. Note that Terraform providers are written in Go and are basically calls to the AWS SDK. There's some additional code to make sure these run safely, so you aren't hammering AWS. - -When you run `sst deploy`, those resources make a call to an embedded Pulumi engine that makes a call to their bridged Terraform provider, and this makes the AWS SDK calls to create your resources. A _bridged Terraform provider_ is a Pulumi provider that's programmatically bridged to the underlying Terraform Go provider. - -If you are familiar with Terraform you might be wondering, isn't Terraform like CloudFormation templates in that you write JSON or HCL. When you deploy these templates through the Terraform engine, it translates these to calls to the Terraform Go providers for those resources. In Ion's case we don't use the Terraform engine, we use Pulumi. - -> You don't need to install Pulumi or Terraform or sign up for anything. - -You don't need to install Pulumi or sign up for it, their engine is embedded in the Ion CLI. Your deployments create a state file locally that are synced with an S3 bucket in your AWS account. - -There are a couple of key things with this model that pretty much addresses all the above issues. - -1. The code is executed exactly how you write it. The deployment engine is run from your local machine and it creates the resources directly. There is no layer or service in between. -2. This simple execution order means there are no cyclical dependencies. If you have a linked resource, you need to create it in the order it is used. -3. If you want to do something like the CloudFront and Lambda function example, where you want to set the distribution URL back into the function environment, you'll need to create a *dynamic provider*, this is basically code that's going to run locally after those resources have both been created. Again, the code you write is what's being executed and deployed. It's Infrastructure as Code. -4. Any deployment errors are displayed directly and in full. -5. Importing resources is a lot easier because you have visibility and control over the state of your deployment. - -> The code you write is what's being executed and deployed. It's Infrastructure as Code. - -This model isn't all perfect. Over the last couple of months we've had to work around some issues. But we have a couple of key tools at our disposal. - -1. We can submit PRs to Terraform providers, since these are open source. -2. There is a process of patching Terraform providers if the changes in the PR are urgent. -3. We can also fork the provider if necessary and create our own. -4. We talk to the Pulumi team regularly and can work with them to find fixes or work arounds. - -The upshot is that we are not dealing with the CloudFormation black box. So we can ultimately do something about the problems we run into. - ---- - -## Roadmap - -Let's look at where we are currently and what we've done for Ion so far. - -### Step 0: Ion Prototype Demo - -Status: *Complete* - -- Created a prototype by embedding the Pulumi engine -- Created a repo for Ion on [GitHub](https://github.com/sst/ion) -- Implemented the most complicated SST construct in Ion β€” Next.js -- Implemented a few other components, including a new Vector component based on Amazon Bedrock -- Built a complete full-stack demo application with Ion β€” [movies.sst.dev](https://movies.sst.dev) - -You can view the repo for our demo movies app on [GitHub](https://github.com/sst/demo-ai-app). The entire SST team worked on this app and it was great watching all the CDK issues we listed basically vanish. - -### Step 1: Ion General Release - -Timeline: *Couple of weeks from now* - -Here's what we need to do next for a general release. - -- Implement a few more components and CLI features -- Write up the docs -- Do a lot of testing -- Launch a new site β€” `ion.sst.dev` - -At this point you'll be able to create new apps from scratch in Ion. It'll give you a chance to try it out. We'll be directing new users that want to get started with SST to start with Ion first. - -### Step 2: Ion β†’ SST v3 - -Timeline: *Couple of months from now* - -Once Ion is stable, it'll give current SST users an opportunity to migrate their apps to Ion. We'll create some tools and documentation that'll help with this process. - -Once we feel comfortable with it and we know many people will be able to move over, we'll set a date for the SST v3 release. This is when `ion.sst.dev` will become `sst.dev` and it'll become SST v3. While SST v2's docs will be moved to a separate site. - ---- - -## What About SST v2 - -So what happens to SST v2 once Ion becomes SST v3? Here's what we are planning: - -- We'll release updates -- We'll accept PRs -- We won't add new constructs -- We won't introduce breaking changes - -There might be caveats here of course but we are planning to let the community drive a lot of what happens with SST v2. - ---- - -## What About Migrating - -Ion is obviously a big change. If you are using mostly SST constructs in your apps, the migration won't be a big problem. - -But what if you are using a ton of CDK constructs currently in your SST apps? There are two types of these: - -1. L1s or low level CDK constructs - - This is far easier to move over because the Terraform AWS providers have support for these. - -2. High level CDK constructs - - But CDK is filled with a ton of high level constructs, especially ones that use the Custom Resource hack described above to make changes that are not in CloudFormation (and also not in Terraform). - -The latter tends to be really messy. There is no way to sugar coat this. Migrating those over is not going to be easy. We'd argue that the new Ion model is better but there are no drop-in replacements for those. You could leave your old SST app around with those resources and not move them over. They'll continue to work because SST v2 isn't going anywhere. - -We'll share more details on the migrations steps through the Ion docs. But in the long run you might have to make a choice. - -### Is Ion Right For Me - -That brings me to something we should address directly. If your company is completely invested in the CDK & CFN model and you were using SST because of its strong ties to CDK; Ion is probably not going to be right for you. We'd still invite you to give it a try and build something non-trivial with it. But we know some folks are married to CDK. - -In this case, the solution would be to migrate your SST apps to CDK when you can. At the end of the day, SST v2 is open source and built on CDK. We chose this architecture because we did not want you to be locked in to us in case something happened. - -### What Ion Is Not - -It's also worth mentioning what we are not trying to be. We are not trying to be an extension of CDK or Terraform or Pulumi. We are not AWS purists. - -So if you are choosing SST or Ion because it's basically CDK or Terraform but *nicer*, you might end up disappointed. SST is fundamentally trying to create something that didn't exist before. We've discovered many of our design patterns as a result of our personal experience with building products and working with teams that are doing the same. - ---- - -## What's Our Goal - -So then what is our goal? Why are we doing all of this? - -We want SST to be the best way to deploy an application. Let's take an example. This `sst.config.ts` is based on the movies demo from above. It includes AWS, OpenAI, and Cloudflare as components. - -```ts -const db = new aws.dynamodb.Table("Movies"); - -const bucket = new sst.Bucket("Assets"); - -const vector = new sst.Vector("Vector", { - openAiApiKey: new sst.Secret("OpenAiApiKey").value, -}); - -const site = new sst.Nextjs("Web", { - link: [db, bucket, vector], -}); - -new cloudflare.cdn("Cdn", { - domain: "movies.sst.dev", - route: { - "/": site.url, - }, -}); -``` - -We want you to be able to drop a single type-safe config file in your repo root, and run `sst deploy`. This should be able to create any kind of resource, in any cloud provider, and link them all together. We also want you to be able to customize any of this to the degree that the provider will let you. - -> Drop a type-safe config file and deploy it with a single command. - -We want the best possible developer experience for this idea. And to accomplish it we need to bet on tools that we think will get us there. - ---- - -## FAQ - -I'm sure you have a lot of questions. I'm going to try and add to this section as I address more of them. - -### 1. Is Ion completely open source and self hosted? - -Yes it's open source and it'll run on your local machine without you having to sign up for anything Pulumi or Terraform related. - -### 2. Our company only uses AWS, can we still use Ion? - -Yes. While Ion will support multiple providers, if you are using AWS it will deploy completely to your AWS account. There won't be any other services or providers involved outside of the one you choose. - -### 3. Isn't Terraform not open source anymore? - -There's been some recent fallout from the Terraform licensing change but that applies to the Terraform engine itself. Ion doesn't use this. - -### 4. What happens to the SST Console? - -It'll support Ion and SST v2 apps. We have some plans for making it easy to self-host the Console. We'll share more details once we launch Ion. diff --git a/www/src/content/docs/blog/moving-to-discord.mdx b/www/src/content/docs/blog/moving-to-discord.mdx deleted file mode 100644 index 108da7e946..0000000000 --- a/www/src/content/docs/blog/moving-to-discord.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -template: splash -title: Moving to Discord -description: We are moving our Slack community to Discord! -author: jay -lastUpdated: 2022-06-23 -pagefind: false ---- - -We are moving our Slack community to [Discord](https://discord.gg/sst)! While our Slack community has grown to over 2000 members, we feel that Discord is better aligned with supporting open source communities. - -To join our Discord server, head over to: [**discord.gg/sst**](https://discord.gg/sst) - -If you are curious about why we are moving to Discord, I [shared some thoughts on this on Twitter](https://x.com/jayair/status/1535360228631379973). - -We hope to see you in [Discord](https://discord.gg/sst) soon! - -PS: The Slack community will be around while we transition. diff --git a/www/src/content/docs/blog/new-console-logs-ui.mdx b/www/src/content/docs/blog/new-console-logs-ui.mdx deleted file mode 100644 index c502989094..0000000000 --- a/www/src/content/docs/blog/new-console-logs-ui.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -template: splash -title: New Console Logs UI -description: We've updated how you view your application logs in the SST Console. -author: jay -lastUpdated: 2025-02-18 -pagefind: false ---- - -import { Image } from "astro:assets" - -import logsLight from '../../../assets/blog/sst-console-logs-light.png'; -import logsDark from '../../../assets/blog/sst-console-logs-dark.png'; - -We recently updated the logs UI in the SST Console. We've added the ability to **search**, view **log streams**, and just made it **faster**. - - - - - SST Console Logs - - -In the Console, you can view logs from your functions, containers, or any other CloudWatch log groups. We added the ability to: - -- **Search these logs** for any string. You can also set a search filter and tail the logs. This helps you debug any issues by triggering your app and watching for the generated logs -- **View log streams**. From the search results, you can jump to the log stream that the log message is coming from. Typically, for very active log groups, you'll see logs from multiple log streams interleaved together. When you view a specific log stream, you can drill down and just view the logs from that specific invocation or request. -- **Faster logs**. We've also used one of the newer CloudWatch APIs that makes fetching these logs from your account a lot faster. - ---- - -Check out the [new logs](/docs/console#logs) in the Console. diff --git a/www/src/content/docs/blog/new-sst-console.mdx b/www/src/content/docs/blog/new-sst-console.mdx deleted file mode 100644 index af77f8604f..0000000000 --- a/www/src/content/docs/blog/new-sst-console.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -template: splash -title: New SST Console -author: jay -lastUpdated: 2023-09-22 -description: The new SST Console is out. -pagefind: false ---- - -The new SST Console is out. You can [learn more](/docs/console/) about it over on our docs. - -### What is the SST Console - -The SST Console is a web based dashboard to manage your SST apps. With it you can invoke functions, debug issues, view logs, and manage all your apps with your team β€” [**console.sst.dev**](https://console.sst.dev/) - -### Features - -#### Logs - -With the SST Console, you don't need to go to CloudWatch to look at the logs for your functions. It also supports a couple of modes; _recent_, _live_, and _time intervals_. - -#### Issues - -The SST Console will automatically show you any errors in your Lambda functions in real-time. There is: - - **Nothing to setup**, no code to instrument - - **Source maps** are supported **automatically**, no need to upload - - **No impact on performance** or cold starts, since the functions aren't modified - -#### Local logs - -When the Console starts up, it checks if you are running `sst dev` locally. If so, then it'll show you real-time logs from your local terminal. - -### Open source - -The Console is built with SST, deployed with [Seed](https://seed.run), and you can [view the source on GitHub](https://github.com/sst/console). - -The codebase is also a good example of what a production SST app looks like. - -### Your team and AWS accounts - -You can create a workspace in the Console, invite your team, and connect all your AWS accounts. It'll automatically discover your SST apps. - -### Pricing - -The SST Console pricing is based on the number of times the Lambda functions in your SST apps are invoked per month. It comes with a free tier of 1M invocations. - -You can [read more about it over on the docs](/docs/console/#pricing). - -### Old Console - -The old SST Console is still accessible at [old.console.sst.dev](https://old.console.sst.dev). But we'll be moving away from it in the future. - -### Learn more - -[Learn more about the new SST Console](/docs/console/). And if you have any questions, join us over on Discord. diff --git a/www/src/content/docs/blog/open-next-v1.mdx b/www/src/content/docs/blog/open-next-v1.mdx deleted file mode 100644 index 0b6c0f5454..0000000000 --- a/www/src/content/docs/blog/open-next-v1.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: OpenNext 1.0 -template: splash -description: OpenNext is an open-source Next.js serverless adapter created by SST. -author: jay -lastUpdated: 2023-04-17 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -OpenNext 1.0 is out. You can try it now with the `NextjsSite` construct. - -## What is OpenNext - -[OpenNext](https://open-next.js.org) is an open-source Next.js serverless adapter created by the SST team. It allows you to self-host Next.js _serverlessly_. - -To celebrate the 1.0 release, we created a fun video. - - - -## Background - -Next.js does not support self-hosting your app using serverless. There have been several projects to try and fix this. However, this is not easy to do, as it requires reverse engineering how Vercel deploys Next.js internally. As a result most of these attempts have failed or have ended up as closed source paid implementations. - -The goal of OpenNext is to create a free open source, framework agnostic, serverless adapter for Next.js. - -## OpenNext 1.0 - -OpenNext was created back in December, 2022. Since then the repo has grown to over 1000 stars on GitHub. The community has really come together to ensure that OpenNext supports all of Next.js 13's features. The OpenNext channel is also one of the most active channels on our Discord. - -While OpenNext is already being used in production, the [1.0 release](https://github.com/sst/open-next/releases/tag/v1.0.0) marks a significant milestone in terms of stability and performance. - -We'd love for you to take it for a spin. - -## Get started - -Here's how you can use OpenNext to deploy your Next.js app to AWS with SST. - -```bash -npx create-next-app -npx create-sst -npx sst deploy -``` - -[**Check out the full tutorial**](/docs/start/aws/nextjs/). If you are using a different framework, check out the [other deployment options](https://github.com/sst/open-next/blob/main/README.md#deployment). - ---- - -We could use your support in maintaining OpenNext, make sure to join `#open-next` on Discord and [star us on GitHub](https://github.com/sst/open-next). diff --git a/www/src/content/docs/blog/openauth-beta.mdx b/www/src/content/docs/blog/openauth-beta.mdx deleted file mode 100644 index 9648b71a56..0000000000 --- a/www/src/content/docs/blog/openauth-beta.mdx +++ /dev/null @@ -1,64 +0,0 @@ ---- -template: splash -title: OpenAuth Beta -description: OpenAuth and the new Auth component is now in beta. -author: jay -pagefind: false -lastUpdated: 2024-12-09 ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -Today we are launching OpenAuth β€” [openauth.js.org](https://openauth.js.org/) - -A universal, standards-based auth provider. It's in beta along with the new [`Auth`](/docs/component/aws/auth) component for SST v3 that uses this. - - - ---- - -## What is OpenAuth - -[OpenAuth](https://openauth.js.org/) is a new auth provider that's built on top of OAuth 2.0. It's a single-page app that you can deploy anywhere. - - - **Universal**: You can deploy it as a standalone service or embed it into an existing application. It works with any framework or platform. - - **Self-hosted**: It runs entirely on your infrastructure and can be deployed on Node.js, Bun, AWS Lambda, or Cloudflare Workers. - - **Standards-based**: It implements the OAuth 2.0 spec and is based on web standards. So any OAuth client can use it. - - **Customizable**: It comes with prebuilt themeable UI that you can customize or opt out of. - - - -You can learn more about it over on the [OpenAuth GitHub](https://github.com/toolbeam/openauth). - ---- - -## Why build OpenAuth - -Auth has been one of the most requested features in SST. With v1 and v2 of our `Auth` components, we found that most folks wanted a standalone, easy to self-host auth provider. - -Most of the existing solutions were either libraries, or SaaS services that held your user data. And the standalone self-hosted ones were just too complicated to set up. - -We also think a universal, standards-based auth provider is something that should exist outside of SST, which is why we built OpenAuth as a separate project. - ---- - -## Using it in SST - -OpenAuth needs some minimal infrastructure to run. The new [`Auth`](/docs/component/aws/auth) component in SST v3 can do this for you. - -```ts title="sst.config.ts" -new sst.aws.Auth("MyAuth", { - domain: "auth.myapp.com", - authorizer: "src/auth.handler" -}); -``` - ---- - -## Next steps - -OpenAuth and the new `Auth` component are in beta. Over the next few weeks we'll be adding more docs, examples, and tutorials, as we finalize the API. - -If you are eager to try it out and play around, head over to the [OpenAuth README](https://github.com/toolbeam/openauth) and check out the examples. - -You can [star the repo](https://github.com/toolbeam/openauth) and [follow us on X](https://x.com/SST_dev) as we get closer to a 1.0 release. diff --git a/www/src/content/docs/blog/opennext-community.mdx b/www/src/content/docs/blog/opennext-community.mdx deleted file mode 100644 index e3b90c6927..0000000000 --- a/www/src/content/docs/blog/opennext-community.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -template: splash -title: OpenNext community -description: OpenNext is now a broader community effort. -author: jay -lastUpdated: 2024-09-24 -pagefind: false ---- - -We launched [OpenNext](https://opennext.js.org) back in April 2023 to build an open-source adapter for Next.js. - -Thanks to our community, most notable [conico974](https://github.com/conico974) and [khuezy](https://github.com/khuezy), it's now the best way to deploy your Next.js apps on AWS. - -Today OpenNext is **joined by Cloudflare and Netlify**; making it a broader community effort. They'll be publishing their adapters through OpenNext as well. - -You can support the community by: - -- Following OpenNext on GitHub: [github.com/opennextjs](https://github.com/opennextjs) -- Joining the new Discord server: [discord.gg/opennextjs](https://discord.gg/opennextjs) - -It's been great to see the community take shape around the project. diff --git a/www/src/content/docs/blog/remixsite-construct.mdx b/www/src/content/docs/blog/remixsite-construct.mdx deleted file mode 100644 index 49066af619..0000000000 --- a/www/src/content/docs/blog/remixsite-construct.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -title: RemixSite -description: The new RemixSite construct makes it easy to deploy Remix apps to AWS. -author: jay -image: /social-cards/blog/remixsite-construct.png -template: splash -lastUpdated: 2022-07-19 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -The new `RemixSite` construct makes it easy to deploy [Remix](https://remix.run) apps to AWS. - -Remix is a frontend focused framework that delivers modern web experiences but by relying on web standards. The SST community has been looking for a way to deploy a Remix app with SST. - -Recently, [Sean Matheson](https://twitter.com/controlplusb) put together a very comprehensive PR implementing an SST construct that would deploy a Remix app. - -[Frank](https://twitter.com/fanjiewang) made a couple of changes and merged the PR to officially add the `RemixSite` construct to the SST family of constructs. - -It allows you to: - -- Access other AWS resources in your Remix loaders and actions. -- Reference environment variables from your backend. -- Easily set custom domains. -- Host your Remix apps in single-region or on the Edge. - -## Launch event - -We hosted a [launch livestream on YouTube](https://www.youtube.com/watch?v=ZBbRZTTCwvU) where we did a deep dive of the construct and its features. - - - -We also, took a look at the internal architecture and the construct code. Here's roughly what we covered. - -- Intro -- Architecture -- Environment variables -- Access AWS services -- Custom domains -- Deploy to Edge -- How to get started -- Deep dive into the code -- How does it work with `sst start`? -- Why is the non-Edge setup the default? -- Should we be talk to the DB directly? -- Does the app size impact deploy time? -- What about the cache policy limit? -- Which Remix deployment target to use? -- Q&A - -The video is timestamped, so you can jump ahead. - -## Get started - -You can get started with the `RemixSite` construct by taking our example for a spin: - -``` bash -$ npx create-sst@latest --template=examples/remix-app my-sst-app -$ cd my-sst-app -$ npm install -$ npx sst start - -# Deploy to prod -$ npx sst deploy --stage prod -``` - -Also make sure to [check out the docs](/docs/). diff --git a/www/src/content/docs/blog/serverless-stack-raises-1m-to-make-it-easy-to-build-serverless-apps.mdx b/www/src/content/docs/blog/serverless-stack-raises-1m-to-make-it-easy-to-build-serverless-apps.mdx deleted file mode 100644 index 919dcee53d..0000000000 --- a/www/src/content/docs/blog/serverless-stack-raises-1m-to-make-it-easy-to-build-serverless-apps.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: SST raises $1M -description: Today we are announcing our $1M seed round. -template: splash -author: jay -lastUpdated: 2021-07-23 -pagefind: false ---- - -Today we are announcing our $1M seed round. The new funding helps us in our mission to make it easy for developers to build full-stack serverless applications. You can [read more about this announcement over on TechCrunch](https://techcrunch.com/2021/07/23/serverless-stack-raises-1m-for-open-source-application-framework/) as well. - -Our SST allows developers to test and make changes to their applications by directly connecting their local machines to the cloud. The biggest issue that developers face while adopting serverless is the ability to debug their applications locally. With SST, developers are able to [set breakpoints and inspect their code](https://youtu.be/2w4A06IsBlU), just as they would with any other type of application. Since its public launch 5 months ago, SST has grown to over 2K stars on GitHub and has been downloaded over 60K times. - -We would like to take this opportunity to thank SST community for being involved right from day one. We couldn't have built SST without you. Your continued feedback has pushed us to improve every part of the framework. It has also allowed us to truly understand the problems developers face while trying to adopt serverless. Also thanks to you, our Slack community has grown to nearly 500 members and is a welcoming space for anybody that's looking to use serverless. - -As more and more developers discover and adopt SST's [live local development environment](/docs/live/); our team is committed to adding features to support their workflow. This commitment shows clearly in [our rapid release history](https://github.com/sst/sst/releases). - -We are also incredibly proud of what we've built with the SST Guide, it is the most widely read resource for serverless. And [Seed](https://seed.run); the best way for teams to deploy and manage their serverless applications. - -The new funding allows us to expand the team to better serve the community and ensure that you have everything you need to build serverless applications. So if you are excited about where we are heading and would like to help our cause, **we would like you to join our team**! diff --git a/www/src/content/docs/blog/sst-dev.mdx b/www/src/content/docs/blog/sst-dev.mdx deleted file mode 100644 index ae0c5ddfd6..0000000000 --- a/www/src/content/docs/blog/sst-dev.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: SST.dev -author: jay -template: splash -lastUpdated: 2022-06-25 -description: We are officially changing our name from Serverless Stack to SST. -pagefind: false ---- - -We are now officially changing our name from Serverless Stack to SST. We are also moving our domain from [serverless-stack.com](https://serverless-stack.com) to [sst.dev](https://sst.dev). - -We were previously called Serverless Stack and we were hosted at serverless-stack.com. Aside from being really long, it was also easy to confuse us with the Serverless Framework folks. We've been informally using SST but now with the new domain, we can make the change official! - -You can call us **SST** and visit us at [**sst.dev**](https://sst.dev)! diff --git a/www/src/content/docs/blog/sst-v1.mdx b/www/src/content/docs/blog/sst-v1.mdx deleted file mode 100644 index 0676f996ff..0000000000 --- a/www/src/content/docs/blog/sst-v1.mdx +++ /dev/null @@ -1,84 +0,0 @@ ---- -template: splash -title: SST v1 -description: SST officially hits v1. -author: jay -lastUpdated: 2022-05-16 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -SST has now officially hit v1. Join us at the [SST 1.0 Conf](https://v1conf.sst.dev) as we celebrate its launch! - - - -A huge thanks to everybody that helped test out the v1 beta versions! - -## Background - -SST was released a little over a year ago. Since then we’ve added [a web based dashboard](/docs/console/) and dozens of constructs! - -While SST has been remarkably stable since its early releases, we learnt that there were some inconsistencies and confusing bits in the API. We also felt like we could do a better job of providing inline documentation. - -## Goals - -SST v1 addresses this by: - -- Making it easy to connect stacks -- Adding consistent interfaces for: - - Underlying AWS resources - - Underlying AWS resource names and ARNs -- Reducing the need for CDK imports -- Supporting inline TS Docs -- Laying the foundation for full typesafety - -You can read more about SST v1’s goals over on the docs. - -## Migrating - -Migrating to v1 should be very straightforward. Most of the changes are reorganizing and renaming construct properties, attributes, and adding TS Docs. The underlying resources (ie. the CloudFormation template) are mostly not impacted. There should be zero downtime during the upgrade. - -You can follow the steps in the migration guide to update. - -## SST v1 - -With the v1 release of SST, we’ve put together the key building blocks you need to create full-stack serverless applications. Let’s take a quick look at what SST v1 can do for you. - -### Easy to use Constructs - -At the heart of SST are its easy to use constructs. These allow you to define the infrastructure that your application needs. - -These constructs also come with great editor support. So you can both auto-complete on fields and read the docs inline. - - - -### Functional Stacks - -In native CDK, stacks are defined as classes. This requires a great deal of boilerplate code and makes it confusing to reference resources across stacks. To simplify this, SST v1 introduces the concept of Functional Stacks. - - - -### SST Console - -SST also comes with a web based dashboard to manage your apps. - - - -### Live Lambda Dev - -When you run `sst start`, it’ll start up the [Live Lambda Development](/docs/live) environment. This allows you to set breakpoints and test your Lambda functions locally. - - - -## SST 1.0 Conf - -To commemorate SST hitting v1 we are holding the [**SST 1.0 Conf**](https://v1conf.sst.dev). It’s a free virtual event filled with talks from the community including folks from Comcast, LEGO, Analog Devices, and Shell. - -It's streaming live on May 17th at 9am PDT. We hope to see you there! - -## Looking ahead - -It’s been an amazing year for SST. When I think about everything we’ve accomplished, I can’t help but wonder that it wouldn’t have happened without our community! A huge thanks to all of you for your support. - -We have some really exciting updates in store for you as we step into this new phase of development for SST. We’ll be sharing more about our direction in the coming weeks and we are giving a sneak peek at the [SST 1.0 Conf](https://v1conf.sst.dev). So stay tuned! diff --git a/www/src/content/docs/blog/sst-v2-preview.mdx b/www/src/content/docs/blog/sst-v2-preview.mdx deleted file mode 100644 index e295f6a6cc..0000000000 --- a/www/src/content/docs/blog/sst-v2-preview.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: SST v2 Preview -description: As the first episode of our new series, we are showing off a preview of SST's upcoming v2 release. -template: splash -author: jay -lastUpdated: 2022-12-06 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -As the first episode of the [Is serverless ready?](https://isserverlessready.com) series, we are showing off a preview of SST's upcoming v2 release. - -You can check it out on YouTube here. - - - -The video is timestamped and here's roughly what's going to be released as a part of SST v2: - -1. **Monopackage** β€” SST is now going to use a monopackage. Moving from `@serverless-stack` to simply `sst`. -1. **New config** β€” There's a new config file. A `.js` file instead of the `.json`. Similar to what Vite has. -1. **New functions API** β€” We've refactored the props in the SST Functions construct. -1. **Improved codegen** β€” We've reworked how SST codegens your types. -1. **pnpm support** β€” We've made SST compatible with [pnpm](https://pnpm.io). We've internally migrated to pnpm as well! -1. **New CLI UI** β€” There's an all new CLI UI, that makes it easier to figure out what the CLI is doing. -1. **Faster CLI** β€” We've refactored the entire CLI codebase and optimized for speed. It's a lot faster than before. -1. **Faster Live Lambda Dev** β€” We've also adopted a new debug stack infrastructure, so [Live Lambda Dev](/docs/live/) is now way faster than before! -1. **Building modern frontends** β€” We are also going to be introducing new constructs for [Astro](https://astro.build) and [Solid](https://www.solidjs.com). -1. **OpenNext** β€” We also launched a new open source initiative called [OpenNext](https://open-next.js.org) to allow Next.js apps to work on AWS, exactly like they do on Vercel. - -SST v2 is now in beta and we need your help testing it. So **make sure to join us on Discord and take it for a spin**. diff --git a/www/src/content/docs/blog/sst-v2.mdx b/www/src/content/docs/blog/sst-v2.mdx deleted file mode 100644 index 0f0c5ae3b7..0000000000 --- a/www/src/content/docs/blog/sst-v2.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: SST v2 -description: "SST v2 is ready. Here's what's new and how you can learn more about it." -lastUpdated: 2023-02-27 -template: splash -author: jay -cover: /social-cards/blog/sst-v2.png -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -SST v2 is ready. Here's what's new and how you can learn more about it. - -## What is SST v2 - -We completely rewrote SST to be simpler, faster, and easier to work with. [Check out this video](https://youtu.be/v97-SJY1Mb0) to get a quick sense of what SST v2 is all about. - - - -Adam and Dax also did a whole [podcast on SST v2](https://tomorrow.fm/8) and the rewrite process. - -We also did a [launch livestream](https://www.youtube.com/watch?v=v6oqlnY6-Vc) where we talked about what's new in v2, how to upgrade, and deep dive into the new codebase. We also answered some questions from the community. - - - ---- - -## Upgrade to v2 - -In general most of the changes are ergonomic and it should be a pretty simple upgrade process. Check out our docs for the **upgrade guide**. - ---- - -## Features - -Here's a quick rundown of the major changes. - -- **Monopackage** - - The first major change is that we are moving to a new npm package β€” [**`sst`**](https://www.npmjs.com/package/sst) - - We are also moving to a monopackage architecture. So instead of installing `@serverless-stack/cli` or `@serverless-stack/resources`; you simply need to install `sst`. - - All the constructs can be imported from `sst/constructs`. And the Node client is under `sst/node`. - -- **New CLI** - - This new package also powers a brand new CLI. It's faster and has a cleaner UI to go with it. - - ```bash - SST v2.0.38 ready! - - β†’ App: my-sst-app - Stage: Jay - Console: https://console.sst.dev/my-sst-app/Jay - - βœ“ Deployed: - Database - Api - API: https://4f574d6lqc.execute-api.us-east-1.amazonaws.com - Web - SITE: https://localhost:3000 - ``` - -- **Faster Live Lambda** - - We've reworked how [Live Lambda](/docs/live/) works! It's a lot faster than before and it does not need to deploy any new infrastructure for it. So no more _Debug Stack_! - - You can [read more about the changes here](/docs/live/). - -- **`sst.config.ts`** - - We've also changed how you configure your SST apps. We've replaced the old `sst.json` with a `sst.config.ts`. - - ```typescript - export default { - config(_input) { - return { - name: "my-sst-app", - region: "us-east-1", - }; - }, - stacks(app) { - app.stack(Database).stack(Api).stack(Web); - }, - } satisfies SSTConfig; - ``` - -- **New frontends** - - With SST v2, we've upgraded support for all the modern frontends out there. Our `NextjsSite` construct supports Next.js 13, thanks to our new [OpenNext](https://open-next.js.org) project. - - We also added a `AstroSite` construct for [Astro](https://astro.build) and the `SolidStartSite` construct for [Solid](https://www.solidjs.com). - -- **pnpm support** - - SST now natively supports [pnpm](https://pnpm.io)! Our new monorepo templates are now built to work with pnpm as well. - -- _**And more...**_ - - There's also a new cleaned up functions API, a better way to generate types, and more. For all the details check out this preview of SST v2 we did recently. - - - ---- - -[**Seed**](https://seed.run) also [supports SST v2](https://seed.run/blog/sst-v2-support). So go ahead and upgrade your apps and **join us on Discord** if you have any questions! diff --git a/www/src/content/docs/blog/sst-v3.mdx b/www/src/content/docs/blog/sst-v3.mdx deleted file mode 100644 index 8a60eed229..0000000000 --- a/www/src/content/docs/blog/sst-v3.mdx +++ /dev/null @@ -1,188 +0,0 @@ ---- -template: splash -title: SST v3 -description: Ion is now officially SST v3. -author: jay -lastUpdated: 2024-08-20 -pagefind: false ---- - -import config from '../../../../config.ts'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; -import { YouTube } from '@astro-community/astro-embed-youtube'; - -Earlier this year we had [announced](/blog/moving-away-from-cdk) that we were working on a new deployment engine for SST called Ion. After months of testing and a gradual rollout, Ion is now officially being released as SST v3. - ---- - -## Background - -SST was built on AWS CDK and CloudFormation. But after nearly 3 years of working with CDK and CloudFormation we hit some of its underlying design flaws and were forced to look at alternatives. We talked about this at length in a [**previous blog post**](/blog/moving-away-from-cdk). - -Late last year we started work on a new deployment engine that would use [Pulumi](https://www.pulumi.com) and [Terraform](https://www.terraform.io), as opposed to CDK and CloudFormation. - -### How We Got Here - -This new deployment engine, code named Ion has now been around for roughly half a year. And for the past few months we've been recommending people start new projects with Ion instead. - -> The number of people using Ion is close to the number of people using v2. - -Fast forward to today, and the number of people actively using Ion is fairly close to the number of people using SST v2. Ion is also being used in production by a sizeable number of teams. - -However given the nature of the change, the plan has been to get to a place where we'd feel comfortable enough to recommend migrating to Ion. - ---- - -## Ion β†’ SST v3 - -After months of hard work, we are finally here. We are now releasing Ion as SST v3. - -> The simpler deployment model has also led to far fewer gotchas. - -Aside from being a lot faster, v3 addressed most of the issues that we had found with the CDK and CFN setup. The simpler deployment model has also led to far fewer _gotchas_. And it has allowed us to expand past AWS and support the broader ecosystem. - -Along with the v3 release, we're also making a couple of changes to our websites, how we do support, the SST Console, and more. In this post we'll go over all of these changes and the migration process. - -### New Docs - -Starting with the first big change, [ion.sst.dev](https://ion.sst.dev) is now just [sst.dev](https://sst.dev). You might've already noticed the new design. - -The docs, [sst.dev/docs](/docs/) are also brand new. The API and reference docs are completely generated from code. This means that they're always up to date and you can view them inline in your code editor. - ---- - -## Major Changes - -As expected, there are some major changes in v3. - -1. **No CloudFormation** - - This one is obvious but it means that there are no stacks and no resource limits. The deployment happens right from your local machine. And the state is stored locally and backed up to S3 in your AWS account. - -2. **No CDK** - - There are no CDK constructs. Instead there is an AWS provider from Pulumi that's built on Terraform. These are like your CDK L1 constructs. That said, the Pulumi/Terraform ecosystem is fairly complete. Aside from AWS, SST now supports [**150+ other providers**](/docs/all-providers#directory). - -3. `sst.config.ts` - - The structure of the SST config has changed a little. - - - - ```ts title="sst.config.ts" - export default $config({ - // Your app's config - app(input) { - return { - name: "my-sst-app", - home: "aws" - }; - }, - // Your app's resources - async run() { } - }); - ``` - - - ```ts title="sst.config.ts" - export default { - // Your app's config - config(_input) { - return { - name: "my-sst-app", - region: "us-east-1" - }; - }, - // Your app's resources - stacks(app) { } - } satisfies SSTConfig; - ``` - - - -4. `sst dev` - - The `sst dev` CLI now runs a _multiplexer_ that deploys your app and runs your frontends locally. So now you don't have to run `sst dev` and then go start your frontend. You also don't need to wrap your frontend's `dev` script with `sst bind`. - -And more. We have a section in our [migration doc](/docs/migrate-from-v2#major-changes) that goes over all the changes in detail. - ---- - -## Learn More - -Given that v3 is such a big change, we've got a couple of resources that can help you learn more about it. - -These are great for getting started with SST in general. But we also recommend checking them out even if you've been using v2. - -- **Docs** - - Start with the [What is SST](/docs/) and [Basics](/docs/basics/) docs. These give you a good overview and lead you to other docs that expand on the various concepts. - -- **Guide** - - Our [SST Guide](https://guide.sst.dev) has been updated to use v3. It teaches you how to build a full-stack app on AWS with SST. - -- **Video** - - To get a more in-depth look at a v3 app in production, we put together this video detailing how [terminal](https://www.terminal.shop) was built with v3. It's comprehensive and you can [view the repo on GitHub](https://github.com/terminaldotshop/terminal) as well. - - - ---- - -## Migration - -We've created a [**detailed migration guide**](/docs/migrate-from-v2) on how to migrate your v2 apps to v3. - -> It's a lot simpler to import resources. - -One of the biggest advantages with this new deployment engine is that it's a lot simpler to [import resources](/docs/import-resources). This makes migrating to v3 easier. - -That said, there are some caveats: - -- If you were heavily reliant on L3 CDK Constructs in your SST apps, it's going to be hard to find direct replacements for those in the Pulumi/Terraform ecosystem. -- There are something that aren't supported yet. But they are on our roadmap. - - Some constructs; like `Job`, `Auth`, `EventBus` that we haven't added support for yet. - - Non-Node runtimes for Lambda functions aren't supported yet either. - - SST v3 does not work on Windows yet, you'll need to use WSL. - ---- - -## Support - -We know that you are going to need some help migrating to v3. To prepare for this we've made some changes to how we do support. - -We are now using GitHub Issues as our primary channel. We've been using it while working on Ion and we are using it to track both issues and feature requests. - -We also streamlined our Discord channels. Instead of having separate channels for the different parts of SST, you can just post your questions in `#general`. - ---- - -## Console - -The [**Console**](/docs/console/) has also been updated to support v3. There are a couple of key things that the Console does a better job of with v3 apps. - -1. **Resources**: - The Console shows you all the resources in your app, not just the SST components. This includes the outputs of each of the resources as well. -2. **Updates**: - You can also see all the updates that are made to your app along with the resources that've been changed. So you can see when a resource was added, removed, or modified. -3. **Autodeploy**: - You can now connect your GitHub repo to the Console and it'll auto-deploy your v3 apps when you _git push_ to it. You can also customize this workflow through your `sst.config.ts`. - -If you are using [Seed](https://seed.run) to deploy your SST v2 apps, we recommend migrating over to the Console for v3. We are currently not planning to support v3 in Seed. - ---- - -## What About v2 - -The v3 migration is not simple and there are likely a few of you that won't be able to make the change. So we are planning on keeping v2 updated. - -We'll accept PRs and release updates. But we won't add new constructs or introduce breaking changes. - -The SST v2 docs have been moved to [v2.sst.dev](https://v2.sst.dev). - ---- - -We know this is a big change and you might have some concerns about it. Feel free to join us on Discord and we'll be happy to address them. - -If you are an enterprise you can **get in touch with us directly via email** as well. diff --git a/www/src/content/docs/blog/tasks-in-v3.mdx b/www/src/content/docs/blog/tasks-in-v3.mdx deleted file mode 100644 index d329d33701..0000000000 --- a/www/src/content/docs/blog/tasks-in-v3.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -template: splash -title: Tasks in v3 -description: We are adding a new component that allows you to run asynchronous tasks. -author: jay -lastUpdated: 2024-12-29 -pagefind: false ---- - -import { Image } from "astro:assets"; -import { YouTube } from "@astro-community/astro-embed-youtube"; -import cliImage from "../../../assets/blog/task-cli.png"; -import consoleImage from "../../../assets/blog/task-console.png"; - -We are adding [`Task`](/docs/component/aws/cluster#tasks), a new component, powered by AWS Fargate that allows you to run asynchronous tasks in your apps. Here's a video where we talk about this and async jobs in general. - - - -## Background - -Most applications have a need to run some background tasks. Typically these take a long time to run so they are triggered asynchronously. Or they are invoked through a cron job. Unfortunately you can't run them in a Lambda function because they might take longer than 15 minutes. - -And since these are triggered asynchronously, they can be harder to test locally. You can mock their invocation but it'd be much better to test them through the usual flow of your application. - -To fix this, we are adding the new [`Task`](/docs/component/aws/cluster#tasks) component. - ---- - -## `Task` - -1. It uses AWS Fargate that can **run as long** as you need and is **cheaper than Lambda**. -2. Can be invoked directly from a **cron job**. -3. Comes with a **JS SDK**, but can also be invoked with the AWS SDK. -4. Has its **own dev mode**, so it can be invoked remotely but it'll run locally. - -You can [**check out an example**](/docs/examples/#aws-task) if you want a quick start. - ---- - -## Getting started - -Tasks are built on AWS Fargate and are tied to an Amazon ECS cluster. And so `Task` is created as a part of the `Cluster` component. - -#### Create a task - -```ts title="sst.config.ts" -const cluster = new sst.aws.Cluster("MyCluster", { vpc }); -const task = new sst.aws.Task("MyTask", { cluster }); -``` - -By default, this looks for a `Dockerfile` in the root directory. You can configure this. - -```ts title="sst.config.ts" -new sst.aws.Task("MyTask", { - cluster, - image: { - context: "./app", - dockerfile: "Dockerfile", - }, -}); -``` - ---- - -#### Run the task - -Once created, you can run the task through: - -1. **Task SDK** - - With the [Task JS SDK](/docs/component/aws/task#sdk), you can run your tasks, stop your tasks, and get the status of your tasks. - - You can call this from your functions, frontends, or container services. For example, you can link the task to a function. - - ```ts title="sst.config.ts" {3} - new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - link: [task], - }); - ``` - - Then from your function start the task. - - ```ts title="src/lambda.ts" {4} - import { Resource } from "sst"; - import { task } from "sst/aws/task"; - - const runRet = await task.run(Resource.MyTask); - const taskArn = runRet.tasks[0].taskArn; - ``` - - **Other languages** - - The JS SDK is calling the AWS ECS SDK behind the scenes. So if you are using a different language, you can directly call the AWS SDK. Here's [how to run a task](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html). - -2. **Cron jobs** - - You can also connect your task to a [`Cron`](/docs/component/aws/cron) job. - - ```ts title="sst.config.ts" {2} - new sst.aws.Cron("MyCronJob", { - task, - schedule: "rate(1 day)", - }); - ``` - - This works by connecting the task to the cron job through EventBridge. - ---- - -## Dev mode - -You can test your tasks locally in `sst dev` in a similar way to how you test your functions [_Live_](/docs/live/). - -SST Dev CLI Tasks tab - -Any tasks that are invoked remotely are proxied to your local machine that runs the `dev.command` you have. These also show up under the **Tasks** tab in the multiplexer sidebar. - -```ts title="sst.config.ts" {3} -new sst.aws.Task("MyTask", { - dev: { - command: "node src/tasks.js", - }, -}); -``` - -If your `Vpc` has `bastion` enabled, then your tasks have access to resources in your VPC as well. - ---- - -## Console logs - -The [Console](/docs/console/) supports viewing logs for your tasks when they are in production. - -SST Console Task logs - ---- - -## Cost - -You are only charged for the time it takes to run the task. With the default memory and vCPU it costs roughly **$0.02 per hour**. - -When running in `sst dev`, you are charged for the time it takes to run the task locally as well. - ---- - -## Next steps - -Learn more in our docs. - -- [Adding a task](/docs/component/aws/cluster/#tasks) -- [Dev mode](/docs/component/aws/cluster/#dev-1) -- [JS SDK](/docs/component/aws/task/#sdk) -- [Cost](/docs/component/aws/cluster/#cost) - -And check out these examples. - -- [Invoking a task with a function](/docs/examples/#aws-task) -- [Invoking a task with a cron job](/docs/examples/#aws-task-cron) - ---- - -#### Comparison to v2 - -If you are coming from SST v2, there are a couple of differences between `Task` and [`Job`](https://v2.sst.dev/constructs/Job). - -1. `Task` is based on AWS Fargate. `Job` used a combination of AWS CodeBuild and Lambda. -2. Since `Task` is natively based on Fargate, you can use the AWS SDK to interact with it, even in runtimes the SST SDK doesn't support. -3. In dev mode, `Task` uses Fargate only, whereas `Job` used Lambda. -4. While CodeBuild is billed per minute, Fargate is a lot cheaper than CodeBuild. Roughly **$0.02 per hour** vs **$0.3 per hour** on X86 machines. diff --git a/www/src/content/docs/blog/testing-in-sst.mdx b/www/src/content/docs/blog/testing-in-sst.mdx deleted file mode 100644 index 3140836a9c..0000000000 --- a/www/src/content/docs/blog/testing-in-sst.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -template: splash -title: Testing in SST -author: jay -description: You can write tests for your SST apps using a new CLI that auto-loads the secrets and config. -image: /social-cards/blog/sst-testing.png -lastUpdated: 2022-08-29 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -You can write tests for your SST apps using the new `sst load-config` CLI. It auto-loads secrets and config for your tests. - -Meaning that it'll load the `Config` of your app, but for your tests. - -So for example, this command loads your `Config` and runs your tests using [Vitest](https://vitest.dev). - -```bash -$ sst load-config -- vitest run -``` - -Also, make sure to check out our launch announcement for `Config` in case you missed it. - -We updated the `create sst` GraphQL starter to include the updated `npm test` script. - -```js -"test": "sst load-config -- vitest run" -``` - -We also have a new chapter in our docs dedicated to testing. It includes how to write tests for the different parts of your app: - -- Tests for your domain code. Recall that we recommend Domain Driven Design. -- Tests for your APIs, the endpoints handling requests. -- Tests for your stacks, the code that creates your infrastructure. - -## Launch event - -We hosted a [launch livestream on YouTube](https://www.youtube.com/watch?v=YtaxDURRjHA) where we talked about how to write tests for your SST apps. - - - -The video is timestamped and here's roughly what we covered. - -1. Intro -2. Setting up a new app -3. Testing domain code -4. Testing APIs -5. Testing stacks -6. Deep dive into `sst load-config` -7. Q&A - 1. How to test asynchronous workflow? - 2. How to run tests in parallel? - -## Get started - -To get started, create a new SST app with our GraphQL starter. - -```bash -$ npx create-sst@latest -``` - -Make sure to select the `graphql` and `DynamoDB` option. - -Next, install the dependencies. - -```bash -$ cd my-sst-app -$ npm install -``` - -Let's deploy the app once. This'll create all the infrastructure for your app and the `Config`. Recall that we use AWS SSM to store our secrets and parameters. - -```bash -$ npm run deploy -``` - -And you can run your tests by running: - -```bash -npm test -``` - -Make sure to check out the sample test included with the starter to get a sense of how it all works! - -To learn more [**check out our docs**](/docs/). diff --git a/www/src/content/docs/blog/update-permalinks.mdx b/www/src/content/docs/blog/update-permalinks.mdx deleted file mode 100644 index 6be6d7fa09..0000000000 --- a/www/src/content/docs/blog/update-permalinks.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -template: splash -title: Update Permalinks -description: Every update made to an SST app now gets a unique URL. -author: jay -lastUpdated: 2025-02-18 -pagefind: false ---- - -import { Image } from "astro:assets" - -import updatesLight from '../../../assets/blog/sst-console-updates-light.png'; -import updatesDark from '../../../assets/blog/sst-console-updates-dark.png'; - -Moving forward, every update made to an SST v3 app will get a unique URL; a **_permalink_**. This is printed out by the SST CLI. - -```bash title="sst deploy" -β†— Permalink https://sst.dev/u/318d3879 -``` - -These permalinks redirect to a page in the Console. [**Check out a short video**](https://x.com/thdxr/status/1891595772937863283) of this in action. - - - - - SST Console Updates - - -Here you can view: - -1. Full list of **all the resources** that were modified -2. Changes in their **inputs and outputs** -3. Any Docker or site **builds logs** -4. **CLI command** that triggered the update -5. **Git commit**, if it was an auto-deploy - -You'll need to have your AWS account connected to the Console to view these details. - ---- - -### How it helps - -The permalinks are useful for. - -1. **Debugging deploys**: The changes in the inputs of a resource let you see if the changes to your `sst.config.ts` have been applied correctly. -2. **Speeding up deploys**: You can check which resources are taking long. Or why a certain resource is being updated in the first place. -3. **Sharing with your team**: Say you run into an error while running `sst dev` locally; now you can send this link to a teammate. And they can view the full event log instead of asking you to send them the log file from your local machine. - ---- - -### How it works - -In addition to the state updates, the SST CLI also uploads the event log from every update to the [S3 state bucket](/docs/state) in your AWS account. It also generates a globally unique id for the update. - -If your AWS account is connected to the Console, it pulls this state and generates the details for the update permalink. This also means that the Console can only show you updates after your AWS account has been connected. - -When you visit the permalink, the Console looks up the id of the update and redirects you to the right app in your workspace. - ---- - -You can learn more about [updates](/docs/console/#updates) in the Console and how [state](/docs/state) works over on the [docs](/docs). diff --git a/www/src/content/docs/blog/windows-support-in-beta.mdx b/www/src/content/docs/blog/windows-support-in-beta.mdx deleted file mode 100644 index a4edd769a1..0000000000 --- a/www/src/content/docs/blog/windows-support-in-beta.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: Windows support in beta -description: SST v3 is now supported natively on Windows. -template: splash -author: jay -lastUpdated: 2025-04-28 -pagefind: false ---- - -Previously, SST v3 was only supported on Linux/macOS and Windows with WSL. With [v3.14](https://github.com/sst/sst/releases/tag/v3.14.0), native Windows support is now in beta. - -The main difference between Windows and Linux/macOS is that [`sst dev`](/docs/reference/cli#dev) does not support the tabbed terminal UI. So while, it does spawn multiple processes, it does show their output in separate tabs. - -If you are on Windows, we recommend upgrading to v3.14 and giving it a try. If you run into any problems, feel free to [open a GitHub issue](https://github.com/sst/sst/issues/new). diff --git a/www/src/content/docs/blog/wrapping-up-sst-1-0-conf.mdx b/www/src/content/docs/blog/wrapping-up-sst-1-0-conf.mdx deleted file mode 100644 index bf7ad4f026..0000000000 --- a/www/src/content/docs/blog/wrapping-up-sst-1-0-conf.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -template: splash -title: Wrapping up SST 1.0 Conf -description: Watch the recording of SST 1.0 Conf, our first-ever conference. -author: jay -image: /social-cards/blog/sst-1-0-conf-replay.png -lastUpdated: 2022-05-23 -pagefind: false ---- - -import { YouTube } from '@astro-community/astro-embed-youtube'; - -Hopefully everybody enjoyed [SST 1.0 Conf](https://v1conf.sst.dev) as much as we enjoyed putting it together. It allowed the community to come together and celebrate SST's v1 release. - -It's been a little over a year since SST launched and it's incredible to see how far it has come in this short time. SST now has over 6500 stars on GitHub, 1900 developers in Slack, and nearly 80000 folks have subscribed to our newsletter. Thousands of teams from companies like Comcast, Shell, Analog Devices, and The LEGO Group are using SST. - -### Watch the recording - -If you missed SST 1.0 Conf, don't worry you can [**watch the recording on YouTube**](https://youtu.be/6FzLjpMYcu8). - - - -All the talks are timestamped. So if you want to watch a specific talk, or rewatch one, you can do that right from YouTube. - -A huge thanks to the speakers for taking the time from their busy schedules to make this event a success. - -### Looking ahead - -Now that SST has hit v1, you might be wondering what we are doing next. We are going to be spending more time on the application code portion of your SST apps. To get an early preview of it, [check out Dax's talk from the conference](https://youtu.be/6FzLjpMYcu8?t=5182). - -SST 1.0 Conf also allowed us as a team to do a couple of things that we don't usually do. It allowed us to share a side of us that's hard to do on Slack. So moving forward we'll be sharing more about how we work. We'll be doing more livestreams and creating screencasts. You can **subscribe to our channel on YouTube**. - -### Give us your feedback - -We are already looking forward to the next SST conference. We've got a ton of ideas on what we'd like to do. But we'd appreciate if you took a second to [**give us some of your feedback on SST 1.0 Conf**](https://forms.gle/HwkDsMnsPEhzxbaPA). - -Once again, thanks to you all for attending SST 1.0 Conf and being a part of this amazing community! diff --git a/www/src/content/docs/docs/all-providers.mdx b/www/src/content/docs/docs/all-providers.mdx deleted file mode 100644 index 0d092eac34..0000000000 --- a/www/src/content/docs/docs/all-providers.mdx +++ /dev/null @@ -1,268 +0,0 @@ ---- -title: All Providers -description: Use 150+ Pulumi or Terraform providers in your app. ---- - -import VideoAside from "../../../components/VideoAside.astro"; - -Aside from the [built-in](/docs/components#built-in) components, SST supports any of the **150+** Pulumi and Terraform providers. - -Check out the full list in the [Directory](#directory). - ---- - -## Add a provider - -To add a provider to your app run. - -```bash -sst add -``` - -This command adds the provider to your config, installs the packages, and adds the namespace of the provider to your globals. - -:::caution -You don't need to `import` the provider packages in your `sst.config.ts`. -::: - -SST manages these packages internally and you do not need to import the package in your `sst.config.ts`. - -For example, to add the Stripe provider. - -```bash -sst add stripe -``` - -Read more about [providers](/docs/providers). - ---- - -### Preloaded - -SST comes preloaded with the following providers, so you **don't need to add them**. - -- [AWS](https://www.pulumi.com/registry/packages/aws/) -- [Cloudflare](https://www.pulumi.com/registry/packages/cloudflare/) - -These are used internally to power the [built-in](/docs/components#built-in) components. - ---- - -## Use a resource - -Once added, you can use a resource from the provider in your `sst.config.ts`. - -For example, use a Stripe resource in your config's `run` function. - -```ts title="sst.config.ts" {4-7} -export default $config({ - // ... - async run() { - new stripe.Product("MyStripeProduct", { - name: "SST Paid Plan", - description: "This is how SST makes money", - }); - }, -}); -``` - -As mentioned above, since the AWS provider comes preloaded, you can use any AWS resource directly as well. - -```ts title="sst.config.ts" -new aws.apprunner.Service("MyService", { - serviceName: "example", - sourceConfiguration: { - imageRepository: { - imageConfiguration: { - port: "8000" - }, - imageIdentifier: "public.ecr.aws/aws-containers/hello-app-runner:latest", - imageRepositoryType: "ECR_PUBLIC" - } - } -}); -``` - ---- - -## Directory - -Below is the full list of providers that SST supports. - -```bash -sst add -``` - -Install any of the following using the package name as the `provider`. For example, `sst add auth0`. - -If you want SST to support a Terraform provider or update a version, you can **submit a PR** to the [sst/provider](https://github.com/sst/provider) repo. - ---- - -| Provider | Package | -|----------------------------------|------------------------------------------------------------| -| [ACI](https://www.pulumi.com/registry/packages/aci) | `@netascode/aci` | -| [ACME](https://www.pulumi.com/registry/packages/acme) | `@pulumiverse/acme` | -| [Aiven](https://www.pulumi.com/registry/packages/aiven) | `aiven` | -| [Akamai](https://www.pulumi.com/registry/packages/akamai) | `akamai` | -| [Alibaba Cloud](https://www.pulumi.com/registry/packages/alicloud) | `alicloud` | -| [Amazon EKS](https://www.pulumi.com/registry/packages/eks) | `eks` | -| [Aquasec](https://www.pulumi.com/registry/packages/aquasec) | `@pulumiverse/aquasec` | -| [Artifactory](https://www.pulumi.com/registry/packages/artifactory) | `artifactory` | -| [Astra DB](https://www.pulumi.com/registry/packages/astra) | `@pulumiverse/astra` | -| [Auth0](https://www.pulumi.com/registry/packages/auth0) | `auth0` | -| [Auto Deploy](https://www.pulumi.com/registry/packages/auto-deploy) | `auto-deploy` | -| [AWS API Gateway](https://www.pulumi.com/registry/packages/aws-apigateway) | `aws-apigateway` | -| [AWS](https://www.pulumi.com/registry/packages/aws/) | `aws` | -| [AWS Control Tower](https://www.pulumi.com/registry/packages/awscontroltower) | `@lbrlabs/pulumi-awscontroltower` | -| [AWS IAM](https://www.pulumi.com/registry/packages/aws-iam) | `aws-iam` | -| [AWS Cloud Control](https://www.pulumi.com/registry/packages/aws-native) | `aws-native` | -| [AWS QuickStart Aurora Postgres](https://www.pulumi.com/registry/packages/aws-quickstart-aurora-postgres) | `aws-quickstart-aurora-postgres` | -| [AWS QuickStart Redshift](https://www.pulumi.com/registry/packages/aws-quickstart-redshift) | `aws-quickstart-redshift` | -| [AWS QuickStart VPC](https://www.pulumi.com/registry/packages/aws-quickstart-vpc) | `aws-quickstart-vpc` | -| [AWS S3 Replicated Bucket](https://www.pulumi.com/registry/packages/aws-s3-replicated-bucket) | `aws-s3-replicated-bucket` | -| [AWS Static Website](https://www.pulumi.com/registry/packages/aws-static-website) | `aws-static-website` | -| [AWSx](https://www.pulumi.com/registry/packages/awsx) | `awsx` | -| [AzAPI](https://www.pulumi.com/registry/packages/azapi) | `@ediri/azapi` | -| [Azure Active Directory](https://www.pulumi.com/registry/packages/azuread) | `azuread` | -| [Azure Classic](https://www.pulumi.com/registry/packages/azure) | `azure` | -| [Azure Justrun](https://www.pulumi.com/registry/packages/azure-justrun) | `pulumi-azure-justrun` | -| [Azure Native](https://www.pulumi.com/registry/packages/azure-native) | `azure-native` | -| [Azure Quickstart ACR Geo Replication](https://www.pulumi.com/registry/packages/azure-quickstart-acr-geo-replication) | `azure-quickstart-acr-geo-replication` | -| [Azure QuickStart ACR Geo Replication](https://www.pulumi.com/registry/packages/azure-quickstart-acr-geo-replication/) | `azure-quickstart-acr-geo-replication` | -| [Azure Static Website](https://www.pulumi.com/registry/packages/azure-static-website) | `azure-static-website` | -| [AzureDevOps](https://www.pulumi.com/registry/packages/azuredevops) | `azuredevops` | -| [Buildkite](https://www.pulumi.com/registry/packages/buildkite) | `@pulumiverse/buildkite` | -| [Checkly](https://www.pulumi.com/registry/packages/checkly) | `@checkly/pulumi` | -| [Cisco Catalyst SD-WAN](https://www.pulumi.com/registry/packages/sdwan) | `sdwan` | -| [Cisco ISE](https://www.pulumi.com/registry/packages/ise/) | `ise` | -| [Civo](https://www.pulumi.com/registry/packages/civo) | `civo` | -| [Cloud-Init](https://www.pulumi.com/registry/packages/cloudinit) | `cloudinit` | -| [CloudAMQP](https://www.pulumi.com/registry/packages/cloudamqp) | `cloudamqp` | -| [Cloudflare](https://www.pulumi.com/registry/packages/cloudflare/) | `cloudflare` | -| [CockroachDB](https://www.pulumi.com/registry/packages/cockroach/) | `@pulumiverse/cockroach` | -| [Command](https://www.pulumi.com/registry/packages/command/) | `command` | -| [Confluent](https://www.pulumi.com/registry/packages/confluentcloud/) | `confluentcloud` | -| [Consul](https://www.pulumi.com/registry/packages/consul) | `consul` | -| [Control Plane](https://www.pulumi.com/registry/packages/cpln/) | `@pulumiverse/cpln` | -| [Databricks](https://www.pulumi.com/registry/packages/databricks) | `databricks` | -| [Datadog](https://www.pulumi.com/registry/packages/datadog) | `datadog` | -| [dbt Cloud](https://www.pulumi.com/registry/packages/dbtcloud/) | `dbtcloud` | -| [DigitalOcean](https://www.pulumi.com/registry/packages/digitalocean) | `digitalocean` | -| [DNSimple](https://www.pulumi.com/registry/packages/dnsimple) | `dnsimple` | -| [Docker](https://www.pulumi.com/registry/packages/docker) | `docker` | -| [Docker Build](https://www.pulumi.com/registry/packages/docker-build) | `docker-build` | -| [Doppler](https://www.pulumi.com/registry/packages/doppler) | `@pulumiverse/doppler` | -| [Dynatrace](https://www.pulumi.com/registry/packages/dynatrace) | `@pulumiverse/dynatrace` | -| [Elastic Cloud](https://www.pulumi.com/registry/packages/ec/) | `ec` | -| [Equinix](https://www.pulumi.com/registry/packages/equinix/) | `@equinix-labs/pulumi-equinix` | -| [ESXi Native](https://www.pulumi.com/registry/packages/esxi-native) | `@pulumiverse/esxi-native` | -| [Event Store Cloud](https://www.pulumi.com/registry/packages/eventstorecloud/) | `@eventstore/pulumi-eventstorecloud` | -| [Exoscale](https://www.pulumi.com/registry/packages/exoscale) | `@pulumiverse/exoscale` | -| [F5 BIG-IP](https://www.pulumi.com/registry/packages/f5bigip) | `f5bigip` | -| [Fastly](https://www.pulumi.com/registry/packages/fastly) | `fastly` | -| [Flux](https://www.pulumi.com/registry/packages/flux) | `@worawat/flux` | -| [Fortios](https://www.pulumi.com/registry/packages/fortios) | `@pulumiverse/fortios` | -| [FusionAuth](https://www.pulumi.com/registry/packages/fusionauth) | `pulumi-fusionauth` | -| [Gandi](https://www.pulumi.com/registry/packages/gandi) | `@pulumiverse/gandi` | -| [GCP Global CloudRun](https://www.pulumi.com/registry/packages/gcp-global-cloudrun) | `gcp-global-cloudrun` | -| [Genesis Cloud](https://www.pulumi.com/registry/packages/genesiscloud/) | `@genesiscloud/pulumi-genesiscloud` | -| [GitHub](https://www.pulumi.com/registry/packages/github) | `github` | -| [GitLab](https://www.pulumi.com/registry/packages/gitlab) | `gitlab` | -| [Google Cloud Classic](https://www.pulumi.com/registry/packages/gcp) | `gcp` | -| [Google Cloud Native](https://www.pulumi.com/registry/packages/google-native/) | `google-native` | -| [Google Cloud Static Website](https://www.pulumi.com/registry/packages/google-cloud-static-website/) | `google-cloud-static-website` | -| [Grafana](https://www.pulumi.com/registry/packages/grafana) | `@pulumiverse/grafana` | -| [Harbor](https://www.pulumi.com/registry/packages/harbor) | `@pulumiverse/harbor` | -| [Harness](https://www.pulumi.com/registry/packages/harness) | `harness` | -| [HashiCorp Vault](https://www.pulumi.com/registry/packages/vault) | `vault` | -| [HCP](https://www.pulumi.com/registry/packages/hcp) | `@grapl/pulumi-hcp` | -| [Hetzner Cloud](https://www.pulumi.com/registry/packages/hcloud) | `hcloud` | -| [Impart Security](https://www.pulumi.com/registry/packages/impart/) | `@impart-security/pulumi-impart` | -| [InfluxDB](https://www.pulumi.com/registry/packages/influxdb) | `@komminarlabs/influxdb` | -| [Kafka](https://www.pulumi.com/registry/packages/kafka) | `kafka` | -| [Keycloak](https://www.pulumi.com/registry/packages/keycloak) | `keycloak` | -| [Kong](https://www.pulumi.com/registry/packages/kong) | `kong` | -| [Koyeb](https://www.pulumi.com/registry/packages/koyeb) | `@koyeb/pulumi-koyeb` | -| [Kubernetes](https://www.pulumi.com/registry/packages/kubernetes) | `kubernetes` | -| [Kubernetes Cert Manager](https://www.pulumi.com/registry/packages/kubernetes-cert-manager) | `kubernetes-cert-manager` | -| [Kubernetes CoreDNS](https://www.pulumi.com/registry/packages/kubernetes-coredns) | `kubernetes-coredns` | -| [LaunchDarkly](https://registry.terraform.io/providers/launchdarkly/launchdarkly) | `lauchdarkly` | -| [LBr Labs EKS](https://www.pulumi.com/registry/packages/lbrlabs-eks) | `@lbrlabs/pulumi-eks` | -| [libvirt](https://www.pulumi.com/registry/packages/libvirt) | `libvirt` | -| [Linode](https://www.pulumi.com/registry/packages/linode) | `linode` | -| [Mailgun](https://www.pulumi.com/registry/packages/mailgun) | `mailgun` | -| [Matchbox](https://www.pulumi.com/registry/packages/matchbox) | `@pulumiverse/matchbox` | -| [Miniflux](https://www.pulumi.com/registry/packages/aws-miniflux/) | `aws-miniflux` | -| [MinIO](https://www.pulumi.com/registry/packages/minio) | `minio` | -| [MongoDB Atlas](https://www.pulumi.com/registry/packages/mongodbatlas) | `mongodbatlas` | -| [MSSQL](https://www.pulumi.com/registry/packages/mssql) | `@pulumiverse/mssql` | -| [MySQL](https://www.pulumi.com/registry/packages/mysql) | `mysql` | -| [Neon](https://www.pulumi.com/registry/packages/neon) | `neon` | -| [New Relic](https://www.pulumi.com/registry/packages/newrelic) | `newrelic` | -| [NGINX Ingress Controller](https://www.pulumi.com/registry/packages/kubernetes-ingress-nginx/) | `kubernetes-ingress-nginx` | -| [ngrok](https://www.pulumi.com/registry/packages/ngrok) | `@pierskarsenbarg/ngrok` | -| [Nomad](https://www.pulumi.com/registry/packages/nomad) | `nomad` | -| [NS1](https://www.pulumi.com/registry/packages/ns1) | `ns1` | -| [Nuage](https://www.pulumi.com/registry/packages/nuage) | `nuage` | -| [Nutanix](https://www.pulumi.com/registry/packages/nutanix) | `@pierskarsenbarg/nutanix` | -| [Okta](https://www.pulumi.com/registry/packages/okta) | `okta` | -| [OneLogin](https://www.pulumi.com/registry/packages/onelogin) | `onelogin` | -| [OpenStack](https://www.pulumi.com/registry/packages/openstack) | `openstack` | -| [Opsgenie](https://www.pulumi.com/registry/packages/opsgenie) | `opsgenie` | -| [Oracle Cloud Infrastructure](https://www.pulumi.com/registry/packages/oci) | `oci` | -| [OVHCloud](https://www.pulumi.com/registry/packages/ovh) | `@ovh-devrelteam/pulumi-ovh` | -| [PagerDuty](https://www.pulumi.com/registry/packages/pagerduty) | `pagerduty` | -| [Pinecone](https://www.pulumi.com/registry/packages/pinecone) | `@pinecone-database/pulumi` | -| [PlanetScale](https://github.com/sst/pulumi-planetscale) | `planetscale` | -| [Port](https://www.pulumi.com/registry/packages/port) | `@port-labs/port` | -| [PostgreSQL](https://www.pulumi.com/registry/packages/postgresql) | `postgresql` | -| [Prodvana](https://www.pulumi.com/registry/packages/prodvana) | `@prodvana/pulumi-prodvana` | -| [Proxmox Virtual Environment](https://www.pulumi.com/registry/packages/proxmoxve) | `@muhlba91/pulumi-proxmoxve` | -| [Pulumi Cloud](https://www.pulumi.com/registry/packages/pulumiservice) | `pulumiservice` | -| [purrl](https://www.pulumi.com/registry/packages/purrl) | `@pulumiverse/purrl` | -| [Qovery](https://www.pulumi.com/registry/packages/qovery) | `@ediri/qovery` | -| [RabbitMQ](https://www.pulumi.com/registry/packages/rabbitmq) | `rabbitmq` | -| [Rancher2](https://www.pulumi.com/registry/packages/rancher2) | `rancher2` | -| [Railway](https://registry.terraform.io/providers/terraform-community-providers/railway/latest) | `railway` | -| [random](https://www.pulumi.com/registry/packages/random) | `random` | -| [Redis Cloud](https://www.pulumi.com/registry/packages/rediscloud) | `@rediscloud/pulumi-rediscloud` | -| [Rootly](https://www.pulumi.com/registry/packages/rootly) | `@rootly/pulumi` | -| [Runpod](https://www.pulumi.com/registry/packages/runpod) | `@runpod-infra/pulumi` | -| [Scaleway](https://www.pulumi.com/registry/packages/scaleway) | `@pulumiverse/scaleway` | -| [Sentry](https://www.pulumi.com/registry/packages/sentry) | `@pulumiverse/sentry` | -| [SignalFx](https://www.pulumi.com/registry/packages/signalfx) | `signalfx` | -| [Slack](https://www.pulumi.com/registry/packages/slack) | `slack` | -| [Snowflake](https://www.pulumi.com/registry/packages/snowflake) | `snowflake` | -| [Splight](https://www.pulumi.com/registry/packages/splight) | `@splightplatform/pulumi-splight` | -| [Splunk](https://www.pulumi.com/registry/packages/splunk) | `splunk` | -| [Spotinst](https://www.pulumi.com/registry/packages/spotinst) | `spotinst` | -| [Statuscake](https://www.pulumi.com/registry/packages/statuscake) | `@pulumiverse/statuscake` | -| [Strata Cloud Manager](https://www.pulumi.com/registry/packages/scm) | `scm` | -| [Stripe](https://github.com/georgegebbett/pulumi-stripe) | `stripe` | -| [Stripe Official](https://github.com/stripe/terraform-provider-stripe) | `stripe-official` | -| [StrongDM](https://www.pulumi.com/registry/packages/sdm/) | `@pierskarsenbarg/sdm` | -| [Sumo Logic](https://www.pulumi.com/registry/packages/sumologic) | `sumologic` | -| [Supabase](https://github.com/sst/pulumi-supabase) | `supabase` | -| [Symbiosis](https://www.pulumi.com/registry/packages/symbiosis) | `@symbiosis-cloud/symbiosis-pulumi` | -| [Synced Folder](https://www.pulumi.com/registry/packages/synced-folder) | `synced-folder` | -| [Tailscale](https://www.pulumi.com/registry/packages/tailscale) | `tailscale` | -| [Talos Linux](https://www.pulumi.com/registry/packages/talos) | `@pulumiverse/talos` | -| [Time](https://www.pulumi.com/registry/packages/time) | `@pulumiverse/time` | -| [TLS](https://www.pulumi.com/registry/packages/tls) | `tls` | -| [Twingate](https://www.pulumi.com/registry/packages/twingate) | `@twingate/pulumi-twingate` | -| [Unifi](https://www.pulumi.com/registry/packages/unifi) | `@pulumiverse/unifi` | -| [Upstash](https://www.pulumi.com/registry/packages/upstash) | `@upstash/pulumi` | -| [Venafi](https://www.pulumi.com/registry/packages/venafi) | `venafi` | -| [Vercel](https://www.pulumi.com/registry/packages/vercel) | `vercel` | -| [VMware vSphere](https://www.pulumi.com/registry/packages/vsphere) | `vsphere` | -| [Volcengine](https://www.pulumi.com/registry/packages/volcengine) | `@volcengine/pulumi` | -| [vSphere](https://www.pulumi.com/registry/packages/vsphere) | `vsphere` | -| [Vultr](https://www.pulumi.com/registry/packages/vultr) | `@ediri/vultr` | -| [Wavefront](https://www.pulumi.com/registry/packages/wavefront) | `wavefront` | -| [Yandex](https://www.pulumi.com/registry/packages/yandex) | `yandex` | -| [Zitadel](https://www.pulumi.com/registry/packages/zitadel) | `@pulumiverse/zitadel` | -| [Zscaler Internet Access](https://www.pulumi.com/registry/packages/zia/) | `@bdzscaler/pulumi-zia` | -| [Zscaler Private Access](https://www.pulumi.com/registry/packages/zpa/) | `@bdzscaler/pulumi-zpa` | - -Any missing providers or typos? Feel free to _Edit this page_ and submit a PR. diff --git a/www/src/content/docs/docs/aws-accounts.mdx b/www/src/content/docs/docs/aws-accounts.mdx deleted file mode 100644 index d87564dc72..0000000000 --- a/www/src/content/docs/docs/aws-accounts.mdx +++ /dev/null @@ -1,308 +0,0 @@ ---- -title: Set up AWS Accounts -description: A simple and secure guide to setting up AWS accounts. ---- - -Unsurprisingly there are multiple ways to set up AWS accounts. And unfortunately the default process misses a few things that'll likely make this a lot easier for your team. - -:::tip -If you are using IAM users or have credential files, this guide is for you. -::: - ---- - -The ideal setup is to have multiple AWS accounts grouped under a single AWS Organization. While your team authenticates through SSO to access the Console and the CLI. - -While this sounds complicated, it's a one time process that you'll never have to think about again. - -Let's get started. - ---- - -## Management account - -The first step is to [**create a management account**](https://portal.aws.amazon.com/billing/signup?type=enterprise#/start/email). - -1. Start by using a **work email alias**. For example `aws@acme.com`. This'll forward to your real email. It allows you to give other people access to it in the future. -2. The **account name** should be your company name, for example `acme`. -3. Enter your **billing info** and **confirm your identity**. -4. Choose **basic support**. You can upgrade this later. - -Once you're done you should be able to login and access the AWS Console. - -These credentials are overly powerful. You should rarely ever need them again. Feel free to throw away the password after completing this guide. You can always do a password reset if it's needed. - -:::tip -The Management account is what you'll use to manage the users in your organization. -::: - -This account won't have anything deployed to it besides the IAM Identity Center which is how we'll manage the users in our organization. - ---- - -### AWS Organization - -Next, we'll create an organization. This allows you to manage multiple AWS accounts together. We'll need this as we create separate accounts for dev and prod. - -Search **AWS Organization** in the search bar to go to its dashboard and click **Create an organization**. - -You'll see that the management account is already in the organization. - ---- - -### IAM Identity Center - -Now let's enable IAM Identity Center. - -1. Search **IAM Identity Center** and go to its dashboard. Click **Enable**. - - :::note - Make a note of the region you're in for the IAM Identity Center. - ::: - - This'll be created in one region and you cannot change it. However, it doesn't matter too much which one it is. You'll just need to navigate to that region when you are trying to find this again. - -2. Click **Enable**. This will give your organization a unique URL to login. - - :::note - Make a note of the URL that IAM Identity Center gives you. - ::: - - This is auto-generated but you can click **Customize** to select a unique name. You'll want to bookmark this for later. - ---- - -## Root user - -Now we'll create a root user in IAM Identity Center. - -1. Click **Users** on the left and then **Add user** to create a user for yourself. Make your username your work email, for example `dax@acme.com`, and fill out the required fields. -2. Skip adding the user to groups. -3. Finish creating the user. - -We've created the user. Now let's give it access to our management account. - ---- - -### User access - -Go to the left panel and click **AWS Accounts**. - -1. Select your management account. It should be tagged as such. And click **Assign users or groups**. -2. Select the Users tab, make sure your user is selected and hit **Next**. -3. Now we'll need to create a new permission set. We need to do this once. Click **Create permission set**. -4. In the new tab select **Predefined permission set** and **AdministratorAccess**. Click **Next**. -5. Increase the session duration to 12 hours. This is the most convenient option. Click **Next** and then **Create**. -6. Close the tab, return to the previous one and hit the refresh icon. Select **AdministratorAccess** and click **Next** and then **Submit**. - -This might seem complicated but all we did was grant the user an _AdministratorAccess role_ into the management account. - -Now you're ready to log in to your user account. - ---- - -### Login - -Check your email and you should have an invite. - -1. **Accept the invite** and **create a new password**. Be sure to save it in your password manager. This is important because this account has access to the management account. - - :::note - If you already have an SSO provider, like Google you can allow your team to _Login with Google_. Let us know if you'd like us to document that as well. - ::: - -2. Sign in and you should see your organization with a **list of accounts** below it. - - You currently only have access to the management account we created above. So click it and you should see the AdministratorAccess role. - -3. Click **Management Console** to login to the AWS Console. - -You're now done setting up the root user account! - ---- - -## Dev and prod accounts - -As mentioned earlier, your management account isn't meant to deploy any resources. It's meant to manage users. - -So a good initial setup is to create separate `dev` and `production` accounts. This helps create some isolation. The `dev` account will be shared between your team while the `production` account is just for production. - -You can also create a staging account or an account per developer but we'll start simple. - ---- - -Navigate back to **AWS Organizations** by searching for it. - -1. Click **Add an AWS account**. -2. For the account name append `-dev` to whatever you called your management account. For example, `acme-dev`. -3. For the email address choose a new email alias. If you're using Google for email, you can do `aws+dev@acme.com` and it'll still go to your `aws@acme.com` email. -4. Click **Create AWS account**. - -**Repeat this step** and create the `-production` as well. So you should now have an `acme-dev` and an `acme-production`. - -It'll take a few seconds to finish creating. - ---- - -### Assign users - -Once it's done head over to **IAM Identity Center** to grant your user access to these accounts. - -1. Select the **AWS Accounts** tab on the left. -2. Select your newly created `acme-dev` and `acme-production` accounts and click **Assign users or groups**. -3. In the **Users** tab select your user and click **Next**. -4. Select the **AdministratorAccess** permission set and click **Next** and **Submit**. - -Now you can go back to your SSO URL. You should now see three different accounts and you'll be able to login to whichever one you want. - -:::tip -You can find your SSO URL by clicking **Dashboard** on the left. -::: - -You can create additional users and add them to these accounts using the steps above. You can reuse the role or create one with stricter permissions. - -Next, let's configure the AWS CLI and SST to use this setup. - ---- - -## Configure AWS CLI - -The great thing about this setup is that you no longer need to generate AWS IAM credentials for your local machine, you can just use SSO. This is both simpler and more secure. - -:::tip -You can [download](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) the AWS CLI from the AWS docs. -::: - -All you need is a single configuration file for the AWS CLI, SST, or any random scripts you want to run. And there will never be any long lived credentials stored on your machine. - ---- - - -1. Add the following block to a `~/.aws/config` file. - - ```bash title="~/.aws/config" - [sso-session acme] - sso_start_url = https://acme.awsapps.com/start - sso_region = us-east-1 - ``` - - Make sure to replace the `sso_start_url` with your SSO URL that you bookmarked. And set the region where you created IAM Identity Center as the `sso_region`. - -2. Add an entry for each environment, in this case `dev` and `production`. - - ```bash title="~/.aws/config" - [profile acme-dev] - sso_session = acme - sso_account_id = - sso_role_name = AdministratorAccess - region = us-east-1 - - [profile acme-production] - sso_session = acme - sso_account_id = - sso_role_name = AdministratorAccess - region = us-east-1 - ``` - - You can find the account ID from your SSO login url. If you expand the account you will see it listed with a `#` sign. - - The region specified in the config is the default region that the CLI will use when one isn't specified. - - :::tip - With this setup you won't need to save your AWS credentials locally. - ::: - - And the role name is the one we created above. If you created a different role, you'd need to change this. - -3. Now you can login by running. - - ```bash - aws sso login --sso-session=acme - ``` - - This'll open your browser and prompt you to allow access. The sessions will last 12 hours, as we had configured previously. - - If you're using Windows with WSL, you can add a script to open the login browser of the host machine. - -
    - View script - - ```sh title="login.sh" - #!/bin/bash - - if grep -q WSL /proc/version; then - export BROWSER=wslview - fi - - aws sso login --sso-session=acme - ``` - -
    - -4. Optionally, for Node.js projects, it can be helpful to add this to a `package.json` script so your team can just run `npm run sso` to login. - - ```json title="package.json" - "scripts": { - "sso": "aws sso login --sso-session=acme" - } - ``` - -5. Finally, test that everything is working with a simple CLI command that targets your dev account. - - ```bash - aws sts get-caller-identity --profile=acme-dev - ``` - -Next, let's configure SST to use these profiles. - ---- - -## Configure SST - -In your `sst.config.ts` file check which stage you are deploying to and return the right profile. - -```ts title="sst.config.ts" {8} -export default $config({ - app(input) { - return { - name: "my-sst-app", - home: "aws", - providers: { - aws: { - profile: input.stage === "production" ? "acme-production" : "acme-dev" - } - } - }; - }, - async run() { - // Your resources - } -}); -``` - -This will use the `acme-production` profile just for production and use `acme-dev` for everything else. - -:::note -The `AWS_PROFILE` environment variable will override the profile set in your `sst.config.ts`. -::: - -If you've configured AWS credentials previously through the `AWS_PROFILE` environment variable or through a `.env` file, it will override the profile set in your `sst.config.ts`. So make sure to remove any references to `AWS_PROFILE`. - -Now to deploy to your production account you just pass in the stage. - -```bash -sst deploy --stage production -``` - -And we are done! - ---- - -To summarize, here what we've created: - -1. A management account to manage the users in our organization. -2. A root user that can login to the management account. -3. Dev and production accounts for our apps. -4. Finally, given the root user access to both accounts. - -You can extend these by adding more users, or adding additional accounts, or modifying the roles you grant. diff --git a/www/src/content/docs/docs/basics.mdx b/www/src/content/docs/docs/basics.mdx deleted file mode 100644 index 1d21515cc1..0000000000 --- a/www/src/content/docs/docs/basics.mdx +++ /dev/null @@ -1,396 +0,0 @@ ---- -title: Basics -description: The basics of building apps with SST. ---- - -import { Tabs, TabItem } from '@astrojs/starlight/components'; -import VideoAside from "../../../components/VideoAside.astro"; - -The main difference between working on SST versus any other framework is that everything related to your app is all **defined in code**. - -1. SST **automatically manages** the resources in AWS (or any provider) defined in your app. -2. You don't need to **make any manual changes** to them in your cloud provider's console. - -This idea of _automating everything_ can feel unfamiliar at first. So let's go through the basics and look at some core concepts. - ---- - -## Setup - -Before you start working on your app, there are a couple of things we recommend setting up. - -Starting with your code editor. - ---- - -### Editor - -SST apps are configured through a file called `sst.config.ts`. It's a TypeScript file and it can work with your editor to type check and autocomplete your code. It can also show you inline help. - - - - ![Editor typecheck](../../../assets/docs/basics/editor-typecheck.png) - - - ![Editor autocomplete](../../../assets/docs/basics/editor-autocomplete.png) - - - ![Editor help](../../../assets/docs/basics/editor-help.png) - - - -Most modern editors; VS Code and Neovim included, should do the above automatically. But you should start by making sure that your editor has been set up. - ---- - -### Credentials - -SST apps are deployed to your infrastructure. So whether you are deploying to AWS, or Cloudflare, or any other cloud provider, make sure you have their credentials configured locally. - -Learn more about how to [configure your AWS credentials](/docs/iam-credentials/). - ---- - -### Console - -SST also comes with a [Console](/docs/console/). It shows you all your apps, the resources in them, lets you configure _git push to deploy_, and also send you alerts for when there are any issues. - -While it is optional, we recommend creating a free account and linking it to your AWS account. Learn more about the [SST Console](/docs/console/). - ---- - -## sst.config.ts - -Now that you are ready to work on your app and your `sst.config.ts`, let's take a look at what it means to _configure everything in code_. - - ---- - -### IaC - -Infrastructure as Code or _IaC_ is a process of automating the management of infrastructure through code. Rather than doing it manually through a console or user interface. - -:::tip -You won't need to use the AWS Console to configure your SST app. -::: - -Say your app has a Function and an S3 bucket, you would define that in your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); - -new sst.aws.Function("MyFunction", { - handler: "index.handler" -}); -``` - -You won't need to go to the Lambda and S3 parts of the AWS Console. SST will do the work for you. - -In the above snippets, `sst.aws.Function` and `sst.aws.Bucket` are called Components. Learn more about [Components](/docs/components/). - ---- - -### Resources - -The reason this works is because when SST deploys the above app, it'll convert it into a set of commands. These then call AWS with your credentials to create the underlying resources. So the above components get transformed into a list of low level resources in AWS. - -:::tip -You are not directly responsible for the low level resources that SST creates. -::: - -If you log in to your AWS Console you can see what gets created internally. While these might look a little intimidating, they are all managed by SST and you are not directly responsible for them. - -SST will create, track, and remove all the low level resources defined in your app. - ---- - -#### Exceptions - -There are some exceptions to this. You might have resources that are not defined in your SST config. These could include the following resources: - -1. **Previously created** - - You might've previously created some resources by hand that you would like to use in your new SST app. You can import these resources into your app. Moving forward, SST will manage them for you. Learn more about [importing resources](/docs/import-resources/). - -2. **Externally managed** - - You might have resources that are managed by a different team. In this case, you don't want SST to manage them. You simply want to reference them in your app. Learn more about [referencing resources](/docs/reference-resources/). - -3. **Shared across stages** - - If you are creating preview environments, you might not want to make copies of certain resources, like your database. You might want to share these across stages. Learn more about [sharing across stages](/docs/share-across-stages/). - ---- - -### Linking - -Let's say you wanted your function from the above example to upload a file to the S3 bucket, you'd need to hardcode the name of the bucket in your API. - - - -SST avoids this by allowing you to **link resources** together. - -```ts title="sst.config.ts" {3} -new sst.aws.Function("MyFunction", { - handler: "index.handler", - link: [bucket] -}); -``` - -Now in your function you can access the bucket using SST's [SDK](/docs/reference/sdk/). - -```ts title="index.ts" "Resource.MyBucket.name" -import { Resource } from "sst"; - -console.log(Resource.MyBucket.name); -``` - -There's a difference between the two snippets above. One is your **infrastructure code** and the other is your **runtime code**. One is run while creating your app, while the other runs when your users use your app. - -:::tip -You can access your infrastructure in your runtime using the SST SDK. -::: - -The _link_ allows you to access your **infrastructure** in your **runtime code**. Learn more about [resource linking](/docs/linking/). - ---- - -### State - -When you make a change to your `sst.config.ts`, like we did above. SST only deploys the changes. - -```diff lang="ts" title="sst.config.ts" -new sst.aws.Function("MyFunction", { - handler: "index.handler", -+ link: [bucket] -}); -``` - -It does this by maintaining a _state_ of your app. The state is a tree of all the resources in your app and all their properties. - -The state is stored in a file locally and backed up to a bucket in your AWS (or Cloudflare) account. - -:::tip -You can view the state of your app and its history in the SST Console. -::: - -A word of caution, if for some reason you delete your state locally and in your provider, SST won't be able to manage the resources anymore. To SST this app won't exist anymore. - -:::danger -Do not delete the bucket that stores your app's state. -::: - -To fix this, you'll have to manually re-import all those resources back into your app. Learn more about [how state works](/docs/state/). - ---- - -#### Out of sync - -We mentioned above that you are not responsible for the low level resources that SST creates. But this isn't just a point of convenience; it's something you should not do. - -:::caution -Do not manually make changes to the low level resources that SST creates. -::: - -The reason for this is that, SST only applies the diffs when your `sst.config.ts` changes. So if you manually change the resources, it'll be out of sync with your state. - -You can fix some of this by running [`sst refresh`](reference/cli/#refresh) but in general you should avoid doing this. - ---- - -## App - -So now that we know how IaC works, a lot of the workflow and concepts will begin to make sense. Starting with the key parts of an app. - ---- - -### Name - -Every app has a name. The name is used as a namespace. It allows SST to deploy multiple apps to the same cloud provider account, while isolating the resources in an app. - -If you change the name of your app in your `sst.config.ts`, SST will create a completely new set of resources for it. It **does not** rename the resources. - -:::caution -To rename an app, you'll need to remove the resources from the old one and deploy to the new one. -::: - -So if you: - -1. Create an app with the name `my-sst-app` in your `sst.config.ts` and deploy it. -2. Rename the app in your `sst.config.ts` to `my-new-sst-app` and deploy again. - -You will now have two apps in your AWS account called `my-sst-app` and `my-new-sst-app`. - -If you want to rename your app, you'll need to [remove](/docs/basics/#remove) the old app first and then deploy a new one with the new name. - ---- - -### Stage - -An app can have multiple stages. A stage is like an _environment_, it's a separate version of your app. For example, you might have a dev stage, a production stage, or a personal stage. - -It's useful to have multiple versions of your app because it lets you make changes and test in one version while your users continue to use the other. - -You create a new stage by deploying to it with the `--stage ` CLI option. The stage name is used as a namespace to create a new version of your app. It's similar to how the app name is used as a namespace. - -:::caution -To rename a stage, you'll need to [remove](/docs/basics/#remove) the resources from the old one and deploy to the new one. -::: - -Similar to app names, stages cannot be renamed. So if you wanted to rename a `development` stage to `dev`; you'll need to first remove `development` and then deploy `dev`. - ---- - -#### Personal stages - -By default, if no stage is passed in, SST creates a stage using the username in your computer. This is called a **personal stage**. Personal stages are typically used in _dev_ mode and every developer on your team should use their own personal stage. - -We'll look at this in detail below. - ---- - -### Region - -Most resources that are created in AWS (and many other providers) belong to a specific region. So when you deploy your app, it's deployed to a specific region. - -:::caution -To switch regions, you'll need to [remove](/docs/basics/#remove) the resources from one region and deploy to the new one. -::: - -For AWS, the region comes from your AWS credentials but it can be specified in the `sst.config.ts`. - -```ts title="sst.config.ts" {5-7} -export default $config({ - app(input) { - return { - name: "my-sst-app", - providers: { - aws: { region: "us-west-2" } - } - }; - } -}); -``` - -Similar to the app and stage, if you want to switch regions; you'll need to remove your app in the old region and deploy it to the new one. - ---- - -## Commands - -Now with the above background let's look at the workflow of building an SST app. - -Let's say you've created an app by running. - -```bash -sst init -``` - ---- - -### Dev - -To start with, you'll run your app in dev. - -```bash -sst dev -``` - -This deploys your app to your _personal_ stage in _dev mode_. It brings up a multiplexer that deploys your app, runs your functions, creates a tunnel, and starts your frontend and container services. - - - -It deploys your app a little differently and is optimized for local development. - -1. It runs the functions in your app [_Live_](/docs/live/) by deploying a **_stub_ version**. These proxy any requests to your local machine. -2. It **does not deploy** your frontends or container services. Instead, it starts them locally. -3. It also creates a [_tunnel_](/docs/reference/cli#tunnel) that allows them to connect to any resources that are deployed in a VPC. - -:::note -Only use `sst dev` in your personal stage. -::: - -For this reason we recommend only using your personal stage for local development. And instead deploying to a separate stage when you want to share your app with your users. - -Learn more about [`sst dev`](/docs/reference/cli/#dev). - ---- - -### Deploy - -Once you are ready to go to production you can run. - -```bash -sst deploy --stage production -``` - -You can use any stage name for production here. - ---- - -### Remove - -If you want to remove your app and all the resources in it, you can run. - -```bash -sst remove --stage -``` - -You want to be careful while running this command because it permanently removes all the resources from your AWS (or cloud provider) account. - -:::caution -Be careful while running `sst remove` since it permanently removes all your resources. -::: - -To prevent accidental removal, our template `sst.config.ts` comes with the following. - -```ts title="sst.config.ts" -removal: input?.stage === "production" ? "retain" : "remove", -``` - -This is telling SST that if the stage is called `production` then on remove, retain critical resources like buckets and databases. This should avoid any accidental data loss. - - - -Learn more about [removal policies](/docs/reference/config/#removal). - ---- - -## With a team - -This workflow really shines when working with a team. Let's look at what it looks like with a basic git workflow. - - - -1. Every developer on the team uses `sst dev` to work in their own isolated personal stage. -2. You commit your changes to a branch called `dev`. -3. Any changes to the `dev` branch are auto-deployed using `sst deploy --stage dev`. -4. Your team tests changes made to the `dev` stage of your app. -5. If they look good, `dev` is merged into a branch called `production`. -6. And any changes to the `production` branch are auto-deployed to the `production` stage with `sst deploy --stage production`. - -In this setup, you have a separate stage per developer, a _dev_ stage for testing, and a _production_ stage. - ---- - -### Autodeploy - -To have a branch automatically deploy to a stage when commits are pushed to it, you need to configure GitHub Actions. - -![SST Console Autodeploy](../../../assets/docs/basics/sst-console-autodeploy.png) - -Or you can connect your repo to the SST Console and it'll auto-deploy your app for you. Learn more about [Autodeploy](/docs/console/#autodeploy). - ---- - -### PR environments - -You can also set it up to create preview environments. - -So when a pull request (say PR#12) is created, you auto-deploy a new stage using `sst deploy --stage pr-12`. And once the PR is merged, the preview environment or stage gets removed using `sst remove --stage pr-12`. - -Just like above, you can configure this using GitHub Actions or let the SST Console do it for you. - ---- - -And there you have it. You are now ready to build apps the _SST way_. diff --git a/www/src/content/docs/docs/changelog.mdx b/www/src/content/docs/docs/changelog.mdx deleted file mode 100644 index 86a0e67e80..0000000000 --- a/www/src/content/docs/docs/changelog.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Changelog -description: Release notes for SST. ---- - -import Changelog from "../../../components/Changelog.astro"; - -Release notes for SST. For older versions or the full commit history, see the [GitHub releases](https://github.com/sst/sst/releases). - - diff --git a/www/src/content/docs/docs/cloudflare.mdx b/www/src/content/docs/docs/cloudflare.mdx deleted file mode 100644 index a2baf83870..0000000000 --- a/www/src/content/docs/docs/cloudflare.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -title: Cloudflare -description: Learn how to use SST with Cloudflare ---- - -[Cloudflare](https://cloudflare.com) lets you deploy apps with Workers and connect services like D1, R2, and DNS. This guide covers how to set it up with SST. - ---- - -## Install - -Add the Cloudflare provider to your SST app. Learn more about [providers](/docs/providers). - -```bash -sst add cloudflare -``` - -This adds the provider to your `sst.config.ts`. - -```ts title="sst.config.ts" {3} -{ - providers: { - cloudflare: "5.37.1", - }, -} -``` - -If Cloudflare should store your app state, set [`home`](/docs/reference/config/#home) to `"cloudflare"`. This is useful in setups where you plan to use Cloudflare as you main cloud provider. - ---- - -## Credentials - -You can create an account token in the Cloudflare dashboard under [Manage Account > API Tokens](https://dash.cloudflare.com/?to=/:account/api-tokens). - -Start with the **Edit Cloudflare Workers** template and add these permissions: - -- *Account - D1 - Edit* -- *Zone - DNS - Edit* - -:::tip -If your app uses other Cloudflare products, add the permissions those features need. -::: - -Give the token access to the account your application will be deploying to. If you are using Cloudflare DNS with SST, include the zones that SST should update. - -Set `CLOUDFLARE_DEFAULT_ACCOUNT_ID` to the Cloudflare account ID that SST should use. If you leave it unset, SST falls back to the first account that Cloudflare returns for that token. - -Then set these variables in your shell, `.env`, or CI environment before you deploy: - -```bash -export CLOUDFLARE_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -export CLOUDFLARE_DEFAULT_ACCOUNT_ID=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -``` - ---- - -### Deploying into Multiple Cloudflare Accounts - -You can deploy cloudflare components into multiple Cloudflare accounts by specifying the accountId argument and providing a different Cloudflare Provider. - -```ts -// define a provider with another api token for a different account -const provider = new cloudflare.Provider("AnotherProvider", { apiToken: "bbbbbbbb_bbbbbbbbbbbb_bbbbbbbb" }); - -// specify resource in another account -const sstWorker = new sst.cloudflare.Worker( - "MyWorker", - { handler: "index.ts", accountId: "bbbbbbbb-bbbbbbbbbbbb-bbbbbbbb" }, - { provider }, -); -``` - -:::caution -Do not link any resources which are deployed into different Cloudflare accounts. -::: - ---- - -## Components - -SST includes Cloudflare components for Workers, storage, queues, cron jobs, AI bindings, and more. - -### Worker - -Create a Cloudflare Worker and enable a URL so it can handle HTTP requests. - -```ts title="sst.config.ts" -const worker = new sst.cloudflare.Worker("MyWorker", { - handler: "index.ts", - url: true, -}); - -return { - url: worker.url, -}; -``` - -Use the [`Worker`](/docs/component/cloudflare/worker/) component to build APIs and edge handlers on Cloudflare. - - -### Storage - -Create Cloudflare storage resources and link them to your Worker. For example, here's a D1 database. - -```ts title="sst.config.ts" -const db = new sst.cloudflare.D1("MyDatabase"); - -new sst.cloudflare.Worker("MyWorker", { - handler: "index.ts", - link: [db], - url: true, -}); -``` - -Then access it in your handler through `Resource`. - -```ts title="index.ts" -import { Resource } from "sst"; - -export default { - async fetch() { - const row = await Resource.MyDatabase.prepare( - "SELECT id FROM todo ORDER BY id DESC LIMIT 1", - ).first(); - - return Response.json(row); - }, -}; -``` - -The same pattern works with [`Bucket`](/docs/component/cloudflare/bucket/) for R2 and [`Kv`](/docs/component/cloudflare/kv/) for KV namespaces. - - -### Queue - -Use [`Queue`](/docs/component/cloudflare/queue/) for async work. - -```ts title="sst.config.ts" -const queue = new sst.cloudflare.Queue("MyQueue"); - -queue.subscribe("consumer.ts"); - -const producer = new sst.cloudflare.Worker("Producer", { - handler: "producer.ts", - link: [queue], - url: true, -}); -``` - -For scheduled work, use [`Cron`](/docs/component/cloudflare/cron/) to run a worker on a cron expression. - -### More components - -Browse the component docs for [`Worker`](/docs/component/cloudflare/worker/), [`Astro`](/docs/component/cloudflare/astro/), [`Bucket`](/docs/component/cloudflare/bucket/), [`D1`](/docs/component/cloudflare/d1/), [`Kv`](/docs/component/cloudflare/kv/), [`Queue`](/docs/component/cloudflare/queue/), [`Cron`](/docs/component/cloudflare/cron/), [`Ai`](/docs/component/cloudflare/ai/), [`Workflow`](/docs/component/cloudflare/workflow/), and [`RateLimit`](/docs/component/cloudflare/rate-limit/). - -If you are using Cloudflare DNS with SST, use [`sst.cloudflare.dns`](/docs/component/cloudflare/dns/) with [custom domains](/docs/custom-domains/). - ---- - -## Cloudflare Vite plugin - -Cloudflare SSR components like [Astro](/docs/component/cloudflare/astro/) or [TanStack Start](/docs/component/cloudflare/tanstack-start/) need the Cloudflare Vite plugin to work correctly. - -:::caution -Do not include any Wrangler configuration files (`wrangler.toml`, `wrangler.json`) in your project. SST manages these for you and will generate them as needed. -::: - -You need to configure the Vite plugin to use the SST-managed Wrangler config. - -```ts title="vite.config.ts" -import { defineConfig } from "vite"; -import { cloudflare } from "@cloudflare/vite-plugin"; - -export default defineConfig({ - plugins: [ - cloudflare({ - configPath: process.env.SST_WRANGLER_CONFIG, - }), - ], -}); -``` - -This environment variable is set by SST and ensures the plugin uses the generated Wrangler configuration. - -:::tip -There is an [open PR](https://github.com/cloudflare/workers-sdk/pull/13587) on the Cloudflare Workers SDK that will add automatic detection of the SST-managed Wrangler config. Once merged, you won't need to explicitly set `configPath`. -::: - ---- - -## Examples - -Check out the full examples: - -- [Cloudflare Workers with SST](/docs/start/cloudflare/worker/) -- [Hono on Cloudflare with SST](/docs/start/cloudflare/hono/) -- [tRPC on Cloudflare with SST](/docs/start/cloudflare/trpc/) -- [Astro on Cloudflare](https://github.com/sst/sst/tree/dev/examples/cloudflare-astro) -- [Cloudflare D1](https://github.com/sst/sst/tree/dev/examples/cloudflare-d1) -- [Cloudflare KV](https://github.com/sst/sst/tree/dev/examples/cloudflare-kv) -- [Cloudflare Queue](https://github.com/sst/sst/tree/dev/examples/cloudflare-queue) -- [Cloudflare Cron](https://github.com/sst/sst/tree/dev/examples/cloudflare-cron) diff --git a/www/src/content/docs/docs/components.mdx b/www/src/content/docs/docs/components.mdx deleted file mode 100644 index e8d1f287e8..0000000000 --- a/www/src/content/docs/docs/components.mdx +++ /dev/null @@ -1,467 +0,0 @@ ---- -title: Components -description: Components are the building blocks of your app. ---- - -import VideoAside from "../../../components/VideoAside.astro"; - -Every SST app is made up of components. These are logical units that represent features in your app; like your frontends, APIs, databases, or queues. - -There are two types of components in SST: - -1. Built-in components β€” High level components built by the SST team -2. Provider components β€” Low level components from the providers - -Let's look at them below. - ---- - -## Background - -Most [providers](/docs/providers/) like AWS are made up of low level resources. And it takes quite a number of these to put together something like a frontend or an API. For example, it takes around 70 low level AWS resources to create a Next.js app on AWS. - -As a result, Infrastructure as Code has been traditionally only been used by DevOps or Platform engineers. - -To fix this, SST has components that can help you with the most common features in your app. - ---- - -## Built-in - -The built-in components in SST, the ones you see in the sidebar, are designed to make it really easy to create the various parts of your app. - -For example, you don't need to know a lot of AWS details to deploy your Next.js frontend: - -```ts title="sst.config.ts" -new sst.aws.Nextjs("MyWeb"); -``` - -And because this is all in code, it's straightforward to configure this further. - -```ts title="sst.config.ts" -new sst.aws.Nextjs("MyWeb", { - domain: "my-app.com", - path: "packages/web", - imageOptimization: { - memory: "512 MB" - }, - buildCommand: "npm run build" -}); -``` - -You can even take this a step further and completely transform how the low level resources are created. We'll look at this below. - -:::tip -Aside from the built-in SST components, all the [Pulumi/Terraform providers](/docs/all-providers#directory) are supported as well. -::: - -Currently SST has built-in components for two cloud providers. - ---- - -### AWS - -The AWS built-in components are designed to make it easy to work with AWS. - -:::tip -SST's built-in components make it easy to build apps with AWS. -::: - -These components are namespaced under **`sst.aws.*`** and listed under AWS in the sidebar. Internally they use Pulumi's [AWS](https://www.pulumi.com/registry/packages/aws/) provider. - ---- - -### Cloudflare - -These components are namespaced under **`sst.cloudflare.*`** and listed under Cloudflare in the sidebar. Internally they use Pulumi's [Cloudflare](https://www.pulumi.com/registry/packages/cloudflare/) provider. - ---- - -## Constructor - -To add a component to your app, you create an instance of it by passing in a couple of args. For example, here's the signature of the [Function](/docs/component/aws/function) component. - -```ts -new sst.aws.Function(name: string, args: FunctionArgs, opts?: pulumi.ComponentResourceOptions) -``` - -Each component takes the following: - -- `name`: The name of the component. This needs to be unique across your entire app. -- `args`: An object of properties that allows you to configure the component. -- `opts?`: An optional object of properties that allows you to configure this component in Pulumi. - -Here's an example of creating a `Function` component: - -```ts title="sst.config.ts" -const function = new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler" -}); -``` - ---- - -### Name - -There are two guidelines to follow when naming your components: - -1. The names of SST's built-in components and components extended with [`Linkable.wrap`](/docs/component/linkable/#static-wrap) need to be global across your entire app. - - This allows [Resource Linking](linking) to look these resources up at runtime. - -2. Optionally, use PascalCase for the component name. - - For example, you might name your bucket, `MyBucket` and use Resource Linking to look it up with `Resource.MyBucket`. - - However this is purely cosmetic. You can use kebab case. So `my-bucket`, and look it up using `Resource['my-bucket']`. - ---- - -### Args - -Each component takes a set of args that allow you to configure it. These args are specific to each component. For example, the Function component takes [`FunctionArgs`](/docs/component/aws/function#functionargs). - -Most of these args are optional, meaning that most components need very little configuration to get started. Typically, the most common configuration options are lifted to the top-level. To further configure the component, you'll need to use the `transform` prop. - -Args usually take primitive types. However, they also take a special version of a primitive type. It'll look something like _`Input`_. We'll look at this in detail below. - ---- - -## Transform - -Most components take a `transform` prop as a part of their constructor or methods. It's an object that takes callbacks that allow you to transform how that component's infrastructure is created. - -:::tip -You can completely configure a component using the `transform` prop. -::: - -For example, here's what the `transform` prop looks like for the [Function](/docs/component/aws/function#transform) component: - -- `function`: A callback to transform the underlying Lambda function -- `logGroup`: A callback to transform the Lambda's LogGroup resource -- `role`: A callback to transform the role that the Lambda function assumes - -The type for these callbacks is similar. Here's what the `role` callback looks like: - -```ts -RoleArgs | (args: RoleArgs, opts: pulumi.ComponentResourceOptions, name: string) => void -``` - -This takes either: - -- A `RoleArgs` object. For example: - - ```ts - { - transform: { - role: { - name: "MyRole" - } - } - } - ``` - - This is **merged** with the original `RoleArgs` that were going to be passed to the component. - -- A function that takes `RoleArgs`. Here's the function signature: - - ```ts - (args: RoleArgs, opts: pulumi.ComponentResourceOptions, name: string) => void - ``` - - Where [`args`, `opts`, and `name`](https://www.pulumi.com/registry/packages/aws/api-docs/iam/role/#constructor-syntax) are the arguments for the Role constructor passed to Pulumi. - - So you can pass in a callback that takes the current `RoleArgs` and mutates it. - - ```ts - { - transform: { - role: (args, opts) => { - args.name = `${args.name}-MyRole`; - opts.retainOnDelete = true; - } - } - } - ``` - ---- - -### `$transform` - -Similar to the component transform, we have the global `$transform`. This allows you to transform how a component of a given type is created. - -:::tip -Set default props across all your components with `$transform`. -::: - -For example, set a default `runtime` for your functions. - -```ts title="sst.config.ts" -$transform(sst.aws.Function, (args, opts) => { - // Set the default if it's not set by the component - args.runtime ??= "nodejs18.x"; -}); -``` - -This sets the runtime for any `Function` component that'll be **created after this call**. - -The reason we do the check for `args.runtime` is to allow components to override the default. We do this by only setting the default if the component isn't specifying its own `runtime`. - -```ts title="sst.config.ts" -new sst.aws.Function("MyFunctionA", { - handler: "src/lambdaA.handler" -}); - -new sst.aws.Function("MyFunctionB", { - handler: "src/lambdaB.handler", - runtime: "nodejs20.x" -}); -``` - -So given the above transform, `MyFunctionA` will have a runtime of `nodejs18.x` and `MyFunctionB` will have a runtime of `nodejs20.x`. - -:::note -The `$transform` is only applied to components that are defined after it. -::: - -The `args` and `opts` in the `$transform` callback are what you'd pass to the `Function` component. Recall the signature of the `Function` component: - -```ts title="sst.config.ts" -new sst.aws.Function(name: string, args: FunctionArgs, opts?: pulumi.ComponentResourceOptions) -``` - -Read more about the global [`$transform`](/docs/reference/global/#transform). - ---- - -## Properties - -An instance of a component exposes a set of properties. For example, the `Function` component exposes the following [properties](/docs/component/aws/function#properties) β€” `arn`, `name`, `url`, and `nodes`. - -```ts -const functionArn = function.arn; -``` - -These can be used to output info about your app or can be used as args for other components. - -These are typically primitive types. However, they can also be a special version of a primitive type. It'll look something like _`Output`_. We'll look at this in detail below. - ---- - -### Links - -Some of these properties are also made available via [resource linking](/docs/linking/). This allows you to access them in your functions and frontends in a typesafe way. - -For example, a Function exposes its `name` through its [links](/docs/component/aws/bucket/#links). - ---- - -### Nodes - -The `nodes` property that a component exposes gives you access to the underlying infrastructure. This is an object that contains references to the underlying Pulumi components that are created. - -:::tip -The nodes that are made available reflect the ones that can be configured using the `transform` prop. -::: - -For example, the `Function` component exposes the following [nodes](/docs/component/aws/function#nodes) β€” `function`, `logGroup`, and `role`. - ---- - -## Outputs - -The properties of a component are typically of a special type that looks something like, _`Output`_. - - - -These are values that are not available yet and will be resolved as the deploy progresses. However, these outputs can be used as args in other components. - -This makes it so that parts of your app are not blocked and all your resources are deployed as concurrently as possible. - -For example, let's create a function with an url. - -```ts title="sst.config.ts" -const myFunction = new sst.aws.Function("MyFunction", { - url: true, - handler: "src/lambda.handler" -}); -``` - -Here, `myFunction.url` is of type `Output`. We want to use this function url as a route in our router. - -```ts {3} title="sst.config.ts" -new sst.aws.Router("MyRouter", { - routes: { - "/api": myFunction.url - } -}); -``` - -The route arg takes `Input`, which means it can take a string or an output. This creates a dependency internally. So the router will be deployed after the function has been. However, other components that are not dependent on this function can be deployed concurrently. - -You can read more about [Input and Output types on the Pulumi docs](https://www.pulumi.com/docs/concepts/inputs-outputs/). - ---- - -### Apply - -Since outputs are values that are yet to be resolved, you cannot use them in regular operations. You'll need to resolve them first. - -For example, let's take the function url from above. We cannot do the following. - -```ts title="sst.config.ts" -const newUrl = myFunction.url + "/foo"; -``` - -This is because the value of the output is not known at the time of this operation. We'll need to resolve it. - -The easiest way to work with an output is using `.apply`. It'll allow you to apply an operation on the output and return a new output. - -```ts title="sst.config.ts" -const newUrl = myFunction.url.apply((value) => value + "/foo"); -``` - -In this case, `newUrl` is also an `Output`. - ---- - -### Helpers - -To make it a little easier to work with outputs, we have the following global helper functions. - ---- - -#### `$concat` - -This lets you do. - -```ts title="sst.config.ts" -const newUrl = $concat(myFunction.url, "/foo"); -``` - -Instead of the apply. - -```ts title="sst.config.ts" -const newUrl = myFunction.url.apply((value) => value + "/foo"); -``` - -Read more about [`$concat`](/docs/reference/global/#concat). - ---- - -#### `$interpolate` - -This lets you do. - -```ts title="sst.config.ts" -const newUrl = $interpolate`${myFunction.url}/foo`; -``` - -Instead of the apply. - -```ts title="sst.config.ts" -const newUrl = myFunction.url.apply((value) => value + "/foo"); -``` - -Read more about [`$interpolate`](/docs/reference/global/#interpolate). - ---- - -#### `$jsonParse` - -This is for outputs that are JSON strings. So instead of doing this. - -```ts title="sst.config.ts" -const policy = policyStr.apply((policy) => - JSON.parse(policy) -); -``` - -You can. - -```ts title="sst.config.ts" -const policy = $jsonParse(policyStr); -``` - -Read more about [`$jsonParse`](/docs/reference/global/#jsonParse). - ---- - -#### `$jsonStringify` - -Similarly, for outputs that are JSON objects. Instead of doing a stringify after an apply. - -```ts title="sst.config.ts" -const policy = policyObj.apply((policy) => - JSON.stringify(policy) -); -``` - -You can. - -```ts title="sst.config.ts" -const policy = $jsonStringify(policyObj); -``` - -Read more about [`$jsonStringify`](/docs/reference/global/#jsonStringify). - ---- - -#### `$resolve` - -And finally when you are working with a list of outputs and you want to resolve them all together. - -```ts title="sst.config.ts" -$resolve([bucket.name, worker.url]).apply(([bucketName, workerUrl]) => { - console.log(`Bucket: ${bucketName}`); - console.log(`Worker: ${workerUrl}`); -}) -``` - -Read more about [`$resolve`](/docs/reference/global/#resolve). - ---- - -## Versioning - -SST components evolve over time, sometimes introducing breaking changes. To maintain backwards compatibility, we implement a component versioning scheme. - -For example, we released a new version the [`Vpc`](/docs/component/aws/vpc) that does not create a NAT Gateway by default. To roll this out the previous version of the `Vpc` component was renamed to [`Vpc.v1`](/docs/component/aws/vpc-v1). - -Now if you were using the original `Vpc` component, update SST, and deploy; you'll get an error during the deploy saying that there's a new version of this component. - -This allows you to decide what you want to do with this component. - ---- - -#### Continue with the old version - -If you prefer to continue using the older version of a component, you can rename it. - -```diff title="sst.config.ts" lang="ts" -- const vpc = new sst.aws.Vpc("MyVpc"); -+ const vpc = new sst.aws.Vpc.v1("MyVpc"); -``` - -Now if you deploy again, SST knows that you want to stick with the old version and it won't error. - ---- - -#### Update to the latest version - -Instead, if you wanted to update to the latest version, you'll have to rename the component. - -```diff title="sst.config.ts" lang="ts" -- const vpc = new sst.aws.Vpc("MyVpc"); -+ const vpc = new sst.aws.Vpc("MyNewVpc"); -``` - -Now if you redeploy, it'll remove the previously created component and recreate it with the new name and the latest version. - -This is because from SST's perspective it looks like the `MyVpc` component was removed and a new component called `MyNewVpc` was added. - -:::caution -Removing and recreating components may cause temporary downtime in your app. -::: - -Since these are being recreated you've to be aware that there might be a period of time when that resource is not around. This might cause some downtime, depending on the resource. diff --git a/www/src/content/docs/docs/configure-a-router.mdx b/www/src/content/docs/docs/configure-a-router.mdx deleted file mode 100644 index d61cbaf831..0000000000 --- a/www/src/content/docs/docs/configure-a-router.mdx +++ /dev/null @@ -1,318 +0,0 @@ ---- -title: Configure a Router -description: Create a shared CloudFront distribution for your entire app. ---- - -import { Image } from "astro:assets" -import { Tabs, TabItem } from '@astrojs/starlight/components'; - -import DevDiagram from "../../../assets/docs/router/dev-architecture.svg"; -import ProdDiagram from "../../../assets/docs/router/prod-architecture.svg"; - -You can set [custom domains](/docs/custom-domains) on components like your frontends, APIs, or services. Each of these create their own CloudFront distribution. But as your app grows you might: - -1. Have multiple frontends, like a landing page, or a docs site, etc. -2. Want to serve resources from different paths of the same domain; like `/docs`, or `/api`. -3. Want to set up preview environments on subdomains. - -Also since CloudFront distributions can take 15-20 minutes to deploy, creating new distributions for each of the components, and for each stage, can really impact how long it takes to deploy your app. - -:::tip -The `Router` lets you create and share a single CloudFront distribution for your entire app. -::: - -The ideal setup here is to create a single CloudFront distribution for your entire app and share that across components and across stages. - -Let's look at how to do this with the `Router` component. - ---- - -#### A sample app - -To demo this, let's say you have the following components in your app. - -```ts title="sst.config.ts" -// Frontend -const web = new sst.aws.Nextjs("MyWeb", { - path: "packages/web" -}); - -// API -const api = new sst.aws.Function("MyApi", { - url: true, - handler: "packages/functions/api.handler" -}); - -// Docs -const docs = new sst.aws.Astro("MyDocs", { - path: "packages/docs" -}); -``` - -This has a frontend, a docs site, and an API. In production we'd like to have: - -- `example.com` serve `MyWeb` -- `example.com/api` serve `MyApi` -- `docs.example.com` serve `MyDocs` - -We'll create a Router for production. - - - -In our dev stage we'd like to have: - -- `dev.example.com` serve `MyWeb` -- `dev.example.com/api` serve `MyApi` -- `docs.dev.example.com` serve `MyDocs` - -For our PR stages or preview environments we'd like to have: - -- `pr-123.dev.example.com` serve `MyWeb` -- `pr-123.dev.example.com/api` serve `MyApi` -- `docs-pr-123.dev.example.com` serve `MyDocs` - -We'll create a separate Router for the dev stage and share it across all the PR stages. - - - -We are doing `docs-pr-123.dev.` instead of `docs.pr-123.dev.` because of a limitation with custom domains in CloudFront that we'll look at below. - -Let's set this up. - ---- - -## Add a router - -Instead of adding custom domains to each component, let's add a `Router` to our app with the domain we are going to use in production. - -```ts title="sst.config.ts" -const router = new sst.aws.Router("MyRouter", { - domain: { - name: "example.com", - aliases: ["*.example.com"] - } -}); -``` - -The `*.example.com` alias is because we want to route to the `docs.` subdomain. - -And use that in our components. - -```diff lang="ts" title="sst.config.ts" -// Frontend -const web = new sst.aws.Nextjs("MyWeb", { - path: "packages/web", -+ router: { -+ instance: router -+ } -}); - -// API -const api = new sst.aws.Function("MyApi", { - handler: "packages/functions/api.handler", -+ url: { -+ router: { -+ instance: router, -+ path: "/api" -+ } -+ } -}); - -// Docs -const docs = new sst.aws.Astro("MyDocs", { - path: "packages/docs", -+ router: { -+ instance: router, -+ domain: "docs.example.com" -+ } -}); -``` - -Next, let's configure the dev stage. - ---- - -## Stage based domains - -Since we also want to configure domains for our dev stage, let's add a function that returns the domain we want, based on the stage. - -```ts title="sst.config.ts" -const domain = $app.stage === "production" - ? "example.com" - : $app.stage === "dev" - ? "dev.example.com" - : undefined; -``` - -Now when we deploy the dev stage, we'll create a new `Router` with our dev domain. - -```diff lang="ts" title="sst.config.ts" -const router = new sst.aws.Router("MyRouter", { - domain: { -- name: "example.com", -- aliases: ["*.example.com"] -+ name: domain, -+ aliases: [`*.${domain}`] - } -}); -``` - -And update the `MyDocs` component to use this. - -```diff lang="ts" title="sst.config.ts" -// Docs -const docs = new sst.aws.Astro("MyDocs", { - path: "packages/docs", - router: { - instance: router, -- domain: "docs.example.com" -+ domain: `docs.${domain}` - } -}); -``` - ---- - -## Preview environments - -Currently, we create a new CloudFront distribution for dev and production. But we want to **share the same distribution from dev** in our PR stages. - ---- - -### Share the router - -To do that, let's modify how we create the `Router`. - -```diff lang="ts" title="sst.config.ts" -- const router = new sst.aws.Router("MyRouter", { -+ const router = isPermanentStage - ? new sst.aws.Router("MyRouter", { - domain: { - name: domain, - aliases: [`*.${domain}`] - } - }) -+ : sst.aws.Router.get("MyRouter", "A2WQRGCYGTFB7Z"); -``` - -The `A2WQRGCYGTFB7Z` is the ID of the Router distribution created in the dev stage. You can look this up in the SST Console or output it when you deploy your dev stage. - -```ts title="sst.config.ts" -return { - router: router.distributionID -}; -``` - -We are also defining `isPermanentStage`. This is set to `true` if the stage is `dev` or `production`. - -```ts title="sst.config.ts" -const isPermanentStage = ["production", "dev"].includes($app.stage); -``` - -Let's also update our `domain` helper. - -```diff lang="ts" title="sst.config.ts" -const domain = $app.stage === "production" - ? "example.com" - : $app.stage === "dev" - ? "dev.example.com" -- : undefined; -+ : `${$app.stage}.dev.example.com`; -``` - -Since the domain alias for the dev stage is set to `*.dev.example.com`, it can match `pr-123.dev.example.com`. But not `docs.pr-123.dev.example.com`. This is a limitation of CloudFront. - ---- - -### Nested subdomains - -So we'll be using `docs-pr-123.dev.example.com` instead. - -:::note -Nested wildcards domain patterns are not supported. -::: - -To do this, let's add a helper function. - -```ts title="sst.config.ts" -function subdomain(name: string) { - if (isPermanentStage) return `${name}.${domain}`; - return `${name}-${domain}`; -} -``` - -This will add the `-` for our PR stages. Let's update our `MyDocs` component to use this. - -```diff lang="ts" title="sst.config.ts" -// Docs -const docs = new sst.aws.Astro("MyDocs", { - path: "packages/docs", - router: { - instance: router, -- domain: `docs.${domain}` -+ domain: subdomain("docs") - } -}); -``` - ---- - -## Wrapping up - -And that's it! We've now configured our router to serve our entire app. - -Here's what the final config looks like. - -```ts title="sst.config.ts" -const isPermanentStage = ["production", "dev"].includes($app.stage); - -const domain = $app.stage === "production" - ? "example.com" - : $app.stage === "dev" - ? "dev.example.com" - : `${$app.stage}.dev.example.com`; - -function subdomain(name: string) { - if (isPermanentStage) return `${name}.${domain}`; - return `${name}-${domain}`; -} - -const router = isPermanentStage - ? new sst.aws.Router("MyRouter", { - domain: { - name: domain, - aliases: [`*.${domain}`] - } - }) - : sst.aws.Router.get("MyRouter", "A2WQRGCYGTFB7Z"); - -// Frontend -const web = new sst.aws.Nextjs("MyWeb", { - path: "packages/web", - router: { - instance: router - } -}); - -// API -const api = new sst.aws.Function("MyApi", { - handler: "packages/functions/api.handler", - url: { - router: { - instance: router, - path: "/api" - } - } -}); - -// Docs -const docs = new sst.aws.Astro("MyDocs", { - path: "packages/docs", - router: { - instance: router, - domain: subdomain("docs") - } -}); -``` - -Our components are all sharing the same CloudFront distribution. We also have our PR stages sharing the same router as our dev stage. diff --git a/www/src/content/docs/docs/console.mdx b/www/src/content/docs/docs/console.mdx deleted file mode 100644 index 1eb18c0fbc..0000000000 --- a/www/src/content/docs/docs/console.mdx +++ /dev/null @@ -1,821 +0,0 @@ ---- -title: Console -description: Manage and monitor your apps with the SST Console. ---- - -import { Image } from "astro:assets" -import { Tabs, TabItem } from '@astrojs/starlight/components'; - -import consoleHomeLight from '../../../assets/docs/console/sst-console-home-light.png'; -import consoleHomeDark from '../../../assets/docs/console/sst-console-home-dark.png'; -import consoleLogsLight from '../../../assets/docs/console/sst-console-logs-light.png'; -import consoleLogsDark from '../../../assets/docs/console/sst-console-logs-dark.png'; -import consoleIssuesLight from '../../../assets/docs/console/sst-console-issues-light.png'; -import consoleIssuesDark from '../../../assets/docs/console/sst-console-issues-dark.png'; -import consoleLocalLight from '../../../assets/docs/console/sst-console-local-light.png'; -import consoleLocalDark from '../../../assets/docs/console/sst-console-local-dark.png'; -import consoleResourcesLight from '../../../assets/docs/console/sst-console-resources-light.png'; -import consoleResourcesDark from '../../../assets/docs/console/sst-console-resources-dark.png'; -import consoleUpdatesLight from '../../../assets/docs/console/sst-console-updates-light.png'; -import consoleUpdatesDark from '../../../assets/docs/console/sst-console-updates-dark.png'; -import consoleAutodeployLight from '../../../assets/docs/console/sst-console-autodeploy-light.png'; -import consoleAutodeployDark from '../../../assets/docs/console/sst-console-autodeploy-dark.png'; - -The Console is a web based dashboard to manage your SST apps β€” [**console.sst.dev**](https://console.sst.dev) - -With it, you and your team can see all your apps, their **resources** and **updates**, **view logs**, **get alerts** on any issues, and **_git push to deploy_** them. - - - - - - SST Console - - - -:::tip -The Console is completely optional and comes with a free tier. -::: - ---- - -## Get started - -Start by creating an account and connecting your AWS account. - -:::note -Currently the Console only supports apps **deployed to AWS**. -::: - -1. **Create an account with your email** - - It's better to use your work email so that you can invite your team to your workspace later β€” [**console.sst.dev**](https://console.sst.dev) - -2. **Create a workspace** - - You can add your apps and invite your team to a workspace. A workspace can be for a personal project or for your team at work. You can create as many workspaces as you want. - - :::tip - Create a workspace for your organization. You can use it to invite your team and connect all your AWS accounts. - ::: - -2. **Connect your AWS account** - - This will ask you to create a CloudFormation stack in your AWS account. Make sure that this stack is being added to **us-east-1**. Scroll down and click **Create stack**. - - :::caution - The CloudFormation stack needs to be created in **us-east-1**. If you create it in the wrong region by mistake, remove it and create it again. - ::: - - This stack will scan all the regions in your account for SST apps and subscribe to them. Once created, you'll see all your apps, stages, and the functions in the apps. - - If you are connecting a newly created AWS account, you might run into the following error while creating the stack. - - > Resource handler returned message: "Specified ReservedConcurrentExecutions for function decreases account's UnreservedConcurrentExecution below its minimum value - - This happens because AWS has been limiting the concurrency of Lambda functions for new accounts. It's a good idea to increase this limit before you go to production anyway. - - To do so, you can [request a quota increase](https://repost.aws/knowledge-center/lambda-concurrency-limit-increase) to the default value of 1000. You can also do the following to expedite the request. - -
    - Expedite the request - If you want to expedite the request: - - 1. Submit the request. - 2. Click the **Quota request history** link in the sidebar. - 3. Click on **AWS Support Center Case** to open your request case details. - 4. Hit the **Reply** button and select **Chat** to chat with an AWS representative to expedite it. -
    - -3. **Invite your team** - - Use the email address of your teammates to invite them. They just need to login with the email you've used and they'll be able to join your workspace. - ---- - -## How it works - -At a high level, here's how the Console works. - -- It's hosted on our side - - It stores some metadata about what resources you have deployed. We'll have a version that can be self-hosted in the future. - -- You can view all your apps and stages - - Once you've connected your AWS accounts, it'll deploy a separate CloudFormation stack and connect to any SST apps in it. And all your apps and stages will show up automatically. - -- It's open-source and built with SST - - The Console is an SST app. You can view the [source on GitHub](https://github.com/sst/console). It's also auto-deployed using itself. - ---- - -## Security - -The CloudFormation stack that the Console uses, creates an IAM Role in your account to manage your resources. If this is a concern for your production environments, we have a couple of options. - -By default, this role is granted `AdministratorAccess`, but you can customize it to restrict access. We'll look at this below. Additionally, if you'd like us to sign a BAA, feel free to [contact us][contact-us]. - -There maybe cases where you don't want any data leaving your AWS account. For this, we'll be supporting self-hosting the Console in the future. - ---- - -#### IAM permissions - -Permissions for the Console fall into two categories: read and write: - -- **Read Permissions**: The Console needs specific permissions to display information about resources within your SST apps. - - | Purpose | AWS IAM Action | - |----------------------------------------|----------------------------------| - | Fetch stack outputs | `cloudformation:DescribeStacks` | - | Retrieve function runtime and size | `lambda:GetFunction` | - | Access stack metadata | `ec2:DescribeRegions`
    `s3:GetObject`
    `s3:ListBucket`| - | Display function logs | `logs:DescribeLogStreams`
    `logs:FilterLogEvents`
    `logs:GetLogEvents`
    `logs:StartQuery`| - | Monitor invocation usage | `cloudwatch:GetMetricData` | - - Attach the `arn:aws:iam::aws:policy/ReadOnlyAccess` AWS managed policy to the IAM Role for comprehensive read access. - -- **Write Permissions**: The Console requires the following write permissions. - - | Purpose | AWS IAM Action | - |-----------------------------------------------------|------------------------------------------------------------------------------| - | Forward bootstrap bucket events to event bus | `s3:PutBucketNotification` | - | Send events to Console | `events:PutRule`
    `events:PutTargets` | - | Grant event bus access for Console | `iam:CreateRole`
    `iam:DeleteRole`
    `iam:DeleteRolePolicy`
    `iam:PassRole`
    `iam:PutRolePolicy` | - | Enable Issues to subscribe logs | `logs:CreateLogGroup`
    `logs:PutSubscriptionFilter` | - | Invoke Lambda functions and replay invocations | `lambda:InvokeFunction` | - - -It's good practice to periodically review and update these policies. - ---- - -#### Customize policy - -To customize IAM permissions for the CloudFormation stack: - -1. On the CloudFormation create stack page, download the default `template.json`. - -2. Edit the template file with necessary changes. - -
    - _View the template changes_ - - ```diff title="template.json" - "SSTRole": { - "Type": "AWS::IAM::Role", - "Properties": { - ... - "ManagedPolicyArns": [ - - "arn:aws:iam::aws:policy/AdministratorAccess" - + "arn:aws:iam::aws:policy/ReadOnlyAccess" - + ], - + "Policies": [ - + { - + "PolicyName": "SSTPolicy", - + "PolicyDocument": { - + "Version": "2012-10-17", - + "Statement": [ - + { - + "Effect": "Allow", - + "Action": [ - + "s3:PutBucketNotification" - + ], - + "Resource": [ - + "arn:aws:s3:::sstbootstrap-*" - + ] - + }, - + { - + "Effect": "Allow", - + "Action": [ - + "events:PutRule", - + "events:PutTargets" - + ], - + "Resource": { - + "Fn::Sub": "arn:aws:events:*:${AWS::AccountId}:rule/SSTConsole*" - + } - + }, - + { - + "Effect": "Allow", - + "Action": [ - + "iam:CreateRole", - + "iam:DeleteRole", - + "iam:DeleteRolePolicy", - + "iam:PassRole", - + "iam:PutRolePolicy" - + ], - + "Resource": { - + "Fn::Sub": "arn:aws:iam::${AWS::AccountId}:role/SSTConsolePublisher*" - + } - + }, - + { - + "Effect": "Allow", - + "Action": [ - + "logs:CreateLogGroup", - + "logs:PutSubscriptionFilter" - + ], - + "Resource": { - + "Fn::Sub": "arn:aws:logs:*:${AWS::AccountId}:log-group:*" - + } - + }, - + { - + "Effect": "Allow", - + "Action": [ - + "lambda:InvokeFunction" - + ], - + "Resource": { - + "Fn::Sub": "arn:aws:lambda:*:${AWS::AccountId}:function:*" - + } - + } - + ] - + } - + } - ] - } - } - ``` - -
    - -3. Upload your edited `template.json` file to an S3 bucket. - -4. Return to the CloudFormation create stack page and replace the template URL in the page URL. - ---- - -## Pricing - -[Starting Feb 1, 2025](/blog/console-pricing-update), the Console will be priced based on the number of active resources in your SST apps. - -| Resources | Rate per resource | -|-----------|-----------| -| First 2000 | $0.086 | -| 2000+ | $0.032 | - -**Free Tier**: Workspaces with 350 active resources or fewer. - -So for example, if you go over the free tier and have 351 active resources in a month, your bill will be 351 x $0.086 = $30.2. - -A couple of things to note. - -- These are calculated for a given workspace every month. -- A resource is what SST creates in your cloud provider. [Learn more below](#faq). -- You can always access personal stages, even if you're above the free tier. -- A resource is considered active if it comes from a stage: - - That has been around for at least 2 weeks. - - And, was updated during the month. -- For volume pricing, feel free to [contact us][contact-us]. - -[Learn more in the FAQ](#faq). - ---- - -##### Active resources - -A resource is considered active if it comes from a stage that has been around for at least 2 weeks. And, was updated during the month. - -Let's look at a few different scenarios to see how this works. - -- A stage that was created 5 months ago and was deployed this month, is active. -- A stage that was created 5 months ago but was not deployed this month, is not active. -- A stage that was created 12 days ago, is not active. -- A stage that was created 20 days ago and was removed 10 days ago, is not active. -- A stage that was created 5 months ago, deployed this month, then removed this month, is active. -- A stage created 5 months ago, was not deployed this month, and removed this month, is not active. - ---- - -#### Old pricing - -Previously, the Console pricing was based on the number of times the Lambda functions in your SST apps are invoked per month and it used the following tiers. - -| Invocations | Rate (per invocation) | -|-------------|------| -| First 1M | Free | -| 1M - 10M | $0.00002 | -| 10M+ | $0.000002 | - -- These are calculated for a given workspace on a monthly basis. -- This does not apply to personal stages, they'll be free forever. -- There's also a soft limit for Issues on all accounts. -- For volume pricing, feel free to [contact us][contact-us]. - ---- - -## Features - -Here are a few of the things the Console does for you. - -1. [**Logs**](#logs): View logs from any log group in your app -2. [**Issues**](#issues): Get real-time alerts for any errors in your app -3. [**Local logs**](#local-logs): View logs from your local `sst dev` session -4. [**Updates**](#updates): View the details of every update made to your app -5. [**Resources**](#resources): View all the resources in your app and their props -6. [**Autodeploy**](#autodeploy): Auto-deploy your app when you _git push_ to your repo - ---- - -### Logs - -With the Console, you don't need to go to CloudWatch to look at the logs for your functions, containers and other log groups. You can view: - -- View recent logs -- Jump to a specific time -- Search for logs with a given string - - - - - SST Console Logs - - ---- - -### Issues - -The Console will automatically show you any errors in your Node.js Lambda functions and containers in real-time. And notify you through Slack or email. - - - - - SST Console Issues - - -With Issues, there is: - -- **Nothing to setup**, no code to instrument -- **Source maps** are supported **automatically** -- **No impact on performance**, since your code isn't modified - -:::note -Issues works out of the box and has no impact on performance. -::: - -Issues currently only supports Node.js functions and containers. Other languages and runtimes are on the roadmap. - ---- - -#### Error detection - -For the Console to automatically report your errors, you need to `console.error` an error object. - -```js title="src/index.ts" -console.error(new Error("my-error")); -``` - -This works a little differently for containers and functions. - -- **Containers** - - In a container applications, your code needs to also import the [SST JS SDK](/docs/reference/sdk/). - - ```js title="src/index.ts" {1} - import "sst"; - - console.error(new Error("my-error")); - ``` - - This applies a polyfill to the `console` object to prepend the log lines with a marker that allows Issues to detect errors. [More on this below](#how-it-works-1). - - If you are already importing the SDK, you won't need to add an additional import. - -- **Functions** - - In addition, to errors logged using `console.error(new Error("my-error"))`, Issues also reports Lambda function failures. - - ```js title="src/lambda.ts" - console.error(new Error("my-error")); - ``` - - In Lambda you don't need to import the SDK to polyfill the `console` object. Since the Lambda runtime does this automatically for you. - ---- - -#### How it works - -Here's how Issues works behind the scenes. - -1. When an app is deployed or when an account is first synced, we add a log subscriber to the CloudWatch Log groups in your SST apps. - - This is added to your AWS account and includes a Lambda function. More on this below. -2. If the subscriber filter matches anything that looks like an error it invokes the Lambda function. - - In case of errors from a Lambda function, the Lambda runtime automatically adds a marker to the logs that the filter matches for. - - For containers, the SST SDK polyfills the `console` object to add the marker. -3. The Lambda function tries to parse the error. If the error comes from a Lambda function, it fetches the source maps from the state bucket in your account. -4. It then hits an endpoint in the SST Console and passes in that error. -5. Finally, the Console groups similar looking errors together and displays them. - ---- - -#### Log subscriber - -The log subscriber also includes the following: - -1. **Lambda function** that'll be invoked when a log with an error is matched. - - This function has a max concurrency set to 10. - - If it falls behind on processing by over 10 minutes, it'll discard the logs. - - This prevents it from scaling indefinitely when there's a burst of errors. - - This also means that if there are a lot of errors, the alerts might be delayed by up to 10 minutes. -2. **IAM role** that gives it access to query the logs and the state bucket for the source maps. -3. **Log group** with a 1 day retention. - -These are added to **every region** in your AWS account that has a CloudWatch log group from your SST apps. It's deployed using a CloudFormation stack. - -This process of adding a log subscriber might fail if we: - -- Don't have enough permissions. In this case, update the permissions that you've granted to the Console. -- Hit the limit for the number of subscribers, there's a maximum of 2 subscribers. To fix this, you can remove one of the existing subscribers. - -You can see these errors in the Issues tab. Once you've fixed these issues, you can hit **Retry** and it'll try attaching the subscriber again. - ---- - -#### Costs - -AWS will bill you for the Lambda function log subscriber that's in your account. This is usually fairly minimal. - -Even if your apps are generating an infinite number of errors, the Lambda function is limited to a concurrency of 10. So the **maximum** you'll be charged $43 x 10 = **$430 per month x # of regions** that are being monitored. - -You can also disable Issues from your workspace settings, if you are using a separate service for monitoring. - -[Learn more about Lambda pricing](https://aws.amazon.com/lambda/pricing/). - ---- - -### Updates - -Each update in your app also gets a unique URL, a **_permalink_**. This is printed out by the SST CLI. - -```bash title="sst deploy" -β†— Permalink https://sst.dev/u/318d3879 -``` - -You can view these updates in the Console. Each update shows: - -1. Full list of **all the resources** that were modified -2. Changes in their **inputs and outputs** -3. Any Docker or site **builds logs** -4. **CLI command** that triggered the update -5. **Git commit**, if it was an auto-deploy - -The permalink is useful for sharing with your team and debugging any issues with your deploys. - - - - - SST Console Updates - - -The CLI updates your [state](/docs/state/) with the event log from each update and generated a globally unique id. If your AWS account is connected to the Console, it'll pull the state and event log to generate the details for the update permalink. - -When you visit the permalink, the Console looks up the id of the update and redirects you to the right app in your workspace. - ---- - -### Resources - -The Console shows you the complete [state of the resources](/docs/state/) in your app. You can view: - -1. Each resource in your app -2. The relation between resources -3. The outputs of a given resource - - - - - SST Console Resources - - ---- - -### Autodeploy - -The Console can auto-deploy your apps when you _git push_ to your GitHub repo. Autodeploy uses [AWS CodeBuild](https://aws.amazon.com/codebuild/) in your account to run the build. - - - - - SST Console Autodeploy - - -We designed Autodeploy to be a better fit for SST apps when compared to alternatives like GitHub Actions or CircleCI. - -1. **Easy to get started** - - Autodeploy supports the standard branch and PR workflow out of the box. You don't need a config file to get started. - - There are no complicated steps in configuring your AWS credentials; since your AWS account is already connected to the Console. -2. **Configurable** - - You can configure how Autodeploy works directly through your `sst.config.ts`. - - It's typesafe and the callbacks let you customize how to respond to incoming git events. -3. **Runs in your AWS account** - - The builds are run in your AWS account. - - It can also be configured to run in your VPC. This is useful if your builds need to access private resources. -4. **Integrates with the Console** - - You can see which resources were updated in a deploy. - - Your resource updates will also show you the related git commit. - ---- - -#### Setup - -To get started with Autodeploy: - -1. **Enable the GitHub integration** - - Head over to your **Workspace settings** > **Integrations** and enable GitHub. This will ask you to login to GitHub and you'll be asked to pick the GitHub organization or user you want to link to. - - :::tip - You can only associate your workspace with a single GitHub org. - ::: - - If you have multiple GitHub orgs, you can create multiple workspaces in the Console. - -2. **Connect a repo** - - To auto-deploy an app, head over to the **App's Settings** > **Autodeploy** and select the repo for the app. - -3. **Configure an environment** - - Next you can configure a branch or PR environment by selecting the **stage** you want deployed to an **AWS account**. You can optionally configure **environment variables** as well. - - :::note - Stage names by default are generated based on the branch or PR. - ::: - - By default, stages are based on the branch name or PR. We'll look at this in detail below. - -4. **Git push** - - Finally, _git push_ to the environment you configured and head over to your app's **Autodeploy** tab to see it in action. - - :::note - PR stages are removed when the PR is closed while branch stages are not. - ::: - - For example, if you configure a branch environment for the stage `production`, any git pushes to the `production` branch will be auto-deployed. Similarly, if you create a new PR, say PR#12, the Console will auto-deploy a stage called `pr-12`. - - You can also manually trigger a deployment through the Console by passing in a Git ref and the stage you want to deploy to. - -5. **Setup alerts** - - Once your deploys are working, you can set the Console to send alerts for your deploys. Head over to your **Workspace Settings** > **Alerts** and add a new alert to be notified on any Autodeploys, or only on Autodeploy errors. - -:::tip -You can configure how Autodeploy works through your `sst.config.ts`. -::: - -While Autodeploy supports the standard branch and PR workflow out of the box, it can be configured in depth through your `sst.config.ts`. - ---- - -#### Configure - -The above can be configured through the [`console.autodeploy`](/docs/reference/config/#console-autodeploy) option in the `sst.config.ts`. - -```ts title="sst.config.ts" {7-15} -export default $config({ - // Your app's config - app(input) { }, - // Your app's resources - async run() { }, - // Your app's Console config - console: { - autodeploy: { - target(event) { - if (event.type === "branch" && event.branch === "main" && event.action === "pushed") { - return { stage: "production" }; - } - } - } - } -}); -``` - -In the above example we are using the `console.autodeploy.target` option to change the stage that's tied to a git event. Only git pushes to the `main` branch to auto-deploy to the `production` stage. - -This works because if `target` returns `undefined`, the deploy is skipped. And if you provide your own `target` callback, it overrides the default behavior. - -:::tip -You can use the git events to configure how your app is auto-deployed. -::: - -Through the `console.autodeploy.runner` option, you can configure the runner that's used. For example, if you wanted to increase the timeouts to 2 hours, you can. - -```ts title="sst.config.ts" -console: { - autodeploy: { - runner: { timeout: "2 hours" } - } -} -``` - -This also takes the stage name, so you can set the runner config for a specific stage. - -```ts title="sst.config.ts" -console: { - autodeploy: { - runner(stage) { - if (stage === "production") return { timeout: "3 hours" }; - } - } -} -``` - -You can also have your builds run inside your VPC. - -```ts title="sst.config.ts" -console: { - autodeploy: { - runner: { - vpc: { - id: "vpc-0be8fa4de860618bb", - securityGroups: ["sg-0399348378a4c256c"], - subnets: ["subnet-0b6a2b73896dc8c4c", "subnet-021389ebee680c2f0"] - } - } - } -} -``` - -Or specify files and directories to be cached. - -```ts title="sst.config.ts" -console: { - autodeploy: { - runner: { - cache: { - paths: ["node_modules", "/path/to/cache"] - } - } - } -} -``` - -Read more about the [`console.autodeploy`](/docs/reference/config/#console-autodeploy) config. - ---- - -#### Environments - -The Console needs to know which account it needs to autodeploy into. You configure this under the **App's Settings** > **Autodeploy**. Each environment takes: - -1. **Stage** - - The stage that is being deployed. By default, the stage name comes from the name of the branch. Branch names are sanitized to only letters/numbers and hyphens. So for example: - - A push to a branch called `production` will deploy a stage called `production`. - - A push to PR#12 will deploy to a stage called `pr-12`. - - As mentioned, above you can customize this through your `sst.config.ts`. - - :::tip - You can specify a pattern to match the stage name in your environments. - ::: - - If multiple stages share the same environment, you can use a glob pattern. For example, `pr-*` matches all stages that start with `pr-`. - -2. **AWS Account** - - The AWS account that you are deploying to. - -3. **Environment Variables** - - Any environment variables you need for the build process. These are made available under `process.env.*` in your `sst.config.ts`. - ---- - -#### How it works - -When you _git push_ to a branch, pull request, or tag, the following happens: - -1. The stage name is generated based on the `console.autodeploy.target` callback. - 1. If there is no callback, the stage name is a sanitized version of the branch or tag. - 2. If there is a callback but no stage is returned, the deploy is skipped. -2. The stage is matched against the environments in the Console to get the AWS account and any environment variables for the deploy. -3. The runner config is generated based on the `console.autodeploy.runner`. Or the defaults are used. -4. The deploy is run based on the above config. - -This only applies only to git events. If you trigger a deploy through the Console, you are asked to specify the stage you want to deploy to. So in this case, it skips step 1 from above and does not call `console.autodeploy.target`. - -Both `target` and `runner` are optional and come with defaults, but they can be customized. - ---- - -#### Costs - -AWS will bill you for the **CodeBuild build minutes** that are used to run your builds. [Learn more about CodeBuild pricing](https://aws.amazon.com/codebuild/pricing/). - ---- - -### Local logs - -When the Console starts up, it checks if you are running `sst dev` locally. If so, then it'll show you real-time logs from your local terminal. This works by connecting to a local server that's run as a part of the SST CLI. - - - - - SST Console Local logs - - -:::info -The local server only allows access from `localhost` and `console.sst.dev`. -::: - -The local logs works in all browsers and environments. But for certain browsers like Safari or Brave, and Gitpod, it needs some additional configuration. - ---- - -#### Safari & Brave - -Certain browsers like Safari and Brave require the local connection between the browser and the `sst dev` CLI to be running on HTTPS. - -SST can automatically generate a locally-trusted certificate using the [`sst cert`](/docs/reference/cli#cert) command. - -```bash -sst cert -``` - -You'll only need to **run this once** on your machine. - ---- - -#### Gitpod - -If you are using [Gitpod](https://www.gitpod.io/), you can use the Gitpod Local Companion app to connect to the `sst dev` process running inside your Gitpod workspace. - -To get started: - -1. [Install Gitpod Local Companion app](https://www.gitpod.io/blog/local-app#installation) -2. [Run the Companion app](https://www.gitpod.io/blog/local-app#running) -3. Navigate to Console in the browser - -The companion app runs locally and creates a tunnelled connection to your Gitpod workspace. - ---- - -## FAQ - -Here are some frequently asked questions about the Console. - -- Do I need to use the Console to use SST? - - You **don't need the Console** to use SST. It compliments the CLI and has some features that help with managing your apps in production. - - That said, it is completely free to get started. You can create an account and invite your team, **without** having to add a **credit card**. - -- Is there a free tier? - - If your workspace has 350 active resources or fewer for the month, it's considered to be in the free tier. This count also resets every month. - -- What happens if I go over the free tier? - - You won't be able to access the _production_ or deployed stages till you add your billing details in the workspace settings. - - Note that, you can continue to **access your personal stages**. Just make sure you have `sst dev` running locally. Otherwise the Console won't be able to detect that it's a personal stage. - -- What counts as a resource? - - Resources are what SST creates in your cloud provider. This includes the resources created by both SST's built-in components, like `Function`, `Nextjs`, `Bucket`, and the ones created by any other Terraform/Pulumi provider. - - Some components, like `Nextjs` and `StaticSite`, create multiple resources. In general, the more complex the component, the more resources it'll create. - - You can see a [full list of resources](#resources) if you go to an app in your Console and navigate to a stage in it. - - For some context, the Console is itself a pretty large [SST app](https://github.com/sst/console) and it has around 320 resources. - -- Do PR stages also count? - - A stage has to be around for at least 2 weeks before the resources in it are counted as active. So if a PR stage is created and removed within 2 weeks, they don't count. - - However, if you remove a stage and create a new one with the same name, it does not reset the 2 week initial period. - ---- - -#### Old pricing FAQ - -Here were some frequently asked questions about the old pricing plan for the Console. - -- Do I need to switch to the new pricing? - - If you are currently on the old plan, you don't have to switch and you won't be automatically switched over either. - - You can go to the workspace settings and check out how much you'll be billed based on both the plans. To switch over, you can cancel your current plan and then subscribe to the new plan. - - At some point in the future, we'll remove the old plan. But there's no specific timeline for it yet. - -- Which Lambda functions are included in the number of invocations? - - The number of invocations are only counted for the **Lambda functions in your SST apps**. Other Lambda functions in your AWS accounts are not included. - -- Do the functions in my personal stages count as a part of the invocations? - - Lambda functions that are invoked **locally are not included**. - -- My invocation volume is far higher than the listed tiers. Are there any other options? - - Feel free to [contact us][contact-us] and we can figure out a pricing plan that works for you. - - -If you have any further questions, feel free to [send us an email][contact-us]. - - -[contact-us]: mailto:hello@sst.dev diff --git a/www/src/content/docs/docs/custom-domains.mdx b/www/src/content/docs/docs/custom-domains.mdx deleted file mode 100644 index ca906c6194..0000000000 --- a/www/src/content/docs/docs/custom-domains.mdx +++ /dev/null @@ -1,257 +0,0 @@ ---- -title: Custom Domains -description: Configure custom domains in your components. ---- - -import { Tabs, TabItem } from '@astrojs/starlight/components'; - -You can configure custom domains and subdomains for your frontends, APIs, services, or routers in SST. - -:::note -SST currently supports configuring custom domains for AWS components. -::: - -By default, these components auto-generate a URL. You can pass in the `domain` to use your custom domain. - - - - ```ts title="sst.config.ts" {2} - new sst.aws.Nextjs("MyWeb", { - domain: "example.com" - }); - ``` - - - ```ts title="sst.config.ts" {2} - new sst.aws.ApiGatewayV2("MyApi", { - domain: "api.example.com" - }); - ``` - - - ```ts title="sst.config.ts" {6} - const vpc = new sst.aws.Vpc("MyVpc"); - - new sst.aws.Cluster("MyCluster", { - vpc, - loadBalancer: { - domain: "example.com" - } - }); - ``` - - - ```ts title="sst.config.ts" {2} - new sst.aws.Router("MyRouter", { - domain: "example.com" - }); - ``` - - - -SST supports a couple of DNS providers automatically. These include AWS Route 53, Cloudflare, and Vercel. Other providers will need to be manually configured. - -We'll look at how it works below. - ---- - -##### Redirect www to apex domain - -A common use case is to redirect `www.example.com` to `example.com`. You can do this by: - -```ts title="sst.config.ts" {3,4} -new sst.aws.Router("MyRouter", { - domain: { - name: "example.com", - redirects: ["www.example.com"] - } -}); -``` - ---- - -##### Add subdomains - -You can add subdomains to your domain. This is useful if you want to use a `Router` to route a subdomain to a separate resource. - -```ts title="sst.config.ts" {3,4,11} -const router = new sst.aws.Router("MyRouter", { - domain: { - name: "example.com", - aliases: ["*.example.com"] - } -}); - -new sst.aws.Nextjs("MyWeb", { - router: { - instance: router, - domain: "docs.example.com" - } -}); -``` - -Here if a user visits `docs.example.com`, they'll kept on the alias domain and be served the docs site. - -:::tip -You can use the `Router` component to centrally manage domains and routing for your -app. [Learn more](/docs/configure-a-router). -::: - -However, this does not match `docs.dev.example.com`. For that, you'll need to add `*.dev.example.com` as an alias. - ---- - -## How it works - -Configuring a custom domain is a two step process. - -1. Validate that you own the domain. For AWS you do this by [creating an ACM certificate](https://docs.aws.amazon.com/acm/latest/userguide/domain-ownership-validation.html) and validating it by: - - Setting a DNS record with your domain provider. - - Verifying through an email sent to the domain owner. -2. Add the DNS records to route your domain to your component. - -SST can perform these steps automatically for the supported providers through a concept of _adapters_. These create the above DNS records on a given provider. - ---- - -## Adapters - -You can use a custom domain hosted on any provider. SST supports domains on AWS, Cloudflare, and Vercel automatically. - ---- - -### AWS - -By default, if you set a custom domain, SST assumes the domain is configured in AWS Route 53 in the same AWS account. - -```js -{ - domain: { - name: "example.com" - } -} -``` - -This is the same as using the [`sst.aws.dns`](/docs/component/aws/dns/) adapter. - -```js -{ - domain: { - name: "example.com", - dns: sst.aws.dns() - } -} -``` - -If you have the same domain in multiple hosted zones in Route 53, you can specify the hosted zone. - -```js {5} -{ - domain: { - name: "example.com", - dns: sst.aws.dns({ - zone: "Z2FDTNDATAQYW2" - }) - } -} -``` - -If your domains are hosted on AWS but in a separate AWS account, you'll need to follow the [manual setup](#manual-setup). - ---- - -### Vercel - -If your domains are hosted on [Vercel](https://vercel.com), you'll need to do the following. - -1. [Add the Vercel provider to your app](/docs/component/vercel/dns/#configure-provider). - - ```bash - sst add vercel - ``` - -2. Set the **`VERCEL_API_TOKEN`** in your environment. You might also need to set the `VERCEL_TEAM_ID` if the domain belongs to a team. - - ```bash - export VERCEL_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa - ``` - -3. Use the [`sst.vercel.dns`](/docs/component/vercel/dns/) adapter. - - ```js - { - domain: { - name: "example.com", - dns: sst.vercel.dns() - } - } - ``` - ---- - -### Cloudflare - -If your domains are hosted on [Cloudflare](https://developers.cloudflare.com/dns/), you'll need to do the following. - -1. Add the Cloudflare provider to your app. - - ```bash - sst add cloudflare - ``` - -2. Set the **`CLOUDFLARE_API_TOKEN`** in your environment. - - ```bash - export CLOUDFLARE_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa - export CLOUDFLARE_DEFAULT_ACCOUNT_ID=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa - ``` - - To get your API tokens, head to the [API Tokens section](https://dash.cloudflare.com/?to=/:account/api-tokens) of your Cloudflare dashboard and create one with the **Edit zone DNS** policy. - - The Cloudflare providers need these credentials to deploy your app in the first place, which means they can't be set using the `sst secret` CLI. - - If you are auto-deploying your app through the [SST Console](console.mdx#autodeploy) or through your CI, you'll need to set these as environment variables. - - -3. Use the [`sst.cloudflare.dns`](/docs/component/cloudflare/dns/) adapter. - - ```js - { - domain: { - name: "example.com", - dns: sst.cloudflare.dns() - } - } - ``` - ---- - -## Manual setup - -If your domain is on a provider that is not supported above, or is in a separate AWS account; you'll need to verify that you own the domain and set up the DNS records on your own. - -To manually set up a domain on an unsupported provider, you'll need to: - -1. [Validate that you own the domain](https://docs.aws.amazon.com/acm/latest/userguide/domain-ownership-validation.html) by creating an ACM certificate. You can either validate it by setting a DNS record or by verifying an email sent to the domain owner. - - :::note - For CloudFront distributions, the certificate needs to be created in `us-east-1`. - ::: - - If you are configuring a custom domain for a CloudFront distribution, the ACM certificate that's used to prove that you own the domain needs be created in the `us-east-1` region. - - For all the other components, like ApiGatewayV2 or Cluster, can be created in any region. - -2. Once validated, set the certificate ARN as the `cert` and set `dns` to `false`. - - ```js - { - domain: { - name: "domain.com", - dns: false, - cert: "arn:aws:acm:us-east-1:112233445566:certificate/3a958790-8878-4cdc-a396-06d95064cf63" - } - } - ``` - -3. Add the DNS records in your provider to point to the CloudFront distribution, API Gateway, or load balancer URL. diff --git a/www/src/content/docs/docs/environment-variables.mdx b/www/src/content/docs/docs/environment-variables.mdx deleted file mode 100644 index ca2774874b..0000000000 --- a/www/src/content/docs/docs/environment-variables.mdx +++ /dev/null @@ -1,199 +0,0 @@ ---- -title: Environment Variables -description: Manage the environment variables in your app. ---- - -You can manage the environment variables for all the components in your app, across all your stages, through the `sst.config.ts`. - -:::tip -You don't need to use `.env` files in SST. -::: - -While SST automatically loads your environment variables and `.env` files; we don't recommend relying on them. - ---- - -## Recommended - -Typically, you'll use environment variables or `.env` files to share things like database URLs, secrets, or other config. - -To understand why we don't recommend `.env` files, let's look at each of these in detail. - ---- - -### Links - -A very common use case for `.env` is to share something like a database URL across your app. - -Instead in SST, you can link the resources together. - -```ts title="sst.config.ts" {4} -const rds = new sst.aws.Postgres("MyPostgres"); - -new sst.aws.Nextjs("MyWeb", { - link: [rds] -}); -``` - -You can then access the database in your Next.js app with the [JS SDK](/docs/reference/sdk/). - -```ts title="app/page.tsx" {5-7} -import { Resource } from "sst"; - -export const db = drizzle(client, { - schema, - database: Resource.MyPostgres.database, - secretArn: Resource.MyPostgres.secretArn, - resourceArn: Resource.MyPostgres.clusterArn -}); -``` - -This has a couple of key advantages: - -1. You don't have to deploy your database separately and then store the credentials in a `.env` file. -2. You don't need to update this for every stage. -3. You don't have to share these URLs with your teammates. - -Anybody on your team can just run `sst deploy` on any stage and it'll deploy the app and link the resources. - -:::tip -Your team can just `git checkout` and `sst deploy`, without the need for a separate `.env` file. -::: - -You can learn more about [linking resources](/docs/linking/). - ---- - -### Secrets - -Another common use case for `.env` is to manage secrets across your app. - -SST has a built-in way to handle secrets. - -```ts title="sst.config.ts" {4} -const secret = new sst.Secret("MySecret"); - -new sst.aws.Nextjs("MyWeb", { - link: [secret] -}); -``` - -You can set the secret using the `sst secret` CLI. - -```bash title="Terminal" -sst secret set MySecret my-secret-value -``` - -This far more secure than storing it in a `.env` file and accidentally committing it to Git. - -Learn more about [secrets](/docs/component/secret). - ---- - -### Other config - -Finally, people use `.env` files for some general config. These are often different across stages and are not really sensitive. For example, you might have your `SENTRY_DSN` that's different for dev and prod. - -We recommend putting these directly in your `sst.config.ts` instead. And using the right one based on the stage. - -```ts title="sst.config.ts" -const SENTRY_DSN = $app.stage !== "prod" - ? "https://foo@sentry.io/bar" - : "https://baz@sentry.io/qux"; -``` - -You can also conditionally set it based on if you are running `sst dev` or `sst deploy`. - -```ts title="sst.config.ts" -const SENTRY_DSN = $dev === true - ? "https://foo@sentry.io/bar" - : "https://baz@sentry.io/qux"; -``` - -And you can pass this into your frontends and functions. - -```ts title="sst.config.ts" {3} -new sst.aws.Nextjs("MyWeb", { - environment: { - SENTRY_DSN - } -}); -``` - -Learn more about [`$app`](/docs/reference/global#app) and [`$dev`](/docs/reference/global#dev). - ---- - -## Traditional - -As mentioned above, SST also supports the traditional approach. If you run `sst dev` or `sst deploy` with an environment variable: - -```bash title="Terminal" "SOME_ENV_VAR=FOO" -SOME_ENV_VAR=FOO sst deploy -``` - -You can access it using the `process.env` in your `sst.config.ts`. - -```ts title="sst.config.ts" -async run() { - console.log(process.env.SOME_ENV_VAR); // FOO -} -``` - -However, this isn't automatically added to your frontends or functions. You'll need to add it manually. - -```ts title="sst.config.ts" {3} -new sst.aws.Nextjs("MyWeb", { - environment: { - SOME_ENV_VAR: process.env.SOME_ENV_VAR ?? "fallback value", - } -}); -``` - -SST doesn't do this automatically because you might have multiple frontends or functions and you might not want to load it for all of them. - -:::tip -Environment variables are not automatically added to your frontend or functions. -::: - -Now you can access it in your frontend. - -```ts title="app/page.tsx" -export default function Home() { - return

    Hello {process.env.SOME_ENV_VAR}

    ; -} -``` - ---- - -### .env - -The same thing works if you have a `.env` file in your project root. - -```bash title=".env" -SOME_ENV_VAR=FOO -``` - -It'll be loaded into `process.env` in your `sst.config.ts`. - -```ts title="sst.config.ts" -async run() { - console.log(process.env.SOME_ENV_VAR); // FOO -} -``` - -Or if you have a stage specific `.env.dev` file. - -```bash title=".env.dev" -SOME_ENV_VAR=BAR -``` - -And you run `sst deploy --stage dev`, it'll be loaded into `process.env` in your `sst.config.ts`. - -```ts title="sst.config.ts" -async run() { - console.log(process.env.SOME_ENV_VAR); // BAR -} -``` - -While the traditional approach works, we do not recommend it because it's both cumbersome and not secure. diff --git a/www/src/content/docs/docs/iam-credentials.mdx b/www/src/content/docs/docs/iam-credentials.mdx deleted file mode 100644 index 7c87eaf66d..0000000000 --- a/www/src/content/docs/docs/iam-credentials.mdx +++ /dev/null @@ -1,424 +0,0 @@ ---- -title: IAM Credentials -description: Configure the IAM credentials that's used to deploy your app. ---- - -SST deploys your AWS resources using your AWS credentials. In this guide we'll look at how to set these credentials, the basic set of permissions it needs, and how to customize it. - ---- - -## Credentials - -There are a couple of different ways to set the credentials that your app will use. The simplest is using a credentials file. - -However, if you're still figuring out how to configure your AWS account, we recommend [following our guide on it](/docs/aws-accounts). - ---- - -#### From a file - -By default, your AWS credentials are in a file: - -- `~/.aws/credentials` on Linux, Unix, macOS -- `C:\Users\USER_NAME\.aws\credentials` on Windows - -If the credentials file does not exist on your machine. - -1. Follow this to [create an IAM user](https://sst.dev/chapters/create-an-iam-user.html) -2. And then use this to [configure the credentials](https://sst.dev/chapters/configure-the-aws-cli.html) - -Below we'll look at how to customize the permissions that are granted to this user. - ---- - -Your credentials file might look like: - -```bash title="~/.aws/credentials" -[default] -aws_access_key_id = -aws_secret_access_key = -``` - -Where `default` is the name of the credentials profile. - -And if you have multiple credentials, it might look like: - -```bash title="~/.aws/credentials" -[default] -aws_access_key_id = -aws_secret_access_key = - -[staging] -aws_access_key_id = -aws_secret_access_key = - -[production] -aws_access_key_id = -aws_secret_access_key = -``` - -By default, SST uses the credentials for the `default` profile. To use one of the other profiles, set the `profile` in your `sst.config.ts`. - -```ts title="sst.config.ts" -{ - providers: { - aws: { - profile: "staging" - } - } -} -``` - -You can customize this for the stage your app is being deployed to. - -```ts title="sst.config.ts" -app(input) { - return { - // ... - providers: { - aws: { - profile: input?.stage === "staging" ? "staging" : "default" - } - } - }; -}, -``` - -If you've configured AWS credentials previously through the `AWS_PROFILE` environment variable or through a `.env` file, it will override the profile set in your `sst.config.ts`. So make sure to remove any references to `AWS_PROFILE`. - ---- - -#### From environment variables - -SST can also detect AWS credentials in your environment and use them to deploy. - -- `AWS_ACCESS_KEY_ID` -- `AWS_SECRET_ACCESS_KEY` - -If you are using temporary credentials, you can also set the `AWS_SESSION_TOKEN`. - -This is useful when you are deploying through a CI environment and there are no credential files around. - ---- - -### Precedence - -If you have AWS credentials set in multiple places, SST will first look at: - -1. Environment variables - - This includes `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, or `AWS_SESSION_TOKEN`, and `AWS_PROFILE`. This also includes environment variables set in a `.env` file. - -2. SST config - - Then it'll check for the credentials or `profile` in your `sst.config.ts`. - -3. AWS config - - It'll then check for the `[default]` profile in your `~/.aws/config` or `C:\Users\USER_NAME\.aws\config`. - -4. Credential files - - Finally, it'll look for any static credentials in your `~/.aws/credentials` or `C:\Users\USER_NAME\.aws\credentials`. - ---- - -## IAM permissions - -The credentials above are for an IAM user and it comes with an IAM policy. This defines what resources the given user has access to. By default, we are using `AdministratorAccess`. This gives your user complete access. - -However, if you are using SST at your company, you want to secure these permissions. Here we'll look at exactly what SST needs and how you can go about customizing it. - ---- - -Let's start with an IAM policy you can _copy and paste_. - -
    -**Copy IAM Policy** - -```json title="iam-policy.json" -{ - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "ManageBootstrapStateBucket", - "Effect": "Allow", - "Action": [ - "s3:CreateBucket", - "s3:PutBucketVersioning", - "s3:PutBucketNotification", - "s3:PutBucketPolicy", - "s3:DeleteObject", - "s3:DeleteObjectVersion", - "s3:GetObject", - "s3:ListBucket", - "s3:ListBucketVersions", - "s3:PutObject" - ], - "Resource": [ - "arn:aws:s3:::sst-state-*" - ] - }, - { - "Sid": "ManageBootstrapAssetBucket", - "Effect": "Allow", - "Action": [ - "s3:CreateBucket", - "s3:PutBucketVersioning", - "s3:PutBucketNotification", - "s3:PutBucketPolicy", - "s3:DeleteObject", - "s3:GetObject", - "s3:ListBucket", - "s3:PutObject" - ], - "Resource": [ - "arn:aws:s3:::sst-asset-*" - ] - }, - { - "Sid": "ManageBootstrapECRRepo", - "Effect": "Allow", - "Action": [ - "ecr:CreateRepository", - "ecr:DescribeRepositories" - ], - "Resource": [ - "arn:aws:ecr:REGION:ACCOUNT:repository/sst-asset" - ] - }, - { - "Sid": "ManageBootstrapSSMParameter", - "Effect": "Allow", - "Action": [ - "ssm:GetParameters", - "ssm:PutParameter" - ], - "Resource": [ - "arn:aws:ssm:REGION:ACCOUNT:parameter/sst/passphrase/*", - "arn:aws:ssm:REGION:ACCOUNT:parameter/sst/bootstrap" - ] - }, - { - "Sid": "Deployments", - "Effect": "Allow", - "Action": [ - "*" - ], - "Resource": [ - "*" - ] - }, - { - "Sid": "ManageSecrets", - "Effect": "Allow", - "Action": [ - "ssm:DeleteParameter", - "ssm:GetParameter", - "ssm:GetParameters", - "ssm:GetParametersByPath", - "ssm:PutParameter", - "ssm:AddTagsToResource", - "ssm:ListTagsForResource" - ], - "Resource": [ - "arn:aws:ssm:REGION:ACCOUNT:parameter/sst/*" - ] - }, - { - "Sid": "LiveLambdaSocketConnection", - "Effect": "Allow", - "Action": [ - "appsync:EventSubscribe", - "appsync:EventPublish", - "appsync:EventConnect" - ], - "Resource": [ - "*" - ] - } - ] -} -``` - -
    - -This list roughly breaks down into the following: - -1. Permissions needed to bootstrap SST in your AWS account -2. Permissions needed to deploy your app -3. Permissions needed by the CLI - -Let's look at them in detail. - ---- - -### Bootstrap - -SST needs to [bootstrap](/docs/state/#bootstrap) each AWS account, in each region, once. This happens automatically when you run `sst deploy` or `sst dev`. - -There are a couple of different things being bootstrapped and these are the permissions they need: - -- Permissions to create the bootstrap bucket for storing state. - - ```json - { - "Sid": "ManageBootstrapStateBucket", - "Effect": "Allow", - "Action": [ - "s3:CreateBucket", - "s3:PutBucketVersioning", - "s3:PutBucketNotification", - "s3:PutBucketPolicy", - "s3:DeleteObject", - "s3:DeleteObjectVersion", - "s3:GetObject", - "s3:ListBucket", - "s3:ListBucketVersions", - "s3:PutObject" - ], - "Resource": [ - "arn:aws:s3:::sst-state-*" - ] - } - ``` - -- Permissions to create the bootstrap bucket for storing the assets in your app. These include the Lambda function bundles and static assets in your frontends. - - ```json - { - "Sid": "ManageBootstrapAssetBucket", - "Effect": "Allow", - "Action": [ - "s3:CreateBucket", - "s3:PutBucketVersioning", - "s3:PutBucketNotification", - "s3:PutBucketPolicy", - "s3:DeleteObject", - "s3:GetObject", - "s3:ListBucket", - "s3:PutObject" - ], - "Resource": [ - "arn:aws:s3:::sst-asset-*" - ] - } - ``` - -- Permissions to create the bootstrap ECR repository for hosting the Docker images in your app. - - ```json - { - "Sid": "ManageBootstrapECRRepo", - "Effect": "Allow", - "Action": [ - "ecr:CreateRepository", - "ecr:DescribeRepositories" - ], - "Resource": [ - "arn:aws:ecr:REGION:ACCOUNT:repository/sst-asset" - ] - } - ``` - -- Permissions to create the bootstrap SSM parameter. This parameter stores information about the deployed bootstrap resources. - - ```json - { - "Sid": "ManageBootstrapSSMParameter", - "Effect": "Allow", - "Action": [ - "ssm:GetParameters", - "ssm:PutParameter" - ], - "Resource": [ - "arn:aws:ssm:REGION:ACCOUNT:parameter/sst/passphrase/*", - "arn:aws:ssm:REGION:ACCOUNT:parameter/sst/bootstrap" - ] - } - ``` - ---- - -### Deploy - -The permissions that SST needs to deploy the resources in your app, depends on what you have in your app. - -The following block is placed as a template in the IAM policy above for you to customize. - -```json -{ - "Sid": "Deployments", - "Effect": "Allow", - "Action": [ - "*" - ], - "Resource": [ - "*" - ] -} -``` - -Below we'll look at how you can try customizing this. - ---- - -### CLI - -The SST CLI also makes some AWS SDK calls to your account. Here are the IAM permissions it needs. - -- Permissions to manage your [secrets](/docs/component/secret). - - ```json - { - "Sid": "ManageSecrets", - "Effect": "Allow", - "Action": [ - "ssm:DeleteParameter", - "ssm:GetParameter", - "ssm:GetParameters", - "ssm:GetParametersByPath", - "ssm:PutParameter", - "ssm:AddTagsToResource", - "ssm:ListTagsForResource" - ], - "Resource": [ - "arn:aws:ssm:us-east-1:112233445566:parameter/sst/*" - ] - } - ``` - -- And permissions to connect to the AppSync endpoint in `sst dev` to run your functions [_Live_](/docs/live). - - ```json - { - "Sid": "LiveLambdaSocketConnection", - "Effect": "Allow", - "Action": [ - "appsync:EventSubscribe", - "appsync:EventPublish", - "appsync:EventConnect" - ], - "Resource": [ - "*" - ] - } - ``` - ---- - -## Minimize permissions - -Editing the above policy based on the resources you are adding to your app can be tedious. Here's an approach to consider. - -- Sandbox accounts - - Start by creating separate AWS accounts for your teammates for their dev usage. In these sandbox accounts, you can grant `AdministratorAccess`. This avoids having to modify their permissions every time they make some changes. - -- IAM Access Analyzer - - For your staging accounts, you can start by granting a broad permissions policy. Then after deploying your app and allowing it to run for a period of time. You can use your CloudTrail events to identify the actions and services used by that IAM user. The [IAM Access Analyzer](https://aws.amazon.com/iam/access-analyzer/) can then generate an IAM policy based on this activity, which you can use to replace the original policy. - - You can now use this for your production accounts. Learn more about how to use the [IAM Access Analyzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-generation.html). - -In general, you want to make sure you audit the IAM permissions you are granting on a regular basis. diff --git a/www/src/content/docs/docs/import-resources.mdx b/www/src/content/docs/docs/import-resources.mdx deleted file mode 100644 index 02d14aea01..0000000000 --- a/www/src/content/docs/docs/import-resources.mdx +++ /dev/null @@ -1,269 +0,0 @@ ---- -title: Import Resources -description: Import previously created resources into your app. ---- - -Importing is the process of bringing some previously created resources into your SST app. This'll allow SST to manage them moving forward. - -This is useful for when you are migrating to SST or if you had manually created some resources in the past. - ---- - -## How it works - -SST keeps a [state](/docs/state/) of your app. It contains all the resources that are managed by your app. - -:::note -Once you import a resource it's managed by SST moving forward. -::: - -When you import a resource, it gets added to this state. This means that if you remove this resource in your code, it'll also remove the resource. - -It's as if this resource had been created by your app. - ---- - -#### When not to import - -This is fine for most cases. But for some teams these resources might be managed by other teams. Or they are being managed by a different IaC tool. Meaning that you don't want to manage it in your app. - -:::caution -Do not import resources that are being managed by another team or a different IaC tool. -::: - -In these cases you should not be importing these resources. You are probably looking to [reference these resources](/docs/reference-resources/). - ---- - -## How to import - -You import resources by passing in a property of the resource you want to import into your app. Resources have a property that you can import with and this is different for different resources. We'll look at this below. - -If you are importing into an SST component, you'll need to use a [`transform`](/docs/components/#transform) to pass it into the underlying resource. - -So let's look at two examples. - -1. Importing into an SST component -2. Importing into a Pulumi resource - ---- - -### SST component - -Let's start with an existing S3 Bucket with the following name. - -```txt -mybucket-xnbmhcvd -``` - -We want to import this bucket into the [`Bucket`](/docs/component/aws/bucket/) component. - -1. Start by adding the `import` option in the `transform`. - - ```ts title="sst.config.ts" {4} - new sst.aws.Bucket("MyBucket", { - transform: { - bucket: (args, opts) => { - opts.import = "mybucket-xnbmhcvd"; - } - } - }); - ``` - - The `transform.bucket` is telling this component that instead of creating a new underlying S3 Bucket resource, we want to import an existing bucket. - - Let's deploy this. - - ```bash frame="none" - sst deploy - ``` - - This will give you an error that looks something like this. - - ```txt frame="none" - βœ• Failed - inputs to import do not match the existing resource - - Set the following in your transform: - - `args.bucket = "mybucket-xnbmhcvd";` - - `args.forceDestroy = undefined;` - ``` - - This is telling us that the resource that the `Bucket` component is trying to create does not match the one you are trying to import. This makes sense because you might've previously created this with a configuration that's different from what SST creates by default. - -2. Update the `args` - - The above error tells us exactly what we need to do next. Add the given lines to your `transform`. - - ```ts title="sst.config.ts" {4,5} - new sst.aws.Bucket("MyBucket", { - transform: { - bucket: (args, opts) => { - args.bucket = "mybucket-xnbmhcvd"; - args.forceDestroy = undefined; - - opts.import = "mybucket-xnbmhcvd"; - } - } - }); - ``` - - Now if you deploy this again. - - ```bash frame="none" - sst deploy - ``` - - You'll notice that the bucket has been imported. - - ```bash frame="none" - | Imported MyBucket aws:s3:BucketV2 - ``` - -3. Finally, to clean things up we can remove the `import` line. - - ```diff lang="ts" title="sst.config.ts" - new sst.aws.Bucket("MyBucket", { - transform: { - bucket: (args, opts) => { - args.bucket = "mybucket-xnbmhcvd"; - args.forceDestroy = undefined; - - - opts.import = "mybucket-xnbmhcvd"; - } - } - }); - ``` - - This bucket is now managed by your app and you can now deploy as usual. - - You **do not want to remove** the `args` changes. This matters for the `args.bucket` prop because the name is generated by SST. So if you remove this, SST will generate a new bucket name and remove the old one! - ---- - -### Pulumi resource - -You might want to also import resources into your SST app that don't have a built-in SST component. In these cases, you can import them into a low-level Pulumi resource. - -Let's take the same S3 Bucket example. Say you have an existing bucket with the following name. - -```txt -mybucket-xnbmhcvd -``` - -We want to import this bucket into the [`aws.s3.BucketV2`](https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketv2/) resource. - -1. Start by adding the `import` option. - - ```ts title="sst.config.ts" {6} - new aws.s3.BucketV2("MyBucket", - { - objectLockEnabled: undefined - }, - { - import: "mybucket-xnbmhcvd" - } - ); - ``` - - The `objectLockEnabled` prop here, is for illustrative purposes. We are trying to demonstrate a case where you are importing a resource in a way that it wasn't created. - - Let's deploy this. - - ```bash frame="none" - sst deploy - ``` - - This will give you an error that looks something like this. - - ```txt frame="none" - βœ• Failed - inputs to import do not match the existing resource - - Set the following: - - `objectLockEnabled: undefined,` - ``` - - This is telling us that the resource that the `BucketV2` component is trying to create does not match the one you are trying to import. - - This makes sense because you might've previously created this with a configuration that's different from what you are defining. Recall the `objectLockEnabled` prop we had added above. - -2. Update the `args` - - The above error tells us exactly what we need to do next. Add the given lines in your `args`. - - ```ts title="sst.config.ts" {3} - new aws.s3.BucketV2("MyBucket", - { - objectLockEnabled: undefined - }, - { - import: "mybucket-xnbmhcvd" - } - ); - ``` - - Now if you deploy this again. - - ```bash frame="none" - sst deploy - ``` - - You'll notice that the bucket has been imported. - - ```bash frame="none" - | Imported MyBucket aws:s3:BucketV2 - ``` - -3. Finally, to clean things up we can remove the `import` line. - - ```diff lang="ts" title="sst.config.ts" - new aws.s3.BucketV2("MyBucket", - { - objectLockEnabled: undefined - }, - - { - - import: "mybucket-xnbmhcvd" - - } - ); - ``` - - This bucket is now managed by your app and you can now deploy as usual. - ---- - -## Import properties - -In the above examples we are importing a bucket using the bucket name. We need the bucket name because that's what AWS internally uses to do a lookup. But this is different for different resources. - -So we've compiled a list of the most common resources you might import, along with the **property to import them with**. - -You can look this up by going to the **Import** section of a resource's doc. For example, here's the one for a [`aws.s3.BucketV2`](https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketv2/#import). - ---- - -The following table lists the properties you need to pass in to the `import` prop of the given resource to be able to import it. - -For example, for `aws.s3.BucketV2`, the property is _bucket name_ and it looks something like, `some-unique-bucket-name`. - -| Resource | Property | Example | -|----------|----------|---------| -| [`aws.ec2.Vpc`](https://www.pulumi.com/registry/packages/aws/api-docs/ec2/vpc/) | VPC ID | `vpc-a01106c2` | -| [`aws.iam.Role`](https://www.pulumi.com/registry/packages/aws/api-docs/iam/role/) | Role name | `role-name` | -| [`aws.sqs.Queue`](https://www.pulumi.com/registry/packages/aws/api-docs/sqs/queue/) | Queue URL | `https://queue.amazonaws.com/80398EXAMPLE/MyQueue` | -| [`aws.sns.Topic`](https://www.pulumi.com/registry/packages/aws/api-docs/sns/topic/) | Topic ARN | `arn:aws:sns:us-west-2:0123456789012:my-topic` | -| [`aws.rds.Cluster`](https://www.pulumi.com/registry/packages/aws/api-docs/rds/cluster/) | Cluster identifier | `aurora-prod-cluster` | -| [`aws.ecs.Service`](https://www.pulumi.com/registry/packages/aws/api-docs/ecs/service/) | Cluster and service name | `cluster-name/service-name` | -| [`aws.ecs.Cluster`](https://www.pulumi.com/registry/packages/aws/api-docs/ecs/cluster/) | Cluster name | `cluster-name` | -| [`aws.s3.BucketV2`](https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketv2/) | Bucket name | `bucket-name` | -| [`aws.kinesis.Stream`](https://www.pulumi.com/registry/packages/aws/api-docs/kinesis/stream/) | Stream name | `my-kinesis-stream` | -| [`aws.dynamodb.Table`](https://www.pulumi.com/registry/packages/aws/api-docs/dynamodb/table/) | Table name | `table-name` | -| [`aws.lambda.Function`](https://www.pulumi.com/registry/packages/aws/api-docs/lambda/function/) | Function name | `function-name` | -| [`aws.apigatewayv2.Api`](https://www.pulumi.com/registry/packages/aws/api-docs/apigatewayv2/api/) | API ID | `12345abcde` | -| [`aws.cognito.UserPool`](https://www.pulumi.com/registry/packages/aws/api-docs/cognito/userpool/) | User Pool ID | `us-east-1_abc123` | -| [`aws.apigateway.RestApi`](https://www.pulumi.com/registry/packages/aws/api-docs/apigateway/restapi/) | REST API ID | `12345abcde` | -| [`aws.cloudwatch.LogGroup`](https://www.pulumi.com/registry/packages/aws/api-docs/cloudwatch/loggroup/) | Log Group name | `my-log-group` | -| [`aws.cognito.IdentityPool`](https://www.pulumi.com/registry/packages/aws/api-docs/cognito/identitypool/) | Identity Pool ID | `us-east-1:1a234567-8901-234b-5cde-f6789g01h2i3` | -| [`aws.cloudfront.Distribution`](https://www.pulumi.com/registry/packages/aws/api-docs/cloudfront/distribution/) | Distribution ID | `E74FTE3EXAMPLE` | - -Feel free to _Edit this page_ and submit a PR if you want to add to this list. diff --git a/www/src/content/docs/docs/index.mdx b/www/src/content/docs/docs/index.mdx deleted file mode 100644 index 310ee4fa1a..0000000000 --- a/www/src/content/docs/docs/index.mdx +++ /dev/null @@ -1,436 +0,0 @@ ---- -title: What is SST -description: Build full-stack apps on your own infrastructure. ---- - -import { Tabs, TabItem } from '@astrojs/starlight/components'; -import { LinkCard } from '@astrojs/starlight/components'; -import { Icon } from '@astrojs/starlight/components'; -import VideoAside from "../../../components/VideoAside.astro"; -import config from '../../../../config.ts'; - -export const github = config.github; - -SST is a framework that makes it easy to build modern full-stack applications on your own infrastructure. - -:::note -SST supports over 150 providers. Check out the [full list](/docs/all-providers#directory). -::: - -What makes SST different is that your _entire_ app is **defined in code** β€” in a single `sst.config.ts` file. This includes databases, buckets, queues, Stripe webhooks, or any one of **150+ providers**. - -With SST, **everything is automated**. - ---- - -## Components - -You start by defining parts of your app, _**in code**_. - -For example, you can add your frontend and set the domain you want to use. - - - - ```ts title="sst.config.ts" - new sst.aws.Nextjs("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.Remix("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.Astro("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.SvelteKit("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.SolidStart("MyWeb", { - domain: "my-app.com" - }); - ``` - - - -Just like the frontend, you can configure backend features _in code_. - -Like your API deployed in a container. Or any Lambda functions, Postgres databases, S3 Buckets, or cron jobs. - - - - ```ts title="sst.config.ts" - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }] - } - }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler" - }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.Postgres("MyDatabase", { vpc }); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.Bucket("MyBucket"); - ``` - - - ```ts title="sst.config.ts" - new sst.aws.Cron("MyCronJob", { - job: "src/cron.handler", - schedule: "rate(1 minute)" - }); - ``` - - - - -You can even set up your Stripe products in code. - -```ts title="sst.config.ts" -new stripe.Product("MyStripeProduct", { - name: "SST Paid Plan", - description: "This is how SST makes money", -}); -``` - -You can check out the full list of components in the sidebar. - ---- - -## Infrastructure - -The above are called **Components**. They are a way of defining the features of your application in code. You can define any feature of your application with them. - -In the above examples, they create the necessary infrastructure in your AWS account. All without using the AWS Console. - -Learn more about [Components](/docs/components/). - ---- - -### Configure - -SST's components come with sensible defaults designed to get you started. But they can also be configured completely. - -For example, the `sst.aws.Function` can be configured with all the common Lambda function options. - -```ts {3,4} title="sst.config.ts" -new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - timeout: "3 minutes", - memory: "1024 MB" -}); -``` - -But with SST you can take it a step further and transform how the Function component creates its low level resources. For example, the Function component also creates an IAM Role. You can transform the IAM Role using the `transform` prop. - -```ts {3-7} title="sst.config.ts" -new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - transform: { - role: (args) => ({ - name: `${args.name}-MyRole` - }) - } -}); -``` - -Learn more about [transforms](/docs/components#transforms). - ---- - -### Providers - -SST has built-in components for AWS and Cloudflare that make these services easier to use. - - - -However it also supports components from any one of the **150+ Pulumi/Terraform providers**. For example, you can use Vercel for your frontends. - -```ts title="sst.config.ts" -new vercel.Project("MyFrontend", { - name: "my-nextjs-app" -}); -``` - -Learn more about [Providers](/docs/providers) and check out the full list in the [Directory](/docs/all-providers#directory). - ---- - -## Link resources - -Once you've added a couple of features, SST can help you link them together. This is great because you **won't need to hardcode** anything in your app. - - - -Let's say you are deploying an Express app in a container and you want to upload files to an S3 bucket. You can `link` the bucket to your container. - -```ts title="sst.config.ts" {6} -const bucket = new sst.aws.Bucket("MyBucket"); - -const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - -new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http" }] - } -}); -``` - -You can then use SST's [SDK](/docs/reference/sdk/) to access the S3 bucket in your Express app. - -```ts title="index.mjs" "Resource.MyBucket.name" -import { Resource } from "sst"; - -console.log(Resource.MyBucket.name); -``` - -Learn more about [resource linking](/docs/linking/). - ---- - -## Project structure - -We've looked at a couple of different types of files. Let's take a step back and see what an SST app looks like in practice. - - - ---- - -### Drop-in mode - -The simplest way to run SST is to use it as a part of your app. This is called _drop-in mode_. For example, if you are building a Next.js app, you can add a `sst.config.ts` file to the root. - -```txt {3} -my-nextjs-app -β”œβ”€ next.config.js -β”œβ”€ sst.config.ts -β”œβ”€ package.json -β”œβ”€ app -β”œβ”€ lib -└─ public -``` - -View an example Next.js app using SST in drop-in mode. - ---- - -### Monorepo - -Alternatively, you might use SST in a monorepo. This is useful because most projects have a frontend, a backend, and some functions. - -In this case, the `sst.config.ts` is still in the root but you can split it up into parts in the `infra/` directory. - -```txt {2,9} -my-sst-app -β”œβ”€ sst.config.ts -β”œβ”€ package.json -β”œβ”€ packages -β”‚Β Β β”œβ”€ functions -β”‚Β Β β”œβ”€ frontend -β”‚Β Β β”œβ”€ backend -│  └─ core -└─ infra -``` - -Learn more about our [monorepo setup](/docs/set-up-a-monorepo/). - ---- - -## CLI - -To make this all work, SST comes with a [CLI](/docs/reference/cli/). For JavaScript projects, install SST locally in your project so the CLI version is tracked with your app. - - - - ```bash - npm install sst - ``` - - - ```bash - pnpm add sst - ``` - - - ```bash - bun add sst - ``` - - - ```bash - yarn add sst - ``` - - - -You can then run the CLI with your package manager. - - - - ```bash - npx sst dev - ``` - - - ```bash - pnpm exec sst dev - ``` - - - ```bash - bun sst dev - ``` - - - ```bash - yarn sst dev - ``` - - - -If you are not using JavaScript, you can install the CLI globally. - -```bash -curl -fsSL https://sst.dev/install | bash -``` - -Learn more about the [CLI](/docs/reference/cli/). - ---- - -### Dev - -The CLI includes a `dev` command that starts a local development environment. - -```bash -sst dev -``` - -This brings up a _multiplexer_ that: - -1. Starts a watcher that deploys any infrastructure changes. -2. Runs your functions [_Live_](/docs/live/), letting you make and test changes without having to redeploy them. -3. Creates a [_tunnel_](/docs/reference/cli#tunnel) to connect your local machine to any resources in a VPC. -4. Starts your frontend and container services in dev mode and links it to your infrastructure. - - - -The `sst dev` CLI makes it so that you won’t have to start your frontend or container applications separately. Learn more about [`sst dev`](/docs/reference/cli/#dev). - ---- - -### Deploy - -When you're ready to deploy your app, you can use the `deploy` command. - -```bash -sst deploy --stage production -``` - ---- - -#### Stages - -The stage name is used to namespace different environments of your app. So you can create one for dev. - -```bash -sst deploy --stage dev -``` - -Or for a pull request. - -```bash -sst deploy --stage pr-123 -``` - -Learn more about [stages](/docs/reference/cli#stage). - ---- - -## Console - -Once you are ready to go to production, you can use the [SST Console](/docs/console/) to **auto-deploy** your app, create **preview environments**, and **monitor** for any issues. - -![SST Console](../../../assets/docs/sst-console-home.png) - -Learn more about the [Console](/docs/console/). - ---- - -## FAQ - -Here are some questions that we frequently get. - ---- - -**Is SST open-source if it's based on Pulumi and Terraform?** - -SST uses Pulumi behind the scenes for the providers and the deployment engine. And Terraform's providers are _bridged_ through Pulumi. - -SST only relies on the open-source parts of Pulumi and Terraform. It does not require a Pulumi account and all the data about your app and its resources stay on your side. - ---- - -**How does SST compare to CDK for Terraform or Pulumi?** - -Both CDKTF and Pulumi allow you to define your infrastructure using a programming language like TypeScript. SST is also built on top of Pulumi. So you might wonder how SST compares to them and why you would use SST instead of them. - -In a nutshell, SST is for developers, while CDKTF and Pulumi are primarily for DevOps engineers. There are 3 big things SST does for developers: - -1. Higher-level components - - SST's built-in components like [`Nextjs`](/docs/component/aws/nextjs/) or [`Email`](/docs/component/aws/email/) make it easy for developers to add features to their app. You can use these without having to figure out how to work with the underlying Terraform resources. - -2. Linking resources - - SST makes it easy to link your infrastructure to your application and access them at runtime in your code. - -3. Dev mode - - Finally, SST features a unified local developer environment that deploys your app through a watcher, runs your functions [_Live_](/docs/live/), creates a [_tunnel_](/docs/reference/cli#tunnel) to your VPC, starts your frontend and backend, all together. - ---- - -**How does SST make money?** - -While SST is open-source and free to use, we also have the [Console](/docs/console/) that can auto-deploy your apps and monitor for any issues. It's optional and includes a free tier but it's a SaaS service. It's used by a large number of teams in our community, including ours. - ---- - -#### Next steps - -1. [Learn the SST basics](/docs/basics/) -2. Create your first SST app - - [Build a Next.js app in AWS](/docs/start/aws/nextjs/) - - [Deploy Bun in a container to AWS](/docs/start/aws/bun/) - - [Build a Hono API with Cloudflare Workers](/docs/start/cloudflare/hono/) diff --git a/www/src/content/docs/docs/linking.mdx b/www/src/content/docs/docs/linking.mdx deleted file mode 100644 index 6ccf0e8609..0000000000 --- a/www/src/content/docs/docs/linking.mdx +++ /dev/null @@ -1,315 +0,0 @@ ---- -title: Linking -description: Link resources together and access them in a typesafe and secure way. ---- - -import { Tabs, TabItem } from '@astrojs/starlight/components'; -import VideoAside from "../../../components/VideoAside.astro"; - -Resource Linking allows you to access your **infrastructure** in your **runtime code** in a typesafe and secure way. - - - -1. Create a resource that you want to link to. For example, a bucket. - - ```ts title="sst.config.ts" {6,11} - const bucket = new sst.aws.Bucket("MyBucket"); - ``` - -2. Link it to your function or frontend, using the `link` prop. - - - - ```ts title="sst.config.ts" {2} - new sst.aws.Nextjs("MyWeb", { - link: [bucket] - }); - ``` - - - ```ts title="sst.config.ts" {2} - new sst.aws.Remix("MyWeb", { - link: [bucket] - }); - ``` - - - ```ts title="sst.config.ts" {2} - new sst.aws.Astro("MyWeb", { - link: [bucket] - }); - ``` - - - ```ts title="sst.config.ts" {3} - new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - link: [bucket] - }); - ``` - - - -3. Use the [SDK](/docs/reference/sdk/) to access the linked resource in your runtime in a typesafe way. - - - - ```js title="app/page.tsx" - import { Resource } from "sst"; - - console.log(Resource.MyBucket.name); - ``` - - - ```js title="app/routes/_index.tsx" - import { Resource } from "sst"; - - console.log(Resource.MyBucket.name); - ``` - - - ```astro title="src/pages/index.astro" - --- - import { Resource } from "sst"; - - console.log(Resource.MyBucket.name); - --- - ``` - - - ```js title="src/lambda.ts" - import { Resource } from "sst"; - - console.log(Resource.MyBucket.name); - ``` - - - - :::tip - The SDK currently supports JS/TS, Python, Golang, and Rust. - ::: - -Learn how to use the SDK in [Python](/docs/reference/sdk/#python), [Golang](/docs/reference/sdk/#golang), and [Rust](/docs/reference/sdk/#rust). - ---- - -### Working locally - -The above applies to your app deployed through `sst deploy`. - -To access linked resources locally you'll need to be running `sst dev`. By default, the `sst dev` CLI runs a multiplexer that also starts your frontend for you. This loads all your linked resources in the environment. Read more about [`sst dev`](/docs/reference/cli/#dev). - -However if you are not using the multiplexer. - -```bash frame="none" -sst dev --mode=basic -``` - -You'll need to wrap your frontend's dev command with the `sst dev` command. - - - - ```bash - sst dev next dev - ``` - - - ```bash - sst dev remix dev - ``` - - - ```bash - sst dev astro dev - ``` - - - ```bash - sst dev - ``` - - - ---- - -## How it works - -At high level when you link a resource to a function or frontend, the following happens: - -1. The _links_ that the resource exposes are injected into the function package. - - :::tip - The links a component exposes are listed in its API reference. For example, you can [view a Bucket's links here](/docs/component/aws/bucket/#links). - ::: - -2. The types to access these links are generated. - -3. The function is given permission to access the linked resource. - ---- - -### Injecting links - -Resource links are injected into your function or frontend package when you run `sst dev` or `sst deploy`. But this is done in a slightly different way for both these cases. - -#### Functions - -The functions in SST are tree shaken and bundled using [esbuild](https://esbuild.github.io/). While bundling, SST injects the resource links into the [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis). These are encrypted and added to the function bundle. And they are synchronously decrypted on load by the SST SDK. - -#### Frontends - -The frontends are not bundled by SST. Instead, when they are built, SST injects the resource links into the `process.env` object using the prefix `SST_RESOURCE_`. - -This is why when you are running your frontend locally, it needs to be wrapped in the `sst dev` command. - -:::note -Links are only available on the server of your frontend. -::: - -Resource links are only available on the server-side of your frontend. If you want to access them in your client components, you'll need to pass them in explicitly. - ---- - -### Generating types - -When you run `sst dev` or `sst deploy`, it generates the types to access the linked resources. These are generated as: - -1. A `sst-env.d.ts` file in the project root with types for **all** the linked resources in the app. -2. A `sst-env.d.ts` file in the same directory of the nearest `package.json` of the function or frontend that's _receiving_ the links. This is usually just a small reference shim to the root `sst-env.d.ts` file. - -You can check the generated `sst-env.d.ts` types into source control. This will let your teammates see the types without having to run `sst dev` when they pull your changes. - ---- - -## Extending linking - -The examples above are built into SST's components. You might want to modify the permissions that are granted as a part of these links. - -Or, you might want to link other resources from the Pulumi/Terraform ecosystem. Or want to link a different set of outputs than what SST exposes. - -You can do this using the [`sst.Linkable`](/docs/component/linkable/) component. - ---- - -### Link any value - -The `Linkable` component takes a list of properties that you want to link. These can be -outputs from other resources or constants. - -```ts title="sst.config.ts" -const myLinkable = new sst.Linkable("MyLinkable", { - properties: { foo: "bar" } -}); -``` - -You can optionally include permissions or bindings for the linked resource. - -Now you can now link this resource to your frontend or a function. - -```ts title="sst.config.ts" {3} -new sst.aws.Function("MyApi", { - handler: "src/lambda.handler", - link: [myLinkable] -}); -``` - -Then use the [SDK](/docs/reference/sdk/) to access that at runtime. - -```js title="src/lambda.ts" -import { Resource } from "sst"; - -console.log(Resource.MyLinkable.foo); -``` - -Read more about [`sst.Linkable`](/docs/component/linkable/). - ---- - -### Link any resource - -You can also wrap any resource class to make it linkable with the `Linkable.wrap` static method. - -```ts title="sst.config.ts" -Linkable.wrap(aws.dynamodb.Table, (table) => ({ - properties: { tableName: table.name } -})); -``` - -Now you create an instance of `aws.dynamodb.Table` and link it in your app like any other SST -component. - -```ts title="sst.config.ts" {7} -const table = new aws.dynamodb.Table("MyTable", { - attributes: [{ name: "id", type: "S" }], - hashKey: "id" -}); - -new sst.aws.Nextjs("MyWeb", { - link: [table] -}); -``` - -And use the [SDK](/docs/reference/sdk/) to access it at runtime. - -```js title="app/page.tsx" -import { Resource } from "sst"; - -console.log(Resource.MyTable.tableName); -``` - ---- - -### Modify built-in links - -You can also modify the links SST creates. For example, you might want to change the permissions of a linkable resource. - -```ts title="sst.config.ts" "sst.aws.Bucket" - sst.Linkable.wrap(sst.aws.Bucket, (bucket) => ({ - properties: { name: bucket.name }, - include: [ - sst.aws.permission({ - actions: ["s3:GetObject"], - resources: [bucket.arn] - }) - ] - })); - ``` - - This overrides the existing link and lets you create your own. - -Read more about [`sst.Linkable.wrap`](/docs/component/linkable/#static-wrap). - ---- - -### Link integration with external providers - -If you want to pass links to compute not managed by SST, like a native ECS task definition or a Kubernetes pod, use `Linkable.env()`. It converts your linked resources into `SST_RESOURCE_*` environment variables so `Resource.MyResource` works at runtime. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); - -const environment = sst.Linkable.env([bucket]); -``` - -This returns an `Output>` that you can pass to any provider that accepts environment variables. - -```ts title="sst.config.ts" -new kubernetes.apps.v1.Deployment("MyDeployment", { - spec: { - template: { - spec: { - containers: [{ - name: "app", - image: "my-image", - env: sst.Linkable.env([bucket]).apply((env) => - // Kubernetes requires environment variables to be an array of objects - Object.entries(env).map(([name, value]) => ({ name, value: String(value) })), - ), - }], - }, - }, - }, -}); -``` - -Read more about [`sst.Linkable.env`](/docs/component/linkable/#static-env). [Check out an example](/docs/examples/#aws-linkable-env). diff --git a/www/src/content/docs/docs/live.mdx b/www/src/content/docs/docs/live.mdx deleted file mode 100644 index dc235d8c84..0000000000 --- a/www/src/content/docs/docs/live.mdx +++ /dev/null @@ -1,212 +0,0 @@ ---- -title: Live -description: Make changes to your Lambda functions in milliseconds. ---- - -Live is a feature of SST that lets you test changes made to your AWS Lambda functions in milliseconds. Your changes work without having to redeploy. And they can be invoked remotely. - -:::tip -By default, `sst dev` will run all the functions in your app _"live"_. -::: - -It works by proxying requests from AWS to your local machine, executing it locally, and proxying the response back. - - ---- - -## Advantages - -This setup of running your functions locally and proxying the results back allows you to do a couple of things: - -- Your changes are **reloaded in under 10ms**. -- You can set **breakpoints to debug** your function in your favorite IDE. -- Functions can be invoked remotely. For example, say `https://my-api.com/hello` is your API endpoint. Hitting that will run the local version of that function. - - This applies to more than just APIs. Any cron job or async event that gets invoked remotely will also run your local function. - - It allows you to very easily debug and **test webhooks**, since you can just give the webhook your API endpoint. - - Supports all function triggers, there's no need to mock an event. -- Uses the **right IAM permissions**, so if a Lambda fails on AWS due to the lack of IAM permissions, it would fail locally as well. - ---- - -## How it works - -Live uses [AWS AppSync Events](https://docs.aws.amazon.com/appsync/latest/eventapi/event-api-welcome.html) to communicate between your local machine and the remote Lambda function. - -When you run `sst dev`, it [bootstraps](/docs/state#bootstrap) a new AppSync Events API for the region you are using. - -This is roughly what the flow looks like: - -1. When you run `sst dev`, it deploys your app and replaces the Lambda functions with a _stub_ version. -2. It also starts up a local WebSocket client and connects to the AppSync API endpoint. -3. When a Lambda function in your app is invoked, it publishes an event, where the payload is the Lambda function request. -4. Your local WebSocket client receives this event. It publishes an event acknowledging that it received the request. -5. Next, it runs the local version of the function and publishes an event with the function response as the payload. The local version is run as a Node.js Worker. -6. Finally, the stub Lambda function receives the event and responds with the payload. - ---- - -### Quirks - -There are a couple of quirks with this setup that are worth noting. - -1. **Runtime change** - - The stub function that's deployed uses a **different runtime** than your Lambda function. You might run into this when you change the runtime in your config but the runtime of the Lambda function in the AWS Console doesn't change. - - :::tip - The _stub_ function that’s deployed uses a different runtime than the actual function. - ::: - - We use a different runtime because we want the function to be as fast as possible at proxying requests. - -2. **Live mode persists** - - If you kill the `sst dev` CLI, your functions are not run locally anymore but the stub function in AWS are still there. This means that it'll attempt to proxy requests to your machine and timeout. - - :::tip - Only use `sst dev` in your personal stage. - ::: - - You can fix this by running `sst deploy` and it'll deploy the real version of your app. But the next time you run `sst dev` it'll need to deploy the stub back. This'll take a couple of minutes. So we recommend only using your personal stages for `sst dev`. And avoid flipping back and forth between `dev` and `deploy`. - ---- - -### Live mode - -When a function is running live it sets the `SST_DEV` environment variable to `true`. So in your Node.js functions you can access it using `process.env.SST_DEV`. - -```js title="src/lambda.js" "process.env.SST_DEV" -export async function main(event) { - const body = process.env.SST_DEV ? "Hello, Live!" : "Hello, World!"; - - return { - body, - statusCode: 200, - }; -} -``` - -This is useful if you want to access some resources locally. - ---- - -#### Connect to a local DB - -For example, when running locally you might want to connect to a local database. You can do that with the `SST_DEV` environment variable. - -```js -const dbHost = process.env.SST_DEV - ? "localhost" - : "amazon-string.rds.amazonaws.com"; -``` - ---- - -## Cost - -AWS AppSync Events that powers Live is **completely serverless**. So you don't get charged when it's not in use. - -It's also pretty cheap. It's roughly $1.00 per million messages and $0.08 per million connection minutes. You can [check out the details here](https://aws.amazon.com/appsync/pricing/#AppSync_Events_). - -This approach has been economical even for large teams with dozens of developers. - ---- - -## Privacy - -All the data stays between your local machine and your AWS account. There are **no 3rd party services** that are used. - -Live also supports connecting to AWS resources inside a VPC. - ---- - -### Using a VPC - -By default your local functions cannot connect to resources in a VPC. You can fix this by either setting up a VPN connection or creating a tunnel. - ---- - -#### Creating a tunnel - -To create a tunnel, you'll need to: - -1. Enable the `bastion` host in your VPC. - - ```ts title="sst.config.ts" "{ bastion: true }" - new sst.aws.Vpc("MyVpc", { bastion: true }); - ``` - -2. Install the tunnel. - - ```bash "sudo" - sudo sst tunnel install - ``` - - This needs _sudo_ to create the network interface on your machine. You only need to do this once. - - :::note - For NixOS users you will also need to declare the following sudo configuration to complete the setup: - - ```nix - security.sudo.extraRules = [ - { - users = ["jay"]; # Your user - commands = [ - { - command = "/opt/sst/tunnel tunnel start *"; - options = ["NOPASSWD" "SETENV"]; - } - ]; - } - ]; - ``` - ::: - - -3. Run `sst dev`. - - ```bash - sst dev - ``` - -This starts the tunnel automatically; notice the **Tunnel** tab on the left. Now your local environment can connect to resources in your VPC. - ---- - -#### Setting up a VPN connection - -To set up a VPN connection, you'll need to: - -1. Setup a VPN connection from your local machine to your VPC network. You can use the AWS Client VPN service to set it up. [Follow the Mutual authentication section in this doc](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/client-authentication.html#mutual) to setup the certificates and import them into your Amazon Certificate Manager. -2. Then [create a Client VPC Endpoint](https://aws.amazon.com/blogs/networking-and-content-delivery/introducing-aws-client-vpn-to-securely-access-aws-and-on-premises-resources/), and associate it with your VPC. -3. And, finally install [Tunnelblick](https://tunnelblick.net) locally to establish the VPN connection. - -Note that, the AWS Client VPC service is billed on an hourly basis but it's fairly inexpensive. [Read more on the pricing here](https://aws.amazon.com/vpn/pricing/). - ---- - -## Breakpoints - -Since Live runs your functions locally, you can set breakpoints and debug your functions in your favorite IDE. - -![VS Code Enable Auto Attach](../../../assets/docs/live/vs-code-enable-auto-attach.png) - -For VS Code, you'll need to enable Auto Attach from the Command Palette. Hit `Ctrl+Shift+P` or `Cmd+Shift+P`, type in **Debug: Toggle Auto Attach** and select **Always**. - -:::note -You need to start a new terminal **in VS Code** after enabling Auto Attach. -::: - -Now open a new terminal in VS Code, run `sst dev`, set a breakpoint in a function, and invoke the function. - ---- - -## Changelog - -Live is a feature that was created by SST when it first launched back in 2021. It's gone through a few different iterations since then. - -| SST Version | Change | -| --- | --- | -| **v0.5.0** | Then called _Live Lambda_, used a API Gateway WebSocket API and a DynamoDB table. | -| **v2.0.0** | Switched to using AWS IoT, this was roughly 2-3x faster. | -| **v3.3.1** | Switched to using AWS AppSync Events, which is even faster and handles larger payloads better. | diff --git a/www/src/content/docs/docs/migrate-from-v2.mdx b/www/src/content/docs/docs/migrate-from-v2.mdx deleted file mode 100644 index 0f11d68eea..0000000000 --- a/www/src/content/docs/docs/migrate-from-v2.mdx +++ /dev/null @@ -1,1399 +0,0 @@ ---- -title: Migrate From v2 -description: Migrate your SST v2 apps to v3. ---- - -import config from '../../../../config.ts'; - -import { Tabs, TabItem } from '@astrojs/starlight/components'; - -This guide will help you migrate your SST v2 apps to v3. We look at the major differences between v2 and v3 below. But to get a quick intro, we recommend reading the [What is SST](/docs/) and [Basics](/docs/basics/) docs. - -:::tip -We recently [migrated our demo notes app](https://github.com/sst/demo-notes-app/pull/8/files) from v2 to v3. You use these changes as reference. -::: - -We'll then go over a migration plan that you can use. The exact details of this will be different from team to team depending on the resources in it, and sensitivity of downtime. - ---- - -#### Getting help - -SST v3 has been around for a few months with a pretty sizeable community on Discord. We've created a channel for folks looking to migrate. - -Join `#migrate-from-v2` on Discord. - ---- - -#### Not supported - -While the goal with v3 is to support most of what's in v2, there are a few things that haven't been supported yet. There are also a couple of them that are currently in beta and will be released in the near future. - -| Construct | GitHub Issue | -|----------|-------| -| `Script` | [#811](https://github.com/sst/sst/issues/4323) | -| `Function` non-Node.js runtimes | [Container](https://github.com/sst/sst/issues/4462), [Custom](https://github.com/sst/sst/issues/4826) | - -Feel free to let us know via the linked GitHub issues if these are blockers for you. It'll help us prioritize this list. - ---- - -## Major changes - -If you are coming from SST v2, it's worth starting with the big differences between v2 and v3. It'll help you understand the types of changes you'll need to make as you migrate. - ---- - -#### No CloudFormation - -Let's start with the obvious. SST v3 moves away from CloudFormation and CDK, [we've written in detail about why we decided to do this](https://sst.dev/blog/moving-away-from-cdk.html). - -No CloudFormation, means a couple of things: - -1. There are no stacks, all the resources are defined through the same function in the `sst.config.ts`. -2. The outputs of constructs or _components_ are different. These used to be tokens that would get replaced on deploy. Now they are something called [_Outputs_](/docs/components/#outputs). -3. The state of your app is stored locally and backed up to S3. Learn more about [State](/docs/state/). - ---- - -#### No CDK - -And moving away from CDK means: - -1. You cannot fall back to CDK constructs if something isn't supported by SST. Instead there is the [AWS](https://www.pulumi.com/registry/packages/aws/) provider from Pulumi that's built on Terraform. There are also 150+ other providers that allow you to build on any cloud. Check out the [Directory](/docs/all-providers#directory). - - If you are using a lot of higher level CDK constructs in your v2 app, it's going to be really hard to migrate to v3. The Pulumi/Terraform ecosystem is fairly complete but it's mainly made up of low level resources. You might not have ready replacements for your CDK constructs. - -2. Since the constructs or _components_ are no longer built on CDK; they don't have a `cdk` prop. Instead, there's a `transform` prop that lets you modify the props that a component sends to its underlying resources. Learn more about the [`transform`](/docs/components/#transform) prop. - ---- - -#### sst.config.ts - -The `sst.config.ts` is similar in v3 but there are some changes. Here's a comparison of the general structure, we look at this in detail in a [section below](#sstconfigts-1). - - - - ```ts title="sst.config.ts" - export default $config({ - // Your app's config - app(input) { - return { - name: "my-sst-app", - home: "aws" - }; - }, - // Your app's resources - async run() { } - }); - ``` - - - ```ts title="sst.config.ts" - export default { - // Your app's config - config(_input) { - return { - name: "my-sst-app", - region: "us-east-1" - }; - }, - // Your app's resources - stacks(app) { } - } satisfies SSTConfig; - ``` - - - -Learn more about the new [`sst.config.ts`](/docs/reference/config/). - ---- - -#### sst dev - -The `sst dev` CLI has been completely reworked. It now runs a _multiplexer_ that deploys your app and runs your frontends together. So you don't need to: - -- Start your frontend separately -- Need to wrap your frontend `dev` script with `sst bind` - -Learn more about [`sst dev`](/docs/reference/cli/#dev). - ---- - -#### sst build - -There is no `sst build` CLI. Instead you can run `sst diff` to see what changes will be deployed, without doing an actual deploy. - -Learn more about [`sst diff`](/docs/reference/cli/#diff). - ---- - -#### Resource binding - -Resource binding is now called resource linking, the `bind` prop is now renamed to `link`. The Node.js client or _JS SDK_ has been reworked so that all linked resources are now available through the `Resource` object. We'll look at this in [detail below](#clients). - -The client handlers and hooks have not been supported yet. - -Learn more about [Resource linking](/docs/linking/). - ---- - -#### Secrets - -Secrets are not stored in SSM. Instead they are encrypted and stored in your state file. It's encrypted using a passphrase that's stored in SSM. - -Loading secrets in your functions no longer needs a top-level await. - - ---- - -## Migration plan - -Say you have a v2 app in a git repo that's currently deployed to production. Here's how we recommend carrying out the migration. - -1. Use the steps below to migrate over your app to a non-prod stage. You don't need to import any resources, just recreate them. -2. Test your non-prod version of your v3 app. -3. Then for your prod stage, follow the steps below and make the import, domain, and subscriber changes. -4. Once the prod version of your v3 app is running, clean up some of the v2 prod resources. - -:::caution -These are recommendations and the specific details depend on the type of resources you have. -::: - -The general idea here is to have the v2 app hand over control of the underlying resources to the v3 version of the app. - ---- - -### Setup - -1. Start by setting the removal policy to `retain` in the v2 app for the production stages. This ensures resources don't get accidentally removed. - - ```ts - app.setDefaultRemovalPolicy("retain"); - ``` - - :::caution - You'll want to deploy your app once after setting this. - ::: - -2. Create a new branch in your repo for the upcoming changes. - -3. For the prod version of the v3 app, pick a different stage name. Say your prod stage in v2 is called `production`. Maybe use `prod`, `main`, or `live` for your v3 app. Or vice versa. This isn't strictly necessary, but we recommend doing this because you don't want to change the wrong resources by mistake. - ---- - -### Init v3 - -Now let's set up our new v3 app in the root of your project. - -1. Update SST to v3. Or set the version by hand in your `package.json`. Make sure to this across all the packages in your repo. - - ```bash frame="none" - npm update sst - ``` - - Ensure v3 is installed. - - ```bash frame="none" - npx sst version - ``` - -2. Backup the v2 config with. - - ```bash frame="none" - mv sst.config.ts sst.config.ts.bk - ``` - -3. Init a v3 app. - - ```bash frame="none" - npx sst init - ``` - - :::caution - Make sure to use the same app name. - ::: - -4. Set the removal policy to `retain`. Similar to `setDefaultRemovalPolicy` in v2, you can configure the removal policy in `sst.config.ts` in v3. - - ```ts title="sst.config.ts" {4} - app(input) { - return { - name: "my-sst-app", - removal: input?.stage === "production" ? "retain" : "remove" - }; - } - ``` - - By default, v3 has removal policy set to `retain` for the `production` stage, and `remove` for other stages. - -5. Deploy an empty app to ensure the app is configured correctly. - - ```bash frame="none" - npx sst deploy - ``` - -6. Update the dev scripts for your frontend. Remove the `sst bind` from the `dev` script in your `package.json`. For example, for a Next.js app. - - ```diff lang="js" title="package.json" - - "dev": "sst bind next dev", - + "dev": "next dev", - ``` - -7. Remove any CDK related packages from your `package.json`. - ---- - -### Migrate stacks - -Now before we start making changes to our constructs, you might have some stacks code in your `sst.config.ts`. - -Take a look at the [**list below**](#sstconfigts-1) and apply the changes that matter to you. - ---- - -#### Restructure - -Since you don't have to import the constructs and there are no stacks, you'll need to change how your constructs are structured. - -For example, in the [monorepo notes app](https://github.com/sst/demo-notes-app/pull/8) we made these changes. - - - - ```ts title="sst.config.ts" - export default $config({ - // ... - - async run() { - await import("./infra/api"); - await import("./infra/storage"); - await import("./infra/frontend"); - const auth = await import("./infra/auth"); - - return { - UserPool: auth.userPool.id, - Region: aws.getRegionOutput().region, - IdentityPool: auth.identityPool.id, - UserPoolClient: auth.userPoolClient.id, - }; - } - } - ``` - - - ```ts title="sst.config.ts" - import { SSTConfig } from "sst"; - import { ApiStack } from "./stacks/ApiStack"; - import { AuthStack } from "./stacks/AuthStack"; - import { StorageStack } from "./stacks/StorageStack"; - import { FrontendStack } from "./stacks/FrontendStack"; - - export default { - // ... - - stacks(app) { - app - .stack(StorageStack) - .stack(ApiStack) - .stack(AuthStack) - .stack(FrontendStack); - } - } satisfies SSTConfig; - ``` - - - -We store our infrastructure files in the `infra/` directory in v3. You can refer to the [demo notes app](https://github.com/sst/demo-notes-app) to see how these are structured. - ---- - -### Migrate runtime - -For your runtime code, your functions and frontend; there are fairly minimal changes. The clients or the _JS SDK_ have been reorganized. - -You can make these changes now or as you are migrating each construct. [**Check out**](#clients) the steps below. - ---- - -### Migrate constructs - - -Constructs in v2 have their equivalent _components_ in v3. Constructs fall into roughly these 3 categories: - -1. Transient β€” these don't contain data, like `Function`, `Topic`, or `Queue`. -2. Data β€” these contain application data, like `RDS`, `Table`, or `Bucket`. -3. Custom domains β€” these have custom domains configured, like `Api`, `StaticSite`, or `NextjsSite`. -4. Subscribers β€” these are constructs that subscribe to other constructs, like the `Bucket`, `Queue`, or `Table` subscribers. - -We'll go over each of these types and copy our v2 constructs over as v3 components. - ---- - -#### Transient constructs - -Constructs like `Function`, `Cron`, `Topic`, `Queue`, and `KinesisStream` do not contain data. They can be recreated in the v3 app. - -Simply copy them over using the [**reference below**](#constructs). - ---- - -#### Data constructs - -Constructs like `RDS`, `Table`, `Bucket`, and `Cognito` contain data. If you do not need to keep the data, you can recreate them like what you did above. This is often the case for non-production stages. - -However, for production stages, you need to import the underlying AWS resource into the v3 app. - -For example, here are the steps for importing an S3 bucket named `app-prod-MyBucket`. - -1. **Import the resource** - - Say the bucket is defined in SST v2, and the bucket name is `app-prod-MyBucket`. - - ```ts title="v2" - const bucket = new Bucket(stack, "MyBucket"); - ``` - - You can use the `import` and `transform` props to import it. - - ```ts title="v3" - const bucket = new sst.aws.Bucket("MyBucket", { - transform: { - bucket: (args, opts) => { - args.bucket = "app-prod-MyBucket"; - opts.import = "app-prod-MyBucket"; - }, - cors: (args, opts) => { - opts.import = "app-prod-MyBucket"; - }, - policy: (args, opts) => { - opts.import = "app-prod-MyBucket"; - }, - publicAccessBlock: (args, opts) => { - opts.import = "app-prod-MyBucket"; - } - } - }); - ``` - - Import is a process of bringing previously created resources into your SST app and allowing it to manage it moving forward. Learn more about [importing resources](/docs/import-resources/). - -2. **Deploy** - - You'll get an error if the resource configurations in your code does not match the exact configuration of the bucket in your AWS account. - - This is good because we don’t want to change our old resource. - -3. **Update props** - - In the error message, you'll see the props you need to change. Add them to the corresponding `transform` block. - - And deploy again. - -:::caution -Make sure the v2 app is set to `retain` to avoid accidentally removing imported resources. -::: - -After the bucket has been imported, the v2 app can still make changes to the resource. If you try to remove the v2 app or remove the bucket from the v2 app, the S3 bucket will get removed. To prevent this, ensure that had the removal policy in the v2 app to `retain`. - ---- - -#### Constructs with custom domains - -Constructs like the following have custom domains. - -- Frontends like `StaticSite`, `NextjsSite`, `SvelteKitSite`, `RemixSite`, `AstroSite`, `SolidStartSite` -- APIs like `Api`, `ApiGatewayv1`, `AppSyncApi`, `WebSocketApi` -- `Service` - -For non-prod stages you can just recreate them. - -However, if they have a custom domain, you need to deploy them in steps to avoid any downtime. - -1. First, create the resource in v3 without a custom domain. So for `Nextjs` for example. - - - - ```ts title="sst.config.ts" - new sst.aws.Nextjs("MySite"); - ``` - - - ```ts title="sst.config.ts" - new NextjsSite(stack, "MySite", { - customDomain: "domain.com" - }); - ``` - - - -2. Deploy your v3 app. - -3. When you are ready, flip the domain using the `override` prop. - - ```ts title="sst.config.ts" {4} - new sst.aws.Nextjs("MySite", { - domain: { - name: "domain.com", - dns: sst.aws.dns({ override: true }) - } - }); - ``` - - This updates the DNS record to point to your new Next.js app. - -And deploy again. - -:::caution -Make sure the v2 app is set to `retain` to avoid accidentally removing imported resources. -::: - -After the DNS record has been overridden, the v2 app can still make changes to it. If you try to remove the v2 app, the record will get removed. To prevent this, ensure that the removal policy in the v2 app to `retain`. - ---- - -#### Subscriber constructs - -Many constructs have subscribers that help with async processing. For example, the `Queue` has a consumer, `Bucket` has the notification, and `Table` constructs have streams. You can recreate the constructs in your v3 app. - -However recreating the subscribers for a production stage with an imported resource is not straight forward: - -- Recreating the consumer for an imported Queue will fail because a `Queue` can only have 1 consumer. -- And, recreating the consumer for an imported DynamoDB Table will result in double processing. As in, an event will be processed both in your v2 and v3 app. - -Here's how we recommend getting around this. - -1. Deploy the v3 app without the subscribers. Either by commenting out the `.subscribe()` call, or by returning early in the subscriber function. -2. When you are ready to flip, remove the subscribers in the v2 app and deploy. -3. Add the subscribers to the v3 app and deploy. - -This ensures that the same subscriber is only attached once to a resource. - ---- - -### Clean up - -Now that your v3 app is handling production traffic. We can optionally go clean up a few things from the v2 app. - -:::tip -We recommend doing a clean up after your v3 app has been in production for a good amount of time. -::: - -The resources that were recreated in v3, the ones that were not imported, can now be removed. However, since we have v2 app set to `retain`, this is going to be a manual process. - -You can go to the CloudFormation console, look at the list of resources in your v2 app's stacks and remove them manually. - -Finally, when you run `sst remove` for your v2 app, it'll remove the CloudFormation stacks as well. - ---- - -### CI/CD - -You probably have _git push to deploy_ or CI/CD set up for your apps. If you are using GitHub Actions; there shouldn't be much of a difference between v2 and v3. - -If you are using [**_Seed_**](https://seed.run) to deploy your v2 app; then you'll want to migrate to using [Autodeploy](/docs/console/#autodeploy) on the [SST Console](/docs/console/). We are currently [not planning to support v3 on Seed](https://seed.run/blog/seed-and-sst-v3). - -There are a couple of key reasons to Autodeploy through the Console: - -- The builds are run in your AWS account. -- You can configure your workflow through your `sst.config.ts`. -- And you can see which resources were updated as a part of the deploy. - -To enable Autodeploy on the Console, you'll need to: - -1. Create a new account on the Console β€” console.sst.dev -2. Link your AWS account -3. Connect your repo -4. Configure your environments -5. And _git push_ - -Learn more about [Console](/docs/console/) and [Autodeploy](/docs/console/#autodeploy). - ---- - -## sst.config.ts - -Listed below are some of the changes to your [`sst.config.ts`](/docs/reference/config/) in general. - ---- - -#### No imports - -All the constructs or _components_ are available in the global context. So there's no need to import anything. Your app's `package.json` only needs the `sst` package. There are no extra CDK or infrastructure related packages. - ---- - -#### Globals - -There are a couple of global variables, `$app` and `$dev` that replace the `app` argument that's passed into the `stacks()` method of your `sst.config.ts`. - -1. `$app.name` gives you the name of app. Used to be `app.name`. -2. `$app.stage` gives you the name of stage. Used to be `app.stage`. -3. `$dev === true` tells you if you are in dev mode. Used to be `app.mode === "dev`. -4. `$dev === false` tells you if it's being deployed. Used to be `app.mode === "deploy`. -5. There is no `app.mode === remove` replacement since your components are not evaluated on `sst remove`. -6. There is no `app.region` since in v3 you can deploy resources to different regions or AWS profiles or _providers_. To get the default AWS provider you can use `aws.getRegionOutput().region`. - ---- - -#### No stacks - -Also since there are no stacks. You don't have access to the `stack` argument inside your stack function. And no `stack.addOutputs({})` method. - -You can still group your constructs or _components_ in files. But to output something you return in the `run` method of your config. - -```ts title="sst.config.ts" -async run() { - const auth = await import("./infra/auth"); - - return { - UserPool: auth.userPool.id, - IdentityPool: auth.identityPool.id, - UserPoolClient: auth.userPoolClient.id - }; -} -``` - ---- - -#### Defaults - -The set of methods that applied defaults to all the functions in your app like; `addDefaultFunctionBinding`, `addDefaultFunctionEnv`, `addDefaultFunctionPermissions`, and `setDefaultFunctionProps` can be replaced with the global `$transform`. - -```ts title="sst.config.ts" -$transform(sst.aws.Function, (args, opts) => { - // Set the default if it's not set by the component - if (args.runtime === undefined) { - args.runtime = "nodejs18.x"; - } -}) -``` - -Learn more about [`$transform`](/docs/reference/global/#transform). - ---- - -## Clients - -The Node.js client, now called the [JS SDK](/docs/reference/sdk/) has a couple of minor changes. - -Update `sst` to the latest version in your `package.json`. If you have a monorepo, make sure to update `sst` in all your packages. - ---- - -### Bind - -In SST v3, you access all bound or _linked_ resources through the `Resource` module. - -Say you link a bucket to a function. - - - - ```ts title="sst.config.ts" {5} - const bucket = new sst.aws.Bucket("MyBucket"); - - new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - link: [bucket] - }); - ``` - - - ```ts title="sst.config.ts" {5} - const bucket = new Bucket(stack, "MyBucket"); - - new Function(stack, "MyFunction", { - handler: "src/lambda.handler", - bind: [bucket] - }); - ``` - - - -In your function you would access it like so. - - - - ```ts title="src/lambda.ts" "Resource.MyBucket.name" "sst" - import { Resource } from "sst"; - - console.log(Resource.MyBucket.name); - ``` - - - ```ts title="src/lambda.ts" "Bucket.MyBucket.bucketName" "sst/node/bucket" - import { Bucket } from "sst/node/bucket"; - - console.log(Bucket.MyBucket.bucketName); - ``` - - - ---- - -### Config - -The same applies to `Config` as well. Let's look at a secret. - - - - ```ts title="sst.config.ts" {5} - const secret = new sst.Secret("MySecret"); - - new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - link: [secret] - }); - ``` - - - ```ts title="sst.config.ts" {5} - const secret = new Config.Secret(stack, "MySecret"); - - new Function(stack, "MyFunction", { - handler: "src/lambda.handler", - bind: [secret] - }); - ``` - - - -And in your function you access it in the same way. - - - - ```ts title="src/lambda.ts" "Resource.MySecret.value" "sst" - import { Resource } from "sst"; - - console.log(Resource.MySecret.value); - ``` - - - ```ts title="src/lambda.ts" "Config.MySecret" "sst/node/config" - import { Config } from "sst/node/config"; - - console.log(Config.MySecret); - ``` - - - ---- - -### Handlers - -In v2, some modules in the Node client had [handlers and hooks](https://v2.sst.dev/clients#handlers). - -```ts title="v2" -import { ApiHandler } from "sst/node/api"; - -export const handler = ApiHandler((event) => { }); -``` - -These were experimental and are not currently supported in v3. To continue using them you can import them by first adding it to your `package.json`. - -```diff lang="json" title="package.json" -{ -+ "sstv2": "npm:sst@^2", - "sst": "^3" -} -``` - -This means that you have both v2 and v3 installed in your project. Since, they both have an `sst` binary, you want to make sure v3 takes precedence. So v3 should be listed **after** v2. - -:::caution -Make sure v3 is listed after v2 in your `package.json`. -::: - -And then import them via the `sstv2` alias. - -```ts title="v3" -import { ApiHandler } from "sstv2/node/api"; - -export const handler = ApiHandler((event) => { }); -``` - ---- - -## Constructs - -Below shows the v3 component version of a v2 construct. - ---- - -### Api - - - - ```ts title="sst.config.ts" - const api = new sst.aws.ApiGatewayV2("MyApi", { - domain: "api.example.com" - }); - - api.route("GET /", "src/get.handler"); - api.route("POST /", "src/post.handler"); - ``` - - - ```ts title="sst.config.ts" - const api = new Api(stack, "MyApi", { - customDomain: "api.example.com" - }); - - api.addRoutes(stack, { - "GET /": "src/get.main", - "POST /": "src/post.handler" - }); - ``` - - - ---- - -### Job - -The `Task` component that replaces `Job` is based on AWS Fargate. It runs a container task in the background. - - - - ```ts title="sst.config.ts" - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Task("MyTask", { - cluster, - image: { - context: "./src", - dockerfile: "Dockerfile" - } - }); - ``` - - - ```ts title="sst.config.ts" - new Job(stack, "MyJob", { - handler: "src/job.main" - }); - ``` - - - -There are some key differences between `Job` and `Task`. - -1. `Task` is based on AWS Fargate. `Job` used a combination of AWS CodeBuild and Lambda. -2. Since `Task` is natively based on Fargate, you can use the AWS SDK to interact with it, even in runtimes the SST SDK doesn't support. -3. In dev mode, `Task` uses Fargate only, whereas `Job` used Lambda. -4. While CodeBuild is billed per minute, Fargate is a lot cheaper than CodeBuild. Roughly **$0.02 per hour** vs **$0.3 per hour** on X86 machines. - -Learn more about [`Task`](/blog/tasks-in-v3). - ---- - -### RDS - - - - ```ts title="sst.config.ts" - const vpc = new sst.aws.Vpc("MyVpc"); - new sst.aws.Aurora("MyDatabase", { - vpc, - engine: "postgres", - version: "15.5", - databaseName: "acme" - }); - ``` - - - ```ts title="sst.config.ts" - new RDS(stack, "MyDatabase", { - engine: "postgresql15.5", - defaultDatabaseName: "acme", - migrations: "path/to/migration/scripts" - }); - ``` - - - -The `Aurora` component uses [Amazon Aurora Serverless v2](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2.html). - -For migrations, we recommend using [Drizzle Kit](https://orm.drizzle.team/kit-docs/overview). Check out our [Drizzle example](/docs/start/aws/drizzle/). - ---- - -### Cron - - - - ```ts title="sst.config.ts" - new sst.aws.Cron("MyCronJob", { - schedule: "rate(1 minute)", - function: "src/cron.handler" - }); - ``` - - - ```ts title="sst.config.ts" - new Cron(stack, "MyCronJob", { - schedule: "rate(1 minute)", - job: "src/cron.handler" - }); - ``` - - - ---- - -### Table - - - - ```ts title="sst.config.ts" - const table = new sst.aws.Dynamo("MyTable", { - fields: { - id: "string" - }, - primaryIndex: { hashKey: "id" } - }); - - table.subscribe("MySubscriber", "src/subscriber.handler"); - ``` - - - ```ts title="sst.config.ts" - const table = new Table(stack, "MyTable", { - fields: { - id: "string" - }, - primaryIndex: { partitionKey: "id" } - }); - - table.addConsumers(stack, { - consumer: "src/subscriber.handler" - }); - ``` - - - ---- - -### Topic - - - - ```ts title="sst.config.ts" - const topic = new sst.aws.SnsTopic("MyTopic"); - - topic.subscribe("MySubscriber", "src/subscriber.handler"); - ``` - - - ```ts title="sst.config.ts" - const topic = new Topic(stack, "MyTopic"); - - topic.addSubscribers(stack, { - subscriber: "src/subscriber.handler" - }); - ``` - - - ---- - -### Queue - - - - ```ts title="sst.config.ts" - const queue = new sst.aws.Queue("MyQueue"); - - queue.subscribe("src/subscriber.handler"); - ``` - - - ```ts title="sst.config.ts" - const queue = new Queue(stack, "MyQueue"); - - queue.addConsumer(stack, "src/subscriber.handler"); - ``` - - - ---- - -### Config - -The `Config` construct is now broken into a `Secret` component and v3 has a separate way to bind any value or _parameter_. - ---- - -#### Secret - - - - ```ts title="sst.config.ts" - const secret = new sst.Secret("MySecret"); - ``` - - - ```ts title="sst.config.ts" - const secret = new Config.Secret(stack, "MySecret"); - ``` - - - -There's also a slight change to the CLI for setting secrets. - - - - ```bash "secret" - npx sst secret set MySecret sk_test_abc123 - ``` - - - ```bash "secrets" - npx sst secrets set MySecret sk_test_abc123 - ``` - - - - ---- - -#### Parameter - -The `Linkable` component lets you bind or _link_ any value. - - - - ```ts title="sst.config.ts" - const secret = new sst.Linkable("MyParameter", { - properties: { version: "1.2.0" } - }); - ``` - - - ```ts title="sst.config.ts" - const secret = new Config.Parameter(stack, "MyParameter", { - value: "1.2.0" - }); - ``` - - - -In your function you'd access this using. - - - - ```ts title="src/lambda.ts" - import { Resource } from "sst"; - - console.log(Resource.MyParameter.version); - ``` - - - ```ts title="src/lambda.ts" - import { Config } from "sst/node/config"; - - console.log(Config.MyParameter); - ``` - - - ---- - -### Bucket - - - - ```ts title="sst.config.ts" - const bucket = new sst.aws.Bucket("MyBucket"); - - bucket.subscribe("src/subscriber.handler"); - ``` - - - ```ts title="sst.config.ts" - const bucket = new Bucket(stack, "MyBucket"); - - bucket.addNotifications(stack, { - notification: "src/notification.main" - }); - ``` - - - ---- - -### Service - - - - ```ts title="sst.config.ts" - const cluster = new sst.aws.Cluster("MyCluster", { - vpc: { - id: "vpc-0d19d2b8ca2b268a1", - securityGroups: ["sg-0399348378a4c256c"], - publicSubnets: ["subnet-0b6a2b73896dc8c4c", "subnet-021389ebee680c2f0"], - privateSubnets: ["subnet-0db7376a7ad4db5fd ", "subnet-06fc7ee8319b2c0ce"] - } - }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - domain: "my-app.com", - ports: [ - { listen: "80/http" } - ] - } - }); - ``` - - - ```ts title="sst.config.ts" - new Service(stack, "MyService", { - customDomain: "my-app.com", - path: "./service", - port: 80, - cdk: { - vpc: Vpc.fromLookup(stack, "VPC", { - vpcId: "vpc-0d19d2b8ca2b268a1" - }) - } - }); - ``` - - - ---- - -### Cognito - - - - ```ts title="sst.config.ts" - const userPool = new sst.aws.CognitoUserPool("MyUserPool"); - - const client = userPool.addClient("MyClient"); - - new sst.aws.CognitoIdentityPool("MyIdentityPool", { - userPools: [{ - userPool: userPool.id, - client: client.id - }] - }); - ``` - - - ```ts title="sst.config.ts" - new Cognito(stack, "MyAuth"); - ``` - - - ---- - -### Function - - - - ```ts title="sst.config.ts" - new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler" - }); - ``` - - - ```ts title="sst.config.ts" - new Function(stack, "MyFunction", { - handler: "src/lambda.handler" - }); - ``` - - - ---- - -### AstroSite - - - ```ts title="sst.config.ts" - new sst.aws.Astro("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new AstroSite(stack, "MyWeb", { - customDomain: "my-app.com" - }); - ``` - - - ---- - -### EventBus - - - - ```ts title="sst.config.ts" - const bus = new sst.aws.Bus("Bus"); - - bus.subscribe("MySubscriber1", "src/function1.handler", { - pattern: { - source: ["myevent"] - } - }); - bus.subscribe("MySubscriber2", "src/function2.handler", { - pattern: { - source: ["myevent"] - } - }); - ``` - - - ```ts title="sst.config.ts" - new EventBus(stack, "Bus", { - rules: { - myRule: { - pattern: { source: ["myevent"] }, - targets: { - myTarget1: "src/function1.handler", - myTarget2: "src/function2.handler" - } - } - } - }); - ``` - - - ---- - -### StaticSite - - - - ```ts title="sst.config.ts" - new sst.aws.StaticSite("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new StaticSite(stack, "MyWeb", { - customDomain: "my-app.com" - }); - ``` - - - ---- - -### RemixSite - - - - ```ts title="sst.config.ts" - new sst.aws.Remix("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new RemixSite(stack, "MyWeb", { - customDomain: "my-app.com" - }); - ``` - - - ---- - -### NextjsSite - - - - ```ts title="sst.config.ts" - new sst.aws.Nextjs("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new NextjsSite(stack, "MyWeb", { - customDomain: "my-app.com" - }); - ``` - - - ---- - -### AppSyncApi - - - - ```ts title="sst.config.ts" - const api = new sst.aws.AppSync("MyApi", { - schema: "schema.graphql", - domain: "api.domain.com" - }); - - const lambdaDS = api.addDataSource({ - name: "lambdaDS", - lambda: "src/lambda.handler" - }); - api.addResolver("Query user", { - dataSource: lambdaDS.name - }); - ``` - - - ```ts title="sst.config.ts" - const api = new AppSyncApi(stack, "MyApi", { - schema: "graphql/schema.graphql", - customDomain: "api.example.com" - }); - - api.addDataSources(stack, { - lambdaDS: "src/lambda.handler" - }); - api.addResolvers(stack, { - "Query user": "lambdaDS" - }); - ``` - - - ---- - -### SvelteKitSite - - - - ```ts title="sst.config.ts" - new sst.aws.SvelteKit("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new SvelteKitSite(stack, "MyWeb", { - customDomain: "my-app.com" - }); - ``` - - - ---- - -### SolidStartSite - - - - ```ts title="sst.config.ts" - new sst.aws.SolidStart("MyWeb", { - domain: "my-app.com" - }); - ``` - - - ```ts title="sst.config.ts" - new SolidStartSite(stack, "MyWeb", { - customDomain: "my-app.com" - }); - ``` - - - ---- - -### WebSocketApi - - - - ```ts title="sst.config.ts" - const api = new sst.aws.ApiGatewayWebSocket("MyApi", { - domain: "api.example.com" - }); - - api.route("$connect", "src/connect.handler"); - api.route("$disconnect", "src/disconnect.handler"); - ``` - - - ```ts title="sst.config.ts" - const api = new WebSocketApi(stack, "MyApi", { - customDomain: "api.example.com" - }); - - api.addRoutes(stack, { - $connect: "src/connect.handler", - $disconnect: "src/disconnect.handler" - }); - ``` - - - ---- - -### KinesisStream - - - - ```ts title="sst.config.ts" - const stream = new sst.aws.KinesisStream("MyStream"); - - stream.subscribe("MySubscriber", "src/subscriber.handler"); - ``` - - - ```ts title="sst.config.ts" - const stream = new KinesisStream(stack, "MyStream"); - - stream.addConsumers(stack, { - consumer: "src/subscriber.handler" - }); - ``` - - - ---- - -### ApiGatewayV1Api - - - - ```ts title="sst.config.ts" - const api = new sst.aws.ApiGatewayV1("MyApi", { - domain: "api.example.com" - }); - - api.route("GET /", "src/get.handler"); - api.route("POST /", "src/post.handler"); - api.deploy(); - ``` - - - ```ts title="sst.config.ts" - const api = new ApiGatewayV1Api(stack, "MyApi", { - customDomain: "api.example.com" - }); - - api.addRoutes(stack, { - "GET /": "src/get.handler", - "POST /": "src/post.handler" - }); - ``` - - - ---- - -Congrats on getting through the migration. - -If you find any errors or if you'd like to add some details to this guide, feel free to _Edit this page_ and submit a PR. diff --git a/www/src/content/docs/docs/migrate-from-v3.mdx b/www/src/content/docs/docs/migrate-from-v3.mdx deleted file mode 100644 index 261d9b7d02..0000000000 --- a/www/src/content/docs/docs/migrate-from-v3.mdx +++ /dev/null @@ -1,120 +0,0 @@ ---- -title: Migrate From v3 -description: Migrate your SST v3 apps to v4. ---- - -import TestimonialWall from "../../../components/TestimonialWall.astro"; - -SST v4 upgrades the underlying [Pulumi AWS provider](https://www.pulumi.com/registry/packages/aws/) from v6 to v7. This guide covers migrating your SST v3 apps to v4. - -:::tip -SST components are already updated for v7. Most users only need to run `sst refresh` and deploy. -::: - -For the full list of upstream changes, refer to the [Pulumi AWS v7 migration guide](https://www.pulumi.com/registry/packages/aws/how-to-guides/7-0-migration). - ---- - -## Breaking changes - -No code changes are needed if you are only using SST components without transforms or direct `@pulumi/aws` usage. Otherwise, refer to the [Pulumi AWS v7 migration guide](https://www.pulumi.com/registry/packages/aws/how-to-guides/7-0-migration) for the full list of breaking changes. - -The internal changes to SST components were minimal: mostly S3 resource renames (dropping the `V2` suffix) and switching from `tags` to `tagsAll`. You can see the full list of changes in the [upgrade PR](https://github.com/anomalyco/sst/pull/6259/). - ---- - -## Migration steps - -When you update SST and the AWS provider version changes, `sst deploy` will be blocked until you migrate your state: - -1. **Install the latest v4** - - Make sure you're on the latest v4 version before running any commands. - -2. **Update your config** - - If you have any breaking changes from above, update your `sst.config.ts` accordingly. - -3. **Review changes** - - Run `sst diff` to preview what will change. This is a **one-way migration**, so it's worth reviewing first. - - ```bash frame="none" - sst diff - ``` - -4. **Migrate state** - - Run `sst refresh` to migrate your state. - - :::caution - Do not use the `--target` flag during migration. The state refresh must cover all resources to ensure a consistent migration. - ::: - - ```bash frame="none" - sst refresh - ``` - - Repeat for each stage. - - ```bash frame="none" - sst refresh --stage production - ``` - - If the stage was deployed using `sst dev`, use the `--dev` flag. - - ```bash frame="none" - sst refresh --dev - ``` - - If you [share resources across stages](/docs/share-across-stages), run `sst refresh` on the stage where the resource is created first β€” not the stage that references it via `.get()`. - -5. **Deploy** - - Once refreshed, deploy as usual. - - ```bash frame="none" - sst deploy - ``` - -That's it β€” once refreshed and deployed, your app is fully migrated to v4. - ---- - -## Upgrade testimonials - -Upgrading your infra framework can feel scary. Here's what teams have shared in Discord after migrating: - - diff --git a/www/src/content/docs/docs/planetscale.mdx b/www/src/content/docs/docs/planetscale.mdx deleted file mode 100644 index 16cf900c53..0000000000 --- a/www/src/content/docs/docs/planetscale.mdx +++ /dev/null @@ -1,150 +0,0 @@ ---- -title: PlanetScale -description: Learn how to use SST with PlanetScale ---- - -[PlanetScale](https://planetscale.com) is a cloud database platform built for speed and scalability. This guide covers how to set it up with SST. - -## Install - -Add the PlanetScale provider to your SST app. Learn more about [providers](/docs/providers). - -```bash -sst add planetscale -``` - -This adds the provider to your `sst.config.ts`. - -```ts title="sst.config.ts" {3} -{ - providers: { - planetscale: "1.0.0", - }, -} -``` - -Then set the `PLANETSCALE_SERVICE_TOKEN` and `PLANETSCALE_SERVICE_TOKEN_ID` environment variables. You can create a service token in the PlanetScale dashboard under [Settings > Service tokens](https://app.planetscale.com/~/settings/service-tokens). The token needs at least the following permissions for the upcoming examples: - -- `connect_branch` -- `connect_production_branch` -- `create_branch` -- `delete_branch` -- `delete_branch_password` -- `read_branch` -- `read_database` - ---- - -## Reference a database - -Reference an existing PlanetScale Vitess database directly from your SST config. - -```ts title="sst.config.ts" -const db = planetscale.getDatabaseVitessOutput({ - id: "mydb", - organization: "myorg", -}); -``` - -:::note -This guide uses the Vitess resources. PlanetScale also supports Postgres with equivalent resources and functions: `PostgresBranch`, `PostgresBranchRole`, `getDatabasePostgresOutput`, and `getPostgresBranchOutput`. -::: - ---- - -## Branch per stage - -PlanetScale supports database branching natively. Combined with SST, every stage and every pull request can get its own isolated database branch automatically. - -Conditionally create or reference a branch based on the current stage. - -```ts title="sst.config.ts" -const branch = - $app.stage === "production" - ? planetscale.getVitessBranchOutput({ - id: db.defaultBranch, - organization: db.organization, - database: db.name, - }) - : new planetscale.VitessBranch("DatabaseBranch", { - database: db.name, - organization: db.organization, - name: $app.stage, - parentBranch: db.defaultBranch, - }); -``` - -In production, it references the existing default branch. In any other stage, it creates a new branch from it. So `sst deploy --stage pr-42` creates a `pr-42` branch in PlanetScale. - -:::tip -Configure [Autodeploy](/docs/console/#autodeploy) in the SST Console to do this automatically on every pull request. -::: - -This is a pattern used in production by [terminal.shop](https://github.com/terminaldotshop/terminal) and [OpenCode](https://github.com/anomalyco/opencode). - ---- - -## Link to your app - -Create a password for the branch and wrap it in a `sst.Linkable`. - -```ts title="sst.config.ts" -const password = new planetscale.VitessBranchPassword("DatabasePassword", { - database: db.name, - organization: db.organization, - branch: branch.name, - role: "admin", - name: `${$app.name}-${$app.stage}`, -}); - -export const database = new sst.Linkable("Database", { - properties: { - host: password.accessHostUrl, - username: password.username, - password: password.plainText, - database: db.name, - port: 3306, - }, -}); -``` - -The [`Linkable`](/docs/component/linkable) component lets you wrap arbitrary values and make them available to any function or service you link it to. Learn more about [linking resources](/docs/linking). - ---- - -## Connect to the database - -Link the database to any function or service. - -```ts title="sst.config.ts" -new sst.aws.Function("Api", { - handler: "src/api.handler", - link: [database], -}); -``` - -Then access the credentials in a type-safe way through `Resource`. For example, with [Drizzle ORM](https://orm.drizzle.team). - -```ts title="src/drizzle.ts" -import { drizzle } from "drizzle-orm/planetscale-serverless"; -import { Resource } from "sst"; - -export const db = drizzle({ - connection: { - host: Resource.Database.host, - username: Resource.Database.username, - password: Resource.Database.password, - }, -}); -``` - -You can use any other ORM or database driver the same way. - ---- - -## Examples - -Check out the full examples: - -- [PlanetScale with Drizzle and MySQL](/docs/examples/#aws-planetscale-drizzle-mysql) -- [PlanetScale with Drizzle and Postgres](/docs/examples/#aws-planetscale-drizzle-postgres) diff --git a/www/src/content/docs/docs/policy-packs.mdx b/www/src/content/docs/docs/policy-packs.mdx deleted file mode 100644 index 5d43029607..0000000000 --- a/www/src/content/docs/docs/policy-packs.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: Policy Packs -description: Enforce compliance and security rules on your infrastructure before deploying. ---- - -Policy packs let you enforce rules on your infrastructure before deploying. They use [Pulumi Policy Packs](https://www.pulumi.com/docs/iac/packages-and-automation/crossguard/) under the hood, and work with the `sst deploy`, `sst diff` and `sst dev` commands. - ---- - -## Quick start - -Say you want to require permission boundaries on all IAM roles. Start by creating a policy pack. - -```bash frame="none" -mkdir policy-pack && cd policy-pack -pulumi policy new aws-typescript -``` - -This creates a `PulumiPolicy.yaml`, `index.ts`, and `package.json`. Update the `index.ts` with your policy. - -```ts title="policy-pack/index.ts" -import * as aws from "@pulumi/aws"; -import { PolicyPack, validateResourceOfType } from "@pulumi/policy"; - -new PolicyPack("aws-policies", { - policies: [ - { - name: "iam-role-requires-permission-boundary", - description: "IAM roles must have a permission boundary.", - enforcementLevel: "mandatory", - validateResource: validateResourceOfType( - aws.iam.Role, - (role, _args, reportViolation) => { - if (!role.permissionsBoundary) { - reportViolation( - "IAM roles must have a permission boundary." - ); - } - } - ), - }, - ], -}); -``` - -Then deploy with the `--policy` flag. - -```bash frame="none" -sst deploy --policy ./policy-pack -``` - -If any resource violates a mandatory policy, the deploy is blocked. - ---- - -## Enforcement levels - -Each policy has an `enforcementLevel` that controls what happens when a resource violates it. - -- **`mandatory`** β€” blocks the deploy. The resource must be fixed before it can be deployed. -- **`advisory`** β€” prints a warning but allows the deploy to continue. - -```ts title="policy-pack/index.ts" -{ - name: "no-wildcard-resources", - description: "Avoid wildcard resources in IAM policies.", - enforcementLevel: "advisory", - validateResource: validateResourceOfType( - aws.iam.RolePolicy, - (policy, _args, reportViolation) => { - // ... - } - ), -} -``` - ---- - -## Writing a policy pack - -A policy pack is a directory with three files: - -- `PulumiPolicy.yaml` β€” metadata and runtime config -- `index.ts` β€” your policies -- `package.json` β€” dependencies - -The `PulumiPolicy.yaml` looks like this. - -```yaml title="policy-pack/PulumiPolicy.yaml" -description: A minimal Policy Pack for AWS using TypeScript. -runtime: nodejs -main: dist/index.js -``` - -And the `package.json` needs the `@pulumi/policy` package, plus any provider packages your policies check against. - -```json title="policy-pack/package.json" -{ - "dependencies": { - "@pulumi/aws": "^6.0.0", - "@pulumi/policy": "^1.20.0" - } -} -``` - -You can check the [full example on GitHub](https://github.com/sst/sst/tree/dev/examples/aws-policy-pack) and the [Pulumi Policy Pack docs](https://www.pulumi.com/docs/iac/packages-and-automation/crossguard/) for more details. diff --git a/www/src/content/docs/docs/providers.mdx b/www/src/content/docs/docs/providers.mdx deleted file mode 100644 index 9a371d1fd9..0000000000 --- a/www/src/content/docs/docs/providers.mdx +++ /dev/null @@ -1,237 +0,0 @@ ---- -title: Providers -description: Providers allow you to interact with cloud services. ---- - -import VideoAside from "../../../components/VideoAside.astro"; - -A provider is what allows SST to interact with the APIs of various cloud services. These are packages that can be installed through your `sst.config.ts`. - - - -SST is built on Pulumi/Terraform and **supports 150+ providers**. This includes the major clouds like AWS, Azure, and GCP; but also services like Cloudflare, Stripe, Vercel, Auth0, etc. - -Check out the full list in the [Directory](/docs/all-providers#directory). - ---- - -## Install - -To add a provider to your app run. - -```bash -sst add -``` - -This command adds the provider to your config, installs the packages, and adds the namespace of the provider to your globals. - -:::caution -Do not `import` the provider packages in your `sst.config.ts`. -::: - -SST manages these packages internally and you do not need to import the package in your `sst.config.ts`. - -:::tip -Your app can have multiple providers. -::: - -The name of a provider comes from the **name of the package** in the [Directory](/docs/all-providers#directory). For example, `sst add planetscale`, will add the following to your `sst.config.ts`. - -```ts title="sst.config.ts" -{ - providers: { - planetscale: "0.0.7" - } -} -``` - -You can add multiple providers to your app. - -```ts title="sst.config.ts" -{ - providers: { - aws: "6.27.0", - cloudflare: "5.37.1" - } -} -``` - -Read more about the [`sst add`](/docs/reference/cli/#add) command. - ---- - -## Configure - -You can configure a provider in your `sst.config.ts`. For example, to change the region for AWS. - -```ts title="sst.config.ts" -{ - providers: { - aws: { - region: "us-west-2" - } - } -} -``` - -You can check out the available list of options that you can configure for a provider over on the provider's docs. For example, here are the ones for [AWS](https://www.pulumi.com/registry/packages/aws/api-docs/provider/#inputs) and [Cloudflare](https://www.pulumi.com/registry/packages/cloudflare/api-docs/provider/#inputs). - ---- - -### Versions - -By default, SST installs the latest version. If you want to use a specific version, you can change it in your config. - -```ts title="sst.config.ts" -{ - providers: { - aws: { - version: "6.27.0" - } - } -} -``` - -If you make any changes to the `providers` in your config, you'll need to run `sst install`. - -:::tip -You'll need to run `sst install` if you update the `providers` in your config. -::: - -The version of the provider is always pinned to what's in the `sst.config.ts` and does not auto-update. This is the case, even if there is no version set. This is to make sure that the providers don't update in the middle of your dev workflow. - -:::note -Providers don't auto-update. They stick to the version that was installed initially. -::: - -So if you want to update it, you'll need to change it manually and run `sst install`. - ---- - -### Credentials - -Most providers will read your credentials from the environment. For example, for Cloudflare you might set your token like so. - -```bash -export CLOUDFLARE_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -export CLOUDFLARE_DEFAULT_ACCOUNT_ID=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -``` - -Follow the [Cloudflare guide](/docs/cloudflare/) for the recommended setup. - -However, some providers also allow you to pass in the credentials through the config. - -```ts title="sst.config.ts" -{ - providers: { - cloudflare: { - apiToken: "aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa" - } - } -} -``` - -Read more about [configuring providers](/docs/reference/config/#providers). - ---- - -## Components - -The provider packages come with components that you can use in your app. - -For example, running `sst add aws` will allow you to use all the components under the `aws` namespace. - -```ts title="sst.config.ts" -new aws.s3.BucketV2("b", { - bucket: "mybucket", - tags: { - Name: "My bucket" - } -}); -``` - -Aside from components in the providers, SST also has a list of built-in components. These are typically higher level components that make it easy to add features to your app. - -You can check these out in the sidebar. Read more about [Components](/docs/components/). - ---- - -## Functions - -Aside from the components, there are a collection of functions that are exposed by a provider. These are listed in the Pulumi docs as `getXXXXXX` on the sidebar. - -For example, to get the AWS account being used in your app. - -```ts title="sst.config.ts" -const current = await aws.getCallerIdentity({}); - -const accountId = current.accountId; -const callerArn = current.arn; -const callerUser = current.userId; -``` - -Or to get the current region. - -```ts title="sst.config.ts" -const current = await aws.getRegion({}); - -const region = current.name; -``` - - ---- - -#### Output versions - -The above are _async_ methods that return promises. That means that if you call these in your app, they'll block the deployment of any resources that are defined after it. - -:::tip -Outputs don't block your deployments. -::: - -So we instead recommend using the _Output_ version of these functions. For example, if we wanted to set the above as environment variables in a function, we would do something like this - -```ts title="sst.config.ts" -new sst.aws.Function("MyFunction, { - handler: "src/lambda.handler", - environment: { - ACCOUNT: aws.getCallerIdentityOutput({}).accountId, - REGION: aws.getRegionOutput().region - } -} -``` - -The `aws.getXXXXOutput` functions typically return an object of type _`Output`_. Read more about [Outputs](/docs/components/#outputs). - ---- - -## Instances - -You can create multiple instances of a provider that's in your config. By default SST creates one instance of each provider in your `sst.config.ts` with the defaults. By you can create multiple instances in your app. - -```ts title="sst.config.ts" -const useast1 = new aws.Provider("AnotherAWS"); -``` - -This is useful for multi-region or multi-account deployments. - ---- - -### Multi-region - -You might want to create multiple providers in cases where some resources in your app need to go to one region, while others need to go to a separate region. - -Let's look at an example. Assume your app is normally deployed to `us-west-1`. But you need to create an ACM certificate that needs to be deployed to `us-east-1`. - -```ts {1} title="sst.config.ts" "{ provider: useast1 }" -const useast1 = new aws.Provider("useast1", { region: "us-east-1" }); - -new sst.aws.Function("MyFunction, "src/lambda.handler"); - -new aws.acm.Certificate("cert", { - domainName: "foo.com", - validationMethod: "EMAIL", -}, { provider: useast1 }); -``` - -Here the function is created in your default region, `us-west-1`. While the certificate is created in `us-east-1`. diff --git a/www/src/content/docs/docs/reference-resources.mdx b/www/src/content/docs/docs/reference-resources.mdx deleted file mode 100644 index 39505e8277..0000000000 --- a/www/src/content/docs/docs/reference-resources.mdx +++ /dev/null @@ -1,165 +0,0 @@ ---- -title: Reference Resources -description: Reference externally created resources in your app. ---- - -Referencing is the process of _using_ some externally created resources in your SST app; without having SST manage them. - -This is for when you have some resources that are either managed by a different team or a different IaC tool. Typically these are low-level resources and not SST's built-in components. - -There are a few different ways this shows up in SST. - ---- - -## Lookup a resource - -Let's say you have an existing resource that you want to use in your SST app. - -You can look it up by passing in a property of the resource. For example, to look up a previously created S3 Bucket with the following name. - -```txt -mybucket-xnbmhcvd -``` - -We can use the [`static aws.s3.BucketV2.get`](https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketv2/#look-up) method. - -```ts title="sst.config.ts" -const bucket = aws.s3.BucketV2.get("MyBucket", "mybucket-xnbmhcvd"); -``` - -This gives you the same bucket object that you'd get if you had created this resource in your app. - -Here we are assuming the bucket wasn't created through an SST app. This is why we are using the low-level `aws.s3.BucketV2`. If this was created in an SST app or in another stage in the same app, there's a similar `static sst.aws.Bucket.get` method. Learn more about [sharing across stages](/docs/share-across-stages). - ---- - -#### How it works - -When you create a resource in your SST app, two things happen. First, the resource is created by making a bunch of calls to your cloud provider. Second, SST makes a call to _get_ the resource from the cloud provider. The data that it gets back is stored in your [state](/docs/state/). - -:::note -When you lookup a resource or create it, you get the same type of object. -::: - -When you lookup a resource, it skips the creation step and just gets the resource. It does this every time you deploy. But the object you get in both cases is the same. - ---- - -#### Lookup properties - -The properties used to do a lookup are the same ones that you'd use if you were trying to import them. - -:::tip -You can look up a resource with its [Import Property](/docs/import-resources/#import-properties). -::: - -We've compiled a list of the most commonly lookedup low-level resources and their [Import Properties](/docs/import-resources/#import-properties). - -Most low-level resources come with a `static get` method that use this property to look up the resource. - ---- - -#### Make it linkable - -Let's take it a step further. - -You can use the [`sst.Linkable`](/docs/component/linkable/) component, to be able to link any property of this resource. - -```ts title="sst.config.ts" {3} -const storage = new sst.Linkable("MyStorage", { - properties: { - domain: bucket.bucketDomainName - } -}); -``` - -Here we are using the domain name of the bucket as an example. - ---- - -#### Link to it - -And link it to a function. - -```ts title="sst.config.ts" {9} -new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - link: [storage] -}); -``` - -Now you can use the [SDK](/docs/reference/sdk/) to access them at runtime. - -```js title="src/lambda.ts" -import { Resource } from "sst"; - -console.log(Resource.MyStorage.domain); -``` - ---- - -## Pass in a resource - -Aside from looking up resources, you can also pass existing resources in to the built-in SST components. This is typically when you are trying to create a new resource and it takes another resource as a part of it. - -For example, let's say you want to add a previously created function as a subscriber to a queue. You can do so by passing its ARN. - -```ts title="sst.config.ts" {3} -const queue = new sst.aws.Queue("MyQueue"); - -queue.subscribe("arn:aws:lambda:us-east-1:123456789012:function:my-function"); -``` - ---- - -#### How it works - -SST is simply asking for the props the underlying resource needs. In this case, it only needs the function ARN. - -However, for more complicated resources like VPCs, you might have to pass in a lot more. Here we are creating a new function in an existing VPC. - -```ts title="sst.config.ts" -new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - vpc: { - subnets: ["subnet-0be8fa4de860618bb"], - securityGroups: ["sg-0be8fa4de860618bb"] - } -}); -``` - -Whereas, for the `Cluster` component, you might need to pass in a lot more. - -```ts title="sst.config.ts" -new sst.aws.Cluster("MyCluster", { - vpc: { - id: "vpc-0be8fa4de860618bb", - securityGroups: ["sg-0be8fa4de860618bb"], - containerSubnets: ["subnet-0be8fa4de860618bb"], - loadBalancerSubnets: ["subnet-8be8fa4de850618ff"] - } -}); -``` - -These are listed under the `vpc` prop of the `Cluster` component. - ---- - -## Attach to a resource - -Referencing existing resources also comes in handy when you are attaching to an existing resource. For example, to add a subscriber to an externally created queue: - -```ts title="sst.config.ts" {3} -sst.aws.Queue.subscribe("arn:aws:sqs:us-east-1:123456789012:MyQueue", "src/subscriber.handler"); -``` - -Here we are using the `static subscribe` method of the `Queue` component. And it takes the queue ARN that you are trying to attach to. - -There are a few other built-in SST components that have `static` methods like this. - -- `Bus` -- `Dynamo` -- `SnsTopic` -- `KinesisStream` - -With this you can continue to manage the root resource outside of SST, while still being able to attach to them. diff --git a/www/src/content/docs/docs/reference/sdk.mdx b/www/src/content/docs/docs/reference/sdk.mdx deleted file mode 100644 index b961d7c0dc..0000000000 --- a/www/src/content/docs/docs/reference/sdk.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: SDK -description: Interact with your infrastructure in your runtime code. ---- - -The SST SDK allows your runtime code to interact with your infrastructure in a typesafe way. - -You can use the SDK in your **functions**, **frontends**, and **container applications**. You can access links from components. And some components come with SDK clients that you can use. - -:::tip -Check out the _SDK_ section in a component's API reference doc. -::: - -Currently, the SDK is only available for JS/TS, Python, Golang, and Rust. Support for other languages is on the roadmap. - ---- - -## Node.js - -The JS SDK is an [npm package](https://www.npmjs.com/package/sst) that you can install in your functions, frontends, or container applications. - -```bash -npm install sst -``` - ---- - -### Links - -Import `Resource` to access the linked resources. - -```js title="src/lambda.ts" -import { Resource } from "sst"; - -console.log(Resource.MyBucket.name); -``` - -:::tip -The `Resource` object is typesafe and will autocomplete the available resources in your editor. -::: - -Here we are assuming that a bucket has been linked to the function. Here's what that could look like. - -```js title="sst.config.ts" {5} -const bucket = new sst.aws.Bucket("MyBucket"); - -new sst.aws.Function("MyFunction", { - handler: "src/lambda.handler", - link: [bucket] -}); -``` - ---- - -#### Defaults - -By default, the `Resource` object contains `Resource.App`. This gives you some info about the current app including: - -- `App.name`: The name of your SST app. -- `App.stage`: The current stage of your SST app. - -```ts title="src/lambda.ts" -import { Resource } from "sst"; - -console.log(Resource.App.name, Resource.App.stage); -``` - ---- - -### Clients - -Components like the [`Realtime`](/docs/component/aws/realtime/) component come with a client that you can use. - -```ts title="src/lambda.ts" -import { realtime } from "sst/aws/realtime"; - -export const handler = realtime.authorizer(async (token) => { - // Validate the token -}); -``` - -For example, `realtime.authorizer` lets you create the handler for the authorizer function that `Realtime` needs. - ---- - -### How it works - -In the above example, `Resource.MyBucket.name` works because it's been injected into the function package on `sst dev` and `sst deploy`. - -For functions, this is injected into the [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) using [esbuild](https://esbuild.github.io/) and for frontends, it's injected into the `process.env` object. - -The JS SDK first checks the `process.env` and then the `globalThis` for the linked resources. You can [read more about how the links are injected](/docs/linking/#injecting-links). - ---- - -## Python - -SST uses [uv](https://docs.astral.sh/uv/) to package your Python functions. Your functions need to be in a [uv workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/#workspace-sources). - -To use the SDK, add it to your `pyproject.toml`. - -```toml title="functions/pyproject.toml" -[project] -dependencies = ["sst-sdk"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } -``` - -And in your function, import the `resource` module and access the linked resource. - -```py title="functions/src/functions/api.py" {1} "Resource.MyBucket.name" -from sst import Resource - -def handler(event, context): - print(Resource.MyBucket.name) -``` - -Here `MyBucket` is the name of a bucket that's linked to the function. - -```ts title="sst.config.ts" {6} -const bucket = new sst.aws.Bucket("MyBucket"); - -new sst.aws.Function("MyFunction", { - handler: "functions/src/functions/api.handler", - runtime: "python3.13", - link: [bucket] -}); -``` - -Client functions are currently **not supported** in the Python SDK. - ---- - -## Golang - -Use the SST Go SDK package in your Golang functions or container applications. - -```go title="src/main.go" -import ( - "github.com/sst/sst/v3/sdk/golang/resource" -) -``` - -In your runtime code, use the `resource.Get` function to access the linked resources. - -```go title="src/main.go" -resource.Get("MyBucket", "name") -``` - -Where `MyBucket` is the name of a bucket that's linked to the function. - -```js title="sst.config.ts" {5} -const bucket = new sst.aws.Bucket("MyBucket"); - -new sst.aws.Function("MyFunction", { - handler: "./src", - link: [bucket] -}); -``` - -You can also access the current app's info with. - -```go title="src/main.go" -resource.Get("App", "name") -resource.Get("App", "stage") -``` - -Client functions are currently **not supported** in the Go SDK. - ---- - -## Rust - -Use the SST Rust SDK package in your Rust functions or container applications. - -```bash -cargo install sst_sdk -``` - -In your runtime, use the `Resource::get()` function to access linked resources as a typesafe struct, or a `serde_json::Value`. - -```rust title="main.rs" -use sst_sdk::Resource; - -#[derive(serde::Deserialize, Debug)] -struct Bucket { - name: String, -} - -fn main() { - let resource = Resource::init().unwrap(); - // access your linked resources as a typesafe struct that implements Deserialize - let Bucket { name } = resource.get("MyBucket").unwrap(); - // or as a weakly typed json value (that also implements Deserialize) - let openai_key: serde_json::Value = resource.get("OpenaiSecret").unwrap(); -} -``` - -where `MyBucket` and `OpenaiSecret` are linked to the function. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -const openai = new sst.Secret("OpenaiSecret"); - -new sst.aws.Function("MyFunction", { - handler: "./", - link: [bucket, openai], - runtime: "rust" -}); -``` - -Client functions are currently **not supported** in the Rust SDK. diff --git a/www/src/content/docs/docs/set-up-a-monorepo.mdx b/www/src/content/docs/docs/set-up-a-monorepo.mdx deleted file mode 100644 index 8622123b08..0000000000 --- a/www/src/content/docs/docs/set-up-a-monorepo.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -title: Set up a Monorepo -description: A TypeScript monorepo setup for your app. ---- - -While, [drop-in mode](/docs/#drop-in-mode) is great for simple projects, we recommend using a monorepo for projects that are going to have multiple packages. - -:::tip -We created a [monorepo template](https://github.com/sst/monorepo-template/tree/main) for your SST projects. -::: - -However, setting up a monorepo with everything you need can be surprisingly tricky. To fix this we created a template for a TypeScript monorepo that uses npm workspaces. - ---- - -## How to use - -To use this template. - -1. Head over to [**github.com/sst/monorepo-template**](https://github.com/sst/monorepo-template) - -2. Click on **Use this template** and create a new repo. - -3. Clone the repo. - -4. From the project root, run the following to rename it to your app. - - ```bash - npx replace-in-file "/monorepo-template/g" "MY_APP" "./**/*" --verbose - ``` - -5. Install the dependencies. - - ```bash - npm install - ``` - -Now just run `npx sst dev` from the project root. - ---- - -## Project structure - -The app is split into the separate `packages/` and an `infra/` directory. - -```txt {2} -my-sst-app -β”œβ”€ sst.config.ts -β”œβ”€ package.json -β”œβ”€ packages -β”‚ β”œβ”€ functions -β”‚ β”œβ”€ scripts -β”‚ └─ core -└─ infra -``` - -The `packages/` directory has your workspaces and this is in the root `package.json`. - -```json title="package.json -"workspaces": [ - "packages/*" -] -``` - -Let's look at it in detail. - ---- - -### Packages - -The `packages/` directory includes the following: - -- `core/` - - This directory includes shared code that can be used by other packages. These are - defined as modules. For example, we have an `Example` module. - - ```ts title="packages/core/src/example/index.ts" - export namespace Example { - export function hello() { - return "Hello, world!"; - } - } - ``` - - We export this using the following in the `package.json`: - - ```json title="packages/core/package.json" - "exports": { - "./*": [ - "./src/*\/index.ts", - "./src/*.ts" - ] - } - ``` - - This will allow us to import the `Example` module by doing: - - ```ts - import { Example } from "@monorepo-template/core/example"; - - Example.hello(); - ``` - - We recommend creating new modules for the various _domains_ in your project. This roughly follows Domain Driven Design. - - We also have [Vitest](https://vitest.dev/) configured for testing this package with the `sst shell` CLI. - - ```bash - npm test - ``` - -- `functions/` - - This directory includes our Lambda functions. It imports from the `core/` - package by using it as a local dependency. - -- `scripts/` - - This directory includes scripts that you can run on your SST app using the `sst shell` CLI - and [`tsx`](https://www.npmjs.com/package/tsx). For example, to the run the example - `scripts/src/example.ts`, run the following from `packages/scripts/`. - - ```bash - npm run shell src/example.ts - ``` - -You can add additional packages to the `packages/` directory. For example, you might add a `frontend/` and a `backend/` package. - ---- - -### Infrastructure - -The `infra/` directory allows you to logically split the infrastructure of your app into separate files. This can be helpful as your app grows. - -In the template, we have an `api.ts`, and `storage.ts`. These export resources that can be used in the other infrastructure files. - -```ts title="infra/storage.ts" -export const bucket = new sst.aws.Bucket("MyBucket"); -``` - -We then dynamically import them in the `sst.config.ts`. - -```ts title="sst.config.ts" -async run() { - const storage = await import("./infra/storage"); - await import("./infra/api"); - - return { - MyBucket: storage.bucket.name - }; -} -``` - -Finally, some of the outputs of our components are set as outputs for our app. diff --git a/www/src/content/docs/docs/share-across-stages.mdx b/www/src/content/docs/docs/share-across-stages.mdx deleted file mode 100644 index bf9d6c92ae..0000000000 --- a/www/src/content/docs/docs/share-across-stages.mdx +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: Share Across Stages -description: Share resources across stages in your app. ---- - -You define all the resources in your app in your `sst.config.ts`. These resources then get created for each stage that you deploy to. - -However, there might be some cases where you don't want to recreate certain resources for every stage. - ---- - -## Why share - -You typically want to share for cases where: - -- Resources that are expensive and their pricing is not truly pay-per-use, like your Postgres cluster. -- Or, if they contain data that these new stages need to reuse. For example, your PR stages might just be for testing against your staging data and don't need to recreate some resources. - -While it might be tempting to share more resources across stages, we only recommend doing it for the above cases. - ---- - -## How to share - -To help with this some SST components come with a `static get` method. These components are typically ones that people want to be able to share. Here are some components that have this: - -- [`Vpc`](/docs/component/aws/vpc/) -- [`Email`](/docs/component/aws/email/) -- [`Bucket`](/docs/component/aws/bucket/) -- [`Postgres`](/docs/component/aws/postgres/) -- [`CognitoUserPool`](/docs/component/aws/cognito-user-pool/) -- [`CognitoIdentityPool`](/docs/component/aws/cognito-identity-pool/) -- [`D1`](/docs/component/cloudflare/d1/) - -If you'd like us to add to this list, feel free to open a GitHub issue. - -It's worth noting that complex components like our frontends, `Nextjs`, or `StaticSite`, are not likely to be supported. Both because they are made up of a large number of resources. But also because they really aren't worth sharing across stages. - -Let's look at an example. - ---- - -### Example - -The [`static get`](/docs/component/aws/bucket/#static-get) in the `Bucket` component has the following signature. It takes the name of the component and the name of the existing bucket. - -```ts -get(name: string, bucketName: string) -``` - -Imagine you create a bucket in the `dev` stage. And in your personal stage `frank`, instead of creating a new bucket, you want to share the bucket from `dev`. - -```ts title="sst.config.ts" -const bucket = $app.stage === "frank" - ? sst.aws.Bucket.get("MyBucket", "app-dev-mybucket-12345678") - : new sst.aws.Bucket("MyBucket"); -``` - -We are using [`$app.stage`](/docs/reference/global/#app-stage), a global to get the current stage the CLI is running on. It allows us to conditionally create the bucket. - -Here `app-dev-mybucket-12345678` is the auto-generated bucket name for the bucket created -in the `dev` stage. You can find this by outputting the bucket name in the `dev` stage. - -```ts title="sst.config.ts" -return { - bucket: bucket.name -}; -``` - -And it'll print it out on `sst deploy`. - -```bash frame="none" -bucket: app-dev-mybucket-12345678 -``` - -You can read more about outputs in the [`run`](/docs/reference/config/#run) function. diff --git a/www/src/content/docs/docs/start/aws/analog.mdx b/www/src/content/docs/docs/start/aws/analog.mdx deleted file mode 100644 index 3b563d661b..0000000000 --- a/www/src/content/docs/docs/start/aws/analog.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -title: Analog on AWS with SST -description: Create and deploy an Analog app to AWS with SST. ---- - -We are going to create an [Analog app](https://analogjs.org/), add an S3 Bucket for file uploads, and deploy it to AWS using SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-analog) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -## 1. Create a project - -Let's start by creating our project. - -```bash -npm create analog@latest -cd aws-analog -``` - -We are picking the **Full-stack Application** option and **not adding Tailwind**. - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `vite.config.ts` with something like this. - -```diff lang="ts" title="vite.config.ts" -plugins: [analog({ -+ nitro: { -+ preset: "aws-lambda", -+ } -})], -``` - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Analog app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your Analog app in your browser. - ---- - -## 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `Analog` component. - -#### Link the bucket - -Now, link the bucket to our Analog app. - -```js title="sst.config.ts" {2} -new sst.aws.Analog("MyWeb", { - link: [bucket], -}); -``` - ---- - -## 3. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload on the server. Create a new `src/pages/index.server.ts` with the following. - -```ts title="src/pages/index.server.ts" {10} -import { Resource } from 'sst'; -import { PageServerLoad } from '@analogjs/router'; -import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'; - -export const load = async ({ }: PageServerLoad) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - // @ts-ignore: Generated on deploy - Bucket: Resource.MyBucket.name, - }); - - const url = await getSignedUrl(new S3Client({}), command); - - return { - url - }; -}; -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - ---- - -## 4. Create an upload form - -Add the upload form client in `src/pages/index.page.ts`. Replace it with the following. - -```ts title="src/pages/index.page.ts" {6,20} -import { Component } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { injectLoad } from '@analogjs/router'; -import { toSignal } from '@angular/core/rxjs-interop'; - -import { load } from './index.server'; - -@Component({ - selector: 'app-home', - standalone: true, - imports: [FormsModule], - template: ` -
    - - -
    - `, -}) -export default class HomeComponent { - data = toSignal(injectLoad(), { requireSync: true }); - - async onSubmit(event: Event): Promise { - const file = (event.target as HTMLFormElement)['file'].files?.[0]!; - - const image = await fetch(this.data().url, { - body: file, - method: 'PUT', - headers: { - 'Content-Type': file.type, - 'Content-Disposition': `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split('?')[0]; - } -} -``` - -Here we are injecting the pre-signed URL from the server into the component. - -Head over to the local Analog app site in your browser, `http://localhost:5173` and try **uploading an image**. You should see it upload and then download the image. - ---- - -## 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. - - diff --git a/www/src/content/docs/docs/start/aws/angular.mdx b/www/src/content/docs/docs/start/aws/angular.mdx deleted file mode 100644 index 9b98b9e4e3..0000000000 --- a/www/src/content/docs/docs/start/aws/angular.mdx +++ /dev/null @@ -1,284 +0,0 @@ ---- -title: Angular on AWS with SST -description: Create and deploy an Angular app to AWS with SST. ---- - -We are going to create an Angular 18 SPA, add an S3 Bucket for file uploads, and deploy it to AWS using SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-angular) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -## 1. Create a project - -Let's start by creating our project. - -```bash -npm install -g @angular/cli -ng new aws-angular -cd aws-angular -``` - -We are picking **CSS** for styles, and **not using SSR**. - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -``` - -This'll create a `sst.config.ts` file in your project root. - ---- - -## 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `StaticSite` component. - -We are going to upload a file to this bucket using a pre-signed URL. This'll let us upload it directly to our bucket. - ---- - -## 3. Add an API - -Let's create a simple API to generate that URL. Add this below the `Bucket` component. - -```ts title="sst.config.ts" {3} -const pre = new sst.aws.Function("MyFunction", { - url: true, - link: [bucket], - handler: "functions/presigned.handler", -}); -``` - -We are linking our bucket to this function. - ---- - -#### Pass the API URL - -Now, pass the API URL to our Angular app. Add this below the `build` prop in our `StaticSite` component. - -```ts title="sst.config.ts" {2} -environment: { - NG_APP_PRESIGNED_API: pre.url -} -``` - -To load this in our Angular app, we'll use the [`@ngx-env/builder`](https://www.npmjs.com/package/@ngx-env/builder) package. - -```bash -ng add @ngx-env/builder -``` - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Angular app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and go to your Angular app in your browser. Typically on `http://localhost:4200`. - - ---- - -## 3. Create an upload form - -Let's create a component to do the file upload. Add the following to `src/app/file-upload.component.ts`. - -```ts title="src/app/file-upload.component.ts" {19} -import { Component, inject } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; - -@Component({ - selector: 'app-file-upload', - standalone: true, - imports: [FormsModule], - template: ` -
    - - -
    - `, -}) -export class FileUploadComponent { - private http = inject(HttpClient); - - presignedApi = import.meta.env['NG_APP_PRESIGNED_API']; - - async onSubmit(event: Event): Promise { - const file = (event.target as HTMLFormElement)['file'].files?.[0]!; - - this.http.get(this.presignedApi, { responseType: 'text' }).subscribe({ - next: async (url: string) => { - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }, - }); - } -} -``` - -This is getting the pre-signed API URL from the environment. Making a request to it to get the pre-signed URL and then uploading our file to it. - -Let's add some `styles` below the `template` prop. - -```ts title="src/app/file-upload.component.ts" -styles: [` - form { - color: white; - padding: 2rem; - display: flex; - align-items: center; - justify-content: space-between; - background-color: #23262d; - background-image: none; - background-size: 400%; - border-radius: 0.6rem; - background-position: 100%; - box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); - } - button { - appearance: none; - border: 0; - font-weight: 500; - border-radius: 5px; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - background-color: white; - color: black; - } - button:active:enabled { - background-color: #EEE; - } -`] -``` - -To make HTTP fetch requests we need to add the provider to our Angular app config. Add the following to the `providers` list in `src/app/app.config.ts`. - -```ts title="src/app/app.config.ts" -provideHttpClient(withFetch()) -``` - -And import it at the top. - -```ts title="src/app/app.config.ts" -import { provideHttpClient, withFetch } from '@angular/common/http'; -``` - -Let's add this to our app. Replace the `src/app/app.component.ts` file with. - -```ts title="src/app/app.component.ts" -import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; -import { FileUploadComponent } from './file-upload.component'; - -@Component({ - selector: 'app-root', - standalone: true, - imports: [RouterOutlet, FileUploadComponent], - template: ` -
    - -
    - - `, - styles: [` - main { - margin: auto; - padding: 1.5rem; - max-width: 60ch; - } - `], -}) -export class AppComponent { } -``` - ---- - -## 4. Generate a pre-signed URL - -Let's implement the API that generates the pre-signed URL. Create a `functions/presigned.ts` file with the following. - -```ts title="functions/presigned.ts" {8} -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export async function handler() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 200, - body: await getSignedUrl(new S3Client({}), command), - }; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local Angular app in your browser, `http://localhost:4200` and try **uploading an image**. You should see it upload and then download the image. - ---- - -## 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. - - diff --git a/www/src/content/docs/docs/start/aws/astro.mdx b/www/src/content/docs/docs/start/aws/astro.mdx deleted file mode 100644 index f6f10c79d6..0000000000 --- a/www/src/content/docs/docs/start/aws/astro.mdx +++ /dev/null @@ -1,513 +0,0 @@ ---- -title: Astro on AWS with SST -description: Create and deploy an Astro site to AWS with SST. ---- - -There are two ways to deploy an Astro site to AWS with SST. - -1. [Serverless](#serverless) -2. [Containers](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -#### Examples - -We also have a few other Astro examples that you can refer to. - -- [Enabling streaming in your Astro app](/docs/examples/#aws-astro-streaming) -- [Hit counter with Redis and Astro in a container](/docs/examples/#aws-astro-container-with-redis) - ---- - -## Serverless - -We are going to create an Astro site, add an S3 Bucket for file uploads, and deploy it using the `Astro` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-astro) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npm create astro@latest aws-astro -cd aws-astro -``` - -We are picking all the default options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `astro.config.mjs` with something like this. - -```diff lang="js" title="astro.config.mjs" -+ import aws from "astro-sst"; - -export default defineConfig({ -+ output: "server", -+ adapter: aws() -}); -``` - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your Astro site. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your Astro site in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `Astro` component. - -##### Link the bucket - -Now, link the bucket to our Astro site. - -```js title="sst.config.ts" {2} -new sst.aws.Astro("MyWeb", { - link: [bucket], -}); -``` - ---- - -### 3. Create an upload form - -Add the upload form client in `src/pages/index.astro`. Replace the `` component with: - -```astro title="src/pages/index.astro" - -
    -
    - - -
    - -
    -
    -``` - -Add some styles, add this to your `src/pages/index.astro`. - -```astro title="src/pages/index.astro" - -``` - ---- - -### 4. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and use it in the form. Add this to the header on your `src/pages/index.astro`. - -```astro title="src/pages/index.astro" {8} ---- -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local Astro site in your browser, `http://localhost:4321` and try **uploading an image**. You should see it upload and then download the image. - -![SST Astro app local](../../../../../assets/docs/start/start-astro-local.png) - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - ---- - -## Containers - -We are going to create a Astro site, add an S3 Bucket for file uploads, and deploy it in a container with the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-astro-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npm create astro@latest aws-astro-container -cd aws-astro-container -``` - -We are picking all the default options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `astro.config.mjs`. But **we'll instead use** the [Node.js adapter](https://docs.astro.build/en/guides/integrations-guide/node/) since we're deploying it through a container. - -```bash -npx astro add node -``` - ---- - -### 2. Add a Service - -To deploy our Astro site in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in your `sst.config.ts`. - -```ts title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "4321/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC, and an ECS Cluster with a Fargate service in it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Astro site locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Astro site. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Astro site in your browser. - ---- - -### 3. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this below the `Vpc` component. - ---- - -##### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Astro site. - ---- - -### 4. Create an upload form - -Add the upload form client in `src/pages/index.astro`. Replace the `` component with: - -```astro title="src/pages/index.astro" - -
    -
    - - -
    - -
    -
    -``` - -Add some styles, add this to your `src/pages/index.astro`. - -```astro title="src/pages/index.astro" - -``` - ---- - -### 5. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and use it in the form. Add this to the header on your `src/pages/index.astro`. - -```astro title="src/pages/index.astro" {8} ---- -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local Astro site in your browser, `http://localhost:4321` and try **uploading an image**. You should see it upload and then download the image. - -![SST Astro app local](../../../../../assets/docs/start/start-astro-local-container.png) - ---- - -### 6. Deploy your app - -To deploy our app we'll add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM node:lts AS base -WORKDIR /app - -COPY package.json package-lock.json ./ - -FROM base AS prod-deps -RUN npm install --omit=dev - -FROM base AS build-deps -RUN npm install - -FROM build-deps AS build -COPY . . -RUN npm run build - -FROM base AS runtime -COPY --from=prod-deps /app/node_modules ./node_modules -COPY --from=build /app/dist ./dist - -ENV HOST=0.0.0.0 -ENV PORT=4321 -EXPOSE 4321 -CMD node ./dist/server/entry.mjs -``` - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -.DS_Store -node_modules -dist -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/auth.mdx b/www/src/content/docs/docs/start/aws/auth.mdx deleted file mode 100644 index 17a4d08968..0000000000 --- a/www/src/content/docs/docs/start/aws/auth.mdx +++ /dev/null @@ -1,438 +0,0 @@ ---- -title: OpenAuth with SST and Next.js -description: Add OpenAuth to your Next.js app and deploy it with SST. ---- - -import { Image } from "astro:assets" - -import nextApp from "../../../../../assets/docs/start/openauth-nextjs.png" -import consoleAutodeploy from "../../../../../assets/docs/start/sst-console-autodeploy.png" - -We are going to create a new Next.js app, add authentication to it with [OpenAuth](https://openauth.js.org), and deploy it with [OpenNext](https://opennext.js.org) and SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-auth-nextjs) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -#### Examples - -We also have another OpenAuth example that you can refer to. - -- [Full-stack React SPA with an API](/docs/examples/#aws-openauth-react-spa) - ---- - -## 1. Create a project - -Let's start by creating our Next.js app and starting it in dev mode. - -```bash -npx create-next-app@latest aws-auth-nextjs -cd aws-auth-nextjs -``` - -We are picking **TypeScript** and not selecting **ESLint**. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -## 2. Add OpenAuth server - -Next, let's add a directory for our OpenAuth server. - -```bash -mkdir auth -``` - -Add our OpenAuth server to a `auth/index.ts` file. - -```ts title="auth/index.ts" -import { handle } from "hono/aws-lambda"; -import { issuer } from "@openauthjs/openauth"; -import { CodeUI } from "@openauthjs/openauth/ui/code"; -import { CodeProvider } from "@openauthjs/openauth/provider/code"; -import { subjects } from "./subjects"; - -async function getUser(email: string) { - // Get user from database and return user ID - return "123"; -} - -const app = issuer({ - subjects, - // Remove after setting custom domain - allow: async () => true, - providers: { - code: CodeProvider( - CodeUI({ - sendCode: async (email, code) => { - console.log(email, code); - }, - }), - ), - }, - success: async (ctx, value) => { - if (value.provider === "code") { - return ctx.subject("user", { - id: await getUser(value.claims.email), - }); - } - throw new Error("Invalid provider"); - }, -}); - -export const handler = handle(app); -``` - ---- - -##### Define subjects - -We are also going to define our subjects. Add the following to a `auth/subjects.ts` file. - -```ts title="auth/subjects.ts" -import { object, string } from "valibot"; -import { createSubjects } from "@openauthjs/openauth/subject"; - -export const subjects = createSubjects({ - user: object({ - id: string(), - }), -}); -``` - -Let's install our dependencies. - -```bash -npm install @openauthjs/openauth valibot hono -``` - ---- - -##### Add Auth component - -Now let's add this to our SST app. Replace the `run` function in `sst.config.ts` with the following. - -```ts title="sst.config.ts" {6} -const auth = new sst.aws.Auth("MyAuth", { - issuer: "auth/index.handler", -}); - -new sst.aws.Nextjs("MyWeb", { - link: [auth], -}); -``` - -This is defining our OpenAuth component and linking it to our Next.js app. - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST, your Next.js app, and your OpenAuth server. - -```bash -npx sst dev -``` - -Once complete, it should give you the URL of your OpenAuth server. - -```bash -βœ“ Complete - MyAuth: https://fv62a3niazbkrazxheevotace40affnk.lambda-url.us-east-1.on.aws -``` - -Also click on **MyWeb** in the sidebar and open your Next.js app by going to `http://localhost:3000`. - ---- - -## 3. Add OpenAuth client - -Next, let's add our OpenAuth client to our Next.js app. Add the following to `app/auth.ts`. - -```ts title="app/auth.ts" {7} -import { Resource } from "sst"; -import { createClient } from "@openauthjs/openauth/client"; -import { cookies as getCookies } from "next/headers"; - -export const client = createClient({ - clientID: "nextjs", - issuer: Resource.MyAuth.url, -}); - -export async function setTokens(access: string, refresh: string) { - const cookies = await getCookies(); - - cookies.set({ - name: "access_token", - value: access, - httpOnly: true, - sameSite: "lax", - path: "/", - maxAge: 34560000, - }); - cookies.set({ - name: "refresh_token", - value: refresh, - httpOnly: true, - sameSite: "lax", - path: "/", - maxAge: 34560000, - }); -} -``` - -Here we are _linking_ to our auth server. And once the user is authenticated, we'll be saving their access and refresh tokens in _http only_ cookies. - ---- - -##### Add auth actions - -Let's add the server actions that our Next.js app will need to authenticate users. Add the following to `app/actions.ts`. - -```ts title="app/actions.ts" -"use server"; - -import { redirect } from "next/navigation"; -import { headers as getHeaders, cookies as getCookies } from "next/headers"; -import { subjects } from "../auth/subjects"; -import { client, setTokens } from "./auth"; - -export async function auth() { - const cookies = await getCookies(); - const accessToken = cookies.get("access_token"); - const refreshToken = cookies.get("refresh_token"); - - if (!accessToken) { - return false; - } - - const verified = await client.verify(subjects, accessToken.value, { - refresh: refreshToken?.value, - }); - - if (verified.err) { - return false; - } - if (verified.tokens) { - await setTokens(verified.tokens.access, verified.tokens.refresh); - } - - return verified.subject; -} - -export async function login() { - const cookies = await getCookies(); - const accessToken = cookies.get("access_token"); - const refreshToken = cookies.get("refresh_token"); - - if (accessToken) { - const verified = await client.verify(subjects, accessToken.value, { - refresh: refreshToken?.value, - }); - if (!verified.err && verified.tokens) { - await setTokens(verified.tokens.access, verified.tokens.refresh); - redirect("/"); - } - } - - const headers = await getHeaders(); - const host = headers.get("host"); - const protocol = host?.includes("localhost") ? "http" : "https"; - const { url } = await client.authorize( - `${protocol}://${host}/api/callback`, - "code", - ); - redirect(url); -} - -export async function logout() { - const cookies = await getCookies(); - cookies.delete("access_token"); - cookies.delete("refresh_token"); - - redirect("/"); -} -``` - -This is adding an `auth` action that checks if a user is authenticated, `login` that starts the OAuth flow, and `logout` that clears the session. - ---- - -##### Add callback route - -When the OpenAuth flow is complete, users will be redirected back to our Next.js app. Let's add a callback route to handle this in `app/api/callback/route.ts`. - -```ts title="app/api/callback/route.ts" -import { client, setTokens } from "../../auth"; -import { type NextRequest, NextResponse } from "next/server"; - -export async function GET(req: NextRequest) { - const url = new URL(req.url); - const code = url.searchParams.get("code"); - - const exchanged = await client.exchange(code!, `${url.origin}/api/callback`); - - if (exchanged.err) return NextResponse.json(exchanged.err, { status: 400 }); - - await setTokens(exchanged.tokens.access, exchanged.tokens.refresh); - - return NextResponse.redirect(`${url.origin}/`); -} -``` - -Once the user is authenticated, we redirect them to the root of our app. - ---- - -## 4. Add auth to app - -Now we are ready to add authentication to our app. Replace the `` component in `app/page.tsx` with the following. - -```tsx title="app/page.tsx" -import { auth, login, logout } from "./actions"; - -export default async function Home() { - const subject = await auth(); - - return ( -
    -
    - Next.js logo -
      - {subject ? ( - <> -
    1. - Logged in as {subject.properties.id}. -
    2. -
    3. - And then check out app/page.tsx. -
    4. - - ) : ( - <> -
    5. Login with your email and password.
    6. -
    7. - And then check out app/page.tsx. -
    8. - - )} -
    - -
    - {subject ? ( -
    - -
    - ) : ( -
    - -
    - )} -
    -
    -
    - ); -} -``` - -Let's also add these styles to `app/page.module.css`. - -```css title="app/page.module.css" -.ctas button { - appearance: none; - background: transparent; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -button.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -button.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} -``` - ---- - -#### Test your app - -Head to `http://localhost:3000` and click the login button, you should be redirected to the OpenAuth server asking you to put in your email. - -If you check the **Functions** tab in your `sst dev` session, you'll see the code being console logged. You can use this code to login. - -Next.js app login with OpenAuth - -This should log you in and print your user ID. - ---- - -## 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -```bash -βœ“ Complete - MyAuth: https://vp3honbl3od4gmo7mei37mchky0waxew.lambda-url.us-east-1.on.aws - MyWeb: https://d2fjg1rqbqi95t.cloudfront.net -``` - -Congrats! Your app and your OpenAuth server should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -SST Console Autodeploy - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. - diff --git a/www/src/content/docs/docs/start/aws/bun.mdx b/www/src/content/docs/docs/start/aws/bun.mdx deleted file mode 100644 index 7b8ff1c96f..0000000000 --- a/www/src/content/docs/docs/start/aws/bun.mdx +++ /dev/null @@ -1,302 +0,0 @@ ---- -title: Bun on AWS with SST -description: Create and deploy a Bun app to AWS with SST. ---- - -We are going to build an app with Bun, add an S3 Bucket for file uploads, and deploy it to AWS in a container with SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-bun) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -#### Examples - -We also have a few other Bun examples that you can refer to. - -- [Deploy Bun with Elysia in a container](/docs/examples/#aws-bun-elysia-container) -- [Build a hit counter with Bun and Redis](/docs/examples/#aws-bun-redis) - ---- - -## 1. Create a project - -Let's start by creating our Bun app. - -```bash -mkdir aws-bun && cd aws-bun -bun init -y -``` - ---- - -#### Init Bun Serve - -Replace your `index.ts` with the following. - -```js title="index.ts" -const server = Bun.serve({ - async fetch(req) { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - return new Response("Hello World!"); - } - - return new Response("404!"); - }, -}); - -console.log(`Listening on ${server.url}`); -``` - -This starts up an HTTP server by default on port `3000`. - ---- - -#### Add scripts - -Add the following to your `package.json`. - -```json title="package.json" -"scripts": { - "dev": "bun run --watch index.ts" -}, -``` - -This adds a `dev` script with a watcher. - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -bunx sst init -bun install -``` - -This'll create an `sst.config.ts` file in your project root and install SST. - ---- - -## 2. Add a Service - -To deploy our Bun app, let's add an [AWS Fargate](https://aws.amazon.com/fargate/) container with [Amazon ECS](https://aws.amazon.com/ecs/). Update your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - }); -} -``` - -This creates a VPC with an ECS Cluster, and adds a Fargate service to it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Bun app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Bun app. - -```bash -bun sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Bun app in your browser. - ---- - -## 3. Add an S3 Bucket - -Let's add an S3 Bucket for file uploads. Add this to your `sst.config.ts` below the `Vpc` component. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -``` - ---- - -#### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Bun app. - ---- - -## 4. Upload a file - -We want a `POST` request made to the `/` route to upload a file to our S3 bucket. Let's add this below our _Hello World_ route in our `index.ts`. - -```ts title="index.ts" {5} -if (url.pathname === "/" && req.method === "POST") { - const formData = await req.formData(); - const file = formData.get("file")! as File; - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return new Response("File uploaded successfully."); -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the imports. We'll use the extra ones below. - -```ts title="index.ts" -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); -``` - -And install the npm packages. - -```bash -bun install @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner -``` - ---- - -## 5. Download the file - -We'll add a `/latest` route that'll download the latest file in our S3 bucket. Let's add this below our upload route in `index.ts`. - -```ts title="index.ts" -if (url.pathname === "/latest" && req.method === "GET") { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return Response.redirect(await getSignedUrl(s3, command)); -} -``` - ---- - -#### Test your app - -To upload a file run the following from your project root. - -```bash -curl -F file=@package.json http://localhost:3000/ -``` - -This should upload the `package.json`. Now head over to `http://localhost:3000/latest` in your browser and it'll show you what you just uploaded. - -![SST Bun app file upload](../../../../../assets/docs/start/start-bun-app-file-upload.png) - ---- - -## 6. Deploy your app - -To deploy our app we'll first add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM oven/bun - -COPY bun.lock . -COPY package.json . - -RUN bun install --frozen-lockfile - -COPY . . - -EXPOSE 3000 -CMD ["bun", "index.ts"] -``` - -This is a pretty basic setup. You can refer to the [Bun docs](https://bun.sh/guides/ecosystem/docker) for a more optimized Dockerfile. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -.git -.gitignore -README.md -Dockerfile* -``` - -Now to build our Docker image and deploy we run: - -```bash -bun sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. This'll give the URL of your Bun app deployed as a Fargate service. - -```bash -βœ“ Complete - MyService: http://prod-MyServiceLoadBalanc-491430065.us-east-1.elb.amazonaws.com -``` - -Congrats! Your app should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/deno.mdx b/www/src/content/docs/docs/start/aws/deno.mdx deleted file mode 100644 index f1f7d309be..0000000000 --- a/www/src/content/docs/docs/start/aws/deno.mdx +++ /dev/null @@ -1,268 +0,0 @@ ---- -title: Deno on AWS with SST -description: Create and deploy a Deno app to AWS with SST. ---- - -We are going to build an app with Deno, add an S3 Bucket for file uploads, and deploy it to AWS in a container with SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-deno) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -#### Examples - -We also have a few other Deno examples that you can refer to. - -- [Build a hit counter with Deno and Redis](/docs/examples/#aws-deno-redis) - ---- - -## 1. Create a project - -Let's start by creating our Deno app. - -```bash -deno init aws-deno -``` - ---- - -#### Init Deno Serve - -Replace your `main.ts` with the following. - -```ts title="main.ts" -Deno.serve(async (req) => { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - return new Response("Hello World!"); - } - - return new Response("404!"); -}); -``` - -This starts up an HTTP server by default on port `8000`. - ---- - -#### Init SST - -Make sure you have [SST installed globally](/docs/reference/cli). - -```bash -sst init -``` - -This'll create an `sst.config.ts` file in your project root. - ---- - -## 2. Add a Service - -To deploy our Deno app, let's add an [AWS Fargate](https://aws.amazon.com/fargate/) container with [Amazon ECS](https://aws.amazon.com/ecs/). Update your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "8000/http" }], - }, - dev: { - command: "deno task dev", - }, - }); -} -``` - -This creates a VPC with an ECS Cluster, and adds a Fargate service to it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Deno app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Deno app. - -```bash -sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Deno app in your browser. - ---- - -## 3. Add an S3 Bucket - -Let's add an S3 Bucket for file uploads. Add this to your `sst.config.ts` below the `Vpc` component. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -``` - ---- - -#### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Deno app. - ---- - -## 4. Upload a file - -We want a `POST` request made to the `/` route to upload a file to our S3 bucket. Let's add this below our _Hello World_ route in our `main.ts`. - -```ts title="main.ts" {6} -if (url.pathname === "/" && req.method === "POST") { - const formData: FormData = await req.formData(); - const file: File | null = formData?.get("file") as File; - - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return new Response("File uploaded successfully."); -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the imports. We'll use the extra ones below. - -```ts title="main.ts" -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); -``` - -And install the npm packages. - -```bash -deno install npm:sst npm:@aws-sdk/client-s3 npm:@aws-sdk/lib-storage npm:@aws-sdk/s3-request-presigner -``` - ---- - -## 5. Download the file - -We'll add a `/latest` route that'll download the latest file in our S3 bucket. Let's add this below our upload route in `main.ts`. - -```ts title="main.ts" -if (url.pathname === "/latest" && req.method === "GET") { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return Response.redirect(await getSignedUrl(s3, command)); -} -``` - ---- - -#### Test your app - -To upload a file run the following from your project root. You might have to go to the `MyService` tab in the sidebar and accept the Deno permission prompts. - -```bash -curl -F file=@deno.json http://localhost:8000/ -``` - -This should upload the `deno.json`. Now head over to `http://localhost:8000/latest` in your browser and it'll show you what you just uploaded. - ---- - -## 5. Deploy your app - -To deploy our app we'll first add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM denoland/deno - -EXPOSE 8000 - -USER deno - -WORKDIR /app - -ADD . /app - -RUN deno install --entrypoint main.ts - -CMD ["run", "--allow-all", "main.ts"] -``` - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Now to build our Docker image and deploy we run: - -```bash -sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. This'll give the URL of your Deno app deployed as a Fargate service. - -```bash -βœ“ Complete - MyService: http://prod-MyServiceLoadBalanc-491430065.us-east-1.elb.amazonaws.com -``` - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/drizzle.mdx b/www/src/content/docs/docs/start/aws/drizzle.mdx deleted file mode 100644 index 1bc7e09775..0000000000 --- a/www/src/content/docs/docs/start/aws/drizzle.mdx +++ /dev/null @@ -1,350 +0,0 @@ ---- -title: Drizzle with Amazon RDS and SST -description: Use Drizzle and SST to manage and deploy your Amazon Postgres RDS database. ---- - -You can use SST to deploy an Amazon Postgres RDS database and set up [Drizzle ORM](https://orm.drizzle.team) and [Drizzle Kit](https://orm.drizzle.team/docs/kit-overview) to manage it. - - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-drizzle) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -#### Examples - -We also have a few other Drizzle and Postgres examples that you can refer to. - -- [Run migrations in your CI/CD pipeline](/docs/examples/#drizzle-migrations-in-cicd) -- [Run Postgres in a local Docker container for dev](/docs/examples/#aws-postgres-local) -- [Use Next.js, Postgres, and Drizzle with the T3 Stack](/docs/examples/#t3-stack-in-aws) - ---- - -## 1. Create a project - -Let's start by creating a Node.js app. - -```bash -mkdir aws-drizzle && cd aws-drizzle -npm init -y -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -#### Init Drizzle - -Add Drizzle to your project. We're also adding the `pg` client that Drizzle will use. - -```bash -npm install pg @types/pg drizzle-orm drizzle-kit -``` - -Drizzle ORM is what will be used to query our database, while Drizzle Kit will allow us to run migrations. It also comes with Drizzle Studio, a query browser. - -Let's add the following to the `scripts` in the `package.json`. - -```json title="package.json" "sst shell" -"scripts": { - "db": "sst shell drizzle-kit" -}, -``` - -The `sst shell` CLI will pass the credentials to Drizzle Kit and allow it to connect to your database. - -Let's also update our `tsconfig.json`. - -```json title="tsconfig.json" -{ - "compilerOptions": { - "strict": true - } -} -``` - ---- - -## 2. Add a Postgres db - -Let's add a Postgres database using [Amazon RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html). This needs a VPC. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); -}, -``` - -The `proxy` option configures an RDS Proxy behind the scenes making it ideal for serverless applications. - -:::tip -The RDS Proxy allows serverless environments to reliably connect to RDS. -::: - -While the `bastion` option will let us connect to the VPC from our local machine. We also need the NAT gateway for this example since we'll be using a Lambda function, and this allows a Lambda function that's in a VPC to access the internet. - ---- - -#### Start Drizzle Studio - -When you run SST in dev it can start other dev processes for you. In this case we want to start Drizzle Studio. Add this below the `Postgres` component. - -```ts title="sst.config.ts" -new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, -}); -``` - -This will run the given command in dev. - ---- - -#### Add an API - -We'll use a Lambda function as an API to query our database. Add the following to your `sst.config.ts` below the database config. - -```ts title="sst.config.ts" {4} -new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - handler: "src/api.handler", -}); -``` - -We are linking our database to the API. - ---- - -#### Install a tunnel - -Since our database cluster is in a VPC, we'll need a tunnel to connect to it from our local machine. - -```bash "sudo" -sudo npx sst tunnel install -``` - -This needs _sudo_ to create a network interface on your machine. You'll only need to do this once on your machine. - ---- - -#### Start dev mode - -Start your app in dev mode. This runs your functions [_Live_](/docs/live/). - -```bash -npx sst dev -``` - -It'll take a few minutes to create your database. Once complete, you'll see this. - -```bash frame="none" -βœ“ Complete - MyApi: https://ouu5vovpxllyn5b6ot2nn6vdsa0hvcuj.lambda-url.us-east-1.on.aws -``` - -You'll see Drizzle Studio started in a tab called **Studio**. And a tunnel in the **Tunnel** tab. - ---- - -## 3. Create a schema - -Let's define our Drizzle config. Add a `drizzle.config.ts` in your project root with this. - -```ts title="drizzle.config.ts" {6-8} -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - // Pick up all our schema files - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, -}); -``` - -Here we are telling Drizzle that we'll be specifying your database schema in `.sql.ts` files in our `src/` directory. - -:::tip -SST allows us to automatically access our database with `Resource.MyPostgres.*`. -::: - -We are going to create a simple database to store some todos. Create a new file in `src/todo.sql.ts` with the following. - -```ts title="src/todo.sql.ts" -import { text, serial, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); -``` - ---- - -## 4. Generate a migration - -We can use this to generate a migration. - -```bash -npm run db generate -``` - -This in turn runs `sst shell drizzle-kit generate` and creates a new migration in the `migrations/` directory. - ---- - -#### Apply the migration - -Now we can apply our migration using. - -```bash -npm run db migrate -``` - -This should create our new schema. - -:::tip -You need a tunnel to connect to your database. -::: - -This needs the tunnel to connect to the database. So you should have `sst dev` in a separate terminal. - -```bash "sudo" -npx sst tunnel -``` - -Alternatively, you can just run the tunnel using the above command. - ---- - -#### Drizzle Studio - -To see our schema in action we can open the Drizzle Studio. Head over to the **Studio** tab in your `sst dev` session and go to the link. - -Or head over to `https://local.drizzle.studio` in your browser. - -![Initial Drizzle Studio with SST](../../../../../assets/docs/start/initial-drizzle-studio-with-sst.png) - - ---- - -## 5. Query the database - -To use Drizzle ORM to query our database, create a new `src/drizzle.ts` config file with the following. - -```ts title="src/drizzle.ts" -import { drizzle } from "drizzle-orm/node-postgres"; -import { Pool } from "pg"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); -``` - -Now we can use that in the API. Create our API handler in `src/api.ts`. - -```ts title="src/api.ts" -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; -``` - -For _POST_ requests we create a new todo and for _GET_ requests we simply print out all our todos. - ---- - -#### Test your app - -To test our app, make a _POST_ request to our API. - -```bash -curl -X POST https://ouu5vovpxllyn5b6ot2nn6vdsa0hvcuj.lambda-url.us-east-1.on.aws -``` - -Now if you head over to `https://ouu5vovpxllyn5b6ot2nn6vdsa0hvcuj.lambda-url.us-east-1.on.aws` in your browser, you'll see that a todo has been added. - -![Todo created with Drizzle in SST](../../../../../assets/docs/start/todo-created-with-drizzle-in-sst.png) - -You should see this in the Drizzle Studio as well. - ---- - -## 6. Deploy your app - -Finally, let's deploy your app. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/email.mdx b/www/src/content/docs/docs/start/aws/email.mdx deleted file mode 100644 index 71cdfe31b2..0000000000 --- a/www/src/content/docs/docs/start/aws/email.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -title: Send emails in AWS with SST -description: Send emails from your API in AWS with SST. ---- - -We are going to build a simple SST app in AWS with a serverless API, and send emails from it. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-email) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -## 1. Create a project - -Let's start by creating our app. - -```bash -mkdir my-email-app && cd my-email-app -npm init -y -``` - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -## 2. Add email - -Let's add Email to our app, it uses [Amazon SES](https://aws.amazon.com/ses/) behind the scenes. Update your `sst.config.ts`. - -```js title="sst.config.ts" {3} -async run() { - const email = new sst.aws.Email("MyEmail", { - sender: "email@example.com", - }); -} -``` - -SES can send emails from a verified email address or domain. To keep things simple we'll be sending from an email. Make sure to use your email address here as we'll be verifying it in the next step. - ---- - -## 3. Add an API - -Next let's create a simple API that'll send out an email when invoked. Add this to your `sst.config.ts`. - -```js title="sst.config.ts" {3} -const api = new sst.aws.Function("MyApi", { - handler: "sender.handler", - link: [email], - url: true, -}); - -return { - api: api.url, -}; -``` - -We are linking the our email component to our API. - ---- - -#### Start dev mode - -Start your app in dev mode. This runs your functions [_Live_](/docs/live/). - -```bash -npx sst dev -``` - -This will give you your API URL. - -```bash frame="none" -+ Complete - api: https://wwwrwteda6kbpquppdz5i3lg4a0nvmbf.lambda-url.us-east-1.on.aws/ -``` - -You should also get an email asking you to verify the sender email address. - -![Verify your email with SST](../../../../../assets/docs/start/verify-your-email-with-sst.png) - -Click the link to verify your email address. - ---- - -## 4. Send an email - -We'll use the SES client to send an email when the API is invoked. Create a new `sender.ts` file and add the following to it. - -```ts title="sender.ts" {4} -export const handler = async () => { - await client.send( - new SendEmailCommand({ - FromEmailAddress: Resource.MyEmail.sender, - Destination: { - ToAddresses: [Resource.MyEmail.sender], - }, - Content: { - Simple: { - Subject: { - Data: "Hello World!", - }, - Body: { - Text: { - Data: "Sent from my SST app.", - }, - }, - }, - }, - }) - ); - - return { - statusCode: 200, - body: "Sent!" - }; -}; -``` - -We are sending an email to the same verified email that we are sending from because your SES account might be in _sandbox_ mode and can only send to verified emails. We'll look at how to go to production below. - -:::tip -We are accessing our email service with `Resource.Email.sender`. -::: - -Add the imports. - -```ts title="sender.ts" -import { Resource } from "sst"; -import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; - -const client = new SESv2Client(); -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-sesv2 -``` - ---- - -#### Test your app - -To test our app, hit the API. - -```bash -curl https://wwwrwteda6kbpquppdz5i3lg4a0nvmbf.lambda-url.us-east-1.on.aws -``` - -This should print out `Sent!` and you should get an email. You might have to check your spam folder since the sender and receiver email address is the same in this case. - -![Email sent from SST](../../../../../assets/docs/start/email-sent-from-sst.png) - ---- - -## 5. Deploy your app - -Now let's deploy your app. - - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Next, for production you can: - -1. [Request production access](https://docs.aws.amazon.com/ses/latest/dg/request-production-access.html) for SES -2. And [use your domain](/docs/component/aws/email/) to send emails - -This'll let you send emails from your domain to any email address. - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/express.mdx b/www/src/content/docs/docs/start/aws/express.mdx deleted file mode 100644 index 0b68c3365a..0000000000 --- a/www/src/content/docs/docs/start/aws/express.mdx +++ /dev/null @@ -1,284 +0,0 @@ ---- -title: Express on AWS with SST -description: Create and deploy an Express app to AWS with SST. ---- - -We are going to build an app with Express, add an S3 Bucket for file uploads, and deploy it to AWS in a container with SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-express) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -#### Examples - -We also have a few other Express examples that you can refer to. - -- [Build a hit counter with Express and Redis](/docs/examples/#aws-express-redis) -- [Use service discovery to connect to your Express app](/docs/examples/#aws-cluster-service-discovery) - ---- - -## 1. Create a project - -Let's start by creating our Express app. - -```bash -mkdir aws-express && cd aws-express -npm init -y -npm install express -``` - ---- - -#### Init Express - -Create your app by adding an `index.mjs` to the root. - -```js title="index.mjs" -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", (req, res) => { - res.send("Hello World!") -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -This'll create a `sst.config.ts` file in your project root. - ---- - -## 2. Add a Service - -To deploy our Express app, let's add an [AWS Fargate](https://aws.amazon.com/fargate/) container with [Amazon ECS](https://aws.amazon.com/ecs/). Update your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); -} -``` - -This creates a VPC with an ECS Cluster, and adds a Fargate service to it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Express app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Express app. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Express app in your browser. - ---- - -## 3. Add an S3 Bucket - -Let's add an S3 Bucket for file uploads. Add this to your `sst.config.ts` below the `Vpc` component. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -``` - ---- - -#### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Express app. - ---- - -## 4. Upload a file - -We want a `POST` request made to the `/` route to upload a file to our S3 bucket. Let's add this below our _Hello World_ route in our `index.mjs`. - -```js title="index.mjs" {4} -app.post("/", upload.single("file"), async (req, res) => { - const file = req.file; - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.mimetype, - Key: file.originalname, - Body: file.buffer, - }; - - const upload = new Upload({ - params, - client: s3, - }); - - await upload.done(); - - res.status(200).send("File uploaded successfully."); -}); -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the imports. We'll use the extra ones below. - -```js title="index.mjs" -import multer from "multer"; -import { Resource } from "sst"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client({}); -const upload = multer({ storage: multer.memoryStorage() }); -``` - -And install the npm packages. - -```bash -npm install multer @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner -``` - ---- - -## 5. Download the file - -We'll add a `/latest` route that'll download the latest file in our S3 bucket. Let's add this below our upload route in `index.mjs`. - -```js title="index.mjs" -app.get("/latest", async (req, res) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents.sort( - (a, b) => b.LastModified - a.LastModified, - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(s3, command); - - res.redirect(url); -}); -``` - ---- - -#### Test your app - -To upload a file run the following from your project root. - -```bash -curl -F file=@package.json http://localhost:80/ -``` - -This should upload the `package.json`. Now head over to `http://localhost:80/latest` in your browser and it'll show you what you just uploaded. - ---- - -## 5. Deploy your app - -To deploy our app we'll first add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM node:lts-alpine - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] -``` - -This just builds our Express app in a Docker image. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. This'll give the URL of your Express app deployed as a Fargate service. - -```bash -βœ“ Complete - MyService: http://jayair-MyServiceLoadBala-592628062.us-east-1.elb.amazonaws.com -``` - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/hono.mdx b/www/src/content/docs/docs/start/aws/hono.mdx deleted file mode 100644 index 49d56e27c6..0000000000 --- a/www/src/content/docs/docs/start/aws/hono.mdx +++ /dev/null @@ -1,491 +0,0 @@ ---- -title: Hono on AWS with SST -description: Create and deploy a Hono API in AWS with SST. ---- - -There are two ways to deploy a [Hono](https://hono.dev) app to AWS with SST. - -1. [Serverless](#serverless) -2. [Containers](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -#### Examples - -We also have a few other Hono examples that you can refer to. - -- [Enabling streaming in your Hono app](/docs/examples/#aws-hono-streaming) -- [Hit counter with Redis and Hono in a container](/docs/examples/#aws-hono-container-with-redis) - ---- - -## Serverless - -We are going to build a serverless Hono API, add an S3 Bucket for file uploads, and deploy it using a Lambda function. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-hono) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npm create hono@latest aws-hono -cd aws-hono -``` - -We are picking the **aws-lambda** template. - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -### 2. Add an API - -Let's add a Hono API using an AWS Lambda. Update your `sst.config.ts`. - -```js title="sst.config.ts" -async run() { - new sst.aws.Function("Hono", { - url: true, - handler: "src/index.handler", - }); -} -``` - -We are enabling the function URL for this. - ---- - -##### Start dev mode - -Start your app in dev mode. This runs your functions [_Live_](/docs/live/). - -```bash -npx sst dev -``` - -This will give you the URL of your API. - -```bash frame="none" -βœ“ Complete - Hono: https://gyrork2ll35rsuml2yr4lifuqu0tsjft.lambda-url.us-east-1.on.aws -``` - ---- - -### 3. Add an S3 Bucket - -Let's add an S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -``` - -##### Link the bucket - -Now, link the bucket to the API. - -```ts title="sst.config.ts" {3} -new sst.aws.Function("Hono", { - url: true, - link: [bucket], - handler: "src/index.handler", -}); -``` - ---- - -### 4. Upload a file - -We want the `/` route of our API to generate a pre-signed URL to upload a file to our S3 Bucket. Replace the _Hello Hono_ route in `src/index.ts`. - -```ts title="src/index.ts" {4} -app.get('/', async (c) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return c.text(await getSignedUrl(s3, command)); -}); -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Then add the relevant imports. We'll use the extra ones below. - -```ts title="src/index.ts" -import { Resource } from 'sst' -import { getSignedUrl } from '@aws-sdk/s3-request-presigner' -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3' - -const s3 = new S3Client(); -``` - ---- - -### 5. Download a file - -We want the `/latest` route of our API to generate a pre-signed URL to download the last uploaded file in our S3 Bucket. Add this to your routes in `src/index.ts`. - -```ts title="src/index.ts" -app.get('/latest', async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return c.redirect(await getSignedUrl(s3, command)); -}); -``` - ---- - -##### Test your app - -Let's try uploading a file from your project root. Make sure to use your API URL. - -```bash -curl --upload-file package.json "$(curl https://gyrork2ll35rsuml2yr4lifuqu0tsjft.lambda-url.us-east-1.on.aws)" -``` - -Now head over to `https://gyrork2ll35rsuml2yr4lifuqu0tsjft.lambda-url.us-east-1.on.aws/latest` in your browser and it'll download the file you just uploaded. - ---- - -### 6. Deploy your app - -Now let's deploy your app. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - ---- - -## Containers - -We are going to create a Hono API, add an S3 Bucket for file uploads, and deploy it in a container with the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-hono-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npm create hono@latest aws-hono-container -cd aws-hono-container -``` - -We are picking the **nodejs** template. - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -### 2. Add a Service - -To deploy our Hono app in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in - - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC, and an ECS Cluster with a Fargate service in it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Hono app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Hono app. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Hono app in your browser. - ---- - -### 3. Add an S3 Bucket - -Let's add an S3 Bucket for file uploads. Add this to your `sst.config.ts` below the `Vpc` component. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -``` - ---- - -##### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Hono app. - ---- - -### 4. Upload a file - -We want a `POST` request made to the `/` route to upload a file to our S3 bucket. Let's add this below our _Hello Hono_ route in our `src/index.ts`. - -```ts title="src/index.ts" {6} -app.post('/', async (c) => { - const body = await c.req.parseBody(); - const file = body['file'] as File; - - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return c.text('File uploaded successfully.'); -}); -``` - -Add the imports. We'll use the extra ones below. - -```tsx title="src/index.ts" -import { Resource } from 'sst' -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3' -import { Upload } from '@aws-sdk/lib-storage' -import { getSignedUrl } from '@aws-sdk/s3-request-presigner' - -const s3 = new S3Client(); -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner -``` - ---- - -### 5. Download the file - -We'll add a `/latest` route that'll download the latest file in our S3 bucket. Let's add this below our upload route in `src/index.ts`. - -```ts title="src/index.ts" -app.get('/latest', async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return c.redirect(await getSignedUrl(s3, command)); -}); -``` - ---- - -#### Test your app - -To upload a file run the following from your project root. - -```bash -curl -F file=@package.json http://localhost:3000/ -``` - -This should upload the `package.json`. Now head over to `http://localhost:3000/latest` in your browser and it'll show you what you just uploaded. - ---- - -### 6. Deploy your app - -To deploy our app we'll first add a `Dockerfile`. This is building our app by running our `build` script from above. - -```diff lang="dockerfile" title="Dockerfile" -FROM node:lts-alpine AS base - -FROM base AS builder -RUN apk add --no-cache gcompat -WORKDIR /app -COPY package*json tsconfig.json src ./ -+ # Copy over generated types -+ COPY sst-env.d.ts* ./ -RUN npm ci && \ - npm run build && \ - npm prune --production - -FROM base AS runner -WORKDIR /app -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 hono -COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules -COPY --from=builder --chown=hono:nodejs /app/dist /app/dist -COPY --from=builder --chown=hono:nodejs /app/package.json /app/package.json - -USER hono -EXPOSE 3000 -CMD ["node", "/app/dist/index.js"] -``` - -This builds our Hono app in a Docker image. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -.git -``` - -To compile our TypeScript file, we'll need add the following to the `tsconfig.json`. - -```diff lang="json" title="tsconfig.json" {4,6} -{ - "compilerOptions": { - // ... -+ "outDir": "./dist" - }, -+ "exclude": ["node_modules"] -} -``` - -Install TypeScript. - -```bash -npm install typescript --save-dev -``` - -And add a `build` script to our `package.json`. - -```diff lang="json" title="package.json" -"scripts": { - // ... -+ "build": "tsc" -} -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. This'll give the URL of your Hono app deployed as a Fargate service. - -```bash -βœ“ Complete - MyService: http://prod-MyServiceLoadBalanc-491430065.us-east-1.elb.amazonaws.com -``` - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/nestjs.mdx b/www/src/content/docs/docs/start/aws/nestjs.mdx deleted file mode 100644 index 53951317f3..0000000000 --- a/www/src/content/docs/docs/start/aws/nestjs.mdx +++ /dev/null @@ -1,283 +0,0 @@ ---- -title: NestJS on AWS with SST -description: Create and deploy an NestJS app to AWS with SST. ---- - -We are going to build an app with NestJS, add an S3 Bucket for file uploads, and deploy it to AWS in a container with SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-nestjs-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - -:::note -You need Node 22.12 or higher for this example to work. -::: - -Also make sure you have Node 22.12. Or set the `--experimental-require-module` flag. This'll allow NestJS to import the SST SDK. - ---- - -#### Examples - -We also have a few other NestJS examples that you can refer to. - -- [Build a hit counter with NestJS and Redis](/docs/examples/#aws-nestjs-with-redis) - ---- - -## 1. Create a project - -Let's start by creating our Nest app. - -```bash -nest new aws-nestjs-container -cd aws-nestjs-container -``` - -We are picking npm as the package manager. - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -This'll create a `sst.config.ts` file in your project root. - -To make sure the types in the `sst.config.ts` are picked up, add the following to the `tsconfig.json`. - -```diff lang="json" title="tsconfig.json" -{ -+ "include": ["src/**/*", "test/**/*", "sst-env.d.ts"] -} -``` - ---- - -## 2. Add a Service - -To deploy our Nest app, let's add an [AWS Fargate](https://aws.amazon.com/fargate/) container with [Amazon ECS](https://aws.amazon.com/ecs/). Update your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run start:dev", - }, - }); -} -``` - -This creates a VPC with an ECS Cluster, and adds a Fargate service to it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Nest app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Nest app. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Nest app in your browser. - ---- - -## 3. Add an S3 Bucket - -Let's add an S3 Bucket for file uploads. Add this to your `sst.config.ts` below the `Vpc` component. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket"); -``` - ---- - -#### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Nest app. - ---- - -## 4. Upload a file - -We want a `POST` request made to the `/` route to upload a file to our S3 bucket. Let's add this below our `getHello` method in our `src/app.controller.ts`. - -```ts title="src/app.controller.ts" {5} -@Post() -@UseInterceptors(FileInterceptor('file')) -async uploadFile(@UploadedFile() file: Express.Multer.File): Promise { - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.mimetype, - Key: file.originalname, - Body: file.buffer, - }; - - const upload = new Upload({ - params, - client: s3, - }); - - await upload.done(); - - return 'File uploaded successfully.'; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the imports. We'll use the extra ones below. - -```ts title="src/app.controller.ts" -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3'; -import { Resource } from 'sst'; -import { Express } from 'express'; -import { Upload } from '@aws-sdk/lib-storage'; -import { FileInterceptor } from '@nestjs/platform-express'; -import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -import { Post, Redirect, UploadedFile, UseInterceptors } from '@nestjs/common'; - -const s3 = new S3Client({}); -``` - -And install the npm packages. - -```bash -npm install -D @types/multer -npm install @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner -``` - ---- - -## 5. Download the file - -We'll add a `/latest` route that'll download the latest file in our S3 bucket. Let's add this below our `uploadFile` method in `src/app.controller.ts`. - -```ts title="src/app.controller.ts" -@Get('latest') -@Redirect('/', 302) -async getLatestFile() { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents.sort( - (a, b) => b.LastModified.getTime() - a.LastModified.getTime(), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(s3, command); - - return { url }; -} -``` - ---- - -#### Test your app - -To upload a file run the following from your project root. - -```bash -curl -F file=@package.json http://localhost:3000/ -``` - -This should upload the `package.json`. Now head over to `http://localhost:3000/latest` in your browser and it'll download you what you just uploaded. - ---- - -## 5. Deploy your app - -To deploy our app we'll first add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM node:22 - -WORKDIR /usr/src/app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build - -EXPOSE 3000 -CMD ["node", "dist/main"] -``` - -This just builds our Nest app in a Docker image. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -dist -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. This'll give the URL of your Nest app deployed as a Fargate service. - -```bash -βœ“ Complete - MyService: http://jayair-MyServiceLoadBala-592628062.us-east-1.elb.amazonaws.com -``` - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. - diff --git a/www/src/content/docs/docs/start/aws/nextjs.mdx b/www/src/content/docs/docs/start/aws/nextjs.mdx deleted file mode 100644 index 3ac69080e4..0000000000 --- a/www/src/content/docs/docs/start/aws/nextjs.mdx +++ /dev/null @@ -1,562 +0,0 @@ ---- -title: Next.js on AWS with SST -description: Create and deploy a Next.js app to AWS with SST. ---- - -import { Image } from "astro:assets" - -import nextApp from "../../../../../assets/docs/start/start-nextjs-local.png" -import nextAppContainer from "../../../../../assets/docs/start/start-nextjs-local-container.png" -import consoleAutodeploy from "../../../../../assets/docs/start/sst-console-autodeploy.png" - -There are two ways to deploy a Next.js app to AWS with SST. - -1. [Serverless with OpenNext](#serverless) -2. [Containers with Docker](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -#### Examples - -We also have a few other Next.js examples that you can refer to. - -- [Adding basic auth to your Next.js app](/docs/examples/#aws-nextjs-basic-auth) -- [Enabling streaming in your Next.js app](/docs/examples/#aws-nextjs-streaming) -- [Add additional routes to the Next.js CDN](/docs/examples/#aws-nextjs-add-behavior) -- [Hit counter with Redis and Next.js in a container](/docs/examples/#aws-nextjs-container-with-redis) - ---- - -## Serverless - -We are going to create a Next.js app, add an S3 Bucket for file uploads, and deploy it using [OpenNext](https://opennext.js.org) and the `Nextjs` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-nextjs) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npx create-next-app@latest aws-nextjs -cd aws-nextjs -``` - -We are picking **TypeScript** and not selecting **ESLint**. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your Next.js app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your Next.js app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `Nextjs` component. - -##### Link the bucket - -Now, link the bucket to our Next.js app. - -```js title="sst.config.ts" {2} -new sst.aws.Nextjs("MyWeb", { - link: [bucket] -}); -``` - ---- - -### 3. Create an upload form - -Add a form client component in `components/form.tsx`. - -```tsx title="components/form.tsx" -"use client"; - -import styles from "./form.module.css"; - -export default function Form({ url }: { url: string }) { - return ( -
    { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
    - ); -} -``` - -Add some styles. - -```css title="components/form.module.css" -.form { - padding: 2rem; - border-radius: 0.5rem; - background-color: var(--gray-alpha-100); -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - background-color: transparent; - font-family: var(--font-geist-sans); - border: 1px solid var(--gray-alpha-200); -} - -.form button:active:enabled { - background-color: var(--gray-alpha-200); -} -``` - ---- - -### 4. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and render the form with it. Replace your `Home` component in `app/page.tsx`. - -```ts title="app/page.tsx" {6} -export const dynamic = "force-dynamic"; - -export default async function Home() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return ( -
    -
    -
    -
    -
    - ); -} -``` - -We need the `force-dynamic` because we don't want Next.js to cache the pre-signed URL. - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```ts title="app/page.tsx" -import { Resource } from "sst"; -import Form from "@/components/form"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - ---- - -#### Test your app - -Head over to the local Next.js app in your browser, `http://localhost:3000` and try **uploading an image**. You should see it upload and then download the image. - -SST Next.js app local - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Containers - -We are going to create a Next.js app, add an S3 Bucket for file uploads, and deploy it in a container with the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-nextjs-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npx create-next-app@latest aws-nextjs-container -cd aws-nextjs-container -``` - -We are picking **TypeScript** and not selecting **ESLint**. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -### 2. Add a Service - -To deploy our Next.js app in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC, and an ECS Cluster with a Fargate service in it. - -:::note -By default, your service is not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Next.js app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Next.js app. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Next.js app in your browser. - ---- - -### 3. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this below the `Vpc` component. - ---- - -##### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Next.js app. - ---- - -### 4. Create an upload form - -Add a form client component in `components/form.tsx`. - -```tsx title="components/form.tsx" -"use client"; - -import styles from "./form.module.css"; - -export default function Form({ url }: { url: string }) { - return ( - { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - - - ); -} -``` - -Add some styles. - -```css title="components/form.module.css" -.form { - padding: 2rem; - border-radius: 0.5rem; - background-color: var(--gray-alpha-100); -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - background-color: transparent; - font-family: var(--font-geist-sans); - border: 1px solid var(--gray-alpha-200); -} - -.form button:active:enabled { - background-color: var(--gray-alpha-200); -} -``` - ---- - -### 5. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and render the form with it. Replace your `Home` component in `app/page.tsx`. - -```ts title="app/page.tsx" {6} -export const dynamic = "force-dynamic"; - -export default async function Home() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return ( -
    -
    -
    -
    -
    - ); -} -``` - -We need the `force-dynamic` because we don't want Next.js to cache the pre-signed URL. - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```ts title="app/page.tsx" -import { Resource } from "sst"; -import Form from "@/components/form"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - ---- - -#### Test your app - -Head over to the local Next.js app in your browser, `http://localhost:3000` and try **uploading an image**. You should see it upload and then download the image. - -SST Next.js app local - ---- - -### 6. Deploy your app - -To build our app for production, we'll enable Next.js's [standalone output](https://nextjs.org/docs/pages/api-reference/next-config-js/output#automatically-copying-traced-files). Let's update our `next.config.mjs`. - -```js title="next.config.ts" {3} -const nextConfig: NextConfig = { - /* config options here */ - output: "standalone" -}; -``` - -Now to deploy our app we'll add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM node:lts-alpine AS base - -# Stage 1: Install dependencies -FROM base AS deps -WORKDIR /app -COPY package.json package-lock.json* ./ -COPY sst-env.d.ts* ./ -RUN npm ci - -# Stage 2: Build the application -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -# If static pages do not need linked resources -RUN npm run build - -# If static pages need linked resources -# RUN --mount=type=secret,id=SST_RESOURCE_MyResource,env=SST_RESOURCE_MyResource \ -# npm run build - -# Stage 3: Production server -FROM base AS runner -WORKDIR /app -ENV NODE_ENV=production -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static - -EXPOSE 3000 -CMD ["node", "server.js"] -``` - -This builds our Next.js app in a Docker image. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -If your Next.js app is building static pages that need linked resources, you can need to declare them in your `Dockerfile`. For example, if we need the linked `MyBucket` component from above. - -```dockerfile -RUN --mount=type=secret,id=SST_RESOURCE_MyBucket,env=SST_RESOURCE_MyBucket npm run build -``` - -You'll need to do this for each linked resource. - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -.git -.next -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -SST Console Autodeploy - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. - diff --git a/www/src/content/docs/docs/start/aws/nuxt.mdx b/www/src/content/docs/docs/start/aws/nuxt.mdx deleted file mode 100644 index efb81011f2..0000000000 --- a/www/src/content/docs/docs/start/aws/nuxt.mdx +++ /dev/null @@ -1,438 +0,0 @@ ---- -title: Nuxt on AWS with SST -description: Create and deploy a Nuxt app to AWS with SST. ---- - -There are two ways to deploy a Nuxt app to AWS with SST. - -1. [Serverless](#serverless) -2. [Containers](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -## Serverless - -We are going to create a Nuxt app, add an S3 Bucket for file uploads, and deploy it using the `Nuxt` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-nuxt) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npx nuxi@latest init aws-nuxt -cd aws-nuxt -``` - -We are picking the **npm** as the package manager. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `nuxt.config.ts` with something like this. - -```diff lang="ts" title="nuxt.config.ts" -export default defineNuxtConfig({ - compatibilityDate: '2024-04-03', -+ nitro: { -+ preset: 'aws-lambda' -+ }, - devtools: { enabled: true } -}) -``` - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your Nuxt app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your Nuxt app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `Nuxt` component. - -##### Link the bucket - -Now, link the bucket to our Nuxt app. - -```ts title="sst.config.ts" {2} -new sst.aws.Nuxt("MyWeb", { - link: [bucket], -}); -``` - ---- - -### 3. Generate a pre-signed URL - -When our app loads, we'll call an API that'll generate a pre-signed URL for the file upload. Create a new `server/api/presigned.ts` with the following. - -```tsx title="server/api/presigned.ts" {4} -export default defineEventHandler(async () => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return await getSignedUrl(new S3Client({}), command); -}) -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```tsx title="src/app.tsx" -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - ---- - -### 4. Create an upload form - -Add a form to upload files to the presigned URL. Replace our `app.vue` with: - -```vue title="app.vue" - - -``` - -Head over to the local app in your browser, `http://localhost:3000` and try **uploading an image**. You should see it upload and then download the image. - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your site should now be live! - -![SST Nuxt app](../../../../../assets/docs/start/start-nuxt.png) - ---- - -## Containers - -We are going to build a hit counter Nuxt app with Redis. We'll deploy it to AWS in a container using the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-nuxt-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npx nuxi@latest init aws-nuxt-container -cd aws-nuxt-container -``` - -We are picking the **npm** as the package manager. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `nuxt.config.ts`. But instead we'll use the **default Node preset**. - -```ts title="nuxt.config.ts" -export default defineNuxtConfig({ - compatibilityDate: '2024-11-01', - devtools: { enabled: true } -}) -``` - ---- - -### 2. Add a Cluster - -To deploy our Nuxt app in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC with a bastion host, an ECS Cluster, and adds a Fargate service to it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Nuxt app locally in dev mode. - ---- - -### 3. Add Redis - -Let's add an [Amazon ElastiCache](https://aws.amazon.com/elasticache/) Redis cluster. Add this below the `Vpc` component in your `sst.config.ts`. - -```js title="sst.config.ts" -const redis = new sst.aws.Redis("MyRedis", { vpc }); -``` - -This shares the same VPC as our ECS cluster. - ---- - -#### Link Redis - -Now, link the Redis cluster to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [redis], -}); -``` - -This will allow us to reference the Redis cluster in our Nuxt app. - ---- - -#### Install a tunnel - -Since our Redis cluster is in a VPC, we'll need a tunnel to connect to it from our local machine. - -```bash "sudo" -sudo npx sst tunnel install -``` - -This needs _sudo_ to create a network interface on your machine. You'll only need to do this once on your machine. - ---- - -#### Start dev mode - -Start your app in dev mode. - -```bash -npx sst dev -``` - -This will deploy your app, start a tunnel in the **Tunnel** tab, and run your Nuxt app locally in the **MyServiceDev** tab. - ---- - -### 4. Connect to Redis - -We want the `/` route to increment a counter in our Redis cluster. Let's start by installing the npm package we'll use. - -```bash -npm install ioredis -``` - -We'll call an API that'll increment the counter when the app loads. Create a new `server/api/counter.ts` with the following. - -```ts title="server/api/counter.ts" {5} -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export default defineEventHandler(async () => { - return await redis.incr("counter"); -}) -``` - -:::tip -We are directly accessing our Redis cluster with `Resource.MyRedis.*`. -::: - -Let's update our component to show the counter. Replace our `app.vue` with: - -```vue title="app.vue" - - - -``` - ---- - -#### Test your app - -Let's head over to `http://localhost:3000` in your browser and it'll show the current hit counter. - -You should see it increment every time you **refresh the page**. - ---- - -### 5. Deploy your app - -To deploy our app we'll add a `Dockerfile`. - -
    -View Dockerfile - -```dockerfile title="Dockerfile" -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] -``` - -
    - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - -![SST Nuxt container app](../../../../../assets/docs/start/start-nuxt-container.png) - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/prisma.mdx b/www/src/content/docs/docs/start/aws/prisma.mdx deleted file mode 100644 index c510207175..0000000000 --- a/www/src/content/docs/docs/start/aws/prisma.mdx +++ /dev/null @@ -1,312 +0,0 @@ ---- -title: Prisma with Amazon RDS and SST -description: Use Prisma and SST to manage and deploy your Amazon Postgres RDS database. ---- - -We are going to use Prisma and SST to deploy an Amazon Postgres RDS database and connect to it from an Express app in a container. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-prisma) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -#### Examples - -We also have a few other Prisma and Postgres examples that you can refer to. - -- [Use Prisma in a Lambda function](/docs/examples/#prisma-in-lambda) -- [Run Postgres in a local Docker container for dev](/docs/examples/#aws-postgres-local) - ---- - -## 1. Create a project - -Let's start by creating a Node.js app. - -```bash -mkdir aws-prisma && cd aws-prisma -npm init -y -``` - -We'll install Prisma, TypeScript, and Express. - -```bash -npm install prisma typescript ts-node @types/node --save-dev -npm install express -``` - -Let's initialize TypeScript and Prisma. - -```bash -npx tsc --init -npx prisma init -``` - -This will create a `prisma` directory with a `schema.prisma`. - ---- - -#### Init Express - -Create your Express app by adding an `index.mjs` to the root. - -```js title="index.mjs" -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", (req, res) => { - res.send("Hello World!") -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -## 2. Add a Postgres db - -Let's add a Postgres database using [Amazon RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html). This needs a VPC. - -```ts title="sst.config.ts" {5} -async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc }); - - const DATABASE_URL = $interpolate`postgresql://${rds.username}:${rds.password}@${rds.host}:${rds.port}/${rds.database}`; -}, -``` - -The `bastion` option will let us connect to the VPC from our local machine. - -We are also building the `DATABASE_URL` variable using the outputs from our RDS database. We'll use this later. - ---- - -#### Start Prisma Studio - -When you run SST in dev it can start other dev processes for you. In this case we want to start Prisma Studio. Add this below the `DATABASE_URL` variable. - -```ts title="sst.config.ts" {2} -new sst.x.DevCommand("Prisma", { - environment: { DATABASE_URL }, - dev: { - autostart: false, - command: "npx prisma studio", - }, -}); -``` - -This will run the given command in dev. - ---- - -## 3. Add a Cluster - -To deploy our Express app, let's add an [AWS Fargate](https://aws.amazon.com/fargate/) container with [Amazon ECS](https://aws.amazon.com/ecs/). Add this at the end of your `sst.config.ts`. - -```ts title="sst.config.ts" {6} -const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - -new sst.aws.Service("MyService", { - cluster, - link: [rds], - environment: { DATABASE_URL }, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, -}); -``` - -This uses the same VPC, and adds an ECS Cluster, with a Fargate service in it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Express app locally in dev mode. - ---- - -#### Install a tunnel - -Since our database cluster is in a VPC, we'll need a tunnel to connect to it from our local machine. - -```bash "sudo" -sudo npx sst tunnel install -``` - -This needs _sudo_ to create a network interface on your machine. You'll only need to do this once on your machine. - ---- - -#### Start dev mode - -Start your app in dev mode. This will take a few minutes. - -```bash -npx sst dev -``` - -It'll deploy your app, start a tunnel in the **Tunnel** tab, run your Express app locally in the **MyServiceDev** tab, and have your Prisma Studio in the **Studio** tab. - -We are setting Prisma Studio to not auto-start since it pops up a browser window. You can start it by clicking on it and hitting _Enter_. - ---- - -## 4. Create a schema - -Let's create a simple schema. Add this to your `schema.prisma`. - -```prisma title="schema.prisma" -model User { - id Int @id @default(autoincrement()) - name String? - email String @unique -} -``` - ---- - -#### Generate a migration - -We'll now generate a migration for this schema and apply it. In a separate terminal run: - -```bash -npx sst shell --target Prisma -- npx prisma migrate dev --name init -``` - -We are wrapping the `prisma migrate dev --name init` command in `sst shell --target Prisma` because we want this command to have access to the `DATABASE_URL` defined in our `sst.config.ts`. - -The `Prisma` target is coming from the `new sst.x.DevCommand("Prisma")` component defined above. - -:::tip -You need a tunnel to connect to your database. -::: - -This needs the tunnel to connect to the database. So you should have `sst dev` in a separate terminal. - -```bash "sudo" -npx sst tunnel -``` - -Alternatively, you can just run the tunnel using the above command. - ---- - -#### Prisma Studio - -To see our schema in action we can open the Prisma Studio. Head over to the **Studio** tab in your `sst dev` session and hit enter to start it. - -![Initial Prisma Studio with SST](../../../../../assets/docs/start/initial-prisma-studio-with-sst.png) - ---- - -## 5. Query the database - -Running the `migrate dev` command also installs the Prisma Client in our project. So let's use that to query our database. - -Replace the `/` route in your `index.mjs` with. - -```ts title="index.mjs" -import { PrismaClient } from '@prisma/client'; - -const prisma = new PrismaClient(); - -app.get("/", async (_req, res) => { - const user = await prisma.user.create({ - data: { - name: "Alice", - email: `alice-${crypto.randomUUID()}@example.com` - }, - }); - res.send(JSON.stringify(user)); -}); -``` - ---- - -#### Test your app - -Let's head over to `http://localhost:80` in your browser and it'll show you the new user that was created. - -![User created with Prisma in SST](../../../../../assets/docs/start/user-created-with-prisma-in-sst.png) - -You should see this in the Prisma Studio as well. - ---- - -## 5. Deploy your app - -To deploy our app we'll first add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json index.mjs prisma /app/ -RUN npm install - -RUN npx prisma generate - -ENTRYPOINT ["node", "index.mjs"] -``` - -This just builds our Express app in a Docker image and runs the `prisma generate` command. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. This'll give the URL of your Express app deployed as a Fargate service. - -```bash -βœ“ Complete - MyService: http://jayair-MyServiceLoadBala-592628062.us-east-1.elb.amazonaws.com -``` - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/react.mdx b/www/src/content/docs/docs/start/aws/react.mdx deleted file mode 100644 index 11acf211c4..0000000000 --- a/www/src/content/docs/docs/start/aws/react.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -title: React Router on AWS with SST -description: Create and deploy a React Router v7 app to AWS with SST. ---- - -We are going to create a React Router v7 app in _Framework mode_, add an S3 Bucket for file uploads, and deploy it to using the `React` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-react-router) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npx create-react-router@latest aws-react-router -cd aws-react-router -``` - -We are picking all the default options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -```ts title="sst.config.ts" -async run() { - new sst.aws.React("MyWeb"); -} -``` - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your React Router app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your React Router app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `React` component. - -##### Link the bucket - -Now, link the bucket to our React Router app. - -```js title="sst.config.ts" {2} -new sst.aws.React("MyWeb", { - link: [bucket], -}); -``` - ---- - -### 3. Create an upload form - -Add the upload form client in `app/routes/home.tsx`. Replace the `Home` component with: - -```tsx title="app/routes/home.tsx" -export default function Home({ - loaderData, -}: Route.ComponentProps) { - const { url } = loaderData; - return ( -
    -
    -

    - Welcome to React Router! -

    - { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - - -
    -
    - ); -} -``` - ---- - -### 4. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and use it in the form. - -Add this above the `Home` component in `app/routes/home.tsx`. - -```tsx title="app/routes/home.tsx" {4} -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```tsx title="app/routes/_index.tsx" -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local React Router app in your browser, `http://localhost:5173` and try **uploading an image**. You should see it upload and then download the image. - -![SST React Router app local](../../../../../assets/docs/start/start-react-router-start-local.png) - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your site should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/realtime.mdx b/www/src/content/docs/docs/start/aws/realtime.mdx deleted file mode 100644 index 33b7f1832d..0000000000 --- a/www/src/content/docs/docs/start/aws/realtime.mdx +++ /dev/null @@ -1,358 +0,0 @@ ---- -title: Realtime apps in AWS with SST -description: Use SST to build and deploy a realtime chat app to AWS. ---- - -We are going to use SST to build and deploy a realtime chat app on AWS. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-realtime-nextjs) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -## 1. Create a project - -Let's start by creating a Node.js app. - -```bash -npx create-next-app@latest my-realtime-app -cd my-realtime-app -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Next.js app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your Next.js app in your browser. - ---- - -## 2. Add Realtime - -Let's add the `Realtime` component and link it to the Next.js app. Update your `sst.config.ts`. - -```js title="sst.config.ts" {7} -async run() { - const realtime = new sst.aws.Realtime("MyRealtime", { - authorizer: "authorizer.handler", - }); - - new sst.aws.Nextjs("MyWeb", { - link: [realtime], - }); -}, -``` - -This component allows us to set up _topics_ that can be subscribed to. The `authorizer` function can be used control who has access to these. - ---- - -#### Add an authorizer - -Add the following to a new `authorizer.ts` file in your project root. - -```ts title="authorizer.ts" -import { Resource } from "sst"; -import { realtime } from "sst/aws/realtime"; - -export const handler = realtime.authorizer(async (token) => { - const prefix = `${Resource.App.name}/${Resource.App.stage}`; - - const isValid = token === "PLACEHOLDER_TOKEN"; - - return isValid - ? { - publish: [`${prefix}/*`], - subscribe: [`${prefix}/*`], - } - : { - publish: [], - subscribe: [], - }; -}); -``` - -Here we are saying that a user with a valid token has access to publish and subscribe to any topic namespaced user the app and stage name. - -:::tip -Namespace your topics with the app and stage name to keep them unique. -::: - -In production, we would validate the given token against our database or auth provider. - ---- - -## 3. Create the chat UI - -Now let's create a chat interface in our app. Create a new component in `components/chat.tsx` with the following. - -```tsx title="components/chat.tsx" {29-33} -"use client"; - -import mqtt from "mqtt"; -import { useState, useEffect } from "react"; -import styles from "./chat.module.css"; - -export default function Chat( - { topic, endpoint, authorizer }: { topic: string, endpoint: string, authorizer: string } -) { - const [messages, setMessages] = useState([]); - const [connection, setConnection] = useState(null); - - return ( -
    - {connection && messages.length > 0 && -
    - {messages.map((msg, i) => ( -
    {JSON.parse(msg).message}
    - ))} -
    - } -
    { - e.preventDefault(); - - const input = (e.target as HTMLFormElement).message; - - connection!.publish( - topic, - JSON.stringify({ message: input.value }), - { qos: 1 } - ); - input.value = ""; - }} - > - - -
    -
    - ); -} -``` - -Here we are going to publish a message that's submitted to the given topic. We'll create the realtime connection below. - -Add some styles. - -```css title="components/chat.module.css" -.chat { - gap: 1rem; - width: 30rem; - display: flex; - padding: 1rem; - flex-direction: column; - border-radius: var(--border-radius); - background-color: rgba(var(--callout-rgb), 0.5); - border: 1px solid rgba(var(--callout-border-rgb), 0.3); -} - -.messages { - padding-bottom: 0.125rem; - border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.3); -} -.messages > div { - line-height: 1.1; - padding-bottom: 0.625rem; -} - -.form { - display: flex; - gap: 0.625rem; -} -.form input { - flex: 1; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - border-radius: calc(1rem - var(--border-radius)); - border: 1px solid rgba(var(--callout-border-rgb), 1); -} -.form button { - font-weight: 500; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - border-radius: calc(1rem - var(--border-radius)); - background: linear-gradient( - to bottom right, - rgba(var(--tile-start-rgb), 1), - rgba(var(--tile-end-rgb), 1) - ); - border: 1px solid rgba(var(--callout-border-rgb), 1); -} -.form button:active:enabled { - background: linear-gradient( - to top left, - rgba(var(--tile-start-rgb), 1), - rgba(var(--tile-end-rgb), 1) - ); -} -``` - -Install the npm package. - -```bash -npm install mqtt -``` - ---- - -#### Add to the page - -Let's use the component in our page. Replace the `Home` component in `app/page.tsx`. - -```tsx title="app/page.tsx" {23-25} -import { Resource } from "sst"; -import Chat from "@/components/chat"; - -const topic = "sst-chat"; - -export default function Home() { - return ( -
    - -
    - Next.js Logo -
    - -
    - -
    - -
    - ); -} -``` - -:::tip -We are directly accessing our Realtime component with `Resource.MyRealtime.*`. -::: - -Here we are going to publish and subscribe to a _topic_ called `sst-chat`, namespaced under the name of the app and the stage our app is deployed to. - ---- - -## 4. Create a connection - -When our chat component loads, it'll create a new connection to our realtime service. Add the following below the imports in `components/chat.tsx`. - -```ts title="components/chat.tsx" -function createConnection(endpoint: string, authorizer: string) { - return mqtt.connect(`wss://${endpoint}/mqtt?x-amz-customauthorizer-name=${authorizer}`, { - protocolVersion: 5, - manualConnect: true, - username: "", // Must be empty for the authorizer - password: "PLACEHOLDER_TOKEN", // Passed as the token to the authorizer - clientId: `client_${window.crypto.randomUUID()}`, - }); -} -``` - -We are using a _placeholder_ token here. In production this might be a user's session token. - -Now let's subscribe to it and save the messages we receive. Add this to the `Chat` component. - -```ts title="components/chat.tsx" -useEffect(() => { - const connection = createConnection(endpoint, authorizer); - - connection.on("connect", async () => { - try { - await connection.subscribeAsync(topic, { qos: 1 }); - setConnection(connection); - } catch (e) { } - }); - connection.on("message", (_fullTopic, payload) => { - const message = new TextDecoder("utf8").decode(new Uint8Array(payload)); - setMessages((prev) => [...prev, message]); - }); - connection.on("error", console.error); - - connection.connect(); - - return () => { - connection.end(); - setConnection(null); - }; -}, [topic, endpoint, authorizer]); -``` - -:::note -If you have a new AWS account, you might have to wait a few minutes before your realtime service is ready to go. -::: - -Head over to the local Next.js app in your browser, `http://localhost:3000` and try **sending a message**, you should see it appear right away. You can also open a new browser window and see them appear in both places. - ---- - -## 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - -![SST Realtime Next.js app](../../../../../assets/docs/start/sst-realtime-nextjs-app.png) - -Next you can: - -- Let users create chat rooms -- Save them to a database -- Only show messages from the right chat rooms - -This'll help you build realtime apps for production. - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/remix.mdx b/www/src/content/docs/docs/start/aws/remix.mdx deleted file mode 100644 index 964a1566ca..0000000000 --- a/www/src/content/docs/docs/start/aws/remix.mdx +++ /dev/null @@ -1,489 +0,0 @@ ---- -title: Remix on AWS with SST -description: Create and deploy a Remix app to AWS with SST. ---- - -There are two ways to deploy a Remix app to AWS with SST. - -1. [Serverless](#serverless) -2. [Containers](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -#### Examples - -We also have a few other Remix examples that you can refer to. - -- [Enabling streaming in your Remix app](/docs/examples/#aws-remix-streaming) -- [Hit counter with Redis and Remix in a container](/docs/examples/#aws-remix-container-with-redis) - ---- - -## Serverless - -We are going to create a Remix app, add an S3 Bucket for file uploads, and deploy it to using the `Remix` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-remix) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npx create-remix@latest aws-remix -cd aws-remix -``` - -We are picking all the default options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your Remix app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your Remix app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `Remix` component. - -##### Link the bucket - -Now, link the bucket to our Remix app. - -```js title="sst.config.ts" {2} -new sst.aws.Remix("MyWeb", { - link: [bucket], -}); -``` - ---- - -### 3. Create an upload form - -Add the upload form client in `app/routes/_index.tsx`. Replace the `Index` component with: - -```tsx title="app/routes/_index.tsx" -export default function Index() { - const data = useLoaderData(); - return ( -
    -
    -

    - Welcome to Remix -

    -
    { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(data.url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
    -
    -
    - ); -} -``` - ---- - -### 4. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and use it in the form. - -Add this above the `Index` component in `app/routes/_index.tsx`. - -```tsx title="app/routes/_index.tsx" {4} -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```tsx title="app/routes/_index.tsx" -import { Resource } from "sst"; -import { useLoaderData } from "@remix-run/react"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local Remix app in your browser, `http://localhost:5173` and try **uploading an image**. You should see it upload and then download the image. - -![SST Remix app local](../../../../../assets/docs/start/start-remix-local.png) - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your site should now be live! - ---- - -## Containers - -We are going to create a Remix app, add an S3 Bucket for file uploads, and deploy it in a container with the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-remix-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npx create-remix@latest aws-remix-container -cd aws-remix-container -``` - -We are picking all the default options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -### 2. Add a Service - -To deploy our Remix app in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC, and an ECS Cluster with a Fargate service in it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our Remix app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your Remix app. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your Remix app in your browser. - ---- - -### 3. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this below the `Vpc` component. - ---- - -##### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our Remix app. - ---- - -### 4. Create an upload form - -Add the upload form client in `app/routes/_index.tsx`. Replace the `Index` component with: - -```tsx title="app/routes/_index.tsx" -export default function Index() { - const data = useLoaderData(); - return ( -
    -
    -

    - Welcome to Remix -

    -
    { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(data.url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
    -
    -
    - ); -} -``` - ---- - -### 5. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and use it in the form. - -Add this above the `Index` component in `app/routes/_index.tsx`. - -```tsx title="app/routes/_index.tsx" {4} -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```tsx title="app/routes/_index.tsx" -import { Resource } from "sst"; -import { useLoaderData } from "@remix-run/react"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local Remix app in your browser, `http://localhost:5173` and try **uploading an image**. You should see it upload and then download the image. - -![SST Remix app local](../../../../../assets/docs/start/start-remix-local-container.png) - ---- - -### 6. Deploy your app - -To deploy our app we'll add a `Dockerfile`. - -```dockerfile title="Dockerfile" -FROM node:lts-alpine as base -ENV NODE_ENV production - -# Stage 1: Install all node_modules, including dev dependencies -FROM base as deps -WORKDIR /myapp -ADD package.json ./ -RUN npm install --include=dev - -# Stage 2: Setup production node_modules -FROM base as production-deps -WORKDIR /myapp -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json ./ -RUN npm prune --omit=dev - -# Stage 3: Build the app -FROM base as build -WORKDIR /myapp -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD . . -RUN npm run build - -# Stage 4: Build the production image -FROM base -WORKDIR /myapp -COPY --from=production-deps /myapp/node_modules /myapp/node_modules -COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public -ADD . . - -CMD ["npm", "start"] -``` - -This builds our Remix app in a Docker image. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -.cache -build -public/build -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/solid.mdx b/www/src/content/docs/docs/start/aws/solid.mdx deleted file mode 100644 index c179b27e36..0000000000 --- a/www/src/content/docs/docs/start/aws/solid.mdx +++ /dev/null @@ -1,461 +0,0 @@ ---- -title: SolidStart on AWS with SST -description: Create and deploy a SolidStart app to AWS with SST. ---- - -There are two ways to deploy SolidStart apps to AWS with SST. - -1. [Serverless](#serverless) -2. [Containers](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -#### Examples - -We also have a few other SolidStart examples that you can refer to. - -- [Adding a WebSocket endpoint to SolidStart](/docs/examples/#aws-solidstart-websocket-endpoint) - ---- - -## Serverless - -We are going to create a SolidStart app, add an S3 Bucket for file uploads, and deploy it using the `SolidStart` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-solid) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npm init solid@latest aws-solid-start -cd aws-solid-start -``` - -We are picking the **SolidStart**, **_basic_**, and **_TypeScript_** options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `app.config.ts` with something like this. - -```diff lang="ts" title="app.config.ts" -export default defineConfig({ -+ server: { -+ preset: "aws-lambda", -+ awsLambda: { -+ streaming: true, -+ }, -+ }, -}); -``` - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your SolidStart app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your SolidStart app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `SolidStart` component. - -##### Link the bucket - -Now, link the bucket to our SolidStart app. - -```js title="sst.config.ts" {2} -new sst.aws.SolidStart("MyWeb", { - link: [bucket], -}); -``` - ---- - -### 3. Generate a pre-signed URL - -When our app loads, we'll generate a pre-signed URL for the file upload and use it in our form. Add this below the imports in `src/routes/index.tsx`. - -```ts title="src/routes/index.tsx" {5} -async function presignedUrl() { - "use server"; - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - return await getSignedUrl(new S3Client({}), command); -} - -export const route = { - load: () => presignedUrl(), -}; -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```tsx title="src/app.tsx" -import { Resource } from "sst"; -import { createAsync } from "@solidjs/router"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -``` - -And install the npm packages. - -```bash -npm install @solidjs/router @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - ---- - -### 4. Create an upload form - -Add a form to upload files to the presigned URL. Replace the `Home` component in `src/routes/index.tsx` with: - -```tsx title="src/routes/index.tsx" -export default function Home() { - const url = createAsync(() => presignedUrl()); - - return ( -
    -

    Hello world!

    -
    { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(url() as string, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
    -
    - ); -} -``` - -Head over to the local app in your browser, `http://localhost:3000` and try **uploading an image**. You should see it upload and then download the image. - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your site should now be live! - -![SST SolidStart app](../../../../../assets/docs/start/start-solidstart.png) - ---- - -## Containers - -We are going to build a hit counter SolidStart app with Redis. We'll deploy it to AWS in a container using the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-solid-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npm init solid@latest aws-solid-container -cd aws-solid-container -``` - -We are picking the **SolidStart**, **_basic_**, and **_TypeScript_** options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `app.config.ts`. Instead we'll use the **default Node preset**. - -```ts title="app.config.ts" -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({}); -``` - ---- - -### 2. Add a Cluster - -To deploy our SolidStart app in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC with a bastion host, an ECS Cluster, and adds a Fargate service to it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our SolidStart app locally in dev mode. - ---- - -### 3. Add Redis - -Let's add an [Amazon ElastiCache](https://aws.amazon.com/elasticache/) Redis cluster. Add this below the `Vpc` component in your `sst.config.ts`. - -```js title="sst.config.ts" -const redis = new sst.aws.Redis("MyRedis", { vpc }); -``` - -This shares the same VPC as our ECS cluster. - ---- - -#### Link Redis - -Now, link the Redis cluster to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [redis], -}); -``` - -This will allow us to reference the Redis cluster in our SolidStart app. - ---- - -#### Install a tunnel - -Since our Redis cluster is in a VPC, we'll need a tunnel to connect to it from our local machine. - -```bash "sudo" -sudo npx sst tunnel install -``` - -This needs _sudo_ to create a network interface on your machine. You'll only need to do this once on your machine. - ---- - -#### Start dev mode - -Start your app in dev mode. - -```bash -npx sst dev -``` - -This will deploy your app, start a tunnel in the **Tunnel** tab, and run your SolidStart app locally in the **MyServiceDev** tab. - ---- - -### 4. Connect to Redis - -We want the `/` route to increment a counter in our Redis cluster. Let's start by installing the packages we'll use. - -```bash -npm install ioredis @solidjs/router -``` - -We'll increment the counter when the route loads. Replace your `src/routes/index.tsx` with: - -```ts title="src/routes/index.tsx" {8} -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { createAsync, cache } from "@solidjs/router"; - -const getCounter = cache(async () => { - "use server"; - const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } - ); - - return await redis.incr("counter"); -}, "counter"); - -export const route = { - load: () => getCounter(), -}; -``` - -:::tip -We are directly accessing our Redis cluster with `Resource.MyRedis.*`. -::: - -Let's update our component to show the counter. Add this to your `src/routes/index.tsx`. - -```tsx title="src/routes/index.tsx" -export default function Page() { - const counter = createAsync(() => getCounter()); - - return

    Hit counter: {counter()}

    ; -} -``` - ---- - -#### Test your app - -Let's head over to `http://localhost:3000` in your browser and it'll show the current hit counter. - -You should see it increment every time you **refresh the page**. - ---- - -### 5. Deploy your app - -To deploy our app we'll add a `Dockerfile`. - -
    -View Dockerfile - -```dockerfile title="Dockerfile" -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] -``` - -
    - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - -![SST SolidStart container app](../../../../../assets/docs/start/start-solidstart-container.png) - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/svelte.mdx b/www/src/content/docs/docs/start/aws/svelte.mdx deleted file mode 100644 index c8b889f0bf..0000000000 --- a/www/src/content/docs/docs/start/aws/svelte.mdx +++ /dev/null @@ -1,482 +0,0 @@ ---- -title: SvelteKit on AWS with SST -description: Create and deploy a SvelteKit app to AWS with SST. ---- - -There are two ways to deploy a SvelteKit app to AWS with SST. - -1. [Serverless](#serverless) -2. [Containers](#containers) - -We'll use both to build a couple of simple apps below. - ---- - -#### Examples - -We also have a few other SvelteKit examples that you can refer to. - -- [Hit counter with Redis and SvelteKit in a container](/docs/examples/#aws-sveltekit-container-with-redis) - ---- - -## Serverless - -We are going to create a SvelteKit app, add an S3 Bucket for file uploads, and deploy it using the `SvelteKit` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-svelte-kit) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npx sv create aws-svelte-kit -cd aws-svelte-kit -``` - -We are picking the **_SvelteKit minimal_** and **_Yes, using TypeScript syntax_** options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `svelte.config.mjs` with something like this. - -```diff lang="js" title="svelte.config.mjs" -- import adapter from '@sveltejs/adapter-auto'; -+ import adapter from "svelte-kit-sst"; -``` - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your SvelteKit app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your SvelteKit app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `SvelteKit` component. - -##### Link the bucket - -Now, link the bucket to our SvelteKit app. - -```js title="sst.config.ts" {2} -new sst.aws.SvelteKit("MyWeb", { - link: [bucket] -}); -``` - ---- - -### 3. Create an upload form - -Let's add a file upload form. Replace your `src/routes/+page.svelte`. This will upload a file to a given pre-signed upload URL. - -```svelte title="src/routes/+page.svelte" - - -
    -
    - - -
    -
    -``` - -Add some styles. - -```css title="src/routes/+page.svelte" - -``` - ---- - -### 4. Generate a pre-signed URL - -When our route loads, we'll generate a pre-signed URL for S3 and our form will upload to it. Create a new `src/routes/+page.server.ts` and add the following. - -```ts title="src/routes/+page.server.ts" {5} -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```ts title="src/routes/+page.server.ts" -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local SvelteKit app in your browser, `http://localhost:5173` and try **uploading an image**. You should see it upload and then download the image. - -![SST SvelteKit app local](../../../../../assets/docs/start/start-svelte-kit-local.png) - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Containers - -We are going to create a SvelteKit app, add an S3 Bucket for file uploads, and deploy it in a container with the `Cluster` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-svelte-container) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our project. - -```bash -npx sv create aws-svelte-container -cd aws-svelte-container -``` - -We are picking the **_SvelteKit minimal_** and **_Yes, using TypeScript syntax_** options. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -It'll also ask you to update your `svelte.config.mjs`. But **we'll instead use** the [Node.js adapter](https://kit.svelte.dev/docs/adapter-node) since we're deploying it through a container. - -```bash -npm i -D @sveltejs/adapter-node -``` - -And updating your `svelte.config.js`. - -```diff lang="js" title="svelte.config.mjs" -- import adapter from '@sveltejs/adapter-auto'; -+ import adapter from '@sveltejs/adapter-node'; -``` - ---- - -### 2. Add a Service - -To deploy our SvelteKit app in a container, we'll use [AWS Fargate](https://aws.amazon.com/fargate/) with [Amazon ECS](https://aws.amazon.com/ecs/). Replace the `run` function in your `sst.config.ts`. - -```js title="sst.config.ts" {10-12} -async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); -} -``` - -This creates a VPC, and an ECS Cluster with a Fargate service in it. - -:::note -By default, your service in not deployed when running in _dev_. -::: - -The `dev.command` tells SST to instead run our SvelteKit app locally in dev mode. - ---- - -#### Start dev mode - -Run the following to start dev mode. This'll start SST and your SvelteKit app. - -```bash -npx sst dev -``` - -Once complete, click on **MyService** in the sidebar and open your SvelteKit app in your browser. - ---- - -### 3. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this below the `Vpc` component. - ---- - -##### Link the bucket - -Now, link the bucket to the container. - -```ts title="sst.config.ts" {3} -new sst.aws.Service("MyService", { - // ... - link: [bucket], -}); -``` - -This will allow us to reference the bucket in our SvelteKit app. - ---- - -### 4. Create an upload form - -Let's add a file upload form. Replace your `src/routes/+page.svelte`. This will upload a file to a given pre-signed upload URL. - -```svelte title="src/routes/+page.svelte" - - -
    -
    - - -
    -
    -``` - -Add some styles. - -```css title="src/routes/+page.svelte" - -``` - ---- - -### 5. Generate a pre-signed URL - -When our route loads, we'll generate a pre-signed URL for S3 and our form will upload to it. Create a new `src/routes/+page.server.ts` and add the following. - -```ts title="src/routes/+page.server.ts" {5} -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```ts title="src/routes/+page.server.ts" -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local SvelteKit app in your browser, `http://localhost:5173` and try **uploading an image**. You should see it upload and then download the image. - -![SST SvelteKit app local](../../../../../assets/docs/start/start-svelte-kit-local-container.png) - ---- - -### 6. Deploy your app - -To deploy our app we'll add a `Dockerfile`. - -```diff lang="dockerfile" title="Dockerfile" -FROM node:18.18.0-alpine AS builder - -WORKDIR /app -COPY package*.json . -RUN npm install -COPY . . -RUN npm run build -RUN npm prune --prod - -FROM builder AS deployer - -WORKDIR /app -COPY --from=builder /app/build build/ -COPY --from=builder /app/package.json . -EXPOSE 3000 -ENV NODE_ENV=production -CMD [ "node", "build" ] -``` - -This builds our SvelteKit app in a Docker image. - -:::tip -You need to be running [Docker Desktop](https://www.docker.com/products/docker-desktop/) to deploy your app. -::: - -Let's also add a `.dockerignore` file in the root. - -```bash title=".dockerignore" -.DS_Store -node_modules -``` - -Now to build our Docker image and deploy we run: - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/tanstack.mdx b/www/src/content/docs/docs/start/aws/tanstack.mdx deleted file mode 100644 index 21f49a63ab..0000000000 --- a/www/src/content/docs/docs/start/aws/tanstack.mdx +++ /dev/null @@ -1,261 +0,0 @@ ---- -title: TanStack Start on AWS with SST -description: Create and deploy a TanStack Start app to AWS with SST. ---- - -We are going to create a TanStack Start app, add an S3 Bucket for file uploads, and deploy it using the `TanStackStart` component. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-tanstack-start) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -### 1. Create a project - -Let's start by creating our app. - -```bash -npm create @tanstack/start@latest -``` - -Now use the init wizard to setup your TanStack Start project: -- Name: aws-start-basic -- Tailwind: `` -- Toolchain: `ESLint` -- Deployment Adapter: `Nitro (agnostic)` -- Add-ons: `` -- Examples: none - -This will create a project with the basic options, and Nitro pre-installed for deployments. - ---- - -##### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - -##### Configure Nitro - -We use Nitro to serve our Tanstack Start app on AWS. You will need to add the correct nitro settings to the `vite.config.ts` file. - -```ts title="vite.config.ts" -import { defineConfig } from 'vite' -import { devtools } from '@tanstack/devtools-vite' -import { tanstackStart } from '@tanstack/react-start/plugin/vite' -import viteReact from '@vitejs/plugin-react' -import viteTsConfigPaths from 'vite-tsconfig-paths' -import tailwindcss from '@tailwindcss/vite' -import { nitro } from 'nitro/vite' - -const config = defineConfig({ - plugins: [ - devtools(), - nitro(), - // this is the plugin that enables path aliases - viteTsConfigPaths({ - projects: ['./tsconfig.json'], - }), - tailwindcss(), - tanstackStart(), - viteReact(), - ], - nitro: { - preset: 'aws-lambda', - awsLambda: { - streaming: true - } - } -}) - -export default config -``` - ---- - -##### Start dev mode - -Run the following to start dev mode. This'll start SST and your TanStack Start app. - -```bash -npx sst dev -``` - -Once complete, click on **MyWeb** in the sidebar and open your TanStack Start app in your browser. - ---- - -### 2. Add an S3 Bucket - -Let's allow public `access` to our S3 Bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" -}); -``` - -Add this above the `TanStackStart` component. - -##### Link the bucket - -Now, link the bucket to our TanStack Start app. - -```js title="sst.config.ts" {2} -new sst.aws.TanStackStart("MyWeb", { - link: [bucket] -}); -``` - ---- - -### 3. Create an upload form - -Add a form component in `src/components/Form.tsx`. - -```tsx title="src/components/Form.tsx" -import './Form.css' - -export default function Form({ url }: { url: string }) { - return ( -
    { - e.preventDefault() - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null - - const image = await fetch(url, { - body: file, - method: 'PUT', - headers: { - 'Content-Type': file.type, - 'Content-Disposition': `attachment filename='${file.name}'`, - }, - }) - - window.location.href = image.url.split('?')[0] - }} - > - - -
    - ) -} -``` - -Add some styles. - -```css title="src/components/Form.css" -.form { - padding: 2rem; -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - border: 1px solid rgba(68, 107, 158, 0); - background-color: rgba(68, 107, 158, 0.1); -} - -.form button:active:enabled { - background-color: rgba(68, 107, 158, 0.2); -} -``` - ---- - -### 4. Generate a pre-signed URL - -When our route loads, we'll generate a pre-signed URL for S3 and our form will upload to it. Add a server function and a route loader in `src/routes/index.tsx`. - -```ts title="src/routes/index.tsx" {4} -export const getPresignedUrl = createServerFn().handler(async () => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name - }) - return await getSignedUrl(new S3Client({}), command) -}) - -export const Route = createFileRoute('/')({ - component: RouteComponent, - loader: async () => { - return { url: await getPresignedUrl() } - } -}) - -function RouteComponent() { - const { url } = Route.useLoaderData() - return ( -
    -
    -
    - ) -} -``` - -:::tip -We are directly accessing our S3 bucket with `Resource.MyBucket.name`. -::: - -Add the relevant imports. - -```ts title="src/routes/+page.server.ts" -import { Resource } from 'sst' -import Form from '~/components/Form' -import { createServerFn } from '@tanstack/react-start' -import { createFileRoute } from '@tanstack/react-router' -import { getSignedUrl } from '@aws-sdk/s3-request-presigner' -import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3' -``` - -And install the npm packages. - -```bash -npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner -``` - -Head over to the local TanStack Start app in your browser, `http://localhost:3000` and try **uploading an image**. You should see it upload and then download the image. - -![SST TanStack Start app local](../../../../../assets/docs/start/start-tanstack-start-local.png) - ---- - -### 5. Deploy your app - -Now let's deploy your app to AWS. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - -Congrats! Your app should now be live! - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and view logs from it. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. diff --git a/www/src/content/docs/docs/start/aws/trpc.mdx b/www/src/content/docs/docs/start/aws/trpc.mdx deleted file mode 100644 index 7747ea2503..0000000000 --- a/www/src/content/docs/docs/start/aws/trpc.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -title: tRPC on AWS with SST -description: Create and deploy a tRPC API in AWS with SST. ---- - -We are going to build a serverless [tRPC](https://trpc.io) API, a simple client, and deploy it to AWS using SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/aws-trpc) of this example in our repo. -::: - -Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials). - ---- - -## 1. Create a project - -Let's start by creating our app. - -```bash -mkdir my-trpc-app && cd my-trpc-app -npm init -y -``` - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **AWS**. This'll create a `sst.config.ts` file in your project root. - ---- - -## 2. Add the API - -Let's add two Lambda functions; one for our tRPC server and one that'll be our client. Update your `sst.config.ts`. - -```js title="sst.config.ts" {9} -async run() { - const trpc = new sst.aws.Function("Trpc", { - url: true, - handler: "index.handler", - }); - - const client = new sst.aws.Function("Client", { - url: true, - link: [trpc], - handler: "client.handler", - }); - - return { - api: trpc.url, - client: client.url, - }; -} -``` - -We are linking the server to our client. This will allow us to access the URL of the server in our client. - ---- - -#### Start dev mode - -Start your app in dev mode. This runs your functions [_Live_](/docs/live/). - -```bash -npx sst dev -``` - -This will give you two URLs. - -```bash frame="none" -+ Complete - api: https://gyrork2ll35rsuml2yr4lifuqu0tsjft.lambda-url.us-east-1.on.aws - client: https://3x4y4kg5zv77jeroxsrnjzde3q0tgxib.lambda-url.us-east-1.on.aws -``` - ---- - -## 3. Create the server - -Let's create our tRPC server. Add the following to `index.ts`. - -```ts title="index.ts" -const t = initTRPC - .context>() - .create(); - -const router = t.router({ - greet: t.procedure - .input(z.object({ name: z.string() })) - .query(({ input }) => { - return `Hello ${input.name}!`; - }), -}); - -export type Router = typeof router; - -export const handler = awsLambdaRequestHandler({ - router: router, - createContext: (opts) => opts, -}); -``` - -We are creating a simple method called `greet` that takes a _string_ as an input. - -Add the imports. - -```ts title="index.ts" -import { z } from "zod"; -import { - awsLambdaRequestHandler, - CreateAWSLambdaContextOptions -} from "@trpc/server/adapters/aws-lambda"; -import { initTRPC } from "@trpc/server"; -import { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from "aws-lambda"; -``` - -And install the npm packages. - -```bash -npm install zod @trpc/server@next -``` - ---- - -## 4. Add the client - -Now we'll connect to our server in our client. Add the following to `client.ts`. - -```ts title="client.ts" {4} -const client = createTRPCClient({ - links: [ - httpBatchLink({ - url: Resource.Trpc.url, - }), - ], -}); - -export async function handler() { - return { - statusCode: 200, - body: await client.greet.query({ name: "Patrick Star" }), - }; -} -``` - -:::tip -We are accessing our server with `Resource.Trpc.url`. -::: - -Add the relevant imports. Notice we are importing the _types_ for our API. - -```ts title="index.ts" {2} -import { Resource } from "sst"; -import type { Router } from "./index"; -import { createTRPCClient, httpBatchLink } from "@trpc/client"; -``` - -Install the client npm package. - -```bash -npm install @trpc/client@next -``` - ---- - -#### Test your app - -To test our app, hit the client URL. - -```bash -curl https://3x4y4kg5zv77jeroxsrnjzde3q0tgxib.lambda-url.us-east-1.on.aws -``` - -This will print out `Hello Patrick Star!`. - ---- - -## 5. Deploy your app - -Now let's deploy your app. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. - ---- - -## Connect the console - -As a next step, you can setup the [SST Console](/docs/console/) to _**git push to deploy**_ your app and monitor it for any issues. - -![SST Console Autodeploy](../../../../../assets/docs/start/sst-console-autodeploy.png) - -You can [create a free account](https://console.sst.dev) and connect it to your AWS account. - diff --git a/www/src/content/docs/docs/start/cloudflare/hono.mdx b/www/src/content/docs/docs/start/cloudflare/hono.mdx deleted file mode 100644 index ac07fdd382..0000000000 --- a/www/src/content/docs/docs/start/cloudflare/hono.mdx +++ /dev/null @@ -1,195 +0,0 @@ ---- -title: Hono on Cloudflare with SST -description: Create and deploy a Hono API on Cloudflare with SST. ---- - -We are going to build an API with Hono, add an R2 bucket for file uploads, and deploy it using Cloudflare with SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/cloudflare-hono) of this example in our repo. -::: - -Before you get started, [create your Cloudflare API token](/docs/cloudflare/#credentials). - ---- - -## 1. Create a project - -Let's start by creating our app. - -```bash -mkdir my-hono-api && cd my-hono-api -npm init -y -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **Cloudflare**. This'll create a `sst.config.ts` file in your project root. - ---- - -#### Set the Cloudflare credentials - -Set the token and account ID in your shell or `.env` file. - -```bash -export CLOUDFLARE_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -export CLOUDFLARE_DEFAULT_ACCOUNT_ID=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -``` - ---- - -## 2. Add a Worker - -Let's add a Worker. Update your `sst.config.ts`. - -```js title="sst.config.ts" -async run() { - const hono = new sst.cloudflare.Worker("Hono", { - url: true, - handler: "index.ts", - }); - - return { - api: hono.url, - }; -} -``` - -We are enabling the Worker URL, so we can use it as our API. - ---- - -## 3. Add an R2 Bucket - -Let's add an R2 bucket for file uploads. Update your `sst.config.ts`. - -```ts title="sst.config.ts" -const bucket = new sst.cloudflare.Bucket("MyBucket"); -``` - -Add this above the `Worker` component. - -#### Link the bucket - -Now, link the bucket to our Worker. - -```ts title="sst.config.ts" {3} -const hono = new sst.cloudflare.Worker("Hono", { - url: true, - link: [bucket], - handler: "index.ts", -}); -``` - ---- - -## 4. Upload a file - -We want the `/` route of our API to upload a file to the R2 bucket. Create an `index.ts` file and add the following. - -```ts title="index.ts" {4-8} -const app = new Hono() - .put("/*", async (c) => { - const key = crypto.randomUUID(); - await Resource.MyBucket.put(key, c.req.raw.body, { - httpMetadata: { - contentType: c.req.header("content-type"), - }, - }); - return c.text(`Object created with key: ${key}`); - }); - -export default app; -``` - -:::tip -We are uploading to our R2 bucket with the SDK β€” `Resource.MyBucket.put()` -::: - -Add the imports. - -```ts title="index.ts" -import { Hono } from "hono"; -import { Resource } from "sst"; -``` - -And install the npm packages. - -```bash -npm install hono -``` - ---- - -## 5. Download a file - -We want to download the last uploaded file if you make a `GET` request to the API. Add this to your routes in `index.ts`. - -```ts title="index.ts" -const app = new Hono() - // ... - .get("/", async (c) => { - const first = await Resource.MyBucket.list().then( - (res) => - res.objects.sort( - (a, b) => a.uploaded.getTime() - b.uploaded.getTime(), - )[0], - ); - const result = await Resource.MyBucket.get(first.key); - c.header("content-type", result.httpMetadata.contentType); - return c.body(result.body); - }); -``` - -We are getting a list of the files in the files in the bucket with `Resource.MyBucket.list()` and we are getting a file for the given key with `Resource.MyBucket.get()`. - ---- - -#### Start dev mode - -Start your app in dev mode. - -```bash -npx sst dev -``` - -This will give you the URL of your API. - -```bash frame="none" -βœ“ Complete - Hono: https://my-hono-api-jayair-honoscript.sst-15d.workers.dev -``` - ---- - -#### Test your app - -Let's try uploading a file from your project root. Make sure to use your API URL. - -```bash -curl -X PUT --upload-file package.json https://my-hono-api-jayair-honoscript.sst-15d.workers.dev -``` - -Now head over to `https://my-hono-api-jayair-honoscript.sst-15d.workers.dev` in your browser and it'll load the file you just uploaded. - ---- - -## 6. Deploy your app - -Finally, let's deploy your app! - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. diff --git a/www/src/content/docs/docs/start/cloudflare/trpc.mdx b/www/src/content/docs/docs/start/cloudflare/trpc.mdx deleted file mode 100644 index 08bf0f893c..0000000000 --- a/www/src/content/docs/docs/start/cloudflare/trpc.mdx +++ /dev/null @@ -1,210 +0,0 @@ ---- -title: tRPC on Cloudflare with SST -description: Create and deploy a tRPC API in Cloudflare with SST. ---- - -We are going to build a [tRPC](https://trpc.io) API, a simple client, and deploy it to Cloudflare using SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/cloudflare-trpc) of this example in our repo. -::: - -Before you get started, [create your Cloudflare API token](/docs/cloudflare/#credentials). - ---- - -## 1. Create a project - -Let's start by creating our app. - -```bash -mkdir my-trpc-app && cd my-trpc-app -npm init -y -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **Cloudflare**. This'll create a `sst.config.ts` file in your project root. - ---- - -#### Set the Cloudflare credentials - -You can save your Cloudflare API token in a `.env` file or just set it directly. - -```bash -export CLOUDFLARE_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -export CLOUDFLARE_DEFAULT_ACCOUNT_ID=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -``` - ---- - -## 2. Add the API - -Let's add two Workers; one for our tRPC server and one that'll be our client. Update your `sst.config.ts`. - -```js title="sst.config.ts" {9} -async run() { - const trpc = new sst.cloudflare.Worker("Trpc", { - url: true, - handler: "index.ts", - }); - - const client = new sst.cloudflare.Worker("Client", { - url: true, - link: [trpc], - handler: "client.ts", - }); - - return { - api: trpc.url, - client: client.url, - }; -} -``` - -We are linking the server to our client. This will allow us to access the server in our client. - ---- - -## 3. Create the server - -Let's create our tRPC server. Add the following to `index.ts`. - -```ts title="index.ts" -const t = initTRPC.context().create(); - -const router = t.router({ - greet: t.procedure - .input(z.object({ name: z.string() })) - .query(({ input }) => { - return `Hello ${input.name}!`; - }), -}); - -export type Router = typeof router; - -export default { - async fetch(request: Request): Promise { - return fetchRequestHandler({ - router, - req: request, - endpoint: "/", - createContext: (opts) => opts, - }); - }, -}; -``` - -We are creating a simple method called `greet` that takes a _string_ as an input. - -Add the relevant imports. - -```ts title="index.ts" -import { z } from "zod"; -import { initTRPC } from "@trpc/server"; -import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; -``` - -And install the npm packages. - -```bash -npm install zod @trpc/server@next -``` - ---- - -## 4. Add the client - -Now we'll connect to our server in our client. Add the following to `client.ts`. - -```ts title="client.ts" {8} -export default { - async fetch() { - const client = createTRPCClient({ - links: [ - httpBatchLink({ - url: "http://localhost/", - fetch(req) { - return Resource.Trpc.fetch(req); - }, - }), - ], - }); - return new Response( - await client.greet.query({ - name: "Patrick Star", - }), - ); - }, -}; -``` - -:::tip -We are accessing our server with `Resource.Trpc.fetch()`. -::: - -Add the imports. Notice we are importing the _types_ for our API. - -```ts title="index.ts" {2} -import { Resource } from "sst"; -import type { Router } from "./index"; -import { createTRPCClient, httpBatchLink } from "@trpc/client"; -``` - -Install the client npm package. - -```bash -npm install @trpc/client@next -``` - ---- - -#### Start dev mode - -Start your app in dev mode. - -```bash -npx sst dev -``` - -This will give you two URLs. - -```bash frame="none" -+ Complete - api: https://my-trpc-app-jayair-trpcscript.sst-15d.workers.dev - client: https://my-trpc-app-jayair-clientscript.sst-15d.workers.dev -``` - ---- - -#### Test your app - -To test our app, hit the client URL. - -```bash -curl https://my-trpc-app-jayair-clientscript.sst-15d.workers.dev -``` - -This will print out `Hello Patrick Star!`. - ---- - -## 5. Deploy your app - -Now let's deploy your app. - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. diff --git a/www/src/content/docs/docs/start/cloudflare/worker.mdx b/www/src/content/docs/docs/start/cloudflare/worker.mdx deleted file mode 100644 index d05450a2a5..0000000000 --- a/www/src/content/docs/docs/start/cloudflare/worker.mdx +++ /dev/null @@ -1,190 +0,0 @@ ---- -title: Cloudflare Workers with SST -description: Create and deploy a Cloudflare Worker as an API with SST. ---- - -We are going to build an API with a Cloudflare Worker, add an R2 bucket for file uploads, and deploy it using SST. - -:::tip[View source] -You can [view the source](https://github.com/sst/sst/tree/dev/examples/cloudflare-worker) of this example in our repo. -::: - -Before you get started, [create your Cloudflare API token](/docs/cloudflare/#credentials). - ---- - -## 1. Create a project - -Let's start by creating our app. - -```bash -mkdir my-worker && cd my-worker -npm init -y -``` - ---- - -#### Init SST - -Now let's initialize SST in our app. - -```bash -npx sst@latest init -npm install -``` - -Select the defaults and pick **Cloudflare**. This'll create a `sst.config.ts` file in your project root. - ---- - -#### Set the Cloudflare credentials - -Set the token and account ID in your shell or `.env` file. - -```bash -export CLOUDFLARE_API_TOKEN=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -export CLOUDFLARE_DEFAULT_ACCOUNT_ID=aaaaaaaa_aaaaaaaaaaaa_aaaaaaaa -``` - ---- - -## 2. Add a Worker - -Let's add a Worker. Update your `sst.config.ts`. - -```js title="sst.config.ts" -async run() { - const worker = new sst.cloudflare.Worker("MyWorker", { - handler: "./index.ts", - url: true, - }); - - return { - api: worker.url, - }; -} -``` - -We are enabling the Worker URL, so we can use it as our API. - ---- - -## 3. Add an R2 Bucket - -Let's add an R2 bucket for file uploads. Update your `sst.config.ts`. - -```js title="sst.config.ts" -const bucket = new sst.cloudflare.Bucket("MyBucket"); -``` - -Add this above the `Worker` component. - -#### Link the bucket - -Now, link the bucket to our Worker. - -```ts title="sst.config.ts" {3} -const worker = new sst.cloudflare.Worker("MyWorker", { - handler: "./index.ts", - link: [bucket], - url: true, -}); -``` - ---- - -## 4. Upload a file - -We want our API to upload a file to the R2 bucket if you make a `PUT` request to it. Create an `index.ts` file and add the following. - -```ts title="index.ts" {5-9} -export default { - async fetch(req: Request) { - if (req.method == "PUT") { - const key = crypto.randomUUID(); - await Resource.MyBucket.put(key, req.body, { - httpMetadata: { - contentType: req.headers.get("content-type"), - }, - }); - return new Response(`Object created with key: ${key}`); - } - }, -}; -``` - -:::tip -We are uploading to our R2 bucket with the SDK β€” `Resource.MyBucket.put()` -::: - -Import the SDK. - -```ts title="index.ts" -import { Resource } from "sst"; -``` - ---- - -## 5. Download a file - -We want to download the last uploaded file if you make a `GET` request to the API. Add this to the `fetch` function in your `index.ts` file. - -```ts title="index.ts" -if (req.method == "GET") { - const first = await Resource.MyBucket.list().then( - (res) => - res.objects.toSorted( - (a, b) => a.uploaded.getTime() - b.uploaded.getTime(), - )[0], - ); - const result = await Resource.MyBucket.get(first.key); - return new Response(result.body, { - headers: { - "content-type": result.httpMetadata.contentType, - }, - }); -} -``` - -We are getting a list of the files in the files in the bucket with `Resource.MyBucket.list()` and we are getting a file for the given key with `Resource.MyBucket.get()`. - ---- - -#### Start dev mode - -Start your app in dev mode. - -```bash -npx sst dev -``` - -This will give you the URL of your API. - -```bash frame="none" -+ Complete - api: https://start-cloudflare-jayair-myworkerscript.sst-15d.workers.dev -``` - ---- - -#### Test your app - -Let's try uploading a file from your project root. Make sure to use your API URL. - -```bash -curl --upload-file package.json https://start-cloudflare-jayair-myworkerscript.sst-15d.workers.dev -``` - -Now head over to `https://start-cloudflare-jayair-myworkerscript.sst-15d.workers.dev` in your browser and it'll load the file you just uploaded. - ---- - -## 6. Deploy your app - -Finally, let's deploy your app! - -```bash -npx sst deploy --stage production -``` - -You can use any stage name here but it's good to create a new stage for production. diff --git a/www/src/content/docs/docs/state.mdx b/www/src/content/docs/docs/state.mdx deleted file mode 100644 index aae2984073..0000000000 --- a/www/src/content/docs/docs/state.mdx +++ /dev/null @@ -1,194 +0,0 @@ ---- -title: State -description: Tracking the infrastructure created by your app. ---- - -import VideoAside from "../../../components/VideoAside.astro"; - -When you deploy your app, SST creates a state file locally to keep track of the state of the infrastructure in your app. - -So when you make a change, it'll allow SST to do a diff with the state and only deploy what's changed. - ---- - -The state of your app includes: - -1. A state file for your resources. This is a JSON file. -2. A passphrase that is used to encrypt the secrets in your state. - -Aside from these, SST also creates some other resources when your app is first deployed. We'll look at this below. - ---- - -The state is generated locally but is backed up to your provider using: - -1. A **bucket** to store the state, typically named `sst-state-`. This is created in the region of your `home`. More on this below. -2. An **SSM parameter** to store the passphrase used to encrypt your secrets, under `/sst/passphrase//`. Also created in the region of your `home`. - -:::danger -Do not delete the SSM parameter that stores the passphrase for your app. -::: - -The passphrase is used to encrypt any secrets and sensitive information. Without it SST won't be able to read the state file and deploy your app. - ---- - -## Home - -Your `sst.config.ts` specifies which provider to use for storing your state. We call this the `home` of your app. - -```ts title="sst.config.ts" -{ - home: "aws" -} -``` - -You can specify which provider you'd like to use for this. Currently `aws` and `cloudflare` are supported. - -:::tip -Your state file is uploaded to your `home`. -::: - -When you specify your home provider, SST assumes you'd like to use that provider in your app as well and adds it to your providers internally. So the above is equivalent to doing this. - -```ts title="sst.config.ts" -{ - home: "aws", - providers: { - aws: true - } -} -``` - -This also means that if you change the region of the `aws` provider above, you are changing the region for your `home` as well. - -You can read more about the `home` provider in [Config](/docs/reference/config/). - ---- - -## Bootstrap - -As SST starts deploying the resources in your app, it creates some additional _bootstrap_ resources. If your app has a Lambda function or a Docker container, then SST will create the following in the same region as the given resource: - -1. An assets bucket to store the function packages, typically named `sst-asset-`. -2. An ECR repository to store container images, called `sst-asset`. -3. An SSM parameter to store the assets bucket name and the ECR repository, stored under `/sst/bootstrap`. -4. An AppSync Events API endpoint to power [Live](/docs/live). - -The SSM parameter is used to look up the location of these resources. - -:::tip -Some additional bootstrap resources are created based on what your app is creating. -::: - -When you remove an SST app, it does not remove the _state_ or _bootstrap_ resources. This is because it does not know if there are other apps that might be using this. So if you want to completely remove any SST created resources, you'll need to manually remove these in the regions you've deployed to. - ---- - -### Reset - -If you accidentally remove the bootstrap resources the SST CLI will not be able to start up. - -To fix this you'll need to reset your bootstrap resources. - -1. Remove the resources that are listed in the parameter. For example, the `asset` or `state` bucket. Or the ECR repository. -2. Remove the SSM parameter. - -Now when you run the SST CLI, it'll bootstrap your account again. - ---- - -## How it works - -The state file is a JSON representation of all the low level resources created by your app. It is a cached version of the state of resources in the cloud provider. - - - -So when you do a deploy the following happens. - -1. The components in the `sst.config.ts` get converted into low level resource definitions. These get compared to the the state file. -2. The differences between the two are turned into API calls that are made to your cloud provider. - - If there's a new resource, it gets created. - - If a resource has been removed, it gets removed. - - If there's a change in config of the resource, it gets applied. -3. The state file is updated to reflect the new state of these resources. Now the `sst.config.ts`, the state file, and the resources in the cloud provider are all in sync. - ---- - -### Out of sync - -This process works fine until you manually go change these resources through the cloud provider's console. This will cause the **state and the resources to not be in sync** anymore. This can cause an issue in some cases. - -:::caution -If you manually change the resources in your cloud provider, they will go out of sync with your app's state. -::: - -Let's look at a couple of scenarios. - -Say we've deployed a `Function` with it set to `{ timeout: 10 seconds" }`. At this point, the config, state, and resource are in sync. - ---- - -#### Change the resource - -- We now go change the timeout to 20 seconds in the AWS Console. - - The config and state are out of sync with the resource since they are still set to 10 seconds. -- Now if we deploy our app, the config will be compared to the state. - - It'll find no differences and so it won't update the resource. - -The config and state will stay out of sync with the resource. - ---- - -#### Change the config - -- If we change our config to `{ timeout: 30 seconds" }` and do a deploy. -- The config and state will have some differences. -- SST will make a call to AWS to set the timeout of the resource to 30 seconds. - - Once updated, it'll update the state file to match the current state of the resource. - -The config, state, and resource are back being in sync. - ---- - -#### Remove the resource - -- Next we go to the AWS Console and remove the function. - - The config and state still have the function with the timeout set to 30 seconds. -- If we change our config to `{ timeout: 60 seconds }` and do a deploy. -- The config and state will be different. -- SST will make a call to update the timeout of the resource to 60 seconds. - - But this call to AWS will fail because the function doesn't exist. - -Your deploys will fail moving forward because your state shows that a resource exists but it doesn't anymore. To fix this, you'll need to _refresh_ your state file. - ---- - -### Refresh - -To fix scenarios where the resources in the cloud are out of sync with the state of your app, you'll need to run. - -```bash -sst refresh -``` - -This command does a couple of simple things: - -1. It goes through every single resource in your state. -2. Makes a call to the cloud provider to check the resource. - - If the configs are different, it'll **update the state** to reflect the change. - - If the resource doesn't exist anymore, it'll **remove it from the state**. - -:::note -The `sst refresh` does not make changes to the resources in the cloud provider. -::: - -Now the state and the resources are in sync. So if we take the scenario from above where we removed the function from the AWS Console but not from our config or state. To fix it, we'll need to: - -- Run `sst refresh` - - This will remove the function from the state as well. -- Now if we change our config to `{ timeout: 60 seconds }` and do a deploy. -- The config and state will be compared and it'll find that a function with that config doesn't exist. -- So SST will make a call to AWS to create a new function with the given config. - -In general we do not recommend manually changing resources in a cloud provider since it puts your state out of sync. But if you find yourself in a situation where this happens, you can use the `sst refresh` command to put them back in sync. diff --git a/www/src/content/docs/docs/upgrade-aws-databases.mdx b/www/src/content/docs/docs/upgrade-aws-databases.mdx deleted file mode 100644 index ab24113a3a..0000000000 --- a/www/src/content/docs/docs/upgrade-aws-databases.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: Upgrade AWS Databases -description: How to upgrade your database and minimize downtime. ---- - -Sometimes database components like [`Postgres`](/docs/component/aws/postgres/) and [`Mysql`](/docs/component/aws/mysql/) need to be upgraded as your application scales. - -When you change fields like `version` or `instance`, SST applies the update on the next `sst deploy`. - -By default, AWS performs the upgrade in place. This restarts the database and causes temporary downtime until your application can reconnect. - -This guide covers the different strategies to minimize that downtime. - ---- - -## Multi-AZ - -[`Postgres`](/docs/component/aws/postgres/) and [`Mysql`](/docs/component/aws/mysql/) support Multi-AZ deployments. AWS maintains a standby replica in a different availability zone. During the upgrade, changes are applied to the standby first, then it fails over. This reduces downtime to around 60-120 seconds instead of the full upgrade duration. - -```ts title="sst.config.ts" {4} -const database = new sst.aws.Postgres("MyDatabase", { - vpc, - version: "17", - multiAz: true, -}); -``` - -Multi-AZ roughly doubles the cost since a standby instance is always running. You can enable it temporarily for the upgrade and disable it after. - -:::caution -Major version upgrades restart both instances, making Multi-AZ ineffective for reducing downtime. -::: - -Enabling [RDS Proxy](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html) through the `proxy` property can help further reduce failover downtime by detecting the new primary directly instead of waiting for DNS propagation. This can bring downtime down to just a few seconds. - ---- - -## Blue/Green - -[`Postgres`](/docs/component/aws/postgres/) and [`Mysql`](/docs/component/aws/mysql/) support [AWS RDS Blue/Green deployments](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/blue-green-deployments.html) through the `blueGreen` property. This creates a staging copy of your database, applies the changes there, and switches over with near-zero downtime. - -```ts title="sst.config.ts" {4} -const database = new sst.aws.Postgres("MyDatabase", { - vpc, - version: "17", - blueGreen: true, -}); -``` - -Your database endpoint stays the same throughout, so no application changes are needed. The overall deploy takes significantly longer but actual downtime is near zero. - -:::caution -Blue/Green deployments are not compatible with databases that have read replicas or `proxy` enabled. -::: - -Learn more in [this Pulumi article](https://www.pulumi.com/blog/aws-rds-blue-green-deployment-updates). - ---- - -## Upgrading steps - -Here's the recommended workflow for upgrading a production database. - -### 1. Check compatibility - -Not all version jumps are allowed. You might need to go through intermediate versions. - -- [PostgreSQL upgrade paths](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.PostgreSQL.html) -- [MySQL upgrade paths](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.MySQL.html) -- [Aurora PostgreSQL upgrade paths](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.PostgreSQL.html) -- [Aurora MySQL upgrade paths](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Updates.MajorVersionUpgrade.html) - -### 2. Pick a strategy - -Use in-place if some downtime is fine, Multi-AZ to reduce it, or Blue/Green for the shortest switchover when supported. - -| Component | In-place | Multi-AZ | Blue/Green | -| --- | --- | --- | --- | -| [`Postgres`](/docs/component/aws/postgres/) | βœ“ | βœ“ | βœ“ | -| [`Mysql`](/docs/component/aws/mysql/) | βœ“ | βœ“ | βœ“ | -| [`Aurora`](/docs/component/aws/aurora/) | βœ“ | βœ• | βœ• | -| [`Redis`](/docs/component/aws/redis/) | βœ“ | βœ• | βœ• | -| [`OpenSearch`](/docs/component/aws/open-search/) | βœ“ | βœ• | βœ• | - -### 3. Verify in a test stage - -Apply the change in a test stage first to ensure the upgrade works as expected. - -```diff lang="ts" title="sst.config.ts" - const database = new sst.aws.Postgres("MyDatabase", { - vpc, -- version: "16", -+ version: "17", -+ blueGreen: true, - }); -``` - -### 4. Deploy to production - -Finally, deploy the upgrade to your production stage. - -```ts title="sst.config.ts" -const database = new sst.aws.Postgres("MyDatabase", { - vpc, - version: "17", - blueGreen: true, -}); -``` diff --git a/www/src/content/docs/dummy/markdown.mdx b/www/src/content/docs/dummy/markdown.mdx deleted file mode 100644 index 555130ba8e..0000000000 --- a/www/src/content/docs/dummy/markdown.mdx +++ /dev/null @@ -1,449 +0,0 @@ ---- -title: Markdown -description: A page to test all the markdown content test cases -draft: true ---- - -import { Tabs, TabItem } from '@astrojs/starlight/components'; -import VideoAside from "../../../components/VideoAside.astro"; - - -The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -Starlight builds pages that are as lightweight as possible. For example, on a first visit, a user will download less than 50 KB of compressed data β€” just 2.5% of the HTTP archive median. With a good caching strategy, subsequent navigations can download as little as 10 KB. - -## Typography - -Once you've added a couple of features, SST can help you connect them together. This is great because you won't need to hardcode anything in your app. - -### Links - -Here are some [links](/), [link-b](/), and [a really really long link to look at](/). - -### Paragraph 1 - -Series' creator Stephen Hillenburg first became fascinated with the ocean as a child and began developing his artistic abilities at a young age. Although these interests would not overlap for some timeβ€”the idea of drawing fish seemed boring to himβ€”Hillenburg pursued both during college, majoring in marine biology and minoring in art. After graduating in 1984, he joined the Ocean Institute, an organization in Dana Point, California, dedicated to educating the public about marine science and maritime history. - -### Paragraph 2 - -While Hillenburg was there, his love of the ocean began to influence his artistry. He created a precursor to SpongeBob SquarePants: a comic book titled The Intertidal Zone used by the institute to teach visiting students about the animal life of tide pools. - -Lorem Ipsum is a placeholder text commonly used in the design and printing industries. Despite its widespread use, the origins of Lorem Ipsum are somewhat mysterious. Several theories exist about who may have invented the text, but no one knows. Some people believe that the ancient Greeks or Romans created Lorem Ipsum, while others think a printer in the 16th century invented it. Regardless of who created Lorem Ipsum, it has become an essential tool for designers and typesetters worldwide. - -#### Sub Heading - -A large inspiration to Hillenburg was Ween's 1997 album The Mollusk, which had a nautical and underwater theme. Hillenburg contacted the band shortly after the album's release, explaining the baseline ideas for SpongeBob SquarePants, and also requested a song from the band, which they sent on Christmas Eve. This song was "Loop de Loop", which was used in the episode "Your Shoe's Untied". - -Lorem Ipsum is a placeholder text that designers and publishers often use to fill space until the content is ready. It has been used for centuries in the printing industry, and its origins can be traced back to the 16th century when a printer named Aldus Manutius created a type specimen book that included a passage of dummy text. The text was based on the works of Cicero, a Roman philosopher and orator, and it has been used ever since as a standard placeholder text. Despite its long history, the exact origins of Lorem Ipsum are still somewhat unclear. - -The text comprises words and phrases that have been scrambled and rearranged, making it appear as if it is real text without any actual meaning. It may not have any particular significance, but it does serve a useful purpose in helping designers to visualize how their designs will look with text in place. - -#### Sub Heading - -Derek Drymon, who served as creative director for the first three seasons, has said that Hillenburg wanted to surround himself with a "team of young and hungry people." - -## Colors - -The series features "sky flowers" as a main setting material. - -Text can be **bold**, _italic_, or ~~strikethrough~~. - -Line normal text color. - -

    Line secondary text color.

    - -

    Line dimmed text color.

    - -Normal secondary dimmed - -## Code - -Let's test some code. - -### Inline - -You can specify lines of code inline, `var a = "some variable name";`. And it can be a part of a paragraph as well. - -If `every` other `word` is `an` inline `code` block `what` does `that` do `for` us. - -Let's **`bold`** **some** words. Also add some links; a [`short`](/) and [`a long one`](/) and a [**`bold`**](/) one. - -### Line - -```js -dateformat.i18n = require('./lang/' + l); -``` - -### Blocks - -Let's add one line above. - -Let's add another line above. - -```js -// Javascript code with syntax highlighting. -var fun = function lang(l) { - dateformat.i18n = require('./lang/' + l); - return true; -}; -``` - -Let's add one line below. - -Let's add another line below. - -### Frame - -Code blocks can be rendered inside a window-like frame. - - -```js title="my-test-file.js" -console.log('Hello World!'); -``` - -#### Bash - -```bash title="Create a new project" -npm create sst -``` - -#### Bash Without Title - -```bash -npm create sst -``` - -### Code Markers - -#### Lines - -Mark entire lines & line ranges using the `{ }` marker. - -```js {3-4} -function demo() { - // This line is not highlighted - // This line (#2) and the next one are highlighted - return 'This is line #3 of this snippet'; -} -``` - -#### Selections - -Mark selections of text using the `" "` marker or regular expressions. - -```js "Individual terms" /Even.*supported/ -// Individual terms can be highlighted, too -function demo() { - return 'Even regular expressions are supported'; -} -``` - -#### Insert Deletes - -Mark text or lines as inserted or deleted with `ins` or `del`. - -```js "return true;" ins="inserted" del="deleted" -function demo() { - console.log('These are inserted and deleted marker types'); - // The return statement uses the default marker type - return true; -} -``` - -#### Diffs - -Combine syntax highlighting with `diff`-like syntax. - -```diff lang="js" - function thisIsJavaScript() { - // This entire block gets highlighted as JavaScript, - // and we can still add diff markers to it! -- console.log('Old code to be removed') -+ console.log('New and shiny code!') - } -``` - -## Tabs - -You can display a tabbed interface using the `` and `` components. - - - Sirius, Vega, Betelgeuse - Io, Europa, Ganymede - - -### Code Blocks - -```ts title="sst.config.ts" -export default $config({ - app(input) { - return { - name: "my-sst-app", - home: "aws" - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - - return { - bucket: bucket.name - }; - } -}); -``` - -#### With Frame - - - - -```bash -npm create astro@latest -- --template starlight -``` - - - - -```bash -pnpm create astro --template starlight -``` - - - - -```bash -yarn create astro --template starlight -``` - - - - -#### Without Frame - - - - -```bash frame="none" -npm create astro@latest -- --template starlight -``` - - - - -```bash frame="none" -pnpm create astro --template starlight -``` - - - - -```bash frame="none" -yarn create astro --template starlight -``` - - - - -### Overflow - -```js -{ - url: { - cors: { - allowOrigins: ["https://www.example.com", "http://localhost:60905", "http://localhost:60905"] - } - } -} -``` - -## Lists - -### Ordered List - -1. First item - 1. First sub item - 2. Second sub item -2. Second item -3. Third item - -#### Multi-Line - -1. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. -2. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. -3. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -#### Long List - -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item -1. Item - -#### Paragraph - -1. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - - :::tip - Make sure to [read this](/) extra resource on this topic. - ::: - - Here's some additional data on it that's relevant to the subject. - -2. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - - Here's some additional data on it that's relevant to the subject. - -3. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -### Unordered List - -- First item - - First sub item - - Second sub item -- Second item -- Third item - -#### Multi-Line - -- The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. -- The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. -- The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -#### Paragraph - -- The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - - :::tip - Make sure to [read this](/) extra resource on this topic. - ::: - - Here's some additional data on it that's relevant to the subject. - -- The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. -- The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -## Dividers - -Use the `---` to add a divider. It inserts an `
    ` tag. - ---- - -## Table - -Let's test some tables. Testing the table and the spacing between it and the neighboring paragraphs. - -| Syntax | Description | -| ----------- | ----------- | -| Header | Title | -| Paragraph | Text | -| Link | URL | - -The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -## Images - -![An illustration of planets and stars featuring the word β€œastro”](https://raw.githubusercontent.com/withastro/docs/main/public/default-og-image.png) - -## Headings - -You can structure content using a heading. Headings in Markdown are indicated by a number of `#` at the start of the line. - -### Heading 3 - -This is heading 3. - -#### Heading 4 - -This is heading 4. - -## Blockquotes - -> This is a blockquote, which is commonly used when quoting another person or document. -> -> Blockquotes are indicated by a `>` at the start of each line. - -## Asides - -:::note -This is a note. -::: - -:::tip -This is a tip. By specifying the ZipFile property within the Code property, specify `index.function_name` as the handler. -::: - -:::caution -This is a caution. -::: - -:::danger -This is a danger. -::: - -### With Links - -:::tip -Here's a website you should probably check out β€” [Google](/) -::: - -:::note -Here's a website with code should probably check out β€” [`Google`](/) -::: - -### Paragraphs - -Let's add one line above. - -Let's add another line above. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -:::caution -This is a caution aside that we can compare the font sizes to the blocks around it. -::: - -:::tip -This is a tip aside to test what back to back aside blocks look like. -::: - -Let's add one line below. Let's make this a paragraph. The more data a web page transfers, the more energy resources it requires. In April 2023, the median web page required a user to download more than 2,000 KB according to data from the HTTP Archive. - -Let's add another line below. - -### Custom Titles - -:::tip[Did you know?] -Astro helps you build faster websites with [β€œIslands Architecture”](https://docs.astro.build/en/concepts/islands/). -::: - -### Video Asides - - - -## Extra - -## Sections - -## At The - -## Bottom - -## For The - -## Right Sidebar - -## Overflow - -```ts -new sst.cloudflare.StaticSite("Website", { - domain: "example.com", - notFound: "single-page-application", - trailingSlash: "auto", -}); -``` diff --git a/www/src/content/docs/dummy/tsdoc.mdx b/www/src/content/docs/dummy/tsdoc.mdx deleted file mode 100644 index b19df81cd1..0000000000 --- a/www/src/content/docs/dummy/tsdoc.mdx +++ /dev/null @@ -1,430 +0,0 @@ ---- -title: TSDoc -description: A page to test all the TSDoc cases -draft: true ---- - -import Segment from '../../../components/tsdoc/Segment.astro'; -import Section from '../../../components/tsdoc/Section.astro'; -import NestedTitle from '../../../components/tsdoc/NestedTitle.astro'; -import InlineSection from '../../../components/tsdoc/InlineSection.astro'; - -
    - -
    -Returns a locale object for the specified definition with `locale.format` and `locale.formatPrefix` methods. - -This section has more from about the `FormatSpecifier`. - -:::note -You can also add notes. By specifying the ZipFile property within the Code property, specify `index.function_name` as the handler. -::: - -#### Simple Example - -Here's a simple example. - -```ts -new FormatSpecifier("param1"); -``` - -#### Complicated Example - -Here's a more complicated example. - -```ts -new FormatSpecifier("param1", "param2", "param3"); -``` - -For more info [refer to our other docs](/). -
    - ---- - -## Constructor - - -
    -```ts -new FormatSpecifier(specifier, addend?): FormatSpecifier -``` -
    - -
    -#### Parameters - --

    specifier [FormatSpecifierObject](#FormatSpecifierObject)

    - - A specifier object. - - --

    addend? number | string & boolean

    - - A number to add. -
    - - -**Returns** [FormatSpecifier](#FormatSpecifier)[] | null - -
    - -## Methods - -### noop - - -
    -```ts -noop(): void -``` -
    - -This function doesn't do anything. -
    - -### simpleArgs - - -
    -```ts -simpleArgs(true, false ,true): void -``` -
    - -This function takes some simple args. - -
    -#### Parameters - --

    isTrue boolean

    --

    isFalse? boolean

    --

    isAny? boolean

    -
    - -
    - -### fullArgs - - -
    -```ts -fullArgs(true, false ,true): FormatSpecifier -``` -
    - -This function takes full args. - -
    - -**Type** Object - - --

    prop1? boolean

    - - - **Default** true - - - A simple prop to add. - --

    prop2? x86_64 | arm_64

    - - - **Default** Uses x86 by default `x86_64`. But this description of the default is really long and runs more than one single line. - - - A complex prop to add with a description that is longer than one line. This matters because - - A simple example. - - ```ts - { prop2: "x86_64" } - ``` - - A more complicated multi-line example. - - ```ts - { - prop2: "x86_64" - } - ``` - --

    prop3? [FormatSpecifier](#FormatSpecifier)[] | null

    - - - **Default** true - - - Just pass something in. - - ```ts - { - prop2: "x86_64" - } - ``` -
    - - -**Returns** [FormatSpecifier](#FormatSpecifier)[] | null - - -Here's an example. - -```diff lang="ts" - function demo() { -+ return fullArgs(true, false ,true); - } -``` - -And another example. - -```ts {4} -const a = 1; -const b = a + 1; - -fullArgs(true, false ,true); -``` - -
    - -## Properties - -### primitiveProp - - -The ARN of the resource. - - -**Type** x86_64 | arm_64 - - - -### objectProp - - -A simple object prop. - -
    - -**Type** Object - - --

    resource1 string

    --

    resource2 [FormatSpecifier](#FormatSpecifier)

    -
    -
    - -### objectPropNested - - -A nested object prop. - -
    - -**Type** Object - --

    [resource1](#) Output<Object>

    - -

    [objectKey1](#) Object

    - -

    [objectKey11](#) Object[]

    - -

    [key111](#) boolean

    - -

    [objectKey112](#) Object

    - -

    [key1111](#) string

    - -

    [key1112](#) string

    - -

    [key2](#) boolean

    --

    [resource2](#) [FormatSpecifier](#FormatSpecifier)

    -
    - -
    - -objectKey1 - - -A simple object prop. - - -**Type** Output<Object> - - - -objectKey1 - - -A simple object prop. - - -**Type** Object - - - -objectKey11 - - -A simple object prop. - - -**Type** Object[] - - - -objectKey112 - - -A simple object prop. - - -**Type** Object - - - -key1111 - - -A simple prop. - - -**Type** string - - - -## DummyArgs - -### simpleArg - - -The CPU architecture of the lambda function. - - -**Type** x86_64 | arm_64 - - - -**Default** Uses x86 by default `x86_64`. But this description of the default is really long and runs more than one single line. - - -For example, - -```ts -new Function(stack, "Function", { - architecture: "arm_64", -}) -``` - - -### objectPropSimple? - - -A prop that takes an object with simple keys. - -
    - -**Type** Object - - --

    isTrue boolean

    --

    isFalse? boolean

    --

    isAny? boolean

    -
    - - -**Default** undefined - - -```ts -new Function(stack, "Function", { - architecture: "arm_64", -}) -``` -
    - -### objectPropFull? - - -A prop that takes an object with full keys. - -
    - -**Type** Object - - --

    prop1? boolean

    - - - **Default** true - - - A simple prop to add. - - ```ts - { - prop1: true - } - ``` - --

    prop2? x86_64 | arm_64

    - - - **Default** Uses x86 by default `x86_64`. But this description of the default is really long and runs more than one single line. - - - A complex prop to add with a description that is longer than one line. This matters because - - A simple example. - - ```ts - { prop2: "x86_64" } - ``` - - A more complicated multi-line example. - - ```ts - { - prop2: "x86_64" - } - ``` - --

    prop3? [FormatSpecifier](#FormatSpecifier)[] | null

    - - - **Default** true - - - Just pass something in. - - ```ts - { - prop2: "x86_64" - } - ``` -
    - - -**Default** undefined - - -```ts -new Function(stack, "Function", { - architecture: "arm_64", -}) -``` -
    - -### transform? - - -[Transform](/docs/transform/) how this component is created. - -
    - -**Type** Object - - --

    resource1? [FormatSpecifier](#FormatSpecifier) | (args: [FormatSpecifier](#FormatSpecifier) => [FormatSpecifier](#FormatSpecifier) | void)

    --

    resource1? [FormatSpecifier](#FormatSpecifier) | (args: [FormatSpecifier](#FormatSpecifier) => [FormatSpecifier](#FormatSpecifier) | void)

    -
    - - -**Default** undefined - -
    - -
    diff --git a/www/src/content/docs/index.mdx b/www/src/content/docs/index.mdx deleted file mode 100644 index 965bdd838b..0000000000 --- a/www/src/content/docs/index.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: SST -template: splash -pagefind: false -hero: - title: "n/a" ---- diff --git a/www/src/content/docs/legal/privacy-policy.mdx b/www/src/content/docs/legal/privacy-policy.mdx deleted file mode 100644 index de53c4b3e0..0000000000 --- a/www/src/content/docs/legal/privacy-policy.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -template: splash -title: Privacy Policy -description: Privacy policy for sst.dev and the SST Console. -pagefind: false ---- - -import config from '../../../../config.ts'; - -**Last updated**: October 3, 2024 - -1. **Welcome** - - Welcome to the Privacy Policy for [sst.dev](/) and the SST Console application(s) (together the β€œ**Platform**”), operated by Anomaly Innovations (hereafter referred to as β€œ**AI**”, β€œ**we**”, β€œ**us**”, and β€œ**our**”). Your privacy is very important to us. This Privacy Policy explains how personal information about you is collected, used and disclosed by AI with respect to your use and interaction with AI, the Platform and our related services (the β€œ**Services**”). - - We may make changes to the Privacy Policy from time to time, so please be sure to check the Privacy Policy regularly. If we decide to make material changes to the Privacy Policy, we will notify you and other users via email or by placing a notice on the Platform. - -2. **How do you collect personal information?** - - We collect personal information from you when you provide information directly to us, for example, when you contact us, register an account, purchase Services or make inquiries to our webmaster. - - We may collect personal information from third parties who you provided information to, such as providers related to our Services, or in connection with processing payment related to your subscription for our Services. - - We may also collect personal information of third parties that you provide to us or authorize us to collect (β€œThird Party Data”). You are responsible for obtaining the necessary consent for the collection and use of Third Party Data and for the disclosure of this data to us. - -3. **What kind of personal information do you collect?** - - Examples of personal information we collect and use are: - - Contact information, such as full name, email address, telephone number - - Company name - - Amazon Web Services (β€œAWS”) Identity and Access Management (β€œIAM”) credentials - - Git provider credentials (access tokens) - - Payment information, including payment card data and billing address - - Information you provide when you contact us, provide feedback, make a complaint or other inquiries - - Other personal information required to provide you with our Services - - Tracking data such as time spent on webpages, clicks, actions - -4. **How do you use the information?** - - AI uses your personal information to: - - Register an account - - Provide our Services - - Administer, troubleshoot, enhance and manage our Services, including processing your subscriptions - - Verify transactions and process payments - - Send processing communications, including updates on your subscription or account - - Send promotional communications such as special offers or other promotions (if you have opted-in to receive such communications) - - Analyze the accuracy and effectiveness of our Platform and Services - - Analyzing and understanding our customers and their needs - - Meet obligations as required by applicable laws, i.e. fraud detection, enforcing the Terms of Use, enforcing any agreements, or when required by court order or an authorized enforcement agency - - Tailor your experience while visiting the Platform - - Responding to inquiries, complaints and other communications to AI - - Other purposes that we identify to you from time to time - - It is important to understand that we will undertake every reasonable precaution to safeguard your personal information, however, providing this data to us may expose your personal information to various risks, including in the event of a data breach. If a data breach occurs, we will notify you as soon as possible and will comply with all legal requirements to mitigate any harms resulting from such a breach. - -5. **Do you automatically collect technical data, and why?** - - Like many websites, we automatically collect technical data when you visit and use our Platform. - - **IP Addresses**: We may collect your IP address when you visit our Platform to help us diagnose problems with our main computers, to administer the Platform and system, to report aggregated information to our partners, and to audit the use of our Platform. We do not normally link IP addresses to anything personally identifiable. In limited circumstances, we may use IP addresses to help us identify you when we feel it is necessary to enforce compliance with our Software as a Service Agreement or to protect our Services, the Platform, users or others. - - **Cookies and similar technologies**: We use β€œcookies”, scripts, pixel tags, etags, web beacons and other similar technologies on certain pages of our Platform. These automatically collect data from a visitor to our Platform and transfer this information to the visitor’s hard drive. Cookies help us recognize repeat visitors, personalize the Platform and communications and tailor content to match particular interests. We also use these technologies to track Platform usage trends and patterns. - - - **Opt out of cookies.** You are always free to set your browser to decline cookies and you can delete them from your computer. If you decline β€œcookies” or delete them from your computer, you will still be able to access our Platform, but you may find that some areas do not work as smoothly as when cookies are enabled on your system. - -6. **Do you share personal information?** - - We may share personal information with third party service providers who assist us in providing and administering the Platform and our Services. Third parties may assist us with services such as data hosting and marketing. These third parties that process personal information on our behalf are contractually obligated to safeguard information and only use the information provided to them for the purposes outlined in this Privacy Policy. - - We may share information with our business and promotional partners to send you information, by email, telephone or other means, about products and services you may like. Users may opt-out of receiving communications at any time. See Section 11 on how to opt-out of receiving promotional emails. - - AI may provide certain demographic information to third parties in connection with providing the Services to you. - - We may disclose and share your personal information to explore and/or undertake a corporate transaction, including a merger, acquisition, amalgamation, IPO, reorganization or sale of AI and/or the Platform. Your personal information will be used and shared solely for the purposes related to the transaction and will be protected by security safeguards appropriate to the sensitivity of the information. - - We may disclose personal information to government, regulatory and/or law enforcement agencies if we believe the disclosure is legally required, is appropriate in connection with an investigation of improper or illegal conduct in connection with our Platform and Services, or is otherwise required or permitted by law. - -7. **Do you aggregate personal information?** - - We may aggregate (i.e. assemble on a basis that does not enable one to personally identify you) the information we collect from you, including any technical data we automatically collect. Aggregated or β€œde-identified data” means that information that does not identify an individual and no longer considered β€œpersonal information”. Aggregated data may be used by us to improve our Services and for marketing or resale purposes, and may be shared with and used by advertisers and other third parties. We may also use aggregate data to determine what types of products and services are best suited for our customers and are requested by our customers. If we share aggregated data to third parties, personal information will not be individually identifiable in the aggregated data. - -8. **Other websites and your information** - - Our Platform may be linked from another website, or have links to other websites such as social media platforms. This Privacy Policy only relates to our collection and use of your information on the Platform and we are not responsible for the privacy policies and practices of other third party websites, including from any provided links. If you would like information on any other party’s privacy policy, you should contact that party directly, and we encourage you to do so. - -9. **Security, storage and retention of your personal information** - - AI employs reasonable measures to protect and ensure the security of your personal information from unauthorized use, access, disclosure, alteration, destruction or loss. - - Your personal information may be stored and/or processed or otherwise used by or on behalf of AI outside of your jurisdiction of residence. By using our Services, you consent that your personal information is subject to the authorities and laws of that jurisdiction. - - AI retains your personal information for as long as necessary or relevant for the listed purposes in this Privacy Policy, or as required by any applicable legal and retention obligations. - -10. **How you can access, update and modify your information** - - **Updating information**: If you have created an account, you can update or make changes to your personal information by logging into your account. If you do not have an account with AI, you can contact us at any of the options below. - - **Access Request**: If you make a request, we will let you know what personal information AI has about you, what it is being used for, and with whom it has been shared. If you notice any inaccuracies or wish to update any part of your personal information, we will look into that as well. - - AI will provide you with access to your personal information that is in our possession, subject to certain exceptions, including information that is referenced to another individual’s personal information that we cannot sever, or information subject to solicitor-client privilege, or other legal restrictions that may prevent us from fulfilling your access request. To inquire contact us at {config.email} (include β€œAttention: Privacy Officer” in the subject line). - -11. **How to opt-out of receiving promotional communications** - - In the event you wish to unsubscribe from receiving promotional email communications from AI, you may opt-out by: - - - Removing yourself by clicking β€œunsubscribe” at the bottom of an email we send you, or - - Contact us at {config.email} - - If you opt-out of receiving marketing-related emails from us, we may still send you important administrative messages, such as notifications regarding your account or subscription to our Services, or as otherwise consistent with applicable law. - -12. **Contact Us** - - To contact us with questions about this Privacy Policy or other inquiries send us an email atΒ {config.email}Β and write β€œPrivacy Policy” in the subject line. - -Still Need Help? Email {config.email}. - diff --git a/www/src/content/docs/legal/terms-of-service.mdx b/www/src/content/docs/legal/terms-of-service.mdx deleted file mode 100644 index 845f5a75ab..0000000000 --- a/www/src/content/docs/legal/terms-of-service.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -template: splash -title: Terms of Service -description: Terms of service for the SST Console. -pagefind: false ---- - -import config from '../../../../config.ts'; - -**PLEASE READ THIS AGREEMENT BEFORE USING THE SST CONSOLE. BY ACCESSING OR USING THE SERVICE (AS DEFINED BELOW), YOU (β€œyou” or the β€œCustomer”) SIGNIFY ACCEPTANCE OF AND AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT, DO NOT ACCESS OR USE THE SERVICE. IF THE PARTIES HAVE A FULLY EXECUTED AGREEMENT THAT EXPRESSLY GOVERNS ORDERS FOR THE SST CONSOLE SERVICE OFFERING, SUCH AGREEMENT SHALL SUPERSEDE THIS AGREEMENT.** - -This Software as a Service Agreement (the β€œ**Agreement**”) governs Customer’s relationship with Anomaly Innovations (β€œ**AI**”) relating to the Service offered by AI through the SST website located at [https://sst.dev](/) and the SST Console application(s) (together the β€œ**Platform**”) owned and operated by AI. - -Please read this Agreement carefully and be sure that you fully understand the terms and conditions contained herein. This Agreement constitutes a binding legal agreement between you and AI. - -Your use of the Service constitutes your agreement to all such terms, conditions, and notices in effect at such time. You hereby represent and warrant that (i) you are lawfully able to enter into and perform a legally binding contract, (ii) if you are entering into this Agreement on behalf of your employer you are authorized to do so, and (iii) you agree to be bound by this Agreement. Please print a copy of this Agreement and retain it for your or your employer’s records. - -You should also read the SST [Privacy Policy](/legal/privacy-policy), which is incorporated by reference into this Agreement and available on the SST Platform. If you do not accept and agree to be bound by all of the terms of this Agreement, including the SST Privacy Policy, do not access or use the Service. - -AI may update or revise this Agreement (including the SST Privacy Policy and the Fee Schedule) from time to time. You agree that you will review this Agreement periodically. You are free to decide whether or not to accept a modified version of this Agreement, but accepting this Agreement, as modified, is required for you to continue using the Service. You may have to click β€œaccept” or β€œagree” to show your acceptance of any modified version of this Agreement. If you do not agree to the terms of this Agreement or any modified version of this Agreement, your sole recourse is to terminate your use of the Service, in which case you will no longer have access to your Account (as defined below). Except as otherwise expressly stated by AI, any use of the Service is subject to the version of this Agreement in effect at the time of use. - -The parties hereby agree to the following terms: - -1. **DEFINITIONS** - - β€œ**Aggregated Data**” means the aggregated, anonymized and de-identified Customer Data. - - β€œ**Service**” means the service provided by AI the details of which are set forth in Section 2 hereof. - - β€œ**Customer Data**” means all information and data that the Customer uploads to or collects or transmits via the Service, including metadata. - - β€œ**Documentation**” means the user guides, online help, release notes, training materials and other documentation provided or made available by AI to the Customer regarding the use or operation of the Services. - - β€œ**Fee Schedule**” means the schedule on the Platform that outlines the fees for the Service, including the Subscription Fee for each Subscription Plan. - - β€œ**Software**” means the object code version of any software to which Customer is provided access as part of the Service, including any updates or new versions. - - β€œ**Subscription Fee**” means the amount charged by AI to the Customer for a Subscription Plan. - - β€œ**Subscription Plan**” means a fixed term plan for use of the Service. - -2. **THE SERVICE** - - 2.1 The SST Console Service is a fully-configured cloud-based continuous integration and continuous delivery pipeline for building, testing, deploying, and monitoring SST applications on Amazon Web Services (β€œAWS”) and other cloud providers. - - 2.2 AI may make modifications to any aspect of the Service from time to time, to add or remove features and functionalities. - -3. **USE OF THE SERVICE** - - 3.1 In order to use the Service, the Customer must register for an account on the Platform (β€œSST Console Account” or β€œAccount”) and subscribe to the Service (a β€œSubscription”). As part of the registration process, the Customer will be required to provide AI with certain information (such as identification or contact details). The Customer agrees that any registration information provided to AI will always be accurate, correct and up to date. - - 3.2 In order to use the Service, Customers must connect their Account to a Git provider and provide AI with AWS Identity and Access Management (β€œIAM”) credentials. - - 3.3 Subject to the Customer’s timely payment of all applicable Subscription Fees, the Customer will, during the term of this Agreement, receive a nonexclusive, non-transferable, worldwide right to access and use the Service subject to the terms and conditions of this Agreement. - - 3.4 The Customer acknowledges that this Agreement is a services agreement and that AI will not deliver copies of the Software to the Customer as part of the Service. - - 3.5 AI or its licensors retain all right, title and interest, including intellectual property rights, in and to the Software, the Service, Documentation and other deliverables provided under this Agreement, including all modifications, improvements, upgrades, derivative works and feedback related thereto. The Customer agrees to assign all right, title and interest it may have in the foregoing to AI. - - 3.6 Customer agrees that it will only access and use the Service by the means described in the Documentation. Customer agrees that it will not attempt to circumvent any limitations on its use of the Service without AI’s express consent. - - 3.7 Customer hereby acknowledges and agrees that AI may monitor and record the Customer’s use of the Service to ensure that the Customer complies with the terms and conditions of this Agreement. - -4. **RESTRICTIONS** - - The Customer shall not, and shall not permit anyone to: (i) copy or republish the Service or Software, (ii) make the Service available to any person other than Customer’s registered users, (iii) use or access the Service to provide service bureau, time-sharing or other computer hosting services to third parties, (iv) modify or create derivative works based upon the Service or Documentation, (v) remove, modify or obscure any copyright, trademark or other proprietary notices contained in the Software used to provide the Service or in the Documentation, (vi) reverse engineer, decompile, disassemble, or otherwise attempt to derive the source code of the Software used to provide the Service, except and only to the extent such activity is expressly permitted by applicable law, or (vii) access the Service or use the Documentation in order to build a similar product or competitive product. - -5. **CUSTOMER RESPONSIBILITIES** - - 5.1 Compliance with Laws. The Customer shall comply with all applicable local, state, national and foreign laws in connection with its use of the Service, including those laws related to spam, data privacy, international communications, and the transmission of technical or personal data. The Customer acknowledges that AI exercises no control over the content of the information transmitted by the Customer through the Service. The Customer shall not upload, post, reproduce or distribute any information, software or other material protected by copyright, privacy rights, or any other intellectual property right without first obtaining the permission of the owner of such rights. - - 5.2 Unauthorized Use; False Information. The Customer shall: (a) notify AI immediately of any unauthorized use of any password or user id or any other known or suspected breach of security, (b) report to AI immediately and use reasonable efforts to stop any unauthorized use of the Service that is known or suspected by the Customer, and (c) not provide false identity information to gain access to or use the Service. - - 5.3 Insurance. The Customer is responsible for obtaining and maintaining levels of and types of insurance coverage that are appropriate for its business operations. - -6. **CUSTOMER DATA** - - 6.1 Customer Responsibility. The Customer is solely responsible for all Customer Data stored on the Service, and for ensuring that the Customer Data does not (i) include anything that actually or potentially infringes or misappropriates the copyright, trade secret, trademark or other intellectual property right of any third party, or (ii) contain anything that is obscene, defamatory, harassing, offensive or malicious. The Customer is solely responsible for the accuracy, timeliness, completeness and usefulness of Customer Data. - - 6.2 Ownership. The Customer retains ownership of its Customer Data, including all intellectual property rights therein and relating thereto. - - 6.3 License from Customer. The Customer grants AI a non-exclusive license to use, copy, store, configure, display, edit, modify, reproduce, distribute and transmit Customer Data for the sole purpose of providing the Service to the Customer. - - 6.4 Aggregated Data. The Customer grants AI a non-exclusive, transferable, assignable, irrevocable, royalty-free, worldwide, perpetual license to create Aggregated Data and to use such Aggregated Data, and all modifications thereto and derivatives thereof , for any purpose, including, without limitation, to improve the Service, develop new products and services and understand usage. AI shall own all Aggregated Data and may transfer or assign any of its rights in the Aggregated Data to any third party. - - 6.5 Transfer Abroad. AI may transfer Customer Data outside of Customer’s jurisdiction of residence for processing and storage. - - 6.6 Security. AI will have in place and maintain appropriate technical and organizational measures to protect Customer Data against unauthorized access, or accidental loss, destruction or damage. - - 6.7 Termination. In the event that this Agreement is terminated or if the Customer removes any Customer Data from the Customer’s Account, AI may retain Aggregated Data and may continue to use the Aggregated Data pursuant to the licenses granted above. - -7. **BILLING AND PAYMENT** - - 7.1 Free Trial. AI may offer the Customer a free trial Subscription. Free trials are for new Customers only. The free trial period lasts until the Customer exceeds a prescribed limit on the number of deployments per month (β€œTrial Period”), or as otherwise specified to the Customer. At end of the Trial Period, the free trial Subscription will come to an end and the Customer must purchase a Subscription Plan to continue to use the Service. - - 7.2 Subscription Plans. AI offers Customers various subscription plans for the use of the Service (each a β€œSubscription Plan”). A description of each Subscription Plan is set out in the Fee Schedule, which can be found on the SST website at [https://sst.dev/docs/console#pricing](https://sst.dev/docs/console#pricing) (the β€œFee Schedule”). AI may also offer certain enterprise Customers custom-made Subscription Plans. - - 7.3 Subscription Fees. The monthly subscription fee (the β€œSubscription Fee”) for each Subscription Plan is set out in the Fee Schedule. - - 7.4 Billing and Payment. When the Customer purchases a Subscription, the Customer authorizes AI to charge the Customer the Subscription Fee for the corresponding Subscription Plan to the Customer’s designated payment method. The Subscription Fee will be charged in arrears to the Customer on a monthly recurring basis on the last day of each month or as otherwise specified by AI (the β€œRenewal Date”). The Customer will be charged a prorated amount of the Subscription Fee for the first month of a Subscription Plan where applicable. - - 7.5 Taxes. AI shall bill the Customer for applicable taxes as a separate line item on each invoice. The Customers shall be responsible for payment of all sales and use taxes, value added taxes (VAT), or similar charges relating to the use of the Service. - - 7.6 Renewal. Each Subscription will automatically renew and continue month-to-month unless and until the Customer cancels the Subscription. The Customer must cancel the Subscription before the Renewal Date to avoid being billed for the renewal. - - 7.7 Cancellation. Upon cancellation of the Subscription, the Customer will continue to have access to the Service through the end of the monthly billing period. - - 7.8 No Refunds. All Fee payments are non-refundable and there are no refunds or credits for partially used periods. - - 7.9 Price and Plan Changes. AI reserves the right to adjust the Subscription Plans, the Fee Schedule and the pricing of any Service in any manner and at any time in its sole discretion. Any price changes to existing Subscriptions will take effect following email notice to the Customer. - -8. **TERM AND TERMINATION** - - 8.1 Term of Agreement. The term of this Agreement shall begin when the Customer registers for a SST Console Account and shall continue until the Agreement is terminated by either party as outlined in this Section. - - 8.2 Termination. AI may terminate this Agreement at any time without notice for any reason, with or without cause, in its sole discretion. The Customer may terminate this Agreement at any time by following the instructions in the Customer’s SST Console Account. This Agreement will automatically terminate when the Customer cancels the Customer’s Account. - - 8.3 Suspension of Service. AI reserves the right to suspend the Service for non-payment of the Subscription Fees or for any other reason, with or without cause, in its sole discretion. Suspension of the Service shall not release the Customer of its payment obligations under this Agreement. - - 8.4 Effect of Termination. Upon termination of this Agreement, AI shall immediately cease providing the Service and all usage rights granted under this Agreement shall terminate. After any suspension or termination, the Customer may or may not be granted permission to use the Service or to reactivate the Customer’s Account or Subscription. The Customer understands that the termination of this Agreement may involve the deletion of Customer Data stored in the Customer’s Account. AI shall not be liable to the Customer or to any third party for any liabilities, claims or expenses arising from or relating to any termination or suspension. - - 8.5 No Refund of Fees. In the event of termination or suspension of the Service, the Customer shall not be entitled to any refund or partial refund of any Subscription Fees paid to AI, including any prepayments. - -9. **WARRANTIES** - - 9.1 Warranty. AI represents and warrants that it will provide the Service in a professional manner consistent with general industry standards. Customer’s exclusive remedy for a breach of this warranty shall be as provided in Section 8, Term and Termination. - - 9.2 Warranty Disclaimer. TO THE EXTENT PERMITTED BY APPLICABLE LAW AND Except as expressly provided herein, the service IS provided to CUSTOMER on an "AS IS" basis without any warranty whatsoever AND AI EXPRESSLY DISCLAIMS ALL OTHER REPRESENTATIONS, WARRANTIES, AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY REPRESENTATION, WARRANTY OR CONDITION OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, OR NON-INFRINGEMENT, OR ANY WARRANTY ARISING FROM A COURSE OF DEALING, PERFORMANCE, OR TRADE USAGE. CUSTOMER’S sole and exclusive remedy, and AI’S sole obligation to CUSTOMER or any third party for any claim arising out of CUSTOMER’S use of the service, is that CUSTOMER IS free to discontinue ITS use of the service at any time. - -10. **LIMITATIONS OF LIABILITY** - - 10.1 Limitation of Liability. TO THE EXTENT PERMITTED BY APPLICABLE LAW AND EXCEPT FOR INDEMNIFICATION CLAIMS UNDER SECTION 11, THE MAXIMUM AGGREGATE LIABILITY OF AI TO THE CUSTOMER ARISING OUT OF OR RELATED TO THIS AGREEMENT (WHETHER IN CONTRACT OR TORT OR UNDER ANY OTHER THEORY OF LIABILITY) SHALL NOT EXCEED THE AMOUNT OF FEES ACTUALLY PAID BY CUSTOMER TO AI DURING THE 12 MONTHS PRECEDING THE DATE OF THE EVENT GIVING RISE TO THE CLAIM. - - 10.2 Exclusion of Consequential and Related Damages. IN NO EVENT SHALL EITHER PARTY HAVE ANY LIABILITY TO THE OTHER FOR ANY LOST PROFITS OR REVENUES OR FOR ANY INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL OR PUNITIVE DAMAGES HOWEVER CAUSED, WHETHER IN CONTRACT, TORT OR UNDER ANY OTHER THEORY OF LIABILITY, AND WHETHER OR NOT SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - 10.3 Connectivity. AI SHALL NOT BE LIABLE FOR DELAYS, INTERRUPTIONS, SERVICE FAILURES, OR OTHER PROBLEMS INHERENT IN USE OF THE INTERNET, ELECTRONIC COMMUNICATIONS, TELECOMMUNICATIONS NETWORKS OR OTHER SYSTEMS OR NETWORKS OUTSIDE THE REASONABLE CONTROL OF AI. - -11. **INDEMNIFICATION** - - 11.1 Indemnification by AI. If a third party makes a claim against the Customer that the Service infringes any patent, copyright or trademark, or misappropriates any trade secret, or that AI’s negligence or willful misconduct has caused bodily injury or death, AI shall defend the Customer and its directors, officers and employees against the claim at AI’s expense and AI shall pay all losses, damages and expenses (including reasonable legal fees) finally awarded against such parties or agreed to in a written settlement agreement signed by AI, to the extent arising from the claim. AI shall have no liability for any claim based on (a) Customer Data, (b) modification of the Service not authorized by AI, or (c) use of the Service other than in accordance with the Documentation and this Agreement. AI may, at its sole option and expense, procure for the Customer the right to continue use of the Service, modify the Service in a manner that does not materially impair the functionality, or as its sole obligation and liability, terminate the Service and repay to Customer any Subscription Fees paid by Customer with respect to the Service for any period following the termination date. - - 11.2 Indemnification by Customer. If a third party makes a claim against AI that the Customer Data infringes any patent, copyright or trademark, or misappropriates any trade secret, the Customer shall defend AI and its directors, officers and employees against the claim at the Customer’s expense and the Customer shall pay all losses, damages and expenses (including reasonable attorneys’ fees) finally awarded against such parties or agreed to in a written settlement agreement signed by the Customer, to the extent arising from the claim. - - 11.3 Conditions for Indemnification. A party seeking indemnification under this section shall (a) promptly notify the other party of the claim, (b) give the other party sole control of the defense and settlement of the claim, and (c) provide, at the other party’s expense for out-of-pocket expenses, the assistance, information and authority reasonably requested by the other party in the defense and settlement of the claim. - -12. **GENERAL PROVISIONS** - - 12.1 Non-Exclusive Service. The Customer acknowledges that the Service is provided on a non-exclusive basis. Nothing shall be deemed to prevent or restrict AI’s ability to provide the Service or other technology, including any features or functionality first developed for Customer, to other parties. - - 12.2 Assignment. Neither party may assign this Agreement or any right under this Agreement, without the consent of the other party, which consent shall not be unreasonably withheld or delayed; provided however, that either party may assign this Agreement to an acquirer of all or substantially all of the business of such party to which this Agreement relates, whether by merger, asset sale or otherwise. This Agreement shall be binding upon and inure to the benefit of the parties’ successors and permitted assigns. - - 12.3 Subcontractors. AI may employ subcontractors in performing its duties under this Agreement, provided, however, that AI shall not be relieved of any obligation under this Agreement. - - 12.4 Notices. Except as otherwise permitted in this Agreement, notices under this Agreement shall be made in writing to the other party. - - 12.5 Force Majeure. Each party will be excused from performance for any period during which, and to the extent that, such party or any subcontractor is prevented from performing any obligation or Service, in whole or in part, as a result of causes beyond its reasonable control, and without its fault or negligence, including without limitation, acts of God, strikes, lockouts, riots, acts of terrorism or war, epidemics, communication line failures, and power failures. - - 12.6 Waiver. No waiver shall be effective unless it is in writing and signed by the waiving party. The waiver by either party of any breach of this Agreement shall not constitute a waiver of any other or subsequent breach. - - 12.7 Severability. If any term of this Agreement is held to be invalid or unenforceable, that term shall be reformed to achieve as nearly as possible the same effect as the original term, and the remainder of this Agreement shall remain in full force. - - 12.8 Entire Agreement. This Agreement (including all Schedules and exhibits) contains the entire agreement of the parties and supersedes all previous oral and written communications by the parties, concerning the subject matter of this Agreement. This Agreement may be amended solely in a writing signed by both parties. Standard or printed terms contained in any purchase order or sales confirmation are deemed rejected and shall be void unless specifically accepted in writing by the party against whom their enforcement is sought; mere commencement of Services or payment against such forms shall not be deemed acceptance of the terms. - - 12.9 Survival. Sections 4, 6, 8, and 9 through 12 of this Agreement shall survive the expiration or termination of this Agreement for any reason. - - 12.10 Publicity. AI may include the Customer’s name and logo in its customer lists and on its website. - - 12.11 Independent Contractor. The parties have the status of independent contractors, and nothing in this Agreement nor the conduct of the parties will be deemed to place the parties in any other relationship. Except as provided in this Agreement, neither party shall be responsible for the acts or omissions of the other party or the other party’s personnel. - - 12.12 Governing Law. This Agreement shall be governed by the laws of the State of Delaware and the federal laws applicable therein. - - 12.13 Compliance with Laws. AI shall comply with all applicable local, state, national and foreign laws in connection with its delivery of the Services, including those laws related to data privacy, international communications, and the transmission of technical or personal data. - - 12.14 Dispute Resolution. Customer’s satisfaction is an important objective to AI in performing its obligations under this Agreement. Except with respect to intellectual property rights, if a dispute arises between the parties relating to the interpretation or performance of this Agreement or the grounds for the termination hereof, the parties agree to hold a meeting within fifteen (15) days of written request by either party, attended by individuals with decision-making authority, regarding the dispute, to attempt in good faith to negotiate a resolution of the dispute prior to pursuing other available remedies. If, within 15 days after such meeting, the parties have not succeeded in resolving the dispute, either party may protect its interests by any lawful means available to it. - diff --git a/www/src/css/custom.css b/www/src/css/custom.css new file mode 100644 index 0000000000..5fc4294f16 --- /dev/null +++ b/www/src/css/custom.css @@ -0,0 +1,500 @@ +/* stylelint-disable docusaurus/copyright-header */ +/** + * Any CSS included here will be global. The classic template + * bundles Infima by default. Infima is a CSS framework designed to + * work well for content-centric websites. + */ + +/* You can override the default Infima variables here. */ +:root { + --ifm-font-family-base: "Source Sans Pro", sans-serif; + --ifm-heading-font-family: "Source Sans Pro", sans-serif; + --ifm-font-family-monospace: "JetBrains Mono", monospace; + + --ifm-global-spacing: 1rem; + --ifm-leading: 1.5rem; + + --ifm-background-color: #fff; + + --ifm-line-height-base: 1.75; + --ifm-font-size-base: 0.975rem; + + --custom-color-black: #383736; + --custom-border-color: #f2f2f2; + --custom-code-block-selection-color: #e2e8f0; + + --ifm-font-color-base: var(--custom-color-black); + --ifm-heading-color: var(--custom-color-black); + + --ifm-hr-border-color: var(--custom-border-color); + + --ifm-color-primary: #e27152; + --ifm-color-primary-dark: #de5b38; + --ifm-color-primary-darker: #db512a; + --ifm-color-primary-darkest: #b9401f; + --ifm-color-primary-light: #e6876c; + --ifm-color-primary-lighter: #e9917a; + --ifm-color-primary-lightest: #efb2a1; + + --ifm-color-secondary: #f4ece8; + --ifm-color-secondary-dark: #e5d1c8; + --ifm-color-secondary-darker: #ddc4b8; + --ifm-color-secondary-darkest: #c69c87; + --ifm-color-secondary-light: #ffffff; + --ifm-color-secondary-lighter: #ffffff; + --ifm-color-secondary-lightest: #ffffff; + + --ifm-color-success: #52e271; + --ifm-color-success-dark: #38de5b; + --ifm-color-success-darker: #2adb51; + --ifm-color-success-darkest: #1fb940; + --ifm-color-success-light: #6ce687; + --ifm-color-success-lighter: #7ae991; + --ifm-color-success-lightest: #a1efb2; + + --ifm-color-info: #52c3e2; + --ifm-color-info-dark: #38bade; + --ifm-color-info-darker: #2ab5db; + --ifm-color-info-darkest: #1f98b9; + --ifm-color-info-light: #6ccce6; + --ifm-color-info-lighter: #7ad1e9; + --ifm-color-info-lightest: #a1deef; + + --ifm-color-danger: #db4d26; + --ifm-color-danger-dark: #c64521; + --ifm-color-danger-darker: #bb411f; + --ifm-color-danger-darkest: #9a351a; + --ifm-color-danger-light: #df5f3c; + --ifm-color-danger-lighter: #e06847; + --ifm-color-danger-lightest: #e68368; + + /** Used in admonition type note gray background **/ + --ifm-color-secondary-contrast-background: rgb(249, 249, 250); + + --ifm-code-font-size: 85%; + --ifm-code-background: #f9fafb; + --ifm-code-padding-horizontal: 0.35rem; + + --ifm-link-hover-decoration: none; + --ifm-link-color: #d36f54; + --ifm-link-hover-color: #a5695b; + + /** Secondary text color **/ + --custom-font-color-secondary: var(--ifm-menu-color); + + /** Navbar **/ + --ifm-navbar-shadow: none; + + /** Table of contents **/ + --ifm-toc-border-color: transparent; + + /** DocSearch button **/ + /* --custom-docsearch-searchbox-background: #f4f5f7; */ + + /** Hide extra scrollbars **/ + /** + --ifm-scrollbar-size: 0; + **/ + + /** Footer **/ + --custom-footer-border-color: #f4f5f7; + + /* Selection color */ + --custom-selection-color: #f4c9bc; +} + +/** Text selection color **/ +::selection { + background: var(--custom-selection-color); +} + +::-moz-selection { + background: var(--custom-selection-color); +} + +.mono { + font-family: var(--ifm-font-family-monospace); + font-size: 14px; +} + +/** Hide sidebar scrollbars **/ +nav.menu.thin-scrollbar::-webkit-scrollbar, +div.theme-doc-toc-desktop.thin-scrollbar::-webkit-scrollbar { + width: revert !important; + height: revert !important; +} +nav.menu.thin-scrollbar::-webkit-scrollbar-thumb, +div.theme-doc-toc-desktop.thin-scrollbar::-webkit-scrollbar-thumb { + background: revert !important; + border-radius: revert !important; +} +nav.menu.thin-scrollbar::-webkit-scrollbar-track, +div.theme-doc-toc-desktop.thin-scrollbar::-webkit-scrollbar-track { + background: revert !important; + border-radius: revert !important; +} + +:root[data-theme="dark"] { + /** DocSearch button **/ + /* --custom-docsearch-searchbox-background: #4d4d4d; */ + + /** Footer **/ + --custom-footer-border-color: #4d4d4d; + --custom-border-color: #1f2937; +} + +html[data-theme="dark"] { + --ifm-font-color-base: #ffffff; + --ifm-heading-color: #ffffff; + --ifm-background-color: #111827; + --custom-selection-color: var(--ifm-color-secondary-contrast-background); + --custom-code-block-selection-color: #334155; + --ifm-color-success-contrast-background: #0c4a6e; +} + +body { + font-feature-settings: "kern" 1; +} + +.navbar { + border-bottom: 1px solid var(--custom-border-color); + background-color: var(--ifm-background-color); +} + +.navbar__link { + font-weight: bold; +} +.navbar__link svg:last-child { + /** Hide external link icon **/ + display: none; +} + +/** Navbar: resize dark mode button **/ +.navbar__items svg[class^="lightToggleIcon_node_"] { + width: 32px; + height: 32px; +} + +.navbar__items svg[class^="darkToggleIcon_node_"] { + width: 32px; + height: 32px; +} + +/** Sidebar **/ +nav.menu { + padding: var(--ifm-navbar-padding-horizontal); + border-right: 1px solid var(--custom-border-color); +} + +/** Sidebar: hide non-collapsable toggle **/ +nav.menu > ul.menu__list > li > div.menu__list-item-collapsible > a:after { + display: none; + border-bottom: 1px solid var(--custom-border-color); +} + +nav.menu + > ul.menu__list + > li + > div.menu__list-item-collapsible + > a:first-child { + opacity: 0.4; + font-size: 0.85em; + font-weight: 700; + text-transform: uppercase; + border: none; +} +nav.menu + > ul.menu__list + > li + > div.menu__list-item-collapsible + > a.menu__link--active { + color: var(--ifm-menu-color); +} +nav.menu div.menu__list-item-collapsible:hover { + background: none; +} +nav.menu + > ul.menu__list + > li + > div.menu__list-item-collapsible + .menu__link:hover { + color: var(--ifm-menu-color); +} +nav.menu > ul > li:not(:last-child) { + margin-bottom: var(--ifm-spacing-vertical); +} +.theme-doc-sidebar-menu > li > .menu__list { + padding-left: 0; +} +.menu__list-item:not(:first-child) { + margin-top: 5px; +} +.menu__link { + font-size: 0.9em; + line-height: 1.1; + transition: color 0.3s; + border-left: 2px solid transparent; + outline: none; +} + +.menu__link:hover, +.menu__link--active:not(.menu__link--sublist-caret) { + color: var(--ifm-color-primary-lighter); + background: none; + border-left: 2px solid var(--ifm-color-primary-lightest); + border-radius: 0; +} + +.menu__caret:hover, +.menu__list-item-collapsible--active { + background: none; +} + +.menu__link--active:not(.menu__link--sublist) { +} + +.menu__caret::before, +.menu__link--sublist-caret:after { + width: 1rem; + height: 1rem; + opacity: 0.9; + background: var(--ifm-menu-link-sublist-icon) 50% / 1.25rem 1.25rem; +} + +/** DocSearch button **/ +nav.navbar .DocSearch-Button { + border-radius: 8px; + background-color: var(--custom-docsearch-searchbox-background); + border: 1px solid var(--custom-border-color); + width: 15vw; + font-family: "Source Sans Pro", sans-serif; +} +nav.navbar .DocSearch-Button:hover { + border-color: inherit; + -webkit-box-shadow: none; + box-shadow: none; + color: var(--docsearch-muted-color); +} +nav.navbar .DocSearch-Button .DocSearch-Search-Icon { + width: 14px; + height: 14px; + color: var(--docsearch-muted-color); +} +nav.navbar .DocSearch-Button .DocSearch-Button-Placeholder { + font-size: 0.9rem; + padding-right: 2px; + font-weight: normal; +} +nav.navbar .DocSearch-Button .DocSearch-Button-Keys { + display: none; +} + +/* mobile sidebar */ +.navbar-sidebar { + background-color: var(--ifm-background-color); +} + +/** Announcement bar **/ +div[class^="announcementBar_"] { + height: 42px; +} +div[class^="announcementBar_"] > div { + padding: 7px 0; + font-size: 90%; +} +div[class^="announcementBar_"] > div a { + font-weight: 600; + text-decoration: none; +} +div[class^="announcementBar_"] > div a:hover { + color: #f4ece8; +} +div[class^="announcementBar_"] > div span.icon { + margin-left: 3px; + vertical-align: -1px; + background: url("/img/star.svg") no-repeat; + display: inline-block; + width: 14px; + height: 14px; +} +div[class^="announcementBar_"] > button.close { + color: #ffffff; +} + +/** Dark mode switch **/ +nav.navbar div[class^="toggleTrack_node"] { + background-color: var(--custom-color-black); +} +nav.navbar span[class^="toggleIcon"] { + visibility: hidden; +} + +.docusaurus-highlight-code-line { + background-color: rgb(72, 77, 91); + display: block; + margin: 0 calc(-1 * var(--ifm-pre-padding)); + padding: 0 var(--ifm-pre-padding); +} + +div[class^="codeBlockContainer_"] { + box-shadow: none; +} + +/** Admonitions **/ +.admonition { + border: none; + box-shadow: none; +} +.admonition-icon svg { + width: 16px; + height: 16px; + opacity: 0.8; + vertical-align: -1px; +} + +/** Markdown styles **/ +.markdown h1:first-child { + --ifm-h1-font-size: 2.6rem; + font-weight: 600; + letter-spacing: -1px; +} +.markdown h2 { + font-weight: 600; + --ifm-h2-font-size: 1.8rem; +} +.markdown h3 { + font-weight: 600; +} +.markdown code { + border: none; +} +.markdown .hash-link:focus, +.markdown *:hover > .hash-link { + opacity: 0.6; +} +.hash-link:hover { + text-decoration: none; + color: var(--ifm-color-primary); +} +div.theme-code-block > div[class^="codeBlockTitle"] { + font-weight: 700; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); +} +html[data-theme="dark"] div.theme-code-block > div[class^="codeBlockTitle"] { + border-color: rgba(255, 255, 255, 0.1); +} + +/** Table of Contents **/ +div[class^="tableOfContents"] a.table-of-contents__link code { + border: 1px solid rgba(0, 0, 0, 0.05); +} + +.alert h5 { + color: var(--ifm-alert-color); +} + +.footer { + border-top: 2px solid var(--custom-footer-border-color); + background-color: var(--ifm-background-color); +} +.footer__title { + opacity: 0.75; + font-size: 0.9em; + font-weight: 700; + text-transform: uppercase; +} +.footer .footer__item a svg { + display: none; +} + +/** Breadcrumb **/ +.theme-doc-breadcrumbs { + display: none; +} + +/** Navbar icons **/ +.navbar__link__slack, +.navbar__link__github { + transition: 0.3s; +} + +.navbar__link__slack:hover, +.navbar__link__github:hover { + opacity: 0.8; +} + +/* Theme toggle */ +svg[class^="lightToggleIcon_"], +svg[class^="darkToggleIcon_"] { + width: 23px; + height: 23px; +} + +div[class^="toggle_"] { + width: 23px !important; + height: 23px !important; + margin: 0 10px !important; +} + +.navbar__link__slack:before { + content: ""; + width: 20px; + height: 20px; + display: flex; + background: url("data:image/svg+xml,%0A%3Csvg width='20' height='20' viewBox='0 0 71 55' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0)'%3E%3Cpath d='M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z' fill='%2323272A'/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0'%3E%3Crect width='71' height='55' fill='white'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E%0A") + no-repeat; +} +html[data-theme="dark"] .navbar__link__slack:before { + background: url("data:image/svg+xml,%0A%3Csvg width='20' height='20' viewBox='0 0 71 55' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0)'%3E%3Cpath d='M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z' fill='%23ffffff'/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0'%3E%3Crect width='71' height='55' fill='white'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E%0A") + no-repeat; +} +.navbar__link__github:before { + content: ""; + width: 20px; + height: 20px; + display: flex; + background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 0C14.1771 0 16.1849 0.536458 18.0234 1.60938C19.862 2.68229 21.3177 4.13802 22.3906 5.97656C23.4635 7.8151 24 9.82292 24 12C24 14.6146 23.237 16.9661 21.7109 19.0547C20.1849 21.1432 18.2135 22.5885 15.7969 23.3906C15.5156 23.4427 15.3073 23.4062 15.1719 23.2812C15.0365 23.1562 14.9688 23 14.9688 22.8125C14.9688 22.7812 14.9714 22.3828 14.9766 21.6172C14.9818 20.8516 14.9844 20.151 14.9844 19.5156C14.9844 18.5052 14.7135 17.7656 14.1719 17.2969C14.7656 17.2344 15.2995 17.1406 15.7734 17.0156C16.2474 16.8906 16.737 16.6875 17.2422 16.4062C17.7474 16.125 18.1693 15.7786 18.5078 15.3672C18.8464 14.9557 19.1224 14.4089 19.3359 13.7266C19.5495 13.0443 19.6562 12.2604 19.6562 11.375C19.6562 10.1354 19.2448 9.0625 18.4219 8.15625C18.8073 7.20833 18.7656 6.14583 18.2969 4.96875C18.0052 4.875 17.5833 4.93229 17.0312 5.14062C16.4792 5.34896 16 5.57812 15.5938 5.82812L15 6.20312C14.0312 5.93229 13.0312 5.79688 12 5.79688C10.9688 5.79688 9.96875 5.93229 9 6.20312C8.83333 6.08854 8.61198 5.94792 8.33594 5.78125C8.0599 5.61458 7.625 5.41406 7.03125 5.17969C6.4375 4.94531 5.99479 4.875 5.70312 4.96875C5.23438 6.14583 5.19271 7.20833 5.57812 8.15625C4.75521 9.0625 4.34375 10.1354 4.34375 11.375C4.34375 12.2604 4.45052 13.0417 4.66406 13.7188C4.8776 14.3958 5.15104 14.9427 5.48438 15.3594C5.81771 15.776 6.23698 16.125 6.74219 16.4062C7.2474 16.6875 7.73698 16.8906 8.21094 17.0156C8.6849 17.1406 9.21875 17.2344 9.8125 17.2969C9.40625 17.6719 9.15104 18.2083 9.04688 18.9062C8.82812 19.0104 8.59375 19.0885 8.34375 19.1406C8.09375 19.1927 7.79688 19.2188 7.45312 19.2188C7.10938 19.2188 6.76823 19.1068 6.42969 18.8828C6.09115 18.6589 5.80208 18.3333 5.5625 17.9062C5.36458 17.5729 5.11198 17.3021 4.80469 17.0938C4.4974 16.8854 4.23958 16.7604 4.03125 16.7188L3.71875 16.6719C3.5 16.6719 3.34896 16.6953 3.26562 16.7422C3.18229 16.7891 3.15625 16.849 3.1875 16.9219C3.21875 16.9948 3.26562 17.0677 3.32812 17.1406C3.39062 17.2135 3.45833 17.276 3.53125 17.3281L3.64062 17.4062C3.86979 17.5104 4.09635 17.7083 4.32031 18C4.54427 18.2917 4.70833 18.5573 4.8125 18.7969L4.96875 19.1562C5.10417 19.5521 5.33333 19.8724 5.65625 20.1172C5.97917 20.362 6.32812 20.5182 6.70312 20.5859C7.07812 20.6536 7.4401 20.6901 7.78906 20.6953C8.13802 20.7005 8.42708 20.6823 8.65625 20.6406L9.01562 20.5781C9.01562 20.974 9.01823 21.4349 9.02344 21.9609C9.02865 22.487 9.03125 22.7708 9.03125 22.8125C9.03125 23 8.96354 23.1562 8.82812 23.2812C8.69271 23.4062 8.48438 23.4427 8.20312 23.3906C5.78646 22.5885 3.8151 21.1432 2.28906 19.0547C0.763021 16.9661 0 14.6146 0 12C0 9.82292 0.536458 7.8151 1.60938 5.97656C2.68229 4.13802 4.13802 2.68229 5.97656 1.60938C7.8151 0.536458 9.82292 0 12 0ZM4.54688 17.2344C4.57812 17.1615 4.54167 17.099 4.4375 17.0469C4.33333 17.0156 4.26562 17.026 4.23438 17.0781C4.20312 17.151 4.23958 17.2135 4.34375 17.2656C4.4375 17.3281 4.50521 17.3177 4.54688 17.2344ZM5.03125 17.7656C5.10417 17.7135 5.09375 17.6302 5 17.5156C4.89583 17.4219 4.8125 17.4062 4.75 17.4688C4.67708 17.5208 4.6875 17.6042 4.78125 17.7188C4.88542 17.8229 4.96875 17.8385 5.03125 17.7656ZM5.5 18.4688C5.59375 18.3958 5.59375 18.2969 5.5 18.1719C5.41667 18.0365 5.32812 18.0052 5.23438 18.0781C5.14062 18.1302 5.14062 18.224 5.23438 18.3594C5.32812 18.4948 5.41667 18.5312 5.5 18.4688ZM6.15625 19.125C6.23958 19.0417 6.21875 18.9427 6.09375 18.8281C5.96875 18.7031 5.86458 18.6875 5.78125 18.7812C5.6875 18.8646 5.70833 18.9635 5.84375 19.0781C5.96875 19.2031 6.07292 19.2188 6.15625 19.125ZM7.04688 19.5156C7.07812 19.401 7.01042 19.3177 6.84375 19.2656C6.6875 19.224 6.58854 19.2604 6.54688 19.375C6.50521 19.4896 6.57292 19.5677 6.75 19.6094C6.90625 19.6719 7.00521 19.6406 7.04688 19.5156ZM8.03125 19.5938C8.03125 19.4583 7.94271 19.401 7.76562 19.4219C7.59896 19.4219 7.51562 19.4792 7.51562 19.5938C7.51562 19.7292 7.60417 19.7865 7.78125 19.7656C7.94792 19.7656 8.03125 19.7083 8.03125 19.5938ZM8.9375 19.4375C8.91667 19.3229 8.82292 19.276 8.65625 19.2969C8.48958 19.3281 8.41667 19.4062 8.4375 19.5312C8.45833 19.6562 8.55208 19.6979 8.71875 19.6562C8.88542 19.6146 8.95833 19.5417 8.9375 19.4375Z' fill='%23383736'/%3E%3C/svg%3E") + no-repeat; +} +.navbar__link__github:hover { + opacity: 0.8; +} +html[data-theme="dark"] .navbar__link__github:before { + background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 0C14.1771 0 16.1849 0.536458 18.0234 1.60938C19.862 2.68229 21.3177 4.13802 22.3906 5.97656C23.4635 7.8151 24 9.82292 24 12C24 14.6146 23.237 16.9661 21.7109 19.0547C20.1849 21.1432 18.2135 22.5885 15.7969 23.3906C15.5156 23.4427 15.3073 23.4062 15.1719 23.2812C15.0365 23.1562 14.9688 23 14.9688 22.8125C14.9688 22.7812 14.9714 22.3828 14.9766 21.6172C14.9818 20.8516 14.9844 20.151 14.9844 19.5156C14.9844 18.5052 14.7135 17.7656 14.1719 17.2969C14.7656 17.2344 15.2995 17.1406 15.7734 17.0156C16.2474 16.8906 16.737 16.6875 17.2422 16.4062C17.7474 16.125 18.1693 15.7786 18.5078 15.3672C18.8464 14.9557 19.1224 14.4089 19.3359 13.7266C19.5495 13.0443 19.6562 12.2604 19.6562 11.375C19.6562 10.1354 19.2448 9.0625 18.4219 8.15625C18.8073 7.20833 18.7656 6.14583 18.2969 4.96875C18.0052 4.875 17.5833 4.93229 17.0312 5.14062C16.4792 5.34896 16 5.57812 15.5938 5.82812L15 6.20312C14.0312 5.93229 13.0312 5.79688 12 5.79688C10.9688 5.79688 9.96875 5.93229 9 6.20312C8.83333 6.08854 8.61198 5.94792 8.33594 5.78125C8.0599 5.61458 7.625 5.41406 7.03125 5.17969C6.4375 4.94531 5.99479 4.875 5.70312 4.96875C5.23438 6.14583 5.19271 7.20833 5.57812 8.15625C4.75521 9.0625 4.34375 10.1354 4.34375 11.375C4.34375 12.2604 4.45052 13.0417 4.66406 13.7188C4.8776 14.3958 5.15104 14.9427 5.48438 15.3594C5.81771 15.776 6.23698 16.125 6.74219 16.4062C7.2474 16.6875 7.73698 16.8906 8.21094 17.0156C8.6849 17.1406 9.21875 17.2344 9.8125 17.2969C9.40625 17.6719 9.15104 18.2083 9.04688 18.9062C8.82812 19.0104 8.59375 19.0885 8.34375 19.1406C8.09375 19.1927 7.79688 19.2188 7.45312 19.2188C7.10938 19.2188 6.76823 19.1068 6.42969 18.8828C6.09115 18.6589 5.80208 18.3333 5.5625 17.9062C5.36458 17.5729 5.11198 17.3021 4.80469 17.0938C4.4974 16.8854 4.23958 16.7604 4.03125 16.7188L3.71875 16.6719C3.5 16.6719 3.34896 16.6953 3.26562 16.7422C3.18229 16.7891 3.15625 16.849 3.1875 16.9219C3.21875 16.9948 3.26562 17.0677 3.32812 17.1406C3.39062 17.2135 3.45833 17.276 3.53125 17.3281L3.64062 17.4062C3.86979 17.5104 4.09635 17.7083 4.32031 18C4.54427 18.2917 4.70833 18.5573 4.8125 18.7969L4.96875 19.1562C5.10417 19.5521 5.33333 19.8724 5.65625 20.1172C5.97917 20.362 6.32812 20.5182 6.70312 20.5859C7.07812 20.6536 7.4401 20.6901 7.78906 20.6953C8.13802 20.7005 8.42708 20.6823 8.65625 20.6406L9.01562 20.5781C9.01562 20.974 9.01823 21.4349 9.02344 21.9609C9.02865 22.487 9.03125 22.7708 9.03125 22.8125C9.03125 23 8.96354 23.1562 8.82812 23.2812C8.69271 23.4062 8.48438 23.4427 8.20312 23.3906C5.78646 22.5885 3.8151 21.1432 2.28906 19.0547C0.763021 16.9661 0 14.6146 0 12C0 9.82292 0.536458 7.8151 1.60938 5.97656C2.68229 4.13802 4.13802 2.68229 5.97656 1.60938C7.8151 0.536458 9.82292 0 12 0ZM4.54688 17.2344C4.57812 17.1615 4.54167 17.099 4.4375 17.0469C4.33333 17.0156 4.26562 17.026 4.23438 17.0781C4.20312 17.151 4.23958 17.2135 4.34375 17.2656C4.4375 17.3281 4.50521 17.3177 4.54688 17.2344ZM5.03125 17.7656C5.10417 17.7135 5.09375 17.6302 5 17.5156C4.89583 17.4219 4.8125 17.4062 4.75 17.4688C4.67708 17.5208 4.6875 17.6042 4.78125 17.7188C4.88542 17.8229 4.96875 17.8385 5.03125 17.7656ZM5.5 18.4688C5.59375 18.3958 5.59375 18.2969 5.5 18.1719C5.41667 18.0365 5.32812 18.0052 5.23438 18.0781C5.14062 18.1302 5.14062 18.224 5.23438 18.3594C5.32812 18.4948 5.41667 18.5312 5.5 18.4688ZM6.15625 19.125C6.23958 19.0417 6.21875 18.9427 6.09375 18.8281C5.96875 18.7031 5.86458 18.6875 5.78125 18.7812C5.6875 18.8646 5.70833 18.9635 5.84375 19.0781C5.96875 19.2031 6.07292 19.2188 6.15625 19.125ZM7.04688 19.5156C7.07812 19.401 7.01042 19.3177 6.84375 19.2656C6.6875 19.224 6.58854 19.2604 6.54688 19.375C6.50521 19.4896 6.57292 19.5677 6.75 19.6094C6.90625 19.6719 7.00521 19.6406 7.04688 19.5156ZM8.03125 19.5938C8.03125 19.4583 7.94271 19.401 7.76562 19.4219C7.59896 19.4219 7.51562 19.4792 7.51562 19.5938C7.51562 19.7292 7.60417 19.7865 7.78125 19.7656C7.94792 19.7656 8.03125 19.7083 8.03125 19.5938ZM8.9375 19.4375C8.91667 19.3229 8.82292 19.276 8.65625 19.2969C8.48958 19.3281 8.41667 19.4062 8.4375 19.5312C8.45833 19.6562 8.55208 19.6979 8.71875 19.6562C8.88542 19.6146 8.95833 19.5417 8.9375 19.4375Z' fill='white'/%3E%3C/svg%3E") + no-repeat; +} + +.docusaurus-highlight-code-line { + background-color: var(--custom-code-block-selection-color); +} + +/* Styles for detail tag */ +details[class^="details_"] { + border: none; + box-shadow: none; +} +details[class^="details_"] > div > div > *:last-child { + /* Fix bottom margin for content */ + margin-bottom: 0; +} +details[class^="details_"] > summary { + text-transform: uppercase; + font-size: var(--ifm-h5-font-size); + font-weight: var(--ifm-heading-font-weight); +} + +/* mobile */ +@media screen and (max-width: 996px) { + :root { + --ifm-font-size-base: 1.1rem; + } + nav.navbar .DocSearch-Button { + width: auto; + } + .menu__link { + font-size: 1em; + } + div[class^="announcementBar_"] > div { + font-size: 80%; + } +} diff --git a/www/src/custom.css b/www/src/custom.css deleted file mode 100644 index 9c0f4ec564..0000000000 --- a/www/src/custom.css +++ /dev/null @@ -1,502 +0,0 @@ -:root { - --hue: 240; - --sat: 28%; - - --content-width: 58.75rem; - - --sl-font: 'Rubik Variable'; - --sl-font-mono: 'IBM Plex Mono'; - --__sl-font-headings: 'Roboto Mono Variable', var(--sl-font-system-mono); - - --sl-line-height: 1.8; - - --sl-text-code: 0.9375rem; - --sl-text-code-sm: 0.8125rem; - --sl-text-code-xs: 0.6875rem; - - --sl-mobile-toc-height: 3.5rem; - - --border-radius: 4px; - --icon-opacity: 0.85; - - --sl-text-h1: 2.5rem; - --sl-text-h2: 1.875rem; - --sl-text-h3: 1.5rem; - --sl-text-h4: 1.125rem; - --sl-text-h5: 1rem; - - --sl-nav-pad-x: 1rem; - - --sl-content-width: var(--content-width); - - --tsdoc-key-margin-right: 0.25rem; - - --search-button-height: 2.25rem; - - --color-transition: 0.25s ease; - - --paragraph-spacing: 1.5rem; -} - -@media (min-width: 72rem) { - :root { - --sl-mobile-toc-height: 0rem; - } -} - -/* Dark mode colors. */ -:root { - --sl-color-accent-low: hsl(198, 39%, 27%); - --sl-color-accent: hsl(198, 39%, 56%); - --sl-color-accent-high: hsl(198, 39%, 84%); - --sl-color-white: #FFFFFF; - --sl-color-gray-1: hsl(var(--hue), var(--sat), 93%); - --sl-color-gray-2: hsl(var(--hue), var(--sat), 87%); - --sl-color-gray-3: hsl(var(--hue), var(--sat), 59%); - --sl-color-gray-4: hsl(var(--hue), var(--sat), 39%); - --sl-color-gray-5: hsl(var(--hue), var(--sat), 26%); - --sl-color-gray-6: hsl(var(--hue), var(--sat), 19%); - --sl-color-black: hsl(var(--hue), var(--sat), 14%); - --sl-color-black-alpha: hsla(var(--hue), var(--sat), 14%, 80%); - - --sl-color-text-accent: var(--sl-color-accent); - - --sl-color-bg-sidebar: var(--sl-color-bg); - - --divider-color: var(--sl-color-gray-5); - --list-marker-color: var(--sl-color-gray-4); - - --sl-color-border-code: var(--sl-color-gray-5); - - --sl-color-hairline: var(--sl-color-gray-5); - - --sl-color-bg-nav: var(--sl-color-black-alpha); - - --sl-color-text: var(--sl-color-gray-2); - --color-text: var(--sl-color-text); - --color-text-secondary: hsla(var(--hue), var(--sat), 87%, 60%); - --color-text-dimmed: hsla(var(--hue), var(--sat), 87%, 38%); - - --color-text-highlight: hsl(13, 88%, 58%); - - --fade-gradient: linear-gradient( - hsla(var(--hue), var(--sat), 14%, 1) 0%, - hsla(var(--hue), var(--sat), 14%, 0.8) 50%, - hsla(var(--hue), var(--sat), 14%, 0) 100% - ); - - --sl-shadow-lg: - 0 2px 10px rgba(0, 0, 0, 0.1), - 0 8px 20px rgba(0, 0, 0, 0.1), - 0 16px 40px rgba(0, 0, 0, 0.1), - 0 32px 80px rgba(0, 0, 0, 0.15), - 0 48px 120px rgba(0, 0, 0, 0.15); - --sl-shadow-md: - 0 1px 1px hsla(0, 0, 0, 0.075), - 0 2px 2px hsla(0, 0, 0, 0.075), - 0 4px 4px hsla(0, 0, 0, 0.075), - 0 8px 8px hsla(0, 0, 0, 0.075), - 0 10px 10px hsla(0, 0, 0, 0.075); - - --dialog-background-color: hsla(var(--hue), var(--sat), 18%, 93%); - --sl-color-backdrop-overlay: hsla(var(--hue), var(--sat), 14%, 50%); -} -/* Light mode colors. */ -:root[data-theme='light'] { - --sl-color-accent-low: hsl(198, 39%, 84%); - --sl-color-accent: hsl(198, 39%, 51%); - --sl-color-accent-high: hsl(198, 39%, 27%); - --sl-color-white: hsl(var(--hue), var(--sat), 14%); - --sl-color-gray-1: hsl(var(--hue), var(--sat), 19%); - --sl-color-gray-2: hsl(var(--hue), var(--sat), 26%); - --sl-color-gray-3: hsl(var(--hue), var(--sat), 39%); - --sl-color-gray-4: hsl(var(--hue), var(--sat), 59%); - --sl-color-gray-5: hsl(var(--hue), var(--sat), 81%); - --sl-color-gray-6: hsl(var(--hue), var(--sat), 93%); - --sl-color-gray-7: hsl(var(--hue), var(--sat), 98%); - --sl-color-black: hsl(255, 100%, 100%); - --sl-color-black-alpha: hsl(255, 100%, 100%, 80%); - - --sl-color-bg-sidebar: var(--sl-color-bg); - - --sl-color-border-code: var(--sl-color-gray-6); - - --sl-color-hairline: var(--sl-color-gray-6); - - --sl-color-bg-nav: var(--sl-color-black-alpha); - - --divider-color: var(--sl-color-gray-6); - --list-marker-color: var(--sl-color-gray-5); - - --sl-color-text: var(--sl-color-gray-2); - --color-text: var(--sl-color-text); - --color-text-secondary: hsla(var(--hue), var(--sat), 14%, 60%); - --color-text-dimmed: hsla(var(--hue), var(--sat), 14%, 38%); - - --color-text-highlight: hsl(13, 88%, 60%); - - --fade-gradient: linear-gradient( - #FFFFFF 0%, - hsla(0, 0%, 100%, 0.8) 50%, - hsla(0, 0%, 100%, 0) 100% - ); - - --sl-shadow-lg: - 0 2px 4px hsla(var(--hue), var(--sat), 10%, 0.05), - 0 4px 8px hsla(var(--hue), var(--sat), 10%, 0.05), - 0 8px 16px hsla(var(--hue), var(--sat), 10%, 0.07), - 0 16px 32px hsla(var(--hue), var(--sat), 10%, 0.07), - 0 32px 64px hsla(var(--hue), var(--sat), 10%, 0.07), - 0 48px 96px hsla(var(--hue), var(--sat), 10%, 0.07); - --sl-shadow-md: - 0 1px 1px hsla(var(--hue), var(--sat), 10%, 0.01), - 0 2px 2px hsla(var(--hue), var(--sat), 10%, 0.01), - 0 4px 4px hsla(var(--hue), var(--sat), 10%, 0.01), - 0 8px 8px hsla(var(--hue), var(--sat), 10%, 0.01), - 0 10px 10px hsla(var(--hue), var(--sat), 10%, 0.01); - - --dialog-background-color: hsl(0, 0%, 97%, 0.93); - --sl-color-backdrop-overlay: hsla(var(--hue), var(--sat), 14%, 3%); -} - -body { - -webkit-font-smoothing: auto; -} - -a { - transition: color var(--color-transition); -} -h1, h2, h3 { - font-family: var(--__sl-font-headings); - letter-spacing: -1px; - font-weight: 500; -} -h4, h5, h6 { - font-family: var(--__sl-font-headings); - letter-spacing: -0.5px; - font-weight: 500; -} - -/** - * Header - */ -body > .page > header { - background-color: var(--sl-color-black-alpha); - backdrop-filter: blur(8px); - -webkit-backdrop-filter: blur(8px); - border-color: var(--sl-color-hairline); -} -@media (min-width: 50rem) { - body > .page > header, - :root[data-has-sidebar] body > .page > header { - padding-inline-end: var(--sl-nav-pad-y); - } -} -body > .page > header a.site-title { - cursor: pointer; -} -body > .page > header a.site-title img { - height: 1.5rem; -} -@media (max-width: 30rem) { - body > .page > header a.site-title img { - height: 1.625rem; - } -} -/* Search button */ -body > .page > header button[data-open-modal] { - border-radius: 0 var(--border-radius) var(--border-radius) 0; - border-color: var(--sl-color-hairline); - height: var(--search-button-height); - padding-inline-start: 10px; - padding-inline-end: 9px; - font-size: var(--sl-text-xs); - color: var(--color-text-secondary); - gap: 0.4375rem; - background-color: var(--sl-color-black-alpha); - line-height: normal; -} -body > .page > header button[data-open-modal] > kbd { - background-color: transparent; - padding-inline-end: 0; -} -body > .page > header button[data-open-modal] > kbd kbd { - line-height: 1; - color: var(--color-text-dimmed); -} -/* Social icons */ -body > .page > nav .social-icons a, -body > .page > header .social-icons a { - color: var(--color-text-secondary); - opacity: var(--icon-opacity); -} -body > .page > nav .social-icons a:hover, -body > .page > header .social-icons a:hover { - color: var(--sl-color-text-accent); - opacity: 1; -} -body > .page > nav .social-icons a svg, -body > .page > header .social-icons a svg { -} -/* Mobile nav button */ -body > .page > nav starlight-menu-button button { - background-color: var(--divider-color); - color: var(--color-text); - box-shadow: none; -} -[data-theme="light"] starlight-menu-button[aria-expanded=true] button { - background-color: var(--sl-color-gray-5); -} -[data-theme="dark"] starlight-menu-button[aria-expanded=true] button { - background-color: var(--sl-color-gray-4); -} - - -/** - * Sidebar - */ -@media (min-width: 50rem) { - nav.sidebar .sidebar-content { - padding-top: 1.25rem; - } - .sidebar-pane:after { - content: ""; - position: fixed; - top: var(--sl-nav-height); - margin-right: 1px; - pointer-events: none; - height: 2rem; - /* Account for scrollbar */ - width: calc(var(--sl-sidebar-width) - 12px); - background: var(--fade-gradient); - } -} -nav.sidebar .sidebar-pane { - border-color: var(--sl-color-hairline); - padding-top: 0; -} -nav.sidebar .sidebar-pane > .sidebar-content { - scrollbar-width: thin; -} -nav.sidebar .sidebar-pane > .sidebar-content::-webkit-scrollbar { - display: none; -} -nav.sidebar ul { - --sl-sidebar-item-padding-inline: 0.3125rem; -} -nav.sidebar ul > li { - border-inline-start: none; -} -nav.sidebar ul.top-level > li > a, -nav.sidebar ul.top-level > li > details > summary, -nav.sidebar ul.top-level > li > details > ul > li { - padding-inline-start: 0; -} -nav.sidebar ul.top-level ul { -} -nav.sidebar ul > li + li { - margin-top: 0.25rem; -} -nav.sidebar ul.top-level > li > a { -} -nav.sidebar ul.top-level > li+li:has(> details) { - margin-top: 0.5rem; - margin-bottom: 0.5rem; -} -nav.sidebar summary { - padding-bottom: 0; - margin-bottom: 0.5rem; -} -nav.sidebar a { - font-size: var(--sl-text-sm); -} -nav.sidebar a.large, -nav.sidebar span.large { - font-size: var(--sl-text-sm); - font-weight: 400; - color: var(--sl-color-gray-2); -} -nav.sidebar a:hover, -nav.sidebar a.large:hover { - color: var(--sl-color-text-accent); -} -nav.sidebar ul.top-level > li > details > summary .group-label > span { - font-weight: 600; - text-transform: uppercase; - font-family: var(--__sl-font-mono); - font-size: var(--sl-text-code-sm); - letter-spacing: 0.5px; - color: var(--sl-color-white); -} -nav.sidebar summary svg.caret { - color: var(--color-text-dimmed); -} -nav.sidebar a[aria-current=page], -nav.sidebar a[aria-current=page]:hover, -nav.sidebar a[aria-current=page]:focus { - font-weight: 500; - background-color: transparent; - color: var(--color-text-highlight); -} - -/** - * Right sidebar - */ -@media (min-width: 72rem) { - .right-sidebar-container { - width: max( - calc(var(--sl-sidebar-width) + (100% - var(--sl-content-width) - var(--sl-sidebar-width)) / 2), var(--sl-sidebar-width)); - } - .right-sidebar-container:after { - content: ""; - position: fixed; - top: var(--sl-nav-height); - margin-left: 1px; - width: 100%; - pointer-events: none; - height: 2rem; - background: var(--fade-gradient); - } - .right-sidebar { - top: var(--sl-nav-height); - border-color: var(--sl-color-hairline); - padding-top: 0; - height: calc(100vh - var(--sl-nav-height)); - } - .right-sidebar-panel { - /* Padding to align with main sidebar */ - padding-bottom: 1.625rem; - } -} -.right-sidebar-panel h2 { - /* Margin to align with main sidebar */ - margin-top: 0.625rem; - font-weight: 600; - color: var(--color-text-dimmed); - text-transform: uppercase; - font-family: var(--__sl-font-mono); - font-size: var(--sl-text-code-sm); - line-height: 1.4; - letter-spacing: -0.5px; -} - -.right-sidebar-panel a { - --pad-inline: 0px; -} -.right-sidebar-panel a { - color: var(--color-text-dimmed); -} -.right-sidebar-panel a:hover { - color: var(--sl-color-text); -} -.right-sidebar-panel a[aria-current=true], -.right-sidebar-panel a[aria-current=true]:hover, -.right-sidebar-panel a[aria-current=true]:focus { - background-color: transparent; - color: var(--sl-color-text); - font-weight: normal; -} -/* Mobile nav */ -mobile-starlight-toc nav { - backdrop-filter: blur(8px); - -webkit-backdrop-filter: blur(8px); - border-top: none; -} -mobile-starlight-toc nav summary { - gap: 0.75rem; - border-bottom: 1px solid var(--sl-color-hairline); -} -mobile-starlight-toc nav summary .toggle { - border-radius: var(--border-radius); - height: 2rem; - background-color: transparent; - color: var(--color-text); - transition: border-color, color var(--color-transition); -} -mobile-starlight-toc nav summary .toggle:hover { - border-color: var(--sl-color-accent); -} -mobile-starlight-toc nav summary .toggle svg { - opacity: var(--icon-opacity); -} -mobile-starlight-toc nav .dropdown { - border: none; - background-color: transparent; - border-bottom: 1px solid var(--sl-color-hairline); -} -mobile-starlight-toc nav .dropdown a { - border-color: var(--divider-color); -} -mobile-starlight-toc nav .dropdown a[aria-current=true] { - font-weight: 500; -} - -/** - * Content - */ -@media (min-width: 72rem) { - /* Expand no sidebar case */ - .main-frame > div > .main-pane:only-child { - --sl-content-width: calc(var(--content-width) + 2 * var(--sl-content-pad-x) + var(--sl-sidebar-width)); - } - .main-frame > div > .main-pane { - min-width: 0; - } - body > .page > .main-frame .main-pane > main > .content-panel .sl-container { - margin-inline: auto; - } -} - -/** - * Search dialog - */ -dialog[aria-label='Search'] { - border: none; - border-radius: 10px; - background-color: var(--dialog-background-color); -} -dialog[aria-label='Search'][open] { - animation: fadeInScaleUp 0.2s ease forwards; -} -dialog[aria-label='Search']::backdrop { - backdrop-filter: blur(2px); - -webkit-backdrop-filter: blur(2px); - background-color: hsla(240, 28%, 14%, 0.5); - animation: fadeInBackdrop 0.2s ease forwards; -} -@media (prefers-color-scheme: light) { - dialog[aria-label='Search']::backdrop { - background-color: hsla(240, 28%, 14%, 0.03); - } -} -@keyframes fadeInScaleUp { - from { - opacity: 0; - transform: scale(0.9); - } - to { - opacity: 1; - transform: scale(1); - } -} -@keyframes fadeInBackdrop { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - -/** - * Ask AI dailog - */ -.mantine-Modal-content { - box-shadow: var(--sl-shadow-lg); -} -.mantine-Overlay-root { - opacity: 1; - background-color: var(--sl-color-backdrop-overlay); - backdrop-filter: blur(2px); - -webkit-backdrop-filter: blur(2px); -} diff --git a/www/src/env.d.ts b/www/src/env.d.ts deleted file mode 100644 index acef35f175..0000000000 --- a/www/src/env.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/www/src/pages/docs/[...slug].md.ts b/www/src/pages/docs/[...slug].md.ts deleted file mode 100644 index 0e714c5430..0000000000 --- a/www/src/pages/docs/[...slug].md.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { getCollection, getEntry } from "astro:content"; -import type { APIRoute } from "astro"; -import { cleanMarkdown } from "../../util/markdown"; - -export async function getStaticPaths() { - const docs = await getCollection("docs"); - return docs - .filter( - (doc) => - doc.id.startsWith("docs/") && - doc.id !== "docs/index.mdx" - ) - .map((doc) => ({ - params: { slug: doc.id.replace(/^docs\//, "").replace(/\.mdx?$/, "") }, - })); -} - -async function buildExamplesCatalog(): Promise { - const docs = await getCollection("docs"); - const examples = docs - .filter((doc) => doc.id.startsWith("docs/examples/")) - .sort((a, b) => a.id.localeCompare(b.id)); - - const lines = examples.map((doc) => { - const slug = doc.id.replace(/\.mdx?$/, "").replace(/^docs\//, ""); - return `- [${doc.data.title}](/docs/${slug}/)`; - }); - - return lines.join("\n"); -} - -export const GET: APIRoute = async ({ params }) => { - const slug = params.slug!; - const entry = await getEntry("docs", `docs/${slug}`); - if (!entry?.body) return new Response("Not found", { status: 404 }); - - let content: string; - if (slug === "examples") { - // Serve as a catalog of links to individual example pages - const catalog = await buildExamplesCatalog(); - content = `# ${entry.data.title} - -${entry.data.description || ""} - -Source: https://sst.dev/docs/${slug} - ---- - -${catalog}`; - } else { - const cleaned = cleanMarkdown(entry.body); - content = `# ${entry.data.title} - -${entry.data.description || ""} - -Source: https://sst.dev/docs/${slug} - ---- - -${cleaned}`; - } - - return new Response(content, { - headers: { - "Content-Type": "text/markdown; charset=utf-8", - "Cache-Control": "public,max-age=0,s-maxage=86400,stale-while-revalidate=86400", - }, - }); -}; diff --git a/www/src/pages/docs/index.md.ts b/www/src/pages/docs/index.md.ts deleted file mode 100644 index f3a5940c9d..0000000000 --- a/www/src/pages/docs/index.md.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { getEntry } from "astro:content"; -import type { APIRoute } from "astro"; -import { cleanMarkdown } from "../../util/markdown"; - -export const GET: APIRoute = async () => { - const entry = await getEntry("docs", "docs"); - if (!entry?.body) return new Response("Not found", { status: 404 }); - - const cleaned = cleanMarkdown(entry.body); - const markdown = `# ${entry.data.title} - -${entry.data.description || ""} - -Source: https://sst.dev/docs - ---- - -${cleaned}`; - - return new Response(markdown, { - headers: { - "Content-Type": "text/markdown; charset=utf-8", - "Cache-Control": "public,max-age=0,s-maxage=86400,stale-while-revalidate=86400", - }, - }); -}; diff --git a/www/src/pages/llms-full.txt.ts b/www/src/pages/llms-full.txt.ts deleted file mode 100644 index 29dc377eb8..0000000000 --- a/www/src/pages/llms-full.txt.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { getCollection } from "astro:content"; -import type { APIRoute } from "astro"; -import { cleanMarkdown } from "../util/markdown"; - -export const GET: APIRoute = async () => { - const docs = await getCollection("docs"); - const filtered = docs - .filter((doc) => doc.id.startsWith("docs/")) - .filter((doc) => doc.id.replace(/\.mdx?$/, "") !== "docs/examples") - .sort((a, b) => a.id.localeCompare(b.id)); - - const pages = filtered.map((doc) => { - const slug = doc.id.replace(/\.mdx?$/, ""); - const cleaned = cleanMarkdown(doc.body || ""); - return `## ${doc.data.title} - -${doc.data.description || ""} - -https://sst.dev/${slug} - -${cleaned}`; - }); - - const body = `# SST Documentation - -> The complete SST documentation for building full-stack applications on AWS and Cloudflare. - -${pages.join("\n\n---\n\n")} -`; - - return new Response(body, { - headers: { - "Content-Type": "text/plain; charset=utf-8", - "Cache-Control": "public,max-age=0,s-maxage=86400,stale-while-revalidate=86400", - }, - }); -}; diff --git a/www/src/pages/llms.txt.ts b/www/src/pages/llms.txt.ts deleted file mode 100644 index a010dba2a2..0000000000 --- a/www/src/pages/llms.txt.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { getCollection } from "astro:content"; -import type { APIRoute } from "astro"; - -export const GET: APIRoute = async () => { - const docs = await getCollection("docs"); - const filtered = docs - .filter((doc) => doc.id.startsWith("docs/")) - .filter((doc) => !doc.id.startsWith("docs/examples/")) - .sort((a, b) => a.id.localeCompare(b.id)); - - const links = filtered - .map((doc) => { - const slug = doc.id.replace(/\.mdx?$/, ""); - const description = doc.data.description || ""; - return `- [${doc.data.title}](https://sst.dev/${slug})${description ? `: ${description}` : ""}`; - }) - .join("\n"); - - const body = `# SST - -> SST is a framework for building full-stack apps on your own infrastructure with support for AWS, Cloudflare, and 150+ providers. - -## Docs - -${links} -`; - - return new Response(body, { - headers: { - "Content-Type": "text/plain; charset=utf-8", - "Cache-Control": "public,max-age=0,s-maxage=86400,stale-while-revalidate=86400", - }, - }); -}; diff --git a/www/src/styles/heading.css b/www/src/styles/heading.css deleted file mode 100644 index b249dfb7d7..0000000000 --- a/www/src/styles/heading.css +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Linkable headings - * - * Exclude links that are custom created, like the blog post list links. - */ -.sl-markdown-content :is(h1, h2, h3, h4, h5, h6) > a:not([class]) { - text-decoration: none; - cursor: none; - color: var(--color-text); - - & code { - color: var(--color-text); - } - - &:hover { - cursor: pointer; - text-decoration: none; - color: var(--color-text); - } - - &:hover::after { - content: '#'; - transform: scale(0.9); - transform-origin: left bottom; - display: inline-block; - margin-left: 0.25em; - color: var(--color-text-dimmed); - width: auto; - height: auto; - background-color: transparent; - font-weight: normal; - } -} diff --git a/www/src/styles/lander.css b/www/src/styles/lander.css deleted file mode 100644 index 49000fafa0..0000000000 --- a/www/src/styles/lander.css +++ /dev/null @@ -1,92 +0,0 @@ -:root[data-has-hero] { - --l-content-pad-x: 1.5rem; - --l-footer-height: 3rem; - - --l-min-content-height: calc( - 100vh - - var(--sl-nav-height) - - var(--l-footer-height) - ); -} -@media (max-width: 30rem) { - :root[data-has-hero] { - --l-content-pad-x: 1rem; - --l-footer-height: auto; - --l-min-content-height: 20rem; - } -} -:root[data-has-hero] { - --l-border-top-color: hsl(var(--hue), var(--sat), 24%); - --l-border-bottom-color: hsl(var(--hue), var(--sat), 20%); - --l-background-top-color: hsl(var(--hue), var(--sat), 17%); - --l-background-bottom-color: hsl(var(--hue), var(--sat), 15%); - - --l-code-inner-glow-color: rgba(255, 255, 255, 0.02); - - --l-code-shadow-color: 240deg 26% 6%; - --l-code-shadow: - 0px 1px 1.5px hsl(var(--l-code-shadow-color) / 0.04), - 0.1px 5.1px 7.7px hsl(var(--l-code-shadow-color) / 0.04), - 0.1px 8.6px 12.9px hsl(var(--l-code-shadow-color) / 0.04), - 0.1px 12px 18px hsl(var(--l-code-shadow-color) / 0.08), - 0.2px 15.7px 23.6px hsl(var(--l-code-shadow-color) / 0.08), - 0.2px 20.3px 30.5px hsl(var(--l-code-shadow-color) / 0.08), - 0.3px 26px 39px hsl(var(--l-code-shadow-color) / 0.08), - 0.3px 33.4px 50.1px hsl(var(--l-code-shadow-color) / 0.1), - 0.4px 42.9px 64.4px hsl(var(--l-code-shadow-color) / 0.1), - 0.6px 55px 82.5px hsl(var(--l-code-shadow-color) / 0.1); -} -:root[data-has-hero][data-theme='light'] { - --l-border-top-color: hsl(var(--hue), var(--sat), 95%); - --l-border-bottom-color: hsl(var(--hue), var(--sat), 92%); - --l-background-top-color: hsl(var(--hue), var(--sat), 99%); - --l-background-bottom-color: hsl(var(--hue), var(--sat), 98%); - - --l-code-inner-glow-color: rgba(255, 255, 255, 0.9); - --l-code-shadow-color: 0deg 0% 78%; - - --l-code-shadow: - 0px 1px 1.5px hsl(var(--l-code-shadow-color) / 0.04), - 0.1px 5.1px 7.7px hsl(var(--l-code-shadow-color) / 0.04), - 0.1px 8.6px 12.9px hsl(var(--l-code-shadow-color) / 0.04), - 0.1px 12px 18px hsl(var(--l-code-shadow-color) / 0.08), - 0.2px 15.7px 23.6px hsl(var(--l-code-shadow-color) / 0.08), - 0.2px 20.3px 30.5px hsl(var(--l-code-shadow-color) / 0.08), - 0.3px 26px 39px hsl(var(--l-code-shadow-color) / 0.08), - 0.3px 33.4px 50.1px hsl(var(--l-code-shadow-color) / 0.1), - 0.4px 42.9px 64.4px hsl(var(--l-code-shadow-color) / 0.1), - 0.6px 55px 82.5px hsl(var(--l-code-shadow-color) / 0.1); -} - -:root[data-has-hero] .main-pane > main, -:root[data-has-hero] .main-pane > main > .content-panel { - padding: 0; -} -:root[data-has-hero] .main-pane > main > .content-panel .sl-container { - max-width: none; -} -:root[data-has-hero] .main-pane > main > .content-panel .sl-markdown-content { - margin: 0; -} - -/* Footer */ -:root[data-has-hero] .main-pane > main > .content-panel footer.splash { - height: var(--l-footer-height); - padding-inline: var(--sl-nav-pad-x); -} - -/* 404 page */ -:root[data-has-hero] .main-pane > main > .content-panel div.hero { - padding: 0 var(--l-content-pad-x); - min-height: var(--l-min-content-height); - display: flex; - align-items: center; - justify-content: center; -} -:root[data-has-hero] .main-pane > main > .content-panel div.hero .copy { - align-items: flex-start; -} -:root[data-has-hero] .main-pane > main > .content-panel div.hero .tagline { - color: var(--color-text-secondary); - text-align: left; -} diff --git a/www/src/styles/markdown.css b/www/src/styles/markdown.css deleted file mode 100644 index 24d7474b2e..0000000000 --- a/www/src/styles/markdown.css +++ /dev/null @@ -1,345 +0,0 @@ -.sl-markdown-content strong:not(:where(.not-content *)) { - font-weight: 600; -} -/** - * Paragraphs - */ -.sl-markdown-content :not(a, strong, em, del, span, input, code) - + :not(a, strong, em, del, span, input, code, :where(.not-content *)) { - margin-top: var(--paragraph-spacing); -} -/* Space around asides and code blocks */ -.sl-markdown-content :not(a, strong, em, del, span, input, code) - + :is(.starlight-aside, .expressive-code) { - margin-top: calc(var(--paragraph-spacing) + 0.4375rem); -} -.sl-markdown-content :is(.starlight-aside, .expressive-code, table) - + :not(a, strong, em, del, span, input, code, h1, h2, h3, h4, h5, h6, :where(.not-content *)) { - margin-top: calc(var(--paragraph-spacing) + 0.5rem); -} -.sl-markdown-content :is(.starlight-aside, .expressive-code) - + :is(.starlight-aside, .expressive-code) { - margin-top: var(--paragraph-spacing); -} -/* Space around sections */ -.sl-markdown-content :not(h1, h2, h3, h4, h5, h6) - + :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)), -.sl-markdown-content :not(a, strong, em, del, span, input, code) - + hr:not(:where(.not-content *)), -.sl-markdown-content hr:not(:where(.not-content *)) + :not(a, strong, em, del, span, input, code, :where(.not-content *)) -{ - margin-top: calc(var(--paragraph-spacing) + 2rem); -} - -/** - * Headings - */ -.sl-markdown-content h2:not(:where(.not-content *)), -.sl-markdown-content h3:not(:where(.not-content *)) { - font-family: var(--__sl-font-headings); - letter-spacing: -1px; - font-weight: 500; -} -.sl-markdown-content h4:not(:where(.not-content *)), -.sl-markdown-content h5:not(:where(.not-content *)) { - font-family: var(--__sl-font-headings); - letter-spacing: -0.5px; - font-weight: 500; -} - -/** - * Asides - */ -.starlight-aside { - border: none; - border-radius: var(--border-radius); - padding: 0.9375rem 1rem 0.875rem; -} -.starlight-aside__title { - font-family: var(--__sl-font-mono); - text-transform: uppercase; - font-size: var(--sl-text-code-sm); - font-weight: 700; - letter-spacing: 0.5px; - gap: 0.4rem; -} -.starlight-aside__icon { - font-size: 0.875rem; - width: 0.8125rem; - height: 0.8125rem; - opacity: var(--icon-opacity); -} -.starlight-aside__title + .starlight-aside__content { - margin-top: 0.75rem; -} -.sl-markdown-content .starlight-aside__content { - font-size: var(--sl-text-code); -} -.sl-markdown-content .starlight-aside__content code:not(:where(.not-content *)) { - background-color: transparent; - font-size: var(--sl-text-code-sm); -} -.sl-markdown-content .starlight-aside a:not(:where(.not-content *)), -.sl-markdown-content .starlight-aside a:not(:where(.not-content *)):hover, -.sl-markdown-content .starlight-aside a:not(:where(.not-content *)) code, -.sl-markdown-content .starlight-aside a:not(:where(.not-content *)):hover code { - color: var(--sl-color-white); - text-decoration: underline; -} -.custom-aside-video .starlight-aside__title { - font-weight: normal; - font-family: var(--__sl-font); - font-size: var(--sl-text-sm); - text-transform: none; - letter-spacing: 0; - line-height: normal; - gap: 0.5rem; -} -.custom-aside-video .starlight-aside__title a { - text-decoration: none; - display: inline-flex; - align-items: center; - justify-content: center; -} -.custom-aside-video .starlight-aside__title a:hover { - text-decoration: underline; -} -.custom-aside-video .starlight-aside__title a svg { - opacity: 0.8; -} - -/** - * Blockquotes - */ - .sl-markdown-content blockquote:not(:where(.not-content *)) { - border-inline-start: 5px solid var(--divider-color); - padding-inline-start: 1rem; - font-size: var(--sl-text-h4); - color: var(--color-text-secondary); -} - -/** - * Links - */ -.sl-markdown-content a:not(:where(.not-content *)), -.sl-markdown-content a:not(:where(.not-content *)) code { - color: var(--sl-color-text-accent); - text-underline-offset: 0.1875rem; - text-decoration: none; -} -.sl-markdown-content a:hover:not(:where(.not-content *)) { - color: var(--sl-color-text-accent); - text-decoration: underline; -} - -/** - * Code blocks - */ -.sl-markdown-content .expressive-code .frame pre { - border-radius: var(--border-radius); -} -.sl-markdown-content .expressive-code .frame pre code { - font-size: var(--sl-text-sm); -} -/* Plain blocks */ -.sl-markdown-content .expressive-code .frame:not(.has-title):not(.is-terminal) pre { - border-color: var(--sl-color-border-code); -} -.sl-markdown-content .expressive-code .copy { - inset-block-start: calc(var(--ec-brdWd) + var(--button-spacing) + 0.1rem); -} -.sl-markdown-content .expressive-code .copy .feedback { - --tooltip-bg: var(--sl-color-gray-3); - - font-size: 0.75rem; - padding: 0.125rem 0.5rem; -} -.sl-markdown-content .expressive-code .copy button { - width: 2rem; - height: 2rem; - border-color: var(--sl-color-border-code); -} -/* Frames */ -.sl-markdown-content .expressive-code .frame.has-title:not(.is-terminal) .header { - background: var(--code-background); - border-bottom: 1px solid var(--sl-color-border-code); - border-radius: var(--border-radius) var(--border-radius) 0 0; -} -.sl-markdown-content .expressive-code .frame.has-title:not(.is-terminal) .header:before { - border-color: var(--sl-color-border-code); -} -.sl-markdown-content .expressive-code .frame.has-title:not(.is-terminal) .title { - border-width: 1px; - border-style: solid; - font-size: var(--sl-text-sm); - background: var(--code-background); - border-radius: var(--border-radius) var(--border-radius) 0 0; - border-color: var(--sl-color-border-code) var(--sl-color-border-code) var(--ec-frm-edActTabIndTopCol); -} -.sl-markdown-content .expressive-code .frame.has-title:not(.is-terminal) .title:after { - border: none; -} -.sl-markdown-content .expressive-code .frame.has-title pre { - border-color: var(--sl-color-border-code); -} -/* Terminal */ -.sl-markdown-content .expressive-code .frame.is-terminal .header { - font-size: var(--sl-text-sm); - font-weight: normal; - border-radius: var(--border-radius) var(--border-radius) 0 0; - background: var(--code-background); - border-color: var(--sl-color-border-code); -} -.sl-markdown-content .expressive-code .frame.is-terminal .header:after { - border-color: var(--sl-color-border-code); -} -.sl-markdown-content .expressive-code .frame.is-terminal pre { - border-color: var(--sl-color-border-code); -} -/* Code markers */ -:root[data-theme='light'] .expressive-code .frame, -.expressive-code[data-theme='light'] .frame { - --ec-tm-markBg: #00000011; - --ec-tm-insBg: #90C87E72; - --ec-tm-delBg: #FF9C8F7F; -} -:root[data-theme='dark'] .expressive-code .frame, -.expressive-code[data-theme='dark'] .frame { - --ec-tm-markBg: #FFFFFF0F; - --ec-tm-insBg: #1E561572; - --ec-tm-delBg: #862D2766; -} -.sl-markdown-content .expressive-code .ec-line.mark > .code, -.sl-markdown-content .expressive-code .ec-line.ins > .code, -.sl-markdown-content .expressive-code .ec-line.del > .code { - border-inline-start-color: transparent; -} -.sl-markdown-content .expressive-code .ec-line mark:before, -.sl-markdown-content .expressive-code .ec-line ins:before, -.sl-markdown-content .expressive-code .ec-line del:before { - border-width: 0px; -} - -/** - * Inline code - */ -.sl-markdown-content code:not(:where(.not-content *)) { - padding: 0; - background: none; - font-weight: 600; - font-size: var(--sl-text-sm); - color: var(--sl-color-white); -} -.sl-markdown-content strong code:not(:where(.not-content *)) { - font-weight: 700; -} -.sl-markdown-content code:not(:where(.not-content *)):before, -.sl-markdown-content code:not(:where(.not-content *)):after { - content: '`'; -} - -/** - * Tabs - */ -.sl-markdown-content [role='tablist'] { - border-color: var(--divider-color); -} -.sl-markdown-content .tab > [role='tab'] { - font-weight: 600; - color: var(--color-text-dimmed); - border-color: var(--divider-color); - text-transform: uppercase; - font-family: var(--__sl-font-mono); - letter-spacing: 0.5px; - font-size: var(--sl-text-code-sm); - padding-block-end: 0.375rem; -} -.sl-markdown-content .tab > [role='tab'][aria-selected='true'] { - color: var(--sl-color-white); - border-color: var(--sl-color-text-accent); -} - -/** - * Lists - */ -.sl-markdown-content ol:not(:where(.not-content *)), -.sl-markdown-content ul:not(:where(.not-content *)) { - list-style-type: none; - padding-left: 0; -} -.sl-markdown-content ol:not(:where(.not-content *)) { - counter-reset: listitem; -} -.sl-markdown-content ol:not(:where(.not-content *)) > li, -.sl-markdown-content ul:not(:where(.not-content *)) > li { - position: relative; - padding-left: 1.75rem; -} -.sl-markdown-content li:not(:where(.not-content *)) > ol, -.sl-markdown-content li:not(:where(.not-content *)) > ul, -.sl-markdown-content li + li:not(:where(.not-content *)) { - margin-top: 0.625rem; -} -.sl-markdown-content li > :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) { - margin-bottom: calc(var(--paragraph-spacing) + 0.5rem); -} -.sl-markdown-content ul:not(:where(.not-content *)) > li:before { - content: ""; - position: absolute; - left: 2px; - top: 13px; - width: 12px; - height: 2px; - border-radius: 1px; - background: var(--list-marker-color); -} -.sl-markdown-content ol:not(:where(.not-content *)) > li:before { - counter-increment: listitem; - content: counter(listitem); - position: absolute; - font-size: 0.625rem; - line-height: 17px; - text-align: center; - height: 18px; - min-width: 18px; - padding-inline: 4px; - left: 0; - top: 4px; - border-radius: 3px; - color: var(--color-text-secondary); - font-family: var(--__sl-font-mono); - border: 1px solid var(--divider-color); -} - -/** - * Tables - */ -.sl-markdown-content thead th:not(:where(.not-content *)) { - border-bottom: 2px solid var(--divider-color); -} -.sl-markdown-content :is(th):not(:where(.not-content *)) { - font-weight: 600; - border-color: var(--divider-color); - text-transform: uppercase; - font-family: var(--__sl-font-mono); - letter-spacing: 0.5px; - font-size: var(--sl-text-code-sm); - border: none; - text-align: left; - padding-block-start: 0; -} -.sl-markdown-content tbody > tr td:not(:where(.not-content *)) { - border-bottom: 1px solid var(--divider-color); - padding-block: 0.5rem; -} -.sl-markdown-content tr:nth-child(2n):not(:where(.not-content *)) { - background-color: transparent; -} - -/** - * Centered images - */ -.sl-markdown-content > :is(img, picture, video, canvas, svg, iframe):not(:where(.not-content *)) { - margin-left: auto; - margin-right: auto; -} diff --git a/www/src/styles/splash.css b/www/src/styles/splash.css deleted file mode 100644 index 416e55cf2b..0000000000 --- a/www/src/styles/splash.css +++ /dev/null @@ -1,34 +0,0 @@ -@media (min-width: 72rem) { - :root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane { - --sl-content-width: 52.5rem; - } -} - -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane > main { - padding: 0; -} -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane > main > .content-panel { - padding-inline: 0; -} -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane > main > .content-panel:first-child .sl-container { - padding-inline: var(--sl-nav-pad-x); -} -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane > main > .content-panel:last-child .sl-container { - max-width: none; -} -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane > main > .content-panel:last-child .sl-container .sl-markdown-content { - margin: auto; - max-width: var(--sl-content-width); - padding-inline: var(--sl-nav-pad-x); - padding-bottom: 4rem; -} - -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) lite-youtube { - max-width: var(--sl-content-width); -} - -:root:not([data-has-hero]):not([data-has-toc]):not([data-has-sidebar]) .main-pane > main > .content-panel:last-child footer.splash { - border-top: 1px solid var(--sl-color-hairline); - padding-top: 1.5rem; - padding-inline: var(--sl-nav-pad-x); -} diff --git a/www/src/styles/tsdoc.css b/www/src/styles/tsdoc.css deleted file mode 100644 index 44a002f47f..0000000000 --- a/www/src/styles/tsdoc.css +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Segments - */ -.sl-markdown-content > .tsdoc div.segment + :is(h2, h3, h4, h5, h6) { - margin-top: 3rem; -} -.sl-markdown-content > .tsdoc div.segment:not(:last-child):after { - content: ''; - display: block; - height: 1px; - background: var(--divider-color); - margin-top: 3rem; -} -.sl-markdown-content > .tsdoc > h2 + h3 { - margin-top: 2.5rem; -} - -/** - * Sections - */ -/* Parameters */ -.sl-markdown-content > .tsdoc section.parameters h4 + :not(a, strong, em, del, span, input, code, :where(.not-content *)) { - /* H4 Heading */ - margin-top: 0.875rem; -} -.sl-markdown-content > .tsdoc section.parameters > section.inline + :not(a, strong, em, del, span, input, code, :where(.not-content *)) { - /* Inline Section Heading */ - margin-top: 0.5625rem; -} -.sl-markdown-content >.tsdoc section.parameters :not(h4, a, strong, em, del, span, input, code) + :not(a, strong, em, del, span, input, code, ul, :where(.not-content *, .starlight-aside *)) { - margin-top: 0.5rem; -} -/* Signature */ -.sl-markdown-content > .tsdoc section.signature, -.sl-markdown-content > .tsdoc section.signature + section { - margin-top: 2rem; -} -/* About */ -.sl-markdown-content > .tsdoc section.about :not(h1, h2, h3, h4, h5, h6) + :is(h4, h5, h6):not(:where(.not-content *)) { - margin-top: 2.5rem; -} - -/** - * Headings - */ -.sl-markdown-content > .tsdoc section h4:not(:where(.not-content *)) { - font-size: var(--sl-text-h5); -} -.sl-markdown-content > .tsdoc section.inline p:first-child strong:not(:where(.not-content *)) { - margin-right: var(--tsdoc-key-margin-right); - font-family: var(--__sl-font-headings); - letter-spacing: -0.5px; - font-weight: 500; - font-size: var(--sl-text-h5); - color: var(--sl-color-white); -} - -/** - * Lists - */ -.sl-markdown-content > .tsdoc section.parameters li > :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) { - margin-bottom: 0.75rem; -} -.sl-markdown-content > .tsdoc section.parameters li > :last-child:is(.starlight-aside, .expressive-code) { - margin-bottom: 0.875rem; -} - -/** - * Nested Title - */ -.sl-markdown-content > .tsdoc :is(h4, h5).nested span.parent { - font-weight: 400; - font-family: var(--__sl-font-mono); - color: var(--color-text-secondary); - font-size: var(--sl-text-code); -} -.sl-markdown-content > .tsdoc h4.nested span.parent { - font-size: calc(var(--sl-text-h4) - 0.0625rem); -} - -/** - * Keys & Values - */ -.sl-markdown-content > .tsdoc section code.key:before, -.sl-markdown-content > .tsdoc section code.type:before, -.sl-markdown-content > .tsdoc section code.method:before, -.sl-markdown-content > .tsdoc section code.symbol:before, -.sl-markdown-content > .tsdoc section code.primitive:before, -.sl-markdown-content > .tsdoc section code.key:after, -.sl-markdown-content > .tsdoc section code.type:after, -.sl-markdown-content > .tsdoc section code.method:after, -.sl-markdown-content > .tsdoc section code.symbol:after, -.sl-markdown-content > .tsdoc section code.primitive:after { - content: ''; -} -.sl-markdown-content > .tsdoc section code.key { - margin-right: var(--tsdoc-key-margin-right); -} -.sl-markdown-content > .tsdoc section code.key, -.sl-markdown-content > .tsdoc section code.type, -.sl-markdown-content > .tsdoc section code.symbol, -.sl-markdown-content > .tsdoc section code.primitive { - font-size: var(--sl-text-code); -} -.sl-markdown-content > .tsdoc section code.key, -.sl-markdown-content > .tsdoc section code.primitive { - color: var(--color-text); -} -.sl-markdown-content > .tsdoc section a > code.key, -.sl-markdown-content > .tsdoc section a > code.primitive { - color: var(--sl-color-text-accent); -} -.sl-markdown-content > .tsdoc section code.symbol { - color: var(--color-text-secondary); -} -.sl-markdown-content > .tsdoc section code.type, -.sl-markdown-content > .tsdoc section code.symbol, -.sl-markdown-content > .tsdoc section code.primitive { - font-weight: 400; -} -.sl-markdown-content > .tsdoc section code.primitive { - font-style: italic; -} - -.sl-markdown-content > .tsdoc section span.dimmed { - color: var(--color-text-secondary); -} diff --git a/www/src/theme/DocItem/index.js b/www/src/theme/DocItem/index.js new file mode 100644 index 0000000000..cb519481d3 --- /dev/null +++ b/www/src/theme/DocItem/index.js @@ -0,0 +1,49 @@ +import React from "react"; +import { Base64 } from "js-base64"; +import Head from "@docusaurus/Head"; +import OriginalDocItem from "@theme-original/DocItem"; +import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; + +/** + * The DocItem component renders component for a page. + * We are wrapping around the original component and overriding + * the og:image tags. + * + * https://docusaurus.io/docs/using-themes/#wrapping-theme-components + * + * The component overrides any previously set tags. + * + * https://docusaurus.io/docs/docusaurus-core#components + * + */ +export default function DocItem(props) { + const { siteConfig } = useDocusaurusContext(); + const { id, title } = props.content.metadata; + // Get the social cards URL from docusaurus.config.js + const { socialCardsUrl } = siteConfig.customFields; + + const encodedTitle = encodeURIComponent( + Base64.encode( + // Convert to ASCII + encodeURIComponent( + // Truncate to fit S3's max key size + title.substring(0, 700) + ) + ) + ); + + // Check if the page is one of the constructs + const metaImageUrl = id.startsWith("constructs/") + ? `${socialCardsUrl}/serverless-stack-constructs/${encodedTitle}.png` + : `${socialCardsUrl}/serverless-stack-docs/${encodedTitle}.png`; + + return ( + <> + + + + + + + ); +} diff --git a/www/src/util/markdown.ts b/www/src/util/markdown.ts deleted file mode 100644 index c5160f843a..0000000000 --- a/www/src/util/markdown.ts +++ /dev/null @@ -1,76 +0,0 @@ -import changelog from "../data/changelog.json"; - -function renderChangelog(): string { - return (changelog as Array<{ tag: string; body: string }>) - .map((r) => `## ${r.tag.replace(/^v/, "")}\n\n${r.body}`) - .join("\n\n"); -} - -function stripImportsAndExports(source: string): string { - return source.replace(/^import\s+.*$/gm, "").replace(/^export\s+.*$/gm, ""); -} - -export function cleanMarkdown(source: string): string { - return source - .split(/(```[\s\S]*?```)/g) - .map((part, i) => - // Odd indices are code blocks β€” leave them alone - i % 2 === 1 ? part : stripImportsAndExports(part) - ) - .join("") - // Remove JSX comments {/* ... */} (single and multiline) - .replace(/\{\/\*[\s\S]*?\*\/\}/g, "") - // Remove self-closing tags - .replace(/]*\/>/g, "") - // Remove self-closing tags - .replace(/]*\/>/g, "") - // Remove self-closing tags - .replace(/]*\/>/g, "") - // Remove self-closing tags - .replace(/]*\/>/g, "") - // Remove tsdoc component tags (opening and closing) - .replace(/<\/?(?:Section|Segment|InlineSection)(?:\s+[^>]*)?>/g, "") - // Convert content to just content - .replace(/]*>([\s\S]*?)<\/NestedTitle>/g, "$1") - // Remove
    and
    - .replace(//g, "") - .replace(/^<\/div>\s*$/gm, "") - // Merge adjacent tags into one (for type expressions like Input) - .replace(/<\/code>/g, "") - // Convert innermost content β†’ `content` - .replace(/([^<]*)<\/code>/g, "`$1`") - // Strip remaining outer and from nested structures - .replace(//g, "") - // Convert plain content β†’ `content` - .replace(/([^<]*)<\/code>/g, "`$1`") - .replace(/<\/code>/g, "") - // Remove

    and

    wrapper tags - .replace(/<\/?p>/g, "") - // Decode common HTML entities - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/&/g, "&") - .replace(/“/g, '"') - .replace(/”/g, '"') - .replace(/{/g, "{") - .replace(/}/g, "}") - .replace(/{/g, "{") - .replace(/}/g, "}") - // Convert / to labeled sections - .replace(//g, "") - .replace(/<\/Tabs>/g, "") - .replace(//g, "**$1**\n") - .replace(/<\/TabItem>/g, "") - // Ensure blank line before and after code blocks, horizontal rules, and headings - .replace(/([^\n])\n(```)/g, "$1\n\n$2") - .replace(/(```)\n([^\n])/g, "$1\n\n$2") - .replace(/([^\n])\n(---)\n/g, "$1\n\n$2\n") - .replace(/\n(---)\n([^\n])/g, "\n$1\n\n$2") - .replace(/([^\n])\n(#{1,6} )/g, "$1\n\n$2") - .replace(/\n(#{1,6} .+)\n([^\n])/g, "\n$1\n\n$2") - // Replace component - .replace(//g, renderChangelog()) - // Collapse 3+ consecutive blank lines to 2 - .replace(/\n{3,}/g, "\n\n") - .trim(); -} diff --git a/www/sst-env.d.ts b/www/sst-env.d.ts deleted file mode 100644 index 164f2bbc25..0000000000 --- a/www/sst-env.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* This file is auto-generated by SST. Do not edit. */ -/* tslint:disable */ -/* eslint-disable */ -import "sst" -export {} -declare module "sst" { - export interface Resource { - "Astro": { - "type": "sst.aws.Astro" - "url": string - } - } -} diff --git a/www/sst.config.ts b/www/sst.config.ts deleted file mode 100644 index 96d45a3d96..0000000000 --- a/www/sst.config.ts +++ /dev/null @@ -1,279 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "www", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - version: "3.13.20", - }; - }, - console: { - autodeploy: { - target(event) { - if ( - event.type === "branch" && - event.branch === "dev" && - event.action === "pushed" - ) { - return { stage: "production" }; - } - }, - async workflow({ $, event }) { - await $`bun i`; - await $`goenv install 1.21.3 && goenv global 1.21.3`; - await $`cd ../platform && ./scripts/build`; - await $`bun i sst-linux-x64`; - event.action === "removed" - ? await $`bun sst remove` - : await $`bun sst deploy`; - }, - }, - }, - async run() { - const domain = - { - production: "sst.dev", - dev: "dev.sst.dev", - }[$app.stage] || $app.stage + "dev.sst.dev"; - - // Redirect /examples to guide.sst.dev/examples - // Redirect /chapters to guide.sst.dev/chapters - // Redirect /archives to guide.sst.dev/archives - const redirectToGuideBehavior = { - targetOriginId: "redirect", - viewerProtocolPolicy: "redirect-to-https", - allowedMethods: ["GET", "HEAD", "OPTIONS"], - cachedMethods: ["GET", "HEAD"], - functionAssociations: [ - { - eventType: "viewer-request", - functionArn: new aws.cloudfront.Function("AstroRedirect", { - runtime: "cloudfront-js-2.0", - code: [ - `async function handler(event) {`, - ` const request = event.request;`, - // ie. request.uri is /examples/foo - ` return {`, - ` statusCode: 302,`, - ` statusDescription: 'Found',`, - ` headers: {`, - ` location: { value: "https://guide.sst.dev" + request.uri }`, - ` },`, - ` };`, - `}`, - ].join("\n"), - }).arn, - }, - ], - forwardedValues: { - queryString: true, - headers: ["Origin"], - cookies: { forward: "none" }, - }, - }; - - // Redirect /u/* to api.console.sst.dev/link/* - const redirectToConsoleBehavior = { - targetOriginId: "redirect", - viewerProtocolPolicy: "redirect-to-https", - allowedMethods: ["GET", "HEAD", "OPTIONS"], - cachedMethods: ["GET", "HEAD"], - functionAssociations: [ - { - eventType: "viewer-request", - functionArn: new aws.cloudfront.Function("ConsoleRedirect", { - runtime: "cloudfront-js-2.0", - code: [ - `async function handler(event) {`, - ` const request = event.request;`, - // ie. request.uri is /u/123 - ` return {`, - ` statusCode: 302,`, - ` statusDescription: 'Found',`, - ` headers: {`, - ` location: { value: "https://api.console.sst.dev/link" + request.uri }`, - ` },`, - ` };`, - `}`, - ].join("\n"), - }).arn, - }, - ], - forwardedValues: { - queryString: true, - headers: ["Origin"], - cookies: { forward: "none" }, - }, - }; - - // Redirect /install to https://raw.githubusercontent.com/sst/sst/dev/install - const redirectToInstallBehavior = { - targetOriginId: "redirect", - viewerProtocolPolicy: "redirect-to-https", - allowedMethods: ["GET", "HEAD", "OPTIONS"], - cachedMethods: ["GET", "HEAD"], - functionAssociations: [ - { - eventType: "viewer-request", - functionArn: new aws.cloudfront.Function("InstallRedirect", { - runtime: "cloudfront-js-2.0", - code: [ - `async function handler(event) {`, - ` const request = event.request;`, - ` return {`, - ` statusCode: 302,`, - ` statusDescription: 'Found',`, - ` headers: {`, - ` location: { value: "https://raw.githubusercontent.com/sst/sst/dev/install" }`, - ` },`, - ` };`, - `}`, - ].join("\n"), - }).arn, - }, - ], - forwardedValues: { - queryString: true, - headers: ["Origin"], - cookies: { forward: "none" }, - }, - }; - - // Strip .html from /blog - const stripHtmlBehavior = { - targetOriginId: "redirect", - viewerProtocolPolicy: "redirect-to-https", - allowedMethods: ["GET", "HEAD", "OPTIONS"], - cachedMethods: ["GET", "HEAD"], - functionAssociations: [ - { - eventType: "viewer-request", - functionArn: new aws.cloudfront.Function("StripHtml", { - runtime: "cloudfront-js-2.0", - code: [ - `async function handler(event) {`, - ` return {`, - ` statusCode: 308,`, - ` headers: {`, - ` location: { value: event.request.uri.replace(/\.html$/, "") }`, - ` },`, - ` };`, - `}`, - ].join("\n"), - }).arn, - }, - ], - forwardedValues: { - queryString: true, - headers: ["Origin"], - cookies: { forward: "none" }, - }, - }; - - new sst.aws.Astro("Astro", { - domain: - $app.stage === "production" - ? { - name: domain, - redirects: [ - "www.sst.dev", - "ion.sst.dev", - "serverless-stack.com", - "www.serverless-stack.com", - ], - } - : domain, - edge: { - // Rewrite /docs/* to .md when Accept: text/markdown (for AI agents) - viewerRequest: { - injection: [ - `var uri = event.request.uri;`, - `var accept = (event.request.headers['accept'] || {}).value || '';`, - `if (uri.startsWith('/docs') && accept.includes('text/markdown') && !/\\.[a-z0-9]+$/i.test(uri)) {`, - ` event.request.uri = (uri === '/docs' || uri === '/docs/')`, - ` ? '/docs/index.md'`, - ` : uri.replace(/\\/$/, '') + '.md';`, - `}`, - ].join("\n"), - }, - // Fix Content-Type on .md responses (S3 serves them as octet-stream) - viewerResponse: { - injection: [ - `if (event.request.uri.endsWith('.md')) {`, - ` event.response.headers['content-type'] = { value: 'text/markdown; charset=utf-8' };`, - `}`, - ].join("\n"), - }, - }, - transform: { - cdn: (args) => { - args.origins = $output(args.origins).apply((origins) => [ - ...origins, - { - domainName: "guide.sst.dev", - originId: "redirect", - customOriginConfig: { - httpPort: 80, - httpsPort: 443, - originProtocolPolicy: "https-only", - originReadTimeout: 20, - originSslProtocols: ["TLSv1.2"], - }, - }, - ]); - args.orderedCacheBehaviors = $output( - args.orderedCacheBehaviors, - ).apply((cacheBehaviors) => [ - ...(cacheBehaviors || []), - { pathPattern: "/blog/*.html", ...stripHtmlBehavior }, - { pathPattern: "/install", ...redirectToInstallBehavior }, - { pathPattern: "/examples*", ...redirectToGuideBehavior }, - { pathPattern: "/chapters*", ...redirectToGuideBehavior }, - { pathPattern: "/archives*", ...redirectToGuideBehavior }, - { pathPattern: "/u/*", ...redirectToConsoleBehavior }, - ]); - }, - }, - }); - - // Redirect docs.sst.dev to sst.dev/docs - if ($app.stage === "production") { - new sst.aws.Router("DocsRouter", { - domain: { - name: "docs.sst.dev", - aliases: ["docs.serverless-stack.com"], - }, - routes: { - "/*": { - url: `https://sst.dev/docs`, - edge: { - viewerRequest: { - injection: ` -return { - statusCode: 301, - statusDescription: 'Moved Permanently', - headers: { - location: { value: "https://sst.dev/docs" } - } -}; - `, - }, - }, - }, - }, - }); - } - - // Redirect telemetry.ion.sst.dev to us.i.posthog.com - new sst.aws.Router("TelemetryRouter", { - domain: { - name: "telemetry.ion." + domain, - }, - routes: { - "/*": "https://us.i.posthog.com", - }, - }); - }, -}); diff --git a/examples/aws-fastapi/functions/src/functions/__init__.py b/www/static/.nojekyll similarity index 100% rename from examples/aws-fastapi/functions/src/functions/__init__.py rename to www/static/.nojekyll diff --git a/www/static/img/astro/bootstrap-astro.png b/www/static/img/astro/bootstrap-astro.png new file mode 100644 index 0000000000..871a83a599 Binary files /dev/null and b/www/static/img/astro/bootstrap-astro.png differ diff --git a/www/static/img/breakpoint-debugging/breakpoint-triggered.png b/www/static/img/breakpoint-debugging/breakpoint-triggered.png new file mode 100644 index 0000000000..c091dedca3 Binary files /dev/null and b/www/static/img/breakpoint-debugging/breakpoint-triggered.png differ diff --git a/www/static/img/breakpoint-debugging/resume.png b/www/static/img/breakpoint-debugging/resume.png new file mode 100644 index 0000000000..5bc4bc693e Binary files /dev/null and b/www/static/img/breakpoint-debugging/resume.png differ diff --git a/www/static/img/breakpoint-debugging/set-breakpoint.png b/www/static/img/breakpoint-debugging/set-breakpoint.png new file mode 100644 index 0000000000..8957bbbfd7 Binary files /dev/null and b/www/static/img/breakpoint-debugging/set-breakpoint.png differ diff --git a/www/static/img/breakpoint-debugging/start-debugging.png b/www/static/img/breakpoint-debugging/start-debugging.png new file mode 100644 index 0000000000..8ddb4898da Binary files /dev/null and b/www/static/img/breakpoint-debugging/start-debugging.png differ diff --git a/www/static/img/components/keyboard.svg b/www/static/img/components/keyboard.svg new file mode 100644 index 0000000000..e03e67931b --- /dev/null +++ b/www/static/img/components/keyboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/www/static/img/console/sst-console-api-tab.png b/www/static/img/console/sst-console-api-tab.png new file mode 100644 index 0000000000..b712b53d7c Binary files /dev/null and b/www/static/img/console/sst-console-api-tab.png differ diff --git a/www/static/img/console/sst-console-buckets-tab.png b/www/static/img/console/sst-console-buckets-tab.png new file mode 100644 index 0000000000..9a229a878c Binary files /dev/null and b/www/static/img/console/sst-console-buckets-tab.png differ diff --git a/www/static/img/console/sst-console-cognito-tab.png b/www/static/img/console/sst-console-cognito-tab.png new file mode 100644 index 0000000000..b59e7bbd94 Binary files /dev/null and b/www/static/img/console/sst-console-cognito-tab.png differ diff --git a/www/static/img/console/sst-console-dynamodb-tab.png b/www/static/img/console/sst-console-dynamodb-tab.png new file mode 100644 index 0000000000..6cbd1a0e18 Binary files /dev/null and b/www/static/img/console/sst-console-dynamodb-tab.png differ diff --git a/www/static/img/console/sst-console-functions-tab.png b/www/static/img/console/sst-console-functions-tab.png new file mode 100644 index 0000000000..3696a36917 Binary files /dev/null and b/www/static/img/console/sst-console-functions-tab.png differ diff --git a/www/static/img/console/sst-console-graphql-tab.png b/www/static/img/console/sst-console-graphql-tab.png new file mode 100644 index 0000000000..0cd11d97fd Binary files /dev/null and b/www/static/img/console/sst-console-graphql-tab.png differ diff --git a/www/static/img/console/sst-console-homescreen.png b/www/static/img/console/sst-console-homescreen.png new file mode 100644 index 0000000000..2d7626e853 Binary files /dev/null and b/www/static/img/console/sst-console-homescreen.png differ diff --git a/www/static/img/console/sst-console-local-tab.png b/www/static/img/console/sst-console-local-tab.png new file mode 100644 index 0000000000..2d7626e853 Binary files /dev/null and b/www/static/img/console/sst-console-local-tab.png differ diff --git a/www/static/img/console/sst-console-rds-tab.png b/www/static/img/console/sst-console-rds-tab.png new file mode 100644 index 0000000000..df738326ee Binary files /dev/null and b/www/static/img/console/sst-console-rds-tab.png differ diff --git a/www/static/img/console/sst-console-stacks-tab.png b/www/static/img/console/sst-console-stacks-tab.png new file mode 100644 index 0000000000..3882a923a3 Binary files /dev/null and b/www/static/img/console/sst-console-stacks-tab.png differ diff --git a/www/static/img/deploy-to-prod/app-deployed-to-prod.png b/www/static/img/deploy-to-prod/app-deployed-to-prod.png new file mode 100644 index 0000000000..a8702364e1 Binary files /dev/null and b/www/static/img/deploy-to-prod/app-deployed-to-prod.png differ diff --git a/www/static/img/editor-setup/vs-code-autocomplete.png b/www/static/img/editor-setup/vs-code-autocomplete.png new file mode 100644 index 0000000000..c719b46ee4 Binary files /dev/null and b/www/static/img/editor-setup/vs-code-autocomplete.png differ diff --git a/www/static/img/editor-setup/vs-code-tsdoc.png b/www/static/img/editor-setup/vs-code-tsdoc.png new file mode 100644 index 0000000000..a8972ad01e Binary files /dev/null and b/www/static/img/editor-setup/vs-code-tsdoc.png differ diff --git a/www/static/img/editor-setup/vs-code-typesafe.png b/www/static/img/editor-setup/vs-code-typesafe.png new file mode 100644 index 0000000000..653d811349 Binary files /dev/null and b/www/static/img/editor-setup/vs-code-typesafe.png differ diff --git a/www/static/img/favicon.ico b/www/static/img/favicon.ico new file mode 100644 index 0000000000..cc32e95d05 Binary files /dev/null and b/www/static/img/favicon.ico differ diff --git a/www/static/img/implement-rds/console-query-comment.png b/www/static/img/implement-rds/console-query-comment.png new file mode 100644 index 0000000000..6923b23cc9 Binary files /dev/null and b/www/static/img/implement-rds/console-query-comment.png differ diff --git a/www/static/img/implement-rds/run-migration.png b/www/static/img/implement-rds/run-migration.png new file mode 100644 index 0000000000..ff0e80d1cb Binary files /dev/null and b/www/static/img/implement-rds/run-migration.png differ diff --git a/www/static/img/initialize-database/console-apply-migration.png b/www/static/img/initialize-database/console-apply-migration.png new file mode 100644 index 0000000000..e73acddb43 Binary files /dev/null and b/www/static/img/initialize-database/console-apply-migration.png differ diff --git a/www/static/img/initialize-database/console-query-article.png b/www/static/img/initialize-database/console-query-article.png new file mode 100644 index 0000000000..95c18e4251 Binary files /dev/null and b/www/static/img/initialize-database/console-query-article.png differ diff --git a/www/static/img/initialize-database/console-rds-tab.png b/www/static/img/initialize-database/console-rds-tab.png new file mode 100644 index 0000000000..9d051abad3 Binary files /dev/null and b/www/static/img/initialize-database/console-rds-tab.png differ diff --git a/www/static/img/learn/completed-sst-app.png b/www/static/img/learn/completed-sst-app.png new file mode 100644 index 0000000000..a8702364e1 Binary files /dev/null and b/www/static/img/learn/completed-sst-app.png differ diff --git a/www/static/img/logo.svg b/www/static/img/logo.svg new file mode 100644 index 0000000000..a838d608fe --- /dev/null +++ b/www/static/img/logo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/www/static/img/logos/astro.svg b/www/static/img/logos/astro.svg new file mode 100644 index 0000000000..afbe94eaef --- /dev/null +++ b/www/static/img/logos/astro.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/www/static/img/logos/nextjs.svg b/www/static/img/logos/nextjs.svg new file mode 100644 index 0000000000..135acfe233 --- /dev/null +++ b/www/static/img/logos/nextjs.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/www/static/img/logos/remix.svg b/www/static/img/logos/remix.svg new file mode 100644 index 0000000000..c79dcf784d --- /dev/null +++ b/www/static/img/logos/remix.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/www/static/img/logos/solid.svg b/www/static/img/logos/solid.svg new file mode 100644 index 0000000000..8a8988c4f1 --- /dev/null +++ b/www/static/img/logos/solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/www/static/img/logos/svelte.svg b/www/static/img/logos/svelte.svg new file mode 100644 index 0000000000..7b7868b1d4 --- /dev/null +++ b/www/static/img/logos/svelte.svg @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/www/static/img/long-running-jobs/sst-console-job.png b/www/static/img/long-running-jobs/sst-console-job.png new file mode 100644 index 0000000000..2db01df0f1 Binary files /dev/null and b/www/static/img/long-running-jobs/sst-console-job.png differ diff --git a/www/static/img/make-updates/new-comment-added-in-the-articles-page.png b/www/static/img/make-updates/new-comment-added-in-the-articles-page.png new file mode 100644 index 0000000000..3c4ec72440 Binary files /dev/null and b/www/static/img/make-updates/new-comment-added-in-the-articles-page.png differ diff --git a/www/static/img/nextjs/bootstrap-nextjs.png b/www/static/img/nextjs/bootstrap-nextjs.png new file mode 100644 index 0000000000..0fa9084fcf Binary files /dev/null and b/www/static/img/nextjs/bootstrap-nextjs.png differ diff --git a/www/static/img/og-image.png b/www/static/img/og-image.png new file mode 100644 index 0000000000..9809254451 Binary files /dev/null and b/www/static/img/og-image.png differ diff --git a/www/static/img/remix/bootstrap-remix.png b/www/static/img/remix/bootstrap-remix.png new file mode 100644 index 0000000000..2754ba7e6c Binary files /dev/null and b/www/static/img/remix/bootstrap-remix.png differ diff --git a/www/static/img/render-queries/comment-count-for-articles-in-homepage.png b/www/static/img/render-queries/comment-count-for-articles-in-homepage.png new file mode 100644 index 0000000000..2f8d0f5fdc Binary files /dev/null and b/www/static/img/render-queries/comment-count-for-articles-in-homepage.png differ diff --git a/www/static/img/screens/iam-permissions-leapp-enter-mfa.png b/www/static/img/screens/iam-permissions-leapp-enter-mfa.png new file mode 100644 index 0000000000..1715e0c595 Binary files /dev/null and b/www/static/img/screens/iam-permissions-leapp-enter-mfa.png differ diff --git a/www/static/img/screens/iam-permissions-leapp-setup.png b/www/static/img/screens/iam-permissions-leapp-setup.png new file mode 100644 index 0000000000..d90e93d1b8 Binary files /dev/null and b/www/static/img/screens/iam-permissions-leapp-setup.png differ diff --git a/www/static/img/screens/vite-environment-variables-autocomplete.png b/www/static/img/screens/vite-environment-variables-autocomplete.png new file mode 100644 index 0000000000..874b8a00fc Binary files /dev/null and b/www/static/img/screens/vite-environment-variables-autocomplete.png differ diff --git a/www/static/img/screens/vs-code-debug-sst-start.png b/www/static/img/screens/vs-code-debug-sst-start.png new file mode 100644 index 0000000000..626c40bf7c Binary files /dev/null and b/www/static/img/screens/vs-code-debug-sst-start.png differ diff --git a/www/static/img/solid-start/bootstrap-solid-start.png b/www/static/img/solid-start/bootstrap-solid-start.png new file mode 100644 index 0000000000..639d40f65b Binary files /dev/null and b/www/static/img/solid-start/bootstrap-solid-start.png differ diff --git a/www/static/img/star.svg b/www/static/img/star.svg new file mode 100644 index 0000000000..f5a3d94499 --- /dev/null +++ b/www/static/img/star.svg @@ -0,0 +1,3 @@ + + + diff --git a/www/static/img/start-frontend/console-create-article-log.png b/www/static/img/start-frontend/console-create-article-log.png new file mode 100644 index 0000000000..9e02d07c1c Binary files /dev/null and b/www/static/img/start-frontend/console-create-article-log.png differ diff --git a/www/static/img/start-frontend/console-load-articles-log.png b/www/static/img/start-frontend/console-load-articles-log.png new file mode 100644 index 0000000000..15412fea18 Binary files /dev/null and b/www/static/img/start-frontend/console-load-articles-log.png differ diff --git a/www/static/img/start-frontend/create-article.png b/www/static/img/start-frontend/create-article.png new file mode 100644 index 0000000000..b42f09238d Binary files /dev/null and b/www/static/img/start-frontend/create-article.png differ diff --git a/www/static/img/start-frontend/load-homepage.png b/www/static/img/start-frontend/load-homepage.png new file mode 100644 index 0000000000..511650e12b Binary files /dev/null and b/www/static/img/start-frontend/load-homepage.png differ diff --git a/www/static/img/start/astro-site-deployed-to-aws-with-sst.png b/www/static/img/start/astro-site-deployed-to-aws-with-sst.png new file mode 100644 index 0000000000..0a16e40efd Binary files /dev/null and b/www/static/img/start/astro-site-deployed-to-aws-with-sst.png differ diff --git a/www/static/img/start/nextjs-app-deployed-to-aws-with-sst.png b/www/static/img/start/nextjs-app-deployed-to-aws-with-sst.png new file mode 100644 index 0000000000..ec30656018 Binary files /dev/null and b/www/static/img/start/nextjs-app-deployed-to-aws-with-sst.png differ diff --git a/www/static/img/start/remix-app-deployed-to-aws-with-sst.png b/www/static/img/start/remix-app-deployed-to-aws-with-sst.png new file mode 100644 index 0000000000..3f128aac77 Binary files /dev/null and b/www/static/img/start/remix-app-deployed-to-aws-with-sst.png differ diff --git a/www/static/img/start/solidstart-app-deployed-to-aws-with-sst.png b/www/static/img/start/solidstart-app-deployed-to-aws-with-sst.png new file mode 100644 index 0000000000..e1236a65f6 Binary files /dev/null and b/www/static/img/start/solidstart-app-deployed-to-aws-with-sst.png differ diff --git a/www/static/img/start/standalone-sst-app-deployed-to-aws.png b/www/static/img/start/standalone-sst-app-deployed-to-aws.png new file mode 100644 index 0000000000..b231c174c5 Binary files /dev/null and b/www/static/img/start/standalone-sst-app-deployed-to-aws.png differ diff --git a/www/static/img/start/sveltekit-app-deployed-to-aws-with-sst.png b/www/static/img/start/sveltekit-app-deployed-to-aws-with-sst.png new file mode 100644 index 0000000000..cf2fdea888 Binary files /dev/null and b/www/static/img/start/sveltekit-app-deployed-to-aws-with-sst.png differ diff --git a/www/static/img/svelte-kit/bootstrap-svelte-kit.png b/www/static/img/svelte-kit/bootstrap-svelte-kit.png new file mode 100644 index 0000000000..52d1768a31 Binary files /dev/null and b/www/static/img/svelte-kit/bootstrap-svelte-kit.png differ diff --git a/www/tsconfig.json b/www/tsconfig.json deleted file mode 100644 index bcbf8b5090..0000000000 --- a/www/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -}