ai-pdf-builder 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.

Potentially problematic release.


This version of ai-pdf-builder might be problematic. Click here for more details.

@@ -0,0 +1,461 @@
1
+ /**
2
+ * @strykr/pdf-builder - TypeScript Types
3
+ * Professional PDF generation from Markdown using Pandoc and LaTeX
4
+ */
5
+ /**
6
+ * Document metadata for PDF generation
7
+ */
8
+ interface DocumentMetadata {
9
+ /** Document title (required) */
10
+ title: string;
11
+ /** Document subtitle */
12
+ subtitle?: string;
13
+ /** Author name(s) */
14
+ author?: string;
15
+ /** Document date */
16
+ date?: string;
17
+ /** Version string */
18
+ version?: string;
19
+ /** Additional custom metadata */
20
+ [key: string]: string | undefined;
21
+ }
22
+ /**
23
+ * Custom color configuration for document styling
24
+ */
25
+ interface ColorConfig {
26
+ /** Primary brand color (RGB format: "59,130,246") */
27
+ primary?: string;
28
+ /** Secondary color for accents */
29
+ secondary?: string;
30
+ /** Accent color for highlights */
31
+ accent?: string;
32
+ }
33
+ /**
34
+ * Page layout configuration
35
+ */
36
+ interface LayoutConfig {
37
+ /** Page margins (e.g., "1in", "1.5in") */
38
+ margin?: string;
39
+ /** Font size in points (10, 11, 12) */
40
+ fontSize?: number;
41
+ /** Line spacing (1, 1.15, 1.5) */
42
+ lineSpacing?: number;
43
+ /** Paper size ("letter", "a4") */
44
+ paperSize?: "letter" | "a4";
45
+ }
46
+ /**
47
+ * Options for PDF generation
48
+ */
49
+ interface PDFOptions {
50
+ /** Markdown content to convert */
51
+ content: string;
52
+ /** Document metadata */
53
+ metadata?: DocumentMetadata;
54
+ /** Template name or path to custom template */
55
+ template?: string;
56
+ /** Custom color configuration */
57
+ customColors?: ColorConfig;
58
+ /** Output file path. If not provided, returns buffer */
59
+ outputPath?: string;
60
+ /** Include table of contents */
61
+ toc?: boolean;
62
+ /** Depth of TOC (1-3) */
63
+ tocDepth?: number;
64
+ /** Number sections automatically */
65
+ numberSections?: boolean;
66
+ /** Font size in points */
67
+ fontSize?: number;
68
+ /** Page margins */
69
+ margin?: string;
70
+ /** Paper size */
71
+ paperSize?: "letter" | "a4";
72
+ /** Working directory for temporary files */
73
+ workDir?: string;
74
+ /** Timeout in milliseconds (default: 60000) */
75
+ timeout?: number;
76
+ }
77
+ /**
78
+ * Result from PDF generation
79
+ */
80
+ interface PDFResult {
81
+ /** Whether generation was successful */
82
+ success: boolean;
83
+ /** Generated PDF as Buffer (if outputPath not specified) */
84
+ buffer?: Buffer;
85
+ /** Path to generated PDF (if outputPath specified) */
86
+ path?: string;
87
+ /** Error message if generation failed */
88
+ error?: string;
89
+ /** Number of pages in generated PDF */
90
+ pageCount?: number;
91
+ /** File size in bytes */
92
+ fileSize?: number;
93
+ /** Generation time in milliseconds */
94
+ generationTime?: number;
95
+ }
96
+ /**
97
+ * Template configuration
98
+ */
99
+ interface TemplateConfig {
100
+ /** Unique template name */
101
+ name: string;
102
+ /** Path to .latex template file */
103
+ path: string;
104
+ /** Human-readable description */
105
+ description: string;
106
+ /** Document types this template supports */
107
+ supportedDocTypes: DocumentType[];
108
+ }
109
+ /**
110
+ * Supported document types
111
+ */
112
+ type DocumentType = "memo" | "whitepaper" | "agreement" | "termsheet" | "report" | "proposal" | "generic";
113
+ /**
114
+ * Check if Pandoc is available
115
+ */
116
+ interface PandocCheck {
117
+ available: boolean;
118
+ version?: string;
119
+ path?: string;
120
+ error?: string;
121
+ }
122
+ /**
123
+ * Check if LaTeX is available
124
+ */
125
+ interface LaTeXCheck {
126
+ available: boolean;
127
+ engine?: string;
128
+ version?: string;
129
+ path?: string;
130
+ error?: string;
131
+ }
132
+ /**
133
+ * System requirements check result
134
+ */
135
+ interface SystemCheck {
136
+ pandoc: PandocCheck;
137
+ latex: LaTeXCheck;
138
+ ready: boolean;
139
+ message: string;
140
+ }
141
+
142
+ /**
143
+ * @strykr/pdf-builder - PDF Generator
144
+ * Core PDF generation logic using Pandoc and LaTeX
145
+ */
146
+
147
+ /**
148
+ * Generate a PDF from Markdown content
149
+ *
150
+ * @param options - PDF generation options
151
+ * @returns Promise resolving to PDFResult
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const result = await generatePDF({
156
+ * content: '# Hello World\n\nThis is my document.',
157
+ * metadata: { title: 'My Document', author: 'John Doe' },
158
+ * template: 'default'
159
+ * });
160
+ *
161
+ * if (result.success) {
162
+ * fs.writeFileSync('output.pdf', result.buffer);
163
+ * }
164
+ * ```
165
+ */
166
+ declare function generatePDF(options: PDFOptions): Promise<PDFResult>;
167
+
168
+ /**
169
+ * @strykr/pdf-builder - Template Management
170
+ * Handle built-in and custom LaTeX templates
171
+ */
172
+
173
+ /**
174
+ * Get template content by name
175
+ *
176
+ * @param name - Template name or path
177
+ * @returns Template content as string, or null if not found
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const template = getTemplate('memo');
182
+ * const customTemplate = getTemplate('/path/to/custom.latex');
183
+ * ```
184
+ */
185
+ declare function getTemplate(name: string): string | null;
186
+ /**
187
+ * Get the file path for a template
188
+ *
189
+ * @param name - Template name
190
+ * @returns Path to template file, or null if not found
191
+ */
192
+ declare function getTemplatePath(name: string): string | null;
193
+ /**
194
+ * List all available templates (built-in and custom)
195
+ *
196
+ * @returns Array of template configurations
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * const templates = listTemplates();
201
+ * templates.forEach(t => console.log(t.name, t.description));
202
+ * ```
203
+ */
204
+ declare function listTemplates(): TemplateConfig[];
205
+ /**
206
+ * Get a specific template configuration
207
+ *
208
+ * @param name - Template name
209
+ * @returns Template configuration or null
210
+ */
211
+ declare function getTemplateConfig(name: string): TemplateConfig | null;
212
+ /**
213
+ * Register a custom template
214
+ *
215
+ * @param config - Template configuration
216
+ * @throws Error if template file doesn't exist
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * registerTemplate({
221
+ * name: 'company-branded',
222
+ * path: './templates/company.latex',
223
+ * description: 'Company branded template',
224
+ * supportedDocTypes: ['memo', 'whitepaper']
225
+ * });
226
+ * ```
227
+ */
228
+ declare function registerTemplate(config: TemplateConfig): void;
229
+ /**
230
+ * Unregister a custom template
231
+ *
232
+ * @param name - Template name to remove
233
+ * @returns true if template was removed, false if not found
234
+ */
235
+ declare function unregisterTemplate(name: string): boolean;
236
+ /**
237
+ * Check if a template exists
238
+ *
239
+ * @param name - Template name
240
+ * @returns true if template exists
241
+ */
242
+ declare function hasTemplate(name: string): boolean;
243
+ /**
244
+ * Get templates that support a specific document type
245
+ *
246
+ * @param docType - Document type to filter by
247
+ * @returns Array of matching template configurations
248
+ */
249
+ declare function getTemplatesForDocType(docType: DocumentType): TemplateConfig[];
250
+ /**
251
+ * Clear the template cache
252
+ * Useful when template files are updated
253
+ */
254
+ declare function clearTemplateCache(): void;
255
+ /**
256
+ * Get the templates directory path
257
+ * Useful for locating bundled templates
258
+ */
259
+ declare function getTemplatesDirectory(): string;
260
+
261
+ /**
262
+ * @strykr/pdf-builder - Preset Document Generators
263
+ * Pre-configured generators for common document types
264
+ */
265
+
266
+ /**
267
+ * Generate a business memo PDF
268
+ *
269
+ * Uses the memo template with settings optimized for executive summaries
270
+ * and internal communications.
271
+ *
272
+ * @param content - Markdown content for the memo
273
+ * @param metadata - Document metadata (title, author, etc.)
274
+ * @param options - Additional PDF options (optional)
275
+ * @returns Promise resolving to PDFResult
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const memo = await generateMemo(
280
+ * '# Executive Summary\n\nKey findings...',
281
+ * { title: 'Q4 Report', author: 'Jane Doe' }
282
+ * );
283
+ * ```
284
+ */
285
+ declare function generateMemo(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
286
+ /**
287
+ * Generate a legal agreement PDF
288
+ *
289
+ * Uses the agreement template with formal legal document formatting,
290
+ * suitable for contracts, advisor agreements, and other legal documents.
291
+ *
292
+ * @param content - Markdown content for the agreement
293
+ * @param metadata - Document metadata (title, parties, etc.)
294
+ * @param options - Additional PDF options (optional)
295
+ * @returns Promise resolving to PDFResult
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const agreement = await generateAgreement(
300
+ * '# Advisor Agreement\n\n## 1. Services\n\nThe Advisor agrees to...',
301
+ * { title: 'Advisor Agreement', subtitle: 'Strykr AI Inc.' }
302
+ * );
303
+ * ```
304
+ */
305
+ declare function generateAgreement(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
306
+ /**
307
+ * Generate a term sheet PDF
308
+ *
309
+ * Uses the termsheet template optimized for investment term sheets,
310
+ * with structured sections for deal terms.
311
+ *
312
+ * @param content - Markdown content for the term sheet
313
+ * @param metadata - Document metadata (title, company, etc.)
314
+ * @param options - Additional PDF options (optional)
315
+ * @returns Promise resolving to PDFResult
316
+ *
317
+ * @example
318
+ * ```typescript
319
+ * const termsheet = await generateTermsheet(
320
+ * '# Series Seed Term Sheet\n\n## Investment Amount\n\n$2,000,000...',
321
+ * { title: 'Series Seed Term Sheet', subtitle: 'Strykr AI Inc.' }
322
+ * );
323
+ * ```
324
+ */
325
+ declare function generateTermsheet(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
326
+ /**
327
+ * Generate a whitepaper PDF
328
+ *
329
+ * Uses the default template with settings optimized for technical
330
+ * whitepapers and litepapers, including table of contents.
331
+ *
332
+ * @param content - Markdown content for the whitepaper
333
+ * @param metadata - Document metadata (title, author, etc.)
334
+ * @param options - Additional PDF options (optional)
335
+ * @returns Promise resolving to PDFResult
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * const whitepaper = await generateWhitepaper(
340
+ * '# Abstract\n\nThis paper presents...\n\n# Introduction\n\n...',
341
+ * { title: 'STRYKR PRISM', subtitle: 'Intelligence Infrastructure', author: 'Ty Blackard' }
342
+ * );
343
+ * ```
344
+ */
345
+ declare function generateWhitepaper(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
346
+ /**
347
+ * Generate a report PDF
348
+ *
349
+ * Uses the default template with settings optimized for business
350
+ * reports and analysis documents.
351
+ *
352
+ * @param content - Markdown content for the report
353
+ * @param metadata - Document metadata (title, author, etc.)
354
+ * @param options - Additional PDF options (optional)
355
+ * @returns Promise resolving to PDFResult
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * const report = await generateReport(
360
+ * '# Market Analysis\n\n## Key Findings\n\n...',
361
+ * { title: 'Q4 Market Report', date: 'January 2026' }
362
+ * );
363
+ * ```
364
+ */
365
+ declare function generateReport(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
366
+ /**
367
+ * Generate a proposal PDF
368
+ *
369
+ * Uses the default template with settings optimized for business
370
+ * proposals and pitch documents.
371
+ *
372
+ * @param content - Markdown content for the proposal
373
+ * @param metadata - Document metadata (title, company, etc.)
374
+ * @param options - Additional PDF options (optional)
375
+ * @returns Promise resolving to PDFResult
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * const proposal = await generateProposal(
380
+ * '# Executive Summary\n\n## Opportunity\n\n...',
381
+ * { title: 'Partnership Proposal', subtitle: 'Strategic Alliance' }
382
+ * );
383
+ * ```
384
+ */
385
+ declare function generateProposal(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
386
+ /**
387
+ * Generate a capital introduction agreement PDF
388
+ *
389
+ * Specialized for fundraising referral agreements with milestone-based
390
+ * compensation structures.
391
+ *
392
+ * @param content - Markdown content for the agreement
393
+ * @param metadata - Document metadata (title, parties, etc.)
394
+ * @param options - Additional PDF options (optional)
395
+ * @returns Promise resolving to PDFResult
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * const agreement = await generateCapitalIntroAgreement(
400
+ * '# Capital Introduction Agreement\n\n## 1. Services\n\n...',
401
+ * { title: 'Capital Introduction Agreement', subtitle: 'Strykr AI Inc.' }
402
+ * );
403
+ * ```
404
+ */
405
+ declare function generateCapitalIntroAgreement(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
406
+ /**
407
+ * Generate a SAFE document PDF
408
+ *
409
+ * Uses the agreement template optimized for Simple Agreement for
410
+ * Future Equity documents.
411
+ *
412
+ * @param content - Markdown content for the SAFE
413
+ * @param metadata - Document metadata
414
+ * @param options - Additional PDF options (optional)
415
+ * @returns Promise resolving to PDFResult
416
+ */
417
+ declare function generateSAFE(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
418
+ /**
419
+ * Generate an NDA PDF
420
+ *
421
+ * Uses the agreement template optimized for Non-Disclosure Agreements.
422
+ *
423
+ * @param content - Markdown content for the NDA
424
+ * @param metadata - Document metadata
425
+ * @param options - Additional PDF options (optional)
426
+ * @returns Promise resolving to PDFResult
427
+ */
428
+ declare function generateNDA(content: string, metadata: DocumentMetadata, options?: Partial<PDFOptions>): Promise<PDFResult>;
429
+
430
+ /**
431
+ * @strykr/pdf-builder - Utility Functions
432
+ */
433
+
434
+ /**
435
+ * Check if Pandoc is installed and available
436
+ */
437
+ declare function checkPandoc(): PandocCheck;
438
+ /**
439
+ * Check if LaTeX/pdflatex is installed and available
440
+ */
441
+ declare function checkLaTeX(): LaTeXCheck;
442
+ /**
443
+ * Check system requirements for PDF generation
444
+ */
445
+ declare function checkSystem(): SystemCheck;
446
+ /**
447
+ * Sanitize content for LaTeX safety
448
+ * Removes dangerous LaTeX commands that could be security risks
449
+ */
450
+ declare function sanitizeContent(content: string): string;
451
+ /**
452
+ * Parse RGB color string to components
453
+ * Accepts formats: "RGB(59,130,246)" or "59,130,246" or "#3B82F6"
454
+ */
455
+ declare function parseColor(color: string): string;
456
+ /**
457
+ * Get file size in human-readable format
458
+ */
459
+ declare function formatFileSize(bytes: number): string;
460
+
461
+ export { type ColorConfig, type DocumentMetadata, type DocumentType, type LaTeXCheck, type LayoutConfig, type PDFOptions, type PDFResult, type PandocCheck, type SystemCheck, type TemplateConfig, checkLaTeX, checkPandoc, checkSystem, clearTemplateCache, formatFileSize, generateAgreement, generateCapitalIntroAgreement, generateMemo, generateNDA, generatePDF, generateProposal, generateReport, generateSAFE, generateTermsheet, generateWhitepaper, getTemplate, getTemplateConfig, getTemplatePath, getTemplatesDirectory, getTemplatesForDocType, hasTemplate, listTemplates, parseColor, registerTemplate, sanitizeContent, unregisterTemplate };