MCPcopy
hub / github.com/simstudioai/sim / assertCanFork

Function assertCanFork

apps/sim/lib/workspaces/fork/lineage/authz.ts:98–115  ·  view source on GitHub ↗
(
  sourceWorkspaceId: string,
  userId: string
)

Source from the content-addressed store, hash-verified

96 * which the policy would otherwise fall back to when the source is personal.
97 */
98export async function assertCanFork(
99 sourceWorkspaceId: string,
100 userId: string
101): Promise<ForkAuthorization> {
102 const source = await assertWorkspaceAdminAccess(sourceWorkspaceId, userId)
103 const policy = await getWorkspaceCreationPolicy({
104 userId,
105 activeOrganizationId: source.organizationId,
106 pinOrganization: true,
107 })
108 if (!policy.canCreate) {
109 throw new ForkError(
110 policy.reason ?? 'You cannot create another workspace on your current plan',
111 policy.status >= 400 ? policy.status : 403
112 )
113 }
114 return { source, policy }
115}
116
117export interface PromoteAuthorization {
118 edge: ForkEdge

Callers 1

route.tsFile · 0.90

Calls 2

Tested by

no test coverage detected