chore: generate

This commit is contained in:
opencode-agent[bot]
2026-05-19 15:52:51 +00:00
parent b32f071502
commit e4eb98b991
24 changed files with 215 additions and 568 deletions
@@ -35,10 +35,9 @@ export const queryGoReferralUsagePreview = query(async (workspaceID: string, ref
export const applyGoReferralReward = action(async (workspaceID: string, referralID: string) => { export const applyGoReferralReward = action(async (workspaceID: string, referralID: string) => {
"use server" "use server"
return json( return json(await withActor(() => Referral.applyReward({ referralID }), workspaceID), {
await withActor(() => Referral.applyReward({ referralID }), workspaceID), revalidate: [queryGoReferral.key, queryGoReferralUsagePreview.key, queryLiteSubscription.key],
{ revalidate: [queryGoReferral.key, queryGoReferralUsagePreview.key, queryLiteSubscription.key] }, })
)
}, "go.referral.reward.apply") }, "go.referral.reward.apply")
function currentUsagePreview(usage: { resetInSec: number; usagePercent: number }) { function currentUsagePreview(usage: { resetInSec: number; usagePercent: number }) {
@@ -245,7 +244,11 @@ export function GoReferralSection(props: { workspaceID: string; summary: GoRefer
</table> </table>
</div> </div>
</Show> </Show>
<Modal open={!!selected()} onClose={() => setSelected(undefined)} title={i18n.t("workspace.referral.apply.confirmTitle")}> <Modal
open={!!selected()}
onClose={() => setSelected(undefined)}
title={i18n.t("workspace.referral.apply.confirmTitle")}
>
<div data-component="go-credit-confirm"> <div data-component="go-credit-confirm">
<p> <p>
{i18n.t("workspace.referral.apply.confirmBody", { {i18n.t("workspace.referral.apply.confirmBody", {
@@ -306,7 +309,8 @@ function GoReferralUsagePreviewRow(props: { label: string; usage: GoReferralUsag
<div data-slot="usage-preview-after" style={{ width: `${props.usage.afterPercent}%` }} /> <div data-slot="usage-preview-after" style={{ width: `${props.usage.afterPercent}%` }} />
</div> </div>
<span data-slot="usage-preview-reset"> <span data-slot="usage-preview-reset">
{i18n.t("workspace.lite.subscription.resetsIn")} {formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)} {i18n.t("workspace.lite.subscription.resetsIn")}{" "}
{formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)}
</span> </span>
</div> </div>
) )
+2 -1
View File
@@ -697,7 +697,8 @@ export const dict = {
"workspace.referral.apply.preview": "Visualizar", "workspace.referral.apply.preview": "Visualizar",
"workspace.referral.apply.action": "Aplicar", "workspace.referral.apply.action": "Aplicar",
"workspace.referral.apply.confirmTitle": "Aplicar recompensa Go", "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", "workspace.referral.apply.confirmAction": "Aplicar",
"download.title": "OpenCode | Baixar", "download.title": "OpenCode | Baixar",
+2 -1
View File
@@ -693,7 +693,8 @@ export const dict = {
"workspace.referral.apply.preview": "Forhåndsvis", "workspace.referral.apply.preview": "Forhåndsvis",
"workspace.referral.apply.action": "Brug", "workspace.referral.apply.action": "Brug",
"workspace.referral.apply.confirmTitle": "Brug Go-belønning", "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", "workspace.referral.apply.confirmAction": "Brug",
"download.title": "OpenCode | Download", "download.title": "OpenCode | Download",
+2 -1
View File
@@ -696,7 +696,8 @@ export const dict = {
"workspace.referral.apply.preview": "Vorschau", "workspace.referral.apply.preview": "Vorschau",
"workspace.referral.apply.action": "Einlösen", "workspace.referral.apply.action": "Einlösen",
"workspace.referral.apply.confirmTitle": "Go-Belohnung 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", "workspace.referral.apply.confirmAction": "Einlösen",
"download.title": "OpenCode | Download", "download.title": "OpenCode | Download",
+2 -1
View File
@@ -697,7 +697,8 @@ export const dict = {
"workspace.referral.apply.preview": "Vista previa", "workspace.referral.apply.preview": "Vista previa",
"workspace.referral.apply.action": "Aplicar", "workspace.referral.apply.action": "Aplicar",
"workspace.referral.apply.confirmTitle": "Aplicar recompensa de Go", "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", "workspace.referral.apply.confirmAction": "Aplicar",
"download.title": "OpenCode | Descargar", "download.title": "OpenCode | Descargar",
+2 -1
View File
@@ -703,7 +703,8 @@ export const dict = {
"workspace.referral.apply.preview": "Aperçu", "workspace.referral.apply.preview": "Aperçu",
"workspace.referral.apply.action": "Utiliser", "workspace.referral.apply.action": "Utiliser",
"workspace.referral.apply.confirmTitle": "Utiliser la récompense Go", "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", "workspace.referral.apply.confirmAction": "Utiliser",
"download.title": "OpenCode | Téléchargement", "download.title": "OpenCode | Téléchargement",
+2 -1
View File
@@ -695,7 +695,8 @@ export const dict = {
"workspace.referral.apply.preview": "Anteprima", "workspace.referral.apply.preview": "Anteprima",
"workspace.referral.apply.action": "Utilizza", "workspace.referral.apply.action": "Utilizza",
"workspace.referral.apply.confirmTitle": "Utilizza premio Go", "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", "workspace.referral.apply.confirmAction": "Utilizza",
"download.title": "OpenCode | Download", "download.title": "OpenCode | Download",
+4 -2
View File
@@ -671,7 +671,8 @@ export const dict = {
"workspace.referral.copyLink": "リンクをコピー", "workspace.referral.copyLink": "リンクをコピー",
"workspace.referral.copied": "コピーしました", "workspace.referral.copied": "コピーしました",
"workspace.referral.overview.title": "友達を Go に招待", "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.invites": "招待",
"workspace.referral.stats.earned": "獲得", "workspace.referral.stats.earned": "獲得",
"workspace.referral.stats.applied": "適用済み", "workspace.referral.stats.applied": "適用済み",
@@ -695,7 +696,8 @@ export const dict = {
"workspace.referral.apply.preview": "プレビュー", "workspace.referral.apply.preview": "プレビュー",
"workspace.referral.apply.action": "適用", "workspace.referral.apply.action": "適用",
"workspace.referral.apply.confirmTitle": "Go 特典を適用", "workspace.referral.apply.confirmTitle": "Go 特典を適用",
"workspace.referral.apply.confirmBody": "{{amount}} を適用して、このワークスペースの現在の Go 使用カウンターを減らします。", "workspace.referral.apply.confirmBody":
"{{amount}} を適用して、このワークスペースの現在の Go 使用カウンターを減らします。",
"workspace.referral.apply.confirmAction": "適用", "workspace.referral.apply.confirmAction": "適用",
"download.title": "OpenCode | ダウンロード", "download.title": "OpenCode | ダウンロード",
+2 -1
View File
@@ -694,7 +694,8 @@ export const dict = {
"workspace.referral.apply.preview": "Forhåndsvis", "workspace.referral.apply.preview": "Forhåndsvis",
"workspace.referral.apply.action": "Bruk", "workspace.referral.apply.action": "Bruk",
"workspace.referral.apply.confirmTitle": "Bruk Go-belønning", "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", "workspace.referral.apply.confirmAction": "Bruk",
"download.title": "OpenCode | Last ned", "download.title": "OpenCode | Last ned",
+2 -1
View File
@@ -695,7 +695,8 @@ export const dict = {
"workspace.referral.apply.preview": "Podgląd", "workspace.referral.apply.preview": "Podgląd",
"workspace.referral.apply.action": "Wykorzystaj", "workspace.referral.apply.action": "Wykorzystaj",
"workspace.referral.apply.confirmTitle": "Wykorzystaj nagrodę Go", "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", "workspace.referral.apply.confirmAction": "Wykorzystaj",
"download.title": "OpenCode | Pobierz", "download.title": "OpenCode | Pobierz",
+2 -1
View File
@@ -701,7 +701,8 @@ export const dict = {
"workspace.referral.apply.preview": "Предпросмотр", "workspace.referral.apply.preview": "Предпросмотр",
"workspace.referral.apply.action": "Применить", "workspace.referral.apply.action": "Применить",
"workspace.referral.apply.confirmTitle": "Применить награду Go", "workspace.referral.apply.confirmTitle": "Применить награду Go",
"workspace.referral.apply.confirmBody": "Используйте {{amount}}, чтобы уменьшить текущие счётчики использования Go этого workspace.", "workspace.referral.apply.confirmBody":
"Используйте {{amount}}, чтобы уменьшить текущие счётчики использования Go этого workspace.",
"workspace.referral.apply.confirmAction": "Применить", "workspace.referral.apply.confirmAction": "Применить",
"download.title": "OpenCode | Скачать", "download.title": "OpenCode | Скачать",
+2 -1
View File
@@ -697,7 +697,8 @@ export const dict = {
"workspace.referral.apply.preview": "Önizleme", "workspace.referral.apply.preview": "Önizleme",
"workspace.referral.apply.action": "Kullan", "workspace.referral.apply.action": "Kullan",
"workspace.referral.apply.confirmTitle": "Go ödülünü 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", "workspace.referral.apply.confirmAction": "Kullan",
"download.title": "OpenCode | İndir", "download.title": "OpenCode | İndir",
@@ -700,7 +700,6 @@
text-decoration: underline; text-decoration: underline;
} }
} }
} }
} }
@@ -211,7 +211,6 @@
align-items: center; align-items: center;
gap: 4px; gap: 4px;
} }
} }
.paymentMethodModal { .paymentMethodModal {
@@ -140,7 +140,8 @@ function LiteUsageItem(props: { label: string; usage: { usagePercent: number; re
<div data-slot="progress-bar" style={{ width: `${props.usage.usagePercent}%` }} /> <div data-slot="progress-bar" style={{ width: `${props.usage.usagePercent}%` }} />
</div> </div>
<span data-slot="reset-time"> <span data-slot="reset-time">
{i18n.t("workspace.lite.subscription.resetsIn")} {formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)} {i18n.t("workspace.lite.subscription.resetsIn")}{" "}
{formatResetTime(props.usage.resetInSec, i18n, liteResetTimeKeys)}
</span> </span>
</div> </div>
) )
@@ -2,9 +2,7 @@
"version": "6", "version": "6",
"dialect": "mysql", "dialect": "mysql",
"id": "91a9afa8-a5b1-4fa4-b71d-b3ae866744c9", "id": "91a9afa8-a5b1-4fa4-b71d-b3ae866744c9",
"prevIds": [ "prevIds": ["c742e0f2-5d89-4216-b843-059d00680f13"],
"c742e0f2-5d89-4216-b843-059d00680f13"
],
"ddl": [ "ddl": [
{ {
"name": "account", "name": "account",
@@ -2671,194 +2669,133 @@
"table": "workspace" "table": "workspace"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "account", "table": "account",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "auth", "table": "auth",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "benchmark", "table": "benchmark",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "billing", "table": "billing",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["email", "type"],
"email",
"type"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "coupon", "table": "coupon",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "lite", "table": "lite",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "payment", "table": "payment",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "subscription", "table": "subscription",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "usage", "table": "usage",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip", "interval"],
"ip",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip_rate_limit", "table": "ip_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip"],
"ip"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip", "table": "ip",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["key", "interval"],
"key",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key_rate_limit", "table": "key_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tpm_rate_limit", "table": "model_tpm_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tps_rate_limit", "table": "model_tps_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key", "table": "key",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model", "table": "model",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "provider", "table": "provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_code", "table": "referral_code",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_reward", "table": "referral_reward",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral", "table": "referral",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "user", "table": "user",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "workspace", "table": "workspace",
"entityType": "pks" "entityType": "pks"
@@ -2,10 +2,7 @@
"version": "6", "version": "6",
"dialect": "mysql", "dialect": "mysql",
"id": "e93db4f6-6e8b-43f4-b883-59d2fd6ede53", "id": "e93db4f6-6e8b-43f4-b883-59d2fd6ede53",
"prevIds": [ "prevIds": ["1f04bd59-35b0-493b-9d55-cfa08207ba8e", "91a9afa8-a5b1-4fa4-b71d-b3ae866744c9"],
"1f04bd59-35b0-493b-9d55-cfa08207ba8e",
"91a9afa8-a5b1-4fa4-b71d-b3ae866744c9"
],
"ddl": [ "ddl": [
{ {
"name": "account", "name": "account",
@@ -2574,191 +2571,133 @@
"table": "workspace" "table": "workspace"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "account", "table": "account",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "auth", "table": "auth",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "benchmark", "table": "benchmark",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "billing", "table": "billing",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["email", "type"],
"email",
"type"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "coupon", "table": "coupon",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "lite", "table": "lite",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "payment", "table": "payment",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "subscription", "table": "subscription",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "usage", "table": "usage",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip", "interval"],
"ip",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip_rate_limit", "table": "ip_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip"],
"ip"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip", "table": "ip",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["key", "interval"],
"key",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key_rate_limit", "table": "key_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_sticky_provider", "table": "model_sticky_provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tpm_rate_limit", "table": "model_tpm_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tps_rate_limit", "table": "model_tps_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key", "table": "key",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model", "table": "model",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "provider", "table": "provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "user", "table": "user",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_reward", "table": "referral_reward",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral", "table": "referral",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "workspace", "table": "workspace",
"entityType": "pks" "entityType": "pks"
@@ -2,9 +2,7 @@
"version": "6", "version": "6",
"dialect": "mysql", "dialect": "mysql",
"id": "77de1eaf-69f6-433f-b244-cda75319450a", "id": "77de1eaf-69f6-433f-b244-cda75319450a",
"prevIds": [ "prevIds": ["e93db4f6-6e8b-43f4-b883-59d2fd6ede53"],
"e93db4f6-6e8b-43f4-b883-59d2fd6ede53"
],
"ddl": [ "ddl": [
{ {
"name": "account", "name": "account",
@@ -2559,192 +2557,133 @@
"table": "workspace" "table": "workspace"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "account", "table": "account",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "auth", "table": "auth",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "benchmark", "table": "benchmark",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "billing", "table": "billing",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["email", "type"],
"email",
"type"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "coupon", "table": "coupon",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "lite", "table": "lite",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "payment", "table": "payment",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "subscription", "table": "subscription",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "usage", "table": "usage",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip", "interval"],
"ip",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip_rate_limit", "table": "ip_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip"],
"ip"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip", "table": "ip",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["key", "interval"],
"key",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key_rate_limit", "table": "key_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_sticky_provider", "table": "model_sticky_provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tpm_rate_limit", "table": "model_tpm_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tps_rate_limit", "table": "model_tps_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key", "table": "key",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model", "table": "model",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "provider", "table": "provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "referral_id"],
"workspace_id",
"referral_id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_reward", "table": "referral_reward",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "user", "table": "user",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral", "table": "referral",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "workspace", "table": "workspace",
"entityType": "pks" "entityType": "pks"
@@ -2,9 +2,7 @@
"version": "6", "version": "6",
"dialect": "mysql", "dialect": "mysql",
"id": "9809797a-e6f6-418c-8532-196553b315b8", "id": "9809797a-e6f6-418c-8532-196553b315b8",
"prevIds": [ "prevIds": ["77de1eaf-69f6-433f-b244-cda75319450a"],
"77de1eaf-69f6-433f-b244-cda75319450a"
],
"ddl": [ "ddl": [
{ {
"name": "account", "name": "account",
@@ -2559,193 +2557,133 @@
"table": "workspace" "table": "workspace"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "account", "table": "account",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "auth", "table": "auth",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "benchmark", "table": "benchmark",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "billing", "table": "billing",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["email", "type"],
"email",
"type"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "coupon", "table": "coupon",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "lite", "table": "lite",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "payment", "table": "payment",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "subscription", "table": "subscription",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "usage", "table": "usage",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip", "interval"],
"ip",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip_rate_limit", "table": "ip_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip"],
"ip"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip", "table": "ip",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["key", "interval"],
"key",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key_rate_limit", "table": "key_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_sticky_provider", "table": "model_sticky_provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tpm_rate_limit", "table": "model_tpm_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tps_rate_limit", "table": "model_tps_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key", "table": "key",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model", "table": "model",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "provider", "table": "provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "referral_id"],
"workspace_id",
"referral_id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_reward", "table": "referral_reward",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral", "table": "referral",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "user", "table": "user",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "workspace", "table": "workspace",
"entityType": "pks" "entityType": "pks"
@@ -2,9 +2,7 @@
"version": "6", "version": "6",
"dialect": "mysql", "dialect": "mysql",
"id": "e49321c9-2b03-4e2c-b2f0-76fbb88088ea", "id": "e49321c9-2b03-4e2c-b2f0-76fbb88088ea",
"prevIds": [ "prevIds": ["9809797a-e6f6-418c-8532-196553b315b8"],
"9809797a-e6f6-418c-8532-196553b315b8"
],
"ddl": [ "ddl": [
{ {
"name": "account", "name": "account",
@@ -2559,193 +2557,133 @@
"table": "workspace" "table": "workspace"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "account", "table": "account",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "auth", "table": "auth",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "benchmark", "table": "benchmark",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "billing", "table": "billing",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["email", "type"],
"email",
"type"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "coupon", "table": "coupon",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "lite", "table": "lite",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "payment", "table": "payment",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "subscription", "table": "subscription",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "usage", "table": "usage",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip", "interval"],
"ip",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip_rate_limit", "table": "ip_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip"],
"ip"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip", "table": "ip",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["key", "interval"],
"key",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key_rate_limit", "table": "key_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_sticky_provider", "table": "model_sticky_provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tpm_rate_limit", "table": "model_tpm_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tps_rate_limit", "table": "model_tps_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key", "table": "key",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model", "table": "model",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "provider", "table": "provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "referral_id"],
"workspace_id",
"referral_id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_reward", "table": "referral_reward",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral", "table": "referral",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "user", "table": "user",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "workspace", "table": "workspace",
"entityType": "pks" "entityType": "pks"
@@ -2,9 +2,7 @@
"version": "6", "version": "6",
"dialect": "mysql", "dialect": "mysql",
"id": "9a7123cb-5c2c-47f6-b22f-8fd6a02dcb03", "id": "9a7123cb-5c2c-47f6-b22f-8fd6a02dcb03",
"prevIds": [ "prevIds": ["e49321c9-2b03-4e2c-b2f0-76fbb88088ea"],
"e49321c9-2b03-4e2c-b2f0-76fbb88088ea"
],
"ddl": [ "ddl": [
{ {
"name": "account", "name": "account",
@@ -2559,193 +2557,133 @@
"table": "workspace" "table": "workspace"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "account", "table": "account",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "auth", "table": "auth",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "benchmark", "table": "benchmark",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "billing", "table": "billing",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["email", "type"],
"email",
"type"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "coupon", "table": "coupon",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "lite", "table": "lite",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "payment", "table": "payment",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "subscription", "table": "subscription",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "usage", "table": "usage",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip", "interval"],
"ip",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip_rate_limit", "table": "ip_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["ip"],
"ip"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "ip", "table": "ip",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["key", "interval"],
"key",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key_rate_limit", "table": "key_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_sticky_provider", "table": "model_sticky_provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tpm_rate_limit", "table": "model_tpm_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id", "interval"],
"id",
"interval"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model_tps_rate_limit", "table": "model_tps_rate_limit",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "key", "table": "key",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "model", "table": "model",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "provider", "table": "provider",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "referral_id"],
"workspace_id",
"referral_id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral_reward", "table": "referral_reward",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "referral", "table": "referral",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["workspace_id", "id"],
"workspace_id",
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "user", "table": "user",
"entityType": "pks" "entityType": "pks"
}, },
{ {
"columns": [ "columns": ["id"],
"id"
],
"name": "PRIMARY", "name": "PRIMARY",
"table": "workspace", "table": "workspace",
"entityType": "pks" "entityType": "pks"
+34 -25
View File
@@ -19,7 +19,10 @@ export namespace Referral {
export const CODE_LENGTH = 10 export const CODE_LENGTH = 10
export function normalizeCode(code?: string | null) { 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() { function generateCode() {
@@ -41,7 +44,11 @@ export namespace Referral {
.update(WorkspaceTable) .update(WorkspaceTable)
.set({ referralCode: generateCode() }) .set({ referralCode: generateCode() })
.where( .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 const created = await tx
@@ -74,7 +81,10 @@ export namespace Referral {
}) })
.from(ReferralRewardTable) .from(ReferralRewardTable)
.innerJoin(ReferralTable, eq(ReferralTable.id, ReferralRewardTable.referralID)) .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( .where(
and( and(
eq(ReferralRewardTable.workspaceID, workspaceID), eq(ReferralRewardTable.workspaceID, workspaceID),
@@ -86,12 +96,18 @@ export namespace Referral {
tx tx
.select({ id: ReferralTable.id, inviteeEmail: AuthTable.subject, timeCreated: ReferralTable.timeCreated }) .select({ id: ReferralTable.id, inviteeEmail: AuthTable.subject, timeCreated: ReferralTable.timeCreated })
.from(ReferralTable) .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))), .where(and(eq(ReferralTable.workspaceID, workspaceID), isNull(ReferralTable.timeDeleted))),
tx tx
.select({ id: ReferralTable.id, inviteeEmail: AuthTable.subject, timeCreated: ReferralTable.timeCreated }) .select({ id: ReferralTable.id, inviteeEmail: AuthTable.subject, timeCreated: ReferralTable.timeCreated })
.from(ReferralTable) .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))), .where(and(eq(ReferralTable.inviteeAccountID, accountID), isNull(ReferralTable.timeDeleted))),
tx tx
.select({ referralID: ReferralRewardTable.referralID }) .select({ referralID: ReferralRewardTable.referralID })
@@ -158,9 +174,7 @@ export namespace Referral {
hasActiveGo: !!rows.lite, hasActiveGo: !!rows.lite,
rewardAmount: microCentsToCents(REWARD_AMOUNT), rewardAmount: microCentsToCents(REWARD_AMOUNT),
totalEarned: rewards.reduce((total, reward) => total + reward.amount, 0), totalEarned: rewards.reduce((total, reward) => total + reward.amount, 0),
totalApplied: rewards totalApplied: rewards.filter((reward) => reward.timeApplied).reduce((total, reward) => total + reward.amount, 0),
.filter((reward) => reward.timeApplied)
.reduce((total, reward) => total + reward.amount, 0),
rewards: allRewards, rewards: allRewards,
} }
}) })
@@ -277,10 +291,7 @@ export namespace Referral {
} }
}) })
export async function createFromAccount(input: { export async function createFromAccount(input: { accountID: string; referralCode?: string }) {
accountID: string
referralCode?: string
}) {
const referralCode = normalizeCode(input.referralCode) const referralCode = normalizeCode(input.referralCode)
if (!referralCode) return if (!referralCode) return
@@ -313,14 +324,11 @@ export namespace Referral {
if (selfReferral) throw new Error("Self-referral is not allowed") if (selfReferral) throw new Error("Self-referral is not allowed")
const referralID = Identifier.create("referral") const referralID = Identifier.create("referral")
await tx await tx.insert(ReferralTable).ignore().values({
.insert(ReferralTable) workspaceID: code.workspaceID,
.ignore() id: referralID,
.values({ inviteeAccountID: input.accountID,
workspaceID: code.workspaceID, })
id: referralID,
inviteeAccountID: input.accountID,
})
const referral = await tx const referral = await tx
.select({ id: ReferralTable.id, workspaceID: ReferralTable.workspaceID }) .select({ id: ReferralTable.id, workspaceID: ReferralTable.workspaceID })
@@ -332,16 +340,17 @@ export namespace Referral {
}) })
} }
export async function completeFromLiteSubscription(input: { export async function completeFromLiteSubscription(input: { workspaceID: string; userID: string }) {
workspaceID: string
userID: string
}) {
return Database.transaction(async (tx) => { return Database.transaction(async (tx) => {
const invitee = await tx const invitee = await tx
.select({ accountID: UserTable.accountID }) .select({ accountID: UserTable.accountID })
.from(UserTable) .from(UserTable)
.where( .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]) .then((rows) => rows[0])
if (!invitee?.accountID) throw new Error("Referral invitee account missing") if (!invitee?.accountID) throw new Error("Referral invitee account missing")
@@ -9,10 +9,7 @@ export const ReferralTable = mysqlTable(
...timestamps, ...timestamps,
inviteeAccountID: ulid("invitee_account_id").notNull(), inviteeAccountID: ulid("invitee_account_id").notNull(),
}, },
(table) => [ (table) => [...workspaceIndexes(table), uniqueIndex("referral_invitee_account_id").on(table.inviteeAccountID)],
...workspaceIndexes(table),
uniqueIndex("referral_invitee_account_id").on(table.inviteeAccountID),
],
) )
export const ReferralRewardTable = mysqlTable( export const ReferralRewardTable = mysqlTable(
@@ -10,10 +10,7 @@ export const WorkspaceTable = mysqlTable(
name: varchar("name", { length: 255 }).notNull(), name: varchar("name", { length: 255 }).notNull(),
...timestamps, ...timestamps,
}, },
(table) => [ (table) => [uniqueIndex("slug").on(table.slug), uniqueIndex("referral_code").on(table.referralCode)],
uniqueIndex("slug").on(table.slug),
uniqueIndex("referral_code").on(table.referralCode),
],
) )
export function workspaceIndexes(table: any) { export function workspaceIndexes(table: any) {