MCPcopy Index your code
hub / github.com/simstudioai/sim / getCreditBalance

Function getCreditBalance

apps/sim/lib/billing/credits/balance.ts:52–71  ·  view source on GitHub ↗
(
  userId: string,
  executor: DbClient = db
)

Source from the content-addressed store, hash-verified

50}
51
52export async function getCreditBalance(
53 userId: string,
54 executor: DbClient = db
55): Promise<CreditBalanceInfo> {
56 const subscription = await getHighestPrioritySubscription(userId, { executor })
57
58 if (isOrgScopedSubscription(subscription, userId) && subscription) {
59 return {
60 balance: await getCreditBalanceForEntity('organization', subscription.referenceId, executor),
61 entityType: 'organization',
62 entityId: subscription.referenceId,
63 }
64 }
65
66 return {
67 balance: await getCreditBalanceForEntity('user', userId, executor),
68 entityType: 'user',
69 entityId: userId,
70 }
71}
72
73export async function addCredits(
74 entityType: 'user' | 'organization',

Callers 2

route.tsFile · 0.90

Calls 3

isOrgScopedSubscriptionFunction · 0.90

Tested by

no test coverage detected