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

@smartsheet-bridge/bridge-sdk

v1.0.0-beta.7

Published

A JavaScript/TypeScript library for the Bridge by Smartsheet API.

Downloads

386

Readme

@smartsheet-bridge/bridge-sdk

A JavaScript/TypeScript library for the Bridge by Smartsheet API.

This is early stage development and not ready for production consumers.


Quick Start

yarn add @smartsheet-bridge/bridge-sdk

or

npm install @smartsheet-bridge/bridge-sdk

HTTP Client

The Bridge by Smartsheet API can be accessed through a REST HTTP via the HTTPClient in the the SDK.

import { createHTTPClient } from '@smartsheet-bridge/bridge-sdk';

const bridge = createHTTPClient({
  baseURL: 'https://example.bridge.smartsheet.com',
  token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
});

const { data } = bridge.platform();

gRPC Client

For some functionality, particularly to do with extensions, Bridge by Smartsheet offers gRPC end communication that can be accessed through the gRPC Client. There is no overlap between the HTTP API and the gRPC API.

import { createGRPCClient } from '@smartsheet-bridge/bridge-sdk';

Usage

To access the REST API you must supply the HTTP client with your baseURL and API token.

createHTTPClient

import {
  createHTTPClient,
  parseAccountURL,
} from '@smartsheet-bridge/bridge-sdk';

// copied from the URL in your browser.
const accountURL = 'https://example.bridge.smartsheet.com/#/dashboard';
// use the helper function to parse the URL.
const { accountName, hostName, protocol } = parseAccountURL(accountURL);
// use the returned properties to build the baseURL
const http = createHTTPClient({
  baseURL: `${protocol}://${accountName}.${hostName}/api/`,
  token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
});

Workspace

API calls will default to the default workspace in your account, to get access to resources on other workspaces you must provide a workspace UUID as part of the config. This can be done at create-time, runtime, or intercept time.

const http = createHTTPClient({
  workspace: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
});

Or

const http = createHTTPClient({ ... });
http.conversation.fetch({ uuid: '<conversationUUID>' }, {
  workspace: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
})

Or

const http = createHTTPClient({ ... });
http.instance.request.use(config => {
  config.workspace = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
  return config;
});

See more info about interceptors below.

Advanced usage

Instance

The Bridge HTTP client extends the very popular Axios library and provides full access to the axios object via the instance property.

This allows for interceptors to be created.

const http = createHTTPClient({...});
http.interceptors.request.use(config => {
  console.log(`Logging request to ${config.url}`);
});

And raw HTTP calls to be made if the SDK has yet to implement them.

http.get('/user');

ESModules

By default the BridgeSDK is export as a commonJS module for use within NodeJS. For TypeScript, Babel, Webpack, or other ES6 focused projects like rollup there is also an ES6 export under the /es folder.

This allows the BridgeSDK to be imported as individual ESModules which can greatly reduce the size of your bundle and allow you to access the HTTP modules without importing the gRPC modules as well.

// Will import everything including gRPC in an CommonJS format.
import * as bridge from '@smartsheet-bridge/bridge-sdk';
// Will import everything including gRPC but in an ESModule format.
import * as bridge from '@smartsheet-bridge/bridge-sdk/es';
// Will import all methods from the HTTP Module.
import * as bridge from '@smartsheet-bridge/bridge-sdk/es/http';
// Will only import the platform module.
import platform from '@smartsheet-bridge/bridge-sdk/es/http/platform';
// Will only import the get method from the platform module.
import { get } from '@smartsheet-bridge/bridge-sdk/es/http/platform';

Individual methods can be used with an Bridge/Axios client or using the default one.

Using the default client.

import { get } from '@smartsheet-bridge/bridge-sdk/es/http/platform';

const { data } = await get({
  baseURL: 'https://example.bridge.smartsheet.com',
  token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
});

OR with Bridge client.

import createHTTPClient from '@smartsheet-bridge/bridge-sdk/es/http/createInstance';
import { get } from '@smartsheet-bridge/bridge-sdk/es/http/platform';

const client = createHTTPClient({
  baseURL: 'https://example.bridge.smartsheet.com',
  token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
});

const { data } = await get(client)();

This is early stage development and not ready for production consumers.