- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import { createAdapter, createJsonSchema } from './adapters.js';
|
|
import { memoize } from '../memoize.js';
|
|
async function modules() {
|
|
const { Vine, errors } = await import(/* webpackIgnore: true */ '@vinejs/vine');
|
|
return { Vine, errors };
|
|
}
|
|
const fetchModule = /* @__PURE__ */ memoize(modules);
|
|
async function validate(schema, data) {
|
|
const { Vine, errors } = await fetchModule();
|
|
try {
|
|
const output = await new Vine().validate({ schema, data });
|
|
return {
|
|
success: true,
|
|
data: output
|
|
};
|
|
}
|
|
catch (e) {
|
|
if (e instanceof errors.E_VALIDATION_ERROR) {
|
|
return {
|
|
success: false,
|
|
issues: e.messages.map((m) => ({
|
|
path: m.field.split('.'),
|
|
message: m.message
|
|
}))
|
|
};
|
|
}
|
|
else {
|
|
return { success: false, issues: [] };
|
|
}
|
|
}
|
|
}
|
|
function _vine(schema, options) {
|
|
return createAdapter({
|
|
superFormValidationLibrary: 'vine',
|
|
validate: async (data) => validate(schema, data),
|
|
jsonSchema: createJsonSchema(options),
|
|
defaults: options.defaults
|
|
});
|
|
}
|
|
function _vineClient(schema) {
|
|
return {
|
|
superFormValidationLibrary: 'vine',
|
|
validate: async (data) => validate(schema, data)
|
|
};
|
|
}
|
|
export const vine = /* @__PURE__ */ memoize(_vine);
|
|
export const vineClient = /* @__PURE__ */ memoize(_vineClient);
|