@onebun/nats 0.1.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/src/types.ts ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * NATS and JetStream Types
3
+ */
4
+
5
+ /**
6
+ * NATS connection options
7
+ */
8
+ export interface NatsConnectionOptions {
9
+ /** NATS server(s) URL */
10
+ servers: string | string[];
11
+
12
+ /** Connection name (for debugging) */
13
+ name?: string;
14
+
15
+ /** Authentication token */
16
+ token?: string;
17
+
18
+ /** Username for authentication */
19
+ user?: string;
20
+
21
+ /** Password for authentication */
22
+ pass?: string;
23
+
24
+ /** Maximum reconnection attempts */
25
+ maxReconnectAttempts?: number;
26
+
27
+ /** Reconnect time wait in milliseconds */
28
+ reconnectTimeWait?: number;
29
+
30
+ /** Timeout for connection in milliseconds */
31
+ timeout?: number;
32
+
33
+ /** Enable TLS */
34
+ tls?: boolean;
35
+ }
36
+
37
+ /**
38
+ * JetStream adapter options
39
+ */
40
+ export interface JetStreamAdapterOptions extends NatsConnectionOptions {
41
+ /** Stream name to use */
42
+ stream: string;
43
+
44
+ /** Whether to create the stream if it doesn't exist */
45
+ createStream?: boolean;
46
+
47
+ /** Stream configuration (if creating) */
48
+ streamConfig?: {
49
+ /** Subjects to store in the stream */
50
+ subjects?: string[];
51
+ /** Retention policy */
52
+ retention?: 'limits' | 'interest' | 'workqueue';
53
+ /** Maximum messages */
54
+ maxMsgs?: number;
55
+ /** Maximum bytes */
56
+ maxBytes?: number;
57
+ /** Maximum age in nanoseconds */
58
+ maxAge?: number;
59
+ /** Storage type */
60
+ storage?: 'file' | 'memory';
61
+ /** Number of replicas */
62
+ replicas?: number;
63
+ };
64
+
65
+ /** Default consumer configuration */
66
+ consumerConfig?: {
67
+ /** Acknowledgment wait time in nanoseconds */
68
+ ackWait?: number;
69
+ /** Maximum number of deliveries before moving to DLQ */
70
+ maxDeliver?: number;
71
+ /** Maximum pending acknowledgments */
72
+ maxAckPending?: number;
73
+ };
74
+ }
75
+
76
+ /**
77
+ * NATS adapter options (pub/sub only)
78
+ */
79
+ export interface NatsAdapterOptions extends NatsConnectionOptions {
80
+ // No additional options for basic NATS
81
+ }