@web-ts-toolkit/access-router-client 0.4.0 → 0.6.0
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 +39 -12
- package/index.d.mts +240 -197
- package/index.d.ts +240 -197
- package/index.js +785 -909
- package/index.mjs +781 -906
- package/llms.txt +53 -0
- package/package.json +13 -11
package/llms.txt
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @web-ts-toolkit/access-router-client
|
|
2
|
+
|
|
3
|
+
Typed Axios-based client utilities for `@web-ts-toolkit/access-router` model routers, data routers, and root batch routes.
|
|
4
|
+
|
|
5
|
+
## Main Patterns
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createAdapter } from '@web-ts-toolkit/access-router-client';
|
|
9
|
+
|
|
10
|
+
const adapter = createAdapter({ baseURL: 'http://localhost:3000/api' });
|
|
11
|
+
|
|
12
|
+
const userService = adapter.createModelService<User>({
|
|
13
|
+
modelName: 'User',
|
|
14
|
+
basePath: 'users',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const user = await userService.read('user-id-1');
|
|
18
|
+
user.data.role = 'owner';
|
|
19
|
+
await user.data.save();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Data service for in-memory `access-router` data routes:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const fruitService = adapter.createDataService<Fruit>({
|
|
26
|
+
dataName: 'fruit',
|
|
27
|
+
basePath: 'fruit',
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Batch grouped lazy requests into one root round trip:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const grouped = await adapter.group(
|
|
35
|
+
userService.readAdvanced('user-id-1', { select: ['name'] }),
|
|
36
|
+
userService.countAdvanced({ role: 'admin' }),
|
|
37
|
+
);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Gotchas
|
|
41
|
+
|
|
42
|
+
- depends on `axios`; bring your own `axios`-compatible runtime
|
|
43
|
+
- service methods return lazy requests; they do not execute until `await`, `.then()`, `.exec()`, etc.
|
|
44
|
+
- `adapter.group(...)` only batches lazy requests from this client, not raw Axios calls
|
|
45
|
+
- the client `basePath` is relative to the adapter `baseURL`, not the full server path
|
|
46
|
+
- match `queryPath`/`mutationPath` to the server-side `queryRouteSegment` and mutation route configuration
|
|
47
|
+
- this package targets `@web-ts-toolkit/access-router` servers; plain Axios is simpler for non-access-router APIs
|
|
48
|
+
- imports are named-only (`import { createAdapter }`); there is no default export
|
|
49
|
+
|
|
50
|
+
## Pointers
|
|
51
|
+
|
|
52
|
+
- README: installation, quickstart, main exports
|
|
53
|
+
- website/docs/packages/access-router-client/: full documentation (adapter, services, model, typing and errors)
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-ts-toolkit/access-router-client",
|
|
3
|
-
"description": "
|
|
4
|
-
"
|
|
3
|
+
"description": "Typed client utilities for @web-ts-toolkit/access-router APIs",
|
|
4
|
+
"homepage": "https://web-ts-toolkit.pages.dev/docs/packages/access-router-client",
|
|
5
|
+
"version": "0.6.0",
|
|
6
|
+
"sideEffects": false,
|
|
5
7
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"axios",
|
|
9
|
+
"typescript",
|
|
10
|
+
"api-client",
|
|
11
|
+
"batching",
|
|
12
|
+
"access-router"
|
|
11
13
|
],
|
|
12
14
|
"main": "./index.js",
|
|
13
15
|
"module": "./index.mjs",
|
|
@@ -20,17 +22,17 @@
|
|
|
20
22
|
"default": "./index.js"
|
|
21
23
|
}
|
|
22
24
|
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20"
|
|
27
|
+
},
|
|
23
28
|
"dependencies": {
|
|
24
|
-
"@web-ts-toolkit/utils": "0.
|
|
29
|
+
"@web-ts-toolkit/utils": "0.6.0",
|
|
25
30
|
"axios": "^1.7.9"
|
|
26
31
|
},
|
|
27
32
|
"author": "Junmin Ahn",
|
|
28
33
|
"bugs": {
|
|
29
34
|
"url": "https://github.com/egose/web-ts-toolkit/issues"
|
|
30
35
|
},
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=20"
|
|
33
|
-
},
|
|
34
36
|
"license": "Apache-2.0",
|
|
35
37
|
"repository": {
|
|
36
38
|
"type": "git",
|