New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yoctol/kurator

Package Overview
Dependencies
Maintainers
1
Versions
703
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yoctol/kurator

```sh yarn add @yoctol/kurator ```

  • 0.50.9
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
46
increased by155.56%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

yarn add @yoctol/kurator

Usage

const Kurator = require('@yoctol/kurator');
const { createDeployMiddleware } = require('@yoctol/kurator/koa');
const { middleware } = require('bottender');

const kurator = new Kurator({
  projectId: '<PROJECT_ID>',
  accessToken: '<ACCESS_TOKEN>',
});

bot.onEvent(
  middleware([
    kurator.createBottenderMiddleware(),
    (context) => {
      // ...
    },
  ])
);

To get specific action, use kurator.getAction:

const action = kurator.getAction('<ACTION_ID>');

To register local action, use kurator.registerAction:

kurator.registerAction('<ACTION_ID>', (context) => {
  /* ... */
});

To register multiple local actions, use kurator.registerActions:

kurator.registerActions({
  '<ACTION_ID_1>': (context) => {
    /* ... */
  },
  '<ACTION_ID_2>': (context) => {
    /* ... */
  },
});

Debug

Add DEBUG env variable for debug package:

DEBUG=kurator
DEBUG=kurator:chatbase
DEBUG=kurator:trigger
DEBUG=kurator:predict

Updating

Webhook:

router.use('deployz', createDeployMiddleware({ kurator }));

Polling:

const kurator = new Kurator({
  projectId: '<PROJECT_ID>',
  accessToken: '<ACCESS_TOKEN>',
  polling: {
    interval: 5 * 60 * 1000,
  },
});

Run with Action Map

If a map between actionId and actionName is needed, visit: https://kurator.yoctol.com/api/projects/<PROJECT_ID>/action-map And the result is a map as below:

{
  "FOO": "87654321",
  "BAR": "12345678"
}

To get action map support in Kurator SDK, just passing actionMap to your Kurator constructor:

const kurator = new Kurator({
  projectId: '<PROJECT_ID>',
  accessToken: '<ACCESS_TOKEN>',
  actionMap: {
    FOO: '87654321',
    BAR: '12345678',
  },
});

After that, you can trigger your action by key of the action map:

kurator.getAction('FOO');

// calling with context
await kurator.getAction('FOO')(context);

Add Chatbase Support

const kurator = new Kurator({
  projectId: '<PROJECT_ID>',
  accessToken: '<ACCESS_TOKEN>',
  chatbase: {
    apiKey: '<CHATBASE_KEY>',
  },
});

Specify Environment

const kurator = new Kurator({
  projectId: '<PROJECT_ID>',
  accessToken: '<ACCESS_TOKEN>',
  environment: 'staging', // Enum: 'staging' | 'production'
});

Use customAdapter to Handle Universal Platform

const customAdapter = {
  toTextAction: ({ descriptor: { text, buttons } }) => (context) =>
    context.sendText(text),
  toImageAction: ({
    descriptor: { imageUrl, title, subtitle, webUrl, buttons },
  }) => (context) => context.sendImage(imageUrl),
};

new Kurator({
  projectId: '<PROJECT_ID>',
  accessToken: '<ACCESS_TOKEN>',
  customAdapter,
});

FAQs

Package last updated on 28 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc