MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / readMembershipTierFromClient

Function readMembershipTierFromClient

server/src/db/organization-db.ts:275–284  ·  view source on GitHub ↗
(
  client: PoolClient,
  orgId: string,
  opts: { forUpdate?: boolean } = {},
)

Source from the content-addressed store, hash-verified

273 * caller needs to lock the organizations row as well.
274 */
275export async function readMembershipTierFromClient(
276 client: PoolClient,
277 orgId: string,
278 opts: { forUpdate?: boolean } = {},
279): Promise<MembershipTier | null> {
280 const lockSuffix = opts.forUpdate ? ' FOR UPDATE' : '';
281 const sql = `SELECT ${MEMBERSHIP_TIER_COLUMNS.join(', ')} FROM organizations WHERE workos_organization_id = $1${lockSuffix}`;
282 const result = await client.query<MembershipTierRow>(sql, [orgId]);
283 return resolveMembershipTier(result.rows[0] ?? null);
284}
285
286/**
287 * Infer membership tier from subscription amount and organization type.

Callers 2

applyAgentVisibilityFunction · 0.85
canAddSeatFunction · 0.85

Calls 1

resolveMembershipTierFunction · 0.85

Tested by

no test coverage detected