@clipboard-health/json-api 0.2.5 → 0.2.7

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@clipboard-health/json-api",
3
3
  "description": "Utilities for adhering to the JSON:API specification.",
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "bugs": "https://github.com/clipboardhealth/core-utils/issues",
6
6
  "dependencies": {
7
7
  "tslib": "2.7.0"
8
8
  },
9
9
  "files": [
10
- "dist"
10
+ "dist/src"
11
11
  ],
12
12
  "keywords": [],
13
13
  "license": "MIT",
package/dist/README.md DELETED
@@ -1,83 +0,0 @@
1
- # @clipboard-health/json-api
2
-
3
- Utilities for adhering to the [JSON:API](https://jsonapi.org/) specification.
4
-
5
- ## Table of Contents
6
-
7
- - [Install](#install)
8
- - [Usage](#usage)
9
- - [Local development commands](#local-development-commands)
10
-
11
- ## Install
12
-
13
- ```bash
14
- npm install @clipboard-health/json-api
15
- ```
16
-
17
- ## Usage
18
-
19
- ### Query helpers
20
-
21
- From the client, call `toSearchParams` to convert from `ClientJsonApiQuery` to `URLSearchParams`:
22
-
23
- <!-- prettier-ignore -->
24
- ```ts
25
- // ./examples/toSearchParams.ts
26
-
27
- import { deepEqual } from "node:assert/strict";
28
-
29
- import { toSearchParams } from "@clipboard-health/json-api";
30
-
31
- import { type ClientJsonApiQuery } from "../src/lib/types";
32
-
33
- const isoDate = "2024-01-01T15:00:00.000Z";
34
- const query: ClientJsonApiQuery = {
35
- fields: { dog: ["age"] },
36
- filter: { age: [2], createdAt: { gte: new Date(isoDate) }, isGoodDog: true },
37
- include: ["owner"],
38
- page: { size: 10 },
39
- sort: ["-age"],
40
- };
41
-
42
- deepEqual(
43
- toSearchParams(query).toString(),
44
- new URLSearchParams(
45
- "fields[dog]=age&filter[age]=2&filter[createdAt][gte]=2024-01-01T15:00:00.000Z&filter[isGoodDog]=true&include=owner&page[size]=10&sort=-age",
46
- ).toString(),
47
- );
48
-
49
- ```
50
-
51
- From the server, call `toJsonApiQuery` to convert from `URLSearchParams` to `ServerJsonApiQuery`:
52
-
53
- <!-- prettier-ignore -->
54
- ```ts
55
- // ./examples/toJsonApiQuery.ts
56
-
57
- import { deepEqual } from "node:assert/strict";
58
-
59
- import { type ServerJsonApiQuery, toJsonApiQuery } from "@clipboard-health/json-api";
60
-
61
- const isoDate = "2024-01-01T15:00:00.000Z";
62
- // The URLSearchParams constructor also supports URL-encoded strings
63
- const searchParams = new URLSearchParams(
64
- `fields[dog]=age&filter[age]=2&filter[createdAt][gte]=${isoDate}&filter[isGoodDog]=true&include=owner&page[size]=10&sort=-age`,
65
- );
66
-
67
- const query: ServerJsonApiQuery = toJsonApiQuery(searchParams);
68
-
69
- deepEqual(query, {
70
- fields: { dog: ["age"] },
71
- filter: { age: ["2"], createdAt: { gte: isoDate }, isGoodDog: ["true"] },
72
- include: ["owner"],
73
- page: {
74
- size: "10",
75
- },
76
- sort: ["-age"],
77
- });
78
-
79
- ```
80
-
81
- ## Local development commands
82
-
83
- See [`package.json`](./package.json) `scripts` for a list of commands.
package/dist/package.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "name": "@clipboard-health/json-api",
3
- "description": "Utilities for adhering to the JSON:API specification.",
4
- "version": "0.2.5",
5
- "bugs": "https://github.com/clipboardhealth/core-utils/issues",
6
- "dependencies": {
7
- "tslib": "2.7.0"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "keywords": [],
13
- "license": "MIT",
14
- "main": "./dist/src/index.js",
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/clipboardhealth/core-utils.git",
21
- "directory": "packages/json-api"
22
- },
23
- "scripts": {
24
- "embed": "embedme README.md"
25
- },
26
- "type": "commonjs",
27
- "typings": "./src/index.d.ts",
28
- "types": "./src/index.d.ts"
29
- }