/**
 * Types of Claims
 *
 * Note that these are for the claims that get signed.
 * Records that are the latest edited entities are in the records.ts file.
 *
 */

import { ClaimObject } from "./common";

export interface AgreeActionClaim extends ClaimObject {
  "@context": "https://schema.org";
  "@type": string;
  object: Record<string, unknown>;
}

// Note that previous VCs may have additional fields.
// https://endorser.ch/doc/html/transactions.html#id4
export interface GiveActionClaim extends ClaimObject {
  // context is optional because it might be embedded in another claim, eg. an AgreeAction
  "@context"?: "https://schema.org";
  "@type": "GiveAction";
  agent?: { identifier: string };
  description?: string;
  fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[];
  identifier?: string;
  image?: string;
  object?: { amountOfThisGood: number; unitCode: string };
  provider?: ClaimObject;
  recipient?: { identifier: string };
}

export interface JoinActionClaim extends ClaimObject {
  agent?: { identifier: string };
  event?: { organizer?: { name: string }; name?: string; startTime?: string };
}

// Note that previous VCs may have additional fields.
// https://endorser.ch/doc/html/transactions.html#id8
export interface OfferClaim extends ClaimObject {
  "@context": "https://schema.org";
  "@type": "Offer";
  agent?: { identifier: string };
  description?: string;
  fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[];
  identifier?: string;
  image?: string;
  includesObject?: { amountOfThisGood: number; unitCode: string };
  itemOffered?: {
    description?: string;
    isPartOf?: {
      identifier?: string;
      lastClaimId?: string;
      "@type"?: string;
      name?: string;
    };
  };
  offeredBy?: {
    type?: "Person";
    identifier: string;
  };
  provider?: ClaimObject;
  recipient?: { identifier: string };
  validThrough?: string;
}

// Note that previous VCs may have additional fields.
// https://endorser.ch/doc/html/transactions.html#id7
export interface PlanActionClaim extends ClaimObject {
  "@context": "https://schema.org";
  "@type": "PlanAction";
  name: string;
  agent?: { identifier: string };
  description?: string;
  identifier?: string;
  lastClaimId?: string;
  location?: {
    geo: { "@type": "GeoCoordinates"; latitude: number; longitude: number };
  };
}

// AKA Registration & RegisterAction
export interface RegisterActionClaim extends ClaimObject {
  "@context": "https://schema.org";
  "@type": "RegisterAction";
  agent: { identifier: string };
  identifier?: string;
  object?: string;
  participant?: { identifier: string };
}

export interface TenureClaim extends ClaimObject {
  "@context": "https://endorser.ch";
  "@type": "Tenure";
  party?: { identifier: string };
  spatialUnit?: { geo?: { polygon?: string } };
}
