@unito/integration-sdk 1.1.3 → 1.1.4
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/src/index.cjs
CHANGED
|
@@ -1209,7 +1209,7 @@ class Provider {
|
|
|
1209
1209
|
});
|
|
1210
1210
|
}
|
|
1211
1211
|
async postForm(endpoint, form, options) {
|
|
1212
|
-
const { url: providerUrl, headers: providerHeaders } = this.prepareRequest(options);
|
|
1212
|
+
const { url: providerUrl, headers: providerHeaders } = await this.prepareRequest(options);
|
|
1213
1213
|
const absoluteUrl = this.generateAbsoluteUrl(providerUrl, endpoint, options.queryParams);
|
|
1214
1214
|
const headers = { ...form.getHeaders(), ...providerHeaders, ...options.additionnalheaders };
|
|
1215
1215
|
const reqOptions = {
|
|
@@ -1335,7 +1335,7 @@ class Provider {
|
|
|
1335
1335
|
return absoluteUrl;
|
|
1336
1336
|
}
|
|
1337
1337
|
async fetchWrapper(endpoint, body, options) {
|
|
1338
|
-
const { url: providerUrl, headers: providerHeaders } = this.prepareRequest(options);
|
|
1338
|
+
const { url: providerUrl, headers: providerHeaders } = await this.prepareRequest(options);
|
|
1339
1339
|
const absoluteUrl = this.generateAbsoluteUrl(providerUrl, endpoint, options.queryParams);
|
|
1340
1340
|
const headers = { ...options.defaultHeaders, ...providerHeaders, ...options.additionnalheaders };
|
|
1341
1341
|
let stringifiedBody = null;
|
|
@@ -54,6 +54,10 @@ export type Response<T> = {
|
|
|
54
54
|
status: number;
|
|
55
55
|
headers: Headers;
|
|
56
56
|
};
|
|
57
|
+
export type PreparedRequest = {
|
|
58
|
+
url: string;
|
|
59
|
+
headers: Record<string, string>;
|
|
60
|
+
};
|
|
57
61
|
/**
|
|
58
62
|
* The Provider class is a wrapper around the fetch function to call a provider's HTTP API.
|
|
59
63
|
*
|
|
@@ -82,10 +86,7 @@ export declare class Provider {
|
|
|
82
86
|
protected prepareRequest: (options: {
|
|
83
87
|
credentials: Credentials;
|
|
84
88
|
logger: Logger;
|
|
85
|
-
}) =>
|
|
86
|
-
url: string;
|
|
87
|
-
headers: Record<string, string>;
|
|
88
|
-
};
|
|
89
|
+
}) => PreparedRequest | Promise<PreparedRequest>;
|
|
89
90
|
/**
|
|
90
91
|
* (Optional) Custom error handler to handle specific errors returned by the provider.
|
|
91
92
|
*
|
|
@@ -110,7 +110,7 @@ export class Provider {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
async postForm(endpoint, form, options) {
|
|
113
|
-
const { url: providerUrl, headers: providerHeaders } = this.prepareRequest(options);
|
|
113
|
+
const { url: providerUrl, headers: providerHeaders } = await this.prepareRequest(options);
|
|
114
114
|
const absoluteUrl = this.generateAbsoluteUrl(providerUrl, endpoint, options.queryParams);
|
|
115
115
|
const headers = { ...form.getHeaders(), ...providerHeaders, ...options.additionnalheaders };
|
|
116
116
|
const reqOptions = {
|
|
@@ -236,7 +236,7 @@ export class Provider {
|
|
|
236
236
|
return absoluteUrl;
|
|
237
237
|
}
|
|
238
238
|
async fetchWrapper(endpoint, body, options) {
|
|
239
|
-
const { url: providerUrl, headers: providerHeaders } = this.prepareRequest(options);
|
|
239
|
+
const { url: providerUrl, headers: providerHeaders } = await this.prepareRequest(options);
|
|
240
240
|
const absoluteUrl = this.generateAbsoluteUrl(providerUrl, endpoint, options.queryParams);
|
|
241
241
|
const headers = { ...options.defaultHeaders, ...providerHeaders, ...options.additionnalheaders };
|
|
242
242
|
let stringifiedBody = null;
|
package/package.json
CHANGED
|
@@ -57,6 +57,11 @@ export type Response<T> = {
|
|
|
57
57
|
headers: Headers;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
export type PreparedRequest = {
|
|
61
|
+
url: string;
|
|
62
|
+
headers: Record<string, string>;
|
|
63
|
+
};
|
|
64
|
+
|
|
60
65
|
/**
|
|
61
66
|
* The Provider class is a wrapper around the fetch function to call a provider's HTTP API.
|
|
62
67
|
*
|
|
@@ -82,10 +87,10 @@ export class Provider {
|
|
|
82
87
|
* This is applied at large to all requests made to the provider. If you need to add specific headers to a single request,
|
|
83
88
|
* pass it through the RequestOptions object when calling the Provider's methods.
|
|
84
89
|
*/
|
|
85
|
-
protected prepareRequest: (options: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
90
|
+
protected prepareRequest: (options: {
|
|
91
|
+
credentials: Credentials;
|
|
92
|
+
logger: Logger;
|
|
93
|
+
}) => PreparedRequest | Promise<PreparedRequest>;
|
|
89
94
|
/**
|
|
90
95
|
* (Optional) Custom error handler to handle specific errors returned by the provider.
|
|
91
96
|
*
|
|
@@ -181,7 +186,7 @@ export class Provider {
|
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
public async postForm<T>(endpoint: string, form: FormData, options: RequestOptions): Promise<Response<T>> {
|
|
184
|
-
const { url: providerUrl, headers: providerHeaders } = this.prepareRequest(options);
|
|
189
|
+
const { url: providerUrl, headers: providerHeaders } = await this.prepareRequest(options);
|
|
185
190
|
const absoluteUrl = this.generateAbsoluteUrl(providerUrl, endpoint, options.queryParams);
|
|
186
191
|
const headers = { ...form.getHeaders(), ...providerHeaders, ...options.additionnalheaders };
|
|
187
192
|
|
|
@@ -325,7 +330,7 @@ export class Provider {
|
|
|
325
330
|
body: Record<string, unknown> | null,
|
|
326
331
|
options: RequestOptions & { defaultHeaders: { 'Content-Type'?: string; Accept?: string }; method: string },
|
|
327
332
|
): Promise<Response<T>> {
|
|
328
|
-
const { url: providerUrl, headers: providerHeaders } = this.prepareRequest(options);
|
|
333
|
+
const { url: providerUrl, headers: providerHeaders } = await this.prepareRequest(options);
|
|
329
334
|
const absoluteUrl = this.generateAbsoluteUrl(providerUrl, endpoint, options.queryParams);
|
|
330
335
|
const headers = { ...options.defaultHeaders, ...providerHeaders, ...options.additionnalheaders };
|
|
331
336
|
|