{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/presscart-com/json-schema/presscart-com-campaign-questionnaire-schema.json",
  "title": "CampaignQuestionnaire",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/presscart-com-openapi.json#/components/schemas/CampaignQuestionnaire",
  "type": [
    "object",
    "null"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "campaign_id": {
      "type": "string",
      "format": "uuid"
    },
    "status": {
      "type": "string",
      "enum": [
        "in_progress",
        "submitted",
        "unlocked"
      ]
    },
    "story_type": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "PROFILE_ARTICLE",
        "THOUGHT_LEADERSHIP",
        "LISTICLE",
        "PRESS_RELEASE",
        "EDUCATION",
        "PERSONAL_EXPERIENCE",
        "CASE_STUDY"
      ]
    },
    "story_selected_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "submitted_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "unlocked_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "unlock_note": {
      "type": [
        "string",
        "null"
      ]
    },
    "eligibility": {
      "type": "object",
      "properties": {
        "story_module": {
          "type": "boolean"
        },
        "eligible_story_types": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "PROFILE_ARTICLE",
              "THOUGHT_LEADERSHIP",
              "LISTICLE",
              "PRESS_RELEASE",
              "EDUCATION",
              "PERSONAL_EXPERIENCE",
              "CASE_STUDY"
            ]
          }
        },
        "preselected": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "PROFILE_ARTICLE",
            "THOUGHT_LEADERSHIP",
            "LISTICLE",
            "PRESS_RELEASE",
            "EDUCATION",
            "PERSONAL_EXPERIENCE",
            "CASE_STUDY"
          ]
        },
        "recommendations": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "story_type": {
                "type": "string",
                "enum": [
                  "PROFILE_ARTICLE",
                  "THOUGHT_LEADERSHIP",
                  "LISTICLE",
                  "PRESS_RELEASE",
                  "EDUCATION",
                  "PERSONAL_EXPERIENCE",
                  "CASE_STUDY"
                ]
              },
              "rank": {
                "type": "integer"
              },
              "reasons": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "story_type",
              "rank",
              "reasons"
            ]
          }
        }
      },
      "required": [
        "story_module",
        "eligible_story_types",
        "preselected",
        "recommendations"
      ]
    },
    "modules": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "module_type": {
            "type": "string",
            "enum": [
              "PROFILE",
              "SHARED_CORE",
              "STORY"
            ]
          },
          "form_key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/QuestionnaireField"
            }
          },
          "answers": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "value": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    },
                    {
                      "nullable": true
                    },
                    {
                      "nullable": true
                    }
                  ]
                },
                "source": {
                  "type": "string"
                },
                "confidence": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "derived_from": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "updated_at": {
                  "type": "string"
                }
              },
              "required": [
                "value",
                "source",
                "confidence",
                "updated_at"
              ]
            }
          },
          "completeness": {
            "$ref": "#/$defs/QuestionnaireCompleteness"
          }
        },
        "required": [
          "module_type",
          "form_key",
          "name",
          "fields",
          "answers",
          "completeness"
        ]
      }
    },
    "overall_completeness": {
      "$ref": "#/$defs/QuestionnaireCompleteness"
    },
    "pending_story_core_count": {
      "type": "integer",
      "minimum": 0,
      "default": 0
    },
    "profile_tags": {
      "type": "object",
      "properties": {
        "audience": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "topic": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "audience",
        "topic"
      ]
    }
  },
  "required": [
    "id",
    "campaign_id",
    "status",
    "story_type",
    "story_selected_at",
    "submitted_at",
    "unlocked_at",
    "unlock_note",
    "eligibility",
    "modules",
    "overall_completeness",
    "profile_tags"
  ],
  "$defs": {
    "QuestionnaireCompleteness": {
      "type": "object",
      "properties": {
        "core_complete": {
          "type": "boolean"
        },
        "unanswered_core": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "optional_remaining": {
          "type": "integer"
        },
        "answered_count": {
          "type": "integer"
        },
        "total_count": {
          "type": "integer"
        }
      },
      "required": [
        "core_complete",
        "unanswered_core",
        "optional_remaining",
        "answered_count",
        "total_count"
      ]
    },
    "QuestionnaireField": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "TEXT",
            "TEXTAREA",
            "RICH_TEXT",
            "SELECT",
            "MULTISELECT",
            "BOOLEAN",
            "NUMBER",
            "DATE",
            "URL",
            "EMAIL",
            "FILE"
          ]
        },
        "required": {
          "type": "boolean",
          "default": false
        },
        "core": {
          "type": "boolean",
          "default": false
        },
        "order": {
          "type": "integer"
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "placeholder": {
          "type": "string"
        },
        "ai_assist": {
          "type": "string",
          "enum": [
            "manual",
            "suggestion",
            "prefill"
          ],
          "default": "manual"
        },
        "example_answer": {
          "type": "string"
        },
        "how_to_answer": {
          "type": "string"
        },
        "drill_down_prompts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "profile_write_through": {
          "type": "string",
          "enum": [
            "name",
            "website_url",
            "overview",
            "products_and_services",
            "founded_year",
            "key_achievements",
            "unique_value_propositions",
            "legal_company_name"
          ]
        },
        "capture": {
          "type": "string",
          "enum": [
            "audience_tags",
            "industry_tags"
          ]
        }
      },
      "required": [
        "key",
        "label",
        "type",
        "order"
      ]
    }
  }
}