(ast: SchemaAST.AST, seen: Set<SchemaAST.AST>)
| 869 | } |
| 870 | |
| 871 | function metadataPortable(ast: SchemaAST.AST, seen: Set<SchemaAST.AST>): boolean { |
| 872 | if (seen.has(ast)) return true |
| 873 | seen.add(ast) |
| 874 | if (!annotationsPortable(ast.annotations) || !checksPortable(ast.checks)) return false |
| 875 | if ("encodingChecks" in ast && !checksPortable(ast.encodingChecks)) return false |
| 876 | if (ast.encoding?.some((link) => !metadataPortable(link.to, seen))) return false |
| 877 | if (SchemaAST.isDeclaration(ast)) return ast.typeParameters.every((item) => metadataPortable(item, seen)) |
| 878 | if (SchemaAST.isSuspend(ast)) return metadataPortable(ast.thunk(), seen) |
| 879 | if (SchemaAST.isUnion(ast)) return ast.types.every((item) => metadataPortable(item, seen)) |
| 880 | if (SchemaAST.isArrays(ast)) { |
| 881 | return ( |
| 882 | ast.elements.every((item) => metadataPortable(item, seen)) && |
| 883 | ast.rest.every((item) => metadataPortable(item, seen)) |
| 884 | ) |
| 885 | } |
| 886 | if (SchemaAST.isObjects(ast)) { |
| 887 | return ( |
| 888 | ast.propertySignatures.every((field) => metadataPortable(field.type, seen)) && |
| 889 | ast.indexSignatures.every( |
| 890 | (field) => metadataPortable(field.parameter, seen) && metadataPortable(field.type, seen), |
| 891 | ) |
| 892 | ) |
| 893 | } |
| 894 | return true |
| 895 | } |
| 896 | |
| 897 | function generationPortable(generation: unknown): boolean { |
| 898 | if (typeof generation !== "object" || generation === null) return false |
no test coverage detected