Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
process.on('message', (data) => {
const {model, type} = data;
amf.Core.init()
.then(() => modelToDoc(model))
.then((doc) => generateEditingResolvedModel(doc, type))
.then((result) => {
process.send({api: result});
})
.catch((cause) => {
let m = `AMF parser: Unable to resolve AMF ld+json model.\n`;
if (cause.message) {
m += cause.message;
} else if (cause.toString) {
m += cause.toString();
}
process.send({error: m});
});
});
function generateEditingResolvedModel(doc, type) {
const resolver = amf.Core.resolver(type);
doc = resolver.resolve(doc, 'editing');
const generator = amf.Core.generator('AMF Graph', 'application/ld+json');
const opts = amf.render.RenderOptions().withSourceMaps.withCompactUris;
return generator.generateString(doc, opts);
}
_resolve(doc, type) {
this.logger.info('Resolving API model for API components...');
const resolver = amf.Core.resolver(type);
return resolver.resolve(doc, 'editing');
}
/**