blaizejs 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-MZG6O7BX.js → chunk-CU6DW3O3.js} +2 -2
- package/dist/{chunk-CM6LIHRF.js → chunk-MITKFOF6.js} +3 -3
- package/dist/{chunk-HQRQVJL6.js → chunk-MTQFFU7R.js} +3 -3
- package/dist/{chunk-J5FJFX2G.js → chunk-QI76VJZJ.js} +3 -3
- package/dist/{chunk-FLI2OVQ5.js → chunk-XSO4EY47.js} +3 -3
- package/dist/index.cjs +17 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -11
- package/dist/index.d.ts +45 -11
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/dist/{internal-server-error-RRNSAEYK.js → internal-server-error-HHP6KU77.js} +3 -3
- package/dist/{payload-too-large-error-SQMCGPZ7.js → payload-too-large-error-PYFKUBOM.js} +3 -3
- package/dist/{unsupported-media-type-error-6T47SVVY.js → unsupported-media-type-error-5B5SHATA.js} +3 -3
- package/dist/{validation-error-DRCBJ7IF.js → validation-error-RO5FS3GN.js} +3 -3
- package/package.json +1 -1
- /package/dist/{chunk-MZG6O7BX.js.map → chunk-CU6DW3O3.js.map} +0 -0
- /package/dist/{chunk-CM6LIHRF.js.map → chunk-MITKFOF6.js.map} +0 -0
- /package/dist/{chunk-HQRQVJL6.js.map → chunk-MTQFFU7R.js.map} +0 -0
- /package/dist/{chunk-J5FJFX2G.js.map → chunk-QI76VJZJ.js.map} +0 -0
- /package/dist/{chunk-FLI2OVQ5.js.map → chunk-XSO4EY47.js.map} +0 -0
- /package/dist/{internal-server-error-RRNSAEYK.js.map → internal-server-error-HHP6KU77.js.map} +0 -0
- /package/dist/{payload-too-large-error-SQMCGPZ7.js.map → payload-too-large-error-PYFKUBOM.js.map} +0 -0
- /package/dist/{unsupported-media-type-error-6T47SVVY.js.map → unsupported-media-type-error-5B5SHATA.js.map} +0 -0
- /package/dist/{validation-error-DRCBJ7IF.js.map → validation-error-RO5FS3GN.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -2210,7 +2210,7 @@ interface SSERouteSchema<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodTy
|
|
|
2210
2210
|
* This is the user-facing API - they write handlers with this signature
|
|
2211
2211
|
*/
|
|
2212
2212
|
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
|
|
2213
|
-
params: TParams) => Promise<void> | void;
|
|
2213
|
+
params: TParams, logger: BlaizeLogger) => Promise<void> | void;
|
|
2214
2214
|
/**
|
|
2215
2215
|
* SSE route creator with state and services support
|
|
2216
2216
|
* Returns a higher-order function to handle generics properly
|
|
@@ -2231,7 +2231,7 @@ type CreateSSERoute = <TState extends State = State, TServices extends Services
|
|
|
2231
2231
|
options?: Record<string, unknown>;
|
|
2232
2232
|
}) => {
|
|
2233
2233
|
GET: {
|
|
2234
|
-
handler: (ctx: any, params: any) => Promise<void>;
|
|
2234
|
+
handler: (ctx: any, params: any, logger: BlaizeLogger) => Promise<void>;
|
|
2235
2235
|
schema?: {
|
|
2236
2236
|
params?: P extends never ? undefined : P;
|
|
2237
2237
|
query?: Q extends never ? undefined : Q;
|
|
@@ -2239,6 +2239,13 @@ type CreateSSERoute = <TState extends State = State, TServices extends Services
|
|
|
2239
2239
|
middleware?: Middleware[];
|
|
2240
2240
|
options?: Record<string, unknown>;
|
|
2241
2241
|
};
|
|
2242
|
+
SSE: {
|
|
2243
|
+
schema: {
|
|
2244
|
+
params?: P extends never ? undefined : P;
|
|
2245
|
+
query?: Q extends never ? undefined : Q;
|
|
2246
|
+
events?: E extends never ? undefined : E;
|
|
2247
|
+
};
|
|
2248
|
+
};
|
|
2242
2249
|
path: string;
|
|
2243
2250
|
};
|
|
2244
2251
|
/**
|
|
@@ -2427,14 +2434,21 @@ interface RequestOptions {
|
|
|
2427
2434
|
type HasSSEMethod<TRoute> = TRoute extends {
|
|
2428
2435
|
SSE: any;
|
|
2429
2436
|
} ? true : false;
|
|
2437
|
+
/**
|
|
2438
|
+
* Extract SSE event types from route schema
|
|
2439
|
+
*/
|
|
2430
2440
|
/**
|
|
2431
2441
|
* Extract SSE event types from route schema
|
|
2432
2442
|
*/
|
|
2433
2443
|
type ExtractSSEEvents<TRoute> = TRoute extends {
|
|
2434
2444
|
SSE: {
|
|
2435
|
-
|
|
2445
|
+
schema?: {
|
|
2446
|
+
events?: infer E;
|
|
2447
|
+
};
|
|
2436
2448
|
};
|
|
2437
|
-
} ? E extends z.ZodType ? z.infer<E> : Record<string,
|
|
2449
|
+
} ? E extends z.ZodType ? z.infer<E> : E extends Record<string, z.ZodType> ? {
|
|
2450
|
+
[K in keyof E]: z.infer<E[K]>;
|
|
2451
|
+
} : Record<string, unknown> : Record<string, unknown>;
|
|
2438
2452
|
/**
|
|
2439
2453
|
* Extract SSE query parameters from route
|
|
2440
2454
|
*/
|
|
@@ -2444,7 +2458,7 @@ type ExtractSSEQuery<TRoute> = TRoute extends {
|
|
|
2444
2458
|
query?: infer Q;
|
|
2445
2459
|
};
|
|
2446
2460
|
};
|
|
2447
|
-
} ? Q extends z.ZodType ? z.infer<Q> :
|
|
2461
|
+
} ? Q extends z.ZodType ? z.infer<Q> : never : never;
|
|
2448
2462
|
/**
|
|
2449
2463
|
* Extract SSE params from route
|
|
2450
2464
|
*/
|
|
@@ -2454,22 +2468,35 @@ type ExtractSSEParams<TRoute> = TRoute extends {
|
|
|
2454
2468
|
params?: infer P;
|
|
2455
2469
|
};
|
|
2456
2470
|
};
|
|
2457
|
-
} ? P extends z.ZodType ? z.infer<P> :
|
|
2471
|
+
} ? P extends z.ZodType ? z.infer<P> : never : never;
|
|
2472
|
+
/**
|
|
2473
|
+
* Check if an object type has any required keys
|
|
2474
|
+
*/
|
|
2475
|
+
type HasRequiredKeys<T> = {
|
|
2476
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
2477
|
+
}[keyof T] extends never ? false : true;
|
|
2458
2478
|
/**
|
|
2459
|
-
* Build SSE method arguments
|
|
2479
|
+
* Build SSE method arguments with proper optionality
|
|
2460
2480
|
*/
|
|
2461
2481
|
type BuildSSEArgs<TRoute> = ExtractSSEParams<TRoute> extends never ? ExtractSSEQuery<TRoute> extends never ? {
|
|
2462
2482
|
options?: SSEClientOptions;
|
|
2463
|
-
} : {
|
|
2483
|
+
} : HasRequiredKeys<ExtractSSEQuery<TRoute>> extends true ? {
|
|
2464
2484
|
query: ExtractSSEQuery<TRoute>;
|
|
2465
2485
|
options?: SSEClientOptions;
|
|
2486
|
+
} : {
|
|
2487
|
+
query?: ExtractSSEQuery<TRoute>;
|
|
2488
|
+
options?: SSEClientOptions;
|
|
2466
2489
|
} : ExtractSSEQuery<TRoute> extends never ? {
|
|
2467
2490
|
params: ExtractSSEParams<TRoute>;
|
|
2468
2491
|
options?: SSEClientOptions;
|
|
2469
|
-
} : {
|
|
2492
|
+
} : HasRequiredKeys<ExtractSSEQuery<TRoute>> extends true ? {
|
|
2470
2493
|
params: ExtractSSEParams<TRoute>;
|
|
2471
2494
|
query: ExtractSSEQuery<TRoute>;
|
|
2472
2495
|
options?: SSEClientOptions;
|
|
2496
|
+
} : {
|
|
2497
|
+
params: ExtractSSEParams<TRoute>;
|
|
2498
|
+
query?: ExtractSSEQuery<TRoute>;
|
|
2499
|
+
options?: SSEClientOptions;
|
|
2473
2500
|
};
|
|
2474
2501
|
/**
|
|
2475
2502
|
* Create SSE client method
|
|
@@ -4241,7 +4268,7 @@ declare function createRouteFactory<TState extends State = State, TServices exte
|
|
|
4241
4268
|
options?: Record<string, unknown>;
|
|
4242
4269
|
}) => {
|
|
4243
4270
|
GET: {
|
|
4244
|
-
handler: (ctx: any, params: any) => Promise<void>;
|
|
4271
|
+
handler: (ctx: any, params: any, logger: BlaizeLogger) => Promise<void>;
|
|
4245
4272
|
schema?: {
|
|
4246
4273
|
params?: (P extends never ? undefined : P) | undefined;
|
|
4247
4274
|
query?: (Q extends never ? undefined : Q) | undefined;
|
|
@@ -4249,6 +4276,13 @@ declare function createRouteFactory<TState extends State = State, TServices exte
|
|
|
4249
4276
|
middleware?: Middleware[];
|
|
4250
4277
|
options?: Record<string, unknown>;
|
|
4251
4278
|
};
|
|
4279
|
+
SSE: {
|
|
4280
|
+
schema: {
|
|
4281
|
+
params?: (P extends never ? undefined : P) | undefined;
|
|
4282
|
+
query?: (Q extends never ? undefined : Q) | undefined;
|
|
4283
|
+
events?: (E extends never ? undefined : E) | undefined;
|
|
4284
|
+
};
|
|
4285
|
+
};
|
|
4252
4286
|
path: string;
|
|
4253
4287
|
};
|
|
4254
4288
|
};
|
|
@@ -4654,7 +4688,7 @@ declare class ServiceNotAvailableError extends BlaizeError<ServiceNotAvailableDe
|
|
|
4654
4688
|
constructor(title: string, details?: ServiceNotAvailableDetails | undefined, correlationId?: string | undefined);
|
|
4655
4689
|
}
|
|
4656
4690
|
|
|
4657
|
-
declare const VERSION
|
|
4691
|
+
declare const VERSION: string;
|
|
4658
4692
|
declare const ServerAPI: {
|
|
4659
4693
|
createServer: typeof create;
|
|
4660
4694
|
inferContext: typeof inferContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -2210,7 +2210,7 @@ interface SSERouteSchema<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodTy
|
|
|
2210
2210
|
* This is the user-facing API - they write handlers with this signature
|
|
2211
2211
|
*/
|
|
2212
2212
|
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
|
|
2213
|
-
params: TParams) => Promise<void> | void;
|
|
2213
|
+
params: TParams, logger: BlaizeLogger) => Promise<void> | void;
|
|
2214
2214
|
/**
|
|
2215
2215
|
* SSE route creator with state and services support
|
|
2216
2216
|
* Returns a higher-order function to handle generics properly
|
|
@@ -2231,7 +2231,7 @@ type CreateSSERoute = <TState extends State = State, TServices extends Services
|
|
|
2231
2231
|
options?: Record<string, unknown>;
|
|
2232
2232
|
}) => {
|
|
2233
2233
|
GET: {
|
|
2234
|
-
handler: (ctx: any, params: any) => Promise<void>;
|
|
2234
|
+
handler: (ctx: any, params: any, logger: BlaizeLogger) => Promise<void>;
|
|
2235
2235
|
schema?: {
|
|
2236
2236
|
params?: P extends never ? undefined : P;
|
|
2237
2237
|
query?: Q extends never ? undefined : Q;
|
|
@@ -2239,6 +2239,13 @@ type CreateSSERoute = <TState extends State = State, TServices extends Services
|
|
|
2239
2239
|
middleware?: Middleware[];
|
|
2240
2240
|
options?: Record<string, unknown>;
|
|
2241
2241
|
};
|
|
2242
|
+
SSE: {
|
|
2243
|
+
schema: {
|
|
2244
|
+
params?: P extends never ? undefined : P;
|
|
2245
|
+
query?: Q extends never ? undefined : Q;
|
|
2246
|
+
events?: E extends never ? undefined : E;
|
|
2247
|
+
};
|
|
2248
|
+
};
|
|
2242
2249
|
path: string;
|
|
2243
2250
|
};
|
|
2244
2251
|
/**
|
|
@@ -2427,14 +2434,21 @@ interface RequestOptions {
|
|
|
2427
2434
|
type HasSSEMethod<TRoute> = TRoute extends {
|
|
2428
2435
|
SSE: any;
|
|
2429
2436
|
} ? true : false;
|
|
2437
|
+
/**
|
|
2438
|
+
* Extract SSE event types from route schema
|
|
2439
|
+
*/
|
|
2430
2440
|
/**
|
|
2431
2441
|
* Extract SSE event types from route schema
|
|
2432
2442
|
*/
|
|
2433
2443
|
type ExtractSSEEvents<TRoute> = TRoute extends {
|
|
2434
2444
|
SSE: {
|
|
2435
|
-
|
|
2445
|
+
schema?: {
|
|
2446
|
+
events?: infer E;
|
|
2447
|
+
};
|
|
2436
2448
|
};
|
|
2437
|
-
} ? E extends z.ZodType ? z.infer<E> : Record<string,
|
|
2449
|
+
} ? E extends z.ZodType ? z.infer<E> : E extends Record<string, z.ZodType> ? {
|
|
2450
|
+
[K in keyof E]: z.infer<E[K]>;
|
|
2451
|
+
} : Record<string, unknown> : Record<string, unknown>;
|
|
2438
2452
|
/**
|
|
2439
2453
|
* Extract SSE query parameters from route
|
|
2440
2454
|
*/
|
|
@@ -2444,7 +2458,7 @@ type ExtractSSEQuery<TRoute> = TRoute extends {
|
|
|
2444
2458
|
query?: infer Q;
|
|
2445
2459
|
};
|
|
2446
2460
|
};
|
|
2447
|
-
} ? Q extends z.ZodType ? z.infer<Q> :
|
|
2461
|
+
} ? Q extends z.ZodType ? z.infer<Q> : never : never;
|
|
2448
2462
|
/**
|
|
2449
2463
|
* Extract SSE params from route
|
|
2450
2464
|
*/
|
|
@@ -2454,22 +2468,35 @@ type ExtractSSEParams<TRoute> = TRoute extends {
|
|
|
2454
2468
|
params?: infer P;
|
|
2455
2469
|
};
|
|
2456
2470
|
};
|
|
2457
|
-
} ? P extends z.ZodType ? z.infer<P> :
|
|
2471
|
+
} ? P extends z.ZodType ? z.infer<P> : never : never;
|
|
2472
|
+
/**
|
|
2473
|
+
* Check if an object type has any required keys
|
|
2474
|
+
*/
|
|
2475
|
+
type HasRequiredKeys<T> = {
|
|
2476
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
2477
|
+
}[keyof T] extends never ? false : true;
|
|
2458
2478
|
/**
|
|
2459
|
-
* Build SSE method arguments
|
|
2479
|
+
* Build SSE method arguments with proper optionality
|
|
2460
2480
|
*/
|
|
2461
2481
|
type BuildSSEArgs<TRoute> = ExtractSSEParams<TRoute> extends never ? ExtractSSEQuery<TRoute> extends never ? {
|
|
2462
2482
|
options?: SSEClientOptions;
|
|
2463
|
-
} : {
|
|
2483
|
+
} : HasRequiredKeys<ExtractSSEQuery<TRoute>> extends true ? {
|
|
2464
2484
|
query: ExtractSSEQuery<TRoute>;
|
|
2465
2485
|
options?: SSEClientOptions;
|
|
2486
|
+
} : {
|
|
2487
|
+
query?: ExtractSSEQuery<TRoute>;
|
|
2488
|
+
options?: SSEClientOptions;
|
|
2466
2489
|
} : ExtractSSEQuery<TRoute> extends never ? {
|
|
2467
2490
|
params: ExtractSSEParams<TRoute>;
|
|
2468
2491
|
options?: SSEClientOptions;
|
|
2469
|
-
} : {
|
|
2492
|
+
} : HasRequiredKeys<ExtractSSEQuery<TRoute>> extends true ? {
|
|
2470
2493
|
params: ExtractSSEParams<TRoute>;
|
|
2471
2494
|
query: ExtractSSEQuery<TRoute>;
|
|
2472
2495
|
options?: SSEClientOptions;
|
|
2496
|
+
} : {
|
|
2497
|
+
params: ExtractSSEParams<TRoute>;
|
|
2498
|
+
query?: ExtractSSEQuery<TRoute>;
|
|
2499
|
+
options?: SSEClientOptions;
|
|
2473
2500
|
};
|
|
2474
2501
|
/**
|
|
2475
2502
|
* Create SSE client method
|
|
@@ -4241,7 +4268,7 @@ declare function createRouteFactory<TState extends State = State, TServices exte
|
|
|
4241
4268
|
options?: Record<string, unknown>;
|
|
4242
4269
|
}) => {
|
|
4243
4270
|
GET: {
|
|
4244
|
-
handler: (ctx: any, params: any) => Promise<void>;
|
|
4271
|
+
handler: (ctx: any, params: any, logger: BlaizeLogger) => Promise<void>;
|
|
4245
4272
|
schema?: {
|
|
4246
4273
|
params?: (P extends never ? undefined : P) | undefined;
|
|
4247
4274
|
query?: (Q extends never ? undefined : Q) | undefined;
|
|
@@ -4249,6 +4276,13 @@ declare function createRouteFactory<TState extends State = State, TServices exte
|
|
|
4249
4276
|
middleware?: Middleware[];
|
|
4250
4277
|
options?: Record<string, unknown>;
|
|
4251
4278
|
};
|
|
4279
|
+
SSE: {
|
|
4280
|
+
schema: {
|
|
4281
|
+
params?: (P extends never ? undefined : P) | undefined;
|
|
4282
|
+
query?: (Q extends never ? undefined : Q) | undefined;
|
|
4283
|
+
events?: (E extends never ? undefined : E) | undefined;
|
|
4284
|
+
};
|
|
4285
|
+
};
|
|
4252
4286
|
path: string;
|
|
4253
4287
|
};
|
|
4254
4288
|
};
|
|
@@ -4654,7 +4688,7 @@ declare class ServiceNotAvailableError extends BlaizeError<ServiceNotAvailableDe
|
|
|
4654
4688
|
constructor(title: string, details?: ServiceNotAvailableDetails | undefined, correlationId?: string | undefined);
|
|
4655
4689
|
}
|
|
4656
4690
|
|
|
4657
|
-
declare const VERSION
|
|
4691
|
+
declare const VERSION: string;
|
|
4658
4692
|
declare const ServerAPI: {
|
|
4659
4693
|
createServer: typeof create;
|
|
4660
4694
|
inferContext: typeof inferContext;
|