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

@brease/sdk

v0.0.3

Published

BreaseSDK Business rule engine as a service

Downloads

3

Readme

BreaseSDK Typescript SDK 1.0.0

The Typescript SDK for BreaseSDK.

  • API version: 1.0.0
  • SDK version: 1.0.0

Table of Contents

About the API

Business rule engine as a service

Installation

npm install sdk  

Authentication

To see whether an endpoint needs a specific type of authentication check the endpoint's documentation.

Bearer Authentication with Refresh Tokens

The BreaseSDK API uses bearer tokens for authentication, but these bearer tokens have a short expiration time. Refresh tokens have longer duration, and they have the ability to obtain new bearer tokens. The bearer and refresh token can be set when initializing the SDK like this:

sdk = new BreaseSDK('YOUR_REFRESH_TOKEN', 'YOUR_BEARER_TOKEN')

Or at a later stage:

sdk = new BreaseSDK()
sdk.setBearerToken('YOUR_BEARER_TOKEN');
sdk.setRefreshToken('YOUR_REFRESH_TOKEN');

After the refresh token has been set, the SDK will automatically refresh the bearer token when needed.

Sample Usage

Here is a simple program demonstrating usage of this SDK. It can also be found in the examples/src/index.ts file in this directory.

When running the sample make sure to use npm install to install all the dependencies.

import { BreaseSDK } from '@brease/sdk';


const sdk = new BreaseSDK();

(async () => {
  const result = await sdk.Context
    .getAllRules('esse');
  console.log(result);
})();
 

Environments

Here is the list of all available environments:

DEFAULT = 'https://api.brease.run',
PRODUCTION = 'https://api.brease.run',
SANDBOX = 'https://api-sandbox.brease.run',
LOCAL = 'http://localhost:4400'

How to set the environment:

const sdk = new BreaseSDK();
sdk.setEnvironment(Environment.DEFAULT);

BreaseSDK Services

A list of all services and services methods.

Auth

| Method | Description| | :-------- | :----------| | refreshToken | | | getToken | |

Context

| Method | Description| | :-------- | :----------| | evaluateRules | | | getAllRules | | | addRule | | | removeRule | | | replaceRule | |

All Methods

refreshToken

  • HTTP Method: POST
  • Endpoint: /refreshToken

Required Parameters

| input | object | Request body. |

Return Type

TokenPair

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const input = { refreshToken: 'cillum pariatur nulla Ut' };
  const result = await sdk.Auth.refreshToken(input);
  console.log(result);
})();

getToken

  • HTTP Method: POST
  • Endpoint: /token

Return Type

TokenPair

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const result = await sdk.Auth.getToken();
  console.log(result);
})();

evaluateRules

  • HTTP Method: POST
  • Endpoint: /{contextID}/evaluate

Required Parameters

| Name | Type| Description | | :-------- | :----------| :----------| | contextId | string | | | input | object | Request body. |

Optional Parameters

Optional parameters are passed as part of the last parameter to the method. Ex. {optionalParam1 : 'value1', optionalParam2: 'value2'}

| Name | Type| Description | | :-------- | :----------| :----------|

Return Type

ApiEvaluateRulesResponse

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const input = {
    object: {
      description: 'Value of any type, including null',
      nullable: true,
      originalName: 'object',
      modelName: 'Object',
      title: 'Object',
    },
    overrideCode: 'ullamco exercitation quis Duis occaecat',
    overrideRules: [],
  };
  const result = await sdk.Context.evaluateRules(input, 'mollit amet esse in');
  console.log(result);
})();

getAllRules

  • HTTP Method: GET
  • Endpoint: /{contextID}/rules

Required Parameters

| Name | Type| Description | | :-------- | :----------| :----------| | contextId | string | |

Optional Parameters

Optional parameters are passed as part of the last parameter to the method. Ex. {optionalParam1 : 'value1', optionalParam2: 'value2'}

| Name | Type| Description | | :-------- | :----------| :----------| | compileCode | boolean | |

Return Type

ApiAllRulesResponse

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const result = await sdk.Context.getAllRules('cillum', { compileCode: true });
  console.log(result);
})();

addRule

  • HTTP Method: POST
  • Endpoint: /{contextID}/rules/add

Required Parameters

| Name | Type| Description | | :-------- | :----------| :----------| | contextId | string | | | input | object | Request body. |

Optional Parameters

Optional parameters are passed as part of the last parameter to the method. Ex. {optionalParam1 : 'value1', optionalParam2: 'value2'}

| Name | Type| Description | | :-------- | :----------| :----------|

Return Type

ApiAddRuleResponse

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const input = { rule: {} };
  const result = await sdk.Context.addRule(input, 'pariatur incididunt proident');
  console.log(result);
})();

removeRule

  • HTTP Method: DELETE
  • Endpoint: /{contextID}/rules/{id}

Required Parameters

| Name | Type| Description | | :-------- | :----------| :----------| | contextId | string | | | id | string | |

Optional Parameters

Optional parameters are passed as part of the last parameter to the method. Ex. {optionalParam1 : 'value1', optionalParam2: 'value2'}

| Name | Type| Description | | :-------- | :----------| :----------|

Return Type

Returns a dict object.

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const result = await sdk.Context.removeRule('in elit in', 'culpa sunt');
  console.log(result);
})();

replaceRule

  • HTTP Method: PUT
  • Endpoint: /{contextID}/rules/{id}

Required Parameters

| Name | Type| Description | | :-------- | :----------| :----------| | contextId | string | | | id | string | | | input | object | Request body. |

Optional Parameters

Optional parameters are passed as part of the last parameter to the method. Ex. {optionalParam1 : 'value1', optionalParam2: 'value2'}

| Name | Type| Description | | :-------- | :----------| :----------|

Return Type

ApiReplaceRuleResponse

Example Usage Code Snippet

import { BreaseSDK } from './src';

const sdk = new BreaseSDK();

(async () => {
  const input = { rule: {} };
  const result = await sdk.Context.replaceRule(input, 'incididunt', 'ex nulla anim qui Ut');
  console.log(result);
})();