# Default row schema for a Supplier / Subcontractor Status Report
# entry, served by zddc-server when no operator-supplied form.yaml
# exists at <project>/archive/<party>/ssr.form.yaml.
#
# The `name` field doubles as the party folder name (the row's
# stable identifier). It's required on create (+ Add row materializes
# <project>/archive/<name>/) but is stripped from the YAML on save —
# the folder name IS the identity, so storing it inside the file too
# would just be a denormalization. On read the dispatcher injects
# name back into the row data so this form (and the SSR table)
# can display it.
#
# Pattern excludes leading `.` and `_` to avoid colliding with
# fileapi.go's dot/underscore-prefix guards on file paths.
#
# To customize: drop your own form.yaml into
# <project>/archive/<party>/ (sibling to the party's ssr.yaml).

title: Supplier / Subcontractor Status
description: One party's status report. The party name doubles as the archive folder name and is required when creating a new row.

schema:
  type: object
  required: [name, vendorType, contractNo, scopeSummary]
  additionalProperties: false
  properties:
    name:
      type: string
      title: Party (folder name)
      description: Becomes <project>/archive/<name>/. Typical naming = MasterFormat 4-digit code + C|P + sequence digit (e.g. 0330C1).
      pattern: "^[A-Za-z0-9][A-Za-z0-9.-]*$"
      minLength: 1
    vendorType:
      type: string
      title: Vendor type
      enum: [subcontractor, supplier, consultant, vendor, other]
    contractNo:
      type: string
      title: Contract / PO number
    scopeSummary:
      type: string
      title: Scope summary
    contractValue:
      type: number
      title: Contract value
    awardDate:
      type: string
      title: Award date
      format: date
    kickoffDate:
      type: string
      title: Kickoff date
      format: date
    scheduleStatus:
      type: string
      title: Schedule status
      enum: [on-track, at-risk, behind, completed, on-hold]
    deliverablesStatus:
      type: string
      title: Deliverables status
      enum: [on-track, at-risk, behind, completed]
    paymentStatus:
      type: string
      title: Payment status
      enum: [current, overdue, hold, complete]
    ownerContact:
      type: string
      title: Owner contact (email)
    notes:
      type: string
      title: Notes

    # --- Audit fields (server-managed; read-only). WriteWithHistory
    # strips any client-supplied versions before validation and
    # re-injects authoritative values on every write.
    created_at:
      type: string
      title: Created
      format: date-time
      readOnly: true
    created_by:
      type: string
      title: Created by
      format: email
      readOnly: true
    updated_at:
      type: string
      title: Updated
      format: date-time
      readOnly: true
    updated_by:
      type: string
      title: Updated by
      format: email
      readOnly: true
    revision:
      type: integer
      title: Revision
      minimum: 1
      readOnly: true
    previous_sha:
      type: string
      title: Previous SHA
      description: SHA-256 (first 8 hex chars) of the prior revision's bytes.
      readOnly: true
ui:
  scopeSummary:
    ui:widget: textarea
  notes:
    ui:widget: textarea
