@talkpilot/core-db 1.3.33 → 1.3.34
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/README.md +54 -0
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +0 -11
- package/dist/connection.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/talkpilot/clients/clients.quota.constants.d.ts +2 -0
- package/dist/talkpilot/clients/clients.quota.constants.d.ts.map +1 -0
- package/dist/talkpilot/clients/clients.quota.constants.js +5 -0
- package/dist/talkpilot/clients/clients.quota.constants.js.map +1 -0
- package/dist/talkpilot/clients/clients.quota.getters.d.ts +7 -0
- package/dist/talkpilot/clients/clients.quota.getters.d.ts.map +1 -0
- package/dist/talkpilot/clients/clients.quota.getters.js +80 -0
- package/dist/talkpilot/clients/clients.quota.getters.js.map +1 -0
- package/dist/talkpilot/clients/clients.quota.types.d.ts +24 -0
- package/dist/talkpilot/clients/clients.quota.types.d.ts.map +1 -0
- package/dist/{configuration/prompts/prompts.types.js → talkpilot/clients/clients.quota.types.js} +1 -1
- package/dist/talkpilot/clients/clients.quota.types.js.map +1 -0
- package/dist/talkpilot/clients/clients.quota.utils.d.ts +8 -0
- package/dist/talkpilot/clients/clients.quota.utils.d.ts.map +1 -0
- package/dist/talkpilot/clients/clients.quota.utils.js +45 -0
- package/dist/talkpilot/clients/clients.quota.utils.js.map +1 -0
- package/dist/talkpilot/clients/clients.types.d.ts +3 -0
- package/dist/talkpilot/clients/clients.types.d.ts.map +1 -1
- package/dist/talkpilot/clients/index.d.ts +2 -0
- package/dist/talkpilot/clients/index.d.ts.map +1 -1
- package/dist/talkpilot/clients/index.js +2 -0
- package/dist/talkpilot/clients/index.js.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +5 -0
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +37 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +3 -3
- package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
- package/dist/talkpilot/clientsConfig/clientsConfig.types.js.map +1 -1
- package/dist/test-utils/db-utils.d.ts.map +1 -1
- package/dist/test-utils/db-utils.js +0 -2
- package/dist/test-utils/db-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +0 -13
- package/src/index.ts +0 -7
- package/src/talkpilot/clients/__tests__/clients.quota.spec.ts +123 -0
- package/src/talkpilot/clients/clients.quota.getters.ts +119 -0
- package/src/talkpilot/clients/clients.quota.types.ts +27 -0
- package/src/talkpilot/clients/clients.types.ts +4 -0
- package/src/talkpilot/clients/index.ts +2 -0
- package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +26 -0
- package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +54 -0
- package/src/talkpilot/clientsConfig/clientsConfig.types.ts +4 -3
- package/src/test-utils/db-utils.ts +1 -8
- package/dist/configuration/index.d.ts +0 -7
- package/dist/configuration/index.d.ts.map +0 -1
- package/dist/configuration/index.js +0 -34
- package/dist/configuration/index.js.map +0 -1
- package/dist/configuration/mongodb-client.d.ts +0 -13
- package/dist/configuration/mongodb-client.d.ts.map +0 -1
- package/dist/configuration/mongodb-client.js +0 -56
- package/dist/configuration/mongodb-client.js.map +0 -1
- package/dist/configuration/prompts/index.d.ts +0 -3
- package/dist/configuration/prompts/index.d.ts.map +0 -1
- package/dist/configuration/prompts/index.js +0 -18
- package/dist/configuration/prompts/index.js.map +0 -1
- package/dist/configuration/prompts/prompts.getters.d.ts +0 -21
- package/dist/configuration/prompts/prompts.getters.d.ts.map +0 -1
- package/dist/configuration/prompts/prompts.getters.js +0 -35
- package/dist/configuration/prompts/prompts.getters.js.map +0 -1
- package/dist/configuration/prompts/prompts.types.d.ts +0 -9
- package/dist/configuration/prompts/prompts.types.d.ts.map +0 -1
- package/dist/configuration/prompts/prompts.types.js.map +0 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.d.ts +0 -10
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.d.ts.map +0 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.js +0 -15
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.js.map +0 -1
- package/dist/municipal/streets/streets.setters.d.ts +0 -10
- package/dist/municipal/streets/streets.setters.d.ts.map +0 -1
- package/dist/municipal/streets/streets.setters.js +0 -15
- package/dist/municipal/streets/streets.setters.js.map +0 -1
- package/dist/reconcile/index.d.ts +0 -5
- package/dist/reconcile/index.d.ts.map +0 -1
- package/dist/reconcile/index.js +0 -21
- package/dist/reconcile/index.js.map +0 -1
- package/dist/reconcile/reconcile.diff.d.ts +0 -4
- package/dist/reconcile/reconcile.diff.d.ts.map +0 -1
- package/dist/reconcile/reconcile.diff.js +0 -36
- package/dist/reconcile/reconcile.diff.js.map +0 -1
- package/dist/reconcile/reconcile.execute.d.ts +0 -7
- package/dist/reconcile/reconcile.execute.d.ts.map +0 -1
- package/dist/reconcile/reconcile.execute.js +0 -20
- package/dist/reconcile/reconcile.execute.js.map +0 -1
- package/dist/reconcile/reconcile.ops.d.ts +0 -12
- package/dist/reconcile/reconcile.ops.d.ts.map +0 -1
- package/dist/reconcile/reconcile.ops.js +0 -24
- package/dist/reconcile/reconcile.ops.js.map +0 -1
- package/dist/reconcile/reconcile.types.d.ts +0 -32
- package/dist/reconcile/reconcile.types.d.ts.map +0 -1
- package/dist/reconcile/reconcile.types.js +0 -3
- package/dist/reconcile/reconcile.types.js.map +0 -1
- package/src/configuration/index.ts +0 -15
- package/src/configuration/mongodb-client.ts +0 -61
- package/src/configuration/prompts/index.ts +0 -2
- package/src/configuration/prompts/prompts.getters.ts +0 -37
- package/src/configuration/prompts/prompts.types.ts +0 -10
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-client.js","sourceRoot":"","sources":["../../src/configuration/mongodb-client.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,mCAAgC;AAChC,oDAAuE;AAEvE,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,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;QAC3E,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,OAAO,EAAE,CAAC;YAC5B,MAAM,YAAY,GAChB,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,IAAI,CAAC,aAAa,CAAC;YACpE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;YACvC,IAAA,aAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,8CAA8C,YAAY,EAAE,CAAC,CAAC;QAC7E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;YAClE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;YAClE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;gBACrE,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IAC3D,CAAC;CACF;AAEY,QAAA,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/prompts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Collection, Filter } from "mongodb";
|
|
2
|
-
import { Prompt } from "./prompts.types";
|
|
3
|
-
export declare const getPromptsCollection: () => Collection<Prompt>;
|
|
4
|
-
/**
|
|
5
|
-
* Get a prompt by its unique name.
|
|
6
|
-
* @param name prompt name
|
|
7
|
-
* @returns the prompt or null if not found
|
|
8
|
-
*/
|
|
9
|
-
export declare const getPromptByName: (name: string) => Promise<Prompt | null>;
|
|
10
|
-
/**
|
|
11
|
-
* Find prompts by filter.
|
|
12
|
-
* @param filter filter to apply
|
|
13
|
-
* @returns array of matching prompts
|
|
14
|
-
*/
|
|
15
|
-
export declare const findPrompts: (filter?: Filter<Prompt>) => Promise<Prompt[]>;
|
|
16
|
-
/**
|
|
17
|
-
* Get all prompts.
|
|
18
|
-
* @returns array of all prompts
|
|
19
|
-
*/
|
|
20
|
-
export declare const getAllPrompts: () => Promise<Prompt[]>;
|
|
21
|
-
//# sourceMappingURL=prompts.getters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAEzC,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"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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
|
-
//# sourceMappingURL=prompts.getters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.getters.js","sourceRoot":"","sources":["../../../src/configuration/prompts/prompts.getters.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAI1B,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"}
|
|
@@ -1 +0,0 @@
|
|
|
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;AAGnC,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.types.js","sourceRoot":"","sources":["../../../src/configuration/prompts/prompts.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/reconcile/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reconcile/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,kDAAgC;AAChC,mDAAiC;AACjC,sDAAoC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.diff.js","sourceRoot":"","sources":["../../src/reconcile/reconcile.diff.ts"],"names":[],"mappings":";;AAGA,oDAiDC;AAjDD,SAAgB,oBAAoB,CAClC,MAA2C,EAC3C,MAAY,IAAI,IAAI,EAAE;IAEtB,MAAM,EACJ,MAAM,EACN,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,GAC9B,GAAG,MAAM,CAAC;IAEX,MAAM,OAAO,GAAG,IAAI,GAAG,CAAY,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChG,MAAM,UAAU,GAAG,IAAI,GAAG,EAAQ,CAAC;IAEnC,MAAM,OAAO,GAAwC,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAEtE,KAAK,MAAM,YAAY,IAAI,MAAM,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;QACvC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,QAAQ,EAAE,CAAC;YAClB,SAAS;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC5D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvB,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,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"}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.types.js","sourceRoot":"","sources":["../../src/reconcile/reconcile.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
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;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { MongoClient, Db } from "mongodb";
|
|
2
|
-
import { setDb } from "./index";
|
|
3
|
-
import { validateConfig, validateMongoUri } from "../utils/validation";
|
|
4
|
-
|
|
5
|
-
class ConfigurationMongoDBClient {
|
|
6
|
-
private client: MongoClient | null = null;
|
|
7
|
-
private db: Db | null = null;
|
|
8
|
-
private readonly defaultDbName = "configuration";
|
|
9
|
-
|
|
10
|
-
async connect(uri?: string, dbName?: string): Promise<void> {
|
|
11
|
-
if (this.client) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const mongodbUri = uri || process.env.MONGO_URI || process.env.MONGODB_URI;
|
|
16
|
-
validateConfig("MONGO_URI", mongodbUri);
|
|
17
|
-
validateMongoUri(mongodbUri!);
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
this.client = new MongoClient(mongodbUri!);
|
|
21
|
-
await this.client.connect();
|
|
22
|
-
const targetDbName =
|
|
23
|
-
dbName || process.env.CONFIGURATION_DB_NAME || this.defaultDbName;
|
|
24
|
-
this.db = this.client.db(targetDbName);
|
|
25
|
-
setDb(this.db);
|
|
26
|
-
console.info(`[core-db] Configuration MongoDB connected: ${targetDbName}`);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error("[core-db] Configuration connection failed", error);
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async disconnect(): Promise<void> {
|
|
34
|
-
if (this.client) {
|
|
35
|
-
try {
|
|
36
|
-
await this.client.close();
|
|
37
|
-
this.client = null;
|
|
38
|
-
this.db = null;
|
|
39
|
-
console.info("Configuration MongoDB disconnected successfully");
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("[core-db] Configuration disconnection failed", error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getDb(): Db {
|
|
48
|
-
if (!this.db) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
"Configuration database not initialized. Call connect() first.",
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return this.db;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
isConnected(): boolean {
|
|
57
|
-
return this.client !== null && this.client !== undefined;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const configurationMongodbClient = new ConfigurationMongoDBClient();
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getDb } from "../index";
|
|
2
|
-
import { Collection, Filter } from "mongodb";
|
|
3
|
-
import { Prompt } from "./prompts.types";
|
|
4
|
-
|
|
5
|
-
export const getPromptsCollection = (): Collection<Prompt> => {
|
|
6
|
-
return getDb().collection<Prompt>("Prompts");
|
|
7
|
-
};
|
|
8
|
-
|
|
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
|
-
export const getPromptByName = async (
|
|
15
|
-
name: string,
|
|
16
|
-
): Promise<Prompt | null> => {
|
|
17
|
-
return await getPromptsCollection().findOne({ name });
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Find prompts by filter.
|
|
22
|
-
* @param filter filter to apply
|
|
23
|
-
* @returns array of matching prompts
|
|
24
|
-
*/
|
|
25
|
-
export const findPrompts = async (
|
|
26
|
-
filter: Filter<Prompt> = {},
|
|
27
|
-
): Promise<Prompt[]> => {
|
|
28
|
-
return await getPromptsCollection().find(filter).toArray();
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get all prompts.
|
|
33
|
-
* @returns array of all prompts
|
|
34
|
-
*/
|
|
35
|
-
export const getAllPrompts = async (): Promise<Prompt[]> => {
|
|
36
|
-
return await findPrompts();
|
|
37
|
-
};
|