@honua/app-platform 0.0.20-alpha.0 → 0.1.1-beta.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 (381) hide show
  1. package/contract/discovery.d.ts +231 -0
  2. package/contract/discovery.d.ts.map +1 -0
  3. package/contract/discovery.js +554 -0
  4. package/contract/edit-sketch.d.ts +8 -0
  5. package/contract/edit-sketch.d.ts.map +1 -1
  6. package/contract/edit-sketch.js +15 -0
  7. package/contract/edit-snapping.d.ts +160 -0
  8. package/contract/edit-snapping.d.ts.map +1 -0
  9. package/contract/edit-snapping.js +675 -0
  10. package/contract/generated/projjson-v0.7-crs-validator.d.ts +35 -0
  11. package/contract/generated/projjson-v0.7-crs-validator.d.ts.map +1 -0
  12. package/contract/generated/projjson-v0.7-crs-validator.js +3941 -0
  13. package/contract/index.d.ts +11 -2
  14. package/contract/index.d.ts.map +1 -1
  15. package/contract/index.js +4 -1
  16. package/contract/pmtiles.d.ts +31 -0
  17. package/contract/pmtiles.d.ts.map +1 -1
  18. package/contract/pmtiles.js +60 -20
  19. package/contract/protocol-module.d.ts +70 -0
  20. package/contract/protocol-module.d.ts.map +1 -0
  21. package/contract/protocol-module.js +1 -0
  22. package/contract/schema-envelope.d.ts +26 -0
  23. package/contract/schema-envelope.d.ts.map +1 -0
  24. package/contract/schema-envelope.js +25 -0
  25. package/contract/schema.d.ts +582 -0
  26. package/contract/schema.d.ts.map +1 -0
  27. package/contract/schema.js +2483 -0
  28. package/contract/source-capability-support.d.ts +6 -0
  29. package/contract/source-capability-support.d.ts.map +1 -0
  30. package/contract/source-capability-support.js +154 -0
  31. package/contract/source.d.ts +35 -17
  32. package/contract/source.d.ts.map +1 -1
  33. package/contract/source.js +267 -71
  34. package/contract/types.d.ts +140 -4
  35. package/contract/types.d.ts.map +1 -1
  36. package/contract/types.js +6 -14
  37. package/core/bounded-json.d.ts +4 -0
  38. package/core/bounded-json.d.ts.map +1 -0
  39. package/core/bounded-json.js +38 -0
  40. package/core/cache-state.d.ts +9 -0
  41. package/core/cache-state.d.ts.map +1 -1
  42. package/core/cache-state.js +10 -0
  43. package/core/capabilities-xml.d.ts +33 -0
  44. package/core/capabilities-xml.d.ts.map +1 -0
  45. package/core/capabilities-xml.js +331 -0
  46. package/core/client.d.ts +4 -1
  47. package/core/client.d.ts.map +1 -1
  48. package/core/client.js +115 -29
  49. package/core/error-classifications.d.ts +153 -0
  50. package/core/error-classifications.d.ts.map +1 -0
  51. package/core/error-classifications.js +140 -0
  52. package/core/error-code-registry.d.ts +158 -0
  53. package/core/error-code-registry.d.ts.map +1 -0
  54. package/core/error-code-registry.js +143 -0
  55. package/core/error-envelope.d.ts +68 -0
  56. package/core/error-envelope.d.ts.map +1 -0
  57. package/core/error-envelope.js +357 -0
  58. package/core/errors.d.ts +45 -29
  59. package/core/errors.d.ts.map +1 -1
  60. package/core/errors.js +97 -50
  61. package/core/geoparquet-sql.d.ts +30 -2
  62. package/core/geoparquet-sql.d.ts.map +1 -1
  63. package/core/geoparquet-sql.js +38 -3
  64. package/core/odata-key-path.d.ts +12 -0
  65. package/core/odata-key-path.d.ts.map +1 -0
  66. package/core/odata-key-path.js +28 -0
  67. package/core/odata-write-codec.d.ts +66 -0
  68. package/core/odata-write-codec.d.ts.map +1 -0
  69. package/core/odata-write-codec.js +1083 -0
  70. package/core/odata.d.ts +59 -7
  71. package/core/odata.d.ts.map +1 -1
  72. package/core/odata.js +431 -99
  73. package/core/ogc-features.d.ts.map +1 -1
  74. package/core/ogc-features.js +3 -0
  75. package/core/ogc-maps.d.ts +7 -0
  76. package/core/ogc-maps.d.ts.map +1 -1
  77. package/core/ogc-maps.js +46 -7
  78. package/core/ogc-processes.d.ts +2 -1
  79. package/core/ogc-processes.d.ts.map +1 -1
  80. package/core/ogc-processes.js +33 -5
  81. package/core/ogc-records.d.ts +9 -0
  82. package/core/ogc-records.d.ts.map +1 -1
  83. package/core/ogc-records.js +78 -29
  84. package/core/ogc-tiles.d.ts +10 -1
  85. package/core/ogc-tiles.d.ts.map +1 -1
  86. package/core/ogc-tiles.js +56 -17
  87. package/core/path-utils.d.ts +9 -0
  88. package/core/path-utils.d.ts.map +1 -1
  89. package/core/path-utils.js +19 -0
  90. package/core/protocol-transport.d.ts +1 -0
  91. package/core/protocol-transport.d.ts.map +1 -1
  92. package/core/request-pipeline.d.ts.map +1 -1
  93. package/core/request-pipeline.js +1 -1
  94. package/core/spatial-filter.d.ts +8 -4
  95. package/core/spatial-filter.d.ts.map +1 -1
  96. package/core/spatial-filter.js +206 -16
  97. package/core/stac-static.d.ts +6 -2
  98. package/core/stac-static.d.ts.map +1 -1
  99. package/core/stac-static.js +260 -69
  100. package/core/surfaces.d.ts.map +1 -1
  101. package/core/surfaces.js +69 -5
  102. package/core/types.d.ts +125 -7
  103. package/core/types.d.ts.map +1 -1
  104. package/core/wfs-capabilities.d.ts +2 -0
  105. package/core/wfs-capabilities.d.ts.map +1 -1
  106. package/core/wfs-capabilities.js +8 -1
  107. package/core/wfs.d.ts.map +1 -1
  108. package/core/wfs.js +10 -0
  109. package/core/wms-capabilities.d.ts +56 -84
  110. package/core/wms-capabilities.d.ts.map +1 -1
  111. package/core/wms-capabilities.js +212 -509
  112. package/core/wmts-capabilities.d.ts +62 -62
  113. package/core/wmts-capabilities.d.ts.map +1 -1
  114. package/core/wmts-capabilities.js +224 -371
  115. package/esri-compat/editor.d.ts +8 -0
  116. package/esri-compat/editor.d.ts.map +1 -1
  117. package/esri-compat/editor.js +13 -0
  118. package/esri-compat/feature-layer.d.ts +2 -0
  119. package/esri-compat/feature-layer.d.ts.map +1 -1
  120. package/esri-compat/feature-layer.js +1 -0
  121. package/esri-compat/layer-list.d.ts +11 -0
  122. package/esri-compat/layer-list.d.ts.map +1 -1
  123. package/esri-compat/layer-list.js +49 -0
  124. package/esri-compat/legend.d.ts +10 -0
  125. package/esri-compat/legend.d.ts.map +1 -1
  126. package/esri-compat/legend.js +27 -0
  127. package/esri-compat/portal.d.ts +197 -0
  128. package/esri-compat/portal.d.ts.map +1 -0
  129. package/esri-compat/portal.js +251 -0
  130. package/esri-compat/renderer-objects.d.ts +40 -0
  131. package/esri-compat/renderer-objects.d.ts.map +1 -0
  132. package/esri-compat/renderer-objects.js +62 -0
  133. package/esri-compat/sketch.d.ts +43 -0
  134. package/esri-compat/sketch.d.ts.map +1 -1
  135. package/esri-compat/sketch.js +46 -0
  136. package/esri-compat/snapping.d.ts +43 -0
  137. package/esri-compat/snapping.d.ts.map +1 -0
  138. package/esri-compat/snapping.js +45 -0
  139. package/esri-compat/url.d.ts.map +1 -1
  140. package/esri-compat/url.js +1 -1
  141. package/esri-compat/widget-host.d.ts +84 -0
  142. package/esri-compat/widget-host.d.ts.map +1 -0
  143. package/esri-compat/widget-host.js +159 -0
  144. package/generated-app/errors.d.ts +18 -2
  145. package/generated-app/errors.d.ts.map +1 -1
  146. package/generated-app/errors.js +44 -11
  147. package/geocoding/index.d.ts +7 -0
  148. package/geocoding/index.d.ts.map +1 -1
  149. package/geocoding/index.js +5 -0
  150. package/geocoding/provider-http.d.ts +37 -0
  151. package/geocoding/provider-http.d.ts.map +1 -0
  152. package/geocoding/provider-http.js +91 -0
  153. package/geocoding/provider.d.ts +145 -0
  154. package/geocoding/provider.d.ts.map +1 -0
  155. package/geocoding/provider.js +41 -0
  156. package/geocoding/providers/honua.d.ts +28 -0
  157. package/geocoding/providers/honua.d.ts.map +1 -0
  158. package/geocoding/providers/honua.js +68 -0
  159. package/geocoding/providers/nominatim.d.ts +47 -0
  160. package/geocoding/providers/nominatim.d.ts.map +1 -0
  161. package/geocoding/providers/nominatim.js +105 -0
  162. package/geocoding/providers/pelias.d.ts +40 -0
  163. package/geocoding/providers/pelias.d.ts.map +1 -0
  164. package/geocoding/providers/pelias.js +115 -0
  165. package/geocoding/providers/photon.d.ts +39 -0
  166. package/geocoding/providers/photon.d.ts.map +1 -0
  167. package/geocoding/providers/photon.js +107 -0
  168. package/geometry/convert.d.ts +13 -0
  169. package/geometry/convert.d.ts.map +1 -0
  170. package/geometry/convert.js +12 -0
  171. package/geometry/index.d.ts +17 -0
  172. package/geometry/index.d.ts.map +1 -0
  173. package/geometry/index.js +15 -0
  174. package/geometry/internal.d.ts +25 -0
  175. package/geometry/internal.d.ts.map +1 -0
  176. package/geometry/internal.js +40 -0
  177. package/geometry/ops.d.ts +71 -0
  178. package/geometry/ops.d.ts.map +1 -0
  179. package/geometry/ops.js +147 -0
  180. package/geometry/project.d.ts +40 -0
  181. package/geometry/project.d.ts.map +1 -0
  182. package/geometry/project.js +88 -0
  183. package/geometry/types.d.ts +36 -0
  184. package/geometry/types.d.ts.map +1 -0
  185. package/geometry/types.js +12 -0
  186. package/map/automatic-mount-integration.d.ts +134 -0
  187. package/map/automatic-mount-integration.d.ts.map +1 -0
  188. package/map/automatic-mount-integration.js +305 -0
  189. package/map/automatic-source-strategy.d.ts +125 -0
  190. package/map/automatic-source-strategy.d.ts.map +1 -0
  191. package/map/automatic-source-strategy.js +494 -0
  192. package/map/data-to-map-bridge.d.ts +293 -0
  193. package/map/data-to-map-bridge.d.ts.map +1 -0
  194. package/map/data-to-map-bridge.js +817 -0
  195. package/map/geojson-projection.d.ts +33 -0
  196. package/map/geojson-projection.d.ts.map +1 -0
  197. package/map/geojson-projection.js +118 -0
  198. package/map/index.d.ts +14 -0
  199. package/map/index.d.ts.map +1 -1
  200. package/map/index.js +8 -0
  201. package/map/raster-source-spec.d.ts +30 -0
  202. package/map/raster-source-spec.d.ts.map +1 -0
  203. package/map/raster-source-spec.js +190 -0
  204. package/map/raster-source-strategy.d.ts +65 -0
  205. package/map/raster-source-strategy.d.ts.map +1 -0
  206. package/map/raster-source-strategy.js +232 -0
  207. package/map/source-to-maplibre.d.ts +91 -0
  208. package/map/source-to-maplibre.d.ts.map +1 -0
  209. package/map/source-to-maplibre.js +454 -0
  210. package/map/temporal-playback.d.ts +139 -0
  211. package/map/temporal-playback.d.ts.map +1 -0
  212. package/map/temporal-playback.js +247 -0
  213. package/package.json +33 -2
  214. package/query-planner/canonical.d.ts +7 -0
  215. package/query-planner/canonical.d.ts.map +1 -0
  216. package/query-planner/canonical.js +145 -0
  217. package/query-planner/cql2-json.d.ts +17 -0
  218. package/query-planner/cql2-json.d.ts.map +1 -0
  219. package/query-planner/cql2-json.js +646 -0
  220. package/query-planner/diagnostics.d.ts +35 -0
  221. package/query-planner/diagnostics.d.ts.map +1 -0
  222. package/query-planner/diagnostics.js +373 -0
  223. package/query-planner/duckdb.d.ts +79 -0
  224. package/query-planner/duckdb.d.ts.map +1 -0
  225. package/query-planner/duckdb.js +758 -0
  226. package/query-planner/execution-context.d.ts +5 -0
  227. package/query-planner/execution-context.d.ts.map +1 -0
  228. package/query-planner/execution-context.js +50 -0
  229. package/query-planner/executor.d.ts +5 -0
  230. package/query-planner/executor.d.ts.map +1 -0
  231. package/query-planner/executor.js +223 -0
  232. package/query-planner/geoservices.d.ts +91 -0
  233. package/query-planner/geoservices.d.ts.map +1 -0
  234. package/query-planner/geoservices.js +667 -0
  235. package/query-planner/grpc.d.ts +100 -0
  236. package/query-planner/grpc.d.ts.map +1 -0
  237. package/query-planner/grpc.js +736 -0
  238. package/query-planner/index.d.ts +44 -0
  239. package/query-planner/index.d.ts.map +1 -0
  240. package/query-planner/index.js +30 -0
  241. package/query-planner/ir.d.ts +20 -0
  242. package/query-planner/ir.d.ts.map +1 -0
  243. package/query-planner/ir.js +417 -0
  244. package/query-planner/local-aggregate.d.ts +5 -0
  245. package/query-planner/local-aggregate.d.ts.map +1 -0
  246. package/query-planner/local-aggregate.js +126 -0
  247. package/query-planner/odata.d.ts +48 -0
  248. package/query-planner/odata.d.ts.map +1 -0
  249. package/query-planner/odata.js +662 -0
  250. package/query-planner/ogc-compiler.d.ts +55 -0
  251. package/query-planner/ogc-compiler.d.ts.map +1 -0
  252. package/query-planner/ogc-compiler.js +480 -0
  253. package/query-planner/ogc-features.d.ts +53 -0
  254. package/query-planner/ogc-features.d.ts.map +1 -0
  255. package/query-planner/ogc-features.js +617 -0
  256. package/query-planner/planner.d.ts +17 -0
  257. package/query-planner/planner.d.ts.map +1 -0
  258. package/query-planner/planner.js +818 -0
  259. package/query-planner/resource.d.ts +94 -0
  260. package/query-planner/resource.d.ts.map +1 -0
  261. package/query-planner/resource.js +526 -0
  262. package/query-planner/semantic-canonical.d.ts +15 -0
  263. package/query-planner/semantic-canonical.d.ts.map +1 -0
  264. package/query-planner/semantic-canonical.js +62 -0
  265. package/query-planner/semantic-compat.d.ts +10 -0
  266. package/query-planner/semantic-compat.d.ts.map +1 -0
  267. package/query-planner/semantic-compat.js +35 -0
  268. package/query-planner/semantic-compiler.d.ts +64 -0
  269. package/query-planner/semantic-compiler.d.ts.map +1 -0
  270. package/query-planner/semantic-compiler.js +81 -0
  271. package/query-planner/semantic-literals.d.ts +30 -0
  272. package/query-planner/semantic-literals.d.ts.map +1 -0
  273. package/query-planner/semantic-literals.js +133 -0
  274. package/query-planner/semantic-types.d.ts +265 -0
  275. package/query-planner/semantic-types.d.ts.map +1 -0
  276. package/query-planner/semantic-types.js +1 -0
  277. package/query-planner/semantic.d.ts +54 -0
  278. package/query-planner/semantic.d.ts.map +1 -0
  279. package/query-planner/semantic.js +1421 -0
  280. package/query-planner/types.d.ts +560 -0
  281. package/query-planner/types.d.ts.map +1 -0
  282. package/query-planner/types.js +49 -0
  283. package/query-planner/wfs-semantic.d.ts +58 -0
  284. package/query-planner/wfs-semantic.d.ts.map +1 -0
  285. package/query-planner/wfs-semantic.js +547 -0
  286. package/query-planner/wfs.d.ts +6 -0
  287. package/query-planner/wfs.d.ts.map +1 -0
  288. package/query-planner/wfs.js +71 -0
  289. package/realtime/contract.d.ts +142 -0
  290. package/realtime/contract.d.ts.map +1 -0
  291. package/realtime/contract.js +154 -0
  292. package/realtime/honua-server.d.ts.map +1 -1
  293. package/realtime/honua-server.js +13 -8
  294. package/realtime/index.d.ts +19 -4
  295. package/realtime/index.d.ts.map +1 -1
  296. package/realtime/index.js +14 -4
  297. package/realtime/odata-delta.d.ts +114 -0
  298. package/realtime/odata-delta.d.ts.map +1 -0
  299. package/realtime/odata-delta.js +483 -0
  300. package/realtime/resumable-transport.d.ts +111 -0
  301. package/realtime/resumable-transport.d.ts.map +1 -0
  302. package/realtime/resumable-transport.js +406 -0
  303. package/realtime/resumable.d.ts +104 -0
  304. package/realtime/resumable.d.ts.map +1 -0
  305. package/realtime/resumable.js +632 -0
  306. package/realtime/sse.d.ts.map +1 -1
  307. package/realtime/sse.js +27 -23
  308. package/realtime/websocket.d.ts +60 -0
  309. package/realtime/websocket.d.ts.map +1 -0
  310. package/realtime/websocket.js +157 -0
  311. package/realtime/wire.d.ts +27 -0
  312. package/realtime/wire.d.ts.map +1 -0
  313. package/realtime/wire.js +57 -0
  314. package/replica-sync/errors.d.ts +2 -1
  315. package/replica-sync/errors.d.ts.map +1 -1
  316. package/replica-sync/errors.js +33 -2
  317. package/runtime/edit-snapping.d.ts +107 -0
  318. package/runtime/edit-snapping.d.ts.map +1 -0
  319. package/runtime/edit-snapping.js +190 -0
  320. package/runtime/errors.d.ts +3 -2
  321. package/runtime/errors.d.ts.map +1 -1
  322. package/runtime/errors.js +19 -2
  323. package/runtime/index.d.ts +6 -0
  324. package/runtime/index.d.ts.map +1 -1
  325. package/runtime/index.js +3 -0
  326. package/runtime/maplibre-renderer.d.ts +41 -0
  327. package/runtime/maplibre-renderer.d.ts.map +1 -0
  328. package/runtime/maplibre-renderer.js +322 -0
  329. package/runtime/query-tiles.d.ts +2 -1
  330. package/runtime/query-tiles.d.ts.map +1 -1
  331. package/runtime/query-tiles.js +6 -2
  332. package/runtime/source-bridge.d.ts +4 -4
  333. package/runtime/source-bridge.d.ts.map +1 -1
  334. package/runtime/source-bridge.js +9 -56
  335. package/runtime/style-interactions.d.ts +3 -2
  336. package/runtime/style-interactions.d.ts.map +1 -1
  337. package/runtime/style-interactions.js +11 -3
  338. package/runtime/terra-draw-sketch.d.ts +275 -0
  339. package/runtime/terra-draw-sketch.d.ts.map +1 -0
  340. package/runtime/terra-draw-sketch.js +404 -0
  341. package/scene-workspace/index.d.ts +4 -0
  342. package/scene-workspace/index.d.ts.map +1 -1
  343. package/scene-workspace/index.js +2 -0
  344. package/scene-workspace/source-to-cesium.d.ts +116 -0
  345. package/scene-workspace/source-to-cesium.d.ts.map +1 -0
  346. package/scene-workspace/source-to-cesium.js +791 -0
  347. package/scene-workspace/state-sync.d.ts +147 -0
  348. package/scene-workspace/state-sync.d.ts.map +1 -0
  349. package/scene-workspace/state-sync.js +1123 -0
  350. package/source-capability-registry.d.ts +1 -0
  351. package/source-capability-registry.js +1 -0
  352. package/source-capability-types.d.ts +186 -0
  353. package/source-capability-types.js +7 -0
  354. package/style/index.d.ts +2 -0
  355. package/style/index.d.ts.map +1 -1
  356. package/style/index.js +2 -0
  357. package/style/renderers.d.ts +326 -0
  358. package/style/renderers.d.ts.map +1 -0
  359. package/style/renderers.js +517 -0
  360. package/web-components/controller.d.ts +2 -0
  361. package/web-components/controller.d.ts.map +1 -1
  362. package/web-components/controller.js +49 -8
  363. package/web-components/elements.d.ts +95 -1
  364. package/web-components/elements.d.ts.map +1 -1
  365. package/web-components/elements.js +458 -19
  366. package/web-components/index.d.ts +8 -1
  367. package/web-components/index.d.ts.map +1 -1
  368. package/web-components/index.js +7 -0
  369. package/web-components/maplibre-renderer.d.ts.map +1 -1
  370. package/web-components/maplibre-renderer.js +87 -0
  371. package/web-components/measurement.d.ts +69 -0
  372. package/web-components/measurement.d.ts.map +1 -0
  373. package/web-components/measurement.js +523 -0
  374. package/web-components/types.d.ts +109 -0
  375. package/web-components/types.d.ts.map +1 -1
  376. package/webmap/convert-renderer.d.ts +24 -3
  377. package/webmap/convert-renderer.d.ts.map +1 -1
  378. package/webmap/convert-renderer.js +93 -112
  379. package/webmap/index.d.ts +1 -1
  380. package/webmap/index.d.ts.map +1 -1
  381. package/webmap/index.js +1 -1
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Provider-pluggable geocoding contract: `GeocodingProvider` plus the
3
+ * normalized result shapes every adapter maps into. The Honua facade
4
+ * (`honuaGeocodingProvider`) and the open-source adapters (Nominatim, Photon,
5
+ * Pelias) all implement this one interface so hosts can swap providers with
6
+ * configuration only.
7
+ *
8
+ * Capability differences between providers are declared up front via
9
+ * {@link GeocodingProvider.capabilities} and enforced with the SDK's existing
10
+ * capability policy: an unsupported operation throws
11
+ * `HonuaCapabilityNotSupportedError` under the default `"strict"` policy and
12
+ * degrades to an empty result under `"degraded"`.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import type { CapabilityPolicy } from "../contract/types.js";
17
+ /**
18
+ * Operations a {@link GeocodingProvider} may support.
19
+ *
20
+ * @experimental
21
+ */
22
+ export type GeocodingCapability = "geocode" | "reverse" | "suggest";
23
+ /**
24
+ * Identifies which provider produced a result and carries that provider's
25
+ * attribution / usage-policy obligations so hosts can surface them (for
26
+ * example in a map attribution control).
27
+ *
28
+ * @experimental
29
+ */
30
+ export interface GeocodingProvenance {
31
+ /** Provider identifier, e.g. `"nominatim"`, `"photon"`, `"pelias"`, `"honua"`. */
32
+ readonly provider: string;
33
+ /** Human-readable data attribution the host is obliged to display. */
34
+ readonly attribution: string;
35
+ /** Usage/acceptable-use policy for the configured endpoint, when known. */
36
+ readonly usagePolicyUrl?: string;
37
+ }
38
+ /**
39
+ * Normalized forward-geocode candidate. Mirrors the contract shape of
40
+ * `GeocodeResult` with provider provenance stamped on every result.
41
+ *
42
+ * @experimental
43
+ */
44
+ export interface ProviderGeocodeMatch {
45
+ /** Formatted address / place label. */
46
+ address: string;
47
+ latitude: number;
48
+ longitude: number;
49
+ /**
50
+ * Provider-reported match quality when available (Nominatim `importance`,
51
+ * Pelias `confidence`, Honua locator `score`). Scale is provider-specific.
52
+ */
53
+ score?: number;
54
+ /** Provider-specific attributes, stringified to the contract shape. */
55
+ attributes: Record<string, string | null>;
56
+ provenance: GeocodingProvenance;
57
+ }
58
+ /**
59
+ * Normalized reverse-geocode result.
60
+ *
61
+ * @experimental
62
+ */
63
+ export interface ProviderReverseMatch {
64
+ address: string;
65
+ latitude: number;
66
+ longitude: number;
67
+ attributes: Record<string, string | null>;
68
+ provenance: GeocodingProvenance;
69
+ }
70
+ /**
71
+ * Normalized typeahead suggestion.
72
+ *
73
+ * @experimental
74
+ */
75
+ export interface ProviderSuggestion {
76
+ text: string;
77
+ provenance: GeocodingProvenance;
78
+ }
79
+ /**
80
+ * Options for {@link GeocodingProvider.geocode}.
81
+ *
82
+ * @experimental
83
+ */
84
+ export interface ProviderGeocodeOptions {
85
+ /** Maximum number of candidates to return. */
86
+ limit?: number;
87
+ /** Comma-separated ISO 3166-1 alpha-2 country codes, e.g. `"us,ca"`. */
88
+ countryCodes?: string;
89
+ }
90
+ /**
91
+ * Options for {@link GeocodingProvider.suggest}.
92
+ *
93
+ * @experimental
94
+ */
95
+ export interface ProviderSuggestOptions {
96
+ /** Maximum number of suggestions to return. */
97
+ limit?: number;
98
+ /** Comma-separated ISO 3166-1 alpha-2 country codes, e.g. `"us,ca"`. */
99
+ countryCodes?: string;
100
+ }
101
+ /**
102
+ * Provider-pluggable geocoding contract. All adapters normalize into the same
103
+ * typed result shapes; capability differences are declared, not discovered at
104
+ * runtime.
105
+ *
106
+ * Operations outside {@link capabilities} throw
107
+ * `HonuaCapabilityNotSupportedError` under the `"strict"` capability policy
108
+ * (the default) and resolve to an empty result under `"degraded"`.
109
+ *
110
+ * @experimental
111
+ */
112
+ export interface GeocodingProvider {
113
+ /** Stable provider identifier, e.g. `"nominatim"`. */
114
+ readonly id: string;
115
+ /** Operations this provider supports. */
116
+ readonly capabilities: ReadonlyArray<GeocodingCapability>;
117
+ /** Human-readable data attribution the host is obliged to display. */
118
+ readonly attribution: string;
119
+ /** Usage/acceptable-use policy for the configured endpoint, when known. */
120
+ readonly usagePolicyUrl?: string;
121
+ /** Forward-geocode a free-text query into candidate locations. */
122
+ geocode(query: string, options?: ProviderGeocodeOptions): Promise<ProviderGeocodeMatch[]>;
123
+ /** Reverse-geocode a latitude/longitude pair; `null` when nothing is found. */
124
+ reverse(latitude: number, longitude: number): Promise<ProviderReverseMatch | null>;
125
+ /** Typeahead suggestions for a partial query. */
126
+ suggest(text: string, options?: ProviderSuggestOptions): Promise<ProviderSuggestion[]>;
127
+ }
128
+ /**
129
+ * `true` when `provider` declares `capability`.
130
+ *
131
+ * @experimental
132
+ */
133
+ export declare function supportsGeocodingCapability(provider: GeocodingProvider, capability: GeocodingCapability): boolean;
134
+ /**
135
+ * Enforce a capability declaration against the active capability policy.
136
+ * Returns `true` when the capability is supported. When it is missing, throws
137
+ * `HonuaCapabilityNotSupportedError` under `"strict"` (the default) or returns
138
+ * `false` under `"degraded"` so callers can resolve to an empty result.
139
+ *
140
+ * @experimental
141
+ */
142
+ export declare function assertGeocodingCapability(provider: Pick<GeocodingProvider, "id" | "capabilities">, capability: GeocodingCapability, policy?: CapabilityPolicy): boolean;
143
+ /** Re-exported so provider hosts can type their policy without importing `/contract`. */
144
+ export type { CapabilityPolicy };
145
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/geocoding/provider.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Provider-pluggable geocoding contract: `GeocodingProvider` plus the
3
+ * normalized result shapes every adapter maps into. The Honua facade
4
+ * (`honuaGeocodingProvider`) and the open-source adapters (Nominatim, Photon,
5
+ * Pelias) all implement this one interface so hosts can swap providers with
6
+ * configuration only.
7
+ *
8
+ * Capability differences between providers are declared up front via
9
+ * {@link GeocodingProvider.capabilities} and enforced with the SDK's existing
10
+ * capability policy: an unsupported operation throws
11
+ * `HonuaCapabilityNotSupportedError` under the default `"strict"` policy and
12
+ * degrades to an empty result under `"degraded"`.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import { HonuaCapabilityNotSupportedError } from "../core/errors.js";
17
+ /**
18
+ * `true` when `provider` declares `capability`.
19
+ *
20
+ * @experimental
21
+ */
22
+ export function supportsGeocodingCapability(provider, capability) {
23
+ return provider.capabilities.includes(capability);
24
+ }
25
+ /**
26
+ * Enforce a capability declaration against the active capability policy.
27
+ * Returns `true` when the capability is supported. When it is missing, throws
28
+ * `HonuaCapabilityNotSupportedError` under `"strict"` (the default) or returns
29
+ * `false` under `"degraded"` so callers can resolve to an empty result.
30
+ *
31
+ * @experimental
32
+ */
33
+ export function assertGeocodingCapability(provider, capability, policy = "strict") {
34
+ if (provider.capabilities.includes(capability)) {
35
+ return true;
36
+ }
37
+ if (policy === "strict") {
38
+ throw new HonuaCapabilityNotSupportedError(capability, provider.id);
39
+ }
40
+ return false;
41
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Honua facade adapter: wraps the existing {@link HonuaGeocodingClient}
3
+ * (Honua-hosted GeocodeServer locator) in the provider-pluggable
4
+ * {@link GeocodingProvider} contract, making the Honua facade one provider
5
+ * among several.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { CapabilityPolicy } from "../../contract/types.js";
10
+ import type { HonuaGeocodingClient } from "../index.js";
11
+ import { type GeocodingProvider } from "../provider.js";
12
+ /** Options for {@link honuaGeocodingProvider}. @experimental */
13
+ export interface HonuaGeocodingProviderOptions {
14
+ /** Capability policy; the Honua locator supports all declared operations. */
15
+ capabilityPolicy?: CapabilityPolicy;
16
+ /** Override the default attribution string for your deployment's data. */
17
+ attribution?: string;
18
+ /** Usage-policy URL for your deployment, when applicable. */
19
+ usagePolicyUrl?: string;
20
+ }
21
+ /**
22
+ * Wrap a {@link HonuaGeocodingClient} in the {@link GeocodingProvider}
23
+ * contract.
24
+ *
25
+ * @experimental
26
+ */
27
+ export declare function honuaGeocodingProvider(client: HonuaGeocodingClient, options?: HonuaGeocodingProviderOptions): GeocodingProvider;
28
+ //# sourceMappingURL=honua.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"honua.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/honua.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,gBAAgB,CAAC;AAExB,gEAAgE;AAChE,MAAM,WAAW,6BAA6B;IAC5C,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,GAAE,6BAAkC,GAC1C,iBAAiB,CAsDnB"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Honua facade adapter: wraps the existing {@link HonuaGeocodingClient}
3
+ * (Honua-hosted GeocodeServer locator) in the provider-pluggable
4
+ * {@link GeocodingProvider} contract, making the Honua facade one provider
5
+ * among several.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import { assertGeocodingCapability, } from "../provider.js";
10
+ const HONUA_ATTRIBUTION = "Honua-hosted locator service";
11
+ const HONUA_CAPABILITIES = ["geocode", "reverse", "suggest"];
12
+ /**
13
+ * Wrap a {@link HonuaGeocodingClient} in the {@link GeocodingProvider}
14
+ * contract.
15
+ *
16
+ * @experimental
17
+ */
18
+ export function honuaGeocodingProvider(client, options = {}) {
19
+ const policy = options.capabilityPolicy ?? "strict";
20
+ const provenance = Object.freeze({
21
+ provider: "honua",
22
+ attribution: options.attribution ?? HONUA_ATTRIBUTION,
23
+ ...(options.usagePolicyUrl !== undefined ? { usagePolicyUrl: options.usagePolicyUrl } : {}),
24
+ });
25
+ return {
26
+ id: "honua",
27
+ capabilities: HONUA_CAPABILITIES,
28
+ attribution: provenance.attribution,
29
+ usagePolicyUrl: provenance.usagePolicyUrl,
30
+ async geocode(query, geocodeOptions) {
31
+ assertGeocodingCapability({ id: "honua", capabilities: HONUA_CAPABILITIES }, "geocode", policy);
32
+ const results = await client.forwardGeocode(query, {
33
+ maxResults: geocodeOptions?.limit,
34
+ countryCodes: geocodeOptions?.countryCodes,
35
+ });
36
+ return results.map((result) => ({
37
+ address: result.address,
38
+ latitude: result.latitude,
39
+ longitude: result.longitude,
40
+ score: result.score,
41
+ attributes: result.attributes,
42
+ provenance,
43
+ }));
44
+ },
45
+ async reverse(latitude, longitude) {
46
+ assertGeocodingCapability({ id: "honua", capabilities: HONUA_CAPABILITIES }, "reverse", policy);
47
+ const result = await client.reverseGeocode(latitude, longitude);
48
+ if (!result) {
49
+ return null;
50
+ }
51
+ return {
52
+ address: result.address,
53
+ latitude: result.latitude,
54
+ longitude: result.longitude,
55
+ attributes: result.attributes,
56
+ provenance,
57
+ };
58
+ },
59
+ async suggest(text, suggestOptions) {
60
+ assertGeocodingCapability({ id: "honua", capabilities: HONUA_CAPABILITIES }, "suggest", policy);
61
+ const suggestions = await client.suggest(text, {
62
+ maxSuggestions: suggestOptions?.limit,
63
+ countryCodes: suggestOptions?.countryCodes,
64
+ });
65
+ return suggestions.map((suggestion) => ({ text: suggestion.text, provenance }));
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Nominatim adapter for the {@link GeocodingProvider} contract.
3
+ *
4
+ * Supports `geocode` and `reverse`; Nominatim has no typeahead endpoint, so
5
+ * `suggest` is declared unsupported and throws
6
+ * `HonuaCapabilityNotSupportedError` under the strict capability policy.
7
+ *
8
+ * There is no default endpoint: pass the `baseUrl` of an instance you are
9
+ * entitled to use. If you point at the public
10
+ * `https://nominatim.openstreetmap.org` service you MUST follow the OSMF
11
+ * Nominatim usage policy — at most 1 request/second, a real `userAgent`
12
+ * identifying your application, and no heavy typeahead-style traffic.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import type { CapabilityPolicy } from "../../contract/types.js";
17
+ import { type ProviderTransportOptions } from "../provider-http.js";
18
+ import { type GeocodingProvider } from "../provider.js";
19
+ /** Options for {@link nominatimGeocodingProvider}. @experimental */
20
+ export interface NominatimProviderOptions extends ProviderTransportOptions {
21
+ /**
22
+ * Base URL of the Nominatim instance, e.g. `https://nominatim.example.org`.
23
+ * Required — no third-party default is baked in (usage-policy safety).
24
+ */
25
+ baseUrl: string;
26
+ /**
27
+ * Value for the `User-Agent` header. The OSMF usage policy requires a real
28
+ * application identifier when using the public instance. Only settable in
29
+ * non-browser runtimes; browsers control their own `User-Agent`.
30
+ */
31
+ userAgent?: string;
32
+ /** Contact email forwarded as the `email` query parameter (public-instance etiquette). */
33
+ email?: string;
34
+ /** Capability policy; `"strict"` (default) throws on `suggest`. */
35
+ capabilityPolicy?: CapabilityPolicy;
36
+ /** Override the default attribution string (self-hosted instances). */
37
+ attribution?: string;
38
+ /** Override the default usage-policy URL (self-hosted instances). */
39
+ usagePolicyUrl?: string;
40
+ }
41
+ /**
42
+ * Create a {@link GeocodingProvider} backed by a Nominatim instance.
43
+ *
44
+ * @experimental
45
+ */
46
+ export declare function nominatimGeocodingProvider(options: NominatimProviderOptions): GeocodingProvider;
47
+ //# sourceMappingURL=nominatim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nominatim.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/nominatim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,iBAAiB,EAMvB,MAAM,gBAAgB,CAAC;AAExB,oEAAoE;AACpE,MAAM,WAAW,wBAAyB,SAAQ,wBAAwB;IACxE;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAmBD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAqF/F"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Nominatim adapter for the {@link GeocodingProvider} contract.
3
+ *
4
+ * Supports `geocode` and `reverse`; Nominatim has no typeahead endpoint, so
5
+ * `suggest` is declared unsupported and throws
6
+ * `HonuaCapabilityNotSupportedError` under the strict capability policy.
7
+ *
8
+ * There is no default endpoint: pass the `baseUrl` of an instance you are
9
+ * entitled to use. If you point at the public
10
+ * `https://nominatim.openstreetmap.org` service you MUST follow the OSMF
11
+ * Nominatim usage policy — at most 1 request/second, a real `userAgent`
12
+ * identifying your application, and no heavy typeahead-style traffic.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import { providerGetJson, stringifyProviderAttributes, trimProviderBaseUrl, } from "../provider-http.js";
17
+ import { assertGeocodingCapability, } from "../provider.js";
18
+ const NOMINATIM_ATTRIBUTION = "Data © OpenStreetMap contributors, ODbL 1.0";
19
+ const NOMINATIM_USAGE_POLICY_URL = "https://operations.osmfoundation.org/policies/nominatim/";
20
+ const NOMINATIM_CAPABILITIES = ["geocode", "reverse"];
21
+ /**
22
+ * Create a {@link GeocodingProvider} backed by a Nominatim instance.
23
+ *
24
+ * @experimental
25
+ */
26
+ export function nominatimGeocodingProvider(options) {
27
+ const baseUrl = trimProviderBaseUrl(options.baseUrl);
28
+ const policy = options.capabilityPolicy ?? "strict";
29
+ const headers = {};
30
+ if (options.userAgent) {
31
+ headers["User-Agent"] = options.userAgent;
32
+ }
33
+ const provenance = Object.freeze({
34
+ provider: "nominatim",
35
+ attribution: options.attribution ?? NOMINATIM_ATTRIBUTION,
36
+ usagePolicyUrl: options.usagePolicyUrl ?? NOMINATIM_USAGE_POLICY_URL,
37
+ });
38
+ const request = (path, params, label) => {
39
+ params.set("format", "jsonv2");
40
+ if (options.email) {
41
+ params.set("email", options.email);
42
+ }
43
+ return providerGetJson(`${baseUrl}${path}?${params.toString()}`, {
44
+ fetchFn: options.fetchFn,
45
+ timeoutMs: options.timeoutMs,
46
+ headers,
47
+ label,
48
+ });
49
+ };
50
+ const toMatch = (place) => ({
51
+ address: place.display_name ?? "",
52
+ latitude: Number(place.lat),
53
+ longitude: Number(place.lon),
54
+ score: place.importance,
55
+ attributes: stringifyProviderAttributes({
56
+ place_id: place.place_id,
57
+ osm_type: place.osm_type,
58
+ osm_id: place.osm_id,
59
+ category: place.category,
60
+ type: place.type,
61
+ }),
62
+ provenance,
63
+ });
64
+ return {
65
+ id: "nominatim",
66
+ capabilities: NOMINATIM_CAPABILITIES,
67
+ attribution: provenance.attribution,
68
+ usagePolicyUrl: provenance.usagePolicyUrl,
69
+ async geocode(query, geocodeOptions) {
70
+ assertGeocodingCapability({ id: "nominatim", capabilities: NOMINATIM_CAPABILITIES }, "geocode", policy);
71
+ const params = new URLSearchParams({ q: query });
72
+ if (geocodeOptions?.limit !== undefined) {
73
+ params.set("limit", String(geocodeOptions.limit));
74
+ }
75
+ if (geocodeOptions?.countryCodes !== undefined) {
76
+ params.set("countrycodes", geocodeOptions.countryCodes);
77
+ }
78
+ const places = await request("/search", params, "nominatim geocode");
79
+ return (places ?? []).map(toMatch);
80
+ },
81
+ async reverse(latitude, longitude) {
82
+ assertGeocodingCapability({ id: "nominatim", capabilities: NOMINATIM_CAPABILITIES }, "reverse", policy);
83
+ const params = new URLSearchParams({ lat: String(latitude), lon: String(longitude) });
84
+ const place = await request("/reverse", params, "nominatim reverse");
85
+ // Nominatim reports "no result" as `{ "error": "Unable to geocode" }`.
86
+ if (!place || place.error !== undefined || place.lat === undefined) {
87
+ return null;
88
+ }
89
+ const match = toMatch(place);
90
+ return {
91
+ address: match.address,
92
+ latitude: match.latitude,
93
+ longitude: match.longitude,
94
+ attributes: match.attributes,
95
+ provenance,
96
+ };
97
+ },
98
+ async suggest() {
99
+ // Declared capability miss: Nominatim's usage policy forbids
100
+ // autocomplete-style traffic and it exposes no suggest endpoint.
101
+ assertGeocodingCapability({ id: "nominatim", capabilities: NOMINATIM_CAPABILITIES }, "suggest", policy);
102
+ return [];
103
+ },
104
+ };
105
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Pelias adapter for the {@link GeocodingProvider} contract.
3
+ *
4
+ * Supports `geocode` (`/v1/search`), `reverse` (`/v1/reverse`), and `suggest`
5
+ * via the dedicated `/v1/autocomplete` endpoint.
6
+ *
7
+ * There is no default endpoint: pass the `baseUrl` of an instance you are
8
+ * entitled to use (self-hosted Pelias or a hosted service such as
9
+ * geocode.earth, whose terms and API key requirements you must follow).
10
+ * Attribution depends on the datasets the instance is built from — override
11
+ * `attribution` to match your instance's obligations.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import type { CapabilityPolicy } from "../../contract/types.js";
16
+ import { type ProviderTransportOptions } from "../provider-http.js";
17
+ import { type GeocodingProvider } from "../provider.js";
18
+ /** Options for {@link peliasGeocodingProvider}. @experimental */
19
+ export interface PeliasProviderOptions extends ProviderTransportOptions {
20
+ /**
21
+ * Base URL of the Pelias instance, e.g. `https://pelias.example.org`.
22
+ * Required — no third-party default is baked in (usage-policy safety).
23
+ */
24
+ baseUrl: string;
25
+ /** API key forwarded as the `api_key` query parameter (hosted instances). */
26
+ apiKey?: string;
27
+ /** Capability policy; Pelias supports all declared operations. */
28
+ capabilityPolicy?: CapabilityPolicy;
29
+ /** Override the default attribution string to match your instance's datasets. */
30
+ attribution?: string;
31
+ /** Override the default usage-policy URL (hosted/self-hosted instances). */
32
+ usagePolicyUrl?: string;
33
+ }
34
+ /**
35
+ * Create a {@link GeocodingProvider} backed by a Pelias instance.
36
+ *
37
+ * @experimental
38
+ */
39
+ export declare function peliasGeocodingProvider(options: PeliasProviderOptions): GeocodingProvider;
40
+ //# sourceMappingURL=pelias.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pelias.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/pelias.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,gBAAgB,CAAC;AAExB,iEAAiE;AACjE,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAwBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAiGzF"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Pelias adapter for the {@link GeocodingProvider} contract.
3
+ *
4
+ * Supports `geocode` (`/v1/search`), `reverse` (`/v1/reverse`), and `suggest`
5
+ * via the dedicated `/v1/autocomplete` endpoint.
6
+ *
7
+ * There is no default endpoint: pass the `baseUrl` of an instance you are
8
+ * entitled to use (self-hosted Pelias or a hosted service such as
9
+ * geocode.earth, whose terms and API key requirements you must follow).
10
+ * Attribution depends on the datasets the instance is built from — override
11
+ * `attribution` to match your instance's obligations.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import { providerGetJson, stringifyProviderAttributes, trimProviderBaseUrl, } from "../provider-http.js";
16
+ import { assertGeocodingCapability, } from "../provider.js";
17
+ const PELIAS_ATTRIBUTION = "Geocoding by Pelias; data © OpenStreetMap contributors and other dataset licensors";
18
+ const PELIAS_USAGE_POLICY_URL = "https://github.com/pelias/documentation/blob/master/data-licenses.md";
19
+ const PELIAS_CAPABILITIES = ["geocode", "reverse", "suggest"];
20
+ /**
21
+ * Create a {@link GeocodingProvider} backed by a Pelias instance.
22
+ *
23
+ * @experimental
24
+ */
25
+ export function peliasGeocodingProvider(options) {
26
+ const baseUrl = trimProviderBaseUrl(options.baseUrl);
27
+ const policy = options.capabilityPolicy ?? "strict";
28
+ const provenance = Object.freeze({
29
+ provider: "pelias",
30
+ attribution: options.attribution ?? PELIAS_ATTRIBUTION,
31
+ usagePolicyUrl: options.usagePolicyUrl ?? PELIAS_USAGE_POLICY_URL,
32
+ });
33
+ const request = (path, params, label) => {
34
+ if (options.apiKey) {
35
+ params.set("api_key", options.apiKey);
36
+ }
37
+ return providerGetJson(`${baseUrl}${path}?${params.toString()}`, {
38
+ fetchFn: options.fetchFn,
39
+ timeoutMs: options.timeoutMs,
40
+ label,
41
+ });
42
+ };
43
+ const toMatch = (feature) => {
44
+ const [longitude, latitude] = feature.geometry?.coordinates ?? [Number.NaN, Number.NaN];
45
+ const p = feature.properties ?? {};
46
+ return {
47
+ address: p.label ?? p.name ?? "",
48
+ latitude,
49
+ longitude,
50
+ score: p.confidence,
51
+ attributes: stringifyProviderAttributes({
52
+ gid: p.gid,
53
+ layer: p.layer,
54
+ source: p.source,
55
+ country_code: p.country_code,
56
+ postalcode: p.postalcode,
57
+ }),
58
+ provenance,
59
+ };
60
+ };
61
+ const applyCountryFilter = (params, countryCodes) => {
62
+ if (countryCodes !== undefined) {
63
+ params.set("boundary.country", countryCodes);
64
+ }
65
+ };
66
+ return {
67
+ id: "pelias",
68
+ capabilities: PELIAS_CAPABILITIES,
69
+ attribution: provenance.attribution,
70
+ usagePolicyUrl: provenance.usagePolicyUrl,
71
+ async geocode(query, geocodeOptions) {
72
+ assertGeocodingCapability({ id: "pelias", capabilities: PELIAS_CAPABILITIES }, "geocode", policy);
73
+ const params = new URLSearchParams({ text: query });
74
+ if (geocodeOptions?.limit !== undefined) {
75
+ params.set("size", String(geocodeOptions.limit));
76
+ }
77
+ applyCountryFilter(params, geocodeOptions?.countryCodes);
78
+ const data = await request("/v1/search", params, "pelias geocode");
79
+ return (data.features ?? []).map(toMatch);
80
+ },
81
+ async reverse(latitude, longitude) {
82
+ assertGeocodingCapability({ id: "pelias", capabilities: PELIAS_CAPABILITIES }, "reverse", policy);
83
+ const params = new URLSearchParams({
84
+ "point.lat": String(latitude),
85
+ "point.lon": String(longitude),
86
+ });
87
+ const data = await request("/v1/reverse", params, "pelias reverse");
88
+ const feature = data.features?.[0];
89
+ if (!feature) {
90
+ return null;
91
+ }
92
+ const match = toMatch(feature);
93
+ return {
94
+ address: match.address,
95
+ latitude: match.latitude,
96
+ longitude: match.longitude,
97
+ attributes: match.attributes,
98
+ provenance,
99
+ };
100
+ },
101
+ async suggest(text, suggestOptions) {
102
+ assertGeocodingCapability({ id: "pelias", capabilities: PELIAS_CAPABILITIES }, "suggest", policy);
103
+ const params = new URLSearchParams({ text });
104
+ if (suggestOptions?.limit !== undefined) {
105
+ params.set("size", String(suggestOptions.limit));
106
+ }
107
+ applyCountryFilter(params, suggestOptions?.countryCodes);
108
+ const data = await request("/v1/autocomplete", params, "pelias suggest");
109
+ return (data.features ?? []).map((feature) => ({
110
+ text: feature.properties?.label ?? feature.properties?.name ?? "",
111
+ provenance,
112
+ }));
113
+ },
114
+ };
115
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Photon adapter for the {@link GeocodingProvider} contract.
3
+ *
4
+ * Photon (komoot) is typeahead-first, so it supports all three operations:
5
+ * `geocode`, `reverse`, and `suggest` (suggest reuses the search endpoint,
6
+ * which is designed for as-you-type queries).
7
+ *
8
+ * There is no default endpoint: pass the `baseUrl` of an instance you are
9
+ * entitled to use (e.g. a self-hosted Photon, or `https://photon.komoot.io`
10
+ * within its fair-use terms).
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import type { CapabilityPolicy } from "../../contract/types.js";
15
+ import { type ProviderTransportOptions } from "../provider-http.js";
16
+ import { type GeocodingProvider } from "../provider.js";
17
+ /** Options for {@link photonGeocodingProvider}. @experimental */
18
+ export interface PhotonProviderOptions extends ProviderTransportOptions {
19
+ /**
20
+ * Base URL of the Photon instance, e.g. `https://photon.example.org`.
21
+ * Required — no third-party default is baked in (usage-policy safety).
22
+ */
23
+ baseUrl: string;
24
+ /** BCP-47 language for results, forwarded as `lang` when set. */
25
+ language?: string;
26
+ /** Capability policy; Photon supports all declared operations. */
27
+ capabilityPolicy?: CapabilityPolicy;
28
+ /** Override the default attribution string (self-hosted instances). */
29
+ attribution?: string;
30
+ /** Override the default usage-policy URL (self-hosted instances). */
31
+ usagePolicyUrl?: string;
32
+ }
33
+ /**
34
+ * Create a {@link GeocodingProvider} backed by a Photon instance.
35
+ *
36
+ * @experimental
37
+ */
38
+ export declare function photonGeocodingProvider(options: PhotonProviderOptions): GeocodingProvider;
39
+ //# sourceMappingURL=photon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"photon.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/photon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,gBAAgB,CAAC;AAExB,iEAAiE;AACjE,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAsCD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAmFzF"}