New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@accordproject/concerto-tools

Package Overview
Dependencies
Maintainers
6
Versions
697
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@accordproject/concerto-tools - npm Package Compare versions

Comparing version 3.0.1-20221116180840 to 3.0.1-20221118155015

57

lib/codegen/fromJsonSchema/cto/inferModel.js

@@ -76,8 +76,9 @@ /*

* Infer a type name for a definition. Examines $id, title and parent declaration
* @param {*} definition the input object
* @param {*} context the processing context
* @param {object} definition - the input object
* @param {*} context - the processing context
* @param {boolean} [skipDictionary] - if true, this function will not use the dictionary help inference
* @returns {string} A name for the definition
* @private
*/
function inferTypeName(definition, context) {
function inferTypeName(definition, context, skipDictionary) {
if (definition.$ref) {

@@ -90,3 +91,8 @@ return normalizeType(definition.$ref);

{ type: definition.title || name };
return normalizeType(type);
if (skipDictionary || context.dictionary.has(normalizeType(type))){
return normalizeType(type);
}
// We fallback to a stringified object representation. This is "untyped".
return 'String';
}

@@ -127,3 +133,4 @@

} else {
throw new Error(`Format '${definition.format}' in '${name}' is not supported`);
console.warn(`Format '${definition.format}' in '${name}' is not supported. It has been ignored.`);
return 'String';
}

@@ -149,9 +156,11 @@ }

// https://github.com/accordproject/concerto/issues/292
if (definition.anyOf){
const alternative = definition.anyOf || definition.oneOf;
if (alternative){
const keyword = definition.anyOf ? 'anyOf' : 'oneOf';
console.warn(
`Keyword 'anyOf' in definition '${name}' is not fully supported. Defaulting to first alternative.`
`Keyword '${keyword}' in definition '${name}' is not fully supported. Defaulting to first alternative.`
);
// Just choose the first item
return inferType(definition.anyOf[0], context);
return inferType(alternative[0], context);
}

@@ -260,5 +269,9 @@

inferConcept(definition, context);
} else if (definition.type === 'array') {
console.warn(
`Type keyword 'array' in definition '${name}' is not supported. It has been ignored.`
);
} else {
throw new Error(
`Type keyword '${definition.type}' in definition '${name}' not supported.`
`Type keyword '${definition.type}' in definition '${name}' is not supported.`
);

@@ -273,3 +286,3 @@ }

console.warn(
`Keyword(s) '${badKeys.join('\', \'')}' in definition '${name}' is not supported.`
`Keyword(s) '${badKeys.join('\', \'')}' in definition '${name}' are not supported.`
);

@@ -313,2 +326,3 @@ }

writer: new Writer(),
dictionary: new Set(),
};

@@ -319,12 +333,25 @@

// Add imports
// TODO we need some heuristic or metadata to identify Concerto dependencies rather than making assumptions
context.writer.writeLine(0, 'import org.accordproject.time.* from https://models.accordproject.org/time@0.2.0.cto');
context.writer.writeLine(0, '');
// Create definitions
const defs = schema.definitions || schema.$defs || schema?.components?.schemas ||[];
// Build a dictionary
context.dictionary.add(defaultType);
if (schema.$id) {
context.dictionary.add(normalizeType(parseIdUri(schema.$id).type));
}
Object.keys(defs).forEach((key) => {
context.parents.push(key);
const definition = defs[key];
const typeName = inferTypeName(definition, context, true);
if (context.dictionary.has(typeName)){
throw new Error(`Duplicate definition found for type '${typeName}'.`);
}
context.dictionary.add(typeName);
context.parents.pop();
});
// Visit each declaration
Object.keys(defs).forEach((key) => {
context.parents.push(key);
const definition = defs[key];
inferDeclaration(definition, context);

@@ -331,0 +358,0 @@ context.parents.pop();

{
"name": "@accordproject/concerto-tools",
"version": "3.0.1-20221116180840",
"version": "3.0.1-20221118155015",
"description": "Tools for the Concerto Modeling Language",

@@ -68,4 +68,4 @@ "homepage": "https://github.com/accordproject/concerto",

"dependencies": {
"@accordproject/concerto-core": "3.0.1-20221116180840",
"@accordproject/concerto-util": "3.0.1-20221116180840",
"@accordproject/concerto-core": "3.0.1-20221118155015",
"@accordproject/concerto-util": "3.0.1-20221118155015",
"ajv": "8.10.0",

@@ -72,0 +72,0 @@ "ajv-formats": "2.1.1",

/*!
* Concerto Tools v3.0.1-20221116180840
* Concerto Tools v3.0.1-20221118155015
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ * you may not use this file except in compliance with the License.

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc