@zlink-systems/stream-wire 0.26.0 → 0.28.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.
@@ -1,3 +1,4 @@
1
+ export { defaultMaxDecompressedPayloadSize } from './lz4-pickle';
1
2
  export interface ZLinkStreamWireFrame {
2
3
  readonly header: Uint8Array;
3
4
  readonly payload: Uint8Array;
@@ -9,6 +10,69 @@ export declare enum ZlinkStreamCodec {
9
10
  MessagePack = 2,
10
11
  Protobuf = 3
11
12
  }
13
+ export declare enum ZlinkStreamMessageKind {
14
+ Send = 1,
15
+ Request = 2,
16
+ Response = 3,
17
+ Error = 4,
18
+ Control = 5
19
+ }
20
+ export declare enum ZlinkStreamHeaderFlags {
21
+ None = 0,
22
+ HasRequestSeq = 1,
23
+ HasMetadata = 2,
24
+ PayloadCompressed = 4,
25
+ HasCorrelationId = 8,
26
+ HasFlowId = 16,
27
+ HasActorSlot = 32
28
+ }
29
+ export declare enum ZlinkStreamCloseReasonCode {
30
+ ClientClose = 1,
31
+ IdleTimeout = 2,
32
+ HeartbeatTimeout = 3,
33
+ ServerDrain = 4,
34
+ ProtocolError = 5,
35
+ TransportError = 6
36
+ }
37
+ export type ZlinkStreamCloseReason = keyof typeof ZlinkStreamCloseReasonCode;
38
+ export declare function isStreamWireMessageKind(value: number): boolean;
39
+ export declare function isStreamWireCodec(value: number): boolean;
40
+ export declare const UINT64_BYTES = 8;
41
+ export declare const UINT64_MAX = 18446744073709551615n;
42
+ export declare const UINT32_MAX = 4294967295;
43
+ export declare const ZLINK_STREAM_FRAME_PREFIX_BYTES: number;
44
+ export declare const ZLINK_STREAM_MAX_PACKET_NAME_BYTES = 255;
45
+ export declare const ZLINK_STREAM_MAX_METADATA_BYTES = 1024;
46
+ export declare function encodeStreamWireActorBoundPayload(actorSlot: number, actorId: string): Uint8Array;
47
+ export declare function decodeStreamWireActorBoundPayload(payload: Uint8Array): {
48
+ readonly slot: number;
49
+ readonly actorId: string;
50
+ };
51
+ export declare function encodeStreamWireActorUnboundPayload(actorSlot: number): Uint8Array;
52
+ export declare function decodeStreamWireActorUnboundPayload(payload: Uint8Array): number;
53
+ export declare function encodeStreamWireSessionClosingPayload(reasonCode: number, diagnostic?: string): Uint8Array;
54
+ export declare function decodeStreamWireSessionClosing(payload: Uint8Array): {
55
+ readonly closeReason: ZlinkStreamCloseReason;
56
+ readonly diagnostic?: string;
57
+ };
58
+ export declare function splitStreamWireFrames(chunk: Uint8Array): readonly Uint8Array[];
59
+ /** @internal Reserved packet name prefix owned by the stream protocol. */
60
+ export declare const ZLINK_STREAM_RESERVED_PACKET_NAME_PREFIX = "$zlink.";
61
+ export declare const ZlinkStreamControlPacket: Readonly<{
62
+ readonly HeartbeatPing: "$zlink.heartbeat.ping";
63
+ readonly HeartbeatPong: "$zlink.heartbeat.pong";
64
+ readonly ActorBound: "$zlink.actor.bound";
65
+ readonly ActorUnbound: "$zlink.actor.unbound";
66
+ readonly SessionClosing: "session-closing";
67
+ }>;
68
+ export declare const ZlinkStreamContentType: Readonly<{
69
+ readonly Raw: "application/octet-stream";
70
+ readonly Json: "application/json";
71
+ readonly MessagePack: "application/x-msgpack";
72
+ readonly Protobuf: "application/x-protobuf";
73
+ }>;
74
+ export declare function streamCodecContentType(codec: ZlinkStreamCodec): string;
75
+ export declare function streamCodecForContentType(contentType: string): ZlinkStreamCodec;
12
76
  export interface ZLinkStreamWireHeader {
13
77
  readonly kind: number;
14
78
  readonly codec: number;
@@ -34,6 +98,8 @@ export declare function decodeStreamWireFrame(frame: Uint8Array): ZLinkStreamWir
34
98
  export declare function tryDecodeStreamWireFrame(frame: Uint8Array): ZLinkStreamWireFrame | undefined;
35
99
  export declare function encodeStreamWireHeader(header: ZLinkStreamWireHeader, flagOverrides?: ZLinkStreamWireHeaderFlags): Uint8Array;
36
100
  export declare function decodeStreamWireHeader(header: Uint8Array, flagOverrides?: ZLinkStreamWireHeaderFlags, includeFlow?: boolean): ZLinkStreamWireHeader;
101
+ /** Standalone metadata includes its count byte even when the map is empty. */
102
+ export declare function streamWireMetadataSize(metadata: ReadonlyMap<string, string>): number;
37
103
  export declare function encodeStreamWireMetadata(metadata: ReadonlyMap<string, string>): Uint8Array;
38
104
  export declare function decodeStreamWireMetadata(metadata: Uint8Array): Map<string, string>;
39
105
  export declare function lz4PickleUncompressed(payload: Uint8Array): Uint8Array;
@@ -41,3 +107,5 @@ export declare function lz4PickledLength(payload: Uint8Array): number;
41
107
  export declare function lz4UnpicklePayload(payload: Uint8Array, maxDecompressedSize?: number): Uint8Array;
42
108
  export declare function utf8Encode(value: string): Uint8Array;
43
109
  export declare function utf8Decode(value: Uint8Array): string;
110
+ /** @internal Shared packet name structure validation for the connector. */
111
+ export declare function validateStreamWirePacketName(name: string): Uint8Array;