@uxf/smart-address 11.80.2 → 11.103.1
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 +1 -1
- package/{smart-address/v1 → common/__tests__}/load-address-options.test.js +22 -14
- package/{smart-address/v1 → common/__tests__}/load-zip-options.test.js +10 -5
- package/{smart-address/v1 → common/__tests__}/search-zip.test.js +5 -4
- package/common/__tests__/search.test.js +24 -0
- package/common/create-loader.d.ts +4 -0
- package/common/create-loader.js +7 -0
- package/common/get-address-extended.d.ts +2 -0
- package/common/get-address-extended.js +9 -0
- package/common/get-address.d.ts +2 -0
- package/common/get-address.js +9 -0
- package/common/index.d.ts +1 -0
- package/common/index.js +17 -0
- package/{smart-address/v1 → common}/load-address-options.d.ts +2 -1
- package/common/load-address-options.js +21 -0
- package/{smart-address/v1 → common}/load-zip-options.d.ts +2 -1
- package/{smart-address/v1 → common}/load-zip-options.js +4 -4
- package/common/search-zip.d.ts +2 -0
- package/common/search-zip.js +19 -0
- package/{smart-address/v1 → common}/search.d.ts +2 -1
- package/{smart-address/v1 → common}/search.js +8 -5
- package/{smart-address/v1 → common}/types.d.ts +4 -5
- package/package.json +1 -1
- package/v1/create-address-loader.d.ts +9 -0
- package/v1/create-address-loader.js +7 -0
- package/v1/create-zip-loader.d.ts +6 -0
- package/{smart-address/v1 → v1}/create-zip-loader.js +2 -6
- package/{smart-address/v1 → v1}/get-address-extended.d.ts +1 -2
- package/v1/get-address-extended.js +5 -0
- package/v1/get-address.d.ts +1 -0
- package/v1/get-address.js +5 -0
- package/{smart-address/v1 → v1}/get-city-part.js +2 -2
- package/{smart-address/v1 → v1}/get-city.js +2 -2
- package/{smart-address/v1 → v1}/get-momc.js +2 -2
- package/{smart-address/v1 → v1}/get-mop.js +2 -2
- package/{smart-address/v1 → v1}/get-street.js +1 -1
- package/{smart-address/v1 → v1}/index.d.ts +6 -3
- package/v1/load-address-options.d.ts +8 -0
- package/v1/load-address-options.js +5 -0
- package/v1/load-zip-options.d.ts +5 -0
- package/v1/load-zip-options.js +5 -0
- package/v1/search-zip.d.ts +1 -0
- package/v1/search-zip.js +5 -0
- package/v1/search.d.ts +7 -0
- package/v1/search.js +5 -0
- package/v1/types.d.ts +1 -0
- package/v1/types.js +17 -0
- package/v2/__tests__/get-building-addresses.test.d.ts +1 -0
- package/v2/__tests__/get-building-addresses.test.js +49 -0
- package/v2/__tests__/search-city-part.test.d.ts +1 -0
- package/v2/__tests__/search-city-part.test.js +46 -0
- package/v2/create-address-loader.d.ts +10 -0
- package/v2/create-address-loader.js +7 -0
- package/v2/create-zip-loader.d.ts +7 -0
- package/v2/create-zip-loader.js +7 -0
- package/v2/get-address-extended.d.ts +2 -0
- package/v2/get-address-extended.js +5 -0
- package/v2/get-address.d.ts +1 -0
- package/v2/get-address.js +5 -0
- package/v2/get-building-addresses.d.ts +2 -0
- package/v2/get-building-addresses.js +9 -0
- package/v2/index.d.ts +11 -0
- package/v2/index.js +27 -0
- package/v2/load-address-options.d.ts +8 -0
- package/v2/load-address-options.js +5 -0
- package/v2/load-zip-options.d.ts +5 -0
- package/v2/load-zip-options.js +5 -0
- package/v2/search-city-part.d.ts +2 -0
- package/v2/search-city-part.js +18 -0
- package/v2/search-zip.d.ts +1 -0
- package/v2/search-zip.js +5 -0
- package/v2/search.d.ts +7 -0
- package/v2/search.js +5 -0
- package/v2/types.d.ts +48 -0
- package/v2/types.js +17 -0
- package/smart-address/v1/create-address-loader.d.ts +0 -9
- package/smart-address/v1/create-address-loader.js +0 -14
- package/smart-address/v1/create-zip-loader.d.ts +0 -6
- package/smart-address/v1/get-address-extended.js +0 -9
- package/smart-address/v1/get-address.d.ts +0 -2
- package/smart-address/v1/get-address.js +0 -9
- package/smart-address/v1/load-address-options.js +0 -15
- package/smart-address/v1/search-zip.d.ts +0 -2
- package/smart-address/v1/search-zip.js +0 -16
- package/smart-address/v1/search.test.js +0 -33
- /package/{smart-address/v1 → common/__tests__}/load-address-options.test.d.ts +0 -0
- /package/{smart-address/v1 → common/__tests__}/load-zip-options.test.d.ts +0 -0
- /package/{smart-address/v1 → common/__tests__}/search-zip.test.d.ts +0 -0
- /package/{smart-address/v1 → common/__tests__}/search.test.d.ts +0 -0
- /package/{smart-address/v1 → common}/types.js +0 -0
- /package/{smart-address/config.d.ts → config.d.ts} +0 -0
- /package/{smart-address/config.js → config.js} +0 -0
- /package/{smart-address/v1 → v1}/get-city-part.d.ts +0 -0
- /package/{smart-address/v1 → v1}/get-city.d.ts +0 -0
- /package/{smart-address/v1 → v1}/get-momc.d.ts +0 -0
- /package/{smart-address/v1 → v1}/get-mop.d.ts +0 -0
- /package/{smart-address/v1 → v1}/get-street.d.ts +0 -0
- /package/{smart-address/v1 → v1}/index.js +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const load_address_options_1 = require("
|
|
4
|
-
const search_1 = require("
|
|
5
|
-
jest.
|
|
3
|
+
const load_address_options_1 = require("../../v1/load-address-options");
|
|
4
|
+
const search_1 = require("../search");
|
|
5
|
+
global.fetch = jest.fn();
|
|
6
|
+
jest.mock("../search");
|
|
6
7
|
describe("loadAddressOptions", () => {
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
jest.clearAllMocks();
|
|
@@ -36,7 +37,7 @@ describe("loadAddressOptions", () => {
|
|
|
36
37
|
psc: null,
|
|
37
38
|
search: "",
|
|
38
39
|
level: 1,
|
|
39
|
-
gps: { latitude:
|
|
40
|
+
gps: { latitude: 50.0755, longitude: 14.4378 },
|
|
40
41
|
platiOd: "2024-01-01",
|
|
41
42
|
aktualizace: "2024-10-01",
|
|
42
43
|
okresKod: 456,
|
|
@@ -45,9 +46,12 @@ describe("loadAddressOptions", () => {
|
|
|
45
46
|
krajNazev: "Czech Republic",
|
|
46
47
|
},
|
|
47
48
|
];
|
|
48
|
-
|
|
49
|
+
const mockSearch = jest.fn();
|
|
50
|
+
search_1.searchGeneral.mockReturnValue(mockSearch);
|
|
51
|
+
mockSearch.mockResolvedValue(mockResponse);
|
|
49
52
|
await (0, load_address_options_1.loadAddressOptions)({ term, level });
|
|
50
|
-
expect(search_1.
|
|
53
|
+
expect(search_1.searchGeneral).toHaveBeenCalledWith("/v1/search");
|
|
54
|
+
expect(mockSearch).toHaveBeenCalledWith({ term, level, limit: 10, zip: undefined });
|
|
51
55
|
});
|
|
52
56
|
const term = "Prague";
|
|
53
57
|
const level = 1;
|
|
@@ -57,7 +61,7 @@ describe("loadAddressOptions", () => {
|
|
|
57
61
|
id: 1,
|
|
58
62
|
obecKod: 123,
|
|
59
63
|
obecNazev: null,
|
|
60
|
-
obec:
|
|
64
|
+
obec: "Vrchlabi",
|
|
61
65
|
momcKod: null,
|
|
62
66
|
momcNazev: null,
|
|
63
67
|
mopKod: null,
|
|
@@ -74,7 +78,7 @@ describe("loadAddressOptions", () => {
|
|
|
74
78
|
psc: null,
|
|
75
79
|
search: "",
|
|
76
80
|
level: 1,
|
|
77
|
-
gps: { latitude:
|
|
81
|
+
gps: { latitude: 50.0755, longitude: 14.4378 },
|
|
78
82
|
platiOd: "2024-01-01",
|
|
79
83
|
aktualizace: "2024-10-01",
|
|
80
84
|
okresKod: 456,
|
|
@@ -83,9 +87,11 @@ describe("loadAddressOptions", () => {
|
|
|
83
87
|
krajNazev: "Czech Republic",
|
|
84
88
|
},
|
|
85
89
|
];
|
|
86
|
-
|
|
90
|
+
const mockSearch = jest.fn();
|
|
91
|
+
search_1.searchGeneral.mockReturnValue(mockSearch);
|
|
92
|
+
mockSearch.mockResolvedValue(mockResponse);
|
|
87
93
|
const options = await (0, load_address_options_1.loadAddressOptions)({ term, level });
|
|
88
|
-
expect(options).toEqual([{ id: 1, label: "Main St,
|
|
94
|
+
expect(options).toEqual([{ id: 1, label: "Main St, Vrchlabi" }]);
|
|
89
95
|
});
|
|
90
96
|
it("should use custom getLabel function if provided", async () => {
|
|
91
97
|
const mockResponse = [
|
|
@@ -93,7 +99,7 @@ describe("loadAddressOptions", () => {
|
|
|
93
99
|
id: 1,
|
|
94
100
|
obecKod: 123,
|
|
95
101
|
obecNazev: null,
|
|
96
|
-
obec:
|
|
102
|
+
obec: "Vrchlabi",
|
|
97
103
|
momcKod: null,
|
|
98
104
|
momcNazev: null,
|
|
99
105
|
mopKod: null,
|
|
@@ -110,7 +116,7 @@ describe("loadAddressOptions", () => {
|
|
|
110
116
|
psc: null,
|
|
111
117
|
search: "",
|
|
112
118
|
level: 1,
|
|
113
|
-
gps: { latitude:
|
|
119
|
+
gps: { latitude: 50.0755, longitude: 14.4378 },
|
|
114
120
|
platiOd: "2024-01-01",
|
|
115
121
|
aktualizace: "2024-10-01",
|
|
116
122
|
okresKod: 456,
|
|
@@ -119,9 +125,11 @@ describe("loadAddressOptions", () => {
|
|
|
119
125
|
krajNazev: "Czech Republic",
|
|
120
126
|
},
|
|
121
127
|
];
|
|
122
|
-
|
|
128
|
+
const mockSearch = jest.fn();
|
|
129
|
+
search_1.searchGeneral.mockReturnValue(mockSearch);
|
|
130
|
+
mockSearch.mockResolvedValue(mockResponse);
|
|
123
131
|
const customGetLabel = (address) => `${address.obec} - ${address.ulice}`;
|
|
124
132
|
const options = await (0, load_address_options_1.loadAddressOptions)({ term, level, getLabel: customGetLabel });
|
|
125
|
-
expect(options).toEqual([{ id: 1, label: "
|
|
133
|
+
expect(options).toEqual([{ id: 1, label: "Vrchlabi - Main St" }]);
|
|
126
134
|
});
|
|
127
135
|
});
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const load_zip_options_1 = require("
|
|
4
|
-
const search_zip_1 = require("
|
|
5
|
-
jest.
|
|
3
|
+
const load_zip_options_1 = require("../../v1/load-zip-options");
|
|
4
|
+
const search_zip_1 = require("../search-zip");
|
|
5
|
+
global.fetch = jest.fn();
|
|
6
|
+
jest.mock("../search-zip");
|
|
6
7
|
describe("loadZipOptions", () => {
|
|
7
8
|
it("should return empty array when term is empty", async () => {
|
|
8
9
|
const result = await (0, load_zip_options_1.loadZipOptions)({ term: "" });
|
|
9
10
|
expect(result).toEqual([]);
|
|
10
11
|
});
|
|
11
12
|
it("should return formatted options with default label when term is provided", async () => {
|
|
12
|
-
|
|
13
|
+
const mockSearch = jest.fn();
|
|
14
|
+
search_zip_1.searchZipGeneral.mockReturnValue(mockSearch);
|
|
15
|
+
mockSearch.mockResolvedValueOnce([
|
|
13
16
|
{ id: 1, psc: 12345 },
|
|
14
17
|
{ id: 2, psc: 54321 },
|
|
15
18
|
]);
|
|
@@ -20,7 +23,9 @@ describe("loadZipOptions", () => {
|
|
|
20
23
|
]);
|
|
21
24
|
});
|
|
22
25
|
it("should return formatted options with custom label when getLabel is provided", async () => {
|
|
23
|
-
|
|
26
|
+
const mockSearch = jest.fn();
|
|
27
|
+
search_zip_1.searchZipGeneral.mockReturnValue(mockSearch);
|
|
28
|
+
mockSearch.mockResolvedValueOnce([
|
|
24
29
|
{ id: 1, psc: 12345 },
|
|
25
30
|
{ id: 2, psc: 54321 },
|
|
26
31
|
]);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const config_1 = require("
|
|
4
|
-
const search_zip_1 = require("
|
|
5
|
-
jest.
|
|
3
|
+
const config_1 = require("../../config");
|
|
4
|
+
const search_zip_1 = require("../../v1/search-zip");
|
|
5
|
+
global.fetch = jest.fn();
|
|
6
|
+
jest.mock("../../config", () => ({
|
|
6
7
|
smartAddressUrl: "http://example.com",
|
|
7
8
|
}));
|
|
8
9
|
describe("searchZip", () => {
|
|
@@ -31,7 +32,7 @@ describe("searchZip", () => {
|
|
|
31
32
|
];
|
|
32
33
|
fetch.mockImplementation(() => Promise.resolve({
|
|
33
34
|
status: 200,
|
|
34
|
-
|
|
35
|
+
json: () => Promise.resolve(mockResponse),
|
|
35
36
|
}));
|
|
36
37
|
const result = await (0, search_zip_1.searchZip)("12345");
|
|
37
38
|
expect(result).toEqual(mockResponse);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("../../config");
|
|
4
|
+
const search_1 = require("../../v1/search");
|
|
5
|
+
global.fetch = jest.fn();
|
|
6
|
+
describe("SmartAddress v1 search", () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
jest.clearAllMocks();
|
|
9
|
+
});
|
|
10
|
+
it("should return an empty array when term is empty", async () => {
|
|
11
|
+
const result = await (0, search_1.search)({ term: "", level: 1 });
|
|
12
|
+
expect(result).toEqual([]);
|
|
13
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
14
|
+
});
|
|
15
|
+
it("should call fetch with correct parameters including address", async () => {
|
|
16
|
+
const mockResponse = [{ id: 1, name: "Test Location" }];
|
|
17
|
+
fetch.mockResolvedValue({
|
|
18
|
+
json: jest.fn().mockResolvedValue(mockResponse),
|
|
19
|
+
});
|
|
20
|
+
const result = await (0, search_1.search)({ term: "test", level: 2, limit: 5, zip: 12345, address: "some address" });
|
|
21
|
+
expect(fetch).toHaveBeenCalledWith(`${config_1.smartAddressUrl}/v1/search?term=test&level=2&limit=5&zip=12345&address=some+address`);
|
|
22
|
+
expect(result).toEqual(mockResponse);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLoaderGeneral = void 0;
|
|
4
|
+
const createLoaderGeneral = (loadOptions, params) => {
|
|
5
|
+
return (term) => loadOptions({ ...params, term });
|
|
6
|
+
};
|
|
7
|
+
exports.createLoaderGeneral = createLoaderGeneral;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddressExtendedGeneral = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getAddressExtendedGeneral = (url) => async (id) => {
|
|
6
|
+
const response = await fetch(`${config_1.smartAddressUrl}${url}${id}/extended`);
|
|
7
|
+
return await response.json();
|
|
8
|
+
};
|
|
9
|
+
exports.getAddressExtendedGeneral = getAddressExtendedGeneral;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddressGeneral = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getAddressGeneral = (url) => async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + url + id);
|
|
7
|
+
return await response.json();
|
|
8
|
+
};
|
|
9
|
+
exports.getAddressGeneral = getAddressGeneral;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|
package/common/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
@@ -4,7 +4,8 @@ type Params = {
|
|
|
4
4
|
level: number;
|
|
5
5
|
limit?: number;
|
|
6
6
|
zip?: number;
|
|
7
|
+
address?: string;
|
|
7
8
|
getLabel?: (address: Location) => string;
|
|
8
9
|
};
|
|
9
|
-
export declare const
|
|
10
|
+
export declare const loadAddressOptionsGeneral: (url: `/${string}`) => (params: Params) => Promise<Option[]>;
|
|
10
11
|
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAddressOptionsGeneral = void 0;
|
|
4
|
+
const search_1 = require("./search");
|
|
5
|
+
const loadAddressOptionsGeneral = (url) => async (params) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const limit = (_a = params.limit) !== null && _a !== void 0 ? _a : 10;
|
|
8
|
+
const getLabel = (_b = params.getLabel) !== null && _b !== void 0 ? _b : ((address) => { var _a, _b; return `${(_a = address.ulice) !== null && _a !== void 0 ? _a : ""}, ${(_b = address.obec) !== null && _b !== void 0 ? _b : ""}`; });
|
|
9
|
+
if (params.term.length === 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const response = await (0, search_1.searchGeneral)(url)({
|
|
13
|
+
term: params.term,
|
|
14
|
+
level: params.level,
|
|
15
|
+
limit,
|
|
16
|
+
zip: params.zip,
|
|
17
|
+
address: params.address,
|
|
18
|
+
});
|
|
19
|
+
return response.map((a) => ({ id: a.id, label: getLabel(a) }));
|
|
20
|
+
};
|
|
21
|
+
exports.loadAddressOptionsGeneral = loadAddressOptionsGeneral;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Location, Option } from "./types";
|
|
2
2
|
type Params = {
|
|
3
3
|
term: string;
|
|
4
|
+
limit?: number;
|
|
4
5
|
getLabel?: (address: Location) => string;
|
|
5
6
|
};
|
|
6
|
-
export declare const
|
|
7
|
+
export declare const loadZipOptionsGeneral: (url: `/${string}`) => (params: Params) => Promise<Option[]>;
|
|
7
8
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.loadZipOptionsGeneral = void 0;
|
|
4
4
|
const search_zip_1 = require("./search-zip");
|
|
5
|
-
const
|
|
5
|
+
const loadZipOptionsGeneral = (url) => async (params) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const getLabel = (_a = params.getLabel) !== null && _a !== void 0 ? _a : ((address) => `${address.psc}`);
|
|
8
8
|
if (params.term.length === 0) {
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
11
|
-
const response = await (0, search_zip_1.
|
|
11
|
+
const response = await (0, search_zip_1.searchZipGeneral)(url)(params.term, params.limit);
|
|
12
12
|
return response.map((a) => ({ id: a.id, label: getLabel(a) }));
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
14
|
+
exports.loadZipOptionsGeneral = loadZipOptionsGeneral;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchZipGeneral = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const regexp = /^([0-9]{1,5})$/;
|
|
6
|
+
const searchZipGeneral = (url) => async (term, limit) => {
|
|
7
|
+
if (term.length === 0 || !regexp.test(term)) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
const params = new URLSearchParams({
|
|
11
|
+
term: term,
|
|
12
|
+
});
|
|
13
|
+
if (limit) {
|
|
14
|
+
params.append("limit", limit.toString());
|
|
15
|
+
}
|
|
16
|
+
const response = await fetch(`${config_1.smartAddressUrl}${url}?${params}`);
|
|
17
|
+
return await response.json();
|
|
18
|
+
};
|
|
19
|
+
exports.searchZipGeneral = searchZipGeneral;
|
|
@@ -4,6 +4,7 @@ type Props = {
|
|
|
4
4
|
level: number;
|
|
5
5
|
limit?: number;
|
|
6
6
|
zip?: number;
|
|
7
|
+
address?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const searchGeneral: (url: `/${string}`) => (props: Props) => Promise<Location[]>;
|
|
9
10
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.searchGeneral = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
|
-
const
|
|
5
|
+
const searchGeneral = (url) => async (props) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const limit = (_a = props.limit) !== null && _a !== void 0 ? _a : 10;
|
|
8
8
|
if (props.term.length === 0) {
|
|
@@ -16,7 +16,10 @@ const search = async (props) => {
|
|
|
16
16
|
if (props.zip) {
|
|
17
17
|
params.append("zip", props.zip.toString());
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (props.address) {
|
|
20
|
+
params.append("address", props.address);
|
|
21
|
+
}
|
|
22
|
+
const response = await fetch(`${config_1.smartAddressUrl}${url}?${params}`);
|
|
23
|
+
return await response.json();
|
|
21
24
|
};
|
|
22
|
-
exports.
|
|
25
|
+
exports.searchGeneral = searchGeneral;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
type BasicType = {
|
|
1
|
+
export type BasicType = {
|
|
2
2
|
id: number;
|
|
3
3
|
nazev: string | null;
|
|
4
4
|
};
|
|
5
|
-
type Type = {
|
|
5
|
+
export type Type = {
|
|
6
6
|
id: number;
|
|
7
7
|
nazev: string | null;
|
|
8
8
|
popis: string | null;
|
|
@@ -25,8 +25,8 @@ export type Option = {
|
|
|
25
25
|
label: string;
|
|
26
26
|
};
|
|
27
27
|
export type Point = {
|
|
28
|
-
latitude:
|
|
29
|
-
longitude:
|
|
28
|
+
latitude: number;
|
|
29
|
+
longitude: number;
|
|
30
30
|
};
|
|
31
31
|
export type Location = {
|
|
32
32
|
id: number;
|
|
@@ -86,4 +86,3 @@ export type LocationExtended = {
|
|
|
86
86
|
objectSize: string | null;
|
|
87
87
|
objectSizeSquare: number | null;
|
|
88
88
|
};
|
|
89
|
-
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Location } from "./types";
|
|
2
|
+
type Params = {
|
|
3
|
+
level: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
zip?: number;
|
|
6
|
+
getLabel?: (address: Location) => string;
|
|
7
|
+
};
|
|
8
|
+
export declare const createAddressLoader: (params: Params) => (term: string) => Promise<import("./types").Option[]>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAddressLoader = void 0;
|
|
4
|
+
const create_loader_1 = require("../common/create-loader");
|
|
5
|
+
const load_address_options_1 = require("./load-address-options");
|
|
6
|
+
const createAddressLoader = (params) => (0, create_loader_1.createLoaderGeneral)(load_address_options_1.loadAddressOptions, params);
|
|
7
|
+
exports.createAddressLoader = createAddressLoader;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createZipLoader = void 0;
|
|
4
|
+
const create_loader_1 = require("../common/create-loader");
|
|
4
5
|
const load_zip_options_1 = require("./load-zip-options");
|
|
5
|
-
const createZipLoader = (params) =>
|
|
6
|
-
return (term) => (0, load_zip_options_1.loadZipOptions)({
|
|
7
|
-
term,
|
|
8
|
-
getLabel: params.getLabel,
|
|
9
|
-
});
|
|
10
|
-
};
|
|
6
|
+
const createZipLoader = (params) => (0, create_loader_1.createLoaderGeneral)(load_zip_options_1.loadZipOptions, params);
|
|
11
7
|
exports.createZipLoader = createZipLoader;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const getAddressExtended: (id: number) => Promise<LocationExtended>;
|
|
1
|
+
export declare const getAddressExtended: (id: number) => Promise<import("./types").LocationExtended>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddressExtended = void 0;
|
|
4
|
+
const get_address_extended_1 = require("../common/get-address-extended");
|
|
5
|
+
exports.getAddressExtended = (0, get_address_extended_1.getAddressExtendedGeneral)("/v1/address/");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getAddress: (id: number) => Promise<import("./types").Location>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCityPart = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const getCityPart = async (id) => {
|
|
6
|
-
const response = await fetch(config_1.smartAddressUrl
|
|
7
|
-
return
|
|
6
|
+
const response = await fetch(`${config_1.smartAddressUrl}/v1/address/city-part/${id}`);
|
|
7
|
+
return await response.json();
|
|
8
8
|
};
|
|
9
9
|
exports.getCityPart = getCityPart;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCity = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const getCity = async (id) => {
|
|
6
|
-
const response = await fetch(config_1.smartAddressUrl +
|
|
7
|
-
return
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + `${config_1.smartAddressUrl}/v1/address/city/${id}`);
|
|
7
|
+
return await response.json();
|
|
8
8
|
};
|
|
9
9
|
exports.getCity = getCity;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMomc = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const getMomc = async (id) => {
|
|
6
|
-
const response = await fetch(config_1.smartAddressUrl
|
|
7
|
-
return
|
|
6
|
+
const response = await fetch(`${config_1.smartAddressUrl}/v1/address/momc/${id}`);
|
|
7
|
+
return await response.json();
|
|
8
8
|
};
|
|
9
9
|
exports.getMomc = getMomc;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMop = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const getMop = async (id) => {
|
|
6
|
-
const response = await fetch(config_1.smartAddressUrl
|
|
7
|
-
return
|
|
6
|
+
const response = await fetch(`${config_1.smartAddressUrl}/v1/address/mop/${id}`);
|
|
7
|
+
return await response.json();
|
|
8
8
|
};
|
|
9
9
|
exports.getMop = getMop;
|
|
@@ -4,6 +4,6 @@ exports.getStreet = void 0;
|
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const getStreet = async (id) => {
|
|
6
6
|
const response = await fetch(config_1.smartAddressUrl + "/v1/address/street/" + id);
|
|
7
|
-
return
|
|
7
|
+
return await response.json();
|
|
8
8
|
};
|
|
9
9
|
exports.getStreet = getStreet;
|
|
@@ -5,10 +5,10 @@ export declare const SmartAddress: {
|
|
|
5
5
|
limit?: number;
|
|
6
6
|
zip?: number;
|
|
7
7
|
getLabel?: (address: import("./types").Location) => string;
|
|
8
|
-
}) => (
|
|
8
|
+
}) => (term: string) => Promise<import("./types").Option[]>;
|
|
9
9
|
createZipLoader: (params: {
|
|
10
10
|
getLabel?: (address: import("./types").Location) => string;
|
|
11
|
-
}) => (
|
|
11
|
+
}) => (term: string) => Promise<import("./types").Option[]>;
|
|
12
12
|
getAddress: (id: number) => Promise<import("./types").Location>;
|
|
13
13
|
getAddressExtended: (id: number) => Promise<import("./types").LocationExtended>;
|
|
14
14
|
getCity: (id: number) => Promise<import("./types").Location>;
|
|
@@ -21,10 +21,12 @@ export declare const SmartAddress: {
|
|
|
21
21
|
level: number;
|
|
22
22
|
limit?: number;
|
|
23
23
|
zip?: number;
|
|
24
|
+
address?: string;
|
|
24
25
|
getLabel?: (address: import("./types").Location) => string;
|
|
25
26
|
}) => Promise<import("./types").Option[]>;
|
|
26
27
|
loadZipOptions: (params: {
|
|
27
28
|
term: string;
|
|
29
|
+
limit?: number;
|
|
28
30
|
getLabel?: (address: import("./types").Location) => string;
|
|
29
31
|
}) => Promise<import("./types").Option[]>;
|
|
30
32
|
search: (props: {
|
|
@@ -32,6 +34,7 @@ export declare const SmartAddress: {
|
|
|
32
34
|
level: number;
|
|
33
35
|
limit?: number;
|
|
34
36
|
zip?: number;
|
|
37
|
+
address?: string;
|
|
35
38
|
}) => Promise<import("./types").Location[]>;
|
|
36
|
-
searchZip: (term: string) => Promise<import("./types").Location[]>;
|
|
39
|
+
searchZip: (term: string, limit?: number) => Promise<import("./types").Location[]>;
|
|
37
40
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAddressOptions = void 0;
|
|
4
|
+
const load_address_options_1 = require("../common/load-address-options");
|
|
5
|
+
exports.loadAddressOptions = (0, load_address_options_1.loadAddressOptionsGeneral)("/v1/search");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadZipOptions = void 0;
|
|
4
|
+
const load_zip_options_1 = require("../common/load-zip-options");
|
|
5
|
+
exports.loadZipOptions = (0, load_zip_options_1.loadZipOptionsGeneral)("/v1/zip/search");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const searchZip: (term: string, limit?: number) => Promise<import("./types").Location[]>;
|
package/v1/search-zip.js
ADDED
package/v1/search.d.ts
ADDED
package/v1/search.js
ADDED
package/v1/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../common/types";
|