MCPcopy Create free account
hub / github.com/HKUDS/AgentSpace / rotateWorkspaceJoinCodeSync

Function rotateWorkspaceJoinCodeSync

packages/db/src/workspaces.ts:183–205  ·  view source on GitHub ↗
(input: {
  workspaceId: string;
  updatedBy: string;
})

Source from the content-addressed store, hash-verified

181}
182
183export function rotateWorkspaceJoinCodeSync(input: {
184 workspaceId: string;
185 updatedBy: string;
186}): StoredWorkspaceRecord {
187 const db = getDatabase();
188 const now = new Date().toISOString();
189 const joinCode = generateUniqueWorkspaceJoinCodeSync(input.workspaceId);
190 const result = db.prepare(
191 `UPDATE workspace
192 SET join_code = ?, join_code_updated_at = ?, join_code_updated_by = ?, updated_at = ?
193 WHERE id = ? AND archived_at IS NULL`,
194 ).run(joinCode, now, input.updatedBy, now, input.workspaceId);
195
196 if (result.changes === 0) {
197 throw new Error("workspace.join_code.workspace_not_found");
198 }
199
200 const workspace = readWorkspaceSync(input.workspaceId);
201 if (!workspace) {
202 throw new Error("workspace.join_code.workspace_not_found");
203 }
204 return workspace;
205}
206
207export function ensureWorkspaceJoinCodesSync(): number {
208 const db = getDatabase();

Callers 1

Calls 5

getDatabaseFunction · 0.90
readWorkspaceSyncFunction · 0.85
prepareMethod · 0.80
runMethod · 0.65

Tested by

no test coverage detected