From 851efc074a7a5b806d2b80f9cf1e7529faaa206b Mon Sep 17 00:00:00 2001 From: Anthony GARCIA Date: Sun, 15 Mar 2026 22:42:55 +0000 Subject: [PATCH 1/2] chore: Bump zod and remove zod-validation-error --- package.json | 3 +-- src/config.js | 7 +------ tests/config.test.js | 12 +++++++++--- yarn.lock | 13 ++++--------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 001ed09..73bda43 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "dependencies": { "async-retry": "^1.2.1", "lru-cache": "^11.0.0", - "zod": "^3.20.2", - "zod-validation-error": "^1.0.1" + "zod": "^4.0.0" }, "devDependencies": { "@apollo/gateway": "^2.13.0", diff --git a/src/config.js b/src/config.js index 0181b77..485bbaa 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,5 @@ // @ts-check const { z } = require('zod') -const { fromZodError } = require('zod-validation-error') const ConfigSchema = z.object({ apiKey: z.string().startsWith('logql:'), @@ -94,11 +93,7 @@ function getConfig(options) { return maybeConfig.data } - const validationError = fromZodError(maybeConfig.error, { - prefix: 'Invalid options', - }) - - logInitError(validationError.message) + logInitError(`Invalid options: ${z.prettifyError(maybeConfig.error)}`) } module.exports = { getConfig, loadEnv } diff --git a/tests/config.test.js b/tests/config.test.js index acdae96..77591c1 100644 --- a/tests/config.test.js +++ b/tests/config.test.js @@ -18,12 +18,16 @@ describe('Config Validation', () => { it('log an error when no config is given', () => { expect(initPlugin()).toEqual({}) - expect(console.error).toHaveBeenCalledWith('[logql-plugin][ERROR][init] Invalid options: Required at "apiKey"') + expect(console.error).toHaveBeenCalledWith( + '[logql-plugin][ERROR][init] Invalid options: ✖ Invalid input: expected string, received undefined\n → at apiKey' + ) }) it('log an error when config is empty', () => { expect(initPlugin({})).toEqual({}) - expect(console.error).toHaveBeenCalledWith('[logql-plugin][ERROR][init] Invalid options: Required at "apiKey"') + expect(console.error).toHaveBeenCalledWith( + '[logql-plugin][ERROR][init] Invalid options: ✖ Invalid input: expected string, received undefined\n → at apiKey' + ) }) it('work with valid minimal config', () => { @@ -34,7 +38,9 @@ describe('Config Validation', () => { it('ignore env by default', () => { process.env.LOGQL_API_KEY = 'logql:FAKE_API_KEY' expect(initPlugin({})).toEqual({}) - expect(console.error).toHaveBeenCalledWith('[logql-plugin][ERROR][init] Invalid options: Required at "apiKey"') + expect(console.error).toHaveBeenCalledWith( + '[logql-plugin][ERROR][init] Invalid options: ✖ Invalid input: expected string, received undefined\n → at apiKey' + ) }) it('load config from env', () => { diff --git a/yarn.lock b/yarn.lock index 4768360..5ffaf6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4426,12 +4426,7 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -zod-validation-error@^1.0.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/zod-validation-error/-/zod-validation-error-1.3.1.tgz#7134579d2ba3994495133b879a076786c8c270f5" - integrity sha512-cNEXpla+tREtNdAnNKY4xKY1SGOn2yzyuZMu4O0RQylX9apRpUjNcPkEc3uHIAr5Ct7LenjZt6RzjEH6+JsqVQ== - -zod@^3.20.2: - version "3.22.3" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.3.tgz#2fbc96118b174290d94e8896371c95629e87a060" - integrity sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug== +zod@^4.0.0: + version "4.3.6" + resolved "https://registry.yarnpkg.com/zod/-/zod-4.3.6.tgz#89c56e0aa7d2b05107d894412227087885ab112a" + integrity sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg== From 2c7668eb00998abc685c511f31ad5ead2fcbb5e0 Mon Sep 17 00:00:00 2001 From: Anthony GARCIA Date: Sun, 15 Mar 2026 22:47:17 +0000 Subject: [PATCH 2/2] chore: fmt log --- package.json | 3 ++- src/config.js | 2 +- tests/config.test.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 73bda43..59872a5 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ }, "jest": { "collectCoverageFrom": [ - "./src/**" + "./src/**", + "!./src/**/*.d.ts" ], "coverageThreshold": { "global": { diff --git a/src/config.js b/src/config.js index 485bbaa..935a5d7 100644 --- a/src/config.js +++ b/src/config.js @@ -93,7 +93,7 @@ function getConfig(options) { return maybeConfig.data } - logInitError(`Invalid options: ${z.prettifyError(maybeConfig.error)}`) + logInitError(z.prettifyError(maybeConfig.error)) } module.exports = { getConfig, loadEnv } diff --git a/tests/config.test.js b/tests/config.test.js index 77591c1..e6e9dac 100644 --- a/tests/config.test.js +++ b/tests/config.test.js @@ -19,14 +19,14 @@ describe('Config Validation', () => { it('log an error when no config is given', () => { expect(initPlugin()).toEqual({}) expect(console.error).toHaveBeenCalledWith( - '[logql-plugin][ERROR][init] Invalid options: ✖ Invalid input: expected string, received undefined\n → at apiKey' + '[logql-plugin][ERROR][init] ✖ Invalid input: expected string, received undefined\n → at apiKey' ) }) it('log an error when config is empty', () => { expect(initPlugin({})).toEqual({}) expect(console.error).toHaveBeenCalledWith( - '[logql-plugin][ERROR][init] Invalid options: ✖ Invalid input: expected string, received undefined\n → at apiKey' + '[logql-plugin][ERROR][init] ✖ Invalid input: expected string, received undefined\n → at apiKey' ) }) @@ -39,7 +39,7 @@ describe('Config Validation', () => { process.env.LOGQL_API_KEY = 'logql:FAKE_API_KEY' expect(initPlugin({})).toEqual({}) expect(console.error).toHaveBeenCalledWith( - '[logql-plugin][ERROR][init] Invalid options: ✖ Invalid input: expected string, received undefined\n → at apiKey' + '[logql-plugin][ERROR][init] ✖ Invalid input: expected string, received undefined\n → at apiKey' ) })