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

Function getWorkspaceBillingSettings

apps/sim/lib/workspaces/utils.ts:19–43  ·  view source on GitHub ↗
(
  workspaceId: string
)

Source from the content-addressed store, hash-verified

17export type WorkspaceScope = 'active' | 'archived' | 'all'
18
19export async function getWorkspaceBillingSettings(
20 workspaceId: string
21): Promise<WorkspaceBillingSettings | null> {
22 if (!workspaceId) {
23 return null
24 }
25
26 const rows = await db
27 .select({
28 billedAccountUserId: workspaceTable.billedAccountUserId,
29 allowPersonalApiKeys: workspaceTable.allowPersonalApiKeys,
30 })
31 .from(workspaceTable)
32 .where(and(eq(workspaceTable.id, workspaceId), isNull(workspaceTable.archivedAt)))
33 .limit(1)
34
35 if (!rows.length) {
36 return null
37 }
38
39 return {
40 billedAccountUserId: rows[0].billedAccountUserId ?? null,
41 allowPersonalApiKeys: rows[0].allowPersonalApiKeys ?? false,
42 }
43}
44
45export async function getWorkspaceBilledAccountUserId(workspaceId: string): Promise<string | null> {
46 const settings = await getWorkspaceBillingSettings(workspaceId)

Callers 3

checkWorkspaceScopeFunction · 0.90

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected