@bpost/bp-address-auto-complete-by-component 1.0.25 → 1.0.29
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/VERSION.md +17 -0
- package/bpost-bp-address-auto-complete-by-component.metadata.json +1 -1
- package/bundles/bpost-bp-address-auto-complete-by-component.umd.js +56 -8
- package/bundles/bpost-bp-address-auto-complete-by-component.umd.js.map +1 -1
- package/bundles/bpost-bp-address-auto-complete-by-component.umd.min.js +1 -1
- package/bundles/bpost-bp-address-auto-complete-by-component.umd.min.js.map +1 -1
- package/esm2015/lib/lib-address-autocomplete-by-component.component.js +21 -6
- package/esm2015/lib/locality/locality.component.js +21 -3
- package/esm2015/lib/model/query-parameters.model.js +2 -2
- package/esm2015/lib/services/adress.service.js +2 -1
- package/esm2015/lib/services/http.service.js +15 -2
- package/esm2015/lib/utils/prefill-data.js +3 -1
- package/esm5/lib/lib-address-autocomplete-by-component.component.js +21 -6
- package/esm5/lib/locality/locality.component.js +21 -3
- package/esm5/lib/model/query-parameters.model.js +2 -2
- package/esm5/lib/services/adress.service.js +2 -1
- package/esm5/lib/services/http.service.js +16 -3
- package/esm5/lib/utils/prefill-data.js +3 -1
- package/fesm2015/bpost-bp-address-auto-complete-by-component.js +57 -9
- package/fesm2015/bpost-bp-address-auto-complete-by-component.js.map +1 -1
- package/fesm5/bpost-bp-address-auto-complete-by-component.js +58 -10
- package/fesm5/bpost-bp-address-auto-complete-by-component.js.map +1 -1
- package/lib/lib-address-autocomplete-by-component.component.d.ts +5 -1
- package/lib/model/query-parameters.model.d.ts +1 -1
- package/lib/services/adress.service.d.ts +1 -0
- package/lib/services/http.service.d.ts +4 -1
- package/lib/utils/prefill-data.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __decorate,
|
|
1
|
+
import { __decorate, __assign, __values } from 'tslib';
|
|
2
2
|
import { ɵɵdefineInjectable, Injectable, ɵɵinject, EventEmitter, ViewChild, Input, Output, Component, Pipe, ElementRef, Renderer2, Directive, NgModule } from '@angular/core';
|
|
3
3
|
import { map, catchError, tap } from 'rxjs/operators';
|
|
4
4
|
import { throwError, BehaviorSubject } from 'rxjs';
|
|
5
|
-
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
5
|
+
import { HttpHeaders, HttpClient, HttpClientModule } from '@angular/common/http';
|
|
6
6
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
7
7
|
import { CommonModule } from '@angular/common';
|
|
8
8
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -58,7 +58,7 @@ var QueryParameters = /** @class */ (function () {
|
|
|
58
58
|
this.sortByStreetNumber = enable;
|
|
59
59
|
};
|
|
60
60
|
QueryParameters.prototype.sortByBox = function (enable) {
|
|
61
|
-
this.
|
|
61
|
+
this.sortByBoxNumber = enable;
|
|
62
62
|
};
|
|
63
63
|
return QueryParameters;
|
|
64
64
|
}());
|
|
@@ -67,13 +67,26 @@ var HttpService = /** @class */ (function () {
|
|
|
67
67
|
function HttpService(httpClient) {
|
|
68
68
|
this.httpClient = httpClient;
|
|
69
69
|
this.openConnections = 0;
|
|
70
|
+
this.apiKey = 'no-value';
|
|
70
71
|
}
|
|
72
|
+
HttpService.prototype.setApiKey = function (apiKey) {
|
|
73
|
+
this.apiKey = apiKey;
|
|
74
|
+
};
|
|
75
|
+
HttpService.prototype.getHttpHeaders = function () {
|
|
76
|
+
var headers = new HttpHeaders();
|
|
77
|
+
// Attention !
|
|
78
|
+
// Need to reassign as the 'set' is returning a clone of the headera object !!!
|
|
79
|
+
headers = headers.set('x-api-key', /*'bBkvimXYnAaEEKMyGqoWO2XiaZCQyqUi7VReYzPJ'*/ this.apiKey);
|
|
80
|
+
return headers;
|
|
81
|
+
};
|
|
71
82
|
HttpService.prototype.get = function (url, options) {
|
|
72
83
|
return this.request('GET', url, options);
|
|
73
84
|
};
|
|
74
85
|
HttpService.prototype.request = function (method, url, options) {
|
|
75
86
|
var _this = this;
|
|
76
87
|
options = !!options ? options : {};
|
|
88
|
+
options = __assign(__assign({}, options), { headers: this.getHttpHeaders() });
|
|
89
|
+
console.log('options:', JSON.stringify(options));
|
|
77
90
|
this.openConnections++;
|
|
78
91
|
return this.httpClient.request(method, url, options).pipe(map(function (response) { return _this.handleResponse(response); }), catchError(function (error) { return _this.handleError(error); }));
|
|
79
92
|
};
|
|
@@ -204,6 +217,7 @@ var AddressService = /** @class */ (function () {
|
|
|
204
217
|
this.httpService = httpService;
|
|
205
218
|
this.domain = 'http://10.194.73.9:8080';
|
|
206
219
|
this.localityURL = this.domain + '/AddressAutoComplete/autocomplete/locality?IncludeGeographicalSanction=true';
|
|
220
|
+
this.log = true;
|
|
207
221
|
}
|
|
208
222
|
AddressService.prototype.getLocality = function (baseUrl, params) {
|
|
209
223
|
var _this = this;
|
|
@@ -1203,11 +1217,29 @@ var LocalityComponent = /** @class */ (function () {
|
|
|
1203
1217
|
var suggestionMunicipality = this.transformMunicipalityInLowercaseAndWithoutDiacritics(sugAddress.municipalityName);
|
|
1204
1218
|
if (suggestionLocality === this.prefillData.prefillMunicipalityName
|
|
1205
1219
|
|| suggestionMunicipality === this.prefillData.prefillMunicipalityName) {
|
|
1220
|
+
if (this.prefillData.prefillMunicipalityAndLocalityPerfectMatchFound === true) {
|
|
1221
|
+
if (this.showDebugMessageToConsole) {
|
|
1222
|
+
console.log('LOCALITY - PREFILL - skipping suggestion:', suggestion);
|
|
1223
|
+
}
|
|
1224
|
+
if (this.showDebugMessageToConsole) {
|
|
1225
|
+
console.log('LOCALITY - PREFILL - keeping suggestion:', this.prefillData.prefillMunicipalityPerfectMatchSuggestion);
|
|
1226
|
+
}
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1206
1229
|
this.prefillData.prefillMunicipalityPerfectMatchFound = true;
|
|
1207
1230
|
this.prefillData.prefillMunicipalityPerfectMatchSuggestion = suggestion;
|
|
1208
1231
|
this.searchText = sugAddress.postalCode + ' ' + sugAddress.localityName;
|
|
1209
|
-
|
|
1210
|
-
|
|
1232
|
+
this.prefillData.prefillMunicipalityAndLocalityPerfectMatchFound = (suggestionLocality === this.prefillData.prefillMunicipalityName
|
|
1233
|
+
&& suggestionMunicipality === this.prefillData.prefillMunicipalityName) ? true : false;
|
|
1234
|
+
if (this.prefillData.prefillMunicipalityAndLocalityPerfectMatchFound === true) {
|
|
1235
|
+
if (this.showDebugMessageToConsole) {
|
|
1236
|
+
console.log('LOCALITY - PREFILL - Perfect match - Municipality & location:', suggestion);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
if (this.showDebugMessageToConsole) {
|
|
1241
|
+
console.log('LOCALITY - PREFILL - Perfect match:', suggestion);
|
|
1242
|
+
}
|
|
1211
1243
|
}
|
|
1212
1244
|
}
|
|
1213
1245
|
}
|
|
@@ -4025,6 +4057,8 @@ var PrefillData // extends PrefilledParameters
|
|
|
4025
4057
|
this.prefillMunicipalityName = null;
|
|
4026
4058
|
this.prefillMunicipalityPerfectMatchFound = false;
|
|
4027
4059
|
this.prefillMunicipalityPerfectMatchSuggestion = null;
|
|
4060
|
+
// This is a working field, do not document
|
|
4061
|
+
this.prefillMunicipalityAndLocalityPerfectMatchFound = false;
|
|
4028
4062
|
this.prefillStreetName = null;
|
|
4029
4063
|
this.prefillStreetPerfectMatchFound = false;
|
|
4030
4064
|
this.prefillStreetPerfectMatchSuggestion = null;
|
|
@@ -4041,32 +4075,34 @@ var PrefillData // extends PrefilledParameters
|
|
|
4041
4075
|
}());
|
|
4042
4076
|
|
|
4043
4077
|
var LibAddressAutocompleteByComponentComponent = /** @class */ (function () {
|
|
4044
|
-
function LibAddressAutocompleteByComponentComponent() {
|
|
4078
|
+
function LibAddressAutocompleteByComponentComponent(httpService) {
|
|
4079
|
+
this.httpService = httpService;
|
|
4045
4080
|
this.selectedLanguage = null;
|
|
4081
|
+
this.baseUrl = "https://api.mailops.bpost.cloud/roa-info/externalMailingAddressProofingRest/autocomplete/";
|
|
4046
4082
|
this.showDebugMessageToConsole = false;
|
|
4047
4083
|
this.notInListAllowed = true;
|
|
4048
4084
|
this.messageOption = 'Y';
|
|
4049
4085
|
// LOCALITY
|
|
4050
|
-
this.localityUrl = '
|
|
4086
|
+
this.localityUrl = this.baseUrl + 'locality';
|
|
4051
4087
|
this.maxSuggestionLocality = 5;
|
|
4052
4088
|
this.visibleSuggestionLocalityCount = 5;
|
|
4053
4089
|
// localityParams: PrefilledParameters;
|
|
4054
4090
|
this.localityPrefillData = null;
|
|
4055
4091
|
// STREET
|
|
4056
|
-
this.streetUrl = '
|
|
4092
|
+
this.streetUrl = this.baseUrl + 'street';
|
|
4057
4093
|
this.maxSuggestionStreet = 5;
|
|
4058
4094
|
this.visibleSuggestionStreetCount = 5;
|
|
4059
4095
|
// streetParams: PrefilledParameters;
|
|
4060
4096
|
this.streetPrefillData = null;
|
|
4061
4097
|
// STREET NUMBER
|
|
4062
4098
|
// tslint:disable-next-line:max-line-length
|
|
4063
|
-
this.streetNumberUrl = '
|
|
4099
|
+
this.streetNumberUrl = this.baseUrl + 'streetNumber';
|
|
4064
4100
|
this.maxSuggestionStreetNb = 5;
|
|
4065
4101
|
this.visibleSuggestionStreetNbCount = 5;
|
|
4066
4102
|
// streetNumberParams: PrefilledParameters;
|
|
4067
4103
|
this.streetNumberPrefillData = null;
|
|
4068
4104
|
// BOX NUMBER
|
|
4069
|
-
this.boxNumberUrl = '
|
|
4105
|
+
this.boxNumberUrl = this.baseUrl + 'boxNumber';
|
|
4070
4106
|
this.maxSuggestionBoxNb = 5;
|
|
4071
4107
|
this.visibleSuggestionBoxNbCount = 5;
|
|
4072
4108
|
// boxParams: PrefilledParameters;
|
|
@@ -4077,6 +4113,8 @@ var LibAddressAutocompleteByComponentComponent = /** @class */ (function () {
|
|
|
4077
4113
|
this.validationMessageEventEmitter = new EventEmitter();
|
|
4078
4114
|
this.clearInputEventEmitter = new EventEmitter();
|
|
4079
4115
|
this.processingPrefillData = false;
|
|
4116
|
+
// Pass the API key as a property of the library !
|
|
4117
|
+
this.apiKey = 'cyRkKOD73O1DOdgcDLLnsaOiDh6OyOkt3BBT5JU1';
|
|
4080
4118
|
}
|
|
4081
4119
|
Object.defineProperty(LibAddressAutocompleteByComponentComponent.prototype, "inputLang", {
|
|
4082
4120
|
// @ts-ignore
|
|
@@ -4103,6 +4141,7 @@ var LibAddressAutocompleteByComponentComponent = /** @class */ (function () {
|
|
|
4103
4141
|
configurable: true
|
|
4104
4142
|
});
|
|
4105
4143
|
LibAddressAutocompleteByComponentComponent.prototype.ngOnInit = function () {
|
|
4144
|
+
this.httpService.setApiKey(this.apiKey);
|
|
4106
4145
|
if (this.addressParams) {
|
|
4107
4146
|
this.prefillData = this.addressParams;
|
|
4108
4147
|
}
|
|
@@ -4119,6 +4158,9 @@ var LibAddressAutocompleteByComponentComponent = /** @class */ (function () {
|
|
|
4119
4158
|
if (this.showDebugMessageToConsole) {
|
|
4120
4159
|
this.displayParametersChangesToConsole(changes);
|
|
4121
4160
|
}
|
|
4161
|
+
if (changes.hasOwnProperty('apiKey') && !changes.apiKey.firstChange) {
|
|
4162
|
+
this.httpService.setApiKey(this.apiKey);
|
|
4163
|
+
}
|
|
4122
4164
|
if (changes.hasOwnProperty('addressParams') && !changes.addressParams.firstChange) {
|
|
4123
4165
|
// if (changes.hasOwnProperty('addressParams')) {
|
|
4124
4166
|
this.processingPrefillData = true;
|
|
@@ -4979,6 +5021,9 @@ var LibAddressAutocompleteByComponentComponent = /** @class */ (function () {
|
|
|
4979
5021
|
}
|
|
4980
5022
|
this.quitPrefillMode();
|
|
4981
5023
|
};
|
|
5024
|
+
LibAddressAutocompleteByComponentComponent.ctorParameters = function () { return [
|
|
5025
|
+
{ type: HttpService }
|
|
5026
|
+
]; };
|
|
4982
5027
|
__decorate([
|
|
4983
5028
|
ViewChild(LocalityComponent, { static: false })
|
|
4984
5029
|
], LibAddressAutocompleteByComponentComponent.prototype, "autocompleteLocality", void 0);
|
|
@@ -5075,6 +5120,9 @@ var LibAddressAutocompleteByComponentComponent = /** @class */ (function () {
|
|
|
5075
5120
|
__decorate([
|
|
5076
5121
|
Output()
|
|
5077
5122
|
], LibAddressAutocompleteByComponentComponent.prototype, "clearInputEventEmitter", void 0);
|
|
5123
|
+
__decorate([
|
|
5124
|
+
Input()
|
|
5125
|
+
], LibAddressAutocompleteByComponentComponent.prototype, "apiKey", void 0);
|
|
5078
5126
|
LibAddressAutocompleteByComponentComponent = __decorate([
|
|
5079
5127
|
Component({
|
|
5080
5128
|
selector: 'bp-lib-address-autocomplete-by-component',
|