@pretto/places 0.45.0 → 0.46.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/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -30
- package/dist/lib/customFetch.d.ts.map +1 -1
- package/dist/module.js +10 -30
- package/dist/searchByAddress.d.ts +1 -1
- package/dist/searchByAddress.d.ts.map +1 -1
- package/dist/searchByCoordinates.d.ts +1 -1
- package/dist/searchByCoordinates.d.ts.map +1 -1
- package/dist/searchByCountry.d.ts +2 -2
- package/dist/searchByCountry.d.ts.map +1 -1
- package/dist/searchByDepartment.d.ts +1 -1
- package/dist/searchByDepartment.d.ts.map +1 -1
- package/dist/searchByMunicipality.d.ts +1 -1
- package/dist/searchByMunicipality.d.ts.map +1 -1
- package/dist/searchByZipcode.d.ts +1 -1
- package/dist/searchByZipcode.d.ts.map +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
import { CustomFetchOptions, LongLat, MunicipalitySearchResult } from './types';
|
2
|
-
|
3
|
-
export declare const searchPlaces: (searchValue: string | LongLat, options?: CustomFetchOptions
|
4
|
-
export declare const searchDepartment: (searchValue: string, options?: CustomFetchOptions
|
5
|
-
export declare const searchAddress: (searchValue: string, options?: CustomFetchOptions
|
2
|
+
type SearchType = 'city' | 'zipcode' | 'coordinates';
|
3
|
+
export declare const searchPlaces: (searchValue: string | LongLat, options?: CustomFetchOptions, searchType?: SearchType[]) => Promise<MunicipalitySearchResult[]>;
|
4
|
+
export declare const searchDepartment: (searchValue: string, options?: CustomFetchOptions) => Promise<import("./types").DepartmentSearchResult[]>;
|
5
|
+
export declare const searchAddress: (searchValue: string, options?: CustomFetchOptions) => Promise<import("./types").AddressSearchResult[]>;
|
6
6
|
export * as searchCountry from './searchByCountry';
|
7
7
|
/**
|
8
8
|
* @deprecated Use searchPlaces instead
|
9
9
|
*/
|
10
|
-
export declare const municipalitySearch: (searchValue: string | LongLat, options?: CustomFetchOptions
|
10
|
+
export declare const municipalitySearch: (searchValue: string | LongLat, options?: CustomFetchOptions, searchType?: SearchType[]) => Promise<MunicipalitySearchResult[]>;
|
11
11
|
/**
|
12
12
|
* @deprecated Use searchPlaces instead
|
13
13
|
*/
|
14
|
-
export declare const geolocSearch: (searchValue: string | LongLat, options?: CustomFetchOptions
|
14
|
+
export declare const geolocSearch: (searchValue: string | LongLat, options?: CustomFetchOptions, searchType?: SearchType[]) => Promise<MunicipalitySearchResult[]>;
|
15
15
|
/**
|
16
16
|
* @deprecated Use searchByCoordinates instead
|
17
17
|
*/
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEhF,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEhF,KAAK,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,CAAA;AAEpD,eAAO,MAAM,YAAY,gBACV,MAAM,GAAG,OAAO,YACnB,kBAAkB,eAChB,UAAU,EAAE,KACvB,QAAQ,wBAAwB,EAAE,CAmCpC,CAAA;AAED,eAAO,MAAM,gBAAgB,gBAAuB,MAAM,YAAY,kBAAkB,wDAWvF,CAAA;AAED,eAAO,MAAM,aAAa,gBAAuB,MAAM,YAAY,kBAAkB,qDAOpF,CAAA;AAED,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAA;AAIlD;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBArEhB,MAAM,GAAG,OAAO,YACnB,kBAAkB,eAChB,UAAU,EAAE,KACvB,QAAQ,wBAAwB,EAAE,CAkES,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,YAAY,gBA1EV,MAAM,GAAG,OAAO,YACnB,kBAAkB,eAChB,UAAU,EAAE,KACvB,QAAQ,wBAAwB,EAAE,CAuEG,CAAA;AAExC;;GAEG;AACH,eAAO,MAAM,mBAAmB,qHAAsB,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,qHAAkB,CAAA"}
|
package/dist/index.js
CHANGED
@@ -8,7 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
8
8
|
|
9
9
|
var algoliasearch__default = /*#__PURE__*/_interopDefaultLegacy(algoliasearch);
|
10
10
|
|
11
|
-
|
11
|
+
/******************************************************************************
|
12
12
|
Copyright (c) Microsoft Corporation.
|
13
13
|
|
14
14
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -31,7 +31,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
31
31
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
32
32
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
33
33
|
});
|
34
|
-
}
|
34
|
+
}
|
35
|
+
|
36
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
37
|
+
var e = new Error(message);
|
38
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
39
|
+
};
|
35
40
|
|
36
41
|
let controller = { current: null };
|
37
42
|
const getSignal = () => {
|
@@ -53,30 +58,9 @@ const DEFAULT_DEBOUNCE_TIME = 300;
|
|
53
58
|
let getDelayedData = null;
|
54
59
|
const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* () {
|
55
60
|
try {
|
56
|
-
const response = yield fetch(url, {
|
57
|
-
signal,
|
58
|
-
headers: {
|
59
|
-
Accept: 'application/json',
|
60
|
-
'Content-Type': 'application/json',
|
61
|
-
},
|
62
|
-
mode: 'cors',
|
63
|
-
credentials: 'same-origin',
|
64
|
-
cache: 'no-cache',
|
65
|
-
redirect: 'follow',
|
66
|
-
referrerPolicy: 'no-referrer',
|
67
|
-
});
|
68
|
-
console.log('RESPONSE', response);
|
61
|
+
const response = yield fetch(url, { signal });
|
69
62
|
if (!response.ok) {
|
70
|
-
throw new Error(
|
71
|
-
}
|
72
|
-
// Vérification des en-têtes de réponse
|
73
|
-
const contentType = response.headers.get('content-type');
|
74
|
-
if (contentType && contentType.includes('application/json')) {
|
75
|
-
// Si c'est du JSON, on vérifie que les en-têtes CORS sont présents
|
76
|
-
const corsHeaders = response.headers.get('access-control-allow-origin');
|
77
|
-
if (!corsHeaders) {
|
78
|
-
console.warn('Attention: En-têtes CORS manquants dans la réponse JSON');
|
79
|
-
}
|
63
|
+
throw new Error('Error: ' + response.status);
|
80
64
|
}
|
81
65
|
return response;
|
82
66
|
}
|
@@ -84,9 +68,6 @@ const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* (
|
|
84
68
|
if (error instanceof DOMException && error.name === 'AbortError') {
|
85
69
|
return new Promise(() => { });
|
86
70
|
}
|
87
|
-
if (error instanceof Error) {
|
88
|
-
throw new Error(`Erreur lors de la requête: ${error.message}`);
|
89
|
-
}
|
90
71
|
throw error;
|
91
72
|
}
|
92
73
|
});
|
@@ -279,8 +260,7 @@ const get = (instance, search, options) => __awaiter(void 0, void 0, void 0, fun
|
|
279
260
|
return acc;
|
280
261
|
const formatCountryName = convertFirstLetterToUpperCase(libcog.includes('(') ? libenr : libcog);
|
281
262
|
const formatCog = !cog.includes('X') ? `(${cog})` : '';
|
282
|
-
|
283
|
-
return [...acc, { label, value: codeiso2.toLowerCase() }];
|
263
|
+
return [...acc, { label: formatCountryName, value: codeiso2.toLowerCase(), cog: formatCog }];
|
284
264
|
}, []);
|
285
265
|
});
|
286
266
|
const init = (appId, apiKey, options) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"customFetch.d.ts","sourceRoot":"","sources":["../../src/lib/customFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"customFetch.d.ts","sourceRoot":"","sources":["../../src/lib/customFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAwB9C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC3G,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA"}
|
package/dist/module.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import algoliasearch from 'algoliasearch';
|
2
2
|
|
3
|
-
|
3
|
+
/******************************************************************************
|
4
4
|
Copyright (c) Microsoft Corporation.
|
5
5
|
|
6
6
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -23,7 +23,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
23
23
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
24
24
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
25
25
|
});
|
26
|
-
}
|
26
|
+
}
|
27
|
+
|
28
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
29
|
+
var e = new Error(message);
|
30
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
31
|
+
};
|
27
32
|
|
28
33
|
let controller = { current: null };
|
29
34
|
const getSignal = () => {
|
@@ -45,30 +50,9 @@ const DEFAULT_DEBOUNCE_TIME = 300;
|
|
45
50
|
let getDelayedData = null;
|
46
51
|
const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* () {
|
47
52
|
try {
|
48
|
-
const response = yield fetch(url, {
|
49
|
-
signal,
|
50
|
-
headers: {
|
51
|
-
Accept: 'application/json',
|
52
|
-
'Content-Type': 'application/json',
|
53
|
-
},
|
54
|
-
mode: 'cors',
|
55
|
-
credentials: 'same-origin',
|
56
|
-
cache: 'no-cache',
|
57
|
-
redirect: 'follow',
|
58
|
-
referrerPolicy: 'no-referrer',
|
59
|
-
});
|
60
|
-
console.log('RESPONSE', response);
|
53
|
+
const response = yield fetch(url, { signal });
|
61
54
|
if (!response.ok) {
|
62
|
-
throw new Error(
|
63
|
-
}
|
64
|
-
// Vérification des en-têtes de réponse
|
65
|
-
const contentType = response.headers.get('content-type');
|
66
|
-
if (contentType && contentType.includes('application/json')) {
|
67
|
-
// Si c'est du JSON, on vérifie que les en-têtes CORS sont présents
|
68
|
-
const corsHeaders = response.headers.get('access-control-allow-origin');
|
69
|
-
if (!corsHeaders) {
|
70
|
-
console.warn('Attention: En-têtes CORS manquants dans la réponse JSON');
|
71
|
-
}
|
55
|
+
throw new Error('Error: ' + response.status);
|
72
56
|
}
|
73
57
|
return response;
|
74
58
|
}
|
@@ -76,9 +60,6 @@ const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* (
|
|
76
60
|
if (error instanceof DOMException && error.name === 'AbortError') {
|
77
61
|
return new Promise(() => { });
|
78
62
|
}
|
79
|
-
if (error instanceof Error) {
|
80
|
-
throw new Error(`Erreur lors de la requête: ${error.message}`);
|
81
|
-
}
|
82
63
|
throw error;
|
83
64
|
}
|
84
65
|
});
|
@@ -271,8 +252,7 @@ const get = (instance, search, options) => __awaiter(void 0, void 0, void 0, fun
|
|
271
252
|
return acc;
|
272
253
|
const formatCountryName = convertFirstLetterToUpperCase(libcog.includes('(') ? libenr : libcog);
|
273
254
|
const formatCog = !cog.includes('X') ? `(${cog})` : '';
|
274
|
-
|
275
|
-
return [...acc, { label, value: codeiso2.toLowerCase() }];
|
255
|
+
return [...acc, { label: formatCountryName, value: codeiso2.toLowerCase(), cog: formatCog }];
|
276
256
|
}, []);
|
277
257
|
});
|
278
258
|
const init = (appId, apiKey, options) => {
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { AddressSearchResult, CustomFetchOptions } from './types';
|
2
|
-
export declare const searchByAddress: (searchValue: string, options?: CustomFetchOptions
|
2
|
+
export declare const searchByAddress: (searchValue: string, options?: CustomFetchOptions) => Promise<AddressSearchResult[]>;
|
3
3
|
//# sourceMappingURL=searchByAddress.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"searchByAddress.d.ts","sourceRoot":"","sources":["../src/searchByAddress.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAalE,eAAO,MAAM,eAAe,gBACb,MAAM
|
1
|
+
{"version":3,"file":"searchByAddress.d.ts","sourceRoot":"","sources":["../src/searchByAddress.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAalE,eAAO,MAAM,eAAe,gBACb,MAAM,YACT,kBAAkB,KAC3B,QAAQ,mBAAmB,EAAE,CAuB/B,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { CustomFetchOptions, LongLat, MunicipalitySearchResult } from './types';
|
2
|
-
export declare const searchByCoordinates: ({ latitude, longitude }: LongLat, options?: CustomFetchOptions
|
2
|
+
export declare const searchByCoordinates: ({ latitude, longitude }: LongLat, options?: CustomFetchOptions) => Promise<MunicipalitySearchResult[]>;
|
3
3
|
//# sourceMappingURL=searchByCoordinates.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"searchByCoordinates.d.ts","sourceRoot":"","sources":["../src/searchByCoordinates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAgB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE9F,eAAO,MAAM,mBAAmB,4BACL,OAAO
|
1
|
+
{"version":3,"file":"searchByCoordinates.d.ts","sourceRoot":"","sources":["../src/searchByCoordinates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAgB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE9F,eAAO,MAAM,mBAAmB,4BACL,OAAO,YACtB,kBAAkB,KAC3B,QAAQ,wBAAwB,EAAE,CAiBpC,CAAA"}
|
@@ -4,8 +4,8 @@ interface Options {
|
|
4
4
|
limit?: number;
|
5
5
|
language?: 'fr' | 'en';
|
6
6
|
}
|
7
|
-
export declare const init: (appId: string, apiKey: string, options?: AlgoliaSearchOptions
|
8
|
-
get(search: string, options?: Options
|
7
|
+
export declare const init: (appId: string, apiKey: string, options?: AlgoliaSearchOptions) => "An error occurred." | {
|
8
|
+
get(search: string, options?: Options): Promise<CountriesSearchResult[]>;
|
9
9
|
};
|
10
10
|
export {};
|
11
11
|
//# sourceMappingURL=searchByCountry.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"searchByCountry.d.ts","sourceRoot":"","sources":["../src/searchByCountry.ts"],"names":[],"mappings":"AAAA,OAAsB,EAAE,oBAAoB,EAAgB,MAAM,eAAe,
|
1
|
+
{"version":3,"file":"searchByCountry.d.ts","sourceRoot":"","sources":["../src/searchByCountry.ts"],"names":[],"mappings":"AAAA,OAAsB,EAAE,oBAAoB,EAAgB,MAAM,eAAe,CAAA;AAGjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAS/C,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACvB;AAwBD,eAAO,MAAM,IAAI,UAAW,MAAM,UAAU,MAAM,YAAY,oBAAoB;gBAK1D,MAAM,YAAY,OAAO;CAShD,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { CustomFetchOptions, DepartmentSearchResult } from './types';
|
2
|
-
export declare const searchByDepartment: (searchValue: string, options?: CustomFetchOptions
|
2
|
+
export declare const searchByDepartment: (searchValue: string, options?: CustomFetchOptions) => Promise<DepartmentSearchResult[]>;
|
3
3
|
//# sourceMappingURL=searchByDepartment.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"searchByDepartment.d.ts","sourceRoot":"","sources":["../src/searchByDepartment.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,kBAAkB,EAAE,sBAAsB,EAC7C,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,kBAAkB,gBAChB,MAAM
|
1
|
+
{"version":3,"file":"searchByDepartment.d.ts","sourceRoot":"","sources":["../src/searchByDepartment.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,kBAAkB,EAAE,sBAAsB,EAC7C,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,kBAAkB,gBAChB,MAAM,YACT,kBAAkB,KAC3B,QAAQ,sBAAsB,EAAE,CA4BlC,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { CustomFetchOptions, MunicipalitySearchResult } from './types';
|
2
|
-
export declare const searchByMunicipality: (searchValue: string, options?: CustomFetchOptions
|
2
|
+
export declare const searchByMunicipality: (searchValue: string, options?: CustomFetchOptions) => Promise<MunicipalitySearchResult[]>;
|
3
3
|
//# sourceMappingURL=searchByMunicipality.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"searchByMunicipality.d.ts","sourceRoot":"","sources":["../src/searchByMunicipality.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAgB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAoBrF,eAAO,MAAM,oBAAoB,gBAClB,MAAM
|
1
|
+
{"version":3,"file":"searchByMunicipality.d.ts","sourceRoot":"","sources":["../src/searchByMunicipality.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAgB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAoBrF,eAAO,MAAM,oBAAoB,gBAClB,MAAM,YACT,kBAAkB,KAC3B,QAAQ,wBAAwB,EAAE,CA+CpC,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { CustomFetchOptions, MunicipalitySearchResult } from './types';
|
2
|
-
export declare const searchByZipcode: (searchValue: string, options?: CustomFetchOptions
|
2
|
+
export declare const searchByZipcode: (searchValue: string, options?: CustomFetchOptions) => Promise<MunicipalitySearchResult[]>;
|
3
3
|
//# sourceMappingURL=searchByZipcode.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"searchByZipcode.d.ts","sourceRoot":"","sources":["../src/searchByZipcode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAgB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAErF,eAAO,MAAM,eAAe,gBACb,MAAM
|
1
|
+
{"version":3,"file":"searchByZipcode.d.ts","sourceRoot":"","sources":["../src/searchByZipcode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAgB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAErF,eAAO,MAAM,eAAe,gBACb,MAAM,YACT,kBAAkB,KAC3B,QAAQ,wBAAwB,EAAE,CAUpC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pretto/places",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.46.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -16,7 +16,6 @@
|
|
16
16
|
"dist/**/*"
|
17
17
|
],
|
18
18
|
"dependencies": {
|
19
|
-
"@pretto/places": "^0.43.0",
|
20
19
|
"@types/algoliasearch": "^4.0.0",
|
21
20
|
"algoliasearch": "4.22.1",
|
22
21
|
"array.prototype.flat": "^1.3.0",
|