mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 05:12:38 +02:00
feat: unified credits and its cost calculations
This commit is contained in:
parent
451a98936e
commit
ae9d36d77f
61 changed files with 5835 additions and 272 deletions
|
|
@ -258,6 +258,8 @@ export const globalImageGenConfig = z.object({
|
|||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
is_global: z.literal(true),
|
||||
is_auto_mode: z.boolean().optional().default(false),
|
||||
billing_tier: z.string().default("free"),
|
||||
quota_reserve_micros: z.number().nullable().optional(),
|
||||
});
|
||||
|
||||
export const getGlobalImageGenConfigsResponse = z.array(globalImageGenConfig);
|
||||
|
|
@ -338,6 +340,10 @@ export const globalVisionLLMConfig = z.object({
|
|||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
is_global: z.literal(true),
|
||||
is_auto_mode: z.boolean().optional().default(false),
|
||||
billing_tier: z.string().default("free"),
|
||||
quota_reserve_tokens: z.number().nullable().optional(),
|
||||
input_cost_per_token: z.number().nullable().optional(),
|
||||
output_cost_per_token: z.number().nullable().optional(),
|
||||
});
|
||||
|
||||
export const getGlobalVisionLLMConfigsResponse = z.array(globalVisionLLMConfig);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export const getPagePurchasesResponse = z.object({
|
|||
purchases: z.array(pagePurchase),
|
||||
});
|
||||
|
||||
// Premium token purchases
|
||||
// Premium credit purchases
|
||||
export const createTokenCheckoutSessionRequest = z.object({
|
||||
quantity: z.number().int().min(1).max(100),
|
||||
search_space_id: z.number().int().min(1),
|
||||
|
|
@ -42,11 +42,16 @@ export const createTokenCheckoutSessionResponse = z.object({
|
|||
checkout_url: z.string(),
|
||||
});
|
||||
|
||||
// Premium credit balance + purchase records.
|
||||
//
|
||||
// The unit is integer micro-USD (1_000_000 == $1.00). The schema names
|
||||
// kept the ``Token`` prefix for API back-compat with pinned clients;
|
||||
// the field names below are authoritative.
|
||||
export const tokenStripeStatusResponse = z.object({
|
||||
token_buying_enabled: z.boolean(),
|
||||
premium_tokens_used: z.number().default(0),
|
||||
premium_tokens_limit: z.number().default(0),
|
||||
premium_tokens_remaining: z.number().default(0),
|
||||
premium_credit_micros_used: z.number().default(0),
|
||||
premium_credit_micros_limit: z.number().default(0),
|
||||
premium_credit_micros_remaining: z.number().default(0),
|
||||
});
|
||||
|
||||
export const tokenPurchaseStatusEnum = pagePurchaseStatusEnum;
|
||||
|
|
@ -56,7 +61,7 @@ export const tokenPurchase = z.object({
|
|||
stripe_checkout_session_id: z.string(),
|
||||
stripe_payment_intent_id: z.string().nullable(),
|
||||
quantity: z.number(),
|
||||
tokens_granted: z.number(),
|
||||
credit_micros_granted: z.number(),
|
||||
amount_total: z.number().nullable(),
|
||||
currency: z.string().nullable(),
|
||||
status: tokenPurchaseStatusEnum,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue