@injectivelabs/utils 1.20.61 → 1.20.63

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.
@@ -0,0 +1,490 @@
1
+ const require_chunk = require('./chunk-CbDLau6x.cjs');
2
+ const require_defineProperty = require('./defineProperty-DAtJs5JQ.cjs');
3
+ let axios = require("axios");
4
+ axios = require_chunk.__toESM(axios);
5
+ let http_status_codes = require("http-status-codes");
6
+ let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
7
+
8
+ //#region src/classes/RetryRequestConfig.ts
9
+ const RETRY_REQUEST_CONFIG_BRAND = Symbol("@injectivelabs/utils/RetryRequestConfig");
10
+ /**
11
+ * @internal
12
+ */
13
+ const createRetryRequestConfig = (signal) => {
14
+ const config = { signal };
15
+ Object.defineProperty(config, RETRY_REQUEST_CONFIG_BRAND, {
16
+ configurable: false,
17
+ enumerable: true,
18
+ value: Object.freeze({ signal }),
19
+ writable: false
20
+ });
21
+ return config;
22
+ };
23
+ /**
24
+ * @internal
25
+ *
26
+ * Returns undefined for ordinary request configs. A branded config with no
27
+ * signal intentionally means "do not compose the current config signal".
28
+ */
29
+ const getRetryRequestCancellation = (config) => {
30
+ if (!config || typeof config !== "object") return;
31
+ return config[RETRY_REQUEST_CONFIG_BRAND];
32
+ };
33
+ /**
34
+ * @internal
35
+ *
36
+ * The brand is only meaningful to HttpClient. Remove it from the final Axios
37
+ * config so it is never forwarded to the transport.
38
+ */
39
+ const clearRetryRequestConfigBrand = (config) => {
40
+ if (!config || typeof config !== "object") return;
41
+ Reflect.deleteProperty(config, RETRY_REQUEST_CONFIG_BRAND);
42
+ };
43
+
44
+ //#endregion
45
+ //#region src/abort.ts
46
+ const ABORT_ERROR_MESSAGE = "The operation was aborted";
47
+ /**
48
+ * Local cancellation error shared by every cancellable SDK operation.
49
+ *
50
+ * The message is deliberately stable and generic so that callers can rely on
51
+ * `name`/`code`/`reason` instead of parsing messages, and so that a user
52
+ * provided reason can never be mistaken for an existing string-based error
53
+ * (for example a "not found" response).
54
+ */
55
+ var AbortError = class extends Error {
56
+ constructor(reason) {
57
+ super(ABORT_ERROR_MESSAGE);
58
+ require_defineProperty._defineProperty(this, "name", "AbortError");
59
+ require_defineProperty._defineProperty(this, "code", "ERR_CANCELED");
60
+ require_defineProperty._defineProperty(this, "reason", void 0);
61
+ this.reason = reason;
62
+ if (reason !== void 0) Object.defineProperty(this, "cause", {
63
+ configurable: true,
64
+ enumerable: false,
65
+ value: reason,
66
+ writable: true
67
+ });
68
+ }
69
+ };
70
+ /**
71
+ * Creates an abort error, preserving the signal's abort reason when present.
72
+ */
73
+ const createAbortError = (signal) => {
74
+ return new AbortError((signal === null || signal === void 0 ? void 0 : signal.aborted) ? signal.reason : void 0);
75
+ };
76
+ /**
77
+ * Identifies local/SDK/documented abort-shaped errors.
78
+ *
79
+ * This intentionally does not treat gRPC status codes (`CANCELLED`,
80
+ * `ABORTED`, `DEADLINE_EXCEEDED`) or arbitrary server errors as cancellation.
81
+ */
82
+ const isAbortError = (error) => {
83
+ if (error instanceof AbortError) return true;
84
+ if (!error || typeof error !== "object") return false;
85
+ const candidate = error;
86
+ if (candidate.name === "AbortError") return true;
87
+ if (candidate.code === "ERR_CANCELED") return true;
88
+ return false;
89
+ };
90
+ /**
91
+ * Throws an {@link AbortError} when the signal has already been aborted.
92
+ */
93
+ const throwIfAborted = (signal) => {
94
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) throw createAbortError(signal);
95
+ };
96
+ function combineAbortSignals(signals) {
97
+ const uniqueSignals = Array.from(new Set(signals.filter((signal) => Boolean(signal))));
98
+ const noop = () => {};
99
+ if (uniqueSignals.length === 0) return {
100
+ signal: void 0,
101
+ dispose: noop
102
+ };
103
+ if (uniqueSignals.length === 1) return {
104
+ signal: uniqueSignals[0],
105
+ dispose: noop
106
+ };
107
+ const controller = new AbortController();
108
+ const alreadyAborted = uniqueSignals.find((signal) => signal.aborted);
109
+ if (alreadyAborted) {
110
+ controller.abort(alreadyAborted.reason);
111
+ return {
112
+ signal: controller.signal,
113
+ dispose: noop
114
+ };
115
+ }
116
+ let disposed = false;
117
+ const listeners = /* @__PURE__ */ new Map();
118
+ const dispose = () => {
119
+ if (disposed) return;
120
+ disposed = true;
121
+ listeners.forEach((listener, signal) => {
122
+ signal.removeEventListener("abort", listener);
123
+ });
124
+ listeners.clear();
125
+ };
126
+ uniqueSignals.forEach((sourceSignal) => {
127
+ const listener = () => {
128
+ if (controller.signal.aborted) return;
129
+ dispose();
130
+ controller.abort(sourceSignal.reason);
131
+ };
132
+ listeners.set(sourceSignal, listener);
133
+ sourceSignal.addEventListener("abort", listener, { once: true });
134
+ });
135
+ const abortedDuringSetup = uniqueSignals.find((signal) => signal.aborted);
136
+ if (abortedDuringSetup && !controller.signal.aborted) {
137
+ dispose();
138
+ controller.abort(abortedDuringSetup.reason);
139
+ }
140
+ return {
141
+ signal: controller.signal,
142
+ dispose
143
+ };
144
+ }
145
+ /**
146
+ * Sleeps for `ms`, rejecting with {@link AbortError} as soon as the signal is
147
+ * aborted. Timers and listeners are always cleaned up.
148
+ */
149
+ const abortableSleep = (ms, signal) => {
150
+ if (!signal) return new Promise((resolve) => {
151
+ setTimeout(resolve, ms);
152
+ });
153
+ if (signal.aborted) return Promise.reject(createAbortError(signal));
154
+ return new Promise((resolve, reject) => {
155
+ let timer;
156
+ let settled = false;
157
+ const onAbort = () => {
158
+ if (settled) return;
159
+ settled = true;
160
+ if (timer !== void 0) {
161
+ clearTimeout(timer);
162
+ timer = void 0;
163
+ }
164
+ signal.removeEventListener("abort", onAbort);
165
+ reject(createAbortError(signal));
166
+ };
167
+ signal.addEventListener("abort", onAbort, { once: true });
168
+ if (signal.aborted) {
169
+ onAbort();
170
+ return;
171
+ }
172
+ timer = setTimeout(() => {
173
+ if (settled) return;
174
+ settled = true;
175
+ signal.removeEventListener("abort", onAbort);
176
+ resolve();
177
+ }, ms);
178
+ });
179
+ };
180
+ /**
181
+ * Waits for `promise`, but rejects promptly when `signal` is aborted.
182
+ *
183
+ * The eventual promise settlement is always observed, so a late rejection can
184
+ * never become unhandled. Late success/rejection cannot override an abort, and
185
+ * listeners are removed on every settlement path.
186
+ */
187
+ const raceWithAbort = (promise, signal) => {
188
+ const observedPromise = Promise.resolve(promise);
189
+ if (!signal) return observedPromise;
190
+ if (signal.aborted) {
191
+ observedPromise.then(() => {}, () => {});
192
+ return Promise.reject(createAbortError(signal));
193
+ }
194
+ return new Promise((resolve, reject) => {
195
+ let settled = false;
196
+ const onAbort = () => {
197
+ if (settled) return;
198
+ settled = true;
199
+ signal.removeEventListener("abort", onAbort);
200
+ reject(createAbortError(signal));
201
+ };
202
+ signal.addEventListener("abort", onAbort, { once: true });
203
+ observedPromise.then((value) => {
204
+ if (settled) return;
205
+ settled = true;
206
+ signal.removeEventListener("abort", onAbort);
207
+ resolve(value);
208
+ }, (error) => {
209
+ if (settled) return;
210
+ settled = true;
211
+ signal.removeEventListener("abort", onAbort);
212
+ reject(error);
213
+ });
214
+ if (signal.aborted) onAbort();
215
+ });
216
+ };
217
+
218
+ //#endregion
219
+ //#region src/classes/HttpClient.ts
220
+ const getAbortReason = (error) => {
221
+ if (!error || typeof error !== "object") return;
222
+ if ("reason" in error) return error.reason;
223
+ if ("cause" in error) return error.cause;
224
+ };
225
+ var HttpClient = class {
226
+ constructor(endpoint, options = { headers: { "Content-Type": "application/json" } }) {
227
+ require_defineProperty._defineProperty(this, "client", void 0);
228
+ require_defineProperty._defineProperty(this, "abortSignal", void 0);
229
+ require_defineProperty._defineProperty(this, "config", {});
230
+ const { signal, ...axiosOptions } = options || {};
231
+ this.client = axios.default.create({
232
+ baseURL: endpoint,
233
+ timeout: 15e3,
234
+ ...axiosOptions
235
+ });
236
+ this.abortSignal = signal;
237
+ this.config = {};
238
+ }
239
+ setConfig(config) {
240
+ this.config = config || {};
241
+ return this;
242
+ }
243
+ /**
244
+ * @internal
245
+ *
246
+ * Current constructor/config cancellation constraint, optionally combined
247
+ * with an operation-level signal. Callers must invoke `dispose` after the
248
+ * operation settles.
249
+ */
250
+ getAbortSignal(signal, config = this.config) {
251
+ return combineAbortSignals([
252
+ this.abortSignal,
253
+ config === null || config === void 0 ? void 0 : config.signal,
254
+ signal
255
+ ]);
256
+ }
257
+ prepareRequest(baseConfig = {}, perCallConfig = {}) {
258
+ const base = baseConfig || {};
259
+ const perCall = perCallConfig || {};
260
+ const retryCancellation = getRetryRequestCancellation(perCall);
261
+ const config = {
262
+ ...base,
263
+ ...perCall
264
+ };
265
+ if (base.headers && perCall.headers) config.headers = {
266
+ ...base.headers,
267
+ ...perCall.headers
268
+ };
269
+ const { signal, dispose } = combineAbortSignals([
270
+ this.abortSignal,
271
+ retryCancellation ? retryCancellation.signal : base.signal,
272
+ perCall.signal
273
+ ]);
274
+ if (signal) config.signal = signal;
275
+ else delete config.signal;
276
+ clearRetryRequestConfigBrand(config);
277
+ return {
278
+ config,
279
+ dispose
280
+ };
281
+ }
282
+ async executeRequest(request, baseConfig, perCallConfig) {
283
+ const { config, dispose } = this.prepareRequest(baseConfig, perCallConfig);
284
+ const signal = config.signal;
285
+ try {
286
+ throwIfAborted(signal);
287
+ return await raceWithAbort(request(config), signal);
288
+ } catch (error) {
289
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) throw createAbortError(signal);
290
+ if (isAbortError(error)) throw error instanceof AbortError ? error : new AbortError(getAbortReason(error));
291
+ throw error;
292
+ } finally {
293
+ dispose();
294
+ }
295
+ }
296
+ get(endpoint, params = {}, config = {}) {
297
+ return this.executeRequest((requestConfig) => this.client.get(endpoint, requestConfig), {
298
+ params,
299
+ ...this.config
300
+ }, config);
301
+ }
302
+ post(endpoint, data = {}, config = {}) {
303
+ return this.executeRequest((requestConfig) => this.client.post(endpoint, data, requestConfig), this.config, config);
304
+ }
305
+ put(endpoint, data = {}, config = {}) {
306
+ return this.executeRequest((requestConfig) => this.client.put(endpoint, data, requestConfig), this.config, config);
307
+ }
308
+ delete(endpoint, params = {}, config = {}) {
309
+ return this.executeRequest((requestConfig) => this.client.delete(endpoint, requestConfig), {
310
+ params,
311
+ ...this.config
312
+ }, config);
313
+ }
314
+ };
315
+
316
+ //#endregion
317
+ //#region src/classes/HttpRestClient.ts
318
+ const getErrorMessage = (error, endpoint) => {
319
+ if (!error.response) return `The request to ${endpoint} has failed.`;
320
+ return error.response.data ? error.response.data.message || error.response.data.statusMessage || error.response.data : error.response.statusText;
321
+ };
322
+ const getLocalAbortError = (error, signal) => {
323
+ var _error$config;
324
+ const axiosSignal = axios.default.isAxiosError(error) ? (_error$config = error.config) === null || _error$config === void 0 ? void 0 : _error$config.signal : void 0;
325
+ if (isAbortError(error)) {
326
+ if (error instanceof AbortError) return error;
327
+ return new AbortError((signal === null || signal === void 0 ? void 0 : signal.aborted) ? signal.reason : (axiosSignal === null || axiosSignal === void 0 ? void 0 : axiosSignal.aborted) ? axiosSignal.reason : error.reason);
328
+ }
329
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) return createAbortError(signal);
330
+ if (axiosSignal === null || axiosSignal === void 0 ? void 0 : axiosSignal.aborted) return createAbortError(axiosSignal);
331
+ };
332
+ /**
333
+ * @hidden
334
+ */
335
+ var HttpRestClient = class {
336
+ constructor(endpoint, options = {}) {
337
+ require_defineProperty._defineProperty(this, "client", void 0);
338
+ require_defineProperty._defineProperty(this, "endpoint", void 0);
339
+ this.client = new HttpClient(endpoint, options);
340
+ this.endpoint = endpoint;
341
+ }
342
+ setConfig(config) {
343
+ this.client.setConfig(config);
344
+ return this;
345
+ }
346
+ async get(endpoint, params = {}, config = {}) {
347
+ const requestConfig = config || {};
348
+ try {
349
+ return await this.client.get(endpoint, params, requestConfig);
350
+ } catch (e) {
351
+ const error = e;
352
+ const abortError = getLocalAbortError(error, requestConfig.signal);
353
+ if (abortError) throw abortError;
354
+ if (axios.default.isAxiosError(error)) {
355
+ if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
356
+ code: http_status_codes.StatusCodes.REQUEST_TOO_LONG,
357
+ context: endpoint
358
+ });
359
+ const message = getErrorMessage(error, endpoint);
360
+ throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), {
361
+ context: endpoint,
362
+ code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST
363
+ });
364
+ }
365
+ throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
366
+ code: __injectivelabs_exceptions.UnspecifiedErrorCode,
367
+ context: endpoint
368
+ });
369
+ }
370
+ }
371
+ async retry(httpCall, retriesOrOptions, legacyDelay, options) {
372
+ var _retriesOrOptions$del;
373
+ const withRequestConfig = typeof retriesOrOptions === "object" && retriesOrOptions !== null;
374
+ const { retries = 3, delay = 1e3, signal: requestSignal } = !withRequestConfig ? {
375
+ ...options,
376
+ retries: retriesOrOptions,
377
+ delay: legacyDelay
378
+ } : {
379
+ ...options,
380
+ ...retriesOrOptions,
381
+ delay: (_retriesOrOptions$del = retriesOrOptions.delay) !== null && _retriesOrOptions$del !== void 0 ? _retriesOrOptions$del : legacyDelay
382
+ };
383
+ const { signal, dispose } = this.client.getAbortSignal(requestSignal);
384
+ const retryHttpCall = async (attempt = 1) => {
385
+ throwIfAborted(signal);
386
+ try {
387
+ const responsePromise = withRequestConfig ? httpCall(createRetryRequestConfig(signal)) : httpCall();
388
+ return await raceWithAbort(Promise.resolve(responsePromise), signal);
389
+ } catch (e) {
390
+ const abortError = getLocalAbortError(e, signal);
391
+ if (abortError) throw abortError;
392
+ throwIfAborted(signal);
393
+ if (e instanceof __injectivelabs_exceptions.HttpRequestException) {
394
+ if (e.code === http_status_codes.StatusCodes.REQUEST_TOO_LONG) throw e;
395
+ }
396
+ if (attempt >= retries) throw e;
397
+ await abortableSleep(delay * attempt, signal);
398
+ return retryHttpCall(attempt + 1);
399
+ }
400
+ };
401
+ try {
402
+ return await retryHttpCall();
403
+ } finally {
404
+ dispose();
405
+ }
406
+ }
407
+ async post(endpoint, params = {}, config = {}) {
408
+ const requestConfig = config || {};
409
+ try {
410
+ return await this.client.post(endpoint, params, requestConfig);
411
+ } catch (e) {
412
+ const error = e;
413
+ const abortError = getLocalAbortError(error, requestConfig.signal);
414
+ if (abortError) throw abortError;
415
+ if (axios.default.isAxiosError(error)) {
416
+ if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
417
+ code: http_status_codes.StatusCodes.REQUEST_TOO_LONG,
418
+ method: __injectivelabs_exceptions.HttpRequestMethod.Post
419
+ });
420
+ const message = getErrorMessage(error, endpoint);
421
+ throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), {
422
+ code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST,
423
+ context: endpoint,
424
+ contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post
425
+ });
426
+ }
427
+ throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
428
+ code: __injectivelabs_exceptions.UnspecifiedErrorCode,
429
+ context: endpoint,
430
+ contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post
431
+ });
432
+ }
433
+ }
434
+ };
435
+
436
+ //#endregion
437
+ Object.defineProperty(exports, 'AbortError', {
438
+ enumerable: true,
439
+ get: function () {
440
+ return AbortError;
441
+ }
442
+ });
443
+ Object.defineProperty(exports, 'HttpClient', {
444
+ enumerable: true,
445
+ get: function () {
446
+ return HttpClient;
447
+ }
448
+ });
449
+ Object.defineProperty(exports, 'HttpRestClient', {
450
+ enumerable: true,
451
+ get: function () {
452
+ return HttpRestClient;
453
+ }
454
+ });
455
+ Object.defineProperty(exports, 'abortableSleep', {
456
+ enumerable: true,
457
+ get: function () {
458
+ return abortableSleep;
459
+ }
460
+ });
461
+ Object.defineProperty(exports, 'combineAbortSignals', {
462
+ enumerable: true,
463
+ get: function () {
464
+ return combineAbortSignals;
465
+ }
466
+ });
467
+ Object.defineProperty(exports, 'createAbortError', {
468
+ enumerable: true,
469
+ get: function () {
470
+ return createAbortError;
471
+ }
472
+ });
473
+ Object.defineProperty(exports, 'isAbortError', {
474
+ enumerable: true,
475
+ get: function () {
476
+ return isAbortError;
477
+ }
478
+ });
479
+ Object.defineProperty(exports, 'raceWithAbort', {
480
+ enumerable: true,
481
+ get: function () {
482
+ return raceWithAbort;
483
+ }
484
+ });
485
+ Object.defineProperty(exports, 'throwIfAborted', {
486
+ enumerable: true,
487
+ get: function () {
488
+ return throwIfAborted;
489
+ }
490
+ });
@@ -0,0 +1,163 @@
1
+ import { AxiosRequestConfig } from "axios";
2
+
3
+ //#region src/classes/HttpClient.d.ts
4
+ declare class HttpClient {
5
+ private readonly client;
6
+ private readonly abortSignal?;
7
+ private config;
8
+ constructor(endpoint: string, options?: Record<string, any>);
9
+ setConfig(config: AxiosRequestConfig): HttpClient;
10
+ /**
11
+ * @internal
12
+ *
13
+ * Current constructor/config cancellation constraint, optionally combined
14
+ * with an operation-level signal. Callers must invoke `dispose` after the
15
+ * operation settles.
16
+ */
17
+ getAbortSignal(signal?: AbortSignal, config?: AxiosRequestConfig): {
18
+ signal: AbortSignal | undefined;
19
+ dispose(): void;
20
+ };
21
+ private prepareRequest;
22
+ private executeRequest;
23
+ get<T, P>(endpoint: string, params?: T, config?: AxiosRequestConfig): Promise<P>;
24
+ post<T, P>(endpoint: string, data?: T, config?: AxiosRequestConfig): Promise<P>;
25
+ put<T, P>(endpoint: string, data?: T, config?: AxiosRequestConfig): Promise<P>;
26
+ delete<T, P>(endpoint: string, params?: T, config?: AxiosRequestConfig): Promise<P>;
27
+ }
28
+ //#endregion
29
+ //#region src/abort.d.ts
30
+ /**
31
+ * Optional cancellation options accepted by read/query APIs.
32
+ */
33
+ interface RequestOptions {
34
+ signal?: AbortSignal;
35
+ }
36
+ /**
37
+ * Local cancellation error shared by every cancellable SDK operation.
38
+ *
39
+ * The message is deliberately stable and generic so that callers can rely on
40
+ * `name`/`code`/`reason` instead of parsing messages, and so that a user
41
+ * provided reason can never be mistaken for an existing string-based error
42
+ * (for example a "not found" response).
43
+ */
44
+ declare class AbortError extends Error {
45
+ readonly name: 'AbortError';
46
+ readonly code: 'ERR_CANCELED';
47
+ readonly reason: unknown;
48
+ constructor(reason?: unknown);
49
+ }
50
+ /**
51
+ * Creates an abort error, preserving the signal's abort reason when present.
52
+ */
53
+ declare const createAbortError: (signal?: AbortSignal) => AbortError;
54
+ /** Structural because native and cross-package cancellation may be plain objects. */
55
+ type AbortErrorLike = ({
56
+ name: 'AbortError';
57
+ code?: unknown;
58
+ } | {
59
+ name?: unknown;
60
+ code: 'ERR_CANCELED';
61
+ }) & {
62
+ reason?: unknown;
63
+ };
64
+ /**
65
+ * Identifies local/SDK/documented abort-shaped errors.
66
+ *
67
+ * This intentionally does not treat gRPC status codes (`CANCELLED`,
68
+ * `ABORTED`, `DEADLINE_EXCEEDED`) or arbitrary server errors as cancellation.
69
+ */
70
+ declare const isAbortError: (error: unknown) => error is AbortErrorLike;
71
+ /**
72
+ * Throws an {@link AbortError} when the signal has already been aborted.
73
+ */
74
+ declare const throwIfAborted: (signal?: AbortSignal) => void;
75
+ /**
76
+ * Combines several optional signals into a single cancellation constraint.
77
+ *
78
+ * - No signal: returns `undefined` without creating controllers/listeners.
79
+ * - One signal: returns it as-is without adding listeners.
80
+ * - Multiple signals: returns a new controller signal that aborts with the
81
+ * first observed reason. Caller controllers are never aborted.
82
+ *
83
+ * `dispose` removes all listeners and is safe to call more than once.
84
+ */
85
+ declare function combineAbortSignals(signals: readonly [AbortSignal, ...(AbortSignal | undefined)[]] | readonly [...(AbortSignal | undefined)[], AbortSignal]): {
86
+ signal: AbortSignal;
87
+ dispose(): void;
88
+ };
89
+ declare function combineAbortSignals(signals: readonly (AbortSignal | undefined)[]): {
90
+ signal: AbortSignal | undefined;
91
+ dispose(): void;
92
+ };
93
+ /**
94
+ * Sleeps for `ms`, rejecting with {@link AbortError} as soon as the signal is
95
+ * aborted. Timers and listeners are always cleaned up.
96
+ */
97
+ declare const abortableSleep: (ms: number, signal?: AbortSignal) => Promise<void>;
98
+ /**
99
+ * Waits for `promise`, but rejects promptly when `signal` is aborted.
100
+ *
101
+ * The eventual promise settlement is always observed, so a late rejection can
102
+ * never become unhandled. Late success/rejection cannot override an abort, and
103
+ * listeners are removed on every settlement path.
104
+ */
105
+ declare const raceWithAbort: <T>(promise: PromiseLike<T>, signal?: AbortSignal) => Promise<T>;
106
+ //#endregion
107
+ //#region src/retry.d.ts
108
+ /** Options shared by HTTP and gRPC retry operations. */
109
+ interface RetryOptions extends RequestOptions {
110
+ /** Maximum number of attempts, including the initial call. Defaults to 3. */
111
+ retries?: number;
112
+ /** Base backoff delay in milliseconds, multiplied by the attempt. Defaults to 1000. */
113
+ delay?: number;
114
+ }
115
+ //#endregion
116
+ //#region src/classes/RetryRequestConfig.d.ts
117
+ declare const RETRY_REQUEST_CONFIG_BRAND: unique symbol;
118
+ /**
119
+ * Request config passed to callbacks in the options-object retry overload.
120
+ *
121
+ * It is a regular Axios request config that carries an internal cancellation
122
+ * scope. Forward it directly to HttpClient methods:
123
+ *
124
+ * ```ts
125
+ * client.retry(
126
+ * (requestConfig) =>
127
+ * client.get(endpoint, params, requestConfig),
128
+ * options ?? {},
129
+ * )
130
+ * ```
131
+ *
132
+ * The scoped signal pins cancellation for the whole retry operation. Later
133
+ * `setConfig` changes still apply to headers/auth/adapter/timeouts/params but
134
+ * cannot retarget the operation's cancellation.
135
+ */
136
+ interface RetryRequestConfig extends AxiosRequestConfig {
137
+ readonly [RETRY_REQUEST_CONFIG_BRAND]?: {
138
+ readonly signal?: AbortSignal;
139
+ };
140
+ }
141
+ //#endregion
142
+ //#region src/classes/HttpRestClient.d.ts
143
+ /**
144
+ * @hidden
145
+ */
146
+ declare class HttpRestClient {
147
+ protected client: HttpClient;
148
+ protected endpoint: string;
149
+ constructor(endpoint: string, options?: Record<string, any>);
150
+ setConfig(config: AxiosRequestConfig): HttpRestClient;
151
+ get<T>(endpoint: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<T>;
152
+ retry<TResponse>(httpCall: (requestConfig: RetryRequestConfig) => TResponse | PromiseLike<TResponse>, options: RetryOptions): Promise<TResponse>;
153
+ /** @deprecated Pass a RetryOptions object instead of positional retry settings. */
154
+ retry<TResponse>(httpCall: () => TResponse | PromiseLike<TResponse>, retries?: number, delay?: number, options?: RequestOptions): Promise<TResponse>;
155
+ /**
156
+ * @deprecated Retained for callers typed as Function by the legacy API.
157
+ * The options-object overload requires a typed request-config callback.
158
+ */
159
+ retry<TResponse>(httpCall: Function, retries?: number, delay?: number, options?: RequestOptions): Promise<TResponse>;
160
+ post<T>(endpoint: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<T>;
161
+ }
162
+ //#endregion
163
+ export { AbortErrorLike as a, combineAbortSignals as c, raceWithAbort as d, throwIfAborted as f, AbortError as i, createAbortError as l, RetryRequestConfig as n, RequestOptions as o, HttpClient as p, RetryOptions as r, abortableSleep as s, HttpRestClient as t, isAbortError as u };
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CbDLau6x.cjs');
2
- const require_defineProperty = require('./defineProperty-CImP5zIM.cjs');
2
+ const require_defineProperty = require('./defineProperty-DAtJs5JQ.cjs');
3
3
  let store2 = require("store2");
4
4
  store2 = require_chunk.__toESM(store2);
5
5
 
@@ -1,4 +1,4 @@
1
- const require_defineProperty = require('./defineProperty-CImP5zIM.cjs');
1
+ const require_defineProperty = require('./defineProperty-DAtJs5JQ.cjs');
2
2
 
3
3
  //#region src/enum.ts
4
4
  const StatusType = {
package/dist/cjs/http.cjs CHANGED
@@ -1,5 +1,5 @@
1
- require('./defineProperty-CImP5zIM.cjs');
2
- const require_HttpRestClient = require('./HttpRestClient-C761J3nA.cjs');
1
+ const require_HttpRestClient = require('./HttpRestClient-BIcHe0ig.cjs');
2
+ require('./defineProperty-DAtJs5JQ.cjs');
3
3
 
4
4
  exports.HttpClient = require_HttpRestClient.HttpClient;
5
5
  exports.HttpRestClient = require_HttpRestClient.HttpRestClient;
@@ -1,2 +1,2 @@
1
- import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-C0p7w6ht.cjs";
1
+ import { p as HttpClient, t as HttpRestClient } from "./HttpRestClient-CtRnRmrM.cjs";
2
2
  export { HttpClient, HttpRestClient };