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

@sonoransoftware/sonoran.js

v1.0.29

Published

Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.

Downloads

251

Readme

Sonoran.js

Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.

Example Instance Setup

Utilizing both Sonoran CMS & Sonoran CAD

const Sonoran = require('sonoran.js');
const instance = Sonoran.instance({
  cadCommunityId: 'mycommunity',
  cadApiKey: 'DF58F1E-FD8A-44C5-BA',
  cmsCommunityId: 'mycommunity',
  cmsApiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf'
});

Utilizing just Sonoran CMS or Sonoran CAD

const Sonoran = require('sonoran.js');
const instance = Sonoran.instance({
  communityId: 'mycommunity',
  apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
  product: Sonoran.productEnums.CMS
});

Example Method Usage

const Sonoran = require('sonoran.js');
const instance = Sonoran.instance({
  communityId: 'mycommunity',
  apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
  product: Sonoran.productEnums.CMS,
  serverId: 2 // Optional - The default server id for both CAD & CMS is 1
});

// This will verify the whitelist of the given API ID or account ID for server id 2 as specified above
instance.cms.verifyWhitelist('459798465498798432');
// OR
// This will verify the whitelist of the given API ID for server id 1 since I specified that
instance.cms.verifyWhitelist({
  apiId: '459798465498798432',
  serverId: 1
});
// OR
// This will verify the whitelist of the given account ID for server id 1 since I specified that
instance.cms.verifyWhitelist({
  accId: 'd5663516-ee35-11e9-9714-5600023b2434',
  serverId: 1
});

CAD Functions

getAccount

Returns the user's account object.

Argument params

Type: object {apiId?, username?}
const params = {
 apiId: '',
 username: 'SomeUser',
};
// Get user account object
const account = await instance.cad.getAccount(params);

CMS Functions

verifyWhitelist(obj)

Verifies that a user is whitelisted in the specified server.

Arugment params

Type object {accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: number, serverId?: number}
Type string (Account UUID or API ID as a string)

Note: If passing a string for data (Account UUID or API ID) the serverId will default to 1

const params = {
 accId: '',
 apiId: '',
 username: '',
 discord: '',
 uniqueId: 1234,
 serverId: 1
};
// Check if user with Unique ID 1234 is whitelisted on Server ID 1
const isWhitelisted = await instance.cms.verifyWhitelist(params);

getFullWhitelist()

Returns a full list of whitelisted users in the specified server.

Arugment serverId

Type number 1
// Get the full whitelist for server ID 1
const fullWhitelist = await instance.cms.getFullWhitelist(1);

getComAccount(obj)

Returns the user's account object

Arugment params

Type object {accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: string}
const params = {
 accId: '',
 apiId: '',
 username: '',
 discord: '',
 uniqueId: '1234',
};
// Get a user's account as an object
const getAccount = await instance.cms.getComAccount(params);

getAccountRanks(obj)

Returns a user account's ranks

Arugment params

Type object {accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: string}
const params = {
 accId: '',
 apiId: '',
 username: '',
 discord: '',
 uniqueId: '1234',
};
// Get a user's ranks
const getRanks = await instance.cms.getAccountRanks(params);

clockInOut(obj)

Clock a user in or out in the CMS system

Arugment obj

Type object {accId?: string, apiId?: string, forceClockIn?: boolean, discord?: string, uniqueId?: string}
const params = {
 accId: '',
 apiId: '',
 forceClockIn: true,
 discord: '',
 uniqueId: '1234',
};
// Clocks a user in or out
const clock = await instance.cms.clockInOut(params);

checkComApiId(apiId)

Checks if a given API ID is attatched to any account within the community, and if true, returns the username of the associated account.

Arugment apiId

Type string 1234
// Checks if API ID is attatched to a user, returns username if true
const apiIdUsername = await instance.cms.checkComApiId('1234');

getDepartments()

Gets all department information for a CMS community

// Gets department information for community
const getDepts = await instance.cms.getDepartments();

setAccountRanks(obj, apiId, accId, username, discord, uniqueId)

Gets all department information for a CMS community

Arugment params

Type object {set?: string[]; add?: string[]; remove?: string[]}

Arguments apiId, accId, username, discord, uniqueId

Type string or undefined

Note: Only one identifier is required (Discord, accID, etc.) pass in undefined for variables you are not searching by

const params = {
 set: ['9ad00ded-93d1-422e-8470-d2515f02652c'],
 add: undefined,
 remove: undefined
};
// Wipe users existing ranks, and set ones provided
// Add and Remove are undefined as we don't want to call them here
// Sets account ranks by the discord ID parameter
const setRanks = await instance.cms.setAccountRanks(params, undefined, undefined, undefined, '12345678', undefined);

Further Documentation

More documentation for Sonoran CAD specific methods and usage can be found here, Sonoran CMS specific methods and usage can be found here, and usage information for the REST class here.