import { randomUUID } from 'node:crypto'; import { api } from './client'; export function randomString(length: number) { return randomUUID().replace(/-/g, '').substring(0, length); } export async function getRandomDelegatedWorkspaceId(): Promise< string | undefined > { const response = await api.workspaces.list({ parentWorkspaceId: process.env.FABRIC_DEV_WORKSPACE_ID, }); const delegatedWorkspaces = response.data.items.filter( (w) => w.type === 'delegated', ); if (!delegatedWorkspaces || delegatedWorkspaces.length === 0) return undefined; const randomIndex = Math.floor(Math.random() * delegatedWorkspaces.length); return delegatedWorkspaces[randomIndex]?.id; }