@lokalise/node-core
Advanced tools
Comparing version 2.5.2 to 3.0.0
@@ -1,3 +0,3 @@ | ||
export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, httpClient, } from './src/http/httpClient'; | ||
export type { GetRequestOptions, DeleteRequestOptions, RequestOptions, Response, HttpRequestContext, } from './src/http/httpClient'; | ||
export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, httpClient, buildClient, } from './src/http/httpClient'; | ||
export type { RequestOptions, Response, HttpRequestContext } from './src/http/httpClient'; | ||
export { PublicNonRecoverableError } from './src/errors/PublicNonRecoverableError'; | ||
@@ -4,0 +4,0 @@ export type { PublicNonRecoverableErrorParams } from './src/errors/PublicNonRecoverableError'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isEmptyObject = exports.copyWithoutUndefined = exports.pickWithoutUndefined = exports.pick = exports.groupBy = exports.chunk = exports.createRangeValidator = exports.ensureClosingSlashTransformer = exports.ConfigScope = exports.InternalError = exports.PublicNonRecoverableError = exports.httpClient = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = void 0; | ||
exports.isEmptyObject = exports.copyWithoutUndefined = exports.pickWithoutUndefined = exports.pick = exports.groupBy = exports.chunk = exports.createRangeValidator = exports.ensureClosingSlashTransformer = exports.ConfigScope = exports.InternalError = exports.PublicNonRecoverableError = exports.buildClient = exports.httpClient = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = void 0; | ||
var httpClient_1 = require("./src/http/httpClient"); | ||
@@ -12,2 +12,3 @@ Object.defineProperty(exports, "sendPut", { enumerable: true, get: function () { return httpClient_1.sendPut; } }); | ||
Object.defineProperty(exports, "httpClient", { enumerable: true, get: function () { return httpClient_1.httpClient; } }); | ||
Object.defineProperty(exports, "buildClient", { enumerable: true, get: function () { return httpClient_1.buildClient; } }); | ||
var PublicNonRecoverableError_1 = require("./src/errors/PublicNonRecoverableError"); | ||
@@ -14,0 +15,0 @@ Object.defineProperty(exports, "PublicNonRecoverableError", { enumerable: true, get: function () { return PublicNonRecoverableError_1.PublicNonRecoverableError; } }); |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { Readable } from 'stream'; | ||
import { Client } from 'undici'; | ||
import type { FormData } from 'undici'; | ||
@@ -9,11 +10,2 @@ type RecordObject = Record<string, any>; | ||
}; | ||
export type GetRequestOptions = { | ||
headers?: RecordObject; | ||
query?: RecordObject; | ||
timeout?: number; | ||
throwOnError?: boolean; | ||
reqContext?: HttpRequestContext; | ||
safeParseJson?: boolean; | ||
}; | ||
export type DeleteRequestOptions = GetRequestOptions; | ||
export type RequestOptions = { | ||
@@ -26,2 +18,4 @@ headers?: RecordObject; | ||
safeParseJson?: boolean; | ||
disableKeepAlive?: boolean; | ||
clientOptions?: Client.Options; | ||
}; | ||
@@ -33,8 +27,9 @@ export type Response<T> = { | ||
}; | ||
export declare function sendGet<T>(baseUrl: string, path: string, options?: GetRequestOptions): Promise<Response<T>>; | ||
export declare function sendDelete<T>(baseUrl: string, path: string, options?: DeleteRequestOptions): Promise<Response<T>>; | ||
export declare function sendPost<T>(baseUrl: string, path: string, body: RecordObject | undefined, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPut<T>(baseUrl: string, path: string, body: RecordObject | undefined, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPutBinary<T>(baseUrl: string, path: string, body: Buffer | Uint8Array | Readable | null | FormData, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPatch<T>(baseUrl: string, path: string, body: RecordObject | undefined, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendGet<T>(client: Client, path: string, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendDelete<T>(client: Client, path: string, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPost<T>(client: Client, path: string, body: RecordObject | undefined, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPut<T>(client: Client, path: string, body: RecordObject | undefined, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPutBinary<T>(client: Client, path: string, body: Buffer | Uint8Array | Readable | null | FormData, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function sendPatch<T>(client: Client, path: string, body: RecordObject | undefined, options?: RequestOptions): Promise<Response<T>>; | ||
export declare function buildClient(baseUrl: string, clientOptions?: Client.Options): Client; | ||
export declare const httpClient: { | ||
@@ -41,0 +36,0 @@ get: typeof sendGet; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.httpClient = exports.sendPatch = exports.sendPutBinary = exports.sendPut = exports.sendPost = exports.sendDelete = exports.sendGet = void 0; | ||
exports.httpClient = exports.buildClient = exports.sendPatch = exports.sendPutBinary = exports.sendPut = exports.sendPost = exports.sendDelete = exports.sendGet = void 0; | ||
const undici_1 = require("undici"); | ||
@@ -11,5 +11,9 @@ const InternalError_1 = require("../errors/InternalError"); | ||
}; | ||
async function sendGet(baseUrl, path, options = defaultOptions) { | ||
const url = resolveUrl(baseUrl, path); | ||
const response = await (0, undici_1.request)(url, { | ||
const defaultClientOptions = { | ||
keepAliveMaxTimeout: 300000, | ||
keepAliveTimeout: 4000, | ||
}; | ||
async function sendGet(client, path, options = defaultOptions) { | ||
const response = await client.request({ | ||
path: path, | ||
method: 'GET', | ||
@@ -21,9 +25,8 @@ query: options.query, | ||
}), | ||
reset: options.disableKeepAlive ?? false, | ||
bodyTimeout: options.timeout, | ||
throwOnError: options.throwOnError, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const resolvedBody = await resolveBody(response, options.safeParseJson); | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
body: resolvedBody, | ||
@@ -35,5 +38,5 @@ headers: response.headers, | ||
exports.sendGet = sendGet; | ||
async function sendDelete(baseUrl, path, options = defaultOptions) { | ||
const url = resolveUrl(baseUrl, path); | ||
const response = await (0, undici_1.request)(url, { | ||
async function sendDelete(client, path, options = defaultOptions) { | ||
const response = await client.request({ | ||
path: path, | ||
method: 'DELETE', | ||
@@ -45,9 +48,8 @@ query: options.query, | ||
}), | ||
reset: options.disableKeepAlive ?? false, | ||
bodyTimeout: options.timeout, | ||
throwOnError: options.throwOnError, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const resolvedBody = await resolveBody(response, options.safeParseJson); | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
body: resolvedBody, | ||
@@ -59,5 +61,5 @@ headers: response.headers, | ||
exports.sendDelete = sendDelete; | ||
async function sendPost(baseUrl, path, body, options = defaultOptions) { | ||
const url = resolveUrl(baseUrl, path); | ||
const response = await (0, undici_1.request)(url, { | ||
async function sendPost(client, path, body, options = defaultOptions) { | ||
const response = await client.request({ | ||
path: path, | ||
method: 'POST', | ||
@@ -70,9 +72,8 @@ body: body ? JSON.stringify(body) : undefined, | ||
}), | ||
reset: options.disableKeepAlive ?? false, | ||
bodyTimeout: options.timeout, | ||
throwOnError: options.throwOnError, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const resolvedBody = await resolveBody(response, options.safeParseJson); | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
body: resolvedBody, | ||
@@ -84,5 +85,5 @@ headers: response.headers, | ||
exports.sendPost = sendPost; | ||
async function sendPut(baseUrl, path, body, options = defaultOptions) { | ||
const url = resolveUrl(baseUrl, path); | ||
const response = await (0, undici_1.request)(url, { | ||
async function sendPut(client, path, body, options = defaultOptions) { | ||
const response = await client.request({ | ||
path: path, | ||
method: 'PUT', | ||
@@ -95,9 +96,8 @@ body: body ? JSON.stringify(body) : undefined, | ||
}), | ||
reset: options.disableKeepAlive ?? false, | ||
bodyTimeout: options.timeout, | ||
throwOnError: options.throwOnError, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const resolvedBody = await resolveBody(response, options.safeParseJson); | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
body: resolvedBody, | ||
@@ -109,5 +109,5 @@ headers: response.headers, | ||
exports.sendPut = sendPut; | ||
async function sendPutBinary(baseUrl, path, body, options = defaultOptions) { | ||
const url = resolveUrl(baseUrl, path); | ||
const response = await (0, undici_1.request)(url, { | ||
async function sendPutBinary(client, path, body, options = defaultOptions) { | ||
const response = await client.request({ | ||
path: path, | ||
method: 'PUT', | ||
@@ -120,9 +120,8 @@ body, | ||
}), | ||
reset: options.disableKeepAlive ?? false, | ||
bodyTimeout: options.timeout, | ||
throwOnError: options.throwOnError, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const resolvedBody = await resolveBody(response, options.safeParseJson); | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
body: resolvedBody, | ||
@@ -134,5 +133,5 @@ headers: response.headers, | ||
exports.sendPutBinary = sendPutBinary; | ||
async function sendPatch(baseUrl, path, body, options = defaultOptions) { | ||
const url = resolveUrl(baseUrl, path); | ||
const response = await (0, undici_1.request)(url, { | ||
async function sendPatch(client, path, body, options = defaultOptions) { | ||
const response = await client.request({ | ||
path: path, | ||
method: 'PATCH', | ||
@@ -145,9 +144,8 @@ body: body ? JSON.stringify(body) : undefined, | ||
}), | ||
reset: options.disableKeepAlive ?? false, | ||
bodyTimeout: options.timeout, | ||
throwOnError: options.throwOnError, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const resolvedBody = await resolveBody(response, options.safeParseJson); | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
body: resolvedBody, | ||
@@ -184,5 +182,10 @@ headers: response.headers, | ||
} | ||
function resolveUrl(baseUrl, path) { | ||
return new URL(path, baseUrl).href; | ||
function buildClient(baseUrl, clientOptions) { | ||
const newClient = new undici_1.Client(baseUrl, { | ||
...defaultClientOptions, | ||
...clientOptions, | ||
}); | ||
return newClient; | ||
} | ||
exports.buildClient = buildClient; | ||
exports.httpClient = { | ||
@@ -189,0 +192,0 @@ get: sendGet, |
@@ -14,4 +14,6 @@ "use strict"; | ||
}; | ||
const baseUrl = 'https://fakestoreapi.com'; | ||
describe('httpClient', () => { | ||
let mockAgent; | ||
let client; | ||
beforeEach(() => { | ||
@@ -21,7 +23,13 @@ mockAgent = new undici_1.MockAgent(); | ||
(0, undici_1.setGlobalDispatcher)(mockAgent); | ||
client = mockAgent.get(baseUrl); | ||
}); | ||
describe('buildClient', () => { | ||
it('creates a client', () => { | ||
const client = (0, httpClient_1.buildClient)(baseUrl); | ||
expect(client).toBeInstanceOf(undici_1.Client); | ||
}); | ||
}); | ||
describe('GET', () => { | ||
it('returns original payload when breaking during parsing', async () => { | ||
expect.assertions(1); | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -34,3 +42,3 @@ .intercept({ | ||
try { | ||
await (0, httpClient_1.sendGet)('https://fakestoreapi.com', 'products/1', { safeParseJson: true }); | ||
await (0, httpClient_1.sendGet)(client, '/products/1', { safeParseJson: true }); | ||
} | ||
@@ -50,3 +58,2 @@ catch (err) { | ||
it('GET without queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -58,7 +65,6 @@ .intercept({ | ||
.reply(200, mockProduct1_json_1.default, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendGet)('https://fakestoreapi.com', 'products/1'); | ||
const result = await (0, httpClient_1.sendGet)(client, '/products/1'); | ||
expect(result.body).toEqual(mockProduct1_json_1.default); | ||
}); | ||
it('GET returning text', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -72,7 +78,6 @@ .intercept({ | ||
}); | ||
const result = await (0, httpClient_1.sendGet)('https://fakestoreapi.com', 'products/1'); | ||
const result = await (0, httpClient_1.sendGet)(client, '/products/1'); | ||
expect(result.body).toBe('just text'); | ||
}); | ||
it('GET returning text without content type', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -84,7 +89,6 @@ .intercept({ | ||
.reply(200, 'just text', {}); | ||
const result = await (0, httpClient_1.sendGet)('https://fakestoreapi.com', 'products/1'); | ||
const result = await (0, httpClient_1.sendGet)(client, '/products/1'); | ||
expect(result.body).toBe('just text'); | ||
}); | ||
it('GET with queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
const query = { | ||
@@ -100,3 +104,3 @@ limit: 3, | ||
.reply(200, mockProductsLimit3_json_1.default, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendGet)('https://fakestoreapi.com', 'products', { | ||
const result = await (0, httpClient_1.sendGet)(client, '/products', { | ||
query, | ||
@@ -109,3 +113,2 @@ }); | ||
it('DELETE without queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -117,3 +120,3 @@ .intercept({ | ||
.reply(204, undefined, { headers: TEXT_HEADERS }); | ||
const result = await (0, httpClient_1.sendDelete)('https://fakestoreapi.com', 'products/1'); | ||
const result = await (0, httpClient_1.sendDelete)(client, '/products/1'); | ||
expect(result.statusCode).toBe(204); | ||
@@ -123,3 +126,2 @@ expect(result.body).toBe(''); | ||
it('DELETE with queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
const query = { | ||
@@ -135,3 +137,3 @@ limit: 3, | ||
.reply(204, undefined, { headers: TEXT_HEADERS }); | ||
const result = await (0, httpClient_1.sendDelete)('https://fakestoreapi.com', 'products', { | ||
const result = await (0, httpClient_1.sendDelete)(client, '/products', { | ||
query, | ||
@@ -145,3 +147,2 @@ }); | ||
it('POST without queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -153,7 +154,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPost)('https://fakestoreapi.com', 'products', mockProduct1_json_1.default); | ||
const result = await (0, httpClient_1.sendPost)(client, '/products', mockProduct1_json_1.default); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('POST without body', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -165,7 +165,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPost)('https://fakestoreapi.com', 'products', undefined); | ||
const result = await (0, httpClient_1.sendPost)(client, '/products', undefined); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('POST with queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
const query = { | ||
@@ -181,3 +180,3 @@ limit: 3, | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPost)('https://fakestoreapi.com', 'products', mockProduct1_json_1.default, { | ||
const result = await (0, httpClient_1.sendPost)(client, '/products', mockProduct1_json_1.default, { | ||
query, | ||
@@ -188,3 +187,2 @@ }); | ||
it('POST that returns 400 throws an error', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -196,3 +194,3 @@ .intercept({ | ||
.reply(400, { errorCode: 'err' }, { headers: JSON_HEADERS }); | ||
await expect((0, httpClient_1.sendPost)('https://fakestoreapi.com', 'products', mockProduct1_json_1.default)).rejects.toThrow('Response status code 400: Bad Request'); | ||
await expect((0, httpClient_1.sendPost)(client, '/products', mockProduct1_json_1.default)).rejects.toThrow('Response status code 400: Bad Request'); | ||
}); | ||
@@ -202,3 +200,2 @@ }); | ||
it('PUT without queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -210,7 +207,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPut)('https://fakestoreapi.com', 'products/1', mockProduct1_json_1.default); | ||
const result = await (0, httpClient_1.sendPut)(client, '/products/1', mockProduct1_json_1.default); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('PUT without body', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -222,7 +218,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPut)('https://fakestoreapi.com', 'products/1', undefined); | ||
const result = await (0, httpClient_1.sendPut)(client, '/products/1', undefined); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('PUT with queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
const query = { | ||
@@ -238,3 +233,3 @@ limit: 3, | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPut)('https://fakestoreapi.com', 'products/1', mockProduct1_json_1.default, { | ||
const result = await (0, httpClient_1.sendPut)(client, '/products/1', mockProduct1_json_1.default, { | ||
query, | ||
@@ -245,3 +240,2 @@ }); | ||
it('PUT that returns 400 throws an error', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -253,3 +247,3 @@ .intercept({ | ||
.reply(400, { errorCode: 'err' }, { headers: JSON_HEADERS }); | ||
await expect((0, httpClient_1.sendPut)('https://fakestoreapi.com', 'products/1', mockProduct1_json_1.default)).rejects.toThrow('Response status code 400: Bad Request'); | ||
await expect((0, httpClient_1.sendPut)(client, '/products/1', mockProduct1_json_1.default)).rejects.toThrow('Response status code 400: Bad Request'); | ||
}); | ||
@@ -259,3 +253,2 @@ }); | ||
it('PUT without queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -267,7 +260,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPutBinary)('https://fakestoreapi.com', 'products/1', Buffer.from('text')); | ||
const result = await (0, httpClient_1.sendPutBinary)(client, '/products/1', Buffer.from('text')); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('PUT with queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
const query = { | ||
@@ -283,3 +275,3 @@ limit: 3, | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPutBinary)('https://fakestoreapi.com', 'products/1', Buffer.from('text'), { | ||
const result = await (0, httpClient_1.sendPutBinary)(client, '/products/1', Buffer.from('text'), { | ||
query, | ||
@@ -290,3 +282,2 @@ }); | ||
it('PUT that returns 400 throws an error', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -298,3 +289,3 @@ .intercept({ | ||
.reply(400, { errorCode: 'err' }, { headers: JSON_HEADERS }); | ||
await expect((0, httpClient_1.sendPutBinary)('https://fakestoreapi.com', 'products/1', Buffer.from('text'))).rejects.toThrow('Response status code 400: Bad Request'); | ||
await expect((0, httpClient_1.sendPutBinary)(client, '/products/1', Buffer.from('text'))).rejects.toThrow('Response status code 400: Bad Request'); | ||
}); | ||
@@ -304,3 +295,2 @@ }); | ||
it('PATCH without queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -312,7 +302,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPatch)('https://fakestoreapi.com', 'products/1', mockProduct1_json_1.default); | ||
const result = await (0, httpClient_1.sendPatch)(client, '/products/1', mockProduct1_json_1.default); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('PATCH without body', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -324,7 +313,6 @@ .intercept({ | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPatch)('https://fakestoreapi.com', 'products/1', undefined); | ||
const result = await (0, httpClient_1.sendPatch)(client, '/products/1', undefined); | ||
expect(result.body).toEqual({ id: 21 }); | ||
}); | ||
it('PATCH with queryParams', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
const query = { | ||
@@ -340,3 +328,3 @@ limit: 3, | ||
.reply(200, { id: 21 }, { headers: JSON_HEADERS }); | ||
const result = await (0, httpClient_1.sendPatch)('https://fakestoreapi.com', 'products/1', mockProduct1_json_1.default, { | ||
const result = await (0, httpClient_1.sendPatch)(client, '/products/1', mockProduct1_json_1.default, { | ||
query, | ||
@@ -347,3 +335,2 @@ }); | ||
it('PATCH that returns 400 throws an error', async () => { | ||
const client = mockAgent.get('https://fakestoreapi.com'); | ||
client | ||
@@ -355,3 +342,3 @@ .intercept({ | ||
.reply(400, { errorCode: 'err' }, { headers: JSON_HEADERS }); | ||
await expect((0, httpClient_1.sendPatch)('https://fakestoreapi.com', 'products/1', mockProduct1_json_1.default)).rejects.toThrow('Response status code 400: Bad Request'); | ||
await expect((0, httpClient_1.sendPatch)(client, '/products/1', mockProduct1_json_1.default)).rejects.toThrow('Response status code 400: Bad Request'); | ||
}); | ||
@@ -358,0 +345,0 @@ }); |
@@ -9,3 +9,2 @@ "use strict"; | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
acc[key] = originalValue[key]; | ||
@@ -24,3 +23,2 @@ } | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
result[propNames[idx]] = source[propNames[idx]]; | ||
@@ -40,3 +38,2 @@ } | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
result[propNames[idx]] = source[propNames[idx]]; | ||
@@ -61,3 +58,3 @@ } | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const key = entry[propName]; | ||
@@ -64,0 +61,0 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument |
{ | ||
"name": "@lokalise/node-core", | ||
"version": "2.5.2", | ||
"version": "3.0.0", | ||
"author": { | ||
@@ -37,9 +37,9 @@ "name": "Lokalise", | ||
"dependencies": { | ||
"undici": "^5.17.1" | ||
"undici": "^5.18.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.4.0", | ||
"@types/node": "^18.11.18", | ||
"@typescript-eslint/eslint-plugin": "^5.50.0", | ||
"@typescript-eslint/parser": "^5.50.0", | ||
"@types/node": "^18.13.0", | ||
"@typescript-eslint/eslint-plugin": "^5.51.0", | ||
"@typescript-eslint/parser": "^5.51.0", | ||
"auto-changelog": "^2.4.0", | ||
@@ -51,4 +51,4 @@ "eslint": "^8.33.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.4.1", | ||
"prettier": "^2.8.3", | ||
"jest": "^29.4.2", | ||
"prettier": "^2.8.4", | ||
"ts-jest": "^29.0.5", | ||
@@ -55,0 +55,0 @@ "typescript": "4.9.5" |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120080
1540
Updatedundici@^5.18.0