Comparing version 2.0.8 to 2.0.9
@@ -5,2 +5,7 @@ # Changelog | ||
## [2.0.9][] - 2021-02-19 | ||
- Extract Procedure class from Application | ||
- Update metautil to 3.3.0 and metacom to 1.5.1 | ||
## [2.0.8][] - 2021-02-17 | ||
@@ -84,3 +89,4 @@ | ||
[unreleased]: https://github.com/metarhia/impress/compare/v2.0.8...HEAD | ||
[unreleased]: https://github.com/metarhia/impress/compare/v2.0.9...HEAD | ||
[2.0.9]: https://github.com/metarhia/impress/compare/v2.0.8...v2.0.9 | ||
[2.0.8]: https://github.com/metarhia/impress/compare/v2.0.7...v2.0.8 | ||
@@ -87,0 +93,0 @@ [2.0.7]: https://github.com/metarhia/impress/compare/v2.0.6...v2.0.7 |
@@ -6,5 +6,4 @@ 'use strict'; | ||
const { metautil, metavm } = metarhia; | ||
const { Schema } = require('./schema.js'); | ||
const { Procedure } = require('./procedure.js'); | ||
const EMPTY_CONTEXT = Object.freeze({}); | ||
const MODULE = 2; | ||
@@ -127,13 +126,2 @@ const win = process.platform === 'win32'; | ||
preprocessProc(script) { | ||
const exp = script(EMPTY_CONTEXT); | ||
if (typeof exp === 'object') { | ||
let { parameters, returns } = exp; | ||
if (parameters) parameters = Schema.from(parameters); | ||
if (returns) returns = Schema.from(returns); | ||
return { ...exp, parameters, returns, script }; | ||
} | ||
return { method: exp, script }; | ||
} | ||
async loadMethod(fileName) { | ||
@@ -149,3 +137,3 @@ const rel = fileName.substring(this.apiPath.length + 1); | ||
if (!script) return; | ||
const proc = this.preprocessProc(script); | ||
const proc = new Procedure(script, this); | ||
let iface = this.api[iname]; | ||
@@ -225,18 +213,2 @@ const { api } = this.sandbox; | ||
async invoke(context, proc, args = {}) { | ||
const exp = proc.script(context); | ||
const method = typeof exp === 'object' ? exp.method : exp; | ||
if (proc.parameters) { | ||
const { valid } = proc.parameters.check(args); | ||
if (!valid) return new Error('Invalid parameter type'); | ||
} | ||
const result = await method(args); | ||
if (result instanceof this.Error) return result; | ||
if (proc.returns) { | ||
const { valid } = proc.returns.check(result); | ||
if (!valid) return new Error('Invalid result type'); | ||
} | ||
return result; | ||
} | ||
async loadFile(filePath) { | ||
@@ -243,0 +215,0 @@ let key = filePath.substring(this.staticPath.length); |
{ | ||
"name": "impress", | ||
"version": "2.0.8", | ||
"version": "2.0.9", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -62,5 +62,5 @@ "description": "Impress application server for Node.js and Metarhia private cloud", | ||
"@metarhia/config": "^2.1.0", | ||
"metacom": "^1.4.0", | ||
"metacom": "^1.5.1", | ||
"metalog": "^3.1.0", | ||
"metautil": "^3.2.0", | ||
"metautil": "^3.3.0", | ||
"metavm": "^1.0.0" | ||
@@ -67,0 +67,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35978
13
739
Updatedmetacom@^1.5.1
Updatedmetautil@^3.3.0