From 5609d28da4eca833499c12026042f1d5d406fa19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Samotn=C3=BD?= Date: Fri, 17 Jul 2026 13:58:32 +0200 Subject: [PATCH 1/2] fix(logger): export logger class, update tests and readme --- README.md | 23 +++++++++++++++++++++++ src/index.ts | 1 + tests/live.test.ts | 12 +++++++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index de8d82b..89a808d 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,27 @@ Types of application are generated automatically from swagger structure via [ope To generate new types after OpenAPI structure has been changed please run ``` npx openapi-typescript ./tatrapayplus_api_sandbox.json -o ./src/paths.d.ts +``` + +# Logging + +`TBPlusLogger` is exported from the package and can be subclassed to customize log output: + +```typescript +import { TBPlusSDK, TBPlusLogger } from "@tatrabanka/tatrapayplus-node"; + +class ConsoleLogger extends TBPlusLogger { + protected writeLine(line: string): void { + console.log("[ConsoleLogger]", line); + } +} + +const logger = new ConsoleLogger(); +const sdk = new TBPlusSDK(API_KEY, API_SECRET, {}, logger); +``` + +Pass `false` to the logger constructor to disable masking of sensitive fields: + +```typescript +const logger = new TBPlusLogger(false); ``` \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index e9ed1fd..69144cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import fs from "node:fs"; import path from "node:path"; export * from "./enums"; +export { TBPlusLogger } from "./logger"; export class TBPlusSDK { private clientId: string; diff --git a/tests/live.test.ts b/tests/live.test.ts index ab0e4de..84d60e1 100644 --- a/tests/live.test.ts +++ b/tests/live.test.ts @@ -1,8 +1,13 @@ import { describe, expect, it, vi } from "vitest"; -import { GatewayMode, TBPlusSDK, PaymentMethod, SimpleStatus } from "../src"; +import { + GatewayMode, + TBPlusSDK, + TBPlusLogger, + PaymentMethod, + SimpleStatus, +} from "../src"; import dotenv from "dotenv"; import { getAvailable } from "../src/helpers"; -import { TBPlusLogger } from "../src/logger"; dotenv.config(); @@ -17,7 +22,6 @@ describe("TBPlusSDK tests on live", () => { const sdk = new TBPlusSDK( process.env.API_KEY as string, process.env.API_SECRET as string, - "192.0.2.123", ); const { data, error } = await sdk.getPaymentMethods(); expect(error).toBeUndefined(); @@ -32,7 +36,6 @@ describe("TBPlusSDK tests on live", () => { const sdk = new TBPlusSDK( process.env.API_KEY as string, process.env.API_SECRET as string, - "192.0.2.123", {}, new TestLogger(), ); @@ -75,7 +78,6 @@ describe("TBPlusSDK tests on live", () => { const sdk = new TBPlusSDK( process.env.API_KEY as string, process.env.API_SECRET as string, - "192.0.2.123", ); const { data, error } = await sdk.createPayment( { From 54870781054d63126793d218f1876a94678aaa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Samotn=C3=BD?= Date: Fri, 17 Jul 2026 14:12:54 +0200 Subject: [PATCH 2/2] triv: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9c886f..358b24a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatrabanka/tatrapayplus-node", - "version": "1.0.1", + "version": "1.0.2", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts",