@mountainpass/addressr 1.0.257 → 1.0.261
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 +50 -4
- package/lib/loader.js +3 -17
- package/lib/server.js +3 -17
- package/lib/service/address-service.js +39 -24
- package/lib/service/printVersion.js +3 -15
- package/lib/src/server2.js +3 -17
- package/lib/version.js +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,18 +1,64 @@
|
|
|
1
1
|
# Addressr
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
|
-
[Australian Address Validation, Search and Autocomplete](https://addressr.
|
|
5
|
+
[Australian Address Validation, Search and Autocomplete](https://addressr.io) - [addressr.io](https://addressr.io)
|
|
6
6
|
|
|
7
7
|
[](https://github.com/mountain-pass/addressr/blob/master/LICENSE) [](https://www.npmjs.com/package/@mountainpass/addressr) [](https://www.npmjs.com/package/@mountainpass/addressr) [](https://hub.docker.com/r/mountainpass/addressr) [](https://hub.docker.com/r/mountainpass/addressr)
|
|
8
8
|
|
|
9
9
|
[](https://circleci.com/gh/mountain-pass/addressr) [](https://codeclimate.com/github/mountain-pass/addressr/maintainability) [](https://codeclimate.com/github/mountain-pass/addressr/test_coverage)
|
|
10
10
|
|
|
11
|
-
[](https://github.com/mountain-pass/addressr/issues) [](https://github.com/mountain-pass/addressr/pulls) [](https://libraries.io/npm/@mountainpass%2Faddressr)
|
|
11
|
+
[](https://github.com/mountain-pass/addressr/issues) [](https://github.com/mountain-pass/addressr/pulls) [](https://libraries.io/npm/@mountainpass%2Faddressr) [](https://gitter.im/mountainpass-addressr/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
12
|
+
|
|
13
|
+
[](https://gitter.im/mountainpass-addressr/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# About
|
|
19
|
+
|
|
20
|
+
Australian Address Validation, Search and Autocomplete
|
|
21
|
+
|
|
22
|
+
## Australian Data Source
|
|
23
|
+
|
|
24
|
+
Addresses validated against the Geocoded National Address File (referred to as G-NAF), Australia’s **authoritative** address file.
|
|
25
|
+
|
|
26
|
+
## Software As or **NOT** As A Service
|
|
27
|
+
|
|
28
|
+
We love SaaS, but we know its not for everyone. SaaS or self hosted, we've got you covered.
|
|
29
|
+
|
|
30
|
+
## Always Up-To-Date
|
|
31
|
+
|
|
32
|
+
Addressr automatically updates with the latest data, so you're never out-of-date.
|
|
33
|
+
|
|
34
|
+
## Real-time Address Validation
|
|
35
|
+
|
|
36
|
+
Add address autocomplete, search and validation to your forms.
|
|
37
|
+
|
|
38
|
+
## Easy To Use API
|
|
39
|
+
|
|
40
|
+
Build your solution quickly, with our straightforward API.
|
|
41
|
+
|
|
42
|
+
## Run On Your Own Infrastructure or Use Ours
|
|
43
|
+
|
|
44
|
+
On-premise or in the cloud, run Addressr on your own infrastructure, or leave all the hard work to us.
|
|
45
|
+
|
|
46
|
+
## Completely Free or Pay for Support
|
|
47
|
+
|
|
48
|
+
That's right, Addressr is completely free **Forever**.
|
|
49
|
+
Or for peace of mind for your mission critical solutions, get commercial support you can truly rely on.
|
|
12
50
|
|
|
13
51
|
# ToC
|
|
14
52
|
|
|
15
53
|
- [Addressr](#addressr)
|
|
54
|
+
- [About](#about)
|
|
55
|
+
- [Australian Data Source](#australian-data-source)
|
|
56
|
+
- [Software As or **NOT** As A Service](#software-as-or-not-as-a-service)
|
|
57
|
+
- [Always Up-To-Date](#always-up-to-date)
|
|
58
|
+
- [Real-time Address Validation](#real-time-address-validation)
|
|
59
|
+
- [Easy To Use API](#easy-to-use-api)
|
|
60
|
+
- [Run On Your Own Infrastructure or Use Ours](#run-on-your-own-infrastructure-or-use-ours)
|
|
61
|
+
- [Completely Free or Pay for Support](#completely-free-or-pay-for-support)
|
|
16
62
|
- [ToC](#toc)
|
|
17
63
|
- [Quick Start](#quick-start)
|
|
18
64
|
- [Self Hosted](#self-hosted)
|
|
@@ -97,7 +143,7 @@
|
|
|
97
143
|
|
|
98
144
|
## How it Works
|
|
99
145
|
|
|
100
|
-

|
|
101
147
|
|
|
102
148
|
## Additional Settings
|
|
103
149
|
|
package/lib/loader.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _cfonts = require("cfonts");
|
|
4
|
-
|
|
5
|
-
var _cfonts2 = _interopRequireDefault(_cfonts);
|
|
6
|
-
|
|
7
3
|
var _debug = require("debug");
|
|
8
4
|
|
|
9
5
|
var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -27,19 +23,9 @@ const start = process.hrtime();
|
|
|
27
23
|
(0, _elasticsearch.esConnect)().then(() => {
|
|
28
24
|
logger('es client connected');
|
|
29
25
|
}).then(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
colors: ['yellowBright', 'cyan'],
|
|
34
|
-
background: 'transparent',
|
|
35
|
-
letterSpacing: 1,
|
|
36
|
-
lineHeight: 1,
|
|
37
|
-
space: true,
|
|
38
|
-
maxLength: '0'
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
_cfonts2.default.say('Addressr|Data|Loader', bannerOptions);
|
|
42
|
-
|
|
26
|
+
console.log('======================');
|
|
27
|
+
console.log('Addressr - Data Loader');
|
|
28
|
+
console.log('======================');
|
|
43
29
|
(0, _printVersion.printVersion)();
|
|
44
30
|
}).then(_addressService.loadGnaf).then(() => {
|
|
45
31
|
logger('data loaded');
|
package/lib/server.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _cfonts = require("cfonts");
|
|
4
|
-
|
|
5
|
-
var _cfonts2 = _interopRequireDefault(_cfonts);
|
|
6
|
-
|
|
7
3
|
var _debug = require("debug");
|
|
8
4
|
|
|
9
5
|
var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -24,19 +20,9 @@ const logger = (0, _debug2.default)('api');
|
|
|
24
20
|
logger('es client connected');
|
|
25
21
|
});
|
|
26
22
|
p1.then(() => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
colors: ['yellowBright', 'cyan'],
|
|
31
|
-
background: 'transparent',
|
|
32
|
-
letterSpacing: 1,
|
|
33
|
-
lineHeight: 1,
|
|
34
|
-
space: true,
|
|
35
|
-
maxLength: '0'
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
_cfonts2.default.say('Addressr|API|Server', bannerOptions);
|
|
39
|
-
|
|
23
|
+
console.log('=====================');
|
|
24
|
+
console.log('Addressr - API Server');
|
|
25
|
+
console.log('=====================');
|
|
40
26
|
(0, _printVersion.printVersion)();
|
|
41
27
|
});
|
|
42
28
|
});
|
|
@@ -68,6 +68,10 @@ var _crypto = require("crypto");
|
|
|
68
68
|
|
|
69
69
|
var _crypto2 = _interopRequireDefault(_crypto);
|
|
70
70
|
|
|
71
|
+
var _globPromise = require("glob-promise");
|
|
72
|
+
|
|
73
|
+
var _globPromise2 = _interopRequireDefault(_globPromise);
|
|
74
|
+
|
|
71
75
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
72
76
|
|
|
73
77
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
@@ -498,6 +502,19 @@ function mapStreetLocality(l, context) {
|
|
|
498
502
|
}
|
|
499
503
|
|
|
500
504
|
function mapGeo(geoSite, context, geoDefault) {
|
|
505
|
+
let foundDefault = false;
|
|
506
|
+
|
|
507
|
+
if (geoSite && geoDefault) {
|
|
508
|
+
geoSite.forEach(geo => {
|
|
509
|
+
if (geo.GEOCODE_TYPE_CODE === geoDefault[0].GEOCODE_TYPE_CODE && geo.LATITUDE === geoDefault[0].LATITUDE && geo.LONGITUDE === geoDefault[0].LONGITUDE) {
|
|
510
|
+
foundDefault = true;
|
|
511
|
+
geo.default = true;
|
|
512
|
+
} else {
|
|
513
|
+
geo.default = false;
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
501
518
|
const sites = geoSite ? geoSite.map(geo => {
|
|
502
519
|
if (geo.BOUNDARY_EXTENT !== '') {
|
|
503
520
|
console.log('be', geo);
|
|
@@ -520,7 +537,7 @@ function mapGeo(geoSite, context, geoDefault) {
|
|
|
520
537
|
}
|
|
521
538
|
|
|
522
539
|
return {
|
|
523
|
-
default: false,
|
|
540
|
+
default: geo.default || false,
|
|
524
541
|
...(geo.GEOCODE_TYPE_CODE !== '' && {
|
|
525
542
|
type: {
|
|
526
543
|
code: geo.GEOCODE_TYPE_CODE,
|
|
@@ -544,7 +561,7 @@ function mapGeo(geoSite, context, geoDefault) {
|
|
|
544
561
|
})
|
|
545
562
|
};
|
|
546
563
|
}) : [];
|
|
547
|
-
const def = geoDefault ? geoDefault.map(geo => {
|
|
564
|
+
const def = geoDefault && !foundDefault ? geoDefault.map(geo => {
|
|
548
565
|
return {
|
|
549
566
|
default: true,
|
|
550
567
|
...(geo.GEOCODE_TYPE_CODE !== '' && {
|
|
@@ -685,7 +702,7 @@ function mapAddressDetails(d, context, i, count) {
|
|
|
685
702
|
...(d.NUMBER_FIRST_SUFFIX !== '' && {
|
|
686
703
|
suffix: d.NUMBER_FIRST_SUFFIX
|
|
687
704
|
}),
|
|
688
|
-
...(d.NUMBER_LAST_PREFIX !== ''
|
|
705
|
+
...((d.NUMBER_LAST_PREFIX !== '' || d.NUMBER_LAST !== '' || d.NUMBER_LAST_SUFFIX !== '') && {
|
|
689
706
|
last: { ...(d.NUMBER_LAST_PREFIX !== '' && {
|
|
690
707
|
prefix: d.NUMBER_LAST_PREFIX
|
|
691
708
|
}),
|
|
@@ -772,8 +789,7 @@ function mapAddressDetails(d, context, i, count) {
|
|
|
772
789
|
if (rval.structured.flat != undefined) {
|
|
773
790
|
rval.smla = mapToShortMla(rval.structured);
|
|
774
791
|
rval.ssla = mapToSla(rval.smla);
|
|
775
|
-
}
|
|
776
|
-
|
|
792
|
+
}
|
|
777
793
|
|
|
778
794
|
if (count) {
|
|
779
795
|
if (i % Math.ceil(count / 100) === 0) {
|
|
@@ -873,8 +889,8 @@ async function loadAddressDetails(file, expectedCount, context, {
|
|
|
873
889
|
// error('refresh error', err);
|
|
874
890
|
// });
|
|
875
891
|
},
|
|
876
|
-
error: (
|
|
877
|
-
error(
|
|
892
|
+
error: (_error, file) => {
|
|
893
|
+
error(_error, file);
|
|
878
894
|
reject();
|
|
879
895
|
}
|
|
880
896
|
});
|
|
@@ -1074,7 +1090,8 @@ const {
|
|
|
1074
1090
|
} = require('fs').promises;
|
|
1075
1091
|
|
|
1076
1092
|
async function getFiles(currentDir, baseDir) {
|
|
1077
|
-
const dir = resolve(baseDir, currentDir);
|
|
1093
|
+
const dir = _path2.default.resolve(baseDir, currentDir);
|
|
1094
|
+
|
|
1078
1095
|
logger(`reading ${dir} (${currentDir} in ${baseDir})`);
|
|
1079
1096
|
const dirents = await readdir(dir, {
|
|
1080
1097
|
withFileTypes: true
|
|
@@ -1444,23 +1461,21 @@ async function loadGnaf({
|
|
|
1444
1461
|
throw new Error(`Data dir '${unzipped}' is empty`);
|
|
1445
1462
|
}
|
|
1446
1463
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
});
|
|
1454
|
-
} else if (contents.includes('Counts.csv')) {
|
|
1455
|
-
// feb20 doesn't have an intermediate directory
|
|
1456
|
-
const mainDirectory = unzipped;
|
|
1457
|
-
logger('2. Main Data dir', mainDirectory);
|
|
1458
|
-
await loadGnafData(mainDirectory, {
|
|
1459
|
-
refresh
|
|
1460
|
-
});
|
|
1461
|
-
} else {
|
|
1462
|
-
throw new Error(`Data dir '${unzipped}' has unexpected contents: ${contents}`);
|
|
1464
|
+
const gnafDir = await (0, _globPromise2.default)('**/G-NAF/', {
|
|
1465
|
+
cwd: unzipped
|
|
1466
|
+
});
|
|
1467
|
+
console.log(gnafDir);
|
|
1468
|
+
|
|
1469
|
+
if (gnafDir.length === 0) {
|
|
1470
|
+
throw new Error(`Cannot find 'G-NAF' directory in Data dir '${unzipped}'`);
|
|
1463
1471
|
}
|
|
1472
|
+
|
|
1473
|
+
const mainDirectory = _path2.default.dirname(`${unzipped}/${gnafDir[0].slice(0, -1)}`);
|
|
1474
|
+
|
|
1475
|
+
logger('Main Data dir', mainDirectory);
|
|
1476
|
+
await loadGnafData(mainDirectory, {
|
|
1477
|
+
refresh
|
|
1478
|
+
});
|
|
1464
1479
|
}
|
|
1465
1480
|
/**
|
|
1466
1481
|
* Get Addresses
|
|
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.printVersion = printVersion;
|
|
7
7
|
|
|
8
|
-
var _cfonts = require("cfonts");
|
|
9
|
-
|
|
10
|
-
var _cfonts2 = _interopRequireDefault(_cfonts);
|
|
11
|
-
|
|
12
8
|
var _dotenv = require("dotenv");
|
|
13
9
|
|
|
14
10
|
var _dotenv2 = _interopRequireDefault(_dotenv);
|
|
@@ -20,15 +16,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
16
|
_dotenv2.default.config();
|
|
21
17
|
|
|
22
18
|
function printVersion() {
|
|
23
|
-
const smallBannerOptions = {
|
|
24
|
-
font: 'console',
|
|
25
|
-
align: 'center',
|
|
26
|
-
colors: ['yellowBright', 'blue'],
|
|
27
|
-
background: 'blue',
|
|
28
|
-
letterSpacing: 0,
|
|
29
|
-
lineHeight: 0,
|
|
30
|
-
space: true
|
|
31
|
-
};
|
|
32
19
|
let environment = process.env.NODE_ENV || 'development';
|
|
33
20
|
|
|
34
21
|
if (environment === 'development') {
|
|
@@ -36,6 +23,7 @@ function printVersion() {
|
|
|
36
23
|
}
|
|
37
24
|
|
|
38
25
|
const port = process.env.PORT || 8080;
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
console.log(`Version: ${_version.version}`);
|
|
27
|
+
console.log(`NODE_ENV: ${environment}`);
|
|
28
|
+
console.log(`PORT: ${port}`);
|
|
41
29
|
}
|
package/lib/src/server2.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _cfonts = require("cfonts");
|
|
4
|
-
|
|
5
|
-
var _cfonts2 = _interopRequireDefault(_cfonts);
|
|
6
|
-
|
|
7
3
|
var _debug = require("debug");
|
|
8
4
|
|
|
9
5
|
var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -26,19 +22,9 @@ const logger = (0, _debug2.default)('api');
|
|
|
26
22
|
logger('es client connected');
|
|
27
23
|
});
|
|
28
24
|
p1.then(() => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
colors: ['yellowBright', 'cyan'],
|
|
33
|
-
background: 'transparent',
|
|
34
|
-
letterSpacing: 1,
|
|
35
|
-
lineHeight: 1,
|
|
36
|
-
space: true,
|
|
37
|
-
maxLength: '0'
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
_cfonts2.default.say('Addressr|API|Server 2', bannerOptions);
|
|
41
|
-
|
|
25
|
+
console.log('=======================');
|
|
26
|
+
console.log('Addressr - API Server 2');
|
|
27
|
+
console.log('=======================');
|
|
42
28
|
(0, _printVersion.printVersion)();
|
|
43
29
|
});
|
|
44
30
|
});
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mountainpass/addressr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.261",
|
|
4
4
|
"description": "Australian Address Validation, Search and Autocomplete",
|
|
5
5
|
"author": "Mountain Pass <addressr@mountain-pass.com.au>",
|
|
6
6
|
"contributors": [
|
|
@@ -99,7 +99,9 @@
|
|
|
99
99
|
"dopublish": "npm publish mountainpass-addressr-${npm_package_version}.tgz --access public",
|
|
100
100
|
"predocker:push": "echo \"$DOCKER_ID_PASS\" | docker login --username \"$DOCKER_ID_USER\" --password-stdin",
|
|
101
101
|
"docker:push": "docker push \"mountainpass/addressr:${npm_package_version}\"",
|
|
102
|
-
"postdocker:push": "docker push \"mountainpass/addressr:latest\""
|
|
102
|
+
"postdocker:push": "docker push \"mountainpass/addressr:latest\"",
|
|
103
|
+
"check-licenses": "license-checker --production --onlyAllow 'MIT;Apache-2.0;ISC;Custom: http://github.com/substack/node-bufferlist;Unlicense;BSD-2-Clause;BSD-3-Clause;WTFPL;0BSD;MIT*' --summary",
|
|
104
|
+
"pre-commit": "lint-staged && npm run check-licenses"
|
|
103
105
|
},
|
|
104
106
|
"bin": {
|
|
105
107
|
"addressr-loader": "lib/bin/addressr-loader.js",
|
|
@@ -129,13 +131,14 @@
|
|
|
129
131
|
"license": "Apache-2.0",
|
|
130
132
|
"private": false,
|
|
131
133
|
"dependencies": {
|
|
132
|
-
"@elastic/elasticsearch": "^7.
|
|
134
|
+
"@elastic/elasticsearch": "^7.15.0",
|
|
133
135
|
"@mountainpass/waycharter": "^1.0.68",
|
|
134
|
-
"cfonts": "^2.4.4",
|
|
135
136
|
"debug": "^4.1.1",
|
|
136
137
|
"directory-exists": "^2.0.1",
|
|
137
138
|
"dotenv": "^10.0.0",
|
|
138
139
|
"express": "^4.17.1",
|
|
140
|
+
"glob": "^7.1.7",
|
|
141
|
+
"glob-promise": "^4.2.0",
|
|
139
142
|
"got": "^9.6.0",
|
|
140
143
|
"http-link-header": "1.0.2",
|
|
141
144
|
"js-yaml": "^3.3.0",
|
|
@@ -188,6 +191,7 @@
|
|
|
188
191
|
"imagemin-lint-staged": "^0.4.0",
|
|
189
192
|
"istanbul": "^0.4.5",
|
|
190
193
|
"istanbul-middleware": "^0.2.2",
|
|
194
|
+
"license-checker": "^25.0.1",
|
|
191
195
|
"lint-staged": "^11.0.0",
|
|
192
196
|
"ngrok": "^4.0.1",
|
|
193
197
|
"nodemon": "^2.0.4",
|
|
@@ -225,7 +229,7 @@
|
|
|
225
229
|
},
|
|
226
230
|
"husky": {
|
|
227
231
|
"hooks": {
|
|
228
|
-
"pre-commit": "
|
|
232
|
+
"pre-commit": "npm run pre-commit"
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
}
|