@uxf/smart-address 11.80.4 → 11.122.4

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.
Files changed (81) hide show
  1. package/README.md +109 -45
  2. package/{v1 → common/__tests__}/load-address-options.test.js +22 -14
  3. package/{v1 → common/__tests__}/load-zip-options.test.js +10 -5
  4. package/{v1 → common/__tests__}/search-zip.test.js +5 -4
  5. package/common/__tests__/search.test.js +24 -0
  6. package/common/create-loader.d.ts +4 -0
  7. package/common/create-loader.js +7 -0
  8. package/common/get-address-extended.d.ts +2 -0
  9. package/common/get-address-extended.js +9 -0
  10. package/common/get-address.d.ts +2 -0
  11. package/common/get-address.js +9 -0
  12. package/common/index.d.ts +1 -0
  13. package/common/index.js +17 -0
  14. package/common/load-address-options.d.ts +11 -0
  15. package/common/load-address-options.js +21 -0
  16. package/common/load-zip-options.d.ts +8 -0
  17. package/common/load-zip-options.js +14 -0
  18. package/common/search-zip.d.ts +2 -0
  19. package/common/search-zip.js +19 -0
  20. package/common/search.d.ts +10 -0
  21. package/common/search.js +25 -0
  22. package/common/types.d.ts +88 -0
  23. package/common/types.js +2 -0
  24. package/package.json +1 -1
  25. package/v1/create-address-loader.d.ts +2 -2
  26. package/v1/create-address-loader.js +2 -9
  27. package/v1/create-zip-loader.d.ts +2 -2
  28. package/v1/create-zip-loader.js +2 -6
  29. package/v1/get-address-extended.d.ts +1 -2
  30. package/v1/get-address-extended.js +2 -6
  31. package/v1/get-address.d.ts +1 -2
  32. package/v1/get-address.js +2 -6
  33. package/v1/get-city-part.js +2 -2
  34. package/v1/get-city.js +2 -2
  35. package/v1/get-momc.js +2 -2
  36. package/v1/get-mop.js +2 -2
  37. package/v1/get-street.js +1 -1
  38. package/v1/index.d.ts +6 -3
  39. package/v1/load-address-options.d.ts +4 -6
  40. package/v1/load-address-options.js +2 -12
  41. package/v1/load-zip-options.d.ts +4 -6
  42. package/v1/load-zip-options.js +2 -11
  43. package/v1/search-zip.d.ts +1 -2
  44. package/v1/search-zip.js +2 -13
  45. package/v1/search.d.ts +3 -5
  46. package/v1/search.js +2 -19
  47. package/v1/types.d.ts +1 -89
  48. package/v1/types.js +15 -0
  49. package/v2/__tests__/get-building-addresses.test.d.ts +1 -0
  50. package/v2/__tests__/get-building-addresses.test.js +49 -0
  51. package/v2/__tests__/search-city-part.test.d.ts +1 -0
  52. package/v2/__tests__/search-city-part.test.js +46 -0
  53. package/v2/create-address-loader.d.ts +10 -0
  54. package/v2/create-address-loader.js +7 -0
  55. package/v2/create-zip-loader.d.ts +7 -0
  56. package/v2/create-zip-loader.js +7 -0
  57. package/v2/get-address-extended.d.ts +2 -0
  58. package/v2/get-address-extended.js +5 -0
  59. package/v2/get-address.d.ts +1 -0
  60. package/v2/get-address.js +5 -0
  61. package/v2/get-building-addresses.d.ts +2 -0
  62. package/v2/get-building-addresses.js +9 -0
  63. package/v2/index.d.ts +11 -0
  64. package/v2/index.js +27 -0
  65. package/v2/load-address-options.d.ts +8 -0
  66. package/v2/load-address-options.js +5 -0
  67. package/v2/load-zip-options.d.ts +5 -0
  68. package/v2/load-zip-options.js +5 -0
  69. package/v2/search-city-part.d.ts +2 -0
  70. package/v2/search-city-part.js +18 -0
  71. package/v2/search-zip.d.ts +1 -0
  72. package/v2/search-zip.js +5 -0
  73. package/v2/search.d.ts +7 -0
  74. package/v2/search.js +5 -0
  75. package/v2/types.d.ts +48 -0
  76. package/v2/types.js +17 -0
  77. package/v1/search.test.js +0 -33
  78. /package/{v1 → common/__tests__}/load-address-options.test.d.ts +0 -0
  79. /package/{v1 → common/__tests__}/load-zip-options.test.d.ts +0 -0
  80. /package/{v1 → common/__tests__}/search-zip.test.d.ts +0 -0
  81. /package/{v1 → common/__tests__}/search.test.d.ts +0 -0
@@ -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)("/v2/search");
@@ -0,0 +1,5 @@
1
+ export declare const loadZipOptions: (params: {
2
+ term: string;
3
+ limit?: number;
4
+ getLabel?: (address: import("./types").Location) => string;
5
+ }) => Promise<import("./types").Option[]>;
@@ -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)("/v2/zip/search");
@@ -0,0 +1,2 @@
1
+ import { CityPart } from "./types";
2
+ export declare const searchCityPart: (term: string, limit?: number) => Promise<CityPart[]>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchCityPart = void 0;
4
+ const config_1 = require("../config");
5
+ const searchCityPart = async (term, limit) => {
6
+ if (term.length === 0) {
7
+ return [];
8
+ }
9
+ const params = new URLSearchParams({
10
+ term,
11
+ });
12
+ if (limit) {
13
+ params.append("limit", limit.toString());
14
+ }
15
+ const response = await fetch(`${config_1.smartAddressUrl}/v2/city-part/search?${params.toString()}`);
16
+ return (await response.json());
17
+ };
18
+ exports.searchCityPart = searchCityPart;
@@ -0,0 +1 @@
1
+ export declare const searchZip: (term: string, limit?: number) => Promise<import("./types").Location[]>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchZip = void 0;
4
+ const search_zip_1 = require("../common/search-zip");
5
+ exports.searchZip = (0, search_zip_1.searchZipGeneral)("/v2/zip/search");
package/v2/search.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare const search: (props: {
2
+ term: string;
3
+ level: number;
4
+ limit?: number;
5
+ zip?: number;
6
+ address?: string;
7
+ }) => Promise<import("./types").Location[]>;
package/v2/search.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.search = void 0;
4
+ const search_1 = require("../common/search");
5
+ exports.search = (0, search_1.searchGeneral)("/v2/search");
package/v2/types.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ export * from "../common/types";
2
+ import { BuildingType, BuildingUsageType, ConstructionType, ElevatorType, GasConnectionType, HeatingType, Location, ObjectType, ObjectTypeBasic, SewerConnectionType, WaterConnectionType } from "../common/types";
3
+ export type AddressExtendedBasicResponse = Location;
4
+ export type AddressExtendedAdministrativeResponse = {
5
+ id: number;
6
+ isknBudovaId: string | null;
7
+ stavebniObjektKod: string | null;
8
+ parcelaKod: string | null;
9
+ zpusobVyuzitiObjektu: BuildingUsageType | null;
10
+ objectType: ObjectType | null;
11
+ objectTypeBasic: ObjectTypeBasic | null;
12
+ };
13
+ export type AddressExtendedBuildingResponse = {
14
+ id: number;
15
+ typBudovy: BuildingType | null;
16
+ druhKonstrukce: ConstructionType | null;
17
+ pocetBytu: number | null;
18
+ pocetPodlazi: number | null;
19
+ pripojeniKanalizace: SewerConnectionType | null;
20
+ pripojeniVodovod: WaterConnectionType | null;
21
+ vybaveniVytahem: ElevatorType | null;
22
+ zastavenaPlocha: number | null;
23
+ obestavenyProstor: number | null;
24
+ podlahovaPlocha: number | null;
25
+ objectSize: string | null;
26
+ };
27
+ export type AddressExtendedEnergyResponse = {
28
+ id: number;
29
+ distributorElektrinyKod: string | null;
30
+ distributorElektrinyId: number | null;
31
+ distributorPlynuKod: string | null;
32
+ distributorPlynuId: number | null;
33
+ pripojeniPlyn: GasConnectionType | null;
34
+ zpusobVytapeni: HeatingType | null;
35
+ };
36
+ export type AddressExtended = {
37
+ zakladniAdresa: AddressExtendedBasicResponse;
38
+ administrativniUdaje: AddressExtendedAdministrativeResponse;
39
+ udajeBudovy: AddressExtendedBuildingResponse;
40
+ udajeEnergii: AddressExtendedEnergyResponse;
41
+ };
42
+ export type CityPart = {
43
+ id: number;
44
+ name: string;
45
+ obecKod: number;
46
+ obecNazev: string;
47
+ zips: string[];
48
+ };
package/v2/types.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("../common/types"), exports);
package/v1/search.test.js DELETED
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_1 = require("../config");
4
- const search_1 = require("./search");
5
- global.fetch = jest.fn();
6
- describe("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 and return data", async () => {
16
- const mockResponse = [{ id: 1, name: "Test Location" }];
17
- fetch.mockResolvedValue({
18
- text: jest.fn().mockResolvedValue(JSON.stringify(mockResponse)),
19
- });
20
- const result = await (0, search_1.search)({ term: "test", level: 2, limit: 5, zip: 12345 });
21
- expect(fetch).toHaveBeenCalledWith(`${config_1.smartAddressUrl}/v1/search?term=test&level=2&limit=5&zip=12345`);
22
- expect(result).toEqual(mockResponse);
23
- });
24
- it("should call fetch without zip when zip is not provided", async () => {
25
- const mockResponse = [{ id: 2, name: "Another Location" }];
26
- fetch.mockResolvedValue({
27
- text: jest.fn().mockResolvedValue(JSON.stringify(mockResponse)),
28
- });
29
- const result = await (0, search_1.search)({ term: "another test", level: 1 });
30
- expect(fetch).toHaveBeenCalledWith(`${config_1.smartAddressUrl}/v1/search?term=another+test&level=1&limit=10`);
31
- expect(result).toEqual(mockResponse);
32
- });
33
- });
File without changes
File without changes