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

@fabernovel/heart-core

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fabernovel/heart-core - npm Package Compare versions

Comparing version 3.1.2 to 3.3.0

lib/config/Config.d.ts

3

lib/event/AnalysisEvents.d.ts

@@ -5,5 +5,4 @@ /**

*/
declare const enum AnalysisEvents {
export declare const enum AnalysisEvents {
DONE = "analysis.done"
}
export default AnalysisEvents;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=AnalysisEvents.js.map

@@ -1,3 +0,2 @@

import { HeadersInit } from 'node-fetch';
export default class Request {
export declare class Request {
private static GET;

@@ -9,8 +8,8 @@ private static POST;

private static BASE_HEADER;
static get<T>(url: string, headers?: HeadersInit | {
static get<T>(url: string, headers?: {
[index: string]: string;
}): Promise<T>;
static post<T>(url: string, body?: object, headers?: HeadersInit | {
static post<T>(url: string, body?: object, headers?: {
[index: string]: string;
}): Promise<T>;
}

@@ -12,2 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Request = void 0;
const node_fetch_1 = require("node-fetch");

@@ -18,3 +19,3 @@ const querystring_1 = require("querystring");

return __awaiter(this, void 0, void 0, function* () {
return yield (0, node_fetch_1.default)(url, {
return (0, node_fetch_1.default)(url, {
method: Request.GET,

@@ -27,3 +28,3 @@ headers: Object.assign(Object.assign({}, Request.BASE_HEADER), headers),

return __awaiter(this, void 0, void 0, function* () {
let bodyString = '';
let bodyString = "";
headers = Object.assign(Object.assign({}, Request.BASE_HEADER), headers);

@@ -38,9 +39,8 @@ switch (headers[Request.HEADER_CONTENT_TYPE]) {

default:
return Promise.reject({ error: 'invalid-header', message: 'Unsupported header Content-Type' });
break;
return Promise.reject({ error: "invalid-header", message: "Unsupported header Content-Type" });
}
return yield (0, node_fetch_1.default)(url, {
return (0, node_fetch_1.default)(url, {
method: Request.POST,
body: bodyString,
headers
headers,
}).then((res) => res.json());

@@ -50,11 +50,10 @@ });

}
exports.default = Request;
Request.GET = 'GET';
Request.POST = 'POST';
Request.HEADER_CONTENT_TYPE = 'Content-Type';
Request.HEADER_CONTENT_TYPE_JSON = 'application/json';
Request.HEADER_CONTENT_TYPE_X_WWW_FORM_URLENCODED = 'application/x-www-form-urlencoded';
exports.Request = Request;
Request.GET = "GET";
Request.POST = "POST";
Request.HEADER_CONTENT_TYPE = "Content-Type";
Request.HEADER_CONTENT_TYPE_JSON = "application/json";
Request.HEADER_CONTENT_TYPE_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
Request.BASE_HEADER = {
[Request.HEADER_CONTENT_TYPE]: Request.HEADER_CONTENT_TYPE_JSON
[Request.HEADER_CONTENT_TYPE]: Request.HEADER_CONTENT_TYPE_JSON,
};
//# sourceMappingURL=Request.js.map

@@ -1,12 +0,17 @@

import AnalysisEvents from './event/AnalysisEvents';
import Request from './http/Request';
import Module from './model/module/Module';
import ModuleAnalysisInterface, { isModuleAnalysis } from './model/module/ModuleAnalysisInterface';
import ModuleInterface from './model/module/ModuleInterface';
import ModuleListenerInterface, { isModuleListener } from './model/module/ModuleListenerInterface';
import ModuleServerInterface, { isModuleServer } from './model/module/ModuleServerInterface';
import Report from './model/report/Report';
import { Config } from "./config/Config";
import { ConfigError } from "./error/ConfigError";
import { ThresholdError } from "./error/ThresholdError";
import { AnalysisEvents } from "./event/AnalysisEvents";
import { Request } from "./http/Request";
import { Module } from "./model/module/Module";
import { ModuleAnalysisInterface, isModuleAnalysis } from "./model/module/ModuleAnalysisInterface";
import { ModuleIndex } from "./model/module/ModuleIndex";
import { ModuleInterface } from "./model/module/ModuleInterface";
import { ModuleListenerInterface, isModuleListener } from "./model/module/ModuleListenerInterface";
import { ModuleServerInterface, isModuleServer } from "./model/module/ModuleServerInterface";
import { Report } from "./model/report/Report";
import { validateInput } from "./validation/InputValidation";
declare const Helper: {
timeout: (delay: number) => Promise<object>;
};
export { AnalysisEvents, Helper, isModuleAnalysis, isModuleListener, isModuleServer, Module, ModuleAnalysisInterface, ModuleInterface, ModuleListenerInterface, ModuleServerInterface, Report, Request, };
export { AnalysisEvents, Config, ConfigError, Helper, isModuleAnalysis, isModuleListener, isModuleServer, Module, ModuleAnalysisInterface, ModuleIndex, ModuleInterface, ModuleListenerInterface, ModuleServerInterface, Report, Request, ThresholdError, validateInput, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Request = exports.Report = exports.Module = exports.isModuleServer = exports.isModuleListener = exports.isModuleAnalysis = exports.Helper = void 0;
exports.validateInput = exports.ThresholdError = exports.Request = exports.Report = exports.Module = exports.isModuleServer = exports.isModuleListener = exports.isModuleAnalysis = exports.Helper = exports.ConfigError = void 0;
const ConfigError_1 = require("./error/ConfigError");
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return ConfigError_1.ConfigError; } });
const ThresholdError_1 = require("./error/ThresholdError");
Object.defineProperty(exports, "ThresholdError", { enumerable: true, get: function () { return ThresholdError_1.ThresholdError; } });
const Request_1 = require("./http/Request");
exports.Request = Request_1.default;
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return Request_1.Request; } });
const Module_1 = require("./model/module/Module");
exports.Module = Module_1.default;
Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return Module_1.Module; } });
const ModuleAnalysisInterface_1 = require("./model/module/ModuleAnalysisInterface");

@@ -15,4 +19,6 @@ Object.defineProperty(exports, "isModuleAnalysis", { enumerable: true, get: function () { return ModuleAnalysisInterface_1.isModuleAnalysis; } });

const Report_1 = require("./model/report/Report");
exports.Report = Report_1.default;
Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return Report_1.Report; } });
const timeout_1 = require("./time/timeout");
const InputValidation_1 = require("./validation/InputValidation");
Object.defineProperty(exports, "validateInput", { enumerable: true, get: function () { return InputValidation_1.validateInput; } });
const Helper = {

@@ -22,2 +28,1 @@ timeout: timeout_1.timeout,

exports.Helper = Helper;
//# sourceMappingURL=index.js.map

@@ -1,15 +0,8 @@

import ServiceInterface from '../service/ServiceInterface';
import ModuleInterface from './ModuleInterface';
export default abstract class Module implements ModuleInterface {
/**
* Examples: dareboost, observatory...
* The id is automatically guessed from the package name, so do not set it explicitly
*/
import { ServiceInterface } from "../service/ServiceInterface";
import { ModuleInterface } from "./ModuleInterface";
export declare abstract class Module implements ModuleInterface {
id: string;
/**
* Example: Heart Observatory, Heart BigQuery
*/
name: string;
service: ServiceInterface;
protected constructor(module: Partial<ModuleInterface>);
readonly name: string;
readonly service: ServiceInterface;
constructor(module: Pick<ModuleInterface, "name" | "service">);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = void 0;
class Module {
constructor(module) {
Object.assign(this, module);
this.id = "";
this.name = module.name;
this.service = module.service;
}
}
exports.default = Module;
//# sourceMappingURL=Module.js.map
exports.Module = Module;

@@ -1,8 +0,9 @@

import Report from '../report/Report';
import ModuleInterface from './ModuleInterface';
import { Config } from "../../config/Config";
import { Report } from "../report/Report";
import { ModuleInterface } from "./ModuleInterface";
/**
* Define an Analysis module.
*/
export default interface ModuleAnalysisInterface extends ModuleInterface {
startAnalysis: (conf: object) => Promise<Report>;
export interface ModuleAnalysisInterface<T extends Config> extends ModuleInterface {
startAnalysis: (conf: T, thresholds?: number) => Promise<Report>;
}

@@ -13,3 +14,3 @@ /**

*/
export declare type ModuleAnalysis = new () => ModuleAnalysisInterface;
export declare type ModuleAnalysis<T extends Config> = new () => ModuleAnalysisInterface<T>;
/**

@@ -19,2 +20,2 @@ * Checks if a module is an Analysis one.

*/
export declare function isModuleAnalysis(module: ModuleInterface): module is ModuleAnalysisInterface;
export declare function isModuleAnalysis<T extends Config>(module: ModuleInterface): module is ModuleAnalysisInterface<T>;

@@ -10,5 +10,4 @@ "use strict";

const m = module;
return m !== undefined && m.startAnalysis !== undefined && 'function' === typeof m.startAnalysis;
return m !== undefined && m.startAnalysis !== undefined && "function" === typeof m.startAnalysis;
}
exports.isModuleAnalysis = isModuleAnalysis;
//# sourceMappingURL=ModuleAnalysisInterface.js.map

@@ -1,3 +0,3 @@

import ServiceInterface from '../service/ServiceInterface';
export default interface ModuleInterface {
import { ServiceInterface } from "../service/ServiceInterface";
export interface ModuleInterface {
/**

@@ -4,0 +4,0 @@ * Example: observatory

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ModuleInterface.js.map
/// <reference types="node" />
import { EventEmitter } from 'events';
import ModuleInterface from './ModuleInterface';
import { EventEmitter } from "events";
import { ModuleInterface } from "./ModuleInterface";
/**
* Define an Listener module.
*/
export default interface ModuleListenerInterface extends ModuleInterface {
export interface ModuleListenerInterface extends ModuleInterface {
/**

@@ -9,0 +9,0 @@ * Register events on the given emitter.

@@ -10,5 +10,4 @@ "use strict";

const m = module;
return m !== undefined && m.registerEvents !== undefined && 'function' === typeof m.registerEvents;
return m !== undefined && m.registerEvents !== undefined && "function" === typeof m.registerEvents;
}
exports.isModuleListener = isModuleListener;
//# sourceMappingURL=ModuleListenerInterface.js.map
/// <reference types="node" />
import { Server } from 'http';
import ModuleInterface from './ModuleInterface';
import { CorsOptions } from "cors";
import { Server } from "http";
import { ModuleInterface } from "./ModuleInterface";
/**
* Define a Server module.
*/
export default interface ModuleServerInterface extends ModuleInterface {
startServer: (modules: ModuleInterface[], port?: number) => Server;
export interface ModuleServerInterface extends ModuleInterface {
startServer: (modules: ModuleInterface[], port: number, cors?: CorsOptions) => Server;
}

@@ -10,0 +11,0 @@ /**

@@ -10,5 +10,4 @@ "use strict";

const m = module;
return m !== undefined && m.startServer !== undefined && 'function' === typeof m.startServer;
return m !== undefined && m.startServer !== undefined && "function" === typeof m.startServer;
}
exports.isModuleServer = isModuleServer;
//# sourceMappingURL=ModuleServerInterface.js.map

@@ -1,3 +0,4 @@

import ServiceInterface from '../service/ServiceInterface';
import ReportInterface from './ReportInterface';
import { ServiceInterface } from "../service/ServiceInterface";
import { ReportInterface } from "./ReportInterface";
declare type ReportParams = Pick<ReportInterface, "analyzedUrl" | "date" | "note" | "resultUrl" | "service" | "threshold"> & Partial<Pick<ReportInterface, "normalizedNote">>;
/**

@@ -9,3 +10,3 @@ * Define an analysis report that is shared between every Heart module.

*/
export default class Report implements ReportInterface {
export declare class Report implements ReportInterface {
analyzedUrl: string;

@@ -17,3 +18,6 @@ date: Date;

service: ServiceInterface;
constructor(report: Partial<ReportInterface>);
threshold?: number;
constructor(report: ReportParams);
isThresholdReached(): boolean | undefined;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Report = void 0;
/**

@@ -11,7 +12,15 @@ * Define an analysis report that is shared between every Heart module.

constructor(report) {
Object.assign(this, report);
this.normalizedNote = this.normalizedNote || parseInt(report.note, 10) || 0;
var _a, _b;
this.analyzedUrl = report.analyzedUrl;
this.date = report.date;
this.note = report.note;
this.normalizedNote = (_b = (_a = report.normalizedNote) !== null && _a !== void 0 ? _a : Number(this.note)) !== null && _b !== void 0 ? _b : 0;
this.resultUrl = report.resultUrl;
this.service = report.service;
this.threshold = report.threshold;
}
isThresholdReached() {
return this.threshold ? this.normalizedNote >= this.threshold : undefined;
}
}
exports.default = Report;
//# sourceMappingURL=Report.js.map
exports.Report = Report;

@@ -1,3 +0,3 @@

import ServiceInterface from '../service/ServiceInterface';
export default interface ReportInterface {
import { ServiceInterface } from "../service/ServiceInterface";
export interface ReportInterface {
/**

@@ -26,5 +26,9 @@ * URL that is analyzed

* Details about the service that process the analysis
* Optional because some Heart modules do not sollicitate a third-party service (Heart API for example)
*/
service?: ServiceInterface;
service: ServiceInterface;
/**
* Threshold
*/
threshold?: number;
isThresholdReached(): boolean | undefined;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ReportInterface.js.map

@@ -5,3 +5,3 @@ /**

*/
export default class ServiceInterface {
export interface ServiceInterface {
/**

@@ -8,0 +8,0 @@ * Example: Mozilla Observatory

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Define a third-party service, as used by the analysis modules for example.
* This data is common to the Report and Module models
*/
class ServiceInterface {
}
exports.default = ServiceInterface;
//# sourceMappingURL=ServiceInterface.js.map

@@ -7,4 +7,3 @@ "use strict";

*/
const timeout = (delay) => new Promise(resolve => setTimeout(resolve, delay));
const timeout = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
exports.timeout = timeout;
//# sourceMappingURL=timeout.js.map
{
"name": "@fabernovel/heart-core",
"version": "3.1.2",
"version": "3.3.0",
"description": "Centralize helpful code needed by every Heart modules",
"homepage": "https://gitlab.com/fabernovel/heart",
"homepage": "https://heart.fabernovel.com",
"bugs": {

@@ -17,5 +17,2 @@ "url": "https://gitlab.com/fabernovel/heart/issues"

],
"files": [
"lib/**/*"
],
"main": "lib/index.js",

@@ -26,5 +23,5 @@ "types": "lib/index.d.ts",

},
"engines": {
"node": ">=14.17.0"
},
"files": [
"lib/**/*"
],
"dependencies": {

@@ -34,19 +31,23 @@ "node-fetch": "^2.6.0"

"devDependencies": {
"@types/cors": "^2.8.12",
"@types/jest": "^27.5.1",
"@types/node": "^10.14.10",
"@types/node-fetch": "^2.3.7",
"jest": "^27.5.1",
"ts-jest": "^27.1.3",
"typescript": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"eslint": "^8.16.0",
"@typescript-eslint/parser": "^5.26.0",
"@typescript-eslint/eslint-plugin": "^5.26.0"
"jest": "^28.1.0",
"rimraf": "^3.0.2",
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
},
"engines": {
"node": ">=14.17.0"
},
"scripts": {
"build": "tsc",
"build-watch": "tsc -w",
"build": "rimraf lib && tsc --project tsconfig.build.json",
"build:watch": "npm run build --watch",
"lint": "eslint .",
"outdated": "npm outdated",
"test": "jest --silent"
}
}

@@ -5,4 +5,4 @@ # Heart Core

THIS PACKAGE DOES NOT NEED TO FIGURE IN YOUR DEPENDENCIES.
THIS PACKAGE MUST NOT FIGURE IN YOUR DIRECT DEPENDENCIES.
Read more about [the purpose, design and general installation of _Heart_](https://www.fabernovel.com/en/clients/cases/heart-a-tool-for-automating-web-quality-metrics).
Read more about [the purpose, design and general installation of _Heart_](https://gitlab.com/fabernovel/heart/-/blob/master/README.md).
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