fix: use import type for GraphConfig, remove verbatim-module-syntax exclusion

The verbatim-module-syntax lint rule was correctly flagging that
GraphConfig is only used in a type position (typeof GraphConfig). Since
typeof resolves purely at the type level, import type works fine here
and is the correct form. No lint exclusion needed.

Also: deno fmt across all files (markdown line wrapping).
This commit is contained in:
2026-05-28 13:38:42 +00:00
parent b0298663dc
commit bb544469fd
34 changed files with 1279 additions and 617 deletions

View File

@@ -1,7 +1,7 @@
import { KindGuard, type TSchema } from "@alkdev/typebox";
import { Value } from "@alkdev/typebox/value";
import { assert } from "@std/assert";
import { GraphSchema, GraphConfig, NodeType, EdgeType } from "./types.ts";
import { EdgeType, GraphConfig, GraphSchema, NodeType } from "./types.ts";
export class SchemaBuilder {
private schema: {
@@ -22,7 +22,10 @@ export class SchemaBuilder {
}
nodeType(name: string, schema: TSchema): SchemaBuilder {
assert(KindGuard.IsSchema(schema), `type '${name}' is not a valid json schema.`);
assert(
KindGuard.IsSchema(schema),
`type '${name}' is not a valid json schema.`,
);
if (!this.schema.nodeTypes) this.schema.nodeTypes = {};
const nodeTypeObj: NodeType = { name, schema };
@@ -37,7 +40,10 @@ export class SchemaBuilder {
schema: TSchema,
options?: { allowedSourceTypes?: string[]; allowedTargetTypes?: string[] },
): SchemaBuilder {
assert(KindGuard.IsSchema(schema), `type '${name}' is not a valid json schema.`);
assert(
KindGuard.IsSchema(schema),
`type '${name}' is not a valid json schema.`,
);
if (!this.schema.edgeTypes) this.schema.edgeTypes = {};
const edgeTypeObj: EdgeType = { name, schema, ...options };
@@ -51,7 +57,9 @@ export class SchemaBuilder {
if (!Value.Check(schema, value)) {
const errors = [...Value.Errors(schema, value)];
throw new Error(
`Invalid schema structure: ${JSON.stringify(errors.map((e) => `${e.path}: ${e.message}`))}`,
`Invalid schema structure: ${
JSON.stringify(errors.map((e) => `${e.path}: ${e.message}`))
}`,
);
}
}
@@ -60,4 +68,4 @@ export class SchemaBuilder {
this.check(GraphSchema, this.schema);
return this.schema as GraphSchema;
}
}
}