- 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
56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
import { InternalPrimitiveConstraint } from "../constraint.js";
|
|
import { Disjoint } from "../shared/disjoint.js";
|
|
import { implementNode } from "../shared/implement.js";
|
|
import { $ark } from "../shared/registry.js";
|
|
import { ToJsonSchema } from "../shared/toJsonSchema.js";
|
|
import { createLengthRuleParser } from "./range.js";
|
|
const implementation = implementNode({
|
|
kind: "exactLength",
|
|
collapsibleKey: "rule",
|
|
keys: {
|
|
rule: {
|
|
parse: createLengthRuleParser("exactLength")
|
|
}
|
|
},
|
|
normalize: schema => typeof schema === "number" ? { rule: schema } : schema,
|
|
hasAssociatedError: true,
|
|
defaults: {
|
|
description: node => `exactly length ${node.rule}`,
|
|
actual: data => `${data.length}`
|
|
},
|
|
intersections: {
|
|
exactLength: (l, r, ctx) => Disjoint.init("unit", ctx.$.node("unit", { unit: l.rule }), ctx.$.node("unit", { unit: r.rule }), { path: ["length"] }),
|
|
minLength: (exactLength, minLength) => exactLength.rule >= minLength.rule ?
|
|
exactLength
|
|
: Disjoint.init("range", exactLength, minLength),
|
|
maxLength: (exactLength, maxLength) => exactLength.rule <= maxLength.rule ?
|
|
exactLength
|
|
: Disjoint.init("range", exactLength, maxLength)
|
|
}
|
|
});
|
|
export class ExactLengthNode extends InternalPrimitiveConstraint {
|
|
traverseAllows = data => data.length === this.rule;
|
|
compiledCondition = `data.length === ${this.rule}`;
|
|
compiledNegation = `data.length !== ${this.rule}`;
|
|
impliedBasis = $ark.intrinsic.lengthBoundable.internal;
|
|
expression = `== ${this.rule}`;
|
|
reduceJsonSchema(schema) {
|
|
switch (schema.type) {
|
|
case "string":
|
|
schema.minLength = this.rule;
|
|
schema.maxLength = this.rule;
|
|
return schema;
|
|
case "array":
|
|
schema.minItems = this.rule;
|
|
schema.maxItems = this.rule;
|
|
return schema;
|
|
default:
|
|
return ToJsonSchema.throwInternalOperandError("exactLength", schema);
|
|
}
|
|
}
|
|
}
|
|
export const ExactLength = {
|
|
implementation,
|
|
Node: ExactLengthNode
|
|
};
|