@classytic/crm 0.5.0 → 0.7.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 +124 -0
- package/dist/events.d.ts +475 -2
- package/dist/events.js +180 -59
- package/dist/index.d.ts +2095 -780
- package/dist/index.js +1787 -72
- package/package.json +8 -8
- package/dist/index2.d.ts +0 -746
- /package/dist/{rolldown-runtime.js → chunk.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,387 +1,69 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _$mongoose from "mongoose";
|
|
2
2
|
import { Connection, Model, Schema, SchemaDefinitionProperty } from "mongoose";
|
|
3
3
|
import { PaginationConfig, PluginType, Repository } from "@classytic/mongokit";
|
|
4
4
|
import { DomainEvent, EventHandler, EventMeta, EventTransport } from "@classytic/primitives/events";
|
|
5
|
+
import * as _$_classytic_primitives_state_machine0 from "@classytic/primitives/state-machine";
|
|
5
6
|
import { z } from "zod";
|
|
7
|
+
import { StatusChangeEntry, StatusHistory, appendStatus, lastTransitionTo, latestEntry, timeInStatus } from "@classytic/primitives/status-history";
|
|
6
8
|
import { OperationContext } from "@classytic/primitives/context";
|
|
9
|
+
import { OutboxStore } from "@classytic/primitives/outbox";
|
|
7
10
|
|
|
8
|
-
//#region src/events/
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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";
|
|
11
|
+
//#region src/events/dispatch.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Context key for the post-commit event queue. `Symbol.for` so the host
|
|
14
|
+
* and the package agree on the key even across duplicated installs.
|
|
15
|
+
*/
|
|
16
|
+
declare const PENDING_EVENTS: unique symbol;
|
|
17
|
+
/** CrmContext as seen inside a unit of work — carries the deferred queue. */
|
|
18
|
+
type InternalCrmContext = CrmContext & {
|
|
19
|
+
[PENDING_EVENTS]?: DomainEvent[];
|
|
67
20
|
};
|
|
68
|
-
|
|
21
|
+
interface CrmEventDispatcherOptions {
|
|
22
|
+
/** Underlying transport (host-supplied or the in-process bus). */
|
|
23
|
+
transport: EventTransport;
|
|
24
|
+
/**
|
|
25
|
+
* Transactional outbox. When wired, every domain event is persisted via
|
|
26
|
+
* `outbox.save(event, { session })` in the SAME session as the business
|
|
27
|
+
* write; the host's relay publishes committed rows.
|
|
28
|
+
*/
|
|
29
|
+
outbox?: OutboxStore | undefined;
|
|
30
|
+
logger?: CrmLogger | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* EventTransport-compatible wrapper the engine hands to repositories.
|
|
34
|
+
* `publish`/`subscribe` delegate straight to the underlying transport
|
|
35
|
+
* (host-facing surface unchanged); domain verbs call `dispatch(ctx, event)`
|
|
36
|
+
* so session/outbox/queue routing happens in ONE place.
|
|
37
|
+
*/
|
|
38
|
+
declare class CrmEventDispatcher implements EventTransport {
|
|
39
|
+
readonly transport: EventTransport;
|
|
40
|
+
private readonly outbox;
|
|
41
|
+
private readonly logger;
|
|
42
|
+
constructor(options: CrmEventDispatcherOptions);
|
|
43
|
+
get name(): string;
|
|
44
|
+
/** Raw immediate publish — post-commit flushes and host-side use only. */
|
|
45
|
+
publish(event: DomainEvent): Promise<void>;
|
|
46
|
+
subscribe(pattern: string, handler: EventHandler): Promise<() => void>;
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Session-bound dispatch (see module doc for the full contract).
|
|
50
|
+
* `ctx` comes first so call sites read `dispatch(ctx, createEvent(...))`.
|
|
51
|
+
*/
|
|
52
|
+
dispatch(ctx: CrmContext | undefined, event: DomainEvent): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Drain a `[PENDING_EVENTS]` queue through a transport after commit,
|
|
56
|
+
* swallowing per-event errors (durable delivery is the outbox's job).
|
|
57
|
+
* Hosts composing their own outer transaction call this after commit;
|
|
58
|
+
* most should use `engine.withTransaction(ctx, fn)` instead.
|
|
59
|
+
*/
|
|
60
|
+
declare function flushPending(transport: Pick<EventTransport, 'publish'> | undefined, events: DomainEvent[], logger?: CrmLogger): Promise<void>;
|
|
69
61
|
//#endregion
|
|
70
|
-
//#region src/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
type
|
|
74
|
-
|
|
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
|
|
380
|
-
//#region src/models/tenant-field.d.ts
|
|
381
|
-
type TenantFieldType = 'objectId' | 'string';
|
|
382
|
-
interface SchemaBuildConfig {
|
|
383
|
-
/** Schema type for the tenant column. Engine plumbs this everywhere. */
|
|
384
|
-
tenantFieldType: TenantFieldType;
|
|
62
|
+
//#region src/models/tenant-field.d.ts
|
|
63
|
+
type TenantFieldType = 'objectId' | 'string';
|
|
64
|
+
interface SchemaBuildConfig {
|
|
65
|
+
/** Schema type for the tenant column. Engine plumbs this everywhere. */
|
|
66
|
+
tenantFieldType: TenantFieldType;
|
|
385
67
|
}
|
|
386
68
|
/**
|
|
387
69
|
* Tenant-column schema definition. Use this anywhere a model has
|
|
@@ -392,7 +74,7 @@ declare function tenantFieldDef(config: SchemaBuildConfig): SchemaDefinitionProp
|
|
|
392
74
|
//#region src/models/pipeline.schema.d.ts
|
|
393
75
|
/** Mongoose document shape for a single embedded stage. */
|
|
394
76
|
interface IStageDocument {
|
|
395
|
-
_id:
|
|
77
|
+
_id: _$mongoose.Types.ObjectId;
|
|
396
78
|
name: string;
|
|
397
79
|
/** Ascending order in the pipeline. Treated as identifier on `moveToStage`. */
|
|
398
80
|
sequence: number;
|
|
@@ -403,8 +85,8 @@ interface IStageDocument {
|
|
|
403
85
|
}
|
|
404
86
|
/** Mongoose document shape for a Pipeline. */
|
|
405
87
|
interface IPipelineDocument {
|
|
406
|
-
_id:
|
|
407
|
-
organizationId:
|
|
88
|
+
_id: _$mongoose.Types.ObjectId;
|
|
89
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
408
90
|
name: string;
|
|
409
91
|
/** Deprecates the pipeline — existing opps still move, no new ones created. */
|
|
410
92
|
isArchived: boolean;
|
|
@@ -443,8 +125,8 @@ interface ILeadStatusEntry {
|
|
|
443
125
|
note?: string;
|
|
444
126
|
}
|
|
445
127
|
interface ILeadDocument {
|
|
446
|
-
_id:
|
|
447
|
-
organizationId:
|
|
128
|
+
_id: _$mongoose.Types.ObjectId;
|
|
129
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
448
130
|
fullName: string;
|
|
449
131
|
firstName?: string;
|
|
450
132
|
lastName?: string;
|
|
@@ -459,9 +141,9 @@ interface ILeadDocument {
|
|
|
459
141
|
statusHistory: ILeadStatusEntry[];
|
|
460
142
|
ownerId?: string;
|
|
461
143
|
tags: string[];
|
|
462
|
-
convertedContactId?:
|
|
463
|
-
convertedAccountId?:
|
|
464
|
-
convertedOpportunityId?:
|
|
144
|
+
convertedContactId?: _$mongoose.Types.ObjectId | string;
|
|
145
|
+
convertedAccountId?: _$mongoose.Types.ObjectId | string;
|
|
146
|
+
convertedOpportunityId?: _$mongoose.Types.ObjectId | string;
|
|
465
147
|
convertedAt?: Date;
|
|
466
148
|
disqualifyReason?: string;
|
|
467
149
|
metadata?: Record<string, unknown>;
|
|
@@ -493,12 +175,12 @@ interface IOpportunityStatusEntry {
|
|
|
493
175
|
note?: string;
|
|
494
176
|
}
|
|
495
177
|
interface IOpportunityDocument {
|
|
496
|
-
_id:
|
|
497
|
-
organizationId:
|
|
178
|
+
_id: _$mongoose.Types.ObjectId;
|
|
179
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
498
180
|
name: string;
|
|
499
|
-
accountId?:
|
|
500
|
-
primaryContactId?:
|
|
501
|
-
pipelineId:
|
|
181
|
+
accountId?: _$mongoose.Types.ObjectId | string;
|
|
182
|
+
primaryContactId?: _$mongoose.Types.ObjectId | string;
|
|
183
|
+
pipelineId: _$mongoose.Types.ObjectId | string;
|
|
502
184
|
stageId: string;
|
|
503
185
|
status: OpportunityStatus;
|
|
504
186
|
statusHistory: IOpportunityStatusEntry[];
|
|
@@ -507,9 +189,9 @@ interface IOpportunityDocument {
|
|
|
507
189
|
probability: number;
|
|
508
190
|
expectedCloseAt?: Date;
|
|
509
191
|
closedAt?: Date;
|
|
510
|
-
lostReasonId?:
|
|
192
|
+
lostReasonId?: _$mongoose.Types.ObjectId | string;
|
|
511
193
|
ownerId?: string;
|
|
512
|
-
sourceLeadId?:
|
|
194
|
+
sourceLeadId?: _$mongoose.Types.ObjectId | string;
|
|
513
195
|
tags: string[];
|
|
514
196
|
metadata?: Record<string, unknown>;
|
|
515
197
|
createdAt: Date;
|
|
@@ -538,12 +220,12 @@ interface IContactInfoEmbedded {
|
|
|
538
220
|
instagram?: string;
|
|
539
221
|
}
|
|
540
222
|
interface IContactDocument {
|
|
541
|
-
_id:
|
|
542
|
-
organizationId:
|
|
223
|
+
_id: _$mongoose.Types.ObjectId;
|
|
224
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
543
225
|
name: IContactName;
|
|
544
226
|
contact: IContactInfoEmbedded;
|
|
545
227
|
jobTitle?: string;
|
|
546
|
-
accountId?:
|
|
228
|
+
accountId?: _$mongoose.Types.ObjectId | string;
|
|
547
229
|
ownerId?: string;
|
|
548
230
|
tags: string[];
|
|
549
231
|
metadata?: Record<string, unknown>;
|
|
@@ -555,8 +237,8 @@ declare function createContactModel(connection: Connection, config: SchemaBuildC
|
|
|
555
237
|
//#endregion
|
|
556
238
|
//#region src/models/account.schema.d.ts
|
|
557
239
|
interface IAccountDocument {
|
|
558
|
-
_id:
|
|
559
|
-
organizationId:
|
|
240
|
+
_id: _$mongoose.Types.ObjectId;
|
|
241
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
560
242
|
name: string;
|
|
561
243
|
domain?: string;
|
|
562
244
|
industry?: string;
|
|
@@ -595,8 +277,8 @@ interface ICampaignStatusEntry {
|
|
|
595
277
|
note?: string;
|
|
596
278
|
}
|
|
597
279
|
interface ICampaignDocument {
|
|
598
|
-
_id:
|
|
599
|
-
organizationId:
|
|
280
|
+
_id: _$mongoose.Types.ObjectId;
|
|
281
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
600
282
|
name: string;
|
|
601
283
|
description?: string;
|
|
602
284
|
status: CampaignStatus;
|
|
@@ -646,10 +328,10 @@ interface ISubscriptionStatusEntry {
|
|
|
646
328
|
note?: string;
|
|
647
329
|
}
|
|
648
330
|
interface ISubscriptionDocument {
|
|
649
|
-
_id:
|
|
650
|
-
organizationId:
|
|
651
|
-
contactId:
|
|
652
|
-
campaignId:
|
|
331
|
+
_id: _$mongoose.Types.ObjectId;
|
|
332
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
333
|
+
contactId: _$mongoose.Types.ObjectId | string;
|
|
334
|
+
campaignId: _$mongoose.Types.ObjectId | string;
|
|
653
335
|
status: SubscriptionStatus;
|
|
654
336
|
statusHistory: ISubscriptionStatusEntry[];
|
|
655
337
|
source?: string;
|
|
@@ -672,6 +354,31 @@ interface ISubscriptionDocument {
|
|
|
672
354
|
declare function buildSubscriptionSchema(config: SchemaBuildConfig): Schema<ISubscriptionDocument>;
|
|
673
355
|
declare function createSubscriptionModel(connection: Connection, config: SchemaBuildConfig): Model<ISubscriptionDocument>;
|
|
674
356
|
//#endregion
|
|
357
|
+
//#region src/enums/suppression-reason.d.ts
|
|
358
|
+
/** Reasons derived 1:1 from an email engagement event kind. */
|
|
359
|
+
declare const EVENT_DERIVED_SUPPRESSION_REASONS: readonly ["bounce", "complaint", "unsubscribe"];
|
|
360
|
+
declare const SUPPRESSION_REASONS: readonly ["bounce", "complaint", "unsubscribe", "manual"];
|
|
361
|
+
type SuppressionReason = (typeof SUPPRESSION_REASONS)[number];
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/models/suppression.schema.d.ts
|
|
364
|
+
interface ISuppressionDocument {
|
|
365
|
+
_id: _$mongoose.Types.ObjectId;
|
|
366
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
367
|
+
/** Stored lowercase-normalized (schema `lowercase: true` + repo trims). */
|
|
368
|
+
email: string;
|
|
369
|
+
reason: SuppressionReason;
|
|
370
|
+
/** Free-form origin: 'campaign:<id>', 'sequence:<id>', 'api', 'import', … */
|
|
371
|
+
source?: string;
|
|
372
|
+
/** Optional polymorphic external ref to the suppressed party (rule 7). */
|
|
373
|
+
subjectKind?: string;
|
|
374
|
+
subjectId?: string;
|
|
375
|
+
suppressedAt: Date;
|
|
376
|
+
metadata?: Record<string, unknown>;
|
|
377
|
+
createdAt: Date;
|
|
378
|
+
updatedAt: Date;
|
|
379
|
+
}
|
|
380
|
+
declare function buildSuppressionSchema(config: SchemaBuildConfig): Schema<ISuppressionDocument>;
|
|
381
|
+
//#endregion
|
|
675
382
|
//#region src/enums/activity.d.ts
|
|
676
383
|
/**
|
|
677
384
|
* Activity type vocabulary. The package stores `type` as free-form
|
|
@@ -694,12 +401,12 @@ type SubjectKind = (typeof SUBJECT_KINDS)[number];
|
|
|
694
401
|
//#endregion
|
|
695
402
|
//#region src/models/activity.schema.d.ts
|
|
696
403
|
interface IActivityDocument {
|
|
697
|
-
_id:
|
|
698
|
-
organizationId:
|
|
404
|
+
_id: _$mongoose.Types.ObjectId;
|
|
405
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
699
406
|
type: ActivityType;
|
|
700
407
|
status: ActivityStatus;
|
|
701
408
|
subjectKind: SubjectKind;
|
|
702
|
-
subjectId:
|
|
409
|
+
subjectId: _$mongoose.Types.ObjectId | string;
|
|
703
410
|
title: string;
|
|
704
411
|
description?: string;
|
|
705
412
|
ownerId?: string;
|
|
@@ -716,10 +423,10 @@ declare function createActivityModel(connection: Connection, config: SchemaBuild
|
|
|
716
423
|
//#endregion
|
|
717
424
|
//#region src/models/note.schema.d.ts
|
|
718
425
|
interface INoteDocument {
|
|
719
|
-
_id:
|
|
720
|
-
organizationId:
|
|
426
|
+
_id: _$mongoose.Types.ObjectId;
|
|
427
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
721
428
|
subjectKind: SubjectKind;
|
|
722
|
-
subjectId:
|
|
429
|
+
subjectId: _$mongoose.Types.ObjectId | string;
|
|
723
430
|
body: string;
|
|
724
431
|
authorId?: string;
|
|
725
432
|
pinned: boolean;
|
|
@@ -732,8 +439,8 @@ declare function createNoteModel(connection: Connection, config: SchemaBuildConf
|
|
|
732
439
|
//#endregion
|
|
733
440
|
//#region src/models/loss-reason.schema.d.ts
|
|
734
441
|
interface ILossReasonDocument {
|
|
735
|
-
_id:
|
|
736
|
-
organizationId:
|
|
442
|
+
_id: _$mongoose.Types.ObjectId;
|
|
443
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
737
444
|
name: string;
|
|
738
445
|
description?: string;
|
|
739
446
|
isActive: boolean;
|
|
@@ -775,18 +482,17 @@ declare function createLossReasonModel(connection: Connection, config: SchemaBui
|
|
|
775
482
|
*/
|
|
776
483
|
declare const EMAIL_EVENT_KINDS: readonly ["open", "click", "bounce", "complaint", "unsubscribe"];
|
|
777
484
|
type EmailEventKind = (typeof EMAIL_EVENT_KINDS)[number];
|
|
778
|
-
/** Engagement (positive signal). */
|
|
779
485
|
//#endregion
|
|
780
486
|
//#region src/models/email-event.schema.d.ts
|
|
781
487
|
declare const EMAIL_EVENT_SUBJECT_KINDS: readonly ["contact", "subscription"];
|
|
782
488
|
type EmailEventSubjectKind = (typeof EMAIL_EVENT_SUBJECT_KINDS)[number];
|
|
783
489
|
interface IEmailEventDocument {
|
|
784
|
-
_id:
|
|
785
|
-
organizationId:
|
|
490
|
+
_id: _$mongoose.Types.ObjectId;
|
|
491
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
786
492
|
kind: EmailEventKind;
|
|
787
493
|
subjectKind: EmailEventSubjectKind;
|
|
788
|
-
subjectId:
|
|
789
|
-
campaignId?:
|
|
494
|
+
subjectId: _$mongoose.Types.ObjectId | string;
|
|
495
|
+
campaignId?: _$mongoose.Types.ObjectId | string;
|
|
790
496
|
messageId?: string;
|
|
791
497
|
url?: string;
|
|
792
498
|
userAgent?: string;
|
|
@@ -820,11 +526,11 @@ type MessageDeliveryStatus = (typeof MESSAGE_DELIVERY_STATUSES)[number];
|
|
|
820
526
|
//#endregion
|
|
821
527
|
//#region src/models/conversation.schema.d.ts
|
|
822
528
|
interface IConversationDocument {
|
|
823
|
-
_id:
|
|
824
|
-
organizationId:
|
|
529
|
+
_id: _$mongoose.Types.ObjectId;
|
|
530
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
825
531
|
channel: ConversationChannel;
|
|
826
532
|
participantKind: ConversationParticipantKind;
|
|
827
|
-
participantId:
|
|
533
|
+
participantId: _$mongoose.Types.ObjectId | string;
|
|
828
534
|
/** Channel-side identifier (e.g. WhatsApp wa_id, Telegram chat id). */
|
|
829
535
|
channelUserId?: string;
|
|
830
536
|
status: ConversationStatus;
|
|
@@ -851,9 +557,9 @@ interface IMessageAttachment {
|
|
|
851
557
|
mimeType?: string;
|
|
852
558
|
}
|
|
853
559
|
interface IMessageDocument {
|
|
854
|
-
_id:
|
|
855
|
-
organizationId:
|
|
856
|
-
conversationId:
|
|
560
|
+
_id: _$mongoose.Types.ObjectId;
|
|
561
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
562
|
+
conversationId: _$mongoose.Types.ObjectId | string;
|
|
857
563
|
direction: MessageDirection;
|
|
858
564
|
body: string;
|
|
859
565
|
attachments: IMessageAttachment[];
|
|
@@ -873,6 +579,124 @@ interface IMessageDocument {
|
|
|
873
579
|
declare function buildMessageSchema(config: SchemaBuildConfig): Schema<IMessageDocument>;
|
|
874
580
|
declare function createMessageModel(connection: Connection, config: SchemaBuildConfig): Model<IMessageDocument>;
|
|
875
581
|
//#endregion
|
|
582
|
+
//#region src/enums/sequence-status.d.ts
|
|
583
|
+
/**
|
|
584
|
+
* Email sequence lifecycle.
|
|
585
|
+
*
|
|
586
|
+
* draft — being built; no enrollments can be created
|
|
587
|
+
* active — accepting new enrollments; steps are executing
|
|
588
|
+
* paused — no new enrollments; running enrollments pause at next step
|
|
589
|
+
* archived — soft-hidden; historical data preserved
|
|
590
|
+
*/
|
|
591
|
+
declare const SEQUENCE_STATUSES: readonly ["draft", "active", "paused", "archived"];
|
|
592
|
+
type SequenceStatus = (typeof SEQUENCE_STATUSES)[number];
|
|
593
|
+
declare const SEQUENCE_TRANSITIONS: Record<SequenceStatus, readonly SequenceStatus[]>;
|
|
594
|
+
declare function canTransitionSequence(from: SequenceStatus, to: SequenceStatus): boolean;
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/models/sequence.schema.d.ts
|
|
597
|
+
interface ISendEmailStep {
|
|
598
|
+
id: string;
|
|
599
|
+
type: 'SEND_EMAIL';
|
|
600
|
+
name?: string;
|
|
601
|
+
subject: string;
|
|
602
|
+
htmlBody: string;
|
|
603
|
+
fromName?: string;
|
|
604
|
+
fromEmail?: string;
|
|
605
|
+
}
|
|
606
|
+
interface IDelayStep {
|
|
607
|
+
id: string;
|
|
608
|
+
type: 'DELAY';
|
|
609
|
+
name?: string;
|
|
610
|
+
settings: {
|
|
611
|
+
days?: number;
|
|
612
|
+
hours?: number;
|
|
613
|
+
minutes?: number;
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
type SequenceStep = ISendEmailStep | IDelayStep;
|
|
617
|
+
interface ISequenceStatusEntry {
|
|
618
|
+
status: SequenceStatus;
|
|
619
|
+
occurredAt: Date;
|
|
620
|
+
by?: string;
|
|
621
|
+
note?: string;
|
|
622
|
+
}
|
|
623
|
+
interface ISequenceDocument {
|
|
624
|
+
_id: _$mongoose.Types.ObjectId;
|
|
625
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
626
|
+
name: string;
|
|
627
|
+
description?: string;
|
|
628
|
+
status: SequenceStatus;
|
|
629
|
+
fromName?: string;
|
|
630
|
+
fromEmail?: string;
|
|
631
|
+
/** Ordered list of steps — each step has a unique `id`. */
|
|
632
|
+
steps: SequenceStep[];
|
|
633
|
+
/** Exit enrollment when a reply is detected. Default true. */
|
|
634
|
+
replyDetectionEnabled: boolean;
|
|
635
|
+
tags: string[];
|
|
636
|
+
ownerId?: string;
|
|
637
|
+
metadata?: Record<string, unknown>;
|
|
638
|
+
statusHistory: ISequenceStatusEntry[];
|
|
639
|
+
createdAt: Date;
|
|
640
|
+
updatedAt: Date;
|
|
641
|
+
}
|
|
642
|
+
declare function buildSequenceSchema(config: SchemaBuildConfig): Schema<ISequenceDocument>;
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/enums/enrollment-status.d.ts
|
|
645
|
+
/**
|
|
646
|
+
* Enrollment lifecycle.
|
|
647
|
+
*
|
|
648
|
+
* active — steps are executing (or waiting on a delay)
|
|
649
|
+
* paused — execution halted; can be resumed
|
|
650
|
+
* completed — all steps ran to completion
|
|
651
|
+
* exited — removed early (reply, unsubscribe, bounce, manual)
|
|
652
|
+
*/
|
|
653
|
+
declare const ENROLLMENT_STATUSES: readonly ["active", "paused", "completed", "exited"];
|
|
654
|
+
type EnrollmentStatus = (typeof ENROLLMENT_STATUSES)[number];
|
|
655
|
+
declare const ENROLLMENT_TRANSITIONS: Record<EnrollmentStatus, readonly EnrollmentStatus[]>;
|
|
656
|
+
declare function canTransitionEnrollment(from: EnrollmentStatus, to: EnrollmentStatus): boolean;
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/models/enrollment.schema.d.ts
|
|
659
|
+
type EnrollmentExitReason = 'completed' | 'reply' | 'unsubscribe' | 'bounce' | 'manual';
|
|
660
|
+
type StepResultStatus = 'pending' | 'sent' | 'failed' | 'skipped';
|
|
661
|
+
declare const ENROLLMENT_SUBJECT_KINDS: readonly ["lead", "contact"];
|
|
662
|
+
type EnrollmentSubjectKind = (typeof ENROLLMENT_SUBJECT_KINDS)[number];
|
|
663
|
+
interface IStepResult {
|
|
664
|
+
stepId: string;
|
|
665
|
+
stepType: string;
|
|
666
|
+
status: StepResultStatus;
|
|
667
|
+
sentAt?: Date;
|
|
668
|
+
error?: string;
|
|
669
|
+
}
|
|
670
|
+
interface IEnrollmentStatusEntry {
|
|
671
|
+
status: EnrollmentStatus;
|
|
672
|
+
occurredAt: Date;
|
|
673
|
+
by?: string;
|
|
674
|
+
}
|
|
675
|
+
interface IEnrollmentDocument {
|
|
676
|
+
_id: _$mongoose.Types.ObjectId;
|
|
677
|
+
organizationId: _$mongoose.Types.ObjectId | string;
|
|
678
|
+
sequenceId: _$mongoose.Types.ObjectId | string;
|
|
679
|
+
subjectKind: EnrollmentSubjectKind;
|
|
680
|
+
subjectId: _$mongoose.Types.ObjectId | string;
|
|
681
|
+
status: EnrollmentStatus;
|
|
682
|
+
/** Index into sequence.steps[] — 0-based. */
|
|
683
|
+
currentStepIndex: number;
|
|
684
|
+
stepResults: IStepResult[];
|
|
685
|
+
/** When a DELAY step will expire (informational — streamline owns the actual timer). */
|
|
686
|
+
resumeAt?: Date;
|
|
687
|
+
/** Streamline workflow run ID — used for idempotency checks. */
|
|
688
|
+
workflowRunId?: string;
|
|
689
|
+
exitReason?: EnrollmentExitReason;
|
|
690
|
+
enrolledAt: Date;
|
|
691
|
+
completedAt?: Date;
|
|
692
|
+
ownerId?: string;
|
|
693
|
+
metadata?: Record<string, unknown>;
|
|
694
|
+
statusHistory: IEnrollmentStatusEntry[];
|
|
695
|
+
createdAt: Date;
|
|
696
|
+
updatedAt: Date;
|
|
697
|
+
}
|
|
698
|
+
declare function buildEnrollmentSchema(config: SchemaBuildConfig): Schema<IEnrollmentDocument>;
|
|
699
|
+
//#endregion
|
|
876
700
|
//#region src/models/create-models.d.ts
|
|
877
701
|
interface CrmModels {
|
|
878
702
|
Pipeline: Model<IPipelineDocument>;
|
|
@@ -882,15 +706,18 @@ interface CrmModels {
|
|
|
882
706
|
Account: Model<IAccountDocument>;
|
|
883
707
|
Campaign: Model<ICampaignDocument>;
|
|
884
708
|
Subscription: Model<ISubscriptionDocument>;
|
|
709
|
+
Suppression: Model<ISuppressionDocument>;
|
|
885
710
|
Activity: Model<IActivityDocument>;
|
|
886
711
|
Note: Model<INoteDocument>;
|
|
887
712
|
LossReason: Model<ILossReasonDocument>;
|
|
888
713
|
EmailEvent: Model<IEmailEventDocument>;
|
|
889
714
|
Conversation: Model<IConversationDocument>;
|
|
890
715
|
Message: Model<IMessageDocument>;
|
|
716
|
+
Sequence: Model<ISequenceDocument>;
|
|
717
|
+
Enrollment: Model<IEnrollmentDocument>;
|
|
891
718
|
}
|
|
892
719
|
/** 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"];
|
|
720
|
+
declare const CRM_MODEL_NAMES: readonly ["Pipeline", "Lead", "Opportunity", "Contact", "Account", "Campaign", "EmailSubscription", "Suppression", "Activity", "Note", "LossReason", "EmailEvent", "Conversation", "Message", "Sequence", "Enrollment"];
|
|
894
721
|
interface CreateModelsOptions extends SchemaBuildConfig {
|
|
895
722
|
/**
|
|
896
723
|
* On a model-name collision: `false` (default) throws
|
|
@@ -905,7 +732,7 @@ declare function createCrmModels(connection: Connection, config: CreateModelsOpt
|
|
|
905
732
|
//#endregion
|
|
906
733
|
//#region src/repositories/pipeline.repository.d.ts
|
|
907
734
|
interface PipelineRepositoryDeps {
|
|
908
|
-
events:
|
|
735
|
+
events: CrmEventDispatcher;
|
|
909
736
|
}
|
|
910
737
|
declare class PipelineRepository extends Repository<IPipelineDocument> {
|
|
911
738
|
private readonly events;
|
|
@@ -943,7 +770,7 @@ declare function composeScorers(...rules: readonly LeadScorer[]): LeadScorer;
|
|
|
943
770
|
//#endregion
|
|
944
771
|
//#region src/repositories/lead.repository.d.ts
|
|
945
772
|
interface LeadRepositoryDeps {
|
|
946
|
-
events:
|
|
773
|
+
events: CrmEventDispatcher;
|
|
947
774
|
/** Override the default lead scorer. */
|
|
948
775
|
scorer?: LeadScorer;
|
|
949
776
|
/** Reject `create()` when an email already exists in-tenant (default true). */
|
|
@@ -1005,7 +832,7 @@ declare class LeadRepository extends Repository<ILeadDocument> {
|
|
|
1005
832
|
//#endregion
|
|
1006
833
|
//#region src/repositories/opportunity.repository.d.ts
|
|
1007
834
|
interface OpportunityRepositoryDeps {
|
|
1008
|
-
events:
|
|
835
|
+
events: CrmEventDispatcher;
|
|
1009
836
|
/** Cross-repo reference: read embedded stages from Pipeline. */
|
|
1010
837
|
pipelines: PipelineRepository;
|
|
1011
838
|
}
|
|
@@ -1096,392 +923,1880 @@ declare class OpportunityRepository extends Repository<IOpportunityDocument> {
|
|
|
1096
923
|
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<IOpportunityDocument[]>;
|
|
1097
924
|
}
|
|
1098
925
|
//#endregion
|
|
1099
|
-
//#region src/repositories/contact.repository.d.ts
|
|
1100
|
-
interface ContactRepositoryDeps {
|
|
1101
|
-
events:
|
|
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
|
-
}
|
|
1115
|
-
declare class ContactRepository extends Repository<IContactDocument> {
|
|
1116
|
-
private readonly events;
|
|
1117
|
-
constructor(model: Model<IContactDocument>, plugins: PluginType[], deps: ContactRepositoryDeps, pagination?: PaginationConfig);
|
|
1118
|
-
/**
|
|
1119
|
-
* Create + emit `crm:contact.created`. Hosts call this instead of
|
|
1120
|
-
* `create()` when they want the event side-effect (e.g. webhook fan-out).
|
|
1121
|
-
*/
|
|
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>;
|
|
1146
|
-
}
|
|
926
|
+
//#region src/repositories/contact.repository.d.ts
|
|
927
|
+
interface ContactRepositoryDeps {
|
|
928
|
+
events: CrmEventDispatcher;
|
|
929
|
+
}
|
|
930
|
+
interface MergeContactInput {
|
|
931
|
+
/** Surviving contact id. Receives merged fields. */
|
|
932
|
+
primaryId: string;
|
|
933
|
+
/** Secondary contact id. Deleted after merge. */
|
|
934
|
+
secondaryId: string;
|
|
935
|
+
/**
|
|
936
|
+
* Per-field strategy. Defaults to `'preferPrimary'` — primary's
|
|
937
|
+
* non-empty fields win, secondary fills the gaps. Use `'preferSecondary'`
|
|
938
|
+
* for the reverse. `tags` are always unioned.
|
|
939
|
+
*/
|
|
940
|
+
strategy?: 'preferPrimary' | 'preferSecondary';
|
|
941
|
+
}
|
|
942
|
+
declare class ContactRepository extends Repository<IContactDocument> {
|
|
943
|
+
private readonly events;
|
|
944
|
+
constructor(model: Model<IContactDocument>, plugins: PluginType[], deps: ContactRepositoryDeps, pagination?: PaginationConfig);
|
|
945
|
+
/**
|
|
946
|
+
* Create + emit `crm:contact.created`. Hosts call this instead of
|
|
947
|
+
* `create()` when they want the event side-effect (e.g. webhook fan-out).
|
|
948
|
+
*/
|
|
949
|
+
createContact(input: Partial<IContactDocument>, ctx?: CrmContext): Promise<IContactDocument>;
|
|
950
|
+
/**
|
|
951
|
+
* Merge enrichment payload into the contact. The `patch` is applied
|
|
952
|
+
* verbatim; deep-merge of `contact.*` channels is the caller's job
|
|
953
|
+
* (they own the provider response shape).
|
|
954
|
+
*/
|
|
955
|
+
enrich(id: string, patch: Partial<IContactDocument>, extras?: {
|
|
956
|
+
provider?: string;
|
|
957
|
+
}, ctx?: CrmContext): Promise<IContactDocument>;
|
|
958
|
+
/** Set / re-assign the contact's owner. Atomic; no-op when unchanged. */
|
|
959
|
+
assign(id: string, ownerId: string, ctx?: CrmContext): Promise<IContactDocument>;
|
|
960
|
+
/**
|
|
961
|
+
* Merge two contacts. Secondary's non-conflicting fields are folded
|
|
962
|
+
* into primary, tags are unioned, then secondary is deleted.
|
|
963
|
+
*
|
|
964
|
+
* Hosts wanting transactional safety can pass `ctx.session` —
|
|
965
|
+
* mongokit threads it through `update` + `delete`.
|
|
966
|
+
*
|
|
967
|
+
* Re-pointing related Activities / Notes / Opportunities is the host's
|
|
968
|
+
* job (they own those relationships) — subscribe to
|
|
969
|
+
* `crm:contact.merged` and rewrite `subjectId` / `primaryContactId`
|
|
970
|
+
* from there.
|
|
971
|
+
*/
|
|
972
|
+
merge(input: MergeContactInput, ctx?: CrmContext): Promise<IContactDocument>;
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/repositories/account.repository.d.ts
|
|
976
|
+
interface AccountRepositoryDeps {
|
|
977
|
+
events: CrmEventDispatcher;
|
|
978
|
+
}
|
|
979
|
+
interface MergeAccountInput {
|
|
980
|
+
primaryId: string;
|
|
981
|
+
secondaryId: string;
|
|
982
|
+
strategy?: 'preferPrimary' | 'preferSecondary';
|
|
983
|
+
}
|
|
984
|
+
declare class AccountRepository extends Repository<IAccountDocument> {
|
|
985
|
+
private readonly events;
|
|
986
|
+
constructor(model: Model<IAccountDocument>, plugins: PluginType[], deps: AccountRepositoryDeps, pagination?: PaginationConfig);
|
|
987
|
+
createAccount(input: Partial<IAccountDocument>, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
988
|
+
enrich(id: string, patch: Partial<IAccountDocument>, extras?: {
|
|
989
|
+
provider?: string;
|
|
990
|
+
}, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
991
|
+
assign(id: string, ownerId: string, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
992
|
+
merge(input: MergeAccountInput, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
993
|
+
}
|
|
994
|
+
//#endregion
|
|
995
|
+
//#region src/repositories/campaign.repository.d.ts
|
|
996
|
+
interface CampaignRepositoryDeps {
|
|
997
|
+
events: CrmEventDispatcher;
|
|
998
|
+
/** Reject `createCampaign` on duplicate names per-tenant (default true). */
|
|
999
|
+
rejectDuplicates?: boolean;
|
|
1000
|
+
}
|
|
1001
|
+
type ExtrasWithRevenue = {
|
|
1002
|
+
by?: string;
|
|
1003
|
+
note?: string;
|
|
1004
|
+
actualRevenueAmount?: number;
|
|
1005
|
+
};
|
|
1006
|
+
declare class CampaignRepository extends Repository<ICampaignDocument> {
|
|
1007
|
+
private readonly events;
|
|
1008
|
+
private readonly rejectDuplicates;
|
|
1009
|
+
constructor(model: Model<ICampaignDocument>, plugins: PluginType[], deps: CampaignRepositoryDeps, pagination?: PaginationConfig);
|
|
1010
|
+
createCampaign(input: Partial<ICampaignDocument>, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1011
|
+
activate(id: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1012
|
+
pause(id: string, reason?: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1013
|
+
resume(id: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1014
|
+
complete(id: string, extras?: ExtrasWithRevenue, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1015
|
+
archive(id: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1016
|
+
private _transition;
|
|
1017
|
+
}
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/repositories/subscription.repository.d.ts
|
|
1020
|
+
interface SubscriptionRepositoryDeps {
|
|
1021
|
+
events: CrmEventDispatcher;
|
|
1022
|
+
/** Default DOI policy when `subscribe` doesn't pass `requireDoubleOptIn`. */
|
|
1023
|
+
defaultRequireDoubleOptIn?: boolean;
|
|
1024
|
+
}
|
|
1025
|
+
interface SubscribeInput {
|
|
1026
|
+
contactId: string;
|
|
1027
|
+
campaignId: string;
|
|
1028
|
+
source?: string;
|
|
1029
|
+
consentIpAddress?: string;
|
|
1030
|
+
consentUserAgent?: string;
|
|
1031
|
+
metadata?: Record<string, unknown>;
|
|
1032
|
+
/** Override the engine-level default. */
|
|
1033
|
+
requireDoubleOptIn?: boolean;
|
|
1034
|
+
}
|
|
1035
|
+
declare class SubscriptionRepository extends Repository<ISubscriptionDocument> {
|
|
1036
|
+
private readonly events;
|
|
1037
|
+
private readonly defaultRequireDoubleOptIn;
|
|
1038
|
+
constructor(model: Model<ISubscriptionDocument>, plugins: PluginType[], deps: SubscriptionRepositoryDeps, pagination?: PaginationConfig);
|
|
1039
|
+
subscribe(input: SubscribeInput, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1040
|
+
confirm(token: string, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1041
|
+
unsubscribe(token: string, reason?: string, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1042
|
+
markBounced(id: string, reason?: string, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1043
|
+
markComplained(id: string, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1044
|
+
private _transition;
|
|
1045
|
+
}
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region src/repositories/suppression.repository.d.ts
|
|
1048
|
+
interface SuppressionRepositoryDeps {
|
|
1049
|
+
events: CrmEventDispatcher;
|
|
1050
|
+
}
|
|
1051
|
+
interface SuppressInput {
|
|
1052
|
+
reason: SuppressionReason;
|
|
1053
|
+
/** Free-form origin: 'campaign:<id>', 'sequence:<id>', 'api', 'import', … */
|
|
1054
|
+
source?: string;
|
|
1055
|
+
/** Optional polymorphic external ref to the suppressed party (rule 7). */
|
|
1056
|
+
subjectKind?: string;
|
|
1057
|
+
subjectId?: string;
|
|
1058
|
+
metadata?: Record<string, unknown>;
|
|
1059
|
+
}
|
|
1060
|
+
declare class SuppressionRepository extends Repository<ISuppressionDocument> {
|
|
1061
|
+
private readonly events;
|
|
1062
|
+
constructor(model: Model<ISuppressionDocument>, plugins: PluginType[], deps: SuppressionRepositoryDeps, pagination?: PaginationConfig);
|
|
1063
|
+
/**
|
|
1064
|
+
* Idempotently add `email` to the org's suppression list. Atomic
|
|
1065
|
+
* `getOrCreate` on the unique (org, email) index — of N concurrent
|
|
1066
|
+
* calls exactly one inserts. Emits `crm:suppression.added` only for
|
|
1067
|
+
* the inserting call; an existing row is returned unchanged, no event.
|
|
1068
|
+
*/
|
|
1069
|
+
suppress(email: string, input: SuppressInput, ctx?: CrmContext): Promise<ISuppressionDocument>;
|
|
1070
|
+
/** True when `email` is on the org's suppression list. */
|
|
1071
|
+
isSuppressed(email: string, ctx?: CrmContext): Promise<boolean>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Return the suppressed subset of `emails` (normalized) as a Set —
|
|
1074
|
+
* ONE `$in` query, built for the campaign-fanout hot path:
|
|
1075
|
+
*
|
|
1076
|
+
* ```ts
|
|
1077
|
+
* const blocked = await suppression.filterSuppressed(recipients, ctx);
|
|
1078
|
+
* const sendable = recipients.filter((e) => !blocked.has(e.toLowerCase()));
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
filterSuppressed(emails: string[], ctx?: CrmContext): Promise<Set<string>>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Remove `email` from the org's suppression list. Single atomic
|
|
1084
|
+
* `deleteMany` on the (unique) email key — emits
|
|
1085
|
+
* `crm:suppression.removed` only when a row was actually removed.
|
|
1086
|
+
* Returns whether a row was removed.
|
|
1087
|
+
*/
|
|
1088
|
+
unsuppress(email: string, ctx?: CrmContext): Promise<boolean>;
|
|
1089
|
+
}
|
|
1090
|
+
//#endregion
|
|
1091
|
+
//#region src/repositories/activity.repository.d.ts
|
|
1092
|
+
interface ActivityRepositoryDeps {
|
|
1093
|
+
events: CrmEventDispatcher;
|
|
1094
|
+
}
|
|
1095
|
+
declare class ActivityRepository extends Repository<IActivityDocument> {
|
|
1096
|
+
private readonly events;
|
|
1097
|
+
constructor(model: Model<IActivityDocument>, plugins: PluginType[], deps: ActivityRepositoryDeps, pagination?: PaginationConfig);
|
|
1098
|
+
plan(input: Partial<IActivityDocument>, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1099
|
+
start(id: string, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1100
|
+
complete(id: string, completedAt?: Date, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1101
|
+
cancel(id: string, reason?: string, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Push an activity's `dueDate`. Allowed on planned / in_progress only;
|
|
1104
|
+
* rescheduling a completed or cancelled activity makes no sense.
|
|
1105
|
+
* Emits `crm:activity.rescheduled` with the previous date for audit.
|
|
1106
|
+
*/
|
|
1107
|
+
reschedule(id: string, newDueDate: Date, extras?: {
|
|
1108
|
+
reason?: string;
|
|
1109
|
+
by?: string;
|
|
1110
|
+
}, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1111
|
+
/**
|
|
1112
|
+
* Record the outcome of an activity (call result, email engagement,
|
|
1113
|
+
* meeting confirmation). Stored under `metadata.outcome` so it stays
|
|
1114
|
+
* polymorphic — the shape is the channel's concern, not this package's.
|
|
1115
|
+
*
|
|
1116
|
+
* Does NOT transition status — call `complete()` separately when the
|
|
1117
|
+
* outcome implies completion. This split lets agents log partial
|
|
1118
|
+
* outcomes (e.g. "left voicemail") without forcing terminal state.
|
|
1119
|
+
*/
|
|
1120
|
+
recordOutcome(id: string, outcome: Record<string, unknown>, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
1121
|
+
private _transition;
|
|
1122
|
+
/** Count `planned` activities with `dueDate` before `asOf`. Dashboard KPI. */
|
|
1123
|
+
countOverduePlanned(asOf: Date, ctx?: CrmContext): Promise<number>;
|
|
1124
|
+
/** Latest `limit` activities — lightweight projection for the activity feed. */
|
|
1125
|
+
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<IActivityDocument[]>;
|
|
1126
|
+
}
|
|
1127
|
+
//#endregion
|
|
1128
|
+
//#region src/repositories/note.repository.d.ts
|
|
1129
|
+
interface NoteRepositoryDeps {
|
|
1130
|
+
events: CrmEventDispatcher;
|
|
1131
|
+
}
|
|
1132
|
+
declare class NoteRepository extends Repository<INoteDocument> {
|
|
1133
|
+
private readonly events;
|
|
1134
|
+
constructor(model: Model<INoteDocument>, plugins: PluginType[], deps: NoteRepositoryDeps, pagination?: PaginationConfig);
|
|
1135
|
+
addNote(input: Partial<INoteDocument>, ctx?: CrmContext): Promise<INoteDocument>;
|
|
1136
|
+
}
|
|
1137
|
+
//#endregion
|
|
1138
|
+
//#region src/repositories/loss-reason.repository.d.ts
|
|
1139
|
+
interface LossReasonRepositoryDeps {
|
|
1140
|
+
events: CrmEventDispatcher;
|
|
1141
|
+
}
|
|
1142
|
+
declare class LossReasonRepository extends Repository<ILossReasonDocument> {
|
|
1143
|
+
private readonly events;
|
|
1144
|
+
constructor(model: Model<ILossReasonDocument>, plugins: PluginType[], deps: LossReasonRepositoryDeps, pagination?: PaginationConfig);
|
|
1145
|
+
/** Hide from pickers without breaking historical FKs. */
|
|
1146
|
+
archive(id: string, ctx?: CrmContext): Promise<ILossReasonDocument>;
|
|
1147
|
+
}
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/repositories/email-event.repository.d.ts
|
|
1150
|
+
interface EmailEventRepositoryDeps {
|
|
1151
|
+
events: CrmEventDispatcher;
|
|
1152
|
+
}
|
|
1153
|
+
interface RecordEmailEventInput {
|
|
1154
|
+
subjectKind: EmailEventSubjectKind;
|
|
1155
|
+
subjectId: string;
|
|
1156
|
+
campaignId?: string;
|
|
1157
|
+
messageId?: string;
|
|
1158
|
+
url?: string;
|
|
1159
|
+
userAgent?: string;
|
|
1160
|
+
ip?: string;
|
|
1161
|
+
metadata?: Record<string, unknown>;
|
|
1162
|
+
}
|
|
1163
|
+
declare class EmailEventRepository extends Repository<IEmailEventDocument> {
|
|
1164
|
+
private readonly events;
|
|
1165
|
+
constructor(model: Model<IEmailEventDocument>, plugins: PluginType[], deps: EmailEventRepositoryDeps, pagination?: PaginationConfig);
|
|
1166
|
+
recordOpen(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1167
|
+
recordClick(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1168
|
+
recordBounce(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1169
|
+
recordComplaint(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1170
|
+
recordUnsubscribe(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1171
|
+
private _record;
|
|
1172
|
+
}
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region src/repositories/conversation.repository.d.ts
|
|
1175
|
+
interface ConversationRepositoryDeps {
|
|
1176
|
+
events: CrmEventDispatcher;
|
|
1177
|
+
}
|
|
1178
|
+
interface OpenConversationInput {
|
|
1179
|
+
channel: ConversationChannel;
|
|
1180
|
+
participantKind: ConversationParticipantKind;
|
|
1181
|
+
participantId: string;
|
|
1182
|
+
channelUserId?: string;
|
|
1183
|
+
assigneeId?: string;
|
|
1184
|
+
metadata?: Record<string, unknown>;
|
|
1185
|
+
}
|
|
1186
|
+
declare class ConversationRepository extends Repository<IConversationDocument> {
|
|
1187
|
+
private readonly events;
|
|
1188
|
+
constructor(model: Model<IConversationDocument>, plugins: PluginType[], deps: ConversationRepositoryDeps, pagination?: PaginationConfig);
|
|
1189
|
+
openConversation(input: OpenConversationInput, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1190
|
+
assign(id: string, assigneeId: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1191
|
+
resolve(id: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1192
|
+
reopen(id: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1193
|
+
/** Reset unread badge. Pure UI affordance, no event. */
|
|
1194
|
+
markRead(id: string, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Bump `lastMessageAt` and (for inbound) increment `unreadCount`.
|
|
1197
|
+
* Called by `MessageRepository` when a message is recorded — not part
|
|
1198
|
+
* of the public surface. Returns the conversation for the caller's
|
|
1199
|
+
* follow-up writes.
|
|
1200
|
+
*/
|
|
1201
|
+
touch(id: string, args: {
|
|
1202
|
+
direction: 'inbound' | 'outbound';
|
|
1203
|
+
sentAt: Date;
|
|
1204
|
+
}, ctx?: CrmContext): Promise<IConversationDocument | null>;
|
|
1205
|
+
private _setStatus;
|
|
1206
|
+
}
|
|
1207
|
+
//#endregion
|
|
1208
|
+
//#region src/repositories/message.repository.d.ts
|
|
1209
|
+
interface MessageRepositoryDeps {
|
|
1210
|
+
events: CrmEventDispatcher;
|
|
1211
|
+
conversations: ConversationRepository;
|
|
1212
|
+
}
|
|
1213
|
+
interface RecordMessageInput {
|
|
1214
|
+
conversationId: string;
|
|
1215
|
+
body: string;
|
|
1216
|
+
attachments?: IMessageAttachment[];
|
|
1217
|
+
externalMessageId?: string;
|
|
1218
|
+
senderRef?: string;
|
|
1219
|
+
recipientRef?: string;
|
|
1220
|
+
sentAt?: Date;
|
|
1221
|
+
metadata?: Record<string, unknown>;
|
|
1222
|
+
}
|
|
1223
|
+
declare class MessageRepository extends Repository<IMessageDocument> {
|
|
1224
|
+
private readonly events;
|
|
1225
|
+
private readonly conversations;
|
|
1226
|
+
constructor(model: Model<IMessageDocument>, plugins: PluginType[], deps: MessageRepositoryDeps, pagination?: PaginationConfig);
|
|
1227
|
+
recordInbound(input: RecordMessageInput, ctx?: CrmContext): Promise<IMessageDocument>;
|
|
1228
|
+
recordOutbound(input: RecordMessageInput, ctx?: CrmContext): Promise<IMessageDocument>;
|
|
1229
|
+
/** Wire delivery callback (e.g. WhatsApp `status` webhook). */
|
|
1230
|
+
updateStatus(id: string, status: MessageDeliveryStatus, ctx?: CrmContext): Promise<IMessageDocument>;
|
|
1231
|
+
private _record;
|
|
1232
|
+
/** Latest `limit` messages — lightweight projection for the activity feed. */
|
|
1233
|
+
findRecentForFeed(limit: number, ctx?: CrmContext): Promise<IMessageDocument[]>;
|
|
1234
|
+
}
|
|
1235
|
+
//#endregion
|
|
1236
|
+
//#region src/repositories/sequence.repository.d.ts
|
|
1237
|
+
interface SequenceRepositoryDeps {
|
|
1238
|
+
events: CrmEventDispatcher;
|
|
1239
|
+
}
|
|
1240
|
+
declare class SequenceRepository extends Repository<ISequenceDocument> {
|
|
1241
|
+
private readonly events;
|
|
1242
|
+
constructor(model: Model<ISequenceDocument>, plugins: PluginType[], deps: SequenceRepositoryDeps, pagination?: PaginationConfig);
|
|
1243
|
+
activate(id: string, ctx?: CrmContext): Promise<ISequenceDocument>;
|
|
1244
|
+
activateFromPaused(id: string, ctx?: CrmContext): Promise<ISequenceDocument>;
|
|
1245
|
+
pause(id: string, ctx?: CrmContext): Promise<ISequenceDocument>;
|
|
1246
|
+
archive(id: string, ctx?: CrmContext): Promise<ISequenceDocument>;
|
|
1247
|
+
private _transition;
|
|
1248
|
+
}
|
|
1249
|
+
//#endregion
|
|
1250
|
+
//#region src/repositories/enrollment.repository.d.ts
|
|
1251
|
+
interface EnrollmentRepositoryDeps {
|
|
1252
|
+
events: CrmEventDispatcher;
|
|
1253
|
+
/** Cross-repo reference: read `replyDetectionEnabled` from Sequence. */
|
|
1254
|
+
sequences: SequenceRepository;
|
|
1255
|
+
}
|
|
1256
|
+
/** A subject that just replied — input to `exitActiveOnReply()`. */
|
|
1257
|
+
interface ReplySubject {
|
|
1258
|
+
subjectKind: EnrollmentSubjectKind;
|
|
1259
|
+
subjectId: string;
|
|
1260
|
+
}
|
|
1261
|
+
interface EnrollInput {
|
|
1262
|
+
sequenceId: string;
|
|
1263
|
+
subjectKind: EnrollmentSubjectKind;
|
|
1264
|
+
subjectId: string;
|
|
1265
|
+
workflowRunId?: string;
|
|
1266
|
+
ownerId?: string;
|
|
1267
|
+
metadata?: Record<string, unknown>;
|
|
1268
|
+
}
|
|
1269
|
+
declare class EnrollmentRepository extends Repository<IEnrollmentDocument> {
|
|
1270
|
+
private readonly events;
|
|
1271
|
+
private readonly sequences;
|
|
1272
|
+
constructor(model: Model<IEnrollmentDocument>, plugins: PluginType[], deps: EnrollmentRepositoryDeps, pagination?: PaginationConfig);
|
|
1273
|
+
/** Create a new enrollment — throws AlreadyEnrolledError if an active one exists. */
|
|
1274
|
+
enroll(input: EnrollInput, ctx?: CrmContext): Promise<IEnrollmentDocument>;
|
|
1275
|
+
/** Set workflowRunId after the workflow has started. */
|
|
1276
|
+
setWorkflowRunId(id: string, workflowRunId: string, ctx?: CrmContext): Promise<void>;
|
|
1277
|
+
/** Atomically advance to the next step and record the result (CAS). */
|
|
1278
|
+
advanceStep(id: string, nextStepIndex: number, stepResult: IStepResult | null, ctx?: CrmContext): Promise<IEnrollmentDocument | null>;
|
|
1279
|
+
pause(id: string, ctx?: CrmContext): Promise<IEnrollmentDocument>;
|
|
1280
|
+
resume(id: string, ctx?: CrmContext): Promise<IEnrollmentDocument>;
|
|
1281
|
+
complete(id: string, ctx?: CrmContext): Promise<IEnrollmentDocument>;
|
|
1282
|
+
exit(id: string, exitReason: IEnrollmentDocument['exitReason'], ctx?: CrmContext): Promise<IEnrollmentDocument>;
|
|
1283
|
+
/**
|
|
1284
|
+
* Reply detection: exit every ACTIVE enrollment of the given subjects
|
|
1285
|
+
* with reason `'reply'` — the one method a host's
|
|
1286
|
+
* `crm:message.received` subscriber calls:
|
|
1287
|
+
*
|
|
1288
|
+
* ```ts
|
|
1289
|
+
* crm.events.subscribe('crm:message.received', async (e) => {
|
|
1290
|
+
* await crm.repositories.enrollment.exitActiveOnReply(
|
|
1291
|
+
* [{ subjectKind: 'contact', subjectId: e.payload.participantId }],
|
|
1292
|
+
* { organizationId: e.meta.organizationId },
|
|
1293
|
+
* );
|
|
1294
|
+
* });
|
|
1295
|
+
* ```
|
|
1296
|
+
*
|
|
1297
|
+
* Sequences are batch-loaded in ONE `$in` query; enrollments whose
|
|
1298
|
+
* sequence has `replyDetectionEnabled === false` are skipped (a missing
|
|
1299
|
+
* sequence — e.g. deleted — does NOT skip: the default is to exit).
|
|
1300
|
+
* Each exit goes through `exit()` (state-machine CAS + statusHistory +
|
|
1301
|
+
* ENROLLMENT_EXITED event). An enrollment that a concurrent transition
|
|
1302
|
+
* already moved out of `active` loses the CAS and is skipped — the
|
|
1303
|
+
* desired end state ("not active") already holds.
|
|
1304
|
+
*
|
|
1305
|
+
* Returns the enrollments this call actually exited.
|
|
1306
|
+
*/
|
|
1307
|
+
exitActiveOnReply(subjects: ReplySubject[], ctx?: CrmContext): Promise<IEnrollmentDocument[]>;
|
|
1308
|
+
private _transition;
|
|
1309
|
+
}
|
|
1310
|
+
//#endregion
|
|
1311
|
+
//#region src/engine/engine-types.d.ts
|
|
1312
|
+
interface CrmLogger {
|
|
1313
|
+
info?(msg: string, meta?: Record<string, unknown>): void;
|
|
1314
|
+
warn?(msg: string, meta?: Record<string, unknown>): void;
|
|
1315
|
+
error?(msg: string, meta?: Record<string, unknown>): void;
|
|
1316
|
+
debug?(msg: string, meta?: Record<string, unknown>): void;
|
|
1317
|
+
}
|
|
1318
|
+
interface CrmConfig {
|
|
1319
|
+
/** Mongoose connection — package creates models on this connection. */
|
|
1320
|
+
connection: Connection;
|
|
1321
|
+
/**
|
|
1322
|
+
* Tenant column shape. `'objectId'` (default) matches Better Auth orgs
|
|
1323
|
+
* and unlocks `$lookup` / `.populate()`; `'string'` matches UUID hosts.
|
|
1324
|
+
* Threaded into both schemas and `multiTenantPlugin` so they stay in
|
|
1325
|
+
* sync (PACKAGE_RULES §9.2).
|
|
1326
|
+
*/
|
|
1327
|
+
tenantFieldType?: TenantFieldType;
|
|
1328
|
+
/**
|
|
1329
|
+
* When `true` (default), wire `multiTenantPlugin` on every repository
|
|
1330
|
+
* with `required: true`. Set `false` only for fixtures / smoke tests
|
|
1331
|
+
* that intentionally drop the scope.
|
|
1332
|
+
*/
|
|
1333
|
+
multiTenant?: boolean;
|
|
1334
|
+
/** Arc-compatible event transport. Default: in-process bus. */
|
|
1335
|
+
eventTransport?: EventTransport;
|
|
1336
|
+
/**
|
|
1337
|
+
* Transactional outbox (PACKAGE_RULES §P8). When wired, every domain
|
|
1338
|
+
* event is persisted via `outbox.save(event, { session })` in the SAME
|
|
1339
|
+
* session as the business write — the host's relay publishes committed
|
|
1340
|
+
* rows. Without it, events publish post-write (or defer to a
|
|
1341
|
+
* `ctx[PENDING_EVENTS]` queue inside `engine.withTransaction`).
|
|
1342
|
+
*/
|
|
1343
|
+
outbox?: OutboxStore;
|
|
1344
|
+
/** Logger surface used by the in-process bus + repositories. */
|
|
1345
|
+
logger?: CrmLogger;
|
|
1346
|
+
/** Pagination defaults for every repository (mongokit). */
|
|
1347
|
+
pagination?: PaginationConfig;
|
|
1348
|
+
/** Extra mongokit plugins applied to every repository (after defaults). */
|
|
1349
|
+
plugins?: PluginType[];
|
|
1350
|
+
/**
|
|
1351
|
+
* On a Mongoose model-name collision (another engine / hot reload owns
|
|
1352
|
+
* the name): `false` (default) throws `CrmModelCollisionError`; `true`
|
|
1353
|
+
* deletes + re-registers. Test fixtures / hot reload only (§21).
|
|
1354
|
+
*/
|
|
1355
|
+
forceRecreate?: boolean;
|
|
1356
|
+
/**
|
|
1357
|
+
* Mongoose auto-index builds. Default `true` (dev). Set `false` in
|
|
1358
|
+
* production and run `engine.syncIndexes()` from a deploy script so
|
|
1359
|
+
* cold-boot index builds don't blow Fastify's plugin timeout (§35).
|
|
1360
|
+
*/
|
|
1361
|
+
autoIndex?: boolean;
|
|
1362
|
+
/**
|
|
1363
|
+
* Skip the boot-time `transactions` capability requirement, downgrading
|
|
1364
|
+
* it to a warning. Set only when the host never calls
|
|
1365
|
+
* `LeadService.convert()` inside a transaction (standalone Mongo).
|
|
1366
|
+
*/
|
|
1367
|
+
allowNonTransactional?: boolean;
|
|
1368
|
+
}
|
|
1369
|
+
interface ResolvedCrmConfig extends SchemaBuildConfig {
|
|
1370
|
+
connection: Connection;
|
|
1371
|
+
tenantFieldType: TenantFieldType;
|
|
1372
|
+
multiTenant: boolean;
|
|
1373
|
+
forceRecreate: boolean;
|
|
1374
|
+
autoIndex: boolean;
|
|
1375
|
+
logger?: CrmLogger;
|
|
1376
|
+
pagination?: PaginationConfig;
|
|
1377
|
+
plugins: PluginType[];
|
|
1378
|
+
}
|
|
1379
|
+
interface CrmRepositories {
|
|
1380
|
+
pipeline: PipelineRepository;
|
|
1381
|
+
lead: LeadRepository;
|
|
1382
|
+
opportunity: OpportunityRepository;
|
|
1383
|
+
contact: ContactRepository;
|
|
1384
|
+
account: AccountRepository;
|
|
1385
|
+
campaign: CampaignRepository;
|
|
1386
|
+
subscription: SubscriptionRepository;
|
|
1387
|
+
suppression: SuppressionRepository;
|
|
1388
|
+
activity: ActivityRepository;
|
|
1389
|
+
note: NoteRepository;
|
|
1390
|
+
lossReason: LossReasonRepository;
|
|
1391
|
+
emailEvent: EmailEventRepository;
|
|
1392
|
+
conversation: ConversationRepository;
|
|
1393
|
+
message: MessageRepository;
|
|
1394
|
+
sequence: SequenceRepository;
|
|
1395
|
+
enrollment: EnrollmentRepository;
|
|
1396
|
+
}
|
|
1397
|
+
interface CrmEngine {
|
|
1398
|
+
/** Repositories ARE the API surface (PACKAGE_RULES §1). */
|
|
1399
|
+
readonly repositories: Readonly<CrmRepositories>;
|
|
1400
|
+
/**
|
|
1401
|
+
* Arc-compatible event transport (a `CrmEventDispatcher` wrapping the
|
|
1402
|
+
* configured transport — `publish`/`subscribe` behave exactly like the
|
|
1403
|
+
* raw transport for hosts).
|
|
1404
|
+
*/
|
|
1405
|
+
readonly events: CrmEventDispatcher;
|
|
1406
|
+
/** Mongoose models — for arc adapter wiring. */
|
|
1407
|
+
readonly models: Readonly<CrmModels>;
|
|
1408
|
+
/** Resolved configuration (frozen). */
|
|
1409
|
+
readonly config: Readonly<ResolvedCrmConfig>;
|
|
1410
|
+
/**
|
|
1411
|
+
* Run `body` inside a MongoDB transaction with post-commit event
|
|
1412
|
+
* discipline (PACKAGE_RULES §P8.1): events dispatched through `txCtx`
|
|
1413
|
+
* are queued and flushed to the transport only AFTER commit — an abort
|
|
1414
|
+
* leaks nothing to in-process subscribers. When `ctx.session` is already
|
|
1415
|
+
* set, the caller's transaction (and queue, if attached) is reused.
|
|
1416
|
+
*
|
|
1417
|
+
* ```ts
|
|
1418
|
+
* await engine.withTransaction(ctx, async (txCtx) => {
|
|
1419
|
+
* return leadService.convert(leadId, input, txCtx);
|
|
1420
|
+
* });
|
|
1421
|
+
* ```
|
|
1422
|
+
*/
|
|
1423
|
+
withTransaction<T>(ctx: CrmContext, body: (txCtx: CrmContext) => Promise<T>): Promise<T>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Build/align every model's indexes against its schema. Call once per
|
|
1426
|
+
* deploy when booted with `autoIndex: false` (§35). Idempotent.
|
|
1427
|
+
*/
|
|
1428
|
+
syncIndexes(): Promise<void>;
|
|
1429
|
+
/** Release resources. Safe to call multiple times. */
|
|
1430
|
+
dispose(): Promise<void>;
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Operation context threaded through every domain verb. Extends
|
|
1434
|
+
* primitives' `OperationContext` and narrows `IdLike` to types Mongoose
|
|
1435
|
+
* stores cleanly. Host-specific extras go through the inherited
|
|
1436
|
+
* `metadata?` field — keep the typed surface tight.
|
|
1437
|
+
*/
|
|
1438
|
+
interface CrmContext extends OperationContext {
|
|
1439
|
+
organizationId?: string | _$mongoose.Types.ObjectId;
|
|
1440
|
+
actorId?: string | _$mongoose.Types.ObjectId;
|
|
1441
|
+
/** Mongo transaction session (passed through to mongokit). */
|
|
1442
|
+
session?: unknown;
|
|
1443
|
+
}
|
|
1444
|
+
type _ModelTypes = Model<unknown>;
|
|
1445
|
+
//#endregion
|
|
1446
|
+
//#region src/engine/create-crm.d.ts
|
|
1447
|
+
declare function createCrm(config: CrmConfig): Promise<CrmEngine>;
|
|
1448
|
+
//#endregion
|
|
1449
|
+
//#region src/repositories/create-repositories.d.ts
|
|
1450
|
+
interface CreateCrmRepositoriesDeps {
|
|
1451
|
+
events: CrmEventDispatcher;
|
|
1452
|
+
config: ResolvedCrmConfig;
|
|
1453
|
+
}
|
|
1454
|
+
declare function createCrmRepositories(models: CrmModels, deps: CreateCrmRepositoriesDeps): CrmRepositories;
|
|
1455
|
+
//#endregion
|
|
1456
|
+
//#region src/services/lead.service.d.ts
|
|
1457
|
+
interface ConvertLeadInput {
|
|
1458
|
+
pipelineId: string;
|
|
1459
|
+
/** Defaults to `<companyName> — <source>` / `<fullName> — New`. */
|
|
1460
|
+
opportunityName?: string;
|
|
1461
|
+
/** Stored flat on the opportunity (`amount` + `currency`). */
|
|
1462
|
+
amount?: number;
|
|
1463
|
+
currency?: string;
|
|
1464
|
+
expectedCloseAt?: Date;
|
|
1465
|
+
by?: string;
|
|
1466
|
+
}
|
|
1467
|
+
interface ConvertResult {
|
|
1468
|
+
lead: ILeadDocument;
|
|
1469
|
+
contact: IContactDocument;
|
|
1470
|
+
account?: IAccountDocument;
|
|
1471
|
+
opportunity: IOpportunityDocument;
|
|
1472
|
+
/** Convenience string id — same as `String(contact._id)`. */
|
|
1473
|
+
contactId: string;
|
|
1474
|
+
/** Convenience string id — present only when an account was created. */
|
|
1475
|
+
accountId?: string;
|
|
1476
|
+
/** Convenience string id — same as `String(opportunity._id)`. */
|
|
1477
|
+
opportunityId: string;
|
|
1478
|
+
}
|
|
1479
|
+
interface LeadServiceDeps {
|
|
1480
|
+
lead: LeadRepository;
|
|
1481
|
+
contact: ContactRepository;
|
|
1482
|
+
account: AccountRepository;
|
|
1483
|
+
opportunity: OpportunityRepository;
|
|
1484
|
+
events: CrmEventDispatcher;
|
|
1485
|
+
}
|
|
1486
|
+
declare class LeadService {
|
|
1487
|
+
private readonly leads;
|
|
1488
|
+
private readonly contacts;
|
|
1489
|
+
private readonly accounts;
|
|
1490
|
+
private readonly opportunities;
|
|
1491
|
+
private readonly events;
|
|
1492
|
+
constructor(deps: LeadServiceDeps);
|
|
1493
|
+
/**
|
|
1494
|
+
* Construct from an already-built CrmEngine — the host's preferred path.
|
|
1495
|
+
* Avoids manually wiring four repositories.
|
|
1496
|
+
*/
|
|
1497
|
+
static fromEngine(engine: CrmEngine): LeadService;
|
|
1498
|
+
/**
|
|
1499
|
+
* Convert a Lead into Account + Contact + Opportunity, then transition
|
|
1500
|
+
* the lead. Wrap the call in `connection.transaction()` and pass the
|
|
1501
|
+
* session via `ctx.session` for atomicity — all four writes commit or
|
|
1502
|
+
* roll back together.
|
|
1503
|
+
*
|
|
1504
|
+
* Best-effort compensation: if a downstream write fails, already-
|
|
1505
|
+
* created docs are deleted in reverse order. The reverse delete may
|
|
1506
|
+
* itself fail (e.g. transient DB issues) — when transactions are
|
|
1507
|
+
* active, prefer that path; compensation is the no-transaction
|
|
1508
|
+
* fallback.
|
|
1509
|
+
*/
|
|
1510
|
+
convert(leadId: string, input: ConvertLeadInput, ctx?: CrmContext): Promise<ConvertResult>;
|
|
1511
|
+
/**
|
|
1512
|
+
* The state-machine hop from whichever status the lead is in to
|
|
1513
|
+
* `converted`. We do this directly (instead of calling
|
|
1514
|
+
* `LeadRepository.qualify` first then a hypothetical `complete`)
|
|
1515
|
+
* because the conversion is "this lead is done" regardless of where
|
|
1516
|
+
* it started — bypassing the `qualified` waypoint is intentional when
|
|
1517
|
+
* a Lead is converted directly from `new` (importers, webhooks).
|
|
1518
|
+
*/
|
|
1519
|
+
private _markConverted;
|
|
1520
|
+
}
|
|
1521
|
+
//#endregion
|
|
1522
|
+
//#region src/events/event-constants.d.ts
|
|
1523
|
+
/** PACKAGE_RULES rule 12: `package:resource.verb`. */
|
|
1524
|
+
declare const CRM_EVENTS: {
|
|
1525
|
+
readonly LEAD_CREATED: "crm:lead.created";
|
|
1526
|
+
readonly LEAD_STATUS_CHANGED: "crm:lead.status_changed";
|
|
1527
|
+
readonly LEAD_SCORED: "crm:lead.scored";
|
|
1528
|
+
readonly LEAD_CONVERTED: "crm:lead.converted";
|
|
1529
|
+
readonly LEAD_DISQUALIFIED: "crm:lead.disqualified";
|
|
1530
|
+
readonly ACCOUNT_CREATED: "crm:account.created";
|
|
1531
|
+
readonly ACCOUNT_UPDATED: "crm:account.updated";
|
|
1532
|
+
readonly CONTACT_CREATED: "crm:contact.created";
|
|
1533
|
+
readonly CONTACT_UPDATED: "crm:contact.updated";
|
|
1534
|
+
readonly OPPORTUNITY_CREATED: "crm:opportunity.created";
|
|
1535
|
+
readonly OPPORTUNITY_STAGE_ADVANCED: "crm:opportunity.stage_advanced";
|
|
1536
|
+
readonly OPPORTUNITY_STAGE_REGRESSED: "crm:opportunity.stage_regressed";
|
|
1537
|
+
readonly OPPORTUNITY_WON: "crm:opportunity.won";
|
|
1538
|
+
readonly OPPORTUNITY_LOST: "crm:opportunity.lost";
|
|
1539
|
+
readonly OPPORTUNITY_ABANDONED: "crm:opportunity.abandoned";
|
|
1540
|
+
readonly PIPELINE_CREATED: "crm:pipeline.created";
|
|
1541
|
+
readonly PIPELINE_ARCHIVED: "crm:pipeline.archived";
|
|
1542
|
+
readonly ACTIVITY_PLANNED: "crm:activity.planned";
|
|
1543
|
+
readonly ACTIVITY_COMPLETED: "crm:activity.completed";
|
|
1544
|
+
readonly ACTIVITY_CANCELLED: "crm:activity.cancelled";
|
|
1545
|
+
readonly NOTE_ADDED: "crm:note.added";
|
|
1546
|
+
readonly CAMPAIGN_CREATED: "crm:campaign.created";
|
|
1547
|
+
readonly CAMPAIGN_ACTIVATED: "crm:campaign.activated";
|
|
1548
|
+
readonly CAMPAIGN_PAUSED: "crm:campaign.paused";
|
|
1549
|
+
readonly CAMPAIGN_RESUMED: "crm:campaign.resumed";
|
|
1550
|
+
readonly CAMPAIGN_COMPLETED: "crm:campaign.completed";
|
|
1551
|
+
readonly CAMPAIGN_ARCHIVED: "crm:campaign.archived";
|
|
1552
|
+
readonly SUBSCRIPTION_CREATED: "crm:subscription.created";
|
|
1553
|
+
readonly SUBSCRIPTION_CONFIRMED: "crm:subscription.confirmed";
|
|
1554
|
+
readonly SUBSCRIPTION_UNSUBSCRIBED: "crm:subscription.unsubscribed";
|
|
1555
|
+
readonly SUBSCRIPTION_BOUNCED: "crm:subscription.bounced";
|
|
1556
|
+
readonly SUBSCRIPTION_COMPLAINED: "crm:subscription.complained";
|
|
1557
|
+
readonly SEQUENCE_CREATED: "crm:sequence.created";
|
|
1558
|
+
readonly SEQUENCE_ACTIVATED: "crm:sequence.active";
|
|
1559
|
+
readonly SEQUENCE_PAUSED: "crm:sequence.paused";
|
|
1560
|
+
readonly SEQUENCE_ARCHIVED: "crm:sequence.archived";
|
|
1561
|
+
readonly ENROLLMENT_CREATED: "crm:enrollment.created";
|
|
1562
|
+
readonly ENROLLMENT_STEP_SENT: "crm:enrollment.step_sent";
|
|
1563
|
+
readonly ENROLLMENT_PAUSED: "crm:enrollment.paused";
|
|
1564
|
+
readonly ENROLLMENT_RESUMED: "crm:enrollment.resumed";
|
|
1565
|
+
readonly ENROLLMENT_COMPLETED: "crm:enrollment.completed";
|
|
1566
|
+
readonly ENROLLMENT_EXITED: "crm:enrollment.exited";
|
|
1567
|
+
readonly EMAIL_EVENT_OPENED: "crm:email_event.opened";
|
|
1568
|
+
readonly EMAIL_EVENT_CLICKED: "crm:email_event.clicked";
|
|
1569
|
+
readonly EMAIL_EVENT_BOUNCED: "crm:email_event.bounced";
|
|
1570
|
+
readonly EMAIL_EVENT_COMPLAINED: "crm:email_event.complained";
|
|
1571
|
+
readonly EMAIL_EVENT_UNSUBSCRIBED: "crm:email_event.unsubscribed";
|
|
1572
|
+
readonly LEAD_ENRICHED: "crm:lead.enriched";
|
|
1573
|
+
readonly LEAD_ASSIGNED: "crm:lead.assigned";
|
|
1574
|
+
readonly CONTACT_ENRICHED: "crm:contact.enriched";
|
|
1575
|
+
readonly CONTACT_ASSIGNED: "crm:contact.assigned";
|
|
1576
|
+
readonly CONTACT_MERGED: "crm:contact.merged";
|
|
1577
|
+
readonly ACCOUNT_ENRICHED: "crm:account.enriched";
|
|
1578
|
+
readonly ACCOUNT_ASSIGNED: "crm:account.assigned";
|
|
1579
|
+
readonly ACCOUNT_MERGED: "crm:account.merged";
|
|
1580
|
+
readonly OPPORTUNITY_ASSIGNED: "crm:opportunity.assigned";
|
|
1581
|
+
readonly OPPORTUNITY_AMOUNT_CHANGED: "crm:opportunity.amount_changed";
|
|
1582
|
+
readonly OPPORTUNITY_EXTENDED: "crm:opportunity.extended";
|
|
1583
|
+
readonly ACTIVITY_RESCHEDULED: "crm:activity.rescheduled";
|
|
1584
|
+
readonly ACTIVITY_OUTCOME_RECORDED: "crm:activity.outcome_recorded";
|
|
1585
|
+
readonly SUPPRESSION_ADDED: "crm:suppression.added";
|
|
1586
|
+
readonly SUPPRESSION_REMOVED: "crm:suppression.removed";
|
|
1587
|
+
readonly CONVERSATION_CREATED: "crm:conversation.created";
|
|
1588
|
+
readonly CONVERSATION_ASSIGNED: "crm:conversation.assigned";
|
|
1589
|
+
readonly CONVERSATION_RESOLVED: "crm:conversation.resolved";
|
|
1590
|
+
readonly CONVERSATION_REOPENED: "crm:conversation.reopened";
|
|
1591
|
+
readonly MESSAGE_RECEIVED: "crm:message.received";
|
|
1592
|
+
readonly MESSAGE_SENT: "crm:message.sent";
|
|
1593
|
+
};
|
|
1594
|
+
type CrmEventName = (typeof CRM_EVENTS)[keyof typeof CRM_EVENTS];
|
|
1595
|
+
//#endregion
|
|
1596
|
+
//#region src/events/event-catalog.d.ts
|
|
1597
|
+
/** JSON-Schema object produced by `z.toJSONSchema` — what arc's registry consumes. */
|
|
1598
|
+
type CrmEventSchema = Record<string, unknown>;
|
|
1599
|
+
/** Structurally identical to arc's `EventDefinitionOutput` — do NOT import arc. */
|
|
1600
|
+
interface CrmEventDefinition<TSchema extends z.ZodType = z.ZodType> {
|
|
1601
|
+
name: CrmEventName;
|
|
1602
|
+
version: number;
|
|
1603
|
+
description: string;
|
|
1604
|
+
zodSchema: TSchema;
|
|
1605
|
+
schema: CrmEventSchema;
|
|
1606
|
+
create(payload: z.infer<TSchema>, meta?: Partial<EventMeta>): DomainEvent<z.infer<TSchema>>;
|
|
1607
|
+
}
|
|
1608
|
+
declare const LeadCreated: CrmEventDefinition<z.ZodObject<{
|
|
1609
|
+
leadId: z.ZodString;
|
|
1610
|
+
email: z.ZodOptional<z.ZodString>;
|
|
1611
|
+
score: z.ZodNumber;
|
|
1612
|
+
}, z.core.$strip>>;
|
|
1613
|
+
declare const LeadStatusChanged: CrmEventDefinition<z.ZodObject<{
|
|
1614
|
+
leadId: z.ZodString;
|
|
1615
|
+
from: z.ZodString;
|
|
1616
|
+
to: z.ZodString;
|
|
1617
|
+
}, z.core.$strip>>;
|
|
1618
|
+
declare const LeadScored: CrmEventDefinition<z.ZodObject<{
|
|
1619
|
+
leadId: z.ZodString;
|
|
1620
|
+
score: z.ZodNumber;
|
|
1621
|
+
}, z.core.$strip>>;
|
|
1622
|
+
declare const LeadConverted: CrmEventDefinition<z.ZodObject<{
|
|
1623
|
+
leadId: z.ZodString;
|
|
1624
|
+
contactId: z.ZodString;
|
|
1625
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
1626
|
+
opportunityId: z.ZodString;
|
|
1627
|
+
}, z.core.$strip>>;
|
|
1628
|
+
declare const LeadDisqualified: CrmEventDefinition<z.ZodObject<{
|
|
1629
|
+
leadId: z.ZodString;
|
|
1630
|
+
reason: z.ZodString;
|
|
1631
|
+
}, z.core.$strip>>;
|
|
1632
|
+
declare const LeadEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1633
|
+
leadId: z.ZodString;
|
|
1634
|
+
fields: z.ZodArray<z.ZodString>;
|
|
1635
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1636
|
+
}, z.core.$strip>>;
|
|
1637
|
+
declare const LeadAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1638
|
+
leadId: z.ZodString;
|
|
1639
|
+
ownerId: z.ZodString;
|
|
1640
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1641
|
+
}, z.core.$strip>>;
|
|
1642
|
+
declare const AccountCreated: CrmEventDefinition<z.ZodObject<{
|
|
1643
|
+
accountId: z.ZodString;
|
|
1644
|
+
name: z.ZodString;
|
|
1645
|
+
}, z.core.$strip>>;
|
|
1646
|
+
declare const AccountUpdated: CrmEventDefinition<z.ZodObject<{
|
|
1647
|
+
accountId: z.ZodString;
|
|
1648
|
+
}, z.core.$strip>>;
|
|
1649
|
+
declare const AccountEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1650
|
+
accountId: z.ZodString;
|
|
1651
|
+
fields: z.ZodArray<z.ZodString>;
|
|
1652
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1653
|
+
}, z.core.$strip>>;
|
|
1654
|
+
declare const AccountAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1655
|
+
accountId: z.ZodString;
|
|
1656
|
+
ownerId: z.ZodString;
|
|
1657
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1658
|
+
}, z.core.$strip>>;
|
|
1659
|
+
declare const AccountMerged: CrmEventDefinition<z.ZodObject<{
|
|
1660
|
+
primaryId: z.ZodString;
|
|
1661
|
+
secondaryId: z.ZodString;
|
|
1662
|
+
strategy: z.ZodEnum<{
|
|
1663
|
+
preferPrimary: "preferPrimary";
|
|
1664
|
+
preferSecondary: "preferSecondary";
|
|
1665
|
+
}>;
|
|
1666
|
+
}, z.core.$strip>>;
|
|
1667
|
+
declare const ContactCreated: CrmEventDefinition<z.ZodObject<{
|
|
1668
|
+
contactId: z.ZodString;
|
|
1669
|
+
email: z.ZodOptional<z.ZodString>;
|
|
1670
|
+
}, z.core.$strip>>;
|
|
1671
|
+
declare const ContactUpdated: CrmEventDefinition<z.ZodObject<{
|
|
1672
|
+
contactId: z.ZodString;
|
|
1673
|
+
}, z.core.$strip>>;
|
|
1674
|
+
declare const ContactEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1675
|
+
contactId: z.ZodString;
|
|
1676
|
+
fields: z.ZodArray<z.ZodString>;
|
|
1677
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1678
|
+
}, z.core.$strip>>;
|
|
1679
|
+
declare const ContactAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1680
|
+
contactId: z.ZodString;
|
|
1681
|
+
ownerId: z.ZodString;
|
|
1682
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1683
|
+
}, z.core.$strip>>;
|
|
1684
|
+
declare const ContactMerged: CrmEventDefinition<z.ZodObject<{
|
|
1685
|
+
primaryId: z.ZodString;
|
|
1686
|
+
secondaryId: z.ZodString;
|
|
1687
|
+
strategy: z.ZodEnum<{
|
|
1688
|
+
preferPrimary: "preferPrimary";
|
|
1689
|
+
preferSecondary: "preferSecondary";
|
|
1690
|
+
}>;
|
|
1691
|
+
}, z.core.$strip>>;
|
|
1692
|
+
declare const OpportunityCreated: CrmEventDefinition<z.ZodObject<{
|
|
1693
|
+
opportunityId: z.ZodString;
|
|
1694
|
+
pipelineId: z.ZodString;
|
|
1695
|
+
stageId: z.ZodString;
|
|
1696
|
+
}, z.core.$strip>>;
|
|
1697
|
+
declare const OpportunityStageAdvanced: CrmEventDefinition<z.ZodObject<{
|
|
1698
|
+
opportunityId: z.ZodString;
|
|
1699
|
+
from: z.ZodObject<{
|
|
1700
|
+
stageId: z.ZodString;
|
|
1701
|
+
sequence: z.ZodNumber;
|
|
1702
|
+
}, z.core.$strip>;
|
|
1703
|
+
to: z.ZodObject<{
|
|
1704
|
+
stageId: z.ZodString;
|
|
1705
|
+
sequence: z.ZodNumber;
|
|
1706
|
+
}, z.core.$strip>;
|
|
1707
|
+
}, z.core.$strip>>;
|
|
1708
|
+
declare const OpportunityStageRegressed: CrmEventDefinition<z.ZodObject<{
|
|
1709
|
+
opportunityId: z.ZodString;
|
|
1710
|
+
from: z.ZodObject<{
|
|
1711
|
+
stageId: z.ZodString;
|
|
1712
|
+
sequence: z.ZodNumber;
|
|
1713
|
+
}, z.core.$strip>;
|
|
1714
|
+
to: z.ZodObject<{
|
|
1715
|
+
stageId: z.ZodString;
|
|
1716
|
+
sequence: z.ZodNumber;
|
|
1717
|
+
}, z.core.$strip>;
|
|
1718
|
+
}, z.core.$strip>>;
|
|
1719
|
+
declare const OpportunityWon: CrmEventDefinition<z.ZodObject<{
|
|
1720
|
+
opportunityId: z.ZodString;
|
|
1721
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
1722
|
+
}, z.core.$strip>>;
|
|
1723
|
+
declare const OpportunityLost: CrmEventDefinition<z.ZodObject<{
|
|
1724
|
+
opportunityId: z.ZodString;
|
|
1725
|
+
lostReasonId: z.ZodOptional<z.ZodString>;
|
|
1726
|
+
}, z.core.$strip>>;
|
|
1727
|
+
declare const OpportunityAbandoned: CrmEventDefinition<z.ZodObject<{
|
|
1728
|
+
opportunityId: z.ZodString;
|
|
1729
|
+
}, z.core.$strip>>;
|
|
1730
|
+
declare const OpportunityAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1731
|
+
opportunityId: z.ZodString;
|
|
1732
|
+
ownerId: z.ZodString;
|
|
1733
|
+
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1734
|
+
}, z.core.$strip>>;
|
|
1735
|
+
declare const OpportunityAmountChanged: CrmEventDefinition<z.ZodObject<{
|
|
1736
|
+
opportunityId: z.ZodString;
|
|
1737
|
+
amount: z.ZodNumber;
|
|
1738
|
+
previousAmount: z.ZodOptional<z.ZodNumber>;
|
|
1739
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1740
|
+
by: z.ZodOptional<z.ZodString>;
|
|
1741
|
+
}, z.core.$strip>>;
|
|
1742
|
+
declare const OpportunityExtended: CrmEventDefinition<z.ZodObject<{
|
|
1743
|
+
opportunityId: z.ZodString;
|
|
1744
|
+
expectedCloseAt: z.ZodISODateTime;
|
|
1745
|
+
previousExpectedCloseAt: z.ZodOptional<z.ZodISODateTime>;
|
|
1746
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1747
|
+
by: z.ZodOptional<z.ZodString>;
|
|
1748
|
+
}, z.core.$strip>>;
|
|
1749
|
+
declare const PipelineCreated: CrmEventDefinition<z.ZodObject<{
|
|
1750
|
+
pipelineId: z.ZodString;
|
|
1751
|
+
}, z.core.$strip>>;
|
|
1752
|
+
declare const PipelineArchived: CrmEventDefinition<z.ZodObject<{
|
|
1753
|
+
pipelineId: z.ZodString;
|
|
1754
|
+
}, z.core.$strip>>;
|
|
1755
|
+
declare const ActivityPlanned: CrmEventDefinition<z.ZodObject<{
|
|
1756
|
+
activityId: z.ZodString;
|
|
1757
|
+
type: z.ZodString;
|
|
1758
|
+
subjectKind: z.ZodString;
|
|
1759
|
+
subjectId: z.ZodString;
|
|
1760
|
+
}, z.core.$strip>>;
|
|
1761
|
+
declare const ActivityCompleted: CrmEventDefinition<z.ZodObject<{
|
|
1762
|
+
activityId: z.ZodString;
|
|
1763
|
+
completedAt: z.ZodISODateTime;
|
|
1764
|
+
}, z.core.$strip>>;
|
|
1765
|
+
declare const ActivityCancelled: CrmEventDefinition<z.ZodObject<{
|
|
1766
|
+
activityId: z.ZodString;
|
|
1767
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1768
|
+
}, z.core.$strip>>;
|
|
1769
|
+
declare const ActivityRescheduled: CrmEventDefinition<z.ZodObject<{
|
|
1770
|
+
activityId: z.ZodString;
|
|
1771
|
+
dueDate: z.ZodISODateTime;
|
|
1772
|
+
previousDueDate: z.ZodOptional<z.ZodISODateTime>;
|
|
1773
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1774
|
+
by: z.ZodOptional<z.ZodString>;
|
|
1775
|
+
}, z.core.$strip>>;
|
|
1776
|
+
declare const ActivityOutcomeRecorded: CrmEventDefinition<z.ZodObject<{
|
|
1777
|
+
activityId: z.ZodString;
|
|
1778
|
+
outcome: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1779
|
+
}, z.core.$strip>>;
|
|
1780
|
+
declare const NoteAdded: CrmEventDefinition<z.ZodObject<{
|
|
1781
|
+
noteId: z.ZodString;
|
|
1782
|
+
subjectKind: z.ZodString;
|
|
1783
|
+
subjectId: z.ZodString;
|
|
1784
|
+
}, z.core.$strip>>;
|
|
1785
|
+
declare const CampaignCreated: CrmEventDefinition<z.ZodObject<{
|
|
1786
|
+
campaignId: z.ZodString;
|
|
1787
|
+
name: z.ZodString;
|
|
1788
|
+
}, z.core.$strip>>;
|
|
1789
|
+
declare const CampaignActivated: CrmEventDefinition<z.ZodObject<{
|
|
1790
|
+
campaignId: z.ZodString;
|
|
1791
|
+
}, z.core.$strip>>;
|
|
1792
|
+
declare const CampaignPaused: CrmEventDefinition<z.ZodObject<{
|
|
1793
|
+
campaignId: z.ZodString;
|
|
1794
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1795
|
+
}, z.core.$strip>>;
|
|
1796
|
+
declare const CampaignResumed: CrmEventDefinition<z.ZodObject<{
|
|
1797
|
+
campaignId: z.ZodString;
|
|
1798
|
+
}, z.core.$strip>>;
|
|
1799
|
+
declare const CampaignCompleted: CrmEventDefinition<z.ZodObject<{
|
|
1800
|
+
campaignId: z.ZodString;
|
|
1801
|
+
actualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
1802
|
+
}, z.core.$strip>>;
|
|
1803
|
+
declare const CampaignArchived: CrmEventDefinition<z.ZodObject<{
|
|
1804
|
+
campaignId: z.ZodString;
|
|
1805
|
+
}, z.core.$strip>>;
|
|
1806
|
+
declare const SubscriptionCreated: CrmEventDefinition<z.ZodObject<{
|
|
1807
|
+
subscriptionId: z.ZodString;
|
|
1808
|
+
contactId: z.ZodString;
|
|
1809
|
+
campaignId: z.ZodString;
|
|
1810
|
+
requiresConfirmation: z.ZodBoolean;
|
|
1811
|
+
}, z.core.$strip>>;
|
|
1812
|
+
declare const SubscriptionConfirmed: CrmEventDefinition<z.ZodObject<{
|
|
1813
|
+
subscriptionId: z.ZodString;
|
|
1814
|
+
contactId: z.ZodString;
|
|
1815
|
+
campaignId: z.ZodString;
|
|
1816
|
+
confirmedAt: z.ZodISODateTime;
|
|
1817
|
+
}, z.core.$strip>>;
|
|
1818
|
+
declare const SubscriptionUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
1819
|
+
subscriptionId: z.ZodString;
|
|
1820
|
+
contactId: z.ZodString;
|
|
1821
|
+
campaignId: z.ZodString;
|
|
1822
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1823
|
+
}, z.core.$strip>>;
|
|
1824
|
+
declare const SubscriptionBounced: CrmEventDefinition<z.ZodObject<{
|
|
1825
|
+
subscriptionId: z.ZodString;
|
|
1826
|
+
contactId: z.ZodString;
|
|
1827
|
+
campaignId: z.ZodString;
|
|
1828
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1829
|
+
}, z.core.$strip>>;
|
|
1830
|
+
declare const SubscriptionComplained: CrmEventDefinition<z.ZodObject<{
|
|
1831
|
+
subscriptionId: z.ZodString;
|
|
1832
|
+
contactId: z.ZodString;
|
|
1833
|
+
campaignId: z.ZodString;
|
|
1834
|
+
}, z.core.$strip>>;
|
|
1835
|
+
declare const SuppressionAdded: CrmEventDefinition<z.ZodObject<{
|
|
1836
|
+
email: z.ZodString;
|
|
1837
|
+
reason: z.ZodEnum<{
|
|
1838
|
+
bounce: "bounce";
|
|
1839
|
+
complaint: "complaint";
|
|
1840
|
+
unsubscribe: "unsubscribe";
|
|
1841
|
+
manual: "manual";
|
|
1842
|
+
}>;
|
|
1843
|
+
source: z.ZodOptional<z.ZodString>;
|
|
1844
|
+
}, z.core.$strip>>;
|
|
1845
|
+
declare const SuppressionRemoved: CrmEventDefinition<z.ZodObject<{
|
|
1846
|
+
email: z.ZodString;
|
|
1847
|
+
}, z.core.$strip>>;
|
|
1848
|
+
declare const EmailEventOpened: CrmEventDefinition<z.ZodObject<{
|
|
1849
|
+
eventId: z.ZodString;
|
|
1850
|
+
kind: z.ZodString;
|
|
1851
|
+
subjectKind: z.ZodString;
|
|
1852
|
+
subjectId: z.ZodString;
|
|
1853
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
1854
|
+
}, z.core.$strip>>;
|
|
1855
|
+
declare const EmailEventClicked: CrmEventDefinition<z.ZodObject<{
|
|
1856
|
+
eventId: z.ZodString;
|
|
1857
|
+
kind: z.ZodString;
|
|
1858
|
+
subjectKind: z.ZodString;
|
|
1859
|
+
subjectId: z.ZodString;
|
|
1860
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
1861
|
+
}, z.core.$strip>>;
|
|
1862
|
+
declare const EmailEventBounced: CrmEventDefinition<z.ZodObject<{
|
|
1863
|
+
eventId: z.ZodString;
|
|
1864
|
+
kind: z.ZodString;
|
|
1865
|
+
subjectKind: z.ZodString;
|
|
1866
|
+
subjectId: z.ZodString;
|
|
1867
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
1868
|
+
}, z.core.$strip>>;
|
|
1869
|
+
declare const EmailEventComplained: CrmEventDefinition<z.ZodObject<{
|
|
1870
|
+
eventId: z.ZodString;
|
|
1871
|
+
kind: z.ZodString;
|
|
1872
|
+
subjectKind: z.ZodString;
|
|
1873
|
+
subjectId: z.ZodString;
|
|
1874
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
1875
|
+
}, z.core.$strip>>;
|
|
1876
|
+
declare const EmailEventUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
1877
|
+
eventId: z.ZodString;
|
|
1878
|
+
kind: z.ZodString;
|
|
1879
|
+
subjectKind: z.ZodString;
|
|
1880
|
+
subjectId: z.ZodString;
|
|
1881
|
+
campaignId: z.ZodOptional<z.ZodString>;
|
|
1882
|
+
}, z.core.$strip>>;
|
|
1883
|
+
declare const ConversationCreated: CrmEventDefinition<z.ZodObject<{
|
|
1884
|
+
conversationId: z.ZodString;
|
|
1885
|
+
channel: z.ZodString;
|
|
1886
|
+
participantKind: z.ZodString;
|
|
1887
|
+
participantId: z.ZodString;
|
|
1888
|
+
}, z.core.$strip>>;
|
|
1889
|
+
declare const ConversationAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1890
|
+
conversationId: z.ZodString;
|
|
1891
|
+
assigneeId: z.ZodString;
|
|
1892
|
+
previousAssigneeId: z.ZodOptional<z.ZodString>;
|
|
1893
|
+
}, z.core.$strip>>;
|
|
1894
|
+
declare const ConversationResolved: CrmEventDefinition<z.ZodObject<{
|
|
1895
|
+
conversationId: z.ZodString;
|
|
1896
|
+
status: z.ZodString;
|
|
1897
|
+
previousStatus: z.ZodString;
|
|
1898
|
+
}, z.core.$strip>>;
|
|
1899
|
+
declare const ConversationReopened: CrmEventDefinition<z.ZodObject<{
|
|
1900
|
+
conversationId: z.ZodString;
|
|
1901
|
+
status: z.ZodString;
|
|
1902
|
+
previousStatus: z.ZodString;
|
|
1903
|
+
}, z.core.$strip>>;
|
|
1904
|
+
declare const MessageReceived: CrmEventDefinition<z.ZodObject<{
|
|
1905
|
+
messageId: z.ZodString;
|
|
1906
|
+
conversationId: z.ZodString;
|
|
1907
|
+
direction: z.ZodString;
|
|
1908
|
+
externalMessageId: z.ZodOptional<z.ZodString>;
|
|
1909
|
+
}, z.core.$strip>>;
|
|
1910
|
+
declare const MessageSent: CrmEventDefinition<z.ZodObject<{
|
|
1911
|
+
messageId: z.ZodString;
|
|
1912
|
+
conversationId: z.ZodString;
|
|
1913
|
+
direction: z.ZodString;
|
|
1914
|
+
externalMessageId: z.ZodOptional<z.ZodString>;
|
|
1915
|
+
}, z.core.$strip>>;
|
|
1916
|
+
declare const SequenceCreated: CrmEventDefinition<z.ZodObject<{
|
|
1917
|
+
sequenceId: z.ZodString;
|
|
1918
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1919
|
+
}, z.core.$strip>>;
|
|
1920
|
+
declare const SequenceActivated: CrmEventDefinition<z.ZodObject<{
|
|
1921
|
+
sequenceId: z.ZodString;
|
|
1922
|
+
}, z.core.$strip>>;
|
|
1923
|
+
declare const SequencePaused: CrmEventDefinition<z.ZodObject<{
|
|
1924
|
+
sequenceId: z.ZodString;
|
|
1925
|
+
}, z.core.$strip>>;
|
|
1926
|
+
declare const SequenceArchived: CrmEventDefinition<z.ZodObject<{
|
|
1927
|
+
sequenceId: z.ZodString;
|
|
1928
|
+
}, z.core.$strip>>;
|
|
1929
|
+
declare const EnrollmentCreated: CrmEventDefinition<z.ZodObject<{
|
|
1930
|
+
enrollmentId: z.ZodString;
|
|
1931
|
+
sequenceId: z.ZodString;
|
|
1932
|
+
subjectId: z.ZodString;
|
|
1933
|
+
subjectKind: z.ZodString;
|
|
1934
|
+
}, z.core.$strip>>;
|
|
1935
|
+
declare const EnrollmentStepSent: CrmEventDefinition<z.ZodObject<{
|
|
1936
|
+
enrollmentId: z.ZodString;
|
|
1937
|
+
sequenceId: z.ZodOptional<z.ZodString>;
|
|
1938
|
+
stepIndex: z.ZodNumber;
|
|
1939
|
+
channel: z.ZodOptional<z.ZodString>;
|
|
1940
|
+
}, z.core.$strip>>;
|
|
1941
|
+
declare const EnrollmentPaused: CrmEventDefinition<z.ZodObject<{
|
|
1942
|
+
enrollmentId: z.ZodString;
|
|
1943
|
+
}, z.core.$strip>>;
|
|
1944
|
+
declare const EnrollmentResumed: CrmEventDefinition<z.ZodObject<{
|
|
1945
|
+
enrollmentId: z.ZodString;
|
|
1946
|
+
}, z.core.$strip>>;
|
|
1947
|
+
declare const EnrollmentCompleted: CrmEventDefinition<z.ZodObject<{
|
|
1948
|
+
enrollmentId: z.ZodString;
|
|
1949
|
+
}, z.core.$strip>>;
|
|
1950
|
+
declare const EnrollmentExited: CrmEventDefinition<z.ZodObject<{
|
|
1951
|
+
enrollmentId: z.ZodString;
|
|
1952
|
+
exitReason: z.ZodOptional<z.ZodString>;
|
|
1953
|
+
}, z.core.$strip>>;
|
|
1954
|
+
declare const crmEventDefinitions: ReadonlyArray<CrmEventDefinition>;
|
|
1955
|
+
//#endregion
|
|
1956
|
+
//#region src/events/helpers.d.ts
|
|
1957
|
+
declare function createEvent<T>(type: string, payload: T, ctx?: CrmContext, meta?: Partial<EventMeta>): DomainEvent<T>;
|
|
1147
1958
|
//#endregion
|
|
1148
|
-
//#region src/
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
constructor(model: Model<IAccountDocument>, plugins: PluginType[], deps: AccountRepositoryDeps, pagination?: PaginationConfig);
|
|
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>;
|
|
1959
|
+
//#region src/events/in-process-bus.d.ts
|
|
1960
|
+
declare class InProcessCrmBus implements EventTransport {
|
|
1961
|
+
readonly name = "in-process-crm";
|
|
1962
|
+
private subs;
|
|
1963
|
+
private logger?;
|
|
1964
|
+
constructor(options?: {
|
|
1965
|
+
logger?: CrmLogger;
|
|
1966
|
+
});
|
|
1967
|
+
publish(event: DomainEvent): Promise<void>;
|
|
1968
|
+
subscribe(pattern: string, handler: EventHandler): Promise<() => void>;
|
|
1969
|
+
close(): Promise<void>;
|
|
1166
1970
|
}
|
|
1167
1971
|
//#endregion
|
|
1168
|
-
//#region src/
|
|
1169
|
-
interface
|
|
1170
|
-
|
|
1171
|
-
/**
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
note?: string;
|
|
1177
|
-
actualRevenueAmount?: number;
|
|
1178
|
-
};
|
|
1179
|
-
declare class CampaignRepository extends Repository<ICampaignDocument> {
|
|
1180
|
-
private readonly events;
|
|
1181
|
-
private readonly rejectDuplicates;
|
|
1182
|
-
constructor(model: Model<ICampaignDocument>, plugins: PluginType[], deps: CampaignRepositoryDeps, pagination?: PaginationConfig);
|
|
1183
|
-
createCampaign(input: Partial<ICampaignDocument>, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1184
|
-
activate(id: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1185
|
-
pause(id: string, reason?: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1186
|
-
resume(id: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1187
|
-
complete(id: string, extras?: ExtrasWithRevenue, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1188
|
-
archive(id: string, by?: string, ctx?: CrmContext): Promise<ICampaignDocument>;
|
|
1189
|
-
private _transition;
|
|
1972
|
+
//#region src/engine/run-unit.d.ts
|
|
1973
|
+
interface RunUnitConfig {
|
|
1974
|
+
connection: Connection;
|
|
1975
|
+
/** Transport used for the post-commit flush. */
|
|
1976
|
+
events: Pick<EventTransport, 'publish'> | undefined;
|
|
1977
|
+
logger?: CrmLogger | undefined;
|
|
1978
|
+
/** Standalone-Mongo fallback (local dev) — partial-write risk, explicit opt-in. */
|
|
1979
|
+
allowNonTransactional: boolean;
|
|
1190
1980
|
}
|
|
1981
|
+
declare function runUnit<T>(config: RunUnitConfig, ctx: CrmContext, body: (innerCtx: CrmContext) => Promise<T>): Promise<T>;
|
|
1191
1982
|
//#endregion
|
|
1192
|
-
//#region src/
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
declare
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
markBounced(id: string, reason?: string, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1216
|
-
markComplained(id: string, ctx?: CrmContext): Promise<ISubscriptionDocument>;
|
|
1217
|
-
private _transition;
|
|
1218
|
-
}
|
|
1983
|
+
//#region src/core/state-machines.d.ts
|
|
1984
|
+
/**
|
|
1985
|
+
* Declarative state machines for every CRM aggregate that has lifecycle
|
|
1986
|
+
* transitions. Single source of truth for what `from -> to` moves are
|
|
1987
|
+
* legal — the repositories' domain verbs (`qualify`, `convert`, `win`,
|
|
1988
|
+
* `lose`, `confirm`, `unsubscribe`, ...) call `assertTransition` before
|
|
1989
|
+
* they touch Mongo.
|
|
1990
|
+
*
|
|
1991
|
+
* Per PACKAGE_RULES §30: "State machines map to Arc Actions". The host
|
|
1992
|
+
* exposes each domain verb as an arc Action (`POST /:id/action` with
|
|
1993
|
+
* `{ action: 'qualify' }`); the verb's implementation lives on the
|
|
1994
|
+
* Repository class and uses these machines internally.
|
|
1995
|
+
*
|
|
1996
|
+
* Built on `@classytic/primitives/state-machine` so the same shape lights
|
|
1997
|
+
* up across kits (mongokit's `claim()` pairing, sqlitekit follow-ups).
|
|
1998
|
+
*/
|
|
1999
|
+
declare const LEAD_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"new" | "contacted" | "qualified" | "converted" | "disqualified" | "nurturing">;
|
|
2000
|
+
declare const OPPORTUNITY_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"open" | "won" | "lost" | "abandoned">;
|
|
2001
|
+
declare const CAMPAIGN_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"draft" | "active" | "paused" | "completed" | "archived">;
|
|
2002
|
+
declare const SUBSCRIPTION_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"pending" | "confirmed" | "unsubscribed" | "bounced" | "complained">;
|
|
2003
|
+
declare const ACTIVITY_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"completed" | "planned" | "in_progress" | "cancelled">;
|
|
2004
|
+
declare const SEQUENCE_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"draft" | "active" | "paused" | "archived">;
|
|
2005
|
+
declare const ENROLLMENT_MACHINE: _$_classytic_primitives_state_machine0.StateMachine<"active" | "paused" | "completed" | "exited">;
|
|
1219
2006
|
//#endregion
|
|
1220
|
-
//#region src/
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
declare class
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
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>;
|
|
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[]>;
|
|
2007
|
+
//#region src/core/errors.d.ts
|
|
2008
|
+
/**
|
|
2009
|
+
* CRM error vocabulary. Hosts catch `CrmError` at API edges.
|
|
2010
|
+
*/
|
|
2011
|
+
declare class CrmError extends Error {
|
|
2012
|
+
readonly code: string;
|
|
2013
|
+
readonly details?: Record<string, unknown>;
|
|
2014
|
+
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
2015
|
+
}
|
|
2016
|
+
declare class NotFoundError extends CrmError {
|
|
2017
|
+
constructor(kind: string, id: string);
|
|
2018
|
+
}
|
|
2019
|
+
declare class InvalidLeadTransitionError extends CrmError {
|
|
2020
|
+
constructor(details: {
|
|
2021
|
+
from: string;
|
|
2022
|
+
to: string;
|
|
2023
|
+
leadId: string;
|
|
2024
|
+
});
|
|
1255
2025
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
2026
|
+
declare class InvalidOpportunityTransitionError extends CrmError {
|
|
2027
|
+
constructor(details: {
|
|
2028
|
+
from: string;
|
|
2029
|
+
to: string;
|
|
2030
|
+
opportunityId: string;
|
|
2031
|
+
});
|
|
1260
2032
|
}
|
|
1261
|
-
declare class
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
2033
|
+
declare class InvalidActivityTransitionError extends CrmError {
|
|
2034
|
+
constructor(details: {
|
|
2035
|
+
from: string;
|
|
2036
|
+
to: string;
|
|
2037
|
+
activityId: string;
|
|
2038
|
+
});
|
|
1265
2039
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
2040
|
+
declare class StageNotInPipelineError extends CrmError {
|
|
2041
|
+
constructor(details: {
|
|
2042
|
+
pipelineId: string;
|
|
2043
|
+
stageId: string;
|
|
2044
|
+
});
|
|
1270
2045
|
}
|
|
1271
|
-
declare class
|
|
1272
|
-
|
|
1273
|
-
constructor(model: Model<ILossReasonDocument>, plugins: PluginType[], deps: LossReasonRepositoryDeps, pagination?: PaginationConfig);
|
|
1274
|
-
/** Hide from pickers without breaking historical FKs. */
|
|
1275
|
-
archive(id: string, ctx?: CrmContext): Promise<ILossReasonDocument>;
|
|
2046
|
+
declare class LeadAlreadyConvertedError extends CrmError {
|
|
2047
|
+
constructor(leadId: string);
|
|
1276
2048
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
2049
|
+
declare class DuplicateLeadError extends CrmError {
|
|
2050
|
+
constructor(details: {
|
|
2051
|
+
email?: string;
|
|
2052
|
+
phone?: string;
|
|
2053
|
+
});
|
|
1281
2054
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
subjectId: string;
|
|
1285
|
-
campaignId?: string;
|
|
1286
|
-
messageId?: string;
|
|
1287
|
-
url?: string;
|
|
1288
|
-
userAgent?: string;
|
|
1289
|
-
ip?: string;
|
|
1290
|
-
metadata?: Record<string, unknown>;
|
|
2055
|
+
declare class UnmanagedSessionError extends CrmError {
|
|
2056
|
+
constructor(eventType?: string);
|
|
1291
2057
|
}
|
|
1292
|
-
declare class
|
|
1293
|
-
|
|
1294
|
-
constructor(model: Model<IEmailEventDocument>, plugins: PluginType[], deps: EmailEventRepositoryDeps, pagination?: PaginationConfig);
|
|
1295
|
-
recordOpen(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1296
|
-
recordClick(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1297
|
-
recordBounce(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1298
|
-
recordComplaint(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1299
|
-
recordUnsubscribe(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
1300
|
-
private _record;
|
|
2058
|
+
declare class EmptyPipelineError extends CrmError {
|
|
2059
|
+
constructor(pipelineId: string);
|
|
1301
2060
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
2061
|
+
declare class InvalidCampaignTransitionError extends CrmError {
|
|
2062
|
+
constructor(details: {
|
|
2063
|
+
from: string;
|
|
2064
|
+
to: string;
|
|
2065
|
+
campaignId: string;
|
|
2066
|
+
});
|
|
1306
2067
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
participantKind: ConversationParticipantKind;
|
|
1310
|
-
participantId: string;
|
|
1311
|
-
channelUserId?: string;
|
|
1312
|
-
assigneeId?: string;
|
|
1313
|
-
metadata?: Record<string, unknown>;
|
|
2068
|
+
declare class DuplicateCampaignError extends CrmError {
|
|
2069
|
+
constructor(name: string);
|
|
1314
2070
|
}
|
|
1315
|
-
declare class
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
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;
|
|
2071
|
+
declare class InvalidSubscriptionTransitionError extends CrmError {
|
|
2072
|
+
constructor(details: {
|
|
2073
|
+
from: string;
|
|
2074
|
+
to: string;
|
|
2075
|
+
subscriptionId: string;
|
|
2076
|
+
});
|
|
1335
2077
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
2078
|
+
declare class DuplicateSubscriptionError extends CrmError {
|
|
2079
|
+
constructor(details: {
|
|
2080
|
+
contactId: string;
|
|
2081
|
+
campaignId: string;
|
|
2082
|
+
});
|
|
1341
2083
|
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
body: string;
|
|
1345
|
-
attachments?: IMessageAttachment[];
|
|
1346
|
-
externalMessageId?: string;
|
|
1347
|
-
senderRef?: string;
|
|
1348
|
-
recipientRef?: string;
|
|
1349
|
-
sentAt?: Date;
|
|
1350
|
-
metadata?: Record<string, unknown>;
|
|
2084
|
+
declare class InvalidConfirmationTokenError extends CrmError {
|
|
2085
|
+
constructor();
|
|
1351
2086
|
}
|
|
1352
|
-
declare class
|
|
1353
|
-
|
|
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[]>;
|
|
2087
|
+
declare class InvalidUnsubscribeTokenError extends CrmError {
|
|
2088
|
+
constructor();
|
|
1363
2089
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
debug?(msg: string, meta?: Record<string, unknown>): void;
|
|
2090
|
+
declare class InvalidSequenceTransitionError extends CrmError {
|
|
2091
|
+
constructor(details: {
|
|
2092
|
+
from: string;
|
|
2093
|
+
to: string;
|
|
2094
|
+
sequenceId: string;
|
|
2095
|
+
});
|
|
1371
2096
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
* Threaded into both schemas and `multiTenantPlugin` so they stay in
|
|
1379
|
-
* sync (PACKAGE_RULES §9.2).
|
|
1380
|
-
*/
|
|
1381
|
-
tenantFieldType?: TenantFieldType;
|
|
1382
|
-
/**
|
|
1383
|
-
* When `true` (default), wire `multiTenantPlugin` on every repository
|
|
1384
|
-
* with `required: true`. Set `false` only for fixtures / smoke tests
|
|
1385
|
-
* that intentionally drop the scope.
|
|
1386
|
-
*/
|
|
1387
|
-
multiTenant?: boolean;
|
|
1388
|
-
/** Arc-compatible event transport. Default: in-process bus. */
|
|
1389
|
-
eventTransport?: EventTransport;
|
|
1390
|
-
/** Logger surface used by the in-process bus + repositories. */
|
|
1391
|
-
logger?: CrmLogger;
|
|
1392
|
-
/** Pagination defaults for every repository (mongokit). */
|
|
1393
|
-
pagination?: PaginationConfig;
|
|
1394
|
-
/** Extra mongokit plugins applied to every repository (after defaults). */
|
|
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;
|
|
2097
|
+
declare class InvalidEnrollmentTransitionError extends CrmError {
|
|
2098
|
+
constructor(details: {
|
|
2099
|
+
from: string;
|
|
2100
|
+
to: string;
|
|
2101
|
+
enrollmentId: string;
|
|
2102
|
+
});
|
|
1414
2103
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
autoIndex: boolean;
|
|
1421
|
-
logger?: CrmLogger;
|
|
1422
|
-
pagination?: PaginationConfig;
|
|
1423
|
-
plugins: PluginType[];
|
|
2104
|
+
declare class AlreadyEnrolledError extends CrmError {
|
|
2105
|
+
constructor(details: {
|
|
2106
|
+
sequenceId: string;
|
|
2107
|
+
subjectId: string;
|
|
2108
|
+
});
|
|
1424
2109
|
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
message: MessageRepository;
|
|
2110
|
+
//#endregion
|
|
2111
|
+
//#region src/shared/calculators/forecast.d.ts
|
|
2112
|
+
type OpportunityForecast = Pick<IOpportunityDocument, 'amount' | 'currency' | 'probability' | 'status' | 'expectedCloseAt' | 'stageId' | 'statusHistory'>;
|
|
2113
|
+
interface ForecastRow {
|
|
2114
|
+
/** Bucket key — ISO month `YYYY-MM` by default. */
|
|
2115
|
+
bucket: string;
|
|
2116
|
+
/** Σ amount. */
|
|
2117
|
+
committed: number;
|
|
2118
|
+
/** Σ amount × probability. */
|
|
2119
|
+
weighted: number;
|
|
2120
|
+
/** Number of opportunities in the bucket. */
|
|
2121
|
+
count: number;
|
|
2122
|
+
currency: string;
|
|
1439
2123
|
}
|
|
1440
|
-
interface
|
|
1441
|
-
/**
|
|
1442
|
-
|
|
1443
|
-
/**
|
|
1444
|
-
|
|
1445
|
-
/** Mongoose models — for arc adapter wiring. */
|
|
1446
|
-
readonly models: Readonly<CrmModels>;
|
|
1447
|
-
/** Resolved configuration (frozen). */
|
|
1448
|
-
readonly config: Readonly<ResolvedCrmConfig>;
|
|
2124
|
+
interface ForecastOptions {
|
|
2125
|
+
/** Bucket function. Default: ISO month from `expectedCloseAt`. */
|
|
2126
|
+
bucket?: (o: OpportunityForecast) => string;
|
|
2127
|
+
/** Filter before bucketing. Default: open + has amount + has expectedCloseAt. */
|
|
2128
|
+
include?: (o: OpportunityForecast) => boolean;
|
|
1449
2129
|
/**
|
|
1450
|
-
*
|
|
1451
|
-
*
|
|
2130
|
+
* IANA zone for the default month bucket (e.g. `'Asia/Dhaka'`). Without
|
|
2131
|
+
* it, months are cut at UTC boundaries — a deal expected to close
|
|
2132
|
+
* July 1, 02:00 Dhaka time (June 30, 20:00 UTC) lands in the JUNE
|
|
2133
|
+
* bucket. Ignored when a custom `bucket` fn is supplied. Invalid zones
|
|
2134
|
+
* throw (same contract as `@classytic/primitives/timezone`).
|
|
1452
2135
|
*/
|
|
1453
|
-
|
|
1454
|
-
/** Release resources. Safe to call multiple times. */
|
|
1455
|
-
dispose(): Promise<void>;
|
|
2136
|
+
timeZone?: string;
|
|
1456
2137
|
}
|
|
1457
2138
|
/**
|
|
1458
|
-
*
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1461
|
-
* `metadata?` field — keep the typed surface tight.
|
|
2139
|
+
* Aggregate opportunities into a forecast table — one row per bucket.
|
|
2140
|
+
* Currency mismatch within a bucket throws — partition by currency
|
|
2141
|
+
* upstream when multi-currency.
|
|
1462
2142
|
*/
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
2143
|
+
declare function forecast(opportunities: readonly OpportunityForecast[], options?: ForecastOptions): ForecastRow[];
|
|
2144
|
+
interface ConversionRow {
|
|
2145
|
+
stageId: string;
|
|
2146
|
+
currentCount: number;
|
|
2147
|
+
wonFromHere: number;
|
|
2148
|
+
lostFromHere: number;
|
|
2149
|
+
conversionRate: number;
|
|
1468
2150
|
}
|
|
1469
|
-
|
|
2151
|
+
/**
|
|
2152
|
+
* "Where do deals die?" summary — opportunities partitioned across
|
|
2153
|
+
* stages with current count + won/lost-from-here.
|
|
2154
|
+
*/
|
|
2155
|
+
declare function pipelineConversion(opportunities: readonly OpportunityForecast[], stageIds: readonly string[]): ConversionRow[];
|
|
1470
2156
|
//#endregion
|
|
1471
|
-
//#region src/
|
|
1472
|
-
declare
|
|
2157
|
+
//#region src/validators/common.d.ts
|
|
2158
|
+
declare const objectIdLike: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2159
|
+
declare const metadataSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2160
|
+
declare const tagsSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2161
|
+
declare const moneyAmountSchema: z.ZodNumber;
|
|
2162
|
+
declare const currencyCodeSchema: z.ZodString;
|
|
1473
2163
|
//#endregion
|
|
1474
|
-
//#region src/
|
|
1475
|
-
declare
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
2164
|
+
//#region src/validators/pipeline.schema.d.ts
|
|
2165
|
+
declare const stageInputSchema: z.ZodObject<{
|
|
2166
|
+
name: z.ZodString;
|
|
2167
|
+
sequence: z.ZodNumber;
|
|
2168
|
+
defaultProbability: z.ZodNumber;
|
|
2169
|
+
color: z.ZodOptional<z.ZodString>;
|
|
2170
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2171
|
+
}, z.core.$strip>;
|
|
2172
|
+
declare const createPipelineSchema: z.ZodObject<{
|
|
2173
|
+
name: z.ZodString;
|
|
2174
|
+
stages: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
2175
|
+
name: z.ZodString;
|
|
2176
|
+
sequence: z.ZodNumber;
|
|
2177
|
+
defaultProbability: z.ZodNumber;
|
|
2178
|
+
color: z.ZodOptional<z.ZodString>;
|
|
2179
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2180
|
+
}, z.core.$strip>>>;
|
|
2181
|
+
teamRef: z.ZodOptional<z.ZodString>;
|
|
2182
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2183
|
+
}, z.core.$strip>;
|
|
2184
|
+
declare const updatePipelineSchema: z.ZodObject<{
|
|
2185
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2186
|
+
stages: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
2187
|
+
name: z.ZodString;
|
|
2188
|
+
sequence: z.ZodNumber;
|
|
2189
|
+
defaultProbability: z.ZodNumber;
|
|
2190
|
+
color: z.ZodOptional<z.ZodString>;
|
|
2191
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2192
|
+
}, z.core.$strip>>>>;
|
|
2193
|
+
teamRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2194
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2195
|
+
}, z.core.$strip>;
|
|
2196
|
+
declare const stageInputSchemaExport: z.ZodObject<{
|
|
2197
|
+
name: z.ZodString;
|
|
2198
|
+
sequence: z.ZodNumber;
|
|
2199
|
+
defaultProbability: z.ZodNumber;
|
|
2200
|
+
color: z.ZodOptional<z.ZodString>;
|
|
2201
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2202
|
+
}, z.core.$strip>;
|
|
2203
|
+
declare const pipelineFilterSchema: z.ZodObject<{
|
|
2204
|
+
isArchived: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
2205
|
+
teamRef: z.ZodOptional<z.ZodString>;
|
|
2206
|
+
}, z.core.$strip>;
|
|
2207
|
+
type CreatePipelineDto = z.infer<typeof createPipelineSchema>;
|
|
2208
|
+
type UpdatePipelineDto = z.infer<typeof updatePipelineSchema>;
|
|
2209
|
+
type StageInputDto = z.infer<typeof stageInputSchema>;
|
|
2210
|
+
//#endregion
|
|
2211
|
+
//#region src/validators/lead.schema.d.ts
|
|
2212
|
+
declare const createLeadSchema: z.ZodObject<{
|
|
2213
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
2214
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
2215
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
2216
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2217
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
2218
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
2219
|
+
jobTitle: z.ZodOptional<z.ZodString>;
|
|
2220
|
+
source: z.ZodOptional<z.ZodString>;
|
|
2221
|
+
campaignRef: z.ZodOptional<z.ZodString>;
|
|
2222
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2223
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2224
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2225
|
+
}, z.core.$strip>;
|
|
2226
|
+
declare const updateLeadSchema: z.ZodObject<{
|
|
2227
|
+
fullName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2228
|
+
firstName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2229
|
+
lastName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2230
|
+
email: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2231
|
+
phone: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2232
|
+
companyName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2233
|
+
jobTitle: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2234
|
+
source: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2235
|
+
campaignRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2236
|
+
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2237
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
2238
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2239
|
+
}, z.core.$strip>;
|
|
2240
|
+
declare const leadFilterSchema: z.ZodObject<{
|
|
2241
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2242
|
+
new: "new";
|
|
2243
|
+
contacted: "contacted";
|
|
2244
|
+
qualified: "qualified";
|
|
2245
|
+
converted: "converted";
|
|
2246
|
+
disqualified: "disqualified";
|
|
2247
|
+
nurturing: "nurturing";
|
|
2248
|
+
}>>;
|
|
2249
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2250
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2251
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2252
|
+
source: z.ZodOptional<z.ZodString>;
|
|
2253
|
+
campaignRef: z.ZodOptional<z.ZodString>;
|
|
2254
|
+
scoreMin: z.ZodOptional<z.ZodNumber>;
|
|
2255
|
+
scoreMax: z.ZodOptional<z.ZodNumber>;
|
|
2256
|
+
}, z.core.$strip>;
|
|
2257
|
+
declare const convertLeadSchema: z.ZodObject<{
|
|
2258
|
+
pipelineId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2259
|
+
opportunityName: z.ZodOptional<z.ZodString>;
|
|
2260
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
2261
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
2262
|
+
expectedCloseAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2263
|
+
by: z.ZodOptional<z.ZodString>;
|
|
2264
|
+
}, z.core.$strip>;
|
|
2265
|
+
type CreateLeadDto = z.infer<typeof createLeadSchema>;
|
|
2266
|
+
type UpdateLeadDto = z.infer<typeof updateLeadSchema>;
|
|
2267
|
+
type ConvertLeadDto = z.infer<typeof convertLeadSchema>;
|
|
2268
|
+
type LeadFilterDto = z.infer<typeof leadFilterSchema>;
|
|
2269
|
+
//#endregion
|
|
2270
|
+
//#region src/validators/opportunity.schema.d.ts
|
|
2271
|
+
declare const openOpportunitySchema: z.ZodObject<{
|
|
2272
|
+
name: z.ZodString;
|
|
2273
|
+
pipelineId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2274
|
+
stageId: z.ZodOptional<z.ZodString>;
|
|
2275
|
+
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2276
|
+
primaryContactId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2277
|
+
sourceLeadId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2278
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
2279
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
2280
|
+
probability: z.ZodOptional<z.ZodNumber>;
|
|
2281
|
+
expectedCloseAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2282
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2283
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2284
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2285
|
+
}, z.core.$strip>;
|
|
2286
|
+
declare const moveStageSchema: z.ZodObject<{
|
|
2287
|
+
stageId: z.ZodString;
|
|
2288
|
+
by: z.ZodOptional<z.ZodString>;
|
|
2289
|
+
note: z.ZodOptional<z.ZodString>;
|
|
2290
|
+
probability: z.ZodOptional<z.ZodNumber>;
|
|
2291
|
+
}, z.core.$strip>;
|
|
2292
|
+
declare const closeWinSchema: z.ZodObject<{
|
|
2293
|
+
by: z.ZodOptional<z.ZodString>;
|
|
2294
|
+
note: z.ZodOptional<z.ZodString>;
|
|
2295
|
+
closedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2296
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
2297
|
+
}, z.core.$strip>;
|
|
2298
|
+
declare const closeLossSchema: z.ZodObject<{
|
|
2299
|
+
by: z.ZodOptional<z.ZodString>;
|
|
2300
|
+
note: z.ZodOptional<z.ZodString>;
|
|
2301
|
+
closedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2302
|
+
lostReasonId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2303
|
+
}, z.core.$strip>;
|
|
2304
|
+
declare const opportunityFilterSchema: z.ZodObject<{
|
|
2305
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2306
|
+
open: "open";
|
|
2307
|
+
won: "won";
|
|
2308
|
+
lost: "lost";
|
|
2309
|
+
abandoned: "abandoned";
|
|
2310
|
+
}>>;
|
|
2311
|
+
pipelineId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2312
|
+
stageId: z.ZodOptional<z.ZodString>;
|
|
2313
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2314
|
+
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2315
|
+
expectedCloseFrom: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2316
|
+
expectedCloseTo: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2317
|
+
}, z.core.$strip>;
|
|
2318
|
+
type OpenOpportunityDto = z.infer<typeof openOpportunitySchema>;
|
|
2319
|
+
type MoveStageDto = z.infer<typeof moveStageSchema>;
|
|
2320
|
+
type CloseWinDto = z.infer<typeof closeWinSchema>;
|
|
2321
|
+
type CloseLossDto = z.infer<typeof closeLossSchema>;
|
|
2322
|
+
type OpportunityFilterDto = z.infer<typeof opportunityFilterSchema>;
|
|
2323
|
+
//#endregion
|
|
2324
|
+
//#region src/validators/contact.schema.d.ts
|
|
2325
|
+
declare const createContactSchema: z.ZodObject<{
|
|
2326
|
+
name: z.ZodObject<{
|
|
2327
|
+
given: z.ZodString;
|
|
2328
|
+
family: z.ZodDefault<z.ZodString>;
|
|
2329
|
+
middle: z.ZodOptional<z.ZodString>;
|
|
2330
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
2331
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
2332
|
+
preferred: z.ZodOptional<z.ZodString>;
|
|
2333
|
+
}, z.core.$strip>;
|
|
2334
|
+
contact: z.ZodDefault<z.ZodObject<{
|
|
2335
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2336
|
+
personalEmail: z.ZodOptional<z.ZodString>;
|
|
2337
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
2338
|
+
alternatePhone: z.ZodOptional<z.ZodString>;
|
|
2339
|
+
whatsapp: z.ZodOptional<z.ZodString>;
|
|
2340
|
+
telegram: z.ZodOptional<z.ZodString>;
|
|
2341
|
+
linkedin: z.ZodOptional<z.ZodString>;
|
|
2342
|
+
instagram: z.ZodOptional<z.ZodString>;
|
|
2343
|
+
}, z.core.$strip>>;
|
|
2344
|
+
jobTitle: z.ZodOptional<z.ZodString>;
|
|
2345
|
+
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2346
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2347
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2348
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2349
|
+
}, z.core.$strip>;
|
|
2350
|
+
declare const updateContactSchema: z.ZodObject<{
|
|
2351
|
+
name: z.ZodOptional<z.ZodObject<{
|
|
2352
|
+
given: z.ZodString;
|
|
2353
|
+
family: z.ZodDefault<z.ZodString>;
|
|
2354
|
+
middle: z.ZodOptional<z.ZodString>;
|
|
2355
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
2356
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
2357
|
+
preferred: z.ZodOptional<z.ZodString>;
|
|
2358
|
+
}, z.core.$strip>>;
|
|
2359
|
+
contact: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
2360
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2361
|
+
personalEmail: z.ZodOptional<z.ZodString>;
|
|
2362
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
2363
|
+
alternatePhone: z.ZodOptional<z.ZodString>;
|
|
2364
|
+
whatsapp: z.ZodOptional<z.ZodString>;
|
|
2365
|
+
telegram: z.ZodOptional<z.ZodString>;
|
|
2366
|
+
linkedin: z.ZodOptional<z.ZodString>;
|
|
2367
|
+
instagram: z.ZodOptional<z.ZodString>;
|
|
2368
|
+
}, z.core.$strip>>>;
|
|
2369
|
+
jobTitle: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2370
|
+
accountId: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
|
|
2371
|
+
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2372
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
2373
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2374
|
+
}, z.core.$strip>;
|
|
2375
|
+
declare const contactFilterSchema: z.ZodObject<{
|
|
2376
|
+
accountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2377
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2378
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2379
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2380
|
+
}, z.core.$strip>;
|
|
2381
|
+
type CreateContactDto = z.infer<typeof createContactSchema>;
|
|
2382
|
+
type UpdateContactDto = z.infer<typeof updateContactSchema>;
|
|
2383
|
+
//#endregion
|
|
2384
|
+
//#region src/validators/account.schema.d.ts
|
|
2385
|
+
declare const createAccountSchema: z.ZodObject<{
|
|
2386
|
+
name: z.ZodString;
|
|
2387
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
2388
|
+
industry: z.ZodOptional<z.ZodString>;
|
|
2389
|
+
sizeBucket: z.ZodOptional<z.ZodString>;
|
|
2390
|
+
annualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
2391
|
+
annualRevenueCurrency: z.ZodOptional<z.ZodString>;
|
|
2392
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2393
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2394
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2395
|
+
}, z.core.$strip>;
|
|
2396
|
+
declare const updateAccountSchema: z.ZodObject<{
|
|
2397
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2398
|
+
domain: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2399
|
+
industry: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2400
|
+
sizeBucket: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2401
|
+
annualRevenueAmount: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
2402
|
+
annualRevenueCurrency: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2403
|
+
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2404
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
2405
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2406
|
+
}, z.core.$strip>;
|
|
2407
|
+
declare const accountFilterSchema: z.ZodObject<{
|
|
2408
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
2409
|
+
industry: z.ZodOptional<z.ZodString>;
|
|
2410
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2411
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2412
|
+
}, z.core.$strip>;
|
|
2413
|
+
type CreateAccountDto = z.infer<typeof createAccountSchema>;
|
|
2414
|
+
type UpdateAccountDto = z.infer<typeof updateAccountSchema>;
|
|
2415
|
+
//#endregion
|
|
2416
|
+
//#region src/validators/campaign.schema.d.ts
|
|
2417
|
+
declare const createCampaignSchema: z.ZodObject<{
|
|
2418
|
+
name: z.ZodString;
|
|
2419
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2420
|
+
utmSource: z.ZodOptional<z.ZodString>;
|
|
2421
|
+
utmMedium: z.ZodOptional<z.ZodString>;
|
|
2422
|
+
utmCampaign: z.ZodOptional<z.ZodString>;
|
|
2423
|
+
startDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2424
|
+
endDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2425
|
+
budgetAmount: z.ZodOptional<z.ZodNumber>;
|
|
2426
|
+
expectedRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
2427
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
2428
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2429
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2430
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2431
|
+
}, z.core.$strip>;
|
|
2432
|
+
declare const updateCampaignSchema: z.ZodObject<{
|
|
2433
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2434
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2435
|
+
utmSource: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2436
|
+
utmMedium: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2437
|
+
utmCampaign: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2438
|
+
startDate: z.ZodOptional<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
2439
|
+
endDate: z.ZodOptional<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
2440
|
+
budgetAmount: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
2441
|
+
expectedRevenueAmount: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
2442
|
+
currency: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2443
|
+
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2444
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
2445
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2446
|
+
}, z.core.$strip>;
|
|
2447
|
+
declare const completeCampaignSchema: z.ZodObject<{
|
|
2448
|
+
by: z.ZodOptional<z.ZodString>;
|
|
2449
|
+
note: z.ZodOptional<z.ZodString>;
|
|
2450
|
+
actualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
2451
|
+
}, z.core.$strip>;
|
|
2452
|
+
declare const campaignFilterSchema: z.ZodObject<{
|
|
2453
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2454
|
+
draft: "draft";
|
|
2455
|
+
active: "active";
|
|
2456
|
+
paused: "paused";
|
|
2457
|
+
completed: "completed";
|
|
2458
|
+
archived: "archived";
|
|
2459
|
+
}>>;
|
|
2460
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2461
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2462
|
+
startDateFrom: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2463
|
+
startDateTo: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2464
|
+
}, z.core.$strip>;
|
|
2465
|
+
type CreateCampaignDto = z.infer<typeof createCampaignSchema>;
|
|
2466
|
+
type UpdateCampaignDto = z.infer<typeof updateCampaignSchema>;
|
|
2467
|
+
type CompleteCampaignDto = z.infer<typeof completeCampaignSchema>;
|
|
2468
|
+
//#endregion
|
|
2469
|
+
//#region src/validators/subscription.schema.d.ts
|
|
2470
|
+
declare const subscribeSchema: z.ZodObject<{
|
|
2471
|
+
contactId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2472
|
+
campaignId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2473
|
+
source: z.ZodOptional<z.ZodString>;
|
|
2474
|
+
consentIpAddress: z.ZodOptional<z.ZodString>;
|
|
2475
|
+
consentUserAgent: z.ZodOptional<z.ZodString>;
|
|
2476
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2477
|
+
requireDoubleOptIn: z.ZodOptional<z.ZodBoolean>;
|
|
2478
|
+
}, z.core.$strip>;
|
|
2479
|
+
declare const confirmSubscriptionSchema: z.ZodObject<{
|
|
2480
|
+
token: z.ZodString;
|
|
2481
|
+
}, z.core.$strip>;
|
|
2482
|
+
declare const unsubscribeSchema: z.ZodObject<{
|
|
2483
|
+
token: z.ZodString;
|
|
2484
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
2485
|
+
}, z.core.$strip>;
|
|
2486
|
+
declare const subscriptionFilterSchema: z.ZodObject<{
|
|
2487
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2488
|
+
pending: "pending";
|
|
2489
|
+
confirmed: "confirmed";
|
|
2490
|
+
unsubscribed: "unsubscribed";
|
|
2491
|
+
bounced: "bounced";
|
|
2492
|
+
complained: "complained";
|
|
2493
|
+
}>>;
|
|
2494
|
+
contactId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2495
|
+
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2496
|
+
}, z.core.$strip>;
|
|
2497
|
+
type SubscribeDto = z.infer<typeof subscribeSchema>;
|
|
2498
|
+
type ConfirmSubscriptionDto = z.infer<typeof confirmSubscriptionSchema>;
|
|
2499
|
+
type UnsubscribeDto = z.infer<typeof unsubscribeSchema>;
|
|
2500
|
+
//#endregion
|
|
2501
|
+
//#region src/validators/suppression.schema.d.ts
|
|
2502
|
+
declare const suppressSchema: z.ZodObject<{
|
|
2503
|
+
email: z.ZodString;
|
|
2504
|
+
reason: z.ZodEnum<{
|
|
2505
|
+
bounce: "bounce";
|
|
2506
|
+
complaint: "complaint";
|
|
2507
|
+
unsubscribe: "unsubscribe";
|
|
2508
|
+
manual: "manual";
|
|
2509
|
+
}>;
|
|
2510
|
+
source: z.ZodOptional<z.ZodString>;
|
|
2511
|
+
subjectKind: z.ZodOptional<z.ZodString>;
|
|
2512
|
+
subjectId: z.ZodOptional<z.ZodString>;
|
|
2513
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2514
|
+
}, z.core.$strip>;
|
|
2515
|
+
declare const unsuppressSchema: z.ZodObject<{
|
|
2516
|
+
email: z.ZodString;
|
|
2517
|
+
}, z.core.$strip>;
|
|
2518
|
+
declare const suppressionFilterSchema: z.ZodObject<{
|
|
2519
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2520
|
+
reason: z.ZodOptional<z.ZodEnum<{
|
|
2521
|
+
bounce: "bounce";
|
|
2522
|
+
complaint: "complaint";
|
|
2523
|
+
unsubscribe: "unsubscribe";
|
|
2524
|
+
manual: "manual";
|
|
2525
|
+
}>>;
|
|
2526
|
+
}, z.core.$strip>;
|
|
2527
|
+
type SuppressDto = z.infer<typeof suppressSchema>;
|
|
2528
|
+
type UnsuppressDto = z.infer<typeof unsuppressSchema>;
|
|
2529
|
+
//#endregion
|
|
2530
|
+
//#region src/validators/activity.schema.d.ts
|
|
2531
|
+
declare const planActivitySchema: z.ZodObject<{
|
|
2532
|
+
type: z.ZodEnum<{
|
|
2533
|
+
call: "call";
|
|
2534
|
+
email: "email";
|
|
2535
|
+
meeting: "meeting";
|
|
2536
|
+
task: "task";
|
|
2537
|
+
note: "note";
|
|
2538
|
+
sms: "sms";
|
|
2539
|
+
social: "social";
|
|
2540
|
+
demo: "demo";
|
|
2541
|
+
other: "other";
|
|
2542
|
+
}>;
|
|
2543
|
+
subjectKind: z.ZodEnum<{
|
|
2544
|
+
lead: "lead";
|
|
2545
|
+
opportunity: "opportunity";
|
|
2546
|
+
contact: "contact";
|
|
2547
|
+
account: "account";
|
|
2548
|
+
}>;
|
|
2549
|
+
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2550
|
+
title: z.ZodString;
|
|
2551
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2552
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2553
|
+
participantIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2554
|
+
dueDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2555
|
+
externalRef: z.ZodOptional<z.ZodString>;
|
|
2556
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2557
|
+
}, z.core.$strip>;
|
|
2558
|
+
declare const updateActivitySchema: z.ZodObject<{
|
|
2559
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
2560
|
+
call: "call";
|
|
2561
|
+
email: "email";
|
|
2562
|
+
meeting: "meeting";
|
|
2563
|
+
task: "task";
|
|
2564
|
+
note: "note";
|
|
2565
|
+
sms: "sms";
|
|
2566
|
+
social: "social";
|
|
2567
|
+
demo: "demo";
|
|
2568
|
+
other: "other";
|
|
2569
|
+
}>>;
|
|
2570
|
+
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
2571
|
+
lead: "lead";
|
|
2572
|
+
opportunity: "opportunity";
|
|
2573
|
+
contact: "contact";
|
|
2574
|
+
account: "account";
|
|
2575
|
+
}>>;
|
|
2576
|
+
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2577
|
+
title: z.ZodOptional<z.ZodString>;
|
|
2578
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2579
|
+
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2580
|
+
participantIds: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
2581
|
+
dueDate: z.ZodOptional<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
2582
|
+
externalRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2583
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2584
|
+
}, z.core.$strip>;
|
|
2585
|
+
declare const cancelActivitySchema: z.ZodObject<{
|
|
2586
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
2587
|
+
}, z.core.$strip>;
|
|
2588
|
+
declare const activityFilterSchema: z.ZodObject<{
|
|
2589
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
2590
|
+
call: "call";
|
|
2591
|
+
email: "email";
|
|
2592
|
+
meeting: "meeting";
|
|
2593
|
+
task: "task";
|
|
2594
|
+
note: "note";
|
|
2595
|
+
sms: "sms";
|
|
2596
|
+
social: "social";
|
|
2597
|
+
demo: "demo";
|
|
2598
|
+
other: "other";
|
|
2599
|
+
}>>;
|
|
2600
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2601
|
+
completed: "completed";
|
|
2602
|
+
planned: "planned";
|
|
2603
|
+
in_progress: "in_progress";
|
|
2604
|
+
cancelled: "cancelled";
|
|
2605
|
+
}>>;
|
|
2606
|
+
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
2607
|
+
lead: "lead";
|
|
2608
|
+
opportunity: "opportunity";
|
|
2609
|
+
contact: "contact";
|
|
2610
|
+
account: "account";
|
|
2611
|
+
}>>;
|
|
2612
|
+
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2613
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2614
|
+
dueDateFrom: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2615
|
+
dueDateTo: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
2616
|
+
}, z.core.$strip>;
|
|
2617
|
+
type PlanActivityDto = z.infer<typeof planActivitySchema>;
|
|
2618
|
+
type CancelActivityDto = z.infer<typeof cancelActivitySchema>;
|
|
2619
|
+
//#endregion
|
|
2620
|
+
//#region src/validators/note.schema.d.ts
|
|
2621
|
+
declare const addNoteSchema: z.ZodObject<{
|
|
2622
|
+
subjectKind: z.ZodEnum<{
|
|
2623
|
+
lead: "lead";
|
|
2624
|
+
opportunity: "opportunity";
|
|
2625
|
+
contact: "contact";
|
|
2626
|
+
account: "account";
|
|
2627
|
+
}>;
|
|
2628
|
+
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2629
|
+
body: z.ZodString;
|
|
2630
|
+
authorId: z.ZodOptional<z.ZodString>;
|
|
2631
|
+
pinned: z.ZodOptional<z.ZodBoolean>;
|
|
2632
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2633
|
+
}, z.core.$strip>;
|
|
2634
|
+
declare const updateNoteSchema: z.ZodObject<{
|
|
2635
|
+
body: z.ZodOptional<z.ZodString>;
|
|
2636
|
+
pinned: z.ZodOptional<z.ZodBoolean>;
|
|
2637
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2638
|
+
}, z.core.$strip>;
|
|
2639
|
+
declare const noteFilterSchema: z.ZodObject<{
|
|
2640
|
+
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
2641
|
+
lead: "lead";
|
|
2642
|
+
opportunity: "opportunity";
|
|
2643
|
+
contact: "contact";
|
|
2644
|
+
account: "account";
|
|
2645
|
+
}>>;
|
|
2646
|
+
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2647
|
+
authorId: z.ZodOptional<z.ZodString>;
|
|
2648
|
+
pinned: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
2649
|
+
}, z.core.$strip>;
|
|
2650
|
+
type AddNoteDto = z.infer<typeof addNoteSchema>;
|
|
2651
|
+
type UpdateNoteDto = z.infer<typeof updateNoteSchema>;
|
|
2652
|
+
//#endregion
|
|
2653
|
+
//#region src/validators/loss-reason.schema.d.ts
|
|
2654
|
+
declare const createLossReasonSchema: z.ZodObject<{
|
|
2655
|
+
name: z.ZodString;
|
|
2656
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2657
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
2658
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
2659
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2660
|
+
}, z.core.$strip>;
|
|
2661
|
+
declare const updateLossReasonSchema: z.ZodObject<{
|
|
2662
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2663
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2664
|
+
isActive: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
2665
|
+
sequence: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
2666
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2667
|
+
}, z.core.$strip>;
|
|
2668
|
+
declare const lossReasonFilterSchema: z.ZodObject<{
|
|
2669
|
+
isActive: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
2670
|
+
}, z.core.$strip>;
|
|
2671
|
+
type CreateLossReasonDto = z.infer<typeof createLossReasonSchema>;
|
|
2672
|
+
type UpdateLossReasonDto = z.infer<typeof updateLossReasonSchema>;
|
|
2673
|
+
//#endregion
|
|
2674
|
+
//#region src/validators/email-event.schema.d.ts
|
|
2675
|
+
declare const recordEmailEventSchema: z.ZodObject<{
|
|
2676
|
+
subjectKind: z.ZodEnum<{
|
|
2677
|
+
contact: "contact";
|
|
2678
|
+
subscription: "subscription";
|
|
2679
|
+
}>;
|
|
2680
|
+
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2681
|
+
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2682
|
+
messageId: z.ZodOptional<z.ZodString>;
|
|
2683
|
+
url: z.ZodOptional<z.ZodString>;
|
|
2684
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
2685
|
+
ip: z.ZodOptional<z.ZodString>;
|
|
2686
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2687
|
+
}, z.core.$strip>;
|
|
2688
|
+
declare const emailEventFilterSchema: z.ZodObject<{
|
|
2689
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
2690
|
+
open: "open";
|
|
2691
|
+
click: "click";
|
|
2692
|
+
bounce: "bounce";
|
|
2693
|
+
complaint: "complaint";
|
|
2694
|
+
unsubscribe: "unsubscribe";
|
|
2695
|
+
}>>;
|
|
2696
|
+
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
2697
|
+
contact: "contact";
|
|
2698
|
+
subscription: "subscription";
|
|
2699
|
+
}>>;
|
|
2700
|
+
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2701
|
+
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2702
|
+
messageId: z.ZodOptional<z.ZodString>;
|
|
2703
|
+
}, z.core.$strip>;
|
|
2704
|
+
type RecordEmailEventDto = z.infer<typeof recordEmailEventSchema>;
|
|
2705
|
+
//#endregion
|
|
2706
|
+
//#region src/validators/sequence.schema.d.ts
|
|
2707
|
+
declare const sequenceStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2708
|
+
id: z.ZodString;
|
|
2709
|
+
type: z.ZodLiteral<"SEND_EMAIL">;
|
|
2710
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2711
|
+
subject: z.ZodString;
|
|
2712
|
+
htmlBody: z.ZodString;
|
|
2713
|
+
fromName: z.ZodOptional<z.ZodString>;
|
|
2714
|
+
fromEmail: z.ZodOptional<z.ZodString>;
|
|
2715
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2716
|
+
id: z.ZodString;
|
|
2717
|
+
type: z.ZodLiteral<"DELAY">;
|
|
2718
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2719
|
+
settings: z.ZodObject<{
|
|
2720
|
+
days: z.ZodOptional<z.ZodNumber>;
|
|
2721
|
+
hours: z.ZodOptional<z.ZodNumber>;
|
|
2722
|
+
minutes: z.ZodOptional<z.ZodNumber>;
|
|
2723
|
+
}, z.core.$strip>;
|
|
2724
|
+
}, z.core.$strip>], "type">;
|
|
2725
|
+
declare const createSequenceSchema: z.ZodObject<{
|
|
2726
|
+
name: z.ZodString;
|
|
2727
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2728
|
+
fromName: z.ZodOptional<z.ZodString>;
|
|
2729
|
+
fromEmail: z.ZodOptional<z.ZodString>;
|
|
2730
|
+
steps: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2731
|
+
id: z.ZodString;
|
|
2732
|
+
type: z.ZodLiteral<"SEND_EMAIL">;
|
|
2733
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2734
|
+
subject: z.ZodString;
|
|
2735
|
+
htmlBody: z.ZodString;
|
|
2736
|
+
fromName: z.ZodOptional<z.ZodString>;
|
|
2737
|
+
fromEmail: z.ZodOptional<z.ZodString>;
|
|
2738
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2739
|
+
id: z.ZodString;
|
|
2740
|
+
type: z.ZodLiteral<"DELAY">;
|
|
2741
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2742
|
+
settings: z.ZodObject<{
|
|
2743
|
+
days: z.ZodOptional<z.ZodNumber>;
|
|
2744
|
+
hours: z.ZodOptional<z.ZodNumber>;
|
|
2745
|
+
minutes: z.ZodOptional<z.ZodNumber>;
|
|
2746
|
+
}, z.core.$strip>;
|
|
2747
|
+
}, z.core.$strip>], "type">>>;
|
|
2748
|
+
replyDetectionEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
2749
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2750
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2751
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2752
|
+
}, z.core.$strip>;
|
|
2753
|
+
declare const updateSequenceSchema: z.ZodObject<{
|
|
2754
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2755
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2756
|
+
fromName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2757
|
+
fromEmail: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2758
|
+
steps: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2759
|
+
id: z.ZodString;
|
|
2760
|
+
type: z.ZodLiteral<"SEND_EMAIL">;
|
|
2761
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2762
|
+
subject: z.ZodString;
|
|
2763
|
+
htmlBody: z.ZodString;
|
|
2764
|
+
fromName: z.ZodOptional<z.ZodString>;
|
|
2765
|
+
fromEmail: z.ZodOptional<z.ZodString>;
|
|
2766
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2767
|
+
id: z.ZodString;
|
|
2768
|
+
type: z.ZodLiteral<"DELAY">;
|
|
2769
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2770
|
+
settings: z.ZodObject<{
|
|
2771
|
+
days: z.ZodOptional<z.ZodNumber>;
|
|
2772
|
+
hours: z.ZodOptional<z.ZodNumber>;
|
|
2773
|
+
minutes: z.ZodOptional<z.ZodNumber>;
|
|
2774
|
+
}, z.core.$strip>;
|
|
2775
|
+
}, z.core.$strip>], "type">>>>;
|
|
2776
|
+
replyDetectionEnabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2777
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
2778
|
+
ownerId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2779
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
2780
|
+
}, z.core.$strip>;
|
|
2781
|
+
declare const sequenceFilterSchema: z.ZodObject<{
|
|
2782
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2783
|
+
draft: "draft";
|
|
2784
|
+
active: "active";
|
|
2785
|
+
paused: "paused";
|
|
2786
|
+
archived: "archived";
|
|
2787
|
+
}>>;
|
|
2788
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
2789
|
+
tags: z.ZodOptional<z.ZodString>;
|
|
2790
|
+
search: z.ZodOptional<z.ZodString>;
|
|
2791
|
+
page: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
2792
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
2793
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
2794
|
+
}, z.core.$strip>;
|
|
2795
|
+
type CreateSequenceInput = z.infer<typeof createSequenceSchema>;
|
|
2796
|
+
type UpdateSequenceInput = z.infer<typeof updateSequenceSchema>;
|
|
2797
|
+
type SequenceFilterInput = z.infer<typeof sequenceFilterSchema>;
|
|
2798
|
+
declare namespace index_d_exports {
|
|
2799
|
+
export { AddNoteDto, CancelActivityDto, CloseLossDto, CloseWinDto, CompleteCampaignDto, ConfirmSubscriptionDto, ConvertLeadDto, CreateAccountDto, CreateCampaignDto, CreateContactDto, CreateLeadDto, CreateLossReasonDto, CreatePipelineDto, CreateSequenceInput, LeadFilterDto, MoveStageDto, OpenOpportunityDto, OpportunityFilterDto, PlanActivityDto, RecordEmailEventDto, SequenceFilterInput, StageInputDto, SubscribeDto, SuppressDto, UnsubscribeDto, UnsuppressDto, UpdateAccountDto, UpdateCampaignDto, UpdateContactDto, UpdateLeadDto, UpdateLossReasonDto, UpdateNoteDto, UpdatePipelineDto, UpdateSequenceInput, accountFilterSchema, activityFilterSchema, addNoteSchema, campaignFilterSchema, cancelActivitySchema, closeLossSchema, closeWinSchema, completeCampaignSchema, confirmSubscriptionSchema, contactFilterSchema, convertLeadSchema, createAccountSchema, createCampaignSchema, createContactSchema, createLeadSchema, createLossReasonSchema, createPipelineSchema, createSequenceSchema, currencyCodeSchema, emailEventFilterSchema, leadFilterSchema, lossReasonFilterSchema, metadataSchema, moneyAmountSchema, moveStageSchema, noteFilterSchema, objectIdLike, openOpportunitySchema, opportunityFilterSchema, pipelineFilterSchema, planActivitySchema, recordEmailEventSchema, sequenceFilterSchema, sequenceStepSchema, stageInputSchemaExport, subscribeSchema, subscriptionFilterSchema, suppressSchema, suppressionFilterSchema, tagsSchema, unsubscribeSchema, unsuppressSchema, updateAccountSchema, updateActivitySchema, updateCampaignSchema, updateContactSchema, updateLeadSchema, updateLossReasonSchema, updateNoteSchema, updatePipelineSchema, updateSequenceSchema };
|
|
1485
2800
|
}
|
|
1486
2801
|
//#endregion
|
|
1487
|
-
export {
|
|
2802
|
+
export { ACTIVITY_MACHINE, ACTIVITY_STATUSES, ACTIVITY_TRANSITIONS, ACTIVITY_TYPES, AccountAssigned, AccountCreated, AccountEnriched, AccountMerged, AccountRepository, AccountRepositoryDeps, AccountUpdated, ActivityCancelled, ActivityCompleted, ActivityOutcomeRecorded, ActivityPlanned, ActivityRepository, ActivityRepositoryDeps, ActivityRescheduled, type ActivityStatus, type ActivityType, AlreadyEnrolledError, CAMPAIGN_MACHINE, CAMPAIGN_STATUSES, CAMPAIGN_TRANSITIONS, CONVERSATION_CHANNELS, CONVERSATION_PARTICIPANT_KINDS, CONVERSATION_STATUSES, CRM_EVENTS, CRM_MODEL_NAMES, CampaignActivated, CampaignArchived, CampaignCompleted, CampaignCreated, CampaignPaused, CampaignRepository, CampaignRepositoryDeps, CampaignResumed, type CampaignStatus, CloseInput, ContactAssigned, ContactCreated, ContactEnriched, ContactMerged, ContactRepository, ContactRepositoryDeps, ContactUpdated, ConversationAssigned, type ConversationChannel, ConversationCreated, type ConversationParticipantKind, ConversationReopened, ConversationRepository, ConversationRepositoryDeps, ConversationResolved, type ConversationStatus, ConversionRow, ConvertLeadInput, ConvertResult, CreateCrmRepositoriesDeps, CreateModelsOptions, CrmConfig, CrmContext, CrmEngine, CrmError, CrmEventDefinition, CrmEventDispatcher, type CrmEventDispatcherOptions, CrmEventName, CrmEventSchema, CrmLogger, CrmModels, CrmRepositories, DuplicateCampaignError, DuplicateLeadError, DuplicateSubscriptionError, EMAIL_EVENT_KINDS, EMAIL_EVENT_SUBJECT_KINDS, ENROLLMENT_MACHINE, ENROLLMENT_STATUSES, ENROLLMENT_SUBJECT_KINDS, ENROLLMENT_TRANSITIONS, EVENT_DERIVED_SUPPRESSION_REASONS, EmailEventBounced, EmailEventClicked, EmailEventComplained, type EmailEventKind, EmailEventOpened, EmailEventRepository, EmailEventRepositoryDeps, EmailEventSubjectKind, EmailEventUnsubscribed, EmptyPipelineError, EnrollInput, EnrollmentCompleted, EnrollmentCreated, EnrollmentExitReason, EnrollmentExited, EnrollmentPaused, EnrollmentRepository, EnrollmentRepositoryDeps, EnrollmentResumed, type EnrollmentStatus, EnrollmentStepSent, EnrollmentSubjectKind, ForecastOptions, ForecastRow, type IAccountDocument, type IActivityDocument, type ICampaignDocument, ICampaignStatusEntry, type IContactDocument, IContactInfoEmbedded, IContactName, type IConversationDocument, IDelayStep, type IEmailEventDocument, type IEnrollmentDocument, IEnrollmentStatusEntry, type ILeadDocument, ILeadStatusEntry, type ILossReasonDocument, IMessageAttachment, type IMessageDocument, type INoteDocument, type IOpportunityDocument, IOpportunityStatusEntry, type IPipelineDocument, ISendEmailStep, type ISequenceDocument, ISequenceStatusEntry, IStageDocument, IStepResult, type ISubscriptionDocument, ISubscriptionStatusEntry, type ISuppressionDocument, InProcessCrmBus, type InternalCrmContext, InvalidActivityTransitionError, InvalidCampaignTransitionError, InvalidConfirmationTokenError, InvalidEnrollmentTransitionError, InvalidLeadTransitionError, InvalidOpportunityTransitionError, InvalidSequenceTransitionError, InvalidSubscriptionTransitionError, InvalidUnsubscribeTokenError, LEAD_MACHINE, LEAD_STATUSES, LEAD_TRANSITIONS, LeadAlreadyConvertedError, LeadAssigned, LeadConverted, LeadCreated, LeadDisqualified, LeadEnriched, LeadInput, LeadRepository, LeadRepositoryDeps, LeadScored, LeadScorer, LeadService, LeadServiceDeps, type LeadStatus, LeadStatusChanged, LossReasonRepository, LossReasonRepositoryDeps, MESSAGE_DELIVERY_STATUSES, MESSAGE_DIRECTIONS, MergeAccountInput, MergeContactInput, type MessageDeliveryStatus, type MessageDirection, MessageReceived, MessageRepository, MessageRepositoryDeps, MessageSent, MoveStageInput, NotFoundError, NoteAdded, NoteRepository, NoteRepositoryDeps, OPPORTUNITY_MACHINE, OPPORTUNITY_STATUSES, OPPORTUNITY_TRANSITIONS, OpenConversationInput, OpenOpportunityInput, OpportunityAbandoned, OpportunityAmountChanged, OpportunityAssigned, OpportunityCreated, OpportunityExtended, OpportunityForecast, OpportunityLost, OpportunityRepository, OpportunityRepositoryDeps, OpportunityStageAdvanced, OpportunityStageRegressed, type OpportunityStatus, OpportunityWon, PENDING_EVENTS, PipelineArchived, PipelineCreated, PipelineRepository, PipelineRepositoryDeps, RecordEmailEventInput, RecordMessageInput, ReplySubject, ResolvedCrmConfig, type RunUnitConfig, SEQUENCE_MACHINE, SEQUENCE_STATUSES, SEQUENCE_TRANSITIONS, SUBJECT_KINDS, SUBSCRIPTION_MACHINE, SUBSCRIPTION_STATUSES, SUBSCRIPTION_TRANSITIONS, SUPPRESSION_REASONS, SchemaBuildConfig, SequenceActivated, SequenceArchived, SequenceCreated, SequencePaused, SequenceRepository, SequenceRepositoryDeps, type SequenceStatus, SequenceStep, StageNotInPipelineError, type StatusChangeEntry, type StatusHistory, StepResultStatus, type SubjectKind, SubscribeInput, SubscriptionBounced, SubscriptionComplained, SubscriptionConfirmed, SubscriptionCreated, SubscriptionRepository, SubscriptionRepositoryDeps, type SubscriptionStatus, SubscriptionUnsubscribed, SuppressInput, SuppressionAdded, type SuppressionReason, SuppressionRemoved, SuppressionRepository, SuppressionRepositoryDeps, TenantFieldType, UnmanagedSessionError, _ModelTypes, appendStatus, buildAccountSchema, buildActivitySchema, buildCampaignSchema, buildContactSchema, buildConversationSchema, buildEmailEventSchema, buildEnrollmentSchema, buildLeadSchema, buildLossReasonSchema, buildMessageSchema, buildNoteSchema, buildOpportunitySchema, buildPipelineSchema, buildSequenceSchema, buildSubscriptionSchema, buildSuppressionSchema, canTransitionActivity, canTransitionCampaign, canTransitionEnrollment, canTransitionLead, canTransitionOpportunity, canTransitionSequence, canTransitionSubscription, composeScorers, createAccountModel, createActivityModel, createCampaignModel, createContactModel, createConversationModel, createCrm, createCrmModels, createCrmRepositories, createEmailEventModel, createEvent, createLeadModel, createLossReasonModel, createMessageModel, createNoteModel, createOpportunityModel, createPipelineModel, createSubscriptionModel, crmEventDefinitions, defaultLeadScorer, flushPending, forecast, lastTransitionTo, latestEntry, pipelineConversion, runUnit, tenantFieldDef, timeInStatus, index_d_exports as validators };
|