From 4ceabdffa07b1af8d99eb73622a4d549d99ec6d2 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 18 Sep 2025 10:59:01 -0400 Subject: wip: zen --- bun.lock | 72 ++- github/sst-env.d.ts | 2 +- infra/cloud.ts | 157 ----- infra/console.ts | 157 +++++ package.json | 2 +- packages/app/sst-env.d.ts | 2 +- packages/cloud/app/.gitignore | 28 - packages/cloud/app/.opencode/agent/css.md | 149 ----- packages/cloud/app/README.md | 32 - packages/cloud/app/app.config.ts | 23 - packages/cloud/app/package.json | 25 - packages/cloud/app/public/favicon.svg | 5 - packages/cloud/app/public/robots.txt | 5 - packages/cloud/app/public/social-share.png | Bin 17520 -> 0 bytes packages/cloud/app/public/theme.json | 182 ------ packages/cloud/app/src/app.css | 1 - packages/cloud/app/src/app.tsx | 23 - packages/cloud/app/src/asset/lander/check.svg | 2 - packages/cloud/app/src/asset/lander/copy.svg | 2 - .../app/src/asset/lander/screenshot-github.png | Bin 924094 -> 0 bytes .../app/src/asset/lander/screenshot-splash.png | Bin 467281 -> 0 bytes .../app/src/asset/lander/screenshot-vscode.png | Bin 1022418 -> 0 bytes packages/cloud/app/src/asset/lander/screenshot.png | Bin 606051 -> 0 bytes packages/cloud/app/src/asset/logo-ornate-dark.svg | 19 - packages/cloud/app/src/asset/logo-ornate-light.svg | 18 - packages/cloud/app/src/asset/logo.svg | 12 - packages/cloud/app/src/component/icon.tsx | 82 --- .../component/workspace/billing-section.module.css | 114 ---- .../src/component/workspace/billing-section.tsx | 193 ------ .../cloud/app/src/component/workspace/common.tsx | 25 - .../src/component/workspace/key-section.module.css | 172 ------ .../app/src/component/workspace/key-section.tsx | 182 ------ .../workspace/monthly-limit-section.module.css | 102 ---- .../component/workspace/monthly-limit-section.tsx | 139 ----- .../workspace/new-user-section.module.css | 163 ------ .../src/component/workspace/new-user-section.tsx | 97 ---- .../component/workspace/payment-section.module.css | 72 --- .../src/component/workspace/payment-section.tsx | 113 ---- .../component/workspace/usage-section.module.css | 88 --- .../app/src/component/workspace/usage-section.tsx | 128 ---- packages/cloud/app/src/context/auth.session.ts | 23 - packages/cloud/app/src/context/auth.ts | 83 --- packages/cloud/app/src/context/auth.withActor.ts | 7 - packages/cloud/app/src/entry-client.tsx | 4 - packages/cloud/app/src/entry-server.tsx | 28 - packages/cloud/app/src/global.d.ts | 1 - packages/cloud/app/src/middleware.ts | 5 - packages/cloud/app/src/routes/[...404].css | 130 ----- packages/cloud/app/src/routes/[...404].tsx | 38 -- packages/cloud/app/src/routes/auth/authorize.ts | 7 - packages/cloud/app/src/routes/auth/callback.ts | 31 - packages/cloud/app/src/routes/auth/index.ts | 13 - packages/cloud/app/src/routes/debug/index.ts | 13 - packages/cloud/app/src/routes/discord.ts | 5 - packages/cloud/app/src/routes/docs/[...path].ts | 20 - packages/cloud/app/src/routes/docs/index.ts | 20 - packages/cloud/app/src/routes/index.css | 504 ---------------- packages/cloud/app/src/routes/index.tsx | 183 ------ packages/cloud/app/src/routes/s/[id].ts | 20 - packages/cloud/app/src/routes/stripe/webhook.ts | 98 ---- packages/cloud/app/src/routes/workspace.css | 127 ---- packages/cloud/app/src/routes/workspace.tsx | 67 --- packages/cloud/app/src/routes/workspace/[id].css | 115 ---- packages/cloud/app/src/routes/workspace/[id].tsx | 50 -- packages/cloud/app/src/routes/workspace/index.tsx | 0 packages/cloud/app/src/routes/zen/handler.ts | 594 ------------------- .../app/src/routes/zen/v1/chat/completions.ts | 54 -- packages/cloud/app/src/routes/zen/v1/messages.ts | 61 -- packages/cloud/app/src/routes/zen/v1/responses.ts | 52 -- packages/cloud/app/src/style/base.css | 9 - packages/cloud/app/src/style/component/button.css | 102 ---- packages/cloud/app/src/style/index.css | 8 - packages/cloud/app/src/style/reset.css | 76 --- packages/cloud/app/src/style/token/color.css | 91 --- packages/cloud/app/src/style/token/font.css | 20 - packages/cloud/app/src/style/token/space.css | 46 -- packages/cloud/app/sst-env.d.ts | 9 - packages/cloud/app/tsconfig.json | 21 - packages/cloud/core/drizzle.config.ts | 20 - .../cloud/core/migrations/0000_fluffy_raza.sql | 89 --- .../core/migrations/0001_serious_whistler.sql | 2 - .../cloud/core/migrations/0002_violet_loners.sql | 1 - .../core/migrations/0003_dusty_clint_barton.sql | 1 - .../core/migrations/0004_first_mockingbird.sql | 1 - .../cloud/core/migrations/0005_jazzy_skrulls.sql | 1 - .../core/migrations/0006_parallel_gauntlet.sql | 2 - .../core/migrations/0007_familiar_nightshade.sql | 1 - .../core/migrations/0008_eminent_ultimatum.sql | 1 - .../core/migrations/0009_redundant_piledriver.sql | 1 - .../cloud/core/migrations/0010_needy_sue_storm.sql | 1 - .../core/migrations/0011_freezing_phil_sheldon.sql | 3 - .../cloud/core/migrations/0012_bright_photon.sql | 3 - .../core/migrations/0013_absurd_hobgoblin.sql | 2 - .../cloud/core/migrations/meta/0000_snapshot.json | 569 ------------------ .../cloud/core/migrations/meta/0001_snapshot.json | 569 ------------------ .../cloud/core/migrations/meta/0002_snapshot.json | 576 ------------------ .../cloud/core/migrations/meta/0003_snapshot.json | 581 ------------------ .../cloud/core/migrations/meta/0004_snapshot.json | 588 ------------------- .../cloud/core/migrations/meta/0005_snapshot.json | 588 ------------------- .../cloud/core/migrations/meta/0006_snapshot.json | 602 ------------------- .../cloud/core/migrations/meta/0007_snapshot.json | 595 ------------------- .../cloud/core/migrations/meta/0008_snapshot.json | 602 ------------------- .../cloud/core/migrations/meta/0009_snapshot.json | 609 ------------------- .../cloud/core/migrations/meta/0010_snapshot.json | 615 -------------------- .../cloud/core/migrations/meta/0011_snapshot.json | 622 -------------------- .../cloud/core/migrations/meta/0012_snapshot.json | 643 -------------------- .../cloud/core/migrations/meta/0013_snapshot.json | 646 --------------------- packages/cloud/core/migrations/meta/_journal.json | 104 ---- packages/cloud/core/package.json | 29 - packages/cloud/core/src/account.ts | 67 --- packages/cloud/core/src/actor.ts | 74 --- packages/cloud/core/src/billing.ts | 244 -------- packages/cloud/core/src/context.ts | 21 - packages/cloud/core/src/drizzle/index.ts | 86 --- packages/cloud/core/src/drizzle/types.ts | 33 -- packages/cloud/core/src/identifier.ts | 26 - packages/cloud/core/src/key.ts | 75 --- packages/cloud/core/src/schema/account.sql.ts | 12 - packages/cloud/core/src/schema/billing.sql.ts | 53 -- packages/cloud/core/src/schema/key.sql.ts | 22 - packages/cloud/core/src/schema/user.sql.ts | 16 - packages/cloud/core/src/schema/workspace.sql.ts | 21 - packages/cloud/core/src/user.ts | 18 - packages/cloud/core/src/util/env.cloudflare.ts | 0 packages/cloud/core/src/util/fn.ts | 11 - packages/cloud/core/src/util/log.ts | 55 -- packages/cloud/core/src/util/memo.ts | 18 - packages/cloud/core/src/util/price.ts | 3 - packages/cloud/core/src/workspace.ts | 58 -- packages/cloud/core/sst-env.d.ts | 9 - packages/cloud/core/tsconfig.json | 9 - packages/cloud/function/package.json | 26 - packages/cloud/function/src/auth.ts | 140 ----- packages/cloud/function/src/log-processor.ts | 49 -- packages/cloud/function/sst-env.d.ts | 96 --- packages/cloud/function/tsconfig.json | 9 - packages/cloud/resource/bun.lock | 13 - packages/cloud/resource/package.json | 15 - packages/cloud/resource/resource.cloudflare.ts | 18 - packages/cloud/resource/resource.node.ts | 1 - packages/cloud/resource/sst-env.d.ts | 96 --- packages/cloud/resource/tsconfig.json | 9 - packages/cloud/scripts/.gitignore | 1 - packages/cloud/scripts/package.json | 20 - .../cloud/scripts/src/backfill-usage-provider.ts | 10 - packages/cloud/scripts/sst-env.d.ts | 9 - packages/cloud/scripts/tsconfig.json | 9 - packages/console/app/.gitignore | 28 + packages/console/app/.opencode/agent/css.md | 149 +++++ packages/console/app/README.md | 32 + packages/console/app/app.config.ts | 23 + packages/console/app/package.json | 25 + packages/console/app/public/favicon.svg | 5 + packages/console/app/public/robots.txt | 5 + packages/console/app/public/social-share.png | Bin 0 -> 17520 bytes packages/console/app/public/theme.json | 182 ++++++ packages/console/app/src/app.css | 1 + packages/console/app/src/app.tsx | 23 + packages/console/app/src/asset/lander/check.svg | 2 + packages/console/app/src/asset/lander/copy.svg | 2 + .../app/src/asset/lander/screenshot-github.png | Bin 0 -> 924094 bytes .../app/src/asset/lander/screenshot-splash.png | Bin 0 -> 467281 bytes .../app/src/asset/lander/screenshot-vscode.png | Bin 0 -> 1022418 bytes .../console/app/src/asset/lander/screenshot.png | Bin 0 -> 606051 bytes .../console/app/src/asset/logo-ornate-dark.svg | 19 + .../console/app/src/asset/logo-ornate-light.svg | 18 + packages/console/app/src/asset/logo.svg | 12 + packages/console/app/src/component/icon.tsx | 82 +++ .../component/workspace/billing-section.module.css | 114 ++++ .../src/component/workspace/billing-section.tsx | 193 ++++++ .../console/app/src/component/workspace/common.tsx | 25 + .../src/component/workspace/key-section.module.css | 172 ++++++ .../app/src/component/workspace/key-section.tsx | 182 ++++++ .../workspace/monthly-limit-section.module.css | 102 ++++ .../component/workspace/monthly-limit-section.tsx | 139 +++++ .../workspace/new-user-section.module.css | 163 ++++++ .../src/component/workspace/new-user-section.tsx | 97 ++++ .../component/workspace/payment-section.module.css | 72 +++ .../src/component/workspace/payment-section.tsx | 113 ++++ .../component/workspace/usage-section.module.css | 88 +++ .../app/src/component/workspace/usage-section.tsx | 128 ++++ packages/console/app/src/context/auth.session.ts | 23 + packages/console/app/src/context/auth.ts | 83 +++ packages/console/app/src/context/auth.withActor.ts | 7 + packages/console/app/src/entry-client.tsx | 4 + packages/console/app/src/entry-server.tsx | 28 + packages/console/app/src/global.d.ts | 1 + packages/console/app/src/middleware.ts | 5 + packages/console/app/src/routes/[...404].css | 130 +++++ packages/console/app/src/routes/[...404].tsx | 38 ++ packages/console/app/src/routes/auth/authorize.ts | 7 + packages/console/app/src/routes/auth/callback.ts | 31 + packages/console/app/src/routes/auth/index.ts | 13 + packages/console/app/src/routes/debug/index.ts | 13 + packages/console/app/src/routes/discord.ts | 5 + packages/console/app/src/routes/docs/[...path].ts | 20 + packages/console/app/src/routes/docs/index.ts | 20 + packages/console/app/src/routes/index.css | 504 ++++++++++++++++ packages/console/app/src/routes/index.tsx | 183 ++++++ packages/console/app/src/routes/s/[id].ts | 20 + packages/console/app/src/routes/stripe/webhook.ts | 98 ++++ packages/console/app/src/routes/workspace.css | 127 ++++ packages/console/app/src/routes/workspace.tsx | 67 +++ packages/console/app/src/routes/workspace/[id].css | 115 ++++ packages/console/app/src/routes/workspace/[id].tsx | 50 ++ .../console/app/src/routes/workspace/index.tsx | 0 packages/console/app/src/routes/zen/handler.ts | 594 +++++++++++++++++++ .../app/src/routes/zen/v1/chat/completions.ts | 54 ++ packages/console/app/src/routes/zen/v1/messages.ts | 61 ++ .../console/app/src/routes/zen/v1/responses.ts | 52 ++ packages/console/app/src/style/base.css | 9 + .../console/app/src/style/component/button.css | 102 ++++ packages/console/app/src/style/index.css | 8 + packages/console/app/src/style/reset.css | 76 +++ packages/console/app/src/style/token/color.css | 91 +++ packages/console/app/src/style/token/font.css | 20 + packages/console/app/src/style/token/space.css | 46 ++ packages/console/app/sst-env.d.ts | 9 + packages/console/app/tsconfig.json | 21 + packages/console/core/drizzle.config.ts | 20 + .../console/core/migrations/0000_fluffy_raza.sql | 89 +++ .../core/migrations/0001_serious_whistler.sql | 2 + .../console/core/migrations/0002_violet_loners.sql | 1 + .../core/migrations/0003_dusty_clint_barton.sql | 1 + .../core/migrations/0004_first_mockingbird.sql | 1 + .../console/core/migrations/0005_jazzy_skrulls.sql | 1 + .../core/migrations/0006_parallel_gauntlet.sql | 2 + .../core/migrations/0007_familiar_nightshade.sql | 1 + .../core/migrations/0008_eminent_ultimatum.sql | 1 + .../core/migrations/0009_redundant_piledriver.sql | 1 + .../core/migrations/0010_needy_sue_storm.sql | 1 + .../core/migrations/0011_freezing_phil_sheldon.sql | 3 + .../console/core/migrations/0012_bright_photon.sql | 3 + .../core/migrations/0013_absurd_hobgoblin.sql | 2 + .../core/migrations/meta/0000_snapshot.json | 569 ++++++++++++++++++ .../core/migrations/meta/0001_snapshot.json | 569 ++++++++++++++++++ .../core/migrations/meta/0002_snapshot.json | 576 ++++++++++++++++++ .../core/migrations/meta/0003_snapshot.json | 581 ++++++++++++++++++ .../core/migrations/meta/0004_snapshot.json | 588 +++++++++++++++++++ .../core/migrations/meta/0005_snapshot.json | 588 +++++++++++++++++++ .../core/migrations/meta/0006_snapshot.json | 602 +++++++++++++++++++ .../core/migrations/meta/0007_snapshot.json | 595 +++++++++++++++++++ .../core/migrations/meta/0008_snapshot.json | 602 +++++++++++++++++++ .../core/migrations/meta/0009_snapshot.json | 609 +++++++++++++++++++ .../core/migrations/meta/0010_snapshot.json | 615 ++++++++++++++++++++ .../core/migrations/meta/0011_snapshot.json | 622 ++++++++++++++++++++ .../core/migrations/meta/0012_snapshot.json | 643 ++++++++++++++++++++ .../core/migrations/meta/0013_snapshot.json | 646 +++++++++++++++++++++ .../console/core/migrations/meta/_journal.json | 104 ++++ packages/console/core/package.json | 29 + packages/console/core/src/account.ts | 67 +++ packages/console/core/src/actor.ts | 74 +++ packages/console/core/src/billing.ts | 244 ++++++++ packages/console/core/src/context.ts | 21 + packages/console/core/src/drizzle/index.ts | 86 +++ packages/console/core/src/drizzle/types.ts | 33 ++ packages/console/core/src/identifier.ts | 26 + packages/console/core/src/key.ts | 75 +++ packages/console/core/src/schema/account.sql.ts | 12 + packages/console/core/src/schema/billing.sql.ts | 53 ++ packages/console/core/src/schema/key.sql.ts | 22 + packages/console/core/src/schema/user.sql.ts | 16 + packages/console/core/src/schema/workspace.sql.ts | 21 + packages/console/core/src/user.ts | 18 + packages/console/core/src/util/env.cloudflare.ts | 0 packages/console/core/src/util/fn.ts | 11 + packages/console/core/src/util/log.ts | 55 ++ packages/console/core/src/util/memo.ts | 18 + packages/console/core/src/util/price.ts | 3 + packages/console/core/src/workspace.ts | 58 ++ packages/console/core/sst-env.d.ts | 9 + packages/console/core/tsconfig.json | 9 + packages/console/function/package.json | 26 + packages/console/function/src/auth.ts | 140 +++++ packages/console/function/src/log-processor.ts | 49 ++ packages/console/function/sst-env.d.ts | 96 +++ packages/console/function/tsconfig.json | 9 + packages/console/resource/bun.lock | 13 + packages/console/resource/package.json | 15 + packages/console/resource/resource.cloudflare.ts | 18 + packages/console/resource/resource.node.ts | 1 + packages/console/resource/sst-env.d.ts | 96 +++ packages/console/resource/tsconfig.json | 9 + packages/console/scripts/.gitignore | 1 + packages/console/scripts/package.json | 20 + .../console/scripts/src/backfill-usage-provider.ts | 10 + packages/console/scripts/sst-env.d.ts | 9 + packages/console/scripts/tsconfig.json | 9 + packages/function/sst-env.d.ts | 158 ++--- packages/opencode/sst-env.d.ts | 2 +- packages/plugin/sst-env.d.ts | 2 +- packages/sdk/js/sst-env.d.ts | 2 +- packages/web/sst-env.d.ts | 2 +- sdks/vscode/sst-env.d.ts | 2 +- sst-env.d.ts | 138 ++--- sst.config.ts | 2 +- 296 files changed, 15399 insertions(+), 15401 deletions(-) delete mode 100644 infra/cloud.ts create mode 100644 infra/console.ts delete mode 100644 packages/cloud/app/.gitignore delete mode 100644 packages/cloud/app/.opencode/agent/css.md delete mode 100644 packages/cloud/app/README.md delete mode 100644 packages/cloud/app/app.config.ts delete mode 100644 packages/cloud/app/package.json delete mode 100644 packages/cloud/app/public/favicon.svg delete mode 100644 packages/cloud/app/public/robots.txt delete mode 100644 packages/cloud/app/public/social-share.png delete mode 100644 packages/cloud/app/public/theme.json delete mode 100644 packages/cloud/app/src/app.css delete mode 100644 packages/cloud/app/src/app.tsx delete mode 100644 packages/cloud/app/src/asset/lander/check.svg delete mode 100644 packages/cloud/app/src/asset/lander/copy.svg delete mode 100644 packages/cloud/app/src/asset/lander/screenshot-github.png delete mode 100644 packages/cloud/app/src/asset/lander/screenshot-splash.png delete mode 100644 packages/cloud/app/src/asset/lander/screenshot-vscode.png delete mode 100644 packages/cloud/app/src/asset/lander/screenshot.png delete mode 100644 packages/cloud/app/src/asset/logo-ornate-dark.svg delete mode 100644 packages/cloud/app/src/asset/logo-ornate-light.svg delete mode 100644 packages/cloud/app/src/asset/logo.svg delete mode 100644 packages/cloud/app/src/component/icon.tsx delete mode 100644 packages/cloud/app/src/component/workspace/billing-section.module.css delete mode 100644 packages/cloud/app/src/component/workspace/billing-section.tsx delete mode 100644 packages/cloud/app/src/component/workspace/common.tsx delete mode 100644 packages/cloud/app/src/component/workspace/key-section.module.css delete mode 100644 packages/cloud/app/src/component/workspace/key-section.tsx delete mode 100644 packages/cloud/app/src/component/workspace/monthly-limit-section.module.css delete mode 100644 packages/cloud/app/src/component/workspace/monthly-limit-section.tsx delete mode 100644 packages/cloud/app/src/component/workspace/new-user-section.module.css delete mode 100644 packages/cloud/app/src/component/workspace/new-user-section.tsx delete mode 100644 packages/cloud/app/src/component/workspace/payment-section.module.css delete mode 100644 packages/cloud/app/src/component/workspace/payment-section.tsx delete mode 100644 packages/cloud/app/src/component/workspace/usage-section.module.css delete mode 100644 packages/cloud/app/src/component/workspace/usage-section.tsx delete mode 100644 packages/cloud/app/src/context/auth.session.ts delete mode 100644 packages/cloud/app/src/context/auth.ts delete mode 100644 packages/cloud/app/src/context/auth.withActor.ts delete mode 100644 packages/cloud/app/src/entry-client.tsx delete mode 100644 packages/cloud/app/src/entry-server.tsx delete mode 100644 packages/cloud/app/src/global.d.ts delete mode 100644 packages/cloud/app/src/middleware.ts delete mode 100644 packages/cloud/app/src/routes/[...404].css delete mode 100644 packages/cloud/app/src/routes/[...404].tsx delete mode 100644 packages/cloud/app/src/routes/auth/authorize.ts delete mode 100644 packages/cloud/app/src/routes/auth/callback.ts delete mode 100644 packages/cloud/app/src/routes/auth/index.ts delete mode 100644 packages/cloud/app/src/routes/debug/index.ts delete mode 100644 packages/cloud/app/src/routes/discord.ts delete mode 100644 packages/cloud/app/src/routes/docs/[...path].ts delete mode 100644 packages/cloud/app/src/routes/docs/index.ts delete mode 100644 packages/cloud/app/src/routes/index.css delete mode 100644 packages/cloud/app/src/routes/index.tsx delete mode 100644 packages/cloud/app/src/routes/s/[id].ts delete mode 100644 packages/cloud/app/src/routes/stripe/webhook.ts delete mode 100644 packages/cloud/app/src/routes/workspace.css delete mode 100644 packages/cloud/app/src/routes/workspace.tsx delete mode 100644 packages/cloud/app/src/routes/workspace/[id].css delete mode 100644 packages/cloud/app/src/routes/workspace/[id].tsx delete mode 100644 packages/cloud/app/src/routes/workspace/index.tsx delete mode 100644 packages/cloud/app/src/routes/zen/handler.ts delete mode 100644 packages/cloud/app/src/routes/zen/v1/chat/completions.ts delete mode 100644 packages/cloud/app/src/routes/zen/v1/messages.ts delete mode 100644 packages/cloud/app/src/routes/zen/v1/responses.ts delete mode 100644 packages/cloud/app/src/style/base.css delete mode 100644 packages/cloud/app/src/style/component/button.css delete mode 100644 packages/cloud/app/src/style/index.css delete mode 100644 packages/cloud/app/src/style/reset.css delete mode 100644 packages/cloud/app/src/style/token/color.css delete mode 100644 packages/cloud/app/src/style/token/font.css delete mode 100644 packages/cloud/app/src/style/token/space.css delete mode 100644 packages/cloud/app/sst-env.d.ts delete mode 100644 packages/cloud/app/tsconfig.json delete mode 100644 packages/cloud/core/drizzle.config.ts delete mode 100644 packages/cloud/core/migrations/0000_fluffy_raza.sql delete mode 100644 packages/cloud/core/migrations/0001_serious_whistler.sql delete mode 100644 packages/cloud/core/migrations/0002_violet_loners.sql delete mode 100644 packages/cloud/core/migrations/0003_dusty_clint_barton.sql delete mode 100644 packages/cloud/core/migrations/0004_first_mockingbird.sql delete mode 100644 packages/cloud/core/migrations/0005_jazzy_skrulls.sql delete mode 100644 packages/cloud/core/migrations/0006_parallel_gauntlet.sql delete mode 100644 packages/cloud/core/migrations/0007_familiar_nightshade.sql delete mode 100644 packages/cloud/core/migrations/0008_eminent_ultimatum.sql delete mode 100644 packages/cloud/core/migrations/0009_redundant_piledriver.sql delete mode 100644 packages/cloud/core/migrations/0010_needy_sue_storm.sql delete mode 100644 packages/cloud/core/migrations/0011_freezing_phil_sheldon.sql delete mode 100644 packages/cloud/core/migrations/0012_bright_photon.sql delete mode 100644 packages/cloud/core/migrations/0013_absurd_hobgoblin.sql delete mode 100644 packages/cloud/core/migrations/meta/0000_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0001_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0002_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0003_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0004_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0005_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0006_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0007_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0008_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0009_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0010_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0011_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0012_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/0013_snapshot.json delete mode 100644 packages/cloud/core/migrations/meta/_journal.json delete mode 100644 packages/cloud/core/package.json delete mode 100644 packages/cloud/core/src/account.ts delete mode 100644 packages/cloud/core/src/actor.ts delete mode 100644 packages/cloud/core/src/billing.ts delete mode 100644 packages/cloud/core/src/context.ts delete mode 100644 packages/cloud/core/src/drizzle/index.ts delete mode 100644 packages/cloud/core/src/drizzle/types.ts delete mode 100644 packages/cloud/core/src/identifier.ts delete mode 100644 packages/cloud/core/src/key.ts delete mode 100644 packages/cloud/core/src/schema/account.sql.ts delete mode 100644 packages/cloud/core/src/schema/billing.sql.ts delete mode 100644 packages/cloud/core/src/schema/key.sql.ts delete mode 100644 packages/cloud/core/src/schema/user.sql.ts delete mode 100644 packages/cloud/core/src/schema/workspace.sql.ts delete mode 100644 packages/cloud/core/src/user.ts delete mode 100644 packages/cloud/core/src/util/env.cloudflare.ts delete mode 100644 packages/cloud/core/src/util/fn.ts delete mode 100644 packages/cloud/core/src/util/log.ts delete mode 100644 packages/cloud/core/src/util/memo.ts delete mode 100644 packages/cloud/core/src/util/price.ts delete mode 100644 packages/cloud/core/src/workspace.ts delete mode 100644 packages/cloud/core/sst-env.d.ts delete mode 100644 packages/cloud/core/tsconfig.json delete mode 100644 packages/cloud/function/package.json delete mode 100644 packages/cloud/function/src/auth.ts delete mode 100644 packages/cloud/function/src/log-processor.ts delete mode 100644 packages/cloud/function/sst-env.d.ts delete mode 100644 packages/cloud/function/tsconfig.json delete mode 100644 packages/cloud/resource/bun.lock delete mode 100644 packages/cloud/resource/package.json delete mode 100644 packages/cloud/resource/resource.cloudflare.ts delete mode 100644 packages/cloud/resource/resource.node.ts delete mode 100644 packages/cloud/resource/sst-env.d.ts delete mode 100644 packages/cloud/resource/tsconfig.json delete mode 100644 packages/cloud/scripts/.gitignore delete mode 100644 packages/cloud/scripts/package.json delete mode 100644 packages/cloud/scripts/src/backfill-usage-provider.ts delete mode 100644 packages/cloud/scripts/sst-env.d.ts delete mode 100644 packages/cloud/scripts/tsconfig.json create mode 100644 packages/console/app/.gitignore create mode 100644 packages/console/app/.opencode/agent/css.md create mode 100644 packages/console/app/README.md create mode 100644 packages/console/app/app.config.ts create mode 100644 packages/console/app/package.json create mode 100644 packages/console/app/public/favicon.svg create mode 100644 packages/console/app/public/robots.txt create mode 100644 packages/console/app/public/social-share.png create mode 100644 packages/console/app/public/theme.json create mode 100644 packages/console/app/src/app.css create mode 100644 packages/console/app/src/app.tsx create mode 100644 packages/console/app/src/asset/lander/check.svg create mode 100644 packages/console/app/src/asset/lander/copy.svg create mode 100644 packages/console/app/src/asset/lander/screenshot-github.png create mode 100644 packages/console/app/src/asset/lander/screenshot-splash.png create mode 100644 packages/console/app/src/asset/lander/screenshot-vscode.png create mode 100644 packages/console/app/src/asset/lander/screenshot.png create mode 100644 packages/console/app/src/asset/logo-ornate-dark.svg create mode 100644 packages/console/app/src/asset/logo-ornate-light.svg create mode 100644 packages/console/app/src/asset/logo.svg create mode 100644 packages/console/app/src/component/icon.tsx create mode 100644 packages/console/app/src/component/workspace/billing-section.module.css create mode 100644 packages/console/app/src/component/workspace/billing-section.tsx create mode 100644 packages/console/app/src/component/workspace/common.tsx create mode 100644 packages/console/app/src/component/workspace/key-section.module.css create mode 100644 packages/console/app/src/component/workspace/key-section.tsx create mode 100644 packages/console/app/src/component/workspace/monthly-limit-section.module.css create mode 100644 packages/console/app/src/component/workspace/monthly-limit-section.tsx create mode 100644 packages/console/app/src/component/workspace/new-user-section.module.css create mode 100644 packages/console/app/src/component/workspace/new-user-section.tsx create mode 100644 packages/console/app/src/component/workspace/payment-section.module.css create mode 100644 packages/console/app/src/component/workspace/payment-section.tsx create mode 100644 packages/console/app/src/component/workspace/usage-section.module.css create mode 100644 packages/console/app/src/component/workspace/usage-section.tsx create mode 100644 packages/console/app/src/context/auth.session.ts create mode 100644 packages/console/app/src/context/auth.ts create mode 100644 packages/console/app/src/context/auth.withActor.ts create mode 100644 packages/console/app/src/entry-client.tsx create mode 100644 packages/console/app/src/entry-server.tsx create mode 100644 packages/console/app/src/global.d.ts create mode 100644 packages/console/app/src/middleware.ts create mode 100644 packages/console/app/src/routes/[...404].css create mode 100644 packages/console/app/src/routes/[...404].tsx create mode 100644 packages/console/app/src/routes/auth/authorize.ts create mode 100644 packages/console/app/src/routes/auth/callback.ts create mode 100644 packages/console/app/src/routes/auth/index.ts create mode 100644 packages/console/app/src/routes/debug/index.ts create mode 100644 packages/console/app/src/routes/discord.ts create mode 100644 packages/console/app/src/routes/docs/[...path].ts create mode 100644 packages/console/app/src/routes/docs/index.ts create mode 100644 packages/console/app/src/routes/index.css create mode 100644 packages/console/app/src/routes/index.tsx create mode 100644 packages/console/app/src/routes/s/[id].ts create mode 100644 packages/console/app/src/routes/stripe/webhook.ts create mode 100644 packages/console/app/src/routes/workspace.css create mode 100644 packages/console/app/src/routes/workspace.tsx create mode 100644 packages/console/app/src/routes/workspace/[id].css create mode 100644 packages/console/app/src/routes/workspace/[id].tsx create mode 100644 packages/console/app/src/routes/workspace/index.tsx create mode 100644 packages/console/app/src/routes/zen/handler.ts create mode 100644 packages/console/app/src/routes/zen/v1/chat/completions.ts create mode 100644 packages/console/app/src/routes/zen/v1/messages.ts create mode 100644 packages/console/app/src/routes/zen/v1/responses.ts create mode 100644 packages/console/app/src/style/base.css create mode 100644 packages/console/app/src/style/component/button.css create mode 100644 packages/console/app/src/style/index.css create mode 100644 packages/console/app/src/style/reset.css create mode 100644 packages/console/app/src/style/token/color.css create mode 100644 packages/console/app/src/style/token/font.css create mode 100644 packages/console/app/src/style/token/space.css create mode 100644 packages/console/app/sst-env.d.ts create mode 100644 packages/console/app/tsconfig.json create mode 100644 packages/console/core/drizzle.config.ts create mode 100644 packages/console/core/migrations/0000_fluffy_raza.sql create mode 100644 packages/console/core/migrations/0001_serious_whistler.sql create mode 100644 packages/console/core/migrations/0002_violet_loners.sql create mode 100644 packages/console/core/migrations/0003_dusty_clint_barton.sql create mode 100644 packages/console/core/migrations/0004_first_mockingbird.sql create mode 100644 packages/console/core/migrations/0005_jazzy_skrulls.sql create mode 100644 packages/console/core/migrations/0006_parallel_gauntlet.sql create mode 100644 packages/console/core/migrations/0007_familiar_nightshade.sql create mode 100644 packages/console/core/migrations/0008_eminent_ultimatum.sql create mode 100644 packages/console/core/migrations/0009_redundant_piledriver.sql create mode 100644 packages/console/core/migrations/0010_needy_sue_storm.sql create mode 100644 packages/console/core/migrations/0011_freezing_phil_sheldon.sql create mode 100644 packages/console/core/migrations/0012_bright_photon.sql create mode 100644 packages/console/core/migrations/0013_absurd_hobgoblin.sql create mode 100644 packages/console/core/migrations/meta/0000_snapshot.json create mode 100644 packages/console/core/migrations/meta/0001_snapshot.json create mode 100644 packages/console/core/migrations/meta/0002_snapshot.json create mode 100644 packages/console/core/migrations/meta/0003_snapshot.json create mode 100644 packages/console/core/migrations/meta/0004_snapshot.json create mode 100644 packages/console/core/migrations/meta/0005_snapshot.json create mode 100644 packages/console/core/migrations/meta/0006_snapshot.json create mode 100644 packages/console/core/migrations/meta/0007_snapshot.json create mode 100644 packages/console/core/migrations/meta/0008_snapshot.json create mode 100644 packages/console/core/migrations/meta/0009_snapshot.json create mode 100644 packages/console/core/migrations/meta/0010_snapshot.json create mode 100644 packages/console/core/migrations/meta/0011_snapshot.json create mode 100644 packages/console/core/migrations/meta/0012_snapshot.json create mode 100644 packages/console/core/migrations/meta/0013_snapshot.json create mode 100644 packages/console/core/migrations/meta/_journal.json create mode 100644 packages/console/core/package.json create mode 100644 packages/console/core/src/account.ts create mode 100644 packages/console/core/src/actor.ts create mode 100644 packages/console/core/src/billing.ts create mode 100644 packages/console/core/src/context.ts create mode 100644 packages/console/core/src/drizzle/index.ts create mode 100644 packages/console/core/src/drizzle/types.ts create mode 100644 packages/console/core/src/identifier.ts create mode 100644 packages/console/core/src/key.ts create mode 100644 packages/console/core/src/schema/account.sql.ts create mode 100644 packages/console/core/src/schema/billing.sql.ts create mode 100644 packages/console/core/src/schema/key.sql.ts create mode 100644 packages/console/core/src/schema/user.sql.ts create mode 100644 packages/console/core/src/schema/workspace.sql.ts create mode 100644 packages/console/core/src/user.ts create mode 100644 packages/console/core/src/util/env.cloudflare.ts create mode 100644 packages/console/core/src/util/fn.ts create mode 100644 packages/console/core/src/util/log.ts create mode 100644 packages/console/core/src/util/memo.ts create mode 100644 packages/console/core/src/util/price.ts create mode 100644 packages/console/core/src/workspace.ts create mode 100644 packages/console/core/sst-env.d.ts create mode 100644 packages/console/core/tsconfig.json create mode 100644 packages/console/function/package.json create mode 100644 packages/console/function/src/auth.ts create mode 100644 packages/console/function/src/log-processor.ts create mode 100644 packages/console/function/sst-env.d.ts create mode 100644 packages/console/function/tsconfig.json create mode 100644 packages/console/resource/bun.lock create mode 100644 packages/console/resource/package.json create mode 100644 packages/console/resource/resource.cloudflare.ts create mode 100644 packages/console/resource/resource.node.ts create mode 100644 packages/console/resource/sst-env.d.ts create mode 100644 packages/console/resource/tsconfig.json create mode 100644 packages/console/scripts/.gitignore create mode 100644 packages/console/scripts/package.json create mode 100644 packages/console/scripts/src/backfill-usage-provider.ts create mode 100644 packages/console/scripts/sst-env.d.ts create mode 100644 packages/console/scripts/tsconfig.json diff --git a/bun.lock b/bun.lock index 48c8ea5b6..b19e23641 100644 --- a/bun.lock +++ b/bun.lock @@ -44,12 +44,12 @@ "vite-plugin-solid": "^2.11.6", }, }, - "packages/cloud/app": { - "name": "@opencode/cloud-app", + "packages/console/app": { + "name": "@opencode/console-app", "dependencies": { "@ibm/plex": "6.4.1", "@openauthjs/openauth": "0.0.0-20250322224806", - "@opencode/cloud-core": "workspace:*", + "@opencode/console-core": "workspace:*", "@solidjs/meta": "^0.29.4", "@solidjs/router": "^0.15.0", "@solidjs/start": "^1.1.0", @@ -57,12 +57,12 @@ "vinxi": "^0.5.7", }, }, - "packages/cloud/core": { - "name": "@opencode/cloud-core", + "packages/console/core": { + "name": "@opencode/console-core", "version": "0.9.11", "dependencies": { "@aws-sdk/client-sts": "3.782.0", - "@opencode/cloud-resource": "workspace:*", + "@opencode/console-resource": "workspace:*", "@planetscale/database": "1.19.0", "drizzle-orm": "0.41.0", "postgres": "3.4.7", @@ -74,8 +74,8 @@ "mysql2": "3.14.4", }, }, - "packages/cloud/function": { - "name": "@opencode/cloud-function", + "packages/console/function": { + "name": "@opencode/console-function", "version": "0.9.11", "dependencies": { "@ai-sdk/anthropic": "2.0.0", @@ -94,17 +94,17 @@ "typescript": "catalog:", }, }, - "packages/cloud/resource": { - "name": "@opencode/cloud-resource", + "packages/console/resource": { + "name": "@opencode/console-resource", "dependencies": { "@cloudflare/workers-types": "^4.20250830.0", }, }, - "packages/cloud/scripts": { - "name": "@opencode/cloud-scripts", + "packages/console/scripts": { + "name": "@opencode/console-scripts", "version": "0.9.11", "dependencies": { - "@opencode/cloud-core": "workspace:*", + "@opencode/console-core": "workspace:*", "tsx": "4.20.5", }, "devDependencies": { @@ -694,15 +694,15 @@ "@opencode/app": ["@opencode/app@workspace:packages/app"], - "@opencode/cloud-app": ["@opencode/cloud-app@workspace:packages/cloud/app"], + "@opencode/console-app": ["@opencode/console-app@workspace:packages/console/app"], - "@opencode/cloud-core": ["@opencode/cloud-core@workspace:packages/cloud/core"], + "@opencode/console-core": ["@opencode/console-core@workspace:packages/console/core"], - "@opencode/cloud-function": ["@opencode/cloud-function@workspace:packages/cloud/function"], + "@opencode/console-function": ["@opencode/console-function@workspace:packages/console/function"], - "@opencode/cloud-resource": ["@opencode/cloud-resource@workspace:packages/cloud/resource"], + "@opencode/console-resource": ["@opencode/console-resource@workspace:packages/console/resource"], - "@opencode/cloud-scripts": ["@opencode/cloud-scripts@workspace:packages/cloud/scripts"], + "@opencode/console-scripts": ["@opencode/console-scripts@workspace:packages/console/scripts"], "@opencode/function": ["@opencode/function@workspace:packages/function"], @@ -914,11 +914,11 @@ "@smithy/abort-controller": ["@smithy/abort-controller@4.1.1", "", { "dependencies": { "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-vkzula+IwRvPR6oKQhMYioM3A/oX/lFCZiwuxkQbRhqJS2S4YRY2k7k/SyR2jMf3607HLtbEwlRxi0ndXHMjRg=="], - "@smithy/config-resolver": ["@smithy/config-resolver@4.2.1", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.1", "@smithy/types": "^4.5.0", "@smithy/util-config-provider": "^4.1.0", "@smithy/util-middleware": "^4.1.1", "tslib": "^2.6.2" } }, "sha512-FXil8q4QN7mgKwU2hCLm0ltab8NyY/1RiqEf25Jnf6WLS3wmb11zGAoLETqg1nur2Aoibun4w4MjeN9CMJ4G6A=="], + "@smithy/config-resolver": ["@smithy/config-resolver@4.2.2", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.2", "@smithy/types": "^4.5.0", "@smithy/util-config-provider": "^4.1.0", "@smithy/util-middleware": "^4.1.1", "tslib": "^2.6.2" } }, "sha512-IT6MatgBWagLybZl1xQcURXRICvqz1z3APSCAI9IqdvfCkrA7RaQIEfgC6G/KvfxnDfQUDqFV+ZlixcuFznGBQ=="], - "@smithy/core": ["@smithy/core@3.11.0", "", { "dependencies": { "@smithy/middleware-serde": "^4.1.1", "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "@smithy/util-base64": "^4.1.0", "@smithy/util-body-length-browser": "^4.1.0", "@smithy/util-middleware": "^4.1.1", "@smithy/util-stream": "^4.3.1", "@smithy/util-utf8": "^4.1.0", "@types/uuid": "^9.0.1", "tslib": "^2.6.2", "uuid": "^9.0.1" } }, "sha512-Abs5rdP1o8/OINtE49wwNeWuynCu0kme1r4RI3VXVrHr4odVDG7h7mTnw1WXXfN5Il+c25QOnrdL2y56USfxkA=="], + "@smithy/core": ["@smithy/core@3.11.1", "", { "dependencies": { "@smithy/middleware-serde": "^4.1.1", "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "@smithy/util-base64": "^4.1.0", "@smithy/util-body-length-browser": "^4.1.0", "@smithy/util-middleware": "^4.1.1", "@smithy/util-stream": "^4.3.2", "@smithy/util-utf8": "^4.1.0", "@types/uuid": "^9.0.1", "tslib": "^2.6.2", "uuid": "^9.0.1" } }, "sha512-REH7crwORgdjSpYs15JBiIWOYjj0hJNC3aCecpJvAlMMaaqL5i2CLb1i6Hc4yevToTKSqslLMI9FKjhugEwALA=="], - "@smithy/credential-provider-imds": ["@smithy/credential-provider-imds@4.1.1", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.1", "@smithy/property-provider": "^4.1.1", "@smithy/types": "^4.5.0", "@smithy/url-parser": "^4.1.1", "tslib": "^2.6.2" } }, "sha512-1WdBfM9DwA59pnpIizxnUvBf/de18p4GP+6zP2AqrlFzoW3ERpZaT4QueBR0nS9deDMaQRkBlngpVlnkuuTisQ=="], + "@smithy/credential-provider-imds": ["@smithy/credential-provider-imds@4.1.2", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.2", "@smithy/property-provider": "^4.1.1", "@smithy/types": "^4.5.0", "@smithy/url-parser": "^4.1.1", "tslib": "^2.6.2" } }, "sha512-JlYNq8TShnqCLg0h+afqe2wLAwZpuoSgOyzhYvTgbiKBWRov+uUve+vrZEQO6lkdLOWPh7gK5dtb9dS+KGendg=="], "@smithy/eventstream-codec": ["@smithy/eventstream-codec@4.1.1", "", { "dependencies": { "@aws-crypto/crc32": "5.2.0", "@smithy/types": "^4.5.0", "@smithy/util-hex-encoding": "^4.1.0", "tslib": "^2.6.2" } }, "sha512-PwkQw1hZwHTQB6X5hSUWz2OSeuj5Z6enWuAqke7DgWoP3t6vg3ktPpqPz3Erkn6w+tmsl8Oss6nrgyezoea2Iw=="], @@ -932,15 +932,15 @@ "@smithy/middleware-content-length": ["@smithy/middleware-content-length@4.1.1", "", { "dependencies": { "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-9wlfBBgTsRvC2JxLJxv4xDGNBrZuio3AgSl0lSFX7fneW2cGskXTYpFxCdRYD2+5yzmsiTuaAJD1Wp7gWt9y9w=="], - "@smithy/middleware-endpoint": ["@smithy/middleware-endpoint@4.2.1", "", { "dependencies": { "@smithy/core": "^3.11.0", "@smithy/middleware-serde": "^4.1.1", "@smithy/node-config-provider": "^4.2.1", "@smithy/shared-ini-file-loader": "^4.1.1", "@smithy/types": "^4.5.0", "@smithy/url-parser": "^4.1.1", "@smithy/util-middleware": "^4.1.1", "tslib": "^2.6.2" } }, "sha512-fUTMmQvQQZakXOuKizfu7fBLDpwvWZjfH6zUK2OLsoNZRZGbNUdNSdLJHpwk1vS208jtDjpUIskh+JoA8zMzZg=="], + "@smithy/middleware-endpoint": ["@smithy/middleware-endpoint@4.2.3", "", { "dependencies": { "@smithy/core": "^3.11.1", "@smithy/middleware-serde": "^4.1.1", "@smithy/node-config-provider": "^4.2.2", "@smithy/shared-ini-file-loader": "^4.2.0", "@smithy/types": "^4.5.0", "@smithy/url-parser": "^4.1.1", "@smithy/util-middleware": "^4.1.1", "tslib": "^2.6.2" } }, "sha512-+1H5A28DeffRVrqmVmtqtRraEjoaC6JVap3xEQdVoBh2EagCVY7noPmcBcG4y7mnr9AJitR1ZAse2l+tEtK5vg=="], - "@smithy/middleware-retry": ["@smithy/middleware-retry@4.2.1", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.1", "@smithy/protocol-http": "^5.2.1", "@smithy/service-error-classification": "^4.1.1", "@smithy/smithy-client": "^4.6.1", "@smithy/types": "^4.5.0", "@smithy/util-middleware": "^4.1.1", "@smithy/util-retry": "^4.1.1", "@types/uuid": "^9.0.1", "tslib": "^2.6.2", "uuid": "^9.0.1" } }, "sha512-JzfvjwSJXWRl7LkLgIRTUTd2Wj639yr3sQGpViGNEOjtb0AkAuYqRAHs+jSOI/LPC0ZTjmFVVtfrCICMuebexw=="], + "@smithy/middleware-retry": ["@smithy/middleware-retry@4.2.4", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.2", "@smithy/protocol-http": "^5.2.1", "@smithy/service-error-classification": "^4.1.2", "@smithy/smithy-client": "^4.6.3", "@smithy/types": "^4.5.0", "@smithy/util-middleware": "^4.1.1", "@smithy/util-retry": "^4.1.2", "@types/uuid": "^9.0.1", "tslib": "^2.6.2", "uuid": "^9.0.1" } }, "sha512-amyqYQFewnAviX3yy/rI/n1HqAgfvUdkEhc04kDjxsngAUREKuOI24iwqQUirrj6GtodWmR4iO5Zeyl3/3BwWg=="], "@smithy/middleware-serde": ["@smithy/middleware-serde@4.1.1", "", { "dependencies": { "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-lh48uQdbCoj619kRouev5XbWhCwRKLmphAif16c4J6JgJ4uXjub1PI6RL38d3BLliUvSso6klyB/LTNpWSNIyg=="], "@smithy/middleware-stack": ["@smithy/middleware-stack@4.1.1", "", { "dependencies": { "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-ygRnniqNcDhHzs6QAPIdia26M7e7z9gpkIMUe/pK0RsrQ7i5MblwxY8078/QCnGq6AmlUUWgljK2HlelsKIb/A=="], - "@smithy/node-config-provider": ["@smithy/node-config-provider@4.2.1", "", { "dependencies": { "@smithy/property-provider": "^4.1.1", "@smithy/shared-ini-file-loader": "^4.1.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-AIA0BJZq2h295J5NeCTKhg1WwtdTA/GqBCaVjk30bDgMHwniUETyh5cP9IiE9VrId7Kt8hS7zvREVMTv1VfA6g=="], + "@smithy/node-config-provider": ["@smithy/node-config-provider@4.2.2", "", { "dependencies": { "@smithy/property-provider": "^4.1.1", "@smithy/shared-ini-file-loader": "^4.2.0", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-SYGTKyPvyCfEzIN5rD8q/bYaOPZprYUPD2f5g9M7OjaYupWOoQFYJ5ho+0wvxIRf471i2SR4GoiZ2r94Jq9h6A=="], "@smithy/node-http-handler": ["@smithy/node-http-handler@4.2.1", "", { "dependencies": { "@smithy/abort-controller": "^4.1.1", "@smithy/protocol-http": "^5.2.1", "@smithy/querystring-builder": "^4.1.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-REyybygHlxo3TJICPF89N2pMQSf+p+tBJqpVe1+77Cfi9HBPReNjTgtZ1Vg73exq24vkqJskKDpfF74reXjxfw=="], @@ -952,13 +952,13 @@ "@smithy/querystring-parser": ["@smithy/querystring-parser@4.1.1", "", { "dependencies": { "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-63TEp92YFz0oQ7Pj9IuI3IgnprP92LrZtRAkE3c6wLWJxfy/yOPRt39IOKerVr0JS770olzl0kGafXlAXZ1vng=="], - "@smithy/service-error-classification": ["@smithy/service-error-classification@4.1.1", "", { "dependencies": { "@smithy/types": "^4.5.0" } }, "sha512-Iam75b/JNXyDE41UvrlM6n8DNOa/r1ylFyvgruTUx7h2Uk7vDNV9AAwP1vfL1fOL8ls0xArwEGVcGZVd7IO/Cw=="], + "@smithy/service-error-classification": ["@smithy/service-error-classification@4.1.2", "", { "dependencies": { "@smithy/types": "^4.5.0" } }, "sha512-Kqd8wyfmBWHZNppZSMfrQFpc3M9Y/kjyN8n8P4DqJJtuwgK1H914R471HTw7+RL+T7+kI1f1gOnL7Vb5z9+NgQ=="], - "@smithy/shared-ini-file-loader": ["@smithy/shared-ini-file-loader@4.1.1", "", { "dependencies": { "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-YkpikhIqGc4sfXeIbzSj10t2bJI/sSoP5qxLue6zG+tEE3ngOBSm8sO3+djacYvS/R5DfpxN/L9CyZsvwjWOAQ=="], + "@smithy/shared-ini-file-loader": ["@smithy/shared-ini-file-loader@4.2.0", "", { "dependencies": { "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-OQTfmIEp2LLuWdxa8nEEPhZmiOREO6bcB6pjs0AySf4yiZhl6kMOfqmcwcY8BaBPX+0Tb+tG7/Ia/6mwpoZ7Pw=="], "@smithy/signature-v4": ["@smithy/signature-v4@5.2.1", "", { "dependencies": { "@smithy/is-array-buffer": "^4.1.0", "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "@smithy/util-hex-encoding": "^4.1.0", "@smithy/util-middleware": "^4.1.1", "@smithy/util-uri-escape": "^4.1.0", "@smithy/util-utf8": "^4.1.0", "tslib": "^2.6.2" } }, "sha512-M9rZhWQLjlQVCCR37cSjHfhriGRN+FQ8UfgrYNufv66TJgk+acaggShl3KS5U/ssxivvZLlnj7QH2CUOKlxPyA=="], - "@smithy/smithy-client": ["@smithy/smithy-client@4.6.1", "", { "dependencies": { "@smithy/core": "^3.11.0", "@smithy/middleware-endpoint": "^4.2.1", "@smithy/middleware-stack": "^4.1.1", "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "@smithy/util-stream": "^4.3.1", "tslib": "^2.6.2" } }, "sha512-WolVLDb9UTPMEPPOncrCt6JmAMCSC/V2y5gst2STWJ5r7+8iNac+EFYQnmvDCYMfOLcilOSEpm5yXZXwbLak1Q=="], + "@smithy/smithy-client": ["@smithy/smithy-client@4.6.3", "", { "dependencies": { "@smithy/core": "^3.11.1", "@smithy/middleware-endpoint": "^4.2.3", "@smithy/middleware-stack": "^4.1.1", "@smithy/protocol-http": "^5.2.1", "@smithy/types": "^4.5.0", "@smithy/util-stream": "^4.3.2", "tslib": "^2.6.2" } }, "sha512-K27LqywsaqKz4jusdUQYJh/YP2VbnbdskZ42zG8xfV+eovbTtMc2/ZatLWCfSkW0PDsTUXlpvlaMyu8925HsOw=="], "@smithy/types": ["@smithy/types@4.5.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-RkUpIOsVlAwUIZXO1dsz8Zm+N72LClFfsNqf173catVlvRZiwPy0x2u0JLEA4byreOPKDZPGjmPDylMoP8ZJRg=="], @@ -974,19 +974,19 @@ "@smithy/util-config-provider": ["@smithy/util-config-provider@4.1.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-swXz2vMjrP1ZusZWVTB/ai5gK+J8U0BWvP10v9fpcFvg+Xi/87LHvHfst2IgCs1i0v4qFZfGwCmeD/KNCdJZbQ=="], - "@smithy/util-defaults-mode-browser": ["@smithy/util-defaults-mode-browser@4.1.1", "", { "dependencies": { "@smithy/property-provider": "^4.1.1", "@smithy/smithy-client": "^4.6.1", "@smithy/types": "^4.5.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-hA1AKIHFUMa9Tl6q6y8p0pJ9aWHCCG8s57flmIyLE0W7HcJeYrYtnqXDcGnftvXEhdQnSexyegXnzzTGk8bKLA=="], + "@smithy/util-defaults-mode-browser": ["@smithy/util-defaults-mode-browser@4.1.3", "", { "dependencies": { "@smithy/property-provider": "^4.1.1", "@smithy/smithy-client": "^4.6.3", "@smithy/types": "^4.5.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-5fm3i2laE95uhY6n6O6uGFxI5SVbqo3/RWEuS3YsT0LVmSZk+0eUqPhKd4qk0KxBRPaT5VNT/WEBUqdMyYoRgg=="], - "@smithy/util-defaults-mode-node": ["@smithy/util-defaults-mode-node@4.1.1", "", { "dependencies": { "@smithy/config-resolver": "^4.2.1", "@smithy/credential-provider-imds": "^4.1.1", "@smithy/node-config-provider": "^4.2.1", "@smithy/property-provider": "^4.1.1", "@smithy/smithy-client": "^4.6.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-RGSpmoBrA+5D2WjwtK7tto6Pc2wO9KSXKLpLONhFZ8VyuCbqlLdiDAfuDTNY9AJe4JoE+Cx806cpTQQoQ71zPQ=="], + "@smithy/util-defaults-mode-node": ["@smithy/util-defaults-mode-node@4.1.3", "", { "dependencies": { "@smithy/config-resolver": "^4.2.2", "@smithy/credential-provider-imds": "^4.1.2", "@smithy/node-config-provider": "^4.2.2", "@smithy/property-provider": "^4.1.1", "@smithy/smithy-client": "^4.6.3", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-lwnMzlMslZ9GJNt+/wVjz6+fe9Wp5tqR1xAyQn+iywmP+Ymj0F6NhU/KfHM5jhGPQchRSCcau5weKhFdLIM4cA=="], - "@smithy/util-endpoints": ["@smithy/util-endpoints@3.1.1", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-qB4R9kO0SetA11Rzu6MVGFIaGYX3p6SGGGfWwsKnC6nXIf0n/0AKVwRTsYsz9ToN8CeNNtNgQRwKFBndGJZdyw=="], + "@smithy/util-endpoints": ["@smithy/util-endpoints@3.1.2", "", { "dependencies": { "@smithy/node-config-provider": "^4.2.2", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-+AJsaaEGb5ySvf1SKMRrPZdYHRYSzMkCoK16jWnIMpREAnflVspMIDeCVSZJuj+5muZfgGpNpijE3mUNtjv01Q=="], "@smithy/util-hex-encoding": ["@smithy/util-hex-encoding@4.1.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-1LcueNN5GYC4tr8mo14yVYbh/Ur8jHhWOxniZXii+1+ePiIbsLZ5fEI0QQGtbRRP5mOhmooos+rLmVASGGoq5w=="], "@smithy/util-middleware": ["@smithy/util-middleware@4.1.1", "", { "dependencies": { "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-CGmZ72mL29VMfESz7S6dekqzCh8ZISj3B+w0g1hZFXaOjGTVaSqfAEFAq8EGp8fUL+Q2l8aqNmt8U1tglTikeg=="], - "@smithy/util-retry": ["@smithy/util-retry@4.1.1", "", { "dependencies": { "@smithy/service-error-classification": "^4.1.1", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-jGeybqEZ/LIordPLMh5bnmnoIgsqnp4IEimmUp5c5voZ8yx+5kAlN5+juyr7p+f7AtZTgvhmInQk4Q0UVbrZ0Q=="], + "@smithy/util-retry": ["@smithy/util-retry@4.1.2", "", { "dependencies": { "@smithy/service-error-classification": "^4.1.2", "@smithy/types": "^4.5.0", "tslib": "^2.6.2" } }, "sha512-NCgr1d0/EdeP6U5PSZ9Uv5SMR5XRRYoVr1kRVtKZxWL3tixEL3UatrPIMFZSKwHlCcp2zPLDvMubVDULRqeunA=="], - "@smithy/util-stream": ["@smithy/util-stream@4.3.1", "", { "dependencies": { "@smithy/fetch-http-handler": "^5.2.1", "@smithy/node-http-handler": "^4.2.1", "@smithy/types": "^4.5.0", "@smithy/util-base64": "^4.1.0", "@smithy/util-buffer-from": "^4.1.0", "@smithy/util-hex-encoding": "^4.1.0", "@smithy/util-utf8": "^4.1.0", "tslib": "^2.6.2" } }, "sha512-khKkW/Jqkgh6caxMWbMuox9+YfGlsk9OnHOYCGVEdYQb/XVzcORXHLYUubHmmda0pubEDncofUrPNniS9d+uAA=="], + "@smithy/util-stream": ["@smithy/util-stream@4.3.2", "", { "dependencies": { "@smithy/fetch-http-handler": "^5.2.1", "@smithy/node-http-handler": "^4.2.1", "@smithy/types": "^4.5.0", "@smithy/util-base64": "^4.1.0", "@smithy/util-buffer-from": "^4.1.0", "@smithy/util-hex-encoding": "^4.1.0", "@smithy/util-utf8": "^4.1.0", "tslib": "^2.6.2" } }, "sha512-Ka+FA2UCC/Q1dEqUanCdpqwxOFdf5Dg2VXtPtB1qxLcSGh5C1HdzklIt18xL504Wiy9nNUKwDMRTVCbKGoK69g=="], "@smithy/util-uri-escape": ["@smithy/util-uri-escape@4.1.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-b0EFQkq35K5NHUYxU72JuoheM6+pytEVUGlTwiFxWFpmddA+Bpz3LgsPRIpBk8lnPE47yT7AF2Egc3jVnKLuPg=="], @@ -3028,7 +3028,7 @@ "@opencode-ai/sdk/@hey-api/openapi-ts": ["@hey-api/openapi-ts@0.81.0", "", { "dependencies": { "@hey-api/json-schema-ref-parser": "1.0.6", "ansi-colors": "4.1.3", "c12": "2.0.1", "color-support": "1.1.3", "commander": "13.0.0", "handlebars": "4.7.8", "js-yaml": "4.1.0", "open": "10.1.2", "semver": "7.7.2" }, "peerDependencies": { "typescript": "^5.5.3" }, "bin": { "openapi-ts": "bin/index.cjs" } }, "sha512-PoJukNBkUfHOoMDpN33bBETX49TUhy7Hu8Sa0jslOvFndvZ5VjQr4Nl/Dzjb9LG1Lp5HjybyTJMA6a1zYk/q6A=="], - "@opencode/cloud-resource/@cloudflare/workers-types": ["@cloudflare/workers-types@4.20250913.0", "", {}, "sha512-JjrYEvRn7cyALxwoFTw3XChaQneHSJOXqz2t5iKEpNzAnC2iPQU75rtTK/gw03Jjy4SHY5aEBh/uqQePtonZlA=="], + "@opencode/console-resource/@cloudflare/workers-types": ["@cloudflare/workers-types@4.20250913.0", "", {}, "sha512-JjrYEvRn7cyALxwoFTw3XChaQneHSJOXqz2t5iKEpNzAnC2iPQU75rtTK/gw03Jjy4SHY5aEBh/uqQePtonZlA=="], "@opencode/web/@shikijs/transformers": ["@shikijs/transformers@3.4.2", "", { "dependencies": { "@shikijs/core": "3.4.2", "@shikijs/types": "3.4.2" } }, "sha512-I5baLVi/ynLEOZoWSAMlACHNnG+yw5HDmse0oe+GW6U1u+ULdEB3UHiVWaHoJSSONV7tlcVxuaMy74sREDkSvg=="], @@ -3200,7 +3200,7 @@ "named-placeholders/lru-cache": ["lru-cache@7.18.3", "", {}, "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA=="], - "nitropack/c12": ["c12@3.2.0", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.1", "exsolve": "^1.0.7", "giget": "^2.0.0", "jiti": "^2.5.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^1.0.0", "pkg-types": "^2.2.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "^0.3.5" }, "optionalPeers": ["magicast"] }, "sha512-ixkEtbYafL56E6HiFuonMm1ZjoKtIo7TH68/uiEq4DAwv9NcUX2nJ95F8TrbMeNjqIkZpruo3ojXQJ+MGG5gcQ=="], + "nitropack/c12": ["c12@3.3.0", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.2", "exsolve": "^1.0.7", "giget": "^2.0.0", "jiti": "^2.5.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^2.0.0", "pkg-types": "^2.3.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "^0.3.5" }, "optionalPeers": ["magicast"] }, "sha512-K9ZkuyeJQeqLEyqldbYLG3wjqwpw4BVaAqvmxq3GYKK0b1A/yYQdIcJxkzAOWcNVWhJpRXAPfZFueekiY/L8Dw=="], "nitropack/confbox": ["confbox@0.2.2", "", {}, "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ=="], @@ -3584,8 +3584,6 @@ "nitropack/c12/giget": ["giget@2.0.0", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.0", "defu": "^6.1.4", "node-fetch-native": "^1.6.6", "nypm": "^0.6.0", "pathe": "^2.0.3" }, "bin": { "giget": "dist/cli.mjs" } }, "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA=="], - "nitropack/c12/perfect-debounce": ["perfect-debounce@1.0.0", "", {}, "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="], - "nitropack/h3/cookie-es": ["cookie-es@1.2.2", "", {}, "sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg=="], "nitropack/serve-static/send": ["send@1.2.0", "", { "dependencies": { "debug": "^4.3.5", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", "http-errors": "^2.0.0", "mime-types": "^3.0.1", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.1" } }, "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw=="], @@ -3750,7 +3748,7 @@ "giget/tar/minizlib/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="], - "nitropack/c12/giget/nypm": ["nypm@0.6.1", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.2", "pathe": "^2.0.3", "pkg-types": "^2.2.0", "tinyexec": "^1.0.1" }, "bin": { "nypm": "dist/cli.mjs" } }, "sha512-hlacBiRiv1k9hZFiphPUkfSQ/ZfQzZDzC+8z0wL3lvDAOUu/2NnChkKuMoMjNur/9OpKuz2QsIeiPVN0xM5Q0w=="], + "nitropack/c12/giget/nypm": ["nypm@0.6.2", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.2", "pathe": "^2.0.3", "pkg-types": "^2.3.0", "tinyexec": "^1.0.1" }, "bin": { "nypm": "dist/cli.mjs" } }, "sha512-7eM+hpOtrKrBDCh7Ypu2lJ9Z7PNZBdi/8AT3AX8xoCj43BBVHD0hPSTEvMtkMpfs8FCqBGhxB+uToIQimA111g=="], "node-gyp/glob/path-scurry/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="], diff --git a/github/sst-env.d.ts b/github/sst-env.d.ts index 6b69016e7..f742a1200 100644 --- a/github/sst-env.d.ts +++ b/github/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/infra/cloud.ts b/infra/cloud.ts deleted file mode 100644 index 23984cb4c..000000000 --- a/infra/cloud.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { WebhookEndpoint } from "pulumi-stripe" -import { domain } from "./stage" - -//////////////// -// DATABASE -//////////////// - -const cluster = planetscale.getDatabaseOutput({ - name: "opencode", - organization: "anomalyco", -}) - -const branch = - $app.stage === "production" - ? planetscale.getBranchOutput({ - name: "production", - organization: cluster.organization, - database: cluster.name, - }) - : new planetscale.Branch("DatabaseBranch", { - database: cluster.name, - organization: cluster.organization, - name: $app.stage, - parentBranch: "production", - }) -const password = new planetscale.Password("DatabasePassword", { - name: $app.stage, - database: cluster.name, - organization: cluster.organization, - branch: branch.name, -}) - -export const database = new sst.Linkable("Database", { - properties: { - host: password.accessHostUrl, - database: cluster.name, - username: password.username, - password: password.plaintext, - port: 3306, - }, -}) - -new sst.x.DevCommand("Studio", { - link: [database], - dev: { - command: "bun db studio", - directory: "packages/cloud/core", - autostart: true, - }, -}) - -//////////////// -// AUTH -//////////////// - -const GITHUB_CLIENT_ID_CONSOLE = new sst.Secret("GITHUB_CLIENT_ID_CONSOLE") -const GITHUB_CLIENT_SECRET_CONSOLE = new sst.Secret("GITHUB_CLIENT_SECRET_CONSOLE") -const GOOGLE_CLIENT_ID = new sst.Secret("GOOGLE_CLIENT_ID") -const authStorage = new sst.cloudflare.Kv("AuthStorage") -export const auth = new sst.cloudflare.Worker("AuthApi", { - domain: `auth.${domain}`, - handler: "packages/cloud/function/src/auth.ts", - url: true, - link: [database, authStorage, GITHUB_CLIENT_ID_CONSOLE, GITHUB_CLIENT_SECRET_CONSOLE, GOOGLE_CLIENT_ID], -}) - -//////////////// -// GATEWAY -//////////////// - -export const stripeWebhook = new WebhookEndpoint("StripeWebhookEndpoint", { - url: $interpolate`https://${domain}/stripe/webhook`, - enabledEvents: [ - "checkout.session.async_payment_failed", - "checkout.session.async_payment_succeeded", - "checkout.session.completed", - "checkout.session.expired", - "customer.created", - "customer.deleted", - "customer.updated", - "customer.discount.created", - "customer.discount.deleted", - "customer.discount.updated", - "customer.source.created", - "customer.source.deleted", - "customer.source.expiring", - "customer.source.updated", - "customer.subscription.created", - "customer.subscription.deleted", - "customer.subscription.paused", - "customer.subscription.pending_update_applied", - "customer.subscription.pending_update_expired", - "customer.subscription.resumed", - "customer.subscription.trial_will_end", - "customer.subscription.updated", - "customer.tax_id.created", - "customer.tax_id.deleted", - "customer.tax_id.updated", - ], -}) - -const ANTHROPIC_API_KEY = new sst.Secret("ANTHROPIC_API_KEY") -const OPENAI_API_KEY = new sst.Secret("OPENAI_API_KEY") -const XAI_API_KEY = new sst.Secret("XAI_API_KEY") -const BASETEN_API_KEY = new sst.Secret("BASETEN_API_KEY") -const FIREWORKS_API_KEY = new sst.Secret("FIREWORKS_API_KEY") -const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY") -const AUTH_API_URL = new sst.Linkable("AUTH_API_URL", { - properties: { value: auth.url.apply((url) => url!) }, -}) -const STRIPE_WEBHOOK_SECRET = new sst.Linkable("STRIPE_WEBHOOK_SECRET", { - properties: { value: stripeWebhook.secret }, -}) - -//////////////// -// CONSOLE -//////////////// - -let logProcessor -if ($app.stage === "production" || $app.stage === "frank") { - const HONEYCOMB_API_KEY = new sst.Secret("HONEYCOMB_API_KEY") - logProcessor = new sst.cloudflare.Worker("LogProcessor", { - handler: "packages/cloud/function/src/log-processor.ts", - link: [HONEYCOMB_API_KEY], - }) -} - -new sst.cloudflare.x.SolidStart("Console", { - domain, - path: "packages/cloud/app", - link: [ - database, - AUTH_API_URL, - STRIPE_WEBHOOK_SECRET, - STRIPE_SECRET_KEY, - ANTHROPIC_API_KEY, - OPENAI_API_KEY, - XAI_API_KEY, - BASETEN_API_KEY, - FIREWORKS_API_KEY, - ], - environment: { - //VITE_DOCS_URL: web.url.apply((url) => url!), - //VITE_API_URL: gateway.url.apply((url) => url!), - VITE_AUTH_URL: auth.url.apply((url) => url!), - }, - transform: { - server: { - transform: { - worker: { - placement: { mode: "smart" }, - tailConsumers: logProcessor ? [{ service: logProcessor.nodes.worker.scriptName }] : [], - }, - }, - }, - }, -}) diff --git a/infra/console.ts b/infra/console.ts new file mode 100644 index 000000000..6ca842380 --- /dev/null +++ b/infra/console.ts @@ -0,0 +1,157 @@ +import { WebhookEndpoint } from "pulumi-stripe" +import { domain } from "./stage" + +//////////////// +// DATABASE +//////////////// + +const cluster = planetscale.getDatabaseOutput({ + name: "opencode", + organization: "anomalyco", +}) + +const branch = + $app.stage === "production" + ? planetscale.getBranchOutput({ + name: "production", + organization: cluster.organization, + database: cluster.name, + }) + : new planetscale.Branch("DatabaseBranch", { + database: cluster.name, + organization: cluster.organization, + name: $app.stage, + parentBranch: "production", + }) +const password = new planetscale.Password("DatabasePassword", { + name: $app.stage, + database: cluster.name, + organization: cluster.organization, + branch: branch.name, +}) + +export const database = new sst.Linkable("Database", { + properties: { + host: password.accessHostUrl, + database: cluster.name, + username: password.username, + password: password.plaintext, + port: 3306, + }, +}) + +new sst.x.DevCommand("Studio", { + link: [database], + dev: { + command: "bun db studio", + directory: "packages/console/core", + autostart: true, + }, +}) + +//////////////// +// AUTH +//////////////// + +const GITHUB_CLIENT_ID_CONSOLE = new sst.Secret("GITHUB_CLIENT_ID_CONSOLE") +const GITHUB_CLIENT_SECRET_CONSOLE = new sst.Secret("GITHUB_CLIENT_SECRET_CONSOLE") +const GOOGLE_CLIENT_ID = new sst.Secret("GOOGLE_CLIENT_ID") +const authStorage = new sst.cloudflare.Kv("AuthStorage") +export const auth = new sst.cloudflare.Worker("AuthApi", { + domain: `auth.${domain}`, + handler: "packages/console/function/src/auth.ts", + url: true, + link: [database, authStorage, GITHUB_CLIENT_ID_CONSOLE, GITHUB_CLIENT_SECRET_CONSOLE, GOOGLE_CLIENT_ID], +}) + +//////////////// +// GATEWAY +//////////////// + +export const stripeWebhook = new WebhookEndpoint("StripeWebhookEndpoint", { + url: $interpolate`https://${domain}/stripe/webhook`, + enabledEvents: [ + "checkout.session.async_payment_failed", + "checkout.session.async_payment_succeeded", + "checkout.session.completed", + "checkout.session.expired", + "customer.created", + "customer.deleted", + "customer.updated", + "customer.discount.created", + "customer.discount.deleted", + "customer.discount.updated", + "customer.source.created", + "customer.source.deleted", + "customer.source.expiring", + "customer.source.updated", + "customer.subscription.created", + "customer.subscription.deleted", + "customer.subscription.paused", + "customer.subscription.pending_update_applied", + "customer.subscription.pending_update_expired", + "customer.subscription.resumed", + "customer.subscription.trial_will_end", + "customer.subscription.updated", + "customer.tax_id.created", + "customer.tax_id.deleted", + "customer.tax_id.updated", + ], +}) + +const ANTHROPIC_API_KEY = new sst.Secret("ANTHROPIC_API_KEY") +const OPENAI_API_KEY = new sst.Secret("OPENAI_API_KEY") +const XAI_API_KEY = new sst.Secret("XAI_API_KEY") +const BASETEN_API_KEY = new sst.Secret("BASETEN_API_KEY") +const FIREWORKS_API_KEY = new sst.Secret("FIREWORKS_API_KEY") +const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY") +const AUTH_API_URL = new sst.Linkable("AUTH_API_URL", { + properties: { value: auth.url.apply((url) => url!) }, +}) +const STRIPE_WEBHOOK_SECRET = new sst.Linkable("STRIPE_WEBHOOK_SECRET", { + properties: { value: stripeWebhook.secret }, +}) + +//////////////// +// CONSOLE +//////////////// + +let logProcessor +if ($app.stage === "production" || $app.stage === "frank") { + const HONEYCOMB_API_KEY = new sst.Secret("HONEYCOMB_API_KEY") + logProcessor = new sst.cloudflare.Worker("LogProcessor", { + handler: "packages/console/function/src/log-processor.ts", + link: [HONEYCOMB_API_KEY], + }) +} + +new sst.cloudflare.x.SolidStart("Console", { + domain, + path: "packages/console/app", + link: [ + database, + AUTH_API_URL, + STRIPE_WEBHOOK_SECRET, + STRIPE_SECRET_KEY, + ANTHROPIC_API_KEY, + OPENAI_API_KEY, + XAI_API_KEY, + BASETEN_API_KEY, + FIREWORKS_API_KEY, + ], + environment: { + //VITE_DOCS_URL: web.url.apply((url) => url!), + //VITE_API_URL: gateway.url.apply((url) => url!), + VITE_AUTH_URL: auth.url.apply((url) => url!), + }, + transform: { + server: { + transform: { + worker: { + placement: { mode: "smart" }, + tailConsumers: logProcessor ? [{ service: logProcessor.nodes.worker.scriptName }] : [], + }, + }, + }, + }, +}) diff --git a/package.json b/package.json index 8afdfbf96..d775a3faf 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "workspaces": { "packages": [ "packages/*", - "packages/cloud/*", + "packages/console/*", "packages/sdk/js" ], "catalog": { diff --git a/packages/app/sst-env.d.ts b/packages/app/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/app/sst-env.d.ts +++ b/packages/app/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/cloud/app/.gitignore b/packages/cloud/app/.gitignore deleted file mode 100644 index 751513ce1..000000000 --- a/packages/cloud/app/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -dist -.wrangler -.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 diff --git a/packages/cloud/app/.opencode/agent/css.md b/packages/cloud/app/.opencode/agent/css.md deleted file mode 100644 index d0ec43a48..000000000 --- a/packages/cloud/app/.opencode/agent/css.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -description: use whenever you are styling a ui with css ---- - -you are very good at writing clean maintainable css using modern techniques - -css is structured like this - -```css -[data-page="home"] { - [data-component="header"] { - [data-slot="logo"] { - } - } -} -``` - -top level pages are scoped using `data-page` - -pages can break down into components using `data-component` - -components can break down into slots using `data-slot` - -structure things so that this hierarchy is followed IN YOUR CSS - you should rarely need to -nest components inside other components. you should NEVER nest components inside -slots. you should NEVER nest slots inside other slots. - -**IMPORTANT: This hierarchy rule applies to CSS structure, NOT JSX/DOM structure.** - -The hierarchy in css file does NOT have to match the hierarchy in the dom - you -can put components or slots at the same level in CSS even if one goes inside another in the DOM. - -Your JSX can nest however makes semantic sense - components can be inside slots, -slots can contain components, etc. The DOM structure should be whatever makes the most -semantic and functional sense. - -It is more important to follow the pages -> components -> slots structure IN YOUR CSS, -while keeping your JSX/DOM structure logical and semantic. - -use data attributes to represent different states of the component - -```css -[data-component="modal"] { - opacity: 0; - - &[data-state="open"] { - opacity: 1; - } -} -``` - -this will allow jsx to control the syling - -avoid selectors that just target an element type like `> span` you should assign -it a slot name. it's ok to do this sometimes where it makes sense semantically -like targeting `li` elements in a list - -in terms of file structure `./src/style/` contains all universal styling rules. -these should not contain anything specific to a page - -`./src/style/token` contains all the tokens used in the project - -`./src/style/component` is for reusable components like buttons or inputs - -page specific styles should go next to the page they are styling so -`./src/routes/about.tsx` should have its styles in `./src/routes/about.css` - -`about.css` should be scoped using `data-page="about"` - -## Example of correct implementation - -JSX can nest however makes sense semantically: - -```jsx -
-
Section Title
-
Content here
-
-``` - -CSS maintains clean hierarchy regardless of DOM nesting: - -```css -[data-page="home"] { - [data-component="screenshots"] { - [data-slot="left"] { - /* styles */ - } - [data-slot="content"] { - /* styles */ - } - } - - [data-component="title"] { - /* can be at same level even though nested in DOM */ - } -} -``` - -## Reusable Components - -If a component is reused across multiple sections of the same page, define it at the page level: - -```jsx - -
-
-

npm

-
-
-

bun

-
-
- -
-
-
Screenshot Title
-
-
-``` - -```css -[data-page="home"] { - /* Reusable title component defined at page level since it's used in multiple components */ - [data-component="title"] { - text-transform: uppercase; - font-weight: 400; - } - - [data-component="install"] { - /* install-specific styles */ - } - - [data-component="screenshots"] { - /* screenshots-specific styles */ - } -} -``` - -This is correct because the `title` component has consistent styling and behavior across the page. - -## Key Clarifications - -1. **JSX Nesting is Flexible**: Components can be nested inside slots, slots can contain components - whatever makes semantic sense -2. **CSS Hierarchy is Strict**: Follow pages → components → slots structure in CSS -3. **Reusable Components**: Define at the appropriate level where they're shared (page level if used across the page, component level if only used within that component) -4. **DOM vs CSS Structure**: These don't need to match - optimize each for its purpose - -See ./src/routes/index.css and ./src/routes/index.tsx for a complete example. diff --git a/packages/cloud/app/README.md b/packages/cloud/app/README.md deleted file mode 100644 index 9337430cf..000000000 --- a/packages/cloud/app/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# SolidStart - -Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com); - -## Creating a project - -```bash -# create a new project in the current directory -npm init solid@latest - -# create a new project in my-app -npm init solid@latest my-app -``` - -## Developing - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: - -```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -## Building - -Solid apps are built with _presets_, which optimise your project for deployment to different environments. - -By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add it to the `devDependencies` in `package.json` and specify in your `app.config.js`. - -## This project was created with the [Solid CLI](https://github.com/solidjs-community/solid-cli) diff --git a/packages/cloud/app/app.config.ts b/packages/cloud/app/app.config.ts deleted file mode 100644 index af013bc81..000000000 --- a/packages/cloud/app/app.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { defineConfig } from "@solidjs/start/config" - -export default defineConfig({ - middleware: "./src/middleware.ts", - vite: { - server: { - allowedHosts: true, - }, - build: { - rollupOptions: { - external: ["cloudflare:workers"], - }, - minify: false, - }, - }, - server: { - compatibilityDate: "2024-09-19", - preset: "cloudflare_module", - cloudflare: { - nodeCompat: true, - }, - }, -}) diff --git a/packages/cloud/app/package.json b/packages/cloud/app/package.json deleted file mode 100644 index 577f1dd8d..000000000 --- a/packages/cloud/app/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "@opencode/cloud-app", - "type": "module", - "scripts": { - "typecheck": "tsc --noEmit", - "dev": "vinxi dev --host 0.0.0.0", - "dev:remote": "VITE_AUTH_URL=https://auth.dev.opencode.ai bun sst shell --stage=dev bun dev", - "build": "vinxi build && ../../opencode/script/schema.ts ./.output/public/config.json", - "start": "vinxi start", - "version": "0.9.11" - }, - "dependencies": { - "@ibm/plex": "6.4.1", - "@openauthjs/openauth": "0.0.0-20250322224806", - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.15.0", - "@solidjs/start": "^1.1.0", - "solid-js": "catalog:", - "vinxi": "^0.5.7", - "@opencode/cloud-core": "workspace:*" - }, - "engines": { - "node": ">=22" - } -} diff --git a/packages/cloud/app/public/favicon.svg b/packages/cloud/app/public/favicon.svg deleted file mode 100644 index 3c81bbdb4..000000000 --- a/packages/cloud/app/public/favicon.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packages/cloud/app/public/robots.txt b/packages/cloud/app/public/robots.txt deleted file mode 100644 index f88eb1790..000000000 --- a/packages/cloud/app/public/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -User-agent: * -Allow: / - -# Disallow shared content pages -Disallow: /s/ \ No newline at end of file diff --git a/packages/cloud/app/public/social-share.png b/packages/cloud/app/public/social-share.png deleted file mode 100644 index 97f67994d..000000000 Binary files a/packages/cloud/app/public/social-share.png and /dev/null differ diff --git a/packages/cloud/app/public/theme.json b/packages/cloud/app/public/theme.json deleted file mode 100644 index b3e97f7ca..000000000 --- a/packages/cloud/app/public/theme.json +++ /dev/null @@ -1,182 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "$schema": { - "type": "string", - "description": "JSON schema reference for configuration validation" - }, - "defs": { - "type": "object", - "description": "Color definitions that can be referenced in the theme", - "patternProperties": { - "^[a-zA-Z][a-zA-Z0-9_]*$": { - "oneOf": [ - { - "type": "string", - "pattern": "^#[0-9a-fA-F]{6}$", - "description": "Hex color value" - }, - { - "type": "integer", - "minimum": 0, - "maximum": 255, - "description": "ANSI color code (0-255)" - }, - { - "type": "string", - "enum": ["none"], - "description": "No color (uses terminal default)" - } - ] - } - }, - "additionalProperties": false - }, - "theme": { - "type": "object", - "description": "Theme color definitions", - "properties": { - "primary": { "$ref": "#/definitions/colorValue" }, - "secondary": { "$ref": "#/definitions/colorValue" }, - "accent": { "$ref": "#/definitions/colorValue" }, - "error": { "$ref": "#/definitions/colorValue" }, - "warning": { "$ref": "#/definitions/colorValue" }, - "success": { "$ref": "#/definitions/colorValue" }, - "info": { "$ref": "#/definitions/colorValue" }, - "text": { "$ref": "#/definitions/colorValue" }, - "textMuted": { "$ref": "#/definitions/colorValue" }, - "background": { "$ref": "#/definitions/colorValue" }, - "backgroundPanel": { "$ref": "#/definitions/colorValue" }, - "backgroundElement": { "$ref": "#/definitions/colorValue" }, - "border": { "$ref": "#/definitions/colorValue" }, - "borderActive": { "$ref": "#/definitions/colorValue" }, - "borderSubtle": { "$ref": "#/definitions/colorValue" }, - "diffAdded": { "$ref": "#/definitions/colorValue" }, - "diffRemoved": { "$ref": "#/definitions/colorValue" }, - "diffContext": { "$ref": "#/definitions/colorValue" }, - "diffHunkHeader": { "$ref": "#/definitions/colorValue" }, - "diffHighlightAdded": { "$ref": "#/definitions/colorValue" }, - "diffHighlightRemoved": { "$ref": "#/definitions/colorValue" }, - "diffAddedBg": { "$ref": "#/definitions/colorValue" }, - "diffRemovedBg": { "$ref": "#/definitions/colorValue" }, - "diffContextBg": { "$ref": "#/definitions/colorValue" }, - "diffLineNumber": { "$ref": "#/definitions/colorValue" }, - "diffAddedLineNumberBg": { "$ref": "#/definitions/colorValue" }, - "diffRemovedLineNumberBg": { "$ref": "#/definitions/colorValue" }, - "markdownText": { "$ref": "#/definitions/colorValue" }, - "markdownHeading": { "$ref": "#/definitions/colorValue" }, - "markdownLink": { "$ref": "#/definitions/colorValue" }, - "markdownLinkText": { "$ref": "#/definitions/colorValue" }, - "markdownCode": { "$ref": "#/definitions/colorValue" }, - "markdownBlockQuote": { "$ref": "#/definitions/colorValue" }, - "markdownEmph": { "$ref": "#/definitions/colorValue" }, - "markdownStrong": { "$ref": "#/definitions/colorValue" }, - "markdownHorizontalRule": { "$ref": "#/definitions/colorValue" }, - "markdownListItem": { "$ref": "#/definitions/colorValue" }, - "markdownListEnumeration": { "$ref": "#/definitions/colorValue" }, - "markdownImage": { "$ref": "#/definitions/colorValue" }, - "markdownImageText": { "$ref": "#/definitions/colorValue" }, - "markdownCodeBlock": { "$ref": "#/definitions/colorValue" }, - "syntaxComment": { "$ref": "#/definitions/colorValue" }, - "syntaxKeyword": { "$ref": "#/definitions/colorValue" }, - "syntaxFunction": { "$ref": "#/definitions/colorValue" }, - "syntaxVariable": { "$ref": "#/definitions/colorValue" }, - "syntaxString": { "$ref": "#/definitions/colorValue" }, - "syntaxNumber": { "$ref": "#/definitions/colorValue" }, - "syntaxType": { "$ref": "#/definitions/colorValue" }, - "syntaxOperator": { "$ref": "#/definitions/colorValue" }, - "syntaxPunctuation": { "$ref": "#/definitions/colorValue" } - }, - "required": ["primary", "secondary", "accent", "text", "textMuted", "background"], - "additionalProperties": false - } - }, - "required": ["theme"], - "additionalProperties": false, - "definitions": { - "colorValue": { - "oneOf": [ - { - "type": "string", - "pattern": "^#[0-9a-fA-F]{6}$", - "description": "Hex color value (same for dark and light)" - }, - { - "type": "integer", - "minimum": 0, - "maximum": 255, - "description": "ANSI color code (0-255, same for dark and light)" - }, - { - "type": "string", - "enum": ["none"], - "description": "No color (uses terminal default)" - }, - { - "type": "string", - "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$", - "description": "Reference to another color in the theme or defs" - }, - { - "type": "object", - "properties": { - "dark": { - "oneOf": [ - { - "type": "string", - "pattern": "^#[0-9a-fA-F]{6}$", - "description": "Hex color value for dark mode" - }, - { - "type": "integer", - "minimum": 0, - "maximum": 255, - "description": "ANSI color code for dark mode" - }, - { - "type": "string", - "enum": ["none"], - "description": "No color (uses terminal default)" - }, - { - "type": "string", - "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$", - "description": "Reference to another color for dark mode" - } - ] - }, - "light": { - "oneOf": [ - { - "type": "string", - "pattern": "^#[0-9a-fA-F]{6}$", - "description": "Hex color value for light mode" - }, - { - "type": "integer", - "minimum": 0, - "maximum": 255, - "description": "ANSI color code for light mode" - }, - { - "type": "string", - "enum": ["none"], - "description": "No color (uses terminal default)" - }, - { - "type": "string", - "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$", - "description": "Reference to another color for light mode" - } - ] - } - }, - "required": ["dark", "light"], - "additionalProperties": false, - "description": "Separate colors for dark and light modes" - } - ] - } - } -} diff --git a/packages/cloud/app/src/app.css b/packages/cloud/app/src/app.css deleted file mode 100644 index c0261c422..000000000 --- a/packages/cloud/app/src/app.css +++ /dev/null @@ -1 +0,0 @@ -@import "./style/index.css"; diff --git a/packages/cloud/app/src/app.tsx b/packages/cloud/app/src/app.tsx deleted file mode 100644 index bc3961214..000000000 --- a/packages/cloud/app/src/app.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { MetaProvider, Title, Meta } from "@solidjs/meta" -import { Router } from "@solidjs/router" -import { FileRoutes } from "@solidjs/start/router" -import { ErrorBoundary, Suspense } from "solid-js" -import "@ibm/plex/css/ibm-plex.css" -import "./app.css" - -export default function App() { - return ( - ( - - opencode - - {props.children} - - )} - > - - - ) -} diff --git a/packages/cloud/app/src/asset/lander/check.svg b/packages/cloud/app/src/asset/lander/check.svg deleted file mode 100644 index 22de6f2a8..000000000 --- a/packages/cloud/app/src/asset/lander/check.svg +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/packages/cloud/app/src/asset/lander/copy.svg b/packages/cloud/app/src/asset/lander/copy.svg deleted file mode 100644 index f1baac30a..000000000 --- a/packages/cloud/app/src/asset/lander/copy.svg +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/packages/cloud/app/src/asset/lander/screenshot-github.png b/packages/cloud/app/src/asset/lander/screenshot-github.png deleted file mode 100644 index fda74e641..000000000 Binary files a/packages/cloud/app/src/asset/lander/screenshot-github.png and /dev/null differ diff --git a/packages/cloud/app/src/asset/lander/screenshot-splash.png b/packages/cloud/app/src/asset/lander/screenshot-splash.png deleted file mode 100644 index e900673ef..000000000 Binary files a/packages/cloud/app/src/asset/lander/screenshot-splash.png and /dev/null differ diff --git a/packages/cloud/app/src/asset/lander/screenshot-vscode.png b/packages/cloud/app/src/asset/lander/screenshot-vscode.png deleted file mode 100644 index b8966a6b8..000000000 Binary files a/packages/cloud/app/src/asset/lander/screenshot-vscode.png and /dev/null differ diff --git a/packages/cloud/app/src/asset/lander/screenshot.png b/packages/cloud/app/src/asset/lander/screenshot.png deleted file mode 100644 index feb617585..000000000 Binary files a/packages/cloud/app/src/asset/lander/screenshot.png and /dev/null differ diff --git a/packages/cloud/app/src/asset/logo-ornate-dark.svg b/packages/cloud/app/src/asset/logo-ornate-dark.svg deleted file mode 100644 index 2efda934d..000000000 --- a/packages/cloud/app/src/asset/logo-ornate-dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/packages/cloud/app/src/asset/logo-ornate-light.svg b/packages/cloud/app/src/asset/logo-ornate-light.svg deleted file mode 100644 index 789223bc4..000000000 --- a/packages/cloud/app/src/asset/logo-ornate-light.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/packages/cloud/app/src/asset/logo.svg b/packages/cloud/app/src/asset/logo.svg deleted file mode 100644 index cbfcccf51..000000000 --- a/packages/cloud/app/src/asset/logo.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/packages/cloud/app/src/component/icon.tsx b/packages/cloud/app/src/component/icon.tsx deleted file mode 100644 index a82572e62..000000000 --- a/packages/cloud/app/src/component/icon.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { JSX } from "solid-js" - -export function IconLogo(props: JSX.SvgSVGAttributes) { - return ( - - - - - - - - - - - - - ) -} - -export function IconCopy(props: JSX.SvgSVGAttributes) { - return ( - - - - - ) -} - -export function IconCheck(props: JSX.SvgSVGAttributes) { - return ( - - - - ) -} - -export function IconCreditCard(props: JSX.SvgSVGAttributes) { - return ( - - - - ) -} diff --git a/packages/cloud/app/src/component/workspace/billing-section.module.css b/packages/cloud/app/src/component/workspace/billing-section.module.css deleted file mode 100644 index 0bb5709cb..000000000 --- a/packages/cloud/app/src/component/workspace/billing-section.module.css +++ /dev/null @@ -1,114 +0,0 @@ -.root { - [data-slot="section-content"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - } - - [data-slot="reload-error"] { - display: flex; - align-items: center; - justify-content: space-between; - gap: var(--space-4); - padding: var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - - p { - color: var(--color-danger); - font-size: var(--font-size-sm); - line-height: 1.4; - margin: 0; - flex: 1; - } - - [data-slot="create-form"] { - display: flex; - gap: var(--space-2); - margin: 0; - flex-shrink: 0; - } - } - [data-slot="payment"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - padding: var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - min-width: 14.5rem; - width: fit-content; - - @media (max-width: 30rem) { - width: 100%; - } - - [data-slot="credit-card"] { - padding: var(--space-3-5) var(--space-4); - background-color: var(--color-bg-surface); - border-radius: var(--border-radius-sm); - display: flex; - align-items: center; - justify-content: space-between; - - [data-slot="card-icon"] { - display: flex; - align-items: center; - color: var(--color-text-muted); - } - - [data-slot="card-details"] { - display: flex; - align-items: baseline; - gap: var(--space-1); - - [data-slot="secret"] { - position: relative; - bottom: 2px; - font-size: var(--font-size-lg); - color: var(--color-text-muted); - font-weight: 400; - } - - [data-slot="number"] { - font-size: var(--font-size-3xl); - font-weight: 500; - color: var(--color-text); - } - } - } - - [data-slot="button-row"] { - display: flex; - gap: var(--space-2); - align-items: center; - - @media (max-width: 30rem) { - flex-direction: column; - - > button { - width: 100%; - } - } - - [data-slot="create-form"] { - margin: 0; - } - - /* Make Enable Billing button full width when it's the only button */ - > button { - flex: 1; - } - } - } - [data-slot="usage"] { - p { - font-size: var(--font-size-sm); - line-height: 1.5; - color: var(--color-text-secondary); - b { - font-weight: 600; - } - } - } -} diff --git a/packages/cloud/app/src/component/workspace/billing-section.tsx b/packages/cloud/app/src/component/workspace/billing-section.tsx deleted file mode 100644 index ec314d9ef..000000000 --- a/packages/cloud/app/src/component/workspace/billing-section.tsx +++ /dev/null @@ -1,193 +0,0 @@ -import { json, query, action, useParams, useAction, createAsync, useSubmission } from "@solidjs/router" -import { createMemo, Show } from "solid-js" -import { Billing } from "@opencode/cloud-core/billing.js" -import { withActor } from "~/context/auth.withActor" -import { IconCreditCard } from "~/component/icon" -import styles from "./billing-section.module.css" - -const createCheckoutUrl = action(async (workspaceID: string, successUrl: string, cancelUrl: string) => { - "use server" - return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl }), workspaceID) -}, "checkoutUrl") - -const reload = action(async (form: FormData) => { - "use server" - const workspaceID = form.get("workspaceID")?.toString() - if (!workspaceID) return { error: "Workspace ID is required" } - return json(await withActor(() => Billing.reload(), workspaceID), { revalidate: getBillingInfo.key }) -}, "billing.reload") - -const disableReload = action(async (form: FormData) => { - "use server" - const workspaceID = form.get("workspaceID")?.toString() - if (!workspaceID) return { error: "Workspace ID is required" } - return json(await withActor(() => Billing.disableReload(), workspaceID), { revalidate: getBillingInfo.key }) -}, "billing.disableReload") - -const createSessionUrl = action(async (workspaceID: string, returnUrl: string) => { - "use server" - return withActor(() => Billing.generateSessionUrl({ returnUrl }), workspaceID) -}, "sessionUrl") - -const getBillingInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - return await Billing.get() - }, workspaceID) -}, "billing.get") - -export function BillingSection() { - const params = useParams() - // ORIGINAL CODE - COMMENTED OUT FOR TESTING - const balanceInfo = createAsync(() => getBillingInfo(params.id)) - const createCheckoutUrlAction = useAction(createCheckoutUrl) - const createCheckoutUrlSubmission = useSubmission(createCheckoutUrl) - const createSessionUrlAction = useAction(createSessionUrl) - const createSessionUrlSubmission = useSubmission(createSessionUrl) - const disableReloadSubmission = useSubmission(disableReload) - const reloadSubmission = useSubmission(reload) - - // DUMMY DATA FOR TESTING - UNCOMMENT ONE OF THE SCENARIOS BELOW - - // Scenario 1: User has not added billing details and has no balance - // const balanceInfo = () => ({ - // balance: 0, - // paymentMethodLast4: null as string | null, - // reload: false, - // reloadError: null as string | null, - // timeReloadError: null as Date | null, - // }) - - // Scenario 2: User has not added billing details but has a balance - // const balanceInfo = () => ({ - // balance: 1500000000, // $15.00 - // paymentMethodLast4: null as string | null, - // reload: false, - // reloadError: null as string | null, - // timeReloadError: null as Date | null - // }) - - // Scenario 3: User has added billing details (reload enabled) - // const balanceInfo = () => ({ - // balance: 750000000, // $7.50 - // paymentMethodLast4: "4242", - // reload: true, - // reloadError: null as string | null, - // timeReloadError: null as Date | null - // }) - - // Scenario 4: User has billing details but reload failed - // const balanceInfo = () => ({ - // balance: 250000000, // $2.50 - // paymentMethodLast4: "4242", - // reload: true, - // reloadError: "Your card was declined." as string, - // timeReloadError: new Date(Date.now() - 3600000) as Date // 1 hour ago - // }) - - const balanceAmount = createMemo(() => { - return ((balanceInfo()?.balance ?? 0) / 100000000).toFixed(2) - }) - - return ( -
-
-

Billing

-

- Manage payments methods. Contact us if you have any questions. -

-
-
- -
-

- Reload failed at{" "} - {balanceInfo()?.timeReloadError!.toLocaleString("en-US", { - month: "short", - day: "numeric", - hour: "numeric", - minute: "2-digit", - second: "2-digit", - })} - . Reason: {balanceInfo()?.reloadError?.replace(/\.$/, "")}. Please update your payment method and try - again. -

-
- - -
-
-
-
-
-
- -
-
- ----}> - •••• - {balanceInfo()?.paymentMethodLast4} - -
-
-
- { - const baseUrl = window.location.href - const checkoutUrl = await createCheckoutUrlAction(params.id, baseUrl, baseUrl) - if (checkoutUrl) { - window.location.href = checkoutUrl - } - }} - > - {createCheckoutUrlSubmission.pending ? "Loading..." : "Enable Billing"} - - } - > - -
- - -
-
-
-
-
- -

- You have ${balanceAmount() === "-0.00" ? "0.00" : balanceAmount()} remaining in - your account. You can continue using the API with your remaining balance. -

-
- -

- Your current balance is ${balanceAmount() === "-0.00" ? "0.00" : balanceAmount()} - . We'll automatically reload $20 (+$1.23 processing fee) when it reaches $5. -

-
-
-
-
- ) -} diff --git a/packages/cloud/app/src/component/workspace/common.tsx b/packages/cloud/app/src/component/workspace/common.tsx deleted file mode 100644 index f85fd8423..000000000 --- a/packages/cloud/app/src/component/workspace/common.tsx +++ /dev/null @@ -1,25 +0,0 @@ -export function formatDateForTable(date: Date) { - const options: Intl.DateTimeFormatOptions = { - day: "numeric", - month: "short", - hour: "numeric", - minute: "2-digit", - hour12: true, - } - return date.toLocaleDateString("en-GB", options).replace(",", ",") -} - -export function formatDateUTC(date: Date) { - const options: Intl.DateTimeFormatOptions = { - weekday: "short", - year: "numeric", - month: "short", - day: "numeric", - hour: "numeric", - minute: "2-digit", - second: "2-digit", - timeZoneName: "short", - timeZone: "UTC", - } - return date.toLocaleDateString("en-US", options) -} diff --git a/packages/cloud/app/src/component/workspace/key-section.module.css b/packages/cloud/app/src/component/workspace/key-section.module.css deleted file mode 100644 index 6a1d0c85f..000000000 --- a/packages/cloud/app/src/component/workspace/key-section.module.css +++ /dev/null @@ -1,172 +0,0 @@ -.root { - [data-component="empty-state"] { - padding: var(--space-20) var(--space-6); - text-align: center; - border: 1px dashed var(--color-border); - border-radius: var(--border-radius-sm); - display: flex; - flex-direction: column; - gap: var(--space-2); - - p { - line-height: 1.5; - font-size: var(--font-size-sm); - color: var(--color-text-muted); - } - } - - [data-slot="create-form"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - padding: var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - - [data-slot="input-container"] { - display: flex; - flex-direction: column; - gap: var(--space-1); - } - - @media (max-width: 30rem) { - gap: var(--space-2); - } - - input { - flex: 1; - padding: var(--space-2) var(--space-3); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - background-color: var(--color-bg); - color: var(--color-text); - font-size: var(--font-size-sm); - font-family: var(--font-mono); - - &:focus { - outline: none; - border-color: var(--color-accent); - } - - &::placeholder { - color: var(--color-text-disabled); - } - } - - [data-slot="form-actions"] { - display: flex; - gap: var(--space-2); - } - - [data-slot="form-error"] { - color: var(--color-danger); - font-size: var(--font-size-sm); - margin-top: var(--space-1); - line-height: 1.4; - } - } - - [data-slot="api-keys-table"] { - overflow-x: auto; - } - - [data-slot="api-keys-table-element"] { - width: 100%; - border-collapse: collapse; - font-size: var(--font-size-sm); - - thead { - border-bottom: 1px solid var(--color-border); - } - - th { - padding: var(--space-3) var(--space-4); - text-align: left; - font-weight: normal; - color: var(--color-text-muted); - text-transform: uppercase; - } - - td { - padding: var(--space-3) var(--space-4); - border-bottom: 1px solid var(--color-border-muted); - color: var(--color-text-muted); - font-family: var(--font-mono); - - &[data-slot="key-name"] { - color: var(--color-text); - font-family: var(--font-sans); - font-weight: 500; - } - - &[data-slot="key-value"] { - font-family: var(--font-mono); - - button { - display: flex; - align-items: center; - gap: var(--space-2); - padding: var(--space-2) var(--space-3); - font-size: var(--font-size-sm); - font-weight: 400; - border: none; - background-color: transparent; - color: var(--color-text-muted); - font-family: var(--font-mono); - border-radius: var(--border-radius-sm); - cursor: pointer; - transition: all 0.15s ease; - text-transform: none; - - &:hover:not(:disabled) { - background-color: var(--color-bg-surface); - color: var(--color-text); - } - - &:disabled { - cursor: default; - color: var(--color-text); - } - - span { - font-family: inherit; - } - } - } - - &[data-slot="key-date"] { - color: var(--color-text); - } - - &[data-slot="key-actions"] { - font-family: var(--font-sans); - } - } - - tbody tr { - &:last-child td { - border-bottom: none; - } - } - - @media (max-width: 40rem) { - th, - td { - padding: var(--space-2) var(--space-3); - font-size: var(--font-size-xs); - } - - th { - &:nth-child(3) /* Date */ { - display: none; - } - } - - td { - &:nth-child(3) /* Date */ { - display: none; - } - } - } - } -} diff --git a/packages/cloud/app/src/component/workspace/key-section.tsx b/packages/cloud/app/src/component/workspace/key-section.tsx deleted file mode 100644 index 4158ce793..000000000 --- a/packages/cloud/app/src/component/workspace/key-section.tsx +++ /dev/null @@ -1,182 +0,0 @@ -import { json, query, action, useParams, createAsync, useSubmission } from "@solidjs/router" -import { createEffect, createSignal, For, Show } from "solid-js" -import { IconCopy, IconCheck } from "~/component/icon" -import { Key } from "@opencode/cloud-core/key.js" -import { withActor } from "~/context/auth.withActor" -import { createStore } from "solid-js/store" -import { formatDateUTC, formatDateForTable } from "./common" -import styles from "./key-section.module.css" - -const removeKey = action(async (form: FormData) => { - "use server" - const id = form.get("id")?.toString() - if (!id) return { error: "ID is required" } - const workspaceID = form.get("workspaceID")?.toString() - if (!workspaceID) return { error: "Workspace ID is required" } - return json(await withActor(() => Key.remove({ id }), workspaceID), { revalidate: listKeys.key }) -}, "key.remove") - -const createKey = action(async (form: FormData) => { - "use server" - const name = form.get("name")?.toString().trim() - if (!name) return { error: "Name is required" } - const workspaceID = form.get("workspaceID")?.toString() - if (!workspaceID) return { error: "Workspace ID is required" } - return json( - await withActor( - () => - Key.create({ name }) - .then((data) => ({ error: undefined, data })) - .catch((e) => ({ error: e.message as string })), - workspaceID, - ), - { revalidate: listKeys.key }, - ) -}, "key.create") - -const listKeys = query(async (workspaceID: string) => { - "use server" - return withActor(() => Key.list(), workspaceID) -}, "key.list") - -export function KeyCreateForm() { - const params = useParams() - const submission = useSubmission(createKey) - const [store, setStore] = createStore({ show: false }) - - let input: HTMLInputElement - - createEffect(() => { - if (!submission.pending && submission.result && !submission.result.error) { - hide() - } - }) - - function show() { - // submission.clear() does not clear the result in some cases, ie. - // 1. Create key with empty name => error shows - // 2. Put in a key name and creates the key => form hides - // 3. Click add key button again => form shows with the same error if - // submission.clear() is called only once - while (true) { - submission.clear() - if (!submission.result) break - } - setStore("show", true) - input.focus() - } - - function hide() { - setStore("show", false) - } - - return ( - show()}> - Create API Key - - } - > -
-
- (input = r)} data-component="input" name="name" type="text" placeholder="Enter key name" /> - - {(err) =>
{err()}
} -
-
- -
- - -
-
-
- ) -} - -export function KeySection() { - const params = useParams() - const keys = createAsync(() => listKeys(params.id)) - - function formatKey(key: string) { - if (key.length <= 11) return key - return `${key.slice(0, 7)}...${key.slice(-4)}` - } - - return ( -
-
-

API Keys

-

Manage your API keys for accessing opencode services.

-
- -
- -

Create an opencode Gateway API key

-
- } - > - - - - - - - - - - - - {(key) => { - const [copied, setCopied] = createSignal(false) - // const submission = useSubmission(removeKey, ([fd]) => fd.get("id")?.toString() === key.id) - return ( - - - - - - - ) - }} - - -
NameKeyCreated
{key.name} - - - {formatDateForTable(key.timeCreated)} - -
- - - -
-
- - -
- ) -} diff --git a/packages/cloud/app/src/component/workspace/monthly-limit-section.module.css b/packages/cloud/app/src/component/workspace/monthly-limit-section.module.css deleted file mode 100644 index 02de058e4..000000000 --- a/packages/cloud/app/src/component/workspace/monthly-limit-section.module.css +++ /dev/null @@ -1,102 +0,0 @@ -.root { - [data-slot="section-content"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - } - - [data-slot="balance"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - padding: var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - min-width: 15rem; - width: fit-content; - - @media (max-width: 30rem) { - width: 100%; - } - - [data-slot="amount"] { - padding: var(--space-3-5) var(--space-4); - background-color: var(--color-bg-surface); - border-radius: var(--border-radius-sm); - display: flex; - align-items: baseline; - gap: var(--space-1); - justify-content: flex-end; - - [data-slot="currency"] { - position: relative; - bottom: 2px; - font-size: var(--font-size-lg); - color: var(--color-text-muted); - font-weight: 400; - } - - [data-slot="value"] { - font-size: var(--font-size-3xl); - font-weight: 500; - color: var(--color-text); - } - } - - [data-slot="create-form"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - margin-top: var(--space-1); - - [data-slot="input-container"] { - display: flex; - flex-direction: column; - gap: var(--space-1); - } - - @media (max-width: 30rem) { - gap: var(--space-2); - } - - input { - flex: 1; - padding: var(--space-2) var(--space-3); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - background-color: var(--color-bg); - color: var(--color-text); - font-size: var(--font-size-sm); - font-family: var(--font-mono); - - &:focus { - outline: none; - border-color: var(--color-accent); - } - - &::placeholder { - color: var(--color-text-disabled); - } - } - - [data-slot="form-actions"] { - display: flex; - gap: var(--space-2); - justify-content: flex-end; - } - - [data-slot="form-error"] { - color: var(--color-danger); - font-size: var(--font-size-sm); - line-height: 1.4; - } - } - } - - [data-slot="usage-status"] { - font-size: var(--font-size-sm); - color: var(--color-text-secondary); - margin: 0; - line-height: 1.4; - } -} diff --git a/packages/cloud/app/src/component/workspace/monthly-limit-section.tsx b/packages/cloud/app/src/component/workspace/monthly-limit-section.tsx deleted file mode 100644 index 5c1077ab1..000000000 --- a/packages/cloud/app/src/component/workspace/monthly-limit-section.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import { json, query, action, useParams, createAsync, useSubmission } from "@solidjs/router" -import { createEffect, Show } from "solid-js" -import { createStore } from "solid-js/store" -import { withActor } from "~/context/auth.withActor" -import { Billing } from "@opencode/cloud-core/billing.js" -import styles from "./monthly-limit-section.module.css" - -const getBillingInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - return await Billing.get() - }, workspaceID) -}, "billing.get") - -const setMonthlyLimit = action(async (form: FormData) => { - "use server" - const limit = form.get("limit")?.toString() - if (!limit) return { error: "Limit is required." } - const numericLimit = parseInt(limit) - if (numericLimit < 0) return { error: "Set a valid monthly limit." } - const workspaceID = form.get("workspaceID")?.toString() - if (!workspaceID) return { error: "Workspace ID is required." } - return json( - await withActor( - () => - Billing.setMonthlyLimit(numericLimit) - .then((data) => ({ error: undefined, data })) - .catch((e) => ({ error: e.message as string })), - workspaceID, - ), - { revalidate: getBillingInfo.key }, - ) -}, "billing.setMonthlyLimit") - -export function MonthlyLimitSection() { - const params = useParams() - const submission = useSubmission(setMonthlyLimit) - const [store, setStore] = createStore({ show: false }) - const balanceInfo = createAsync(() => getBillingInfo(params.id)) - - let input: HTMLInputElement - - createEffect(() => { - if (!submission.pending && submission.result && !submission.result.error) { - hide() - } - }) - - function show() { - // submission.clear() does not clear the result in some cases, ie. - // 1. Create key with empty name => error shows - // 2. Put in a key name and creates the key => form hides - // 3. Click add key button again => form shows with the same error if - // submission.clear() is called only once - while (true) { - submission.clear() - if (!submission.result) break - } - setStore("show", true) - input.focus() - } - - function hide() { - setStore("show", false) - } - - return ( -
-
-

Monthly Limit

-

Set a monthly spending limit for your account.

-
-
-
-
- {balanceInfo()?.monthlyLimit ? $ : null} - {balanceInfo()?.monthlyLimit ?? "-"} -
- -
- (input = r)} - data-component="input" - name="limit" - type="number" - placeholder="50" - /> - - {(err) =>
{err()}
} -
-
- -
- - -
- - } - > - -
-
- No spending limit set.

}> -

- Current usage for {new Date().toLocaleDateString("en-US", { month: "long", timeZone: "UTC" })} is $ - {(() => { - const dateLastUsed = balanceInfo()?.timeMonthlyUsageUpdated - if (!dateLastUsed) return "0" - - const current = new Date().toLocaleDateString("en-US", { - year: "numeric", - month: "long", - timeZone: "UTC", - }) - const lastUsed = dateLastUsed.toLocaleDateString("en-US", { - year: "numeric", - month: "long", - timeZone: "UTC", - }) - if (current !== lastUsed) return "0" - return ((balanceInfo()?.monthlyUsage ?? 0) / 100000000).toFixed(2) - })()} - . -

-
-
-
- ) -} diff --git a/packages/cloud/app/src/component/workspace/new-user-section.module.css b/packages/cloud/app/src/component/workspace/new-user-section.module.css deleted file mode 100644 index 2edc7cc14..000000000 --- a/packages/cloud/app/src/component/workspace/new-user-section.module.css +++ /dev/null @@ -1,163 +0,0 @@ -.root { - display: flex; - flex-direction: column; - gap: var(--space-8); - padding: var(--space-6); - background-color: var(--color-bg-surface); - border: 1px dashed var(--color-border); - border-radius: var(--border-radius-sm); - - @media (max-width: 30rem) { - gap: var(--space-8); - padding: var(--space-4); - } - - [data-component="feature-grid"] { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); - gap: var(--space-6); - - @media (max-width: 30rem) { - grid-template-columns: 1fr; - gap: var(--space-4); - } - - [data-slot="feature"] { - display: flex; - flex-direction: column; - gap: var(--space-2); - padding: var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - - h3 { - font-size: var(--font-size-sm); - font-weight: 600; - margin: 0; - color: var(--color-text); - text-transform: uppercase; - letter-spacing: -0.025rem; - } - - p { - font-size: var(--font-size-sm); - line-height: 1.5; - margin: 0; - color: var(--color-text-muted); - } - } - } - - [data-component="api-key-highlight"] { - display: flex; - flex-direction: column; - gap: var(--space-6); - - [data-slot="section-title"] { - display: flex; - flex-direction: column; - gap: var(--space-1); - - h2 { - font-size: var(--font-size-md); - font-weight: 600; - line-height: 1.2; - letter-spacing: -0.03125rem; - margin: 0; - color: var(--color-text-secondary); - text-transform: uppercase; - - @media (max-width: 30rem) { - font-size: var(--font-size-md); - } - } - } - - [data-slot="key-display"] { - display: flex; - flex-direction: column; - gap: var(--space-3); - - [data-slot="key-container"] { - display: flex; - gap: var(--space-3); - padding: var(--space-4); - border: 2px solid var(--color-accent); - border-radius: var(--border-radius-sm); - align-items: center; - - @media (max-width: 40rem) { - flex-direction: column; - gap: var(--space-3); - align-items: stretch; - } - - [data-slot="key-value"] { - flex: 1; - font-family: var(--font-mono); - font-size: var(--font-size-sm); - color: var(--color-text); - background-color: var(--color-bg); - padding: var(--space-3); - border-radius: var(--border-radius-sm); - border: 1px solid var(--color-border); - word-break: break-all; - line-height: 1.4; - - @media (max-width: 40rem) { - font-size: var(--font-size-xs); - padding: var(--space-2-5); - } - } - - button { - display: flex; - align-items: center; - gap: var(--space-2); - padding: var(--space-3) var(--space-4); - font-size: var(--font-size-sm); - font-weight: 500; - white-space: nowrap; - min-width: 130px; - - @media (max-width: 40rem) { - justify-content: center; - padding: var(--space-2-5) var(--space-3); - font-size: var(--font-size-xs); - min-width: 96px; - } - } - } - } - } - - [data-component="next-steps"] { - display: flex; - flex-direction: column; - gap: var(--space-6); - - ol { - margin: 0; - padding-left: 0; - display: flex; - flex-direction: column; - gap: var(--space-2); - list-style-position: inside; - - li { - font-size: var(--font-size-md); - line-height: 1.5; - color: var(--color-text-secondary); - - code { - font-family: var(--font-mono); - font-size: var(--font-size-sm); - padding: var(--space-1) var(--space-2); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - color: var(--color-text); - } - } - } - } -} diff --git a/packages/cloud/app/src/component/workspace/new-user-section.tsx b/packages/cloud/app/src/component/workspace/new-user-section.tsx deleted file mode 100644 index 6e031e371..000000000 --- a/packages/cloud/app/src/component/workspace/new-user-section.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import { query, useParams, createAsync } from "@solidjs/router" -import { createMemo, createSignal, Show } from "solid-js" -import { IconCopy, IconCheck } from "~/component/icon" -import { Key } from "@opencode/cloud-core/key.js" -import { Billing } from "@opencode/cloud-core/billing.js" -import { withActor } from "~/context/auth.withActor" -import styles from "./new-user-section.module.css" - -const getUsageInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - return await Billing.usages() - }, workspaceID) -}, "usage.list") - -const listKeys = query(async (workspaceID: string) => { - "use server" - return withActor(() => Key.list(), workspaceID) -}, "key.list") - -export function NewUserSection() { - const params = useParams() - const [copiedKey, setCopiedKey] = createSignal(false) - const keys = createAsync(() => listKeys(params.id)) - const usage = createAsync(() => getUsageInfo(params.id)) - const isNew = createMemo(() => { - const keysList = keys() - const usageList = usage() - return keysList?.length === 1 && (!usageList || usageList.length === 0) - }) - const defaultKey = createMemo(() => keys()?.at(-1)?.key) - - return ( - -
-
-
-

Tested & Verified Models

-

We've benchmarked and tested models specifically for coding agents to ensure the best performance.

-
-
-

Highest Quality

-

Access models configured for optimal performance - no downgrades or routing to cheaper providers.

-
-
-

No Lock-in

-

Use Zen with any coding agent, and continue using other providers with opencode whenever you want.

-
-
- -
- -
-
- {defaultKey()} - -
-
-
-
- -
-
    -
  1. Enable billing
  2. -
  3. - Run opencode auth login and select opencode -
  4. -
  5. Paste your API key
  6. -
  7. - Start opencode and run /models to select a model -
  8. -
-
-
-
- ) -} diff --git a/packages/cloud/app/src/component/workspace/payment-section.module.css b/packages/cloud/app/src/component/workspace/payment-section.module.css deleted file mode 100644 index ea8e2ed42..000000000 --- a/packages/cloud/app/src/component/workspace/payment-section.module.css +++ /dev/null @@ -1,72 +0,0 @@ -.root { - [data-slot="payments-table"] { - overflow-x: auto; - } - - [data-slot="payments-table-element"] { - width: 100%; - border-collapse: collapse; - font-size: var(--font-size-sm); - - thead { - border-bottom: 1px solid var(--color-border); - } - - th { - padding: var(--space-3) var(--space-4); - text-align: left; - font-weight: normal; - color: var(--color-text-muted); - text-transform: uppercase; - } - - td { - padding: var(--space-3) var(--space-4); - border-bottom: 1px solid var(--color-border-muted); - color: var(--color-text-muted); - font-family: var(--font-mono); - - &[data-slot="payment-date"] { - color: var(--color-text); - } - - &[data-slot="payment-id"] { - font-family: var(--font-mono); - font-weight: 400; - color: var(--color-text-muted); - max-width: 200px; - word-break: break-word; - } - - &[data-slot="payment-amount"] { - color: var(--color-text); - } - } - - tbody tr { - &:last-child td { - border-bottom: none; - } - } - - @media (max-width: 40rem) { - th, - td { - padding: var(--space-2) var(--space-3); - font-size: var(--font-size-xs); - } - - th { - &:nth-child(2) /* Payment ID */ { - display: none; - } - } - - td { - &:nth-child(2) /* Payment ID */ { - display: none; - } - } - } - } -} diff --git a/packages/cloud/app/src/component/workspace/payment-section.tsx b/packages/cloud/app/src/component/workspace/payment-section.tsx deleted file mode 100644 index 8cdceebc3..000000000 --- a/packages/cloud/app/src/component/workspace/payment-section.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import { Billing } from "@opencode/cloud-core/billing.js" -import { query, action, useParams, createAsync, useAction } from "@solidjs/router" -import { For } from "solid-js" -import { withActor } from "~/context/auth.withActor" -import { formatDateUTC, formatDateForTable } from "./common" -import styles from "./payment-section.module.css" - -const getPaymentsInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - return await Billing.payments() - }, workspaceID) -}, "payment.list") - -const downloadReceipt = action(async (workspaceID: string, paymentID: string) => { - "use server" - return withActor(() => Billing.generateReceiptUrl({ paymentID }), workspaceID) -}, "receipt.download") - -export function PaymentSection() { - const params = useParams() - // ORIGINAL CODE - COMMENTED OUT FOR TESTING - const payments = createAsync(() => getPaymentsInfo(params.id)) - const downloadReceiptAction = useAction(downloadReceipt) - - // DUMMY DATA FOR TESTING - // const payments = () => [ - // { - // id: "pi_3QK1x2FT9vXn4A6r1234567890", - // paymentID: "pi_3QK1x2FT9vXn4A6r1234567890", - // timeCreated: new Date(Date.now() - 86400000 * 1).toISOString(), // 1 day ago - // amount: 2100000000, // $21.00 ($20 + $1 fee) - // }, - // { - // id: "pi_3QJ8k7FT9vXn4A6r0987654321", - // paymentID: "pi_3QJ8k7FT9vXn4A6r0987654321", - // timeCreated: new Date(Date.now() - 86400000 * 15).toISOString(), // 15 days ago - // amount: 2100000000, // $21.00 - // }, - // { - // id: "pi_3QI5m1FT9vXn4A6r5678901234", - // paymentID: "pi_3QI5m1FT9vXn4A6r5678901234", - // timeCreated: new Date(Date.now() - 86400000 * 32).toISOString(), // 32 days ago - // amount: 2100000000, // $21.00 - // }, - // { - // id: "pi_3QH2n9FT9vXn4A6r3456789012", - // paymentID: "pi_3QH2n9FT9vXn4A6r3456789012", - // timeCreated: new Date(Date.now() - 86400000 * 47).toISOString(), // 47 days ago - // amount: 2100000000, // $21.00 - // }, - // { - // id: "pi_3QG7p4FT9vXn4A6r7890123456", - // paymentID: "pi_3QG7p4FT9vXn4A6r7890123456", - // timeCreated: new Date(Date.now() - 86400000 * 63).toISOString(), // 63 days ago - // amount: 2100000000, // $21.00 - // }, - // ] - - return ( - payments() && - payments()!.length > 0 && ( -
-
-

Payments History

-

Recent payment transactions.

-
-
- - - - - - - - - - - - {(payment) => { - const date = new Date(payment.timeCreated) - return ( - - - - - - - ) - }} - - -
DatePayment IDAmountReceipt
- {formatDateForTable(date)} - {payment.id}${((payment.amount ?? 0) / 100000000).toFixed(2)} - -
-
-
- ) - ) -} diff --git a/packages/cloud/app/src/component/workspace/usage-section.module.css b/packages/cloud/app/src/component/workspace/usage-section.module.css deleted file mode 100644 index 1a772ba87..000000000 --- a/packages/cloud/app/src/component/workspace/usage-section.module.css +++ /dev/null @@ -1,88 +0,0 @@ -.root { - [data-component="empty-state"] { - padding: var(--space-20) var(--space-6); - text-align: center; - border: 1px dashed var(--color-border); - border-radius: var(--border-radius-sm); - display: flex; - flex-direction: column; - gap: var(--space-2); - - p { - line-height: 1.5; - font-size: var(--font-size-sm); - color: var(--color-text-muted); - } - } - - [data-slot="usage-table"] { - overflow-x: auto; - } - - [data-slot="usage-table-element"] { - width: 100%; - border-collapse: collapse; - font-size: var(--font-size-sm); - - thead { - border-bottom: 1px solid var(--color-border); - } - - th { - padding: var(--space-3) var(--space-4); - text-align: left; - font-weight: normal; - color: var(--color-text-muted); - text-transform: uppercase; - } - - td { - padding: var(--space-3) var(--space-4); - border-bottom: 1px solid var(--color-border-muted); - color: var(--color-text-muted); - font-family: var(--font-mono); - - &[data-slot="usage-date"] { - color: var(--color-text); - } - - &[data-slot="usage-model"] { - font-family: var(--font-sans); - font-weight: 400; - color: var(--color-text-secondary); - max-width: 200px; - word-break: break-word; - } - - &[data-slot="usage-cost"] { - color: var(--color-text); - } - } - - tbody tr { - &:last-child td { - border-bottom: none; - } - } - - @media (max-width: 40rem) { - th, - td { - padding: var(--space-2) var(--space-3); - font-size: var(--font-size-xs); - } - - th { - &:nth-child(2) /* Model */ { - display: none; - } - } - - td { - &:nth-child(2) /* Model */ { - display: none; - } - } - } - } -} diff --git a/packages/cloud/app/src/component/workspace/usage-section.tsx b/packages/cloud/app/src/component/workspace/usage-section.tsx deleted file mode 100644 index 5d3d3b6c3..000000000 --- a/packages/cloud/app/src/component/workspace/usage-section.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { Billing } from "@opencode/cloud-core/billing.js" -import { query, useParams, createAsync } from "@solidjs/router" -import { createMemo, For, Show } from "solid-js" -import { formatDateUTC, formatDateForTable } from "./common" -import { withActor } from "~/context/auth.withActor" -import styles from "./usage-section.module.css" - -const getUsageInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - return await Billing.usages() - }, workspaceID) -}, "usage.list") - -export function UsageSection() { - const params = useParams() - // ORIGINAL CODE - COMMENTED OUT FOR TESTING - const usage = createAsync(() => getUsageInfo(params.id)) - - // DUMMY DATA FOR TESTING - // const usage = () => [ - // { - // timeCreated: new Date(Date.now() - 86400000 * 0).toISOString(), // Today - // model: "claude-3-5-sonnet-20241022", - // inputTokens: 1247, - // outputTokens: 423, - // cost: 125400000, // $1.254 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 0.5).toISOString(), // 12 hours ago - // model: "claude-3-haiku-20240307", - // inputTokens: 892, - // outputTokens: 156, - // cost: 23500000, // $0.235 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 1).toISOString(), // Yesterday - // model: "claude-3-5-sonnet-20241022", - // inputTokens: 2134, - // outputTokens: 687, - // cost: 234700000, // $2.347 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 1.3).toISOString(), // 1.3 days ago - // model: "gpt-4o-mini", - // inputTokens: 567, - // outputTokens: 234, - // cost: 8900000, // $0.089 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 2).toISOString(), // 2 days ago - // model: "claude-3-opus-20240229", - // inputTokens: 1893, - // outputTokens: 945, - // cost: 445600000, // $4.456 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 2.7).toISOString(), // 2.7 days ago - // model: "gpt-4o", - // inputTokens: 1456, - // outputTokens: 532, - // cost: 156800000, // $1.568 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 3).toISOString(), // 3 days ago - // model: "claude-3-haiku-20240307", - // inputTokens: 634, - // outputTokens: 89, - // cost: 12300000, // $0.123 - // }, - // { - // timeCreated: new Date(Date.now() - 86400000 * 4).toISOString(), // 4 days ago - // model: "claude-3-5-sonnet-20241022", - // inputTokens: 3245, - // outputTokens: 1123, - // cost: 387200000, // $3.872 - // }, - // ] - - return ( -
-
-

Usage History

-

Recent API usage and costs.

-
-
- 0} - fallback={ -
-

Make your first API call to get started.

-
- } - > - - - - - - - - - - - - - {(usage) => { - const date = createMemo(() => new Date(usage.timeCreated)) - return ( - - - - - - - - ) - }} - - -
DateModelInputOutputCost
- {formatDateForTable(date())} - {usage.model}{usage.inputTokens}{usage.outputTokens}${((usage.cost ?? 0) / 100000000).toFixed(4)}
-
-
-
- ) -} diff --git a/packages/cloud/app/src/context/auth.session.ts b/packages/cloud/app/src/context/auth.session.ts deleted file mode 100644 index 609bc364b..000000000 --- a/packages/cloud/app/src/context/auth.session.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { useSession } from "vinxi/http" - -export interface AuthSession { - account?: Record< - string, - { - id: string - email: string - } - > - current?: string -} - -export function useAuthSession() { - return useSession({ - password: "0".repeat(32), - name: "auth", - cookie: { - secure: false, - httpOnly: true, - }, - }) -} diff --git a/packages/cloud/app/src/context/auth.ts b/packages/cloud/app/src/context/auth.ts deleted file mode 100644 index e08d965b8..000000000 --- a/packages/cloud/app/src/context/auth.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { getRequestEvent } from "solid-js/web" -import { and, Database, eq, inArray } from "@opencode/cloud-core/drizzle/index.js" -import { WorkspaceTable } from "@opencode/cloud-core/schema/workspace.sql.js" -import { UserTable } from "@opencode/cloud-core/schema/user.sql.js" -import { redirect } from "@solidjs/router" -import { AccountTable } from "@opencode/cloud-core/schema/account.sql.js" -import { Actor } from "@opencode/cloud-core/actor.js" - -import { createClient } from "@openauthjs/openauth/client" -import { useAuthSession } from "./auth.session" - -export const AuthClient = createClient({ - clientID: "app", - issuer: import.meta.env.VITE_AUTH_URL, -}) - -export const getActor = async (workspace?: string): Promise => { - "use server" - const evt = getRequestEvent() - if (!evt) throw new Error("No request event") - if (evt.locals.actor) return evt.locals.actor - evt.locals.actor = (async () => { - const auth = await useAuthSession() - if (!workspace) { - const account = auth.data.account ?? {} - const current = account[auth.data.current ?? ""] - if (current) { - return { - type: "account", - properties: { - email: current.email, - accountID: current.id, - }, - } - } - if (Object.keys(account).length > 0) { - const current = Object.values(account)[0] - await auth.update((val) => ({ - ...val, - current: current.id, - })) - return { - type: "account", - properties: { - email: current.email, - accountID: current.id, - }, - } - } - return { - type: "public", - properties: {}, - } - } - const accounts = Object.keys(auth.data.account ?? {}) - if (accounts.length) { - const result = await Database.transaction(async (tx) => { - return await tx - .select({ - user: UserTable, - }) - .from(AccountTable) - .innerJoin(UserTable, and(eq(UserTable.email, AccountTable.email))) - .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID)) - .where(and(inArray(AccountTable.id, accounts), eq(WorkspaceTable.id, workspace))) - .limit(1) - .execute() - .then((x) => x[0]) - }) - if (result) { - return { - type: "user", - properties: { - userID: result.user.id, - workspaceID: result.user.workspaceID, - }, - } - } - } - throw redirect("/auth/authorize") - })() - return evt.locals.actor -} diff --git a/packages/cloud/app/src/context/auth.withActor.ts b/packages/cloud/app/src/context/auth.withActor.ts deleted file mode 100644 index 4cfd5c3e0..000000000 --- a/packages/cloud/app/src/context/auth.withActor.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Actor } from "@opencode/cloud-core/actor.js" -import { getActor } from "./auth" - -export async function withActor(fn: () => T, workspace?: string) { - const actor = await getActor(workspace) - return Actor.provide(actor.type, actor.properties, fn) -} diff --git a/packages/cloud/app/src/entry-client.tsx b/packages/cloud/app/src/entry-client.tsx deleted file mode 100644 index 642deacf7..000000000 --- a/packages/cloud/app/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/packages/cloud/app/src/entry-server.tsx b/packages/cloud/app/src/entry-server.tsx deleted file mode 100644 index d5fca6aa5..000000000 --- a/packages/cloud/app/src/entry-server.tsx +++ /dev/null @@ -1,28 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server" - -export default createHandler( - () => ( - ( - - - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> - ), - { - mode: "async", - }, -) diff --git a/packages/cloud/app/src/global.d.ts b/packages/cloud/app/src/global.d.ts deleted file mode 100644 index dc6f10c22..000000000 --- a/packages/cloud/app/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages/cloud/app/src/middleware.ts b/packages/cloud/app/src/middleware.ts deleted file mode 100644 index b49473cbe..000000000 --- a/packages/cloud/app/src/middleware.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { defineMiddleware } from "vinxi/http" - -export default defineMiddleware({ - onBeforeResponse() {}, -}) diff --git a/packages/cloud/app/src/routes/[...404].css b/packages/cloud/app/src/routes/[...404].css deleted file mode 100644 index 1edbd0a5a..000000000 --- a/packages/cloud/app/src/routes/[...404].css +++ /dev/null @@ -1,130 +0,0 @@ -[data-page="not-found"] { - --color-text: hsl(224, 10%, 10%); - --color-text-secondary: hsl(224, 7%, 46%); - --color-text-dimmed: hsl(224, 6%, 63%); - --color-text-inverted: hsl(0, 0%, 100%); - - --color-border: hsl(224, 6%, 77%); -} - -[data-page="not-found"] { - @media (prefers-color-scheme: dark) { - --color-text: hsl(0, 0%, 100%); - --color-text-secondary: hsl(224, 6%, 66%); - --color-text-dimmed: hsl(224, 7%, 46%); - --color-text-inverted: hsl(224, 10%, 10%); - - --color-border: hsl(224, 6%, 36%); - } -} - -[data-page="not-found"] { - --padding: 3rem; - --vertical-padding: 1.5rem; - --heading-font-size: 1.375rem; - - @media (max-width: 30rem) { - --padding: 1rem; - --vertical-padding: 0.75rem; - --heading-font-size: 1rem; - } - - font-family: var(--font-mono); - color: var(--color-text); - padding: calc(var(--padding) + 1rem); - min-height: 100vh; - display: flex; - align-items: center; - justify-content: center; - - a { - color: var(--color-text); - text-decoration: underline; - text-underline-offset: var(--space-0-75); - text-decoration-thickness: 1px; - } - - [data-component="content"] { - max-width: 40rem; - width: 100%; - border: 1px solid var(--color-border); - } - - [data-component="top"] { - padding: var(--padding); - display: flex; - flex-direction: column; - align-items: center; - gap: calc(var(--vertical-padding) / 2); - text-align: center; - - [data-slot="logo-link"] { - text-decoration: none; - } - - img { - height: auto; - width: clamp(200px, 85vw, 400px); - } - - [data-slot="logo dark"] { - display: none; - } - - @media (prefers-color-scheme: dark) { - [data-slot="logo light"] { - display: none; - } - [data-slot="logo dark"] { - display: block; - } - } - - [data-slot="title"] { - line-height: 1.25; - font-weight: 500; - text-align: center; - font-size: var(--heading-font-size); - color: var(--color-text); - text-transform: uppercase; - margin: 0; - } - } - - [data-component="actions"] { - border-top: 1px solid var(--color-border); - display: flex; - - [data-slot="action"] { - flex: 1; - text-align: center; - line-height: 1.4; - padding: var(--vertical-padding) 1rem; - text-transform: uppercase; - font-size: 1rem; - - a { - display: block; - width: 100%; - height: 100%; - color: var(--color-text); - text-decoration: underline; - text-underline-offset: var(--space-0-75); - text-decoration-thickness: 1px; - } - } - - [data-slot="action"] + [data-slot="action"] { - border-left: 1px solid var(--color-border); - } - - @media (max-width: 40rem) { - flex-direction: column; - - [data-slot="action"] + [data-slot="action"] { - border-left: none; - border-top: 1px solid var(--color-border); - } - } - } -} diff --git a/packages/cloud/app/src/routes/[...404].tsx b/packages/cloud/app/src/routes/[...404].tsx deleted file mode 100644 index ba2842b5a..000000000 --- a/packages/cloud/app/src/routes/[...404].tsx +++ /dev/null @@ -1,38 +0,0 @@ -import "./[...404].css" -import { Title } from "@solidjs/meta" -import { HttpStatusCode } from "@solidjs/start" -import logoLight from "../asset/logo-ornate-light.svg" -import logoDark from "../asset/logo-ornate-dark.svg" - -export default function NotFound() { - return ( -
- Not Found | opencode - -
-
- - opencode logo light - opencode logo dark - -

404 - Page Not Found

-
- -
-
- Home -
-
- Docs -
-
- GitHub -
-
- Discord -
-
-
-
- ) -} diff --git a/packages/cloud/app/src/routes/auth/authorize.ts b/packages/cloud/app/src/routes/auth/authorize.ts deleted file mode 100644 index 166466ef8..000000000 --- a/packages/cloud/app/src/routes/auth/authorize.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" -import { AuthClient } from "~/context/auth" - -export async function GET(input: APIEvent) { - const result = await AuthClient.authorize(new URL("./callback", input.request.url).toString(), "code") - return Response.redirect(result.url, 302) -} diff --git a/packages/cloud/app/src/routes/auth/callback.ts b/packages/cloud/app/src/routes/auth/callback.ts deleted file mode 100644 index 23025b54d..000000000 --- a/packages/cloud/app/src/routes/auth/callback.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { redirect } from "@solidjs/router" -import type { APIEvent } from "@solidjs/start/server" -import { AuthClient } from "~/context/auth" -import { useAuthSession } from "~/context/auth.session" - -export async function GET(input: APIEvent) { - const url = new URL(input.request.url) - const code = url.searchParams.get("code") - if (!code) throw new Error("No code found") - const result = await AuthClient.exchange(code, `${url.origin}${url.pathname}`) - if (result.err) { - throw new Error(result.err.message) - } - const decoded = AuthClient.decode(result.tokens.access, {} as any) - if (decoded.err) throw new Error(decoded.err.message) - const session = await useAuthSession() - const id = decoded.subject.properties.accountID - await session.update((value) => { - return { - ...value, - account: { - [id]: { - id, - email: decoded.subject.properties.email, - }, - }, - current: id, - } - }) - return redirect("/auth") -} diff --git a/packages/cloud/app/src/routes/auth/index.ts b/packages/cloud/app/src/routes/auth/index.ts deleted file mode 100644 index 308ae2d1d..000000000 --- a/packages/cloud/app/src/routes/auth/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Account } from "@opencode/cloud-core/account.js" -import { redirect } from "@solidjs/router" -import type { APIEvent } from "@solidjs/start/server" -import { withActor } from "~/context/auth.withActor" - -export async function GET(input: APIEvent) { - try { - const workspaces = await withActor(async () => Account.workspaces()) - return redirect(`/workspace/${workspaces[0].id}`) - } catch { - return redirect("/auth/authorize") - } -} diff --git a/packages/cloud/app/src/routes/debug/index.ts b/packages/cloud/app/src/routes/debug/index.ts deleted file mode 100644 index 8c7eb7bd8..000000000 --- a/packages/cloud/app/src/routes/debug/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" -import { json } from "@solidjs/router" -import { Database } from "@opencode/cloud-core/drizzle/index.js" -import { UserTable } from "@opencode/cloud-core/schema/user.sql.js" - -export async function GET(evt: APIEvent) { - return json({ - data: await Database.use(async (tx) => { - const result = await tx.$count(UserTable) - return result - }), - }) -} diff --git a/packages/cloud/app/src/routes/discord.ts b/packages/cloud/app/src/routes/discord.ts deleted file mode 100644 index 7088295da..000000000 --- a/packages/cloud/app/src/routes/discord.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { redirect } from "@solidjs/router" - -export async function GET() { - return redirect("https://discord.gg/opencode") -} diff --git a/packages/cloud/app/src/routes/docs/[...path].ts b/packages/cloud/app/src/routes/docs/[...path].ts deleted file mode 100644 index f07781583..000000000 --- a/packages/cloud/app/src/routes/docs/[...path].ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" - -async function handler(evt: APIEvent) { - const req = evt.request.clone() - const url = new URL(req.url) - const targetUrl = `https://docs.opencode.ai${url.pathname}${url.search}` - const response = await fetch(targetUrl, { - method: req.method, - headers: req.headers, - body: req.body, - }) - return response -} - -export const GET = handler -export const POST = handler -export const PUT = handler -export const DELETE = handler -export const OPTIONS = handler -export const PATCH = handler diff --git a/packages/cloud/app/src/routes/docs/index.ts b/packages/cloud/app/src/routes/docs/index.ts deleted file mode 100644 index f07781583..000000000 --- a/packages/cloud/app/src/routes/docs/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" - -async function handler(evt: APIEvent) { - const req = evt.request.clone() - const url = new URL(req.url) - const targetUrl = `https://docs.opencode.ai${url.pathname}${url.search}` - const response = await fetch(targetUrl, { - method: req.method, - headers: req.headers, - body: req.body, - }) - return response -} - -export const GET = handler -export const POST = handler -export const PUT = handler -export const DELETE = handler -export const OPTIONS = handler -export const PATCH = handler diff --git a/packages/cloud/app/src/routes/index.css b/packages/cloud/app/src/routes/index.css deleted file mode 100644 index fe95bb7ea..000000000 --- a/packages/cloud/app/src/routes/index.css +++ /dev/null @@ -1,504 +0,0 @@ -[data-page="home"] { - --color-text: hsl(224, 10%, 10%); - --color-text-secondary: hsl(224, 7%, 46%); - --color-text-dimmed: hsl(224, 6%, 63%); - --color-text-inverted: hsl(0, 0%, 100%); - - --color-border: hsl(224, 6%, 77%); -} - -[data-page="home"] { - @media (prefers-color-scheme: dark) { - --color-text: hsl(0, 0%, 100%); - --color-text-secondary: hsl(224, 6%, 66%); - --color-text-dimmed: hsl(224, 7%, 46%); - --color-text-inverted: hsl(224, 10%, 10%); - - --color-border: hsl(224, 6%, 36%); - } -} - -[data-page="home"] { - --padding: 3rem; - --vertical-padding: 1.5rem; - --heading-font-size: 1.375rem; - - @media (max-width: 30rem) { - --padding: 1rem; - --vertical-padding: 0.75rem; - --heading-font-size: 1rem; - } - - display: flex; - gap: var(--vertical-padding); - flex-direction: column; - font-family: var(--font-mono); - color: var(--color-text); - padding: calc(var(--padding) + 1rem); - - a { - color: var(--color-text); - text-decoration: underline; - text-underline-offset: var(--space-0-75); - text-decoration-thickness: 1px; - } - - [data-component="content"] { - max-width: 67.5rem; - margin: 0 auto; - border: 1px solid var(--color-border); - } - - [data-component="top"] { - padding: calc(var(--padding) * 1.5) var(--padding) var(--padding); - position: relative; - display: flex; - flex-direction: column; - align-items: center; - gap: calc(var(--vertical-padding) / 2); - - img { - height: auto; - width: clamp(200px, 85vw, 552px); - } - - [data-slot="logo dark"] { - display: none; - } - - @media (prefers-color-scheme: dark) { - [data-slot="logo light"] { - display: none; - } - [data-slot="logo dark"] { - display: block; - } - } - - [data-slot="title"] { - line-height: 1.25; - font-weight: 500; - text-align: center; - font-size: var(--heading-font-size); - color: var(--color-text-secondary); - text-transform: uppercase; - } - - [data-slot="login"] { - position: absolute; - top: 0; - right: 0; - border-width: 0 0 1px 1px; - border-style: solid; - border-color: var(--color-border); - background-color: var(--color-bg); - - @media (max-width: 30rem) { - display: none; - } - - a { - display: block; - padding: 0.5rem 1rem calc(0.5rem + 4px); - } - } - } - - [data-component="cta"] { - border-top: 1px solid var(--color-border); - display: flex; - - & > div + div { - border-left: 1px solid var(--color-border); - } - - [data-slot="left"] { - flex: 0 0 auto; - text-align: center; - line-height: 1.4; - padding: var(--vertical-padding) 2rem; - text-transform: uppercase; - font-size: 1.125rem; - - @media (max-width: 30rem) { - font-size: 1rem; - padding-bottom: calc(var(--vertical-padding) + 4px); - } - - @media (max-width: 30rem) { - padding-left: 0.5rem; - padding-right: 0.5rem; - } - } - - [data-slot="center"] { - display: none; - - @media (max-width: 30rem) { - display: block; - flex: 1; - text-align: center; - padding: var(--vertical-padding) 0.5rem; - border-top: 1px solid var(--color-border); - border-left: none; - } - } - - [data-slot="right"] { - flex: 1; - padding: var(--vertical-padding) 1rem; - } - - @media (max-width: 50rem) { - flex-direction: column; - - [data-slot="right"] { - border-left: none; - border-top: 1px solid var(--color-border); - } - } - - [data-slot="command"] { - all: unset; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; - color: var(--color-text-secondary); - font-size: 1.125rem; - font-family: var(--font-mono); - gap: var(--space-2); - width: 100%; - - & > span { - @media (max-width: 24rem) { - font-size: 0.875rem; - } - @media (max-width: 56rem) { - [data-slot="protocol"] { - display: none; - } - } - @media (max-width: 38rem) { - text-align: center; - span:first-child { - display: block; - } - } - } - } - - [data-slot="highlight"] { - color: var(--color-text); - font-weight: 500; - } - } - - [data-component="features"] { - border-top: 1px solid var(--color-border); - padding: var(--padding); - - [data-slot="list"] { - padding-left: var(--space-4); - margin: 0; - list-style: disc; - - li { - margin-bottom: var(--space-4); - line-height: 1.6; - - strong { - text-transform: uppercase; - font-weight: 600; - } - - label { - line-height: 1; - text-transform: uppercase; - font-size: 0.75rem; - letter-spacing: 0.03125rem; - background: var(--color-border); - padding: 0.125rem 0.375rem; - color: var(--color-text-inverted); - } - } - - li:last-child { - margin-bottom: 0; - } - } - } - - [data-component="install"] { - border-top: 1px solid var(--color-border); - display: grid; - grid-template-columns: 1fr 1fr; - grid-template-rows: 1fr 1fr; - - @media (max-width: 40rem) { - grid-template-columns: 1fr; - grid-template-rows: auto; - } - } - - [data-component="method"] { - display: flex; - padding: calc(var(--vertical-padding) / 2) calc(var(--padding) / 2) calc(var(--vertical-padding) / 2 + 0.125rem); - flex-direction: column; - text-align: left; - gap: var(--space-2-5); - - @media (max-width: 30rem) { - gap: 0.3125rem; - } - - @media (max-width: 40rem) { - text-align: left; - } - - &:nth-child(2) { - border-left: 1px solid var(--color-border); - - @media (max-width: 40rem) { - border-left: none; - border-top: 1px solid var(--color-border); - } - } - - &:nth-child(3) { - border-top: 1px solid var(--color-border); - } - - &:nth-child(4) { - border-top: 1px solid var(--color-border); - border-left: 1px solid var(--color-border); - - @media (max-width: 40rem) { - border-left: none; - } - } - - [data-component="title"] { - letter-spacing: -0.03125rem; - text-transform: uppercase; - font-weight: normal; - font-size: 1rem; - flex-shrink: 0; - color: var(--color-text-dimmed); - - @media (max-width: 30rem) { - font-size: 0.75rem; - } - } - - [data-slot="button"] { - all: unset; - cursor: pointer; - display: flex; - align-items: center; - color: var(--color-text-secondary); - gap: var(--space-2-5); - font-size: 1rem; - - @media (max-width: 24rem) { - font-size: 0.875rem; - } - - strong { - color: var(--color-text); - font-weight: 500; - } - - @media (max-width: 40rem) { - justify-content: flex-start; - } - - @media (max-width: 30rem) { - justify-content: center; - } - } - } - - [data-component="screenshots"] { - border-top: 1px solid var(--color-border); - - figure { - flex: 1; - display: flex; - flex-direction: column; - gap: calc(var(--padding) / 4); - padding: calc(var(--padding) / 2); - border-width: 0; - border-style: solid; - border-color: var(--color-border); - min-height: 0; - overflow: hidden; - - & > div, - figcaption { - display: flex; - align-items: center; - } - - & > div { - flex: 1; - min-height: 0; - display: flex; - align-items: center; - justify-content: center; - } - - a { - display: flex; - flex: 1; - min-height: 0; - align-items: center; - justify-content: center; - width: 100%; - height: 100%; - } - - figcaption { - letter-spacing: -0.03125rem; - text-transform: uppercase; - color: var(--color-text-dimmed); - flex-shrink: 0; - - @media (max-width: 30rem) { - font-size: 0.75rem; - } - } - } - - & > [data-slot="left"] figure { - height: var(--images-height); - box-sizing: border-box; - } - - & > [data-slot="right"] figure { - height: calc(var(--images-height) / 2); - box-sizing: border-box; - } - - & > [data-slot="left"] img { - width: 100%; - height: 100%; - min-width: 0; - object-fit: contain; - } - - & > [data-slot="right"] img { - width: 100%; - height: calc(100% - 2rem); - object-fit: contain; - display: block; - } - - @media (max-width: 30rem) { - & { - --images-height: auto; - grid-template-columns: 1fr; - grid-template-rows: auto auto; - } - - & > [data-slot="left"] { - grid-row: 1; - grid-column: 1; - } - - & > [data-slot="right"] { - grid-row: 2; - grid-column: 1; - border-left: none; - border-top: 1px solid var(--color-border); - - & > [data-slot="row1"], - & > [data-slot="row2"] { - height: auto; - } - } - - & > [data-slot="left"] figure, - & > [data-slot="right"] figure { - height: auto; - } - - & > [data-slot="left"] img, - & > [data-slot="right"] img { - width: 100%; - height: auto; - max-height: none; - } - } - } - - [data-component="copy-status"] { - @media (max-width: 38rem) { - display: none; - } - - [data-slot="copy"] { - display: block; - width: var(--space-4); - height: var(--space-4); - color: var(--color-text-dimmed); - - [data-copied] & { - display: none; - } - } - - [data-slot="check"] { - display: none; - width: var(--space-4); - height: var(--space-4); - color: var(--color-text); - - [data-copied] & { - display: block; - } - } - } - - [data-component="footer"] { - border-top: 1px solid var(--color-border); - display: flex; - flex-direction: row; - - [data-slot="cell"] { - flex: 1; - text-align: center; - text-transform: uppercase; - padding: var(--vertical-padding) 0.5rem; - } - - [data-slot="cell"] + [data-slot="cell"] { - border-left: 1px solid var(--color-border); - } - - /* Mobile: third column on its own row */ - @media (max-width: 30rem) { - flex-wrap: wrap; - - [data-slot="cell"]:nth-child(1), - [data-slot="cell"]:nth-child(2) { - flex: 1; - } - - [data-slot="cell"]:nth-child(3) { - flex: 1 0 100%; - border-left: none; - border-top: 1px solid var(--color-border); - } - } - } - - [data-component="legal"] { - color: var(--color-text-dimmed); - text-align: center; - - a { - color: var(--color-text-dimmed); - } - } -} diff --git a/packages/cloud/app/src/routes/index.tsx b/packages/cloud/app/src/routes/index.tsx deleted file mode 100644 index 9075f4079..000000000 --- a/packages/cloud/app/src/routes/index.tsx +++ /dev/null @@ -1,183 +0,0 @@ -import "./index.css" -import { Title } from "@solidjs/meta" -import { onCleanup, onMount } from "solid-js" -import logoLight from "../asset/logo-ornate-light.svg" -import logoDark from "../asset/logo-ornate-dark.svg" -import IMG_SPLASH from "../asset/lander/screenshot-splash.png" -import { IconCopy, IconCheck } from "../component/icon" -import { createAsync, query } from "@solidjs/router" -import { getActor } from "~/context/auth" -import { withActor } from "~/context/auth.withActor" -import { Account } from "@opencode/cloud-core/account.js" - -function CopyStatus() { - return ( -
- - -
- ) -} - -const defaultWorkspace = query(async () => { - "use server" - const actor = await getActor() - if (actor.type === "account") { - const workspaces = await withActor(() => Account.workspaces()) - return workspaces[0].id - } -}, "defaultWorkspace") - -export default function Home() { - const workspace = createAsync(() => defaultWorkspace()) - onMount(() => { - const commands = document.querySelectorAll("[data-copy]") - for (const button of commands) { - const callback = () => { - const text = button.textContent - if (text) { - navigator.clipboard.writeText(text) - button.setAttribute("data-copied", "") - setTimeout(() => { - button.removeAttribute("data-copied") - }, 1500) - } - } - button.addEventListener("click", callback) - onCleanup(() => { - button.removeEventListener("click", callback) - }) - } - }) - - return ( -
- opencode | AI coding agent built for the terminal - -
-
- opencode logo light - opencode logo dark -

The AI coding agent built for the terminal

- -
- -
- - -
- -
-
- -
-
    -
  • - Native TUI A responsive, native, themeable terminal UI -
  • -
  • - LSP enabled Automatically loads the right LSPs for the LLM -
  • -
  • - opencode zen A curated list of models provided by opencode{" "} - -
  • -
  • - Multi-session Start multiple agents in parallel on the same project -
  • -
  • - Shareable links Share a link to any sessions for reference or to debug -
  • -
  • - Claude Pro Log in with Anthropic to use your Claude Pro or Max account -
  • -
  • - Use any model Supports 75+ LLM providers through{" "} - Models.dev, including local models -
  • -
-
- -
-
-

npm

- -
-
-

bun

- -
-
-

homebrew

- -
-
-

paru

- -
-
- -
-
-
opencode TUI with the tokyonight theme
- - opencode TUI with tokyonight theme - -
-
- - -
- -
- - ©2025 Anomaly Innovations - -
-
- ) -} diff --git a/packages/cloud/app/src/routes/s/[id].ts b/packages/cloud/app/src/routes/s/[id].ts deleted file mode 100644 index 3fd1305a0..000000000 --- a/packages/cloud/app/src/routes/s/[id].ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" - -async function handler(evt: APIEvent) { - const req = evt.request.clone() - const url = new URL(req.url) - const targetUrl = `https://docs.opencode.ai/docs${url.pathname}${url.search}` - const response = await fetch(targetUrl, { - method: req.method, - headers: req.headers, - body: req.body, - }) - return response -} - -export const GET = handler -export const POST = handler -export const PUT = handler -export const DELETE = handler -export const OPTIONS = handler -export const PATCH = handler diff --git a/packages/cloud/app/src/routes/stripe/webhook.ts b/packages/cloud/app/src/routes/stripe/webhook.ts deleted file mode 100644 index 925ede1ac..000000000 --- a/packages/cloud/app/src/routes/stripe/webhook.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { Billing } from "@opencode/cloud-core/billing.js" -import type { APIEvent } from "@solidjs/start/server" -import { Database, eq, sql } from "@opencode/cloud-core/drizzle/index.js" -import { BillingTable, PaymentTable } from "@opencode/cloud-core/schema/billing.sql.js" -import { Identifier } from "@opencode/cloud-core/identifier.js" -import { centsToMicroCents } from "@opencode/cloud-core/util/price.js" -import { Actor } from "@opencode/cloud-core/actor.js" -import { Resource } from "@opencode/cloud-resource" - -export async function POST(input: APIEvent) { - const body = await Billing.stripe().webhooks.constructEventAsync( - await input.request.text(), - input.request.headers.get("stripe-signature")!, - Resource.STRIPE_WEBHOOK_SECRET.value, - ) - - console.log(body.type, JSON.stringify(body, null, 2)) - if (body.type === "customer.updated") { - // check default payment method changed - const prevInvoiceSettings = body.data.previous_attributes?.invoice_settings ?? {} - if (!("default_payment_method" in prevInvoiceSettings)) return - - const customerID = body.data.object.id - const paymentMethodID = body.data.object.invoice_settings.default_payment_method as string - - if (!customerID) throw new Error("Customer ID not found") - if (!paymentMethodID) throw new Error("Payment method ID not found") - - const paymentMethod = await Billing.stripe().paymentMethods.retrieve(paymentMethodID) - await Database.use(async (tx) => { - await tx - .update(BillingTable) - .set({ - paymentMethodID, - paymentMethodLast4: paymentMethod.card!.last4, - }) - .where(eq(BillingTable.customerID, customerID)) - }) - } - if (body.type === "checkout.session.completed") { - const workspaceID = body.data.object.metadata?.workspaceID - const customerID = body.data.object.customer as string - const paymentID = body.data.object.payment_intent as string - const amount = body.data.object.amount_total - - if (!workspaceID) throw new Error("Workspace ID not found") - if (!customerID) throw new Error("Customer ID not found") - if (!amount) throw new Error("Amount not found") - if (!paymentID) throw new Error("Payment ID not found") - - await Actor.provide("system", { workspaceID }, async () => { - const customer = await Billing.get() - if (customer?.customerID && customer.customerID !== customerID) throw new Error("Customer ID mismatch") - - // set customer metadata - if (!customer?.customerID) { - await Billing.stripe().customers.update(customerID, { - metadata: { - workspaceID, - }, - }) - } - - // get payment method for the payment intent - const paymentIntent = await Billing.stripe().paymentIntents.retrieve(paymentID, { - expand: ["payment_method"], - }) - const paymentMethod = paymentIntent.payment_method - if (!paymentMethod || typeof paymentMethod === "string") throw new Error("Payment method not expanded") - - await Database.transaction(async (tx) => { - await tx - .update(BillingTable) - .set({ - balance: sql`${BillingTable.balance} + ${centsToMicroCents(Billing.CHARGE_AMOUNT)}`, - customerID, - paymentMethodID: paymentMethod.id, - paymentMethodLast4: paymentMethod.card!.last4, - reload: true, - reloadError: null, - timeReloadError: null, - }) - .where(eq(BillingTable.workspaceID, workspaceID)) - await tx.insert(PaymentTable).values({ - workspaceID, - id: Identifier.create("payment"), - amount: centsToMicroCents(Billing.CHARGE_AMOUNT), - paymentID, - customerID, - }) - }) - }) - } - - console.log("finished handling") - - return Response.json("ok", { status: 200 }) -} diff --git a/packages/cloud/app/src/routes/workspace.css b/packages/cloud/app/src/routes/workspace.css deleted file mode 100644 index ed94365f0..000000000 --- a/packages/cloud/app/src/routes/workspace.css +++ /dev/null @@ -1,127 +0,0 @@ -[data-page="workspace"] { - line-height: 1; - - /* Common elements */ - button { - padding: var(--space-3) var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--border-radius-sm); - background-color: var(--color-bg); - color: var(--color-text); - font-size: var(--font-size-sm); - font-family: var(--font-sans); - font-weight: 500; - text-transform: uppercase; - cursor: pointer; - transition: all 0.15s ease; - - &:hover:not(:disabled) { - background-color: var(--color-surface-hover); - border-color: var(--color-accent); - } - - &:active { - transform: translateY(1px); - } - - &:disabled { - opacity: 0.5; - transform: none; - } - - &[data-color="primary"] { - background-color: var(--color-primary); - border-color: var(--color-primary); - color: var(--color-primary-text); - - &:hover:not(:disabled) { - background-color: var(--color-primary-hover); - border-color: var(--color-primary-hover); - } - } - - &[data-color="ghost"] { - background-color: transparent; - border-color: transparent; - color: var(--color-text-muted); - - &:hover:not(:disabled) { - background-color: var(--color-surface-hover); - border-color: var(--color-border); - color: var(--color-text); - } - } - } - - a { - color: var(--color-text); - text-decoration: underline; - text-underline-offset: var(--space-0-75); - text-decoration-thickness: 1px; - } - - /* Workspace Header */ - [data-component="workspace-header"] { - position: sticky; - top: 0; - z-index: 100; - display: flex; - justify-content: space-between; - align-items: center; - padding: var(--space-4) var(--space-4); - border-bottom: 1px solid var(--color-border); - background-color: var(--color-bg); - - @media (max-width: 30rem) { - padding: var(--space-4) var(--space-4); - } - } - - [data-slot="header-brand"] { - flex: 0 0 auto; - padding-top: 4px; - - svg { - width: 138px; - } - - [data-component="site-title"] { - font-size: var(--font-size-lg); - font-weight: 600; - color: var(--color-text); - text-decoration: none; - letter-spacing: -0.02em; - } - } - - [data-slot="header-actions"] { - display: flex; - gap: var(--space-4); - align-items: center; - font-size: var(--font-size-sm); - - [data-slot="user"] { - color: var(--color-text-muted); - } - - @media (max-width: 30rem) { - [data-slot="user"] { - display: none; - } - } - - a, - button { - appearance: none; - background: none; - border: none; - cursor: pointer; - padding: 0; - color: var(--color-text); - text-decoration: underline; - text-underline-offset: var(--space-0-75); - text-decoration-thickness: 1px; - text-transform: uppercase; - } - } -} diff --git a/packages/cloud/app/src/routes/workspace.tsx b/packages/cloud/app/src/routes/workspace.tsx deleted file mode 100644 index 3f08a70a0..000000000 --- a/packages/cloud/app/src/routes/workspace.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import "./workspace.css" -import { useAuthSession } from "~/context/auth.session" -import { IconLogo } from "../component/icon" -import { withActor } from "~/context/auth.withActor" -import { - query, - action, - redirect, - createAsync, - RouteSectionProps, - Navigate, - useNavigate, - useParams, - A, -} from "@solidjs/router" -import { User } from "@opencode/cloud-core/user.js" -import { Actor } from "@opencode/cloud-core/actor.js" -import { getRequestEvent } from "solid-js/web" - -const getUserInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - const actor = Actor.assert("user") - return await User.fromID(actor.properties.userID) - }, workspaceID) -}, "userInfo") - -const logout = action(async () => { - "use server" - const auth = await useAuthSession() - const event = getRequestEvent() - const current = auth.data.current - if (current) - await auth.update((val) => { - delete val.account?.[current] - const first = Object.keys(val.account ?? {})[0] - val.current = first - event!.locals.actor = undefined - return val - }) - throw redirect("/") -}) - -export default function WorkspaceLayout(props: RouteSectionProps) { - const params = useParams() - const userInfo = createAsync(() => getUserInfo(params.id)) - return ( -
-
-
- - - -
-
- {userInfo()?.email} -
- -
-
-
-
{props.children}
-
- ) -} diff --git a/packages/cloud/app/src/routes/workspace/[id].css b/packages/cloud/app/src/routes/workspace/[id].css deleted file mode 100644 index 8b318a19f..000000000 --- a/packages/cloud/app/src/routes/workspace/[id].css +++ /dev/null @@ -1,115 +0,0 @@ -[data-page="workspace-[id]"] { - max-width: 64rem; - padding: var(--space-10) var(--space-4); - margin: 0 auto; - width: 100%; - display: flex; - flex-direction: column; - gap: var(--space-10); - - @media (max-width: 30rem) { - padding-top: var(--space-4); - padding-bottom: var(--space-4); - - gap: var(--space-8); - } - - [data-slot="sections"] { - display: flex; - flex-direction: column; - gap: var(--space-16); - - @media (max-width: 30rem) { - gap: var(--space-8); - } - - section { - display: flex; - flex-direction: column; - gap: var(--space-8); - - @media (max-width: 30rem) { - gap: var(--space-6); - } - - /* Section titles */ - [data-slot="section-title"] { - display: flex; - flex-direction: column; - gap: var(--space-1); - - h2 { - font-size: var(--font-size-md); - font-weight: 600; - line-height: 1.2; - letter-spacing: -0.03125rem; - margin: 0; - color: var(--color-text-secondary); - text-transform: uppercase; - - @media (max-width: 30rem) { - font-size: var(--font-size-md); - } - } - - p { - line-height: 1.5; - font-size: var(--font-size-md); - color: var(--color-text-muted); - - a { - color: var(--color-text-muted); - } - - @media (max-width: 30rem) { - font-size: var(--font-size-sm); - } - } - } - } - section:not(:last-child) { - border-bottom: 1px solid var(--color-border); - padding-bottom: var(--space-16); - - @media (max-width: 30rem) { - padding-bottom: var(--space-8); - } - } - } - - /* Title section */ - [data-component="title-section"] { - display: flex; - flex-direction: column; - gap: var(--space-2); - padding-bottom: var(--space-8); - border-bottom: 1px solid var(--color-border); - - @media (max-width: 30rem) { - padding-bottom: var(--space-6); - } - - h1 { - font-size: var(--font-size-2xl); - font-weight: 500; - line-height: 1.2; - letter-spacing: -0.03125rem; - margin: 0; - text-transform: uppercase; - - @media (max-width: 30rem) { - font-size: var(--font-size-xl); - } - } - - p { - line-height: 1.5; - font-size: var(--font-size-md); - color: var(--color-text-muted); - - a { - color: var(--color-text-muted); - } - } - } -} diff --git a/packages/cloud/app/src/routes/workspace/[id].tsx b/packages/cloud/app/src/routes/workspace/[id].tsx deleted file mode 100644 index 4a2c3424d..000000000 --- a/packages/cloud/app/src/routes/workspace/[id].tsx +++ /dev/null @@ -1,50 +0,0 @@ -import "./[id].css" -import { Billing } from "@opencode/cloud-core/billing.js" -import { query, useParams, createAsync } from "@solidjs/router" -import { Show } from "solid-js" -import { withActor } from "~/context/auth.withActor" -import { MonthlyLimitSection } from "~/component/workspace/monthly-limit-section" -import { NewUserSection } from "~/component/workspace/new-user-section" -import { BillingSection } from "~/component/workspace/billing-section" -import { PaymentSection } from "~/component/workspace/payment-section" -import { UsageSection } from "~/component/workspace/usage-section" -import { KeySection } from "~/component/workspace/key-section" - -const getBillingInfo = query(async (workspaceID: string) => { - "use server" - return withActor(async () => { - return await Billing.get() - }, workspaceID) -}, "billing.get") - -export default function () { - const params = useParams() - const balanceInfo = createAsync(() => getBillingInfo(params.id)) - - return ( -
-
-

Zen

-

- Curated list of models provided by opencode.{" "} - - Learn more - - . -

-
- -
- - - - - {/**/} - - - - -
-
- ) -} diff --git a/packages/cloud/app/src/routes/workspace/index.tsx b/packages/cloud/app/src/routes/workspace/index.tsx deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/cloud/app/src/routes/zen/handler.ts b/packages/cloud/app/src/routes/zen/handler.ts deleted file mode 100644 index ab1fc6599..000000000 --- a/packages/cloud/app/src/routes/zen/handler.ts +++ /dev/null @@ -1,594 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" -import path from "node:path" -import { and, Database, eq, isNull, lt, or, sql } from "@opencode/cloud-core/drizzle/index.js" -import { KeyTable } from "@opencode/cloud-core/schema/key.sql.js" -import { BillingTable, PaymentTable, UsageTable } from "@opencode/cloud-core/schema/billing.sql.js" -import { centsToMicroCents } from "@opencode/cloud-core/util/price.js" -import { Identifier } from "@opencode/cloud-core/identifier.js" -import { Resource } from "@opencode/cloud-resource" -import { Billing } from "../../../../core/src/billing" -import { Actor } from "@opencode/cloud-core/actor.js" - -type ModelCost = { - input: number - output: number - cacheRead?: number - cacheWrite5m?: number - cacheWrite1h?: number -} - -type Model = { - id: string - auth: boolean - cost: ModelCost | ((usage: any) => ModelCost) - headerMappings: Record - providers: Record< - string, - { - api: string - apiKey: string - model: string - weight?: number - } - > -} - -export async function handler( - input: APIEvent, - opts: { - modifyBody?: (body: any) => any - setAuthHeader: (headers: Headers, apiKey: string) => void - parseApiKey: (headers: Headers) => string | undefined - onStreamPart: (chunk: string) => void - getStreamUsage: () => any - normalizeUsage: (body: any) => { - inputTokens: number - outputTokens: number - reasoningTokens?: number - cacheReadTokens?: number - cacheWrite5mTokens?: number - cacheWrite1hTokens?: number - } - }, -) { - class AuthError extends Error {} - class CreditsError extends Error {} - class MonthlyLimitError extends Error {} - class ModelError extends Error {} - - const MODELS: Record = { - "claude-opus-4-1": { - id: "claude-opus-4-1" as const, - auth: true, - cost: { - input: 0.000015, - output: 0.000075, - cacheRead: 0.0000015, - cacheWrite5m: 0.00001875, - cacheWrite1h: 0.00003, - }, - headerMappings: {}, - providers: { - anthropic: { - api: "https://api.anthropic.com", - apiKey: Resource.ANTHROPIC_API_KEY.value, - model: "claude-opus-4-1-20250805", - }, - }, - }, - "claude-sonnet-4": { - id: "claude-sonnet-4" as const, - auth: true, - cost: (usage: any) => { - const totalInputTokens = - usage.inputTokens + usage.cacheReadTokens + usage.cacheWrite5mTokens + usage.cacheWrite1hTokens - return totalInputTokens <= 200_000 - ? { - input: 0.000003, - output: 0.000015, - cacheRead: 0.0000003, - cacheWrite5m: 0.00000375, - cacheWrite1h: 0.000006, - } - : { - input: 0.000006, - output: 0.0000225, - cacheRead: 0.0000006, - cacheWrite5m: 0.0000075, - cacheWrite1h: 0.000012, - } - }, - headerMappings: {}, - providers: { - anthropic: { - api: "https://api.anthropic.com", - apiKey: Resource.ANTHROPIC_API_KEY.value, - model: "claude-sonnet-4-20250514", - }, - }, - }, - "claude-3-5-haiku": { - id: "claude-3-5-haiku" as const, - auth: true, - cost: { - input: 0.0000008, - output: 0.000004, - cacheRead: 0.00000008, - cacheWrite5m: 0.000001, - cacheWrite1h: 0.0000016, - }, - headerMappings: {}, - providers: { - anthropic: { - api: "https://api.anthropic.com", - apiKey: Resource.ANTHROPIC_API_KEY.value, - model: "claude-3-5-haiku-20241022", - }, - }, - }, - "gpt-5": { - id: "gpt-5" as const, - auth: true, - cost: { - input: 0.00000125, - output: 0.00001, - cacheRead: 0.000000125, - }, - headerMappings: {}, - providers: { - openai: { - api: "https://api.openai.com", - apiKey: Resource.OPENAI_API_KEY.value, - model: "gpt-5", - }, - }, - }, - "qwen3-coder": { - id: "qwen3-coder" as const, - auth: true, - cost: { - input: 0.00000045, - output: 0.0000018, - }, - headerMappings: {}, - providers: { - baseten: { - api: "https://inference.baseten.co", - apiKey: Resource.BASETEN_API_KEY.value, - model: "Qwen/Qwen3-Coder-480B-A35B-Instruct", - weight: 4, - }, - fireworks: { - api: "https://api.fireworks.ai/inference", - apiKey: Resource.FIREWORKS_API_KEY.value, - model: "accounts/fireworks/models/qwen3-coder-480b-a35b-instruct", - weight: 1, - }, - }, - }, - "kimi-k2": { - id: "kimi-k2" as const, - auth: true, - cost: { - input: 0.0000006, - output: 0.0000025, - }, - headerMappings: {}, - providers: { - baseten: { - api: "https://inference.baseten.co", - apiKey: Resource.BASETEN_API_KEY.value, - model: "moonshotai/Kimi-K2-Instruct-0905", - //weight: 4, - }, - //fireworks: { - // api: "https://api.fireworks.ai/inference", - // apiKey: Resource.FIREWORKS_API_KEY.value, - // model: "accounts/fireworks/models/kimi-k2-instruct-0905", - // weight: 1, - //}, - }, - }, - "grok-code": { - id: "grok-code" as const, - auth: false, - cost: { - input: 0, - output: 0, - cacheRead: 0, - }, - headerMappings: { - "x-grok-conv-id": "x-opencode-session", - "x-grok-req-id": "x-opencode-request", - }, - providers: { - xai: { - api: "https://api.x.ai", - apiKey: Resource.XAI_API_KEY.value, - model: "grok-code", - }, - }, - }, - // deprecated - "qwen/qwen3-coder": { - id: "qwen/qwen3-coder" as const, - auth: true, - cost: { - input: 0.00000038, - output: 0.00000153, - }, - headerMappings: {}, - providers: { - baseten: { - api: "https://inference.baseten.co", - apiKey: Resource.BASETEN_API_KEY.value, - model: "Qwen/Qwen3-Coder-480B-A35B-Instruct", - weight: 5, - }, - fireworks: { - api: "https://api.fireworks.ai/inference", - apiKey: Resource.FIREWORKS_API_KEY.value, - model: "accounts/fireworks/models/qwen3-coder-480b-a35b-instruct", - weight: 1, - }, - }, - }, - } - - const FREE_WORKSPACES = [ - "wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank - ] - - const logger = { - metric: (values: Record) => { - console.log(`_metric:${JSON.stringify(values)}`) - }, - log: console.log, - debug: (message: string) => { - if (Resource.App.stage === "production") return - console.debug(message) - }, - } - - try { - const url = new URL(input.request.url) - const body = await input.request.json() - logger.debug(JSON.stringify(body)) - logger.metric({ - is_tream: !!body.stream, - session: input.request.headers.get("x-opencode-session"), - request: input.request.headers.get("x-opencode-request"), - }) - const MODEL = validateModel() - const apiKey = await authenticate() - const isFree = FREE_WORKSPACES.includes(apiKey?.workspaceID ?? "") - await checkCreditsAndLimit() - const providerName = selectProvider() - const providerData = MODEL.providers[providerName] - logger.metric({ provider: providerName }) - - // Request to model provider - const startTimestamp = Date.now() - const res = await fetch(path.posix.join(providerData.api, url.pathname.replace(/^\/zen/, "") + url.search), { - method: "POST", - headers: (() => { - const headers = input.request.headers - headers.delete("host") - headers.delete("content-length") - opts.setAuthHeader(headers, providerData.apiKey) - Object.entries(MODEL.headerMappings ?? {}).forEach(([k, v]) => { - headers.set(k, headers.get(v)!) - }) - return headers - })(), - body: JSON.stringify({ - ...(opts.modifyBody?.(body) ?? body), - model: providerData.model, - }), - }) - - // Scrub response headers - const resHeaders = new Headers() - const keepHeaders = ["content-type", "cache-control"] - for (const [k, v] of res.headers.entries()) { - if (keepHeaders.includes(k.toLowerCase())) { - resHeaders.set(k, v) - } - } - - // Handle non-streaming response - if (!body.stream) { - const json = await res.json() - const body = JSON.stringify(json) - logger.metric({ response_length: body.length }) - logger.debug(body) - await trackUsage(json.usage) - await reload() - return new Response(body, { - status: res.status, - statusText: res.statusText, - headers: resHeaders, - }) - } - - // Handle streaming response - const stream = new ReadableStream({ - start(c) { - const reader = res.body?.getReader() - const decoder = new TextDecoder() - let buffer = "" - let responseLength = 0 - - function pump(): Promise { - return ( - reader?.read().then(async ({ done, value }) => { - if (done) { - logger.metric({ response_length: responseLength }) - const usage = opts.getStreamUsage() - if (usage) { - await trackUsage(usage) - await reload() - } - c.close() - return - } - - if (responseLength === 0) { - logger.metric({ time_to_first_byte: Date.now() - startTimestamp }) - } - responseLength += value.length - buffer += decoder.decode(value, { stream: true }) - - const parts = buffer.split("\n\n") - buffer = parts.pop() ?? "" - - for (const part of parts) { - logger.debug(part) - opts.onStreamPart(part.trim()) - } - - c.enqueue(value) - - return pump() - }) || Promise.resolve() - ) - } - - return pump() - }, - }) - - return new Response(stream, { - status: res.status, - statusText: res.statusText, - headers: resHeaders, - }) - - function validateModel() { - if (!(body.model in MODELS)) { - throw new ModelError(`Model ${body.model} not supported`) - } - const model = MODELS[body.model as keyof typeof MODELS] - logger.metric({ model: model.id }) - return model - } - - async function authenticate() { - try { - const apiKey = opts.parseApiKey(input.request.headers) - if (!apiKey) throw new AuthError("Missing API key.") - - const key = await Database.use((tx) => - tx - .select({ - id: KeyTable.id, - workspaceID: KeyTable.workspaceID, - }) - .from(KeyTable) - .where(and(eq(KeyTable.key, apiKey), isNull(KeyTable.timeDeleted))) - .then((rows) => rows[0]), - ) - - if (!key) throw new AuthError("Invalid API key.") - logger.metric({ - api_key: key.id, - workspace: key.workspaceID, - }) - return key - } catch (e) { - // ignore error if model does not require authentication - if (!MODEL.auth) return - throw e - } - } - - async function checkCreditsAndLimit() { - if (!apiKey || !MODEL.auth || isFree) return - - const billing = await Database.use((tx) => - tx - .select({ - balance: BillingTable.balance, - paymentMethodID: BillingTable.paymentMethodID, - monthlyLimit: BillingTable.monthlyLimit, - monthlyUsage: BillingTable.monthlyUsage, - timeMonthlyUsageUpdated: BillingTable.timeMonthlyUsageUpdated, - }) - .from(BillingTable) - .where(eq(BillingTable.workspaceID, apiKey.workspaceID)) - .then((rows) => rows[0]), - ) - - if (!billing.paymentMethodID) throw new CreditsError("No payment method") - if (billing.balance <= 0) throw new CreditsError("Insufficient balance") - if ( - billing.monthlyLimit && - billing.monthlyUsage && - billing.timeMonthlyUsageUpdated && - billing.monthlyUsage >= centsToMicroCents(billing.monthlyLimit * 100) - ) { - const now = new Date() - const currentYear = now.getUTCFullYear() - const currentMonth = now.getUTCMonth() - const dateYear = billing.timeMonthlyUsageUpdated.getUTCFullYear() - const dateMonth = billing.timeMonthlyUsageUpdated.getUTCMonth() - if (currentYear === dateYear && currentMonth === dateMonth) - throw new MonthlyLimitError(`You have reached your monthly spending limit of $${billing.monthlyLimit}.`) - } - } - - function selectProvider() { - const picks = Object.entries(MODEL.providers).flatMap(([name, provider]) => - Array(provider.weight ?? 1).fill(name), - ) - return picks[Math.floor(Math.random() * picks.length)] - } - - async function trackUsage(usage: any) { - const { inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWrite5mTokens, cacheWrite1hTokens } = - opts.normalizeUsage(usage) - - const modelCost = typeof MODEL.cost === "function" ? MODEL.cost(usage) : MODEL.cost - - const inputCost = modelCost.input * inputTokens * 100 - const outputCost = modelCost.output * outputTokens * 100 - const reasoningCost = (() => { - if (!reasoningTokens) return undefined - return modelCost.output * reasoningTokens * 100 - })() - const cacheReadCost = (() => { - if (!cacheReadTokens) return undefined - if (!modelCost.cacheRead) return undefined - return modelCost.cacheRead * cacheReadTokens * 100 - })() - const cacheWrite5mCost = (() => { - if (!cacheWrite5mTokens) return undefined - if (!modelCost.cacheWrite5m) return undefined - return modelCost.cacheWrite5m * cacheWrite5mTokens * 100 - })() - const cacheWrite1hCost = (() => { - if (!cacheWrite1hTokens) return undefined - if (!modelCost.cacheWrite1h) return undefined - return modelCost.cacheWrite1h * cacheWrite1hTokens * 100 - })() - const totalCostInCent = - inputCost + - outputCost + - (reasoningCost ?? 0) + - (cacheReadCost ?? 0) + - (cacheWrite5mCost ?? 0) + - (cacheWrite1hCost ?? 0) - - logger.metric({ - "tokens.input": inputTokens, - "tokens.output": outputTokens, - "tokens.reasoning": reasoningTokens, - "tokens.cache_read": cacheReadTokens, - "tokens.cache_write_5m": cacheWrite5mTokens, - "tokens.cache_write_1h": cacheWrite1hTokens, - "cost.input": Math.round(inputCost), - "cost.output": Math.round(outputCost), - "cost.reasoning": reasoningCost ? Math.round(reasoningCost) : undefined, - "cost.cache_read": cacheReadCost ? Math.round(cacheReadCost) : undefined, - "cost.cache_write_5m": cacheWrite5mCost ? Math.round(cacheWrite5mCost) : undefined, - "cost.cache_write_1h": cacheWrite1hCost ? Math.round(cacheWrite1hCost) : undefined, - "cost.total": Math.round(totalCostInCent), - }) - - if (!apiKey) return - - const cost = isFree ? 0 : centsToMicroCents(totalCostInCent) - await Database.transaction(async (tx) => { - await tx.insert(UsageTable).values({ - workspaceID: apiKey.workspaceID, - id: Identifier.create("usage"), - model: MODEL.id, - provider: providerName, - inputTokens, - outputTokens, - reasoningTokens, - cacheReadTokens, - cacheWrite5mTokens, - cacheWrite1hTokens, - cost, - }) - await tx - .update(BillingTable) - .set({ - balance: sql`${BillingTable.balance} - ${cost}`, - monthlyUsage: sql` - CASE - WHEN MONTH(${BillingTable.timeMonthlyUsageUpdated}) = MONTH(now()) AND YEAR(${BillingTable.timeMonthlyUsageUpdated}) = YEAR(now()) THEN ${BillingTable.monthlyUsage} + ${cost} - ELSE ${cost} - END - `, - timeMonthlyUsageUpdated: sql`now()`, - }) - .where(eq(BillingTable.workspaceID, apiKey.workspaceID)) - }) - - await Database.use((tx) => - tx - .update(KeyTable) - .set({ timeUsed: sql`now()` }) - .where(eq(KeyTable.id, apiKey.id)), - ) - } - - async function reload() { - if (!apiKey) return - - const lock = await Database.use((tx) => - tx - .update(BillingTable) - .set({ - timeReloadLockedTill: sql`now() + interval 1 minute`, - }) - .where( - and( - eq(BillingTable.workspaceID, apiKey.workspaceID), - eq(BillingTable.reload, true), - lt(BillingTable.balance, centsToMicroCents(Billing.CHARGE_THRESHOLD)), - or(isNull(BillingTable.timeReloadLockedTill), lt(BillingTable.timeReloadLockedTill, sql`now()`)), - ), - ), - ) - if (lock.rowsAffected === 0) return - - await Actor.provide("system", { workspaceID: apiKey.workspaceID }, async () => { - await Billing.reload() - }) - } - } catch (error: any) { - logger.metric({ - "error.type": error.constructor.name, - "error.message": error.message, - }) - - // Note: both top level "type" and "error.type" fields are used by the @ai-sdk/anthropic client to render the error message. - if ( - error instanceof AuthError || - error instanceof CreditsError || - error instanceof MonthlyLimitError || - error instanceof ModelError - ) - return new Response( - JSON.stringify({ - type: "error", - error: { type: error.constructor.name, message: error.message }, - }), - { status: 401 }, - ) - - return new Response( - JSON.stringify({ - type: "error", - error: { - type: "error", - message: error.message, - }, - }), - { status: 500 }, - ) - } -} diff --git a/packages/cloud/app/src/routes/zen/v1/chat/completions.ts b/packages/cloud/app/src/routes/zen/v1/chat/completions.ts deleted file mode 100644 index 801557324..000000000 --- a/packages/cloud/app/src/routes/zen/v1/chat/completions.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" -import { handler } from "~/routes/zen/handler" - -type Usage = { - prompt_tokens?: number - completion_tokens?: number - total_tokens?: number - prompt_tokens_details?: { - text_tokens?: number - audio_tokens?: number - image_tokens?: number - cached_tokens?: number - } - completion_tokens_details?: { - reasoning_tokens?: number - audio_tokens?: number - accepted_prediction_tokens?: number - rejected_prediction_tokens?: number - } -} - -export function POST(input: APIEvent) { - let usage: Usage - return handler(input, { - modifyBody: (body: any) => ({ - ...body, - ...(body.stream ? { stream_options: { include_usage: true } } : {}), - }), - setAuthHeader: (headers: Headers, apiKey: string) => { - headers.set("authorization", `Bearer ${apiKey}`) - }, - parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1], - onStreamPart: (chunk: string) => { - if (!chunk.startsWith("data: ")) return - - let json - try { - json = JSON.parse(chunk.slice(6)) as { usage?: Usage } - } catch (e) { - return - } - - if (!json.usage) return - usage = json.usage - }, - getStreamUsage: () => usage, - normalizeUsage: (usage: Usage) => ({ - inputTokens: usage.prompt_tokens ?? 0, - outputTokens: usage.completion_tokens ?? 0, - reasoningTokens: usage.completion_tokens_details?.reasoning_tokens ?? undefined, - cacheReadTokens: usage.prompt_tokens_details?.cached_tokens ?? undefined, - }), - }) -} diff --git a/packages/cloud/app/src/routes/zen/v1/messages.ts b/packages/cloud/app/src/routes/zen/v1/messages.ts deleted file mode 100644 index 1fd85d5c7..000000000 --- a/packages/cloud/app/src/routes/zen/v1/messages.ts +++ /dev/null @@ -1,61 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" -import { handler } from "~/routes/zen/handler" - -type Usage = { - cache_creation?: { - ephemeral_5m_input_tokens?: number - ephemeral_1h_input_tokens?: number - } - cache_creation_input_tokens?: number - cache_read_input_tokens?: number - input_tokens?: number - output_tokens?: number - server_tool_use?: { - web_search_requests?: number - } -} - -export function POST(input: APIEvent) { - let usage: Usage - return handler(input, { - modifyBody: (body: any) => ({ - ...body, - service_tier: "standard_only", - }), - setAuthHeader: (headers: Headers, apiKey: string) => headers.set("x-api-key", apiKey), - parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined, - onStreamPart: (chunk: string) => { - const data = chunk.split("\n")[1] - if (!data.startsWith("data: ")) return - - let json - try { - json = JSON.parse(data.slice(6)) as { usage?: Usage } - } catch (e) { - return - } - - if (!json.usage) return - usage = { - ...usage, - ...json.usage, - cache_creation: { - ...usage?.cache_creation, - ...json.usage.cache_creation, - }, - server_tool_use: { - ...usage?.server_tool_use, - ...json.usage.server_tool_use, - }, - } - }, - getStreamUsage: () => usage, - normalizeUsage: (usage: Usage) => ({ - inputTokens: usage.input_tokens ?? 0, - outputTokens: usage.output_tokens ?? 0, - cacheReadTokens: usage.cache_read_input_tokens ?? undefined, - cacheWrite5mTokens: usage.cache_creation?.ephemeral_5m_input_tokens ?? undefined, - cacheWrite1hTokens: usage.cache_creation?.ephemeral_1h_input_tokens ?? undefined, - }), - }) -} diff --git a/packages/cloud/app/src/routes/zen/v1/responses.ts b/packages/cloud/app/src/routes/zen/v1/responses.ts deleted file mode 100644 index 486c129b9..000000000 --- a/packages/cloud/app/src/routes/zen/v1/responses.ts +++ /dev/null @@ -1,52 +0,0 @@ -import type { APIEvent } from "@solidjs/start/server" -import { handler } from "~/routes/zen/handler" - -type Usage = { - input_tokens?: number - input_tokens_details?: { - cached_tokens?: number - } - output_tokens?: number - output_tokens_details?: { - reasoning_tokens?: number - } - total_tokens?: number -} - -export function POST(input: APIEvent) { - let usage: Usage - return handler(input, { - setAuthHeader: (headers: Headers, apiKey: string) => { - headers.set("authorization", `Bearer ${apiKey}`) - }, - parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1], - onStreamPart: (chunk: string) => { - const [event, data] = chunk.split("\n") - if (event !== "event: response.completed") return - if (!data.startsWith("data: ")) return - - let json - try { - json = JSON.parse(data.slice(6)) as { response?: { usage?: Usage } } - } catch (e) { - return - } - - if (!json.response?.usage) return - usage = json.response.usage - }, - getStreamUsage: () => usage, - normalizeUsage: (usage: Usage) => { - const inputTokens = usage.input_tokens ?? 0 - const outputTokens = usage.output_tokens ?? 0 - const reasoningTokens = usage.output_tokens_details?.reasoning_tokens ?? undefined - const cacheReadTokens = usage.input_tokens_details?.cached_tokens ?? undefined - return { - inputTokens: inputTokens - (cacheReadTokens ?? 0), - outputTokens: outputTokens - (reasoningTokens ?? 0), - reasoningTokens, - cacheReadTokens, - } - }, - }) -} diff --git a/packages/cloud/app/src/style/base.css b/packages/cloud/app/src/style/base.css deleted file mode 100644 index a4847ed43..000000000 --- a/packages/cloud/app/src/style/base.css +++ /dev/null @@ -1,9 +0,0 @@ -html { - line-height: 1; - background-color: var(--color-bg); - color: var(--color-text); -} - -body { - font-family: var(--font-sans); -} diff --git a/packages/cloud/app/src/style/component/button.css b/packages/cloud/app/src/style/component/button.css deleted file mode 100644 index d10f7af53..000000000 --- a/packages/cloud/app/src/style/component/button.css +++ /dev/null @@ -1,102 +0,0 @@ -[data-component="button"] { - display: inline-flex; - align-items: center; - justify-content: center; - gap: var(--space-2); - padding: var(--space-3) var(--space-4); - border: 1px solid transparent; - border-radius: var(--space-2); - font-family: var(--font-sans); - font-size: var(--font-size-md); - font-weight: 500; - line-height: 1.25; - cursor: pointer; - transition: all 0.2s ease-in-out; - text-decoration: none; - user-select: none; - - &:disabled { - opacity: 0.5; - cursor: not-allowed; - } - - &:focus { - outline: none; - box-shadow: 0 0 0 2px var(--color-primary); - } - - &[data-color="primary"] { - background-color: var(--color-primary); - color: var(--color-primary-text); - border-color: var(--color-primary); - - &:hover:not(:disabled) { - background-color: var(--color-primary-hover); - border-color: var(--color-primary-hover); - } - - &:active:not(:disabled) { - background-color: var(--color-primary-active); - border-color: var(--color-primary-active); - } - } - - &[data-color="danger"] { - background-color: var(--color-danger); - color: var(--color-danger-text); - border-color: var(--color-danger); - - &:hover:not(:disabled) { - background-color: var(--color-danger-hover); - border-color: var(--color-danger-hover); - } - - &:active:not(:disabled) { - background-color: var(--color-danger-active); - border-color: var(--color-danger-active); - } - - &:focus { - box-shadow: 0 0 0 2px var(--color-danger); - } - } - - &[data-color="warning"] { - background-color: var(--color-warning); - color: var(--color-warning-text); - border-color: var(--color-warning); - - &:hover:not(:disabled) { - background-color: var(--color-warning-hover); - border-color: var(--color-warning-hover); - } - - &:active:not(:disabled) { - background-color: var(--color-warning-active); - border-color: var(--color-warning-active); - } - - &:focus { - box-shadow: 0 0 0 2px var(--color-warning); - } - } - - &[data-size="small"] { - padding: var(--space-2) var(--space-3); - font-size: var(--font-size-sm); - gap: var(--space-1-5); - } - - &[data-size="large"] { - padding: var(--space-4) var(--space-6); - font-size: var(--font-size-lg); - gap: var(--space-3); - } - - [data-slot="icon"] { - display: flex; - align-items: center; - width: 1em; - height: 1em; - } -} diff --git a/packages/cloud/app/src/style/index.css b/packages/cloud/app/src/style/index.css deleted file mode 100644 index 832a901e8..000000000 --- a/packages/cloud/app/src/style/index.css +++ /dev/null @@ -1,8 +0,0 @@ -@import "./token/color.css"; -@import "./token/font.css"; -@import "./token/space.css"; - -@import "./component/button.css"; - -@import "./reset.css"; -@import "./base.css"; diff --git a/packages/cloud/app/src/style/reset.css b/packages/cloud/app/src/style/reset.css deleted file mode 100644 index d331ed724..000000000 --- a/packages/cloud/app/src/style/reset.css +++ /dev/null @@ -1,76 +0,0 @@ -/* 1. Use a more-intuitive box-sizing model */ -*, -*::before, -*::after { - box-sizing: border-box; -} - -/* 2. Remove default margin */ -* { - margin: 0; -} - -/* 3. Enable keyword animations */ -@media (prefers-reduced-motion: no-preference) { - html { - interpolate-size: allow-keywords; - } -} - -body { - /* 4. Add accessible line-height */ - line-height: 1.5; - /* 5. Improve text rendering */ - -webkit-font-smoothing: antialiased; -} - -/* 6. Improve media defaults */ -img, -picture, -video, -canvas, -svg { - display: block; - max-width: 100%; -} - -/* 7. Inherit fonts for form controls */ -input, -button, -textarea, -select { - font: inherit; -} - -/* 8. Avoid text overflows */ -p, -h1, -h2, -h3, -h4, -h5, -h6 { - overflow-wrap: break-word; -} - -/* 9. Improve line wrapping */ -p { - text-wrap: pretty; -} - -h1, -h2, -h3, -h4, -h5, -h6 { - text-wrap: balance; -} - -/* - 10. Create a root stacking context -*/ -#root, -#__next { - isolation: isolate; -} diff --git a/packages/cloud/app/src/style/token/color.css b/packages/cloud/app/src/style/token/color.css deleted file mode 100644 index f1a097d2f..000000000 --- a/packages/cloud/app/src/style/token/color.css +++ /dev/null @@ -1,91 +0,0 @@ -:root { - --color-white: #ffffff; - --color-black: #000000; - - /* Default light theme colors */ - --color-bg: #ffffff; - --color-bg-surface: #f5f5f7; - --color-bg-elevated: #ffffff; - - --color-text: #1d1d1f; - --color-text-secondary: #424245; - --color-text-muted: #6e6e73; - --color-text-disabled: #86868b; - - --color-accent: #007aff; - --color-accent-hover: #0056b3; - --color-accent-active: #004085; - - --color-success: #30d158; - --color-warning: #ff9f0a; - --color-danger: #ff3b30; - - --color-border: #d2d2d7; - --color-border-muted: #e5e5ea; - - /* Button colors */ - --color-primary: var(--color-accent); - --color-primary-hover: var(--color-accent-hover); - --color-primary-active: var(--color-accent-active); - --color-primary-text: #ffffff; - - --color-danger: #ff3b30; - --color-danger-hover: #d70015; - --color-danger-active: #a50011; - --color-danger-text: #ffffff; - - --color-warning: #ff9f0a; - --color-warning-hover: #cc7f08; - --color-warning-active: #995f06; - --color-warning-text: #000000; - - /* Surface colors */ - --color-surface: var(--color-bg-surface); - --color-surface-hover: var(--color-bg-elevated); - --color-surface-border: var(--color-border); -} - -@media (prefers-color-scheme: dark) { - :root { - --color-bg: #0c0c0e; - --color-bg-surface: #161618; - --color-bg-elevated: #1c1c1f; - - --color-text: #ffffff; - --color-text-secondary: #c7c7cc; - --color-text-muted: #a1a1a6; - --color-text-disabled: #68686f; - - --color-accent: #007aff; - --color-accent-hover: #0056b3; - --color-accent-active: #004085; - - --color-success: #30d158; - --color-warning: #ff9f0a; - --color-danger: #ff453a; - - --color-border: #38383a; - --color-border-muted: #2c2c2e; - - /* Button colors */ - --color-primary: var(--color-accent); - --color-primary-hover: var(--color-accent-hover); - --color-primary-active: var(--color-accent-active); - --color-primary-text: #ffffff; - - --color-danger: #ff453a; - --color-danger-hover: #d70015; - --color-danger-active: #a50011; - --color-danger-text: #ffffff; - - --color-warning: #ff9f0a; - --color-warning-hover: #cc7f08; - --color-warning-active: #995f06; - --color-warning-text: #000000; - - /* Surface colors */ - --color-surface: var(--color-bg-surface); - --color-surface-hover: var(--color-bg-elevated); - --color-surface-border: var(--color-border); - } -} diff --git a/packages/cloud/app/src/style/token/font.css b/packages/cloud/app/src/style/token/font.css deleted file mode 100644 index 67143e662..000000000 --- a/packages/cloud/app/src/style/token/font.css +++ /dev/null @@ -1,20 +0,0 @@ -body { - --font-size-2xs: 0.6875rem; - --font-size-xs: 0.75rem; - --font-size-sm: 0.8125rem; - --font-size-md: 0.9375rem; - --font-size-lg: 1.125rem; - --font-size-xl: 1.25rem; - --font-size-2xl: 1.5rem; - --font-size-3xl: 1.875rem; - --font-size-4xl: 2.25rem; - --font-size-5xl: 3rem; - --font-size-6xl: 3.75rem; - --font-size-7xl: 4.5rem; - --font-size-8xl: 6rem; - --font-size-9xl: 8rem; - - --font-mono: - "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; - --font-sans: var(--font-mono); -} diff --git a/packages/cloud/app/src/style/token/space.css b/packages/cloud/app/src/style/token/space.css deleted file mode 100644 index 7e1a1b397..000000000 --- a/packages/cloud/app/src/style/token/space.css +++ /dev/null @@ -1,46 +0,0 @@ -body { - --space-0: 0; - --space-px: 1px; - --space-0-5: 0.125rem; - --space-0-75: 0.1875rem; - --space-1: 0.25rem; - --space-1-5: 0.375rem; - --space-2: 0.5rem; - --space-2-5: 0.625rem; - --space-3: 0.75rem; - --space-3-5: 0.875rem; - --space-4: 1rem; - --space-4-5: 1.125rem; - --space-5: 1.25rem; - --space-6: 1.5rem; - --space-7: 1.75rem; - --space-8: 2rem; - --space-9: 2.25rem; - --space-10: 2.5rem; - --space-11: 2.75rem; - --space-12: 3rem; - --space-14: 3.5rem; - --space-16: 4rem; - --space-17: 4.25rem; - --space-18: 4.5rem; - --space-19: 4.75rem; - --space-20: 5rem; - --space-24: 6rem; - --space-28: 7rem; - --space-32: 8rem; - --space-36: 9rem; - --space-40: 10rem; - --space-44: 11rem; - --space-48: 12rem; - --space-52: 13rem; - --space-56: 14rem; - --space-60: 15rem; - --space-64: 16rem; - --space-72: 18rem; - --space-80: 20rem; - --space-96: 24rem; - - --border-radius-sm: 0.1875rem; - --border-radius-md: 0.3125rem; - --border-radius-lg: 0.5rem; -} diff --git a/packages/cloud/app/sst-env.d.ts b/packages/cloud/app/sst-env.d.ts deleted file mode 100644 index bd5588217..000000000 --- a/packages/cloud/app/sst-env.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* This file is auto-generated by SST. Do not edit. */ -/* tslint:disable */ -/* eslint-disable */ -/* deno-fmt-ignore-file */ - -/// - -import "sst" -export {} diff --git a/packages/cloud/app/tsconfig.json b/packages/cloud/app/tsconfig.json deleted file mode 100644 index 07148a458..000000000 --- a/packages/cloud/app/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "skipLibCheck": true, - "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/packages/cloud/core/drizzle.config.ts b/packages/cloud/core/drizzle.config.ts deleted file mode 100644 index 0b7c4417e..000000000 --- a/packages/cloud/core/drizzle.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Resource } from "sst" -import { defineConfig } from "drizzle-kit" - -export default defineConfig({ - out: "./migrations/", - strict: true, - schema: ["./src/**/*.sql.ts"], - verbose: true, - dialect: "mysql", - dbCredentials: { - database: Resource.Database.database, - host: Resource.Database.host, - user: Resource.Database.username, - password: Resource.Database.password, - port: Resource.Database.port, - ssl: { - rejectUnauthorized: false, - }, - }, -}) diff --git a/packages/cloud/core/migrations/0000_fluffy_raza.sql b/packages/cloud/core/migrations/0000_fluffy_raza.sql deleted file mode 100644 index 8e8173346..000000000 --- a/packages/cloud/core/migrations/0000_fluffy_raza.sql +++ /dev/null @@ -1,89 +0,0 @@ -CREATE TABLE `account` ( - `id` varchar(30) NOT NULL, - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - `email` varchar(255) NOT NULL, - CONSTRAINT `email` UNIQUE(`email`) -); ---> statement-breakpoint -CREATE TABLE `billing` ( - `id` varchar(30) NOT NULL, - `workspace_id` varchar(30) NOT NULL, - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - `customer_id` varchar(255), - `payment_method_id` varchar(255), - `payment_method_last4` varchar(4), - `balance` bigint NOT NULL, - `reload` boolean, - CONSTRAINT `billing_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`) -); ---> statement-breakpoint -CREATE TABLE `payment` ( - `id` varchar(30) NOT NULL, - `workspace_id` varchar(30) NOT NULL, - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - `customer_id` varchar(255), - `payment_id` varchar(255), - `amount` bigint NOT NULL, - CONSTRAINT `payment_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`) -); ---> statement-breakpoint -CREATE TABLE `usage` ( - `id` varchar(30) NOT NULL, - `workspace_id` varchar(30) NOT NULL, - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - `model` varchar(255) NOT NULL, - `input_tokens` int NOT NULL, - `output_tokens` int NOT NULL, - `reasoning_tokens` int, - `cache_read_tokens` int, - `cache_write_tokens` int, - `cost` bigint NOT NULL, - CONSTRAINT `usage_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`) -); ---> statement-breakpoint -CREATE TABLE `key` ( - `id` varchar(30) NOT NULL, - `workspace_id` varchar(30) NOT NULL, - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - `user_id` text NOT NULL, - `name` varchar(255) NOT NULL, - `key` varchar(255) NOT NULL, - `time_used` timestamp(3), - CONSTRAINT `key_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`), - CONSTRAINT `global_key` UNIQUE(`key`) -); ---> statement-breakpoint -CREATE TABLE `user` ( - `id` varchar(30) NOT NULL, - `workspace_id` varchar(30) NOT NULL, - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - `email` varchar(255) NOT NULL, - `name` varchar(255) NOT NULL, - `time_seen` timestamp(3), - `color` int, - CONSTRAINT `user_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`), - CONSTRAINT `user_email` UNIQUE(`workspace_id`,`email`) -); ---> statement-breakpoint -CREATE TABLE `workspace` ( - `id` varchar(30) NOT NULL, - `slug` varchar(255), - `name` varchar(255), - `time_created` timestamp(3) NOT NULL DEFAULT (now()), - `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - `time_deleted` timestamp(3), - CONSTRAINT `workspace_id` PRIMARY KEY(`id`), - CONSTRAINT `slug` UNIQUE(`slug`) -); diff --git a/packages/cloud/core/migrations/0001_serious_whistler.sql b/packages/cloud/core/migrations/0001_serious_whistler.sql deleted file mode 100644 index 4a9a03d63..000000000 --- a/packages/cloud/core/migrations/0001_serious_whistler.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `key` ADD `actor` json;--> statement-breakpoint -ALTER TABLE `key` DROP COLUMN `user_id`; \ No newline at end of file diff --git a/packages/cloud/core/migrations/0002_violet_loners.sql b/packages/cloud/core/migrations/0002_violet_loners.sql deleted file mode 100644 index 17273356c..000000000 --- a/packages/cloud/core/migrations/0002_violet_loners.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `key` ADD `old_name` varchar(255); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0003_dusty_clint_barton.sql b/packages/cloud/core/migrations/0003_dusty_clint_barton.sql deleted file mode 100644 index 14efae216..000000000 --- a/packages/cloud/core/migrations/0003_dusty_clint_barton.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `key` ADD CONSTRAINT `name` UNIQUE(`workspace_id`,`name`); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0004_first_mockingbird.sql b/packages/cloud/core/migrations/0004_first_mockingbird.sql deleted file mode 100644 index 2a6b11067..000000000 --- a/packages/cloud/core/migrations/0004_first_mockingbird.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `usage` ADD `provider` varchar(255); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0005_jazzy_skrulls.sql b/packages/cloud/core/migrations/0005_jazzy_skrulls.sql deleted file mode 100644 index 774c38dd8..000000000 --- a/packages/cloud/core/migrations/0005_jazzy_skrulls.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `usage` MODIFY COLUMN `provider` varchar(255) NOT NULL; \ No newline at end of file diff --git a/packages/cloud/core/migrations/0006_parallel_gauntlet.sql b/packages/cloud/core/migrations/0006_parallel_gauntlet.sql deleted file mode 100644 index a1ff78e78..000000000 --- a/packages/cloud/core/migrations/0006_parallel_gauntlet.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `usage` ADD `cache_write_5m_tokens` int;--> statement-breakpoint -ALTER TABLE `usage` ADD `cache_write_1h_tokens` int; \ No newline at end of file diff --git a/packages/cloud/core/migrations/0007_familiar_nightshade.sql b/packages/cloud/core/migrations/0007_familiar_nightshade.sql deleted file mode 100644 index 89cf77f92..000000000 --- a/packages/cloud/core/migrations/0007_familiar_nightshade.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `usage` DROP COLUMN `cache_write_tokens`; \ No newline at end of file diff --git a/packages/cloud/core/migrations/0008_eminent_ultimatum.sql b/packages/cloud/core/migrations/0008_eminent_ultimatum.sql deleted file mode 100644 index 93e40a7fe..000000000 --- a/packages/cloud/core/migrations/0008_eminent_ultimatum.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `billing` ADD `time_reload_locked_till` timestamp(3); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0009_redundant_piledriver.sql b/packages/cloud/core/migrations/0009_redundant_piledriver.sql deleted file mode 100644 index 4ba1b2d4a..000000000 --- a/packages/cloud/core/migrations/0009_redundant_piledriver.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `payment` ADD `error` varchar(255); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0010_needy_sue_storm.sql b/packages/cloud/core/migrations/0010_needy_sue_storm.sql deleted file mode 100644 index ffd46c9fc..000000000 --- a/packages/cloud/core/migrations/0010_needy_sue_storm.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `billing` ADD CONSTRAINT `global_customer_id` UNIQUE(`customer_id`); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0011_freezing_phil_sheldon.sql b/packages/cloud/core/migrations/0011_freezing_phil_sheldon.sql deleted file mode 100644 index 095f25993..000000000 --- a/packages/cloud/core/migrations/0011_freezing_phil_sheldon.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `billing` ADD `last_error` varchar(255);--> statement-breakpoint -ALTER TABLE `billing` ADD `time_last_error` timestamp(3);--> statement-breakpoint -ALTER TABLE `payment` DROP COLUMN `error`; \ No newline at end of file diff --git a/packages/cloud/core/migrations/0012_bright_photon.sql b/packages/cloud/core/migrations/0012_bright_photon.sql deleted file mode 100644 index 8ad777bcf..000000000 --- a/packages/cloud/core/migrations/0012_bright_photon.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `billing` ADD `monthly_limit` int;--> statement-breakpoint -ALTER TABLE `billing` ADD `monthly_usage` bigint;--> statement-breakpoint -ALTER TABLE `billing` ADD `time_monthly_usage_updated` timestamp(3); \ No newline at end of file diff --git a/packages/cloud/core/migrations/0013_absurd_hobgoblin.sql b/packages/cloud/core/migrations/0013_absurd_hobgoblin.sql deleted file mode 100644 index 8c331b12f..000000000 --- a/packages/cloud/core/migrations/0013_absurd_hobgoblin.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `billing` RENAME COLUMN `last_error` TO `reload_error`;--> statement-breakpoint -ALTER TABLE `billing` RENAME COLUMN `time_last_error` TO `time_reload_error`; \ No newline at end of file diff --git a/packages/cloud/core/migrations/meta/0000_snapshot.json b/packages/cloud/core/migrations/meta/0000_snapshot.json deleted file mode 100644 index 17d3bd7f9..000000000 --- a/packages/cloud/core/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,569 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "aee779c5-db1d-4655-95ec-6451c18455be", - "prevId": "00000000-0000-0000-0000-000000000000", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0001_snapshot.json b/packages/cloud/core/migrations/meta/0001_snapshot.json deleted file mode 100644 index d23d1601d..000000000 --- a/packages/cloud/core/migrations/meta/0001_snapshot.json +++ /dev/null @@ -1,569 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "79b7ee25-1c1c-41ff-9bbf-754af257102b", - "prevId": "aee779c5-db1d-4655-95ec-6451c18455be", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0002_snapshot.json b/packages/cloud/core/migrations/meta/0002_snapshot.json deleted file mode 100644 index 45d06926c..000000000 --- a/packages/cloud/core/migrations/meta/0002_snapshot.json +++ /dev/null @@ -1,576 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "9f51ef52-31ac-4ace-8b6d-39b35efe9c81", - "prevId": "79b7ee25-1c1c-41ff-9bbf-754af257102b", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0003_snapshot.json b/packages/cloud/core/migrations/meta/0003_snapshot.json deleted file mode 100644 index e832ebb00..000000000 --- a/packages/cloud/core/migrations/meta/0003_snapshot.json +++ /dev/null @@ -1,581 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "26cebd59-f553-441c-a2b2-2f9578a0ad2b", - "prevId": "9f51ef52-31ac-4ace-8b6d-39b35efe9c81", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0004_snapshot.json b/packages/cloud/core/migrations/meta/0004_snapshot.json deleted file mode 100644 index 6d2695c48..000000000 --- a/packages/cloud/core/migrations/meta/0004_snapshot.json +++ /dev/null @@ -1,588 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "06dc6226-bfbb-4ccc-b4bc-f26070c3bed5", - "prevId": "26cebd59-f553-441c-a2b2-2f9578a0ad2b", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0005_snapshot.json b/packages/cloud/core/migrations/meta/0005_snapshot.json deleted file mode 100644 index 12246a6d6..000000000 --- a/packages/cloud/core/migrations/meta/0005_snapshot.json +++ /dev/null @@ -1,588 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "d13af80e-3c70-4866-8f14-48e7ff6ff0ff", - "prevId": "06dc6226-bfbb-4ccc-b4bc-f26070c3bed5", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0006_snapshot.json b/packages/cloud/core/migrations/meta/0006_snapshot.json deleted file mode 100644 index d726b6f67..000000000 --- a/packages/cloud/core/migrations/meta/0006_snapshot.json +++ /dev/null @@ -1,602 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "b0ad4b11-b607-46c7-8e2d-3b9823cdc5f7", - "prevId": "d13af80e-3c70-4866-8f14-48e7ff6ff0ff", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_tokens": { - "name": "cache_write_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0007_snapshot.json b/packages/cloud/core/migrations/meta/0007_snapshot.json deleted file mode 100644 index 122db42cb..000000000 --- a/packages/cloud/core/migrations/meta/0007_snapshot.json +++ /dev/null @@ -1,595 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "91067cc9-d492-47b3-932a-42dcc0920b3c", - "prevId": "b0ad4b11-b607-46c7-8e2d-3b9823cdc5f7", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0008_snapshot.json b/packages/cloud/core/migrations/meta/0008_snapshot.json deleted file mode 100644 index 02c473200..000000000 --- a/packages/cloud/core/migrations/meta/0008_snapshot.json +++ /dev/null @@ -1,602 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "3e080fc0-9efd-411f-b764-ed3aa4abcee5", - "prevId": "91067cc9-d492-47b3-932a-42dcc0920b3c", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_locked_till": { - "name": "time_reload_locked_till", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0009_snapshot.json b/packages/cloud/core/migrations/meta/0009_snapshot.json deleted file mode 100644 index a3bd57cae..000000000 --- a/packages/cloud/core/migrations/meta/0009_snapshot.json +++ /dev/null @@ -1,609 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "b0019e1e-d365-4f67-be3d-a2e69bdddc04", - "prevId": "3e080fc0-9efd-411f-b764-ed3aa4abcee5", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_locked_till": { - "name": "time_reload_locked_till", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0010_snapshot.json b/packages/cloud/core/migrations/meta/0010_snapshot.json deleted file mode 100644 index cb55610ae..000000000 --- a/packages/cloud/core/migrations/meta/0010_snapshot.json +++ /dev/null @@ -1,615 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "1f08bd5a-436d-4905-a585-87b156847402", - "prevId": "b0019e1e-d365-4f67-be3d-a2e69bdddc04", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_locked_till": { - "name": "time_reload_locked_till", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_customer_id": { - "name": "global_customer_id", - "columns": ["customer_id"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "error": { - "name": "error", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0011_snapshot.json b/packages/cloud/core/migrations/meta/0011_snapshot.json deleted file mode 100644 index 7eb6fa71a..000000000 --- a/packages/cloud/core/migrations/meta/0011_snapshot.json +++ /dev/null @@ -1,622 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "cd9c94c4-9167-4346-b716-1bd0cff10ffc", - "prevId": "1f08bd5a-436d-4905-a585-87b156847402", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_locked_till": { - "name": "time_reload_locked_till", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "last_error": { - "name": "last_error", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_last_error": { - "name": "time_last_error", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_customer_id": { - "name": "global_customer_id", - "columns": ["customer_id"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0012_snapshot.json b/packages/cloud/core/migrations/meta/0012_snapshot.json deleted file mode 100644 index 4220c988b..000000000 --- a/packages/cloud/core/migrations/meta/0012_snapshot.json +++ /dev/null @@ -1,643 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "ba801b30-747a-433e-ab43-b407c961a24c", - "prevId": "cd9c94c4-9167-4346-b716-1bd0cff10ffc", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "monthly_limit": { - "name": "monthly_limit", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "monthly_usage": { - "name": "monthly_usage", - "type": "bigint", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_monthly_usage_updated": { - "name": "time_monthly_usage_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_locked_till": { - "name": "time_reload_locked_till", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "last_error": { - "name": "last_error", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_last_error": { - "name": "time_last_error", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_customer_id": { - "name": "global_customer_id", - "columns": ["customer_id"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/0013_snapshot.json b/packages/cloud/core/migrations/meta/0013_snapshot.json deleted file mode 100644 index ef805ee83..000000000 --- a/packages/cloud/core/migrations/meta/0013_snapshot.json +++ /dev/null @@ -1,646 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "28336c91-553c-4d1d-9875-1ee761e47582", - "prevId": "ba801b30-747a-433e-ab43-b407c961a24c", - "tables": { - "account": { - "name": "account", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "email": { - "name": "email", - "columns": ["email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "billing": { - "name": "billing", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_id": { - "name": "payment_method_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_method_last4": { - "name": "payment_method_last4", - "type": "varchar(4)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "balance": { - "name": "balance", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "monthly_limit": { - "name": "monthly_limit", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "monthly_usage": { - "name": "monthly_usage", - "type": "bigint", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_monthly_usage_updated": { - "name": "time_monthly_usage_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "reload": { - "name": "reload", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "reload_error": { - "name": "reload_error", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_error": { - "name": "time_reload_error", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_reload_locked_till": { - "name": "time_reload_locked_till", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_customer_id": { - "name": "global_customer_id", - "columns": ["customer_id"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "billing_workspace_id_id_pk": { - "name": "billing_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "payment": { - "name": "payment", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "customer_id": { - "name": "customer_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "payment_id": { - "name": "payment_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "amount": { - "name": "amount", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "payment_workspace_id_id_pk": { - "name": "payment_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "usage": { - "name": "usage", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "provider": { - "name": "provider", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "reasoning_tokens": { - "name": "reasoning_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_read_tokens": { - "name": "cache_read_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_5m_tokens": { - "name": "cache_write_5m_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cache_write_1h_tokens": { - "name": "cache_write_1h_tokens", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "cost": { - "name": "cost", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "usage_workspace_id_id_pk": { - "name": "usage_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "key": { - "name": "key", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "actor": { - "name": "actor", - "type": "json", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "old_name": { - "name": "old_name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "key": { - "name": "key", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_used": { - "name": "time_used", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "global_key": { - "name": "global_key", - "columns": ["key"], - "isUnique": true - }, - "name": { - "name": "name", - "columns": ["workspace_id", "name"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "key_workspace_id_id_pk": { - "name": "key_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "user": { - "name": "user", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "time_seen": { - "name": "time_seen", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "color": { - "name": "color", - "type": "int", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "user_email": { - "name": "user_email", - "columns": ["workspace_id", "email"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "user_workspace_id_id_pk": { - "name": "user_workspace_id_id_pk", - "columns": ["workspace_id", "id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - }, - "workspace": { - "name": "workspace", - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "slug": { - "name": "slug", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "time_created": { - "name": "time_created", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "(now())" - }, - "time_updated": { - "name": "time_updated", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" - }, - "time_deleted": { - "name": "time_deleted", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "slug": { - "name": "slug", - "columns": ["slug"], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "workspace_id": { - "name": "workspace_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {}, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": { - "\"billing\".\"last_error\"": "\"billing\".\"reload_error\"", - "\"billing\".\"time_last_error\"": "\"billing\".\"time_reload_error\"" - } - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/packages/cloud/core/migrations/meta/_journal.json b/packages/cloud/core/migrations/meta/_journal.json deleted file mode 100644 index 1b7d45da3..000000000 --- a/packages/cloud/core/migrations/meta/_journal.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "version": "7", - "dialect": "mysql", - "entries": [ - { - "idx": 0, - "version": "5", - "when": 1756796050935, - "tag": "0000_fluffy_raza", - "breakpoints": true - }, - { - "idx": 1, - "version": "5", - "when": 1756871639102, - "tag": "0001_serious_whistler", - "breakpoints": true - }, - { - "idx": 2, - "version": "5", - "when": 1757597611832, - "tag": "0002_violet_loners", - "breakpoints": true - }, - { - "idx": 3, - "version": "5", - "when": 1757600397194, - "tag": "0003_dusty_clint_barton", - "breakpoints": true - }, - { - "idx": 4, - "version": "5", - "when": 1757627357232, - "tag": "0004_first_mockingbird", - "breakpoints": true - }, - { - "idx": 5, - "version": "5", - "when": 1757632304856, - "tag": "0005_jazzy_skrulls", - "breakpoints": true - }, - { - "idx": 6, - "version": "5", - "when": 1757643108507, - "tag": "0006_parallel_gauntlet", - "breakpoints": true - }, - { - "idx": 7, - "version": "5", - "when": 1757693869142, - "tag": "0007_familiar_nightshade", - "breakpoints": true - }, - { - "idx": 8, - "version": "5", - "when": 1757885904718, - "tag": "0008_eminent_ultimatum", - "breakpoints": true - }, - { - "idx": 9, - "version": "5", - "when": 1757888582598, - "tag": "0009_redundant_piledriver", - "breakpoints": true - }, - { - "idx": 10, - "version": "5", - "when": 1757892305788, - "tag": "0010_needy_sue_storm", - "breakpoints": true - }, - { - "idx": 11, - "version": "5", - "when": 1757948881012, - "tag": "0011_freezing_phil_sheldon", - "breakpoints": true - }, - { - "idx": 12, - "version": "5", - "when": 1757956814524, - "tag": "0012_bright_photon", - "breakpoints": true - }, - { - "idx": 13, - "version": "5", - "when": 1757956978089, - "tag": "0013_absurd_hobgoblin", - "breakpoints": true - } - ] -} diff --git a/packages/cloud/core/package.json b/packages/cloud/core/package.json deleted file mode 100644 index e9e7fc701..000000000 --- a/packages/cloud/core/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/package.json", - "name": "@opencode/cloud-core", - "version": "0.9.11", - "private": true, - "type": "module", - "dependencies": { - "@aws-sdk/client-sts": "3.782.0", - "@opencode/cloud-resource": "workspace:*", - "@planetscale/database": "1.19.0", - "drizzle-orm": "0.41.0", - "postgres": "3.4.7", - "stripe": "18.0.0", - "ulid": "3.0.0" - }, - "exports": { - "./*": "./src/*" - }, - "scripts": { - "db": "sst shell drizzle-kit", - "db-dev": "sst shell --stage dev -- drizzle-kit", - "db-prod": "sst shell --stage production -- drizzle-kit", - "typecheck": "tsc --noEmit" - }, - "devDependencies": { - "drizzle-kit": "0.30.5", - "mysql2": "3.14.4" - } -} diff --git a/packages/cloud/core/src/account.ts b/packages/cloud/core/src/account.ts deleted file mode 100644 index cb123e048..000000000 --- a/packages/cloud/core/src/account.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { z } from "zod" -import { and, eq, getTableColumns, isNull } from "drizzle-orm" -import { fn } from "./util/fn" -import { Database } from "./drizzle" -import { Identifier } from "./identifier" -import { AccountTable } from "./schema/account.sql" -import { Actor } from "./actor" -import { WorkspaceTable } from "./schema/workspace.sql" -import { UserTable } from "./schema/user.sql" - -export namespace Account { - export const create = fn( - z.object({ - email: z.string().email(), - id: z.string().optional(), - }), - async (input) => - Database.transaction(async (tx) => { - const id = input.id ?? Identifier.create("account") - await tx.insert(AccountTable).values({ - id, - email: input.email, - }) - return id - }), - ) - - export const fromID = fn(z.string(), async (id) => - Database.transaction(async (tx) => { - return tx - .select() - .from(AccountTable) - .where(eq(AccountTable.id, id)) - .execute() - .then((rows) => rows[0]) - }), - ) - - export const fromEmail = fn(z.string().email(), async (email) => - Database.transaction(async (tx) => { - return tx - .select() - .from(AccountTable) - .where(eq(AccountTable.email, email)) - .execute() - .then((rows) => rows[0]) - }), - ) - - export const workspaces = async () => { - const actor = Actor.assert("account") - return Database.transaction(async (tx) => - tx - .select(getTableColumns(WorkspaceTable)) - .from(WorkspaceTable) - .innerJoin(UserTable, eq(UserTable.workspaceID, WorkspaceTable.id)) - .where( - and( - eq(UserTable.email, actor.properties.email), - isNull(UserTable.timeDeleted), - isNull(WorkspaceTable.timeDeleted), - ), - ) - .execute(), - ) - } -} diff --git a/packages/cloud/core/src/actor.ts b/packages/cloud/core/src/actor.ts deleted file mode 100644 index 0d13f7216..000000000 --- a/packages/cloud/core/src/actor.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { Context } from "./context" -import { Log } from "./util/log" - -export namespace Actor { - interface Account { - type: "account" - properties: { - accountID: string - email: string - } - } - - interface Public { - type: "public" - properties: {} - } - - interface User { - type: "user" - properties: { - userID: string - workspaceID: string - } - } - - interface System { - type: "system" - properties: { - workspaceID: string - } - } - - export type Info = Account | Public | User | System - - const ctx = Context.create() - export const use = ctx.use - - const log = Log.create().tag("namespace", "actor") - - export function provide( - type: T, - properties: Extract["properties"], - cb: () => R, - ) { - return ctx.provide( - { - type, - properties, - } as any, - () => { - return Log.provide({ ...properties }, () => { - log.info("provided") - return cb() - }) - }, - ) - } - - export function assert(type: T) { - const actor = use() - if (actor.type !== type) { - throw new Error(`Expected actor type ${type}, got ${actor.type}`) - } - return actor as Extract - } - - export function workspace() { - const actor = use() - if ("workspaceID" in actor.properties) { - return actor.properties.workspaceID - } - throw new Error(`actor of type "${actor.type}" is not associated with a workspace`) - } -} diff --git a/packages/cloud/core/src/billing.ts b/packages/cloud/core/src/billing.ts deleted file mode 100644 index 2254adc79..000000000 --- a/packages/cloud/core/src/billing.ts +++ /dev/null @@ -1,244 +0,0 @@ -import { Stripe } from "stripe" -import { Database, eq, sql } from "./drizzle" -import { BillingTable, PaymentTable, UsageTable } from "./schema/billing.sql" -import { Actor } from "./actor" -import { fn } from "./util/fn" -import { z } from "zod" -import { User } from "./user" -import { Resource } from "@opencode/cloud-resource" -import { Identifier } from "./identifier" -import { centsToMicroCents } from "./util/price" - -export namespace Billing { - export const CHARGE_AMOUNT = 2000 // $20 - export const CHARGE_FEE = 123 // Stripe fee 4.4% + $0.30 - export const CHARGE_THRESHOLD = 500 // $5 - export const stripe = () => - new Stripe(Resource.STRIPE_SECRET_KEY.value, { - apiVersion: "2025-03-31.basil", - }) - - export const get = async () => { - return Database.use(async (tx) => - tx - .select({ - customerID: BillingTable.customerID, - paymentMethodID: BillingTable.paymentMethodID, - paymentMethodLast4: BillingTable.paymentMethodLast4, - balance: BillingTable.balance, - reload: BillingTable.reload, - monthlyLimit: BillingTable.monthlyLimit, - monthlyUsage: BillingTable.monthlyUsage, - timeMonthlyUsageUpdated: BillingTable.timeMonthlyUsageUpdated, - reloadError: BillingTable.reloadError, - timeReloadError: BillingTable.timeReloadError, - }) - .from(BillingTable) - .where(eq(BillingTable.workspaceID, Actor.workspace())) - .then((r) => r[0]), - ) - } - - export const payments = async () => { - return await Database.use((tx) => - tx - .select() - .from(PaymentTable) - .where(eq(PaymentTable.workspaceID, Actor.workspace())) - .orderBy(sql`${PaymentTable.timeCreated} DESC`) - .limit(100), - ) - } - - export const usages = async () => { - return await Database.use((tx) => - tx - .select() - .from(UsageTable) - .where(eq(UsageTable.workspaceID, Actor.workspace())) - .orderBy(sql`${UsageTable.timeCreated} DESC`) - .limit(100), - ) - } - - export const reload = async () => { - const { customerID, paymentMethodID } = await Database.use((tx) => - tx - .select({ - customerID: BillingTable.customerID, - paymentMethodID: BillingTable.paymentMethodID, - }) - .from(BillingTable) - .where(eq(BillingTable.workspaceID, Actor.workspace())) - .then((rows) => rows[0]), - ) - const paymentID = Identifier.create("payment") - let charge - try { - charge = await Billing.stripe().paymentIntents.create( - { - amount: Billing.CHARGE_AMOUNT + Billing.CHARGE_FEE, - currency: "usd", - customer: customerID!, - payment_method: paymentMethodID!, - off_session: true, - confirm: true, - }, - { idempotencyKey: paymentID }, - ) - - if (charge.status !== "succeeded") throw new Error(charge.last_payment_error?.message) - } catch (e: any) { - await Database.use((tx) => - tx - .update(BillingTable) - .set({ - reloadError: e.message ?? "Payment failed.", - timeReloadError: sql`now()`, - }) - .where(eq(BillingTable.workspaceID, Actor.workspace())), - ) - return - } - - await Database.transaction(async (tx) => { - await tx - .update(BillingTable) - .set({ - balance: sql`${BillingTable.balance} + ${centsToMicroCents(CHARGE_AMOUNT)}`, - reloadError: null, - timeReloadError: null, - }) - .where(eq(BillingTable.workspaceID, Actor.workspace())) - await tx.insert(PaymentTable).values({ - workspaceID: Actor.workspace(), - id: paymentID, - amount: centsToMicroCents(CHARGE_AMOUNT), - paymentID: charge.id, - customerID, - }) - }) - } - - export const disableReload = async () => { - return await Database.use((tx) => - tx - .update(BillingTable) - .set({ - reload: false, - }) - .where(eq(BillingTable.workspaceID, Actor.workspace())), - ) - } - - export const setMonthlyLimit = fn(z.number(), async (input) => { - return await Database.use((tx) => - tx - .update(BillingTable) - .set({ - monthlyLimit: input, - }) - .where(eq(BillingTable.workspaceID, Actor.workspace())), - ) - }) - - export const generateCheckoutUrl = fn( - z.object({ - successUrl: z.string(), - cancelUrl: z.string(), - }), - async (input) => { - const account = Actor.assert("user") - const { successUrl, cancelUrl } = input - - const user = await User.fromID(account.properties.userID) - const customer = await Billing.get() - const session = await Billing.stripe().checkout.sessions.create({ - mode: "payment", - line_items: [ - { - price_data: { - currency: "usd", - product_data: { - name: "opencode credits", - }, - unit_amount: CHARGE_AMOUNT, - }, - quantity: 1, - }, - { - price_data: { - currency: "usd", - product_data: { - name: "processing fee", - }, - unit_amount: CHARGE_FEE, - }, - quantity: 1, - }, - ], - payment_intent_data: { - setup_future_usage: "on_session", - }, - ...(customer.customerID - ? { - customer: customer.customerID, - } - : { - customer_email: user.email, - customer_creation: "always", - }), - metadata: { - workspaceID: Actor.workspace(), - }, - currency: "usd", - payment_method_types: ["card"], - payment_method_data: { - allow_redisplay: "always", - }, - success_url: successUrl, - cancel_url: cancelUrl, - }) - - return session.url - }, - ) - - export const generateSessionUrl = fn( - z.object({ - returnUrl: z.string(), - }), - async (input) => { - const { returnUrl } = input - - const customer = await Billing.get() - if (!customer?.customerID) { - throw new Error("No stripe customer ID") - } - - const session = await Billing.stripe().billingPortal.sessions.create({ - customer: customer.customerID, - return_url: returnUrl, - }) - - return session.url - }, - ) - - export const generateReceiptUrl = fn( - z.object({ - paymentID: z.string(), - }), - async (input) => { - const { paymentID } = input - - const intent = await Billing.stripe().paymentIntents.retrieve(paymentID) - if (!intent.latest_charge) throw new Error("No charge found") - - const charge = await Billing.stripe().charges.retrieve(intent.latest_charge as string) - if (!charge.receipt_url) throw new Error("No receipt URL found") - - return charge.receipt_url - }, - ) -} diff --git a/packages/cloud/core/src/context.ts b/packages/cloud/core/src/context.ts deleted file mode 100644 index c2ca6a313..000000000 --- a/packages/cloud/core/src/context.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { AsyncLocalStorage } from "node:async_hooks" - -export namespace Context { - export class NotFound extends Error {} - - export function create() { - const storage = new AsyncLocalStorage() - return { - use() { - const result = storage.getStore() - if (!result) { - throw new NotFound() - } - return result - }, - provide(value: T, fn: () => R) { - return storage.run(value, fn) - }, - } - } -} diff --git a/packages/cloud/core/src/drizzle/index.ts b/packages/cloud/core/src/drizzle/index.ts deleted file mode 100644 index 806037996..000000000 --- a/packages/cloud/core/src/drizzle/index.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { drizzle } from "drizzle-orm/planetscale-serverless" -import { Resource } from "@opencode/cloud-resource" -export * from "drizzle-orm" -import { Client } from "@planetscale/database" - -import { MySqlTransaction, type MySqlTransactionConfig } from "drizzle-orm/mysql-core" -import type { ExtractTablesWithRelations } from "drizzle-orm" -import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "drizzle-orm/planetscale-serverless" -import { Context } from "../context" -import { memo } from "../util/memo" - -export namespace Database { - export type Transaction = MySqlTransaction< - PlanetscaleQueryResultHKT, - PlanetScalePreparedQueryHKT, - Record, - ExtractTablesWithRelations> - > - - const client = memo(() => { - const result = new Client({ - host: Resource.Database.host, - username: Resource.Database.username, - password: Resource.Database.password, - }) - const db = drizzle(result, {}) - return db - }) - - export type TxOrDb = Transaction | ReturnType - - const TransactionContext = Context.create<{ - tx: TxOrDb - effects: (() => void | Promise)[] - }>() - - export async function use(callback: (trx: TxOrDb) => Promise) { - try { - const { tx } = TransactionContext.use() - return tx.transaction(callback) - } catch (err) { - if (err instanceof Context.NotFound) { - const effects: (() => void | Promise)[] = [] - const result = await TransactionContext.provide( - { - effects, - tx: client(), - }, - () => callback(client()), - ) - await Promise.all(effects.map((x) => x())) - return result - } - throw err - } - } - export async function fn(callback: (input: Input, trx: TxOrDb) => Promise) { - return (input: Input) => use(async (tx) => callback(input, tx)) - } - - export async function effect(effect: () => any | Promise) { - try { - const { effects } = TransactionContext.use() - effects.push(effect) - } catch { - await effect() - } - } - - export async function transaction(callback: (tx: TxOrDb) => Promise, config?: MySqlTransactionConfig) { - try { - const { tx } = TransactionContext.use() - return callback(tx) - } catch (err) { - if (err instanceof Context.NotFound) { - const effects: (() => void | Promise)[] = [] - const result = await client().transaction(async (tx) => { - return TransactionContext.provide({ tx, effects }, () => callback(tx)) - }, config) - await Promise.all(effects.map((x) => x())) - return result - } - throw err - } - } -} diff --git a/packages/cloud/core/src/drizzle/types.ts b/packages/cloud/core/src/drizzle/types.ts deleted file mode 100644 index f16ad5a8a..000000000 --- a/packages/cloud/core/src/drizzle/types.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { sql } from "drizzle-orm" -import { bigint, timestamp, varchar } from "drizzle-orm/mysql-core" - -export const ulid = (name: string) => varchar(name, { length: 30 }) - -export const workspaceColumns = { - get id() { - return ulid("id").notNull() - }, - get workspaceID() { - return ulid("workspace_id").notNull() - }, -} - -export const id = () => ulid("id").notNull() - -export const utc = (name: string) => - timestamp(name, { - fsp: 3, - }) - -export const currency = (name: string) => - bigint(name, { - mode: "number", - }) - -export const timestamps = { - timeCreated: utc("time_created").notNull().defaultNow(), - timeUpdated: utc("time_updated") - .notNull() - .default(sql`CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)`), - timeDeleted: utc("time_deleted"), -} diff --git a/packages/cloud/core/src/identifier.ts b/packages/cloud/core/src/identifier.ts deleted file mode 100644 index f8e73852e..000000000 --- a/packages/cloud/core/src/identifier.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ulid } from "ulid" -import { z } from "zod" - -export namespace Identifier { - const prefixes = { - account: "acc", - billing: "bil", - key: "key", - payment: "pay", - usage: "usg", - user: "usr", - workspace: "wrk", - } as const - - export function create(prefix: keyof typeof prefixes, given?: string): string { - if (given) { - if (given.startsWith(prefixes[prefix])) return given - throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`) - } - return [prefixes[prefix], ulid()].join("_") - } - - export function schema(prefix: keyof typeof prefixes) { - return z.string().startsWith(prefixes[prefix]) - } -} diff --git a/packages/cloud/core/src/key.ts b/packages/cloud/core/src/key.ts deleted file mode 100644 index 28643a521..000000000 --- a/packages/cloud/core/src/key.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { z } from "zod" -import { fn } from "./util/fn" -import { Actor } from "./actor" -import { and, Database, eq, isNull, sql } from "./drizzle" -import { Identifier } from "./identifier" -import { KeyTable } from "./schema/key.sql" - -export namespace Key { - export const list = async () => { - const workspace = Actor.workspace() - const keys = await Database.use((tx) => - tx - .select() - .from(KeyTable) - .where(and(eq(KeyTable.workspaceID, workspace), isNull(KeyTable.timeDeleted))) - .orderBy(sql`${KeyTable.timeCreated} DESC`), - ) - return keys - } - - export const create = fn(z.object({ name: z.string().min(1).max(255) }), async (input) => { - const workspaceID = Actor.workspace() - const { name } = input - - // Generate secret key: sk- + 64 random characters (upper, lower, numbers) - const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - let secretKey = "sk-" - const array = new Uint32Array(64) - crypto.getRandomValues(array) - for (let i = 0, l = array.length; i < l; i++) { - secretKey += chars[array[i] % chars.length] - } - const keyID = Identifier.create("key") - - await Database.use((tx) => - tx.insert(KeyTable).values({ - id: keyID, - workspaceID, - actor: Actor.use(), - name, - key: secretKey, - timeUsed: null, - }), - ).catch((e: any) => { - if (e.message.match(/Duplicate entry '.*' for key 'key.name'/)) - throw new Error("A key with this name already exists. Please choose a different name.") - throw e - }) - - return keyID - }) - - export const remove = fn(z.object({ id: z.string() }), async (input) => { - const workspace = Actor.workspace() - await Database.transaction(async (tx) => { - const row = await tx - .select({ - name: KeyTable.name, - }) - .from(KeyTable) - .where(and(eq(KeyTable.id, input.id), eq(KeyTable.workspaceID, workspace))) - .then((rows) => rows[0]) - if (!row) return - - await tx - .update(KeyTable) - .set({ - timeDeleted: sql`now()`, - oldName: row.name, - name: input.id, // Use the key ID as the name - }) - .where(and(eq(KeyTable.id, input.id), eq(KeyTable.workspaceID, workspace))) - }) - }) -} diff --git a/packages/cloud/core/src/schema/account.sql.ts b/packages/cloud/core/src/schema/account.sql.ts deleted file mode 100644 index 4d9937114..000000000 --- a/packages/cloud/core/src/schema/account.sql.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core" -import { id, timestamps } from "../drizzle/types" - -export const AccountTable = mysqlTable( - "account", - { - id: id(), - ...timestamps, - email: varchar("email", { length: 255 }).notNull(), - }, - (table) => [uniqueIndex("email").on(table.email)], -) diff --git a/packages/cloud/core/src/schema/billing.sql.ts b/packages/cloud/core/src/schema/billing.sql.ts deleted file mode 100644 index 5bec4e900..000000000 --- a/packages/cloud/core/src/schema/billing.sql.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { bigint, boolean, int, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core" -import { timestamps, utc, workspaceColumns } from "../drizzle/types" -import { workspaceIndexes } from "./workspace.sql" - -export const BillingTable = mysqlTable( - "billing", - { - ...workspaceColumns, - ...timestamps, - customerID: varchar("customer_id", { length: 255 }), - paymentMethodID: varchar("payment_method_id", { length: 255 }), - paymentMethodLast4: varchar("payment_method_last4", { length: 4 }), - balance: bigint("balance", { mode: "number" }).notNull(), - monthlyLimit: int("monthly_limit"), - monthlyUsage: bigint("monthly_usage", { mode: "number" }), - timeMonthlyUsageUpdated: utc("time_monthly_usage_updated"), - reload: boolean("reload"), - reloadError: varchar("reload_error", { length: 255 }), - timeReloadError: utc("time_reload_error"), - timeReloadLockedTill: utc("time_reload_locked_till"), - }, - (table) => [...workspaceIndexes(table), uniqueIndex("global_customer_id").on(table.customerID)], -) - -export const PaymentTable = mysqlTable( - "payment", - { - ...workspaceColumns, - ...timestamps, - customerID: varchar("customer_id", { length: 255 }), - paymentID: varchar("payment_id", { length: 255 }), - amount: bigint("amount", { mode: "number" }).notNull(), - }, - (table) => [...workspaceIndexes(table)], -) - -export const UsageTable = mysqlTable( - "usage", - { - ...workspaceColumns, - ...timestamps, - model: varchar("model", { length: 255 }).notNull(), - provider: varchar("provider", { length: 255 }).notNull(), - inputTokens: int("input_tokens").notNull(), - outputTokens: int("output_tokens").notNull(), - reasoningTokens: int("reasoning_tokens"), - cacheReadTokens: int("cache_read_tokens"), - cacheWrite5mTokens: int("cache_write_5m_tokens"), - cacheWrite1hTokens: int("cache_write_1h_tokens"), - cost: bigint("cost", { mode: "number" }).notNull(), - }, - (table) => [...workspaceIndexes(table)], -) diff --git a/packages/cloud/core/src/schema/key.sql.ts b/packages/cloud/core/src/schema/key.sql.ts deleted file mode 100644 index 98b99c788..000000000 --- a/packages/cloud/core/src/schema/key.sql.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { mysqlTable, varchar, uniqueIndex, json } from "drizzle-orm/mysql-core" -import { timestamps, utc, workspaceColumns } from "../drizzle/types" -import { workspaceIndexes } from "./workspace.sql" -import { Actor } from "../actor" - -export const KeyTable = mysqlTable( - "key", - { - ...workspaceColumns, - ...timestamps, - actor: json("actor").$type(), - name: varchar("name", { length: 255 }).notNull(), - oldName: varchar("old_name", { length: 255 }), - key: varchar("key", { length: 255 }).notNull(), - timeUsed: utc("time_used"), - }, - (table) => [ - ...workspaceIndexes(table), - uniqueIndex("global_key").on(table.key), - uniqueIndex("name").on(table.workspaceID, table.name), - ], -) diff --git a/packages/cloud/core/src/schema/user.sql.ts b/packages/cloud/core/src/schema/user.sql.ts deleted file mode 100644 index 00c372d1a..000000000 --- a/packages/cloud/core/src/schema/user.sql.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { text, mysqlTable, uniqueIndex, varchar, int } from "drizzle-orm/mysql-core" -import { timestamps, utc, workspaceColumns } from "../drizzle/types" -import { workspaceIndexes } from "./workspace.sql" - -export const UserTable = mysqlTable( - "user", - { - ...workspaceColumns, - ...timestamps, - email: varchar("email", { length: 255 }).notNull(), - name: varchar("name", { length: 255 }).notNull(), - timeSeen: utc("time_seen"), - color: int("color"), - }, - (table) => [...workspaceIndexes(table), uniqueIndex("user_email").on(table.workspaceID, table.email)], -) diff --git a/packages/cloud/core/src/schema/workspace.sql.ts b/packages/cloud/core/src/schema/workspace.sql.ts deleted file mode 100644 index 979255428..000000000 --- a/packages/cloud/core/src/schema/workspace.sql.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { primaryKey, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core" -import { timestamps, ulid } from "../drizzle/types" - -export const WorkspaceTable = mysqlTable( - "workspace", - { - id: ulid("id").notNull().primaryKey(), - slug: varchar("slug", { length: 255 }), - name: varchar("name", { length: 255 }), - ...timestamps, - }, - (table) => [uniqueIndex("slug").on(table.slug)], -) - -export function workspaceIndexes(table: any) { - return [ - primaryKey({ - columns: [table.workspaceID, table.id], - }), - ] -} diff --git a/packages/cloud/core/src/user.ts b/packages/cloud/core/src/user.ts deleted file mode 100644 index 7914926ff..000000000 --- a/packages/cloud/core/src/user.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { z } from "zod" -import { eq } from "drizzle-orm" -import { fn } from "./util/fn" -import { Database } from "./drizzle" -import { UserTable } from "./schema/user.sql" - -export namespace User { - export const fromID = fn(z.string(), async (id) => - Database.transaction(async (tx) => { - return tx - .select() - .from(UserTable) - .where(eq(UserTable.id, id)) - .execute() - .then((rows) => rows[0]) - }), - ) -} diff --git a/packages/cloud/core/src/util/env.cloudflare.ts b/packages/cloud/core/src/util/env.cloudflare.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/cloud/core/src/util/fn.ts b/packages/cloud/core/src/util/fn.ts deleted file mode 100644 index 9efe4622f..000000000 --- a/packages/cloud/core/src/util/fn.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { z } from "zod" - -export function fn(schema: T, cb: (input: z.infer) => Result) { - const result = (input: z.infer) => { - const parsed = schema.parse(input) - return cb(parsed) - } - result.force = (input: z.infer) => cb(input) - result.schema = schema - return result -} diff --git a/packages/cloud/core/src/util/log.ts b/packages/cloud/core/src/util/log.ts deleted file mode 100644 index 4f2d25c13..000000000 --- a/packages/cloud/core/src/util/log.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Context } from "../context" - -export namespace Log { - const ctx = Context.create<{ - tags: Record - }>() - - export function create(tags?: Record) { - tags = tags || {} - - const result = { - info(message?: any, extra?: Record) { - const prefix = Object.entries({ - ...use().tags, - ...tags, - ...extra, - }) - .map(([key, value]) => `${key}=${value}`) - .join(" ") - console.log(prefix, message) - return result - }, - tag(key: string, value: string) { - if (tags) tags[key] = value - return result - }, - clone() { - return Log.create({ ...tags }) - }, - } - - return result - } - - export function provide(tags: Record, cb: () => R) { - const existing = use() - return ctx.provide( - { - tags: { - ...existing.tags, - ...tags, - }, - }, - cb, - ) - } - - function use() { - try { - return ctx.use() - } catch (e) { - return { tags: {} } - } - } -} diff --git a/packages/cloud/core/src/util/memo.ts b/packages/cloud/core/src/util/memo.ts deleted file mode 100644 index 49043010f..000000000 --- a/packages/cloud/core/src/util/memo.ts +++ /dev/null @@ -1,18 +0,0 @@ -export function memo(fn: () => T, cleanup?: (input: T) => Promise) { - let value: T | undefined - let loaded = false - - const result = (): T => { - if (loaded) return value as T - loaded = true - value = fn() - return value as T - } - result.reset = async () => { - if (cleanup && value) await cleanup(value) - loaded = false - value = undefined - } - - return result -} diff --git a/packages/cloud/core/src/util/price.ts b/packages/cloud/core/src/util/price.ts deleted file mode 100644 index abdbca032..000000000 --- a/packages/cloud/core/src/util/price.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function centsToMicroCents(amount: number) { - return Math.round(amount * 1000000) -} diff --git a/packages/cloud/core/src/workspace.ts b/packages/cloud/core/src/workspace.ts deleted file mode 100644 index a9fb923d6..000000000 --- a/packages/cloud/core/src/workspace.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { z } from "zod" -import { fn } from "./util/fn" -import { centsToMicroCents } from "./util/price" -import { Actor } from "./actor" -import { Database, eq } from "./drizzle" -import { Identifier } from "./identifier" -import { UserTable } from "./schema/user.sql" -import { BillingTable } from "./schema/billing.sql" -import { WorkspaceTable } from "./schema/workspace.sql" -import { Key } from "./key" - -export namespace Workspace { - export const create = fn(z.void(), async () => { - const account = Actor.assert("account") - const workspaceID = Identifier.create("workspace") - await Database.transaction(async (tx) => { - await tx.insert(WorkspaceTable).values({ - id: workspaceID, - }) - await tx.insert(UserTable).values({ - workspaceID, - id: Identifier.create("user"), - email: account.properties.email, - name: "", - }) - await tx.insert(BillingTable).values({ - workspaceID, - id: Identifier.create("billing"), - balance: 0, - }) - }) - await Actor.provide( - "system", - { - workspaceID, - }, - async () => { - await Key.create({ name: "Default API Key" }) - }, - ) - return workspaceID - }) - - export async function list() { - const account = Actor.assert("account") - return Database.use(async (tx) => { - return tx - .select({ - id: WorkspaceTable.id, - slug: WorkspaceTable.slug, - name: WorkspaceTable.name, - }) - .from(UserTable) - .innerJoin(WorkspaceTable, eq(UserTable.workspaceID, WorkspaceTable.id)) - .where(eq(UserTable.email, account.properties.email)) - }) - } -} diff --git a/packages/cloud/core/sst-env.d.ts b/packages/cloud/core/sst-env.d.ts deleted file mode 100644 index bd5588217..000000000 --- a/packages/cloud/core/sst-env.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* This file is auto-generated by SST. Do not edit. */ -/* tslint:disable */ -/* eslint-disable */ -/* deno-fmt-ignore-file */ - -/// - -import "sst" -export {} diff --git a/packages/cloud/core/tsconfig.json b/packages/cloud/core/tsconfig.json deleted file mode 100644 index 0faf16aab..000000000 --- a/packages/cloud/core/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "types": ["@cloudflare/workers-types", "node"] - } -} diff --git a/packages/cloud/function/package.json b/packages/cloud/function/package.json deleted file mode 100644 index 856db3696..000000000 --- a/packages/cloud/function/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@opencode/cloud-function", - "version": "0.9.11", - "$schema": "https://json.schemastore.org/package.json", - "private": true, - "type": "module", - "scripts": { - "typecheck": "tsc --noEmit" - }, - "devDependencies": { - "@cloudflare/workers-types": "4.20250522.0", - "@types/node": "catalog:", - "openai": "5.11.0", - "typescript": "catalog:" - }, - "dependencies": { - "@ai-sdk/anthropic": "2.0.0", - "@ai-sdk/openai": "2.0.2", - "@ai-sdk/openai-compatible": "1.0.1", - "@hono/zod-validator": "catalog:", - "@openauthjs/openauth": "0.0.0-20250322224806", - "ai": "catalog:", - "hono": "catalog:", - "zod": "catalog:" - } -} diff --git a/packages/cloud/function/src/auth.ts b/packages/cloud/function/src/auth.ts deleted file mode 100644 index 776855e46..000000000 --- a/packages/cloud/function/src/auth.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { z } from "zod" -import { issuer } from "@openauthjs/openauth" -import type { Theme } from "@openauthjs/openauth/ui/theme" -import { createSubjects } from "@openauthjs/openauth/subject" -import { THEME_OPENAUTH } from "@openauthjs/openauth/ui/theme" -import { GithubProvider } from "@openauthjs/openauth/provider/github" -import { GoogleOidcProvider } from "@openauthjs/openauth/provider/google" -import { CloudflareStorage } from "@openauthjs/openauth/storage/cloudflare" -import { Account } from "@opencode/cloud-core/account.js" -import { Workspace } from "@opencode/cloud-core/workspace.js" -import { Actor } from "@opencode/cloud-core/actor.js" -import { Resource } from "@opencode/cloud-resource" -import { Database } from "@opencode/cloud-core/drizzle/index.js" - -type Env = { - AuthStorage: KVNamespace -} - -export const subjects = createSubjects({ - account: z.object({ - accountID: z.string(), - email: z.string(), - }), - user: z.object({ - userID: z.string(), - workspaceID: z.string(), - }), -}) - -const MY_THEME: Theme = { - ...THEME_OPENAUTH, - logo: "https://opencode.ai/favicon.svg", -} - -export default { - async fetch(request: Request, env: Env, ctx: ExecutionContext) { - const result = await issuer({ - theme: MY_THEME, - providers: { - github: GithubProvider({ - clientID: Resource.GITHUB_CLIENT_ID_CONSOLE.value, - clientSecret: Resource.GITHUB_CLIENT_SECRET_CONSOLE.value, - scopes: ["read:user", "user:email"], - }), - google: GoogleOidcProvider({ - clientID: Resource.GOOGLE_CLIENT_ID.value, - scopes: ["openid", "email"], - }), - // email: CodeProvider({ - // async request(req, state, form, error) { - // console.log(state) - // const params = new URLSearchParams() - // if (error) { - // params.set("error", error.type) - // } - // if (state.type === "start") { - // return Response.redirect(process.env.AUTH_FRONTEND_URL + "/auth/email?" + params.toString(), 302) - // } - // - // if (state.type === "code") { - // return Response.redirect(process.env.AUTH_FRONTEND_URL + "/auth/code?" + params.toString(), 302) - // } - // - // return new Response("ok") - // }, - // async sendCode(claims, code) { - // const email = z.string().email().parse(claims.email) - // const cmd = new SendEmailCommand({ - // Destination: { - // ToAddresses: [email], - // }, - // FromEmailAddress: `SST `, - // Content: { - // Simple: { - // Body: { - // Html: { - // Data: `Your pin code is ${code}`, - // }, - // Text: { - // Data: `Your pin code is ${code}`, - // }, - // }, - // Subject: { - // Data: "SST Console Pin Code: " + code, - // }, - // }, - // }, - // }) - // await ses.send(cmd) - // }, - // }), - }, - storage: CloudflareStorage({ - namespace: env.AuthStorage, - }), - subjects, - async success(ctx, response) { - console.log(response) - - let email: string | undefined - - if (response.provider === "github") { - const emails = (await fetch("https://api.github.com/user/emails", { - headers: { - Authorization: `Bearer ${response.tokenset.access}`, - "User-Agent": "opencode", - Accept: "application/vnd.github+json", - }, - }).then((x) => x.json())) as any - email = emails.find((x: any) => x.primary && x.verified)?.email - } else if (response.provider === "google") { - if (!response.id.email_verified) throw new Error("Google email not verified") - email = response.id.email as string - } - //if (response.provider === "email") { - // email = response.claims.email - //} - else throw new Error("Unsupported provider") - - if (!email) throw new Error("No email found") - - let accountID = await Account.fromEmail(email).then((x) => x?.id) - if (!accountID) { - console.log("creating account for", email) - accountID = await Account.create({ - email: email!, - }) - } - await Actor.provide("account", { accountID, email }, async () => { - const workspaces = await Account.workspaces() - if (workspaces.length === 0) { - await Workspace.create() - } - }) - return ctx.subject("account", accountID, { accountID, email }) - }, - }).fetch(request, env, ctx) - return result - }, -} diff --git a/packages/cloud/function/src/log-processor.ts b/packages/cloud/function/src/log-processor.ts deleted file mode 100644 index 70fcf5a44..000000000 --- a/packages/cloud/function/src/log-processor.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Resource } from "@opencode/cloud-resource" -import type { TraceItem } from "@cloudflare/workers-types" - -export default { - async tail(events: TraceItem[]) { - for (const event of events) { - if (!event.event) continue - if (!("request" in event.event)) continue - if (event.event.request.method !== "POST") continue - - const url = new URL(event.event.request.url) - if (url.pathname !== "/zen/v1/chat/completions") return - - let metrics = { - event_type: "completions", - "cf.continent": event.event.request.cf?.continent, - "cf.country": event.event.request.cf?.country, - "cf.city": event.event.request.cf?.city, - "cf.region": event.event.request.cf?.region, - "cf.latitude": event.event.request.cf?.latitude, - "cf.longitude": event.event.request.cf?.longitude, - "cf.timezone": event.event.request.cf?.timezone, - duration: event.wallTime, - request_length: parseInt(event.event.request.headers["content-length"] ?? "0"), - status: event.event.response?.status ?? 0, - ip: event.event.request.headers["x-real-ip"], - } - for (const log of event.logs) { - for (const message of log.message) { - if (!message.startsWith("_metric:")) continue - metrics = { ...metrics, ...JSON.parse(message.slice(8)) } - } - } - console.log(JSON.stringify(metrics, null, 2)) - - const ret = await fetch("https://api.honeycomb.io/1/events/zen", { - method: "POST", - headers: { - "Content-Type": "application/json", - "X-Honeycomb-Event-Time": (event.eventTimestamp ?? Date.now()).toString(), - "X-Honeycomb-Team": Resource.HONEYCOMB_API_KEY.value, - }, - body: JSON.stringify(metrics), - }) - console.log(ret.status) - console.log(await ret.text()) - } - }, -} diff --git a/packages/cloud/function/sst-env.d.ts b/packages/cloud/function/sst-env.d.ts deleted file mode 100644 index afa8c6fe7..000000000 --- a/packages/cloud/function/sst-env.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* This file is auto-generated by SST. Do not edit. */ -/* tslint:disable */ -/* eslint-disable */ -/* deno-fmt-ignore-file */ - -import "sst" -declare module "sst" { - export interface Resource { - ANTHROPIC_API_KEY: { - type: "sst.sst.Secret" - value: string - } - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string - } - BASETEN_API_KEY: { - type: "sst.sst.Secret" - value: string - } - Console: { - type: "sst.cloudflare.SolidStart" - url: string - } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string - } - FIREWORKS_API_KEY: { - type: "sst.sst.Secret" - value: string - } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string - } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string - } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string - } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string - } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string - } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string - } - OPENAI_API_KEY: { - type: "sst.sst.Secret" - value: string - } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string - } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string - } - Web: { - type: "sst.cloudflare.Astro" - url: string - } - XAI_API_KEY: { - type: "sst.sst.Secret" - value: string - } - } -} -// cloudflare -import * as cloudflare from "@cloudflare/workers-types" -declare module "sst" { - export interface Resource { - Api: cloudflare.Service - AuthApi: cloudflare.Service - AuthStorage: cloudflare.KVNamespace - Bucket: cloudflare.R2Bucket - LogProcessor: cloudflare.Service - } -} - -import "sst" -export {} diff --git a/packages/cloud/function/tsconfig.json b/packages/cloud/function/tsconfig.json deleted file mode 100644 index 0faf16aab..000000000 --- a/packages/cloud/function/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "types": ["@cloudflare/workers-types", "node"] - } -} diff --git a/packages/cloud/resource/bun.lock b/packages/cloud/resource/bun.lock deleted file mode 100644 index 56bdf44ca..000000000 --- a/packages/cloud/resource/bun.lock +++ /dev/null @@ -1,13 +0,0 @@ -{ - "lockfileVersion": 1, - "workspaces": { - "": { - "dependencies": { - "@cloudflare/workers-types": "^4.20250830.0", - }, - }, - }, - "packages": { - "@cloudflare/workers-types": ["@cloudflare/workers-types@4.20250830.0", "", {}, "sha512-uAGZFqEBFnCiwIokxMnrrtjIkT8qyGT1LACSScEUyW7nKmtD0Viykp9QZWrIlssyEp/MDB6XsdALF8y6upxpcg=="], - } -} diff --git a/packages/cloud/resource/package.json b/packages/cloud/resource/package.json deleted file mode 100644 index fd9fa6f34..000000000 --- a/packages/cloud/resource/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/package.json", - "name": "@opencode/cloud-resource", - "dependencies": { - "@cloudflare/workers-types": "^4.20250830.0" - }, - "exports": { - ".": { - "production": { - "import": "./resource.cloudflare.ts" - }, - "import": "./resource.node.ts" - } - } -} diff --git a/packages/cloud/resource/resource.cloudflare.ts b/packages/cloud/resource/resource.cloudflare.ts deleted file mode 100644 index a56b1e417..000000000 --- a/packages/cloud/resource/resource.cloudflare.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { env } from "cloudflare:workers" - -export const Resource = new Proxy( - {}, - { - get(_target, prop: string) { - if (prop in env) { - // @ts-expect-error - const value = env[prop] - return typeof value === "string" ? JSON.parse(value) : value - } else if (prop === "App") { - // @ts-expect-error - return JSON.parse(env.SST_RESOURCE_App) - } - throw new Error(`"${prop}" is not linked in your sst.config.ts (cloudflare)`) - }, - }, -) as Record diff --git a/packages/cloud/resource/resource.node.ts b/packages/cloud/resource/resource.node.ts deleted file mode 100644 index d7dbb6c6d..000000000 --- a/packages/cloud/resource/resource.node.ts +++ /dev/null @@ -1 +0,0 @@ -export { Resource } from "sst" diff --git a/packages/cloud/resource/sst-env.d.ts b/packages/cloud/resource/sst-env.d.ts deleted file mode 100644 index afa8c6fe7..000000000 --- a/packages/cloud/resource/sst-env.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* This file is auto-generated by SST. Do not edit. */ -/* tslint:disable */ -/* eslint-disable */ -/* deno-fmt-ignore-file */ - -import "sst" -declare module "sst" { - export interface Resource { - ANTHROPIC_API_KEY: { - type: "sst.sst.Secret" - value: string - } - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string - } - BASETEN_API_KEY: { - type: "sst.sst.Secret" - value: string - } - Console: { - type: "sst.cloudflare.SolidStart" - url: string - } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string - } - FIREWORKS_API_KEY: { - type: "sst.sst.Secret" - value: string - } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string - } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string - } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string - } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string - } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string - } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string - } - OPENAI_API_KEY: { - type: "sst.sst.Secret" - value: string - } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string - } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string - } - Web: { - type: "sst.cloudflare.Astro" - url: string - } - XAI_API_KEY: { - type: "sst.sst.Secret" - value: string - } - } -} -// cloudflare -import * as cloudflare from "@cloudflare/workers-types" -declare module "sst" { - export interface Resource { - Api: cloudflare.Service - AuthApi: cloudflare.Service - AuthStorage: cloudflare.KVNamespace - Bucket: cloudflare.R2Bucket - LogProcessor: cloudflare.Service - } -} - -import "sst" -export {} diff --git a/packages/cloud/resource/tsconfig.json b/packages/cloud/resource/tsconfig.json deleted file mode 100644 index 0faf16aab..000000000 --- a/packages/cloud/resource/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "types": ["@cloudflare/workers-types", "node"] - } -} diff --git a/packages/cloud/scripts/.gitignore b/packages/cloud/scripts/.gitignore deleted file mode 100644 index 18c5ea0f8..000000000 --- a/packages/cloud/scripts/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/scrap.ts diff --git a/packages/cloud/scripts/package.json b/packages/cloud/scripts/package.json deleted file mode 100644 index bddc1b967..000000000 --- a/packages/cloud/scripts/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@opencode/cloud-scripts", - "version": "0.9.11", - "$schema": "https://json.schemastore.org/package.json", - "private": true, - "type": "module", - "scripts": { - "shell": "sst shell -- bun tsx", - "shell-dev": "sst shell --stage dev -- bun tsx", - "shell-prod": "sst shell --stage production -- bun tsx" - }, - "dependencies": { - "@opencode/cloud-core": "workspace:*", - "tsx": "4.20.5" - }, - "devDependencies": { - "@types/node": "catalog:", - "typescript": "catalog:" - } -} diff --git a/packages/cloud/scripts/src/backfill-usage-provider.ts b/packages/cloud/scripts/src/backfill-usage-provider.ts deleted file mode 100644 index 553dcb478..000000000 --- a/packages/cloud/scripts/src/backfill-usage-provider.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Database, eq } from "@opencode/cloud-core/drizzle/index.js" -import { UsageTable } from "@opencode/cloud-core/schema/billing.sql.js" - -await Database.use(async (tx) => { - await tx - .update(UsageTable) - .set({ model: "grok-code" }) - .where(eq(UsageTable.model, "x-ai/grok-code-fast-1")) - .limit(90000) -}) diff --git a/packages/cloud/scripts/sst-env.d.ts b/packages/cloud/scripts/sst-env.d.ts deleted file mode 100644 index bd5588217..000000000 --- a/packages/cloud/scripts/sst-env.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* This file is auto-generated by SST. Do not edit. */ -/* tslint:disable */ -/* eslint-disable */ -/* deno-fmt-ignore-file */ - -/// - -import "sst" -export {} diff --git a/packages/cloud/scripts/tsconfig.json b/packages/cloud/scripts/tsconfig.json deleted file mode 100644 index 0faf16aab..000000000 --- a/packages/cloud/scripts/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "bundler", - "types": ["@cloudflare/workers-types", "node"] - } -} diff --git a/packages/console/app/.gitignore b/packages/console/app/.gitignore new file mode 100644 index 000000000..751513ce1 --- /dev/null +++ b/packages/console/app/.gitignore @@ -0,0 +1,28 @@ +dist +.wrangler +.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 diff --git a/packages/console/app/.opencode/agent/css.md b/packages/console/app/.opencode/agent/css.md new file mode 100644 index 000000000..d0ec43a48 --- /dev/null +++ b/packages/console/app/.opencode/agent/css.md @@ -0,0 +1,149 @@ +--- +description: use whenever you are styling a ui with css +--- + +you are very good at writing clean maintainable css using modern techniques + +css is structured like this + +```css +[data-page="home"] { + [data-component="header"] { + [data-slot="logo"] { + } + } +} +``` + +top level pages are scoped using `data-page` + +pages can break down into components using `data-component` + +components can break down into slots using `data-slot` + +structure things so that this hierarchy is followed IN YOUR CSS - you should rarely need to +nest components inside other components. you should NEVER nest components inside +slots. you should NEVER nest slots inside other slots. + +**IMPORTANT: This hierarchy rule applies to CSS structure, NOT JSX/DOM structure.** + +The hierarchy in css file does NOT have to match the hierarchy in the dom - you +can put components or slots at the same level in CSS even if one goes inside another in the DOM. + +Your JSX can nest however makes semantic sense - components can be inside slots, +slots can contain components, etc. The DOM structure should be whatever makes the most +semantic and functional sense. + +It is more important to follow the pages -> components -> slots structure IN YOUR CSS, +while keeping your JSX/DOM structure logical and semantic. + +use data attributes to represent different states of the component + +```css +[data-component="modal"] { + opacity: 0; + + &[data-state="open"] { + opacity: 1; + } +} +``` + +this will allow jsx to control the syling + +avoid selectors that just target an element type like `> span` you should assign +it a slot name. it's ok to do this sometimes where it makes sense semantically +like targeting `li` elements in a list + +in terms of file structure `./src/style/` contains all universal styling rules. +these should not contain anything specific to a page + +`./src/style/token` contains all the tokens used in the project + +`./src/style/component` is for reusable components like buttons or inputs + +page specific styles should go next to the page they are styling so +`./src/routes/about.tsx` should have its styles in `./src/routes/about.css` + +`about.css` should be scoped using `data-page="about"` + +## Example of correct implementation + +JSX can nest however makes sense semantically: + +```jsx +
+
Section Title
+
Content here
+
+``` + +CSS maintains clean hierarchy regardless of DOM nesting: + +```css +[data-page="home"] { + [data-component="screenshots"] { + [data-slot="left"] { + /* styles */ + } + [data-slot="content"] { + /* styles */ + } + } + + [data-component="title"] { + /* can be at same level even though nested in DOM */ + } +} +``` + +## Reusable Components + +If a component is reused across multiple sections of the same page, define it at the page level: + +```jsx + +
+
+

npm

+
+
+

bun

+
+
+ +
+
+
Screenshot Title
+
+
+``` + +```css +[data-page="home"] { + /* Reusable title component defined at page level since it's used in multiple components */ + [data-component="title"] { + text-transform: uppercase; + font-weight: 400; + } + + [data-component="install"] { + /* install-specific styles */ + } + + [data-component="screenshots"] { + /* screenshots-specific styles */ + } +} +``` + +This is correct because the `title` component has consistent styling and behavior across the page. + +## Key Clarifications + +1. **JSX Nesting is Flexible**: Components can be nested inside slots, slots can contain components - whatever makes semantic sense +2. **CSS Hierarchy is Strict**: Follow pages → components → slots structure in CSS +3. **Reusable Components**: Define at the appropriate level where they're shared (page level if used across the page, component level if only used within that component) +4. **DOM vs CSS Structure**: These don't need to match - optimize each for its purpose + +See ./src/routes/index.css and ./src/routes/index.tsx for a complete example. diff --git a/packages/console/app/README.md b/packages/console/app/README.md new file mode 100644 index 000000000..9337430cf --- /dev/null +++ b/packages/console/app/README.md @@ -0,0 +1,32 @@ +# SolidStart + +Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com); + +## Creating a project + +```bash +# create a new project in the current directory +npm init solid@latest + +# create a new project in my-app +npm init solid@latest my-app +``` + +## Developing + +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: + +```bash +npm run dev + +# or start the server and open the app in a new browser tab +npm run dev -- --open +``` + +## Building + +Solid apps are built with _presets_, which optimise your project for deployment to different environments. + +By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add it to the `devDependencies` in `package.json` and specify in your `app.config.js`. + +## This project was created with the [Solid CLI](https://github.com/solidjs-community/solid-cli) diff --git a/packages/console/app/app.config.ts b/packages/console/app/app.config.ts new file mode 100644 index 000000000..af013bc81 --- /dev/null +++ b/packages/console/app/app.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from "@solidjs/start/config" + +export default defineConfig({ + middleware: "./src/middleware.ts", + vite: { + server: { + allowedHosts: true, + }, + build: { + rollupOptions: { + external: ["cloudflare:workers"], + }, + minify: false, + }, + }, + server: { + compatibilityDate: "2024-09-19", + preset: "cloudflare_module", + cloudflare: { + nodeCompat: true, + }, + }, +}) diff --git a/packages/console/app/package.json b/packages/console/app/package.json new file mode 100644 index 000000000..2a9d9a98b --- /dev/null +++ b/packages/console/app/package.json @@ -0,0 +1,25 @@ +{ + "name": "@opencode/console-app", + "type": "module", + "scripts": { + "typecheck": "tsc --noEmit", + "dev": "vinxi dev --host 0.0.0.0", + "dev:remote": "VITE_AUTH_URL=https://auth.dev.opencode.ai bun sst shell --stage=dev bun dev", + "build": "vinxi build && ../../opencode/script/schema.ts ./.output/public/config.json", + "start": "vinxi start", + "version": "0.9.11" + }, + "dependencies": { + "@ibm/plex": "6.4.1", + "@openauthjs/openauth": "0.0.0-20250322224806", + "@solidjs/meta": "^0.29.4", + "@solidjs/router": "^0.15.0", + "@solidjs/start": "^1.1.0", + "solid-js": "catalog:", + "vinxi": "^0.5.7", + "@opencode/console-core": "workspace:*" + }, + "engines": { + "node": ">=22" + } +} diff --git a/packages/console/app/public/favicon.svg b/packages/console/app/public/favicon.svg new file mode 100644 index 000000000..3c81bbdb4 --- /dev/null +++ b/packages/console/app/public/favicon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/console/app/public/robots.txt b/packages/console/app/public/robots.txt new file mode 100644 index 000000000..f88eb1790 --- /dev/null +++ b/packages/console/app/public/robots.txt @@ -0,0 +1,5 @@ +User-agent: * +Allow: / + +# Disallow shared content pages +Disallow: /s/ \ No newline at end of file diff --git a/packages/console/app/public/social-share.png b/packages/console/app/public/social-share.png new file mode 100644 index 000000000..97f67994d Binary files /dev/null and b/packages/console/app/public/social-share.png differ diff --git a/packages/console/app/public/theme.json b/packages/console/app/public/theme.json new file mode 100644 index 000000000..b3e97f7ca --- /dev/null +++ b/packages/console/app/public/theme.json @@ -0,0 +1,182 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "$schema": { + "type": "string", + "description": "JSON schema reference for configuration validation" + }, + "defs": { + "type": "object", + "description": "Color definitions that can be referenced in the theme", + "patternProperties": { + "^[a-zA-Z][a-zA-Z0-9_]*$": { + "oneOf": [ + { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$", + "description": "Hex color value" + }, + { + "type": "integer", + "minimum": 0, + "maximum": 255, + "description": "ANSI color code (0-255)" + }, + { + "type": "string", + "enum": ["none"], + "description": "No color (uses terminal default)" + } + ] + } + }, + "additionalProperties": false + }, + "theme": { + "type": "object", + "description": "Theme color definitions", + "properties": { + "primary": { "$ref": "#/definitions/colorValue" }, + "secondary": { "$ref": "#/definitions/colorValue" }, + "accent": { "$ref": "#/definitions/colorValue" }, + "error": { "$ref": "#/definitions/colorValue" }, + "warning": { "$ref": "#/definitions/colorValue" }, + "success": { "$ref": "#/definitions/colorValue" }, + "info": { "$ref": "#/definitions/colorValue" }, + "text": { "$ref": "#/definitions/colorValue" }, + "textMuted": { "$ref": "#/definitions/colorValue" }, + "background": { "$ref": "#/definitions/colorValue" }, + "backgroundPanel": { "$ref": "#/definitions/colorValue" }, + "backgroundElement": { "$ref": "#/definitions/colorValue" }, + "border": { "$ref": "#/definitions/colorValue" }, + "borderActive": { "$ref": "#/definitions/colorValue" }, + "borderSubtle": { "$ref": "#/definitions/colorValue" }, + "diffAdded": { "$ref": "#/definitions/colorValue" }, + "diffRemoved": { "$ref": "#/definitions/colorValue" }, + "diffContext": { "$ref": "#/definitions/colorValue" }, + "diffHunkHeader": { "$ref": "#/definitions/colorValue" }, + "diffHighlightAdded": { "$ref": "#/definitions/colorValue" }, + "diffHighlightRemoved": { "$ref": "#/definitions/colorValue" }, + "diffAddedBg": { "$ref": "#/definitions/colorValue" }, + "diffRemovedBg": { "$ref": "#/definitions/colorValue" }, + "diffContextBg": { "$ref": "#/definitions/colorValue" }, + "diffLineNumber": { "$ref": "#/definitions/colorValue" }, + "diffAddedLineNumberBg": { "$ref": "#/definitions/colorValue" }, + "diffRemovedLineNumberBg": { "$ref": "#/definitions/colorValue" }, + "markdownText": { "$ref": "#/definitions/colorValue" }, + "markdownHeading": { "$ref": "#/definitions/colorValue" }, + "markdownLink": { "$ref": "#/definitions/colorValue" }, + "markdownLinkText": { "$ref": "#/definitions/colorValue" }, + "markdownCode": { "$ref": "#/definitions/colorValue" }, + "markdownBlockQuote": { "$ref": "#/definitions/colorValue" }, + "markdownEmph": { "$ref": "#/definitions/colorValue" }, + "markdownStrong": { "$ref": "#/definitions/colorValue" }, + "markdownHorizontalRule": { "$ref": "#/definitions/colorValue" }, + "markdownListItem": { "$ref": "#/definitions/colorValue" }, + "markdownListEnumeration": { "$ref": "#/definitions/colorValue" }, + "markdownImage": { "$ref": "#/definitions/colorValue" }, + "markdownImageText": { "$ref": "#/definitions/colorValue" }, + "markdownCodeBlock": { "$ref": "#/definitions/colorValue" }, + "syntaxComment": { "$ref": "#/definitions/colorValue" }, + "syntaxKeyword": { "$ref": "#/definitions/colorValue" }, + "syntaxFunction": { "$ref": "#/definitions/colorValue" }, + "syntaxVariable": { "$ref": "#/definitions/colorValue" }, + "syntaxString": { "$ref": "#/definitions/colorValue" }, + "syntaxNumber": { "$ref": "#/definitions/colorValue" }, + "syntaxType": { "$ref": "#/definitions/colorValue" }, + "syntaxOperator": { "$ref": "#/definitions/colorValue" }, + "syntaxPunctuation": { "$ref": "#/definitions/colorValue" } + }, + "required": ["primary", "secondary", "accent", "text", "textMuted", "background"], + "additionalProperties": false + } + }, + "required": ["theme"], + "additionalProperties": false, + "definitions": { + "colorValue": { + "oneOf": [ + { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$", + "description": "Hex color value (same for dark and light)" + }, + { + "type": "integer", + "minimum": 0, + "maximum": 255, + "description": "ANSI color code (0-255, same for dark and light)" + }, + { + "type": "string", + "enum": ["none"], + "description": "No color (uses terminal default)" + }, + { + "type": "string", + "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$", + "description": "Reference to another color in the theme or defs" + }, + { + "type": "object", + "properties": { + "dark": { + "oneOf": [ + { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$", + "description": "Hex color value for dark mode" + }, + { + "type": "integer", + "minimum": 0, + "maximum": 255, + "description": "ANSI color code for dark mode" + }, + { + "type": "string", + "enum": ["none"], + "description": "No color (uses terminal default)" + }, + { + "type": "string", + "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$", + "description": "Reference to another color for dark mode" + } + ] + }, + "light": { + "oneOf": [ + { + "type": "string", + "pattern": "^#[0-9a-fA-F]{6}$", + "description": "Hex color value for light mode" + }, + { + "type": "integer", + "minimum": 0, + "maximum": 255, + "description": "ANSI color code for light mode" + }, + { + "type": "string", + "enum": ["none"], + "description": "No color (uses terminal default)" + }, + { + "type": "string", + "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$", + "description": "Reference to another color for light mode" + } + ] + } + }, + "required": ["dark", "light"], + "additionalProperties": false, + "description": "Separate colors for dark and light modes" + } + ] + } + } +} diff --git a/packages/console/app/src/app.css b/packages/console/app/src/app.css new file mode 100644 index 000000000..c0261c422 --- /dev/null +++ b/packages/console/app/src/app.css @@ -0,0 +1 @@ +@import "./style/index.css"; diff --git a/packages/console/app/src/app.tsx b/packages/console/app/src/app.tsx new file mode 100644 index 000000000..bc3961214 --- /dev/null +++ b/packages/console/app/src/app.tsx @@ -0,0 +1,23 @@ +import { MetaProvider, Title, Meta } from "@solidjs/meta" +import { Router } from "@solidjs/router" +import { FileRoutes } from "@solidjs/start/router" +import { ErrorBoundary, Suspense } from "solid-js" +import "@ibm/plex/css/ibm-plex.css" +import "./app.css" + +export default function App() { + return ( + ( + + opencode + + {props.children} + + )} + > + + + ) +} diff --git a/packages/console/app/src/asset/lander/check.svg b/packages/console/app/src/asset/lander/check.svg new file mode 100644 index 000000000..22de6f2a8 --- /dev/null +++ b/packages/console/app/src/asset/lander/check.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/console/app/src/asset/lander/copy.svg b/packages/console/app/src/asset/lander/copy.svg new file mode 100644 index 000000000..f1baac30a --- /dev/null +++ b/packages/console/app/src/asset/lander/copy.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/console/app/src/asset/lander/screenshot-github.png b/packages/console/app/src/asset/lander/screenshot-github.png new file mode 100644 index 000000000..fda74e641 Binary files /dev/null and b/packages/console/app/src/asset/lander/screenshot-github.png differ diff --git a/packages/console/app/src/asset/lander/screenshot-splash.png b/packages/console/app/src/asset/lander/screenshot-splash.png new file mode 100644 index 000000000..e900673ef Binary files /dev/null and b/packages/console/app/src/asset/lander/screenshot-splash.png differ diff --git a/packages/console/app/src/asset/lander/screenshot-vscode.png b/packages/console/app/src/asset/lander/screenshot-vscode.png new file mode 100644 index 000000000..b8966a6b8 Binary files /dev/null and b/packages/console/app/src/asset/lander/screenshot-vscode.png differ diff --git a/packages/console/app/src/asset/lander/screenshot.png b/packages/console/app/src/asset/lander/screenshot.png new file mode 100644 index 000000000..feb617585 Binary files /dev/null and b/packages/console/app/src/asset/lander/screenshot.png differ diff --git a/packages/console/app/src/asset/logo-ornate-dark.svg b/packages/console/app/src/asset/logo-ornate-dark.svg new file mode 100644 index 000000000..2efda934d --- /dev/null +++ b/packages/console/app/src/asset/logo-ornate-dark.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/packages/console/app/src/asset/logo-ornate-light.svg b/packages/console/app/src/asset/logo-ornate-light.svg new file mode 100644 index 000000000..789223bc4 --- /dev/null +++ b/packages/console/app/src/asset/logo-ornate-light.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/packages/console/app/src/asset/logo.svg b/packages/console/app/src/asset/logo.svg new file mode 100644 index 000000000..cbfcccf51 --- /dev/null +++ b/packages/console/app/src/asset/logo.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/packages/console/app/src/component/icon.tsx b/packages/console/app/src/component/icon.tsx new file mode 100644 index 000000000..a82572e62 --- /dev/null +++ b/packages/console/app/src/component/icon.tsx @@ -0,0 +1,82 @@ +import { JSX } from "solid-js" + +export function IconLogo(props: JSX.SvgSVGAttributes) { + return ( + + + + + + + + + + + + + ) +} + +export function IconCopy(props: JSX.SvgSVGAttributes) { + return ( + + + + + ) +} + +export function IconCheck(props: JSX.SvgSVGAttributes) { + return ( + + + + ) +} + +export function IconCreditCard(props: JSX.SvgSVGAttributes) { + return ( + + + + ) +} diff --git a/packages/console/app/src/component/workspace/billing-section.module.css b/packages/console/app/src/component/workspace/billing-section.module.css new file mode 100644 index 000000000..0bb5709cb --- /dev/null +++ b/packages/console/app/src/component/workspace/billing-section.module.css @@ -0,0 +1,114 @@ +.root { + [data-slot="section-content"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + } + + [data-slot="reload-error"] { + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-4); + padding: var(--space-4); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + + p { + color: var(--color-danger); + font-size: var(--font-size-sm); + line-height: 1.4; + margin: 0; + flex: 1; + } + + [data-slot="create-form"] { + display: flex; + gap: var(--space-2); + margin: 0; + flex-shrink: 0; + } + } + [data-slot="payment"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + padding: var(--space-4); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + min-width: 14.5rem; + width: fit-content; + + @media (max-width: 30rem) { + width: 100%; + } + + [data-slot="credit-card"] { + padding: var(--space-3-5) var(--space-4); + background-color: var(--color-bg-surface); + border-radius: var(--border-radius-sm); + display: flex; + align-items: center; + justify-content: space-between; + + [data-slot="card-icon"] { + display: flex; + align-items: center; + color: var(--color-text-muted); + } + + [data-slot="card-details"] { + display: flex; + align-items: baseline; + gap: var(--space-1); + + [data-slot="secret"] { + position: relative; + bottom: 2px; + font-size: var(--font-size-lg); + color: var(--color-text-muted); + font-weight: 400; + } + + [data-slot="number"] { + font-size: var(--font-size-3xl); + font-weight: 500; + color: var(--color-text); + } + } + } + + [data-slot="button-row"] { + display: flex; + gap: var(--space-2); + align-items: center; + + @media (max-width: 30rem) { + flex-direction: column; + + > button { + width: 100%; + } + } + + [data-slot="create-form"] { + margin: 0; + } + + /* Make Enable Billing button full width when it's the only button */ + > button { + flex: 1; + } + } + } + [data-slot="usage"] { + p { + font-size: var(--font-size-sm); + line-height: 1.5; + color: var(--color-text-secondary); + b { + font-weight: 600; + } + } + } +} diff --git a/packages/console/app/src/component/workspace/billing-section.tsx b/packages/console/app/src/component/workspace/billing-section.tsx new file mode 100644 index 000000000..57316e208 --- /dev/null +++ b/packages/console/app/src/component/workspace/billing-section.tsx @@ -0,0 +1,193 @@ +import { json, query, action, useParams, useAction, createAsync, useSubmission } from "@solidjs/router" +import { createMemo, Show } from "solid-js" +import { Billing } from "@opencode/console-core/billing.js" +import { withActor } from "~/context/auth.withActor" +import { IconCreditCard } from "~/component/icon" +import styles from "./billing-section.module.css" + +const createCheckoutUrl = action(async (workspaceID: string, successUrl: string, cancelUrl: string) => { + "use server" + return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl }), workspaceID) +}, "checkoutUrl") + +const reload = action(async (form: FormData) => { + "use server" + const workspaceID = form.get("workspaceID")?.toString() + if (!workspaceID) return { error: "Workspace ID is required" } + return json(await withActor(() => Billing.reload(), workspaceID), { revalidate: getBillingInfo.key }) +}, "billing.reload") + +const disableReload = action(async (form: FormData) => { + "use server" + const workspaceID = form.get("workspaceID")?.toString() + if (!workspaceID) return { error: "Workspace ID is required" } + return json(await withActor(() => Billing.disableReload(), workspaceID), { revalidate: getBillingInfo.key }) +}, "billing.disableReload") + +const createSessionUrl = action(async (workspaceID: string, returnUrl: string) => { + "use server" + return withActor(() => Billing.generateSessionUrl({ returnUrl }), workspaceID) +}, "sessionUrl") + +const getBillingInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.get() + }, workspaceID) +}, "billing.get") + +export function BillingSection() { + const params = useParams() + // ORIGINAL CODE - COMMENTED OUT FOR TESTING + const balanceInfo = createAsync(() => getBillingInfo(params.id)) + const createCheckoutUrlAction = useAction(createCheckoutUrl) + const createCheckoutUrlSubmission = useSubmission(createCheckoutUrl) + const createSessionUrlAction = useAction(createSessionUrl) + const createSessionUrlSubmission = useSubmission(createSessionUrl) + const disableReloadSubmission = useSubmission(disableReload) + const reloadSubmission = useSubmission(reload) + + // DUMMY DATA FOR TESTING - UNCOMMENT ONE OF THE SCENARIOS BELOW + + // Scenario 1: User has not added billing details and has no balance + // const balanceInfo = () => ({ + // balance: 0, + // paymentMethodLast4: null as string | null, + // reload: false, + // reloadError: null as string | null, + // timeReloadError: null as Date | null, + // }) + + // Scenario 2: User has not added billing details but has a balance + // const balanceInfo = () => ({ + // balance: 1500000000, // $15.00 + // paymentMethodLast4: null as string | null, + // reload: false, + // reloadError: null as string | null, + // timeReloadError: null as Date | null + // }) + + // Scenario 3: User has added billing details (reload enabled) + // const balanceInfo = () => ({ + // balance: 750000000, // $7.50 + // paymentMethodLast4: "4242", + // reload: true, + // reloadError: null as string | null, + // timeReloadError: null as Date | null + // }) + + // Scenario 4: User has billing details but reload failed + // const balanceInfo = () => ({ + // balance: 250000000, // $2.50 + // paymentMethodLast4: "4242", + // reload: true, + // reloadError: "Your card was declined." as string, + // timeReloadError: new Date(Date.now() - 3600000) as Date // 1 hour ago + // }) + + const balanceAmount = createMemo(() => { + return ((balanceInfo()?.balance ?? 0) / 100000000).toFixed(2) + }) + + return ( +
+
+

Billing

+

+ Manage payments methods. Contact us if you have any questions. +

+
+
+ +
+

+ Reload failed at{" "} + {balanceInfo()?.timeReloadError!.toLocaleString("en-US", { + month: "short", + day: "numeric", + hour: "numeric", + minute: "2-digit", + second: "2-digit", + })} + . Reason: {balanceInfo()?.reloadError?.replace(/\.$/, "")}. Please update your payment method and try + again. +

+
+ + +
+
+
+
+
+
+ +
+
+ ----}> + •••• + {balanceInfo()?.paymentMethodLast4} + +
+
+
+ { + const baseUrl = window.location.href + const checkoutUrl = await createCheckoutUrlAction(params.id, baseUrl, baseUrl) + if (checkoutUrl) { + window.location.href = checkoutUrl + } + }} + > + {createCheckoutUrlSubmission.pending ? "Loading..." : "Enable Billing"} + + } + > + +
+ + +
+
+
+
+
+ +

+ You have ${balanceAmount() === "-0.00" ? "0.00" : balanceAmount()} remaining in + your account. You can continue using the API with your remaining balance. +

+
+ +

+ Your current balance is ${balanceAmount() === "-0.00" ? "0.00" : balanceAmount()} + . We'll automatically reload $20 (+$1.23 processing fee) when it reaches $5. +

+
+
+
+
+ ) +} diff --git a/packages/console/app/src/component/workspace/common.tsx b/packages/console/app/src/component/workspace/common.tsx new file mode 100644 index 000000000..f85fd8423 --- /dev/null +++ b/packages/console/app/src/component/workspace/common.tsx @@ -0,0 +1,25 @@ +export function formatDateForTable(date: Date) { + const options: Intl.DateTimeFormatOptions = { + day: "numeric", + month: "short", + hour: "numeric", + minute: "2-digit", + hour12: true, + } + return date.toLocaleDateString("en-GB", options).replace(",", ",") +} + +export function formatDateUTC(date: Date) { + const options: Intl.DateTimeFormatOptions = { + weekday: "short", + year: "numeric", + month: "short", + day: "numeric", + hour: "numeric", + minute: "2-digit", + second: "2-digit", + timeZoneName: "short", + timeZone: "UTC", + } + return date.toLocaleDateString("en-US", options) +} diff --git a/packages/console/app/src/component/workspace/key-section.module.css b/packages/console/app/src/component/workspace/key-section.module.css new file mode 100644 index 000000000..6a1d0c85f --- /dev/null +++ b/packages/console/app/src/component/workspace/key-section.module.css @@ -0,0 +1,172 @@ +.root { + [data-component="empty-state"] { + padding: var(--space-20) var(--space-6); + text-align: center; + border: 1px dashed var(--color-border); + border-radius: var(--border-radius-sm); + display: flex; + flex-direction: column; + gap: var(--space-2); + + p { + line-height: 1.5; + font-size: var(--font-size-sm); + color: var(--color-text-muted); + } + } + + [data-slot="create-form"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + padding: var(--space-4); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + + [data-slot="input-container"] { + display: flex; + flex-direction: column; + gap: var(--space-1); + } + + @media (max-width: 30rem) { + gap: var(--space-2); + } + + input { + flex: 1; + padding: var(--space-2) var(--space-3); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + background-color: var(--color-bg); + color: var(--color-text); + font-size: var(--font-size-sm); + font-family: var(--font-mono); + + &:focus { + outline: none; + border-color: var(--color-accent); + } + + &::placeholder { + color: var(--color-text-disabled); + } + } + + [data-slot="form-actions"] { + display: flex; + gap: var(--space-2); + } + + [data-slot="form-error"] { + color: var(--color-danger); + font-size: var(--font-size-sm); + margin-top: var(--space-1); + line-height: 1.4; + } + } + + [data-slot="api-keys-table"] { + overflow-x: auto; + } + + [data-slot="api-keys-table-element"] { + width: 100%; + border-collapse: collapse; + font-size: var(--font-size-sm); + + thead { + border-bottom: 1px solid var(--color-border); + } + + th { + padding: var(--space-3) var(--space-4); + text-align: left; + font-weight: normal; + color: var(--color-text-muted); + text-transform: uppercase; + } + + td { + padding: var(--space-3) var(--space-4); + border-bottom: 1px solid var(--color-border-muted); + color: var(--color-text-muted); + font-family: var(--font-mono); + + &[data-slot="key-name"] { + color: var(--color-text); + font-family: var(--font-sans); + font-weight: 500; + } + + &[data-slot="key-value"] { + font-family: var(--font-mono); + + button { + display: flex; + align-items: center; + gap: var(--space-2); + padding: var(--space-2) var(--space-3); + font-size: var(--font-size-sm); + font-weight: 400; + border: none; + background-color: transparent; + color: var(--color-text-muted); + font-family: var(--font-mono); + border-radius: var(--border-radius-sm); + cursor: pointer; + transition: all 0.15s ease; + text-transform: none; + + &:hover:not(:disabled) { + background-color: var(--color-bg-surface); + color: var(--color-text); + } + + &:disabled { + cursor: default; + color: var(--color-text); + } + + span { + font-family: inherit; + } + } + } + + &[data-slot="key-date"] { + color: var(--color-text); + } + + &[data-slot="key-actions"] { + font-family: var(--font-sans); + } + } + + tbody tr { + &:last-child td { + border-bottom: none; + } + } + + @media (max-width: 40rem) { + th, + td { + padding: var(--space-2) var(--space-3); + font-size: var(--font-size-xs); + } + + th { + &:nth-child(3) /* Date */ { + display: none; + } + } + + td { + &:nth-child(3) /* Date */ { + display: none; + } + } + } + } +} diff --git a/packages/console/app/src/component/workspace/key-section.tsx b/packages/console/app/src/component/workspace/key-section.tsx new file mode 100644 index 000000000..a2bd380ea --- /dev/null +++ b/packages/console/app/src/component/workspace/key-section.tsx @@ -0,0 +1,182 @@ +import { json, query, action, useParams, createAsync, useSubmission } from "@solidjs/router" +import { createEffect, createSignal, For, Show } from "solid-js" +import { IconCopy, IconCheck } from "~/component/icon" +import { Key } from "@opencode/console-core/key.js" +import { withActor } from "~/context/auth.withActor" +import { createStore } from "solid-js/store" +import { formatDateUTC, formatDateForTable } from "./common" +import styles from "./key-section.module.css" + +const removeKey = action(async (form: FormData) => { + "use server" + const id = form.get("id")?.toString() + if (!id) return { error: "ID is required" } + const workspaceID = form.get("workspaceID")?.toString() + if (!workspaceID) return { error: "Workspace ID is required" } + return json(await withActor(() => Key.remove({ id }), workspaceID), { revalidate: listKeys.key }) +}, "key.remove") + +const createKey = action(async (form: FormData) => { + "use server" + const name = form.get("name")?.toString().trim() + if (!name) return { error: "Name is required" } + const workspaceID = form.get("workspaceID")?.toString() + if (!workspaceID) return { error: "Workspace ID is required" } + return json( + await withActor( + () => + Key.create({ name }) + .then((data) => ({ error: undefined, data })) + .catch((e) => ({ error: e.message as string })), + workspaceID, + ), + { revalidate: listKeys.key }, + ) +}, "key.create") + +const listKeys = query(async (workspaceID: string) => { + "use server" + return withActor(() => Key.list(), workspaceID) +}, "key.list") + +export function KeyCreateForm() { + const params = useParams() + const submission = useSubmission(createKey) + const [store, setStore] = createStore({ show: false }) + + let input: HTMLInputElement + + createEffect(() => { + if (!submission.pending && submission.result && !submission.result.error) { + hide() + } + }) + + function show() { + // submission.clear() does not clear the result in some cases, ie. + // 1. Create key with empty name => error shows + // 2. Put in a key name and creates the key => form hides + // 3. Click add key button again => form shows with the same error if + // submission.clear() is called only once + while (true) { + submission.clear() + if (!submission.result) break + } + setStore("show", true) + input.focus() + } + + function hide() { + setStore("show", false) + } + + return ( + show()}> + Create API Key + + } + > +
+
+ (input = r)} data-component="input" name="name" type="text" placeholder="Enter key name" /> + + {(err) =>
{err()}
} +
+
+ +
+ + +
+
+
+ ) +} + +export function KeySection() { + const params = useParams() + const keys = createAsync(() => listKeys(params.id)) + + function formatKey(key: string) { + if (key.length <= 11) return key + return `${key.slice(0, 7)}...${key.slice(-4)}` + } + + return ( +
+
+

API Keys

+

Manage your API keys for accessing opencode services.

+
+ +
+ +

Create an opencode Gateway API key

+
+ } + > + + + + + + + + + + + + {(key) => { + const [copied, setCopied] = createSignal(false) + // const submission = useSubmission(removeKey, ([fd]) => fd.get("id")?.toString() === key.id) + return ( + + + + + + + ) + }} + + +
NameKeyCreated
{key.name} + + + {formatDateForTable(key.timeCreated)} + +
+ + + +
+
+ + +
+ ) +} diff --git a/packages/console/app/src/component/workspace/monthly-limit-section.module.css b/packages/console/app/src/component/workspace/monthly-limit-section.module.css new file mode 100644 index 000000000..02de058e4 --- /dev/null +++ b/packages/console/app/src/component/workspace/monthly-limit-section.module.css @@ -0,0 +1,102 @@ +.root { + [data-slot="section-content"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + } + + [data-slot="balance"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + padding: var(--space-4); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + min-width: 15rem; + width: fit-content; + + @media (max-width: 30rem) { + width: 100%; + } + + [data-slot="amount"] { + padding: var(--space-3-5) var(--space-4); + background-color: var(--color-bg-surface); + border-radius: var(--border-radius-sm); + display: flex; + align-items: baseline; + gap: var(--space-1); + justify-content: flex-end; + + [data-slot="currency"] { + position: relative; + bottom: 2px; + font-size: var(--font-size-lg); + color: var(--color-text-muted); + font-weight: 400; + } + + [data-slot="value"] { + font-size: var(--font-size-3xl); + font-weight: 500; + color: var(--color-text); + } + } + + [data-slot="create-form"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + margin-top: var(--space-1); + + [data-slot="input-container"] { + display: flex; + flex-direction: column; + gap: var(--space-1); + } + + @media (max-width: 30rem) { + gap: var(--space-2); + } + + input { + flex: 1; + padding: var(--space-2) var(--space-3); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + background-color: var(--color-bg); + color: var(--color-text); + font-size: var(--font-size-sm); + font-family: var(--font-mono); + + &:focus { + outline: none; + border-color: var(--color-accent); + } + + &::placeholder { + color: var(--color-text-disabled); + } + } + + [data-slot="form-actions"] { + display: flex; + gap: var(--space-2); + justify-content: flex-end; + } + + [data-slot="form-error"] { + color: var(--color-danger); + font-size: var(--font-size-sm); + line-height: 1.4; + } + } + } + + [data-slot="usage-status"] { + font-size: var(--font-size-sm); + color: var(--color-text-secondary); + margin: 0; + line-height: 1.4; + } +} diff --git a/packages/console/app/src/component/workspace/monthly-limit-section.tsx b/packages/console/app/src/component/workspace/monthly-limit-section.tsx new file mode 100644 index 000000000..35da774d0 --- /dev/null +++ b/packages/console/app/src/component/workspace/monthly-limit-section.tsx @@ -0,0 +1,139 @@ +import { json, query, action, useParams, createAsync, useSubmission } from "@solidjs/router" +import { createEffect, Show } from "solid-js" +import { createStore } from "solid-js/store" +import { withActor } from "~/context/auth.withActor" +import { Billing } from "@opencode/console-core/billing.js" +import styles from "./monthly-limit-section.module.css" + +const getBillingInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.get() + }, workspaceID) +}, "billing.get") + +const setMonthlyLimit = action(async (form: FormData) => { + "use server" + const limit = form.get("limit")?.toString() + if (!limit) return { error: "Limit is required." } + const numericLimit = parseInt(limit) + if (numericLimit < 0) return { error: "Set a valid monthly limit." } + const workspaceID = form.get("workspaceID")?.toString() + if (!workspaceID) return { error: "Workspace ID is required." } + return json( + await withActor( + () => + Billing.setMonthlyLimit(numericLimit) + .then((data) => ({ error: undefined, data })) + .catch((e) => ({ error: e.message as string })), + workspaceID, + ), + { revalidate: getBillingInfo.key }, + ) +}, "billing.setMonthlyLimit") + +export function MonthlyLimitSection() { + const params = useParams() + const submission = useSubmission(setMonthlyLimit) + const [store, setStore] = createStore({ show: false }) + const balanceInfo = createAsync(() => getBillingInfo(params.id)) + + let input: HTMLInputElement + + createEffect(() => { + if (!submission.pending && submission.result && !submission.result.error) { + hide() + } + }) + + function show() { + // submission.clear() does not clear the result in some cases, ie. + // 1. Create key with empty name => error shows + // 2. Put in a key name and creates the key => form hides + // 3. Click add key button again => form shows with the same error if + // submission.clear() is called only once + while (true) { + submission.clear() + if (!submission.result) break + } + setStore("show", true) + input.focus() + } + + function hide() { + setStore("show", false) + } + + return ( +
+
+

Monthly Limit

+

Set a monthly spending limit for your account.

+
+
+
+
+ {balanceInfo()?.monthlyLimit ? $ : null} + {balanceInfo()?.monthlyLimit ?? "-"} +
+ +
+ (input = r)} + data-component="input" + name="limit" + type="number" + placeholder="50" + /> + + {(err) =>
{err()}
} +
+
+ +
+ + +
+ + } + > + +
+
+ No spending limit set.

}> +

+ Current usage for {new Date().toLocaleDateString("en-US", { month: "long", timeZone: "UTC" })} is $ + {(() => { + const dateLastUsed = balanceInfo()?.timeMonthlyUsageUpdated + if (!dateLastUsed) return "0" + + const current = new Date().toLocaleDateString("en-US", { + year: "numeric", + month: "long", + timeZone: "UTC", + }) + const lastUsed = dateLastUsed.toLocaleDateString("en-US", { + year: "numeric", + month: "long", + timeZone: "UTC", + }) + if (current !== lastUsed) return "0" + return ((balanceInfo()?.monthlyUsage ?? 0) / 100000000).toFixed(2) + })()} + . +

+
+
+
+ ) +} diff --git a/packages/console/app/src/component/workspace/new-user-section.module.css b/packages/console/app/src/component/workspace/new-user-section.module.css new file mode 100644 index 000000000..2edc7cc14 --- /dev/null +++ b/packages/console/app/src/component/workspace/new-user-section.module.css @@ -0,0 +1,163 @@ +.root { + display: flex; + flex-direction: column; + gap: var(--space-8); + padding: var(--space-6); + background-color: var(--color-bg-surface); + border: 1px dashed var(--color-border); + border-radius: var(--border-radius-sm); + + @media (max-width: 30rem) { + gap: var(--space-8); + padding: var(--space-4); + } + + [data-component="feature-grid"] { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); + gap: var(--space-6); + + @media (max-width: 30rem) { + grid-template-columns: 1fr; + gap: var(--space-4); + } + + [data-slot="feature"] { + display: flex; + flex-direction: column; + gap: var(--space-2); + padding: var(--space-4); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + + h3 { + font-size: var(--font-size-sm); + font-weight: 600; + margin: 0; + color: var(--color-text); + text-transform: uppercase; + letter-spacing: -0.025rem; + } + + p { + font-size: var(--font-size-sm); + line-height: 1.5; + margin: 0; + color: var(--color-text-muted); + } + } + } + + [data-component="api-key-highlight"] { + display: flex; + flex-direction: column; + gap: var(--space-6); + + [data-slot="section-title"] { + display: flex; + flex-direction: column; + gap: var(--space-1); + + h2 { + font-size: var(--font-size-md); + font-weight: 600; + line-height: 1.2; + letter-spacing: -0.03125rem; + margin: 0; + color: var(--color-text-secondary); + text-transform: uppercase; + + @media (max-width: 30rem) { + font-size: var(--font-size-md); + } + } + } + + [data-slot="key-display"] { + display: flex; + flex-direction: column; + gap: var(--space-3); + + [data-slot="key-container"] { + display: flex; + gap: var(--space-3); + padding: var(--space-4); + border: 2px solid var(--color-accent); + border-radius: var(--border-radius-sm); + align-items: center; + + @media (max-width: 40rem) { + flex-direction: column; + gap: var(--space-3); + align-items: stretch; + } + + [data-slot="key-value"] { + flex: 1; + font-family: var(--font-mono); + font-size: var(--font-size-sm); + color: var(--color-text); + background-color: var(--color-bg); + padding: var(--space-3); + border-radius: var(--border-radius-sm); + border: 1px solid var(--color-border); + word-break: break-all; + line-height: 1.4; + + @media (max-width: 40rem) { + font-size: var(--font-size-xs); + padding: var(--space-2-5); + } + } + + button { + display: flex; + align-items: center; + gap: var(--space-2); + padding: var(--space-3) var(--space-4); + font-size: var(--font-size-sm); + font-weight: 500; + white-space: nowrap; + min-width: 130px; + + @media (max-width: 40rem) { + justify-content: center; + padding: var(--space-2-5) var(--space-3); + font-size: var(--font-size-xs); + min-width: 96px; + } + } + } + } + } + + [data-component="next-steps"] { + display: flex; + flex-direction: column; + gap: var(--space-6); + + ol { + margin: 0; + padding-left: 0; + display: flex; + flex-direction: column; + gap: var(--space-2); + list-style-position: inside; + + li { + font-size: var(--font-size-md); + line-height: 1.5; + color: var(--color-text-secondary); + + code { + font-family: var(--font-mono); + font-size: var(--font-size-sm); + padding: var(--space-1) var(--space-2); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + color: var(--color-text); + } + } + } + } +} diff --git a/packages/console/app/src/component/workspace/new-user-section.tsx b/packages/console/app/src/component/workspace/new-user-section.tsx new file mode 100644 index 000000000..5909072dd --- /dev/null +++ b/packages/console/app/src/component/workspace/new-user-section.tsx @@ -0,0 +1,97 @@ +import { query, useParams, createAsync } from "@solidjs/router" +import { createMemo, createSignal, Show } from "solid-js" +import { IconCopy, IconCheck } from "~/component/icon" +import { Key } from "@opencode/console-core/key.js" +import { Billing } from "@opencode/console-core/billing.js" +import { withActor } from "~/context/auth.withActor" +import styles from "./new-user-section.module.css" + +const getUsageInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.usages() + }, workspaceID) +}, "usage.list") + +const listKeys = query(async (workspaceID: string) => { + "use server" + return withActor(() => Key.list(), workspaceID) +}, "key.list") + +export function NewUserSection() { + const params = useParams() + const [copiedKey, setCopiedKey] = createSignal(false) + const keys = createAsync(() => listKeys(params.id)) + const usage = createAsync(() => getUsageInfo(params.id)) + const isNew = createMemo(() => { + const keysList = keys() + const usageList = usage() + return keysList?.length === 1 && (!usageList || usageList.length === 0) + }) + const defaultKey = createMemo(() => keys()?.at(-1)?.key) + + return ( + +
+
+
+

Tested & Verified Models

+

We've benchmarked and tested models specifically for coding agents to ensure the best performance.

+
+
+

Highest Quality

+

Access models configured for optimal performance - no downgrades or routing to cheaper providers.

+
+
+

No Lock-in

+

Use Zen with any coding agent, and continue using other providers with opencode whenever you want.

+
+
+ +
+ +
+
+ {defaultKey()} + +
+
+
+
+ +
+
    +
  1. Enable billing
  2. +
  3. + Run opencode auth login and select opencode +
  4. +
  5. Paste your API key
  6. +
  7. + Start opencode and run /models to select a model +
  8. +
+
+
+
+ ) +} diff --git a/packages/console/app/src/component/workspace/payment-section.module.css b/packages/console/app/src/component/workspace/payment-section.module.css new file mode 100644 index 000000000..ea8e2ed42 --- /dev/null +++ b/packages/console/app/src/component/workspace/payment-section.module.css @@ -0,0 +1,72 @@ +.root { + [data-slot="payments-table"] { + overflow-x: auto; + } + + [data-slot="payments-table-element"] { + width: 100%; + border-collapse: collapse; + font-size: var(--font-size-sm); + + thead { + border-bottom: 1px solid var(--color-border); + } + + th { + padding: var(--space-3) var(--space-4); + text-align: left; + font-weight: normal; + color: var(--color-text-muted); + text-transform: uppercase; + } + + td { + padding: var(--space-3) var(--space-4); + border-bottom: 1px solid var(--color-border-muted); + color: var(--color-text-muted); + font-family: var(--font-mono); + + &[data-slot="payment-date"] { + color: var(--color-text); + } + + &[data-slot="payment-id"] { + font-family: var(--font-mono); + font-weight: 400; + color: var(--color-text-muted); + max-width: 200px; + word-break: break-word; + } + + &[data-slot="payment-amount"] { + color: var(--color-text); + } + } + + tbody tr { + &:last-child td { + border-bottom: none; + } + } + + @media (max-width: 40rem) { + th, + td { + padding: var(--space-2) var(--space-3); + font-size: var(--font-size-xs); + } + + th { + &:nth-child(2) /* Payment ID */ { + display: none; + } + } + + td { + &:nth-child(2) /* Payment ID */ { + display: none; + } + } + } + } +} diff --git a/packages/console/app/src/component/workspace/payment-section.tsx b/packages/console/app/src/component/workspace/payment-section.tsx new file mode 100644 index 000000000..7be51a581 --- /dev/null +++ b/packages/console/app/src/component/workspace/payment-section.tsx @@ -0,0 +1,113 @@ +import { Billing } from "@opencode/console-core/billing.js" +import { query, action, useParams, createAsync, useAction } from "@solidjs/router" +import { For } from "solid-js" +import { withActor } from "~/context/auth.withActor" +import { formatDateUTC, formatDateForTable } from "./common" +import styles from "./payment-section.module.css" + +const getPaymentsInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.payments() + }, workspaceID) +}, "payment.list") + +const downloadReceipt = action(async (workspaceID: string, paymentID: string) => { + "use server" + return withActor(() => Billing.generateReceiptUrl({ paymentID }), workspaceID) +}, "receipt.download") + +export function PaymentSection() { + const params = useParams() + // ORIGINAL CODE - COMMENTED OUT FOR TESTING + const payments = createAsync(() => getPaymentsInfo(params.id)) + const downloadReceiptAction = useAction(downloadReceipt) + + // DUMMY DATA FOR TESTING + // const payments = () => [ + // { + // id: "pi_3QK1x2FT9vXn4A6r1234567890", + // paymentID: "pi_3QK1x2FT9vXn4A6r1234567890", + // timeCreated: new Date(Date.now() - 86400000 * 1).toISOString(), // 1 day ago + // amount: 2100000000, // $21.00 ($20 + $1 fee) + // }, + // { + // id: "pi_3QJ8k7FT9vXn4A6r0987654321", + // paymentID: "pi_3QJ8k7FT9vXn4A6r0987654321", + // timeCreated: new Date(Date.now() - 86400000 * 15).toISOString(), // 15 days ago + // amount: 2100000000, // $21.00 + // }, + // { + // id: "pi_3QI5m1FT9vXn4A6r5678901234", + // paymentID: "pi_3QI5m1FT9vXn4A6r5678901234", + // timeCreated: new Date(Date.now() - 86400000 * 32).toISOString(), // 32 days ago + // amount: 2100000000, // $21.00 + // }, + // { + // id: "pi_3QH2n9FT9vXn4A6r3456789012", + // paymentID: "pi_3QH2n9FT9vXn4A6r3456789012", + // timeCreated: new Date(Date.now() - 86400000 * 47).toISOString(), // 47 days ago + // amount: 2100000000, // $21.00 + // }, + // { + // id: "pi_3QG7p4FT9vXn4A6r7890123456", + // paymentID: "pi_3QG7p4FT9vXn4A6r7890123456", + // timeCreated: new Date(Date.now() - 86400000 * 63).toISOString(), // 63 days ago + // amount: 2100000000, // $21.00 + // }, + // ] + + return ( + payments() && + payments()!.length > 0 && ( +
+
+

Payments History

+

Recent payment transactions.

+
+
+ + + + + + + + + + + + {(payment) => { + const date = new Date(payment.timeCreated) + return ( + + + + + + + ) + }} + + +
DatePayment IDAmountReceipt
+ {formatDateForTable(date)} + {payment.id}${((payment.amount ?? 0) / 100000000).toFixed(2)} + +
+
+
+ ) + ) +} diff --git a/packages/console/app/src/component/workspace/usage-section.module.css b/packages/console/app/src/component/workspace/usage-section.module.css new file mode 100644 index 000000000..1a772ba87 --- /dev/null +++ b/packages/console/app/src/component/workspace/usage-section.module.css @@ -0,0 +1,88 @@ +.root { + [data-component="empty-state"] { + padding: var(--space-20) var(--space-6); + text-align: center; + border: 1px dashed var(--color-border); + border-radius: var(--border-radius-sm); + display: flex; + flex-direction: column; + gap: var(--space-2); + + p { + line-height: 1.5; + font-size: var(--font-size-sm); + color: var(--color-text-muted); + } + } + + [data-slot="usage-table"] { + overflow-x: auto; + } + + [data-slot="usage-table-element"] { + width: 100%; + border-collapse: collapse; + font-size: var(--font-size-sm); + + thead { + border-bottom: 1px solid var(--color-border); + } + + th { + padding: var(--space-3) var(--space-4); + text-align: left; + font-weight: normal; + color: var(--color-text-muted); + text-transform: uppercase; + } + + td { + padding: var(--space-3) var(--space-4); + border-bottom: 1px solid var(--color-border-muted); + color: var(--color-text-muted); + font-family: var(--font-mono); + + &[data-slot="usage-date"] { + color: var(--color-text); + } + + &[data-slot="usage-model"] { + font-family: var(--font-sans); + font-weight: 400; + color: var(--color-text-secondary); + max-width: 200px; + word-break: break-word; + } + + &[data-slot="usage-cost"] { + color: var(--color-text); + } + } + + tbody tr { + &:last-child td { + border-bottom: none; + } + } + + @media (max-width: 40rem) { + th, + td { + padding: var(--space-2) var(--space-3); + font-size: var(--font-size-xs); + } + + th { + &:nth-child(2) /* Model */ { + display: none; + } + } + + td { + &:nth-child(2) /* Model */ { + display: none; + } + } + } + } +} diff --git a/packages/console/app/src/component/workspace/usage-section.tsx b/packages/console/app/src/component/workspace/usage-section.tsx new file mode 100644 index 000000000..e68670c6d --- /dev/null +++ b/packages/console/app/src/component/workspace/usage-section.tsx @@ -0,0 +1,128 @@ +import { Billing } from "@opencode/console-core/billing.js" +import { query, useParams, createAsync } from "@solidjs/router" +import { createMemo, For, Show } from "solid-js" +import { formatDateUTC, formatDateForTable } from "./common" +import { withActor } from "~/context/auth.withActor" +import styles from "./usage-section.module.css" + +const getUsageInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.usages() + }, workspaceID) +}, "usage.list") + +export function UsageSection() { + const params = useParams() + // ORIGINAL CODE - COMMENTED OUT FOR TESTING + const usage = createAsync(() => getUsageInfo(params.id)) + + // DUMMY DATA FOR TESTING + // const usage = () => [ + // { + // timeCreated: new Date(Date.now() - 86400000 * 0).toISOString(), // Today + // model: "claude-3-5-sonnet-20241022", + // inputTokens: 1247, + // outputTokens: 423, + // cost: 125400000, // $1.254 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 0.5).toISOString(), // 12 hours ago + // model: "claude-3-haiku-20240307", + // inputTokens: 892, + // outputTokens: 156, + // cost: 23500000, // $0.235 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 1).toISOString(), // Yesterday + // model: "claude-3-5-sonnet-20241022", + // inputTokens: 2134, + // outputTokens: 687, + // cost: 234700000, // $2.347 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 1.3).toISOString(), // 1.3 days ago + // model: "gpt-4o-mini", + // inputTokens: 567, + // outputTokens: 234, + // cost: 8900000, // $0.089 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 2).toISOString(), // 2 days ago + // model: "claude-3-opus-20240229", + // inputTokens: 1893, + // outputTokens: 945, + // cost: 445600000, // $4.456 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 2.7).toISOString(), // 2.7 days ago + // model: "gpt-4o", + // inputTokens: 1456, + // outputTokens: 532, + // cost: 156800000, // $1.568 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 3).toISOString(), // 3 days ago + // model: "claude-3-haiku-20240307", + // inputTokens: 634, + // outputTokens: 89, + // cost: 12300000, // $0.123 + // }, + // { + // timeCreated: new Date(Date.now() - 86400000 * 4).toISOString(), // 4 days ago + // model: "claude-3-5-sonnet-20241022", + // inputTokens: 3245, + // outputTokens: 1123, + // cost: 387200000, // $3.872 + // }, + // ] + + return ( +
+
+

Usage History

+

Recent API usage and costs.

+
+
+ 0} + fallback={ +
+

Make your first API call to get started.

+
+ } + > + + + + + + + + + + + + + {(usage) => { + const date = createMemo(() => new Date(usage.timeCreated)) + return ( + + + + + + + + ) + }} + + +
DateModelInputOutputCost
+ {formatDateForTable(date())} + {usage.model}{usage.inputTokens}{usage.outputTokens}${((usage.cost ?? 0) / 100000000).toFixed(4)}
+
+
+
+ ) +} diff --git a/packages/console/app/src/context/auth.session.ts b/packages/console/app/src/context/auth.session.ts new file mode 100644 index 000000000..609bc364b --- /dev/null +++ b/packages/console/app/src/context/auth.session.ts @@ -0,0 +1,23 @@ +import { useSession } from "vinxi/http" + +export interface AuthSession { + account?: Record< + string, + { + id: string + email: string + } + > + current?: string +} + +export function useAuthSession() { + return useSession({ + password: "0".repeat(32), + name: "auth", + cookie: { + secure: false, + httpOnly: true, + }, + }) +} diff --git a/packages/console/app/src/context/auth.ts b/packages/console/app/src/context/auth.ts new file mode 100644 index 000000000..027885241 --- /dev/null +++ b/packages/console/app/src/context/auth.ts @@ -0,0 +1,83 @@ +import { getRequestEvent } from "solid-js/web" +import { and, Database, eq, inArray } from "@opencode/console-core/drizzle/index.js" +import { WorkspaceTable } from "@opencode/console-core/schema/workspace.sql.js" +import { UserTable } from "@opencode/console-core/schema/user.sql.js" +import { redirect } from "@solidjs/router" +import { AccountTable } from "@opencode/console-core/schema/account.sql.js" +import { Actor } from "@opencode/console-core/actor.js" + +import { createClient } from "@openauthjs/openauth/client" +import { useAuthSession } from "./auth.session" + +export const AuthClient = createClient({ + clientID: "app", + issuer: import.meta.env.VITE_AUTH_URL, +}) + +export const getActor = async (workspace?: string): Promise => { + "use server" + const evt = getRequestEvent() + if (!evt) throw new Error("No request event") + if (evt.locals.actor) return evt.locals.actor + evt.locals.actor = (async () => { + const auth = await useAuthSession() + if (!workspace) { + const account = auth.data.account ?? {} + const current = account[auth.data.current ?? ""] + if (current) { + return { + type: "account", + properties: { + email: current.email, + accountID: current.id, + }, + } + } + if (Object.keys(account).length > 0) { + const current = Object.values(account)[0] + await auth.update((val) => ({ + ...val, + current: current.id, + })) + return { + type: "account", + properties: { + email: current.email, + accountID: current.id, + }, + } + } + return { + type: "public", + properties: {}, + } + } + const accounts = Object.keys(auth.data.account ?? {}) + if (accounts.length) { + const result = await Database.transaction(async (tx) => { + return await tx + .select({ + user: UserTable, + }) + .from(AccountTable) + .innerJoin(UserTable, and(eq(UserTable.email, AccountTable.email))) + .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID)) + .where(and(inArray(AccountTable.id, accounts), eq(WorkspaceTable.id, workspace))) + .limit(1) + .execute() + .then((x) => x[0]) + }) + if (result) { + return { + type: "user", + properties: { + userID: result.user.id, + workspaceID: result.user.workspaceID, + }, + } + } + } + throw redirect("/auth/authorize") + })() + return evt.locals.actor +} diff --git a/packages/console/app/src/context/auth.withActor.ts b/packages/console/app/src/context/auth.withActor.ts new file mode 100644 index 000000000..2cb970269 --- /dev/null +++ b/packages/console/app/src/context/auth.withActor.ts @@ -0,0 +1,7 @@ +import { Actor } from "@opencode/console-core/actor.js" +import { getActor } from "./auth" + +export async function withActor(fn: () => T, workspace?: string) { + const actor = await getActor(workspace) + return Actor.provide(actor.type, actor.properties, fn) +} diff --git a/packages/console/app/src/entry-client.tsx b/packages/console/app/src/entry-client.tsx new file mode 100644 index 000000000..642deacf7 --- /dev/null +++ b/packages/console/app/src/entry-client.tsx @@ -0,0 +1,4 @@ +// @refresh reload +import { mount, StartClient } from "@solidjs/start/client" + +mount(() => , document.getElementById("app")!) diff --git a/packages/console/app/src/entry-server.tsx b/packages/console/app/src/entry-server.tsx new file mode 100644 index 000000000..d5fca6aa5 --- /dev/null +++ b/packages/console/app/src/entry-server.tsx @@ -0,0 +1,28 @@ +// @refresh reload +import { createHandler, StartServer } from "@solidjs/start/server" + +export default createHandler( + () => ( + ( + + + + + + + + {assets} + + +
{children}
+ {scripts} + + + )} + /> + ), + { + mode: "async", + }, +) diff --git a/packages/console/app/src/global.d.ts b/packages/console/app/src/global.d.ts new file mode 100644 index 000000000..dc6f10c22 --- /dev/null +++ b/packages/console/app/src/global.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/console/app/src/middleware.ts b/packages/console/app/src/middleware.ts new file mode 100644 index 000000000..b49473cbe --- /dev/null +++ b/packages/console/app/src/middleware.ts @@ -0,0 +1,5 @@ +import { defineMiddleware } from "vinxi/http" + +export default defineMiddleware({ + onBeforeResponse() {}, +}) diff --git a/packages/console/app/src/routes/[...404].css b/packages/console/app/src/routes/[...404].css new file mode 100644 index 000000000..1edbd0a5a --- /dev/null +++ b/packages/console/app/src/routes/[...404].css @@ -0,0 +1,130 @@ +[data-page="not-found"] { + --color-text: hsl(224, 10%, 10%); + --color-text-secondary: hsl(224, 7%, 46%); + --color-text-dimmed: hsl(224, 6%, 63%); + --color-text-inverted: hsl(0, 0%, 100%); + + --color-border: hsl(224, 6%, 77%); +} + +[data-page="not-found"] { + @media (prefers-color-scheme: dark) { + --color-text: hsl(0, 0%, 100%); + --color-text-secondary: hsl(224, 6%, 66%); + --color-text-dimmed: hsl(224, 7%, 46%); + --color-text-inverted: hsl(224, 10%, 10%); + + --color-border: hsl(224, 6%, 36%); + } +} + +[data-page="not-found"] { + --padding: 3rem; + --vertical-padding: 1.5rem; + --heading-font-size: 1.375rem; + + @media (max-width: 30rem) { + --padding: 1rem; + --vertical-padding: 0.75rem; + --heading-font-size: 1rem; + } + + font-family: var(--font-mono); + color: var(--color-text); + padding: calc(var(--padding) + 1rem); + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + + a { + color: var(--color-text); + text-decoration: underline; + text-underline-offset: var(--space-0-75); + text-decoration-thickness: 1px; + } + + [data-component="content"] { + max-width: 40rem; + width: 100%; + border: 1px solid var(--color-border); + } + + [data-component="top"] { + padding: var(--padding); + display: flex; + flex-direction: column; + align-items: center; + gap: calc(var(--vertical-padding) / 2); + text-align: center; + + [data-slot="logo-link"] { + text-decoration: none; + } + + img { + height: auto; + width: clamp(200px, 85vw, 400px); + } + + [data-slot="logo dark"] { + display: none; + } + + @media (prefers-color-scheme: dark) { + [data-slot="logo light"] { + display: none; + } + [data-slot="logo dark"] { + display: block; + } + } + + [data-slot="title"] { + line-height: 1.25; + font-weight: 500; + text-align: center; + font-size: var(--heading-font-size); + color: var(--color-text); + text-transform: uppercase; + margin: 0; + } + } + + [data-component="actions"] { + border-top: 1px solid var(--color-border); + display: flex; + + [data-slot="action"] { + flex: 1; + text-align: center; + line-height: 1.4; + padding: var(--vertical-padding) 1rem; + text-transform: uppercase; + font-size: 1rem; + + a { + display: block; + width: 100%; + height: 100%; + color: var(--color-text); + text-decoration: underline; + text-underline-offset: var(--space-0-75); + text-decoration-thickness: 1px; + } + } + + [data-slot="action"] + [data-slot="action"] { + border-left: 1px solid var(--color-border); + } + + @media (max-width: 40rem) { + flex-direction: column; + + [data-slot="action"] + [data-slot="action"] { + border-left: none; + border-top: 1px solid var(--color-border); + } + } + } +} diff --git a/packages/console/app/src/routes/[...404].tsx b/packages/console/app/src/routes/[...404].tsx new file mode 100644 index 000000000..ba2842b5a --- /dev/null +++ b/packages/console/app/src/routes/[...404].tsx @@ -0,0 +1,38 @@ +import "./[...404].css" +import { Title } from "@solidjs/meta" +import { HttpStatusCode } from "@solidjs/start" +import logoLight from "../asset/logo-ornate-light.svg" +import logoDark from "../asset/logo-ornate-dark.svg" + +export default function NotFound() { + return ( +
+ Not Found | opencode + +
+
+ + opencode logo light + opencode logo dark + +

404 - Page Not Found

+
+ +
+
+ Home +
+
+ Docs +
+
+ GitHub +
+
+ Discord +
+
+
+
+ ) +} diff --git a/packages/console/app/src/routes/auth/authorize.ts b/packages/console/app/src/routes/auth/authorize.ts new file mode 100644 index 000000000..166466ef8 --- /dev/null +++ b/packages/console/app/src/routes/auth/authorize.ts @@ -0,0 +1,7 @@ +import type { APIEvent } from "@solidjs/start/server" +import { AuthClient } from "~/context/auth" + +export async function GET(input: APIEvent) { + const result = await AuthClient.authorize(new URL("./callback", input.request.url).toString(), "code") + return Response.redirect(result.url, 302) +} diff --git a/packages/console/app/src/routes/auth/callback.ts b/packages/console/app/src/routes/auth/callback.ts new file mode 100644 index 000000000..23025b54d --- /dev/null +++ b/packages/console/app/src/routes/auth/callback.ts @@ -0,0 +1,31 @@ +import { redirect } from "@solidjs/router" +import type { APIEvent } from "@solidjs/start/server" +import { AuthClient } from "~/context/auth" +import { useAuthSession } from "~/context/auth.session" + +export async function GET(input: APIEvent) { + const url = new URL(input.request.url) + const code = url.searchParams.get("code") + if (!code) throw new Error("No code found") + const result = await AuthClient.exchange(code, `${url.origin}${url.pathname}`) + if (result.err) { + throw new Error(result.err.message) + } + const decoded = AuthClient.decode(result.tokens.access, {} as any) + if (decoded.err) throw new Error(decoded.err.message) + const session = await useAuthSession() + const id = decoded.subject.properties.accountID + await session.update((value) => { + return { + ...value, + account: { + [id]: { + id, + email: decoded.subject.properties.email, + }, + }, + current: id, + } + }) + return redirect("/auth") +} diff --git a/packages/console/app/src/routes/auth/index.ts b/packages/console/app/src/routes/auth/index.ts new file mode 100644 index 000000000..2c893185f --- /dev/null +++ b/packages/console/app/src/routes/auth/index.ts @@ -0,0 +1,13 @@ +import { Account } from "@opencode/console-core/account.js" +import { redirect } from "@solidjs/router" +import type { APIEvent } from "@solidjs/start/server" +import { withActor } from "~/context/auth.withActor" + +export async function GET(input: APIEvent) { + try { + const workspaces = await withActor(async () => Account.workspaces()) + return redirect(`/workspace/${workspaces[0].id}`) + } catch { + return redirect("/auth/authorize") + } +} diff --git a/packages/console/app/src/routes/debug/index.ts b/packages/console/app/src/routes/debug/index.ts new file mode 100644 index 000000000..39fa33d90 --- /dev/null +++ b/packages/console/app/src/routes/debug/index.ts @@ -0,0 +1,13 @@ +import type { APIEvent } from "@solidjs/start/server" +import { json } from "@solidjs/router" +import { Database } from "@opencode/console-core/drizzle/index.js" +import { UserTable } from "@opencode/console-core/schema/user.sql.js" + +export async function GET(evt: APIEvent) { + return json({ + data: await Database.use(async (tx) => { + const result = await tx.$count(UserTable) + return result + }), + }) +} diff --git a/packages/console/app/src/routes/discord.ts b/packages/console/app/src/routes/discord.ts new file mode 100644 index 000000000..7088295da --- /dev/null +++ b/packages/console/app/src/routes/discord.ts @@ -0,0 +1,5 @@ +import { redirect } from "@solidjs/router" + +export async function GET() { + return redirect("https://discord.gg/opencode") +} diff --git a/packages/console/app/src/routes/docs/[...path].ts b/packages/console/app/src/routes/docs/[...path].ts new file mode 100644 index 000000000..f07781583 --- /dev/null +++ b/packages/console/app/src/routes/docs/[...path].ts @@ -0,0 +1,20 @@ +import type { APIEvent } from "@solidjs/start/server" + +async function handler(evt: APIEvent) { + const req = evt.request.clone() + const url = new URL(req.url) + const targetUrl = `https://docs.opencode.ai${url.pathname}${url.search}` + const response = await fetch(targetUrl, { + method: req.method, + headers: req.headers, + body: req.body, + }) + return response +} + +export const GET = handler +export const POST = handler +export const PUT = handler +export const DELETE = handler +export const OPTIONS = handler +export const PATCH = handler diff --git a/packages/console/app/src/routes/docs/index.ts b/packages/console/app/src/routes/docs/index.ts new file mode 100644 index 000000000..f07781583 --- /dev/null +++ b/packages/console/app/src/routes/docs/index.ts @@ -0,0 +1,20 @@ +import type { APIEvent } from "@solidjs/start/server" + +async function handler(evt: APIEvent) { + const req = evt.request.clone() + const url = new URL(req.url) + const targetUrl = `https://docs.opencode.ai${url.pathname}${url.search}` + const response = await fetch(targetUrl, { + method: req.method, + headers: req.headers, + body: req.body, + }) + return response +} + +export const GET = handler +export const POST = handler +export const PUT = handler +export const DELETE = handler +export const OPTIONS = handler +export const PATCH = handler diff --git a/packages/console/app/src/routes/index.css b/packages/console/app/src/routes/index.css new file mode 100644 index 000000000..fe95bb7ea --- /dev/null +++ b/packages/console/app/src/routes/index.css @@ -0,0 +1,504 @@ +[data-page="home"] { + --color-text: hsl(224, 10%, 10%); + --color-text-secondary: hsl(224, 7%, 46%); + --color-text-dimmed: hsl(224, 6%, 63%); + --color-text-inverted: hsl(0, 0%, 100%); + + --color-border: hsl(224, 6%, 77%); +} + +[data-page="home"] { + @media (prefers-color-scheme: dark) { + --color-text: hsl(0, 0%, 100%); + --color-text-secondary: hsl(224, 6%, 66%); + --color-text-dimmed: hsl(224, 7%, 46%); + --color-text-inverted: hsl(224, 10%, 10%); + + --color-border: hsl(224, 6%, 36%); + } +} + +[data-page="home"] { + --padding: 3rem; + --vertical-padding: 1.5rem; + --heading-font-size: 1.375rem; + + @media (max-width: 30rem) { + --padding: 1rem; + --vertical-padding: 0.75rem; + --heading-font-size: 1rem; + } + + display: flex; + gap: var(--vertical-padding); + flex-direction: column; + font-family: var(--font-mono); + color: var(--color-text); + padding: calc(var(--padding) + 1rem); + + a { + color: var(--color-text); + text-decoration: underline; + text-underline-offset: var(--space-0-75); + text-decoration-thickness: 1px; + } + + [data-component="content"] { + max-width: 67.5rem; + margin: 0 auto; + border: 1px solid var(--color-border); + } + + [data-component="top"] { + padding: calc(var(--padding) * 1.5) var(--padding) var(--padding); + position: relative; + display: flex; + flex-direction: column; + align-items: center; + gap: calc(var(--vertical-padding) / 2); + + img { + height: auto; + width: clamp(200px, 85vw, 552px); + } + + [data-slot="logo dark"] { + display: none; + } + + @media (prefers-color-scheme: dark) { + [data-slot="logo light"] { + display: none; + } + [data-slot="logo dark"] { + display: block; + } + } + + [data-slot="title"] { + line-height: 1.25; + font-weight: 500; + text-align: center; + font-size: var(--heading-font-size); + color: var(--color-text-secondary); + text-transform: uppercase; + } + + [data-slot="login"] { + position: absolute; + top: 0; + right: 0; + border-width: 0 0 1px 1px; + border-style: solid; + border-color: var(--color-border); + background-color: var(--color-bg); + + @media (max-width: 30rem) { + display: none; + } + + a { + display: block; + padding: 0.5rem 1rem calc(0.5rem + 4px); + } + } + } + + [data-component="cta"] { + border-top: 1px solid var(--color-border); + display: flex; + + & > div + div { + border-left: 1px solid var(--color-border); + } + + [data-slot="left"] { + flex: 0 0 auto; + text-align: center; + line-height: 1.4; + padding: var(--vertical-padding) 2rem; + text-transform: uppercase; + font-size: 1.125rem; + + @media (max-width: 30rem) { + font-size: 1rem; + padding-bottom: calc(var(--vertical-padding) + 4px); + } + + @media (max-width: 30rem) { + padding-left: 0.5rem; + padding-right: 0.5rem; + } + } + + [data-slot="center"] { + display: none; + + @media (max-width: 30rem) { + display: block; + flex: 1; + text-align: center; + padding: var(--vertical-padding) 0.5rem; + border-top: 1px solid var(--color-border); + border-left: none; + } + } + + [data-slot="right"] { + flex: 1; + padding: var(--vertical-padding) 1rem; + } + + @media (max-width: 50rem) { + flex-direction: column; + + [data-slot="right"] { + border-left: none; + border-top: 1px solid var(--color-border); + } + } + + [data-slot="command"] { + all: unset; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + color: var(--color-text-secondary); + font-size: 1.125rem; + font-family: var(--font-mono); + gap: var(--space-2); + width: 100%; + + & > span { + @media (max-width: 24rem) { + font-size: 0.875rem; + } + @media (max-width: 56rem) { + [data-slot="protocol"] { + display: none; + } + } + @media (max-width: 38rem) { + text-align: center; + span:first-child { + display: block; + } + } + } + } + + [data-slot="highlight"] { + color: var(--color-text); + font-weight: 500; + } + } + + [data-component="features"] { + border-top: 1px solid var(--color-border); + padding: var(--padding); + + [data-slot="list"] { + padding-left: var(--space-4); + margin: 0; + list-style: disc; + + li { + margin-bottom: var(--space-4); + line-height: 1.6; + + strong { + text-transform: uppercase; + font-weight: 600; + } + + label { + line-height: 1; + text-transform: uppercase; + font-size: 0.75rem; + letter-spacing: 0.03125rem; + background: var(--color-border); + padding: 0.125rem 0.375rem; + color: var(--color-text-inverted); + } + } + + li:last-child { + margin-bottom: 0; + } + } + } + + [data-component="install"] { + border-top: 1px solid var(--color-border); + display: grid; + grid-template-columns: 1fr 1fr; + grid-template-rows: 1fr 1fr; + + @media (max-width: 40rem) { + grid-template-columns: 1fr; + grid-template-rows: auto; + } + } + + [data-component="method"] { + display: flex; + padding: calc(var(--vertical-padding) / 2) calc(var(--padding) / 2) calc(var(--vertical-padding) / 2 + 0.125rem); + flex-direction: column; + text-align: left; + gap: var(--space-2-5); + + @media (max-width: 30rem) { + gap: 0.3125rem; + } + + @media (max-width: 40rem) { + text-align: left; + } + + &:nth-child(2) { + border-left: 1px solid var(--color-border); + + @media (max-width: 40rem) { + border-left: none; + border-top: 1px solid var(--color-border); + } + } + + &:nth-child(3) { + border-top: 1px solid var(--color-border); + } + + &:nth-child(4) { + border-top: 1px solid var(--color-border); + border-left: 1px solid var(--color-border); + + @media (max-width: 40rem) { + border-left: none; + } + } + + [data-component="title"] { + letter-spacing: -0.03125rem; + text-transform: uppercase; + font-weight: normal; + font-size: 1rem; + flex-shrink: 0; + color: var(--color-text-dimmed); + + @media (max-width: 30rem) { + font-size: 0.75rem; + } + } + + [data-slot="button"] { + all: unset; + cursor: pointer; + display: flex; + align-items: center; + color: var(--color-text-secondary); + gap: var(--space-2-5); + font-size: 1rem; + + @media (max-width: 24rem) { + font-size: 0.875rem; + } + + strong { + color: var(--color-text); + font-weight: 500; + } + + @media (max-width: 40rem) { + justify-content: flex-start; + } + + @media (max-width: 30rem) { + justify-content: center; + } + } + } + + [data-component="screenshots"] { + border-top: 1px solid var(--color-border); + + figure { + flex: 1; + display: flex; + flex-direction: column; + gap: calc(var(--padding) / 4); + padding: calc(var(--padding) / 2); + border-width: 0; + border-style: solid; + border-color: var(--color-border); + min-height: 0; + overflow: hidden; + + & > div, + figcaption { + display: flex; + align-items: center; + } + + & > div { + flex: 1; + min-height: 0; + display: flex; + align-items: center; + justify-content: center; + } + + a { + display: flex; + flex: 1; + min-height: 0; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; + } + + figcaption { + letter-spacing: -0.03125rem; + text-transform: uppercase; + color: var(--color-text-dimmed); + flex-shrink: 0; + + @media (max-width: 30rem) { + font-size: 0.75rem; + } + } + } + + & > [data-slot="left"] figure { + height: var(--images-height); + box-sizing: border-box; + } + + & > [data-slot="right"] figure { + height: calc(var(--images-height) / 2); + box-sizing: border-box; + } + + & > [data-slot="left"] img { + width: 100%; + height: 100%; + min-width: 0; + object-fit: contain; + } + + & > [data-slot="right"] img { + width: 100%; + height: calc(100% - 2rem); + object-fit: contain; + display: block; + } + + @media (max-width: 30rem) { + & { + --images-height: auto; + grid-template-columns: 1fr; + grid-template-rows: auto auto; + } + + & > [data-slot="left"] { + grid-row: 1; + grid-column: 1; + } + + & > [data-slot="right"] { + grid-row: 2; + grid-column: 1; + border-left: none; + border-top: 1px solid var(--color-border); + + & > [data-slot="row1"], + & > [data-slot="row2"] { + height: auto; + } + } + + & > [data-slot="left"] figure, + & > [data-slot="right"] figure { + height: auto; + } + + & > [data-slot="left"] img, + & > [data-slot="right"] img { + width: 100%; + height: auto; + max-height: none; + } + } + } + + [data-component="copy-status"] { + @media (max-width: 38rem) { + display: none; + } + + [data-slot="copy"] { + display: block; + width: var(--space-4); + height: var(--space-4); + color: var(--color-text-dimmed); + + [data-copied] & { + display: none; + } + } + + [data-slot="check"] { + display: none; + width: var(--space-4); + height: var(--space-4); + color: var(--color-text); + + [data-copied] & { + display: block; + } + } + } + + [data-component="footer"] { + border-top: 1px solid var(--color-border); + display: flex; + flex-direction: row; + + [data-slot="cell"] { + flex: 1; + text-align: center; + text-transform: uppercase; + padding: var(--vertical-padding) 0.5rem; + } + + [data-slot="cell"] + [data-slot="cell"] { + border-left: 1px solid var(--color-border); + } + + /* Mobile: third column on its own row */ + @media (max-width: 30rem) { + flex-wrap: wrap; + + [data-slot="cell"]:nth-child(1), + [data-slot="cell"]:nth-child(2) { + flex: 1; + } + + [data-slot="cell"]:nth-child(3) { + flex: 1 0 100%; + border-left: none; + border-top: 1px solid var(--color-border); + } + } + } + + [data-component="legal"] { + color: var(--color-text-dimmed); + text-align: center; + + a { + color: var(--color-text-dimmed); + } + } +} diff --git a/packages/console/app/src/routes/index.tsx b/packages/console/app/src/routes/index.tsx new file mode 100644 index 000000000..e8c1998ae --- /dev/null +++ b/packages/console/app/src/routes/index.tsx @@ -0,0 +1,183 @@ +import "./index.css" +import { Title } from "@solidjs/meta" +import { onCleanup, onMount } from "solid-js" +import logoLight from "../asset/logo-ornate-light.svg" +import logoDark from "../asset/logo-ornate-dark.svg" +import IMG_SPLASH from "../asset/lander/screenshot-splash.png" +import { IconCopy, IconCheck } from "../component/icon" +import { createAsync, query } from "@solidjs/router" +import { getActor } from "~/context/auth" +import { withActor } from "~/context/auth.withActor" +import { Account } from "@opencode/console-core/account.js" + +function CopyStatus() { + return ( +
+ + +
+ ) +} + +const defaultWorkspace = query(async () => { + "use server" + const actor = await getActor() + if (actor.type === "account") { + const workspaces = await withActor(() => Account.workspaces()) + return workspaces[0].id + } +}, "defaultWorkspace") + +export default function Home() { + const workspace = createAsync(() => defaultWorkspace()) + onMount(() => { + const commands = document.querySelectorAll("[data-copy]") + for (const button of commands) { + const callback = () => { + const text = button.textContent + if (text) { + navigator.clipboard.writeText(text) + button.setAttribute("data-copied", "") + setTimeout(() => { + button.removeAttribute("data-copied") + }, 1500) + } + } + button.addEventListener("click", callback) + onCleanup(() => { + button.removeEventListener("click", callback) + }) + } + }) + + return ( +
+ opencode | AI coding agent built for the terminal + +
+
+ opencode logo light + opencode logo dark +

The AI coding agent built for the terminal

+ +
+ +
+ + +
+ +
+
+ +
+
    +
  • + Native TUI A responsive, native, themeable terminal UI +
  • +
  • + LSP enabled Automatically loads the right LSPs for the LLM +
  • +
  • + opencode zen A curated list of models provided by opencode{" "} + +
  • +
  • + Multi-session Start multiple agents in parallel on the same project +
  • +
  • + Shareable links Share a link to any sessions for reference or to debug +
  • +
  • + Claude Pro Log in with Anthropic to use your Claude Pro or Max account +
  • +
  • + Use any model Supports 75+ LLM providers through{" "} + Models.dev, including local models +
  • +
+
+ +
+
+

npm

+ +
+
+

bun

+ +
+
+

homebrew

+ +
+
+

paru

+ +
+
+ +
+
+
opencode TUI with the tokyonight theme
+ + opencode TUI with tokyonight theme + +
+
+ + +
+ +
+ + ©2025 Anomaly Innovations + +
+
+ ) +} diff --git a/packages/console/app/src/routes/s/[id].ts b/packages/console/app/src/routes/s/[id].ts new file mode 100644 index 000000000..3fd1305a0 --- /dev/null +++ b/packages/console/app/src/routes/s/[id].ts @@ -0,0 +1,20 @@ +import type { APIEvent } from "@solidjs/start/server" + +async function handler(evt: APIEvent) { + const req = evt.request.clone() + const url = new URL(req.url) + const targetUrl = `https://docs.opencode.ai/docs${url.pathname}${url.search}` + const response = await fetch(targetUrl, { + method: req.method, + headers: req.headers, + body: req.body, + }) + return response +} + +export const GET = handler +export const POST = handler +export const PUT = handler +export const DELETE = handler +export const OPTIONS = handler +export const PATCH = handler diff --git a/packages/console/app/src/routes/stripe/webhook.ts b/packages/console/app/src/routes/stripe/webhook.ts new file mode 100644 index 000000000..920966286 --- /dev/null +++ b/packages/console/app/src/routes/stripe/webhook.ts @@ -0,0 +1,98 @@ +import { Billing } from "@opencode/console-core/billing.js" +import type { APIEvent } from "@solidjs/start/server" +import { Database, eq, sql } from "@opencode/console-core/drizzle/index.js" +import { BillingTable, PaymentTable } from "@opencode/console-core/schema/billing.sql.js" +import { Identifier } from "@opencode/console-core/identifier.js" +import { centsToMicroCents } from "@opencode/console-core/util/price.js" +import { Actor } from "@opencode/console-core/actor.js" +import { Resource } from "@opencode/console-resource" + +export async function POST(input: APIEvent) { + const body = await Billing.stripe().webhooks.constructEventAsync( + await input.request.text(), + input.request.headers.get("stripe-signature")!, + Resource.STRIPE_WEBHOOK_SECRET.value, + ) + + console.log(body.type, JSON.stringify(body, null, 2)) + if (body.type === "customer.updated") { + // check default payment method changed + const prevInvoiceSettings = body.data.previous_attributes?.invoice_settings ?? {} + if (!("default_payment_method" in prevInvoiceSettings)) return + + const customerID = body.data.object.id + const paymentMethodID = body.data.object.invoice_settings.default_payment_method as string + + if (!customerID) throw new Error("Customer ID not found") + if (!paymentMethodID) throw new Error("Payment method ID not found") + + const paymentMethod = await Billing.stripe().paymentMethods.retrieve(paymentMethodID) + await Database.use(async (tx) => { + await tx + .update(BillingTable) + .set({ + paymentMethodID, + paymentMethodLast4: paymentMethod.card!.last4, + }) + .where(eq(BillingTable.customerID, customerID)) + }) + } + if (body.type === "checkout.session.completed") { + const workspaceID = body.data.object.metadata?.workspaceID + const customerID = body.data.object.customer as string + const paymentID = body.data.object.payment_intent as string + const amount = body.data.object.amount_total + + if (!workspaceID) throw new Error("Workspace ID not found") + if (!customerID) throw new Error("Customer ID not found") + if (!amount) throw new Error("Amount not found") + if (!paymentID) throw new Error("Payment ID not found") + + await Actor.provide("system", { workspaceID }, async () => { + const customer = await Billing.get() + if (customer?.customerID && customer.customerID !== customerID) throw new Error("Customer ID mismatch") + + // set customer metadata + if (!customer?.customerID) { + await Billing.stripe().customers.update(customerID, { + metadata: { + workspaceID, + }, + }) + } + + // get payment method for the payment intent + const paymentIntent = await Billing.stripe().paymentIntents.retrieve(paymentID, { + expand: ["payment_method"], + }) + const paymentMethod = paymentIntent.payment_method + if (!paymentMethod || typeof paymentMethod === "string") throw new Error("Payment method not expanded") + + await Database.transaction(async (tx) => { + await tx + .update(BillingTable) + .set({ + balance: sql`${BillingTable.balance} + ${centsToMicroCents(Billing.CHARGE_AMOUNT)}`, + customerID, + paymentMethodID: paymentMethod.id, + paymentMethodLast4: paymentMethod.card!.last4, + reload: true, + reloadError: null, + timeReloadError: null, + }) + .where(eq(BillingTable.workspaceID, workspaceID)) + await tx.insert(PaymentTable).values({ + workspaceID, + id: Identifier.create("payment"), + amount: centsToMicroCents(Billing.CHARGE_AMOUNT), + paymentID, + customerID, + }) + }) + }) + } + + console.log("finished handling") + + return Response.json("ok", { status: 200 }) +} diff --git a/packages/console/app/src/routes/workspace.css b/packages/console/app/src/routes/workspace.css new file mode 100644 index 000000000..ed94365f0 --- /dev/null +++ b/packages/console/app/src/routes/workspace.css @@ -0,0 +1,127 @@ +[data-page="workspace"] { + line-height: 1; + + /* Common elements */ + button { + padding: var(--space-3) var(--space-4); + border: 1px solid var(--color-border); + border-radius: var(--border-radius-sm); + background-color: var(--color-bg); + color: var(--color-text); + font-size: var(--font-size-sm); + font-family: var(--font-sans); + font-weight: 500; + text-transform: uppercase; + cursor: pointer; + transition: all 0.15s ease; + + &:hover:not(:disabled) { + background-color: var(--color-surface-hover); + border-color: var(--color-accent); + } + + &:active { + transform: translateY(1px); + } + + &:disabled { + opacity: 0.5; + transform: none; + } + + &[data-color="primary"] { + background-color: var(--color-primary); + border-color: var(--color-primary); + color: var(--color-primary-text); + + &:hover:not(:disabled) { + background-color: var(--color-primary-hover); + border-color: var(--color-primary-hover); + } + } + + &[data-color="ghost"] { + background-color: transparent; + border-color: transparent; + color: var(--color-text-muted); + + &:hover:not(:disabled) { + background-color: var(--color-surface-hover); + border-color: var(--color-border); + color: var(--color-text); + } + } + } + + a { + color: var(--color-text); + text-decoration: underline; + text-underline-offset: var(--space-0-75); + text-decoration-thickness: 1px; + } + + /* Workspace Header */ + [data-component="workspace-header"] { + position: sticky; + top: 0; + z-index: 100; + display: flex; + justify-content: space-between; + align-items: center; + padding: var(--space-4) var(--space-4); + border-bottom: 1px solid var(--color-border); + background-color: var(--color-bg); + + @media (max-width: 30rem) { + padding: var(--space-4) var(--space-4); + } + } + + [data-slot="header-brand"] { + flex: 0 0 auto; + padding-top: 4px; + + svg { + width: 138px; + } + + [data-component="site-title"] { + font-size: var(--font-size-lg); + font-weight: 600; + color: var(--color-text); + text-decoration: none; + letter-spacing: -0.02em; + } + } + + [data-slot="header-actions"] { + display: flex; + gap: var(--space-4); + align-items: center; + font-size: var(--font-size-sm); + + [data-slot="user"] { + color: var(--color-text-muted); + } + + @media (max-width: 30rem) { + [data-slot="user"] { + display: none; + } + } + + a, + button { + appearance: none; + background: none; + border: none; + cursor: pointer; + padding: 0; + color: var(--color-text); + text-decoration: underline; + text-underline-offset: var(--space-0-75); + text-decoration-thickness: 1px; + text-transform: uppercase; + } + } +} diff --git a/packages/console/app/src/routes/workspace.tsx b/packages/console/app/src/routes/workspace.tsx new file mode 100644 index 000000000..3aa3f20d3 --- /dev/null +++ b/packages/console/app/src/routes/workspace.tsx @@ -0,0 +1,67 @@ +import "./workspace.css" +import { useAuthSession } from "~/context/auth.session" +import { IconLogo } from "../component/icon" +import { withActor } from "~/context/auth.withActor" +import { + query, + action, + redirect, + createAsync, + RouteSectionProps, + Navigate, + useNavigate, + useParams, + A, +} from "@solidjs/router" +import { User } from "@opencode/console-core/user.js" +import { Actor } from "@opencode/console-core/actor.js" +import { getRequestEvent } from "solid-js/web" + +const getUserInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + const actor = Actor.assert("user") + return await User.fromID(actor.properties.userID) + }, workspaceID) +}, "userInfo") + +const logout = action(async () => { + "use server" + const auth = await useAuthSession() + const event = getRequestEvent() + const current = auth.data.current + if (current) + await auth.update((val) => { + delete val.account?.[current] + const first = Object.keys(val.account ?? {})[0] + val.current = first + event!.locals.actor = undefined + return val + }) + throw redirect("/") +}) + +export default function WorkspaceLayout(props: RouteSectionProps) { + const params = useParams() + const userInfo = createAsync(() => getUserInfo(params.id)) + return ( +
+
+
+ + + +
+
+ {userInfo()?.email} +
+ +
+
+
+
{props.children}
+
+ ) +} diff --git a/packages/console/app/src/routes/workspace/[id].css b/packages/console/app/src/routes/workspace/[id].css new file mode 100644 index 000000000..8b318a19f --- /dev/null +++ b/packages/console/app/src/routes/workspace/[id].css @@ -0,0 +1,115 @@ +[data-page="workspace-[id]"] { + max-width: 64rem; + padding: var(--space-10) var(--space-4); + margin: 0 auto; + width: 100%; + display: flex; + flex-direction: column; + gap: var(--space-10); + + @media (max-width: 30rem) { + padding-top: var(--space-4); + padding-bottom: var(--space-4); + + gap: var(--space-8); + } + + [data-slot="sections"] { + display: flex; + flex-direction: column; + gap: var(--space-16); + + @media (max-width: 30rem) { + gap: var(--space-8); + } + + section { + display: flex; + flex-direction: column; + gap: var(--space-8); + + @media (max-width: 30rem) { + gap: var(--space-6); + } + + /* Section titles */ + [data-slot="section-title"] { + display: flex; + flex-direction: column; + gap: var(--space-1); + + h2 { + font-size: var(--font-size-md); + font-weight: 600; + line-height: 1.2; + letter-spacing: -0.03125rem; + margin: 0; + color: var(--color-text-secondary); + text-transform: uppercase; + + @media (max-width: 30rem) { + font-size: var(--font-size-md); + } + } + + p { + line-height: 1.5; + font-size: var(--font-size-md); + color: var(--color-text-muted); + + a { + color: var(--color-text-muted); + } + + @media (max-width: 30rem) { + font-size: var(--font-size-sm); + } + } + } + } + section:not(:last-child) { + border-bottom: 1px solid var(--color-border); + padding-bottom: var(--space-16); + + @media (max-width: 30rem) { + padding-bottom: var(--space-8); + } + } + } + + /* Title section */ + [data-component="title-section"] { + display: flex; + flex-direction: column; + gap: var(--space-2); + padding-bottom: var(--space-8); + border-bottom: 1px solid var(--color-border); + + @media (max-width: 30rem) { + padding-bottom: var(--space-6); + } + + h1 { + font-size: var(--font-size-2xl); + font-weight: 500; + line-height: 1.2; + letter-spacing: -0.03125rem; + margin: 0; + text-transform: uppercase; + + @media (max-width: 30rem) { + font-size: var(--font-size-xl); + } + } + + p { + line-height: 1.5; + font-size: var(--font-size-md); + color: var(--color-text-muted); + + a { + color: var(--color-text-muted); + } + } + } +} diff --git a/packages/console/app/src/routes/workspace/[id].tsx b/packages/console/app/src/routes/workspace/[id].tsx new file mode 100644 index 000000000..68a706d5d --- /dev/null +++ b/packages/console/app/src/routes/workspace/[id].tsx @@ -0,0 +1,50 @@ +import "./[id].css" +import { Billing } from "@opencode/console-core/billing.js" +import { query, useParams, createAsync } from "@solidjs/router" +import { Show } from "solid-js" +import { withActor } from "~/context/auth.withActor" +import { MonthlyLimitSection } from "~/component/workspace/monthly-limit-section" +import { NewUserSection } from "~/component/workspace/new-user-section" +import { BillingSection } from "~/component/workspace/billing-section" +import { PaymentSection } from "~/component/workspace/payment-section" +import { UsageSection } from "~/component/workspace/usage-section" +import { KeySection } from "~/component/workspace/key-section" + +const getBillingInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.get() + }, workspaceID) +}, "billing.get") + +export default function () { + const params = useParams() + const balanceInfo = createAsync(() => getBillingInfo(params.id)) + + return ( +
+
+

Zen

+

+ Curated list of models provided by opencode.{" "} + + Learn more + + . +

+
+ +
+ + + + + {/**/} + + + + +
+
+ ) +} diff --git a/packages/console/app/src/routes/workspace/index.tsx b/packages/console/app/src/routes/workspace/index.tsx new file mode 100644 index 000000000..e69de29bb diff --git a/packages/console/app/src/routes/zen/handler.ts b/packages/console/app/src/routes/zen/handler.ts new file mode 100644 index 000000000..6065e2f76 --- /dev/null +++ b/packages/console/app/src/routes/zen/handler.ts @@ -0,0 +1,594 @@ +import type { APIEvent } from "@solidjs/start/server" +import path from "node:path" +import { and, Database, eq, isNull, lt, or, sql } from "@opencode/console-core/drizzle/index.js" +import { KeyTable } from "@opencode/console-core/schema/key.sql.js" +import { BillingTable, PaymentTable, UsageTable } from "@opencode/console-core/schema/billing.sql.js" +import { centsToMicroCents } from "@opencode/console-core/util/price.js" +import { Identifier } from "@opencode/console-core/identifier.js" +import { Resource } from "@opencode/console-resource" +import { Billing } from "../../../../core/src/billing" +import { Actor } from "@opencode/console-core/actor.js" + +type ModelCost = { + input: number + output: number + cacheRead?: number + cacheWrite5m?: number + cacheWrite1h?: number +} + +type Model = { + id: string + auth: boolean + cost: ModelCost | ((usage: any) => ModelCost) + headerMappings: Record + providers: Record< + string, + { + api: string + apiKey: string + model: string + weight?: number + } + > +} + +export async function handler( + input: APIEvent, + opts: { + modifyBody?: (body: any) => any + setAuthHeader: (headers: Headers, apiKey: string) => void + parseApiKey: (headers: Headers) => string | undefined + onStreamPart: (chunk: string) => void + getStreamUsage: () => any + normalizeUsage: (body: any) => { + inputTokens: number + outputTokens: number + reasoningTokens?: number + cacheReadTokens?: number + cacheWrite5mTokens?: number + cacheWrite1hTokens?: number + } + }, +) { + class AuthError extends Error {} + class CreditsError extends Error {} + class MonthlyLimitError extends Error {} + class ModelError extends Error {} + + const MODELS: Record = { + "claude-opus-4-1": { + id: "claude-opus-4-1" as const, + auth: true, + cost: { + input: 0.000015, + output: 0.000075, + cacheRead: 0.0000015, + cacheWrite5m: 0.00001875, + cacheWrite1h: 0.00003, + }, + headerMappings: {}, + providers: { + anthropic: { + api: "https://api.anthropic.com", + apiKey: Resource.ANTHROPIC_API_KEY.value, + model: "claude-opus-4-1-20250805", + }, + }, + }, + "claude-sonnet-4": { + id: "claude-sonnet-4" as const, + auth: true, + cost: (usage: any) => { + const totalInputTokens = + usage.inputTokens + usage.cacheReadTokens + usage.cacheWrite5mTokens + usage.cacheWrite1hTokens + return totalInputTokens <= 200_000 + ? { + input: 0.000003, + output: 0.000015, + cacheRead: 0.0000003, + cacheWrite5m: 0.00000375, + cacheWrite1h: 0.000006, + } + : { + input: 0.000006, + output: 0.0000225, + cacheRead: 0.0000006, + cacheWrite5m: 0.0000075, + cacheWrite1h: 0.000012, + } + }, + headerMappings: {}, + providers: { + anthropic: { + api: "https://api.anthropic.com", + apiKey: Resource.ANTHROPIC_API_KEY.value, + model: "claude-sonnet-4-20250514", + }, + }, + }, + "claude-3-5-haiku": { + id: "claude-3-5-haiku" as const, + auth: true, + cost: { + input: 0.0000008, + output: 0.000004, + cacheRead: 0.00000008, + cacheWrite5m: 0.000001, + cacheWrite1h: 0.0000016, + }, + headerMappings: {}, + providers: { + anthropic: { + api: "https://api.anthropic.com", + apiKey: Resource.ANTHROPIC_API_KEY.value, + model: "claude-3-5-haiku-20241022", + }, + }, + }, + "gpt-5": { + id: "gpt-5" as const, + auth: true, + cost: { + input: 0.00000125, + output: 0.00001, + cacheRead: 0.000000125, + }, + headerMappings: {}, + providers: { + openai: { + api: "https://api.openai.com", + apiKey: Resource.OPENAI_API_KEY.value, + model: "gpt-5", + }, + }, + }, + "qwen3-coder": { + id: "qwen3-coder" as const, + auth: true, + cost: { + input: 0.00000045, + output: 0.0000018, + }, + headerMappings: {}, + providers: { + baseten: { + api: "https://inference.baseten.co", + apiKey: Resource.BASETEN_API_KEY.value, + model: "Qwen/Qwen3-Coder-480B-A35B-Instruct", + weight: 4, + }, + fireworks: { + api: "https://api.fireworks.ai/inference", + apiKey: Resource.FIREWORKS_API_KEY.value, + model: "accounts/fireworks/models/qwen3-coder-480b-a35b-instruct", + weight: 1, + }, + }, + }, + "kimi-k2": { + id: "kimi-k2" as const, + auth: true, + cost: { + input: 0.0000006, + output: 0.0000025, + }, + headerMappings: {}, + providers: { + baseten: { + api: "https://inference.baseten.co", + apiKey: Resource.BASETEN_API_KEY.value, + model: "moonshotai/Kimi-K2-Instruct-0905", + //weight: 4, + }, + //fireworks: { + // api: "https://api.fireworks.ai/inference", + // apiKey: Resource.FIREWORKS_API_KEY.value, + // model: "accounts/fireworks/models/kimi-k2-instruct-0905", + // weight: 1, + //}, + }, + }, + "grok-code": { + id: "grok-code" as const, + auth: false, + cost: { + input: 0, + output: 0, + cacheRead: 0, + }, + headerMappings: { + "x-grok-conv-id": "x-opencode-session", + "x-grok-req-id": "x-opencode-request", + }, + providers: { + xai: { + api: "https://api.x.ai", + apiKey: Resource.XAI_API_KEY.value, + model: "grok-code", + }, + }, + }, + // deprecated + "qwen/qwen3-coder": { + id: "qwen/qwen3-coder" as const, + auth: true, + cost: { + input: 0.00000038, + output: 0.00000153, + }, + headerMappings: {}, + providers: { + baseten: { + api: "https://inference.baseten.co", + apiKey: Resource.BASETEN_API_KEY.value, + model: "Qwen/Qwen3-Coder-480B-A35B-Instruct", + weight: 5, + }, + fireworks: { + api: "https://api.fireworks.ai/inference", + apiKey: Resource.FIREWORKS_API_KEY.value, + model: "accounts/fireworks/models/qwen3-coder-480b-a35b-instruct", + weight: 1, + }, + }, + }, + } + + const FREE_WORKSPACES = [ + "wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank + ] + + const logger = { + metric: (values: Record) => { + console.log(`_metric:${JSON.stringify(values)}`) + }, + log: console.log, + debug: (message: string) => { + if (Resource.App.stage === "production") return + console.debug(message) + }, + } + + try { + const url = new URL(input.request.url) + const body = await input.request.json() + logger.debug(JSON.stringify(body)) + logger.metric({ + is_tream: !!body.stream, + session: input.request.headers.get("x-opencode-session"), + request: input.request.headers.get("x-opencode-request"), + }) + const MODEL = validateModel() + const apiKey = await authenticate() + const isFree = FREE_WORKSPACES.includes(apiKey?.workspaceID ?? "") + await checkCreditsAndLimit() + const providerName = selectProvider() + const providerData = MODEL.providers[providerName] + logger.metric({ provider: providerName }) + + // Request to model provider + const startTimestamp = Date.now() + const res = await fetch(path.posix.join(providerData.api, url.pathname.replace(/^\/zen/, "") + url.search), { + method: "POST", + headers: (() => { + const headers = input.request.headers + headers.delete("host") + headers.delete("content-length") + opts.setAuthHeader(headers, providerData.apiKey) + Object.entries(MODEL.headerMappings ?? {}).forEach(([k, v]) => { + headers.set(k, headers.get(v)!) + }) + return headers + })(), + body: JSON.stringify({ + ...(opts.modifyBody?.(body) ?? body), + model: providerData.model, + }), + }) + + // Scrub response headers + const resHeaders = new Headers() + const keepHeaders = ["content-type", "cache-control"] + for (const [k, v] of res.headers.entries()) { + if (keepHeaders.includes(k.toLowerCase())) { + resHeaders.set(k, v) + } + } + + // Handle non-streaming response + if (!body.stream) { + const json = await res.json() + const body = JSON.stringify(json) + logger.metric({ response_length: body.length }) + logger.debug(body) + await trackUsage(json.usage) + await reload() + return new Response(body, { + status: res.status, + statusText: res.statusText, + headers: resHeaders, + }) + } + + // Handle streaming response + const stream = new ReadableStream({ + start(c) { + const reader = res.body?.getReader() + const decoder = new TextDecoder() + let buffer = "" + let responseLength = 0 + + function pump(): Promise { + return ( + reader?.read().then(async ({ done, value }) => { + if (done) { + logger.metric({ response_length: responseLength }) + const usage = opts.getStreamUsage() + if (usage) { + await trackUsage(usage) + await reload() + } + c.close() + return + } + + if (responseLength === 0) { + logger.metric({ time_to_first_byte: Date.now() - startTimestamp }) + } + responseLength += value.length + buffer += decoder.decode(value, { stream: true }) + + const parts = buffer.split("\n\n") + buffer = parts.pop() ?? "" + + for (const part of parts) { + logger.debug(part) + opts.onStreamPart(part.trim()) + } + + c.enqueue(value) + + return pump() + }) || Promise.resolve() + ) + } + + return pump() + }, + }) + + return new Response(stream, { + status: res.status, + statusText: res.statusText, + headers: resHeaders, + }) + + function validateModel() { + if (!(body.model in MODELS)) { + throw new ModelError(`Model ${body.model} not supported`) + } + const model = MODELS[body.model as keyof typeof MODELS] + logger.metric({ model: model.id }) + return model + } + + async function authenticate() { + try { + const apiKey = opts.parseApiKey(input.request.headers) + if (!apiKey) throw new AuthError("Missing API key.") + + const key = await Database.use((tx) => + tx + .select({ + id: KeyTable.id, + workspaceID: KeyTable.workspaceID, + }) + .from(KeyTable) + .where(and(eq(KeyTable.key, apiKey), isNull(KeyTable.timeDeleted))) + .then((rows) => rows[0]), + ) + + if (!key) throw new AuthError("Invalid API key.") + logger.metric({ + api_key: key.id, + workspace: key.workspaceID, + }) + return key + } catch (e) { + // ignore error if model does not require authentication + if (!MODEL.auth) return + throw e + } + } + + async function checkCreditsAndLimit() { + if (!apiKey || !MODEL.auth || isFree) return + + const billing = await Database.use((tx) => + tx + .select({ + balance: BillingTable.balance, + paymentMethodID: BillingTable.paymentMethodID, + monthlyLimit: BillingTable.monthlyLimit, + monthlyUsage: BillingTable.monthlyUsage, + timeMonthlyUsageUpdated: BillingTable.timeMonthlyUsageUpdated, + }) + .from(BillingTable) + .where(eq(BillingTable.workspaceID, apiKey.workspaceID)) + .then((rows) => rows[0]), + ) + + if (!billing.paymentMethodID) throw new CreditsError("No payment method") + if (billing.balance <= 0) throw new CreditsError("Insufficient balance") + if ( + billing.monthlyLimit && + billing.monthlyUsage && + billing.timeMonthlyUsageUpdated && + billing.monthlyUsage >= centsToMicroCents(billing.monthlyLimit * 100) + ) { + const now = new Date() + const currentYear = now.getUTCFullYear() + const currentMonth = now.getUTCMonth() + const dateYear = billing.timeMonthlyUsageUpdated.getUTCFullYear() + const dateMonth = billing.timeMonthlyUsageUpdated.getUTCMonth() + if (currentYear === dateYear && currentMonth === dateMonth) + throw new MonthlyLimitError(`You have reached your monthly spending limit of $${billing.monthlyLimit}.`) + } + } + + function selectProvider() { + const picks = Object.entries(MODEL.providers).flatMap(([name, provider]) => + Array(provider.weight ?? 1).fill(name), + ) + return picks[Math.floor(Math.random() * picks.length)] + } + + async function trackUsage(usage: any) { + const { inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWrite5mTokens, cacheWrite1hTokens } = + opts.normalizeUsage(usage) + + const modelCost = typeof MODEL.cost === "function" ? MODEL.cost(usage) : MODEL.cost + + const inputCost = modelCost.input * inputTokens * 100 + const outputCost = modelCost.output * outputTokens * 100 + const reasoningCost = (() => { + if (!reasoningTokens) return undefined + return modelCost.output * reasoningTokens * 100 + })() + const cacheReadCost = (() => { + if (!cacheReadTokens) return undefined + if (!modelCost.cacheRead) return undefined + return modelCost.cacheRead * cacheReadTokens * 100 + })() + const cacheWrite5mCost = (() => { + if (!cacheWrite5mTokens) return undefined + if (!modelCost.cacheWrite5m) return undefined + return modelCost.cacheWrite5m * cacheWrite5mTokens * 100 + })() + const cacheWrite1hCost = (() => { + if (!cacheWrite1hTokens) return undefined + if (!modelCost.cacheWrite1h) return undefined + return modelCost.cacheWrite1h * cacheWrite1hTokens * 100 + })() + const totalCostInCent = + inputCost + + outputCost + + (reasoningCost ?? 0) + + (cacheReadCost ?? 0) + + (cacheWrite5mCost ?? 0) + + (cacheWrite1hCost ?? 0) + + logger.metric({ + "tokens.input": inputTokens, + "tokens.output": outputTokens, + "tokens.reasoning": reasoningTokens, + "tokens.cache_read": cacheReadTokens, + "tokens.cache_write_5m": cacheWrite5mTokens, + "tokens.cache_write_1h": cacheWrite1hTokens, + "cost.input": Math.round(inputCost), + "cost.output": Math.round(outputCost), + "cost.reasoning": reasoningCost ? Math.round(reasoningCost) : undefined, + "cost.cache_read": cacheReadCost ? Math.round(cacheReadCost) : undefined, + "cost.cache_write_5m": cacheWrite5mCost ? Math.round(cacheWrite5mCost) : undefined, + "cost.cache_write_1h": cacheWrite1hCost ? Math.round(cacheWrite1hCost) : undefined, + "cost.total": Math.round(totalCostInCent), + }) + + if (!apiKey) return + + const cost = isFree ? 0 : centsToMicroCents(totalCostInCent) + await Database.transaction(async (tx) => { + await tx.insert(UsageTable).values({ + workspaceID: apiKey.workspaceID, + id: Identifier.create("usage"), + model: MODEL.id, + provider: providerName, + inputTokens, + outputTokens, + reasoningTokens, + cacheReadTokens, + cacheWrite5mTokens, + cacheWrite1hTokens, + cost, + }) + await tx + .update(BillingTable) + .set({ + balance: sql`${BillingTable.balance} - ${cost}`, + monthlyUsage: sql` + CASE + WHEN MONTH(${BillingTable.timeMonthlyUsageUpdated}) = MONTH(now()) AND YEAR(${BillingTable.timeMonthlyUsageUpdated}) = YEAR(now()) THEN ${BillingTable.monthlyUsage} + ${cost} + ELSE ${cost} + END + `, + timeMonthlyUsageUpdated: sql`now()`, + }) + .where(eq(BillingTable.workspaceID, apiKey.workspaceID)) + }) + + await Database.use((tx) => + tx + .update(KeyTable) + .set({ timeUsed: sql`now()` }) + .where(eq(KeyTable.id, apiKey.id)), + ) + } + + async function reload() { + if (!apiKey) return + + const lock = await Database.use((tx) => + tx + .update(BillingTable) + .set({ + timeReloadLockedTill: sql`now() + interval 1 minute`, + }) + .where( + and( + eq(BillingTable.workspaceID, apiKey.workspaceID), + eq(BillingTable.reload, true), + lt(BillingTable.balance, centsToMicroCents(Billing.CHARGE_THRESHOLD)), + or(isNull(BillingTable.timeReloadLockedTill), lt(BillingTable.timeReloadLockedTill, sql`now()`)), + ), + ), + ) + if (lock.rowsAffected === 0) return + + await Actor.provide("system", { workspaceID: apiKey.workspaceID }, async () => { + await Billing.reload() + }) + } + } catch (error: any) { + logger.metric({ + "error.type": error.constructor.name, + "error.message": error.message, + }) + + // Note: both top level "type" and "error.type" fields are used by the @ai-sdk/anthropic client to render the error message. + if ( + error instanceof AuthError || + error instanceof CreditsError || + error instanceof MonthlyLimitError || + error instanceof ModelError + ) + return new Response( + JSON.stringify({ + type: "error", + error: { type: error.constructor.name, message: error.message }, + }), + { status: 401 }, + ) + + return new Response( + JSON.stringify({ + type: "error", + error: { + type: "error", + message: error.message, + }, + }), + { status: 500 }, + ) + } +} diff --git a/packages/console/app/src/routes/zen/v1/chat/completions.ts b/packages/console/app/src/routes/zen/v1/chat/completions.ts new file mode 100644 index 000000000..801557324 --- /dev/null +++ b/packages/console/app/src/routes/zen/v1/chat/completions.ts @@ -0,0 +1,54 @@ +import type { APIEvent } from "@solidjs/start/server" +import { handler } from "~/routes/zen/handler" + +type Usage = { + prompt_tokens?: number + completion_tokens?: number + total_tokens?: number + prompt_tokens_details?: { + text_tokens?: number + audio_tokens?: number + image_tokens?: number + cached_tokens?: number + } + completion_tokens_details?: { + reasoning_tokens?: number + audio_tokens?: number + accepted_prediction_tokens?: number + rejected_prediction_tokens?: number + } +} + +export function POST(input: APIEvent) { + let usage: Usage + return handler(input, { + modifyBody: (body: any) => ({ + ...body, + ...(body.stream ? { stream_options: { include_usage: true } } : {}), + }), + setAuthHeader: (headers: Headers, apiKey: string) => { + headers.set("authorization", `Bearer ${apiKey}`) + }, + parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1], + onStreamPart: (chunk: string) => { + if (!chunk.startsWith("data: ")) return + + let json + try { + json = JSON.parse(chunk.slice(6)) as { usage?: Usage } + } catch (e) { + return + } + + if (!json.usage) return + usage = json.usage + }, + getStreamUsage: () => usage, + normalizeUsage: (usage: Usage) => ({ + inputTokens: usage.prompt_tokens ?? 0, + outputTokens: usage.completion_tokens ?? 0, + reasoningTokens: usage.completion_tokens_details?.reasoning_tokens ?? undefined, + cacheReadTokens: usage.prompt_tokens_details?.cached_tokens ?? undefined, + }), + }) +} diff --git a/packages/console/app/src/routes/zen/v1/messages.ts b/packages/console/app/src/routes/zen/v1/messages.ts new file mode 100644 index 000000000..1fd85d5c7 --- /dev/null +++ b/packages/console/app/src/routes/zen/v1/messages.ts @@ -0,0 +1,61 @@ +import type { APIEvent } from "@solidjs/start/server" +import { handler } from "~/routes/zen/handler" + +type Usage = { + cache_creation?: { + ephemeral_5m_input_tokens?: number + ephemeral_1h_input_tokens?: number + } + cache_creation_input_tokens?: number + cache_read_input_tokens?: number + input_tokens?: number + output_tokens?: number + server_tool_use?: { + web_search_requests?: number + } +} + +export function POST(input: APIEvent) { + let usage: Usage + return handler(input, { + modifyBody: (body: any) => ({ + ...body, + service_tier: "standard_only", + }), + setAuthHeader: (headers: Headers, apiKey: string) => headers.set("x-api-key", apiKey), + parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined, + onStreamPart: (chunk: string) => { + const data = chunk.split("\n")[1] + if (!data.startsWith("data: ")) return + + let json + try { + json = JSON.parse(data.slice(6)) as { usage?: Usage } + } catch (e) { + return + } + + if (!json.usage) return + usage = { + ...usage, + ...json.usage, + cache_creation: { + ...usage?.cache_creation, + ...json.usage.cache_creation, + }, + server_tool_use: { + ...usage?.server_tool_use, + ...json.usage.server_tool_use, + }, + } + }, + getStreamUsage: () => usage, + normalizeUsage: (usage: Usage) => ({ + inputTokens: usage.input_tokens ?? 0, + outputTokens: usage.output_tokens ?? 0, + cacheReadTokens: usage.cache_read_input_tokens ?? undefined, + cacheWrite5mTokens: usage.cache_creation?.ephemeral_5m_input_tokens ?? undefined, + cacheWrite1hTokens: usage.cache_creation?.ephemeral_1h_input_tokens ?? undefined, + }), + }) +} diff --git a/packages/console/app/src/routes/zen/v1/responses.ts b/packages/console/app/src/routes/zen/v1/responses.ts new file mode 100644 index 000000000..486c129b9 --- /dev/null +++ b/packages/console/app/src/routes/zen/v1/responses.ts @@ -0,0 +1,52 @@ +import type { APIEvent } from "@solidjs/start/server" +import { handler } from "~/routes/zen/handler" + +type Usage = { + input_tokens?: number + input_tokens_details?: { + cached_tokens?: number + } + output_tokens?: number + output_tokens_details?: { + reasoning_tokens?: number + } + total_tokens?: number +} + +export function POST(input: APIEvent) { + let usage: Usage + return handler(input, { + setAuthHeader: (headers: Headers, apiKey: string) => { + headers.set("authorization", `Bearer ${apiKey}`) + }, + parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1], + onStreamPart: (chunk: string) => { + const [event, data] = chunk.split("\n") + if (event !== "event: response.completed") return + if (!data.startsWith("data: ")) return + + let json + try { + json = JSON.parse(data.slice(6)) as { response?: { usage?: Usage } } + } catch (e) { + return + } + + if (!json.response?.usage) return + usage = json.response.usage + }, + getStreamUsage: () => usage, + normalizeUsage: (usage: Usage) => { + const inputTokens = usage.input_tokens ?? 0 + const outputTokens = usage.output_tokens ?? 0 + const reasoningTokens = usage.output_tokens_details?.reasoning_tokens ?? undefined + const cacheReadTokens = usage.input_tokens_details?.cached_tokens ?? undefined + return { + inputTokens: inputTokens - (cacheReadTokens ?? 0), + outputTokens: outputTokens - (reasoningTokens ?? 0), + reasoningTokens, + cacheReadTokens, + } + }, + }) +} diff --git a/packages/console/app/src/style/base.css b/packages/console/app/src/style/base.css new file mode 100644 index 000000000..a4847ed43 --- /dev/null +++ b/packages/console/app/src/style/base.css @@ -0,0 +1,9 @@ +html { + line-height: 1; + background-color: var(--color-bg); + color: var(--color-text); +} + +body { + font-family: var(--font-sans); +} diff --git a/packages/console/app/src/style/component/button.css b/packages/console/app/src/style/component/button.css new file mode 100644 index 000000000..d10f7af53 --- /dev/null +++ b/packages/console/app/src/style/component/button.css @@ -0,0 +1,102 @@ +[data-component="button"] { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--space-2); + padding: var(--space-3) var(--space-4); + border: 1px solid transparent; + border-radius: var(--space-2); + font-family: var(--font-sans); + font-size: var(--font-size-md); + font-weight: 500; + line-height: 1.25; + cursor: pointer; + transition: all 0.2s ease-in-out; + text-decoration: none; + user-select: none; + + &:disabled { + opacity: 0.5; + cursor: not-allowed; + } + + &:focus { + outline: none; + box-shadow: 0 0 0 2px var(--color-primary); + } + + &[data-color="primary"] { + background-color: var(--color-primary); + color: var(--color-primary-text); + border-color: var(--color-primary); + + &:hover:not(:disabled) { + background-color: var(--color-primary-hover); + border-color: var(--color-primary-hover); + } + + &:active:not(:disabled) { + background-color: var(--color-primary-active); + border-color: var(--color-primary-active); + } + } + + &[data-color="danger"] { + background-color: var(--color-danger); + color: var(--color-danger-text); + border-color: var(--color-danger); + + &:hover:not(:disabled) { + background-color: var(--color-danger-hover); + border-color: var(--color-danger-hover); + } + + &:active:not(:disabled) { + background-color: var(--color-danger-active); + border-color: var(--color-danger-active); + } + + &:focus { + box-shadow: 0 0 0 2px var(--color-danger); + } + } + + &[data-color="warning"] { + background-color: var(--color-warning); + color: var(--color-warning-text); + border-color: var(--color-warning); + + &:hover:not(:disabled) { + background-color: var(--color-warning-hover); + border-color: var(--color-warning-hover); + } + + &:active:not(:disabled) { + background-color: var(--color-warning-active); + border-color: var(--color-warning-active); + } + + &:focus { + box-shadow: 0 0 0 2px var(--color-warning); + } + } + + &[data-size="small"] { + padding: var(--space-2) var(--space-3); + font-size: var(--font-size-sm); + gap: var(--space-1-5); + } + + &[data-size="large"] { + padding: var(--space-4) var(--space-6); + font-size: var(--font-size-lg); + gap: var(--space-3); + } + + [data-slot="icon"] { + display: flex; + align-items: center; + width: 1em; + height: 1em; + } +} diff --git a/packages/console/app/src/style/index.css b/packages/console/app/src/style/index.css new file mode 100644 index 000000000..832a901e8 --- /dev/null +++ b/packages/console/app/src/style/index.css @@ -0,0 +1,8 @@ +@import "./token/color.css"; +@import "./token/font.css"; +@import "./token/space.css"; + +@import "./component/button.css"; + +@import "./reset.css"; +@import "./base.css"; diff --git a/packages/console/app/src/style/reset.css b/packages/console/app/src/style/reset.css new file mode 100644 index 000000000..d331ed724 --- /dev/null +++ b/packages/console/app/src/style/reset.css @@ -0,0 +1,76 @@ +/* 1. Use a more-intuitive box-sizing model */ +*, +*::before, +*::after { + box-sizing: border-box; +} + +/* 2. Remove default margin */ +* { + margin: 0; +} + +/* 3. Enable keyword animations */ +@media (prefers-reduced-motion: no-preference) { + html { + interpolate-size: allow-keywords; + } +} + +body { + /* 4. Add accessible line-height */ + line-height: 1.5; + /* 5. Improve text rendering */ + -webkit-font-smoothing: antialiased; +} + +/* 6. Improve media defaults */ +img, +picture, +video, +canvas, +svg { + display: block; + max-width: 100%; +} + +/* 7. Inherit fonts for form controls */ +input, +button, +textarea, +select { + font: inherit; +} + +/* 8. Avoid text overflows */ +p, +h1, +h2, +h3, +h4, +h5, +h6 { + overflow-wrap: break-word; +} + +/* 9. Improve line wrapping */ +p { + text-wrap: pretty; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + text-wrap: balance; +} + +/* + 10. Create a root stacking context +*/ +#root, +#__next { + isolation: isolate; +} diff --git a/packages/console/app/src/style/token/color.css b/packages/console/app/src/style/token/color.css new file mode 100644 index 000000000..f1a097d2f --- /dev/null +++ b/packages/console/app/src/style/token/color.css @@ -0,0 +1,91 @@ +:root { + --color-white: #ffffff; + --color-black: #000000; + + /* Default light theme colors */ + --color-bg: #ffffff; + --color-bg-surface: #f5f5f7; + --color-bg-elevated: #ffffff; + + --color-text: #1d1d1f; + --color-text-secondary: #424245; + --color-text-muted: #6e6e73; + --color-text-disabled: #86868b; + + --color-accent: #007aff; + --color-accent-hover: #0056b3; + --color-accent-active: #004085; + + --color-success: #30d158; + --color-warning: #ff9f0a; + --color-danger: #ff3b30; + + --color-border: #d2d2d7; + --color-border-muted: #e5e5ea; + + /* Button colors */ + --color-primary: var(--color-accent); + --color-primary-hover: var(--color-accent-hover); + --color-primary-active: var(--color-accent-active); + --color-primary-text: #ffffff; + + --color-danger: #ff3b30; + --color-danger-hover: #d70015; + --color-danger-active: #a50011; + --color-danger-text: #ffffff; + + --color-warning: #ff9f0a; + --color-warning-hover: #cc7f08; + --color-warning-active: #995f06; + --color-warning-text: #000000; + + /* Surface colors */ + --color-surface: var(--color-bg-surface); + --color-surface-hover: var(--color-bg-elevated); + --color-surface-border: var(--color-border); +} + +@media (prefers-color-scheme: dark) { + :root { + --color-bg: #0c0c0e; + --color-bg-surface: #161618; + --color-bg-elevated: #1c1c1f; + + --color-text: #ffffff; + --color-text-secondary: #c7c7cc; + --color-text-muted: #a1a1a6; + --color-text-disabled: #68686f; + + --color-accent: #007aff; + --color-accent-hover: #0056b3; + --color-accent-active: #004085; + + --color-success: #30d158; + --color-warning: #ff9f0a; + --color-danger: #ff453a; + + --color-border: #38383a; + --color-border-muted: #2c2c2e; + + /* Button colors */ + --color-primary: var(--color-accent); + --color-primary-hover: var(--color-accent-hover); + --color-primary-active: var(--color-accent-active); + --color-primary-text: #ffffff; + + --color-danger: #ff453a; + --color-danger-hover: #d70015; + --color-danger-active: #a50011; + --color-danger-text: #ffffff; + + --color-warning: #ff9f0a; + --color-warning-hover: #cc7f08; + --color-warning-active: #995f06; + --color-warning-text: #000000; + + /* Surface colors */ + --color-surface: var(--color-bg-surface); + --color-surface-hover: var(--color-bg-elevated); + --color-surface-border: var(--color-border); + } +} diff --git a/packages/console/app/src/style/token/font.css b/packages/console/app/src/style/token/font.css new file mode 100644 index 000000000..67143e662 --- /dev/null +++ b/packages/console/app/src/style/token/font.css @@ -0,0 +1,20 @@ +body { + --font-size-2xs: 0.6875rem; + --font-size-xs: 0.75rem; + --font-size-sm: 0.8125rem; + --font-size-md: 0.9375rem; + --font-size-lg: 1.125rem; + --font-size-xl: 1.25rem; + --font-size-2xl: 1.5rem; + --font-size-3xl: 1.875rem; + --font-size-4xl: 2.25rem; + --font-size-5xl: 3rem; + --font-size-6xl: 3.75rem; + --font-size-7xl: 4.5rem; + --font-size-8xl: 6rem; + --font-size-9xl: 8rem; + + --font-mono: + "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + --font-sans: var(--font-mono); +} diff --git a/packages/console/app/src/style/token/space.css b/packages/console/app/src/style/token/space.css new file mode 100644 index 000000000..7e1a1b397 --- /dev/null +++ b/packages/console/app/src/style/token/space.css @@ -0,0 +1,46 @@ +body { + --space-0: 0; + --space-px: 1px; + --space-0-5: 0.125rem; + --space-0-75: 0.1875rem; + --space-1: 0.25rem; + --space-1-5: 0.375rem; + --space-2: 0.5rem; + --space-2-5: 0.625rem; + --space-3: 0.75rem; + --space-3-5: 0.875rem; + --space-4: 1rem; + --space-4-5: 1.125rem; + --space-5: 1.25rem; + --space-6: 1.5rem; + --space-7: 1.75rem; + --space-8: 2rem; + --space-9: 2.25rem; + --space-10: 2.5rem; + --space-11: 2.75rem; + --space-12: 3rem; + --space-14: 3.5rem; + --space-16: 4rem; + --space-17: 4.25rem; + --space-18: 4.5rem; + --space-19: 4.75rem; + --space-20: 5rem; + --space-24: 6rem; + --space-28: 7rem; + --space-32: 8rem; + --space-36: 9rem; + --space-40: 10rem; + --space-44: 11rem; + --space-48: 12rem; + --space-52: 13rem; + --space-56: 14rem; + --space-60: 15rem; + --space-64: 16rem; + --space-72: 18rem; + --space-80: 20rem; + --space-96: 24rem; + + --border-radius-sm: 0.1875rem; + --border-radius-md: 0.3125rem; + --border-radius-lg: 0.5rem; +} diff --git a/packages/console/app/sst-env.d.ts b/packages/console/app/sst-env.d.ts new file mode 100644 index 000000000..9b9de7327 --- /dev/null +++ b/packages/console/app/sst-env.d.ts @@ -0,0 +1,9 @@ +/* This file is auto-generated by SST. Do not edit. */ +/* tslint:disable */ +/* eslint-disable */ +/* deno-fmt-ignore-file */ + +/// + +import "sst" +export {} \ No newline at end of file diff --git a/packages/console/app/tsconfig.json b/packages/console/app/tsconfig.json new file mode 100644 index 000000000..07148a458 --- /dev/null +++ b/packages/console/app/tsconfig.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "skipLibCheck": true, + "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/packages/console/core/drizzle.config.ts b/packages/console/core/drizzle.config.ts new file mode 100644 index 000000000..0b7c4417e --- /dev/null +++ b/packages/console/core/drizzle.config.ts @@ -0,0 +1,20 @@ +import { Resource } from "sst" +import { defineConfig } from "drizzle-kit" + +export default defineConfig({ + out: "./migrations/", + strict: true, + schema: ["./src/**/*.sql.ts"], + verbose: true, + dialect: "mysql", + dbCredentials: { + database: Resource.Database.database, + host: Resource.Database.host, + user: Resource.Database.username, + password: Resource.Database.password, + port: Resource.Database.port, + ssl: { + rejectUnauthorized: false, + }, + }, +}) diff --git a/packages/console/core/migrations/0000_fluffy_raza.sql b/packages/console/core/migrations/0000_fluffy_raza.sql new file mode 100644 index 000000000..8e8173346 --- /dev/null +++ b/packages/console/core/migrations/0000_fluffy_raza.sql @@ -0,0 +1,89 @@ +CREATE TABLE `account` ( + `id` varchar(30) NOT NULL, + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + `email` varchar(255) NOT NULL, + CONSTRAINT `email` UNIQUE(`email`) +); +--> statement-breakpoint +CREATE TABLE `billing` ( + `id` varchar(30) NOT NULL, + `workspace_id` varchar(30) NOT NULL, + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + `customer_id` varchar(255), + `payment_method_id` varchar(255), + `payment_method_last4` varchar(4), + `balance` bigint NOT NULL, + `reload` boolean, + CONSTRAINT `billing_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`) +); +--> statement-breakpoint +CREATE TABLE `payment` ( + `id` varchar(30) NOT NULL, + `workspace_id` varchar(30) NOT NULL, + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + `customer_id` varchar(255), + `payment_id` varchar(255), + `amount` bigint NOT NULL, + CONSTRAINT `payment_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`) +); +--> statement-breakpoint +CREATE TABLE `usage` ( + `id` varchar(30) NOT NULL, + `workspace_id` varchar(30) NOT NULL, + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + `model` varchar(255) NOT NULL, + `input_tokens` int NOT NULL, + `output_tokens` int NOT NULL, + `reasoning_tokens` int, + `cache_read_tokens` int, + `cache_write_tokens` int, + `cost` bigint NOT NULL, + CONSTRAINT `usage_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`) +); +--> statement-breakpoint +CREATE TABLE `key` ( + `id` varchar(30) NOT NULL, + `workspace_id` varchar(30) NOT NULL, + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + `user_id` text NOT NULL, + `name` varchar(255) NOT NULL, + `key` varchar(255) NOT NULL, + `time_used` timestamp(3), + CONSTRAINT `key_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`), + CONSTRAINT `global_key` UNIQUE(`key`) +); +--> statement-breakpoint +CREATE TABLE `user` ( + `id` varchar(30) NOT NULL, + `workspace_id` varchar(30) NOT NULL, + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + `email` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `time_seen` timestamp(3), + `color` int, + CONSTRAINT `user_workspace_id_id_pk` PRIMARY KEY(`workspace_id`,`id`), + CONSTRAINT `user_email` UNIQUE(`workspace_id`,`email`) +); +--> statement-breakpoint +CREATE TABLE `workspace` ( + `id` varchar(30) NOT NULL, + `slug` varchar(255), + `name` varchar(255), + `time_created` timestamp(3) NOT NULL DEFAULT (now()), + `time_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), + `time_deleted` timestamp(3), + CONSTRAINT `workspace_id` PRIMARY KEY(`id`), + CONSTRAINT `slug` UNIQUE(`slug`) +); diff --git a/packages/console/core/migrations/0001_serious_whistler.sql b/packages/console/core/migrations/0001_serious_whistler.sql new file mode 100644 index 000000000..4a9a03d63 --- /dev/null +++ b/packages/console/core/migrations/0001_serious_whistler.sql @@ -0,0 +1,2 @@ +ALTER TABLE `key` ADD `actor` json;--> statement-breakpoint +ALTER TABLE `key` DROP COLUMN `user_id`; \ No newline at end of file diff --git a/packages/console/core/migrations/0002_violet_loners.sql b/packages/console/core/migrations/0002_violet_loners.sql new file mode 100644 index 000000000..17273356c --- /dev/null +++ b/packages/console/core/migrations/0002_violet_loners.sql @@ -0,0 +1 @@ +ALTER TABLE `key` ADD `old_name` varchar(255); \ No newline at end of file diff --git a/packages/console/core/migrations/0003_dusty_clint_barton.sql b/packages/console/core/migrations/0003_dusty_clint_barton.sql new file mode 100644 index 000000000..14efae216 --- /dev/null +++ b/packages/console/core/migrations/0003_dusty_clint_barton.sql @@ -0,0 +1 @@ +ALTER TABLE `key` ADD CONSTRAINT `name` UNIQUE(`workspace_id`,`name`); \ No newline at end of file diff --git a/packages/console/core/migrations/0004_first_mockingbird.sql b/packages/console/core/migrations/0004_first_mockingbird.sql new file mode 100644 index 000000000..2a6b11067 --- /dev/null +++ b/packages/console/core/migrations/0004_first_mockingbird.sql @@ -0,0 +1 @@ +ALTER TABLE `usage` ADD `provider` varchar(255); \ No newline at end of file diff --git a/packages/console/core/migrations/0005_jazzy_skrulls.sql b/packages/console/core/migrations/0005_jazzy_skrulls.sql new file mode 100644 index 000000000..774c38dd8 --- /dev/null +++ b/packages/console/core/migrations/0005_jazzy_skrulls.sql @@ -0,0 +1 @@ +ALTER TABLE `usage` MODIFY COLUMN `provider` varchar(255) NOT NULL; \ No newline at end of file diff --git a/packages/console/core/migrations/0006_parallel_gauntlet.sql b/packages/console/core/migrations/0006_parallel_gauntlet.sql new file mode 100644 index 000000000..a1ff78e78 --- /dev/null +++ b/packages/console/core/migrations/0006_parallel_gauntlet.sql @@ -0,0 +1,2 @@ +ALTER TABLE `usage` ADD `cache_write_5m_tokens` int;--> statement-breakpoint +ALTER TABLE `usage` ADD `cache_write_1h_tokens` int; \ No newline at end of file diff --git a/packages/console/core/migrations/0007_familiar_nightshade.sql b/packages/console/core/migrations/0007_familiar_nightshade.sql new file mode 100644 index 000000000..89cf77f92 --- /dev/null +++ b/packages/console/core/migrations/0007_familiar_nightshade.sql @@ -0,0 +1 @@ +ALTER TABLE `usage` DROP COLUMN `cache_write_tokens`; \ No newline at end of file diff --git a/packages/console/core/migrations/0008_eminent_ultimatum.sql b/packages/console/core/migrations/0008_eminent_ultimatum.sql new file mode 100644 index 000000000..93e40a7fe --- /dev/null +++ b/packages/console/core/migrations/0008_eminent_ultimatum.sql @@ -0,0 +1 @@ +ALTER TABLE `billing` ADD `time_reload_locked_till` timestamp(3); \ No newline at end of file diff --git a/packages/console/core/migrations/0009_redundant_piledriver.sql b/packages/console/core/migrations/0009_redundant_piledriver.sql new file mode 100644 index 000000000..4ba1b2d4a --- /dev/null +++ b/packages/console/core/migrations/0009_redundant_piledriver.sql @@ -0,0 +1 @@ +ALTER TABLE `payment` ADD `error` varchar(255); \ No newline at end of file diff --git a/packages/console/core/migrations/0010_needy_sue_storm.sql b/packages/console/core/migrations/0010_needy_sue_storm.sql new file mode 100644 index 000000000..ffd46c9fc --- /dev/null +++ b/packages/console/core/migrations/0010_needy_sue_storm.sql @@ -0,0 +1 @@ +ALTER TABLE `billing` ADD CONSTRAINT `global_customer_id` UNIQUE(`customer_id`); \ No newline at end of file diff --git a/packages/console/core/migrations/0011_freezing_phil_sheldon.sql b/packages/console/core/migrations/0011_freezing_phil_sheldon.sql new file mode 100644 index 000000000..095f25993 --- /dev/null +++ b/packages/console/core/migrations/0011_freezing_phil_sheldon.sql @@ -0,0 +1,3 @@ +ALTER TABLE `billing` ADD `last_error` varchar(255);--> statement-breakpoint +ALTER TABLE `billing` ADD `time_last_error` timestamp(3);--> statement-breakpoint +ALTER TABLE `payment` DROP COLUMN `error`; \ No newline at end of file diff --git a/packages/console/core/migrations/0012_bright_photon.sql b/packages/console/core/migrations/0012_bright_photon.sql new file mode 100644 index 000000000..8ad777bcf --- /dev/null +++ b/packages/console/core/migrations/0012_bright_photon.sql @@ -0,0 +1,3 @@ +ALTER TABLE `billing` ADD `monthly_limit` int;--> statement-breakpoint +ALTER TABLE `billing` ADD `monthly_usage` bigint;--> statement-breakpoint +ALTER TABLE `billing` ADD `time_monthly_usage_updated` timestamp(3); \ No newline at end of file diff --git a/packages/console/core/migrations/0013_absurd_hobgoblin.sql b/packages/console/core/migrations/0013_absurd_hobgoblin.sql new file mode 100644 index 000000000..8c331b12f --- /dev/null +++ b/packages/console/core/migrations/0013_absurd_hobgoblin.sql @@ -0,0 +1,2 @@ +ALTER TABLE `billing` RENAME COLUMN `last_error` TO `reload_error`;--> statement-breakpoint +ALTER TABLE `billing` RENAME COLUMN `time_last_error` TO `time_reload_error`; \ No newline at end of file diff --git a/packages/console/core/migrations/meta/0000_snapshot.json b/packages/console/core/migrations/meta/0000_snapshot.json new file mode 100644 index 000000000..17d3bd7f9 --- /dev/null +++ b/packages/console/core/migrations/meta/0000_snapshot.json @@ -0,0 +1,569 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "aee779c5-db1d-4655-95ec-6451c18455be", + "prevId": "00000000-0000-0000-0000-000000000000", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0001_snapshot.json b/packages/console/core/migrations/meta/0001_snapshot.json new file mode 100644 index 000000000..d23d1601d --- /dev/null +++ b/packages/console/core/migrations/meta/0001_snapshot.json @@ -0,0 +1,569 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "79b7ee25-1c1c-41ff-9bbf-754af257102b", + "prevId": "aee779c5-db1d-4655-95ec-6451c18455be", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0002_snapshot.json b/packages/console/core/migrations/meta/0002_snapshot.json new file mode 100644 index 000000000..45d06926c --- /dev/null +++ b/packages/console/core/migrations/meta/0002_snapshot.json @@ -0,0 +1,576 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "9f51ef52-31ac-4ace-8b6d-39b35efe9c81", + "prevId": "79b7ee25-1c1c-41ff-9bbf-754af257102b", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0003_snapshot.json b/packages/console/core/migrations/meta/0003_snapshot.json new file mode 100644 index 000000000..e832ebb00 --- /dev/null +++ b/packages/console/core/migrations/meta/0003_snapshot.json @@ -0,0 +1,581 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "26cebd59-f553-441c-a2b2-2f9578a0ad2b", + "prevId": "9f51ef52-31ac-4ace-8b6d-39b35efe9c81", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0004_snapshot.json b/packages/console/core/migrations/meta/0004_snapshot.json new file mode 100644 index 000000000..6d2695c48 --- /dev/null +++ b/packages/console/core/migrations/meta/0004_snapshot.json @@ -0,0 +1,588 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "06dc6226-bfbb-4ccc-b4bc-f26070c3bed5", + "prevId": "26cebd59-f553-441c-a2b2-2f9578a0ad2b", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0005_snapshot.json b/packages/console/core/migrations/meta/0005_snapshot.json new file mode 100644 index 000000000..12246a6d6 --- /dev/null +++ b/packages/console/core/migrations/meta/0005_snapshot.json @@ -0,0 +1,588 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "d13af80e-3c70-4866-8f14-48e7ff6ff0ff", + "prevId": "06dc6226-bfbb-4ccc-b4bc-f26070c3bed5", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0006_snapshot.json b/packages/console/core/migrations/meta/0006_snapshot.json new file mode 100644 index 000000000..d726b6f67 --- /dev/null +++ b/packages/console/core/migrations/meta/0006_snapshot.json @@ -0,0 +1,602 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "b0ad4b11-b607-46c7-8e2d-3b9823cdc5f7", + "prevId": "d13af80e-3c70-4866-8f14-48e7ff6ff0ff", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_tokens": { + "name": "cache_write_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0007_snapshot.json b/packages/console/core/migrations/meta/0007_snapshot.json new file mode 100644 index 000000000..122db42cb --- /dev/null +++ b/packages/console/core/migrations/meta/0007_snapshot.json @@ -0,0 +1,595 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "91067cc9-d492-47b3-932a-42dcc0920b3c", + "prevId": "b0ad4b11-b607-46c7-8e2d-3b9823cdc5f7", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0008_snapshot.json b/packages/console/core/migrations/meta/0008_snapshot.json new file mode 100644 index 000000000..02c473200 --- /dev/null +++ b/packages/console/core/migrations/meta/0008_snapshot.json @@ -0,0 +1,602 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "3e080fc0-9efd-411f-b764-ed3aa4abcee5", + "prevId": "91067cc9-d492-47b3-932a-42dcc0920b3c", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0009_snapshot.json b/packages/console/core/migrations/meta/0009_snapshot.json new file mode 100644 index 000000000..a3bd57cae --- /dev/null +++ b/packages/console/core/migrations/meta/0009_snapshot.json @@ -0,0 +1,609 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "b0019e1e-d365-4f67-be3d-a2e69bdddc04", + "prevId": "3e080fc0-9efd-411f-b764-ed3aa4abcee5", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0010_snapshot.json b/packages/console/core/migrations/meta/0010_snapshot.json new file mode 100644 index 000000000..cb55610ae --- /dev/null +++ b/packages/console/core/migrations/meta/0010_snapshot.json @@ -0,0 +1,615 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "1f08bd5a-436d-4905-a585-87b156847402", + "prevId": "b0019e1e-d365-4f67-be3d-a2e69bdddc04", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_customer_id": { + "name": "global_customer_id", + "columns": ["customer_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0011_snapshot.json b/packages/console/core/migrations/meta/0011_snapshot.json new file mode 100644 index 000000000..7eb6fa71a --- /dev/null +++ b/packages/console/core/migrations/meta/0011_snapshot.json @@ -0,0 +1,622 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "cd9c94c4-9167-4346-b716-1bd0cff10ffc", + "prevId": "1f08bd5a-436d-4905-a585-87b156847402", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_last_error": { + "name": "time_last_error", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_customer_id": { + "name": "global_customer_id", + "columns": ["customer_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0012_snapshot.json b/packages/console/core/migrations/meta/0012_snapshot.json new file mode 100644 index 000000000..4220c988b --- /dev/null +++ b/packages/console/core/migrations/meta/0012_snapshot.json @@ -0,0 +1,643 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "ba801b30-747a-433e-ab43-b407c961a24c", + "prevId": "cd9c94c4-9167-4346-b716-1bd0cff10ffc", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "monthly_limit": { + "name": "monthly_limit", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "monthly_usage": { + "name": "monthly_usage", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_monthly_usage_updated": { + "name": "time_monthly_usage_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_last_error": { + "name": "time_last_error", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_customer_id": { + "name": "global_customer_id", + "columns": ["customer_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/0013_snapshot.json b/packages/console/core/migrations/meta/0013_snapshot.json new file mode 100644 index 000000000..ef805ee83 --- /dev/null +++ b/packages/console/core/migrations/meta/0013_snapshot.json @@ -0,0 +1,646 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "28336c91-553c-4d1d-9875-1ee761e47582", + "prevId": "ba801b30-747a-433e-ab43-b407c961a24c", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "monthly_limit": { + "name": "monthly_limit", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "monthly_usage": { + "name": "monthly_usage", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_monthly_usage_updated": { + "name": "time_monthly_usage_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reload_error": { + "name": "reload_error", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_error": { + "name": "time_reload_error", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_customer_id": { + "name": "global_customer_id", + "columns": ["customer_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": ["key"], + "isUnique": true + }, + "name": { + "name": "name", + "columns": ["workspace_id", "name"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": ["workspace_id", "email"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": ["workspace_id", "id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": ["slug"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": { + "\"billing\".\"last_error\"": "\"billing\".\"reload_error\"", + "\"billing\".\"time_last_error\"": "\"billing\".\"time_reload_error\"" + } + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/packages/console/core/migrations/meta/_journal.json b/packages/console/core/migrations/meta/_journal.json new file mode 100644 index 000000000..1b7d45da3 --- /dev/null +++ b/packages/console/core/migrations/meta/_journal.json @@ -0,0 +1,104 @@ +{ + "version": "7", + "dialect": "mysql", + "entries": [ + { + "idx": 0, + "version": "5", + "when": 1756796050935, + "tag": "0000_fluffy_raza", + "breakpoints": true + }, + { + "idx": 1, + "version": "5", + "when": 1756871639102, + "tag": "0001_serious_whistler", + "breakpoints": true + }, + { + "idx": 2, + "version": "5", + "when": 1757597611832, + "tag": "0002_violet_loners", + "breakpoints": true + }, + { + "idx": 3, + "version": "5", + "when": 1757600397194, + "tag": "0003_dusty_clint_barton", + "breakpoints": true + }, + { + "idx": 4, + "version": "5", + "when": 1757627357232, + "tag": "0004_first_mockingbird", + "breakpoints": true + }, + { + "idx": 5, + "version": "5", + "when": 1757632304856, + "tag": "0005_jazzy_skrulls", + "breakpoints": true + }, + { + "idx": 6, + "version": "5", + "when": 1757643108507, + "tag": "0006_parallel_gauntlet", + "breakpoints": true + }, + { + "idx": 7, + "version": "5", + "when": 1757693869142, + "tag": "0007_familiar_nightshade", + "breakpoints": true + }, + { + "idx": 8, + "version": "5", + "when": 1757885904718, + "tag": "0008_eminent_ultimatum", + "breakpoints": true + }, + { + "idx": 9, + "version": "5", + "when": 1757888582598, + "tag": "0009_redundant_piledriver", + "breakpoints": true + }, + { + "idx": 10, + "version": "5", + "when": 1757892305788, + "tag": "0010_needy_sue_storm", + "breakpoints": true + }, + { + "idx": 11, + "version": "5", + "when": 1757948881012, + "tag": "0011_freezing_phil_sheldon", + "breakpoints": true + }, + { + "idx": 12, + "version": "5", + "when": 1757956814524, + "tag": "0012_bright_photon", + "breakpoints": true + }, + { + "idx": 13, + "version": "5", + "when": 1757956978089, + "tag": "0013_absurd_hobgoblin", + "breakpoints": true + } + ] +} diff --git a/packages/console/core/package.json b/packages/console/core/package.json new file mode 100644 index 000000000..e54dd4b0a --- /dev/null +++ b/packages/console/core/package.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/package.json", + "name": "@opencode/console-core", + "version": "0.9.11", + "private": true, + "type": "module", + "dependencies": { + "@aws-sdk/client-sts": "3.782.0", + "@opencode/console-resource": "workspace:*", + "@planetscale/database": "1.19.0", + "drizzle-orm": "0.41.0", + "postgres": "3.4.7", + "stripe": "18.0.0", + "ulid": "3.0.0" + }, + "exports": { + "./*": "./src/*" + }, + "scripts": { + "db": "sst shell drizzle-kit", + "db-dev": "sst shell --stage dev -- drizzle-kit", + "db-prod": "sst shell --stage production -- drizzle-kit", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "drizzle-kit": "0.30.5", + "mysql2": "3.14.4" + } +} diff --git a/packages/console/core/src/account.ts b/packages/console/core/src/account.ts new file mode 100644 index 000000000..cb123e048 --- /dev/null +++ b/packages/console/core/src/account.ts @@ -0,0 +1,67 @@ +import { z } from "zod" +import { and, eq, getTableColumns, isNull } from "drizzle-orm" +import { fn } from "./util/fn" +import { Database } from "./drizzle" +import { Identifier } from "./identifier" +import { AccountTable } from "./schema/account.sql" +import { Actor } from "./actor" +import { WorkspaceTable } from "./schema/workspace.sql" +import { UserTable } from "./schema/user.sql" + +export namespace Account { + export const create = fn( + z.object({ + email: z.string().email(), + id: z.string().optional(), + }), + async (input) => + Database.transaction(async (tx) => { + const id = input.id ?? Identifier.create("account") + await tx.insert(AccountTable).values({ + id, + email: input.email, + }) + return id + }), + ) + + export const fromID = fn(z.string(), async (id) => + Database.transaction(async (tx) => { + return tx + .select() + .from(AccountTable) + .where(eq(AccountTable.id, id)) + .execute() + .then((rows) => rows[0]) + }), + ) + + export const fromEmail = fn(z.string().email(), async (email) => + Database.transaction(async (tx) => { + return tx + .select() + .from(AccountTable) + .where(eq(AccountTable.email, email)) + .execute() + .then((rows) => rows[0]) + }), + ) + + export const workspaces = async () => { + const actor = Actor.assert("account") + return Database.transaction(async (tx) => + tx + .select(getTableColumns(WorkspaceTable)) + .from(WorkspaceTable) + .innerJoin(UserTable, eq(UserTable.workspaceID, WorkspaceTable.id)) + .where( + and( + eq(UserTable.email, actor.properties.email), + isNull(UserTable.timeDeleted), + isNull(WorkspaceTable.timeDeleted), + ), + ) + .execute(), + ) + } +} diff --git a/packages/console/core/src/actor.ts b/packages/console/core/src/actor.ts new file mode 100644 index 000000000..0d13f7216 --- /dev/null +++ b/packages/console/core/src/actor.ts @@ -0,0 +1,74 @@ +import { Context } from "./context" +import { Log } from "./util/log" + +export namespace Actor { + interface Account { + type: "account" + properties: { + accountID: string + email: string + } + } + + interface Public { + type: "public" + properties: {} + } + + interface User { + type: "user" + properties: { + userID: string + workspaceID: string + } + } + + interface System { + type: "system" + properties: { + workspaceID: string + } + } + + export type Info = Account | Public | User | System + + const ctx = Context.create() + export const use = ctx.use + + const log = Log.create().tag("namespace", "actor") + + export function provide( + type: T, + properties: Extract["properties"], + cb: () => R, + ) { + return ctx.provide( + { + type, + properties, + } as any, + () => { + return Log.provide({ ...properties }, () => { + log.info("provided") + return cb() + }) + }, + ) + } + + export function assert(type: T) { + const actor = use() + if (actor.type !== type) { + throw new Error(`Expected actor type ${type}, got ${actor.type}`) + } + return actor as Extract + } + + export function workspace() { + const actor = use() + if ("workspaceID" in actor.properties) { + return actor.properties.workspaceID + } + throw new Error(`actor of type "${actor.type}" is not associated with a workspace`) + } +} diff --git a/packages/console/core/src/billing.ts b/packages/console/core/src/billing.ts new file mode 100644 index 000000000..dda0c539f --- /dev/null +++ b/packages/console/core/src/billing.ts @@ -0,0 +1,244 @@ +import { Stripe } from "stripe" +import { Database, eq, sql } from "./drizzle" +import { BillingTable, PaymentTable, UsageTable } from "./schema/billing.sql" +import { Actor } from "./actor" +import { fn } from "./util/fn" +import { z } from "zod" +import { User } from "./user" +import { Resource } from "@opencode/console-resource" +import { Identifier } from "./identifier" +import { centsToMicroCents } from "./util/price" + +export namespace Billing { + export const CHARGE_AMOUNT = 2000 // $20 + export const CHARGE_FEE = 123 // Stripe fee 4.4% + $0.30 + export const CHARGE_THRESHOLD = 500 // $5 + export const stripe = () => + new Stripe(Resource.STRIPE_SECRET_KEY.value, { + apiVersion: "2025-03-31.basil", + }) + + export const get = async () => { + return Database.use(async (tx) => + tx + .select({ + customerID: BillingTable.customerID, + paymentMethodID: BillingTable.paymentMethodID, + paymentMethodLast4: BillingTable.paymentMethodLast4, + balance: BillingTable.balance, + reload: BillingTable.reload, + monthlyLimit: BillingTable.monthlyLimit, + monthlyUsage: BillingTable.monthlyUsage, + timeMonthlyUsageUpdated: BillingTable.timeMonthlyUsageUpdated, + reloadError: BillingTable.reloadError, + timeReloadError: BillingTable.timeReloadError, + }) + .from(BillingTable) + .where(eq(BillingTable.workspaceID, Actor.workspace())) + .then((r) => r[0]), + ) + } + + export const payments = async () => { + return await Database.use((tx) => + tx + .select() + .from(PaymentTable) + .where(eq(PaymentTable.workspaceID, Actor.workspace())) + .orderBy(sql`${PaymentTable.timeCreated} DESC`) + .limit(100), + ) + } + + export const usages = async () => { + return await Database.use((tx) => + tx + .select() + .from(UsageTable) + .where(eq(UsageTable.workspaceID, Actor.workspace())) + .orderBy(sql`${UsageTable.timeCreated} DESC`) + .limit(100), + ) + } + + export const reload = async () => { + const { customerID, paymentMethodID } = await Database.use((tx) => + tx + .select({ + customerID: BillingTable.customerID, + paymentMethodID: BillingTable.paymentMethodID, + }) + .from(BillingTable) + .where(eq(BillingTable.workspaceID, Actor.workspace())) + .then((rows) => rows[0]), + ) + const paymentID = Identifier.create("payment") + let charge + try { + charge = await Billing.stripe().paymentIntents.create( + { + amount: Billing.CHARGE_AMOUNT + Billing.CHARGE_FEE, + currency: "usd", + customer: customerID!, + payment_method: paymentMethodID!, + off_session: true, + confirm: true, + }, + { idempotencyKey: paymentID }, + ) + + if (charge.status !== "succeeded") throw new Error(charge.last_payment_error?.message) + } catch (e: any) { + await Database.use((tx) => + tx + .update(BillingTable) + .set({ + reloadError: e.message ?? "Payment failed.", + timeReloadError: sql`now()`, + }) + .where(eq(BillingTable.workspaceID, Actor.workspace())), + ) + return + } + + await Database.transaction(async (tx) => { + await tx + .update(BillingTable) + .set({ + balance: sql`${BillingTable.balance} + ${centsToMicroCents(CHARGE_AMOUNT)}`, + reloadError: null, + timeReloadError: null, + }) + .where(eq(BillingTable.workspaceID, Actor.workspace())) + await tx.insert(PaymentTable).values({ + workspaceID: Actor.workspace(), + id: paymentID, + amount: centsToMicroCents(CHARGE_AMOUNT), + paymentID: charge.id, + customerID, + }) + }) + } + + export const disableReload = async () => { + return await Database.use((tx) => + tx + .update(BillingTable) + .set({ + reload: false, + }) + .where(eq(BillingTable.workspaceID, Actor.workspace())), + ) + } + + export const setMonthlyLimit = fn(z.number(), async (input) => { + return await Database.use((tx) => + tx + .update(BillingTable) + .set({ + monthlyLimit: input, + }) + .where(eq(BillingTable.workspaceID, Actor.workspace())), + ) + }) + + export const generateCheckoutUrl = fn( + z.object({ + successUrl: z.string(), + cancelUrl: z.string(), + }), + async (input) => { + const account = Actor.assert("user") + const { successUrl, cancelUrl } = input + + const user = await User.fromID(account.properties.userID) + const customer = await Billing.get() + const session = await Billing.stripe().checkout.sessions.create({ + mode: "payment", + line_items: [ + { + price_data: { + currency: "usd", + product_data: { + name: "opencode credits", + }, + unit_amount: CHARGE_AMOUNT, + }, + quantity: 1, + }, + { + price_data: { + currency: "usd", + product_data: { + name: "processing fee", + }, + unit_amount: CHARGE_FEE, + }, + quantity: 1, + }, + ], + payment_intent_data: { + setup_future_usage: "on_session", + }, + ...(customer.customerID + ? { + customer: customer.customerID, + } + : { + customer_email: user.email, + customer_creation: "always", + }), + metadata: { + workspaceID: Actor.workspace(), + }, + currency: "usd", + payment_method_types: ["card"], + payment_method_data: { + allow_redisplay: "always", + }, + success_url: successUrl, + cancel_url: cancelUrl, + }) + + return session.url + }, + ) + + export const generateSessionUrl = fn( + z.object({ + returnUrl: z.string(), + }), + async (input) => { + const { returnUrl } = input + + const customer = await Billing.get() + if (!customer?.customerID) { + throw new Error("No stripe customer ID") + } + + const session = await Billing.stripe().billingPortal.sessions.create({ + customer: customer.customerID, + return_url: returnUrl, + }) + + return session.url + }, + ) + + export const generateReceiptUrl = fn( + z.object({ + paymentID: z.string(), + }), + async (input) => { + const { paymentID } = input + + const intent = await Billing.stripe().paymentIntents.retrieve(paymentID) + if (!intent.latest_charge) throw new Error("No charge found") + + const charge = await Billing.stripe().charges.retrieve(intent.latest_charge as string) + if (!charge.receipt_url) throw new Error("No receipt URL found") + + return charge.receipt_url + }, + ) +} diff --git a/packages/console/core/src/context.ts b/packages/console/core/src/context.ts new file mode 100644 index 000000000..c2ca6a313 --- /dev/null +++ b/packages/console/core/src/context.ts @@ -0,0 +1,21 @@ +import { AsyncLocalStorage } from "node:async_hooks" + +export namespace Context { + export class NotFound extends Error {} + + export function create() { + const storage = new AsyncLocalStorage() + return { + use() { + const result = storage.getStore() + if (!result) { + throw new NotFound() + } + return result + }, + provide(value: T, fn: () => R) { + return storage.run(value, fn) + }, + } + } +} diff --git a/packages/console/core/src/drizzle/index.ts b/packages/console/core/src/drizzle/index.ts new file mode 100644 index 000000000..899f69148 --- /dev/null +++ b/packages/console/core/src/drizzle/index.ts @@ -0,0 +1,86 @@ +import { drizzle } from "drizzle-orm/planetscale-serverless" +import { Resource } from "@opencode/console-resource" +export * from "drizzle-orm" +import { Client } from "@planetscale/database" + +import { MySqlTransaction, type MySqlTransactionConfig } from "drizzle-orm/mysql-core" +import type { ExtractTablesWithRelations } from "drizzle-orm" +import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "drizzle-orm/planetscale-serverless" +import { Context } from "../context" +import { memo } from "../util/memo" + +export namespace Database { + export type Transaction = MySqlTransaction< + PlanetscaleQueryResultHKT, + PlanetScalePreparedQueryHKT, + Record, + ExtractTablesWithRelations> + > + + const client = memo(() => { + const result = new Client({ + host: Resource.Database.host, + username: Resource.Database.username, + password: Resource.Database.password, + }) + const db = drizzle(result, {}) + return db + }) + + export type TxOrDb = Transaction | ReturnType + + const TransactionContext = Context.create<{ + tx: TxOrDb + effects: (() => void | Promise)[] + }>() + + export async function use(callback: (trx: TxOrDb) => Promise) { + try { + const { tx } = TransactionContext.use() + return tx.transaction(callback) + } catch (err) { + if (err instanceof Context.NotFound) { + const effects: (() => void | Promise)[] = [] + const result = await TransactionContext.provide( + { + effects, + tx: client(), + }, + () => callback(client()), + ) + await Promise.all(effects.map((x) => x())) + return result + } + throw err + } + } + export async function fn(callback: (input: Input, trx: TxOrDb) => Promise) { + return (input: Input) => use(async (tx) => callback(input, tx)) + } + + export async function effect(effect: () => any | Promise) { + try { + const { effects } = TransactionContext.use() + effects.push(effect) + } catch { + await effect() + } + } + + export async function transaction(callback: (tx: TxOrDb) => Promise, config?: MySqlTransactionConfig) { + try { + const { tx } = TransactionContext.use() + return callback(tx) + } catch (err) { + if (err instanceof Context.NotFound) { + const effects: (() => void | Promise)[] = [] + const result = await client().transaction(async (tx) => { + return TransactionContext.provide({ tx, effects }, () => callback(tx)) + }, config) + await Promise.all(effects.map((x) => x())) + return result + } + throw err + } + } +} diff --git a/packages/console/core/src/drizzle/types.ts b/packages/console/core/src/drizzle/types.ts new file mode 100644 index 000000000..f16ad5a8a --- /dev/null +++ b/packages/console/core/src/drizzle/types.ts @@ -0,0 +1,33 @@ +import { sql } from "drizzle-orm" +import { bigint, timestamp, varchar } from "drizzle-orm/mysql-core" + +export const ulid = (name: string) => varchar(name, { length: 30 }) + +export const workspaceColumns = { + get id() { + return ulid("id").notNull() + }, + get workspaceID() { + return ulid("workspace_id").notNull() + }, +} + +export const id = () => ulid("id").notNull() + +export const utc = (name: string) => + timestamp(name, { + fsp: 3, + }) + +export const currency = (name: string) => + bigint(name, { + mode: "number", + }) + +export const timestamps = { + timeCreated: utc("time_created").notNull().defaultNow(), + timeUpdated: utc("time_updated") + .notNull() + .default(sql`CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)`), + timeDeleted: utc("time_deleted"), +} diff --git a/packages/console/core/src/identifier.ts b/packages/console/core/src/identifier.ts new file mode 100644 index 000000000..f8e73852e --- /dev/null +++ b/packages/console/core/src/identifier.ts @@ -0,0 +1,26 @@ +import { ulid } from "ulid" +import { z } from "zod" + +export namespace Identifier { + const prefixes = { + account: "acc", + billing: "bil", + key: "key", + payment: "pay", + usage: "usg", + user: "usr", + workspace: "wrk", + } as const + + export function create(prefix: keyof typeof prefixes, given?: string): string { + if (given) { + if (given.startsWith(prefixes[prefix])) return given + throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`) + } + return [prefixes[prefix], ulid()].join("_") + } + + export function schema(prefix: keyof typeof prefixes) { + return z.string().startsWith(prefixes[prefix]) + } +} diff --git a/packages/console/core/src/key.ts b/packages/console/core/src/key.ts new file mode 100644 index 000000000..28643a521 --- /dev/null +++ b/packages/console/core/src/key.ts @@ -0,0 +1,75 @@ +import { z } from "zod" +import { fn } from "./util/fn" +import { Actor } from "./actor" +import { and, Database, eq, isNull, sql } from "./drizzle" +import { Identifier } from "./identifier" +import { KeyTable } from "./schema/key.sql" + +export namespace Key { + export const list = async () => { + const workspace = Actor.workspace() + const keys = await Database.use((tx) => + tx + .select() + .from(KeyTable) + .where(and(eq(KeyTable.workspaceID, workspace), isNull(KeyTable.timeDeleted))) + .orderBy(sql`${KeyTable.timeCreated} DESC`), + ) + return keys + } + + export const create = fn(z.object({ name: z.string().min(1).max(255) }), async (input) => { + const workspaceID = Actor.workspace() + const { name } = input + + // Generate secret key: sk- + 64 random characters (upper, lower, numbers) + const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + let secretKey = "sk-" + const array = new Uint32Array(64) + crypto.getRandomValues(array) + for (let i = 0, l = array.length; i < l; i++) { + secretKey += chars[array[i] % chars.length] + } + const keyID = Identifier.create("key") + + await Database.use((tx) => + tx.insert(KeyTable).values({ + id: keyID, + workspaceID, + actor: Actor.use(), + name, + key: secretKey, + timeUsed: null, + }), + ).catch((e: any) => { + if (e.message.match(/Duplicate entry '.*' for key 'key.name'/)) + throw new Error("A key with this name already exists. Please choose a different name.") + throw e + }) + + return keyID + }) + + export const remove = fn(z.object({ id: z.string() }), async (input) => { + const workspace = Actor.workspace() + await Database.transaction(async (tx) => { + const row = await tx + .select({ + name: KeyTable.name, + }) + .from(KeyTable) + .where(and(eq(KeyTable.id, input.id), eq(KeyTable.workspaceID, workspace))) + .then((rows) => rows[0]) + if (!row) return + + await tx + .update(KeyTable) + .set({ + timeDeleted: sql`now()`, + oldName: row.name, + name: input.id, // Use the key ID as the name + }) + .where(and(eq(KeyTable.id, input.id), eq(KeyTable.workspaceID, workspace))) + }) + }) +} diff --git a/packages/console/core/src/schema/account.sql.ts b/packages/console/core/src/schema/account.sql.ts new file mode 100644 index 000000000..4d9937114 --- /dev/null +++ b/packages/console/core/src/schema/account.sql.ts @@ -0,0 +1,12 @@ +import { mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core" +import { id, timestamps } from "../drizzle/types" + +export const AccountTable = mysqlTable( + "account", + { + id: id(), + ...timestamps, + email: varchar("email", { length: 255 }).notNull(), + }, + (table) => [uniqueIndex("email").on(table.email)], +) diff --git a/packages/console/core/src/schema/billing.sql.ts b/packages/console/core/src/schema/billing.sql.ts new file mode 100644 index 000000000..5bec4e900 --- /dev/null +++ b/packages/console/core/src/schema/billing.sql.ts @@ -0,0 +1,53 @@ +import { bigint, boolean, int, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core" +import { timestamps, utc, workspaceColumns } from "../drizzle/types" +import { workspaceIndexes } from "./workspace.sql" + +export const BillingTable = mysqlTable( + "billing", + { + ...workspaceColumns, + ...timestamps, + customerID: varchar("customer_id", { length: 255 }), + paymentMethodID: varchar("payment_method_id", { length: 255 }), + paymentMethodLast4: varchar("payment_method_last4", { length: 4 }), + balance: bigint("balance", { mode: "number" }).notNull(), + monthlyLimit: int("monthly_limit"), + monthlyUsage: bigint("monthly_usage", { mode: "number" }), + timeMonthlyUsageUpdated: utc("time_monthly_usage_updated"), + reload: boolean("reload"), + reloadError: varchar("reload_error", { length: 255 }), + timeReloadError: utc("time_reload_error"), + timeReloadLockedTill: utc("time_reload_locked_till"), + }, + (table) => [...workspaceIndexes(table), uniqueIndex("global_customer_id").on(table.customerID)], +) + +export const PaymentTable = mysqlTable( + "payment", + { + ...workspaceColumns, + ...timestamps, + customerID: varchar("customer_id", { length: 255 }), + paymentID: varchar("payment_id", { length: 255 }), + amount: bigint("amount", { mode: "number" }).notNull(), + }, + (table) => [...workspaceIndexes(table)], +) + +export const UsageTable = mysqlTable( + "usage", + { + ...workspaceColumns, + ...timestamps, + model: varchar("model", { length: 255 }).notNull(), + provider: varchar("provider", { length: 255 }).notNull(), + inputTokens: int("input_tokens").notNull(), + outputTokens: int("output_tokens").notNull(), + reasoningTokens: int("reasoning_tokens"), + cacheReadTokens: int("cache_read_tokens"), + cacheWrite5mTokens: int("cache_write_5m_tokens"), + cacheWrite1hTokens: int("cache_write_1h_tokens"), + cost: bigint("cost", { mode: "number" }).notNull(), + }, + (table) => [...workspaceIndexes(table)], +) diff --git a/packages/console/core/src/schema/key.sql.ts b/packages/console/core/src/schema/key.sql.ts new file mode 100644 index 000000000..98b99c788 --- /dev/null +++ b/packages/console/core/src/schema/key.sql.ts @@ -0,0 +1,22 @@ +import { mysqlTable, varchar, uniqueIndex, json } from "drizzle-orm/mysql-core" +import { timestamps, utc, workspaceColumns } from "../drizzle/types" +import { workspaceIndexes } from "./workspace.sql" +import { Actor } from "../actor" + +export const KeyTable = mysqlTable( + "key", + { + ...workspaceColumns, + ...timestamps, + actor: json("actor").$type(), + name: varchar("name", { length: 255 }).notNull(), + oldName: varchar("old_name", { length: 255 }), + key: varchar("key", { length: 255 }).notNull(), + timeUsed: utc("time_used"), + }, + (table) => [ + ...workspaceIndexes(table), + uniqueIndex("global_key").on(table.key), + uniqueIndex("name").on(table.workspaceID, table.name), + ], +) diff --git a/packages/console/core/src/schema/user.sql.ts b/packages/console/core/src/schema/user.sql.ts new file mode 100644 index 000000000..00c372d1a --- /dev/null +++ b/packages/console/core/src/schema/user.sql.ts @@ -0,0 +1,16 @@ +import { text, mysqlTable, uniqueIndex, varchar, int } from "drizzle-orm/mysql-core" +import { timestamps, utc, workspaceColumns } from "../drizzle/types" +import { workspaceIndexes } from "./workspace.sql" + +export const UserTable = mysqlTable( + "user", + { + ...workspaceColumns, + ...timestamps, + email: varchar("email", { length: 255 }).notNull(), + name: varchar("name", { length: 255 }).notNull(), + timeSeen: utc("time_seen"), + color: int("color"), + }, + (table) => [...workspaceIndexes(table), uniqueIndex("user_email").on(table.workspaceID, table.email)], +) diff --git a/packages/console/core/src/schema/workspace.sql.ts b/packages/console/core/src/schema/workspace.sql.ts new file mode 100644 index 000000000..979255428 --- /dev/null +++ b/packages/console/core/src/schema/workspace.sql.ts @@ -0,0 +1,21 @@ +import { primaryKey, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core" +import { timestamps, ulid } from "../drizzle/types" + +export const WorkspaceTable = mysqlTable( + "workspace", + { + id: ulid("id").notNull().primaryKey(), + slug: varchar("slug", { length: 255 }), + name: varchar("name", { length: 255 }), + ...timestamps, + }, + (table) => [uniqueIndex("slug").on(table.slug)], +) + +export function workspaceIndexes(table: any) { + return [ + primaryKey({ + columns: [table.workspaceID, table.id], + }), + ] +} diff --git a/packages/console/core/src/user.ts b/packages/console/core/src/user.ts new file mode 100644 index 000000000..7914926ff --- /dev/null +++ b/packages/console/core/src/user.ts @@ -0,0 +1,18 @@ +import { z } from "zod" +import { eq } from "drizzle-orm" +import { fn } from "./util/fn" +import { Database } from "./drizzle" +import { UserTable } from "./schema/user.sql" + +export namespace User { + export const fromID = fn(z.string(), async (id) => + Database.transaction(async (tx) => { + return tx + .select() + .from(UserTable) + .where(eq(UserTable.id, id)) + .execute() + .then((rows) => rows[0]) + }), + ) +} diff --git a/packages/console/core/src/util/env.cloudflare.ts b/packages/console/core/src/util/env.cloudflare.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/console/core/src/util/fn.ts b/packages/console/core/src/util/fn.ts new file mode 100644 index 000000000..9efe4622f --- /dev/null +++ b/packages/console/core/src/util/fn.ts @@ -0,0 +1,11 @@ +import { z } from "zod" + +export function fn(schema: T, cb: (input: z.infer) => Result) { + const result = (input: z.infer) => { + const parsed = schema.parse(input) + return cb(parsed) + } + result.force = (input: z.infer) => cb(input) + result.schema = schema + return result +} diff --git a/packages/console/core/src/util/log.ts b/packages/console/core/src/util/log.ts new file mode 100644 index 000000000..4f2d25c13 --- /dev/null +++ b/packages/console/core/src/util/log.ts @@ -0,0 +1,55 @@ +import { Context } from "../context" + +export namespace Log { + const ctx = Context.create<{ + tags: Record + }>() + + export function create(tags?: Record) { + tags = tags || {} + + const result = { + info(message?: any, extra?: Record) { + const prefix = Object.entries({ + ...use().tags, + ...tags, + ...extra, + }) + .map(([key, value]) => `${key}=${value}`) + .join(" ") + console.log(prefix, message) + return result + }, + tag(key: string, value: string) { + if (tags) tags[key] = value + return result + }, + clone() { + return Log.create({ ...tags }) + }, + } + + return result + } + + export function provide(tags: Record, cb: () => R) { + const existing = use() + return ctx.provide( + { + tags: { + ...existing.tags, + ...tags, + }, + }, + cb, + ) + } + + function use() { + try { + return ctx.use() + } catch (e) { + return { tags: {} } + } + } +} diff --git a/packages/console/core/src/util/memo.ts b/packages/console/core/src/util/memo.ts new file mode 100644 index 000000000..49043010f --- /dev/null +++ b/packages/console/core/src/util/memo.ts @@ -0,0 +1,18 @@ +export function memo(fn: () => T, cleanup?: (input: T) => Promise) { + let value: T | undefined + let loaded = false + + const result = (): T => { + if (loaded) return value as T + loaded = true + value = fn() + return value as T + } + result.reset = async () => { + if (cleanup && value) await cleanup(value) + loaded = false + value = undefined + } + + return result +} diff --git a/packages/console/core/src/util/price.ts b/packages/console/core/src/util/price.ts new file mode 100644 index 000000000..abdbca032 --- /dev/null +++ b/packages/console/core/src/util/price.ts @@ -0,0 +1,3 @@ +export function centsToMicroCents(amount: number) { + return Math.round(amount * 1000000) +} diff --git a/packages/console/core/src/workspace.ts b/packages/console/core/src/workspace.ts new file mode 100644 index 000000000..a9fb923d6 --- /dev/null +++ b/packages/console/core/src/workspace.ts @@ -0,0 +1,58 @@ +import { z } from "zod" +import { fn } from "./util/fn" +import { centsToMicroCents } from "./util/price" +import { Actor } from "./actor" +import { Database, eq } from "./drizzle" +import { Identifier } from "./identifier" +import { UserTable } from "./schema/user.sql" +import { BillingTable } from "./schema/billing.sql" +import { WorkspaceTable } from "./schema/workspace.sql" +import { Key } from "./key" + +export namespace Workspace { + export const create = fn(z.void(), async () => { + const account = Actor.assert("account") + const workspaceID = Identifier.create("workspace") + await Database.transaction(async (tx) => { + await tx.insert(WorkspaceTable).values({ + id: workspaceID, + }) + await tx.insert(UserTable).values({ + workspaceID, + id: Identifier.create("user"), + email: account.properties.email, + name: "", + }) + await tx.insert(BillingTable).values({ + workspaceID, + id: Identifier.create("billing"), + balance: 0, + }) + }) + await Actor.provide( + "system", + { + workspaceID, + }, + async () => { + await Key.create({ name: "Default API Key" }) + }, + ) + return workspaceID + }) + + export async function list() { + const account = Actor.assert("account") + return Database.use(async (tx) => { + return tx + .select({ + id: WorkspaceTable.id, + slug: WorkspaceTable.slug, + name: WorkspaceTable.name, + }) + .from(UserTable) + .innerJoin(WorkspaceTable, eq(UserTable.workspaceID, WorkspaceTable.id)) + .where(eq(UserTable.email, account.properties.email)) + }) + } +} diff --git a/packages/console/core/sst-env.d.ts b/packages/console/core/sst-env.d.ts new file mode 100644 index 000000000..9b9de7327 --- /dev/null +++ b/packages/console/core/sst-env.d.ts @@ -0,0 +1,9 @@ +/* This file is auto-generated by SST. Do not edit. */ +/* tslint:disable */ +/* eslint-disable */ +/* deno-fmt-ignore-file */ + +/// + +import "sst" +export {} \ No newline at end of file diff --git a/packages/console/core/tsconfig.json b/packages/console/core/tsconfig.json new file mode 100644 index 000000000..0faf16aab --- /dev/null +++ b/packages/console/core/tsconfig.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/node22/tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler", + "types": ["@cloudflare/workers-types", "node"] + } +} diff --git a/packages/console/function/package.json b/packages/console/function/package.json new file mode 100644 index 000000000..4ced6510b --- /dev/null +++ b/packages/console/function/package.json @@ -0,0 +1,26 @@ +{ + "name": "@opencode/console-function", + "version": "0.9.11", + "$schema": "https://json.schemastore.org/package.json", + "private": true, + "type": "module", + "scripts": { + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "@cloudflare/workers-types": "4.20250522.0", + "@types/node": "catalog:", + "openai": "5.11.0", + "typescript": "catalog:" + }, + "dependencies": { + "@ai-sdk/anthropic": "2.0.0", + "@ai-sdk/openai": "2.0.2", + "@ai-sdk/openai-compatible": "1.0.1", + "@hono/zod-validator": "catalog:", + "@openauthjs/openauth": "0.0.0-20250322224806", + "ai": "catalog:", + "hono": "catalog:", + "zod": "catalog:" + } +} diff --git a/packages/console/function/src/auth.ts b/packages/console/function/src/auth.ts new file mode 100644 index 000000000..5dc799683 --- /dev/null +++ b/packages/console/function/src/auth.ts @@ -0,0 +1,140 @@ +import { z } from "zod" +import { issuer } from "@openauthjs/openauth" +import type { Theme } from "@openauthjs/openauth/ui/theme" +import { createSubjects } from "@openauthjs/openauth/subject" +import { THEME_OPENAUTH } from "@openauthjs/openauth/ui/theme" +import { GithubProvider } from "@openauthjs/openauth/provider/github" +import { GoogleOidcProvider } from "@openauthjs/openauth/provider/google" +import { CloudflareStorage } from "@openauthjs/openauth/storage/cloudflare" +import { Account } from "@opencode/console-core/account.js" +import { Workspace } from "@opencode/console-core/workspace.js" +import { Actor } from "@opencode/console-core/actor.js" +import { Resource } from "@opencode/console-resource" +import { Database } from "@opencode/console-core/drizzle/index.js" + +type Env = { + AuthStorage: KVNamespace +} + +export const subjects = createSubjects({ + account: z.object({ + accountID: z.string(), + email: z.string(), + }), + user: z.object({ + userID: z.string(), + workspaceID: z.string(), + }), +}) + +const MY_THEME: Theme = { + ...THEME_OPENAUTH, + logo: "https://opencode.ai/favicon.svg", +} + +export default { + async fetch(request: Request, env: Env, ctx: ExecutionContext) { + const result = await issuer({ + theme: MY_THEME, + providers: { + github: GithubProvider({ + clientID: Resource.GITHUB_CLIENT_ID_CONSOLE.value, + clientSecret: Resource.GITHUB_CLIENT_SECRET_CONSOLE.value, + scopes: ["read:user", "user:email"], + }), + google: GoogleOidcProvider({ + clientID: Resource.GOOGLE_CLIENT_ID.value, + scopes: ["openid", "email"], + }), + // email: CodeProvider({ + // async request(req, state, form, error) { + // console.log(state) + // const params = new URLSearchParams() + // if (error) { + // params.set("error", error.type) + // } + // if (state.type === "start") { + // return Response.redirect(process.env.AUTH_FRONTEND_URL + "/auth/email?" + params.toString(), 302) + // } + // + // if (state.type === "code") { + // return Response.redirect(process.env.AUTH_FRONTEND_URL + "/auth/code?" + params.toString(), 302) + // } + // + // return new Response("ok") + // }, + // async sendCode(claims, code) { + // const email = z.string().email().parse(claims.email) + // const cmd = new SendEmailCommand({ + // Destination: { + // ToAddresses: [email], + // }, + // FromEmailAddress: `SST `, + // Content: { + // Simple: { + // Body: { + // Html: { + // Data: `Your pin code is ${code}`, + // }, + // Text: { + // Data: `Your pin code is ${code}`, + // }, + // }, + // Subject: { + // Data: "SST Console Pin Code: " + code, + // }, + // }, + // }, + // }) + // await ses.send(cmd) + // }, + // }), + }, + storage: CloudflareStorage({ + namespace: env.AuthStorage, + }), + subjects, + async success(ctx, response) { + console.log(response) + + let email: string | undefined + + if (response.provider === "github") { + const emails = (await fetch("https://api.github.com/user/emails", { + headers: { + Authorization: `Bearer ${response.tokenset.access}`, + "User-Agent": "opencode", + Accept: "application/vnd.github+json", + }, + }).then((x) => x.json())) as any + email = emails.find((x: any) => x.primary && x.verified)?.email + } else if (response.provider === "google") { + if (!response.id.email_verified) throw new Error("Google email not verified") + email = response.id.email as string + } + //if (response.provider === "email") { + // email = response.claims.email + //} + else throw new Error("Unsupported provider") + + if (!email) throw new Error("No email found") + + let accountID = await Account.fromEmail(email).then((x) => x?.id) + if (!accountID) { + console.log("creating account for", email) + accountID = await Account.create({ + email: email!, + }) + } + await Actor.provide("account", { accountID, email }, async () => { + const workspaces = await Account.workspaces() + if (workspaces.length === 0) { + await Workspace.create() + } + }) + return ctx.subject("account", accountID, { accountID, email }) + }, + }).fetch(request, env, ctx) + return result + }, +} diff --git a/packages/console/function/src/log-processor.ts b/packages/console/function/src/log-processor.ts new file mode 100644 index 000000000..21b9b214e --- /dev/null +++ b/packages/console/function/src/log-processor.ts @@ -0,0 +1,49 @@ +import { Resource } from "@opencode/console-resource" +import type { TraceItem } from "@cloudflare/workers-types" + +export default { + async tail(events: TraceItem[]) { + for (const event of events) { + if (!event.event) continue + if (!("request" in event.event)) continue + if (event.event.request.method !== "POST") continue + + const url = new URL(event.event.request.url) + if (url.pathname !== "/zen/v1/chat/completions") return + + let metrics = { + event_type: "completions", + "cf.continent": event.event.request.cf?.continent, + "cf.country": event.event.request.cf?.country, + "cf.city": event.event.request.cf?.city, + "cf.region": event.event.request.cf?.region, + "cf.latitude": event.event.request.cf?.latitude, + "cf.longitude": event.event.request.cf?.longitude, + "cf.timezone": event.event.request.cf?.timezone, + duration: event.wallTime, + request_length: parseInt(event.event.request.headers["content-length"] ?? "0"), + status: event.event.response?.status ?? 0, + ip: event.event.request.headers["x-real-ip"], + } + for (const log of event.logs) { + for (const message of log.message) { + if (!message.startsWith("_metric:")) continue + metrics = { ...metrics, ...JSON.parse(message.slice(8)) } + } + } + console.log(JSON.stringify(metrics, null, 2)) + + const ret = await fetch("https://api.honeycomb.io/1/events/zen", { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-Honeycomb-Event-Time": (event.eventTimestamp ?? Date.now()).toString(), + "X-Honeycomb-Team": Resource.HONEYCOMB_API_KEY.value, + }, + body: JSON.stringify(metrics), + }) + console.log(ret.status) + console.log(await ret.text()) + } + }, +} diff --git a/packages/console/function/sst-env.d.ts b/packages/console/function/sst-env.d.ts new file mode 100644 index 000000000..09c60c7c2 --- /dev/null +++ b/packages/console/function/sst-env.d.ts @@ -0,0 +1,96 @@ +/* This file is auto-generated by SST. Do not edit. */ +/* tslint:disable */ +/* eslint-disable */ +/* deno-fmt-ignore-file */ + +import "sst" +declare module "sst" { + export interface Resource { + "ANTHROPIC_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string + } + "BASETEN_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string + } + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string + } + "FIREWORKS_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string + } + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string + } + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "OPENAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "XAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + } +} +// cloudflare +import * as cloudflare from "@cloudflare/workers-types"; +declare module "sst" { + export interface Resource { + "Api": cloudflare.Service + "AuthApi": cloudflare.Service + "AuthStorage": cloudflare.KVNamespace + "Bucket": cloudflare.R2Bucket + "LogProcessor": cloudflare.Service + } +} + +import "sst" +export {} \ No newline at end of file diff --git a/packages/console/function/tsconfig.json b/packages/console/function/tsconfig.json new file mode 100644 index 000000000..0faf16aab --- /dev/null +++ b/packages/console/function/tsconfig.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/node22/tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler", + "types": ["@cloudflare/workers-types", "node"] + } +} diff --git a/packages/console/resource/bun.lock b/packages/console/resource/bun.lock new file mode 100644 index 000000000..56bdf44ca --- /dev/null +++ b/packages/console/resource/bun.lock @@ -0,0 +1,13 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "dependencies": { + "@cloudflare/workers-types": "^4.20250830.0", + }, + }, + }, + "packages": { + "@cloudflare/workers-types": ["@cloudflare/workers-types@4.20250830.0", "", {}, "sha512-uAGZFqEBFnCiwIokxMnrrtjIkT8qyGT1LACSScEUyW7nKmtD0Viykp9QZWrIlssyEp/MDB6XsdALF8y6upxpcg=="], + } +} diff --git a/packages/console/resource/package.json b/packages/console/resource/package.json new file mode 100644 index 000000000..94a654548 --- /dev/null +++ b/packages/console/resource/package.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json.schemastore.org/package.json", + "name": "@opencode/console-resource", + "dependencies": { + "@cloudflare/workers-types": "^4.20250830.0" + }, + "exports": { + ".": { + "production": { + "import": "./resource.cloudflare.ts" + }, + "import": "./resource.node.ts" + } + } +} diff --git a/packages/console/resource/resource.cloudflare.ts b/packages/console/resource/resource.cloudflare.ts new file mode 100644 index 000000000..a56b1e417 --- /dev/null +++ b/packages/console/resource/resource.cloudflare.ts @@ -0,0 +1,18 @@ +import { env } from "cloudflare:workers" + +export const Resource = new Proxy( + {}, + { + get(_target, prop: string) { + if (prop in env) { + // @ts-expect-error + const value = env[prop] + return typeof value === "string" ? JSON.parse(value) : value + } else if (prop === "App") { + // @ts-expect-error + return JSON.parse(env.SST_RESOURCE_App) + } + throw new Error(`"${prop}" is not linked in your sst.config.ts (cloudflare)`) + }, + }, +) as Record diff --git a/packages/console/resource/resource.node.ts b/packages/console/resource/resource.node.ts new file mode 100644 index 000000000..d7dbb6c6d --- /dev/null +++ b/packages/console/resource/resource.node.ts @@ -0,0 +1 @@ +export { Resource } from "sst" diff --git a/packages/console/resource/sst-env.d.ts b/packages/console/resource/sst-env.d.ts new file mode 100644 index 000000000..09c60c7c2 --- /dev/null +++ b/packages/console/resource/sst-env.d.ts @@ -0,0 +1,96 @@ +/* This file is auto-generated by SST. Do not edit. */ +/* tslint:disable */ +/* eslint-disable */ +/* deno-fmt-ignore-file */ + +import "sst" +declare module "sst" { + export interface Resource { + "ANTHROPIC_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string + } + "BASETEN_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string + } + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string + } + "FIREWORKS_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string + } + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string + } + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "OPENAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "XAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + } +} +// cloudflare +import * as cloudflare from "@cloudflare/workers-types"; +declare module "sst" { + export interface Resource { + "Api": cloudflare.Service + "AuthApi": cloudflare.Service + "AuthStorage": cloudflare.KVNamespace + "Bucket": cloudflare.R2Bucket + "LogProcessor": cloudflare.Service + } +} + +import "sst" +export {} \ No newline at end of file diff --git a/packages/console/resource/tsconfig.json b/packages/console/resource/tsconfig.json new file mode 100644 index 000000000..0faf16aab --- /dev/null +++ b/packages/console/resource/tsconfig.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/node22/tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler", + "types": ["@cloudflare/workers-types", "node"] + } +} diff --git a/packages/console/scripts/.gitignore b/packages/console/scripts/.gitignore new file mode 100644 index 000000000..18c5ea0f8 --- /dev/null +++ b/packages/console/scripts/.gitignore @@ -0,0 +1 @@ +src/scrap.ts diff --git a/packages/console/scripts/package.json b/packages/console/scripts/package.json new file mode 100644 index 000000000..06795ee15 --- /dev/null +++ b/packages/console/scripts/package.json @@ -0,0 +1,20 @@ +{ + "name": "@opencode/console-scripts", + "version": "0.9.11", + "$schema": "https://json.schemastore.org/package.json", + "private": true, + "type": "module", + "scripts": { + "shell": "sst shell -- bun tsx", + "shell-dev": "sst shell --stage dev -- bun tsx", + "shell-prod": "sst shell --stage production -- bun tsx" + }, + "dependencies": { + "@opencode/console-core": "workspace:*", + "tsx": "4.20.5" + }, + "devDependencies": { + "@types/node": "catalog:", + "typescript": "catalog:" + } +} diff --git a/packages/console/scripts/src/backfill-usage-provider.ts b/packages/console/scripts/src/backfill-usage-provider.ts new file mode 100644 index 000000000..1485735da --- /dev/null +++ b/packages/console/scripts/src/backfill-usage-provider.ts @@ -0,0 +1,10 @@ +import { Database, eq } from "@opencode/console-core/drizzle/index.js" +import { UsageTable } from "@opencode/console-core/schema/billing.sql.js" + +await Database.use(async (tx) => { + await tx + .update(UsageTable) + .set({ model: "grok-code" }) + .where(eq(UsageTable.model, "x-ai/grok-code-fast-1")) + .limit(90000) +}) diff --git a/packages/console/scripts/sst-env.d.ts b/packages/console/scripts/sst-env.d.ts new file mode 100644 index 000000000..9b9de7327 --- /dev/null +++ b/packages/console/scripts/sst-env.d.ts @@ -0,0 +1,9 @@ +/* This file is auto-generated by SST. Do not edit. */ +/* tslint:disable */ +/* eslint-disable */ +/* deno-fmt-ignore-file */ + +/// + +import "sst" +export {} \ No newline at end of file diff --git a/packages/console/scripts/tsconfig.json b/packages/console/scripts/tsconfig.json new file mode 100644 index 000000000..0faf16aab --- /dev/null +++ b/packages/console/scripts/tsconfig.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/node22/tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler", + "types": ["@cloudflare/workers-types", "node"] + } +} diff --git a/packages/function/sst-env.d.ts b/packages/function/sst-env.d.ts index afa8c6fe7..09c60c7c2 100644 --- a/packages/function/sst-env.d.ts +++ b/packages/function/sst-env.d.ts @@ -6,91 +6,91 @@ import "sst" declare module "sst" { export interface Resource { - ANTHROPIC_API_KEY: { - type: "sst.sst.Secret" - value: string - } - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string - } - BASETEN_API_KEY: { - type: "sst.sst.Secret" - value: string - } - Console: { - type: "sst.cloudflare.SolidStart" - url: string - } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string - } - FIREWORKS_API_KEY: { - type: "sst.sst.Secret" - value: string - } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string - } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string - } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string - } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string - } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string - } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string - } - OPENAI_API_KEY: { - type: "sst.sst.Secret" - value: string - } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string - } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string - } - Web: { - type: "sst.cloudflare.Astro" - url: string - } - XAI_API_KEY: { - type: "sst.sst.Secret" - value: string + "ANTHROPIC_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string + } + "BASETEN_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string + } + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string + } + "FIREWORKS_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string + } + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string + } + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string + } + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "OPENAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string + } + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "XAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string } } } -// cloudflare -import * as cloudflare from "@cloudflare/workers-types" +// cloudflare +import * as cloudflare from "@cloudflare/workers-types"; declare module "sst" { export interface Resource { - Api: cloudflare.Service - AuthApi: cloudflare.Service - AuthStorage: cloudflare.KVNamespace - Bucket: cloudflare.R2Bucket - LogProcessor: cloudflare.Service + "Api": cloudflare.Service + "AuthApi": cloudflare.Service + "AuthStorage": cloudflare.KVNamespace + "Bucket": cloudflare.R2Bucket + "LogProcessor": cloudflare.Service } } import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/opencode/sst-env.d.ts b/packages/opencode/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/opencode/sst-env.d.ts +++ b/packages/opencode/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/plugin/sst-env.d.ts b/packages/plugin/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/plugin/sst-env.d.ts +++ b/packages/plugin/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/sdk/js/sst-env.d.ts b/packages/sdk/js/sst-env.d.ts index bd5588217..9b9de7327 100644 --- a/packages/sdk/js/sst-env.d.ts +++ b/packages/sdk/js/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/web/sst-env.d.ts b/packages/web/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/web/sst-env.d.ts +++ b/packages/web/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/sdks/vscode/sst-env.d.ts b/sdks/vscode/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/sdks/vscode/sst-env.d.ts +++ b/sdks/vscode/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/sst-env.d.ts b/sst-env.d.ts index 22caba969..e45b4e5ea 100644 --- a/sst-env.d.ts +++ b/sst-env.d.ts @@ -5,99 +5,99 @@ declare module "sst" { export interface Resource { - ANTHROPIC_API_KEY: { - type: "sst.sst.Secret" - value: string + "ANTHROPIC_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string } - Api: { - type: "sst.cloudflare.Worker" - url: string + "Api": { + "type": "sst.cloudflare.Worker" + "url": string } - AuthApi: { - type: "sst.cloudflare.Worker" - url: string + "AuthApi": { + "type": "sst.cloudflare.Worker" + "url": string } - AuthStorage: { - type: "sst.cloudflare.Kv" + "AuthStorage": { + "type": "sst.cloudflare.Kv" } - BASETEN_API_KEY: { - type: "sst.sst.Secret" - value: string + "BASETEN_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - Bucket: { - name: string - type: "sst.cloudflare.Bucket" + "Bucket": { + "name": string + "type": "sst.cloudflare.Bucket" } - Console: { - type: "sst.cloudflare.SolidStart" - url: string + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string } - FIREWORKS_API_KEY: { - type: "sst.sst.Secret" - value: string + "FIREWORKS_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - LogProcessor: { - type: "sst.cloudflare.Worker" + "LogProcessor": { + "type": "sst.cloudflare.Worker" } - OPENAI_API_KEY: { - type: "sst.sst.Secret" - value: string + "OPENAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string } - Web: { - type: "sst.cloudflare.Astro" - url: string + "Web": { + "type": "sst.cloudflare.Astro" + "url": string } - XAI_API_KEY: { - type: "sst.sst.Secret" - value: string + "XAI_API_KEY": { + "type": "sst.sst.Secret" + "value": string } } } /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/sst.config.ts b/sst.config.ts index 05e50e50a..5fcd4273a 100644 --- a/sst.config.ts +++ b/sst.config.ts @@ -16,7 +16,7 @@ export default $config({ }, async run() { await import("./infra/app.js") - await import("./infra/cloud.js") + await import("./infra/console.js") //await import("./infra/desktop.js") }, }) -- cgit v1.2.3