@modality-counter/core 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -850,7 +850,7 @@ ${r.join(`
|
|
|
850
850
|
\u274C FAILURES (${r.length}/${t.length}):
|
|
851
851
|
${r.join(`
|
|
852
852
|
`)}
|
|
853
|
-
`),new Error(`Validation failed for ${r.length} files.`);console.log(`\u2705 Validated ${t.length} personas`),FXs(r.length).toBe(0)})})}import{describe as rlt,test as qse,expect as iA,beforeAll as qXs}from"bun:test";import{readFileSync as BXs}from"fs";rlt("Template Schema Unit Tests",()=>{qse("Should catch all invalid frontmatter patterns",()=>{[{name:"missing-name",template:{description:"Valid description","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}},{name:"missing-description",template:{name:"Valid Name","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}},{name:"empty-name",template:{name:"",description:"Valid description","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}},{name:"empty-description",template:{name:"Valid Name",description:"","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}}].forEach(({template:
|
|
853
|
+
`),new Error(`Validation failed for ${r.length} files.`);console.log(`\u2705 Validated ${t.length} personas`),FXs(r.length).toBe(0)})})}import{describe as rlt,test as qse,expect as iA,beforeAll as qXs}from"bun:test";import{readFileSync as BXs}from"fs";function VXs(e){let t=R1o(e);rlt("Template Schema Unit Tests",()=>{qse("Should catch all invalid frontmatter patterns",()=>{[{name:"missing-name",template:{description:"Valid description","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}},{name:"missing-description",template:{name:"Valid Name","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}},{name:"empty-name",template:{name:"",description:"Valid description","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}},{name:"empty-description",template:{name:"Valid Name",description:"","my-tmpl":{template:{output:{format:"markdown"}},sections:{intro:{title:"Intro"}}}}}].forEach(({template:i})=>{let n=Qz(i);iA(n.success).toBe(!1),iA(n.errors?.length).toBeGreaterThan(0)})}),qse("Should catch all invalid structure patterns",()=>{[{name:"missing-sections",template:{name:"Valid Name",description:"Valid description","my-tmpl":{template:{output:{format:"markdown"}},execution_flow:["Execute"]}}}].forEach(({template:i})=>{let n=Qz(i);iA(n.success).toBe(!1),iA(n.errors?.length).toBeGreaterThan(0)})})}),rlt("Template Validation with Zod Schemas",()=>{let r=new Map;qXs(async()=>{let i=t.map(async({filename:n,fullPath:o})=>{try{let a=await $R(o),s=BXs(o,"utf-8"),c=Aee(s),u={name:c.name||a.name,description:c.description||a.description,...a};r.set(n,u)}catch(a){console.warn(`Warning: Failed to pre-load ${n}:`,a),r.set(n,null)}});await Promise.all(i),console.log(`\u2705 Pre-loaded ${r.size} template files for testing`)}),rlt("Auto-Discovery Template Validation",()=>{qse("All template files should pass comprehensive validation",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping template validation - no templates found");return}let i=[],n=0;for(let{filename:o}of t){let a=r.get(o);if(!a){i.push(`\u{1F4C4} ${o}:
|
|
854
854
|
\u2192 No cached data available. File may be missing, unreadable, or contain invalid YAML.`);continue}let s=Qz(a);if(s.success)iA(s.data).toBeDefined(),n++;else{let c=s.errors?.map(u=>`
|
|
855
855
|
\u2192 ${u}`).join("")||"Unknown validation error";i.push(`\u{1F4C4} ${o}:${c}`)}}if(i.length>0){let o=i.map(a=>` ${a}`).join(`
|
|
856
856
|
`);throw console.error(`
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod-Based Template Validator with Enhanced YAML Validation
|
|
3
|
+
*
|
|
4
|
+
* This test suite uses TypeScript-first Zod schemas for template validation,
|
|
5
|
+
* ensuring type-safe validation with superior error messages.
|
|
6
|
+
* Performance optimized with caching to prevent repeated file I/O.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Type-safe validation with automatic TypeScript types
|
|
10
|
+
* - Runtime validation with detailed error paths
|
|
11
|
+
* - Comprehensive template structure validation
|
|
12
|
+
* - Quality metrics validation with precise scoring
|
|
13
|
+
* - EXPLICIT YAML format validation - any invalid YAML will cause test failure
|
|
14
|
+
* - Enhanced error handling for both YAML syntax and template structure errors
|
|
15
|
+
*/
|
|
1
16
|
/**
|
|
2
17
|
* Setup template validation tests - can be imported and reused in other projects
|
|
3
18
|
*/
|
package/package.json
CHANGED