{
  "id": "tradle.Message",
  "type": "tradle.Model",
  "title": "Message",
  "properties": {
    "object": {
      "type": "object",
      "inlined": true,
      "ref": "tradle.Object"
    },
    "context": {
      "type": "string"
    },
    "forward": {
      "type": "string"
    },
    "originalSender": {
      "type": "string",
      "description": "for proxied messages"
    },
    "originalRecipient": {
      "type": "string",
      "description": "for proxied messages"
    },
    "inReplyTo": {
      "type": "string"
    },
    "iOfN": {
      "type": "object",
      "properties": {
        "i": {
          "type": "number"
        },
        "n": {
          "type": "number"
        }
      }
    },
    "_n": {
      "type": "number",
      "readOnly": true,
      "immutable": true,
      "description": "message sequence number, for this recipient",
      "sample": "random.number"
    },
    "_q": {
      "type": "string",
      "readOnly": true,
      "immutable": true,
      "description": "link to the previous message sent to this recipient",
      "sample": "hash"
    },
    "_time": {
      "type": "date",
      "readOnly": true,
      "immutable": true,
      "sample": "timestamp.recent"
    },
    "_recipient": {
      "type": "string"
    },
    "_payloadType": {
      "type": "string",
      "virtual": true
    },
    "_payloadLink": {
      "type": "string",
      "virtual": true
    },
    "_payloadRecipient": {
      "type": "string",
      "virtual": true
    },
    "_inbound": {
      "type": "boolean",
      "virtual": true
    },
    "_counterparty": {
      "type": "string",
      "virtual": true,
      "description": "_author if inbound, _recipient otherwise"
    },
    "_dcounterparty": {
      "type": "string",
      "virtual": true,
      "description": "property used for indexing in/outbound messages by counterparty"
    }
  },
  "required": [
    "object",
    "_time",
    "_recipient"
  ],
  "primaryKeys": {
    "hashKey": "_counterparty",
    "rangeKey": "_time"
  },
  "indexes": [
    {
      "hashKey": "_dcounterparty",
      "rangeKey": "_time"
    },
    {
      "hashKey": "context",
      "rangeKey": "_time"
    },
    {
      "hashKey": "_link"
    }
  ]
}
