mftsccs-node 0.0.80-dev → 0.0.81-dev
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.
|
@@ -55,51 +55,7 @@ export declare class HttpResponse {
|
|
|
55
55
|
*/
|
|
56
56
|
get ok(): boolean;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
* Make an HTTP request with automatic retry on 401 Unauthorized.
|
|
60
|
-
*
|
|
61
|
-
* If a 401 error occurs and OAuth credentials are available, this function
|
|
62
|
-
* will automatically refresh the token and retry the request once.
|
|
63
|
-
*
|
|
64
|
-
* @async
|
|
65
|
-
* @param {string} method - HTTP method (GET, POST, PUT, DELETE, etc.)
|
|
66
|
-
* @param {string} url - The URL to request
|
|
67
|
-
* @param {Record<string, string>} [headers] - Optional headers dict
|
|
68
|
-
* @param {any} [body] - Optional request body (JSON will be stringified)
|
|
69
|
-
* @param {number} [maxRetries=1] - Maximum number of retries on 401
|
|
70
|
-
* @returns {Promise<HttpResponse>} HttpResponse object with status, body, and headers
|
|
71
|
-
* @throws {TokenRefreshError} If token refresh fails
|
|
72
|
-
* @throws {Error} For other network errors
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const headers = { "Content-Type": "application/json" };
|
|
77
|
-
* const response = await requestWithRetry(
|
|
78
|
-
* "POST",
|
|
79
|
-
* url,
|
|
80
|
-
* headers,
|
|
81
|
-
* { id: 123 }
|
|
82
|
-
* );
|
|
83
|
-
* if (response.ok) {
|
|
84
|
-
* const data = await response.json();
|
|
85
|
-
* console.log(data);
|
|
86
|
-
* }
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* // Automatic token refresh on 401
|
|
92
|
-
* try {
|
|
93
|
-
* const response = await requestWithRetry("GET", url);
|
|
94
|
-
* // If receives 401, will automatically refresh token and retry
|
|
95
|
-
* } catch (error) {
|
|
96
|
-
* if (error instanceof TokenRefreshError) {
|
|
97
|
-
* console.error('Authentication failed:', error.message);
|
|
98
|
-
* }
|
|
99
|
-
* }
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
export declare function requestWithRetry(method: string, url: string, headers?: Record<string, string>, body?: any, maxRetries?: number): Promise<HttpResponse>;
|
|
58
|
+
export declare function requestWithRetry(method: string, url: string, headers?: Record<string, string>, body?: any, maxRetries?: number, timeoutMs?: number): Promise<HttpResponse>;
|
|
103
59
|
/**
|
|
104
60
|
* Fetch-compatible wrapper backed by requestWithRetry.
|
|
105
61
|
*
|