metaschema
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -42,20 +42,26 @@ 'use strict'; | ||
class Log extends Decorator {} | ||
class View extends Decorator {} | ||
module.exports = { | ||
// Field decorators | ||
Enum: (...values) => new Enum(values), | ||
Many: def => new Many(def), | ||
Parent: def => new Parent(def), | ||
Master: def => new Master(def), | ||
Include: def => new Include(def), | ||
// Index decorators | ||
Index: (...values) => new Index(values), | ||
Unique: (...fields) => new Unique(fields), | ||
// Validation function decorator | ||
Validate: fn => Object.setPrototypeOf(fn, Validate), | ||
// Entity decorators | ||
Registry: def => new Registry(def), | ||
Dictionary: def => new Dictionary(def), | ||
System: def => new System(def), | ||
Log: def => new Log(def) | ||
entity: { | ||
// Entity decorators | ||
Registry: def => new Registry(def), | ||
Dictionary: def => new Dictionary(def), | ||
System: def => new System(def), | ||
Log: def => new Log(def), | ||
View: def => new View(def) | ||
}, | ||
attribute: { | ||
// Field decorators | ||
Enum: (...values) => new Enum(values), | ||
Many: def => new Many(def), | ||
Parent: def => new Parent(def), | ||
Master: def => new Master(def), | ||
Include: def => new Include(def), | ||
// Index decorators | ||
Index: (...fields) => new Index(fields), | ||
Unique: (...fields) => new Unique(fields), | ||
// Validation function decorator | ||
Validate: fn => Object.setPrototypeOf(fn, Validate) | ||
} | ||
}; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { basename } = require('path'); | ||
@@ -11,2 +12,4 @@ const metasync = require('metasync'); | ||
const decorators = require('./decorators.js'); | ||
const moduleDir = path.dirname(__dirname); | ||
const schemasDir = moduleDir + '/schemas/'; | ||
@@ -56,3 +59,3 @@ const SCRIPT_TIMEOUT = 2000; | ||
) => { | ||
if (!path.includes('/')) path = './schemas/' + path; | ||
if (!path.includes('/')) path = schemasDir + path; | ||
const schemas = {}; | ||
@@ -95,8 +98,12 @@ fs.readdir(path, (err, files) => { | ||
Object.assign(structs, decorators, { | ||
List: category => items => items.map( | ||
item => createInstance(category, item) | ||
) | ||
}); | ||
decorators.attribute.List = category => items => items.map( | ||
item => createInstance(category, item) | ||
); | ||
Object.assign( | ||
structs, | ||
decorators.entity, | ||
decorators.attribute | ||
); | ||
const min = (a, b) => (a < b ? a : b); | ||
@@ -245,3 +252,3 @@ | ||
loadSchema('./schemas/CategoryField.schema', (err, schema) => { | ||
loadSchema(schemasDir + 'CategoryField.schema', (err, schema) => { | ||
if (err) throw err; | ||
@@ -251,3 +258,3 @@ build({ CategoryField: schema }); | ||
loadSchema('./schemas/domains.schema', (err, schema) => { | ||
loadSchema(schemasDir + 'domains.schema', (err, schema) => { | ||
if (err) throw err; | ||
@@ -266,2 +273,3 @@ for (const name in schema) { | ||
categories, | ||
decorators, | ||
createInstance, | ||
@@ -268,0 +276,0 @@ validate, |
{ | ||
"name": "metaschema", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Metadata Schema and Interface Definition Language (IDL)", |
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
31125
632