boom-format 0.9.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.
@@ -0,0 +1,779 @@
1
+ /**
2
+ * BOOM Type Definitions
3
+ * @module boom-format/types
4
+ */
5
+ type BoomPrimitive$1 = string | number | boolean | null | bigint;
6
+ type BoomValue$1 = BoomPrimitive$1 | BoomArray$1 | BoomObject$1 | Uint8Array;
7
+ interface BoomArray$1 extends Array<BoomValue$1> {
8
+ }
9
+ interface BoomObject$1 {
10
+ [key: string]: BoomValue$1;
11
+ }
12
+ interface BoomOptions$1 {
13
+ /** Maximum nesting depth for arrays/objects (default: 64) */
14
+ maxDepth?: number;
15
+ /** Maximum string length in bytes (default: 16MB) */
16
+ maxStringLength?: number;
17
+ /** Maximum array/object length (default: 1,000,000) */
18
+ maxArrayLength?: number;
19
+ /** Enable string interning for repeated values (default: true) */
20
+ enableInterning?: boolean;
21
+ /** Skip BOOM header for compressed transport (default: false) */
22
+ skipHeader?: boolean;
23
+ /** Optimize for HTTP compression - disables interning, skips header (default: false) */
24
+ forCompression?: boolean;
25
+ }
26
+ interface BoomTextOptions$1 extends BoomOptions$1 {
27
+ /** Use compact single-line format (default: false) */
28
+ compact?: boolean;
29
+ /** Indentation string for pretty printing (default: " ") */
30
+ indentString?: string;
31
+ }
32
+ interface SmallestEncodeResult$1 {
33
+ data: Uint8Array | string;
34
+ format: 'boom' | 'json';
35
+ savings: number;
36
+ }
37
+ type BoomMode$1 = 'boom-binary' | 'boom-text' | 'json';
38
+ interface BoomThresholdConfig$1 {
39
+ /** Below this size in bytes, use JSON (default: 1024) */
40
+ minSize?: number;
41
+ /** Above this size in bytes, prefer BOOM (default: 10240) */
42
+ preferSize?: number;
43
+ /** Above this size in bytes, always use BOOM (default: 102400) */
44
+ forceSize?: number;
45
+ /** Enable automatic format detection (default: true) */
46
+ autoDetect?: boolean;
47
+ /** Honor client X-Boom-Expected-Size hints (default: true) */
48
+ respectClientHint?: boolean;
49
+ }
50
+
51
+ /**
52
+ * BOOM Error Class
53
+ * @module boom-format/errors
54
+ */
55
+ declare class BoomError extends Error {
56
+ constructor(message: string);
57
+ }
58
+
59
+ /**
60
+ * BOOM Varint Utilities
61
+ * @module boom-format/varint
62
+ */
63
+ /**
64
+ * Zigzag encode a signed integer for varint encoding
65
+ */
66
+ declare function zigzagEncode(value: number): number;
67
+ /**
68
+ * Zigzag decode a varint back to signed integer
69
+ */
70
+ declare function zigzagDecode(value: number): number;
71
+
72
+ /**
73
+ * BOOM Buffer Utilities
74
+ * ByteWriter and ByteReader for binary serialization
75
+ * @module boom-format/buffer
76
+ */
77
+ /**
78
+ * Growable byte buffer for writing binary data
79
+ */
80
+ declare class ByteWriter {
81
+ buffer: Uint8Array;
82
+ private view;
83
+ pos: number;
84
+ private capacity;
85
+ constructor(initialCapacity?: number);
86
+ private grow;
87
+ write(data: Uint8Array): void;
88
+ writeByte(value: number): void;
89
+ writeInt8(value: number): void;
90
+ writeInt16LE(value: number): void;
91
+ writeInt32LE(value: number): void;
92
+ writeBigInt64LE(value: bigint): void;
93
+ writeBigUInt64LE(value: bigint): void;
94
+ writeFloat32LE(value: number): void;
95
+ writeFloat64LE(value: number): void;
96
+ writeVarint(value: number): void;
97
+ writeVarintSmall(value: number): void;
98
+ toUint8Array(): Uint8Array;
99
+ }
100
+ /**
101
+ * Byte buffer reader for decoding binary data
102
+ */
103
+ declare class ByteReader {
104
+ private view;
105
+ offset: number;
106
+ private buf;
107
+ private len;
108
+ constructor(buffer: Uint8Array);
109
+ get remaining(): number;
110
+ get buffer(): Uint8Array;
111
+ readByte(): number;
112
+ readBytes(count: number): Uint8Array;
113
+ readInt8(): number;
114
+ readInt16LE(): number;
115
+ readInt32LE(): number;
116
+ readBigInt64LE(): bigint;
117
+ readUInt8(): number;
118
+ readUInt16LE(): number;
119
+ readUInt32LE(): number;
120
+ readBigUInt64LE(): bigint;
121
+ readFloat32LE(): number;
122
+ readFloat64LE(): number;
123
+ readVarint(): number;
124
+ }
125
+
126
+ /**
127
+ * BOOM - Binary Object Optimised Markup
128
+ * A compact binary serialisation format with readable debug mode
129
+ *
130
+ * @module boom-format
131
+ * @version 1.0.0
132
+ * @license MIT
133
+ */
134
+
135
+ type BoomPrimitive = string | number | boolean | null | bigint;
136
+ type BoomValue = BoomPrimitive | BoomArray | BoomObject | Uint8Array;
137
+ interface BoomArray extends Array<BoomValue> {
138
+ }
139
+ interface BoomObject {
140
+ [key: string]: BoomValue;
141
+ }
142
+ interface BoomOptions {
143
+ /** Maximum nesting depth for arrays/objects (default: 64) */
144
+ maxDepth?: number;
145
+ /** Maximum string length in bytes (default: 16MB) */
146
+ maxStringLength?: number;
147
+ /** Maximum array/object length (default: 1,000,000) */
148
+ maxArrayLength?: number;
149
+ /** Enable string interning for repeated values (default: true) */
150
+ enableInterning?: boolean;
151
+ /** Skip BOOM header for compressed transport (default: false) */
152
+ skipHeader?: boolean;
153
+ /** Optimize for HTTP compression - disables interning, skips header (default: false) */
154
+ forCompression?: boolean;
155
+ /** Use built-in shared dictionary for common strings (default: true) */
156
+ useBuiltInDictionary?: boolean;
157
+ /** Custom shared dictionary - array of strings known to both encoder and decoder */
158
+ sharedDictionary?: string[];
159
+ /**
160
+ * Strict binary mode - only accept BOOM binary format, reject text/JSON (default: false)
161
+ *
162
+ * Enable this in production to prevent clients from sending unexpected formats.
163
+ * When true, decode() will throw an error if the input doesn't start with BOOM magic bytes.
164
+ * This protects against:
165
+ * - Clients sending JSON instead of BOOM binary
166
+ * - Clients sending BOOM text format (debug mode)
167
+ * - Malformed or malicious input that might be parsed differently
168
+ */
169
+ strictBinaryMode?: boolean;
170
+ }
171
+ interface BoomTextOptions extends BoomOptions {
172
+ /** Use compact single-line format (default: false) */
173
+ compact?: boolean;
174
+ /** Indentation string for pretty printing (default: " ") */
175
+ indentString?: string;
176
+ }
177
+ /**
178
+ * BOOM Built-in Shared Dictionary v1
179
+ *
180
+ * Comprehensive dictionary of common strings used in APIs, AI/LLM, HTTP, and web applications.
181
+ * This dictionary is shared across ALL BOOM implementations (JS, Go, PHP, Rust, Java, .NET, Swift, C++).
182
+ *
183
+ * IMPORTANT: This dictionary is versioned and MUST remain identical across all plugins.
184
+ * Never modify existing entries - only append new entries to maintain backwards compatibility.
185
+ *
186
+ * Organization (optimized for 1-byte varint encoding for indices < 128):
187
+ * - 0-31: Most common keys (id, name, type, content, data, etc.)
188
+ * - 32-63: API response fields
189
+ * - 64-95: AI/LLM streaming fields (OpenAI, Anthropic, etc.)
190
+ * - 96-127: Status and state values
191
+ * - 128-159: HTTP and headers
192
+ * - 160-191: Timestamps and dates
193
+ * - 192-223: User/auth fields
194
+ * - 224-255: Data types and formats
195
+ * - 256-287: Error handling
196
+ * - 288-319: Collections and pagination
197
+ * - 320+: Additional common fields
198
+ */
199
+ declare const BOOM_DICTIONARY_V1: readonly string[];
200
+ /**
201
+ * Dictionary analysis result showing which strings could benefit from being in the dictionary
202
+ */
203
+ interface DictionaryAnalysisResult {
204
+ /** Strings already in the built-in dictionary (with their indices) */
205
+ inDictionary: {
206
+ string: string;
207
+ index: number;
208
+ count: number;
209
+ }[];
210
+ /** Strings NOT in the dictionary that appear frequently (sorted by potential savings) */
211
+ missingStrings: {
212
+ string: string;
213
+ count: number;
214
+ potentialSavings: number;
215
+ }[];
216
+ /** Summary statistics */
217
+ stats: {
218
+ totalStrings: number;
219
+ uniqueStrings: number;
220
+ dictionaryHits: number;
221
+ dictionaryMisses: number;
222
+ dictionaryHitRate: number;
223
+ potentialSavingsBytes: number;
224
+ };
225
+ }
226
+ /**
227
+ * Analyze data to find which strings are in the dictionary and which are missing.
228
+ * This helps users build custom dictionaries for their specific use cases.
229
+ *
230
+ * @param value - The data to analyze
231
+ * @returns Analysis showing dictionary hits, misses, and potential savings
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * const data = [
236
+ * { myCustomField: 'value1', status: 'active' },
237
+ * { myCustomField: 'value2', status: 'pending' },
238
+ * ];
239
+ * const analysis = analyzeDictionary(data);
240
+ * console.log('Missing strings:', analysis.missingStrings);
241
+ * // Use this to build a custom dictionary
242
+ * ```
243
+ */
244
+ declare function analyzeDictionary(value: BoomValue): DictionaryAnalysisResult;
245
+ /**
246
+ * Process all <script type="text/boom"> elements in the document
247
+ * and make their parsed data available via dataset
248
+ */
249
+ declare function processBoomScripts$1(): Map<string, BoomValue>;
250
+ /**
251
+ * Get parsed data from a specific BOOM script element
252
+ */
253
+ declare function getBoomData$1(scriptId: string): BoomValue | undefined;
254
+ /**
255
+ * Auto-initialise BOOM script processing when DOM is ready
256
+ */
257
+ declare function autoInit$1(): void;
258
+ /**
259
+ * Encode a value to BOOM binary format
260
+ */
261
+ declare function encode(value: BoomValue, options?: BoomOptions): Uint8Array;
262
+ /**
263
+ * Decode BOOM binary format to a value
264
+ */
265
+ declare function decode(buffer: Uint8Array, options?: BoomOptions): BoomValue;
266
+ /**
267
+ * Encode a value to BOOM text format
268
+ */
269
+ declare function stringify(value: BoomValue, options?: BoomTextOptions): string;
270
+ /**
271
+ * Parse BOOM text format to a value
272
+ */
273
+ declare function parseText(input: string, options?: BoomOptions): BoomValue;
274
+ /**
275
+ * Convert JSON to BOOM binary
276
+ */
277
+ declare function fromJSON(json: string, options?: BoomOptions): Uint8Array;
278
+ /**
279
+ * Result from encodeSmallest - includes format indicator
280
+ */
281
+ interface SmallestEncodeResult {
282
+ /** The encoded data (BOOM binary or JSON) */
283
+ data: Uint8Array;
284
+ /** Format used: 'boom' or 'json' */
285
+ format: 'boom' | 'json';
286
+ /** Size comparison info */
287
+ sizes: {
288
+ boom: number;
289
+ json: number;
290
+ };
291
+ }
292
+ /**
293
+ * Encode to the smallest format for compressed transport.
294
+ * Compares BOOM binary vs JSON and returns whichever compresses smaller.
295
+ * Use this when you need GUARANTEED smallest output over HTTP with compression.
296
+ *
297
+ * @param value - Value to encode
298
+ * @param compress - Compression function to use for comparison (e.g., zlib.brotliCompressSync)
299
+ * @returns Result with data, format indicator, and size info
300
+ */
301
+ declare function encodeSmallest(value: BoomValue, compress: (data: Uint8Array) => Uint8Array): SmallestEncodeResult;
302
+ /**
303
+ * Decode data that was encoded with encodeSmallest
304
+ */
305
+ declare function decodeSmallest(data: Uint8Array, format: 'boom' | 'json', options?: BoomOptions): BoomValue;
306
+ /**
307
+ * Direct JSON-to-BOOM streaming parser
308
+ * Parses JSON directly to BOOM binary without creating intermediate objects
309
+ * Supports string interning for repeated strings
310
+ */
311
+ declare function fromJSONDirect(json: string): Uint8Array;
312
+ /**
313
+ * Convert BOOM binary to JSON
314
+ */
315
+ declare function toJSON(buffer: Uint8Array, options?: BoomOptions): string;
316
+ /**
317
+ * Calculate size comparison between JSON and BOOM
318
+ */
319
+ declare function compare(value: BoomValue): {
320
+ jsonSize: number;
321
+ jsonMinSize: number;
322
+ boomBinarySize: number;
323
+ boomTextSize: number;
324
+ boomTextCompactSize: number;
325
+ savings: {
326
+ vsJson: string;
327
+ vsJsonMin: string;
328
+ };
329
+ };
330
+ /**
331
+ * Encode a value with 4-byte length prefix for streaming/pipe usage.
332
+ * Format: [4-byte little-endian length][BOOM data]
333
+ */
334
+ declare function encodeWithLength(value: BoomValue, options?: BoomOptions): Uint8Array;
335
+ /**
336
+ * Decode a single length-prefixed message from a buffer.
337
+ * Returns { value, bytesRead } or null if buffer doesn't have a complete message.
338
+ */
339
+ declare function decodeFromLengthPrefixed(buffer: Uint8Array, offset?: number, options?: BoomOptions): {
340
+ value: BoomValue;
341
+ bytesRead: number;
342
+ } | null;
343
+ /**
344
+ * Stream decoder for processing length-prefixed BOOM messages from chunks.
345
+ * Accumulates partial data and yields complete messages.
346
+ */
347
+ declare class StreamDecoder {
348
+ private buffer;
349
+ private writePos;
350
+ private options;
351
+ constructor(initialCapacity?: number, options?: BoomOptions);
352
+ /**
353
+ * Push a chunk of data and return any complete decoded messages.
354
+ */
355
+ push(chunk: Uint8Array): BoomValue[];
356
+ /**
357
+ * Check if there's pending partial data.
358
+ */
359
+ get hasPending(): boolean;
360
+ /**
361
+ * Clear any pending data.
362
+ */
363
+ clear(): void;
364
+ }
365
+ type BoomMode = 'boom-binary' | 'boom-text' | 'json';
366
+ /**
367
+ * HTTP header names for threshold negotiation.
368
+ * Servers announce their policy, clients can hint expected payload size.
369
+ */
370
+ declare const BoomHeaders: {
371
+ /** Server announces minimum payload size for BOOM (below this, JSON is acceptable) */
372
+ readonly MIN_SIZE: "X-Boom-Min-Size";
373
+ /** Server announces payload size where BOOM is preferred */
374
+ readonly PREFER_SIZE: "X-Boom-Prefer-Size";
375
+ /** Server announces payload size where BOOM is required */
376
+ readonly FORCE_SIZE: "X-Boom-Force-Size";
377
+ /** Client hints expected payload size: 'large', 'small', or byte count */
378
+ readonly EXPECTED_SIZE: "X-Boom-Expected-Size";
379
+ /** Server response indicates format used */
380
+ readonly FORMAT: "X-Boom-Format";
381
+ /** Server explains why format was chosen */
382
+ readonly REASON: "X-Boom-Reason";
383
+ };
384
+ /**
385
+ * Default threshold values based on benchmark data:
386
+ * - Below 1KB: JSON is often faster (native C++ implementation)
387
+ * - 1KB-10KB: Depends on structure (BOOM better for tabular)
388
+ * - 10KB-100KB: BOOM consistently faster
389
+ * - Above 100KB: BOOM significantly faster (40-70% smaller, 2-5x faster decode)
390
+ */
391
+ declare const DEFAULT_THRESHOLDS: {
392
+ /** Below this, use JSON (default: 1KB) */
393
+ readonly minSize: 1024;
394
+ /** Above this, prefer BOOM (default: 10KB) */
395
+ readonly preferSize: 10240;
396
+ /** Above this, always use BOOM (default: 100KB) */
397
+ readonly forceSize: 102400;
398
+ };
399
+ /**
400
+ * Configuration for automatic format selection based on payload size.
401
+ */
402
+ interface BoomThresholdConfig {
403
+ /** Below this size in bytes, use JSON (default: 1024) */
404
+ minSize?: number;
405
+ /** Above this size in bytes, prefer BOOM (default: 10240) */
406
+ preferSize?: number;
407
+ /** Above this size in bytes, always use BOOM (default: 102400) */
408
+ forceSize?: number;
409
+ /** Enable automatic format detection (default: true) */
410
+ autoDetect?: boolean;
411
+ /** Honor client X-Boom-Expected-Size hints (default: true) */
412
+ respectClientHint?: boolean;
413
+ }
414
+ /**
415
+ * Set global threshold configuration for automatic format selection.
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * setThresholdConfig({
420
+ * minSize: 2048, // Use JSON below 2KB
421
+ * forceSize: 50000, // Force BOOM above 50KB
422
+ * });
423
+ * ```
424
+ */
425
+ declare function setThresholdConfig(config: BoomThresholdConfig): void;
426
+ /**
427
+ * Get the current global threshold configuration.
428
+ */
429
+ declare function getThresholdConfig(): Required<BoomThresholdConfig>;
430
+ /**
431
+ * Select the optimal format based on payload size and configuration.
432
+ *
433
+ * @param payloadSize - Size of the payload in bytes
434
+ * @param config - Optional threshold configuration (uses global if not provided)
435
+ * @param clientHint - Optional client hint ('large', 'small', or byte count)
436
+ * @returns The recommended BoomMode and reason
437
+ *
438
+ * @example
439
+ * ```typescript
440
+ * const { mode, reason } = selectFormat(500);
441
+ * // mode: 'json', reason: 'size-below-threshold'
442
+ *
443
+ * const { mode, reason } = selectFormat(200000);
444
+ * // mode: 'boom-binary', reason: 'size-above-force'
445
+ *
446
+ * const { mode, reason } = selectFormat(500, undefined, 'large');
447
+ * // mode: 'boom-binary', reason: 'client-hint'
448
+ * ```
449
+ */
450
+ declare function selectFormat(payloadSize: number, config?: BoomThresholdConfig, clientHint?: string): {
451
+ mode: BoomMode;
452
+ reason: string;
453
+ };
454
+ /**
455
+ * Estimate the encoded size of a value (for format selection before encoding).
456
+ * This is a fast approximation - actual encoded size may vary.
457
+ *
458
+ * @param value - The value to estimate
459
+ * @returns Estimated size in bytes
460
+ */
461
+ declare function estimateSize(value: BoomValue): number;
462
+ /**
463
+ * Create threshold headers for server responses.
464
+ * Servers should include these to announce their threshold policy.
465
+ *
466
+ * @param config - Optional custom thresholds (uses global if not provided)
467
+ * @returns Headers object to spread into response
468
+ *
469
+ * @example
470
+ * ```typescript
471
+ * // Express middleware
472
+ * app.use((req, res, next) => {
473
+ * const headers = createThresholdHeaders();
474
+ * Object.entries(headers).forEach(([k, v]) => res.setHeader(k, v));
475
+ * next();
476
+ * });
477
+ * ```
478
+ */
479
+ declare function createThresholdHeaders(config?: BoomThresholdConfig): Record<string, string>;
480
+ /**
481
+ * Parse threshold configuration from response headers.
482
+ *
483
+ * @param headers - Response headers (Headers object or plain object)
484
+ * @returns Parsed threshold config or null if no threshold headers present
485
+ */
486
+ declare function parseThresholdHeaders(headers: Headers | Record<string, string>): BoomThresholdConfig | null;
487
+ /**
488
+ * Set the global BOOM mode for all HTTP helpers.
489
+ * - 'boom-binary': Binary format (smallest, fastest - production)
490
+ * - 'boom-text': Text format (readable BOOM syntax - debugging)
491
+ * - 'json': Standard JSON (maximum compatibility - debugging)
492
+ */
493
+ declare function setBoomMode(mode: BoomMode): void;
494
+ /**
495
+ * Get the current global BOOM mode.
496
+ */
497
+ declare function getBoomMode(): BoomMode;
498
+ interface BoomFetchOptions$1 extends Omit<RequestInit, 'body' | 'mode'> {
499
+ body?: BoomValue;
500
+ params?: Record<string, string | number | boolean>;
501
+ /** BOOM mode: 'boom' for binary (production), 'json' for debugging */
502
+ boomMode?: BoomMode;
503
+ /** Standard fetch mode (cors, no-cors, same-origin) */
504
+ mode?: RequestMode;
505
+ /** Enable auto-format selection based on payload size (default: false for backwards compat) */
506
+ autoFormat?: boolean;
507
+ /** Threshold configuration for auto-format selection */
508
+ threshold?: BoomThresholdConfig;
509
+ /** Hint to server about expected response size ('large', 'small', or byte count) */
510
+ expectedSize?: 'large' | 'small' | number;
511
+ }
512
+ /**
513
+ * Drop-in fetch replacement with automatic BOOM encoding/decoding.
514
+ * Supports easy switching between JSON (debugging) and BOOM (production).
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * // GET request
519
+ * const users = await boomFetch('/api/users');
520
+ *
521
+ * // POST request
522
+ * const newUser = await boomFetch('/api/users', {
523
+ * method: 'POST',
524
+ * body: { name: 'Alice', role: 'admin' }
525
+ * });
526
+ *
527
+ * // With query params
528
+ * const admins = await boomFetch('/api/users', {
529
+ * params: { role: 'admin', limit: 10 }
530
+ * });
531
+ *
532
+ * // Force JSON mode for debugging
533
+ * const data = await boomFetch('/api/users', { boomMode: 'json' });
534
+ *
535
+ * // Auto-format selection based on payload size
536
+ * const largeData = await boomFetch('/api/data', {
537
+ * body: hugeDataset,
538
+ * autoFormat: true // Automatically uses BOOM for large payloads
539
+ * });
540
+ *
541
+ * // Hint to server about expected response size
542
+ * const report = await boomFetch('/api/reports/full', {
543
+ * expectedSize: 'large' // Server will use BOOM format
544
+ * });
545
+ * ```
546
+ */
547
+ declare function boomFetch$1<T = BoomValue>(url: string, options?: BoomFetchOptions$1): Promise<T>;
548
+ interface BoomAxiosConfig$1 {
549
+ baseURL?: string;
550
+ headers?: Record<string, string>;
551
+ boomMode?: BoomMode;
552
+ }
553
+ interface BoomAxiosInstance$1 {
554
+ get<T = BoomValue>(url: string, config?: {
555
+ params?: Record<string, string | number | boolean>;
556
+ }): Promise<{
557
+ data: T;
558
+ }>;
559
+ post<T = BoomValue>(url: string, data?: BoomValue): Promise<{
560
+ data: T;
561
+ }>;
562
+ put<T = BoomValue>(url: string, data?: BoomValue): Promise<{
563
+ data: T;
564
+ }>;
565
+ patch<T = BoomValue>(url: string, data?: BoomValue): Promise<{
566
+ data: T;
567
+ }>;
568
+ delete<T = BoomValue>(url: string): Promise<{
569
+ data: T;
570
+ }>;
571
+ setBoomMode(mode: BoomMode): void;
572
+ }
573
+ /**
574
+ * Create an axios-like instance with automatic BOOM encoding/decoding.
575
+ *
576
+ * @example
577
+ * ```typescript
578
+ * const api = createBoomAxios({
579
+ * baseURL: 'https://api.example.com',
580
+ * boomMode: 'boom-binary'
581
+ * });
582
+ *
583
+ * const { data: users } = await api.get('/users');
584
+ * const { data: user } = await api.post('/users', { name: 'Alice' });
585
+ *
586
+ * // Switch to JSON for debugging
587
+ * api.setBoomMode('json');
588
+ * ```
589
+ */
590
+ declare function createBoomAxios$1(config?: BoomAxiosConfig$1): BoomAxiosInstance$1;
591
+ interface BoomGraphQLConfig$1 {
592
+ url: string;
593
+ headers?: Record<string, string>;
594
+ boomMode?: BoomMode;
595
+ }
596
+ interface BoomGraphQLClient$1 {
597
+ query<T = Record<string, unknown>>(query: string, variables?: Record<string, unknown>): Promise<T>;
598
+ mutate<T = Record<string, unknown>>(mutation: string, variables?: Record<string, unknown>): Promise<T>;
599
+ setBoomMode(mode: BoomMode): void;
600
+ }
601
+ /**
602
+ * Create a GraphQL client with automatic BOOM encoding/decoding.
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * const gql = createBoomGraphQL({
607
+ * url: '/graphql',
608
+ * boomMode: 'boom-binary'
609
+ * });
610
+ *
611
+ * const { users } = await gql.query(`
612
+ * query { users { id name } }
613
+ * `);
614
+ *
615
+ * const { createUser } = await gql.mutate(`
616
+ * mutation CreateUser($name: String!) {
617
+ * createUser(name: $name) { id name }
618
+ * }
619
+ * `, { name: 'Alice' });
620
+ * ```
621
+ */
622
+ declare function createBoomGraphQL$1(config: BoomGraphQLConfig$1): BoomGraphQLClient$1;
623
+
624
+ /**
625
+ * BOOM Fetch Adapter
626
+ * Drop-in fetch replacement with automatic BOOM encoding/decoding
627
+ * @module boom-format/http/fetch
628
+ */
629
+
630
+ interface BoomFetchOptions extends Omit<RequestInit, 'body' | 'mode'> {
631
+ body?: BoomValue$1;
632
+ params?: Record<string, string | number | boolean>;
633
+ boomMode?: BoomMode$1;
634
+ mode?: RequestMode;
635
+ autoFormat?: boolean;
636
+ threshold?: BoomThresholdConfig$1;
637
+ expectedSize?: 'large' | 'small' | number;
638
+ }
639
+ /**
640
+ * Drop-in fetch replacement with automatic BOOM encoding/decoding
641
+ */
642
+ declare function boomFetch<T = BoomValue$1>(url: string, options?: BoomFetchOptions): Promise<T>;
643
+
644
+ /**
645
+ * BOOM Axios-like Adapter
646
+ * Create axios-style instances with automatic BOOM encoding/decoding
647
+ * @module boom-format/http/axios
648
+ */
649
+
650
+ interface BoomAxiosConfig {
651
+ baseURL?: string;
652
+ headers?: Record<string, string>;
653
+ boomMode?: BoomMode$1;
654
+ }
655
+ interface BoomAxiosInstance {
656
+ get<T = BoomValue$1>(url: string, config?: {
657
+ params?: Record<string, string | number | boolean>;
658
+ }): Promise<{
659
+ data: T;
660
+ }>;
661
+ post<T = BoomValue$1>(url: string, data?: BoomValue$1): Promise<{
662
+ data: T;
663
+ }>;
664
+ put<T = BoomValue$1>(url: string, data?: BoomValue$1): Promise<{
665
+ data: T;
666
+ }>;
667
+ patch<T = BoomValue$1>(url: string, data?: BoomValue$1): Promise<{
668
+ data: T;
669
+ }>;
670
+ delete<T = BoomValue$1>(url: string): Promise<{
671
+ data: T;
672
+ }>;
673
+ setBoomMode(mode: BoomMode$1): void;
674
+ }
675
+ /**
676
+ * Create an axios-like instance with automatic BOOM encoding/decoding
677
+ */
678
+ declare function createBoomAxios(config?: BoomAxiosConfig): BoomAxiosInstance;
679
+
680
+ /**
681
+ * BOOM GraphQL Adapter
682
+ * GraphQL client with automatic BOOM encoding/decoding
683
+ * @module boom-format/http/graphql
684
+ */
685
+
686
+ interface BoomGraphQLConfig {
687
+ url: string;
688
+ headers?: Record<string, string>;
689
+ boomMode?: BoomMode$1;
690
+ }
691
+ interface BoomGraphQLClient {
692
+ query<T = Record<string, unknown>>(query: string, variables?: Record<string, unknown>): Promise<T>;
693
+ mutate<T = Record<string, unknown>>(mutation: string, variables?: Record<string, unknown>): Promise<T>;
694
+ setBoomMode(mode: BoomMode$1): void;
695
+ }
696
+ /**
697
+ * Create a GraphQL client with automatic BOOM encoding/decoding
698
+ */
699
+ declare function createBoomGraphQL(config: BoomGraphQLConfig): BoomGraphQLClient;
700
+
701
+ /**
702
+ * BOOM Browser Utilities
703
+ * DOM integration for script elements with BOOM data
704
+ * @module boom-format/browser
705
+ */
706
+
707
+ /**
708
+ * Process all <script type="text/boom"> elements in the document
709
+ * Parses BOOM text format and stores result on the element
710
+ */
711
+ declare function processBoomScripts(): Map<string, BoomValue$1>;
712
+ /**
713
+ * Get parsed data from a specific BOOM script element
714
+ */
715
+ declare function getBoomData(scriptId: string): BoomValue$1 | undefined;
716
+ /**
717
+ * Auto-initialise BOOM script processing when DOM is ready
718
+ */
719
+ declare function autoInit(): void;
720
+
721
+ /**
722
+ * BOOM Constants
723
+ * @module boom-format/constants
724
+ */
725
+
726
+ declare const MAGIC: Uint8Array<ArrayBuffer>;
727
+ declare const VERSION = 1;
728
+
729
+ /**
730
+ * BOOM - Binary Object Optimised Markup
731
+ * A compact binary serialization format with readable debug mode
732
+ *
733
+ * @module boom-format
734
+ * @version 1.0.0
735
+ * @license MIT
736
+ */
737
+
738
+ declare const _default: {
739
+ encode: typeof encode;
740
+ decode: typeof decode;
741
+ stringify: typeof stringify;
742
+ parseText: typeof parseText;
743
+ fromJSON: typeof fromJSON;
744
+ toJSON: typeof toJSON;
745
+ compare: typeof compare;
746
+ encodeWithLength: typeof encodeWithLength;
747
+ decodeFromLengthPrefixed: typeof decodeFromLengthPrefixed;
748
+ StreamDecoder: typeof StreamDecoder;
749
+ processBoomScripts: typeof processBoomScripts$1;
750
+ getBoomData: typeof getBoomData$1;
751
+ autoInit: typeof autoInit$1;
752
+ BoomError: typeof BoomError;
753
+ setBoomMode: typeof setBoomMode;
754
+ getBoomMode: typeof getBoomMode;
755
+ boomFetch: typeof boomFetch$1;
756
+ createBoomAxios: typeof createBoomAxios$1;
757
+ createBoomGraphQL: typeof createBoomGraphQL$1;
758
+ BoomHeaders: {
759
+ readonly MIN_SIZE: "X-Boom-Min-Size";
760
+ readonly PREFER_SIZE: "X-Boom-Prefer-Size";
761
+ readonly FORCE_SIZE: "X-Boom-Force-Size";
762
+ readonly EXPECTED_SIZE: "X-Boom-Expected-Size";
763
+ readonly FORMAT: "X-Boom-Format";
764
+ readonly REASON: "X-Boom-Reason";
765
+ };
766
+ DEFAULT_THRESHOLDS: {
767
+ readonly minSize: 1024;
768
+ readonly preferSize: 10240;
769
+ readonly forceSize: 102400;
770
+ };
771
+ setThresholdConfig: typeof setThresholdConfig;
772
+ getThresholdConfig: typeof getThresholdConfig;
773
+ selectFormat: typeof selectFormat;
774
+ estimateSize: typeof estimateSize;
775
+ createThresholdHeaders: typeof createThresholdHeaders;
776
+ parseThresholdHeaders: typeof parseThresholdHeaders;
777
+ };
778
+
779
+ export { BOOM_DICTIONARY_V1, VERSION as BOOM_VERSION, type BoomArray$1 as BoomArray, type BoomAxiosConfig, type BoomAxiosInstance, BoomError, type BoomFetchOptions, type BoomGraphQLClient, type BoomGraphQLConfig, BoomHeaders, type BoomMode$1 as BoomMode, type BoomObject$1 as BoomObject, type BoomOptions$1 as BoomOptions, type BoomPrimitive$1 as BoomPrimitive, type BoomTextOptions$1 as BoomTextOptions, type BoomThresholdConfig$1 as BoomThresholdConfig, type BoomValue$1 as BoomValue, ByteReader, ByteWriter, DEFAULT_THRESHOLDS, type DictionaryAnalysisResult, MAGIC, type SmallestEncodeResult$1 as SmallestEncodeResult, StreamDecoder, analyzeDictionary, autoInit, boomFetch, compare, createBoomAxios, createBoomGraphQL, createThresholdHeaders, decode, decodeFromLengthPrefixed, decodeSmallest, _default as default, encode, encodeSmallest, encodeWithLength, estimateSize, fromJSON, fromJSONDirect, getBoomData, getBoomMode, getThresholdConfig, parseText, parseThresholdHeaders, processBoomScripts, selectFormat, setBoomMode, setThresholdConfig, stringify, toJSON, zigzagDecode, zigzagEncode };