← Public packages
@charlesmatte/granola
Search and read Granola meeting notes, summaries and transcripts from any agent; manage webhooks and legal holds safely.
src/lib/holds.ts
20 lines · 1.1 KB · TypeScriptimport type { Account } from './account.ts'
import { granolaRequest } from './client.ts'
import { EMAIL_PATTERN, USER_ID_PATTERN } from './validate.ts'
export const LEGAL_HOLD_NOTE =
'Legal holds need a separate "Legal hold API key" (Enterprise, enabled by Granola support; Settings → Connectors → API → Legal hold API keys). Save it under its own account name, e.g. granola-<account>-legal. https://docs.granola.ai/legal-holds'
/** `["a@x.com", "usr_…"]` → `[{ email }, { id }]` (exactly one per entry, as the API requires). */
export function custodianInputs(values: Array<string>): Array<{ email: string } | { id: string }> {
if (values.length > 100) throw new Error('At most 100 custodians per request.')
return values.map((v) => {
if (USER_ID_PATTERN.test(v)) return { id: v }
if (EMAIL_PATTERN.test(v)) return { email: v }
throw new Error(`Custodian "${v}" must be a workspace member email or a Granola user id (usr_…).`)
})
}
export async function getHold(a: Account, holdId: string) {
return (await granolaRequest<Record<string, unknown>>(a, { path: `/v1/legal-holds/${holdId}` })).data
}