npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vex-tm-client

v1.4.1

Published

Programmatic Control of VEX Tournament Manager

Downloads

20

Readme

Tournament Manager API

This package is a client library for the Tournament Manager API

  • Automatically manages authorization process, and ensures a valid bearer token is present for every request

  • Supports the full API surface

  • Strongly typed

  • Does not throw exceptions, which is very useful for preventing crashes in applications.

  • Easy to use

Developing An Integration

Developers need to obtain credentials from DWAB to create integrations.

Example Usage

See examples/basic.ts for an example of basic functionality.

import { Client, FieldsetQueueSkillsType, MatchRound } from "vex-tm-client";
import authorization from "./credentials.json";

const client = new Client({
  address: "http://localhost",
  authorization: {
    client_id: authorization.client_id,
    client_secret: authorization.client_secret,
    grant_type: "client_credentials",
    expiration_date: authorization.expiration_date,
  },
});

const result = await client.connect();
if (!result.success) {
  console.error("Could not connect to TM instance", result);
  return;
}

const divisions = await client.getDivisions();
if (!divisions.success) {
  console.error("divisions", divisions);
  return;
}

console.log(divisions);

const division = divisions.data[0];

const teams = await division.getTeams();
if (!teams.success) {
  console.error("teams", teams);
  return;
}

console.log(teams);

const matches = await division.getMatches();
if (!matches.success) {
  console.error("matches", matches);
  return;
}

for (const match of matches.data) {
  console.log(match);
}

const rankings = await division.getRankings(MatchRound.Qualification);
if (!rankings.success) {
  console.error("rankings", rankings);
  return;
}

console.log(rankings);

const fieldsets = await client.getFieldsets();
if (!fieldsets.success) {
  console.error("fieldsets", fieldsets);
  return;
}

console.log(fieldsets);

const fieldset = fieldsets.data[0];
const fields = await fieldset.getFields();
if (!fields.success) {
  console.error("fields", fields);
  return;
}

console.log(fields.data);

const connection = await fieldset.connect();
if (!connection.success) {
  console.error("connection", connection);
  return;
}

fieldset.addEventListener("matchStarted", (event) => console.log(event.detail));
fieldset.addEventListener("matchStopped", (event) => console.log(event.detail));
fieldset.addEventListener("fieldActivated", (event) =>
  console.log(event.detail)
);
fieldset.addEventListener("fieldMatchAssigned", (event) =>
  console.log(event.detail)
);
fieldset.addEventListener("audienceDisplayChanged", (event) =>
  console.log(event.detail)
);

await fieldset.queueSkills(FieldsetQueueSkillsType.Driver);
await fieldset.startMatch(1);

fieldset.on("matchStopped", async (event) => {
  await fieldset.setAudienceDisplay(FieldsetAudienceDisplay.SkillsRankings);
});

process.on("exit", () => {
  fieldset.disconnect();
});

Use In the Browser

This library is primarily designed for use in Node.js, however, it is possible to run in the browser if you polyfill the following Node libraries using their bundler of choice:

events
crypto

Polyfill Tools:

  • Vite: https://www.npmjs.com/package/vite-plugin-node-polyfills

Disclaimer

This library is not developed or supported by DWAB, the REC Foundation, or VEX Robotics. Developers are responsible for adhering to the Tournament Manager API Usage Agreement when developing integrations using this library.