@chrtco/sdk 0.10.4 → 0.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -4
- package/dist/index.d.ts +200 -4
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -800,6 +800,37 @@ var FeaturesEndpoint = class {
|
|
|
800
800
|
}
|
|
801
801
|
};
|
|
802
802
|
|
|
803
|
+
// src/endpoints/search.ts
|
|
804
|
+
var SearchEndpoint = class {
|
|
805
|
+
constructor(http) {
|
|
806
|
+
this.http = http;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Search the gazetteer.
|
|
810
|
+
*
|
|
811
|
+
* `near` biases ranking and never filters — "Newport" is Rhode Island, Oregon
|
|
812
|
+
* *and* California, and all three come back with the nearest first. `bbox`
|
|
813
|
+
* does filter.
|
|
814
|
+
*/
|
|
815
|
+
async find(options) {
|
|
816
|
+
return this.http.request(
|
|
817
|
+
"/search",
|
|
818
|
+
{
|
|
819
|
+
q: options.q,
|
|
820
|
+
near: options.near ? `${options.near[0]},${options.near[1]}` : void 0,
|
|
821
|
+
bbox: options.bbox ? options.bbox.join(",") : void 0,
|
|
822
|
+
kind: options.kind,
|
|
823
|
+
// Both spellings are accepted server-side; the SDK sends the
|
|
824
|
+
// comma-joined form so one array maps to one query parameter.
|
|
825
|
+
layer: Array.isArray(options.layer) ? options.layer.join(",") : options.layer,
|
|
826
|
+
limit: options.limit,
|
|
827
|
+
offset: options.offset
|
|
828
|
+
},
|
|
829
|
+
options.signal
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
|
|
803
834
|
// src/endpoints/query.ts
|
|
804
835
|
var METRES_PER_NAUTICAL_MILE2 = 1852;
|
|
805
836
|
var QueryEndpoint = class {
|
|
@@ -28677,6 +28708,7 @@ var Chrt = class {
|
|
|
28677
28708
|
*/
|
|
28678
28709
|
interact;
|
|
28679
28710
|
featuresEp;
|
|
28711
|
+
searchEp;
|
|
28680
28712
|
queryEp;
|
|
28681
28713
|
http;
|
|
28682
28714
|
tileAuth;
|
|
@@ -28697,6 +28729,7 @@ var Chrt = class {
|
|
|
28697
28729
|
this.coverage = new CoverageEndpoint(this.http);
|
|
28698
28730
|
this.weather = new WeatherEndpoint(this.http);
|
|
28699
28731
|
this.featuresEp = new FeaturesEndpoint(this.http);
|
|
28732
|
+
this.searchEp = new SearchEndpoint(this.http);
|
|
28700
28733
|
this.queryEp = new QueryEndpoint(this.http);
|
|
28701
28734
|
this.offline = new OfflineEndpoint(this.http, config.deviceId, config.manifestPath);
|
|
28702
28735
|
this.interact = new InteractClient(this.http);
|
|
@@ -28706,6 +28739,32 @@ var Chrt = class {
|
|
|
28706
28739
|
async features(options) {
|
|
28707
28740
|
return this.featuresEp.list(options);
|
|
28708
28741
|
}
|
|
28742
|
+
/**
|
|
28743
|
+
* CHRTsearch — find charted places by name.
|
|
28744
|
+
*
|
|
28745
|
+
* The only CHRT surface addressed by NAME rather than by space or identifier.
|
|
28746
|
+
* Text in, a small ranked list of named charted places out.
|
|
28747
|
+
*
|
|
28748
|
+
* ```ts
|
|
28749
|
+
* const { results } = await chrt.search({ q: "cutty harbor", near: [-70.93, 41.42] });
|
|
28750
|
+
* // -> [{ name: "Cuttyhunk Harbor Channel", class: "Fairway", kind: "place", ... }]
|
|
28751
|
+
* ```
|
|
28752
|
+
*
|
|
28753
|
+
* Three things worth knowing before wiring it to a text field:
|
|
28754
|
+
*
|
|
28755
|
+
* 1. **Pass `near`.** It biases ranking and never filters. "Newport" is
|
|
28756
|
+
* Rhode Island, Oregon *and* California; without `near` the first row is
|
|
28757
|
+
* the wrong Newport most of the time.
|
|
28758
|
+
* 2. **It is metered separately** from `features()` — exhausting one does not
|
|
28759
|
+
* affect the other. Sized for a typeahead, and not gated by tier.
|
|
28760
|
+
* 3. **An empty `results` array is not proof a place does not exist.** If the
|
|
28761
|
+
* response carries a `coverage` block, CHRT holds no charts at that
|
|
28762
|
+
* position and the search could not run there. That is a different answer
|
|
28763
|
+
* from "nothing matched", and neither means the water is clear.
|
|
28764
|
+
*/
|
|
28765
|
+
async search(options) {
|
|
28766
|
+
return this.searchEp.find(options);
|
|
28767
|
+
}
|
|
28709
28768
|
/** Spatial proximity query around a point */
|
|
28710
28769
|
async query(options) {
|
|
28711
28770
|
return this.queryEp.nearby(options);
|