@elevasis/core 0.30.0 → 0.32.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/auth/index.d.ts +58 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +73 -109
- package/dist/knowledge/index.d.ts +10 -2
- package/dist/organization-model/index.d.ts +16 -5
- package/dist/organization-model/index.js +73 -109
- package/dist/test-utils/index.d.ts +55 -2
- package/dist/test-utils/index.js +72 -108
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +376 -446
- package/src/business/acquisition/api-schemas.test.ts +69 -5
- package/src/business/acquisition/crm-state-actions.test.ts +24 -6
- package/src/business/pdf/sections/__tests__/proposal-document.test.ts +146 -0
- package/src/business/pdf/sections/acceptance.ts +114 -112
- package/src/business/pdf/sections/proposal-document.ts +206 -200
- package/src/execution/engine/index.ts +440 -439
- package/src/execution/engine/tools/integration/types/clickup.ts +57 -0
- package/src/execution/engine/tools/integration/types/index.ts +20 -19
- package/src/execution/engine/tools/tool-maps.ts +16 -0
- package/src/organization-model/__tests__/domains/entities.test.ts +35 -56
- package/src/organization-model/__tests__/domains/passthrough-extensibility.test.ts +199 -0
- package/src/organization-model/domains/branding.ts +58 -16
- package/src/organization-model/domains/entities.ts +0 -103
- package/src/organization-model/domains/identity.ts +122 -94
- package/src/organization-model/domains/sales.test.ts +35 -28
- package/src/organization-model/domains/sales.ts +0 -85
- package/src/organization-model/published.ts +0 -1
- package/src/organization-model/schema.ts +2 -2
- package/src/reference/_generated/contracts.md +0 -94
- package/src/supabase/database.types.ts +45 -0
|
@@ -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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
}
|