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

Function getOrganizationSubscription

apps/sim/lib/billing/core/billing.ts:51–77  ·  view source on GitHub ↗
(
  organizationId: string,
  options: GetOrganizationSubscriptionOptions = {}
)

Source from the content-addressed store, hash-verified

49 * omit the executor (or pass `db`).
50 */
51export async function getOrganizationSubscription(
52 organizationId: string,
53 options: GetOrganizationSubscriptionOptions = {}
54) {
55 const { onError = 'return-null', executor = db } = options
56 try {
57 const orgSubs = await executor
58 .select()
59 .from(subscription)
60 .where(
61 and(
62 eq(subscription.referenceId, organizationId),
63 inArray(subscription.status, ENTITLED_SUBSCRIPTION_STATUSES)
64 )
65 )
66 .orderBy(desc(subscription.periodStart), desc(subscription.id))
67 .limit(1)
68
69 return orgSubs.length > 0 ? orgSubs[0] : null
70 } catch (error) {
71 logger.error('Error getting organization subscription', { error, organizationId })
72 if (onError === 'throw') {
73 throw error
74 }
75 return null
76 }
77}
78
79/**
80 * BILLING MODEL:

Callers 15

getOrgMemberLedgerByUserFunction · 0.90
validateSeatAvailabilityFunction · 0.90
getOrganizationSeatInfoFunction · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

errorMethod · 0.80
eqFunction · 0.50

Tested by

no test coverage detected