The organization's single default group (`isDefault`), or `null`.
( organizationId: string )
| 139 | |
| 140 | /** The organization's single default group (`isDefault`), or `null`. */ |
| 141 | async function resolveDefaultGroup( |
| 142 | organizationId: string |
| 143 | ): Promise<ResolvedPermissionGroup | null> { |
| 144 | const [defaultGroup] = await db |
| 145 | .select({ |
| 146 | id: permissionGroup.id, |
| 147 | name: permissionGroup.name, |
| 148 | config: permissionGroup.config, |
| 149 | }) |
| 150 | .from(permissionGroup) |
| 151 | .where( |
| 152 | and(eq(permissionGroup.organizationId, organizationId), eq(permissionGroup.isDefault, true)) |
| 153 | ) |
| 154 | .limit(1) |
| 155 | |
| 156 | if (!defaultGroup) { |
| 157 | return null |
| 158 | } |
| 159 | |
| 160 | return { |
| 161 | permissionGroupId: defaultGroup.id, |
| 162 | groupName: defaultGroup.name, |
| 163 | config: parsePermissionGroupConfig(defaultGroup.config), |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Resolve the group governing `userId` in `workspaceId` (which belongs to |
no test coverage detected