@lokalise/backend-http-client
Advanced tools
Comparing version 2.2.0 to 2.3.0
export type { RequestOptions, HttpRequestContext, RequestResultDefinitiveEither, } from './src/client/types'; | ||
export { isInternalRequestError } from './src/client/types'; | ||
export { JSON_HEADERS, TEST_OPTIONS, NO_CONTENT_RESPONSE_SCHEMA, UNKNOWN_RESPONSE_SCHEMA, } from './src/client/constants'; | ||
export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, sendPostBinary, httpClient, buildClient, } from './src/client/httpClient'; | ||
export { isResponseStatusError, ResponseStatusError, } from './src/errors/ResponseStatusError'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResponseStatusError = exports.isResponseStatusError = exports.buildClient = exports.httpClient = exports.sendPostBinary = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = exports.UNKNOWN_RESPONSE_SCHEMA = exports.NO_CONTENT_RESPONSE_SCHEMA = exports.TEST_OPTIONS = exports.JSON_HEADERS = void 0; | ||
exports.ResponseStatusError = exports.isResponseStatusError = exports.buildClient = exports.httpClient = exports.sendPostBinary = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = exports.UNKNOWN_RESPONSE_SCHEMA = exports.NO_CONTENT_RESPONSE_SCHEMA = exports.TEST_OPTIONS = exports.JSON_HEADERS = exports.isInternalRequestError = void 0; | ||
var types_1 = require("./src/client/types"); | ||
Object.defineProperty(exports, "isInternalRequestError", { enumerable: true, get: function () { return types_1.isInternalRequestError; } }); | ||
var constants_1 = require("./src/client/constants"); | ||
@@ -5,0 +7,0 @@ Object.defineProperty(exports, "JSON_HEADERS", { enumerable: true, get: function () { return constants_1.JSON_HEADERS; } }); |
@@ -13,3 +13,3 @@ import type { Client } from 'undici'; | ||
}; | ||
export declare const TEST_OPTIONS: RequestOptions<unknown, any>; | ||
export declare const TEST_OPTIONS: RequestOptions<unknown, any, true>; | ||
/** | ||
@@ -16,0 +16,0 @@ * Technically 204 will send an empty body, but undici-retry defaults to parsing unknown mimetype as text for |
import type { Readable } from 'node:stream'; | ||
import { Client } from 'undici'; | ||
import type { FormData } from 'undici'; | ||
import { DEFAULT_OPTIONS } from './constants'; | ||
import type { RecordObject, RequestOptions, RequestResultDefinitiveEither } from './types'; | ||
type DEFAULT_THROW_ON_ERROR = typeof DEFAULT_OPTIONS.throwOnError; | ||
export declare function buildClient(baseUrl: string, clientOptions?: Client.Options): Client; | ||
export declare function sendGet<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendDelete<T, IsEmptyResponseExpected extends boolean = true>(client: Client, path: string, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendPost<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendPostBinary<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendPut<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendPutBinary<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendPatch<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>; | ||
export declare function sendGet<T, IsEmptyResponseExpected extends boolean = false, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare function sendDelete<T, IsEmptyResponseExpected extends boolean = true, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare function sendPost<T, IsEmptyResponseExpected extends boolean = false, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare function sendPostBinary<T, IsEmptyResponseExpected extends boolean = false, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare function sendPut<T, IsEmptyResponseExpected extends boolean = false, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare function sendPutBinary<T, IsEmptyResponseExpected extends boolean = false, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare function sendPatch<T, IsEmptyResponseExpected extends boolean = false, DoThrowOnError extends boolean = DEFAULT_THROW_ON_ERROR>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected, DoThrowOnError>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected, DoThrowOnError>>; | ||
export declare const httpClient: { | ||
@@ -20,1 +22,2 @@ get: typeof sendGet; | ||
}; | ||
export {}; |
import type { DefiniteEither } from '@lokalise/node-core'; | ||
import type { Client } from 'undici'; | ||
import type { RequestResult, RetryConfig } from 'undici-retry'; | ||
import type { Either, InternalRequestError, RequestResult, RetryConfig } from 'undici-retry'; | ||
import type { ZodSchema } from 'zod'; | ||
@@ -9,2 +9,3 @@ export type RecordObject = Record<string, any>; | ||
}; | ||
export declare function isInternalRequestError(error: unknown): error is InternalRequestError; | ||
export type InternalRequestOptions<T> = { | ||
@@ -14,3 +15,2 @@ headers?: RecordObject; | ||
timeout?: number | null; | ||
throwOnError?: boolean; | ||
reqContext?: HttpRequestContext; | ||
@@ -26,5 +26,6 @@ safeParseJson?: boolean; | ||
}; | ||
export type RequestOptions<T, IsEmptyResponseExpected extends boolean> = InternalRequestOptions<T> & { | ||
export type RequestOptions<T, IsEmptyResponseExpected extends boolean, DoThrowOnError extends boolean> = InternalRequestOptions<T> & { | ||
isEmptyResponseExpected?: IsEmptyResponseExpected; | ||
throwOnError?: DoThrowOnError; | ||
}; | ||
export type RequestResultDefinitiveEither<T, IsEmptyResponseExpected extends boolean> = DefiniteEither<RequestResult<unknown>, IsEmptyResponseExpected extends true ? RequestResult<T | null> : RequestResult<T>>; | ||
export type RequestResultDefinitiveEither<T, IsEmptyResponseExpected extends boolean, DoThrowOnError extends boolean> = DoThrowOnError extends true ? DefiniteEither<RequestResult<unknown>, IsEmptyResponseExpected extends true ? RequestResult<T | null> : RequestResult<T>> : Either<RequestResult<unknown> | InternalRequestError, IsEmptyResponseExpected extends true ? RequestResult<T | null> : RequestResult<T>>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isInternalRequestError = isInternalRequestError; | ||
function isInternalRequestError(error) { | ||
return error.isInternalRequestError === true; | ||
} | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@lokalise/backend-http-client", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": { | ||
@@ -36,3 +36,3 @@ "name": "Lokalise", | ||
"@lokalise/node-core": "^12.0.0", | ||
"undici": "^6.19.5", | ||
"undici": "^6.19.8", | ||
"undici-retry": "^5.0.3", | ||
@@ -43,4 +43,4 @@ "zod": "^3.23.8" | ||
"@biomejs/biome": "^1.8.3", | ||
"@lokalise/biome-config": "^1.3.0", | ||
"@types/node": "^22.1.0", | ||
"@lokalise/biome-config": "^1.4.0", | ||
"@types/node": "^22.5.0", | ||
"@vitest/coverage-v8": "^2.0.5", | ||
@@ -47,0 +47,0 @@ "typescript": "^5.5.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
38132
381
Updatedundici@^6.19.8