@cratestack/api 0.5.2 → 0.6.1

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.
Files changed (43) hide show
  1. package/README.md +36 -39
  2. package/dist/adapter-rtk.d.ts +2 -0
  3. package/dist/adapter-rtk.d.ts.map +1 -0
  4. package/dist/adapter-rtk.js +2 -0
  5. package/dist/adapter-rtk.js.map +1 -0
  6. package/dist/adapter-tanstack-query.d.ts +2 -0
  7. package/dist/adapter-tanstack-query.d.ts.map +1 -0
  8. package/dist/adapter-tanstack-query.js +2 -0
  9. package/dist/adapter-tanstack-query.js.map +1 -0
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +10 -3
  13. package/dist/index.js.map +1 -1
  14. package/dist/runtime-axios.d.ts +2 -0
  15. package/dist/runtime-axios.d.ts.map +1 -0
  16. package/dist/runtime-axios.js +2 -0
  17. package/dist/runtime-axios.js.map +1 -0
  18. package/dist/runtime-fetch.d.ts +2 -0
  19. package/dist/runtime-fetch.d.ts.map +1 -0
  20. package/dist/runtime-fetch.js +2 -0
  21. package/dist/runtime-fetch.js.map +1 -0
  22. package/dist/validator-yup.d.ts +2 -0
  23. package/dist/validator-yup.d.ts.map +1 -0
  24. package/dist/validator-yup.js +2 -0
  25. package/dist/validator-yup.js.map +1 -0
  26. package/dist/validator-zod.d.ts +2 -0
  27. package/dist/validator-zod.d.ts.map +1 -0
  28. package/dist/validator-zod.js +2 -0
  29. package/dist/validator-zod.js.map +1 -0
  30. package/package.json +44 -3
  31. package/LICENSE +0 -21
  32. package/dist/batch-link.d.ts +0 -51
  33. package/dist/batch-link.d.ts.map +0 -1
  34. package/dist/batch-link.js +0 -187
  35. package/dist/batch-link.js.map +0 -1
  36. package/dist/logger-link.d.ts +0 -9
  37. package/dist/logger-link.d.ts.map +0 -1
  38. package/dist/logger-link.js +0 -22
  39. package/dist/logger-link.js.map +0 -1
  40. package/dist/types.d.ts +0 -51
  41. package/dist/types.d.ts.map +0 -1
  42. package/dist/types.js +0 -11
  43. package/dist/types.js.map +0 -1
package/README.md CHANGED
@@ -1,20 +1,30 @@
1
1
  # @cratestack/api
2
2
 
3
- Composable links for CrateStack's generated TypeScript RPC client (`transport rpc` schemas).
4
-
5
- Every `cratestack generate-typescript` project ships a `links?: RpcLink[]` option on
6
- `CratestackRpcClientOptions` ([issue #182](https://github.com/cratestack/cratestack/issues/182)) —
7
- an ordered chain of interceptors, each wrapping the next, terminating in the real network call.
8
- This package ships two of them:
9
-
10
- - **`createBatchLink()`** — a [batshit](https://github.com/yornaath/batshit)-style automatic batch
11
- scheduler. Multiple unary calls issued in the same tick collapse into a single `POST /rpc/batch`
12
- request instead of firing one `POST /rpc/{op_id}` each.
13
- - **`createLoggerLink()`** — a small reference link that logs each call's op id, outcome, and
14
- duration.
3
+ Compat umbrella over the split `@cratestack/*` npm family for CrateStack's generated TypeScript
4
+ RPC client (`transport rpc` schemas). If you're starting fresh, prefer depending on the individual
5
+ packages below directly — smaller install, no unused peer dependencies. `@cratestack/api` exists
6
+ so existing `import { createBatchLink } from "@cratestack/api"` code keeps working unchanged.
7
+
8
+ ## The split
9
+
10
+ | Package | What it does |
11
+ | --- | --- |
12
+ | [`@cratestack/ts-types`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-ts-types) | Shared `RpcLink`/wire-frame interfaces. Types only — no runtime code. |
13
+ | [`@cratestack/link-batch`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-link-batch) | Automatic batch-scheduler `RpcLink`. |
14
+ | [`@cratestack/link-logger`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-link-logger) | Reference logging `RpcLink`. |
15
+ | [`@cratestack/runtime-fetch`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-runtime-fetch) | `typeof fetch` transport with an optional timeout. |
16
+ | [`@cratestack/runtime-axios`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-runtime-axios) | `typeof fetch` transport backed by axios. |
17
+ | [`@cratestack/validator-zod`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-validator-zod) | Input-validating `RpcLink`, zod schemas. |
18
+ | [`@cratestack/validator-yup`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-validator-yup) | Input-validating `RpcLink`, yup schemas. |
19
+ | [`@cratestack/adapter-tanstack-query`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-adapter-tanstack-query) | Generic TanStack Query option builders. |
20
+ | [`@cratestack/adapter-rtk`](https://github.com/cratestack/cratestack/tree/main/packages/cratestack-adapter-rtk) | RTK Query `BaseQueryFn` adapter. |
15
21
 
16
22
  ## Usage
17
23
 
24
+ The root import is unchanged from before the split — it re-exports exactly `ts-types` +
25
+ `link-batch` + `link-logger`, so importing it never pulls in zod/yup/axios/tanstack-query/rtk as
26
+ implicit peer dependencies:
27
+
18
28
  ```ts
19
29
  import { createBatchLink, createLoggerLink } from "@cratestack/api";
20
30
  import { CratestackRpcRuntime } from "./generated/runtime"; // your project's generated client
@@ -32,33 +42,20 @@ const [a, b, c] = await Promise.all([
32
42
  ]);
33
43
  ```
34
44
 
35
- Order matters: a link's `next` reruns everything below it (the real fetch and any links declared
36
- after it), never just the terminal fetch. Put `createBatchLink()` last (closest to the network) if
37
- you also want a logger or retry link to see the real per-call outcome; put it first if you want
38
- logging/retry to apply to the *batched* request instead.
39
-
40
- `stream()` calls bypass the chain entirely — a link that wants to inspect/retry a response would
41
- need to clone a streamed body, which defeats streaming.
45
+ Everything else added since the split is available as a named subpath — each pulls in only its
46
+ own peer dependency, not every package's:
42
47
 
43
- ## Batching semantics
44
-
45
- - **Window**: defaults to `queueMicrotask` — calls fired synchronously in the same tick (e.g.
46
- inside `Promise.all`) collapse. Pass `windowMs` to widen the window across ticks.
47
- - **Dedup**: only calls sharing an explicit `idempotencyKey` are collapsed into one request frame
48
- by default — that's already the caller's own signal that the call is a safe repeat. Calls with
49
- no idempotency key are never auto-collapsed, since the server does no dedup of its own and
50
- silently merging two textually-identical but unmarked mutations would be unsafe. Pass a custom
51
- `dedupe` for full value-based collapsing, or `() => null` to disable dedup and only batch.
52
- - **Correlation**: results are fanned back out by matching each response frame's `id`, not array
53
- position — the server's `/rpc/batch` contract already guarantees order (see
54
- `docs/design/rpc-transport.md` §3.2), but id-based matching is strictly more robust and mirrors
55
- the repo's own Rust client-side batch debouncer (`examples/rpc-batch-debounce`).
48
+ ```ts
49
+ import { createFetchRuntime } from "@cratestack/api/runtime-fetch";
50
+ import { createAxiosRuntime } from "@cratestack/api/runtime-axios";
51
+ import { createZodValidatorLink } from "@cratestack/api/validator-zod";
52
+ import { createYupValidatorLink } from "@cratestack/api/validator-yup";
53
+ import { rpcQueryOptions, rpcMutationOptions } from "@cratestack/api/adapter-tanstack-query";
54
+ import { createRpcBaseQuery } from "@cratestack/api/adapter-rtk";
55
+ ```
56
56
 
57
- ### Known limitations
57
+ See each package's own README (linked in the table above) for its full API and semantics.
58
58
 
59
- - The synthesized `/rpc/batch` request reuses the **first** queued call's `headers`/`fetchFn`/
60
- `codec` for the whole flush — per-call custom headers on later calls in the same window are not
61
- applied to the aggregate request. Pass shared headers via the runtime's own `headers` option
62
- rather than per-call `CratestackRpcCallOptions.headers` when using this link.
63
- - Aborting an individual call's `AbortSignal` only cancels it if its batch hasn't been sent yet —
64
- it does not cancel an in-flight `/rpc/batch` request.
59
+ Order matters: a link's `next` reruns everything below it (the real fetch and any links declared
60
+ after it), never just the terminal fetch. `stream()` calls bypass the chain entirely — a link that
61
+ wants to inspect/retry a response would need to clone a streamed body, which defeats streaming.
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/adapter-rtk";
2
+ //# sourceMappingURL=adapter-rtk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-rtk.d.ts","sourceRoot":"","sources":["../src/adapter-rtk.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/adapter-rtk";
2
+ //# sourceMappingURL=adapter-rtk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-rtk.js","sourceRoot":"","sources":["../src/adapter-rtk.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/adapter-tanstack-query";
2
+ //# sourceMappingURL=adapter-tanstack-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-tanstack-query.d.ts","sourceRoot":"","sources":["../src/adapter-tanstack-query.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/adapter-tanstack-query";
2
+ //# sourceMappingURL=adapter-tanstack-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-tanstack-query.js","sourceRoot":"","sources":["../src/adapter-tanstack-query.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./types.js";
2
- export * from "./batch-link.js";
3
- export * from "./logger-link.js";
1
+ export * from "@cratestack/ts-types";
2
+ export * from "@cratestack/link-batch";
3
+ export * from "@cratestack/link-logger";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,11 @@
1
- export * from "./types.js";
2
- export * from "./batch-link.js";
3
- export * from "./logger-link.js";
1
+ // @cratestack/api is now a thin compat re-export over the split
2
+ // @cratestack/{ts-types,link-*,runtime-*,validator-*,adapter-*} family —
3
+ // see README.md. The root entry point only re-exports the three pieces
4
+ // this package originally shipped (no new peer dependency is required
5
+ // just to `import from "@cratestack/api"`); everything net-new is a
6
+ // named subpath import instead, so e.g. zod/yup/axios/tanstack-query/
7
+ // rtk never become implicit peer requirements of the root import.
8
+ export * from "@cratestack/ts-types";
9
+ export * from "@cratestack/link-batch";
10
+ export * from "@cratestack/link-logger";
4
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,kEAAkE;AAClE,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/runtime-axios";
2
+ //# sourceMappingURL=runtime-axios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-axios.d.ts","sourceRoot":"","sources":["../src/runtime-axios.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/runtime-axios";
2
+ //# sourceMappingURL=runtime-axios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-axios.js","sourceRoot":"","sources":["../src/runtime-axios.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/runtime-fetch";
2
+ //# sourceMappingURL=runtime-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-fetch.d.ts","sourceRoot":"","sources":["../src/runtime-fetch.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/runtime-fetch";
2
+ //# sourceMappingURL=runtime-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-fetch.js","sourceRoot":"","sources":["../src/runtime-fetch.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/validator-yup";
2
+ //# sourceMappingURL=validator-yup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator-yup.d.ts","sourceRoot":"","sources":["../src/validator-yup.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/validator-yup";
2
+ //# sourceMappingURL=validator-yup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator-yup.js","sourceRoot":"","sources":["../src/validator-yup.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/validator-zod";
2
+ //# sourceMappingURL=validator-zod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator-zod.d.ts","sourceRoot":"","sources":["../src/validator-zod.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@cratestack/validator-zod";
2
+ //# sourceMappingURL=validator-zod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator-zod.js","sourceRoot":"","sources":["../src/validator-zod.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cratestack/api",
3
- "version": "0.5.2",
4
- "description": "Composable links for CrateStack's generated TypeScript RPC client — batching, logging, and more.",
3
+ "version": "0.6.1",
4
+ "description": "Compat umbrella over the split @cratestack/{ts-types,link-*,runtime-*,validator-*,adapter-*} family for CrateStack's generated TypeScript RPC client — batching, logging, and more.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,12 +12,37 @@
12
12
  "bugs": "https://github.com/cratestack/cratestack/issues",
13
13
  "keywords": ["cratestack", "cstack", "rpc", "batching", "trpc-links"],
14
14
  "type": "module",
15
+ "sideEffects": false,
15
16
  "main": "./dist/index.js",
16
17
  "types": "./dist/index.d.ts",
17
18
  "exports": {
18
19
  ".": {
19
20
  "types": "./dist/index.d.ts",
20
21
  "import": "./dist/index.js"
22
+ },
23
+ "./runtime-fetch": {
24
+ "types": "./dist/runtime-fetch.d.ts",
25
+ "import": "./dist/runtime-fetch.js"
26
+ },
27
+ "./runtime-axios": {
28
+ "types": "./dist/runtime-axios.d.ts",
29
+ "import": "./dist/runtime-axios.js"
30
+ },
31
+ "./validator-zod": {
32
+ "types": "./dist/validator-zod.d.ts",
33
+ "import": "./dist/validator-zod.js"
34
+ },
35
+ "./validator-yup": {
36
+ "types": "./dist/validator-yup.d.ts",
37
+ "import": "./dist/validator-yup.js"
38
+ },
39
+ "./adapter-tanstack-query": {
40
+ "types": "./dist/adapter-tanstack-query.d.ts",
41
+ "import": "./dist/adapter-tanstack-query.js"
42
+ },
43
+ "./adapter-rtk": {
44
+ "types": "./dist/adapter-rtk.d.ts",
45
+ "import": "./dist/adapter-rtk.js"
21
46
  }
22
47
  },
23
48
  "files": ["dist", "README.md", "LICENSE"],
@@ -26,9 +51,25 @@
26
51
  "test": "vitest run",
27
52
  "lint": "biome check ."
28
53
  },
54
+ "dependencies": {
55
+ "@cratestack/ts-types": "0.6.1",
56
+ "@cratestack/link-batch": "0.6.1",
57
+ "@cratestack/link-logger": "0.6.1",
58
+ "@cratestack/runtime-fetch": "0.6.1",
59
+ "@cratestack/runtime-axios": "0.6.1",
60
+ "@cratestack/validator-zod": "0.6.1",
61
+ "@cratestack/validator-yup": "0.6.1",
62
+ "@cratestack/adapter-tanstack-query": "0.6.1",
63
+ "@cratestack/adapter-rtk": "0.6.1"
64
+ },
29
65
  "devDependencies": {
66
+ "@reduxjs/toolkit": "^2.0.0",
67
+ "@tanstack/query-core": "^5.0.0",
68
+ "axios": "^1.7.0",
30
69
  "typescript": "^5.7.0",
31
- "vitest": "^3.0.0"
70
+ "vitest": "^3.0.0",
71
+ "yup": "^1.4.0",
72
+ "zod": "^4.0.0"
32
73
  },
33
74
  "engines": {
34
75
  "node": ">=18"
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Stephane Segning
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,51 +0,0 @@
1
- import type { RpcLink, RpcLinkRequest } from "./types.js";
2
- export interface BatchLinkOptions {
3
- /** Scheduling window. Omitted (default) uses `queueMicrotask` — calls
4
- * fired synchronously in the same tick (e.g. inside `Promise.all`)
5
- * collapse into one `/rpc/batch` request. Pass a millisecond value to
6
- * widen the window across ticks (e.g. debounce bursts from unrelated
7
- * components). */
8
- windowMs?: number;
9
- /** Maximum requests per flushed `/rpc/batch` call. Default: unbounded
10
- * — the server enforces no size limit either (see
11
- * `docs/design/rpc-transport.md` §3.2), but a huge fan-in may still
12
- * be worth capping client-side. */
13
- maxBatchSize?: number;
14
- /** Returns a dedupe key for a queued call, or `null` to never
15
- * collapse it with anything else. Two calls in the same flush that
16
- * return the same non-null key become ONE `/rpc/batch` frame, and
17
- * every caller resolves from that single result.
18
- *
19
- * Default: only collapse calls that share an explicit
20
- * `idempotencyKey` — that's already the caller's own signal that the
21
- * call is safe to treat as a repeat. Calls with no idempotency key
22
- * are never auto-collapsed, since the server does no dedup of its
23
- * own and silently merging two textually-identical but unmarked
24
- * mutations would be unsafe. Pass a custom `dedupe` for full
25
- * value-based batshit-style collapsing (e.g.
26
- * `req => \`${req.opId}:${JSON.stringify(req.input)}\``), or
27
- * `() => null` to disable dedup entirely and only batch.
28
- */
29
- dedupe?: (request: RpcLinkRequest) => string | null;
30
- }
31
- /** A batshit-style (github.com/yornaath/batshit) automatic batch
32
- * scheduler, shipped as an `RpcLink` (issue #182's composition
33
- * mechanism) rather than a `fetch` override — so it composes with a
34
- * logger, retry, or auth-refresh link instead of clobbering them.
35
- *
36
- * Terminal in practice: for `kind: "unary"` calls it never invokes
37
- * `next` — it queues the call and later performs its own single
38
- * `POST /rpc/batch`. An explicit `runtime.batch()` call (`kind:
39
- * "batch"`) passes straight through via `next`, since it's already
40
- * the shape this link would otherwise build.
41
- *
42
- * Known limitation: the synthesized `/rpc/batch` request reuses the
43
- * first queued call's `headers`/`fetchFn`/`codec` for the whole flush
44
- * — per-call custom headers on later calls in the same window are not
45
- * applied to the aggregate request. Pass shared headers via the
46
- * runtime's own `headers` option rather than per-call
47
- * `CratestackRpcCallOptions.headers` when using this link. Similarly,
48
- * aborting an individual call's `AbortSignal` only cancels it if the
49
- * flush hasn't been sent yet — it does not cancel an in-flight batch. */
50
- export declare function createBatchLink(options?: BatchLinkOptions): RpcLink;
51
- //# sourceMappingURL=batch-link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batch-link.d.ts","sourceRoot":"","sources":["../src/batch-link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,OAAO,EACP,cAAc,EAIf,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B;;;;uBAImB;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;wCAGoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,MAAM,GAAG,IAAI,CAAC;CACrD;AAgBD;;;;;;;;;;;;;;;;;;0EAkB0E;AAC1E,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAyGvE"}
@@ -1,187 +0,0 @@
1
- const defaultDedupe = (request) => request.idempotencyKey !== undefined ? `idem:${request.idempotencyKey}` : null;
2
- /** A batshit-style (github.com/yornaath/batshit) automatic batch
3
- * scheduler, shipped as an `RpcLink` (issue #182's composition
4
- * mechanism) rather than a `fetch` override — so it composes with a
5
- * logger, retry, or auth-refresh link instead of clobbering them.
6
- *
7
- * Terminal in practice: for `kind: "unary"` calls it never invokes
8
- * `next` — it queues the call and later performs its own single
9
- * `POST /rpc/batch`. An explicit `runtime.batch()` call (`kind:
10
- * "batch"`) passes straight through via `next`, since it's already
11
- * the shape this link would otherwise build.
12
- *
13
- * Known limitation: the synthesized `/rpc/batch` request reuses the
14
- * first queued call's `headers`/`fetchFn`/`codec` for the whole flush
15
- * — per-call custom headers on later calls in the same window are not
16
- * applied to the aggregate request. Pass shared headers via the
17
- * runtime's own `headers` option rather than per-call
18
- * `CratestackRpcCallOptions.headers` when using this link. Similarly,
19
- * aborting an individual call's `AbortSignal` only cancels it if the
20
- * flush hasn't been sent yet — it does not cancel an in-flight batch. */
21
- export function createBatchLink(options = {}) {
22
- const maxBatchSize = options.maxBatchSize ?? Number.POSITIVE_INFINITY;
23
- const dedupe = options.dedupe ?? defaultDedupe;
24
- const windowMs = options.windowMs;
25
- const queue = [];
26
- let flushScheduled = false;
27
- function scheduleFlush() {
28
- if (flushScheduled) {
29
- return;
30
- }
31
- flushScheduled = true;
32
- const run = () => {
33
- flushScheduled = false;
34
- flush();
35
- };
36
- if (windowMs === undefined) {
37
- queueMicrotask(run);
38
- }
39
- else {
40
- setTimeout(run, windowMs);
41
- }
42
- }
43
- function flush() {
44
- if (queue.length === 0) {
45
- return;
46
- }
47
- const size = Math.max(1, maxBatchSize);
48
- const batch = queue.splice(0, size);
49
- if (queue.length > 0) {
50
- scheduleFlush();
51
- }
52
- void runBatch(batch);
53
- }
54
- async function runBatch(entries) {
55
- const groups = groupByDedupeKey(entries, dedupe);
56
- const leader = entries[0].request;
57
- const requests = groups.map((group, id) => {
58
- const request = group.entries[0].request;
59
- const frame = { id, op: request.opId, input: request.input };
60
- if (request.idempotencyKey !== undefined) {
61
- frame.idem = request.idempotencyKey;
62
- }
63
- return frame;
64
- });
65
- try {
66
- const response = await leader.fetchFn(leader.urls.batch(), {
67
- method: "POST",
68
- headers: leader.headers,
69
- body: leader.codec.encode(requests),
70
- signal: null,
71
- });
72
- if (!response.ok) {
73
- const bytes = new Uint8Array(await response.arrayBuffer().catch(() => new ArrayBuffer(0)));
74
- for (const group of groups) {
75
- for (const entry of group.entries) {
76
- entry.resolve({ response: new Response(bytes, { status: response.status }) });
77
- }
78
- }
79
- return;
80
- }
81
- const bytes = new Uint8Array(await response.arrayBuffer());
82
- const frames = leader.codec.decode(bytes);
83
- resolveGroups(groups, frames);
84
- }
85
- catch (error) {
86
- for (const group of groups) {
87
- for (const entry of group.entries) {
88
- entry.reject(error);
89
- }
90
- }
91
- }
92
- }
93
- return async (request, next) => {
94
- if (request.kind === "batch") {
95
- return next(request);
96
- }
97
- return new Promise((resolve, reject) => {
98
- if (request.signal?.aborted) {
99
- reject(request.signal.reason ?? new Error("aborted"));
100
- return;
101
- }
102
- const entry = { request, resolve, reject };
103
- request.signal?.addEventListener("abort", () => {
104
- const index = queue.indexOf(entry);
105
- // No-op once already flushed — cancelling one call after its
106
- // batch has been sent does not cancel the network request.
107
- if (index !== -1) {
108
- queue.splice(index, 1);
109
- reject(request.signal.reason ?? new Error("aborted"));
110
- }
111
- });
112
- queue.push(entry);
113
- scheduleFlush();
114
- });
115
- };
116
- }
117
- function groupByDedupeKey(entries, dedupe) {
118
- const groups = [];
119
- const indexByKey = new Map();
120
- for (const entry of entries) {
121
- const key = dedupe(entry.request);
122
- if (key === null) {
123
- groups.push({ key: null, entries: [entry] });
124
- continue;
125
- }
126
- const existingIndex = indexByKey.get(key);
127
- if (existingIndex === undefined) {
128
- indexByKey.set(key, groups.length);
129
- groups.push({ key, entries: [entry] });
130
- }
131
- else {
132
- groups[existingIndex].entries.push(entry);
133
- }
134
- }
135
- return groups;
136
- }
137
- function resolveGroups(groups, frames) {
138
- // Correlate by `id`, not array position — the server contract
139
- // guarantees order (docs/design/rpc-transport.md §3.2), but matching
140
- // by id is strictly more robust and is the pattern the repo's own
141
- // Rust client-side batch debouncer already establishes
142
- // (examples/rpc-batch-debounce/src/lib.rs's `responders` map).
143
- const frameById = new Map(frames.map((frame) => [frame.id, frame]));
144
- groups.forEach((group, id) => {
145
- const frame = frameById.get(id);
146
- if (!frame) {
147
- const error = new Error(`batch response is missing frame id ${id}`);
148
- for (const entry of group.entries) {
149
- entry.reject(error);
150
- }
151
- return;
152
- }
153
- const hasError = frame.error !== undefined;
154
- for (const entry of group.entries) {
155
- if (!hasError && frame.output === undefined) {
156
- // Mirrors the unary path's `response.status === 204` shortcut
157
- // (void-returning calls resolve `undefined`, not a decoded null).
158
- entry.resolve({ response: new Response(null, { status: 204 }) });
159
- continue;
160
- }
161
- const body = hasError ? frame.error : frame.output;
162
- entry.resolve({
163
- response: new Response(entry.request.codec.encode(body), {
164
- status: hasError ? errorStatus(frame.error.code) : 200,
165
- }),
166
- });
167
- }
168
- });
169
- }
170
- function errorStatus(code) {
171
- switch (code) {
172
- case "invalid_argument":
173
- case "failed_precondition":
174
- return 400;
175
- case "unauthenticated":
176
- return 401;
177
- case "permission_denied":
178
- return 403;
179
- case "not_found":
180
- return 404;
181
- case "conflict":
182
- return 409;
183
- default:
184
- return 500;
185
- }
186
- }
187
- //# sourceMappingURL=batch-link.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batch-link.js","sourceRoot":"","sources":["../src/batch-link.ts"],"names":[],"mappings":"AAkDA,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAiB,EAAE,CAC/D,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAEjF;;;;;;;;;;;;;;;;;;0EAkB0E;AAC1E,MAAM,UAAU,eAAe,CAAC,UAA4B,EAAE;IAC5D,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,iBAAiB,CAAC;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAElC,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,SAAS,aAAa;QACpB,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,cAAc,GAAG,IAAI,CAAC;QACtB,MAAM,GAAG,GAAG,GAAG,EAAE;YACf,cAAc,GAAG,KAAK,CAAC;YACvB,KAAK,EAAE,CAAC;QACV,CAAC,CAAC;QACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,cAAc,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACH,CA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C,OAAO,EAAE,CAAC;YAClC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC5C,8DAA8D;gBAC9D,kEAAkE;gBAClE,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;gBACjE,SAAS;YACX,CAAC;YACD,MAAM,IAAI,GAA2B,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;YAC3E,KAAK,CAAC,OAAO,CAAC;gBACZ,QAAQ,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBACvD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,KAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG;iBACxD,CAAC;aACH,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,kBAAkB,CAAC;QACxB,KAAK,qBAAqB;YACxB,OAAO,GAAG,CAAC;QACb,KAAK,iBAAiB;YACpB,OAAO,GAAG,CAAC;QACb,KAAK,mBAAmB;YACtB,OAAO,GAAG,CAAC;QACb,KAAK,WAAW;YACd,OAAO,GAAG,CAAC;QACb,KAAK,UAAU;YACb,OAAO,GAAG,CAAC;QACb;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { RpcLink } from "./types.js";
2
- /** Convenience copy of the reference link generated into every
3
- * `transport rpc` project's `src/links.ts` (issue #182). Not a
4
- * re-export — there's no shared import path between this package and
5
- * per-project generated code — kept in sync by this package's own
6
- * test coverage instead. Logs each call's kind, op id, outcome, and
7
- * duration; never touches `response.body`. */
8
- export declare function createLoggerLink(logger?: Pick<Console, "info" | "error">): RpcLink;
9
- //# sourceMappingURL=logger-link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-link.d.ts","sourceRoot":"","sources":["../src/logger-link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;+CAK+C;AAC/C,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAW,GAAG,OAAO,CAa3F"}
@@ -1,22 +0,0 @@
1
- /** Convenience copy of the reference link generated into every
2
- * `transport rpc` project's `src/links.ts` (issue #182). Not a
3
- * re-export — there's no shared import path between this package and
4
- * per-project generated code — kept in sync by this package's own
5
- * test coverage instead. Logs each call's kind, op id, outcome, and
6
- * duration; never touches `response.body`. */
7
- export function createLoggerLink(logger = console) {
8
- return async (request, next) => {
9
- const start = Date.now();
10
- logger.info(`[rpc] -> ${request.kind} ${request.opId}`);
11
- try {
12
- const result = await next(request);
13
- logger.info(`[rpc] <- ${request.opId} ${result.response.status} (${Date.now() - start}ms)`);
14
- return result;
15
- }
16
- catch (error) {
17
- logger.error(`[rpc] x ${request.opId} failed (${Date.now() - start}ms)`, error);
18
- throw error;
19
- }
20
- };
21
- }
22
- //# sourceMappingURL=logger-link.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-link.js","sourceRoot":"","sources":["../src/logger-link.ts"],"names":[],"mappings":"AAEA;;;;;+CAK+C;AAC/C,MAAM,UAAU,gBAAgB,CAAC,SAA0C,OAAO;IAChF,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,KAAK,CAAC,CAAC;YAC5F,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,WAAW,OAAO,CAAC,IAAI,YAAY,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,KAAK,EAAE,KAAK,CAAC,CAAC;YAChF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,51 +0,0 @@
1
- /** One request going through the chain — mirrors the generated
2
- * `RpcLinkRequest`. */
3
- export interface RpcLinkRequest {
4
- readonly kind: "unary" | "batch";
5
- readonly opId: string;
6
- readonly input: unknown;
7
- readonly headers: Headers;
8
- readonly signal: AbortSignal | null;
9
- readonly idempotencyKey?: string;
10
- readonly codec: CratestackRpcCodec;
11
- readonly fetchFn: typeof fetch;
12
- readonly urls: {
13
- unary(opId: string): string;
14
- batch(): string;
15
- };
16
- }
17
- /** Mirrors the generated `RpcLinkResponse`. */
18
- export interface RpcLinkResponse {
19
- readonly response: Response;
20
- }
21
- export type RpcLinkNext = (request: RpcLinkRequest) => Promise<RpcLinkResponse>;
22
- /** Mirrors the generated `RpcLink`. */
23
- export type RpcLink = (request: RpcLinkRequest, next: RpcLinkNext) => Promise<RpcLinkResponse>;
24
- /** Mirrors the generated `CratestackRpcCodec`. */
25
- export interface CratestackRpcCodec {
26
- readonly contentType: string;
27
- encode(value: unknown): BodyInit;
28
- decode(bytes: Uint8Array): unknown;
29
- }
30
- /** Wire shape of a single `/rpc/batch` request frame — mirrors the
31
- * generated `RpcRequest`. */
32
- export interface RpcRequest<I = unknown> {
33
- id: number;
34
- op: string;
35
- input: I;
36
- idem?: string;
37
- }
38
- /** Wire shape of a single `/rpc/batch` response frame — mirrors the
39
- * generated `RpcResponseFrame`. */
40
- export interface RpcResponseFrame<O = unknown> {
41
- id: number;
42
- output?: O;
43
- error?: RpcErrorBody;
44
- }
45
- /** Mirrors the generated `RpcErrorBody`. */
46
- export interface RpcErrorBody {
47
- code: string;
48
- message: string;
49
- details?: unknown;
50
- }
51
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA;wBACwB;AACxB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE;QACb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;QAC5B,KAAK,IAAI,MAAM,CAAC;KACjB,CAAC;CACH;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAEhF,uCAAuC;AACvC,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAE/F,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IACjC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC;CACpC;AAED;8BAC8B;AAC9B,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;oCACoC;AACpC,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
package/dist/types.js DELETED
@@ -1,11 +0,0 @@
1
- // Pinned local copies of the wire/link contract generated into every
2
- // CrateStack `transport rpc` project by
3
- // `crates/cratestack-client-typescript/templates/src/rpc-links.ts.j2` and
4
- // `rpc-runtime.ts.j2` (issue #182). Kept as plain interfaces/function
5
- // types deliberately — a generated project's `CratestackRpcRuntime` is a
6
- // per-project class with no shared import path, so this package can't
7
- // (and doesn't need to) import it; TypeScript's structural typing means
8
- // any object shaped like these types is assignable into a generated
9
- // client's `links` array, regardless of which project generated it.
10
- export {};
11
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,wCAAwC;AACxC,0EAA0E;AAC1E,sEAAsE;AACtE,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AACxE,oEAAoE;AACpE,oEAAoE"}