@whereq/cloud 0.6.0 → 0.7.1

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.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * The SDK version, read straight from `package.json` so it can never drift
3
- * from what is published. Changesets bumps `package.json`; this follows it.
3
+ * from what is published. The release tooling bumps `package.json`; this
4
+ * follows it.
4
5
  */
5
6
  declare const VERSION: string;
6
7
  /** The products a station can quote. Mexico's CRE feed carries the first,
@@ -297,6 +298,233 @@ declare class WhereqError extends Error {
297
298
  readonly url: string;
298
299
  constructor(status: number, message: string, url: string);
299
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
+ /** The province code, e.g. `ON`. */
371
+ province?: string | null;
372
+ school_count: number;
373
+ }
374
+ /**
375
+ * One school.
376
+ *
377
+ * The `hs_*` fields are **present only when the API key holds the
378
+ * `school_licensed` scope**. Without it they are absent — not null — so a
379
+ * caller can tell "you are not entitled to this" from "there is no value
380
+ * here".
381
+ */
382
+ interface SchoolSummary {
383
+ /**
384
+ * The platform's own row id.
385
+ *
386
+ * **Not an identifier** — the `uid` is — but the join key for the
387
+ * migration: whereq.com's school rows carry the same integers, because
388
+ * the import preserved them. It changes if the dataset is reloaded.
389
+ */
390
+ id: number;
391
+ uid: string;
392
+ name: string;
393
+ type?: string | null;
394
+ status?: string | null;
395
+ province?: string | null;
396
+ /**
397
+ * The **board's** region — `York Region`, `Toronto`.
398
+ *
399
+ * This is what the `region` filter matches. The school row's own
400
+ * `region` column holds a denormalised province name and is not served.
401
+ */
402
+ region?: string | null;
403
+ city?: string | null;
404
+ municipality?: string | null;
405
+ board?: SchoolBoard | null;
406
+ latitude?: number | null;
407
+ longitude?: number | null;
408
+ grade_range?: string | null;
409
+ /**
410
+ * The programme **codes** (`french_immersion`), not the labels.
411
+ *
412
+ * The code is what the `program` filter takes and what the taxonomy
413
+ * lists as its `id`; the labels are in the taxonomy.
414
+ */
415
+ programs: string[];
416
+ has_boundary: boolean;
417
+ source?: string | null;
418
+ source_url?: string | null;
419
+ license?: string | null;
420
+ hs_score?: number | null;
421
+ hs_rank?: number | null;
422
+ hs_rank_total?: number | null;
423
+ hs_school_type?: string | null;
424
+ }
425
+ /** One school's yearly assessment snapshot. Licensed. */
426
+ interface SchoolScores {
427
+ uid: string;
428
+ year: number;
429
+ rank?: number | null;
430
+ rank_total?: number | null;
431
+ rank_score?: number | null;
432
+ avg_exam_mark?: number | null;
433
+ year_label?: string | null;
434
+ source?: string | null;
435
+ eqao: Array<{
436
+ grade: number;
437
+ year_mark?: string | null;
438
+ rank?: number | null;
439
+ total?: number | null;
440
+ last5_avg?: number | null;
441
+ }>;
442
+ }
443
+ /** One school, with its contact block. `scores` needs `school_licensed`. */
444
+ interface SchoolDetail extends SchoolSummary {
445
+ address?: string | null;
446
+ phone?: string | null;
447
+ phone2?: string | null;
448
+ fax?: string | null;
449
+ website_url?: string | null;
450
+ boundary_pdf_url?: string | null;
451
+ principal?: string | null;
452
+ feeder_schools?: Record<string, unknown> | null;
453
+ extra?: Record<string, unknown> | null;
454
+ scores?: SchoolScores[];
455
+ /** HouseSigma's own name for the school. */
456
+ hs_name?: string | null;
457
+ /** HouseSigma's own label for the kind of board — `Public` or `Catholic`. */
458
+ hs_board_type?: string | null;
459
+ hs_score_year?: number | null;
460
+ hs_score_average?: number | null;
461
+ hs_rank_year?: number | null;
462
+ }
463
+ /** A school's catchment outline. Licensed. */
464
+ interface SchoolBoundary {
465
+ uid: string;
466
+ name: string;
467
+ geometry?: {
468
+ type: string;
469
+ coordinates: unknown;
470
+ } | null;
471
+ polygon_count: number;
472
+ point_count: number;
473
+ source?: string | null;
474
+ source_url?: string | null;
475
+ license?: string | null;
476
+ }
477
+ /** One catchment covering a queried point. Licensed. */
478
+ interface CatchmentHit {
479
+ uid: string;
480
+ name: string;
481
+ type?: string | null;
482
+ /** The board the school belongs to. */
483
+ board?: string | null;
484
+ /** Which of the school's polygons this is — a catchment can be split. */
485
+ polygon_index: number;
486
+ distance_m?: number | null;
487
+ }
488
+ /** The school vocabulary and the headline counts.
489
+ *
490
+ * The whole vocabulary comes in one call.
491
+ */
492
+ interface SchoolTaxonomy {
493
+ boards: SchoolBoard[];
494
+ types: Array<{
495
+ id: string;
496
+ name: string;
497
+ count: number;
498
+ }>;
499
+ /** The programmes, as `{ id: <code>, name: <label> }`. */
500
+ program_categories: Array<{
501
+ id: string;
502
+ name: string;
503
+ count: number;
504
+ }>;
505
+ /** The provinces, by code. The *names* come from the geography feed. */
506
+ provinces: Array<{
507
+ id: string;
508
+ name: string;
509
+ count: number;
510
+ }>;
511
+ /** The boards' own regions, each with its province. */
512
+ regions: Array<{
513
+ id: string;
514
+ name: string;
515
+ province: string | null;
516
+ count: number;
517
+ }>;
518
+ /** The boards' own types — public, catholic, private. */
519
+ board_types: Array<{
520
+ id: string;
521
+ name: string;
522
+ count: number;
523
+ }>;
524
+ /** The headline counts, with the breakdowns by province, board type and
525
+ * school type. */
526
+ stats: Record<string, unknown>;
527
+ }
300
528
  interface ClientOptions {
301
529
  /** `wq_live_…` key for metered endpoints (sent as `X-API-Key`). */
302
530
  apiKey?: string;
@@ -445,6 +673,138 @@ declare class Whereq {
445
673
  min_ratio?: number;
446
674
  limit?: number;
447
675
  } & Params): Promise<GeoOverlapList>;
676
+ /** The local feed — news, events, stories and notices. */
677
+ localContent(p?: {
678
+ type?: string;
679
+ category?: string;
680
+ source?: string;
681
+ city?: string;
682
+ province?: string;
683
+ bbox?: string;
684
+ q?: string;
685
+ since?: string;
686
+ until?: string;
687
+ has_location?: boolean;
688
+ include_expired?: boolean;
689
+ limit?: number;
690
+ cursor?: string;
691
+ } & Params): Promise<Page<LocalContent>>;
692
+ /** One item, with its tags. */
693
+ localContentItem(contentId: number): Promise<LocalContent>;
694
+ /** The points of interest — the OpenStreetMap sweep.
695
+ *
696
+ * `lat`, `lng` and `radius_km` go together: a proximity search needs
697
+ * all three.
698
+ */
699
+ localPlaces(p?: {
700
+ category?: string;
701
+ kind?: string;
702
+ sub?: string;
703
+ bbox?: string;
704
+ lat?: number;
705
+ lng?: number;
706
+ radius_km?: number;
707
+ q?: string;
708
+ limit?: number;
709
+ offset?: number;
710
+ } & Params): Promise<Page<LocalPlace>>;
711
+ /** One place. */
712
+ localPlace(placeId: number): Promise<LocalPlace>;
713
+ /** The configured local feeds. */
714
+ localSources(p?: {
715
+ enabled?: boolean;
716
+ kind?: string;
717
+ limit?: number;
718
+ } & Params): Promise<Page<LocalSource>>;
719
+ /** The local vocabulary — types, categories, place categories, sources. */
720
+ localTaxonomy(): Promise<{
721
+ types: Array<{
722
+ id: string;
723
+ name: string;
724
+ count: number;
725
+ }>;
726
+ categories: Array<{
727
+ id: string;
728
+ name: string;
729
+ count: number;
730
+ }>;
731
+ place_categories: Array<{
732
+ id: string;
733
+ name: string;
734
+ count: number;
735
+ }>;
736
+ sources: Array<{
737
+ slug: string;
738
+ name: string;
739
+ count: number;
740
+ }>;
741
+ }>;
742
+ /** The school directory.
743
+ *
744
+ * `sort` is a whitelist — `name`, `hs_score`, `hs_rank`, `grade_range`,
745
+ * `type`, `city` — and anything else is a 422. `rank` orders name
746
+ * matches by relevance: exact, then prefix, then a word that starts
747
+ * with the query, then any substring.
748
+ *
749
+ * The limit goes to **5 000**: the map needs a whole viewport in one
750
+ * call, and the whole directory is 2 528 schools.
751
+ */
752
+ schools(p?: {
753
+ q?: string;
754
+ board?: string;
755
+ /** The board's own type — public, catholic or private. */
756
+ board_type?: string;
757
+ /** The board's region, matched loosely. */
758
+ region?: string;
759
+ city?: string;
760
+ province?: string;
761
+ type?: string;
762
+ /** A programme code, e.g. `french_immersion`. */
763
+ program?: string;
764
+ bbox?: string;
765
+ lat?: number;
766
+ lng?: number;
767
+ radius_km?: number;
768
+ has_boundary?: boolean;
769
+ sort?: string;
770
+ order?: "asc" | "desc";
771
+ rank?: boolean;
772
+ limit?: number;
773
+ offset?: number;
774
+ } & Params): Promise<Page<SchoolSummary>>;
775
+ /** The board registry — the vocabulary the `board` filter uses. */
776
+ schoolBoards(): Promise<Page<SchoolBoard>>;
777
+ /** The school vocabulary and the headline counts. */
778
+ schoolTaxonomy(): Promise<SchoolTaxonomy>;
779
+ /** The catchments that cover a point.
780
+ *
781
+ * **Licensed.** This reads the catchment polygons, so it needs the
782
+ * `school_licensed` scope — a key without it gets a 403.
783
+ */
784
+ schoolsAt(p: {
785
+ lat: number;
786
+ lng: number;
787
+ limit?: number;
788
+ } & Params): Promise<Page<CatchmentHit>>;
789
+ /** One school.
790
+ *
791
+ * The uid is board-qualified — `ycdsb/0158`, or
792
+ * `ycdsb/st-theresa-of-lisieux-chs` when the board publishes no code.
793
+ * It carries a slash, and the API's route is built for that.
794
+ *
795
+ * The scores come back only with the `school_licensed` scope.
796
+ */
797
+ school(uid: string): Promise<SchoolDetail>;
798
+ /** A school's catchment outline, as GeoJSON. **Licensed.**
799
+ * `simplify` is in METRES. */
800
+ schoolBoundary(uid: string, p?: {
801
+ simplify?: number;
802
+ } & Params): Promise<SchoolBoundary>;
803
+ /** One year's assessment snapshot, with the EQAO marks. **Licensed.**
804
+ * `year` picks a year; the latest is the default. */
805
+ schoolScores(uid: string, p?: {
806
+ year?: number;
807
+ } & Params): Promise<SchoolScores>;
448
808
  }
449
809
 
450
- 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 GeoAtPlace, type GeoAtResponse, type GeoBoundary, type GeoConcept, type GeoConceptList, type GeoOverlap, type GeoOverlapList, type GeoParent, type GeoPlace, type GeoPlaceDetail, type GeoPlaceList, type GeoPlacesParams, type PriceSeries, type PriceSeriesResponse, VERSION, Whereq, WhereqError, Whereq as default };
810
+ 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 };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var package_default = {
3
- version: "0.6.0"};
3
+ version: "0.7.1"};
4
4
 
5
5
  // src/index.ts
6
6
  var VERSION = package_default.version;
@@ -257,6 +257,86 @@ var Whereq = class {
257
257
  geoOverlaps(p) {
258
258
  return this.get("/v1/geo/overlaps", p);
259
259
  }
260
+ // -- local (news, events, stories, places) --------------------------------
261
+ /** The local feed — news, events, stories and notices. */
262
+ localContent(p = {}) {
263
+ return this.get("/v1/local/content", p);
264
+ }
265
+ /** One item, with its tags. */
266
+ localContentItem(contentId) {
267
+ return this.get(`/v1/local/content/${contentId}`);
268
+ }
269
+ /** The points of interest — the OpenStreetMap sweep.
270
+ *
271
+ * `lat`, `lng` and `radius_km` go together: a proximity search needs
272
+ * all three.
273
+ */
274
+ localPlaces(p = {}) {
275
+ return this.get("/v1/local/places", p);
276
+ }
277
+ /** One place. */
278
+ localPlace(placeId) {
279
+ return this.get(`/v1/local/places/${placeId}`);
280
+ }
281
+ /** The configured local feeds. */
282
+ localSources(p = {}) {
283
+ return this.get("/v1/local/sources", p);
284
+ }
285
+ /** The local vocabulary — types, categories, place categories, sources. */
286
+ localTaxonomy() {
287
+ return this.get("/v1/local/taxonomy");
288
+ }
289
+ // -- schools ----------------------------------------------------------------
290
+ /** The school directory.
291
+ *
292
+ * `sort` is a whitelist — `name`, `hs_score`, `hs_rank`, `grade_range`,
293
+ * `type`, `city` — and anything else is a 422. `rank` orders name
294
+ * matches by relevance: exact, then prefix, then a word that starts
295
+ * with the query, then any substring.
296
+ *
297
+ * The limit goes to **5 000**: the map needs a whole viewport in one
298
+ * call, and the whole directory is 2 528 schools.
299
+ */
300
+ schools(p = {}) {
301
+ return this.get("/v1/schools", p);
302
+ }
303
+ /** The board registry — the vocabulary the `board` filter uses. */
304
+ schoolBoards() {
305
+ return this.get("/v1/schools/boards");
306
+ }
307
+ /** The school vocabulary and the headline counts. */
308
+ schoolTaxonomy() {
309
+ return this.get("/v1/schools/taxonomy");
310
+ }
311
+ /** The catchments that cover a point.
312
+ *
313
+ * **Licensed.** This reads the catchment polygons, so it needs the
314
+ * `school_licensed` scope — a key without it gets a 403.
315
+ */
316
+ schoolsAt(p) {
317
+ return this.get("/v1/schools/at", p);
318
+ }
319
+ /** One school.
320
+ *
321
+ * The uid is board-qualified — `ycdsb/0158`, or
322
+ * `ycdsb/st-theresa-of-lisieux-chs` when the board publishes no code.
323
+ * It carries a slash, and the API's route is built for that.
324
+ *
325
+ * The scores come back only with the `school_licensed` scope.
326
+ */
327
+ school(uid) {
328
+ return this.get(`/v1/schools/${uid}`);
329
+ }
330
+ /** A school's catchment outline, as GeoJSON. **Licensed.**
331
+ * `simplify` is in METRES. */
332
+ schoolBoundary(uid, p = {}) {
333
+ return this.get(`/v1/schools/${uid}/boundary`, p);
334
+ }
335
+ /** One year's assessment snapshot, with the EQAO marks. **Licensed.**
336
+ * `year` picks a year; the latest is the default. */
337
+ schoolScores(uid, p = {}) {
338
+ return this.get(`/v1/schools/${uid}/scores`, p);
339
+ }
260
340
  };
261
341
  var index_default = Whereq;
262
342
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EAEE,OAAA,EAAW,OA+Db,CAAA;;;AC1CO,IAAM,UAAU,eAAA,CAAI;AAE3B,IAAM,gBAAA,GAAmB,0BAAA;AAIlB,IAAM,aAAA,GAAgB,CAAC,SAAA,EAAW,UAAA,EAAY,WAAW,QAAQ;AAIjE,IAAM,cAAA,GAAiB,CAAC,IAAA,EAAM,IAAA,EAAM,IAAI;AAIxC,IAAM,eA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AAE,QAAQ,MAAA,EAAQ,GAAG,GAAG,CAAA;AAAA,EAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAA,CAAU,CAAA,GAA8B,EAAC,EAA0B;AACjE,IAAA,OAAO,IAAA,CAAK,GAAA,CAAkB,gBAAA,EAAkB,CAAC,CAAA;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,GAAA,EAAsC;AAC7C,IAAA,OAAO,KAAK,GAAA,CAAoB,CAAA,eAAA,EAAkB,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAE,CAAA;AAAA,EAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA,CAAY,GAAA,EAAa,CAAA,GAAoC,EAAC,EAAyB;AACrF,IAAA,OAAO,KAAK,GAAA,CAAiB,CAAA,eAAA,EAAkB,mBAAmB,GAAG,CAAC,aAAa,CAAC,CAAA;AAAA,EACtF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,KAAA,CAAM,KAAa,GAAA,EAAqC;AACtD,IAAA,OAAO,KAAK,GAAA,CAAmB,YAAA,EAAc,EAAE,GAAA,EAAK,KAAK,CAAA;AAAA,EAC3D;AAAA;AAAA;AAAA,EAIA,WAAA,GAAuC;AACrC,IAAA,OAAO,IAAA,CAAK,IAAoB,kBAAkB,CAAA;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YACE,CAAA,EACyB;AACzB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAoB,kBAAA,EAAoB,CAAC,CAAA;AAAA,EACvD;AACF;AAEA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["{\n \"name\": \"@whereq/cloud\",\n \"version\": \"0.6.0\",\n \"packageManager\": \"pnpm@9.15.9\",\n \"description\": \"Official JavaScript/TypeScript SDK for the WhereQ data cloud (api.whereq.cloud) — North-America fuel & gas-station prices, cost-of-living prices, autos, lottery, trending, finance & more.\",\n \"license\": \"MIT\",\n \"author\": \"WhereQ <whereq@gmail.com>\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"sideEffects\": false,\n \"engines\": {\n \"node\": \">=18\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/whereq/whereq-cloud-js.git\"\n },\n \"homepage\": \"https://whereq.cloud\",\n \"bugs\": \"https://github.com/whereq/whereq-cloud-js/issues\",\n \"keywords\": [\n \"whereq\",\n \"data\",\n \"api\",\n \"fuel-prices\",\n \"gas-prices\",\n \"cost-of-living\",\n \"prices\",\n \"autos\",\n \"trending\",\n \"finance\",\n \"sdk\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"verify\": \"pnpm run typecheck && pnpm run test && pnpm run build\",\n \"release\": \"pnpm run build && changeset publish\",\n \"prepublishOnly\": \"pnpm run build\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.27.9\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.7.2\",\n \"vitest\": \"^2.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n }\n}\n","/**\n * whereq.cloud — official JavaScript/TypeScript SDK for the WhereQ data cloud.\n *\n * A thin, typed wrapper over the versioned `/v1` HTTP API at `api.whereq.cloud`.\n * Public endpoints work with no key; metered endpoints take an API key.\n *\n * ```ts\n * import { Whereq } from \"@whereq/cloud\";\n *\n * const wq = new Whereq(); // public access\n * // const wq = new Whereq({ apiKey: \"wq_live_…\" }); // metered tier\n *\n * await wq.costOfLiving(\"us:California,ca:Ontario\");\n * await wq.prices({ domain: \"rent\", region: \"us\", bedrooms: 2 });\n * await wq.get(\"/v1/trending\", { limit: 10 }); // escape hatch\n * ```\n */\nimport pkg from \"../package.json\";\n\n/**\n * The SDK version, read straight from `package.json` so it can never drift\n * from what is published. Changesets bumps `package.json`; this follows it.\n */\nexport const VERSION = pkg.version;\n\nconst DEFAULT_BASE_URL = \"https://api.whereq.cloud\";\n\n/** The products a station can quote. Mexico's CRE feed carries the first,\n * second and fourth; GasBuddy (US/Canada) adds midgrade. */\nexport const FUEL_PRODUCTS = [\"regular\", \"midgrade\", \"premium\", \"diesel\"] as const;\nexport type FuelProduct = (typeof FUEL_PRODUCTS)[number];\n\n/** Countries with station-level fuel data. */\nexport const FUEL_COUNTRIES = [\"MX\", \"US\", \"CA\"] as const;\nexport type FuelCountry = (typeof FUEL_COUNTRIES)[number];\n\n/** The unit each country quotes in — always local currency per litre. */\nexport const FUEL_CURRENCIES: Record<FuelCountry, string> = {\n MX: \"MXN/L\",\n US: \"USD/L\",\n CA: \"CAD/L\",\n};\n\n/** One product's latest price at a station. */\nexport interface FuelStationPrice {\n price: number;\n observed_at: string;\n}\n\n/** A geolocated retail fuel station.\n * `state` is the human label (\"Ontario\", \"Texas\"); `state_iso` is the\n * two-letter code (\"ON\", \"TX\"). */\nexport interface FuelStation {\n id: number;\n source: string;\n ext_id: string;\n country: string;\n name: string;\n brand?: string | null;\n state?: string | null;\n state_iso?: string | null;\n municipality?: string | null;\n lat?: number | null;\n lon?: number | null;\n /** The latest price per product — present on the *list* endpoint. The\n * *detail* endpoint omits it: its timeline comes back as the separate\n * `prices` array on the response. */\n prices?: Record<string, FuelStationPrice>;\n}\n\n/** Filters for `fuelStations()`. */\nexport interface FuelStationsParams {\n /** \"MX\", \"US\" or \"CA\". */\n country?: FuelCountry | string;\n /** State/province name *or* ISO code — \"Ontario\"/\"ON\", \"Texas\"/\"TX\". */\n state?: string;\n /** City name, e.g. \"Mississauga\". */\n municipality?: string;\n product?: FuelProduct | string;\n /** \"minLon,minLat,maxLon,maxLat\" — a map viewport. */\n bbox?: string;\n /** Station-name search. */\n q?: string;\n /** 1–500 rows per page (default 100). */\n limit?: number;\n /** Row offset for paging. */\n offset?: number;\n}\n\n/** Filters for `fuelStation()`. */\nexport interface FuelStationParams {\n /** Restrict the timeline to one product. */\n product?: FuelProduct | string;\n /** How far back the timeline reaches (1–1825, default 90). */\n days?: number;\n}\n\n/** `GET /v1/fuel/stations`. Unentitled callers get a 100-row preview of the\n * oldest rows: `demo` is true, `total` is null and paging is ignored. */\nexport interface FuelStationsResponse {\n demo?: boolean;\n preview_rows?: number;\n note?: string;\n upgrade_url?: string;\n as_of: string;\n count: number;\n total?: number | null;\n stations: FuelStation[];\n}\n\n/** One observed price change — the intra-day timeline for a station. */\nexport interface FuelStationPricePoint {\n product: string;\n observed_at: string;\n price: number;\n}\n\n/** `GET /v1/fuel/stations/{id}`. `days` is null in the unentitled preview. */\nexport interface FuelStationDetail {\n demo?: boolean;\n preview_rows?: number;\n note?: string;\n upgrade_url?: string;\n station: FuelStation;\n days?: number | null;\n prices: FuelStationPricePoint[];\n}\n\n/** Filters for `fuelPrices()`. */\nexport interface FuelPricesParams {\n /** Region slug, or a comma-separated list of them (\"us,ca\"). */\n region?: string;\n /** Free-text place name (\"Calgary, Alberta\"). */\n geo?: string;\n q?: string;\n limit?: number;\n offset?: number;\n}\n\n/** One aggregated price series (state / national / metro). */\nexport interface PriceSeries {\n id: number;\n domain: string;\n source: string;\n region?: string | null;\n geo?: string | null;\n item: string;\n item_cn?: string | null;\n unit?: string | null;\n unit_cn?: string | null;\n frequency?: string | null;\n latest_period?: string | null;\n latest_value?: number | null;\n prev_value?: number | null;\n points?: number | null;\n spark?: number[];\n}\n\n/** `GET /v1/prices` — a page of series plus the page's own metadata. */\nexport interface PriceSeriesResponse {\n count: number;\n domain?: string | null;\n region?: string | null;\n limit: number;\n offset: number;\n data: PriceSeries[];\n}\n\n// -- geography (places, boundaries, hierarchy) ---------------------------------\n\n/** One place — a province, a municipality, a ward, a neighbourhood.\n *\n * `kind` is the platform's own concept (`province`, `region`,\n * `municipality`, `city`, `town`, `ward`, `neighbourhood`…), not the\n * source's admin level. `country_code` is the two-letter ISO code and is\n * the same for both vocabularies — a country filter accepts `CA` or\n * `CAN` and answers with the same places either way.\n */\nexport interface GeoPlace {\n uid: string;\n kind: string;\n kind_source: string;\n name: string;\n name_en?: string | null;\n name_zh?: string | null;\n name_local?: string | null;\n official_name?: string | null;\n source: string;\n source_id: string;\n source_url?: string | null;\n license?: string | null;\n raw_admin_level?: number | null;\n raw_place?: string | null;\n raw_boundary?: string | null;\n country_code?: string | null;\n province_code?: string | null;\n iso_code?: string | null;\n ref?: string | null;\n population?: number | null;\n population_date?: string | null;\n wikidata?: string | null;\n wikipedia?: string | null;\n website?: string | null;\n capital?: string | null;\n centroid_lon?: number | null;\n centroid_lat?: number | null;\n bbox_min_lon?: number | null;\n bbox_min_lat?: number | null;\n bbox_max_lon?: number | null;\n bbox_max_lat?: number | null;\n area_km2?: number | null;\n has_boundary: boolean;\n}\n\nexport interface GeoPlaceList {\n count: number;\n data: GeoPlace[];\n limit: number;\n offset: number;\n}\n\n/** One container of a place, as the detail endpoint lists them.\n *\n * A place has SEVERAL parents — a neighbourhood is in a ward, in a city,\n * in a census division and in a province, all at once. The list is\n * deliberately a list.\n */\nexport interface GeoParent {\n uid: string;\n kind: string;\n name: string;\n source: string;\n area_ratio?: number | null;\n is_primary: boolean;\n}\n\n/** One place with its containers and the places inside it. */\nexport interface GeoPlaceDetail {\n uid: string;\n place: GeoPlace;\n parents: GeoParent[];\n children: GeoParent[];\n}\n\n/** One concept in the vocabulary, with a live count behind it. */\nexport interface GeoConcept {\n kind: string;\n name: string;\n name_cn?: string | null;\n description?: string | null;\n description_cn?: string | null;\n places: number;\n with_boundary: number;\n rank: number;\n}\n\n/** The vocabulary, explained. */\nexport interface GeoConceptList {\n count: number;\n concepts: GeoConcept[];\n sources: Array<Record<string, unknown>>;\n}\n\n/** Two places of DIFFERENT kinds covering the same ground.\n *\n * This is the deliberate part of the dataset: a census subdivision and\n * an OpenStreetMap city boundary that describe the same town in two\n * vocabularies. The platform keeps both rather than picking one.\n */\nexport interface GeoOverlap {\n a_id: number;\n b_id: number;\n a_uid: string;\n b_uid: string;\n a_name: string;\n b_name: string;\n a_kind: string;\n b_kind: string;\n a_source: string;\n b_source: string;\n overlap_ratio: number;\n a_concept: string;\n b_concept: string;\n}\n\n/** The overlapping pairs inside a box. */\nexport interface GeoOverlapList {\n bbox: Record<string, number>;\n min_ratio: number;\n count: number;\n overlaps: GeoOverlap[];\n}\n\n/** One place in the containing stack at a point.\n *\n * `country_code` is on every level, so the stack can be read without a\n * second lookup.\n */\nexport interface GeoAtPlace {\n uid: string;\n kind: string;\n kind_source: string;\n name: string;\n name_en?: string | null;\n name_zh?: string | null;\n source: string;\n raw_admin_level?: number | null;\n raw_place?: string | null;\n population?: number | null;\n wikidata?: string | null;\n centroid_lon?: number | null;\n centroid_lat?: number | null;\n area_km2?: number | null;\n country_code?: string | null;\n province_code?: string | null;\n boundary_area_km2?: number | null;\n concept?: Record<string, unknown>;\n}\n\n/** Every place containing a point, broadest first: country, province,\n * region, municipality, city, ward, neighbourhood. The answer to \"where\n * am I?\" without pretending one of them is *the* answer. */\nexport interface GeoAtResponse {\n lon: number;\n lat: number;\n count: number;\n places: GeoAtPlace[];\n}\n\n/** A place's outline as GeoJSON — a FeatureCollection you can hand\n * straight to a map library. */\nexport interface GeoBoundary {\n type: string;\n features: Array<Record<string, unknown>>;\n}\n\nexport interface GeoPlacesParams {\n kind?: string;\n source?: string;\n country?: string;\n q?: string;\n bbox?: string;\n has_boundary?: boolean;\n limit?: number;\n offset?: number;\n}\n\nexport class WhereqError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n public readonly url: string,\n ) {\n super(`whereq.cloud API error ${status} for ${url}: ${message}`);\n this.name = \"WhereqError\";\n }\n}\n\nexport interface ClientOptions {\n /** `wq_live_…` key for metered endpoints (sent as `X-API-Key`). */\n apiKey?: string;\n /** Override the API base (default `https://api.whereq.cloud`). */\n baseUrl?: string;\n /** Custom fetch (e.g. for Node <18 or testing). Defaults to global `fetch`. */\n fetch?: typeof fetch;\n}\n\ntype Params = Record<string, unknown>;\n\n/** The API key from the environment, when there is one. */\nfunction envApiKey(): string {\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process;\n return proc?.env?.WHEREQ_API_KEY ?? \"\";\n}\n\nexport class Whereq {\n private readonly baseUrl: string;\n private readonly headers: Record<string, string>;\n private readonly _fetch: typeof fetch;\n\n constructor(opts: ClientOptions = {}) {\n this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.headers = { Accept: \"application/json\" };\n // The key may come from the options or the environment, in that order.\n const key = opts.apiKey ?? envApiKey();\n if (key) this.headers[\"X-API-Key\"] = key;\n const f = opts.fetch ?? globalThis.fetch;\n if (!f) throw new Error(\"No global fetch available — pass `fetch` in options (Node <18).\");\n this._fetch = f;\n }\n\n private url(path: string, params: Params): string {\n const qs = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined && v !== null) qs.set(k, String(v));\n }\n const s = qs.toString();\n return `${this.baseUrl}${path}${s ? `?${s}` : \"\"}`;\n }\n\n /** GET any endpoint; `undefined`/`null` params are dropped. Returns parsed JSON. */\n async get<T = unknown>(path: string, params: Params = {}): Promise<T> {\n const url = this.url(path, params);\n const res = await this._fetch(url, { headers: this.headers });\n if (!res.ok) {\n let msg = res.statusText;\n try {\n const j = (await res.json()) as { detail?: string };\n msg = j?.detail || JSON.stringify(j) || msg;\n } catch {\n /* non-JSON error body */\n }\n throw new WhereqError(res.status, msg, url);\n }\n return (await res.json()) as T;\n }\n\n /** GET a non-JSON endpoint (e.g. CSV export) as text. */\n async getText(path: string, params: Params = {}): Promise<string> {\n const url = this.url(path, params);\n const res = await this._fetch(url, { headers: this.headers });\n if (!res.ok) throw new WhereqError(res.status, res.statusText, url);\n return res.text();\n }\n\n // -- prices / cost of living ------------------------------------------------\n /** Cost-of-living price series (fuel | food | energy | housing | rent).\n * `region` takes a region slug or a comma-separated list (\"us,ca\");\n * `geo` is a free-text place name (\"Calgary, Alberta\"). */\n prices(p: { domain?: string; region?: string; geo?: string; bedrooms?: number; q?: string; limit?: number; offset?: number } = {}): Promise<PriceSeriesResponse> {\n return this.get<PriceSeriesResponse>(\"/v1/prices\", p);\n }\n price(seriesId: number) {\n return this.get(`/v1/prices/${seriesId}`);\n }\n pricesCsv(p: { domain?: string; region?: string; geo?: string; bedrooms?: number; q?: string } = {}) {\n return this.getText(\"/v1/prices/export\", p);\n }\n /** Compare cost of living across US states / CA provinces / metros.\n * `places`: comma-separated `region:name` or `m:<rent-series-id>`. */\n costOfLiving(places: string) {\n return this.get(\"/v1/cost-of-living\", { places });\n }\n\n // -- discovery / facets -----------------------------------------------------\n catalog() { return this.get(\"/v1/catalog\"); }\n categories() { return this.get(\"/v1/categories\"); }\n regions() { return this.get(\"/v1/regions\"); }\n domains() { return this.get(\"/v1/domains\"); }\n trending(p: Params = {}) { return this.get(\"/v1/trending\", p); }\n\n // -- finance ----------------------------------------------------------------\n hotstocks(limit = 20) { return this.get(\"/v1/hotstocks\", { limit }); }\n quotes(p: Params = {}) { return this.get(\"/v1/quotes\", p); }\n news(p: Params = {}) { return this.get(\"/v1/news\", p); }\n screener(p: Params = {}) { return this.get(\"/v1/screener\", p); }\n search(q: string, p: Params = {}) { return this.get(\"/v1/search\", { q, ...p }); }\n\n // -- autos ------------------------------------------------------------------\n autosRecalls(p: Params = {}) { return this.get(\"/v1/autos/recalls\", p); }\n autosListings(p: Params = {}) { return this.get(\"/v1/autos/listings\", p); }\n autosFuelEconomy(p: Params = {}) { return this.get(\"/v1/autos/fuel-economy\", p); }\n autosModels(p: Params = {}) { return this.get(\"/v1/autos/models\", p); }\n\n // -- lottery -----------------------------------------------------------------\n /** Recent lottery draws, newest first.\n *\n * Unentitled callers get the oldest 100 draws instead of the recent\n * ones — check `response.demo`.\n */\n lotteryDraws(p: { game?: string; days?: number; limit?: number } & Params = {}): Promise<any> {\n return this.get(\"/v1/lottery/draws\", p);\n }\n /** The most recent draw for a game. On the unentitled preview this is the\n * *oldest* draw — the recent one is the gated, valuable row. */\n lotteryLatestDraw(game: string): Promise<any> {\n return this.get(`/v1/lottery/draws/${encodeURIComponent(game)}/latest`);\n }\n /** Per-number frequency for a game over a window (30–1825 days). */\n lotteryFrequency(game: string, days = 365): Promise<any> {\n return this.get(`/v1/lottery/draws/${encodeURIComponent(game)}/frequency`, { days });\n }\n /** The lottery game registry: names, play rules and draw days. */\n lotteryGames(p: { country?: string; region?: string } & Params = {}): Promise<any> {\n return this.get(\"/v1/lottery/games\", p);\n }\n /** One game's full play rules and metadata. */\n lotteryGame(slug: string): Promise<any> {\n return this.get(`/v1/lottery/games/${encodeURIComponent(slug)}`);\n }\n\n // -- fuel (gas & diesel) ----------------------------------------------------\n /** Geolocated retail fuel stations with their latest prices.\n *\n * Coverage: Mexico (`MX`, CRE open data), the United States (`US`) and\n * Canada (`CA`). Prices are in **local currency per litre** — `MXN/L`,\n * `USD/L` and `CAD/L` respectively.\n *\n * Unentitled callers get a 100-row preview of the oldest rows and the\n * pagination arguments are ignored — check `response.demo`.\n */\n fuelStations(p: FuelStationsParams & Params = {}): Promise<FuelStationsResponse> {\n return this.get<FuelStationsResponse>(\"/v1/fuel/stations\", p);\n }\n\n /** One station: location, latest prices and its price-change timeline. */\n fuelStation(\n id: number | string,\n p: FuelStationParams & Params = {},\n ): Promise<FuelStationDetail> {\n return this.get<FuelStationDetail>(\n `/v1/fuel/stations/${encodeURIComponent(String(id))}`,\n p,\n );\n }\n\n /** Yield every matching station, paging through the API for you.\n *\n * Only meaningful with an entitled key. The unentitled preview always\n * returns the *same* oldest 100 rows and ignores the paging arguments,\n * so there is nothing more to fetch: this yields that first page and\n * stops rather than looping on it.\n */\n async *fuelStationsAll(\n p: FuelStationsParams & Params = {},\n ): AsyncGenerator<FuelStation> {\n const pageSize = Math.min(Math.max(Number(p.limit ?? 500), 1), 500);\n let offset = Number(p.offset ?? 0);\n for (;;) {\n const page = await this.fuelStations({ ...p, limit: pageSize, offset });\n const stations = page.stations ?? [];\n if (stations.length === 0) return;\n for (const s of stations) yield s;\n if (page.demo) return; // preview: every page is the same slice\n offset += stations.length;\n if (page.total != null && offset >= page.total) return;\n }\n }\n\n /** Aggregated fuel price series (state / national / metro).\n *\n * These are the *series* behind the charts — EIA weekly for the US,\n * StatCan monthly for Canada, CRE for Mexico — not the station-level\n * prices that `fuelStations()` returns.\n */\n fuelPrices(p: FuelPricesParams & Params = {}): Promise<PriceSeriesResponse> {\n return this.get<PriceSeriesResponse>(\"/v1/prices\", { domain: \"fuel\", ...p });\n }\n\n // -- geography (places, boundaries, hierarchy) ------------------------------\n /** The place list — provinces, regions, municipalities, cities, towns,\n * wards, neighbourhoods, countries.\n *\n * `country` takes an ISO code and either spelling works: `\"CA\"` and\n * `\"CAN\"` find the same places, in both vocabularies.\n */\n geoPlaces(p: GeoPlacesParams & Params = {}): Promise<GeoPlaceList> {\n return this.get<GeoPlaceList>(\"/v1/geo/places\", p);\n }\n\n /** One place, with its containers AND the places inside it.\n *\n * The parents are a list on purpose: a place belongs to several things\n * at once.\n */\n geoPlace(uid: string): Promise<GeoPlaceDetail> {\n return this.get<GeoPlaceDetail>(`/v1/geo/places/${encodeURIComponent(uid)}`);\n }\n\n /** A place's outline as GeoJSON.\n *\n * `simplify` is in METRES: the outline keeps every corner more than\n * that far from the original, and the result is still a valid polygon.\n */\n geoBoundary(uid: string, p: { simplify?: number } & Params = {}): Promise<GeoBoundary> {\n return this.get<GeoBoundary>(`/v1/geo/places/${encodeURIComponent(uid)}/boundary`, p);\n }\n\n /** Every place containing a point, broadest first.\n *\n * The answer to \"which district is this?\" without picking a winner: a\n * point downtown Toronto lands in a neighbourhood, a ward, a city, a\n * census division, a province and a country, and all of them are\n * returned.\n */\n geoAt(lon: number, lat: number): Promise<GeoAtResponse> {\n return this.get<GeoAtResponse>(\"/v1/geo/at\", { lon, lat });\n }\n\n /** The vocabulary: every concept, in both languages, with a live count of\n * how many places and outlines it has. */\n geoConcepts(): Promise<GeoConceptList> {\n return this.get<GeoConceptList>(\"/v1/geo/concepts\");\n }\n\n /** The places of different kinds that cover the same ground.\n *\n * `bbox` is required — \"minLon,minLat,maxLon,maxLat\". Comparing every\n * pair in the country is a quadratic join, and nobody asks that\n * question about all of Canada at once.\n */\n geoOverlaps(\n p: { bbox: string; min_ratio?: number; limit?: number } & Params,\n ): Promise<GeoOverlapList> {\n return this.get<GeoOverlapList>(\"/v1/geo/overlaps\", p);\n }\n}\n\nexport default Whereq;\n"]}
1
+ {"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EAEE,OAAA,EAAW,OA8Db,CAAA;;;ACxCO,IAAM,UAAU,eAAA,CAAI;AAE3B,IAAM,gBAAA,GAAmB,0BAAA;AAIlB,IAAM,aAAA,GAAgB,CAAC,SAAA,EAAW,UAAA,EAAY,WAAW,QAAQ;AAIjE,IAAM,cAAA,GAAiB,CAAC,IAAA,EAAM,IAAA,EAAM,IAAI;AAIxC,IAAM,eAAA,GAA+C;AAAA,EAC1D,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI;AACN;AAkTO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACkB,MAAA,EAChB,OAAA,EACgB,GAAA,EAChB;AACA,IAAA,KAAA,CAAM,0BAA0B,MAAM,CAAA,KAAA,EAAQ,GAAG,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA;AAJ/C,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEA,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO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O,aAAA,GAAQ","file":"index.js","sourcesContent":["{\n \"name\": \"@whereq/cloud\",\n \"version\": \"0.7.1\",\n \"packageManager\": \"pnpm@9.15.9\",\n \"description\": \"Official JavaScript/TypeScript SDK for the WhereQ data cloud (api.whereq.cloud) — North-America fuel & gas-station prices, cost-of-living prices, autos, lottery, trending, finance & more.\",\n \"license\": \"MIT\",\n \"author\": \"WhereQ <whereq@gmail.com>\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"sideEffects\": false,\n \"engines\": {\n \"node\": \">=18\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/whereq/whereq-cloud-js.git\"\n },\n \"homepage\": \"https://whereq.cloud\",\n \"bugs\": \"https://github.com/whereq/whereq-cloud-js/issues\",\n \"keywords\": [\n \"whereq\",\n \"data\",\n \"api\",\n \"fuel-prices\",\n \"gas-prices\",\n \"cost-of-living\",\n \"prices\",\n \"autos\",\n \"trending\",\n \"finance\",\n \"sdk\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"verify\": \"pnpm run typecheck && pnpm run test && pnpm run build\",\n \"prepublishOnly\": \"pnpm run build\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.10.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.7.2\",\n \"vitest\": \"^2.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n }\n}\n","/**\n * whereq.cloud — official JavaScript/TypeScript SDK for the WhereQ data cloud.\n *\n * A thin, typed wrapper over the versioned `/v1` HTTP API at `api.whereq.cloud`.\n * Public endpoints work with no key; metered endpoints take an API key.\n *\n * ```ts\n * import { Whereq } from \"@whereq/cloud\";\n *\n * const wq = new Whereq(); // public access\n * // const wq = new Whereq({ apiKey: \"wq_live_…\" }); // metered tier\n *\n * await wq.costOfLiving(\"us:California,ca:Ontario\");\n * await wq.prices({ domain: \"rent\", region: \"us\", bedrooms: 2 });\n * await wq.get(\"/v1/trending\", { limit: 10 }); // escape hatch\n * ```\n */\nimport pkg from \"../package.json\";\n\n/**\n * The SDK version, read straight from `package.json` so it can never drift\n * from what is published. The release tooling bumps `package.json`; this\n * follows it.\n */\nexport const VERSION = pkg.version;\n\nconst DEFAULT_BASE_URL = \"https://api.whereq.cloud\";\n\n/** The products a station can quote. Mexico's CRE feed carries the first,\n * second and fourth; GasBuddy (US/Canada) adds midgrade. */\nexport const FUEL_PRODUCTS = [\"regular\", \"midgrade\", \"premium\", \"diesel\"] as const;\nexport type FuelProduct = (typeof FUEL_PRODUCTS)[number];\n\n/** Countries with station-level fuel data. */\nexport const FUEL_COUNTRIES = [\"MX\", \"US\", \"CA\"] as const;\nexport type FuelCountry = (typeof FUEL_COUNTRIES)[number];\n\n/** The unit each country quotes in — always local currency per litre. */\nexport const FUEL_CURRENCIES: Record<FuelCountry, string> = {\n MX: \"MXN/L\",\n US: \"USD/L\",\n CA: \"CAD/L\",\n};\n\n/** One product's latest price at a station. */\nexport interface FuelStationPrice {\n price: number;\n observed_at: string;\n}\n\n/** A geolocated retail fuel station.\n * `state` is the human label (\"Ontario\", \"Texas\"); `state_iso` is the\n * two-letter code (\"ON\", \"TX\"). */\nexport interface FuelStation {\n id: number;\n source: string;\n ext_id: string;\n country: string;\n name: string;\n brand?: string | null;\n state?: string | null;\n state_iso?: string | null;\n municipality?: string | null;\n lat?: number | null;\n lon?: number | null;\n /** The latest price per product — present on the *list* endpoint. The\n * *detail* endpoint omits it: its timeline comes back as the separate\n * `prices` array on the response. */\n prices?: Record<string, FuelStationPrice>;\n}\n\n/** Filters for `fuelStations()`. */\nexport interface FuelStationsParams {\n /** \"MX\", \"US\" or \"CA\". */\n country?: FuelCountry | string;\n /** State/province name *or* ISO code — \"Ontario\"/\"ON\", \"Texas\"/\"TX\". */\n state?: string;\n /** City name, e.g. \"Mississauga\". */\n municipality?: string;\n product?: FuelProduct | string;\n /** \"minLon,minLat,maxLon,maxLat\" — a map viewport. */\n bbox?: string;\n /** Station-name search. */\n q?: string;\n /** 1–500 rows per page (default 100). */\n limit?: number;\n /** Row offset for paging. */\n offset?: number;\n}\n\n/** Filters for `fuelStation()`. */\nexport interface FuelStationParams {\n /** Restrict the timeline to one product. */\n product?: FuelProduct | string;\n /** How far back the timeline reaches (1–1825, default 90). */\n days?: number;\n}\n\n/** `GET /v1/fuel/stations`. Unentitled callers get a 100-row preview of the\n * oldest rows: `demo` is true, `total` is null and paging is ignored. */\nexport interface FuelStationsResponse {\n demo?: boolean;\n preview_rows?: number;\n note?: string;\n upgrade_url?: string;\n as_of: string;\n count: number;\n total?: number | null;\n stations: FuelStation[];\n}\n\n/** One observed price change — the intra-day timeline for a station. */\nexport interface FuelStationPricePoint {\n product: string;\n observed_at: string;\n price: number;\n}\n\n/** `GET /v1/fuel/stations/{id}`. `days` is null in the unentitled preview. */\nexport interface FuelStationDetail {\n demo?: boolean;\n preview_rows?: number;\n note?: string;\n upgrade_url?: string;\n station: FuelStation;\n days?: number | null;\n prices: FuelStationPricePoint[];\n}\n\n/** Filters for `fuelPrices()`. */\nexport interface FuelPricesParams {\n /** Region slug, or a comma-separated list of them (\"us,ca\"). */\n region?: string;\n /** Free-text place name (\"Calgary, Alberta\"). */\n geo?: string;\n q?: string;\n limit?: number;\n offset?: number;\n}\n\n/** One aggregated price series (state / national / metro). */\nexport interface PriceSeries {\n id: number;\n domain: string;\n source: string;\n region?: string | null;\n geo?: string | null;\n item: string;\n item_cn?: string | null;\n unit?: string | null;\n unit_cn?: string | null;\n frequency?: string | null;\n latest_period?: string | null;\n latest_value?: number | null;\n prev_value?: number | null;\n points?: number | null;\n spark?: number[];\n}\n\n/** `GET /v1/prices` — a page of series plus the page's own metadata. */\nexport interface PriceSeriesResponse {\n count: number;\n domain?: string | null;\n region?: string | null;\n limit: number;\n offset: number;\n data: PriceSeries[];\n}\n\n// -- geography (places, boundaries, hierarchy) ---------------------------------\n\n/** One place — a province, a municipality, a ward, a neighbourhood.\n *\n * `kind` is the platform's own concept (`province`, `region`,\n * `municipality`, `city`, `town`, `ward`, `neighbourhood`…), not the\n * source's admin level. `country_code` is the two-letter ISO code and is\n * the same for both vocabularies — a country filter accepts `CA` or\n * `CAN` and answers with the same places either way.\n */\nexport interface GeoPlace {\n uid: string;\n kind: string;\n kind_source: string;\n name: string;\n name_en?: string | null;\n name_zh?: string | null;\n name_local?: string | null;\n official_name?: string | null;\n source: string;\n source_id: string;\n source_url?: string | null;\n license?: string | null;\n raw_admin_level?: number | null;\n raw_place?: string | null;\n raw_boundary?: string | null;\n country_code?: string | null;\n province_code?: string | null;\n iso_code?: string | null;\n ref?: string | null;\n population?: number | null;\n population_date?: string | null;\n wikidata?: string | null;\n wikipedia?: string | null;\n website?: string | null;\n capital?: string | null;\n centroid_lon?: number | null;\n centroid_lat?: number | null;\n bbox_min_lon?: number | null;\n bbox_min_lat?: number | null;\n bbox_max_lon?: number | null;\n bbox_max_lat?: number | null;\n area_km2?: number | null;\n has_boundary: boolean;\n}\n\nexport interface GeoPlaceList {\n count: number;\n data: GeoPlace[];\n limit: number;\n offset: number;\n}\n\n/** One container of a place, as the detail endpoint lists them.\n *\n * A place has SEVERAL parents — a neighbourhood is in a ward, in a city,\n * in a census division and in a province, all at once. The list is\n * deliberately a list.\n */\nexport interface GeoParent {\n uid: string;\n kind: string;\n name: string;\n source: string;\n area_ratio?: number | null;\n is_primary: boolean;\n}\n\n/** One place with its containers and the places inside it. */\nexport interface GeoPlaceDetail {\n uid: string;\n place: GeoPlace;\n parents: GeoParent[];\n children: GeoParent[];\n}\n\n/** One concept in the vocabulary, with a live count behind it. */\nexport interface GeoConcept {\n kind: string;\n name: string;\n name_cn?: string | null;\n description?: string | null;\n description_cn?: string | null;\n places: number;\n with_boundary: number;\n rank: number;\n}\n\n/** The vocabulary, explained. */\nexport interface GeoConceptList {\n count: number;\n concepts: GeoConcept[];\n sources: Array<Record<string, unknown>>;\n}\n\n/** Two places of DIFFERENT kinds covering the same ground.\n *\n * This is the deliberate part of the dataset: a census subdivision and\n * an OpenStreetMap city boundary that describe the same town in two\n * vocabularies. The platform keeps both rather than picking one.\n */\nexport interface GeoOverlap {\n a_id: number;\n b_id: number;\n a_uid: string;\n b_uid: string;\n a_name: string;\n b_name: string;\n a_kind: string;\n b_kind: string;\n a_source: string;\n b_source: string;\n overlap_ratio: number;\n a_concept: string;\n b_concept: string;\n}\n\n/** The overlapping pairs inside a box. */\nexport interface GeoOverlapList {\n bbox: Record<string, number>;\n min_ratio: number;\n count: number;\n overlaps: GeoOverlap[];\n}\n\n/** One place in the containing stack at a point.\n *\n * `country_code` is on every level, so the stack can be read without a\n * second lookup.\n */\nexport interface GeoAtPlace {\n uid: string;\n kind: string;\n kind_source: string;\n name: string;\n name_en?: string | null;\n name_zh?: string | null;\n source: string;\n raw_admin_level?: number | null;\n raw_place?: string | null;\n population?: number | null;\n wikidata?: string | null;\n centroid_lon?: number | null;\n centroid_lat?: number | null;\n area_km2?: number | null;\n country_code?: string | null;\n province_code?: string | null;\n boundary_area_km2?: number | null;\n concept?: Record<string, unknown>;\n}\n\n/** Every place containing a point, broadest first: country, province,\n * region, municipality, city, ward, neighbourhood. The answer to \"where\n * am I?\" without pretending one of them is *the* answer. */\nexport interface GeoAtResponse {\n lon: number;\n lat: number;\n count: number;\n places: GeoAtPlace[];\n}\n\n/** A place's outline as GeoJSON — a FeatureCollection you can hand\n * straight to a map library. */\nexport interface GeoBoundary {\n type: string;\n features: Array<Record<string, unknown>>;\n}\n\nexport interface GeoPlacesParams {\n kind?: string;\n source?: string;\n country?: string;\n q?: string;\n bbox?: string;\n has_boundary?: boolean;\n limit?: number;\n offset?: number;\n}\n\nexport class WhereqError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n public readonly url: string,\n ) {\n super(`whereq.cloud API error ${status} for ${url}: ${message}`);\n this.name = \"WhereqError\";\n }\n}\n\n/* -- local (news, events, stories, places) -------------------------------- */\n\n/** One item from a local feed — a story, an event, a notice. */\nexport interface LocalContent {\n id: number;\n type: string;\n category?: string | null;\n title: string;\n summary?: string | null;\n description?: string | null;\n source_name?: string | null;\n source_url?: string | null;\n url?: string | null;\n publish_time?: string | null;\n latitude?: number | null;\n longitude?: number | null;\n city?: string | null;\n province?: string | null;\n country?: string | null;\n geocode_status?: string | null;\n confidence_score?: number | null;\n status: string;\n expires_at?: string | null;\n tags?: string[];\n}\n\n/** One point of interest. */\nexport interface LocalPlace {\n id: number;\n source: string;\n source_url?: string | null;\n license?: string | null;\n external_id: string;\n name: string;\n latitude?: number | null;\n longitude?: number | null;\n city?: string | null;\n province?: string | null;\n country?: string | null;\n category?: string | null;\n kind?: string | null;\n metadata?: Record<string, unknown>;\n}\n\n/** One configured local feed. */\nexport interface LocalSource {\n slug: string;\n name: string;\n kind: string;\n url?: string | null;\n default_type?: string | null;\n default_city?: string | null;\n default_province?: string | null;\n default_country?: string | null;\n enabled: boolean;\n crawl_interval_minutes: number;\n}\n\n/** The page envelope every list endpoint uses. */\nexport interface Page<T> {\n data: T[];\n pagination: {\n limit: number;\n count: number;\n next_cursor?: string | null;\n offset?: number;\n };\n}\n\n/* -- schools ---------------------------------------------------------------- */\n\n/** One school board. */\nexport interface SchoolBoard {\n slug: string;\n name: string;\n type?: string | null;\n region?: string | null;\n /** The province code, e.g. `ON`. */\n province?: string | null;\n school_count: number;\n}\n\n/**\n * One school.\n *\n * The `hs_*` fields are **present only when the API key holds the\n * `school_licensed` scope**. Without it they are absent — not null — so a\n * caller can tell \"you are not entitled to this\" from \"there is no value\n * here\".\n */\nexport interface SchoolSummary {\n /**\n * The platform's own row id.\n *\n * **Not an identifier** — the `uid` is — but the join key for the\n * migration: whereq.com's school rows carry the same integers, because\n * the import preserved them. It changes if the dataset is reloaded.\n */\n id: number;\n uid: string;\n name: string;\n type?: string | null;\n status?: string | null;\n province?: string | null;\n /**\n * The **board's** region — `York Region`, `Toronto`.\n *\n * This is what the `region` filter matches. The school row's own\n * `region` column holds a denormalised province name and is not served.\n */\n region?: string | null;\n city?: string | null;\n municipality?: string | null;\n board?: SchoolBoard | null;\n latitude?: number | null;\n longitude?: number | null;\n grade_range?: string | null;\n /**\n * The programme **codes** (`french_immersion`), not the labels.\n *\n * The code is what the `program` filter takes and what the taxonomy\n * lists as its `id`; the labels are in the taxonomy.\n */\n programs: string[];\n has_boundary: boolean;\n source?: string | null;\n source_url?: string | null;\n license?: string | null;\n hs_score?: number | null;\n hs_rank?: number | null;\n hs_rank_total?: number | null;\n hs_school_type?: string | null;\n}\n\n/** One school's yearly assessment snapshot. Licensed. */\nexport interface SchoolScores {\n uid: string;\n year: number;\n rank?: number | null;\n rank_total?: number | null;\n rank_score?: number | null;\n avg_exam_mark?: number | null;\n year_label?: string | null;\n source?: string | null;\n eqao: Array<{\n grade: number;\n year_mark?: string | null;\n rank?: number | null;\n total?: number | null;\n last5_avg?: number | null;\n }>;\n}\n\n/** One school, with its contact block. `scores` needs `school_licensed`. */\nexport interface SchoolDetail extends SchoolSummary {\n address?: string | null;\n phone?: string | null;\n phone2?: string | null;\n fax?: string | null;\n website_url?: string | null;\n boundary_pdf_url?: string | null;\n principal?: string | null;\n feeder_schools?: Record<string, unknown> | null;\n extra?: Record<string, unknown> | null;\n scores?: SchoolScores[];\n // The licensed block — present only with the `school_licensed` scope.\n /** HouseSigma's own name for the school. */\n hs_name?: string | null;\n /** HouseSigma's own label for the kind of board — `Public` or `Catholic`. */\n hs_board_type?: string | null;\n hs_score_year?: number | null;\n hs_score_average?: number | null;\n hs_rank_year?: number | null;\n}\n\n/** A school's catchment outline. Licensed. */\nexport interface SchoolBoundary {\n uid: string;\n name: string;\n geometry?: { type: string; coordinates: unknown } | null;\n polygon_count: number;\n point_count: number;\n source?: string | null;\n source_url?: string | null;\n license?: string | null;\n}\n\n/** One catchment covering a queried point. Licensed. */\nexport interface CatchmentHit {\n uid: string;\n name: string;\n type?: string | null;\n /** The board the school belongs to. */\n board?: string | null;\n /** Which of the school's polygons this is — a catchment can be split. */\n polygon_index: number;\n distance_m?: number | null;\n}\n\n/** The school vocabulary and the headline counts.\n *\n * The whole vocabulary comes in one call.\n */\nexport interface SchoolTaxonomy {\n boards: SchoolBoard[];\n types: Array<{ id: string; name: string; count: number }>;\n /** The programmes, as `{ id: <code>, name: <label> }`. */\n program_categories: Array<{ id: string; name: string; count: number }>;\n /** The provinces, by code. The *names* come from the geography feed. */\n provinces: Array<{ id: string; name: string; count: number }>;\n /** The boards' own regions, each with its province. */\n regions: Array<{ id: string; name: string; province: string | null; count: number }>;\n /** The boards' own types — public, catholic, private. */\n board_types: Array<{ id: string; name: string; count: number }>;\n /** The headline counts, with the breakdowns by province, board type and\n * school type. */\n stats: Record<string, unknown>;\n}\n\nexport interface ClientOptions {\n /** `wq_live_…` key for metered endpoints (sent as `X-API-Key`). */\n apiKey?: string;\n /** Override the API base (default `https://api.whereq.cloud`). */\n baseUrl?: string;\n /** Custom fetch (e.g. for Node <18 or testing). Defaults to global `fetch`. */\n fetch?: typeof fetch;\n}\n\ntype Params = Record<string, unknown>;\n\n/** The API key from the environment, when there is one. */\nfunction envApiKey(): string {\n const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process;\n return proc?.env?.WHEREQ_API_KEY ?? \"\";\n}\n\nexport class Whereq {\n private readonly baseUrl: string;\n private readonly headers: Record<string, string>;\n private readonly _fetch: typeof fetch;\n\n constructor(opts: ClientOptions = {}) {\n this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.headers = { Accept: \"application/json\" };\n // The key may come from the options or the environment, in that order.\n const key = opts.apiKey ?? envApiKey();\n if (key) this.headers[\"X-API-Key\"] = key;\n const f = opts.fetch ?? globalThis.fetch;\n if (!f) throw new Error(\"No global fetch available — pass `fetch` in options (Node <18).\");\n this._fetch = f;\n }\n\n private url(path: string, params: Params): string {\n const qs = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined && v !== null) qs.set(k, String(v));\n }\n const s = qs.toString();\n return `${this.baseUrl}${path}${s ? `?${s}` : \"\"}`;\n }\n\n /** GET any endpoint; `undefined`/`null` params are dropped. Returns parsed JSON. */\n async get<T = unknown>(path: string, params: Params = {}): Promise<T> {\n const url = this.url(path, params);\n const res = await this._fetch(url, { headers: this.headers });\n if (!res.ok) {\n let msg = res.statusText;\n try {\n const j = (await res.json()) as { detail?: string };\n msg = j?.detail || JSON.stringify(j) || msg;\n } catch {\n /* non-JSON error body */\n }\n throw new WhereqError(res.status, msg, url);\n }\n return (await res.json()) as T;\n }\n\n /** GET a non-JSON endpoint (e.g. CSV export) as text. */\n async getText(path: string, params: Params = {}): Promise<string> {\n const url = this.url(path, params);\n const res = await this._fetch(url, { headers: this.headers });\n if (!res.ok) throw new WhereqError(res.status, res.statusText, url);\n return res.text();\n }\n\n // -- prices / cost of living ------------------------------------------------\n /** Cost-of-living price series (fuel | food | energy | housing | rent).\n * `region` takes a region slug or a comma-separated list (\"us,ca\");\n * `geo` is a free-text place name (\"Calgary, Alberta\"). */\n prices(p: { domain?: string; region?: string; geo?: string; bedrooms?: number; q?: string; limit?: number; offset?: number } = {}): Promise<PriceSeriesResponse> {\n return this.get<PriceSeriesResponse>(\"/v1/prices\", p);\n }\n price(seriesId: number) {\n return this.get(`/v1/prices/${seriesId}`);\n }\n pricesCsv(p: { domain?: string; region?: string; geo?: string; bedrooms?: number; q?: string } = {}) {\n return this.getText(\"/v1/prices/export\", p);\n }\n /** Compare cost of living across US states / CA provinces / metros.\n * `places`: comma-separated `region:name` or `m:<rent-series-id>`. */\n costOfLiving(places: string) {\n return this.get(\"/v1/cost-of-living\", { places });\n }\n\n // -- discovery / facets -----------------------------------------------------\n catalog() { return this.get(\"/v1/catalog\"); }\n categories() { return this.get(\"/v1/categories\"); }\n regions() { return this.get(\"/v1/regions\"); }\n domains() { return this.get(\"/v1/domains\"); }\n trending(p: Params = {}) { return this.get(\"/v1/trending\", p); }\n\n // -- finance ----------------------------------------------------------------\n hotstocks(limit = 20) { return this.get(\"/v1/hotstocks\", { limit }); }\n quotes(p: Params = {}) { return this.get(\"/v1/quotes\", p); }\n news(p: Params = {}) { return this.get(\"/v1/news\", p); }\n screener(p: Params = {}) { return this.get(\"/v1/screener\", p); }\n search(q: string, p: Params = {}) { return this.get(\"/v1/search\", { q, ...p }); }\n\n // -- autos ------------------------------------------------------------------\n autosRecalls(p: Params = {}) { return this.get(\"/v1/autos/recalls\", p); }\n autosListings(p: Params = {}) { return this.get(\"/v1/autos/listings\", p); }\n autosFuelEconomy(p: Params = {}) { return this.get(\"/v1/autos/fuel-economy\", p); }\n autosModels(p: Params = {}) { return this.get(\"/v1/autos/models\", p); }\n\n // -- lottery -----------------------------------------------------------------\n /** Recent lottery draws, newest first.\n *\n * Unentitled callers get the oldest 100 draws instead of the recent\n * ones — check `response.demo`.\n */\n lotteryDraws(p: { game?: string; days?: number; limit?: number } & Params = {}): Promise<any> {\n return this.get(\"/v1/lottery/draws\", p);\n }\n /** The most recent draw for a game. On the unentitled preview this is the\n * *oldest* draw — the recent one is the gated, valuable row. */\n lotteryLatestDraw(game: string): Promise<any> {\n return this.get(`/v1/lottery/draws/${encodeURIComponent(game)}/latest`);\n }\n /** Per-number frequency for a game over a window (30–1825 days). */\n lotteryFrequency(game: string, days = 365): Promise<any> {\n return this.get(`/v1/lottery/draws/${encodeURIComponent(game)}/frequency`, { days });\n }\n /** The lottery game registry: names, play rules and draw days. */\n lotteryGames(p: { country?: string; region?: string } & Params = {}): Promise<any> {\n return this.get(\"/v1/lottery/games\", p);\n }\n /** One game's full play rules and metadata. */\n lotteryGame(slug: string): Promise<any> {\n return this.get(`/v1/lottery/games/${encodeURIComponent(slug)}`);\n }\n\n // -- fuel (gas & diesel) ----------------------------------------------------\n /** Geolocated retail fuel stations with their latest prices.\n *\n * Coverage: Mexico (`MX`, CRE open data), the United States (`US`) and\n * Canada (`CA`). Prices are in **local currency per litre** — `MXN/L`,\n * `USD/L` and `CAD/L` respectively.\n *\n * Unentitled callers get a 100-row preview of the oldest rows and the\n * pagination arguments are ignored — check `response.demo`.\n */\n fuelStations(p: FuelStationsParams & Params = {}): Promise<FuelStationsResponse> {\n return this.get<FuelStationsResponse>(\"/v1/fuel/stations\", p);\n }\n\n /** One station: location, latest prices and its price-change timeline. */\n fuelStation(\n id: number | string,\n p: FuelStationParams & Params = {},\n ): Promise<FuelStationDetail> {\n return this.get<FuelStationDetail>(\n `/v1/fuel/stations/${encodeURIComponent(String(id))}`,\n p,\n );\n }\n\n /** Yield every matching station, paging through the API for you.\n *\n * Only meaningful with an entitled key. The unentitled preview always\n * returns the *same* oldest 100 rows and ignores the paging arguments,\n * so there is nothing more to fetch: this yields that first page and\n * stops rather than looping on it.\n */\n async *fuelStationsAll(\n p: FuelStationsParams & Params = {},\n ): AsyncGenerator<FuelStation> {\n const pageSize = Math.min(Math.max(Number(p.limit ?? 500), 1), 500);\n let offset = Number(p.offset ?? 0);\n for (;;) {\n const page = await this.fuelStations({ ...p, limit: pageSize, offset });\n const stations = page.stations ?? [];\n if (stations.length === 0) return;\n for (const s of stations) yield s;\n if (page.demo) return; // preview: every page is the same slice\n offset += stations.length;\n if (page.total != null && offset >= page.total) return;\n }\n }\n\n /** Aggregated fuel price series (state / national / metro).\n *\n * These are the *series* behind the charts — EIA weekly for the US,\n * StatCan monthly for Canada, CRE for Mexico — not the station-level\n * prices that `fuelStations()` returns.\n */\n fuelPrices(p: FuelPricesParams & Params = {}): Promise<PriceSeriesResponse> {\n return this.get<PriceSeriesResponse>(\"/v1/prices\", { domain: \"fuel\", ...p });\n }\n\n // -- geography (places, boundaries, hierarchy) ------------------------------\n /** The place list — provinces, regions, municipalities, cities, towns,\n * wards, neighbourhoods, countries.\n *\n * `country` takes an ISO code and either spelling works: `\"CA\"` and\n * `\"CAN\"` find the same places, in both vocabularies.\n */\n geoPlaces(p: GeoPlacesParams & Params = {}): Promise<GeoPlaceList> {\n return this.get<GeoPlaceList>(\"/v1/geo/places\", p);\n }\n\n /** One place, with its containers AND the places inside it.\n *\n * The parents are a list on purpose: a place belongs to several things\n * at once.\n */\n geoPlace(uid: string): Promise<GeoPlaceDetail> {\n return this.get<GeoPlaceDetail>(`/v1/geo/places/${encodeURIComponent(uid)}`);\n }\n\n /** A place's outline as GeoJSON.\n *\n * `simplify` is in METRES: the outline keeps every corner more than\n * that far from the original, and the result is still a valid polygon.\n */\n geoBoundary(uid: string, p: { simplify?: number } & Params = {}): Promise<GeoBoundary> {\n return this.get<GeoBoundary>(`/v1/geo/places/${encodeURIComponent(uid)}/boundary`, p);\n }\n\n /** Every place containing a point, broadest first.\n *\n * The answer to \"which district is this?\" without picking a winner: a\n * point downtown Toronto lands in a neighbourhood, a ward, a city, a\n * census division, a province and a country, and all of them are\n * returned.\n */\n geoAt(lon: number, lat: number): Promise<GeoAtResponse> {\n return this.get<GeoAtResponse>(\"/v1/geo/at\", { lon, lat });\n }\n\n /** The vocabulary: every concept, in both languages, with a live count of\n * how many places and outlines it has. */\n geoConcepts(): Promise<GeoConceptList> {\n return this.get<GeoConceptList>(\"/v1/geo/concepts\");\n }\n\n /** The places of different kinds that cover the same ground.\n *\n * `bbox` is required — \"minLon,minLat,maxLon,maxLat\". Comparing every\n * pair in the country is a quadratic join, and nobody asks that\n * question about all of Canada at once.\n */\n geoOverlaps(\n p: { bbox: string; min_ratio?: number; limit?: number } & Params,\n ): Promise<GeoOverlapList> {\n return this.get<GeoOverlapList>(\"/v1/geo/overlaps\", p);\n }\n\n // -- local (news, events, stories, places) --------------------------------\n /** The local feed — news, events, stories and notices. */\n localContent(\n p: {\n type?: string;\n category?: string;\n source?: string;\n city?: string;\n province?: string;\n bbox?: string;\n q?: string;\n since?: string;\n until?: string;\n has_location?: boolean;\n include_expired?: boolean;\n limit?: number;\n cursor?: string;\n } & Params = {},\n ): Promise<Page<LocalContent>> {\n return this.get<Page<LocalContent>>(\"/v1/local/content\", p);\n }\n\n /** One item, with its tags. */\n localContentItem(contentId: number): Promise<LocalContent> {\n return this.get<LocalContent>(`/v1/local/content/${contentId}`);\n }\n\n /** The points of interest — the OpenStreetMap sweep.\n *\n * `lat`, `lng` and `radius_km` go together: a proximity search needs\n * all three.\n */\n localPlaces(\n p: {\n category?: string;\n kind?: string;\n sub?: string;\n bbox?: string;\n lat?: number;\n lng?: number;\n radius_km?: number;\n q?: string;\n limit?: number;\n offset?: number;\n } & Params = {},\n ): Promise<Page<LocalPlace>> {\n return this.get<Page<LocalPlace>>(\"/v1/local/places\", p);\n }\n\n /** One place. */\n localPlace(placeId: number): Promise<LocalPlace> {\n return this.get<LocalPlace>(`/v1/local/places/${placeId}`);\n }\n\n /** The configured local feeds. */\n localSources(\n p: { enabled?: boolean; kind?: string; limit?: number } & Params = {},\n ): Promise<Page<LocalSource>> {\n return this.get<Page<LocalSource>>(\"/v1/local/sources\", p);\n }\n\n /** The local vocabulary — types, categories, place categories, sources. */\n localTaxonomy(): Promise<{\n types: Array<{ id: string; name: string; count: number }>;\n categories: Array<{ id: string; name: string; count: number }>;\n place_categories: Array<{ id: string; name: string; count: number }>;\n sources: Array<{ slug: string; name: string; count: number }>;\n }> {\n return this.get(\"/v1/local/taxonomy\");\n }\n\n // -- schools ----------------------------------------------------------------\n /** The school directory.\n *\n * `sort` is a whitelist — `name`, `hs_score`, `hs_rank`, `grade_range`,\n * `type`, `city` — and anything else is a 422. `rank` orders name\n * matches by relevance: exact, then prefix, then a word that starts\n * with the query, then any substring.\n *\n * The limit goes to **5 000**: the map needs a whole viewport in one\n * call, and the whole directory is 2 528 schools.\n */\n schools(\n p: {\n q?: string;\n board?: string;\n /** The board's own type — public, catholic or private. */\n board_type?: string;\n /** The board's region, matched loosely. */\n region?: string;\n city?: string;\n province?: string;\n type?: string;\n /** A programme code, e.g. `french_immersion`. */\n program?: string;\n bbox?: string;\n lat?: number;\n lng?: number;\n radius_km?: number;\n has_boundary?: boolean;\n sort?: string;\n order?: \"asc\" | \"desc\";\n rank?: boolean;\n limit?: number;\n offset?: number;\n } & Params = {},\n ): Promise<Page<SchoolSummary>> {\n return this.get<Page<SchoolSummary>>(\"/v1/schools\", p);\n }\n\n /** The board registry — the vocabulary the `board` filter uses. */\n schoolBoards(): Promise<Page<SchoolBoard>> {\n return this.get<Page<SchoolBoard>>(\"/v1/schools/boards\");\n }\n\n /** The school vocabulary and the headline counts. */\n schoolTaxonomy(): Promise<SchoolTaxonomy> {\n return this.get<SchoolTaxonomy>(\"/v1/schools/taxonomy\");\n }\n\n /** The catchments that cover a point.\n *\n * **Licensed.** This reads the catchment polygons, so it needs the\n * `school_licensed` scope — a key without it gets a 403.\n */\n schoolsAt(\n p: { lat: number; lng: number; limit?: number } & Params,\n ): Promise<Page<CatchmentHit>> {\n return this.get<Page<CatchmentHit>>(\"/v1/schools/at\", p);\n }\n\n /** One school.\n *\n * The uid is board-qualified — `ycdsb/0158`, or\n * `ycdsb/st-theresa-of-lisieux-chs` when the board publishes no code.\n * It carries a slash, and the API's route is built for that.\n *\n * The scores come back only with the `school_licensed` scope.\n */\n school(uid: string): Promise<SchoolDetail> {\n return this.get<SchoolDetail>(`/v1/schools/${uid}`);\n }\n\n /** A school's catchment outline, as GeoJSON. **Licensed.**\n * `simplify` is in METRES. */\n schoolBoundary(\n uid: string,\n p: { simplify?: number } & Params = {},\n ): Promise<SchoolBoundary> {\n return this.get<SchoolBoundary>(`/v1/schools/${uid}/boundary`, p);\n }\n\n /** One year's assessment snapshot, with the EQAO marks. **Licensed.**\n * `year` picks a year; the latest is the default. */\n schoolScores(\n uid: string,\n p: { year?: number } & Params = {},\n ): Promise<SchoolScores> {\n return this.get<SchoolScores>(`/v1/schools/${uid}/scores`, p);\n }\n}\n\nexport default Whereq;\n"]}