import { ContentType } from '@coolio/http'; export interface Attributes { [x: string]: any; } export declare type RelationshipData = { id: string; type: Type; }; export declare type RelationshipType = RelationshipData | RelationshipData[]; declare type RawRelationship = { data: T; links?: { self?: string; related: string; }; related?: string; }; export declare type Relationship = RawRelationship; export declare type RelationshipArray = RawRelationship; export declare type ResolvedRelationship = RawRelationship; export declare type ResolvedRelationshipArray = RawRelationship; export declare type Relationships = Record | undefined>; export declare type UnresolvedRelationships = Record; export declare type ResolvedRelationships = Record; export declare type OptionalRels = Relationships | undefined; export declare type IncludedRelationships = D[]; export interface Data { id: string; type: string; attributes: Attrs; relationships: Rels; links: { self: string; }; } export declare type AnyData = Data; declare type EmptyRecord = { [key: string]: never; }; export declare type AttributesOf = D extends { attributes: Attributes; } ? D['attributes'] : EmptyRecord; export declare type RelationshipsOf = D extends { relationships: Relationships; } ? D['relationships'] : EmptyRecord; /** * MergeData type * -------------- * This sophisticated type allows to correctly infer nicely formatted data from JSON API format. * `id`, `type`, `attributes` and `relationships` suddenly become a single, combined object with easy access to it. * Same is applied to arrays. */ export declare type MergedData = D extends AnyData ? (AttributesOf & (RelationshipsOf extends Relationships ? { [k in keyof RelationshipsOf]: MergedData[k]['data']>; } : RelationshipsOf) & ({ id: string; type: string; self: string; })) : D extends AnyData[] ? (AttributesOf & (RelationshipsOf extends Relationships ? { [k in keyof RelationshipsOf]: MergedData[k]['data']>; } : RelationshipsOf) & ({ id: string; type: string; self: string; }))[] : (D extends RelationshipData ? D['id'] : D extends RelationshipData[] ? D[0]['id'][] : never); export interface ListMetaData { totalResourceCount: number; } /** * Included groups * --------------- * Included groups allow you to extract stuff from 'included' JSON API field * basing on specified name-type pairs, and add proper types to it. * */ export interface IncludedGroup { type: string; __d: D; } export declare type IncludedGroupsSchema = Record; export declare type IncludedGroups = { [k in keyof Groups]: Groups[k]['__d'][]; }; export declare type MergedIncludedGroups> = { [k in keyof G]: MergedData; }; /** * This interface covers JSON API response for single element. */ export interface RawResponse { data: D; meta?: M; included?: IncludedRelationships; } /** * This interface covers JSON API response for multiple elements. */ export interface RawListResponse { data: D[]; links: { self?: string; first: string; next?: string; prev?: string; last: string; }; included?: IncludedRelationships; meta: M; } export declare const Headers: { 'Content-Type': ContentType; Accept: ContentType; }; export declare enum SortOrder { ASCENDING = "", DESCENDING = "-" } export {}; //# sourceMappingURL=types.d.ts.map