Skip to content

Commit 21b1b74

Browse files
committed
refactor(md-db): switch to config object
1 parent 224a1c7 commit 21b1b74

2 files changed

Lines changed: 92 additions & 100 deletions

File tree

packages/markdown-db/src/markdown-db.engine.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe("MarkdownDb", () => {
7777

7878
const engine = MarkdownDb.cwd<TestInput>(testPatternsDir)
7979
.setQueryEngine(customQuery)
80-
.setConfigSchema(z.object({ status: z.string() }));
80+
.setEntrySchema(z.object({ status: z.string() }));
8181

8282
const input = {
8383
query: { contains: "test" },
@@ -89,10 +89,10 @@ describe("MarkdownDb", () => {
8989
});
9090
});
9191

92-
describe("setConfigSchema", () => {
92+
describe("setEntrySchema", () => {
9393
it("returns a new instance with extended config schema", () => {
9494
const engine1 = MarkdownDb.cwd(testPatternsDir);
95-
const engine2 = engine1.setConfigSchema(
95+
const engine2 = engine1.setEntrySchema(
9696
z.object({
9797
status: z
9898
.enum(["tag", "blocked", "ok", "ignore"])
@@ -115,7 +115,7 @@ describe("MarkdownDb", () => {
115115
});
116116

117117
it("applies default values from config schema", () => {
118-
const engine = MarkdownDb.cwd(testPatternsDir).setConfigSchema(
118+
const engine = MarkdownDb.cwd(testPatternsDir).setEntrySchema(
119119
z.object({
120120
status: z
121121
.enum(["tag", "blocked", "ok", "ignore"])
@@ -194,7 +194,7 @@ describe("MarkdownDb", () => {
194194
it("loads patterns with custom config fields", async () => {
195195
const engine = MarkdownDb.cwd<TestInput>(testPatternsDir)
196196
.setQueryEngine(createTestQueryEngine())
197-
.setConfigSchema(
197+
.setEntrySchema(
198198
z.object({
199199
status: z.string().optional(),
200200
}),
@@ -342,7 +342,7 @@ query:
342342

343343
describe("schema getters", () => {
344344
it("returns the correct zod schema", () => {
345-
const engine = MarkdownDb.cwd(testPatternsDir).setConfigSchema(
345+
const engine = MarkdownDb.cwd(testPatternsDir).setEntrySchema(
346346
z.object({
347347
status: z.string(),
348348
priority: z.number(),
@@ -372,7 +372,7 @@ query:
372372
});
373373

374374
it("generates valid JSON schema", () => {
375-
const engine = MarkdownDb.cwd(testPatternsDir).setConfigSchema(
375+
const engine = MarkdownDb.cwd(testPatternsDir).setEntrySchema(
376376
z.object({
377377
status: z.enum(["blocked", "ok"]),
378378
}),
@@ -401,7 +401,7 @@ query:
401401
});
402402

403403
it("throws error for missing required config fields", async () => {
404-
const engine = MarkdownDb.cwd(testInvalidPatternsDir).setConfigSchema(
404+
const engine = MarkdownDb.cwd(testInvalidPatternsDir).setEntrySchema(
405405
z.object({
406406
status: z.string(),
407407
}),
@@ -496,7 +496,7 @@ This file has no frontmatter header at all.`);
496496
it("throws specific error when frontmatter is missing but required fields exist in schema", async () => {
497497
const engine = MarkdownDb.cwd<TestInput>(testOptionalFrontmatterDir)
498498
.setQueryEngine(createTestQueryEngine())
499-
.setConfigSchema(
499+
.setEntrySchema(
500500
z.object({
501501
requiredField: z.string(),
502502
}),
@@ -548,7 +548,7 @@ Content with empty frontmatter`);
548548

549549
describe("type inference", () => {
550550
it("correctly infers config type", () => {
551-
const _engine = MarkdownDb.cwd(testPatternsDir).setConfigSchema(
551+
const _engine = MarkdownDb.cwd(testPatternsDir).setEntrySchema(
552552
z.object({
553553
status: z.enum(["blocked", "ok"]),
554554
priority: z.number().optional(),

0 commit comments

Comments
 (0)