blaizejs 0.5.0 → 0.5.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.
- package/dist/{chunk-6XBGCGAR.js → chunk-6G464Q37.js} +3 -3
- package/dist/{chunk-J7KS32ZT.js → chunk-NA2GUVHF.js} +3 -3
- package/dist/chunk-VAD7G4RR.js +11 -0
- package/dist/chunk-VAD7G4RR.js.map +1 -0
- package/dist/{chunk-2LP25IUP.js → chunk-XZOKQ5VF.js} +3 -3
- package/dist/{chunk-6A3MHG3V.js → chunk-Y7KAZMOI.js} +3 -3
- package/dist/index.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +808 -698
- package/dist/index.d.ts +808 -698
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/{internal-server-error-BDHJW7WB.js → internal-server-error-4S64KATC.js} +3 -3
- package/dist/{payload-too-large-error-PX6RP7T6.js → payload-too-large-error-BC6YVP2R.js} +3 -3
- package/dist/{unsupported-media-type-error-IXHPPRCO.js → unsupported-media-type-error-FV554WCH.js} +3 -3
- package/dist/{validation-error-FNJKIDG6.js → validation-error-ZLDRDHW5.js} +3 -3
- package/package.json +2 -2
- package/dist/chunk-QD45PRU4.js +0 -11
- package/dist/chunk-QD45PRU4.js.map +0 -1
- /package/dist/{chunk-6XBGCGAR.js.map → chunk-6G464Q37.js.map} +0 -0
- /package/dist/{chunk-J7KS32ZT.js.map → chunk-NA2GUVHF.js.map} +0 -0
- /package/dist/{chunk-2LP25IUP.js.map → chunk-XZOKQ5VF.js.map} +0 -0
- /package/dist/{chunk-6A3MHG3V.js.map → chunk-Y7KAZMOI.js.map} +0 -0
- /package/dist/{internal-server-error-BDHJW7WB.js.map → internal-server-error-4S64KATC.js.map} +0 -0
- /package/dist/{payload-too-large-error-PX6RP7T6.js.map → payload-too-large-error-BC6YVP2R.js.map} +0 -0
- /package/dist/{unsupported-media-type-error-IXHPPRCO.js.map → unsupported-media-type-error-FV554WCH.js.map} +0 -0
- /package/dist/{validation-error-FNJKIDG6.js.map → validation-error-ZLDRDHW5.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -135,6 +135,16 @@ interface ValidationFieldError {
|
|
|
135
135
|
/** Expected type or format */
|
|
136
136
|
expectedType?: string;
|
|
137
137
|
}
|
|
138
|
+
interface ServiceNotAvailableDetails {
|
|
139
|
+
/** Service that's unavailable */
|
|
140
|
+
service?: string;
|
|
141
|
+
/** Seconds to wait before retry */
|
|
142
|
+
retryAfter?: number;
|
|
143
|
+
/** Why service is unavailable */
|
|
144
|
+
reason?: 'maintenance' | 'overload' | 'circuit_breaker' | 'dependency_down';
|
|
145
|
+
/** Additional context */
|
|
146
|
+
[key: string]: unknown;
|
|
147
|
+
}
|
|
138
148
|
/**
|
|
139
149
|
* Validation error details structure
|
|
140
150
|
*
|
|
@@ -210,7 +220,9 @@ declare enum ErrorType {
|
|
|
210
220
|
/** SSE buffer overflow (503) */
|
|
211
221
|
SSE_BUFFER_OVERFLOW = "SSE_BUFFER_OVERFLOW",
|
|
212
222
|
/** SSE stream closed (410) */
|
|
213
|
-
SSE_STREAM_CLOSED = "SSE_STREAM_CLOSED"
|
|
223
|
+
SSE_STREAM_CLOSED = "SSE_STREAM_CLOSED",
|
|
224
|
+
/** Service temporarily unavailable (503) */
|
|
225
|
+
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE"
|
|
214
226
|
}
|
|
215
227
|
/**
|
|
216
228
|
* Error severity levels for logging and monitoring
|
|
@@ -1369,853 +1381,891 @@ type CreateOptionsRoute = <TState extends State = State, TServices extends Servi
|
|
|
1369
1381
|
declare function compose(middlewareStack: Middleware[]): MiddlewareFunction;
|
|
1370
1382
|
|
|
1371
1383
|
/**
|
|
1372
|
-
*
|
|
1373
|
-
*/
|
|
1374
|
-
declare function create$2<TState = {}, TServices = {}>(handlerOrOptions: MiddlewareFunction | MiddlewareOptions): Middleware<TState, TServices>;
|
|
1375
|
-
/**
|
|
1376
|
-
* Create a middleware that only contributes state (no services)
|
|
1377
|
-
* Convenience helper for state-only middleware
|
|
1378
|
-
*
|
|
1379
|
-
* @template T - Type of state to contribute
|
|
1380
|
-
* @param handler - Middleware function that adds state
|
|
1381
|
-
* @returns Middleware that contributes state only
|
|
1382
|
-
*
|
|
1383
|
-
*/
|
|
1384
|
-
declare function stateMiddleware<T = {}>(handler: MiddlewareFunction): Middleware<T, {}>;
|
|
1385
|
-
/**
|
|
1386
|
-
* Create a middleware that only contributes services (no state)
|
|
1387
|
-
* Convenience helper for service-only middleware
|
|
1384
|
+
* CORS Types for BlaizeJS Framework
|
|
1388
1385
|
*
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1391
|
-
* @returns Middleware that contributes services only
|
|
1386
|
+
* Comprehensive type definitions for W3C-compliant CORS middleware
|
|
1387
|
+
* with support for string, regex, and async function origin validation.
|
|
1392
1388
|
*
|
|
1389
|
+
* @module @blaizejs/types/cors
|
|
1393
1390
|
*/
|
|
1394
|
-
declare function serviceMiddleware<T = {}>(handler: MiddlewareFunction): Middleware<{}, T>;
|
|
1395
1391
|
|
|
1396
1392
|
/**
|
|
1397
|
-
*
|
|
1398
|
-
* @template T - The type of data payload
|
|
1393
|
+
* Origin configuration type supporting multiple validation methods
|
|
1399
1394
|
*
|
|
1400
1395
|
* @example
|
|
1401
1396
|
* ```typescript
|
|
1402
|
-
*
|
|
1403
|
-
*
|
|
1404
|
-
* event: 'message',
|
|
1405
|
-
* data: { message: 'Hello, world!' },
|
|
1406
|
-
* retry: 5000
|
|
1407
|
-
* };
|
|
1408
|
-
* ```
|
|
1409
|
-
*/
|
|
1410
|
-
interface SSEEvent<T = unknown> {
|
|
1411
|
-
/** Unique identifier for the event */
|
|
1412
|
-
id: string;
|
|
1413
|
-
/** Event type/name for client-side event listeners */
|
|
1414
|
-
event: string;
|
|
1415
|
-
/** The actual data payload of the event */
|
|
1416
|
-
data: T;
|
|
1417
|
-
/** Optional retry interval in milliseconds for reconnection */
|
|
1418
|
-
retry?: number;
|
|
1419
|
-
}
|
|
1420
|
-
/**
|
|
1421
|
-
* Backpressure handling strategies for SSE streams
|
|
1397
|
+
* // String origin (exact match)
|
|
1398
|
+
* const origin: CorsOrigin = 'https://example.com';
|
|
1422
1399
|
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
* - `close`: Close the stream when buffer limit is reached
|
|
1426
|
-
*/
|
|
1427
|
-
type SSEBufferStrategy = 'drop-oldest' | 'drop-newest' | 'close';
|
|
1428
|
-
/**
|
|
1429
|
-
* Configuration options for SSE streams
|
|
1400
|
+
* // RegExp pattern
|
|
1401
|
+
* const origin: CorsOrigin = /^https:\/\/.*\.example\.com$/;
|
|
1430
1402
|
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1434
|
-
* autoClose: true,
|
|
1435
|
-
* maxBufferSize: 100,
|
|
1436
|
-
* bufferStrategy: 'drop-oldest'
|
|
1403
|
+
* // Dynamic validation function
|
|
1404
|
+
* const origin: CorsOrigin = async (origin, ctx) => {
|
|
1405
|
+
* return await checkOriginAllowed(origin, ctx?.state.user);
|
|
1437
1406
|
* };
|
|
1407
|
+
*
|
|
1408
|
+
* // Array of mixed types
|
|
1409
|
+
* const origin: CorsOrigin = [
|
|
1410
|
+
* 'https://localhost:3000',
|
|
1411
|
+
* /^https:\/\/.*\.example\.com$/,
|
|
1412
|
+
* (origin) => origin.endsWith('.trusted.com')
|
|
1413
|
+
* ];
|
|
1438
1414
|
* ```
|
|
1439
1415
|
*/
|
|
1440
|
-
|
|
1441
|
-
/** ms between heartbeat pings (0 to disable) */
|
|
1442
|
-
heartbeatInterval?: number;
|
|
1443
|
-
/** Maximum size in bytes for a single event */
|
|
1444
|
-
maxEventSize?: number;
|
|
1445
|
-
/** Automatically close stream when client disconnects */
|
|
1446
|
-
autoClose?: boolean;
|
|
1447
|
-
/** Maximum number of events to buffer before applying strategy */
|
|
1448
|
-
maxBufferSize?: number;
|
|
1449
|
-
/** Strategy to handle buffer overflow conditions */
|
|
1450
|
-
bufferStrategy?: SSEBufferStrategy;
|
|
1451
|
-
}
|
|
1416
|
+
type CorsOrigin = string | RegExp | ((origin: string, ctx?: Context<any, any>) => boolean | Promise<boolean>) | Array<string | RegExp | ((origin: string, ctx?: Context<any, any>) => boolean | Promise<boolean>)>;
|
|
1452
1417
|
/**
|
|
1453
|
-
*
|
|
1418
|
+
* HTTP methods that can be allowed in CORS
|
|
1419
|
+
* Based on W3C CORS specification
|
|
1454
1420
|
*/
|
|
1455
|
-
type
|
|
1421
|
+
type CorsHttpMethod = HttpMethod | 'CONNECT' | 'TRACE';
|
|
1456
1422
|
/**
|
|
1457
|
-
*
|
|
1423
|
+
* Main CORS configuration options
|
|
1458
1424
|
*
|
|
1459
1425
|
* @example
|
|
1460
1426
|
* ```typescript
|
|
1461
|
-
* const
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
* stream.sendError(new Error('Processing failed'));
|
|
1468
|
-
*
|
|
1469
|
-
* // Clean up on close
|
|
1470
|
-
* stream.onClose(() => {
|
|
1471
|
-
* console.log('Client disconnected');
|
|
1472
|
-
* });
|
|
1473
|
-
*
|
|
1474
|
-
* // Close stream
|
|
1475
|
-
* stream.close();
|
|
1427
|
+
* const corsOptions: CorsOptions = {
|
|
1428
|
+
* origin: 'https://example.com',
|
|
1429
|
+
* methods: ['GET', 'POST'],
|
|
1430
|
+
* credentials: true,
|
|
1431
|
+
* maxAge: 86400
|
|
1432
|
+
* };
|
|
1476
1433
|
* ```
|
|
1477
1434
|
*/
|
|
1478
|
-
interface
|
|
1435
|
+
interface CorsOptions {
|
|
1479
1436
|
/**
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1437
|
+
* Configures the Access-Control-Allow-Origin header
|
|
1438
|
+
*
|
|
1439
|
+
* Possible values:
|
|
1440
|
+
* - `true`: Allow all origins (sets to '*' unless credentials is true, then reflects origin)
|
|
1441
|
+
* - `false`: Disable CORS (no headers set)
|
|
1442
|
+
* - `string`: Specific origin to allow
|
|
1443
|
+
* - `RegExp`: Pattern to match origins
|
|
1444
|
+
* - `function`: Custom validation logic
|
|
1445
|
+
* - `array`: Multiple origin configurations
|
|
1446
|
+
*
|
|
1447
|
+
* @default false
|
|
1484
1448
|
*/
|
|
1485
|
-
|
|
1449
|
+
origin?: boolean | CorsOrigin;
|
|
1486
1450
|
/**
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1451
|
+
* Configures the Access-Control-Allow-Methods header
|
|
1452
|
+
*
|
|
1453
|
+
* @default ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE']
|
|
1454
|
+
* @example ['GET', 'POST']
|
|
1489
1455
|
*/
|
|
1490
|
-
|
|
1456
|
+
methods?: CorsHttpMethod[] | string;
|
|
1491
1457
|
/**
|
|
1492
|
-
*
|
|
1458
|
+
* Configures the Access-Control-Allow-Headers header
|
|
1459
|
+
*
|
|
1460
|
+
* Pass an array of allowed headers or a comma-delimited string.
|
|
1461
|
+
*
|
|
1462
|
+
* @default Request's Access-Control-Request-Headers header value
|
|
1463
|
+
* @example ['Content-Type', 'Authorization']
|
|
1493
1464
|
*/
|
|
1494
|
-
|
|
1465
|
+
allowedHeaders?: string[] | string;
|
|
1495
1466
|
/**
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1467
|
+
* Configures the Access-Control-Expose-Headers header
|
|
1468
|
+
*
|
|
1469
|
+
* Headers that the browser is allowed to access.
|
|
1470
|
+
*
|
|
1471
|
+
* @default []
|
|
1472
|
+
* @example ['Content-Range', 'X-Content-Range']
|
|
1498
1473
|
*/
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
/**
|
|
1502
|
-
* Extended SSE stream with additional control methods
|
|
1503
|
-
*/
|
|
1504
|
-
interface SSEStreamExtended extends SSEStream {
|
|
1505
|
-
readonly id: string;
|
|
1506
|
-
[Symbol.asyncIterator](): AsyncGenerator<BufferedEvent, void, unknown>;
|
|
1507
|
-
/** Current connection state */
|
|
1508
|
-
readonly state: SSEConnectionState;
|
|
1509
|
-
/** Number of events in the buffer */
|
|
1510
|
-
readonly bufferSize: number;
|
|
1511
|
-
/** Check if stream is writable */
|
|
1512
|
-
readonly isWritable: boolean;
|
|
1474
|
+
exposedHeaders?: string[] | string;
|
|
1513
1475
|
/**
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1476
|
+
* Configures the Access-Control-Allow-Credentials header
|
|
1477
|
+
*
|
|
1478
|
+
* Set to true to allow credentials (cookies, authorization headers, TLS client certificates).
|
|
1479
|
+
* Note: Cannot be used with origin: '*' for security reasons.
|
|
1480
|
+
*
|
|
1481
|
+
* @default false
|
|
1516
1482
|
*/
|
|
1517
|
-
|
|
1483
|
+
credentials?: boolean;
|
|
1518
1484
|
/**
|
|
1519
|
-
*
|
|
1520
|
-
*
|
|
1485
|
+
* Configures the Access-Control-Max-Age header in seconds
|
|
1486
|
+
*
|
|
1487
|
+
* Indicates how long browsers can cache preflight response.
|
|
1488
|
+
* Set to -1 to disable caching.
|
|
1489
|
+
*
|
|
1490
|
+
* @default undefined (browser decides)
|
|
1491
|
+
* @example 86400 // 24 hours
|
|
1521
1492
|
*/
|
|
1522
|
-
|
|
1493
|
+
maxAge?: number;
|
|
1523
1494
|
/**
|
|
1524
|
-
*
|
|
1495
|
+
* Whether to pass the CORS preflight response to the next handler
|
|
1496
|
+
*
|
|
1497
|
+
* When false, the preflight response is sent immediately.
|
|
1498
|
+
* When true, control passes to the next middleware/handler.
|
|
1499
|
+
*
|
|
1500
|
+
* @default false
|
|
1525
1501
|
*/
|
|
1526
|
-
|
|
1527
|
-
|
|
1502
|
+
preflightContinue?: boolean;
|
|
1503
|
+
/**
|
|
1504
|
+
* HTTP status code for successful OPTIONS requests
|
|
1505
|
+
*
|
|
1506
|
+
* Some legacy browsers require 200, while 204 is more correct.
|
|
1507
|
+
*
|
|
1508
|
+
* @default 204
|
|
1509
|
+
*/
|
|
1510
|
+
optionsSuccessStatus?: number;
|
|
1528
1511
|
}
|
|
1529
1512
|
/**
|
|
1530
|
-
*
|
|
1513
|
+
* Internal CORS validation result
|
|
1514
|
+
* Used by middleware implementation
|
|
1531
1515
|
*/
|
|
1532
|
-
interface
|
|
1533
|
-
/**
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
/**
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1516
|
+
interface CorsValidationResult {
|
|
1517
|
+
/**
|
|
1518
|
+
* Whether the origin is allowed
|
|
1519
|
+
*/
|
|
1520
|
+
allowed: boolean;
|
|
1521
|
+
/**
|
|
1522
|
+
* The origin value to set in the header
|
|
1523
|
+
* Can be '*', specific origin, or 'null'
|
|
1524
|
+
*/
|
|
1525
|
+
origin?: string;
|
|
1526
|
+
/**
|
|
1527
|
+
* Whether to add Vary: Origin header
|
|
1528
|
+
*/
|
|
1529
|
+
vary?: boolean;
|
|
1543
1530
|
}
|
|
1544
1531
|
/**
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1547
|
-
*/
|
|
1548
|
-
type SSEEventHandler<T = unknown> = (event: SSEEvent<T>) => void | Promise<void>;
|
|
1549
|
-
/**
|
|
1550
|
-
* SSE event listener registration
|
|
1532
|
+
* CORS preflight request information
|
|
1533
|
+
* Extracted from OPTIONS request headers
|
|
1551
1534
|
*/
|
|
1552
|
-
interface
|
|
1553
|
-
/**
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
|
|
1535
|
+
interface CorsPreflightInfo {
|
|
1536
|
+
/**
|
|
1537
|
+
* The origin making the request
|
|
1538
|
+
*/
|
|
1539
|
+
origin?: string;
|
|
1540
|
+
/**
|
|
1541
|
+
* The method that will be used in the actual request
|
|
1542
|
+
* From Access-Control-Request-Method header
|
|
1543
|
+
*/
|
|
1544
|
+
requestedMethod?: string;
|
|
1545
|
+
/**
|
|
1546
|
+
* The headers that will be sent in the actual request
|
|
1547
|
+
* From Access-Control-Request-Headers header
|
|
1548
|
+
*/
|
|
1549
|
+
requestedHeaders?: string[];
|
|
1559
1550
|
}
|
|
1560
1551
|
/**
|
|
1561
|
-
*
|
|
1552
|
+
* Cache entry for origin validation results
|
|
1553
|
+
* Used for performance optimization
|
|
1562
1554
|
*/
|
|
1563
|
-
interface
|
|
1564
|
-
/**
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
/**
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
/**
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1555
|
+
interface CorsOriginCacheEntry {
|
|
1556
|
+
/**
|
|
1557
|
+
* Whether the origin is allowed
|
|
1558
|
+
*/
|
|
1559
|
+
allowed: boolean;
|
|
1560
|
+
/**
|
|
1561
|
+
* When this cache entry expires (timestamp)
|
|
1562
|
+
*/
|
|
1563
|
+
expiresAt: number;
|
|
1564
|
+
/**
|
|
1565
|
+
* Optional user identifier for cache key
|
|
1566
|
+
*/
|
|
1567
|
+
userId?: string;
|
|
1576
1568
|
}
|
|
1577
1569
|
/**
|
|
1578
|
-
*
|
|
1570
|
+
* Configuration for CORS origin validation cache
|
|
1579
1571
|
*/
|
|
1580
|
-
interface
|
|
1572
|
+
interface CorsOriginCacheConfig {
|
|
1581
1573
|
/**
|
|
1582
|
-
*
|
|
1583
|
-
* @
|
|
1584
|
-
* @param options - Stream configuration options
|
|
1574
|
+
* Time-to-live for cache entries in milliseconds
|
|
1575
|
+
* @default 60000 (1 minute)
|
|
1585
1576
|
*/
|
|
1586
|
-
|
|
1577
|
+
ttl?: number;
|
|
1587
1578
|
/**
|
|
1588
|
-
*
|
|
1589
|
-
* @
|
|
1579
|
+
* Maximum number of entries in the cache
|
|
1580
|
+
* @default 1000
|
|
1590
1581
|
*/
|
|
1591
|
-
|
|
1582
|
+
maxSize?: number;
|
|
1592
1583
|
/**
|
|
1593
|
-
*
|
|
1594
|
-
* @
|
|
1595
|
-
* @param event - Event name
|
|
1596
|
-
* @param data - Event data
|
|
1584
|
+
* Whether to include user ID in cache key
|
|
1585
|
+
* @default true
|
|
1597
1586
|
*/
|
|
1598
|
-
|
|
1587
|
+
includeUserId?: boolean;
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Statistics for CORS middleware performance monitoring
|
|
1591
|
+
*/
|
|
1592
|
+
interface CorsStats {
|
|
1599
1593
|
/**
|
|
1600
|
-
*
|
|
1601
|
-
* @template T - Type of the event data
|
|
1602
|
-
* @param clientIds - Array of client IDs
|
|
1603
|
-
* @param event - Event name
|
|
1604
|
-
* @param data - Event data
|
|
1594
|
+
* Total number of CORS requests processed
|
|
1605
1595
|
*/
|
|
1606
|
-
|
|
1596
|
+
totalRequests: number;
|
|
1607
1597
|
/**
|
|
1608
|
-
*
|
|
1609
|
-
* @param clientId - Client identifier
|
|
1598
|
+
* Number of preflight requests handled
|
|
1610
1599
|
*/
|
|
1611
|
-
|
|
1600
|
+
preflightRequests: number;
|
|
1612
1601
|
/**
|
|
1613
|
-
*
|
|
1602
|
+
* Number of allowed origins
|
|
1614
1603
|
*/
|
|
1615
|
-
|
|
1604
|
+
allowedOrigins: number;
|
|
1616
1605
|
/**
|
|
1617
|
-
*
|
|
1606
|
+
* Number of denied origins
|
|
1618
1607
|
*/
|
|
1619
|
-
|
|
1608
|
+
deniedOrigins: number;
|
|
1609
|
+
/**
|
|
1610
|
+
* Cache hit rate for origin validation
|
|
1611
|
+
*/
|
|
1612
|
+
cacheHitRate: number;
|
|
1613
|
+
/**
|
|
1614
|
+
* Average origin validation time in milliseconds
|
|
1615
|
+
*/
|
|
1616
|
+
avgValidationTime: number;
|
|
1620
1617
|
}
|
|
1621
1618
|
/**
|
|
1622
|
-
*
|
|
1623
|
-
*/
|
|
1624
|
-
type RegistryResult<T> = {
|
|
1625
|
-
success: true;
|
|
1626
|
-
value: T;
|
|
1627
|
-
} | {
|
|
1628
|
-
success: false;
|
|
1629
|
-
error: string;
|
|
1630
|
-
};
|
|
1631
|
-
/**
|
|
1632
|
-
* Connection metadata stored in the registry
|
|
1619
|
+
* Cache entry type
|
|
1633
1620
|
*/
|
|
1634
|
-
interface
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
clientIp?: string;
|
|
1639
|
-
userAgent?: string;
|
|
1621
|
+
interface CacheEntry {
|
|
1622
|
+
allowed: boolean;
|
|
1623
|
+
expiresAt: number;
|
|
1624
|
+
lastAccessed: number;
|
|
1640
1625
|
}
|
|
1641
1626
|
/**
|
|
1642
|
-
*
|
|
1627
|
+
* Cache configuration
|
|
1643
1628
|
*/
|
|
1644
|
-
interface
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
clientIp?: string;
|
|
1648
|
-
userAgent?: string;
|
|
1649
|
-
}) => void;
|
|
1650
|
-
/** Remove a connection from the registry */
|
|
1651
|
-
remove: (id: string) => void;
|
|
1652
|
-
/** Get current connection count */
|
|
1653
|
-
count: () => number;
|
|
1654
|
-
/** Clean up inactive or closed connections */
|
|
1655
|
-
cleanup: () => void;
|
|
1656
|
-
/** Get connection by ID (for internal use) */
|
|
1657
|
-
get: (id: string) => SSEStream | undefined;
|
|
1658
|
-
/** Check if a connection exists */
|
|
1659
|
-
has: (id: string) => boolean;
|
|
1660
|
-
/** Get all connection IDs */
|
|
1661
|
-
getIds: () => string[];
|
|
1662
|
-
/** Shutdown the registry and close all connections */
|
|
1663
|
-
shutdown: () => void;
|
|
1629
|
+
interface CacheConfig {
|
|
1630
|
+
ttl: number;
|
|
1631
|
+
maxSize: number;
|
|
1664
1632
|
}
|
|
1633
|
+
|
|
1665
1634
|
/**
|
|
1666
|
-
*
|
|
1635
|
+
* Create CORS middleware with the specified options
|
|
1636
|
+
*
|
|
1637
|
+
* @param userOptions - CORS configuration options or boolean
|
|
1638
|
+
* @returns Middleware function that handles CORS
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```typescript
|
|
1642
|
+
* import { cors } from '@blaize-core/middleware/cors';
|
|
1643
|
+
*
|
|
1644
|
+
* // Development mode - allow all origins
|
|
1645
|
+
* server.use(cors(true));
|
|
1646
|
+
*
|
|
1647
|
+
* // Production - specific origin
|
|
1648
|
+
* server.use(cors({
|
|
1649
|
+
* origin: 'https://app.example.com',
|
|
1650
|
+
* credentials: true,
|
|
1651
|
+
* maxAge: 86400
|
|
1652
|
+
* }));
|
|
1653
|
+
*
|
|
1654
|
+
* // Multiple origins with regex
|
|
1655
|
+
* server.use(cors({
|
|
1656
|
+
* origin: [
|
|
1657
|
+
* 'https://app.example.com',
|
|
1658
|
+
* /^https:\/\/.*\.example\.com$/
|
|
1659
|
+
* ]
|
|
1660
|
+
* }));
|
|
1661
|
+
*
|
|
1662
|
+
* // Dynamic origin validation
|
|
1663
|
+
* server.use(cors({
|
|
1664
|
+
* origin: async (origin, ctx) => {
|
|
1665
|
+
* return await checkOriginAllowed(origin, ctx.state.user);
|
|
1666
|
+
* }
|
|
1667
|
+
* }));
|
|
1668
|
+
* ```
|
|
1667
1669
|
*/
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
}
|
|
1670
|
+
declare function cors(userOptions?: CorsOptions | boolean): Middleware;
|
|
1671
|
+
|
|
1671
1672
|
/**
|
|
1672
|
-
*
|
|
1673
|
+
* Create a middleware
|
|
1673
1674
|
*/
|
|
1674
|
-
|
|
1675
|
-
/** Parameter schema for validation */
|
|
1676
|
-
params?: P;
|
|
1677
|
-
/** Query schema for validation */
|
|
1678
|
-
query?: Q;
|
|
1679
|
-
/** Events schema for validation (SSE-specific, replaces response) */
|
|
1680
|
-
events?: E;
|
|
1681
|
-
}
|
|
1675
|
+
declare function create$2<TState = {}, TServices = {}>(handlerOrOptions: MiddlewareFunction | MiddlewareOptions): Middleware<TState, TServices>;
|
|
1682
1676
|
/**
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1677
|
+
* Create a middleware that only contributes state (no services)
|
|
1678
|
+
* Convenience helper for state-only middleware
|
|
1679
|
+
*
|
|
1680
|
+
* @template T - Type of state to contribute
|
|
1681
|
+
* @param handler - Middleware function that adds state
|
|
1682
|
+
* @returns Middleware that contributes state only
|
|
1683
|
+
*
|
|
1685
1684
|
*/
|
|
1686
|
-
|
|
1687
|
-
params: TParams) => Promise<void> | void;
|
|
1685
|
+
declare function stateMiddleware<T = {}>(handler: MiddlewareFunction): Middleware<T, {}>;
|
|
1688
1686
|
/**
|
|
1689
|
-
*
|
|
1690
|
-
*
|
|
1687
|
+
* Create a middleware that only contributes services (no state)
|
|
1688
|
+
* Convenience helper for service-only middleware
|
|
1689
|
+
*
|
|
1690
|
+
* @template T - Type of services to contribute
|
|
1691
|
+
* @param handler - Middleware function that adds services
|
|
1692
|
+
* @returns Middleware that contributes services only
|
|
1691
1693
|
*
|
|
1692
|
-
* The return type matches what the implementation actually returns:
|
|
1693
|
-
* - A route object with a GET property
|
|
1694
|
-
* - The GET property contains the wrapped handler and schemas
|
|
1695
|
-
* - The wrapped handler has the standard (ctx, params) signature expected by the router
|
|
1696
1694
|
*/
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
params?: P extends never ? never : P;
|
|
1700
|
-
query?: Q extends never ? never : Q;
|
|
1701
|
-
events?: E extends never ? never : E;
|
|
1702
|
-
};
|
|
1703
|
-
handler: SSERouteHandler<E extends Record<string, z.ZodType> ? TypedSSEStream<E> : SSEStreamExtended, P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, TState, TServices>;
|
|
1704
|
-
middleware?: Middleware[];
|
|
1705
|
-
options?: Record<string, unknown>;
|
|
1706
|
-
}) => {
|
|
1707
|
-
GET: {
|
|
1708
|
-
handler: (ctx: any, params: any) => Promise<void>;
|
|
1709
|
-
schema?: {
|
|
1710
|
-
params?: P extends never ? undefined : P;
|
|
1711
|
-
query?: Q extends never ? undefined : Q;
|
|
1712
|
-
};
|
|
1713
|
-
middleware?: Middleware[];
|
|
1714
|
-
options?: Record<string, unknown>;
|
|
1715
|
-
};
|
|
1716
|
-
path: string;
|
|
1717
|
-
};
|
|
1695
|
+
declare function serviceMiddleware<T = {}>(handler: MiddlewareFunction): Middleware<{}, T>;
|
|
1696
|
+
|
|
1718
1697
|
/**
|
|
1719
|
-
*
|
|
1698
|
+
* Represents a single Server-Sent Event
|
|
1699
|
+
* @template T - The type of data payload
|
|
1700
|
+
*
|
|
1701
|
+
* @example
|
|
1702
|
+
* ```typescript
|
|
1703
|
+
* const event: SSEEvent<{ message: string }> = {
|
|
1704
|
+
* id: '123',
|
|
1705
|
+
* event: 'message',
|
|
1706
|
+
* data: { message: 'Hello, world!' },
|
|
1707
|
+
* retry: 5000
|
|
1708
|
+
* };
|
|
1709
|
+
* ```
|
|
1720
1710
|
*/
|
|
1721
|
-
interface
|
|
1711
|
+
interface SSEEvent<T = unknown> {
|
|
1712
|
+
/** Unique identifier for the event */
|
|
1722
1713
|
id: string;
|
|
1714
|
+
/** Event type/name for client-side event listeners */
|
|
1723
1715
|
event: string;
|
|
1724
|
-
data
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1716
|
+
/** The actual data payload of the event */
|
|
1717
|
+
data: T;
|
|
1718
|
+
/** Optional retry interval in milliseconds for reconnection */
|
|
1719
|
+
retry?: number;
|
|
1728
1720
|
}
|
|
1729
1721
|
/**
|
|
1730
|
-
*
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1722
|
+
* Backpressure handling strategies for SSE streams
|
|
1723
|
+
*
|
|
1724
|
+
* - `drop-oldest`: Remove oldest events from buffer when full
|
|
1725
|
+
* - `drop-newest`: Reject new events when buffer is full
|
|
1726
|
+
* - `close`: Close the stream when buffer limit is reached
|
|
1727
|
+
*/
|
|
1728
|
+
type SSEBufferStrategy = 'drop-oldest' | 'drop-newest' | 'close';
|
|
1729
|
+
/**
|
|
1730
|
+
* Configuration options for SSE streams
|
|
1731
|
+
*
|
|
1732
|
+
* @example
|
|
1733
|
+
* ```typescript
|
|
1734
|
+
* const options: SSEOptions = {
|
|
1735
|
+
* autoClose: true,
|
|
1736
|
+
* maxBufferSize: 100,
|
|
1737
|
+
* bufferStrategy: 'drop-oldest'
|
|
1738
|
+
* };
|
|
1739
|
+
* ```
|
|
1740
|
+
*/
|
|
1741
|
+
interface SSEOptions {
|
|
1742
|
+
/** ms between heartbeat pings (0 to disable) */
|
|
1743
|
+
heartbeatInterval?: number;
|
|
1744
|
+
/** Maximum size in bytes for a single event */
|
|
1745
|
+
maxEventSize?: number;
|
|
1746
|
+
/** Automatically close stream when client disconnects */
|
|
1747
|
+
autoClose?: boolean;
|
|
1748
|
+
/** Maximum number of events to buffer before applying strategy */
|
|
1749
|
+
maxBufferSize?: number;
|
|
1750
|
+
/** Strategy to handle buffer overflow conditions */
|
|
1751
|
+
bufferStrategy?: SSEBufferStrategy;
|
|
1738
1752
|
}
|
|
1739
|
-
|
|
1740
1753
|
/**
|
|
1741
|
-
*
|
|
1742
|
-
* Location: packages/blaize-client/src/sse/types.ts
|
|
1754
|
+
* Connection states for SSE streams
|
|
1743
1755
|
*/
|
|
1744
|
-
|
|
1756
|
+
type SSEConnectionState = 'connecting' | 'connected' | 'disconnected' | 'closed';
|
|
1745
1757
|
/**
|
|
1746
|
-
*
|
|
1758
|
+
* SSE stream interface for managing server-sent events
|
|
1759
|
+
*
|
|
1760
|
+
* @example
|
|
1761
|
+
* ```typescript
|
|
1762
|
+
* const stream: SSEStream = createSSEStream(response);
|
|
1763
|
+
*
|
|
1764
|
+
* // Send typed event
|
|
1765
|
+
* stream.send('notification', { type: 'info', message: 'Update available' });
|
|
1766
|
+
*
|
|
1767
|
+
* // Send error event
|
|
1768
|
+
* stream.sendError(new Error('Processing failed'));
|
|
1769
|
+
*
|
|
1770
|
+
* // Clean up on close
|
|
1771
|
+
* stream.onClose(() => {
|
|
1772
|
+
* console.log('Client disconnected');
|
|
1773
|
+
* });
|
|
1774
|
+
*
|
|
1775
|
+
* // Close stream
|
|
1776
|
+
* stream.close();
|
|
1777
|
+
* ```
|
|
1747
1778
|
*/
|
|
1748
|
-
interface
|
|
1749
|
-
|
|
1779
|
+
interface SSEStream {
|
|
1780
|
+
/**
|
|
1781
|
+
* Send an event with typed data to the client
|
|
1782
|
+
* @template T - Type of the data payload
|
|
1783
|
+
* @param event - Event name/type
|
|
1784
|
+
* @param data - Event data payload
|
|
1785
|
+
*/
|
|
1786
|
+
send<T>(event: string, data: T): void;
|
|
1787
|
+
/**
|
|
1788
|
+
* Send an error event to the client
|
|
1789
|
+
* @param error - Error object to send
|
|
1790
|
+
*/
|
|
1791
|
+
sendError(error: Error): void;
|
|
1792
|
+
/**
|
|
1793
|
+
* Close the SSE stream connection
|
|
1794
|
+
*/
|
|
1795
|
+
close(): void;
|
|
1796
|
+
/**
|
|
1797
|
+
* Register a callback for stream closure
|
|
1798
|
+
* @param cb - Callback function to execute on close
|
|
1799
|
+
*/
|
|
1800
|
+
onClose(cb: () => void): void;
|
|
1750
1801
|
}
|
|
1751
1802
|
/**
|
|
1752
|
-
* SSE
|
|
1803
|
+
* Extended SSE stream with additional control methods
|
|
1753
1804
|
*/
|
|
1754
|
-
interface
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
bufferMissedEvents?: boolean;
|
|
1764
|
-
maxMissedEvents?: number;
|
|
1765
|
-
heartbeatTimeout?: number;
|
|
1766
|
-
parseJSON?: boolean;
|
|
1805
|
+
interface SSEStreamExtended extends SSEStream {
|
|
1806
|
+
readonly id: string;
|
|
1807
|
+
[Symbol.asyncIterator](): AsyncGenerator<BufferedEvent, void, unknown>;
|
|
1808
|
+
/** Current connection state */
|
|
1809
|
+
readonly state: SSEConnectionState;
|
|
1810
|
+
/** Number of events in the buffer */
|
|
1811
|
+
readonly bufferSize: number;
|
|
1812
|
+
/** Check if stream is writable */
|
|
1813
|
+
readonly isWritable: boolean;
|
|
1767
1814
|
/**
|
|
1768
|
-
*
|
|
1769
|
-
*
|
|
1770
|
-
* Default: true
|
|
1815
|
+
* Ping the client to keep connection alive
|
|
1816
|
+
* @param comment - Optional comment to include in ping
|
|
1771
1817
|
*/
|
|
1772
|
-
|
|
1818
|
+
ping(comment?: string): void;
|
|
1773
1819
|
/**
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1776
|
-
* Only applies if waitForConnection is true.
|
|
1820
|
+
* Set retry interval for client reconnection
|
|
1821
|
+
* @param milliseconds - Retry interval in milliseconds
|
|
1777
1822
|
*/
|
|
1778
|
-
|
|
1823
|
+
setRetry(milliseconds: number): void;
|
|
1824
|
+
/**
|
|
1825
|
+
* Flush any buffered events immediately
|
|
1826
|
+
*/
|
|
1827
|
+
flush(): void;
|
|
1828
|
+
getMetrics(): StreamMetrics;
|
|
1779
1829
|
}
|
|
1780
1830
|
/**
|
|
1781
|
-
*
|
|
1831
|
+
* SSE event serialization format
|
|
1782
1832
|
*/
|
|
1783
|
-
interface
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1833
|
+
interface SSESerializedEvent {
|
|
1834
|
+
/** Event ID field */
|
|
1835
|
+
id?: string;
|
|
1836
|
+
/** Event type field */
|
|
1837
|
+
event?: string;
|
|
1838
|
+
/** Data field (can be multi-line) */
|
|
1839
|
+
data: string;
|
|
1840
|
+
/** Retry field */
|
|
1841
|
+
retry?: number;
|
|
1842
|
+
/** Comment field for keep-alive */
|
|
1843
|
+
comment?: string;
|
|
1789
1844
|
}
|
|
1790
1845
|
/**
|
|
1791
|
-
*
|
|
1846
|
+
* SSE event handler function type
|
|
1847
|
+
* @template T - Type of the event data
|
|
1792
1848
|
*/
|
|
1793
|
-
type
|
|
1849
|
+
type SSEEventHandler<T = unknown> = (event: SSEEvent<T>) => void | Promise<void>;
|
|
1794
1850
|
/**
|
|
1795
|
-
* SSE
|
|
1851
|
+
* SSE event listener registration
|
|
1796
1852
|
*/
|
|
1797
|
-
interface
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
off(event: 'open', handler?: () => void): void;
|
|
1805
|
-
off(event: 'close', handler?: (event: CloseEvent) => void): void;
|
|
1806
|
-
once<K extends keyof TEvents>(event: K & string, handler: (data: TEvents[K]) => void): void;
|
|
1807
|
-
once(event: 'error', handler: (error: BlaizeError) => void): void;
|
|
1808
|
-
once(event: 'open', handler: () => void): void;
|
|
1809
|
-
once(event: 'close', handler: (event: CloseEvent) => void): void;
|
|
1810
|
-
close(): void;
|
|
1811
|
-
readonly state: SSEConnectionState;
|
|
1812
|
-
readonly metrics: SSEClientMetrics;
|
|
1813
|
-
readonly lastEventId?: string;
|
|
1853
|
+
interface SSEEventListener {
|
|
1854
|
+
/** Event type to listen for (use '*' for all events) */
|
|
1855
|
+
event: string;
|
|
1856
|
+
/** Handler function for the event */
|
|
1857
|
+
handler: SSEEventHandler;
|
|
1858
|
+
/** Optional listener identifier for removal */
|
|
1859
|
+
id?: string;
|
|
1814
1860
|
}
|
|
1815
1861
|
/**
|
|
1816
|
-
*
|
|
1862
|
+
* SSE metrics for monitoring stream performance
|
|
1817
1863
|
*/
|
|
1818
|
-
interface
|
|
1819
|
-
|
|
1820
|
-
|
|
1864
|
+
interface SSEMetrics {
|
|
1865
|
+
/** Total number of events sent */
|
|
1866
|
+
eventsSent: number;
|
|
1867
|
+
/** Total number of events dropped */
|
|
1868
|
+
eventsDropped: number;
|
|
1869
|
+
/** Current number of connected clients */
|
|
1870
|
+
activeConnections: number;
|
|
1871
|
+
/** Total bytes sent */
|
|
1872
|
+
bytesSent: number;
|
|
1873
|
+
/** Average event send latency in milliseconds */
|
|
1874
|
+
averageLatency: number;
|
|
1875
|
+
/** Connection duration in milliseconds */
|
|
1876
|
+
connectionDuration: number;
|
|
1821
1877
|
}
|
|
1822
1878
|
/**
|
|
1823
|
-
*
|
|
1824
|
-
* Returns a Promise that resolves to an SSEClient instance
|
|
1879
|
+
* SSE stream manager for handling multiple clients
|
|
1825
1880
|
*/
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
}) & (IsNever$1<Q> extends true ? {} : {
|
|
1867
|
-
query: Infer<Q>;
|
|
1868
|
-
}) & (IsNever$1<B> extends true ? {} : {
|
|
1869
|
-
body: Infer<B>;
|
|
1870
|
-
});
|
|
1871
|
-
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
1872
|
-
type BuildArgs<P, Q, B> = IsEmptyObject<BuildArgsObject<P, Q, B>> extends true ? void : BuildArgsObject<P, Q, B>;
|
|
1873
|
-
type CreateClientMethod<TRoute> = GetRouteMethodOptions<TRoute> extends RouteMethodOptions<infer P, infer Q, infer B, infer R> ? BuildArgs<P, Q, B> extends void ? () => Promise<R extends z.ZodType ? Infer<R> : unknown> : (args: BuildArgs<P, Q, B>) => Promise<R extends z.ZodType ? Infer<R> : unknown> : never;
|
|
1874
|
-
type CreateClient<TRoutes extends Record<string, Record<string, any>>> = {
|
|
1875
|
-
[Method in keyof TRoutes]: {
|
|
1876
|
-
[RouteName in keyof TRoutes[Method]]: CreateClientMethod<TRoutes[Method][RouteName]>;
|
|
1877
|
-
};
|
|
1878
|
-
};
|
|
1879
|
-
interface ClientConfig {
|
|
1880
|
-
baseUrl: string;
|
|
1881
|
-
defaultHeaders?: Record<string, string>;
|
|
1882
|
-
timeout?: number;
|
|
1883
|
-
sse?: SSEClientOptions;
|
|
1884
|
-
}
|
|
1885
|
-
interface InternalRequestArgs {
|
|
1886
|
-
params?: Record<string, any>;
|
|
1887
|
-
query?: Record<string, any>;
|
|
1888
|
-
body?: any;
|
|
1889
|
-
}
|
|
1890
|
-
interface RequestOptions {
|
|
1891
|
-
method: string;
|
|
1892
|
-
url: string;
|
|
1893
|
-
headers: Record<string, string>;
|
|
1894
|
-
body?: string;
|
|
1895
|
-
timeout: number;
|
|
1881
|
+
interface SSEStreamManager {
|
|
1882
|
+
/**
|
|
1883
|
+
* Create a new SSE stream for a client
|
|
1884
|
+
* @param clientId - Unique identifier for the client
|
|
1885
|
+
* @param options - Stream configuration options
|
|
1886
|
+
*/
|
|
1887
|
+
createStream(clientId: string, options?: SSEOptions): SSEStream;
|
|
1888
|
+
/**
|
|
1889
|
+
* Get an existing stream by client ID
|
|
1890
|
+
* @param clientId - Client identifier
|
|
1891
|
+
*/
|
|
1892
|
+
getStream(clientId: string): SSEStream | undefined;
|
|
1893
|
+
/**
|
|
1894
|
+
* Broadcast an event to all connected clients
|
|
1895
|
+
* @template T - Type of the event data
|
|
1896
|
+
* @param event - Event name
|
|
1897
|
+
* @param data - Event data
|
|
1898
|
+
*/
|
|
1899
|
+
broadcast<T>(event: string, data: T): void;
|
|
1900
|
+
/**
|
|
1901
|
+
* Broadcast to specific clients
|
|
1902
|
+
* @template T - Type of the event data
|
|
1903
|
+
* @param clientIds - Array of client IDs
|
|
1904
|
+
* @param event - Event name
|
|
1905
|
+
* @param data - Event data
|
|
1906
|
+
*/
|
|
1907
|
+
multicast<T>(clientIds: string[], event: string, data: T): void;
|
|
1908
|
+
/**
|
|
1909
|
+
* Close a specific client stream
|
|
1910
|
+
* @param clientId - Client identifier
|
|
1911
|
+
*/
|
|
1912
|
+
closeStream(clientId: string): void;
|
|
1913
|
+
/**
|
|
1914
|
+
* Close all active streams
|
|
1915
|
+
*/
|
|
1916
|
+
closeAll(): void;
|
|
1917
|
+
/**
|
|
1918
|
+
* Get metrics for all streams
|
|
1919
|
+
*/
|
|
1920
|
+
getMetrics(): SSEMetrics;
|
|
1896
1921
|
}
|
|
1897
1922
|
/**
|
|
1898
|
-
*
|
|
1899
|
-
* SSE routes have a special 'SSE' method key
|
|
1923
|
+
* Result type for operations that can fail
|
|
1900
1924
|
*/
|
|
1901
|
-
type
|
|
1902
|
-
|
|
1903
|
-
|
|
1925
|
+
type RegistryResult<T> = {
|
|
1926
|
+
success: true;
|
|
1927
|
+
value: T;
|
|
1928
|
+
} | {
|
|
1929
|
+
success: false;
|
|
1930
|
+
error: string;
|
|
1931
|
+
};
|
|
1904
1932
|
/**
|
|
1905
|
-
*
|
|
1933
|
+
* Connection metadata stored in the registry
|
|
1906
1934
|
*/
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1935
|
+
interface ConnectionEntry {
|
|
1936
|
+
stream: SSEStream;
|
|
1937
|
+
connectedAt: number;
|
|
1938
|
+
lastActivity: number;
|
|
1939
|
+
clientIp?: string;
|
|
1940
|
+
userAgent?: string;
|
|
1941
|
+
}
|
|
1912
1942
|
/**
|
|
1913
|
-
*
|
|
1943
|
+
* Internal connection registry interface
|
|
1914
1944
|
*/
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
};
|
|
1921
|
-
|
|
1945
|
+
interface ConnectionRegistry {
|
|
1946
|
+
/** Add a new connection to the registry */
|
|
1947
|
+
add: (id: string, stream: SSEStream, metadata?: {
|
|
1948
|
+
clientIp?: string;
|
|
1949
|
+
userAgent?: string;
|
|
1950
|
+
}) => void;
|
|
1951
|
+
/** Remove a connection from the registry */
|
|
1952
|
+
remove: (id: string) => void;
|
|
1953
|
+
/** Get current connection count */
|
|
1954
|
+
count: () => number;
|
|
1955
|
+
/** Clean up inactive or closed connections */
|
|
1956
|
+
cleanup: () => void;
|
|
1957
|
+
/** Get connection by ID (for internal use) */
|
|
1958
|
+
get: (id: string) => SSEStream | undefined;
|
|
1959
|
+
/** Check if a connection exists */
|
|
1960
|
+
has: (id: string) => boolean;
|
|
1961
|
+
/** Get all connection IDs */
|
|
1962
|
+
getIds: () => string[];
|
|
1963
|
+
/** Shutdown the registry and close all connections */
|
|
1964
|
+
shutdown: () => void;
|
|
1965
|
+
}
|
|
1922
1966
|
/**
|
|
1923
|
-
*
|
|
1967
|
+
* Extended stream interface for typed events
|
|
1924
1968
|
*/
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
params?: infer P;
|
|
1929
|
-
};
|
|
1930
|
-
};
|
|
1931
|
-
} ? P extends z.ZodType ? z.infer<P> : Record<string, string> : never;
|
|
1969
|
+
interface TypedSSEStream<TEvents extends Record<string, z.ZodType>> extends SSEStreamExtended {
|
|
1970
|
+
send<K extends keyof TEvents>(event: K & string, data: z.infer<TEvents[K]>): void;
|
|
1971
|
+
}
|
|
1932
1972
|
/**
|
|
1933
|
-
*
|
|
1973
|
+
* Schema for SSE route validation with generic type parameters
|
|
1934
1974
|
*/
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
} : {
|
|
1944
|
-
params: ExtractSSEParams<TRoute>;
|
|
1945
|
-
query: ExtractSSEQuery<TRoute>;
|
|
1946
|
-
options?: SSEClientOptions;
|
|
1947
|
-
};
|
|
1975
|
+
interface SSERouteSchema<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, E = any> {
|
|
1976
|
+
/** Parameter schema for validation */
|
|
1977
|
+
params?: P;
|
|
1978
|
+
/** Query schema for validation */
|
|
1979
|
+
query?: Q;
|
|
1980
|
+
/** Events schema for validation (SSE-specific, replaces response) */
|
|
1981
|
+
events?: E;
|
|
1982
|
+
}
|
|
1948
1983
|
/**
|
|
1949
|
-
*
|
|
1984
|
+
* SSE route handler function with stream as first parameter
|
|
1985
|
+
* This is the user-facing API - they write handlers with this signature
|
|
1950
1986
|
*/
|
|
1951
|
-
type
|
|
1952
|
-
|
|
1953
|
-
} ? (args?: BuildSSEArgs<TRoute>) => Promise<SSEClient<ExtractSSEEvents<TRoute>>> : (args: BuildSSEArgs<TRoute>) => Promise<SSEClient<ExtractSSEEvents<TRoute>>> : never;
|
|
1987
|
+
type SSERouteHandler<TStream extends SSEStreamExtended = SSEStreamExtended, TParams = Record<string, string>, TQuery = Record<string, string | string[] | undefined>, TState extends State = State, TServices extends Services = Services> = (stream: TStream, ctx: Context<TState, TServices, never, TQuery>, // SSE never has body
|
|
1988
|
+
params: TParams) => Promise<void> | void;
|
|
1954
1989
|
/**
|
|
1955
|
-
*
|
|
1990
|
+
* SSE route creator with state and services support
|
|
1991
|
+
* Returns a higher-order function to handle generics properly
|
|
1992
|
+
*
|
|
1993
|
+
* The return type matches what the implementation actually returns:
|
|
1994
|
+
* - A route object with a GET property
|
|
1995
|
+
* - The GET property contains the wrapped handler and schemas
|
|
1996
|
+
* - The wrapped handler has the standard (ctx, params) signature expected by the router
|
|
1956
1997
|
*/
|
|
1957
|
-
type
|
|
1958
|
-
|
|
1998
|
+
type CreateSSERoute = <TState extends State = State, TServices extends Services = Services>() => <P = never, Q = never, E = never>(config: {
|
|
1999
|
+
schema?: {
|
|
2000
|
+
params?: P extends never ? never : P;
|
|
2001
|
+
query?: Q extends never ? never : Q;
|
|
2002
|
+
events?: E extends never ? never : E;
|
|
2003
|
+
};
|
|
2004
|
+
handler: SSERouteHandler<E extends Record<string, z.ZodType> ? TypedSSEStream<E> : SSEStreamExtended, P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, TState, TServices>;
|
|
2005
|
+
middleware?: Middleware[];
|
|
2006
|
+
options?: Record<string, unknown>;
|
|
2007
|
+
}) => {
|
|
2008
|
+
GET: {
|
|
2009
|
+
handler: (ctx: any, params: any) => Promise<void>;
|
|
2010
|
+
schema?: {
|
|
2011
|
+
params?: P extends never ? undefined : P;
|
|
2012
|
+
query?: Q extends never ? undefined : Q;
|
|
2013
|
+
};
|
|
2014
|
+
middleware?: Middleware[];
|
|
2015
|
+
options?: Record<string, unknown>;
|
|
2016
|
+
};
|
|
2017
|
+
path: string;
|
|
1959
2018
|
};
|
|
1960
2019
|
/**
|
|
1961
|
-
*
|
|
2020
|
+
* Buffered event with metadata
|
|
1962
2021
|
*/
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2022
|
+
interface BufferedEvent {
|
|
2023
|
+
id: string;
|
|
2024
|
+
event: string;
|
|
2025
|
+
data: unknown;
|
|
2026
|
+
size: number;
|
|
2027
|
+
timestamp: number;
|
|
2028
|
+
correlationId: string;
|
|
2029
|
+
}
|
|
1969
2030
|
/**
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1972
|
-
* Comprehensive type definitions for W3C-compliant CORS middleware
|
|
1973
|
-
* with support for string, regex, and async function origin validation.
|
|
1974
|
-
*
|
|
1975
|
-
* @module @blaizejs/types/cors
|
|
2031
|
+
* Stream metrics for monitoring
|
|
1976
2032
|
*/
|
|
2033
|
+
interface StreamMetrics {
|
|
2034
|
+
eventsSent: number;
|
|
2035
|
+
eventsDropped: number;
|
|
2036
|
+
bytesWritten: number;
|
|
2037
|
+
bufferHighWatermark: number;
|
|
2038
|
+
lastEventTime: number;
|
|
2039
|
+
}
|
|
1977
2040
|
|
|
1978
2041
|
/**
|
|
1979
|
-
*
|
|
1980
|
-
*
|
|
1981
|
-
* @example
|
|
1982
|
-
* ```typescript
|
|
1983
|
-
* // String origin (exact match)
|
|
1984
|
-
* const origin: CorsOrigin = 'https://example.com';
|
|
1985
|
-
*
|
|
1986
|
-
* // RegExp pattern
|
|
1987
|
-
* const origin: CorsOrigin = /^https:\/\/.*\.example\.com$/;
|
|
1988
|
-
*
|
|
1989
|
-
* // Dynamic validation function
|
|
1990
|
-
* const origin: CorsOrigin = async (origin, ctx) => {
|
|
1991
|
-
* return await checkOriginAllowed(origin, ctx?.state.user);
|
|
1992
|
-
* };
|
|
1993
|
-
*
|
|
1994
|
-
* // Array of mixed types
|
|
1995
|
-
* const origin: CorsOrigin = [
|
|
1996
|
-
* 'https://localhost:3000',
|
|
1997
|
-
* /^https:\/\/.*\.example\.com$/,
|
|
1998
|
-
* (origin) => origin.endsWith('.trusted.com')
|
|
1999
|
-
* ];
|
|
2000
|
-
* ```
|
|
2042
|
+
* SSE Client Types for BlaizeJS
|
|
2043
|
+
* Location: packages/blaize-client/src/sse/types.ts
|
|
2001
2044
|
*/
|
|
2002
|
-
|
|
2045
|
+
|
|
2003
2046
|
/**
|
|
2004
|
-
*
|
|
2005
|
-
* Based on W3C CORS specification
|
|
2047
|
+
* Event handlers map
|
|
2006
2048
|
*/
|
|
2007
|
-
|
|
2049
|
+
interface EventHandlers {
|
|
2050
|
+
[event: string]: Set<(data: any) => void>;
|
|
2051
|
+
}
|
|
2008
2052
|
/**
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
* @example
|
|
2012
|
-
* ```typescript
|
|
2013
|
-
* const corsOptions: CorsOptions = {
|
|
2014
|
-
* origin: 'https://example.com',
|
|
2015
|
-
* methods: ['GET', 'POST'],
|
|
2016
|
-
* credentials: true,
|
|
2017
|
-
* maxAge: 86400
|
|
2018
|
-
* };
|
|
2019
|
-
* ```
|
|
2053
|
+
* SSE connection configuration options
|
|
2020
2054
|
*/
|
|
2021
|
-
interface
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
*/
|
|
2035
|
-
origin?: boolean | CorsOrigin;
|
|
2036
|
-
/**
|
|
2037
|
-
* Configures the Access-Control-Allow-Methods header
|
|
2038
|
-
*
|
|
2039
|
-
* @default ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE']
|
|
2040
|
-
* @example ['GET', 'POST']
|
|
2041
|
-
*/
|
|
2042
|
-
methods?: CorsHttpMethod[] | string;
|
|
2043
|
-
/**
|
|
2044
|
-
* Configures the Access-Control-Allow-Headers header
|
|
2045
|
-
*
|
|
2046
|
-
* Pass an array of allowed headers or a comma-delimited string.
|
|
2047
|
-
*
|
|
2048
|
-
* @default Request's Access-Control-Request-Headers header value
|
|
2049
|
-
* @example ['Content-Type', 'Authorization']
|
|
2050
|
-
*/
|
|
2051
|
-
allowedHeaders?: string[] | string;
|
|
2052
|
-
/**
|
|
2053
|
-
* Configures the Access-Control-Expose-Headers header
|
|
2054
|
-
*
|
|
2055
|
-
* Headers that the browser is allowed to access.
|
|
2056
|
-
*
|
|
2057
|
-
* @default []
|
|
2058
|
-
* @example ['Content-Range', 'X-Content-Range']
|
|
2059
|
-
*/
|
|
2060
|
-
exposedHeaders?: string[] | string;
|
|
2061
|
-
/**
|
|
2062
|
-
* Configures the Access-Control-Allow-Credentials header
|
|
2063
|
-
*
|
|
2064
|
-
* Set to true to allow credentials (cookies, authorization headers, TLS client certificates).
|
|
2065
|
-
* Note: Cannot be used with origin: '*' for security reasons.
|
|
2066
|
-
*
|
|
2067
|
-
* @default false
|
|
2068
|
-
*/
|
|
2069
|
-
credentials?: boolean;
|
|
2070
|
-
/**
|
|
2071
|
-
* Configures the Access-Control-Max-Age header in seconds
|
|
2072
|
-
*
|
|
2073
|
-
* Indicates how long browsers can cache preflight response.
|
|
2074
|
-
* Set to -1 to disable caching.
|
|
2075
|
-
*
|
|
2076
|
-
* @default undefined (browser decides)
|
|
2077
|
-
* @example 86400 // 24 hours
|
|
2078
|
-
*/
|
|
2079
|
-
maxAge?: number;
|
|
2055
|
+
interface SSEClientOptions {
|
|
2056
|
+
headers?: Record<string, string>;
|
|
2057
|
+
withCredentials?: boolean;
|
|
2058
|
+
reconnect?: {
|
|
2059
|
+
enabled: boolean;
|
|
2060
|
+
maxAttempts?: number;
|
|
2061
|
+
strategy?: ReconnectStrategy;
|
|
2062
|
+
initialDelay?: number;
|
|
2063
|
+
};
|
|
2064
|
+
bufferMissedEvents?: boolean;
|
|
2065
|
+
maxMissedEvents?: number;
|
|
2066
|
+
heartbeatTimeout?: number;
|
|
2067
|
+
parseJSON?: boolean;
|
|
2080
2068
|
/**
|
|
2081
|
-
* Whether to
|
|
2082
|
-
*
|
|
2083
|
-
*
|
|
2084
|
-
* When true, control passes to the next middleware/handler.
|
|
2085
|
-
*
|
|
2086
|
-
* @default false
|
|
2069
|
+
* Whether to wait for connection before resolving the promise.
|
|
2070
|
+
* If false, returns the client immediately without waiting.
|
|
2071
|
+
* Default: true
|
|
2087
2072
|
*/
|
|
2088
|
-
|
|
2073
|
+
waitForConnection?: boolean;
|
|
2089
2074
|
/**
|
|
2090
|
-
*
|
|
2091
|
-
*
|
|
2092
|
-
*
|
|
2093
|
-
*
|
|
2094
|
-
* @default 204
|
|
2075
|
+
* Optional timeout for initial connection in milliseconds.
|
|
2076
|
+
* If not set, no timeout is applied (relies on EventSource native timeout).
|
|
2077
|
+
* Only applies if waitForConnection is true.
|
|
2095
2078
|
*/
|
|
2096
|
-
|
|
2079
|
+
connectionTimeout?: number;
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* Metrics for SSE connection monitoring
|
|
2083
|
+
*/
|
|
2084
|
+
interface SSEClientMetrics {
|
|
2085
|
+
eventsReceived: number;
|
|
2086
|
+
bytesReceived: number;
|
|
2087
|
+
connectionDuration: number;
|
|
2088
|
+
reconnectAttempts: number;
|
|
2089
|
+
lastEventId?: string;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Reconnection delay calculation strategy
|
|
2093
|
+
*/
|
|
2094
|
+
type ReconnectStrategy = (attempt: number) => number;
|
|
2095
|
+
/**
|
|
2096
|
+
* SSE Client interface with type-safe event handling
|
|
2097
|
+
*/
|
|
2098
|
+
interface SSEClient<TEvents extends Record<string, unknown> = Record<string, unknown>> {
|
|
2099
|
+
on<K extends keyof TEvents>(event: K & string, handler: (data: TEvents[K]) => void): void;
|
|
2100
|
+
on(event: 'error', handler: (error: BlaizeError) => void): void;
|
|
2101
|
+
on(event: 'open', handler: () => void): void;
|
|
2102
|
+
on(event: 'close', handler: (event: CloseEvent) => void): void;
|
|
2103
|
+
off<K extends keyof TEvents>(event: K & string, handler?: (data: TEvents[K]) => void): void;
|
|
2104
|
+
off(event: 'error', handler?: (error: BlaizeError) => void): void;
|
|
2105
|
+
off(event: 'open', handler?: () => void): void;
|
|
2106
|
+
off(event: 'close', handler?: (event: CloseEvent) => void): void;
|
|
2107
|
+
once<K extends keyof TEvents>(event: K & string, handler: (data: TEvents[K]) => void): void;
|
|
2108
|
+
once(event: 'error', handler: (error: BlaizeError) => void): void;
|
|
2109
|
+
once(event: 'open', handler: () => void): void;
|
|
2110
|
+
once(event: 'close', handler: (event: CloseEvent) => void): void;
|
|
2111
|
+
close(): void;
|
|
2112
|
+
readonly state: SSEConnectionState;
|
|
2113
|
+
readonly metrics: SSEClientMetrics;
|
|
2114
|
+
readonly lastEventId?: string;
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Close event for SSE connections
|
|
2118
|
+
*/
|
|
2119
|
+
interface CloseEvent {
|
|
2120
|
+
reconnect: boolean;
|
|
2121
|
+
reason?: string;
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Internal SSE connection factory
|
|
2125
|
+
* Returns a Promise that resolves to an SSEClient instance
|
|
2126
|
+
*/
|
|
2127
|
+
type SSEConnectionFactory<TEvents extends Record<string, unknown> = Record<string, unknown>> = (options?: SSEClientOptions) => Promise<SSEClient<TEvents>>;
|
|
2128
|
+
|
|
2129
|
+
type ExtractMethod<T> = T extends {
|
|
2130
|
+
GET: any;
|
|
2131
|
+
} ? 'GET' : T extends {
|
|
2132
|
+
POST: any;
|
|
2133
|
+
} ? 'POST' : T extends {
|
|
2134
|
+
PUT: any;
|
|
2135
|
+
} ? 'PUT' : T extends {
|
|
2136
|
+
DELETE: any;
|
|
2137
|
+
} ? 'DELETE' : T extends {
|
|
2138
|
+
PATCH: any;
|
|
2139
|
+
} ? 'PATCH' : T extends {
|
|
2140
|
+
HEAD: any;
|
|
2141
|
+
} ? 'HEAD' : T extends {
|
|
2142
|
+
OPTIONS: any;
|
|
2143
|
+
} ? 'OPTIONS' : never;
|
|
2144
|
+
type BuildRoutesRegistry<TRoutes extends Record<string, any>> = {
|
|
2145
|
+
[Method in ExtractMethod<TRoutes[keyof TRoutes]> as `$${Lowercase<Method>}`]: {
|
|
2146
|
+
[K in keyof TRoutes as ExtractMethod<TRoutes[K]> extends Method ? K : never]: TRoutes[K];
|
|
2147
|
+
};
|
|
2148
|
+
};
|
|
2149
|
+
type GetRouteMethodOptions<TRoute> = TRoute extends {
|
|
2150
|
+
GET: infer M;
|
|
2151
|
+
} ? M : TRoute extends {
|
|
2152
|
+
POST: infer M;
|
|
2153
|
+
} ? M : TRoute extends {
|
|
2154
|
+
PUT: infer M;
|
|
2155
|
+
} ? M : TRoute extends {
|
|
2156
|
+
DELETE: infer M;
|
|
2157
|
+
} ? M : TRoute extends {
|
|
2158
|
+
PATCH: infer M;
|
|
2159
|
+
} ? M : TRoute extends {
|
|
2160
|
+
HEAD: infer M;
|
|
2161
|
+
} ? M : TRoute extends {
|
|
2162
|
+
OPTIONS: infer M;
|
|
2163
|
+
} ? M : never;
|
|
2164
|
+
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
2165
|
+
type BuildArgsObject<P, Q, B> = (IsNever$1<P> extends true ? {} : {
|
|
2166
|
+
params: Infer<P>;
|
|
2167
|
+
}) & (IsNever$1<Q> extends true ? {} : {
|
|
2168
|
+
query: Infer<Q>;
|
|
2169
|
+
}) & (IsNever$1<B> extends true ? {} : {
|
|
2170
|
+
body: Infer<B>;
|
|
2171
|
+
});
|
|
2172
|
+
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
2173
|
+
type BuildArgs<P, Q, B> = IsEmptyObject<BuildArgsObject<P, Q, B>> extends true ? void : BuildArgsObject<P, Q, B>;
|
|
2174
|
+
type CreateClientMethod<TRoute> = GetRouteMethodOptions<TRoute> extends RouteMethodOptions<infer P, infer Q, infer B, infer R> ? BuildArgs<P, Q, B> extends void ? () => Promise<R extends z.ZodType ? Infer<R> : unknown> : (args: BuildArgs<P, Q, B>) => Promise<R extends z.ZodType ? Infer<R> : unknown> : never;
|
|
2175
|
+
type CreateClient<TRoutes extends Record<string, Record<string, any>>> = {
|
|
2176
|
+
[Method in keyof TRoutes]: {
|
|
2177
|
+
[RouteName in keyof TRoutes[Method]]: CreateClientMethod<TRoutes[Method][RouteName]>;
|
|
2178
|
+
};
|
|
2179
|
+
};
|
|
2180
|
+
interface ClientConfig {
|
|
2181
|
+
baseUrl: string;
|
|
2182
|
+
defaultHeaders?: Record<string, string>;
|
|
2183
|
+
timeout?: number;
|
|
2184
|
+
sse?: SSEClientOptions;
|
|
2185
|
+
}
|
|
2186
|
+
interface InternalRequestArgs {
|
|
2187
|
+
params?: Record<string, any>;
|
|
2188
|
+
query?: Record<string, any>;
|
|
2189
|
+
body?: any;
|
|
2190
|
+
}
|
|
2191
|
+
interface RequestOptions {
|
|
2192
|
+
method: string;
|
|
2193
|
+
url: string;
|
|
2194
|
+
headers: Record<string, string>;
|
|
2195
|
+
body?: string;
|
|
2196
|
+
timeout: number;
|
|
2097
2197
|
}
|
|
2098
2198
|
/**
|
|
2099
|
-
*
|
|
2100
|
-
*
|
|
2199
|
+
* Detect if a route has SSE support
|
|
2200
|
+
* SSE routes have a special 'SSE' method key
|
|
2101
2201
|
*/
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
*/
|
|
2106
|
-
allowed: boolean;
|
|
2107
|
-
/**
|
|
2108
|
-
* The origin value to set in the header
|
|
2109
|
-
* Can be '*', specific origin, or 'null'
|
|
2110
|
-
*/
|
|
2111
|
-
origin?: string;
|
|
2112
|
-
/**
|
|
2113
|
-
* Whether to add Vary: Origin header
|
|
2114
|
-
*/
|
|
2115
|
-
vary?: boolean;
|
|
2116
|
-
}
|
|
2202
|
+
type HasSSEMethod<TRoute> = TRoute extends {
|
|
2203
|
+
SSE: any;
|
|
2204
|
+
} ? true : false;
|
|
2117
2205
|
/**
|
|
2118
|
-
*
|
|
2119
|
-
* Extracted from OPTIONS request headers
|
|
2206
|
+
* Extract SSE event types from route schema
|
|
2120
2207
|
*/
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
/**
|
|
2127
|
-
* The method that will be used in the actual request
|
|
2128
|
-
* From Access-Control-Request-Method header
|
|
2129
|
-
*/
|
|
2130
|
-
requestedMethod?: string;
|
|
2131
|
-
/**
|
|
2132
|
-
* The headers that will be sent in the actual request
|
|
2133
|
-
* From Access-Control-Request-Headers header
|
|
2134
|
-
*/
|
|
2135
|
-
requestedHeaders?: string[];
|
|
2136
|
-
}
|
|
2208
|
+
type ExtractSSEEvents<TRoute> = TRoute extends {
|
|
2209
|
+
SSE: {
|
|
2210
|
+
events?: infer E;
|
|
2211
|
+
};
|
|
2212
|
+
} ? E extends z.ZodType ? z.infer<E> : Record<string, unknown> : Record<string, unknown>;
|
|
2137
2213
|
/**
|
|
2138
|
-
*
|
|
2139
|
-
* Used for performance optimization
|
|
2214
|
+
* Extract SSE query parameters from route
|
|
2140
2215
|
*/
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
*/
|
|
2149
|
-
expiresAt: number;
|
|
2150
|
-
/**
|
|
2151
|
-
* Optional user identifier for cache key
|
|
2152
|
-
*/
|
|
2153
|
-
userId?: string;
|
|
2154
|
-
}
|
|
2216
|
+
type ExtractSSEQuery<TRoute> = TRoute extends {
|
|
2217
|
+
SSE: {
|
|
2218
|
+
schema?: {
|
|
2219
|
+
query?: infer Q;
|
|
2220
|
+
};
|
|
2221
|
+
};
|
|
2222
|
+
} ? Q extends z.ZodType ? z.infer<Q> : Record<string, unknown> : never;
|
|
2155
2223
|
/**
|
|
2156
|
-
*
|
|
2224
|
+
* Extract SSE params from route
|
|
2157
2225
|
*/
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
* Maximum number of entries in the cache
|
|
2166
|
-
* @default 1000
|
|
2167
|
-
*/
|
|
2168
|
-
maxSize?: number;
|
|
2169
|
-
/**
|
|
2170
|
-
* Whether to include user ID in cache key
|
|
2171
|
-
* @default true
|
|
2172
|
-
*/
|
|
2173
|
-
includeUserId?: boolean;
|
|
2174
|
-
}
|
|
2226
|
+
type ExtractSSEParams<TRoute> = TRoute extends {
|
|
2227
|
+
SSE: {
|
|
2228
|
+
schema?: {
|
|
2229
|
+
params?: infer P;
|
|
2230
|
+
};
|
|
2231
|
+
};
|
|
2232
|
+
} ? P extends z.ZodType ? z.infer<P> : Record<string, string> : never;
|
|
2175
2233
|
/**
|
|
2176
|
-
*
|
|
2234
|
+
* Build SSE method arguments
|
|
2177
2235
|
*/
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
/**
|
|
2192
|
-
* Number of denied origins
|
|
2193
|
-
*/
|
|
2194
|
-
deniedOrigins: number;
|
|
2195
|
-
/**
|
|
2196
|
-
* Cache hit rate for origin validation
|
|
2197
|
-
*/
|
|
2198
|
-
cacheHitRate: number;
|
|
2199
|
-
/**
|
|
2200
|
-
* Average origin validation time in milliseconds
|
|
2201
|
-
*/
|
|
2202
|
-
avgValidationTime: number;
|
|
2203
|
-
}
|
|
2236
|
+
type BuildSSEArgs<TRoute> = ExtractSSEParams<TRoute> extends never ? ExtractSSEQuery<TRoute> extends never ? {
|
|
2237
|
+
options?: SSEClientOptions;
|
|
2238
|
+
} : {
|
|
2239
|
+
query: ExtractSSEQuery<TRoute>;
|
|
2240
|
+
options?: SSEClientOptions;
|
|
2241
|
+
} : ExtractSSEQuery<TRoute> extends never ? {
|
|
2242
|
+
params: ExtractSSEParams<TRoute>;
|
|
2243
|
+
options?: SSEClientOptions;
|
|
2244
|
+
} : {
|
|
2245
|
+
params: ExtractSSEParams<TRoute>;
|
|
2246
|
+
query: ExtractSSEQuery<TRoute>;
|
|
2247
|
+
options?: SSEClientOptions;
|
|
2248
|
+
};
|
|
2204
2249
|
/**
|
|
2205
|
-
*
|
|
2250
|
+
* Create SSE client method
|
|
2206
2251
|
*/
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
lastAccessed: number;
|
|
2211
|
-
}
|
|
2252
|
+
type CreateSSEMethod<TRoute> = HasSSEMethod<TRoute> extends true ? BuildSSEArgs<TRoute> extends {
|
|
2253
|
+
options?: SSEClientOptions;
|
|
2254
|
+
} ? (args?: BuildSSEArgs<TRoute>) => Promise<SSEClient<ExtractSSEEvents<TRoute>>> : (args: BuildSSEArgs<TRoute>) => Promise<SSEClient<ExtractSSEEvents<TRoute>>> : never;
|
|
2212
2255
|
/**
|
|
2213
|
-
*
|
|
2256
|
+
* Extract SSE routes from registry
|
|
2214
2257
|
*/
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2258
|
+
type ExtractSSERoutes<TRoutes extends Record<string, any>> = {
|
|
2259
|
+
[K in keyof TRoutes as HasSSEMethod<TRoutes[K]> extends true ? K : never]: TRoutes[K];
|
|
2260
|
+
};
|
|
2261
|
+
/**
|
|
2262
|
+
* Enhanced client with SSE support
|
|
2263
|
+
*/
|
|
2264
|
+
type CreateEnhancedClient<TRoutes extends Record<string, any>, TRegistry> = TRegistry & {
|
|
2265
|
+
$sse: {
|
|
2266
|
+
[K in keyof ExtractSSERoutes<TRoutes>]: CreateSSEMethod<TRoutes[K]>;
|
|
2267
|
+
};
|
|
2268
|
+
};
|
|
2219
2269
|
|
|
2220
2270
|
/**
|
|
2221
2271
|
* BlaizeJS Server Module - Enhanced with Correlation Configuration
|
|
@@ -2468,7 +2518,7 @@ interface Plugin<TState = {}, TServices = {}> extends PluginHooks {
|
|
|
2468
2518
|
/**
|
|
2469
2519
|
* Plugin factory function
|
|
2470
2520
|
*/
|
|
2471
|
-
type PluginFactory<
|
|
2521
|
+
type PluginFactory<TConfig = any, TState = {}, TServices = {}> = (options?: TConfig) => Plugin<TState, TServices>;
|
|
2472
2522
|
interface PluginLifecycleManager {
|
|
2473
2523
|
initializePlugins(server: Server<any, any>): Promise<void>;
|
|
2474
2524
|
terminatePlugins(server: Server<any, any>): Promise<void>;
|
|
@@ -2730,7 +2780,7 @@ declare function createPluginArray<T extends ReadonlyArray<Plugin<any, any>>>(..
|
|
|
2730
2780
|
/**
|
|
2731
2781
|
* Create a plugin with the given name, version, and setup function
|
|
2732
2782
|
*/
|
|
2733
|
-
declare function create$1<
|
|
2783
|
+
declare function create$1<TConfig = any, TState = {}, TServices = {}>(name: string, version: string, setup: (app: UnknownServer, options: TConfig) => void | Partial<PluginHooks> | Promise<void> | Promise<Partial<PluginHooks>>, defaultOptions?: Partial<TConfig>): PluginFactory<TConfig, TState, TServices>;
|
|
2734
2784
|
|
|
2735
2785
|
/**
|
|
2736
2786
|
* Create a GET route
|
|
@@ -2899,6 +2949,31 @@ declare function createRouteFactory<TState extends State = State, TServices exte
|
|
|
2899
2949
|
};
|
|
2900
2950
|
};
|
|
2901
2951
|
|
|
2952
|
+
/**
|
|
2953
|
+
* Create a route matcher
|
|
2954
|
+
*/
|
|
2955
|
+
declare function createMatcher(): Matcher;
|
|
2956
|
+
|
|
2957
|
+
/**
|
|
2958
|
+
* Extract parameter values from a URL path
|
|
2959
|
+
*/
|
|
2960
|
+
declare function extractParams(path: string, pattern: RegExp, paramNames: string[]): Record<string, string>;
|
|
2961
|
+
/**
|
|
2962
|
+
* Compile a path pattern with parameters
|
|
2963
|
+
*/
|
|
2964
|
+
declare function compilePathPattern(path: string): {
|
|
2965
|
+
pattern: RegExp;
|
|
2966
|
+
paramNames: string[];
|
|
2967
|
+
};
|
|
2968
|
+
/**
|
|
2969
|
+
* Convert parameters object to URL query string
|
|
2970
|
+
*/
|
|
2971
|
+
declare function paramsToQuery(params: Record<string, string | number | boolean>): string;
|
|
2972
|
+
/**
|
|
2973
|
+
* Build a URL with path parameters
|
|
2974
|
+
*/
|
|
2975
|
+
declare function buildUrl(pathPattern: string, params?: Record<string, string | number | boolean>, query?: Record<string, string | number | boolean>): string;
|
|
2976
|
+
|
|
2902
2977
|
/**
|
|
2903
2978
|
* Creates a BlaizeJS server instance
|
|
2904
2979
|
*/
|
|
@@ -3244,14 +3319,37 @@ declare class RequestTimeoutError extends BlaizeError {
|
|
|
3244
3319
|
constructor(title: string, details?: unknown, correlationId?: string);
|
|
3245
3320
|
}
|
|
3246
3321
|
|
|
3247
|
-
declare class
|
|
3322
|
+
declare class UnprocessableEntityError extends BlaizeError {
|
|
3248
3323
|
constructor(title: string, details?: unknown, correlationId?: string);
|
|
3249
3324
|
}
|
|
3250
3325
|
|
|
3251
|
-
declare class
|
|
3326
|
+
declare class UnsupportedMediaTypeError extends BlaizeError {
|
|
3252
3327
|
constructor(title: string, details?: unknown, correlationId?: string);
|
|
3253
3328
|
}
|
|
3254
3329
|
|
|
3330
|
+
/**
|
|
3331
|
+
* Error thrown when a service is temporarily unavailable
|
|
3332
|
+
*
|
|
3333
|
+
* Automatically sets HTTP status to 503 and optionally includes Retry-After.
|
|
3334
|
+
*
|
|
3335
|
+
* @example Basic usage:
|
|
3336
|
+
* ```typescript
|
|
3337
|
+
* throw new ServiceNotAvailableError('Database unavailable');
|
|
3338
|
+
* ```
|
|
3339
|
+
*
|
|
3340
|
+
* @example With retry guidance:
|
|
3341
|
+
* ```typescript
|
|
3342
|
+
* throw new ServiceNotAvailableError('Payment service down', {
|
|
3343
|
+
* service: 'stripe',
|
|
3344
|
+
* retryAfter: 30,
|
|
3345
|
+
* reason: 'circuit_breaker'
|
|
3346
|
+
* });
|
|
3347
|
+
* ```
|
|
3348
|
+
*/
|
|
3349
|
+
declare class ServiceNotAvailableError extends BlaizeError<ServiceNotAvailableDetails> {
|
|
3350
|
+
constructor(title: string, details?: ServiceNotAvailableDetails | undefined, correlationId?: string | undefined);
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3255
3353
|
declare const VERSION = "0.1.0";
|
|
3256
3354
|
declare const ServerAPI: {
|
|
3257
3355
|
createServer: typeof create;
|
|
@@ -3266,12 +3364,18 @@ declare const RouterAPI: {
|
|
|
3266
3364
|
createPostRoute: CreatePostRoute;
|
|
3267
3365
|
createPutRoute: CreatePutRoute;
|
|
3268
3366
|
createRouteFactory: typeof createRouteFactory;
|
|
3367
|
+
createMatcher: typeof createMatcher;
|
|
3368
|
+
extractParams: typeof extractParams;
|
|
3369
|
+
compilePathPattern: typeof compilePathPattern;
|
|
3370
|
+
paramsToQuery: typeof paramsToQuery;
|
|
3371
|
+
buildUrl: typeof buildUrl;
|
|
3269
3372
|
};
|
|
3270
3373
|
declare const MiddlewareAPI: {
|
|
3271
3374
|
createMiddleware: typeof create$2;
|
|
3272
3375
|
createServiceMiddleware: typeof serviceMiddleware;
|
|
3273
3376
|
createStateMiddleware: typeof stateMiddleware;
|
|
3274
3377
|
compose: typeof compose;
|
|
3378
|
+
cors: typeof cors;
|
|
3275
3379
|
};
|
|
3276
3380
|
declare const PluginsAPI: {
|
|
3277
3381
|
createPlugin: typeof create$1;
|
|
@@ -3297,12 +3401,18 @@ declare const Blaize: {
|
|
|
3297
3401
|
createPostRoute: CreatePostRoute;
|
|
3298
3402
|
createPutRoute: CreatePutRoute;
|
|
3299
3403
|
createRouteFactory: typeof createRouteFactory;
|
|
3404
|
+
createMatcher: typeof createMatcher;
|
|
3405
|
+
extractParams: typeof extractParams;
|
|
3406
|
+
compilePathPattern: typeof compilePathPattern;
|
|
3407
|
+
paramsToQuery: typeof paramsToQuery;
|
|
3408
|
+
buildUrl: typeof buildUrl;
|
|
3300
3409
|
};
|
|
3301
3410
|
Middleware: {
|
|
3302
3411
|
createMiddleware: typeof create$2;
|
|
3303
3412
|
createServiceMiddleware: typeof serviceMiddleware;
|
|
3304
3413
|
createStateMiddleware: typeof stateMiddleware;
|
|
3305
3414
|
compose: typeof compose;
|
|
3415
|
+
cors: typeof cors;
|
|
3306
3416
|
};
|
|
3307
3417
|
Plugins: {
|
|
3308
3418
|
createPlugin: typeof create$1;
|
|
@@ -3310,4 +3420,4 @@ declare const Blaize: {
|
|
|
3310
3420
|
VERSION: string;
|
|
3311
3421
|
};
|
|
3312
3422
|
|
|
3313
|
-
export { Blaize, BlaizeError, type BlaizeErrorResponse, type BodyParseError, type BufferedEvent, type BuildRoutesRegistry, type BuildSSEArgs, type CacheConfig, type CacheEntry, type ClientConfig, type CloseEvent, type ComposeMiddlewareServices, type ComposeMiddlewareStates, type ComposeMiddlewareTypes, type ComposePluginServices, type ComposePluginStates, type ComposePluginTypes, ConflictError, type ConflictErrorDetails, type ConnectionEntry, type ConnectionRegistry, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CorrelationOptions, type CorsHttpMethod, type CorsOptions, type CorsOrigin, type CorsOriginCacheConfig, type CorsOriginCacheEntry, type CorsPreflightInfo, type CorsStats, type CorsValidationResult, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateEnhancedClient, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type CreateSSEMethod, type CreateSSERoute, type ErrorHandlerOptions, ErrorSeverity, type ErrorTransformContext, ErrorType, type EventHandlers, type ExtractMethod, type ExtractMiddlewareServices, type ExtractMiddlewareState, type ExtractMiddlewareTypes, type ExtractPluginServices, type ExtractPluginState, type ExtractPluginTypes, type ExtractSSEEvents, type ExtractSSEParams, type ExtractSSEQuery, type ExtractSSERoutes, type FileCache, type FindRouteFilesOptions, ForbiddenError, type ForbiddenErrorDetails, type GetContextFn, type HasSSEMethod, type Http2Options, type HttpMethod, type Infer, type InferContext, type InternalRequestArgs, InternalServerError, type InternalServerErrorDetails, type Matcher, type MergeServices, type MergeStates, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type MultipartData, type MultipartError, type MultipartLimits, type NetworkErrorContext, type NextFunction, NotFoundError, type NotFoundErrorDetails, type ParseErrorContext, type ParseOptions, type ParseResult, type ParsedRoute, type ParserState, PayloadTooLargeError, type PayloadTooLargeErrorDetails, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type ProcessingConfig, type QueryParams, RateLimitError, type RateLimitErrorDetails, type ReconnectStrategy, type RegistryResult, type ReloadMetrics, type RequestHandler, type RequestOptions, type RequestParams, RequestTimeoutError, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteRegistry, type RouteSchema, type Router, RouterAPI, type RouterOptions, type SSEBufferOverflowErrorDetails, type SSEBufferStrategy, type SSEClient, type SSEClientMetrics, type SSEClientOptions, type SSEConnectionErrorContext, type SSEConnectionErrorDetails, type SSEConnectionFactory, type SSEConnectionState, type SSEEvent, type SSEEventHandler, type SSEEventListener, type SSEHeartbeatErrorContext, type SSEMetrics, type SSEOptions, type SSERouteHandler, type SSERouteSchema, type SSESerializedEvent, type SSEStream, type SSEStreamClosedErrorDetails, type SSEStreamErrorContext, type SSEStreamExtended, type SSEStreamManager, type SafeComposeMiddlewareServices, type SafeComposeMiddlewareStates, type SafeComposePluginServices, type SafeComposePluginStates, type SafeExtractMiddlewareServices, type SafeExtractMiddlewareState, type SafeExtractPluginServices, type SafeExtractPluginState, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type Services, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamMetrics, type StreamOptions, type TimeoutErrorContext, type TypedSSEStream, UnauthorizedError, type UnauthorizedErrorDetails, type UnifiedRequest, type UnifiedResponse, type UnionToIntersection, type UnknownFunction, type UnknownServer, UnprocessableEntityError, UnsupportedMediaTypeError, type UnsupportedMediaTypeErrorDetails, type UploadProgress, type UploadedFile, VERSION, type ValidationConfig, ValidationError, type ValidationErrorDetails, type ValidationFieldError, type WatchOptions, asMiddlewareArray, asPluginArray, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createMiddlewareArray, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPluginArray, createPostRoute, createPutRoute, createRouteFactory, create as createServer, serviceMiddleware as createServiceMiddleware, stateMiddleware as createStateMiddleware, getCorrelationId, inferContext, isBodyParseError, isMiddleware, isPlugin };
|
|
3423
|
+
export { Blaize, BlaizeError, type BlaizeErrorResponse, type BodyParseError, type BufferedEvent, type BuildRoutesRegistry, type BuildSSEArgs, type CacheConfig, type CacheEntry, type ClientConfig, type CloseEvent, type ComposeMiddlewareServices, type ComposeMiddlewareStates, type ComposeMiddlewareTypes, type ComposePluginServices, type ComposePluginStates, type ComposePluginTypes, ConflictError, type ConflictErrorDetails, type ConnectionEntry, type ConnectionRegistry, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CorrelationOptions, type CorsHttpMethod, type CorsOptions, type CorsOrigin, type CorsOriginCacheConfig, type CorsOriginCacheEntry, type CorsPreflightInfo, type CorsStats, type CorsValidationResult, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateEnhancedClient, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type CreateSSEMethod, type CreateSSERoute, type ErrorHandlerOptions, ErrorSeverity, type ErrorTransformContext, ErrorType, type EventHandlers, type ExtractMethod, type ExtractMiddlewareServices, type ExtractMiddlewareState, type ExtractMiddlewareTypes, type ExtractPluginServices, type ExtractPluginState, type ExtractPluginTypes, type ExtractSSEEvents, type ExtractSSEParams, type ExtractSSEQuery, type ExtractSSERoutes, type FileCache, type FindRouteFilesOptions, ForbiddenError, type ForbiddenErrorDetails, type GetContextFn, type HasSSEMethod, type Http2Options, type HttpMethod, type Infer, type InferContext, type InternalRequestArgs, InternalServerError, type InternalServerErrorDetails, type Matcher, type MergeServices, type MergeStates, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type MultipartData, type MultipartError, type MultipartLimits, type NetworkErrorContext, type NextFunction, NotFoundError, type NotFoundErrorDetails, type ParseErrorContext, type ParseOptions, type ParseResult, type ParsedRoute, type ParserState, PayloadTooLargeError, type PayloadTooLargeErrorDetails, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type ProcessingConfig, type QueryParams, RateLimitError, type RateLimitErrorDetails, type ReconnectStrategy, type RegistryResult, type ReloadMetrics, type RequestHandler, type RequestOptions, type RequestParams, RequestTimeoutError, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteRegistry, type RouteSchema, type Router, RouterAPI, type RouterOptions, type SSEBufferOverflowErrorDetails, type SSEBufferStrategy, type SSEClient, type SSEClientMetrics, type SSEClientOptions, type SSEConnectionErrorContext, type SSEConnectionErrorDetails, type SSEConnectionFactory, type SSEConnectionState, type SSEEvent, type SSEEventHandler, type SSEEventListener, type SSEHeartbeatErrorContext, type SSEMetrics, type SSEOptions, type SSERouteHandler, type SSERouteSchema, type SSESerializedEvent, type SSEStream, type SSEStreamClosedErrorDetails, type SSEStreamErrorContext, type SSEStreamExtended, type SSEStreamManager, type SafeComposeMiddlewareServices, type SafeComposeMiddlewareStates, type SafeComposePluginServices, type SafeComposePluginStates, type SafeExtractMiddlewareServices, type SafeExtractMiddlewareState, type SafeExtractPluginServices, type SafeExtractPluginState, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type ServiceNotAvailableDetails, ServiceNotAvailableError, type Services, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamMetrics, type StreamOptions, type TimeoutErrorContext, type TypedSSEStream, UnauthorizedError, type UnauthorizedErrorDetails, type UnifiedRequest, type UnifiedResponse, type UnionToIntersection, type UnknownFunction, type UnknownServer, UnprocessableEntityError, UnsupportedMediaTypeError, type UnsupportedMediaTypeErrorDetails, type UploadProgress, type UploadedFile, VERSION, type ValidationConfig, ValidationError, type ValidationErrorDetails, type ValidationFieldError, type WatchOptions, asMiddlewareArray, asPluginArray, buildUrl, compilePathPattern, compose, cors, createDeleteRoute, createGetRoute, createHeadRoute, createMatcher, create$2 as createMiddleware, createMiddlewareArray, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPluginArray, createPostRoute, createPutRoute, createRouteFactory, create as createServer, serviceMiddleware as createServiceMiddleware, stateMiddleware as createStateMiddleware, extractParams, getCorrelationId, inferContext, isBodyParseError, isMiddleware, isPlugin, paramsToQuery };
|