(joinCode: string)
| 148 | } |
| 149 | |
| 150 | export function readWorkspaceByJoinCodeSync(joinCode: string): StoredWorkspaceRecord | null { |
| 151 | const normalizedJoinCode = normalizeWorkspaceJoinCode(joinCode); |
| 152 | if (!normalizedJoinCode) { |
| 153 | return null; |
| 154 | } |
| 155 | |
| 156 | const db = getDatabase(); |
| 157 | const row = (db.prepare( |
| 158 | `SELECT id, slug, name, created_by, created_at, updated_at, archived_at, |
| 159 | join_code, join_code_updated_at, join_code_updated_by |
| 160 | FROM workspace |
| 161 | WHERE join_code = ? AND archived_at IS NULL`, |
| 162 | ).get(normalizedJoinCode) as { |
| 163 | id: string; slug: string; name: string; created_by: string; |
| 164 | created_at: string; updated_at: string; archived_at: string | null; |
| 165 | join_code: string | null; join_code_updated_at: string | null; join_code_updated_by: string | null; |
| 166 | } | undefined) ?? null; |
| 167 | |
| 168 | if (!row) return null; |
| 169 | return { |
| 170 | id: row.id, |
| 171 | slug: row.slug, |
| 172 | name: row.name, |
| 173 | createdBy: row.created_by, |
| 174 | createdAt: row.created_at, |
| 175 | updatedAt: row.updated_at, |
| 176 | archivedAt: row.archived_at ?? undefined, |
| 177 | joinCode: row.join_code ?? undefined, |
| 178 | joinCodeUpdatedAt: row.join_code_updated_at ?? undefined, |
| 179 | joinCodeUpdatedBy: row.join_code_updated_by ?? undefined, |
| 180 | }; |
| 181 | } |
| 182 | |
| 183 | export function rotateWorkspaceJoinCodeSync(input: { |
| 184 | workspaceId: string; |
no test coverage detected