Luigit
repositories / will

will

owned by admin

src/shared/ids.ts

Raw
import { randomUUID } from 'node:crypto'

/** Globally unique event id (spool dedup relies on it). */
export function newId(): string {
  return randomUUID()
}

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

export function isUuid(value: string): boolean {
  return UUID_RE.test(value)
}