@cratestack/ts-types 0.5.2 → 0.6.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.
@@ -0,0 +1,30 @@
1
+ /** A cbor-seq body the walker can't make sense of at all — a reserved
2
+ * additional-info value, an indefinite-length string chunk of the
3
+ * wrong major type, a stray "break" byte with nothing open, etc. This
4
+ * is always a hard failure: unlike running out of bytes mid-item, more
5
+ * data arriving later can never fix it. */
6
+ export declare class MalformedCborSeqError extends Error {
7
+ }
8
+ /** Not enough bytes yet to know where the current item ends. Callers
9
+ * (`CborSeqBoundaryScanner.feedChunk`) catch this and just wait for
10
+ * the next chunk — it is never a real failure. */
11
+ export declare class NeedMoreBytesError extends Error {
12
+ }
13
+ /** Advance past exactly one top-level CBOR data item starting at
14
+ * `offset`, returning the offset just past it. Handles every major
15
+ * type, including indefinite-length byte strings, text strings,
16
+ * arrays, and maps (RFC 8949 §3.2.1-§3.2.3), recursively — the same
17
+ * structural cases `minicbor::Decoder::skip` covers on the Rust side.
18
+ * Never interprets a value — only walks structure. */
19
+ export declare function skipItem(bytes: Uint8Array, offset: number): number;
20
+ /** Read the argument (length/count/tag-number/value) encoded by
21
+ * `additionalInfo` starting at `offset`. `additionalInfo <= 23` means
22
+ * it's inline in the initial byte already consumed by the caller; 24,
23
+ * 25, 26, 27 mean 1, 2, 4, 8 big-endian bytes follow respectively.
24
+ * Exported so `./cbor-seq`'s tag-header detection can reuse the exact
25
+ * same argument-decoding logic rather than a second copy of it. */
26
+ export declare function readArgument(bytes: Uint8Array, offset: number, additionalInfo: number): {
27
+ value: number;
28
+ next: number;
29
+ };
30
+ //# sourceMappingURL=cbor-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-item.d.ts","sourceRoot":"","sources":["../src/cbor-item.ts"],"names":[],"mappings":"AAgBA;;;;4CAI4C;AAC5C,qBAAa,qBAAsB,SAAQ,KAAK;CAAG;AAEnD;;mDAEmD;AACnD,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD;;;;;uDAKuD;AACvD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAyClE;AAwED;;;;;oEAKoE;AACpE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA8BjC"}
@@ -0,0 +1,169 @@
1
+ // Pinned local copy of the low-level single-CBOR-item structural walker
2
+ // generated into every CrateStack `transport rpc` project by
3
+ // `crates/cratestack-client-typescript/templates/src/rpc-cbor-item.ts.j2`
4
+ // (issue #277) — kept in sync with that template manually, the same way
5
+ // `RpcLink` in `./index.ts` is kept in sync with `rpc-links.ts.j2`. See
6
+ // that template file for the full design rationale (ported from
7
+ // `crates/cratestack-client-rust/src/streaming.rs`'s use of
8
+ // `minicbor::Decoder::skip` deliberately, not reimplemented from a CBOR
9
+ // spec reading).
10
+ //
11
+ // Internal to this package (not part of the `.`/`./cbor-seq` public
12
+ // exports) — `./cbor-seq` is the public surface for boundary-scanning;
13
+ // this file only exists so `packages/cratestack-ts-types/tests/cbor-seq.test.ts`
14
+ // can exercise the real algorithm shape directly, same as `./cbor-seq`
15
+ // does for the stateful half.
16
+ /** A cbor-seq body the walker can't make sense of at all — a reserved
17
+ * additional-info value, an indefinite-length string chunk of the
18
+ * wrong major type, a stray "break" byte with nothing open, etc. This
19
+ * is always a hard failure: unlike running out of bytes mid-item, more
20
+ * data arriving later can never fix it. */
21
+ export class MalformedCborSeqError extends Error {
22
+ }
23
+ /** Not enough bytes yet to know where the current item ends. Callers
24
+ * (`CborSeqBoundaryScanner.feedChunk`) catch this and just wait for
25
+ * the next chunk — it is never a real failure. */
26
+ export class NeedMoreBytesError extends Error {
27
+ }
28
+ /** Advance past exactly one top-level CBOR data item starting at
29
+ * `offset`, returning the offset just past it. Handles every major
30
+ * type, including indefinite-length byte strings, text strings,
31
+ * arrays, and maps (RFC 8949 §3.2.1-§3.2.3), recursively — the same
32
+ * structural cases `minicbor::Decoder::skip` covers on the Rust side.
33
+ * Never interprets a value — only walks structure. */
34
+ export function skipItem(bytes, offset) {
35
+ if (offset >= bytes.length) {
36
+ throw new NeedMoreBytesError();
37
+ }
38
+ const initial = bytes[offset];
39
+ const majorType = initial >> 5;
40
+ const additionalInfo = initial & 0x1f;
41
+ const cursor = offset + 1;
42
+ if (majorType === 7) {
43
+ return skipSimpleOrFloat(bytes, cursor, additionalInfo);
44
+ }
45
+ if (additionalInfo === 31) {
46
+ // Indefinite length is only valid for byte/text strings, arrays,
47
+ // and maps (RFC 8949 §3.2.1) — never for an integer or a tag.
48
+ if (majorType === 0 || majorType === 1 || majorType === 6) {
49
+ throw new MalformedCborSeqError(`major type ${majorType} cannot use indefinite-length encoding`);
50
+ }
51
+ return skipIndefinite(bytes, cursor, majorType);
52
+ }
53
+ const argument = readArgument(bytes, cursor, additionalInfo);
54
+ switch (majorType) {
55
+ case 0: // unsigned integer — the argument IS the value, no payload
56
+ case 1: // negative integer
57
+ return argument.next;
58
+ case 2: // byte string
59
+ case 3: // text string
60
+ return requireBytes(bytes, argument.next + argument.value);
61
+ case 4: // array — `argument.value` items follow
62
+ return skipCount(bytes, argument.next, argument.value, 1);
63
+ case 5: // map — `argument.value` key/value pairs follow
64
+ return skipCount(bytes, argument.next, argument.value, 2);
65
+ case 6: // tag — exactly one nested item follows the tag number
66
+ return skipItem(bytes, argument.next);
67
+ default:
68
+ // Unreachable: majorType is `initial >> 5`, always 0-7.
69
+ throw new MalformedCborSeqError(`unreachable CBOR major type ${majorType}`);
70
+ }
71
+ }
72
+ function skipCount(bytes, start, count, itemsPerElement) {
73
+ let cursor = start;
74
+ for (let i = 0; i < count * itemsPerElement; i++) {
75
+ cursor = skipItem(bytes, cursor);
76
+ }
77
+ return cursor;
78
+ }
79
+ function skipSimpleOrFloat(bytes, cursor, additionalInfo) {
80
+ if (additionalInfo <= 23) {
81
+ return cursor; // simple value encoded inline in the initial byte
82
+ }
83
+ switch (additionalInfo) {
84
+ case 24:
85
+ return requireBytes(bytes, cursor + 1); // 1-byte simple value
86
+ case 25:
87
+ return requireBytes(bytes, cursor + 2); // half-precision float
88
+ case 26:
89
+ return requireBytes(bytes, cursor + 4); // single-precision float
90
+ case 27:
91
+ return requireBytes(bytes, cursor + 8); // double-precision float
92
+ case 31:
93
+ throw new MalformedCborSeqError("unexpected CBOR break code outside an open indefinite-length item");
94
+ default:
95
+ throw new MalformedCborSeqError(`reserved additional info ${additionalInfo} on major type 7`);
96
+ }
97
+ }
98
+ /** Indefinite-length byte string / text string / array / map (major
99
+ * types 2, 3, 4, 5 with additional info 31): items until a "break"
100
+ * byte (`0xff`). Byte/text strings additionally require every chunk to
101
+ * be a definite-length chunk of the *same* major type (RFC 8949
102
+ * §3.2.3) — nesting or mixing major types there is malformed. */
103
+ function skipIndefinite(bytes, start, majorType) {
104
+ let cursor = start;
105
+ for (;;) {
106
+ if (cursor >= bytes.length) {
107
+ throw new NeedMoreBytesError();
108
+ }
109
+ if (bytes[cursor] === 0xff) {
110
+ return cursor + 1; // break
111
+ }
112
+ if (majorType === 2 || majorType === 3) {
113
+ const chunkMajorType = bytes[cursor] >> 5;
114
+ const chunkAdditionalInfo = bytes[cursor] & 0x1f;
115
+ if (chunkMajorType !== majorType) {
116
+ throw new MalformedCborSeqError(`indefinite-length string chunk has major type ${chunkMajorType}, expected ${majorType}`);
117
+ }
118
+ if (chunkAdditionalInfo === 31) {
119
+ throw new MalformedCborSeqError("indefinite-length string chunks cannot themselves be indefinite-length");
120
+ }
121
+ }
122
+ cursor = skipItem(bytes, cursor); // array element, map key, or string chunk
123
+ if (majorType === 5) {
124
+ cursor = skipItem(bytes, cursor); // map value half of the pair
125
+ }
126
+ }
127
+ }
128
+ /** Read the argument (length/count/tag-number/value) encoded by
129
+ * `additionalInfo` starting at `offset`. `additionalInfo <= 23` means
130
+ * it's inline in the initial byte already consumed by the caller; 24,
131
+ * 25, 26, 27 mean 1, 2, 4, 8 big-endian bytes follow respectively.
132
+ * Exported so `./cbor-seq`'s tag-header detection can reuse the exact
133
+ * same argument-decoding logic rather than a second copy of it. */
134
+ export function readArgument(bytes, offset, additionalInfo) {
135
+ if (additionalInfo <= 23) {
136
+ return { value: additionalInfo, next: offset };
137
+ }
138
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
139
+ switch (additionalInfo) {
140
+ case 24:
141
+ requireBytes(bytes, offset + 1);
142
+ return { value: view.getUint8(offset), next: offset + 1 };
143
+ case 25:
144
+ requireBytes(bytes, offset + 2);
145
+ return { value: view.getUint16(offset, false), next: offset + 2 };
146
+ case 26:
147
+ requireBytes(bytes, offset + 4);
148
+ return { value: view.getUint32(offset, false), next: offset + 4 };
149
+ case 27: {
150
+ requireBytes(bytes, offset + 8);
151
+ const big = view.getBigUint64(offset, false);
152
+ if (big > BigInt(Number.MAX_SAFE_INTEGER)) {
153
+ throw new MalformedCborSeqError("cbor-seq item length/count exceeds what this scanner supports");
154
+ }
155
+ return { value: Number(big), next: offset + 8 };
156
+ }
157
+ default:
158
+ // 28-30 are reserved; 31 (indefinite) is handled by the caller
159
+ // before `readArgument` is ever reached.
160
+ throw new MalformedCborSeqError(`reserved additional info ${additionalInfo}`);
161
+ }
162
+ }
163
+ function requireBytes(bytes, endOffsetExclusive) {
164
+ if (endOffsetExclusive > bytes.length) {
165
+ throw new NeedMoreBytesError();
166
+ }
167
+ return endOffsetExclusive;
168
+ }
169
+ //# sourceMappingURL=cbor-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-item.js","sourceRoot":"","sources":["../src/cbor-item.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,6DAA6D;AAC7D,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,gEAAgE;AAChE,4DAA4D;AAC5D,wEAAwE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EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,KAAK,EAAE,CAAC,CAAC,CAAC;YACR,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;YAChC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAC7C,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,qBAAqB,CAC7B,+DAA+D,CAChE,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,CAAC;QACD;YACE,+DAA+D;YAC/D,yCAAyC;YACzC,MAAM,IAAI,qBAAqB,CAAC,4BAA4B,cAAc,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAiB,EAAE,kBAA0B;IACjE,IAAI,kBAAkB,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { CratestackRpcCodec, RpcStreamFrame } from "./index.js";
2
+ export { MalformedCborSeqError } from "./cbor-item.js";
3
+ /** Mirrors `cratestack_core::rpc::RPC_STREAM_ERROR_TAG`. Not an
4
+ * IANA-registered tag — see that constant's own doc comment for the
5
+ * collision-risk note this repo already accepted. */
6
+ export declare const RPC_STREAM_ERROR_TAG = 48900;
7
+ /** Stateful boundary scanner for `application/cbor-seq` streams. A
8
+ * `fetch` `ReadableStream` gives no guarantee that a chunk boundary
9
+ * lines up with an item boundary, so this buffers bytes across calls
10
+ * and returns the byte ranges of every complete top-level CBOR item
11
+ * observed so far, leaving any trailing partial item buffered for the
12
+ * next chunk. */
13
+ export declare class CborSeqBoundaryScanner {
14
+ private buffer;
15
+ /** Append `chunk` and return every complete top-level item now
16
+ * available, oldest first. Throws (a `MalformedCborSeqError`) only
17
+ * for structurally invalid CBOR — a genuinely truncated final item
18
+ * just stays buffered, it never throws here. */
19
+ feedChunk(chunk: Uint8Array): Uint8Array[];
20
+ /** Bytes currently buffered, waiting for a frame to complete. Check
21
+ * this once the upstream stream has closed: non-zero means the final
22
+ * item was truncated (e.g. the connection dropped mid-item). */
23
+ get pendingLength(): number;
24
+ }
25
+ /** Classify one already-boundary-scanned, complete cbor-seq item: an
26
+ * ordinary output value, or — if its leading bytes are
27
+ * `Tag(RPC_STREAM_ERROR_TAG, ...)` — the mid-stream error sentinel.
28
+ * Detected structurally from the tag header alone, without decoding
29
+ * the tagged content as anything other than `RpcErrorBody` first,
30
+ * mirroring the Rust side's equivalent classification. */
31
+ export declare function classifyCborSeqItem<O>(itemBytes: Uint8Array, codec: CratestackRpcCodec): RpcStreamFrame<O>;
32
+ //# sourceMappingURL=cbor-seq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-seq.d.ts","sourceRoot":"","sources":["../src/cbor-seq.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;sDAEsD;AACtD,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C;;;;;kBAKkB;AAClB,qBAAa,sBAAsB;IAQjC,OAAO,CAAC,MAAM,CAAiC;IAE/C;;;qDAGiD;IACjD,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE;IA6B1C;;qEAEiE;IACjE,IAAI,aAAa,IAAI,MAAM,CAE1B;CACF;AAED;;;;;2DAK2D;AAC3D,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,kBAAkB,GACxB,cAAc,CAAC,CAAC,CAAC,CAOnB"}
@@ -0,0 +1,122 @@
1
+ // Pinned local copy of the `application/cbor-seq` boundary scanner
2
+ // generated into every CrateStack `transport rpc` project by
3
+ // `crates/cratestack-client-typescript/templates/src/rpc-cbor-seq.ts.j2`
4
+ // (issue #277) — kept in sync with that template manually, the same way
5
+ // `RpcLink` in `./index.ts` is kept in sync with `rpc-links.ts.j2`.
6
+ //
7
+ // `RPC_STREAM_ERROR_TAG` mirrors the server-side constant
8
+ // (`cratestack_core::rpc::RPC_STREAM_ERROR_TAG`, issue #281): a failed
9
+ // `@stream` procedure's response ends in
10
+ // `Tag(48900, RpcErrorBody-as-CBOR-map)` as its final item — see
11
+ // `docs/design/rpc-transport.md` §3.3.
12
+ import { MalformedCborSeqError, NeedMoreBytesError, readArgument, skipItem } from "./cbor-item.js";
13
+ export { MalformedCborSeqError } from "./cbor-item.js";
14
+ /** Mirrors `cratestack_core::rpc::RPC_STREAM_ERROR_TAG`. Not an
15
+ * IANA-registered tag — see that constant's own doc comment for the
16
+ * collision-risk note this repo already accepted. */
17
+ export const RPC_STREAM_ERROR_TAG = 48900;
18
+ /** Stateful boundary scanner for `application/cbor-seq` streams. A
19
+ * `fetch` `ReadableStream` gives no guarantee that a chunk boundary
20
+ * lines up with an item boundary, so this buffers bytes across calls
21
+ * and returns the byte ranges of every complete top-level CBOR item
22
+ * observed so far, leaving any trailing partial item buffered for the
23
+ * next chunk. */
24
+ export class CborSeqBoundaryScanner {
25
+ // Explicitly typed (not inferred from the initializer): `new
26
+ // Uint8Array(0)` infers the narrower `Uint8Array<ArrayBuffer>`, but
27
+ // bytes fed in later (e.g. a `fetch` reader's chunks) are the wider
28
+ // `Uint8Array<ArrayBufferLike>` — an explicit bare `Uint8Array`
29
+ // annotation (which itself defaults to `Uint8Array<ArrayBufferLike>`)
30
+ // avoids a spurious assignment error under TypeScript 5.7+'s generic
31
+ // typed-array types.
32
+ buffer = new Uint8Array(0);
33
+ /** Append `chunk` and return every complete top-level item now
34
+ * available, oldest first. Throws (a `MalformedCborSeqError`) only
35
+ * for structurally invalid CBOR — a genuinely truncated final item
36
+ * just stays buffered, it never throws here. */
37
+ feedChunk(chunk) {
38
+ this.buffer = concatBytes(this.buffer, chunk);
39
+ const items = [];
40
+ let consumed = 0;
41
+ for (;;) {
42
+ if (consumed >= this.buffer.length) {
43
+ break;
44
+ }
45
+ let end;
46
+ try {
47
+ end = skipItem(this.buffer, consumed);
48
+ }
49
+ catch (error) {
50
+ if (error instanceof NeedMoreBytesError) {
51
+ break;
52
+ }
53
+ throw error;
54
+ }
55
+ if (end <= consumed) {
56
+ throw new MalformedCborSeqError("cbor-seq boundary scanner made no progress on an item");
57
+ }
58
+ items.push(this.buffer.slice(consumed, end));
59
+ consumed = end;
60
+ }
61
+ if (consumed > 0) {
62
+ this.buffer = this.buffer.slice(consumed);
63
+ }
64
+ return items;
65
+ }
66
+ /** Bytes currently buffered, waiting for a frame to complete. Check
67
+ * this once the upstream stream has closed: non-zero means the final
68
+ * item was truncated (e.g. the connection dropped mid-item). */
69
+ get pendingLength() {
70
+ return this.buffer.length;
71
+ }
72
+ }
73
+ /** Classify one already-boundary-scanned, complete cbor-seq item: an
74
+ * ordinary output value, or — if its leading bytes are
75
+ * `Tag(RPC_STREAM_ERROR_TAG, ...)` — the mid-stream error sentinel.
76
+ * Detected structurally from the tag header alone, without decoding
77
+ * the tagged content as anything other than `RpcErrorBody` first,
78
+ * mirroring the Rust side's equivalent classification. */
79
+ export function classifyCborSeqItem(itemBytes, codec) {
80
+ const tag = readLeadingTag(itemBytes);
81
+ if (tag !== null && tag.tagNumber === RPC_STREAM_ERROR_TAG) {
82
+ const error = codec.decode(itemBytes.slice(tag.headerLength));
83
+ return { kind: "error", error };
84
+ }
85
+ return { kind: "output", output: codec.decode(itemBytes) };
86
+ }
87
+ function concatBytes(a, b) {
88
+ if (a.length === 0) {
89
+ return b;
90
+ }
91
+ if (b.length === 0) {
92
+ return a;
93
+ }
94
+ const out = new Uint8Array(a.length + b.length);
95
+ out.set(a, 0);
96
+ out.set(b, a.length);
97
+ return out;
98
+ }
99
+ /** If `itemBytes` starts with a CBOR tag (major type 6), return its tag
100
+ * number and how many leading bytes the tag header occupies;
101
+ * otherwise `null`. Only reads the initial byte(s), never the tagged
102
+ * content. `itemBytes` already passed `skipItem` as a complete item,
103
+ * so a malformed/truncated tag header here can't happen in practice —
104
+ * this stays defensive rather than assuming that invariant. */
105
+ function readLeadingTag(itemBytes) {
106
+ if (itemBytes.length === 0) {
107
+ return null;
108
+ }
109
+ const initial = itemBytes[0];
110
+ if (initial >> 5 !== 6) {
111
+ return null;
112
+ }
113
+ const additionalInfo = initial & 0x1f;
114
+ try {
115
+ const { value, next } = readArgument(itemBytes, 1, additionalInfo);
116
+ return { tagNumber: value, headerLength: next };
117
+ }
118
+ catch {
119
+ return null;
120
+ }
121
+ }
122
+ //# sourceMappingURL=cbor-seq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-seq.js","sourceRoot":"","sources":["../src/cbor-seq.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,6DAA6D;AAC7D,yEAAyE;AACzE,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,0DAA0D;AAC1D,uEAAuE;AACvE,yCAAyC;AACzC,iEAAiE;AACjE,uCAAuC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;sDAEsD;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C;;;;;kBAKkB;AAClB,MAAM,OAAO,sBAAsB;IACjC,6DAA6D;IAC7D,oEAAoE;IACpE,oEAAoE;IACpE,gEAAgE;IAChE,sEAAsE;IACtE,qEAAqE;IACrE,qBAAqB;IACb,MAAM,GAAe,IAAI,UAAU,CAAC,CAAC,CAAC,CA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,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;QACnE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -21,6 +21,34 @@ export interface RpcLinkResponse {
21
21
  export type RpcLinkNext = (request: RpcLinkRequest) => Promise<RpcLinkResponse>;
22
22
  /** Mirrors the generated `RpcLink`. */
23
23
  export type RpcLink = (request: RpcLinkRequest, next: RpcLinkNext) => Promise<RpcLinkResponse>;
24
+ /** One `stream()` call going through the stream chain — mirrors the
25
+ * generated `RpcStreamLinkRequest` (issue #277). Deliberately NOT a
26
+ * variant of `RpcLinkRequest`; see the generated `rpc-links.ts.j2`
27
+ * template's doc comment on `RpcStreamLinkRequest` for why. */
28
+ export interface RpcStreamLinkRequest {
29
+ readonly opId: string;
30
+ readonly input: unknown;
31
+ readonly headers: Headers;
32
+ readonly signal: AbortSignal | null;
33
+ readonly codec: CratestackRpcCodec;
34
+ readonly fetchFn: typeof fetch;
35
+ readonly url: string;
36
+ }
37
+ /** Mirrors the generated `RpcStreamFrame`: one item out of a stream,
38
+ * either a decoded output value or — for a genuinely-incremental
39
+ * `application/cbor-seq` response that failed partway through (issue
40
+ * #281) — the mid-stream error sentinel. */
41
+ export type RpcStreamFrame<O = unknown> = {
42
+ readonly kind: "output";
43
+ readonly output: O;
44
+ } | {
45
+ readonly kind: "error";
46
+ readonly error: RpcErrorBody;
47
+ };
48
+ /** Mirrors the generated `RpcStreamLinkNext`. */
49
+ export type RpcStreamLinkNext = (request: RpcStreamLinkRequest) => AsyncIterable<RpcStreamFrame>;
50
+ /** Mirrors the generated `RpcStreamLink`. */
51
+ export type RpcStreamLink = (request: RpcStreamLinkRequest, next: RpcStreamLinkNext) => AsyncIterable<RpcStreamFrame>;
24
52
  /** Mirrors the generated `CratestackRpcCodec`. */
25
53
  export interface CratestackRpcCodec {
26
54
  readonly contentType: string;
@@ -62,4 +90,5 @@ export interface RpcCaller {
62
90
  signal?: AbortSignal;
63
91
  }): Promise<O>;
64
92
  }
93
+ export * from "./cbor-seq.js";
65
94
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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,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+1,22 @@
1
1
  // Pinned local copies of the wire/link contract generated into every
2
2
  // CrateStack `transport rpc` project by
3
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 {};
4
+ // `rpc-runtime.ts.j2` (issue #182, extended by issue #277). Kept as
5
+ // plain interfaces/function types deliberately — a generated project's
6
+ // `CratestackRpcRuntime` is a per-project class with no shared import
7
+ // path, so this package can't (and doesn't need to) import it;
8
+ // TypeScript's structural typing means any object shaped like these
9
+ // types is assignable into a generated client's `links`/`streamLinks`
10
+ // array, regardless of which project generated it.
11
+ //
12
+ // `./cbor-seq` (re-exported below) is the one piece of this package
13
+ // that ISN'T just types — the boundary-scanner is real, non-trivial
14
+ // logic (issue #277's own highest-risk piece), pinned here as an actual
15
+ // implementation, not merely a type, the same way the generated
16
+ // `rpc-cbor-seq.ts.j2`/`rpc-cbor-item.ts.j2` templates are.
17
+ // `./cbor-item` is deliberately internal (the low-level single-item
18
+ // walk) — mirroring the generated package's own `src/cbor-item.ts`,
19
+ // which `src/index.ts.j2` never re-exports either. `./cbor-seq` is the
20
+ // public surface for boundary-scanning.
21
+ export * from "./cbor-seq.js";
11
22
  //# 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,qEAAqE;AACrE,wCAAwC;AACxC,0EAA0E;AAC1E,sEAAsE;AACtE,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AACxE,oEAAoE;AACpE,oEAAoE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,wCAAwC;AACxC,0EAA0E;AAC1E,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,+DAA+D;AAC/D,oEAAoE;AACpE,sEAAsE;AACtE,mDAAmD;AACnD,EAAE;AACF,oEAAoE;AACpE,oEAAoE;AACpE,wEAAwE;AACxE,gEAAgE;AAChE,4DAA4D;AAwG5D,oEAAoE;AACpE,oEAAoE;AACpE,uEAAuE;AACvE,wCAAwC;AACxC,cAAc,eAAe,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { RpcLink } from "./index.js";
1
+ import type { CratestackRpcCodec, RpcErrorBody, RpcLink, RpcStreamLink } from "./index.js";
2
2
  export declare const jsonCodec: {
3
3
  contentType: string;
4
4
  encode(value: unknown): BodyInit;
@@ -19,7 +19,33 @@ export declare class FakeRuntime {
19
19
  call<O>(opId: string, input: unknown, opts?: {
20
20
  signal?: AbortSignal;
21
21
  idempotencyKey?: string;
22
+ headers?: HeadersInit;
22
23
  }): Promise<O>;
23
24
  batch(requests: unknown[]): Promise<unknown>;
24
25
  }
26
+ /** Thrown by `FakeStreamRuntime.stream()` for the mid-stream error
27
+ * sentinel — mirrors `CratestackRpcStreamError`
28
+ * (`rpc-runtime.ts.j2`) closely enough for tests to assert on
29
+ * `error.body`, without pulling in the whole generated-runtime class
30
+ * (which, like `CratestackRpcRuntime` itself, has no shared import
31
+ * path from a per-project generated package). */
32
+ export declare class FakeStreamError extends Error {
33
+ readonly body: RpcErrorBody;
34
+ constructor(body: RpcErrorBody);
35
+ }
36
+ /** Mirrors `CratestackRpcRuntime`'s stream chain construction and
37
+ * `terminalStreamLink` exactly (see
38
+ * `crates/cratestack-client-typescript/templates/src/rpc-stream-terminal.ts.j2`),
39
+ * so `RpcStreamLink` tests exercise the real generated contract rather
40
+ * than a reimplementation of it — the sibling of `FakeRuntime` above,
41
+ * for `stream()` instead of `call()`/`batch()`. */
42
+ export declare class FakeStreamRuntime {
43
+ private readonly streamChain;
44
+ private readonly fetchFn;
45
+ private readonly codec;
46
+ constructor(fetchFn: typeof fetch, streamLinks?: RpcStreamLink[], codec?: CratestackRpcCodec);
47
+ stream<O>(opId: string, input: unknown, opts?: {
48
+ signal?: AbortSignal;
49
+ }): AsyncIterable<O>;
50
+ }
25
51
  //# sourceMappingURL=test-harness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-harness.d.ts","sourceRoot":"","sources":["../src/test-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA+B,MAAM,YAAY,CAAC;AAEvE,eAAO,MAAM,SAAS;;kBAEN,OAAO,GAAG,QAAQ;kBAGlB,UAAU,GAAG,OAAO;CAMnC,CAAC;AAaF;;;;;;;sDAOsD;AACtD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,OAAO,EAAE,OAAO,KAAK,EAAE,KAAK,GAAE,OAAO,EAAO;IAQlD,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAO,GAC3D,OAAO,CAAC,CAAC,CAAC;IA2BP,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAkBnD"}
1
+ {"version":3,"file":"test-harness.d.ts","sourceRoot":"","sources":["../src/test-harness.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,OAAO,EAGP,aAAa,EAGd,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,SAAS;;kBAEN,OAAO,GAAG,QAAQ;kBAGlB,UAAU,GAAG,OAAO;CAMnC,CAAC;AAaF;;;;;;;sDAOsD;AACtD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,OAAO,EAAE,OAAO,KAAK,EAAE,KAAK,GAAE,OAAO,EAAO;IAQlD,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,WAAW,CAAA;KAAO,GAClF,OAAO,CAAC,CAAC,CAAC;IAyCP,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAkBnD;AAQD;;;;;kDAKkD;AAClD,qBAAa,eAAgB,SAAQ,KAAK;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY;gBAAlB,IAAI,EAAE,YAAY;CAGxC;AAED;;;;;oDAKoD;AACpD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;gBAOzC,OAAO,EAAE,OAAO,KAAK,EACrB,WAAW,GAAE,aAAa,EAAO,EACjC,KAAK,GAAE,kBAA8B;IAUhC,MAAM,CAAC,CAAC,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAClC,aAAa,CAAC,CAAC,CAAC;CAiBpB"}
@@ -1,3 +1,4 @@
1
+ import { CborSeqBoundaryScanner, classifyCborSeqItem } from "./cbor-seq.js";
1
2
  export const jsonCodec = {
2
3
  contentType: "application/json",
3
4
  encode(value) {
@@ -36,11 +37,25 @@ export class FakeRuntime {
36
37
  this.chain = links.reduceRight((next, link) => (request) => link(request, next), terminalLink);
37
38
  }
38
39
  async call(opId, input, opts = {}) {
40
+ // Mirrors `CratestackRpcRuntime.call()`/`buildHeaders()`: per-call
41
+ // `options.headers` are merged in, and the caller's `idempotencyKey`
42
+ // is written into the `Idempotency-Key` header too, not just the
43
+ // `RpcLinkRequest.idempotencyKey` field — a link that only reads one
44
+ // of the two (e.g. deriving a batch signature from headers) needs a
45
+ // harness that actually sets both, or its coverage of that case is
46
+ // vacuous. Set AFTER `opts.headers` (deliberately, matching the real
47
+ // runtime's own order) so `opts.idempotencyKey`, the explicit typed
48
+ // option, always wins over a same-named header the caller happened
49
+ // to also pass in `opts.headers` — not a merge, an override.
50
+ const headers = new Headers(opts.headers);
51
+ if (opts.idempotencyKey !== undefined) {
52
+ headers.set("Idempotency-Key", opts.idempotencyKey);
53
+ }
39
54
  const request = {
40
55
  kind: "unary",
41
56
  opId,
42
57
  input: input ?? null,
43
- headers: new Headers(),
58
+ headers,
44
59
  signal: opts.signal ?? null,
45
60
  ...(opts.idempotencyKey !== undefined ? { idempotencyKey: opts.idempotencyKey } : {}),
46
61
  codec: jsonCodec,
@@ -80,4 +95,107 @@ export class FakeRuntime {
80
95
  return jsonCodec.decode(bytes);
81
96
  }
82
97
  }
98
+ const CBOR_SEQ_CONTENT_TYPE = "application/cbor-seq";
99
+ function matchesContentType(header, expected) {
100
+ return (header.split(";", 1)[0]?.trim() ?? "") === expected;
101
+ }
102
+ /** Thrown by `FakeStreamRuntime.stream()` for the mid-stream error
103
+ * sentinel — mirrors `CratestackRpcStreamError`
104
+ * (`rpc-runtime.ts.j2`) closely enough for tests to assert on
105
+ * `error.body`, without pulling in the whole generated-runtime class
106
+ * (which, like `CratestackRpcRuntime` itself, has no shared import
107
+ * path from a per-project generated package). */
108
+ export class FakeStreamError extends Error {
109
+ body;
110
+ constructor(body) {
111
+ super(`rpc stream error ${body.code}: ${body.message}`);
112
+ this.body = body;
113
+ }
114
+ }
115
+ /** Mirrors `CratestackRpcRuntime`'s stream chain construction and
116
+ * `terminalStreamLink` exactly (see
117
+ * `crates/cratestack-client-typescript/templates/src/rpc-stream-terminal.ts.j2`),
118
+ * so `RpcStreamLink` tests exercise the real generated contract rather
119
+ * than a reimplementation of it — the sibling of `FakeRuntime` above,
120
+ * for `stream()` instead of `call()`/`batch()`. */
121
+ export class FakeStreamRuntime {
122
+ streamChain;
123
+ fetchFn;
124
+ codec;
125
+ // `codec` defaults to the same `jsonCodec` `FakeRuntime` uses, but is
126
+ // overridable so a test can drive the real `application/cbor-seq`
127
+ // terminal-link path end to end (that path picks its behavior off
128
+ // `request.codec.contentType`, exactly like the generated runtime).
129
+ constructor(fetchFn, streamLinks = [], codec = jsonCodec) {
130
+ this.fetchFn = fetchFn;
131
+ this.codec = codec;
132
+ this.streamChain = streamLinks.reduceRight((next, link) => (request) => link(request, next), terminalStreamLink);
133
+ }
134
+ async *stream(opId, input, opts = {}) {
135
+ const request = {
136
+ opId,
137
+ input: input ?? null,
138
+ headers: new Headers(),
139
+ signal: opts.signal ?? null,
140
+ codec: this.codec,
141
+ fetchFn: this.fetchFn,
142
+ url: `https://example.test/rpc/${opId}`,
143
+ };
144
+ for await (const frame of this.streamChain(request)) {
145
+ if (frame.kind === "error") {
146
+ throw new FakeStreamError(frame.error);
147
+ }
148
+ yield frame.output;
149
+ }
150
+ }
151
+ }
152
+ const terminalStreamLink = async function* (request) {
153
+ const response = await request.fetchFn(request.url, {
154
+ method: "POST",
155
+ headers: request.headers,
156
+ body: request.codec.encode(request.input),
157
+ signal: request.signal,
158
+ });
159
+ if (!response.ok) {
160
+ throw new Error(`rpc stream request failed with status ${response.status}`);
161
+ }
162
+ const contentType = response.headers.get("Content-Type") ?? "";
163
+ if (matchesContentType(contentType, request.codec.contentType)) {
164
+ const bytes = new Uint8Array(await response.arrayBuffer());
165
+ if (bytes.length === 0) {
166
+ return;
167
+ }
168
+ const items = request.codec.decode(bytes);
169
+ for (const item of items) {
170
+ yield { kind: "output", output: item };
171
+ }
172
+ return;
173
+ }
174
+ if (!matchesContentType(contentType, CBOR_SEQ_CONTENT_TYPE) || response.body === null) {
175
+ throw new Error(`streaming response had unsupported Content-Type "${contentType}"`);
176
+ }
177
+ const scanner = new CborSeqBoundaryScanner();
178
+ const reader = response.body.getReader();
179
+ try {
180
+ for (;;) {
181
+ const { done, value } = await reader.read();
182
+ if (done) {
183
+ break;
184
+ }
185
+ for (const itemBytes of scanner.feedChunk(value)) {
186
+ const frame = classifyCborSeqItem(itemBytes, request.codec);
187
+ yield frame;
188
+ if (frame.kind === "error") {
189
+ return;
190
+ }
191
+ }
192
+ }
193
+ if (scanner.pendingLength > 0) {
194
+ throw new Error(`${CBOR_SEQ_CONTENT_TYPE} response ended with ${scanner.pendingLength} bytes buffered (truncated final item)`);
195
+ }
196
+ }
197
+ finally {
198
+ reader.releaseLock();
199
+ }
200
+ };
83
201
  //# sourceMappingURL=test-harness.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-harness.js","sourceRoot":"","sources":["../src/test-harness.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,WAAW,EAAE,kBAAkB;IAC/B,MAAM,CAAC,KAAc;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,MAAM,CAAC,KAAiB;QACtB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;CACF,CAAC;AAEF,MAAM,YAAY,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IAClD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IA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EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACzC,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,qBAAqB,CAAC,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,oDAAoD,WAAW,GAAG,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IACzC,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM;YACR,CAAC;YACD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjD,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC5D,MAAM,KAAK,CAAC;gBACZ,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,OAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,OAAO,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,GAAG,qBAAqB,wBAAwB,OAAO,CAAC,aAAa,wCAAwC,CAC9G,CAAC;QACJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratestack/ts-types",
3
- "version": "0.5.2",
3
+ "version": "0.6.3",
4
4
  "description": "Shared TypeScript interfaces for CrateStack's generated RPC client (RpcLink, RpcLinkRequest, wire frame shapes). Types only — compiles to near-empty JS.",
5
5
  "license": "MIT",
6
6
  "repository": {