From c8abe1871c8122a2355d24c6667bf5a547a22676 Mon Sep 17 00:00:00 2001 From: jamieshorten Date: Tue, 26 May 2026 12:58:12 +0000 Subject: [PATCH] chore(actions): publish v4.1.2 to npm Signed-off-by: GitHub --- package-lock.json | 4 +- package.json | 2 +- .../codegen/fromcto/csharp/csharpvisitor.d.ts | 77 ++++++++++++++++++- .../fromcto/typescript/typescriptvisitor.d.ts | 16 ++++ 4 files changed, 94 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index bbd25355..ba2888f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@accordproject/concerto-codegen", - "version": "4.1.1", + "version": "4.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@accordproject/concerto-codegen", - "version": "4.1.1", + "version": "4.1.2", "license": "Apache-2.0", "dependencies": { "@openapi-contrib/openapi-schema-to-json-schema": "4.0.0", diff --git a/package.json b/package.json index d4473cb6..ac8b577b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@accordproject/concerto-codegen", - "version": "4.1.1", + "version": "4.1.2", "description": "Code Generation for the Concerto Modeling Language", "homepage": "https://github.com/accordproject/concerto", "engines": { diff --git a/types/lib/codegen/fromcto/csharp/csharpvisitor.d.ts b/types/lib/codegen/fromcto/csharp/csharpvisitor.d.ts index 59933c99..0cf943f4 100644 --- a/types/lib/codegen/fromcto/csharp/csharpvisitor.d.ts +++ b/types/lib/codegen/fromcto/csharp/csharpvisitor.d.ts @@ -64,7 +64,41 @@ declare class CSharpVisitor { * @return {Object} the result of visiting or null * @private */ - private visitScalarDeclarationField; + private visitScalarDeclaration; + /** + * Build the DataAnnotations attribute lines for a scalar declaration's validator. + * @param {ScalarDeclaration} scalarDeclaration - the scalar declaration + * @returns {string[]} attribute lines, empty if no validator + * @private + */ + private buildScalarValidatorLines; + /** + * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + private visitMapDeclaration; + /** + * Resolve the C# key and value types for a MapDeclaration. + * Handles primitives, scalars (via global using aliases and special UUID mapping), + * and concept types. + * @param {MapDeclaration} mapDeclaration - the map declaration to resolve types for + * @param {Object} parameters - the visitor parameters (used for PascalCase conversion) + * @returns {{ keyType: string, valueType: string }} the resolved C# key and value type strings + * @private + */ + private resolveMapTypes; + /** + * Resolve a single map key or value side to a C# type string. + * @param {MapKeyType|MapValueType} side - key or value side of the map + * @param {ModelFile} modelFile - the model file containing the map declaration + * @param {Object} parameters - the visitor parameters + * @returns {string} - the resolved type string for the map side + * @private + */ + private resolveMapSide; /** * Visitor design pattern * @param {Field} field - the object being visited @@ -87,10 +121,27 @@ declare class CSharpVisitor { * @param {Object} parameters - the parameter * @param {string} [externalFieldType] - the external field type like UUID (optional) * @param {bool} [isOptional] - the bool value indicating if external field type like UUID is optional (optional) + * @param {*} [scalarDefaultValue] - pre-resolved default value for scalar-typed fields (optional) * @return {Object} the result of visiting or null * @private */ private writeField; + /** + * Determines if a property should emit the C# `required` modifier. + * This centralizes required-emission decisions for fields and relationships. + * @param {Object} parameters - visitor parameters + * @param {Object} options - decision options + * @param {string} [options.nullableType] - nullable marker (`?`) when present + * @param {boolean} [options.hasDefault] - true when a default initializer is emitted + * @param {boolean} [options.isArray] - true when property is an array type + * @param {boolean} [options.isScalarAlias] - true for scalar alias value-type wrappers + * @param {boolean} [options.isPrimitive] - true for Concerto primitive fields + * @param {boolean} [options.isEnum] - true for enum fields + * @param {string} [options.csharpType] - resolved C# type string + * @returns {boolean} true if `required` should be emitted + * @private + */ + private shouldEmitRequired; /** * Visitor design pattern * @param {EnumValueDeclaration} enumValueDeclaration - the object being visited @@ -107,6 +158,26 @@ declare class CSharpVisitor { * @private */ private visitRelationship; + /** + * Determines whether a generated C# property type is a reference type. + * @param {string} csharpType - resolved C# type name + * @param {boolean} isArray - whether the property is an array + * @returns {boolean} true if reference type + * @private + */ + private isCSharpReferenceType; + /** + * Format a Concerto default value as a C# literal suitable for a property initializer. + * String values are quoted; scalar-typed fields wrap the literal in `new(...)`. + * @param {*} value - the raw default value from getDefaultValue() + * @param {string} concertoType - the underlying Concerto primitive type + * @param {boolean} isScalar - true when the property type is a scalar struct + * @param {Field} [field] - the field for context when handling enum defaults (optional) + * @param {string} [resolvedFieldType] - resolved C# property type used for enum qualification + * @returns {string|null} C# literal string, or null if no default + * @private + */ + private formatDefaultLiteral; /** * Ensures that a concerto property name is valid in CSharp * @param {string} access the CSharp field access @@ -117,9 +188,11 @@ declare class CSharpVisitor { * @param {string} nullableType the nullable expression ? * @param {string} getset the getter and setter declaration * @param {Object} [parameters] - the parameter + * @param {string} [resolvedType] - pre-built C# type string; when provided, skips toCSharpType + * @param {boolean} [emitRequired] - true to emit the C# `required` modifier * @returns {string} the property declaration */ - toCSharpProperty(access: string, parentName: string | undefined, propertyName: string, propertyType: string, array: string, nullableType: string, getset: string, parameters?: any): string; + toCSharpProperty(access: string, parentName: string | undefined, propertyName: string, propertyType: string, array: string, nullableType: string, getset: string, parameters?: any, resolvedType?: string, emitRequired?: boolean): string; /** * Converts a Concerto namespace to a CSharp namespace. If pascal casing is enabled, * each component of the namespace is pascal cased - for example org.example will diff --git a/types/lib/codegen/fromcto/typescript/typescriptvisitor.d.ts b/types/lib/codegen/fromcto/typescript/typescriptvisitor.d.ts index d12d2115..8f56a365 100644 --- a/types/lib/codegen/fromcto/typescript/typescriptvisitor.d.ts +++ b/types/lib/codegen/fromcto/typescript/typescriptvisitor.d.ts @@ -50,6 +50,14 @@ declare class TypescriptVisitor { * @private */ private visitClassDeclaration; + /** + * Visitor design pattern + * @param {Object} scalarDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + private visitScalarDeclaration; /** * Visitor design pattern * @param {Field} field - the object being visited @@ -58,6 +66,14 @@ declare class TypescriptVisitor { * @private */ private visitField; + /** + * Visitor design pattern - handles fields whose type is a scalar declaration + * @param {Object} field - the scalar-typed field being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + private visitScalarField; /** * Visitor design pattern * @param {EnumValueDeclaration} enumValueDeclaration - the object being visited