@elevasis/core 0.30.0 → 0.31.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.
@@ -1,200 +1,206 @@
1
- /**
2
- * Shared Proposal Document Builder
3
- *
4
- * Standardized document builder used across:
5
- * - Production proposal agent (document.ts)
6
- * - Render PDF diagnostic (render-pdf.ts)
7
- * - PDF Sandbox (page.tsx)
8
- *
9
- * Changes to the page structure here propagate to all consumers automatically.
10
- *
11
- * Page Structure:
12
- * 1. Cover page
13
- * 2. Executive Summary (with paragraph support)
14
- * 3. Automation pages (one per automation)
15
- * 4. Summary + Investment (combined)
16
- * 5. Acceptance (signature page)
17
- */
18
-
19
- import type { PDFDocument, Page } from '../types'
20
- import { coverSection } from './cover'
21
- import { summarySection } from './summary'
22
- import { automationSection } from './automation'
23
- import { summaryInvestmentSection } from './summary-investment'
24
- import { acceptanceSection } from './acceptance'
25
- import type { AutomationConfig } from './types'
26
-
27
- // =============================================================================
28
- // Types
29
- // =============================================================================
30
-
31
- /**
32
- * Standardized proposal document configuration
33
- *
34
- * All fields required for building a complete proposal PDF.
35
- * Used by production, diagnostic, and sandbox.
36
- */
37
- export interface ProposalDocumentConfig {
38
- // Cover page fields
39
- /** Company name (appears on cover and acceptance) */
40
- company: string
41
- /** Contact name (appears on cover and acceptance) */
42
- contact: string
43
- /** Business vertical (e.g., "Marketing & Creative Agency") */
44
- vertical: string
45
- /** Solutions summary (e.g., "Client reporting - Content workflows") */
46
- solutions: string
47
- /** Logo as base64 data URL (optional) */
48
- logoSrc?: string
49
-
50
- // Executive summary
51
- /** Executive summary text - supports paragraph breaks via \n\n */
52
- executiveSummary: string
53
-
54
- // Automations (each becomes a detail page)
55
- /** Automation configurations - each generates one page */
56
- automations: AutomationConfig[]
57
-
58
- // Acceptance page
59
- /** Service tier for acceptance page */
60
- tier: 'tier1' | 'tier2' | 'tier3' | 'custom'
61
- /** Initial fee amount in dollars (one-time implementation fee) */
62
- initialFee: number
63
- /** Monthly fee amount in dollars (optional, for ongoing support) */
64
- monthlyFee?: number
65
- }
66
-
67
- // =============================================================================
68
- // Builder
69
- // =============================================================================
70
-
71
- /**
72
- * Build a standardized proposal PDF document
73
- *
74
- * Creates the standard 6+ page proposal structure:
75
- * 1. Cover page with company branding
76
- * 2. Executive Summary with key metrics
77
- * 3-N. Automation detail pages (one per automation)
78
- * N+1. Summary table + Investment (combined)
79
- * N+2. Acceptance page with signature fields
80
- *
81
- * @param config - Proposal document configuration
82
- * @returns PDFDocument ready for rendering
83
- *
84
- * @example
85
- * ```typescript
86
- * import { buildProposalDocument } from '@repo/core/pdf/sections'
87
- *
88
- * const document = buildProposalDocument({
89
- * company: 'Acme Corp',
90
- * contact: 'John Smith',
91
- * vertical: 'Marketing Agency',
92
- * solutions: 'Reporting - Invoicing',
93
- * executiveSummary: 'Based on our discovery call...',
94
- * automations: [
95
- * { title: 'Client Reporting', hoursPerWeek: 12, annualSavings: 31200, ... }
96
- * ],
97
- * tier: 'tier2',
98
- * initialFee: 5000,
99
- * monthlyFee: 2500 // optional
100
- * })
101
- * ```
102
- */
103
- export function buildProposalDocument(config: ProposalDocumentConfig): PDFDocument {
104
- const {
105
- company,
106
- contact,
107
- vertical,
108
- solutions,
109
- logoSrc,
110
- executiveSummary,
111
- automations,
112
- tier,
113
- initialFee,
114
- monthlyFee
115
- } = config
116
-
117
- // Calculate totals for metrics
118
- const totalSavings = automations.reduce((sum, a) => sum + a.annualSavings, 0)
119
-
120
- // Build page array
121
- const pages: Page[] = [
122
- // Page 1: Cover
123
- coverSection({
124
- company,
125
- contact,
126
- vertical,
127
- solutions,
128
- logoSrc
129
- }),
130
-
131
- // Page 2: Executive Summary
132
- summarySection({
133
- totalSavings,
134
- automationCount: automations.length,
135
- description: executiveSummary
136
- }),
137
-
138
- // Pages 3-N: Automation details (one per automation)
139
- ...automations.map(automation => automationSection(automation)),
140
-
141
- // Page N+1: Combined Summary Table + Investment
142
- summaryInvestmentSection({
143
- automations: automations.map(a => ({
144
- title: a.title,
145
- hoursPerWeek: a.hoursPerWeek,
146
- annualSavings: a.annualSavings
147
- })),
148
- initialFee,
149
- monthlyFee
150
- }),
151
-
152
- // Page N+2: Acceptance (signature fields)
153
- acceptanceSection({
154
- companyName: company,
155
- contactName: contact,
156
- tier,
157
- initialFee,
158
- monthlyFee
159
- })
160
- ]
161
-
162
- return {
163
- pages,
164
- metadata: {
165
- title: `Proposal for ${company}`,
166
- author: 'Elevasis'
167
- }
168
- }
169
- }
170
-
171
- // =============================================================================
172
- // Helper for generating executive summary text
173
- // =============================================================================
174
-
175
- /**
176
- * Generate standard 3-paragraph executive summary
177
- *
178
- * Creates consistent narrative structure:
179
- * - Paragraph 1: Problem statement with cost impact
180
- * - Paragraph 2: Solution overview with human oversight emphasis
181
- * - Paragraph 3: Projected ROI and implementation timeline
182
- *
183
- * @param config - Summary generation parameters
184
- * @returns Executive summary with paragraph breaks (\n\n)
185
- */
186
- export function generateExecutiveSummary(config: {
187
- contact: string
188
- company: string
189
- totalSavings: number
190
- totalHoursPerWeek: number
191
- automationCount: number
192
- }): string {
193
- const { contact, company, totalSavings, totalHoursPerWeek, automationCount } = config
194
-
195
- return `${contact}, your team at ${company} is caught in a cycle of inefficiency that's quietly draining $${totalSavings.toLocaleString()} annually from your bottom line. These aren't just administrative headaches - they're opportunities slipping through the cracks, relationships strained by delays, and time wasted on tasks that could run themselves.
196
-
197
- This proposal outlines ${automationCount} targeted automations designed specifically for ${company}'s workflow. Each solution maintains human oversight at critical decision points while eliminating the repetitive tasks consuming your team's time. We're not replacing your people - we're freeing them to focus on what they do best.
198
-
199
- The projected annual savings of $${totalSavings.toLocaleString()} represents 70% of the cost you're currently losing to manual processes. More importantly, reclaiming ${totalHoursPerWeek} hours per week means your team can take on more work without burning out. The automations outlined here can be implemented within 2-3 weeks of approval.`
200
- }
1
+ /**
2
+ * Shared Proposal Document Builder
3
+ *
4
+ * Standardized document builder used across:
5
+ * - Production proposal agent (document.ts)
6
+ * - Render PDF diagnostic (render-pdf.ts)
7
+ * - PDF Sandbox (page.tsx)
8
+ *
9
+ * Changes to the page structure here propagate to all consumers automatically.
10
+ *
11
+ * Page Structure:
12
+ * 1. Cover page
13
+ * 2. Executive Summary (with paragraph support)
14
+ * 3. Automation pages (one per automation)
15
+ * 4. Summary + Investment (combined)
16
+ * 5. Acceptance (signature page)
17
+ */
18
+
19
+ import type { PDFDocument, Page } from '../types'
20
+ import { coverSection } from './cover'
21
+ import { summarySection } from './summary'
22
+ import { automationSection } from './automation'
23
+ import { summaryInvestmentSection } from './summary-investment'
24
+ import { acceptanceSection } from './acceptance'
25
+ import type { AutomationConfig } from './types'
26
+
27
+ // =============================================================================
28
+ // Types
29
+ // =============================================================================
30
+
31
+ /**
32
+ * Standardized proposal document configuration
33
+ *
34
+ * All fields required for building a complete proposal PDF.
35
+ * Used by production, diagnostic, and sandbox.
36
+ */
37
+ export interface ProposalDocumentConfig {
38
+ // Cover page fields
39
+ /** Company name (appears on cover and acceptance) */
40
+ company: string
41
+ /** Contact name (appears on cover and acceptance) */
42
+ contact: string
43
+ /** Business vertical (e.g., "Marketing & Creative Agency") */
44
+ vertical: string
45
+ /** Solutions summary (e.g., "Client reporting - Content workflows") */
46
+ solutions: string
47
+ /** Logo as base64 data URL (optional) */
48
+ logoSrc?: string
49
+
50
+ // Executive summary
51
+ /** Executive summary text - supports paragraph breaks via \n\n */
52
+ executiveSummary: string
53
+
54
+ // Automations (each becomes a detail page)
55
+ /** Automation configurations - each generates one page */
56
+ automations: AutomationConfig[]
57
+
58
+ // Acceptance page
59
+ /** Service tier for acceptance page */
60
+ tier: 'tier1' | 'tier2' | 'tier3' | 'custom'
61
+ /** Initial fee amount in dollars (one-time implementation fee) */
62
+ initialFee: number
63
+ /** Monthly fee amount in dollars (optional, for ongoing support) */
64
+ monthlyFee?: number
65
+
66
+ // Document metadata
67
+ /** Name of the service provider issuing the proposal (used in acceptance text and document metadata) */
68
+ providerName: string
69
+ }
70
+
71
+ // =============================================================================
72
+ // Builder
73
+ // =============================================================================
74
+
75
+ /**
76
+ * Build a standardized proposal PDF document
77
+ *
78
+ * Creates the standard 6+ page proposal structure:
79
+ * 1. Cover page with company branding
80
+ * 2. Executive Summary with key metrics
81
+ * 3-N. Automation detail pages (one per automation)
82
+ * N+1. Summary table + Investment (combined)
83
+ * N+2. Acceptance page with signature fields
84
+ *
85
+ * @param config - Proposal document configuration
86
+ * @returns PDFDocument ready for rendering
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * import { buildProposalDocument } from '@repo/core/pdf/sections'
91
+ *
92
+ * const document = buildProposalDocument({
93
+ * company: 'Acme Corp',
94
+ * contact: 'John Smith',
95
+ * vertical: 'Marketing Agency',
96
+ * solutions: 'Reporting - Invoicing',
97
+ * executiveSummary: 'Based on our discovery call...',
98
+ * automations: [
99
+ * { title: 'Client Reporting', hoursPerWeek: 12, annualSavings: 31200, ... }
100
+ * ],
101
+ * tier: 'tier2',
102
+ * initialFee: 5000,
103
+ * monthlyFee: 2500 // optional
104
+ * })
105
+ * ```
106
+ */
107
+ export function buildProposalDocument(config: ProposalDocumentConfig): PDFDocument {
108
+ const {
109
+ company,
110
+ contact,
111
+ vertical,
112
+ solutions,
113
+ logoSrc,
114
+ executiveSummary,
115
+ automations,
116
+ tier,
117
+ initialFee,
118
+ monthlyFee,
119
+ providerName
120
+ } = config
121
+
122
+ // Calculate totals for metrics
123
+ const totalSavings = automations.reduce((sum, a) => sum + a.annualSavings, 0)
124
+
125
+ // Build page array
126
+ const pages: Page[] = [
127
+ // Page 1: Cover
128
+ coverSection({
129
+ company,
130
+ contact,
131
+ vertical,
132
+ solutions,
133
+ logoSrc
134
+ }),
135
+
136
+ // Page 2: Executive Summary
137
+ summarySection({
138
+ totalSavings,
139
+ automationCount: automations.length,
140
+ description: executiveSummary
141
+ }),
142
+
143
+ // Pages 3-N: Automation details (one per automation)
144
+ ...automations.map((automation) => automationSection(automation)),
145
+
146
+ // Page N+1: Combined Summary Table + Investment
147
+ summaryInvestmentSection({
148
+ automations: automations.map((a) => ({
149
+ title: a.title,
150
+ hoursPerWeek: a.hoursPerWeek,
151
+ annualSavings: a.annualSavings
152
+ })),
153
+ initialFee,
154
+ monthlyFee
155
+ }),
156
+
157
+ // Page N+2: Acceptance (signature fields)
158
+ acceptanceSection({
159
+ companyName: company,
160
+ contactName: contact,
161
+ tier,
162
+ initialFee,
163
+ monthlyFee,
164
+ providerName
165
+ })
166
+ ]
167
+
168
+ return {
169
+ pages,
170
+ metadata: {
171
+ title: `Proposal for ${company}`,
172
+ author: providerName
173
+ }
174
+ }
175
+ }
176
+
177
+ // =============================================================================
178
+ // Helper for generating executive summary text
179
+ // =============================================================================
180
+
181
+ /**
182
+ * Generate standard 3-paragraph executive summary
183
+ *
184
+ * Creates consistent narrative structure:
185
+ * - Paragraph 1: Problem statement with cost impact
186
+ * - Paragraph 2: Solution overview with human oversight emphasis
187
+ * - Paragraph 3: Projected ROI and implementation timeline
188
+ *
189
+ * @param config - Summary generation parameters
190
+ * @returns Executive summary with paragraph breaks (\n\n)
191
+ */
192
+ export function generateExecutiveSummary(config: {
193
+ contact: string
194
+ company: string
195
+ totalSavings: number
196
+ totalHoursPerWeek: number
197
+ automationCount: number
198
+ }): string {
199
+ const { contact, company, totalSavings, totalHoursPerWeek, automationCount } = config
200
+
201
+ return `${contact}, your team at ${company} is caught in a cycle of inefficiency that's quietly draining $${totalSavings.toLocaleString()} annually from your bottom line. These aren't just administrative headaches - they're opportunities slipping through the cracks, relationships strained by delays, and time wasted on tasks that could run themselves.
202
+
203
+ This proposal outlines ${automationCount} targeted automations designed specifically for ${company}'s workflow. Each solution maintains human oversight at critical decision points while eliminating the repetitive tasks consuming your team's time. We're not replacing your people - we're freeing them to focus on what they do best.
204
+
205
+ The projected annual savings of $${totalSavings.toLocaleString()} represents 70% of the cost you're currently losing to manual processes. More importantly, reclaiming ${totalHoursPerWeek} hours per week means your team can take on more work without burning out. The automations outlined here can be implemented within 2-3 weeks of approval.`
206
+ }