- 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
42 lines
1.8 KiB
JavaScript
42 lines
1.8 KiB
JavaScript
import { constraints as schemaConstraints } from '../jsonSchema/constraints.js';
|
|
import { defaultValues } from '../jsonSchema/schemaDefaults.js';
|
|
import { schemaShape } from '../jsonSchema/schemaShape.js';
|
|
import { schemaHash } from '../jsonSchema/schemaHash.js';
|
|
import { SuperFormError } from '../errors.js';
|
|
import { simpleSchema } from './simple-schema/index.js';
|
|
/**
|
|
* If the adapter options doesn't have a "defaults" or "jsonSchema" fields,
|
|
* this is a convenient function for creating a JSON schema.
|
|
* If no transformer exist for the adapter, use RequiredDefaultsOptions.
|
|
* @see {AdapterOptions}
|
|
* @see {RequiredDefaultsOptions}
|
|
* @__NO_SIDE_EFFECTS__
|
|
*/
|
|
export function createJsonSchema(options, transformer) {
|
|
return 'jsonSchema' in options && options.jsonSchema
|
|
? options.jsonSchema
|
|
: !transformer && 'defaults' in options && options.defaults
|
|
? simpleSchema(options.defaults)
|
|
: transformer
|
|
? /* @__PURE__ */ transformer()
|
|
: () => {
|
|
throw new SuperFormError('The "defaults" option is required for this adapter.');
|
|
};
|
|
}
|
|
/* @__NO_SIDE_EFFECTS__ */
|
|
export function createAdapter(adapter, jsonSchema) {
|
|
if (!adapter || !('superFormValidationLibrary' in adapter)) {
|
|
throw new SuperFormError('Superforms v2 requires a validation adapter for the schema. ' +
|
|
'Import one of your choice from "sveltekit-superforms/adapters" and wrap the schema with it.');
|
|
}
|
|
if (!jsonSchema)
|
|
jsonSchema = adapter.jsonSchema;
|
|
return {
|
|
...adapter,
|
|
constraints: adapter.constraints ?? schemaConstraints(jsonSchema),
|
|
defaults: adapter.defaults ?? defaultValues(jsonSchema),
|
|
shape: schemaShape(jsonSchema),
|
|
id: schemaHash(jsonSchema)
|
|
};
|
|
}
|