@web-ts-toolkit/access-router-client 0.38.0 → 0.40.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 +48 -25
- package/index.d.mts +95 -60
- package/index.d.ts +95 -60
- package/index.js +605 -373
- package/index.mjs +605 -373
- package/llms.txt +9 -6
- package/package.json +6 -3
package/llms.txt
CHANGED
|
@@ -47,21 +47,24 @@ const grouped = await adapter.group(
|
|
|
47
47
|
- enabled caches are GET-only, identity-partitioned for credentials, and bounded to 100 LRU entries by default; caching remains disabled when `cacheTTL: 0`
|
|
48
48
|
- each lazy request can execute directly or in one group, never both or repeatedly; grouped requests require one effective `throwOnError` policy, run all callbacks, and expose `{}` per-entry headers
|
|
49
49
|
- remove data-service `includePermissions`, use string data sort, and call `countAdvanced(filter, config?)`; use the named filter escape hatches only for intentional dynamic/cast filters
|
|
50
|
+
- model create/update/upsert payloads default to `ModelMutationInput<T>` (`Partial<T>`), and subdocument create/update payloads default to `SubDocumentMutationInput<S>` (`Partial<S>` for object subdocuments). Use `createModelService<T, TCreateInput, TUpdateInput, TUpsertInput>(...)` or `subs<S, K, TCreateInput, TUpdateInput>(...)` when request schemas differ from response shapes. `ModelData<T>` is the direct-field data surface of a `Model<T>` with reserved wrapper method names omitted
|
|
50
51
|
- pass raw dynamic path values, reuse caller configs safely, and handle `MissingPersistenceIdentityError` when an existing projected model has no recoverable id
|
|
51
52
|
|
|
52
53
|
## Gotchas
|
|
53
54
|
|
|
54
|
-
- supports **browsers and Node** (maintainer decision, ARC-19). Bundle target is `es2022`; `engines.node: ">=22"`, `browserslist: ["
|
|
55
|
-
- `withCredentials: true` is the adapter default; in the browser this
|
|
56
|
-
- caching is disabled by default (`cacheTTL: 0`). When enabled, only GET requests with supported JSON/text semantics cache or deduplicate, custom transforms/serializers and cancellation-sensitive requests bypass caching, and the default LRU capacity is 100 entries.
|
|
55
|
+
- supports **browsers and Node** (maintainer decision, ARC-19). Bundle target is `es2022`; `engines.node: ">=22"`, `browserslist: ["chrome >= 94", "edge >= 94", "firefox >= 93", "safari >= 16"]`. The source imports no Node built-ins; the cache `unref()` guard is feature-detected and a no-op in browsers.
|
|
56
|
+
- `withCredentials: true` is the adapter default; in the browser this permits cookie credentials when CORS and cookie policy allow them. `Authorization`, proxy authorization, API-key style headers, and Node `Cookie` headers are explicit Axios config values; `withCredentials` does not create them. Credentialed caching still requires an explicit `cachePartition` token so one identity cannot receive another's cached response.
|
|
57
|
+
- caching is disabled by default (`cacheTTL: 0`). `cacheTTL` is milliseconds. When enabled, only GET requests with supported JSON/text semantics cache or deduplicate, custom transforms/serializers and cancellation-sensitive requests bypass caching, and the default LRU capacity is 100 entries.
|
|
57
58
|
- `axios` is a regular runtime dependency (declared in `package.json` `dependencies`); an installed consumer does not need to add axios separately. Use it as a peer only if you intentionally dedupe against an existing axios install.
|
|
58
59
|
- service methods return lazy requests; they do not execute until `await`, `.then()`, `.exec()`, etc.
|
|
59
|
-
- `adapter.group(...)` only batches lazy requests from
|
|
60
|
+
- `adapter.group(...)` only batches service lazy requests from the same adapter, not raw Axios calls or consumer-created `wrapLazyPromise(...)` values
|
|
60
61
|
- grouped requests must have one effective `throwOnError` policy after per-call/service/adapter precedence; mixed policies reject before dispatch. Non-throwing groups return all partial-failure entries. Throwing groups invoke every executed entry callback once, then reject with the first failed entry's `ServiceError`. Group entry `headers` are `{}` because root responses do not carry per-operation headers
|
|
61
62
|
- the client `basePath` is relative to the adapter `baseURL`, not the full server path
|
|
62
63
|
- match `queryPath`/`mutationPath` to the server-side `queryRouteSegment` and mutation route configuration
|
|
63
64
|
- each dynamic URL path segment (identifiers, `distinct` field, subdocument `id`/`sub`/`subId`, wrapper `pathParams` values) is `encodeURIComponent`-encoded exactly once; already-encoded inputs are re-encoded so a single server-side decode returns the literal input
|
|
64
65
|
- caller-owned `axiosRequestConfig`, headers (including `AxiosHeaders` instances), and wrapper default configs are never mutated by service methods or wrap helpers; the same config object can be reused across many requests without acquiring hidden cache controls or `params`
|
|
66
|
+
- `Model<T>` reserves public wrapper member names (`save`, `reset`, `set`, `get`, `assign`, `toObject`, `toJSON`, etc.) for methods on direct property access; document fields with those names remain available through `get(...)`, `set(...)`, `assign(...)`, and `toObject()`
|
|
67
|
+
- multiple overlapping `save()` calls on the same `Model<T>` instance are serialized in call order; a queued save snapshots dirty paths only after the previous save finishes reconciling
|
|
65
68
|
- the client request contract mirrors the sibling `@web-ts-toolkit/access-router` server:
|
|
66
69
|
- `distinctAdvanced(field, filter, ...)` sends `{ filter }` as the request body, not the bare conditions, so the server honors the filter
|
|
67
70
|
- `DataService<T>` does not advertise `includePermissions` — the data routers do not parse `include_permissions`; data records are returned without `_permissions`
|
|
@@ -75,7 +78,7 @@ const grouped = await adapter.group(
|
|
|
75
78
|
- imports are named-only (`import { createAdapter }`); there is no default export
|
|
76
79
|
- the public export surface is locked by `access-router-client.exports.unit.test.ts`. Only these names are part of the supported root API:
|
|
77
80
|
- runtime values: `createAdapter`, `ModelService`, `DataService`, `Service`, `ServiceError`, `MissingPersistenceIdentityError`, `Model`, `CustomHeaders`, `wrapLazyPromise`, `replaceItemById`, `removeItemById`
|
|
78
|
-
- type/interface exports (named via `import type`): `AdapterOptions`, `ModelServiceOptions`, `DataServiceOptions`, `CacheController`, `CachePartitioner`, `Response`, `SuccessResult`, `FailureResult`, `ModelResponse`, `ArrayModelResponse`, `ListModelResponse`, `DataResponse`, `ArrayDataResponse`, `ListDataResponse`, `SubDocumentResponse`, `SubDocumentListResponse`, `Document`, `Projection`, `KeyValueProjection`, `SelectedKeys`, `SelectedShape`, `ResolvedSelectedShape`, `Sort`, `SortOrder`, `FilterQuery`, `DottedPathFilter`, `ServerSideCast`, `Populate`, `PopulateAccess`, `Include`, `Task`, `SubQueryOptions`, `WrapOptions`, `ResultError`, `ResponseCallback`, `AdditionalReqConfig`, `Defaults`, `DataDefaults`, `LazyRequest`, `ModelRequest`, `DataRequest`, `ModelPromiseMeta`, `DataPromiseMeta`, `RootModelQueryMeta`, `RootDataQueryMeta`, `RootQueryMeta`, `ListArgs`, `ListOptions`, `ListAdvancedArgs`, `ListAdvancedOptions`, `ReadOptions`, `ReadAdvancedArgs`, `ReadAdvancedOptions`, `CreateOptions`, `CreateAdvancedArgs`, `CreateAdvancedOptions`, `UpdateOptions`, `UpdateAdvancedArgs`, `UpdateAdvancedOptions`, `UpsertOptions`, `UpsertAdvancedArgs`, `UpsertAdvancedOptions`, `DataListArgs`, `DataListOptions`, `DataListAdvancedArgs`, `DataListAdvancedOptions`, `DataReadOptions`, `DataReadAdvancedArgs`, `DataReadAdvancedOptions`
|
|
81
|
+
- type/interface exports (named via `import type`): `AdapterOptions`, `ModelServiceOptions`, `DataServiceOptions`, `CacheController`, `CachePartitioner`, `Response`, `SuccessResult`, `FailureResult`, `ModelResponse`, `ArrayModelResponse`, `ListModelResponse`, `ModelData`, `DataResponse`, `ArrayDataResponse`, `ListDataResponse`, `SubDocumentResponse`, `SubDocumentListResponse`, `Document`, `ModelMutationInput`, `SubDocumentMutationInput`, `Projection`, `KeyValueProjection`, `SelectedKeys`, `SelectedShape`, `ResolvedSelectedShape`, `Sort`, `SortOrder`, `FilterQuery`, `DottedPathFilter`, `ServerSideCast`, `Populate`, `PopulateAccess`, `Include`, `Task`, `SubQueryOptions`, `WrapOptions`, `ResultError`, `ResponseCallback`, `AdditionalReqConfig`, `Defaults`, `DataDefaults`, `LazyRequest`, `ModelRequest`, `DataRequest`, `ModelPromiseMeta`, `DataPromiseMeta`, `RootModelQueryMeta`, `RootDataQueryMeta`, `RootQueryMeta`, `ListArgs`, `ListOptions`, `ListAdvancedArgs`, `ListAdvancedOptions`, `ReadOptions`, `ReadAdvancedArgs`, `ReadAdvancedOptions`, `CreateOptions`, `CreateAdvancedArgs`, `CreateAdvancedOptions`, `UpdateOptions`, `UpdateAdvancedArgs`, `UpdateAdvancedOptions`, `UpsertOptions`, `UpsertAdvancedArgs`, `UpsertAdvancedOptions`, `DataListArgs`, `DataListOptions`, `DataListAdvancedArgs`, `DataListAdvancedOptions`, `DataReadOptions`, `DataReadAdvancedArgs`, `DataReadAdvancedOptions`
|
|
79
82
|
|
|
80
83
|
Model `create(...)` and `createAdvanced(...)` preserve cardinality: object input returns `ModelResponse<T>`; array input returns `ArrayModelResponse<T>`, even for one item.
|
|
81
84
|
- any name not listed above is implementation-internal and must not be relied on. Configure caching through `AdapterOptions` (`cacheTTL`, `cachePartition`, `cacheCapacity`); control an existing cache through the adapter's `clearCache()` and `disposeCache()` methods; configure `throwOnError` per-service or per-call rather than reaching for `applyResponseCallbacks` directly.
|
|
@@ -84,4 +87,4 @@ Model `create(...)` and `createAdvanced(...)` preserve cardinality: object input
|
|
|
84
87
|
|
|
85
88
|
- README: installation, quickstart, main exports, browser+Node runtime matrix
|
|
86
89
|
- website (not packed into the npm tarball; use the live URLs after install): full documentation online at https://web-ts-toolkit.pages.dev/docs/packages/access-router-client (adapter, services, model, typing and errors)
|
|
87
|
-
- `pnpm --filter @web-ts-toolkit/access-router-client test:browser-smoke`: jsdom+Vite
|
|
90
|
+
- `pnpm --filter @web-ts-toolkit/access-router-client test:browser-smoke`: jsdom+Vite smoke test that imports the built bundle; this is not a real-browser engine/version gate
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@web-ts-toolkit/access-router-client",
|
|
3
3
|
"description": "Typed client utilities for @web-ts-toolkit/access-router APIs",
|
|
4
4
|
"homepage": "https://web-ts-toolkit.pages.dev/docs/packages/access-router-client",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.40.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"keywords": [
|
|
8
8
|
"axios",
|
|
@@ -30,10 +30,13 @@
|
|
|
30
30
|
"node": ">=22"
|
|
31
31
|
},
|
|
32
32
|
"browserslist": [
|
|
33
|
-
"
|
|
33
|
+
"chrome >= 94",
|
|
34
|
+
"edge >= 94",
|
|
35
|
+
"firefox >= 93",
|
|
36
|
+
"safari >= 16"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@web-ts-toolkit/utils": "0.
|
|
39
|
+
"@web-ts-toolkit/utils": "0.40.0",
|
|
37
40
|
"axios": "^1.18.1"
|
|
38
41
|
},
|
|
39
42
|
"files": [
|