0.1.6Updated a month ago
declare namespace Supply {

  interface Item {
    id?: number

    key: string

    name: string
    description?: string

    provider: string
    reference?: string

    uncapped?: boolean

    stock_capacity: number
    stock_allotted?: number
    weight: number
    monetary_value?: number

    allotments_expire?: boolean,
    allotment_expiration_days?: number,

    timestamp_added: Date

    available_from_date?: Date
    available_until_date?: Date

    archived?: boolean
  }

  namespace Item {

    type Unserialized = Omit<Item, 'available_from_date' | 'available_until_date'> & {
      available_from_date: Date | string,
      available_until_date: Date | string
    }

    type Unentered = Omit<Item, 'id' | 'timestamp_added'> & { stock_allotted?: number }

    type WithPools = Item & { pools: string[] }

    interface AddResponseFailure {
      added: false
      reason: string
    }

    interface AddResponseSuccess {
      added: true
    }

    type Response = AddResponseFailure | AddResponseSuccess

    interface ArchiveResponseFailure {
      archived: false
      reason: string
    }

    interface ArchiveResponseSuccess {
      archived: true
    }

    type ArchiveResponse = ArchiveResponseFailure | ArchiveResponseSuccess
  }
}