@talkpilot/core-db 1.3.34 → 1.3.36

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 (84) hide show
  1. package/dist/config.d.ts +9 -0
  2. package/dist/config.d.ts.map +1 -0
  3. package/dist/config.js +12 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/configuration/index.d.ts +7 -0
  6. package/dist/configuration/index.d.ts.map +1 -0
  7. package/dist/configuration/index.js +34 -0
  8. package/dist/configuration/index.js.map +1 -0
  9. package/dist/configuration/mongodb-client.d.ts +13 -0
  10. package/dist/configuration/mongodb-client.d.ts.map +1 -0
  11. package/dist/configuration/mongodb-client.js +57 -0
  12. package/dist/configuration/mongodb-client.js.map +1 -0
  13. package/dist/configuration/prompts/index.d.ts +3 -0
  14. package/dist/configuration/prompts/index.d.ts.map +1 -0
  15. package/dist/configuration/prompts/index.js +18 -0
  16. package/dist/configuration/prompts/index.js.map +1 -0
  17. package/dist/configuration/prompts/prompts.getters.d.ts +28 -0
  18. package/dist/configuration/prompts/prompts.getters.d.ts.map +1 -0
  19. package/dist/configuration/prompts/prompts.getters.js +44 -0
  20. package/dist/configuration/prompts/prompts.getters.js.map +1 -0
  21. package/dist/configuration/prompts/prompts.types.d.ts +11 -0
  22. package/dist/configuration/prompts/prompts.types.d.ts.map +1 -0
  23. package/dist/configuration/prompts/prompts.types.js +3 -0
  24. package/dist/configuration/prompts/prompts.types.js.map +1 -0
  25. package/dist/connection.d.ts.map +1 -1
  26. package/dist/connection.js +12 -0
  27. package/dist/connection.js.map +1 -1
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +6 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.d.ts +10 -0
  33. package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.d.ts.map +1 -0
  34. package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.js +15 -0
  35. package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.js.map +1 -0
  36. package/dist/municipal/streets/streets.setters.d.ts +10 -0
  37. package/dist/municipal/streets/streets.setters.d.ts.map +1 -0
  38. package/dist/municipal/streets/streets.setters.js +15 -0
  39. package/dist/municipal/streets/streets.setters.js.map +1 -0
  40. package/dist/reconcile/index.d.ts +5 -0
  41. package/dist/reconcile/index.d.ts.map +1 -0
  42. package/dist/reconcile/index.js +21 -0
  43. package/dist/reconcile/index.js.map +1 -0
  44. package/dist/reconcile/reconcile.diff.d.ts +4 -0
  45. package/dist/reconcile/reconcile.diff.d.ts.map +1 -0
  46. package/dist/reconcile/reconcile.diff.js +36 -0
  47. package/dist/reconcile/reconcile.diff.js.map +1 -0
  48. package/dist/reconcile/reconcile.execute.d.ts +7 -0
  49. package/dist/reconcile/reconcile.execute.d.ts.map +1 -0
  50. package/dist/reconcile/reconcile.execute.js +20 -0
  51. package/dist/reconcile/reconcile.execute.js.map +1 -0
  52. package/dist/reconcile/reconcile.ops.d.ts +12 -0
  53. package/dist/reconcile/reconcile.ops.d.ts.map +1 -0
  54. package/dist/reconcile/reconcile.ops.js +24 -0
  55. package/dist/reconcile/reconcile.ops.js.map +1 -0
  56. package/dist/reconcile/reconcile.types.d.ts +32 -0
  57. package/dist/reconcile/reconcile.types.d.ts.map +1 -0
  58. package/dist/reconcile/reconcile.types.js +3 -0
  59. package/dist/reconcile/reconcile.types.js.map +1 -0
  60. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +3 -1
  61. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
  62. package/dist/talkpilot/clientsConfig/clientsConfig.types.js.map +1 -1
  63. package/dist/test-utils/db-utils.d.ts.map +1 -1
  64. package/dist/test-utils/db-utils.js +2 -0
  65. package/dist/test-utils/db-utils.js.map +1 -1
  66. package/package.json +1 -1
  67. package/src/config.ts +9 -0
  68. package/src/configuration/index.ts +15 -0
  69. package/src/configuration/mongodb-client.ts +62 -0
  70. package/src/configuration/prompts/index.ts +2 -0
  71. package/src/configuration/prompts/prompts.getters.ts +49 -0
  72. package/src/configuration/prompts/prompts.types.ts +11 -0
  73. package/src/connection.ts +14 -0
  74. package/src/index.ts +7 -0
  75. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +3 -1
  76. package/src/test-utils/db-utils.ts +8 -1
  77. package/dist/talkpilot/clients/clients.quota.constants.d.ts +0 -2
  78. package/dist/talkpilot/clients/clients.quota.constants.d.ts.map +0 -1
  79. package/dist/talkpilot/clients/clients.quota.constants.js +0 -5
  80. package/dist/talkpilot/clients/clients.quota.constants.js.map +0 -1
  81. package/dist/talkpilot/clients/clients.quota.utils.d.ts +0 -8
  82. package/dist/talkpilot/clients/clients.quota.utils.d.ts.map +0 -1
  83. package/dist/talkpilot/clients/clients.quota.utils.js +0 -45
  84. package/dist/talkpilot/clients/clients.quota.utils.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Centralized env var access. Add new fields here instead of reading
3
+ * process.env directly elsewhere, so each env var has exactly one source of truth in the code.
4
+ */
5
+ export declare const configurationDbConfig: {
6
+ mongoUri: string | undefined;
7
+ configurationDbName: string | undefined;
8
+ };
9
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * Centralized env var access. Add new fields here instead of reading
4
+ * process.env directly elsewhere, so each env var has exactly one source of truth in the code.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.configurationDbConfig = void 0;
8
+ exports.configurationDbConfig = {
9
+ mongoUri: process.env.MONGO_URI || process.env.MONGODB_URI,
10
+ configurationDbName: process.env.CONFIGURATION_DB_NAME,
11
+ };
12
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,qBAAqB,GAAG;IACnC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;IAC1D,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;CACvD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Db, ObjectId as MongoObjectId } from "mongodb";
2
+ export * from "./prompts";
3
+ export { configurationMongodbClient } from "./mongodb-client";
4
+ export declare const setDb: (d: Db) => void;
5
+ export declare const getDb: () => Db;
6
+ export declare const ObjectId: typeof MongoObjectId;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAG9D,eAAO,MAAM,KAAK,GAAI,GAAG,EAAE,SAE1B,CAAC;AAEF,eAAO,MAAM,KAAK,QAAO,EAGxB,CAAC;AACF,eAAO,MAAM,QAAQ,sBAAgB,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ObjectId = exports.getDb = exports.setDb = exports.configurationMongodbClient = void 0;
18
+ const mongodb_1 = require("mongodb");
19
+ __exportStar(require("./prompts"), exports);
20
+ var mongodb_client_1 = require("./mongodb-client");
21
+ Object.defineProperty(exports, "configurationMongodbClient", { enumerable: true, get: function () { return mongodb_client_1.configurationMongodbClient; } });
22
+ let db;
23
+ const setDb = (d) => {
24
+ db = d;
25
+ };
26
+ exports.setDb = setDb;
27
+ const getDb = () => {
28
+ if (!db)
29
+ throw new Error("Configuration DB not initialised");
30
+ return db;
31
+ };
32
+ exports.getDb = getDb;
33
+ exports.ObjectId = mongodb_1.ObjectId;
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAwD;AAExD,4CAA0B;AAC1B,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AAEnC,IAAI,EAAM,CAAC;AACJ,MAAM,KAAK,GAAG,CAAC,CAAK,EAAE,EAAE;IAC7B,EAAE,GAAG,CAAC,CAAC;AACT,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEK,MAAM,KAAK,GAAG,GAAO,EAAE;IAC5B,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC7D,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB;AACW,QAAA,QAAQ,GAAG,kBAAa,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Db } from "mongodb";
2
+ declare class ConfigurationMongoDBClient {
3
+ private client;
4
+ private db;
5
+ private readonly defaultDbName;
6
+ connect(uri?: string, dbName?: string): Promise<void>;
7
+ disconnect(): Promise<void>;
8
+ getDb(): Db;
9
+ isConnected(): boolean;
10
+ }
11
+ export declare const configurationMongodbClient: ConfigurationMongoDBClient;
12
+ export {};
13
+ //# sourceMappingURL=mongodb-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-client.d.ts","sourceRoot":"","sources":["../../src/configuration/mongodb-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAE,MAAM,SAAS,CAAC;AAK1C,cAAM,0BAA0B;IAC9B,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,EAAE,CAAmB;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmB;IAE3C,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAcjC,KAAK,IAAI,EAAE;IASX,WAAW,IAAI,OAAO;CAGvB;AAED,eAAO,MAAM,0BAA0B,4BAAmC,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configurationMongodbClient = void 0;
4
+ const mongodb_1 = require("mongodb");
5
+ const index_1 = require("./index");
6
+ const validation_1 = require("../utils/validation");
7
+ const config_1 = require("../config");
8
+ class ConfigurationMongoDBClient {
9
+ client = null;
10
+ db = null;
11
+ defaultDbName = "configuration";
12
+ async connect(uri, dbName) {
13
+ if (this.client) {
14
+ return;
15
+ }
16
+ const mongodbUri = uri || config_1.configurationDbConfig.mongoUri;
17
+ (0, validation_1.validateConfig)("MONGO_URI", mongodbUri);
18
+ (0, validation_1.validateMongoUri)(mongodbUri);
19
+ try {
20
+ this.client = new mongodb_1.MongoClient(mongodbUri);
21
+ await this.client.connect();
22
+ const targetDbName = dbName || config_1.configurationDbConfig.configurationDbName || this.defaultDbName;
23
+ this.db = this.client.db(targetDbName);
24
+ (0, index_1.setDb)(this.db);
25
+ console.info(`[core-db] Configuration MongoDB connected: ${targetDbName}`);
26
+ }
27
+ catch (error) {
28
+ console.error("[core-db] Configuration connection failed", error);
29
+ throw error;
30
+ }
31
+ }
32
+ async disconnect() {
33
+ if (this.client) {
34
+ try {
35
+ await this.client.close();
36
+ this.client = null;
37
+ this.db = null;
38
+ console.info("Configuration MongoDB disconnected successfully");
39
+ }
40
+ catch (error) {
41
+ console.error("[core-db] Configuration disconnection failed", error);
42
+ throw error;
43
+ }
44
+ }
45
+ }
46
+ getDb() {
47
+ if (!this.db) {
48
+ throw new Error("Configuration database not initialized. Call connect() first.");
49
+ }
50
+ return this.db;
51
+ }
52
+ isConnected() {
53
+ return this.client !== null && this.client !== undefined;
54
+ }
55
+ }
56
+ exports.configurationMongodbClient = new ConfigurationMongoDBClient();
57
+ //# sourceMappingURL=mongodb-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-client.js","sourceRoot":"","sources":["../../src/configuration/mongodb-client.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,mCAAgC;AAChC,oDAAuE;AACvE,sCAAkD;AAElD,MAAM,0BAA0B;IACtB,MAAM,GAAuB,IAAI,CAAC;IAClC,EAAE,GAAc,IAAI,CAAC;IACZ,aAAa,GAAG,eAAe,CAAC;IAEjD,KAAK,CAAC,OAAO,CAAC,GAAY,EAAE,MAAe;QACzC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,GAAG,IAAI,8BAAqB,CAAC,QAAQ,CAAC;QACzD,IAAA,2BAAc,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACxC,IAAA,6BAAgB,EAAC,UAAW,CAAC,CAAC;QAE9B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAW,CAAC,UAAW,CAAC,CAAC;YAC3C,MAAM,IAAI,CAAC,MAAM,CAAC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 -0,0 +1,3 @@
1
+ export * from "./prompts.getters";
2
+ export type { Prompt } from "./prompts.types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/configuration/prompts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./prompts.getters"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/prompts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
@@ -0,0 +1,28 @@
1
+ import { Collection, Filter } from "mongodb";
2
+ import { Prompt } from "./prompts.types";
3
+ import { KnownProductKey } from "../../talkpilot";
4
+ export declare const getPromptsCollection: () => Collection<Prompt>;
5
+ /**
6
+ * Get a prompt by its unique name.
7
+ * @param name prompt name
8
+ * @returns the prompt or null if not found
9
+ */
10
+ export declare const getPromptByName: (name: string) => Promise<Prompt | null>;
11
+ /**
12
+ * Find prompts by filter.
13
+ * @param filter filter to apply
14
+ * @returns array of matching prompts
15
+ */
16
+ export declare const findPrompts: (filter?: Filter<Prompt>) => Promise<Prompt[]>;
17
+ /**
18
+ * Get all prompts.
19
+ * @returns array of all prompts
20
+ */
21
+ export declare const getAllPrompts: () => Promise<Prompt[]>;
22
+ /**
23
+ * Get all prompts for a given product.
24
+ * @param productName product key
25
+ * @returns array of matching prompts
26
+ */
27
+ export declare const getPromptsByProduct: (productName: KnownProductKey) => Promise<Prompt[]>;
28
+ //# sourceMappingURL=prompts.getters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.getters.d.ts","sourceRoot":"","sources":["../../../src/configuration/prompts/prompts.getters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,oBAAoB,QAAO,UAAU,CAAC,MAAM,CAExD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,IAAI,CAEvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,SAAQ,MAAM,CAAC,MAAM,CAAM,KAC1B,OAAO,CAAC,MAAM,EAAE,CAElB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,MAAM,EAAE,CAEtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,eAAe,KAC3B,OAAO,CAAC,MAAM,EAAE,CAElB,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPromptsByProduct = exports.getAllPrompts = exports.findPrompts = exports.getPromptByName = exports.getPromptsCollection = void 0;
4
+ const index_1 = require("../index");
5
+ const getPromptsCollection = () => {
6
+ return (0, index_1.getDb)().collection("prompts");
7
+ };
8
+ exports.getPromptsCollection = getPromptsCollection;
9
+ /**
10
+ * Get a prompt by its unique name.
11
+ * @param name prompt name
12
+ * @returns the prompt or null if not found
13
+ */
14
+ const getPromptByName = async (name) => {
15
+ return await (0, exports.getPromptsCollection)().findOne({ name });
16
+ };
17
+ exports.getPromptByName = getPromptByName;
18
+ /**
19
+ * Find prompts by filter.
20
+ * @param filter filter to apply
21
+ * @returns array of matching prompts
22
+ */
23
+ const findPrompts = async (filter = {}) => {
24
+ return await (0, exports.getPromptsCollection)().find(filter).toArray();
25
+ };
26
+ exports.findPrompts = findPrompts;
27
+ /**
28
+ * Get all prompts.
29
+ * @returns array of all prompts
30
+ */
31
+ const getAllPrompts = async () => {
32
+ return await (0, exports.findPrompts)();
33
+ };
34
+ exports.getAllPrompts = getAllPrompts;
35
+ /**
36
+ * Get all prompts for a given product.
37
+ * @param productName product key
38
+ * @returns array of matching prompts
39
+ */
40
+ const getPromptsByProduct = async (productName) => {
41
+ return await (0, exports.findPrompts)({ productName });
42
+ };
43
+ exports.getPromptsByProduct = getPromptsByProduct;
44
+ //# sourceMappingURL=prompts.getters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.getters.js","sourceRoot":"","sources":["../../../src/configuration/prompts/prompts.getters.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAK1B,MAAM,oBAAoB,GAAG,GAAuB,EAAE;IAC3D,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAS,SAAS,CAAC,CAAC;AAC/C,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,KAAK,EAClC,IAAY,EACY,EAAE;IAC1B,OAAO,MAAM,IAAA,4BAAoB,GAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEF;;;;GAIG;AACI,MAAM,WAAW,GAAG,KAAK,EAC9B,SAAyB,EAAE,EACR,EAAE;IACrB,OAAO,MAAM,IAAA,4BAAoB,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7D,CAAC,CAAC;AAJW,QAAA,WAAW,eAItB;AAEF;;;GAGG;AACI,MAAM,aAAa,GAAG,KAAK,IAAuB,EAAE;IACzD,OAAO,MAAM,IAAA,mBAAW,GAAE,CAAC;AAC7B,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEF;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,KAAK,EACtC,WAA4B,EACT,EAAE;IACrB,OAAO,MAAM,IAAA,mBAAW,EAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AAC5C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B"}
@@ -0,0 +1,11 @@
1
+ import { ObjectId } from "mongodb";
2
+ import { KnownProductKey } from "../../talkpilot";
3
+ export type Prompt = {
4
+ _id: ObjectId;
5
+ name: string;
6
+ content: string;
7
+ productName: KnownProductKey;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ };
11
+ //# sourceMappingURL=prompts.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.types.d.ts","sourceRoot":"","sources":["../../../src/configuration/prompts/prompts.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,eAAe,CAAC;IAC7B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=prompts.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.types.js","sourceRoot":"","sources":["../../../src/configuration/prompts/prompts.types.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAsB,iBAAiB,kBA2CtC;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAWlD"}
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAsB,iBAAiB,kBAsDtC;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAYlD"}
@@ -5,6 +5,8 @@ exports.disconnectDb = disconnectDb;
5
5
  const talkpilot_1 = require("./talkpilot");
6
6
  const municipal_1 = require("./municipal");
7
7
  const websitalk_1 = require("./websitalk");
8
+ const configuration_1 = require("./configuration");
9
+ const config_1 = require("./config");
8
10
  let isConnected = false;
9
11
  /**
10
12
  * Ensures the database clients are initialized.
@@ -18,6 +20,7 @@ async function ensureDbConnected() {
18
20
  const talkpilotUri = mongoUri;
19
21
  const municipalUri = mongoUri;
20
22
  const websiteTalkUri = mongoUri;
23
+ const configurationUri = mongoUri;
21
24
  if (!talkpilotUri) {
22
25
  console.warn("[core-db] MONGO_URI is not set");
23
26
  }
@@ -44,6 +47,14 @@ async function ensureDbConnected() {
44
47
  await websitalk_1.websitalkMongodbClient.connect(websiteTalkUri, dbName);
45
48
  console.info(`[core-db] Connected to Website Talk MongoDB: ${dbName || "website-talk (default)"}`);
46
49
  }
50
+ if (!configurationUri) {
51
+ console.warn("[core-db] MONGO_URI is not set");
52
+ }
53
+ else {
54
+ const dbName = config_1.configurationDbConfig.configurationDbName;
55
+ await configuration_1.configurationMongodbClient.connect(configurationUri, dbName);
56
+ console.info(`[core-db] Connected to Configuration MongoDB: ${dbName || "configuration (default)"}`);
57
+ }
47
58
  isConnected = true;
48
59
  }
49
60
  async function disconnectDb() {
@@ -54,6 +65,7 @@ async function disconnectDb() {
54
65
  talkpilot_1.mongodbClient.disconnect(),
55
66
  municipal_1.municipalDataMongodbClient.disconnect(),
56
67
  websitalk_1.websitalkMongodbClient.disconnect(),
68
+ configuration_1.configurationMongodbClient.disconnect(),
57
69
  ]);
58
70
  isConnected = false;
59
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;AAUA,8CA2CC;AAED,oCAWC;AAlED,2CAA4C;AAC5C,2CAAyD;AACzD,2CAAqD;AAErD,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;;GAGG;AACI,KAAK,UAAU,iBAAiB;IACrC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAClE,MAAM,YAAY,GAAG,QAAQ,CAAC;IAC9B,MAAM,YAAY,GAAG,QAAQ,CAAC;IAC9B,MAAM,cAAc,GAAG,QAAQ,CAAC;IAEhC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACjD,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAC9D,MAAM,yBAAa,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAClD,OAAO,CAAC,IAAI,CACV,6CAA6C,MAAM,IAAI,SAAS,EAAE,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WebsitalkDb, setDb as setWebsitalkD
13
13
  export * from "./websitalk/scans/scans.getters";
14
14
  export type * from "./websitalk/scans/scans.types";
15
15
  export * from "./websitalk/websiteUrls";
16
+ export { configurationMongodbClient, getDb as getConfigurationDb, setDb as setConfigurationDb, } from "./configuration";
17
+ export * from "./configuration/prompts";
16
18
  export { ObjectId } from "mongodb";
17
19
  export type { Filter } from "mongodb";
18
20
  export type { AnyBulkWriteOperation as BulkWriteOp } from "mongodb";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,EAC3B,QAAQ,IAAI,qBAAqB,GAClC,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,sBAAsB,EACtB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,QAAQ,IAAI,iBAAiB,GAC9B,MAAM,aAAa,CAAC;AACrB,cAAc,iCAAiC,CAAC;AAChD,mBAAmB,+BAA+B,CAAC;AACnD,cAAc,yBAAyB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,EAC3B,QAAQ,IAAI,qBAAqB,GAClC,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,sBAAsB,EACtB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,QAAQ,IAAI,iBAAiB,GAC9B,MAAM,aAAa,CAAC;AACrB,cAAc,iCAAiC,CAAC;AAChD,mBAAmB,+BAA+B,CAAC;AACnD,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,GAC5B,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BulkWriteError = exports.ObjectId = exports.WebsitalkObjectId = exports.setWebsitalkDb = exports.getWebsitalkDb = exports.websitalkMongodbClient = exports.MunicipalDataObjectId = exports.setMunicipalDataDb = exports.getMunicipalDataDb = exports.municipalDataMongodbClient = void 0;
17
+ exports.BulkWriteError = exports.ObjectId = exports.setConfigurationDb = exports.getConfigurationDb = exports.configurationMongodbClient = exports.WebsitalkObjectId = exports.setWebsitalkDb = exports.getWebsitalkDb = exports.websitalkMongodbClient = exports.MunicipalDataObjectId = exports.setMunicipalDataDb = exports.getMunicipalDataDb = exports.municipalDataMongodbClient = void 0;
18
18
  // TalkPilot DB exports
19
19
  __exportStar(require("./talkpilot"), exports);
20
20
  __exportStar(require("./connection"), exports);
@@ -38,6 +38,11 @@ Object.defineProperty(exports, "setWebsitalkDb", { enumerable: true, get: functi
38
38
  Object.defineProperty(exports, "WebsitalkObjectId", { enumerable: true, get: function () { return websitalk_1.ObjectId; } });
39
39
  __exportStar(require("./websitalk/scans/scans.getters"), exports);
40
40
  __exportStar(require("./websitalk/websiteUrls"), exports);
41
+ var configuration_1 = require("./configuration");
42
+ Object.defineProperty(exports, "configurationMongodbClient", { enumerable: true, get: function () { return configuration_1.configurationMongodbClient; } });
43
+ Object.defineProperty(exports, "getConfigurationDb", { enumerable: true, get: function () { return configuration_1.getDb; } });
44
+ Object.defineProperty(exports, "setConfigurationDb", { enumerable: true, get: function () { return configuration_1.setDb; } });
45
+ __exportStar(require("./configuration/prompts"), exports);
41
46
  var mongodb_1 = require("mongodb");
42
47
  Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return mongodb_1.ObjectId; } });
43
48
  var mongodb_2 = require("mongodb");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,8CAA4B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,OAAkB"}
@@ -0,0 +1,10 @@
1
+ import { AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult } from "mongodb";
2
+ import { DepartmentSubject } from "./departmentsSubjects.types";
3
+ /**
4
+ * Generic batch write for the departmentsSubjects collection — a thin passthrough to the
5
+ * driver's bulkWrite, with no diffing/key-building/business logic. `operations` must be
6
+ * non-empty (the driver throws on an empty batch). Errors (including partial failures under
7
+ * `{ ordered: false }`) propagate unchanged, so callers can still catch `MongoBulkWriteError`.
8
+ */
9
+ export declare const bulkWriteDepartmentsSubjects: (operations: AnyBulkWriteOperation<DepartmentSubject>[], options?: BulkWriteOptions) => Promise<BulkWriteResult>;
10
+ //# sourceMappingURL=departmentsSubjects.setters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"departmentsSubjects.setters.d.ts","sourceRoot":"","sources":["../../../src/municipal/departmentsSubjects/departmentsSubjects.setters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACvC,YAAY,qBAAqB,CAAC,iBAAiB,CAAC,EAAE,EACtD,UAAU,gBAAgB,KACzB,OAAO,CAAC,eAAe,CAEzB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bulkWriteDepartmentsSubjects = void 0;
4
+ const departmentsSubjects_getters_1 = require("./departmentsSubjects.getters");
5
+ /**
6
+ * Generic batch write for the departmentsSubjects collection — a thin passthrough to the
7
+ * driver's bulkWrite, with no diffing/key-building/business logic. `operations` must be
8
+ * non-empty (the driver throws on an empty batch). Errors (including partial failures under
9
+ * `{ ordered: false }`) propagate unchanged, so callers can still catch `MongoBulkWriteError`.
10
+ */
11
+ const bulkWriteDepartmentsSubjects = async (operations, options) => {
12
+ return (0, departmentsSubjects_getters_1.getDepartmentsSubjectsCollection)().bulkWrite(operations, options);
13
+ };
14
+ exports.bulkWriteDepartmentsSubjects = bulkWriteDepartmentsSubjects;
15
+ //# sourceMappingURL=departmentsSubjects.setters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"departmentsSubjects.setters.js","sourceRoot":"","sources":["../../../src/municipal/departmentsSubjects/departmentsSubjects.setters.ts"],"names":[],"mappings":";;;AAEA,+EAAiF;AAEjF;;;;;GAKG;AACI,MAAM,4BAA4B,GAAG,KAAK,EAC/C,UAAsD,EACtD,OAA0B,EACA,EAAE;IAC5B,OAAO,IAAA,8DAAgC,GAAE,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC"}
@@ -0,0 +1,10 @@
1
+ import { AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult } from "mongodb";
2
+ import { Street } from "./streets.types";
3
+ /**
4
+ * Generic batch write for the streets collection — a thin passthrough to the driver's
5
+ * bulkWrite, with no diffing/key-building/business logic. `operations` must be non-empty
6
+ * (the driver throws on an empty batch). Errors (including partial failures under
7
+ * `{ ordered: false }`) propagate unchanged, so callers can still catch `MongoBulkWriteError`.
8
+ */
9
+ export declare const bulkWriteStreets: (operations: AnyBulkWriteOperation<Street>[], options?: BulkWriteOptions) => Promise<BulkWriteResult>;
10
+ //# sourceMappingURL=streets.setters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streets.setters.d.ts","sourceRoot":"","sources":["../../../src/municipal/streets/streets.setters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,YAAY,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAC3C,UAAU,gBAAgB,KACzB,OAAO,CAAC,eAAe,CAEzB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bulkWriteStreets = void 0;
4
+ const streets_getters_1 = require("./streets.getters");
5
+ /**
6
+ * Generic batch write for the streets collection — a thin passthrough to the driver's
7
+ * bulkWrite, with no diffing/key-building/business logic. `operations` must be non-empty
8
+ * (the driver throws on an empty batch). Errors (including partial failures under
9
+ * `{ ordered: false }`) propagate unchanged, so callers can still catch `MongoBulkWriteError`.
10
+ */
11
+ const bulkWriteStreets = async (operations, options) => {
12
+ return (0, streets_getters_1.getStreetsCollection)().bulkWrite(operations, options);
13
+ };
14
+ exports.bulkWriteStreets = bulkWriteStreets;
15
+ //# sourceMappingURL=streets.setters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streets.setters.js","sourceRoot":"","sources":["../../../src/municipal/streets/streets.setters.ts"],"names":[],"mappings":";;;AAEA,uDAAyD;AAEzD;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,KAAK,EACnC,UAA2C,EAC3C,OAA0B,EACA,EAAE;IAC5B,OAAO,IAAA,sCAAoB,GAAE,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,CAAC;AALW,QAAA,gBAAgB,oBAK3B"}
@@ -0,0 +1,5 @@
1
+ export * from "./reconcile.types";
2
+ export * from "./reconcile.ops";
3
+ export * from "./reconcile.diff";
4
+ export * from "./reconcile.execute";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reconcile/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./reconcile.types"), exports);
18
+ __exportStar(require("./reconcile.ops"), exports);
19
+ __exportStar(require("./reconcile.diff"), exports);
20
+ __exportStar(require("./reconcile.execute"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reconcile/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,kDAAgC;AAChC,mDAAiC;AACjC,sDAAoC"}
@@ -0,0 +1,4 @@
1
+ import { Document } from "mongodb";
2
+ import { ReconcileConfig, ReconcileDiffResult } from "./reconcile.types";
3
+ export declare function computeReconcileDiff<TSource, TDb extends Document, TKey extends string | number>(config: ReconcileConfig<TSource, TDb, TKey>, now?: Date): ReconcileDiffResult<TDb>;
4
+ //# sourceMappingURL=reconcile.diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.diff.d.ts","sourceRoot":"","sources":["../../src/reconcile/reconcile.diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,GAAG,SAAS,QAAQ,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAC9F,MAAM,EAAE,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAC3C,GAAG,GAAE,IAAiB,GACrB,mBAAmB,CAAC,GAAG,CAAC,CA8C1B"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeReconcileDiff = computeReconcileDiff;
4
+ function computeReconcileDiff(config, now = new Date()) {
5
+ const { source, dbRecords, getSourceKey, getDbKey, buildInsertOp, buildUpdateOp, buildDeactivateOp, shouldDeactivate = () => true, } = config;
6
+ const dbByKey = new Map(dbRecords.map((dbRecord) => [getDbKey(dbRecord), dbRecord]));
7
+ const sourceKeys = new Set();
8
+ const bulkOps = [];
9
+ const counts = { inserted: 0, updated: 0, deactivated: 0, exists: 0 };
10
+ for (const sourceRecord of source) {
11
+ const key = getSourceKey(sourceRecord);
12
+ sourceKeys.add(key);
13
+ const dbRecord = dbByKey.get(key);
14
+ if (!dbRecord) {
15
+ bulkOps.push(buildInsertOp(sourceRecord, now));
16
+ counts.inserted++;
17
+ continue;
18
+ }
19
+ const updateOp = buildUpdateOp(sourceRecord, dbRecord, now);
20
+ if (updateOp) {
21
+ bulkOps.push(updateOp);
22
+ counts.updated++;
23
+ }
24
+ else {
25
+ counts.exists++;
26
+ }
27
+ }
28
+ for (const dbRecord of dbRecords) {
29
+ if (!sourceKeys.has(getDbKey(dbRecord)) && shouldDeactivate(dbRecord)) {
30
+ bulkOps.push(buildDeactivateOp(dbRecord, now));
31
+ counts.deactivated++;
32
+ }
33
+ }
34
+ return { bulkOps, counts };
35
+ }
36
+ //# sourceMappingURL=reconcile.diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.diff.js","sourceRoot":"","sources":["../../src/reconcile/reconcile.diff.ts"],"names":[],"mappings":";;AAGA,oDAiDC;AAjDD,SAAgB,oBAAoB,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AM,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { BulkWriteOptions, Collection, Document } from "mongodb";
2
+ import { BulkWriteOp } from "./reconcile.types";
3
+ export interface ExecuteReconcileBulkWriteResult {
4
+ errors: string[];
5
+ }
6
+ export declare function executeReconcileBulkWrite<TDb extends Document>(collection: Collection<TDb>, bulkOps: BulkWriteOp<TDb>[], options?: BulkWriteOptions): Promise<ExecuteReconcileBulkWriteResult>;
7
+ //# sourceMappingURL=reconcile.execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.execute.d.ts","sourceRoot":"","sources":["../../src/reconcile/reconcile.execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAuB,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAsB,yBAAyB,CAAC,GAAG,SAAS,QAAQ,EAClE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,EAC3B,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,EAC3B,OAAO,GAAE,gBAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CAa1C"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeReconcileBulkWrite = executeReconcileBulkWrite;
4
+ const mongodb_1 = require("mongodb");
5
+ async function executeReconcileBulkWrite(collection, bulkOps, options = { ordered: false }) {
6
+ if (bulkOps.length === 0)
7
+ return { errors: [] };
8
+ try {
9
+ await collection.bulkWrite(bulkOps, options);
10
+ return { errors: [] };
11
+ }
12
+ catch (err) {
13
+ if (err instanceof mongodb_1.MongoBulkWriteError) {
14
+ const writeErrors = [err.writeErrors].flat();
15
+ return { errors: writeErrors.map((writeError) => `Write error: ${writeError.errmsg}`) };
16
+ }
17
+ return { errors: [err instanceof Error ? err.message : String(err)] };
18
+ }
19
+ }
20
+ //# sourceMappingURL=reconcile.execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.execute.js","sourceRoot":"","sources":["../../src/reconcile/reconcile.execute.ts"],"names":[],"mappings":";;AAOA,8DAiBC;AAxBD,qCAAsF;AAO/E,KAAK,UAAU,yBAAyB,CAC7C,UAA2B,EAC3B,OAA2B,EAC3B,UAA4B,EAAE,OAAO,EAAE,KAAK,EAAE;IAE9C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7C,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,6BAAmB,EAAE,CAAC;YACvC,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7C,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,gBAAgB,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QAC1F,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IACxE,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Document, Filter } from "mongodb";
2
+ import { BulkWriteOp } from "./reconcile.types";
3
+ /**
4
+ * updateOne with a plain $set — e.g. a deactivation:
5
+ * buildSetOp({ _id }, { isActive: false, updatedAt: now })
6
+ */
7
+ export declare function buildSetOp<T extends Document>(filter: Filter<T>, setFields: Partial<T>): BulkWriteOp<T>;
8
+ /**
9
+ * updateOne with $set + $setOnInsert + upsert:true.
10
+ */
11
+ export declare function buildUpsertOp<T extends Document>(filter: Filter<T>, setFields: Partial<T>, setOnInsertFields?: Partial<T>): BulkWriteOp<T>;
12
+ //# sourceMappingURL=reconcile.ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.ops.d.ts","sourceRoot":"","sources":["../../src/reconcile/reconcile.ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEvG;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAC9C,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EACrB,iBAAiB,GAAE,OAAO,CAAC,CAAC,CAAM,GACjC,WAAW,CAAC,CAAC,CAAC,CAQhB"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildSetOp = buildSetOp;
4
+ exports.buildUpsertOp = buildUpsertOp;
5
+ /**
6
+ * updateOne with a plain $set — e.g. a deactivation:
7
+ * buildSetOp({ _id }, { isActive: false, updatedAt: now })
8
+ */
9
+ function buildSetOp(filter, setFields) {
10
+ return { updateOne: { filter, update: { $set: setFields } } };
11
+ }
12
+ /**
13
+ * updateOne with $set + $setOnInsert + upsert:true.
14
+ */
15
+ function buildUpsertOp(filter, setFields, setOnInsertFields = {}) {
16
+ return {
17
+ updateOne: {
18
+ filter,
19
+ update: { $set: setFields, $setOnInsert: setOnInsertFields },
20
+ upsert: true,
21
+ },
22
+ };
23
+ }
24
+ //# sourceMappingURL=reconcile.ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.ops.js","sourceRoot":"","sources":["../../src/reconcile/reconcile.ops.ts"],"names":[],"mappings":";;AAOA,gCAEC;AAKD,sCAYC;AAvBD;;;GAGG;AACH,SAAgB,UAAU,CAAqB,MAAiB,EAAE,SAAqB;IACrF,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAC3B,MAAiB,EACjB,SAAqB,EACrB,oBAAgC,EAAE;IAElC,OAAO;QACL,SAAS,EAAE;YACT,MAAM;YACN,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE;YAC5D,MAAM,EAAE,IAAI;SACb;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { AnyBulkWriteOperation, Document } from "mongodb";
2
+ export type BulkWriteOp<T extends Document> = AnyBulkWriteOperation<T>;
3
+ export interface ReconcileCounts {
4
+ inserted: number;
5
+ updated: number;
6
+ deactivated: number;
7
+ exists: number;
8
+ }
9
+ export interface ReconcileDiffResult<TDb extends Document> {
10
+ bulkOps: BulkWriteOp<TDb>[];
11
+ counts: ReconcileCounts;
12
+ }
13
+ export interface ReconcileConfig<TSource, TDb extends Document, TKey extends string | number> {
14
+ source: TSource[];
15
+ dbRecords: TDb[];
16
+ getSourceKey: (source: TSource) => TKey;
17
+ getDbKey: (dbRecord: TDb) => TKey;
18
+ buildInsertOp: (source: TSource, now: Date) => BulkWriteOp<TDb>;
19
+ /** Return null when unchanged — counted as `exists`, no op emitted. */
20
+ buildUpdateOp: (source: TSource, existing: TDb, now: Date) => BulkWriteOp<TDb> | null;
21
+ /**
22
+ * Called for every dbRecord missing from source (and passing shouldDeactivate).
23
+ * The caller decides the op shape entirely — typically via buildSetOp.
24
+ */
25
+ buildDeactivateOp: (dbRecord: TDb, now: Date) => BulkWriteOp<TDb>;
26
+ /**
27
+ * Whether a missing dbRecord should even be considered for deactivation.
28
+ * Defaults to always true — core-db has no opinion on what "already inactive" means.
29
+ */
30
+ shouldDeactivate?: (dbRecord: TDb) => boolean;
31
+ }
32
+ //# sourceMappingURL=reconcile.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.types.d.ts","sourceRoot":"","sources":["../../src/reconcile/reconcile.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,QAAQ,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB,CAAC,GAAG,SAAS,QAAQ;IACvD,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5B,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,eAAe,CAAC,OAAO,EAAE,GAAG,SAAS,QAAQ,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM;IAC1F,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,SAAS,EAAE,GAAG,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,KAAK,WAAW,CAAC,GAAG,CAAC,CAAC;IAChE,uEAAuE;IACvE,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACtF;;;OAGG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,WAAW,CAAC,GAAG,CAAC,CAAC;IAClE;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC;CAC/C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=reconcile.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.types.js","sourceRoot":"","sources":["../../src/reconcile/reconcile.types.ts"],"names":[],"mappings":""}
@@ -9,10 +9,12 @@ export type InitiateCallForShortSlaConfig = {
9
9
  }[];
10
10
  flow_id?: string | string[];
11
11
  };
12
- /** Per-tool LLM system prompt overrides. Falls back to hardcoded defaults when absent. */
12
+ /** Per-tool LLM system prompt overrides. Falls back to configuration-db defaults when absent. */
13
13
  export type Moked106ToolPrompts = {
14
14
  findSubjectsSystemPrompt?: string;
15
15
  findStreetsSystemPrompt?: string;
16
+ transcriptionStreetSystemPrompt?: string;
17
+ transcriptionSubjectSystemPrompt?: string;
16
18
  };
17
19
  /** Feature flags and behavior config for the moked_106 municipal call-center product. */
18
20
  export type Moked106Config = {
@@ -1 +1 @@
1
- {"version":3,"file":"clientsConfig.types.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/clientsConfig/clientsConfig.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAMhE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,0FAA0F;AAC1F,MAAM,MAAM,mBAAmB,GAAG;IAChC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,yFAAyF;AACzF,MAAM,MAAM,cAAc,GAAG;IAC3B,2BAA2B,CAAC,EAAE,6BAA6B,CAAC;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,kDAIrB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,QAAQ,EAAE,MAAM,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AC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,MAAM,CACjE,YAAY,CAAC,CAAC,CAAC,CAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"clientsConfig.types.js","sourceRoot":"","sources":["../../../src/talkpilot/clientsConfig/clientsConfig.types.ts"],"names":[],"mappings":";;;AA6Ba,QAAA,kBAAkB,GAAG;IAChC,WAAW;IACX,SAAS;IACT,aAAa;CACL,CAAC"}
1
+ {"version":3,"file":"clientsConfig.types.js","sourceRoot":"","sources":["../../../src/talkpilot/clientsConfig/clientsConfig.types.ts"],"names":[],"mappings":";;;AA+Ba,QAAA,kBAAkB,GAAG;IAChC,WAAW;IACX,SAAS;IACT,aAAa;CACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"db-utils.d.ts","sourceRoot":"","sources":["../../src/test-utils/db-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,EAAE,EAAE,MAAM,SAAS,CAAC;AAM1C,wBAAsB,UAAU,IAAI,OAAO,CAAC,EAAE,CAAC,CAa9C;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAGjD"}
1
+ {"version":3,"file":"db-utils.d.ts","sourceRoot":"","sources":["../../src/test-utils/db-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,EAAE,EAAE,MAAM,SAAS,CAAC;AAW1C,wBAAsB,UAAU,IAAI,OAAO,CAAC,EAAE,CAAC,CAe9C;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAGjD"}
@@ -16,9 +16,11 @@ async function initTestDb() {
16
16
  const talkpilotDb = client.db();
17
17
  const municipalDb = client.db("municipal-data");
18
18
  const websitalkDb = client.db("website-talk");
19
+ const configurationDb = client.db("configuration");
19
20
  (0, index_1.setDb)(talkpilotDb);
20
21
  (0, index_1.setMunicipalDataDb)(municipalDb);
21
22
  (0, index_1.setWebsitalkDb)(websitalkDb);
23
+ (0, index_1.setConfigurationDb)(configurationDb);
22
24
  return talkpilotDb;
23
25
  }
24
26
  async function closeTestDb() {
@@ -1 +1 @@
1
- {"version":3,"file":"db-utils.js","sourceRoot":"","sources":["../../src/test-utils/db-utils.ts"],"names":[],"mappings":";;AAOA,gCAaC;AAED,kCAGC;AAzBD,iEAA0D;AAC1D,qCAA0C;AAC1C,oCAAqE;AAErE,IAAI,WAA8B,CAAC;AACnC,IAAI,MAAmB,CAAC;AAEjB,KAAK,UAAU,UAAU;IAC9B,WAAW,GAAG,MAAM,yCAAiB,CAAC,MAAM,CAAC;QAC3C,QAAQ,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;KAC9B,CAAC,CAAC;IACH,MAAM,GAAG,IAAI,qBAAW,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACvB,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;IAC9C,IAAA,aAAK,EAAC,WAAW,CAAC,CAAC;IACnB,IAAA,0BAAkB,EAAC,WAAW,CAAC,CAAC;IAChC,IAAA,sBAAc,EAAC,WAAW,CAAC,CAAC;IAC5B,OAAO,WAAW,CAAC;AACrB,CAAC;AAEM,KAAK,UAAU,WAAW;IAC/B,IAAI,MAAM;QAAE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 @@
1
1
  {
2
2
  "name": "@talkpilot/core-db",
3
- "version": "1.3.34",
3
+ "version": "1.3.36",
4
4
  "description": "Core database package for centralized connections and ORM integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/config.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Centralized env var access. Add new fields here instead of reading
3
+ * process.env directly elsewhere, so each env var has exactly one source of truth in the code.
4
+ */
5
+
6
+ export const configurationDbConfig = {
7
+ mongoUri: process.env.MONGO_URI || process.env.MONGODB_URI,
8
+ configurationDbName: process.env.CONFIGURATION_DB_NAME,
9
+ };
@@ -0,0 +1,15 @@
1
+ import { Db, ObjectId as MongoObjectId } from "mongodb";
2
+
3
+ export * from "./prompts";
4
+ export { configurationMongodbClient } from "./mongodb-client";
5
+
6
+ let db: Db;
7
+ export const setDb = (d: Db) => {
8
+ db = d;
9
+ };
10
+
11
+ export const getDb = (): Db => {
12
+ if (!db) throw new Error("Configuration DB not initialised");
13
+ return db;
14
+ };
15
+ export const ObjectId = MongoObjectId;
@@ -0,0 +1,62 @@
1
+ import { MongoClient, Db } from "mongodb";
2
+ import { setDb } from "./index";
3
+ import { validateConfig, validateMongoUri } from "../utils/validation";
4
+ import { configurationDbConfig } from "../config";
5
+
6
+ class ConfigurationMongoDBClient {
7
+ private client: MongoClient | null = null;
8
+ private db: Db | null = null;
9
+ private readonly defaultDbName = "configuration";
10
+
11
+ async connect(uri?: string, dbName?: string): Promise<void> {
12
+ if (this.client) {
13
+ return;
14
+ }
15
+
16
+ const mongodbUri = uri || configurationDbConfig.mongoUri;
17
+ validateConfig("MONGO_URI", mongodbUri);
18
+ validateMongoUri(mongodbUri!);
19
+
20
+ try {
21
+ this.client = new MongoClient(mongodbUri!);
22
+ await this.client.connect();
23
+ const targetDbName =
24
+ dbName || configurationDbConfig.configurationDbName || this.defaultDbName;
25
+ this.db = this.client.db(targetDbName);
26
+ setDb(this.db);
27
+ console.info(`[core-db] Configuration MongoDB connected: ${targetDbName}`);
28
+ } catch (error) {
29
+ console.error("[core-db] Configuration connection failed", error);
30
+ throw error;
31
+ }
32
+ }
33
+
34
+ async disconnect(): Promise<void> {
35
+ if (this.client) {
36
+ try {
37
+ await this.client.close();
38
+ this.client = null;
39
+ this.db = null;
40
+ console.info("Configuration MongoDB disconnected successfully");
41
+ } catch (error) {
42
+ console.error("[core-db] Configuration disconnection failed", error);
43
+ throw error;
44
+ }
45
+ }
46
+ }
47
+
48
+ getDb(): Db {
49
+ if (!this.db) {
50
+ throw new Error(
51
+ "Configuration database not initialized. Call connect() first.",
52
+ );
53
+ }
54
+ return this.db;
55
+ }
56
+
57
+ isConnected(): boolean {
58
+ return this.client !== null && this.client !== undefined;
59
+ }
60
+ }
61
+
62
+ export const configurationMongodbClient = new ConfigurationMongoDBClient();
@@ -0,0 +1,2 @@
1
+ export * from "./prompts.getters";
2
+ export type { Prompt } from "./prompts.types";
@@ -0,0 +1,49 @@
1
+ import { getDb } from "../index";
2
+ import { Collection, Filter } from "mongodb";
3
+ import { Prompt } from "./prompts.types";
4
+ import { KnownProductKey } from "../../talkpilot";
5
+
6
+ export const getPromptsCollection = (): Collection<Prompt> => {
7
+ return getDb().collection<Prompt>("prompts");
8
+ };
9
+
10
+ /**
11
+ * Get a prompt by its unique name.
12
+ * @param name prompt name
13
+ * @returns the prompt or null if not found
14
+ */
15
+ export const getPromptByName = async (
16
+ name: string,
17
+ ): Promise<Prompt | null> => {
18
+ return await getPromptsCollection().findOne({ name });
19
+ };
20
+
21
+ /**
22
+ * Find prompts by filter.
23
+ * @param filter filter to apply
24
+ * @returns array of matching prompts
25
+ */
26
+ export const findPrompts = async (
27
+ filter: Filter<Prompt> = {},
28
+ ): Promise<Prompt[]> => {
29
+ return await getPromptsCollection().find(filter).toArray();
30
+ };
31
+
32
+ /**
33
+ * Get all prompts.
34
+ * @returns array of all prompts
35
+ */
36
+ export const getAllPrompts = async (): Promise<Prompt[]> => {
37
+ return await findPrompts();
38
+ };
39
+
40
+ /**
41
+ * Get all prompts for a given product.
42
+ * @param productName product key
43
+ * @returns array of matching prompts
44
+ */
45
+ export const getPromptsByProduct = async (
46
+ productName: KnownProductKey,
47
+ ): Promise<Prompt[]> => {
48
+ return await findPrompts({ productName });
49
+ };
@@ -0,0 +1,11 @@
1
+ import { ObjectId } from "mongodb";
2
+ import { KnownProductKey } from "../../talkpilot";
3
+
4
+ export type Prompt = {
5
+ _id: ObjectId;
6
+ name: string;
7
+ content: string;
8
+ productName: KnownProductKey;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ };
package/src/connection.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { mongodbClient } from "./talkpilot";
2
2
  import { municipalDataMongodbClient } from "./municipal";
3
3
  import { websitalkMongodbClient } from "./websitalk";
4
+ import { configurationMongodbClient } from "./configuration";
5
+ import { configurationDbConfig } from "./config";
4
6
 
5
7
  let isConnected = false;
6
8
 
@@ -17,6 +19,7 @@ export async function ensureDbConnected() {
17
19
  const talkpilotUri = mongoUri;
18
20
  const municipalUri = mongoUri;
19
21
  const websiteTalkUri = mongoUri;
22
+ const configurationUri = mongoUri;
20
23
 
21
24
  if (!talkpilotUri) {
22
25
  console.warn("[core-db] MONGO_URI is not set");
@@ -50,6 +53,16 @@ export async function ensureDbConnected() {
50
53
  );
51
54
  }
52
55
 
56
+ if (!configurationUri) {
57
+ console.warn("[core-db] MONGO_URI is not set");
58
+ } else {
59
+ const dbName = configurationDbConfig.configurationDbName;
60
+ await configurationMongodbClient.connect(configurationUri, dbName);
61
+ console.info(
62
+ `[core-db] Connected to Configuration MongoDB: ${dbName || "configuration (default)"}`,
63
+ );
64
+ }
65
+
53
66
  isConnected = true;
54
67
  }
55
68
 
@@ -62,6 +75,7 @@ export async function disconnectDb(): Promise<void> {
62
75
  mongodbClient.disconnect(),
63
76
  municipalDataMongodbClient.disconnect(),
64
77
  websitalkMongodbClient.disconnect(),
78
+ configurationMongodbClient.disconnect(),
65
79
  ]);
66
80
  isConnected = false;
67
81
  }
package/src/index.ts CHANGED
@@ -27,6 +27,13 @@ export * from "./websitalk/scans/scans.getters";
27
27
  export type * from "./websitalk/scans/scans.types";
28
28
  export * from "./websitalk/websiteUrls";
29
29
 
30
+ export {
31
+ configurationMongodbClient,
32
+ getDb as getConfigurationDb,
33
+ setDb as setConfigurationDb,
34
+ } from "./configuration";
35
+ export * from "./configuration/prompts";
36
+
30
37
  export { ObjectId } from "mongodb";
31
38
  export type { Filter } from "mongodb";
32
39
  export type { AnyBulkWriteOperation as BulkWriteOp } from "mongodb";
@@ -12,10 +12,12 @@ export type InitiateCallForShortSlaConfig = {
12
12
  flow_id?: string | string[];
13
13
  };
14
14
 
15
- /** Per-tool LLM system prompt overrides. Falls back to hardcoded defaults when absent. */
15
+ /** Per-tool LLM system prompt overrides. Falls back to configuration-db defaults when absent. */
16
16
  export type Moked106ToolPrompts = {
17
17
  findSubjectsSystemPrompt?: string;
18
18
  findStreetsSystemPrompt?: string;
19
+ transcriptionStreetSystemPrompt?: string;
20
+ transcriptionSubjectSystemPrompt?: string;
19
21
  };
20
22
 
21
23
  /** Feature flags and behavior config for the moked_106 municipal call-center product. */
@@ -1,6 +1,11 @@
1
1
  import { MongoMemoryServer } from "mongodb-memory-server";
2
2
  import { MongoClient, Db } from "mongodb";
3
- import { setDb, setMunicipalDataDb, setWebsitalkDb } from "../index";
3
+ import {
4
+ setDb,
5
+ setMunicipalDataDb,
6
+ setWebsitalkDb,
7
+ setConfigurationDb,
8
+ } from "../index";
4
9
 
5
10
  let mongoServer: MongoMemoryServer;
6
11
  let client: MongoClient;
@@ -14,9 +19,11 @@ export async function initTestDb(): Promise<Db> {
14
19
  const talkpilotDb = client.db();
15
20
  const municipalDb = client.db("municipal-data");
16
21
  const websitalkDb = client.db("website-talk");
22
+ const configurationDb = client.db("configuration");
17
23
  setDb(talkpilotDb);
18
24
  setMunicipalDataDb(municipalDb);
19
25
  setWebsitalkDb(websitalkDb);
26
+ setConfigurationDb(configurationDb);
20
27
  return talkpilotDb;
21
28
  }
22
29
 
@@ -1,2 +0,0 @@
1
- export declare const FULL_QUOTA_THRESHOLD = 100;
2
- //# sourceMappingURL=clients.quota.constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.constants.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,MAAM,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FULL_QUOTA_THRESHOLD = void 0;
4
- exports.FULL_QUOTA_THRESHOLD = 100;
5
- //# sourceMappingURL=clients.quota.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.constants.js","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,GAAG,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { ClientQuotaNotifications, ClientQuotaState, ClientQuotaStatus, QuotaThresholdAlert } from "./clients.quota.types";
2
- export declare const computeClientQuotaStatus: (quota: ClientQuotaState | null) => ClientQuotaStatus;
3
- export declare const getQuotaAlerts: (quota?: ClientQuotaState) => QuotaThresholdAlert[];
4
- export declare const findFullQuotaAlertIndex: (alerts: QuotaThresholdAlert[]) => number;
5
- export declare const getFullQuotaAlert: (quota?: ClientQuotaState) => QuotaThresholdAlert | undefined;
6
- export declare const isFullQuotaAlert: (thresholdPct: number) => boolean;
7
- export declare const toClientQuotaNotifications: (quota: ClientQuotaState | null) => ClientQuotaNotifications;
8
- //# sourceMappingURL=clients.quota.utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.utils.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,wBAAwB,GACnC,OAAO,gBAAgB,GAAG,IAAI,KAC7B,iBAiBF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,KAAG,mBAAmB,EAClC,CAAC;AAE5C,eAAO,MAAM,uBAAuB,GAAI,QAAQ,mBAAmB,EAAE,KAAG,MACP,CAAC;AAElE,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,gBAAgB,KACvB,mBAAmB,GAAG,SAIxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,KAAG,OAClB,CAAC;AAEvC,eAAO,MAAM,0BAA0B,GACrC,OAAO,gBAAgB,GAAG,IAAI,KAC7B,wBASD,CAAC"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toClientQuotaNotifications = exports.isFullQuotaAlert = exports.getFullQuotaAlert = exports.findFullQuotaAlertIndex = exports.getQuotaAlerts = exports.computeClientQuotaStatus = void 0;
4
- const clients_quota_constants_1 = require("./clients.quota.constants");
5
- const computeUsagePct = (usedQuota, totalQuota) => totalQuota > 0 ? Math.round((usedQuota / totalQuota) * 100) : 0;
6
- const isPastExpiration = (expiresAt) => expiresAt ? Date.now() > new Date(expiresAt).getTime() : false;
7
- const computeClientQuotaStatus = (quota) => {
8
- if (!quota) {
9
- return { hasQuota: false };
10
- }
11
- const totalQuota = quota.totalQuota;
12
- const usedQuota = quota.usedQuota ?? 0;
13
- return {
14
- hasQuota: true,
15
- totalQuota,
16
- usedQuota,
17
- pct: computeUsagePct(usedQuota, totalQuota),
18
- expiresAt: quota.expiresAt ? new Date(quota.expiresAt).toISOString() : null,
19
- isExceeded: usedQuota >= totalQuota,
20
- isExpired: isPastExpiration(quota.expiresAt),
21
- };
22
- };
23
- exports.computeClientQuotaStatus = computeClientQuotaStatus;
24
- const getQuotaAlerts = (quota) => quota?.alerts?.length ? quota.alerts : [];
25
- exports.getQuotaAlerts = getQuotaAlerts;
26
- const findFullQuotaAlertIndex = (alerts) => alerts.findIndex((a) => a.thresholdPct >= clients_quota_constants_1.FULL_QUOTA_THRESHOLD);
27
- exports.findFullQuotaAlertIndex = findFullQuotaAlertIndex;
28
- const getFullQuotaAlert = (quota) => {
29
- const alerts = (0, exports.getQuotaAlerts)(quota);
30
- const index = (0, exports.findFullQuotaAlertIndex)(alerts);
31
- return index >= 0 ? alerts[index] : undefined;
32
- };
33
- exports.getFullQuotaAlert = getFullQuotaAlert;
34
- const isFullQuotaAlert = (thresholdPct) => thresholdPct >= clients_quota_constants_1.FULL_QUOTA_THRESHOLD;
35
- exports.isFullQuotaAlert = isFullQuotaAlert;
36
- const toClientQuotaNotifications = (quota) => ({
37
- alerts: (0, exports.getQuotaAlerts)(quota ?? undefined).map(({ thresholdPct, recipientEmails, thresholdSent }) => ({
38
- thresholdPct,
39
- recipientEmails: recipientEmails ?? [],
40
- ...(thresholdSent ? { thresholdSent: true } : {}),
41
- })),
42
- ...(quota?.expiredSent ? { expiredSent: true } : {}),
43
- });
44
- exports.toClientQuotaNotifications = toClientQuotaNotifications;
45
- //# sourceMappingURL=clients.quota.utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clients.quota.utils.js","sourceRoot":"","sources":["../../../src/talkpilot/clients/clients.quota.utils.ts"],"names":[],"mappings":";;;AAAA,uEAAiE;AAQjE,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAE,UAAkB,EAAU,EAAE,CACxE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAElE,MAAM,gBAAgB,GAAG,CAAC,SAAwC,EAAW,EAAE,CAC7E,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,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