From 8cd97c12458a2067aff77497e86087fc294aef70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=B6derlund?= Date: Sun, 1 Dec 2024 06:22:20 +0100 Subject: [PATCH] Typebox bump to 0.34.9 Fixes #511 --- CHANGELOG.md | 4 ++ package.json | 4 +- pnpm-lock.yaml | 10 ++-- src/routes/(v2)/v2/Navigation.svelte | 3 +- src/routes/(v2)/v2/typebox/+page.server.ts | 23 +++++++++ src/routes/(v2)/v2/typebox/+page.svelte | 54 ++++++++++++++++++++++ src/routes/(v2)/v2/typebox/schema.ts | 6 +++ 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 src/routes/(v2)/v2/typebox/+page.server.ts create mode 100644 src/routes/(v2)/v2/typebox/+page.svelte create mode 100644 src/routes/(v2)/v2/typebox/schema.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 749d8925..2c4631d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - All properties for object unions weren't added to the adapter defaults. +### Changed + +- Typebox updated to require `^0.34.9` (hoping for a stable release soon). + ## [2.20.1] - 2024-11-15 ### Changed diff --git a/package.json b/package.json index ea6f1a72..b914b92b 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "peerDependencies": { "@effect/schema": "^0.75.3", "@exodus/schemasafe": "^1.3.0", - "@sinclair/typebox": ">=0.32.30 <1", + "@sinclair/typebox": "^0.34.9", "@sveltejs/kit": "1.x || 2.x", "@typeschema/class-validator": "^0.3.0", "@vinejs/vine": "^1.8.0 || ^2.0.0", @@ -163,7 +163,7 @@ "@effect/schema": "^0.75.3", "@exodus/schemasafe": "^1.3.0", "@gcornut/valibot-json-schema": "^0.31.0", - "@sinclair/typebox": "^0.32.35", + "@sinclair/typebox": "^0.34.9", "@typeschema/class-validator": "^0.3.0", "@vinejs/vine": "^2.0.0", "arktype": "^2.0.0-rc.23", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c977109c..93f77e2b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,8 +31,8 @@ importers: specifier: ^0.31.0 version: 0.31.0 '@sinclair/typebox': - specifier: ^0.32.35 - version: 0.32.35 + specifier: ^0.34.9 + version: 0.34.9 '@typeschema/class-validator': specifier: ^0.3.0 version: 0.3.0(@types/json-schema@7.0.15)(class-validator@0.14.1) @@ -654,8 +654,8 @@ packages: '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} - '@sinclair/typebox@0.32.35': - resolution: {integrity: sha512-Ul3YyOTU++to8cgNkttakC0dWvpERr6RYoHO2W47DLbFvrwBDJUY31B1sImH6JZSYc4Kt4PyHtoPNu+vL2r2dA==} + '@sinclair/typebox@0.34.9': + resolution: {integrity: sha512-KTuEZ4UHIp8rNgbLrsQwmGo4cCVj/AHPG3DsI1VvfzudG8dzpZNCV4qm4NWfYY02ReB5INVyuq6xGrl3Ks8vAQ==} '@sveltejs/adapter-auto@3.2.5': resolution: {integrity: sha512-27LR+uKccZ62lgq4N/hvyU2G+hTP9fxWEAfnZcl70HnyfAjMSsGk1z/SjAPXNCD1mVJIE7IFu3TQ8cQ/UH3c0A==} @@ -2340,7 +2340,7 @@ snapshots: '@sinclair/typebox@0.27.8': {} - '@sinclair/typebox@0.32.35': + '@sinclair/typebox@0.34.9': optional: true '@sveltejs/adapter-auto@3.2.5(@sveltejs/kit@2.6.1(@sveltejs/vite-plugin-svelte@4.0.0-next.7(svelte@5.1.2)(vite@5.4.8(@types/node@22.7.4)(sass@1.79.4)))(svelte@5.1.2)(vite@5.4.8(@types/node@22.7.4)(sass@1.79.4)))': diff --git a/src/routes/(v2)/v2/Navigation.svelte b/src/routes/(v2)/v2/Navigation.svelte index bfbc4a9f..1176188b 100644 --- a/src/routes/(v2)/v2/Navigation.svelte +++ b/src/routes/(v2)/v2/Navigation.svelte @@ -71,7 +71,8 @@ 'issue-485', 'arktype', 'effect', - 'issue-500' + 'issue-500', + 'typebox' ].sort(); diff --git a/src/routes/(v2)/v2/typebox/+page.server.ts b/src/routes/(v2)/v2/typebox/+page.server.ts new file mode 100644 index 00000000..3f63f8a2 --- /dev/null +++ b/src/routes/(v2)/v2/typebox/+page.server.ts @@ -0,0 +1,23 @@ +import { typebox } from '$lib/adapters/typebox.js'; +import { message, superValidate } from '$lib/server/index.js'; +import { schema } from './schema.js'; +import { fail } from '@sveltejs/kit'; + +export const load = async () => { + const form = await superValidate(typebox(schema)); + return { form }; +}; + +export const actions = { + default: async ({ request }) => { + const formData = await request.formData(); + console.log(formData); + + const form = await superValidate(formData, typebox(schema)); + console.log(form); + + if (!form.valid) return fail(400, { form }); + + return message(form, 'Posted OK!'); + } +}; diff --git a/src/routes/(v2)/v2/typebox/+page.svelte b/src/routes/(v2)/v2/typebox/+page.svelte new file mode 100644 index 00000000..3c50314a --- /dev/null +++ b/src/routes/(v2)/v2/typebox/+page.svelte @@ -0,0 +1,54 @@ + + + + +{#if $message}

{$message}

{/if} + +
+ + +
+ +
+
+ + diff --git a/src/routes/(v2)/v2/typebox/schema.ts b/src/routes/(v2)/v2/typebox/schema.ts new file mode 100644 index 00000000..87959391 --- /dev/null +++ b/src/routes/(v2)/v2/typebox/schema.ts @@ -0,0 +1,6 @@ +import { Type } from '@sinclair/typebox'; + +export const schema = Type.Object({ + name: Type.String({ minLength: 2 }), + email: Type.String({ format: 'email' }) +});