Files
headroom/frontend/node_modules/@ark/schema/out/refinements/pattern.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

53 lines
1.7 KiB
JavaScript

import { InternalPrimitiveConstraint } from "../constraint.js";
import { implementNode } from "../shared/implement.js";
import { $ark } from "../shared/registry.js";
const implementation = implementNode({
kind: "pattern",
collapsibleKey: "rule",
keys: {
rule: {},
flags: {}
},
normalize: schema => typeof schema === "string" ? { rule: schema }
: schema instanceof RegExp ?
schema.flags ?
{ rule: schema.source, flags: schema.flags }
: { rule: schema.source }
: schema,
obviatesBasisDescription: true,
obviatesBasisExpression: true,
hasAssociatedError: true,
intersectionIsOpen: true,
defaults: {
description: node => `matched by ${node.rule}`
},
intersections: {
// for now, non-equal regex are naively intersected:
// https://github.com/arktypeio/arktype/issues/853
pattern: () => null
}
});
export class PatternNode extends InternalPrimitiveConstraint {
instance = new RegExp(this.rule, this.flags);
expression = `${this.instance}`;
traverseAllows = this.instance.test.bind(this.instance);
compiledCondition = `${this.expression}.test(data)`;
compiledNegation = `!${this.compiledCondition}`;
impliedBasis = $ark.intrinsic.string.internal;
reduceJsonSchema(base, ctx) {
if (base.pattern) {
return ctx.fallback.patternIntersection({
code: "patternIntersection",
base: base,
pattern: this.rule
});
}
base.pattern = this.rule;
return base;
}
}
export const Pattern = {
implementation,
Node: PatternNode
};