@talkpilot/core-db 1.3.21 → 1.3.22
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 +494 -500
- package/dist/talkpilot/calls/calls.constants.d.ts +0 -2
- package/dist/talkpilot/calls/calls.constants.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.constants.js +1 -3
- package/dist/talkpilot/calls/calls.constants.js.map +1 -1
- package/dist/talkpilot/calls/calls.getters.d.ts +0 -3
- package/dist/talkpilot/calls/calls.getters.d.ts.map +1 -1
- package/dist/talkpilot/calls/calls.getters.js +1 -12
- package/dist/talkpilot/calls/calls.getters.js.map +1 -1
- package/dist/talkpilot/calls/calls.types.d.ts +1 -10
- package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
- package/dist/websitalk/websiteUrls/websiteUrls.context.d.ts +11 -0
- package/dist/websitalk/websiteUrls/websiteUrls.context.d.ts.map +1 -0
- package/dist/websitalk/websiteUrls/websiteUrls.context.js +35 -0
- package/dist/websitalk/websiteUrls/websiteUrls.context.js.map +1 -0
- package/dist/websitalk/websiteUrls/websiteUrls.setters.d.ts +7 -0
- package/dist/websitalk/websiteUrls/websiteUrls.setters.d.ts.map +1 -0
- package/dist/websitalk/websiteUrls/websiteUrls.setters.js +29 -0
- package/dist/websitalk/websiteUrls/websiteUrls.setters.js.map +1 -0
- package/jest.config.js +20 -20
- package/package.json +46 -46
- package/src/__tests__/setup.ts +20 -20
- package/src/connection.ts +54 -54
- package/src/index.ts +27 -27
- package/src/municipal/__tests__/validation.spec.ts +62 -62
- package/src/municipal/cities/cities.getters.ts +50 -50
- package/src/municipal/cities/cities.types.ts +11 -11
- package/src/municipal/cities/index.ts +2 -2
- package/src/municipal/departmentsSubjects/departmentsSubjects.getters.ts +282 -282
- package/src/municipal/departmentsSubjects/departmentsSubjects.types.ts +72 -72
- package/src/municipal/departmentsSubjects/index.ts +9 -9
- package/src/municipal/index.ts +22 -22
- package/src/municipal/mongodb-client.ts +61 -61
- package/src/municipal/muniIssues/__tests__/muniIssues.setters.spec.ts +94 -94
- 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/streets/index.ts +2 -2
- package/src/municipal/streets/streets.getters.ts +125 -125
- package/src/municipal/streets/streets.types.ts +18 -18
- package/src/municipal/systemInstructions/__tests__/getters.spec.ts +113 -113
- package/src/municipal/systemInstructions/__tests__/setters.spec.ts +274 -274
- package/src/municipal/systemInstructions/index.ts +7 -7
- package/src/municipal/systemInstructions/instructions.getters.ts +57 -57
- package/src/municipal/systemInstructions/instructions.setters.ts +119 -119
- package/src/municipal/systemInstructions/instructions.types.ts +30 -30
- package/src/municipal/tickets/__tests__/tickets.getters.spec.ts +30 -30
- package/src/municipal/tickets/__tests__/tickets.statistics.spec.ts +99 -99
- package/src/municipal/tickets/index.ts +9 -9
- 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 -110
- package/src/municipal/tickets/tickets.statistics.getters.ts +145 -145
- package/src/municipal/tickets/tickets.types.ts +54 -54
- package/src/municipal/utils/types.ts +11 -11
- package/src/talkpilot/__tests__/db.spec.ts +38 -38
- package/src/talkpilot/__tests__/mongodb-client.spec.ts +18 -18
- package/src/talkpilot/__tests__/validation.spec.ts +68 -68
- package/src/talkpilot/agents/__tests__/agents.getters.spec.ts +29 -29
- package/src/talkpilot/agents/agents.getters.ts +34 -34
- package/src/talkpilot/agents/agents.types.ts +14 -14
- package/src/talkpilot/agents/index.ts +2 -2
- package/src/talkpilot/backgroundToolResults/__tests__/backgroundToolResults.getters.spec.ts +147 -147
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.getters.ts +65 -65
- package/src/talkpilot/backgroundToolResults/backgroundToolResults.types.ts +23 -23
- package/src/talkpilot/backgroundToolResults/index.ts +2 -2
- package/src/talkpilot/calls/__tests__/callStats.utils.spec.ts +128 -128
- package/src/talkpilot/calls/__tests__/calls.dashboard.spec.ts +229 -229
- package/src/talkpilot/calls/__tests__/calls.spec.ts +283 -471
- package/src/talkpilot/calls/__tests__/calls.statistics.spec.ts +483 -483
- package/src/talkpilot/calls/calls.constants.ts +32 -35
- package/src/talkpilot/calls/calls.getters.ts +258 -277
- package/src/talkpilot/calls/calls.statistics.getters.ts +668 -668
- package/src/talkpilot/calls/calls.statistics.types.ts +48 -48
- package/src/talkpilot/calls/calls.types.ts +130 -141
- package/src/talkpilot/calls/dashboard/calls.dashboard.ts +295 -295
- package/src/talkpilot/calls/dashboard/calls.dashboard.types.ts +57 -57
- package/src/talkpilot/calls/index.ts +6 -6
- package/src/talkpilot/clientAudioBuffers/__tests__/clientAudioBuffer.getters.spec.ts +160 -160
- package/src/talkpilot/clientAudioBuffers/clientAudioBuffer.getters.ts +117 -117
- package/src/talkpilot/clientAudioBuffers/clientsAudioBuffers.types.ts +25 -25
- package/src/talkpilot/clientAudioBuffers/index.ts +2 -2
- package/src/talkpilot/clients/clients.getters.ts +16 -16
- package/src/talkpilot/clients/clients.types.ts +14 -14
- package/src/talkpilot/clients/index.ts +2 -2
- package/src/talkpilot/clientsConfig/__tests__/clientsConfig.getters.spec.ts +105 -105
- package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +186 -186
- package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +79 -79
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +127 -127
- package/src/talkpilot/clientsConfig/index.ts +2 -2
- package/src/talkpilot/contextNotes/__tests__/contextNotes.getters.spec.ts +217 -217
- package/src/talkpilot/contextNotes/contextNotes.getters.ts +85 -85
- 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 +99 -99
- package/src/talkpilot/flows/flows.getter.ts +14 -14
- package/src/talkpilot/flows/flows.schema.ts +155 -155
- package/src/talkpilot/flows/flows.types.ts +189 -189
- package/src/talkpilot/flows/index.ts +2 -2
- package/src/talkpilot/groups/__tests__/groups.spec.ts +90 -90
- package/src/talkpilot/groups/__tests__/phone.utils.spec.ts +32 -32
- package/src/talkpilot/groups/groups.getters.ts +30 -30
- package/src/talkpilot/groups/groups.types.ts +29 -29
- package/src/talkpilot/groups/index.ts +3 -3
- package/src/talkpilot/groups/phone.utils.ts +46 -46
- package/src/talkpilot/index.ts +31 -31
- package/src/talkpilot/leads/index.ts +2 -2
- package/src/talkpilot/leads/leads.getter.ts +6 -6
- package/src/talkpilot/leads/leads.schema.ts +33 -33
- package/src/talkpilot/leads/leads.types.ts +20 -20
- package/src/talkpilot/mongodb-client.ts +78 -78
- package/src/talkpilot/phone_numbers/__tests__/phone_numbers.spec.ts +252 -252
- package/src/talkpilot/phone_numbers/index.ts +2 -2
- package/src/talkpilot/phone_numbers/phone_numbers.getter.ts +171 -171
- package/src/talkpilot/phone_numbers/phone_numbers.schema.ts +17 -17
- package/src/talkpilot/phone_numbers/phone_numbers.types.ts +30 -30
- package/src/talkpilot/plans/__tests__/plans.spec.ts +70 -70
- package/src/talkpilot/plans/index.ts +2 -2
- package/src/talkpilot/plans/plans.getters.ts +132 -132
- package/src/talkpilot/plans/plans.types.ts +89 -89
- package/src/talkpilot/products/__tests__/products.getters.spec.ts +44 -44
- 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/talkpilot/results/index.ts +7 -7
- package/src/talkpilot/results/results.getter.ts +39 -39
- package/src/talkpilot/results/results.schema.ts +25 -25
- package/src/talkpilot/results/results.types.ts +34 -34
- package/src/talkpilot/retry_analyze/__tests__/retryAnalyze.getters.spec.ts +156 -156
- package/src/talkpilot/retry_analyze/index.ts +2 -2
- package/src/talkpilot/retry_analyze/retryAnalyze.getters.ts +84 -84
- package/src/talkpilot/retry_analyze/retryAnalyze.types.ts +13 -13
- package/src/talkpilot/sessions/__tests__/sessions.spec.ts +147 -147
- package/src/talkpilot/sessions/index.ts +2 -2
- package/src/talkpilot/sessions/sessions.getter.ts +92 -92
- package/src/talkpilot/sessions/sessions.schema.ts +34 -34
- package/src/talkpilot/sessions/sessions.types.ts +30 -30
- package/src/talkpilot/subscriptions/__tests__/subscriptions.getters.utils.spec.ts +45 -45
- package/src/talkpilot/subscriptions/index.ts +3 -3
- package/src/talkpilot/subscriptions/subscriptions.getters.ts +146 -146
- package/src/talkpilot/subscriptions/subscriptions.getters.utils.ts +33 -33
- package/src/talkpilot/subscriptions/subscriptions.types.ts +66 -66
- package/src/talkpilot/utils/__tests__/query.utils.spec.ts +49 -49
- package/src/talkpilot/utils/query.utils.ts +21 -21
- package/src/test-utils/db-utils.ts +26 -26
- package/src/test-utils/factories/index.ts +16 -16
- package/src/test-utils/factories/municipal/cities.ts +16 -16
- package/src/test-utils/factories/municipal/departmentsSubjects.ts +37 -37
- package/src/test-utils/factories/municipal/muniIssues.ts +32 -32
- package/src/test-utils/factories/municipal/streets.ts +22 -22
- package/src/test-utils/factories/municipal/tickets.ts +39 -39
- package/src/test-utils/factories/talkpilot/agents.ts +19 -19
- package/src/test-utils/factories/talkpilot/calls.ts +37 -37
- package/src/test-utils/factories/talkpilot/clientAudioBuffers.ts +20 -20
- package/src/test-utils/factories/talkpilot/clientsConfig.ts +18 -18
- package/src/test-utils/factories/talkpilot/contextNotes.ts +40 -40
- package/src/test-utils/factories/talkpilot/flows.ts +33 -33
- package/src/test-utils/factories/talkpilot/groups.ts +33 -33
- package/src/test-utils/factories/talkpilot/phone_numbers.ts +22 -22
- package/src/test-utils/factories/talkpilot/sessions.ts +35 -35
- package/src/test-utils/factories/websitalk/scans.ts +24 -24
- package/src/test-utils/factories/websitalk/websiteUrls.ts +17 -17
- package/src/utils/date.utils.ts +126 -126
- package/src/utils/shared.types.ts +4 -4
- package/src/utils/validation.ts +23 -23
- package/src/websitalk/index.ts +16 -16
- package/src/websitalk/mongodb-client.ts +61 -61
- package/src/websitalk/scans/__tests__/scans.spec.ts +313 -313
- package/src/websitalk/scans/index.ts +4 -4
- package/src/websitalk/scans/scans.constants.ts +15 -15
- package/src/websitalk/scans/scans.getters.ts +160 -160
- package/src/websitalk/scans/scans.types.ts +45 -45
- package/src/websitalk/scans/scans.utils.ts +5 -5
- package/src/websitalk/websiteUrls/__tests__/websiteUrls.spec.ts +77 -77
- package/src/websitalk/websiteUrls/index.ts +2 -2
- package/src/websitalk/websiteUrls/websiteUrls.getters.ts +65 -65
- package/src/websitalk/websiteUrls/websiteUrls.types.ts +13 -13
- package/tsconfig.json +23 -23
- package/.claude/settings.local.json +0 -13
- package/dist/talkpilot/leads/leads.setter.d.ts +0 -4
- package/dist/talkpilot/leads/leads.setter.d.ts.map +0 -1
- package/dist/talkpilot/leads/leads.setter.js +0 -16
- package/dist/talkpilot/leads/leads.setter.js.map +0 -1
|
@@ -18,6 +18,4 @@ export declare const STATS_MAX_TIME_MS = 30000;
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const TREND_MONTH_BUCKET_MIN_MONTHS = 6;
|
|
20
20
|
export declare const TREND_WEEK_BUCKET_MIN_MONTHS = 3;
|
|
21
|
-
export declare const TOOL_EXECUTIONS_DEFAULT_SKIP = 0;
|
|
22
|
-
export declare const TOOL_EXECUTIONS_DEFAULT_LIMIT = 50;
|
|
23
21
|
//# sourceMappingURL=calls.constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calls.constants.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.constants.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,EAAG,UAAmB,CAAC;AAE5D,gDAAgD;AAChD,eAAO,MAAM,0BAA0B,EAAG,YAAqB,CAAC;AAEhE,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,sCAAuC,CAAC;AAErE,4EAA4E;AAC5E,eAAO,MAAM,cAAc,mEAMjB,CAAC;AAEX,6BAA6B;AAC7B,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,4BAA4B,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"calls.constants.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.constants.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,EAAG,UAAmB,CAAC;AAE5D,gDAAgD;AAChD,eAAO,MAAM,0BAA0B,EAAG,YAAqB,CAAC;AAEhE,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,sCAAuC,CAAC;AAErE,4EAA4E;AAC5E,eAAO,MAAM,cAAc,mEAMjB,CAAC;AAEX,6BAA6B;AAC7B,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TREND_WEEK_BUCKET_MIN_MONTHS = exports.TREND_MONTH_BUCKET_MIN_MONTHS = exports.STATS_MAX_TIME_MS = exports.HOURS_PER_DAY = exports.FINAL_STATUSES = exports.IN_CALL_STATUSES = exports.CONFERENCE_ROLE_SUPERVISOR = exports.CONFERENCE_ROLE_CUSTOMER = void 0;
|
|
4
4
|
/** Customer role within a conference call. */
|
|
5
5
|
exports.CONFERENCE_ROLE_CUSTOMER = "customer";
|
|
6
6
|
/** Supervisor role within a conference call. */
|
|
@@ -27,6 +27,4 @@ exports.STATS_MAX_TIME_MS = 30_000;
|
|
|
27
27
|
*/
|
|
28
28
|
exports.TREND_MONTH_BUCKET_MIN_MONTHS = 6;
|
|
29
29
|
exports.TREND_WEEK_BUCKET_MIN_MONTHS = 3;
|
|
30
|
-
exports.TOOL_EXECUTIONS_DEFAULT_SKIP = 0;
|
|
31
|
-
exports.TOOL_EXECUTIONS_DEFAULT_LIMIT = 50;
|
|
32
30
|
//# sourceMappingURL=calls.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calls.constants.js","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.constants.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AACjC,QAAA,wBAAwB,GAAG,UAAmB,CAAC;AAE5D,gDAAgD;AACnC,QAAA,0BAA0B,GAAG,YAAqB,CAAC;AAEhE,wEAAwE;AAC3D,QAAA,gBAAgB,GAAG,CAAC,aAAa,EAAE,UAAU,CAAU,CAAC;AAErE,4EAA4E;AAC/D,QAAA,cAAc,GAAG;IAC5B,WAAW;IACX,WAAW;IACX,MAAM;IACN,QAAQ;IACR,UAAU;CACF,CAAC;AAEX,6BAA6B;AAChB,QAAA,aAAa,GAAG,EAAE,CAAC;AAEhC,iEAAiE;AACpD,QAAA,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;;GAKG;AACU,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAClC,QAAA,4BAA4B,GAAG,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"calls.constants.js","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.constants.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AACjC,QAAA,wBAAwB,GAAG,UAAmB,CAAC;AAE5D,gDAAgD;AACnC,QAAA,0BAA0B,GAAG,YAAqB,CAAC;AAEhE,wEAAwE;AAC3D,QAAA,gBAAgB,GAAG,CAAC,aAAa,EAAE,UAAU,CAAU,CAAC;AAErE,4EAA4E;AAC/D,QAAA,cAAc,GAAG;IAC5B,WAAW;IACX,WAAW;IACX,MAAM;IACN,QAAQ;IACR,UAAU;CACF,CAAC;AAEX,6BAA6B;AAChB,QAAA,aAAa,GAAG,EAAE,CAAC;AAEhC,iEAAiE;AACpD,QAAA,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;;GAKG;AACU,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAClC,QAAA,4BAA4B,GAAG,CAAC,CAAC"}
|
|
@@ -9,9 +9,6 @@ export declare const getCallsByClient: (clientId: string) => Promise<import("mon
|
|
|
9
9
|
export declare const getCallsByFlow: (flowId: ObjectId) => Promise<import("mongodb").WithId<Call>[]>;
|
|
10
10
|
export declare const createCallDoc: (call: Omit<Call, "createdAt" | "updatedAt" | "env">) => Promise<import("mongodb").InsertOneResult<Call>>;
|
|
11
11
|
export declare const updateCallByCallSid: (callSid: string, updates: CallUpdateParams) => Promise<CallDoc | null>;
|
|
12
|
-
export declare const getToolExecutionsByCallSid: (callSid: string, opts?: Pick<CallQueryOptions, "skip" | "limit"> & {
|
|
13
|
-
clientId?: string;
|
|
14
|
-
}) => Promise<ToolExecution[]>;
|
|
15
12
|
export declare const updateCallStatusByCallSid: (callSid: string, status: CallStatus) => Promise<CallDoc | null>;
|
|
16
13
|
export declare const pushToolExecution: (callSid: string, execution: ToolExecution) => Promise<void>;
|
|
17
14
|
export declare const getCallsByClientAndDateRange: (clientId: string, startDate: Date, endDate: Date) => Promise<import("mongodb").WithId<Call>[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calls.getters.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/calls/cal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C"}
|
|
@@ -33,14 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.range = exports.countCalls = exports.findCallsByQuery = exports.getCallsByClientAndDateRange = exports.pushToolExecution = exports.updateCallStatusByCallSid = exports.
|
|
36
|
+
exports.range = exports.countCalls = exports.findCallsByQuery = exports.getCallsByClientAndDateRange = exports.pushToolExecution = exports.updateCallStatusByCallSid = exports.updateCallByCallSid = exports.createCallDoc = exports.getCallsByFlow = exports.getCallsByClient = exports.getCallsByPhoneNumber = exports.getCallByCallSid = exports.getCallsCollection = void 0;
|
|
37
37
|
exports.countCallsByPhoneInRange = countCallsByPhoneInRange;
|
|
38
38
|
exports.startOfDay = startOfDay;
|
|
39
39
|
exports.addDays = addDays;
|
|
40
40
|
exports.getCallsStatsForDateRange = getCallsStatsForDateRange;
|
|
41
41
|
exports.getCallsHourlyAggregation = getCallsHourlyAggregation;
|
|
42
42
|
const index_1 = require("../index");
|
|
43
|
-
const calls_constants_1 = require("./calls.constants");
|
|
44
43
|
const process = __importStar(require("node:process"));
|
|
45
44
|
const query_utils_1 = require("../utils/query.utils");
|
|
46
45
|
const getCallsCollection = () => {
|
|
@@ -83,16 +82,6 @@ const updateCallByCallSid = async (callSid, updates) => {
|
|
|
83
82
|
}, { returnDocument: "after" });
|
|
84
83
|
};
|
|
85
84
|
exports.updateCallByCallSid = updateCallByCallSid;
|
|
86
|
-
const getToolExecutionsByCallSid = async (callSid, opts) => {
|
|
87
|
-
const skip = Math.max(0, opts?.skip ?? calls_constants_1.TOOL_EXECUTIONS_DEFAULT_SKIP);
|
|
88
|
-
const limit = Math.max(1, opts?.limit ?? calls_constants_1.TOOL_EXECUTIONS_DEFAULT_LIMIT);
|
|
89
|
-
const filter = { callSid };
|
|
90
|
-
if (opts?.clientId != null)
|
|
91
|
-
filter.clientId = opts.clientId;
|
|
92
|
-
const call = await (0, exports.getCallsCollection)().findOne(filter, { projection: { toolExecutions: { $slice: [skip, limit] } } });
|
|
93
|
-
return call?.toolExecutions ?? [];
|
|
94
|
-
};
|
|
95
|
-
exports.getToolExecutionsByCallSid = getToolExecutionsByCallSid;
|
|
96
85
|
const updateCallStatusByCallSid = async (callSid, status) => (0, exports.getCallsCollection)().findOneAndUpdate({ callSid }, { $set: { status, updatedAt: new Date() } }, { returnDocument: "after" });
|
|
97
86
|
exports.updateCallStatusByCallSid = updateCallStatusByCallSid;
|
|
98
87
|
const pushToolExecution = async (callSid, execution) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calls.getters.js","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.getters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"calls.getters.js","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.getters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgHA,4DAwBC;AAqBD,gCAIC;AAED,0BAIC;AAMD,8DAgDC;AAKD,8DA+BC;AAjQD,oCAMkB;AAGlB,sDAAwC;AACxC,sDAAyD;AAGlD,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAO,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEK,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;IAClD,OAAO,IAAA,0BAAkB,GAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEK,MAAM,qBAAqB,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC3D,OAAO,IAAA,0BAAkB,GAAE;SACxB,IAAI,CAAC,EAAE,mBAAmB,EAAE,WAAW,EAAE,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EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE;iBACpE;gBACD,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;aAClD;SACF;QACD,kCAAkC;QAClC,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QAClC,uCAAuC;QACvC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE;QAChD,qCAAqC;QACrC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;KACtB,CAAC;SACD,OAAO,EAAE,CAAC;IAEb,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;QAC3B,IAAI,EAAE,CAAC,CAAC,GAAG;QACX,KAAK,EAAE,CAAC,CAAC,KAAK;KACf,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -46,15 +46,6 @@ export type ToolExecution = {
|
|
|
46
46
|
status: "success" | "error";
|
|
47
47
|
httpStatus?: number;
|
|
48
48
|
response?: Record<string, unknown>;
|
|
49
|
-
steps?: ToolExecutionStep[];
|
|
50
|
-
};
|
|
51
|
-
export type ToolExecutionStepLevel = "info" | "warn" | "error";
|
|
52
|
-
export type ToolExecutionStep = {
|
|
53
|
-
timestamp: Date;
|
|
54
|
-
label: string;
|
|
55
|
-
level: ToolExecutionStepLevel;
|
|
56
|
-
data?: Record<string, unknown> | string;
|
|
57
|
-
payload?: Record<string, unknown>;
|
|
58
49
|
};
|
|
59
50
|
export type ToolExecutionMeta = {
|
|
60
51
|
kind: "http";
|
|
@@ -76,7 +67,7 @@ export type CallsFilterParams = {
|
|
|
76
67
|
callSid?: string;
|
|
77
68
|
startDate?: Date;
|
|
78
69
|
endDate?: Date;
|
|
79
|
-
status?:
|
|
70
|
+
status?: CallStatus;
|
|
80
71
|
customerPhoneNumber?: string;
|
|
81
72
|
agentPhoneNumber?: string;
|
|
82
73
|
flowId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calls.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/calls/calls.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,cAAc,GACtB,OAAO,wBAAwB,GAC/B,OAAO,0BAA0B,GACjC,IAAI,CAAC;AAET,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,SAAS,GACT,aAAa,GACb,UAAU,GACV,WAAW,GACX,MAAM,GACN,WAAW,GACX,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,MAAM,IAAI,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACvC,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,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IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,WAAW,GACX,SAAS,GACT,QAAQ,GACR,UAAU,GACV,OAAO,GACP,UAAU,GACV,KAAK,GACL,WAAW,CAAC;AAEhB,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAEnC,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScanDoc } from "../scans/scans.types";
|
|
2
|
+
import type { WebsiteUrlDoc } from "./websiteUrls.types";
|
|
3
|
+
export type ActiveWebsiteContext = {
|
|
4
|
+
websiteUrl: WebsiteUrlDoc | null;
|
|
5
|
+
scan: ScanDoc | null;
|
|
6
|
+
activeScanId: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare const resolveActiveWebsiteContext: (clientId: string) => Promise<ActiveWebsiteContext>;
|
|
9
|
+
export declare const getSelectedScanByClient: (clientId: string) => Promise<ScanDoc | null>;
|
|
10
|
+
export declare const getActiveWebsiteUrlByClient: (clientId: string) => Promise<WebsiteUrlDoc | null>;
|
|
11
|
+
//# sourceMappingURL=websiteUrls.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websiteUrls.context.d.ts","sourceRoot":"","sources":["../../../src/websitalk/websiteUrls/websiteUrls.context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,KACf,OAAO,CAAC,oBAAoB,CAgB9B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,GAAG,IAAI,CAOxB,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,KACf,OAAO,CAAC,aAAa,GAAG,IAAI,CAG9B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getActiveWebsiteUrlByClient = exports.getSelectedScanByClient = exports.resolveActiveWebsiteContext = void 0;
|
|
4
|
+
const clientsConfig_getters_1 = require("../../talkpilot/clientsConfig/clientsConfig.getters");
|
|
5
|
+
const scans_getters_1 = require("../scans/scans.getters");
|
|
6
|
+
const websiteUrls_getters_1 = require("./websiteUrls.getters");
|
|
7
|
+
const resolveActiveWebsiteContext = async (clientId) => {
|
|
8
|
+
const config = await (0, clientsConfig_getters_1.getClientConfig)(clientId);
|
|
9
|
+
const activeScanId = config?.products?.websiteTalk?.activeScanId ?? null;
|
|
10
|
+
if (!activeScanId) {
|
|
11
|
+
return { websiteUrl: null, scan: null, activeScanId: null };
|
|
12
|
+
}
|
|
13
|
+
const scan = await (0, scans_getters_1.getScanById)(activeScanId);
|
|
14
|
+
if (!scan) {
|
|
15
|
+
return { websiteUrl: null, scan: null, activeScanId };
|
|
16
|
+
}
|
|
17
|
+
const websiteUrl = await (0, websiteUrls_getters_1.getWebsiteUrlById)(scan.websiteUrlId);
|
|
18
|
+
return { websiteUrl, scan, activeScanId };
|
|
19
|
+
};
|
|
20
|
+
exports.resolveActiveWebsiteContext = resolveActiveWebsiteContext;
|
|
21
|
+
const getSelectedScanByClient = async (clientId) => {
|
|
22
|
+
const config = await (0, clientsConfig_getters_1.getClientConfig)(clientId);
|
|
23
|
+
const activeScanId = config?.products?.websiteTalk?.activeScanId;
|
|
24
|
+
if (!activeScanId) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return (0, scans_getters_1.getScanById)(activeScanId);
|
|
28
|
+
};
|
|
29
|
+
exports.getSelectedScanByClient = getSelectedScanByClient;
|
|
30
|
+
const getActiveWebsiteUrlByClient = async (clientId) => {
|
|
31
|
+
const context = await (0, exports.resolveActiveWebsiteContext)(clientId);
|
|
32
|
+
return context.websiteUrl;
|
|
33
|
+
};
|
|
34
|
+
exports.getActiveWebsiteUrlByClient = getActiveWebsiteUrlByClient;
|
|
35
|
+
//# sourceMappingURL=websiteUrls.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websiteUrls.context.js","sourceRoot":"","sources":["../../../src/websitalk/websiteUrls/websiteUrls.context.ts"],"names":[],"mappings":";;;AAAA,+FAAsF;AACtF,0DAAqD;AAErD,+DAE+B;AASxB,MAAM,2BAA2B,GAAG,KAAK,EAC9C,QAAgB,EACe,EAAE;IACjC,MAAM,MAAM,GAAG,MAAM,IAAA,uCAAe,EAAC,QAAQ,CAAC,CAAC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
|
1
|
+
import { ObjectId as MongoObjectId } from "mongodb";
|
|
2
|
+
import type { WebsiteUrl, WebsiteUrlDoc } from "./websiteUrls.types";
|
|
3
|
+
export type CreateWebsiteUrlInput = Omit<WebsiteUrl, "createdAt" | "updatedAt">;
|
|
4
|
+
export declare const createWebsiteUrl: (input: CreateWebsiteUrlInput) => Promise<MongoObjectId>;
|
|
5
|
+
export declare const updateWebsiteUrl: (id: string, updates: Partial<Pick<WebsiteUrl, "name" | "baseUrl">>) => Promise<WebsiteUrlDoc | null>;
|
|
6
|
+
export declare const deleteWebsiteUrl: (id: string) => Promise<boolean>;
|
|
7
|
+
//# sourceMappingURL=websiteUrls.setters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websiteUrls.setters.d.ts","sourceRoot":"","sources":["../../../src/websitalk/websiteUrls/websiteUrls.setters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,UAAU,EACV,WAAW,GAAG,WAAW,CAC1B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,qBAAqB,KAC3B,OAAO,CAAC,aAAa,CAWvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,IAAI,MAAM,EACV,SAAS,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,KACrD,OAAO,CAAC,aAAa,GAAG,IAAI,CAM9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,IAAI,MAAM,KAAG,OAAO,CAAC,OAAO,CAMlE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteWebsiteUrl = exports.updateWebsiteUrl = exports.createWebsiteUrl = void 0;
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
const websiteUrls_getters_1 = require("./websiteUrls.getters");
|
|
6
|
+
const createWebsiteUrl = async (input) => {
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const { insertedId } = await (0, websiteUrls_getters_1.getWebsiteUrlsCollection)().insertOne({
|
|
9
|
+
clientId: input.clientId,
|
|
10
|
+
name: input.name,
|
|
11
|
+
baseUrl: input.baseUrl,
|
|
12
|
+
createdAt: now,
|
|
13
|
+
updatedAt: now,
|
|
14
|
+
});
|
|
15
|
+
return insertedId;
|
|
16
|
+
};
|
|
17
|
+
exports.createWebsiteUrl = createWebsiteUrl;
|
|
18
|
+
const updateWebsiteUrl = async (id, updates) => {
|
|
19
|
+
return (0, websiteUrls_getters_1.getWebsiteUrlsCollection)().findOneAndUpdate({ _id: new index_1.ObjectId(id) }, { $set: { ...updates, updatedAt: new Date() } }, { returnDocument: "after" });
|
|
20
|
+
};
|
|
21
|
+
exports.updateWebsiteUrl = updateWebsiteUrl;
|
|
22
|
+
const deleteWebsiteUrl = async (id) => {
|
|
23
|
+
const result = await (0, websiteUrls_getters_1.getWebsiteUrlsCollection)().deleteOne({
|
|
24
|
+
_id: new index_1.ObjectId(id),
|
|
25
|
+
});
|
|
26
|
+
return result.deletedCount > 0;
|
|
27
|
+
};
|
|
28
|
+
exports.deleteWebsiteUrl = deleteWebsiteUrl;
|
|
29
|
+
//# sourceMappingURL=websiteUrls.setters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websiteUrls.setters.js","sourceRoot":"","sources":["../../../src/websitalk/websiteUrls/websiteUrls.setters.ts"],"names":[],"mappings":";;;AACA,oCAAoC;AACpC,+DAAoF;AAQ7E,MAAM,gBAAgB,GAAG,KAAK,EACnC,KAA4B,EACJ,EAAE;IAC1B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,8CAAwB,GAAE,CAAC,SAAS,CAAC;QAChE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAbW,QAAA,gBAAgB,oBAa3B;AAEK,MAAM,gBAAgB,GAAG,KAAK,EACnC,EAAU,EACV,OAAsD,EACvB,EAAE;IACjC,OAAO,IAAA,8CAAwB,GAAE,CAAC,gBAAgB,CAChD,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,EAAE,CAAC,EAAE,EACzB,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAC/C,EAAE,cAAc,EAAE,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B;AAEK,MAAM,gBAAgB,GAAG,KAAK,EAAE,EAAU,EAAoB,EAAE;IACrE,MAAM,MAAM,GAAG,MAAM,IAAA,8CAAwB,GAAE,CAAC,SAAS,CAAC;QACxD,GAAG,EAAE,IAAI,gBAAQ,CAAC,EAAE,CAAC;KACtB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;AANW,QAAA,gBAAgB,oBAM3B"}
|
package/jest.config.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
preset: 'ts-jest',
|
|
4
|
-
testEnvironment: 'node',
|
|
5
|
-
roots: ['<rootDir>/src'],
|
|
6
|
-
testPathIgnorePatterns: ['<rootDir>/src/__tests__/legacy/'],
|
|
7
|
-
testMatch: ['**/__tests__/**/*.spec.ts', '**/*.spec.ts'],
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.tsx?$': ['ts-jest', {
|
|
10
|
-
tsconfig: 'tsconfig.json',
|
|
11
|
-
}],
|
|
12
|
-
},
|
|
13
|
-
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
|
|
14
|
-
maxWorkers: 1,
|
|
15
|
-
verbose: true,
|
|
16
|
-
forceExit: true,
|
|
17
|
-
clearMocks: true,
|
|
18
|
-
resetMocks: true,
|
|
19
|
-
restoreMocks: true,
|
|
20
|
-
};
|
|
1
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
preset: 'ts-jest',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
roots: ['<rootDir>/src'],
|
|
6
|
+
testPathIgnorePatterns: ['<rootDir>/src/__tests__/legacy/'],
|
|
7
|
+
testMatch: ['**/__tests__/**/*.spec.ts', '**/*.spec.ts'],
|
|
8
|
+
transform: {
|
|
9
|
+
'^.+\\.tsx?$': ['ts-jest', {
|
|
10
|
+
tsconfig: 'tsconfig.json',
|
|
11
|
+
}],
|
|
12
|
+
},
|
|
13
|
+
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
|
|
14
|
+
maxWorkers: 1,
|
|
15
|
+
verbose: true,
|
|
16
|
+
forceExit: true,
|
|
17
|
+
clearMocks: true,
|
|
18
|
+
resetMocks: true,
|
|
19
|
+
restoreMocks: true,
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@talkpilot/core-db",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Core database package for centralized connections and ORM integration.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"dev": "tsc --watch",
|
|
10
|
-
"test": "jest",
|
|
11
|
-
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
12
|
-
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
13
|
-
"prepare": "npm run build"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"database",
|
|
17
|
-
"orm",
|
|
18
|
-
"typescript",
|
|
19
|
-
"postgres",
|
|
20
|
-
"db-client"
|
|
21
|
-
],
|
|
22
|
-
"author": "",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"dayjs": "^1.11.21",
|
|
26
|
-
"express": "^4.18.0",
|
|
27
|
-
"google-libphonenumber": "^3.2.0",
|
|
28
|
-
"mongodb": "^6.11.0"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@faker-js/faker": "^8.0.0",
|
|
32
|
-
"@types/express": "^4.17.0",
|
|
33
|
-
"@types/google-libphonenumber": "^7.4.0",
|
|
34
|
-
"@types/jest": "^29.0.0",
|
|
35
|
-
"@types/node": "^20.0.0",
|
|
36
|
-
"fishery": "^2.4.0",
|
|
37
|
-
"jest": "^29.0.0",
|
|
38
|
-
"mongodb-memory-server": "^10.0.0",
|
|
39
|
-
"prettier": "^3.8.2",
|
|
40
|
-
"ts-jest": "^29.0.0",
|
|
41
|
-
"typescript": "^5.0.0"
|
|
42
|
-
},
|
|
43
|
-
"publishConfig": {
|
|
44
|
-
"access": "public"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@talkpilot/core-db",
|
|
3
|
+
"version": "1.3.22",
|
|
4
|
+
"description": "Core database package for centralized connections and ORM integration.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
12
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
13
|
+
"prepare": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"database",
|
|
17
|
+
"orm",
|
|
18
|
+
"typescript",
|
|
19
|
+
"postgres",
|
|
20
|
+
"db-client"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"dayjs": "^1.11.21",
|
|
26
|
+
"express": "^4.18.0",
|
|
27
|
+
"google-libphonenumber": "^3.2.0",
|
|
28
|
+
"mongodb": "^6.11.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@faker-js/faker": "^8.0.0",
|
|
32
|
+
"@types/express": "^4.17.0",
|
|
33
|
+
"@types/google-libphonenumber": "^7.4.0",
|
|
34
|
+
"@types/jest": "^29.0.0",
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"fishery": "^2.4.0",
|
|
37
|
+
"jest": "^29.0.0",
|
|
38
|
+
"mongodb-memory-server": "^10.0.0",
|
|
39
|
+
"prettier": "^3.8.2",
|
|
40
|
+
"ts-jest": "^29.0.0",
|
|
41
|
+
"typescript": "^5.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/__tests__/setup.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { initTestDb, closeTestDb } from "../test-utils/db-utils";
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
// eslint-disable-next-line no-var
|
|
5
|
-
var db: import("mongodb").Db;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// Set up global mocks if needed
|
|
9
|
-
// global.fetch = jest.fn();
|
|
10
|
-
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
global.db = await initTestDb();
|
|
13
|
-
}, 30_000);
|
|
14
|
-
|
|
15
|
-
afterEach(async () => {
|
|
16
|
-
await closeTestDb();
|
|
17
|
-
jest.resetAllMocks();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
process.env.NODE_ENV = "test";
|
|
1
|
+
import { initTestDb, closeTestDb } from "../test-utils/db-utils";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
// eslint-disable-next-line no-var
|
|
5
|
+
var db: import("mongodb").Db;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Set up global mocks if needed
|
|
9
|
+
// global.fetch = jest.fn();
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
global.db = await initTestDb();
|
|
13
|
+
}, 30_000);
|
|
14
|
+
|
|
15
|
+
afterEach(async () => {
|
|
16
|
+
await closeTestDb();
|
|
17
|
+
jest.resetAllMocks();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
process.env.NODE_ENV = "test";
|
package/src/connection.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { mongodbClient } from "./talkpilot";
|
|
2
|
-
import { municipalDataMongodbClient } from "./municipal";
|
|
3
|
-
import { websitalkMongodbClient } from "./websitalk";
|
|
4
|
-
|
|
5
|
-
let isConnected = false;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Ensures the database clients are initialized.
|
|
9
|
-
* This function reads from MONGO_URI.
|
|
10
|
-
*/
|
|
11
|
-
export async function ensureDbConnected() {
|
|
12
|
-
if (isConnected) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const mongoUri = process.env.MONGO_URI || process.env.MONGODB_URI;
|
|
17
|
-
const talkpilotUri = mongoUri;
|
|
18
|
-
const municipalUri = mongoUri;
|
|
19
|
-
const websiteTalkUri = mongoUri;
|
|
20
|
-
|
|
21
|
-
if (!talkpilotUri) {
|
|
22
|
-
console.warn("[core-db] MONGO_URI is not set");
|
|
23
|
-
} else {
|
|
24
|
-
const dbNameFromUri = talkpilotUri.split("/").pop()?.split("?")[0];
|
|
25
|
-
const dbName = dbNameFromUri || process.env.TALKPILOT_DB_NAME;
|
|
26
|
-
await mongodbClient.connect(talkpilotUri, dbName);
|
|
27
|
-
console.info(
|
|
28
|
-
`[core-db] Connected to TalkPilot MongoDB: ${dbName || "via env"}`,
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!municipalUri) {
|
|
33
|
-
console.warn("[core-db] MONGO_URI is not set");
|
|
34
|
-
} else {
|
|
35
|
-
const dbNameFromUri = municipalUri.split("/").pop()?.split("?")[0];
|
|
36
|
-
const dbName = dbNameFromUri || process.env.MUNICIPAL_DB_NAME;
|
|
37
|
-
await municipalDataMongodbClient.connect(municipalUri, dbName);
|
|
38
|
-
console.info(
|
|
39
|
-
`[core-db] Connected to Municipal Data MongoDB: ${dbName || "via env"}`,
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!websiteTalkUri) {
|
|
44
|
-
console.warn("[core-db] MONGO_URI is not set");
|
|
45
|
-
} else {
|
|
46
|
-
const dbName = process.env.WEBSITALK_DB_NAME;
|
|
47
|
-
await websitalkMongodbClient.connect(websiteTalkUri, dbName);
|
|
48
|
-
console.info(
|
|
49
|
-
`[core-db] Connected to Website Talk MongoDB: ${dbName || "website-talk (default)"}`,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
isConnected = true;
|
|
54
|
-
}
|
|
1
|
+
import { mongodbClient } from "./talkpilot";
|
|
2
|
+
import { municipalDataMongodbClient } from "./municipal";
|
|
3
|
+
import { websitalkMongodbClient } from "./websitalk";
|
|
4
|
+
|
|
5
|
+
let isConnected = false;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Ensures the database clients are initialized.
|
|
9
|
+
* This function reads from MONGO_URI.
|
|
10
|
+
*/
|
|
11
|
+
export async function ensureDbConnected() {
|
|
12
|
+
if (isConnected) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const mongoUri = process.env.MONGO_URI || process.env.MONGODB_URI;
|
|
17
|
+
const talkpilotUri = mongoUri;
|
|
18
|
+
const municipalUri = mongoUri;
|
|
19
|
+
const websiteTalkUri = mongoUri;
|
|
20
|
+
|
|
21
|
+
if (!talkpilotUri) {
|
|
22
|
+
console.warn("[core-db] MONGO_URI is not set");
|
|
23
|
+
} else {
|
|
24
|
+
const dbNameFromUri = talkpilotUri.split("/").pop()?.split("?")[0];
|
|
25
|
+
const dbName = dbNameFromUri || process.env.TALKPILOT_DB_NAME;
|
|
26
|
+
await mongodbClient.connect(talkpilotUri, dbName);
|
|
27
|
+
console.info(
|
|
28
|
+
`[core-db] Connected to TalkPilot MongoDB: ${dbName || "via env"}`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!municipalUri) {
|
|
33
|
+
console.warn("[core-db] MONGO_URI is not set");
|
|
34
|
+
} else {
|
|
35
|
+
const dbNameFromUri = municipalUri.split("/").pop()?.split("?")[0];
|
|
36
|
+
const dbName = dbNameFromUri || process.env.MUNICIPAL_DB_NAME;
|
|
37
|
+
await municipalDataMongodbClient.connect(municipalUri, dbName);
|
|
38
|
+
console.info(
|
|
39
|
+
`[core-db] Connected to Municipal Data MongoDB: ${dbName || "via env"}`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!websiteTalkUri) {
|
|
44
|
+
console.warn("[core-db] MONGO_URI is not set");
|
|
45
|
+
} else {
|
|
46
|
+
const dbName = process.env.WEBSITALK_DB_NAME;
|
|
47
|
+
await websitalkMongodbClient.connect(websiteTalkUri, dbName);
|
|
48
|
+
console.info(
|
|
49
|
+
`[core-db] Connected to Website Talk MongoDB: ${dbName || "website-talk (default)"}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
isConnected = true;
|
|
54
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// TalkPilot DB exports
|
|
2
|
-
export * from "./talkpilot";
|
|
3
|
-
export * from "./connection";
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
municipalDataMongodbClient,
|
|
7
|
-
getDb as getMunicipalDataDb,
|
|
8
|
-
setDb as setMunicipalDataDb,
|
|
9
|
-
ObjectId as MunicipalDataObjectId,
|
|
10
|
-
} from "./municipal";
|
|
11
|
-
export * from "./municipal/cities";
|
|
12
|
-
export * from "./municipal/streets";
|
|
13
|
-
export * from "./municipal/departmentsSubjects";
|
|
14
|
-
export * from "./municipal/tickets";
|
|
15
|
-
export * from "./municipal/systemInstructions";
|
|
16
|
-
export * from "./municipal/muniIssues";
|
|
17
|
-
export * from "./municipal/utils/types";
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
websitalkMongodbClient,
|
|
21
|
-
getDb as getWebsitalkDb,
|
|
22
|
-
setDb as setWebsitalkDb,
|
|
23
|
-
ObjectId as WebsitalkObjectId,
|
|
24
|
-
} from "./websitalk";
|
|
25
|
-
export * from "./websitalk/scans/scans.getters";
|
|
26
|
-
export type * from "./websitalk/scans/scans.types";
|
|
27
|
-
export * from "./websitalk/websiteUrls";
|
|
1
|
+
// TalkPilot DB exports
|
|
2
|
+
export * from "./talkpilot";
|
|
3
|
+
export * from "./connection";
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
municipalDataMongodbClient,
|
|
7
|
+
getDb as getMunicipalDataDb,
|
|
8
|
+
setDb as setMunicipalDataDb,
|
|
9
|
+
ObjectId as MunicipalDataObjectId,
|
|
10
|
+
} from "./municipal";
|
|
11
|
+
export * from "./municipal/cities";
|
|
12
|
+
export * from "./municipal/streets";
|
|
13
|
+
export * from "./municipal/departmentsSubjects";
|
|
14
|
+
export * from "./municipal/tickets";
|
|
15
|
+
export * from "./municipal/systemInstructions";
|
|
16
|
+
export * from "./municipal/muniIssues";
|
|
17
|
+
export * from "./municipal/utils/types";
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
websitalkMongodbClient,
|
|
21
|
+
getDb as getWebsitalkDb,
|
|
22
|
+
setDb as setWebsitalkDb,
|
|
23
|
+
ObjectId as WebsitalkObjectId,
|
|
24
|
+
} from "./websitalk";
|
|
25
|
+
export * from "./websitalk/scans/scans.getters";
|
|
26
|
+
export type * from "./websitalk/scans/scans.types";
|
|
27
|
+
export * from "./websitalk/websiteUrls";
|