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

mark-job-module-test

v1.0.2

Published

Creates Jobs to be handled by exframe-workflow

Downloads

1

Readme

exframe-job

A module for jobs and job items while integrating with exframe-workflow to execute job items.

Usage

const { createJob, applyJobTasks } = initialize({ workflow, dbClient });

Initialize Arguments

  • workflow - Required. The workflow instance created by the consuming service to be passed into the module.

  • dbClient - Required. The database client using to store jobs and jobItems

Methods

createJob

Starts polling the database for actions that need to be executed.

Example

const { job, jobItems } = await createJob(context, { jobData, jobItemData });

Arguments:

  • context object Required. Context object containing the user and log object
  • jobData object Required. The job type
  • jobItemData array Required. Array of job items. Job items will be stored in the DB. Job items will include all data needed to execute

Example Arguments

/*
"jobData": {
    "type":"BOB Endorsement"
}
*/
/*
"jobItemData": [
    {
      "agencyCodeFrom": 643,
      "agencyCodeTo": 295,
      "agentCodeFrom": 584,
      "agentCodeTo": 677,
      "policyNumber": "54-2444157-01",
      "agencyNameTo": "Joe - Smith",
      "agentNameTo": "Steve Adams",
      "agencyNameFrom": "John - Jacobs",
      "agentNameFrom": "Marion Miller",
      "transactionType": "BOB Endorsement"
    }
]
*/

Returns a Promise that resolves with an object containing the job and jobItems.

Example Response

/*
{
  "job": {
    "_id": "611d07b04d04e62070ed0eb4",
    "type": "BOB Endorsement",
    "status": "Pending",
    "createdBy": {
      "_id": "611d07a84d04e62070ed0e50",
      "userName": "TESTUSER",
      "userId": "eD1wfj9HGr"
    },
    "updatedBy": {
      "_id": "611d07a84d04e62070ed0e51",
      "userName": "TESTUSER",
      "userId": "eD1wfj9HGr"
    },
    "createdAt": "2021-08-18T13:14:16.227Z",
    "updatedAt": "2021-08-18T13:14:16.227Z",
    "__v": 0
  },
  "jobItems": [
    {
      "_id": "611d07b14d04e62070ed0eb8",
      "jobId": "611d07b04d04e62070ed0eb4",
      "data": {
        "agencyCodeFrom": 643,
        "agencyCodeTo": 295,
        "agentCodeFrom": 584,
        "agentCodeTo": 677,
        "policyNumber": "54-2444157-01",
        "agencyNameTo": "Joe - Fisher",
        "agentNameTo": "Henry Adams",
        "agencyNameFrom": "Jake - Jacobs",
        "agentNameFrom": "Mac Brown",
        "transactionType": "BOB Endorsement"
      },
      "status": "Pending",
      "createdBy": {
        "_id": "611d07b14d04e62070ed0eb9",
        "userName": "TESTUSER",
        "userId": "ULZzlYVSjI"
      },
      "updatedBy": {
        "_id": "611d07b14d04e62070ed0eba",
        "userName": "TESTUSER",
        "userId": "ULZzlYVSjI"
      },
      "createdAt": "2021-08-18T13:14:24.998Z",
      "updatedAt": "2021-08-18T13:14:24.998Z",
      "__v": 0
    }
  ]
}
 */

applyBlockTasks

Applies a block of tasks to the existing workflow that was originally passed in. This will be the block of tasks that will execute for each jobItem. This function is responsible for starting the job. The sourceIterator will then iterate over each jobItem that matches the jobId and attempt to start the job item (Set job status to "Started") The workflow block will then process the jobItem and set the status for each jobItem (Set jobItem status to "Complete" or "Failed") After iterating through each jobItem, the status for the job will be set (Set job status to "Complete" or "Failed")

Example

 await applyBlockTasks({
    workflowBlock: wfBlock => {
        wfBlock.task('taskOne', (context, workContext) => {

        });
        wfBlock.task('taskTwo', (context, workContext) => {

        });
        wfBlock.task('taskThree', (context, workContext) => {

        });
    }
});

Arguments

  • workflowBlock function Required. A function that applies workflow tasks to process a jobItem