Files
headroom/frontend/node_modules/sveltekit-superforms/dist/adapters/adapters.js
Santhosh Janardhanan de2d83092e feat: Reinitialize frontend with SvelteKit and TypeScript
- 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
2026-02-17 16:19:59 -05:00

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)
};
}