From d0fa8ba9382a6d603fda4afe486946c6b71be0e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 09:08:48 +0000 Subject: [PATCH 1/2] Initial plan From 5c13bb525b74799f2410e06a7bc914ae056658f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 09:18:51 +0000 Subject: [PATCH 2/2] feat: replace validateWithTypeBox with shared package - Add dependency on @jsr/nrfcloud__validate-with-typebox - Replace local implementation with re-export from shared package - Add .npmrc for JSR registry configuration Co-authored-by: coderbyheart <188915+coderbyheart@users.noreply.github.com> --- .npmrc | 1 + package.json | 3 +++ validator/validateWithTypeBox.ts | 24 ++---------------------- 3 files changed, 6 insertions(+), 22 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..41583e36 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@jsr:registry=https://npm.jsr.io diff --git a/package.json b/package.json index ed84669f..4a122581 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,9 @@ "schemas", "generate" ], + "dependencies": { + "@jsr/nrfcloud__validate-with-typebox": "1.0.0" + }, "peerDependencies": { "@hello.nrfcloud.com/proto-map": "^16.6.4", "@sinclair/typebox": "^0.34.48", diff --git a/validator/validateWithTypeBox.ts b/validator/validateWithTypeBox.ts index b9d16a16..c8f00354 100644 --- a/validator/validateWithTypeBox.ts +++ b/validator/validateWithTypeBox.ts @@ -1,24 +1,4 @@ -import type { Static, TSchema } from '@sinclair/typebox' -import { TypeCompiler, type ValueError } from '@sinclair/typebox/compiler' - /** - * Validate the value against the given TypeBox schema + * Re-export validateWithTypeBox from the shared package */ -export const validateWithTypeBox = ( - schema: T, -): ((value: unknown) => - | { value: Static } - | { - errors: ValueError[] - }) => { - const C = TypeCompiler.Compile(schema) - return (value: unknown) => { - const firstError = C.Errors(value).First() - if (firstError !== undefined) { - return { - errors: [...C.Errors(value)], - } - } - return { value: value as Static } - } -} +export { validateWithTypeBox } from '@jsr/nrfcloud__validate-with-typebox'