fitzroy 1.6.0 → 1.6.2

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/cli.js CHANGED
@@ -1045,7 +1045,7 @@ var init_footywire = __esm({
1045
1045
  FootyWireClient = class {
1046
1046
  fetchFn;
1047
1047
  constructor(options) {
1048
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
1048
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
1049
1049
  }
1050
1050
  /**
1051
1051
  * Fetch the HTML content of any URL using this client's fetch function.
@@ -1361,7 +1361,7 @@ var init_afl_coaches = __esm({
1361
1361
  AflCoachesClient = class {
1362
1362
  fetchFn;
1363
1363
  constructor(options) {
1364
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
1364
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
1365
1365
  }
1366
1366
  /**
1367
1367
  * Fetch the HTML content of an AFLCA page.
@@ -1827,7 +1827,7 @@ var init_validation = __esm({
1827
1827
  });
1828
1828
 
1829
1829
  // src/sources/afl-api.ts
1830
- var TOKEN_URL, API_BASE, CFS_BASE, AflApiClient;
1830
+ var USER_AGENT, TOKEN_URL, API_BASE, CFS_BASE, AflApiClient;
1831
1831
  var init_afl_api = __esm({
1832
1832
  "src/sources/afl-api.ts"() {
1833
1833
  "use strict";
@@ -1835,6 +1835,7 @@ var init_afl_api = __esm({
1835
1835
  init_errors();
1836
1836
  init_result();
1837
1837
  init_validation();
1838
+ USER_AGENT = "fitzroy/2 (https://github.com/jackemcpherson/fitzRoy-ts)";
1838
1839
  TOKEN_URL = "https://api.afl.com.au/cfs/afl/WMCTok";
1839
1840
  API_BASE = "https://aflapi.afl.com.au/afl/v2";
1840
1841
  CFS_BASE = "https://api.afl.com.au/cfs/afl";
@@ -1844,7 +1845,14 @@ var init_afl_api = __esm({
1844
1845
  cachedToken = null;
1845
1846
  pendingAuth = null;
1846
1847
  constructor(options) {
1847
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
1848
+ const baseFetch = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
1849
+ this.fetchFn = (input, init) => {
1850
+ const headers = new Headers(init?.headers);
1851
+ if (!headers.has("User-Agent")) {
1852
+ headers.set("User-Agent", USER_AGENT);
1853
+ }
1854
+ return baseFetch(input, { ...init, headers });
1855
+ };
1848
1856
  this.tokenUrl = options?.tokenUrl ?? TOKEN_URL;
1849
1857
  }
1850
1858
  /**
@@ -2261,7 +2269,7 @@ var init_squiggle_validation = __esm({
2261
2269
  });
2262
2270
 
2263
2271
  // src/sources/squiggle.ts
2264
- var SQUIGGLE_BASE, USER_AGENT, SquiggleClient;
2272
+ var SQUIGGLE_BASE, USER_AGENT2, SquiggleClient;
2265
2273
  var init_squiggle = __esm({
2266
2274
  "src/sources/squiggle.ts"() {
2267
2275
  "use strict";
@@ -2269,11 +2277,11 @@ var init_squiggle = __esm({
2269
2277
  init_result();
2270
2278
  init_squiggle_validation();
2271
2279
  SQUIGGLE_BASE = "https://api.squiggle.com.au/";
2272
- USER_AGENT = "fitzRoy-ts/1.0 (https://github.com/jackemcpherson/fitzRoy-ts)";
2280
+ USER_AGENT2 = "fitzRoy-ts/1.0 (https://github.com/jackemcpherson/fitzRoy-ts)";
2273
2281
  SquiggleClient = class {
2274
2282
  fetchFn;
2275
2283
  constructor(options) {
2276
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
2284
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
2277
2285
  }
2278
2286
  /**
2279
2287
  * Fetch JSON from the Squiggle API.
@@ -2282,7 +2290,7 @@ var init_squiggle = __esm({
2282
2290
  const url = `${SQUIGGLE_BASE}?${params.toString()}`;
2283
2291
  try {
2284
2292
  const response = await this.fetchFn(url, {
2285
- headers: { "User-Agent": USER_AGENT }
2293
+ headers: { "User-Agent": USER_AGENT2 }
2286
2294
  });
2287
2295
  if (!response.ok) {
2288
2296
  return err(
@@ -2894,7 +2902,7 @@ var init_afl_tables = __esm({
2894
2902
  AflTablesClient = class {
2895
2903
  fetchFn;
2896
2904
  constructor(options) {
2897
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
2905
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
2898
2906
  }
2899
2907
  /**
2900
2908
  * Fetch season match results from AFL Tables.
@@ -5392,7 +5400,7 @@ resolveAliases();
5392
5400
  var main = defineCommand11({
5393
5401
  meta: {
5394
5402
  name: "fitzroy",
5395
- version: "1.6.0",
5403
+ version: "1.6.2",
5396
5404
  description: "TypeScript port of the fitzRoy R package \u2014 fetch AFL data from the command line"
5397
5405
  },
5398
5406
  subCommands: {
package/dist/index.js CHANGED
@@ -684,7 +684,7 @@ var FOOTYWIRE_BASE = "https://www.footywire.com/afl/footy";
684
684
  var FootyWireClient = class {
685
685
  fetchFn;
686
686
  constructor(options) {
687
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
687
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
688
688
  }
689
689
  /**
690
690
  * Fetch the HTML content of any URL using this client's fetch function.
@@ -1376,7 +1376,7 @@ import * as cheerio4 from "cheerio";
1376
1376
  var AflCoachesClient = class {
1377
1377
  fetchFn;
1378
1378
  constructor(options) {
1379
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
1379
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
1380
1380
  }
1381
1381
  /**
1382
1382
  * Fetch the HTML content of an AFLCA page.
@@ -1872,6 +1872,7 @@ var LadderResponseSchema = z.object({
1872
1872
  }).passthrough();
1873
1873
 
1874
1874
  // src/sources/afl-api.ts
1875
+ var USER_AGENT = "fitzroy/2 (https://github.com/jackemcpherson/fitzRoy-ts)";
1875
1876
  var TOKEN_URL = "https://api.afl.com.au/cfs/afl/WMCTok";
1876
1877
  var API_BASE = "https://aflapi.afl.com.au/afl/v2";
1877
1878
  var CFS_BASE = "https://api.afl.com.au/cfs/afl";
@@ -1881,7 +1882,14 @@ var AflApiClient = class {
1881
1882
  cachedToken = null;
1882
1883
  pendingAuth = null;
1883
1884
  constructor(options) {
1884
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
1885
+ const baseFetch = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
1886
+ this.fetchFn = (input, init) => {
1887
+ const headers = new Headers(init?.headers);
1888
+ if (!headers.has("User-Agent")) {
1889
+ headers.set("User-Agent", USER_AGENT);
1890
+ }
1891
+ return baseFetch(input, { ...init, headers });
1892
+ };
1885
1893
  this.tokenUrl = options?.tokenUrl ?? TOKEN_URL;
1886
1894
  }
1887
1895
  /**
@@ -2291,11 +2299,11 @@ var SquiggleStandingsResponseSchema = z2.object({
2291
2299
 
2292
2300
  // src/sources/squiggle.ts
2293
2301
  var SQUIGGLE_BASE = "https://api.squiggle.com.au/";
2294
- var USER_AGENT = "fitzRoy-ts/1.0 (https://github.com/jackemcpherson/fitzRoy-ts)";
2302
+ var USER_AGENT2 = "fitzRoy-ts/1.0 (https://github.com/jackemcpherson/fitzRoy-ts)";
2295
2303
  var SquiggleClient = class {
2296
2304
  fetchFn;
2297
2305
  constructor(options) {
2298
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
2306
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
2299
2307
  }
2300
2308
  /**
2301
2309
  * Fetch JSON from the Squiggle API.
@@ -2304,7 +2312,7 @@ var SquiggleClient = class {
2304
2312
  const url = `${SQUIGGLE_BASE}?${params.toString()}`;
2305
2313
  try {
2306
2314
  const response = await this.fetchFn(url, {
2307
- headers: { "User-Agent": USER_AGENT }
2315
+ headers: { "User-Agent": USER_AGENT2 }
2308
2316
  });
2309
2317
  if (!response.ok) {
2310
2318
  return err(
@@ -2646,7 +2654,7 @@ var AFL_TABLES_BASE = "https://afltables.com/afl/seas";
2646
2654
  var AflTablesClient = class {
2647
2655
  fetchFn;
2648
2656
  constructor(options) {
2649
- this.fetchFn = options?.fetchFn ?? globalThis.fetch;
2657
+ this.fetchFn = options?.fetchFn ?? globalThis.fetch.bind(globalThis);
2650
2658
  }
2651
2659
  /**
2652
2660
  * Fetch season match results from AFL Tables.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fitzroy",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "TypeScript port of the fitzRoy R package — programmatic access to AFL data including match results, player stats, fixtures, ladders, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",