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-20221111115247 to 3.0.1-20221116180840

types/lib/codegen/fromJsonSchema/cto/inferModel.d.ts

2

lib/codegen/codegen.js

@@ -31,2 +31,3 @@ /*

const ProtobufVisitor = require('./fromcto/protobuf/protobufvisitor');
const InferFromJsonSchema = require('./fromJsonSchema/cto/inferModel');

@@ -47,2 +48,3 @@ module.exports = {

ProtobufVisitor,
InferFromJsonSchema,
formats: {

@@ -49,0 +51,0 @@ golang: GoLangVisitor,

53

lib/codegen/fromJsonSchema/cto/inferModel.js

@@ -24,3 +24,2 @@ /*

const addFormats = require('ajv-formats');
// const fs = require('fs');

@@ -44,3 +43,9 @@ /**

function normalizeType(type) {
return capitalizeFirstLetter(type.replace(/[\s\\.-]/g, '_'));
return capitalizeFirstLetter(
type
// In CTO we only have one place to store definitions, so we flatten the storage structure from JSON Schema
.replace(/^#\/(definitions|\$defs|components\/schemas)\//, '')
// Replace delimiters with underscore
.replace(/[\s\\.-]/g, '_')
);
}

@@ -79,2 +84,6 @@

function inferTypeName(definition, context) {
if (definition.$ref) {
return normalizeType(definition.$ref);
}
const name = context.parents.peek();

@@ -104,3 +113,3 @@ const { type } = parseIdUri(definition.$id) ||

return normalizeType(definition.$ref.replace(/^#\/(definitions|\$defs)\//, ''));
return inferTypeName(definition, context);
}

@@ -138,2 +147,14 @@

}
// Hack until we support union types.
// https://github.com/accordproject/concerto/issues/292
if (definition.anyOf){
console.warn(
`Keyword 'anyOf' in definition '${name}' is not fully supported. Defaulting to first alternative.`
);
// Just choose the first item
return inferType(definition.anyOf[0], context);
}
throw new Error(`Unsupported definition: ${JSON.stringify(definition)}`);

@@ -247,6 +268,9 @@ }

// Find all keys that are not supported
const badKeys = Object.keys(definition).filter(key => !['enum', 'type'].includes(key));
throw new Error(
`Keyword(s) '${badKeys.join('\', \'')}' in definition '${name}' not supported.`
const badKeys = Object.keys(definition).filter(key =>
!['enum', 'type'].includes(key) &&
!key.startsWith('x-') // Ignore custom extensions
);
console.warn(
`Keyword(s) '${badKeys.join('\', \'')}' in definition '${name}' is not supported.`
);
}

@@ -265,3 +289,3 @@ }

let ajv = new Ajv2019({ strict: true })
let ajv = new Ajv2019({ strict: false })
.addMetaSchema(draft6MetaSchema)

@@ -271,5 +295,9 @@ .addMetaSchema(draft7MetaSchema);

if (schemaVersion && schemaVersion.startsWith('https://json-schema.org/draft/2020-12/schema')) {
ajv = new Ajv2020({ strict: true });
ajv = new Ajv2020({ strict: false });
}
if (schemaVersion && schemaVersion.startsWith('https://json-schema.org/draft/2020-12/schema')) {
ajv = new Ajv2020({ strict: false });
}
const { namespace, type } = parseIdUri(schema.$id) ||

@@ -298,3 +326,3 @@ { namespace: defaultNamespace, type: defaultType };

// Create definitions
const defs = schema.definitions || schema.$defs || [];
const defs = schema.definitions || schema.$defs || schema?.components?.schemas ||[];
Object.keys(defs).forEach((key) => {

@@ -315,9 +343,2 @@ context.parents.push(key);

// Prototype CLI tool
// usage: node lib/codegen/fromJsonSchema/cto/inferModel.js MyJsonSchema.json namespace RootType
// if (!module.parent) {
// const schema = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
// console.log(inferModelFile(process.argv[3], process.argv[4], schema));
// }
module.exports = inferModelFile;
{
"name": "@accordproject/concerto-tools",
"version": "3.0.1-20221111115247",
"version": "3.0.1-20221116180840",
"description": "Tools for the Concerto Modeling Language",

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

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

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

@@ -15,2 +15,3 @@ export var CodeGen: {

ProtobufVisitor: typeof import("./lib/codegen/fromcto/protobuf/protobufvisitor");
InferFromJsonSchema: typeof import("./lib/codegen/fromJsonSchema/cto/inferModel");
formats: {

@@ -17,0 +18,0 @@ golang: typeof import("./lib/codegen/fromcto/golang/golangvisitor");

@@ -14,2 +14,3 @@ import AbstractPlugin = require("./abstractplugin");

import ProtobufVisitor = require("./fromcto/protobuf/protobufvisitor");
import InferFromJsonSchema = require("./fromJsonSchema/cto/inferModel");
export declare namespace formats {

@@ -29,2 +30,2 @@ export { GoLangVisitor as golang };

}
export { AbstractPlugin, GoLangVisitor, JSONSchemaVisitor, XmlSchemaVisitor, PlantUMLVisitor, TypescriptVisitor, JavaVisitor, GraphQLVisitor, CSharpVisitor, ODataVisitor, MermaidVisitor, MarkdownVisitor, ProtobufVisitor };
export { AbstractPlugin, GoLangVisitor, JSONSchemaVisitor, XmlSchemaVisitor, PlantUMLVisitor, TypescriptVisitor, JavaVisitor, GraphQLVisitor, CSharpVisitor, ODataVisitor, MermaidVisitor, MarkdownVisitor, ProtobufVisitor, InferFromJsonSchema };

@@ -46,18 +46,23 @@ export = ProtobufVisitor;

/**
* Get the names of the children of a class.
* @param {string} className - the name of the class
* @param {Object[]} declarations - the declarations in scope
* @return {string[]} an array of the names of the children of the classes
* Recursively get the names of the subclasses of a class.
* @param {Object} classDeclaration - the class declaration object
* @return {String[]} an array of the names of the subclasses of the class
* @public
*/
public getChildrenOfClass(className: string, declarations: any[]): string[];
public getNamesOfSubclassesOfClassRecursively(classDeclaration: any): string[];
/**
* Check if a class has children.
* @param {string} className - the name of the class
* @param {Object[]} declarations - the declarations in scope
* @return {boolean} whether or not the class has children
* Recursively get the names of the subclasses of a class that are not abstract.
* @param {Object} classDeclaration - the class declaration object
* @return {String[]} an array of the names of the nonabstract subclasses of the class
* @public
*/
public doesClassHaveChildren(className: string, declarations: any[]): boolean;
public getNamesOfNonabstractSubclassesOfClassRecursively(classDeclaration: any): string[];
/**
* Recursively check if a class has subclasses.
* @param {Object} classDeclaration - the class declaration object
* @return {Boolean} whether or not the class has subclasses
* @public
*/
public doesClassHaveSubclassesRecursively(classDeclaration: any): boolean;
/**
* Visitor design pattern

@@ -72,3 +77,3 @@ * @param {Object} thing - the object being visited

* Visitor design pattern
* @param {ModelManager} modelManager - the object being visited
* @param {Object} modelManager - the object being visited
* @param {Object} parameters - the parameter

@@ -80,3 +85,3 @@ * @private

* Visitor design pattern
* @param {ModelFile} modelFile - the object being visited
* @param {Object} modelFile - the object being visited
* @param {Object} parameters - the parameter

@@ -88,3 +93,3 @@ * @private

* Visitor design pattern
* @param {AssetDeclaration} assetDeclaration - the object being visited
* @param {Object} assetDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -97,3 +102,3 @@ * @return {Object} the result of visiting or null

* Visitor design pattern
* @param {TransactionDeclaration} transactionDeclaration - the object being visited
* @param {Object} transactionDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -106,3 +111,3 @@ * @return {Object} the result of visiting or null

* Visitor design pattern
* @param {ConceptDeclaration} conceptDeclaration - the object being visited
* @param {Object} conceptDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -115,3 +120,3 @@ * @return {Object} the result of visiting or null

* Visitor design pattern
* @param {ClassDeclaration} classDeclaration - the object being visited
* @param {Object} classDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -124,3 +129,3 @@ * @return {Object} the result of visiting or null

* Visit a Concerto class
* @param {ClassDeclaration} classDeclaration - the Concerto class being visited
* @param {Object} classDeclaration - the Concerto class being visited
* @param {Object} parameters - the parameters

@@ -132,3 +137,3 @@ * @private

* Visitor design pattern
* @param {Field} field - the object being visited
* @param {Object} field - the object being visited
* @param {Object} parameters - the parameter

@@ -140,3 +145,3 @@ * @private

* Visitor design pattern
* @param {EnumDeclaration} enumDeclaration - the object being visited
* @param {Object} enumDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -148,3 +153,3 @@ * @private

* Visitor design pattern
* @param {EnumValueDeclaration} enumValueDeclaration - the object being visited
* @param {Object} enumValueDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -156,3 +161,3 @@ * @private

* Visitor design pattern
* @param {RelationshipDeclaration} relationshipDeclaration - the object being visited
* @param {Object} relationshipDeclaration - the object being visited
* @param {Object} parameters - the parameter

@@ -159,0 +164,0 @@ * @private

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

@@ -17,1 +17,3 @@ * you may not use this file except in compliance with the License.

/*! For license information please see concerto-util.js.LICENSE.txt */
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */

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