@talkpilot/core-db 1.3.8 → 1.3.9

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 (97) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/.cursor/rules/development.mdc +65 -65
  3. package/DEVELOPMENT.md +141 -141
  4. package/README.md +257 -243
  5. package/README_OLD.md +160 -160
  6. package/dist/municipal/tickets/tickets.deprecated.getters.d.ts +12 -0
  7. package/dist/municipal/tickets/tickets.deprecated.getters.d.ts.map +1 -0
  8. package/dist/municipal/tickets/tickets.deprecated.getters.js +131 -0
  9. package/dist/municipal/tickets/tickets.deprecated.getters.js.map +1 -0
  10. package/dist/municipal/tickets/tickets.statistics.dates.d.ts +7 -0
  11. package/dist/municipal/tickets/tickets.statistics.dates.d.ts.map +1 -0
  12. package/dist/municipal/tickets/tickets.statistics.dates.js +40 -0
  13. package/dist/municipal/tickets/tickets.statistics.dates.js.map +1 -0
  14. package/dist/municipal/tickets/tickets.statistics.pipeline.d.ts +53 -0
  15. package/dist/municipal/tickets/tickets.statistics.pipeline.d.ts.map +1 -0
  16. package/dist/municipal/tickets/tickets.statistics.pipeline.js +112 -0
  17. package/dist/municipal/tickets/tickets.statistics.pipeline.js.map +1 -0
  18. package/dist/municipal/tickets/tickets.statistics.utils.d.ts +7 -0
  19. package/dist/municipal/tickets/tickets.statistics.utils.d.ts.map +1 -0
  20. package/dist/municipal/tickets/tickets.statistics.utils.js +40 -0
  21. package/dist/municipal/tickets/tickets.statistics.utils.js.map +1 -0
  22. package/dist/talkpilot/calls/calls.statistics.getters.d.ts.map +1 -1
  23. package/dist/talkpilot/calls/calls.statistics.getters.js +6 -3
  24. package/dist/talkpilot/calls/calls.statistics.getters.js.map +1 -1
  25. package/dist/talkpilot/calls/calls.statistics.ticketScope.d.ts +12 -0
  26. package/dist/talkpilot/calls/calls.statistics.ticketScope.d.ts.map +1 -0
  27. package/dist/talkpilot/calls/calls.statistics.ticketScope.js +37 -0
  28. package/dist/talkpilot/calls/calls.statistics.ticketScope.js.map +1 -0
  29. package/dist/talkpilot/calls/calls.statistics.tickets.d.ts +17 -0
  30. package/dist/talkpilot/calls/calls.statistics.tickets.d.ts.map +1 -0
  31. package/dist/talkpilot/calls/calls.statistics.tickets.js +33 -0
  32. package/dist/talkpilot/calls/calls.statistics.tickets.js.map +1 -0
  33. package/dist/utils/statistics.aggregation.d.ts +20 -0
  34. package/dist/utils/statistics.aggregation.d.ts.map +1 -0
  35. package/dist/utils/statistics.aggregation.js +43 -0
  36. package/dist/utils/statistics.aggregation.js.map +1 -0
  37. package/jest.config.js +20 -20
  38. package/package.json +46 -46
  39. package/src/connection.ts +54 -54
  40. package/src/index.ts +26 -26
  41. package/src/municipal/index.ts +22 -22
  42. package/src/municipal/muniIssues/__tests__/muniIssues.setters.spec.ts +92 -92
  43. package/src/municipal/muniIssues/__tests__/muniIssues.setup.spec.ts +92 -92
  44. package/src/municipal/muniIssues/index.ts +17 -17
  45. package/src/municipal/muniIssues/muniIssues.constants.ts +18 -18
  46. package/src/municipal/muniIssues/muniIssues.getters.ts +24 -24
  47. package/src/municipal/muniIssues/muniIssues.schema.ts +66 -66
  48. package/src/municipal/muniIssues/muniIssues.setters.ts +24 -24
  49. package/src/municipal/muniIssues/muniIssues.setup.ts +65 -65
  50. package/src/municipal/muniIssues/muniIssues.types.ts +37 -37
  51. package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +30 -30
  52. package/src/municipal/tickets/__tests__/tickets.statistics.spec.ts +68 -68
  53. package/src/municipal/tickets/index.ts +3 -3
  54. package/src/municipal/tickets/tickets.constants.ts +8 -8
  55. package/src/municipal/tickets/tickets.getters.ts +121 -121
  56. package/src/municipal/tickets/tickets.statistics.aggregation.ts +96 -96
  57. package/src/municipal/tickets/tickets.statistics.getters.ts +109 -109
  58. package/src/municipal/tickets/tickets.types.ts +53 -53
  59. package/src/talkpilot/calls/__tests__/calls.dashboard.spec.ts +149 -149
  60. package/src/talkpilot/calls/__tests__/calls.statistics.spec.ts +375 -351
  61. package/src/talkpilot/calls/calls.constants.ts +20 -20
  62. package/src/talkpilot/calls/calls.statistics.getters.ts +590 -587
  63. package/src/talkpilot/calls/calls.statistics.types.ts +47 -47
  64. package/src/talkpilot/calls/calls.types.ts +119 -119
  65. package/src/talkpilot/calls/dashboard/calls.dashboard.ts +292 -292
  66. package/src/talkpilot/calls/dashboard/calls.dashboard.types.ts +57 -57
  67. package/src/talkpilot/calls/index.ts +6 -6
  68. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +190 -190
  69. package/src/talkpilot/contextNotes/__tests__/contextNotes.getters.spec.ts +176 -176
  70. package/src/talkpilot/contextNotes/contextNotes.getters.ts +86 -86
  71. package/src/talkpilot/contextNotes/contextNotes.types.ts +20 -20
  72. package/src/talkpilot/contextNotes/index.ts +2 -2
  73. package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +96 -96
  74. package/src/talkpilot/flows/flows.schema.ts +154 -154
  75. package/src/talkpilot/flows/flows.types.ts +187 -187
  76. package/src/talkpilot/index.ts +31 -31
  77. package/src/talkpilot/products/__tests__/products.getters.spec.ts +45 -45
  78. package/src/talkpilot/products/index.ts +2 -2
  79. package/src/talkpilot/products/products.getters.ts +12 -12
  80. package/src/talkpilot/products/products.types.ts +9 -9
  81. package/src/test-utils/db-utils.ts +26 -26
  82. package/src/test-utils/factories/index.ts +15 -15
  83. package/src/test-utils/factories/municipal/muniIssues.ts +32 -32
  84. package/src/test-utils/factories/talkpilot/contextNotes.ts +33 -33
  85. package/src/test-utils/factories/websitalk/scans.ts +23 -23
  86. package/src/utils/date.utils.ts +116 -116
  87. package/src/websitalk/index.ts +15 -15
  88. package/src/websitalk/mongodb-client.ts +61 -61
  89. package/src/websitalk/scans/__tests__/scans.spec.ts +218 -218
  90. package/src/websitalk/scans/index.ts +2 -2
  91. package/src/websitalk/scans/scans.getters.ts +113 -113
  92. package/src/websitalk/scans/scans.types.ts +53 -53
  93. package/tsconfig.json +23 -23
  94. package/dist/talkpilot/calls/calls.dashboard.d.ts +0 -3
  95. package/dist/talkpilot/calls/calls.dashboard.d.ts.map +0 -1
  96. package/dist/talkpilot/calls/calls.dashboard.js +0 -191
  97. package/dist/talkpilot/calls/calls.dashboard.js.map +0 -1
@@ -1,96 +1,96 @@
1
- import { CityName } from "../utils/types";
2
- import { STATS_MAX_TIME_MS, UNCLASSIFIED } from "./tickets.constants";
3
- import { getTicketsCollection } from "./tickets.getters";
4
- import type { TicketStatsDateRange } from "./tickets.types";
5
-
6
- const effectiveSubjectIdExpr = {
7
- $ifNull: [
8
- "$externalCallFields.event_subject_id",
9
- {
10
- $ifNull: [
11
- "$externalCallFields.event_sub_subject_id",
12
- "$externalCallFields.event_sub_subject_id2",
13
- ],
14
- },
15
- ],
16
- };
17
-
18
- const departmentsSubjectsLookup = (cityName: CityName) => ({
19
- $lookup: {
20
- from: "departmentsSubjects",
21
- let: { sid: "$effectiveSubjectId", c: cityName },
22
- pipeline: [
23
- {
24
- $match: {
25
- $expr: {
26
- $and: [
27
- { $eq: ["$cityName", "$$c"] },
28
- {
29
- $or: [
30
- { $eq: ["$subject_id", { $ifNull: ["$$sid", ""] }] },
31
- { $eq: ["$sub_subject_id", { $ifNull: ["$$sid", ""] }] },
32
- { $eq: ["$sub_subject_id2", { $ifNull: ["$$sid", ""] }] },
33
- ],
34
- },
35
- ],
36
- },
37
- },
38
- },
39
- { $limit: 1 },
40
- ],
41
- as: "subj",
42
- },
43
- });
44
-
45
- const subjectLabelExpr = {
46
- $cond: {
47
- if: { $gt: [{ $size: "$subj" }, 0] },
48
- then: {
49
- $ifNull: [{ $arrayElemAt: ["$subj.subjectName", 0] }, UNCLASSIFIED],
50
- },
51
- else: UNCLASSIFIED,
52
- },
53
- };
54
-
55
- const ticketDateMatch = (dateRange: TicketStatsDateRange) => ({
56
- createdAt: { $gte: dateRange.from, $lte: dateRange.to },
57
- });
58
-
59
- export const isDraftSubjectIdExpr = {
60
- $or: [
61
- { $eq: [{ $type: "$externalCallFields.event_subject_id" }, "missing"] },
62
- { $eq: ["$externalCallFields.event_subject_id", null] },
63
- {
64
- $regexMatch: {
65
- input: { $ifNull: ["$externalCallFields.event_subject_id", ""] },
66
- regex: /^\s*$/,
67
- },
68
- },
69
- ],
70
- };
71
-
72
- export const ticketsWithCallSidMatch = (
73
- cityName: CityName,
74
- dateRange: TicketStatsDateRange,
75
- ) => ({
76
- cityName,
77
- callSid: { $exists: true, $nin: [null, ""] },
78
- ...ticketDateMatch(dateRange),
79
- });
80
-
81
- export const subjectResolutionStages = (
82
- cityName: CityName,
83
- ): Record<string, unknown>[] => [
84
- { $addFields: { effectiveSubjectId: effectiveSubjectIdExpr } },
85
- departmentsSubjectsLookup(cityName),
86
- { $addFields: { subject: subjectLabelExpr } },
87
- ];
88
-
89
- export const runTicketStatsAggregate = async <T>(
90
- pipeline: Record<string, unknown>[],
91
- ): Promise<T[]> => {
92
- const rows = await getTicketsCollection()
93
- .aggregate(pipeline, { maxTimeMS: STATS_MAX_TIME_MS })
94
- .toArray();
95
- return rows as T[];
96
- };
1
+ import { CityName } from "../utils/types";
2
+ import { STATS_MAX_TIME_MS, UNCLASSIFIED } from "./tickets.constants";
3
+ import { getTicketsCollection } from "./tickets.getters";
4
+ import type { TicketStatsDateRange } from "./tickets.types";
5
+
6
+ const effectiveSubjectIdExpr = {
7
+ $ifNull: [
8
+ "$externalCallFields.event_subject_id",
9
+ {
10
+ $ifNull: [
11
+ "$externalCallFields.event_sub_subject_id",
12
+ "$externalCallFields.event_sub_subject_id2",
13
+ ],
14
+ },
15
+ ],
16
+ };
17
+
18
+ const departmentsSubjectsLookup = (cityName: CityName) => ({
19
+ $lookup: {
20
+ from: "departmentsSubjects",
21
+ let: { sid: "$effectiveSubjectId", c: cityName },
22
+ pipeline: [
23
+ {
24
+ $match: {
25
+ $expr: {
26
+ $and: [
27
+ { $eq: ["$cityName", "$$c"] },
28
+ {
29
+ $or: [
30
+ { $eq: ["$subject_id", { $ifNull: ["$$sid", ""] }] },
31
+ { $eq: ["$sub_subject_id", { $ifNull: ["$$sid", ""] }] },
32
+ { $eq: ["$sub_subject_id2", { $ifNull: ["$$sid", ""] }] },
33
+ ],
34
+ },
35
+ ],
36
+ },
37
+ },
38
+ },
39
+ { $limit: 1 },
40
+ ],
41
+ as: "subj",
42
+ },
43
+ });
44
+
45
+ const subjectLabelExpr = {
46
+ $cond: {
47
+ if: { $gt: [{ $size: "$subj" }, 0] },
48
+ then: {
49
+ $ifNull: [{ $arrayElemAt: ["$subj.subjectName", 0] }, UNCLASSIFIED],
50
+ },
51
+ else: UNCLASSIFIED,
52
+ },
53
+ };
54
+
55
+ const ticketDateMatch = (dateRange: TicketStatsDateRange) => ({
56
+ createdAt: { $gte: dateRange.from, $lte: dateRange.to },
57
+ });
58
+
59
+ export const isDraftSubjectIdExpr = {
60
+ $or: [
61
+ { $eq: [{ $type: "$externalCallFields.event_subject_id" }, "missing"] },
62
+ { $eq: ["$externalCallFields.event_subject_id", null] },
63
+ {
64
+ $regexMatch: {
65
+ input: { $ifNull: ["$externalCallFields.event_subject_id", ""] },
66
+ regex: /^\s*$/,
67
+ },
68
+ },
69
+ ],
70
+ };
71
+
72
+ export const ticketsWithCallSidMatch = (
73
+ cityName: CityName,
74
+ dateRange: TicketStatsDateRange,
75
+ ) => ({
76
+ cityName,
77
+ callSid: { $exists: true, $nin: [null, ""] },
78
+ ...ticketDateMatch(dateRange),
79
+ });
80
+
81
+ export const subjectResolutionStages = (
82
+ cityName: CityName,
83
+ ): Record<string, unknown>[] => [
84
+ { $addFields: { effectiveSubjectId: effectiveSubjectIdExpr } },
85
+ departmentsSubjectsLookup(cityName),
86
+ { $addFields: { subject: subjectLabelExpr } },
87
+ ];
88
+
89
+ export const runTicketStatsAggregate = async <T>(
90
+ pipeline: Record<string, unknown>[],
91
+ ): Promise<T[]> => {
92
+ const rows = await getTicketsCollection()
93
+ .aggregate(pipeline, { maxTimeMS: STATS_MAX_TIME_MS })
94
+ .toArray();
95
+ return rows as T[];
96
+ };
@@ -1,109 +1,109 @@
1
- import { CityName } from "../utils/types";
2
- import {
3
- DAY_MS,
4
- endOfCalendarDayInTz,
5
- startOfCalendarDayInTz,
6
- } from "../../utils/date.utils";
7
- import { DEFAULT_LOOKBACK_DAYS } from "./tickets.constants";
8
- import {
9
- isDraftSubjectIdExpr,
10
- runTicketStatsAggregate,
11
- subjectResolutionStages,
12
- ticketsWithCallSidMatch,
13
- } from "./tickets.statistics.aggregation";
14
- import type {
15
- TicketStatsDateRange,
16
- TicketStatsDateScope,
17
- TicketSubjectRow,
18
- } from "./tickets.types";
19
-
20
- export const resolveTicketStatsDateRange = (
21
- dateScope?: TicketStatsDateScope,
22
- ): TicketStatsDateRange => {
23
- const to = dateScope?.to ?? new Date();
24
- const from =
25
- dateScope?.from ?? new Date(to.getTime() - DEFAULT_LOOKBACK_DAYS * DAY_MS);
26
- return { from, to };
27
- };
28
-
29
- export const ticketStatsDateScopeFromYmd = (
30
- startStr: string,
31
- endStr: string,
32
- timezone: string,
33
- ): TicketStatsDateScope => ({
34
- from: startOfCalendarDayInTz(startStr, timezone),
35
- to: endOfCalendarDayInTz(endStr, timezone),
36
- });
37
-
38
- /** @deprecated Use findCallSidTicketCountsByCity instead. */
39
- export const findCallSidsWithTicketsByCity = async (
40
- cityName: CityName,
41
- dateScope?: TicketStatsDateScope,
42
- ): Promise<string[]> => {
43
- const rows = await runTicketStatsAggregate<{ _id: unknown }>([
44
- { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
45
- { $group: { _id: "$callSid" } },
46
- ]);
47
- return rows
48
- .filter((r) => r._id != null && r._id !== "")
49
- .map((r) => String(r._id));
50
- };
51
-
52
- export const findCallSidTicketCountsByCity = async (
53
- cityName: CityName,
54
- dateScope?: TicketStatsDateScope,
55
- ): Promise<Map<string, number>> => {
56
- const rows = await runTicketStatsAggregate<{ _id: unknown; ticketCount: number }>([
57
- { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
58
- { $group: { _id: "$callSid", ticketCount: { $sum: 1 } } },
59
- ]);
60
- return new Map(
61
- rows
62
- .filter((r) => r._id != null && r._id !== "")
63
- .map((r) => [String(r._id), r.ticketCount])
64
- );
65
- };
66
-
67
-
68
- /** @deprecated Use findCallSidDraftTicketCountsByCity instead. */
69
- export const findCallSidsWithDraftTicketsByCity = async (
70
- cityName: CityName,
71
- dateScope?: TicketStatsDateScope,
72
- ): Promise<string[]> => {
73
- const rows = await runTicketStatsAggregate<{ _id: unknown }>([
74
- { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
75
- { $match: { $expr: isDraftSubjectIdExpr } },
76
- { $group: { _id: "$callSid" } },
77
- ]);
78
- return rows
79
- .filter((r) => r._id != null && r._id !== "")
80
- .map((r) => String(r._id));
81
- };
82
-
83
- export const findCallSidDraftTicketCountsByCity = async (
84
- cityName: CityName,
85
- dateScope?: TicketStatsDateScope,
86
- ): Promise<Map<string, number>> => {
87
- const rows = await runTicketStatsAggregate<{ _id: unknown; ticketCount: number }>([
88
- { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
89
- { $match: { $expr: isDraftSubjectIdExpr } },
90
- { $group: { _id: "$callSid", ticketCount: { $sum: 1 } } },
91
- ]);
92
- return new Map(
93
- rows
94
- .filter((r) => r._id != null && r._id !== "")
95
- .map((r) => [String(r._id), r.ticketCount])
96
- );
97
- };
98
-
99
- export const findTicketSubjectRows = async (
100
- cityName: CityName,
101
- dateScope?: TicketStatsDateScope,
102
- ): Promise<TicketSubjectRow[]> => {
103
- const rows = await runTicketStatsAggregate<{ callSid: unknown; subject: unknown }>([
104
- { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
105
- ...subjectResolutionStages(cityName),
106
- { $project: { _id: 0, callSid: 1, subject: 1 } },
107
- ]);
108
- return rows.map((r) => ({ callSid: String(r.callSid), subject: String(r.subject) }));
109
- };
1
+ import { CityName } from "../utils/types";
2
+ import {
3
+ DAY_MS,
4
+ endOfCalendarDayInTz,
5
+ startOfCalendarDayInTz,
6
+ } from "../../utils/date.utils";
7
+ import { DEFAULT_LOOKBACK_DAYS } from "./tickets.constants";
8
+ import {
9
+ isDraftSubjectIdExpr,
10
+ runTicketStatsAggregate,
11
+ subjectResolutionStages,
12
+ ticketsWithCallSidMatch,
13
+ } from "./tickets.statistics.aggregation";
14
+ import type {
15
+ TicketStatsDateRange,
16
+ TicketStatsDateScope,
17
+ TicketSubjectRow,
18
+ } from "./tickets.types";
19
+
20
+ export const resolveTicketStatsDateRange = (
21
+ dateScope?: TicketStatsDateScope,
22
+ ): TicketStatsDateRange => {
23
+ const to = dateScope?.to ?? new Date();
24
+ const from =
25
+ dateScope?.from ?? new Date(to.getTime() - DEFAULT_LOOKBACK_DAYS * DAY_MS);
26
+ return { from, to };
27
+ };
28
+
29
+ export const ticketStatsDateScopeFromYmd = (
30
+ startStr: string,
31
+ endStr: string,
32
+ timezone: string,
33
+ ): TicketStatsDateScope => ({
34
+ from: startOfCalendarDayInTz(startStr, timezone),
35
+ to: endOfCalendarDayInTz(endStr, timezone),
36
+ });
37
+
38
+ /** @deprecated Use findCallSidTicketCountsByCity instead. */
39
+ export const findCallSidsWithTicketsByCity = async (
40
+ cityName: CityName,
41
+ dateScope?: TicketStatsDateScope,
42
+ ): Promise<string[]> => {
43
+ const rows = await runTicketStatsAggregate<{ _id: unknown }>([
44
+ { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
45
+ { $group: { _id: "$callSid" } },
46
+ ]);
47
+ return rows
48
+ .filter((r) => r._id != null && r._id !== "")
49
+ .map((r) => String(r._id));
50
+ };
51
+
52
+ export const findCallSidTicketCountsByCity = async (
53
+ cityName: CityName,
54
+ dateScope?: TicketStatsDateScope,
55
+ ): Promise<Map<string, number>> => {
56
+ const rows = await runTicketStatsAggregate<{ _id: unknown; ticketCount: number }>([
57
+ { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
58
+ { $group: { _id: "$callSid", ticketCount: { $sum: 1 } } },
59
+ ]);
60
+ return new Map(
61
+ rows
62
+ .filter((r) => r._id != null && r._id !== "")
63
+ .map((r) => [String(r._id), r.ticketCount])
64
+ );
65
+ };
66
+
67
+
68
+ /** @deprecated Use findCallSidDraftTicketCountsByCity instead. */
69
+ export const findCallSidsWithDraftTicketsByCity = async (
70
+ cityName: CityName,
71
+ dateScope?: TicketStatsDateScope,
72
+ ): Promise<string[]> => {
73
+ const rows = await runTicketStatsAggregate<{ _id: unknown }>([
74
+ { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
75
+ { $match: { $expr: isDraftSubjectIdExpr } },
76
+ { $group: { _id: "$callSid" } },
77
+ ]);
78
+ return rows
79
+ .filter((r) => r._id != null && r._id !== "")
80
+ .map((r) => String(r._id));
81
+ };
82
+
83
+ export const findCallSidDraftTicketCountsByCity = async (
84
+ cityName: CityName,
85
+ dateScope?: TicketStatsDateScope,
86
+ ): Promise<Map<string, number>> => {
87
+ const rows = await runTicketStatsAggregate<{ _id: unknown; ticketCount: number }>([
88
+ { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
89
+ { $match: { $expr: isDraftSubjectIdExpr } },
90
+ { $group: { _id: "$callSid", ticketCount: { $sum: 1 } } },
91
+ ]);
92
+ return new Map(
93
+ rows
94
+ .filter((r) => r._id != null && r._id !== "")
95
+ .map((r) => [String(r._id), r.ticketCount])
96
+ );
97
+ };
98
+
99
+ export const findTicketSubjectRows = async (
100
+ cityName: CityName,
101
+ dateScope?: TicketStatsDateScope,
102
+ ): Promise<TicketSubjectRow[]> => {
103
+ const rows = await runTicketStatsAggregate<{ callSid: unknown; subject: unknown }>([
104
+ { $match: ticketsWithCallSidMatch(cityName, resolveTicketStatsDateRange(dateScope)) },
105
+ ...subjectResolutionStages(cityName),
106
+ { $project: { _id: 0, callSid: 1, subject: 1 } },
107
+ ]);
108
+ return rows.map((r) => ({ callSid: String(r.callSid), subject: String(r.subject) }));
109
+ };
@@ -1,53 +1,53 @@
1
- import { ObjectId, WithId } from "mongodb";
2
-
3
- import { CityName } from "../utils/types";
4
-
5
- export type Ticket = {
6
- _id: ObjectId;
7
- createdAt: Date;
8
- updatedAt: Date;
9
- callSid?: string;
10
- cityName: CityName;
11
- externalCallFields: {
12
- first_name?: string;
13
- last_name?: string;
14
- event_description?: string;
15
- street?: string;
16
- house_number?: string;
17
- event_subject_id?: string;
18
- event_sub_subject_id?: string;
19
- event_sub_subject_id2?: string | null;
20
- call_number?: string;
21
- status?: number;
22
- error?: string;
23
- image1?: string;
24
- image2?: string;
25
- image3?: string;
26
- file1?: string;
27
- file2?: string;
28
- file3?: string;
29
- };
30
- guestJwt?: string;
31
- };
32
-
33
- export type TicketDoc = WithId<Ticket>;
34
-
35
- export type SubjectItem = {
36
- subject: string;
37
- count: number;
38
- };
39
-
40
- export type TicketSubjectRow = {
41
- callSid: string;
42
- subject: string;
43
- };
44
-
45
- export type TicketStatsDateScope = {
46
- from?: Date;
47
- to?: Date;
48
- };
49
-
50
- export type TicketStatsDateRange = {
51
- from: Date;
52
- to: Date;
53
- };
1
+ import { ObjectId, WithId } from "mongodb";
2
+
3
+ import { CityName } from "../utils/types";
4
+
5
+ export type Ticket = {
6
+ _id: ObjectId;
7
+ createdAt: Date;
8
+ updatedAt: Date;
9
+ callSid?: string;
10
+ cityName: CityName;
11
+ externalCallFields: {
12
+ first_name?: string;
13
+ last_name?: string;
14
+ event_description?: string;
15
+ street?: string;
16
+ house_number?: string;
17
+ event_subject_id?: string;
18
+ event_sub_subject_id?: string;
19
+ event_sub_subject_id2?: string | null;
20
+ call_number?: string;
21
+ status?: number;
22
+ error?: string;
23
+ image1?: string;
24
+ image2?: string;
25
+ image3?: string;
26
+ file1?: string;
27
+ file2?: string;
28
+ file3?: string;
29
+ };
30
+ guestJwt?: string;
31
+ };
32
+
33
+ export type TicketDoc = WithId<Ticket>;
34
+
35
+ export type SubjectItem = {
36
+ subject: string;
37
+ count: number;
38
+ };
39
+
40
+ export type TicketSubjectRow = {
41
+ callSid: string;
42
+ subject: string;
43
+ };
44
+
45
+ export type TicketStatsDateScope = {
46
+ from?: Date;
47
+ to?: Date;
48
+ };
49
+
50
+ export type TicketStatsDateRange = {
51
+ from: Date;
52
+ to: Date;
53
+ };