@classytic/crm 1.1.0 → 1.2.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 +531 -500
- package/dist/events.d.ts +182 -158
- package/dist/index.d.ts +450 -426
- package/dist/index.js +16 -4
- package/package.json +82 -79
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { HttpError } from "@classytic/repo-core/errors";
|
|
|
13
13
|
* Context key for the post-commit event queue. `Symbol.for` so the host
|
|
14
14
|
* and the package agree on the key even across duplicated installs.
|
|
15
15
|
*/
|
|
16
|
-
declare const PENDING_EVENTS: unique symbol;
|
|
16
|
+
export declare const PENDING_EVENTS: unique symbol;
|
|
17
17
|
/** CrmContext as seen inside a unit of work — carries the deferred queue. */
|
|
18
18
|
type InternalCrmContext = CrmContext & {
|
|
19
19
|
[PENDING_EVENTS]?: DomainEvent[];
|
|
@@ -35,7 +35,7 @@ interface CrmEventDispatcherOptions {
|
|
|
35
35
|
* (host-facing surface unchanged); domain verbs call `dispatch(ctx, event)`
|
|
36
36
|
* so session/outbox/queue routing happens in ONE place.
|
|
37
37
|
*/
|
|
38
|
-
declare class CrmEventDispatcher implements EventTransport {
|
|
38
|
+
export declare class CrmEventDispatcher implements EventTransport {
|
|
39
39
|
readonly transport: EventTransport;
|
|
40
40
|
private readonly outbox;
|
|
41
41
|
private readonly logger;
|
|
@@ -57,11 +57,11 @@ declare class CrmEventDispatcher implements EventTransport {
|
|
|
57
57
|
* Hosts composing their own outer transaction call this after commit;
|
|
58
58
|
* most should use `engine.withTransaction(ctx, fn)` instead.
|
|
59
59
|
*/
|
|
60
|
-
declare function flushPending(transport: Pick<EventTransport, 'publish'> | undefined, events: DomainEvent[], logger?: CrmLogger): Promise<void>;
|
|
60
|
+
export declare function flushPending(transport: Pick<EventTransport, 'publish'> | undefined, events: DomainEvent[], logger?: CrmLogger): Promise<void>;
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/engine/modules.d.ts
|
|
63
63
|
/** Coarse CRM feature bundles. Keep entity-level switches out of the API. */
|
|
64
|
-
interface CrmModulesConfig {
|
|
64
|
+
export interface CrmModulesConfig {
|
|
65
65
|
/** Operational sales CRM: leads, accounts, contacts, opportunities and follow-up. */
|
|
66
66
|
sales?: boolean | undefined;
|
|
67
67
|
/** Customer communication: conversations, messages, consent and email events. */
|
|
@@ -69,37 +69,37 @@ interface CrmModulesConfig {
|
|
|
69
69
|
/** Campaign and sequence automation. Implies engagement and sales. */
|
|
70
70
|
automation?: boolean | undefined;
|
|
71
71
|
}
|
|
72
|
-
interface ResolvedCrmModules {
|
|
72
|
+
export interface ResolvedCrmModules {
|
|
73
73
|
readonly sales: boolean;
|
|
74
74
|
readonly engagement: boolean;
|
|
75
75
|
readonly automation: boolean;
|
|
76
76
|
}
|
|
77
|
-
declare const ALL_CRM_MODULES: ResolvedCrmModules;
|
|
77
|
+
export declare const ALL_CRM_MODULES: ResolvedCrmModules;
|
|
78
78
|
/**
|
|
79
79
|
* Resolve module dependencies once at boot.
|
|
80
80
|
*
|
|
81
81
|
* Omitting `modules` preserves the pre-module package behaviour (everything
|
|
82
82
|
* enabled). Supplying it is opt-in: unspecified modules are disabled.
|
|
83
83
|
*/
|
|
84
|
-
declare function resolveCrmModules(modules: CrmModulesConfig | undefined): ResolvedCrmModules;
|
|
84
|
+
export declare function resolveCrmModules(modules: CrmModulesConfig | undefined): ResolvedCrmModules;
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region src/models/tenant-field.d.ts
|
|
87
|
-
interface SchemaBuildConfig {
|
|
87
|
+
export interface SchemaBuildConfig {
|
|
88
88
|
/** Canonical resolved tenant config. Engine plumbs this everywhere. */
|
|
89
89
|
tenant: ResolvedTenantConfig;
|
|
90
90
|
/** Optional Mongoose model namespace for hosts with generic model names. */
|
|
91
91
|
modelPrefix?: string | undefined;
|
|
92
92
|
}
|
|
93
|
-
declare function crmModelName(config: SchemaBuildConfig, base: string): string;
|
|
93
|
+
export declare function crmModelName(config: SchemaBuildConfig, base: string): string;
|
|
94
94
|
/**
|
|
95
95
|
* Tenant-column schema definition. Use this anywhere a model has
|
|
96
96
|
* `organizationId` — never write the raw type in a schema file.
|
|
97
97
|
*/
|
|
98
|
-
declare function tenantFieldDef(config: SchemaBuildConfig): SchemaDefinitionProperty;
|
|
98
|
+
export declare function tenantFieldDef(config: SchemaBuildConfig): SchemaDefinitionProperty;
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/models/pipeline.schema.d.ts
|
|
101
101
|
/** Mongoose document shape for a single embedded stage. */
|
|
102
|
-
interface IStageDocument {
|
|
102
|
+
export interface IStageDocument {
|
|
103
103
|
_id: import('mongoose').Types.ObjectId;
|
|
104
104
|
name: string;
|
|
105
105
|
/** Ascending order in the pipeline. Treated as identifier on `moveToStage`. */
|
|
@@ -110,7 +110,7 @@ interface IStageDocument {
|
|
|
110
110
|
description?: string;
|
|
111
111
|
}
|
|
112
112
|
/** Mongoose document shape for a Pipeline. */
|
|
113
|
-
interface IPipelineDocument {
|
|
113
|
+
export interface IPipelineDocument {
|
|
114
114
|
_id: import('mongoose').Types.ObjectId;
|
|
115
115
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
116
116
|
name: string;
|
|
@@ -124,8 +124,8 @@ interface IPipelineDocument {
|
|
|
124
124
|
createdAt: Date;
|
|
125
125
|
updatedAt: Date;
|
|
126
126
|
}
|
|
127
|
-
declare function buildPipelineSchema(config: SchemaBuildConfig): Schema<IPipelineDocument>;
|
|
128
|
-
declare function createPipelineModel(connection: Connection, config: SchemaBuildConfig): Model<IPipelineDocument>;
|
|
127
|
+
export declare function buildPipelineSchema(config: SchemaBuildConfig): Schema<IPipelineDocument>;
|
|
128
|
+
export declare function createPipelineModel(connection: Connection, config: SchemaBuildConfig): Model<IPipelineDocument>;
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/enums/lead-status.d.ts
|
|
131
131
|
/**
|
|
@@ -138,13 +138,13 @@ declare function createPipelineModel(connection: Connection, config: SchemaBuild
|
|
|
138
138
|
* disqualified — rejected (bad fit, spam, duplicate)
|
|
139
139
|
* nurturing — not ready now; parked for later outreach
|
|
140
140
|
*/
|
|
141
|
-
declare const LEAD_STATUSES: readonly [
|
|
141
|
+
export declare const LEAD_STATUSES: readonly ['new', 'contacted', 'qualified', 'converted', 'disqualified', 'nurturing'];
|
|
142
142
|
type LeadStatus = (typeof LEAD_STATUSES)[number];
|
|
143
|
-
declare const LEAD_TRANSITIONS: Record<LeadStatus, readonly LeadStatus[]>;
|
|
144
|
-
declare function canTransitionLead(from: LeadStatus, to: LeadStatus): boolean;
|
|
143
|
+
export declare const LEAD_TRANSITIONS: Record<LeadStatus, readonly LeadStatus[]>;
|
|
144
|
+
export declare function canTransitionLead(from: LeadStatus, to: LeadStatus): boolean;
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region src/models/lead.schema.d.ts
|
|
147
|
-
interface ILeadStatusEntry {
|
|
147
|
+
export interface ILeadStatusEntry {
|
|
148
148
|
status: LeadStatus;
|
|
149
149
|
occurredAt: Date;
|
|
150
150
|
by?: string;
|
|
@@ -156,14 +156,14 @@ interface ILeadStatusEntry {
|
|
|
156
156
|
* `LeadRepository.recordEngagement`. Read by the lead scorer alongside
|
|
157
157
|
* the firmographic fields. Zero-valued on old rows (nested default).
|
|
158
158
|
*/
|
|
159
|
-
interface ILeadEngagement {
|
|
159
|
+
export interface ILeadEngagement {
|
|
160
160
|
opens: number;
|
|
161
161
|
clicks: number;
|
|
162
162
|
replies: number;
|
|
163
163
|
activities: number;
|
|
164
164
|
lastEngagedAt?: Date;
|
|
165
165
|
}
|
|
166
|
-
interface ILeadDocument {
|
|
166
|
+
export interface ILeadDocument {
|
|
167
167
|
_id: import('mongoose').Types.ObjectId;
|
|
168
168
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
169
169
|
fullName: string;
|
|
@@ -192,8 +192,8 @@ interface ILeadDocument {
|
|
|
192
192
|
createdAt: Date;
|
|
193
193
|
updatedAt: Date;
|
|
194
194
|
}
|
|
195
|
-
declare function buildLeadSchema(config: SchemaBuildConfig): Schema<ILeadDocument>;
|
|
196
|
-
declare function createLeadModel(connection: Connection, config: SchemaBuildConfig): Model<ILeadDocument>;
|
|
195
|
+
export declare function buildLeadSchema(config: SchemaBuildConfig): Schema<ILeadDocument>;
|
|
196
|
+
export declare function createLeadModel(connection: Connection, config: SchemaBuildConfig): Model<ILeadDocument>;
|
|
197
197
|
//#endregion
|
|
198
198
|
//#region src/enums/opportunity-status.d.ts
|
|
199
199
|
/**
|
|
@@ -203,20 +203,20 @@ declare function createLeadModel(connection: Connection, config: SchemaBuildConf
|
|
|
203
203
|
* convention is to clone the opportunity rather than revive the
|
|
204
204
|
* terminal record.
|
|
205
205
|
*/
|
|
206
|
-
declare const OPPORTUNITY_STATUSES: readonly [
|
|
206
|
+
export declare const OPPORTUNITY_STATUSES: readonly ['open', 'won', 'lost', 'abandoned'];
|
|
207
207
|
type OpportunityStatus = (typeof OPPORTUNITY_STATUSES)[number];
|
|
208
|
-
declare const OPPORTUNITY_TRANSITIONS: Record<OpportunityStatus, readonly OpportunityStatus[]>;
|
|
209
|
-
declare function canTransitionOpportunity(from: OpportunityStatus, to: OpportunityStatus): boolean;
|
|
208
|
+
export declare const OPPORTUNITY_TRANSITIONS: Record<OpportunityStatus, readonly OpportunityStatus[]>;
|
|
209
|
+
export declare function canTransitionOpportunity(from: OpportunityStatus, to: OpportunityStatus): boolean;
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region src/models/opportunity.schema.d.ts
|
|
212
|
-
interface IOpportunityStatusEntry {
|
|
212
|
+
export interface IOpportunityStatusEntry {
|
|
213
213
|
status: OpportunityStatus;
|
|
214
214
|
stageId?: string;
|
|
215
215
|
occurredAt: Date;
|
|
216
216
|
by?: string;
|
|
217
217
|
note?: string;
|
|
218
218
|
}
|
|
219
|
-
interface IOpportunityDocument {
|
|
219
|
+
export interface IOpportunityDocument {
|
|
220
220
|
_id: import('mongoose').Types.ObjectId;
|
|
221
221
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
222
222
|
name: string;
|
|
@@ -239,11 +239,11 @@ interface IOpportunityDocument {
|
|
|
239
239
|
createdAt: Date;
|
|
240
240
|
updatedAt: Date;
|
|
241
241
|
}
|
|
242
|
-
declare function buildOpportunitySchema(config: SchemaBuildConfig): Schema<IOpportunityDocument>;
|
|
243
|
-
declare function createOpportunityModel(connection: Connection, config: SchemaBuildConfig): Model<IOpportunityDocument>;
|
|
242
|
+
export declare function buildOpportunitySchema(config: SchemaBuildConfig): Schema<IOpportunityDocument>;
|
|
243
|
+
export declare function createOpportunityModel(connection: Connection, config: SchemaBuildConfig): Model<IOpportunityDocument>;
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/models/contact.schema.d.ts
|
|
246
|
-
interface IContactName {
|
|
246
|
+
export interface IContactName {
|
|
247
247
|
given: string;
|
|
248
248
|
family: string;
|
|
249
249
|
middle?: string;
|
|
@@ -251,7 +251,7 @@ interface IContactName {
|
|
|
251
251
|
suffix?: string;
|
|
252
252
|
preferred?: string;
|
|
253
253
|
}
|
|
254
|
-
interface IContactInfoEmbedded {
|
|
254
|
+
export interface IContactInfoEmbedded {
|
|
255
255
|
email?: string;
|
|
256
256
|
personalEmail?: string;
|
|
257
257
|
phone?: string;
|
|
@@ -261,7 +261,7 @@ interface IContactInfoEmbedded {
|
|
|
261
261
|
linkedin?: string;
|
|
262
262
|
instagram?: string;
|
|
263
263
|
}
|
|
264
|
-
interface IContactDocument {
|
|
264
|
+
export interface IContactDocument {
|
|
265
265
|
_id: import('mongoose').Types.ObjectId;
|
|
266
266
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
267
267
|
name: IContactName;
|
|
@@ -276,11 +276,11 @@ interface IContactDocument {
|
|
|
276
276
|
createdAt: Date;
|
|
277
277
|
updatedAt: Date;
|
|
278
278
|
}
|
|
279
|
-
declare function buildContactSchema(config: SchemaBuildConfig): Schema<IContactDocument>;
|
|
280
|
-
declare function createContactModel(connection: Connection, config: SchemaBuildConfig): Model<IContactDocument>;
|
|
279
|
+
export declare function buildContactSchema(config: SchemaBuildConfig): Schema<IContactDocument>;
|
|
280
|
+
export declare function createContactModel(connection: Connection, config: SchemaBuildConfig): Model<IContactDocument>;
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/models/account.schema.d.ts
|
|
283
|
-
interface IAccountDocument {
|
|
283
|
+
export interface IAccountDocument {
|
|
284
284
|
_id: import('mongoose').Types.ObjectId;
|
|
285
285
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
286
286
|
name: string;
|
|
@@ -295,8 +295,8 @@ interface IAccountDocument {
|
|
|
295
295
|
createdAt: Date;
|
|
296
296
|
updatedAt: Date;
|
|
297
297
|
}
|
|
298
|
-
declare function buildAccountSchema(config: SchemaBuildConfig): Schema<IAccountDocument>;
|
|
299
|
-
declare function createAccountModel(connection: Connection, config: SchemaBuildConfig): Model<IAccountDocument>;
|
|
298
|
+
export declare function buildAccountSchema(config: SchemaBuildConfig): Schema<IAccountDocument>;
|
|
299
|
+
export declare function createAccountModel(connection: Connection, config: SchemaBuildConfig): Model<IAccountDocument>;
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/enums/campaign-status.d.ts
|
|
302
302
|
/**
|
|
@@ -308,19 +308,19 @@ declare function createAccountModel(connection: Connection, config: SchemaBuildC
|
|
|
308
308
|
* completed — finished its run; preserved for historical attribution
|
|
309
309
|
* archived — soft-hidden from the default UI; still queryable
|
|
310
310
|
*/
|
|
311
|
-
declare const CAMPAIGN_STATUSES: readonly [
|
|
311
|
+
export declare const CAMPAIGN_STATUSES: readonly ['draft', 'active', 'paused', 'completed', 'archived'];
|
|
312
312
|
type CampaignStatus = (typeof CAMPAIGN_STATUSES)[number];
|
|
313
|
-
declare const CAMPAIGN_TRANSITIONS: Record<CampaignStatus, readonly CampaignStatus[]>;
|
|
314
|
-
declare function canTransitionCampaign(from: CampaignStatus, to: CampaignStatus): boolean;
|
|
313
|
+
export declare const CAMPAIGN_TRANSITIONS: Record<CampaignStatus, readonly CampaignStatus[]>;
|
|
314
|
+
export declare function canTransitionCampaign(from: CampaignStatus, to: CampaignStatus): boolean;
|
|
315
315
|
//#endregion
|
|
316
316
|
//#region src/models/campaign.schema.d.ts
|
|
317
|
-
interface ICampaignStatusEntry {
|
|
317
|
+
export interface ICampaignStatusEntry {
|
|
318
318
|
status: CampaignStatus;
|
|
319
319
|
occurredAt: Date;
|
|
320
320
|
by?: string;
|
|
321
321
|
note?: string;
|
|
322
322
|
}
|
|
323
|
-
interface ICampaignDocument {
|
|
323
|
+
export interface ICampaignDocument {
|
|
324
324
|
_id: import('mongoose').Types.ObjectId;
|
|
325
325
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
326
326
|
name: string;
|
|
@@ -342,8 +342,8 @@ interface ICampaignDocument {
|
|
|
342
342
|
createdAt: Date;
|
|
343
343
|
updatedAt: Date;
|
|
344
344
|
}
|
|
345
|
-
declare function buildCampaignSchema(config: SchemaBuildConfig): Schema<ICampaignDocument>;
|
|
346
|
-
declare function createCampaignModel(connection: Connection, config: SchemaBuildConfig): Model<ICampaignDocument>;
|
|
345
|
+
export declare function buildCampaignSchema(config: SchemaBuildConfig): Schema<ICampaignDocument>;
|
|
346
|
+
export declare function createCampaignModel(connection: Connection, config: SchemaBuildConfig): Model<ICampaignDocument>;
|
|
347
347
|
//#endregion
|
|
348
348
|
//#region src/enums/subscription-status.d.ts
|
|
349
349
|
/**
|
|
@@ -359,19 +359,19 @@ declare function createCampaignModel(connection: Connection, config: SchemaBuild
|
|
|
359
359
|
* All terminal states are non-reopenable. Re-subscribing creates a new
|
|
360
360
|
* Subscription row — the audit trail of unsubscribes/bounces is preserved.
|
|
361
361
|
*/
|
|
362
|
-
declare const SUBSCRIPTION_STATUSES: readonly [
|
|
362
|
+
export declare const SUBSCRIPTION_STATUSES: readonly ['pending', 'confirmed', 'unsubscribed', 'bounced', 'complained'];
|
|
363
363
|
type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];
|
|
364
|
-
declare const SUBSCRIPTION_TRANSITIONS: Record<SubscriptionStatus, readonly SubscriptionStatus[]>;
|
|
365
|
-
declare function canTransitionSubscription(from: SubscriptionStatus, to: SubscriptionStatus): boolean;
|
|
364
|
+
export declare const SUBSCRIPTION_TRANSITIONS: Record<SubscriptionStatus, readonly SubscriptionStatus[]>;
|
|
365
|
+
export declare function canTransitionSubscription(from: SubscriptionStatus, to: SubscriptionStatus): boolean;
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/models/subscription.schema.d.ts
|
|
368
|
-
interface ISubscriptionStatusEntry {
|
|
368
|
+
export interface ISubscriptionStatusEntry {
|
|
369
369
|
status: SubscriptionStatus;
|
|
370
370
|
occurredAt: Date;
|
|
371
371
|
by?: string;
|
|
372
372
|
note?: string;
|
|
373
373
|
}
|
|
374
|
-
interface ISubscriptionDocument {
|
|
374
|
+
export interface ISubscriptionDocument {
|
|
375
375
|
_id: import('mongoose').Types.ObjectId;
|
|
376
376
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
377
377
|
contactId: import('mongoose').Types.ObjectId | string;
|
|
@@ -395,17 +395,17 @@ interface ISubscriptionDocument {
|
|
|
395
395
|
createdAt: Date;
|
|
396
396
|
updatedAt: Date;
|
|
397
397
|
}
|
|
398
|
-
declare function buildSubscriptionSchema(config: SchemaBuildConfig): Schema<ISubscriptionDocument>;
|
|
399
|
-
declare function createSubscriptionModel(connection: Connection, config: SchemaBuildConfig): Model<ISubscriptionDocument>;
|
|
398
|
+
export declare function buildSubscriptionSchema(config: SchemaBuildConfig): Schema<ISubscriptionDocument>;
|
|
399
|
+
export declare function createSubscriptionModel(connection: Connection, config: SchemaBuildConfig): Model<ISubscriptionDocument>;
|
|
400
400
|
//#endregion
|
|
401
401
|
//#region src/enums/suppression-reason.d.ts
|
|
402
402
|
/** Reasons derived 1:1 from an email engagement event kind. */
|
|
403
|
-
declare const EVENT_DERIVED_SUPPRESSION_REASONS: readonly ["bounce", "complaint", "unsubscribe"];
|
|
404
|
-
declare const SUPPRESSION_REASONS: readonly ["bounce", "complaint", "unsubscribe", "manual"];
|
|
403
|
+
export declare const EVENT_DERIVED_SUPPRESSION_REASONS: readonly ["bounce", "complaint", "unsubscribe"];
|
|
404
|
+
export declare const SUPPRESSION_REASONS: readonly ["bounce", "complaint", "unsubscribe", "manual"];
|
|
405
405
|
type SuppressionReason = (typeof SUPPRESSION_REASONS)[number];
|
|
406
406
|
//#endregion
|
|
407
407
|
//#region src/models/suppression.schema.d.ts
|
|
408
|
-
interface ISuppressionDocument {
|
|
408
|
+
export interface ISuppressionDocument {
|
|
409
409
|
_id: import('mongoose').Types.ObjectId;
|
|
410
410
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
411
411
|
/**
|
|
@@ -429,7 +429,7 @@ interface ISuppressionDocument {
|
|
|
429
429
|
createdAt: Date;
|
|
430
430
|
updatedAt: Date;
|
|
431
431
|
}
|
|
432
|
-
declare function buildSuppressionSchema(config: SchemaBuildConfig): Schema<ISuppressionDocument>;
|
|
432
|
+
export declare function buildSuppressionSchema(config: SchemaBuildConfig): Schema<ISuppressionDocument>;
|
|
433
433
|
//#endregion
|
|
434
434
|
//#region src/enums/activity.d.ts
|
|
435
435
|
/**
|
|
@@ -437,22 +437,22 @@ declare function buildSuppressionSchema(config: SchemaBuildConfig): Schema<ISupp
|
|
|
437
437
|
* string so hosts can extend; these constants cover the common
|
|
438
438
|
* channels that automation tooling typically keys off.
|
|
439
439
|
*/
|
|
440
|
-
declare const ACTIVITY_TYPES: readonly [
|
|
440
|
+
export declare const ACTIVITY_TYPES: readonly ['call', 'email', 'meeting', 'task', 'note', 'sms', 'social', 'demo', 'other'];
|
|
441
441
|
type ActivityType = (typeof ACTIVITY_TYPES)[number];
|
|
442
|
-
declare const ACTIVITY_STATUSES: readonly [
|
|
442
|
+
export declare const ACTIVITY_STATUSES: readonly ['planned', 'in_progress', 'completed', 'cancelled'];
|
|
443
443
|
type ActivityStatus = (typeof ACTIVITY_STATUSES)[number];
|
|
444
|
-
declare const ACTIVITY_TRANSITIONS: Record<ActivityStatus, readonly ActivityStatus[]>;
|
|
445
|
-
declare function canTransitionActivity(from: ActivityStatus, to: ActivityStatus): boolean;
|
|
444
|
+
export declare const ACTIVITY_TRANSITIONS: Record<ActivityStatus, readonly ActivityStatus[]>;
|
|
445
|
+
export declare function canTransitionActivity(from: ActivityStatus, to: ActivityStatus): boolean;
|
|
446
446
|
/**
|
|
447
447
|
* Kinds of entity an Activity can reference. Polymorphic linking lets
|
|
448
448
|
* hosts log a call against a Lead, an Opportunity, a Contact, or a
|
|
449
449
|
* stand-alone Account.
|
|
450
450
|
*/
|
|
451
|
-
declare const SUBJECT_KINDS: readonly [
|
|
451
|
+
export declare const SUBJECT_KINDS: readonly ['lead', 'opportunity', 'contact', 'account'];
|
|
452
452
|
type SubjectKind = (typeof SUBJECT_KINDS)[number];
|
|
453
453
|
//#endregion
|
|
454
454
|
//#region src/models/activity.schema.d.ts
|
|
455
|
-
interface IActivityDocument {
|
|
455
|
+
export interface IActivityDocument {
|
|
456
456
|
_id: import('mongoose').Types.ObjectId;
|
|
457
457
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
458
458
|
type: ActivityType;
|
|
@@ -470,11 +470,11 @@ interface IActivityDocument {
|
|
|
470
470
|
createdAt: Date;
|
|
471
471
|
updatedAt: Date;
|
|
472
472
|
}
|
|
473
|
-
declare function buildActivitySchema(config: SchemaBuildConfig): Schema<IActivityDocument>;
|
|
474
|
-
declare function createActivityModel(connection: Connection, config: SchemaBuildConfig): Model<IActivityDocument>;
|
|
473
|
+
export declare function buildActivitySchema(config: SchemaBuildConfig): Schema<IActivityDocument>;
|
|
474
|
+
export declare function createActivityModel(connection: Connection, config: SchemaBuildConfig): Model<IActivityDocument>;
|
|
475
475
|
//#endregion
|
|
476
476
|
//#region src/models/note.schema.d.ts
|
|
477
|
-
interface INoteDocument {
|
|
477
|
+
export interface INoteDocument {
|
|
478
478
|
_id: import('mongoose').Types.ObjectId;
|
|
479
479
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
480
480
|
subjectKind: SubjectKind;
|
|
@@ -486,11 +486,11 @@ interface INoteDocument {
|
|
|
486
486
|
createdAt: Date;
|
|
487
487
|
updatedAt: Date;
|
|
488
488
|
}
|
|
489
|
-
declare function buildNoteSchema(config: SchemaBuildConfig): Schema<INoteDocument>;
|
|
490
|
-
declare function createNoteModel(connection: Connection, config: SchemaBuildConfig): Model<INoteDocument>;
|
|
489
|
+
export declare function buildNoteSchema(config: SchemaBuildConfig): Schema<INoteDocument>;
|
|
490
|
+
export declare function createNoteModel(connection: Connection, config: SchemaBuildConfig): Model<INoteDocument>;
|
|
491
491
|
//#endregion
|
|
492
492
|
//#region src/models/loss-reason.schema.d.ts
|
|
493
|
-
interface ILossReasonDocument {
|
|
493
|
+
export interface ILossReasonDocument {
|
|
494
494
|
_id: import('mongoose').Types.ObjectId;
|
|
495
495
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
496
496
|
name: string;
|
|
@@ -502,8 +502,8 @@ interface ILossReasonDocument {
|
|
|
502
502
|
createdAt: Date;
|
|
503
503
|
updatedAt: Date;
|
|
504
504
|
}
|
|
505
|
-
declare function buildLossReasonSchema(config: SchemaBuildConfig): Schema<ILossReasonDocument>;
|
|
506
|
-
declare function createLossReasonModel(connection: Connection, config: SchemaBuildConfig): Model<ILossReasonDocument>;
|
|
505
|
+
export declare function buildLossReasonSchema(config: SchemaBuildConfig): Schema<ILossReasonDocument>;
|
|
506
|
+
export declare function createLossReasonModel(connection: Connection, config: SchemaBuildConfig): Model<ILossReasonDocument>;
|
|
507
507
|
//#endregion
|
|
508
508
|
//#region src/enums/email-event-kind.d.ts
|
|
509
509
|
/**
|
|
@@ -532,13 +532,13 @@ declare function createLossReasonModel(connection: Connection, config: SchemaBui
|
|
|
532
532
|
* categories so consumers can compute open rate, click rate, bounce rate
|
|
533
533
|
* without filtering kind themselves.
|
|
534
534
|
*/
|
|
535
|
-
declare const EMAIL_EVENT_KINDS: readonly [
|
|
535
|
+
export declare const EMAIL_EVENT_KINDS: readonly ['open', 'click', 'bounce', 'complaint', 'unsubscribe'];
|
|
536
536
|
type EmailEventKind = (typeof EMAIL_EVENT_KINDS)[number];
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/models/email-event.schema.d.ts
|
|
539
|
-
declare const EMAIL_EVENT_SUBJECT_KINDS: readonly [
|
|
540
|
-
type EmailEventSubjectKind = (typeof EMAIL_EVENT_SUBJECT_KINDS)[number];
|
|
541
|
-
interface IEmailEventDocument {
|
|
539
|
+
export declare const EMAIL_EVENT_SUBJECT_KINDS: readonly ['contact', 'subscription'];
|
|
540
|
+
export type EmailEventSubjectKind = (typeof EMAIL_EVENT_SUBJECT_KINDS)[number];
|
|
541
|
+
export interface IEmailEventDocument {
|
|
542
542
|
_id: import('mongoose').Types.ObjectId;
|
|
543
543
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
544
544
|
kind: EmailEventKind;
|
|
@@ -552,8 +552,8 @@ interface IEmailEventDocument {
|
|
|
552
552
|
metadata?: Record<string, unknown>;
|
|
553
553
|
createdAt: Date;
|
|
554
554
|
}
|
|
555
|
-
declare function buildEmailEventSchema(config: SchemaBuildConfig): Schema<IEmailEventDocument>;
|
|
556
|
-
declare function createEmailEventModel(connection: Connection, config: SchemaBuildConfig): Model<IEmailEventDocument>;
|
|
555
|
+
export declare function buildEmailEventSchema(config: SchemaBuildConfig): Schema<IEmailEventDocument>;
|
|
556
|
+
export declare function createEmailEventModel(connection: Connection, config: SchemaBuildConfig): Model<IEmailEventDocument>;
|
|
557
557
|
//#endregion
|
|
558
558
|
//#region src/enums/conversation.d.ts
|
|
559
559
|
/**
|
|
@@ -564,20 +564,20 @@ declare function createEmailEventModel(connection: Connection, config: SchemaBui
|
|
|
564
564
|
* The host's webhook adapters write to this surface — the CRM does not
|
|
565
565
|
* dial outward.
|
|
566
566
|
*/
|
|
567
|
-
declare const CONVERSATION_CHANNELS: readonly [
|
|
567
|
+
export declare const CONVERSATION_CHANNELS: readonly ['whatsapp', 'telegram', 'email', 'instagram_dm', 'sms', 'web_chat'];
|
|
568
568
|
type ConversationChannel = (typeof CONVERSATION_CHANNELS)[number];
|
|
569
|
-
declare const CONVERSATION_STATUSES: readonly [
|
|
569
|
+
export declare const CONVERSATION_STATUSES: readonly ['open', 'snoozed', 'resolved'];
|
|
570
570
|
type ConversationStatus = (typeof CONVERSATION_STATUSES)[number];
|
|
571
571
|
/** Conversations attach to either a Contact or a (yet-unconverted) Lead. */
|
|
572
|
-
declare const CONVERSATION_PARTICIPANT_KINDS: readonly [
|
|
572
|
+
export declare const CONVERSATION_PARTICIPANT_KINDS: readonly ['contact', 'lead'];
|
|
573
573
|
type ConversationParticipantKind = (typeof CONVERSATION_PARTICIPANT_KINDS)[number];
|
|
574
|
-
declare const MESSAGE_DIRECTIONS: readonly [
|
|
574
|
+
export declare const MESSAGE_DIRECTIONS: readonly ['inbound', 'outbound'];
|
|
575
575
|
type MessageDirection = (typeof MESSAGE_DIRECTIONS)[number];
|
|
576
|
-
declare const MESSAGE_DELIVERY_STATUSES: readonly [
|
|
576
|
+
export declare const MESSAGE_DELIVERY_STATUSES: readonly ['queued', 'sent', 'delivered', 'read', 'failed'];
|
|
577
577
|
type MessageDeliveryStatus = (typeof MESSAGE_DELIVERY_STATUSES)[number];
|
|
578
578
|
//#endregion
|
|
579
579
|
//#region src/models/conversation.schema.d.ts
|
|
580
|
-
interface IConversationDocument {
|
|
580
|
+
export interface IConversationDocument {
|
|
581
581
|
_id: import('mongoose').Types.ObjectId;
|
|
582
582
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
583
583
|
channel: ConversationChannel;
|
|
@@ -597,18 +597,18 @@ interface IConversationDocument {
|
|
|
597
597
|
createdAt: Date;
|
|
598
598
|
updatedAt: Date;
|
|
599
599
|
}
|
|
600
|
-
declare function buildConversationSchema(config: SchemaBuildConfig): Schema<IConversationDocument>;
|
|
601
|
-
declare function createConversationModel(connection: Connection, config: SchemaBuildConfig): Model<IConversationDocument>;
|
|
600
|
+
export declare function buildConversationSchema(config: SchemaBuildConfig): Schema<IConversationDocument>;
|
|
601
|
+
export declare function createConversationModel(connection: Connection, config: SchemaBuildConfig): Model<IConversationDocument>;
|
|
602
602
|
//#endregion
|
|
603
603
|
//#region src/models/message.schema.d.ts
|
|
604
|
-
interface IMessageAttachment {
|
|
604
|
+
export interface IMessageAttachment {
|
|
605
605
|
type: string;
|
|
606
606
|
url: string;
|
|
607
607
|
name?: string;
|
|
608
608
|
size?: number;
|
|
609
609
|
mimeType?: string;
|
|
610
610
|
}
|
|
611
|
-
interface IMessageDocument {
|
|
611
|
+
export interface IMessageDocument {
|
|
612
612
|
_id: import('mongoose').Types.ObjectId;
|
|
613
613
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
614
614
|
conversationId: import('mongoose').Types.ObjectId | string;
|
|
@@ -628,8 +628,8 @@ interface IMessageDocument {
|
|
|
628
628
|
createdAt: Date;
|
|
629
629
|
updatedAt: Date;
|
|
630
630
|
}
|
|
631
|
-
declare function buildMessageSchema(config: SchemaBuildConfig): Schema<IMessageDocument>;
|
|
632
|
-
declare function createMessageModel(connection: Connection, config: SchemaBuildConfig): Model<IMessageDocument>;
|
|
631
|
+
export declare function buildMessageSchema(config: SchemaBuildConfig): Schema<IMessageDocument>;
|
|
632
|
+
export declare function createMessageModel(connection: Connection, config: SchemaBuildConfig): Model<IMessageDocument>;
|
|
633
633
|
//#endregion
|
|
634
634
|
//#region src/enums/sequence-status.d.ts
|
|
635
635
|
/**
|
|
@@ -640,13 +640,13 @@ declare function createMessageModel(connection: Connection, config: SchemaBuildC
|
|
|
640
640
|
* paused — no new enrollments; running enrollments pause at next step
|
|
641
641
|
* archived — soft-hidden; historical data preserved
|
|
642
642
|
*/
|
|
643
|
-
declare const SEQUENCE_STATUSES: readonly [
|
|
643
|
+
export declare const SEQUENCE_STATUSES: readonly ['draft', 'active', 'paused', 'archived'];
|
|
644
644
|
type SequenceStatus = (typeof SEQUENCE_STATUSES)[number];
|
|
645
|
-
declare const SEQUENCE_TRANSITIONS: Record<SequenceStatus, readonly SequenceStatus[]>;
|
|
646
|
-
declare function canTransitionSequence(from: SequenceStatus, to: SequenceStatus): boolean;
|
|
645
|
+
export declare const SEQUENCE_TRANSITIONS: Record<SequenceStatus, readonly SequenceStatus[]>;
|
|
646
|
+
export declare function canTransitionSequence(from: SequenceStatus, to: SequenceStatus): boolean;
|
|
647
647
|
//#endregion
|
|
648
648
|
//#region src/models/sequence.schema.d.ts
|
|
649
|
-
interface ISendEmailStep {
|
|
649
|
+
export interface ISendEmailStep {
|
|
650
650
|
id: string;
|
|
651
651
|
type: 'SEND_EMAIL';
|
|
652
652
|
name?: string;
|
|
@@ -655,7 +655,7 @@ interface ISendEmailStep {
|
|
|
655
655
|
fromName?: string;
|
|
656
656
|
fromEmail?: string;
|
|
657
657
|
}
|
|
658
|
-
interface IDelayStep {
|
|
658
|
+
export interface IDelayStep {
|
|
659
659
|
id: string;
|
|
660
660
|
type: 'DELAY';
|
|
661
661
|
name?: string;
|
|
@@ -665,14 +665,14 @@ interface IDelayStep {
|
|
|
665
665
|
minutes?: number;
|
|
666
666
|
};
|
|
667
667
|
}
|
|
668
|
-
type SequenceStep = ISendEmailStep | IDelayStep;
|
|
669
|
-
interface ISequenceStatusEntry {
|
|
668
|
+
export type SequenceStep = ISendEmailStep | IDelayStep;
|
|
669
|
+
export interface ISequenceStatusEntry {
|
|
670
670
|
status: SequenceStatus;
|
|
671
671
|
occurredAt: Date;
|
|
672
672
|
by?: string;
|
|
673
673
|
note?: string;
|
|
674
674
|
}
|
|
675
|
-
interface ISequenceDocument {
|
|
675
|
+
export interface ISequenceDocument {
|
|
676
676
|
_id: import('mongoose').Types.ObjectId;
|
|
677
677
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
678
678
|
name: string;
|
|
@@ -691,7 +691,7 @@ interface ISequenceDocument {
|
|
|
691
691
|
createdAt: Date;
|
|
692
692
|
updatedAt: Date;
|
|
693
693
|
}
|
|
694
|
-
declare function buildSequenceSchema(config: SchemaBuildConfig): Schema<ISequenceDocument>;
|
|
694
|
+
export declare function buildSequenceSchema(config: SchemaBuildConfig): Schema<ISequenceDocument>;
|
|
695
695
|
//#endregion
|
|
696
696
|
//#region src/enums/enrollment-status.d.ts
|
|
697
697
|
/**
|
|
@@ -702,29 +702,29 @@ declare function buildSequenceSchema(config: SchemaBuildConfig): Schema<ISequenc
|
|
|
702
702
|
* completed — all steps ran to completion
|
|
703
703
|
* exited — removed early (reply, unsubscribe, bounce, manual)
|
|
704
704
|
*/
|
|
705
|
-
declare const ENROLLMENT_STATUSES: readonly [
|
|
705
|
+
export declare const ENROLLMENT_STATUSES: readonly ['active', 'paused', 'completed', 'exited'];
|
|
706
706
|
type EnrollmentStatus = (typeof ENROLLMENT_STATUSES)[number];
|
|
707
|
-
declare const ENROLLMENT_TRANSITIONS: Record<EnrollmentStatus, readonly EnrollmentStatus[]>;
|
|
708
|
-
declare function canTransitionEnrollment(from: EnrollmentStatus, to: EnrollmentStatus): boolean;
|
|
707
|
+
export declare const ENROLLMENT_TRANSITIONS: Record<EnrollmentStatus, readonly EnrollmentStatus[]>;
|
|
708
|
+
export declare function canTransitionEnrollment(from: EnrollmentStatus, to: EnrollmentStatus): boolean;
|
|
709
709
|
//#endregion
|
|
710
710
|
//#region src/models/enrollment.schema.d.ts
|
|
711
|
-
type EnrollmentExitReason = 'completed' | 'reply' | 'unsubscribe' | 'bounce' | 'manual';
|
|
712
|
-
type StepResultStatus = 'pending' | 'sent' | 'failed' | 'skipped';
|
|
713
|
-
declare const ENROLLMENT_SUBJECT_KINDS: readonly [
|
|
714
|
-
type EnrollmentSubjectKind = (typeof ENROLLMENT_SUBJECT_KINDS)[number];
|
|
715
|
-
interface IStepResult {
|
|
711
|
+
export type EnrollmentExitReason = 'completed' | 'reply' | 'unsubscribe' | 'bounce' | 'manual';
|
|
712
|
+
export type StepResultStatus = 'pending' | 'sent' | 'failed' | 'skipped';
|
|
713
|
+
export declare const ENROLLMENT_SUBJECT_KINDS: readonly ['lead', 'contact'];
|
|
714
|
+
export type EnrollmentSubjectKind = (typeof ENROLLMENT_SUBJECT_KINDS)[number];
|
|
715
|
+
export interface IStepResult {
|
|
716
716
|
stepId: string;
|
|
717
717
|
stepType: string;
|
|
718
718
|
status: StepResultStatus;
|
|
719
719
|
sentAt?: Date;
|
|
720
720
|
error?: string;
|
|
721
721
|
}
|
|
722
|
-
interface IEnrollmentStatusEntry {
|
|
722
|
+
export interface IEnrollmentStatusEntry {
|
|
723
723
|
status: EnrollmentStatus;
|
|
724
724
|
occurredAt: Date;
|
|
725
725
|
by?: string;
|
|
726
726
|
}
|
|
727
|
-
interface IEnrollmentDocument {
|
|
727
|
+
export interface IEnrollmentDocument {
|
|
728
728
|
_id: import('mongoose').Types.ObjectId;
|
|
729
729
|
organizationId: import('mongoose').Types.ObjectId | string;
|
|
730
730
|
sequenceId: import('mongoose').Types.ObjectId | string;
|
|
@@ -747,10 +747,10 @@ interface IEnrollmentDocument {
|
|
|
747
747
|
createdAt: Date;
|
|
748
748
|
updatedAt: Date;
|
|
749
749
|
}
|
|
750
|
-
declare function buildEnrollmentSchema(config: SchemaBuildConfig): Schema<IEnrollmentDocument>;
|
|
750
|
+
export declare function buildEnrollmentSchema(config: SchemaBuildConfig): Schema<IEnrollmentDocument>;
|
|
751
751
|
//#endregion
|
|
752
752
|
//#region src/models/create-models.d.ts
|
|
753
|
-
interface CrmModels {
|
|
753
|
+
export interface CrmModels {
|
|
754
754
|
Pipeline: Model<IPipelineDocument>;
|
|
755
755
|
Lead: Model<ILeadDocument>;
|
|
756
756
|
Opportunity: Model<IOpportunityDocument>;
|
|
@@ -768,10 +768,10 @@ interface CrmModels {
|
|
|
768
768
|
Sequence: Model<ISequenceDocument>;
|
|
769
769
|
Enrollment: Model<IEnrollmentDocument>;
|
|
770
770
|
}
|
|
771
|
-
type ModularCrmModels = Partial<CrmModels>;
|
|
771
|
+
export type ModularCrmModels = Partial<CrmModels>;
|
|
772
772
|
/** Mongoose model names this package can register (before `modelPrefix`). Reference/documentation. */
|
|
773
|
-
declare const CRM_MODEL_NAMES: readonly [
|
|
774
|
-
interface DefineCrmModelsConfig extends SchemaBuildConfig {
|
|
773
|
+
export declare const CRM_MODEL_NAMES: readonly ['Pipeline', 'Lead', 'Opportunity', 'Contact', 'Account', 'Campaign', 'EmailSubscription', 'Suppression', 'Activity', 'Note', 'LossReason', 'EmailEvent', 'Conversation', 'Message', 'Sequence', 'Enrollment'];
|
|
774
|
+
export interface DefineCrmModelsConfig extends SchemaBuildConfig {
|
|
775
775
|
/** Which model families to describe. A disabled family contributes no spec. */
|
|
776
776
|
modules: ResolvedCrmModules;
|
|
777
777
|
/**
|
|
@@ -788,13 +788,13 @@ interface DefineCrmModelsConfig extends SchemaBuildConfig {
|
|
|
788
788
|
* schema and registers nothing until `.bind(connection)`. Only the enabled
|
|
789
789
|
* module families contribute `ModelSpec` entries.
|
|
790
790
|
*/
|
|
791
|
-
declare function defineCrmModels(config: DefineCrmModelsConfig): ModelBlueprint<ModularCrmModels>;
|
|
791
|
+
export declare function defineCrmModels(config: DefineCrmModelsConfig): ModelBlueprint<ModularCrmModels>;
|
|
792
792
|
//#endregion
|
|
793
793
|
//#region src/repositories/pipeline.repository.d.ts
|
|
794
|
-
interface PipelineRepositoryDeps {
|
|
794
|
+
export interface PipelineRepositoryDeps {
|
|
795
795
|
events: CrmEventDispatcher;
|
|
796
796
|
}
|
|
797
|
-
declare class PipelineRepository extends Repository<IPipelineDocument> {
|
|
797
|
+
export declare class PipelineRepository extends Repository<IPipelineDocument> {
|
|
798
798
|
private readonly events;
|
|
799
799
|
constructor(model: Model<IPipelineDocument>, plugins: PluginType[], deps: PipelineRepositoryDeps, pagination?: PaginationConfig);
|
|
800
800
|
/**
|
|
@@ -812,8 +812,8 @@ declare class PipelineRepository extends Repository<IPipelineDocument> {
|
|
|
812
812
|
//#endregion
|
|
813
813
|
//#region src/shared/calculators/scoring.d.ts
|
|
814
814
|
/** Minimal Lead shape the scorer reads — firmographic + engagement counters. */
|
|
815
|
-
type LeadInput = Pick<ILeadDocument, 'email' | 'phone' | 'companyName' | 'tags' | 'jobTitle' | 'engagement'>;
|
|
816
|
-
type LeadScorer = (lead: LeadInput) => number;
|
|
815
|
+
export type LeadInput = Pick<ILeadDocument, 'email' | 'phone' | 'companyName' | 'tags' | 'jobTitle' | 'engagement'>;
|
|
816
|
+
export type LeadScorer = (lead: LeadInput) => number;
|
|
817
817
|
/**
|
|
818
818
|
* Reference implementation. Intentionally simple — hosts read it and
|
|
819
819
|
* replace it. Deterministic + pure (no I/O, no wall-clock).
|
|
@@ -827,14 +827,14 @@ type LeadScorer = (lead: LeadInput) => number;
|
|
|
827
827
|
* genuine reply: reply ×25 · click ×8 · open ×2 · activity ×5. Counters are
|
|
828
828
|
* fed by the host via `LeadRepository.recordEngagement`; absent on old rows.
|
|
829
829
|
*/
|
|
830
|
-
declare function defaultLeadScorer(lead: LeadInput): number;
|
|
830
|
+
export declare function defaultLeadScorer(lead: LeadInput): number;
|
|
831
831
|
/** Compose multiple small rules into one scorer. */
|
|
832
|
-
declare function composeScorers(...rules: readonly LeadScorer[]): LeadScorer;
|
|
832
|
+
export declare function composeScorers(...rules: readonly LeadScorer[]): LeadScorer;
|
|
833
833
|
//#endregion
|
|
834
834
|
//#region src/repositories/lead.repository.d.ts
|
|
835
835
|
/** Behavioural engagement signals fed via `recordEngagement`. */
|
|
836
|
-
type LeadEngagementSignal = 'open' | 'click' | 'reply' | 'activity';
|
|
837
|
-
interface LeadRepositoryDeps {
|
|
836
|
+
export type LeadEngagementSignal = 'open' | 'click' | 'reply' | 'activity';
|
|
837
|
+
export interface LeadRepositoryDeps {
|
|
838
838
|
events: CrmEventDispatcher;
|
|
839
839
|
/** Override the default lead scorer. */
|
|
840
840
|
scorer?: LeadScorer;
|
|
@@ -846,7 +846,7 @@ type TransitionExtras = {
|
|
|
846
846
|
note?: string;
|
|
847
847
|
patch?: Partial<ILeadDocument>;
|
|
848
848
|
};
|
|
849
|
-
declare class LeadRepository extends Repository<ILeadDocument> {
|
|
849
|
+
export declare class LeadRepository extends Repository<ILeadDocument> {
|
|
850
850
|
private readonly events;
|
|
851
851
|
private readonly scorer;
|
|
852
852
|
private readonly rejectDuplicates;
|
|
@@ -932,12 +932,12 @@ declare class LeadRepository extends Repository<ILeadDocument> {
|
|
|
932
932
|
}
|
|
933
933
|
//#endregion
|
|
934
934
|
//#region src/repositories/opportunity.repository.d.ts
|
|
935
|
-
interface OpportunityRepositoryDeps {
|
|
935
|
+
export interface OpportunityRepositoryDeps {
|
|
936
936
|
events: CrmEventDispatcher;
|
|
937
937
|
/** Cross-repo reference: read embedded stages from Pipeline. */
|
|
938
938
|
pipelines: PipelineRepository;
|
|
939
939
|
}
|
|
940
|
-
interface OpenOpportunityInput {
|
|
940
|
+
export interface OpenOpportunityInput {
|
|
941
941
|
name: string;
|
|
942
942
|
pipelineId: string;
|
|
943
943
|
/** When omitted, opp enters the pipeline's first stage. */
|
|
@@ -954,21 +954,21 @@ interface OpenOpportunityInput {
|
|
|
954
954
|
tags?: readonly string[];
|
|
955
955
|
metadata?: Record<string, unknown>;
|
|
956
956
|
}
|
|
957
|
-
interface MoveStageInput {
|
|
957
|
+
export interface MoveStageInput {
|
|
958
958
|
stageId: string;
|
|
959
959
|
by?: string;
|
|
960
960
|
note?: string;
|
|
961
961
|
/** Override the target stage's `defaultProbability`. */
|
|
962
962
|
probability?: number;
|
|
963
963
|
}
|
|
964
|
-
interface CloseInput {
|
|
964
|
+
export interface CloseInput {
|
|
965
965
|
by?: string;
|
|
966
966
|
note?: string;
|
|
967
967
|
closedAt?: Date;
|
|
968
968
|
amount?: number;
|
|
969
969
|
lostReasonId?: string;
|
|
970
970
|
}
|
|
971
|
-
declare class OpportunityRepository extends Repository<IOpportunityDocument> {
|
|
971
|
+
export declare class OpportunityRepository extends Repository<IOpportunityDocument> {
|
|
972
972
|
private readonly events;
|
|
973
973
|
private readonly pipelines;
|
|
974
974
|
constructor(model: Model<IOpportunityDocument>, plugins: PluginType[], deps: OpportunityRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -1031,7 +1031,7 @@ declare class OpportunityRepository extends Repository<IOpportunityDocument> {
|
|
|
1031
1031
|
}
|
|
1032
1032
|
//#endregion
|
|
1033
1033
|
//#region src/repositories/contact.repository.d.ts
|
|
1034
|
-
interface ContactRepositoryDeps {
|
|
1034
|
+
export interface ContactRepositoryDeps {
|
|
1035
1035
|
events: CrmEventDispatcher;
|
|
1036
1036
|
/** Reject `createContact()` when an email already exists in-tenant (default true). */
|
|
1037
1037
|
rejectDuplicates?: boolean;
|
|
@@ -1045,12 +1045,12 @@ interface ContactRepositoryDeps {
|
|
|
1045
1045
|
* Activity/Note `.subjectId`) so the delete never orphans a required
|
|
1046
1046
|
* reference. Throwing here aborts the merge — nothing is deleted.
|
|
1047
1047
|
*/
|
|
1048
|
-
type ContactMergeRepoint = (args: {
|
|
1048
|
+
export type ContactMergeRepoint = (args: {
|
|
1049
1049
|
primaryId: string;
|
|
1050
1050
|
secondaryId: string;
|
|
1051
1051
|
ctx?: CrmContext;
|
|
1052
1052
|
}) => Promise<void> | void;
|
|
1053
|
-
interface MergeContactInput {
|
|
1053
|
+
export interface MergeContactInput {
|
|
1054
1054
|
/** Surviving contact id. Receives merged fields. */
|
|
1055
1055
|
primaryId: string;
|
|
1056
1056
|
/** Secondary contact id. Deleted after merge. */
|
|
@@ -1069,7 +1069,7 @@ interface MergeContactInput {
|
|
|
1069
1069
|
*/
|
|
1070
1070
|
repoint?: ContactMergeRepoint;
|
|
1071
1071
|
}
|
|
1072
|
-
declare class ContactRepository extends Repository<IContactDocument> {
|
|
1072
|
+
export declare class ContactRepository extends Repository<IContactDocument> {
|
|
1073
1073
|
private readonly events;
|
|
1074
1074
|
private readonly rejectDuplicates;
|
|
1075
1075
|
constructor(model: Model<IContactDocument>, plugins: PluginType[], deps: ContactRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -1129,15 +1129,15 @@ declare class ContactRepository extends Repository<IContactDocument> {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
//#endregion
|
|
1131
1131
|
//#region src/repositories/account.repository.d.ts
|
|
1132
|
-
interface AccountRepositoryDeps {
|
|
1132
|
+
export interface AccountRepositoryDeps {
|
|
1133
1133
|
events: CrmEventDispatcher;
|
|
1134
1134
|
}
|
|
1135
|
-
interface MergeAccountInput {
|
|
1135
|
+
export interface MergeAccountInput {
|
|
1136
1136
|
primaryId: string;
|
|
1137
1137
|
secondaryId: string;
|
|
1138
1138
|
strategy?: 'preferPrimary' | 'preferSecondary';
|
|
1139
1139
|
}
|
|
1140
|
-
declare class AccountRepository extends Repository<IAccountDocument> {
|
|
1140
|
+
export declare class AccountRepository extends Repository<IAccountDocument> {
|
|
1141
1141
|
private readonly events;
|
|
1142
1142
|
constructor(model: Model<IAccountDocument>, plugins: PluginType[], deps: AccountRepositoryDeps, pagination?: PaginationConfig);
|
|
1143
1143
|
createAccount(input: Partial<IAccountDocument>, ctx?: CrmContext): Promise<IAccountDocument>;
|
|
@@ -1149,7 +1149,7 @@ declare class AccountRepository extends Repository<IAccountDocument> {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
//#endregion
|
|
1151
1151
|
//#region src/repositories/campaign.repository.d.ts
|
|
1152
|
-
interface CampaignRepositoryDeps {
|
|
1152
|
+
export interface CampaignRepositoryDeps {
|
|
1153
1153
|
events: CrmEventDispatcher;
|
|
1154
1154
|
/** Reject `createCampaign` on duplicate names per-tenant (default true). */
|
|
1155
1155
|
rejectDuplicates?: boolean;
|
|
@@ -1159,7 +1159,7 @@ type ExtrasWithRevenue = {
|
|
|
1159
1159
|
note?: string;
|
|
1160
1160
|
actualRevenueAmount?: number;
|
|
1161
1161
|
};
|
|
1162
|
-
declare class CampaignRepository extends Repository<ICampaignDocument> {
|
|
1162
|
+
export declare class CampaignRepository extends Repository<ICampaignDocument> {
|
|
1163
1163
|
private readonly events;
|
|
1164
1164
|
private readonly rejectDuplicates;
|
|
1165
1165
|
constructor(model: Model<ICampaignDocument>, plugins: PluginType[], deps: CampaignRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -1173,12 +1173,12 @@ declare class CampaignRepository extends Repository<ICampaignDocument> {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
//#endregion
|
|
1175
1175
|
//#region src/repositories/subscription.repository.d.ts
|
|
1176
|
-
interface SubscriptionRepositoryDeps {
|
|
1176
|
+
export interface SubscriptionRepositoryDeps {
|
|
1177
1177
|
events: CrmEventDispatcher;
|
|
1178
1178
|
/** Default DOI policy when `subscribe` doesn't pass `requireDoubleOptIn`. */
|
|
1179
1179
|
defaultRequireDoubleOptIn?: boolean;
|
|
1180
1180
|
}
|
|
1181
|
-
interface SubscribeInput {
|
|
1181
|
+
export interface SubscribeInput {
|
|
1182
1182
|
contactId: string;
|
|
1183
1183
|
campaignId: string;
|
|
1184
1184
|
source?: string;
|
|
@@ -1188,7 +1188,7 @@ interface SubscribeInput {
|
|
|
1188
1188
|
/** Override the engine-level default. */
|
|
1189
1189
|
requireDoubleOptIn?: boolean;
|
|
1190
1190
|
}
|
|
1191
|
-
declare class SubscriptionRepository extends Repository<ISubscriptionDocument> {
|
|
1191
|
+
export declare class SubscriptionRepository extends Repository<ISubscriptionDocument> {
|
|
1192
1192
|
private readonly events;
|
|
1193
1193
|
private readonly defaultRequireDoubleOptIn;
|
|
1194
1194
|
constructor(model: Model<ISubscriptionDocument>, plugins: PluginType[], deps: SubscriptionRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -1201,10 +1201,10 @@ declare class SubscriptionRepository extends Repository<ISubscriptionDocument> {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
//#endregion
|
|
1203
1203
|
//#region src/repositories/suppression.repository.d.ts
|
|
1204
|
-
interface SuppressionRepositoryDeps {
|
|
1204
|
+
export interface SuppressionRepositoryDeps {
|
|
1205
1205
|
events: CrmEventDispatcher;
|
|
1206
1206
|
}
|
|
1207
|
-
interface SuppressInput {
|
|
1207
|
+
export interface SuppressInput {
|
|
1208
1208
|
reason: SuppressionReason;
|
|
1209
1209
|
/** Free-form origin: 'campaign:<id>', 'sequence:<id>', 'api', 'import', … */
|
|
1210
1210
|
source?: string;
|
|
@@ -1221,8 +1221,8 @@ interface SuppressInput {
|
|
|
1221
1221
|
* to `true` on purpose (see the fail-closed rule in the module docblock), and a
|
|
1222
1222
|
* caller that needs the distinction should not re-derive the rule to get it.
|
|
1223
1223
|
*/
|
|
1224
|
-
declare function suppressionEmailKey(email: string): string | null;
|
|
1225
|
-
declare class SuppressionRepository extends Repository<ISuppressionDocument> {
|
|
1224
|
+
export declare function suppressionEmailKey(email: string): string | null;
|
|
1225
|
+
export declare class SuppressionRepository extends Repository<ISuppressionDocument> {
|
|
1226
1226
|
private readonly events;
|
|
1227
1227
|
constructor(model: Model<ISuppressionDocument>, plugins: PluginType[], deps: SuppressionRepositoryDeps, pagination?: PaginationConfig);
|
|
1228
1228
|
/**
|
|
@@ -1277,10 +1277,10 @@ declare class SuppressionRepository extends Repository<ISuppressionDocument> {
|
|
|
1277
1277
|
}
|
|
1278
1278
|
//#endregion
|
|
1279
1279
|
//#region src/repositories/activity.repository.d.ts
|
|
1280
|
-
interface ActivityRepositoryDeps {
|
|
1280
|
+
export interface ActivityRepositoryDeps {
|
|
1281
1281
|
events: CrmEventDispatcher;
|
|
1282
1282
|
}
|
|
1283
|
-
declare class ActivityRepository extends Repository<IActivityDocument> {
|
|
1283
|
+
export declare class ActivityRepository extends Repository<IActivityDocument> {
|
|
1284
1284
|
private readonly events;
|
|
1285
1285
|
constructor(model: Model<IActivityDocument>, plugins: PluginType[], deps: ActivityRepositoryDeps, pagination?: PaginationConfig);
|
|
1286
1286
|
plan(input: Partial<IActivityDocument>, ctx?: CrmContext): Promise<IActivityDocument>;
|
|
@@ -1314,20 +1314,20 @@ declare class ActivityRepository extends Repository<IActivityDocument> {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
//#endregion
|
|
1316
1316
|
//#region src/repositories/note.repository.d.ts
|
|
1317
|
-
interface NoteRepositoryDeps {
|
|
1317
|
+
export interface NoteRepositoryDeps {
|
|
1318
1318
|
events: CrmEventDispatcher;
|
|
1319
1319
|
}
|
|
1320
|
-
declare class NoteRepository extends Repository<INoteDocument> {
|
|
1320
|
+
export declare class NoteRepository extends Repository<INoteDocument> {
|
|
1321
1321
|
private readonly events;
|
|
1322
1322
|
constructor(model: Model<INoteDocument>, plugins: PluginType[], deps: NoteRepositoryDeps, pagination?: PaginationConfig);
|
|
1323
1323
|
addNote(input: Partial<INoteDocument>, ctx?: CrmContext): Promise<INoteDocument>;
|
|
1324
1324
|
}
|
|
1325
1325
|
//#endregion
|
|
1326
1326
|
//#region src/repositories/loss-reason.repository.d.ts
|
|
1327
|
-
interface LossReasonRepositoryDeps {
|
|
1327
|
+
export interface LossReasonRepositoryDeps {
|
|
1328
1328
|
events: CrmEventDispatcher;
|
|
1329
1329
|
}
|
|
1330
|
-
declare class LossReasonRepository extends Repository<ILossReasonDocument> {
|
|
1330
|
+
export declare class LossReasonRepository extends Repository<ILossReasonDocument> {
|
|
1331
1331
|
private readonly events;
|
|
1332
1332
|
constructor(model: Model<ILossReasonDocument>, plugins: PluginType[], deps: LossReasonRepositoryDeps, pagination?: PaginationConfig);
|
|
1333
1333
|
/** Hide from pickers without breaking historical FKs. */
|
|
@@ -1335,10 +1335,10 @@ declare class LossReasonRepository extends Repository<ILossReasonDocument> {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
//#endregion
|
|
1337
1337
|
//#region src/repositories/email-event.repository.d.ts
|
|
1338
|
-
interface EmailEventRepositoryDeps {
|
|
1338
|
+
export interface EmailEventRepositoryDeps {
|
|
1339
1339
|
events: CrmEventDispatcher;
|
|
1340
1340
|
}
|
|
1341
|
-
interface RecordEmailEventInput {
|
|
1341
|
+
export interface RecordEmailEventInput {
|
|
1342
1342
|
subjectKind: EmailEventSubjectKind;
|
|
1343
1343
|
subjectId: string;
|
|
1344
1344
|
campaignId?: string;
|
|
@@ -1348,7 +1348,7 @@ interface RecordEmailEventInput {
|
|
|
1348
1348
|
ip?: string;
|
|
1349
1349
|
metadata?: Record<string, unknown>;
|
|
1350
1350
|
}
|
|
1351
|
-
declare class EmailEventRepository extends Repository<IEmailEventDocument> {
|
|
1351
|
+
export declare class EmailEventRepository extends Repository<IEmailEventDocument> {
|
|
1352
1352
|
private readonly events;
|
|
1353
1353
|
constructor(model: Model<IEmailEventDocument>, plugins: PluginType[], deps: EmailEventRepositoryDeps, pagination?: PaginationConfig);
|
|
1354
1354
|
recordOpen(input: RecordEmailEventInput, ctx?: CrmContext): Promise<IEmailEventDocument>;
|
|
@@ -1360,10 +1360,10 @@ declare class EmailEventRepository extends Repository<IEmailEventDocument> {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
//#endregion
|
|
1362
1362
|
//#region src/repositories/conversation.repository.d.ts
|
|
1363
|
-
interface ConversationRepositoryDeps {
|
|
1363
|
+
export interface ConversationRepositoryDeps {
|
|
1364
1364
|
events: CrmEventDispatcher;
|
|
1365
1365
|
}
|
|
1366
|
-
interface OpenConversationInput {
|
|
1366
|
+
export interface OpenConversationInput {
|
|
1367
1367
|
channel: ConversationChannel;
|
|
1368
1368
|
participantKind: ConversationParticipantKind;
|
|
1369
1369
|
participantId: string;
|
|
@@ -1371,7 +1371,7 @@ interface OpenConversationInput {
|
|
|
1371
1371
|
assigneeId?: string;
|
|
1372
1372
|
metadata?: Record<string, unknown>;
|
|
1373
1373
|
}
|
|
1374
|
-
declare class ConversationRepository extends Repository<IConversationDocument> {
|
|
1374
|
+
export declare class ConversationRepository extends Repository<IConversationDocument> {
|
|
1375
1375
|
private readonly events;
|
|
1376
1376
|
constructor(model: Model<IConversationDocument>, plugins: PluginType[], deps: ConversationRepositoryDeps, pagination?: PaginationConfig);
|
|
1377
1377
|
openConversation(input: OpenConversationInput, ctx?: CrmContext): Promise<IConversationDocument>;
|
|
@@ -1394,11 +1394,11 @@ declare class ConversationRepository extends Repository<IConversationDocument> {
|
|
|
1394
1394
|
}
|
|
1395
1395
|
//#endregion
|
|
1396
1396
|
//#region src/repositories/message.repository.d.ts
|
|
1397
|
-
interface MessageRepositoryDeps {
|
|
1397
|
+
export interface MessageRepositoryDeps {
|
|
1398
1398
|
events: CrmEventDispatcher;
|
|
1399
1399
|
conversations: ConversationRepository;
|
|
1400
1400
|
}
|
|
1401
|
-
interface RecordMessageInput {
|
|
1401
|
+
export interface RecordMessageInput {
|
|
1402
1402
|
conversationId: string;
|
|
1403
1403
|
body: string;
|
|
1404
1404
|
attachments?: IMessageAttachment[];
|
|
@@ -1408,7 +1408,7 @@ interface RecordMessageInput {
|
|
|
1408
1408
|
sentAt?: Date;
|
|
1409
1409
|
metadata?: Record<string, unknown>;
|
|
1410
1410
|
}
|
|
1411
|
-
declare class MessageRepository extends Repository<IMessageDocument> {
|
|
1411
|
+
export declare class MessageRepository extends Repository<IMessageDocument> {
|
|
1412
1412
|
private readonly events;
|
|
1413
1413
|
private readonly conversations;
|
|
1414
1414
|
constructor(model: Model<IMessageDocument>, plugins: PluginType[], deps: MessageRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -1422,10 +1422,10 @@ declare class MessageRepository extends Repository<IMessageDocument> {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
//#endregion
|
|
1424
1424
|
//#region src/repositories/sequence.repository.d.ts
|
|
1425
|
-
interface SequenceRepositoryDeps {
|
|
1425
|
+
export interface SequenceRepositoryDeps {
|
|
1426
1426
|
events: CrmEventDispatcher;
|
|
1427
1427
|
}
|
|
1428
|
-
declare class SequenceRepository extends Repository<ISequenceDocument> {
|
|
1428
|
+
export declare class SequenceRepository extends Repository<ISequenceDocument> {
|
|
1429
1429
|
private readonly events;
|
|
1430
1430
|
constructor(model: Model<ISequenceDocument>, plugins: PluginType[], deps: SequenceRepositoryDeps, pagination?: PaginationConfig);
|
|
1431
1431
|
activate(id: string, ctx?: CrmContext): Promise<ISequenceDocument>;
|
|
@@ -1436,17 +1436,17 @@ declare class SequenceRepository extends Repository<ISequenceDocument> {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
//#endregion
|
|
1438
1438
|
//#region src/repositories/enrollment.repository.d.ts
|
|
1439
|
-
interface EnrollmentRepositoryDeps {
|
|
1439
|
+
export interface EnrollmentRepositoryDeps {
|
|
1440
1440
|
events: CrmEventDispatcher;
|
|
1441
1441
|
/** Cross-repo reference: read `replyDetectionEnabled` from Sequence. */
|
|
1442
1442
|
sequences: SequenceRepository;
|
|
1443
1443
|
}
|
|
1444
1444
|
/** A subject that just replied — input to `exitActiveOnReply()`. */
|
|
1445
|
-
interface ReplySubject {
|
|
1445
|
+
export interface ReplySubject {
|
|
1446
1446
|
subjectKind: EnrollmentSubjectKind;
|
|
1447
1447
|
subjectId: string;
|
|
1448
1448
|
}
|
|
1449
|
-
interface EnrollInput {
|
|
1449
|
+
export interface EnrollInput {
|
|
1450
1450
|
sequenceId: string;
|
|
1451
1451
|
subjectKind: EnrollmentSubjectKind;
|
|
1452
1452
|
subjectId: string;
|
|
@@ -1454,7 +1454,7 @@ interface EnrollInput {
|
|
|
1454
1454
|
ownerId?: string;
|
|
1455
1455
|
metadata?: Record<string, unknown>;
|
|
1456
1456
|
}
|
|
1457
|
-
declare class EnrollmentRepository extends Repository<IEnrollmentDocument> {
|
|
1457
|
+
export declare class EnrollmentRepository extends Repository<IEnrollmentDocument> {
|
|
1458
1458
|
private readonly events;
|
|
1459
1459
|
private readonly sequences;
|
|
1460
1460
|
constructor(model: Model<IEnrollmentDocument>, plugins: PluginType[], deps: EnrollmentRepositoryDeps, pagination?: PaginationConfig);
|
|
@@ -1497,7 +1497,7 @@ declare class EnrollmentRepository extends Repository<IEnrollmentDocument> {
|
|
|
1497
1497
|
}
|
|
1498
1498
|
//#endregion
|
|
1499
1499
|
//#region src/engine/engine-types.d.ts
|
|
1500
|
-
interface CrmLogger {
|
|
1500
|
+
export interface CrmLogger {
|
|
1501
1501
|
info?(msg: string, meta?: Record<string, unknown>): void;
|
|
1502
1502
|
warn?(msg: string, meta?: Record<string, unknown>): void;
|
|
1503
1503
|
error?(msg: string, meta?: Record<string, unknown>): void;
|
|
@@ -1508,7 +1508,7 @@ interface CrmLogger {
|
|
|
1508
1508
|
* determines the persistence SHAPE and needs no connection or I/O to inspect.
|
|
1509
1509
|
* Passed to `defineCrm(shape)`; nothing here opens a socket or reads a secret.
|
|
1510
1510
|
*/
|
|
1511
|
-
interface CrmShape {
|
|
1511
|
+
export interface CrmShape {
|
|
1512
1512
|
/**
|
|
1513
1513
|
* Tenant column shape. `'objectId'` (default) matches Better Auth orgs
|
|
1514
1514
|
* and unlocks `$lookup` / `.populate()`; `'string'` matches UUID hosts.
|
|
@@ -1546,7 +1546,7 @@ interface CrmShape {
|
|
|
1546
1546
|
* connection is the first `bind` arg; these are the rest. A transport, outbox,
|
|
1547
1547
|
* logger or plugin set belongs here, not in the shape.
|
|
1548
1548
|
*/
|
|
1549
|
-
interface CrmRuntime {
|
|
1549
|
+
export interface CrmRuntime {
|
|
1550
1550
|
/** Arc-compatible event transport. Default: in-process bus (owned + closed by the engine). */
|
|
1551
1551
|
eventTransport?: EventTransport | undefined;
|
|
1552
1552
|
/**
|
|
@@ -1570,7 +1570,7 @@ interface CrmRuntime {
|
|
|
1570
1570
|
*/
|
|
1571
1571
|
allowNonTransactional?: boolean | undefined;
|
|
1572
1572
|
}
|
|
1573
|
-
interface ResolvedCrmConfig extends SchemaBuildConfig {
|
|
1573
|
+
export interface ResolvedCrmConfig extends SchemaBuildConfig {
|
|
1574
1574
|
connection: Connection;
|
|
1575
1575
|
tenant: ResolvedTenantConfig;
|
|
1576
1576
|
forceRecreate: boolean;
|
|
@@ -1580,7 +1580,7 @@ interface ResolvedCrmConfig extends SchemaBuildConfig {
|
|
|
1580
1580
|
pagination?: PaginationConfig | undefined;
|
|
1581
1581
|
plugins: PluginType[];
|
|
1582
1582
|
}
|
|
1583
|
-
interface CrmRepositories {
|
|
1583
|
+
export interface CrmRepositories {
|
|
1584
1584
|
pipeline: PipelineRepository;
|
|
1585
1585
|
lead: LeadRepository;
|
|
1586
1586
|
opportunity: OpportunityRepository;
|
|
@@ -1598,28 +1598,28 @@ interface CrmRepositories {
|
|
|
1598
1598
|
sequence: SequenceRepository;
|
|
1599
1599
|
enrollment: EnrollmentRepository;
|
|
1600
1600
|
}
|
|
1601
|
-
type ModularCrmRepositories = Partial<CrmRepositories>;
|
|
1602
|
-
type SalesCrmModels = Pick<CrmModels, 'Pipeline' | 'Lead' | 'Opportunity' | 'Contact' | 'Account' | 'Activity' | 'Note' | 'LossReason'>;
|
|
1603
|
-
type SalesCrmRepositories = Pick<CrmRepositories, 'pipeline' | 'lead' | 'opportunity' | 'contact' | 'account' | 'activity' | 'note' | 'lossReason'>;
|
|
1604
|
-
type EngagementCrmModels = Pick<CrmModels, 'Subscription' | 'Suppression' | 'EmailEvent' | 'Conversation' | 'Message'>;
|
|
1605
|
-
type EngagementCrmRepositories = Pick<CrmRepositories, 'subscription' | 'suppression' | 'emailEvent' | 'conversation' | 'message'>;
|
|
1606
|
-
type AutomationCrmModels = Pick<CrmModels, 'Campaign' | 'Sequence' | 'Enrollment'>;
|
|
1607
|
-
type AutomationCrmRepositories = Pick<CrmRepositories, 'campaign' | 'sequence' | 'enrollment'>;
|
|
1608
|
-
interface CrmModuleView<TModels, TRepositories> {
|
|
1601
|
+
export type ModularCrmRepositories = Partial<CrmRepositories>;
|
|
1602
|
+
export type SalesCrmModels = Pick<CrmModels, 'Pipeline' | 'Lead' | 'Opportunity' | 'Contact' | 'Account' | 'Activity' | 'Note' | 'LossReason'>;
|
|
1603
|
+
export type SalesCrmRepositories = Pick<CrmRepositories, 'pipeline' | 'lead' | 'opportunity' | 'contact' | 'account' | 'activity' | 'note' | 'lossReason'>;
|
|
1604
|
+
export type EngagementCrmModels = Pick<CrmModels, 'Subscription' | 'Suppression' | 'EmailEvent' | 'Conversation' | 'Message'>;
|
|
1605
|
+
export type EngagementCrmRepositories = Pick<CrmRepositories, 'subscription' | 'suppression' | 'emailEvent' | 'conversation' | 'message'>;
|
|
1606
|
+
export type AutomationCrmModels = Pick<CrmModels, 'Campaign' | 'Sequence' | 'Enrollment'>;
|
|
1607
|
+
export type AutomationCrmRepositories = Pick<CrmRepositories, 'campaign' | 'sequence' | 'enrollment'>;
|
|
1608
|
+
export interface CrmModuleView<TModels, TRepositories> {
|
|
1609
1609
|
readonly models: Readonly<TModels>;
|
|
1610
1610
|
readonly repositories: Readonly<TRepositories>;
|
|
1611
1611
|
}
|
|
1612
|
-
interface ModularCrmModuleViews {
|
|
1612
|
+
export interface ModularCrmModuleViews {
|
|
1613
1613
|
readonly sales?: CrmModuleView<SalesCrmModels, SalesCrmRepositories> | undefined;
|
|
1614
1614
|
readonly engagement?: CrmModuleView<EngagementCrmModels, EngagementCrmRepositories> | undefined;
|
|
1615
1615
|
readonly automation?: CrmModuleView<AutomationCrmModels, AutomationCrmRepositories> | undefined;
|
|
1616
1616
|
}
|
|
1617
|
-
interface FullCrmModuleViews {
|
|
1617
|
+
export interface FullCrmModuleViews {
|
|
1618
1618
|
readonly sales: CrmModuleView<SalesCrmModels, SalesCrmRepositories>;
|
|
1619
1619
|
readonly engagement: CrmModuleView<EngagementCrmModels, EngagementCrmRepositories>;
|
|
1620
1620
|
readonly automation: CrmModuleView<AutomationCrmModels, AutomationCrmRepositories>;
|
|
1621
1621
|
}
|
|
1622
|
-
interface CrmEngineBase<TModels, TRepositories, TModules> {
|
|
1622
|
+
export interface CrmEngineBase<TModels, TRepositories, TModules> {
|
|
1623
1623
|
/** Repositories ARE the API surface (PACKAGE_RULES §1). */
|
|
1624
1624
|
readonly repositories: Readonly<TRepositories>;
|
|
1625
1625
|
/**
|
|
@@ -1663,16 +1663,16 @@ interface CrmEngineBase<TModels, TRepositories, TModules> {
|
|
|
1663
1663
|
close(): Promise<void>;
|
|
1664
1664
|
}
|
|
1665
1665
|
/** All-enabled engine returned when `shape.modules` is omitted. */
|
|
1666
|
-
type CrmEngine = CrmEngineBase<CrmModels, CrmRepositories, FullCrmModuleViews>;
|
|
1666
|
+
export type CrmEngine = CrmEngineBase<CrmModels, CrmRepositories, FullCrmModuleViews>;
|
|
1667
1667
|
/** Progressive engine returned when a `modules` selection is supplied. */
|
|
1668
|
-
type ModularCrmEngine = CrmEngineBase<ModularCrmModels, ModularCrmRepositories, ModularCrmModuleViews>;
|
|
1668
|
+
export type ModularCrmEngine = CrmEngineBase<ModularCrmModels, ModularCrmRepositories, ModularCrmModuleViews>;
|
|
1669
1669
|
/**
|
|
1670
1670
|
* The connection-free description produced by `defineCrm(shape)` (Kernel
|
|
1671
1671
|
* Construction Standard §6.1). `defineCrm` is the SOLE construction API — there
|
|
1672
1672
|
* is no `createCrm` wrapper. `bind` compiles the schemas on the supplied
|
|
1673
1673
|
* connection, wires the engine, verifies capabilities, and returns the engine.
|
|
1674
1674
|
*/
|
|
1675
|
-
interface CrmBlueprint<TEngine extends CrmEngine | ModularCrmEngine = ModularCrmEngine> {
|
|
1675
|
+
export interface CrmBlueprint<TEngine extends CrmEngine | ModularCrmEngine = ModularCrmEngine> {
|
|
1676
1676
|
readonly id: 'crm';
|
|
1677
1677
|
/** The model names this blueprint registers — known without a connection. */
|
|
1678
1678
|
readonly modelNames: readonly string[];
|
|
@@ -1688,32 +1688,32 @@ interface CrmBlueprint<TEngine extends CrmEngine | ModularCrmEngine = ModularCrm
|
|
|
1688
1688
|
* stores cleanly. Host-specific extras go through the inherited
|
|
1689
1689
|
* `metadata?` field — keep the typed surface tight.
|
|
1690
1690
|
*/
|
|
1691
|
-
interface CrmContext extends OperationContext {
|
|
1691
|
+
export interface CrmContext extends OperationContext {
|
|
1692
1692
|
organizationId?: string | import('mongoose').Types.ObjectId;
|
|
1693
1693
|
actorId?: string | import('mongoose').Types.ObjectId;
|
|
1694
1694
|
/** Mongo transaction session (passed through to mongokit). */
|
|
1695
1695
|
session?: unknown;
|
|
1696
1696
|
}
|
|
1697
|
-
type _ModelTypes = Model<unknown>;
|
|
1697
|
+
export type _ModelTypes = Model<unknown>;
|
|
1698
1698
|
//#endregion
|
|
1699
1699
|
//#region src/engine/define-crm.d.ts
|
|
1700
|
-
declare function defineCrm(shape: CrmShape & {
|
|
1700
|
+
export declare function defineCrm(shape: CrmShape & {
|
|
1701
1701
|
modules: CrmModulesConfig;
|
|
1702
1702
|
}): CrmBlueprint<ModularCrmEngine>;
|
|
1703
|
-
declare function defineCrm(shape?: CrmShape & {
|
|
1703
|
+
export declare function defineCrm(shape?: CrmShape & {
|
|
1704
1704
|
modules?: undefined;
|
|
1705
1705
|
}): CrmBlueprint<CrmEngine>;
|
|
1706
|
-
declare function defineCrm(shape?: CrmShape): CrmBlueprint<ModularCrmEngine>;
|
|
1706
|
+
export declare function defineCrm(shape?: CrmShape): CrmBlueprint<ModularCrmEngine>;
|
|
1707
1707
|
//#endregion
|
|
1708
1708
|
//#region src/repositories/create-repositories.d.ts
|
|
1709
|
-
interface CreateCrmRepositoriesDeps {
|
|
1709
|
+
export interface CreateCrmRepositoriesDeps {
|
|
1710
1710
|
events: CrmEventDispatcher;
|
|
1711
1711
|
config: ResolvedCrmConfig;
|
|
1712
1712
|
}
|
|
1713
|
-
declare function createCrmRepositories(models: ModularCrmModels, deps: CreateCrmRepositoriesDeps): ModularCrmRepositories;
|
|
1713
|
+
export declare function createCrmRepositories(models: ModularCrmModels, deps: CreateCrmRepositoriesDeps): ModularCrmRepositories;
|
|
1714
1714
|
//#endregion
|
|
1715
1715
|
//#region src/services/lead.service.d.ts
|
|
1716
|
-
interface ConvertLeadInput {
|
|
1716
|
+
export interface ConvertLeadInput {
|
|
1717
1717
|
pipelineId: string;
|
|
1718
1718
|
/** Defaults to `<companyName> — <source>` / `<fullName> — New`. */
|
|
1719
1719
|
opportunityName?: string;
|
|
@@ -1723,7 +1723,7 @@ interface ConvertLeadInput {
|
|
|
1723
1723
|
expectedCloseAt?: Date;
|
|
1724
1724
|
by?: string;
|
|
1725
1725
|
}
|
|
1726
|
-
interface ConvertResult {
|
|
1726
|
+
export interface ConvertResult {
|
|
1727
1727
|
lead: ILeadDocument;
|
|
1728
1728
|
contact: IContactDocument;
|
|
1729
1729
|
account?: IAccountDocument;
|
|
@@ -1735,14 +1735,14 @@ interface ConvertResult {
|
|
|
1735
1735
|
/** Convenience string id — same as `String(opportunity._id)`. */
|
|
1736
1736
|
opportunityId: string;
|
|
1737
1737
|
}
|
|
1738
|
-
interface LeadServiceDeps {
|
|
1738
|
+
export interface LeadServiceDeps {
|
|
1739
1739
|
lead: LeadRepository;
|
|
1740
1740
|
contact: ContactRepository;
|
|
1741
1741
|
account: AccountRepository;
|
|
1742
1742
|
opportunity: OpportunityRepository;
|
|
1743
1743
|
events: CrmEventDispatcher;
|
|
1744
1744
|
}
|
|
1745
|
-
declare class LeadService {
|
|
1745
|
+
export declare class LeadService {
|
|
1746
1746
|
private readonly leads;
|
|
1747
1747
|
private readonly contacts;
|
|
1748
1748
|
private readonly accounts;
|
|
@@ -1780,85 +1780,109 @@ declare class LeadService {
|
|
|
1780
1780
|
//#endregion
|
|
1781
1781
|
//#region src/events/event-constants.d.ts
|
|
1782
1782
|
/** PACKAGE_RULES rule 12: `package:resource.verb`. */
|
|
1783
|
-
declare const CRM_EVENTS: {
|
|
1784
|
-
readonly LEAD_CREATED:
|
|
1785
|
-
readonly LEAD_STATUS_CHANGED:
|
|
1786
|
-
readonly LEAD_SCORED:
|
|
1787
|
-
readonly LEAD_CONVERTED:
|
|
1788
|
-
readonly LEAD_DISQUALIFIED:
|
|
1789
|
-
readonly ACCOUNT_CREATED:
|
|
1790
|
-
readonly ACCOUNT_UPDATED:
|
|
1791
|
-
readonly CONTACT_CREATED:
|
|
1792
|
-
readonly CONTACT_UPDATED:
|
|
1793
|
-
readonly OPPORTUNITY_CREATED:
|
|
1794
|
-
readonly OPPORTUNITY_STAGE_ADVANCED:
|
|
1795
|
-
readonly OPPORTUNITY_STAGE_REGRESSED:
|
|
1796
|
-
readonly OPPORTUNITY_WON:
|
|
1797
|
-
readonly OPPORTUNITY_LOST:
|
|
1798
|
-
readonly OPPORTUNITY_ABANDONED:
|
|
1799
|
-
readonly PIPELINE_CREATED:
|
|
1800
|
-
readonly PIPELINE_ARCHIVED:
|
|
1801
|
-
readonly ACTIVITY_PLANNED:
|
|
1802
|
-
readonly ACTIVITY_COMPLETED:
|
|
1803
|
-
readonly ACTIVITY_CANCELLED:
|
|
1804
|
-
readonly NOTE_ADDED:
|
|
1805
|
-
readonly CAMPAIGN_CREATED:
|
|
1806
|
-
readonly CAMPAIGN_ACTIVATED:
|
|
1807
|
-
readonly CAMPAIGN_PAUSED:
|
|
1808
|
-
readonly CAMPAIGN_RESUMED:
|
|
1809
|
-
readonly CAMPAIGN_COMPLETED:
|
|
1810
|
-
readonly CAMPAIGN_ARCHIVED:
|
|
1811
|
-
readonly SUBSCRIPTION_CREATED:
|
|
1812
|
-
readonly SUBSCRIPTION_CONFIRMED:
|
|
1813
|
-
readonly SUBSCRIPTION_UNSUBSCRIBED:
|
|
1814
|
-
readonly SUBSCRIPTION_BOUNCED:
|
|
1815
|
-
readonly SUBSCRIPTION_COMPLAINED:
|
|
1816
|
-
readonly SEQUENCE_CREATED:
|
|
1817
|
-
readonly SEQUENCE_ACTIVATED:
|
|
1818
|
-
readonly SEQUENCE_PAUSED:
|
|
1819
|
-
readonly SEQUENCE_ARCHIVED:
|
|
1820
|
-
readonly ENROLLMENT_CREATED:
|
|
1821
|
-
readonly ENROLLMENT_STEP_SENT:
|
|
1822
|
-
readonly ENROLLMENT_PAUSED:
|
|
1823
|
-
readonly ENROLLMENT_RESUMED:
|
|
1824
|
-
readonly ENROLLMENT_COMPLETED:
|
|
1825
|
-
readonly ENROLLMENT_EXITED:
|
|
1826
|
-
readonly EMAIL_EVENT_OPENED:
|
|
1827
|
-
readonly EMAIL_EVENT_CLICKED:
|
|
1828
|
-
readonly EMAIL_EVENT_BOUNCED:
|
|
1829
|
-
readonly EMAIL_EVENT_COMPLAINED:
|
|
1830
|
-
readonly EMAIL_EVENT_UNSUBSCRIBED:
|
|
1831
|
-
readonly LEAD_ENRICHED:
|
|
1832
|
-
readonly LEAD_ASSIGNED:
|
|
1833
|
-
readonly LEAD_ANONYMIZED:
|
|
1834
|
-
readonly CONTACT_ENRICHED:
|
|
1835
|
-
readonly CONTACT_ASSIGNED:
|
|
1836
|
-
readonly CONTACT_MERGED:
|
|
1837
|
-
readonly CONTACT_ANONYMIZED:
|
|
1838
|
-
readonly ACCOUNT_ENRICHED:
|
|
1839
|
-
readonly ACCOUNT_ASSIGNED:
|
|
1840
|
-
readonly ACCOUNT_MERGED:
|
|
1841
|
-
readonly OPPORTUNITY_ASSIGNED:
|
|
1842
|
-
readonly OPPORTUNITY_AMOUNT_CHANGED:
|
|
1843
|
-
readonly OPPORTUNITY_EXTENDED:
|
|
1844
|
-
readonly ACTIVITY_RESCHEDULED:
|
|
1845
|
-
readonly ACTIVITY_OUTCOME_RECORDED:
|
|
1846
|
-
readonly SUPPRESSION_ADDED:
|
|
1847
|
-
readonly SUPPRESSION_REMOVED:
|
|
1848
|
-
readonly CONVERSATION_CREATED:
|
|
1849
|
-
readonly CONVERSATION_ASSIGNED:
|
|
1850
|
-
readonly CONVERSATION_RESOLVED:
|
|
1851
|
-
readonly CONVERSATION_REOPENED:
|
|
1852
|
-
readonly MESSAGE_RECEIVED:
|
|
1853
|
-
readonly MESSAGE_SENT:
|
|
1783
|
+
export declare const CRM_EVENTS: {
|
|
1784
|
+
readonly LEAD_CREATED: 'crm:lead.created';
|
|
1785
|
+
readonly LEAD_STATUS_CHANGED: 'crm:lead.status_changed';
|
|
1786
|
+
readonly LEAD_SCORED: 'crm:lead.scored';
|
|
1787
|
+
readonly LEAD_CONVERTED: 'crm:lead.converted';
|
|
1788
|
+
readonly LEAD_DISQUALIFIED: 'crm:lead.disqualified';
|
|
1789
|
+
readonly ACCOUNT_CREATED: 'crm:account.created';
|
|
1790
|
+
readonly ACCOUNT_UPDATED: 'crm:account.updated';
|
|
1791
|
+
readonly CONTACT_CREATED: 'crm:contact.created';
|
|
1792
|
+
readonly CONTACT_UPDATED: 'crm:contact.updated';
|
|
1793
|
+
readonly OPPORTUNITY_CREATED: 'crm:opportunity.created';
|
|
1794
|
+
readonly OPPORTUNITY_STAGE_ADVANCED: 'crm:opportunity.stage_advanced';
|
|
1795
|
+
readonly OPPORTUNITY_STAGE_REGRESSED: 'crm:opportunity.stage_regressed';
|
|
1796
|
+
readonly OPPORTUNITY_WON: 'crm:opportunity.won';
|
|
1797
|
+
readonly OPPORTUNITY_LOST: 'crm:opportunity.lost';
|
|
1798
|
+
readonly OPPORTUNITY_ABANDONED: 'crm:opportunity.abandoned';
|
|
1799
|
+
readonly PIPELINE_CREATED: 'crm:pipeline.created';
|
|
1800
|
+
readonly PIPELINE_ARCHIVED: 'crm:pipeline.archived';
|
|
1801
|
+
readonly ACTIVITY_PLANNED: 'crm:activity.planned';
|
|
1802
|
+
readonly ACTIVITY_COMPLETED: 'crm:activity.completed';
|
|
1803
|
+
readonly ACTIVITY_CANCELLED: 'crm:activity.cancelled';
|
|
1804
|
+
readonly NOTE_ADDED: 'crm:note.added';
|
|
1805
|
+
readonly CAMPAIGN_CREATED: 'crm:campaign.created';
|
|
1806
|
+
readonly CAMPAIGN_ACTIVATED: 'crm:campaign.activated';
|
|
1807
|
+
readonly CAMPAIGN_PAUSED: 'crm:campaign.paused';
|
|
1808
|
+
readonly CAMPAIGN_RESUMED: 'crm:campaign.resumed';
|
|
1809
|
+
readonly CAMPAIGN_COMPLETED: 'crm:campaign.completed';
|
|
1810
|
+
readonly CAMPAIGN_ARCHIVED: 'crm:campaign.archived';
|
|
1811
|
+
readonly SUBSCRIPTION_CREATED: 'crm:subscription.created';
|
|
1812
|
+
readonly SUBSCRIPTION_CONFIRMED: 'crm:subscription.confirmed';
|
|
1813
|
+
readonly SUBSCRIPTION_UNSUBSCRIBED: 'crm:subscription.unsubscribed';
|
|
1814
|
+
readonly SUBSCRIPTION_BOUNCED: 'crm:subscription.bounced';
|
|
1815
|
+
readonly SUBSCRIPTION_COMPLAINED: 'crm:subscription.complained';
|
|
1816
|
+
readonly SEQUENCE_CREATED: 'crm:sequence.created';
|
|
1817
|
+
readonly SEQUENCE_ACTIVATED: 'crm:sequence.active';
|
|
1818
|
+
readonly SEQUENCE_PAUSED: 'crm:sequence.paused';
|
|
1819
|
+
readonly SEQUENCE_ARCHIVED: 'crm:sequence.archived';
|
|
1820
|
+
readonly ENROLLMENT_CREATED: 'crm:enrollment.created';
|
|
1821
|
+
readonly ENROLLMENT_STEP_SENT: 'crm:enrollment.step_sent';
|
|
1822
|
+
readonly ENROLLMENT_PAUSED: 'crm:enrollment.paused';
|
|
1823
|
+
readonly ENROLLMENT_RESUMED: 'crm:enrollment.resumed';
|
|
1824
|
+
readonly ENROLLMENT_COMPLETED: 'crm:enrollment.completed';
|
|
1825
|
+
readonly ENROLLMENT_EXITED: 'crm:enrollment.exited';
|
|
1826
|
+
readonly EMAIL_EVENT_OPENED: 'crm:email_event.opened';
|
|
1827
|
+
readonly EMAIL_EVENT_CLICKED: 'crm:email_event.clicked';
|
|
1828
|
+
readonly EMAIL_EVENT_BOUNCED: 'crm:email_event.bounced';
|
|
1829
|
+
readonly EMAIL_EVENT_COMPLAINED: 'crm:email_event.complained';
|
|
1830
|
+
readonly EMAIL_EVENT_UNSUBSCRIBED: 'crm:email_event.unsubscribed';
|
|
1831
|
+
readonly LEAD_ENRICHED: 'crm:lead.enriched';
|
|
1832
|
+
readonly LEAD_ASSIGNED: 'crm:lead.assigned';
|
|
1833
|
+
readonly LEAD_ANONYMIZED: 'crm:lead.anonymized';
|
|
1834
|
+
readonly CONTACT_ENRICHED: 'crm:contact.enriched';
|
|
1835
|
+
readonly CONTACT_ASSIGNED: 'crm:contact.assigned';
|
|
1836
|
+
readonly CONTACT_MERGED: 'crm:contact.merged';
|
|
1837
|
+
readonly CONTACT_ANONYMIZED: 'crm:contact.anonymized';
|
|
1838
|
+
readonly ACCOUNT_ENRICHED: 'crm:account.enriched';
|
|
1839
|
+
readonly ACCOUNT_ASSIGNED: 'crm:account.assigned';
|
|
1840
|
+
readonly ACCOUNT_MERGED: 'crm:account.merged';
|
|
1841
|
+
readonly OPPORTUNITY_ASSIGNED: 'crm:opportunity.assigned';
|
|
1842
|
+
readonly OPPORTUNITY_AMOUNT_CHANGED: 'crm:opportunity.amount_changed';
|
|
1843
|
+
readonly OPPORTUNITY_EXTENDED: 'crm:opportunity.extended';
|
|
1844
|
+
readonly ACTIVITY_RESCHEDULED: 'crm:activity.rescheduled';
|
|
1845
|
+
readonly ACTIVITY_OUTCOME_RECORDED: 'crm:activity.outcome_recorded';
|
|
1846
|
+
readonly SUPPRESSION_ADDED: 'crm:suppression.added';
|
|
1847
|
+
readonly SUPPRESSION_REMOVED: 'crm:suppression.removed';
|
|
1848
|
+
readonly CONVERSATION_CREATED: 'crm:conversation.created';
|
|
1849
|
+
readonly CONVERSATION_ASSIGNED: 'crm:conversation.assigned';
|
|
1850
|
+
readonly CONVERSATION_RESOLVED: 'crm:conversation.resolved';
|
|
1851
|
+
readonly CONVERSATION_REOPENED: 'crm:conversation.reopened';
|
|
1852
|
+
readonly MESSAGE_RECEIVED: 'crm:message.received';
|
|
1853
|
+
readonly MESSAGE_SENT: 'crm:message.sent';
|
|
1854
1854
|
};
|
|
1855
|
-
type CrmEventName = (typeof CRM_EVENTS)[keyof typeof CRM_EVENTS];
|
|
1855
|
+
export type CrmEventName = (typeof CRM_EVENTS)[keyof typeof CRM_EVENTS];
|
|
1856
1856
|
//#endregion
|
|
1857
1857
|
//#region src/events/event-catalog.d.ts
|
|
1858
|
-
/**
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1858
|
+
/**
|
|
1859
|
+
* JSON-Schema object produced by `z.toJSONSchema` — what arc's registry consumes.
|
|
1860
|
+
*
|
|
1861
|
+
* `type` is DECLARED. This was `Record<string, unknown>`, which is neither what
|
|
1862
|
+
* `z.toJSONSchema` returns for an object schema nor what arc's `EventSchema`
|
|
1863
|
+
* accepts — arc requires `type: 'object'`. So the comment below claiming
|
|
1864
|
+
* structural identity with arc's `EventDefinitionOutput` was false, and a host
|
|
1865
|
+
* registering this catalog got a type error whose only cheap escapes were a
|
|
1866
|
+
* cast or re-declaring the events locally. Every runtime value already carries
|
|
1867
|
+
* `type: 'object'`; only the declaration was loose.
|
|
1868
|
+
*
|
|
1869
|
+
* Same fix, same reason, as `@classytic/transfer`'s `TransferEventSchema` —
|
|
1870
|
+
* read the note there. Enforcement is at the CONSUMER: be-prod's
|
|
1871
|
+
* `shared/event-registry.ts` hands these straight to arc, so drift fails that
|
|
1872
|
+
* build. A kernel must not import arc, which is why the claim can only be
|
|
1873
|
+
* checked where both are visible.
|
|
1874
|
+
*/
|
|
1875
|
+
export interface CrmEventSchema {
|
|
1876
|
+
type: 'object';
|
|
1877
|
+
properties?: Record<string, {
|
|
1878
|
+
type?: string;
|
|
1879
|
+
[key: string]: unknown;
|
|
1880
|
+
}>;
|
|
1881
|
+
required?: string[];
|
|
1882
|
+
[key: string]: unknown;
|
|
1883
|
+
}
|
|
1884
|
+
/** Structurally assignable to arc's `EventDefinitionOutput` — do NOT import arc. */
|
|
1885
|
+
export interface CrmEventDefinition<TSchema extends z.ZodType = z.ZodType> {
|
|
1862
1886
|
name: CrmEventName;
|
|
1863
1887
|
version: number;
|
|
1864
1888
|
description: string;
|
|
@@ -1866,62 +1890,62 @@ interface CrmEventDefinition<TSchema extends z.ZodType = z.ZodType> {
|
|
|
1866
1890
|
schema: CrmEventSchema;
|
|
1867
1891
|
create(payload: z.infer<TSchema>, meta?: Partial<EventMeta>): DomainEvent<z.infer<TSchema>>;
|
|
1868
1892
|
}
|
|
1869
|
-
declare const LeadCreated: CrmEventDefinition<z.ZodObject<{
|
|
1893
|
+
export declare const LeadCreated: CrmEventDefinition<z.ZodObject<{
|
|
1870
1894
|
leadId: z.ZodString;
|
|
1871
1895
|
email: z.ZodOptional<z.ZodString>;
|
|
1872
1896
|
score: z.ZodNumber;
|
|
1873
1897
|
}, z.core.$strip>>;
|
|
1874
|
-
declare const LeadStatusChanged: CrmEventDefinition<z.ZodObject<{
|
|
1898
|
+
export declare const LeadStatusChanged: CrmEventDefinition<z.ZodObject<{
|
|
1875
1899
|
leadId: z.ZodString;
|
|
1876
1900
|
from: z.ZodString;
|
|
1877
1901
|
to: z.ZodString;
|
|
1878
1902
|
}, z.core.$strip>>;
|
|
1879
|
-
declare const LeadScored: CrmEventDefinition<z.ZodObject<{
|
|
1903
|
+
export declare const LeadScored: CrmEventDefinition<z.ZodObject<{
|
|
1880
1904
|
leadId: z.ZodString;
|
|
1881
1905
|
score: z.ZodNumber;
|
|
1882
1906
|
}, z.core.$strip>>;
|
|
1883
|
-
declare const LeadConverted: CrmEventDefinition<z.ZodObject<{
|
|
1907
|
+
export declare const LeadConverted: CrmEventDefinition<z.ZodObject<{
|
|
1884
1908
|
leadId: z.ZodString;
|
|
1885
1909
|
contactId: z.ZodString;
|
|
1886
1910
|
accountId: z.ZodOptional<z.ZodString>;
|
|
1887
1911
|
opportunityId: z.ZodString;
|
|
1888
1912
|
}, z.core.$strip>>;
|
|
1889
|
-
declare const LeadDisqualified: CrmEventDefinition<z.ZodObject<{
|
|
1913
|
+
export declare const LeadDisqualified: CrmEventDefinition<z.ZodObject<{
|
|
1890
1914
|
leadId: z.ZodString;
|
|
1891
1915
|
reason: z.ZodString;
|
|
1892
1916
|
}, z.core.$strip>>;
|
|
1893
|
-
declare const LeadEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1894
|
-
leadId: z.ZodString;
|
|
1917
|
+
export declare const LeadEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1895
1918
|
fields: z.ZodArray<z.ZodString>;
|
|
1896
1919
|
provider: z.ZodOptional<z.ZodString>;
|
|
1897
|
-
}, z.core.$strip>>;
|
|
1898
|
-
declare const LeadAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1899
1920
|
leadId: z.ZodString;
|
|
1921
|
+
}, z.core.$strip>>;
|
|
1922
|
+
export declare const LeadAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1900
1923
|
ownerId: z.ZodString;
|
|
1901
1924
|
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1925
|
+
leadId: z.ZodString;
|
|
1902
1926
|
}, z.core.$strip>>;
|
|
1903
|
-
declare const LeadAnonymized: CrmEventDefinition<z.ZodObject<{
|
|
1927
|
+
export declare const LeadAnonymized: CrmEventDefinition<z.ZodObject<{
|
|
1904
1928
|
leadId: z.ZodString;
|
|
1905
1929
|
fields: z.ZodArray<z.ZodString>;
|
|
1906
1930
|
}, z.core.$strip>>;
|
|
1907
|
-
declare const AccountCreated: CrmEventDefinition<z.ZodObject<{
|
|
1931
|
+
export declare const AccountCreated: CrmEventDefinition<z.ZodObject<{
|
|
1908
1932
|
accountId: z.ZodString;
|
|
1909
1933
|
name: z.ZodString;
|
|
1910
1934
|
}, z.core.$strip>>;
|
|
1911
|
-
declare const AccountUpdated: CrmEventDefinition<z.ZodObject<{
|
|
1935
|
+
export declare const AccountUpdated: CrmEventDefinition<z.ZodObject<{
|
|
1912
1936
|
accountId: z.ZodString;
|
|
1913
1937
|
}, z.core.$strip>>;
|
|
1914
|
-
declare const AccountEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1915
|
-
accountId: z.ZodString;
|
|
1938
|
+
export declare const AccountEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1916
1939
|
fields: z.ZodArray<z.ZodString>;
|
|
1917
1940
|
provider: z.ZodOptional<z.ZodString>;
|
|
1918
|
-
}, z.core.$strip>>;
|
|
1919
|
-
declare const AccountAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1920
1941
|
accountId: z.ZodString;
|
|
1942
|
+
}, z.core.$strip>>;
|
|
1943
|
+
export declare const AccountAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1921
1944
|
ownerId: z.ZodString;
|
|
1922
1945
|
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1946
|
+
accountId: z.ZodString;
|
|
1923
1947
|
}, z.core.$strip>>;
|
|
1924
|
-
declare const AccountMerged: CrmEventDefinition<z.ZodObject<{
|
|
1948
|
+
export declare const AccountMerged: CrmEventDefinition<z.ZodObject<{
|
|
1925
1949
|
primaryId: z.ZodString;
|
|
1926
1950
|
secondaryId: z.ZodString;
|
|
1927
1951
|
strategy: z.ZodEnum<{
|
|
@@ -1929,24 +1953,24 @@ declare const AccountMerged: CrmEventDefinition<z.ZodObject<{
|
|
|
1929
1953
|
preferSecondary: "preferSecondary";
|
|
1930
1954
|
}>;
|
|
1931
1955
|
}, z.core.$strip>>;
|
|
1932
|
-
declare const ContactCreated: CrmEventDefinition<z.ZodObject<{
|
|
1956
|
+
export declare const ContactCreated: CrmEventDefinition<z.ZodObject<{
|
|
1933
1957
|
contactId: z.ZodString;
|
|
1934
1958
|
email: z.ZodOptional<z.ZodString>;
|
|
1935
1959
|
}, z.core.$strip>>;
|
|
1936
|
-
declare const ContactUpdated: CrmEventDefinition<z.ZodObject<{
|
|
1960
|
+
export declare const ContactUpdated: CrmEventDefinition<z.ZodObject<{
|
|
1937
1961
|
contactId: z.ZodString;
|
|
1938
1962
|
}, z.core.$strip>>;
|
|
1939
|
-
declare const ContactEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1940
|
-
contactId: z.ZodString;
|
|
1963
|
+
export declare const ContactEnriched: CrmEventDefinition<z.ZodObject<{
|
|
1941
1964
|
fields: z.ZodArray<z.ZodString>;
|
|
1942
1965
|
provider: z.ZodOptional<z.ZodString>;
|
|
1943
|
-
}, z.core.$strip>>;
|
|
1944
|
-
declare const ContactAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1945
1966
|
contactId: z.ZodString;
|
|
1967
|
+
}, z.core.$strip>>;
|
|
1968
|
+
export declare const ContactAssigned: CrmEventDefinition<z.ZodObject<{
|
|
1946
1969
|
ownerId: z.ZodString;
|
|
1947
1970
|
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
1971
|
+
contactId: z.ZodString;
|
|
1948
1972
|
}, z.core.$strip>>;
|
|
1949
|
-
declare const ContactMerged: CrmEventDefinition<z.ZodObject<{
|
|
1973
|
+
export declare const ContactMerged: CrmEventDefinition<z.ZodObject<{
|
|
1950
1974
|
primaryId: z.ZodString;
|
|
1951
1975
|
secondaryId: z.ZodString;
|
|
1952
1976
|
strategy: z.ZodEnum<{
|
|
@@ -1954,16 +1978,16 @@ declare const ContactMerged: CrmEventDefinition<z.ZodObject<{
|
|
|
1954
1978
|
preferSecondary: "preferSecondary";
|
|
1955
1979
|
}>;
|
|
1956
1980
|
}, z.core.$strip>>;
|
|
1957
|
-
declare const ContactAnonymized: CrmEventDefinition<z.ZodObject<{
|
|
1981
|
+
export declare const ContactAnonymized: CrmEventDefinition<z.ZodObject<{
|
|
1958
1982
|
contactId: z.ZodString;
|
|
1959
1983
|
fields: z.ZodArray<z.ZodString>;
|
|
1960
1984
|
}, z.core.$strip>>;
|
|
1961
|
-
declare const OpportunityCreated: CrmEventDefinition<z.ZodObject<{
|
|
1985
|
+
export declare const OpportunityCreated: CrmEventDefinition<z.ZodObject<{
|
|
1962
1986
|
opportunityId: z.ZodString;
|
|
1963
1987
|
pipelineId: z.ZodString;
|
|
1964
1988
|
stageId: z.ZodString;
|
|
1965
1989
|
}, z.core.$strip>>;
|
|
1966
|
-
declare const OpportunityStageAdvanced: CrmEventDefinition<z.ZodObject<{
|
|
1990
|
+
export declare const OpportunityStageAdvanced: CrmEventDefinition<z.ZodObject<{
|
|
1967
1991
|
opportunityId: z.ZodString;
|
|
1968
1992
|
from: z.ZodObject<{
|
|
1969
1993
|
stageId: z.ZodString;
|
|
@@ -1974,7 +1998,7 @@ declare const OpportunityStageAdvanced: CrmEventDefinition<z.ZodObject<{
|
|
|
1974
1998
|
sequence: z.ZodNumber;
|
|
1975
1999
|
}, z.core.$strip>;
|
|
1976
2000
|
}, z.core.$strip>>;
|
|
1977
|
-
declare const OpportunityStageRegressed: CrmEventDefinition<z.ZodObject<{
|
|
2001
|
+
export declare const OpportunityStageRegressed: CrmEventDefinition<z.ZodObject<{
|
|
1978
2002
|
opportunityId: z.ZodString;
|
|
1979
2003
|
from: z.ZodObject<{
|
|
1980
2004
|
stageId: z.ZodString;
|
|
@@ -1985,248 +2009,248 @@ declare const OpportunityStageRegressed: CrmEventDefinition<z.ZodObject<{
|
|
|
1985
2009
|
sequence: z.ZodNumber;
|
|
1986
2010
|
}, z.core.$strip>;
|
|
1987
2011
|
}, z.core.$strip>>;
|
|
1988
|
-
declare const OpportunityWon: CrmEventDefinition<z.ZodObject<{
|
|
2012
|
+
export declare const OpportunityWon: CrmEventDefinition<z.ZodObject<{
|
|
1989
2013
|
opportunityId: z.ZodString;
|
|
1990
2014
|
amount: z.ZodOptional<z.ZodNumber>;
|
|
1991
2015
|
}, z.core.$strip>>;
|
|
1992
|
-
declare const OpportunityLost: CrmEventDefinition<z.ZodObject<{
|
|
2016
|
+
export declare const OpportunityLost: CrmEventDefinition<z.ZodObject<{
|
|
1993
2017
|
opportunityId: z.ZodString;
|
|
1994
2018
|
lostReasonId: z.ZodOptional<z.ZodString>;
|
|
1995
2019
|
}, z.core.$strip>>;
|
|
1996
|
-
declare const OpportunityAbandoned: CrmEventDefinition<z.ZodObject<{
|
|
2020
|
+
export declare const OpportunityAbandoned: CrmEventDefinition<z.ZodObject<{
|
|
1997
2021
|
opportunityId: z.ZodString;
|
|
1998
2022
|
}, z.core.$strip>>;
|
|
1999
|
-
declare const OpportunityAssigned: CrmEventDefinition<z.ZodObject<{
|
|
2000
|
-
opportunityId: z.ZodString;
|
|
2023
|
+
export declare const OpportunityAssigned: CrmEventDefinition<z.ZodObject<{
|
|
2001
2024
|
ownerId: z.ZodString;
|
|
2002
2025
|
previousOwnerId: z.ZodOptional<z.ZodString>;
|
|
2026
|
+
opportunityId: z.ZodString;
|
|
2003
2027
|
}, z.core.$strip>>;
|
|
2004
|
-
declare const OpportunityAmountChanged: CrmEventDefinition<z.ZodObject<{
|
|
2028
|
+
export declare const OpportunityAmountChanged: CrmEventDefinition<z.ZodObject<{
|
|
2005
2029
|
opportunityId: z.ZodString;
|
|
2006
2030
|
amount: z.ZodNumber;
|
|
2007
2031
|
previousAmount: z.ZodOptional<z.ZodNumber>;
|
|
2008
2032
|
reason: z.ZodOptional<z.ZodString>;
|
|
2009
2033
|
by: z.ZodOptional<z.ZodString>;
|
|
2010
2034
|
}, z.core.$strip>>;
|
|
2011
|
-
declare const OpportunityExtended: CrmEventDefinition<z.ZodObject<{
|
|
2035
|
+
export declare const OpportunityExtended: CrmEventDefinition<z.ZodObject<{
|
|
2012
2036
|
opportunityId: z.ZodString;
|
|
2013
2037
|
expectedCloseAt: z.ZodISODateTime;
|
|
2014
2038
|
previousExpectedCloseAt: z.ZodOptional<z.ZodISODateTime>;
|
|
2015
2039
|
reason: z.ZodOptional<z.ZodString>;
|
|
2016
2040
|
by: z.ZodOptional<z.ZodString>;
|
|
2017
2041
|
}, z.core.$strip>>;
|
|
2018
|
-
declare const PipelineCreated: CrmEventDefinition<z.ZodObject<{
|
|
2042
|
+
export declare const PipelineCreated: CrmEventDefinition<z.ZodObject<{
|
|
2019
2043
|
pipelineId: z.ZodString;
|
|
2020
2044
|
}, z.core.$strip>>;
|
|
2021
|
-
declare const PipelineArchived: CrmEventDefinition<z.ZodObject<{
|
|
2045
|
+
export declare const PipelineArchived: CrmEventDefinition<z.ZodObject<{
|
|
2022
2046
|
pipelineId: z.ZodString;
|
|
2023
2047
|
}, z.core.$strip>>;
|
|
2024
|
-
declare const ActivityPlanned: CrmEventDefinition<z.ZodObject<{
|
|
2048
|
+
export declare const ActivityPlanned: CrmEventDefinition<z.ZodObject<{
|
|
2025
2049
|
activityId: z.ZodString;
|
|
2026
2050
|
type: z.ZodString;
|
|
2027
2051
|
subjectKind: z.ZodString;
|
|
2028
2052
|
subjectId: z.ZodString;
|
|
2029
2053
|
}, z.core.$strip>>;
|
|
2030
|
-
declare const ActivityCompleted: CrmEventDefinition<z.ZodObject<{
|
|
2054
|
+
export declare const ActivityCompleted: CrmEventDefinition<z.ZodObject<{
|
|
2031
2055
|
activityId: z.ZodString;
|
|
2032
2056
|
completedAt: z.ZodISODateTime;
|
|
2033
2057
|
}, z.core.$strip>>;
|
|
2034
|
-
declare const ActivityCancelled: CrmEventDefinition<z.ZodObject<{
|
|
2058
|
+
export declare const ActivityCancelled: CrmEventDefinition<z.ZodObject<{
|
|
2035
2059
|
activityId: z.ZodString;
|
|
2036
2060
|
reason: z.ZodOptional<z.ZodString>;
|
|
2037
2061
|
}, z.core.$strip>>;
|
|
2038
|
-
declare const ActivityRescheduled: CrmEventDefinition<z.ZodObject<{
|
|
2062
|
+
export declare const ActivityRescheduled: CrmEventDefinition<z.ZodObject<{
|
|
2039
2063
|
activityId: z.ZodString;
|
|
2040
2064
|
dueDate: z.ZodISODateTime;
|
|
2041
2065
|
previousDueDate: z.ZodOptional<z.ZodISODateTime>;
|
|
2042
2066
|
reason: z.ZodOptional<z.ZodString>;
|
|
2043
2067
|
by: z.ZodOptional<z.ZodString>;
|
|
2044
2068
|
}, z.core.$strip>>;
|
|
2045
|
-
declare const ActivityOutcomeRecorded: CrmEventDefinition<z.ZodObject<{
|
|
2069
|
+
export declare const ActivityOutcomeRecorded: CrmEventDefinition<z.ZodObject<{
|
|
2046
2070
|
activityId: z.ZodString;
|
|
2047
2071
|
outcome: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2048
2072
|
}, z.core.$strip>>;
|
|
2049
|
-
declare const NoteAdded: CrmEventDefinition<z.ZodObject<{
|
|
2073
|
+
export declare const NoteAdded: CrmEventDefinition<z.ZodObject<{
|
|
2050
2074
|
noteId: z.ZodString;
|
|
2051
2075
|
subjectKind: z.ZodString;
|
|
2052
2076
|
subjectId: z.ZodString;
|
|
2053
2077
|
}, z.core.$strip>>;
|
|
2054
|
-
declare const CampaignCreated: CrmEventDefinition<z.ZodObject<{
|
|
2078
|
+
export declare const CampaignCreated: CrmEventDefinition<z.ZodObject<{
|
|
2055
2079
|
campaignId: z.ZodString;
|
|
2056
2080
|
name: z.ZodString;
|
|
2057
2081
|
}, z.core.$strip>>;
|
|
2058
|
-
declare const CampaignActivated: CrmEventDefinition<z.ZodObject<{
|
|
2082
|
+
export declare const CampaignActivated: CrmEventDefinition<z.ZodObject<{
|
|
2059
2083
|
campaignId: z.ZodString;
|
|
2060
2084
|
}, z.core.$strip>>;
|
|
2061
|
-
declare const CampaignPaused: CrmEventDefinition<z.ZodObject<{
|
|
2085
|
+
export declare const CampaignPaused: CrmEventDefinition<z.ZodObject<{
|
|
2062
2086
|
campaignId: z.ZodString;
|
|
2063
2087
|
reason: z.ZodOptional<z.ZodString>;
|
|
2064
2088
|
}, z.core.$strip>>;
|
|
2065
|
-
declare const CampaignResumed: CrmEventDefinition<z.ZodObject<{
|
|
2089
|
+
export declare const CampaignResumed: CrmEventDefinition<z.ZodObject<{
|
|
2066
2090
|
campaignId: z.ZodString;
|
|
2067
2091
|
}, z.core.$strip>>;
|
|
2068
|
-
declare const CampaignCompleted: CrmEventDefinition<z.ZodObject<{
|
|
2092
|
+
export declare const CampaignCompleted: CrmEventDefinition<z.ZodObject<{
|
|
2069
2093
|
campaignId: z.ZodString;
|
|
2070
2094
|
actualRevenueAmount: z.ZodOptional<z.ZodNumber>;
|
|
2071
2095
|
}, z.core.$strip>>;
|
|
2072
|
-
declare const CampaignArchived: CrmEventDefinition<z.ZodObject<{
|
|
2096
|
+
export declare const CampaignArchived: CrmEventDefinition<z.ZodObject<{
|
|
2073
2097
|
campaignId: z.ZodString;
|
|
2074
2098
|
}, z.core.$strip>>;
|
|
2075
|
-
declare const SubscriptionCreated: CrmEventDefinition<z.ZodObject<{
|
|
2099
|
+
export declare const SubscriptionCreated: CrmEventDefinition<z.ZodObject<{
|
|
2076
2100
|
subscriptionId: z.ZodString;
|
|
2077
2101
|
contactId: z.ZodString;
|
|
2078
2102
|
campaignId: z.ZodString;
|
|
2079
2103
|
requiresConfirmation: z.ZodBoolean;
|
|
2080
2104
|
}, z.core.$strip>>;
|
|
2081
|
-
declare const SubscriptionConfirmed: CrmEventDefinition<z.ZodObject<{
|
|
2105
|
+
export declare const SubscriptionConfirmed: CrmEventDefinition<z.ZodObject<{
|
|
2082
2106
|
subscriptionId: z.ZodString;
|
|
2083
2107
|
contactId: z.ZodString;
|
|
2084
2108
|
campaignId: z.ZodString;
|
|
2085
2109
|
confirmedAt: z.ZodISODateTime;
|
|
2086
2110
|
}, z.core.$strip>>;
|
|
2087
|
-
declare const SubscriptionUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
2111
|
+
export declare const SubscriptionUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
2088
2112
|
subscriptionId: z.ZodString;
|
|
2089
2113
|
contactId: z.ZodString;
|
|
2090
2114
|
campaignId: z.ZodString;
|
|
2091
2115
|
reason: z.ZodOptional<z.ZodString>;
|
|
2092
2116
|
}, z.core.$strip>>;
|
|
2093
|
-
declare const SubscriptionBounced: CrmEventDefinition<z.ZodObject<{
|
|
2117
|
+
export declare const SubscriptionBounced: CrmEventDefinition<z.ZodObject<{
|
|
2094
2118
|
subscriptionId: z.ZodString;
|
|
2095
2119
|
contactId: z.ZodString;
|
|
2096
2120
|
campaignId: z.ZodString;
|
|
2097
2121
|
reason: z.ZodOptional<z.ZodString>;
|
|
2098
2122
|
}, z.core.$strip>>;
|
|
2099
|
-
declare const SubscriptionComplained: CrmEventDefinition<z.ZodObject<{
|
|
2123
|
+
export declare const SubscriptionComplained: CrmEventDefinition<z.ZodObject<{
|
|
2100
2124
|
subscriptionId: z.ZodString;
|
|
2101
2125
|
contactId: z.ZodString;
|
|
2102
2126
|
campaignId: z.ZodString;
|
|
2103
2127
|
}, z.core.$strip>>;
|
|
2104
|
-
declare const SuppressionAdded: CrmEventDefinition<z.ZodObject<{
|
|
2128
|
+
export declare const SuppressionAdded: CrmEventDefinition<z.ZodObject<{
|
|
2105
2129
|
email: z.ZodString;
|
|
2106
2130
|
reason: z.ZodEnum<{
|
|
2107
2131
|
bounce: "bounce";
|
|
2108
2132
|
complaint: "complaint";
|
|
2109
|
-
unsubscribe: "unsubscribe";
|
|
2110
2133
|
manual: "manual";
|
|
2134
|
+
unsubscribe: "unsubscribe";
|
|
2111
2135
|
}>;
|
|
2112
2136
|
source: z.ZodOptional<z.ZodString>;
|
|
2113
2137
|
}, z.core.$strip>>;
|
|
2114
|
-
declare const SuppressionRemoved: CrmEventDefinition<z.ZodObject<{
|
|
2138
|
+
export declare const SuppressionRemoved: CrmEventDefinition<z.ZodObject<{
|
|
2115
2139
|
email: z.ZodString;
|
|
2116
2140
|
}, z.core.$strip>>;
|
|
2117
|
-
declare const EmailEventOpened: CrmEventDefinition<z.ZodObject<{
|
|
2141
|
+
export declare const EmailEventOpened: CrmEventDefinition<z.ZodObject<{
|
|
2118
2142
|
eventId: z.ZodString;
|
|
2119
2143
|
kind: z.ZodString;
|
|
2120
2144
|
subjectKind: z.ZodString;
|
|
2121
2145
|
subjectId: z.ZodString;
|
|
2122
2146
|
campaignId: z.ZodOptional<z.ZodString>;
|
|
2123
2147
|
}, z.core.$strip>>;
|
|
2124
|
-
declare const EmailEventClicked: CrmEventDefinition<z.ZodObject<{
|
|
2148
|
+
export declare const EmailEventClicked: CrmEventDefinition<z.ZodObject<{
|
|
2125
2149
|
eventId: z.ZodString;
|
|
2126
2150
|
kind: z.ZodString;
|
|
2127
2151
|
subjectKind: z.ZodString;
|
|
2128
2152
|
subjectId: z.ZodString;
|
|
2129
2153
|
campaignId: z.ZodOptional<z.ZodString>;
|
|
2130
2154
|
}, z.core.$strip>>;
|
|
2131
|
-
declare const EmailEventBounced: CrmEventDefinition<z.ZodObject<{
|
|
2155
|
+
export declare const EmailEventBounced: CrmEventDefinition<z.ZodObject<{
|
|
2132
2156
|
eventId: z.ZodString;
|
|
2133
2157
|
kind: z.ZodString;
|
|
2134
2158
|
subjectKind: z.ZodString;
|
|
2135
2159
|
subjectId: z.ZodString;
|
|
2136
2160
|
campaignId: z.ZodOptional<z.ZodString>;
|
|
2137
2161
|
}, z.core.$strip>>;
|
|
2138
|
-
declare const EmailEventComplained: CrmEventDefinition<z.ZodObject<{
|
|
2162
|
+
export declare const EmailEventComplained: CrmEventDefinition<z.ZodObject<{
|
|
2139
2163
|
eventId: z.ZodString;
|
|
2140
2164
|
kind: z.ZodString;
|
|
2141
2165
|
subjectKind: z.ZodString;
|
|
2142
2166
|
subjectId: z.ZodString;
|
|
2143
2167
|
campaignId: z.ZodOptional<z.ZodString>;
|
|
2144
2168
|
}, z.core.$strip>>;
|
|
2145
|
-
declare const EmailEventUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
2169
|
+
export declare const EmailEventUnsubscribed: CrmEventDefinition<z.ZodObject<{
|
|
2146
2170
|
eventId: z.ZodString;
|
|
2147
2171
|
kind: z.ZodString;
|
|
2148
2172
|
subjectKind: z.ZodString;
|
|
2149
2173
|
subjectId: z.ZodString;
|
|
2150
2174
|
campaignId: z.ZodOptional<z.ZodString>;
|
|
2151
2175
|
}, z.core.$strip>>;
|
|
2152
|
-
declare const ConversationCreated: CrmEventDefinition<z.ZodObject<{
|
|
2176
|
+
export declare const ConversationCreated: CrmEventDefinition<z.ZodObject<{
|
|
2153
2177
|
conversationId: z.ZodString;
|
|
2154
2178
|
channel: z.ZodString;
|
|
2155
2179
|
participantKind: z.ZodString;
|
|
2156
2180
|
participantId: z.ZodString;
|
|
2157
2181
|
}, z.core.$strip>>;
|
|
2158
|
-
declare const ConversationAssigned: CrmEventDefinition<z.ZodObject<{
|
|
2182
|
+
export declare const ConversationAssigned: CrmEventDefinition<z.ZodObject<{
|
|
2159
2183
|
conversationId: z.ZodString;
|
|
2160
2184
|
assigneeId: z.ZodString;
|
|
2161
2185
|
previousAssigneeId: z.ZodOptional<z.ZodString>;
|
|
2162
2186
|
}, z.core.$strip>>;
|
|
2163
|
-
declare const ConversationResolved: CrmEventDefinition<z.ZodObject<{
|
|
2187
|
+
export declare const ConversationResolved: CrmEventDefinition<z.ZodObject<{
|
|
2164
2188
|
conversationId: z.ZodString;
|
|
2165
2189
|
status: z.ZodString;
|
|
2166
2190
|
previousStatus: z.ZodString;
|
|
2167
2191
|
}, z.core.$strip>>;
|
|
2168
|
-
declare const ConversationReopened: CrmEventDefinition<z.ZodObject<{
|
|
2192
|
+
export declare const ConversationReopened: CrmEventDefinition<z.ZodObject<{
|
|
2169
2193
|
conversationId: z.ZodString;
|
|
2170
2194
|
status: z.ZodString;
|
|
2171
2195
|
previousStatus: z.ZodString;
|
|
2172
2196
|
}, z.core.$strip>>;
|
|
2173
|
-
declare const MessageReceived: CrmEventDefinition<z.ZodObject<{
|
|
2197
|
+
export declare const MessageReceived: CrmEventDefinition<z.ZodObject<{
|
|
2174
2198
|
messageId: z.ZodString;
|
|
2175
2199
|
conversationId: z.ZodString;
|
|
2176
2200
|
direction: z.ZodString;
|
|
2177
2201
|
externalMessageId: z.ZodOptional<z.ZodString>;
|
|
2178
2202
|
}, z.core.$strip>>;
|
|
2179
|
-
declare const MessageSent: CrmEventDefinition<z.ZodObject<{
|
|
2203
|
+
export declare const MessageSent: CrmEventDefinition<z.ZodObject<{
|
|
2180
2204
|
messageId: z.ZodString;
|
|
2181
2205
|
conversationId: z.ZodString;
|
|
2182
2206
|
direction: z.ZodString;
|
|
2183
2207
|
externalMessageId: z.ZodOptional<z.ZodString>;
|
|
2184
2208
|
}, z.core.$strip>>;
|
|
2185
|
-
declare const SequenceCreated: CrmEventDefinition<z.ZodObject<{
|
|
2209
|
+
export declare const SequenceCreated: CrmEventDefinition<z.ZodObject<{
|
|
2186
2210
|
sequenceId: z.ZodString;
|
|
2187
2211
|
name: z.ZodOptional<z.ZodString>;
|
|
2188
2212
|
}, z.core.$strip>>;
|
|
2189
|
-
declare const SequenceActivated: CrmEventDefinition<z.ZodObject<{
|
|
2213
|
+
export declare const SequenceActivated: CrmEventDefinition<z.ZodObject<{
|
|
2190
2214
|
sequenceId: z.ZodString;
|
|
2191
2215
|
}, z.core.$strip>>;
|
|
2192
|
-
declare const SequencePaused: CrmEventDefinition<z.ZodObject<{
|
|
2216
|
+
export declare const SequencePaused: CrmEventDefinition<z.ZodObject<{
|
|
2193
2217
|
sequenceId: z.ZodString;
|
|
2194
2218
|
}, z.core.$strip>>;
|
|
2195
|
-
declare const SequenceArchived: CrmEventDefinition<z.ZodObject<{
|
|
2219
|
+
export declare const SequenceArchived: CrmEventDefinition<z.ZodObject<{
|
|
2196
2220
|
sequenceId: z.ZodString;
|
|
2197
2221
|
}, z.core.$strip>>;
|
|
2198
|
-
declare const EnrollmentCreated: CrmEventDefinition<z.ZodObject<{
|
|
2222
|
+
export declare const EnrollmentCreated: CrmEventDefinition<z.ZodObject<{
|
|
2199
2223
|
enrollmentId: z.ZodString;
|
|
2200
2224
|
sequenceId: z.ZodString;
|
|
2201
2225
|
subjectId: z.ZodString;
|
|
2202
2226
|
subjectKind: z.ZodString;
|
|
2203
2227
|
}, z.core.$strip>>;
|
|
2204
|
-
declare const EnrollmentStepSent: CrmEventDefinition<z.ZodObject<{
|
|
2228
|
+
export declare const EnrollmentStepSent: CrmEventDefinition<z.ZodObject<{
|
|
2205
2229
|
enrollmentId: z.ZodString;
|
|
2206
2230
|
sequenceId: z.ZodOptional<z.ZodString>;
|
|
2207
2231
|
stepIndex: z.ZodNumber;
|
|
2208
2232
|
channel: z.ZodOptional<z.ZodString>;
|
|
2209
2233
|
}, z.core.$strip>>;
|
|
2210
|
-
declare const EnrollmentPaused: CrmEventDefinition<z.ZodObject<{
|
|
2234
|
+
export declare const EnrollmentPaused: CrmEventDefinition<z.ZodObject<{
|
|
2211
2235
|
enrollmentId: z.ZodString;
|
|
2212
2236
|
}, z.core.$strip>>;
|
|
2213
|
-
declare const EnrollmentResumed: CrmEventDefinition<z.ZodObject<{
|
|
2237
|
+
export declare const EnrollmentResumed: CrmEventDefinition<z.ZodObject<{
|
|
2214
2238
|
enrollmentId: z.ZodString;
|
|
2215
2239
|
}, z.core.$strip>>;
|
|
2216
|
-
declare const EnrollmentCompleted: CrmEventDefinition<z.ZodObject<{
|
|
2240
|
+
export declare const EnrollmentCompleted: CrmEventDefinition<z.ZodObject<{
|
|
2217
2241
|
enrollmentId: z.ZodString;
|
|
2218
2242
|
}, z.core.$strip>>;
|
|
2219
|
-
declare const EnrollmentExited: CrmEventDefinition<z.ZodObject<{
|
|
2243
|
+
export declare const EnrollmentExited: CrmEventDefinition<z.ZodObject<{
|
|
2220
2244
|
enrollmentId: z.ZodString;
|
|
2221
2245
|
exitReason: z.ZodOptional<z.ZodString>;
|
|
2222
2246
|
}, z.core.$strip>>;
|
|
2223
|
-
declare const crmEventDefinitions: ReadonlyArray<CrmEventDefinition>;
|
|
2247
|
+
export declare const crmEventDefinitions: ReadonlyArray<CrmEventDefinition>;
|
|
2224
2248
|
//#endregion
|
|
2225
2249
|
//#region src/events/helpers.d.ts
|
|
2226
|
-
declare function createEvent<T>(type: string, payload: T, ctx?: CrmContext, meta?: Partial<EventMeta>): DomainEvent<T>;
|
|
2250
|
+
export declare function createEvent<T>(type: string, payload: T, ctx?: CrmContext, meta?: Partial<EventMeta>): DomainEvent<T>;
|
|
2227
2251
|
//#endregion
|
|
2228
2252
|
//#region src/events/in-process-bus.d.ts
|
|
2229
|
-
declare class InProcessCrmBus extends InProcessEventBus {
|
|
2253
|
+
export declare class InProcessCrmBus extends InProcessEventBus {
|
|
2230
2254
|
constructor(options?: {
|
|
2231
2255
|
logger?: CrmLogger;
|
|
2232
2256
|
});
|
|
@@ -2241,7 +2265,7 @@ interface RunUnitConfig {
|
|
|
2241
2265
|
/** Standalone-Mongo fallback (local dev) — partial-write risk, explicit opt-in. */
|
|
2242
2266
|
allowNonTransactional: boolean;
|
|
2243
2267
|
}
|
|
2244
|
-
declare function runUnit<T>(config: RunUnitConfig, ctx: CrmContext, body: (innerCtx: CrmContext) => Promise<T>): Promise<T>;
|
|
2268
|
+
export declare function runUnit<T>(config: RunUnitConfig, ctx: CrmContext, body: (innerCtx: CrmContext) => Promise<T>): Promise<T>;
|
|
2245
2269
|
//#endregion
|
|
2246
2270
|
//#region src/core/state-machines.d.ts
|
|
2247
2271
|
/**
|
|
@@ -2259,13 +2283,13 @@ declare function runUnit<T>(config: RunUnitConfig, ctx: CrmContext, body: (inner
|
|
|
2259
2283
|
* Built on `@classytic/primitives/state-machine` so the same shape lights
|
|
2260
2284
|
* up across kits (mongokit's `claim()` pairing, sqlitekit follow-ups).
|
|
2261
2285
|
*/
|
|
2262
|
-
declare const LEAD_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"
|
|
2263
|
-
declare const OPPORTUNITY_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"
|
|
2264
|
-
declare const CAMPAIGN_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"
|
|
2265
|
-
declare const SUBSCRIPTION_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"
|
|
2266
|
-
declare const ACTIVITY_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"
|
|
2267
|
-
declare const SEQUENCE_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"
|
|
2268
|
-
declare const ENROLLMENT_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"active" | "
|
|
2286
|
+
export declare const LEAD_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"contacted" | "converted" | "disqualified" | "new" | "nurturing" | "qualified">;
|
|
2287
|
+
export declare const OPPORTUNITY_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"abandoned" | "lost" | "open" | "won">;
|
|
2288
|
+
export declare const CAMPAIGN_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"active" | "archived" | "completed" | "draft" | "paused">;
|
|
2289
|
+
export declare const SUBSCRIPTION_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"bounced" | "complained" | "confirmed" | "pending" | "unsubscribed">;
|
|
2290
|
+
export declare const ACTIVITY_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"cancelled" | "completed" | "in_progress" | "planned">;
|
|
2291
|
+
export declare const SEQUENCE_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"active" | "archived" | "draft" | "paused">;
|
|
2292
|
+
export declare const ENROLLMENT_MACHINE: import("@classytic/primitives/state-machine").StateMachine<"active" | "completed" | "exited" | "paused">;
|
|
2269
2293
|
//#endregion
|
|
2270
2294
|
//#region src/core/errors.d.ts
|
|
2271
2295
|
/**
|
|
@@ -2281,17 +2305,17 @@ declare const ENROLLMENT_MACHINE: import("@classytic/primitives/state-machine").
|
|
|
2281
2305
|
* the common case here. Subclasses override with `readonly status = N`;
|
|
2282
2306
|
* the subclass field initializer runs after this constructor, so it wins.
|
|
2283
2307
|
*/
|
|
2284
|
-
declare class CrmError extends Error implements HttpError {
|
|
2308
|
+
export declare class CrmError extends Error implements HttpError {
|
|
2285
2309
|
readonly code: string;
|
|
2286
2310
|
readonly status: number;
|
|
2287
2311
|
readonly details?: Record<string, unknown>;
|
|
2288
2312
|
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
2289
2313
|
}
|
|
2290
|
-
declare class NotFoundError extends CrmError {
|
|
2314
|
+
export declare class NotFoundError extends CrmError {
|
|
2291
2315
|
readonly status = 404;
|
|
2292
2316
|
constructor(kind: string, id: string);
|
|
2293
2317
|
}
|
|
2294
|
-
declare class InvalidLeadTransitionError extends CrmError {
|
|
2318
|
+
export declare class InvalidLeadTransitionError extends CrmError {
|
|
2295
2319
|
readonly status = 422;
|
|
2296
2320
|
constructor(details: {
|
|
2297
2321
|
from: string;
|
|
@@ -2299,7 +2323,7 @@ declare class InvalidLeadTransitionError extends CrmError {
|
|
|
2299
2323
|
leadId: string;
|
|
2300
2324
|
});
|
|
2301
2325
|
}
|
|
2302
|
-
declare class InvalidOpportunityTransitionError extends CrmError {
|
|
2326
|
+
export declare class InvalidOpportunityTransitionError extends CrmError {
|
|
2303
2327
|
readonly status = 422;
|
|
2304
2328
|
constructor(details: {
|
|
2305
2329
|
from: string;
|
|
@@ -2307,7 +2331,7 @@ declare class InvalidOpportunityTransitionError extends CrmError {
|
|
|
2307
2331
|
opportunityId: string;
|
|
2308
2332
|
});
|
|
2309
2333
|
}
|
|
2310
|
-
declare class InvalidActivityTransitionError extends CrmError {
|
|
2334
|
+
export declare class InvalidActivityTransitionError extends CrmError {
|
|
2311
2335
|
readonly status = 422;
|
|
2312
2336
|
constructor(details: {
|
|
2313
2337
|
from: string;
|
|
@@ -2315,39 +2339,39 @@ declare class InvalidActivityTransitionError extends CrmError {
|
|
|
2315
2339
|
activityId: string;
|
|
2316
2340
|
});
|
|
2317
2341
|
}
|
|
2318
|
-
declare class StageNotInPipelineError extends CrmError {
|
|
2342
|
+
export declare class StageNotInPipelineError extends CrmError {
|
|
2319
2343
|
readonly status = 422;
|
|
2320
2344
|
constructor(details: {
|
|
2321
2345
|
pipelineId: string;
|
|
2322
2346
|
stageId: string;
|
|
2323
2347
|
});
|
|
2324
2348
|
}
|
|
2325
|
-
declare class LeadAlreadyConvertedError extends CrmError {
|
|
2349
|
+
export declare class LeadAlreadyConvertedError extends CrmError {
|
|
2326
2350
|
readonly status = 409;
|
|
2327
2351
|
constructor(leadId: string);
|
|
2328
2352
|
}
|
|
2329
|
-
declare class DuplicateLeadError extends CrmError {
|
|
2353
|
+
export declare class DuplicateLeadError extends CrmError {
|
|
2330
2354
|
readonly status = 409;
|
|
2331
2355
|
constructor(details: {
|
|
2332
2356
|
email?: string;
|
|
2333
2357
|
phone?: string;
|
|
2334
2358
|
});
|
|
2335
2359
|
}
|
|
2336
|
-
declare class DuplicateContactError extends CrmError {
|
|
2360
|
+
export declare class DuplicateContactError extends CrmError {
|
|
2337
2361
|
readonly status = 409;
|
|
2338
2362
|
constructor(details: {
|
|
2339
2363
|
email: string;
|
|
2340
2364
|
});
|
|
2341
2365
|
}
|
|
2342
|
-
declare class UnmanagedSessionError extends CrmError {
|
|
2366
|
+
export declare class UnmanagedSessionError extends CrmError {
|
|
2343
2367
|
readonly status = 500;
|
|
2344
2368
|
constructor(eventType?: string);
|
|
2345
2369
|
}
|
|
2346
|
-
declare class EmptyPipelineError extends CrmError {
|
|
2370
|
+
export declare class EmptyPipelineError extends CrmError {
|
|
2347
2371
|
readonly status = 422;
|
|
2348
2372
|
constructor(pipelineId: string);
|
|
2349
2373
|
}
|
|
2350
|
-
declare class InvalidCampaignTransitionError extends CrmError {
|
|
2374
|
+
export declare class InvalidCampaignTransitionError extends CrmError {
|
|
2351
2375
|
readonly status = 422;
|
|
2352
2376
|
constructor(details: {
|
|
2353
2377
|
from: string;
|
|
@@ -2355,11 +2379,11 @@ declare class InvalidCampaignTransitionError extends CrmError {
|
|
|
2355
2379
|
campaignId: string;
|
|
2356
2380
|
});
|
|
2357
2381
|
}
|
|
2358
|
-
declare class DuplicateCampaignError extends CrmError {
|
|
2382
|
+
export declare class DuplicateCampaignError extends CrmError {
|
|
2359
2383
|
readonly status = 409;
|
|
2360
2384
|
constructor(name: string);
|
|
2361
2385
|
}
|
|
2362
|
-
declare class InvalidSubscriptionTransitionError extends CrmError {
|
|
2386
|
+
export declare class InvalidSubscriptionTransitionError extends CrmError {
|
|
2363
2387
|
readonly status = 422;
|
|
2364
2388
|
constructor(details: {
|
|
2365
2389
|
from: string;
|
|
@@ -2367,22 +2391,22 @@ declare class InvalidSubscriptionTransitionError extends CrmError {
|
|
|
2367
2391
|
subscriptionId: string;
|
|
2368
2392
|
});
|
|
2369
2393
|
}
|
|
2370
|
-
declare class DuplicateSubscriptionError extends CrmError {
|
|
2394
|
+
export declare class DuplicateSubscriptionError extends CrmError {
|
|
2371
2395
|
readonly status = 409;
|
|
2372
2396
|
constructor(details: {
|
|
2373
2397
|
contactId: string;
|
|
2374
2398
|
campaignId: string;
|
|
2375
2399
|
});
|
|
2376
2400
|
}
|
|
2377
|
-
declare class InvalidConfirmationTokenError extends CrmError {
|
|
2401
|
+
export declare class InvalidConfirmationTokenError extends CrmError {
|
|
2378
2402
|
readonly status = 422;
|
|
2379
2403
|
constructor();
|
|
2380
2404
|
}
|
|
2381
|
-
declare class InvalidUnsubscribeTokenError extends CrmError {
|
|
2405
|
+
export declare class InvalidUnsubscribeTokenError extends CrmError {
|
|
2382
2406
|
readonly status = 422;
|
|
2383
2407
|
constructor();
|
|
2384
2408
|
}
|
|
2385
|
-
declare class InvalidSequenceTransitionError extends CrmError {
|
|
2409
|
+
export declare class InvalidSequenceTransitionError extends CrmError {
|
|
2386
2410
|
readonly status = 422;
|
|
2387
2411
|
constructor(details: {
|
|
2388
2412
|
from: string;
|
|
@@ -2390,7 +2414,7 @@ declare class InvalidSequenceTransitionError extends CrmError {
|
|
|
2390
2414
|
sequenceId: string;
|
|
2391
2415
|
});
|
|
2392
2416
|
}
|
|
2393
|
-
declare class InvalidEnrollmentTransitionError extends CrmError {
|
|
2417
|
+
export declare class InvalidEnrollmentTransitionError extends CrmError {
|
|
2394
2418
|
readonly status = 422;
|
|
2395
2419
|
constructor(details: {
|
|
2396
2420
|
from: string;
|
|
@@ -2398,7 +2422,7 @@ declare class InvalidEnrollmentTransitionError extends CrmError {
|
|
|
2398
2422
|
enrollmentId: string;
|
|
2399
2423
|
});
|
|
2400
2424
|
}
|
|
2401
|
-
declare class AlreadyEnrolledError extends CrmError {
|
|
2425
|
+
export declare class AlreadyEnrolledError extends CrmError {
|
|
2402
2426
|
readonly status = 409;
|
|
2403
2427
|
constructor(details: {
|
|
2404
2428
|
sequenceId: string;
|
|
@@ -2417,7 +2441,7 @@ declare class AlreadyEnrolledError extends CrmError {
|
|
|
2417
2441
|
* Only WRITES throw. Reads fail closed instead — see
|
|
2418
2442
|
* `suppression.repository.ts`, which writes the asymmetry down.
|
|
2419
2443
|
*/
|
|
2420
|
-
declare class SuppressionEmailFormatError extends CrmError {
|
|
2444
|
+
export declare class SuppressionEmailFormatError extends CrmError {
|
|
2421
2445
|
readonly status = 400;
|
|
2422
2446
|
constructor(details: {
|
|
2423
2447
|
email: string;
|
|
@@ -2432,7 +2456,7 @@ declare class SuppressionEmailFormatError extends CrmError {
|
|
|
2432
2456
|
* `core/email-identity.ts`, which owns the write-throws / setter-degrades
|
|
2433
2457
|
* asymmetry and writes down why each side goes the way it does.
|
|
2434
2458
|
*/
|
|
2435
|
-
declare class LeadEmailFormatError extends CrmError {
|
|
2459
|
+
export declare class LeadEmailFormatError extends CrmError {
|
|
2436
2460
|
readonly status = 400;
|
|
2437
2461
|
constructor(details: {
|
|
2438
2462
|
email: string;
|
|
@@ -2440,7 +2464,7 @@ declare class LeadEmailFormatError extends CrmError {
|
|
|
2440
2464
|
});
|
|
2441
2465
|
}
|
|
2442
2466
|
/** As {@link LeadEmailFormatError}, for `ContactRepository.createContact`. */
|
|
2443
|
-
declare class ContactEmailFormatError extends CrmError {
|
|
2467
|
+
export declare class ContactEmailFormatError extends CrmError {
|
|
2444
2468
|
readonly status = 400;
|
|
2445
2469
|
constructor(details: {
|
|
2446
2470
|
email: string;
|
|
@@ -2503,11 +2527,11 @@ declare class ContactEmailFormatError extends CrmError {
|
|
|
2503
2527
|
* Exported so a host can tell "not on file" apart from "not an address" without
|
|
2504
2528
|
* re-deriving the rule — the same reason `suppressionEmailKey` is exported.
|
|
2505
2529
|
*/
|
|
2506
|
-
declare function crmEmailKey(email: string): string | null;
|
|
2530
|
+
export declare function crmEmailKey(email: string): string | null;
|
|
2507
2531
|
//#endregion
|
|
2508
2532
|
//#region src/shared/calculators/forecast.d.ts
|
|
2509
|
-
type OpportunityForecast = Pick<IOpportunityDocument, 'amount' | 'currency' | 'probability' | 'status' | 'expectedCloseAt' | 'stageId' | 'statusHistory'>;
|
|
2510
|
-
interface ForecastRow {
|
|
2533
|
+
export type OpportunityForecast = Pick<IOpportunityDocument, 'amount' | 'currency' | 'probability' | 'status' | 'expectedCloseAt' | 'stageId' | 'statusHistory'>;
|
|
2534
|
+
export interface ForecastRow {
|
|
2511
2535
|
/** Bucket key — ISO month `YYYY-MM` by default. */
|
|
2512
2536
|
bucket: string;
|
|
2513
2537
|
/** Σ amount. */
|
|
@@ -2518,7 +2542,7 @@ interface ForecastRow {
|
|
|
2518
2542
|
count: number;
|
|
2519
2543
|
currency: string;
|
|
2520
2544
|
}
|
|
2521
|
-
interface ForecastOptions {
|
|
2545
|
+
export interface ForecastOptions {
|
|
2522
2546
|
/** Bucket function. Default: ISO month from `expectedCloseAt`. */
|
|
2523
2547
|
bucket?: (o: OpportunityForecast) => string;
|
|
2524
2548
|
/** Filter before bucketing. Default: open + has amount + has expectedCloseAt. */
|
|
@@ -2537,8 +2561,8 @@ interface ForecastOptions {
|
|
|
2537
2561
|
* Currency mismatch within a bucket throws — partition by currency
|
|
2538
2562
|
* upstream when multi-currency.
|
|
2539
2563
|
*/
|
|
2540
|
-
declare function forecast(opportunities: readonly OpportunityForecast[], options?: ForecastOptions): ForecastRow[];
|
|
2541
|
-
interface ConversionRow {
|
|
2564
|
+
export declare function forecast(opportunities: readonly OpportunityForecast[], options?: ForecastOptions): ForecastRow[];
|
|
2565
|
+
export interface ConversionRow {
|
|
2542
2566
|
stageId: string;
|
|
2543
2567
|
currentCount: number;
|
|
2544
2568
|
wonFromHere: number;
|
|
@@ -2549,7 +2573,7 @@ interface ConversionRow {
|
|
|
2549
2573
|
* "Where do deals die?" summary — opportunities partitioned across
|
|
2550
2574
|
* stages with current count + won/lost-from-here.
|
|
2551
2575
|
*/
|
|
2552
|
-
declare function pipelineConversion(opportunities: readonly OpportunityForecast[], stageIds: readonly string[]): ConversionRow[];
|
|
2576
|
+
export declare function pipelineConversion(opportunities: readonly OpportunityForecast[], stageIds: readonly string[]): ConversionRow[];
|
|
2553
2577
|
//#endregion
|
|
2554
2578
|
//#region src/validators/common.d.ts
|
|
2555
2579
|
declare const objectIdLike: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
@@ -2636,12 +2660,12 @@ declare const updateLeadSchema: z.ZodObject<{
|
|
|
2636
2660
|
}, z.core.$strip>;
|
|
2637
2661
|
declare const leadFilterSchema: z.ZodObject<{
|
|
2638
2662
|
status: z.ZodOptional<z.ZodEnum<{
|
|
2639
|
-
new: "new";
|
|
2640
2663
|
contacted: "contacted";
|
|
2641
|
-
qualified: "qualified";
|
|
2642
2664
|
converted: "converted";
|
|
2643
2665
|
disqualified: "disqualified";
|
|
2666
|
+
new: "new";
|
|
2644
2667
|
nurturing: "nurturing";
|
|
2668
|
+
qualified: "qualified";
|
|
2645
2669
|
}>>;
|
|
2646
2670
|
ownerId: z.ZodOptional<z.ZodString>;
|
|
2647
2671
|
email: z.ZodOptional<z.ZodString>;
|
|
@@ -2700,10 +2724,10 @@ declare const closeLossSchema: z.ZodObject<{
|
|
|
2700
2724
|
}, z.core.$strip>;
|
|
2701
2725
|
declare const opportunityFilterSchema: z.ZodObject<{
|
|
2702
2726
|
status: z.ZodOptional<z.ZodEnum<{
|
|
2727
|
+
abandoned: "abandoned";
|
|
2728
|
+
lost: "lost";
|
|
2703
2729
|
open: "open";
|
|
2704
2730
|
won: "won";
|
|
2705
|
-
lost: "lost";
|
|
2706
|
-
abandoned: "abandoned";
|
|
2707
2731
|
}>>;
|
|
2708
2732
|
pipelineId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2709
2733
|
stageId: z.ZodOptional<z.ZodString>;
|
|
@@ -2848,11 +2872,11 @@ declare const completeCampaignSchema: z.ZodObject<{
|
|
|
2848
2872
|
}, z.core.$strip>;
|
|
2849
2873
|
declare const campaignFilterSchema: z.ZodObject<{
|
|
2850
2874
|
status: z.ZodOptional<z.ZodEnum<{
|
|
2851
|
-
draft: "draft";
|
|
2852
2875
|
active: "active";
|
|
2853
|
-
paused: "paused";
|
|
2854
|
-
completed: "completed";
|
|
2855
2876
|
archived: "archived";
|
|
2877
|
+
completed: "completed";
|
|
2878
|
+
draft: "draft";
|
|
2879
|
+
paused: "paused";
|
|
2856
2880
|
}>>;
|
|
2857
2881
|
ownerId: z.ZodOptional<z.ZodString>;
|
|
2858
2882
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -2882,11 +2906,11 @@ declare const unsubscribeSchema: z.ZodObject<{
|
|
|
2882
2906
|
}, z.core.$strip>;
|
|
2883
2907
|
declare const subscriptionFilterSchema: z.ZodObject<{
|
|
2884
2908
|
status: z.ZodOptional<z.ZodEnum<{
|
|
2885
|
-
pending: "pending";
|
|
2886
|
-
confirmed: "confirmed";
|
|
2887
|
-
unsubscribed: "unsubscribed";
|
|
2888
2909
|
bounced: "bounced";
|
|
2889
2910
|
complained: "complained";
|
|
2911
|
+
confirmed: "confirmed";
|
|
2912
|
+
pending: "pending";
|
|
2913
|
+
unsubscribed: "unsubscribed";
|
|
2890
2914
|
}>>;
|
|
2891
2915
|
contactId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2892
2916
|
campaignId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
@@ -2901,8 +2925,8 @@ declare const suppressSchema: z.ZodObject<{
|
|
|
2901
2925
|
reason: z.ZodEnum<{
|
|
2902
2926
|
bounce: "bounce";
|
|
2903
2927
|
complaint: "complaint";
|
|
2904
|
-
unsubscribe: "unsubscribe";
|
|
2905
2928
|
manual: "manual";
|
|
2929
|
+
unsubscribe: "unsubscribe";
|
|
2906
2930
|
}>;
|
|
2907
2931
|
source: z.ZodOptional<z.ZodString>;
|
|
2908
2932
|
subjectKind: z.ZodOptional<z.ZodString>;
|
|
@@ -2917,8 +2941,8 @@ declare const suppressionFilterSchema: z.ZodObject<{
|
|
|
2917
2941
|
reason: z.ZodOptional<z.ZodEnum<{
|
|
2918
2942
|
bounce: "bounce";
|
|
2919
2943
|
complaint: "complaint";
|
|
2920
|
-
unsubscribe: "unsubscribe";
|
|
2921
2944
|
manual: "manual";
|
|
2945
|
+
unsubscribe: "unsubscribe";
|
|
2922
2946
|
}>>;
|
|
2923
2947
|
}, z.core.$strip>;
|
|
2924
2948
|
type SuppressDto = z.infer<typeof suppressSchema>;
|
|
@@ -2928,20 +2952,20 @@ type UnsuppressDto = z.infer<typeof unsuppressSchema>;
|
|
|
2928
2952
|
declare const planActivitySchema: z.ZodObject<{
|
|
2929
2953
|
type: z.ZodEnum<{
|
|
2930
2954
|
call: "call";
|
|
2955
|
+
demo: "demo";
|
|
2931
2956
|
email: "email";
|
|
2932
2957
|
meeting: "meeting";
|
|
2933
|
-
task: "task";
|
|
2934
2958
|
note: "note";
|
|
2959
|
+
other: "other";
|
|
2935
2960
|
sms: "sms";
|
|
2936
2961
|
social: "social";
|
|
2937
|
-
|
|
2938
|
-
other: "other";
|
|
2962
|
+
task: "task";
|
|
2939
2963
|
}>;
|
|
2940
2964
|
subjectKind: z.ZodEnum<{
|
|
2965
|
+
account: "account";
|
|
2966
|
+
contact: "contact";
|
|
2941
2967
|
lead: "lead";
|
|
2942
2968
|
opportunity: "opportunity";
|
|
2943
|
-
contact: "contact";
|
|
2944
|
-
account: "account";
|
|
2945
2969
|
}>;
|
|
2946
2970
|
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
2947
2971
|
title: z.ZodString;
|
|
@@ -2955,20 +2979,20 @@ declare const planActivitySchema: z.ZodObject<{
|
|
|
2955
2979
|
declare const updateActivitySchema: z.ZodObject<{
|
|
2956
2980
|
type: z.ZodOptional<z.ZodEnum<{
|
|
2957
2981
|
call: "call";
|
|
2982
|
+
demo: "demo";
|
|
2958
2983
|
email: "email";
|
|
2959
2984
|
meeting: "meeting";
|
|
2960
|
-
task: "task";
|
|
2961
2985
|
note: "note";
|
|
2986
|
+
other: "other";
|
|
2962
2987
|
sms: "sms";
|
|
2963
2988
|
social: "social";
|
|
2964
|
-
|
|
2965
|
-
other: "other";
|
|
2989
|
+
task: "task";
|
|
2966
2990
|
}>>;
|
|
2967
2991
|
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
2992
|
+
account: "account";
|
|
2993
|
+
contact: "contact";
|
|
2968
2994
|
lead: "lead";
|
|
2969
2995
|
opportunity: "opportunity";
|
|
2970
|
-
contact: "contact";
|
|
2971
|
-
account: "account";
|
|
2972
2996
|
}>>;
|
|
2973
2997
|
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
2974
2998
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -2985,26 +3009,26 @@ declare const cancelActivitySchema: z.ZodObject<{
|
|
|
2985
3009
|
declare const activityFilterSchema: z.ZodObject<{
|
|
2986
3010
|
type: z.ZodOptional<z.ZodEnum<{
|
|
2987
3011
|
call: "call";
|
|
3012
|
+
demo: "demo";
|
|
2988
3013
|
email: "email";
|
|
2989
3014
|
meeting: "meeting";
|
|
2990
|
-
task: "task";
|
|
2991
3015
|
note: "note";
|
|
3016
|
+
other: "other";
|
|
2992
3017
|
sms: "sms";
|
|
2993
3018
|
social: "social";
|
|
2994
|
-
|
|
2995
|
-
other: "other";
|
|
3019
|
+
task: "task";
|
|
2996
3020
|
}>>;
|
|
2997
3021
|
status: z.ZodOptional<z.ZodEnum<{
|
|
3022
|
+
cancelled: "cancelled";
|
|
2998
3023
|
completed: "completed";
|
|
2999
|
-
planned: "planned";
|
|
3000
3024
|
in_progress: "in_progress";
|
|
3001
|
-
|
|
3025
|
+
planned: "planned";
|
|
3002
3026
|
}>>;
|
|
3003
3027
|
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
3028
|
+
account: "account";
|
|
3029
|
+
contact: "contact";
|
|
3004
3030
|
lead: "lead";
|
|
3005
3031
|
opportunity: "opportunity";
|
|
3006
|
-
contact: "contact";
|
|
3007
|
-
account: "account";
|
|
3008
3032
|
}>>;
|
|
3009
3033
|
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
3010
3034
|
ownerId: z.ZodOptional<z.ZodString>;
|
|
@@ -3017,10 +3041,10 @@ type CancelActivityDto = z.infer<typeof cancelActivitySchema>;
|
|
|
3017
3041
|
//#region src/validators/note.schema.d.ts
|
|
3018
3042
|
declare const addNoteSchema: z.ZodObject<{
|
|
3019
3043
|
subjectKind: z.ZodEnum<{
|
|
3044
|
+
account: "account";
|
|
3045
|
+
contact: "contact";
|
|
3020
3046
|
lead: "lead";
|
|
3021
3047
|
opportunity: "opportunity";
|
|
3022
|
-
contact: "contact";
|
|
3023
|
-
account: "account";
|
|
3024
3048
|
}>;
|
|
3025
3049
|
subjectId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
3026
3050
|
body: z.ZodString;
|
|
@@ -3035,10 +3059,10 @@ declare const updateNoteSchema: z.ZodObject<{
|
|
|
3035
3059
|
}, z.core.$strip>;
|
|
3036
3060
|
declare const noteFilterSchema: z.ZodObject<{
|
|
3037
3061
|
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
3062
|
+
account: "account";
|
|
3063
|
+
contact: "contact";
|
|
3038
3064
|
lead: "lead";
|
|
3039
3065
|
opportunity: "opportunity";
|
|
3040
|
-
contact: "contact";
|
|
3041
|
-
account: "account";
|
|
3042
3066
|
}>>;
|
|
3043
3067
|
subjectId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
3044
3068
|
authorId: z.ZodOptional<z.ZodString>;
|
|
@@ -3084,10 +3108,10 @@ declare const recordEmailEventSchema: z.ZodObject<{
|
|
|
3084
3108
|
}, z.core.$strip>;
|
|
3085
3109
|
declare const emailEventFilterSchema: z.ZodObject<{
|
|
3086
3110
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
3087
|
-
open: "open";
|
|
3088
|
-
click: "click";
|
|
3089
3111
|
bounce: "bounce";
|
|
3112
|
+
click: "click";
|
|
3090
3113
|
complaint: "complaint";
|
|
3114
|
+
open: "open";
|
|
3091
3115
|
unsubscribe: "unsubscribe";
|
|
3092
3116
|
}>>;
|
|
3093
3117
|
subjectKind: z.ZodOptional<z.ZodEnum<{
|
|
@@ -3177,10 +3201,10 @@ declare const updateSequenceSchema: z.ZodObject<{
|
|
|
3177
3201
|
}, z.core.$strip>;
|
|
3178
3202
|
declare const sequenceFilterSchema: z.ZodObject<{
|
|
3179
3203
|
status: z.ZodOptional<z.ZodEnum<{
|
|
3180
|
-
draft: "draft";
|
|
3181
3204
|
active: "active";
|
|
3182
|
-
paused: "paused";
|
|
3183
3205
|
archived: "archived";
|
|
3206
|
+
draft: "draft";
|
|
3207
|
+
paused: "paused";
|
|
3184
3208
|
}>>;
|
|
3185
3209
|
ownerId: z.ZodOptional<z.ZodString>;
|
|
3186
3210
|
tags: z.ZodOptional<z.ZodString>;
|
|
@@ -3196,4 +3220,4 @@ declare namespace index_d_exports {
|
|
|
3196
3220
|
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 };
|
|
3197
3221
|
}
|
|
3198
3222
|
//#endregion
|
|
3199
|
-
export {
|
|
3223
|
+
export { type ActivityStatus, type ActivityType, type CampaignStatus, type ConversationChannel, type ConversationParticipantKind, type ConversationStatus, type CrmEventDispatcherOptions, type EmailEventKind, type EnrollmentStatus, type InternalCrmContext, type LeadStatus, type MessageDeliveryStatus, type MessageDirection, type OpportunityStatus, type RunUnitConfig, type SequenceStatus, type StatusChangeEntry, type StatusHistory, type SubjectKind, type SubscriptionStatus, type SuppressionReason, appendStatus, lastTransitionTo, latestEntry, timeInStatus, index_d_exports as validators };
|