feat(billing): make metering formula admin-configurable
Memind CI / Test, build, and release guards (pull_request) Failing after 1m29s
Memind CI / Test, build, and release guards (pull_request) Failing after 1m29s
Allow margin/FX/cost-mode knobs to be overridden via h5_billing_admin_config so memind_adm can adjust DeepSeek billing without editing env. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { createBillingAdminConfigService } from '../billing-admin-config.mjs';
|
||||
import { createRechargeService } from '../billing-recharge.mjs';
|
||||
import {
|
||||
createPlanCatalogService,
|
||||
@@ -53,6 +54,7 @@ export async function bootstrapPortalAuthServices({
|
||||
loadWechatOAuthConfigFn = loadWechatOAuthConfig,
|
||||
createWechatOAuthServiceFn = createWechatOAuthService,
|
||||
createRechargeServiceFn = createRechargeService,
|
||||
createBillingAdminConfigServiceFn = createBillingAdminConfigService,
|
||||
} = {}) {
|
||||
if (
|
||||
!pool ||
|
||||
@@ -77,6 +79,10 @@ export async function bootstrapPortalAuthServices({
|
||||
subscriptionService._planCatalogService =
|
||||
planCatalogService;
|
||||
|
||||
const billingConfigService =
|
||||
createBillingAdminConfigServiceFn(pool, { env });
|
||||
await billingConfigService.ensureSchema();
|
||||
|
||||
const userAuth = createUserAuthFn(pool, {
|
||||
usersRoot,
|
||||
h5Root,
|
||||
@@ -84,6 +90,7 @@ export async function bootstrapPortalAuthServices({
|
||||
env.H5_SIGNUP_BALANCE_CENTS ?? 500,
|
||||
),
|
||||
subscriptionService,
|
||||
billingConfigService,
|
||||
getMindSearchConfig: () =>
|
||||
mindSearchConfigService.getEffectiveConfig(),
|
||||
provisionUserDataSpace: async ({
|
||||
@@ -158,6 +165,7 @@ export async function bootstrapPortalAuthServices({
|
||||
return {
|
||||
planCatalogService,
|
||||
subscriptionService,
|
||||
billingConfigService,
|
||||
userAuth,
|
||||
sessionAccess,
|
||||
routerDecisionMode,
|
||||
|
||||
@@ -129,6 +129,7 @@ export function bootstrapPortalGatewayServices({
|
||||
sessionStreamStore,
|
||||
llmProviderService,
|
||||
subscriptionService,
|
||||
billingConfigService = null,
|
||||
sessionSnapshotService,
|
||||
conversationMemoryService,
|
||||
memoryV2,
|
||||
@@ -176,6 +177,7 @@ export function bootstrapPortalGatewayServices({
|
||||
sessionStreamStore,
|
||||
llmProviderService,
|
||||
subscriptionService,
|
||||
billingConfigService,
|
||||
sessionSnapshotService,
|
||||
conversationMemoryService,
|
||||
memoryV2,
|
||||
|
||||
Reference in New Issue
Block a user