@mix-space-lts/api-client 2.4.2 → 2.4.3
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/dist/adapter-D1g1obyM.d.mts +25 -0
- package/dist/adapter-DLzJOGbI.d.cts +25 -0
- package/dist/adaptors/axios.cjs +63 -0
- package/dist/adaptors/axios.d.cts +7 -0
- package/dist/adaptors/axios.d.mts +7 -0
- package/dist/adaptors/axios.mjs +32 -0
- package/dist/adaptors/fetch.cjs +77 -0
- package/dist/adaptors/fetch.d.cts +6 -0
- package/dist/adaptors/fetch.d.mts +6 -0
- package/dist/adaptors/fetch.mjs +75 -0
- package/dist/adaptors/umi-request.cjs +35 -0
- package/dist/adaptors/umi-request.d.cts +7 -0
- package/dist/adaptors/umi-request.d.mts +7 -0
- package/dist/adaptors/umi-request.mjs +32 -0
- package/dist/index.cjs +1340 -0
- package/dist/index.d.cts +2653 -0
- package/dist/index.d.mts +2653 -0
- package/dist/index.mjs +1296 -0
- package/package.json +5 -2
- package/readme.md +15 -15
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mix-space-lts/api-client",
|
|
3
|
-
"version": "2.4.
|
|
4
|
-
"description": "A api client for
|
|
3
|
+
"version": "2.4.3",
|
|
4
|
+
"description": "A api client for mix-space-lts server@next",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"author": "Innei",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
11
14
|
"files": [
|
|
12
15
|
"dist"
|
|
13
16
|
],
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @mix-space-lts/api-client
|
|
2
2
|
|
|
3
3
|
A framework-agnostic TypeScript/JavaScript SDK for the MX Space server (MServer v3). It wraps common API endpoints with typed request methods and response types for fast frontend and server-side integration.
|
|
4
4
|
|
|
@@ -32,13 +32,13 @@ A framework-agnostic TypeScript/JavaScript SDK for the MX Space server (MServer
|
|
|
32
32
|
From the monorepo root (recommended):
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
pnpm add @
|
|
35
|
+
pnpm add @mix-space-lts/api-client
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Or with npm:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
npm install @
|
|
41
|
+
npm install @mix-space-lts/api-client
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
The package is **framework-agnostic** and does not bundle a specific HTTP client. You must provide an adapter (e.g. Axios or fetch). Install the HTTP library you use:
|
|
@@ -63,8 +63,8 @@ import {
|
|
|
63
63
|
NoteController,
|
|
64
64
|
AggregateController,
|
|
65
65
|
CategoryController,
|
|
66
|
-
} from '@
|
|
67
|
-
import { axiosAdaptor } from '@
|
|
66
|
+
} from '@mix-space-lts/api-client'
|
|
67
|
+
import { axiosAdaptor } from '@mix-space-lts/api-client/adaptors/axios'
|
|
68
68
|
|
|
69
69
|
const endpoint = 'https://api.example.com/v2'
|
|
70
70
|
const client = createClient(axiosAdaptor)(endpoint)
|
|
@@ -108,15 +108,15 @@ $axios.interceptors.request.use((config) => {
|
|
|
108
108
|
|
|
109
109
|
## Adapters
|
|
110
110
|
|
|
111
|
-
Official adapters live under `@
|
|
111
|
+
Official adapters live under `@mix-space-lts/api-client/adaptors/`:
|
|
112
112
|
|
|
113
113
|
| Adapter | Import path | Notes |
|
|
114
114
|
|----------------|------------------------------------------|--------------------------|
|
|
115
|
-
| **Axios** | `@
|
|
116
|
-
| **umi-request**| `@
|
|
117
|
-
| **Fetch** | `@
|
|
115
|
+
| **Axios** | `@mix-space-lts/api-client/adaptors/axios` | Exposes `axiosAdaptor.default` (AxiosInstance). |
|
|
116
|
+
| **umi-request**| `@mix-space-lts/api-client/adaptors/umi-request` | For umi-request users. |
|
|
117
|
+
| **Fetch** | `@mix-space-lts/api-client/adaptors/fetch` | Uses global `fetch`; no extra dependency. |
|
|
118
118
|
|
|
119
|
-
**Custom adapter**: Implement `IRequestAdapter` from `@
|
|
119
|
+
**Custom adapter**: Implement `IRequestAdapter` from `@mix-space-lts/api-client` (methods: `get`, `post`, `put`, `patch`, `delete`; optional `default`). See `src/adaptors/axios.ts` and `src/adaptors/umi-request.ts` for reference.
|
|
120
120
|
|
|
121
121
|
---
|
|
122
122
|
|
|
@@ -149,8 +149,8 @@ Inject one or more controllers so the client exposes them (e.g. `client.post`, `
|
|
|
149
149
|
**Example — inject all controllers:**
|
|
150
150
|
|
|
151
151
|
```ts
|
|
152
|
-
import { createClient, allControllers } from '@
|
|
153
|
-
import { axiosAdaptor } from '@
|
|
152
|
+
import { createClient, allControllers } from '@mix-space-lts/api-client'
|
|
153
|
+
import { axiosAdaptor } from '@mix-space-lts/api-client/adaptors/axios'
|
|
154
154
|
|
|
155
155
|
const client = createClient(axiosAdaptor)('https://api.example.com/v2')
|
|
156
156
|
client.injectControllers(allControllers)
|
|
@@ -241,8 +241,8 @@ v2 introduces breaking changes; see migration below.
|
|
|
241
241
|
- No re-export of `camelcase-keys`. Use the built-in helper or install yourself:
|
|
242
242
|
|
|
243
243
|
```diff
|
|
244
|
-
- import { camelcaseKeysDeep, camelcaseKeys } from '@
|
|
245
|
-
+ import { simpleCamelcaseKeys as camelcaseKeysDeep } from '@
|
|
244
|
+
- import { camelcaseKeysDeep, camelcaseKeys } from '@mix-space-lts/api-client'
|
|
245
|
+
+ import { simpleCamelcaseKeys as camelcaseKeysDeep } from '@mix-space-lts/api-client'
|
|
246
246
|
```
|
|
247
247
|
|
|
248
248
|
---
|
|
@@ -272,7 +272,7 @@ pnpm i
|
|
|
272
272
|
**Exports:**
|
|
273
273
|
|
|
274
274
|
- Main: `createClient`, `RequestError`, controllers, models, DTOs, `simpleCamelcaseKeys`, `HTTPClient` type, `IRequestAdapter` type.
|
|
275
|
-
- Adapters: `@
|
|
275
|
+
- Adapters: `@mix-space-lts/api-client/adaptors/axios`, `/adaptors/umi-request`, `/adaptors/fetch`.
|
|
276
276
|
|
|
277
277
|
---
|
|
278
278
|
|