@elevasis/core 0.11.2 → 0.13.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/index.d.ts +2 -1
- package/dist/index.js +8 -1
- package/dist/organization-model/index.d.ts +2 -1
- package/dist/organization-model/index.js +8 -1
- package/dist/test-utils/index.d.ts +27 -15
- package/dist/test-utils/index.js +25 -0
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +27 -270
- package/src/auth/multi-tenancy/credentials/__tests__/encryption.test.ts +217 -216
- package/src/auth/multi-tenancy/credentials/server/encryption.ts +69 -39
- package/src/auth/multi-tenancy/credentials/server/kek-loader.ts +37 -0
- package/src/auth/multi-tenancy/index.ts +3 -0
- package/src/auth/multi-tenancy/invitations/api-schemas.ts +104 -107
- package/src/auth/multi-tenancy/memberships/api-schemas.ts +6 -5
- package/src/auth/multi-tenancy/memberships/membership.ts +130 -138
- package/src/auth/multi-tenancy/permissions.ts +12 -5
- package/src/auth/multi-tenancy/role-management/api-schemas.ts +78 -0
- package/src/auth/multi-tenancy/role-management/index.ts +16 -0
- package/src/business/acquisition/activity-events.ts +142 -0
- package/src/business/acquisition/api-schemas.ts +694 -689
- package/src/business/acquisition/derive-actions.ts +90 -0
- package/src/business/acquisition/index.ts +111 -109
- package/src/execution/engine/index.ts +434 -434
- package/src/execution/engine/tools/integration/server/adapters/apify/__tests__/apify-run-actor.integration.test.ts +298 -293
- package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +0 -1
- package/src/execution/engine/tools/integration/service.test.ts +214 -0
- package/src/execution/engine/tools/integration/service.ts +169 -161
- package/src/execution/engine/tools/lead-service-types.ts +882 -879
- package/src/execution/engine/tools/registry.ts +699 -700
- package/src/execution/engine/tools/tool-maps.ts +777 -780
- package/src/integrations/credentials/__tests__/api-schemas.test.ts +420 -496
- package/src/integrations/credentials/api-schemas.ts +127 -143
- package/src/integrations/webhook-endpoints/__tests__/api-schemas.test.ts +327 -318
- package/src/integrations/webhook-endpoints/api-schemas.ts +103 -102
- package/src/integrations/webhook-endpoints/types.ts +58 -51
- package/src/operations/activities/api-schemas.ts +80 -79
- package/src/operations/activities/types.ts +64 -63
- package/src/organization-model/contracts.ts +1 -0
- package/src/organization-model/defaults.ts +6 -0
- package/src/organization-model/domains/navigation.ts +37 -23
- package/src/organization-model/organization-graph.mdx +2 -2
- package/src/organization-model/published.ts +2 -1
- package/src/platform/constants/versions.ts +1 -1
- package/src/reference/_generated/contracts.md +27 -270
- package/src/scaffold-registry/__tests__/index.test.ts +72 -7
- package/src/scaffold-registry/index.ts +163 -29
- package/src/scaffold-registry/schema.ts +68 -62
- package/src/server.ts +281 -272
- package/src/supabase/database.types.ts +16 -10
- package/src/test-utils/rls/RLSTestContext.ts +585 -553
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Individual event member schemas
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
const StageChangeEventSchema = z.object({
|
|
8
|
+
type: z.literal('stage_change'),
|
|
9
|
+
timestamp: z.string().datetime(),
|
|
10
|
+
stageBefore: z.string(),
|
|
11
|
+
stageAfter: z.string(),
|
|
12
|
+
reason: z.string().optional()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const StateChangeEventSchema = z.object({
|
|
16
|
+
type: z.literal('state_change'),
|
|
17
|
+
timestamp: z.string().datetime(),
|
|
18
|
+
stateBefore: z.string().nullable(),
|
|
19
|
+
stateAfter: z.string().nullable(),
|
|
20
|
+
reason: z.string().optional()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const ActionTakenEventSchema = z.object({
|
|
24
|
+
type: z.literal('action_taken'),
|
|
25
|
+
timestamp: z.string().datetime(),
|
|
26
|
+
actionKey: z.string(),
|
|
27
|
+
payload: z.record(z.string(), z.unknown()).optional()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const ApprovalCreatedEventSchema = z.object({
|
|
31
|
+
type: z.literal('approval_created'),
|
|
32
|
+
timestamp: z.string().datetime(),
|
|
33
|
+
commandId: z.string(),
|
|
34
|
+
dealStageBefore: z.string().optional(),
|
|
35
|
+
dealStageAfter: z.string().optional()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const ApprovalResolvedEventSchema = z.object({
|
|
39
|
+
type: z.literal('approval_resolved'),
|
|
40
|
+
timestamp: z.string().datetime(),
|
|
41
|
+
commandId: z.string(),
|
|
42
|
+
resolution: z.enum(['superseded']),
|
|
43
|
+
originResourceType: z.string().optional()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const ApprovalStaleEventSchema = z.object({
|
|
47
|
+
type: z.literal('approval_stale'),
|
|
48
|
+
timestamp: z.string().datetime(),
|
|
49
|
+
commandId: z.string(),
|
|
50
|
+
dealStageBefore: z.string().optional(),
|
|
51
|
+
dealStageAfter: z.string().optional()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const TaskCreatedEventSchema = z.object({
|
|
55
|
+
type: z.literal('task_created'),
|
|
56
|
+
timestamp: z.string().datetime(),
|
|
57
|
+
taskId: z.string()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const DealCreatedEventSchema = z.object({
|
|
61
|
+
type: z.literal('deal_created'),
|
|
62
|
+
timestamp: z.string().datetime()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const ReplyReceivedEventSchema = z.object({
|
|
66
|
+
type: z.literal('reply_received'),
|
|
67
|
+
timestamp: z.string().datetime(),
|
|
68
|
+
messageId: z.string().optional(),
|
|
69
|
+
source: z.string().optional()
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const ReplySentToLeadEventSchema = z.object({
|
|
73
|
+
type: z.literal('reply_sent_to_lead'),
|
|
74
|
+
timestamp: z.string().datetime(),
|
|
75
|
+
messageId: z.string().optional(),
|
|
76
|
+
source: z.string().optional()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const BookingNudgeSentEventSchema = z.object({
|
|
80
|
+
type: z.literal('booking_nudge_sent'),
|
|
81
|
+
timestamp: z.string().datetime(),
|
|
82
|
+
followupDay: z.number()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const ReminderSentEventSchema = z.object({
|
|
86
|
+
type: z.literal('reminder_sent'),
|
|
87
|
+
timestamp: z.string().datetime(),
|
|
88
|
+
followupDay: z.number().optional()
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const BookingCancelledEventSchema = z.object({
|
|
92
|
+
type: z.literal('booking_cancelled'),
|
|
93
|
+
timestamp: z.string().datetime(),
|
|
94
|
+
reason: z.string().optional()
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const DiscoverySubmittedEventSchema = z.object({
|
|
98
|
+
type: z.literal('discovery_submitted'),
|
|
99
|
+
timestamp: z.string().datetime()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const MovedToNurturingEventSchema = z.object({
|
|
103
|
+
type: z.literal('moved_to_nurturing'),
|
|
104
|
+
timestamp: z.string().datetime()
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const NoShowEventSchema = z.object({
|
|
108
|
+
type: z.literal('no_show'),
|
|
109
|
+
timestamp: z.string().datetime()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
const FollowupEmailSentEventSchema = z.object({
|
|
113
|
+
type: z.literal('followup_email_sent'),
|
|
114
|
+
timestamp: z.string().datetime(),
|
|
115
|
+
followupDay: z.number().optional()
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Union
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
|
|
122
|
+
export const ActivityEventSchema = z.discriminatedUnion('type', [
|
|
123
|
+
StageChangeEventSchema,
|
|
124
|
+
StateChangeEventSchema,
|
|
125
|
+
ActionTakenEventSchema,
|
|
126
|
+
ApprovalCreatedEventSchema,
|
|
127
|
+
ApprovalResolvedEventSchema,
|
|
128
|
+
ApprovalStaleEventSchema,
|
|
129
|
+
TaskCreatedEventSchema,
|
|
130
|
+
DealCreatedEventSchema,
|
|
131
|
+
ReplyReceivedEventSchema,
|
|
132
|
+
ReplySentToLeadEventSchema,
|
|
133
|
+
BookingNudgeSentEventSchema,
|
|
134
|
+
ReminderSentEventSchema,
|
|
135
|
+
BookingCancelledEventSchema,
|
|
136
|
+
DiscoverySubmittedEventSchema,
|
|
137
|
+
MovedToNurturingEventSchema,
|
|
138
|
+
NoShowEventSchema,
|
|
139
|
+
FollowupEmailSentEventSchema
|
|
140
|
+
])
|
|
141
|
+
|
|
142
|
+
export type ActivityEvent = z.infer<typeof ActivityEventSchema>
|