@shophost/client 2.0.34 → 2.0.36
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 +72 -1
- package/index.js +5 -0
- package/package.json +8 -7
- package/src/index.d.ts +55 -0
- package/src/__generated__/openapi.json +0 -15243
- package/src/__generated__/sdk/client/client.gen.js +0 -200
- package/src/__generated__/sdk/client/client.gen.js.map +0 -1
- package/src/__generated__/sdk/client/index.js +0 -7
- package/src/__generated__/sdk/client/index.js.map +0 -1
- package/src/__generated__/sdk/client/types.gen.js +0 -3
- package/src/__generated__/sdk/client/types.gen.js.map +0 -1
- package/src/__generated__/sdk/client/utils.gen.js +0 -221
- package/src/__generated__/sdk/client/utils.gen.js.map +0 -1
- package/src/__generated__/sdk/client.gen.js +0 -4
- package/src/__generated__/sdk/client.gen.js.map +0 -1
- package/src/__generated__/sdk/core/auth.gen.js +0 -16
- package/src/__generated__/sdk/core/auth.gen.js.map +0 -1
- package/src/__generated__/sdk/core/bodySerializer.gen.js +0 -58
- package/src/__generated__/sdk/core/bodySerializer.gen.js.map +0 -1
- package/src/__generated__/sdk/core/params.gen.js +0 -101
- package/src/__generated__/sdk/core/params.gen.js.map +0 -1
- package/src/__generated__/sdk/core/pathSerializer.gen.js +0 -115
- package/src/__generated__/sdk/core/pathSerializer.gen.js.map +0 -1
- package/src/__generated__/sdk/core/queryKeySerializer.gen.js +0 -100
- package/src/__generated__/sdk/core/queryKeySerializer.gen.js.map +0 -1
- package/src/__generated__/sdk/core/serverSentEvents.gen.js +0 -135
- package/src/__generated__/sdk/core/serverSentEvents.gen.js.map +0 -1
- package/src/__generated__/sdk/core/types.gen.js +0 -3
- package/src/__generated__/sdk/core/types.gen.js.map +0 -1
- package/src/__generated__/sdk/core/utils.gen.js +0 -88
- package/src/__generated__/sdk/core/utils.gen.js.map +0 -1
- package/src/__generated__/sdk/index.js +0 -3
- package/src/__generated__/sdk/index.js.map +0 -1
- package/src/__generated__/sdk/sdk.gen.js +0 -424
- package/src/__generated__/sdk/sdk.gen.js.map +0 -1
- package/src/__generated__/sdk/types.gen.js +0 -3
- package/src/__generated__/sdk/types.gen.js.map +0 -1
- package/src/index.js +0 -159
- package/src/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,9 +1,80 @@
|
|
|
1
1
|
# @shophost/client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@shophost/client` is the generated TypeScript client for the ShopHost API.
|
|
4
|
+
|
|
5
|
+
It wraps the generated OpenAPI SDK with a small runtime that normalizes request
|
|
6
|
+
shapes and responses.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @shophost/client
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Create a client pointed at the public app origin:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { initClient } from "@shophost/client";
|
|
20
|
+
|
|
21
|
+
const shophost = initClient({
|
|
22
|
+
baseUrl: "http://localhost:3000",
|
|
23
|
+
credentials: "include",
|
|
24
|
+
throwOnUnknownStatus: true,
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Fetch products:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const response = await shophost.product.getProducts({
|
|
32
|
+
params: {
|
|
33
|
+
organizationId: "org_123",
|
|
34
|
+
},
|
|
35
|
+
query: {
|
|
36
|
+
page: 1,
|
|
37
|
+
limit: 20,
|
|
38
|
+
locale: "en",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (response.status === 200) {
|
|
43
|
+
console.log(response.body.list);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Create a temporary upload record:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const response = await shophost.file.createTemporaryFile({
|
|
51
|
+
body: {
|
|
52
|
+
filename: "hero.jpg",
|
|
53
|
+
mimeType: "image/jpeg",
|
|
54
|
+
size: 1024,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Client Options
|
|
60
|
+
|
|
61
|
+
- `baseUrl`
|
|
62
|
+
Public origin of the app exposing ShopHost routes. The client appends `/api`.
|
|
63
|
+
- `baseHeaders`
|
|
64
|
+
Default headers sent with every request.
|
|
65
|
+
- `credentials`
|
|
66
|
+
Forward cookies for auth-aware calls.
|
|
67
|
+
- `fetch`
|
|
68
|
+
Custom fetch implementation.
|
|
69
|
+
- `throwOnUnknownStatus`
|
|
70
|
+
Throw when the API returns a status code that is not documented in OpenAPI.
|
|
4
71
|
|
|
5
72
|
## Regenerate
|
|
6
73
|
|
|
7
74
|
```sh
|
|
8
75
|
pnpm exec nx run client:generate
|
|
9
76
|
```
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|