@clipboard-health/json-api 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# @clipboard-health/json-api
|
|
1
|
+
# @clipboard-health/json-api <!-- omit from toc -->
|
|
2
2
|
|
|
3
3
|
Utilities for adhering to the [JSON:API](https://jsonapi.org/) specification.
|
|
4
4
|
|
|
5
|
-
## Table of
|
|
5
|
+
## Table of contents <!-- omit from toc -->
|
|
6
6
|
|
|
7
7
|
- [Install](#install)
|
|
8
8
|
- [Usage](#usage)
|
|
@@ -33,7 +33,7 @@ import { type ClientJsonApiQuery } from "../src/lib/types";
|
|
|
33
33
|
|
|
34
34
|
const [date1, date2] = ["2024-01-01", "2024-01-02"];
|
|
35
35
|
const query: ClientJsonApiQuery = {
|
|
36
|
-
fields: { user: ["age", "
|
|
36
|
+
fields: { user: ["age", "dateOfBirth"] },
|
|
37
37
|
filter: {
|
|
38
38
|
age: { eq: ["2"] },
|
|
39
39
|
dateOfBirth: { gt: [date1], lt: [date2] },
|
|
@@ -49,7 +49,7 @@ const query: ClientJsonApiQuery = {
|
|
|
49
49
|
deepEqual(
|
|
50
50
|
toClientSearchParams(query).toString(),
|
|
51
51
|
new URLSearchParams(
|
|
52
|
-
`fields[user]=age,
|
|
52
|
+
`fields[user]=age,dateOfBirth&filter[age]=2&filter[dateOfBirth][gt]=${date1}&filter[dateOfBirth][lt]=${date2}&filter[isActive]=true&include=article&page[size]=10&sort=-age`,
|
|
53
53
|
).toString(),
|
|
54
54
|
);
|
|
55
55
|
|
|
@@ -68,13 +68,13 @@ import { type ServerJsonApiQuery, toServerJsonApiQuery } from "@clipboard-health
|
|
|
68
68
|
const [date1, date2] = ["2024-01-01", "2024-01-02"];
|
|
69
69
|
// The URLSearchParams constructor also supports URL-encoded strings
|
|
70
70
|
const searchParams = new URLSearchParams(
|
|
71
|
-
`fields[user]=age,
|
|
71
|
+
`fields[user]=age,dateOfBirth&filter[age]=2&filter[dateOfBirth][gt]=${date1}&filter[dateOfBirth][lt]=${date2}&filter[isActive]=true&include=article&page[size]=10&sort=-age`,
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
const query: ServerJsonApiQuery = toServerJsonApiQuery(searchParams);
|
|
75
75
|
|
|
76
76
|
deepEqual(query, {
|
|
77
|
-
fields: { user: ["age", "
|
|
77
|
+
fields: { user: ["age", "dateOfBirth"] },
|
|
78
78
|
filter: {
|
|
79
79
|
age: { eq: ["2"] },
|
|
80
80
|
dateOfBirth: { gt: [date1], lt: [date2] },
|
package/package.json
CHANGED