@talkpilot/core-db 1.3.8 → 1.3.11
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/.cursor/rules/development.mdc +65 -65
- package/DEVELOPMENT.md +141 -141
- package/README.md +287 -243
- package/README_OLD.md +160 -160
- package/dist/municipal/tickets/tickets.statistics.aggregation.d.ts +34 -0
- package/dist/municipal/tickets/tickets.statistics.aggregation.d.ts.map +1 -1
- package/dist/municipal/tickets/tickets.statistics.aggregation.js +14 -1
- package/dist/municipal/tickets/tickets.statistics.aggregation.js.map +1 -1
- package/dist/municipal/tickets/tickets.statistics.getters.js +2 -2
- package/dist/municipal/tickets/tickets.statistics.getters.js.map +1 -1
- package/dist/municipal/tickets/tickets.types.d.ts +1 -0
- package/dist/municipal/tickets/tickets.types.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.statistics.getters.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.statistics.getters.js +6 -3
- package/dist/talkpilot/calls/calls.statistics.getters.js.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
- package/jest.config.js +20 -20
- package/package.json +46 -46
- package/src/connection.ts +54 -54
- package/src/index.ts +26 -26
- package/src/municipal/index.ts +22 -22
- package/src/municipal/muniIssues/__tests__/muniIssues.setters.spec.ts +92 -92
- package/src/municipal/muniIssues/__tests__/muniIssues.setup.spec.ts +92 -92
- package/src/municipal/muniIssues/index.ts +17 -17
- package/src/municipal/muniIssues/muniIssues.constants.ts +18 -18
- package/src/municipal/muniIssues/muniIssues.getters.ts +24 -24
- package/src/municipal/muniIssues/muniIssues.schema.ts +66 -66
- package/src/municipal/muniIssues/muniIssues.setters.ts +24 -24
- package/src/municipal/muniIssues/muniIssues.setup.ts +65 -65
- package/src/municipal/muniIssues/muniIssues.types.ts +37 -37
- package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +30 -30
- package/src/municipal/tickets/__tests__/tickets.statistics.spec.ts +94 -68
- package/src/municipal/tickets/index.ts +3 -3
- package/src/municipal/tickets/tickets.constants.ts +8 -8
- package/src/municipal/tickets/tickets.getters.ts +121 -121
- package/src/municipal/tickets/tickets.statistics.aggregation.ts +110 -96
- package/src/municipal/tickets/tickets.statistics.getters.ts +109 -109
- package/src/municipal/tickets/tickets.types.ts +54 -53
- package/src/talkpilot/calls/__tests__/calls.dashboard.spec.ts +149 -149
- package/src/talkpilot/calls/__tests__/calls.statistics.spec.ts +375 -351
- package/src/talkpilot/calls/calls.constants.ts +20 -20
- package/src/talkpilot/calls/calls.statistics.getters.ts +590 -587
- package/src/talkpilot/calls/calls.statistics.types.ts +47 -47
- package/src/talkpilot/calls/calls.types.ts +119 -119
- package/src/talkpilot/calls/dashboard/calls.dashboard.ts +292 -292
- package/src/talkpilot/calls/dashboard/calls.dashboard.types.ts +57 -57
- package/src/talkpilot/calls/index.ts +6 -6
- package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +190 -190
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +1 -1
- package/src/talkpilot/contextNotes/__tests__/contextNotes.getters.spec.ts +176 -176
- package/src/talkpilot/contextNotes/contextNotes.getters.ts +86 -86
- package/src/talkpilot/contextNotes/contextNotes.types.ts +20 -20
- package/src/talkpilot/contextNotes/index.ts +2 -2
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +96 -96
- package/src/talkpilot/flows/flows.schema.ts +154 -154
- package/src/talkpilot/flows/flows.types.ts +187 -187
- package/src/talkpilot/index.ts +31 -31
- package/src/talkpilot/products/__tests__/products.getters.spec.ts +45 -45
- package/src/talkpilot/products/index.ts +2 -2
- package/src/talkpilot/products/products.getters.ts +12 -12
- package/src/talkpilot/products/products.types.ts +9 -9
- package/src/test-utils/db-utils.ts +26 -26
- package/src/test-utils/factories/index.ts +15 -15
- package/src/test-utils/factories/municipal/muniIssues.ts +32 -32
- package/src/test-utils/factories/talkpilot/contextNotes.ts +33 -33
- package/src/test-utils/factories/websitalk/scans.ts +23 -23
- package/src/utils/date.utils.ts +116 -116
- package/src/websitalk/index.ts +15 -15
- package/src/websitalk/mongodb-client.ts +61 -61
- package/src/websitalk/scans/__tests__/scans.spec.ts +218 -218
- package/src/websitalk/scans/index.ts +2 -2
- package/src/websitalk/scans/scans.getters.ts +113 -113
- package/src/websitalk/scans/scans.types.ts +53 -53
- package/tsconfig.json +23 -23
- package/dist/talkpilot/calls/calls.dashboard.d.ts +0 -3
- package/dist/talkpilot/calls/calls.dashboard.d.ts.map +0 -1
- package/dist/talkpilot/calls/calls.dashboard.js +0 -191
- package/dist/talkpilot/calls/calls.dashboard.js.map +0 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
export type DashboardHeatmapMetric = {
|
|
2
|
-
hour: number;
|
|
3
|
-
calls: number;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export type DashboardDailyTrendMetric = {
|
|
7
|
-
date: string;
|
|
8
|
-
completed: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type DashboardVolumeGranularity =
|
|
12
|
-
| "hour"
|
|
13
|
-
| "day"
|
|
14
|
-
| "week"
|
|
15
|
-
| "month"
|
|
16
|
-
| "quarter"
|
|
17
|
-
| "year";
|
|
18
|
-
|
|
19
|
-
export type DashboardSummaryMetrics = {
|
|
20
|
-
totalCalls: number;
|
|
21
|
-
avgDurationSeconds: number;
|
|
22
|
-
timeSavedMinutes: number;
|
|
23
|
-
completedCount: number;
|
|
24
|
-
busyCount: number;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type DashboardVisualData = {
|
|
28
|
-
volumeData: DashboardDailyTrendMetric[];
|
|
29
|
-
volumeGranularity: DashboardVolumeGranularity;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type DashboardReportQuery = {
|
|
33
|
-
clientId: string;
|
|
34
|
-
startDate: string;
|
|
35
|
-
endDate: string;
|
|
36
|
-
granularity?: DashboardVolumeGranularity;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type DashboardReportResponse = {
|
|
40
|
-
kpis: DashboardSummaryMetrics;
|
|
41
|
-
charts: DashboardVisualData;
|
|
42
|
-
};
|
|
43
|
-
type RawKpiResult = {
|
|
44
|
-
completedCount: number;
|
|
45
|
-
busyCount: number;
|
|
46
|
-
answeredDuration: number | null;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type RawVolumeAggregationResult = {
|
|
50
|
-
_id: string;
|
|
51
|
-
completed: number;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export interface DashboardAggregationResult {
|
|
55
|
-
kpis: RawKpiResult[];
|
|
56
|
-
volumeData: RawVolumeAggregationResult[];
|
|
57
|
-
}
|
|
1
|
+
export type DashboardHeatmapMetric = {
|
|
2
|
+
hour: number;
|
|
3
|
+
calls: number;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type DashboardDailyTrendMetric = {
|
|
7
|
+
date: string;
|
|
8
|
+
completed: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type DashboardVolumeGranularity =
|
|
12
|
+
| "hour"
|
|
13
|
+
| "day"
|
|
14
|
+
| "week"
|
|
15
|
+
| "month"
|
|
16
|
+
| "quarter"
|
|
17
|
+
| "year";
|
|
18
|
+
|
|
19
|
+
export type DashboardSummaryMetrics = {
|
|
20
|
+
totalCalls: number;
|
|
21
|
+
avgDurationSeconds: number;
|
|
22
|
+
timeSavedMinutes: number;
|
|
23
|
+
completedCount: number;
|
|
24
|
+
busyCount: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type DashboardVisualData = {
|
|
28
|
+
volumeData: DashboardDailyTrendMetric[];
|
|
29
|
+
volumeGranularity: DashboardVolumeGranularity;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type DashboardReportQuery = {
|
|
33
|
+
clientId: string;
|
|
34
|
+
startDate: string;
|
|
35
|
+
endDate: string;
|
|
36
|
+
granularity?: DashboardVolumeGranularity;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type DashboardReportResponse = {
|
|
40
|
+
kpis: DashboardSummaryMetrics;
|
|
41
|
+
charts: DashboardVisualData;
|
|
42
|
+
};
|
|
43
|
+
type RawKpiResult = {
|
|
44
|
+
completedCount: number;
|
|
45
|
+
busyCount: number;
|
|
46
|
+
answeredDuration: number | null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type RawVolumeAggregationResult = {
|
|
50
|
+
_id: string;
|
|
51
|
+
completed: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export interface DashboardAggregationResult {
|
|
55
|
+
kpis: RawKpiResult[];
|
|
56
|
+
volumeData: RawVolumeAggregationResult[];
|
|
57
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./calls.constants";
|
|
2
|
-
export * from "./calls.types";
|
|
3
|
-
export * from "./calls.getters";
|
|
4
|
-
export * from "./calls.statistics.types";
|
|
5
|
-
export * from "./calls.statistics.getters";
|
|
6
|
-
export * from "./dashboard/calls.dashboard";
|
|
1
|
+
export * from "./calls.constants";
|
|
2
|
+
export * from "./calls.types";
|
|
3
|
+
export * from "./calls.getters";
|
|
4
|
+
export * from "./calls.statistics.types";
|
|
5
|
+
export * from "./calls.statistics.getters";
|
|
6
|
+
export * from "./dashboard/calls.dashboard";
|
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createClientConfigDoc,
|
|
3
|
-
getClientConfig,
|
|
4
|
-
} from "../clientsConfig.getters";
|
|
5
|
-
import { createClientConfig } from "../../../test-utils/factories";
|
|
6
|
-
|
|
7
|
-
describe("db.clientsConfig", () => {
|
|
8
|
-
describe("getClientConfig", () => {
|
|
9
|
-
it("should return client config by clientId", async () => {
|
|
10
|
-
const clientId = "test-client-id";
|
|
11
|
-
const clientConfig = createClientConfig({
|
|
12
|
-
clientId,
|
|
13
|
-
language: "Hebrew",
|
|
14
|
-
products: { feature1: true, feature2: false } as any,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
await createClientConfigDoc(clientConfig);
|
|
18
|
-
|
|
19
|
-
const result = await getClientConfig(clientId);
|
|
20
|
-
|
|
21
|
-
expect(result).toMatchObject({
|
|
22
|
-
clientId,
|
|
23
|
-
language: "Hebrew",
|
|
24
|
-
products: { feature1: true, feature2: false },
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should support websiteTalk product config", async () => {
|
|
29
|
-
const clientId = "websiteTalk-test";
|
|
30
|
-
const clientConfig = createClientConfig({
|
|
31
|
-
clientId,
|
|
32
|
-
products: {
|
|
33
|
-
websiteTalk: {
|
|
34
|
-
logoUrl: "https://cdn.example.com/branding/acme/logo.png",
|
|
35
|
-
companyName: "Acme Ltd",
|
|
36
|
-
timezone: "Asia/Jerusalem",
|
|
37
|
-
language: "he",
|
|
38
|
-
defaultBaseUrl: "https://acme.example",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
await createClientConfigDoc(clientConfig);
|
|
44
|
-
|
|
45
|
-
const result = await getClientConfig(clientId);
|
|
46
|
-
|
|
47
|
-
expect(result).toMatchObject({
|
|
48
|
-
clientId,
|
|
49
|
-
products: {
|
|
50
|
-
websiteTalk: {
|
|
51
|
-
logoUrl: "https://cdn.example.com/branding/acme/logo.png",
|
|
52
|
-
companyName: "Acme Ltd",
|
|
53
|
-
timezone: "Asia/Jerusalem",
|
|
54
|
-
language: "he",
|
|
55
|
-
defaultBaseUrl: "https://acme.example",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should return null for non-existent clientId", async () => {
|
|
62
|
-
const result = await getClientConfig("non-existent-client");
|
|
63
|
-
expect(result).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("given moked_106 with both toolsPrompts when saved and retrieved then both prompts are persisted", async () => {
|
|
67
|
-
// Given
|
|
68
|
-
const clientId = "tools-prompts-both";
|
|
69
|
-
const clientConfig = createClientConfig({
|
|
70
|
-
clientId,
|
|
71
|
-
products: {
|
|
72
|
-
municipal: {
|
|
73
|
-
cityName: "ashdod",
|
|
74
|
-
timezone: "Asia/Jerusalem",
|
|
75
|
-
moked_106: {
|
|
76
|
-
toolsPrompts: {
|
|
77
|
-
findSubjectsSystemPrompt: "Custom subjects prompt",
|
|
78
|
-
findStreetsSystemPrompt: "Custom streets prompt",
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// When
|
|
86
|
-
await createClientConfigDoc(clientConfig);
|
|
87
|
-
const result = await getClientConfig(clientId);
|
|
88
|
-
|
|
89
|
-
// Then
|
|
90
|
-
expect(result?.products.municipal?.moked_106?.toolsPrompts).toMatchObject(
|
|
91
|
-
{
|
|
92
|
-
findSubjectsSystemPrompt: "Custom subjects prompt",
|
|
93
|
-
findStreetsSystemPrompt: "Custom streets prompt",
|
|
94
|
-
},
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("given moked_106 with findSubjectsSystemPrompt only when saved and retrieved then findStreetsSystemPrompt is undefined", async () => {
|
|
99
|
-
// Given
|
|
100
|
-
const clientId = "tools-prompts-subjects-only";
|
|
101
|
-
const clientConfig = createClientConfig({
|
|
102
|
-
clientId,
|
|
103
|
-
products: {
|
|
104
|
-
municipal: {
|
|
105
|
-
cityName: "ashdod",
|
|
106
|
-
timezone: "Asia/Jerusalem",
|
|
107
|
-
moked_106: {
|
|
108
|
-
toolsPrompts: {
|
|
109
|
-
findSubjectsSystemPrompt: "Subjects only prompt",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// When
|
|
117
|
-
await createClientConfigDoc(clientConfig);
|
|
118
|
-
const result = await getClientConfig(clientId);
|
|
119
|
-
|
|
120
|
-
// Then
|
|
121
|
-
expect(
|
|
122
|
-
result?.products.municipal?.moked_106?.toolsPrompts
|
|
123
|
-
?.findSubjectsSystemPrompt,
|
|
124
|
-
).toBe("Subjects only prompt");
|
|
125
|
-
expect(
|
|
126
|
-
result?.products.municipal?.moked_106?.toolsPrompts
|
|
127
|
-
?.findStreetsSystemPrompt,
|
|
128
|
-
).toBeUndefined();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("given moked_106 without toolsPrompts when saved and retrieved then toolsPrompts is undefined", async () => {
|
|
132
|
-
// Given
|
|
133
|
-
const clientId = "tools-prompts-absent";
|
|
134
|
-
const clientConfig = createClientConfig({
|
|
135
|
-
clientId,
|
|
136
|
-
products: {
|
|
137
|
-
municipal: {
|
|
138
|
-
cityName: "ashdod",
|
|
139
|
-
timezone: "Asia/Jerusalem",
|
|
140
|
-
moked_106: {
|
|
141
|
-
avoidSaveTickets: true,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// When
|
|
148
|
-
await createClientConfigDoc(clientConfig);
|
|
149
|
-
const result = await getClientConfig(clientId);
|
|
150
|
-
|
|
151
|
-
// Then
|
|
152
|
-
expect(
|
|
153
|
-
result?.products.municipal?.moked_106?.toolsPrompts,
|
|
154
|
-
).toBeUndefined();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("should support communications config", async () => {
|
|
158
|
-
const clientId = "communications-test";
|
|
159
|
-
const clientConfig = createClientConfig({
|
|
160
|
-
clientId,
|
|
161
|
-
communications: {
|
|
162
|
-
sendGrid: {
|
|
163
|
-
emailTo: ["test@example.com"],
|
|
164
|
-
templateId: "temp-123",
|
|
165
|
-
senderId: "sender-123",
|
|
166
|
-
},
|
|
167
|
-
sms: {},
|
|
168
|
-
whatsapp: {},
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
await createClientConfigDoc(clientConfig);
|
|
173
|
-
|
|
174
|
-
const result = await getClientConfig(clientId);
|
|
175
|
-
|
|
176
|
-
expect(result).toMatchObject({
|
|
177
|
-
clientId,
|
|
178
|
-
communications: {
|
|
179
|
-
sendGrid: {
|
|
180
|
-
emailTo: ["test@example.com"],
|
|
181
|
-
templateId: "temp-123",
|
|
182
|
-
senderId: "sender-123",
|
|
183
|
-
},
|
|
184
|
-
sms: {},
|
|
185
|
-
whatsapp: {},
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
createClientConfigDoc,
|
|
3
|
+
getClientConfig,
|
|
4
|
+
} from "../clientsConfig.getters";
|
|
5
|
+
import { createClientConfig } from "../../../test-utils/factories";
|
|
6
|
+
|
|
7
|
+
describe("db.clientsConfig", () => {
|
|
8
|
+
describe("getClientConfig", () => {
|
|
9
|
+
it("should return client config by clientId", async () => {
|
|
10
|
+
const clientId = "test-client-id";
|
|
11
|
+
const clientConfig = createClientConfig({
|
|
12
|
+
clientId,
|
|
13
|
+
language: "Hebrew",
|
|
14
|
+
products: { feature1: true, feature2: false } as any,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
await createClientConfigDoc(clientConfig);
|
|
18
|
+
|
|
19
|
+
const result = await getClientConfig(clientId);
|
|
20
|
+
|
|
21
|
+
expect(result).toMatchObject({
|
|
22
|
+
clientId,
|
|
23
|
+
language: "Hebrew",
|
|
24
|
+
products: { feature1: true, feature2: false },
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should support websiteTalk product config", async () => {
|
|
29
|
+
const clientId = "websiteTalk-test";
|
|
30
|
+
const clientConfig = createClientConfig({
|
|
31
|
+
clientId,
|
|
32
|
+
products: {
|
|
33
|
+
websiteTalk: {
|
|
34
|
+
logoUrl: "https://cdn.example.com/branding/acme/logo.png",
|
|
35
|
+
companyName: "Acme Ltd",
|
|
36
|
+
timezone: "Asia/Jerusalem",
|
|
37
|
+
language: "he",
|
|
38
|
+
defaultBaseUrl: "https://acme.example",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await createClientConfigDoc(clientConfig);
|
|
44
|
+
|
|
45
|
+
const result = await getClientConfig(clientId);
|
|
46
|
+
|
|
47
|
+
expect(result).toMatchObject({
|
|
48
|
+
clientId,
|
|
49
|
+
products: {
|
|
50
|
+
websiteTalk: {
|
|
51
|
+
logoUrl: "https://cdn.example.com/branding/acme/logo.png",
|
|
52
|
+
companyName: "Acme Ltd",
|
|
53
|
+
timezone: "Asia/Jerusalem",
|
|
54
|
+
language: "he",
|
|
55
|
+
defaultBaseUrl: "https://acme.example",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should return null for non-existent clientId", async () => {
|
|
62
|
+
const result = await getClientConfig("non-existent-client");
|
|
63
|
+
expect(result).toBeNull();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("given moked_106 with both toolsPrompts when saved and retrieved then both prompts are persisted", async () => {
|
|
67
|
+
// Given
|
|
68
|
+
const clientId = "tools-prompts-both";
|
|
69
|
+
const clientConfig = createClientConfig({
|
|
70
|
+
clientId,
|
|
71
|
+
products: {
|
|
72
|
+
municipal: {
|
|
73
|
+
cityName: "ashdod",
|
|
74
|
+
timezone: "Asia/Jerusalem",
|
|
75
|
+
moked_106: {
|
|
76
|
+
toolsPrompts: {
|
|
77
|
+
findSubjectsSystemPrompt: "Custom subjects prompt",
|
|
78
|
+
findStreetsSystemPrompt: "Custom streets prompt",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// When
|
|
86
|
+
await createClientConfigDoc(clientConfig);
|
|
87
|
+
const result = await getClientConfig(clientId);
|
|
88
|
+
|
|
89
|
+
// Then
|
|
90
|
+
expect(result?.products.municipal?.moked_106?.toolsPrompts).toMatchObject(
|
|
91
|
+
{
|
|
92
|
+
findSubjectsSystemPrompt: "Custom subjects prompt",
|
|
93
|
+
findStreetsSystemPrompt: "Custom streets prompt",
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("given moked_106 with findSubjectsSystemPrompt only when saved and retrieved then findStreetsSystemPrompt is undefined", async () => {
|
|
99
|
+
// Given
|
|
100
|
+
const clientId = "tools-prompts-subjects-only";
|
|
101
|
+
const clientConfig = createClientConfig({
|
|
102
|
+
clientId,
|
|
103
|
+
products: {
|
|
104
|
+
municipal: {
|
|
105
|
+
cityName: "ashdod",
|
|
106
|
+
timezone: "Asia/Jerusalem",
|
|
107
|
+
moked_106: {
|
|
108
|
+
toolsPrompts: {
|
|
109
|
+
findSubjectsSystemPrompt: "Subjects only prompt",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// When
|
|
117
|
+
await createClientConfigDoc(clientConfig);
|
|
118
|
+
const result = await getClientConfig(clientId);
|
|
119
|
+
|
|
120
|
+
// Then
|
|
121
|
+
expect(
|
|
122
|
+
result?.products.municipal?.moked_106?.toolsPrompts
|
|
123
|
+
?.findSubjectsSystemPrompt,
|
|
124
|
+
).toBe("Subjects only prompt");
|
|
125
|
+
expect(
|
|
126
|
+
result?.products.municipal?.moked_106?.toolsPrompts
|
|
127
|
+
?.findStreetsSystemPrompt,
|
|
128
|
+
).toBeUndefined();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("given moked_106 without toolsPrompts when saved and retrieved then toolsPrompts is undefined", async () => {
|
|
132
|
+
// Given
|
|
133
|
+
const clientId = "tools-prompts-absent";
|
|
134
|
+
const clientConfig = createClientConfig({
|
|
135
|
+
clientId,
|
|
136
|
+
products: {
|
|
137
|
+
municipal: {
|
|
138
|
+
cityName: "ashdod",
|
|
139
|
+
timezone: "Asia/Jerusalem",
|
|
140
|
+
moked_106: {
|
|
141
|
+
avoidSaveTickets: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// When
|
|
148
|
+
await createClientConfigDoc(clientConfig);
|
|
149
|
+
const result = await getClientConfig(clientId);
|
|
150
|
+
|
|
151
|
+
// Then
|
|
152
|
+
expect(
|
|
153
|
+
result?.products.municipal?.moked_106?.toolsPrompts,
|
|
154
|
+
).toBeUndefined();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should support communications config", async () => {
|
|
158
|
+
const clientId = "communications-test";
|
|
159
|
+
const clientConfig = createClientConfig({
|
|
160
|
+
clientId,
|
|
161
|
+
communications: {
|
|
162
|
+
sendGrid: {
|
|
163
|
+
emailTo: ["test@example.com"],
|
|
164
|
+
templateId: "temp-123",
|
|
165
|
+
senderId: "sender-123",
|
|
166
|
+
},
|
|
167
|
+
sms: {},
|
|
168
|
+
whatsapp: {},
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await createClientConfigDoc(clientConfig);
|
|
173
|
+
|
|
174
|
+
const result = await getClientConfig(clientId);
|
|
175
|
+
|
|
176
|
+
expect(result).toMatchObject({
|
|
177
|
+
clientId,
|
|
178
|
+
communications: {
|
|
179
|
+
sendGrid: {
|
|
180
|
+
emailTo: ["test@example.com"],
|
|
181
|
+
templateId: "temp-123",
|
|
182
|
+
senderId: "sender-123",
|
|
183
|
+
},
|
|
184
|
+
sms: {},
|
|
185
|
+
whatsapp: {},
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|