{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/SimonFoote-greensparx/D365Forge/profiles/schema.json",
  "title": "D365Forge organisation profile",
  "description": "Describes one organisation's team, goals and estate so the project-tailoring department can produce a tailored pack. Real profiles belong in input/ (git-ignored), never in the repository.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "organisation",
    "goals",
    "modules",
    "team"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "enum": [
        "0.1"
      ]
    },
    "organisation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "size_staff"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Organisation name or an alias such as 'Org A'."
        },
        "sector": {
          "type": "string"
        },
        "size_staff": {
          "type": "integer",
          "minimum": 1
        },
        "countries": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "legal_entities": {
          "type": "integer",
          "minimum": 1
        },
        "regulatory_context": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "goals": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "outcomes"
      ],
      "properties": {
        "outcomes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "success_measures": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "target_go_live": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}$",
          "description": "YYYY-MM"
        },
        "budget_band": {
          "type": "string",
          "enum": [
            "under-50k",
            "50k-250k",
            "250k-1m",
            "over-1m",
            "not-shared"
          ]
        }
      }
    },
    "modules": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sales",
        "marketing",
        "customer_service",
        "field_service"
      ],
      "properties": {
        "sales": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "in_scope"
          ],
          "properties": {
            "in_scope": {
              "type": "boolean"
            },
            "users": {
              "type": "integer",
              "minimum": 0
            },
            "notes": {
              "type": "string"
            }
          }
        },
        "marketing": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "in_scope"
          ],
          "properties": {
            "in_scope": {
              "type": "boolean"
            },
            "users": {
              "type": "integer",
              "minimum": 0
            },
            "notes": {
              "type": "string"
            },
            "contacts": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "customer_service": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "in_scope"
          ],
          "properties": {
            "in_scope": {
              "type": "boolean"
            },
            "users": {
              "type": "integer",
              "minimum": 0
            },
            "notes": {
              "type": "string"
            },
            "channels": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "email",
                  "phone",
                  "chat",
                  "messaging",
                  "social",
                  "web-portal"
                ]
              }
            }
          }
        },
        "field_service": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "in_scope"
          ],
          "properties": {
            "in_scope": {
              "type": "boolean"
            },
            "users": {
              "type": "integer",
              "minimum": 0
            },
            "notes": {
              "type": "string"
            },
            "technicians": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      }
    },
    "estate": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "current_crm": {
          "type": "string"
        },
        "legacy_systems": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "purpose": {
                "type": "string"
              },
              "retire": {
                "type": "boolean"
              },
              "records_estimate": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        },
        "erp": {
          "type": "string"
        },
        "email_and_calendar": {
          "type": "string"
        },
        "telephony": {
          "type": "string"
        },
        "data_sources": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "integrations": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "system"
            ],
            "properties": {
              "system": {
                "type": "string"
              },
              "direction": {
                "type": "string",
                "enum": [
                  "inbound",
                  "outbound",
                  "both"
                ]
              },
              "frequency": {
                "type": "string",
                "enum": [
                  "real-time",
                  "near-real-time",
                  "scheduled",
                  "manual"
                ]
              },
              "purpose": {
                "type": "string"
              }
            }
          }
        },
        "microsoft_365": {
          "type": "boolean"
        },
        "licences": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "environments": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "team": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "alias",
          "availability_percent",
          "skills"
        ],
        "properties": {
          "alias": {
            "type": "string",
            "description": "Short alias such as 'Analyst A'. Use this instead of a name where the organisation prefers."
          },
          "name": {
            "type": "string",
            "description": "Optional. Leave out when preferences.use_aliases is true."
          },
          "current_role": {
            "type": "string"
          },
          "availability_percent": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "internal": {
            "type": "boolean",
            "description": "false for partner or contractor staff."
          },
          "skills": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "skill",
                "level"
              ],
              "properties": {
                "skill": {
                  "type": "string",
                  "description": "An id from data/skills-vocabulary.toml."
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "awareness",
                    "working",
                    "advanced",
                    "expert"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "constraints": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "partner": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "engaged": {
              "type": "boolean"
            },
            "scope": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "compliance": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "change_freezes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "known_risks": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "preferences": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "use_aliases": {
          "type": "boolean"
        },
        "edition": {
          "type": "string",
          "enum": [
            "auto",
            "smb",
            "enterprise"
          ]
        },
        "output_formats": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "docx",
              "xlsx",
              "md"
            ]
          }
        }
      }
    }
  }
}