From e4eb98b9911d0cd6bd3378d51b974b14828c8543 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Tue, 19 May 2026 15:52:51 +0000 Subject: [PATCH] chore: generate --- .../console/app/src/component/go-referral.tsx | 16 ++- packages/console/app/src/i18n/br.ts | 3 +- packages/console/app/src/i18n/da.ts | 3 +- packages/console/app/src/i18n/de.ts | 3 +- packages/console/app/src/i18n/es.ts | 3 +- packages/console/app/src/i18n/fr.ts | 3 +- packages/console/app/src/i18n/it.ts | 3 +- packages/console/app/src/i18n/ja.ts | 6 +- packages/console/app/src/i18n/no.ts | 3 +- packages/console/app/src/i18n/pl.ts | 3 +- packages/console/app/src/i18n/ru.ts | 3 +- packages/console/app/src/i18n/tr.ts | 3 +- packages/console/app/src/routes/black.css | 1 - .../workspace/[id]/go/lite-section.module.css | 1 - .../routes/workspace/[id]/go/lite-section.tsx | 3 +- .../snapshot.json | 109 ++++------------- .../20260516082200_long_spirit/snapshot.json | 109 ++++------------- .../snapshot.json | 109 ++++------------- .../snapshot.json | 110 ++++-------------- .../snapshot.json | 110 ++++-------------- .../snapshot.json | 110 ++++-------------- packages/console/core/src/referral.ts | 59 ++++++---- .../console/core/src/schema/referral.sql.ts | 5 +- .../console/core/src/schema/workspace.sql.ts | 5 +- 24 files changed, 215 insertions(+), 568 deletions(-) diff --git a/packages/console/app/src/component/go-referral.tsx b/packages/console/app/src/component/go-referral.tsx index 6a186974ea..e1f4174c74 100644 --- a/packages/console/app/src/component/go-referral.tsx +++ b/packages/console/app/src/component/go-referral.tsx @@ -35,10 +35,9 @@ export const queryGoReferralUsagePreview = query(async (workspaceID: string, ref export const applyGoReferralReward = action(async (workspaceID: string, referralID: string) => { "use server" - return json( - await withActor(() => Referral.applyReward({ referralID }), workspaceID), - { revalidate: [queryGoReferral.key, queryGoReferralUsagePreview.key, queryLiteSubscription.key] }, - ) + return json(await withActor(() => Referral.applyReward({ referralID }), workspaceID), { + revalidate: [queryGoReferral.key, queryGoReferralUsagePreview.key, queryLiteSubscription.key], + }) }, "go.referral.reward.apply") function currentUsagePreview(usage: { resetInSec: number; usagePercent: number }) { @@ -245,7 +244,11 @@ export function GoReferralSection(props: { workspaceID: string; summary: GoRefer - setSelected(undefined)} title={i18n.t("workspace.referral.apply.confirmTitle")}> + setSelected(undefined)} + title={i18n.t("workspace.referral.apply.confirmTitle")} + >

{i18n.t("workspace.referral.apply.confirmBody", { @@ -306,7 +309,8 @@ function GoReferralUsagePreviewRow(props: { label: string; usage: GoReferralUsag

- {i18n.t("workspace.lite.subscription.resetsIn")} {formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)} + {i18n.t("workspace.lite.subscription.resetsIn")}{" "} + {formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)}
) diff --git a/packages/console/app/src/i18n/br.ts b/packages/console/app/src/i18n/br.ts index 4cd1ef2747..9e0024898a 100644 --- a/packages/console/app/src/i18n/br.ts +++ b/packages/console/app/src/i18n/br.ts @@ -697,7 +697,8 @@ export const dict = { "workspace.referral.apply.preview": "Visualizar", "workspace.referral.apply.action": "Aplicar", "workspace.referral.apply.confirmTitle": "Aplicar recompensa Go", - "workspace.referral.apply.confirmBody": "Aplique {{amount}} para reduzir os contadores atuais de uso do Go deste workspace.", + "workspace.referral.apply.confirmBody": + "Aplique {{amount}} para reduzir os contadores atuais de uso do Go deste workspace.", "workspace.referral.apply.confirmAction": "Aplicar", "download.title": "OpenCode | Baixar", diff --git a/packages/console/app/src/i18n/da.ts b/packages/console/app/src/i18n/da.ts index 2e27ddac33..13c1a8a6cb 100644 --- a/packages/console/app/src/i18n/da.ts +++ b/packages/console/app/src/i18n/da.ts @@ -693,7 +693,8 @@ export const dict = { "workspace.referral.apply.preview": "Forhåndsvis", "workspace.referral.apply.action": "Brug", "workspace.referral.apply.confirmTitle": "Brug Go-belønning", - "workspace.referral.apply.confirmBody": "Brug {{amount}} til at reducere dette workspaces nuværende Go-forbrugstællere.", + "workspace.referral.apply.confirmBody": + "Brug {{amount}} til at reducere dette workspaces nuværende Go-forbrugstællere.", "workspace.referral.apply.confirmAction": "Brug", "download.title": "OpenCode | Download", diff --git a/packages/console/app/src/i18n/de.ts b/packages/console/app/src/i18n/de.ts index 6f6986e745..9debb9f959 100644 --- a/packages/console/app/src/i18n/de.ts +++ b/packages/console/app/src/i18n/de.ts @@ -696,7 +696,8 @@ export const dict = { "workspace.referral.apply.preview": "Vorschau", "workspace.referral.apply.action": "Einlösen", "workspace.referral.apply.confirmTitle": "Go-Belohnung einlösen", - "workspace.referral.apply.confirmBody": "Löse {{amount}} ein, um die aktuellen Go-Nutzungszähler dieses Workspace zu reduzieren.", + "workspace.referral.apply.confirmBody": + "Löse {{amount}} ein, um die aktuellen Go-Nutzungszähler dieses Workspace zu reduzieren.", "workspace.referral.apply.confirmAction": "Einlösen", "download.title": "OpenCode | Download", diff --git a/packages/console/app/src/i18n/es.ts b/packages/console/app/src/i18n/es.ts index 071d3a2c76..9b00cc6443 100644 --- a/packages/console/app/src/i18n/es.ts +++ b/packages/console/app/src/i18n/es.ts @@ -697,7 +697,8 @@ export const dict = { "workspace.referral.apply.preview": "Vista previa", "workspace.referral.apply.action": "Aplicar", "workspace.referral.apply.confirmTitle": "Aplicar recompensa de Go", - "workspace.referral.apply.confirmBody": "Aplica {{amount}} para reducir los contadores actuales de uso de Go de este workspace.", + "workspace.referral.apply.confirmBody": + "Aplica {{amount}} para reducir los contadores actuales de uso de Go de este workspace.", "workspace.referral.apply.confirmAction": "Aplicar", "download.title": "OpenCode | Descargar", diff --git a/packages/console/app/src/i18n/fr.ts b/packages/console/app/src/i18n/fr.ts index 7ae31968fa..0bd79399b3 100644 --- a/packages/console/app/src/i18n/fr.ts +++ b/packages/console/app/src/i18n/fr.ts @@ -703,7 +703,8 @@ export const dict = { "workspace.referral.apply.preview": "Aperçu", "workspace.referral.apply.action": "Utiliser", "workspace.referral.apply.confirmTitle": "Utiliser la récompense Go", - "workspace.referral.apply.confirmBody": "Utilisez {{amount}} pour réduire les compteurs d'utilisation Go actuels de ce workspace.", + "workspace.referral.apply.confirmBody": + "Utilisez {{amount}} pour réduire les compteurs d'utilisation Go actuels de ce workspace.", "workspace.referral.apply.confirmAction": "Utiliser", "download.title": "OpenCode | Téléchargement", diff --git a/packages/console/app/src/i18n/it.ts b/packages/console/app/src/i18n/it.ts index a2d300bede..ab62763843 100644 --- a/packages/console/app/src/i18n/it.ts +++ b/packages/console/app/src/i18n/it.ts @@ -695,7 +695,8 @@ export const dict = { "workspace.referral.apply.preview": "Anteprima", "workspace.referral.apply.action": "Utilizza", "workspace.referral.apply.confirmTitle": "Utilizza premio Go", - "workspace.referral.apply.confirmBody": "Utilizza {{amount}} per ridurre i contatori di utilizzo Go attuali di questo workspace.", + "workspace.referral.apply.confirmBody": + "Utilizza {{amount}} per ridurre i contatori di utilizzo Go attuali di questo workspace.", "workspace.referral.apply.confirmAction": "Utilizza", "download.title": "OpenCode | Download", diff --git a/packages/console/app/src/i18n/ja.ts b/packages/console/app/src/i18n/ja.ts index 003682ec53..a6c4158c64 100644 --- a/packages/console/app/src/i18n/ja.ts +++ b/packages/console/app/src/i18n/ja.ts @@ -671,7 +671,8 @@ export const dict = { "workspace.referral.copyLink": "リンクをコピー", "workspace.referral.copied": "コピーしました", "workspace.referral.overview.title": "友達を Go に招待", - "workspace.referral.overview.subtitle": "友達がサブスクライブすると $5 分の Go クレジットを獲得。友達にも $5 が付与されます。", + "workspace.referral.overview.subtitle": + "友達がサブスクライブすると $5 分の Go クレジットを獲得。友達にも $5 が付与されます。", "workspace.referral.stats.invites": "招待", "workspace.referral.stats.earned": "獲得", "workspace.referral.stats.applied": "適用済み", @@ -695,7 +696,8 @@ export const dict = { "workspace.referral.apply.preview": "プレビュー", "workspace.referral.apply.action": "適用", "workspace.referral.apply.confirmTitle": "Go 特典を適用", - "workspace.referral.apply.confirmBody": "{{amount}} を適用して、このワークスペースの現在の Go 使用カウンターを減らします。", + "workspace.referral.apply.confirmBody": + "{{amount}} を適用して、このワークスペースの現在の Go 使用カウンターを減らします。", "workspace.referral.apply.confirmAction": "適用", "download.title": "OpenCode | ダウンロード", diff --git a/packages/console/app/src/i18n/no.ts b/packages/console/app/src/i18n/no.ts index e80c3ff19e..019db79ba0 100644 --- a/packages/console/app/src/i18n/no.ts +++ b/packages/console/app/src/i18n/no.ts @@ -694,7 +694,8 @@ export const dict = { "workspace.referral.apply.preview": "Forhåndsvis", "workspace.referral.apply.action": "Bruk", "workspace.referral.apply.confirmTitle": "Bruk Go-belønning", - "workspace.referral.apply.confirmBody": "Bruk {{amount}} for å redusere dette workspacets nåværende Go-forbrukstellere.", + "workspace.referral.apply.confirmBody": + "Bruk {{amount}} for å redusere dette workspacets nåværende Go-forbrukstellere.", "workspace.referral.apply.confirmAction": "Bruk", "download.title": "OpenCode | Last ned", diff --git a/packages/console/app/src/i18n/pl.ts b/packages/console/app/src/i18n/pl.ts index 8ec6c519ea..5f123158dd 100644 --- a/packages/console/app/src/i18n/pl.ts +++ b/packages/console/app/src/i18n/pl.ts @@ -695,7 +695,8 @@ export const dict = { "workspace.referral.apply.preview": "Podgląd", "workspace.referral.apply.action": "Wykorzystaj", "workspace.referral.apply.confirmTitle": "Wykorzystaj nagrodę Go", - "workspace.referral.apply.confirmBody": "Wykorzystaj {{amount}}, aby zmniejszyć aktualne liczniki użycia Go w tym workspace.", + "workspace.referral.apply.confirmBody": + "Wykorzystaj {{amount}}, aby zmniejszyć aktualne liczniki użycia Go w tym workspace.", "workspace.referral.apply.confirmAction": "Wykorzystaj", "download.title": "OpenCode | Pobierz", diff --git a/packages/console/app/src/i18n/ru.ts b/packages/console/app/src/i18n/ru.ts index 9f0a108c04..40e75727f9 100644 --- a/packages/console/app/src/i18n/ru.ts +++ b/packages/console/app/src/i18n/ru.ts @@ -701,7 +701,8 @@ export const dict = { "workspace.referral.apply.preview": "Предпросмотр", "workspace.referral.apply.action": "Применить", "workspace.referral.apply.confirmTitle": "Применить награду Go", - "workspace.referral.apply.confirmBody": "Используйте {{amount}}, чтобы уменьшить текущие счётчики использования Go этого workspace.", + "workspace.referral.apply.confirmBody": + "Используйте {{amount}}, чтобы уменьшить текущие счётчики использования Go этого workspace.", "workspace.referral.apply.confirmAction": "Применить", "download.title": "OpenCode | Скачать", diff --git a/packages/console/app/src/i18n/tr.ts b/packages/console/app/src/i18n/tr.ts index f6cf2d2b6a..c38a5b2fd6 100644 --- a/packages/console/app/src/i18n/tr.ts +++ b/packages/console/app/src/i18n/tr.ts @@ -697,7 +697,8 @@ export const dict = { "workspace.referral.apply.preview": "Önizleme", "workspace.referral.apply.action": "Kullan", "workspace.referral.apply.confirmTitle": "Go ödülünü kullan", - "workspace.referral.apply.confirmBody": "Bu workspace'in mevcut Go kullanım sayaçlarını azaltmak için {{amount}} kullan.", + "workspace.referral.apply.confirmBody": + "Bu workspace'in mevcut Go kullanım sayaçlarını azaltmak için {{amount}} kullan.", "workspace.referral.apply.confirmAction": "Kullan", "download.title": "OpenCode | İndir", diff --git a/packages/console/app/src/routes/black.css b/packages/console/app/src/routes/black.css index fa78eee560..648a79c33f 100644 --- a/packages/console/app/src/routes/black.css +++ b/packages/console/app/src/routes/black.css @@ -700,7 +700,6 @@ text-decoration: underline; } } - } } diff --git a/packages/console/app/src/routes/workspace/[id]/go/lite-section.module.css b/packages/console/app/src/routes/workspace/[id]/go/lite-section.module.css index 0904f8b4aa..5e598eeaf6 100644 --- a/packages/console/app/src/routes/workspace/[id]/go/lite-section.module.css +++ b/packages/console/app/src/routes/workspace/[id]/go/lite-section.module.css @@ -211,7 +211,6 @@ align-items: center; gap: 4px; } - } .paymentMethodModal { diff --git a/packages/console/app/src/routes/workspace/[id]/go/lite-section.tsx b/packages/console/app/src/routes/workspace/[id]/go/lite-section.tsx index 04d45ce258..a3ce2bf9c9 100644 --- a/packages/console/app/src/routes/workspace/[id]/go/lite-section.tsx +++ b/packages/console/app/src/routes/workspace/[id]/go/lite-section.tsx @@ -140,7 +140,8 @@ function LiteUsageItem(props: { label: string; usage: { usagePercent: number; re
- {i18n.t("workspace.lite.subscription.resetsIn")} {formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)} + {i18n.t("workspace.lite.subscription.resetsIn")}{" "} + {formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)} ) diff --git a/packages/console/core/migrations/20260513173355_groovy_jane_foster/snapshot.json b/packages/console/core/migrations/20260513173355_groovy_jane_foster/snapshot.json index 4ab0b08f7e..3fb58d1fb1 100644 --- a/packages/console/core/migrations/20260513173355_groovy_jane_foster/snapshot.json +++ b/packages/console/core/migrations/20260513173355_groovy_jane_foster/snapshot.json @@ -2,9 +2,7 @@ "version": "6", "dialect": "mysql", "id": "91a9afa8-a5b1-4fa4-b71d-b3ae866744c9", - "prevIds": [ - "c742e0f2-5d89-4216-b843-059d00680f13" - ], + "prevIds": ["c742e0f2-5d89-4216-b843-059d00680f13"], "ddl": [ { "name": "account", @@ -2671,194 +2669,133 @@ "table": "workspace" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "auth", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "benchmark", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "billing", "entityType": "pks" }, { - "columns": [ - "email", - "type" - ], + "columns": ["email", "type"], "name": "PRIMARY", "table": "coupon", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "lite", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "payment", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "subscription", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "usage", "entityType": "pks" }, { - "columns": [ - "ip", - "interval" - ], + "columns": ["ip", "interval"], "name": "PRIMARY", "table": "ip_rate_limit", "entityType": "pks" }, { - "columns": [ - "ip" - ], + "columns": ["ip"], "name": "PRIMARY", "table": "ip", "entityType": "pks" }, { - "columns": [ - "key", - "interval" - ], + "columns": ["key", "interval"], "name": "PRIMARY", "table": "key_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tpm_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tps_rate_limit", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "key", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "model", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "provider", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "referral_code", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "referral_reward", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "referral", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "user", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "workspace", "entityType": "pks" diff --git a/packages/console/core/migrations/20260516082200_long_spirit/snapshot.json b/packages/console/core/migrations/20260516082200_long_spirit/snapshot.json index 0bf2a4b2f7..2bdb0af0e7 100644 --- a/packages/console/core/migrations/20260516082200_long_spirit/snapshot.json +++ b/packages/console/core/migrations/20260516082200_long_spirit/snapshot.json @@ -2,10 +2,7 @@ "version": "6", "dialect": "mysql", "id": "e93db4f6-6e8b-43f4-b883-59d2fd6ede53", - "prevIds": [ - "1f04bd59-35b0-493b-9d55-cfa08207ba8e", - "91a9afa8-a5b1-4fa4-b71d-b3ae866744c9" - ], + "prevIds": ["1f04bd59-35b0-493b-9d55-cfa08207ba8e", "91a9afa8-a5b1-4fa4-b71d-b3ae866744c9"], "ddl": [ { "name": "account", @@ -2574,191 +2571,133 @@ "table": "workspace" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "auth", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "benchmark", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "billing", "entityType": "pks" }, { - "columns": [ - "email", - "type" - ], + "columns": ["email", "type"], "name": "PRIMARY", "table": "coupon", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "lite", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "payment", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "subscription", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "usage", "entityType": "pks" }, { - "columns": [ - "ip", - "interval" - ], + "columns": ["ip", "interval"], "name": "PRIMARY", "table": "ip_rate_limit", "entityType": "pks" }, { - "columns": [ - "ip" - ], + "columns": ["ip"], "name": "PRIMARY", "table": "ip", "entityType": "pks" }, { - "columns": [ - "key", - "interval" - ], + "columns": ["key", "interval"], "name": "PRIMARY", "table": "key_rate_limit", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "model_sticky_provider", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tpm_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tps_rate_limit", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "key", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "model", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "provider", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "user", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "referral_reward", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "referral", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "workspace", "entityType": "pks" @@ -3121,4 +3060,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/console/core/migrations/20260516110447_classy_wilson_fisk/snapshot.json b/packages/console/core/migrations/20260516110447_classy_wilson_fisk/snapshot.json index 5e0d535173..f229312518 100644 --- a/packages/console/core/migrations/20260516110447_classy_wilson_fisk/snapshot.json +++ b/packages/console/core/migrations/20260516110447_classy_wilson_fisk/snapshot.json @@ -2,9 +2,7 @@ "version": "6", "dialect": "mysql", "id": "77de1eaf-69f6-433f-b244-cda75319450a", - "prevIds": [ - "e93db4f6-6e8b-43f4-b883-59d2fd6ede53" - ], + "prevIds": ["e93db4f6-6e8b-43f4-b883-59d2fd6ede53"], "ddl": [ { "name": "account", @@ -2559,192 +2557,133 @@ "table": "workspace" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "auth", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "benchmark", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "billing", "entityType": "pks" }, { - "columns": [ - "email", - "type" - ], + "columns": ["email", "type"], "name": "PRIMARY", "table": "coupon", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "lite", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "payment", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "subscription", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "usage", "entityType": "pks" }, { - "columns": [ - "ip", - "interval" - ], + "columns": ["ip", "interval"], "name": "PRIMARY", "table": "ip_rate_limit", "entityType": "pks" }, { - "columns": [ - "ip" - ], + "columns": ["ip"], "name": "PRIMARY", "table": "ip", "entityType": "pks" }, { - "columns": [ - "key", - "interval" - ], + "columns": ["key", "interval"], "name": "PRIMARY", "table": "key_rate_limit", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "model_sticky_provider", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tpm_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tps_rate_limit", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "key", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "model", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "provider", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "referral_id" - ], + "columns": ["workspace_id", "referral_id"], "name": "PRIMARY", "table": "referral_reward", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "user", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "referral", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "workspace", "entityType": "pks" @@ -3087,4 +3026,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/console/core/migrations/20260516112143_cynical_dexter_bennett/snapshot.json b/packages/console/core/migrations/20260516112143_cynical_dexter_bennett/snapshot.json index 73c4209c2f..c38a24ee8b 100644 --- a/packages/console/core/migrations/20260516112143_cynical_dexter_bennett/snapshot.json +++ b/packages/console/core/migrations/20260516112143_cynical_dexter_bennett/snapshot.json @@ -2,9 +2,7 @@ "version": "6", "dialect": "mysql", "id": "9809797a-e6f6-418c-8532-196553b315b8", - "prevIds": [ - "77de1eaf-69f6-433f-b244-cda75319450a" - ], + "prevIds": ["77de1eaf-69f6-433f-b244-cda75319450a"], "ddl": [ { "name": "account", @@ -2559,193 +2557,133 @@ "table": "workspace" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "auth", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "benchmark", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "billing", "entityType": "pks" }, { - "columns": [ - "email", - "type" - ], + "columns": ["email", "type"], "name": "PRIMARY", "table": "coupon", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "lite", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "payment", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "subscription", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "usage", "entityType": "pks" }, { - "columns": [ - "ip", - "interval" - ], + "columns": ["ip", "interval"], "name": "PRIMARY", "table": "ip_rate_limit", "entityType": "pks" }, { - "columns": [ - "ip" - ], + "columns": ["ip"], "name": "PRIMARY", "table": "ip", "entityType": "pks" }, { - "columns": [ - "key", - "interval" - ], + "columns": ["key", "interval"], "name": "PRIMARY", "table": "key_rate_limit", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "model_sticky_provider", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tpm_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tps_rate_limit", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "key", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "model", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "provider", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "referral_id" - ], + "columns": ["workspace_id", "referral_id"], "name": "PRIMARY", "table": "referral_reward", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "referral", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "user", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "workspace", "entityType": "pks" @@ -3072,4 +3010,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/console/core/migrations/20260516222132_referral_code_length/snapshot.json b/packages/console/core/migrations/20260516222132_referral_code_length/snapshot.json index 9841c032b9..b7265ebefa 100644 --- a/packages/console/core/migrations/20260516222132_referral_code_length/snapshot.json +++ b/packages/console/core/migrations/20260516222132_referral_code_length/snapshot.json @@ -2,9 +2,7 @@ "version": "6", "dialect": "mysql", "id": "e49321c9-2b03-4e2c-b2f0-76fbb88088ea", - "prevIds": [ - "9809797a-e6f6-418c-8532-196553b315b8" - ], + "prevIds": ["9809797a-e6f6-418c-8532-196553b315b8"], "ddl": [ { "name": "account", @@ -2559,193 +2557,133 @@ "table": "workspace" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "auth", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "benchmark", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "billing", "entityType": "pks" }, { - "columns": [ - "email", - "type" - ], + "columns": ["email", "type"], "name": "PRIMARY", "table": "coupon", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "lite", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "payment", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "subscription", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "usage", "entityType": "pks" }, { - "columns": [ - "ip", - "interval" - ], + "columns": ["ip", "interval"], "name": "PRIMARY", "table": "ip_rate_limit", "entityType": "pks" }, { - "columns": [ - "ip" - ], + "columns": ["ip"], "name": "PRIMARY", "table": "ip", "entityType": "pks" }, { - "columns": [ - "key", - "interval" - ], + "columns": ["key", "interval"], "name": "PRIMARY", "table": "key_rate_limit", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "model_sticky_provider", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tpm_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tps_rate_limit", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "key", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "model", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "provider", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "referral_id" - ], + "columns": ["workspace_id", "referral_id"], "name": "PRIMARY", "table": "referral_reward", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "referral", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "user", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "workspace", "entityType": "pks" @@ -3072,4 +3010,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/console/core/migrations/20260518181630_secret_strong_guy/snapshot.json b/packages/console/core/migrations/20260518181630_secret_strong_guy/snapshot.json index 5b8e94a7ff..c7625a714e 100644 --- a/packages/console/core/migrations/20260518181630_secret_strong_guy/snapshot.json +++ b/packages/console/core/migrations/20260518181630_secret_strong_guy/snapshot.json @@ -2,9 +2,7 @@ "version": "6", "dialect": "mysql", "id": "9a7123cb-5c2c-47f6-b22f-8fd6a02dcb03", - "prevIds": [ - "e49321c9-2b03-4e2c-b2f0-76fbb88088ea" - ], + "prevIds": ["e49321c9-2b03-4e2c-b2f0-76fbb88088ea"], "ddl": [ { "name": "account", @@ -2559,193 +2557,133 @@ "table": "workspace" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "auth", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "benchmark", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "billing", "entityType": "pks" }, { - "columns": [ - "email", - "type" - ], + "columns": ["email", "type"], "name": "PRIMARY", "table": "coupon", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "lite", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "payment", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "subscription", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "usage", "entityType": "pks" }, { - "columns": [ - "ip", - "interval" - ], + "columns": ["ip", "interval"], "name": "PRIMARY", "table": "ip_rate_limit", "entityType": "pks" }, { - "columns": [ - "ip" - ], + "columns": ["ip"], "name": "PRIMARY", "table": "ip", "entityType": "pks" }, { - "columns": [ - "key", - "interval" - ], + "columns": ["key", "interval"], "name": "PRIMARY", "table": "key_rate_limit", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "model_sticky_provider", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tpm_rate_limit", "entityType": "pks" }, { - "columns": [ - "id", - "interval" - ], + "columns": ["id", "interval"], "name": "PRIMARY", "table": "model_tps_rate_limit", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "key", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "model", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "provider", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "referral_id" - ], + "columns": ["workspace_id", "referral_id"], "name": "PRIMARY", "table": "referral_reward", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "referral", "entityType": "pks" }, { - "columns": [ - "workspace_id", - "id" - ], + "columns": ["workspace_id", "id"], "name": "PRIMARY", "table": "user", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "name": "PRIMARY", "table": "workspace", "entityType": "pks" @@ -3072,4 +3010,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/console/core/src/referral.ts b/packages/console/core/src/referral.ts index 7150a21bdc..d9d88bf104 100644 --- a/packages/console/core/src/referral.ts +++ b/packages/console/core/src/referral.ts @@ -19,7 +19,10 @@ export namespace Referral { export const CODE_LENGTH = 10 export function normalizeCode(code?: string | null) { - return code?.toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, CODE_LENGTH) + return code + ?.toUpperCase() + .replace(/[^A-Z0-9]/g, "") + .slice(0, CODE_LENGTH) } function generateCode() { @@ -41,7 +44,11 @@ export namespace Referral { .update(WorkspaceTable) .set({ referralCode: generateCode() }) .where( - and(eq(WorkspaceTable.id, workspaceID), isNull(WorkspaceTable.referralCode), isNull(WorkspaceTable.timeDeleted)), + and( + eq(WorkspaceTable.id, workspaceID), + isNull(WorkspaceTable.referralCode), + isNull(WorkspaceTable.timeDeleted), + ), ) const created = await tx @@ -74,7 +81,10 @@ export namespace Referral { }) .from(ReferralRewardTable) .innerJoin(ReferralTable, eq(ReferralTable.id, ReferralRewardTable.referralID)) - .innerJoin(AuthTable, and(eq(AuthTable.accountID, ReferralTable.inviteeAccountID), eq(AuthTable.provider, "email"))) + .innerJoin( + AuthTable, + and(eq(AuthTable.accountID, ReferralTable.inviteeAccountID), eq(AuthTable.provider, "email")), + ) .where( and( eq(ReferralRewardTable.workspaceID, workspaceID), @@ -86,12 +96,18 @@ export namespace Referral { tx .select({ id: ReferralTable.id, inviteeEmail: AuthTable.subject, timeCreated: ReferralTable.timeCreated }) .from(ReferralTable) - .innerJoin(AuthTable, and(eq(AuthTable.accountID, ReferralTable.inviteeAccountID), eq(AuthTable.provider, "email"))) + .innerJoin( + AuthTable, + and(eq(AuthTable.accountID, ReferralTable.inviteeAccountID), eq(AuthTable.provider, "email")), + ) .where(and(eq(ReferralTable.workspaceID, workspaceID), isNull(ReferralTable.timeDeleted))), tx .select({ id: ReferralTable.id, inviteeEmail: AuthTable.subject, timeCreated: ReferralTable.timeCreated }) .from(ReferralTable) - .innerJoin(AuthTable, and(eq(AuthTable.accountID, ReferralTable.inviteeAccountID), eq(AuthTable.provider, "email"))) + .innerJoin( + AuthTable, + and(eq(AuthTable.accountID, ReferralTable.inviteeAccountID), eq(AuthTable.provider, "email")), + ) .where(and(eq(ReferralTable.inviteeAccountID, accountID), isNull(ReferralTable.timeDeleted))), tx .select({ referralID: ReferralRewardTable.referralID }) @@ -158,9 +174,7 @@ export namespace Referral { hasActiveGo: !!rows.lite, rewardAmount: microCentsToCents(REWARD_AMOUNT), totalEarned: rewards.reduce((total, reward) => total + reward.amount, 0), - totalApplied: rewards - .filter((reward) => reward.timeApplied) - .reduce((total, reward) => total + reward.amount, 0), + totalApplied: rewards.filter((reward) => reward.timeApplied).reduce((total, reward) => total + reward.amount, 0), rewards: allRewards, } }) @@ -277,10 +291,7 @@ export namespace Referral { } }) - export async function createFromAccount(input: { - accountID: string - referralCode?: string - }) { + export async function createFromAccount(input: { accountID: string; referralCode?: string }) { const referralCode = normalizeCode(input.referralCode) if (!referralCode) return @@ -313,14 +324,11 @@ export namespace Referral { if (selfReferral) throw new Error("Self-referral is not allowed") const referralID = Identifier.create("referral") - await tx - .insert(ReferralTable) - .ignore() - .values({ - workspaceID: code.workspaceID, - id: referralID, - inviteeAccountID: input.accountID, - }) + await tx.insert(ReferralTable).ignore().values({ + workspaceID: code.workspaceID, + id: referralID, + inviteeAccountID: input.accountID, + }) const referral = await tx .select({ id: ReferralTable.id, workspaceID: ReferralTable.workspaceID }) @@ -332,16 +340,17 @@ export namespace Referral { }) } - export async function completeFromLiteSubscription(input: { - workspaceID: string - userID: string - }) { + export async function completeFromLiteSubscription(input: { workspaceID: string; userID: string }) { return Database.transaction(async (tx) => { const invitee = await tx .select({ accountID: UserTable.accountID }) .from(UserTable) .where( - and(eq(UserTable.workspaceID, input.workspaceID), eq(UserTable.id, input.userID), isNull(UserTable.timeDeleted)), + and( + eq(UserTable.workspaceID, input.workspaceID), + eq(UserTable.id, input.userID), + isNull(UserTable.timeDeleted), + ), ) .then((rows) => rows[0]) if (!invitee?.accountID) throw new Error("Referral invitee account missing") diff --git a/packages/console/core/src/schema/referral.sql.ts b/packages/console/core/src/schema/referral.sql.ts index 63d01a2c7d..8a83254411 100644 --- a/packages/console/core/src/schema/referral.sql.ts +++ b/packages/console/core/src/schema/referral.sql.ts @@ -9,10 +9,7 @@ export const ReferralTable = mysqlTable( ...timestamps, inviteeAccountID: ulid("invitee_account_id").notNull(), }, - (table) => [ - ...workspaceIndexes(table), - uniqueIndex("referral_invitee_account_id").on(table.inviteeAccountID), - ], + (table) => [...workspaceIndexes(table), uniqueIndex("referral_invitee_account_id").on(table.inviteeAccountID)], ) export const ReferralRewardTable = mysqlTable( diff --git a/packages/console/core/src/schema/workspace.sql.ts b/packages/console/core/src/schema/workspace.sql.ts index 7fe7e0c2a2..fc9b0dd5f6 100644 --- a/packages/console/core/src/schema/workspace.sql.ts +++ b/packages/console/core/src/schema/workspace.sql.ts @@ -10,10 +10,7 @@ export const WorkspaceTable = mysqlTable( name: varchar("name", { length: 255 }).notNull(), ...timestamps, }, - (table) => [ - uniqueIndex("slug").on(table.slug), - uniqueIndex("referral_code").on(table.referralCode), - ], + (table) => [uniqueIndex("slug").on(table.slug), uniqueIndex("referral_code").on(table.referralCode)], ) export function workspaceIndexes(table: any) {