From 06d7a7979fa4c6071437778a14875c6f6f02c5de Mon Sep 17 00:00:00 2001 From: Evgeny Metelkin Date: Fri, 28 Jun 2024 19:57:44 +0300 Subject: [PATCH] null in properties of `Component` --- TODO.md | 2 +- cases/27-null/.gitattributes | 34 ++++ cases/27-null/.gitignore | 11 + cases/27-null/platform.json | 12 ++ cases/27-null/src/index.heta | 19 ++ package-lock.json | 6 +- package.json | 2 +- src/container/actions.js | 3 +- src/core/_size.js | 4 +- src/core/_switcher.js | 10 +- src/core/c-switcher.js | 4 +- src/core/compartment.js | 4 +- src/core/component.js | 24 ++- src/core/const.js | 30 ++- src/core/d-switcher.js | 4 +- src/core/page.js | 6 +- src/core/process.js | 12 +- src/core/reaction.js | 25 ++- src/core/record.js | 20 +- src/core/reference-definition.js | 12 +- src/core/species.js | 12 +- src/core/stop-switcher.js | 4 +- src/core/time-scale.js | 18 +- src/core/time-switcher.js | 15 +- src/heta.json-schema.json | 278 ++++++++++++++------------ test/schema/function-definition.json | 8 - test/schema/index.js | 5 - test/schema/monteCarloTask-error.json | 30 --- test/schema/monteCarloTask.json | 20 -- 29 files changed, 395 insertions(+), 239 deletions(-) create mode 100644 cases/27-null/.gitattributes create mode 100644 cases/27-null/.gitignore create mode 100644 cases/27-null/platform.json create mode 100644 cases/27-null/src/index.heta delete mode 100644 test/schema/function-definition.json delete mode 100644 test/schema/monteCarloTask-error.json delete mode 100644 test/schema/monteCarloTask.json diff --git a/TODO.md b/TODO.md index 2513ba24..cc72ba1c 100644 --- a/TODO.md +++ b/TODO.md @@ -41,7 +41,7 @@ - write reusable `Build` class - alternative solution to substitute "pkg": Node.js 21 https://nodejs.org/api/single-executable-applications.html wait until Node.js 22 will be released -- support `null` for properties: highlight, parse, heta standard +- support `null` for properties: highlight, heta standard ## ideas diff --git a/cases/27-null/.gitattributes b/cases/27-null/.gitattributes new file mode 100644 index 00000000..27dae8bf --- /dev/null +++ b/cases/27-null/.gitattributes @@ -0,0 +1,34 @@ +### Basic .gitattributes for a Heta repo. +# Note that binary is a macro for -text -diff. + +* text=auto + +# main files +# to have heta files in linux style line endings +*.heta text eol=lf +*.xlsx binary + +# auxilary files +*.bash text eol=lf +*.sh text eol=lf +*.xlsm binary +*.xls binary +*.pptx binary +*.ppt binary + +# code +*.md text +*.m text +# -diff +*.slv text eol=crlf diff=slv +*.dat text eol=crlf diff=dat +*.cpp text +*.svg text diff=xml +*.xml text diff=xml +*.sbml text diff=xml + +# LFS (large files) +large/* filter=lfs diff=lfs merge=lfs -text +literature/* filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text diff --git a/cases/27-null/.gitignore b/cases/27-null/.gitignore new file mode 100644 index 00000000..ce522c01 --- /dev/null +++ b/cases/27-null/.gitignore @@ -0,0 +1,11 @@ +### Heta specific files and dirs +/dist +/draft +/drafts +/meta + +### temporal files +*.tmp +~$*.* +*.log +.Rhistory diff --git a/cases/27-null/platform.json b/cases/27-null/platform.json new file mode 100644 index 00000000..2b0ca80a --- /dev/null +++ b/cases/27-null/platform.json @@ -0,0 +1,12 @@ +{ + "builderVersion": "^0.8.4", + "id": "template", + "notes": "platform notes", + "version": "v0.1.0", + "license": "UNLICENSED", + "options": {}, + "importModule": { + "type": "heta", + "source": "src/index.heta" + } +} diff --git a/cases/27-null/src/index.heta b/cases/27-null/src/index.heta new file mode 100644 index 00000000..9d46249a --- /dev/null +++ b/cases/27-null/src/index.heta @@ -0,0 +1,19 @@ +/* + template file for creating platform +*/ + +#defineFunction xxx { + arguments: [x,y,z], + math: null +}; + +p1 @Record 'This is title' .= 1; +p1 := 2; + +p1 {title: null}; +p1 .= null; +//p1 := null; +p1 [xxx]= null; + +// exports +#export { format: JSON, filepath: output }; diff --git a/package-lock.json b/package-lock.json index b3cf1b59..c6a85fe8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2146,9 +2146,9 @@ "dev": true }, "heta-parser": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/heta-parser/-/heta-parser-0.3.18.tgz", - "integrity": "sha512-nOyiGi1N6JVmN/zxyDaYYwXlipJnm0NElVG2twwj3Z6aTH2NdpT5GVZAMRQaZlLEVMZ4glWDLpPjy3CeyRU3Og==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/heta-parser/-/heta-parser-0.4.0.tgz", + "integrity": "sha512-Qk7Bnirbg5ombRQ4aBzR/KF7cvUQxw4zr5dWcpQeRtOomgmTQ/b23U2yR3Z5bJ8dE5WR82NyonxI24AtG1T2aA==", "requires": { "commander": "^11.1.0", "pegjs": "^0.10.0" diff --git a/package.json b/package.json index e01f2e1a..0053928f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "colors": "^1.4.0", "commander": "^11.1.0", "fs-extra": "^11.1.1", - "heta-parser": "^0.3.18", + "heta-parser": "^0.4.0", "inquirer": "^8.2.6", "js-yaml": "^4.1.0", "lodash": "^4.17.21", diff --git a/src/container/actions.js b/src/container/actions.js index b430a790..6314849e 100644 --- a/src/container/actions.js +++ b/src/container/actions.js @@ -6,7 +6,8 @@ const reservedWords = [ 'include', 'block', 'namespace', 'abstract', 'concrete', 'begin', 'end', 'NaN', 'Infinity', 'e', 'E', 'pi', 'PI', - 'time', 'SOLVERTIME', 'default' // mrgsolve specific reserved words + 'time', 'SOLVERTIME', 'default', // mrgsolve specific reserved words + 'null' ]; /** diff --git a/src/core/_size.js b/src/core/_size.js index 0103c3dc..6b574eec 100644 --- a/src/core/_size.js +++ b/src/core/_size.js @@ -20,7 +20,7 @@ class _Size extends Component { let logger = this.namespace?.container?.logger; let valid = _Size.isValid(q, logger); if (valid) { - if (q.units) { + if (q.units !== undefined) { if (q.units === 1) { this.unitsParsed = new Unit(); } else if (typeof q.units === 'string') { @@ -30,6 +30,8 @@ class _Size extends Component { let msg = this.index + ': '+ e.message; logger && logger.error(msg, {type: 'ValidationError', space: this.space}); } + } else if (q.unit === null) { + delete this.unitsParsed; } else { this.unitsParsed = Unit.fromQ(q.units); } diff --git a/src/core/_switcher.js b/src/core/_switcher.js index fda15734..b26d38d4 100644 --- a/src/core/_switcher.js +++ b/src/core/_switcher.js @@ -18,10 +18,16 @@ class _Switcher extends Component { let valid = _Switcher.isValid(q, logger); if (valid) { - if (typeof q.atStart !== 'undefined') { + if (q.atStart === null) { + delete this.atStart; + } else if (typeof q.atStart !== 'undefined') { this.atStart = !!q.atStart; } - q.active !== undefined && (this.active = !!q.active); + if (q.active === null) { + delete this.active; + } else if (q.active !== undefined) { + this.active = !!q.active; + } } return this; diff --git a/src/core/c-switcher.js b/src/core/c-switcher.js index 5e6af6a7..c3470ee3 100644 --- a/src/core/c-switcher.js +++ b/src/core/c-switcher.js @@ -15,7 +15,9 @@ class CSwitcher extends _Switcher { let valid = CSwitcher.isValid(q, logger); if (valid) { - if (typeof q.trigger !== 'undefined') { + if (q.trigger === null) { + delete this.trigger; + } else if (typeof q.trigger !== 'undefined') { try { // this is for the cases of wrong ExprString structure let expr = Expression.fromString(q.trigger); if (!expr.hasBooleanResult()) { diff --git a/src/core/compartment.js b/src/core/compartment.js index a789e01a..7c29cd12 100644 --- a/src/core/compartment.js +++ b/src/core/compartment.js @@ -14,8 +14,8 @@ class Compartment extends Record { } merge(q = {}){ super.merge(q); - let logger = this.namespace?.container?.logger; - let valid = Compartment.isValid(q, logger); + //let logger = this.namespace?.container?.logger; + //let valid = Compartment.isValid(q, logger); return this; } diff --git a/src/core/component.js b/src/core/component.js index f193e48f..253897cc 100644 --- a/src/core/component.js +++ b/src/core/component.js @@ -25,10 +25,26 @@ class Component { let valid = Component.isValid(q, logger); if (valid) { - if (q.title) this.title = q.title; - if (q.notes) this.notes = q.notes.trim(); // remove trailing symbols - if (q.tags) this.tags = q.tags.map((tag) => tag); // clone - if (q.aux) this.aux = cloneDeep(q.aux); + if (q.title === null) { + delete this.title; + } else if (q.title !== undefined) { + this.title = q.title; + } + if (q.notes === null) { + delete this.notes; + } else if (q.notes !== undefined) { + this.notes = q.notes.trim(); // remove trailing symbols + } + if (q.tags === null) { + this.tags = []; + } else if (q.tags !== undefined) { + this.tags = q.tags.map((tag) => tag); // clone + } + if (q.aux === null) { + this.aux = {}; + } else if (q.aux) { + this.aux = cloneDeep(q.aux); + } } return this; diff --git a/src/core/const.js b/src/core/const.js index 7bab7b24..e80167ea 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -21,11 +21,31 @@ class Const extends _Size { // implicit extend Numeric let valid = Const.isValid(q, logger); if (valid) { - if (q.num !== undefined) this.num = q.num; - if (q.free !== undefined) this.free = !!q.free; - if (q.scale !== undefined) this.scale = q.scale; - if (q.lower !== undefined) this.lower = q.lower; - if (q.upper !== undefined) this.upper = q.upper; + if (q.num === null) { + delete this.num; + } else if (q.num !== undefined) { + this.num = q.num + }; + if (q.free === null) { + delete this.free; + } else if (q.free !== undefined) { + this.free = !!q.free; + } + if (q.scale === null) { + delete this.scale; + } else if (q.scale !== undefined) { + this.scale = q.scale; + } + if (q.lower === null) { + delete this.lower; + } else if (q.lower !== undefined) { + this.lower = q.lower; + } + if (q.upper === null) { + delete this.upper; + } else if (q.upper !== undefined) { + this.upper = q.upper; + } } return this; diff --git a/src/core/d-switcher.js b/src/core/d-switcher.js index 9997914d..ac86e5f4 100644 --- a/src/core/d-switcher.js +++ b/src/core/d-switcher.js @@ -17,7 +17,9 @@ class DSwitcher extends _Switcher { let valid = DSwitcher.isValid(q, logger); if (valid) { - if (typeof q.trigger !== 'undefined') { + if (q.trigger === null) { + delete this.trigger; + } else if (typeof q.trigger !== 'undefined') { q.trigger += ''; try { // this is for the cases of wrong ExprString structure let expr = Expression.fromString(q.trigger); diff --git a/src/core/page.js b/src/core/page.js index 7c21bcc4..c8db9d03 100644 --- a/src/core/page.js +++ b/src/core/page.js @@ -7,7 +7,11 @@ class Page extends Component { let valid = Page.isValid(q, logger); if (valid) { - if (q.content) this.content = q.content; + if (q.content === null) { + delete this.content; + } else if (q.content !== undefined) { + this.content = q.content; + } } return this; diff --git a/src/core/process.js b/src/core/process.js index e3a9dd2c..7ffb95db 100644 --- a/src/core/process.js +++ b/src/core/process.js @@ -22,10 +22,12 @@ class Process extends Record { let valid = Process.isValid(q, logger); if (valid) { - if (q.actors) { - if(q.actors instanceof Array){ + if (q.actors !== undefined) { + if (q.actors instanceof Array) { this.actors = q.actors .map((q) => new Actor(q)); + } else if (q.actors === null) { + this.actors = []; } else { let { targetArray, isReversible } = rct2actors(q.actors); this.actors = targetArray @@ -33,7 +35,11 @@ class Process extends Record { this.reversible = isReversible; } } - if (q.reversible !== undefined) this.reversible = !!q.reversible; + if (q.reversible === null) { + this.reversible = true; + } else if (q.reversible !== undefined) { + this.reversible = !!q.reversible; + } } return this; diff --git a/src/core/reaction.js b/src/core/reaction.js index 6033e732..c697b935 100644 --- a/src/core/reaction.js +++ b/src/core/reaction.js @@ -22,18 +22,23 @@ class Reaction extends Process { let valid = Reaction.isValid(q, logger); if (valid) { - if (q.modifiers) { - this.modifiers = q.modifiers - .map((mod) => { - if (typeof mod==='string') { - return new Modifier({target: mod}); - } else { - return new Modifier(mod); - } - }); + if (q.modifiers === null) { + this.modifiers = []; + } else if (q.modifiers !== undefined) { + this.modifiers = q.modifiers.map((mod) => { + if (typeof mod==='string') { + return new Modifier({target: mod}); + } else { + return new Modifier(mod); + } + }); } - if (q.compartment !== undefined) this.compartment = q.compartment; + if (q.compartment === null) { + delete this.compartment; + } else if (q.compartment !== undefined) { + this.compartment = q.compartment; + } } return this; diff --git a/src/core/record.js b/src/core/record.js index 51332d50..ba7a85cc 100644 --- a/src/core/record.js +++ b/src/core/record.js @@ -36,15 +36,29 @@ class Record extends _Size { let msg = this.index + ': '+ e.message + ` in "${x.toString()}"`; logger && logger.error(msg, {type: 'ValidationError', space: this.space}); } + } else if (x === null) { + delete this.assignments[key]; } else { throw new Error('Wrong expression argument.'); // if code is OK never throws } }); } - if (q.boundary !== undefined) this.boundary = !!q.boundary; - if (q.ss !== undefined) this.ss = !!q.ss; - if (q.output !== undefined) this.output = !!q.output; + if (q.boundary === null) { + delete this.boundary; + } else if (q.boundary !== undefined) { + this.boundary = !!q.boundary; + } + if (q.ss === null) { + delete this.ss; + } else if (q.ss !== undefined) { + this.ss = !!q.ss; + } + if (q.output === null) { + delete this.output; + } else if (q.output !== undefined) { + this.output = !!q.output; + } } return this; diff --git a/src/core/reference-definition.js b/src/core/reference-definition.js index d7eb7d5e..eea7c540 100644 --- a/src/core/reference-definition.js +++ b/src/core/reference-definition.js @@ -7,8 +7,16 @@ class ReferenceDefinition extends Component { let valid = ReferenceDefinition.isValid(q, logger); if (valid) { - if(q.prefix) this.prefix = q.prefix; - if(q.suffix) this.suffix = q.suffix; + if (q.prefix === null) { + delete this.prefix; + } else if (q.prefix !== undefined) { + this.prefix = q.prefix; + } + if (q.suffix === null) { + delete this.suffix; + } else if (q.suffix !== undefined) { + this.suffix = q.suffix; + } } return this; diff --git a/src/core/species.js b/src/core/species.js index 01dc7492..c9ef07a2 100644 --- a/src/core/species.js +++ b/src/core/species.js @@ -17,8 +17,16 @@ class Species extends Record { let valid = Species.isValid(q, logger); if (valid) { - if (q.compartment !== undefined) this.compartment = q.compartment; - if (q.isAmount !== undefined) this.isAmount = !!q.isAmount; + if (q.compartment === null) { + delete this.compartment; + } else if (q.compartment !== undefined) { + this.compartment = q.compartment; + } + if (q.isAmount === null) { + delete this.isAmount; + } else if (q.isAmount !== undefined) { + this.isAmount = !!q.isAmount; + } } return this; diff --git a/src/core/stop-switcher.js b/src/core/stop-switcher.js index 52786e68..37235875 100644 --- a/src/core/stop-switcher.js +++ b/src/core/stop-switcher.js @@ -17,7 +17,9 @@ class StopSwitcher extends _Switcher { let valid = StopSwitcher.isValid(q, logger); if (valid) { - if (typeof q.trigger !== 'undefined') { + if (q.trigger === null) { + delete this.trigger; + } else if (typeof q.trigger !== 'undefined') { q.trigger += ''; try { // this is for the cases of wrong ExprString structure let expr = Expression.fromString(q.trigger); diff --git a/src/core/time-scale.js b/src/core/time-scale.js index be99f1d8..69391c51 100644 --- a/src/core/time-scale.js +++ b/src/core/time-scale.js @@ -24,9 +24,21 @@ class TimeScale extends _Size { // implicit extend Numeric let valid = TimeScale.isValid(q, logger); if (valid) { - if (q.slope !== undefined) this.slope = q.slope; - if (q.intercept !== undefined) this.intercept = q.intercept; - if (q.output !== undefined) this.output = !!q.output; + if (q.slope === null) { + this.slope = 1; + } else if (q.slope !== undefined) { + this.slope = q.slope; + } + if (q.intercept === null) { + this.intercept = 0; + } else if (q.intercept !== undefined) { + this.intercept = q.intercept; + } + if (q.output === null) { + delete this.output; + } else if (q.output !== undefined) { + this.output = !!q.output; + } } return this; diff --git a/src/core/time-switcher.js b/src/core/time-switcher.js index e2b6053d..f375ba58 100644 --- a/src/core/time-switcher.js +++ b/src/core/time-switcher.js @@ -33,21 +33,30 @@ class TimeSwitcher extends _Switcher { if (valid) { // empty means anon 0 as default - if (typeof q.start === 'string'){ + if (q.start === null) { + delete this.start; + this.startObj = (new Const).merge({ num: 0 }); + } else if (typeof q.start === 'string') { this.start = q.start; } else if (typeof q.start === 'number') { delete this.start; this.startObj = (new Const).merge({ num: q.start }); } // empty is same as 0 - if (typeof q.period === 'string'){ + if (q.period === null) { + delete this.period; + delete this.periodObj; + } else if (typeof q.period === 'string'){ this.period = q.period; } else if (typeof q.period === 'number') { delete this.period; this.periodObj = (new Const).merge({ num: q.period }); } // empty is the same as Infinity - if (typeof q.stop === 'string'){ + if (q.stop === null) { + delete this.stop; + delete this.stopObj; + } else if (typeof q.stop === 'string'){ this.stop = q.stop; } else if (typeof q.stop === 'number') { delete this.stop; diff --git a/src/heta.json-schema.json b/src/heta.json-schema.json index e1fbe19f..9b24b970 100644 --- a/src/heta.json-schema.json +++ b/src/heta.json-schema.json @@ -40,7 +40,8 @@ "additionalProperties": { "oneOf": [ { "$ref": "#/definitions/ExprString" }, - { "type": "number"} + { "type": "number"}, + { "type": "null" } ] }, "example": { @@ -86,10 +87,22 @@ "properties": { "class": { "type": "string" }, "id": { "$ref": "#/definitions/ID" }, - "title": { "type": "string" }, - "notes": { "type": "string" }, - "tags": { "type": "array", "items": { "type": "string" } }, - "aux": { "type": "object" } + "title": {"oneOf": [ + { "type": "null" }, + { "type": "string" } + ]}, + "notes": {"oneOf": [ + { "type": "null" }, + { "type": "string" } + ]}, + "tags": {"oneOf": [ + { "type": "null" }, + { "type": "array", "items": { "type": "string" } } + ]}, + "aux": {"oneOf": [ + { "type": "null" }, + { "type": "object" } + ]} } }, @@ -106,54 +119,60 @@ "assignments": { "$ref": "#/definitions/AssignmentDict" }, - "boundary": { - "enum": [true, false, 1, 0], "default": false, - "description": "If it is true the record cannot be changed by any process, only by expression in assignments." - }, - "ss": { - "enum": [true, false, 1, 0], - "description": "Steady-State variable" - }, - "output": { - "enum": [true, false, 1, 0], - "description": "Should be the record listed as an output" - } + "boundary": {"oneOf": [ + { + "enum": [true, false, 1, 0], "default": false, + "description": "If it is true the record cannot be changed by any process, only by expression in assignments." + }, + { "type": "null" } + ]}, + "ss": {"oneOf": [ + { + "enum": [true, false, 1, 0], + "description": "Steady-State variable" + }, + { "type": "null" } + ]}, + "output": {"oneOf": [ + { + "enum": [true, false, 1, 0], + "description": "Should be the record listed as an output" + }, + { "type": "null" } + ]} } }, - - "Compartment": { "type": "object" }, - "Species": { "type": "object", "properties": { - "compartment": { - "$ref": "#/definitions/ID" - }, - "isAmount": { - "description": "If it is false then the value represents the concentration, i.e. normalized to compartment.", - "enum": [true, false, 1, 0], - "default": false - } + "compartment": {"oneOf": [ + { "$ref": "#/definitions/ID" }, + { "type": "null" } + ]}, + "isAmount": {"oneOf": [ + { + "description": "If it is false then the value represents the concentration, i.e. normalized to compartment.", + "enum": [true, false, 1, 0], + "default": false + }, + { "type": "null" } + ]} } }, - - "Process": { "type": "object", "properties": { - "assignments": { - "required": ["ode_"] - }, "actors": { "oneOf": [ { "type": "array", "items": {"$ref": "#/definitions/Actor"}, "errorMessage": {"type": "should be an array of actors."}}, - { "$ref": "#/definitions/ProcessExpr" } + { "$ref": "#/definitions/ProcessExpr" }, + { "type": "null"} ] } }, @@ -164,21 +183,25 @@ } }, - - "Reaction": { "type": "object", "properties": { - "reversible": { "enum": [true, false, 1, 0], "default": true }, - "modifiers": { - "type": "array", - "items": { - "oneOf": [ - { "$ref": "#/definitions/Effector" }, - { "$ref": "#/definitions/ID" } - ] - } - } + "reversible": {"oneOf": [ + { "enum": [true, false, 1, 0], "default": true }, + { "type": "null" } + ]}, + "modifiers": {"oneOf": [ + { + "type": "array", + "items": { + "oneOf": [ + { "$ref": "#/definitions/Effector" }, + { "$ref": "#/definitions/ID" } + ] + } + }, + { "type": "null" } + ]} }, "errorMessage": { "properties": { @@ -192,23 +215,32 @@ "_Switcher": { "type": "object", "properties": { - "atStart": { - "description": "If true than the condition will be checked at start_", - "enum": [true, false, 1, 0], - "default": false - }, - "active": { - "description": "if false the event will not run.", - "enum": [true, false, 1, 0], - "default": true - } + "atStart": {"oneOf": [ + { + "description": "If true than the condition will be checked at start_", + "enum": [true, false, 1, 0], + "default": false + }, + { "type": "null" } + ]}, + "active": {"oneOf": [ + { + "description": "if false the event will not run.", + "enum": [true, false, 1, 0], + "default": true + }, + { "type": "null" } + ]} } }, "CSwitcher": { "type": "object", "properties": { - "trigger": { "$ref": "#/definitions/ExprString" } + "trigger": {"oneOf": [ + { "$ref": "#/definitions/ExprString" }, + { "type": "null" } + ]} } }, @@ -217,10 +249,10 @@ "DSwitcher": { "type": "object", "properties": { - "trigger": { - "oneOf": [ + "trigger": {"oneOf": [ { "$ref": "#/definitions/ExprString" }, - { "enum": [true, false, 1, 0] } + { "enum": [true, false, 1, 0] }, + { "type": "null" } ] } } @@ -229,10 +261,10 @@ "StopSwitcher": { "type": "object", "properties": { - "trigger": { - "oneOf": [ + "trigger": {"oneOf": [ { "$ref": "#/definitions/ExprString" }, - { "enum": [true, false, 1, 0] } + { "enum": [true, false, 1, 0] }, + { "type": "null" } ] } } @@ -241,9 +273,18 @@ "TimeSwitcher": { "type": "object", "properties": { - "start": { "$ref" : "#/definitions/ConstInternal" }, - "stop": { "$ref" : "#/definitions/ConstInternal" }, - "period": { "$ref" : "#/definitions/ConstInternal" } + "start": {"oneOf": [ + { "$ref" : "#/definitions/ConstInternal" }, + { "type": "null" } + ]}, + "stop": {"oneOf": [ + { "$ref" : "#/definitions/ConstInternal" }, + { "type": "null" } + ]}, + "period": {"oneOf": [ + { "$ref" : "#/definitions/ConstInternal" }, + { "type": "null" } + ]} } }, @@ -253,25 +294,49 @@ "type": "object", "description": "Input value. Upper and lower describes possible values. Scale describes transformation for fitting.", "properties": { - "free": { "enum": [true, false, 1, 0] }, - "num": { "type": "number" }, - "scale": { "type": "string", "enum": ["direct", "log", "logit"], "default": "direct" }, - "upper": { "type": "number" }, - "lower": { "type": "number" } + "free": {"oneOf": [ + { "enum": [true, false, 1, 0] }, + { "type": "null" } + ]}, + "num": {"oneOf": [ + { "type": "number" }, + { "type": "null" } + ]}, + "scale": {"oneOf": [ + { "type": "string", "enum": ["direct", "log", "logit"], "default": "direct" }, + { "type": "null" } + ]}, + "upper": {"oneOf": [ + { "type": "number" }, + { "type": "null" } + ]}, + "lower": {"oneOf": [ + { "type": "number" }, + { "type": "null" } + ]} } }, - "TimeScale": { + "TimeScale": { "type": "object", "description": "t and other time scales", "properties": { - "slope": { "type": "number", "exclusiveMinimum": 0 }, - "intercept": { "type": "number" }, - "output": { "enum": [true, false, 1, 0] } + "slope": {"oneOf": [ + { "type": "number", "exclusiveMinimum": 0 }, + { "type": "null" } + ]}, + "intercept": {"oneOf": [ + { "type": "number" }, + { "type": "null" } + ]}, + "output": {"oneOf": [ + { "enum": [true, false, 1, 0] }, + { "type": "null" } + ]} } }, - "UnitComponent": { + "UnitComponent": { "type": "object", "required": ["kind"], "properties": { @@ -282,75 +347,36 @@ "example": { "kind": "mole", "multiplier": 1e-6, "exponent": 1 } }, - "_Size": { + "_Size": { "type": "object", "properties": { "units": { "anyOf": [ { "type": "number", "enum": [1] }, { "$ref": "#/definitions/UnitsExpr" }, - { "type": "array", "items": { "$ref": "#/definitions/UnitComponent" } } + { "type": "array", "items": { "$ref": "#/definitions/UnitComponent" } }, + { "type": "null" } ] } } - }, + }, - "ConstInternal": { - "anyOf": [ + "ConstInternal": {"anyOf": [ { "allOf": [ { "$ref": "#/definitions/Const" }, { "required": ["num"] } ] }, { "$ref": "#/definitions/ID" }, - { "type": "number" } + { "type": "number" }, + { "type": "null" } ] - }, - - - - "_Task": { - "type": "object" - }, - - "MonteCarloTask": { - "type": "object", - "properties": { - "statistics": { - "type": "array", - "items": { "$ref": "#/definitions/Statistics" } - } - } }, - - "Page": { "type": "object", "properties": { - "content": { - "type": "string" - } + "content": {"anyOf": [ + { "type": "string" }, + { "type": "null" } + ]} } }, - - - "UnitDef": { - "type": "object", - "properties": { - } - }, - - - - "FunctionDefinition": { - "type": "object", - "properties": { - "arguments": { - "type": "array", - "items": { "$ref": "#/definitions/ID" } - }, - "math": { "$ref": "#/definitions/ExprString" } - } - }, - - - "ReferenceDefinition": { "type": "object", "properties": { diff --git a/test/schema/function-definition.json b/test/schema/function-definition.json deleted file mode 100644 index 6b9094dc..00000000 --- a/test/schema/function-definition.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "class": "FunctionDefinition", - "id": "pow", - "args": ["x", "y"], - "expr": "x^y" - } -] diff --git a/test/schema/index.js b/test/schema/index.js index 6b05f29b..d9f4345e 100644 --- a/test/schema/index.js +++ b/test/schema/index.js @@ -10,8 +10,6 @@ const record = require('./record'); const recordError = require('./record-error'); const process = require('./process'); const processError = require('./process-error'); -const monteCarloTask = require('./monteCarloTask'); -const monteCarloTaskError = require('./monteCarloTask-error'); const page = require('./page'); const pageError = require('./page-error'); //const switcherError = require('./c-switcher-error'); @@ -19,7 +17,6 @@ const timeSwitcher = require('./timeSwitcher'); const timeSwitcherError = require('./timeSwitcher-error'); // unscoped -const functionDefinition = require('./function-definition'); const referenceDefinition = require('./reference-definition'); const const_ = require('./const'); @@ -27,12 +24,10 @@ const const_ = require('./const'); //singleTest('Record', record, recordError); //singleTest('Process', process, processError); //singleTest('CSwitcher', switcher, switcherError); -singleTest('MonteCarloTask', monteCarloTask, monteCarloTaskError); //singleTest('Page', page, pageError); //singleTest('TimeSwitcher', timeSwitcher, timeSwitcherError); // unscoped -singleTest('FunctionDefinition', functionDefinition); singleTest('ReferenceDefinition', referenceDefinition); singleTest('Const', const_); diff --git a/test/schema/monteCarloTask-error.json b/test/schema/monteCarloTask-error.json deleted file mode 100644 index c4baf1b1..00000000 --- a/test/schema/monteCarloTask-error.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "class": "MonteCarloTask", - "id": "tsk6", - "space": "one", - "statistics": [ - {} - ], - "aux": { - "validationResult": { - "num": 0, - "prop": "missingProperty" - } - } - }, - { - "class": "MonteCarloTask", - "id": "tsk7", - "space": "one", - "statistics": [ - {"kind": "xxx"} - ], - "aux": { - "validationResult": { - "num": 0, - "prop": "allowedValues" - } - } - } -] diff --git a/test/schema/monteCarloTask.json b/test/schema/monteCarloTask.json deleted file mode 100644 index f1b43b70..00000000 --- a/test/schema/monteCarloTask.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "class": "MonteCarloTask", - "id": "tsk1", - "space": "one", - "statistics": [ - ] - }, - { - "class": "MonteCarloTask", - "id": "tsk2", - "space": "one", - "statistics": [ - {"kind": "raw"}, - {"kind": "quantile"}, - {"kind": "correlation"}, - {"kind": "mean"} - ] - } -]