Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

q247-models-core

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

q247-models-core

Models for effort/calories in q247 plugin

latest
npmnpm
Version
0.0.29
Version published
Maintainers
0
Created
Source

Q247 Models

Model and reference implementation of developer effort models for Q247 plugin

Key features

  • Pluggable model architecture
  • Easy to provide custom made models
  • 2 sample models to start with are provided

Provided models

As of today model based on Shanon's entropy model is provided in two versions. You can read more about Shanon's entropy at this link

Installation

$ npm install q247-models-core

Usage

const {ShanonEntropyScoreModelV2} = require("q247-my-custom-models")

const q247Event = {
  gitlog: "commit 5fc617ef5ede5d7ff6ffef0ba3205afe3e2a337e\nAuthor: xxxxx xxxxx <xxxxx.xxxxx@somecompany.pl>\nDate:   Sat Jun 8 18:44:46 2024 +0200\n\n    PWR-01 cleaning\n\n index.js | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n",
  oper: "commit",
  remote: "/Users/xxxxx/Documents/Projekty/gitspace/private/grm-microservices/process",
  diff: "commit 5fc617ef5ede5d7ff6ffef0ba3205afe3e2a337e\nAuthor: xxxxx xxxxx <xxxxx.xxxxx@somecompany.pl>\nDate:   Sat Jun 8 18:44:46 2024 +0200\n\n    PWR-01 cleaning\n\ndiff --git a/index.js b/index.js\nindex d7c4190..d232a53 100644\n--- a/index.js\n+++ b/index.js\n@@ -101,11 +101,8 @@ function attachNewPostOperation(appHandler, version, path, context, operationHan\n attachNewGetOperation(app, version, path, \"/transition/available/:typeId/:entityId\", manager.availableTransitions.bind(manager));\n attachNewPostOperation(app, version, path, \"/transition/execute/:typeId/:entityId/:transitionCode\", manager.transitionExecute.bind(manager));\n attachNewPostOperation(app, version, path, \"/instance/:typeId/:entityId\", manager.postProcessInstance.bind(manager));\n-\n attachNewGetOperation(app, version, path, \"/instance/:typeId/:entityId\", manager.getProcessInstance.bind(manager));\n-\n attachNewGetOperation(app, version, path, \"/definition/:typeId\", manager.getProcessDefinition.bind(manager));\n attachNewPostOperation(app, version, path, \"/definition/:typeId\", manager.postProcessDefinition.bind(manager));\n \n-attachNewGetOperation(app, version, path, \"/instance/:typeId/:entityId/history\", manager.getProcessInstanceHistory.bind(manager));\n-\n+attachNewGetOperation(app, version, path, \"/instance/:typeId/:entityId/history\", manager.getProcessInstanceHistory.bind(manager));\n\\ No newline at end of file\n",
  account: "a_somecompany",
  user: "xxxxx.xxxxx@somecompany.pl",
  project: "4r3t7x7fj6",
  id: "xj8d6c840o",
  ct: 1718393469569,
  decoded: {
    ticket: "PWR-01",
    ticketPrefix: "PWR",
    commit: "commit 5fc617ef5ede5d7ff6ffef0ba3205afe3e2a337e",
    author: {
      name: "xxxxx xxxxx",
      email: "xxxxx.xxxxx@somecompany.pl",
    },
    date: "Date:   Sat Jun 8 18:44:46 2024 +0200",
    message: "PWR-01 cleaning",
    changes: [
      " index.js | 5 +----",
    ],
    changeSummary: {
      raw: " 1 file changed, 1 insertion(+), 4 deletions(-)",
      files: 1,
      inserts: 1,
      deletions: 4,
    },
  }
}

const model = new ShanonEntropyScoreModelV2();
const score = await model.score(q247Event);
        

async score(gitEvent)

Calculates effort scoring for provided gitEvent. Returns a Promise that resolves to a Score object.

ParameterTypeDescription
gitEventobjectGit event object from q247 plugin

Score

Result of score calculation.

export interface ScoreModelCard {
    name: string;
    version: string;
}
export interface Score {
    id: string; // score unique id
    model: ScoreModelCard;
    event: Event; // source event that was scored
}
export interface ScalarScore extends Score{    
    score: number
}
NameDescriptionExample
"id"Unique score ida8sjk800js71ja
"name"Name of the model used to calculate this scoreShanonEntropyScoreModelV2
"version"Version number of the model used to calculate scorew$Tsu4G
"event"Source git event for which score was calculatedSee Usage section for event example
"score"Estimated effort required to produce source git event1.23

Writing custom models

Q247 models are fully extendable. In order to create custom model one should provide an implementation of a ScoreModel class/interface

import { ScalarScore, ScoreModel, Event } from "q247-models-core";

export class ShanonEntropyScoreModelV1 implements ScoreModel {
    
    name = "ShanonEntropyScoreModel";
    version = "1.0";

    score(event: Event): Promise<ScalarScore> {
      /* here goes your custom model implementation */
    }
}

Keywords

q247

FAQs

Package last updated on 27 Jul 2025

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