@whereq/cloud 0.5.1 → 0.7.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.
package/dist/index.d.cts CHANGED
@@ -1,21 +1,9 @@
1
1
  /**
2
- * whereq.cloud — official JavaScript/TypeScript SDK for the WhereQ data cloud.
3
- *
4
- * A thin, typed wrapper over the versioned `/v1` HTTP API at `api.whereq.cloud`.
5
- * Public endpoints work with no key; metered endpoints take an API key.
6
- *
7
- * ```ts
8
- * import { Whereq } from "@whereq/cloud";
9
- *
10
- * const wq = new Whereq(); // public access
11
- * // const wq = new Whereq({ apiKey: "wq_live_…" }); // metered tier
12
- *
13
- * await wq.costOfLiving("us:California,ca:Ontario");
14
- * await wq.prices({ domain: "rent", region: "us", bedrooms: 2 });
15
- * await wq.get("/v1/trending", { limit: 10 }); // escape hatch
16
- * ```
2
+ * The SDK version, read straight from `package.json` so it can never drift
3
+ * from what is published. The release tooling bumps `package.json`; this
4
+ * follows it.
17
5
  */
18
- declare const VERSION = "0.5.1";
6
+ declare const VERSION: string;
19
7
  /** The products a station can quote. Mexico's CRE feed carries the first,
20
8
  * second and fourth; GasBuddy (US/Canada) adds midgrade. */
21
9
  declare const FUEL_PRODUCTS: readonly ["regular", "midgrade", "premium", "diesel"];
@@ -140,11 +128,345 @@ interface PriceSeriesResponse {
140
128
  offset: number;
141
129
  data: PriceSeries[];
142
130
  }
131
+ /** One place — a province, a municipality, a ward, a neighbourhood.
132
+ *
133
+ * `kind` is the platform's own concept (`province`, `region`,
134
+ * `municipality`, `city`, `town`, `ward`, `neighbourhood`…), not the
135
+ * source's admin level. `country_code` is the two-letter ISO code and is
136
+ * the same for both vocabularies — a country filter accepts `CA` or
137
+ * `CAN` and answers with the same places either way.
138
+ */
139
+ interface GeoPlace {
140
+ uid: string;
141
+ kind: string;
142
+ kind_source: string;
143
+ name: string;
144
+ name_en?: string | null;
145
+ name_zh?: string | null;
146
+ name_local?: string | null;
147
+ official_name?: string | null;
148
+ source: string;
149
+ source_id: string;
150
+ source_url?: string | null;
151
+ license?: string | null;
152
+ raw_admin_level?: number | null;
153
+ raw_place?: string | null;
154
+ raw_boundary?: string | null;
155
+ country_code?: string | null;
156
+ province_code?: string | null;
157
+ iso_code?: string | null;
158
+ ref?: string | null;
159
+ population?: number | null;
160
+ population_date?: string | null;
161
+ wikidata?: string | null;
162
+ wikipedia?: string | null;
163
+ website?: string | null;
164
+ capital?: string | null;
165
+ centroid_lon?: number | null;
166
+ centroid_lat?: number | null;
167
+ bbox_min_lon?: number | null;
168
+ bbox_min_lat?: number | null;
169
+ bbox_max_lon?: number | null;
170
+ bbox_max_lat?: number | null;
171
+ area_km2?: number | null;
172
+ has_boundary: boolean;
173
+ }
174
+ interface GeoPlaceList {
175
+ count: number;
176
+ data: GeoPlace[];
177
+ limit: number;
178
+ offset: number;
179
+ }
180
+ /** One container of a place, as the detail endpoint lists them.
181
+ *
182
+ * A place has SEVERAL parents — a neighbourhood is in a ward, in a city,
183
+ * in a census division and in a province, all at once. The list is
184
+ * deliberately a list.
185
+ */
186
+ interface GeoParent {
187
+ uid: string;
188
+ kind: string;
189
+ name: string;
190
+ source: string;
191
+ area_ratio?: number | null;
192
+ is_primary: boolean;
193
+ }
194
+ /** One place with its containers and the places inside it. */
195
+ interface GeoPlaceDetail {
196
+ uid: string;
197
+ place: GeoPlace;
198
+ parents: GeoParent[];
199
+ children: GeoParent[];
200
+ }
201
+ /** One concept in the vocabulary, with a live count behind it. */
202
+ interface GeoConcept {
203
+ kind: string;
204
+ name: string;
205
+ name_cn?: string | null;
206
+ description?: string | null;
207
+ description_cn?: string | null;
208
+ places: number;
209
+ with_boundary: number;
210
+ rank: number;
211
+ }
212
+ /** The vocabulary, explained. */
213
+ interface GeoConceptList {
214
+ count: number;
215
+ concepts: GeoConcept[];
216
+ sources: Array<Record<string, unknown>>;
217
+ }
218
+ /** Two places of DIFFERENT kinds covering the same ground.
219
+ *
220
+ * This is the deliberate part of the dataset: a census subdivision and
221
+ * an OpenStreetMap city boundary that describe the same town in two
222
+ * vocabularies. The platform keeps both rather than picking one.
223
+ */
224
+ interface GeoOverlap {
225
+ a_id: number;
226
+ b_id: number;
227
+ a_uid: string;
228
+ b_uid: string;
229
+ a_name: string;
230
+ b_name: string;
231
+ a_kind: string;
232
+ b_kind: string;
233
+ a_source: string;
234
+ b_source: string;
235
+ overlap_ratio: number;
236
+ a_concept: string;
237
+ b_concept: string;
238
+ }
239
+ /** The overlapping pairs inside a box. */
240
+ interface GeoOverlapList {
241
+ bbox: Record<string, number>;
242
+ min_ratio: number;
243
+ count: number;
244
+ overlaps: GeoOverlap[];
245
+ }
246
+ /** One place in the containing stack at a point.
247
+ *
248
+ * `country_code` is on every level, so the stack can be read without a
249
+ * second lookup.
250
+ */
251
+ interface GeoAtPlace {
252
+ uid: string;
253
+ kind: string;
254
+ kind_source: string;
255
+ name: string;
256
+ name_en?: string | null;
257
+ name_zh?: string | null;
258
+ source: string;
259
+ raw_admin_level?: number | null;
260
+ raw_place?: string | null;
261
+ population?: number | null;
262
+ wikidata?: string | null;
263
+ centroid_lon?: number | null;
264
+ centroid_lat?: number | null;
265
+ area_km2?: number | null;
266
+ country_code?: string | null;
267
+ province_code?: string | null;
268
+ boundary_area_km2?: number | null;
269
+ concept?: Record<string, unknown>;
270
+ }
271
+ /** Every place containing a point, broadest first: country, province,
272
+ * region, municipality, city, ward, neighbourhood. The answer to "where
273
+ * am I?" without pretending one of them is *the* answer. */
274
+ interface GeoAtResponse {
275
+ lon: number;
276
+ lat: number;
277
+ count: number;
278
+ places: GeoAtPlace[];
279
+ }
280
+ /** A place's outline as GeoJSON — a FeatureCollection you can hand
281
+ * straight to a map library. */
282
+ interface GeoBoundary {
283
+ type: string;
284
+ features: Array<Record<string, unknown>>;
285
+ }
286
+ interface GeoPlacesParams {
287
+ kind?: string;
288
+ source?: string;
289
+ country?: string;
290
+ q?: string;
291
+ bbox?: string;
292
+ has_boundary?: boolean;
293
+ limit?: number;
294
+ offset?: number;
295
+ }
143
296
  declare class WhereqError extends Error {
144
297
  readonly status: number;
145
298
  readonly url: string;
146
299
  constructor(status: number, message: string, url: string);
147
300
  }
301
+ /** One item from a local feed — a story, an event, a notice. */
302
+ interface LocalContent {
303
+ id: number;
304
+ type: string;
305
+ category?: string | null;
306
+ title: string;
307
+ summary?: string | null;
308
+ description?: string | null;
309
+ source_name?: string | null;
310
+ source_url?: string | null;
311
+ url?: string | null;
312
+ publish_time?: string | null;
313
+ latitude?: number | null;
314
+ longitude?: number | null;
315
+ city?: string | null;
316
+ province?: string | null;
317
+ country?: string | null;
318
+ geocode_status?: string | null;
319
+ confidence_score?: number | null;
320
+ status: string;
321
+ expires_at?: string | null;
322
+ tags?: string[];
323
+ }
324
+ /** One point of interest. */
325
+ interface LocalPlace {
326
+ id: number;
327
+ source: string;
328
+ source_url?: string | null;
329
+ license?: string | null;
330
+ external_id: string;
331
+ name: string;
332
+ latitude?: number | null;
333
+ longitude?: number | null;
334
+ city?: string | null;
335
+ province?: string | null;
336
+ country?: string | null;
337
+ category?: string | null;
338
+ kind?: string | null;
339
+ metadata?: Record<string, unknown>;
340
+ }
341
+ /** One configured local feed. */
342
+ interface LocalSource {
343
+ slug: string;
344
+ name: string;
345
+ kind: string;
346
+ url?: string | null;
347
+ default_type?: string | null;
348
+ default_city?: string | null;
349
+ default_province?: string | null;
350
+ default_country?: string | null;
351
+ enabled: boolean;
352
+ crawl_interval_minutes: number;
353
+ }
354
+ /** The page envelope every list endpoint uses. */
355
+ interface Page<T> {
356
+ data: T[];
357
+ pagination: {
358
+ limit: number;
359
+ count: number;
360
+ next_cursor?: string | null;
361
+ offset?: number;
362
+ };
363
+ }
364
+ /** One school board. */
365
+ interface SchoolBoard {
366
+ slug: string;
367
+ name: string;
368
+ type?: string | null;
369
+ region?: string | null;
370
+ school_count: number;
371
+ }
372
+ /**
373
+ * One school.
374
+ *
375
+ * The `hs_*` fields are **present only when the API key holds the
376
+ * `school_licensed` scope**. Without it they are absent — not null — so a
377
+ * caller can tell "you are not entitled to this" from "there is no value
378
+ * here".
379
+ */
380
+ interface SchoolSummary {
381
+ uid: string;
382
+ name: string;
383
+ type?: string | null;
384
+ status?: string | null;
385
+ province?: string | null;
386
+ region?: string | null;
387
+ city?: string | null;
388
+ municipality?: string | null;
389
+ board?: SchoolBoard | null;
390
+ latitude?: number | null;
391
+ longitude?: number | null;
392
+ grade_range?: string | null;
393
+ programs: string[];
394
+ has_boundary: boolean;
395
+ source?: string | null;
396
+ source_url?: string | null;
397
+ license?: string | null;
398
+ hs_score?: number | null;
399
+ hs_rank?: number | null;
400
+ hs_rank_total?: number | null;
401
+ hs_school_type?: string | null;
402
+ }
403
+ /** One school's yearly assessment snapshot. Licensed. */
404
+ interface SchoolScores {
405
+ uid: string;
406
+ year: number;
407
+ rank?: number | null;
408
+ rank_total?: number | null;
409
+ rank_score?: number | null;
410
+ avg_exam_mark?: number | null;
411
+ year_label?: string | null;
412
+ source?: string | null;
413
+ eqao: Array<{
414
+ grade: number;
415
+ year_mark?: string | null;
416
+ rank?: number | null;
417
+ total?: number | null;
418
+ last5_avg?: number | null;
419
+ }>;
420
+ }
421
+ /** One school, with its contact block. `scores` needs `school_licensed`. */
422
+ interface SchoolDetail extends SchoolSummary {
423
+ address?: string | null;
424
+ phone?: string | null;
425
+ phone2?: string | null;
426
+ fax?: string | null;
427
+ website_url?: string | null;
428
+ boundary_pdf_url?: string | null;
429
+ principal?: string | null;
430
+ feeder_schools?: Record<string, unknown> | null;
431
+ extra?: Record<string, unknown> | null;
432
+ scores?: SchoolScores[];
433
+ }
434
+ /** A school's catchment outline. Licensed. */
435
+ interface SchoolBoundary {
436
+ uid: string;
437
+ name: string;
438
+ geometry?: {
439
+ type: string;
440
+ coordinates: unknown;
441
+ } | null;
442
+ polygon_count: number;
443
+ point_count: number;
444
+ source?: string | null;
445
+ source_url?: string | null;
446
+ license?: string | null;
447
+ }
448
+ /** One catchment covering a queried point. Licensed. */
449
+ interface CatchmentHit {
450
+ uid: string;
451
+ name: string;
452
+ type?: string | null;
453
+ distance_m?: number | null;
454
+ }
455
+ /** The school vocabulary and the headline counts. */
456
+ interface SchoolTaxonomy {
457
+ boards: SchoolBoard[];
458
+ types: Array<{
459
+ id: string;
460
+ name: string;
461
+ count: number;
462
+ }>;
463
+ program_categories: Array<{
464
+ id: string;
465
+ name: string;
466
+ count: number;
467
+ }>;
468
+ stats: Record<string, number>;
469
+ }
148
470
  interface ClientOptions {
149
471
  /** `wq_live_…` key for metered endpoints (sent as `X-API-Key`). */
150
472
  apiKey?: string;
@@ -250,6 +572,163 @@ declare class Whereq {
250
572
  * prices that `fuelStations()` returns.
251
573
  */
252
574
  fuelPrices(p?: FuelPricesParams & Params): Promise<PriceSeriesResponse>;
575
+ /** The place list — provinces, regions, municipalities, cities, towns,
576
+ * wards, neighbourhoods, countries.
577
+ *
578
+ * `country` takes an ISO code and either spelling works: `"CA"` and
579
+ * `"CAN"` find the same places, in both vocabularies.
580
+ */
581
+ geoPlaces(p?: GeoPlacesParams & Params): Promise<GeoPlaceList>;
582
+ /** One place, with its containers AND the places inside it.
583
+ *
584
+ * The parents are a list on purpose: a place belongs to several things
585
+ * at once.
586
+ */
587
+ geoPlace(uid: string): Promise<GeoPlaceDetail>;
588
+ /** A place's outline as GeoJSON.
589
+ *
590
+ * `simplify` is in METRES: the outline keeps every corner more than
591
+ * that far from the original, and the result is still a valid polygon.
592
+ */
593
+ geoBoundary(uid: string, p?: {
594
+ simplify?: number;
595
+ } & Params): Promise<GeoBoundary>;
596
+ /** Every place containing a point, broadest first.
597
+ *
598
+ * The answer to "which district is this?" without picking a winner: a
599
+ * point downtown Toronto lands in a neighbourhood, a ward, a city, a
600
+ * census division, a province and a country, and all of them are
601
+ * returned.
602
+ */
603
+ geoAt(lon: number, lat: number): Promise<GeoAtResponse>;
604
+ /** The vocabulary: every concept, in both languages, with a live count of
605
+ * how many places and outlines it has. */
606
+ geoConcepts(): Promise<GeoConceptList>;
607
+ /** The places of different kinds that cover the same ground.
608
+ *
609
+ * `bbox` is required — "minLon,minLat,maxLon,maxLat". Comparing every
610
+ * pair in the country is a quadratic join, and nobody asks that
611
+ * question about all of Canada at once.
612
+ */
613
+ geoOverlaps(p: {
614
+ bbox: string;
615
+ min_ratio?: number;
616
+ limit?: number;
617
+ } & Params): Promise<GeoOverlapList>;
618
+ /** The local feed — news, events, stories and notices. */
619
+ localContent(p?: {
620
+ type?: string;
621
+ category?: string;
622
+ source?: string;
623
+ city?: string;
624
+ province?: string;
625
+ bbox?: string;
626
+ q?: string;
627
+ since?: string;
628
+ until?: string;
629
+ has_location?: boolean;
630
+ include_expired?: boolean;
631
+ limit?: number;
632
+ cursor?: string;
633
+ } & Params): Promise<Page<LocalContent>>;
634
+ /** One item, with its tags. */
635
+ localContentItem(contentId: number): Promise<LocalContent>;
636
+ /** The points of interest — the OpenStreetMap sweep.
637
+ *
638
+ * `lat`, `lng` and `radius_km` go together: a proximity search needs
639
+ * all three.
640
+ */
641
+ localPlaces(p?: {
642
+ category?: string;
643
+ kind?: string;
644
+ sub?: string;
645
+ bbox?: string;
646
+ lat?: number;
647
+ lng?: number;
648
+ radius_km?: number;
649
+ q?: string;
650
+ limit?: number;
651
+ offset?: number;
652
+ } & Params): Promise<Page<LocalPlace>>;
653
+ /** One place. */
654
+ localPlace(placeId: number): Promise<LocalPlace>;
655
+ /** The configured local feeds. */
656
+ localSources(p?: {
657
+ enabled?: boolean;
658
+ kind?: string;
659
+ limit?: number;
660
+ } & Params): Promise<Page<LocalSource>>;
661
+ /** The local vocabulary — types, categories, place categories, sources. */
662
+ localTaxonomy(): Promise<{
663
+ types: Array<{
664
+ id: string;
665
+ name: string;
666
+ count: number;
667
+ }>;
668
+ categories: Array<{
669
+ id: string;
670
+ name: string;
671
+ count: number;
672
+ }>;
673
+ place_categories: Array<{
674
+ id: string;
675
+ name: string;
676
+ count: number;
677
+ }>;
678
+ sources: Array<{
679
+ slug: string;
680
+ name: string;
681
+ count: number;
682
+ }>;
683
+ }>;
684
+ /** The school directory. */
685
+ schools(p?: {
686
+ q?: string;
687
+ board?: string;
688
+ city?: string;
689
+ province?: string;
690
+ type?: string;
691
+ bbox?: string;
692
+ lat?: number;
693
+ lng?: number;
694
+ radius_km?: number;
695
+ has_boundary?: boolean;
696
+ limit?: number;
697
+ offset?: number;
698
+ } & Params): Promise<Page<SchoolSummary>>;
699
+ /** The board registry — the vocabulary the `board` filter uses. */
700
+ schoolBoards(): Promise<Page<SchoolBoard>>;
701
+ /** The school vocabulary and the headline counts. */
702
+ schoolTaxonomy(): Promise<SchoolTaxonomy>;
703
+ /** The catchments that cover a point.
704
+ *
705
+ * **Licensed.** This reads the catchment polygons, so it needs the
706
+ * `school_licensed` scope — a key without it gets a 403.
707
+ */
708
+ schoolsAt(p: {
709
+ lat: number;
710
+ lng: number;
711
+ limit?: number;
712
+ } & Params): Promise<Page<CatchmentHit>>;
713
+ /** One school.
714
+ *
715
+ * The uid is board-qualified — `ycdsb/0158`, or
716
+ * `ycdsb/st-theresa-of-lisieux-chs` when the board publishes no code.
717
+ * It carries a slash, and the API's route is built for that.
718
+ *
719
+ * The scores come back only with the `school_licensed` scope.
720
+ */
721
+ school(uid: string): Promise<SchoolDetail>;
722
+ /** A school's catchment outline, as GeoJSON. **Licensed.**
723
+ * `simplify` is in METRES. */
724
+ schoolBoundary(uid: string, p?: {
725
+ simplify?: number;
726
+ } & Params): Promise<SchoolBoundary>;
727
+ /** One year's assessment snapshot, with the EQAO marks. **Licensed.**
728
+ * `year` picks a year; the latest is the default. */
729
+ schoolScores(uid: string, p?: {
730
+ year?: number;
731
+ } & Params): Promise<SchoolScores>;
253
732
  }
254
733
 
255
- export { type ClientOptions, FUEL_COUNTRIES, FUEL_CURRENCIES, FUEL_PRODUCTS, type FuelCountry, type FuelPricesParams, type FuelProduct, type FuelStation, type FuelStationDetail, type FuelStationParams, type FuelStationPrice, type FuelStationPricePoint, type FuelStationsParams, type FuelStationsResponse, type PriceSeries, type PriceSeriesResponse, VERSION, Whereq, WhereqError, Whereq as default };
734
+ export { type CatchmentHit, type ClientOptions, FUEL_COUNTRIES, FUEL_CURRENCIES, FUEL_PRODUCTS, type FuelCountry, type FuelPricesParams, type FuelProduct, type FuelStation, type FuelStationDetail, type FuelStationParams, type FuelStationPrice, type FuelStationPricePoint, type FuelStationsParams, type FuelStationsResponse, type GeoAtPlace, type GeoAtResponse, type GeoBoundary, type GeoConcept, type GeoConceptList, type GeoOverlap, type GeoOverlapList, type GeoParent, type GeoPlace, type GeoPlaceDetail, type GeoPlaceList, type GeoPlacesParams, type LocalContent, type LocalPlace, type LocalSource, type Page, type PriceSeries, type PriceSeriesResponse, type SchoolBoard, type SchoolBoundary, type SchoolDetail, type SchoolScores, type SchoolSummary, type SchoolTaxonomy, VERSION, Whereq, WhereqError, Whereq as default };