[ { "description": "Edge missing - 0 relations", "database": { "types": [ { "id": "11111111-1111-1111-1111-111111111111", "type": "type", "name": "org", "module": "test", "source": "test", "hierarchy": [ "org" ], "variations": [ "org" ], "schemas": { "full.org": { "type": "object", "properties": { "missing_users": { "type": "array", "items": { "type": "full.user" } } } } } }, { "id": "22222222-2222-2222-2222-222222222222", "type": "type", "name": "user", "module": "test", "source": "test", "hierarchy": [ "user" ], "variations": [ "user" ], "schemas": { "full.user": { "type": "object", "properties": {} } } } ], "relations": [] }, "tests": [ { "description": "throws EDGE_MISSING when 0 relations exist between org and user", "action": "compile", "expect": { "success": false, "errors": [ { "code": "EDGE_MISSING" } ] } } ] }, { "description": "Edge missing - array cardinality rejection", "database": { "types": [ { "id": "11111111-1111-1111-1111-111111111111", "type": "type", "name": "parent", "module": "test", "source": "test", "hierarchy": [ "parent" ], "variations": [ "parent" ], "schemas": { "full.parent": { "type": "object", "properties": { "children": { "type": "array", "items": { "type": "full.child" } } } } } }, { "id": "22222222-2222-2222-2222-222222222222", "type": "type", "name": "child", "module": "test", "source": "test", "hierarchy": [ "child" ], "variations": [ "child" ], "schemas": { "full.child": { "type": "object", "properties": {} } } } ], "relations": [ { "id": "33333333-3333-3333-3333-333333333333", "type": "relation", "constraint": "fk_parent_child", "source_type": "parent", "source_columns": [ "child_id" ], "destination_type": "child", "destination_columns": [ "id" ] } ] }, "tests": [ { "description": "throws EDGE_MISSING because a Forward scaler edge cannot mathematically fulfill an Array collection", "action": "compile", "expect": { "success": false, "errors": [ { "code": "EDGE_MISSING" } ] } } ] }, { "description": "Ambiguous type relations - multiple unprefixed relations", "database": { "types": [ { "id": "11111111-1111-1111-1111-111111111111", "type": "type", "name": "invoice", "module": "test", "source": "test", "hierarchy": [ "invoice" ], "variations": [ "invoice" ], "schemas": { "full.invoice": { "type": "object", "properties": { "activities": { "type": "array", "items": { "type": "full.activity" } } } } } }, { "id": "22222222-2222-2222-2222-222222222222", "type": "type", "name": "activity", "module": "test", "source": "test", "hierarchy": [ "activity" ], "variations": [ "activity" ], "schemas": { "full.activity": { "type": "object", "properties": {} } } } ], "relations": [ { "id": "33333333-3333-3333-3333-333333333333", "type": "relation", "constraint": "fk_activity_invoice_1", "source_type": "activity", "source_columns": [ "invoice_id_1" ], "destination_type": "invoice", "destination_columns": [ "id" ] }, { "id": "44444444-4444-4444-4444-444444444444", "type": "relation", "constraint": "fk_activity_invoice_2", "source_type": "activity", "source_columns": [ "invoice_id_2" ], "destination_type": "invoice", "destination_columns": [ "id" ] } ] }, "tests": [ { "description": "throws AMBIGUOUS_TYPE_RELATIONS when fallback encounters multiple naked constraints", "action": "compile", "expect": { "success": false, "errors": [ { "code": "AMBIGUOUS_TYPE_RELATIONS", "details": { "cause": "Multiple conflicting constraints found matching prefixes", "context": [ { "constraint": "fk_activity_invoice_1" }, { "constraint": "fk_activity_invoice_2" } ] } } ] } } ] }, { "description": "Ambiguous type relations - M:M twin deduction failure", "database": { "types": [ { "id": "11111111-1111-1111-1111-111111111111", "type": "type", "name": "actor", "module": "test", "source": "test", "hierarchy": [ "actor" ], "variations": [ "actor" ], "schemas": { "full.actor": { "type": "object", "properties": { "ambiguous_edge": { "type": "array", "items": { "type": "empty.junction" } } } } } }, { "id": "22222222-2222-2222-2222-222222222222", "type": "type", "name": "junction", "module": "test", "source": "test", "hierarchy": [ "junction" ], "variations": [ "junction" ], "schemas": { "empty.junction": { "type": "object", "properties": {} } } } ], "relations": [ { "id": "33333333-3333-3333-3333-333333333333", "type": "relation", "constraint": "fk_junction_source_actor", "source_type": "junction", "source_columns": [ "source_id" ], "destination_type": "actor", "destination_columns": [ "id" ], "prefix": "source" }, { "id": "44444444-4444-4444-4444-444444444444", "type": "relation", "constraint": "fk_junction_target_actor", "source_type": "junction", "source_columns": [ "target_id" ], "destination_type": "actor", "destination_columns": [ "id" ], "prefix": "target" } ] }, "tests": [ { "description": "throws AMBIGUOUS_TYPE_RELATIONS because child doesn't explicitly expose 'source' or 'target' for twin deduction", "action": "compile", "expect": { "success": false, "errors": [ { "code": "AMBIGUOUS_TYPE_RELATIONS", "details": { "cause": "Multiple conflicting constraints found matching prefixes", "context": [ { "constraint": "fk_junction_source_actor" }, { "constraint": "fk_junction_target_actor" } ] } } ] } } ] }, { "description": "Database type parse failed", "database": { "types": [ { "id": [ "must", "be", "string", "to", "fail" ], "type": "type", "name": "failure", "module": "test", "source": "test", "hierarchy": [ "failure" ], "variations": [ "failure" ] } ] }, "tests": [ { "description": "throws DATABASE_TYPE_PARSE_FAILED when metadata completely fails Serde typing", "action": "compile", "expect": { "success": false, "errors": [ { "code": "DATABASE_TYPE_PARSE_FAILED" } ] } } ] }, { "description": "Schema Promotion Accuracy Test", "database": { "puncs": [], "enums": [], "relations": [ { "id": "r1", "type": "relation", "constraint": "fk_person_email", "source_type": "person", "source_columns": [ "email_id" ], "destination_type": "email_address", "destination_columns": [ "id" ], "prefix": "email" }, { "id": "r2", "type": "relation", "constraint": "fk_person_ad_hoc_bubble", "source_type": "person", "source_columns": [ "ad_hoc_bubble_id" ], "destination_type": "some_bubble", "destination_columns": [ "id" ], "prefix": "ad_hoc_bubble" }, { "id": "r3", "type": "relation", "constraint": "fk_person_generic_bubble", "source_type": "person", "source_columns": [ "generic_bubble_id" ], "destination_type": "some_bubble", "destination_columns": [ "id" ], "prefix": "generic_bubble" }, { "id": "r4", "type": "relation", "constraint": "fk_person_extended_relations", "source_type": "contact", "source_columns": [ "source_id" ], "destination_type": "person", "destination_columns": [ "id" ], "prefix": "extended_relations" }, { "id": "r5", "type": "relation", "constraint": "fk_person_standard_relations", "source_type": "contact", "source_columns": [ "source_id_2" ], "destination_type": "person", "destination_columns": [ "id" ], "prefix": "standard_relations" }, { "id": "r6", "type": "relation", "constraint": "fk_contact_target", "source_type": "contact", "source_columns": [ "target_id" ], "destination_type": "email_address", "destination_columns": [ "id" ], "prefix": "target" } ], "types": [ { "id": "t1", "type": "type", "name": "person", "module": "core", "source": "person", "hierarchy": [ "person" ], "variations": [ "person", "student" ], "schemas": { "full.person": { "type": "object", "properties": { "type": { "type": "string" }, "name": { "type": "string" }, "email": { "$family": "email_address" }, "generic_bubble": { "type": "some_bubble" }, "ad_hoc_bubble": { "type": "some_bubble", "properties": { "extra_inline_feature": { "type": "string" } } }, "tags": { "type": "array", "items": { "type": "string" } }, "standard_relations": { "type": "array", "items": { "type": "contact" } }, "extended_relations": { "type": "array", "items": { "type": "contact", "properties": { "target": { "type": "email_address", "properties": { "extra_3rd_level": { "type": "string" } } } } } } } }, "student.person": { "type": "object", "properties": { "type": { "type": "string" }, "kind": { "type": "string" }, "school": { "type": "string" } } } } }, { "id": "t2", "type": "type", "name": "email_address", "module": "core", "source": "email_address", "hierarchy": [ "email_address" ], "variations": [ "email_address" ], "schemas": { "light.email_address": { "type": "object", "properties": { "address": { "type": "string" } } } } }, { "id": "t3", "type": "type", "name": "contact", "module": "core", "source": "contact", "hierarchy": [ "contact" ], "variations": [ "contact" ], "schemas": { "full.contact": { "type": "object", "properties": { "id": { "type": "string" } } } } }, { "id": "t4", "type": "type", "name": "some_bubble", "module": "core", "source": "some_bubble", "hierarchy": [ "some_bubble" ], "variations": [ "some_bubble" ], "schemas": { "some_bubble": { "type": "object", "properties": { "bubble_prop": { "type": "string" } } } } } ] }, "tests": [ { "description": "Assert exact topological schema promotion paths", "action": "compile", "expect": { "success": true, "schemas": [ "full.contact", "full.person", "full.person/ad_hoc_bubble", "full.person/extended_relations", "full.person/extended_relations/target", "light.email_address", "some_bubble", "student.person" ] } } ] } ]