metaschema
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -12,4 +12,14 @@ 'use strict'; | ||
class Enum extends ValuesDecorator {} | ||
class Bitmask extends ValuesDecorator {} | ||
const createEnum = (...values) => new Enum(values); | ||
class Flags extends ValuesDecorator { | ||
constructor(values, enumDomain) { | ||
super(values); | ||
this.enum = enumDomain; | ||
} | ||
} | ||
const createFlags = (...values) => new Flags(values); | ||
createFlags.of = enumDomain => new Flags(null, enumDomain); | ||
class Decorator { | ||
@@ -64,2 +74,3 @@ constructor(def) { | ||
class View extends Decorator {} | ||
class Memory extends Decorator {} | ||
@@ -75,3 +86,4 @@ module.exports = { | ||
History: def => new History(def), | ||
View: def => new View(def) | ||
View: def => new View(def), | ||
Memory: def => new Memory(def) | ||
}, | ||
@@ -81,4 +93,4 @@ attribute: { | ||
// Data types | ||
Enum: (...values) => new Enum(values), | ||
Bitmask: (...values) => new Bitmask(values), | ||
Enum: createEnum, | ||
Flags: createFlags, | ||
// Relations | ||
@@ -85,0 +97,0 @@ Many: def => new Many(def), |
@@ -73,2 +73,7 @@ 'use strict'; | ||
const domain = schema[name]; | ||
const decorator = domain.constructor.name; | ||
if (decorator === 'Flags' && domain.enum) { | ||
const enumDomain = schema[domain.enum]; | ||
domain.values = enumDomain.values; | ||
} | ||
domains.set(name, domain); | ||
@@ -75,0 +80,0 @@ } |
{ | ||
"name": "metaschema", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Metadata Schema and Interface Definition Language (IDL)", |
Sorry, the diff of this file is not supported yet
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
32078
664