{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://antiwhelm.com/schemas/course-catalog.v1.schema.json",
  "title": "AntiWhelm Public Course Catalog v1",
  "description": "The public, non-learner-data schema for one AntiWhelm course record. Unknown values are null, never inferred.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion", "id", "slug", "title", "shortDescription", "fullDescription", "category",
    "learnerAudiences", "buyerAudiences", "minimumAge", "maximumAge", "developmentalBand",
    "problemsAddressed", "learningOutcomes", "majorTopics", "deliveryFormats",
    "estimatedDurationMinutes", "requiredComplianceHours", "supportModes", "price", "purchaseModel",
    "countriesAvailable", "languagesAvailable", "jurisdictions", "markets", "useTypes",
    "certificateAvailable", "completionRequirements", "assessmentRequirements", "programStatus",
    "approvalAndAcceptanceRecords", "standardsAlignment", "credentialsAndReviewers",
    "lastCurriculumReviewDate", "currentCourseVersion", "publicUrl", "purchaseUrl", "sampleUrl", "productImageUrl", "availability",
    "institutionalLicensingAvailable", "requestQuoteUrl", "institutionalDelivery", "commerceMapping"
  ],
  "properties": {
    "schemaVersion": { "const": "1.0.0" },
    "id": { "type": "string", "minLength": 1 },
    "slug": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
    "title": { "type": "string", "minLength": 1 },
    "shortDescription": { "type": "string" },
    "fullDescription": { "type": "string" },
    "category": { "type": "string" },
    "learnerAudiences": { "$ref": "#/$defs/stringArray" },
    "buyerAudiences": { "$ref": "#/$defs/stringArray" },
    "minimumAge": { "type": ["integer", "null"], "minimum": 0 },
    "maximumAge": { "type": ["integer", "null"], "minimum": 0 },
    "developmentalBand": { "type": ["string", "null"] },
    "problemsAddressed": { "$ref": "#/$defs/stringArray" },
    "learningOutcomes": { "$ref": "#/$defs/stringArray" },
    "majorTopics": { "$ref": "#/$defs/stringArray" },
    "deliveryFormats": { "$ref": "#/$defs/stringArray" },
    "estimatedDurationMinutes": { "type": ["integer", "null"], "minimum": 0 },
    "requiredComplianceHours": { "type": ["number", "null"], "minimum": 0 },
    "supportModes": { "$ref": "#/$defs/stringArray" },
    "price": {
      "oneOf": [
        { "type": "null" },
        {
          "type": "object", "additionalProperties": false, "required": ["amount", "currency"],
          "properties": { "amount": { "type": "number", "minimum": 0 }, "currency": { "type": "string", "pattern": "^[A-Z]{3}$" } }
        }
      ]
    },
    "purchaseModel": { "enum": ["one-time", "subscription", null] },
    "countriesAvailable": { "$ref": "#/$defs/nullableStringArray" },
    "languagesAvailable": { "$ref": "#/$defs/nullableStringArray" },
    "jurisdictions": { "$ref": "#/$defs/nullableStringArray" },
    "markets": { "$ref": "#/$defs/stringArray" },
    "useTypes": { "$ref": "#/$defs/stringArray" },
    "certificateAvailable": { "type": ["boolean", "null"] },
    "completionRequirements": { "$ref": "#/$defs/nullableStringArray" },
    "assessmentRequirements": { "$ref": "#/$defs/nullableStringArray" },
    "programStatus": { "$ref": "#/$defs/institutionalStatus" },
    "approvalAndAcceptanceRecords": { "type": "array", "items": { "$ref": "#/$defs/approvalRecord" } },
    "standardsAlignment": { "$ref": "#/$defs/nullableStringArray" },
    "credentialsAndReviewers": { "$ref": "#/$defs/nullableStringArray" },
    "lastCurriculumReviewDate": { "$ref": "#/$defs/nullableDate" },
    "currentCourseVersion": { "type": ["string", "null"] },
    "publicUrl": { "type": "string", "format": "uri" },
    "purchaseUrl": { "$ref": "#/$defs/nullableUri" },
    "sampleUrl": { "$ref": "#/$defs/nullableUri" },
    "productImageUrl": { "$ref": "#/$defs/nullableUri" },
    "availability": { "enum": ["in_stock", "out_of_stock", "pre_order", "backorder", "unknown", null] },
    "institutionalLicensingAvailable": { "type": ["boolean", "null"] },
    "requestQuoteUrl": { "type": "string", "format": "uri" },
    "institutionalDelivery": { "type": "object" },
    "commerceMapping": {
      "oneOf": [
        { "type": "null" },
        {
          "type": "object", "additionalProperties": false,
          "required": ["provider", "shopDomain", "productId", "variantId", "entitlementKey"],
          "properties": {
            "provider": { "const": "shopify" }, "shopDomain": { "type": "string" },
            "productId": { "type": "string" }, "variantId": { "type": "string" }, "entitlementKey": { "type": "string" }
          }
        }
      ]
    }
  },
  "$defs": {
    "stringArray": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
    "nullableStringArray": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/stringArray" }] },
    "nullableUri": { "oneOf": [{ "type": "null" }, { "type": "string", "format": "uri" }] },
    "nullableDate": { "oneOf": [{ "type": "null" }, { "type": "string", "format": "date" }] },
    "institutionalStatus": {
      "enum": ["consumer", "under_development", "pilot", "submitted_for_review", "accepted_by_specific_agency", "approved_by_specific_jurisdiction", "recognized_program", "independently_evaluated", "evidence_based_designation", "not_verified"]
    },
    "approvalRecord": {
      "type": "object", "additionalProperties": false,
      "required": ["status", "organization", "jurisdiction", "courseVersion", "effectiveDate", "expirationOrReviewDate", "sourceUrl", "notes"],
      "properties": {
        "status": { "$ref": "#/$defs/institutionalStatus" }, "organization": { "type": ["string", "null"] },
        "jurisdiction": { "type": ["string", "null"] }, "courseVersion": { "type": ["string", "null"] },
        "effectiveDate": { "$ref": "#/$defs/nullableDate" }, "expirationOrReviewDate": { "$ref": "#/$defs/nullableDate" },
        "sourceUrl": { "$ref": "#/$defs/nullableUri" }, "notes": { "type": ["string", "null"] }
      }
    }
  }
}
