File tree Expand file tree Collapse file tree
packages/core/src/v3/schemas Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,9 +42,11 @@ const QueueItemCommon = {
4242 * concurrency limit (applied per key when runs pass a `concurrencyKey`, to the
4343 * whole queue when they don't) and its override state. V2 queues are only the
4444 * line runs wait in: concurrency is declared with the task `concurrency`
45- * option and read or overridden through `concurrencyLimits`.
45+ * option and read or overridden through `concurrencyLimits`. A response from a
46+ * server that predates the discriminator has V1 semantics by definition, so a
47+ * missing `version` defaults to "V1" rather than failing the parse.
4648 */
47- export const QueueItem = z . discriminatedUnion ( "version" , [
49+ const QueueItemUnion = z . discriminatedUnion ( "version" , [
4850 z . object ( {
4951 ...QueueItemCommon ,
5052 version : z . literal ( "V1" ) ,
@@ -70,7 +72,15 @@ export const QueueItem = z.discriminatedUnion("version", [
7072 } ) ,
7173] ) ;
7274
73- export type QueueItem = z . infer < typeof QueueItem > ;
75+ export const QueueItem = z . preprocess (
76+ ( value ) =>
77+ value && typeof value === "object" && ! ( "version" in value )
78+ ? { ...value , version : "V1" }
79+ : value ,
80+ QueueItemUnion
81+ ) ;
82+
83+ export type QueueItem = z . infer < typeof QueueItemUnion > ;
7484
7585export const ListQueueOptions = z . object ( {
7686 /** The page number */
You can’t perform that action at this time.
0 commit comments