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

@mondaycom/apps-sdk

v3.0.7

Published

monday apps SDK for NodeJS

Downloads

3,513

Readme


apps-sdk

This sdk is used to leverage some of the capabilities exposed via <monday-code />:

Storage

  • This is the way to store customer data for your app
  • key/value based where the key is a string and value can be any serializable type (object, number, string, etc.)
  • Compartmentalized based on accountId and app for your specific app which means that data stored for one account will not be accessible from the context of another account
  • There are two modes for the storage which are based on a passed option shared:
    • false (default) - The stored data will be accessible only you "backend" oriented apps (storage will not be shared between integrations and views).
    • true - The stored data will be accessible from both "backend" and "frontend" oriented apps.

Storage API

There are three methods exposed to manage the storage - set, get and delete

Initialize

  • <ACCESS_TOKEN> - access token of the customer/account the app is working on behalf of
import { Storage } from '@mondaycom/apps-sdk';

const storage = new Storage('<ACCESS_TOKEN>');

Set

  • key: string - key to store the content for
  • value: any - value to store
  • previousVersion?: string - the last version of the stored value for a specific key (OPTIONAL)
  • shared?: boolean - whether the stored data will be accessible from both "backend" and "frontend" oriented apps (OPTIONAL)
  • version: string - the new version of the stored value
const { version, success, error } = await storage.set(key, value, { previousVersion, shared });

get

const { value, version, success } = await storage.get(key, { shared });

delete

const { success, error } = await storage.delete(key, { shared });

Secure storage

  • This is the way to store sensitive customer data (i.e access tokens generated by OAuth for example)
  • Has 3 different modes (dependent on where it is used)
    • Secure storage - when used in a deployed <monday-code/> project it will automatically utilize the real secure storage
    • Local "secure storage" - a local mock db which will mimic the api exposed by the real secure storage. Will work in this mode when sdk is used locally.

      If there are no permissions to write files on the disk, Local "secure storage" will not be persisted

  • key/value based where the key is a string and value can be any type (object, number, string, etc.)
  • compartmentalized for your specific app which means that data stored for one app will not be accessible by other apps

Secure Storage API

There are three methods exposed to manage the storage - set, get and delete

initialize

import { SecureStorage } from '@mondaycom/apps-sdk';

const secureStorage = new SecureStorage();

Set

  • key: string - key to store the content for
  • value: any - value to store (must be serializable)
await secureStorage.set(key, value);

get

const storedValue = await secureStorage.get(key);

delete

await secureStorage.delete(key);

Environment variables manager

  • This is the way to read environment variables for your app in a project deployed <monday-code/>.
  • Environment variables set via @mondaycom/apps-cli
    $ mapps code:env -m set -k <key> -v <value>
  • The environment variables are on the app level which means that they are accessible by all the versions of the app

Environment variables manager API

There are two methods exposed to manage the environment variables - get and getKeys

initialize

import { EnvironmentVariablesManager } from '@mondaycom/apps-sdk';

// Initialize the environment variables manager without injecting env into `process.env`
let envManager = new EnvironmentVariablesManager();

// Initialize the environment variables manager and inject env into `process.env`
envManager = new EnvironmentVariablesManager({ updateProcessEnv: true });

get

// Get cached environment variable
const cachedValue = envManager.get(key, { invalidate: false });

// Get the latest version of environment variable
const latestValue = envManager.get(key);

getKeys

// Get all cached environment variables keys
const cachedKeys = envManager.getKeys({ invalidate: false });

// Get all environment variables keys
const latestKeys = envManager.getKeys();

Secrets manager

  • This is the way to read secrets for your app in a project deployed <monday-code/>.
  • Secrets are set via @mondaycom/apps-cli
    $ mapps code:secrets -m set -k <key> -v <value>
  • These secrets are stored in a secure manner and can be used to store sensitive data (i.e. DB connection string, API keys, etc.)
  • The secrets are on the app level which means that they are accessible by all the versions of the app

Secrets manager API

There are two methods exposed to manage the secrets - get and getKeys

initialize

import { SecretsManager } from '@mondaycom/apps-sdk';

const secretsManager = new SecretsManager();

get

// Get cached secrets
const cachedValue = secretsManager.get(key, { invalidate: false });

// Get the latest version of a secret
const latestValue = secretsManager.get(key);

getKeys

// Get all cached secrets keys
const cachedKeys = secretsManager.getKeys({ invalidate: false });

// Get all secrets keys
const latestKeys = secretsManager.getKeys();

Logger

  • This logger provides a simple way to log messages for your app in a project deployed <monday-code/>.
  • Logged messages are accessible via via @mondaycom/apps-cli
    $ mapps code:logs
  • Logs written without this logger may not be accessible via @mondaycom/apps-cli or not get labeled correctly

Logger API

There are four methods exposed to manage the environment variables - info, warn, error and debug.

initialize

import { Logger } from '@mondaycom/apps-sdk';

const tag = 'my-app';
// tag will be added to every logged message
const logger = new Logger(tag);

info

logger.info('info message');

warn

logger.warn('warn message');

debug

logger.debug('debug message');

error

// Stack trace will be logged as well if error is provided
logger.error('error message', { error: new Error('error') });