@quillmark/registry 0.5.2 → 0.6.0
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/validate.d.ts +103 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +64 -0
- package/dist/validate.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export { HttpSource } from './sources/http-source.js';
|
|
|
7
7
|
export type { HttpSourceOptions } from './sources/http-source.js';
|
|
8
8
|
export { QuillRegistry } from './registry.js';
|
|
9
9
|
export type { QuillRegistryOptions } from './registry.js';
|
|
10
|
+
export { validateQuills } from './validate.js';
|
|
11
|
+
export type { QuillValidationEngine, ValidateQuillsOptions, QuillValidationEntry, ValidateQuillsResult, } from './validate.js';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EACX,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,6 @@ export { FileSystemSource } from './sources/file-system-source.js';
|
|
|
7
7
|
export { HttpSource } from './sources/http-source.js';
|
|
8
8
|
// Registry
|
|
9
9
|
export { QuillRegistry } from './registry.js';
|
|
10
|
+
// Validation
|
|
11
|
+
export { validateQuills } from './validate.js';
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,SAAS;AACT,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,UAAU;AACV,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,WAAW;AACX,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,SAAS;AACT,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,UAAU;AACV,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,WAAW;AACX,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { QuillmarkEngine } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Engine interface for quill validation.
|
|
4
|
+
*
|
|
5
|
+
* Extends the base {@link QuillmarkEngine} with `render()` so the validator
|
|
6
|
+
* can compile each quill's example document end-to-end.
|
|
7
|
+
*
|
|
8
|
+
* Structurally compatible with `@quillmark/wasm`'s `Quillmark` class —
|
|
9
|
+
* pass a `Quillmark` instance directly without adapters:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Quillmark } from '@quillmark/wasm';
|
|
13
|
+
* const engine: QuillValidationEngine = new Quillmark();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export interface QuillValidationEngine extends QuillmarkEngine {
|
|
17
|
+
render(parsed: {
|
|
18
|
+
fields: Record<string, unknown>;
|
|
19
|
+
quillName: string;
|
|
20
|
+
}, opts: {
|
|
21
|
+
format?: string;
|
|
22
|
+
}): {
|
|
23
|
+
artifacts: Array<{
|
|
24
|
+
bytes: Uint8Array;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for {@link validateQuills}.
|
|
30
|
+
*
|
|
31
|
+
* Example usage in a collection repo's test suite:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { validateQuills } from '@quillmark/registry';
|
|
35
|
+
* import { Quillmark, init } from '@quillmark/wasm';
|
|
36
|
+
*
|
|
37
|
+
* init();
|
|
38
|
+
* const wasm = new Quillmark();
|
|
39
|
+
* try {
|
|
40
|
+
* const { passed, failed, results } = await validateQuills({
|
|
41
|
+
* quillsDir: './quills',
|
|
42
|
+
* engine: wasm,
|
|
43
|
+
* parseMarkdown: Quillmark.parseMarkdown,
|
|
44
|
+
* });
|
|
45
|
+
* console.log(`${passed} passed, ${failed} failed`);
|
|
46
|
+
* } finally {
|
|
47
|
+
* wasm.free();
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export interface ValidateQuillsOptions {
|
|
52
|
+
/** Path to the quills directory following the `name/version/` layout. */
|
|
53
|
+
quillsDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* Initialised WASM engine instance (e.g. `new Quillmark()` from `@quillmark/wasm`).
|
|
56
|
+
*
|
|
57
|
+
* Must support `registerQuill`, `resolveQuill`, `listQuills`, and `render`.
|
|
58
|
+
*/
|
|
59
|
+
engine: QuillValidationEngine;
|
|
60
|
+
/**
|
|
61
|
+
* Static markdown parser (e.g. `Quillmark.parseMarkdown` from `@quillmark/wasm`).
|
|
62
|
+
*/
|
|
63
|
+
parseMarkdown: (markdown: string) => {
|
|
64
|
+
fields: Record<string, unknown>;
|
|
65
|
+
quillName: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Validation result for a single quill version. */
|
|
69
|
+
export interface QuillValidationEntry {
|
|
70
|
+
name: string;
|
|
71
|
+
version: string;
|
|
72
|
+
/** Whether `registerQuill()` succeeded (validates quill structure). */
|
|
73
|
+
registered: boolean;
|
|
74
|
+
/** Whether the quill's example document rendered to non-empty artifacts. */
|
|
75
|
+
rendered: boolean;
|
|
76
|
+
/** Error message if any validation step failed. */
|
|
77
|
+
error?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Aggregate result returned by {@link validateQuills}. */
|
|
80
|
+
export interface ValidateQuillsResult {
|
|
81
|
+
results: QuillValidationEntry[];
|
|
82
|
+
/** Number of quills that passed all validation steps. */
|
|
83
|
+
passed: number;
|
|
84
|
+
/** Number of quills that failed at least one validation step. */
|
|
85
|
+
failed: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validates every quill in a directory by registering it with the WASM engine
|
|
89
|
+
* and rendering its example document.
|
|
90
|
+
*
|
|
91
|
+
* Designed for Quill collection repositories to run as a CI gate before release.
|
|
92
|
+
* Each quill goes through two validation stages:
|
|
93
|
+
*
|
|
94
|
+
* 1. **Registration** — `registerQuill()` validates the quill's file structure,
|
|
95
|
+
* `Quill.yaml` schema, and Typst package layout.
|
|
96
|
+
* 2. **Render** — if the quill includes an example document, it is parsed and
|
|
97
|
+
* rendered to the first supported output format (e.g. PDF), confirming that
|
|
98
|
+
* the Typst template compiles without error.
|
|
99
|
+
*
|
|
100
|
+
* @returns Per-quill results and aggregate pass/fail counts.
|
|
101
|
+
*/
|
|
102
|
+
export declare function validateQuills(options: ValidateQuillsOptions): Promise<ValidateQuillsResult>;
|
|
103
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC7D,MAAM,CACL,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAC9D,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACvB;QAAE,SAAS,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,UAAU,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,qBAAqB;IACrC,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,MAAM,EAAE,qBAAqB,CAAC;IAE9B;;OAEG;IACH,aAAa,EAAE,CACd,QAAQ,EAAE,MAAM,KACZ;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC;IAClB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,2DAA2D;AAC3D,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CAkD/B"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FileSystemSource } from './sources/file-system-source.js';
|
|
2
|
+
import { QuillRegistry } from './registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates every quill in a directory by registering it with the WASM engine
|
|
5
|
+
* and rendering its example document.
|
|
6
|
+
*
|
|
7
|
+
* Designed for Quill collection repositories to run as a CI gate before release.
|
|
8
|
+
* Each quill goes through two validation stages:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Registration** — `registerQuill()` validates the quill's file structure,
|
|
11
|
+
* `Quill.yaml` schema, and Typst package layout.
|
|
12
|
+
* 2. **Render** — if the quill includes an example document, it is parsed and
|
|
13
|
+
* rendered to the first supported output format (e.g. PDF), confirming that
|
|
14
|
+
* the Typst template compiles without error.
|
|
15
|
+
*
|
|
16
|
+
* @returns Per-quill results and aggregate pass/fail counts.
|
|
17
|
+
*/
|
|
18
|
+
export async function validateQuills(options) {
|
|
19
|
+
const { quillsDir, engine, parseMarkdown } = options;
|
|
20
|
+
const source = new FileSystemSource(quillsDir);
|
|
21
|
+
const registry = new QuillRegistry({ source, engine });
|
|
22
|
+
const manifest = await source.getManifest();
|
|
23
|
+
const results = [];
|
|
24
|
+
for (const quill of manifest.quills) {
|
|
25
|
+
const entry = {
|
|
26
|
+
name: quill.name,
|
|
27
|
+
version: quill.version,
|
|
28
|
+
registered: false,
|
|
29
|
+
rendered: false,
|
|
30
|
+
};
|
|
31
|
+
try {
|
|
32
|
+
// Stage 1: load + register (validates quill structure)
|
|
33
|
+
const ref = `${quill.name}@${quill.version}`;
|
|
34
|
+
await registry.resolve(ref);
|
|
35
|
+
entry.registered = true;
|
|
36
|
+
// Stage 2: render the example document
|
|
37
|
+
const info = engine.resolveQuill(quill.name);
|
|
38
|
+
if (info?.example && info.supportedFormats?.length > 0) {
|
|
39
|
+
// Replace the colon-style QUILL reference (e.g. "name:0.1") with
|
|
40
|
+
// the engine-compatible "@" format (e.g. "name@0.1.0")
|
|
41
|
+
const exampleMd = info.example.replace(/^QUILL:.*$/m, `QUILL: ${ref}`);
|
|
42
|
+
const parsed = parseMarkdown(exampleMd);
|
|
43
|
+
const result = engine.render(parsed, {
|
|
44
|
+
format: info.supportedFormats[0],
|
|
45
|
+
});
|
|
46
|
+
const firstArtifact = result.artifacts[0];
|
|
47
|
+
if (!firstArtifact || firstArtifact.bytes.length === 0) {
|
|
48
|
+
entry.error = 'Render produced no output artifacts';
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
entry.rendered = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
entry.error = err instanceof Error ? err.message : String(err);
|
|
57
|
+
}
|
|
58
|
+
results.push(entry);
|
|
59
|
+
}
|
|
60
|
+
const failed = results.filter((r) => r.error !== undefined).length;
|
|
61
|
+
const passed = results.length - failed;
|
|
62
|
+
return { results, passed, failed };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAuF9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,OAA8B;IAE9B,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5C,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,KAAK,GAAyB;YACnC,IAAI,EAAE,KAAK,CAA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