Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default tseslint.config(
},
rules: {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
"no-console": ["warn", { allow: ["warn", "error", "info"] }],
},
},
Expand Down
1 change: 1 addition & 0 deletions src/cli/swagger-generator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import fs from "node:fs/promises";
import path from "node:path";

Expand Down
1 change: 1 addition & 0 deletions src/utils/async/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type {
AsyncFunction,
DebounceOptions,
Expand Down
1 change: 1 addition & 0 deletions src/utils/async/sequential.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { SequentialTask, SequentialOptions } from "./types.js";

/**
Expand Down
1 change: 1 addition & 0 deletions src/utils/async/throttle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type {
AsyncFunction,
ThrottleOptions,
Expand Down
1 change: 1 addition & 0 deletions src/utils/async/timeout.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { TimeoutError } from "./errors.js";
import { sleep } from "./sleep.js";

Expand Down
1 change: 1 addition & 0 deletions src/utils/async/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Type definitions for AsyncUtils module
*/
Expand Down
11 changes: 10 additions & 1 deletion src/utils/core/ApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { Logger } from "#core/Logger.js";
import { UrlHelper } from "#helpers/UrlHelper.js";
import { retry as retryFn } from "../async/retry.js";
Expand Down Expand Up @@ -45,6 +46,14 @@
circuitBreaker?: CircuitBreakerConfig;
}

export type RequestBody =
| Record<string, unknown>
| unknown[]
| string
| FormData
| Blob
| BufferSource;

export interface RequestOptions<TResponse = unknown> extends Omit<
RequestInit,
"body"
Expand Down Expand Up @@ -298,7 +307,7 @@
* })
*/
async post<T>(path: string | URL, bodyOrOptions?: RequestOptions<T> | unknown) {
const options = this.normalizeBodyOrOptions<T>(bodyOrOptions);

Check failure on line 310 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / coverage

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 310 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / Run Tests (20.x)

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 310 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / Run Tests (22.x)

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 310 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / size

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.
return this.request<T>(path, { ...options, method: "POST" });
}

Expand All @@ -306,7 +315,7 @@
* PUT request - Acepta body directamente o RequestOptions
*/
async put<T>(path: string | URL, bodyOrOptions?: RequestOptions<T> | unknown) {
const options = this.normalizeBodyOrOptions<T>(bodyOrOptions);

Check failure on line 318 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / coverage

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 318 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / Run Tests (20.x)

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 318 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / Run Tests (22.x)

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 318 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / size

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.
return this.request<T>(path, { ...options, method: "PUT" });
}

Expand All @@ -314,7 +323,7 @@
* PATCH request - Acepta body directamente o RequestOptions
*/
async patch<T>(path: string | URL, bodyOrOptions?: RequestOptions<T> | unknown) {
const options = this.normalizeBodyOrOptions<T>(bodyOrOptions);

Check failure on line 326 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / coverage

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 326 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / Run Tests (20.x)

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 326 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / Run Tests (22.x)

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.

Check failure on line 326 in src/utils/core/ApiClient.ts

View workflow job for this annotation

GitHub Actions / size

Argument of type 'unknown' is not assignable to parameter of type 'RequestBody | RequestOptions<T> | undefined'.
return this.request<T>(path, { ...options, method: "PATCH" });
}

Expand Down Expand Up @@ -638,7 +647,7 @@
* 2. RequestOptions: post("/path", { body: {...}, headers: {...} })
*/
private normalizeBodyOrOptions<T>(
bodyOrOptions?: RequestOptions<T> | unknown
bodyOrOptions?: RequestOptions<T> | RequestBody
): RequestOptions<T> {
if (!bodyOrOptions) {
return {};
Expand All @@ -646,7 +655,7 @@

// Si tiene propiedades típicas de RequestOptions, tratarlo como options
if (this.isRequestOptions(bodyOrOptions)) {
return bodyOrOptions as RequestOptions<T>;

Check warning on line 658 in src/utils/core/ApiClient.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This assertion is unnecessary since it does not change the type of the expression.

See more on https://sonarcloud.io/project/issues?id=sebamar88_bytekit&issues=AZ0CjEhwHvFTY8nCiNHc&open=AZ0CjEhwHvFTY8nCiNHc&pullRequest=13
}

// Caso contrario, tratarlo como body directo
Expand Down
1 change: 1 addition & 0 deletions src/utils/core/SchemaAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Generic interface for schema validation adapters (e.g., Zod, Valibot, ArkType)
*/
Expand Down
1 change: 1 addition & 0 deletions src/utils/helpers/CryptoUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Cryptographic utilities for hashing, encoding, and token generation
* Isomorphic crypto operations for Node.js and browsers
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers/PollingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class PollingHelper<T = unknown> {
const {
result,
error,
responseTime: _responseTime,
responseTime: _,
} = await this.executeAttempt(attempt, responseTimes);

if (result !== undefined) {
Expand Down
1 change: 1 addition & 0 deletions tests/async/debounce.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, expect, beforeEach, vi } from "vitest";
import { debounceAsync } from "../../src/utils/async/debounce";

Expand Down
1 change: 1 addition & 0 deletions tests/async/sequential.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, expect } from "vitest";
import { sequential } from "../../src/utils/async/sequential";
import { sleep } from "../../src/utils/async/sleep";
Expand Down
1 change: 1 addition & 0 deletions tests/async/throttle.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, expect, beforeEach, vi } from "vitest";
import { throttleAsync } from "../../src/utils/async/throttle";

Expand Down
1 change: 1 addition & 0 deletions tests/async/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, expect } from "vitest";
import { timeout, withTimeout } from "../../src/utils/async/timeout";
import { allSettled } from "../../src/utils/async/allSettled";
Expand Down
2 changes: 1 addition & 1 deletion tests/cli-main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("CLI main entry", () => {

try {
await runCli(["--invalid"]);
} catch (e) {
} catch {
// ignore exit error
}

Expand Down
7 changes: 3 additions & 4 deletions tests/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import {
Logger,
createLogger,
Expand Down Expand Up @@ -55,7 +56,7 @@ test("Logger.child creates nested namespaces", () => {
test("consoleTransportNode formats correctly", () => {
const originalLog = console.log;
let output = "";
// eslint-disable-next-line no-console

console.log = (msg) => {
output = msg;
};
Expand All @@ -71,7 +72,6 @@ test("consoleTransportNode formats correctly", () => {

assert.match(output, /INFO.*\[test\].*hello/);

// eslint-disable-next-line no-console
console.log = originalLog;
});

Expand All @@ -82,7 +82,7 @@ test("consoleTransportBrowser formats correctly (mocked environment)", () => {

const originalLog = console.log;
let output = "";
// eslint-disable-next-line no-console

console.log = (msg) => {
output = msg;
};
Expand All @@ -97,7 +97,6 @@ test("consoleTransportBrowser formats correctly (mocked environment)", () => {

assert.match(output, /%cINFO.*\[test\].*hello/);

// eslint-disable-next-line no-console
console.log = originalLog;
delete globalThis.window;
delete globalThis.document;
Expand Down
2 changes: 0 additions & 2 deletions tests/new-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
PollingHelper,
createPoller,
CryptoUtils,
PaginationHelper,
createPaginator,
CacheManager,
createCacheManager,
CompressionUtils,
Expand Down
1 change: 1 addition & 0 deletions tests/retry-policy.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { RetryPolicy, CircuitBreaker } from "../src/index";

test("RetryPolicy retries on failure and succeeds", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/schema-adapters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Schema Adapters for ApiClient", () => {
// Mock fetch for tests
globalThis.fetch = async (
input: RequestInfo | URL,
init?: RequestInit
_init?: RequestInit
) => {
const url = input.toString();

Expand Down
1 change: 1 addition & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Jest setup file for wiki documentation system tests
* Configures property-based testing with fast-check
Expand Down
Loading