@talkpilot/core-db 1.3.75 → 1.3.76
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/AGENTS.md +1 -1
- package/README.md +1 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.d.ts +10 -0
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.d.ts.map +1 -0
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.js +15 -0
- package/dist/municipal/departmentsSubjects/departmentsSubjects.setters.js.map +1 -0
- package/dist/municipal/index.d.ts +0 -1
- package/dist/municipal/index.d.ts.map +1 -1
- package/dist/municipal/index.js +0 -1
- package/dist/municipal/index.js.map +1 -1
- package/dist/municipal/streets/streets.setters.d.ts +10 -0
- package/dist/municipal/streets/streets.setters.d.ts.map +1 -0
- package/dist/municipal/streets/streets.setters.js +15 -0
- package/dist/municipal/streets/streets.setters.js.map +1 -0
- package/dist/reconcile/index.d.ts +5 -0
- package/dist/reconcile/index.d.ts.map +1 -0
- package/dist/{municipal/residents → reconcile}/index.js +4 -7
- package/dist/reconcile/index.js.map +1 -0
- package/dist/reconcile/reconcile.diff.d.ts +4 -0
- package/dist/reconcile/reconcile.diff.d.ts.map +1 -0
- package/dist/reconcile/reconcile.diff.js +36 -0
- package/dist/reconcile/reconcile.diff.js.map +1 -0
- package/dist/reconcile/reconcile.execute.d.ts +7 -0
- package/dist/reconcile/reconcile.execute.d.ts.map +1 -0
- package/dist/reconcile/reconcile.execute.js +20 -0
- package/dist/reconcile/reconcile.execute.js.map +1 -0
- package/dist/reconcile/reconcile.ops.d.ts +12 -0
- package/dist/reconcile/reconcile.ops.d.ts.map +1 -0
- package/dist/reconcile/reconcile.ops.js +24 -0
- package/dist/reconcile/reconcile.ops.js.map +1 -0
- package/dist/reconcile/reconcile.types.d.ts +32 -0
- package/dist/reconcile/reconcile.types.d.ts.map +1 -0
- package/dist/{municipal/residents/residents.types.js → reconcile/reconcile.types.js} +1 -1
- package/dist/reconcile/reconcile.types.js.map +1 -0
- package/dist/talkpilot/calls/calls.types.d.ts +12 -0
- package/dist/talkpilot/calls/calls.types.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.schema.d.ts +0 -28
- package/dist/talkpilot/flows/flows.schema.d.ts.map +1 -1
- package/dist/talkpilot/flows/flows.schema.js +0 -16
- package/dist/talkpilot/flows/flows.schema.js.map +1 -1
- package/dist/talkpilot/flows/flows.types.d.ts +0 -8
- package/dist/talkpilot/flows/flows.types.d.ts.map +1 -1
- package/dist/test-utils/factories/index.d.ts +0 -1
- package/dist/test-utils/factories/index.d.ts.map +1 -1
- package/dist/test-utils/factories/index.js +0 -1
- package/dist/test-utils/factories/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/municipal/index.ts +0 -1
- package/src/talkpilot/calls/calls.types.ts +13 -0
- package/src/talkpilot/flows/__tests__/flows.schema.spec.ts +0 -28
- package/src/talkpilot/flows/flows.schema.ts +0 -16
- package/src/talkpilot/flows/flows.types.ts +0 -9
- package/src/test-utils/factories/index.ts +0 -1
- package/dist/municipal/residents/index.d.ts +0 -5
- package/dist/municipal/residents/index.d.ts.map +0 -1
- package/dist/municipal/residents/index.js.map +0 -1
- package/dist/municipal/residents/residents.constants.d.ts +0 -3
- package/dist/municipal/residents/residents.constants.d.ts.map +0 -1
- package/dist/municipal/residents/residents.constants.js +0 -6
- package/dist/municipal/residents/residents.constants.js.map +0 -1
- package/dist/municipal/residents/residents.getters.d.ts +0 -9
- package/dist/municipal/residents/residents.getters.d.ts.map +0 -1
- package/dist/municipal/residents/residents.getters.js +0 -32
- package/dist/municipal/residents/residents.getters.js.map +0 -1
- package/dist/municipal/residents/residents.schema.d.ts +0 -4
- package/dist/municipal/residents/residents.schema.d.ts.map +0 -1
- package/dist/municipal/residents/residents.schema.js +0 -29
- package/dist/municipal/residents/residents.schema.js.map +0 -1
- package/dist/municipal/residents/residents.types.d.ts +0 -15
- package/dist/municipal/residents/residents.types.d.ts.map +0 -1
- package/dist/municipal/residents/residents.types.js.map +0 -1
- package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts +0 -4
- package/dist/talkpilot/subscriptions/subscriptions.utils.d.ts.map +0 -1
- package/dist/talkpilot/subscriptions/subscriptions.utils.js +0 -20
- package/dist/talkpilot/subscriptions/subscriptions.utils.js.map +0 -1
- package/dist/test-utils/factories/municipal/residents.d.ts +0 -5
- package/dist/test-utils/factories/municipal/residents.d.ts.map +0 -1
- package/dist/test-utils/factories/municipal/residents.js +0 -22
- package/dist/test-utils/factories/municipal/residents.js.map +0 -1
- package/src/municipal/residents/__tests__/residents.spec.ts +0 -92
- package/src/municipal/residents/index.ts +0 -4
- package/src/municipal/residents/residents.constants.ts +0 -2
- package/src/municipal/residents/residents.getters.ts +0 -42
- package/src/municipal/residents/residents.schema.ts +0 -28
- package/src/municipal/residents/residents.types.ts +0 -17
- package/src/test-utils/factories/municipal/residents.ts +0 -20
|
@@ -26,7 +26,6 @@ __exportStar(require("./talkpilot/sessions"), exports);
|
|
|
26
26
|
__exportStar(require("./municipal/cities"), exports);
|
|
27
27
|
__exportStar(require("./municipal/departmentsSubjects"), exports);
|
|
28
28
|
__exportStar(require("./municipal/muniIssues"), exports);
|
|
29
|
-
__exportStar(require("./municipal/residents"), exports);
|
|
30
29
|
__exportStar(require("./municipal/streets"), exports);
|
|
31
30
|
__exportStar(require("./municipal/tickets"), exports);
|
|
32
31
|
__exportStar(require("./websitalk/scans"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/test-utils/factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,iEAA+C;AAC/C,4DAA0C;AAC1C,oDAAkC;AAClC,2DAAyC;AACzC,qDAAmC;AACnC,4DAA0C;AAC1C,uDAAqC;AACrC,qDAAmC;AACnC,kEAAgD;AAChD,yDAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/test-utils/factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,iEAA+C;AAC/C,4DAA0C;AAC1C,oDAAkC;AAClC,2DAAyC;AACzC,qDAAmC;AACnC,4DAA0C;AAC1C,uDAAqC;AACrC,qDAAmC;AACnC,kEAAgD;AAChD,yDAAuC;AACvC,sDAAoC;AACpC,sDAAoC;AACpC,oDAAkC;AAClC,4DAA0C;AAC1C,0DAAwC;AACxC,iEAA+C"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,7 +15,6 @@ export * from "./municipal/departmentsSubjects";
|
|
|
15
15
|
export * from "./municipal/tickets";
|
|
16
16
|
export * from "./municipal/systemInstructions";
|
|
17
17
|
export * from "./municipal/muniIssues";
|
|
18
|
-
export * from "./municipal/residents";
|
|
19
18
|
export * from "./municipal/utils/types";
|
|
20
19
|
|
|
21
20
|
export {
|
package/src/municipal/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./departmentsSubjects";
|
|
|
6
6
|
export * from "./tickets";
|
|
7
7
|
export * from "./systemInstructions";
|
|
8
8
|
export * from "./muniIssues";
|
|
9
|
-
export * from "./residents";
|
|
10
9
|
export * from "./utils/types";
|
|
11
10
|
export type { CityName } from "./utils/types";
|
|
12
11
|
export { municipalDataMongodbClient } from "./mongodb-client";
|
|
@@ -15,6 +15,16 @@ export type ConferenceRole =
|
|
|
15
15
|
|
|
16
16
|
export type CallStatus = (typeof CallStatusValues)[keyof typeof CallStatusValues];
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Represents the call usage information with details about charging segments and quota impact.
|
|
20
|
+
*/
|
|
21
|
+
export type CallUsage = {
|
|
22
|
+
/** Length in minutes of a segment the call is charged by. */
|
|
23
|
+
minutesPerSegment: number;
|
|
24
|
+
/** Segments the call adds to the customer's quota. */
|
|
25
|
+
segments: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
export type Call = {
|
|
19
29
|
callSid: string;
|
|
20
30
|
flowId: ObjectId;
|
|
@@ -27,6 +37,7 @@ export type Call = {
|
|
|
27
37
|
isIncomingCall: boolean;
|
|
28
38
|
isOutgoingCall: boolean;
|
|
29
39
|
callLength: number;
|
|
40
|
+
usage?: CallUsage;
|
|
30
41
|
transcription?: TranscriptionSegment[];
|
|
31
42
|
status?: CallStatus;
|
|
32
43
|
leads?: LeadProperty[];
|
|
@@ -116,6 +127,8 @@ export type CallsFilterParams = {
|
|
|
116
127
|
runId?: string;
|
|
117
128
|
sessionId?: string;
|
|
118
129
|
isIncoming?: boolean;
|
|
130
|
+
billableCallsFrom?: number;
|
|
131
|
+
billableCallsTo?: number;
|
|
119
132
|
search?: string;
|
|
120
133
|
};
|
|
121
134
|
|
|
@@ -121,32 +121,4 @@ describe("flowMongoSchema", () => {
|
|
|
121
121
|
"null",
|
|
122
122
|
]);
|
|
123
123
|
});
|
|
124
|
-
|
|
125
|
-
it("defines beforeCallEvent as an optional object with url, and afterCallEvent as optional string or null", () => {
|
|
126
|
-
const schema: any = flowMongoSchema;
|
|
127
|
-
|
|
128
|
-
expect(schema.properties).toHaveProperty("beforeCallEvent");
|
|
129
|
-
expect(schema.properties.beforeCallEvent.bsonType).toEqual(["object", "null"]);
|
|
130
|
-
expect(schema.properties.beforeCallEvent.required).toEqual(["url"]);
|
|
131
|
-
expect(schema.properties.beforeCallEvent.properties).toEqual(
|
|
132
|
-
expect.objectContaining({
|
|
133
|
-
url: { bsonType: "string" },
|
|
134
|
-
timeoutMs: { bsonType: ["number", "null"] },
|
|
135
|
-
sendUserAuthToken: { bsonType: ["bool", "null"] },
|
|
136
|
-
wait: { bsonType: ["bool", "null"] },
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
expect(schema.properties.beforeCallEvent.properties.allowedKeys).toEqual({
|
|
140
|
-
bsonType: ["array", "null"],
|
|
141
|
-
items: { bsonType: "string" },
|
|
142
|
-
});
|
|
143
|
-
expect(schema.required).not.toContain("beforeCallEvent");
|
|
144
|
-
|
|
145
|
-
expect(schema.properties).toHaveProperty("afterCallEvent");
|
|
146
|
-
expect(schema.properties.afterCallEvent.bsonType).toEqual([
|
|
147
|
-
"string",
|
|
148
|
-
"null",
|
|
149
|
-
]);
|
|
150
|
-
expect(schema.required).not.toContain("afterCallEvent");
|
|
151
|
-
});
|
|
152
124
|
});
|
|
@@ -175,22 +175,6 @@ export const flowMongoSchema = {
|
|
|
175
175
|
additionalProperties: false,
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
|
-
beforeCallEvent: {
|
|
179
|
-
bsonType: ["object", "null"],
|
|
180
|
-
required: ["url"],
|
|
181
|
-
properties: {
|
|
182
|
-
url: { bsonType: "string" },
|
|
183
|
-
timeoutMs: { bsonType: ["number", "null"] },
|
|
184
|
-
sendUserAuthToken: { bsonType: ["bool", "null"] },
|
|
185
|
-
allowedKeys: {
|
|
186
|
-
bsonType: ["array", "null"],
|
|
187
|
-
items: { bsonType: "string" },
|
|
188
|
-
},
|
|
189
|
-
wait: { bsonType: ["bool", "null"] },
|
|
190
|
-
},
|
|
191
|
-
additionalProperties: false,
|
|
192
|
-
},
|
|
193
|
-
afterCallEvent: { bsonType: ["string", "null"] },
|
|
194
178
|
},
|
|
195
179
|
additionalProperties: false,
|
|
196
180
|
} as const;
|
|
@@ -167,14 +167,6 @@ export type InternalToolConfig = {
|
|
|
167
167
|
params?: Record<string, InternalToolParamConfig>;
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
export type BeforeCallEvent = {
|
|
171
|
-
url: string;
|
|
172
|
-
timeoutMs?: number;
|
|
173
|
-
sendUserAuthToken?: boolean;
|
|
174
|
-
allowedKeys?: string[];
|
|
175
|
-
wait?: boolean;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
170
|
/* ---------- The Flow object ---------- */
|
|
179
171
|
|
|
180
172
|
export type Flow = {
|
|
@@ -199,7 +191,6 @@ export type Flow = {
|
|
|
199
191
|
metaKeys?: MetaKey[] | null;
|
|
200
192
|
userProperties?: UserProperty[] | null;
|
|
201
193
|
tools?: FlowTool[];
|
|
202
|
-
beforeCallEvent?: BeforeCallEvent;
|
|
203
194
|
afterCallEvent?: string;
|
|
204
195
|
|
|
205
196
|
products?: string[];
|
|
@@ -10,7 +10,6 @@ export * from "./talkpilot/sessions";
|
|
|
10
10
|
export * from "./municipal/cities";
|
|
11
11
|
export * from "./municipal/departmentsSubjects";
|
|
12
12
|
export * from "./municipal/muniIssues";
|
|
13
|
-
export * from "./municipal/residents";
|
|
14
13
|
export * from "./municipal/streets";
|
|
15
14
|
export * from "./municipal/tickets";
|
|
16
15
|
export * from "./websitalk/scans";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from "./residents.getters";
|
|
2
|
-
export { RESIDENTS_COLLECTION } from "./residents.constants";
|
|
3
|
-
export { residentsJsonSchema, residentsIndexes } from "./residents.schema";
|
|
4
|
-
export type { Resident, ResidentDoc } from "./residents.types";
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/municipal/residents/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/municipal/residents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6DAA6D;AAApD,2HAAA,oBAAoB,OAAA;AAC7B,uDAA2E;AAAlE,uHAAA,mBAAmB,OAAA;AAAE,oHAAA,gBAAgB,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.constants.d.ts","sourceRoot":"","sources":["../../../src/municipal/residents/residents.constants.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,cAAc,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RESIDENTS_COLLECTION = void 0;
|
|
4
|
-
/** Mongo collection name for municipal resident records. */
|
|
5
|
-
exports.RESIDENTS_COLLECTION = "residents";
|
|
6
|
-
//# sourceMappingURL=residents.constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.constants.js","sourceRoot":"","sources":["../../../src/municipal/residents/residents.constants.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC/C,QAAA,oBAAoB,GAAG,WAAW,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Collection, Filter } from "mongodb";
|
|
2
|
-
import { CityName, Resident } from "../index";
|
|
3
|
-
export declare const getResidentsCollection: () => Collection<Resident>;
|
|
4
|
-
export declare const findResidents: (filter?: Filter<Resident>) => Promise<Resident[]>;
|
|
5
|
-
export declare const getResidentById: (residentId: string) => Promise<Resident | null>;
|
|
6
|
-
export declare const findResidentsByCityAndPhone: (cityName: CityName, phoneNumber: string) => Promise<Resident[]>;
|
|
7
|
-
export declare const getResidentByCityAndIdNumber: (cityName: CityName, idNumber: string) => Promise<Resident | null>;
|
|
8
|
-
export declare const getResidentByCityPhoneAndIdNumber: (cityName: CityName, phoneNumber: string, idNumber: string) => Promise<Resident | null>;
|
|
9
|
-
//# sourceMappingURL=residents.getters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.getters.d.ts","sourceRoot":"","sources":["../../../src/municipal/residents/residents.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAmB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAG/D,eAAO,MAAM,sBAAsB,QAAO,UAAU,CAAC,QAAQ,CAE5D,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,SAAQ,MAAM,CAAC,QAAQ,CAAM,KAC5B,OAAO,CAAC,QAAQ,EAAE,CAEpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,YAAY,MAAM,KACjB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAGzB,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,UAAU,QAAQ,EAClB,aAAa,MAAM,KAClB,OAAO,CAAC,QAAQ,EAAE,CAEpB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,UAAU,QAAQ,EAClB,UAAU,MAAM,KACf,OAAO,CAAC,QAAQ,GAAG,IAAI,CAEzB,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,UAAU,QAAQ,EAClB,aAAa,MAAM,EACnB,UAAU,MAAM,KACf,OAAO,CAAC,QAAQ,GAAG,IAAI,CAEzB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResidentByCityPhoneAndIdNumber = exports.getResidentByCityAndIdNumber = exports.findResidentsByCityAndPhone = exports.getResidentById = exports.findResidents = exports.getResidentsCollection = void 0;
|
|
4
|
-
const index_1 = require("../index");
|
|
5
|
-
const residents_constants_1 = require("./residents.constants");
|
|
6
|
-
const getResidentsCollection = () => {
|
|
7
|
-
return (0, index_1.getDb)().collection(residents_constants_1.RESIDENTS_COLLECTION);
|
|
8
|
-
};
|
|
9
|
-
exports.getResidentsCollection = getResidentsCollection;
|
|
10
|
-
const findResidents = async (filter = {}) => {
|
|
11
|
-
return (0, exports.getResidentsCollection)().find(filter).toArray();
|
|
12
|
-
};
|
|
13
|
-
exports.findResidents = findResidents;
|
|
14
|
-
const getResidentById = async (residentId) => {
|
|
15
|
-
if (!index_1.ObjectId.isValid(residentId))
|
|
16
|
-
return null;
|
|
17
|
-
return (0, exports.getResidentsCollection)().findOne({ _id: new index_1.ObjectId(residentId) });
|
|
18
|
-
};
|
|
19
|
-
exports.getResidentById = getResidentById;
|
|
20
|
-
const findResidentsByCityAndPhone = async (cityName, phoneNumber) => {
|
|
21
|
-
return (0, exports.getResidentsCollection)().find({ cityName, phoneNumber }).toArray();
|
|
22
|
-
};
|
|
23
|
-
exports.findResidentsByCityAndPhone = findResidentsByCityAndPhone;
|
|
24
|
-
const getResidentByCityAndIdNumber = async (cityName, idNumber) => {
|
|
25
|
-
return (0, exports.getResidentsCollection)().findOne({ cityName, idNumber });
|
|
26
|
-
};
|
|
27
|
-
exports.getResidentByCityAndIdNumber = getResidentByCityAndIdNumber;
|
|
28
|
-
const getResidentByCityPhoneAndIdNumber = async (cityName, phoneNumber, idNumber) => {
|
|
29
|
-
return (0, exports.getResidentsCollection)().findOne({ cityName, phoneNumber, idNumber });
|
|
30
|
-
};
|
|
31
|
-
exports.getResidentByCityPhoneAndIdNumber = getResidentByCityPhoneAndIdNumber;
|
|
32
|
-
//# sourceMappingURL=residents.getters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.getters.js","sourceRoot":"","sources":["../../../src/municipal/residents/residents.getters.ts"],"names":[],"mappings":";;;AACA,oCAA+D;AAC/D,+DAA6D;AAEtD,MAAM,sBAAsB,GAAG,GAAyB,EAAE;IAC/D,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAW,0CAAoB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAEK,MAAM,aAAa,GAAG,KAAK,EAChC,SAA2B,EAAE,EACR,EAAE;IACvB,OAAO,IAAA,8BAAsB,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB;AAEK,MAAM,eAAe,GAAG,KAAK,EAClC,UAAkB,EACQ,EAAE;IAC5B,IAAI,CAAC,gBAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,IAAA,8BAAsB,GAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,gBAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC;AALW,QAAA,eAAe,mBAK1B;AAEK,MAAM,2BAA2B,GAAG,KAAK,EAC9C,QAAkB,EAClB,WAAmB,EACE,EAAE;IACvB,OAAO,IAAA,8BAAsB,GAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5E,CAAC,CAAC;AALW,QAAA,2BAA2B,+BAKtC;AAEK,MAAM,4BAA4B,GAAG,KAAK,EAC/C,QAAkB,EAClB,QAAgB,EACU,EAAE;IAC5B,OAAO,IAAA,8BAAsB,GAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEK,MAAM,iCAAiC,GAAG,KAAK,EACpD,QAAkB,EAClB,WAAmB,EACnB,QAAgB,EACU,EAAE;IAC5B,OAAO,IAAA,8BAAsB,GAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AANW,QAAA,iCAAiC,qCAM5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.schema.d.ts","sourceRoot":"","sources":["../../../src/municipal/residents/residents.schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,mBAAmB,EAAE,QAYjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,gBAAgB,EAW9C,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.residentsIndexes = exports.residentsJsonSchema = void 0;
|
|
4
|
-
exports.residentsJsonSchema = {
|
|
5
|
-
bsonType: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
cityName: { bsonType: "string" },
|
|
8
|
-
firstName: { bsonType: "string" },
|
|
9
|
-
lastName: { bsonType: "string" },
|
|
10
|
-
idNumber: { bsonType: "string" },
|
|
11
|
-
phoneNumber: { bsonType: "string" },
|
|
12
|
-
address: { bsonType: "string" },
|
|
13
|
-
createdAt: { bsonType: "date" },
|
|
14
|
-
updatedAt: { bsonType: "date" },
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
exports.residentsIndexes = [
|
|
18
|
-
{ key: { cityName: 1, phoneNumber: 1 }, name: "cityName_1_phoneNumber_1" },
|
|
19
|
-
{
|
|
20
|
-
key: { cityName: 1, idNumber: 1 },
|
|
21
|
-
name: "cityName_1_idNumber_unique",
|
|
22
|
-
unique: true,
|
|
23
|
-
partialFilterExpression: {
|
|
24
|
-
cityName: { $type: "string" },
|
|
25
|
-
idNumber: { $type: "string" },
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
//# sourceMappingURL=residents.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.schema.js","sourceRoot":"","sources":["../../../src/municipal/residents/residents.schema.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAa;IAC3C,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAChC,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACjC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAChC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAChC,WAAW,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACnC,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAC/B,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;QAC/B,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;KAChC;CACF,CAAC;AAEW,QAAA,gBAAgB,GAAuB;IAClD,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE;IAC1E;QACE,GAAG,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE;QACjC,IAAI,EAAE,4BAA4B;QAClC,MAAM,EAAE,IAAI;QACZ,uBAAuB,EAAE;YACvB,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC7B,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;SAC9B;KACF;CACF,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ObjectId, WithId } from "mongodb";
|
|
2
|
-
import { CityName } from "../utils/types";
|
|
3
|
-
export type Resident = {
|
|
4
|
-
_id: ObjectId;
|
|
5
|
-
createdAt?: Date;
|
|
6
|
-
updatedAt?: Date;
|
|
7
|
-
cityName?: CityName;
|
|
8
|
-
firstName?: string;
|
|
9
|
-
lastName?: string;
|
|
10
|
-
idNumber?: string;
|
|
11
|
-
phoneNumber?: string;
|
|
12
|
-
address?: string;
|
|
13
|
-
};
|
|
14
|
-
export type ResidentDoc = WithId<Resident>;
|
|
15
|
-
//# sourceMappingURL=residents.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.types.d.ts","sourceRoot":"","sources":["../../../src/municipal/residents/residents.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,QAAQ,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.types.js","sourceRoot":"","sources":["../../../src/municipal/residents/residents.types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.utils.d.ts","sourceRoot":"","sources":["../../../src/talkpilot/subscriptions/subscriptions.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAA6B,MAAM,UAAU,CAAC;AAE7F,eAAO,MAAM,gBAAgB,GAAI,QAAQ,wBAAwB,KAAG,MAAM,CAAC,YAAY,CAetF,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildSimpleQuery = void 0;
|
|
4
|
-
const mongodb_1 = require("mongodb");
|
|
5
|
-
const index_1 = require("../index");
|
|
6
|
-
const buildSimpleQuery = (filter) => {
|
|
7
|
-
const query = {};
|
|
8
|
-
if (filter._id) {
|
|
9
|
-
query._id = new mongodb_1.ObjectId(filter._id);
|
|
10
|
-
}
|
|
11
|
-
index_1.simpleFields.forEach((field) => {
|
|
12
|
-
const val = filter[field];
|
|
13
|
-
if (val !== undefined) {
|
|
14
|
-
query[field] = val;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return query;
|
|
18
|
-
};
|
|
19
|
-
exports.buildSimpleQuery = buildSimpleQuery;
|
|
20
|
-
//# sourceMappingURL=subscriptions.utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.utils.js","sourceRoot":"","sources":["../../../src/talkpilot/subscriptions/subscriptions.utils.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAC3C,oCAA6F;AAEtF,MAAM,gBAAgB,GAAG,CAAC,MAAgC,EAAwB,EAAE;IACzF,MAAM,KAAK,GAAyB,EAAE,CAAC;IAEvC,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,KAAK,CAAC,GAAG,GAAG,IAAI,kBAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,oBAAY,CAAC,OAAO,CAAC,CAAC,KAAkB,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,KAAK,CAAC,KAAK,CAAC,GAAG,GAAU,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAfW,QAAA,gBAAgB,oBAe3B"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Factory } from "fishery";
|
|
2
|
-
import type { Resident } from "../../../municipal";
|
|
3
|
-
export declare const residentFactory: Factory<Resident, any, Resident, import("fishery").DeepPartialObject<Resident>>;
|
|
4
|
-
export declare function createResident(overrides?: Partial<Resident>): Resident;
|
|
5
|
-
//# sourceMappingURL=residents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.d.ts","sourceRoot":"","sources":["../../../../src/test-utils/factories/municipal/residents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,eAAe,iFAUzB,CAAC;AAEJ,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAEtE"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.residentFactory = void 0;
|
|
4
|
-
exports.createResident = createResident;
|
|
5
|
-
const fishery_1 = require("fishery");
|
|
6
|
-
const mongodb_1 = require("mongodb");
|
|
7
|
-
const faker_1 = require("@faker-js/faker");
|
|
8
|
-
exports.residentFactory = fishery_1.Factory.define(() => ({
|
|
9
|
-
_id: new mongodb_1.ObjectId(),
|
|
10
|
-
createdAt: new Date(),
|
|
11
|
-
updatedAt: new Date(),
|
|
12
|
-
cityName: faker_1.faker.location.city(),
|
|
13
|
-
firstName: faker_1.faker.person.firstName(),
|
|
14
|
-
lastName: faker_1.faker.person.lastName(),
|
|
15
|
-
idNumber: faker_1.faker.string.numeric(9),
|
|
16
|
-
phoneNumber: `+97250${faker_1.faker.string.numeric(7)}`,
|
|
17
|
-
address: faker_1.faker.location.streetAddress(),
|
|
18
|
-
}));
|
|
19
|
-
function createResident(overrides) {
|
|
20
|
-
return exports.residentFactory.build(overrides);
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=residents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"residents.js","sourceRoot":"","sources":["../../../../src/test-utils/factories/municipal/residents.ts"],"names":[],"mappings":";;;AAiBA,wCAEC;AAnBD,qCAAkC;AAClC,qCAAmC;AACnC,2CAAwC;AAG3B,QAAA,eAAe,GAAG,iBAAO,CAAC,MAAM,CAAW,GAAG,EAAE,CAAC,CAAC;IAC7D,GAAG,EAAE,IAAI,kBAAQ,EAAE;IACnB,SAAS,EAAE,IAAI,IAAI,EAAE;IACrB,SAAS,EAAE,IAAI,IAAI,EAAE;IACrB,QAAQ,EAAE,aAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;IAC/B,SAAS,EAAE,aAAK,CAAC,MAAM,CAAC,SAAS,EAAE;IACnC,QAAQ,EAAE,aAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;IACjC,QAAQ,EAAE,aAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACjC,WAAW,EAAE,SAAS,aAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;IAC/C,OAAO,EAAE,aAAK,CAAC,QAAQ,CAAC,aAAa,EAAE;CACxC,CAAC,CAAC,CAAC;AAEJ,SAAgB,cAAc,CAAC,SAA6B;IAC1D,OAAO,uBAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { ObjectId } from "mongodb";
|
|
2
|
-
import {
|
|
3
|
-
findResidentsByCityAndPhone,
|
|
4
|
-
getResidentByCityAndIdNumber,
|
|
5
|
-
getResidentByCityPhoneAndIdNumber,
|
|
6
|
-
getResidentById,
|
|
7
|
-
getResidentsCollection,
|
|
8
|
-
} from "../residents.getters";
|
|
9
|
-
import { createResident } from "../../../test-utils/factories/municipal/residents";
|
|
10
|
-
|
|
11
|
-
const CITY = "tests" as const;
|
|
12
|
-
const OTHER_CITY = "eilat" as const;
|
|
13
|
-
|
|
14
|
-
describe("residents getters", () => {
|
|
15
|
-
it("getResidentById returns the document, or null for a missing / invalid id", async () => {
|
|
16
|
-
const resident = createResident({ cityName: CITY });
|
|
17
|
-
await getResidentsCollection().insertOne(resident);
|
|
18
|
-
|
|
19
|
-
const found = await getResidentById(resident._id.toHexString());
|
|
20
|
-
expect(found?._id.equals(resident._id)).toBe(true);
|
|
21
|
-
expect(found?.idNumber).toBe(resident.idNumber);
|
|
22
|
-
|
|
23
|
-
expect(await getResidentById("not-an-id")).toBeNull();
|
|
24
|
-
expect(await getResidentById(new ObjectId().toHexString())).toBeNull();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("findResidentsByCityAndPhone returns only matching city + phone", async () => {
|
|
28
|
-
const phone = "+972501111111";
|
|
29
|
-
const match = createResident({ cityName: CITY, phoneNumber: phone });
|
|
30
|
-
const samePhoneOtherCity = createResident({
|
|
31
|
-
cityName: OTHER_CITY,
|
|
32
|
-
phoneNumber: phone,
|
|
33
|
-
});
|
|
34
|
-
const sameCityOtherPhone = createResident({
|
|
35
|
-
cityName: CITY,
|
|
36
|
-
phoneNumber: "+972502222222",
|
|
37
|
-
});
|
|
38
|
-
await getResidentsCollection().insertMany([
|
|
39
|
-
match,
|
|
40
|
-
samePhoneOtherCity,
|
|
41
|
-
sameCityOtherPhone,
|
|
42
|
-
]);
|
|
43
|
-
|
|
44
|
-
const found = await findResidentsByCityAndPhone(CITY, phone);
|
|
45
|
-
expect(found).toHaveLength(1);
|
|
46
|
-
expect(found[0]._id.equals(match._id)).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("allows a document with only _id", async () => {
|
|
50
|
-
const resident = { _id: new ObjectId() };
|
|
51
|
-
await getResidentsCollection().insertOne(resident);
|
|
52
|
-
|
|
53
|
-
const found = await getResidentById(resident._id.toHexString());
|
|
54
|
-
expect(found?._id.equals(resident._id)).toBe(true);
|
|
55
|
-
expect(found?.firstName).toBeUndefined();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("getResidentByCityAndIdNumber is scoped to the city", async () => {
|
|
59
|
-
const idNumber = "123456789";
|
|
60
|
-
const match = createResident({ cityName: CITY, idNumber });
|
|
61
|
-
const otherCity = createResident({ cityName: OTHER_CITY, idNumber: "987654321" });
|
|
62
|
-
await getResidentsCollection().insertMany([match, otherCity]);
|
|
63
|
-
|
|
64
|
-
const found = await getResidentByCityAndIdNumber(CITY, idNumber);
|
|
65
|
-
expect(found?._id.equals(match._id)).toBe(true);
|
|
66
|
-
|
|
67
|
-
expect(await getResidentByCityAndIdNumber(OTHER_CITY, idNumber)).toBeNull();
|
|
68
|
-
expect(await getResidentByCityAndIdNumber(CITY, "000000000")).toBeNull();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("getResidentByCityPhoneAndIdNumber requires both phone and id in that city", async () => {
|
|
72
|
-
const phone = "+972501111111";
|
|
73
|
-
const idNumber = "201111111";
|
|
74
|
-
const match = createResident({ cityName: CITY, phoneNumber: phone, idNumber });
|
|
75
|
-
const samePhoneWrongId = createResident({
|
|
76
|
-
cityName: CITY,
|
|
77
|
-
phoneNumber: phone,
|
|
78
|
-
idNumber: "209999999",
|
|
79
|
-
});
|
|
80
|
-
await getResidentsCollection().insertMany([match, samePhoneWrongId]);
|
|
81
|
-
|
|
82
|
-
const found = await getResidentByCityPhoneAndIdNumber(CITY, phone, idNumber);
|
|
83
|
-
expect(found?._id.equals(match._id)).toBe(true);
|
|
84
|
-
|
|
85
|
-
expect(
|
|
86
|
-
await getResidentByCityPhoneAndIdNumber(CITY, phone, "000000000"),
|
|
87
|
-
).toBeNull();
|
|
88
|
-
expect(
|
|
89
|
-
await getResidentByCityPhoneAndIdNumber(OTHER_CITY, phone, idNumber),
|
|
90
|
-
).toBeNull();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Collection, Filter } from "mongodb";
|
|
2
|
-
import { CityName, getDb, ObjectId, Resident } from "../index";
|
|
3
|
-
import { RESIDENTS_COLLECTION } from "./residents.constants";
|
|
4
|
-
|
|
5
|
-
export const getResidentsCollection = (): Collection<Resident> => {
|
|
6
|
-
return getDb().collection<Resident>(RESIDENTS_COLLECTION);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const findResidents = async (
|
|
10
|
-
filter: Filter<Resident> = {},
|
|
11
|
-
): Promise<Resident[]> => {
|
|
12
|
-
return getResidentsCollection().find(filter).toArray();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const getResidentById = async (
|
|
16
|
-
residentId: string,
|
|
17
|
-
): Promise<Resident | null> => {
|
|
18
|
-
if (!ObjectId.isValid(residentId)) return null;
|
|
19
|
-
return getResidentsCollection().findOne({ _id: new ObjectId(residentId) });
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const findResidentsByCityAndPhone = async (
|
|
23
|
-
cityName: CityName,
|
|
24
|
-
phoneNumber: string,
|
|
25
|
-
): Promise<Resident[]> => {
|
|
26
|
-
return getResidentsCollection().find({ cityName, phoneNumber }).toArray();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const getResidentByCityAndIdNumber = async (
|
|
30
|
-
cityName: CityName,
|
|
31
|
-
idNumber: string,
|
|
32
|
-
): Promise<Resident | null> => {
|
|
33
|
-
return getResidentsCollection().findOne({ cityName, idNumber });
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const getResidentByCityPhoneAndIdNumber = async (
|
|
37
|
-
cityName: CityName,
|
|
38
|
-
phoneNumber: string,
|
|
39
|
-
idNumber: string,
|
|
40
|
-
): Promise<Resident | null> => {
|
|
41
|
-
return getResidentsCollection().findOne({ cityName, phoneNumber, idNumber });
|
|
42
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Document, IndexDescription } from "mongodb";
|
|
2
|
-
|
|
3
|
-
export const residentsJsonSchema: Document = {
|
|
4
|
-
bsonType: "object",
|
|
5
|
-
properties: {
|
|
6
|
-
cityName: { bsonType: "string" },
|
|
7
|
-
firstName: { bsonType: "string" },
|
|
8
|
-
lastName: { bsonType: "string" },
|
|
9
|
-
idNumber: { bsonType: "string" },
|
|
10
|
-
phoneNumber: { bsonType: "string" },
|
|
11
|
-
address: { bsonType: "string" },
|
|
12
|
-
createdAt: { bsonType: "date" },
|
|
13
|
-
updatedAt: { bsonType: "date" },
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const residentsIndexes: IndexDescription[] = [
|
|
18
|
-
{ key: { cityName: 1, phoneNumber: 1 }, name: "cityName_1_phoneNumber_1" },
|
|
19
|
-
{
|
|
20
|
-
key: { cityName: 1, idNumber: 1 },
|
|
21
|
-
name: "cityName_1_idNumber_unique",
|
|
22
|
-
unique: true,
|
|
23
|
-
partialFilterExpression: {
|
|
24
|
-
cityName: { $type: "string" },
|
|
25
|
-
idNumber: { $type: "string" },
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ObjectId, WithId } from "mongodb";
|
|
2
|
-
|
|
3
|
-
import { CityName } from "../utils/types";
|
|
4
|
-
|
|
5
|
-
export type Resident = {
|
|
6
|
-
_id: ObjectId;
|
|
7
|
-
createdAt?: Date;
|
|
8
|
-
updatedAt?: Date;
|
|
9
|
-
cityName?: CityName;
|
|
10
|
-
firstName?: string;
|
|
11
|
-
lastName?: string;
|
|
12
|
-
idNumber?: string;
|
|
13
|
-
phoneNumber?: string;
|
|
14
|
-
address?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type ResidentDoc = WithId<Resident>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Factory } from "fishery";
|
|
2
|
-
import { ObjectId } from "mongodb";
|
|
3
|
-
import { faker } from "@faker-js/faker";
|
|
4
|
-
import type { Resident } from "../../../municipal";
|
|
5
|
-
|
|
6
|
-
export const residentFactory = Factory.define<Resident>(() => ({
|
|
7
|
-
_id: new ObjectId(),
|
|
8
|
-
createdAt: new Date(),
|
|
9
|
-
updatedAt: new Date(),
|
|
10
|
-
cityName: faker.location.city(),
|
|
11
|
-
firstName: faker.person.firstName(),
|
|
12
|
-
lastName: faker.person.lastName(),
|
|
13
|
-
idNumber: faker.string.numeric(9),
|
|
14
|
-
phoneNumber: `+97250${faker.string.numeric(7)}`,
|
|
15
|
-
address: faker.location.streetAddress(),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
export function createResident(overrides?: Partial<Resident>): Resident {
|
|
19
|
-
return residentFactory.build(overrides);
|
|
20
|
-
}
|