@classytic/crm 0.3.0 → 0.5.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/CHANGELOG.md +114 -0
- package/README.md +157 -255
- package/dist/events.d.ts +2 -0
- package/dist/events.js +716 -0
- package/dist/index.d.ts +732 -820
- package/dist/index.js +1055 -214
- package/dist/index2.d.ts +746 -0
- package/package.json +13 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- /package/dist/{chunk.js → rolldown-runtime.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,382 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as mongoose0 from "mongoose";
|
|
1
|
+
import * as mongoose1 from "mongoose";
|
|
3
2
|
import { Connection, Model, Schema, SchemaDefinitionProperty } from "mongoose";
|
|
4
3
|
import { PaginationConfig, PluginType, Repository } from "@classytic/mongokit";
|
|
5
4
|
import { DomainEvent, EventHandler, EventMeta, EventTransport } from "@classytic/primitives/events";
|
|
6
|
-
import * as _classytic_primitives_state_machine0 from "@classytic/primitives/state-machine";
|
|
7
5
|
import { z } from "zod";
|
|
8
|
-
import { StatusChangeEntry, StatusHistory, appendStatus, lastTransitionTo, latestEntry, timeInStatus } from "@classytic/primitives/status-history";
|
|
9
6
|
import { OperationContext } from "@classytic/primitives/context";
|
|
10
7
|
|
|
8
|
+
//#region src/events/event-constants.d.ts
|
|
9
|
+
/** PACKAGE_RULES rule 12: `package:resource.verb`. */
|
|
10
|
+
declare const CRM_EVENTS: {
|
|
11
|
+
readonly LEAD_CREATED: "crm:lead.created";
|
|
12
|
+
readonly LEAD_STATUS_CHANGED: "crm:lead.status_changed";
|
|
13
|
+
readonly LEAD_SCORED: "crm:lead.scored";
|
|
14
|
+
readonly LEAD_CONVERTED: "crm:lead.converted";
|
|
15
|
+
readonly LEAD_DISQUALIFIED: "crm:lead.disqualified";
|
|
16
|
+
readonly ACCOUNT_CREATED: "crm:account.created";
|
|
17
|
+
readonly ACCOUNT_UPDATED: "crm:account.updated";
|
|
18
|
+
readonly CONTACT_CREATED: "crm:contact.created";
|
|
19
|
+
readonly CONTACT_UPDATED: "crm:contact.updated";
|
|
20
|
+
readonly OPPORTUNITY_CREATED: "crm:opportunity.created";
|
|
21
|
+
readonly OPPORTUNITY_STAGE_ADVANCED: "crm:opportunity.stage_advanced";
|
|
22
|
+
readonly OPPORTUNITY_STAGE_REGRESSED: "crm:opportunity.stage_regressed";
|
|
23
|
+
readonly OPPORTUNITY_WON: "crm:opportunity.won";
|
|
24
|
+
readonly OPPORTUNITY_LOST: "crm:opportunity.lost";
|
|
25
|
+
readonly OPPORTUNITY_ABANDONED: "crm:opportunity.abandoned";
|
|
26
|
+
readonly PIPELINE_CREATED: "crm:pipeline.created";
|
|
27
|
+
readonly PIPELINE_ARCHIVED: "crm:pipeline.archived";
|
|
28
|
+
readonly ACTIVITY_PLANNED: "crm:activity.planned";
|
|
29
|
+
readonly ACTIVITY_COMPLETED: "crm:activity.completed";
|
|
30
|
+
readonly ACTIVITY_CANCELLED: "crm:activity.cancelled";
|
|
31
|
+
readonly NOTE_ADDED: "crm:note.added";
|
|
32
|
+
readonly CAMPAIGN_CREATED: "crm:campaign.created";
|
|
33
|
+
readonly CAMPAIGN_ACTIVATED: "crm:campaign.activated";
|
|
34
|
+
readonly CAMPAIGN_PAUSED: "crm:campaign.paused";
|
|
35
|
+
readonly CAMPAIGN_RESUMED: "crm:campaign.resumed";
|
|
36
|
+
readonly CAMPAIGN_COMPLETED: "crm:campaign.completed";
|
|
37
|
+
readonly CAMPAIGN_ARCHIVED: "crm:campaign.archived";
|
|
38
|
+
readonly SUBSCRIPTION_CREATED: "crm:subscription.created";
|
|
39
|
+
readonly SUBSCRIPTION_CONFIRMED: "crm:subscription.confirmed";
|
|
40
|
+
readonly SUBSCRIPTION_UNSUBSCRIBED: "crm:subscription.unsubscribed";
|
|
41
|
+
readonly SUBSCRIPTION_BOUNCED: "crm:subscription.bounced";
|
|
42
|
+
readonly SUBSCRIPTION_COMPLAINED: "crm:subscription.complained";
|
|
43
|
+
readonly EMAIL_EVENT_OPENED: "crm:email_event.opened";
|
|
44
|
+
readonly EMAIL_EVENT_CLICKED: "crm:email_event.clicked";
|
|
45
|
+
readonly EMAIL_EVENT_BOUNCED: "crm:email_event.bounced";
|
|
46
|
+
readonly EMAIL_EVENT_COMPLAINED: "crm:email_event.complained";
|
|
47
|
+
readonly EMAIL_EVENT_UNSUBSCRIBED: "crm:email_event.unsubscribed";
|
|
48
|
+
readonly LEAD_ENRICHED: "crm:lead.enriched";
|
|
49
|
+
readonly LEAD_ASSIGNED: "crm:lead.assigned";
|
|
50
|
+
readonly CONTACT_ENRICHED: "crm:contact.enriched";
|
|
51
|
+
readonly CONTACT_ASSIGNED: "crm:contact.assigned";
|
|
52
|
+
readonly CONTACT_MERGED: "crm:contact.merged";
|
|
53
|
+
readonly ACCOUNT_ENRICHED: "crm:account.enriched";
|
|
54
|
+
readonly ACCOUNT_ASSIGNED: "crm:account.assigned";
|
|
55
|
+
readonly ACCOUNT_MERGED: "crm:account.merged";
|
|
56
|
+
readonly OPPORTUNITY_ASSIGNED: "crm:opportunity.assigned";
|
|
57
|
+
readonly OPPORTUNITY_AMOUNT_CHANGED: "crm:opportunity.amount_changed";
|
|
58
|
+
readonly OPPORTUNITY_EXTENDED: "crm:opportunity.extended";
|
|
59
|
+
readonly ACTIVITY_RESCHEDULED: "crm:activity.rescheduled";
|
|
60
|
+
readonly ACTIVITY_OUTCOME_RECORDED: "crm:activity.outcome_recorded";
|
|
61
|
+
readonly CONVERSATION_CREATED: "crm:conversation.created";
|
|
62
|
+
readonly CONVERSATION_ASSIGNED: "crm:conversation.assigned";
|
|
63
|
+
readonly CONVERSATION_RESOLVED: "crm:conversation.resolved";
|
|
64
|
+
readonly CONVERSATION_REOPENED: "crm:conversation.reopened";
|
|
65
|
+
readonly MESSAGE_RECEIVED: "crm:message.received";
|
|
66
|
+
readonly MESSAGE_SENT: "crm:message.sent";
|
|
67
|
+
};
|
|
68
|
+
type CrmEventName = (typeof CRM_EVENTS)[keyof typeof CRM_EVENTS];
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/events/event-catalog.d.ts
|
|
71
|
+
|
|
72
|
+
/** JSON-Schema object produced by `z.toJSONSchema` — what arc's registry consumes. */
|
|
73
|
+
type CrmEventSchema = Record<string, unknown>;
|
|
74
|
+
/** Structurally identical to arc's `EventDefinitionOutput` — do NOT import arc. */
|
|
75
|
+
interface CrmEventDefinition<TSchema extends z.ZodType = z.ZodType> {
|
|
76
|
+
name: CrmEventName;
|
|
77
|
+
version: number;
|
|
78
|
+
description: string;
|
|
79
|
+
zodSchema: TSchema;
|
|
80
|
+
schema: CrmEventSchema;
|
|
81
|
+
create(payload: z.infer<TSchema>, meta?: Partial<EventMeta>): DomainEvent<z.infer<TSchema>>;
|
|
82
|
+
}
|
|
83
|
+
declare const LeadCreated: CrmEventDefinition<z.ZodObject<{
|
|
84
|
+
leadId: z.ZodString;
|
|
85
|
+
email: z.ZodOptional<z.ZodString>;
|
|
86
|
+
score: z.ZodNumber;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
declare const LeadStatusChanged: CrmEventDefinition<z.ZodObject<{
|
|
89
|
+
leadId: z.ZodString;
|
|
90
|
+
from: z.ZodString;
|
|
91
|
+
to: z.ZodString;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
declare const LeadScored: CrmEventDefinition<z.ZodObject<{
|
|
94
|
+
leadId: z.ZodString;
|
|
95
|
+
score: z.ZodNumber;
|
|
96
|
+
}, z.core.$strip>>;
|
|
97
|
+
declare const LeadConverted: CrmEventDefinition<z.ZodObject<{
|
|
98
|
+
leadId: z.ZodString;
|
|
99
|
+
contactId: z.ZodString;
|
|
100
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
101
|
+
opportunityId: z.ZodString;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
declare const LeadDisqualified: CrmEventDefinition<z.ZodObject<{
|
|
104
|
+
leadId: z.ZodString;
|
|
105
|
+
reason: z.ZodString;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
declare const LeadEnriched: CrmEventDefinition<z.ZodObject<{
|
|
108
|
+
leadId: z.ZodString;
|
|
109
|
+
fields: z.ZodArray<z.ZodString>;
|
|
110
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
declare const LeadAssigned: CrmEventDefinition<z.ZodObject<{
|
|
113
|
+
leadId: z.ZodString;
|
|
114
|
+
ownerId: z.ZodString;
|
|
115
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
declare const AccountCreated: CrmEventDefinition<z.ZodObject<{
|
|
118
|
+
accountId: z.ZodString;
|
|
119
|
+
name: z.ZodString;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
declare const AccountUpdated: CrmEventDefinition<z.ZodObject<{
|
|
122
|
+
accountId: z.ZodString;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
declare const AccountEnriched: CrmEventDefinition<z.ZodObject<{
|
|
125
|
+
accountId: z.ZodString;
|
|
126
|
+
fields: z.ZodArray<z.ZodString>;
|
|
127
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
declare const AccountAssigned: CrmEventDefinition<z.ZodObject<{
|
|
130
|
+
accountId: z.ZodString;
|
|
131
|
+
ownerId: z.ZodString;
|
|
132
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
declare const AccountMerged: CrmEventDefinition<z.ZodObject<{
|
|
135
|
+
primaryId: z.ZodString;
|
|
136
|
+
secondaryId: z.ZodString;
|
|
137
|
+
strategy: z.ZodEnum<{
|
|
138
|
+
preferPrimary: "preferPrimary";
|
|
139
|
+
preferSecondary: "preferSecondary";
|
|
140
|
+
}>;
|
|
141
|
+
}, z.core.$strip>>;
|
|
142
|
+
declare const ContactCreated: CrmEventDefinition<z.ZodObject<{
|
|
143
|
+
contactId: z.ZodString;
|
|
144
|
+
email: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, z.core.$strip>>;
|
|
146
|
+
declare const ContactUpdated: CrmEventDefinition<z.ZodObject<{
|
|
147
|
+
contactId: z.ZodString;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
declare const ContactEnriched: CrmEventDefinition<z.ZodObject<{
|
|
150
|
+
contactId: z.ZodString;
|
|
151
|
+
fields: z.ZodArray<z.ZodString>;
|
|
152
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
declare const ContactAssigned: CrmEventDefinition<z.ZodObject<{
|
|
155
|
+
contactId: z.ZodString;
|
|
156
|
+
ownerId: z.ZodString;
|
|
157
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
declare const ContactMerged: CrmEventDefinition<z.ZodObject<{
|
|
160
|
+
primaryId: z.ZodString;
|
|
161
|
+
secondaryId: z.ZodString;
|
|
162
|
+
strategy: z.ZodEnum<{
|
|
163
|
+
preferPrimary: "preferPrimary";
|
|
164
|
+
preferSecondary: "preferSecondary";
|
|
165
|
+
}>;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
declare const OpportunityCreated: CrmEventDefinition<z.ZodObject<{
|
|
168
|
+
opportunityId: z.ZodString;
|
|
169
|
+
pipelineId: z.ZodString;
|
|
170
|
+
stageId: z.ZodString;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
declare const OpportunityStageAdvanced: CrmEventDefinition<z.ZodObject<{
|
|
173
|
+
opportunityId: z.ZodString;
|
|
174
|
+
from: z.ZodObject<{
|
|
175
|
+
stageId: z.ZodString;
|
|
176
|
+
sequence: z.ZodNumber;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
to: z.ZodObject<{
|
|
179
|
+
stageId: z.ZodString;
|
|
180
|
+
sequence: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
}, z.core.$strip>>;
|
|
183
|
+
declare const OpportunityStageRegressed: CrmEventDefinition<z.ZodObject<{
|
|
184
|
+
opportunityId: z.ZodString;
|
|
185
|
+
from: z.ZodObject<{
|
|
186
|
+
stageId: z.ZodString;
|
|
187
|
+
sequence: z.ZodNumber;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
to: z.ZodObject<{
|
|
190
|
+
stageId: z.ZodString;
|
|
191
|
+
sequence: z.ZodNumber;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
declare const OpportunityWon: CrmEventDefinition<z.ZodObject<{
|
|
195
|
+
opportunityId: z.ZodString;
|
|
196
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
declare const OpportunityLost: CrmEventDefinition<z.ZodObject<{
|
|
199
|
+
opportunityId: z.ZodString;
|
|
200
|
+
lostReasonId: z.ZodOptional<z.ZodString>;
|
|
201
|
+
}, z.core.$strip>>;
|
|
202
|
+
declare const OpportunityAbandoned: CrmEventDefinition<z.ZodObject<{
|
|
203
|
+
opportunityId: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
declare const OpportunityAssigned: CrmEventDefinition<z.ZodObject<{
|
|
206
|
+
opportunityId: z.ZodString;
|
|
207
|
+
ownerId: z.ZodString;
|
|
208
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, z.core.$strip>>;
|
|
210
|
+
declare const OpportunityAmountChanged: CrmEventDefinition<z.ZodObject<{
|
|
211
|
+
opportunityId: z.ZodString;
|
|
212
|
+
amount: z.ZodNumber;
|
|
213
|
+
previousAmount: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
215
|
+
by: z.ZodOptional<z.ZodString>;
|
|
216
|
+
}, z.core.$strip>>;
|
|
217
|
+
declare const OpportunityExtended: CrmEventDefinition<z.ZodObject<{
|
|
218
|
+
opportunityId: z.ZodString;
|
|
219
|
+
expectedCloseAt: z.ZodISODateTime;
|
|
220
|
+
previousExpectedCloseAt: z.ZodOptional<z.ZodISODateTime>;
|
|
221
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
222
|
+
by: z.ZodOptional<z.ZodString>;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
declare const PipelineCreated: CrmEventDefinition<z.ZodObject<{
|
|
225
|
+
pipelineId: z.ZodString;
|
|
226
|
+
}, z.core.$strip>>;
|
|
227
|
+
declare const PipelineArchived: CrmEventDefinition<z.ZodObject<{
|
|
228
|
+
pipelineId: z.ZodString;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
declare const ActivityPlanned: CrmEventDefinition<z.ZodObject<{
|
|
231
|
+
activityId: z.ZodString;
|
|
232
|
+
type: z.ZodString;
|
|
233
|
+
subjectKind: z.ZodString;
|
|
234
|
+
subjectId: z.ZodString;
|
|
235
|
+
}, z.core.$strip>>;
|
|
236
|
+
declare const ActivityCompleted: CrmEventDefinition<z.ZodObject<{
|
|
237
|
+
activityId: z.ZodString;
|
|
238
|
+
completedAt: z.ZodISODateTime;
|
|
239
|
+
}, z.core.$strip>>;
|
|
240
|
+
declare const ActivityCancelled: CrmEventDefinition<z.ZodObject<{
|
|
241
|
+
activityId: z.ZodString;
|
|
242
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
243
|
+
}, z.core.$strip>>;
|
|
244
|
+
declare const ActivityRescheduled: CrmEventDefinition<z.ZodObject<{
|
|
245
|
+
activityId: z.ZodString;
|
|
246
|
+
dueDate: z.ZodISODateTime;
|
|
247
|
+
previousDueDate: z.ZodOptional<z.ZodISODateTime>;
|
|
248
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
249
|
+
by: z.ZodOptional<z.ZodString>;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
declare const ActivityOutcomeRecorded: CrmEventDefinition<z.ZodObject<{
|
|
252
|
+
activityId: z.ZodString;
|
|
253
|
+
outcome: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
254
|
+
}, z.core.$strip>>;
|
|
255
|
+
declare const NoteAdded: CrmEventDefinition<z.ZodObject<{
|
|
256
|
+
noteId: z.ZodString;
|
|
257
|
+
subjectKind: z.ZodString;
|
|
258
|
+
subjectId: z.ZodString;
|
|
259
|
+
}, z.core.$strip>>;
|
|
260
|
+
declare const CampaignCreated: CrmEventDefinition<z.ZodObject<{
|
|
261
|
+
campaignId: z.ZodString;
|
|
262
|
+
name: z.ZodString;
|
|
263
|
+
}, z.core.$strip>>;
|
|
264
|
+
declare const CampaignActivated: CrmEventDefinition<z.ZodObject<{
|
|
265
|
+
campaignId: z.ZodString;
|
|
266
|
+
}, z.core.$strip>>;
|
|
267
|
+
declare const CampaignPaused: CrmEventDefinition<z.ZodObject<{
|
|
268
|
+
campaignId: z.ZodString;
|
|
269
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
270
|
+
}, z.core.$strip>>;
|
|
271
|
+
declare const CampaignResumed: CrmEventDefinition<z.ZodObject<{
|
|
272
|
+
campaignId: z.ZodString;
|
|
273
|
+
}, z.core.$strip>>;
|
|
274
|
+
declare const CampaignCompleted: CrmEventDefinition<z.ZodObject<{
|
|
275
|
+
campaignId: z.ZodString;
|
|
276
|
+
actualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
277
|
+
}, z.core.$strip>>;
|
|
278
|
+
declare const CampaignArchived: CrmEventDefinition<z.ZodObject<{
|
|
279
|
+
campaignId: z.ZodString;
|
|
280
|
+
}, z.core.$strip>>;
|
|
281
|
+
declare const SubscriptionCreated: CrmEventDefinition<z.ZodObject<{
|
|
282
|
+
subscriptionId: z.ZodString;
|
|
283
|
+
contactId: z.ZodString;
|
|
284
|
+
campaignId: z.ZodString;
|
|
285
|
+
requiresConfirmation: z.ZodBoolean;
|
|
286
|
+
}, z.core.$strip>>;
|
|
287
|
+
declare const SubscriptionConfirmed: CrmEventDefinition<z.ZodObject<{
|
|
288
|
+
subscriptionId: z.ZodString;
|
|
289
|
+
contactId: z.ZodString;
|
|
290
|
+
campaignId: z.ZodString;
|
|
291
|
+
confirmedAt: z.ZodISODateTime;
|
|
292
|
+
}, z.core.$strip>>;
|
|
293
|
+
declare const SubscriptionUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
294
|
+
subscriptionId: z.ZodString;
|
|
295
|
+
contactId: z.ZodString;
|
|
296
|
+
campaignId: z.ZodString;
|
|
297
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
298
|
+
}, z.core.$strip>>;
|
|
299
|
+
declare const SubscriptionBounced: CrmEventDefinition<z.ZodObject<{
|
|
300
|
+
subscriptionId: z.ZodString;
|
|
301
|
+
contactId: z.ZodString;
|
|
302
|
+
campaignId: z.ZodString;
|
|
303
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
304
|
+
}, z.core.$strip>>;
|
|
305
|
+
declare const SubscriptionComplained: CrmEventDefinition<z.ZodObject<{
|
|
306
|
+
subscriptionId: z.ZodString;
|
|
307
|
+
contactId: z.ZodString;
|
|
308
|
+
campaignId: z.ZodString;
|
|
309
|
+
}, z.core.$strip>>;
|
|
310
|
+
declare const EmailEventOpened: CrmEventDefinition<z.ZodObject<{
|
|
311
|
+
eventId: z.ZodString;
|
|
312
|
+
kind: z.ZodString;
|
|
313
|
+
subjectKind: z.ZodString;
|
|
314
|
+
subjectId: z.ZodString;
|
|
315
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
316
|
+
}, z.core.$strip>>;
|
|
317
|
+
declare const EmailEventClicked: CrmEventDefinition<z.ZodObject<{
|
|
318
|
+
eventId: z.ZodString;
|
|
319
|
+
kind: z.ZodString;
|
|
320
|
+
subjectKind: z.ZodString;
|
|
321
|
+
subjectId: z.ZodString;
|
|
322
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
323
|
+
}, z.core.$strip>>;
|
|
324
|
+
declare const EmailEventBounced: CrmEventDefinition<z.ZodObject<{
|
|
325
|
+
eventId: z.ZodString;
|
|
326
|
+
kind: z.ZodString;
|
|
327
|
+
subjectKind: z.ZodString;
|
|
328
|
+
subjectId: z.ZodString;
|
|
329
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
330
|
+
}, z.core.$strip>>;
|
|
331
|
+
declare const EmailEventComplained: CrmEventDefinition<z.ZodObject<{
|
|
332
|
+
eventId: z.ZodString;
|
|
333
|
+
kind: z.ZodString;
|
|
334
|
+
subjectKind: z.ZodString;
|
|
335
|
+
subjectId: z.ZodString;
|
|
336
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
337
|
+
}, z.core.$strip>>;
|
|
338
|
+
declare const EmailEventUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
339
|
+
eventId: z.ZodString;
|
|
340
|
+
kind: z.ZodString;
|
|
341
|
+
subjectKind: z.ZodString;
|
|
342
|
+
subjectId: z.ZodString;
|
|
343
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
344
|
+
}, z.core.$strip>>;
|
|
345
|
+
declare const ConversationCreated: CrmEventDefinition<z.ZodObject<{
|
|
346
|
+
conversationId: z.ZodString;
|
|
347
|
+
channel: z.ZodString;
|
|
348
|
+
participantKind: z.ZodString;
|
|
349
|
+
participantId: z.ZodString;
|
|
350
|
+
}, z.core.$strip>>;
|
|
351
|
+
declare const ConversationAssigned: CrmEventDefinition<z.ZodObject<{
|
|
352
|
+
conversationId: z.ZodString;
|
|
353
|
+
assigneeId: z.ZodString;
|
|
354
|
+
previousAssigneeId: z.ZodOptional<z.ZodString>;
|
|
355
|
+
}, z.core.$strip>>;
|
|
356
|
+
declare const ConversationResolved: CrmEventDefinition<z.ZodObject<{
|
|
357
|
+
conversationId: z.ZodString;
|
|
358
|
+
status: z.ZodString;
|
|
359
|
+
previousStatus: z.ZodString;
|
|
360
|
+
}, z.core.$strip>>;
|
|
361
|
+
declare const ConversationReopened: CrmEventDefinition<z.ZodObject<{
|
|
362
|
+
conversationId: z.ZodString;
|
|
363
|
+
status: z.ZodString;
|
|
364
|
+
previousStatus: z.ZodString;
|
|
365
|
+
}, z.core.$strip>>;
|
|
366
|
+
declare const MessageReceived: CrmEventDefinition<z.ZodObject<{
|
|
367
|
+
messageId: z.ZodString;
|
|
368
|
+
conversationId: z.ZodString;
|
|
369
|
+
direction: z.ZodString;
|
|
370
|
+
externalMessageId: z.ZodOptional<z.ZodString>;
|
|
371
|
+
}, z.core.$strip>>;
|
|
372
|
+
declare const MessageSent: CrmEventDefinition<z.ZodObject<{
|
|
373
|
+
messageId: z.ZodString;
|
|
374
|
+
conversationId: z.ZodString;
|
|
375
|
+
direction: z.ZodString;
|
|
376
|
+
externalMessageId: z.ZodOptional<z.ZodString>;
|
|
377
|
+
}, z.core.$strip>>;
|
|
378
|
+
declare const crmEventDefinitions: ReadonlyArray<CrmEventDefinition>;
|
|
379
|
+
//#endregion
|
|
11
380
|
//#region src/models/tenant-field.d.ts
|
|
12
381
|
type TenantFieldType = 'objectId' | 'string';
|
|
13
382
|
interface SchemaBuildConfig {
|
|
@@ -23,7 +392,7 @@ declare function tenantFieldDef(config: SchemaBuildConfig): SchemaDefinitionProp
|
|
|
23
392
|
//#region src/models/pipeline.schema.d.ts
|
|
24
393
|
/** Mongoose document shape for a single embedded stage. */
|
|
25
394
|
interface IStageDocument {
|
|
26
|
-
_id:
|
|
395
|
+
_id: mongoose1.Types.ObjectId;
|
|
27
396
|
name: string;
|
|
28
397
|
/** Ascending order in the pipeline. Treated as identifier on `moveToStage`. */
|
|
29
398
|
sequence: number;
|
|
@@ -34,8 +403,8 @@ interface IStageDocument {
|
|
|
34
403
|
}
|
|
35
404
|
/** Mongoose document shape for a Pipeline. */
|
|
36
405
|
interface IPipelineDocument {
|
|
37
|
-
_id:
|
|
38
|
-
organizationId:
|
|
406
|
+
_id: mongoose1.Types.ObjectId;
|
|
407
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
39
408
|
name: string;
|
|
40
409
|
/** Deprecates the pipeline — existing opps still move, no new ones created. */
|
|
41
410
|
isArchived: boolean;
|
|
@@ -74,8 +443,8 @@ interface ILeadStatusEntry {
|
|
|
74
443
|
note?: string;
|
|
75
444
|
}
|
|
76
445
|
interface ILeadDocument {
|
|
77
|
-
_id:
|
|
78
|
-
organizationId:
|
|
446
|
+
_id: mongoose1.Types.ObjectId;
|
|
447
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
79
448
|
fullName: string;
|
|
80
449
|
firstName?: string;
|
|
81
450
|
lastName?: string;
|
|
@@ -90,9 +459,9 @@ interface ILeadDocument {
|
|
|
90
459
|
statusHistory: ILeadStatusEntry[];
|
|
91
460
|
ownerId?: string;
|
|
92
461
|
tags: string[];
|
|
93
|
-
convertedContactId?:
|
|
94
|
-
convertedAccountId?:
|
|
95
|
-
convertedOpportunityId?:
|
|
462
|
+
convertedContactId?: mongoose1.Types.ObjectId | string;
|
|
463
|
+
convertedAccountId?: mongoose1.Types.ObjectId | string;
|
|
464
|
+
convertedOpportunityId?: mongoose1.Types.ObjectId | string;
|
|
96
465
|
convertedAt?: Date;
|
|
97
466
|
disqualifyReason?: string;
|
|
98
467
|
metadata?: Record<string, unknown>;
|
|
@@ -124,12 +493,12 @@ interface IOpportunityStatusEntry {
|
|
|
124
493
|
note?: string;
|
|
125
494
|
}
|
|
126
495
|
interface IOpportunityDocument {
|
|
127
|
-
_id:
|
|
128
|
-
organizationId:
|
|
496
|
+
_id: mongoose1.Types.ObjectId;
|
|
497
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
129
498
|
name: string;
|
|
130
|
-
accountId?:
|
|
131
|
-
primaryContactId?:
|
|
132
|
-
pipelineId:
|
|
499
|
+
accountId?: mongoose1.Types.ObjectId | string;
|
|
500
|
+
primaryContactId?: mongoose1.Types.ObjectId | string;
|
|
501
|
+
pipelineId: mongoose1.Types.ObjectId | string;
|
|
133
502
|
stageId: string;
|
|
134
503
|
status: OpportunityStatus;
|
|
135
504
|
statusHistory: IOpportunityStatusEntry[];
|
|
@@ -138,9 +507,9 @@ interface IOpportunityDocument {
|
|
|
138
507
|
probability: number;
|
|
139
508
|
expectedCloseAt?: Date;
|
|
140
509
|
closedAt?: Date;
|
|
141
|
-
lostReasonId?:
|
|
510
|
+
lostReasonId?: mongoose1.Types.ObjectId | string;
|
|
142
511
|
ownerId?: string;
|
|
143
|
-
sourceLeadId?:
|
|
512
|
+
sourceLeadId?: mongoose1.Types.ObjectId | string;
|
|
144
513
|
tags: string[];
|
|
145
514
|
metadata?: Record<string, unknown>;
|
|
146
515
|
createdAt: Date;
|
|
@@ -163,14 +532,18 @@ interface IContactInfoEmbedded {
|
|
|
163
532
|
personalEmail?: string;
|
|
164
533
|
phone?: string;
|
|
165
534
|
alternatePhone?: string;
|
|
535
|
+
whatsapp?: string;
|
|
536
|
+
telegram?: string;
|
|
537
|
+
linkedin?: string;
|
|
538
|
+
instagram?: string;
|
|
166
539
|
}
|
|
167
540
|
interface IContactDocument {
|
|
168
|
-
_id:
|
|
169
|
-
organizationId:
|
|
541
|
+
_id: mongoose1.Types.ObjectId;
|
|
542
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
170
543
|
name: IContactName;
|
|
171
544
|
contact: IContactInfoEmbedded;
|
|
172
545
|
jobTitle?: string;
|
|
173
|
-
accountId?:
|
|
546
|
+
accountId?: mongoose1.Types.ObjectId | string;
|
|
174
547
|
ownerId?: string;
|
|
175
548
|
tags: string[];
|
|
176
549
|
metadata?: Record<string, unknown>;
|
|
@@ -182,8 +555,8 @@ declare function createContactModel(connection: Connection, config: SchemaBuildC
|
|
|
182
555
|
//#endregion
|
|
183
556
|
//#region src/models/account.schema.d.ts
|
|
184
557
|
interface IAccountDocument {
|
|
185
|
-
_id:
|
|
186
|
-
organizationId:
|
|
558
|
+
_id: mongoose1.Types.ObjectId;
|
|
559
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
187
560
|
name: string;
|
|
188
561
|
domain?: string;
|
|
189
562
|
industry?: string;
|
|
@@ -222,8 +595,8 @@ interface ICampaignStatusEntry {
|
|
|
222
595
|
note?: string;
|
|
223
596
|
}
|
|
224
597
|
interface ICampaignDocument {
|
|
225
|
-
_id:
|
|
226
|
-
organizationId:
|
|
598
|
+
_id: mongoose1.Types.ObjectId;
|
|
599
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
227
600
|
name: string;
|
|
228
601
|
description?: string;
|
|
229
602
|
status: CampaignStatus;
|
|
@@ -273,10 +646,10 @@ interface ISubscriptionStatusEntry {
|
|
|
273
646
|
note?: string;
|
|
274
647
|
}
|
|
275
648
|
interface ISubscriptionDocument {
|
|
276
|
-
_id:
|
|
277
|
-
organizationId:
|
|
278
|
-
contactId:
|
|
279
|
-
campaignId:
|
|
649
|
+
_id: mongoose1.Types.ObjectId;
|
|
650
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
651
|
+
contactId: mongoose1.Types.ObjectId | string;
|
|
652
|
+
campaignId: mongoose1.Types.ObjectId | string;
|
|
280
653
|
status: SubscriptionStatus;
|
|
281
654
|
statusHistory: ISubscriptionStatusEntry[];
|
|
282
655
|
source?: string;
|
|
@@ -321,12 +694,12 @@ type SubjectKind = (typeof SUBJECT_KINDS)[number];
|
|
|
321
694
|
//#endregion
|
|
322
695
|
//#region src/models/activity.schema.d.ts
|
|
323
696
|
interface IActivityDocument {
|
|
324
|
-
_id:
|
|
325
|
-
organizationId:
|
|
697
|
+
_id: mongoose1.Types.ObjectId;
|
|
698
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
326
699
|
type: ActivityType;
|
|
327
700
|
status: ActivityStatus;
|
|
328
701
|
subjectKind: SubjectKind;
|
|
329
|
-
subjectId:
|
|
702
|
+
subjectId: mongoose1.Types.ObjectId | string;
|
|
330
703
|
title: string;
|
|
331
704
|
description?: string;
|
|
332
705
|
ownerId?: string;
|
|
@@ -343,10 +716,10 @@ declare function createActivityModel(connection: Connection, config: SchemaBuild
|
|
|
343
716
|
//#endregion
|
|
344
717
|
//#region src/models/note.schema.d.ts
|
|
345
718
|
interface INoteDocument {
|
|
346
|
-
_id:
|
|
347
|
-
organizationId:
|
|
719
|
+
_id: mongoose1.Types.ObjectId;
|
|
720
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
348
721
|
subjectKind: SubjectKind;
|
|
349
|
-
subjectId:
|
|
722
|
+
subjectId: mongoose1.Types.ObjectId | string;
|
|
350
723
|
body: string;
|
|
351
724
|
authorId?: string;
|
|
352
725
|
pinned: boolean;
|
|
@@ -359,8 +732,8 @@ declare function createNoteModel(connection: Connection, config: SchemaBuildConf
|
|
|
359
732
|
//#endregion
|
|
360
733
|
//#region src/models/loss-reason.schema.d.ts
|
|
361
734
|
interface ILossReasonDocument {
|
|
362
|
-
_id:
|
|
363
|
-
organizationId:
|
|
735
|
+
_id: mongoose1.Types.ObjectId;
|
|
736
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
364
737
|
name: string;
|
|
365
738
|
description?: string;
|
|
366
739
|
isActive: boolean;
|
|
@@ -408,12 +781,12 @@ type EmailEventKind = (typeof EMAIL_EVENT_KINDS)[number];
|
|
|
408
781
|
declare const EMAIL_EVENT_SUBJECT_KINDS: readonly ["contact", "subscription"];
|
|
409
782
|
type EmailEventSubjectKind = (typeof EMAIL_EVENT_SUBJECT_KINDS)[number];
|
|
410
783
|
interface IEmailEventDocument {
|
|
411
|
-
_id:
|
|
412
|
-
organizationId:
|
|
784
|
+
_id: mongoose1.Types.ObjectId;
|
|
785
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
413
786
|
kind: EmailEventKind;
|
|
414
787
|
subjectKind: EmailEventSubjectKind;
|
|
415
|
-
subjectId:
|
|
416
|
-
campaignId?:
|
|
788
|
+
subjectId: mongoose1.Types.ObjectId | string;
|
|
789
|
+
campaignId?: mongoose1.Types.ObjectId | string;
|
|
417
790
|
messageId?: string;
|
|
418
791
|
url?: string;
|
|
419
792
|
userAgent?: string;
|
|
@@ -424,6 +797,82 @@ interface IEmailEventDocument {
|
|
|
424
797
|
declare function buildEmailEventSchema(config: SchemaBuildConfig): Schema<IEmailEventDocument>;
|
|
425
798
|
declare function createEmailEventModel(connection: Connection, config: SchemaBuildConfig): Model<IEmailEventDocument>;
|
|
426
799
|
//#endregion
|
|
800
|
+
//#region src/enums/conversation.d.ts
|
|
801
|
+
/**
|
|
802
|
+
* Conversation / Message vocabulary.
|
|
803
|
+
*
|
|
804
|
+
* Conversations unify a contact's (or pre-conversion lead's) message
|
|
805
|
+
* thread across channels (WhatsApp / Telegram / Email / IG-DM / SMS).
|
|
806
|
+
* The host's webhook adapters write to this surface — the CRM does not
|
|
807
|
+
* dial outward.
|
|
808
|
+
*/
|
|
809
|
+
declare const CONVERSATION_CHANNELS: readonly ["whatsapp", "telegram", "email", "instagram_dm", "sms", "web_chat"];
|
|
810
|
+
type ConversationChannel = (typeof CONVERSATION_CHANNELS)[number];
|
|
811
|
+
declare const CONVERSATION_STATUSES: readonly ["open", "snoozed", "resolved"];
|
|
812
|
+
type ConversationStatus = (typeof CONVERSATION_STATUSES)[number];
|
|
813
|
+
/** Conversations attach to either a Contact or a (yet-unconverted) Lead. */
|
|
814
|
+
declare const CONVERSATION_PARTICIPANT_KINDS: readonly ["contact", "lead"];
|
|
815
|
+
type ConversationParticipantKind = (typeof CONVERSATION_PARTICIPANT_KINDS)[number];
|
|
816
|
+
declare const MESSAGE_DIRECTIONS: readonly ["inbound", "outbound"];
|
|
817
|
+
type MessageDirection = (typeof MESSAGE_DIRECTIONS)[number];
|
|
818
|
+
declare const MESSAGE_DELIVERY_STATUSES: readonly ["queued", "sent", "delivered", "read", "failed"];
|
|
819
|
+
type MessageDeliveryStatus = (typeof MESSAGE_DELIVERY_STATUSES)[number];
|
|
820
|
+
//#endregion
|
|
821
|
+
//#region src/models/conversation.schema.d.ts
|
|
822
|
+
interface IConversationDocument {
|
|
823
|
+
_id: mongoose1.Types.ObjectId;
|
|
824
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
825
|
+
channel: ConversationChannel;
|
|
826
|
+
participantKind: ConversationParticipantKind;
|
|
827
|
+
participantId: mongoose1.Types.ObjectId | string;
|
|
828
|
+
/** Channel-side identifier (e.g. WhatsApp wa_id, Telegram chat id). */
|
|
829
|
+
channelUserId?: string;
|
|
830
|
+
status: ConversationStatus;
|
|
831
|
+
/** Last message timestamp — surfaced for inbox sort + idle SLAs. */
|
|
832
|
+
lastMessageAt?: Date;
|
|
833
|
+
/** Unread inbound count. Reset to 0 on `markRead`. */
|
|
834
|
+
unreadCount: number;
|
|
835
|
+
/** Assignee. Stored as a string so hosts can use either userId or a queue id. */
|
|
836
|
+
assigneeId?: string;
|
|
837
|
+
/** Free-form bag — channel-specific settings (preview text, IMAP folder). */
|
|
838
|
+
metadata?: Record<string, unknown>;
|
|
839
|
+
createdAt: Date;
|
|
840
|
+
updatedAt: Date;
|
|
841
|
+
}
|
|
842
|
+
declare function buildConversationSchema(config: SchemaBuildConfig): Schema<IConversationDocument>;
|
|
843
|
+
declare function createConversationModel(connection: Connection, config: SchemaBuildConfig): Model<IConversationDocument>;
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/models/message.schema.d.ts
|
|
846
|
+
interface IMessageAttachment {
|
|
847
|
+
type: string;
|
|
848
|
+
url: string;
|
|
849
|
+
name?: string;
|
|
850
|
+
size?: number;
|
|
851
|
+
mimeType?: string;
|
|
852
|
+
}
|
|
853
|
+
interface IMessageDocument {
|
|
854
|
+
_id: mongoose1.Types.ObjectId;
|
|
855
|
+
organizationId: mongoose1.Types.ObjectId | string;
|
|
856
|
+
conversationId: mongoose1.Types.ObjectId | string;
|
|
857
|
+
direction: MessageDirection;
|
|
858
|
+
body: string;
|
|
859
|
+
attachments: IMessageAttachment[];
|
|
860
|
+
/** Provider-side id — webhook dedup key. */
|
|
861
|
+
externalMessageId?: string;
|
|
862
|
+
status: MessageDeliveryStatus;
|
|
863
|
+
/** Channel id of the sender (phone number, email, telegram id). */
|
|
864
|
+
senderRef?: string;
|
|
865
|
+
/** Channel id of the recipient. */
|
|
866
|
+
recipientRef?: string;
|
|
867
|
+
/** When the wire said it left / arrived; falls back to createdAt. */
|
|
868
|
+
sentAt?: Date;
|
|
869
|
+
metadata?: Record<string, unknown>;
|
|
870
|
+
createdAt: Date;
|
|
871
|
+
updatedAt: Date;
|
|
872
|
+
}
|
|
873
|
+
declare function buildMessageSchema(config: SchemaBuildConfig): Schema<IMessageDocument>;
|
|
874
|
+
declare function createMessageModel(connection: Connection, config: SchemaBuildConfig): Model<IMessageDocument>;
|
|
875
|
+
//#endregion
|
|
427
876
|
//#region src/models/create-models.d.ts
|
|
428
877
|
interface CrmModels {
|
|
429
878
|
Pipeline: Model<IPipelineDocument>;
|
|
@@ -437,8 +886,22 @@ interface CrmModels {
|
|
|
437
886
|
Note: Model<INoteDocument>;
|
|
438
887
|
LossReason: Model<ILossReasonDocument>;
|
|
439
888
|
EmailEvent: Model<IEmailEventDocument>;
|
|
889
|
+
Conversation: Model<IConversationDocument>;
|
|
890
|
+
Message: Model<IMessageDocument>;
|
|
891
|
+
}
|
|
892
|
+
/** Mongoose model names this package registers — drives the §21 collision check. */
|
|
893
|
+
declare const CRM_MODEL_NAMES: readonly ["Pipeline", "Lead", "Opportunity", "Contact", "Account", "Campaign", "EmailSubscription", "Activity", "Note", "LossReason", "EmailEvent", "Conversation", "Message"];
|
|
894
|
+
interface CreateModelsOptions extends SchemaBuildConfig {
|
|
895
|
+
/**
|
|
896
|
+
* On a model-name collision: `false` (default) throws
|
|
897
|
+
* `CrmModelCollisionError`; `true` deletes + re-registers (test
|
|
898
|
+
* fixtures / hot reload only).
|
|
899
|
+
*/
|
|
900
|
+
forceRecreate?: boolean;
|
|
901
|
+
/** Mongoose auto-index builds. Default `true` (dev); `false` in prod. */
|
|
902
|
+
autoIndex?: boolean;
|
|
440
903
|
}
|
|
441
|
-
declare function createCrmModels(connection: Connection, config:
|
|
904
|
+
declare function createCrmModels(connection: Connection, config: CreateModelsOptions): CrmModels;
|
|
442
905
|
//#endregion
|
|
443
906
|
//#region src/repositories/pipeline.repository.d.ts
|
|
444
907
|
interface PipelineRepositoryDeps {
|
|
@@ -506,12 +969,38 @@ declare class LeadRepository extends Repository<ILeadDocument> {
|
|
|
506
969
|
qualify(id: string, extras?: TransitionExtras, ctx?: CrmContext): Promise<ILeadDocument>;
|
|
507
970
|
disqualify(id: string, reason: string, extras?: Omit<TransitionExtras, 'patch'>, ctx?: CrmContext): Promise<ILeadDocument>;
|
|
508
971
|
nurture(id: string, extras?: TransitionExtras, ctx?: CrmContext): Promise<ILeadDocument>;
|
|
972
|
+
/**
|
|
973
|
+
* Merge enrichment payload (3rd-party provider response or manual
|
|
974
|
+
* patch) into the lead doc, then re-score. Emits `crm:lead.enriched`
|
|
975
|
+
* with the field set written so subscribers can fan out (e.g. push a
|
|
976
|
+
* `recompute_segment` job) without re-reading the doc.
|
|
977
|
+
*
|
|
978
|
+
* The `provider` tag flows into the event for attribution; the package
|
|
979
|
+
* is provider-agnostic so the actual enrichment call lives at the host.
|
|
980
|
+
*/
|
|
981
|
+
enrich(id: string, patch: Partial<ILeadDocument>, extras?: {
|
|
982
|
+
provider?: string;
|
|
983
|
+
}, ctx?: CrmContext): Promise<ILeadDocument>;
|
|
984
|
+
/**
|
|
985
|
+
* Assign / re-assign the lead's owner. Emits `crm:lead.assigned` with
|
|
986
|
+
* the previous owner so audit consumers can compute hand-off chains.
|
|
987
|
+
*/
|
|
988
|
+
assign(id: string, ownerId: string, ctx?: CrmContext): Promise<ILeadDocument>;
|
|
509
989
|
/**
|
|
510
990
|
* Recompute + persist the lead's score. Called from `createLead`
|
|
511
991
|
* automatically; hosts also call this after enrichment writes.
|
|
512
992
|
*/
|
|
513
993
|
recomputeScore(id: string, ctx?: CrmContext): Promise<ILeadDocument>;
|
|
514
994
|
private _transition;
|
|
995
|
+
/**
|
|
996
|
+
* Count leads created on or after `since`. Used by dashboard KPI tiles.
|
|
997
|
+
* Goes through the inherited tenant-scoped `count()` — the plugin
|
|
998
|
+
* injects `organizationId` (never a manual `if (ctx)` filter, which
|
|
999
|
+
* silently reads ALL tenants when ctx is absent).
|
|
1000
|
+
*/
|
|
1001
|
+
countCreatedSince(since: Date, ctx?: CrmContext): Promise<number>;
|
|
1002
|
+
/** Latest `limit` leads — lightweight projection for the activity feed. */
|
|
1003
|
+
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<ILeadDocument[]>;
|
|
515
1004
|
}
|
|
516
1005
|
//#endregion
|
|
517
1006
|
//#region src/repositories/opportunity.repository.d.ts
|
|
@@ -564,14 +1053,65 @@ declare class OpportunityRepository extends Repository<IOpportunityDocument> {
|
|
|
564
1053
|
moveToStage(id: string, input: MoveStageInput, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
565
1054
|
win(id: string, input?: CloseInput, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
566
1055
|
lose(id: string, input?: CloseInput, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Re-assign opportunity owner. Mutates `ownerId` only; no status
|
|
1058
|
+
* transition. Emits `crm:opportunity.assigned` with the previous owner.
|
|
1059
|
+
*/
|
|
1060
|
+
assign(id: string, ownerId: string, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Adjust the deal amount on an open opportunity. Rejected after
|
|
1063
|
+
* win/lose/abandon — closed-deal amounts are immutable history.
|
|
1064
|
+
* Emits `crm:opportunity.amount_changed` with the delta so forecast
|
|
1065
|
+
* subscribers can re-bucket.
|
|
1066
|
+
*/
|
|
1067
|
+
updateAmount(id: string, amount: number, extras?: {
|
|
1068
|
+
reason?: string;
|
|
1069
|
+
by?: string;
|
|
1070
|
+
}, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Push `expectedCloseAt` further out. Only valid on open opps —
|
|
1073
|
+
* extending a closed deal is meaningless. The new date must be later
|
|
1074
|
+
* than the current one; pulling the date in is silently accepted
|
|
1075
|
+
* (no event is meaningful there).
|
|
1076
|
+
*/
|
|
1077
|
+
extendCloseDate(id: string, newDate: Date, extras?: {
|
|
1078
|
+
reason?: string;
|
|
1079
|
+
by?: string;
|
|
1080
|
+
}, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
567
1081
|
abandon(id: string, by?: string, note?: string, ctx?: CrmContext): Promise<IOpportunityDocument>;
|
|
568
1082
|
private _closeStatus;
|
|
1083
|
+
/** Count opportunities with status `open`. Used by dashboard KPI tiles. */
|
|
1084
|
+
countOpen(ctx?: CrmContext): Promise<number>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Sum `amount` on won opportunities updated within `since`.
|
|
1087
|
+
* Goes through the tenant-scoped `findAll()` — the multiTenant plugin
|
|
1088
|
+
* injects `organizationId`, so a missing ctx can't leak other tenants'
|
|
1089
|
+
* revenue (a manual `if (ctx)` filter would).
|
|
1090
|
+
*/
|
|
1091
|
+
sumWonSince(since: Date, ctx?: CrmContext): Promise<{
|
|
1092
|
+
total: number;
|
|
1093
|
+
currency?: string;
|
|
1094
|
+
} | null>;
|
|
1095
|
+
/** Latest `limit` opportunities — lightweight projection for the activity feed. */
|
|
1096
|
+
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<IOpportunityDocument[]>;
|
|
569
1097
|
}
|
|
570
1098
|
//#endregion
|
|
571
1099
|
//#region src/repositories/contact.repository.d.ts
|
|
572
1100
|
interface ContactRepositoryDeps {
|
|
573
1101
|
events: EventTransport;
|
|
574
1102
|
}
|
|
1103
|
+
interface MergeContactInput {
|
|
1104
|
+
/** Surviving contact id. Receives merged fields. */
|
|
1105
|
+
primaryId: string;
|
|
1106
|
+
/** Secondary contact id. Deleted after merge. */
|
|
1107
|
+
secondaryId: string;
|
|
1108
|
+
/**
|
|
1109
|
+
* Per-field strategy. Defaults to `'preferPrimary'` — primary's
|
|
1110
|
+
* non-empty fields win, secondary fills the gaps. Use `'preferSecondary'`
|
|
1111
|
+
* for the reverse. `tags` are always unioned.
|
|
1112
|
+
*/
|
|
1113
|
+
strategy?: 'preferPrimary' | 'preferSecondary';
|
|
1114
|
+
}
|
|
575
1115
|
declare class ContactRepository extends Repository<IContactDocument> {
|
|
576
1116
|
private readonly events;
|
|
577
1117
|
constructor(model: Model<IContactDocument>, plugins: PluginType[], deps: ContactRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -580,16 +1120,49 @@ declare class ContactRepository extends Repository<IContactDocument> {
|
|
|
580
1120
|
* `create()` when they want the event side-effect (e.g. webhook fan-out).
|
|
581
1121
|
*/
|
|
582
1122
|
createContact(input: Partial<IContactDocument>, ctx?: CrmContext): Promise<IContactDocument>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Merge enrichment payload into the contact. The `patch` is applied
|
|
1125
|
+
* verbatim; deep-merge of `contact.*` channels is the caller's job
|
|
1126
|
+
* (they own the provider response shape).
|
|
1127
|
+
*/
|
|
1128
|
+
enrich(id: string, patch: Partial<IContactDocument>, extras?: {
|
|
1129
|
+
provider?: string;
|
|
1130
|
+
}, ctx?: CrmContext): Promise<IContactDocument>;
|
|
1131
|
+
/** Set / re-assign the contact's owner. Atomic; no-op when unchanged. */
|
|
1132
|
+
assign(id: string, ownerId: string, ctx?: CrmContext): Promise<IContactDocument>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Merge two contacts. Secondary's non-conflicting fields are folded
|
|
1135
|
+
* into primary, tags are unioned, then secondary is deleted.
|
|
1136
|
+
*
|
|
1137
|
+
* Hosts wanting transactional safety can pass `ctx.session` —
|
|
1138
|
+
* mongokit threads it through `update` + `delete`.
|
|
1139
|
+
*
|
|
1140
|
+
* Re-pointing related Activities / Notes / Opportunities is the host's
|
|
1141
|
+
* job (they own those relationships) — subscribe to
|
|
1142
|
+
* `crm:contact.merged` and rewrite `subjectId` / `primaryContactId`
|
|
1143
|
+
* from there.
|
|
1144
|
+
*/
|
|
1145
|
+
merge(input: MergeContactInput, ctx?: CrmContext): Promise<IContactDocument>;
|
|
583
1146
|
}
|
|
584
1147
|
//#endregion
|
|
585
1148
|
//#region src/repositories/account.repository.d.ts
|
|
586
1149
|
interface AccountRepositoryDeps {
|
|
587
1150
|
events: EventTransport;
|
|
588
1151
|
}
|
|
1152
|
+
interface MergeAccountInput {
|
|
1153
|
+
primaryId: string;
|
|
1154
|
+
secondaryId: string;
|
|
1155
|
+
strategy?: 'preferPrimary' | 'preferSecondary';
|
|
1156
|
+
}
|
|
589
1157
|
declare class AccountRepository extends Repository<IAccountDocument> {
|
|
590
1158
|
private readonly events;
|
|
591
1159
|
constructor(model: Model<IAccountDocument>, plugins: PluginType[], deps: AccountRepositoryDeps, pagination?: PaginationConfig);
|
|
592
1160
|
createAccount(input: Partial<IAccountDocument>, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
1161
|
+
enrich(id: string, patch: Partial<IAccountDocument>, extras?: {
|
|
1162
|
+
provider?: string;
|
|
1163
|
+
}, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
1164
|
+
assign(id: string, ownerId: string, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
1165
|
+
merge(input: MergeAccountInput, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
593
1166
|
}
|
|
594
1167
|
//#endregion
|
|
595
1168
|
//#region src/repositories/campaign.repository.d.ts
|
|
@@ -655,7 +1228,30 @@ declare class ActivityRepository extends Repository<IActivityDocument> {
|
|
|
655
1228
|
start(id: string, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
656
1229
|
complete(id: string, completedAt?: Date, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
657
1230
|
cancel(id: string, reason?: string, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1231
|
+
/**
|
|
1232
|
+
* Push an activity's `dueDate`. Allowed on planned / in_progress only;
|
|
1233
|
+
* rescheduling a completed or cancelled activity makes no sense.
|
|
1234
|
+
* Emits `crm:activity.rescheduled` with the previous date for audit.
|
|
1235
|
+
*/
|
|
1236
|
+
reschedule(id: string, newDueDate: Date, extras?: {
|
|
1237
|
+
reason?: string;
|
|
1238
|
+
by?: string;
|
|
1239
|
+
}, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Record the outcome of an activity (call result, email engagement,
|
|
1242
|
+
* meeting confirmation). Stored under `metadata.outcome` so it stays
|
|
1243
|
+
* polymorphic — the shape is the channel's concern, not this package's.
|
|
1244
|
+
*
|
|
1245
|
+
* Does NOT transition status — call `complete()` separately when the
|
|
1246
|
+
* outcome implies completion. This split lets agents log partial
|
|
1247
|
+
* outcomes (e.g. "left voicemail") without forcing terminal state.
|
|
1248
|
+
*/
|
|
1249
|
+
recordOutcome(id: string, outcome: Record<string, unknown>, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
658
1250
|
private _transition;
|
|
1251
|
+
/** Count `planned` activities with `dueDate` before `asOf`. Dashboard KPI. */
|
|
1252
|
+
countOverduePlanned(asOf: Date, ctx?: CrmContext): Promise<number>;
|
|
1253
|
+
/** Latest `limit` activities — lightweight projection for the activity feed. */
|
|
1254
|
+
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<IActivityDocument[]>;
|
|
659
1255
|
}
|
|
660
1256
|
//#endregion
|
|
661
1257
|
//#region src/repositories/note.repository.d.ts
|
|
@@ -704,6 +1300,68 @@ declare class EmailEventRepository extends Repository<IEmailEventDocument> {
|
|
|
704
1300
|
private _record;
|
|
705
1301
|
}
|
|
706
1302
|
//#endregion
|
|
1303
|
+
//#region src/repositories/conversation.repository.d.ts
|
|
1304
|
+
interface ConversationRepositoryDeps {
|
|
1305
|
+
events: EventTransport;
|
|
1306
|
+
}
|
|
1307
|
+
interface OpenConversationInput {
|
|
1308
|
+
channel: ConversationChannel;
|
|
1309
|
+
participantKind: ConversationParticipantKind;
|
|
1310
|
+
participantId: string;
|
|
1311
|
+
channelUserId?: string;
|
|
1312
|
+
assigneeId?: string;
|
|
1313
|
+
metadata?: Record<string, unknown>;
|
|
1314
|
+
}
|
|
1315
|
+
declare class ConversationRepository extends Repository<IConversationDocument> {
|
|
1316
|
+
private readonly events;
|
|
1317
|
+
constructor(model: Model<IConversationDocument>, plugins: PluginType[], deps: ConversationRepositoryDeps, pagination?: PaginationConfig);
|
|
1318
|
+
openConversation(input: OpenConversationInput, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1319
|
+
assign(id: string, assigneeId: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1320
|
+
resolve(id: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1321
|
+
reopen(id: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1322
|
+
/** Reset unread badge. Pure UI affordance, no event. */
|
|
1323
|
+
markRead(id: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Bump `lastMessageAt` and (for inbound) increment `unreadCount`.
|
|
1326
|
+
* Called by `MessageRepository` when a message is recorded — not part
|
|
1327
|
+
* of the public surface. Returns the conversation for the caller's
|
|
1328
|
+
* follow-up writes.
|
|
1329
|
+
*/
|
|
1330
|
+
touch(id: string, args: {
|
|
1331
|
+
direction: 'inbound' | 'outbound';
|
|
1332
|
+
sentAt: Date;
|
|
1333
|
+
}, ctx?: CrmContext): Promise<IConversationDocument | null>;
|
|
1334
|
+
private _setStatus;
|
|
1335
|
+
}
|
|
1336
|
+
//#endregion
|
|
1337
|
+
//#region src/repositories/message.repository.d.ts
|
|
1338
|
+
interface MessageRepositoryDeps {
|
|
1339
|
+
events: EventTransport;
|
|
1340
|
+
conversations: ConversationRepository;
|
|
1341
|
+
}
|
|
1342
|
+
interface RecordMessageInput {
|
|
1343
|
+
conversationId: string;
|
|
1344
|
+
body: string;
|
|
1345
|
+
attachments?: IMessageAttachment[];
|
|
1346
|
+
externalMessageId?: string;
|
|
1347
|
+
senderRef?: string;
|
|
1348
|
+
recipientRef?: string;
|
|
1349
|
+
sentAt?: Date;
|
|
1350
|
+
metadata?: Record<string, unknown>;
|
|
1351
|
+
}
|
|
1352
|
+
declare class MessageRepository extends Repository<IMessageDocument> {
|
|
1353
|
+
private readonly events;
|
|
1354
|
+
private readonly conversations;
|
|
1355
|
+
constructor(model: Model<IMessageDocument>, plugins: PluginType[], deps: MessageRepositoryDeps, pagination?: PaginationConfig);
|
|
1356
|
+
recordInbound(input: RecordMessageInput, ctx?: CrmContext): Promise<IMessageDocument>;
|
|
1357
|
+
recordOutbound(input: RecordMessageInput, ctx?: CrmContext): Promise<IMessageDocument>;
|
|
1358
|
+
/** Wire delivery callback (e.g. WhatsApp `status` webhook). */
|
|
1359
|
+
updateStatus(id: string, status: MessageDeliveryStatus, ctx?: CrmContext): Promise<IMessageDocument>;
|
|
1360
|
+
private _record;
|
|
1361
|
+
/** Latest `limit` messages — lightweight projection for the activity feed. */
|
|
1362
|
+
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<IMessageDocument[]>;
|
|
1363
|
+
}
|
|
1364
|
+
//#endregion
|
|
707
1365
|
//#region src/engine/engine-types.d.ts
|
|
708
1366
|
interface CrmLogger {
|
|
709
1367
|
info?(msg: string, meta?: Record<string, unknown>): void;
|
|
@@ -735,11 +1393,31 @@ interface CrmConfig {
|
|
|
735
1393
|
pagination?: PaginationConfig;
|
|
736
1394
|
/** Extra mongokit plugins applied to every repository (after defaults). */
|
|
737
1395
|
plugins?: PluginType[];
|
|
1396
|
+
/**
|
|
1397
|
+
* On a Mongoose model-name collision (another engine / hot reload owns
|
|
1398
|
+
* the name): `false` (default) throws `CrmModelCollisionError`; `true`
|
|
1399
|
+
* deletes + re-registers. Test fixtures / hot reload only (§21).
|
|
1400
|
+
*/
|
|
1401
|
+
forceRecreate?: boolean;
|
|
1402
|
+
/**
|
|
1403
|
+
* Mongoose auto-index builds. Default `true` (dev). Set `false` in
|
|
1404
|
+
* production and run `engine.syncIndexes()` from a deploy script so
|
|
1405
|
+
* cold-boot index builds don't blow Fastify's plugin timeout (§35).
|
|
1406
|
+
*/
|
|
1407
|
+
autoIndex?: boolean;
|
|
1408
|
+
/**
|
|
1409
|
+
* Skip the boot-time `transactions` capability requirement, downgrading
|
|
1410
|
+
* it to a warning. Set only when the host never calls
|
|
1411
|
+
* `LeadService.convert()` inside a transaction (standalone Mongo).
|
|
1412
|
+
*/
|
|
1413
|
+
allowNonTransactional?: boolean;
|
|
738
1414
|
}
|
|
739
1415
|
interface ResolvedCrmConfig extends SchemaBuildConfig {
|
|
740
1416
|
connection: Connection;
|
|
741
1417
|
tenantFieldType: TenantFieldType;
|
|
742
1418
|
multiTenant: boolean;
|
|
1419
|
+
forceRecreate: boolean;
|
|
1420
|
+
autoIndex: boolean;
|
|
743
1421
|
logger?: CrmLogger;
|
|
744
1422
|
pagination?: PaginationConfig;
|
|
745
1423
|
plugins: PluginType[];
|
|
@@ -756,6 +1434,8 @@ interface CrmRepositories {
|
|
|
756
1434
|
note: NoteRepository;
|
|
757
1435
|
lossReason: LossReasonRepository;
|
|
758
1436
|
emailEvent: EmailEventRepository;
|
|
1437
|
+
conversation: ConversationRepository;
|
|
1438
|
+
message: MessageRepository;
|
|
759
1439
|
}
|
|
760
1440
|
interface CrmEngine {
|
|
761
1441
|
/** Repositories ARE the API surface (PACKAGE_RULES §1). */
|
|
@@ -766,6 +1446,11 @@ interface CrmEngine {
|
|
|
766
1446
|
readonly models: Readonly<CrmModels>;
|
|
767
1447
|
/** Resolved configuration (frozen). */
|
|
768
1448
|
readonly config: Readonly<ResolvedCrmConfig>;
|
|
1449
|
+
/**
|
|
1450
|
+
* Build/align every model's indexes against its schema. Call once per
|
|
1451
|
+
* deploy when booted with `autoIndex: false` (§35). Idempotent.
|
|
1452
|
+
*/
|
|
1453
|
+
syncIndexes(): Promise<void>;
|
|
769
1454
|
/** Release resources. Safe to call multiple times. */
|
|
770
1455
|
dispose(): Promise<void>;
|
|
771
1456
|
}
|
|
@@ -776,134 +1461,15 @@ interface CrmEngine {
|
|
|
776
1461
|
* `metadata?` field — keep the typed surface tight.
|
|
777
1462
|
*/
|
|
778
1463
|
interface CrmContext extends OperationContext {
|
|
779
|
-
organizationId?: string |
|
|
780
|
-
actorId?: string |
|
|
1464
|
+
organizationId?: string | mongoose1.Types.ObjectId;
|
|
1465
|
+
actorId?: string | mongoose1.Types.ObjectId;
|
|
781
1466
|
/** Mongo transaction session (passed through to mongokit). */
|
|
782
1467
|
session?: unknown;
|
|
783
1468
|
}
|
|
784
1469
|
type _ModelTypes = Model<unknown>;
|
|
785
1470
|
//#endregion
|
|
786
|
-
//#region src/engine/create-crm.d.ts
|
|
787
|
-
declare function createCrm(config: CrmConfig): Promise<CrmEngine>;
|
|
788
|
-
//#endregion
|
|
789
|
-
//#region src/repositories/create-repositories.d.ts
|
|
790
|
-
interface CreateCrmRepositoriesDeps {
|
|
791
|
-
events: EventTransport;
|
|
792
|
-
config: ResolvedCrmConfig;
|
|
793
|
-
}
|
|
794
|
-
declare function createCrmRepositories(models: CrmModels, deps: CreateCrmRepositoriesDeps): CrmRepositories;
|
|
795
|
-
//#endregion
|
|
796
|
-
//#region src/services/lead.service.d.ts
|
|
797
|
-
interface ConvertLeadInput {
|
|
798
|
-
pipelineId: string;
|
|
799
|
-
/** Defaults to `<companyName> — <source>` / `<fullName> — New`. */
|
|
800
|
-
opportunityName?: string;
|
|
801
|
-
/** Stored flat on the opportunity (`amount` + `currency`). */
|
|
802
|
-
amount?: number;
|
|
803
|
-
currency?: string;
|
|
804
|
-
expectedCloseAt?: Date;
|
|
805
|
-
by?: string;
|
|
806
|
-
}
|
|
807
|
-
interface ConvertResult {
|
|
808
|
-
lead: ILeadDocument;
|
|
809
|
-
contact: IContactDocument;
|
|
810
|
-
account?: IAccountDocument;
|
|
811
|
-
opportunity: IOpportunityDocument;
|
|
812
|
-
/** @deprecated use contact._id */
|
|
813
|
-
contactId: string;
|
|
814
|
-
/** @deprecated use account._id */
|
|
815
|
-
accountId?: string;
|
|
816
|
-
/** @deprecated use opportunity._id */
|
|
817
|
-
opportunityId: string;
|
|
818
|
-
}
|
|
819
|
-
interface LeadServiceDeps {
|
|
820
|
-
lead: LeadRepository;
|
|
821
|
-
contact: ContactRepository;
|
|
822
|
-
account: AccountRepository;
|
|
823
|
-
opportunity: OpportunityRepository;
|
|
824
|
-
events: EventTransport;
|
|
825
|
-
}
|
|
826
|
-
declare class LeadService {
|
|
827
|
-
private readonly leads;
|
|
828
|
-
private readonly contacts;
|
|
829
|
-
private readonly accounts;
|
|
830
|
-
private readonly opportunities;
|
|
831
|
-
private readonly events;
|
|
832
|
-
constructor(deps: LeadServiceDeps);
|
|
833
|
-
/**
|
|
834
|
-
* Construct from an already-built CrmEngine — the host's preferred path.
|
|
835
|
-
* Avoids manually wiring four repositories.
|
|
836
|
-
*/
|
|
837
|
-
static fromEngine(engine: CrmEngine): LeadService;
|
|
838
|
-
/**
|
|
839
|
-
* Convert a Lead into Account + Contact + Opportunity, then transition
|
|
840
|
-
* the lead. Wrap the call in `connection.transaction()` and pass the
|
|
841
|
-
* session via `ctx.session` for atomicity — all four writes commit or
|
|
842
|
-
* roll back together.
|
|
843
|
-
*
|
|
844
|
-
* Best-effort compensation: if a downstream write fails, already-
|
|
845
|
-
* created docs are deleted in reverse order. The reverse delete may
|
|
846
|
-
* itself fail (e.g. transient DB issues) — when transactions are
|
|
847
|
-
* active, prefer that path; compensation is the no-transaction
|
|
848
|
-
* fallback.
|
|
849
|
-
*/
|
|
850
|
-
convert(leadId: string, input: ConvertLeadInput, ctx?: CrmContext): Promise<ConvertResult>;
|
|
851
|
-
/**
|
|
852
|
-
* The state-machine hop from whichever status the lead is in to
|
|
853
|
-
* `converted`. We do this directly (instead of calling
|
|
854
|
-
* `LeadRepository.qualify` first then a hypothetical `complete`)
|
|
855
|
-
* because the conversion is "this lead is done" regardless of where
|
|
856
|
-
* it started — bypassing the `qualified` waypoint is intentional when
|
|
857
|
-
* a Lead is converted directly from `new` (importers, webhooks).
|
|
858
|
-
*/
|
|
859
|
-
private _markConverted;
|
|
860
|
-
}
|
|
861
|
-
//#endregion
|
|
862
|
-
//#region src/events/event-constants.d.ts
|
|
863
|
-
/** PACKAGE_RULES rule 12: `package:resource.verb`. */
|
|
864
|
-
declare const CRM_EVENTS: {
|
|
865
|
-
readonly LEAD_CREATED: "crm:lead.created";
|
|
866
|
-
readonly LEAD_STATUS_CHANGED: "crm:lead.status_changed";
|
|
867
|
-
readonly LEAD_SCORED: "crm:lead.scored";
|
|
868
|
-
readonly LEAD_CONVERTED: "crm:lead.converted";
|
|
869
|
-
readonly LEAD_DISQUALIFIED: "crm:lead.disqualified";
|
|
870
|
-
readonly ACCOUNT_CREATED: "crm:account.created";
|
|
871
|
-
readonly ACCOUNT_UPDATED: "crm:account.updated";
|
|
872
|
-
readonly CONTACT_CREATED: "crm:contact.created";
|
|
873
|
-
readonly CONTACT_UPDATED: "crm:contact.updated";
|
|
874
|
-
readonly OPPORTUNITY_CREATED: "crm:opportunity.created";
|
|
875
|
-
readonly OPPORTUNITY_STAGE_ADVANCED: "crm:opportunity.stage_advanced";
|
|
876
|
-
readonly OPPORTUNITY_STAGE_REGRESSED: "crm:opportunity.stage_regressed";
|
|
877
|
-
readonly OPPORTUNITY_WON: "crm:opportunity.won";
|
|
878
|
-
readonly OPPORTUNITY_LOST: "crm:opportunity.lost";
|
|
879
|
-
readonly OPPORTUNITY_ABANDONED: "crm:opportunity.abandoned";
|
|
880
|
-
readonly PIPELINE_CREATED: "crm:pipeline.created";
|
|
881
|
-
readonly PIPELINE_ARCHIVED: "crm:pipeline.archived";
|
|
882
|
-
readonly ACTIVITY_PLANNED: "crm:activity.planned";
|
|
883
|
-
readonly ACTIVITY_COMPLETED: "crm:activity.completed";
|
|
884
|
-
readonly ACTIVITY_CANCELLED: "crm:activity.cancelled";
|
|
885
|
-
readonly NOTE_ADDED: "crm:note.added";
|
|
886
|
-
readonly CAMPAIGN_CREATED: "crm:campaign.created";
|
|
887
|
-
readonly CAMPAIGN_ACTIVATED: "crm:campaign.activated";
|
|
888
|
-
readonly CAMPAIGN_PAUSED: "crm:campaign.paused";
|
|
889
|
-
readonly CAMPAIGN_RESUMED: "crm:campaign.resumed";
|
|
890
|
-
readonly CAMPAIGN_COMPLETED: "crm:campaign.completed";
|
|
891
|
-
readonly CAMPAIGN_ARCHIVED: "crm:campaign.archived";
|
|
892
|
-
readonly SUBSCRIPTION_CREATED: "crm:subscription.created";
|
|
893
|
-
readonly SUBSCRIPTION_CONFIRMED: "crm:subscription.confirmed";
|
|
894
|
-
readonly SUBSCRIPTION_UNSUBSCRIBED: "crm:subscription.unsubscribed";
|
|
895
|
-
readonly SUBSCRIPTION_BOUNCED: "crm:subscription.bounced";
|
|
896
|
-
readonly SUBSCRIPTION_COMPLAINED: "crm:subscription.complained";
|
|
897
|
-
readonly EMAIL_EVENT_OPENED: "crm:email_event.opened";
|
|
898
|
-
readonly EMAIL_EVENT_CLICKED: "crm:email_event.clicked";
|
|
899
|
-
readonly EMAIL_EVENT_BOUNCED: "crm:email_event.bounced";
|
|
900
|
-
readonly EMAIL_EVENT_COMPLAINED: "crm:email_event.complained";
|
|
901
|
-
readonly EMAIL_EVENT_UNSUBSCRIBED: "crm:email_event.unsubscribed";
|
|
902
|
-
};
|
|
903
|
-
type CrmEventName = (typeof CRM_EVENTS)[keyof typeof CRM_EVENTS];
|
|
904
|
-
//#endregion
|
|
905
1471
|
//#region src/events/helpers.d.ts
|
|
906
|
-
declare function createEvent<T>(type: string, payload: T, ctx?: CrmContext, meta?: Partial<EventMeta>): DomainEvent<T>;
|
|
1472
|
+
declare function createEvent$1<T>(type: string, payload: T, ctx?: CrmContext, meta?: Partial<EventMeta>): DomainEvent<T>;
|
|
907
1473
|
//#endregion
|
|
908
1474
|
//#region src/events/in-process-bus.d.ts
|
|
909
1475
|
declare class InProcessCrmBus implements EventTransport {
|
|
@@ -918,658 +1484,4 @@ declare class InProcessCrmBus implements EventTransport {
|
|
|
918
1484
|
close(): Promise<void>;
|
|
919
1485
|
}
|
|
920
1486
|
//#endregion
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Declarative state machines for every CRM aggregate that has lifecycle
|
|
924
|
-
* transitions. Single source of truth for what `from -> to` moves are
|
|
925
|
-
* legal — the repositories' domain verbs (`qualify`, `convert`, `win`,
|
|
926
|
-
* `lose`, `confirm`, `unsubscribe`, ...) call `assertTransition` before
|
|
927
|
-
* they touch Mongo.
|
|
928
|
-
*
|
|
929
|
-
* Per PACKAGE_RULES §30: "State machines map to Arc Actions". The host
|
|
930
|
-
* exposes each domain verb as an arc Action (`POST /:id/action` with
|
|
931
|
-
* `{ action: 'qualify' }`); the verb's implementation lives on the
|
|
932
|
-
* Repository class and uses these machines internally.
|
|
933
|
-
*
|
|
934
|
-
* Built on `@classytic/primitives/state-machine` so the same shape lights
|
|
935
|
-
* up across kits (mongokit's `claim()` pairing, sqlitekit follow-ups).
|
|
936
|
-
*/
|
|
937
|
-
declare const LEAD_MACHINE: _classytic_primitives_state_machine0.StateMachine<"new" | "contacted" | "qualified" | "converted" | "disqualified" | "nurturing">;
|
|
938
|
-
declare const OPPORTUNITY_MACHINE: _classytic_primitives_state_machine0.StateMachine<"open" | "won" | "lost" | "abandoned">;
|
|
939
|
-
declare const CAMPAIGN_MACHINE: _classytic_primitives_state_machine0.StateMachine<"draft" | "active" | "paused" | "completed" | "archived">;
|
|
940
|
-
declare const SUBSCRIPTION_MACHINE: _classytic_primitives_state_machine0.StateMachine<"pending" | "confirmed" | "unsubscribed" | "bounced" | "complained">;
|
|
941
|
-
declare const ACTIVITY_MACHINE: _classytic_primitives_state_machine0.StateMachine<"completed" | "planned" | "in_progress" | "cancelled">;
|
|
942
|
-
//#endregion
|
|
943
|
-
//#region src/core/errors.d.ts
|
|
944
|
-
/**
|
|
945
|
-
* CRM error vocabulary. Hosts catch `CrmError` at API edges.
|
|
946
|
-
*/
|
|
947
|
-
declare class CrmError extends Error {
|
|
948
|
-
readonly code: string;
|
|
949
|
-
readonly details?: Record<string, unknown>;
|
|
950
|
-
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
951
|
-
}
|
|
952
|
-
declare class NotFoundError extends CrmError {
|
|
953
|
-
constructor(kind: string, id: string);
|
|
954
|
-
}
|
|
955
|
-
declare class InvalidLeadTransitionError extends CrmError {
|
|
956
|
-
constructor(details: {
|
|
957
|
-
from: string;
|
|
958
|
-
to: string;
|
|
959
|
-
leadId: string;
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
declare class InvalidOpportunityTransitionError extends CrmError {
|
|
963
|
-
constructor(details: {
|
|
964
|
-
from: string;
|
|
965
|
-
to: string;
|
|
966
|
-
opportunityId: string;
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
declare class InvalidActivityTransitionError extends CrmError {
|
|
970
|
-
constructor(details: {
|
|
971
|
-
from: string;
|
|
972
|
-
to: string;
|
|
973
|
-
activityId: string;
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
declare class StageNotInPipelineError extends CrmError {
|
|
977
|
-
constructor(details: {
|
|
978
|
-
pipelineId: string;
|
|
979
|
-
stageId: string;
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
declare class LeadAlreadyConvertedError extends CrmError {
|
|
983
|
-
constructor(leadId: string);
|
|
984
|
-
}
|
|
985
|
-
declare class DuplicateLeadError extends CrmError {
|
|
986
|
-
constructor(details: {
|
|
987
|
-
email?: string;
|
|
988
|
-
phone?: string;
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
declare class EmptyPipelineError extends CrmError {
|
|
992
|
-
constructor(pipelineId: string);
|
|
993
|
-
}
|
|
994
|
-
declare class InvalidCampaignTransitionError extends CrmError {
|
|
995
|
-
constructor(details: {
|
|
996
|
-
from: string;
|
|
997
|
-
to: string;
|
|
998
|
-
campaignId: string;
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
declare class DuplicateCampaignError extends CrmError {
|
|
1002
|
-
constructor(name: string);
|
|
1003
|
-
}
|
|
1004
|
-
declare class InvalidSubscriptionTransitionError extends CrmError {
|
|
1005
|
-
constructor(details: {
|
|
1006
|
-
from: string;
|
|
1007
|
-
to: string;
|
|
1008
|
-
subscriptionId: string;
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
declare class DuplicateSubscriptionError extends CrmError {
|
|
1012
|
-
constructor(details: {
|
|
1013
|
-
contactId: string;
|
|
1014
|
-
campaignId: string;
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
declare class InvalidConfirmationTokenError extends CrmError {
|
|
1018
|
-
constructor();
|
|
1019
|
-
}
|
|
1020
|
-
declare class InvalidUnsubscribeTokenError extends CrmError {
|
|
1021
|
-
constructor();
|
|
1022
|
-
}
|
|
1023
|
-
//#endregion
|
|
1024
|
-
//#region src/shared/calculators/forecast.d.ts
|
|
1025
|
-
type OpportunityForecast = Pick<IOpportunityDocument, 'amount' | 'currency' | 'probability' | 'status' | 'expectedCloseAt' | 'stageId' | 'statusHistory'>;
|
|
1026
|
-
interface ForecastRow {
|
|
1027
|
-
/** Bucket key — ISO month `YYYY-MM` by default. */
|
|
1028
|
-
bucket: string;
|
|
1029
|
-
/** Σ amount. */
|
|
1030
|
-
committed: number;
|
|
1031
|
-
/** Σ amount × probability. */
|
|
1032
|
-
weighted: number;
|
|
1033
|
-
/** Number of opportunities in the bucket. */
|
|
1034
|
-
count: number;
|
|
1035
|
-
currency: string;
|
|
1036
|
-
}
|
|
1037
|
-
interface ForecastOptions {
|
|
1038
|
-
/** Bucket function. Default: ISO month from `expectedCloseAt`. */
|
|
1039
|
-
bucket?: (o: OpportunityForecast) => string;
|
|
1040
|
-
/** Filter before bucketing. Default: open + has amount + has expectedCloseAt. */
|
|
1041
|
-
include?: (o: OpportunityForecast) => boolean;
|
|
1042
|
-
}
|
|
1043
|
-
/**
|
|
1044
|
-
* Aggregate opportunities into a forecast table — one row per bucket.
|
|
1045
|
-
* Currency mismatch within a bucket throws — partition by currency
|
|
1046
|
-
* upstream when multi-currency.
|
|
1047
|
-
*/
|
|
1048
|
-
declare function forecast(opportunities: readonly OpportunityForecast[], options?: ForecastOptions): ForecastRow[];
|
|
1049
|
-
interface ConversionRow {
|
|
1050
|
-
stageId: string;
|
|
1051
|
-
currentCount: number;
|
|
1052
|
-
wonFromHere: number;
|
|
1053
|
-
lostFromHere: number;
|
|
1054
|
-
conversionRate: number;
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* "Where do deals die?" summary — opportunities partitioned across
|
|
1058
|
-
* stages with current count + won/lost-from-here.
|
|
1059
|
-
*/
|
|
1060
|
-
declare function pipelineConversion(opportunities: readonly OpportunityForecast[], stageIds: readonly string[]): ConversionRow[];
|
|
1061
|
-
//#endregion
|
|
1062
|
-
//#region src/validators/common.d.ts
|
|
1063
|
-
declare const objectIdLike: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1064
|
-
declare const metadataSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1065
|
-
declare const tagsSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1066
|
-
declare const moneyAmountSchema: z.ZodNumber;
|
|
1067
|
-
declare const currencyCodeSchema: z.ZodString;
|
|
1068
|
-
//#endregion
|
|
1069
|
-
//#region src/validators/pipeline.schema.d.ts
|
|
1070
|
-
declare const stageInputSchema: z.ZodObject<{
|
|
1071
|
-
name: z.ZodString;
|
|
1072
|
-
sequence: z.ZodNumber;
|
|
1073
|
-
defaultProbability: z.ZodNumber;
|
|
1074
|
-
color: z.ZodOptional<z.ZodString>;
|
|
1075
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1076
|
-
}, z.core.$strip>;
|
|
1077
|
-
declare const createPipelineSchema: z.ZodObject<{
|
|
1078
|
-
name: z.ZodString;
|
|
1079
|
-
stages: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1080
|
-
name: z.ZodString;
|
|
1081
|
-
sequence: z.ZodNumber;
|
|
1082
|
-
defaultProbability: z.ZodNumber;
|
|
1083
|
-
color: z.ZodOptional<z.ZodString>;
|
|
1084
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1085
|
-
}, z.core.$strip>>>;
|
|
1086
|
-
teamRef: z.ZodOptional<z.ZodString>;
|
|
1087
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1088
|
-
}, z.core.$strip>;
|
|
1089
|
-
declare const updatePipelineSchema: z.ZodObject<{
|
|
1090
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1091
|
-
stages: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1092
|
-
name: z.ZodString;
|
|
1093
|
-
sequence: z.ZodNumber;
|
|
1094
|
-
defaultProbability: z.ZodNumber;
|
|
1095
|
-
color: z.ZodOptional<z.ZodString>;
|
|
1096
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1097
|
-
}, z.core.$strip>>>>;
|
|
1098
|
-
teamRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1099
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1100
|
-
}, z.core.$strip>;
|
|
1101
|
-
declare const stageInputSchemaExport: z.ZodObject<{
|
|
1102
|
-
name: z.ZodString;
|
|
1103
|
-
sequence: z.ZodNumber;
|
|
1104
|
-
defaultProbability: z.ZodNumber;
|
|
1105
|
-
color: z.ZodOptional<z.ZodString>;
|
|
1106
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1107
|
-
}, z.core.$strip>;
|
|
1108
|
-
declare const pipelineFilterSchema: z.ZodObject<{
|
|
1109
|
-
isArchived: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
1110
|
-
teamRef: z.ZodOptional<z.ZodString>;
|
|
1111
|
-
}, z.core.$strip>;
|
|
1112
|
-
type CreatePipelineDto = z.infer<typeof createPipelineSchema>;
|
|
1113
|
-
type UpdatePipelineDto = z.infer<typeof updatePipelineSchema>;
|
|
1114
|
-
type StageInputDto = z.infer<typeof stageInputSchema>;
|
|
1115
|
-
//#endregion
|
|
1116
|
-
//#region src/validators/lead.schema.d.ts
|
|
1117
|
-
declare const createLeadSchema: z.ZodObject<{
|
|
1118
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
1119
|
-
firstName: z.ZodOptional<z.ZodString>;
|
|
1120
|
-
lastName: z.ZodOptional<z.ZodString>;
|
|
1121
|
-
email: z.ZodOptional<z.ZodString>;
|
|
1122
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
1123
|
-
companyName: z.ZodOptional<z.ZodString>;
|
|
1124
|
-
jobTitle: z.ZodOptional<z.ZodString>;
|
|
1125
|
-
source: z.ZodOptional<z.ZodString>;
|
|
1126
|
-
campaignRef: z.ZodOptional<z.ZodString>;
|
|
1127
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1128
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1129
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1130
|
-
}, z.core.$strip>;
|
|
1131
|
-
declare const updateLeadSchema: z.ZodObject<{
|
|
1132
|
-
fullName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1133
|
-
firstName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1134
|
-
lastName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1135
|
-
email: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1136
|
-
phone: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1137
|
-
companyName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1138
|
-
jobTitle: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1139
|
-
source: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1140
|
-
campaignRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1141
|
-
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1142
|
-
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
1143
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1144
|
-
}, z.core.$strip>;
|
|
1145
|
-
declare const leadFilterSchema: z.ZodObject<{
|
|
1146
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
1147
|
-
new: "new";
|
|
1148
|
-
contacted: "contacted";
|
|
1149
|
-
qualified: "qualified";
|
|
1150
|
-
converted: "converted";
|
|
1151
|
-
disqualified: "disqualified";
|
|
1152
|
-
nurturing: "nurturing";
|
|
1153
|
-
}>>;
|
|
1154
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1155
|
-
email: z.ZodOptional<z.ZodString>;
|
|
1156
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1157
|
-
source: z.ZodOptional<z.ZodString>;
|
|
1158
|
-
campaignRef: z.ZodOptional<z.ZodString>;
|
|
1159
|
-
scoreMin: z.ZodOptional<z.ZodNumber>;
|
|
1160
|
-
scoreMax: z.ZodOptional<z.ZodNumber>;
|
|
1161
|
-
}, z.core.$strip>;
|
|
1162
|
-
declare const convertLeadSchema: z.ZodObject<{
|
|
1163
|
-
pipelineId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1164
|
-
opportunityName: z.ZodOptional<z.ZodString>;
|
|
1165
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
1166
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
1167
|
-
expectedCloseAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1168
|
-
by: z.ZodOptional<z.ZodString>;
|
|
1169
|
-
}, z.core.$strip>;
|
|
1170
|
-
type CreateLeadDto = z.infer<typeof createLeadSchema>;
|
|
1171
|
-
type UpdateLeadDto = z.infer<typeof updateLeadSchema>;
|
|
1172
|
-
type ConvertLeadDto = z.infer<typeof convertLeadSchema>;
|
|
1173
|
-
type LeadFilterDto = z.infer<typeof leadFilterSchema>;
|
|
1174
|
-
//#endregion
|
|
1175
|
-
//#region src/validators/opportunity.schema.d.ts
|
|
1176
|
-
declare const openOpportunitySchema: z.ZodObject<{
|
|
1177
|
-
name: z.ZodString;
|
|
1178
|
-
pipelineId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1179
|
-
stageId: z.ZodOptional<z.ZodString>;
|
|
1180
|
-
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1181
|
-
primaryContactId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1182
|
-
sourceLeadId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1183
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
1184
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
1185
|
-
probability: z.ZodOptional<z.ZodNumber>;
|
|
1186
|
-
expectedCloseAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1187
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1188
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1189
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1190
|
-
}, z.core.$strip>;
|
|
1191
|
-
declare const moveStageSchema: z.ZodObject<{
|
|
1192
|
-
stageId: z.ZodString;
|
|
1193
|
-
by: z.ZodOptional<z.ZodString>;
|
|
1194
|
-
note: z.ZodOptional<z.ZodString>;
|
|
1195
|
-
probability: z.ZodOptional<z.ZodNumber>;
|
|
1196
|
-
}, z.core.$strip>;
|
|
1197
|
-
declare const closeWinSchema: z.ZodObject<{
|
|
1198
|
-
by: z.ZodOptional<z.ZodString>;
|
|
1199
|
-
note: z.ZodOptional<z.ZodString>;
|
|
1200
|
-
closedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1201
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
1202
|
-
}, z.core.$strip>;
|
|
1203
|
-
declare const closeLossSchema: z.ZodObject<{
|
|
1204
|
-
by: z.ZodOptional<z.ZodString>;
|
|
1205
|
-
note: z.ZodOptional<z.ZodString>;
|
|
1206
|
-
closedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1207
|
-
lostReasonId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1208
|
-
}, z.core.$strip>;
|
|
1209
|
-
declare const opportunityFilterSchema: z.ZodObject<{
|
|
1210
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
1211
|
-
open: "open";
|
|
1212
|
-
won: "won";
|
|
1213
|
-
lost: "lost";
|
|
1214
|
-
abandoned: "abandoned";
|
|
1215
|
-
}>>;
|
|
1216
|
-
pipelineId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1217
|
-
stageId: z.ZodOptional<z.ZodString>;
|
|
1218
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1219
|
-
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1220
|
-
expectedCloseFrom: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1221
|
-
expectedCloseTo: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1222
|
-
}, z.core.$strip>;
|
|
1223
|
-
type OpenOpportunityDto = z.infer<typeof openOpportunitySchema>;
|
|
1224
|
-
type MoveStageDto = z.infer<typeof moveStageSchema>;
|
|
1225
|
-
type CloseWinDto = z.infer<typeof closeWinSchema>;
|
|
1226
|
-
type CloseLossDto = z.infer<typeof closeLossSchema>;
|
|
1227
|
-
type OpportunityFilterDto = z.infer<typeof opportunityFilterSchema>;
|
|
1228
|
-
//#endregion
|
|
1229
|
-
//#region src/validators/contact.schema.d.ts
|
|
1230
|
-
declare const createContactSchema: z.ZodObject<{
|
|
1231
|
-
name: z.ZodObject<{
|
|
1232
|
-
given: z.ZodString;
|
|
1233
|
-
family: z.ZodDefault<z.ZodString>;
|
|
1234
|
-
middle: z.ZodOptional<z.ZodString>;
|
|
1235
|
-
prefix: z.ZodOptional<z.ZodString>;
|
|
1236
|
-
suffix: z.ZodOptional<z.ZodString>;
|
|
1237
|
-
preferred: z.ZodOptional<z.ZodString>;
|
|
1238
|
-
}, z.core.$strip>;
|
|
1239
|
-
contact: z.ZodDefault<z.ZodObject<{
|
|
1240
|
-
email: z.ZodOptional<z.ZodString>;
|
|
1241
|
-
personalEmail: z.ZodOptional<z.ZodString>;
|
|
1242
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
1243
|
-
alternatePhone: z.ZodOptional<z.ZodString>;
|
|
1244
|
-
}, z.core.$strip>>;
|
|
1245
|
-
jobTitle: z.ZodOptional<z.ZodString>;
|
|
1246
|
-
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1247
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1248
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1249
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1250
|
-
}, z.core.$strip>;
|
|
1251
|
-
declare const updateContactSchema: z.ZodObject<{
|
|
1252
|
-
name: z.ZodOptional<z.ZodObject<{
|
|
1253
|
-
given: z.ZodString;
|
|
1254
|
-
family: z.ZodDefault<z.ZodString>;
|
|
1255
|
-
middle: z.ZodOptional<z.ZodString>;
|
|
1256
|
-
prefix: z.ZodOptional<z.ZodString>;
|
|
1257
|
-
suffix: z.ZodOptional<z.ZodString>;
|
|
1258
|
-
preferred: z.ZodOptional<z.ZodString>;
|
|
1259
|
-
}, z.core.$strip>>;
|
|
1260
|
-
contact: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
1261
|
-
email: z.ZodOptional<z.ZodString>;
|
|
1262
|
-
personalEmail: z.ZodOptional<z.ZodString>;
|
|
1263
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
1264
|
-
alternatePhone: z.ZodOptional<z.ZodString>;
|
|
1265
|
-
}, z.core.$strip>>>;
|
|
1266
|
-
jobTitle: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1267
|
-
accountId: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
|
|
1268
|
-
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1269
|
-
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
1270
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1271
|
-
}, z.core.$strip>;
|
|
1272
|
-
declare const contactFilterSchema: z.ZodObject<{
|
|
1273
|
-
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1274
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1275
|
-
email: z.ZodOptional<z.ZodString>;
|
|
1276
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1277
|
-
}, z.core.$strip>;
|
|
1278
|
-
type CreateContactDto = z.infer<typeof createContactSchema>;
|
|
1279
|
-
type UpdateContactDto = z.infer<typeof updateContactSchema>;
|
|
1280
|
-
//#endregion
|
|
1281
|
-
//#region src/validators/account.schema.d.ts
|
|
1282
|
-
declare const createAccountSchema: z.ZodObject<{
|
|
1283
|
-
name: z.ZodString;
|
|
1284
|
-
domain: z.ZodOptional<z.ZodString>;
|
|
1285
|
-
industry: z.ZodOptional<z.ZodString>;
|
|
1286
|
-
sizeBucket: z.ZodOptional<z.ZodString>;
|
|
1287
|
-
annualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
1288
|
-
annualRevenueCurrency: z.ZodOptional<z.ZodString>;
|
|
1289
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1290
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1291
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1292
|
-
}, z.core.$strip>;
|
|
1293
|
-
declare const updateAccountSchema: z.ZodObject<{
|
|
1294
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1295
|
-
domain: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1296
|
-
industry: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1297
|
-
sizeBucket: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1298
|
-
annualRevenueAmount: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1299
|
-
annualRevenueCurrency: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1300
|
-
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1301
|
-
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
1302
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1303
|
-
}, z.core.$strip>;
|
|
1304
|
-
declare const accountFilterSchema: z.ZodObject<{
|
|
1305
|
-
domain: z.ZodOptional<z.ZodString>;
|
|
1306
|
-
industry: z.ZodOptional<z.ZodString>;
|
|
1307
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1308
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1309
|
-
}, z.core.$strip>;
|
|
1310
|
-
type CreateAccountDto = z.infer<typeof createAccountSchema>;
|
|
1311
|
-
type UpdateAccountDto = z.infer<typeof updateAccountSchema>;
|
|
1312
|
-
//#endregion
|
|
1313
|
-
//#region src/validators/campaign.schema.d.ts
|
|
1314
|
-
declare const createCampaignSchema: z.ZodObject<{
|
|
1315
|
-
name: z.ZodString;
|
|
1316
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1317
|
-
utmSource: z.ZodOptional<z.ZodString>;
|
|
1318
|
-
utmMedium: z.ZodOptional<z.ZodString>;
|
|
1319
|
-
utmCampaign: z.ZodOptional<z.ZodString>;
|
|
1320
|
-
startDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1321
|
-
endDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1322
|
-
budgetAmount: z.ZodOptional<z.ZodNumber>;
|
|
1323
|
-
expectedRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
1324
|
-
currency: z.ZodOptional<z.ZodString>;
|
|
1325
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1326
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1327
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1328
|
-
}, z.core.$strip>;
|
|
1329
|
-
declare const updateCampaignSchema: z.ZodObject<{
|
|
1330
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1331
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1332
|
-
utmSource: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1333
|
-
utmMedium: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1334
|
-
utmCampaign: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1335
|
-
startDate: z.ZodOptional<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
1336
|
-
endDate: z.ZodOptional<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
1337
|
-
budgetAmount: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1338
|
-
expectedRevenueAmount: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1339
|
-
currency: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1340
|
-
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1341
|
-
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
1342
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1343
|
-
}, z.core.$strip>;
|
|
1344
|
-
declare const completeCampaignSchema: z.ZodObject<{
|
|
1345
|
-
by: z.ZodOptional<z.ZodString>;
|
|
1346
|
-
note: z.ZodOptional<z.ZodString>;
|
|
1347
|
-
actualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
1348
|
-
}, z.core.$strip>;
|
|
1349
|
-
declare const campaignFilterSchema: z.ZodObject<{
|
|
1350
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
1351
|
-
draft: "draft";
|
|
1352
|
-
active: "active";
|
|
1353
|
-
paused: "paused";
|
|
1354
|
-
completed: "completed";
|
|
1355
|
-
archived: "archived";
|
|
1356
|
-
}>>;
|
|
1357
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1358
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1359
|
-
startDateFrom: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1360
|
-
startDateTo: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1361
|
-
}, z.core.$strip>;
|
|
1362
|
-
type CreateCampaignDto = z.infer<typeof createCampaignSchema>;
|
|
1363
|
-
type UpdateCampaignDto = z.infer<typeof updateCampaignSchema>;
|
|
1364
|
-
type CompleteCampaignDto = z.infer<typeof completeCampaignSchema>;
|
|
1365
|
-
//#endregion
|
|
1366
|
-
//#region src/validators/subscription.schema.d.ts
|
|
1367
|
-
declare const subscribeSchema: z.ZodObject<{
|
|
1368
|
-
contactId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1369
|
-
campaignId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1370
|
-
source: z.ZodOptional<z.ZodString>;
|
|
1371
|
-
consentIpAddress: z.ZodOptional<z.ZodString>;
|
|
1372
|
-
consentUserAgent: z.ZodOptional<z.ZodString>;
|
|
1373
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1374
|
-
requireDoubleOptIn: z.ZodOptional<z.ZodBoolean>;
|
|
1375
|
-
}, z.core.$strip>;
|
|
1376
|
-
declare const confirmSubscriptionSchema: z.ZodObject<{
|
|
1377
|
-
token: z.ZodString;
|
|
1378
|
-
}, z.core.$strip>;
|
|
1379
|
-
declare const unsubscribeSchema: z.ZodObject<{
|
|
1380
|
-
token: z.ZodString;
|
|
1381
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
1382
|
-
}, z.core.$strip>;
|
|
1383
|
-
declare const subscriptionFilterSchema: z.ZodObject<{
|
|
1384
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
1385
|
-
pending: "pending";
|
|
1386
|
-
confirmed: "confirmed";
|
|
1387
|
-
unsubscribed: "unsubscribed";
|
|
1388
|
-
bounced: "bounced";
|
|
1389
|
-
complained: "complained";
|
|
1390
|
-
}>>;
|
|
1391
|
-
contactId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1392
|
-
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1393
|
-
}, z.core.$strip>;
|
|
1394
|
-
type SubscribeDto = z.infer<typeof subscribeSchema>;
|
|
1395
|
-
type ConfirmSubscriptionDto = z.infer<typeof confirmSubscriptionSchema>;
|
|
1396
|
-
type UnsubscribeDto = z.infer<typeof unsubscribeSchema>;
|
|
1397
|
-
//#endregion
|
|
1398
|
-
//#region src/validators/activity.schema.d.ts
|
|
1399
|
-
declare const planActivitySchema: z.ZodObject<{
|
|
1400
|
-
type: z.ZodEnum<{
|
|
1401
|
-
call: "call";
|
|
1402
|
-
email: "email";
|
|
1403
|
-
meeting: "meeting";
|
|
1404
|
-
task: "task";
|
|
1405
|
-
note: "note";
|
|
1406
|
-
sms: "sms";
|
|
1407
|
-
social: "social";
|
|
1408
|
-
demo: "demo";
|
|
1409
|
-
other: "other";
|
|
1410
|
-
}>;
|
|
1411
|
-
subjectKind: z.ZodEnum<{
|
|
1412
|
-
lead: "lead";
|
|
1413
|
-
opportunity: "opportunity";
|
|
1414
|
-
contact: "contact";
|
|
1415
|
-
account: "account";
|
|
1416
|
-
}>;
|
|
1417
|
-
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1418
|
-
title: z.ZodString;
|
|
1419
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1420
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1421
|
-
participantIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1422
|
-
dueDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1423
|
-
externalRef: z.ZodOptional<z.ZodString>;
|
|
1424
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1425
|
-
}, z.core.$strip>;
|
|
1426
|
-
declare const updateActivitySchema: z.ZodObject<{
|
|
1427
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
1428
|
-
call: "call";
|
|
1429
|
-
email: "email";
|
|
1430
|
-
meeting: "meeting";
|
|
1431
|
-
task: "task";
|
|
1432
|
-
note: "note";
|
|
1433
|
-
sms: "sms";
|
|
1434
|
-
social: "social";
|
|
1435
|
-
demo: "demo";
|
|
1436
|
-
other: "other";
|
|
1437
|
-
}>>;
|
|
1438
|
-
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
1439
|
-
lead: "lead";
|
|
1440
|
-
opportunity: "opportunity";
|
|
1441
|
-
contact: "contact";
|
|
1442
|
-
account: "account";
|
|
1443
|
-
}>>;
|
|
1444
|
-
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1445
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1446
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1447
|
-
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1448
|
-
participantIds: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
1449
|
-
dueDate: z.ZodOptional<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
1450
|
-
externalRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1451
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1452
|
-
}, z.core.$strip>;
|
|
1453
|
-
declare const cancelActivitySchema: z.ZodObject<{
|
|
1454
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
1455
|
-
}, z.core.$strip>;
|
|
1456
|
-
declare const activityFilterSchema: z.ZodObject<{
|
|
1457
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
1458
|
-
call: "call";
|
|
1459
|
-
email: "email";
|
|
1460
|
-
meeting: "meeting";
|
|
1461
|
-
task: "task";
|
|
1462
|
-
note: "note";
|
|
1463
|
-
sms: "sms";
|
|
1464
|
-
social: "social";
|
|
1465
|
-
demo: "demo";
|
|
1466
|
-
other: "other";
|
|
1467
|
-
}>>;
|
|
1468
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
1469
|
-
completed: "completed";
|
|
1470
|
-
planned: "planned";
|
|
1471
|
-
in_progress: "in_progress";
|
|
1472
|
-
cancelled: "cancelled";
|
|
1473
|
-
}>>;
|
|
1474
|
-
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
1475
|
-
lead: "lead";
|
|
1476
|
-
opportunity: "opportunity";
|
|
1477
|
-
contact: "contact";
|
|
1478
|
-
account: "account";
|
|
1479
|
-
}>>;
|
|
1480
|
-
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1481
|
-
ownerId: z.ZodOptional<z.ZodString>;
|
|
1482
|
-
dueDateFrom: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1483
|
-
dueDateTo: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
1484
|
-
}, z.core.$strip>;
|
|
1485
|
-
type PlanActivityDto = z.infer<typeof planActivitySchema>;
|
|
1486
|
-
type CancelActivityDto = z.infer<typeof cancelActivitySchema>;
|
|
1487
|
-
//#endregion
|
|
1488
|
-
//#region src/validators/note.schema.d.ts
|
|
1489
|
-
declare const addNoteSchema: z.ZodObject<{
|
|
1490
|
-
subjectKind: z.ZodEnum<{
|
|
1491
|
-
lead: "lead";
|
|
1492
|
-
opportunity: "opportunity";
|
|
1493
|
-
contact: "contact";
|
|
1494
|
-
account: "account";
|
|
1495
|
-
}>;
|
|
1496
|
-
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1497
|
-
body: z.ZodString;
|
|
1498
|
-
authorId: z.ZodOptional<z.ZodString>;
|
|
1499
|
-
pinned: z.ZodOptional<z.ZodBoolean>;
|
|
1500
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1501
|
-
}, z.core.$strip>;
|
|
1502
|
-
declare const updateNoteSchema: z.ZodObject<{
|
|
1503
|
-
body: z.ZodOptional<z.ZodString>;
|
|
1504
|
-
pinned: z.ZodOptional<z.ZodBoolean>;
|
|
1505
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1506
|
-
}, z.core.$strip>;
|
|
1507
|
-
declare const noteFilterSchema: z.ZodObject<{
|
|
1508
|
-
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
1509
|
-
lead: "lead";
|
|
1510
|
-
opportunity: "opportunity";
|
|
1511
|
-
contact: "contact";
|
|
1512
|
-
account: "account";
|
|
1513
|
-
}>>;
|
|
1514
|
-
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1515
|
-
authorId: z.ZodOptional<z.ZodString>;
|
|
1516
|
-
pinned: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
1517
|
-
}, z.core.$strip>;
|
|
1518
|
-
type AddNoteDto = z.infer<typeof addNoteSchema>;
|
|
1519
|
-
type UpdateNoteDto = z.infer<typeof updateNoteSchema>;
|
|
1520
|
-
//#endregion
|
|
1521
|
-
//#region src/validators/loss-reason.schema.d.ts
|
|
1522
|
-
declare const createLossReasonSchema: z.ZodObject<{
|
|
1523
|
-
name: z.ZodString;
|
|
1524
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1525
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
1526
|
-
sequence: z.ZodOptional<z.ZodNumber>;
|
|
1527
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1528
|
-
}, z.core.$strip>;
|
|
1529
|
-
declare const updateLossReasonSchema: z.ZodObject<{
|
|
1530
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1531
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1532
|
-
isActive: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
1533
|
-
sequence: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
1534
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1535
|
-
}, z.core.$strip>;
|
|
1536
|
-
declare const lossReasonFilterSchema: z.ZodObject<{
|
|
1537
|
-
isActive: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
1538
|
-
}, z.core.$strip>;
|
|
1539
|
-
type CreateLossReasonDto = z.infer<typeof createLossReasonSchema>;
|
|
1540
|
-
type UpdateLossReasonDto = z.infer<typeof updateLossReasonSchema>;
|
|
1541
|
-
//#endregion
|
|
1542
|
-
//#region src/validators/email-event.schema.d.ts
|
|
1543
|
-
declare const recordEmailEventSchema: z.ZodObject<{
|
|
1544
|
-
subjectKind: z.ZodEnum<{
|
|
1545
|
-
contact: "contact";
|
|
1546
|
-
subscription: "subscription";
|
|
1547
|
-
}>;
|
|
1548
|
-
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
1549
|
-
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1550
|
-
messageId: z.ZodOptional<z.ZodString>;
|
|
1551
|
-
url: z.ZodOptional<z.ZodString>;
|
|
1552
|
-
userAgent: z.ZodOptional<z.ZodString>;
|
|
1553
|
-
ip: z.ZodOptional<z.ZodString>;
|
|
1554
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1555
|
-
}, z.core.$strip>;
|
|
1556
|
-
declare const emailEventFilterSchema: z.ZodObject<{
|
|
1557
|
-
kind: z.ZodOptional<z.ZodEnum<{
|
|
1558
|
-
open: "open";
|
|
1559
|
-
click: "click";
|
|
1560
|
-
bounce: "bounce";
|
|
1561
|
-
complaint: "complaint";
|
|
1562
|
-
unsubscribe: "unsubscribe";
|
|
1563
|
-
}>>;
|
|
1564
|
-
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
1565
|
-
contact: "contact";
|
|
1566
|
-
subscription: "subscription";
|
|
1567
|
-
}>>;
|
|
1568
|
-
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1569
|
-
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
1570
|
-
messageId: z.ZodOptional<z.ZodString>;
|
|
1571
|
-
}, z.core.$strip>;
|
|
1572
|
-
type RecordEmailEventDto = z.infer<typeof recordEmailEventSchema>;
|
|
1573
|
-
//#endregion
|
|
1574
|
-
export { ACTIVITY_MACHINE, ACTIVITY_STATUSES, ACTIVITY_TRANSITIONS, ACTIVITY_TYPES, AccountRepository, AccountRepositoryDeps, ActivityRepository, ActivityRepositoryDeps, type ActivityStatus, type ActivityType, CAMPAIGN_MACHINE, CAMPAIGN_STATUSES, CAMPAIGN_TRANSITIONS, CRM_EVENTS, CampaignRepository, CampaignRepositoryDeps, type CampaignStatus, CloseInput, ContactRepository, ContactRepositoryDeps, ConversionRow, ConvertLeadInput, ConvertResult, CreateCrmRepositoriesDeps, CrmConfig, CrmContext, CrmEngine, CrmError, CrmEventName, CrmLogger, CrmModels, CrmRepositories, DuplicateCampaignError, DuplicateLeadError, DuplicateSubscriptionError, EMAIL_EVENT_KINDS, EMAIL_EVENT_SUBJECT_KINDS, type EmailEventKind, EmailEventRepository, EmailEventRepositoryDeps, EmailEventSubjectKind, EmptyPipelineError, ForecastOptions, ForecastRow, type IAccountDocument, type IActivityDocument, type ICampaignDocument, ICampaignStatusEntry, type IContactDocument, IContactInfoEmbedded, IContactName, type IEmailEventDocument, type ILeadDocument, ILeadStatusEntry, type ILossReasonDocument, type INoteDocument, type IOpportunityDocument, IOpportunityStatusEntry, type IPipelineDocument, IStageDocument, type ISubscriptionDocument, ISubscriptionStatusEntry, InProcessCrmBus, InvalidActivityTransitionError, InvalidCampaignTransitionError, InvalidConfirmationTokenError, InvalidLeadTransitionError, InvalidOpportunityTransitionError, InvalidSubscriptionTransitionError, InvalidUnsubscribeTokenError, LEAD_MACHINE, LEAD_STATUSES, LEAD_TRANSITIONS, LeadAlreadyConvertedError, LeadInput, LeadRepository, LeadRepositoryDeps, LeadScorer, LeadService, LeadServiceDeps, type LeadStatus, LossReasonRepository, LossReasonRepositoryDeps, MoveStageInput, NotFoundError, NoteRepository, NoteRepositoryDeps, OPPORTUNITY_MACHINE, OPPORTUNITY_STATUSES, OPPORTUNITY_TRANSITIONS, OpenOpportunityInput, OpportunityForecast, OpportunityRepository, OpportunityRepositoryDeps, type OpportunityStatus, PipelineRepository, PipelineRepositoryDeps, RecordEmailEventInput, ResolvedCrmConfig, SUBJECT_KINDS, SUBSCRIPTION_MACHINE, SUBSCRIPTION_STATUSES, SUBSCRIPTION_TRANSITIONS, SchemaBuildConfig, StageNotInPipelineError, type StatusChangeEntry, type StatusHistory, type SubjectKind, SubscribeInput, SubscriptionRepository, SubscriptionRepositoryDeps, type SubscriptionStatus, TenantFieldType, _ModelTypes, appendStatus, buildAccountSchema, buildActivitySchema, buildCampaignSchema, buildContactSchema, buildEmailEventSchema, buildLeadSchema, buildLossReasonSchema, buildNoteSchema, buildOpportunitySchema, buildPipelineSchema, buildSubscriptionSchema, canTransitionActivity, canTransitionCampaign, canTransitionLead, canTransitionOpportunity, canTransitionSubscription, composeScorers, createAccountModel, createActivityModel, createCampaignModel, createContactModel, createCrm, createCrmModels, createCrmRepositories, createEmailEventModel, createEvent, createLeadModel, createLossReasonModel, createNoteModel, createOpportunityModel, createPipelineModel, createSubscriptionModel, defaultLeadScorer, forecast, lastTransitionTo, latestEntry, pipelineConversion, tenantFieldDef, timeInStatus, index_d_exports as validators };
|
|
1575
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1487
|
+
export { IMessageAttachment as $, ContactUpdated as $n, CAMPAIGN_TRANSITIONS as $t, AccountRepository as A, SchemaBuildConfig as An, PipelineArchived as Ar, buildActivitySchema as At, OpportunityRepositoryDeps as B, ActivityOutcomeRecorded as Bn, ISubscriptionDocument as Bt, ActivityRepository as C, LEAD_TRANSITIONS as Cn, OpportunityAssigned as Cr, ILossReasonDocument as Ct, SubscriptionRepositoryDeps as D, IStageDocument as Dn, OpportunityStageAdvanced as Dr, buildNoteSchema as Dt, SubscriptionRepository as E, IPipelineDocument as En, OpportunityLost as Er, INoteDocument as Et, MergeContactInput as F, AccountEnriched as Fn, SubscriptionCreated as Fr, ActivityStatus as Ft, composeScorers as G, CampaignCompleted as Gn, SUBSCRIPTION_TRANSITIONS as Gt, LeadRepositoryDeps as H, ActivityRescheduled as Hn, buildSubscriptionSchema as Ht, CloseInput as I, AccountMerged as In, SubscriptionUnsubscribed as Ir, ActivityType as It, PipelineRepositoryDeps as J, CampaignResumed as Jn, ICampaignDocument as Jt, defaultLeadScorer as K, CampaignCreated as Kn, SubscriptionStatus as Kt, MoveStageInput as L, AccountUpdated as Ln, crmEventDefinitions as Lr, SUBJECT_KINDS as Lt, MergeAccountInput as M, tenantFieldDef as Mn, SubscriptionBounced as Mr, ACTIVITY_STATUSES as Mt, ContactRepository as N, AccountAssigned as Nn, SubscriptionComplained as Nr, ACTIVITY_TRANSITIONS as Nt, CampaignRepository as O, buildPipelineSchema as On, OpportunityStageRegressed as Or, createNoteModel as Ot, ContactRepositoryDeps as P, AccountCreated as Pn, SubscriptionConfirmed as Pr, ACTIVITY_TYPES as Pt, createCrmModels as Q, ContactMerged as Qn, CAMPAIGN_STATUSES as Qt, OpenOpportunityInput as R, ActivityCancelled as Rn, CRM_EVENTS as Rr, SubjectKind as Rt, NoteRepositoryDeps as S, LEAD_STATUSES as Sn, OpportunityAmountChanged as Sr, EmailEventKind as St, SubscribeInput as T, canTransitionLead as Tn, OpportunityExtended as Tr, createLossReasonModel as Tt, LeadInput as U, CampaignActivated as Un, createSubscriptionModel as Ut, LeadRepository as V, ActivityPlanned as Vn, ISubscriptionStatusEntry as Vt, LeadScorer as W, CampaignArchived as Wn, SUBSCRIPTION_STATUSES as Wt, CreateModelsOptions as X, ContactCreated as Xn, buildCampaignSchema as Xt, CRM_MODEL_NAMES as Y, ContactAssigned as Yn, ICampaignStatusEntry as Yt, CrmModels as Z, ContactEnriched as Zn, createCampaignModel as Zt, EmailEventRepositoryDeps as _, canTransitionOpportunity as _n, LeadStatusChanged as _r, EmailEventSubjectKind as _t, CrmEngine as a, IContactDocument as an, CrmEventSchema as ar, createConversationModel as at, LossReasonRepositoryDeps as b, buildLeadSchema as bn, NoteAdded as br, createEmailEventModel as bt, ResolvedCrmConfig as c, buildContactSchema as cn, EmailEventComplained as cr, CONVERSATION_STATUSES as ct, MessageRepositoryDeps as d, IOpportunityStatusEntry as dn, LeadAssigned as dr, ConversationStatus as dt, CampaignStatus as en, ConversationAssigned as er, IMessageDocument as et, RecordMessageInput as f, buildOpportunitySchema as fn, LeadConverted as fr, MESSAGE_DELIVERY_STATUSES as ft, EmailEventRepository as g, OpportunityStatus as gn, LeadScored as gr, EMAIL_EVENT_SUBJECT_KINDS as gt, OpenConversationInput as h, OPPORTUNITY_TRANSITIONS as hn, LeadEnriched as hr, MessageDirection as ht, CrmContext as i, createAccountModel as in, CrmEventDefinition as ir, buildConversationSchema as it, AccountRepositoryDeps as j, TenantFieldType as jn, PipelineCreated as jr, createActivityModel as jt, CampaignRepositoryDeps as k, createPipelineModel as kn, OpportunityWon as kr, IActivityDocument as kt, _ModelTypes as l, createContactModel as ln, EmailEventOpened as lr, ConversationChannel as lt, ConversationRepositoryDeps as m, OPPORTUNITY_STATUSES as mn, LeadDisqualified as mr, MessageDeliveryStatus as mt, createEvent$1 as n, IAccountDocument as nn, ConversationReopened as nr, createMessageModel as nt, CrmLogger as o, IContactInfoEmbedded as on, EmailEventBounced as or, CONVERSATION_CHANNELS as ot, ConversationRepository as p, createOpportunityModel as pn, LeadCreated as pr, MESSAGE_DIRECTIONS as pt, PipelineRepository as q, CampaignPaused as qn, canTransitionSubscription as qt, CrmConfig as r, buildAccountSchema as rn, ConversationResolved as rr, IConversationDocument as rt, CrmRepositories as s, IContactName as sn, EmailEventClicked as sr, CONVERSATION_PARTICIPANT_KINDS as st, InProcessCrmBus as t, canTransitionCampaign as tn, ConversationCreated as tr, buildMessageSchema as tt, MessageRepository as u, IOpportunityDocument as un, EmailEventUnsubscribed as ur, ConversationParticipantKind as ut, RecordEmailEventInput as v, ILeadDocument as vn, MessageReceived as vr, IEmailEventDocument as vt, ActivityRepositoryDeps as w, LeadStatus as wn, OpportunityCreated as wr, buildLossReasonSchema as wt, NoteRepository as x, createLeadModel as xn, OpportunityAbandoned as xr, EMAIL_EVENT_KINDS as xt, LossReasonRepository as y, ILeadStatusEntry as yn, MessageSent as yr, buildEmailEventSchema as yt, OpportunityRepository as z, ActivityCompleted as zn, CrmEventName as zr, canTransitionActivity as zt };
|