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

savvi

v0.3.2

Published

Node.js SDK for Savvi's API

Downloads

1

Readme

savvi.js

Savvi Node.js SDK (Proof-of-Concept)

CLI

Install

npm install --location=global 'ssh://[email protected]/savvi-legal/savvi.js'

Usage

savvi [flags]

| flag | description | | ------------- | ---------------------------------------------------------------- | | --ask | alias for --env, --user, and --org | | --env | ask for and set the current environment url (staging, prod, etc) | | --user | ask for and set the current user email | | --password | forces password auth (rather than secure second-factor) | | --logout | forces re-authentication | | --org | ask for and set the current org | | --impersonate | ask for user and org to impersonate |

You'll get a login link that looks like this:

https://dev.savvilegal.dev/c/12345/#/?access_token=<ACCESS_TOKEN>&id_token=<ID_TOKEN>

SDK

Install

npm install --save 'github:savvi-legal/savvi.js#v1'
<script src="./dist/savvi.js"></script>

<!-- TODO -->
<script src="https://unpkg.com/savvi"></script>

Usage

Node.js

"use strict";

let Savvi = require("savvi");

async function main() {
  await Savvi.init({ env: "sandbox" });
  await Savvi.login({ email: "[email protected]" });
}

main().catch(console.error);

WebPack

You can build the main library like this:

# build savvi.js
npx webpack-cli build -c ./webpack.config.js

You can build the ./example/app.js (TODO) like so:

# build example app.js
npx webpack-cli build -c ./webpack.config.example-app.js
npm run genenv
rsync -avhP ./example/app.js public/app.js

And serve it up like so:

npm run start

Then open the example app or tests:

  • https://localhost:3000/
  • https://localhost:3000/tests/

Documentation

npm run jsdoc

The generated documentation will be in the docs/ folder.

API (proof-of-concept)

// Login with credentials, or initialize with id_token
Savvi.init({
    // 'http://localhost:3000/api'
    env = 'https://dev.savvilegal.dev/api'
});

Savvi.login({ email, password, id_token });

// Auto-prefixed for the environment. Ex: `https://dev.savvy.legal/api${url}`
Savvi.request({ url: '/user/accounts' })

// Inspect / Debug current id_token
Savvi.Auth.inspect();

// Inspect / Debug current access_token
Savvi.Orgs.inspect();

// Get list of accounts
Savvi.Orgs.list(query);

// Invite new user to account
Savvi.Orgs.invite(account_id, { email });

// Act on behalf of the given organization
Savvi.Orgs.createSession(account_id, { email });

// Manage Workflow Library and Instances
Savvi#Org.Library.list();

Savvi#Org.Partners.add({ code });
Savvi#Org.Partners.list();
Savvi#Org.Partners.remove({ id });

Savvi#Org.Todos.list();
Savvi#Org.Todos.remove({ id });

Savvi#Org.Workflows.open({ template_id });
Savvi#Org.Workflows.list();
Savvi#Org.Workflows.close({ project_id });

Savvi.Public.Partners.get({ code });

// 3rd party tools for testing
Savvi.Box.upsert(token, stream, filename = Path.basename(stream.path));

Testing

Tests can be run in node.js or the browser. Either way, you'll want to set some ENVs:

.env:

[email protected]
TEST_PASSWORD=test-password-1234
TEST_ORG=1411011163

Node.js

node tests/some-test-name.js

Browser (Vanilla)

  1. Build the relevant test and env files
    npm run webpack
    npm run genenv
    rsync -avhP ./tests/ ./public/tests/
  2. Edit the test runner to include / exclude the tests you want to run.
    vim ./public/tests/index.html
    -    <script src="./tests/some-test-1.js"></script>
    +    <script src="./tests/better-test-2.js"></script>
  3. Run the localhost server
    npm run start
    open https://localhost:3000/tests/