Line data Source code
1 : import { z } from 'zod'
2 :
3 : import type { NodeProperty } from '@comfyorg/graph-model/nodeProperty'
4 : import type { WidgetValue } from '@comfyorg/graph-model/widgetValue'
5 :
6 : import { parseNodePropertyArray } from './parseNodePropertyArray'
7 : import { serializedProxyWidgetTupleSchema } from './promotionSchema'
8 :
9 2356 : const proxyWidgetQuarantineReasonSchema = z.enum([
10 : 'missingSourceNode',
11 : 'missingSourceWidget',
12 : 'missingSubgraphInput',
13 : 'ambiguousSubgraphInput',
14 : 'unlinkedSourceWidget',
15 : 'primitiveBypassFailed'
16 : ])
17 : export type ProxyWidgetQuarantineReason = z.infer<
18 : typeof proxyWidgetQuarantineReasonSchema
19 : >
20 :
21 2356 : const proxyWidgetErrorQuarantineEntrySchema = z.object({
22 : originalEntry: serializedProxyWidgetTupleSchema,
23 : reason: proxyWidgetQuarantineReasonSchema,
24 : hostValue: z.unknown().optional(),
25 : attemptedAtVersion: z.literal(1)
26 : })
27 :
28 2356 : const proxyWidgetErrorQuarantinePropertySchema = z.array(
29 : proxyWidgetErrorQuarantineEntrySchema
30 : )
31 :
32 : export type ProxyWidgetErrorQuarantineEntry = Omit<
33 : z.infer<typeof proxyWidgetErrorQuarantineEntrySchema>,
34 : 'hostValue'
35 : > & { hostValue?: WidgetValue }
36 :
37 3655 : export function parseProxyWidgetErrorQuarantine(
38 : property: NodeProperty | undefined
39 : ): ProxyWidgetErrorQuarantineEntry[] {
40 3655 : return parseNodePropertyArray(
41 : property,
42 : proxyWidgetErrorQuarantinePropertySchema,
43 : 'properties.proxyWidgetErrorQuarantine'
44 : ) as ProxyWidgetErrorQuarantineEntry[]
45 : }
|