feat(release): prepare 1.1.0 candidate
This commit is contained in:
parent
5a34f66981
commit
5205dcdfa9
736 changed files with 115667 additions and 12203 deletions
44
server/supabase/functions/_shared/generation-receipt.ts
Normal file
44
server/supabase/functions/_shared/generation-receipt.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
export const GENERATION_PURPOSE_HEADER = 'X-D3RO-Generation-Purpose'
|
||||
export const GENERATION_ID_HEADER = 'X-D3RO-Generation-Id'
|
||||
|
||||
export type GenerationPurpose = 'talk_response' | 'command_response' | 'action_response'
|
||||
|
||||
const GENERATION_PURPOSES = new Set<string>([
|
||||
'talk_response',
|
||||
'command_response',
|
||||
'action_response',
|
||||
])
|
||||
|
||||
const UUID_PATTERN = /^[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 class GenerationReceiptError extends Error {
|
||||
constructor(readonly code: string) {
|
||||
super(code)
|
||||
this.name = 'GenerationReceiptError'
|
||||
}
|
||||
}
|
||||
|
||||
export function parseGenerationPurpose(value: string | null): GenerationPurpose | null {
|
||||
if (value === null) return null
|
||||
const normalized = value.trim()
|
||||
if (!GENERATION_PURPOSES.has(normalized)) {
|
||||
throw new GenerationReceiptError('invalid_generation_purpose')
|
||||
}
|
||||
return normalized as GenerationPurpose
|
||||
}
|
||||
|
||||
export function parseGenerationReceiptId(value: unknown): string {
|
||||
if (
|
||||
typeof value !== 'object'
|
||||
|| value === null
|
||||
|| Array.isArray(value)
|
||||
|| typeof (value as Record<string, unknown>).generationId !== 'string'
|
||||
) {
|
||||
throw new GenerationReceiptError('invalid_generation_receipt')
|
||||
}
|
||||
const generationId = ((value as Record<string, unknown>).generationId as string).toLowerCase()
|
||||
if (!UUID_PATTERN.test(generationId)) {
|
||||
throw new GenerationReceiptError('invalid_generation_receipt')
|
||||
}
|
||||
return generationId
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue