(t: unknown, pathLabel: string)
| 133 | } |
| 134 | |
| 135 | function validateTargeting(t: unknown, pathLabel: string): { targeting?: PackageTargeting; errors: TaskError[] } { |
| 136 | if (t === undefined || t === null) return { errors: [] }; |
| 137 | if (typeof t !== 'object' || Array.isArray(t)) { |
| 138 | return { errors: [{ code: 'VALIDATION_ERROR', message: `${pathLabel}: must be an object`, field: pathLabel }] }; |
| 139 | } |
| 140 | const src = t as Record<string, unknown>; |
| 141 | const errors: TaskError[] = []; |
| 142 | const pl = validateListRef(src.property_list, `${pathLabel}.property_list`); |
| 143 | const cl = validateListRef(src.collection_list, `${pathLabel}.collection_list`); |
| 144 | const cle = validateListRef(src.collection_list_exclude, `${pathLabel}.collection_list_exclude`); |
| 145 | if (pl.error) errors.push(pl.error); |
| 146 | if (cl.error) errors.push(cl.error); |
| 147 | if (cle.error) errors.push(cle.error); |
| 148 | if (errors.length) return { errors }; |
| 149 | if (!pl.ref && !cl.ref && !cle.ref) return { errors: [] }; |
| 150 | return { |
| 151 | targeting: { |
| 152 | ...(pl.ref && { property_list: pl.ref }), |
| 153 | ...(cl.ref && { collection_list: cl.ref }), |
| 154 | ...(cle.ref && { collection_list_exclude: cle.ref }), |
| 155 | }, |
| 156 | errors: [], |
| 157 | }; |
| 158 | } |
| 159 | |
| 160 | // Proposal lifecycle fields not yet in @adcp/client — remove after client update |
| 161 | interface ProposalLifecycle { |
no test coverage detected