Skip to content

Commit

Permalink
fix(sanity): changes the apioptions to include name and names
Browse files Browse the repository at this point in the history
this update also includes changes to the default options for the getPlayers method to ensure that a
request using name or names will result in the field names will be set
  • Loading branch information
KenEucker committed Jan 24, 2024
1 parent 2ee0105 commit bbd3442
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "biketag",
"version": "3.3.2",
"version": "3.3.3",
"description": "The Javascript client API for BikeTag Games",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -39,7 +39,7 @@
"homepage": "https://keneucker.github.io/biketag-api/",
"scripts": {
"dev": "npm run dev:node",
"dev:build": "npm run build && npm run compile && npm run dev",
"dev:build": "npm run build && npm run dev",
"dev:node": "node examples/node/index.js",
"dev:testnode": "node examples/node/test.js",
"dev:upnode": "node examples/node/update.js",
Expand Down
7 changes: 7 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ export class BikeTagClient extends EventEmitter {
case DataTypes.player:
options.game = options.game ? options.game : this.biketagConfig?.game

if (method === 'getPlayers') {
options.names =
options.names ?? options.name ? [options.name] : undefined
}

options.game = options.game ? options.game : this.biketagConfig?.game

if (method === 'updatePlayer' || method === 'updatePlayers') {
delete options.game
}
Expand Down
6 changes: 4 additions & 2 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ export type ApiOptions = RequireAtLeastOne<{
host?: string
queuehash?: string
archivehash?: string
slugs?: string[]
fields?: string[]
slug?: string
tagnumbers?: number[]
slugs?: string[]
tagnumber?: number
tagnumbers?: number[]
name?: string
names?: string[]
account?: string
concise?: boolean
cached?: boolean
Expand Down
1 change: 1 addition & 0 deletions src/sanity/getPlayers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export async function getPlayers(
DataTypes[DataTypes.player],
/// NOT PASSING IN THE GAME because we are not yet assigning players to games
undefined, // payload.game,
/// We only support querying by a single name??
payload.names?.length === 1 ? payload.names[0] : undefined,
payload.slugs,
undefined,
Expand Down

0 comments on commit bbd3442

Please sign in to comment.