@openuji/render-respec 0.1.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/README.md +100 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +90 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +214 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +81 -0
- package/dist/model.js.map +1 -0
- package/dist/render/diagnostics.d.ts +19 -0
- package/dist/render/diagnostics.d.ts.map +1 -0
- package/dist/render/diagnostics.js +63 -0
- package/dist/render/diagnostics.js.map +1 -0
- package/dist/render/html.d.ts +8 -0
- package/dist/render/html.d.ts.map +1 -0
- package/dist/render/html.js +174 -0
- package/dist/render/html.js.map +1 -0
- package/dist/render/toc.d.ts +16 -0
- package/dist/render/toc.d.ts.map +1 -0
- package/dist/render/toc.js +60 -0
- package/dist/render/toc.js.map +1 -0
- package/dist/templates/respec.html +355 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @openuji/render-respec
|
|
2
|
+
|
|
3
|
+
Generate ReSpec-compatible HTML from specification source files using the Speculator AST pipeline.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Server-Side Rendering**: Produces static HTML similar to what ReSpec would generate
|
|
8
|
+
- **Speculator Integration**: Uses Speculator pipeline to build AST with all indexes and resolutions
|
|
9
|
+
- **Diagnostics**: Integrates speculator-lint for aggregating errors and warnings in-place
|
|
10
|
+
- **ReSpec Compatible**: Generates HTML with 100% look and feel of classical ReSpec template
|
|
11
|
+
- **Markdown & HTML**: Accepts both Markdown and HTML spec source files
|
|
12
|
+
- **Complete Documents**: Ships complete `<html/>` documents, similar to vocab-build
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @openuji/render-respec
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Programmatic API
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { renderRespec } from '@openuji/render-respec';
|
|
26
|
+
|
|
27
|
+
const result = await renderRespec({
|
|
28
|
+
input: 'spec/index.md',
|
|
29
|
+
config: 'spec/config.respec.json',
|
|
30
|
+
output: 'dist/index.html',
|
|
31
|
+
strict: false,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (result.success) {
|
|
35
|
+
console.log('Generated:', result.outputPath);
|
|
36
|
+
console.log('Diagnostics:', result.diagnostics);
|
|
37
|
+
} else {
|
|
38
|
+
console.error('Errors:', result.errors);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### CLI
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Render spec to HTML
|
|
46
|
+
render-respec render -i spec/index.md -c spec/config.respec.json -o dist/index.html
|
|
47
|
+
|
|
48
|
+
# Validate spec without rendering
|
|
49
|
+
render-respec validate -i spec/index.md -c spec/config.respec.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
Create a `config.respec.json` file that mirrors standard ReSpec configuration:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"specStatus": "ED",
|
|
59
|
+
"shortName": "my-spec",
|
|
60
|
+
"subtitle": "My Specification",
|
|
61
|
+
"editors": [
|
|
62
|
+
{
|
|
63
|
+
"name": "Editor Name",
|
|
64
|
+
"email": "editor@example.com",
|
|
65
|
+
"company": "Company",
|
|
66
|
+
"companyURL": "https://example.com"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"publishDate": "2025-12-25",
|
|
70
|
+
"maxTocLevel": 3,
|
|
71
|
+
"github": "org/repo"
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Supported Config Options
|
|
76
|
+
|
|
77
|
+
- `specStatus`: Document status (ED, FPWD, WD, CR, PR, REC, etc.)
|
|
78
|
+
- `shortName`: Short name for the spec
|
|
79
|
+
- `subtitle`: Optional subtitle
|
|
80
|
+
- `editors`: Array of editor objects
|
|
81
|
+
- `authors`: Array of author objects
|
|
82
|
+
- `publishDate`: Publication date (YYYY-MM-DD)
|
|
83
|
+
- `previousPublishDate`: Previous publication date
|
|
84
|
+
- `group`: Working group name
|
|
85
|
+
- `github`: GitHub repository (org/repo format)
|
|
86
|
+
- `maxTocLevel`: Maximum TOC depth (default: 3)
|
|
87
|
+
- `copyrightStart`: Copyright start year
|
|
88
|
+
- `logos`: Custom logo configurations
|
|
89
|
+
|
|
90
|
+
## How It Works
|
|
91
|
+
|
|
92
|
+
1. **Parse**: Loads spec source file (HTML or Markdown)
|
|
93
|
+
2. **Build AST**: Runs Speculator pipeline with transform, index, and resolve phases
|
|
94
|
+
3. **Lint**: Runs speculator-lint to collect diagnostics
|
|
95
|
+
4. **Render**: Generates ReSpec-compatible HTML with diagnostics displayed inline
|
|
96
|
+
5. **Output**: Writes complete HTML document
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { renderRespec, validateSpec } from './index.js';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
program
|
|
6
|
+
.name('render-respec')
|
|
7
|
+
.description('Generate ReSpec-compatible HTML from specification source files')
|
|
8
|
+
.version('0.1.0');
|
|
9
|
+
/**
|
|
10
|
+
* Render command
|
|
11
|
+
*/
|
|
12
|
+
program
|
|
13
|
+
.command('render')
|
|
14
|
+
.description('Render specification to ReSpec HTML')
|
|
15
|
+
.requiredOption('-i, --input <path>', 'Path to spec source file (HTML or Markdown)')
|
|
16
|
+
.option('-c, --config <path>', 'Path to config.respec.json')
|
|
17
|
+
.requiredOption('-o, --output <path>', 'Output HTML file path')
|
|
18
|
+
.option('-l, --lint-config <path>', 'Path to .speculatorlintrc.json')
|
|
19
|
+
.option('-s, --strict', 'Fail on any errors', false)
|
|
20
|
+
.action(async (options) => {
|
|
21
|
+
const config = {
|
|
22
|
+
input: options.input,
|
|
23
|
+
config: options.config,
|
|
24
|
+
output: options.output,
|
|
25
|
+
lintConfig: options.lintConfig,
|
|
26
|
+
strict: options.strict,
|
|
27
|
+
};
|
|
28
|
+
console.log('🔧 Rendering ReSpec HTML...');
|
|
29
|
+
console.log(` Input: ${config.input}`);
|
|
30
|
+
if (config.config) {
|
|
31
|
+
console.log(` Config: ${config.config}`);
|
|
32
|
+
}
|
|
33
|
+
console.log(` Output: ${config.output}`);
|
|
34
|
+
const result = await renderRespec(config);
|
|
35
|
+
if (result.success) {
|
|
36
|
+
console.log('\n✅ Render successful!\n');
|
|
37
|
+
console.log(`Generated: ${result.outputPath}`);
|
|
38
|
+
if (result.diagnostics && result.diagnostics.length > 0) {
|
|
39
|
+
console.log('\n📋 Diagnostics:');
|
|
40
|
+
const errorCount = result.diagnostics.filter(d => d.severity === 'error').length;
|
|
41
|
+
const warningCount = result.diagnostics.filter(d => d.severity === 'warning').length;
|
|
42
|
+
console.log(` ${errorCount} error(s), ${warningCount} warning(s)`);
|
|
43
|
+
if (config.strict && errorCount > 0) {
|
|
44
|
+
console.error('\n❌ Strict mode: failing due to errors');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.error('\n❌ Render failed:\n');
|
|
51
|
+
result.errors?.forEach(error => console.error(` ${error}`));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Validate command
|
|
57
|
+
*/
|
|
58
|
+
program
|
|
59
|
+
.command('validate')
|
|
60
|
+
.description('Validate specification without rendering')
|
|
61
|
+
.requiredOption('-i, --input <path>', 'Path to spec source file')
|
|
62
|
+
.option('-c, --config <path>', 'Path to config.respec.json')
|
|
63
|
+
.action(async (options) => {
|
|
64
|
+
console.log('🔍 Validating specification...');
|
|
65
|
+
console.log(` Input: ${options.input}`);
|
|
66
|
+
const result = await validateSpec(options.input, options.config);
|
|
67
|
+
if (result.success) {
|
|
68
|
+
console.log('\n✅ Validation successful!');
|
|
69
|
+
if (result.diagnostics && result.diagnostics.length > 0) {
|
|
70
|
+
const warningCount = result.diagnostics.filter(d => d.severity === 'warning').length;
|
|
71
|
+
const infoCount = result.diagnostics.filter(d => d.severity === 'info').length;
|
|
72
|
+
console.log(` ${warningCount} warning(s), ${infoCount} info message(s)`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.log(' No issues found');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.error('\n❌ Validation failed:\n');
|
|
80
|
+
if (result.diagnostics) {
|
|
81
|
+
result.diagnostics
|
|
82
|
+
.filter(d => d.severity === 'error')
|
|
83
|
+
.forEach(d => console.error(` [${d.code}] ${d.message}`));
|
|
84
|
+
}
|
|
85
|
+
result.errors?.forEach(error => console.error(` ${error}`));
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
program.parse();
|
|
90
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,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IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { validateRenderConfig, validateReSpecConfig } from './model.js';
|
|
2
|
+
import type { RenderConfig, RenderResult, ReSpecConfig } from './model.js';
|
|
3
|
+
export type { RenderConfig, RenderResult, ReSpecConfig };
|
|
4
|
+
export { validateRenderConfig, validateReSpecConfig };
|
|
5
|
+
/**
|
|
6
|
+
* Main render function: generates ReSpec-compatible HTML from spec source
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderRespec(config: RenderConfig): Promise<RenderResult>;
|
|
9
|
+
/**
|
|
10
|
+
* Validate a spec file and config without rendering
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateSpec(inputPath: string, configPath?: string): Promise<RenderResult>;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0C,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG3E,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;AAEtD;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CA4E9E;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAuDhG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
2
|
+
import { speculate, corePlugins } from '@openuji/speculator';
|
|
3
|
+
import { SpeculatorLinter, builtInRules } from '@openuji/speculator-lint';
|
|
4
|
+
import { RenderConfigSchema, ReSpecConfigSchema, validateRenderConfig, validateReSpecConfig } from './model.js';
|
|
5
|
+
import { generateHTML } from './render/html.js';
|
|
6
|
+
export { validateRenderConfig, validateReSpecConfig };
|
|
7
|
+
/**
|
|
8
|
+
* Main render function: generates ReSpec-compatible HTML from spec source
|
|
9
|
+
*/
|
|
10
|
+
export async function renderRespec(config) {
|
|
11
|
+
try {
|
|
12
|
+
// Validate and parse config
|
|
13
|
+
const parsedConfig = RenderConfigSchema.parse(config);
|
|
14
|
+
// Load ReSpec configuration if provided
|
|
15
|
+
let respecConfig = ReSpecConfigSchema.parse({});
|
|
16
|
+
if (parsedConfig.config) {
|
|
17
|
+
const configContent = await readFile(parsedConfig.config, 'utf-8');
|
|
18
|
+
const configData = JSON.parse(configContent);
|
|
19
|
+
// Support both unified config (with 'respec' key) and standalone respec config
|
|
20
|
+
const respecData = configData.respec || configData;
|
|
21
|
+
respecConfig = ReSpecConfigSchema.parse(respecData);
|
|
22
|
+
}
|
|
23
|
+
// Run Speculator pipeline to build AST with indexes and resolution
|
|
24
|
+
console.log('🔍 Building AST with Speculator...');
|
|
25
|
+
const speculateResult = await speculate({
|
|
26
|
+
entry: parsedConfig.input,
|
|
27
|
+
plugins: corePlugins, // Use core plugins for transform, index, resolve
|
|
28
|
+
});
|
|
29
|
+
if (!speculateResult.workspace) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
errors: ['Failed to build AST: workspace is undefined'],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const workspace = speculateResult.workspace;
|
|
36
|
+
// Build document levels map
|
|
37
|
+
const documentLevels = new Map();
|
|
38
|
+
workspace.documents.forEach((doc, index) => {
|
|
39
|
+
const file = doc.sourcePos?.file || `doc-${index}`;
|
|
40
|
+
documentLevels.set(file, index);
|
|
41
|
+
});
|
|
42
|
+
// Run Speculator-lint to collect diagnostics
|
|
43
|
+
console.log('🔍 Running linter...');
|
|
44
|
+
// Use built-in rules by default
|
|
45
|
+
const linter = new SpeculatorLinter(builtInRules);
|
|
46
|
+
const lintResult = await linter.lint({
|
|
47
|
+
workspace,
|
|
48
|
+
documentLevels,
|
|
49
|
+
});
|
|
50
|
+
// Generate HTML using the AST, indexes, and diagnostics
|
|
51
|
+
console.log('📝 Generating ReSpec HTML...');
|
|
52
|
+
const html = await generateHTML(workspace, respecConfig, lintResult);
|
|
53
|
+
// Write output
|
|
54
|
+
await writeFile(parsedConfig.output, html, 'utf-8');
|
|
55
|
+
// Format diagnostics for result
|
|
56
|
+
const formattedDiagnostics = lintResult.diagnostics.map((d) => ({
|
|
57
|
+
code: d.code,
|
|
58
|
+
severity: d.severity,
|
|
59
|
+
message: d.message,
|
|
60
|
+
file: d.file,
|
|
61
|
+
line: d.sourcePos?.line,
|
|
62
|
+
column: d.sourcePos?.column,
|
|
63
|
+
}));
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
outputPath: parsedConfig.output,
|
|
67
|
+
diagnostics: formattedDiagnostics,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate a spec file and config without rendering
|
|
79
|
+
*/
|
|
80
|
+
export async function validateSpec(inputPath, configPath) {
|
|
81
|
+
try {
|
|
82
|
+
// Load ReSpec configuration if provided
|
|
83
|
+
if (configPath) {
|
|
84
|
+
const configContent = await readFile(configPath, 'utf-8');
|
|
85
|
+
const configData = JSON.parse(configContent);
|
|
86
|
+
validateReSpecConfig(configData);
|
|
87
|
+
}
|
|
88
|
+
// Run Speculator pipeline
|
|
89
|
+
const speculateResult = await speculate({
|
|
90
|
+
entry: inputPath,
|
|
91
|
+
plugins: corePlugins,
|
|
92
|
+
});
|
|
93
|
+
if (!speculateResult.workspace) {
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
errors: ['Failed to validate: workspace is undefined'],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Build document levels map
|
|
100
|
+
const documentLevels = new Map();
|
|
101
|
+
speculateResult.workspace.documents.forEach((doc, index) => {
|
|
102
|
+
const file = doc.sourcePos?.file || `doc-${index}`;
|
|
103
|
+
documentLevels.set(file, index);
|
|
104
|
+
});
|
|
105
|
+
// Run linter
|
|
106
|
+
const linter = new SpeculatorLinter(builtInRules);
|
|
107
|
+
const lintResult = await linter.lint({
|
|
108
|
+
workspace: speculateResult.workspace,
|
|
109
|
+
documentLevels,
|
|
110
|
+
});
|
|
111
|
+
const hasErrors = lintResult.diagnostics.some((d) => d.severity === 'error');
|
|
112
|
+
return {
|
|
113
|
+
success: !hasErrors,
|
|
114
|
+
diagnostics: lintResult.diagnostics.map((d) => ({
|
|
115
|
+
code: d.code,
|
|
116
|
+
severity: d.severity,
|
|
117
|
+
message: d.message,
|
|
118
|
+
file: d.file,
|
|
119
|
+
line: d.sourcePos?.line,
|
|
120
|
+
column: d.sourcePos?.column,
|
|
121
|
+
})),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMapp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
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* ReSpec configuration schema (mirrors standard ReSpec config)
|
|
4
|
+
* Based on: https://respec.org/docs/
|
|
5
|
+
*/
|
|
6
|
+
export declare const ReSpecConfigSchema: z.ZodObject<{
|
|
7
|
+
specStatus: z.ZodDefault<z.ZodEnum<["ED", "FPWD", "WD", "CR", "PR", "REC", "NOTE", "unofficial"]>>;
|
|
8
|
+
shortName: z.ZodOptional<z.ZodString>;
|
|
9
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
10
|
+
publishDate: z.ZodOptional<z.ZodString>;
|
|
11
|
+
previousPublishDate: z.ZodOptional<z.ZodString>;
|
|
12
|
+
previousMaturity: z.ZodOptional<z.ZodString>;
|
|
13
|
+
editors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
email: z.ZodOptional<z.ZodString>;
|
|
16
|
+
company: z.ZodOptional<z.ZodString>;
|
|
17
|
+
companyURL: z.ZodOptional<z.ZodString>;
|
|
18
|
+
w3cid: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
name: string;
|
|
21
|
+
email?: string | undefined;
|
|
22
|
+
company?: string | undefined;
|
|
23
|
+
companyURL?: string | undefined;
|
|
24
|
+
w3cid?: number | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
name: string;
|
|
27
|
+
email?: string | undefined;
|
|
28
|
+
company?: string | undefined;
|
|
29
|
+
companyURL?: string | undefined;
|
|
30
|
+
w3cid?: number | undefined;
|
|
31
|
+
}>, "many">>;
|
|
32
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
email: z.ZodOptional<z.ZodString>;
|
|
35
|
+
company: z.ZodOptional<z.ZodString>;
|
|
36
|
+
companyURL: z.ZodOptional<z.ZodString>;
|
|
37
|
+
w3cid: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
name: string;
|
|
40
|
+
email?: string | undefined;
|
|
41
|
+
company?: string | undefined;
|
|
42
|
+
companyURL?: string | undefined;
|
|
43
|
+
w3cid?: number | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
name: string;
|
|
46
|
+
email?: string | undefined;
|
|
47
|
+
company?: string | undefined;
|
|
48
|
+
companyURL?: string | undefined;
|
|
49
|
+
w3cid?: number | undefined;
|
|
50
|
+
}>, "many">>;
|
|
51
|
+
group: z.ZodOptional<z.ZodString>;
|
|
52
|
+
wg: z.ZodOptional<z.ZodString>;
|
|
53
|
+
wgURI: z.ZodOptional<z.ZodString>;
|
|
54
|
+
wgPublicList: z.ZodOptional<z.ZodString>;
|
|
55
|
+
wgPatentURI: z.ZodOptional<z.ZodString>;
|
|
56
|
+
logos: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
57
|
+
src: z.ZodString;
|
|
58
|
+
alt: z.ZodString;
|
|
59
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
url: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
src: string;
|
|
64
|
+
alt: string;
|
|
65
|
+
width?: number | undefined;
|
|
66
|
+
height?: number | undefined;
|
|
67
|
+
url?: string | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
src: string;
|
|
70
|
+
alt: string;
|
|
71
|
+
width?: number | undefined;
|
|
72
|
+
height?: number | undefined;
|
|
73
|
+
url?: string | undefined;
|
|
74
|
+
}>, "many">>;
|
|
75
|
+
copyrightStart: z.ZodOptional<z.ZodString>;
|
|
76
|
+
license: z.ZodOptional<z.ZodString>;
|
|
77
|
+
maxTocLevel: z.ZodDefault<z.ZodNumber>;
|
|
78
|
+
github: z.ZodOptional<z.ZodString>;
|
|
79
|
+
githubAPI: z.ZodOptional<z.ZodString>;
|
|
80
|
+
localBiblio: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
81
|
+
xref: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
lint: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
specStatus: "ED" | "FPWD" | "WD" | "CR" | "PR" | "REC" | "NOTE" | "unofficial";
|
|
85
|
+
maxTocLevel: number;
|
|
86
|
+
shortName?: string | undefined;
|
|
87
|
+
subtitle?: string | undefined;
|
|
88
|
+
publishDate?: string | undefined;
|
|
89
|
+
previousPublishDate?: string | undefined;
|
|
90
|
+
previousMaturity?: string | undefined;
|
|
91
|
+
editors?: {
|
|
92
|
+
name: string;
|
|
93
|
+
email?: string | undefined;
|
|
94
|
+
company?: string | undefined;
|
|
95
|
+
companyURL?: string | undefined;
|
|
96
|
+
w3cid?: number | undefined;
|
|
97
|
+
}[] | undefined;
|
|
98
|
+
authors?: {
|
|
99
|
+
name: string;
|
|
100
|
+
email?: string | undefined;
|
|
101
|
+
company?: string | undefined;
|
|
102
|
+
companyURL?: string | undefined;
|
|
103
|
+
w3cid?: number | undefined;
|
|
104
|
+
}[] | undefined;
|
|
105
|
+
group?: string | undefined;
|
|
106
|
+
wg?: string | undefined;
|
|
107
|
+
wgURI?: string | undefined;
|
|
108
|
+
wgPublicList?: string | undefined;
|
|
109
|
+
wgPatentURI?: string | undefined;
|
|
110
|
+
logos?: {
|
|
111
|
+
src: string;
|
|
112
|
+
alt: string;
|
|
113
|
+
width?: number | undefined;
|
|
114
|
+
height?: number | undefined;
|
|
115
|
+
url?: string | undefined;
|
|
116
|
+
}[] | undefined;
|
|
117
|
+
copyrightStart?: string | undefined;
|
|
118
|
+
license?: string | undefined;
|
|
119
|
+
github?: string | undefined;
|
|
120
|
+
githubAPI?: string | undefined;
|
|
121
|
+
localBiblio?: Record<string, any> | undefined;
|
|
122
|
+
xref?: boolean | undefined;
|
|
123
|
+
lint?: boolean | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
specStatus?: "ED" | "FPWD" | "WD" | "CR" | "PR" | "REC" | "NOTE" | "unofficial" | undefined;
|
|
126
|
+
shortName?: string | undefined;
|
|
127
|
+
subtitle?: string | undefined;
|
|
128
|
+
publishDate?: string | undefined;
|
|
129
|
+
previousPublishDate?: string | undefined;
|
|
130
|
+
previousMaturity?: string | undefined;
|
|
131
|
+
editors?: {
|
|
132
|
+
name: string;
|
|
133
|
+
email?: string | undefined;
|
|
134
|
+
company?: string | undefined;
|
|
135
|
+
companyURL?: string | undefined;
|
|
136
|
+
w3cid?: number | undefined;
|
|
137
|
+
}[] | undefined;
|
|
138
|
+
authors?: {
|
|
139
|
+
name: string;
|
|
140
|
+
email?: string | undefined;
|
|
141
|
+
company?: string | undefined;
|
|
142
|
+
companyURL?: string | undefined;
|
|
143
|
+
w3cid?: number | undefined;
|
|
144
|
+
}[] | undefined;
|
|
145
|
+
group?: string | undefined;
|
|
146
|
+
wg?: string | undefined;
|
|
147
|
+
wgURI?: string | undefined;
|
|
148
|
+
wgPublicList?: string | undefined;
|
|
149
|
+
wgPatentURI?: string | undefined;
|
|
150
|
+
logos?: {
|
|
151
|
+
src: string;
|
|
152
|
+
alt: string;
|
|
153
|
+
width?: number | undefined;
|
|
154
|
+
height?: number | undefined;
|
|
155
|
+
url?: string | undefined;
|
|
156
|
+
}[] | undefined;
|
|
157
|
+
copyrightStart?: string | undefined;
|
|
158
|
+
license?: string | undefined;
|
|
159
|
+
maxTocLevel?: number | undefined;
|
|
160
|
+
github?: string | undefined;
|
|
161
|
+
githubAPI?: string | undefined;
|
|
162
|
+
localBiblio?: Record<string, any> | undefined;
|
|
163
|
+
xref?: boolean | undefined;
|
|
164
|
+
lint?: boolean | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
export type ReSpecConfig = z.infer<typeof ReSpecConfigSchema>;
|
|
167
|
+
/**
|
|
168
|
+
* Render configuration for the render-respec tool
|
|
169
|
+
*/
|
|
170
|
+
export declare const RenderConfigSchema: z.ZodObject<{
|
|
171
|
+
input: z.ZodString;
|
|
172
|
+
config: z.ZodOptional<z.ZodString>;
|
|
173
|
+
output: z.ZodString;
|
|
174
|
+
strict: z.ZodDefault<z.ZodBoolean>;
|
|
175
|
+
lintConfig: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
input: string;
|
|
178
|
+
output: string;
|
|
179
|
+
strict: boolean;
|
|
180
|
+
config?: string | undefined;
|
|
181
|
+
lintConfig?: string | undefined;
|
|
182
|
+
}, {
|
|
183
|
+
input: string;
|
|
184
|
+
output: string;
|
|
185
|
+
config?: string | undefined;
|
|
186
|
+
strict?: boolean | undefined;
|
|
187
|
+
lintConfig?: string | undefined;
|
|
188
|
+
}>;
|
|
189
|
+
export type RenderConfig = z.infer<typeof RenderConfigSchema>;
|
|
190
|
+
/**
|
|
191
|
+
* Result from renderRespec()
|
|
192
|
+
*/
|
|
193
|
+
export interface RenderResult {
|
|
194
|
+
success: boolean;
|
|
195
|
+
outputPath?: string;
|
|
196
|
+
diagnostics?: Array<{
|
|
197
|
+
code: string;
|
|
198
|
+
severity: 'error' | 'warning' | 'info';
|
|
199
|
+
message: string;
|
|
200
|
+
file?: string;
|
|
201
|
+
line?: number;
|
|
202
|
+
column?: number;
|
|
203
|
+
}>;
|
|
204
|
+
errors?: string[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Validate ReSpec configuration
|
|
208
|
+
*/
|
|
209
|
+
export declare function validateReSpecConfig(config: unknown): ReSpecConfig;
|
|
210
|
+
/**
|
|
211
|
+
* Validate render configuration
|
|
212
|
+
*/
|
|
213
|
+
export declare function validateRenderConfig(config: unknown): RenderConfig;
|
|
214
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AA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
|
4
|
+
* Based on: https://respec.org/docs/
|
|
5
|
+
*/
|
|
6
|
+
export const ReSpecConfigSchema = z.object({
|
|
7
|
+
// Document metadata
|
|
8
|
+
specStatus: z.enum(['ED', 'FPWD', 'WD', 'CR', 'PR', 'REC', 'NOTE', 'unofficial']).default('ED'),
|
|
9
|
+
shortName: z.string().optional(),
|
|
10
|
+
subtitle: z.string().optional(),
|
|
11
|
+
// Publication dates
|
|
12
|
+
publishDate: z.string().optional(), // YYYY-MM-DD format
|
|
13
|
+
previousPublishDate: z.string().optional(),
|
|
14
|
+
previousMaturity: z.string().optional(),
|
|
15
|
+
// People
|
|
16
|
+
editors: z.array(z.object({
|
|
17
|
+
name: z.string(),
|
|
18
|
+
email: z.string().optional(),
|
|
19
|
+
company: z.string().optional(),
|
|
20
|
+
companyURL: z.string().optional(),
|
|
21
|
+
w3cid: z.number().optional(),
|
|
22
|
+
})).optional(),
|
|
23
|
+
authors: z.array(z.object({
|
|
24
|
+
name: z.string(),
|
|
25
|
+
email: z.string().optional(),
|
|
26
|
+
company: z.string().optional(),
|
|
27
|
+
companyURL: z.string().optional(),
|
|
28
|
+
w3cid: z.number().optional(),
|
|
29
|
+
})).optional(),
|
|
30
|
+
// Organization
|
|
31
|
+
group: z.string().optional(),
|
|
32
|
+
wg: z.string().optional(), // Working group name
|
|
33
|
+
wgURI: z.string().optional(),
|
|
34
|
+
wgPublicList: z.string().optional(),
|
|
35
|
+
wgPatentURI: z.string().optional(),
|
|
36
|
+
// Logos and branding
|
|
37
|
+
logos: z.array(z.object({
|
|
38
|
+
src: z.string(),
|
|
39
|
+
alt: z.string(),
|
|
40
|
+
width: z.number().optional(),
|
|
41
|
+
height: z.number().optional(),
|
|
42
|
+
url: z.string().optional(),
|
|
43
|
+
})).optional(),
|
|
44
|
+
// Copyright
|
|
45
|
+
copyrightStart: z.string().optional(),
|
|
46
|
+
license: z.string().optional(),
|
|
47
|
+
// Table of Contents
|
|
48
|
+
maxTocLevel: z.number().min(1).max(6).default(3),
|
|
49
|
+
// GitHub integration
|
|
50
|
+
github: z.string().optional(), // e.g., "org/repo"
|
|
51
|
+
githubAPI: z.string().optional(),
|
|
52
|
+
// Other options
|
|
53
|
+
localBiblio: z.record(z.any()).optional(),
|
|
54
|
+
xref: z.boolean().optional(),
|
|
55
|
+
lint: z.boolean().optional(),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Render configuration for the render-respec tool
|
|
59
|
+
*/
|
|
60
|
+
export const RenderConfigSchema = z.object({
|
|
61
|
+
// Input/output
|
|
62
|
+
input: z.string(),
|
|
63
|
+
config: z.string().optional(), // Path to config.respec.json
|
|
64
|
+
output: z.string(),
|
|
65
|
+
// Processing options
|
|
66
|
+
strict: z.boolean().default(false),
|
|
67
|
+
lintConfig: z.string().optional(), // Path to .speculatorlintrc.json
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Validate ReSpec configuration
|
|
71
|
+
*/
|
|
72
|
+
export function validateReSpecConfig(config) {
|
|
73
|
+
return ReSpecConfigSchema.parse(config);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validate render configuration
|
|
77
|
+
*/
|
|
78
|
+
export function validateRenderConfig(config) {
|
|
79
|
+
return RenderConfigSchema.parse(config);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,oBAAoB;IACpB,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,I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