Chunk boundaries never split a surrogate pair (a lone high surrogate re-encodes as U+FFFD and silently corrupts the exported artifact), production yields whenever the response queue fills so a slow consumer bounds the accumulation, includeDescendants rejects values other than true/false instead of silently under-exporting, the dead missing-services arm is deleted by narrowing the streaming deps, and the readRaw failure answers 500 without leaking host paths into the browser error bar.
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
/**
|
|
* downloads domain zod schemas. The GET download surface has no wire
|
|
* envelope: the request arrives as query parameters (all strings), so its
|
|
* request schema parses the raw query-parameter object into the method's
|
|
* exact request shape. SessionId brand cast point: sessionIdSchema, and only
|
|
* there (hosted in sessions.schema like every other cast).
|
|
*/
|
|
|
|
import { z } from 'zod'
|
|
import type { DownloadsApi } from './downloads.ts'
|
|
import { sessionIdSchema } from './sessions.schema.ts'
|
|
|
|
/**
|
|
* session.export query params → the sessionLog request. `includeDescendants`
|
|
* accepts exactly `true`/`false`/absent; any other value is rejected (400) so
|
|
* a misspelled flag cannot silently under-export.
|
|
*/
|
|
export const sessionLogQuerySchema = z
|
|
.object({
|
|
sessionId: sessionIdSchema,
|
|
includeDescendants: z.union([z.literal('true'), z.literal('false')]).optional(),
|
|
})
|
|
.transform(query => ({
|
|
sessionId: query.sessionId,
|
|
...(query.includeDescendants === 'true' ? { includeDescendants: true } : {}),
|
|
})) satisfies z.ZodType<Parameters<DownloadsApi['sessionLog']>[0]>
|