{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/custom_directory_records.json",
  "title": "Custom directory records",
  "description": "A row of a directory, such as one data provider. The directory and its columns (`fields`) are defined in `custom_directories`; this record gives the row, naming the directory in `directory_ref` and the cell of each field in `values`, keyed by the `external_id` of the field. `display_value` is the text shown for the row in lists and should repeat the value of the display field. Cards point at a row through a custom property of type `directory`.\n\nA row of the directory `dir-providers`, which has the fields `fld-name` and `fld-seats`:\n\n```json\n{\n  \"external_id\": \"rec-nimbus\",\n  \"directory_ref\": \"dir-providers\",\n  \"display_value\": \"Nimbus Analytics\",\n  \"values\": { \"fld-name\": \"Nimbus Analytics\", \"fld-seats\": 40 }\n}\n```\n\nA card picks the row by its `external_id` in its `properties`, under the property of type `directory` (only that field of the card is shown):\n\n```json\n{\n  \"external_id\": \"k-mrr\",\n  \"properties\": { \"cp-provider\": \"rec-nimbus\" }\n}\n```",
  "type": "object",
  "properties": {
    "external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Your own identifier of the record, for example `k-mrr`, unique within the resource across all of its files and case sensitive. Other records refer to this one by it."
    },
    "directory_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "custom_directories",
      "description": "The directory the row belongs to. Give the external_id of a `custom_directories` record."
    },
    "display_value": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024,
      "description": "The text shown for the row in lists, for example `Nimbus Analytics`. Repeat the value of the display field."
    },
    "values": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "precision": {
                    "type": "string",
                    "enum": [
                      "date"
                    ],
                    "description": "Always date."
                  },
                  "value": {
                    "type": "string",
                    "format": "date",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  }
                },
                "required": [
                  "precision",
                  "value"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "precision": {
                    "type": "string",
                    "enum": [
                      "date_time"
                    ],
                    "description": "Always date_time."
                  },
                  "value": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
                  }
                },
                "required": [
                  "precision",
                  "value"
                ],
                "additionalProperties": false
              }
            ]
          },
          {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "uniqueItems": true
          }
        ]
      },
      "description": "The values of the row by field, for example `{\"fld-name\": \"Nimbus Analytics\", \"fld-seats\": 40, \"fld-owner\": \"u-omar\"}`. Each key is the `external_id` of a field in the `fields` of the directory of the row and each value has the shape the type of that field decides: text for `string`, `email`, `url` and `phone`; `true` or `false` for `checkbox`; a number for `number`; a date value for `date`, for example `{\"precision\": \"date\", \"value\": \"2024-05-01\"}`; the `external_id` of an option (an item of `options`) of the property of the field for `select`; the `external_id` of a `users` record for `user`; the `external_id` of a `custom_directory_records` record of the linked directory for `directory_link`. A link shows only on the row that has it; to show it in both directories, give it on both rows, each in its own `directory_link` field. A field of type `file` takes no value. A field the row has no value for is left out."
    },
    "author_ref": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "users",
      "description": "The user who added the row, by the external_id of a `users` record, for example `u-ava`. Leave it out or use null when the author is unknown."
    },
    "condition": {
      "type": "string",
      "enum": [
        "active",
        "inactive"
      ],
      "description": "Whether the row is in use: `active` (the default) or `inactive`. An inactive row is left out of the list of the directory's rows.",
      "default": "active"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$",
      "description": "When the row was added, with a time zone, for example `2026-01-12T09:30:00Z`; the directory's list of rows shows this date.",
      "x-default-text": "source.exported_at of the manifest"
    }
  },
  "required": [
    "external_id",
    "directory_ref",
    "display_value"
  ],
  "additionalProperties": false
}
