{
  "$meta": {
    "package": "@walkeros/transformer-router",
    "version": "3.1.0",
    "type": "transformer",
    "platform": [
      "web",
      "server"
    ],
    "docs": "https://www.walkeros.io/docs/transformers/router",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/transformers/router/src"
  },
  "schemas": {
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "routes": {
          "description": "Routing rules evaluated in order. First matching route wins.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "match": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/__schema0"
                  },
                  {
                    "type": "string",
                    "const": "*"
                  }
                ],
                "description": "Match expression or \"*\" as catch-all route"
              },
              "next": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                ],
                "description": "Next transformer(s) in the chain for matched events"
              }
            },
            "required": [
              "match",
              "next"
            ],
            "additionalProperties": false,
            "description": "Route: directs events to different transformer chains based on match criteria"
          }
        }
      },
      "additionalProperties": false,
      "description": "Router transformer: routes events to different transformer chains based on match rules",
      "definitions": {
        "__schema0": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "description": "Property path to match against"
                },
                "operator": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "contains",
                    "prefix",
                    "suffix",
                    "regex",
                    "gt",
                    "lt",
                    "exists"
                  ],
                  "description": "Match operator"
                },
                "value": {
                  "type": "string",
                  "description": "Value to compare against"
                },
                "not": {
                  "description": "Negate the condition",
                  "type": "boolean"
                }
              },
              "required": [
                "key",
                "operator",
                "value"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "and": {
                  "type": "array",
                  "items": {
                    "allOf": [
                      {
                        "$ref": "#/definitions/__schema0"
                      }
                    ]
                  }
                }
              },
              "required": [
                "and"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "or": {
                  "type": "array",
                  "items": {
                    "allOf": [
                      {
                        "$ref": "#/definitions/__schema0"
                      }
                    ]
                  }
                }
              },
              "required": [
                "or"
              ],
              "additionalProperties": false
            }
          ]
        }
      }
    }
  },
  "examples": {
    "step": {
      "routeMatch": {
        "in": {
          "name": "entity action",
          "data": {
            "v": "2",
            "en": "purchase"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              },
              "nested": [],
              "context": {
                "element": [
                  "child",
                  0
                ]
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "1700000600-gr0up-1",
          "trigger": "test",
          "entity": "entity",
          "action": "action",
          "timestamp": 1700000600,
          "timing": 3.14,
          "group": "gr0up",
          "count": 1,
          "version": {
            "source": "3.1.0",
            "tagging": 1
          },
          "source": {
            "type": "server",
            "id": "",
            "previous_id": ""
          }
        },
        "out": {
          "next": "gtag-parser"
        }
      },
      "routeMiss": {
        "in": {
          "name": "entity action",
          "data": {
            "unknown": "payload"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              },
              "nested": [],
              "context": {
                "element": [
                  "child",
                  0
                ]
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "1700000601-gr0up-1",
          "trigger": "test",
          "entity": "entity",
          "action": "action",
          "timestamp": 1700000601,
          "timing": 3.14,
          "group": "gr0up",
          "count": 1,
          "version": {
            "source": "3.1.0",
            "tagging": 1
          },
          "source": {
            "type": "server",
            "id": "",
            "previous_id": ""
          }
        },
        "out": false
      },
      "wildcardFallback": {
        "description": "Catch-all wildcard route captures events not matching specific routes",
        "in": {
          "name": "entity action",
          "data": {
            "path": "/unknown/endpoint",
            "method": "POST"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              },
              "nested": [],
              "context": {
                "element": [
                  "child",
                  0
                ]
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "1700000602-gr0up-1",
          "trigger": "test",
          "entity": "entity",
          "action": "action",
          "timestamp": 1700000602,
          "timing": 3.14,
          "group": "gr0up",
          "count": 1,
          "version": {
            "source": "3.1.0",
            "tagging": 1
          },
          "source": {
            "type": "server",
            "id": "",
            "previous_id": ""
          }
        },
        "out": {
          "next": "default-handler"
        }
      }
    }
  }
}