( error: Error, )
| 148 | * Accepts an AJV compilation error and extracts the error details from the message. |
| 149 | */ |
| 150 | export const ajvErrorToFailures = ( |
| 151 | error: Error, |
| 152 | ): { path: string; error: string }[] => { |
| 153 | // example: /data/properties/name some error message |
| 154 | if (error.message.startsWith("schema is invalid:")) { |
| 155 | return error.message |
| 156 | .replace("schema is invalid:", "") |
| 157 | .split(",") |
| 158 | .map((s) => s.trim()) |
| 159 | .map((s) => { |
| 160 | const firstSpace = s.indexOf(" "); |
| 161 | |
| 162 | if (firstSpace === -1) { |
| 163 | throw new AgentRPCError("Could not extract failures from AJV error", { |
| 164 | error, |
| 165 | }); |
| 166 | } |
| 167 | |
| 168 | return { |
| 169 | path: s.slice(0, firstSpace), |
| 170 | error: s.slice(firstSpace + 1), |
| 171 | }; |
| 172 | }); |
| 173 | } |
| 174 | |
| 175 | return [ |
| 176 | { |
| 177 | path: "", |
| 178 | error: error.message, |
| 179 | }, |
| 180 | ]; |
| 181 | }; |
| 182 | |
| 183 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 184 | export const isZodType = (input: any): input is z.ZodTypeAny => { |
no outgoing calls
no test coverage detected