@foundatiofx/fetchclient 0.47.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 (106) hide show
  1. package/esm/mod.js +5 -0
  2. package/esm/package.json +3 -0
  3. package/esm/src/Counter.js +36 -0
  4. package/esm/src/DefaultHelpers.js +132 -0
  5. package/esm/src/FetchClient.js +543 -0
  6. package/esm/src/FetchClientCache.js +88 -0
  7. package/esm/src/FetchClientContext.js +1 -0
  8. package/esm/src/FetchClientMiddleware.js +1 -0
  9. package/esm/src/FetchClientOptions.js +1 -0
  10. package/esm/src/FetchClientProvider.js +200 -0
  11. package/esm/src/FetchClientResponse.js +1 -0
  12. package/esm/src/LinkHeader.js +70 -0
  13. package/esm/src/ObjectEvent.js +15 -0
  14. package/esm/src/ProblemDetails.js +47 -0
  15. package/esm/src/RateLimitMiddleware.js +115 -0
  16. package/esm/src/RateLimiter.js +347 -0
  17. package/esm/src/RequestOptions.js +1 -0
  18. package/license +20 -0
  19. package/package.json +50 -0
  20. package/readme.md +303 -0
  21. package/script/mod.js +27 -0
  22. package/script/package.json +3 -0
  23. package/script/src/Counter.js +40 -0
  24. package/script/src/DefaultHelpers.js +149 -0
  25. package/script/src/FetchClient.js +547 -0
  26. package/script/src/FetchClientCache.js +92 -0
  27. package/script/src/FetchClientContext.js +2 -0
  28. package/script/src/FetchClientMiddleware.js +2 -0
  29. package/script/src/FetchClientOptions.js +2 -0
  30. package/script/src/FetchClientProvider.js +204 -0
  31. package/script/src/FetchClientResponse.js +2 -0
  32. package/script/src/LinkHeader.js +72 -0
  33. package/script/src/ObjectEvent.js +19 -0
  34. package/script/src/ProblemDetails.js +51 -0
  35. package/script/src/RateLimitMiddleware.js +120 -0
  36. package/script/src/RateLimiter.js +356 -0
  37. package/script/src/RequestOptions.js +2 -0
  38. package/types/_dnt.test_shims.d.ts.map +1 -0
  39. package/types/deps/jsr.io/@std/assert/1.0.14/almost_equals.d.ts.map +1 -0
  40. package/types/deps/jsr.io/@std/assert/1.0.14/array_includes.d.ts.map +1 -0
  41. package/types/deps/jsr.io/@std/assert/1.0.14/assert.d.ts.map +1 -0
  42. package/types/deps/jsr.io/@std/assert/1.0.14/assertion_error.d.ts.map +1 -0
  43. package/types/deps/jsr.io/@std/assert/1.0.14/equal.d.ts.map +1 -0
  44. package/types/deps/jsr.io/@std/assert/1.0.14/equals.d.ts.map +1 -0
  45. package/types/deps/jsr.io/@std/assert/1.0.14/exists.d.ts.map +1 -0
  46. package/types/deps/jsr.io/@std/assert/1.0.14/fail.d.ts.map +1 -0
  47. package/types/deps/jsr.io/@std/assert/1.0.14/false.d.ts.map +1 -0
  48. package/types/deps/jsr.io/@std/assert/1.0.14/greater.d.ts.map +1 -0
  49. package/types/deps/jsr.io/@std/assert/1.0.14/greater_or_equal.d.ts.map +1 -0
  50. package/types/deps/jsr.io/@std/assert/1.0.14/instance_of.d.ts.map +1 -0
  51. package/types/deps/jsr.io/@std/assert/1.0.14/is_error.d.ts.map +1 -0
  52. package/types/deps/jsr.io/@std/assert/1.0.14/less.d.ts.map +1 -0
  53. package/types/deps/jsr.io/@std/assert/1.0.14/less_or_equal.d.ts.map +1 -0
  54. package/types/deps/jsr.io/@std/assert/1.0.14/match.d.ts.map +1 -0
  55. package/types/deps/jsr.io/@std/assert/1.0.14/mod.d.ts.map +1 -0
  56. package/types/deps/jsr.io/@std/assert/1.0.14/not_equals.d.ts.map +1 -0
  57. package/types/deps/jsr.io/@std/assert/1.0.14/not_instance_of.d.ts.map +1 -0
  58. package/types/deps/jsr.io/@std/assert/1.0.14/not_match.d.ts.map +1 -0
  59. package/types/deps/jsr.io/@std/assert/1.0.14/not_strict_equals.d.ts.map +1 -0
  60. package/types/deps/jsr.io/@std/assert/1.0.14/object_match.d.ts.map +1 -0
  61. package/types/deps/jsr.io/@std/assert/1.0.14/rejects.d.ts.map +1 -0
  62. package/types/deps/jsr.io/@std/assert/1.0.14/strict_equals.d.ts.map +1 -0
  63. package/types/deps/jsr.io/@std/assert/1.0.14/string_includes.d.ts.map +1 -0
  64. package/types/deps/jsr.io/@std/assert/1.0.14/throws.d.ts.map +1 -0
  65. package/types/deps/jsr.io/@std/assert/1.0.14/unimplemented.d.ts.map +1 -0
  66. package/types/deps/jsr.io/@std/assert/1.0.14/unreachable.d.ts.map +1 -0
  67. package/types/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  68. package/types/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  69. package/types/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  70. package/types/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  71. package/types/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  72. package/types/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  73. package/types/mod.d.ts +11 -0
  74. package/types/mod.d.ts.map +1 -0
  75. package/types/src/Counter.d.ts +27 -0
  76. package/types/src/Counter.d.ts.map +1 -0
  77. package/types/src/DefaultHelpers.d.ts +106 -0
  78. package/types/src/DefaultHelpers.d.ts.map +1 -0
  79. package/types/src/FetchClient.d.ts +156 -0
  80. package/types/src/FetchClient.d.ts.map +1 -0
  81. package/types/src/FetchClient.test.d.ts.map +1 -0
  82. package/types/src/FetchClientCache.d.ts +62 -0
  83. package/types/src/FetchClientCache.d.ts.map +1 -0
  84. package/types/src/FetchClientContext.d.ts +8 -0
  85. package/types/src/FetchClientContext.d.ts.map +1 -0
  86. package/types/src/FetchClientMiddleware.d.ts +9 -0
  87. package/types/src/FetchClientMiddleware.d.ts.map +1 -0
  88. package/types/src/FetchClientOptions.d.ts +53 -0
  89. package/types/src/FetchClientOptions.d.ts.map +1 -0
  90. package/types/src/FetchClientProvider.d.ts +109 -0
  91. package/types/src/FetchClientProvider.d.ts.map +1 -0
  92. package/types/src/FetchClientResponse.d.ts +29 -0
  93. package/types/src/FetchClientResponse.d.ts.map +1 -0
  94. package/types/src/LinkHeader.d.ts +15 -0
  95. package/types/src/LinkHeader.d.ts.map +1 -0
  96. package/types/src/ObjectEvent.d.ts +20 -0
  97. package/types/src/ObjectEvent.d.ts.map +1 -0
  98. package/types/src/ProblemDetails.d.ts +43 -0
  99. package/types/src/ProblemDetails.d.ts.map +1 -0
  100. package/types/src/RateLimit.test.d.ts.map +1 -0
  101. package/types/src/RateLimitMiddleware.d.ts +50 -0
  102. package/types/src/RateLimitMiddleware.d.ts.map +1 -0
  103. package/types/src/RateLimiter.d.ts +179 -0
  104. package/types/src/RateLimiter.d.ts.map +1 -0
  105. package/types/src/RequestOptions.d.ts +64 -0
  106. package/types/src/RequestOptions.d.ts.map +1 -0
@@ -0,0 +1,106 @@
1
+ import type { FetchClient } from "./FetchClient.js";
2
+ import type { FetchClientMiddleware } from "./FetchClientMiddleware.js";
3
+ import type { FetchClientOptions } from "./FetchClientOptions.js";
4
+ import { type FetchClientProvider } from "./FetchClientProvider.js";
5
+ import type { FetchClientResponse } from "./FetchClientResponse.js";
6
+ import type { ProblemDetails } from "./ProblemDetails.js";
7
+ import type { RateLimitMiddlewareOptions } from "./RateLimitMiddleware.js";
8
+ import type { GetRequestOptions, RequestOptions } from "./RequestOptions.js";
9
+ /**
10
+ * Gets a FetchClient instance from the current provider.
11
+ * @returns The FetchClient instance.
12
+ */
13
+ export declare function useFetchClient(options?: FetchClientOptions): FetchClient;
14
+ /**
15
+ * Sends a GET request to the specified URL using the default client and provider and returns the response as JSON.
16
+ * @param url - The URL to send the GET request to.
17
+ * @param options - Optional request options.
18
+ * @returns A promise that resolves to the response as JSON.
19
+ */
20
+ export declare function getJSON<T>(url: string, options?: GetRequestOptions): Promise<FetchClientResponse<T>>;
21
+ /**
22
+ * Sends a POST request with JSON payload using the default client and provider to the specified URL.
23
+ *
24
+ * @template T - The type of the response data.
25
+ * @param {string} url - The URL to send the request to.
26
+ * @param {object | string | FormData} [body] - The JSON payload or form data to send with the request.
27
+ * @param {RequestOptions} [options] - Additional options for the request.
28
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
29
+ */
30
+ export declare function postJSON<T>(url: string, body?: object | string | FormData, options?: RequestOptions): Promise<FetchClientResponse<T>>;
31
+ /**
32
+ * Sends a PUT request with JSON payload using the default client and provider to the specified URL.
33
+ *
34
+ * @template T - The type of the response data.
35
+ * @param {string} url - The URL to send the request to.
36
+ * @param {object | string} [body] - The JSON payload to send with the request.
37
+ * @param {RequestOptions} [options] - Additional options for the request.
38
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
39
+ */
40
+ export declare function putJSON<T>(url: string, body?: object | string, options?: RequestOptions): Promise<FetchClientResponse<T>>;
41
+ /**
42
+ * Sends a PATCH request with JSON payload using the default client and provider to the specified URL.
43
+ *
44
+ * @template T - The type of the response data.
45
+ * @param {string} url - The URL to send the request to.
46
+ * @param {object | string} [body] - The JSON payload to send with the request.
47
+ * @param {RequestOptions} [options] - Additional options for the request.
48
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
49
+ */
50
+ export declare function patchJSON<T>(url: string, body?: object | string, options?: RequestOptions): Promise<FetchClientResponse<T>>;
51
+ /**
52
+ * Sends a DELETE request with JSON payload using the default client and provider to the specified URL.
53
+ *
54
+ * @template T - The type of the response data.
55
+ * @param {string} url - The URL to send the request to.
56
+ * @param {RequestOptions} [options] - Additional options for the request.
57
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
58
+ */
59
+ export declare function deleteJSON<T>(url: string, options?: RequestOptions): Promise<FetchClientResponse<T>>;
60
+ /**
61
+ * Gets the current FetchClientProvider.
62
+ * @returns The current FetchClientProvider.
63
+ */
64
+ export declare function getCurrentProvider(): FetchClientProvider;
65
+ /**
66
+ * Sets the function that retrieves the current FetchClientProvider using whatever scoping mechanism is available.
67
+ * @param getProviderFunc - The function that retrieves the current FetchClientProvider.
68
+ * @returns void
69
+ */
70
+ export declare function setCurrentProviderFunc(getProviderFunc: () => FetchClientProvider | null): void;
71
+ /**
72
+ * Sets the base URL for any FetchClient instances created by the current provider.
73
+ * @param baseUrl - The base URL to use for requests.
74
+ */
75
+ export declare function setBaseUrl(baseUrl: string): void;
76
+ /**
77
+ * Sets the access token function for any FetchClient instances created by the current provider.
78
+ * @param accessTokenFunc - The function that retrieves the access token.
79
+ */
80
+ export declare function setAccessTokenFunc(accessTokenFunc: () => string | null): void;
81
+ /**
82
+ * Sets the model validator function for any FetchClient instances created by the current provider.
83
+ * @param validate - The function that validates the model.
84
+ */
85
+ export declare function setModelValidator(validate: (model: object | null) => Promise<ProblemDetails | null>): void;
86
+ /**
87
+ * Adds a middleware to any FetchClient instances created by the current provider.
88
+ * @param middleware - The middleware function to be added.
89
+ */
90
+ export declare function useMiddleware(middleware: FetchClientMiddleware): void;
91
+ /**
92
+ * Sets the default request options for any FetchClient instances created by the current provider.
93
+ * @param options - The options to set as the default request options.
94
+ */
95
+ export declare function setRequestOptions(options: RequestOptions): void;
96
+ /**
97
+ * Enables rate limiting for any FetchClient instances created by the current provider.
98
+ * @param options - The rate limiting configuration options.
99
+ */
100
+ export declare function useRateLimit(options: RateLimitMiddlewareOptions): void;
101
+ /**
102
+ * Enables per-domain rate limiting for any FetchClient instances created by the current provider.
103
+ * @param options - The rate limiting configuration options.
104
+ */
105
+ export declare function usePerDomainRateLimit(options: Omit<RateLimitMiddlewareOptions, "getGroupFunc">): void;
106
+ //# sourceMappingURL=DefaultHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultHelpers.d.ts","sourceRoot":"","sources":["../../src/src/DefaultHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AA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CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAEjC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,CAMxD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,MAAM,mBAAmB,GAAG,IAAI,QAGlD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,MAAM,GAAG,IAAI,QAGrC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,QAGnE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,qBAAqB,QAE9D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,QAExD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,0BAA0B,QAGpC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,IAAI,CAAC,0BAA0B,EAAE,cAAc,CAAC,QAG1D"}
@@ -0,0 +1,156 @@
1
+ import type { GetRequestOptions, RequestOptions } from "./RequestOptions.js";
2
+ import type { FetchClientResponse } from "./FetchClientResponse.js";
3
+ import type { FetchClientMiddleware } from "./FetchClientMiddleware.js";
4
+ import type { FetchClientCache } from "./FetchClientCache.js";
5
+ import { FetchClientProvider } from "./FetchClientProvider.js";
6
+ import type { FetchClientOptions } from "./FetchClientOptions.js";
7
+ import { type IObjectEvent } from "./ObjectEvent.js";
8
+ type Fetch = typeof globalThis.fetch;
9
+ /**
10
+ * Represents a client for making HTTP requests using the Fetch API.
11
+ */
12
+ export declare class FetchClient {
13
+ #private;
14
+ /**
15
+ * Represents a FetchClient that handles HTTP requests using the Fetch API.
16
+ * @param options - The options to use for the FetchClient.
17
+ */
18
+ constructor(optionsOrProvider?: FetchClientOptions | FetchClientProvider);
19
+ /**
20
+ * Gets the provider used by this FetchClient instance. The provider contains shared options that can be used by multiple FetchClient instances.
21
+ */
22
+ get provider(): FetchClientProvider;
23
+ /**
24
+ * Gets the options used by this FetchClient instance.
25
+ */
26
+ get options(): FetchClientOptions;
27
+ /**
28
+ * Gets the cache used for storing HTTP responses.
29
+ */
30
+ get cache(): FetchClientCache;
31
+ /**
32
+ * Gets the fetch implementation used for making HTTP requests.
33
+ */
34
+ get fetch(): Fetch | undefined;
35
+ /**
36
+ * Gets the number of inflight requests for this FetchClient instance.
37
+ */
38
+ get requestCount(): number;
39
+ /**
40
+ * Gets a value indicating whether the client is currently loading.
41
+ * @returns {boolean} A boolean value indicating whether the client is loading.
42
+ */
43
+ get isLoading(): boolean;
44
+ /**
45
+ * Gets an event that is triggered when the loading state changes.
46
+ */
47
+ get loading(): IObjectEvent<boolean>;
48
+ /**
49
+ * Adds one or more middleware functions to the FetchClient's middleware pipeline.
50
+ * Middleware functions are executed in the order they are added.
51
+ *
52
+ * @param mw - The middleware functions to add.
53
+ */
54
+ use(...mw: FetchClientMiddleware[]): FetchClient;
55
+ /**
56
+ * Sends a GET request to the specified URL.
57
+ *
58
+ * @param url - The URL to send the GET request to.
59
+ * @param options - The optional request options.
60
+ * @returns A promise that resolves to the response of the GET request.
61
+ */
62
+ get(url: string, options?: GetRequestOptions): Promise<FetchClientResponse<unknown>>;
63
+ /**
64
+ * Sends a GET request to the specified URL and returns the response as JSON.
65
+ * @param url - The URL to send the GET request to.
66
+ * @param options - Optional request options.
67
+ * @returns A promise that resolves to the response as JSON.
68
+ */
69
+ getJSON<T>(url: string, options?: GetRequestOptions): Promise<FetchClientResponse<T>>;
70
+ /**
71
+ * Sends a POST request to the specified URL.
72
+ *
73
+ * @param url - The URL to send the request to.
74
+ * @param body - The request body, can be an object, a string, or FormData.
75
+ * @param options - Additional options for the request.
76
+ * @returns A promise that resolves to a FetchClientResponse object.
77
+ */
78
+ post(url: string, body?: object | string | FormData, options?: RequestOptions): Promise<FetchClientResponse<unknown>>;
79
+ /**
80
+ * Sends a POST request with JSON payload to the specified URL.
81
+ *
82
+ * @template T - The type of the response data.
83
+ * @param {string} url - The URL to send the request to.
84
+ * @param {object | string | FormData} [body] - The JSON payload or form data to send with the request.
85
+ * @param {RequestOptions} [options] - Additional options for the request.
86
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
87
+ */
88
+ postJSON<T>(url: string, body?: object | string | FormData, options?: RequestOptions): Promise<FetchClientResponse<T>>;
89
+ /**
90
+ * Sends a PUT request to the specified URL with the given body and options.
91
+ * @param url - The URL to send the request to.
92
+ * @param body - The request body, can be an object, a string, or FormData.
93
+ * @param options - The request options.
94
+ * @returns A promise that resolves to a FetchClientResponse object.
95
+ */
96
+ put(url: string, body?: object | string | FormData, options?: RequestOptions): Promise<FetchClientResponse<unknown>>;
97
+ /**
98
+ * Sends a PUT request with JSON payload to the specified URL.
99
+ *
100
+ * @template T - The type of the response data.
101
+ * @param {string} url - The URL to send the request to.
102
+ * @param {object | string} [body] - The JSON payload to send with the request.
103
+ * @param {RequestOptions} [options] - Additional options for the request.
104
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
105
+ */
106
+ putJSON<T>(url: string, body?: object | string, options?: RequestOptions): Promise<FetchClientResponse<T>>;
107
+ /**
108
+ * Sends a PATCH request to the specified URL with the provided body and options.
109
+ * @param url - The URL to send the PATCH request to.
110
+ * @param body - The body of the request. It can be an object, a string, or FormData.
111
+ * @param options - The options for the request.
112
+ * @returns A Promise that resolves to the response of the PATCH request.
113
+ */
114
+ patch(url: string, body?: object | string | FormData, options?: RequestOptions): Promise<Response>;
115
+ /**
116
+ * Sends a PATCH request with JSON payload to the specified URL.
117
+ *
118
+ * @template T - The type of the response data.
119
+ * @param {string} url - The URL to send the request to.
120
+ * @param {object | string} [body] - The JSON payload to send with the request.
121
+ * @param {RequestOptions} [options] - Additional options for the request.
122
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
123
+ */
124
+ patchJSON<T>(url: string, body?: object | string, options?: RequestOptions): Promise<FetchClientResponse<T>>;
125
+ /**
126
+ * Sends a DELETE request to the specified URL.
127
+ *
128
+ * @param url - The URL to send the DELETE request to.
129
+ * @param options - The options for the request.
130
+ * @returns A promise that resolves to a `FetchClientResponse` object.
131
+ */
132
+ delete(url: string, options?: RequestOptions): Promise<FetchClientResponse<unknown>>;
133
+ /**
134
+ * Sends a DELETE request with JSON payload to the specified URL.
135
+ *
136
+ * @template T - The type of the response data.
137
+ * @param {string} url - The URL to send the request to.
138
+ * @param {RequestOptions} [options] - Additional options for the request.
139
+ * @returns {Promise<FetchClientResponse<T>>} - A promise that resolves to the response data.
140
+ */
141
+ deleteJSON<T>(url: string, options?: RequestOptions): Promise<FetchClientResponse<T>>;
142
+ private validate;
143
+ private fetchInternal;
144
+ private invokeMiddleware;
145
+ private mergeAbortSignals;
146
+ private getJSONResponse;
147
+ private reviveJsonValue;
148
+ private tryParseDate;
149
+ private buildRequestInit;
150
+ private buildJsonRequestOptions;
151
+ private problemToResponse;
152
+ private buildUrl;
153
+ private validateResponse;
154
+ }
155
+ export {};
156
+ //# sourceMappingURL=FetchClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClient.d.ts","sourceRoot":"","sources":["../../src/src/FetchClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EAAE,kBA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A2C7B,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,iBAAiB;IAiCzB,OAAO,CAAC,QAAQ;IAuDhB,OAAO,CAAC,gBAAgB;CAiCzB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClient.test.d.ts","sourceRoot":"","sources":["../../src/src/FetchClient.test.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,CAAC,EAAmB,MAAM,KAAK,CAAC;AAMzC,eAAO,MAAM,UAAU;;;;;;iBAMrB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Represents a cache key used in the FetchClientCache.
3
+ */
4
+ export type CacheKey = string[] | string;
5
+ /**
6
+ * Represents an entry in the FetchClientCache.
7
+ */
8
+ type CacheEntry = {
9
+ key: CacheKey;
10
+ lastAccess: Date;
11
+ expires: Date;
12
+ response: Response;
13
+ };
14
+ /**
15
+ * Represents a cache for storing responses from the FetchClient.
16
+ */
17
+ export declare class FetchClientCache {
18
+ private cache;
19
+ /**
20
+ * Sets a response in the cache with the specified key.
21
+ * @param key - The cache key.
22
+ * @param response - The response to be cached.
23
+ * @param cacheDuration - The duration for which the response should be cached (in milliseconds).
24
+ */
25
+ set(key: CacheKey, response: Response, cacheDuration?: number): void;
26
+ /**
27
+ * Retrieves a response from the cache with the specified key.
28
+ * @param key - The cache key.
29
+ * @returns The cached response, or null if the response is not found or has expired.
30
+ */
31
+ get(key: CacheKey): Response | null;
32
+ /**
33
+ * Deletes a response from the cache with the specified key.
34
+ * @param key - The cache key.
35
+ * @returns True if the response was successfully deleted, false otherwise.
36
+ */
37
+ delete(key: CacheKey): boolean;
38
+ /**
39
+ * Deletes all responses from the cache that have keys beginning with the specified key.
40
+ * @param prefix - The cache key prefix.
41
+ * @returns The number of responses that were deleted.
42
+ */
43
+ deleteAll(prefix: CacheKey): number;
44
+ /**
45
+ * Checks if a response exists in the cache with the specified key.
46
+ * @param key - The cache key.
47
+ * @returns True if the response exists in the cache, false otherwise.
48
+ */
49
+ has(key: CacheKey): boolean;
50
+ /**
51
+ * Returns an iterator for the cache entries.
52
+ * @returns An iterator for the cache entries.
53
+ */
54
+ values(): IterableIterator<CacheEntry>;
55
+ /**
56
+ * Clears all entries from the cache.
57
+ */
58
+ clear(): void;
59
+ private getHash;
60
+ }
61
+ export {};
62
+ //# sourceMappingURL=FetchClientCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClientCache.d.ts","sourceRoot":"","sources":["../../src/src/FetchClientCache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;AAEzC;;GAEG;AACH,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,QAAQ,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAiC;IAE9C;;;;;OAKG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI;IAS3E;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI;IAgB1C;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO;IAIrC;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM;IAc1C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO;IAIlC;;;OAGG;IACI,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC;IAI7C;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,OAAO;CAOhB"}
@@ -0,0 +1,8 @@
1
+ import type { FetchClientResponse } from "./FetchClientResponse.js";
2
+ import type { RequestOptions } from "./RequestOptions.js";
3
+ export type FetchClientContext = {
4
+ options: RequestOptions;
5
+ request: Request;
6
+ response: FetchClientResponse<unknown> | null;
7
+ } & Record<string, unknown>;
8
+ //# sourceMappingURL=FetchClientContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClientContext.d.ts","sourceRoot":"","sources":["../../src/src/FetchClientContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAC/C,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { FetchClientContext } from "./FetchClientContext.js";
2
+ /**
3
+ * Represents a middleware function for the FetchClient.
4
+ * @param context - The context object containing information about the request.
5
+ * @param next - The next function to be called in the middleware chain.
6
+ * @returns A Promise that resolves when the middleware has completed its operation.
7
+ */
8
+ export type FetchClientMiddleware = (context: FetchClientContext, next: () => Promise<void>) => Promise<void>;
9
+ //# sourceMappingURL=FetchClientMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClientMiddleware.d.ts","sourceRoot":"","sources":["../../src/src/FetchClientMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACtB,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { Counter } from "./Counter.js";
2
+ import type { FetchClientCache } from "./FetchClientCache.js";
3
+ import type { FetchClientMiddleware } from "./FetchClientMiddleware.js";
4
+ import type { FetchClientProvider } from "./FetchClientProvider.js";
5
+ import type { ProblemDetails } from "./ProblemDetails.js";
6
+ import type { RequestOptions } from "./RequestOptions.js";
7
+ type Fetch = typeof globalThis.fetch;
8
+ /**
9
+ * Fetch client options to use for making HTTP requests.
10
+ */
11
+ export type FetchClientOptions = {
12
+ /**
13
+ * The fetch client provider to get shared options from. Any options specified in this options class will override the provider options.
14
+ */
15
+ provider?: FetchClientProvider;
16
+ /**
17
+ * The default request options to use for requests. If specified, these options will be merged with the
18
+ * options from the FetchClientProvider and the options provided in each request.
19
+ */
20
+ defaultRequestOptions?: RequestOptions;
21
+ /**
22
+ * The cache to use for storing HTTP responses.
23
+ */
24
+ cache?: FetchClientCache;
25
+ /**
26
+ * The fetch implementation to use for making HTTP requests.
27
+ * If not provided, the global fetch function will be used.
28
+ */
29
+ fetch?: Fetch;
30
+ /**
31
+ * An array of middleware functions to be applied to the request.
32
+ */
33
+ middleware?: FetchClientMiddleware[];
34
+ /**
35
+ * The base URL for making HTTP requests.
36
+ */
37
+ baseUrl?: string;
38
+ /**
39
+ * A function that validates the model before making the request.
40
+ * Returns a Promise that resolves to a ProblemDetails object if validation fails, or null if validation succeeds.
41
+ */
42
+ modelValidator?: (model: object | null) => Promise<ProblemDetails | null>;
43
+ /**
44
+ * A function that returns the access token to use for making requests.
45
+ */
46
+ accessTokenFunc?: () => string | null;
47
+ /**
48
+ * Counter for tracking the number of inflight requests at the provider level
49
+ */
50
+ providerCounter?: Counter;
51
+ } & Record<string, unknown>;
52
+ export {};
53
+ //# sourceMappingURL=FetchClientOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClientOptions.d.ts","sourceRoot":"","sources":["../../src/src/FetchClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,KAAK,KAAK,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAErC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAE/B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,cAAc,CAAC;IAEvC;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAEzB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAErC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAE1E;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAEtC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { FetchClient } from "./FetchClient.js";
2
+ import { Counter } from "./Counter.js";
3
+ import type { FetchClientMiddleware } from "./FetchClientMiddleware.js";
4
+ import type { ProblemDetails } from "./ProblemDetails.js";
5
+ import { FetchClientCache } from "./FetchClientCache.js";
6
+ import type { FetchClientOptions } from "./FetchClientOptions.js";
7
+ import { type IObjectEvent } from "./ObjectEvent.js";
8
+ import { type RateLimitMiddlewareOptions } from "./RateLimitMiddleware.js";
9
+ import { type RateLimiter } from "./RateLimiter.js";
10
+ type Fetch = typeof globalThis.fetch;
11
+ /**
12
+ * Represents a provider for creating instances of the FetchClient class with shared default options and cache.
13
+ */
14
+ export declare class FetchClientProvider {
15
+ #private;
16
+ /**
17
+ * Creates a new instance of FetchClientProvider.
18
+ * @param fetch - The fetch function to use. If not provided, the global fetch function will be used.
19
+ */
20
+ constructor(fetch?: Fetch);
21
+ /**
22
+ * Gets the fetch function used for making requests.
23
+ */
24
+ get fetch(): Fetch | undefined;
25
+ /**
26
+ * Sets the fetch function used for making requests.
27
+ */
28
+ set fetch(value: Fetch | undefined);
29
+ /**
30
+ * Gets a value indicating whether there are ongoing requests.
31
+ */
32
+ get isLoading(): boolean;
33
+ /**
34
+ * Gets an event that is triggered when the loading state changes.
35
+ */
36
+ get loading(): IObjectEvent<boolean>;
37
+ /**
38
+ * Gets the number of ongoing requests.
39
+ */
40
+ get requestCount(): number;
41
+ /**
42
+ * Gets the counter used for tracking ongoing requests.
43
+ */
44
+ get counter(): Counter;
45
+ /**
46
+ * Gets the options used for FetchClient instances.
47
+ */
48
+ get options(): FetchClientOptions;
49
+ /**
50
+ * Sets the options used for FetchClient instances.
51
+ */
52
+ set options(value: FetchClientOptions);
53
+ /**
54
+ * Gets the cache used for storing HTTP responses.
55
+ */
56
+ get cache(): FetchClientCache;
57
+ /**
58
+ * Creates a new instance of FetchClient using the current provider.
59
+ * @param options - The options to use for the FetchClient instance.
60
+ * @returns A new instance of FetchClient.
61
+ */
62
+ getFetchClient(options?: FetchClientOptions): FetchClient;
63
+ /**
64
+ * Applies the specified options by merging with the current options.
65
+ */
66
+ applyOptions(options: FetchClientOptions): void;
67
+ /**
68
+ * Sets the function used for retrieving the access token.
69
+ * @param accessTokenFunc - The function that retrieves the access token.
70
+ */
71
+ setAccessTokenFunc(accessTokenFunc: () => string | null): void;
72
+ /**
73
+ * Sets the default model validator function for all FetchClient instances created by this provider.
74
+ * @param validate - The function that validates the model.
75
+ */
76
+ setModelValidator(validate: (model: object | null) => Promise<ProblemDetails | null>): void;
77
+ /**
78
+ * Sets the default base URL for all FetchClient instances created by this provider.
79
+ * @param url - The URL to set as the default base URL.
80
+ */
81
+ setBaseUrl(url: string): void;
82
+ /**
83
+ * Adds a middleware to all FetchClient instances created by this provider.
84
+ * @param middleware - The middleware function to be added.
85
+ */
86
+ useMiddleware(middleware: FetchClientMiddleware): void;
87
+ /**
88
+ * Enables rate limiting for all FetchClient instances created by this provider.
89
+ * @param options - The rate limiting configuration options.
90
+ */
91
+ useRateLimit(options: RateLimitMiddlewareOptions): void;
92
+ /**
93
+ * Enables rate limiting for all FetchClient instances created by this provider.
94
+ * @param options - The rate limiting configuration options.
95
+ */
96
+ usePerDomainRateLimit(options: Omit<RateLimitMiddlewareOptions, "getGroupFunc">): void;
97
+ /**
98
+ * Gets the rate limiter instance used for rate limiting.
99
+ * @returns The rate limiter instance, or undefined if rate limiting is not enabled.
100
+ */
101
+ get rateLimiter(): RateLimiter | undefined;
102
+ /**
103
+ * Removes the rate limiting middleware from all FetchClient instances created by this provider.
104
+ */
105
+ removeRateLimit(): void;
106
+ }
107
+ export declare const defaultInstance: FetchClientProvider;
108
+ export {};
109
+ //# sourceMappingURL=FetchClientProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClientProvider.d.ts","sourceRoot":"","sources":["../../src/src/FetchClientProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,C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AAc,GAAG,IAAI,CAAC;IAQpE;;;OAGG;IACI,UAAU,CAAC,GAAG,EAAE,MAAM;IAO7B;;;OAGG;IACI,aAAa,CAAC,UAAU,EAAE,qBAAqB;IAUtD;;;OAGG;IACI,YAAY,CAAC,OAAO,EAAE,0BAA0B;IAKvD;;;OAGG;IACI,qBAAqB,CAC1B,OAAO,EAAE,IAAI,CAAC,0BAA0B,EAAE,cAAc,CAAC;IAS3D;;;OAGG;IACH,IAAW,WAAW,IAAI,WAAW,GAAG,SAAS,CAEhD;IAED;;OAEG;IACI,eAAe;CAMvB;AAGD,eAAO,MAAM,eAAe,EAAE,mBAA8B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { Link, Links } from "./LinkHeader.js";
2
+ import type { ProblemDetails } from "./ProblemDetails.js";
3
+ /**
4
+ * Represents a response from the FetchClient.
5
+ * @template T - The type of the response data.
6
+ */
7
+ export type FetchClientResponse<T> = Response & {
8
+ /**
9
+ * The response data.
10
+ */
11
+ data: T | null;
12
+ /**
13
+ * Details about any problem that occurred during the request.
14
+ */
15
+ problem: ProblemDetails;
16
+ /**
17
+ * Additional metadata associated with the response.
18
+ */
19
+ meta: Record<string, unknown> & {
20
+ /**
21
+ * Links associated with the response.
22
+ */
23
+ links: Links & {
24
+ next?: Link;
25
+ previous?: Link;
26
+ };
27
+ };
28
+ };
29
+ //# sourceMappingURL=FetchClientResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchClientResponse.d.ts","sourceRoot":"","sources":["../../src/src/FetchClientResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,QAAQ,GAAG;IAC9C;;OAEG;IACH,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,cAAc,CAAC;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAC9B;;WAEG;QACH,KAAK,EAAE,KAAK,GAAG;YAAE,IAAI,CAAC,EAAE,IAAI,CAAC;YAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;SAAE,CAAC;KACjD,CAAC;CACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ declare function parseLinkHeader(linkHeader: string | null | undefined, options?: Options): Links | null;
2
+ export interface Link {
3
+ url: string;
4
+ rel: string;
5
+ [queryParam: string]: string;
6
+ }
7
+ export interface Links {
8
+ [rel: string]: Link;
9
+ }
10
+ export interface Options {
11
+ maxHeaderLength?: number;
12
+ throwOnMaxHeaderLengthExceeded?: boolean;
13
+ }
14
+ export { parseLinkHeader };
15
+ //# sourceMappingURL=LinkHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkHeader.d.ts","sourceRoot":"","sources":["../../src/src/LinkHeader.ts"],"names":[],"mappings":"AA4EA,iBAAS,eAAe,CACtB,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,OAAO,CAAC,EAAE,OAAO,GAChB,KAAK,GAAG,IAAI,CAOd;AAED,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ export interface IObjectEvent<T> {
2
+ on(handler: {
3
+ (data?: T): void;
4
+ }): void;
5
+ off(handler: {
6
+ (data?: T): void;
7
+ }): void;
8
+ }
9
+ export declare class ObjectEvent<T> implements IObjectEvent<T> {
10
+ private handlers;
11
+ on(handler: {
12
+ (data?: T): void;
13
+ }): void;
14
+ off(handler: {
15
+ (data?: T): void;
16
+ }): void;
17
+ trigger(data?: T): void;
18
+ expose(): IObjectEvent<T>;
19
+ }
20
+ //# sourceMappingURL=ObjectEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectEvent.d.ts","sourceRoot":"","sources":["../../src/src/ObjectEvent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,EAAE,CAAC,OAAO,EAAE;QAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACxC,GAAG,CAAC,OAAO,EAAE;QAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAC1C;AAED,qBAAa,WAAW,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,QAAQ,CAA8B;IAEvC,EAAE,CAAC,OAAO,EAAE;QAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI;IAIvC,GAAG,CAAC,OAAO,EAAE;QAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI;IAIxC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IAIhB,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC;CAGjC"}