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

@robinthomas/sxt-sdk

v0.5.4

Published

NodeJS SDK for SxT

Downloads

5

Readme

SxT NodeJS SDK

Installation

$ npm install @robinthomas/sxt-sdk

Features

  • Tiny 4KB bundled library
  • Zero dependencies
  • Session management
    • Uses refresh tokens to generate new access tokens
  • SQL support for:

Pre-Requisites

  1. Create an empty .env file
  • Add SXT_HOST (refer to SxT welcome email)
  1. Complete the steps mentioned at https://docs.spaceandtime.io/docs/space-and-time-cli
  • At the end of which, you shall have:
    • SXT_USER_ID
    • SXT_PRIVATE_KEY
    • SXT_PUBLIC_KEY
  • Add those to the .env file.
  1. Complete the steps mentioned at https://docs.spaceandtime.io/docs/space-and-time-cli-biscuit
  • At the end of which, you shall have:
    • SXT_BISCUIT_PUBLIC_KEY
    • SXT_BISCUIT_PRIVATE_KEY
  • Add those to the .env file
  1. Create a biscuit with the following code:
$ sxtcli biscuit generate table --privateKey="<SXT_BISCUIT_PRIVATE_KEY>" --resources="<resourceId>" --operations="CREATE,ALTER,DROP,INSERT,UPDATE,MERGE,DELETE,SELECT"

resourceId is SCHEMA.TABLE.

Add the response of the above operation as SXT_BISCUIT to the .env file

Operations

DDL

Example below shows how to create a new table.

import { DdlSDK } from '@robinthomas/sxt-sdk';
import { config as dotenvConfig } from 'dotenv';

dotenvConfig();

const sdk = new DdlSDK({ host: process.env.SXT_HOST });

const data = await sdk.query(
  `CREATE TABLE ${SCHEMA}.${TABLE} (
    id VARCHAR PRIMARY KEY,
    name VARCHAR NOT NULL,
    detail VARCHAR NOT NULL
  ) WITH \"public_key=${process.env.SXT_BISCUIT_PUBLIC_KEY},access_type=public_write\"`,
  {
    biscuit: process.env.SXT_BISCUIT,
    userId: process.env.SXT_USER_ID,
    privateKey: process.env.SXT_PRIVATE_KEY,
    publicKey: process.env.SXT_PUBLIC_KEY,
  }
);

DML

Example below shows how to insert data into a table.

import { DmlSDK } from '@robinthomas/sxt-sdk';
import { config as dotenvConfig } from 'dotenv';

dotenvConfig();

const sdk = new DmlSDK({ host: process.env.SXT_HOST });

(async () => {
  const data = await sdk.query(
    `INSERT INTO ${SCHEMA}.${TABLE} (id, name, detail)
      VALUES('${id}', '${name}', '${detail}')`,
    {
      resourceId: `${SCHEMA}.${TABLE}`,
      biscuit: process.env.SXT_BISCUIT,
      userId: process.env.SXT_USER_ID,
      privateKey: process.env.SXT_PRIVATE_KEY,
      publicKey: process.env.SXT_PUBLIC_KEY,
    }
  );

  console.log(data);
})();

DQL

Example below shows how to read data from the table.

import { DqlSDK } from '@robinthomas/sxt-sdk';
import { config as dotenvConfig } from 'dotenv';

dotenvConfig();

const sdk = new DqlSDK({ host: process.env.SXT_HOST });

(async () => {
  const data = await sdk.query(
    `SELECT * FROM ${SCHEMA}.${TABLE}`,
    {
      resourceId: `${SCHEMA}.${TABLE}`,
      biscuit: process.env.SXT_BISCUIT,
      userId: process.env.SXT_USER_ID,
      privateKey: process.env.SXT_PRIVATE_KEY,
      publicKey: process.env.SXT_PUBLIC_KEY,
    }
  );

  console.log(data);
})();