@mountainpass/addressr 1.0.268 → 1.1.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/README.md CHANGED
@@ -165,6 +165,12 @@ Or for peace of mind for your mission critical solutions, get commercial support
165
165
  | ELASTIC_PASSWORD | _blank_ | Connect to open search without authentication | ✅ |
166
166
  | ELASTIC_PASSWORD | _non-blank_ | Connect to open search with the specified password | |
167
167
  | PAGE_SIZE | 8 | Number or records to return in a search | ✅ |
168
+ | ADDRESSR_ACCESS_CONTROL_ALLOW_ORIGIN | _blank_ | An `Access-Control-Allow-Origin` response header is **not** returned | ✅ |
169
+ | ADDRESSR_ACCESS_CONTROL_ALLOW_ORIGIN | _non-blank_ | An `Access-Control-Allow-Origin` response header is returned with the value in the environment variable | |
170
+ | ADDRESSR_ACCESS_CONTROL_EXPOSE_HEADERS | _blank_ | An `Access-Control-Expose-Headers` response header is **not** returned | ✅ |
171
+ | ADDRESSR_ACCESS_CONTROL_EXPOSE_HEADERS | _non-blank_ | An `Access-Control-Expose-Headers` response header is returned with the value in the environment variable | |
172
+ | ADDRESSR_ACCESS_CONTROL_ALLOW_HEADERS | _blank_ | An `Access-Control-Allow-Headers` response header is **not** returned | ✅ |
173
+ | ADDRESSR_ACCESS_CONTROL_ALLOW_HEADERS | _non-blank_ | An `Access-Control-Allow-Headers` response header is returned with the value in the environment variable | |
168
174
 
169
175
  NOTE: When adjusting PAGE_SIZE, you should take into account how quickly you want the initial results returned to the user. In many use cases, you want this to be as fast as possible. If you need show more results to the user, you are often better off leaving it a 8 and using the paging links to get more results while you are displaying the first 8.
170
176
 
@@ -364,7 +364,7 @@ async function unzipFile(file) {
364
364
  // }
365
365
 
366
366
 
367
- function levelTypeCodeToName(code, context) {
367
+ function levelTypeCodeToName(code, context, address) {
368
368
  const found = context['Authority_Code_LEVEL_TYPE_AUT_psv'].find(entry => entry.CODE === code);
369
369
 
370
370
  if (found) {
@@ -372,10 +372,13 @@ function levelTypeCodeToName(code, context) {
372
372
  }
373
373
 
374
374
  error(`Unknown Level Type Code: '${code}'`);
375
+ error({
376
+ address
377
+ });
375
378
  return;
376
379
  }
377
380
 
378
- function flatTypeCodeToName(code, context) {
381
+ function flatTypeCodeToName(code, context, address) {
379
382
  const found = context['Authority_Code_FLAT_TYPE_AUT_psv'].find(entry => entry.CODE === code);
380
383
 
381
384
  if (found) {
@@ -383,6 +386,9 @@ function flatTypeCodeToName(code, context) {
383
386
  }
384
387
 
385
388
  error(`Unknown Flat Type Code: '${code}'`);
389
+ error({
390
+ address
391
+ });
386
392
  return;
387
393
  }
388
394
 
@@ -720,7 +726,7 @@ function mapAddressDetails(d, context, i, count) {
720
726
  level: { ...(d.LEVEL_TYPE_CODE !== '' && {
721
727
  type: {
722
728
  code: d.LEVEL_TYPE_CODE,
723
- name: levelTypeCodeToName(d.LEVEL_TYPE_CODE, context)
729
+ name: levelTypeCodeToName(d.LEVEL_TYPE_CODE, context, d)
724
730
  }
725
731
  }),
726
732
  ...(d.LEVEL_NUMBER_PREFIX !== '' && {
@@ -738,7 +744,7 @@ function mapAddressDetails(d, context, i, count) {
738
744
  flat: { ...(d.FLAT_TYPE_CODE !== '' && {
739
745
  type: {
740
746
  code: d.FLAT_TYPE_CODE,
741
- name: flatTypeCodeToName(d.FLAT_TYPE_CODE, context)
747
+ name: flatTypeCodeToName(d.FLAT_TYPE_CODE, context, d)
742
748
  }
743
749
  }),
744
750
  ...(d.FLAT_NUMBER_PREFIX !== '' && {
@@ -821,45 +827,48 @@ async function loadAddressDetails(file, expectedCount, context, {
821
827
 
822
828
  if (chunk.errors.length > 0) {
823
829
  error(`Errors reading '${file}': ${chunk.errors}`);
824
- } else {
825
- const indexingBody = [];
826
- chunk.data.forEach(row => {
827
- const item = mapAddressDetails(row, context, actualCount, expectedCount);
828
- items.push(item);
829
- actualCount += 1;
830
- indexingBody.push({
831
- index: {
832
- _index: ES_INDEX_NAME,
833
- _id: `/addresses/${item.pid}`
834
- }
835
- });
836
- const {
837
- sla,
838
- ssla,
839
- ...structured
840
- } = item;
841
- indexingBody.push({
842
- sla,
843
- ssla,
844
- structured,
845
- confidence: structured.structured.confidence
846
- });
830
+ error({
831
+ errors: chunk.errors
847
832
  });
833
+ }
848
834
 
849
- if (indexingBody.length > 0) {
850
- sendIndexRequest(indexingBody, undefined, {
851
- refresh
852
- }).then(() => {
853
- parser.resume();
854
- return;
855
- }).catch(error_ => {
856
- error('error sending index request', error_);
857
- throw error_;
858
- });
859
- } else {
860
- // nothing to process. Have reached end of file.
835
+ const indexingBody = [];
836
+ chunk.data.forEach(row => {
837
+ const item = mapAddressDetails(row, context, actualCount, expectedCount);
838
+ items.push(item);
839
+ actualCount += 1;
840
+ indexingBody.push({
841
+ index: {
842
+ _index: ES_INDEX_NAME,
843
+ _id: `/addresses/${item.pid}`
844
+ }
845
+ });
846
+ const {
847
+ sla,
848
+ ssla,
849
+ ...structured
850
+ } = item;
851
+ indexingBody.push({
852
+ sla,
853
+ ssla,
854
+ structured,
855
+ confidence: structured.structured.confidence
856
+ });
857
+ });
858
+
859
+ if (indexingBody.length > 0) {
860
+ sendIndexRequest(indexingBody, undefined, {
861
+ refresh
862
+ }).then(() => {
861
863
  parser.resume();
862
- }
864
+ return;
865
+ }).catch(error_ => {
866
+ error('error sending index request', error_);
867
+ throw error_;
868
+ });
869
+ } else {
870
+ // nothing to process. Have reached end of file.
871
+ parser.resume();
863
872
  }
864
873
  },
865
874
  // step: function(row) {
@@ -1232,10 +1241,13 @@ async function loadFileCounts(countsFile) {
1232
1241
  step: function (row) {
1233
1242
  if (row.errors.length > 0) {
1234
1243
  error(`Errors reading '${countsFile}': ${row.errors}`);
1235
- } else {
1236
- const psvFile = row.data.File.replace(/\\/g, '/').replace(/\.zip$/, '.psv');
1237
- filesCounts[psvFile] = row.data.Count;
1244
+ error({
1245
+ errors: row.errors
1246
+ });
1238
1247
  }
1248
+
1249
+ const psvFile = row.data.File.replace(/\\/g, '/').replace(/\.zip$/, '.psv');
1250
+ filesCounts[psvFile] = row.data.Count;
1239
1251
  },
1240
1252
  complete: function () {
1241
1253
  console.log('GNAF data loaded');
@@ -1333,6 +1345,9 @@ async function loadSiteGeo(files, directory, state, loadContext, filesCounts) {
1333
1345
 
1334
1346
  if (chunk.errors.length > 0) {
1335
1347
  error(`Errors reading '${directory}/${geoFile}': ${chunk.errors}`);
1348
+ error({
1349
+ errors: chunk.errors
1350
+ });
1336
1351
  } else {
1337
1352
  chunk.data.forEach(row => {
1338
1353
  if (expectedCount) {
@@ -1385,6 +1400,9 @@ async function loadDefaultGeo(files, directory, state, loadContext, filesCounts)
1385
1400
 
1386
1401
  if (chunk.errors.length > 0) {
1387
1402
  error(`Errors reading '${directory}/${geoFile}': ${chunk.errors}`);
1403
+ error({
1404
+ errors: chunk.errors
1405
+ });
1388
1406
  } else {
1389
1407
  chunk.data.forEach(row => {
1390
1408
  if (expectedCount) {
@@ -50,6 +50,10 @@ function startRest2Server() {
50
50
  response.append('Access-Control-Expose-Headers', process.env.ADDRESSR_ACCESS_CONTROL_EXPOSE_HEADERS);
51
51
  }
52
52
 
53
+ if (process.env.ADDRESSR_ACCESS_CONTROL_ALLOW_HEADERS !== undefined) {
54
+ response.append('Access-Control-Allow-Headers', process.env.ADDRESSR_ACCESS_CONTROL_ALLOW_HEADERS);
55
+ }
56
+
53
57
  next();
54
58
  });
55
59
  const waycharter = new _waycharter.WayCharter();
package/lib/swagger.js CHANGED
@@ -112,6 +112,10 @@ function startServer() {
112
112
  response.append('Access-Control-Expose-Headers', process.env.ADDRESSR_ACCESS_CONTROL_EXPOSE_HEADERS);
113
113
  }
114
114
 
115
+ if (process.env.ADDRESSR_ACCESS_CONTROL_ALLOW_HEADERS !== undefined) {
116
+ response.append('Access-Control-Allow-Headers', process.env.ADDRESSR_ACCESS_CONTROL_ALLOW_HEADERS);
117
+ }
118
+
115
119
  next();
116
120
  });
117
121
  return swaggerInit().then(({
package/lib/version.js CHANGED
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  // generated by genversion
7
- const version = exports.version = '1.0.268';
7
+ const version = exports.version = '1.1.0';
package/package.json CHANGED
@@ -1,21 +1,31 @@
1
1
  {
2
2
  "name": "@mountainpass/addressr",
3
- "version": "1.0.268",
3
+ "version": "1.1.0",
4
4
  "description": "Australian Address Validation, Search and Autocomplete",
5
- "author": "Mountain Pass <addressr@mountain-pass.com.au>",
5
+ "author": {
6
+ "name": "Mountain Pass",
7
+ "url": "https://mountain-pass.com.au"
8
+ },
6
9
  "contributors": [
7
10
  "Tom Howard <tom@mountain-pass.com.au>"
8
11
  ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
9
15
  "engines": {
10
16
  "node": ">=14.21.2"
11
17
  },
12
18
  "config": {
13
- "localport": "6060"
19
+ "localport": "6060",
20
+ "SEARCH_IMAGE": "opensearchproject/opensearch:1.2.4"
14
21
  },
15
22
  "scripts": {
16
- "docs:build": "log4brains build",
17
- "docs:preview": "log4brains preview",
18
- "deploy": "deploy/deploy.sh",
23
+ "turbo:build": "turbo run build",
24
+ "turbo:ci:version": "turbo run ci:version",
25
+ "turbo:ci:publish": "turbo run ci:publish",
26
+ "pull:open-search": "docker pull ${npm_package_config_SEARCH_IMAGE}",
27
+ "start:open-search": "docker run -p 9200:9200 -p 9300:9300 -e \"ES_JAVA_OPTS=-Xms1g -Xmx1g\" -e \"discovery.type=single-node\" -e \"plugins.security.disabled=true\" \"${npm_package_config_SEARCH_IMAGE}\"",
28
+ "hmm": "echo mountainpass-addressr-${npm_package_version}.tgz",
19
29
  "requirements-check": "scripts/check-version.js",
20
30
  "postinstall": "npm run requirements-check",
21
31
  "prestart:loader:babel:OT": "npm run build && cp -r target lib/.",
@@ -42,7 +52,7 @@
42
52
  "start:loader:geo:WA:prod": ". .env && COVERED_STATES=WA PORT=$npm_package_config_localport NODE_OPTIONS=--max_old_space_size=8196 babel-node loader.js ",
43
53
  "start:server:OT": "ES_INDEX_NAME=ot DEBUG=error,api,express:*,swagger-tools*,test,es PORT=$npm_package_config_localport babel-node server.js",
44
54
  "start:server": "DEBUG=error,api,express:*,swagger-tools*,test,es PORT=$npm_package_config_localport babel-node server.js",
45
- "start:server:prod": ". .env && PORT=$npm_package_config_localport DEBUG=error,api,express:*,swagger-tools*,test,es babel-node src/server2.js",
55
+ "start:server:prod": ". .env && PORT=$npm_package_config_localport DEBUG=error babel-node server.js",
46
56
  "start:server2:prod": ". .env && ADDRESSR_ACCESS_CONTROL_ALLOW_ORIGIN=null ADDRESSR_ACCESS_CONTROL_EXPOSE_HEADERS=* PORT=$npm_package_config_localport DEBUG=error,api,express:*,swagger-tools*,test,es babel-node src/server2.js",
47
57
  "start:server:OT:prod": ". .env && ES_INDEX_NAME=ot PORT=$npm_package_config_localport DEBUG=error,api,express:*,swagger-tools*,test,es babel-node server.js",
48
58
  "start:server:preinstalled": "ES_INDEX_NAME=test DEBUG=error,api,express:*,swagger-tools*,test,es PORT=$npm_package_config_localport addressr-server",
@@ -104,7 +114,10 @@
104
114
  "postdocker:push": "docker push \"mountainpass/addressr:latest\"",
105
115
  "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",
106
116
  "pre-commit": "lint-staged && npm run check-licenses",
107
- "test:performance": "k6 run --out csv=target/stress.csv test/k6/script.js"
117
+ "test:performance": "k6 run --out csv=target/stress.csv test/k6/script.js",
118
+ "add-changeset": "changeset add --open",
119
+ "ci:version": "[ \"$CI\" = true ] && changeset version || echo \"Dry run: changeset version\"",
120
+ "ci:publish": "[ \"$CI\" = true ] && changeset publish || echo \"Dry run: changeset publish\""
108
121
  },
109
122
  "bin": {
110
123
  "addressr-loader": "lib/bin/addressr-loader.js",
@@ -134,6 +147,7 @@
134
147
  "license": "Apache-2.0",
135
148
  "private": false,
136
149
  "dependencies": {
150
+ "@changesets/cli": "^2.26.2",
137
151
  "@mountainpass/waycharter": "^1.0.68",
138
152
  "@opensearch-project/opensearch": "^2.0.0",
139
153
  "debug": "^4.1.1",
@@ -152,8 +166,8 @@
152
166
  "papaparse": "^5.0.0",
153
167
  "progress": "^2.0.3",
154
168
  "semver": "^7.3.2",
155
- "shelljs": "^0.8.5",
156
169
  "swagger-tools": "^0.10.4",
170
+ "turbo": "^1.10.15",
157
171
  "unzip-stream": "^0.3.0",
158
172
  "uri-template-lite": "^20.5.0",
159
173
  "wait-port": "^0.2.2"
@@ -169,17 +183,14 @@
169
183
  "@babel/preset-react": "^7.0.0",
170
184
  "@babel/register": "^7.7.0",
171
185
  "@babel/runtime": "^7.5.0",
172
- "@dagger.io/dagger": "^0.3.1",
173
186
  "@istanbuljs/nyc-config-babel": "^3.0.0",
174
187
  "@mountainpass/waychaser": "^4.0.0",
175
188
  "@windyroad/cucumber-js-throwables": "^1.0.4",
176
- "@windyroad/quick-containers-js": "^2.0.0",
177
189
  "babel-eslint": "^10.0.2",
178
190
  "babel-plugin-istanbul": "^6.0.0",
179
191
  "babel-preset-env": "^1.7.0",
180
192
  "chai": "^4.2.0",
181
193
  "cucumber": "^5.1.0",
182
- "dockerode": "^3.3.4",
183
194
  "eslint": "^7.9.0",
184
195
  "eslint-config-prettier": "^8.0.0",
185
196
  "eslint-plugin-chai-friendly": "^0.7.1",
@@ -198,15 +209,13 @@
198
209
  "istanbul-middleware": "^0.2.2",
199
210
  "license-checker": "^25.0.1",
200
211
  "lint-staged": "^11.0.0",
201
- "log4brains": "^1.0.1",
202
212
  "ngrok": "^4.0.1",
203
213
  "nodemon": "^2.0.4",
204
214
  "npm-check": "^5.9.0",
205
215
  "npm-run-all": "^4.1.5",
206
216
  "nyc": "^15.1.0",
207
217
  "prettier": "^2.1.0",
208
- "prettier-config-standard": "^4.0.0",
209
- "zip-a-folder": "^1.1.3"
218
+ "prettier-config-standard": "^4.0.0"
210
219
  },
211
220
  "repository": {
212
221
  "type": "git",
@@ -239,4 +248,4 @@
239
248
  "pre-commit": "npm run pre-commit"
240
249
  }
241
250
  }
242
- }
251
+ }