Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

low

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

low - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

lib/loggers/logger.d.ts

11

lib/doers/doer.js

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

const object_compiler_1 = require("../object-compiler");
//import { Log } from '../log';
class Doer extends module_1.Module {

@@ -20,7 +19,8 @@ execute(context, task) {

try {
//Log.info(context, this.moduleType, `Executing task ${task.name}`);
const env = context.env;
env.info(context, this.moduleType, `Executing task ${task.name}`);
let cacheManager;
let cacheKey;
if (task.cacheConfig) {
//Log.info(context, this.moduleType, `Loading cache manager '${task.cacheConfig.cacheManager}`);
env.info(context, this.moduleType, `Loading cache manager '${task.cacheConfig.cacheManager}`);
cacheManager = this.env.getCacheManager(task.cacheConfig.cacheManager);

@@ -30,4 +30,4 @@ cacheKey = yield cacheManager.makeKey(task.cacheConfig, context);

if (cachedItem) {
//Log.info(context, 'Found cached item');
//Log.log(context, 'Found cached item', cachedItem);
env.info(context, 'Found cached item');
env.debug(context, 'Found cached item', cachedItem);
context.data[task.name] = cachedItem;

@@ -54,2 +54,3 @@ return;

return __awaiter(this, void 0, void 0, function* () {
this.env.debug(context, this.moduleType, 'Executing main(), returning', coreConfig);
return coreConfig;

@@ -56,0 +57,0 @@ });

@@ -12,4 +12,4 @@ import { Doer } from './doer';

export interface BranchConfig {
taskName: string;
haltAfterExecution: boolean;
taskName?: string;
haltAfterExecution?: boolean;
}

@@ -17,17 +17,30 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
this.env.debug(context, this.moduleType, 'Executing main(), returning');
for (const multiDoerTask of multiDoerTasks) {
const task = typeof multiDoerTask.task === 'string' ?
this.env.getTask(multiDoerTask.task) :
multiDoerTask.task;
let task;
if (typeof multiDoerTask.task === 'string') {
this.env.debug(context, this.moduleType, `Finding task '${multiDoerTask.task}'`);
task = this.env.getTask(multiDoerTask.task);
}
else {
task = multiDoerTask.task;
}
this.env.debug(context, this.moduleType, `Finding doer '${task.doer}'`);
const doer = this.env.getDoer(task.doer);
yield doer.execute(context, task);
if (multiDoerTask.branch) {
this.env.debug(context, this.moduleType, 'Task executed with BranchConfig, compiling it');
const branchConfig = yield object_compiler_1.ObjectCompiler.compile(multiDoerTask.branch, context);
if (!branchConfig.taskName) {
throw new Error(`Invalid BranchConfig for task '${task.name}'`);
this.env.debug(context, this.moduleType, 'No branch task given so doing nothing');
}
const branchTask = this.env.getTask(branchConfig.taskName);
const branchDoer = this.env.getDoer(branchTask.doer);
yield branchDoer.execute(context, branchTask);
else {
this.env.debug(context, this.moduleType, `Branching to task '${branchConfig.taskName}'`);
const branchTask = this.env.getTask(branchConfig.taskName);
this.env.debug(context, this.moduleType, `Loading branch Doer '${branchTask.doer}'`);
const branchDoer = this.env.getDoer(branchTask.doer);
yield branchDoer.execute(context, branchTask);
}
if (branchConfig.haltAfterExecution) {
this.env.debug(context, this.moduleType, 'Halting after execution of Branch task');
break;

@@ -34,0 +47,0 @@ }

import { Connector } from './connectors/connector';
import { CacheManager, CacheConfig } from './cache-managers/cache-manager';
import { Doer } from './doers/doer';
import { Logger, LogLevel } from './loggers/logger';
import { Parser } from './parsers/parser';
import { Renderer } from './renderers/renderer';
import { LogLevel } from './log';
/**

@@ -48,2 +48,3 @@ * The Environment class is the core of a `low` system.

private doers;
private loggers;
/**

@@ -77,2 +78,7 @@ * A collection of [[Parser]] modules. Parsers ensure that any compiled

getTask(name: string): TaskConfig;
log(context: Context | null, level: LogLevel, ...args: any[]): boolean;
debug(context: Context | null, ...args: any[]): void;
info(context: Context | null, ...args: any[]): void;
warn(context: Context | null, ...args: any[]): void;
error(context: Context | null, ...args: any[]): void;
destroy(): Promise<void>;

@@ -90,2 +96,3 @@ }

doers?: Doer<any, any>[];
loggers?: Logger<any, any>[];
parsers?: Parser<any>[];

@@ -97,2 +104,3 @@ renderers?: Renderer<any, any, any>[];

logLevel?: LogLevel;
uid?: string;
[key: string]: any;

@@ -99,0 +107,0 @@ }

@@ -11,6 +11,15 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Crypto = __importStar(require("crypto"));
const connector_1 = require("./connectors/connector");
const cache_manager_1 = require("./cache-managers/cache-manager");
const doer_1 = require("./doers/doer");
const logger_1 = require("./loggers/logger");
const boolean_parser_1 = require("./parsers/boolean-parser");

@@ -25,3 +34,2 @@ const integer_parser_1 = require("./parsers/integer-parser");

const multi_doer_1 = require("./doers/multi-doer");
const log_1 = require("./log");
/**

@@ -55,3 +63,3 @@ * The Environment class is the core of a `low` system.

this.ready = false;
this.logLevel = log_1.LogLevel.ERROR;
this.logLevel = logger_1.LogLevel.ERROR;
/**

@@ -78,2 +86,5 @@ * A collection of [[Connector]] modules. Connectors are gateways from

};
this.loggers = {
Logger: new logger_1.Logger()
};
/**

@@ -115,2 +126,7 @@ * A collection of [[Parser]] modules. Parsers ensure that any compiled

}
if (modules.loggers) {
for (const mod of modules.loggers) {
this.loggers[mod.moduleType] = mod;
}
}
if (modules.parsers) {

@@ -160,2 +176,5 @@ for (const mod of modules.parsers) {

}
for (const mod of Object.values(this.loggers)) {
yield mod.init(this);
}
for (const mod of Object.values(this.parsers)) {

@@ -264,2 +283,60 @@ yield mod.init(this);

}
log(context, level, ...args) {
try {
let contextLogLevel = this.logLevel;
if (typeof context === 'object' && context !== null && typeof context.logLevel === 'number') {
contextLogLevel = context.logLevel;
}
if (level < contextLogLevel) {
return false;
}
let label = 'ENVIRONMENT';
if (typeof context === 'object' && context !== null) {
if (typeof context.uid !== 'string') {
context.uid = Crypto.randomBytes(4).toString('hex');
}
label = context.uid;
}
for (const logger of Object.values(this.loggers)) {
switch (level) {
case (logger_1.LogLevel.DEBUG):
logger.debug(label, ...args).then().catch(err => {
console.error(`Logger Error: '${logger.moduleType}.debug()`, err);
});
break;
case (logger_1.LogLevel.INFO):
logger.info(label, ...args).then().catch(err => {
console.error(`Logger Error: '${logger.moduleType}.info()`, err);
});
break;
case (logger_1.LogLevel.WARN):
logger.warn(label, ...args).then().catch(err => {
console.error(`Logger Error: '${logger.moduleType}.warn()`, err);
});
break;
default:
logger.error(label, ...args).then().catch(err => {
console.error(`Logger Error: '${logger.moduleType}.error()`, err);
});
}
}
return true;
}
catch (err) {
console.error('Logger Error: Failed to initialise log', context, level, ...args);
return false;
}
}
debug(context, ...args) {
this.log(context, logger_1.LogLevel.DEBUG, ...args);
}
info(context, ...args) {
this.log(context, logger_1.LogLevel.INFO, ...args);
}
warn(context, ...args) {
this.log(context, logger_1.LogLevel.WARN, ...args);
}
error(context, ...args) {
this.log(context, logger_1.LogLevel.ERROR, ...args);
}
destroy() {

@@ -279,2 +356,5 @@ return __awaiter(this, void 0, void 0, function* () {

}
for (const mod of Object.values(this.loggers)) {
yield mod.destroy();
}
for (const mod of Object.values(this.parsers)) {

@@ -281,0 +361,0 @@ yield mod.destroy();

@@ -7,3 +7,2 @@ export * from './cache-managers/cache-manager';

export * from './environment';
export * from './log';
export * from './module';

@@ -10,0 +9,0 @@ export * from './object-compiler';

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

__export(require("./environment"));
__export(require("./log"));
__export(require("./module"));

@@ -15,0 +14,0 @@ __export(require("./object-compiler"));

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

Object.defineProperty(exports, "__esModule", { value: true });
//import { Log } from './log';
class Module {

@@ -44,5 +43,5 @@ constructor() {

return __awaiter(this, void 0, void 0, function* () {
//Log.log(env, this.moduleType, `Initialising`);
env.debug(null, this.moduleType, `Initialising`);
if (this._ready) {
//Log.warn(env, this.moduleType, 'Module already initialised. Destroying and re-initialising');
env.warn(null, this.moduleType, 'Module already initialised. Destroying and re-initialising');
yield this.destroy();

@@ -53,8 +52,8 @@ this._ready = false;

this._config = env.config.modules && env.config.modules[this.moduleType] || {};
//Log.log(env, this.moduleType, `Set config:`, this.config);
env.debug(null, this.moduleType, `Set config:`, this.config);
this._secrets = env.secrets.modules && env.secrets.modules[this.moduleType] || {};
//Log.log(env, this.moduleType, `Set secrets:`, this.secrets);
env.debug(null, this.moduleType, `Set secrets:`, this.secrets);
yield this.setup();
this._ready = true;
//Log.log(env, this.moduleType, `Module ready`);
env.debug(null, this.moduleType, `Module ready`);
});

@@ -61,0 +60,0 @@ }

@@ -11,4 +11,11 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Querystring = require("querystring");
const Querystring = __importStar(require("querystring"));
const parser_1 = require("./parser");

@@ -15,0 +22,0 @@ class QuerystringParser extends parser_1.Parser {

{
"name": "low",
"version": "1.1.5",
"version": "1.1.6",
"description": "a templating driven low-code framework for rapid systems development",

@@ -15,3 +15,3 @@ "main": "lib/index.js",

"test": "jest --coverage",
"build": "npm run clean && tsc && npm test && typedoc"
"build": "npm run clean && tsc && npm test"
},

@@ -26,3 +26,10 @@ "author": {

},
"gitHead": "5619c75a2b664f915f0f6ba995c05cb37391abd0"
"gitHead": "35a8c602a51f3daae5ce502f34d672fb2757fd9c",
"devDependencies": {
"@types/jest": "^24.9.0",
"jest": "^24.9.0",
"ts-jest": "^24.3.0",
"typedoc": "^0.16.6",
"typescript": "^3.7.4"
}
}

@@ -7,3 +7,2 @@ export * from './cache-managers/cache-manager';

export * from './environment';
export * from './log';
export * from './module';

@@ -10,0 +9,0 @@ export * from './object-compiler';

{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"declaration": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es6",
"resolveJsonModule": true,
"skipLibCheck": true
"outDir": "lib"
},

@@ -14,0 +6,0 @@ "compileOnSave": true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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