@elevasis/core 0.15.0 → 0.16.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 (88) hide show
  1. package/dist/index.d.ts +1718 -19
  2. package/dist/index.js +369 -25
  3. package/dist/organization-model/index.d.ts +1718 -19
  4. package/dist/organization-model/index.js +369 -25
  5. package/dist/test-utils/index.d.ts +1108 -371
  6. package/dist/test-utils/index.js +357 -17
  7. package/package.json +5 -1
  8. package/src/__tests__/publish.test.ts +14 -13
  9. package/src/__tests__/template-core-compatibility.test.ts +4 -4
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +1109 -882
  11. package/src/auth/multi-tenancy/index.ts +3 -0
  12. package/src/auth/multi-tenancy/theme-presets.ts +45 -0
  13. package/src/auth/multi-tenancy/types.ts +57 -83
  14. package/src/auth/multi-tenancy/users/api-schemas.ts +165 -194
  15. package/src/business/acquisition/activity-events.ts +13 -4
  16. package/src/business/acquisition/api-schemas.test.ts +315 -4
  17. package/src/business/acquisition/api-schemas.ts +122 -8
  18. package/src/business/acquisition/build-templates.ts +44 -0
  19. package/src/business/acquisition/crm-next-action.test.ts +262 -0
  20. package/src/business/acquisition/crm-next-action.ts +220 -0
  21. package/src/business/acquisition/crm-priority.test.ts +216 -0
  22. package/src/business/acquisition/crm-priority.ts +349 -0
  23. package/src/business/acquisition/crm-state-actions.test.ts +151 -160
  24. package/src/business/acquisition/deal-ownership.test.ts +351 -0
  25. package/src/business/acquisition/deal-ownership.ts +120 -0
  26. package/src/business/acquisition/derive-actions.test.ts +101 -37
  27. package/src/business/acquisition/derive-actions.ts +102 -87
  28. package/src/business/acquisition/index.ts +10 -0
  29. package/src/business/acquisition/types.ts +400 -366
  30. package/src/business/crm/api-schemas.ts +40 -0
  31. package/src/business/crm/index.ts +1 -0
  32. package/src/business/deals/api-schemas.ts +79 -0
  33. package/src/business/deals/index.ts +1 -0
  34. package/src/business/projects/types.ts +124 -88
  35. package/src/execution/core/runner-types.ts +61 -80
  36. package/src/execution/engine/index.ts +4 -3
  37. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -104
  38. package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1473
  39. package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -102
  40. package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -179
  41. package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -309
  42. package/src/execution/engine/tools/integration/tool.ts +255 -253
  43. package/src/execution/engine/tools/lead-service-types.ts +939 -924
  44. package/src/execution/engine/tools/messages.ts +43 -0
  45. package/src/execution/engine/tools/platform/acquisition/list-tools.ts +6 -5
  46. package/src/execution/engine/tools/platform/acquisition/types.ts +5 -2
  47. package/src/execution/engine/tools/platform/email/types.ts +97 -96
  48. package/src/execution/engine/tools/registry.ts +4 -3
  49. package/src/execution/engine/tools/tool-maps.ts +3 -1
  50. package/src/execution/engine/tools/types.ts +234 -233
  51. package/src/execution/engine/workflow/types.ts +195 -193
  52. package/src/execution/external/api-schemas.ts +40 -0
  53. package/src/execution/external/index.ts +1 -0
  54. package/src/knowledge/README.md +32 -0
  55. package/src/knowledge/__tests__/queries.test.ts +504 -0
  56. package/src/knowledge/format.ts +99 -0
  57. package/src/knowledge/index.ts +5 -0
  58. package/src/knowledge/queries.ts +256 -0
  59. package/src/organization-model/__tests__/defaults.test.ts +172 -172
  60. package/src/organization-model/__tests__/foundation.test.ts +7 -7
  61. package/src/organization-model/__tests__/icons.test.ts +27 -0
  62. package/src/organization-model/__tests__/knowledge.test.ts +214 -0
  63. package/src/organization-model/contracts.ts +17 -15
  64. package/src/organization-model/defaults.ts +74 -19
  65. package/src/organization-model/domains/knowledge.ts +53 -0
  66. package/src/organization-model/domains/navigation.ts +416 -399
  67. package/src/organization-model/domains/prospecting.ts +204 -1
  68. package/src/organization-model/domains/sales.test.ts +29 -0
  69. package/src/organization-model/domains/sales.ts +102 -0
  70. package/src/organization-model/domains/shared.ts +6 -5
  71. package/src/organization-model/foundation.ts +10 -6
  72. package/src/organization-model/graph/build.ts +209 -182
  73. package/src/organization-model/graph/schema.ts +37 -34
  74. package/src/organization-model/graph/types.ts +47 -31
  75. package/src/organization-model/icons.ts +81 -0
  76. package/src/organization-model/index.ts +8 -3
  77. package/src/organization-model/organization-model.mdx +1 -1
  78. package/src/organization-model/published.ts +103 -86
  79. package/src/organization-model/schema.ts +90 -85
  80. package/src/organization-model/types.ts +42 -35
  81. package/src/platform/constants/versions.ts +1 -1
  82. package/src/platform/index.ts +23 -27
  83. package/src/platform/registry/index.ts +0 -4
  84. package/src/platform/registry/resource-registry.ts +0 -77
  85. package/src/platform/registry/serialized-types.ts +148 -219
  86. package/src/platform/registry/stats-types.ts +60 -60
  87. package/src/reference/_generated/contracts.md +829 -595
  88. package/src/supabase/database.types.ts +2978 -2958
@@ -0,0 +1,40 @@
1
+ /**
2
+ * CRM API Schemas — SSOT subpath entry
3
+ *
4
+ * Re-exports all CRM-related Zod schemas from their canonical locations
5
+ * so consumers can import from a single surface:
6
+ * import { CrmSchemas, CrmPriorityOverrideSchema } from '@repo/core/business/crm/api-schemas'
7
+ *
8
+ * Schema definitions live in:
9
+ * packages/core/src/business/sales/api-schemas.ts (activity / recent-activity)
10
+ * packages/core/src/business/acquisition/crm-priority.ts (priority override shapes)
11
+ */
12
+
13
+ // ---------------------------------------------------------------------------
14
+ // Re-exports from sales/api-schemas (recent-activity surface)
15
+ // ---------------------------------------------------------------------------
16
+
17
+ export {
18
+ CrmActivityKindSchema,
19
+ RecentActivityEntrySchema,
20
+ GetRecentActivityQuerySchema,
21
+ GetRecentActivityResponseSchema,
22
+ CrmSchemas,
23
+ type CrmActivityKind,
24
+ type RecentActivityEntry,
25
+ type GetRecentActivityQuery,
26
+ type GetRecentActivityResponse
27
+ } from '../sales/api-schemas'
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // Re-exports from acquisition/crm-priority (priority override surface)
31
+ // ---------------------------------------------------------------------------
32
+
33
+ export {
34
+ CrmPriorityBucketKeySchema,
35
+ CrmPriorityBucketOverrideSchema,
36
+ CrmPriorityOverrideSchema,
37
+ type CrmPriorityBucketOverride,
38
+ type CrmPriorityOverride,
39
+ type ResolvedCrmPriorityRuleConfig
40
+ } from '../acquisition/crm-priority'
@@ -0,0 +1 @@
1
+ export * from './api-schemas'
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Deals API Schemas — SSOT subpath entry
3
+ *
4
+ * Re-exports all deal-related Zod schemas from their canonical locations
5
+ * so consumers can import from a single surface:
6
+ * import { DealSchemas, ... } from '@repo/core/business/deals/api-schemas'
7
+ *
8
+ * Schema definitions live in:
9
+ * packages/core/src/business/acquisition/api-schemas.ts (deal shapes)
10
+ * packages/core/src/business/acquisition/crm-priority.ts (priority overrides)
11
+ */
12
+
13
+ export {
14
+ // Enum schemas
15
+ DealStageSchema,
16
+ AcqDealTaskKindSchema,
17
+
18
+ // Params
19
+ DealIdParamsSchema,
20
+ DealTaskIdParamsSchema,
21
+
22
+ // Query schemas
23
+ ListDealsQuerySchema,
24
+ DealLookupQuerySchema,
25
+ ListDealTasksDueQuerySchema,
26
+
27
+ // Request body schemas
28
+ CreateDealNoteRequestSchema,
29
+ CreateDealTaskRequestSchema,
30
+ TransitionItemRequestSchema,
31
+ TransitionDealStateRequestSchema,
32
+ ExecuteActionParamsSchema,
33
+ ExecuteActionRequestSchema,
34
+
35
+ // Response schemas
36
+ DealContactSummarySchema,
37
+ DealPrioritySchema,
38
+ DealListItemSchema,
39
+ DealListResponseSchema,
40
+ DealSummaryResponseSchema,
41
+ DealLookupItemSchema,
42
+ DealLookupResponseSchema,
43
+ ConversationMessageSchema,
44
+ DealConversationSchema,
45
+ DealDetailResponseSchema,
46
+ DealNoteResponseSchema,
47
+ DealNoteListResponseSchema,
48
+ DealTaskResponseSchema,
49
+ DealTaskListResponseSchema,
50
+
51
+ // Bundled export
52
+ DealSchemas,
53
+
54
+ // Inferred types
55
+ type DealStage,
56
+ type AcqDealTaskKind,
57
+ type DealIdParams,
58
+ type DealTaskIdParams,
59
+ type ListDealsQuery,
60
+ type DealLookupQuery,
61
+ type ListDealTasksDueQuery,
62
+ type CreateDealNoteRequest,
63
+ type CreateDealTaskRequest,
64
+ type TransitionItemRequest,
65
+ type TransitionDealStateRequest,
66
+ type ExecuteActionParams,
67
+ type ExecuteActionRequest,
68
+ type DealPriorityResponse,
69
+ type DealListResponse,
70
+ type DealSummaryResponse,
71
+ type DealLookupItem,
72
+ type DealLookupResponse,
73
+ type ConversationMessage,
74
+ type DealDetailResponse,
75
+ type DealNoteResponse,
76
+ type DealNoteListResponse,
77
+ type DealTaskResponse,
78
+ type DealTaskListResponse
79
+ } from '../acquisition/api-schemas'
@@ -0,0 +1 @@
1
+ export * from './api-schemas'
@@ -1,89 +1,125 @@
1
- import type { Database } from '../../supabase/database.types'
2
-
3
- // Row types from Supabase
4
- export type ProjectRow = Database['public']['Tables']['prj_projects']['Row']
5
- export type ProjectInsert = Database['public']['Tables']['prj_projects']['Insert']
6
- export type ProjectUpdate = Database['public']['Tables']['prj_projects']['Update']
7
-
8
- export type MilestoneRow = Database['public']['Tables']['prj_milestones']['Row']
9
- export type MilestoneInsert = Database['public']['Tables']['prj_milestones']['Insert']
10
- export type MilestoneUpdate = Database['public']['Tables']['prj_milestones']['Update']
11
-
12
- export type TaskRow = Database['public']['Tables']['prj_tasks']['Row']
13
- export type TaskInsert = Database['public']['Tables']['prj_tasks']['Insert']
14
- export type TaskUpdate = Database['public']['Tables']['prj_tasks']['Update']
15
-
16
- export type NoteRow = Database['public']['Tables']['prj_notes']['Row']
17
- export type NoteInsert = Database['public']['Tables']['prj_notes']['Insert']
18
-
19
- // Status enums
20
- export type ProjectStatus = 'active' | 'on_track' | 'at_risk' | 'blocked' | 'completed' | 'paused'
21
-
22
- export type ProjectKind = 'client_engagement' | 'internal' | 'research' | 'other'
23
-
24
- export type MilestoneStatus = 'upcoming' | 'in_progress' | 'completed' | 'overdue' | 'blocked'
25
-
26
- export type TaskStatus =
27
- | 'planned'
28
- | 'in_progress'
29
- | 'blocked'
30
- | 'completed'
31
- | 'cancelled'
32
- | 'submitted'
33
- | 'approved'
34
- | 'rejected'
35
- | 'revision_requested'
36
-
37
- export type TaskType = 'documentation' | 'code' | 'report' | 'design' | 'other'
38
-
1
+ import type { Database } from '../../supabase/database.types'
2
+
3
+ // Row types from Supabase
4
+ export type ProjectRow = Database['public']['Tables']['prj_projects']['Row']
5
+ export type ProjectInsert = Database['public']['Tables']['prj_projects']['Insert']
6
+ export type ProjectUpdate = Database['public']['Tables']['prj_projects']['Update']
7
+
8
+ export type MilestoneRow = Database['public']['Tables']['prj_milestones']['Row']
9
+ export type MilestoneInsert = Database['public']['Tables']['prj_milestones']['Insert']
10
+ export type MilestoneUpdate = Database['public']['Tables']['prj_milestones']['Update']
11
+
12
+ export type TaskRow = Database['public']['Tables']['prj_tasks']['Row']
13
+ export type TaskInsert = Database['public']['Tables']['prj_tasks']['Insert']
14
+ export type TaskUpdate = Database['public']['Tables']['prj_tasks']['Update']
15
+
16
+ export type NoteRow = Database['public']['Tables']['prj_notes']['Row']
17
+ export type NoteInsert = Database['public']['Tables']['prj_notes']['Insert']
18
+
19
+ // Status enums
20
+ export type ProjectStatus = 'active' | 'on_track' | 'at_risk' | 'blocked' | 'completed' | 'paused'
21
+
22
+ export type ProjectKind = 'client_engagement' | 'internal' | 'research' | 'other'
23
+
24
+ export type MilestoneStatus = 'upcoming' | 'in_progress' | 'completed' | 'overdue' | 'blocked'
25
+
26
+ export type TaskStatus =
27
+ | 'planned'
28
+ | 'in_progress'
29
+ | 'blocked'
30
+ | 'completed'
31
+ | 'cancelled'
32
+ | 'submitted'
33
+ | 'approved'
34
+ | 'rejected'
35
+ | 'revision_requested'
36
+
37
+ export type TaskType = 'documentation' | 'code' | 'report' | 'design' | 'other'
38
+
39
39
  export type NoteType = 'call_note' | 'status_update' | 'issue' | 'blocker' | 'agent_learning'
40
-
41
- // Filter types
42
- export interface ProjectFilters {
43
- status?: ProjectStatus
44
- kind?: ProjectKind
45
- companyId?: string
46
- search?: string
47
- }
48
-
49
- export interface MilestoneFilters {
50
- status?: MilestoneStatus
51
- projectId?: string
52
- }
53
-
54
- export interface TaskFilters {
55
- status?: TaskStatus
56
- type?: TaskType
57
- milestoneId?: string
58
- projectId?: string
59
- }
60
-
61
- export interface NoteFilters {
62
- type?: NoteType
63
- projectId?: string
64
- }
65
-
66
- // Display types (for JOINed data)
67
- export interface ProjectWithCounts extends ProjectRow {
68
- milestoneCount: number
69
- taskCount: number
70
- completedMilestones?: number
71
- completedTasks?: number
72
- }
73
-
74
- export interface ProjectDetail extends ProjectRow {
75
- milestones: MilestoneRow[]
76
- tasks: TaskRow[]
77
- company: { id: string; name: string; domain: string | null } | null
78
- }
79
-
80
- export interface MilestoneWithTasks extends MilestoneRow {
81
- tasks: TaskRow[]
82
- }
83
-
84
- // Checklist item stored in prj_milestones.checklist JSONB column
85
- export interface ChecklistItem {
86
- id: string
87
- label: string
88
- completed: boolean
89
- }
40
+
41
+ // Filter types
42
+ export interface ProjectFilters {
43
+ status?: ProjectStatus
44
+ kind?: ProjectKind
45
+ companyId?: string
46
+ search?: string
47
+ }
48
+
49
+ export interface MilestoneFilters {
50
+ status?: MilestoneStatus
51
+ projectId?: string
52
+ }
53
+
54
+ export interface TaskFilters {
55
+ status?: TaskStatus
56
+ type?: TaskType
57
+ milestoneId?: string
58
+ projectId?: string
59
+ }
60
+
61
+ export interface NoteFilters {
62
+ type?: NoteType
63
+ projectId?: string
64
+ }
65
+
66
+ // Display types (for JOINed data)
67
+ export interface ProjectWithCounts extends ProjectRow {
68
+ milestoneCount: number
69
+ taskCount: number
70
+ completedMilestones?: number
71
+ completedTasks?: number
72
+ }
73
+
74
+ export interface ProjectDetail extends ProjectRow {
75
+ milestones: MilestoneRow[]
76
+ tasks: TaskRow[]
77
+ company: { id: string; name: string; domain: string | null } | null
78
+ }
79
+
80
+ export interface MilestoneWithTasks extends MilestoneRow {
81
+ tasks: TaskRow[]
82
+ }
83
+
84
+ // Checklist item stored in prj_milestones.checklist JSONB column
85
+ export interface ChecklistItem {
86
+ id: string
87
+ label: string
88
+ completed: boolean
89
+ }
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // CamelCase domain types (snake_case DB rows mapped via service.transformRow)
93
+ // ---------------------------------------------------------------------------
94
+
95
+ /**
96
+ * CamelCase domain type for a project row.
97
+ * Produced by ProjectsService.transformRow() from the snake_case ProjectRow.
98
+ */
99
+ export interface Project {
100
+ id: string
101
+ organizationId: string
102
+ name: string
103
+ kind: ProjectKind
104
+ status: ProjectStatus
105
+ description: string | null
106
+ dealId: string | null
107
+ clientCompanyId: string | null
108
+ startDate: string | null
109
+ targetEndDate: string | null
110
+ actualEndDate: string | null
111
+ contractValue: number | null
112
+ metadata: Record<string, unknown> | null
113
+ createdAt: string
114
+ updatedAt: string
115
+ }
116
+
117
+ /**
118
+ * CamelCase project with aggregated counts (for list views).
119
+ */
120
+ export interface ProjectSummary extends Project {
121
+ milestoneCount: number
122
+ taskCount: number
123
+ completedMilestones: number
124
+ completedTasks: number
125
+ }
@@ -1,80 +1,61 @@
1
- /**
2
- * Execution Runner Types
3
- *
4
- * Shared types for the Execution Runner UI feature.
5
- * Used by both API (apps/api) and frontend (apps/command-center).
6
- */
7
-
8
- import type { SerializedExecutionInterface } from '../../platform/registry/serialized-types'
9
- import type { ExecutionStatus } from './sse-executions'
10
-
11
- // ============================================================================
12
- // PAGINATION
13
- // ============================================================================
14
-
15
- export interface PaginationMetadata {
16
- total: number
17
- limit: number
18
- offset: number
19
- hasMore: boolean
20
- }
21
-
22
- // ============================================================================
23
- // EXECUTION METRICS
24
- // ============================================================================
25
-
26
- export interface ExecutionMetrics {
27
- tokenCount?: number
28
- stepCount?: number
29
- toolCallCount?: number
30
- }
31
-
32
- // ============================================================================
33
- // CATALOG TYPES
34
- // ============================================================================
35
-
36
- export interface ExecutionRunnerCatalogItem {
37
- resourceId: string
38
- resourceName: string
39
- resourceType: 'workflow' | 'agent'
40
- description?: string
41
- status: 'dev' | 'prod'
42
- version: string
43
- interface: SerializedExecutionInterface
44
- }
45
-
46
- export interface ExecutionRunnerCatalogResponse {
47
- resources: ExecutionRunnerCatalogItem[]
48
- }
49
-
50
- // ============================================================================
51
- // EXECUTION HISTORY TYPES
52
- // ============================================================================
53
-
54
- export interface ExecutionSummary {
55
- id: string
56
- resourceId: string
57
- resourceName: string
58
- status: ExecutionStatus
59
- startedAt: string
60
- completedAt?: string
61
- durationMs?: number
62
- metrics?: ExecutionMetrics
63
- input?: unknown
64
- output?: unknown
65
- error?: { message: string }
66
- }
67
-
68
- export interface ExecutionListResponse {
69
- executions: ExecutionSummary[]
70
- pagination: PaginationMetadata
71
- }
72
-
73
- // ============================================================================
74
- // RUN RESOURCE TYPES
75
- // ============================================================================
76
-
77
- export interface RunResourceResponse {
78
- executionId: string
79
- status: ExecutionStatus
80
- }
1
+ /**
2
+ * Execution Runner Types
3
+ *
4
+ * Shared types for execution history and run responses.
5
+ * Used by both API (apps/api) and frontend (apps/command-center).
6
+ */
7
+
8
+ import type { ExecutionStatus } from './sse-executions'
9
+
10
+ // ============================================================================
11
+ // PAGINATION
12
+ // ============================================================================
13
+
14
+ export interface PaginationMetadata {
15
+ total: number
16
+ limit: number
17
+ offset: number
18
+ hasMore: boolean
19
+ }
20
+
21
+ // ============================================================================
22
+ // EXECUTION METRICS
23
+ // ============================================================================
24
+
25
+ export interface ExecutionMetrics {
26
+ tokenCount?: number
27
+ stepCount?: number
28
+ toolCallCount?: number
29
+ }
30
+
31
+ // ============================================================================
32
+ // EXECUTION HISTORY TYPES
33
+ // ============================================================================
34
+
35
+ export interface ExecutionSummary {
36
+ id: string
37
+ resourceId: string
38
+ resourceName: string
39
+ status: ExecutionStatus
40
+ startedAt: string
41
+ completedAt?: string
42
+ durationMs?: number
43
+ metrics?: ExecutionMetrics
44
+ input?: unknown
45
+ output?: unknown
46
+ error?: { message: string }
47
+ }
48
+
49
+ export interface ExecutionListResponse {
50
+ executions: ExecutionSummary[]
51
+ pagination: PaginationMetadata
52
+ }
53
+
54
+ // ============================================================================
55
+ // RUN RESOURCE TYPES
56
+ // ============================================================================
57
+
58
+ export interface RunResourceResponse {
59
+ executionId: string
60
+ status: ExecutionStatus
61
+ }
@@ -297,9 +297,10 @@ export {
297
297
  type UpdateProposalDataParams,
298
298
  type MarkProposalSentParams,
299
299
  type MarkProposalReviewedParams,
300
- type UpdateCloseLostReasonParams,
301
- type UpdateFeesParams,
302
- type TransitionItemParams,
300
+ type UpdateCloseLostReasonParams,
301
+ type UpdateFeesParams,
302
+ type CacheInstantlyThreadIdsParams,
303
+ type TransitionItemParams,
303
304
  type SetContactNurtureParams,
304
305
  type CancelSchedulesAndHitlByEmailParams,
305
306
  type CancelHitlByDealIdParams,