@h-rig/validator-kit 0.0.6-alpha.9 → 0.0.6-alpha.91
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/src/checks.d.ts +9 -0
- package/dist/src/content.d.ts +7 -0
- package/dist/src/fs.d.ts +19 -0
- package/dist/src/grep.d.ts +6 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/result.d.ts +27 -0
- package/package.json +5 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Checker } from "./result";
|
|
2
|
+
/** Check a file exists. */
|
|
3
|
+
export declare function requireFileCheck(checker: Checker, path: string, checkName: string): void;
|
|
4
|
+
/** Check a directory exists. */
|
|
5
|
+
export declare function requireDirCheck(checker: Checker, path: string, checkName: string): void;
|
|
6
|
+
/** Validate standard package structure: package.json + tsconfig.json + src/. */
|
|
7
|
+
export declare function requirePackageStructure(checker: Checker, serviceDir: string, prefix: string): void;
|
|
8
|
+
/** Check test files exist in a project directory. */
|
|
9
|
+
export declare function checkTestsExist(checker: Checker, projectDir: string, checkName: string): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Checker } from "./result";
|
|
2
|
+
/** Check markdown file has section headings matching each term. */
|
|
3
|
+
export declare function requireMarkdownSections(checker: Checker, filePath: string, sections: string[]): void;
|
|
4
|
+
/** Check document contains terms (case-insensitive). Pattern can include | for alternation. */
|
|
5
|
+
export declare function requireTerms(checker: Checker, filePath: string, terms: Record<string, string>): void;
|
|
6
|
+
/** Parse JSON and check key paths exist (dot-separated, e.g. ".summary.total"). */
|
|
7
|
+
export declare function requireJsonKeys(checker: Checker, filePath: string, keys: string[]): void;
|
package/dist/src/fs.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Return the first existing path from candidates, or null. */
|
|
2
|
+
export declare function findFirstFile(candidates: string[]): string | null;
|
|
3
|
+
/** Read a file as UTF-8 or return null if missing. */
|
|
4
|
+
export declare function readFileSafe(path: string): string | null;
|
|
5
|
+
export declare function requireFile(path: string, id: string, description: string): string;
|
|
6
|
+
/** Check if file content matches a pattern. */
|
|
7
|
+
export declare function fileContains(path: string, pattern: RegExp): boolean;
|
|
8
|
+
/** Walk a directory tree, calling fn for each file. Skips node_modules/.git. */
|
|
9
|
+
export declare function walkDir(dir: string, fn: (filePath: string) => void): void;
|
|
10
|
+
/** List subdirectories of a directory. */
|
|
11
|
+
export declare function listSubdirs(dir: string): string[];
|
|
12
|
+
/** Count .ts files in a directory (excluding tests). */
|
|
13
|
+
export declare function countTsFiles(dir: string): number;
|
|
14
|
+
/** Count test files (.test.ts / .spec.ts) in a directory. */
|
|
15
|
+
export declare function countTestFiles(dir: string): number;
|
|
16
|
+
/** Find first directory matching candidates. */
|
|
17
|
+
export declare function findFirstDir(candidates: string[]): string | null;
|
|
18
|
+
/** Find files by name pattern (glob-free, recursive). */
|
|
19
|
+
export declare function findFilesByName(dir: string, namePattern: RegExp): string[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Find files whose content matches pattern. Optionally filter by extension. */
|
|
2
|
+
export declare function grepFiles(dir: string, pattern: RegExp, extensions?: string[]): string[];
|
|
3
|
+
/** Count files matching pattern. */
|
|
4
|
+
export declare function grepCount(dir: string, pattern: RegExp, extensions?: string[]): number;
|
|
5
|
+
/** Get matching lines from files in a directory. */
|
|
6
|
+
export declare function grepLines(dir: string, pattern: RegExp, extensions?: string[], maxLines?: number): string[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ValidatorOutput } from "./result";
|
|
2
|
+
export { pass, fail, error, Checker } from "./result";
|
|
3
|
+
export { findFirstFile, readFileSafe, requireFile, fileContains, walkDir, listSubdirs, countTsFiles, countTestFiles, findFirstDir, findFilesByName, } from "./fs";
|
|
4
|
+
export { grepFiles, grepCount, grepLines } from "./grep";
|
|
5
|
+
export { requireMarkdownSections, requireTerms, requireJsonKeys, } from "./content";
|
|
6
|
+
export { requireFileCheck, requireDirCheck, requirePackageStructure, checkTestsExist, } from "./checks";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validator output contract and result helpers.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `ValidatorOutput` shape, single-shot exit helpers (`pass`,
|
|
5
|
+
* `fail`, `error`), and the multi-check `Checker` accumulator.
|
|
6
|
+
*
|
|
7
|
+
* Moved from packages/runtime/src/control-plane/validators/shared.ts
|
|
8
|
+
* in Phase 3 Task 3.3 of the Rig extraction.
|
|
9
|
+
*/
|
|
10
|
+
export type ValidatorOutput = {
|
|
11
|
+
id: string;
|
|
12
|
+
passed: boolean;
|
|
13
|
+
summary: string;
|
|
14
|
+
details?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function pass(id: string, summary: string): never;
|
|
17
|
+
export declare function fail(id: string, summary: string, details?: string): never;
|
|
18
|
+
export declare function error(id: string, message: string): never;
|
|
19
|
+
export declare class Checker {
|
|
20
|
+
private results;
|
|
21
|
+
pass(name: string): void;
|
|
22
|
+
fail(name: string, reason: string): void;
|
|
23
|
+
/** Fail and immediately emit — for fatal precondition failures. */
|
|
24
|
+
fatal(id: string, reason: string): never;
|
|
25
|
+
/** Print JSON result and exit. */
|
|
26
|
+
emit(id: string): never;
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/validator-kit",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.91",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Rig
|
|
5
|
+
"description": "Validator schema helpers for Rig plugin contributions; not a validation runtime.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"types": "./dist/src/index.d.ts",
|
|
13
14
|
"import": "./dist/src/index.js"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
@@ -18,8 +19,9 @@
|
|
|
18
19
|
},
|
|
19
20
|
"main": "./dist/src/index.js",
|
|
20
21
|
"module": "./dist/src/index.js",
|
|
22
|
+
"types": "./dist/src/index.d.ts",
|
|
21
23
|
"dependencies": {
|
|
22
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
24
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.91",
|
|
23
25
|
"effect": "4.0.0-beta.78"
|
|
24
26
|
}
|
|
25
27
|
}
|