chore: JSPG Engine tuple decoupling and core routing optimizations
This commit is contained in:
@ -2,87 +2,193 @@
|
||||
{
|
||||
"description": "Multi-Paradigm Declarative Cases",
|
||||
"database": {
|
||||
"schemas": [
|
||||
{
|
||||
"$id": "parallel_rules",
|
||||
"schemas": {
|
||||
"parallel_rules": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": { "type": "string" },
|
||||
"kind": { "type": "string" }
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"when": { "properties": { "status": {"const": "unverified"} }, "required": ["status"] },
|
||||
"then": {
|
||||
"properties": {
|
||||
"amount_1": {"type": "number"},
|
||||
"amount_2": {"type": "number"}
|
||||
},
|
||||
"required": ["amount_1", "amount_2"]
|
||||
}
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"when": { "properties": { "kind": {"const": "credit"} }, "required": ["kind"] },
|
||||
"then": {
|
||||
"properties": {
|
||||
"cvv": {"type": "number"}
|
||||
},
|
||||
"required": ["cvv"]
|
||||
}
|
||||
"kind": {
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"$id": "mutually_exclusive",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": { "type": "string" }
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"when": { "properties": { "type": {"const": "A"} }, "required": ["type"] },
|
||||
"then": {
|
||||
"properties": { "field_a": {"type": "number"} },
|
||||
"required": ["field_a"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": { "properties": { "type": {"const": "B"} }, "required": ["type"] },
|
||||
"then": {
|
||||
"properties": { "field_b": {"type": "number"} },
|
||||
"required": ["field_b"]
|
||||
"when": {
|
||||
"properties": {
|
||||
"status": {
|
||||
"const": "unverified"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"status"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"properties": { "fallback_b": {"type": "number"} },
|
||||
"required": ["fallback_b"]
|
||||
"then": {
|
||||
"properties": {
|
||||
"amount_1": {
|
||||
"type": "number"
|
||||
},
|
||||
"amount_2": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"amount_1",
|
||||
"amount_2"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "credit"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"cvv": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"cvv"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"$id": "nested_fallbacks",
|
||||
"mutually_exclusive": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tier": { "type": "string" }
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"when": { "properties": { "tier": {"const": "1"} }, "required": ["tier"] },
|
||||
"then": {
|
||||
"properties": { "basic": {"type": "number"} },
|
||||
"required": ["basic"]
|
||||
"when": {
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "A"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"field_a": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"field_a"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "B"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"field_b": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"field_b"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"properties": {
|
||||
"fallback_b": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"fallback_b"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"nested_fallbacks": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tier": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"when": {
|
||||
"properties": {
|
||||
"tier": {
|
||||
"const": "1"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tier"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"basic": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"basic"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"cases": [
|
||||
{
|
||||
"when": { "properties": { "tier": {"const": "2"} }, "required": ["tier"] },
|
||||
"then": {
|
||||
"properties": { "standard": {"type": "number"} },
|
||||
"required": ["standard"]
|
||||
"when": {
|
||||
"properties": {
|
||||
"tier": {
|
||||
"const": "2"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tier"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"properties": { "premium": {"type": "number"} },
|
||||
"required": ["premium"]
|
||||
"then": {
|
||||
"properties": {
|
||||
"standard": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"standard"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"properties": {
|
||||
"premium": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"premium"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -90,94 +196,159 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"$id": "missing_when",
|
||||
"missing_when": {
|
||||
"type": "object",
|
||||
"cases": [
|
||||
{
|
||||
"else": {
|
||||
"properties": { "unconditional": {"type": "number"} },
|
||||
"required": ["unconditional"]
|
||||
"else": {
|
||||
"properties": {
|
||||
"unconditional": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"unconditional"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "Fires only the first rule successfully",
|
||||
"data": { "status": "unverified", "amount_1": 1, "amount_2": 2 },
|
||||
"data": {
|
||||
"status": "unverified",
|
||||
"amount_1": 1,
|
||||
"amount_2": 2
|
||||
},
|
||||
"schema_id": "parallel_rules",
|
||||
"action": "validate",
|
||||
"expect": { "success": true }
|
||||
"expect": {
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Fires both independent parallel rules flawlessly",
|
||||
"data": { "status": "unverified", "kind": "credit", "amount_1": 1, "amount_2": 2, "cvv": 123 },
|
||||
"data": {
|
||||
"status": "unverified",
|
||||
"kind": "credit",
|
||||
"amount_1": 1,
|
||||
"amount_2": 2,
|
||||
"cvv": 123
|
||||
},
|
||||
"schema_id": "parallel_rules",
|
||||
"action": "validate",
|
||||
"expect": { "success": true }
|
||||
"expect": {
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Catches errors triggered concurrently by multiple independent blocked rules",
|
||||
"data": { "status": "unverified", "kind": "credit" },
|
||||
"data": {
|
||||
"status": "unverified",
|
||||
"kind": "credit"
|
||||
},
|
||||
"schema_id": "parallel_rules",
|
||||
"action": "validate",
|
||||
"expect": {
|
||||
"success": false,
|
||||
"errors": [
|
||||
{ "code": "REQUIRED_FIELD_MISSING", "details": { "path": "amount_1" } },
|
||||
{ "code": "REQUIRED_FIELD_MISSING", "details": { "path": "amount_2" } },
|
||||
{ "code": "REQUIRED_FIELD_MISSING", "details": { "path": "cvv" } }
|
||||
{
|
||||
"code": "REQUIRED_FIELD_MISSING",
|
||||
"details": {
|
||||
"path": "amount_1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "REQUIRED_FIELD_MISSING",
|
||||
"details": {
|
||||
"path": "amount_2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "REQUIRED_FIELD_MISSING",
|
||||
"details": {
|
||||
"path": "cvv"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "STRICT_PROPERTY_VIOLATION throws if an un-triggered then property is submitted",
|
||||
"data": { "status": "verified", "cvv": 123 },
|
||||
"data": {
|
||||
"status": "verified",
|
||||
"cvv": 123
|
||||
},
|
||||
"schema_id": "parallel_rules",
|
||||
"action": "validate",
|
||||
"expect": {
|
||||
"success": false,
|
||||
"errors": [
|
||||
{ "code": "STRICT_PROPERTY_VIOLATION", "details": { "path": "cvv" } }
|
||||
{
|
||||
"code": "STRICT_PROPERTY_VIOLATION",
|
||||
"details": {
|
||||
"path": "cvv"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Successfully routes mutually exclusive properties seamlessly",
|
||||
"data": { "type": "A", "field_a": 1, "fallback_b": 2 },
|
||||
"data": {
|
||||
"type": "A",
|
||||
"field_a": 1,
|
||||
"fallback_b": 2
|
||||
},
|
||||
"schema_id": "mutually_exclusive",
|
||||
"action": "validate",
|
||||
"expect": { "success": true }
|
||||
"expect": {
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Nested fallbacks execute seamlessly",
|
||||
"data": { "tier": "3", "premium": 1 },
|
||||
"data": {
|
||||
"tier": "3",
|
||||
"premium": 1
|
||||
},
|
||||
"schema_id": "nested_fallbacks",
|
||||
"action": "validate",
|
||||
"expect": { "success": true }
|
||||
"expect": {
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A case without a when executes its else indiscriminately",
|
||||
"data": { "unconditional": 1 },
|
||||
"data": {
|
||||
"unconditional": 1
|
||||
},
|
||||
"schema_id": "missing_when",
|
||||
"action": "validate",
|
||||
"expect": { "success": true }
|
||||
"expect": {
|
||||
"success": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A case without a when throws if else unconditionally requires field",
|
||||
"data": { },
|
||||
"data": {},
|
||||
"schema_id": "missing_when",
|
||||
"action": "validate",
|
||||
"expect": {
|
||||
"success": false,
|
||||
"errors": [
|
||||
{ "code": "REQUIRED_FIELD_MISSING", "details": { "path": "unconditional" } }
|
||||
{
|
||||
"code": "REQUIRED_FIELD_MISSING",
|
||||
"details": {
|
||||
"path": "unconditional"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user