@squidcloud/client 1.0.181 → 1.0.182
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/cjs/index.js +8 -14
- package/dist/internal-common/src/public-types/api-call.public-context.d.ts +2 -2
- package/dist/typescript-client/src/api-client.d.ts +6 -6
- package/dist/typescript-client/src/rpc.manager.d.ts +3 -3
- package/dist/typescript-client/src/squid-http-client.d.ts +6 -6
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -50387,21 +50387,15 @@ class RpcError extends Error {
|
|
|
50387
50387
|
* Runs a post request to the given URL.
|
|
50388
50388
|
* @internal.
|
|
50389
50389
|
*/
|
|
50390
|
-
async function rawSquidHttpPost(
|
|
50390
|
+
async function rawSquidHttpPost(input) {
|
|
50391
50391
|
// Native fetch is used in json request mode or when the corresponding private Squid option is enabled.
|
|
50392
50392
|
// This option is enabled in console-local and console-dev modes both in Web & Backend.
|
|
50393
|
-
const isFetch = files.length === 0 || !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
|
|
50394
|
-
|
|
50395
|
-
if (isFetch) {
|
|
50396
|
-
response = await performFetchRequest(headers, files, filesFieldName, message, url, extractErrorMessage);
|
|
50397
|
-
}
|
|
50398
|
-
else {
|
|
50399
|
-
response = await performAxiosRequest(files, filesFieldName, message, url, headers, extractErrorMessage);
|
|
50400
|
-
}
|
|
50393
|
+
const isFetch = input.files.length === 0 || !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
|
|
50394
|
+
const response = await (isFetch ? performFetchRequest(input) : await performAxiosRequest(input));
|
|
50401
50395
|
response.body = tryDeserializing(response.body);
|
|
50402
50396
|
return response;
|
|
50403
50397
|
}
|
|
50404
|
-
async function performFetchRequest(headers, files, filesFieldName, body, url, extractErrorMessage) {
|
|
50398
|
+
async function performFetchRequest({ headers, files, filesFieldName, message: body, url, extractErrorMessage, }) {
|
|
50405
50399
|
const requestOptionHeaders = new Headers(headers);
|
|
50406
50400
|
const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
|
|
50407
50401
|
if (files.length) {
|
|
@@ -50431,7 +50425,7 @@ async function performFetchRequest(headers, files, filesFieldName, body, url, ex
|
|
|
50431
50425
|
}
|
|
50432
50426
|
let message;
|
|
50433
50427
|
try {
|
|
50434
|
-
message = typeof parsedBody === 'string' ? parsedBody : parsedBody['message'] || rawBody;
|
|
50428
|
+
message = typeof parsedBody === 'string' ? parsedBody : (parsedBody === null || parsedBody === void 0 ? void 0 : parsedBody['message']) || rawBody;
|
|
50435
50429
|
}
|
|
50436
50430
|
catch (_a) { }
|
|
50437
50431
|
if (!message)
|
|
@@ -50453,7 +50447,7 @@ function extractAxiosResponseHeaders(response) {
|
|
|
50453
50447
|
return acc;
|
|
50454
50448
|
}, {});
|
|
50455
50449
|
}
|
|
50456
|
-
async function performAxiosRequest(files, filesFieldName, body, url, headers, extractErrorMessage) {
|
|
50450
|
+
async function performAxiosRequest({ files, filesFieldName, message: body, url, headers, extractErrorMessage, }) {
|
|
50457
50451
|
let axiosResponse;
|
|
50458
50452
|
try {
|
|
50459
50453
|
if (files.length) {
|
|
@@ -50490,7 +50484,7 @@ async function performAxiosRequest(files, filesFieldName, body, url, headers, ex
|
|
|
50490
50484
|
}
|
|
50491
50485
|
let message;
|
|
50492
50486
|
try {
|
|
50493
|
-
message = typeof parsedBody === 'string' ? parsedBody : parsedBody['message'] || rawBody;
|
|
50487
|
+
message = typeof parsedBody === 'string' ? parsedBody : (parsedBody === null || parsedBody === void 0 ? void 0 : parsedBody['message']) || rawBody;
|
|
50494
50488
|
}
|
|
50495
50489
|
catch (_a) { }
|
|
50496
50490
|
if (!message)
|
|
@@ -50529,7 +50523,7 @@ function tryDeserializing(text) {
|
|
|
50529
50523
|
|
|
50530
50524
|
|
|
50531
50525
|
class RpcManager {
|
|
50532
|
-
constructor(region, appId, destructManager, headers
|
|
50526
|
+
constructor(region, appId, destructManager, headers, authManager, clientIdService) {
|
|
50533
50527
|
this.region = region;
|
|
50534
50528
|
this.appId = appId;
|
|
50535
50529
|
this.authManager = authManager;
|
|
@@ -26,10 +26,10 @@ export interface CallApiOptions {
|
|
|
26
26
|
*/
|
|
27
27
|
originOverride?: string;
|
|
28
28
|
}
|
|
29
|
-
export interface CallApiRequest {
|
|
29
|
+
export interface CallApiRequest<BodyType = any> {
|
|
30
30
|
integrationId: IntegrationId;
|
|
31
31
|
endpointId: ApiEndpointId;
|
|
32
|
-
body?:
|
|
32
|
+
body?: BodyType;
|
|
33
33
|
overrideMethod?: HttpMethod;
|
|
34
34
|
options: ApiOptions;
|
|
35
35
|
}
|
|
@@ -4,17 +4,17 @@ import { ApiOptions } from '../../internal-common/src/public-types/api-call.publ
|
|
|
4
4
|
import { HttpResponse } from './squid-http-client';
|
|
5
5
|
export declare class ApiClient {
|
|
6
6
|
private readonly rpcManager;
|
|
7
|
-
get<
|
|
8
|
-
post<
|
|
9
|
-
delete<
|
|
10
|
-
patch<
|
|
11
|
-
put<
|
|
7
|
+
get<ResponseBodyType = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, options?: ApiOptions): Promise<HttpResponse<ResponseBodyType>>;
|
|
8
|
+
post<ResponseBodyType = unknown, RequestBodyType = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: RequestBodyType, options?: ApiOptions): Promise<HttpResponse<ResponseBodyType>>;
|
|
9
|
+
delete<ResponseBodyType = unknown, RequestBodyType = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: RequestBodyType, options?: ApiOptions): Promise<HttpResponse<ResponseBodyType>>;
|
|
10
|
+
patch<ResponseBodyType = unknown, RequestBodyType = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: RequestBodyType, options?: ApiOptions): Promise<HttpResponse<ResponseBodyType>>;
|
|
11
|
+
put<ResponseBodyType = unknown, RequestBodyType = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: RequestBodyType, options?: ApiOptions): Promise<HttpResponse<ResponseBodyType>>;
|
|
12
12
|
/**
|
|
13
13
|
* Performs an HTTP API request to the given integration ID and endpoint ID.
|
|
14
14
|
* The provided options will be merged with the default options.
|
|
15
15
|
* In case of error (status code >= 400 or other error), the promise will be rejected with an RpcError.
|
|
16
16
|
*/
|
|
17
|
-
request<
|
|
17
|
+
request<ResponseBodyType = unknown, RequestBodyType = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: RequestBodyType, options?: ApiOptions, method?: HttpMethod): Promise<HttpResponse<ResponseBodyType>>;
|
|
18
18
|
private convertOptionsToStrings;
|
|
19
19
|
private convertToStrings;
|
|
20
20
|
}
|
|
@@ -12,13 +12,13 @@ export declare class RpcManager {
|
|
|
12
12
|
private readonly staticHeaders;
|
|
13
13
|
private readonly onGoingRpcCounter;
|
|
14
14
|
private readonly rateLimiters;
|
|
15
|
-
constructor(region: SquidRegion, appId: string, destructManager: DestructManager, headers: Record<string, string
|
|
15
|
+
constructor(region: SquidRegion, appId: string, destructManager: DestructManager, headers: Record<string, string>, authManager: AuthManager, clientIdService: ClientIdService);
|
|
16
16
|
private getAuthHeaders;
|
|
17
17
|
awaitAllSettled(): Promise<void>;
|
|
18
18
|
setStaticHeader(key: string, value: string): void;
|
|
19
19
|
deleteStaticHeader(key: string): void;
|
|
20
20
|
getStaticHeaders(): Record<string, string>;
|
|
21
|
-
post<
|
|
22
|
-
rawPost<
|
|
21
|
+
post<ResponseType = unknown, RequestType = unknown>(path: string, message: RequestType, files?: Array<File | BlobAndFilename>, filesFieldName?: string): Promise<ResponseType>;
|
|
22
|
+
rawPost<ResponseType = unknown, RequestType = unknown>(path: string, message: RequestType, files?: Array<File | BlobAndFilename>, filesFieldName?: string, extractErrorMessage?: boolean): Promise<HttpResponse<ResponseType>>;
|
|
23
23
|
private getRateLimiterBucket;
|
|
24
24
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { BlobAndFilename } from './types';
|
|
2
|
-
export declare class RpcError extends Error {
|
|
2
|
+
export declare class RpcError<BodyType = unknown> extends Error {
|
|
3
3
|
readonly statusCode: number;
|
|
4
4
|
readonly statusText: string;
|
|
5
5
|
readonly url: string;
|
|
6
6
|
readonly headers: Record<string, string>;
|
|
7
|
-
readonly body
|
|
7
|
+
readonly body: BodyType;
|
|
8
8
|
}
|
|
9
|
-
export interface HttpPostInput {
|
|
9
|
+
export interface HttpPostInput<RequestBodyType = unknown> {
|
|
10
10
|
url: string;
|
|
11
11
|
headers: Record<string, string>;
|
|
12
|
-
message:
|
|
12
|
+
message: RequestBodyType;
|
|
13
13
|
files: Array<File | BlobAndFilename>;
|
|
14
14
|
filesFieldName: string;
|
|
15
15
|
extractErrorMessage: boolean;
|
|
16
16
|
}
|
|
17
17
|
/** A response object with type T for the body. */
|
|
18
|
-
export interface HttpResponse<
|
|
18
|
+
export interface HttpResponse<BodyType = unknown> {
|
|
19
19
|
status: number;
|
|
20
20
|
statusText: string;
|
|
21
21
|
headers: Record<string, string>;
|
|
22
|
-
body:
|
|
22
|
+
body: BodyType;
|
|
23
23
|
}
|