spiceflow 1.1.7 → 1.1.9

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.
Files changed (61) hide show
  1. package/README.md +177 -92
  2. package/dist/benchmark.benchmark.js.map +1 -1
  3. package/dist/client/errors.d.ts.map +1 -1
  4. package/dist/client/errors.js.map +1 -1
  5. package/dist/client/index.d.ts.map +1 -1
  6. package/dist/client/index.js +8 -12
  7. package/dist/client/index.js.map +1 -1
  8. package/dist/client/types.d.ts.map +1 -1
  9. package/dist/client/utils.js.map +1 -1
  10. package/dist/client/ws.d.ts.map +1 -1
  11. package/dist/client/ws.js +1 -3
  12. package/dist/client/ws.js.map +1 -1
  13. package/dist/client.test.js.map +1 -1
  14. package/dist/context.d.ts.map +1 -1
  15. package/dist/cors.d.ts.map +1 -1
  16. package/dist/cors.js.map +1 -1
  17. package/dist/cors.test.js.map +1 -1
  18. package/dist/error.d.ts.map +1 -1
  19. package/dist/error.js.map +1 -1
  20. package/dist/middleware.test.js +65 -0
  21. package/dist/middleware.test.js.map +1 -1
  22. package/dist/openapi.d.ts.map +1 -1
  23. package/dist/openapi.js +1 -1
  24. package/dist/openapi.js.map +1 -1
  25. package/dist/openapi.test.js.map +1 -1
  26. package/dist/spiceflow.d.ts.map +1 -1
  27. package/dist/spiceflow.js +12 -5
  28. package/dist/spiceflow.js.map +1 -1
  29. package/dist/spiceflow.test.js.map +1 -1
  30. package/dist/stream.test.js +6 -6
  31. package/dist/stream.test.js.map +1 -1
  32. package/dist/types.d.ts +1 -1
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js.map +1 -1
  35. package/dist/types.test.js +56 -6
  36. package/dist/types.test.js.map +1 -1
  37. package/dist/utils.d.ts.map +1 -1
  38. package/dist/utils.js.map +1 -1
  39. package/dist/zod.test.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/benchmark.benchmark.ts +8 -8
  42. package/src/client/errors.ts +17 -17
  43. package/src/client/index.ts +437 -469
  44. package/src/client/types.ts +168 -191
  45. package/src/client/utils.ts +5 -5
  46. package/src/client/ws.ts +87 -89
  47. package/src/client.test.ts +176 -183
  48. package/src/context.ts +82 -82
  49. package/src/cors.test.ts +38 -38
  50. package/src/cors.ts +87 -92
  51. package/src/error.ts +13 -13
  52. package/src/middleware.test.ts +221 -149
  53. package/src/openapi.test.ts +97 -97
  54. package/src/openapi.ts +365 -365
  55. package/src/spiceflow.test.ts +461 -467
  56. package/src/spiceflow.ts +1117 -1157
  57. package/src/stream.test.ts +310 -310
  58. package/src/types.test.ts +59 -39
  59. package/src/types.ts +698 -701
  60. package/src/utils.ts +79 -79
  61. package/src/zod.test.ts +64 -64
package/src/types.ts CHANGED
@@ -5,11 +5,11 @@ import z from 'zod'
5
5
  import type { BunFile, Server } from 'bun'
6
6
 
7
7
  import type {
8
- OptionalKind,
9
- Static,
10
- StaticDecode,
11
- TObject,
12
- TSchema,
8
+ OptionalKind,
9
+ Static,
10
+ StaticDecode,
11
+ TObject,
12
+ TSchema,
13
13
  } from '@sinclair/typebox'
14
14
 
15
15
  import type { OpenAPIV3 } from 'openapi-types'
@@ -17,10 +17,10 @@ import type { OpenAPIV3 } from 'openapi-types'
17
17
  import { ZodObject, ZodTypeAny } from 'zod'
18
18
  import type { Context, ErrorContext, MiddlewareContext } from './context.js'
19
19
  import {
20
- ELYSIA_RESPONSE,
21
- InternalServerError,
22
- ParseError,
23
- ValidationError,
20
+ ELYSIA_RESPONSE,
21
+ InternalServerError,
22
+ ParseError,
23
+ ValidationError,
24
24
  } from './error.js'
25
25
  import { Spiceflow } from './spiceflow.js'
26
26
 
@@ -30,145 +30,146 @@ export type MaybePromise<T> = T | Promise<T>
30
30
  export type ObjectValues<T extends object> = T[keyof T]
31
31
 
32
32
  type IsPathParameter<Part extends string> = Part extends `:${infer Parameter}`
33
- ? Parameter
34
- : Part extends `*`
35
- ? '*'
36
- : never
33
+ ? Parameter
34
+ : Part extends `*`
35
+ ? '*'
36
+ : never
37
37
 
38
38
  export type GetPathParameter<Path extends string> =
39
- Path extends `${infer A}/${infer B}`
40
- ? IsPathParameter<A> | GetPathParameter<B>
41
- : IsPathParameter<Path>
39
+ Path extends `${infer A}/${infer B}`
40
+ ? IsPathParameter<A> | GetPathParameter<B>
41
+ : IsPathParameter<Path>
42
42
 
43
43
  export type ResolvePath<Path extends string> = Prettify<
44
- {
45
- [Param in GetPathParameter<Path> as Param extends `${string}?`
46
- ? never
47
- : Param]: string
48
- } & {
49
- [Param in GetPathParameter<Path> as Param extends `${infer OptionalParam}?`
50
- ? OptionalParam
51
- : never]?: string
52
- }
44
+ {
45
+ [Param in GetPathParameter<Path> as Param extends `${string}?`
46
+ ? never
47
+ : Param]: string
48
+ } & {
49
+ [Param in GetPathParameter<Path> as Param extends `${infer OptionalParam}?`
50
+ ? OptionalParam
51
+ : never]?: string
52
+ }
53
53
  >
54
54
 
55
55
  // https://twitter.com/mattpocockuk/status/1622730173446557697?s=20
56
56
  export type Prettify<T> = {
57
- [K in keyof T]: T[K]
57
+ [K in keyof T]: T[K]
58
58
  } & {}
59
59
 
60
60
  export type Prettify2<T> = {
61
- [K in keyof T]: Prettify<T[K]>
61
+ [K in keyof T]: Prettify<T[K]>
62
62
  } & {}
63
63
 
64
64
  export type Partial2<T> = {
65
- [K in keyof T]?: Partial<T[K]>
65
+ [K in keyof T]?: Partial<T[K]>
66
66
  }
67
67
 
68
68
  export type NeverKey<T> = {
69
- [K in keyof T]?: T[K]
69
+ [K in keyof T]?: T[K]
70
70
  } & {}
71
71
 
72
- type IsBothObject<A, B> = A extends Record<string | number | symbol, unknown>
73
- ? B extends Record<string | number | symbol, unknown>
74
- ? IsClass<A> extends false
75
- ? IsClass<B> extends false
76
- ? true
77
- : false
78
- : false
79
- : false
80
- : false
72
+ type IsBothObject<A, B> =
73
+ A extends Record<string | number | symbol, unknown>
74
+ ? B extends Record<string | number | symbol, unknown>
75
+ ? IsClass<A> extends false
76
+ ? IsClass<B> extends false
77
+ ? true
78
+ : false
79
+ : false
80
+ : false
81
+ : false
81
82
 
82
83
  type IsClass<V> = V extends abstract new (...args: any) => any ? true : false
83
84
  type And<A, B> = A extends true ? (B extends true ? true : false) : false
84
85
 
85
86
  export type Reconcile<
86
- A extends Object,
87
- B extends Object,
88
- Override extends boolean = false,
89
- // Detect Stack limit, eg. circular dependency
90
- Stack extends number[] = [],
87
+ A extends Object,
88
+ B extends Object,
89
+ Override extends boolean = false,
90
+ // Detect Stack limit, eg. circular dependency
91
+ Stack extends number[] = [],
91
92
  > = Stack['length'] extends 16
92
- ? A
93
- : Override extends true
94
- ? {
95
- [key in keyof A as key extends keyof B ? never : key]: A[key]
96
- } extends infer Collision
97
- ? {} extends Collision
98
- ? {
99
- [key in keyof B]: IsBothObject<
100
- // @ts-ignore trust me bro
101
- A[key],
102
- B[key]
103
- > extends true
104
- ? Reconcile<
105
- // @ts-ignore trust me bro
106
- A[key],
107
- B[key],
108
- Override,
109
- [0, ...Stack]
110
- >
111
- : B[key]
112
- }
113
- : Prettify<
114
- Collision & {
115
- [key in keyof B]: B[key]
116
- }
117
- >
118
- : never
119
- : {
120
- [key in keyof B as key extends keyof A ? never : key]: B[key]
121
- } extends infer Collision
122
- ? {} extends Collision
123
- ? {
124
- [key in keyof A]: IsBothObject<
125
- A[key],
126
- // @ts-ignore trust me bro
127
- B[key]
128
- > extends true
129
- ? Reconcile<
130
- // @ts-ignore trust me bro
131
- A[key],
132
- // @ts-ignore trust me bro
133
- B[key],
134
- Override,
135
- [0, ...Stack]
136
- >
137
- : A[key]
138
- }
139
- : Prettify<
140
- {
141
- [key in keyof A]: A[key]
142
- } & Collision
143
- >
144
- : never
93
+ ? A
94
+ : Override extends true
95
+ ? {
96
+ [key in keyof A as key extends keyof B ? never : key]: A[key]
97
+ } extends infer Collision
98
+ ? {} extends Collision
99
+ ? {
100
+ [key in keyof B]: IsBothObject<
101
+ // @ts-ignore trust me bro
102
+ A[key],
103
+ B[key]
104
+ > extends true
105
+ ? Reconcile<
106
+ // @ts-ignore trust me bro
107
+ A[key],
108
+ B[key],
109
+ Override,
110
+ [0, ...Stack]
111
+ >
112
+ : B[key]
113
+ }
114
+ : Prettify<
115
+ Collision & {
116
+ [key in keyof B]: B[key]
117
+ }
118
+ >
119
+ : never
120
+ : {
121
+ [key in keyof B as key extends keyof A ? never : key]: B[key]
122
+ } extends infer Collision
123
+ ? {} extends Collision
124
+ ? {
125
+ [key in keyof A]: IsBothObject<
126
+ A[key],
127
+ // @ts-ignore trust me bro
128
+ B[key]
129
+ > extends true
130
+ ? Reconcile<
131
+ // @ts-ignore trust me bro
132
+ A[key],
133
+ // @ts-ignore trust me bro
134
+ B[key],
135
+ Override,
136
+ [0, ...Stack]
137
+ >
138
+ : A[key]
139
+ }
140
+ : Prettify<
141
+ {
142
+ [key in keyof A]: A[key]
143
+ } & Collision
144
+ >
145
+ : never
145
146
 
146
147
  export interface SingletonBase {
147
- state: Record<string, unknown>
148
+ state: Record<string, unknown>
148
149
  }
149
150
 
150
151
  export interface DefinitionBase {
151
- type: Record<string, unknown>
152
- error: Record<string, Error>
152
+ type: Record<string, unknown>
153
+ error: Record<string, Error>
153
154
  }
154
155
 
155
156
  export type RouteBase = Record<string, unknown>
156
157
 
157
158
  export interface MetadataBase {
158
- schema: RouteSchema
159
- macro: BaseMacro
160
- macroFn: BaseMacroFn
159
+ schema: RouteSchema
160
+ macro: BaseMacro
161
+ macroFn: BaseMacroFn
161
162
  }
162
163
 
163
164
  export interface RouteSchema {
164
- body?: unknown
165
- query?: unknown
166
- params?: unknown
167
- response?: unknown
165
+ body?: unknown
166
+ query?: unknown
167
+ params?: unknown
168
+ response?: unknown
168
169
  }
169
170
 
170
171
  type OptionalField = {
171
- [OptionalKind]: 'Optional'
172
+ [OptionalKind]: 'Optional'
172
173
  }
173
174
 
174
175
  export type TypeSchema = TSchema | ZodTypeAny
@@ -176,320 +177,319 @@ export type TypeSchema = TSchema | ZodTypeAny
176
177
  export type TypeObject = TObject | ZodObject<any, any, any>
177
178
 
178
179
  export type UnwrapSchema<
179
- Schema extends TypeSchema | string | undefined,
180
- Definitions extends Record<string, unknown> = {},
180
+ Schema extends TypeSchema | string | undefined,
181
+ Definitions extends Record<string, unknown> = {},
181
182
  > = undefined extends Schema
182
- ? unknown
183
- : Schema extends ZodTypeAny
184
- ? z.infer<Schema>
185
- : Schema extends TSchema
186
- ? Schema extends OptionalField
187
- ? Prettify<Partial<Static<Schema>>>
188
- : StaticDecode<Schema>
189
- : Schema extends string
190
- ? Definitions extends Record<Schema, infer NamedSchema>
191
- ? NamedSchema
192
- : Definitions
193
- : unknown
183
+ ? unknown
184
+ : Schema extends ZodTypeAny
185
+ ? z.infer<Schema>
186
+ : Schema extends TSchema
187
+ ? Schema extends OptionalField
188
+ ? Prettify<Partial<Static<Schema>>>
189
+ : StaticDecode<Schema>
190
+ : Schema extends string
191
+ ? Definitions extends Record<Schema, infer NamedSchema>
192
+ ? NamedSchema
193
+ : Definitions
194
+ : unknown
194
195
 
195
196
  export interface UnwrapRoute<
196
- in out Schema extends InputSchema<any>,
197
- in out Definitions extends DefinitionBase['type'] = {},
197
+ in out Schema extends InputSchema<any>,
198
+ in out Definitions extends DefinitionBase['type'] = {},
198
199
  > {
199
- body: UnwrapSchema<Schema['body'], Definitions>
200
- query: UnwrapSchema<Schema['query'], Definitions>
201
- params: UnwrapSchema<Schema['params'], Definitions>
202
- response: Schema['response'] extends TypeSchema | string
203
- ? {
204
- 200: CoExist<
205
- UnwrapSchema<Schema['response'], Definitions>,
206
- File,
207
- BunFile
208
- >
209
- }
210
- : Schema['response'] extends Record<number, TypeSchema | string>
211
- ? {
212
- [k in keyof Schema['response']]: CoExist<
213
- UnwrapSchema<Schema['response'][k], Definitions>,
214
- File,
215
- BunFile
216
- >
217
- }
218
- : unknown | void
200
+ body: UnwrapSchema<Schema['body'], Definitions>
201
+ query: UnwrapSchema<Schema['query'], Definitions>
202
+ params: UnwrapSchema<Schema['params'], Definitions>
203
+ response: Schema['response'] extends TypeSchema | string
204
+ ? {
205
+ 200: CoExist<
206
+ UnwrapSchema<Schema['response'], Definitions>,
207
+ File,
208
+ BunFile
209
+ >
210
+ }
211
+ : Schema['response'] extends Record<number, TypeSchema | string>
212
+ ? {
213
+ [k in keyof Schema['response']]: CoExist<
214
+ UnwrapSchema<Schema['response'][k], Definitions>,
215
+ File,
216
+ BunFile
217
+ >
218
+ }
219
+ : unknown | void
219
220
  }
220
221
 
221
222
  export type LifeCycleEvent =
222
- | 'start'
223
- | 'request'
224
- | 'parse'
225
- | 'transform'
226
- | 'beforeHandle'
227
- | 'afterHandle'
228
- | 'response'
229
- | 'error'
230
- | 'stop'
223
+ | 'start'
224
+ | 'request'
225
+ | 'parse'
226
+ | 'transform'
227
+ | 'beforeHandle'
228
+ | 'afterHandle'
229
+ | 'response'
230
+ | 'error'
231
+ | 'stop'
231
232
 
232
233
  export type ContentType = MaybeArray<
233
- | (string & {})
234
- | 'none'
235
- | 'text'
236
- | 'json'
237
- | 'formdata'
238
- | 'urlencoded'
239
- | 'arrayBuffer'
240
- | 'text/plain'
241
- | 'application/json'
242
- | 'multipart/form-data'
243
- | 'application/x-www-form-urlencoded'
234
+ | (string & {})
235
+ | 'none'
236
+ | 'text'
237
+ | 'json'
238
+ | 'formdata'
239
+ | 'urlencoded'
240
+ | 'arrayBuffer'
241
+ | 'text/plain'
242
+ | 'application/json'
243
+ | 'multipart/form-data'
244
+ | 'application/x-www-form-urlencoded'
244
245
  >
245
246
 
246
247
  export type HTTPMethod =
247
- | (string & {})
248
- | 'ACL'
249
- | 'BIND'
250
- | 'CHECKOUT'
251
- | 'CONNECT'
252
- | 'COPY'
253
- | 'DELETE'
254
- | 'GET'
255
- | 'HEAD'
256
- | 'LINK'
257
- | 'LOCK'
258
- | 'M-SEARCH'
259
- | 'MERGE'
260
- | 'MKACTIVITY'
261
- | 'MKCALENDAR'
262
- | 'MKCOL'
263
- | 'MOVE'
264
- | 'NOTIFY'
265
- | 'OPTIONS'
266
- | 'PATCH'
267
- | 'POST'
268
- | 'PROPFIND'
269
- | 'PROPPATCH'
270
- | 'PURGE'
271
- | 'PUT'
272
- | 'REBIND'
273
- | 'REPORT'
274
- | 'SEARCH'
275
- | 'SOURCE'
276
- | 'SUBSCRIBE'
277
- | 'TRACE'
278
- | 'UNBIND'
279
- | 'UNLINK'
280
- | 'UNLOCK'
281
- | 'UNSUBSCRIBE'
282
- | 'ALL'
248
+ | (string & {})
249
+ | 'ACL'
250
+ | 'BIND'
251
+ | 'CHECKOUT'
252
+ | 'CONNECT'
253
+ | 'COPY'
254
+ | 'DELETE'
255
+ | 'GET'
256
+ | 'HEAD'
257
+ | 'LINK'
258
+ | 'LOCK'
259
+ | 'M-SEARCH'
260
+ | 'MERGE'
261
+ | 'MKACTIVITY'
262
+ | 'MKCALENDAR'
263
+ | 'MKCOL'
264
+ | 'MOVE'
265
+ | 'NOTIFY'
266
+ | 'OPTIONS'
267
+ | 'PATCH'
268
+ | 'POST'
269
+ | 'PROPFIND'
270
+ | 'PROPPATCH'
271
+ | 'PURGE'
272
+ | 'PUT'
273
+ | 'REBIND'
274
+ | 'REPORT'
275
+ | 'SEARCH'
276
+ | 'SOURCE'
277
+ | 'SUBSCRIBE'
278
+ | 'TRACE'
279
+ | 'UNBIND'
280
+ | 'UNLINK'
281
+ | 'UNLOCK'
282
+ | 'UNSUBSCRIBE'
283
+ | 'ALL'
283
284
 
284
285
  export interface InputSchema<Name extends string = string> {
285
- body?: TypeSchema | Name
286
- query?: TypeObject | Name
287
- params?: TypeObject | Name
288
- response?:
289
- | TypeSchema
290
- | Record<number, TypeSchema>
291
- | Name
292
- | Record<number, Name | TypeSchema>
286
+ body?: TypeSchema | Name
287
+ query?: TypeObject | Name
288
+ params?: TypeObject | Name
289
+ response?:
290
+ | TypeSchema
291
+ | Record<number, TypeSchema>
292
+ | Name
293
+ | Record<number, Name | TypeSchema>
293
294
  }
294
295
 
295
296
  export interface MergeSchema<
296
- in out A extends RouteSchema,
297
- in out B extends RouteSchema,
297
+ in out A extends RouteSchema,
298
+ in out B extends RouteSchema,
298
299
  > {
299
- body: undefined extends A['body'] ? B['body'] : A['body']
300
- query: undefined extends A['query'] ? B['query'] : A['query']
301
- params: undefined extends A['params'] ? B['params'] : A['params']
302
- response: {} extends A['response']
303
- ? {} extends B['response']
304
- ? {}
305
- : B['response']
306
- : {} extends B['response']
307
- ? A['response']
308
- : A['response'] & Omit<B['response'], keyof A['response']>
300
+ body: undefined extends A['body'] ? B['body'] : A['body']
301
+ query: undefined extends A['query'] ? B['query'] : A['query']
302
+ params: undefined extends A['params'] ? B['params'] : A['params']
303
+ response: {} extends A['response']
304
+ ? {} extends B['response']
305
+ ? {}
306
+ : B['response']
307
+ : {} extends B['response']
308
+ ? A['response']
309
+ : A['response'] & Omit<B['response'], keyof A['response']>
309
310
  }
310
311
 
311
312
  export type Handler<
312
- in out Route extends RouteSchema = {},
313
- in out Singleton extends SingletonBase = {
314
- state: {}
315
- },
316
- Path extends string = '',
313
+ in out Route extends RouteSchema = {},
314
+ in out Singleton extends SingletonBase = {
315
+ state: {}
316
+ },
317
+ Path extends string = '',
317
318
  > = (
318
- context: Context<Route, Singleton, Path>,
319
+ context: Context<Route, Singleton, Path>,
319
320
  ) => MaybePromise<
320
- {} extends Route['response']
321
- ? unknown
322
- : Route['response'][keyof Route['response']]
321
+ {} extends Route['response']
322
+ ? unknown
323
+ : Route['response'][keyof Route['response']]
323
324
  >
324
325
 
325
- export type Replace<Original, Target, With> = IsAny<Target> extends true
326
- ? Original
327
- : Original extends Record<string, unknown>
328
- ? {
329
- [K in keyof Original]: Original[K] extends Target
330
- ? With
331
- : Original[K]
332
- }
333
- : Original extends Target
334
- ? With
335
- : Original
326
+ export type Replace<Original, Target, With> =
327
+ IsAny<Target> extends true
328
+ ? Original
329
+ : Original extends Record<string, unknown>
330
+ ? {
331
+ [K in keyof Original]: Original[K] extends Target ? With : Original[K]
332
+ }
333
+ : Original extends Target
334
+ ? With
335
+ : Original
336
336
 
337
337
  export type IsAny<T> = 0 extends 1 & T ? true : false
338
338
 
339
- export type CoExist<Original, Target, With> = IsAny<Target> extends true
340
- ? Original
341
- : Original extends Record<string, unknown>
342
- ? {
343
- [K in keyof Original]: Original[K] extends Target
344
- ? Original[K] | With
345
- : Original[K]
346
- }
347
- : Original extends Target
348
- ? Original | With
349
- : Original
339
+ export type CoExist<Original, Target, With> =
340
+ IsAny<Target> extends true
341
+ ? Original
342
+ : Original extends Record<string, unknown>
343
+ ? {
344
+ [K in keyof Original]: Original[K] extends Target
345
+ ? Original[K] | With
346
+ : Original[K]
347
+ }
348
+ : Original extends Target
349
+ ? Original | With
350
+ : Original
350
351
 
351
352
  export type InlineHandler<
352
- Route extends RouteSchema = {},
353
- Singleton extends SingletonBase = {
354
- state: {}
355
- },
356
- Path extends string = '',
357
- MacroContext = {},
353
+ Route extends RouteSchema = {},
354
+ Singleton extends SingletonBase = {
355
+ state: {}
356
+ },
357
+ Path extends string = '',
358
+ MacroContext = {},
358
359
  > = (
359
- context: MacroContext extends Record<string | number | symbol, unknown>
360
- ? Prettify<MacroContext & Context<Route, Singleton, Path>>
361
- : Context<Route, Singleton, Path>,
360
+ context: MacroContext extends Record<string | number | symbol, unknown>
361
+ ? Prettify<MacroContext & Context<Route, Singleton, Path>>
362
+ : Context<Route, Singleton, Path>,
362
363
  ) =>
363
- | Response
364
- | MaybePromise<
365
- {} extends Route['response']
366
- ? unknown
367
- :
368
- | (Route['response'] extends { 200: any }
369
- ? Route['response']
370
- : string | number | boolean | Object)
371
- | Route['response'][keyof Route['response']]
372
- | {
373
- [Status in keyof Route['response']]: {
374
- _type: Record<
375
- Status,
376
- Route['response'][Status]
377
- >
378
- [ELYSIA_RESPONSE]: Status
379
- }
380
- }[keyof Route['response']]
381
- >
364
+ | Response
365
+ | MaybePromise<
366
+ {} extends Route['response']
367
+ ? unknown
368
+ :
369
+ | (Route['response'] extends { 200: any }
370
+ ? Route['response']
371
+ : string | number | boolean | Object)
372
+ | Route['response'][keyof Route['response']]
373
+ | {
374
+ [Status in keyof Route['response']]: {
375
+ _type: Record<Status, Route['response'][Status]>
376
+ [ELYSIA_RESPONSE]: Status
377
+ }
378
+ }[keyof Route['response']]
379
+ >
382
380
 
383
381
  export type OptionalHandler<
384
- in out Route extends RouteSchema = {},
385
- in out Singleton extends SingletonBase = {
386
- state: {}
387
- },
388
- Path extends string = '',
389
- > = Handler<Route, Singleton, Path> extends (
390
- context: infer Context,
391
- ) => infer Returned
392
- ? (context: Context) => Returned | MaybePromise<void>
393
- : never
382
+ in out Route extends RouteSchema = {},
383
+ in out Singleton extends SingletonBase = {
384
+ state: {}
385
+ },
386
+ Path extends string = '',
387
+ > =
388
+ Handler<Route, Singleton, Path> extends (
389
+ context: infer Context,
390
+ ) => infer Returned
391
+ ? (context: Context) => Returned | MaybePromise<void>
392
+ : never
394
393
 
395
394
  export type AfterHandler<
396
- in out Route extends RouteSchema = {},
397
- in out Singleton extends SingletonBase = {
398
- state: {}
399
- },
400
- Path extends string = '',
401
- > = Handler<Route, Singleton, Path> extends (
402
- context: infer Context,
403
- ) => infer Returned
404
- ? (
405
- context: Prettify<
406
- {
407
- response: Route['response']
408
- } & Context
409
- >,
410
- ) => Returned | MaybePromise<void>
411
- : never
395
+ in out Route extends RouteSchema = {},
396
+ in out Singleton extends SingletonBase = {
397
+ state: {}
398
+ },
399
+ Path extends string = '',
400
+ > =
401
+ Handler<Route, Singleton, Path> extends (
402
+ context: infer Context,
403
+ ) => infer Returned
404
+ ? (
405
+ context: Prettify<
406
+ {
407
+ response: Route['response']
408
+ } & Context
409
+ >,
410
+ ) => Returned | MaybePromise<void>
411
+ : never
412
412
 
413
413
  export type MapResponse<
414
- in out Route extends RouteSchema = {},
415
- in out Singleton extends SingletonBase = {
416
- state: {}
417
- },
418
- Path extends string = '',
414
+ in out Route extends RouteSchema = {},
415
+ in out Singleton extends SingletonBase = {
416
+ state: {}
417
+ },
418
+ Path extends string = '',
419
419
  > = Handler<
420
- Omit<Route, 'response'> & {
421
- response: MaybePromise<Response | undefined | unknown>
422
- },
423
- Singleton & {
424
- derive: {
425
- response: Route['response']
426
- }
427
- },
428
- Path
420
+ Omit<Route, 'response'> & {
421
+ response: MaybePromise<Response | undefined | unknown>
422
+ },
423
+ Singleton & {
424
+ derive: {
425
+ response: Route['response']
426
+ }
427
+ },
428
+ Path
429
429
  >
430
430
 
431
431
  export type VoidHandler<
432
- in out Route extends RouteSchema = {},
433
- in out Singleton extends SingletonBase = {
434
- state: {}
435
- },
432
+ in out Route extends RouteSchema = {},
433
+ in out Singleton extends SingletonBase = {
434
+ state: {}
435
+ },
436
436
  > = (context: Context<Route, Singleton>) => MaybePromise<void>
437
437
 
438
438
  export type TransformHandler<
439
- in out Route extends RouteSchema = {},
440
- in out Singleton extends SingletonBase = {
441
- state: {}
442
- },
443
- BasePath extends string = '',
439
+ in out Route extends RouteSchema = {},
440
+ in out Singleton extends SingletonBase = {
441
+ state: {}
442
+ },
443
+ BasePath extends string = '',
444
444
  > = {
445
- (
446
- context: Prettify<
447
- Context<
448
- Route,
449
- Omit<Singleton, 'resolve'> & {
450
- resolve: {}
451
- },
452
- BasePath
453
- >
454
- >,
455
- ): MaybePromise<void>
445
+ (
446
+ context: Prettify<
447
+ Context<
448
+ Route,
449
+ Omit<Singleton, 'resolve'> & {
450
+ resolve: {}
451
+ },
452
+ BasePath
453
+ >
454
+ >,
455
+ ): MaybePromise<void>
456
456
  }
457
457
 
458
458
  export type BodyHandler<
459
- in out Route extends RouteSchema = {},
460
- in out Singleton extends SingletonBase = {
461
- state: {}
462
- },
463
- Path extends string = '',
459
+ in out Route extends RouteSchema = {},
460
+ in out Singleton extends SingletonBase = {
461
+ state: {}
462
+ },
463
+ Path extends string = '',
464
464
  > = (
465
- context: Prettify<
466
- {
467
- contentType: string
468
- } & Context<Route, Singleton, Path>
469
- >,
465
+ context: Prettify<
466
+ {
467
+ contentType: string
468
+ } & Context<Route, Singleton, Path>
469
+ >,
470
470
 
471
- contentType: string,
471
+ contentType: string,
472
472
  ) => MaybePromise<any>
473
473
 
474
474
  export type MiddlewareHandler<
475
- in out Route extends RouteSchema = {},
476
- in out Singleton extends SingletonBase = any,
475
+ in out Route extends RouteSchema = {},
476
+ in out Singleton extends SingletonBase = any,
477
477
  > = (
478
- context: MiddlewareContext<Singleton>,
479
- next: () => Promise<Response>,
478
+ context: MiddlewareContext<Singleton>,
479
+ next: () => Promise<Response>,
480
480
  ) => MaybePromise<Route['response'] | void>
481
481
 
482
482
  export type AfterResponseHandler<
483
- in out Route extends RouteSchema = {},
484
- in out Singleton extends SingletonBase = {
485
- state: {}
486
- },
483
+ in out Route extends RouteSchema = {},
484
+ in out Singleton extends SingletonBase = {
485
+ state: {}
486
+ },
487
487
  > = (
488
- context: Prettify<
489
- Context<Route, Singleton> & {
490
- response: Route['response']
491
- }
492
- >,
488
+ context: Prettify<
489
+ Context<Route, Singleton> & {
490
+ response: Route['response']
491
+ }
492
+ >,
493
493
  ) => MaybePromise<void>
494
494
 
495
495
  // export type GracefulHandler<
@@ -497,406 +497,403 @@ export type AfterResponseHandler<
497
497
  // > = (data: Instance) => any
498
498
 
499
499
  export type ErrorHandler<
500
- in out T extends Record<string, Error> = {},
501
- in out Route extends RouteSchema = {},
502
- in out Singleton extends SingletonBase = {
503
- state: {}
504
- },
500
+ in out T extends Record<string, Error> = {},
501
+ in out Route extends RouteSchema = {},
502
+ in out Singleton extends SingletonBase = {
503
+ state: {}
504
+ },
505
505
  > = (
506
- context: ErrorContext<
507
- Route,
508
- {
509
- state: Singleton['state']
510
- }
511
- > &
512
- (
513
- | Prettify<
514
- {
515
- request: Request
516
- code: 'UNKNOWN'
517
- error: Readonly<Error>
518
- } & Partial<Singleton['state']>
519
- >
520
- | Prettify<
521
- {
522
- request: Request
523
- code: 'VALIDATION'
524
- error: Readonly<ValidationError>
525
- } & Singleton['state']
526
- >
527
- // | Prettify<
528
- // {
529
- // request: Request
530
- // code: 'NOT_FOUND'
531
- // error: Readonly<NotFoundError>
532
- // } & NeverKey<Singleton['state']>
533
- // >
534
- | Prettify<
535
- {
536
- request: Request
537
- code: 'PARSE'
538
- error: Readonly<ParseError>
539
- } & Singleton['state']
540
- >
541
- | Prettify<
542
- {
543
- request: Request
544
- code: 'INTERNAL_SERVER_ERROR'
545
- error: Readonly<InternalServerError>
546
- } & Partial<Singleton['state']>
547
- >
548
- | Prettify<
549
- {
550
- [K in keyof T]: {
551
- request: Request
552
- code: K
553
- error: Readonly<T[K]>
554
- }
555
- }[keyof T] &
556
- Partial<Singleton['state']>
557
- >
558
- ),
506
+ context: ErrorContext<
507
+ Route,
508
+ {
509
+ state: Singleton['state']
510
+ }
511
+ > &
512
+ (
513
+ | Prettify<
514
+ {
515
+ request: Request
516
+ code: 'UNKNOWN'
517
+ error: Readonly<Error>
518
+ } & Partial<Singleton['state']>
519
+ >
520
+ | Prettify<
521
+ {
522
+ request: Request
523
+ code: 'VALIDATION'
524
+ error: Readonly<ValidationError>
525
+ } & Singleton['state']
526
+ >
527
+ // | Prettify<
528
+ // {
529
+ // request: Request
530
+ // code: 'NOT_FOUND'
531
+ // error: Readonly<NotFoundError>
532
+ // } & NeverKey<Singleton['state']>
533
+ // >
534
+ | Prettify<
535
+ {
536
+ request: Request
537
+ code: 'PARSE'
538
+ error: Readonly<ParseError>
539
+ } & Singleton['state']
540
+ >
541
+ | Prettify<
542
+ {
543
+ request: Request
544
+ code: 'INTERNAL_SERVER_ERROR'
545
+ error: Readonly<InternalServerError>
546
+ } & Partial<Singleton['state']>
547
+ >
548
+ | Prettify<
549
+ {
550
+ [K in keyof T]: {
551
+ request: Request
552
+ code: K
553
+ error: Readonly<T[K]>
554
+ }
555
+ }[keyof T] &
556
+ Partial<Singleton['state']>
557
+ >
558
+ ),
559
559
  ) => any | Promise<any>
560
560
 
561
561
  export type Isolate<T> = {
562
- [P in keyof T]: T[P]
562
+ [P in keyof T]: T[P]
563
563
  }
564
564
 
565
565
  export type DocumentDecoration = Partial<OpenAPIV3.OperationObject> & {
566
- /**
567
- * Pass `true` to hide route from OpenAPI/swagger document
568
- * */
569
- hide?: boolean
566
+ /**
567
+ * Pass `true` to hide route from OpenAPI/swagger document
568
+ * */
569
+ hide?: boolean
570
570
  }
571
571
 
572
572
  export type LocalHook<
573
- LocalSchema extends InputSchema,
574
- Schema extends RouteSchema,
575
- Singleton extends SingletonBase,
576
- Errors extends Record<string, Error>,
577
- Extension extends BaseMacro,
578
- Path extends string = '',
579
- TypedRoute extends RouteSchema = Schema extends {
580
- params: Record<string, unknown>
581
- }
582
- ? Schema
583
- : Schema & {
584
- params: undefined extends Schema['params']
585
- ? ResolvePath<Path>
586
- : Schema['params']
587
- },
573
+ LocalSchema extends InputSchema,
574
+ Schema extends RouteSchema,
575
+ Singleton extends SingletonBase,
576
+ Errors extends Record<string, Error>,
577
+ Extension extends BaseMacro,
578
+ Path extends string = '',
579
+ TypedRoute extends RouteSchema = Schema extends {
580
+ params: Record<string, unknown>
581
+ }
582
+ ? Schema
583
+ : Schema & {
584
+ params: undefined extends Schema['params']
585
+ ? ResolvePath<Path>
586
+ : Schema['params']
587
+ },
588
588
  > = (LocalSchema extends {} ? LocalSchema : Isolate<LocalSchema>) &
589
- Extension & {
590
- detail?: DocumentDecoration
591
- /**
592
- * Short for 'Content-Type'
593
- *
594
- * Available:
595
- * - 'none': do not parse body
596
- * - 'text' / 'text/plain': parse body as string
597
- * - 'json' / 'application/json': parse body as json
598
- * - 'formdata' / 'multipart/form-data': parse body as form-data
599
- * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
600
- * - 'arraybuffer': parse body as readable stream
601
- */
602
- type?: ContentType
603
- }
589
+ Extension & {
590
+ detail?: DocumentDecoration
591
+ /**
592
+ * Short for 'Content-Type'
593
+ *
594
+ * Available:
595
+ * - 'none': do not parse body
596
+ * - 'text' / 'text/plain': parse body as string
597
+ * - 'json' / 'application/json': parse body as json
598
+ * - 'formdata' / 'multipart/form-data': parse body as form-data
599
+ * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
600
+ * - 'arraybuffer': parse body as readable stream
601
+ */
602
+ type?: ContentType
603
+ }
604
604
 
605
605
  export type ComposedHandler = (context: Context) => MaybePromise<Response>
606
606
 
607
607
  export interface InternalRoute {
608
- method: HTTPMethod
609
- path: string
610
- composed: ComposedHandler | Response | null
611
- handler: Handler
612
- hooks: LocalHook<any, any, any, any, any, any, any>
608
+ method: HTTPMethod
609
+ path: string
610
+ composed: ComposedHandler | Response | null
611
+ handler: Handler
612
+ hooks: LocalHook<any, any, any, any, any, any, any>
613
613
  }
614
614
 
615
615
  export type ListenCallback = (server: Server) => MaybePromise<void>
616
616
 
617
617
  export type AddPrefix<Prefix extends string, T> = {
618
- [K in keyof T as Prefix extends string ? `${Prefix}${K & string}` : K]: T[K]
618
+ [K in keyof T as Prefix extends string ? `${Prefix}${K & string}` : K]: T[K]
619
619
  }
620
620
 
621
621
  export type AddPrefixCapitalize<Prefix extends string, T> = {
622
- [K in keyof T as `${Prefix}${Capitalize<K & string>}`]: T[K]
622
+ [K in keyof T as `${Prefix}${Capitalize<K & string>}`]: T[K]
623
623
  }
624
624
 
625
625
  export type AddSuffix<Suffix extends string, T> = {
626
- [K in keyof T as `${K & string}${Suffix}`]: T[K]
626
+ [K in keyof T as `${K & string}${Suffix}`]: T[K]
627
627
  }
628
628
 
629
629
  export type AddSuffixCapitalize<Suffix extends string, T> = {
630
- [K in keyof T as `${K & string}${Capitalize<Suffix>}`]: T[K]
630
+ [K in keyof T as `${K & string}${Capitalize<Suffix>}`]: T[K]
631
631
  }
632
632
 
633
633
  export type BaseMacro = Record<
634
- string,
635
- string | number | boolean | Object | undefined | null
634
+ string,
635
+ string | number | boolean | Object | undefined | null
636
636
  >
637
637
  export type BaseMacroFn = Record<string, (...a: any) => unknown>
638
638
 
639
639
  type _CreateEden<
640
- Path extends string,
641
- Property extends Record<string, unknown> = {},
640
+ Path extends string,
641
+ Property extends Record<string, unknown> = {},
642
642
  > = Path extends `${infer Start}/${infer Rest}`
643
- ? {
644
- [x in Start]: _CreateEden<Rest, Property>
645
- }
646
- : {
647
- [x in Path]: Property
648
- }
643
+ ? {
644
+ [x in Start]: _CreateEden<Rest, Property>
645
+ }
646
+ : {
647
+ [x in Path]: Property
648
+ }
649
649
 
650
650
  export type CreateEden<
651
- Path extends string,
652
- Property extends Record<string, unknown> = {},
651
+ Path extends string,
652
+ Property extends Record<string, unknown> = {},
653
653
  > = Path extends `/${infer Rest}`
654
- ? _CreateEden<Rest, Property>
655
- : Path extends ''
656
- ? _CreateEden<'index', Property>
657
- : _CreateEden<Path, Property>
654
+ ? _CreateEden<Rest, Property>
655
+ : Path extends ''
656
+ ? _CreateEden<'index', Property>
657
+ : _CreateEden<Path, Property>
658
658
 
659
659
  export type ComposeSpiceflowResponse<Response, Handle> = Handle extends (
660
- ...a: any[]
660
+ ...a: any[]
661
661
  ) => infer A
662
- ? _ComposeSpiceflowResponse<Response, Replace<Awaited<A>, BunFile, File>>
663
- : _ComposeSpiceflowResponse<
664
- Response,
665
- Replace<Awaited<Handle>, BunFile, File>
666
- >
662
+ ? _ComposeSpiceflowResponse<Response, Awaited<A>>
663
+ : _ComposeSpiceflowResponse<Response, Replace<Awaited<Handle>, BunFile, File>>
667
664
 
668
665
  type _ComposeSpiceflowResponse<Response, Handle> = Prettify<
669
- {} extends Response
670
- ? {
671
- 200: Exclude<Handle, { [ELYSIA_RESPONSE]: any }>
672
- } & {
673
- [ErrorResponse in Extract<
674
- Handle,
675
- { response: any }
676
- > as ErrorResponse extends {
677
- [ELYSIA_RESPONSE]: infer Status extends number
678
- }
679
- ? Status
680
- : never]: ErrorResponse['response']
681
- }
682
- : Response
666
+ {} extends Response
667
+ ? {
668
+ 200: Exclude<Handle, { [ELYSIA_RESPONSE]: any }>
669
+ } & {
670
+ [ErrorResponse in Extract<
671
+ Handle,
672
+ { response: any }
673
+ > as ErrorResponse extends {
674
+ [ELYSIA_RESPONSE]: infer Status extends number
675
+ }
676
+ ? Status
677
+ : never]: ErrorResponse['response']
678
+ }
679
+ : Response
683
680
  >
684
681
 
685
682
  export type MergeSpiceflowInstances<
686
- Instances extends Spiceflow<any, any, any, any, any, any>[] = [],
687
- Prefix extends string = '',
688
- Scoped extends boolean = false,
689
- Singleton extends SingletonBase = {
690
- state: {}
691
- },
692
- Definitions extends DefinitionBase = {
693
- type: {}
694
- error: {}
695
- },
696
- Metadata extends MetadataBase = {
697
- schema: {}
698
- macro: {}
699
- macroFn: {}
700
- },
701
- Routes extends RouteBase = {},
683
+ Instances extends Spiceflow<any, any, any, any, any, any>[] = [],
684
+ Prefix extends string = '',
685
+ Scoped extends boolean = false,
686
+ Singleton extends SingletonBase = {
687
+ state: {}
688
+ },
689
+ Definitions extends DefinitionBase = {
690
+ type: {}
691
+ error: {}
692
+ },
693
+ Metadata extends MetadataBase = {
694
+ schema: {}
695
+ macro: {}
696
+ macroFn: {}
697
+ },
698
+ Routes extends RouteBase = {},
702
699
  > = Instances extends [
703
- infer Current extends Spiceflow<any, any, any, any, any, any>,
704
- ...infer Rest extends Spiceflow<any, any, any, any, any, any>[],
700
+ infer Current extends Spiceflow<any, any, any, any, any, any>,
701
+ ...infer Rest extends Spiceflow<any, any, any, any, any, any>[],
705
702
  ]
706
- ? Current['_types']['Scoped'] extends true
707
- ? MergeSpiceflowInstances<
708
- Rest,
709
- Prefix,
710
- Scoped,
711
- Singleton,
712
- Definitions,
713
- Metadata,
714
- Routes
715
- >
716
- : MergeSpiceflowInstances<
717
- Rest,
718
- Prefix,
719
- Scoped,
720
- Singleton & Current['_types']['Singleton'],
721
- Definitions & Current['_types']['Definitions'],
722
- Metadata & Current['_types']['Metadata'],
723
- Routes &
724
- (Prefix extends ``
725
- ? Current['_routes']
726
- : AddPrefix<Prefix, Current['_routes']>)
727
- >
728
- : Spiceflow<
729
- Prefix,
730
- Scoped,
731
- {
732
- state: Prettify<Singleton['state']>
733
- },
734
- {
735
- type: Prettify<Definitions['type']>
736
- error: Prettify<Definitions['error']>
737
- },
738
- {
739
- schema: Prettify<Metadata['schema']>
740
- macro: Prettify<Metadata['macro']>
741
- macroFn: Prettify<Metadata['macroFn']>
742
- },
743
- Routes
744
- >
703
+ ? Current['_types']['Scoped'] extends true
704
+ ? MergeSpiceflowInstances<
705
+ Rest,
706
+ Prefix,
707
+ Scoped,
708
+ Singleton,
709
+ Definitions,
710
+ Metadata,
711
+ Routes
712
+ >
713
+ : MergeSpiceflowInstances<
714
+ Rest,
715
+ Prefix,
716
+ Scoped,
717
+ Singleton & Current['_types']['Singleton'],
718
+ Definitions & Current['_types']['Definitions'],
719
+ Metadata & Current['_types']['Metadata'],
720
+ Routes &
721
+ (Prefix extends ``
722
+ ? Current['_routes']
723
+ : AddPrefix<Prefix, Current['_routes']>)
724
+ >
725
+ : Spiceflow<
726
+ Prefix,
727
+ Scoped,
728
+ {
729
+ state: Prettify<Singleton['state']>
730
+ },
731
+ {
732
+ type: Prettify<Definitions['type']>
733
+ error: Prettify<Definitions['error']>
734
+ },
735
+ {
736
+ schema: Prettify<Metadata['schema']>
737
+ macro: Prettify<Metadata['macro']>
738
+ macroFn: Prettify<Metadata['macroFn']>
739
+ },
740
+ Routes
741
+ >
745
742
 
746
743
  export type LifeCycleType = 'global' | 'local' | 'scoped'
747
744
 
748
745
  export type UnionToIntersect<U> = (
749
- U extends unknown ? (arg: U) => 0 : never
746
+ U extends unknown ? (arg: U) => 0 : never
750
747
  ) extends (arg: infer I) => 0
751
- ? I
752
- : never
748
+ ? I
749
+ : never
753
750
 
754
751
  export type ContextAppendType = 'append' | 'override'
755
752
 
756
753
  export type HTTPHeaders = Record<string, string> & {
757
- // Authentication
758
- 'www-authenticate'?: string
759
- authorization?: string
760
- 'proxy-authenticate'?: string
761
- 'proxy-authorization'?: string
762
-
763
- // Caching
764
- age?: string
765
- 'cache-control'?: string
766
- 'clear-site-data'?: string
767
- expires?: string
768
- 'no-vary-search'?: string
769
- pragma?: string
770
-
771
- // Conditionals
772
- 'last-modified'?: string
773
- etag?: string
774
- 'if-match'?: string
775
- 'if-none-match'?: string
776
- 'if-modified-since'?: string
777
- 'if-unmodified-since'?: string
778
- vary?: string
779
-
780
- // Connection management
781
- connection?: string
782
- 'keep-alive'?: string
783
-
784
- // Content negotiation
785
- accept?: string
786
- 'accept-encoding'?: string
787
- 'accept-language'?: string
788
-
789
- // Controls
790
- expect?: string
791
- 'max-forwards'?: string
792
-
793
- // Cokies
794
- cookie?: string
795
- 'set-cookie'?: string | string[]
796
-
797
- // CORS
798
- 'access-control-allow-origin'?: string
799
- 'access-control-allow-credentials'?: string
800
- 'access-control-allow-headers'?: string
801
- 'access-control-allow-methods'?: string
802
- 'access-control-expose-headers'?: string
803
- 'access-control-max-age'?: string
804
- 'access-control-request-headers'?: string
805
- 'access-control-request-method'?: string
806
- origin?: string
807
- 'timing-allow-origin'?: string
808
-
809
- // Downloads
810
- 'content-disposition'?: string
811
-
812
- // Message body information
813
- 'content-length'?: string
814
- 'content-type'?: string
815
- 'content-encoding'?: string
816
- 'content-language'?: string
817
- 'content-location'?: string
818
-
819
- // Proxies
820
- forwarded?: string
821
- via?: string
822
-
823
- // Redirects
824
- location?: string
825
- refresh?: string
826
-
827
- // Request context
828
- // from?: string
829
- // host?: string
830
- // referer?: string
831
- // 'user-agent'?: string
832
-
833
- // Response context
834
- allow?: string
835
- server?: 'spiceflow' | (string & {})
836
-
837
- // Range requests
838
- 'accept-ranges'?: string
839
- range?: string
840
- 'if-range'?: string
841
- 'content-range'?: string
842
-
843
- // Security
844
- 'content-security-policy'?: string
845
- 'content-security-policy-report-only'?: string
846
- 'cross-origin-embedder-policy'?: string
847
- 'cross-origin-opener-policy'?: string
848
- 'cross-origin-resource-policy'?: string
849
- 'expect-ct'?: string
850
- 'permission-policy'?: string
851
- 'strict-transport-security'?: string
852
- 'upgrade-insecure-requests'?: string
853
- 'x-content-type-options'?: string
854
- 'x-frame-options'?: string
855
- 'x-xss-protection'?: string
856
-
857
- // Server-sent events
858
- 'last-event-id'?: string
859
- 'ping-from'?: string
860
- 'ping-to'?: string
861
- 'report-to'?: string
862
-
863
- // Transfer coding
864
- te?: string
865
- trailer?: string
866
- 'transfer-encoding'?: string
867
-
868
- // Other
869
- 'alt-svg'?: string
870
- 'alt-used'?: string
871
- date?: string
872
- dnt?: string
873
- 'early-data'?: string
874
- 'large-allocation'?: string
875
- link?: string
876
- 'retry-after'?: string
877
- 'service-worker-allowed'?: string
878
- 'source-map'?: string
879
- upgrade?: string
880
-
881
- // Non-standard
882
- 'x-dns-prefetch-control'?: string
883
- 'x-forwarded-for'?: string
884
- 'x-forwarded-host'?: string
885
- 'x-forwarded-proto'?: string
886
- 'x-powered-by'?: 'spiceflow' | (string & {})
887
- 'x-request-id'?: string
888
- 'x-requested-with'?: string
889
- 'x-robots-tag'?: string
890
- 'x-ua-compatible'?: string
754
+ // Authentication
755
+ 'www-authenticate'?: string
756
+ authorization?: string
757
+ 'proxy-authenticate'?: string
758
+ 'proxy-authorization'?: string
759
+
760
+ // Caching
761
+ age?: string
762
+ 'cache-control'?: string
763
+ 'clear-site-data'?: string
764
+ expires?: string
765
+ 'no-vary-search'?: string
766
+ pragma?: string
767
+
768
+ // Conditionals
769
+ 'last-modified'?: string
770
+ etag?: string
771
+ 'if-match'?: string
772
+ 'if-none-match'?: string
773
+ 'if-modified-since'?: string
774
+ 'if-unmodified-since'?: string
775
+ vary?: string
776
+
777
+ // Connection management
778
+ connection?: string
779
+ 'keep-alive'?: string
780
+
781
+ // Content negotiation
782
+ accept?: string
783
+ 'accept-encoding'?: string
784
+ 'accept-language'?: string
785
+
786
+ // Controls
787
+ expect?: string
788
+ 'max-forwards'?: string
789
+
790
+ // Cokies
791
+ cookie?: string
792
+ 'set-cookie'?: string | string[]
793
+
794
+ // CORS
795
+ 'access-control-allow-origin'?: string
796
+ 'access-control-allow-credentials'?: string
797
+ 'access-control-allow-headers'?: string
798
+ 'access-control-allow-methods'?: string
799
+ 'access-control-expose-headers'?: string
800
+ 'access-control-max-age'?: string
801
+ 'access-control-request-headers'?: string
802
+ 'access-control-request-method'?: string
803
+ origin?: string
804
+ 'timing-allow-origin'?: string
805
+
806
+ // Downloads
807
+ 'content-disposition'?: string
808
+
809
+ // Message body information
810
+ 'content-length'?: string
811
+ 'content-type'?: string
812
+ 'content-encoding'?: string
813
+ 'content-language'?: string
814
+ 'content-location'?: string
815
+
816
+ // Proxies
817
+ forwarded?: string
818
+ via?: string
819
+
820
+ // Redirects
821
+ location?: string
822
+ refresh?: string
823
+
824
+ // Request context
825
+ // from?: string
826
+ // host?: string
827
+ // referer?: string
828
+ // 'user-agent'?: string
829
+
830
+ // Response context
831
+ allow?: string
832
+ server?: 'spiceflow' | (string & {})
833
+
834
+ // Range requests
835
+ 'accept-ranges'?: string
836
+ range?: string
837
+ 'if-range'?: string
838
+ 'content-range'?: string
839
+
840
+ // Security
841
+ 'content-security-policy'?: string
842
+ 'content-security-policy-report-only'?: string
843
+ 'cross-origin-embedder-policy'?: string
844
+ 'cross-origin-opener-policy'?: string
845
+ 'cross-origin-resource-policy'?: string
846
+ 'expect-ct'?: string
847
+ 'permission-policy'?: string
848
+ 'strict-transport-security'?: string
849
+ 'upgrade-insecure-requests'?: string
850
+ 'x-content-type-options'?: string
851
+ 'x-frame-options'?: string
852
+ 'x-xss-protection'?: string
853
+
854
+ // Server-sent events
855
+ 'last-event-id'?: string
856
+ 'ping-from'?: string
857
+ 'ping-to'?: string
858
+ 'report-to'?: string
859
+
860
+ // Transfer coding
861
+ te?: string
862
+ trailer?: string
863
+ 'transfer-encoding'?: string
864
+
865
+ // Other
866
+ 'alt-svg'?: string
867
+ 'alt-used'?: string
868
+ date?: string
869
+ dnt?: string
870
+ 'early-data'?: string
871
+ 'large-allocation'?: string
872
+ link?: string
873
+ 'retry-after'?: string
874
+ 'service-worker-allowed'?: string
875
+ 'source-map'?: string
876
+ upgrade?: string
877
+
878
+ // Non-standard
879
+ 'x-dns-prefetch-control'?: string
880
+ 'x-forwarded-for'?: string
881
+ 'x-forwarded-host'?: string
882
+ 'x-forwarded-proto'?: string
883
+ 'x-powered-by'?: 'spiceflow' | (string & {})
884
+ 'x-request-id'?: string
885
+ 'x-requested-with'?: string
886
+ 'x-robots-tag'?: string
887
+ 'x-ua-compatible'?: string
891
888
  }
892
889
 
893
890
  export type JoinPath<A extends string, B extends string> = `${A}${B extends '/'
894
- ? '/index'
895
- : B extends ''
896
- ? B
897
- : B extends `/${string}`
898
- ? B
899
- : B}`
891
+ ? '/index'
892
+ : B extends ''
893
+ ? B
894
+ : B extends `/${string}`
895
+ ? B
896
+ : B}`
900
897
 
901
898
  export type PartialWithRequired<T, K extends keyof T> = Partial<Omit<T, K>> &
902
- Pick<T, K>
899
+ Pick<T, K>