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

@workflowd1/workflow-sdk

v2.1.2

Published

[![NPM version](https://img.shields.io/npm/v/@workflowd1/workflow-sdk.svg)](https://www.npmjs.com/package/@workflowd1/workflow-sdk) [![NPM downloads](https://img.shields.io/npm/dm/@workflowd1/workflow-sdk.svg)](https://www.npmjs.com/package/@workflowd1/wo

Downloads

6

Readme

Workflow SDK for JavaScript

NPM version NPM downloads

Contents

How to install

The Workflow SDK is compatible with Node.js 14+, as is written in TypeScript. The way to install Workflow SDK for Node.js is to use npm package manager:

npm i @workflowd1/workflow-sdk

You can also use yarn, by simply type:

yarn add @workflowd1/workflow-sdk

Workflow

To use Workflow features, you should know some basic information, as which Tenant URL you are consuming. With that in mind, now you need to have some credentials to call the available operations, and the credential that is active will be the one related on logs.

Credentials

This class main responsibility is store one credential, that is basically one email, one password and the Tenant URL.

const { Credentials } = require('@workflows/workflow-sdk')

const userCredential = new Credentials({email: '[email protected]', password: 'strongPassword', baseURL: 'tenant.url.com'})

You can also create multiple credentials only by instancing a new class

const { Credentials } = require('@workflows/workflow-sdk')

const userOneCredential = new Credentials({ email: '[email protected]', password: 'strongPassword', baseURL: 'tenant.url.com' })

const userTwoCredential = new Credentials({ email: '[email protected]', password: 'strongPassword', baseURL: 'tenant.url.com' })

It is important to know that the baseURL needs to be the one you are operating on. If you pass any other tenant URL, all the calls will be made on that, and it may cause you some problems.

Also credentials will be consumed by Workflow classes as an object and it has the following structure.

{
  'default': new Credentials({ email, password, baseURL }), // ('default' key is mandatory, and will applied if no other specified)
  'custom': new Credentials({ email, password, baseURL })
}

Credentials can also be instanced with Redis, it can be configured at the second parameter on constructor, it is basically connection options and a key that will store the authentication token, as the example bellow:

const userOneCredential = new Credentials(auth, { redis: { host: '', port: '', key: '' }})

Entities

All Workflow entities are available on the same class, as properties. This properties are references to classes that execute entity operations, as create or update. It is essential that Credentials are configured.

It should be instanced as below:

const { Workflow } = require('@workflows/workflow-sdk')

const workflowHandler = new Workflow({ default: defaultCredential, [key]: new Credential(auth) })

All the credentials that were passed on class constructor will be available as credential key on subsequent calls for any entity. The methods available are basically an easy axios call, all the parameters are described on API references.

The methods follow a pattern on parameters that is:

// Credential key is optional and references to Workflow constructor.
async function(data: RequestBody, credentialsKey?: string) {
  //If no credential key is provided, default key will be set.
  this.currentCredentials = this.credentialsObject[credentialKey]
}

Document

const newDocument = await workflowHandler.document.create(createParams: object)
const updatedDocument = await workflowHandler.document.update(updateParams: object)
const loadDocument = await workflowHandler.document.load(loadParams: object)
const loadDocument = await workflowHandler.document.loadById(idParam: object)

Attachment

const newAttachment = await workflowHandler.attachment.uploadFile(createParams: object)
const updatedAttachment = await workflowHandler.attachment.update(updateParams: object)
const newPendency = await workflowHandler.attachment.createPendency(loadParams: object)
const loadPendency = await workflowHandler.attachment.loadPendency(idParam: object)

Observation

  • create
const createParams = {
  document_id: number,
  message: string,
  observation_from: string,
  section: string,
  send_communication: boolean
}

const createObservation = await workflowHandler.observation.create(createParams)
  • delete
const deleteObservation = await workflowHandler.observation.delete({ id: idToDelete })

CertDox

You can you CertDox integration easily in your codes just instantiating it. Follow the example below:

const { Certdox } = require('@workflowd1/workflow-sdk')

const certdox = new Certdox('your_api_key_here')

Voucher

  • ask
const data = [
  {
    tipoCombo: "1",
    idDocumento: "10101010",
    nome: "Nome",
    cpfCnpj: "000.000.000-00",
    cidade: "São Paulo",
    uf: "SP",
    nomeMae: "Nome da Mãe",
    nomePai: "Nome do Pai",
    rg: "99999999",
    dataNascimento: "10-10-1900",
    informacoesAdicionais: "Informações adicionais"
  }
]

const res = await certdox.voucher.ask(data)

Register

  • ask
const data = {
  tipoCombo: "1",
  idDocumento: "10101010",
  cartorio: "Nome do Cartorio",
  cidade: "São Paulo",
  uf: "SP",
  numeroContrato: "123123123",
  partes: [
    {
      nome: "Nome da parte",
      cpf: "000.000.000-00",
      tipoDocumento: "RG"
    }
  ],
  documentos: [
    {
      tipoDocumento: "CPF",
      urlDocumento: "https://url-do-documento/documento.pdf"
    }
  ],
  informacoesAdicionais: "Informações adicionais"
}

const res = await certdox.register.ask(data)

Requirements

  • ask
const data = {
    idPedido: "10101010",
    idSmarkio: "20202020",
    textoSolucao: "Texto contendo teste"
}

const res = await certdox.requirements.ask(data)

Common

There is some classes that can be used by any other module or consumer. They are called 'Common'.

Redis

Redis class is based on Singleton, and should be used as one.

const redisInstance = Redis.getInstance(options, key);