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

@turbot/sdk

v5.15.0

Published

Turbot SDK

Downloads

185

Readme

@turbot/sdk

The turbot JavaScript SDK simplifies writing controls, actions and calculated policies for execution in a Turbot environment. It is generally used as a key component of @turbot/fn, which establishes context and environment for Turbot when run inside an AWS Lambda function.

Install

The turbot SDK is used as a sub-component of @turbot/fn and should be installed through @turbot/fn instead using:

npm install @turbot/fn

The turbot SDK can be used without @turbot/fn with the source downloadable from GitHub. The easiest installation is through npm by running:

npm install @turbot/sdk

SDK components

Logging

  • turbot.log.debug
  • turbot.log.info
  • turbot.log.notice
  • turbot.log.warning
  • turbot.log.error

turbot.log.{level}(message, data)

  • Logging requires a message and data/or data to be processed Valid log levels are:
  • error
  • warning
  • notice
  • info
  • debug

Examples:

  • turbot.log.debug("String message for logging");
  • turbot.log.debug({object: "will", be: "logged", as: "data", with: "no", message: "string"});
  • turbot.log.debug("A message", {and: "an", object: "works fine"});

Limits:

  • Each log message with its data must be less than 256kB in size.

States

  • turbot.ok(reason, data)
  • turbot.invalid(reason, data)
  • turbot.error(reason, data)
  • urbot.tbd(reason, data)
  • turbot.skipped(reason, data)

Action

  • turbot.action.run(actionUri, parameters)
  • turbot.action.run(aka, actionUri, parameters)
    • Run actionUri with parameters for resource aka (optional, defaults to target resource). Examples: turbot.action.run("tmod:@turbot/aws-s3#/action/types/bucketDelete");

Policy

Policies that are set to manage the configuration settings for controls, return the states as per the conditions provided.

  • turbot.policy.ok(value, reason, data)
  • turbot.policy.invalid(reason, data)
  • turbot.policy.error(reason, data)
  • turbot.policy.tbd(reason, data)

| State | Description | | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | OK | The state is returned when the Policy value is set correctly and is valid against the schema at the time it was set. | | Invalid | State is returned when the Policy value is not set, Either a prerequisite was Invalid, or the value given for this policy was not valid against its schema. The previous value of the policy is still in place, but any controls or policies depending on this policy are blocked until it is in an OK state. | | Error | The state is returned when an unexpected error occurrs while calculating the policy. Human intervention is required to fix, and support may be required to review. | | TBD | The state is returned when insufficient information or input has been provided for the policy to be calculated. |

Control

turbot.control.{ok,alarm,skipped,error,invalid,tbd}(reason, data)

Set controlId (optional, defaults to target control) to be {state} with an optional reason and data. | State | Description | | -- | -- | | OK | The state is returned when the control runs successfully with no change required.| | Alarm | The state is returned when conditions are not met and changes are required in the resource or the environment.| | Invalid | The state is returned when the policy settings require changes in order to meet the conditions or the environment needs configuration checks. The only resolution is by changes to the policies or different configurations. | | Error | The state is returned when unexpected error occurs while executing the control. Human intervention is required to fix unexpected conditions, and support may be required to review. | | TBD | The state is returned when insufficient information or input has been provided for the control to be executed. The state is fixed with correct required inputs.| Examples:

  • turbot.control.ok();
  • turbot.control.invalid("Incompatible requirements or state that requires human intervention");
  • turbot.control.error("Not Found", { more: "details" });
  • turbot.control.tbd("Waiting on updates");
  • turbot.control.skipped();

Resource

  • turbot.resource.create(parentId, resourceTypeAka, data, turbotData)
  • turbot.resource.upsert(parentId, resourceTypeAka, data, turbotData)
  • turbot.resource.put(resourceId,data, turbotData)
  • turbot.resource.putPath(resourceId, path, data, turbotDataPath, turbotData)
  • turbot.resource.putPaths(resourceId,data, turbotData)
  • turbot.resource.update(resourceId,data, turbotData)
  • turbot.resource.delete(resourceId)
  • turbot.resource.notify(resourceId, icon, message, data)

| State | Description | | -------- | -------------------------------------------------------------------- | | upsert | It upsert the resource with the parentID | | put | It put the resource data in the CMDB with resourceId | | putPaths | It put the resource data in the CMDB with | | update | It update the data of resource in the CMDB with the given resourceId |

Examples:

  • turbot.resource.upsert(“#/resource/types/certificate”, resource, turbotData);
  • turbot.resource.put(result, turbotData);
  • turbot.resource.putPaths(result, turbotData);
  • turbot.resource.update({ title: ‘New title’ });
  • turbot.resource.delete(resourceId);

Watch

  • turbot.watch.create(resourceId, filters, action)
  • turbot.watch.delete(watchId)

| State | Description | | -------- | -------------------------------------------------------------------- | | create | It creates the watch | | delete | It deletes the watch |

Examples:

  • turbot.watch.delete(227139196406160, [ "level:self,descendant notificationType:resource_deleted" ], "tmod:@turbot/aws-s3#/action/types/bucketDelete");
  • turbot.watch.delete(304627475971091);

Action

  • turbot.action.ok(reason, data)
  • turbot.action.invalid(reason, data)
  • turbot.action.tbd(reason, data)
  • turbot.action.error(reason, data)
  • turbot.action.skipped(reason, data) Examples: turbot.action.ok() turbot.action.error()

Notifications

  • turbot.notify(icon, message, data)
  • turbot.notify(controlId, icon, message, data)