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

impress

Package Overview
Dependencies
Maintainers
4
Versions
719
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impress - npm Package Compare versions

Comparing version 2.0.9 to 2.0.10

schemas/.eslintrc.json

11

CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

## [2.0.10][] - 2021-02-24
- Fix bug in Procedure locking with semaphore
- Procedure execution timeout
- Schema custom validation method
- Support nested schemas
- Added config schemas
## [2.0.9][] - 2021-02-19

@@ -89,3 +97,4 @@

[unreleased]: https://github.com/metarhia/impress/compare/v2.0.9...HEAD
[unreleased]: https://github.com/metarhia/impress/compare/v2.0.10...HEAD
[2.0.10]: https://github.com/metarhia/impress/compare/v2.0.9...v2.0.10
[2.0.9]: https://github.com/metarhia/impress/compare/v2.0.8...v2.0.9

@@ -92,0 +101,0 @@ [2.0.8]: https://github.com/metarhia/impress/compare/v2.0.7...v2.0.8

'use strict';
const { Semaphore } = require('./dependencies.js').metarhia.metautil;
const { metautil } = require('./dependencies.js').metarhia;
const { Semaphore, createAbortController } = metautil;

@@ -31,3 +32,3 @@ const { Schema } = require('./schema.js');

} catch (err) {
this.application.semaphore.leave();
this.application.server.semaphore.leave();
throw err;

@@ -44,3 +45,3 @@ }

async invoke(context, args = {}) {
const { script, parameters, returns } = this;
const { script, parameters, validate, returns, timeout } = this;
const exp = script(context);

@@ -52,3 +53,16 @@ const method = typeof exp === 'object' ? exp.method : exp;

}
const result = await method(args);
if (validate) {
validate(args);
}
let result;
if (timeout) {
const ac = createAbortController();
result = await Promise.race([
metautil.timeout(timeout, ac.signal),
method(args),
]);
ac.abort();
} else {
result = await method(args);
}
if (result instanceof this.application.Error) return result;

@@ -55,0 +69,0 @@ if (returns) {

@@ -81,6 +81,11 @@ 'use strict';

const def = short ? { type: value } : value;
if (!def.type) {
const { unique, index, primary } = def;
if (Array.isArray(unique || index || primary)) {
this.indexes[key] = def;
continue;
}
if (!def.type) {
this.fields[key] = Schema.from(def);
continue;
}
if (!Reflect.has(def, 'required')) def.required = true;

@@ -112,8 +117,17 @@ if (def.length) {

const def = this.fields[name];
if (!def) errors.push(`Field "${name}" is not expected`);
const errs = check(name, def, value);
if (errs.length > 0) errors.push(...errs);
if (def instanceof Schema) {
const subcheck = def.check(value);
if (!subcheck.valid) errors.push(...subcheck.errors);
continue;
}
if (!def) {
errors.push(`Field "${name}" is not expected`);
continue;
}
if (def.required && !keys.includes(name)) {
errors.push(`Field "${name}" is required`);
continue;
}
const errs = check(name, def, value);
if (errs.length > 0) errors.push(...errs);
}

@@ -120,0 +134,0 @@ return { valid: errors.length === 0, errors };

11

package.json
{
"name": "impress",
"version": "2.0.9",
"version": "2.0.10",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",

@@ -50,3 +50,4 @@ "description": "Impress application server for Node.js and Metarhia private cloud",

"files": [
"lib/"
"lib/",
"schemas/"
],

@@ -63,5 +64,5 @@ "scripts": {

"@metarhia/config": "^2.1.0",
"metacom": "^1.5.1",
"metacom": "^1.5.2",
"metalog": "^3.1.0",
"metautil": "^3.3.0",
"metautil": "^3.5.0",
"metavm": "^1.0.0"

@@ -72,3 +73,3 @@ },

"eslint-config-metarhia": "^7.0.1",
"eslint-config-prettier": "^7.2.0",
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-import": "^2.22.1",

@@ -75,0 +76,0 @@ "eslint-plugin-impress": "^2.3.1",

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