{
  "description": "Common elements used across FxMS schemas",
  "$id": "file:///FxMSCommon.schema.json",
  "$defs": {
    "Message": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The message identifier"
        },
        "groups": {
          "description": "Array of preferences used to control `enabled` status of the group. If any is `false` the group is disabled.",
          "type": "array",
          "items": {
            "type": "string",
            "description": "Preference name"
          }
        },
        "template": {
          "type": "string",
          "description": "Which messaging template this message is using."
        },
        "frequency": {
          "type": "object",
          "description": "An object containing frequency cap information for a message.",
          "properties": {
            "lifetime": {
              "type": "integer",
              "description": "The maximum lifetime impressions for a message.",
              "minimum": 1,
              "maximum": 100
            },
            "custom": {
              "type": "array",
              "description": "An array of custom frequency cap definitions.",
              "items": {
                "description": "A frequency cap definition containing time and max impression information",
                "type": "object",
                "properties": {
                  "period": {
                    "type": "integer",
                    "description": "Period of time in milliseconds (e.g. 86400000 for one day)"
                  },
                  "cap": {
                    "type": "integer",
                    "description": "The maximum impressions for the message within the defined period.",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": ["period", "cap"]
              }
            }
          }
        },
        "priority": {
          "description": "The priority of the message. If there are two competing messages to show, the one with the highest priority will be shown",
          "type": "integer"
        },
        "order": {
          "description": "The order in which messages should be shown. Messages will be shown in increasing order.",
          "type": "integer"
        },
        "targeting": {
          "description": "A JEXL expression representing targeting information",
          "type": "string"
        },
        "trigger": {
          "description": "An action to trigger potentially showing the message",
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "A string identifying the trigger action"
            },
            "params": {
              "type": "array",
              "description": "An optional array of string parameters for the trigger action",
              "items": {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            }
          },
          "required": ["id"]
        },
        "provider": {
          "description": "An identifier for the provider of this message, such as \"cfr\" or \"preview\".",
          "type": "string"
        }
      },
      "additionalProperties": true,
      "dependentRequired": {
        "content": ["id", "template"],
        "template": ["id", "content"]
      }
    },
    "localizedText": {
      "type": "object",
      "properties": {
        "string_id": {
          "description": "Id of localized string to be rendered.",
          "type": "string"
        }
      },
      "required": ["string_id"]
    },
    "localizableText": {
      "description": "Either a raw string or an object containing the string_id of the localized text",
      "oneOf": [
        {
          "type": "string",
          "description": "The string to be rendered."
        },
        {
          "$ref": "#/$defs/localizedText"
        }
      ]
    }
  }
}
