You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

odata-json-schema

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

odata-json-schema - npm Package Compare versions

Comparing version

to
0.0.5

@@ -12,4 +12,10 @@ {

"program": "${workspaceFolder}/__test__/index.js"
},
{
"type": "node",
"request": "launch",
"name": "Bundle Schemas",
"program": "${workspaceFolder}/bundle.js"
}
]
}
const fs = require('fs');
const path = require('path');
const util = require('util');
const glob = util.promisify(require('glob'));
const mkdirp = util.promisify(require('mkdirp'));

@@ -16,3 +17,3 @@ const writeFile = util.promisify(fs.writeFile);

}
return !ref.startsWith('Edm');
return !ref.startsWith('Edm')
},

@@ -29,4 +30,4 @@ withEnumValue = false,

if (Object.getOwnPropertyNames(schemas[namespace]).length) {
const namespacePath = path.join(dist, parseFullName(namespace));
await mkdirp(namespacePath);
const namespacePath = path.join(dist, parseFullName(namespace))
await mkdirp(namespacePath)
for (const name in schemas[namespace]) {

@@ -41,14 +42,14 @@ await writeFile(path.join(namespacePath, `${name}.json`), JSON.stringify(schemas[namespace][name], null, 2));

function loadRawSchema(name) {
return require(`./dist/${name}`);
return require(`./dist/${name}`)
}
const queue = [startingPoint];
const visited = new Set(queue);
const navigableSchemas = [];
const queue = [startingPoint]
const visited = new Set(queue)
const navigableSchemas = []
while (queue.length) {
const first = queue.shift();
navigableSchemas.push(first);
const first = queue.shift()
navigableSchemas.push(first)
const schema = loadRawSchema(first);
const schema = loadRawSchema(first)
for (let property of schema.$$ODataExtension.NavigationProperty || []) {

@@ -58,6 +59,6 @@ const propertySchema = schema.properties[property];

propertySchema.items.$ref :
propertySchema.$ref;
propertySchema.$ref
if (typeof refType === 'string' && !visited.has(refType)) {
queue.push(refType);
visited.add(refType);
queue.push(refType)
visited.add(refType)
}

@@ -67,6 +68,20 @@ }

return
return navigableSchemas;
}
async function bundle(root, {
dist = 'schemas.json',
} = {}) {
const files = await glob('**/*.json', {
cwd: root
})
const bundled = {}
for (const file of files) {
bundled[file.substr(0, file.length - '.json'.length)] = require(`./${root}/${file}`);
}
await writeFile(dist, JSON.stringify(bundled))
}
module.exports.generateJSONSchema = generateJSONSchema
module.exports.findNavigableSchemas = findNavigableSchemas
module.exports.findNavigableSchemas = findNavigableSchemas
module.exports.bundle = bundle
{
"name": "odata-json-schema",
"version": "0.0.4",
"version": "0.0.5",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": {