@overturebio-stack/lectern-client
Advanced tools
Comparing version 0.2.0 to 1.0.0
@@ -407,5 +407,6 @@ "use strict"; | ||
}; | ||
const ctx = vm_1.default.createContext(); | ||
const validateWithScript = (field, record) => { | ||
try { | ||
const sandbox = { | ||
const args = { | ||
$row: record, | ||
@@ -423,3 +424,2 @@ $field: record[field.name], | ||
: field.restrictions.script; | ||
const ctx = vm_1.default.createContext(sandbox); | ||
let result = { | ||
@@ -430,4 +430,7 @@ valid: false, | ||
for (const scriptString of scripts) { | ||
const script = new vm_1.default.Script(scriptString); | ||
result = script.runInContext(ctx); | ||
const script = getScript(scriptString); | ||
const valFunc = script.runInContext(ctx); | ||
if (!valFunc) | ||
throw new Error('Invalid script'); | ||
result = valFunc(args); | ||
/* Return the first script that's invalid. Otherwise result will be valid with message: 'ok'*/ | ||
@@ -447,2 +450,6 @@ if (!result.valid) | ||
}; | ||
const getScript = (scriptString) => { | ||
const script = new vm_1.default.Script(scriptString); | ||
return script; | ||
}; | ||
const buildError = (errorType, fieldName, index, info = {}) => { | ||
@@ -449,0 +456,0 @@ const errorData = { errorType, fieldName, index, info }; |
{ | ||
"name": "@overturebio-stack/lectern-client", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"files": [ | ||
@@ -36,6 +36,6 @@ "lib/**/*" | ||
"husky": "^3.0.0", | ||
"rimraf": "^2.6.2", | ||
"mocha": "^6.1.4", | ||
"prettier": "^1.19.1", | ||
"pretty-quick": "^1.11.1", | ||
"rimraf": "^2.6.2", | ||
"tslint": "^5.20.1", | ||
@@ -46,9 +46,10 @@ "typedoc": "^0.17.7", | ||
"dependencies": { | ||
"ts-node": "^8.5.4", | ||
"cd": "^0.3.3", | ||
"deep-freeze": "^0.0.1", | ||
"lodash": "^4.17.14", | ||
"node-fetch": "^2.6.0", | ||
"lodash": "^4.17.14", | ||
"node-worker-threads-pool": "^1.2.2", | ||
"promise-tools": "^2.1.0", | ||
"winston": "^3.2.1", | ||
"deep-freeze": "^0.0.1" | ||
"ts-node": "^8.5.4", | ||
"winston": "^3.2.1" | ||
}, | ||
@@ -55,0 +56,0 @@ "prettier": { |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
138515
1499
1
8