quanstructor
Advanced tools
Comparing version 0.4.20 to 0.4.21
{ | ||
"name": "quanstructor", | ||
"version": "0.4.20", | ||
"version": "0.4.21", | ||
"description": "Exceptionally powerful object model builder for complex architectures", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -248,2 +248,25 @@ let { defined } = require('./lib/Statics') | ||
}, | ||
async schema ( name, projection = 'complete', options = {} ) { | ||
let res = await this.proto( projection, options ) | ||
function walk (object, embedded = false) { | ||
if ( !defined(object) ) return { type: 'object' } | ||
if ( _.isNumber( object ) ) return { type: 'number' } | ||
if ( _.isString( object ) ) return { type: 'integer' } | ||
if ( _.isBoolean( object ) ) return { type: 'boolean' } | ||
if ( _.isArray( object ) ) return { type: 'array' } | ||
if ( _.isObject( object ) ) { | ||
let sd = embedded ? { } : { title: name, type: 'object', properties: { } } | ||
let props = embedded ? sd : sd.properties | ||
for (let key in object) | ||
props[ key ] = walk( object[key], true ) | ||
return sd | ||
} | ||
else return { type: 'object' } | ||
} | ||
return walk( res, false ) | ||
}, | ||
async derive ( obj, projection = 'complete', options = {} ) { | ||
@@ -250,0 +273,0 @@ return this.bridge( obj, projection, options.view || projection, options ) |
@@ -68,2 +68,4 @@ const Quastructor = require( '../Quanstructor' ) | ||
} ) | ||
console.log( 'SCHEMA::::::', await Absoluter.schema( 'Emp' ) ) | ||
console.log( JSON.stringify( await Absoluter.build( { | ||
@@ -70,0 +72,0 @@ employeeID: '121212', |
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
23706
649