Skill Tracer
Skills › gstack › make-pdf › types.ts

types.ts

109 lines · make-pdf/src/types.ts at 3f79d81

1/**
2 * make-pdf — shared types.
3 *
4 * No runtime code. Imports are safe from any module.
5 */
6
7export type PageSize = "letter" | "a4" | "legal" | "tabloid";
8export type FontMode = "sans"; // v1: Helvetica only. Future: "serif" | "custom".
9
10/**
11 * Options for `$P generate` — the public CLI contract.
12 * Matches the flag set documented in the CEO plan.
13 */
14export type OutputFormat = "pdf" | "html" | "docx";
16export interface GenerateOptions {
17 input: string; // markdown input path
18 output?: string; // output path (default: /tmp/<slug>.<ext>)
20 // Output format (NOT --format, which is a --page-size alias):
21 // pdf — print-quality PDF through the browser: Aside, else gstack's own (default)
22 // html — single self-contained file, zero network references
23 // docx — content-fidelity Word document (diagrams embedded as PNG)
24 to?: OutputFormat;
26 // Page layout
27 margins?: string; // "1in" | "72pt" | "25mm" | "2.54cm"
28 marginTop?: string;
29 marginRight?: string;
30 marginBottom?: string;
31 marginLeft?: string;
32 pageSize?: PageSize; // default "letter"
34 // Document structure
35 cover?: boolean;
36 toc?: boolean;
37 noChapterBreaks?: boolean; // default: chapter breaks ON
39 // Branding
40 watermark?: string; // e.g. "DRAFT"
41 headerTemplate?: string; // raw HTML
42 footerTemplate?: string; // raw HTML, mutex with pageNumbers
43 confidential?: boolean; // default: true
45 // Output control
46 pageNumbers?: boolean; // default: true
47 tagged?: boolean; // default: true (accessible PDF)
48 outline?: boolean; // default: true (PDF bookmarks)
49 quiet?: boolean; // suppress progress on stderr
50 verbose?: boolean; // per-stage timings on stderr
52 // Network
53 allowNetwork?: boolean; // default: false
55 // Strict mode (eng-review D6.1): missing/remote images hard-fail instead of
56 // warn + placeholder. For CI docs pipelines that need determinism.
57 strict?: boolean; // default: false
59 // Metadata
60 title?: string;
61 author?: string;
62 date?: string; // ISO-ish; default: today
65/**
66 * Options for `$P preview`.
67 */
68export interface PreviewOptions {
69 input: string;
70 quiet?: boolean;
71 verbose?: boolean;
72 // Same render flags as generate so preview matches output
73 cover?: boolean;
74 toc?: boolean;
75 watermark?: string;
76 noChapterBreaks?: boolean;
77 confidential?: boolean;
78 pageNumbers?: boolean;
79 allowNetwork?: boolean;
80 title?: string;
81 author?: string;
82 date?: string;
85/**
86 * Exit codes for $P generate.
87 * Mirror these in orchestrator error paths.
88 */
89export const ExitCode = {
90 Success: 0,
91 BadArgs: 1,
92 RenderError: 2,
93 TocPagination: 3,
94 BrowserUnavailable: 4,
95} as const;
96export type ExitCode = typeof ExitCode[keyof typeof ExitCode];
98/**
99 * No browser at all: Aside is not installed or not open AND gstack's own
100 * headless browser is not built (exit 4). The message (lib/aside-render's
101 * NO_BROWSER text) names both remedies. A render that fails while a browser
102 * IS available is a plain Error (exit 2).
103 */
104export class BrowserUnavailableError extends Error {
105 constructor(message: string) {
106 super(message);
107 this.name = "BrowserUnavailableError";
108 }