@elevasis/core 0.13.0 → 0.15.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.
Files changed (42) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +9 -2
  3. package/dist/organization-model/index.d.ts +1 -1
  4. package/dist/organization-model/index.js +9 -2
  5. package/dist/test-utils/index.d.ts +463 -377
  6. package/dist/test-utils/index.js +9 -2
  7. package/package.json +1 -1
  8. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +2336 -0
  9. package/src/business/acquisition/activity-events.test.ts +250 -0
  10. package/src/business/acquisition/activity-events.ts +7 -65
  11. package/src/business/acquisition/api-schemas.test.ts +1180 -0
  12. package/src/business/acquisition/api-schemas.ts +317 -73
  13. package/src/business/acquisition/crm-state-actions.test.ts +160 -0
  14. package/src/business/acquisition/derive-actions.test.ts +518 -0
  15. package/src/business/acquisition/derive-actions.ts +101 -78
  16. package/src/business/acquisition/index.ts +51 -9
  17. package/src/business/acquisition/stateful.ts +30 -0
  18. package/src/business/acquisition/types.ts +48 -80
  19. package/src/execution/engine/index.ts +437 -434
  20. package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +363 -360
  21. package/src/execution/engine/tools/integration/server/adapters/attio/fetch/get-record/index.test.ts +162 -186
  22. package/src/execution/engine/tools/integration/server/adapters/attio/fetch/list-records/index.test.ts +316 -338
  23. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-adapter.ts +204 -210
  24. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.test.ts +88 -0
  25. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.ts +141 -134
  26. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/utils/types.ts +76 -75
  27. package/src/execution/engine/tools/integration/service.test.ts +34 -9
  28. package/src/execution/engine/tools/integration/service.ts +6 -3
  29. package/src/execution/engine/tools/lead-service-types.ts +934 -874
  30. package/src/execution/engine/tools/platform/acquisition/types.ts +266 -260
  31. package/src/execution/engine/tools/registry.ts +701 -699
  32. package/src/execution/engine/tools/tool-maps.ts +30 -2
  33. package/src/execution/engine/workflow/types.ts +11 -0
  34. package/src/organization-model/contracts.ts +4 -4
  35. package/src/organization-model/domains/navigation.ts +62 -62
  36. package/src/organization-model/domains/sales.test.ts +189 -0
  37. package/src/organization-model/domains/sales.ts +456 -94
  38. package/src/organization-model/published.ts +21 -21
  39. package/src/organization-model/resolve.ts +21 -8
  40. package/src/platform/constants/versions.ts +1 -1
  41. package/src/reference/_generated/contracts.md +2336 -0
  42. package/src/supabase/database.types.ts +2958 -2886
@@ -1,94 +1,456 @@
1
- import { z } from 'zod'
2
- import { DescriptionSchema, DisplayMetadataSchema, ModelIdSchema, ReferenceIdsSchema } from './shared'
3
-
4
- export const SalesStageSemanticClassSchema = z.enum(['open', 'active', 'nurturing', 'closed_won', 'closed_lost'])
5
-
6
- export const SalesStageSchema = DisplayMetadataSchema.extend({
7
- id: ModelIdSchema,
8
- order: z.number().int().min(0),
9
- semanticClass: SalesStageSemanticClassSchema,
10
- surfaceIds: ReferenceIdsSchema,
11
- resourceIds: ReferenceIdsSchema
12
- })
13
-
14
- export const SalesPipelineSchema = z.object({
15
- id: ModelIdSchema,
16
- label: z.string().trim().min(1).max(120),
17
- description: DescriptionSchema.optional(),
18
- entityId: ModelIdSchema,
19
- stages: z.array(SalesStageSchema).min(1)
20
- })
21
-
22
- export const OrganizationModelSalesSchema = z.object({
23
- entityId: ModelIdSchema,
24
- defaultPipelineId: ModelIdSchema,
25
- pipelines: z.array(SalesPipelineSchema).min(1)
26
- })
27
-
28
- export const DEFAULT_ORGANIZATION_MODEL_SALES: z.infer<typeof OrganizationModelSalesSchema> = {
29
- entityId: 'crm.deal',
30
- defaultPipelineId: 'default',
31
- pipelines: [
32
- {
33
- id: 'default',
34
- label: 'Default Pipeline',
35
- entityId: 'crm.deal',
36
- stages: [
37
- {
38
- id: 'interested',
39
- label: 'Interested',
40
- color: 'blue',
41
- order: 1,
42
- semanticClass: 'open',
43
- surfaceIds: ['crm.pipeline'],
44
- resourceIds: []
45
- },
46
- {
47
- id: 'proposal',
48
- label: 'Proposal',
49
- color: 'yellow',
50
- order: 2,
51
- semanticClass: 'active',
52
- surfaceIds: ['crm.pipeline'],
53
- resourceIds: []
54
- },
55
- {
56
- id: 'closing',
57
- label: 'Closing',
58
- color: 'lime',
59
- order: 3,
60
- semanticClass: 'active',
61
- surfaceIds: ['crm.pipeline'],
62
- resourceIds: []
63
- },
64
- {
65
- id: 'closed_won',
66
- label: 'Closed Won',
67
- color: 'green',
68
- order: 4,
69
- semanticClass: 'closed_won',
70
- surfaceIds: ['crm.pipeline'],
71
- resourceIds: []
72
- },
73
- {
74
- id: 'closed_lost',
75
- label: 'Closed Lost',
76
- color: 'red',
77
- order: 5,
78
- semanticClass: 'closed_lost',
79
- surfaceIds: ['crm.pipeline'],
80
- resourceIds: []
81
- },
82
- {
83
- id: 'nurturing',
84
- label: 'Nurturing',
85
- color: 'grape',
86
- order: 6,
87
- semanticClass: 'nurturing',
88
- surfaceIds: ['crm.pipeline'],
89
- resourceIds: []
90
- }
91
- ]
92
- }
93
- ]
94
- }
1
+ import { z } from 'zod'
2
+ import { DescriptionSchema, DisplayMetadataSchema, ModelIdSchema, ReferenceIdsSchema } from './shared'
3
+
4
+ export const SalesStageSemanticClassSchema = z.enum(['open', 'active', 'nurturing', 'closed_won', 'closed_lost'])
5
+
6
+ export const SalesStageSchema = DisplayMetadataSchema.extend({
7
+ id: ModelIdSchema,
8
+ order: z.number().int().min(0),
9
+ semanticClass: SalesStageSemanticClassSchema,
10
+ surfaceIds: ReferenceIdsSchema,
11
+ resourceIds: ReferenceIdsSchema
12
+ })
13
+
14
+ export const SalesPipelineSchema = z.object({
15
+ id: ModelIdSchema,
16
+ label: z.string().trim().min(1).max(120),
17
+ description: DescriptionSchema.optional(),
18
+ entityId: ModelIdSchema,
19
+ stages: z.array(SalesStageSchema).min(1)
20
+ })
21
+
22
+ export const OrganizationModelSalesSchema = z.object({
23
+ entityId: ModelIdSchema,
24
+ defaultPipelineId: ModelIdSchema,
25
+ pipelines: z.array(SalesPipelineSchema).min(1)
26
+ })
27
+
28
+ export const DEFAULT_ORGANIZATION_MODEL_SALES: z.infer<typeof OrganizationModelSalesSchema> = {
29
+ entityId: 'crm.deal',
30
+ defaultPipelineId: 'default',
31
+ pipelines: [
32
+ {
33
+ id: 'default',
34
+ label: 'Default Pipeline',
35
+ entityId: 'crm.deal',
36
+ stages: [
37
+ {
38
+ id: 'interested',
39
+ label: 'Interested',
40
+ color: 'blue',
41
+ order: 1,
42
+ semanticClass: 'open',
43
+ surfaceIds: ['crm.pipeline'],
44
+ resourceIds: []
45
+ },
46
+ {
47
+ id: 'proposal',
48
+ label: 'Proposal',
49
+ color: 'yellow',
50
+ order: 2,
51
+ semanticClass: 'active',
52
+ surfaceIds: ['crm.pipeline'],
53
+ resourceIds: []
54
+ },
55
+ {
56
+ id: 'closing',
57
+ label: 'Closing',
58
+ color: 'lime',
59
+ order: 3,
60
+ semanticClass: 'active',
61
+ surfaceIds: ['crm.pipeline'],
62
+ resourceIds: []
63
+ },
64
+ {
65
+ id: 'closed_won',
66
+ label: 'Closed Won',
67
+ color: 'green',
68
+ order: 4,
69
+ semanticClass: 'closed_won',
70
+ surfaceIds: ['crm.pipeline'],
71
+ resourceIds: []
72
+ },
73
+ {
74
+ id: 'closed_lost',
75
+ label: 'Closed Lost',
76
+ color: 'red',
77
+ order: 5,
78
+ semanticClass: 'closed_lost',
79
+ surfaceIds: ['crm.pipeline'],
80
+ resourceIds: []
81
+ },
82
+ {
83
+ id: 'nurturing',
84
+ label: 'Nurturing',
85
+ color: 'grape',
86
+ order: 6,
87
+ semanticClass: 'nurturing',
88
+ surfaceIds: ['crm.pipeline'],
89
+ resourceIds: []
90
+ }
91
+ ]
92
+ }
93
+ ]
94
+ }
95
+
96
+ // ============================================================================
97
+ // Lead-Gen Stateful Pipeline Definitions (Decision N8, Wave 4)
98
+ //
99
+ // Defines the (pipeline_key, stage_key, state_key) vocabulary for the three
100
+ // entities that carry the Stateful trait via Track B:
101
+ // - acq_lists (pipeline_key='lead-gen', stage_key='lifecycle')
102
+ // - acq_list_members (pipeline_key='lead-gen', stages: outreach / prospecting / qualification)
103
+ // - acq_list_companies (pipeline_key='lead-gen', stages: outreach / prospecting / qualification)
104
+ //
105
+ // DB columns (pipeline_key, stage_key, state_key) remain free-form text with no
106
+ // CHECK constraint — new states can be introduced without a migration (Decision N8).
107
+ // These definitions are the org-specific source of truth consumed by UI and tooling.
108
+ //
109
+ // State vocabularies sourced from the post-restructure sales tree (W3 canonical):
110
+ // outreach/:
111
+ // - personalized (instantly-personalization.ts → contacts)
112
+ // - uploaded (instantly-upload.ts → contacts)
113
+ // - interested (instantly-reply-handler.ts → contacts, initial reply transition)
114
+ // prospecting/:
115
+ // - populated (apify-acquire.ts, apify-scrape.ts → companies)
116
+ // - extracted (website-extract.ts → companies)
117
+ // - discovered (email-discovery.ts, anymailfinder-enrich.ts → contacts)
118
+ // - verified (email-verification.ts → contacts)
119
+ // qualification/:
120
+ // - qualified (company-qualification.ts → companies)
121
+ //
122
+ // The 'pending' state is the W2 backfill default (coalesce(stage, 'pending')).
123
+ // It is valid in any stage and represents "not yet processed by a workflow step".
124
+ // ============================================================================
125
+
126
+ /** One state within a stage — minimal shape: key + display label. */
127
+ export interface StatefulStateDefinition {
128
+ /** Matches state_key values written by workflow steps. */
129
+ stateKey: string
130
+ label: string
131
+ }
132
+
133
+ /** One stage within a pipeline — has a stage_key and an ordered list of valid states. */
134
+ export interface StatefulStageDefinition {
135
+ /** Matches stage_key values written by workflow steps. */
136
+ stageKey: string
137
+ label: string
138
+ states: StatefulStateDefinition[]
139
+ }
140
+
141
+ /**
142
+ * Pipeline definition for a single entity participating in the Stateful trait.
143
+ * Parallel to acq_deals' pipeline_key concept but structured for lead-gen entities.
144
+ */
145
+ export interface StatefulPipelineDefinition {
146
+ /** Matches pipeline_key values in the database (e.g. 'lead-gen'). */
147
+ pipelineKey: string
148
+ label: string
149
+ /** Entity this pipeline applies to (e.g. 'acq.list', 'acq.list-member', 'acq.list-company'). */
150
+ entityKey: string
151
+ stages: StatefulStageDefinition[]
152
+ }
153
+
154
+ /**
155
+ * Find a pipeline definition by pipeline_key within an array of definitions.
156
+ * Preferred over direct array indexing since the model is array-based (not keyed).
157
+ */
158
+ export function findPipeline(
159
+ definitions: StatefulPipelineDefinition[],
160
+ pipelineKey: string
161
+ ): StatefulPipelineDefinition | undefined {
162
+ return definitions.find((def) => def.pipelineKey === pipelineKey)
163
+ }
164
+
165
+ /**
166
+ * Returns the valid states for a given stage within a pipeline definition.
167
+ * Returns an empty array if the stage is not found.
168
+ */
169
+ export function getValidStatesForStage(
170
+ definition: StatefulPipelineDefinition,
171
+ stageKey: string
172
+ ): StatefulStateDefinition[] {
173
+ return definition.stages.find((s) => s.stageKey === stageKey)?.states ?? []
174
+ }
175
+
176
+ // ============================================================================
177
+ // CRM Stateful Pipeline Definition
178
+ //
179
+ // Defines the (pipeline_key, stage_key, state_key) vocabulary for crm.deal
180
+ // entities. Stage keys match DEFAULT_ORGANIZATION_MODEL_SALES.pipelines[0].stages.
181
+ //
182
+ // State vocabularies sourced from the CRM action/handler tree:
183
+ // interested/:
184
+ // - discovery_replied (instantly-reply-handler.ts → first/subsequent reply)
185
+ // - discovery_link_sent (crm-send-booking-link.ts, crm-rebook.ts → booking link sent)
186
+ // - discovery_nudging (crm-send-nudge.ts → nudge sent after link)
187
+ // - discovery_booking_cancelled (booking-revert.ts → Cal cancellation webhook)
188
+ // - reply_sent (crm-send-reply.ts → operator reply sent)
189
+ // - followup_1_sent (crm-reply-followup.ts day=3)
190
+ // - followup_2_sent (crm-reply-followup.ts day=5)
191
+ // - followup_3_sent (crm-reply-followup.ts day=7)
192
+ // proposal, closing, closed_won, closed_lost, nurturing: no observed sub-states
193
+ // ============================================================================
194
+
195
+ export const CRM_DISCOVERY_REPLIED_STATE: StatefulStateDefinition = {
196
+ stateKey: 'discovery_replied',
197
+ label: 'Discovery Replied'
198
+ }
199
+ export const CRM_DISCOVERY_LINK_SENT_STATE: StatefulStateDefinition = {
200
+ stateKey: 'discovery_link_sent',
201
+ label: 'Discovery Link Sent'
202
+ }
203
+ export const CRM_DISCOVERY_NUDGING_STATE: StatefulStateDefinition = {
204
+ stateKey: 'discovery_nudging',
205
+ label: 'Discovery Nudging'
206
+ }
207
+ export const CRM_DISCOVERY_BOOKING_CANCELLED_STATE: StatefulStateDefinition = {
208
+ stateKey: 'discovery_booking_cancelled',
209
+ label: 'Discovery Booking Cancelled'
210
+ }
211
+ export const CRM_REPLY_SENT_STATE: StatefulStateDefinition = {
212
+ stateKey: 'reply_sent',
213
+ label: 'Reply Sent'
214
+ }
215
+ export const CRM_FOLLOWUP_1_SENT_STATE: StatefulStateDefinition = {
216
+ stateKey: 'followup_1_sent',
217
+ label: 'Follow-up 1 Sent'
218
+ }
219
+ export const CRM_FOLLOWUP_2_SENT_STATE: StatefulStateDefinition = {
220
+ stateKey: 'followup_2_sent',
221
+ label: 'Follow-up 2 Sent'
222
+ }
223
+ export const CRM_FOLLOWUP_3_SENT_STATE: StatefulStateDefinition = {
224
+ stateKey: 'followup_3_sent',
225
+ label: 'Follow-up 3 Sent'
226
+ }
227
+
228
+ export const CRM_PIPELINE_DEFINITION: StatefulPipelineDefinition = {
229
+ pipelineKey: 'crm',
230
+ label: 'CRM',
231
+ entityKey: 'crm.deal',
232
+ stages: [
233
+ {
234
+ stageKey: 'interested',
235
+ label: 'Interested',
236
+ states: [
237
+ CRM_DISCOVERY_REPLIED_STATE,
238
+ CRM_DISCOVERY_LINK_SENT_STATE,
239
+ CRM_DISCOVERY_NUDGING_STATE,
240
+ CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
241
+ CRM_REPLY_SENT_STATE,
242
+ CRM_FOLLOWUP_1_SENT_STATE,
243
+ CRM_FOLLOWUP_2_SENT_STATE,
244
+ CRM_FOLLOWUP_3_SENT_STATE
245
+ ]
246
+ },
247
+ { stageKey: 'proposal', label: 'Proposal', states: [] },
248
+ { stageKey: 'closing', label: 'Closing', states: [] },
249
+ { stageKey: 'closed_won', label: 'Closed Won', states: [] },
250
+ { stageKey: 'closed_lost', label: 'Closed Lost', states: [] },
251
+ { stageKey: 'nurturing', label: 'Nurturing', states: [] }
252
+ ]
253
+ }
254
+
255
+ /** Common states that appear across multiple stages. */
256
+ const PENDING_STATE: StatefulStateDefinition = { stateKey: 'pending', label: 'Pending' }
257
+
258
+ /**
259
+ * Lead-gen pipeline definition for acq_list_members (contacts).
260
+ * Three stages matching the post-restructure sales subdomain tree.
261
+ *
262
+ * Note: members visit outreach and prospecting states depending on which
263
+ * workflow last processed them. stage_key is set per-transition by the workflow.
264
+ */
265
+ export const ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
266
+ pipelineKey: 'lead-gen',
267
+ label: 'Lead Generation',
268
+ entityKey: 'acq.list-member',
269
+ stages: [
270
+ {
271
+ stageKey: 'outreach',
272
+ label: 'Outreach',
273
+ states: [
274
+ PENDING_STATE,
275
+ { stateKey: 'personalized', label: 'Personalized' },
276
+ { stateKey: 'uploaded', label: 'Uploaded' },
277
+ { stateKey: 'interested', label: 'Interested' }
278
+ ]
279
+ },
280
+ {
281
+ stageKey: 'prospecting',
282
+ label: 'Prospecting',
283
+ states: [
284
+ PENDING_STATE,
285
+ { stateKey: 'discovered', label: 'Discovered' },
286
+ { stateKey: 'verified', label: 'Verified' }
287
+ ]
288
+ },
289
+ {
290
+ stageKey: 'qualification',
291
+ label: 'Qualification',
292
+ states: [PENDING_STATE]
293
+ }
294
+ ]
295
+ }
296
+
297
+ /**
298
+ * Lead-gen pipeline definition for acq_list_companies.
299
+ * Three stages matching the post-restructure sales subdomain tree.
300
+ *
301
+ * Note: companies visit prospecting and qualification states depending on which
302
+ * workflow last processed them. stage_key is set per-transition by the workflow.
303
+ */
304
+ export const ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
305
+ pipelineKey: 'lead-gen',
306
+ label: 'Lead Generation',
307
+ entityKey: 'acq.list-company',
308
+ stages: [
309
+ {
310
+ stageKey: 'outreach',
311
+ label: 'Outreach',
312
+ states: [PENDING_STATE]
313
+ },
314
+ {
315
+ stageKey: 'prospecting',
316
+ label: 'Prospecting',
317
+ states: [
318
+ PENDING_STATE,
319
+ { stateKey: 'populated', label: 'Populated' },
320
+ { stateKey: 'extracted', label: 'Extracted' }
321
+ ]
322
+ },
323
+ {
324
+ stageKey: 'qualification',
325
+ label: 'Qualification',
326
+ states: [PENDING_STATE, { stateKey: 'qualified', label: 'Qualified' }]
327
+ }
328
+ ]
329
+ }
330
+
331
+ /**
332
+ * All lead-gen pipeline definitions indexed by entity key.
333
+ * Use findPipeline() to locate a definition by pipeline_key within any of these arrays.
334
+ */
335
+ export const LEAD_GEN_PIPELINE_DEFINITIONS: Record<string, StatefulPipelineDefinition[]> = {
336
+ 'acq.list-member': [ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE],
337
+ 'acq.list-company': [ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE]
338
+ }
339
+
340
+ // ============================================================================
341
+ // Lead-Gen Stage Catalog (status-based processing model)
342
+ //
343
+ // Canonical set of processing stage keys for the status-map model that replaces
344
+ // the stateful trait on acq_list_members and acq_list_companies. Each key maps
345
+ // to a terminal status string in the processing_state jsonb column.
346
+ //
347
+ // Sources:
348
+ // ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE → personalized, uploaded, interested,
349
+ // discovered, verified
350
+ // ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE → populated, extracted, qualified
351
+ // Design plan hint (lead-gen-domain-cleanup.mdx §4) → scraped, enriched
352
+ //
353
+ // Wave 2 will validate pipeline_config.stages[].key against this catalog at
354
+ // list-create/update time. Each lead-gen workflow in operations will declare
355
+ // stageImplemented: '<key>' in its WorkflowDefinition (Slice D-2).
356
+ // ============================================================================
357
+
358
+ /** One entry in the lead-gen stage catalog. */
359
+ export interface LeadGenStageCatalogEntry {
360
+ /** Matches the status key written into processing_state jsonb (e.g. 'scraped'). */
361
+ key: string
362
+ /** Human-readable label for UI display. */
363
+ label: string
364
+ /** Short description of what this stage represents. */
365
+ description: string
366
+ /** Canonical pipeline order for UI sorting. Lower = earlier in the funnel. */
367
+ order: number
368
+ /** Which entity's processing_state jsonb carries this stage status. */
369
+ entity: 'company' | 'contact'
370
+ }
371
+
372
+ /**
373
+ * Canonical lead-gen processing stage catalog.
374
+ * Keys are the stage names written by workflow steps into processing_state jsonb.
375
+ *
376
+ * Ordered roughly by pipeline progression (prospecting → outreach → qualification).
377
+ */
378
+ export const LEAD_GEN_STAGE_CATALOG: Record<string, LeadGenStageCatalogEntry> = {
379
+ // Prospecting — company population
380
+ scraped: {
381
+ key: 'scraped',
382
+ label: 'Scraped',
383
+ description: 'Company was scraped from a source directory (Apify actor run).',
384
+ order: 1,
385
+ entity: 'company'
386
+ },
387
+ populated: {
388
+ key: 'populated',
389
+ label: 'Populated',
390
+ description: 'Company record populated with structured data from scrape results.',
391
+ order: 2,
392
+ entity: 'company'
393
+ },
394
+ extracted: {
395
+ key: 'extracted',
396
+ label: 'Extracted',
397
+ description: 'Website content extracted and parsed for company intelligence.',
398
+ order: 3,
399
+ entity: 'company'
400
+ },
401
+ enriched: {
402
+ key: 'enriched',
403
+ label: 'Enriched',
404
+ description: 'Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).',
405
+ order: 4,
406
+ entity: 'company'
407
+ },
408
+
409
+ // Prospecting — contact discovery
410
+ discovered: {
411
+ key: 'discovered',
412
+ label: 'Discovered',
413
+ description: 'Contact email address discovered via an email-discovery workflow.',
414
+ order: 5,
415
+ entity: 'contact'
416
+ },
417
+ verified: {
418
+ key: 'verified',
419
+ label: 'Verified',
420
+ description: 'Contact email address verified as deliverable (email verification workflow).',
421
+ order: 6,
422
+ entity: 'contact'
423
+ },
424
+
425
+ // Qualification
426
+ qualified: {
427
+ key: 'qualified',
428
+ label: 'Qualified',
429
+ description: 'Company passed the ICP qualification rubric (company-qualification workflow).',
430
+ order: 7,
431
+ entity: 'company'
432
+ },
433
+
434
+ // Outreach
435
+ personalized: {
436
+ key: 'personalized',
437
+ label: 'Personalized',
438
+ description: 'Outreach message personalized for the contact (Instantly personalization workflow).',
439
+ order: 8,
440
+ entity: 'contact'
441
+ },
442
+ uploaded: {
443
+ key: 'uploaded',
444
+ label: 'Uploaded',
445
+ description: 'Contact uploaded to an Instantly campaign for outreach.',
446
+ order: 9,
447
+ entity: 'contact'
448
+ },
449
+ interested: {
450
+ key: 'interested',
451
+ label: 'Interested',
452
+ description: 'Contact replied with a positive signal (Instantly reply-handler transition).',
453
+ order: 10,
454
+ entity: 'contact'
455
+ }
456
+ }
@@ -1,6 +1,6 @@
1
1
  export { OrganizationModelSchema } from './schema'
2
- export { FeatureSchema, NodeIdPathSchema, NodeIdStringSchema, UiPositionSchema } from './domains/features'
3
- export { LinkSchema } from './graph/link'
2
+ export { FeatureSchema, NodeIdPathSchema, NodeIdStringSchema, UiPositionSchema } from './domains/features'
3
+ export { LinkSchema } from './graph/link'
4
4
  export { TechStackEntrySchema } from './domains/shared'
5
5
  export {
6
6
  PROJECTS_FEATURE_ID,
@@ -11,12 +11,12 @@ export {
11
11
  OPERATIONS_FEATURE_ID,
12
12
  MONITORING_FEATURE_ID,
13
13
  SETTINGS_FEATURE_ID,
14
- SEO_FEATURE_ID,
15
- SALES_PIPELINE_SURFACE_ID,
16
- PROSPECTING_LISTS_SURFACE_ID,
17
- OPERATIONS_COMMAND_VIEW_SURFACE_ID,
18
- SETTINGS_ROLES_SURFACE_ID
19
- } from './contracts'
14
+ SEO_FEATURE_ID,
15
+ SALES_PIPELINE_SURFACE_ID,
16
+ PROSPECTING_LISTS_SURFACE_ID,
17
+ OPERATIONS_COMMAND_VIEW_SURFACE_ID,
18
+ SETTINGS_ROLES_SURFACE_ID
19
+ } from './contracts'
20
20
  export { DEFAULT_ORGANIZATION_MODEL } from './defaults'
21
21
  export {
22
22
  DEFAULT_ORGANIZATION_MODEL_STATUSES,
@@ -57,25 +57,25 @@ export type {
57
57
  OrganizationModelCustomerFirmographics,
58
58
  OrganizationModelCustomers,
59
59
  OrganizationModelCustomerSegment,
60
- OrganizationModelFeature,
61
- OrganizationModelGoals,
62
- OrganizationModelKeyResult,
63
- OrganizationModelObjective,
60
+ OrganizationModelFeature,
61
+ OrganizationModelGoals,
62
+ OrganizationModelKeyResult,
63
+ OrganizationModelObjective,
64
64
  OrganizationModelOfferings,
65
65
  OrganizationModelOperationEntry,
66
66
  OrganizationModelOperationSemanticClass,
67
67
  OrganizationModelOperations,
68
- OrganizationModelPricingModel,
69
- OrganizationModelProduct,
70
- OrganizationModelRole,
68
+ OrganizationModelPricingModel,
69
+ OrganizationModelProduct,
70
+ OrganizationModelRole,
71
71
  OrganizationModelTechStackEntry,
72
72
  OrganizationModelRoles,
73
- OrganizationModelStatuses,
74
- OrganizationModelStatusEntry,
75
- OrganizationModelStatusSemanticClass,
76
- NodeIdPath,
77
- NodeIdString
78
- } from './types'
73
+ OrganizationModelStatuses,
74
+ OrganizationModelStatusEntry,
75
+ OrganizationModelStatusSemanticClass,
76
+ NodeIdPath,
77
+ NodeIdString
78
+ } from './types'
79
79
 
80
80
  export type {
81
81
  FoundationBranding,
@@ -31,11 +31,24 @@ function deepMerge<T>(base: T, override: DeepPartial<T> | undefined): T {
31
31
  return result as T
32
32
  }
33
33
 
34
- export function defineOrganizationModel<T extends DeepPartial<OrganizationModel>>(model: T): T {
35
- return model
36
- }
37
-
38
- export function resolveOrganizationModel(override?: DeepPartial<OrganizationModel>): OrganizationModel {
39
- const merged = deepMerge(DEFAULT_ORGANIZATION_MODEL, override)
40
- return OrganizationModelSchema.parse(merged)
41
- }
34
+ export function defineOrganizationModel<T extends DeepPartial<OrganizationModel>>(model: T): T {
35
+ return model
36
+ }
37
+
38
+ export function resolveOrganizationModel(
39
+ override?: DeepPartial<OrganizationModel>,
40
+ organizationId?: string
41
+ ): OrganizationModel {
42
+ const merged = deepMerge(DEFAULT_ORGANIZATION_MODEL, override)
43
+ const model = OrganizationModelSchema.parse(merged)
44
+
45
+ if (!model.sales?.pipelines || model.sales.pipelines.length === 0) {
46
+ const orgLabel = organizationId ? `Organization ${organizationId}` : 'Organization'
47
+ throw new Error(
48
+ `${orgLabel} has no sales pipeline configuration. ` +
49
+ `This indicates an incomplete provisioning state. Run org provisioning to seed defaults.`
50
+ )
51
+ }
52
+
53
+ return model
54
+ }
@@ -1,3 +1,3 @@
1
1
  export const VERSION = {
2
- CURRENT: '1.6.17'
2
+ CURRENT: '1.7.1'
3
3
  }