@servicetitan/acquisition-functions 0.10.0 → 0.11.0
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/dist/__tests__/assessorlastsaledate-converter.test.js +28 -40
- package/dist/__tests__/filter-fetcher.test.js +9 -9
- package/dist/__tests__/property-fix-use-group.test.js +18 -24
- package/dist/__tests__/setup.js +1 -3
- package/dist/filter-fetcher/index.js +1 -1
- package/dist/fix-property-use/index.js +1 -2
- package/dist/property-assessorlastsaledate-converter/index.js +1 -2
- package/dist/utils/utils.d.ts +1 -1
- package/package.json +3 -4
|
@@ -22,29 +22,23 @@ describe('property-assessorlastsaledate-converter', () => {
|
|
|
22
22
|
metadata = await assessorLastSaleDateProcessor.start('90001');
|
|
23
23
|
});
|
|
24
24
|
(0, globals_1.test)('should convert existing field to date', async () => {
|
|
25
|
-
const result = await
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
resolve(res);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
25
|
+
const result = await base
|
|
26
|
+
.collection('properties')
|
|
27
|
+
.find({
|
|
28
|
+
assessorlastsaledate: {
|
|
29
|
+
$exists: true,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.toArray();
|
|
36
33
|
(0, globals_1.expect)(result[0].assessorlastsaledate).toBeInstanceOf(Date);
|
|
37
34
|
});
|
|
38
35
|
(0, globals_1.test)('should not touch nulls', async () => {
|
|
39
|
-
const result = await
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
resolve(res);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
36
|
+
const result = await base
|
|
37
|
+
.collection('properties')
|
|
38
|
+
.find({
|
|
39
|
+
assessorlastsaledate: null,
|
|
40
|
+
})
|
|
41
|
+
.toArray();
|
|
48
42
|
(0, globals_1.expect)(result[0].assessorlastsaledate).toBe(null);
|
|
49
43
|
});
|
|
50
44
|
(0, globals_1.test)('should return metadata', async () => {
|
|
@@ -59,29 +53,23 @@ describe('property-assessorlastsaledate-converter', () => {
|
|
|
59
53
|
await (0, index_1.propertiesAssessorLastSaleDateAggregate)(base);
|
|
60
54
|
});
|
|
61
55
|
(0, globals_1.test)('should convert existing field to date', async () => {
|
|
62
|
-
const result = await
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
resolve(res);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
56
|
+
const result = await base
|
|
57
|
+
.collection('properties')
|
|
58
|
+
.find({
|
|
59
|
+
assessorlastsaledate: {
|
|
60
|
+
$exists: true,
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
.toArray();
|
|
73
64
|
(0, globals_1.expect)(result[0].assessorlastsaledate).toBeInstanceOf(Date);
|
|
74
65
|
});
|
|
75
66
|
(0, globals_1.test)('should not touch nulls', async () => {
|
|
76
|
-
const result = await
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
resolve(res);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
67
|
+
const result = await base
|
|
68
|
+
.collection('properties')
|
|
69
|
+
.find({
|
|
70
|
+
assessorlastsaledate: null,
|
|
71
|
+
})
|
|
72
|
+
.toArray();
|
|
85
73
|
(0, globals_1.expect)(result[0].assessorlastsaledate).toBe(null);
|
|
86
74
|
});
|
|
87
75
|
});
|
|
@@ -44,31 +44,31 @@ describe('property-assessorlastsaledate-converter', () => {
|
|
|
44
44
|
zipcode: '90001',
|
|
45
45
|
propertyusegroup: [
|
|
46
46
|
{
|
|
47
|
-
name: '
|
|
47
|
+
name: 'Commercial',
|
|
48
48
|
count: 2,
|
|
49
49
|
},
|
|
50
50
|
],
|
|
51
51
|
propertyusestandardized: [
|
|
52
52
|
{
|
|
53
|
-
name: '
|
|
54
|
-
groupName: '
|
|
53
|
+
name: 'Apartment house (5+ units)',
|
|
54
|
+
groupName: 'Commercial',
|
|
55
55
|
count: 1,
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
|
-
name: '
|
|
59
|
-
groupName: '
|
|
58
|
+
name: 'Auto repair, garage',
|
|
59
|
+
groupName: 'Commercial',
|
|
60
60
|
count: 1,
|
|
61
61
|
},
|
|
62
62
|
],
|
|
63
63
|
hvaccoolingdetail: [
|
|
64
64
|
{
|
|
65
|
-
name: '
|
|
65
|
+
name: 'Yes',
|
|
66
66
|
count: 1,
|
|
67
67
|
},
|
|
68
68
|
],
|
|
69
69
|
hvacheatingdetail: [
|
|
70
70
|
{
|
|
71
|
-
name: '
|
|
71
|
+
name: 'None',
|
|
72
72
|
count: 2,
|
|
73
73
|
},
|
|
74
74
|
],
|
|
@@ -83,8 +83,8 @@ describe('property-assessorlastsaledate-converter', () => {
|
|
|
83
83
|
});
|
|
84
84
|
(0, globals_1.expect)(result).not.toBe(null);
|
|
85
85
|
(0, globals_1.expect)(result?.propertyusegroup.length).toBe(1);
|
|
86
|
-
(0, globals_1.expect)(result?.propertyusegroup[0].name).toBe('
|
|
87
|
-
(0, globals_1.expect)(result?.propertyusestandardized.every(({ groupName }) => groupName === '
|
|
86
|
+
(0, globals_1.expect)(result?.propertyusegroup[0].name).toBe('Commercial');
|
|
87
|
+
(0, globals_1.expect)(result?.propertyusestandardized.every(({ groupName }) => groupName === 'Commercial')).toBeTruthy();
|
|
88
88
|
});
|
|
89
89
|
afterAll(async () => {
|
|
90
90
|
await (0, setup_1.closeConnection)();
|
|
@@ -26,18 +26,15 @@ describe('property-use-group-converter', () => {
|
|
|
26
26
|
(0, globals_1.expect)(metadata.properties).toBe(2);
|
|
27
27
|
(0, globals_1.expect)(metadata.requests).toBe(2);
|
|
28
28
|
});
|
|
29
|
-
(0, globals_1.test)('should convert existing field to
|
|
30
|
-
const result = await
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
resolve(res);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
29
|
+
(0, globals_1.test)('should convert existing field to capital-case', async () => {
|
|
30
|
+
const result = await base
|
|
31
|
+
.collection('properties')
|
|
32
|
+
.find({
|
|
33
|
+
propertyusegroup: {
|
|
34
|
+
$exists: true,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
.toArray();
|
|
41
38
|
(0, globals_1.expect)(result[0].propertyusegroup).toBe('COMMERCIAL');
|
|
42
39
|
(0, globals_1.expect)(result[1].propertyusegroup).toBe('COMMERCIAL');
|
|
43
40
|
});
|
|
@@ -46,19 +43,16 @@ describe('property-use-group-converter', () => {
|
|
|
46
43
|
(0, globals_1.beforeAll)(async () => {
|
|
47
44
|
await (0, setup_1.setupProperties)(base);
|
|
48
45
|
});
|
|
49
|
-
(0, globals_1.test)('should convert existing field to
|
|
46
|
+
(0, globals_1.test)('should convert existing field to capital-case', async () => {
|
|
50
47
|
await (0, index_1.propertyUseGroupProcessorAggregate)(base);
|
|
51
|
-
const result = await
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
resolve(res);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
48
|
+
const result = await base
|
|
49
|
+
.collection('properties')
|
|
50
|
+
.find({
|
|
51
|
+
propertyusegroup: {
|
|
52
|
+
$exists: true,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
.toArray();
|
|
62
56
|
(0, globals_1.expect)(result[0].propertyusegroup).toBe('COMMERCIAL');
|
|
63
57
|
(0, globals_1.expect)(result[1].propertyusegroup).toBe('COMMERCIAL');
|
|
64
58
|
});
|
package/dist/__tests__/setup.js
CHANGED
|
@@ -27,9 +27,7 @@ async function setupProperties(base) {
|
|
|
27
27
|
exports.setupProperties = setupProperties;
|
|
28
28
|
const url = `mongodb://${process.env.MONGO_HOSTNAME ?? 'localhost'}:27017`;
|
|
29
29
|
const mongoClient = new mongodb_1.MongoClient(url, {
|
|
30
|
-
|
|
31
|
-
useUnifiedTopology: true,
|
|
32
|
-
poolSize: 60,
|
|
30
|
+
maxPoolSize: 60,
|
|
33
31
|
});
|
|
34
32
|
let connectedMongoClient;
|
|
35
33
|
const openConnection = async () => {
|
|
@@ -25,12 +25,11 @@ function getPropertyUseGroupProcessor(db) {
|
|
|
25
25
|
const collection = await getPropertiesCollection(db);
|
|
26
26
|
const propQuery = properties.map(({ _id, ...p }) => ({
|
|
27
27
|
updateOne: {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
29
28
|
filter: { _id },
|
|
30
29
|
update: { $set: p },
|
|
31
30
|
},
|
|
32
31
|
}));
|
|
33
|
-
return collection.bulkWrite(propQuery, { ordered: true, w: 1 });
|
|
32
|
+
return collection.bulkWrite(propQuery, { ordered: true, writeConcern: { w: 1 } });
|
|
34
33
|
};
|
|
35
34
|
const getProperties = (zip) => {
|
|
36
35
|
return db
|
|
@@ -26,12 +26,11 @@ function getAssessorLastSaleDateProcessor(db) {
|
|
|
26
26
|
const collection = await getPropertiesCollection(db);
|
|
27
27
|
const propQuery = properties.map(({ _id, ...p }) => ({
|
|
28
28
|
updateOne: {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
30
29
|
filter: { _id },
|
|
31
30
|
update: { $set: p },
|
|
32
31
|
},
|
|
33
32
|
}));
|
|
34
|
-
return collection.bulkWrite(propQuery, { ordered: true, w: 1 });
|
|
33
|
+
return collection.bulkWrite(propQuery, { ordered: true, writeConcern: { w: 1 } });
|
|
35
34
|
};
|
|
36
35
|
return async function processZip(zip, errors) {
|
|
37
36
|
const meta = {
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -228,7 +228,7 @@ export declare const convertStringToDate: (props: Property[], propName: keyof Pr
|
|
|
228
228
|
buildingscount: number;
|
|
229
229
|
modifiedon: string;
|
|
230
230
|
location: string;
|
|
231
|
-
_id: import("bson").
|
|
231
|
+
_id: import("bson").ObjectId;
|
|
232
232
|
}[];
|
|
233
233
|
export declare function FilterNameValidator(filtersToIgnore: string[], unknownCharacter: string): {
|
|
234
234
|
isValidFilterName(filterName: string, checkIgnoredFilters?: boolean): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/acquisition-functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@jest/globals": "29.1.2",
|
|
17
17
|
"@types/jest": "^29.1.0",
|
|
18
|
-
"@types/mongodb": "^3.6.20",
|
|
19
18
|
"@types/node": "^18.6.3",
|
|
20
19
|
"jest": "29.1.2",
|
|
21
|
-
"mongodb": "
|
|
20
|
+
"mongodb": "~6.6.2",
|
|
22
21
|
"ts-jest": "29.0.3",
|
|
23
22
|
"ts-node": "^10.9.1"
|
|
24
23
|
},
|
|
@@ -28,5 +27,5 @@
|
|
|
28
27
|
"cli": {
|
|
29
28
|
"webpack": false
|
|
30
29
|
},
|
|
31
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f9ea8fb7e8b10f8d969e7afa52ffb9bb76de07b7"
|
|
32
31
|
}
|