@talkpilot/core-db 1.3.12 → 1.3.13

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 +307 -297
  4. package/dist/municipal/tickets/tickets.statistics.getters.d.ts.map +1 -1
  5. package/dist/municipal/tickets/tickets.statistics.getters.js +6 -2
  6. package/dist/municipal/tickets/tickets.statistics.getters.js.map +1 -1
  7. package/dist/talkpilot/flows/flows.schema.d.ts +3 -0
  8. package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
  9. package/dist/talkpilot/flows/flows.schema.js +1 -0
  10. package/dist/talkpilot/flows/flows.schema.js.map +1 -1
  11. package/dist/talkpilot/flows/flows.types.d.ts +2 -0
  12. package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
  13. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +4 -0
  14. package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +1 -0
  15. package/dist/talkpilot/subscriptions/subscriptions.utils.js +20 -0
  16. package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +1 -0
  17. package/dist/test-utils/factories/talkpilot/flows.d.ts.map +1 -1
  18. package/dist/test-utils/factories/talkpilot/flows.js +1 -0
  19. package/dist/test-utils/factories/talkpilot/flows.js.map +1 -1
  20. package/jest.config.js +20 -20
  21. package/package.json +46 -46
  22. package/src/municipal/muniIssues/__tests__/muniIssues.setters.spec.ts +94 -94
  23. package/src/municipal/tickets/__tests__/tickets.statistics.spec.ts +99 -99
  24. package/src/municipal/tickets/index.ts +9 -9
  25. package/src/municipal/tickets/tickets.statistics.aggregation.ts +110 -110
  26. package/src/municipal/tickets/tickets.statistics.getters.ts +145 -132
  27. package/src/municipal/tickets/tickets.types.ts +54 -54
  28. package/src/talkpilot/calls/__tests__/calls.statistics.spec.ts +483 -481
  29. package/src/talkpilot/calls/calls.statistics.getters.ts +668 -668
  30. package/src/talkpilot/calls/calls.statistics.types.ts +48 -48
  31. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +127 -127
  32. package/src/talkpilot/contextNotes/__tests__/contextNotes.getters.spec.ts +217 -217
  33. package/src/talkpilot/contextNotes/contextNotes.getters.ts +85 -85
  34. package/src/talkpilot/flows/flows.schema.ts +1 -0
  35. package/src/talkpilot/flows/flows.types.ts +2 -0
  36. package/src/talkpilot/products/__tests__/products.getters.spec.ts +44 -44
  37. package/src/test-utils/factories/talkpilot/contextNotes.ts +40 -40
  38. package/src/test-utils/factories/talkpilot/flows.ts +1 -0
  39. package/src/utils/date.utils.ts +126 -126
  40. package/tsconfig.json +23 -23
  41. package/README_OLD.md +0 -160
  42. package/dist/talkpilot/calls/calls.dashboard.d.ts +0 -3
  43. package/dist/talkpilot/calls/calls.dashboard.d.ts.map +0 -1
  44. package/dist/talkpilot/calls/calls.dashboard.js +0 -191
  45. package/dist/talkpilot/calls/calls.dashboard.js.map +0 -1
@@ -1,48 +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
- 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
+ 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
+ >;