{
  "$meta": {
    "package": "@walkeros/server-destination-redis",
    "version": "4.2.1",
    "type": "destination",
    "platform": [
      "server"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/server/redis",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/redis/src"
  },
  "schemas": {
    "mapping": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "streamKey": {
          "description": "Override Redis stream key for this rule. Takes precedence over settings.redis.streamKey.",
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "redis": {
          "type": "object",
          "properties": {
            "streamKey": {
              "type": "string",
              "minLength": 1,
              "description": "Redis stream key name (like 'walkeros:events'). All events are appended to this stream via XADD."
            },
            "url": {
              "type": "string",
              "description": "Redis connection URL (like 'redis://localhost:6379' or 'rediss://:password@host:6380'). Supports redis:// and rediss:// (TLS) protocols."
            },
            "options": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {},
              "description": "ioredis connection options. Used when url is not provided. Supports host, port, password, db, tls, and all other ioredis options."
            },
            "maxLen": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991,
              "description": "Maximum stream length. Enables approximate MAXLEN trimming on every XADD to bound memory usage (like 50000)."
            },
            "exactTrimming": {
              "type": "boolean",
              "description": "Use exact MAXLEN instead of approximate (~). Not recommended for production. Default: false."
            },
            "serialization": {
              "type": "string",
              "enum": [
                "json",
                "flat"
              ],
              "description": "Serialization mode. 'json' stores the full event as a single 'event' field (default). 'flat' stores top-level event fields as separate stream entry fields."
            }
          },
          "required": [
            "streamKey"
          ],
          "additionalProperties": false,
          "description": "Redis Streams configuration (like { streamKey: 'walkeros:events', url: 'redis://localhost:6379' })",
          "title": "redis"
        }
      },
      "required": [
        "redis"
      ],
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "push": {
        "Redis": {
          "Client": {
            "$code": "class{constructor(e){}xadd=v;pipeline(){return function(){const e={xadd:()=>e,exec:()=>Promise.resolve([])};return e}()}quit=u;on(){return this}}"
          }
        }
      },
      "simulation": [
        "call:client.xadd"
      ]
    },
    "step": {
      "ignoredEvent": {
        "public": false,
        "in": {
          "name": "debug noise",
          "data": {
            "string": "foo",
            "number": 1,
            "boolean": true,
            "array": [
              0,
              "text",
              false
            ]
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "e45011779abeb115",
          "trigger": "test",
          "entity": "debug",
          "action": "noise",
          "timestamp": 1700000105,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "ignore": true
        },
        "out": []
      },
      "jsonDefault": {
        "title": "Default stream",
        "description": "An event is appended to the configured Redis stream via XADD with the full event JSON as a single field.",
        "in": {
          "name": "page view",
          "data": {
            "domain": "www.example.com",
            "title": "walkerOS documentation",
            "referrer": "https://www.walkeros.io/",
            "search": "?foo=bar",
            "hash": "#hash",
            "id": "/docs/"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "458ea02967f05c18",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000100,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "out": [
          [
            "client.xadd",
            [
              "walkeros:events",
              "*",
              "event",
              "json:event"
            ]
          ]
        ]
      },
      "orderComplete": {
        "title": "Order event",
        "description": "An order complete event is appended to the Redis stream alongside other event types for downstream consumers.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "ORD-400",
            "total": 99.99,
            "currency": "EUR"
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "0d502a7ad8b9b6ca",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000101,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "out": [
          [
            "client.xadd",
            [
              "walkeros:events",
              "*",
              "event",
              "json:event"
            ]
          ]
        ]
      },
      "streamKeyOverride": {
        "title": "Stream key override",
        "description": "A mapping rule routes the event to a dedicated Redis stream instead of the destination default.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "ORD-500",
            "total": 42
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "eea809c808911b90",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000104,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "streamKey": "walkeros:orders"
          }
        },
        "out": [
          [
            "client.xadd",
            [
              "walkeros:orders",
              "*",
              "event",
              "json:event"
            ]
          ]
        ]
      },
      "withExactTrim": {
        "title": "Exact trim",
        "description": "XADD uses exact MAXLEN trimming to enforce a precise Redis stream length at the cost of extra work.",
        "in": {
          "name": "page view",
          "data": {
            "domain": "www.example.com",
            "title": "walkerOS documentation",
            "referrer": "https://www.walkeros.io/",
            "search": "?foo=bar",
            "hash": "#hash",
            "id": "/docs/"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "d7c88566cb86f892",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000103,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "settings": {
          "redis": {
            "streamKey": "walkeros:events",
            "maxLen": 5000,
            "exactTrimming": true
          }
        },
        "out": [
          [
            "client.xadd",
            [
              "walkeros:events",
              "MAXLEN",
              5000,
              "*",
              "event",
              "json:event"
            ]
          ]
        ]
      },
      "withMaxLen": {
        "title": "MAXLEN trim",
        "description": "XADD uses approximate MAXLEN trimming to cap the Redis stream length, discarding older entries efficiently.",
        "in": {
          "name": "product view",
          "data": {
            "id": "SKU-123",
            "name": "Widget"
          },
          "context": {
            "shopping": [
              "detail",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [],
          "consent": {
            "functional": true
          },
          "id": "9ca9f2ab1842db70",
          "trigger": "load",
          "entity": "product",
          "action": "view",
          "timestamp": 1700000102,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "settings": {
          "redis": {
            "streamKey": "walkeros:events",
            "maxLen": 50000
          }
        },
        "out": [
          [
            "client.xadd",
            [
              "walkeros:events",
              "MAXLEN",
              "~",
              50000,
              "*",
              "event",
              "json:event"
            ]
          ]
        ]
      }
    }
  }
}