Skip to content

Commit

Permalink
fix(serializer): inject provided top level links into JSON:API document
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Mar 20, 2024
1 parent aee3e92 commit 7754e4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export type JsonApiError = {
meta?: Meta;
};

type TopLevelLinks = Links<"self" | "related" | "describedby" | "first" | "last" | "prev" | "next">;
export type TopLevelLinks = Links<
"self" | "related" | "describedby" | "first" | "last" | "prev" | "next"
>;

type OptionalTopLevelMembers = {
links?: TopLevelLinks;
Expand Down
5 changes: 3 additions & 2 deletions src/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonApiBody } from "./body.js";
import { JsonApiBody, type TopLevelLinks } from "./body.js";
import type {
Attributes,
Links,
Expand Down Expand Up @@ -99,7 +99,7 @@ export type SerializeManagerOptions<TContext = undefined, TSideloaded = undefine
fields?: Record<string, string[]>;
include?: string[];
meta?: Meta;
links?: Links;
links?: TopLevelLinks;
extensions?: string[];
profiles?: string[];
sideloaded?: TSideloaded;
Expand Down Expand Up @@ -178,6 +178,7 @@ export class SerializeManager<
{
data,
meta: options?.meta,
links: options?.links,
included: included?.toJson(),
},
{
Expand Down

0 comments on commit 7754e4d

Please sign in to comment.