Skip to content

Instantly share code, notes, and snippets.

@shovon
Created March 13, 2022 04:59
Show Gist options
  • Save shovon/4e8260b4753bfb90a7333647136f9ff2 to your computer and use it in GitHub Desktop.
Save shovon/4e8260b4753bfb90a7333647136f9ff2 to your computer and use it in GitHub Desktop.
export type Links = { [key: string]: Link };
export type StatusCode =
| "400"
| "401"
| "402"
| "403"
| "404"
| "405"
| "406"
| "407"
| "408"
| "409"
| "410"
| "411"
| "412"
| "413"
| "414"
| "415"
| "416"
| "417"
| "418"
| "421"
| "422"
| "423"
| "424"
| "425"
| "426"
| "428"
| "429"
| "431"
| "451"
| "500"
| "501"
| "502"
| "503"
| "504"
| "505"
| "506"
| "507"
| "508"
| "510"
| "511";
export type Error = {
id?: string;
links?: { about: Link };
status?: StatusCode;
code?: string;
title?: string;
detail?: string;
source?: {
pointer?: string;
parameter?: string;
[key: string]: any;
};
meta?: {};
};
export type Link =
| string
| {
href: string;
meta?: {};
};
export type Self = { self: Link };
export type Related = { related: Link };
export type ResourceIdentifier = {
type: string;
id: number;
meta?: {};
};
export type Linkage = null | [];
export type Relationship = {
links: (Self | Related | (Self & Related)) & Links;
data: ResourceIdentifier | ResourceIdentifier[];
};
export type ResourceObject = {
id: string;
type: string;
attributes?: {};
relationships?: { [key: string]: Relationship };
links?: Links;
meta?: {};
};
export type PrimaryData = ResourceObject | ResourceIdentifier | null;
export type Document = (
| {
data: PrimaryData | PrimaryData[];
meta?: {};
included?: ResourceObject[];
}
| {
errors: Error[];
meta?: {};
}
| {
meta: {};
}
) & {
jsonapi?: {};
links: {
self?: Link;
related?: Link;
} & Links;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment