keq 2.9.0 → 2.10.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.
Files changed (151) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/esm/src/constant.d.ts +2 -0
  3. package/dist/esm/src/constant.js +2 -0
  4. package/dist/esm/src/core.d.ts +30 -0
  5. package/dist/esm/src/core.js +162 -53
  6. package/dist/esm/src/exception/abort.exception.d.ts +3 -0
  7. package/dist/esm/src/exception/abort.exception.js +6 -0
  8. package/dist/esm/src/index.d.ts +1 -0
  9. package/dist/esm/src/index.js +1 -0
  10. package/dist/esm/src/is/is-abort-signal.d.ts +1 -0
  11. package/dist/esm/src/is/is-abort-signal.js +8 -0
  12. package/dist/esm/src/middlewares/fetch-arguments-middleware.js +5 -1
  13. package/dist/esm/src/middlewares/retry-middleware.js +20 -3
  14. package/dist/esm/src/middlewares/timeout-middleware.js +3 -1
  15. package/dist/esm/src/types/keq-context.d.ts +10 -1
  16. package/dist/esm/src/types/keq-context.js +1 -1
  17. package/dist/umd/src/constant.d.ts +2 -0
  18. package/dist/umd/src/constant.js +3 -1
  19. package/dist/umd/src/core.d.ts +30 -0
  20. package/dist/umd/src/core.js +162 -53
  21. package/dist/umd/src/exception/abort.exception.d.ts +3 -0
  22. package/dist/umd/src/exception/abort.exception.js +20 -0
  23. package/dist/umd/src/index.d.ts +1 -0
  24. package/dist/umd/src/index.js +4 -2
  25. package/dist/umd/src/is/is-abort-signal.d.ts +1 -0
  26. package/dist/umd/src/is/is-abort-signal.js +22 -0
  27. package/dist/umd/src/middlewares/fetch-arguments-middleware.js +4 -0
  28. package/dist/umd/src/middlewares/retry-middleware.js +21 -4
  29. package/dist/umd/src/middlewares/timeout-middleware.js +4 -2
  30. package/dist/umd/src/types/keq-context.d.ts +10 -1
  31. package/package.json +10 -13
  32. package/.claude/settings.local.json +0 -26
  33. package/packages/cache/.turbo/turbo-build.log +0 -29
  34. package/packages/cache/dist/index.d.mts +0 -354
  35. package/packages/cache/dist/index.d.mts.map +0 -1
  36. package/packages/cache/dist/index.d.ts +0 -353
  37. package/packages/cache/dist/index.d.ts.map +0 -1
  38. package/packages/cache/dist/index.js +0 -1271
  39. package/packages/cache/dist/index.js.map +0 -1
  40. package/packages/cache/dist/index.mjs +0 -1237
  41. package/packages/cache/dist/index.mjs.map +0 -1
  42. package/packages/cli/.turbo/turbo-build.log +0 -91
  43. package/packages/cli/dist/cli.cjs +0 -1364
  44. package/packages/cli/dist/cli.cjs.map +0 -1
  45. package/packages/cli/dist/cli.d.cts +0 -1
  46. package/packages/cli/dist/cli.d.mts +0 -1
  47. package/packages/cli/dist/cli.mjs +0 -1359
  48. package/packages/cli/dist/cli.mjs.map +0 -1
  49. package/packages/cli/dist/compiler-0Kli6UCr.cjs +0 -738
  50. package/packages/cli/dist/compiler-0Kli6UCr.cjs.map +0 -1
  51. package/packages/cli/dist/compiler-C3AE8j54.mjs +0 -715
  52. package/packages/cli/dist/compiler-C3AE8j54.mjs.map +0 -1
  53. package/packages/cli/dist/index.cjs +0 -20
  54. package/packages/cli/dist/index.cjs.map +0 -1
  55. package/packages/cli/dist/index.d.cts +0 -17
  56. package/packages/cli/dist/index.d.cts.map +0 -1
  57. package/packages/cli/dist/index.d.mts +0 -17
  58. package/packages/cli/dist/index.d.mts.map +0 -1
  59. package/packages/cli/dist/index.mjs +0 -10
  60. package/packages/cli/dist/index.mjs.map +0 -1
  61. package/packages/cli/dist/init-BNhD2oCI.mjs +0 -168
  62. package/packages/cli/dist/init-BNhD2oCI.mjs.map +0 -1
  63. package/packages/cli/dist/init-DqxLcRSQ.cjs +0 -170
  64. package/packages/cli/dist/init-DqxLcRSQ.cjs.map +0 -1
  65. package/packages/cli/dist/logger-D7PyVZo3.cjs +0 -46
  66. package/packages/cli/dist/logger-D7PyVZo3.cjs.map +0 -1
  67. package/packages/cli/dist/logger-QLBHySQ3.mjs +0 -12
  68. package/packages/cli/dist/logger-QLBHySQ3.mjs.map +0 -1
  69. package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs +0 -16
  70. package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs.map +0 -1
  71. package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs +0 -11
  72. package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs.map +0 -1
  73. package/packages/cli/dist/mock-command-Bp1LxSls.mjs +0 -350
  74. package/packages/cli/dist/mock-command-Bp1LxSls.mjs.map +0 -1
  75. package/packages/cli/dist/mock-command-WZcfy5Iq.cjs +0 -353
  76. package/packages/cli/dist/mock-command-WZcfy5Iq.cjs.map +0 -1
  77. package/packages/cli/dist/plugins-CgMhaNZq.cjs +0 -3558
  78. package/packages/cli/dist/plugins-CgMhaNZq.cjs.map +0 -1
  79. package/packages/cli/dist/plugins-DCvJ8iHR.mjs +0 -3280
  80. package/packages/cli/dist/plugins-DCvJ8iHR.mjs.map +0 -1
  81. package/packages/cli/dist/plugins.cjs +0 -36
  82. package/packages/cli/dist/plugins.d.cts +0 -2
  83. package/packages/cli/dist/plugins.d.mts +0 -2
  84. package/packages/cli/dist/plugins.mjs +0 -2
  85. package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts +0 -780
  86. package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts.map +0 -1
  87. package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts +0 -780
  88. package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts.map +0 -1
  89. package/packages/cli/dist/translators.cjs +0 -14
  90. package/packages/cli/dist/translators.cjs.map +0 -1
  91. package/packages/cli/dist/translators.d.cts +0 -14
  92. package/packages/cli/dist/translators.d.cts.map +0 -1
  93. package/packages/cli/dist/translators.d.mts +0 -14
  94. package/packages/cli/dist/translators.d.mts.map +0 -1
  95. package/packages/cli/dist/translators.mjs +0 -12
  96. package/packages/cli/dist/translators.mjs.map +0 -1
  97. package/packages/cli/node_modules/.bin/eslint +0 -21
  98. package/packages/cli/node_modules/.bin/jiti +0 -21
  99. package/packages/cli/node_modules/.bin/js-yaml +0 -21
  100. package/packages/cli/node_modules/.bin/jsf +0 -21
  101. package/packages/cli/node_modules/.bin/jsonpath +0 -21
  102. package/packages/cli/node_modules/.bin/jsonpath-plus +0 -21
  103. package/packages/cli/node_modules/.bin/semver +0 -21
  104. package/packages/cli/node_modules/.bin/tsc +0 -21
  105. package/packages/cli/node_modules/.bin/tsserver +0 -21
  106. package/packages/exception/.turbo/turbo-build.log +0 -29
  107. package/packages/exception/dist/index.d.mts +0 -21
  108. package/packages/exception/dist/index.d.mts.map +0 -1
  109. package/packages/exception/dist/index.d.ts +0 -21
  110. package/packages/exception/dist/index.d.ts.map +0 -1
  111. package/packages/exception/dist/index.js +0 -104
  112. package/packages/exception/dist/index.js.map +0 -1
  113. package/packages/exception/dist/index.mjs +0 -99
  114. package/packages/exception/dist/index.mjs.map +0 -1
  115. package/packages/headers/.turbo/turbo-build.log +0 -29
  116. package/packages/headers/dist/index.d.mts +0 -46
  117. package/packages/headers/dist/index.d.mts.map +0 -1
  118. package/packages/headers/dist/index.d.ts +0 -46
  119. package/packages/headers/dist/index.d.ts.map +0 -1
  120. package/packages/headers/dist/index.js +0 -81
  121. package/packages/headers/dist/index.js.map +0 -1
  122. package/packages/headers/dist/index.mjs +0 -75
  123. package/packages/headers/dist/index.mjs.map +0 -1
  124. package/packages/keq/.turbo/turbo-build.log +0 -29
  125. package/packages/keq/dist/index.d.mts +0 -962
  126. package/packages/keq/dist/index.d.mts.map +0 -1
  127. package/packages/keq/dist/index.d.ts +0 -962
  128. package/packages/keq/dist/index.d.ts.map +0 -1
  129. package/packages/keq/dist/index.js +0 -1876
  130. package/packages/keq/dist/index.js.map +0 -1
  131. package/packages/keq/dist/index.mjs +0 -1814
  132. package/packages/keq/dist/index.mjs.map +0 -1
  133. package/packages/nestjs/.turbo/turbo-build.log +0 -29
  134. package/packages/nestjs/dist/index.d.mts +0 -52
  135. package/packages/nestjs/dist/index.d.mts.map +0 -1
  136. package/packages/nestjs/dist/index.d.ts +0 -52
  137. package/packages/nestjs/dist/index.d.ts.map +0 -1
  138. package/packages/nestjs/dist/index.js +0 -166
  139. package/packages/nestjs/dist/index.js.map +0 -1
  140. package/packages/nestjs/dist/index.mjs +0 -136
  141. package/packages/nestjs/dist/index.mjs.map +0 -1
  142. package/packages/test/.turbo/turbo-build.log +0 -6
  143. package/packages/url/.turbo/turbo-build.log +0 -29
  144. package/packages/url/dist/index.d.mts +0 -9
  145. package/packages/url/dist/index.d.mts.map +0 -1
  146. package/packages/url/dist/index.d.ts +0 -9
  147. package/packages/url/dist/index.d.ts.map +0 -1
  148. package/packages/url/dist/index.js +0 -43
  149. package/packages/url/dist/index.js.map +0 -1
  150. package/packages/url/dist/index.mjs +0 -40
  151. package/packages/url/dist/index.mjs.map +0 -1
@@ -1,962 +0,0 @@
1
- import { ConditionalExcept, ConditionalPick, IsUnion, Primitive, Promisable } from "type-fest";
2
- import { UriTemplateContext } from "@opendoc/uri-template";
3
- import { Emitter } from "mitt";
4
- import { IStringifyBaseOptions } from "qs";
5
- import { EventSourceMessage } from "eventsource-parser";
6
- import { queueAsPromised } from "fastq";
7
- import { CustomError } from "ts-custom-error";
8
-
9
- //#region src/middleware/types/keq-next.d.ts
10
- type KeqNext = () => Promise<void>;
11
- //#endregion
12
- //#region src/middleware/types/keq-middleware.d.ts
13
- interface KeqMiddleware {
14
- (ctx: KeqExecutionContext, next: KeqNext): Promisable<void>;
15
- __keqMiddlewareName__?: string;
16
- }
17
- //#endregion
18
- //#region src/middleware/utils/compose-middleware.d.ts
19
- interface ComposeMiddlewareOptions {
20
- name?: string;
21
- }
22
- declare function composeMiddleware(middlewares: KeqMiddleware[], options?: ComposeMiddlewareOptions): KeqMiddleware;
23
- //#endregion
24
- //#region src/context/middleware-context.d.ts
25
- declare const ExecutorProperty$1 = "__KeyProtectedProperty(context.orchestration.middlewares)__";
26
- declare class KeqMiddlewareContext {
27
- readonly [ExecutorProperty$1]: KeqMiddlewareExecutor;
28
- constructor(executor: KeqMiddlewareExecutor);
29
- get name(): string;
30
- get status(): KeqMiddlewareExecutor['status'];
31
- get finished(): boolean;
32
- }
33
- //#endregion
34
- //#region src/orchestrator/executor.d.ts
35
- declare class KeqMiddlewareExecutor {
36
- readonly middleware: KeqMiddleware;
37
- readonly name: string;
38
- status: 'idle' | 'pending' | 'canceled' | 'fulfilled' | 'rejected';
39
- context: KeqMiddlewareContext;
40
- constructor(middleware: KeqMiddleware);
41
- execute(context: KeqExecutionContext, next: KeqNext): Promise<void>;
42
- }
43
- //#endregion
44
- //#region src/orchestrator/orchestrator.d.ts
45
- interface KeqMiddlewareOrchestratorPointer {
46
- orchestrator: KeqMiddlewareOrchestrator;
47
- index: number;
48
- }
49
- type KeqMiddlewareOrchestratorStatus = 'idle' | 'pending' | 'fulfilled' | 'rejected';
50
- declare class KeqMiddlewareOrchestrator {
51
- main?: KeqMiddlewareOrchestratorPointer;
52
- status: KeqMiddlewareOrchestratorStatus;
53
- context: KeqSharedContext;
54
- executors: KeqMiddlewareExecutor[];
55
- current: number;
56
- constructor(context: KeqSharedContext, middlewares?: KeqMiddleware[], inherit?: {
57
- main?: KeqMiddlewareOrchestratorPointer;
58
- });
59
- private cancelNotFinished;
60
- private run;
61
- execute(): Promise<void>;
62
- fork(): KeqMiddlewareOrchestrator;
63
- merge(source: KeqMiddlewareOrchestrator): void;
64
- }
65
- //#endregion
66
- //#region src/request-init/types/keq-body-init.d.ts
67
- type KeqBodyInit = BodyInit | object | Array<any> | undefined;
68
- //#endregion
69
- //#region src/request-init/types/keq-request-method.d.ts
70
- type KeqRequestMethod = 'get' | 'post' | 'put' | 'delete' | 'head' | 'patch' | 'options';
71
- //#endregion
72
- //#region src/request-init/request-init.d.ts
73
- interface KeqRequestInitOptions {
74
- url: URL;
75
- pathParameters: UriTemplateContext;
76
- method: KeqRequestMethod;
77
- headers: Headers;
78
- body: KeqBodyInit;
79
- cache?: RequestCache;
80
- credentials?: RequestCredentials;
81
- integrity?: string;
82
- keepalive?: boolean;
83
- mode?: RequestMode;
84
- redirect?: RequestRedirect;
85
- referrer?: string;
86
- referrerPolicy?: ReferrerPolicy;
87
- }
88
- declare const AbortControllerProperty = "__KeqProtectedProperty(context.request.abortController)__";
89
- declare class KeqRequestInit {
90
- url: URL;
91
- pathParameters: UriTemplateContext;
92
- method: KeqRequestMethod;
93
- headers: Headers;
94
- body: KeqBodyInit;
95
- cache?: RequestCache;
96
- credentials?: RequestCredentials;
97
- integrity?: string;
98
- keepalive?: boolean;
99
- mode?: RequestMode;
100
- redirect?: RequestRedirect;
101
- referrer?: string;
102
- referrerPolicy?: ReferrerPolicy;
103
- [AbortControllerProperty]: AbortController;
104
- constructor(options: KeqRequestInitOptions);
105
- get __url__(): Readonly<URL>;
106
- get signal(): AbortSignal;
107
- abort(reason: any): void;
108
- private getContentType;
109
- private toFetchBody;
110
- toFetchArguments(): [string, RequestInit];
111
- }
112
- //#endregion
113
- //#region src/context/orchestrator-context.d.ts
114
- declare const OrchestratorProperty = "__KeyProtectedProperty(context.orchestration.orchestrator)__";
115
- declare const ExecutorProperty = "__KeyProtectedProperty(context.orchestration.executor)__";
116
- declare class KeqOrchestratorContext {
117
- readonly [OrchestratorProperty]: KeqMiddlewareOrchestrator;
118
- readonly [ExecutorProperty]: KeqMiddlewareExecutor;
119
- constructor(orchestrator: KeqMiddlewareOrchestrator, executor: KeqMiddlewareExecutor);
120
- get middlewares(): KeqMiddlewareContext[];
121
- /**
122
- * The middleware context of the current middleware
123
- */
124
- get middleware(): KeqMiddlewareContext;
125
- fork(): KeqMiddlewareOrchestrator;
126
- merge(source: KeqMiddlewareOrchestrator): void;
127
- }
128
- //#endregion
129
- //#region src/context/shared-context.d.ts
130
- interface KeqSharedContextOptions {
131
- locationId?: string;
132
- request: KeqRequestInitOptions;
133
- global: KeqGlobal;
134
- options?: KeqContextOptions;
135
- data?: KeqContextData;
136
- emitter?: KeqContextEmitter;
137
- }
138
- declare const ContextLocationIdProperty = "__KeqProtectedProperty(context.locationId)__";
139
- declare const ContextRequestProperty = "__KeqProtectedProperty(context.request)__";
140
- declare const ContextGlobalProperty = "__KeqProtectedProperty(context.global)__";
141
- declare const ContextEmitterProperty = "__KeqProtectedProperty(context.emitter)__";
142
- declare const ContextOptionsProperty = "__KeqProtectedProperty(context.options)__";
143
- declare const ContextDataProperty = "__KeqProtectedProperty(context.data)__";
144
- declare const ContextOutputProperty = "__KeqProtectedProperty(context.output)__";
145
- declare class KeqSharedContext implements KeqContext {
146
- readonly [ContextLocationIdProperty]?: string;
147
- [ContextRequestProperty]: KeqRequestInit;
148
- [ContextGlobalProperty]: Record<string, any>;
149
- [ContextEmitterProperty]: KeqContextEmitter;
150
- [ContextOptionsProperty]: KeqContextOptions;
151
- [ContextOutputProperty]?: any;
152
- [ContextDataProperty]: KeqContextData;
153
- /**
154
- * original response
155
- */
156
- res?: Response;
157
- constructor(options: KeqSharedContextOptions);
158
- /**
159
- * The unique identifier of the request's location in the code
160
- */
161
- get locationId(): string | undefined;
162
- get request(): KeqRequestInit;
163
- get global(): KeqGlobal;
164
- get emitter(): KeqContextEmitter;
165
- get options(): KeqContextOptions;
166
- set output(value: any);
167
- get response(): Response | undefined;
168
- get data(): KeqContextData;
169
- }
170
- //#endregion
171
- //#region src/context/types/keq-context-emitter.d.ts
172
- interface KeqEvents {
173
- retry: {
174
- context: KeqSharedContext;
175
- };
176
- error: {
177
- context: KeqSharedContext;
178
- };
179
- abort: {
180
- context: KeqSharedContext;
181
- reason: any;
182
- };
183
- timeout: {
184
- context: KeqExecutionContext;
185
- };
186
- 'fetch:before': {
187
- context: KeqExecutionContext;
188
- };
189
- 'fetch:after': {
190
- context: KeqExecutionContext;
191
- };
192
- 'middleware:before': {
193
- context: KeqExecutionContext;
194
- };
195
- 'middleware:after': {
196
- context: KeqExecutionContext;
197
- };
198
- }
199
- type KeqListeners = { [K in keyof KeqEvents]?: ((data: KeqEvents[K]) => void)[] };
200
- type KeqContextEmitter = Emitter<Omit<KeqEvents, never>>;
201
- //#endregion
202
- //#region src/middlewares/timeout-middleware/index.d.ts
203
- interface KeqTimeoutOptions {
204
- millisecond: number;
205
- }
206
- //#endregion
207
- //#region src/middlewares/flow-control-middleware/types/keq-flow-control.d.ts
208
- interface KeqFlowControlOptions {
209
- mode: 'abort' | 'serial' | 'concurrent' | 'mutex';
210
- concurrencyLimit?: number;
211
- signal: string | ((ctx: KeqExecutionContext) => string);
212
- }
213
- type KeqFlowControlSignal = KeqFlowControlOptions['signal'];
214
- //#endregion
215
- //#region src/request/types/keq-query-value.d.ts
216
- type KeqQueryPrimitive = string | number | bigint | null | undefined;
217
- type KeqQueryObject<K extends string = string> = { [key in K]: KeqQueryValue };
218
- type KeqQueryArray = KeqQueryValue[];
219
- type KeqQueryValue = KeqQueryPrimitive | KeqQueryArray | KeqQueryObject;
220
- type KeqQueryInit = KeqQueryValue;
221
- //#endregion
222
- //#region src/request/types/keq-param-value.d.ts
223
- type KeqPathParameterInit = UriTemplateContext[string];
224
- //#endregion
225
- //#region src/request/types/api-schema/operation.d.ts
226
- interface KeqOperation {
227
- requestParams: { [key in string]: KeqPathParameterInit };
228
- requestQuery: { [key in string]: KeqQueryInit };
229
- requestHeaders: { [key in string]: string | number };
230
- requestBody: KeqBodyInit;
231
- responseBody: any;
232
- }
233
- //#endregion
234
- //#region src/request/types/api-schema/api-schema.d.ts
235
- interface KeqApiSchema {
236
- [pathname: string]: { [method in KeqRequestMethod]?: KeqOperation };
237
- }
238
- //#endregion
239
- //#region src/types/literal-keys.d.ts
240
- /**
241
- * Extracts only the literal keys from an object type T.
242
- *
243
- * @example
244
- * ```ts
245
- * type Example = {
246
- * [key: string]: number;
247
- * knownProp: string;
248
- * }
249
- *
250
- * type Result = LiteralKeys<Example>;
251
- * // Result is { knownProp: string; }
252
- * ```
253
- */
254
- type LiteralKeys<T> = { [K in keyof T as K extends string ? (string extends K ? never : K) : K extends number ? (number extends K ? never : K) : K extends symbol ? (symbol extends K ? never : K) : never]: T[K] };
255
- //#endregion
256
- //#region src/types/string-index-value-of.d.ts
257
- /**
258
- * Extracts the value type of string index signatures from an object type.
259
- *
260
- * @example
261
- * ```ts
262
- * type Example = {
263
- * [key: string]: number | string;
264
- * knownProp: number;
265
- * }
266
- *
267
- * type Result = StringIndexValueOf<Example>;
268
- * // Result is number | string
269
- * ```
270
- */
271
- type StringIndexValueOf<T> = string extends keyof T ? T extends {
272
- [key: string]: infer V;
273
- } ? V : never : never;
274
- //#endregion
275
- //#region src/types/enabled-if-string-index.d.ts
276
- /**
277
- * A utility type that evaluates to `unknown` if the type `T` has a string index signature,
278
- * otherwise it evaluates to `never`.
279
- *
280
- * @example
281
- * ```ts
282
- * type WithStringIndex = {
283
- * [key: string]: number;
284
- * knownProp: string;
285
- * }
286
- *
287
- * type WithoutStringIndex = {
288
- * knownProp: string;
289
- * anotherProp: number;
290
- * }
291
- *
292
- * type Result1 = EnabledIfStringIndex<WithStringIndex>;
293
- * // Result1 is unknown
294
- * type Result2 = EnabledIfStringIndex<WithoutStringIndex>;
295
- * // Result2 is never
296
- * ```
297
- */
298
- type EnabledIfStringIndex<T> = string extends keyof T ? unknown : never;
299
- //#endregion
300
- //#region src/types/loose-nested-like.d.ts
301
- /**
302
- * Recursively maps a nested structure `T` so that every leaf value becomes `V`.
303
- * Arrays and objects are traversed recursively; primitive leaves are replaced with `V`.
304
- *
305
- * @example
306
- * ```ts
307
- * // Scalar → replaced by V
308
- * type A = LooseNestedLike<string, number>;
309
- * // string
310
- *
311
- * // Array → each element is recursively mapped
312
- * type B = LooseNestedLike<string, [number, boolean]>;
313
- * // [string, string]
314
- *
315
- * // Nested object → every leaf becomes V
316
- * type C = LooseNestedLike<string, { a: number; b: { c: boolean } }>;
317
- * // { a: string; b: { c: string } }
318
- * ```
319
- */
320
- type LooseNestedLike<V, T> = T extends any[] ? { [I in keyof T]: LooseNestedLike<V, T[I]> } : T extends object ? { [K in keyof T]: LooseNestedLike<V, T[K]> } : V;
321
- /**
322
- * Conditional guard that resolves to `unknown` when `T` is structurally compatible
323
- * with `LooseNestedLike<V, T>`, and `never` otherwise.
324
- * Useful as a constraint in generic parameters to ensure a value matches
325
- * the expected nested shape.
326
- *
327
- * @example
328
- * ```ts
329
- * // T's leaves are all assignable to string → passes
330
- * type Ok = EnableLooseNestedLike<string, { a: string; b: { c: string } }>;
331
- * // unknown
332
- *
333
- * // T contains a leaf (number) not assignable to string → fails
334
- * type Fail = EnableLooseNestedLike<string, { a: string; b: { c: number } }>;
335
- * // never
336
- * ```
337
- */
338
- type EnableLooseNestedLike<V, T> = T extends LooseNestedLike<V, T> ? unknown : never;
339
- /**
340
- * Maps each property of `U` through `LooseNestedLike`, using the string-index
341
- * value type of `T` as the leaf replacement type.
342
- * Commonly used to validate that a user-supplied object `U` has the same nested
343
- * shape but with values drawn from `T`'s string index signature.
344
- *
345
- * @example
346
- * ```ts
347
- * type Schema = { [key: string]: string | number };
348
- *
349
- * type Input = {
350
- * name: string;
351
- * meta: { tag: boolean };
352
- * };
353
- *
354
- * type Result = LooseNestedObject<Schema, Input>;
355
- * // { name: string | number; meta: { tag: string | number } }
356
- * ```
357
- */
358
- type LooseNestedObject<T, U> = { [K in keyof U]: LooseNestedLike<StringIndexValueOf<T>, U[K]> };
359
- //#endregion
360
- //#region src/types/override.d.ts
361
- /**
362
- * Override properties of Destination with properties from Source.
363
- *
364
- * Unlike type-fest's `Merge`, this uses only built-in TypeScript type
365
- * operations (`Omit` + `&`), ensuring the result remains transparent
366
- * to the type checker — property access like `Override<A, B>['key']`
367
- * resolves eagerly instead of producing opaque conditional types.
368
- *
369
- * @example
370
- * ```ts
371
- * type Base = { a: string; b: number; c: boolean }
372
- * type Result = Override<Base, { b: string }>
373
- * // Result is { a: string; b: string; c: boolean }
374
- * ```
375
- */
376
- type Override<Destination, Source> = Omit<Destination, keyof Source> & Source;
377
- //#endregion
378
- //#region src/request/types/api-schema/default-operation.d.ts
379
- interface DefaultOperation extends KeqOperation {
380
- requestHeaders: {
381
- 'content-type': string;
382
- accept: string;
383
- 'accept-language': string;
384
- authorization: string;
385
- 'cache-control': string;
386
- 'if-modified-since': string;
387
- 'if-none-match': string;
388
- referer: string;
389
- [key: string]: string | number;
390
- };
391
- responseBody: unknown;
392
- }
393
- type KeqDefaultOperation<T extends Partial<KeqOperation> = {}> = Override<DefaultOperation, T>;
394
- //#endregion
395
- //#region src/request/types/api-schema/extract-method-operations.d.ts
396
- /**
397
- * Extract operations by method from API schema
398
- *
399
- * @example
400
- * ```
401
- * type MyApiSchema = {
402
- * '/users': {
403
- * get: { ... }
404
- * post: { ... }
405
- * }
406
- * }
407
- *
408
- * type GetOperations = ExtractMethodOperations<MyApiSchema, 'get'>
409
- * // Result:
410
- * // {
411
- * // '/users': { ... }
412
- * // }
413
- *
414
- * // Union method results in never
415
- * type NeverOperations = ExtractMethodOperations<MyApiSchema, 'put' | 'delete'>
416
- * // Result: never
417
- * ```
418
- */
419
- type ExtractMethodOperations<T extends KeqApiSchema, M extends KeqRequestMethod> = IsUnion<M> extends true ? never : { [P in keyof T as T[P][M] extends KeqOperation ? P : never]: T[P][M] extends KeqOperation ? T[P][M] : never };
420
- //#endregion
421
- //#region src/request/types/content-type.d.ts
422
- type ShorthandContentType = 'json' | 'form-data' | 'form' | 'jpeg' | 'bmp' | 'apng' | 'gif' | 'x-icon' | 'png' | 'webp' | 'tiff' | 'svg' | 'xml' | 'html' | 'css';
423
- type CommonContentType = 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | 'image/jpeg' | 'image/bmp' | 'image/apng' | 'image/gif' | 'image/x-icon' | 'image/png' | 'image/webp' | 'image/tiff' | 'image/svg+xml' | 'text/xml' | 'text/html' | 'text/css';
424
- //#endregion
425
- //#region src/request/types/keq-attachable-file.d.ts
426
- type KeqAttachableFile = Blob | File | Buffer;
427
- //#endregion
428
- //#region src/request/types/keq-query-options.d.ts
429
- interface KeqQueryOptions {
430
- indices?: IStringifyBaseOptions['indices'];
431
- arrayFormat?: IStringifyBaseOptions['arrayFormat'] | 'pipe' | 'space';
432
- allowDots?: boolean;
433
- }
434
- //#endregion
435
- //#region src/request/types/server-sent-event.d.ts
436
- type ServerSentEvent = EventSourceMessage;
437
- //#endregion
438
- //#region src/request/keq.d.ts
439
- /**
440
- * extends Core to provide a fluent API for building HTTP requests
441
- */
442
- declare class Keq<OP extends KeqOperation = KeqDefaultOperation, RES_BODY extends KeqOperation['responseBody'] = OP['responseBody'], REQ_PARAMS extends KeqOperation['requestParams'] = OP['requestParams'], REQ_QUERY extends KeqOperation['requestQuery'] = OP['requestQuery'], REQ_HEADERS extends KeqOperation['requestHeaders'] = OP['requestHeaders'], REQ_BODY extends KeqOperation['requestBody'] = OP['requestBody']> extends Core<OP> {
443
- /**
444
- * Set request header
445
- *
446
- * @description 设置请求头
447
- */
448
- set(headers: Partial<REQ_HEADERS> | Headers): this;
449
- set<T extends keyof LiteralKeys<REQ_HEADERS>>(name: T, value: LiteralKeys<REQ_HEADERS>[T]): this;
450
- set<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_HEADERS>): this;
451
- set<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(key: string, value: StringIndexValueOf<REQ_HEADERS> & EnabledIfStringIndex<REQ_HEADERS>): this;
452
- /**
453
- * Set request headers
454
- */
455
- headers(headers: Partial<REQ_HEADERS> | Headers): this;
456
- headers<T extends keyof LiteralKeys<REQ_HEADERS>>(name: T, value: LiteralKeys<REQ_HEADERS>[T]): this;
457
- headers<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_HEADERS>): this;
458
- headers<O extends { [K in keyof O]: StringIndexValueOf<REQ_HEADERS> }>(key: string, value: StringIndexValueOf<REQ_HEADERS> & EnabledIfStringIndex<REQ_HEADERS>): this;
459
- /**
460
- * Set request query/searchParams
461
- */
462
- query(obj: Partial<REQ_QUERY>, options?: KeqQueryOptions): this;
463
- query<T extends keyof LiteralKeys<REQ_QUERY>>(key: T, value: LiteralKeys<REQ_QUERY>[T], options?: KeqQueryOptions): this;
464
- /**
465
- * The following two overloads handle flat (non-nested) query params
466
- * with arbitrary key names when REQ_QUERY has a string index signature (`[key: string]: ...`).
467
- * Values must be directly assignable to the string index value type — no nested objects.
468
- *
469
- * @example
470
- * ```ts
471
- * // Given REQ_QUERY = { [key: string]: string }
472
- * request.query('customKey', 'value')
473
- * request.query({ customKey: 'value', anotherKey: 'value2' })
474
- * ```
475
- */
476
- query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(key: string, obj: (StringIndexValueOf<REQ_QUERY> & EnabledIfStringIndex<REQ_QUERY>) | undefined, options?: KeqQueryOptions): this;
477
- query<O extends { [K in keyof O]: StringIndexValueOf<REQ_QUERY> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_QUERY>, options?: KeqQueryOptions): this;
478
- /**
479
- * The following two overloads handle nested object query params
480
- * when REQ_QUERY has a string index signature (`[key: string]: ...`).
481
- * Every leaf value in the nested object must be assignable to the string index value type of REQ_QUERY.
482
- *
483
- * @example
484
- * ```ts
485
- * // Given REQ_QUERY = { [key: string]: string }
486
- * request.query({ filter: { status: 'active', tags: ['a', 'b'] } })
487
- * request.query('filter', { status: 'active', tags: ['a', 'b'] })
488
- * ```
489
- */
490
- query<O extends object>(arg: O & Partial<LooseNestedObject<REQ_QUERY, O>> & EnableLooseNestedLike<StringIndexValueOf<REQ_QUERY>, O> & EnabledIfStringIndex<REQ_QUERY>): this;
491
- query<K extends keyof REQ_QUERY, O extends object>(key: K, arg: (O & LooseNestedLike<StringIndexValueOf<REQ_QUERY>, O> & EnableLooseNestedLike<StringIndexValueOf<REQ_QUERY>, O> & EnabledIfStringIndex<REQ_QUERY>) | undefined, options?: KeqQueryOptions): this;
492
- /**
493
- * Set request route params
494
- */
495
- params(params: Partial<REQ_PARAMS>): this;
496
- params<T extends keyof LiteralKeys<REQ_PARAMS>>(key: T, value: LiteralKeys<REQ_PARAMS>[T]): this;
497
- params<O extends { [K in keyof O]: StringIndexValueOf<REQ_PARAMS> }>(obj: Partial<O> & EnabledIfStringIndex<REQ_PARAMS>): this;
498
- params<O extends { [K in keyof O]: StringIndexValueOf<REQ_PARAMS> }>(key: string, value: StringIndexValueOf<REQ_PARAMS> & EnabledIfStringIndex<REQ_PARAMS>): this;
499
- /**
500
- * Set request body
501
- */
502
- body(value: KeqBodyInit): this;
503
- /**
504
- * Setting the Content-Type
505
- */
506
- type(contentType: ShorthandContentType): this;
507
- type(contentType: CommonContentType): this;
508
- type(contentType: string): this;
509
- /**
510
- * Http Basic Authentication
511
- */
512
- auth(username: string, password: string): this;
513
- private setTypeIfEmpty;
514
- /**
515
- * set request body
516
- */
517
- send(value: Partial<REQ_BODY>): this;
518
- field<T extends ConditionalPick<RES_BODY, Primitive>, K extends keyof T>(arg1: K, value: T[K]): this;
519
- field(arg1: ConditionalPick<RES_BODY, Primitive>): this;
520
- field(arg1: string, value: string | string[]): this;
521
- field(arg1: Record<string, string>): this;
522
- attach<T extends keyof ConditionalPick<REQ_BODY, KeqAttachableFile>>(key: T, value: KeqAttachableFile, filename: string): this;
523
- attach<T extends keyof ConditionalPick<REQ_BODY, KeqAttachableFile>>(key: T, value: KeqAttachableFile | KeqAttachableFile[]): this;
524
- attach(key: string, value: KeqAttachableFile, filename: string): this;
525
- attach(key: string, value: KeqAttachableFile | KeqAttachableFile[]): this;
526
- /**
527
- *
528
- * @param retryTimes Max number of retries per call
529
- * @param retryDelay Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)
530
- * @param retryCallback Will be called after request failed
531
- */
532
- retry(retryTimes: number, retryDelay?: KeqRetryDelay, retryOn?: KeqRetryOn): this;
533
- redirect(mod: RequestRedirect): this;
534
- credentials(mod: RequestCredentials): this;
535
- mode(mod: RequestMode): this;
536
- flowControl(mode: 'concurrent', limit: number, signal?: KeqFlowControlSignal): this;
537
- flowControl(mode: 'serial', signal?: KeqFlowControlSignal): this;
538
- flowControl(mode: 'abort', signal?: KeqFlowControlSignal): this;
539
- flowControl(mode: 'mutex', signal?: KeqFlowControlSignal): this;
540
- timeout(milliseconds: number): this;
541
- resolveWith(m: 'response'): Keq<Override<OP, {
542
- responseBody: Response;
543
- }>>;
544
- resolveWith(m: 'array-buffer'): Keq<Override<OP, {
545
- responseBody: ArrayBuffer;
546
- }>>;
547
- resolveWith(m: 'blob'): Keq<Override<OP, {
548
- responseBody: Blob;
549
- }>>;
550
- resolveWith(m: 'text'): Keq<Override<OP, {
551
- responseBody: string;
552
- }>>;
553
- resolveWith(m: 'sse'): Keq<Override<OP, {
554
- responseBody: ReadableStream<ServerSentEvent>;
555
- }>>;
556
- resolveWith<T = any>(m: 'json' | 'form-data'): Keq<Override<OP, {
557
- responseBody: T;
558
- }>>;
559
- }
560
- //#endregion
561
- //#region src/context/types/keq-context-options/keq-resolve-with-mode.d.ts
562
- type KeqResolveWithMode = 'intelligent' | 'response' | 'text' | 'json' | 'form-data' | 'blob' | 'array-buffer' | 'sse';
563
- //#endregion
564
- //#region src/context/types/keq-context-options/keq-retry-options.d.ts
565
- type KeqRetryOn = (attempt: number, error: unknown | null, ctx: KeqSharedContext) => (boolean | Promise<boolean>);
566
- type KeqRetryDelay = number | ((attempt: number, error: unknown | null, ctx: KeqSharedContext) => number | Promise<number>);
567
- interface KeqRetryOptions {
568
- times: number;
569
- delay?: KeqRetryDelay;
570
- on?: KeqRetryOn;
571
- }
572
- //#endregion
573
- //#region src/context/types/keq-context-options/keq-middleware-options.d.ts
574
- interface KeqMiddlewareOptions<OP extends KeqOperation> {
575
- /**
576
- * replace the default fetch api
577
- * default use node-fetch@2 in node and window.fetch in browser
578
- */
579
- fetchAPI(value: typeof fetch): Keq<OP>;
580
- /**
581
- * how to resolve the response body
582
- * @description 如何解析响应体
583
- * @default 'intelligent'
584
- */
585
- resolveWith(value: KeqResolveWithMode): Keq<OP>;
586
- retry(value: KeqRetryOptions): Keq<OP>;
587
- flowControl(value: KeqFlowControlOptions): Keq<OP>;
588
- timeout(value: KeqTimeoutOptions): Keq<OP>;
589
- }
590
- type ExpectNever<T> = ConditionalExcept<T, never>;
591
- type KeqMiddlewareOptionsParameter = ExpectNever<{ [key in keyof KeqMiddlewareOptions<any>]?: Parameters<KeqMiddlewareOptions<any>[key]>[0] }>;
592
- type KeqMiddlewareOptionsReturnType<OP extends KeqOperation> = ExpectNever<{ [key in keyof KeqMiddlewareOptions<OP>]: ReturnType<KeqMiddlewareOptions<OP>[key]> }>;
593
- //#endregion
594
- //#region src/context/types/keq-context-options/keq-context-options.d.ts
595
- interface KeqContextOptions extends KeqMiddlewareOptionsParameter {
596
- [key: string]: any;
597
- }
598
- //#endregion
599
- //#region src/context/types/keq-global.d.ts
600
- interface KeqGlobalCore {
601
- abortFlowControl?: Record<string, ((reason: any) => void) | undefined>;
602
- serialFlowControl?: Record<string, queueAsPromised<{
603
- next: KeqNext;
604
- }, void>>;
605
- mutexFlowControl?: Set<string>;
606
- }
607
- interface KeqGlobal {
608
- core?: KeqGlobalCore;
609
- }
610
- //#endregion
611
- //#region src/context/types/keq-context-data.d.ts
612
- interface KeqContextData {
613
- retry?: {
614
- attempt: number;
615
- };
616
- [key: string]: any;
617
- }
618
- //#endregion
619
- //#region src/context/types/keq-context.d.ts
620
- interface KeqContext {
621
- locationId?: string;
622
- request: KeqRequestInit;
623
- response?: Response;
624
- res?: Response;
625
- output?: any;
626
- global: KeqGlobal;
627
- emitter: KeqContextEmitter;
628
- options: KeqContextOptions;
629
- data: KeqContextData;
630
- }
631
- //#endregion
632
- //#region src/context/execution-context.d.ts
633
- declare const ContextOrchestratorProperty = "__KeyProtectedProperty(context.orchestrator)__";
634
- declare const ContextOrchestrationProperty = "__KeyProtectedProperty(context.orchestration)__";
635
- declare class KeqExecutionContext implements KeqContext {
636
- private [ContextOrchestratorProperty];
637
- private [ContextOrchestrationProperty];
638
- constructor(orchestrator: KeqMiddlewareOrchestrator, executor: KeqMiddlewareExecutor);
639
- get orchestration(): KeqOrchestratorContext;
640
- /**
641
- * The unique identifier of the request's location in the code
642
- */
643
- get locationId(): string | undefined;
644
- get request(): KeqRequestInit;
645
- get global(): KeqGlobal;
646
- get emitter(): KeqContextEmitter;
647
- get options(): KeqContextOptions;
648
- set output(value: any);
649
- get res(): Response | undefined;
650
- set res(value: Response | undefined);
651
- get response(): Response | undefined;
652
- get data(): KeqContextData;
653
- }
654
- //#endregion
655
- //#region src/context/utils/create-proxy-response.d.ts
656
- declare function createProxyResponse(response: Response): Response;
657
- //#endregion
658
- //#region src/request/core.d.ts
659
- type KeqOptions = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone'>> & {
660
- locationId?: string;
661
- global?: KeqGlobal;
662
- qs?: KeqQueryOptions;
663
- middlewares?: KeqMiddleware[];
664
- };
665
- /**
666
- * Core class that provides the foundational structure for managing middlewares, events, and request execution.
667
- */
668
- declare class Core<OP extends KeqOperation = KeqDefaultOperation, RES_BODY extends KeqOperation['responseBody'] = OP['responseBody']> extends Promise<RES_BODY> {
669
- /**
670
- * Ensures `.then()`, `.catch()`, `.finally()` return plain Promise instances instead of Core/Keq instances.
671
- */
672
- static get [Symbol.species](): PromiseConstructor;
673
- /**
674
- * The unique identifier of the request's location in the code
675
- */
676
- __locationId__?: string;
677
- /** Deferred resolve callback captured from the Promise executor. */
678
- private __resolve__;
679
- /** Deferred reject callback captured from the Promise executor. */
680
- private __reject__;
681
- /** Whether the request has been lazily triggered by `.then()`. */
682
- private __triggered__;
683
- /** Cached promise for idempotent `end()` calls. */
684
- private __requestPromise__?;
685
- protected requestInit: KeqRequestInit;
686
- protected __listeners__: KeqListeners;
687
- protected __global__: Record<string, any>;
688
- protected __prepend_middlewares__: KeqMiddleware[];
689
- protected __append_middlewares__: KeqMiddleware[];
690
- protected __qs__: KeqQueryOptions | undefined;
691
- protected get __middlewares__(): KeqMiddleware[];
692
- protected __options__: KeqContextOptions;
693
- constructor(url: URL, options: KeqOptions);
694
- use(...middlewares: KeqMiddleware[]): this;
695
- on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this;
696
- option<K extends keyof KeqMiddlewareOptionsReturnType<OP>>(key: K, value?: KeqMiddlewareOptionsParameter[K]): KeqMiddlewareOptionsReturnType<OP>[K];
697
- option(key: string, value?: any): this;
698
- options(opts: KeqContextOptions): this;
699
- derive(): this;
700
- private buildSharedContext;
701
- private run;
702
- private __execute__;
703
- fire(): void;
704
- then<TResult1 = RES_BODY, TResult2 = never>(onfulfilled?: ((value: RES_BODY) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
705
- }
706
- //#endregion
707
- //#region src/router/types/keq-route.d.ts
708
- interface KeqRoute {
709
- (ctx: KeqExecutionContext): Promisable<boolean>;
710
- __keqRouteName__?: string;
711
- }
712
- //#endregion
713
- //#region src/router/utils/compose-route.d.ts
714
- declare function composeRoute(routes: KeqRoute[]): KeqRoute;
715
- //#endregion
716
- //#region src/router/keq-router.d.ts
717
- declare class KeqRouter {
718
- private readonly middlewares;
719
- constructor(middlewares?: KeqMiddleware[]);
720
- private static buildMiddleware;
721
- route(route: KeqRoute, middleware: KeqMiddleware[]): this;
722
- route(route: KeqRoute, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this;
723
- host(host: string, middleware: KeqMiddleware[]): this;
724
- host(host: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this;
725
- method(method: string, middleware: KeqMiddleware[]): this;
726
- method(method: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this;
727
- pathname(pathname: string, middleware: KeqMiddleware[]): this;
728
- pathname(pathname: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this;
729
- location(middleware: KeqMiddleware[]): this;
730
- location(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): this;
731
- static route(route: KeqRoute, middleware: KeqMiddleware[]): KeqMiddleware;
732
- static route(route: KeqRoute, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware;
733
- static host(host: string, middleware: KeqMiddleware[]): KeqMiddleware;
734
- static host(host: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware;
735
- static method(method: string, middleware: KeqMiddleware[]): KeqMiddleware;
736
- static method(method: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware;
737
- static pathname(pathname: string, middleware: KeqMiddleware[], ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware;
738
- static pathname(pathname: string, middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware;
739
- static location(middleware: KeqMiddleware[]): KeqMiddleware;
740
- static location(middleware: KeqMiddleware, ...additionalMiddlewares: KeqMiddleware[]): KeqMiddleware;
741
- }
742
- //#endregion
743
- //#region src/request/request.d.ts
744
- interface KeqRequestOptions {
745
- middlewares?: KeqMiddleware[];
746
- terminalMiddlewares?: KeqMiddleware[];
747
- baseOrigin?: string;
748
- qs?: KeqQueryOptions;
749
- }
750
- interface KeqRequestForkOptions {
751
- baseOrigin?: string;
752
- qs?: KeqQueryOptions;
753
- }
754
- type KeqRequestFetchOptions<M extends KeqRequestMethod = KeqRequestMethod> = Partial<Omit<KeqRequestInit, 'url' | '__url__' | 'signal' | 'abort' | 'clone' | 'toFetchArguments' | 'method'>> & {
755
- method: M;
756
- };
757
- /**
758
- * Keq instance factory class,
759
- * and shares global data and middlewares across requests
760
- */
761
- declare class KeqRequest<SCHEMA extends KeqApiSchema = KeqApiSchema> {
762
- baseOrigin: string;
763
- qs?: KeqQueryOptions;
764
- /**
765
- * share data between requests, used to implement flowControl
766
- * @description 跨请求共享数据,用于实现 flowControl的功能
767
- */
768
- readonly global: KeqGlobal;
769
- readonly middlewares: KeqMiddleware[];
770
- private readonly __terminalMiddlewares__;
771
- private __parent__?;
772
- constructor(options?: KeqRequestOptions);
773
- private __formatUrl__;
774
- private resolveMiddlewares;
775
- private __fetch__;
776
- fetch<P extends keyof SCHEMA, M extends KeqRequestMethod>(url: P, init: KeqRequestFetchOptions<M>): Keq<Exclude<SCHEMA[P][M], undefined>>;
777
- fetch<T = unknown>(url: string | URL, init: KeqRequestFetchOptions): Keq<KeqDefaultOperation<{
778
- responseBody: T;
779
- }>>;
780
- get<P extends keyof ExtractMethodOperations<SCHEMA, 'get'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'get'>[P], ExtractMethodOperations<SCHEMA, 'get'>[P]>;
781
- get<T>(url: string | URL): Keq<KeqDefaultOperation<{
782
- responseBody: T;
783
- }>>;
784
- put<P extends keyof ExtractMethodOperations<SCHEMA, 'put'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'put'>[P], ExtractMethodOperations<SCHEMA, 'put'>[P]>;
785
- put<T>(url: string | URL): Keq<KeqDefaultOperation<{
786
- responseBody: T;
787
- }>>;
788
- delete<P extends keyof ExtractMethodOperations<SCHEMA, 'delete'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'delete'>[P], ExtractMethodOperations<SCHEMA, 'delete'>[P]>;
789
- delete<T>(url: string | URL): Keq<KeqDefaultOperation<{
790
- responseBody: T;
791
- }>>;
792
- del<P extends keyof ExtractMethodOperations<SCHEMA, 'delete'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'delete'>[P], ExtractMethodOperations<SCHEMA, 'delete'>[P]>;
793
- del<T>(url: string | URL): Keq<KeqDefaultOperation<{
794
- responseBody: T;
795
- }>>;
796
- post<P extends keyof ExtractMethodOperations<SCHEMA, 'post'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'post'>[P], ExtractMethodOperations<SCHEMA, 'post'>[P]>;
797
- post<T>(url: string | URL): Keq<KeqDefaultOperation<{
798
- responseBody: T;
799
- }>>;
800
- head<P extends keyof ExtractMethodOperations<SCHEMA, 'head'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'head'>[P], ExtractMethodOperations<SCHEMA, 'head'>[P]>;
801
- head<T>(url: string | URL): Keq<KeqDefaultOperation<{
802
- responseBody: T;
803
- }>>;
804
- patch<P extends keyof ExtractMethodOperations<SCHEMA, 'patch'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'patch'>[P], ExtractMethodOperations<SCHEMA, 'patch'>[P]>;
805
- patch<T>(url: string | URL): Keq<KeqDefaultOperation<{
806
- responseBody: T;
807
- }>>;
808
- options<P extends keyof ExtractMethodOperations<SCHEMA, 'options'>>(url: P): Keq<ExtractMethodOperations<SCHEMA, 'options'>[P], ExtractMethodOperations<SCHEMA, 'options'>[P]>;
809
- options<T>(url: string | URL): Keq<KeqDefaultOperation<{
810
- responseBody: T;
811
- }>>;
812
- use(firstMiddleware: KeqMiddleware, ...middleware: KeqMiddleware[]): this;
813
- useRouter(): KeqRouter;
814
- fork(options?: KeqRequestForkOptions): KeqRequest;
815
- inherit(parent: KeqRequest): this;
816
- adopt(child: KeqRequest): this;
817
- /** @deprecated Use `middlewares` instead */
818
- get preMiddlewares(): KeqMiddleware[];
819
- on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this;
820
- }
821
- declare const request: KeqRequest<KeqApiSchema>;
822
- //#endregion
823
- //#region src/request/create-request.d.ts
824
- /**
825
- * @deprecated use new KeqRequest<SCHEMA>(options) instead
826
- */
827
- declare function createRequest<SCHEMA extends KeqApiSchema>(options?: KeqRequestOptions): KeqRequest<SCHEMA>;
828
- //#endregion
829
- //#region src/exception/exception.d.ts
830
- declare class Exception extends CustomError {
831
- constructor(message?: string);
832
- }
833
- //#endregion
834
- //#region src/exception/type.exception.d.ts
835
- declare class TypeException extends Exception {
836
- constructor(msg?: string);
837
- }
838
- //#endregion
839
- //#region src/exception/abort.exception.d.ts
840
- declare class AbortException extends DOMException {
841
- constructor(msg: string);
842
- }
843
- //#endregion
844
- //#region src/exception/timeout.exception.d.ts
845
- declare class TimeoutException extends AbortException {
846
- constructor(msg: string);
847
- }
848
- //#endregion
849
- //#region src/exception/http-exceptions/request.exception.d.ts
850
- interface RequestExceptionOptions {
851
- fatal?: boolean;
852
- response?: Response;
853
- }
854
- declare class RequestException extends Exception {
855
- statusCode: number | string;
856
- retry: boolean;
857
- response?: Response;
858
- constructor(statusCode: number | string, message?: string, options?: RequestExceptionOptions);
859
- }
860
- //#endregion
861
- //#region src/exception/http-exceptions/bad-request.exception.d.ts
862
- declare class BadRequestException extends RequestException {
863
- constructor(message?: string, options?: RequestExceptionOptions);
864
- }
865
- //#endregion
866
- //#region src/exception/http-exceptions/unauthorized.exception.d.ts
867
- declare class UnauthorizedException extends RequestException {
868
- constructor(message?: string, options?: RequestExceptionOptions);
869
- }
870
- //#endregion
871
- //#region src/exception/http-exceptions/forbidden.exception.d.ts
872
- declare class ForbiddenException extends RequestException {
873
- constructor(message?: string, options?: RequestExceptionOptions);
874
- }
875
- //#endregion
876
- //#region src/exception/http-exceptions/not-founded.exception.d.ts
877
- declare class NotFoundedException extends RequestException {
878
- constructor(message?: string, options?: RequestExceptionOptions);
879
- }
880
- //#endregion
881
- //#region src/exception/http-exceptions/method-not-allowed.exception.d.ts
882
- declare class MethodNotAllowedException extends RequestException {
883
- constructor(message?: string, options?: RequestExceptionOptions);
884
- }
885
- //#endregion
886
- //#region src/exception/http-exceptions/not-acceptable.exception.d.ts
887
- declare class NotAcceptableException extends RequestException {
888
- constructor(message?: string, options?: RequestExceptionOptions);
889
- }
890
- //#endregion
891
- //#region src/exception/http-exceptions/proxy-authentication-required.exception.d.ts
892
- declare class ProxyAuthenticationRequiredException extends RequestException {
893
- constructor(message?: string, options?: RequestExceptionOptions);
894
- }
895
- //#endregion
896
- //#region src/exception/http-exceptions/request-timeout.exception.d.ts
897
- declare class RequestTimeoutException extends RequestException {
898
- constructor(message?: string, options?: RequestExceptionOptions);
899
- }
900
- //#endregion
901
- //#region src/exception/http-exceptions/conflict.exception.d.ts
902
- declare class ConflictException extends RequestException {
903
- constructor(message?: string, options?: RequestExceptionOptions);
904
- }
905
- //#endregion
906
- //#region src/exception/http-exceptions/precondition-failed.exception.d.ts
907
- declare class PreconditionFailedException extends RequestException {
908
- constructor(message?: string, options?: RequestExceptionOptions);
909
- }
910
- //#endregion
911
- //#region src/exception/http-exceptions/content-too-large.exception.d.ts
912
- declare class ContentTooLargeException extends RequestException {
913
- constructor(message?: string, options?: RequestExceptionOptions);
914
- }
915
- //#endregion
916
- //#region src/exception/http-exceptions/uri-too-long.exception.d.ts
917
- declare class UriTooLongException extends RequestException {
918
- constructor(message?: string, options?: RequestExceptionOptions);
919
- }
920
- //#endregion
921
- //#region src/exception/http-exceptions/unsupported-media-type.exception.d.ts
922
- declare class UnsupportedMediaTypeException extends RequestException {
923
- constructor(message?: string, options?: RequestExceptionOptions);
924
- }
925
- //#endregion
926
- //#region src/exception/http-exceptions/im-a-teapot.exception.d.ts
927
- declare class ImATeapotException extends RequestException {
928
- constructor(message?: string, options?: RequestExceptionOptions);
929
- }
930
- //#endregion
931
- //#region src/exception/http-exceptions/too-many-requests.exception.d.ts
932
- declare class TooManyRequestsException extends RequestException {
933
- constructor(message?: string, options?: RequestExceptionOptions);
934
- }
935
- //#endregion
936
- //#region src/exception/http-exceptions/internal-server-error.exception.d.ts
937
- declare class InternalServerErrorException extends RequestException {
938
- constructor(message?: string, options?: RequestExceptionOptions);
939
- }
940
- //#endregion
941
- //#region src/exception/http-exceptions/not-implemented.exception.d.ts
942
- declare class NotImplementedException extends RequestException {
943
- constructor(message?: string, options?: RequestExceptionOptions);
944
- }
945
- //#endregion
946
- //#region src/exception/http-exceptions/bad-gateway.exception.d.ts
947
- declare class BadGatewayException extends RequestException {
948
- constructor(message?: string, options?: RequestExceptionOptions);
949
- }
950
- //#endregion
951
- //#region src/exception/http-exceptions/service-unavailable.exception.d.ts
952
- declare class ServiceUnavailableException extends RequestException {
953
- constructor(message?: string, options?: RequestExceptionOptions);
954
- }
955
- //#endregion
956
- //#region src/exception/http-exceptions/gateway-timeout.exception.d.ts
957
- declare class GatewayTimeoutException extends RequestException {
958
- constructor(message?: string, options?: RequestExceptionOptions);
959
- }
960
- //#endregion
961
- export { AbortException, BadGatewayException, BadRequestException, ConflictException, ContentTooLargeException, Exception, ForbiddenException, GatewayTimeoutException, ImATeapotException, InternalServerErrorException, Keq, type KeqApiSchema, type KeqBodyInit, type KeqContext, type KeqContextData, type KeqContextEmitter, type KeqContextOptions, type KeqDefaultOperation, type KeqEvents, KeqExecutionContext, type KeqGlobal, type KeqGlobalCore, type KeqMiddleware, KeqMiddlewareExecutor, type KeqMiddlewareOptions, KeqMiddlewareOrchestrator, type KeqNext, type KeqOperation, type KeqOptions, type KeqPathParameterInit, type KeqQueryInit, type KeqQueryOptions, KeqRequest, type KeqRequestForkOptions, type KeqRetryDelay, type KeqRetryOn, type KeqRoute, KeqSharedContext, type KeqSharedContextOptions, MethodNotAllowedException, NotAcceptableException, NotFoundedException, NotImplementedException, PreconditionFailedException, ProxyAuthenticationRequiredException, RequestException, type RequestExceptionOptions, RequestTimeoutException, type ServerSentEvent, ServiceUnavailableException, TimeoutException, TooManyRequestsException, TypeException, UnauthorizedException, UnsupportedMediaTypeException, UriTooLongException, composeMiddleware, composeRoute, createProxyResponse, createRequest, request };
962
- //# sourceMappingURL=index.d.ts.map