← Public packages
@charlesmatte/granola
Search and read Granola meeting notes, summaries and transcripts from any agent; manage webhooks and legal holds safely.
src/lib/webhooks.ts
32 lines · 1.3 KB · TypeScriptimport type { Account } from './account.ts'
import { granolaRequest } from './client.ts'
export const WEBHOOK_EVENTS = ['note.generated', 'note.edited', 'note.access_granted'] as const
export const WEBHOOK_SCOPES = ['personal', 'public', 'workspace'] as const
export type WebhookEndpoint = {
id: string
url: string
url_redacted?: boolean
events: Array<string>
folder_ids?: Array<string>
scopes: Array<string>
created_by?: { name?: string | null; email?: string } | null
enabled: boolean
created_at: string
}
export async function listWebhookEndpoints(a: Account): Promise<Array<WebhookEndpoint>> {
const res = await granolaRequest<{ webhook_endpoints?: Array<WebhookEndpoint> }>(a, { path: '/v1/webhook-endpoints' })
return res.data?.webhook_endpoints ?? []
}
/** Read-only lookup used by update/delete previews; null when the key cannot see the endpoint. */
export async function findWebhookEndpoint(a: Account, id: string): Promise<WebhookEndpoint | null> {
return (await listWebhookEndpoints(a)).find((w) => w.id === id) ?? null
}
export function checkEnumList(name: string, values: Array<string> | undefined, allowed: ReadonlyArray<string>): void {
const bad = (values ?? []).filter((v) => !allowed.includes(v))
if (bad.length) throw new Error(`${name} contains unsupported value(s) ${bad.join(', ')}; allowed: ${allowed.join(', ')}.`)
}