@igniter-js/caller 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -8,6 +8,20 @@ import { z } from 'zod';
8
8
  */
9
9
  type IgniterCallerHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
10
10
 
11
+ /**
12
+ * Retry configuration for failed requests.
13
+ */
14
+ interface IgniterCallerRetryOptions {
15
+ /** Maximum number of retry attempts. */
16
+ maxAttempts: number;
17
+ /** Backoff strategy between retries. */
18
+ backoff?: 'linear' | 'exponential';
19
+ /** Base delay in milliseconds (default: 1000). */
20
+ baseDelay?: number;
21
+ /** HTTP status codes that should trigger a retry (default: [408, 429, 500, 502, 503, 504]). */
22
+ retryOnStatus?: number[];
23
+ }
24
+
11
25
  /**
12
26
  * Base configuration options for HTTP requests.
13
27
  */
@@ -31,6 +45,34 @@ interface IgniterCallerRequestOptions<TBody = unknown> extends IgniterCallerBase
31
45
  responseSchema?: z.ZodSchema<any>;
32
46
  cache?: RequestCache;
33
47
  }
48
+ /**
49
+ * Options for the direct request() method (axios-style).
50
+ * All options in one object, executes immediately.
51
+ */
52
+ interface IgniterCallerDirectRequestOptions<TBody = unknown> extends IgniterCallerBaseRequestOptions {
53
+ /** HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD) */
54
+ method: IgniterCallerHttpMethod;
55
+ /** Endpoint URL path. If absolute, `baseURL` is ignored. */
56
+ url: string;
57
+ /** Request body (for POST, PUT, PATCH) */
58
+ body?: TBody;
59
+ /** URL query parameters */
60
+ params?: Record<string, string | number | boolean>;
61
+ /** Cookies to send with the request */
62
+ cookies?: Record<string, string>;
63
+ /** Response validation schema (Zod) */
64
+ responseSchema?: z.ZodSchema<any>;
65
+ /** Cache strategy */
66
+ cache?: RequestCache;
67
+ /** Cache key for stale-while-revalidate */
68
+ cacheKey?: string;
69
+ /** Stale time in milliseconds for caching */
70
+ staleTime?: number;
71
+ /** Retry configuration */
72
+ retry?: IgniterCallerRetryOptions;
73
+ /** Fallback value if request fails */
74
+ fallback?: () => any;
75
+ }
34
76
 
35
77
  /**
36
78
  * Response object containing either successful data or an error.
@@ -38,14 +80,32 @@ interface IgniterCallerRequestOptions<TBody = unknown> extends IgniterCallerBase
38
80
  interface IgniterCallerApiResponse<T> {
39
81
  data?: T;
40
82
  error?: Error;
83
+ /** HTTP status code from the response */
84
+ status?: number;
85
+ /** Response headers */
86
+ headers?: Headers;
41
87
  }
42
88
  /**
43
89
  * Response object for file downloads.
90
+ * @deprecated Use execute() with responseType<File>() instead
44
91
  */
45
92
  interface IgniterCallerFileResponse {
46
93
  file: File | null;
47
94
  error: Error | null;
48
95
  }
96
+ /**
97
+ * Supported response content types that can be auto-detected.
98
+ */
99
+ type IgniterCallerResponseContentType = 'json' | 'xml' | 'csv' | 'text' | 'html' | 'blob' | 'stream' | 'arraybuffer' | 'formdata';
100
+ /**
101
+ * Content types that support schema validation.
102
+ */
103
+ type IgniterCallerValidatableContentType = 'json' | 'xml' | 'csv';
104
+ /**
105
+ * Marker types for responseType() to indicate expected response format.
106
+ * These are used for typing only and don't affect runtime behavior.
107
+ */
108
+ type IgniterCallerResponseMarker = File | Blob | ReadableStream | ArrayBuffer | FormData;
49
109
 
50
110
  /**
51
111
  * Function that can modify request configuration before execution.
@@ -59,7 +119,7 @@ type IgniterCallerResponseInterceptor = <T>(response: IgniterCallerApiResponse<T
59
119
  /**
60
120
  * HTTP methods supported for schema mapping.
61
121
  */
62
- type IgniterCallerSchemaMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
122
+ type IgniterCallerSchemaMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
63
123
  /**
64
124
  * Schema definition for a single endpoint.
65
125
  *
@@ -128,6 +188,10 @@ type InferRequestType<T> = T extends IgniterCallerEndpointSchema<infer R, any> ?
128
188
  * Infer response type by status code from endpoint schema.
129
189
  */
130
190
  type InferResponseType<T, Status extends number> = T extends IgniterCallerEndpointSchema<any, infer Responses> ? Status extends keyof Responses ? Responses[Status] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Responses[Status]> : never : never : never;
191
+ /**
192
+ * Infer the success response type (status 200 or 201) from endpoint schema.
193
+ */
194
+ type InferSuccessResponseType<T> = T extends IgniterCallerEndpointSchema<any, infer Responses> ? 200 extends keyof Responses ? Responses[200] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Responses[200]> : never : 201 extends keyof Responses ? Responses[201] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Responses[201]> : never : never : never;
131
195
  /**
132
196
  * Infer all possible response types (union) from endpoint schema.
133
197
  */
@@ -137,6 +201,26 @@ type InferAllResponseTypes<T> = T extends IgniterCallerEndpointSchema<any, infer
137
201
  data: StandardSchemaV1.InferOutput<Responses[K]>;
138
202
  } : never;
139
203
  }[keyof Responses] : never : never;
204
+ /**
205
+ * Get all available paths from a schema map.
206
+ */
207
+ type SchemaMapPaths<TSchemas extends IgniterCallerSchemaMap> = keyof TSchemas & string;
208
+ /**
209
+ * Get available methods for a specific path.
210
+ */
211
+ type SchemaMapMethods<TSchemas extends IgniterCallerSchemaMap, TPath extends keyof TSchemas> = keyof TSchemas[TPath] & IgniterCallerSchemaMethod;
212
+ /**
213
+ * Get endpoint schema for a specific path and method.
214
+ */
215
+ type SchemaMapEndpoint<TSchemas extends IgniterCallerSchemaMap, TPath extends keyof TSchemas, TMethod extends keyof TSchemas[TPath]> = TSchemas[TPath][TMethod];
216
+ /**
217
+ * Infer response type from schema map for a specific path, method, and status.
218
+ */
219
+ type SchemaMapResponseType<TSchemas extends IgniterCallerSchemaMap, TPath extends keyof TSchemas, TMethod extends keyof TSchemas[TPath], TStatus extends number = 200> = TSchemas[TPath][TMethod] extends IgniterCallerEndpointSchema<any, infer Responses> ? TStatus extends keyof Responses ? Responses[TStatus] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Responses[TStatus]> : never : never : never;
220
+ /**
221
+ * Infer request type from schema map for a specific path and method.
222
+ */
223
+ type SchemaMapRequestType<TSchemas extends IgniterCallerSchemaMap, TPath extends keyof TSchemas, TMethod extends keyof TSchemas[TPath]> = TSchemas[TPath][TMethod] extends IgniterCallerEndpointSchema<infer Request, any> ? Request extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Request> : never : never;
140
224
  /**
141
225
  * Options for schema validation behavior.
142
226
  */
@@ -207,7 +291,7 @@ interface IgniterCallerStoreOptions {
207
291
  fallbackToFetch?: boolean;
208
292
  }
209
293
 
210
- type IgniterCallerBuilderState<TSchemas extends IgniterCallerSchemaMap = any> = {
294
+ type IgniterCallerBuilderState<TSchemas extends IgniterCallerSchemaMap = IgniterCallerSchemaMap> = {
211
295
  baseURL?: string;
212
296
  headers?: Record<string, string>;
213
297
  cookies?: Record<string, string>;
@@ -219,7 +303,16 @@ type IgniterCallerBuilderState<TSchemas extends IgniterCallerSchemaMap = any> =
219
303
  schemas?: TSchemas;
220
304
  schemaValidation?: IgniterCallerSchemaValidationOptions;
221
305
  };
222
- type IgniterCallerBuilderFactory<TCaller, TSchemas extends IgniterCallerSchemaMap = any> = (state: IgniterCallerBuilderState<TSchemas>) => TCaller;
306
+ type IgniterCallerBuilderFactory<TCaller, TSchemas extends IgniterCallerSchemaMap = IgniterCallerSchemaMap> = (state: IgniterCallerBuilderState<TSchemas>) => TCaller;
307
+ /**
308
+ * Utility type to replace the schema type in a caller.
309
+ * Used by withSchemas to properly type the returned caller.
310
+ */
311
+ type ReplaceCallerSchema<TCaller, TNewSchemas extends IgniterCallerSchemaMap> = TCaller extends {
312
+ schemas?: infer _;
313
+ } ? Omit<TCaller, 'schemas'> & {
314
+ schemas?: TNewSchemas;
315
+ } : TCaller;
223
316
  /**
224
317
  * Builder used by developers to initialize the `IgniterCaller` client.
225
318
  *
@@ -289,23 +382,26 @@ declare class IgniterCallerBuilder<TCaller = unknown, TSchemas extends IgniterCa
289
382
  }
290
383
 
291
384
  /**
292
- * Retry configuration for failed requests.
385
+ * Constructor params for the request builder.
293
386
  */
294
- interface IgniterCallerRetryOptions {
295
- /** Maximum number of retry attempts. */
296
- maxAttempts: number;
297
- /** Backoff strategy between retries. */
298
- backoff?: 'linear' | 'exponential';
299
- /** Base delay in milliseconds (default: 1000). */
300
- baseDelay?: number;
301
- /** HTTP status codes that should trigger a retry (default: [408, 429, 500, 502, 503, 504]). */
302
- retryOnStatus?: number[];
387
+ interface IgniterCallerRequestBuilderParams {
388
+ baseURL?: string;
389
+ defaultHeaders?: Record<string, string>;
390
+ defaultCookies?: Record<string, string>;
391
+ logger?: IgniterLogger;
392
+ requestInterceptors?: IgniterCallerRequestInterceptor[];
393
+ responseInterceptors?: IgniterCallerResponseInterceptor[];
394
+ eventEmitter?: (url: string, method: string, result: any) => Promise<void>;
395
+ schemas?: IgniterCallerSchemaMap;
396
+ schemaValidation?: IgniterCallerSchemaValidationOptions;
303
397
  }
304
-
305
398
  /**
306
399
  * Fluent request builder for `IgniterCaller`.
400
+ *
401
+ * When created via specific HTTP methods (get, post, put, patch, delete),
402
+ * the method is already set and cannot be changed.
307
403
  */
308
- declare class IgniterCallerRequestBuilder {
404
+ declare class IgniterCallerRequestBuilder<TResponse = unknown> {
309
405
  private options;
310
406
  private logger?;
311
407
  private retryOptions?;
@@ -317,27 +413,46 @@ declare class IgniterCallerRequestBuilder {
317
413
  private eventEmitter?;
318
414
  private schemas?;
319
415
  private schemaValidation?;
320
- constructor(params: {
321
- baseURL?: string;
322
- defaultHeaders?: Record<string, string>;
323
- defaultCookies?: Record<string, string>;
324
- logger?: IgniterLogger;
325
- requestInterceptors?: IgniterCallerRequestInterceptor[];
326
- responseInterceptors?: IgniterCallerResponseInterceptor[];
327
- eventEmitter?: (url: string, method: string, result: any) => Promise<void>;
328
- schemas?: IgniterCallerSchemaMap;
329
- schemaValidation?: IgniterCallerSchemaValidationOptions;
330
- });
416
+ private responseTypeSchema?;
417
+ constructor(params: IgniterCallerRequestBuilderParams);
418
+ /**
419
+ * Sets the HTTP method for this request.
420
+ * @internal Used by IgniterCaller.request() for generic requests.
421
+ */
422
+ _setMethod(method: IgniterCallerHttpMethod): this;
423
+ /**
424
+ * Sets the URL for this request.
425
+ * @internal Used when URL is passed to HTTP method directly.
426
+ */
427
+ _setUrl(url: string): this;
331
428
  /**
332
429
  * Overrides the logger for this request chain.
333
430
  */
334
431
  withLogger(logger: IgniterLogger): this;
335
- method(method: IgniterCallerHttpMethod): this;
432
+ /**
433
+ * Sets the request URL.
434
+ */
336
435
  url(url: string): this;
436
+ /**
437
+ * Sets the request body.
438
+ * For GET/HEAD requests, body will be automatically converted to query params.
439
+ */
337
440
  body<TBody>(body: TBody): this;
441
+ /**
442
+ * Sets URL query parameters.
443
+ */
338
444
  params(params: Record<string, string | number | boolean>): this;
445
+ /**
446
+ * Merges additional headers into the request.
447
+ */
339
448
  headers(headers: Record<string, string>): this;
449
+ /**
450
+ * Sets request timeout in milliseconds.
451
+ */
340
452
  timeout(timeout: number): this;
453
+ /**
454
+ * Sets cache strategy and optional cache key.
455
+ */
341
456
  cache(cache: RequestCache, key?: string): this;
342
457
  /**
343
458
  * Configures retry behavior for failed requests.
@@ -351,14 +466,45 @@ declare class IgniterCallerRequestBuilder {
351
466
  * Sets cache stale time in milliseconds.
352
467
  */
353
468
  stale(milliseconds: number): this;
354
- responseType<T>(schema?: z.ZodSchema<T>): this;
469
+ /**
470
+ * Sets the expected response type for TypeScript inference.
471
+ *
472
+ * - If a Zod/StandardSchema is passed, it will validate the response (only for JSON/XML/CSV)
473
+ * - If a type parameter is passed (e.g., `responseType<File>()`), it's for typing only
474
+ *
475
+ * The actual parsing is based on Content-Type headers, not this setting.
476
+ *
477
+ * @example
478
+ * ```ts
479
+ * // With Zod schema (validates JSON response)
480
+ * const result = await api.get('/users').responseType(UserSchema).execute()
481
+ *
482
+ * // With type marker (typing only, no validation)
483
+ * const result = await api.get('/file').responseType<Blob>().execute()
484
+ * ```
485
+ */
486
+ responseType<T>(schema?: z.ZodSchema<T> | StandardSchemaV1): IgniterCallerRequestBuilder<T>;
355
487
  /**
356
488
  * Downloads a file via GET request.
489
+ * @deprecated Use `.responseType<File>().execute()` instead. The response type is auto-detected.
357
490
  */
358
491
  getFile(url: string): {
359
492
  execute: () => Promise<IgniterCallerFileResponse>;
360
493
  };
361
- execute<T = unknown>(): Promise<IgniterCallerApiResponse<T>>;
494
+ /**
495
+ * Executes the HTTP request.
496
+ *
497
+ * Response parsing is automatic based on Content-Type headers:
498
+ * - `application/json` → parsed as JSON
499
+ * - `text/xml`, `application/xml` → returned as text (parse with your XML library)
500
+ * - `text/csv` → returned as text
501
+ * - `text/html`, `text/plain` → returned as text
502
+ * - `image/*`, `audio/*`, `video/*`, `application/pdf`, etc. → returned as Blob
503
+ * - `application/octet-stream` → returned as Blob
504
+ *
505
+ * Schema validation (if configured) only runs for validatable content types (JSON, XML, CSV).
506
+ */
507
+ execute(): Promise<IgniterCallerApiResponse<TResponse>>;
362
508
  private executeWithRetry;
363
509
  private executeSingleRequest;
364
510
  private buildRequest;
@@ -367,6 +513,19 @@ declare class IgniterCallerRequestBuilder {
367
513
  */
368
514
  private emitEvent;
369
515
  }
516
+ /**
517
+ * Request builder type without internal methods.
518
+ * Used when creating requests via specific HTTP methods (get, post, etc.)
519
+ */
520
+ type IgniterCallerMethodRequestBuilder<TResponse = unknown> = Omit<IgniterCallerRequestBuilder<TResponse>, '_setMethod' | '_setUrl'>;
521
+ /**
522
+ * Request builder with typed response based on schema inference.
523
+ * Used when creating requests via HTTP methods with URL that matches a schema.
524
+ *
525
+ * This type ensures that the execute() method returns the correct response type
526
+ * based on the schema map configuration.
527
+ */
528
+ type IgniterCallerTypedRequestBuilder<TResponse = unknown> = Omit<IgniterCallerRequestBuilder<TResponse>, '_setMethod' | '_setUrl'>;
370
529
 
371
530
  /**
372
531
  * Callback function for event listeners.
@@ -381,13 +540,28 @@ type IgniterCallerEventCallback<T = any> = (result: IgniterCallerApiResponse<T>,
381
540
  */
382
541
  type IgniterCallerUrlPattern = string | RegExp;
383
542
 
543
+ /**
544
+ * Infer success response type from endpoint schema (200 or 201).
545
+ */
546
+ type InferSuccessResponse<T> = T extends IgniterCallerEndpointSchema<any, infer R> ? 200 extends keyof R ? R[200] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<R[200]> : unknown : 201 extends keyof R ? R[201] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<R[201]> : unknown : unknown : unknown;
547
+ /**
548
+ * Get the endpoint schema for a path and method from a schema map.
549
+ */
550
+ type GetEndpoint<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends IgniterCallerSchemaMethod> = TPath extends keyof TSchemas ? TMethod extends keyof TSchemas[TPath] ? TSchemas[TPath][TMethod] : undefined : undefined;
551
+ /**
552
+ * Infer the response type for a given path and method.
553
+ * Returns `unknown` if the path/method is not in the schema.
554
+ */
555
+ type InferResponse<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends IgniterCallerSchemaMethod> = InferSuccessResponse<GetEndpoint<TSchemas, TPath, TMethod>>;
384
556
  /**
385
557
  * HTTP client runtime for Igniter.js.
386
558
  *
387
559
  * This module is intentionally structured to be extracted into a standalone package
388
560
  * in the Igniter.js ecosystem as `@igniter-js/caller`.
561
+ *
562
+ * @template TSchemas - The schema map type for type-safe requests/responses.
389
563
  */
390
- declare class IgniterCaller {
564
+ declare class IgniterCaller<TSchemas extends IgniterCallerSchemaMap = IgniterCallerSchemaMap> {
391
565
  /** Global event emitter for observing HTTP responses */
392
566
  private static readonly events;
393
567
  private baseURL?;
@@ -404,7 +578,7 @@ declare class IgniterCaller {
404
578
  logger?: IgniterLogger;
405
579
  requestInterceptors?: IgniterCallerRequestInterceptor[];
406
580
  responseInterceptors?: IgniterCallerResponseInterceptor[];
407
- schemas?: IgniterCallerSchemaMap;
581
+ schemas?: TSchemas;
408
582
  schemaValidation?: IgniterCallerSchemaValidationOptions;
409
583
  });
410
584
  /**
@@ -412,20 +586,132 @@ declare class IgniterCaller {
412
586
  *
413
587
  * This is designed to remain stable when extracted to `@igniter-js/caller`.
414
588
  */
415
- static create(): IgniterCallerBuilder<IgniterCaller>;
589
+ static create<TInitSchemas extends IgniterCallerSchemaMap = IgniterCallerSchemaMap>(): IgniterCallerBuilder<IgniterCaller<TInitSchemas>, TInitSchemas>;
416
590
  /**
417
591
  * Returns a new client with the same config and a new logger.
418
592
  */
419
- withLogger(logger: IgniterLogger): IgniterCaller;
593
+ withLogger(logger: IgniterLogger): IgniterCaller<TSchemas>;
420
594
  setBaseURL(baseURL: string): this;
421
595
  setHeaders(headers: Record<string, string>): this;
422
596
  setCookies(cookies: Record<string, string>): this;
423
- get(): IgniterCallerRequestBuilder;
424
- post(): IgniterCallerRequestBuilder;
425
- put(): IgniterCallerRequestBuilder;
426
- patch(): IgniterCallerRequestBuilder;
427
- delete(): IgniterCallerRequestBuilder;
428
- request(): IgniterCallerRequestBuilder;
597
+ /**
598
+ * Creates common request builder params.
599
+ */
600
+ private createBuilderParams;
601
+ /**
602
+ * Resolves the full URL path by prepending baseURL if needed.
603
+ */
604
+ private resolveSchemaPath;
605
+ /**
606
+ * Creates a GET request.
607
+ *
608
+ * When a URL is provided and matches a schema, the response type is automatically inferred.
609
+ *
610
+ * @param url Optional URL for the request. Can also be set via `.url()`.
611
+ *
612
+ * @example
613
+ * ```ts
614
+ * // With typed schema - response type is inferred
615
+ * const result = await api.get('/users').execute()
616
+ * // result.data is typed based on schema
617
+ *
618
+ * // Without schema or URL set later
619
+ * const result = await api.get().url('/users').execute()
620
+ * ```
621
+ */
622
+ get<TPath extends string>(url?: TPath): IgniterCallerTypedRequestBuilder<InferResponse<TSchemas, TPath, 'GET'>>;
623
+ /**
624
+ * Creates a POST request.
625
+ *
626
+ * When a URL is provided and matches a schema, the response type is automatically inferred.
627
+ *
628
+ * @param url Optional URL for the request. Can also be set via `.url()`.
629
+ *
630
+ * @example
631
+ * ```ts
632
+ * const result = await api.post('/users').body({ name: 'John' }).execute()
633
+ * ```
634
+ */
635
+ post<TPath extends string>(url?: TPath): IgniterCallerTypedRequestBuilder<InferResponse<TSchemas, TPath, 'POST'>>;
636
+ /**
637
+ * Creates a PUT request.
638
+ *
639
+ * When a URL is provided and matches a schema, the response type is automatically inferred.
640
+ *
641
+ * @param url Optional URL for the request. Can also be set via `.url()`.
642
+ *
643
+ * @example
644
+ * ```ts
645
+ * const result = await api.put('/users/1').body({ name: 'Jane' }).execute()
646
+ * ```
647
+ */
648
+ put<TPath extends string>(url?: TPath): IgniterCallerTypedRequestBuilder<InferResponse<TSchemas, TPath, 'PUT'>>;
649
+ /**
650
+ * Creates a PATCH request.
651
+ *
652
+ * When a URL is provided and matches a schema, the response type is automatically inferred.
653
+ *
654
+ * @param url Optional URL for the request. Can also be set via `.url()`.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * const result = await api.patch('/users/1').body({ name: 'Jane' }).execute()
659
+ * ```
660
+ */
661
+ patch<TPath extends string>(url?: TPath): IgniterCallerTypedRequestBuilder<InferResponse<TSchemas, TPath, 'PATCH'>>;
662
+ /**
663
+ * Creates a DELETE request.
664
+ *
665
+ * When a URL is provided and matches a schema, the response type is automatically inferred.
666
+ *
667
+ * @param url Optional URL for the request. Can also be set via `.url()`.
668
+ *
669
+ * @example
670
+ * ```ts
671
+ * const result = await api.delete('/users/1').execute()
672
+ * ```
673
+ */
674
+ delete<TPath extends string>(url?: TPath): IgniterCallerTypedRequestBuilder<InferResponse<TSchemas, TPath, 'DELETE'>>;
675
+ /**
676
+ * Creates a HEAD request.
677
+ *
678
+ * When a URL is provided and matches a schema, the response type is automatically inferred.
679
+ *
680
+ * @param url Optional URL for the request. Can also be set via `.url()`.
681
+ */
682
+ head<TPath extends string>(url?: TPath): IgniterCallerTypedRequestBuilder<InferResponse<TSchemas, TPath, 'HEAD'>>;
683
+ /**
684
+ * Executes a request directly with all options in one object (axios-style).
685
+ *
686
+ * This is a convenience method for making requests without using the builder pattern.
687
+ * Useful for dynamic requests where options are constructed programmatically.
688
+ *
689
+ * @example
690
+ * ```ts
691
+ * const result = await api.request({
692
+ * method: 'POST',
693
+ * url: '/users',
694
+ * body: { name: 'John' },
695
+ * headers: { 'X-Custom': 'value' },
696
+ * timeout: 5000,
697
+ * })
698
+ *
699
+ * // With caching
700
+ * const result = await api.request({
701
+ * method: 'GET',
702
+ * url: '/users',
703
+ * staleTime: 30000,
704
+ * })
705
+ *
706
+ * // With retry
707
+ * const result = await api.request({
708
+ * method: 'GET',
709
+ * url: '/health',
710
+ * retry: { maxAttempts: 3, backoff: 'exponential' },
711
+ * })
712
+ * ```
713
+ */
714
+ request<T = unknown>(options: IgniterCallerDirectRequestOptions): Promise<IgniterCallerApiResponse<T>>;
429
715
  /**
430
716
  * Executes multiple requests in parallel and returns results as an array.
431
717
  *
@@ -471,7 +757,7 @@ declare class IgniterCaller {
471
757
  * @example
472
758
  * ```ts
473
759
  * // After creating a user
474
- * await api.post().url('/users').body(newUser).execute()
760
+ * await api.post('/users').body(newUser).execute()
475
761
  * await IgniterCaller.invalidate('/users') // Clear users list cache
476
762
  * ```
477
763
  */
@@ -735,4 +1021,4 @@ declare class IgniterCallerUrlUtils {
735
1021
  }): string;
736
1022
  }
737
1023
 
738
- export { type ExtractPathParams, IgniterCaller, type IgniterCallerApiResponse, type IgniterCallerBaseRequestOptions, IgniterCallerBodyUtils, IgniterCallerBuilder, type IgniterCallerBuilderFactory, type IgniterCallerBuilderState, IgniterCallerCacheUtils, type IgniterCallerEndpointSchema, IgniterCallerError, type IgniterCallerErrorCode, type IgniterCallerErrorPayload, type IgniterCallerEventCallback, IgniterCallerEvents, type IgniterCallerFileResponse, type IgniterCallerHttpMethod, IgniterCallerMock, type IgniterCallerOperation, IgniterCallerRequestBuilder, type IgniterCallerRequestInterceptor, type IgniterCallerRequestOptions, type IgniterCallerResponseInterceptor, type IgniterCallerRetryOptions, type IgniterCallerSchemaMap, type IgniterCallerSchemaMethod, IgniterCallerSchemaUtils, type IgniterCallerSchemaValidationOptions, type IgniterCallerStoreAdapter, type IgniterCallerStoreOptions, type IgniterCallerUrlPattern, IgniterCallerUrlUtils, type InferAllResponseTypes, type InferRequestType, type InferResponseType };
1024
+ export { type ExtractPathParams, IgniterCaller, type IgniterCallerApiResponse, type IgniterCallerBaseRequestOptions, IgniterCallerBodyUtils, IgniterCallerBuilder, type IgniterCallerBuilderFactory, type IgniterCallerBuilderState, IgniterCallerCacheUtils, type IgniterCallerDirectRequestOptions, type IgniterCallerEndpointSchema, IgniterCallerError, type IgniterCallerErrorCode, type IgniterCallerErrorPayload, type IgniterCallerEventCallback, IgniterCallerEvents, type IgniterCallerFileResponse, type IgniterCallerHttpMethod, type IgniterCallerMethodRequestBuilder, IgniterCallerMock, type IgniterCallerOperation, IgniterCallerRequestBuilder, type IgniterCallerRequestBuilderParams, type IgniterCallerRequestInterceptor, type IgniterCallerRequestOptions, type IgniterCallerResponseContentType, type IgniterCallerResponseInterceptor, type IgniterCallerResponseMarker, type IgniterCallerRetryOptions, type IgniterCallerSchemaMap, type IgniterCallerSchemaMethod, IgniterCallerSchemaUtils, type IgniterCallerSchemaValidationOptions, type IgniterCallerStoreAdapter, type IgniterCallerStoreOptions, type IgniterCallerTypedRequestBuilder, type IgniterCallerUrlPattern, IgniterCallerUrlUtils, type IgniterCallerValidatableContentType, type InferAllResponseTypes, type InferRequestType, type InferResponseType, type InferSuccessResponseType, type ReplaceCallerSchema, type SchemaMapEndpoint, type SchemaMapMethods, type SchemaMapPaths, type SchemaMapRequestType, type SchemaMapResponseType };