(
check: SchemaRepresentation.Check,
path: Path
)
| 331 | } |
| 332 | |
| 333 | function compileCheck( |
| 334 | check: SchemaRepresentation.Check, |
| 335 | path: Path |
| 336 | ): string { |
| 337 | const callback = check.annotations?.toCode |
| 338 | let runtime: string |
| 339 | if (callback !== undefined) { |
| 340 | const schemas = annotationSchemas(check.representation, [...path, "representation"]) |
| 341 | const output = (callback as SchemaRepresentation.Generation.Check)({ schemas }) |
| 342 | for (const importDeclaration of output.importDeclarations ?? []) addImport(importDeclaration) |
| 343 | runtime = output.runtime |
| 344 | } else if (check._tag === "Filter") { |
| 345 | throw errorWithPath("Missing toCode callback", [...path, "annotations", "toCode"]) |
| 346 | } else { |
| 347 | runtime = `Schema.makeFilterGroup([${ |
| 348 | check.checks.map((child, index) => compileCheck(child, [...path, "checks", index])).join(", ") |
| 349 | }])` |
| 350 | } |
| 351 | runtime += runtimeAnnotate(check.annotations) |
| 352 | if (check._tag === "Filter" && check.aborted) runtime += ".abort()" |
| 353 | return runtime |
| 354 | } |
| 355 | |
| 356 | function applyNode( |
| 357 | base: SchemaRepresentation.Code, |
no test coverage detected