@astralibx/call-log-engine 0.2.0 → 0.3.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 +29 -4
- package/dist/index.cjs +517 -227
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +57 -13
- package/dist/index.d.ts +57 -13
- package/dist/index.mjs +515 -227
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Router } from 'express';
|
|
2
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,
|
|
3
|
+
import { IPipeline, IPipelineStage, ICallLog, IContactRef, IStageChange, ITimelineEntry, ICallLogSettings, IPriorityConfig, ResolvedOptions, CallLogEngineConfig, DateRange, AgentInfo, AgentCallStats, DailyReport, DashboardStats, OverallCallReport, PipelineReport, PipelineFunnel, ChannelDistribution, OutcomeDistribution, FollowUpStats, ExportFormat, ExportFilter, AuthResult } from '@astralibx/call-log-types';
|
|
4
4
|
export { CallLogEngineConfig, DEFAULT_OPTIONS, ResolvedOptions } from '@astralibx/call-log-types';
|
|
5
5
|
import { LogAdapter, AlxError } from '@astralibx/core';
|
|
6
6
|
|
|
@@ -168,6 +168,8 @@ interface CreateCallLogInput {
|
|
|
168
168
|
pipelineId: string;
|
|
169
169
|
contactRef: ICallLog['contactRef'];
|
|
170
170
|
direction: ICallLog['direction'];
|
|
171
|
+
channel: string;
|
|
172
|
+
outcome: string;
|
|
171
173
|
callDate?: Date | string;
|
|
172
174
|
agentId: string;
|
|
173
175
|
priority?: ICallLog['priority'];
|
|
@@ -175,6 +177,7 @@ interface CreateCallLogInput {
|
|
|
175
177
|
category?: string;
|
|
176
178
|
nextFollowUpDate?: Date;
|
|
177
179
|
durationMinutes?: number;
|
|
180
|
+
isFollowUp?: boolean;
|
|
178
181
|
tenantId?: string;
|
|
179
182
|
metadata?: Record<string, unknown>;
|
|
180
183
|
}
|
|
@@ -184,6 +187,9 @@ interface UpdateCallLogInput {
|
|
|
184
187
|
category?: string;
|
|
185
188
|
nextFollowUpDate?: Date;
|
|
186
189
|
durationMinutes?: number;
|
|
190
|
+
channel?: string;
|
|
191
|
+
outcome?: string;
|
|
192
|
+
isFollowUp?: boolean;
|
|
187
193
|
}
|
|
188
194
|
interface ListCallLogsFilter {
|
|
189
195
|
pipelineId?: string;
|
|
@@ -192,12 +198,16 @@ interface ListCallLogsFilter {
|
|
|
192
198
|
tags?: string[];
|
|
193
199
|
category?: string;
|
|
194
200
|
isClosed?: boolean;
|
|
201
|
+
includeDeleted?: boolean;
|
|
195
202
|
contactExternalId?: string;
|
|
196
203
|
contactName?: string;
|
|
197
204
|
contactPhone?: string;
|
|
198
205
|
contactEmail?: string;
|
|
199
206
|
priority?: ICallLog['priority'];
|
|
200
207
|
direction?: ICallLog['direction'];
|
|
208
|
+
channel?: string;
|
|
209
|
+
outcome?: string;
|
|
210
|
+
isFollowUp?: boolean;
|
|
201
211
|
dateRange?: DateRange;
|
|
202
212
|
page?: number;
|
|
203
213
|
limit?: number;
|
|
@@ -217,7 +227,7 @@ interface BulkChangeStageResult {
|
|
|
217
227
|
}[];
|
|
218
228
|
total: number;
|
|
219
229
|
}
|
|
220
|
-
type ResolvedHooks = NonNullable<CallLogEngineConfig['hooks']>;
|
|
230
|
+
type ResolvedHooks$1 = NonNullable<CallLogEngineConfig['hooks']>;
|
|
221
231
|
declare class CallLogService {
|
|
222
232
|
private CallLog;
|
|
223
233
|
private Pipeline;
|
|
@@ -225,18 +235,30 @@ declare class CallLogService {
|
|
|
225
235
|
private logger;
|
|
226
236
|
private hooks;
|
|
227
237
|
private options;
|
|
228
|
-
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks, options: ResolvedOptions);
|
|
238
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks$1, options: ResolvedOptions);
|
|
229
239
|
create(data: CreateCallLogInput): Promise<ICallLogDocument>;
|
|
230
240
|
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
241
|
list(filter?: ListCallLogsFilter): Promise<ListCallLogsResult>;
|
|
234
242
|
get(callLogId: string): Promise<ICallLogDocument>;
|
|
235
243
|
getByContact(externalId: string): Promise<ICallLogDocument[]>;
|
|
236
|
-
|
|
237
|
-
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
type ResolvedHooks = NonNullable<CallLogEngineConfig['hooks']>;
|
|
247
|
+
declare class CallLogLifecycleService {
|
|
248
|
+
private CallLog;
|
|
249
|
+
private Pipeline;
|
|
250
|
+
private timeline;
|
|
251
|
+
private logger;
|
|
252
|
+
private hooks;
|
|
253
|
+
private options;
|
|
254
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks, options: ResolvedOptions);
|
|
255
|
+
changeStage(callLogId: string, newStageId: string, agentId: string): Promise<ICallLogDocument>;
|
|
256
|
+
assign(callLogId: string, agentId: string, assignedBy: string): Promise<ICallLogDocument>;
|
|
238
257
|
close(callLogId: string, agentId: string): Promise<ICallLogDocument>;
|
|
239
258
|
reopen(callLogId: string, agentId: string): Promise<ICallLogDocument>;
|
|
259
|
+
bulkChangeStage(callLogIds: string[], newStageId: string, agentId: string): Promise<BulkChangeStageResult>;
|
|
260
|
+
getFollowUpsDue(agentId?: string, dateRange?: DateRange): Promise<ICallLogDocument[]>;
|
|
261
|
+
softDelete(callLogId: string, agentId?: string, agentName?: string): Promise<ICallLogDocument>;
|
|
240
262
|
}
|
|
241
263
|
|
|
242
264
|
interface WeeklySummary {
|
|
@@ -260,20 +282,33 @@ declare class AnalyticsService {
|
|
|
260
282
|
private buildDateMatch;
|
|
261
283
|
getAgentStats(agentId: string, dateRange: DateRange): Promise<AgentCallStats>;
|
|
262
284
|
getAgentLeaderboard(dateRange: DateRange): Promise<AgentCallStats[]>;
|
|
263
|
-
getPipelineStats(pipelineId: string, dateRange: DateRange): Promise<PipelineReport>;
|
|
264
|
-
getPipelineFunnel(pipelineId: string, dateRange: DateRange): Promise<PipelineFunnel>;
|
|
265
285
|
getTeamStats(teamId?: string, dateRange?: DateRange): Promise<TeamStats>;
|
|
266
|
-
getDailyReport(dateRange: DateRange): Promise<DailyReport[]>;
|
|
286
|
+
getDailyReport(dateRange: DateRange, agentId?: string): Promise<DailyReport[]>;
|
|
267
287
|
getDashboardStats(): Promise<DashboardStats>;
|
|
268
288
|
getWeeklyTrends(weeks: number): Promise<WeeklySummary[]>;
|
|
269
289
|
getOverallReport(dateRange: DateRange): Promise<OverallCallReport>;
|
|
270
290
|
}
|
|
271
291
|
|
|
292
|
+
declare class PipelineAnalyticsService {
|
|
293
|
+
private CallLog;
|
|
294
|
+
private Pipeline;
|
|
295
|
+
private logger;
|
|
296
|
+
private resolveAgent?;
|
|
297
|
+
private tenantId?;
|
|
298
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, logger: LogAdapter, resolveAgent?: ((agentId: string) => Promise<AgentInfo | null>) | undefined, tenantId?: string | undefined);
|
|
299
|
+
private buildDateMatch;
|
|
300
|
+
getPipelineStats(pipelineId: string, dateRange: DateRange): Promise<PipelineReport>;
|
|
301
|
+
getPipelineFunnel(pipelineId: string, dateRange: DateRange): Promise<PipelineFunnel>;
|
|
302
|
+
getChannelDistribution(dateRange: DateRange): Promise<ChannelDistribution[]>;
|
|
303
|
+
getOutcomeDistribution(dateRange: DateRange): Promise<OutcomeDistribution[]>;
|
|
304
|
+
getFollowUpStats(dateRange: DateRange): Promise<FollowUpStats>;
|
|
305
|
+
}
|
|
306
|
+
|
|
272
307
|
declare class ExportService {
|
|
273
308
|
private CallLog;
|
|
274
|
-
private
|
|
309
|
+
private pipelineAnalytics;
|
|
275
310
|
private logger;
|
|
276
|
-
constructor(CallLog: Model<ICallLogDocument>,
|
|
311
|
+
constructor(CallLog: Model<ICallLogDocument>, pipelineAnalytics: PipelineAnalyticsService, logger: LogAdapter);
|
|
277
312
|
exportCallLog(callLogId: string, format: ExportFormat): Promise<string>;
|
|
278
313
|
exportCallLogs(filter: ExportFilter, format: ExportFormat): Promise<string>;
|
|
279
314
|
exportPipelineReport(pipelineId: string, dateRange: DateRange, format: ExportFormat): Promise<string>;
|
|
@@ -288,6 +323,7 @@ declare const ERROR_CODE: {
|
|
|
288
323
|
readonly StageInUse: "CALL_STAGE_IN_USE";
|
|
289
324
|
readonly CallLogNotFound: "CALL_LOG_NOT_FOUND";
|
|
290
325
|
readonly CallLogClosed: "CALL_LOG_CLOSED";
|
|
326
|
+
readonly CallLogDeleted: "CALL_LOG_DELETED";
|
|
291
327
|
readonly ContactNotFound: "CALL_CONTACT_NOT_FOUND";
|
|
292
328
|
readonly AgentCapacityFull: "CALL_AGENT_CAPACITY_FULL";
|
|
293
329
|
readonly InvalidConfig: "CALL_INVALID_CONFIG";
|
|
@@ -303,6 +339,7 @@ declare const ERROR_MESSAGE: {
|
|
|
303
339
|
readonly StageInUse: "Cannot remove stage that has active calls";
|
|
304
340
|
readonly CallLogNotFound: "Call log not found";
|
|
305
341
|
readonly CallLogClosed: "Cannot modify a closed call log";
|
|
342
|
+
readonly CallLogDeleted: "Call log has been deleted";
|
|
306
343
|
readonly ContactNotFound: "Contact not found";
|
|
307
344
|
readonly AgentCapacityFull: "Agent has reached maximum concurrent calls";
|
|
308
345
|
readonly AuthFailed: "Authentication failed";
|
|
@@ -329,6 +366,8 @@ declare const SYSTEM_TIMELINE_FN: {
|
|
|
329
366
|
readonly callAssigned: (agentName: string) => string;
|
|
330
367
|
readonly callReassigned: (from: string, to: string) => string;
|
|
331
368
|
readonly followUpSet: (date: string) => string;
|
|
369
|
+
readonly callDeleted: (agentName: string) => string;
|
|
370
|
+
readonly followUpCallCreated: () => string;
|
|
332
371
|
};
|
|
333
372
|
|
|
334
373
|
declare class AlxCallLogError extends AlxError {
|
|
@@ -414,22 +453,27 @@ declare class FollowUpWorker {
|
|
|
414
453
|
interface RouteServices {
|
|
415
454
|
pipelines: PipelineService;
|
|
416
455
|
callLogs: CallLogService;
|
|
456
|
+
lifecycle: CallLogLifecycleService;
|
|
417
457
|
timeline: TimelineService;
|
|
418
458
|
analytics: AnalyticsService;
|
|
459
|
+
pipelineAnalytics: PipelineAnalyticsService;
|
|
419
460
|
settings: SettingsService;
|
|
420
461
|
export: ExportService;
|
|
421
462
|
}
|
|
422
463
|
interface RouteOptions {
|
|
423
464
|
authenticateRequest?: (req: Request) => Promise<AuthResult | null>;
|
|
424
465
|
logger: LogAdapter;
|
|
466
|
+
enableAgentScoping?: boolean;
|
|
425
467
|
}
|
|
426
468
|
declare function createRoutes(services: RouteServices, options: RouteOptions): Router;
|
|
427
469
|
|
|
428
470
|
interface CallLogEngine {
|
|
429
471
|
pipelines: PipelineService;
|
|
430
472
|
callLogs: CallLogService;
|
|
473
|
+
lifecycle: CallLogLifecycleService;
|
|
431
474
|
timeline: TimelineService;
|
|
432
475
|
analytics: AnalyticsService;
|
|
476
|
+
pipelineAnalytics: PipelineAnalyticsService;
|
|
433
477
|
settings: SettingsService;
|
|
434
478
|
export: ExportService;
|
|
435
479
|
routes: Router;
|
|
@@ -442,4 +486,4 @@ interface CallLogEngine {
|
|
|
442
486
|
}
|
|
443
487
|
declare function createCallLogEngine(config: CallLogEngineConfig): CallLogEngine;
|
|
444
488
|
|
|
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 };
|
|
489
|
+
export { AGENT_CALL_DEFAULTS, AgentCapacityError, AlxCallLogError, AnalyticsService, AuthFailedError, CALL_LOG_DEFAULTS, CallLogClosedError, type CallLogEngine, CallLogLifecycleService, 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, PipelineAnalyticsService, PipelineNotFoundError, PipelineSchema, PipelineService, PipelineStageSchema, SYSTEM_TIMELINE, SYSTEM_TIMELINE_FN, SettingsService, StageChangeSchema, StageInUseError, StageNotFoundError, TimelineEntrySchema, TimelineService, createCallLogEngine, createCallLogModel, createCallLogSettingsModel, createPipelineModel, createRoutes, validatePipelineStages };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Router } from 'express';
|
|
2
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,
|
|
3
|
+
import { IPipeline, IPipelineStage, ICallLog, IContactRef, IStageChange, ITimelineEntry, ICallLogSettings, IPriorityConfig, ResolvedOptions, CallLogEngineConfig, DateRange, AgentInfo, AgentCallStats, DailyReport, DashboardStats, OverallCallReport, PipelineReport, PipelineFunnel, ChannelDistribution, OutcomeDistribution, FollowUpStats, ExportFormat, ExportFilter, AuthResult } from '@astralibx/call-log-types';
|
|
4
4
|
export { CallLogEngineConfig, DEFAULT_OPTIONS, ResolvedOptions } from '@astralibx/call-log-types';
|
|
5
5
|
import { LogAdapter, AlxError } from '@astralibx/core';
|
|
6
6
|
|
|
@@ -168,6 +168,8 @@ interface CreateCallLogInput {
|
|
|
168
168
|
pipelineId: string;
|
|
169
169
|
contactRef: ICallLog['contactRef'];
|
|
170
170
|
direction: ICallLog['direction'];
|
|
171
|
+
channel: string;
|
|
172
|
+
outcome: string;
|
|
171
173
|
callDate?: Date | string;
|
|
172
174
|
agentId: string;
|
|
173
175
|
priority?: ICallLog['priority'];
|
|
@@ -175,6 +177,7 @@ interface CreateCallLogInput {
|
|
|
175
177
|
category?: string;
|
|
176
178
|
nextFollowUpDate?: Date;
|
|
177
179
|
durationMinutes?: number;
|
|
180
|
+
isFollowUp?: boolean;
|
|
178
181
|
tenantId?: string;
|
|
179
182
|
metadata?: Record<string, unknown>;
|
|
180
183
|
}
|
|
@@ -184,6 +187,9 @@ interface UpdateCallLogInput {
|
|
|
184
187
|
category?: string;
|
|
185
188
|
nextFollowUpDate?: Date;
|
|
186
189
|
durationMinutes?: number;
|
|
190
|
+
channel?: string;
|
|
191
|
+
outcome?: string;
|
|
192
|
+
isFollowUp?: boolean;
|
|
187
193
|
}
|
|
188
194
|
interface ListCallLogsFilter {
|
|
189
195
|
pipelineId?: string;
|
|
@@ -192,12 +198,16 @@ interface ListCallLogsFilter {
|
|
|
192
198
|
tags?: string[];
|
|
193
199
|
category?: string;
|
|
194
200
|
isClosed?: boolean;
|
|
201
|
+
includeDeleted?: boolean;
|
|
195
202
|
contactExternalId?: string;
|
|
196
203
|
contactName?: string;
|
|
197
204
|
contactPhone?: string;
|
|
198
205
|
contactEmail?: string;
|
|
199
206
|
priority?: ICallLog['priority'];
|
|
200
207
|
direction?: ICallLog['direction'];
|
|
208
|
+
channel?: string;
|
|
209
|
+
outcome?: string;
|
|
210
|
+
isFollowUp?: boolean;
|
|
201
211
|
dateRange?: DateRange;
|
|
202
212
|
page?: number;
|
|
203
213
|
limit?: number;
|
|
@@ -217,7 +227,7 @@ interface BulkChangeStageResult {
|
|
|
217
227
|
}[];
|
|
218
228
|
total: number;
|
|
219
229
|
}
|
|
220
|
-
type ResolvedHooks = NonNullable<CallLogEngineConfig['hooks']>;
|
|
230
|
+
type ResolvedHooks$1 = NonNullable<CallLogEngineConfig['hooks']>;
|
|
221
231
|
declare class CallLogService {
|
|
222
232
|
private CallLog;
|
|
223
233
|
private Pipeline;
|
|
@@ -225,18 +235,30 @@ declare class CallLogService {
|
|
|
225
235
|
private logger;
|
|
226
236
|
private hooks;
|
|
227
237
|
private options;
|
|
228
|
-
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks, options: ResolvedOptions);
|
|
238
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks$1, options: ResolvedOptions);
|
|
229
239
|
create(data: CreateCallLogInput): Promise<ICallLogDocument>;
|
|
230
240
|
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
241
|
list(filter?: ListCallLogsFilter): Promise<ListCallLogsResult>;
|
|
234
242
|
get(callLogId: string): Promise<ICallLogDocument>;
|
|
235
243
|
getByContact(externalId: string): Promise<ICallLogDocument[]>;
|
|
236
|
-
|
|
237
|
-
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
type ResolvedHooks = NonNullable<CallLogEngineConfig['hooks']>;
|
|
247
|
+
declare class CallLogLifecycleService {
|
|
248
|
+
private CallLog;
|
|
249
|
+
private Pipeline;
|
|
250
|
+
private timeline;
|
|
251
|
+
private logger;
|
|
252
|
+
private hooks;
|
|
253
|
+
private options;
|
|
254
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, timeline: TimelineService, logger: LogAdapter, hooks: ResolvedHooks, options: ResolvedOptions);
|
|
255
|
+
changeStage(callLogId: string, newStageId: string, agentId: string): Promise<ICallLogDocument>;
|
|
256
|
+
assign(callLogId: string, agentId: string, assignedBy: string): Promise<ICallLogDocument>;
|
|
238
257
|
close(callLogId: string, agentId: string): Promise<ICallLogDocument>;
|
|
239
258
|
reopen(callLogId: string, agentId: string): Promise<ICallLogDocument>;
|
|
259
|
+
bulkChangeStage(callLogIds: string[], newStageId: string, agentId: string): Promise<BulkChangeStageResult>;
|
|
260
|
+
getFollowUpsDue(agentId?: string, dateRange?: DateRange): Promise<ICallLogDocument[]>;
|
|
261
|
+
softDelete(callLogId: string, agentId?: string, agentName?: string): Promise<ICallLogDocument>;
|
|
240
262
|
}
|
|
241
263
|
|
|
242
264
|
interface WeeklySummary {
|
|
@@ -260,20 +282,33 @@ declare class AnalyticsService {
|
|
|
260
282
|
private buildDateMatch;
|
|
261
283
|
getAgentStats(agentId: string, dateRange: DateRange): Promise<AgentCallStats>;
|
|
262
284
|
getAgentLeaderboard(dateRange: DateRange): Promise<AgentCallStats[]>;
|
|
263
|
-
getPipelineStats(pipelineId: string, dateRange: DateRange): Promise<PipelineReport>;
|
|
264
|
-
getPipelineFunnel(pipelineId: string, dateRange: DateRange): Promise<PipelineFunnel>;
|
|
265
285
|
getTeamStats(teamId?: string, dateRange?: DateRange): Promise<TeamStats>;
|
|
266
|
-
getDailyReport(dateRange: DateRange): Promise<DailyReport[]>;
|
|
286
|
+
getDailyReport(dateRange: DateRange, agentId?: string): Promise<DailyReport[]>;
|
|
267
287
|
getDashboardStats(): Promise<DashboardStats>;
|
|
268
288
|
getWeeklyTrends(weeks: number): Promise<WeeklySummary[]>;
|
|
269
289
|
getOverallReport(dateRange: DateRange): Promise<OverallCallReport>;
|
|
270
290
|
}
|
|
271
291
|
|
|
292
|
+
declare class PipelineAnalyticsService {
|
|
293
|
+
private CallLog;
|
|
294
|
+
private Pipeline;
|
|
295
|
+
private logger;
|
|
296
|
+
private resolveAgent?;
|
|
297
|
+
private tenantId?;
|
|
298
|
+
constructor(CallLog: Model<ICallLogDocument>, Pipeline: Model<IPipelineDocument>, logger: LogAdapter, resolveAgent?: ((agentId: string) => Promise<AgentInfo | null>) | undefined, tenantId?: string | undefined);
|
|
299
|
+
private buildDateMatch;
|
|
300
|
+
getPipelineStats(pipelineId: string, dateRange: DateRange): Promise<PipelineReport>;
|
|
301
|
+
getPipelineFunnel(pipelineId: string, dateRange: DateRange): Promise<PipelineFunnel>;
|
|
302
|
+
getChannelDistribution(dateRange: DateRange): Promise<ChannelDistribution[]>;
|
|
303
|
+
getOutcomeDistribution(dateRange: DateRange): Promise<OutcomeDistribution[]>;
|
|
304
|
+
getFollowUpStats(dateRange: DateRange): Promise<FollowUpStats>;
|
|
305
|
+
}
|
|
306
|
+
|
|
272
307
|
declare class ExportService {
|
|
273
308
|
private CallLog;
|
|
274
|
-
private
|
|
309
|
+
private pipelineAnalytics;
|
|
275
310
|
private logger;
|
|
276
|
-
constructor(CallLog: Model<ICallLogDocument>,
|
|
311
|
+
constructor(CallLog: Model<ICallLogDocument>, pipelineAnalytics: PipelineAnalyticsService, logger: LogAdapter);
|
|
277
312
|
exportCallLog(callLogId: string, format: ExportFormat): Promise<string>;
|
|
278
313
|
exportCallLogs(filter: ExportFilter, format: ExportFormat): Promise<string>;
|
|
279
314
|
exportPipelineReport(pipelineId: string, dateRange: DateRange, format: ExportFormat): Promise<string>;
|
|
@@ -288,6 +323,7 @@ declare const ERROR_CODE: {
|
|
|
288
323
|
readonly StageInUse: "CALL_STAGE_IN_USE";
|
|
289
324
|
readonly CallLogNotFound: "CALL_LOG_NOT_FOUND";
|
|
290
325
|
readonly CallLogClosed: "CALL_LOG_CLOSED";
|
|
326
|
+
readonly CallLogDeleted: "CALL_LOG_DELETED";
|
|
291
327
|
readonly ContactNotFound: "CALL_CONTACT_NOT_FOUND";
|
|
292
328
|
readonly AgentCapacityFull: "CALL_AGENT_CAPACITY_FULL";
|
|
293
329
|
readonly InvalidConfig: "CALL_INVALID_CONFIG";
|
|
@@ -303,6 +339,7 @@ declare const ERROR_MESSAGE: {
|
|
|
303
339
|
readonly StageInUse: "Cannot remove stage that has active calls";
|
|
304
340
|
readonly CallLogNotFound: "Call log not found";
|
|
305
341
|
readonly CallLogClosed: "Cannot modify a closed call log";
|
|
342
|
+
readonly CallLogDeleted: "Call log has been deleted";
|
|
306
343
|
readonly ContactNotFound: "Contact not found";
|
|
307
344
|
readonly AgentCapacityFull: "Agent has reached maximum concurrent calls";
|
|
308
345
|
readonly AuthFailed: "Authentication failed";
|
|
@@ -329,6 +366,8 @@ declare const SYSTEM_TIMELINE_FN: {
|
|
|
329
366
|
readonly callAssigned: (agentName: string) => string;
|
|
330
367
|
readonly callReassigned: (from: string, to: string) => string;
|
|
331
368
|
readonly followUpSet: (date: string) => string;
|
|
369
|
+
readonly callDeleted: (agentName: string) => string;
|
|
370
|
+
readonly followUpCallCreated: () => string;
|
|
332
371
|
};
|
|
333
372
|
|
|
334
373
|
declare class AlxCallLogError extends AlxError {
|
|
@@ -414,22 +453,27 @@ declare class FollowUpWorker {
|
|
|
414
453
|
interface RouteServices {
|
|
415
454
|
pipelines: PipelineService;
|
|
416
455
|
callLogs: CallLogService;
|
|
456
|
+
lifecycle: CallLogLifecycleService;
|
|
417
457
|
timeline: TimelineService;
|
|
418
458
|
analytics: AnalyticsService;
|
|
459
|
+
pipelineAnalytics: PipelineAnalyticsService;
|
|
419
460
|
settings: SettingsService;
|
|
420
461
|
export: ExportService;
|
|
421
462
|
}
|
|
422
463
|
interface RouteOptions {
|
|
423
464
|
authenticateRequest?: (req: Request) => Promise<AuthResult | null>;
|
|
424
465
|
logger: LogAdapter;
|
|
466
|
+
enableAgentScoping?: boolean;
|
|
425
467
|
}
|
|
426
468
|
declare function createRoutes(services: RouteServices, options: RouteOptions): Router;
|
|
427
469
|
|
|
428
470
|
interface CallLogEngine {
|
|
429
471
|
pipelines: PipelineService;
|
|
430
472
|
callLogs: CallLogService;
|
|
473
|
+
lifecycle: CallLogLifecycleService;
|
|
431
474
|
timeline: TimelineService;
|
|
432
475
|
analytics: AnalyticsService;
|
|
476
|
+
pipelineAnalytics: PipelineAnalyticsService;
|
|
433
477
|
settings: SettingsService;
|
|
434
478
|
export: ExportService;
|
|
435
479
|
routes: Router;
|
|
@@ -442,4 +486,4 @@ interface CallLogEngine {
|
|
|
442
486
|
}
|
|
443
487
|
declare function createCallLogEngine(config: CallLogEngineConfig): CallLogEngine;
|
|
444
488
|
|
|
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 };
|
|
489
|
+
export { AGENT_CALL_DEFAULTS, AgentCapacityError, AlxCallLogError, AnalyticsService, AuthFailedError, CALL_LOG_DEFAULTS, CallLogClosedError, type CallLogEngine, CallLogLifecycleService, 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, PipelineAnalyticsService, PipelineNotFoundError, PipelineSchema, PipelineService, PipelineStageSchema, SYSTEM_TIMELINE, SYSTEM_TIMELINE_FN, SettingsService, StageChangeSchema, StageInUseError, StageNotFoundError, TimelineEntrySchema, TimelineService, createCallLogEngine, createCallLogModel, createCallLogSettingsModel, createPipelineModel, createRoutes, validatePipelineStages };
|