@fieldia/map 0.19.0 → 0.20.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.
Files changed (66) hide show
  1. package/README.md +90 -3
  2. package/package.json +4 -4
  3. package/src/lib/address-labels.d.mts +14 -2
  4. package/src/lib/address-labels.d.ts +14 -2
  5. package/src/lib/address-labels.js.map +1 -1
  6. package/src/lib/address-labels.mjs.map +1 -1
  7. package/src/lib/address-line.d.mts +10 -1
  8. package/src/lib/address-line.d.ts +10 -1
  9. package/src/lib/address-line.js +25 -8
  10. package/src/lib/address-line.js.map +1 -1
  11. package/src/lib/address-line.mjs +24 -8
  12. package/src/lib/address-line.mjs.map +1 -1
  13. package/src/lib/address-names.d.mts +38 -0
  14. package/src/lib/address-names.d.ts +38 -0
  15. package/src/lib/address-names.js +240 -0
  16. package/src/lib/address-names.js.map +1 -0
  17. package/src/lib/address-names.mjs +232 -0
  18. package/src/lib/address-names.mjs.map +1 -0
  19. package/src/lib/address-parts.d.mts +128 -10
  20. package/src/lib/address-parts.d.ts +128 -10
  21. package/src/lib/address-parts.js +836 -17
  22. package/src/lib/address-parts.js.map +1 -1
  23. package/src/lib/address-parts.mjs +827 -14
  24. package/src/lib/address-parts.mjs.map +1 -1
  25. package/src/lib/address-search.d.mts +8 -4
  26. package/src/lib/address-search.d.ts +8 -4
  27. package/src/lib/address-search.js +27 -9
  28. package/src/lib/address-search.js.map +1 -1
  29. package/src/lib/address-search.mjs +28 -10
  30. package/src/lib/address-search.mjs.map +1 -1
  31. package/src/lib/address-suggest.d.mts +5 -2
  32. package/src/lib/address-suggest.d.ts +5 -2
  33. package/src/lib/address-suggest.js +161 -28
  34. package/src/lib/address-suggest.js.map +1 -1
  35. package/src/lib/address-suggest.mjs +161 -28
  36. package/src/lib/address-suggest.mjs.map +1 -1
  37. package/src/lib/form-map.js +9 -7
  38. package/src/lib/form-map.js.map +1 -1
  39. package/src/lib/form-map.mjs +10 -8
  40. package/src/lib/form-map.mjs.map +1 -1
  41. package/src/lib/place.js +21 -10
  42. package/src/lib/place.js.map +1 -1
  43. package/src/lib/place.mjs +21 -10
  44. package/src/lib/place.mjs.map +1 -1
  45. package/src/lib/providers.d.mts +6 -0
  46. package/src/lib/providers.d.ts +6 -0
  47. package/src/lib/providers.js +46 -97
  48. package/src/lib/providers.js.map +1 -1
  49. package/src/lib/providers.mjs +46 -97
  50. package/src/lib/providers.mjs.map +1 -1
  51. package/src/lib/route-line.d.mts +9 -0
  52. package/src/lib/route-line.d.ts +9 -0
  53. package/src/lib/route-line.js +13 -0
  54. package/src/lib/route-line.js.map +1 -1
  55. package/src/lib/route-line.mjs +11 -0
  56. package/src/lib/route-line.mjs.map +1 -1
  57. package/src/lib/routes.js +6 -2
  58. package/src/lib/routes.js.map +1 -1
  59. package/src/lib/routes.mjs +6 -2
  60. package/src/lib/routes.mjs.map +1 -1
  61. package/src/lib/search-box.d.mts +15 -3
  62. package/src/lib/search-box.d.ts +15 -3
  63. package/src/lib/search-box.js +118 -34
  64. package/src/lib/search-box.js.map +1 -1
  65. package/src/lib/search-box.mjs +118 -34
  66. package/src/lib/search-box.mjs.map +1 -1
@@ -1,9 +1,16 @@
1
+ import type { Locale } from '@fieldia/core';
2
+ import type { PlaceFound, SearchRequest } from './providers';
1
3
  /**
2
- * An address in its parts, as Fieldia's address field (`json.address`) keeps
3
- * one: the street with its number, the city, the region (a state, a
4
- * governorate), the postcode, and the country as its ISO code ("EG"). Each
5
- * provider names them its own way; they are read into these here, asked for
6
- * only by a search that wants them (`SearchRequest.parts`).
4
+ * How each provider's addresses read, loaded with the first search that
5
+ * needs it (an address field's; any of Azure's or Google's), never with a
6
+ * page: an address in its parts, as Fieldia's address field
7
+ * (`json.address`) keeps one (the street with its number, the city, the
8
+ * region, a state or a governorate, the postcode, and the country as its ISO
9
+ * code, "EG"); Azure's and Google's places on two lines, in the page's
10
+ * language; and where a suggestion picked is, for those whose suggestions
11
+ * carry no place. Each provider names the parts its own way: what each
12
+ * answered in Egypt, Saudi Arabia, the UAE and Jordan on 12 Oct 2026 is
13
+ * read here.
7
14
  */
8
15
  export interface AddressParts {
9
16
  street?: string;
@@ -16,13 +23,124 @@ export interface AddressParts {
16
23
  export declare const photonParts: (p: unknown) => AddressParts | undefined;
17
24
  /** Nominatim's `address` (with `addressdetails=1`): a town or a village where there is no city. */
18
25
  export declare const nominatimParts: (a: unknown) => AddressParts | undefined;
19
- /** Azure's `address`: its own street line when it has one, its first admin district the region; its country's code is `ISO`, or `iso` in some answers. */
20
- export declare const azureParts: (a: unknown) => AddressParts | undefined;
21
- /** Google's `addressComponents`, each by its type: the country by its short code. */
22
- export declare const googleParts: (components: unknown) => AddressParts | undefined;
23
- /** Mapbox's `context`: its address's own line (number and street), or the street alone. */
26
+ /** Mapbox's `context`: its address's own line (number and street, in its country's order), or the street alone. */
24
27
  export declare const mapboxParts: (p: unknown) => AddressParts | undefined;
25
28
  /** Only places in the countries asked for, when some are: for a provider that cannot be asked to keep to them. */
26
29
  export declare const inCountries: <T extends {
27
30
  parts?: AddressParts;
28
31
  }>(places: T[], countries?: string[]) => T[];
32
+ /**
33
+ * The countries a provider can be asked to keep to: ISO codes, each once,
34
+ * "UK" read as "GB" (as every provider's parts name it). A code no one
35
+ * knows ("XX", "EGY") is left out and said once: Azure and Google refuse a
36
+ * whole search for one.
37
+ */
38
+ export declare function knownCountries(countries: string[] | undefined): string[];
39
+ /** The countries Google is asked to keep to (`includedRegionCodes`): 15 at most, as it refuses a whole search for more; with more, none, said once. */
40
+ export declare function googleRegions(countries: string[] | undefined): string[];
41
+ /** What one of Azure's places is, by its type: a street (an address, a road), an area (a town, a district, a governorate), or a place with a name of its own (a station, a park, a mall). */
42
+ type Level = 'street' | 'area' | 'named';
43
+ type LatLngAt = {
44
+ lat: number;
45
+ lng: number;
46
+ };
47
+ /** A place of Azure's, with what locating it takes: its address as Azure gave it, its level, its street line or its area's own name, and where the search looked. */
48
+ export interface AzurePlace extends PlaceFound {
49
+ country: string;
50
+ azure: {
51
+ address: unknown;
52
+ level: Level;
53
+ street: string;
54
+ area?: string;
55
+ type?: string;
56
+ near?: LatLngAt;
57
+ };
58
+ }
59
+ /** Azure's places on two lines: the street, or the place's own name (a quarter's, a town's), then where it is; their parts when asked. */
60
+ export declare function azurePlaces(found: unknown, locale: Locale, typed?: string, withParts?: boolean, near?: LatLngAt): AzurePlace[];
61
+ /** A point named by Azure: its first address, in order. */
62
+ export declare function azureNamed(found: unknown, locale: Locale): string;
63
+ type Ask = (params: Record<string, string | number | undefined>) => Promise<unknown>;
64
+ /**
65
+ * Azure's suggestions: nearest the place the page gives first, or the whole
66
+ * world's by prominence when it gives none; kept to the countries the page
67
+ * names by Azure itself (`countryRegion`), one request for each (a tenth of
68
+ * a Search transaction each; a list of them answers nothing), taken in
69
+ * turn, five in all. For an address field (`addresses`), no postcodes alone,
70
+ * and the addresses and areas first, the places with names of their own
71
+ * (a station, a park) after them, as Azure's types say. A row that reads as
72
+ * one before it is left out, as one that says less of the same place than
73
+ * another is. The word for a district typed before its name ("حي الروضة")
74
+ * is left out of the words asked, as Azure names its districts without it
75
+ * (with it, Azure lists other towns' streets and districts named with the
76
+ * word, and none of Riyadh's Al Rawdah); the words are asked as typed only
77
+ * when that finds nothing.
78
+ */
79
+ export declare function azureSearch(autocomplete: Ask, request: SearchRequest): Promise<AzurePlace[]>;
80
+ /**
81
+ * Where a suggestion of Azure's is (its suggestions carry no place), asked
82
+ * of its geocoding, the hits in the suggestion's own country and admin
83
+ * districts kept (`fits`; "Al Rawdah" in Riyadh's governorate, never in
84
+ * Al Wasiah's).
85
+ *
86
+ * A street, by its own address in Azure's structured form: its street line
87
+ * (never with a house number Azure made up), its own district for its
88
+ * locality where it names one below its town (its neighbourhood, the
89
+ * district its line names, "Kamel El Shenawy, Garden City"), then its
90
+ * locality, its admin districts, postcode and country; then by its two
91
+ * lines (`query`). Of each answer's streets, the one that names its
92
+ * district; else one in the district's own box as Azure has it (a little
93
+ * beyond it, as its point is a stretch's middle), asked for once; never a
94
+ * street of the name in another district (Azure's first "Kamel El Shenawy"
95
+ * is New Cairo's, 25 km from Garden City's), nor, for a street named by its
96
+ * number alone ("10 41 Street | Abu Tina"), one that does not say it is in
97
+ * its district where Azure knows none. Found nowhere so, its district
98
+ * (`precise: false`), else its town.
99
+ *
100
+ * An area by its own name (its neighbourhood, the place its line names, its
101
+ * locality; a governorate named for its town as the town: "Sohag", whose
102
+ * division's middle is 57 km from the city), never by its postcode (one of
103
+ * a town's many: Azure gives Tanta's 31111 for Tanta), or by its two lines
104
+ * where its neighbourhood is not its locality; a place with a name of its
105
+ * own by its two lines. Of places of one kind and name (Abu Dhabi's Al
106
+ * Bateen and Al Ain's), the one nearest where the search looked; found
107
+ * nowhere, the town it is in (`precise: false`).
108
+ *
109
+ * It is precise when the hit is the place itself (`isItself`), a street's
110
+ * in its own district: where Azure knows no box for the district, a street
111
+ * it marks `Ambiguous` (several of the words) is only near, as one of a
112
+ * number is unless it says it is in its district. Otherwise only near it.
113
+ * Never a place anywhere else: none is found then.
114
+ * A suggestion that names no region ("البرشاء 2", which Azure lists beside
115
+ * the same in Dubai) takes its city and region from the place found.
116
+ */
117
+ export declare function azureLocate(geocode: Ask, place: AzurePlace, locale: Locale): Promise<{
118
+ precise?: false | undefined;
119
+ parts?: {
120
+ city?: string;
121
+ region?: string;
122
+ street?: string;
123
+ postcode?: string;
124
+ country?: string;
125
+ } | undefined;
126
+ address: string;
127
+ lat: number;
128
+ lng: number;
129
+ }>;
130
+ /**
131
+ * Google's `addressComponents`, each by its type: the country by its short
132
+ * code. Its number where Google's own line (`formatted`) puts it: before the
133
+ * street in Egypt and Saudi Arabia ("7524 King Fahd Rd"), after it in Jordan
134
+ * and Germany ("Rainbow St. 15"). Its city its locality; Egypt's streets have
135
+ * none, and their district stands for it ("Qasr El Nil", "Maadi"), by its
136
+ * name alone in Arabic too ("الدقي", not "قسم الدقي", its police district's).
137
+ */
138
+ export declare const googleParts: (components: unknown, formatted?: unknown) => AddressParts | undefined;
139
+ /**
140
+ * Google's suggestions: each one's name, and where it is; for an address
141
+ * field, the addresses first (their types say "geocode"), the shops and
142
+ * buildings after them. Each is located when picked, through `details`
143
+ * (Place Details), which ends its session (`end`), as picking it does.
144
+ */
145
+ export declare function googlePlaces(answer: unknown, { locale, addresses, parts }: SearchRequest, details: (placeId: string) => Promise<unknown>, end: () => void): PlaceFound[];
146
+ export {};