mirror of
https://github.com/gorules/zen.git
synced 2026-10-06 00:02:31 +00:00
* first draft * mock time; update snapshots * fix * Node.js test fix --------- Co-authored-by: Stefan <stefan@gorules.io>
334 lines
8.6 KiB
JSON
334 lines
8.6 KiB
JSON
{
|
|
"tests": [
|
|
{
|
|
"input": {
|
|
"listing": {
|
|
"id": "LIST12345",
|
|
"title": "Designer Handbag - Limited Edition",
|
|
"brand": "LuxuryBrand",
|
|
"price": 950,
|
|
"condition": "New",
|
|
"description": "Authentic designer handbag, limited edition, comes with certificate"
|
|
},
|
|
"category": {
|
|
"id": "CAT789",
|
|
"type": "luxury",
|
|
"name": "Designer Handbags",
|
|
"averagePrice": 1500,
|
|
"highValueBrands": [
|
|
"LuxuryBrand",
|
|
"PremiumDesigner",
|
|
"ExclusiveFashion"
|
|
]
|
|
},
|
|
"seller": {
|
|
"id": "SELL456",
|
|
"name": "FashionReseller",
|
|
"rating": 3.8,
|
|
"accountAgeDays": 45,
|
|
"previousViolations": 1,
|
|
"listingsCount": 27
|
|
}
|
|
},
|
|
"output": {
|
|
"category": {
|
|
"averagePrice": 1500,
|
|
"highValueBrands": [
|
|
"LuxuryBrand",
|
|
"PremiumDesigner",
|
|
"ExclusiveFashion"
|
|
],
|
|
"id": "CAT789",
|
|
"name": "Designer Handbags",
|
|
"type": "luxury"
|
|
},
|
|
"hasLowRating": true,
|
|
"hasPreviousViolations": true,
|
|
"isHighValueBrand": true,
|
|
"isNewSeller": true,
|
|
"isSensitiveCategory": true,
|
|
"listing": {
|
|
"brand": "LuxuryBrand",
|
|
"condition": "New",
|
|
"description": "Authentic designer handbag, limited edition, comes with certificate",
|
|
"id": "LIST12345",
|
|
"price": 950,
|
|
"title": "Designer Handbag - Limited Edition"
|
|
},
|
|
"priceDeviationScore": 36.66666666666666666666666667,
|
|
"riskAssessment": {
|
|
"level": "high",
|
|
"reason": "Suspicious pricing for high-value brand with history of violations"
|
|
},
|
|
"seller": {
|
|
"accountAgeDays": 45,
|
|
"id": "SELL456",
|
|
"listingsCount": 27,
|
|
"name": "FashionReseller",
|
|
"previousViolations": 1,
|
|
"rating": 3.8
|
|
},
|
|
"verification": {
|
|
"message": "High risk listing requires immediate manual verification",
|
|
"required": true,
|
|
"type": "manual"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"nodes": [
|
|
{
|
|
"type": "inputNode",
|
|
"content": {
|
|
"schema": ""
|
|
},
|
|
"id": "input",
|
|
"name": "request",
|
|
"position": {
|
|
"x": 110,
|
|
"y": 114
|
|
}
|
|
},
|
|
{
|
|
"type": "expressionNode",
|
|
"content": {
|
|
"expressions": [
|
|
{
|
|
"id": "expr1",
|
|
"key": "priceDeviationScore",
|
|
"value": "abs((listing.price - category.averagePrice) / category.averagePrice * 100)"
|
|
},
|
|
{
|
|
"id": "expr2",
|
|
"key": "isSensitiveCategory",
|
|
"value": "contains(['luxury', 'electronics', 'collectibles', 'designer'], category.type)"
|
|
},
|
|
{
|
|
"id": "expr3",
|
|
"key": "isHighValueBrand",
|
|
"value": "contains(category.highValueBrands ?? [], listing.brand)"
|
|
},
|
|
{
|
|
"id": "expr4",
|
|
"key": "hasLowRating",
|
|
"value": "seller.rating < 4.0"
|
|
},
|
|
{
|
|
"id": "expr5",
|
|
"key": "isNewSeller",
|
|
"value": "seller.accountAgeDays < 90"
|
|
},
|
|
{
|
|
"id": "expr6",
|
|
"key": "hasPreviousViolations",
|
|
"value": "seller.previousViolations > 0"
|
|
}
|
|
],
|
|
"passThrough": true,
|
|
"inputField": null,
|
|
"outputPath": null,
|
|
"executionMode": "single"
|
|
},
|
|
"id": "calculateRiskFactors",
|
|
"name": "calculateRiskFactors",
|
|
"position": {
|
|
"x": 430,
|
|
"y": 115
|
|
}
|
|
},
|
|
{
|
|
"type": "decisionTableNode",
|
|
"content": {
|
|
"hitPolicy": "first",
|
|
"rules": [
|
|
{
|
|
"_id": "rule1",
|
|
"i1": "isHighValueBrand == true",
|
|
"i2": "priceDeviationScore > 30",
|
|
"i3": "hasPreviousViolations == true",
|
|
"o1": "'high'",
|
|
"o2": "'Suspicious pricing for high-value brand with history of violations'"
|
|
},
|
|
{
|
|
"_id": "rule2",
|
|
"i1": "isHighValueBrand == true",
|
|
"i2": "priceDeviationScore > 30",
|
|
"i3": "",
|
|
"o1": "'high'",
|
|
"o2": "'Suspicious pricing for high-value brand'"
|
|
},
|
|
{
|
|
"_id": "rule3",
|
|
"i1": "isHighValueBrand == true",
|
|
"i2": "",
|
|
"i3": "hasPreviousViolations == true",
|
|
"o1": "'medium'",
|
|
"o2": "'High-value brand with seller violation history'"
|
|
},
|
|
{
|
|
"_id": "rule4",
|
|
"i1": "",
|
|
"i2": "priceDeviationScore > 40",
|
|
"i3": "",
|
|
"o1": "'medium'",
|
|
"o2": "'Significant price deviation from market average'"
|
|
},
|
|
{
|
|
"_id": "rule5",
|
|
"i1": "",
|
|
"i2": "",
|
|
"i3": "hasPreviousViolations > 2",
|
|
"o1": "'medium'",
|
|
"o2": "'Multiple previous seller violations'"
|
|
},
|
|
{
|
|
"_id": "rule6",
|
|
"i1": "isNewSeller == true",
|
|
"i2": "isSensitiveCategory == true",
|
|
"i3": "",
|
|
"o1": "'medium'",
|
|
"o2": "'New seller listing sensitive category items'"
|
|
},
|
|
{
|
|
"_id": "rule7",
|
|
"i1": "hasLowRating == true",
|
|
"i2": "isSensitiveCategory == true",
|
|
"i3": "",
|
|
"o1": "'medium'",
|
|
"o2": "'Low-rated seller with sensitive category items'"
|
|
},
|
|
{
|
|
"_id": "rule8",
|
|
"i1": "",
|
|
"i2": "",
|
|
"i3": "",
|
|
"o1": "'low'",
|
|
"o2": "'Standard risk level'"
|
|
}
|
|
],
|
|
"inputs": [
|
|
{
|
|
"id": "i1",
|
|
"name": "Brand Risk",
|
|
"field": ""
|
|
},
|
|
{
|
|
"id": "i2",
|
|
"name": "Price Risk",
|
|
"field": ""
|
|
},
|
|
{
|
|
"id": "i3",
|
|
"name": "Seller Risk",
|
|
"field": ""
|
|
}
|
|
],
|
|
"outputs": [
|
|
{
|
|
"id": "o1",
|
|
"name": "Risk Level",
|
|
"field": "riskAssessment.level"
|
|
},
|
|
{
|
|
"id": "o2",
|
|
"name": "Risk Reason",
|
|
"field": "riskAssessment.reason"
|
|
}
|
|
],
|
|
"passThrough": true,
|
|
"inputField": null,
|
|
"outputPath": null,
|
|
"executionMode": "single"
|
|
},
|
|
"id": "evaluateRisk",
|
|
"name": "evaluateRiskLevel",
|
|
"position": {
|
|
"x": 750,
|
|
"y": 114
|
|
}
|
|
},
|
|
{
|
|
"type": "decisionTableNode",
|
|
"content": {
|
|
"hitPolicy": "first",
|
|
"rules": [
|
|
{
|
|
"_id": "rule1",
|
|
"i1": "'high'",
|
|
"o1": "true",
|
|
"o2": "'manual'",
|
|
"o3": "'High risk listing requires immediate manual verification'"
|
|
},
|
|
{
|
|
"_id": "rule2",
|
|
"i1": "'medium'",
|
|
"o1": "true",
|
|
"o2": "'batch'",
|
|
"o3": "'Medium risk listing added to batch verification queue'"
|
|
},
|
|
{
|
|
"_id": "rule3",
|
|
"i1": "'low'",
|
|
"o1": "false",
|
|
"o2": "'none'",
|
|
"o3": "'No verification required'"
|
|
}
|
|
],
|
|
"inputs": [
|
|
{
|
|
"id": "i1",
|
|
"name": "Risk Level",
|
|
"field": "riskAssessment.level"
|
|
}
|
|
],
|
|
"outputs": [
|
|
{
|
|
"id": "o1",
|
|
"name": "Requires Verification",
|
|
"field": "verification.required"
|
|
},
|
|
{
|
|
"id": "o2",
|
|
"name": "Verification Type",
|
|
"field": "verification.type"
|
|
},
|
|
{
|
|
"id": "o3",
|
|
"name": "Verification Message",
|
|
"field": "verification.message"
|
|
}
|
|
],
|
|
"passThrough": true,
|
|
"inputField": null,
|
|
"outputPath": null,
|
|
"executionMode": "single"
|
|
},
|
|
"id": "determineAction",
|
|
"name": "determineAction",
|
|
"position": {
|
|
"x": 1070,
|
|
"y": 114
|
|
}
|
|
}
|
|
],
|
|
"edges": [
|
|
{
|
|
"id": "edge1",
|
|
"sourceId": "input",
|
|
"targetId": "calculateRiskFactors",
|
|
"type": "edge"
|
|
},
|
|
{
|
|
"id": "edge2",
|
|
"sourceId": "calculateRiskFactors",
|
|
"targetId": "evaluateRisk",
|
|
"type": "edge"
|
|
},
|
|
{
|
|
"id": "edge3",
|
|
"sourceId": "evaluateRisk",
|
|
"targetId": "determineAction",
|
|
"type": "edge"
|
|
}
|
|
]
|
|
} |