# Schema artifacts: one per contract, linked by contract_name and contract_version.
# schema_data is the full JSON Schema (type, properties, required, etc.).

- contract_name: example_user_contract
  contract_version: "1.0.0"
  title: example_user
  version: "1.0.0"
  type: object
  properties:
    user_id:
      type: string
      description: Unique user identifier
      minLength: 1
    name:
      type: string
      description: Full name
      minLength: 1
      maxLength: 100
    email:
      type: string
      format: email
      description: Email address
    status:
      type: string
      enum: [active, inactive, pending]
      description: Account status
    created_at:
      type: string
      format: date-time
      description: Creation timestamp
  required:
    - user_id
    - name
    - email
    - status
    - created_at

- contract_name: example_event_contract
  contract_version: "1.0.0"
  title: example_event
  version: "1.0.0"
  type: object
  properties:
    event_id:
      type: string
      description: Event identifier
    event_type:
      type: string
      description: Type of event
    occurred_at:
      type: string
      format: date-time
  required:
    - event_id
    - event_type
    - occurred_at

- contract_name: aircraft_configuration
  contract_version: "1.0.0"
  title: aircraft_configuration
  version: "1.0.0"
  type: object
  properties:
    metadata:
      description: Metadata when the record is processed
      title: Metadata
      type: object
    registration:
      description: Registration of the Aircraft
      examples: [BLBK, BLXN]
      maxLength: 10
      title: Registration
      type: string
    valid_since:
      description: Start of validity
      format: date-time
      title: Valid Since
      type: string
    valid_until:
      description: End of validity
      format: date-time
      title: Valid Until
      type: string
    ac_operator:
      description: Aircraft Operator
      examples: [CX, KA]
      maxLength: 3
      title: Ac Operator
      type: string
    ac_owner:
      description: Owner of the aircraft
      examples: [CX, KA]
      maxLength: 3
      title: Ac Owner
      type: string
    ac_subtype:
      description: Subtype of the aircraft
      maxLength: 3
      title: Ac Subtype
      type: string
    ac_logical_no:
      description: Logical number of the Aircraft
      title: Ac Logical No
      type: integer
    ac_state:
      description: "Status of Aircraft('R'=real and 'O'=overflow)"
      enum: [R, O]
      maxLength: 1
      title: Ac State
      type: string
    dry_operating_wgt:
      description: Dry Operating Weight (kg)
      title: Dry Operating Wgt
      type: integer
    max_takeoff_wgt:
      description: Max Takeoff Weight (kg)
      title: Max Takeoff Wgt
      type: integer
    cargo_capacity:
      description: Cargo Capacity (kg)
      title: Cargo Capacity
      type: integer
    fuel_capacity:
      description: Fuel Capacity (kg)
      title: Fuel Capacity
      type: integer
    avg_fuel_consump:
      description: Average Fuel Consumption (kg per hour)
      title: Avg Fuel Consump
      type: integer
    ac_index:
      description: Aircraft index
      title: Ac Index
      type: integer
    crewsize_cockpit:
      description: Number of Cockpit Crewmembers
      title: Crewsize Cockpit
      type: integer
    crewsize_cabin:
      description: Number of Cabin Crewmembers
      title: Crewsize Cabin
      type: integer
    std_version:
      description: Aircraft Standard Version
      maxLength: 20
      title: Std Version
      type: string
    ap_restriction:
      description: "Airport Restriction - e.g. Political Reason, Performance('Y' or 'N')"
      examples: [N, Y, R]
      maxLength: 1
      title: Ap Restriction
      type: string
    ac_owner_name:
      description: Full Name of Owner
      maxLength: 30
      title: Ac Owner Name
      type: string
    ac_subtype_name:
      description: Full Name of Subtype
      maxLength: 30
      title: Ac Subtype Name
      type: string
    ac_category:
      description: SSIM-Category of Aircraft
      maxLength: 1
      title: Ac Category
      type: string
    remark:
      anyOf: [{ maxLength: 80, type: "string" }, { type: "null" }]
      default: null
      description: Additional remarks
      title: Remark
    fuel_measure_unit:
      description: Unit for fuel
      maxLength: 3
      title: Fuel Measure Unit
      type: string
    ac_callsign:
      anyOf: [{ maxLength: 5, type: "string" }, { type: "null" }]
      default: null
      description: Callsign of aircraft
      title: Ac Callsign
    radio:
      anyOf: [{ maxLength: 1, type: "string" }, { type: "null" }]
      default: null
      description: Radio type
      title: Radio
    noise:
      anyOf: [{ type: "integer" }, { type: "null" }]
      default: null
      description: ICAO noise chapter
      title: Noise
    phone:
      anyOf: [{ maxLength: 20, type: "string" }, { type: "null" }]
      default: null
      description: Onboard mobile phone number
      title: Phone
    special_equipment:
      anyOf: [{ maxLength: 40, type: "string" }, { type: "null" }]
      default: null
      description: Special equipment
      title: Special Equipment
    acars:
      anyOf: [{ maxLength: 1, type: "string" }, { type: "null" }]
      default: null
      description: ACARS type
      enum: [V, H, S]
      title: Acars
    alt_reg:
      anyOf: [{ maxLength: 10, type: "string" }, { type: "null" }]
      default: null
      description: Alternate Registration
      title: Alt Reg
    record_id:
      default: 0
      description: Record ID
      title: Record Id
      type: integer
    last_update:
      anyOf: [{ format: date-time, type: "string" }, { type: "null" }]
      default: null
      description: Timestamp of last update
      title: Last Update
    last_update_user_id:
      anyOf: [{ maxLength: 32, type: "string" }, { type: "null" }]
      default: null
      description: User ID of last update
      title: Last Update User Id
    std_version_alt_1:
      anyOf: [{ maxLength: 20, type: "string" }, { type: "null" }]
      default: null
      title: Std Version Alt 1
    std_version_alt_2:
      anyOf: [{ maxLength: 20, type: "string" }, { type: "null" }]
      default: null
      title: Std Version Alt 2
    std_version_alt_3:
      anyOf: [{ maxLength: 20, type: "string" }, { type: "null" }]
      default: null
      title: Std Version Alt 3
    std_version_alt_4:
      anyOf: [{ maxLength: 20, type: "string" }, { type: "null" }]
      default: null
      title: Std Version Alt 4
    ils_equipment:
      default: I
      description: "aircraft equipment supporting ILS CAT approaches(I, II, IIIa, IIIb)"
      enum: [I, II, IIIa, IIIb]
      maxLength: 4
      title: Ils Equipment
      type: string
    autoland:
      default: N
      description: Autoland capability indicator
      enum: [Y, N]
      maxLength: 1
      title: Autoland
      type: string
    homebase:
      anyOf: [{ maxLength: 3, type: "string" }, { type: "null" }]
      default: null
      description: Homebase of the aircraft (IATA CODE)
      title: Homebase
    aircraft_owner:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Aircraft Owner from subfleet
      title: Aircraft Owner
    aircraft_subtype:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Subtype of the Aircraft from subfleet
      title: Aircraft Subtype
    fleet_print_code:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      title: Fleet Print Code
    rotational_flag:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Rotational Flag Y/N (Yes/No)
      title: Rotational Flag
    standard_configuration:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Standard Configuration AC_VERSION.AC_VERSION
      title: Standard Configuration
    payload:
      anyOf: [{ type: "number" }, { type: "null" }]
      default: null
      title: Payload
    mtom:
      anyOf: [{ type: "number" }, { type: "null" }]
      default: null
      description: Maximum Take-Off Mass
      title: MTOM
    max_range:
      anyOf: [{ type: "number" }, { type: "null" }]
      default: null
      title: Max Range
    noise_category:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      title: Noise Category
    average_speed:
      anyOf: [{ type: "number" }, { type: "null" }]
      default: null
      title: Average Speed
    aircraft_group:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Group of the Aircraft
      title: Aircraft Group
    icao_code:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      title: ICAO Code
    name:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Fleet Type Name
      title: Name
    body_type:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Body Type N/W (Narrow/Wide)
      title: Body Type
    category:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Category H/J/P/S/T
      title: Category
    aircraft_compartment:
      description: List of aircraft compartments with seat configurations
      items:
        type: object
      title: Aircraft Compartment
      type: array
    aircraft_restriction:
      description: List of aircraft restrictions with constraint codes
      items:
        type: object
      title: Aircraft Restriction
      type: array
  required:
    - metadata
    - registration
    - valid_since
    - valid_until
    - ac_operator
    - ac_owner
    - ac_subtype
    - ac_logical_no
    - ac_state
    - dry_operating_wgt
    - max_takeoff_wgt
    - cargo_capacity
    - fuel_capacity
    - avg_fuel_consump
    - ac_index
    - crewsize_cockpit
    - crewsize_cabin
    - std_version
    - ap_restriction
    - ac_owner_name
    - ac_subtype_name
    - ac_category
    - fuel_measure_unit

- contract_name: airports_and_geographic_information
  contract_version: "1.0.0"
  title: airports_and_geographic_information
  version: "1.0.0"
  type: object
  properties:
    metadata:
      description: Metadata when the record is processed
      title: Metadata
      type: object
    iata_ap_code:
      description: IATA airport code
      maxLength: 3
      title: IATA AP Code
      type: string
    valid_since:
      description: Valid from date
      format: date-time
      title: Valid Since
      type: string
    valid_until:
      description: Valid until date
      format: date-time
      title: Valid Until
      type: string
    icao_code:
      anyOf: [{ maxLength: 4, type: "string" }, { type: "null" }]
      default: null
      description: ICAO airport code
      title: ICAO Code
    ap_name:
      description: Airport name
      maxLength: 30
      title: AP Name
      type: string
    country_code:
      description: Country code
      maxLength: 4
      title: Country Code
      type: string
    dst_zone_code:
      description: Daylight saving time zone code
      maxLength: 4
      title: DST Zone Code
      type: string
    area:
      anyOf: [{ maxLength: 3, type: "string" }, { type: "null" }]
      default: null
      description: Area code
      title: Area
    category:
      description: Airport category
      maxLength: 1
      title: Category
      type: string
    time_zone:
      description: Time zone code
      maxLength: 4
      title: Time Zone
      type: string
    coord_longitude:
      description: Longitude coordinate
      maxLength: 10
      title: Coord Longitude
      type: string
    coord_latitude:
      description: Latitude coordinate
      maxLength: 9
      title: Coord Latitude
      type: string
    external_reference:
      anyOf: [{ maxLength: 10, type: "string" }, { type: "null" }]
      default: null
      description: External reference
      title: External Reference
    record_id:
      default: 0
      description: Record ID
      title: Record Id
      type: integer
    last_update:
      anyOf: [{ format: date-time, type: "string" }, { type: "null" }]
      default: null
      description: Last update timestamp
      title: Last Update
    last_update_user_id:
      anyOf: [{ maxLength: 32, type: "string" }, { type: "null" }]
      default: null
      description: Last update user ID
      title: Last Update User Id
    ap_name_nls:
      anyOf: [{ maxLength: 60, type: "string" }, { type: "null" }]
      default: null
      description: Airport name in native language
      title: AP Name NLS
    runways:
      description: List of runways at this airport
      items: { type: object }
      title: Runways
      type: array
    subtype_details:
      description: Subtype-specific airport details
      items: { type: object }
      title: Subtype Details
      type: array
    city_info:
      description: City information
      items: { type: object }
      title: City Info
      type: array
    iata_city_code:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: IATA city code (from city_info)
      title: IATA City Code
    city:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: City name (from city_info)
      title: City
    state_designator:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: State designator (from city_info)
      title: State Designator
    country:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Country name
      title: Country
    diff_utc_lst:
      anyOf: [{ type: "integer" }, { type: "null" }]
      default: null
      description: Deviation to UTC (signed Minutes)
      title: Diff UTC LST
    diff_lst_dst:
      anyOf: [{ type: "integer" }, { type: "null" }]
      default: null
      description: Deviation from Local Standard Time (signed Minutes)
      title: Diff LST DST
    area_rules:
      anyOf: [{ type: "string" }, { type: "null" }]
      default: null
      description: Area rules categorized by airport, country, and city
      title: Area Rules
  required:
    - metadata
    - iata_ap_code
    - valid_since
    - valid_until
    - ap_name
    - country_code
    - dst_zone_code
    - category
    - time_zone
    - coord_longitude
    - coord_latitude

# Domain entity schemas (status enums align with PyStator FSM state names)
- contract_name: order_domain
  contract_version: "1.0.0"
  title: order_domain
  version: "1.0.0"
  type: object
  properties:
    order_id:
      type: string
      description: Unique order identifier
      minLength: 1
    symbol:
      type: string
      description: Instrument symbol
      minLength: 1
    side:
      type: string
      enum: [buy, sell]
      description: Order side
    quantity:
      type: number
      description: Order quantity
      minimum: 0
    status:
      type: string
      enum:
        - PENDING_NEW
        - OPEN
        - PARTIALLY_FILLED
        - FILLED
        - CANCELED
        - REJECTED
        - TIMED_OUT
        - EXPIRED
      description: FSM state (order_lifecycle)
    filled_qty:
      type: number
      description: Filled quantity so far
      minimum: 0
    created_at:
      type: string
      format: date-time
      description: Creation timestamp
  required:
    - order_id
    - symbol
    - side
    - quantity
    - status

- contract_name: intraday_signal_domain
  contract_version: "1.0.0"
  title: intraday_signal_domain
  version: "1.0.0"
  type: object
  properties:
    signal_id:
      type: string
      description: Unique signal identifier
      minLength: 1
    symbol:
      type: string
      description: Instrument symbol
    direction:
      type: string
      enum: [long, short]
      description: Signal direction
    strength:
      type: number
      description: Signal strength score
    status:
      type: string
      enum:
        - SIGNAL_DETECTED
        - VALIDATING
        - VALIDATION_FAILED
        - PENDING_SUBMIT
        - OPEN
        - FILLED
        - CANCELED
        - REJECTED
      description: FSM state (intraday_signal_lifecycle)
    created_at:
      type: string
      format: date-time
  required:
    - signal_id
    - symbol
    - status

- contract_name: intraday_session_domain
  contract_version: "1.0.0"
  title: intraday_session_domain
  version: "1.0.0"
  type: object
  properties:
    session_id:
      type: string
      description: Unique session identifier
      minLength: 1
    account_id:
      type: string
      description: Trading account id
    status:
      type: string
      enum:
        - PRE_MARKET
        - SCANNING
        - ANALYZING
        - EXECUTING
        - MANAGING
        - POST_MARKET
        - HALTED
      description: FSM state (intraday_trading_session)
    started_at:
      type: string
      format: date-time
    ended_at:
      type: string
      format: date-time
  required:
    - session_id
    - status

- contract_name: portfolio_domain
  contract_version: "1.0.0"
  title: portfolio_domain
  version: "1.0.0"
  type: object
  properties:
    portfolio_id:
      type: string
      description: Unique portfolio identifier
      minLength: 1
    status:
      type: string
      enum:
        - MONITORING
        - REBALANCING
        - REVIEWING
        - SUSPENDED
        - DEACTIVATED
      description: FSM state (portfolio_lifecycle)
    last_rebalance_at:
      type: string
      format: date-time
      description: Last rebalance completion time
    created_at:
      type: string
      format: date-time
      description: Record creation timestamp
  required:
    - portfolio_id
    - status

- contract_name: optimization_cycle_domain
  contract_version: "1.0.0"
  title: optimization_cycle_domain
  version: "1.0.0"
  type: object
  properties:
    run_id:
      type: string
      description: Unique optimization run identifier
      minLength: 1
    portfolio_id:
      type: string
      description: Portfolio identifier
    status:
      type: string
      enum:
        - DATA_COLLECTION
        - OPTIMIZING
        - VALIDATION
        - APPROVAL_PENDING
        - EXECUTING
        - SETTLING
        - COMPLETED
        - FAILED
        - CANCELLED
      description: FSM state (optimization_cycle)
    started_at:
      type: string
      format: date-time
      description: Cycle start time
    completed_at:
      type: string
      format: date-time
      description: Cycle completion time (when terminal)
  required:
    - run_id
    - status

- contract_name: flight_domain
  contract_version: "1.0.0"
  title: flight_domain
  version: "1.0.0"
  type: object
  properties:
    flight_id:
      type: string
      description: Unique flight identifier (e.g. flight number + date)
      minLength: 1
    origin:
      type: string
      description: Origin airport code (IATA/ICAO)
      minLength: 1
    destination:
      type: string
      description: Destination airport code (IATA/ICAO)
      minLength: 1
    status:
      type: string
      enum:
        - SCHEDULED
        - CHECK_IN_OPEN
        - BOARDING
        - DEPARTED
        - IN_FLIGHT
        - LANDED
        - ARRIVED
        - CANCELLED
        - DELAYED
      description: FSM state (flight_lifecycle)
    scheduled_departure:
      type: string
      format: date-time
      description: Scheduled departure time
    scheduled_arrival:
      type: string
      format: date-time
      description: Scheduled arrival time
    actual_departure:
      type: string
      format: date-time
      description: Actual departure time
    actual_arrival:
      type: string
      format: date-time
      description: Actual arrival time
    aircraft_registration:
      type: string
      description: Aircraft registration (e.g. tail number)
    created_at:
      type: string
      format: date-time
      description: Record creation timestamp
  required:
    - flight_id
    - origin
    - destination
    - status
