/* For creating nominal types. Primitive values can still be assigned to this type. */
type Flavor<T, N extends string> = T & {
  /** Don't use this. Added by `Flavor` to support Nominal typing */
  readonly __brand?: N;
};

/** ISO-8601 timestamp. E.g. '2021-10-10T15:30:00Z' */
export type Timestamp = Flavor<string, 'ISO'>;

export interface CustomAttributes {
  [attribute: string]: CustomAttribute[];
}

export interface CustomAttribute {
  /** The id of the attribute */
  id: string;
  /**
   * The label of the attribute (name in the feed).
   * *Note*: Currently not available for content items
   */
  label: string;
}

export interface Image {
  /**
   * The alt text for the image for A11y. Should describe the image.
   * Will be `undefined` if omitted during import
   */
  alt?: string;
  /**
   * The caption for the image. Only available for ProductPage and ContentInformation
   * requests. Will be `undefined` if omitted during import
   */
  caption?: string;
  /** Custom attributes added to this image during import. Will be `undefined` if omitted during import */
  custom?: Record<string, string>;
  /** Multiple sources for each image, use with `<img srcset={VALUES} />` */
  sources: ImageSource[];
}

export interface ImageSource {
  /** Url to the image source. */
  url: string;
  /**
   * The width of the image. Will be `undefined` if not expicitly specified or if
   * image hasn't yet been assessed by image service.
   */
  width?: number;
  /** The height of the image. Will be `undefined` if not specified. */
  height?: number;
}

export interface AutoCorrect {
  /** The original search phrase */
  q: string;
  /** The number of hits for the original search phrase */
  originalTotalHits: number;
}

export interface DidYouMean {
  /** A suggested correction phrase */
  q: string;
}

export interface RelatedSearch {
  /** A suggested query related to the original query */
  q: string;
}
