640 lines
14 KiB
JSON
640 lines
14 KiB
JSON
[
|
|
{
|
|
"description": "Vertical $family Routing (Across Tables)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "entity",
|
|
"variations": [
|
|
"entity",
|
|
"organization",
|
|
"person",
|
|
"bot"
|
|
],
|
|
"schemas": {
|
|
"entity": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "organization",
|
|
"variations": [
|
|
"organization",
|
|
"person"
|
|
],
|
|
"schemas": {
|
|
"organization": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "person",
|
|
"variations": [
|
|
"person"
|
|
],
|
|
"schemas": {
|
|
"person": {
|
|
"type": "organization",
|
|
"properties": {
|
|
"first_name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "bot",
|
|
"variations": [
|
|
"bot"
|
|
],
|
|
"schemas": {
|
|
"bot": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"model": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"schemas": {
|
|
"family_entity": {
|
|
"$family": "entity"
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Matches base entity",
|
|
"schema_id": "family_entity",
|
|
"data": {
|
|
"type": "entity",
|
|
"id": "1"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Matches descendant person natively",
|
|
"schema_id": "family_entity",
|
|
"data": {
|
|
"type": "person",
|
|
"id": "2",
|
|
"first_name": "Bob"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Missing type fails out immediately",
|
|
"schema_id": "family_entity",
|
|
"data": {
|
|
"id": "3",
|
|
"first_name": "Bob"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MISSING_TYPE",
|
|
"details": {
|
|
"path": ""
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Alias matching failure",
|
|
"schema_id": "family_entity",
|
|
"data": {
|
|
"type": "alien",
|
|
"id": "4"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "NO_FAMILY_MATCH",
|
|
"details": {
|
|
"path": ""
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Matrix $family Routing (Vertical + Horizontal Intersections)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "entity",
|
|
"variations": [
|
|
"entity",
|
|
"organization",
|
|
"person",
|
|
"bot"
|
|
],
|
|
"schemas": {
|
|
"entity": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"light.entity": {
|
|
"type": "entity",
|
|
"properties": {
|
|
"kind": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "organization",
|
|
"variations": [
|
|
"organization",
|
|
"person"
|
|
],
|
|
"schemas": {
|
|
"organization": {
|
|
"type": "entity"
|
|
},
|
|
"light.organization": {
|
|
"type": "light.entity"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "person",
|
|
"variations": [
|
|
"person"
|
|
],
|
|
"schemas": {
|
|
"person": {
|
|
"type": "organization"
|
|
},
|
|
"light.person": {
|
|
"type": "light.organization"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "bot",
|
|
"variations": [
|
|
"bot"
|
|
],
|
|
"schemas": {
|
|
"bot": {
|
|
"type": "entity"
|
|
},
|
|
"light.bot": {
|
|
"type": "light.entity"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"schemas": {
|
|
"family_light_org": {
|
|
"$family": "light.organization"
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Matches light.organization exact matrix target",
|
|
"schema_id": "family_light_org",
|
|
"data": {
|
|
"type": "organization",
|
|
"kind": "light"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Matches descendant light.person through matrix evaluation",
|
|
"schema_id": "family_light_org",
|
|
"data": {
|
|
"type": "person",
|
|
"kind": "light"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Structurally fails to route bot (bot is not descendant of organization)",
|
|
"schema_id": "family_light_org",
|
|
"data": {
|
|
"type": "bot",
|
|
"kind": "light"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "NO_FAMILY_MATCH",
|
|
"details": {
|
|
"path": ""
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Horizontal $family Routing (Virtual Variations)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "widget",
|
|
"variations": [
|
|
"widget"
|
|
],
|
|
"schemas": {
|
|
"widget": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"stock.widget": {
|
|
"type": "widget",
|
|
"properties": {
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"amount": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"super_stock.widget": {
|
|
"type": "stock.widget",
|
|
"properties": {
|
|
"super_amount": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"schemas": {
|
|
"family_widget": {
|
|
"$family": "widget"
|
|
},
|
|
"family_stock_widget": {
|
|
"$family": "stock.widget"
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Base widget resolves stock widget horizontally",
|
|
"schema_id": "family_widget",
|
|
"data": {
|
|
"type": "widget",
|
|
"kind": "stock",
|
|
"amount": 5
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Base widget resolves nested super stock widget natively via descendants crawl",
|
|
"schema_id": "family_widget",
|
|
"data": {
|
|
"type": "widget",
|
|
"kind": "super_stock",
|
|
"amount": 5,
|
|
"super_amount": 10
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "stock.widget explicit family resolves nested super stock via fast path",
|
|
"schema_id": "family_stock_widget",
|
|
"data": {
|
|
"type": "widget",
|
|
"kind": "super_stock",
|
|
"amount": 5,
|
|
"super_amount": 10
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "stock.widget fails when presented an invalid payload constraint",
|
|
"schema_id": "family_stock_widget",
|
|
"data": {
|
|
"type": "widget",
|
|
"kind": "super_stock",
|
|
"amount": 5,
|
|
"super_amount": "not_an_int"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"details": {
|
|
"path": "super_amount"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Strict oneOf Punc Pointers (Tagged Unions)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "entity",
|
|
"variations": [
|
|
"entity",
|
|
"person",
|
|
"bot"
|
|
],
|
|
"schemas": {
|
|
"entity": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "person",
|
|
"variations": [
|
|
"person"
|
|
],
|
|
"schemas": {
|
|
"person": {
|
|
"type": "entity"
|
|
},
|
|
"full.person": {
|
|
"type": "person",
|
|
"properties": {
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"age": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"age"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "bot",
|
|
"variations": [
|
|
"bot"
|
|
],
|
|
"schemas": {
|
|
"bot": {
|
|
"type": "entity"
|
|
},
|
|
"full.bot": {
|
|
"type": "bot",
|
|
"properties": {
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"version": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"version"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"schemas": {
|
|
"oneOf_union": {
|
|
"oneOf": [
|
|
{
|
|
"type": "full.person"
|
|
},
|
|
{
|
|
"type": "full.bot"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Throws MISSING_TYPE if discriminator matches neither",
|
|
"schema_id": "oneOf_union",
|
|
"data": {
|
|
"kind": "full",
|
|
"age": 5
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MISSING_TYPE",
|
|
"details": {
|
|
"path": ""
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Golden match throws pure structural error exclusively on person",
|
|
"schema_id": "oneOf_union",
|
|
"data": {
|
|
"type": "person",
|
|
"kind": "full",
|
|
"age": "five"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"details": {
|
|
"path": "age"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Golden matches perfectly",
|
|
"schema_id": "oneOf_union",
|
|
"data": {
|
|
"type": "person",
|
|
"kind": "full",
|
|
"age": 5
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Fails nicely with NO_ONEOF_MATCH",
|
|
"schema_id": "oneOf_union",
|
|
"data": {
|
|
"type": "alien",
|
|
"kind": "full",
|
|
"age": 5
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "NO_ONEOF_MATCH",
|
|
"details": {
|
|
"path": ""
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "JSONB Field Bubble oneOf Discrimination (Promoted IDs)",
|
|
"database": {
|
|
"schemas": {
|
|
"metadata": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"invoice.metadata": {
|
|
"type": "metadata",
|
|
"properties": {
|
|
"invoice_id": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"invoice_id"
|
|
]
|
|
},
|
|
"payment.metadata": {
|
|
"type": "metadata",
|
|
"properties": {
|
|
"payment_id": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"payment_id"
|
|
]
|
|
},
|
|
"oneOf_bubble": {
|
|
"oneOf": [
|
|
{
|
|
"type": "invoice.metadata"
|
|
},
|
|
{
|
|
"type": "payment.metadata"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Extracts golden match natively from explicit JSONB type discriminator",
|
|
"schema_id": "oneOf_bubble",
|
|
"data": {
|
|
"type": "invoice.metadata",
|
|
"invoice_id": "nan"
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"details": {
|
|
"path": "invoice_id"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Valid payload succeeds perfectly in JSONB universe",
|
|
"schema_id": "oneOf_bubble",
|
|
"data": {
|
|
"type": "payment.metadata",
|
|
"payment_id": 123
|
|
},
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |