@talkpilot/core-db 1.3.11 → 1.3.12

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.
Files changed (45) hide show
  1. package/.cursor/rules/development.mdc +65 -65
  2. package/DEVELOPMENT.md +141 -141
  3. package/README.md +297 -287
  4. package/README_OLD.md +160 -160
  5. package/dist/municipal/tickets/index.d.ts +1 -1
  6. package/dist/municipal/tickets/index.d.ts.map +1 -1
  7. package/dist/municipal/tickets/tickets.statistics.getters.d.ts.map +1 -1
  8. package/dist/municipal/tickets/tickets.statistics.getters.js +13 -4
  9. package/dist/municipal/tickets/tickets.statistics.getters.js.map +1 -1
  10. package/dist/talkpilot/calls/calls.dashboard.d.ts +3 -0
  11. package/dist/talkpilot/calls/calls.dashboard.d.ts.map +1 -0
  12. package/dist/talkpilot/calls/calls.dashboard.js +191 -0
  13. package/dist/talkpilot/calls/calls.dashboard.js.map +1 -0
  14. package/dist/talkpilot/calls/calls.statistics.getters.d.ts.map +1 -1
  15. package/dist/talkpilot/calls/calls.statistics.getters.js +39 -10
  16. package/dist/talkpilot/calls/calls.statistics.getters.js.map +1 -1
  17. package/dist/talkpilot/calls/calls.statistics.types.d.ts +1 -0
  18. package/dist/talkpilot/calls/calls.statistics.types.d.ts.map +1 -1
  19. package/dist/talkpilot/contextNotes/contextNotes.getters.d.ts.map +1 -1
  20. package/dist/talkpilot/contextNotes/contextNotes.getters.js +1 -3
  21. package/dist/talkpilot/contextNotes/contextNotes.getters.js.map +1 -1
  22. package/dist/test-utils/factories/talkpilot/contextNotes.d.ts.map +1 -1
  23. package/dist/test-utils/factories/talkpilot/contextNotes.js +4 -1
  24. package/dist/test-utils/factories/talkpilot/contextNotes.js.map +1 -1
  25. package/dist/utils/date.utils.d.ts.map +1 -1
  26. package/dist/utils/date.utils.js +7 -2
  27. package/dist/utils/date.utils.js.map +1 -1
  28. package/jest.config.js +20 -20
  29. package/package.json +46 -46
  30. package/src/municipal/muniIssues/__tests__/muniIssues.setters.spec.ts +94 -92
  31. package/src/municipal/tickets/__tests__/tickets.statistics.spec.ts +99 -94
  32. package/src/municipal/tickets/index.ts +9 -3
  33. package/src/municipal/tickets/tickets.statistics.aggregation.ts +110 -110
  34. package/src/municipal/tickets/tickets.statistics.getters.ts +132 -109
  35. package/src/municipal/tickets/tickets.types.ts +54 -54
  36. package/src/talkpilot/calls/__tests__/calls.statistics.spec.ts +481 -375
  37. package/src/talkpilot/calls/calls.statistics.getters.ts +668 -590
  38. package/src/talkpilot/calls/calls.statistics.types.ts +48 -47
  39. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +127 -127
  40. package/src/talkpilot/contextNotes/__tests__/contextNotes.getters.spec.ts +217 -176
  41. package/src/talkpilot/contextNotes/contextNotes.getters.ts +85 -86
  42. package/src/talkpilot/products/__tests__/products.getters.spec.ts +44 -45
  43. package/src/test-utils/factories/talkpilot/contextNotes.ts +40 -33
  44. package/src/utils/date.utils.ts +126 -116
  45. package/tsconfig.json +23 -23
@@ -1,47 +1,48 @@
1
- export type ResolvedTimeBucket = "day" | "week" | "month";
2
-
3
- export type TicketStatusFilter = "opened" | "not_opened";
4
- export type CallRoutingFilter = "ai_only" | "transferred" | "hijacked";
5
-
6
- export type CallsStatsFilter = {
7
- clientId: string;
8
- startStr: string;
9
- endStr: string;
10
- timezone: string;
11
- hourFrom?: string; // HH:mm
12
- hourTo?: string; // HH:mm
13
- callRouting?: CallRoutingFilter[];
14
- /** @deprecated Use callSidTicketCounts instead. */
15
- callSidsWithTickets?: string[];
16
- callSidTicketCounts?: Map<string, number>;
17
- /** @deprecated Use callSidDraftTicketCounts instead. */
18
- callSidsWithDraftTickets?: string[];
19
- callSidDraftTicketCounts?: Map<string, number>;
20
- ticketStatusFilters?: TicketStatusFilter[];
21
- };
22
-
23
- export type CallsSummaryAggregation = {
24
- totalCalls: number;
25
- avgDurationSeconds: number;
26
- openTickets: number;
27
- draftTickets: number;
28
- };
29
-
30
- export type CallsTrendBucket = {
31
- /** Day: YYYY-MM-DD; week: YYYY-MM-DD/YYYY-MM-DD (inclusive, clipped to filter); month: YYYY-MM-01 */
32
- bucket: string;
33
- totalCalls: number;
34
- openTickets: number;
35
- };
36
-
37
- export type CallsHourlyBucket = {
38
- hour: number;
39
- totalCalls: number;
40
- avgCalls: number;
41
- };
42
-
43
- export type CallsRoutingAggregation = {
44
- aiHandled: number;
45
- transferred: number;
46
- hijacked: number;
47
- };
1
+ export type ResolvedTimeBucket = "day" | "week" | "month";
2
+
3
+ export type TicketStatusFilter = "opened" | "not_opened";
4
+ export type CallRoutingFilter = "ai_only" | "transferred" | "hijacked";
5
+
6
+ export type CallsStatsFilter = {
7
+ clientId: string;
8
+ startStr: string;
9
+ endStr: string;
10
+ timezone: string;
11
+ hourFrom?: string; // HH:mm
12
+ hourTo?: string; // HH:mm
13
+ callRouting?: CallRoutingFilter[];
14
+ /** @deprecated Use callSidTicketCounts instead. */
15
+ callSidsWithTickets?: string[];
16
+ callSidTicketCounts?: Map<string, number>;
17
+ /** @deprecated Use callSidDraftTicketCounts instead. */
18
+ callSidsWithDraftTickets?: string[];
19
+ callSidDraftTicketCounts?: Map<string, number>;
20
+ ticketStatusFilters?: TicketStatusFilter[];
21
+ };
22
+
23
+ export type CallsSummaryAggregation = {
24
+ totalCalls: number;
25
+ avgDurationSeconds: number;
26
+ openTickets: number;
27
+ draftTickets: number;
28
+ callsWithTickets?: number;
29
+ };
30
+
31
+ export type CallsTrendBucket = {
32
+ /** Day: YYYY-MM-DD; week: YYYY-MM-DD/YYYY-MM-DD (inclusive, clipped to filter); month: YYYY-MM-01 */
33
+ bucket: string;
34
+ totalCalls: number;
35
+ openTickets: number;
36
+ };
37
+
38
+ export type CallsHourlyBucket = {
39
+ hour: number;
40
+ totalCalls: number;
41
+ avgCalls: number;
42
+ };
43
+
44
+ export type CallsRoutingAggregation = {
45
+ aiHandled: number;
46
+ transferred: number;
47
+ hijacked: number;
48
+ };
@@ -1,127 +1,127 @@
1
- import { WithId } from "mongodb";
2
- import { CallLengthThresholds } from "../../utils/shared.types";
3
-
4
- // ---------------------------------------------------------------------------
5
- // Moked106 (MIS)
6
- // ---------------------------------------------------------------------------
7
-
8
- export type InitiateCallForShortSlaConfig = {
9
- active: boolean;
10
- max_hours: number;
11
- contacts?: { name: string; phoneNumber: string }[];
12
- flow_id?: string | string[];
13
- };
14
-
15
- /** Per-tool LLM system prompt overrides. Falls back to hardcoded defaults when absent. */
16
- export type Moked106ToolPrompts = {
17
- findSubjectsSystemPrompt?: string;
18
- findStreetsSystemPrompt?: string;
19
- };
20
-
21
- /** Feature flags and behavior config for the moked_106 municipal call-center product. */
22
- export type Moked106Config = {
23
- initiate_call_for_short_sla?: InitiateCallForShortSlaConfig;
24
- avoidSaveTickets?: boolean;
25
- withUploadImagesSms?: boolean;
26
- withNeedAttentionCalls?: boolean;
27
- toolsPrompts?: Moked106ToolPrompts;
28
- };
29
-
30
- export const KNOWN_PRODUCT_KEYS = [
31
- "municipal",
32
- "clinics",
33
- "websiteTalk",
34
- ] as const;
35
- export type KnownProductKey = (typeof KNOWN_PRODUCT_KEYS)[number];
36
-
37
- /** Product config for the MIS */
38
- export type MunicipalProduct = {
39
- moked_106?: Moked106Config;
40
- cityName: string;
41
- crmName?: string;
42
- cityDisplayName?: string;
43
- cityLogoURL?: string;
44
- timezone: string;
45
- websiteUrl?: string;
46
- isProductionReady?: boolean;
47
- municipalDisplayName?: string;
48
- };
49
-
50
- // ---------------------------------------------------------------------------
51
- // WebsiteTalk
52
- // ---------------------------------------------------------------------------
53
-
54
- export type WebsiteTalkScheduler = {
55
- type: "cron";
56
- schedule: string;
57
- };
58
-
59
- /** Product config for the websiteTalk */
60
- export type WebsiteTalkProduct = {
61
- logoUrl: string;
62
- companyName: string;
63
- timezone: string;
64
- language: string;
65
- defaultBaseUrl: string;
66
- };
67
-
68
- // ---------------------------------------------------------------------------
69
- // Clinics
70
- // ---------------------------------------------------------------------------
71
-
72
- /** Product config for the clinics scheduling integration. */
73
- export type ClinicsProduct = {
74
- api_key_secret_name: string;
75
- base_api_url: string;
76
- provider: "clinix" | (string & {});
77
- description?: string;
78
- };
79
-
80
- // ---------------------------------------------------------------------------
81
- // Top Level Client config
82
- // ---------------------------------------------------------------------------
83
-
84
- export type Products = {
85
- municipal?: MunicipalProduct;
86
- clinics?: ClinicsProduct;
87
- websiteTalk?: WebsiteTalkProduct;
88
- [key: string]: unknown;
89
- };
90
-
91
- export type ClientLanguageName =
92
- | "Hebrew"
93
- | "English"
94
- | "Russian"
95
- | "French"
96
- | "Spanish"
97
- | (string & {});
98
-
99
- export type SendGridConfig = {
100
- emailTo: string[];
101
- templateId?: string;
102
- senderId?: string;
103
- };
104
-
105
- export type SmsConfig = {};
106
-
107
- export type WhatsappConfig = {};
108
-
109
- export type CommunicationsConfig = {
110
- sendGrid?: SendGridConfig;
111
- sms?: SmsConfig;
112
- whatsapp?: WhatsappConfig;
113
- };
114
-
115
- export type ClientConfig<P extends Products = Products> = {
116
- clientId: string;
117
- phoneNumber?: string;
118
- language?: ClientLanguageName;
119
- products: P;
120
- timezone?: string;
121
- communications?: CommunicationsConfig;
122
- callLengthThresholds?: CallLengthThresholds;
123
- };
124
-
125
- export type ClientConfigDoc<P extends Products = Products> = WithId<
126
- ClientConfig<P>
127
- >;
1
+ import { WithId } from "mongodb";
2
+ import { CallLengthThresholds } from "../../utils/shared.types";
3
+
4
+ // ---------------------------------------------------------------------------
5
+ // Moked106 (MIS)
6
+ // ---------------------------------------------------------------------------
7
+
8
+ export type InitiateCallForShortSlaConfig = {
9
+ active: boolean;
10
+ max_hours: number;
11
+ contacts?: { name: string; phoneNumber: string }[];
12
+ flow_id?: string | string[];
13
+ };
14
+
15
+ /** Per-tool LLM system prompt overrides. Falls back to hardcoded defaults when absent. */
16
+ export type Moked106ToolPrompts = {
17
+ findSubjectsSystemPrompt?: string;
18
+ findStreetsSystemPrompt?: string;
19
+ };
20
+
21
+ /** Feature flags and behavior config for the moked_106 municipal call-center product. */
22
+ export type Moked106Config = {
23
+ initiate_call_for_short_sla?: InitiateCallForShortSlaConfig;
24
+ avoidSaveTickets?: boolean;
25
+ withUploadImagesSms?: boolean;
26
+ withNeedAttentionCalls?: boolean;
27
+ toolsPrompts?: Moked106ToolPrompts;
28
+ };
29
+
30
+ export const KNOWN_PRODUCT_KEYS = [
31
+ "municipal",
32
+ "clinics",
33
+ "websiteTalk",
34
+ ] as const;
35
+ export type KnownProductKey = (typeof KNOWN_PRODUCT_KEYS)[number];
36
+
37
+ /** Product config for the MIS */
38
+ export type MunicipalProduct = {
39
+ moked_106?: Moked106Config;
40
+ cityName: string;
41
+ crmName?: string;
42
+ cityDisplayName?: string;
43
+ cityLogoURL?: string;
44
+ timezone: string;
45
+ websiteUrl?: string;
46
+ isProductionReady?: boolean;
47
+ municipalDisplayName?: string;
48
+ };
49
+
50
+ // ---------------------------------------------------------------------------
51
+ // WebsiteTalk
52
+ // ---------------------------------------------------------------------------
53
+
54
+ export type WebsiteTalkScheduler = {
55
+ type: "cron";
56
+ schedule: string;
57
+ };
58
+
59
+ /** Product config for the websiteTalk */
60
+ export type WebsiteTalkProduct = {
61
+ logoUrl: string;
62
+ companyName: string;
63
+ timezone: string;
64
+ language: string;
65
+ defaultBaseUrl: string;
66
+ };
67
+
68
+ // ---------------------------------------------------------------------------
69
+ // Clinics
70
+ // ---------------------------------------------------------------------------
71
+
72
+ /** Product config for the clinics scheduling integration. */
73
+ export type ClinicsProduct = {
74
+ api_key_secret_name: string;
75
+ base_api_url: string;
76
+ provider: "clinix" | (string & {});
77
+ description?: string;
78
+ };
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // Top Level Client config
82
+ // ---------------------------------------------------------------------------
83
+
84
+ export type Products = {
85
+ municipal?: MunicipalProduct;
86
+ clinics?: ClinicsProduct;
87
+ websiteTalk?: WebsiteTalkProduct;
88
+ [key: string]: unknown;
89
+ };
90
+
91
+ export type ClientLanguageName =
92
+ | "Hebrew"
93
+ | "English"
94
+ | "Russian"
95
+ | "French"
96
+ | "Spanish"
97
+ | (string & {});
98
+
99
+ export type SendGridConfig = {
100
+ emailTo: string[];
101
+ templateId?: string;
102
+ senderId?: string;
103
+ };
104
+
105
+ export type SmsConfig = {};
106
+
107
+ export type WhatsappConfig = {};
108
+
109
+ export type CommunicationsConfig = {
110
+ sendGrid?: SendGridConfig;
111
+ sms?: SmsConfig;
112
+ whatsapp?: WhatsappConfig;
113
+ };
114
+
115
+ export type ClientConfig<P extends Products = Products> = {
116
+ clientId: string;
117
+ phoneNumber?: string;
118
+ language?: ClientLanguageName;
119
+ products: P;
120
+ timezone?: string;
121
+ communications?: CommunicationsConfig;
122
+ callLengthThresholds?: CallLengthThresholds;
123
+ };
124
+
125
+ export type ClientConfigDoc<P extends Products = Products> = WithId<
126
+ ClientConfig<P>
127
+ >;