Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/ts-json-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.1] - 2021-01-08
### Added
- `publication links` interface as part of the JSON:API 1.0 specification

### Changed
- `meta` key in `link` object to be optional to be JSON:API 1.0 compliant

## [1.0.0] - 2020-02-17
### Changed
- Moved to [TSDX](https://https://github.com/palmerhq/tsdx) for development.
Expand Down
4 changes: 2 additions & 2 deletions packages/ts-json-api/src/types/requests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NewResourceObject, ResourceObject } from './resourceObjects';
import { Links, Meta } from './shared';
import { Meta, TopLevelLinks } from './shared';

/**
* A Request to be sent to a JSON API-compliant server.
Expand All @@ -11,7 +11,7 @@ export interface Request<
> {
data: D;
included?: ResourceObject[];
links?: Links;
links?: TopLevelLinks;
errors?: [Error];
meta?: Meta;
}
10 changes: 5 additions & 5 deletions packages/ts-json-api/src/types/responses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ResourceObject, ResourceObjectOrObjects } from './resourceObjects';
import { Links, Meta } from './shared';
import { Links, Meta, TopLevelLinks } from './shared';

/**
* A Response for sure containing data.
Expand All @@ -9,7 +9,7 @@ export interface ResponseWithData<
> {
data: D;
included?: ResourceObject[];
links?: Links;
links?: TopLevelLinks;
errors?: Error[];
meta?: Meta;
}
Expand All @@ -22,7 +22,7 @@ export interface ResponseWithErrors<
> {
data?: D;
included?: ResourceObject[];
links?: Links;
links?: TopLevelLinks;
errors: Error[];
meta?: Meta;
}
Expand All @@ -35,7 +35,7 @@ export interface ResponseWithMetaData<
> {
data?: D;
included?: ResourceObject[];
links?: Links;
links?: TopLevelLinks;
errors?: Error[];
meta: Meta;
}
Expand All @@ -48,7 +48,7 @@ export interface Response<
> {
data?: D;
included?: ResourceObject[];
links?: Links;
links?: TopLevelLinks;
errors?: Error[];
meta?: Meta;
}
Expand Down
24 changes: 22 additions & 2 deletions packages/ts-json-api/src/types/shared.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
/**
* A single Link.
*/
export type Link = string | LinkObject;

/**
* An index of Links.
*/
export interface Links {
[index: string]: string | LinkObject;
[index: string]: Link;
}

/**
* Top level pagination Links.
*/
export interface PaginationLinks {
first?: Link | null;
last?: Link | null;
prev?: Link | null;
next?: Link | null;
}

/**
* The top level Links.
*/
export type TopLevelLinks = Links & PaginationLinks;

/**
* A Link.
*/
export interface LinkObject {
href: string;
meta: Meta;
meta?: Meta;
}

/**
Expand Down