@astralibx/call-log-engine 0.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/README.md +157 -0
- package/dist/index.cjs +2500 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +445 -0
- package/dist/index.d.ts +445 -0
- package/dist/index.mjs +2454 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { Request, Router } from 'express';
|
|
2
|
+
import mongoose, { Document, Schema, Model } from 'mongoose';
|
|
3
|
+
import { IPipeline, IPipelineStage, ICallLog, IContactRef, IStageChange, ITimelineEntry, ICallLogSettings, IPriorityConfig, ResolvedOptions, CallLogEngineConfig, DateRange, AgentInfo, AgentCallStats, PipelineReport, PipelineFunnel, DailyReport, DashboardStats, OverallCallReport, ExportFormat, ExportFilter, AuthResult } from '@astralibx/call-log-types';
|
|
4
|
+
export { CallLogEngineConfig, DEFAULT_OPTIONS, ResolvedOptions } from '@astralibx/call-log-types';
|
|
5
|
+
import { LogAdapter, AlxError } from '@astralibx/core';
|
|
6
|
+
|
|
7
|
+
interface IPipelineStageDocument extends IPipelineStage, Document {
|
|
8
|
+
}
|
|
9
|
+
interface IPipelineDocument extends IPipeline, Document {
|
|
10
|
+
}
|
|
11
|
+
declare const PipelineStageSchema: Schema<IPipelineStageDocument, Model<IPipelineStageDocument, any, any, any, Document<unknown, any, IPipelineStageDocument, any, {}> & IPipelineStageDocument & Required<{
|
|
12
|
+
_id: mongoose.Types.ObjectId;
|
|
13
|
+
}> & {
|
|
14
|
+
__v: number;
|
|
15
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IPipelineStageDocument, Document<unknown, {}, mongoose.FlatRecord<IPipelineStageDocument>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<IPipelineStageDocument> & Required<{
|
|
16
|
+
_id: mongoose.Types.ObjectId;
|
|
17
|
+
}> & {
|
|
18
|
+
__v: number;
|
|
19
|
+
}>;
|
|
20
|
+
declare const PipelineSchema: Schema<IPipelineDocument, Model<IPipelineDocument, any, any, any, Document<unknown, any, IPipelineDocument, any, {}> & IPipelineDocument & Required<{
|
|
21
|
+
_id: mongoose.Types.ObjectId;
|
|
22
|
+
}> & {
|
|
23
|
+
__v: number;
|
|
24
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IPipelineDocument, Document<unknown, {}, mongoose.FlatRecord<IPipelineDocument>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<IPipelineDocument> & Required<{
|
|
25
|
+
_id: mongoose.Types.ObjectId;
|
|
26
|
+
}> & {
|
|
27
|
+
__v: number;
|
|
28
|
+
}>;
|
|
29
|
+
declare function createPipelineModel(connection: mongoose.Connection, prefix?: string): Model<IPipelineDocument>;
|
|
30
|
+
|
|
31
|
+
interface ICallLogDocument extends Omit<ICallLog, 'agentId'>, Document {
|
|
32
|
+
agentId: mongoose.Types.ObjectId;
|
|
33
|
+
}
|
|
34
|
+
declare const ContactRefSchema: Schema<IContactRef, Model<IContactRef, any, any, any, Document<unknown, any, IContactRef, any, {}> & IContactRef & {
|
|
35
|
+
_id: mongoose.Types.ObjectId;
|
|
36
|
+
} & {
|
|
37
|
+
__v: number;
|
|
38
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IContactRef, Document<unknown, {}, mongoose.FlatRecord<IContactRef>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<IContactRef> & {
|
|
39
|
+
_id: mongoose.Types.ObjectId;
|
|
40
|
+
} & {
|
|
41
|
+
__v: number;
|
|
42
|
+
}>;
|
|
43
|
+
declare const TimelineEntrySchema: Schema<ITimelineEntry, Model<ITimelineEntry, any, any, any, Document<unknown, any, ITimelineEntry, any, {}> & ITimelineEntry & {
|
|
44
|
+
_id: mongoose.Types.ObjectId;
|
|
45
|
+
} & {
|
|
46
|
+
__v: number;
|
|
47
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, ITimelineEntry, Document<unknown, {}, mongoose.FlatRecord<ITimelineEntry>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<ITimelineEntry> & {
|
|
48
|
+
_id: mongoose.Types.ObjectId;
|
|
49
|
+
} & {
|
|
50
|
+
__v: number;
|
|
51
|
+
}>;
|
|
52
|
+
declare const StageChangeSchema: Schema<IStageChange, Model<IStageChange, any, any, any, Document<unknown, any, IStageChange, any, {}> & IStageChange & {
|
|
53
|
+
_id: mongoose.Types.ObjectId;
|
|
54
|
+
} & {
|
|
55
|
+
__v: number;
|
|
56
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IStageChange, Document<unknown, {}, mongoose.FlatRecord<IStageChange>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<IStageChange> & {
|
|
57
|
+
_id: mongoose.Types.ObjectId;
|
|
58
|
+
} & {
|
|
59
|
+
__v: number;
|
|
60
|
+
}>;
|
|
61
|
+
declare const CallLogSchema: Schema<ICallLogDocument, Model<ICallLogDocument, any, any, any, Document<unknown, any, ICallLogDocument, any, {}> & ICallLogDocument & Required<{
|
|
62
|
+
_id: mongoose.Types.ObjectId;
|
|
63
|
+
}> & {
|
|
64
|
+
__v: number;
|
|
65
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, ICallLogDocument, Document<unknown, {}, mongoose.FlatRecord<ICallLogDocument>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<ICallLogDocument> & Required<{
|
|
66
|
+
_id: mongoose.Types.ObjectId;
|
|
67
|
+
}> & {
|
|
68
|
+
__v: number;
|
|
69
|
+
}>;
|
|
70
|
+
declare function createCallLogModel(connection: mongoose.Connection, prefix?: string): Model<ICallLogDocument>;
|
|
71
|
+
|
|
72
|
+
interface ICallLogSettingsDocument extends ICallLogSettings, Document {
|
|
73
|
+
}
|
|
74
|
+
declare const CallLogSettingsSchema: Schema<ICallLogSettingsDocument, Model<ICallLogSettingsDocument, any, any, any, Document<unknown, any, ICallLogSettingsDocument, any, {}> & ICallLogSettingsDocument & Required<{
|
|
75
|
+
_id: mongoose.Types.ObjectId;
|
|
76
|
+
}> & {
|
|
77
|
+
__v: number;
|
|
78
|
+
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, ICallLogSettingsDocument, Document<unknown, {}, mongoose.FlatRecord<ICallLogSettingsDocument>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<ICallLogSettingsDocument> & Required<{
|
|
79
|
+
_id: mongoose.Types.ObjectId;
|
|
80
|
+
}> & {
|
|
81
|
+
__v: number;
|
|
82
|
+
}>;
|
|
83
|
+
declare function createCallLogSettingsModel(connection: mongoose.Connection, prefix?: string): Model<ICallLogSettingsDocument>;
|
|
84
|
+
|
|
85
|
+
declare class SettingsService {
|
|
86
|
+
private CallLogSettings;
|
|
87
|
+
private logger;
|
|
88
|
+
private tenantId?;
|
|
89
|
+
constructor(CallLogSettings: Model<ICallLogSettingsDocument>, logger: LogAdapter, tenantId?: string | undefined);
|
|
90
|
+
private get settingsFilter();
|
|
91
|
+
private buildDefaults;
|
|
92
|
+
get(): Promise<ICallLogSettingsDocument>;
|
|
93
|
+
update(data: Partial<{
|
|
94
|
+
availableTags: string[];
|
|
95
|
+
availableCategories: string[];
|
|
96
|
+
priorityLevels: IPriorityConfig[];
|
|
97
|
+
defaultFollowUpDays: number;
|
|
98
|
+
followUpReminderEnabled: boolean;
|
|
99
|
+
defaultPipelineId: string;
|
|
100
|
+
timelinePageSize: number;
|
|
101
|
+
maxConcurrentCalls: number;
|
|
102
|
+
metadata: Record<string, unknown>;
|
|
103
|
+
}>): Promise<ICallLogSettingsDocument>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface CreatePipelineInput {
|
|
107
|
+
name: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
stages: Omit<IPipelineStage, 'stageId'>[];
|
|
110
|
+
isDefault?: boolean;
|
|
111
|
+
createdBy: string;
|
|
112
|
+
tenantId?: string;
|
|
113
|
+
metadata?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
interface UpdatePipelineInput {
|
|
116
|
+
name?: string;
|
|
117
|
+
description?: string;
|
|
118
|
+
isActive?: boolean;
|
|
119
|
+
isDefault?: boolean;
|
|
120
|
+
metadata?: Record<string, unknown>;
|
|
121
|
+
}
|
|
122
|
+
declare class PipelineService {
|
|
123
|
+
private Pipeline;
|
|
124
|
+
private CallLog;
|
|
125
|
+
private logger;
|
|
126
|
+
private tenantId?;
|
|
127
|
+
constructor(Pipeline: Model<IPipelineDocument>, CallLog: Model<ICallLogDocument>, logger: LogAdapter, tenantId?: string | undefined);
|
|
128
|
+
private get tenantFilter();
|
|
129
|
+
create(data: CreatePipelineInput): Promise<IPipelineDocument>;
|
|
130
|
+
update(pipelineId: string, data: UpdatePipelineInput): Promise<IPipelineDocument>;
|
|
131
|
+
delete(pipelineId: string): Promise<void>;
|
|
132
|
+
list(filter?: {
|
|
133
|
+
isActive?: boolean;
|
|
134
|
+
}): Promise<IPipelineDocument[]>;
|
|
135
|
+
get(pipelineId: string): Promise<IPipelineDocument>;
|
|
136
|
+
addStage(pipelineId: string, stage: Omit<IPipelineStage, 'stageId'>): Promise<IPipelineDocument>;
|
|
137
|
+
removeStage(pipelineId: string, stageId: string): Promise<IPipelineDocument>;
|
|
138
|
+
updateStage(pipelineId: string, stageId: string, data: Partial<IPipelineStage>): Promise<IPipelineDocument>;
|
|
139
|
+
reorderStages(pipelineId: string, stageIds: string[]): Promise<IPipelineDocument>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare class TimelineService {
|
|
143
|
+
private CallLog;
|
|
144
|
+
private logger;
|
|
145
|
+
private options;
|
|
146
|
+
constructor(CallLog: Model<ICallLogDocument>, logger: LogAdapter, options: ResolvedOptions);
|
|
147
|
+
addNote(callLogId: string, content: string, authorId: string, authorName: string): Promise<ITimelineEntry>;
|
|
148
|
+
addSystemEntry(callLogId: string, content: string): Promise<ITimelineEntry>;
|
|
149
|
+
getTimeline(callLogId: string, pagination: {
|
|
150
|
+
page: number;
|
|
151
|
+
limit: number;
|
|
152
|
+
}): Promise<{
|
|
153
|
+
entries: ITimelineEntry[];
|
|
154
|
+
total: number;
|
|
155
|
+
}>;
|
|
156
|
+
getContactTimeline(externalId: string, pagination: {
|
|
157
|
+
page: number;
|
|
158
|
+
limit: number;
|
|
159
|
+
}): Promise<{
|
|
160
|
+
entries: (ITimelineEntry & {
|
|
161
|
+
callLogId: string;
|
|
162
|
+
})[];
|
|
163
|
+
total: number;
|
|
164
|
+
}>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface CreateCallLogInput {
|
|
168
|
+
pipelineId: string;
|
|
169
|
+
contactRef: ICallLog['contactRef'];
|
|
170
|
+
direction: ICallLog['direction'];
|
|
171
|
+
callDate?: Date | string;
|
|
172
|
+
agentId: string;
|
|
173
|
+
priority?: ICallLog['priority'];
|
|
174
|
+
tags?: string[];
|
|
175
|
+
category?: string;
|
|
176
|
+
nextFollowUpDate?: Date;
|
|
177
|
+
durationMinutes?: number;
|
|
178
|
+
tenantId?: string;
|
|
179
|
+
metadata?: Record<string, unknown>;
|
|
180
|
+
}
|
|
181
|
+
interface UpdateCallLogInput {
|
|
182
|
+
priority?: ICallLog['priority'];
|
|
183
|
+
tags?: string[];
|
|
184
|
+
category?: string;
|
|
185
|
+
nextFollowUpDate?: Date;
|
|
186
|
+
durationMinutes?: number;
|
|
187
|
+
}
|
|
188
|
+
interface ListCallLogsFilter {
|
|
189
|
+
pipelineId?: string;
|
|
190
|
+
currentStageId?: string;
|
|
191
|
+
agentId?: string;
|
|
192
|
+
tags?: string[];
|
|
193
|
+
category?: string;
|
|
194
|
+
isClosed?: boolean;
|
|
195
|
+
contactExternalId?: string;
|
|
196
|
+
contactName?: string;
|
|
197
|
+
contactPhone?: string;
|
|
198
|
+
contactEmail?: string;
|
|
199
|
+
priority?: ICallLog['priority'];
|
|
200
|
+
direction?: ICallLog['direction'];
|
|
201
|
+
dateRange?: DateRange;
|
|
202
|
+
page?: number;
|
|
203
|
+
limit?: number;
|
|
204
|
+
sort?: Record<string, 1 | -1>;
|
|
205
|
+
}
|
|
206
|
+
interface ListCallLogsResult {
|
|
207
|
+
callLogs: ICallLogDocument[];
|
|
208
|
+
total: number;
|
|
209
|
+
page: number;
|
|
210
|
+
limit: number;
|
|
211
|
+
}
|
|
212
|
+
interface BulkChangeStageResult {
|
|
213
|
+
succeeded: string[];
|
|
214
|
+
failed: {
|
|
215
|
+
callLogId: string;
|
|
216
|
+
error: string;
|
|
217
|
+
}[];
|
|
218
|
+
total: number;
|
|
219
|
+
}
|
|
220
|
+
type ResolvedHooks = NonNullable<CallLogEngineConfig['hooks']>;
|
|
221
|
+
declare class CallLogService {
|
|
222
|
+
private CallLog;
|
|
223
|
+
private Pipeline;
|
|
224
|
+
private timeline;
|
|
225
|
+
private logger;
|
|
226
|
+
private hooks;
|
|
227
|
+
private options;
|
|
228
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks, options: ResolvedOptions);
|
|
229
|
+
create(data: CreateCallLogInput): Promise<ICallLogDocument>;
|
|
230
|
+
update(callLogId: string, data: UpdateCallLogInput): Promise<ICallLogDocument>;
|
|
231
|
+
changeStage(callLogId: string, newStageId: string, agentId: string): Promise<ICallLogDocument>;
|
|
232
|
+
assign(callLogId: string, agentId: string, assignedBy: string): Promise<ICallLogDocument>;
|
|
233
|
+
list(filter?: ListCallLogsFilter): Promise<ListCallLogsResult>;
|
|
234
|
+
get(callLogId: string): Promise<ICallLogDocument>;
|
|
235
|
+
getByContact(externalId: string): Promise<ICallLogDocument[]>;
|
|
236
|
+
getFollowUpsDue(agentId?: string, dateRange?: DateRange): Promise<ICallLogDocument[]>;
|
|
237
|
+
bulkChangeStage(callLogIds: string[], newStageId: string, agentId: string): Promise<BulkChangeStageResult>;
|
|
238
|
+
close(callLogId: string, agentId: string): Promise<ICallLogDocument>;
|
|
239
|
+
reopen(callLogId: string, agentId: string): Promise<ICallLogDocument>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface WeeklySummary {
|
|
243
|
+
week: string;
|
|
244
|
+
year: number;
|
|
245
|
+
totalCalls: number;
|
|
246
|
+
closedCalls: number;
|
|
247
|
+
}
|
|
248
|
+
interface TeamStats {
|
|
249
|
+
teamId: string | null;
|
|
250
|
+
agentStats: AgentCallStats[];
|
|
251
|
+
totalCalls: number;
|
|
252
|
+
}
|
|
253
|
+
declare class AnalyticsService {
|
|
254
|
+
private CallLog;
|
|
255
|
+
private Pipeline;
|
|
256
|
+
private logger;
|
|
257
|
+
private resolveAgent?;
|
|
258
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, logger: LogAdapter, resolveAgent?: ((agentId: string) => Promise<AgentInfo | null>) | undefined);
|
|
259
|
+
private getAgentName;
|
|
260
|
+
private buildDateMatch;
|
|
261
|
+
getAgentStats(agentId: string, dateRange: DateRange): Promise<AgentCallStats>;
|
|
262
|
+
getAgentLeaderboard(dateRange: DateRange): Promise<AgentCallStats[]>;
|
|
263
|
+
getPipelineStats(pipelineId: string, dateRange: DateRange): Promise<PipelineReport>;
|
|
264
|
+
getPipelineFunnel(pipelineId: string, dateRange: DateRange): Promise<PipelineFunnel>;
|
|
265
|
+
getTeamStats(teamId?: string, dateRange?: DateRange): Promise<TeamStats>;
|
|
266
|
+
getDailyReport(dateRange: DateRange): Promise<DailyReport[]>;
|
|
267
|
+
getDashboardStats(): Promise<DashboardStats>;
|
|
268
|
+
getWeeklyTrends(weeks: number): Promise<WeeklySummary[]>;
|
|
269
|
+
getOverallReport(dateRange: DateRange): Promise<OverallCallReport>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class ExportService {
|
|
273
|
+
private CallLog;
|
|
274
|
+
private analytics;
|
|
275
|
+
private logger;
|
|
276
|
+
constructor(CallLog: Model<ICallLogDocument>, analytics: AnalyticsService, logger: LogAdapter);
|
|
277
|
+
exportCallLog(callLogId: string, format: ExportFormat): Promise<string>;
|
|
278
|
+
exportCallLogs(filter: ExportFilter, format: ExportFormat): Promise<string>;
|
|
279
|
+
exportPipelineReport(pipelineId: string, dateRange: DateRange, format: ExportFormat): Promise<string>;
|
|
280
|
+
private toCSV;
|
|
281
|
+
private escapeCSV;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare const ERROR_CODE: {
|
|
285
|
+
readonly PipelineNotFound: "CALL_PIPELINE_NOT_FOUND";
|
|
286
|
+
readonly InvalidPipeline: "CALL_INVALID_PIPELINE";
|
|
287
|
+
readonly StageNotFound: "CALL_STAGE_NOT_FOUND";
|
|
288
|
+
readonly StageInUse: "CALL_STAGE_IN_USE";
|
|
289
|
+
readonly CallLogNotFound: "CALL_LOG_NOT_FOUND";
|
|
290
|
+
readonly CallLogClosed: "CALL_LOG_CLOSED";
|
|
291
|
+
readonly ContactNotFound: "CALL_CONTACT_NOT_FOUND";
|
|
292
|
+
readonly AgentCapacityFull: "CALL_AGENT_CAPACITY_FULL";
|
|
293
|
+
readonly InvalidConfig: "CALL_INVALID_CONFIG";
|
|
294
|
+
readonly AuthFailed: "CALL_AUTH_FAILED";
|
|
295
|
+
};
|
|
296
|
+
type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE];
|
|
297
|
+
declare const ERROR_MESSAGE: {
|
|
298
|
+
readonly PipelineNotFound: "Pipeline not found";
|
|
299
|
+
readonly PipelineNoDefaultStage: "Pipeline must have exactly one default stage";
|
|
300
|
+
readonly PipelineNoTerminalStage: "Pipeline must have at least one terminal stage";
|
|
301
|
+
readonly PipelineDuplicateStageNames: "Stage names must be unique within a pipeline";
|
|
302
|
+
readonly StageNotFound: "Stage not found in pipeline";
|
|
303
|
+
readonly StageInUse: "Cannot remove stage that has active calls";
|
|
304
|
+
readonly CallLogNotFound: "Call log not found";
|
|
305
|
+
readonly CallLogClosed: "Cannot modify a closed call log";
|
|
306
|
+
readonly ContactNotFound: "Contact not found";
|
|
307
|
+
readonly AgentCapacityFull: "Agent has reached maximum concurrent calls";
|
|
308
|
+
readonly AuthFailed: "Authentication failed";
|
|
309
|
+
};
|
|
310
|
+
declare const PIPELINE_DEFAULTS: {
|
|
311
|
+
readonly MaxStages: 20;
|
|
312
|
+
};
|
|
313
|
+
declare const CALL_LOG_DEFAULTS: {
|
|
314
|
+
readonly MaxTimelineEntries: 200;
|
|
315
|
+
readonly DefaultFollowUpDays: 3;
|
|
316
|
+
readonly TimelinePageSize: 20;
|
|
317
|
+
};
|
|
318
|
+
declare const AGENT_CALL_DEFAULTS: {
|
|
319
|
+
readonly MaxConcurrentCalls: 10;
|
|
320
|
+
};
|
|
321
|
+
declare const SYSTEM_TIMELINE: {
|
|
322
|
+
readonly CallCreated: "Call log created";
|
|
323
|
+
readonly CallClosed: "Call closed";
|
|
324
|
+
readonly CallReopened: "Call reopened";
|
|
325
|
+
readonly FollowUpCompleted: "Follow-up completed";
|
|
326
|
+
};
|
|
327
|
+
declare const SYSTEM_TIMELINE_FN: {
|
|
328
|
+
readonly stageChanged: (from: string, to: string) => string;
|
|
329
|
+
readonly callAssigned: (agentName: string) => string;
|
|
330
|
+
readonly callReassigned: (from: string, to: string) => string;
|
|
331
|
+
readonly followUpSet: (date: string) => string;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
declare class AlxCallLogError extends AlxError {
|
|
335
|
+
readonly context?: Record<string, unknown> | undefined;
|
|
336
|
+
constructor(message: string, code: string, context?: Record<string, unknown> | undefined);
|
|
337
|
+
}
|
|
338
|
+
declare class PipelineNotFoundError extends AlxCallLogError {
|
|
339
|
+
readonly pipelineId: string;
|
|
340
|
+
constructor(pipelineId: string);
|
|
341
|
+
}
|
|
342
|
+
declare class InvalidPipelineError extends AlxCallLogError {
|
|
343
|
+
readonly reason: string;
|
|
344
|
+
readonly pipelineId?: string | undefined;
|
|
345
|
+
constructor(reason: string, pipelineId?: string | undefined);
|
|
346
|
+
}
|
|
347
|
+
declare class StageNotFoundError extends AlxCallLogError {
|
|
348
|
+
readonly pipelineId: string;
|
|
349
|
+
readonly stageId: string;
|
|
350
|
+
constructor(pipelineId: string, stageId: string);
|
|
351
|
+
}
|
|
352
|
+
declare class StageInUseError extends AlxCallLogError {
|
|
353
|
+
readonly pipelineId: string;
|
|
354
|
+
readonly stageId: string;
|
|
355
|
+
readonly activeCallCount: number;
|
|
356
|
+
constructor(pipelineId: string, stageId: string, activeCallCount: number);
|
|
357
|
+
}
|
|
358
|
+
declare class CallLogNotFoundError extends AlxCallLogError {
|
|
359
|
+
readonly callLogId: string;
|
|
360
|
+
constructor(callLogId: string);
|
|
361
|
+
}
|
|
362
|
+
declare class CallLogClosedError extends AlxCallLogError {
|
|
363
|
+
readonly callLogId: string;
|
|
364
|
+
readonly attemptedAction: string;
|
|
365
|
+
constructor(callLogId: string, attemptedAction: string);
|
|
366
|
+
}
|
|
367
|
+
declare class ContactNotFoundError extends AlxCallLogError {
|
|
368
|
+
readonly contactQuery: Record<string, unknown>;
|
|
369
|
+
constructor(contactQuery: Record<string, unknown>);
|
|
370
|
+
}
|
|
371
|
+
declare class AgentCapacityError extends AlxCallLogError {
|
|
372
|
+
readonly agentId: string;
|
|
373
|
+
readonly currentCalls: number;
|
|
374
|
+
readonly maxCalls: number;
|
|
375
|
+
constructor(agentId: string, currentCalls: number, maxCalls: number);
|
|
376
|
+
}
|
|
377
|
+
declare class InvalidConfigError extends AlxCallLogError {
|
|
378
|
+
readonly field: string;
|
|
379
|
+
readonly reason: string;
|
|
380
|
+
constructor(field: string, reason: string);
|
|
381
|
+
}
|
|
382
|
+
declare class AuthFailedError extends AlxCallLogError {
|
|
383
|
+
readonly reason?: string | undefined;
|
|
384
|
+
constructor(reason?: string | undefined);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Validates a pipeline's stages array against all business rules.
|
|
389
|
+
*
|
|
390
|
+
* @param stages - The array of pipeline stages to validate.
|
|
391
|
+
* @param pipelineId - Optional pipeline identifier used in error messages.
|
|
392
|
+
* @throws InvalidPipelineError when any rule is violated.
|
|
393
|
+
*/
|
|
394
|
+
declare function validatePipelineStages(stages: IPipelineStage[], pipelineId?: string): void;
|
|
395
|
+
|
|
396
|
+
interface FollowUpWorkerDeps {
|
|
397
|
+
CallLog: Model<ICallLogDocument>;
|
|
398
|
+
hooks: {
|
|
399
|
+
onFollowUpDue?: (callLog: ICallLog) => void | Promise<void>;
|
|
400
|
+
};
|
|
401
|
+
logger: LogAdapter;
|
|
402
|
+
options: ResolvedOptions;
|
|
403
|
+
}
|
|
404
|
+
declare class FollowUpWorker {
|
|
405
|
+
private deps;
|
|
406
|
+
private intervalId;
|
|
407
|
+
private running;
|
|
408
|
+
constructor(deps: FollowUpWorkerDeps);
|
|
409
|
+
start(): void;
|
|
410
|
+
stop(): void;
|
|
411
|
+
private tick;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
interface RouteServices {
|
|
415
|
+
pipelines: PipelineService;
|
|
416
|
+
callLogs: CallLogService;
|
|
417
|
+
timeline: TimelineService;
|
|
418
|
+
analytics: AnalyticsService;
|
|
419
|
+
settings: SettingsService;
|
|
420
|
+
export: ExportService;
|
|
421
|
+
}
|
|
422
|
+
interface RouteOptions {
|
|
423
|
+
authenticateRequest?: (req: Request) => Promise<AuthResult | null>;
|
|
424
|
+
logger: LogAdapter;
|
|
425
|
+
}
|
|
426
|
+
declare function createRoutes(services: RouteServices, options: RouteOptions): Router;
|
|
427
|
+
|
|
428
|
+
interface CallLogEngine {
|
|
429
|
+
pipelines: PipelineService;
|
|
430
|
+
callLogs: CallLogService;
|
|
431
|
+
timeline: TimelineService;
|
|
432
|
+
analytics: AnalyticsService;
|
|
433
|
+
settings: SettingsService;
|
|
434
|
+
export: ExportService;
|
|
435
|
+
routes: Router;
|
|
436
|
+
models: {
|
|
437
|
+
Pipeline: Model<IPipelineDocument>;
|
|
438
|
+
CallLog: Model<ICallLogDocument>;
|
|
439
|
+
CallLogSettings: Model<ICallLogSettingsDocument>;
|
|
440
|
+
};
|
|
441
|
+
destroy: () => Promise<void>;
|
|
442
|
+
}
|
|
443
|
+
declare function createCallLogEngine(config: CallLogEngineConfig): CallLogEngine;
|
|
444
|
+
|
|
445
|
+
export { AGENT_CALL_DEFAULTS, AgentCapacityError, AlxCallLogError, AnalyticsService, AuthFailedError, CALL_LOG_DEFAULTS, CallLogClosedError, type CallLogEngine, CallLogNotFoundError, CallLogSchema, CallLogService, CallLogSettingsSchema, ContactNotFoundError, ContactRefSchema, ERROR_CODE, ERROR_MESSAGE, type ErrorCode, ExportService, FollowUpWorker, type ICallLogDocument, type ICallLogSettingsDocument, type IPipelineDocument, type IPipelineStageDocument, InvalidConfigError, InvalidPipelineError, PIPELINE_DEFAULTS, PipelineNotFoundError, PipelineSchema, PipelineService, PipelineStageSchema, SYSTEM_TIMELINE, SYSTEM_TIMELINE_FN, SettingsService, StageChangeSchema, StageInUseError, StageNotFoundError, TimelineEntrySchema, TimelineService, createCallLogEngine, createCallLogModel, createCallLogSettingsModel, createPipelineModel, createRoutes, validatePipelineStages };
|