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

coam-client

v0.6.2

Published

A thin client for COAM service

Downloads

1,611

Readme

COAM thin client

A thin client to perform certain requests in COAM. This is not an exhaustive implementation of COAM API.

If you like to add a method (or tweak something), please open a pull-request. We love pull-requests! But we also love solving issues, so in case you don't really have the time for a pull-request right now, maybe you can just tell us what you'd like?

Or maybe you just feel like writing us a mail? Yes, you guessed right, we also love reading mails ;)

CoamClient class

A simple client to make API calls to COAM. It has a few additional features that can be controlled by the options parameter passed in the constructor.

const client = new CoamClient(options);
Accepted options are:
  • accessToken (required) - The access token to use to authenticate the API calls
  • baseUrl - Base COAM API URL. Defaults to https://api.cimpress.io
  • retryAttempts - How many tries to retry the requests in case of failure*. Defaults to 2.
  • retryDelayInMs - How many milliseconds to wait between retires. Defaults to 200.
  • retryOnForbidden - A flag specifying if a retry has to be performed in case of 'Forbidden' response. Defaults to 'true'
  • debugFunction - A function to call to provide debug information. Defaults to none.
  • errorFunction - A function to call on error. Defaults to console.err;
  • timeout - A value setting the timeout of the underlying HTTP calls to COAM. Defaults to 8000 (8 seconds). Set it to 0 for no timeout.
  • skipCache - A flag specifying if cache should be skipped. Defaults to 'false'
Provided methods
  • buildGroupUrlFromId(groupId)
  • hasPermission(principal, resourceType, resourceIdentifier, permission)
  • grantRoleToPrincipal(groupUrl, principal, roleName)
  • getGroupInfo(groupUrl)
  • setAdminFlag(groupId, principal, isAdmin)
  • removeUserRole(groupId, principal, role)
  • addUserRole(groupId, principal, role)
  • modifyUserRoles(groupId, principal, rolesChanges)
  • addGroupMember(groupId, principal, isAdmin)
  • removeGroupMember(groupId, principal)
  • getRoles()
  • findPrincipals(query)
  • createGroup(name, description)
  • getPrincipal(accessToken, principal)
  • removeGroup(groupId)
  • findGroups(resourceType, resourceIdentifier, accountId, forAccountId, relationAccountId, isEssentialGroup, offset, limit, q)
  • removeResourceFromGroup(groupId, resourceType, resourceId)
  • addResourceToGroup(groupId, resourceType, resourceId)
  • getUserPermissionsForResourceType(principal, resourceType, include, permissionFilters)
  • getUserPermissionsForResourceTypes(principal, resourceTypes, include, permissionFilters)
  • getUsersWithPermission(resourceType, resourceIdentifier, permission)
  • getUsersWithResource(resourceType, permissionFilters)
  • createGroupWithUser(principalToCreateGroup, principalToAddToGroup, groupName, groupDescription, rolesToAdd, resourcesToAdd)
  • group56(principal)

Direct helper functions

In some cases, it is easier to simply call a function to perform the required action without the need for creating a specific client. The following helper methods satisfy these needs by creating a default client and performing the necessary requests.

Here is a list of helpers (name + required parameters):

  • buildGroupUrlFromId(groupId)
  • hasPermission(accessToken, principal, resourceType, resourceIdentifier, permission)
  • grantRoleToPrincipal (accessToken, groupUrl, principal, roleName)
  • getGroupInfo (accessToken, groupUrl)
  • setAdminFlag (accessToken, groupId, principal, isAdmin)
  • removeUserRole (accessToken, groupId, principal, role)
  • addUserRole (accessToken, groupId, principal, role)
  • modifyUserRoles (accessToken, groupId, principal, rolesChanges)
  • addGroupMember (accessToken, groupId, principal, isAdmin)
  • removeGroupMember (accessToken, groupId, principal)
  • getRoles (accessToken)
  • findPrincipals (accessToken, query)
  • getPrincipal (accessToken, principal)
  • createGroup (accessToken, name, description)
  • removeGroup (accessToken, groupId)
  • findGroups (accessToken, resourceType, resourceIdentifier, accountId, forAccountId, relationAccountId, isEssentialGroup, offset, limit, q)
  • removeResourceFromGroup (accessToken, groupId, resourceType, resourceId)
  • addResourceToGroup (accessToken, groupId, resourceType, resourceId)
  • getUserPermissionsForResourceType (accessToken, principal, resourceType, include, permissionFilters)
  • getUserPermissionsForResourceTypes (accessToken, principal, resourceTypes, include, permissionFilters)
  • getUsersWithPermission (accessToken, resourceType, resourceIdentifier, permission)
  • getUsersWithResource (accessToken, resourceType, permissionFilters)
  • createGroupWithUser (accessToken, principalToCreateGroup, principalToAddToGroup, groupName, groupDescription, rolesToAdd, resourcesToAdd)
  • group56 (accessToken, principal)

Important: All helper methods are using the CoamClient class with default settings (see above).