test(validate): cover cu prayers, shared marker-type constant
- validate-data now scans cu/services/prayers (349 files; 331 -> 680 total). - marker types (TROPARION/KONTAKION/THEOTOKION/LITANY/COMMUNION) factored into PRAYER_NODE_TYPES with a keep-in-sync comment. - COMMUNION marker (cu COMMUNION/SUN.json) added per the same convention.
This commit is contained in:
1 parent
4f9f55b3f3
commit
69f3533c41
1 file changed
+19
-4
@@ -11,6 +11,16 @@ import { fileURLToPath } from 'url';
|
||||
const __dirname = new URL('.', import.meta.url).pathname;
|
||||
const DATA_DIR = join(__dirname, '..', 'static', 'data');
|
||||
|
||||
/**
|
||||
* Node types allowed in prayer files. Besides TEXT/HEADER content nodes,
|
||||
* imported prayers carry bare classification markers (no payload) that the
|
||||
* assembler intentionally ignores — keep this list in sync with the data.
|
||||
*/
|
||||
const PRAYER_NODE_TYPES = [
|
||||
'TEXT', 'HEADER',
|
||||
'TROPARION', 'KONTAKION', 'THEOTOKION', 'LITANY', 'COMMUNION',
|
||||
];
|
||||
|
||||
interface ValidationError {
|
||||
file: string;
|
||||
path: string;
|
||||
@@ -152,10 +162,8 @@ class Validator {
|
||||
continue;
|
||||
}
|
||||
const obj = node as Record<string, unknown>;
|
||||
// LITANY/THEOTOKION are bare classification markers (no payload):
|
||||
// TROPARION/KONTAKION have the same convention, content is TEXT/HEADER.
|
||||
if (!obj.type || !['TEXT', 'HEADER', 'TROPARION', 'KONTAKION', 'LITANY', 'THEOTOKION'].includes(obj.type as string)) {
|
||||
this.addError(path, `[${i}].type`, 'Type must be TEXT, HEADER, TROPARION, KONTAKION, LITANY or THEOTOKION');
|
||||
if (!obj.type || !PRAYER_NODE_TYPES.includes(obj.type as string)) {
|
||||
this.addError(path, `[${i}].type`, `Type must be one of: ${PRAYER_NODE_TYPES.join(', ')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,6 +273,13 @@ function main() {
|
||||
validator.validateDir(join(enDir, 'services', 'commands'), 'command');
|
||||
}
|
||||
|
||||
// Church Slavonic prayers share the same import format and marker types
|
||||
const cuDir = join(DATA_DIR, 'cu');
|
||||
if (existsSync(cuDir)) {
|
||||
console.log('Validating Church Slavonic data...');
|
||||
validator.validateDir(join(cuDir, 'services', 'prayers'), 'prayer');
|
||||
}
|
||||
|
||||
validator.printReport();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user